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
}
render_system.h
rviz::RenderSystem::get
static RenderSystem * get()
Definition:
render_system.cpp:76
get
def get(url)
main
int main(int argc, char **argv)
Definition:
stl_loader_test.cpp:41
mesh_loader.h
package.h
rviz::loadMeshFromResource
Ogre::MeshPtr loadMeshFromResource(const std::string &resource_path)
Definition:
mesh_loader.cpp:605
TEST
TEST(STLLoader, load)
Definition:
stl_loader_test.cpp:6
rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Dec 13 2024 03:31:03