1 | //===-- Unittests for strcasestr ------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "src/string/strcasestr.h" |
10 | #include "test/UnitTest/Test.h" |
11 | |
12 | TEST(LlvmLibcStrCaseStrTest, NeedleNotInHaystack) { |
13 | EXPECT_STREQ(LIBC_NAMESPACE::strcasestr("abcd" , "e" ), nullptr); |
14 | EXPECT_STREQ(LIBC_NAMESPACE::strcasestr("ABCD" , "e" ), nullptr); |
15 | EXPECT_STREQ(LIBC_NAMESPACE::strcasestr("abcd" , "E" ), nullptr); |
16 | EXPECT_STREQ(LIBC_NAMESPACE::strcasestr("ABCD" , "E" ), nullptr); |
17 | } |
18 | |
19 | TEST(LlvmLibcStrCaseStrTest, NeedleInMiddle) { |
20 | EXPECT_STREQ(LIBC_NAMESPACE::strcasestr("abcdefghi" , "def" ), "defghi" ); |
21 | EXPECT_STREQ(LIBC_NAMESPACE::strcasestr("ABCDEFGHI" , "def" ), "DEFGHI" ); |
22 | EXPECT_STREQ(LIBC_NAMESPACE::strcasestr("abcdefghi" , "DEF" ), "defghi" ); |
23 | EXPECT_STREQ(LIBC_NAMESPACE::strcasestr("ABCDEFGHI" , "DEF" ), "DEFGHI" ); |
24 | } |
25 | |