Danny Robson
f6056153e3
This places, at long last, the core library code into the same namespace as the extended library code.
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
#include "tap.hpp"
|
|
#include "string.hpp"
|
|
#include "types.hpp"
|
|
#include "iterator.hpp"
|
|
|
|
#include <vector>
|
|
|
|
int
|
|
main (int, char**)
|
|
{
|
|
cruft::TAP::logger tap;
|
|
|
|
// the string_literal prefix is required to (easily) construct a string
|
|
// with an internal null character.
|
|
using namespace std::literals::string_literals;
|
|
const std::string csv = "\0,a,123,,this is a test,"s;
|
|
|
|
// expected test data must be a std::string so we can check embedded
|
|
// nulls (which are ambiguous when using a cstr).
|
|
struct foo {
|
|
const std::string value;
|
|
const char *message;
|
|
} TESTS[] = {
|
|
{ "\0"s, "null" },
|
|
{ "a", "single letter" },
|
|
{ "123", "three digits" },
|
|
{ "", "empty string" },
|
|
{ "this is a test", "string with spaces" },
|
|
{ "", "trailing empty" }
|
|
};
|
|
|
|
cruft::view src { csv.c_str (), csv.size () };
|
|
for (auto [tok, expected]: cruft::zip (cruft::tokeniser (src, ','), TESTS)) {
|
|
tap.expect (equal (tok, expected.value), "%s", expected.message);
|
|
}
|
|
|
|
return tap.status ();
|
|
} |