mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-02 16:16:19 +08:00
@@ -5,6 +5,7 @@
|
||||
#include <optional>
|
||||
#include <type_traits>
|
||||
|
||||
#include "../Generic.hpp"
|
||||
#include "../Rename.hpp"
|
||||
#include "../internal/StringLiteral.hpp"
|
||||
#include "../internal/is_rename.hpp"
|
||||
@@ -37,7 +38,8 @@ constexpr bool is_never_required_v = is_never_required<T>::value;
|
||||
template <class T, bool _ignore_empty_containers>
|
||||
consteval bool is_required() {
|
||||
using Type = std::remove_cvref_t<std::remove_pointer_t<T>>;
|
||||
if constexpr (internal::has_reflection_type_v<Type>) {
|
||||
if constexpr (internal::has_reflection_type_v<Type> &&
|
||||
!std::is_same_v<Type, rfl::Generic>) {
|
||||
return is_required<typename Type::ReflectionType,
|
||||
_ignore_empty_containers>();
|
||||
} else if constexpr (internal::is_rename_v<Type>) {
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ SOFTWARE.
|
||||
|
||||
namespace rfl {
|
||||
|
||||
Generic::Generic() : value_(false) {}
|
||||
Generic::Generic() : value_(std::nullopt) {}
|
||||
|
||||
Generic::Generic(Generic&& _other) noexcept = default;
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
#include <rfl/json.hpp>
|
||||
#include <source_location>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "write_and_read.hpp"
|
||||
|
||||
namespace test_generic2 {
|
||||
|
||||
TEST(json, test_generic2) {
|
||||
std::string response =
|
||||
"{\"kind\":2,\"error\":\"Internal "
|
||||
"error\",\"status\":101,\"stats\":{\"cpuTime\":803,\"totalTime\":1}}";
|
||||
|
||||
struct DataHolder {
|
||||
int kind = 0;
|
||||
rfl::Generic data;
|
||||
};
|
||||
auto result = rfl::json::read<DataHolder>(response);
|
||||
|
||||
EXPECT_TRUE(!(result && true));
|
||||
}
|
||||
|
||||
} // namespace test_generic2
|
||||
Reference in New Issue
Block a user