20221212
[devspec.git] / devspec.en_US / project / recutils / torture / rec-field / rec-field-set-name.c
blob89f8121f298433ab2f042f19b3d91ea7c8a74ced
1 /* -*- mode: C -*-
3 * File: rec-field-set-name.c
4 * Date: Sun Mar 1 17:04:00 2009
6 * GNU recutils - rec_field_set_name 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 <check.h>
30 #include <rec.h>
32 /*-
33 * Test: rec_field_set_name_empty
34 * Unit: rec_field_set_name
35 * Description:
36 * + Set the name of a field to the empty string
37 * +
38 * + 1. The call should not produce an error.
39 * + 2. The name of the field should be properly
40 * + set.
42 START_TEST(rec_field_set_name_empty)
44 rec_field_t field;
45 const char *field_name;
46 const char *field_name_2;
48 field_name = "";
49 field = rec_field_new (field_name, "");
50 fail_if(field == NULL);
51 field_name_2 = "";
52 rec_field_set_name (field, field_name_2);
54 field_name_2 = rec_field_name (field);
55 fail_if(strcmp (field_name_2, "") != 0);
57 rec_field_destroy (field);
59 END_TEST
61 /*-
62 * Test: rec_field_set_name_nonempty
63 * Unit: rec_field_set_name
64 * Description:
65 * + Set the name of a field to a non-empty name
66 * +
67 * + 1. The call should not produce an error.
68 * + 2. The name of the field should be properly
69 * + set.
71 START_TEST(rec_field_set_name_nonempty)
73 rec_field_t field;
74 const char *field_name;
75 const char *field_name_2;
77 field_name = "";
78 field = rec_field_new (field_name, "");
79 fail_if(field == NULL);
80 field_name_2 = "foo";
82 rec_field_set_name (field, field_name_2);
84 field_name_2 = rec_field_name (field);
85 fail_if(strcmp (field_name_2, "foo") != 0);
87 rec_field_destroy (field);
89 END_TEST
92 * Test case creation function
94 TCase *
95 test_rec_field_set_name (void)
97 TCase *tc = tcase_create("rec_field_set_name");
98 tcase_add_test (tc, rec_field_set_name_empty);
99 tcase_add_test (tc, rec_field_set_name_nonempty);
101 return tc;
104 /* End of rec-field-set-name.c */