MCPcopy
hub / github.com/lmorg/murex / TestLazyStringGet

Function TestLazyStringGet

utils/mxjson/structs_test.go:99–136  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

97}
98
99func TestLazyStringGet(t *testing.T) {
100 nums := []string{
101 "zero.",
102 "one.",
103 "two.",
104 "three.",
105 "four.",
106 "five.",
107 "six.",
108 "seven.",
109 "eight.",
110 "nine.",
111 }
112
113 count.Tests(t, 1)
114
115 s := newStr()
116 max := cap(s.b)
117
118 for i := 0; i < max; i++ {
119 ints := strconv.Itoa(i)
120 var new string
121 for _, b := range []byte(ints) {
122 new += nums[b-48] // 48 == ASCII code for 0
123 }
124
125 for _, b := range []byte(new) {
126 s.Append(b)
127 }
128
129 b := s.Get()
130 if new != string(b) {
131 t.Errorf("String mismatch in test %d", i)
132 t.Logf(" Expected: %s", new)
133 t.Logf(" Actual: %s", string(b))
134 }
135 }
136}
137
138func TestLazyStringStringer(t *testing.T) {
139 nums := []string{

Callers

nothing calls this directly

Calls 4

TestsFunction · 0.92
newStrFunction · 0.85
AppendMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected