2019-04-16 10:15:44 +03:00
|
|
|
/*
|
|
|
|
NAME
|
|
|
|
parse_test.go
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
parse_test.go provides testing utilities for functionality found in parse.go.
|
|
|
|
|
|
|
|
AUTHORS
|
|
|
|
Saxon A. Nelson-Milton <saxon@ausocean.org>
|
|
|
|
|
|
|
|
LICENSE
|
|
|
|
This is Copyright (C) 2019 the Australian Ocean Lab (AusOcean)
|
|
|
|
|
|
|
|
It is free software: you can redistribute it and/or modify them
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
2019-04-21 18:04:03 +03:00
|
|
|
for more details.
|
2019-04-16 10:15:44 +03:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
|
|
|
*/
|
|
|
|
|
2019-04-12 11:32:27 +03:00
|
|
|
package rtcp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TestTimestamp checks that Timestamp correctly returns the most signicicant
|
|
|
|
// word, and least signiciant word, of a receiver report timestamp.
|
|
|
|
func TestTimestamp(t *testing.T) {
|
|
|
|
const expectedMSW = 2209003992
|
|
|
|
const expectedLSW = 1956821460
|
|
|
|
report := []byte{
|
|
|
|
0x80, 0xc8, 0x00, 0x06,
|
|
|
|
0x6f, 0xad, 0x40, 0xc6,
|
|
|
|
0x83, 0xaa, 0xb9, 0xd8, // Most significant word of timestamp (2209003992)
|
|
|
|
0x74, 0xa2, 0xb9, 0xd4, // Least significant word of timestamp (1956821460)
|
|
|
|
0x4b, 0x1c, 0x5a, 0xa5,
|
|
|
|
0x00, 0x00, 0x00, 0x66,
|
|
|
|
0x00, 0x01, 0xc2, 0xc5,
|
|
|
|
}
|
|
|
|
|
2019-04-21 18:04:03 +03:00
|
|
|
ts, err := Timestamp(report)
|
2019-04-12 11:32:27 +03:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("did not expect error: %v", err)
|
|
|
|
}
|
|
|
|
|
2019-04-23 07:55:22 +03:00
|
|
|
if ts.Seconds != expectedMSW {
|
|
|
|
t.Errorf("most significant word of timestamp is not what's expected. \nGot: %v\n Want: %v\n", ts.Seconds, expectedMSW)
|
2019-04-12 11:32:27 +03:00
|
|
|
}
|
|
|
|
|
2019-04-23 07:55:22 +03:00
|
|
|
if ts.Fraction != expectedLSW {
|
|
|
|
t.Errorf("least significant word of timestamp is not what's expected. \nGot: %v\n Want: %v\n", ts.Fraction, expectedLSW)
|
2019-04-12 11:32:27 +03:00
|
|
|
}
|
|
|
|
}
|