mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Add round-trip tests
This commit is contained in:
parent
043fea04e9
commit
b64f6f7568
1 changed files with 28 additions and 10 deletions
|
@ -32,7 +32,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int, char**)
|
||||
{
|
||||
UnitTest t (40);
|
||||
UnitTest t (48);
|
||||
|
||||
// bool is_started () const;
|
||||
// bool is_ended () const;
|
||||
|
@ -127,41 +127,59 @@ int main (int, char**)
|
|||
i12 = IntervalFactory::fromSerialization ("inc");
|
||||
t.is (i12.json (), "{}",
|
||||
"JSON '{}'");
|
||||
t.is (IntervalFactory::fromJson (i12.json ()).serialize (),
|
||||
"inc",
|
||||
"Round-trip 'inc'");
|
||||
|
||||
Interval i13;
|
||||
i13 = IntervalFactory::fromSerialization ("inc # foo");
|
||||
t.is (i13.json (), "{\"tags\":[\"foo\"]}",
|
||||
"JSON '{\"tags\":[\"foo\"]}'");
|
||||
|
||||
t.is (IntervalFactory::fromJson (i13.json ()).serialize (),
|
||||
"inc # foo",
|
||||
"Round-trip 'inc # foo'");
|
||||
Interval i14;
|
||||
i14 = IntervalFactory::fromSerialization ("inc # bar foo");
|
||||
t.is (i14.json (), "{\"tags\":[\"bar\",\"foo\"]}",
|
||||
"JSON '{\"tags\":[\"bar\",\"foo\"]}'");
|
||||
|
||||
t.is (IntervalFactory::fromJson (i14.json ()).serialize (),
|
||||
"inc # bar foo",
|
||||
"Round-trip 'inc # bar foo'");
|
||||
Interval i15;
|
||||
i15 = IntervalFactory::fromSerialization ("inc 19700101T000001Z");
|
||||
t.is (i15.json (), "{\"start\":\"19700101T000001Z\"}",
|
||||
"JSON '{\"start\":\"19700101T000001Z\"}'");
|
||||
|
||||
t.is (IntervalFactory::fromJson (i15.json ()).serialize (),
|
||||
"inc 19700101T000001Z",
|
||||
"Round-trip 'inc 19700101T000001Z'");
|
||||
Interval i16;
|
||||
i16 = IntervalFactory::fromSerialization ("inc 19700101T000001Z - 19700101T000002Z");
|
||||
t.is (i16.json (), "{\"start\":\"19700101T000001Z\",\"end\":\"19700101T000002Z\"}",
|
||||
"JSON '{\"start\":\"19700101T000001Z\",\"end\":\"19700101T000002Z\"}'");
|
||||
|
||||
t.is (IntervalFactory::fromJson (i16.json ()).serialize (),
|
||||
"inc 19700101T000001Z - 19700101T000002Z",
|
||||
"Round-trip 'inc 19700101T000001Z - 19700101T000002Z'");
|
||||
Interval i17;
|
||||
i17 = IntervalFactory::fromSerialization ("inc 19700101T000001Z # bar foo");
|
||||
t.is (i17.json (), "{\"start\":\"19700101T000001Z\",\"tags\":[\"bar\",\"foo\"]}",
|
||||
"JSON '{\"start\":\"19700101T000001Z\",\"tags\":[\"bar\",\"foo\"]}'");
|
||||
|
||||
t.is (IntervalFactory::fromJson (i17.json ()).serialize (),
|
||||
"inc 19700101T000001Z # bar foo",
|
||||
"Round-trip 'inc 19700101T000001Z # bar foo'");
|
||||
Interval i18;
|
||||
i18 = IntervalFactory::fromSerialization ("inc 19700101T000001Z - 19700101T000002Z # bar foo");
|
||||
t.is (i18.json (), "{\"start\":\"19700101T000001Z\",\"end\":\"19700101T000002Z\",\"tags\":[\"bar\",\"foo\"]}",
|
||||
"JSON '{\"start\":\"19700101T000001Z\",\"end\":\"19700101T000002Z\",\"tags\":[\"bar\",\"foo\"]}'");
|
||||
|
||||
t.is (IntervalFactory::fromJson (i18.json ()).serialize (),
|
||||
"inc 19700101T000001Z - 19700101T000002Z # bar foo",
|
||||
"Round-trip 'inc 19700101T000001Z - 19700101T000002Z # bar foo'");
|
||||
Interval i19;
|
||||
i19 = IntervalFactory::fromSerialization ("inc 19700101T000001Z - 19700101T000002Z # \"Trans-Europe Express\" bar foo");
|
||||
t.is (i19.json (), "{\"start\":\"19700101T000001Z\",\"end\":\"19700101T000002Z\",\"tags\":[\"Trans-Europe Express\",\"bar\",\"foo\"]}",
|
||||
"JSON '{\"start\":\"19700101T000001Z\",\"end\":\"19700101T000002Z\",\"tags\":[\"Trans-Europe Express\",\"bar\",\"foo\"]}'");
|
||||
t.is (IntervalFactory::fromJson (i19.json ()).serialize (),
|
||||
"inc 19700101T000001Z - 19700101T000002Z # \"Trans-Europe Express\" bar foo",
|
||||
"Round-trip 'inc 19700101T000001Z - 19700101T000002Z # \"Trans-Europe Express\" bar foo");
|
||||
|
||||
Interval i20;
|
||||
i20.tag ("foo");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue