34 #include <gtest/gtest.h> 39 TEST(IndustrialUtilsSuite, vector_within_range)
42 std::vector<double> v1;
43 std::vector<double> v2;
44 const double range = 0.01;
45 const double half_range = range / 2.0;
46 const double outside_range = 1.1 * half_range;
47 const double inside_range = 0.9 * half_range;
48 const double a = 9.65;
49 const double b = 1324.239;
50 const double c = 90204987243.1433223;
65 v2.push_back(b + inside_range);
69 v2.push_back(b + outside_range);
76 v2.push_back(c + inside_range);
80 v2.push_back(c + outside_range);
85 TEST(IndustrialUtilsSuite, map_within_range)
87 std::vector<double> v1;
88 std::vector<std::string> v1_keys;
89 std::vector<double> v2;
90 std::vector<std::string> v2_keys;
91 std::vector<double> v3;
92 std::vector<std::string> v3_keys;
93 const double range = 0.01;
94 const double half_range = range / 2.0;
95 const double outside_range = 1.1 * half_range;
96 const double inside_range = 0.9 * half_range;
97 const double a = 9.65;
98 const double b = 1324.239;
99 const double c = 90204987243.1433223;
107 v1_keys.push_back(
"a");
109 v1_keys.push_back(
"b");
111 v1_keys.push_back(
"c");
113 ASSERT_FALSE(
isWithinRange(v1_keys, v1, v2_keys, v2, range));
117 v2.push_back(inside_range + c);
118 v2_keys.push_back(
"c");
119 v2.push_back(inside_range + b);
120 v2_keys.push_back(
"b");
121 v2.push_back(inside_range + a);
122 v2_keys.push_back(
"a");
126 v3.push_back(outside_range + a);
127 v3_keys.push_back(
"a");
128 v3.push_back(outside_range + b);
129 v3_keys.push_back(
"b");
130 v3.push_back(outside_range + c);
131 v3_keys.push_back(
"c");
134 ASSERT_FALSE(
isWithinRange(v1_keys, v1, v3_keys, v3, range));
140 int main(
int argc,
char **argv)
142 testing::InitGoogleTest(&argc, argv);
143 return RUN_ALL_TESTS();
TEST(IndustrialUtilsSuite, vector_within_range)
int main(int argc, char **argv)
bool isWithinRange(const std::vector< double > &lhs, const std::vector< double > &rhs, double full_range)
Checks to see if members are within the same range. Specifically, Each item in abs(lhs[i] - rhs[i]) <...