Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

t_tc_break.c

Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 2004, 2005 by Kevin L. Mitchell <klmitch@mit.edu>
00003 **
00004 ** This program is free software; you can redistribute it and/or modify
00005 ** it under the terms of the GNU General Public License as published by
00006 ** the Free Software Foundation; either version 2 of the License, or
00007 ** (at your option) any later version.
00008 **
00009 ** This program is distributed in the hope that it will be useful,
00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 ** GNU General Public License for more details.
00013 **
00014 ** You should have received a copy of the GNU General Public License
00015 ** along with this program; if not, write to the Free Software
00016 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 **
00018 ** @(#)$Id: t_tc_break.c,v 1.3 2005/06/08 04:38:39 klmitch Exp $
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                 /* 01234567890123 */
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 }

Generated on Wed Jun 8 09:18:27 2005 for treeconf by  doxygen 1.3.9.1