(t *testing.T)
| 59 | } |
| 60 | |
| 61 | func TestParseParams(t *testing.T) { |
| 62 | testByteArray := []byte("HelloWorld") |
| 63 | testByteArrayParam := hex.EncodeToString(testByteArray) |
| 64 | rawParamStr := "bytearray:" + testByteArrayParam + ",string:foo,[int:0,[bool:true,string:bar],bool:false]" |
| 65 | params, err := ParseParams(rawParamStr) |
| 66 | if err != nil { |
| 67 | t.Errorf("TestParseParams error:%s", err) |
| 68 | return |
| 69 | } |
| 70 | data, err := json.Marshal(params) |
| 71 | if err != nil { |
| 72 | t.Errorf("json.Marshal error:%s", err) |
| 73 | return |
| 74 | } |
| 75 | fmt.Printf("%s\n", data) |
| 76 | |
| 77 | expect := []interface{}{testByteArray, "foo", []interface{}{0, []interface{}{true, "bar"}, false}} |
| 78 | ok, err := arrayEqual(params, expect) |
| 79 | if err != nil { |
| 80 | t.Errorf("TestParseParams error:%s", err) |
| 81 | return |
| 82 | } |
| 83 | if !ok { |
| 84 | t.Errorf("TestParseParams faild, res:%s != %s", params, expect) |
| 85 | return |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | func arrayEqual(a1, a2 []interface{}) (bool, error) { |
| 90 | data1, err := json.Marshal(a1) |
nothing calls this directly
no test coverage detected