@@ -185,4 +185,41 @@ describe('Uint64', () => {
185185 expect ( result ) . to . be . true ;
186186 } ) ;
187187 } ) ;
188+
189+ describe ( 'Operation' , ( ) => {
190+ it ( 'should return added value' , ( ) => {
191+ const value = UInt64 . fromUint ( 100 ) ;
192+ const other = UInt64 . fromUint ( 1 ) ;
193+ const result = value . add ( other ) ;
194+ expect ( result . compact ( ) ) . to . be . equal ( 101 ) ;
195+ } ) ;
196+ it ( 'should return added value' , ( ) => {
197+ const value = UInt64 . fromUint ( 0 ) ;
198+ const other = UInt64 . fromUint ( 0 ) ;
199+ const result = value . add ( other ) ;
200+ expect ( result . compact ( ) ) . to . be . equal ( 0 ) ;
201+ } ) ;
202+
203+ it ( 'should return substract value' , ( ) => {
204+ const value = UInt64 . fromUint ( 100 ) ;
205+ const other = UInt64 . fromUint ( 1 ) ;
206+ const result = value . subtract ( other ) ;
207+ expect ( result . compact ( ) ) . to . be . equal ( 99 ) ;
208+ } ) ;
209+
210+ it ( 'should return substract value' , ( ) => {
211+ const value = UInt64 . fromUint ( 1 ) ;
212+ const other = UInt64 . fromUint ( 1 ) ;
213+ const result = value . subtract ( other ) ;
214+ expect ( result . compact ( ) ) . to . be . equal ( 0 ) ;
215+ } ) ;
216+
217+ it ( 'should return substract value' , ( ) => {
218+ const value = UInt64 . fromUint ( 100 ) ;
219+ const other = UInt64 . fromUint ( 1 ) ;
220+ expect ( ( ) => {
221+ other . subtract ( value ) ;
222+ } ) . to . throw ( Error , 'Unsigned substraction result cannot be negative.' ) ;
223+ } ) ;
224+ } ) ;
188225} ) ;
0 commit comments