1 /* 2 * Copyright 2015, Axel Dörfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include "UtilityTest.h" 8 9 #include <stdlib.h> 10 11 #include <cppunit/TestCaller.h> 12 #include <cppunit/TestSuite.h> 13 14 #include "Utility.h" 15 16 17 UtilityTest::UtilityTest() 18 { 19 } 20 21 22 UtilityTest::~UtilityTest() 23 { 24 } 25 26 27 void 28 UtilityTest::TestTranslatePath() 29 { 30 CPPUNIT_ASSERT_EQUAL(BString("/boot/home/test"), 31 Utility::TranslatePath("$HOME/test")); 32 CPPUNIT_ASSERT_EQUAL(BString("/boot/home/test"), 33 Utility::TranslatePath("${HOME}/test")); 34 CPPUNIT_ASSERT_EQUAL(BString("--/boot/home--"), 35 Utility::TranslatePath("--${HOME}--")); 36 CPPUNIT_ASSERT_EQUAL(BString("$(HOME)/test"), 37 Utility::TranslatePath("$(HOME)/test")); 38 CPPUNIT_ASSERT_EQUAL(BString("/boot/home/test"), 39 Utility::TranslatePath("~/test")); 40 CPPUNIT_ASSERT_EQUAL(BString("~baron/test"), 41 Utility::TranslatePath("~baron/test")); 42 CPPUNIT_ASSERT_EQUAL(BString("/~/test"), 43 Utility::TranslatePath("/~/test")); 44 } 45 46 47 /*static*/ void 48 UtilityTest::AddTests(BTestSuite& parent) 49 { 50 CppUnit::TestSuite& suite = *new CppUnit::TestSuite("UtilityTest"); 51 52 suite.addTest(new CppUnit::TestCaller<UtilityTest>( 53 "UtilityTest::TestTranslatePath", &UtilityTest::TestTranslatePath)); 54 55 parent.addTest("UtilityTest", &suite); 56 } 57