stl_loader_test.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 #include <boost/filesystem.hpp>
3 #include <ros/package.h>
5 
6 TEST( STLLoader, load )
7 {
8  // Get the path to the directory where the meshes are located.
9  boost::filesystem::path meshDir = ros::package::getPath("rviz");
10  meshDir /= "src/test/meshes";
11 
12  // Load an ascii STL file. Note that only binary STL files are supported.
13  ogre_tools::STLLoader loader;
14  boost::filesystem::path meshFilePath = meshDir / "ascii.stl";
15  EXPECT_FALSE(loader.load(meshFilePath.string()));
16 
17  // Load an invalid STL binary file (size < 84 bytes).
18  meshFilePath = meshDir / "invalid_short.stl";
19  EXPECT_FALSE(loader.load(meshFilePath.string()));
20 
21  // Load an invalid STL binary file (size does not match the expected size).
22  meshFilePath = meshDir / "invalid.stl";
23  EXPECT_FALSE(loader.load(meshFilePath.string()));
24 
25  // Load an invalid STL binary file (size does not match the expected size,
26  // but does if incorrectly read as an 16-bit uint)
27  meshFilePath = meshDir / "16bit_vs_32bit_should_fail.stl";
28  EXPECT_FALSE(loader.load(meshFilePath.string()));
29 
30  // Load a valid STL binary file.
31  meshFilePath = meshDir / "valid.stl";
32  EXPECT_TRUE(loader.load(meshFilePath.string()));
33 
34  // Load a "potentially" valid STL binary file with bigger size than the
35  // expected. The extra "unexpected" data at the end of the file should be
36  // ignored.
37  meshFilePath = meshDir / "valid_extra.stl";
38  EXPECT_TRUE(loader.load(meshFilePath.string()));
39 }
40 
41 int main( int argc, char **argv ) {
42  testing::InitGoogleTest( &argc, argv );
43  return RUN_ALL_TESTS();
44 }
bool load(const std::string &path)
Definition: stl_loader.cpp:48
int main(int argc, char **argv)
ROSLIB_DECL std::string getPath(const std::string &package_name)
TEST(STLLoader, load)


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Wed Aug 28 2019 04:01:51