-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
29 lines (25 loc) · 749 Bytes
/
test.cpp
File metadata and controls
29 lines (25 loc) · 749 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
#include <vector>
#include <gtest/gtest.h>
#include <iostream>
#include "./src/singleton/index.hpp"
using namespace std;
// there is a problem with singleton
TEST(RecordFinderTests, SingletonTotalPopulationTest) {
SingletonRecordFinder rf;
vector<string> names{"Seoul", "Mexico City"};
int tp = rf.total_population(names);
ASSERT_EQ(17500000+17400000, tp);
}
// much better way of dealing with a dependency on a singleton
TEST(RecordFinderTests, DependendantTotalPopulationTest) {
DummyDatabase db;
ConfigurableRecordFinder rf{db};
vector<string> names{"alpha", "gamma"};
int tp = rf.total_population(names);
EXPECT_EQ(4, tp);
}
int dsfmain(int ac, char* av[])
{
testing::InitGoogleTest(&ac, av);
return RUN_ALL_TESTS();
}