csvpp

csvpp Commit Details


Date:2014-03-02 10:18:00 (10 years 9 months ago)
Author:Natalie Adams
Branch:default
Commit:561bd2190994
Parents: 1b7e886a1b5d
Message:Adding tests

Changes:
Atests.cpp (full)
MMakefile (2 diffs)

File differences

Makefile
22
33
44
5
56
67
78
......
1516
1617
1718
19
20
21
CFLAGS=-c -Wall -I./include
LDFLAGS=-I./include
SOURCES=main.cpp ./src/csvpp.cpp ./src/stringhelper.cpp
TEST=tests.cpp ./src/csvpp.cpp ./src/stringhelper.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=csvpp
clean:
rm -f src/*o csvpp
test:
$(CC) $(LDFLAGS) -o test
tests.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
#include <iostream>
#include "csvpp.h"
using namespace std;
int main()
{
RowReader tmp;
stringstream ss;
ss << "field1,field2,field3\r\n123,234,345\r\n999,000,111\r\n";
ss >> tmp;
rowiterator it;
int row = 0;
while(ss >> tmp)
{
switch (row)
{
case 0:
if (tmp["field1"] != "123")
{
cerr << "Failed at row " << row << endl;
return 1;
}
break;
case 1:
if (tmp["field1"] != "999")
{
cerr << "Failed at row " << row << endl;
return 1;
}
break;
}
}
cout << "All tests ran successfully" << endl;
return 0;
}

Archive Download the corresponding diff file

Branches

Tags

Page rendered in 0.40559s using 14 queries.