| 1234567891011121314151617181920212223242526272829303132333435363738 |
- package clt_client
- import (
- "bytes"
- "fmt"
- "testing"
- )
- //func SetUp() func() {
- // fmt.Printf("生成固件")
- // //清除固件
- // return func() {
- // fmt.Printf("清除!")
- // }
- //}
- func TestNewPVsn(t *testing.T) {
- pvs := []Programm{
- {Type: "2", Name: "p1", ImageInfo: ImageInfo{[]string{"http://110.40.223.170:9000/picture-100000/user/ct.jpg"}, "", InEffect{Type: "", Time: ""}}},
- {Type: "2", Name: "p2", ImageInfo: ImageInfo{[]string{"http://110.40.223.170:9000/picture-100000/user/ct.jpg", "http://110.40.223.170:9000/picture-100000/user/ct1.jpg"}, "5000", InEffect{Type: "2", Time: "1000"}}},
- }
- source := []struct {
- p Programm
- expectation string
- }{
- {pvs[0], "{\"Programs\":{\"Program\":{\"Pages\":[{\"Regions\":[{\"Layer\":1,\"Rect\":{\"X\":\"0\",\"Y\":\"0\",\"Width\":\"128\",\"Height\":\"256\",\"BorderWidth\":\"0\",\"BorderColor\":\"0xFFFFFF00\"},\"Items\":[{\"Type\":\"2\",\"Volume\":\"\",\"Duration\":\"\",\"FileSource\":{\"IsRelative\":\"1\",\"FilePath\":\".\\\\p1.files\\\\ct.jpg\"},\"ReserveAS\":\"\",\"inEffect\":{\"Type\":\"\",\"Time\":\"\"},\"URL\":\"\"}]}]}]}}}"},
- {pvs[1], "{\"Programs\":{\"Program\":{\"Pages\":[{\"Regions\":[{\"Layer\":1,\"Rect\":{\"X\":\"0\",\"Y\":\"0\",\"Width\":\"128\",\"Height\":\"256\",\"BorderWidth\":\"0\",\"BorderColor\":\"0xFFFFFF00\"},\"Items\":[{\"Type\":\"2\",\"Volume\":\"\",\"Duration\":\"\",\"FileSource\":{\"IsRelative\":\"1\",\"FilePath\":\".\\\\p2.files\\\\ct.jpg\"},\"ReserveAS\":\"\",\"inEffect\":{\"Type\":\"\",\"Time\":\"\"},\"URL\":\"\"},{\"Type\":\"2\",\"Volume\":\"\",\"Duration\":\"5000\",\"FileSource\":{\"IsRelative\":\"1\",\"FilePath\":\".\\\\p2.files\\\\ct1.jpg\"},\"ReserveAS\":\"\",\"inEffect\":{\"Type\":\"2\",\"Time\":\"1000\"},\"URL\":\"\"}]}]}]}}}"},
- }
- for i, v := range source {
- vsn := NewPVsn(v.p)
- if bytes.Equal([]byte(v.expectation), vsn) {
- fmt.Printf("用例%d通过!\n", i)
- } else {
- t.Errorf("用例%d未通过!\n,预期:%s\n,实际:%s\n======\n", i, v.expectation, string(vsn))
- }
- }
- }
|