forked from mc2soft/mpd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpd_test.go
54 lines (41 loc) · 1.51 KB
/
mpd_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package mpd
import (
"io/ioutil"
"strings"
"testing"
. "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
type MPDSuite struct{}
var _ = Suite(&MPDSuite{})
func testUnmarshalMarshal(c *C, name string) {
expected, err := ioutil.ReadFile(name)
c.Assert(err, IsNil)
mpd := new(MPD)
err = mpd.Decode(expected)
c.Assert(err, IsNil)
obtained, err := mpd.Encode()
c.Assert(err, IsNil)
obtainedName := name + ".ignore"
err = ioutil.WriteFile(obtainedName, obtained, 0666)
c.Assert(err, IsNil)
// strip stupid XML rubish
expectedS := string(expected)
expectedS = strings.Replace(expectedS, `xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" `, ``, 1)
expectedS = strings.Replace(expectedS, `xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd" `, ``, 1)
obtainedSlice := strings.Split(strings.TrimSpace(string(obtained)), "\n")
expectedSlice := strings.Split(strings.TrimSpace(expectedS), "\n")
c.Check(obtainedSlice, HasLen, len(expectedSlice))
for i := range obtainedSlice {
c.Check(obtainedSlice[i], Equals, expectedSlice[i], Commentf("line %d", i+1))
}
}
func (s *MPDSuite) TestUnmarshalMarshalVod(c *C) {
testUnmarshalMarshal(c, "fixture_elemental_delta_vod.mpd")
}
func (s *MPDSuite) TestUnmarshalMarshalLive(c *C) {
testUnmarshalMarshal(c, "fixture_elemental_delta_live.mpd")
}
func (s *MPDSuite) TestUnmarshalMarshalLiveDelta161(c *C) {
testUnmarshalMarshal(c, "fixture_elemental_delta_1.6.1_live.mpd")
}