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 FileHelpersTest.cpp
11 /// @author Matthias Heppner
12 /// @author Michael Behrisch
13 /// @date 2009
14 /// @version $Id$
15 ///
16 // Tests FileHelpers class from <SUMO>/src/utils/common
17 /****************************************************************************/
18
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <gtest/gtest.h>
23 #include <utils/common/FileHelpers.h>
24
25
26 // ===========================================================================
27 // test definitions
28 // ===========================================================================
29 /* Tests the method checkForRelativity. Unify special filenames and make standard file paths relative to the config. */
TEST(FileHelpers,test_method_checkForRelativity)30 TEST(FileHelpers, test_method_checkForRelativity) {
31 EXPECT_EQ("stdout", FileHelpers::checkForRelativity("-", "")) << "Special filename '-' should be treated as stdout";
32 EXPECT_EQ("/home/user/test.net.xml", FileHelpers::checkForRelativity("test.net.xml", "/home/user/test.sumocfg")) << "configuration path should be used.";
33 EXPECT_EQ("/test.net.xml", FileHelpers::checkForRelativity("test.net.xml", "/test.sumocfg")) << "configuration path should be used.";
34 }
35
36
TEST(FileHelpers,test_method_getConfigurationRelative)37 TEST(FileHelpers, test_method_getConfigurationRelative) {
38 EXPECT_EQ("/home/user/test.net.xml", FileHelpers::getConfigurationRelative("/home/user/test.sumocfg", "test.net.xml")) << "configuration path should be used.";
39 EXPECT_EQ("/test.net.xml", FileHelpers::getConfigurationRelative("/test.sumocfg", "test.net.xml")) << "configuration path should be used.";
40 }
41
42
TEST(FileHelpers,test_method_getFilePath)43 TEST(FileHelpers, test_method_getFilePath) {
44 EXPECT_EQ("/home/user/", FileHelpers::getFilePath("/home/user/test.sumocfg")) << "configuration path should be used.";
45 EXPECT_EQ("/", FileHelpers::getFilePath("/test.sumocfg")) << "configuration path should be used.";
46 }
47
48
49