first version upgrade
[devspec.git] / devspec.en_US / project / recutils / torture / rec-parser / rec-parse-field-name-str.c
blob8dca53ceaf2a19fe05921c90cdd93471532bb981
1 /* -*- mode: C -*-
3 * File: rec-parse-field-name-str.c
4 * Date: Sat Nov 13 15:42:21 2010
6 * GNU recutils - rec_parse_field_name_str unit tests.
8 */
10 /* Copyright (C) 2009-2015 Jose E. Marchesi */
12 /* This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include <config.h>
27 #include <string.h>
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <check.h>
32 #include <rec.h>
34 /*-
35 * Test: rec_parse_field_name_str_nominal
36 * Unit: rec_parse_field_name_str
37 * Description:
38 * + Parse valid field names.
40 START_TEST(rec_parse_field_name_str_nominal)
42 char *fname;
44 fname = rec_parse_field_name_str ("foo");
45 fail_if (fname == NULL);
46 fail_if (strcmp (fname, "foo") != 0);
47 free (fname);
49 fname = rec_parse_field_name_str ("foo:");
50 fail_if (fname == NULL);
51 fail_if (strcmp (fname, "foo") != 0);
52 free (fname);
54 END_TEST
56 /*-
57 * Test: rec_parse_field_name_str_invalid
58 * Unit: rec_parse_field_name_str
59 * Description:
60 * + Try to parse invalid field names.
62 START_TEST(rec_parse_field_name_str_invalid)
64 char *fname;
66 fname = rec_parse_field_name_str ("");
67 fail_if (fname != NULL);
69 fname = rec_parse_field_name_str ("fo!o");
70 fail_if (fname != NULL);
72 fname = rec_parse_field_name_str ("foo::");
73 fail_if (fname != NULL);
75 fname = rec_parse_field_name_str (":foo");
76 fail_if (fname != NULL);
78 fname = rec_parse_field_name_str ("foobar baz");
79 fail_if (fname != NULL);
81 fname = rec_parse_field_name_str ("foo:bar:baz");
82 fail_if (fname != NULL);
84 fname = rec_parse_field_name_str ("foo:baz!!#");
85 fail_if (fname != NULL);
87 END_TEST
90 * Test creation function
92 TCase *
93 test_rec_parse_field_name_str (void)
95 TCase *tc = tcase_create ("rec_parse_field_name_str");
96 tcase_add_test (tc, rec_parse_field_name_str_nominal);
97 tcase_add_test (tc, rec_parse_field_name_str_invalid);
99 return tc;
102 /* rec-parse-field-name-str.c */