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.cpp
totest-csv.cpp
Expected 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 binary
read_file()
Compare
Implement
In
UserDB::write(string filename, bool binary=true)
if/else
Pull in
write-csv
into CSV branch
Write CSV: Frontend Program¶
Build that functionality into bin/userdb-write-binaryfile.cpp
Rename to
bin/userdb-write.cpp
argv[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-test
into body
Ah yes,
UserDB::read(string filename, binary=true)
if/else
Pull in
write-csv
into CSV branch
Write CSV: Frontend Program¶
Build that functionality into bin/userdb-read-binaryfile.cpp
Rename to
bin/userdb-read.cpp
argv[1]
… typeargv[2]
… filename