factor.tests 1.2 KB

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