1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-10-14 15:03:39 -04:00
v2fly/tools/conf/json/reader_test.go

51 lines
844 B
Go
Raw Normal View History

2016-12-14 17:51:03 -05:00
package json_test
import (
"testing"
"bytes"
2016-12-15 09:53:23 -05:00
2016-12-14 17:51:03 -05:00
"v2ray.com/core/testing/assert"
. "v2ray.com/core/tools/conf/json"
)
func TestReader(t *testing.T) {
assert := assert.On(t)
data := []struct {
input string
output string
}{
{
`
content #comment 1
#comment 2
content 2`,
`
content content 2`},
{`content`, `content`},
{" ", " "},
{`con/*abcd*/tent`, "content"},
{`
text // adlkhdf /*
//comment adfkj
text 2*/`, `
text text 2*`},
{`"//"content`, `"//"content`},
{`abcd'//'abcd`, `abcd'//'abcd`},
2016-12-14 18:00:44 -05:00
{`"\""`, `"\""`},
2016-12-15 09:53:23 -05:00
{`\"/*abcd*/\"`, `\"\"`},
2016-12-14 17:51:03 -05:00
}
for _, testCase := range data {
reader := &Reader{
Reader: bytes.NewReader([]byte(testCase.input)),
}
actual := make([]byte, 1024)
n, err := reader.Read(actual)
assert.Error(err).IsNil()
assert.String(string(actual[:n])).Equals(testCase.output)
}
}