614 std::cout <<
"***************************************************************"
615 "******************************************************"
617 std::cout <<
"==> testVectorOfApplicationModule" << std::endl;
620 size_t nInstances = 10;
627 for(
size_t i = 0; i < nInstances; ++i) {
628 std::string name =
"testModule_" + std::to_string(i) +
"_instance";
631 BOOST_TEST(node.getQualifiedName() ==
"/myApp/" + name +
"/nameOfSomeInput");
634 std::list<ctk::VariableNetworkNode> accList = app.
vectorOfTestModule[i].getAccessorList();
635 BOOST_TEST(accList.size() == 2);
636 size_t foundSomeInput = 0;
637 size_t foundSomeOutput = 0;
638 for(
auto& acc : accList) {
646 BOOST_TEST(foundSomeInput == 1);
647 BOOST_TEST(foundSomeOutput == 1);
651 BOOST_TEST(modList.size() == 2);
652 size_t foundSomeGroup = 0;
653 size_t foundAnotherGroup = 0;
654 for(
const auto* mod : modList) {
662 BOOST_TEST(foundSomeGroup == 1);
663 BOOST_TEST(foundAnotherGroup == 1);
669 BOOST_TEST(list.size() == nInstances);
670 std::map<size_t, size_t> instancesFound;
671 for(
size_t i = 0; i < nInstances; ++i) {
672 instancesFound[i] = 0;
674 for(
const auto* mod : list) {
675 for(
size_t i = 0; i < nInstances; ++i) {
681 for(
size_t i = 0; i < nInstances; ++i) {
682 BOOST_TEST(instancesFound[i] == 1);
689 BOOST_TEST(list.size() == 3 * nInstances);
690 std::map<size_t, size_t> instancesFound, instancesSomeGroupFound, instancesAnotherGroupFound;
691 for(
size_t i = 0; i < nInstances; ++i) {
692 instancesFound[i] = 0;
693 instancesSomeGroupFound[i] = 0;
694 instancesAnotherGroupFound[i] = 0;
696 for(
const auto* mod : list) {
697 for(
size_t i = 0; i < nInstances; ++i) {
702 instancesSomeGroupFound[i]++;
705 instancesAnotherGroupFound[i]++;
709 for(
size_t i = 0; i < nInstances; ++i) {
710 BOOST_TEST(instancesFound[i] == 1);
711 BOOST_TEST(instancesSomeGroupFound[i] == 1);
712 BOOST_TEST(instancesAnotherGroupFound[i] == 1);
717 for(
size_t i = 0; i < nInstances; ++i) {
734 std::cout <<
"***************************************************************"
735 "******************************************************"
737 std::cout <<
"==> testVectorsOfAllModules" << std::endl;
740 size_t nInstances = 10;
746 for(
size_t i = 0; i < nInstances; ++i) {
748 for(
size_t k = 0; k < nInstances; ++k) {
758 BOOST_CHECK(list.size() == nInstances);
759 std::map<size_t, size_t> found;
760 for(
size_t i = 0; i < nInstances; ++i) {
763 for(
const auto* mod : list) {
764 for(
size_t i = 0; i < nInstances; ++i) {
770 for(
size_t i = 0; i < nInstances; ++i) {
771 BOOST_CHECK(found[i] == 1);
776 for(
size_t i = 0; i < nInstances; ++i) {
778 BOOST_CHECK(list.size() == nInstances);
780 std::map<size_t, size_t> found;
781 for(
size_t k = 0; k < nInstances; ++k) {
784 for(
const auto* mod : list) {
785 for(
size_t k = 0; k < nInstances; ++k) {
791 for(
size_t k = 0; k < nInstances; ++k) {
792 BOOST_CHECK(found[k] == 1);
798 for(
size_t i = 0; i < nInstances; ++i) {
799 for(
size_t k = 0; k < nInstances; ++k) {
801 std::list<ctk::VariableNetworkNode> accList =
803 BOOST_CHECK_EQUAL(accList.size(), 2);
804 size_t someInputFound = 0;
805 size_t someOutputFound = 0;
806 for(
const auto& acc : accList) {
814 BOOST_CHECK_EQUAL(someInputFound, 1);
815 BOOST_CHECK_EQUAL(someOutputFound, 1);
819 BOOST_CHECK_EQUAL(modList.size(), nInstances + 1);
821 std::map<size_t, size_t> someGroupFound;
822 for(
size_t m = 0; m < nInstances; ++m) {
823 someGroupFound[m] = 0;
825 size_t anotherGroupFound = 0;
826 for(
const auto* mod : modList) {
827 for(
size_t m = 0; m < nInstances; ++m) {
836 for(
size_t m = 0; m < nInstances; ++m) {
837 BOOST_CHECK_EQUAL(someGroupFound[m], 1);
839 BOOST_CHECK_EQUAL(anotherGroupFound, 1);
845 for(
size_t i = 0; i < nInstances; ++i) {
846 for(
size_t k = 0; k < nInstances; ++k) {
847 for(
size_t m = 0; m < nInstances; ++m) {
849 std::list<ctk::VariableNetworkNode> accList =
851 BOOST_CHECK_EQUAL(accList.size(), 2);
852 size_t inGroupFound = 0;
853 size_t alsoInGroupFound = 0;
854 for(
const auto& acc : accList) {
866 BOOST_CHECK_EQUAL(inGroupFound, 1);
867 BOOST_CHECK_EQUAL(alsoInGroupFound, 1);
880 for(
size_t i = 0; i < nInstances; ++i) {
882 for(
size_t k = 0; k < nInstances; ++k) {
889 for(
size_t m = 0; m < nInstances; ++m) {
904 for(
size_t i = 0; i < nInstances; ++i) {
905 for(
size_t k = 0; k < nInstances; ++k) {
909 .getAppAccessorNoType());
916 .getAppAccessorNoType());
920 for(
size_t m = 0; m < nInstances; ++m) {
924 .getAppAccessorNoType());
931 .getAppAccessorNoType());
944 std::set<std::string> pvNames;
946 auto checker = [&](
auto proxy) {
947 pvNames.emplace(proxy.getFullyQualifiedPath());
952 checker, ctk::Model::depthFirstSearch, ctk::Model::keepProcessVariables, ctk::Model::keepParenthood);
954 size_t nExpected = 0;
955 for(
size_t i = 0; i < nInstances; ++i) {
956 std::string mgName =
"/testModule_" + std::to_string(i) +
"_instance";
957 for(
size_t k = 0; k < nInstances; ++k) {
958 std::string amName = mgName +
"/test_" + std::to_string(k);
959 for(
size_t l = 0; l < nInstances; ++l) {
960 std::string vgName = amName +
"/testGroup_" + std::to_string(l);
961 BOOST_CHECK(pvNames.count(vgName +
"/inGroup"));
962 BOOST_CHECK(pvNames.count(vgName +
"/alsoInGroup"));
966 BOOST_CHECK(pvNames.count(amName +
"/nameOfSomeInput"));
967 BOOST_CHECK(pvNames.count(amName +
"/someOutput"));
968 BOOST_CHECK(pvNames.count(amName +
"/anotherName/foo"));
973 assert(nExpected == 2 * pow(nInstances, 3) + 3 * pow(nInstances, 2));
974 BOOST_TEST(nFound == nExpected);
979 std::set<std::string> mgNames;
981 auto checker = [&](
auto proxy) {
982 mgNames.emplace(proxy.getName());
987 checker, ctk::Model::adjacentOutSearch, ctk::Model::keepOwnership, ctk::Model::keepModuleGroups);
989 for(
size_t i = 0; i < nInstances; ++i) {
990 std::string mgName =
"testModule_" + std::to_string(i) +
"_instance";
991 BOOST_CHECK(mgNames.count(mgName));
994 BOOST_TEST(nFound == nInstances);
998 for(
size_t i = 0; i < nInstances; ++i) {
1000 std::set<std::string> amNames;
1002 auto checker = [&](
auto proxy) {
1003 amNames.emplace(proxy.getName());
1008 checker, ctk::Model::adjacentOutSearch, ctk::Model::keepOwnership, ctk::Model::keepApplicationModules);
1010 for(
size_t k = 0; k < nInstances; ++k) {
1011 std::string amName =
"test_" + std::to_string(k);
1012 BOOST_CHECK(amNames.count(amName));
1015 BOOST_TEST(nFound == nInstances);
1020 for(
size_t i = 0; i < nInstances; ++i) {
1021 for(
size_t k = 0; k < nInstances; ++k) {
1023 std::set<std::string> vgNames;
1025 auto checker = [&](
auto proxy) {
1026 vgNames.emplace(proxy.getName());
1031 checker, ctk::Model::adjacentOutSearch, ctk::Model::keepOwnership, ctk::Model::keepVariableGroups);
1033 BOOST_CHECK(vgNames.count(
"anotherName"));
1034 for(
size_t l = 0; l < nInstances; ++l) {
1035 std::string vgName =
"testGroup_" + std::to_string(l);
1036 BOOST_CHECK(vgNames.count(vgName));
1039 BOOST_TEST(nFound == nInstances + 1);
1049 std::cout <<
"***************************************************************"
1050 "******************************************************"
1052 std::cout <<
"==> test_moveAssignmentOperator" << std::endl;
1053 std::cout << std::endl;
1059 "This instance of VectorModuleGroup was assigned using the operator=()");
1063 "This instance of VectorModule was assigned using the operator=()");
1066 BOOST_CHECK(list.size() == 2);
1068 bool modGroupInstanceToAssignLater_found =
false;
1069 bool modInstanceToAssignLater_found =
false;
1070 for(
const auto* mod : list) {
1072 modGroupInstanceToAssignLater_found =
true;
1075 modInstanceToAssignLater_found =
true;
1079 BOOST_CHECK(modGroupInstanceToAssignLater_found);
1080 BOOST_CHECK(modInstanceToAssignLater_found);
1092 MovedTwiceAssignModuleLaterApp() : Application(
"myApp") {
1093 modGroupInstanceToAssignLater = std::move(modGroupInstanceSource);
1094 modInstanceToAssignLater = std::move(modInstanceSource);
1095 modGroupInstanceToAssignedAfterMove = std::move(modGroupInstanceSource);
1096 modInstanceToAssignedAfterMove = std::move(modInstanceSource);
1098 ~MovedTwiceAssignModuleLaterApp()
override { shutdown(); }
1101 "This instance of VectorModuleGroup was assigned using the operator=()", 42};
1103 this,
"modInstanceToAssignLater",
"This instance of VectorModule was assigned using the operator=()", 13};
1112 auto appAgain = std::make_unique<MovedTwiceAssignModuleLaterApp>();
1114 "This instance of VectorModuleGroup was created to be destroyed after the correspondig app to check for "
1117 BOOST_CHECK(appAgain->modInstanceToAssignedAfterMove.getName() ==
"**INVALID**");
1118 BOOST_CHECK(appAgain->modGroupInstanceToAssignedAfterMove.vectorOfVectorModule.size() == 0);
1119 appAgain->modGroupInstanceToAssignLater = std::move(externalModGroup);
1122 BOOST_CHECK(externalModGroup.getName() ==
"**INVALID**");