1 /* vi: set sw=4 ts=4: */
5 * Copyright (C) 2008 Bernhard Reutner-Fischer
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
12 * The strrstr() function finds the last occurrence of the substring needle
13 * in the string haystack. The terminating nul characters are not compared.
15 char* FAST_FUNC strrstr(const char *haystack, const char *needle)
20 return (char*)haystack + strlen(haystack);
22 char *p = strstr(haystack, needle);
32 BBUNIT_DEFINE_TEST(strrstr)
39 { "baaabaaab", "aaa", 5 },
40 { "baaabaaaab", "aaa", 6 },
41 { "baaabaab", "aaa", 1 },
54 while (i < sizeof(test_array) / sizeof(test_array[0])) {
55 const char *r = strrstr(test_array[i].h, test_array[i].n);
57 r = test_array[i].h - 1;
58 BBUNIT_ASSERT_EQ(r, test_array[i].h + test_array[i].pos);
65 #endif /* ENABLE_UNIT_TEST */