-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath_tests.cpp
More file actions
41 lines (35 loc) · 785 Bytes
/
Copy pathmath_tests.cpp
File metadata and controls
41 lines (35 loc) · 785 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 <chrono>
#include <thread>
// Helper function to make tests take varying amounts of time
void delayExecution(int milliseconds)
{
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
}
// Basic math test suite
TEST(MathTest, Addition)
{
delayExecution(100);
EXPECT_EQ(2 + 2, 4);
}
TEST(MathTest, Subtraction)
{
delayExecution(150);
EXPECT_EQ(5 - 3, 2);
}
TEST(MathTest, Multiplication)
{
delayExecution(120);
EXPECT_EQ(3 * 4, 12);
}
TEST(MathTest, Division)
{
delayExecution(180);
EXPECT_EQ(10 / 2, 5);
}
// Add an intentional failure to demonstrate failure reporting
TEST(MathTest, IntentionalFail)
{
delayExecution(130);
EXPECT_EQ(2 + 2, 5) << "This test is intentionally failing";
}