Skip to content

Commit

Permalink
Merge pull request #65 from dubbo-x/master
Browse files Browse the repository at this point in the history
add double, int, long encode unit test
  • Loading branch information
wongoo authored Jun 13, 2019
2 parents feca15f + 1002151 commit a3fe917
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
5 changes: 5 additions & 0 deletions boolean_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ func TestBoolean(t *testing.T) {
testDecodeFramework(t, "replyFalse", false)
testDecodeFramework(t, "replyTrue", true)
}

func TestBooleanEncode(t *testing.T) {
testJavaDecode(t, "argFalse", false)
testJavaDecode(t, "argTrue", true)
}
16 changes: 16 additions & 0 deletions double_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,19 @@ func TestDouble(t *testing.T) {
testDecodeFramework(t, "replyDouble_m129_0", -129.0)
testDecodeFramework(t, "replyDouble_m32768_0", -32768.0)
}

func TestDoubleEncode(t *testing.T) {
testJavaDecode(t, "argDouble_0_0", 0.0)
testJavaDecode(t, "argDouble_0_001", 0.001)
testJavaDecode(t, "argDouble_1_0", 1.0)
testJavaDecode(t, "argDouble_127_0", 127.0)
testJavaDecode(t, "argDouble_128_0", 128.0)
testJavaDecode(t, "argDouble_2_0", 2.0)
testJavaDecode(t, "argDouble_3_14159", 3.14159)
testJavaDecode(t, "argDouble_32767_0", 32767.0)
testJavaDecode(t, "argDouble_65_536", 65.536)
testJavaDecode(t, "argDouble_m0_001", -0.001)
testJavaDecode(t, "argDouble_m128_0", -128.0)
testJavaDecode(t, "argDouble_m129_0", -129.0)
testJavaDecode(t, "argDouble_m32768_0", -32768.0)
}
19 changes: 19 additions & 0 deletions int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,22 @@ func TestInt(t *testing.T) {
testDecodeFramework(t, "replyInt_m16", int32(-16))
testDecodeFramework(t, "replyInt_m17", int32(-17))
}

func TestIntEncode(t *testing.T) {
testJavaDecode(t, "argInt_0", int32(0))
testJavaDecode(t, "argInt_0x30", int32(0x30))
testJavaDecode(t, "argInt_0x3ffff", int32(0x3ffff))
testJavaDecode(t, "argInt_0x40000", int32(0x40000))
testJavaDecode(t, "argInt_0x7ff", int32(0x7ff))
testJavaDecode(t, "argInt_0x7fffffff", int32(0x7fffffff))
testJavaDecode(t, "argInt_0x800", int32(0x800))
testJavaDecode(t, "argInt_1", int32(1))
testJavaDecode(t, "argInt_47", int32(47))
testJavaDecode(t, "argInt_m0x40000", int32(-0x40000))
testJavaDecode(t, "argInt_m0x40001", int32(-0x40001))
testJavaDecode(t, "argInt_m0x800", int32(-0x800))
testJavaDecode(t, "argInt_m0x80000000", int32(-0x80000000))
testJavaDecode(t, "argInt_m0x801", int32(-0x801))
testJavaDecode(t, "argInt_m16", int32(-16))
testJavaDecode(t, "argInt_m17", int32(-17))
}
20 changes: 20 additions & 0 deletions long_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,23 @@ func TestLong(t *testing.T) {
testDecodeFramework(t, "replyLong_m8", int64(-8))
testDecodeFramework(t, "replyLong_m9", int64(-9))
}

func TestLongEncode(t *testing.T) {
testJavaDecode(t, "argLong_0", int64(0))
testJavaDecode(t, "argLong_0x10", int64(0x10))
testJavaDecode(t, "argLong_0x3ffff", int64(0x3ffff))
testJavaDecode(t, "argLong_0x40000", int64(0x40000))
testJavaDecode(t, "argLong_0x7ff", int64(0x7ff))
testJavaDecode(t, "argLong_0x7fffffff", int64(0x7fffffff))
testJavaDecode(t, "argLong_0x800", int64(0x800))
testJavaDecode(t, "argLong_1", int64(1))
testJavaDecode(t, "argLong_15", int64(15))
testJavaDecode(t, "argLong_m0x40000", int64(-0x40000))
testJavaDecode(t, "argLong_m0x40001", int64(-0x40001))
testJavaDecode(t, "argLong_m0x800", int64(-0x800))
testJavaDecode(t, "argLong_m0x80000000", int64(-0x80000000))
testJavaDecode(t, "argLong_m0x80000001", int64(-0x80000001))
testJavaDecode(t, "argLong_m0x801", int64(-0x801))
testJavaDecode(t, "argLong_m8", int64(-8))
testJavaDecode(t, "argLong_m9", int64(-9))
}

0 comments on commit a3fe917

Please sign in to comment.