1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
10 /// @file NBHeightMapperTest.cpp
11 /// @author Laura Bieker
12 /// @author Michael Behrisch
13 /// @date 2014-09-09
14 /// @version $Id$
15 ///
16 // Tests the class NBHeightMapper
17 /****************************************************************************/
18
19 #include <gtest/gtest.h>
20 #include <netbuild/NBHeightMapper.h>
21
22 class NBHeightMapperTest : public testing::Test {
23 protected :
24
SetUp()25 virtual void SetUp(){
26 NBHeightMapper &hm = NBHeightMapper::Singleton;
27 PositionVector t1;
28 t1.push_back(Position(0,0,0));
29 t1.push_back(Position(1,0,0));
30 t1.push_back(Position(0,1,0));
31 hm.addTriangle(t1);
32
33 PositionVector t2;
34 t2.push_back(Position(1,0,1));
35 t2.push_back(Position(1,1,1));
36 t2.push_back(Position(0,1,1));
37 hm.addTriangle(t2);
38
39 PositionVector t3;
40 t3.push_back(Position(1,0,0));
41 t3.push_back(Position(3,0,4));
42 t3.push_back(Position(1,2,4));
43 hm.addTriangle(t3);
44 }
45
TearDown()46 virtual void TearDown(){
47 NBHeightMapper &hm = NBHeightMapper::Singleton;
48 hm.clearData();
49 }
50 };
51
52 /* Test the method 'getZ'*/
TEST_F(NBHeightMapperTest,test_method_getZ)53 TEST_F(NBHeightMapperTest, test_method_getZ) {
54 const NBHeightMapper &hm = NBHeightMapper::get();
55 EXPECT_TRUE(hm.ready());
56 EXPECT_DOUBLE_EQ(0., hm.getZ(Position(0.25, 0.25)));
57 EXPECT_DOUBLE_EQ(1., hm.getZ(Position(0.75, 0.75)));
58 EXPECT_DOUBLE_EQ(2., hm.getZ(Position(1.5, 0.5)));
59 //EXPECT_DOUBLE_EQ(0.5, hm.getZ(Position(0.5, 0.5, 100)));
60 }
61
62
63