-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_test.go
More file actions
33 lines (29 loc) · 806 Bytes
/
string_test.go
File metadata and controls
33 lines (29 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package lexy_test
import (
"testing"
"github.com/phiryll/lexy"
"github.com/stretchr/testify/assert"
)
func TestString(t *testing.T) {
t.Parallel()
assert.True(t, lexy.String().RequiresTerminator())
assert.False(t, lexy.TerminatedString().RequiresTerminator())
testCodec(t, lexy.String(), []testCase[string]{
{"empty", "", []byte{}},
{"a", "a", []byte{'a'}},
{"xyz", "xyz", []byte{'x', 'y', 'z'}},
{"⌘", "⌘", []byte{0xE2, 0x8C, 0x98}},
})
}
func TestCastString(t *testing.T) {
t.Parallel()
type myString string
codec := lexy.CastString[myString]()
assert.True(t, codec.RequiresTerminator())
testCodec(t, codec, []testCase[myString]{
{"empty", "", []byte{}},
{"a", "a", []byte{'a'}},
{"xyz", "xyz", []byte{'x', 'y', 'z'}},
{"⌘", "⌘", []byte{0xE2, 0x8C, 0x98}},
})
}