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

GothenburgBitFactory / taskwarrior / 12086238352

29 Nov 2024 02:12PM UTC coverage: 85.803% (+0.002%) from 85.801%
12086238352

push

github

web-flow
Check Datetime addition when performing recurrence (#3708)

21 of 23 new or added lines in 2 files covered. (91.3%)

2 existing lines in 2 files now uncovered.

19256 of 22442 relevant lines covered (85.8%)

22959.47 hits per line

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

97.67
/test/util_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
#include <util.h>
34

35
#include <iostream>
36
#include <limits>
37

38
////////////////////////////////////////////////////////////////////////////////
39
int TEST_NAME(int, char**) {
1✔
40
  UnitTest t(19);
1✔
41
  Context context;
1✔
42
  Context::setContext(&context);
1✔
43

44
  // Ensure environment has no influence.
45
  unsetenv("TASKDATA");
1✔
46
  unsetenv("TASKRC");
1✔
47

48
  // TODO int confirm4 (const std::string&);
49

50
  // TODO const std::string uuid ();
51

52
  // TODO These are in feedback.cpp, not util.cpp.
53
  Task left;
1✔
54
  left.set("zero", "0");
1✔
55
  left.set("one", 1);
1✔
56
  left.set("two", 2);
1✔
57

58
  Task right;
1✔
59
  right.set("zero", "00");
1✔
60
  right.set("two", 2);
1✔
61
  right.set("three", 3);
1✔
62

63
  Task rightAgain(right);
1✔
64

65
  std::string output = left.diff(right);
1✔
66
  t.ok(!(left == right), "Detected changes");
1✔
67
  t.ok(output.find("Zero will be changed from '0' to '00'") != std::string::npos,
1✔
68
       "Detected change zero:0 -> zero:00");
69
  t.ok(output.find("One will be deleted") != std::string::npos, "Detected deletion one:1 ->");
1✔
70
  t.ok(output.find("Two") == std::string::npos, "Detected no change two:2 -> two:2");
1✔
71
  t.ok(output.find("Three will be set to '3'") != std::string::npos,
1✔
72
       "Detected addition -> three:3");
73

74
  output = right.diff(rightAgain);
1✔
75
  t.ok(output.find("No changes will be made") != std::string::npos, "No changes detected");
1✔
76

77
  // std::vector<std::string> indentProject (const std::string&, const std::string whitespace="  ",
78
  // char delimiter='.');
79
  t.is(indentProject(""), "", "indentProject '' -> ''");
1✔
80
  t.is(indentProject("one"), "one", "indentProject 'one' -> 'one'");
1✔
81
  t.is(indentProject("one.two"), "  two", "indentProject 'one.two' -> '  two'");
1✔
82
  t.is(indentProject("one.two.three"), "    three", "indentProject 'one.two.three' -> '    three'");
1✔
83

84
  // bool nontrivial (const std::string&);
85
  t.notok(nontrivial(""), "nontrivial '' -> false");
1✔
86
  t.notok(nontrivial("   "), "nontrivial '   ' -> false");
1✔
87
  t.notok(nontrivial("\t\t"), "nontrivial '\\t\\t' -> false");
1✔
88
  t.notok(nontrivial(" \t \t"), "nontrivial ' \\t \\t' -> false");
1✔
89
  t.ok(nontrivial("a"), "nontrivial 'a' -> true");
1✔
90
  t.ok(nontrivial("   a"), "nontrivial '   a' -> true");
1✔
91
  t.ok(nontrivial("a   "), "nontrivial 'a   ' -> true");
1✔
92
  t.ok(nontrivial("  \t\ta"), "nontrivial '  \\t\\ta' -> true");
1✔
93
  t.ok(nontrivial("a\t\t  "), "nontrivial 'a\\t\\t  ' -> true");
1✔
94

95
  Datetime dt(1234526400);
1✔
96
  Datetime max(std::numeric_limits<time_t>::max());
1✔
97
  t.ok(checked_add_datetime(dt, 10).has_value(), "small delta");
1✔
98
  t.ok(!checked_add_datetime(dt, 0x100000000).has_value(), "delta > 32bit");
1✔
99
  t.ok(!checked_add_datetime(max, 1).has_value(), "huge base time");
1✔
100

UNCOV
101
  return 0;
×
102
}
1✔
103

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