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

Function TEST_NAME

test/tw_2689_test.cpp:35–94  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

33
34////////////////////////////////////////////////////////////////////////////////
35int TEST_NAME(int, char**) {
36 UnitTest test(12);
37
38 // Ensure environment has no influence.
39 unsetenv("TASKDATA");
40 unsetenv("TASKRC");
41
42 // Inform Task about the attributes in the JSON below
43 Task::attributes["depends"] = "string";
44 Task::attributes["uuid"] = "string";
45
46 // depends in [..] string from a taskserver (issue#2689)
47 auto sample =
48 "{"
49 "\"depends\":\"[\\\"92a40a34-37f3-4785-8ca1-ff89cfbfd105\\\",\\\"e08e35fa-e42b-4de0-acc4-"
50 "518fca8f6365\\\"]\","
51 "\"uuid\":\"00000000-0000-0000-0000-000000000000\""
52 "}";
53 auto json = Task(sample);
54 auto value = json.get("uuid");
55 test.is(value, "00000000-0000-0000-0000-000000000000", "json [..] uuid");
56 value = json.get("depends");
57 test.is(value, "92a40a34-37f3-4785-8ca1-ff89cfbfd105,e08e35fa-e42b-4de0-acc4-518fca8f6365",
58 "json [..] depends");
59 test.ok(json.has("dep_92a40a34-37f3-4785-8ca1-ff89cfbfd105"), "json [..] dep attr");
60 test.ok(json.has("dep_e08e35fa-e42b-4de0-acc4-518fca8f6365"), "json [..] dep attr");
61
62 // depends in comma-delimited string from a taskserver (deprecated format)
63 sample =
64 "{"
65 "\"depends\":\"92a40a34-37f3-4785-8ca1-ff89cfbfd105,e08e35fa-e42b-4de0-acc4-518fca8f6365\","
66 "\"uuid\":\"00000000-0000-0000-0000-000000000000\""
67 "}";
68 json = Task(sample);
69 value = json.get("uuid");
70 test.is(value, "00000000-0000-0000-0000-000000000000", "json comma-separated uuid");
71 value = json.get("depends");
72 test.is(value, "92a40a34-37f3-4785-8ca1-ff89cfbfd105,e08e35fa-e42b-4de0-acc4-518fca8f6365",
73 "json comma-separated depends");
74 test.ok(json.has("dep_92a40a34-37f3-4785-8ca1-ff89cfbfd105"), "json comma-separated dep attr");
75 test.ok(json.has("dep_e08e35fa-e42b-4de0-acc4-518fca8f6365"), "json comma-separated dep attr");
76
77 // depends in a JSON array from a taskserver
78 sample =
79 "{"
80 "\"depends\":[\"92a40a34-37f3-4785-8ca1-ff89cfbfd105\",\"e08e35fa-e42b-4de0-acc4-"
81 "518fca8f6365\"],"
82 "\"uuid\":\"00000000-0000-0000-0000-000000000000\""
83 "}";
84 json = Task(sample);
85 value = json.get("uuid");
86 test.is(value, "00000000-0000-0000-0000-000000000000", "json array uuid");
87 value = json.get("depends");
88 test.is(value, "92a40a34-37f3-4785-8ca1-ff89cfbfd105,e08e35fa-e42b-4de0-acc4-518fca8f6365",
89 "json array depends");
90 test.ok(json.has("dep_92a40a34-37f3-4785-8ca1-ff89cfbfd105"), "json array dep attr");
91 test.ok(json.has("dep_e08e35fa-e42b-4de0-acc4-518fca8f6365"), "json array dep attr");
92

Callers

nothing calls this directly

Calls 5

isMethod · 0.80
okMethod · 0.80
TaskClass · 0.50
getMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected