blob: 6c8ddf391f0e6a16fa4f3af764727dd53112a23b [file] [log] [blame]
Deepak Kodihalli707a3e12017-06-14 03:56:12 -05001#include "serialization_tests.hpp"
2#include "elog_entry.hpp"
3#include "elog_serialize.hpp"
4
5namespace phosphor
6{
7namespace logging
8{
9namespace test
10{
11
12TEST_F(TestSerialization, testProperties)
13{
14 auto id = 99;
15 phosphor::logging::AssociationList assocations{};
16 std::vector<std::string> testData{"additional", "data"};
17 uint64_t timestamp{100};
18 std::string message{"test error"};
19 auto input = std::make_unique<Entry>(
20 bus,
21 std::string(OBJ_ENTRY) + '/' + std::to_string(id),
22 id,
23 timestamp,
24 Entry::Level::Informational,
25 std::move(message),
26 std::move(testData),
27 std::move(assocations),
28 manager);
29 auto path = serialize(*input, TestSerialization::dir);
30
31 auto idStr = path.filename().c_str();
32 id = std::stol(idStr);
33 auto output = std::make_unique<Entry>(
34 bus,
35 std::string(OBJ_ENTRY) + '/' + idStr,
36 id,
37 manager);
38 deserialize(path, *output);
39
40 EXPECT_EQ(input->id(), output->id());
41 EXPECT_EQ(input->severity(), output->severity());
42 EXPECT_EQ(input->timestamp(), output->timestamp());
43 EXPECT_EQ(input->message(), output->message());
44 EXPECT_EQ(input->additionalData(), output->additionalData());
45 EXPECT_EQ(input->resolved(), output->resolved());
46 EXPECT_EQ(input->associations(), output->associations());
47}
48
49} // namespace test
50} // namespace logging
51} // namespace phosphor
52
53