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 12testing "factor ' 0'" \ 13 "factor ' 0'" \ 14 "0:\n" \ 15 "" "" 16testing "factor +1" \ 17 "factor +1" \ 18 "1:\n" \ 19 "" "" 20testing "factor ' +2'" \ 21 "factor ' +2'" \ 22 "2: 2\n" \ 23 "" "" 24 25testing "factor 1024" \ 26 "factor 1024" \ 27 "1024: 2 2 2 2 2 2 2 2 2 2\n" \ 28 "" "" 29 30testing "factor 2^61-1" \ 31 "factor 2305843009213693951" \ 32 "2305843009213693951: 2305843009213693951\n" \ 33 "" "" 34testing "factor 2^62-1" \ 35 "factor 4611686018427387903" \ 36 "4611686018427387903: 3 715827883 2147483647\n" \ 37 "" "" 38testing "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: 43testing "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# Test that square-detection code is not buggy 49testing "factor 2 * 3037000493 * 3037000493" \ 50 "factor 18446743988964486098" \ 51 "18446743988964486098: 2 3037000493 3037000493\n" \ 52 "" "" 53testing "factor 3 * 2479700513 * 2479700513" \ 54 "factor 18446743902517389507" \ 55 "18446743902517389507: 3 2479700513 2479700513\n" \ 56 "" "" 57# including square-of-square cases: 58testing "factor 3 * 37831 * 37831 * 37831 * 37831" \ 59 "factor 6144867742934288163" \ 60 "6144867742934288163: 3 37831 37831 37831 37831\n" \ 61 "" "" 62testing "factor 3 * 13^16" \ 63 "factor 1996249827549539523" \ 64 "1996249827549539523: 3 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13\n" \ 65 "" "" 66testing "factor 13^16" \ 67 "factor 665416609183179841" \ 68 "665416609183179841: 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13\n" \ 69 "" "" 70 71exit $FAILCOUNT 72