• 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

90.91
/src/Operation.h
1
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright 2006 - 2024, 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
#ifndef INCLUDED_OPERATIOn
28
#define INCLUDED_OPERATIOn
29

30
#include <taskchampion-cpp/lib.h>
31

32
#include <optional>
33
#include <vector>
34

35
// Representation of a TaskChampion operation.
36
//
37
// This class wraps `tc::Operation&` and thus cannot outlive that underlying
38
// type.
39
class Operation {
40
 public:
41
  explicit Operation(const tc::Operation &);
42

43
  Operation(const Operation &other) = default;
44
  Operation &operator=(const Operation &other);
45

46
  // Create a vector of Operations given the result of `Replica::get_undo_operations` or
47
  // `Replica::get_task_operations`. The resulting vector must not outlive the input `rust::Vec`.
48
  static std::vector<Operation> operations(const rust::Vec<tc::Operation> &);
49

50
  // Methods from the underlying `tc::Operation`.
51
  bool is_create() const { return op->is_create(); }
1,862✔
52
  bool is_update() const { return op->is_update(); }
2,348✔
53
  bool is_delete() const { return op->is_delete(); }
16✔
54
  bool is_undo_point() const { return op->is_undo_point(); }
46✔
55
  std::string get_uuid() const { return std::string(op->get_uuid().to_string()); }
23✔
56
  ::rust::Vec<::tc::PropValuePair> get_old_task() const { return op->get_old_task(); };
57
  std::string get_property() const {
494✔
58
    std::string value;
494✔
59
    op->get_property(value);
494✔
60
    return value;
494✔
61
  }
62
  std::optional<std::string> get_value() const {
470✔
63
    std::optional<std::string> value{std::string()};
470✔
64
    if (!op->get_value(value.value())) {
470✔
65
      value = std::nullopt;
7✔
66
    }
67
    return value;
470✔
UNCOV
68
  }
×
69
  std::optional<std::string> get_old_value() const {
468✔
70
    std::optional<std::string> old_value{std::string()};
468✔
71
    if (!op->get_old_value(old_value.value())) {
468✔
72
      old_value = std::nullopt;
445✔
73
    }
74
    return old_value;
468✔
UNCOV
75
  }
×
76
  time_t get_timestamp() const { return static_cast<time_t>(op->get_timestamp()); }
2,076✔
77

78
  // Define a partial order on Operations:
79
  //  - Create < Update < Delete < UndoPoint
80
  //  - Given two updates, sort by timestamp
81
  bool operator<(const Operation &other) const;
82

83
 private:
84
  const tc::Operation *op;
85
};
86

87
#endif
88
////////////////////////////////////////////////////////////////////////////////
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