package frameproto import ( "testing" "io" "strings" ) func TestWriteSkeleFrame(t *testing.T) { tests := []struct{ Head string Expected string }{ { Head: "", Expected: ``+"\n"+ ``+"\n"+ `
`+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n", }, { Head: ``+"\n", Expected: ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n", }, { Head: ``+"\n", Expected: ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n", }, { Head: ``+"\n"+ ``+"\n"+ ``+"\n", Expected: ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n"+ ``+"\n", }, } for testNumber, test := range tests { var buffer strings.Builder WriteSkeleFrame(&buffer, func(writer io.Writer)error { io.WriteString(writer, test.Head) return nil }) expected := test.Expected actual := buffer.String() if expected != actual { t.Errorf("For test #%d, ", testNumber) t.Logf("EXPECTED:\n%s", expected) t.Logf("ACTUAL:\n%s", actual) t.Logf("EXPECTED: %q", expected) t.Logf("ACTUAL: %q", actual) t.Logf("HEAD:\n%s", test.Head) t.Logf("HEAD: %q", test.Head) continue } } }