00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00034 #include <string.h>
00035
00036 #include "test-harness.h"
00037
00038 #include "treeconf_int.h"
00039
00040 RCSTAG("@(#)$Id: t_tc_break.c,v 1.3 2005/06/08 04:38:39 klmitch Exp $");
00041
00042 TEST_PROG(t_tc_break, "Test tc_break() function")
00043
00044
00050 int
00051 main(int argc, char **argv)
00052 {
00053 treeconf_str_t *strs = 0;
00054 int cnt = 0;
00055 unsigned int err = 0;
00056 const char *t_str = "this.is/a!test";
00057
00058
00059 TEST(t_tc_break, tc_break_call, "Test that tc_break() may be called",
00060 (!(err = tc_break(&strs, &cnt, t_str, ".!"))), FATAL(0),
00061 ("tc_break() call successful"),
00062 ("tc_break() call failed with error %u", err));
00063
00064 TEST(t_tc_break, tc_break_return, "Test that tc_break() set return "
00065 "arguments to sane values", (strs && cnt == 3), FATAL(0),
00066 ("tc_break() call set string array and count properly"),
00067 ("tc_break() call failed to set string array or count (string array "
00068 "%p, count %d)", (void *)strs, cnt));
00069
00070 TEST(t_tc_break, tc_break_modify, "Test that tc_break() did not modify "
00071 "the string", (!strcmp(t_str, "this.is/a!test")), FATAL(0),
00072 ("tc_break() call did not modify test string"),
00073 ("tc_break() call improperly modified test string\n"));
00074
00075 TEST(t_tc_break, tc_break_split, "Test that tc_break() properly split "
00076 "the string",
00077 (ts_string(strs, 0) == (t_str + 0) && ts_length(strs, 0) == 4 &&
00078 ts_string(strs, 1) == (t_str + 5) && ts_length(strs, 1) == 4 &&
00079 ts_string(strs, 2) == (t_str + 10) && ts_length(strs, 2) == 4),
00080 FATAL(0),
00081 ("tc_break() call properly split test string"),
00082 ("tc_break() call failed to properly split the string"));
00083
00084 return 0;
00085 }