13#ifndef RTCTK_COMPONENTFRAMEWORK_TEST_REPOSITORYIFTESTSUITE_HPP
14#define RTCTK_COMPONENTFRAMEWORK_TEST_REPOSITORYIFTESTSUITE_HPP
19#include <gmock/gmock.h>
20#include <gtest/gtest.h>
22#include <fmt/format.h>
28#pragma GCC diagnostic push
30#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
34static std::shared_ptr<RepositoryIf> MakeRepository();
40 repo = MakeRepository();
42 for (
unsigned i = 0;
i < 10;
i++) {
43 std::string name = fmt::format(
"/test/datapoint_{:0>2}",
i);
50 if (
repo->DataPointExists(path)) {
51 repo->DeleteDataPoint(path);
58 if constexpr (std::is_same_v<T, std::byte>) {
60 }
else if constexpr (std::is_same_v<T, RtcBinary>) {
61 return {std::byte{42}, std::byte{43}};
62 }
else if constexpr (std::is_same_v<T, RtcBool>) {
64 }
else if constexpr (std::is_same_v<T, RtcString>) {
66 }
else if constexpr (std::is_same_v<T, RtcMatrixBool>) {
67 return {1, 3, {
false,
true,
false}};
68 }
else if constexpr (std::is_same_v<T, RtcVectorBool>) {
69 return {
false,
false,
false};
70 }
else if constexpr (std::is_same_v<T, RtcMatrixString>) {
71 return {1, 2, {
"foo",
"bar"}};
72 }
else if constexpr (std::is_same_v<T, RtcVectorString>) {
73 return {
"goo",
"gar"};
74 }
else if constexpr (std::is_arithmetic_v<T>) {
77 return {1, 2, {42, 44}};
86 if constexpr (std::is_same_v<T, std::byte>) {
88 }
else if constexpr (std::is_same_v<T, RtcBinary>) {
89 return {std::byte{43}, std::byte{44}, std::byte{45}};
90 }
else if constexpr (std::is_same_v<T, RtcBool>) {
92 }
else if constexpr (std::is_same_v<T, RtcString>) {
94 }
else if constexpr (std::is_same_v<T, RtcMatrixBool>) {
95 return {2, 2, {
true,
false,
true,
false}};
96 }
else if constexpr (std::is_same_v<T, RtcVectorBool>) {
97 return {
true,
true,
true,
true};
98 }
else if constexpr (std::is_same_v<T, RtcMatrixString>) {
99 return {1, 3, {
"foo",
"bar",
"baz"}};
100 }
else if constexpr (std::is_same_v<T, RtcVectorString>) {
101 return {
"goo",
"gar",
"gaz"};
102 }
else if constexpr (std::is_arithmetic_v<T>) {
105 return {1, 3, {43, 44, 45}};
111 template <
typename U>
113 if constexpr (std::is_same_v<U, std::byte>) {
114 return sizeof(value);
115 }
else if constexpr (std::is_arithmetic_v<U>) {
116 return sizeof(value);
125 std::shared_ptr<RepositoryIf>
repo;
176 auto path = this->dp_paths[0];
177 auto& repo = *this->repo;
191 repo.DeleteDataPoint(path);
200 auto path = this->dp_paths[0];
201 auto& repo = *this->repo;
219 auto path = this->dp_paths[0];
220 auto& repo = *this->repo;
222 const auto write_value = this->MakeOtherTestValue();
238 auto path = this->dp_paths[0];
250 auto path = this->dp_paths[0];
251 auto& repo = *this->repo;
256 const auto& type = repo.GetDataPointType(path);
262 auto path = this->dp_paths[0];
263 auto& repo = *this->repo;
272 auto path = this->dp_paths[0];
273 auto& repo = *this->repo;
277 auto shape = repo.GetDataPointShape(path);
279 if constexpr (std::is_same_v<TypeParam, std::byte>) {
281 }
else if constexpr (std::is_arithmetic_v<TypeParam>) {
290 }
else if constexpr (std::is_same_v<TypeParam, RtcString>) {
294 FAIL() <<
"Should never enter here. There is a bug in the test code.";
299 auto path = this->dp_paths[0];
300 auto& repo = *this->repo;
313 repo.SendRequest(req).Wait();
325 repo.SendRequest(req).Wait();
332 auto path = this->dp_paths[0];
333 auto& repo = *this->repo;
337 const auto write_value = this->MakeOtherTestValue();
346 repo.SendRequest(req).Wait();
358 repo.SendRequest(req).Wait();
365 auto& repo = *this->repo;
366 auto path_1 = this->dp_paths[0];
367 auto path_2 = this->dp_paths[1];
379 repo.SendRequest(req).Wait();
388 repo.SendRequest(req).Wait();
396 auto& repo = *this->repo;
397 auto path_1 = this->dp_paths[0];
398 auto path_2 = this->dp_paths[1];
408 repo.SendRequest(req).Wait();
423 if constexpr (std::is_same_v<T, RtcBinary>) {
424 return T(5000, std::byte{43});
425 }
else if constexpr (std::is_same_v<T, RtcString>) {
426 return std::string(5000,
'c');
427 }
else if constexpr (std::is_same_v<T, RtcMatrixString>) {
428 return T(500, 500, std::vector<std::string>(500 * 500, std::string(
"foo")));
429 }
else if constexpr (std::is_same_v<T, RtcVectorString>) {
430 return T(5000, std::string(
"foo"));
432 return {500, 500, std::vector<typename T::value_type>(500 * 500, 42)};
441 if constexpr (std::is_same_v<T, RtcBinary>) {
443 }
else if constexpr (std::is_same_v<T, RtcString>) {
445 }
else if constexpr (std::is_same_v<T, RtcMatrixString>) {
447 }
else if constexpr (std::is_same_v<T, RtcVectorString>) {
459 if constexpr (std::is_same_v<T, RtcBinary>) {
460 return T(2, std::byte{42});
461 }
else if constexpr (std::is_same_v<T, RtcString>) {
462 return std::string(2,
'b');
463 }
else if constexpr (std::is_same_v<T, RtcMatrixString>) {
464 return T(2, 2, std::vector<std::string>(2 * 2, std::string(
"goo")));
465 }
else if constexpr (std::is_same_v<T, RtcVectorString>) {
466 return T(2, std::string(
"goo"));
468 return {2, 2, std::vector<typename T::value_type>(2 * 2, 43)};
477 if constexpr (std::is_same_v<T, RtcBinary>) {
479 }
else if constexpr (std::is_same_v<T, RtcString>) {
481 }
else if constexpr (std::is_same_v<T, RtcMatrixString>) {
483 }
else if constexpr (std::is_same_v<T, RtcVectorString>) {
525 auto path = this->dp_paths[0];
526 auto& repo = *this->repo;
539 auto path = this->dp_paths[0];
540 auto& repo = *this->repo;
548 repo.SendRequest(req).Wait();
554 auto path = this->dp_paths[0];
555 auto& repo = *this->repo;
562 auto val = this->MakeLargeTestValue();
569 repo.SendRequest(req).Wait();
572 auto shape = repo.GetDataPointShape(path);
577 auto path = this->dp_paths[0];
578 auto& repo = *this->repo;
589 repo.SendRequest(req).Wait();
592 auto shape = repo.GetDataPointShape(path);
597 auto path = this->dp_paths[0];
598 auto& repo = *this->repo;
606 if constexpr (std::is_same_v<TypeParam, RtcBinary>) {
609 }
else if constexpr (std::is_same_v<TypeParam, RtcMatrixString>) {
612 }
else if constexpr (std::is_same_v<TypeParam, RtcVectorString>) {
615 }
else if constexpr (std::is_same_v<TypeParam, RtcString>) {
625 FAIL() <<
"Should never enter here. There is a bug in the test code.";
633 repo.SendRequest(req).Wait();
637 auto shape = repo.GetDataPointShape(path);
642 auto path = this->dp_paths[0];
643 auto& repo = *this->repo;
650 if constexpr (std::is_same_v<TypeParam, RtcBinary>) {
653 }
else if constexpr (std::is_same_v<TypeParam, RtcMatrixString>) {
656 }
else if constexpr (std::is_same_v<TypeParam, RtcVectorString>) {
659 }
else if constexpr (std::is_same_v<TypeParam, RtcString>) {
669 FAIL() <<
"Should never enter here. There is a bug in the test code.";
676 repo.SendRequest(req).Wait();
679 auto shape = repo.GetDataPointShape(path);
684 auto path = this->dp_paths[0];
685 auto& repo = *this->repo;
692 if constexpr (std::is_same_v<TypeParam, RtcString>) {
696 }
else if constexpr (std::is_same_v<TypeParam, RtcBinary>) {
698 create_value = {std::byte{1}, std::byte{2}, std::byte{3}, std::byte{4},
699 std::byte{5}, std::byte{6}, std::byte{7}, std::byte{8},
700 std::byte{9}, std::byte{10}, std::byte{11}, std::byte{12},
701 std::byte{13}, std::byte{14}, std::byte{15}, std::byte{16}};
702 write_value = {std::byte{12}, std::byte{13}, std::byte{14}, std::byte{15}};
703 result_value = {std::byte{12}, std::byte{13}, std::byte{14}, std::byte{15},
704 std::byte{5}, std::byte{6}, std::byte{7}, std::byte{8},
705 std::byte{9}, std::byte{10}, std::byte{11}, std::byte{12},
706 std::byte{13}, std::byte{14}, std::byte{15}, std::byte{16}};
708 }
else if constexpr (std::is_same_v<TypeParam, RtcMatrixBool>) {
711 false,
false,
false,
false,
712 false,
false,
false,
false,
713 false,
false,
false,
false}};
716 false,
false,
false,
false,
717 false,
false,
false,
false,
718 false,
false,
false,
false}};
720 }
else if constexpr (std::is_same_v<TypeParam, RtcMatrixString>) {
724 "9",
"10",
"11",
"12",
725 "13",
"14",
"15",
"16"}};
729 "9",
"10",
"11",
"12",
730 "13",
"14",
"15",
"16"}};
732 }
else if constexpr (std::is_same_v<TypeParam, RtcVectorBool>) {
734 create_value = {
false,
false,
false,
false,
false,
false,
false,
false,
735 false,
false,
false,
false,
false,
false,
false,
false};
737 result_value = {
true,
true,
true,
true,
false,
false,
false,
false,
738 false,
false,
false,
false,
false,
false,
false,
false};
740 }
else if constexpr (std::is_same_v<TypeParam, RtcVectorString>) {
743 "9",
"10",
"11",
"12",
"13",
"14",
"15",
"16"};
745 result_value = {
"12",
"13",
"14",
"15",
"5",
"6",
"7",
"8",
746 "9",
"10",
"11",
"12",
"13",
"14",
"15",
"16"};
761 create_value = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
763 result_value = {12, 13, 14, 15, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
765 FAIL() <<
"Should never enter here. There is a bug in the test code.";
772 repo.SendRequest(req).Wait();
778 auto path = this->dp_paths[0];
779 auto& repo = *this->repo;
785 if constexpr (std::is_same_v<TypeParam, RtcString>) {
789 }
else if constexpr (std::is_same_v<TypeParam, RtcBinary>) {
791 create_value = {std::byte{1}, std::byte{2}, std::byte{3}, std::byte{4},
792 std::byte{5}, std::byte{6}, std::byte{7}, std::byte{8},
793 std::byte{9}, std::byte{10}, std::byte{11}, std::byte{12},
794 std::byte{13}, std::byte{14}, std::byte{15}, std::byte{16}};
795 result_value = {std::byte{1}, std::byte{2}, std::byte{3}, std::byte{4}};
798 }
else if constexpr (std::is_same_v<TypeParam, RtcMatrixBool>) {
801 false,
false,
true,
false,
802 false,
false,
false,
true,
803 false,
false,
false,
false}};
807 }
else if constexpr (std::is_same_v<TypeParam, RtcMatrixString>) {
811 "9",
"10",
"11",
"12",
812 "13",
"14",
"15",
"16"}};
816 }
else if constexpr (std::is_same_v<TypeParam, RtcVectorBool>) {
818 create_value = {
true,
false,
true,
false,
true,
false,
true,
false,
819 true,
false,
true,
false,
true,
false,
true,
false};
823 }
else if constexpr (std::is_same_v<TypeParam, RtcVectorString>) {
825 "1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16"};
838 create_value = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
842 FAIL() <<
"Should never enter here. There is a bug in the test code.";
848 repo.SendRequest(req).Wait();
862template <
typename T,
typename A>
868template <
typename T,
typename A>
887 auto path = this->dp_paths[0];
888 auto& repo = *this->repo;
895 if constexpr (std::is_same_v<TypeParam, RtcString>) {
899 }
else if constexpr (std::is_same_v<TypeParam, RtcBinary>) {
900 create_value = {std::byte{1}, std::byte{2}, std::byte{3}, std::byte{4}};
901 write_value = {std::byte{11}, std::byte{12}, std::byte{13}, std::byte{14}};
903 }
else if constexpr (std::is_same_v<TypeParam, RtcMatrixBool>) {
907 }
else if constexpr (std::is_same_v<TypeParam, RtcMatrixString>) {
915 }
else if constexpr (std::is_same_v<TypeParam, RtcVectorBool>) {
919 }
else if constexpr (std::is_same_v<TypeParam, RtcVectorString>) {
928 FAIL() <<
"Should never enter here. There is a bug in the test code.";
936 if constexpr (std::is_same_v<TypeParam, RtcMatrixBool>) {
956 if constexpr (std::is_same_v<TypeParam, RtcString>) {
959 auto path2 = this->dp_paths[1];
976 auto path = this->dp_paths[0];
977 auto& repo = *this->repo;
980 using ArrayType = std::array<typename TypeParam::value_type, 4>;
984 if constexpr (std::is_same_v<TypeParam, RtcString>) {
987 }
else if constexpr (std::is_same_v<TypeParam, RtcBinary>) {
988 create_array = {std::byte{1}, std::byte{2}, std::byte{3}, std::byte{4}};
989 write_array = {std::byte{11}, std::byte{12}, std::byte{13}, std::byte{14}};
990 }
else if constexpr (std::is_same_v<TypeParam, RtcVectorBool>) {
993 }
else if constexpr (std::is_same_v<TypeParam, RtcVectorString>) {
1012 using Row = std::array<typename TypeParam::value_type, 2>;
1017 if constexpr (std::is_same_v<TypeParam, RtcMatrixBool>) {
1020 }
else if constexpr (std::is_same_v<TypeParam, RtcMatrixString>) {
1039 FAIL() <<
"Should never enter here. There is a bug in the test code.";
1044 using testing::ElementsAreArray;
1045 auto path = this->dp_paths[0];
1046 auto& repo = *this->repo;
1049 using ValueType =
typename TypeParam::value_type;
1053 if constexpr (std::is_same_v<TypeParam, RtcString>) {
1062 }
else if constexpr (std::is_same_v<TypeParam, RtcBinary>) {
1071 }
else if constexpr (std::is_same_v<TypeParam, RtcVectorBool>) {
1080 }
else if constexpr (std::is_same_v<TypeParam, RtcVectorString>) {
1113 using ValueType =
typename TypeParam::value_type;
1117 if constexpr (std::is_same_v<TypeParam, RtcMatrixBool>) {
1126 }
else if constexpr (std::is_same_v<TypeParam, RtcMatrixString>) {
1160 FAIL() <<
"Should never enter here. There is a bug in the test code.";
1169 repo = MakeRepository();
1170 path1 =
"/foo"_dppath;
1171 path2 =
"/bar"_dppath;
1172 link1 =
"/link1"_dppath;
1173 link2 =
"/link2"_dppath;
1191 template <
typename T = RtcInt64>
1196 repo->SendRequest(req).Wait();
1200 std::shared_ptr<RepositoryIf>
repo;
1229 auto cb = std::bind(&MockCallbacks::CreateCallback, &
callbacks, std::placeholders::_1);
1236 repo->SendRequest(req).Wait();
1245 auto cb = std::bind(&MockCallbacks::DeleteCallback, &
callbacks, std::placeholders::_1);
1252 repo->SendRequest(req).Wait();
1262 auto cb = std::bind(&MockCallbacks::ExistsCallback, &
callbacks, std::placeholders::_1);
1267 repo->SendRequest(req).Wait();
1277 auto cb = std::bind(&MockCallbacks::GetChildrenCallback, &
callbacks, std::placeholders::_1);
1282 repo->SendRequest(req).Wait();
1293 auto cb = std::bind(&MockCallbacks::WriteCallback, &
callbacks, std::placeholders::_1);
1300 repo->SendRequest(req).Wait();
1310 auto cb = std::bind(&MockCallbacks::ReadCallback, &
callbacks, std::placeholders::_1);
1317 repo->SendRequest(req).Wait();
1328 auto cb = std::bind(&MockCallbacks::PartialWriteCallback, &
callbacks, std::placeholders::_1);
1334 req.PartialWriteDataPoint(path2,
buffer2, 0, 2, 0, std::nullopt,
cb);
1335 repo->SendRequest(req).Wait();
1346 auto cb = std::bind(&MockCallbacks::PartialReadCallback, &
callbacks, std::placeholders::_1);
1352 req.PartialReadDataPoint(path2,
buffer2, 0, 2, 0, std::nullopt,
cb);
1353 repo->SendRequest(req).Wait();
1359 metadata1[
"comment"] = std::string{
"foo"};
1360 metadata2[
"comment"] = std::string{
"bar"};
1365 auto cb = std::bind(&MockCallbacks::WriteMetaDataCallback, &
callbacks, std::placeholders::_1);
1372 repo->SendRequest(req).Wait();
1382 auto cb = std::bind(&MockCallbacks::ReadMetaDataCallback, &
callbacks, std::placeholders::_1);
1389 repo->SendRequest(req).Wait();
1398 auto cb = std::bind(&MockCallbacks::CreateSymlinkCallback, &
callbacks, std::placeholders::_1);
1405 repo->SendRequest(req).Wait();
1414 auto cb = std::bind(&MockCallbacks::UpdateSymlinkCallback, &
callbacks, std::placeholders::_1);
1424 repo->SendRequest(req).Wait();
1434 testing::InSequence
seq;
1438 auto cb2 = std::bind(&MockCallbacks::CreateCallback, &
callbacks, std::placeholders::_1);
1445 repo->SendRequest(
req2).Wait();
1451 repo->SendRequest(
req1).Wait();
1461 testing::InSequence
seq;
1465 auto cb2 = std::bind(&MockCallbacks::DeleteCallback, &
callbacks, std::placeholders::_1);
1471 repo->SendRequest(
req2).Wait();
1478 repo->SendRequest(
req1).Wait();
1489 testing::InSequence
seq;
1493 auto cb2 = std::bind(&MockCallbacks::ExistsCallback, &
callbacks, std::placeholders::_1);
1499 repo->SendRequest(
req2).Wait();
1506 repo->SendRequest(
req1).Wait();
1518 testing::InSequence
seq;
1522 auto cb2 = std::bind(&MockCallbacks::GetChildrenCallback, &
callbacks, std::placeholders::_1);
1528 repo->SendRequest(
req2).Wait();
1535 repo->SendRequest(
req1).Wait();
1547 testing::InSequence
seq;
1551 auto cb2 = std::bind(&MockCallbacks::WriteCallback, &
callbacks, std::placeholders::_1);
1557 repo->SendRequest(
req2).Wait();
1564 repo->SendRequest(
req1).Wait();
1575 testing::InSequence
seq;
1579 auto cb2 = std::bind(&MockCallbacks::ReadCallback, &
callbacks, std::placeholders::_1);
1585 repo->SendRequest(
req2).Wait();
1592 repo->SendRequest(
req1).Wait();
1604 testing::InSequence
seq;
1608 auto cb2 = std::bind(&MockCallbacks::WriteCallback, &
callbacks, std::placeholders::_1);
1614 repo->SendRequest(
req2).Wait();
1621 repo->SendRequest(
req1).Wait();
1633 testing::InSequence
seq;
1637 auto cb2 = std::bind(&MockCallbacks::ReadCallback, &
callbacks, std::placeholders::_1);
1643 repo->SendRequest(
req2).Wait();
1650 repo->SendRequest(
req1).Wait();
1658 metadata1[
"comment"] = std::string{
"foo"};
1659 metadata2[
"comment"] = std::string{
"bar"};
1663 testing::InSequence
seq;
1667 auto cb2 = std::bind(&MockCallbacks::WriteCallback, &
callbacks, std::placeholders::_1);
1673 repo->SendRequest(
req2).Wait();
1680 repo->SendRequest(
req1).Wait();
1691 testing::InSequence
seq;
1695 auto cb2 = std::bind(&MockCallbacks::ReadCallback, &
callbacks, std::placeholders::_1);
1701 repo->SendRequest(
req2).Wait();
1708 repo->SendRequest(
req1).Wait();
1718 testing::InSequence
seq;
1722 auto cb2 = std::bind(&MockCallbacks::CreateSymlinkCallback, &
callbacks, std::placeholders::_1);
1728 repo->SendRequest(
req2).Wait();
1735 repo->SendRequest(
req1).Wait();
1746 testing::InSequence
seq;
1750 auto cb2 = std::bind(&MockCallbacks::UpdateSymlinkCallback, &
callbacks, std::placeholders::_1);
1756 repo->SendRequest(
req2).Wait();
1762 req0.CreateSymlink(path2,
"/link2"_dppath);
1763 repo->SendRequest(
req0).Wait();
1768 repo->SendRequest(
req1).Wait();
1776 repo = MakeRepository();
1777 repo->CreateDataPoint(
"/topdir/datapoint1"_dppath, 0);
1778 repo->CreateDataPoint(
"/topdir/subdir1/datapoint2"_dppath, 0);
1779 repo->CreateDataPoint(
"/topdir/subdir1/datapoint3"_dppath, 0);
1780 repo->CreateDataPoint(
"/topdir/subdir2/datapoint4"_dppath, 0);
1781 repo->CreateDataPoint(
"/topdir/subdir21/datapoint5"_dppath, 0);
1785 if (
repo->DataPointExists(
"/topdir/datapoint1"_dppath)) {
1786 repo->DeleteDataPoint(
"/topdir/datapoint1"_dppath);
1788 if (
repo->DataPointExists(
"/topdir/subdir1/datapoint2"_dppath)) {
1789 repo->DeleteDataPoint(
"/topdir/subdir1/datapoint2"_dppath);
1791 if (
repo->DataPointExists(
"/topdir/subdir1/datapoint2"_dppath)) {
1792 repo->DeleteDataPoint(
"/topdir/subdir1/datapoint2"_dppath);
1794 if (
repo->DataPointExists(
"/topdir/subdir1/datapoint3"_dppath)) {
1795 repo->DeleteDataPoint(
"/topdir/subdir1/datapoint3"_dppath);
1797 if (
repo->DataPointExists(
"/topdir/subdir2/datapoint4"_dppath)) {
1798 repo->DeleteDataPoint(
"/topdir/subdir2/datapoint4"_dppath);
1800 if (
repo->DataPointExists(
"/topdir/subdir21/datapoint5"_dppath)) {
1801 repo->DeleteDataPoint(
"/topdir/subdir21/datapoint5"_dppath);
1806 std::shared_ptr<RepositoryIf>
repo;
1810 auto [
dps,
paths] = repo->GetChildren(
"/"_dppath);
1817 auto [
dps,
paths] = repo->GetChildren(
"/topdir"_dppath);
1828 auto [
dps,
paths] = repo->GetChildren(
"/topdir/subdir1"_dppath);
1831 std::sort(
dps.begin(),
dps.end());
1832 EXPECT_EQ(
dps[0],
"/topdir/subdir1/datapoint2"_dppath);
1833 EXPECT_EQ(
dps[1],
"/topdir/subdir1/datapoint3"_dppath);
1837 auto [
dps,
paths] = repo->GetChildren(
"/topdir/subdir2"_dppath);
1840 std::sort(
dps.begin(),
dps.end());
1841 EXPECT_EQ(
dps[0],
"/topdir/subdir2/datapoint4"_dppath);
1845 auto [
dps,
paths] = repo->GetChildren(
"/topdir/datapoint1"_dppath);
1851 auto [
dps,
paths] = repo->GetChildren(
"/does/not/exist"_dppath);
1857 auto [
dps,
paths] = repo->GetChildren(
"/"_dppath,
true);
1859 std::sort(
dps.begin(),
dps.end());
1862 EXPECT_EQ(
dps[1],
"/topdir/subdir1/datapoint2"_dppath);
1863 EXPECT_EQ(
dps[2],
"/topdir/subdir1/datapoint3"_dppath);
1864 EXPECT_EQ(
dps[3],
"/topdir/subdir2/datapoint4"_dppath);
1865 EXPECT_EQ(
dps[4],
"/topdir/subdir21/datapoint5"_dppath);
1876 repo->DeleteDataPoint(
"/"_dppath,
true);
1878 auto [
dps,
paths] = repo->GetChildren(
"/"_dppath,
true);
1884 repo->DeleteDataPoint(
"/topdir"_dppath,
true);
1886 auto [
dps,
paths] = repo->GetChildren(
"/"_dppath,
true);
1892 repo->DeleteDataPoint(
"/topdir/subdir2"_dppath,
true);
1894 auto [
dps,
paths] = repo->GetChildren(
"/"_dppath,
true);
1896 std::sort(
dps.begin(),
dps.end());
1899 EXPECT_EQ(
dps[1],
"/topdir/subdir1/datapoint2"_dppath);
1900 EXPECT_EQ(
dps[2],
"/topdir/subdir1/datapoint3"_dppath);
1901 EXPECT_EQ(
dps[3],
"/topdir/subdir21/datapoint5"_dppath);
1915 repo = MakeRepository();
1916 path =
"/foo"_dppath;
1926 std::shared_ptr<RepositoryIf>
repo;
1936 md[
"comment"] = std::string{
"some comment"};
1937 md[
"units"] = std::string{
"bar"};
1943 repo->SendRequest(req).Wait();
1964 md[
"comment"] = std::string{
"some comment"};
1965 md[
"units"] = std::string{
"bar"};
1972 repo->SendRequest(req).Wait();
1990 md[
"comment"] = std::string{
"some comment"};
1991 md[
"units"] = std::string{
"bar"};
1997 repo->SendRequest(req).Wait();
2016 md[
"comment"] = std::string{
"some comment"};
2017 md[
"units"] = std::string{
"bar"};
2024 repo->SendRequest(req).Wait();
2042 repo->SendRequest(req).Wait();
2056 repo->SendRequest(req).Wait();
2071 repo->SendRequest(req).Wait();
2084 repo->SendRequest(req).Wait();
2105 repo->SendRequest(req).Wait();
2115 repo->SendRequest(req).Wait();
2135 repo->SendRequest(req).Wait();
2153 metadata[
"min"] =
static_cast<int>(-3);
2154 metadata[
"max"] =
static_cast<int>(3);
2155 metadata[
"text"] = std::string{
"This is a custom text description."};
2160 repo->SendRequest(req).Wait();
2170 metadata[
"min"] =
static_cast<int>(-5);
2171 metadata[
"max"] =
static_cast<int>(5);
2172 metadata[
"text"] = std::string{
"This is another description."};
2177 repo->SendRequest(req).Wait();
2188 metadata[
"min"] =
static_cast<int>(-7);
2189 metadata[
"max"] =
static_cast<int>(7);
2190 metadata[
"text"] = std::string{
"This is a description."};
2195 repo->SendRequest(req).Wait();
2207 metadata[
"min"] =
static_cast<int>(-9);
2208 metadata[
"max"] =
static_cast<int>(9);
2209 metadata[
"text"] = std::string{
"A description.\nBut on two lines."};
2214 repo->SendRequest(req).Wait();
2228 repo = MakeRepository();
2229 path =
"/foo"_dppath;
2236 if (
repo->DataPointExists(
"/links/foo"_dppath)) {
2237 repo->DeleteDataPoint(
"/links/foo"_dppath);
2239 if (
repo->DataPointExists(
"/links/bar"_dppath)) {
2240 repo->DeleteDataPoint(
"/links/bar"_dppath);
2245 std::shared_ptr<RepositoryIf>
repo;
2273 repo->SendRequest(req).Wait();
2292 std::set<DataPointPath>
links_2;
2307 repo->SendRequest(req).Wait();
2315 std::set<DataPointPath>({
"/links/foo"_dppath,
"/links/bar"_dppath}));
2336 repo->SendRequest(req).Wait();
2354 repo->SendRequest(req).Wait();
2369 repo = MakeRepository();
2370 path =
"/foo"_dppath;
2388 std::shared_ptr<RepositoryIf>
repo;
2537 metadata[
"min"] = std::make_any<UnsupportedMetaDataType>(
new_value);
2541 repo->SendRequest(req).Wait();
2549 repo->CreateDataPoint(path, 12);
2557 metadata[
"min"] = std::make_any<UnsupportedMetaDataType>(
new_value);
2560 repo->SendRequest(req).Wait();
2585 repo->CreateDataPoint(path, 42);
2590 repo->SendRequest(req).Wait();
2600 repo->CreateDataPoint(path, 42);
2609 repo->CreateDataPoint(path, 42);
2614 repo->SendRequest(req).Wait();
2626 repo->CreateDataPoint(path, 42);
2632 repo->SendRequest(req).Wait();
2649 repo->SendRequest(req).Wait();
2668 repo->SendRequest(req).Wait();
2688 repo->SendRequest(req).Wait();
2689 FAIL() <<
"Call did not throw";
2691 auto info =
ex.GetInfo();
2712 FAIL() <<
"Incorrect exception type";
2721 repo = MakeRepository();
2722 for (
unsigned i = 0;
i < 500;
i++) {
2723 std::string name = fmt::format(
"/test/datapoint_{:0>2}",
i);
2729 for (
const auto& path :
dp_paths) {
2730 if (
repo->DataPointExists(path)) {
2731 repo->DeleteDataPoint(path);
2737 std::shared_ptr<RepositoryIf>
repo;
2744 std::vector<std::future<void>>
futures;
2746 for (
unsigned i = 0;
i < dp_paths.size();
i++) {
2747 futures.push_back(std::async(std::launch::async, [
this,
idx =
i] {
2748 repo->CreateDataPoint(dp_paths[
idx],
idx);
2759 std::vector<std::future<bool>>
futures;
2761 for (
unsigned i = 0;
i < dp_paths.size();
i++) {
2762 futures.push_back(std::async(std::launch::async, [
this,
idx =
i] {
2763 return repo->DataPointExists(dp_paths[
idx]);
2768 bool result =
false;
2776 std::vector<std::future<void>>
futures;
2778 for (
unsigned i = 0;
i < dp_paths.size();
i++) {
2779 futures.push_back(std::async(std::launch::async, [
this,
idx =
i] {
2780 repo->SetDataPoint<
unsigned>(dp_paths[
idx],
idx + 1);
2791 std::vector<std::future<unsigned>>
futures;
2793 for (
unsigned i = 0;
i < dp_paths.size();
i++) {
2794 futures.push_back(std::async(std::launch::async, [
this,
idx =
i] {
2795 return repo->GetDataPoint<
unsigned>(dp_paths[
idx]);
2799 for (
unsigned i = 0;
i < dp_paths.size();
i++) {
2800 unsigned result = 0;
2808 std::vector<std::future<void>>
futures;
2810 for (
unsigned i = 0;
i < dp_paths.size();
i++) {
2812 std::launch::async, [
this,
idx =
i] { repo->DeleteDataPoint(dp_paths[
idx]); }));
2822 std::vector<std::future<bool>>
futures;
2824 for (
unsigned i = 0;
i < dp_paths.size();
i++) {
2825 futures.push_back(std::async(std::launch::async, [
this,
idx =
i] {
2826 return repo->DataPointExists(dp_paths[
idx]);
2839 auto path = dp_paths[0];
2844 std::vector<std::future<unsigned>>
futures;
2846 for (
unsigned i = 0;
i < 500;
i++) {
2848 std::async(std::launch::async, [&] {
return repo->GetDataPoint<
unsigned>(path); }));
2860 auto path = dp_paths[0];
2865 std::vector<std::future<void>>
futures;
2867 for (
unsigned i = 0;
i < 500;
i++) {
2869 std::async(std::launch::async, [&] { repo->SetDataPoint<
unsigned>(path, 43); }));
2881 repo->SendRequest(req).Wait();
2888 auto path = dp_paths[0];
2893 std::vector<std::future<void>>
futures;
2895 for (
unsigned i = 0;
i < 50;
i++) {
2896 futures.push_back(std::async(std::launch::async, [&] {
2899 for (
unsigned j = 0;
j < 10;
j++) {
2902 repo->SendRequest(req).Wait();
2915 repo->SendRequest(req).Wait();
2922 auto path = dp_paths[0];
2927 std::vector<std::future<unsigned>>
futures;
2929 for (
unsigned i = 0;
i < 50;
i++) {
2930 futures.push_back(std::async(std::launch::async, [&] {
2943 repo->SendRequest(req).Wait();
2949 unsigned result = 0;
2958#pragma GCC diagnostic pop
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:74
A buffer class representing 2D matrix data.
Definition matrixBuffer.hpp:28
A span referencing a 2D matrix buffer.
Definition matrixSpan.hpp:35
Definition repositoryIf.hpp:144
An object representing one or more asynchronous I/O requests to a repository.
Definition repositoryIf.hpp:683
void DataPointExists(const DataPointPath &path, bool &result, const CallbackType &callback=nullptr) const
Definition repositoryIf.cpp:300
void DeleteDataPoint(const DataPointPath &path, const CallbackType &callback=nullptr)
Definition repositoryIf.cpp:295
void ReadDataPoint(const DataPointPath &path, T &buffer, std::optional< std::reference_wrapper< MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr) const
Definition repositoryIf.ipp:1395
void GetChildren(const DataPointPath &path, std::pair< PathList, PathList > &result, bool recurse=false, const CallbackType &callback=nullptr) const
Add request to query the child datapoints and paths for a given parent path.
void PartialWriteDataPoint(const DataPointPath &path, const T &buffer, size_t first, size_t last, size_t d_first, std::optional< std::reference_wrapper< const MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr)
Definition repositoryIf.ipp:1597
void PartialReadDataPoint(const DataPointPath &path, T &buffer, size_t first, size_t last, size_t d_first, std::optional< std::reference_wrapper< MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr) const
Add request to partially read a datapoint.
Definition repositoryIf.ipp:1526
void ReadMetaData(const DataPointPath &path, MetaData &metadata, const CallbackType &callback=nullptr) const
Definition repositoryIf.cpp:314
void CreateSymlink(const DataPointPath &dp, const DataPointPath &link, const CallbackType &callback=nullptr)
Definition repositoryIf.cpp:326
void CreateDataPoint(const DataPointPath &path, const T &initial_value, std::optional< std::reference_wrapper< const MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr)
Add a request to create a new datapoint.
Definition repositoryIf.ipp:1338
void WriteDataPoint(const DataPointPath &path, const T &buffer, std::optional< std::reference_wrapper< const MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr)
Definition repositoryIf.ipp:1471
void UpdateSymlink(const DataPointPath &dp, const DataPointPath &link, const CallbackType &callback=nullptr)
Definition repositoryIf.cpp:332
void WriteMetaData(const DataPointPath &path, const MetaData &metadata, const CallbackType &callback=nullptr)
Definition repositoryIf.cpp:320
Definition repositoryIf.hpp:139
Definition repositoryIf.hpp:135
Definition repositoryIf.hpp:131
Definition repositoryIf.hpp:127
Definition repositoryIf.hpp:152
Definition repositoryIf.hpp:148
Abstract interface providing basic read and write facilities to a repository.
Definition repositoryIf.hpp:104
Clock::time_point Timestamp
Definition repositoryIf.hpp:111
T GetDataPoint(const DataPointPath &path) const
Fetches a datapoint from the repository.
Definition repositoryIf.ipp:1711
void CreateDataPoint(const DataPointPath &path)
Creates a new datapoint in the repository.
Definition repositoryIf.ipp:1696
void SetDataPoint(const DataPointPath &path, const T &value)
Sets a datapoint in the repository.
Definition repositoryIf.ipp:1720
std::vector< DataPointPath > PathList
Definition repositoryIf.hpp:109
The RtctkException class is the base class for all Rtctk exceptions.
Definition exceptions.hpp:211
Definition repositoryIfTestSuite.hpp:420
T MakeLargeTestValue()
Definition repositoryIfTestSuite.hpp:422
T MakeSmallTestValue()
Definition repositoryIfTestSuite.hpp:458
RtcVectorUInt64 ExpectedSmallTestValueShape()
Definition repositoryIfTestSuite.hpp:476
RtcVectorUInt64 ExpectedLargeTestValueShape()
Definition repositoryIfTestSuite.hpp:440
Definition repositoryIfTestSuite.hpp:1166
void TearDown() override
Definition repositoryIfTestSuite.hpp:1176
DataPointPath link1
Definition repositoryIfTestSuite.hpp:1203
DataPointPath path1
Definition repositoryIfTestSuite.hpp:1201
DataPointPath link2
Definition repositoryIfTestSuite.hpp:1204
void SetupDataPoints(const T &initial_value=0)
Definition repositoryIfTestSuite.hpp:1192
DataPointPath path2
Definition repositoryIfTestSuite.hpp:1202
std::shared_ptr< RepositoryIf > repo
Definition repositoryIfTestSuite.hpp:1200
void SetUp() override
Definition repositoryIfTestSuite.hpp:1168
Definition repositoryIfTestSuite.hpp:2366
std::shared_ptr< RepositoryIf > repo
Definition repositoryIfTestSuite.hpp:2388
void TearDown() override
Definition repositoryIfTestSuite.hpp:2375
DataPointPath link_path
Definition repositoryIfTestSuite.hpp:2390
void SetUp() override
Definition repositoryIfTestSuite.hpp:2368
DataPointPath link_path2
Definition repositoryIfTestSuite.hpp:2391
DataPointPath path
Definition repositoryIfTestSuite.hpp:2389
Definition repositoryIfTestSuite.hpp:1773
void TearDown() override
Definition repositoryIfTestSuite.hpp:1784
std::shared_ptr< RepositoryIf > repo
Definition repositoryIfTestSuite.hpp:1806
void SetUp() override
Definition repositoryIfTestSuite.hpp:1775
Definition repositoryIfTestSuite.hpp:2718
void TearDown() override
Definition repositoryIfTestSuite.hpp:2728
std::shared_ptr< RepositoryIf > repo
Definition repositoryIfTestSuite.hpp:2737
std::vector< DataPointPath > dp_paths
Definition repositoryIfTestSuite.hpp:2738
void SetUp() override
Definition repositoryIfTestSuite.hpp:2720
Definition repositoryIfTestSuite.hpp:1207
MOCK_METHOD(void, ReadMetaDataCallback,(const DataPointPath &path))
MOCK_METHOD(void, PartialReadCallback,(const DataPointPath &path))
MOCK_METHOD(void, DeleteCallback,(const DataPointPath &path))
MOCK_METHOD(void, ExistsCallback,(const DataPointPath &path))
MOCK_METHOD(void, CreateSymlinkCallback,(const DataPointPath &path))
MOCK_METHOD(void, CreateCallback,(const DataPointPath &path))
MOCK_METHOD(void, GetChildrenCallback,(const DataPointPath &path))
MOCK_METHOD(void, ReadCallback,(const DataPointPath &path))
MOCK_METHOD(void, WriteCallback,(const DataPointPath &path))
MOCK_METHOD(void, UpdateSymlinkCallback,(const DataPointPath &path))
MOCK_METHOD(void, PartialWriteCallback,(const DataPointPath &path))
MOCK_METHOD(void, WriteMetaDataCallback,(const DataPointPath &path))
Definition repositoryIfTestSuite.hpp:37
std::vector< DataPointPath > dp_paths
Definition repositoryIfTestSuite.hpp:124
T MakeSomeTestValue()
Definition repositoryIfTestSuite.hpp:57
void SetUp() override
Definition repositoryIfTestSuite.hpp:39
std::shared_ptr< RepositoryIf > repo
Definition repositoryIfTestSuite.hpp:125
size_t GetExpectedSize(const U &value)
Definition repositoryIfTestSuite.hpp:112
void TearDown() override
Definition repositoryIfTestSuite.hpp:48
T MakeOtherTestValue()
Definition repositoryIfTestSuite.hpp:83
Definition repositoryIfTestSuite.hpp:2225
void SetUp() override
Definition repositoryIfTestSuite.hpp:2227
void TearDown() override
Definition repositoryIfTestSuite.hpp:2232
std::shared_ptr< RepositoryIf > repo
Definition repositoryIfTestSuite.hpp:2245
DataPointPath path
Definition repositoryIfTestSuite.hpp:2246
Definition fakeClock.cpp:15
TYPED_TEST_SUITE(BasicOperation, TypeSetForBasicOperation)
::testing::Types< RtcBool, RtcInt8, RtcInt16, RtcInt32, RtcInt64, RtcUInt8, RtcUInt16, RtcUInt32, RtcUInt64, RtcFloat, RtcDouble, RtcString, RtcBinary, RtcVectorBool, RtcVectorInt8, RtcVectorInt16, RtcVectorInt32, RtcVectorInt64, RtcVectorUInt8, RtcVectorUInt16, RtcVectorUInt32, RtcVectorUInt64, RtcVectorFloat, RtcVectorDouble, RtcVectorString, RtcMatrixBool, RtcMatrixInt8, RtcMatrixInt16, RtcMatrixInt32, RtcMatrixInt64, RtcMatrixUInt8, RtcMatrixUInt16, RtcMatrixUInt32, RtcMatrixUInt64, RtcMatrixFloat, RtcMatrixDouble, RtcMatrixString > TypeSetForBasicOperation
Definition repositoryIfTestSuite.hpp:134
TYPED_TEST(BasicOperation, DataPointCreationAndDeletion)
Definition repositoryIfTestSuite.hpp:175
::testing::Types< RtcString, RtcBinary, RtcVectorBool, RtcVectorInt8, RtcVectorInt16, RtcVectorInt32, RtcVectorInt64, RtcVectorUInt8, RtcVectorUInt16, RtcVectorUInt32, RtcVectorUInt64, RtcVectorFloat, RtcVectorDouble, RtcVectorString, RtcMatrixBool, RtcMatrixInt8, RtcMatrixInt16, RtcMatrixInt32, RtcMatrixInt64, RtcMatrixUInt8, RtcMatrixUInt16, RtcMatrixUInt32, RtcMatrixUInt64, RtcMatrixFloat, RtcMatrixDouble, RtcMatrixString > TypeSetAdvancedOperation
Definition repositoryIfTestSuite.hpp:495
TEST_F(Callbacks, CreateDataPointCallback)
Definition repositoryIfTestSuite.hpp:1223
RepositoryIf::PathList PathList
Definition oldbAdapterLegacy.cpp:322
elt::mal::future< std::string > InjectReqRepEvent(StateMachineEngine &engine)
Definition malEventInjector.hpp:23
uint64_t RtcUInt64
Definition repositoryIf.hpp:61
RtcMatrix< RtcInt8 > RtcMatrixInt8
Definition repositoryIf.hpp:79
uint8_t RtcUInt8
Definition repositoryIf.hpp:58
int64_t RtcInt64
Definition repositoryIf.hpp:57
float RtcFloat
Definition repositoryIf.hpp:62
RtcMatrix< RtcInt32 > RtcMatrixInt32
Definition repositoryIf.hpp:81
RtcMatrix< RtcInt64 > RtcMatrixInt64
Definition repositoryIf.hpp:82
RtcMatrix< RtcUInt64 > RtcMatrixUInt64
Definition repositoryIf.hpp:86
RtcVector< RtcUInt32 > RtcVectorUInt32
Definition repositoryIf.hpp:73
RtcMatrix< RtcUInt8 > RtcMatrixUInt8
Definition repositoryIf.hpp:83
RtcMatrix< RtcFloat > RtcMatrixFloat
Definition repositoryIf.hpp:87
RtcVector< RtcDouble > RtcVectorDouble
Definition repositoryIf.hpp:76
std::string RtcString
Definition repositoryIf.hpp:64
RtcMatrix< RtcInt16 > RtcMatrixInt16
Definition repositoryIf.hpp:80
int8_t RtcInt8
Definition repositoryIf.hpp:54
uint32_t RtcUInt32
Definition repositoryIf.hpp:60
RtcMatrix< RtcDouble > RtcMatrixDouble
Definition repositoryIf.hpp:88
bool RtcBool
Definition repositoryIf.hpp:53
int16_t RtcInt16
Definition repositoryIf.hpp:55
RtcVector< RtcUInt16 > RtcVectorUInt16
Definition repositoryIf.hpp:72
RtcVector< RtcInt16 > RtcVectorInt16
Definition repositoryIf.hpp:68
RtcMatrix< RtcBool > RtcMatrixBool
Definition repositoryIf.hpp:78
RtcVector< RtcFloat > RtcVectorFloat
Definition repositoryIf.hpp:75
RtcVector< RtcInt8 > RtcVectorInt8
Definition repositoryIf.hpp:67
uint16_t RtcUInt16
Definition repositoryIf.hpp:59
RtcVector< RtcBool > RtcVectorBool
Definition repositoryIf.hpp:66
int32_t RtcInt32
Definition repositoryIf.hpp:56
RtcVector< RtcUInt64 > RtcVectorUInt64
Definition repositoryIf.hpp:74
RtcVector< RtcString > RtcVectorString
Definition repositoryIf.hpp:77
RtcVector< RtcInt32 > RtcVectorInt32
Definition repositoryIf.hpp:69
std::vector< std::byte > RtcBinary
Definition repositoryIf.hpp:65
RtcVector< RtcUInt8 > RtcVectorUInt8
Definition repositoryIf.hpp:71
RtcMatrix< RtcUInt16 > RtcMatrixUInt16
Definition repositoryIf.hpp:84
RtcVector< RtcInt64 > RtcVectorInt64
Definition repositoryIf.hpp:70
RtcMatrix< RtcUInt32 > RtcMatrixUInt32
Definition repositoryIf.hpp:85
double RtcDouble
Definition repositoryIf.hpp:63
Header file for RepositoryIf and related base classes.
boost::container::vector< bool, A > BufferType
Definition repositoryIfTestSuite.hpp:882
gsl::span< char > SpanType
Definition repositoryIfTestSuite.hpp:859
RtcString BufferType
Definition repositoryIfTestSuite.hpp:858
std::vector< T, A > BufferType
Definition repositoryIfTestSuite.hpp:870
gsl::span< T > SpanType
Definition repositoryIfTestSuite.hpp:871
boost::container::vector< bool, A > BufferType
Definition repositoryIfTestSuite.hpp:876
gsl::span< bool > SpanType
Definition repositoryIfTestSuite.hpp:877
Definition repositoryIfTestSuite.hpp:854
Provides useful mechanisms to test various type traits.