-
Notifications
You must be signed in to change notification settings - Fork 3
/
bn_test.go
43 lines (32 loc) · 1.09 KB
/
bn_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package otr4
import (
"math/big"
. "gopkg.in/check.v1"
)
func (s *OTR4Suite) Test_BigIntAddition(c *C) {
result := add(big.NewInt(7), big.NewInt(3))
c.Assert(result, DeepEquals, big.NewInt(10))
result = add(big.NewInt(0), big.NewInt(0))
c.Assert(result, DeepEquals, big.NewInt(0))
}
func (s *OTR4Suite) Test_BigIntSubtraction(c *C) {
// XXX: this fails when the result is zero
result := sub(big.NewInt(7), big.NewInt(3))
c.Assert(result, DeepEquals, big.NewInt(4))
}
func (s *OTR4Suite) Test_BigIntLessOrEqualThan(c *C) {
result := lessOrEqual(big.NewInt(7), big.NewInt(13))
c.Assert(result, Equals, true)
result = lessOrEqual(big.NewInt(7), big.NewInt(7))
c.Assert(result, Equals, true)
result = lessOrEqual(big.NewInt(7), big.NewInt(3))
c.Assert(result, Equals, false)
}
func (s *OTR4Suite) Test_BigIntGreatOrEqualThan(c *C) {
result := greatOrEqual(big.NewInt(7), big.NewInt(3))
c.Assert(result, Equals, true)
result = greatOrEqual(big.NewInt(7), big.NewInt(7))
c.Assert(result, Equals, true)
result = greatOrEqual(big.NewInt(3), big.NewInt(7))
c.Assert(result, Equals, false)
}