2 * Copyright (C) 2010-2011 jeanfi@gmail.com
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 static int test_strrep(const char *str,
38 result = strrep(s, old, new);
41 (result != NULL && ref != NULL && !strcmp(result, ref)))
44 fprintf(stderr, "strrep(%s, %s, %s) = %s\n", str, old, new, result);
49 static int tests_strrep()
55 failures += test_strrep(NULL, NULL, NULL, NULL);
56 failures += test_strrep("astring", NULL, NULL, "astring");
57 failures += test_strrep("astring", "astring", NULL, "astring");
58 failures += test_strrep("astring", NULL, "astring", "astring");
59 failures += test_strrep("astring", "astring", "astring", "astring");
60 failures += test_strrep(NULL, "astring", "astring", NULL);
61 failures += test_strrep(NULL, NULL, "astring", NULL);
62 failures += test_strrep(NULL, "astring", NULL, NULL);
64 failures += test_strrep("astring", "astring", "", "");
65 failures += test_strrep("DastringE", "astring", "", "DE");
66 failures += test_strrep("Dastring", "astring", "", "D");
67 failures += test_strrep("astringE", "astring", "", "E");
69 failures += test_strrep("astring", "old", "new", "astring");
70 failures += test_strrep("aoldstring", "old", "new", "anewstring");
71 failures += test_strrep("astring", "astring", "thenewstring",
73 failures += test_strrep("Dastring", "astring", "thenewstring",
75 failures += test_strrep("astringE", "astring", "thenewstring",
81 int main(int argc, char **argv)
87 failures += tests_strrep();