protocol_test.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package clt_client
  2. import (
  3. "bytes"
  4. "fmt"
  5. "testing"
  6. )
  7. //func SetUp() func() {
  8. // fmt.Printf("生成固件")
  9. // //清除固件
  10. // return func() {
  11. // fmt.Printf("清除!")
  12. // }
  13. //}
  14. func TestNewPVsn(t *testing.T) {
  15. pvs := []Programm{
  16. {Type: "2", Name: "p1", ImageInfo: ImageInfo{[]string{"http://110.40.223.170:9000/picture-100000/user/ct.jpg"}, "", InEffect{Type: "", Time: ""}}},
  17. {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"}}},
  18. }
  19. source := []struct {
  20. p Programm
  21. expectation string
  22. }{
  23. {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\":\"\"}]}]}]}}}"},
  24. {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\":\"\"}]}]}]}}}"},
  25. }
  26. for i, v := range source {
  27. vsn := NewPVsn(v.p)
  28. if bytes.Equal([]byte(v.expectation), vsn) {
  29. fmt.Printf("用例%d通过!\n", i)
  30. } else {
  31. t.Errorf("用例%d未通过!\n,预期:%s\n,实际:%s\n======\n", i, v.expectation, string(vsn))
  32. }
  33. }
  34. }