forked from carla-simulator/carla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_vector3D.cpp
25 lines (21 loc) · 876 Bytes
/
test_vector3D.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
// de Barcelona (UAB).
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
#include "test.h"
#include "gtest/gtest-death-test.h"
#include <carla/geom/Vector3D.h>
#include <carla/geom/Math.h>
using namespace carla::geom;
TEST(vector3D, make_unit_vec) {
ASSERT_EQ(Vector3D(10,0,0).MakeUnitVector(), Vector3D(1,0,0));
ASSERT_NE(Vector3D(10,0,0).MakeUnitVector(), Vector3D(0,1,0));
ASSERT_EQ(Vector3D(0,10,0).MakeUnitVector(), Vector3D(0,1,0));
ASSERT_EQ(Vector3D(0,0,512).MakeUnitVector(), Vector3D(0,0,1));
ASSERT_NE(Vector3D(0,1,512).MakeUnitVector(), Vector3D(0,0,1));
#ifndef NDEBUG
ASSERT_DEATH_IF_SUPPORTED(
Vector3D().MakeUnitVector(), "len > std::numeric_limits<double>::epsilon()");
#endif // NDEBUG
}