simplify testing

This commit is contained in:
v2ray committed 2016-05-24 21:55:46 +02:00
1 parent 3582b9d869
commit fc63f0432c
99 files changed
+726 -817

No files matched your search

+4 -5
View File
@@ -7,12 +7,11 @@ import (
"testing"
. "github.com/v2ray/v2ray-core/common/protocol"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
)
func TestUserParsing(t *testing.T) {
v2testing.Current(t)
assert := assert.On(t)
user := new(User)
err := json.Unmarshal([]byte(`{
@@ -22,12 +21,12 @@ func TestUserParsing(t *testing.T) {
"alterId": 100
}`), user)
assert.Error(err).IsNil()
assert.String(user.ID).Equals("96edb838-6d68-42ef-a933-25f7ac3a9d09")
assert.String(user.ID.String()).Equals("96edb838-6d68-42ef-a933-25f7ac3a9d09")
assert.Byte(byte(user.Level)).Equals(1)
}
func TestInvalidUserJson(t *testing.T) {
v2testing.Current(t)
assert := assert.On(t)
user := new(User)
err := json.Unmarshal([]byte(`{"id": 1234}`), user)
@@ -35,7 +34,7 @@ func TestInvalidUserJson(t *testing.T) {
}
func TestInvalidIdJson(t *testing.T) {
v2testing.Current(t)
assert := assert.On(t)
user := new(User)
err := json.Unmarshal([]byte(`{"id": "1234"}`), user)