aboutsummaryrefslogtreecommitdiff
path: root/testsuite/factor.tests
blob: e404e29c14a79658787b1f5b58d7a884ddb33d09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh

# Copyright 2017 by Denys Vlasenko <vda.linux@googlemail.com>
# Licensed under GPLv2, see file LICENSE in this source tree.

. ./testing.sh

# testing "test name" "command" "expected result" "file input" "stdin"
#   file input will be file called "input"
#   test can create a file "actual" instead of writing to stdout

testing "factor '  0'" \
	"factor '  0'" \
	"0:\n" \
	"" ""
testing "factor +1" \
	"factor +1" \
	"1:\n" \
	"" ""
testing "factor ' +2'" \
	"factor ' +2'" \
	"2: 2\n" \
	"" ""

testing "factor 1024" \
	"factor 1024" \
	"1024: 2 2 2 2 2 2 2 2 2 2\n" \
	"" ""

testing "factor 2^61-1" \
	"factor 2305843009213693951" \
	"2305843009213693951: 2305843009213693951\n" \
	"" ""
testing "factor 2^62-1" \
	"factor 4611686018427387903" \
	"4611686018427387903: 3 715827883 2147483647\n" \
	"" ""
testing "factor 2^64-1" \
	"factor 18446744073709551615" \
	"18446744073709551615: 3 5 17 257 641 65537 6700417\n" \
	"" ""
# This is a 60-bit number (0x888 86ff db34 4692): first few primes multiplied together:
testing "factor \$((2*3*5*7*11*13*17*19*23*29*31*37*41*43*47))" \
	"factor \$((2*3*5*7*11*13*17*19*23*29*31*37*41*43*47))" \
	"614889782588491410: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47\n" \
	"" ""

# Test that square-detection code is not buggy
testing "factor 2 * 3037000493 * 3037000493" \
	"factor 18446743988964486098" \
	"18446743988964486098: 2 3037000493 3037000493\n" \
	"" ""
testing "factor 3 * 2479700513 * 2479700513" \
	"factor 18446743902517389507" \
	"18446743902517389507: 3 2479700513 2479700513\n" \
	"" ""
# including square-of-square cases:
testing "factor 3 * 37831 * 37831 * 37831 * 37831" \
	"factor 6144867742934288163" \
	"6144867742934288163: 3 37831 37831 37831 37831\n" \
	"" ""
testing "factor 3 * 13^16" \
	"factor 1996249827549539523" \
	"1996249827549539523: 3 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13\n" \
	"" ""
testing "factor 13^16" \
	"factor 665416609183179841" \
	"665416609183179841: 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13\n" \
	"" ""

exit $FAILCOUNT