fix: 修复pkg/nazareflect包中无符号整型比较逻辑并添加测试用例

pull/5/head
Etuloser 3 years ago
parent 78368b26cc
commit ac05140b50

@ -60,7 +60,7 @@ func EqualInteger(a, b interface{}) bool {
buv, buok := tryUint(b)
if auok && buok { // a,b都是无符号整型 (1)
return auv == auv
return auv == buv
}
if aiok && buok { // a是有符号整型b是无符号整型 (1)
if aiv < 0 {

@ -57,6 +57,7 @@ func TestEqualInteger(t *testing.T) {
sure(t, !EqualInteger(1, 0))
sure(t, !EqualInteger(0, "aaa"))
sure(t, !EqualInteger(-1, uint(0)))
sure(t, !EqualInteger(int32(0), int16(1)))
sure(t, !EqualInteger(uint16(0), int32(-1)))
}

Loading…
Cancel
Save