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

GothenburgBitFactory / taskwarrior / 12343201393

15 Dec 2024 11:30PM UTC coverage: 84.419% (-1.1%) from 85.522%
12343201393

Pull #3724

github

web-flow
Merge 532931b9f into ddae5c4ba
Pull Request #3724: Support importing Taskwarrior v2.x data files

15 of 145 new or added lines in 4 files covered. (10.34%)

183 existing lines in 48 files now uncovered.

19289 of 22849 relevant lines covered (84.42%)

23168.82 hits per line

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

84.51
/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
// cmake.h include header must come first
29

30
#include <main.h>
31
#include <stdlib.h>
32
#include <test.h>
33

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

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

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

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

54
  /*
55

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

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

70
  TODO Task::urgency
71

72
  TODO Task::encode
73
  TODO Task::decode
74

75
  */
76

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

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

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

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

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

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

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

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

114
  ////////////////////////////////////////////////////////////////////////////////
115

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

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

130
  good = true;
1✔
131
  try {
132
    Task t5(
133
        R"({"uuid":"00000000-0000-0000-000000000001","description":"foo","entry":"1234567890"})");
1✔
134
  } catch (const std::string& e) {
1✔
135
    test.diag(e);
×
136
    good = false;
×
UNCOV
137
  }
×
138
  test.ok(good, "Task::Task ('{<minimal>}')");
1✔
139

140
  // Verify tag handling is correct
141
  Task t6;
1✔
142
  t6.set("entry", "20130602T224000Z");
4✔
143
  t6.set("description", "DESC");
4✔
144
  t6.addTag("tag1");
2✔
145
  test.is(t6.composeJSON(), R"({"description":"DESC","entry":"20130602T224000Z","tags":["tag1"]})",
4✔
146
          "JSON good");
147

148
  t6.addTag("tag2");
2✔
149
  test.is(t6.composeJSON(),
3✔
150
          R"({"description":"DESC","entry":"20130602T224000Z","tags":["tag1","tag2"]})",
151
          "JSON good");
152

153
  good = true;
1✔
154
  Task t7;
1✔
155
  try {
156
    t7 = Task(R"({"description":"DESC","entry":"20130602T224000Z","tags":["tag1","tag2"]})");
2✔
157
  } catch (const std::string& e) {
×
158
    test.diag(e);
×
159
    good = false;
×
UNCOV
160
  }
×
161
  test.ok(good, "Task::Task ('{two tags}')");
2✔
162
  test.is(t7.composeJSON(),
3✔
163
          R"({"description":"DESC","entry":"20130602T224000Z","tags":["tag1","tag2"]})",
164
          "JSON good");
165

166
  return 0;
×
167
}
1✔
168

169
////////////////////////////////////////////////////////////////////////////////
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

© 2025 Coveralls, Inc