forked from Brill-Power/thingsetplusplus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestSubsets.cpp
More file actions
49 lines (40 loc) · 1.06 KB
/
TestSubsets.cpp
File metadata and controls
49 lines (40 loc) · 1.06 KB
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
/*
* Copyright (c) 2025 Brill Power.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "gtest/gtest.h"
#include <thingset++/ThingSet.hpp>
using namespace ThingSet;
TEST(Subsets, Collection)
{
ThingSetReadOnlyProperty<float, Subset::live> f32 { 0x100, 0, "f32" };
ThingSetReadOnlyProperty<int32_t> i32 { 0x200, 0, "i32" };
ThingSetReadOnlyProperty<uint32_t, Subset::live> u32 { 0x201, 0, "u32" };
size_t count = 0;
std::array<const char *, 2> names = {
"f32",
"u32"
};
for (auto node : ThingSetRegistry::nodesInSubset(Subset::live))
{
ASSERT_EQ(names[count++], node->getName());
}
ASSERT_EQ(2, count);
}
TEST(Subsets, Multiple)
{
ThingSetReadWriteProperty<float, Subset::live | Subset::persisted> f32 { 0x100, 0, "f32" };
size_t count = 0;
for (auto node : ThingSetRegistry::nodesInSubset(Subset::live))
{
count++;
}
ASSERT_EQ(1, count);
count = 0;
for (auto node: ThingSetRegistry::nodesInSubset(Subset::persisted))
{
count++;
}
ASSERT_EQ(1, count);
}