Line data Source code
1 : /****************************************************************************/ 2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 3 : // Copyright (C) 2001-2024 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 2 : class NBHeightMapperTest : public testing::Test { 27 : protected : 28 : 29 2 : virtual void SetUp() { 30 : NBHeightMapper& hm = NBHeightMapper::myInstance; 31 2 : PositionVector t1; 32 2 : t1.push_back(Position(0, 0, 0)); 33 2 : t1.push_back(Position(1, 0, 0)); 34 2 : t1.push_back(Position(0, 1, 0)); 35 2 : hm.addTriangle(t1); 36 : 37 2 : PositionVector t2; 38 2 : t2.push_back(Position(1, 0, 1)); 39 2 : t2.push_back(Position(1, 1, 1)); 40 2 : t2.push_back(Position(0, 1, 1)); 41 2 : hm.addTriangle(t2); 42 : 43 2 : PositionVector t3; 44 2 : t3.push_back(Position(1, 0, 0)); 45 2 : t3.push_back(Position(3, 0, 4)); 46 2 : t3.push_back(Position(1, 2, 4)); 47 2 : hm.addTriangle(t3); 48 2 : } 49 : 50 2 : virtual void TearDown() { 51 : NBHeightMapper& hm = NBHeightMapper::myInstance; 52 2 : hm.clearData(); 53 2 : } 54 : }; 55 : 56 : /* Test the method 'getZ'*/ 57 2 : TEST_F(NBHeightMapperTest, test_method_getZ) { 58 2 : const NBHeightMapper& hm = NBHeightMapper::get(); 59 2 : EXPECT_TRUE(hm.ready()); 60 2 : EXPECT_DOUBLE_EQ(0., hm.getZ(Position(0.25, 0.25))); 61 2 : EXPECT_DOUBLE_EQ(1., hm.getZ(Position(0.75, 0.75))); 62 2 : 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 2 : }