CARLA
 
载入中...
搜索中...
未找到
test_vector3D.cpp
浏览该文件的文档.
1// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#include "test.h"
8#include "gtest/gtest-death-test.h"
9
10#include <carla/geom/Vector3D.h>
11#include <carla/geom/Math.h>
12
13using namespace carla::geom;
14
15TEST(vector3D, make_unit_vec) {
16 ASSERT_EQ(Vector3D(10,0,0).MakeUnitVector(), Vector3D(1,0,0));
17 ASSERT_NE(Vector3D(10,0,0).MakeUnitVector(), Vector3D(0,1,0));
18 ASSERT_EQ(Vector3D(0,10,0).MakeUnitVector(), Vector3D(0,1,0));
19 ASSERT_EQ(Vector3D(0,0,512).MakeUnitVector(), Vector3D(0,0,1));
20 ASSERT_NE(Vector3D(0,1,512).MakeUnitVector(), Vector3D(0,0,1));
21#ifdef LIBCARLA_NO_EXCEPTIONS
22 ASSERT_DEATH_IF_SUPPORTED(
23 Vector3D().MakeUnitVector(),
24 "length > 2.0f \\* std::numeric_limits<float>::epsilon()");
25#else
26 ASSERT_THROW(
27 Vector3D().MakeUnitVector(),
28 std::runtime_error);
29#endif // LIBCARLA_NO_EXCEPTIONS
30}
TEST(vector3D, make_unit_vec)