first version upgrade
[devspec.git] / devspec.en_US / project / recutils / torture / rec-parser / rec-parser-new-mem.c
blobb8d8488d183b6baf121244626c4908e8000370a2
1 /* -*- mode: C -*-
3 * File: rec-parser-new-mem.c
4 * Date: Fri May 25 11:14:05 2012
6 * GNU recutils - rec_parser_new_mem unit tests.
8 */
10 /* Copyright (C) 2010-2015 Jose E. Marchesi */
11 /* Copyright (C) 2012-2015 Michał Masłowski */
13 /* This program is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include <config.h>
28 #include <string.h>
29 #include <stdio.h>
30 #include <check.h>
32 #include <rec.h>
34 /* Based on rec_parse_rset unit tests. */
36 /*-
37 * Test: rec_parser_new_mem_nominal
38 * Unit: rec_parser_new_mem
39 * Description:
40 * + Parse a valid truncated record set.
42 START_TEST(rec_parser_new_mem_nominal)
44 rec_parser_t parser;
45 rec_rset_t rset;
46 char *str;
47 char *short_str;
49 str = "foo1: bar1\n\nfoo2: bar2\n\nfoo3: bar3";
50 short_str = "foo1: bar1\n\nfoo2: bar2";
51 parser = rec_parser_new_mem (str, strlen(short_str), "dummy");
52 fail_if (!rec_parse_rset (parser, &rset));
53 fail_if (rec_rset_num_records (rset) != 2);
54 rec_rset_destroy (rset);
55 rec_parser_destroy (parser);
57 END_TEST
60 * Test creation function
62 TCase *
63 test_rec_parser_new_mem (void)
65 TCase *tc = tcase_create ("rec_parser_new_mem");
66 tcase_add_test (tc, rec_parser_new_mem_nominal);
68 return tc;
71 /* End of rec-parser-new-mem.c */