- TEST2(("Hello, world!"), "Hello, world!");
- TEST2(("just a ->%%<- sign"), "just a ->%<- sign");
- TEST2(("Testing, testing, %d, %d, %d.", 1, 2, 3),
- "Testing, testing, 1, 2, 3.");
- TEST2(("->%5d<-", 138), "-> 138<-");
- TEST2(("->%*d<-", 5, 138), "-> 138<-");
- TEST2(("->%-*d<-", 5, 138), "->138 <-");
- TEST2(("->%*d<-", -5, 138), "->138 <-");
- TEST2(("->%-*d<-", -5, 138), "->138 <-");
- TEST2(("->%.*s<-", 5, "truncate me"), "->trunc<-");
- TEST2(("->%.*s<-", -5, "don't truncate me"), "->don't truncate me<-");
- TEST2(("Truncation indirect: ->%.*s<-", 10, "a long string to be chopped"),
- "Truncation indirect: ->a long str<-");
- TEST2(("%08lx:%s", 0x65604204ul, "tripe-ec"), "65604204:tripe-ec");
- TEST2(("%s", LENGTHY), LENGTHY);
-
- TEST1(("big float: ->%f<- and integer %d\n", DBL_MAX, 42));
-
- TEST2(("Testing, testing, %3$d, %2$d, %1$d.", 3, 2, 1),
- "Testing, testing, 1, 2, 3.");
- TEST2(("Truncation indirect: ->%1$.*2$s<-",
- "a long string to be chopped", 10),
- "Truncation indirect: ->a long str<-");
-
- if (!lose) printf("All tests successful.\n");
- else printf("FAILED %d of %d tests.\n", lose, win + lose);
- return (!!lose);
+ struct tvec_test test;
+ int argpos;
+
+ tvec_parseargs(argc, argv, &tvstate, &argpos, &tvec_adhocconfig);
+ if (argpos < argc) die(2, "no input files expected");
+ tvec_adhoc(&tvstate, &test);
+
+ TESTGROUP("basics") {
+ TEST_KNOWN(("Hello, world!"), "Hello, world!");
+ TEST_KNOWN(("just a ->%%<- sign"), "just a ->%<- sign");
+ }
+
+ TESTGROUP("integers") {
+ TEST_KNOWN(("Testing, testing, %d, %d, %d.", 1, 2, 3),
+ "Testing, testing, 1, 2, 3.");
+ TEST_KNOWN(("->%5d<-", 138), "-> 138<-");
+ TEST_KNOWN(("->%*d<-", 5, 138), "-> 138<-");
+ TEST_KNOWN(("->%-*d<-", 5, 138), "->138 <-");
+ TEST_KNOWN(("->%*d<-", -5, 138), "->138 <-");
+ TEST_KNOWN(("->%-*d<-", -5, 138), "->138 <-");
+ }
+
+ TESTGROUP("strings") {
+ TEST_KNOWN(("->%.*s<-", 5, "truncate me"), "->trunc<-");
+ TEST_KNOWN(("->%.*s<-", -5, "don't truncate me"),
+ "->don't truncate me<-");
+ TEST_KNOWN(("Truncation indirect: ->%.*s<-", 10,
+ "a long string to be chopped"),
+ "Truncation indirect: ->a long str<-");
+ }
+
+ TESTGROUP("combinations") {
+ TEST_KNOWN(("%08lx:%s", 0x65604204ul, "tripe-ec"), "65604204:tripe-ec");
+ TEST_REF(("big float: ->%f<- and integer %d\n", DBL_MAX, 42));
+ }
+
+ TESTGROUP("argument-order") {
+ TEST_KNOWN(("Testing, testing, %3$d, %2$d, %1$d.", 3, 2, 1),
+ "Testing, testing, 1, 2, 3.");
+ TEST_KNOWN(("Truncation indirect: ->%1$.*2$s<-",
+ "a long string to be chopped", 10),
+ "Truncation indirect: ->a long str<-");
+ }
+
+ TESTGROUP("misc")
+ TEST_KNOWN(("%s", LENGTHY), LENGTHY);
+
+ return (tvec_end(&tvstate));