• 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

93.15
/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 <main.h>
35
#include <stdio.h>
36
#include <stdlib.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
  UnitTest t(1);
1✔
48
  Context context;
1✔
49
  Context::setContext(&context);
1✔
50

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

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

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

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

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

114
    sort_tasks(data, sequence, "description+,id-");
1✔
115

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

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

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

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

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

159
  catch (const std::string& e) {
×
160
    t.fail("Exception thrown.");
×
161
    t.diag(e);
×
UNCOV
162
  }
×
163

164
  return 0;
×
165
}
1✔
166

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