-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
41 lines (36 loc) · 927 Bytes
/
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
#include "csv.h"
#include <iostream>
void writeTestCSV();
void writeTestQuotedCSV();
void test(std::string, std::string, int);
int main()
{
writeTestCSV();
CSV example("example.csv");
test(example.rows[0]["Name"], "John", 1);
example.rows[0]["Name"] = "Jane";
example.writeCSV();
test(example.rows[0]["Name"], "Jane", 2);
test(example.columns[0], "Name", 3);
return 0;
}
void writeTestCSV()
{
std::remove("example.csv"); // Remove existing csv that may have been modified from previous test
CSV csv("example.csv");
csv.addColumn("Name");
csv.addColumn("Age");
csv.addRow({"John", "24"});
csv.writeCSV();
}
void test(std::string value, std::string expectedValue, int test)
{
if (value == expectedValue)
{
std::cout << "\e[0;32mTest #" << test << " passed.\n";
}
else
{
std::cout << "\e[0;31mTest #" << test << " failed.\n";
}
}