MCPcopy Create free account
hub / github.com/GothenburgBitFactory/taskwarrior / TEST_NAME

Function TEST_NAME

test/util_test.cpp:38–101  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

36
37////////////////////////////////////////////////////////////////////////////////
38int TEST_NAME(int, char**) {
39 UnitTest t(19);
40 Context context;
41 Context::setContext(&context);
42
43 // Ensure environment has no influence.
44 unsetenv("TASKDATA");
45 unsetenv("TASKRC");
46
47 // TODO int confirm4 (const std::string&);
48
49 // TODO const std::string uuid ();
50
51 // TODO These are in feedback.cpp, not util.cpp.
52 Task left;
53 left.set("zero", "0");
54 left.set("one", 1);
55 left.set("two", 2);
56
57 Task right;
58 right.set("zero", "00");
59 right.set("two", 2);
60 right.set("three", 3);
61
62 Task rightAgain(right);
63
64 std::string output = left.diff(right);
65 t.ok(!(left == right), "Detected changes");
66 t.ok(output.find("Zero will be changed from '0' to '00'") != std::string::npos,
67 "Detected change zero:0 -> zero:00");
68 t.ok(output.find("One will be deleted") != std::string::npos, "Detected deletion one:1 ->");
69 t.ok(output.find("Two") == std::string::npos, "Detected no change two:2 -> two:2");
70 t.ok(output.find("Three will be set to '3'") != std::string::npos,
71 "Detected addition -> three:3");
72
73 output = right.diff(rightAgain);
74 t.ok(output.find("No changes will be made") != std::string::npos, "No changes detected");
75
76 // std::vector<std::string> indentProject (const std::string&, const std::string whitespace=" ",
77 // char delimiter='.');
78 t.is(indentProject(""), "", "indentProject '' -> ''");
79 t.is(indentProject("one"), "one", "indentProject 'one' -> 'one'");
80 t.is(indentProject("one.two"), " two", "indentProject 'one.two' -> ' two'");
81 t.is(indentProject("one.two.three"), " three", "indentProject 'one.two.three' -> ' three'");
82
83 // bool nontrivial (const std::string&);
84 t.notok(nontrivial(""), "nontrivial '' -> false");
85 t.notok(nontrivial(" "), "nontrivial ' ' -> false");
86 t.notok(nontrivial("\t\t"), "nontrivial '\\t\\t' -> false");
87 t.notok(nontrivial(" \t \t"), "nontrivial ' \\t \\t' -> false");
88 t.ok(nontrivial("a"), "nontrivial 'a' -> true");
89 t.ok(nontrivial(" a"), "nontrivial ' a' -> true");
90 t.ok(nontrivial("a "), "nontrivial 'a ' -> true");
91 t.ok(nontrivial(" \t\ta"), "nontrivial ' \\t\\ta' -> true");
92 t.ok(nontrivial("a\t\t "), "nontrivial 'a\\t\\t ' -> true");
93
94 Datetime dt(1234526400);
95 Datetime max(std::numeric_limits<time_t>::max());

Callers

nothing calls this directly

Calls 9

indentProjectFunction · 0.85
nontrivialFunction · 0.85
checked_add_datetimeFunction · 0.85
setMethod · 0.80
diffMethod · 0.80
okMethod · 0.80
findMethod · 0.80
isMethod · 0.80
notokMethod · 0.80

Tested by

no test coverage detected