2 * This file is part of DisOrder.
3 * Copyright (C) 2005, 2007, 2008 Richard Kettlewell
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 static void test_sink(void) {
28 s = sink_stdio("tmpfile", fp);
29 insist(sink_printf(s, "test: %d\n", 999) == 10);
30 insist(sink_printf(s, "wibble: %s\n", "foobar") == 15);
32 insist(inputline("tmpfile", fp, &l, '\n') == 0);
33 check_string(l, "test: 999");
34 insist(inputline("tmpfile", fp, &l, '\n') == 0);
35 check_string(l, "wibble: foobar");
36 insist(inputline("tmpfile", fp, &l, '\n') == -1);
40 fprintf(fp, "foo\rbar\nwibble\r\n");
41 fprintf(fp, "second\n\rspong\r\n");
43 insist(inputline("tmpfile", fp, &l, CRLF) == 0);
44 check_string(l, "foo\rbar\nwibble");
45 insist(inputline("tmpfile", fp, &l, CRLF) == 0);
46 check_string(l, "second\n\rspong");
47 insist(inputline("tmpfile", fp, &l, CRLF) == -1);
51 insist(sink_printf(s, "test: %d\n", 999) == 10);
52 insist(sink_printf(s, "wibble: %s\n", "foobar") == 15);
54 check_string(d->vec, "test: 999\nwibble: foobar\n");