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

GothenburgBitFactory / taskwarrior / 20752910333

06 Jan 2026 03:23PM UTC coverage: 85.247% (+0.09%) from 85.162%
20752910333

push

github

djmitche
Update to TaskChampion-3.0.1

19617 of 23012 relevant lines covered (85.25%)

23481.55 hits per line

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

93.33
/test/view_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 <Column.h>
31
#include <Context.h>
32
#include <Task.h>
33
#include <ViewTask.h>
34
#include <sort.h>
35
#include <stdio.h>
36
#include <tempdir.h>
37
#include <test.h>
38
#include <unistd.h>
39

40
#include <iostream>
41

42
Context context;
43
extern std::string configurationDefaults;
44

45
////////////////////////////////////////////////////////////////////////////////
46
int TEST_NAME(int, char**) {
1✔
47
  TempDir tmp;
1✔
48
  UnitTest t(1);
1✔
49
  Context context;
1✔
50
  Context::setContext(&context);
1✔
51
  context.tdb2.open_replica(tmp.path.string(), true, false);
1✔
52

53
  // Ensure environment has no influence.
54
  unsetenv("TASKDATA");
1✔
55
  unsetenv("TASKRC");
1✔
56

57
  try {
58
    // Set up configuration.
59
    context.config.parse(configurationDefaults);
1✔
60
    context.config.set("fontunderline", true);
2✔
61
    context.config.set("tag.indicator", "+");
4✔
62
    context.config.set("dependency.indicator", "D");
4✔
63
    context.config.set("recurrence.indicator", "R");
4✔
64
    context.config.set("active.indicator", "A");
4✔
65
    context.config.set("dateformat", "Y-M-D");
4✔
66
    context.config.set("indent.annotation", "2");
4✔
67

68
    // Two sample tasks.
69
    t.ok(true, "zero");
2✔
70
    Task t1(
71
        "{"
72
        "\"status\":\"pending\", "
73
        "\"uuid\":\"2a64f6e0-bf8e-430d-bf71-9ec3f0d9b661\", "
74
        "\"description\":\"This is the description text\", "
75
        "\"project\":\"Home\", "
76
        "\"priority\":\"H\", "
77
        "\"annotation_1234567890\":\"This is an annotation\", "
78
        "\"start\":\"1234567890\", "
79
        "\"due\":\"1234567890\", "
80
        "\"tags\":\"one,two\""
81
        "}");
1✔
82
    t1.id = 1;
1✔
83
    t.ok(true, "one");
2✔
84
    Task t2(
85
        "{"
86
        "\"status\":\"pending\", "
87
        "\"uuid\":\"f30cb9c3-3fc0-483f-bfb2-3bf134f00694\", "
88
        "\"description\":\"This is the description text\", "
89
        "\"project\":\"Garden Care\", "
90
        "\"recur\":\"monthly\", "
91
        "\"depends\":\"2a64f6e0-bf8e-430d-bf71-9ec3f0d9b661\""
92
        "}");
1✔
93
    t2.id = 11;
1✔
94
    t.ok(true, "two");
2✔
95
    Task t3(
96
        "{"
97
        "\"status\":\"pending\", "
98
        "\"uuid\":\"c44cb9c3-3fc0-483f-bfb2-3bf134f05554\", "
99
        "\"description\":\"Another description\", "
100
        "\"project\":\"Garden\""
101
        "}");
1✔
102
    t3.id = 8;
1✔
103
    t.ok(true, "three");
1✔
104

105
    std::vector<Task> data;
1✔
106
    data.push_back(t1);
1✔
107
    data.push_back(t2);
1✔
108
    data.push_back(t3);
1✔
109

110
    // Sequence of tasks.
111
    std::vector<int> sequence;
1✔
112
    sequence.push_back(0);
1✔
113
    sequence.push_back(1);
1✔
114
    sequence.push_back(2);
1✔
115

116
    sort_tasks(data, sequence, "description+,id-");
1✔
117

118
    // Create colors.
119
    Color header_color(Color(Color::yellow, Color::nocolor, false, false, false));
1✔
120
    Color odd_color("on gray1");
2✔
121
    Color even_color("on gray0");
2✔
122

123
    // Create a view.
124
    std::string report = "view.t";
1✔
125
    ViewTask view;
1✔
126
    view.add(Column::factory("id", report));
2✔
127
    view.add(Column::factory("uuid.short", report));
2✔
128
    view.add(Column::factory("project", report));
2✔
129
    view.add(Column::factory("priority", report));
2✔
130
    view.add(Column::factory("tags", report));
2✔
131
    view.add(Column::factory("tags.count", report));
2✔
132
    view.add(Column::factory("description", report));
2✔
133
    view.add(Column::factory("depends.indicator", report));
2✔
134
    view.add(Column::factory("recur.indicator", report));
2✔
135
    view.add(Column::factory("status.short", report));
2✔
136
    view.add(Column::factory("due.countdown", report));
2✔
137
    view.add(Column::factory("start.active", report));
2✔
138
    view.add(Column::factory("urgency", report));
1✔
139
    view.width(context.getWidth());
1✔
140
    view.leftMargin(4);
1✔
141
    view.extraPadding(0);
1✔
142
    view.intraPadding(1);
1✔
143
    view.colorHeader(header_color);
1✔
144
    view.colorOdd(odd_color);
1✔
145
    view.colorEven(even_color);
1✔
146
    view.intraColorOdd(odd_color);
1✔
147
    view.intraColorEven(even_color);
1✔
148

149
    // Render the view.
150
    std::cout << view.render(data, sequence);
1✔
151
    int expected_lines = 5;
1✔
152
    if (!isatty(fileno(stdout))) expected_lines = 6;
1✔
153

154
    t.is(view.lines(), expected_lines, "View::lines == 5");
2✔
155

156
    // Now render a string-only grid.
157
    context.config.set("fontunderline", false);
2✔
158
    Color single_cell("bold white on red");
1✔
159
  }
1✔
160

161
  catch (const std::string& e) {
×
162
    t.fail("Exception thrown.");
×
163
    t.diag(e);
×
164
  }
×
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

© 2026 Coveralls, Inc