UserDB: Alternative Output Format - CSV#
Write CSV: Test#
Talk
We have tests, why not continue this way?
Write test to see how it could be done
Write test
Copy
test-funny-overflow-file.cpptotest-csv.cppExpected content:
std::string expected_content = "666;Joerg;Faschingbauer;joerg@home.com\n";
Pull in
read-file(at the top of the file -> function)Write out filled DB
Discuss implementation strategy
In a hurry ⟶
bool binaryread_file()Compare
Implement
In
UserDB::write(string filename, bool binary=true)if/elsePull in
write-csvinto CSV branch
Write CSV: Frontend Program#
Build that functionality into bin/userdb-write-binaryfile.cpp
Rename to
bin/userdb-write.cppargv[1]… typeargv[2]… filename
Read CSV: Test#
Discuss
Do we really want to write one file per test?
Doesn’t writing and reading CSV belong together?
Implement read test inside tests/test-csv.cpp
Rename
main()totest_write_csv()Call that in
main()New (empty) test,
test_read_csv()Pull
read-csv-testinto body
Ah yes,
UserDB::read(string filename, binary=true)if/elsePull in
write-csvinto CSV branch
Write CSV: Frontend Program#
Build that functionality into bin/userdb-read-binaryfile.cpp
Rename to
bin/userdb-read.cppargv[1]… typeargv[2]… filename