MCPcopy
hub / github.com/AlistGo/alist / TestEncodeElement

Function TestEncodeElement

server/webdav/internal/xml/marshal_test.go:1395–1411  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1393}}
1394
1395func TestEncodeElement(t *testing.T) {
1396 for idx, test := range encodeElementTests {
1397 var buf bytes.Buffer
1398 enc := NewEncoder(&buf)
1399 err := enc.EncodeElement(test.value, test.start)
1400 if err != nil {
1401 t.Fatalf("enc.EncodeElement: %v", err)
1402 }
1403 err = enc.Flush()
1404 if err != nil {
1405 t.Fatalf("enc.Flush: %v", err)
1406 }
1407 if got, want := buf.String(), test.expectXML; got != want {
1408 t.Errorf("#%d(%s): EncodeElement(%#v, %#v):\nhave %#q\nwant %#q", idx, test.desc, test.value, test.start, got, want)
1409 }
1410 }
1411}
1412
1413func BenchmarkMarshal(b *testing.B) {
1414 b.ReportAllocs()

Callers

nothing calls this directly

Calls 4

EncodeElementMethod · 0.95
FlushMethod · 0.95
NewEncoderFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected