stl_loader_test.cpp
Go to the documentation of this file.
00001 #include <gtest/gtest.h>
00002 #include <boost/filesystem.hpp>
00003 #include <ros/package.h>
00004 #include <rviz/ogre_helpers/stl_loader.h>
00005 
00006 TEST( STLLoader, load )
00007 {
00008   // Get the path to the directory where the meshes are located.
00009   boost::filesystem::path meshDir = ros::package::getPath("rviz");
00010   meshDir /= "src/test/meshes";
00011 
00012   // Load an ascii STL file. Note that only binary STL files are supported.
00013   ogre_tools::STLLoader loader;
00014   boost::filesystem::path meshFilePath = meshDir / "ascii.stl";
00015   EXPECT_FALSE(loader.load(meshFilePath.string()));
00016 
00017   // Load an invalid STL binary file (size < 84 bytes).
00018   meshFilePath = meshDir / "invalid_short.stl";
00019   EXPECT_FALSE(loader.load(meshFilePath.string()));
00020 
00021   // Load an invalid STL binary file (size does not match the expected size).
00022   meshFilePath = meshDir / "invalid.stl";
00023   EXPECT_FALSE(loader.load(meshFilePath.string()));
00024 
00025   // Load an invalid STL binary file (size does not match the expected size,
00026   // but does if incorrectly read as an 16-bit uint)
00027   meshFilePath = meshDir / "16bit_vs_32bit_should_fail.stl";
00028   EXPECT_FALSE(loader.load(meshFilePath.string()));
00029 
00030   // Load a valid STL binary file.
00031   meshFilePath = meshDir / "valid.stl";
00032   EXPECT_TRUE(loader.load(meshFilePath.string()));
00033 
00034   // Load a "potentially" valid STL binary file with bigger size than the
00035   // expected. The extra "unexpected" data at the end of the file should be
00036   // ignored.
00037   meshFilePath = meshDir / "valid_extra.stl";
00038   EXPECT_TRUE(loader.load(meshFilePath.string()));
00039 }
00040 
00041 int main( int argc, char **argv ) {
00042   testing::InitGoogleTest( &argc, argv );
00043   return RUN_ALL_TESTS();
00044 }


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Tue Oct 3 2017 03:19:31