|
|
@@ -317,11 +317,31 @@ func TestWritePriority(t *testing.T) {
|
|
|
|
|
|
func TestWriteSettings(t *testing.T) {
|
|
|
fr, buf := testFramer()
|
|
|
- fr.WriteSettings(Setting{1, 2}, Setting{3, 4})
|
|
|
+ settings := []Setting{{1, 2}, {3, 4}}
|
|
|
+ fr.WriteSettings(settings...)
|
|
|
const wantEnc = "\x00\x00\f\x04\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x03\x00\x00\x00\x04"
|
|
|
if buf.String() != wantEnc {
|
|
|
t.Errorf("encoded as %q; want %q", buf.Bytes(), wantEnc)
|
|
|
}
|
|
|
+ f, err := fr.ReadFrame()
|
|
|
+ if err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+ sf, ok := f.(*SettingsFrame)
|
|
|
+ if !ok {
|
|
|
+ t.Fatalf("Got a %T; want a SettingsFrame", f)
|
|
|
+ }
|
|
|
+ var got []Setting
|
|
|
+ sf.ForeachSetting(func(s Setting) {
|
|
|
+ got = append(got, s)
|
|
|
+ valBack, ok := sf.Value(s.ID)
|
|
|
+ if !ok || valBack != s.Val {
|
|
|
+ t.Errorf("Value(%d) = %v, %v; want %v, true", valBack, ok)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if !reflect.DeepEqual(settings, got) {
|
|
|
+ t.Errorf("Read settings %+v != written settings %+v", got, settings)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
func TestWriteSettingsAck(t *testing.T) {
|