[brlcad-commits] SF.net SVN: brlcad:[51635] brlcad/trunk/src/libbu/tests
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <sta...@us...> - 2012-07-23 13:54:43
|
Revision: 51635 http://brlcad.svn.sourceforge.net/brlcad/?rev=51635&view=rev Author: starseeker Date: 2012-07-23 13:54:32 +0000 (Mon, 23 Jul 2012) Log Message: ----------- Add bu_str_isprint tests Modified Paths: -------------- brlcad/trunk/src/libbu/tests/CMakeLists.txt brlcad/trunk/src/libbu/tests/bu_str_isprint.c Modified: brlcad/trunk/src/libbu/tests/CMakeLists.txt =================================================================== --- brlcad/trunk/src/libbu/tests/CMakeLists.txt 2012-07-23 13:18:25 UTC (rev 51634) +++ brlcad/trunk/src/libbu/tests/CMakeLists.txt 2012-07-23 13:54:32 UTC (rev 51635) @@ -116,10 +116,20 @@ ################################## # bu_str_isprint testing # ################################## +# Note - because of the special characters needed in these tests, the strings +# don't work well when fed in from the command line. BRLCAD_ADDEXEC(tester_bu_str_isprint bu_str_isprint.c libbu NO_INSTALL LOCAL) +add_test(bu_str_isprint_basic tester_bu_str_isprint 1) +add_test(bu_str_isprint_eol tester_bu_str_isprint 2) +add_test(bu_str_isprint_double_slash tester_bu_str_isprint 3) +add_test(bu_str_isprint_horiz_tab tester_bu_str_isprint 4) +add_test(bu_str_isprint_non-alphanumeric tester_bu_str_isprint 5) +add_test(bu_str_isprint_eol_non-alphanumeric tester_bu_str_isprint 6) +add_test(bu_str_isprint_carriage_return tester_bu_str_isprint 7) + # Local Variables: # tab-width: 8 # mode: cmake Modified: brlcad/trunk/src/libbu/tests/bu_str_isprint.c =================================================================== --- brlcad/trunk/src/libbu/tests/bu_str_isprint.c 2012-07-23 13:18:25 UTC (rev 51634) +++ brlcad/trunk/src/libbu/tests/bu_str_isprint.c 2012-07-23 13:54:32 UTC (rev 51635) @@ -48,21 +48,35 @@ int -main(int UNUSED(ac) , char **UNUSED(av)) +main(int argc, char **argv) { - int pass = 1; + int test_num = 0; - printf("\nStarting Tests For ctype.c....\n"); + if (argc < 2) { + printf("Usage: %s test_num\n", argv[0]); + return 1; + } + + sscanf(argv[1], "%d", &test_num); - pass *= test_str_isprint("abc", 1); - pass *= test_str_isprint("abc123\n", 0); /* \n is end of line -not printable */ - pass *= test_str_isprint("abc123\\n1!", 1); - pass *= test_str_isprint("123\txyz", 0); /* \t is horizontal tab - not printable */ - pass *= test_str_isprint("#$%\n 748", 0); /* \n is end of line -not printable */ - pass *= test_str_isprint("#$ ab12", 1); - pass *= test_str_isprint("#$^\ry", 0); /* \r is carriage return - not printable */ + switch (test_num) { + case 1: + return !test_str_isprint("abc", 1); + case 2: + return !test_str_isprint("abc123\n", 0); /* \n is end of line -not printable */ + case 3: + return !test_str_isprint("abc123\\n1!", 1); + case 4: + return !test_str_isprint("123\txyz", 0); /* \t is horizontal tab - not printable */ + case 5: + return !test_str_isprint("#$%\n 748", 0); /* \n is end of line -not printable */ + case 6: + return !test_str_isprint("#$ ab12", 1); + case 7: + return !test_str_isprint("#$^\ry", 0); /* \r is carriage return - not printable */ + } - return (1-pass); + return 1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |