direct_search_handler_test.cpp
Go to the documentation of this file.
1 
18 #include <algorithm>
19 
20 #include "gtest/gtest.h"
21 #include "ros/ros.h"
23 #include "asr_msgs/AsrTypeAndId.h"
24 
25 using namespace directSearchWS;
26 
27 
28 TEST(DirectSearchHandlerTest, FilterSearchedObjectTypes) {
29  SearchedObjectTypes SOTToFilter;
30  SearchedObjectTypes filterSOT;
31 
32  filterSOT.push_back("PlateDeep");
33  filterSOT.push_back("Marker0");
34  filterSOT.push_back("Marker1");
35  filterSOT.push_back("Marker1");
36 
37 
38  filterSearchedObjectTypes(SOTToFilter, filterSOT);
39  ASSERT_EQ(0, SOTToFilter.size());
40 
41  SOTToFilter.push_back("PlateDeep");
42  SOTToFilter.push_back("Marker1");
43  SOTToFilter.push_back("PlateDeep");
44  filterSearchedObjectTypes(SOTToFilter, filterSOT);
45  ASSERT_EQ(0, SOTToFilter.size());
46 
47  SOTToFilter.push_back("Marker1");
48  SOTToFilter.push_back("PlateDeep");
49  SOTToFilter.push_back("Marker10");
50  SOTToFilter.push_back("Marker1");
51  SOTToFilter.push_back("Marker1");
52  SOTToFilter.push_back("PlateDeep");
53  filterSearchedObjectTypes(SOTToFilter, filterSOT);
54  ASSERT_EQ(1, SOTToFilter.size());
55  ASSERT_EQ("Marker10", SOTToFilter[0]);
56 }
57 
58 TEST(DirectSearchHandlerTest, filterSearchedObjectTypesAndIds) {
59  SearchedObjectTypesAndIds SOTToFilter;
60  SearchedObjectTypes filterSOT;
61 
62  filterSOT.push_back("PlateDeep");
63  filterSOT.push_back("Marker0");
64  filterSOT.push_back("Marker1");
65  filterSOT.push_back("Marker1");
66 
67 
68  filterSearchedObjectTypesAndIds(SOTToFilter, filterSOT);
69  ASSERT_EQ(0, SOTToFilter.size());
70 
71  asr_msgs::AsrTypeAndId typeAndId1;
72  typeAndId1.type = "PlateDeep";
73  typeAndId1.identifier = "2";
74  SOTToFilter.push_back(typeAndId1);
75  asr_msgs::AsrTypeAndId typeAndId2;
76  typeAndId2.type = "Marker1";
77  typeAndId2.identifier = "3";
78  SOTToFilter.push_back(typeAndId2);
79  asr_msgs::AsrTypeAndId typeAndId3;
80  typeAndId3.type = "PlateDeep";
81  typeAndId3.identifier = "2";
82  SOTToFilter.push_back(typeAndId3);
83  filterSearchedObjectTypesAndIds(SOTToFilter, filterSOT);
84  ASSERT_EQ(0, SOTToFilter.size());
85 
86  asr_msgs::AsrTypeAndId typeAndId4;
87  typeAndId4.type = "Marker1";
88  typeAndId4.identifier = "3";
89  SOTToFilter.push_back(typeAndId4);
90  asr_msgs::AsrTypeAndId typeAndId5;
91  typeAndId5.type = "PlateDeep";
92  typeAndId5.identifier = "4";
93  SOTToFilter.push_back(typeAndId5);
94  asr_msgs::AsrTypeAndId typeAndId6;
95  typeAndId6.type = "Marker10";
96  typeAndId6.identifier = "4";
97  SOTToFilter.push_back(typeAndId6);
98  asr_msgs::AsrTypeAndId typeAndId7;
99  typeAndId7.type = "Marker1";
100  typeAndId7.identifier = "2";
101  SOTToFilter.push_back(typeAndId7);
102  asr_msgs::AsrTypeAndId typeAndId8;
103  typeAndId8.type = "Marker1";
104  typeAndId8.identifier = "3";
105  SOTToFilter.push_back(typeAndId8);
106  asr_msgs::AsrTypeAndId typeAndId9;
107  typeAndId9.type = "PlateDeep";
108  typeAndId9.identifier = "3";
109  SOTToFilter.push_back(typeAndId9);
110  filterSearchedObjectTypesAndIds(SOTToFilter, filterSOT);
111  ASSERT_EQ(1, SOTToFilter.size());
112  ASSERT_EQ("Marker10", SOTToFilter[0].type);
113  ASSERT_EQ("4", SOTToFilter[0].identifier);
114 }
115 
116 TEST(DirectSearchHandlerTest, GetIntersectionOfSearchObjectTypes) {
117  SearchedObjectTypes SOT1;
118  SearchedObjectTypes SOT2;
119  SearchedObjectTypes intersectionSOT;
120 
121  intersectionSOT = getIntersectionOfSearchObjectTypes(SOT1, SOT2);
122  ASSERT_EQ(0, intersectionSOT.size());
123 
124  SOT1.push_back("PlateDeep");
125  SOT1.push_back("Marker0");
126  SOT1.push_back("Marker10");
127 
128  SOT2.push_back("Marker2");
129  SOT2.push_back("Marker3");
130  SOT2.push_back("Marker4");
131 
132  intersectionSOT = getIntersectionOfSearchObjectTypes(SOT1, SOT2);
133  ASSERT_EQ(0, intersectionSOT.size());
134 
135 
136  SOT2.push_back("Marker0");
137  SOT2.push_back("Marker3");
138  SOT2.push_back("Marker0");
139 
140  intersectionSOT = getIntersectionOfSearchObjectTypes(SOT1, SOT2);
141  ASSERT_EQ(1, intersectionSOT.size());
142  ASSERT_EQ("Marker0", intersectionSOT[0]);
143 
144 
145  SOT1.push_back("Marker0");
146  intersectionSOT = getIntersectionOfSearchObjectTypes(SOT1, SOT2);
147  ASSERT_EQ(2, intersectionSOT.size());
148  ASSERT_EQ("Marker0", intersectionSOT[0]);
149  ASSERT_EQ("Marker0", intersectionSOT[1]);
150 
151 
152  SOT1.push_back("Marker3");
153  intersectionSOT = getIntersectionOfSearchObjectTypes(SOT1, SOT2);
154  ASSERT_EQ(3, intersectionSOT.size());
155  ASSERT_NE(intersectionSOT.end(), std::find(intersectionSOT.begin(), intersectionSOT.end(), "Marker0"));
156  ASSERT_NE(intersectionSOT.end(), std::find(intersectionSOT.begin(), intersectionSOT.end(), "Marker3"));
157 }
158 
159 
160 
void filterSearchedObjectTypes(SearchedObjectTypes &searched_object_types_to_filter, const SearchedObjectTypes &filter_searched_object_types)
std::vector< std::string > SearchedObjectTypes
Definition: ptu_tuple.hpp:27
std::vector< asr_msgs::AsrTypeAndId > SearchedObjectTypesAndIds
void filterSearchedObjectTypesAndIds(SearchedObjectTypesAndIds &searched_object_types_and_ids_to_filter, const SearchedObjectTypes &filter_searched_object_types)
TEST(DirectSearchHandlerTest, FilterSearchedObjectTypes)
SearchedObjectTypes getIntersectionOfSearchObjectTypes(const SearchedObjectTypes &first_searched_object_types, const SearchedObjectTypes &second_searched_object_types)


asr_direct_search_manager
Author(s): Borella Jocelyn, Karrenbauer Oliver, Mei├čner Pascal
autogenerated on Wed Jan 8 2020 03:15:41