first version upgrade
[devspec.git] / devspec.en_US / project / recutils / torture / rec-fex / rec-fex-elem-rewrite-to.c
blob03c05654ed7ab81b92c27348af3ce427c97af563
1 /* -*- mode: C -*- Time-stamp: "2015-04-27 19:59:28 jemarch"
3 * File: rec-fex-elem-rewrite-to.c
4 * Date: Sun Feb 26 13:14:15 2012
6 * GNU recutils - rec_fex_elem_rewrite_to unit tests.
8 */
10 /* Copyright (C) 2012-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_elem_rewrite_to_default
34 * Unit: rec_fex_elem_rewrite_to
35 * Description:
36 * + The rewrite_to property of a fex
37 * + elem without a rewrite rule must be NULL.
39 START_TEST(rec_fex_elem_rewrite_to_default)
41 rec_fex_t fex;
42 rec_fex_elem_t elem;
44 fex = rec_fex_new ("foo,bar,baz", REC_FEX_SUBSCRIPTS);
45 fail_if (fex == NULL);
47 elem = rec_fex_get (fex, 0);
48 fail_if (elem == NULL);
49 fail_if (rec_fex_elem_rewrite_to (elem) != NULL);
51 rec_fex_destroy (fex);
53 END_TEST
55 /*-
56 * Test: rec_fex_elem_rewrite_to_nominal
57 * Unit: rec_fex_elem_rewrite_to
58 * Description:
59 * + The rewrite_to property of a fex
60 * + elem must be properly parsed and returned.
62 START_TEST(rec_fex_elem_rewrite_to_nominal)
64 rec_fex_t fex;
65 rec_fex_elem_t elem;
67 fex = rec_fex_new ("foo,bar:xxx,baz", REC_FEX_SUBSCRIPTS);
68 fail_if (fex == NULL);
70 elem = rec_fex_get (fex, 1);
71 fail_if (elem == NULL);
72 fail_if (rec_fex_elem_rewrite_to (elem) == NULL);
73 fail_if (strcmp (rec_fex_elem_rewrite_to (elem), "xxx") != 0);
75 rec_fex_destroy (fex);
77 END_TEST
80 * Test case creation function
83 TCase *
84 test_rec_fex_elem_rewrite_to (void)
86 TCase *tc = tcase_create ("rec_fex_elem_rewrite_to");
87 tcase_add_test (tc, rec_fex_elem_rewrite_to_default);
88 tcase_add_test (tc, rec_fex_elem_rewrite_to_nominal);
90 return tc;
93 /* End of rec-fex-elem-rewrite-to.c */