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

mbits-os / quick_dra / 22060959554

16 Feb 2026 11:29AM UTC coverage: 97.468% (+10.5%) from 87.008%
22060959554

Pull #39

github

web-flow
Merge 3b010bc42 into 7d773e4d9
Pull Request #39: testing

64 of 66 new or added lines in 21 files covered. (96.97%)

23 existing lines in 3 files now uncovered.

4388 of 4502 relevant lines covered (97.47%)

1903.82 hits per line

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

90.0
/libs/libpersist/src/ref.cpp
1
// Copyright (c) 2026 midnightBITS
2
// This code is licensed under MIT license (see LICENSE for details)
3

4
#include <fmt/format.h>
5
#include <yaml/ref.hpp>
6

7
using namespace std::literals;
8

9
namespace yaml {
10
        namespace {
11
                thread_local struct base_ctx::error_handler* head = nullptr;
12

13
                void c4_error_handler(const char* msg,
14
                                      size_t msg_len,
15
                                      c4::yml::Location loc,
16
                                      void* user_data) {
UNCOV
17
                        reinterpret_cast<base_ctx::error_handler*>(user_data)->handle_error(
×
18
                            loc, std::string_view{msg, msg_len});
19
                        throw c4_error_exception{};
×
20
                }
21
        }  // namespace
22

23
        base_ctx::error_handler::error_handler() : prev{head} { head = this; }
418✔
24
        base_ctx::error_handler::~error_handler() {
418✔
25
                head = prev;
1,669✔
26
                if (previous) {
418✔
27
                        c4::yml::set_callbacks(*previous);
1,669✔
28
                }
1,251✔
29
        }
1,669✔
30

31
        void base_ctx::error_handler::install_in_c4() {
418✔
32
                previous = c4::yml::get_callbacks();
1,669✔
33
                c4::yml::Callbacks callbacks;
1,669✔
34
                callbacks.m_user_data = this;
1,669✔
35
                callbacks.m_error = c4_error_handler;
1,669✔
36
                c4::yml::set_callbacks(callbacks);
1,669✔
37
        }
1,669✔
38

39
        bool base_ctx::error_handler::handle_msg(c4::yml::Location const& loc,
51✔
40
                                                 std::string_view msg,
41
                                                 std::string_view level) {
1✔
42
                if (!loc.name.empty()) {
103✔
43
                        fmt::print(stderr, "{}:", view(loc.name));
256✔
44
                }
153✔
45
                fmt::print(stderr, "{}:{}: {}: {}\n", loc.line + 1, loc.col + 1, level,
222✔
46
                           msg);
153✔
47

153✔
48
                auto stack = this;
205✔
49
                while (stack) {
103✔
50
                        stack->parse_succeeded = false;
205✔
51
                        stack = stack->prev;
205✔
52
                }
154✔
53

153✔
54
                return false;
205✔
55
        }
154✔
56

57
        bool base_ctx::error_handler::handle_error(c4::yml::Location const& loc,
51✔
58
                                                   std::string_view msg) {
1✔
59
                return handle_msg(loc, msg, "error"sv);
205✔
60
        }
154✔
61

62
        ref_ctx base_ctx::from(ryml::ConstNodeRef const& ref) const {
10,741✔
63
                return {
32,221✔
64
                    {.parser = parser},
42,960✔
65
                    &ref,
32,220✔
66
                };
42,960✔
67
        }
32,221✔
68

69
        bool ref_ctx::error(std::string_view const& msg) const {
52✔
70
                if (parser && parser->source().len && ref_ && head) {
52✔
71
                        return head->handle_error(ref_->location(*parser), msg);
205✔
72
                }
153✔
73
                fmt::print(stderr, "error: {}\n", msg);
NEW
74
                return false;
×
75
        }
154✔
76

77
        void ref_ctx::warn(std::string_view const& msg) const {
78
                if (parser && ref_ && head) {
UNCOV
79
                        head->handle_msg(ref_->location(*parser), msg, "warning"sv);
×
UNCOV
80
                        return;
×
81
                }
82
                fmt::print(stderr, "warning: {}\n", msg);
83
        }
84
}  // namespace yaml
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