-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_tests.cpp
More file actions
41 lines (36 loc) · 842 Bytes
/
Copy pathstring_tests.cpp
File metadata and controls
41 lines (36 loc) · 842 Bytes
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
#include <gtest/gtest.h>
#include <string>
#include <chrono>
#include <thread>
// Helper function to make tests take varying amounts of time
void delayStringTests(int milliseconds)
{
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
}
// String test suite
TEST(StringTest, Length)
{
delayStringTests(200);
std::string test = "Hello";
EXPECT_EQ(test.length(), 5);
}
TEST(StringTest, Concatenation)
{
delayStringTests(250);
std::string a = "Hello";
std::string b = " World";
EXPECT_EQ(a + b, "Hello World");
}
TEST(StringTest, Comparison)
{
delayStringTests(150);
std::string a = "abc";
std::string b = "def";
EXPECT_TRUE(a < b);
}
TEST(StringTest, Substring)
{
delayStringTests(180);
std::string test = "Hello World";
EXPECT_EQ(test.substr(0, 5), "Hello");
}