test_failed_at_this_configuration.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2023. Toyota Research Institute
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of CNRS-LAAS and AIST nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34 
37 #include <gtest/gtest.h>
38 
39 #include <regex>
40 
41 #include "fcl/geometry/shape/box.h"
45 
46 namespace fcl {
47 namespace detail {
48 namespace {
49 
50 // We're testing for the following:
51 //
52 // 1. The exception message is included.
53 // 2. The shapes have had representation() called on them. We'll use two
54 // different shapes to confirm they get ordered correctly.
55 // 3. The first matrix is printed with the first shape, the second with the
56 // second.
57 // 4. The matrices have commas.
58 GTEST_TEST(ConfigurationFailureTest, ConfirmFormatting) {
59  const Sphered sphere(1.5);
60  const Transform3d X_WS(Translation3d(12, 13, 14));
61  const Boxd box(1, 2, 3);
62  const Transform3d X_WB(Translation3d(17, 18, 19));
63  const GJKSolver_libccd<double> solver;
64  const std::logic_error e("dummy message");
65 
66  try {
67  ThrowDetailedConfiguration(sphere, X_WS, box, X_WB, solver, e);
68  } catch (const std::logic_error& e) {
70  std::regex_search(e.what(), std::regex("[^]+dummy message[^]+")));
71 
72  // Shape<S> is evidence that representation() got called.
73  std::regex ordered_shapes_re("[^]+Sphere<double>[^]+Box<double>[^]+");
74  EXPECT_TRUE(std::regex_search(e.what(), ordered_shapes_re)) << e.what();
75 
76  // Commas and order; we're looking for the translation values in order
77  // following commas.
78  std::regex matrices_re(
79  "[^]+X_FS1[^]+, 12,[^]+, 13,[^]+, 14,[^]+, 1;"
80  "[^]+X_FS2[^]+, 17,[^]+, 18,[^]+, 19,[^]+, 1;");
81  EXPECT_TRUE(std::regex_search(e.what(), matrices_re)) << e.what();
82  }
83 }
84 
85 } // namespace
86 } // namespace detail
87 } // namespace fcl
88 
89 //==============================================================================
90 int main(int argc, char* argv[]) {
91  ::testing::InitGoogleTest(&argc, argv);
92  return RUN_ALL_TESTS();
93 }
fcl::Sphered
Sphere< double > Sphered
Definition: sphere.h:91
sphere.h
fcl::Transform3d
Transform3< double > Transform3d
Definition: types.h:117
EXPECT_TRUE
#define EXPECT_TRUE(args)
failed_at_this_configuration.h
box.h
fcl::Translation3d
Translation3< double > Translation3d
Definition: types.h:118
gjk_solver_libccd.h
main
int main(int argc, char *argv[])
Definition: test_failed_at_this_configuration.cpp:90
fcl::detail::GTEST_TEST
GTEST_TEST(FCL_GJK_EPA, faceNormalPointingOutward)
Definition: test_gjk_libccd-inl_epa.cpp:205
fcl::Boxd
Box< double > Boxd
Definition: box.h:100
fcl::detail::ThrowDetailedConfiguration
void ThrowDetailedConfiguration(const Shape1 &s1, const Transform3< S > &X_FS1, const Shape2 &s2, const Transform3< S > &X_FS2, const Solver &solver, const std::exception &e)
Definition: failed_at_this_configuration.h:142
fcl
Main namespace.
Definition: broadphase_bruteforce-inl.h:45


fcl
Author(s):
autogenerated on Tue Dec 5 2023 03:40:49