blob: 7c59664f63fa6f0c017cf1b3c2ff21bae6f03a26 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "garnet/public/lib/fidl/cpp/object_coding.h"
#include <fidl/test/misc/cpp/fidl.h>
#include <utility>
#include "gtest/gtest.h"
namespace fidl {
namespace {
TEST(EncodeObject, Struct) {
fidl::test::misc::Int64Struct s;
s.x = 123;
std::vector<uint8_t> data;
const char* err_msg;
EXPECT_EQ(ZX_OK, EncodeObject(&s, &data, &err_msg)) << err_msg;
fidl::test::misc::Int64Struct t;
EXPECT_EQ(ZX_OK, DecodeObject(data.data(), data.size(), &t, &err_msg))
<< err_msg;
EXPECT_EQ(s.x, 123);
EXPECT_EQ(t.x, 123);
}
} // namespace
} // namespace fidl