• 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

49.15
/test/tdb2.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 <main.h>
32
#include <test.h>
33

34
Context context;
35

36
void cleardb ()
1✔
37
{
38
    // Remove any residual test files.
39
    rmdir ("./extensions");
1✔
40
    unlink ("./taskchampion.sqlite3");
1✔
41
}
1✔
42

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

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

54
  try
55
  {
56
    cleardb ();
1✔
57

58
    // Set the context to allow GC.
59
    context.config.set ("gc", 1);
1✔
60
    context.config.set ("debug", 1);
1✔
61

62
    context.tdb2.open_replica (".", true);
1✔
63

64
    // Try reading an empty database.
65
    std::vector <Task> pending          = context.tdb2.pending_tasks ();
1✔
66
    std::vector <Task> completed        = context.tdb2.completed_tasks ();
1✔
67
    int num_reverts_possible            = context.tdb2.num_reverts_possible ();
1✔
68
    int num_local_changes               = context.tdb2.num_local_changes ();
1✔
69

70
    t.is ((int) pending.size (),      0, "TDB2 Read empty pending");
1✔
71
    t.is ((int) completed.size (),    0, "TDB2 Read empty completed");
1✔
72
    t.is ((int) num_reverts_possible, 0, "TDB2 Read empty undo");
1✔
73
    t.is ((int) num_local_changes,    0, "TDB2 Read empty backlog");
1✔
74

75
    // Add a task.
76
    Task task (R"([description:"description" name:"value"])");
3✔
77
    context.tdb2.add (task);
×
78

79
    pending              = context.tdb2.pending_tasks ();
×
80
    completed            = context.tdb2.completed_tasks ();
×
81
    num_reverts_possible = context.tdb2.num_reverts_possible ();
×
82
    num_local_changes    = context.tdb2.num_local_changes ();
×
83

84
    t.is ((int) pending.size (),      1, "TDB2 after add, 1 pending task");
×
85
    t.is ((int) completed.size (),    0, "TDB2 after add, 0 completed tasks");
×
86
    t.is ((int) num_reverts_possible, 1, "TDB2 after add, 1 revert possible");
×
87
    t.is ((int) num_local_changes,    6, "TDB2 after add, 6 local changes");
×
88

89
    task.set ("description", "This is a test");
×
90
    context.tdb2.modify (task);
×
91

92
    pending              = context.tdb2.pending_tasks ();
×
93
    completed            = context.tdb2.completed_tasks ();
×
94
    num_reverts_possible = context.tdb2.num_reverts_possible ();
×
95
    num_local_changes    = context.tdb2.num_local_changes ();
×
96

97
    t.is ((int) pending.size (),      1, "TDB2 after set, 1 pending task");
×
98
    t.is ((int) completed.size (),    0, "TDB2 after set, 0 completed tasks");
×
99
    t.is ((int) num_reverts_possible, 1, "TDB2 after set, 1 revert possible");
×
100

101
    // At this point, there may be 7 or 8 local changes, depending on whether
102
    // the `modified` property changed between the `add` and `modify`
103
    // invocation. That only happens if the clock ticks over to the next second
104
    // between those invocations.
105
    t.ok (num_local_changes == 7 || num_local_changes == 8,
×
106
          "TDB2 after set, 7 or 8 local changes");
107

108
    // Reset for reuse.
109
    cleardb ();
×
110
    context.tdb2.open_replica (".", true);
×
111

112
    // TODO complete a task
113
    // TODO gc
114
  }
2✔
115

116
  catch (const std::string& error)
1✔
117
  {
118
    t.diag (error);
1✔
119
    return -1;
1✔
120
  }
1✔
121

122
  catch (...)
×
123
  {
124
    t.diag ("Unknown error.");
×
125
    return -2;
×
126
  }
127

128
  rmdir ("./extensions");
×
129
  unlink ("./pending.data");
×
130
  unlink ("./completed.data");
×
131
  unlink ("./undo.data");
×
132
  unlink ("./backlog.data");
×
133

134
  return 0;
×
135
}
1✔
136

137
////////////////////////////////////////////////////////////////////////////////
138

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