@@ -53,13 +53,20 @@ contract('SafeMath', function () {
53
53
( await this . safeMath . mul ( a , b ) ) . should . be . bignumber . equal ( a . times ( b ) ) ;
54
54
} ) ;
55
55
56
- it ( 'handles a zero product correctly' , async function ( ) {
56
+ it ( 'handles a zero product correctly (first number as zero) ' , async function ( ) {
57
57
const a = new BigNumber ( 0 ) ;
58
58
const b = new BigNumber ( 5678 ) ;
59
59
60
60
( await this . safeMath . mul ( a , b ) ) . should . be . bignumber . equal ( a . times ( b ) ) ;
61
61
} ) ;
62
62
63
+ it ( 'handles a zero product correctly (second number as zero)' , async function ( ) {
64
+ const a = new BigNumber ( 5678 ) ;
65
+ const b = new BigNumber ( 0 ) ;
66
+
67
+ ( await this . safeMath . mul ( a , b ) ) . should . be . bignumber . equal ( a . times ( b ) ) ;
68
+ } ) ;
69
+
63
70
it ( 'throws a revert error on multiplication overflow' , async function ( ) {
64
71
const a = MAX_UINT256 ;
65
72
const b = new BigNumber ( 2 ) ;
@@ -76,6 +83,20 @@ contract('SafeMath', function () {
76
83
( await this . safeMath . div ( a , b ) ) . should . be . bignumber . equal ( a . div ( b ) ) ;
77
84
} ) ;
78
85
86
+ it ( 'divides zero correctly' , async function ( ) {
87
+ const a = new BigNumber ( 0 ) ;
88
+ const b = new BigNumber ( 5678 ) ;
89
+
90
+ ( await this . safeMath . div ( a , b ) ) . should . be . bignumber . equal ( 0 ) ;
91
+ } ) ;
92
+
93
+ it ( 'returns complete number result on non-even division' , async function ( ) {
94
+ const a = new BigNumber ( 7000 ) ;
95
+ const b = new BigNumber ( 5678 ) ;
96
+
97
+ ( await this . safeMath . div ( a , b ) ) . should . be . bignumber . equal ( 1 ) ;
98
+ } ) ;
99
+
79
100
it ( 'throws a revert error on zero division' , async function ( ) {
80
101
const a = new BigNumber ( 5678 ) ;
81
102
const b = new BigNumber ( 0 ) ;
0 commit comments