mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "revng/Model/Binary.h"
|
|
#include "revng/Model/Filters.h"
|
|
|
|
static bool verify(const model::TypeDefinition &ModelType,
|
|
const model::Binary &,
|
|
const bool Assert) {
|
|
return ModelType.verify(Assert);
|
|
}
|
|
|
|
static bool
|
|
verify(const model::Type &ModelType, const model::Binary &, 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 = cantFail(TupleTree<model::Binary>::fromString(Buffer));
|
|
|
|
std::string OtherBuffer;
|
|
Deserialized.serialize(OtherBuffer);
|
|
|
|
return Deserialized;
|
|
}
|
|
|
|
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"
|