1 /* Copyright (C) 2014 Trend Micro Inc.
4 * This program is a free software; you can redistribute it
5 * and/or modify it under the terms of the GNU General Public
6 * License (version 2) as published by the FSF - Free Software
13 #include "../headers/custom_output_search.h"
15 Suite *test_suite(void);
18 START_TEST(test_searchAndReplace)
21 const char *tests[][4] = {
22 {"testMe", "nomatch", "", "testMe"},
23 {"test me", "ME", "me", "test me"},
24 {"test me", "me", "ME", "test ME"},
25 {"testMe", "test", "Tested", "TestedMe"},
26 {"Metest", "test", "Tested", "MeTested"},
27 {"A B CTeStD E F", "TeSt", "tEsT", "A B CtEsTD E F"},
28 {"TeStA B CTeStD E F", "TeSt", "tEsT", "tEsTA B CtEsTD E F"},
29 {"TeSt TeStA B CTeStD E F", "TeSt", "tEsT", "tEsT tEsTA B CtEsTD E F"},
30 {"A B CTeStD E FTeSt", "TeSt", "tEsT", "A B CtEsTD E FtEsT"},
31 {"A B CTeStD E FTeSt TeSt", "TeSt", "tEsT", "A B CtEsTD E FtEsT tEsT"},
32 {"TeSt++ TeSt++A B CTeSt++D E F", "TeSt++", "tEsT", "tEsT tEsTA B CtEsTD E F"},
33 {"A B CTeStD E FTeSt TeSt", "TeSt", "tEsT++", "A B CtEsT++D E FtEsT++ tEsT++"},
34 {NULL, NULL, NULL, NULL}
37 for (i = 0; tests[i][0] != NULL ; i++) {
38 char *result = searchAndReplace(tests[i][0], tests[i][1], tests[i][2]);
39 ck_assert_str_eq(result, tests[i][3]);
45 Suite *test_suite(void)
47 Suite *s = suite_create("shared");
49 TCase *tc_searchAndReplace = tcase_create("searchAndReplace");
50 tcase_add_test(tc_searchAndReplace, test_searchAndReplace);
52 suite_add_tcase(s, tc_searchAndReplace);
59 Suite *s = test_suite();
60 SRunner *sr = srunner_create(s);
61 srunner_run_all(sr, CK_NORMAL);
62 int number_failed = srunner_ntests_failed(sr);
65 return ((number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE);