-
Notifications
You must be signed in to change notification settings - Fork 0
/
implement-strstr-test.cpp
42 lines (36 loc) · 1.01 KB
/
implement-strstr-test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* Copyright (c) 2018 Christopher Friedt
*
* SPDX-License-Identifier: MIT
*/
#include <gtest/gtest.h>
#include "implement-strstr.cpp"
TEST(ImplementStrStr, Test_empty_empty) {
string haystack = "";
string needle = "";
int expected_int = 0;
int actual_int = Solution().strStr(haystack, needle);
EXPECT_EQ(actual_int, expected_int);
}
TEST(ImplementStrStr, Test_empty_tiny__yuuuuuge) {
// needle too big
string haystack = "tiny";
string needle = "yuuuuuge";
int expected_int = -1;
int actual_int = Solution().strStr(haystack, needle);
EXPECT_EQ(actual_int, expected_int);
}
TEST(ImplementStrStr, Test_hello_ll) {
string haystack = "hello";
string needle = "ll";
int expected_int = 2;
int actual_int = Solution().strStr(haystack, needle);
EXPECT_EQ(actual_int, expected_int);
}
TEST(ImplementStrStr, Test_aaaaa_bba) {
string haystack = "aaaaa";
string needle = "ba";
int expected_int = -1;
int actual_int = Solution().strStr(haystack, needle);
EXPECT_EQ(actual_int, expected_int);
}