• 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

73.68
/src/columns/ColTypeDuration.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 <ColTypeDuration.h>
31
#include <Context.h>
32
#include <Eval.h>
33
#include <Filter.h>
34
#include <Variant.h>
35
#include <format.h>
36

37
////////////////////////////////////////////////////////////////////////////////
38
ColumnTypeDuration::ColumnTypeDuration() { _type = "duration"; }
119✔
39

40
////////////////////////////////////////////////////////////////////////////////
41
bool ColumnTypeDuration::validate(const std::string& input) const {
×
42
  return input.length() ? true : false;
×
43
}
44

45
////////////////////////////////////////////////////////////////////////////////
46
void ColumnTypeDuration::modify(Task& task, const std::string& value) {
10✔
47
  // Try to evaluate 'value'.  It might work.
48
  Variant evaluatedValue;
10✔
49
  try {
50
    Eval e;
10✔
51
    e.addSource(domSource);
10✔
52
    e.evaluateInfixExpression(value, evaluatedValue);
10✔
53
  }
10✔
54

55
  catch (...) {
×
56
    evaluatedValue = Variant(value);
×
UNCOV
57
  }
×
58

59
  // The duration is stored in raw form, but it must still be valid,
60
  // and therefore is parsed first.
61
  std::string label = "   [1;37;43mMODIFICATION [0m ";
10✔
62
  if (evaluatedValue.type() == Variant::type_duration) {
10✔
63
    // Store the raw value, for 'recur'.
64
    Context::getContext().debug(label + _name + " <-- " + (std::string)evaluatedValue + " <-- '" +
27✔
65
                                value + '\'');
18✔
66
    task.set(_name, evaluatedValue);
9✔
67
  } else
68
    throw format("The duration value '{1}' is not supported.", value);
3✔
69
}
11✔
70

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