Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit 8659709

Browse files
committed
doc: better wording though review
Signed-off-by: Alexander Bezzubov <[email protected]>
1 parent c521aea commit 8659709

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

driver/normalizer/strconv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const lowerhex = "0123456789abcdef"
9191

9292
// quoteSingle is the same as strconv.Quote, but uses ' as a quote.
9393
// quoteSingle(unquoteSingle(s)) may not result in exact same bytes as s,
94-
// due to quoteSingle always opting in for hex escape sequnece format.
94+
// because quoteSingle always uses the hex escape sequence format.
9595
func quoteSingle(s string) string {
9696
const quote = '\''
9797
buf := make([]byte, 0, 3*len(s)/2)

driver/normalizer/strconv_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ const msg = "test case %d failed"
1414
var testCasesUnquote = []struct {
1515
quoted string
1616
unquoted string
17-
// isn't empty only for cases where quote(unqote(s)) != s
18-
// e.g when we loose the informaiton wich original escape sequence was used
17+
// If this is non-empty it means that quoteing back unqoted string does not
18+
// produce same result bit-wise.
19+
// This happens when we lose the information about original escape sequence (octal, hex)
1920
// Golang unquote() defaults to hex format, so it's used as canonical one.
2021
canonicalQuoted string
2122
}{
@@ -31,7 +32,6 @@ func TestUnquoteSingle(t *testing.T) {
3132
for i, test := range testCasesUnquote {
3233
s, err := unquoteSingle(test.quoted)
3334
require.NoError(t, err, msg, i)
34-
3535
require.Equal(t, test.unquoted, s, msg, i)
3636
}
3737
}
@@ -51,15 +51,14 @@ func TestUnquoteSingleAndQuoteBack(t *testing.T) {
5151
}
5252

5353
func assertEquals(t *testing.T, quoted, actual string, i int) {
54-
success := assert.Equal(t, quoted, actual, msg, i)
55-
if !success {
54+
if !assert.Equal(t, quoted, actual, msg, i) {
5655
printDebug(t, quoted, actual)
5756
t.FailNow()
5857
}
5958
}
6059

6160
func printDebug(t *testing.T, quoted, actual string) {
62-
t.Logf("\texepcted: len=%d", len(quoted))
61+
t.Logf("\texpected: len=%d", len(quoted))
6362
for _, c := range quoted {
6463
t.Logf("%x - %#U", c, c)
6564
}
@@ -78,6 +77,8 @@ func BenchmarkReplacingNullEscape_Iterative(b *testing.B) {
7877
}
7978
}
8079

80+
// replaceEscapedMaybeIter is alternative implementation of replaceEscapedMaybe
81+
// It is only used in benchmark tests for performance comparison.
8182
func replaceEscapedMaybeIter(s string, old, new rune) string {
8283
var runeTmp [utf8.UTFMax]byte
8384
n := utf8.EncodeRune(runeTmp[:], new)
@@ -124,7 +125,8 @@ func BenchmarkReplacingNullEscape_Regexp(b *testing.B) {
124125

125126
var re = regexp.MustCompile(`\\0([^0-9]|$)`)
126127

127-
// replaceEscapedMaybeRegexp is very simple, but slower alternative to normalizer.replaceEscapedMaybe
128+
// replaceEscapedMaybeRegexp is alternative implementation of replaceEscapedMaybe
129+
// It is only used in benchmark tests for performance comparison.
128130
func replaceEscapedMaybeRegexp(s string) string {
129131
return re.ReplaceAllString(s, "\x00$1")
130132
}

0 commit comments

Comments
 (0)