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.
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/>.
35 * Test: rec_parse_field_name_str_nominal
36 * Unit: rec_parse_field_name_str
38 * + Parse valid field names.
40 START_TEST(rec_parse_field_name_str_nominal
)
44 fname
= rec_parse_field_name_str ("foo");
45 fail_if (fname
== NULL
);
46 fail_if (strcmp (fname
, "foo") != 0);
49 fname
= rec_parse_field_name_str ("foo:");
50 fail_if (fname
== NULL
);
51 fail_if (strcmp (fname
, "foo") != 0);
57 * Test: rec_parse_field_name_str_invalid
58 * Unit: rec_parse_field_name_str
60 * + Try to parse invalid field names.
62 START_TEST(rec_parse_field_name_str_invalid
)
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
);
90 * Test creation function
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
);
102 /* rec-parse-field-name-str.c */