#ifdef TEST_PROGRAM
int main(int argc, char *argv[])
{
- return EXIT_FAILURE;
+ if (argc < 2) {
+ error(EXIT_FAILURE, 0, "no arguments");
+ } else if (argc < 3) {
+ printf("%ld\n", strtol_or_err(argv[1], "strtol_or_err"));
+ } else {
+ printf("%lf\n", strtod_or_err(argv[2], "strtod_or_err"));
+ }
+ return EXIT_SUCCESS;
}
#endif /* TEST_PROGRAM */
--- /dev/null
+#
+# Testsuite for lib/strutils program
+#
+
+set teststr "${topdir}lib/test_strutils"
+
+set test "without argument"
+spawn $teststr
+expect_pass "$test" "test_strutils: no arguments"
+
+set test "test long"
+spawn $teststr 1
+expect_pass "$test" "1"
+
+set test "test long fail"
+spawn $teststr fail
+expect_pass "$test" "test_strutils: strtol_or_err: \'fail\'"
+
+set test "test double"
+spawn $teststr dummy 1.1
+expect_pass "$test" "1.100000"
+
+set test "test double fail"
+spawn $teststr dummy fail
+expect_pass "$test" "test_strutils: strtod_or_err: \'fail\'"