Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/unittest/src/netbuild/NBHeightMapperTest.cpp
169678 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file NBHeightMapperTest.cpp
15
/// @author Laura Bieker
16
/// @author Michael Behrisch
17
/// @date 2014-09-09
18
///
19
// Tests the class NBHeightMapper
20
/****************************************************************************/
21
#include <config.h>
22
23
#include <gtest/gtest.h>
24
#include <netbuild/NBHeightMapper.h>
25
26
class NBHeightMapperTest : public testing::Test {
27
protected :
28
29
virtual void SetUp() {
30
NBHeightMapper& hm = NBHeightMapper::myInstance;
31
PositionVector t1;
32
t1.push_back(Position(0, 0, 0));
33
t1.push_back(Position(1, 0, 0));
34
t1.push_back(Position(0, 1, 0));
35
hm.addTriangle(t1);
36
37
PositionVector t2;
38
t2.push_back(Position(1, 0, 1));
39
t2.push_back(Position(1, 1, 1));
40
t2.push_back(Position(0, 1, 1));
41
hm.addTriangle(t2);
42
43
PositionVector t3;
44
t3.push_back(Position(1, 0, 0));
45
t3.push_back(Position(3, 0, 4));
46
t3.push_back(Position(1, 2, 4));
47
hm.addTriangle(t3);
48
}
49
50
virtual void TearDown() {
51
NBHeightMapper& hm = NBHeightMapper::myInstance;
52
hm.clearData();
53
}
54
};
55
56
/* Test the method 'getZ'*/
57
TEST_F(NBHeightMapperTest, test_method_getZ) {
58
const NBHeightMapper& hm = NBHeightMapper::get();
59
EXPECT_TRUE(hm.ready());
60
EXPECT_DOUBLE_EQ(0., hm.getZ(Position(0.25, 0.25)));
61
EXPECT_DOUBLE_EQ(1., hm.getZ(Position(0.75, 0.75)));
62
EXPECT_DOUBLE_EQ(2., hm.getZ(Position(1.5, 0.5)));
63
//EXPECT_DOUBLE_EQ(0.5, hm.getZ(Position(0.5, 0.5, 100)));
64
}
65
66