• 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.89
/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
#include <iostream>
29
#include <stdlib.h>
30
#include <unistd.h>
31
#include <stdio.h>
32
#include <Context.h>
33
#include <Column.h>
34
#include <Task.h>
35
#include <ViewTask.h>
36
#include <test.h>
37
#include <main.h>
38

39
Context context;
40
extern std::string configurationDefaults;
41

42
////////////////////////////////////////////////////////////////////////////////
43
int main (int, char**)
1✔
44
{
45
  UnitTest t (1);
1✔
46
  Context context;
1✔
47
  Context::setContext(&context);
1✔
48

49
  // Ensure environment has no influence.
50
  unsetenv ("TASKDATA");
1✔
51
  unsetenv ("TASKRC");
1✔
52

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

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

99
    std::vector <Task> data;
1✔
100
    data.push_back (t1);
1✔
101
    data.push_back (t2);
1✔
102
    data.push_back (t3);
1✔
103

104
    // Sequence of tasks.
105
    std::vector <int> sequence;
1✔
106
    sequence.push_back (0);
1✔
107
    sequence.push_back (1);
1✔
108
    sequence.push_back (2);
1✔
109

110
    sort_tasks (data, sequence, "description+,id-");
1✔
111

112
    // Create colors.
113
    Color header_color (Color (Color::yellow, Color::nocolor, false, false, false));
1✔
114
    Color odd_color ("on gray1");
1✔
115
    Color even_color ("on gray0");
1✔
116

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

143
    // Render the view.
144
    std::cout << view.render (data, sequence);
1✔
145
    int expected_lines = 5;
1✔
146
    if (!isatty (fileno (stdout)))
1✔
147
      expected_lines = 6;
1✔
148

149
    t.is (view.lines (), expected_lines, "View::lines == 5");
1✔
150

151
    // Now render a string-only grid.
152
    context.config.set ("fontunderline", false);
1✔
153
    Color single_cell ("bold white on red");
1✔
154
  }
1✔
155

156
  catch (const std::string& e)
×
157
  {
158
    t.fail ("Exception thrown.");
×
159
    t.diag (e);
×
160
  }
161

162
  return 0;
1✔
163
}
1✔
164

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