3 * File: rec-field-value.c
4 * Date: Sun Mar 1 17:04:00 2009
6 * GNU recutils - rec_field_value 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/>.
33 * Test: rec_field_value_empty
34 * Unit: rec_field_value
36 * + Get the value of a field with an empy value
38 * + 1. The call should not produce an error.
39 * + 2. The value of the field should be properly
42 START_TEST(rec_field_value_empty
)
46 const char *field_value
;
49 field
= rec_field_new (fname
, "");
50 fail_if(field
== NULL
);
52 field_value
= rec_field_value (field
);
53 fail_if(strcmp (field_value
, "") != 0);
55 rec_field_destroy (field
);
60 * Test: rec_field_value_nonempty
61 * Unit: rec_field_value
63 * + Get the value of a field with a non-empty value
65 * + 1. The call should not produce an error.
66 * + 2. The value of the field should be properly
69 START_TEST(rec_field_value_nonempty
)
73 const char *field_value
;
76 field
= rec_field_new (fname
, "foo");
77 fail_if(field
== NULL
);
79 field_value
= rec_field_value (field
);
80 fail_if(strcmp (field_value
, "foo") != 0);
82 rec_field_destroy (field
);
87 * Test case creation function
90 test_rec_field_value (void)
92 TCase
*tc
= tcase_create("rec_field_value");
93 tcase_add_test (tc
, rec_field_value_empty
);
94 tcase_add_test (tc
, rec_field_value_nonempty
);
99 /* End of rec-field-value.c */