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.
13 * The strrstr() function finds the last occurrence of the substring needle
14 * in the string haystack. The terminating nul characters are not compared.
16 char* FAST_FUNC strrstr(const char *haystack, const char *needle)
21 return (char*)haystack + strlen(haystack);
23 char *p = strstr(haystack, needle);
33 BBUNIT_DEFINE_TEST(strrstr)
40 { "baaabaaab", "aaa", 5 },
41 { "baaabaaaab", "aaa", 6 },
42 { "baaabaab", "aaa", 1 },
55 while (i < sizeof(test_array) / sizeof(test_array[0])) {
56 const char *r = strrstr(test_array[i].h, test_array[i].n);
58 r = test_array[i].h - 1;
59 BBUNIT_ASSERT_EQ(r, test_array[i].h + test_array[i].pos);
66 #endif /* ENABLE_UNIT_TEST */