mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "revng/Model/Binary.h"
|
|
|
|
static bool verify(const model::TypeDefinition &ModelType, const bool Assert) {
|
|
return ModelType.verify(Assert);
|
|
}
|
|
|
|
static bool verify(const model::QualifiedType &ModelType, const bool Assert) {
|
|
return ModelType.verify(Assert);
|
|
}
|
|
|
|
static bool verify(const model::Binary &Tree, const bool Assert) {
|
|
return Tree.verify(Assert);
|
|
}
|
|
|
|
static TupleTree<model::Binary>
|
|
serializeDeserialize(const TupleTree<model::Binary> &T) {
|
|
|
|
std::string Buffer;
|
|
T.serialize(Buffer);
|
|
|
|
auto Deserialized = TupleTree<model::Binary>::deserialize(Buffer);
|
|
|
|
std::string OtherBuffer;
|
|
Deserialized->serialize(OtherBuffer);
|
|
|
|
return std::move(Deserialized.get());
|
|
}
|
|
|
|
static bool checkSerialization(const TupleTree<model::Binary> &T) {
|
|
revng_check(T->verify(true));
|
|
auto Deserialized = serializeDeserialize(T);
|
|
revng_check(Deserialized->verify(true));
|
|
return T->TypeDefinitions() == Deserialized->TypeDefinitions();
|
|
}
|
|
|
|
#include "revng/tests/unit/ModelType.inc"
|