Denys Vlasenko | ee7f75d | 2017-04-09 21:18:43 +0200 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Copyright 2017 by Denys Vlasenko <vda.linux@googlemail.com> |
| 4 | # Licensed under GPLv2, see file LICENSE in this source tree. |
| 5 | |
| 6 | . ./testing.sh |
| 7 | |
| 8 | # testing "test name" "command" "expected result" "file input" "stdin" |
| 9 | # file input will be file called "input" |
| 10 | # test can create a file "actual" instead of writing to stdout |
| 11 | |
| 12 | testing "factor ' 0'" \ |
| 13 | "factor ' 0'" \ |
| 14 | "0:\n" \ |
| 15 | "" "" |
| 16 | testing "factor +1" \ |
| 17 | "factor +1" \ |
| 18 | "1:\n" \ |
| 19 | "" "" |
| 20 | testing "factor ' +2'" \ |
| 21 | "factor ' +2'" \ |
| 22 | "2: 2\n" \ |
| 23 | "" "" |
| 24 | |
| 25 | testing "factor 1024" \ |
| 26 | "factor 1024" \ |
| 27 | "1024: 2 2 2 2 2 2 2 2 2 2\n" \ |
| 28 | "" "" |
| 29 | |
| 30 | testing "factor 2^61-1" \ |
| 31 | "factor 2305843009213693951" \ |
| 32 | "2305843009213693951: 2305843009213693951\n" \ |
| 33 | "" "" |
| 34 | testing "factor 2^62-1" \ |
| 35 | "factor 4611686018427387903" \ |
| 36 | "4611686018427387903: 3 715827883 2147483647\n" \ |
| 37 | "" "" |
| 38 | testing "factor 2^64-1" \ |
| 39 | "factor 18446744073709551615" \ |
| 40 | "18446744073709551615: 3 5 17 257 641 65537 6700417\n" \ |
| 41 | "" "" |
| 42 | # This is a 60-bit number (0x888 86ff db34 4692): first few primes multiplied together: |
| 43 | testing "factor \$((2*3*5*7*11*13*17*19*23*29*31*37*41*43*47))" \ |
| 44 | "factor \$((2*3*5*7*11*13*17*19*23*29*31*37*41*43*47))" \ |
| 45 | "614889782588491410: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47\n" \ |
| 46 | "" "" |
| 47 | |
| 48 | exit $FAILCOUNT |