34 lines · c
1//===-- simple_packed_serialization_utils.h -------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef ORC_RT_TEST_SIMPLE_PACKED_SERIALIZATION_UTILS_H10#define ORC_RT_TEST_SIMPLE_PACKED_SERIALIZATION_UTILS_H11 12#include "simple_packed_serialization.h"13#include "gtest/gtest.h"14 15template <typename SPSTagT, typename T>16static void blobSerializationRoundTrip(const T &Value) {17 using BST = orc_rt::SPSSerializationTraits<SPSTagT, T>;18 19 size_t Size = BST::size(Value);20 auto Buffer = std::make_unique<char[]>(Size);21 orc_rt::SPSOutputBuffer OB(Buffer.get(), Size);22 23 EXPECT_TRUE(BST::serialize(OB, Value));24 25 orc_rt::SPSInputBuffer IB(Buffer.get(), Size);26 27 T DSValue;28 EXPECT_TRUE(BST::deserialize(IB, DSValue));29 30 EXPECT_EQ(Value, DSValue)31 << "Incorrect value after serialization/deserialization round-trip";32}33 34#endif // ORC_RT_TEST_SIMPLE_PACKED_SERIALIZATION_UTILS_H