-
Notifications
You must be signed in to change notification settings - Fork 49
/
EventPropertiesStorageTests.cpp
78 lines (69 loc) · 3.06 KB
/
EventPropertiesStorageTests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
#include "system/EventPropertiesStorage.hpp"
#include "common/Common.hpp"
using namespace testing;
using namespace MAT;
TEST(EventPropertiesStorageTests, DefaultConstructor)
{
EventPropertiesStorage storage;
EXPECT_THAT(storage.eventName, Eq(""));
EXPECT_THAT(storage.eventType, Eq(""));
EXPECT_THAT(storage.eventLatency, EventLatency_Normal);
EXPECT_THAT(storage.eventPersistence, EventPersistence_Normal);
EXPECT_THAT(storage.eventPopSample, 100);
EXPECT_THAT(storage.eventPolicyBitflags, 0);
EXPECT_THAT(storage.timestampInMillis, 0);
}
static EventPropertiesStorage ConstructNonDefaultStorage() noexcept
{
EventPropertiesStorage storage;
storage.eventName = "Fred";
storage.eventType = "Rogers";
storage.eventLatency = EventLatency::EventLatency_CostDeferred;
storage.eventPersistence = EventPersistence::EventPersistence_Critical;
storage.eventPopSample = 3.14;
storage.eventPolicyBitflags = 42;
storage.timestampInMillis = 123;
return storage;
}
TEST(EventPropertiesStorageTests, CopyConstructor)
{
EventPropertiesStorage storage = ConstructNonDefaultStorage();
EventPropertiesStorage storageCopy{ storage };
EXPECT_THAT(storageCopy.eventName, storage.eventName);
EXPECT_THAT(storageCopy.eventType, storage.eventType);
EXPECT_THAT(storageCopy.eventLatency, storage.eventLatency);
EXPECT_THAT(storageCopy.eventPersistence, storage.eventPersistence);
EXPECT_THAT(storageCopy.eventPopSample, storage.eventPopSample);
EXPECT_THAT(storageCopy.eventPolicyBitflags, storage.eventPolicyBitflags);
EXPECT_THAT(storageCopy.timestampInMillis, storage.timestampInMillis);
}
TEST(EventPropertiesStorageTests, MoveConstructor)
{
EventPropertiesStorage storage = ConstructNonDefaultStorage();
EventPropertiesStorage storageCopy{ std::move(storage) };
EXPECT_THAT(storageCopy.eventName, "Fred");
EXPECT_THAT(storageCopy.eventType, "Rogers");
EXPECT_THAT(storageCopy.eventLatency, EventLatency::EventLatency_CostDeferred);
EXPECT_THAT(storageCopy.eventPersistence, EventPersistence::EventPersistence_Critical);
EXPECT_THAT(storageCopy.eventPopSample, 3.14);
EXPECT_THAT(storageCopy.eventPolicyBitflags, 42);
EXPECT_THAT(storageCopy.timestampInMillis, 123);
}
TEST(EventPropertiesStorageTests, AssignmentOperator)
{
EventPropertiesStorage storage = ConstructNonDefaultStorage();
EventPropertiesStorage secondStorage;
secondStorage.eventName = "Mister";
secondStorage = storage;
EXPECT_THAT(secondStorage.eventName, storage.eventName);
EXPECT_THAT(secondStorage.eventType, storage.eventType);
EXPECT_THAT(secondStorage.eventLatency, storage.eventLatency);
EXPECT_THAT(secondStorage.eventPersistence, storage.eventPersistence);
EXPECT_THAT(secondStorage.eventPopSample, storage.eventPopSample);
EXPECT_THAT(secondStorage.eventPolicyBitflags, storage.eventPolicyBitflags);
EXPECT_THAT(secondStorage.timestampInMillis, storage.timestampInMillis);
}