first version upgrade
[devspec.git] / devspec.en_US / project / recutils / torture / rec-field / rec-field-set-value.c
blobb80899a55634e0b3098411c5945dac500daa736d
1 /* -*- mode: C -*-
3 * File: rec-field-set-value.c
4 * Date: Sun Mar 1 17:04:00 2009
6 * GNU recutils - rec_field_set_value 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_value_empty
34 * Unit: rec_field_set_value
35 * Description:
36 * + Set the value of a field to the empty string
37 * +
38 * + 1. The call should not produce an error.
39 * + 2. The value of the field should be properly
40 * + set.
42 START_TEST(rec_field_set_value_empty)
44 rec_field_t field;
45 const char *fname;
46 const char *field_value;
48 fname = "";
49 field = rec_field_new (fname, "");
50 fail_if(field == NULL);
52 rec_field_set_value (field, "");
53 field_value = rec_field_value (field);
54 fail_if(strcmp (field_value, "") != 0);
56 rec_field_destroy (field);
58 END_TEST
60 /*-
61 * Test: rec_field_set_value_nonempty
62 * Unit: rec_field_set_value
63 * Description:
64 * + Set the value of a field to a non-empty value
65 * +
66 * + 1. The call should not produce an error.
67 * + 2. The value of the field should be properly
68 * + set.
70 START_TEST(rec_field_set_value_nonempty)
72 rec_field_t field;
73 const char *fname;
74 const char *field_value;
76 fname = "";
77 field = rec_field_new (fname, "foo");
78 fail_if(field == NULL);
80 rec_field_set_value (field, "foo");
81 field_value = rec_field_value (field);
82 fail_if(strcmp (field_value, "foo") != 0);
84 rec_field_destroy (field);
86 END_TEST
89 * Test case creation function
91 TCase *
92 test_rec_field_set_value (void)
94 TCase *tc = tcase_create("rec_field_set_value");
95 tcase_add_test (tc, rec_field_set_value_empty);
96 tcase_add_test (tc, rec_field_set_value_nonempty);
98 return tc;
101 /* End of rec-field-set-value.c */