Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
TestAssert.cpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
16#include "TestAssert.hpp"
18
19namespace shamtest::details {
20
22 std::string acc = "\n{\n";
23
24 acc += R"( "value" : )" + std::to_string(value) + ",\n";
25 acc += R"( "name" : ")" + name + "\"";
26
27 if (!comment.empty()) {
28 acc += ",\n"
29 R"( "comment" : ")"
30 + comment + "\"";
31 }
32
33 acc += "\n}";
34 return acc;
35 }
36
37 void TestAssert::serialize(std::basic_stringstream<byte> &stream) {
38 byte bl = value;
39 shambase::stream_write(stream, bl);
40 shambase::stream_write_string(stream, name);
41 shambase::stream_write_string(stream, comment);
42 }
43
44 TestAssert TestAssert::deserialize(std::basic_stringstream<byte> &stream) {
45 byte bl;
46 std::string name;
47 std::string comment;
48 shambase::stream_read(stream, bl);
49 shambase::stream_read_string(stream, name);
50 shambase::stream_read_string(stream, comment);
51
52 return {bool(bl), name, comment};
53 }
54
55} // namespace shamtest::details
implementation details of the test library
Definition DataNode.hpp:23
std::string serialize_json()
Serialize the assertion in JSON.
std::string comment
Comment attached to the assert.
bool value
Value of the assert.
void serialize(std::basic_stringstream< byte > &stream)
Serialize the assertion in binary format.
std::string name
Name of the assert.
static TestAssert deserialize(std::basic_stringstream< byte > &reader)
DeSerialize the assertion from binary format.