• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

GothenburgBitFactory / taskwarrior / 9689737168

27 Jun 2024 02:29AM UTC coverage: 84.216% (-0.3%) from 84.513%
9689737168

push

github

web-flow
Un-deprecate the non-1/0 boolean values (#3522)

As per https://github.com/GothenburgBitFactory/tw.org/issues/867

Co-authored-by: Sebastian Carlos <sebastiancarlos@gmail.com>

19251 of 22859 relevant lines covered (84.22%)

19999.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.16
/test/t.test.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright 2006 - 2021, Tomas Babej, Paul Beckingham, Federico Hernandez.
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
//
12
// The above copyright notice and this permission notice shall be included
13
// in all copies or substantial portions of the Software.
14
//
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
//
23
// https://www.opensource.org/licenses/mit-license.php
24
//
25
////////////////////////////////////////////////////////////////////////////////
26

27
#include <cmake.h>
28
#include <stdlib.h>
29
#include <main.h>
30
#include <test.h>
31

32
////////////////////////////////////////////////////////////////////////////////
33
int main (int, char**)
1✔
34
{
35
  UnitTest test (48);
1✔
36
  Context context;
1✔
37
  Context::setContext(&context);
1✔
38

39
  // Ensure environment has no influence.
40
  unsetenv ("TASKDATA");
1✔
41
  unsetenv ("TASKRC");
1✔
42

43
  test.is ((int)Task::textToStatus ("pending"),   (int)Task::pending,   "textToStatus pending");
1✔
44
  test.is ((int)Task::textToStatus ("completed"), (int)Task::completed, "textToStatus completed");
1✔
45
  test.is ((int)Task::textToStatus ("deleted"),   (int)Task::deleted,   "textToStatus deleted");
1✔
46
  test.is ((int)Task::textToStatus ("recurring"), (int)Task::recurring, "textToStatus recurring");
1✔
47

48
  test.is (Task::statusToText (Task::pending),   "pending",   "statusToText pending");
1✔
49
  test.is (Task::statusToText (Task::completed), "completed", "statusToText completed");
1✔
50
  test.is (Task::statusToText (Task::deleted),   "deleted",   "statusToText deleted");
1✔
51
  test.is (Task::statusToText (Task::recurring), "recurring", "statusToText recurring");
1✔
52

53
/*
54

55
TODO Task::composeCSV
56
TODO Task::composeYAML
57
TODO Task::id
58
TODO Task::*Status
59
TODO Task::*Tag*
60
TODO Task::*Annotation*
61

62
TODO Task::addDependency
63
TODO Task::addDependency
64
TODO Task::removeDependency
65
TODO Task::removeDependency
66
TODO Task::getDependencies
67
TODO Task::getDependencies
68

69
TODO Task::urgency
70

71
TODO Task::encode
72
TODO Task::decode
73

74
*/
75

76
  // Task::operator==
77
  Task left ("{\"one\":\"1\", \"two\":\"2\", \"three\":\"3\"}");
2✔
78
  Task right (left);
1✔
79
  test.ok (left == right, "left == right -> true");
1✔
80
  left.set ("one", "1.0");
1✔
81
  test.notok (left == right, "left == right -> false");
1✔
82

83
  ////////////////////////////////////////////////////////////////////////////////
84
  Task task;
1✔
85

86
  // Task::set
87
  task = Task();
1✔
88
  task.set ("name", "value");
1✔
89
  test.is (task.composeJSON (), "{\"name\":\"value\"}", "Task::set");
1✔
90

91
  // Task::has
92
  test.ok    (task.has ("name"), "Task::has");
1✔
93
  test.notok (task.has ("woof"), "Task::has not");
1✔
94

95
  // Task::get_int
96
  task.set ("one", 1);
1✔
97
  test.is (task.composeJSON (), R"({"name":"value","one":"1"})", "Task::set");
1✔
98
  test.is (task.get_int ("one"), 1, "Task::get_int");
1✔
99

100
  // Task::get_ulong
101
  task.set ("two", "4294967295");
1✔
102
  test.is (task.composeJSON (), R"({"name":"value","one":"1","two":"4294967295"})", "Task::set");
1✔
103
  test.is ((size_t)task.get_ulong ("two"), (size_t)4294967295UL, "Task::get_ulong");
1✔
104

105
  // Task::remove
106
  task.remove ("one");
1✔
107
  task.remove ("two");
1✔
108
  test.is (task.composeJSON (), "{\"name\":\"value\"}", "Task::remove");
1✔
109

110
  // Task::all
111
  test.is (task.all ().size (), (size_t)1, "Task::all size");
1✔
112

113
  ////////////////////////////////////////////////////////////////////////////////
114

115
  Task::attributes["description"] = "string";
1✔
116
  Task::attributes["entry"] = "date";
1✔
117
  Task::attributes["tags"] = "string";
1✔
118
  Task::attributes["uuid"] = "string";
1✔
119

120
  bool good = true;
1✔
121
  try {Task t4 ("{}");}
2✔
122
  catch (const std::string& e){test.diag (e); good = false;}
×
123
  test.ok (good, "Task::Task ('{}')");
1✔
124

125
  good = true;
1✔
126
  try {Task t5 (R"({"uuid":"00000000-0000-0000-000000000001","description":"foo","entry":"1234567890"})");}
2✔
127
  catch (const std::string& e){test.diag (e); good = false;}
×
128
  test.ok (good, "Task::Task ('{<minimal>}')");
1✔
129

130
  // Verify tag handling is correct
131
  Task t6;
1✔
132
  t6.set ("entry", "20130602T224000Z");
1✔
133
  t6.set ("description", "DESC");
1✔
134
  t6.addTag ("tag1");
1✔
135
  test.is (t6.composeJSON (), R"({"description":"DESC","entry":"20130602T224000Z","tags":["tag1"]})", "JSON good");
1✔
136

137
  t6.addTag ("tag2");
1✔
138
  test.is (t6.composeJSON (), R"({"description":"DESC","entry":"20130602T224000Z","tags":["tag1","tag2"]})", "JSON good");
1✔
139

140
  good = true;
1✔
141
  Task t7;
1✔
142
  try {t7 = Task (R"({"description":"DESC","entry":"20130602T224000Z","tags":["tag1","tag2"]})");}
1✔
143
  catch (const std::string& e){test.diag (e); good = false;}
×
144
  test.ok (good, "Task::Task ('{two tags}')");
1✔
145
  test.is (t7.composeJSON (), R"({"description":"DESC","entry":"20130602T224000Z","tags":["tag1","tag2"]})", "JSON good");
1✔
146

147
  return 0;
1✔
148
}
1✔
149

150
////////////////////////////////////////////////////////////////////////////////
151

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc