@@ -8,12 +8,14 @@ import (
88
99//I took these from hexdumps
1010var typeSix = []byte {0x06 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x9E , 0x40 }
11+ var typeFive = []byte {0x05 , 0x2E , 00 , 00 , 00 }
1112var typeFour = []byte {0x04 , 0x05 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }
1213var typeThree = []byte {0x03 , 0x1E , 00 , 00 , 00 }
1314
1415const typeSixDecoded float64 = 1920
15- const typeThreeDecoded uint32 = 30
16+ const typeFiveDecoded uint32 = 46
1617const typeFourDecoded uint64 = 5
18+ const typeThreeDecoded uint32 = 30
1719
1820func TestErrors (t * testing.T ) {
1921 var broken []byte
@@ -36,6 +38,12 @@ func TestErrors(t *testing.T) {
3638 broken [0 ] = 56
3739 _ , err = common .NewNSNumber (broken )
3840 assert .Error (t , err )
41+
42+ broken = make ([]byte , len (typeFive ))
43+ copy (broken , typeFive )
44+ broken [0 ] = 134
45+ _ , err = common .NewNSNumber (broken )
46+ assert .Error (t , err )
3947}
4048
4149func TestNumberValue (t * testing.T ) {
@@ -45,12 +53,17 @@ func TestNumberValue(t *testing.T) {
4553 assert .Equal (t , typeSixDecoded , float64Num .FloatValue )
4654 }
4755
56+ uint32Num , err := common .NewNSNumber (typeFive )
57+ if assert .NoError (t , err ) {
58+ assert .Equal (t , typeFiveDecoded , uint32Num .IntValue )
59+ }
60+
4861 uint64Num , err := common .NewNSNumber (typeFour )
4962 if assert .NoError (t , err ) {
5063 assert .Equal (t , typeFourDecoded , uint64Num .LongValue )
5164 }
5265
53- uint32Num , err : = common .NewNSNumber (typeThree )
66+ uint32Num , err = common .NewNSNumber (typeThree )
5467 if assert .NoError (t , err ) {
5568 assert .Equal (t , typeThreeDecoded , uint32Num .IntValue )
5669 }
0 commit comments