first version upgrade
[devspec.git] / devspec.en_US / project / recutils / torture / rec-writer / rec-write-field-name.c
blob693df9e5e6324752ad7b8f00a58b915267272494
1 /* -*- mode: C -*-
3 * File: rec-write-field-name.c
4 * Date: Sun Nov 14 11:32:17 2010
6 * GNU recutils - rec_write_field_name 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 <stdio.h>
29 #include <stdlib.h>
30 #include <check.h>
32 #include <rec.h>
34 /*-
35 * Test: rec_write_field_name_nominal
36 * Unit: rec_write_field_name
37 * Description:
38 * + Write field names.
40 START_TEST(rec_write_field_name_nominal)
42 rec_writer_t writer;
43 char *fname;
44 char *str;
45 size_t str_size;
47 fname = "foo";
48 writer = rec_writer_new_str (&str, &str_size);
49 rec_writer_set_mode (writer, REC_WRITER_NORMAL);
50 fail_if (!rec_write_field_name (writer, fname));
51 rec_writer_destroy (writer);
52 fail_if (strcmp (str, "foo:") != 0);
53 free (str);
55 END_TEST
57 /*-
58 * Test: rec_write_field_name_sexp
59 * Unit: rec_write_field_name
60 * Description:
61 * + Write field names.
63 START_TEST(rec_write_field_name_sexp)
65 rec_writer_t writer;
66 char *fname;
67 char *str;
68 size_t str_size;
70 fname = "foo";
71 writer = rec_writer_new_str (&str, &str_size);
72 rec_writer_set_mode (writer, REC_WRITER_SEXP);
73 fail_if (!rec_write_field_name (writer, fname));
74 rec_writer_destroy (writer);
75 fail_if (strcmp (str, "\"foo\"") != 0);
76 free (str);
78 END_TEST
81 * Test creation function
83 TCase *
84 test_rec_write_field_name (void)
86 TCase *tc = tcase_create ("rec_write_field_name");
87 tcase_add_test (tc, rec_write_field_name_nominal);
88 tcase_add_test (tc, rec_write_field_name_sexp);
90 return tc;
93 /* End of rec-write-field-name.c */