forked from varoudis/depthmapX
-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathtestperformancewriter.cpp
More file actions
42 lines (33 loc) · 1021 Bytes
/
testperformancewriter.cpp
File metadata and controls
42 lines (33 loc) · 1021 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
42
#include <catch.hpp>
#include "../depthmapXcli/performancewriter.h"
#include "selfcleaningfile.h"
#include <fstream>
TEST_CASE("TestPerformanceWriting", "Simple test case")
{
SelfCleaningFile scf("timertest.csv");
PerformanceWriter writer(scf.Filename());
writer.addData("test1", 100.0);
writer.addData("test2", 200.0 );
writer.write();
std::ifstream f(scf.Filename());
REQUIRE(f.good());
char line[1000];
std::vector<std::string> lines;
while( !f.eof())
{
f.getline(line, 1000);
lines.push_back(line);
}
std::vector<std::string> expected{"\"action\",\"duration\"", "\"test1\",100", "\"test2\",200", ""};
REQUIRE(lines == expected);
}
TEST_CASE("TestPerformanceNotWriting", "No filename no writing")
{
SelfCleaningFile scf("timertest.csv");
PerformanceWriter writer("");
writer.addData("test1", 100.0);
writer.addData("test2", 200.0 );
writer.write();
std::ifstream f(scf.Filename());
REQUIRE_FALSE(f.good());
}