summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorDenys Vlasenko2017-04-09 21:18:43 +0200
committerDenys Vlasenko2017-04-09 21:18:43 +0200
commitee7f75d94f2a70d61a71eca9416d51a3268859d7 (patch)
treee6273417231ae83178cf8d5050d02bc59ff195d9 /testsuite
parent87ae0fe095686b169ab1aeeb25c8ac3f5be30feb (diff)
downloadbusybox-ee7f75d94f2a70d61a71eca9416d51a3268859d7.zip
busybox-ee7f75d94f2a70d61a71eca9416d51a3268859d7.tar.gz
factor: new applet
thus far only able to factor up to ULLONG_MAX function old new delta factor_main - 378 +378 packed_usage 31427 31502 +75 applet_names 2590 2597 +7 applet_main 1500 1504 +4 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 3/0 up/down: 464/0) Total: 464 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'testsuite')
-rwxr-xr-xtestsuite/factor.tests48
1 files changed, 48 insertions, 0 deletions
diff --git a/testsuite/factor.tests b/testsuite/factor.tests
new file mode 100755
index 0000000..2cf4a54
--- /dev/null
+++ b/testsuite/factor.tests
@@ -0,0 +1,48 @@
+#!/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" \
+ "" ""
+
+exit $FAILCOUNT