mirror of https://bitbucket.org/ausocean/av.git
stream/mts/meta/meta_test.go: using table of tests for TestReadFrom
This commit is contained in:
parent
f96f761b2f
commit
66a2325dcb
|
@ -151,20 +151,28 @@ func TestEncode(t *testing.T) {
|
||||||
// from a string of metadata using the ReadFrom func.
|
// from a string of metadata using the ReadFrom func.
|
||||||
func TestReadFrom(t *testing.T) {
|
func TestReadFrom(t *testing.T) {
|
||||||
tstMeta := append([]byte{0x00, 0x10, 0x00, 0x12}, "loc=a,b,c\tts=12345"...)
|
tstMeta := append([]byte{0x00, 0x10, 0x00, 0x12}, "loc=a,b,c\tts=12345"...)
|
||||||
got, err := ReadFrom([]byte(tstMeta), "loc")
|
|
||||||
|
tests := []struct {
|
||||||
|
key string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"loc",
|
||||||
|
"a,b,c",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ts",
|
||||||
|
"12345",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
got, err := ReadFrom([]byte(tstMeta), test.key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected err: %v\n", err)
|
t.Errorf("Unexpected err: %v\n", err)
|
||||||
}
|
}
|
||||||
want := "a,b,c"
|
if got != test.want {
|
||||||
if got != want {
|
t.Errorf("Did not get expected out. \nGot : %v, \nwant: %v\n", got, test.want)
|
||||||
t.Errorf("Did not get expected out. \nGot : %v, \nwant: %v\n", got, want)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if got, err = ReadFrom([]byte(tstMeta), "ts"); err != nil {
|
|
||||||
t.Errorf("Unexpected err: %v\n", err)
|
|
||||||
}
|
|
||||||
want = "12345"
|
|
||||||
if got != want {
|
|
||||||
t.Errorf("Did not get expected out. \nGot : %v, \nwant: %v\n", got, want)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue