Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/Progmasoft/Runner/ResultsJson.hpp
blob: f2022d96eb23e98762cef5005602dc24a1fc43db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) 2026 Progmasoft.
// SPDX-License-Identifier: MPL-2.0 WITH AdditionRef-Progmasoft-Exception-2.0
#pragma once

#include "Json.hpp"

#include <Progmasoft/Catch3/Results.hpp>

namespace Progmasoft::Catch3::Runner
{
    /// The version of the JSON shapes below. It is written into every
    /// report and protocol stream; a reader refuses a newer major version.
    inline constexpr int kResultsFormatVersion = 1;

    [[nodiscard]] JsonValue
    ToJson(const AssertionRecord &assertion);

    [[nodiscard]] AssertionRecord
    AssertionFromJson(const JsonValue &value);

    [[nodiscard]] JsonValue
    ToJson(const BenchmarkRecord &benchmark);

    [[nodiscard]] BenchmarkRecord
    BenchmarkFromJson(const JsonValue &value);

    [[nodiscard]] JsonValue
    ToJson(const SectionRecord &section);

    [[nodiscard]] SectionRecord
    SectionFromJson(const JsonValue &value);

    [[nodiscard]] JsonValue
    ToJson(const Attempt &attempt);

    [[nodiscard]] Attempt
    AttemptFromJson(const JsonValue &value);

    [[nodiscard]] JsonValue
    ToJson(const TestResult &test);

    [[nodiscard]] TestResult
    TestResultFromJson(const JsonValue &value);

    /// The whole run, with a summary: the `--json` report.
    [[nodiscard]] JsonValue
    ToJson(const RunResult &run);

    [[nodiscard]] Expected<RunResult>
    RunResultFromJson(const JsonValue &value);
} // namespace Progmasoft::Catch3::Runner