src
test
stl_loader_test.cpp
Go to the documentation of this file.
1
#include <gtest/gtest.h>
2
#include <
rviz/mesh_loader.h
>
3
#include <
ros/package.h
>
4
#include <
rviz/ogre_helpers/render_system.h
>
5
6
TEST
(STLLoader, load)
7
{
8
// Get the path to the directory where the meshes are located.
9
std::string meshDir =
"package://rviz/src/test/meshes/"
;
10
11
// Load a valid ascii STL file.
12
std::string meshFilePath = meshDir +
"valid_ascii.stl"
;
13
EXPECT_TRUE(
rviz::loadMeshFromResource
(meshFilePath).
get
());
14
15
// Load an invalid ascii STL file, using "end facet" instead of "endfacet"
16
meshFilePath = meshDir +
"invalid_end_tags.stl"
;
17
EXPECT_FALSE(
rviz::loadMeshFromResource
(meshFilePath).
get
());
18
19
// Load an invalid STL binary file (size < 84 bytes).
20
meshFilePath = meshDir +
"invalid_short.stl"
;
21
EXPECT_FALSE(
rviz::loadMeshFromResource
(meshFilePath).
get
());
22
23
// Load an invalid STL binary file (size does not match the expected size).
24
meshFilePath = meshDir +
"invalid.stl"
;
25
EXPECT_FALSE(
rviz::loadMeshFromResource
(meshFilePath).
get
());
26
27
// Load an invalid STL binary file (size does not match the expected size,
28
// but does if incorrectly read as an 16-bit uint)
29
meshFilePath = meshDir +
"16bit_vs_32bit_should_fail.stl"
;
30
EXPECT_FALSE(
rviz::loadMeshFromResource
(meshFilePath).
get
());
31
32
// Load a valid STL binary file.
33
meshFilePath = meshDir +
"valid.stl"
;
34
EXPECT_TRUE(
rviz::loadMeshFromResource
(meshFilePath).
get
());
35
36
// Load a "potentially" valid STL binary file with extra data at the end of the file
37
meshFilePath = meshDir +
"invalid_extra.stl"
;
38
EXPECT_FALSE(
rviz::loadMeshFromResource
(meshFilePath).
get
());
39
}
40
41
int
main
(
int
argc,
char
** argv)
42
{
43
testing::InitGoogleTest(&argc, argv);
44
45
// initialize ogre resource system
46
rviz::RenderSystem::get
();
47
48
return
RUN_ALL_TESTS();
49
}
rviz::RenderSystem::get
static RenderSystem * get()
Definition:
render_system.cpp:73
rviz::loadMeshFromResource
Ogre::MeshPtr loadMeshFromResource(const std::string &resource_path)
Definition:
mesh_loader.cpp:606
mesh_loader.h
main
int main(int argc, char **argv)
Definition:
stl_loader_test.cpp:41
render_system.h
package.h
TEST
TEST(STLLoader, load)
Definition:
stl_loader_test.cpp:6
rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat May 27 2023 02:06:25