|
| 1 | +import test from 'ava' ; |
| 2 | + |
| 3 | +import { ZZ , ZeroDivisionError } from '../../../src' ; |
| 4 | + |
| 5 | +function macro ( t , a , b , q ) { |
| 6 | + const A = ZZ.from(a) ; |
| 7 | + const B = ZZ.from(b) ; |
| 8 | + const Q = A.divide_knowing_divisible_by(B) ; |
| 9 | + |
| 10 | + t.is(q.toString(), Q.toString()) ; |
| 11 | + t.is(a.toString(), A.toString()) ; |
| 12 | + t.is(b.toString(), B.toString()) ; |
| 13 | +} |
| 14 | + |
| 15 | +macro.title = ( providedTitle , a , b , q , r ) => `${a} divide_knowing_divisible_by ${b} = ${q}` ; |
| 16 | + |
| 17 | +test(macro, 3, 1, 3) ; |
| 18 | +test(macro, '123', 3, 41) ; |
| 19 | +test(macro, 15, 5, 3) ; |
| 20 | +test(macro, 17, 17, 1) ; |
| 21 | +test(macro, 18, 6, 3) ; |
| 22 | + |
| 23 | +test(macro, |
| 24 | + '-7244741064308655582166346607524458070674504593046523339005489416933659838435253944103203222937740081100645849', |
| 25 | + '10633823966279326983230456482242756607', |
| 26 | + '-681292175541205709486531011694243236571309860372760091522256581907552807', |
| 27 | +) |
| 28 | + |
| 29 | +test(macro, |
| 30 | + '-7244741064308655582166346607524458070674504593046523339005489416933659838435253944103203222937740081100645849', |
| 31 | + '-681292175541205709486531011694243236571309860372760091522256581907552807', |
| 32 | + '10633823966279326983230456482242756607', |
| 33 | +) |
| 34 | + |
| 35 | +test(macro, |
| 36 | + '7244741064308655582166346607524458070674504593046523339005489416933659838435253944103203222937740081100645849', |
| 37 | + '-10633823966279326983230456482242756607', |
| 38 | + '-681292175541205709486531011694243236571309860372760091522256581907552807', |
| 39 | +) |
| 40 | + |
| 41 | +test(macro, |
| 42 | + '7244741064308655582166346607524458070674504593046523339005489416933659838435253944103203222937740081100645849', |
| 43 | + '-681292175541205709486531011694243236571309860372760091522256581907552807', |
| 44 | + '-10633823966279326983230456482242756607', |
| 45 | +) |
0 commit comments