mirror of https://bitbucket.org/ausocean/av.git
62 lines
1.8 KiB
Go
62 lines
1.8 KiB
Go
/*
|
|
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
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
|
*/
|
|
|
|
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,
|
|
}
|
|
|
|
ts, err := ParseTimestamp(report)
|
|
if err != nil {
|
|
t.Fatalf("did not expect error: %v", err)
|
|
}
|
|
|
|
if ts.Seconds != expectedMSW {
|
|
t.Errorf("most significant word of timestamp is not what's expected. \nGot: %v\n Want: %v\n", ts.Seconds, int64(expectedMSW))
|
|
}
|
|
|
|
if ts.Fraction != expectedLSW {
|
|
t.Errorf("least significant word of timestamp is not what's expected. \nGot: %v\n Want: %v\n", ts.Fraction, int64(expectedLSW))
|
|
}
|
|
}
|