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

antonvw / wex / 24932513120

25 Apr 2026 01:57PM UTC coverage: 64.281% (-0.05%) from 64.326%
24932513120

push

github

web-flow
1202 allow comparing file using unified diff (#1232)

* first step, update the unified diff class to handle non git diffs

* when using diff as comparator add U0 flags, and changes for process::system

* factory::unified_diff now reports diff

* added ui item for unified diff opening for lists

* fixed path for unified diff: it is before the tab

* and added test for the paths

* changes after review

18754 of 32046 branches covered (58.52%)

Branch coverage included in aggregate %.

14955 of 20394 relevant lines covered (73.33%)

1457.93 hits per line

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

40.7
/src/factory/unified-diff.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
// Name:      unified-diff.cpp
3
// Purpose:   Implementation of class wex::factory::unified_diff
4
//            https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
5
// Author:    Anton van Wezenbeek
6
// Copyright: (c) 2024-2026 Anton van Wezenbeek
7
////////////////////////////////////////////////////////////////////////////////
8

9
#include <wex/core/log.h>
10
#include <wex/factory/frame.h>
11
#include <wex/factory/unified-diff.h>
12
#include <wx/app.h>
13

14
#include <algorithm>
15
#include <utility>
16

17
#include "unified-diff-parser.h"
18

19
wex::factory::unified_diff::unified_diff(
27✔
20
  std::string     input,
21
  factory::frame* frame)
27✔
22
  : m_input(std::move(input))
27✔
23
  , m_range{0, 0, 0, 0}
27✔
24
  , m_frame(frame)
27✔
25
{
26
  if (
27✔
27
    auto* frame = dynamic_cast<wex::factory::frame*>(wxTheApp->GetTopWindow());
27!
28
    frame != nullptr && m_frame != nullptr)
27✔
29
  {
30
    m_frame = frame;
3✔
31
  }
32

33
  if (m_frame != nullptr)
27✔
34
  {
35
    m_frame->page_save();
3✔
36
  }
37
}
27✔
38

39
bool wex::factory::unified_diff::parse()
17✔
40
{
41
  return unified_diff_parser(this).parse();
17✔
42
}
43

44
bool wex::factory::unified_diff::report_diff()
15✔
45
{
46
  return m_frame != nullptr && m_frame->report_unified_diff(this);
15!
47
}
48

49
void wex::factory::unified_diff::report_diff_finish()
11✔
50
{
51
  if (m_frame != nullptr)
11!
52
  {
53
    m_frame->report_unified_diff(this);
×
54
    m_frame->page_restore();
×
55
  }
56
}
11✔
57

58
void wex::factory::unified_diff::trace(const std::string& text) const
41✔
59
{
60
  if (log::get_level() != log::level_t::TRACE)
41!
61
  {
62
    return;
41✔
63
  }
64

65
  using boost::describe::operators::operator<<;
66

67
  std::stringstream str;
×
68
  str << "type: " << boost::describe::enum_to_string(m_type, "none") << " "
×
69
      << *this << " ranges: ";
×
70

71
  std::ranges::for_each(
×
72
    m_range,
×
73
    [this, &str](const auto& it)
×
74
    {
75
      str << std::to_string(it) << ",";
×
76
    });
×
77

78
  str << " text sizes: ";
×
79

80
  std::ranges::for_each(
×
81
    m_text,
×
82
    [this, &str](const auto& it)
×
83
    {
84
      str << it.size() << ",";
×
85
    });
×
86

87
  str << " paths: ";
×
88

89
  std::ranges::for_each(
×
90
    m_path,
×
91
    [this, &str](const auto& it)
×
92
    {
93
      str << it.string() << ",";
×
94
    });
×
95

96
  log::trace("unified_diff::" + text) << str.str();
×
97
}
×
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