1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 18:17:52 -05:00
v2fly/common/serial/string_json_test.go
2016-02-04 17:45:16 +01:00

30 lines
580 B
Go

// +build json
package serial_test
import (
"encoding/json"
"testing"
. "github.com/v2ray/v2ray-core/common/serial"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
)
func TestInvalidStringLiteralJson(t *testing.T) {
v2testing.Current(t)
var s StringLiteral
err := json.Unmarshal([]byte("1"), &s)
assert.Error(err).IsNotNil()
}
func TestStringLiteralParsing(t *testing.T) {
v2testing.Current(t)
var s StringLiteral
err := json.Unmarshal([]byte("\"1\""), &s)
assert.Error(err).IsNil()
assert.String(s).Equals("1")
}