csvpp

csvpp Commit Details


Date:2014-03-15 00:16:00 (10 years 9 months ago)
Author:Natalie Adams
Branch:default
Commit:b9fb3f140d64
Parents: 3eeaa517e066
Message:Adding tests

Changes:
MMakefile (1 diff)
Mtests.cpp (1 diff)

File differences

Makefile
88
99
1010
11
12
11
12
1313
1414
15
15
1616
1717
18
18
1919
20
21
20
21
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
.cpp.o:
$(CC) $(CFLAGS) $< -o $@
$(CC) $(CFLAGS) $< -o $@
clean:
rm -f src/*o csvpp
rm -f src/*o csvpp
test:
$(CC) $(LDFLAGS) -o test
tests:
$(CC) $(LDFLAGS) ./src/csvpp.o ./src/stringhelper.o tests.cpp -o test
tests.cpp
22
33
44
5
5
66
77
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
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
3638
37
39
#include "csvpp.h"
using namespace std;
using namespace csvpp;
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;
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")
{
cout << tmp["field1"] << endl;
cerr << "Failed at row " << row << endl;
return 1;
}
break;
case 1:
if (tmp["field1"] != "999")
{
cerr << "Failed at row " << row << endl;
return 1;
}
break;
}
row++;
}
cout << "All tests ran successfully" << endl;
return 0;
}
}

Archive Download the corresponding diff file

Branches

Tags

Page rendered in 0.41323s using 14 queries.