22 #include <cppunit/ui/text/TestRunner.h> 23 #include <cppunit/TextOutputter.h> 24 #include <cppunit/extensions/TestFactoryRegistry.h> 25 #include <cppunit/extensions/HelperMacros.h> 26 #include <cppunit/TestAssert.h> 27 #include <coil/File.h> 29 static const std::string
Str01(
"/usr/include/coil");
30 static const std::string
Str02(
"/usr/include/coil/");
31 static const std::string
Str03(
"coil");
32 static const std::string
Str04(
"/");
33 static const std::string
Str05(
".");
34 static const std::string
Str06(
"..");
35 static const std::string
Str07(
"/usr");
44 :
public CppUnit::TestFixture
99 strcpy(buff,
Str01.c_str());
102 std::string expected(
"/usr/include");
103 CPPUNIT_ASSERT_EQUAL(expected, result);
109 strcpy(buff,
Str01.c_str());
112 std::string expected(
"coil");
113 CPPUNIT_ASSERT_EQUAL(expected, result);
119 strcpy(buff,
Str02.c_str());
122 std::string expected(
"/usr/include");
123 CPPUNIT_ASSERT_EQUAL(expected, result);
129 strcpy(buff,
Str02.c_str());
132 std::string expected(
"coil");
133 CPPUNIT_ASSERT_EQUAL(expected, result);
139 strcpy(buff,
Str03.c_str());
142 std::string expected(
".");
143 CPPUNIT_ASSERT_EQUAL(expected, result);
149 strcpy(buff,
Str03.c_str());
152 std::string expected(
"coil");
153 CPPUNIT_ASSERT_EQUAL(expected, result);
159 strcpy(buff,
Str04.c_str());
162 std::string expected(
"/");
163 CPPUNIT_ASSERT_EQUAL(expected, result);
169 strcpy(buff,
Str04.c_str());
172 std::string expected(
"/");
173 CPPUNIT_ASSERT_EQUAL(expected, result);
179 strcpy(buff,
Str05.c_str());
182 std::string expected(
".");
183 CPPUNIT_ASSERT_EQUAL(expected, result);
189 strcpy(buff,
Str05.c_str());
192 std::string expected(
".");
193 CPPUNIT_ASSERT_EQUAL(expected, result);
199 strcpy(buff,
Str06.c_str());
202 std::string expected(
".");
203 CPPUNIT_ASSERT_EQUAL(expected, result);
209 strcpy(buff,
Str06.c_str());
212 std::string expected(
"..");
213 CPPUNIT_ASSERT_EQUAL(expected, result);
219 strcpy(buff,
Str07.c_str());
222 std::string expected(
"/");
223 CPPUNIT_ASSERT_EQUAL(expected, result);
229 strcpy(buff,
Str07.c_str());
232 std::string expected(
"usr");
233 CPPUNIT_ASSERT_EQUAL(expected, result);
245 int main(
int argc,
char* argv[])
247 CppUnit::TextUi::TestRunner runner;
248 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
249 CppUnit::Outputter* outputter =
250 new CppUnit::TextOutputter(&runner.result(), std::cout);
251 runner.setOutputter(outputter);
int main(int argc, char **argv)
static const std::string Str04("/")
CPPUNIT_TEST_SUITE(FileTests)
static const std::string Str03("coil")
static const std::string Str05(".")
CPPUNIT_TEST_SUITE_REGISTRATION(File::FileTests)
static const std::string Str07("/usr")
static const std::string Str02("/usr/include/coil/")
static const std::string Str01("/usr/include/coil")
virtual void tearDown()
Test finalization.
static const std::string Str06("..")
CPPUNIT_TEST(test_dirname_01)
const char * basename(const char *path)
Get a file name part than a file pass.
virtual void setUp()
Test initialization.
const char * dirname(const char *path)