aboutsummaryrefslogtreecommitdiff
path: root/lib/bytes/bytes_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2019-06-14 19:02:22 +0700
committerShulhan <ms@kilabit.info>2019-06-14 19:02:22 +0700
commit8d5ffba2d9483f049385d37bc468f2a114548eb0 (patch)
treef545e93345f3c4273ec1b962f797bdcbc20dc80b /lib/bytes/bytes_test.go
parent381a0c6e6dfc702ffbbd398abaae356f4e075a0e (diff)
downloadpakakeh.go-8d5ffba2d9483f049385d37bc468f2a114548eb0.tar.xz
ascii: new library for working with ASCII characters
This library previously part of bytes package. To make it bytes package consistent (only working with slice of byte), we move all ASCII related constants, variables, and functions into new package.
Diffstat (limited to 'lib/bytes/bytes_test.go')
-rw-r--r--lib/bytes/bytes_test.go58
1 files changed, 2 insertions, 56 deletions
diff --git a/lib/bytes/bytes_test.go b/lib/bytes/bytes_test.go
index e5eb2ac4..938f4ca1 100644
--- a/lib/bytes/bytes_test.go
+++ b/lib/bytes/bytes_test.go
@@ -1,9 +1,9 @@
package bytes
import (
- "bytes"
"testing"
+ "github.com/shuLhan/share/lib/ascii"
"github.com/shuLhan/share/lib/test"
)
@@ -280,33 +280,6 @@ func TestSkipAfterToken(t *testing.T) {
}
}
-func TestToLower(t *testing.T) {
- cases := []struct {
- in []byte
- exp []byte
- }{{
- in: []byte("@ABCDEFG"),
- exp: []byte("@abcdefg"),
- }, {
- in: []byte("@ABCDEFG12345678"),
- exp: []byte("@abcdefg12345678"),
- }, {
- in: []byte("@ABCDEFGhijklmno12345678"),
- exp: []byte("@abcdefghijklmno12345678"),
- }, {
- in: []byte("@ABCDEFGhijklmnoPQRSTUVW12345678"),
- exp: []byte("@abcdefghijklmnopqrstuvw12345678"),
- }, {
- in: []byte("@ABCDEFGhijklmnoPQRSTUVWxyz{12345678"),
- exp: []byte("@abcdefghijklmnopqrstuvwxyz{12345678"),
- }}
-
- for _, c := range cases {
- ToLower(&c.in)
- test.Assert(t, "ToLower", c.exp, c.in, true)
- }
-}
-
func testTokenFind(t *testing.T, line, token []byte, startat int, exp []int) {
got := []int{}
tokenlen := len(token)
@@ -354,35 +327,8 @@ func TestInReplace(t *testing.T) {
}}
for _, c := range cases {
- got := InReplace([]byte(c.in), []byte(ASCIILettersNumber), '_')
+ got := InReplace([]byte(c.in), []byte(ascii.LettersNumber), '_')
test.Assert(t, "InReplace", c.exp, string(got), true)
}
}
-
-func BenchmarkToLowerStd(b *testing.B) {
- randomInput256 := Random([]byte(HexaLetters), 256)
-
- in := make([]byte, len(randomInput256))
- copy(in, randomInput256)
-
- b.ResetTimer()
-
- for x := 0; x < b.N; x++ {
- bytes.ToLower(in)
- }
-}
-
-func BenchmarkToLower(b *testing.B) {
- randomInput256 := Random([]byte(HexaLetters), 256)
-
- in := make([]byte, len(randomInput256))
- copy(in, randomInput256)
-
- b.ResetTimer()
-
- for x := 0; x < b.N; x++ {
- ToLower(&in)
- copy(in, randomInput256)
- }
-}