Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions include/rfl/Literal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ class Literal {

Literal(const std::string& _str) : value_(find_value(_str).value()) {}

/// A single-field literal is special because it
/// can also have a default constructor.
template <ValueType num_fields = num_fields_,
typename = std::enable_if_t<num_fields <= 1>>
Literal() : value_(0) {}

~Literal() = default;
Expand Down
19 changes: 19 additions & 0 deletions tests/json/test_duration_default.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <chrono>
#include <rfl.hpp>
#include <rfl/json.hpp>

#include "rfl/DefaultIfMissing.hpp"
#include "write_and_read.hpp"

namespace test_duration_default {

struct TestStruct {
std::chrono::seconds duration;
};

TEST(json, test_duration_default) {
const auto test = TestStruct{.duration = std::chrono::seconds(10)};
write_and_read<rfl::DefaultIfMissing>(
test, R"({"duration":{"count":10,"unit":"seconds"}})");
}
Comment thread
liuzicheng1987 marked this conversation as resolved.
} // namespace test_duration_default
Loading