Unit Tests - all file formats
- Added unit tests to verify correct parsing of file formats 1, 2 and 3.
This commit is contained in:
@@ -31,7 +31,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
UnitTest test (8);
|
UnitTest test (10);
|
||||||
|
|
||||||
T t;
|
T t;
|
||||||
std::string s = t.compose ();
|
std::string s = t.compose ();
|
||||||
@@ -53,12 +53,27 @@ int main (int argc, char** argv)
|
|||||||
test.is (s[37], 'r', "T::setStatus (recurring)");
|
test.is (s[37], 'r', "T::setStatus (recurring)");
|
||||||
test.diag (s);
|
test.diag (s);
|
||||||
|
|
||||||
// Round trip test.
|
std::string format3 = "00000000-0000-0000-0000-000000000000 - [] [] [] Sample\n";
|
||||||
std::string sample = "00000000-0000-0000-0000-000000000000 - [] [] [] Sample";
|
|
||||||
T t2;
|
// Format 1 Round trip test.
|
||||||
t2.parse (sample);
|
std::string sample = "[] [] Sample";
|
||||||
sample += "\n";
|
T tf1;
|
||||||
test.is (t2.compose (), sample, "T::parse -> T::compose round trip");
|
tf1.parse (sample);
|
||||||
|
test.is (tf1.compose ().substr (36, std::string::npos),
|
||||||
|
format3.substr (36, std::string::npos),
|
||||||
|
"T::parse format 1 -> T::compose round trip");
|
||||||
|
|
||||||
|
// Format 2 Round trip test.
|
||||||
|
sample = "00000000-0000-0000-0000-000000000000 - [] [] Sample";
|
||||||
|
T tf2;
|
||||||
|
tf2.parse (sample);
|
||||||
|
test.is (tf2.compose (), format3, "T::parse format 2 -> T::compose round trip");
|
||||||
|
|
||||||
|
// Format 3 Round trip test.
|
||||||
|
sample = "00000000-0000-0000-0000-000000000000 - [] [] [] Sample";
|
||||||
|
T tf3;
|
||||||
|
tf3.parse (sample);
|
||||||
|
test.is (tf3.compose (), format3, "T::parse format 3 -> T::compose round trip");
|
||||||
|
|
||||||
// b10b3236-70d8-47bb-840a-b4c430758fb6 - [foo] [bar:baz] [1237865996:'woof'] sample\n
|
// b10b3236-70d8-47bb-840a-b4c430758fb6 - [foo] [bar:baz] [1237865996:'woof'] sample\n
|
||||||
// ....:....|....:....|....:....|....:....|....:....|....:....|....:....|....:....|....:....|
|
// ....:....|....:....|....:....|....:....|....:....|....:....|....:....|....:....|....:....|
|
||||||
|
|||||||
Reference in New Issue
Block a user