MCPcopy Create free account
hub / github.com/google/nftables / TestAlignedBuffPutNullTerminatedString

Function TestAlignedBuffPutNullTerminatedString

alignedbuff/alignedbuff_test.go:272–302  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

270}
271
272func TestAlignedBuffPutNullTerminatedString(t *testing.T) {
273 b0 := New()
274 b0.PutUint8(0x42)
275 b0.PutString("test" + "\x00")
276
277 b := NewWithData(b0.data)
278
279 v, err := b.Uint8()
280 if v != 0x42 || err != nil {
281 t.Fatalf("unaligment read failed")
282 }
283 tests := []struct {
284 name string
285 v string
286 err error
287 }{
288 {
289 name: "first read",
290 v: "test",
291 err: nil,
292 },
293 }
294
295 for _, tt := range tests {
296 v, err := b.String()
297 if v != tt.v || err != tt.err {
298 t.Errorf("expected: %#v %#v, got: %#v, %#v",
299 tt.v, tt.err, v, err)
300 }
301 }
302}
303
304func TestAlignedBuffPutString(t *testing.T) {
305 b0 := New()

Callers

nothing calls this directly

Calls 6

NewWithDataFunction · 0.85
PutUint8Method · 0.80
PutStringMethod · 0.80
Uint8Method · 0.80
StringMethod · 0.80
NewFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…