3 * File: rec-parse-record-str.c
4 * Date: Sat Nov 13 20:16:11 2010
6 * GNU recutils - rec_parse_record_str unit tests.
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/>.
34 * Test: rec_parse_record_str_nominal
35 * Unit: rec_parse_record_str
37 * + Parse valid records from strings.
39 START_TEST(rec_parse_record_str_nominal
)
45 record
= rec_parse_record_str ("foo: bar");
46 fail_if (record
== NULL
);
47 fname
= rec_parse_field_name_str ("foo");
48 fail_if (fname
== NULL
);
49 field
= (rec_field_t
) rec_mset_get_at (rec_record_mset (record
), MSET_FIELD
, 0);
50 fail_if (strcmp (rec_field_value (field
), "bar") != 0);
51 fail_if (!rec_field_name_equal_p (fname
,
52 rec_field_name (field
)));
54 rec_record_destroy (record
);
59 * Test: rec_parse_record_str_invalid
60 * Unit: rec_parse_record_str
62 * + Try to parse invalid records from strings.
64 START_TEST(rec_parse_record_str_invalid
)
68 record
= rec_parse_record_str ("");
69 fail_if (record
!= NULL
);
71 record
= rec_parse_record_str (" ");
72 fail_if (record
!= NULL
);
77 * Test creation function.
80 test_rec_parse_record_str (void)
82 TCase
*tc
= tcase_create ("rec_parse_record_str");
83 tcase_add_test (tc
, rec_parse_record_str_nominal
);
84 tcase_add_test (tc
, rec_parse_record_str_invalid
);
89 /* End of rec-parse-record-str.c */