first version upgrade
[devspec.git] / devspec.en_US / project / recutils / torture / rec-fex / rec-fex-check.c
blob7fdb170c60a109cda90a539093d82b27a76e28e2
1 /* -*- mode: C -*-
3 * File: rec-fex-check.c
4 * Date: Tue Nov 9 17:26:40 2010
6 * GNU recutils - rec_fex_check unit tests.
8 */
10 /* Copyright (C) 2010-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 <check.h>
30 #include <rec.h>
32 /*-
33 * Test: rec_fex_check_simple_nominal
34 * Unit: rec_fex_check
35 * Description:
36 * + Check for simple field expressions.
38 START_TEST(rec_fex_check_simple_nominal)
40 fail_if (!rec_fex_check ("foo", REC_FEX_SIMPLE));
41 fail_if (!rec_fex_check ("foo bar baz", REC_FEX_SIMPLE));
42 fail_if (!rec_fex_check ("foo\nbar\nbaz", REC_FEX_SIMPLE));
43 fail_if (!rec_fex_check ("foo\tbar\tbaz", REC_FEX_SIMPLE));
45 END_TEST
47 /*-
48 * Test: rec_fex_check_simple_invalid
49 * Unit: rec_fex_check
50 * Description:
51 * + Check for simple field expressions.
53 START_TEST(rec_fex_check_simple_invalid)
55 fail_if (rec_fex_check ("fo!o", REC_FEX_SIMPLE));
56 fail_if (rec_fex_check ("foo,bar", REC_FEX_SIMPLE));
58 END_TEST
60 /*-
61 * Test: rec_fex_check_csv_nominal
62 * Unit: rec_fex_check
63 * Description:
64 * + Check for comma-separated simple field expressions.
66 START_TEST(rec_fex_check_csv_nominal)
68 fail_if (!rec_fex_check ("foo", REC_FEX_CSV));
69 fail_if (!rec_fex_check ("foo,bar,baz", REC_FEX_CSV));
70 fail_if (!rec_fex_check ("foobarbaz,bar,baz", REC_FEX_CSV));
72 END_TEST
74 /*-
75 * Test: rec_fex_check_csv_invalid
76 * Unit: rec_fex_check
77 * Description:
78 * + Check for csv simple field expressions.
80 START_TEST(rec_fex_check_csv_invalid)
82 fail_if (rec_fex_check ("fo!o", REC_FEX_CSV));
83 fail_if (rec_fex_check ("foo bar", REC_FEX_CSV));
85 END_TEST
87 /*-
88 * Test: rec_fex_check_sub_nominal
89 * Unit: rec_fex_check
90 * Description:
91 * + Check for comma-separated field expressions.
93 START_TEST(rec_fex_check_sub_nominal)
95 fail_if (!rec_fex_check ("foo", REC_FEX_SUBSCRIPTS));
96 fail_if (!rec_fex_check ("foo[10]", REC_FEX_SUBSCRIPTS));
97 fail_if (!rec_fex_check ("foo,bar,baz", REC_FEX_SUBSCRIPTS));
98 fail_if (!rec_fex_check ("foo[0],bar[1],baz[2]", REC_FEX_SUBSCRIPTS));
99 fail_if (!rec_fex_check ("foo[0-10],bar[1-100],baz[2-20]", REC_FEX_SUBSCRIPTS));
100 fail_if (!rec_fex_check ("foobarbaz,bar,baz", REC_FEX_SUBSCRIPTS));
101 fail_if (!rec_fex_check ("foobarbaz,bar[100-0],baz", REC_FEX_SUBSCRIPTS));
103 END_TEST
106 * Test: rec_fex_check_sub_invalid
107 * Unit: rec_fex_check
108 * Description:
109 * + Check for comma-separated field expressions.
111 START_TEST(rec_fex_check_sub_invalid)
113 fail_if (rec_fex_check ("fo!o", REC_FEX_SUBSCRIPTS));
114 fail_if (rec_fex_check ("foo[]", REC_FEX_SUBSCRIPTS));
115 fail_if (rec_fex_check ("foo bar", REC_FEX_SUBSCRIPTS));
116 fail_if (rec_fex_check ("foo,bar[[10]", REC_FEX_SUBSCRIPTS));
118 END_TEST
121 * Test case creation function
123 TCase *
124 test_rec_fex_check (void)
126 TCase *tc = tcase_create ("rec_fex_check");
127 tcase_add_test (tc, rec_fex_check_simple_nominal);
128 tcase_add_test (tc, rec_fex_check_simple_invalid);
129 tcase_add_test (tc, rec_fex_check_csv_nominal);
130 tcase_add_test (tc, rec_fex_check_csv_invalid);
131 tcase_add_test (tc, rec_fex_check_sub_nominal);
132 tcase_add_test (tc, rec_fex_check_sub_invalid);
134 return tc;
137 /* End of rec-fex-check.c */