diff -r 1b7e886a1b5d26a5e66b01e68397e3ca9acf5e06 -r 561bd21909945b50f673c46a236c1cd3ba261cf9 Makefile --- a/Makefile Sat Oct 12 20:44:44 2013 -0500 +++ b/Makefile Sun Mar 02 10:18:30 2014 -0600 @@ -2,6 +2,7 @@ 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 @@ -15,3 +16,6 @@ clean: rm -f src/*o csvpp + +test: + $(CC) $(LDFLAGS) -o test \ No newline at end of file diff -r 1b7e886a1b5d26a5e66b01e68397e3ca9acf5e06 -r 561bd21909945b50f673c46a236c1cd3ba261cf9 tests.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests.cpp Sun Mar 02 10:18:30 2014 -0600 @@ -0,0 +1,37 @@ +#include +#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; +} \ No newline at end of file