2
* Copyright (C) 2021 Open Source Robotics Foundation
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
18
#include <gtest/gtest.h>
20
#include <ignition/gazebo/Primitives.hh>
21
#include <sdf/Root.hh>
23
using PrimitiveShape = ignition::gazebo::PrimitiveShape;
24
using PrimitiveLight = ignition::gazebo::PrimitiveLight;
26
/////////////////////////////////////////////////
27
TEST(Primitives, shapes)
31
PrimitiveShape::kSphere,
32
PrimitiveShape::kCylinder,
33
PrimitiveShape::kCapsule,
34
PrimitiveShape::kEllipsoid
37
for (auto prim : primitives)
39
auto sdfString = ignition::gazebo::getPrimitiveShape(prim);
40
ASSERT_FALSE(sdfString.empty());
42
/// Verify that string contains valid SDF
44
auto errors = root.LoadSdfString(sdfString);
45
EXPECT_TRUE(errors.empty()) << sdfString;
49
/////////////////////////////////////////////////
50
TEST(Primitives, lights)
53
PrimitiveLight::kDirectional,
54
PrimitiveLight::kPoint,
55
PrimitiveLight::kSpot,
58
for (auto prim : primitives)
60
auto sdfString = ignition::gazebo::getPrimitiveLight(prim);
61
ASSERT_FALSE(sdfString.empty());
63
/// Verify that string contains valid SDF
65
auto errors = root.LoadSdfString(sdfString);
66
EXPECT_TRUE(errors.empty()) << sdfString;
70
/////////////////////////////////////////////////
71
TEST(Primitives, invalid)
73
auto sdfString = ignition::gazebo::getPrimitive("foobar");
74
ASSERT_TRUE(sdfString.empty());
77
/////////////////////////////////////////////////
78
TEST(Primitives, strings)
81
"box", "sphere", "cylinder", "capsule", "ellipsoid",
82
"point", "directional", "spot"
85
for (auto prim : primitives)
87
auto sdfString = ignition::gazebo::getPrimitive(prim);
88
ASSERT_FALSE(sdfString.empty());
90
/// Verify that string contains valid SDF
92
auto errors = root.LoadSdfString(sdfString);
93
EXPECT_TRUE(errors.empty()) << sdfString;