aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-08-17 23:23:29 -0500
committerRob Landley <rob@landley.net>2015-08-17 23:23:29 -0500
commit4e49e2cca731f2e1dd01ebc5163beb71e0d640ec (patch)
tree7965d0ae22105f20d940f1736bdf202c79917604
parentc82be78035e536b2b2248be6d6f3cd5a995f11f1 (diff)
downloadtoybox-4e49e2cca731f2e1dd01ebc5163beb71e0d640ec.tar.gz
Test for human_readable()
-rw-r--r--toys/example/test_human_readable.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/toys/example/test_human_readable.c b/toys/example/test_human_readable.c
new file mode 100644
index 00000000..ae8e7888
--- /dev/null
+++ b/toys/example/test_human_readable.c
@@ -0,0 +1,23 @@
+/* test_human_readable.c - Expose lib/lib.c human_readable() for testing.
+ *
+ * Copyright 2015 Rob Landley <rob@landley.net>
+
+USE_TEST_HUMAN_READABLE(NEWTOY(test_human_readable, "<1>1ibs", 0))
+
+config TEST_HUMAN_READABLE
+ bool "test_human_readable"
+ default n
+ help
+ usage: test_human_readable [-sbi] NUMBER
+*/
+
+#define FOR_test_human_readable
+#include "toys.h"
+
+void test_human_readable_main(void)
+{
+ char *c;
+
+ human_readable(toybuf, strtoll(*toys.optargs, &c, 0), toys.optflags);
+ printf("%s\n", toybuf);
+}