xref: /haiku/src/tests/apps/haikudepot/StorageUtilsTest.cpp (revision 17889a8c70dbb3d59c1412f6431968753c767bab)
1 /*
2  * Copyright 2020, Andrew Lindesay <apl@lindesay.co.nz>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 #include "StorageUtilsTest.h"
6 
7 #include <String.h>
8 
9 #include <cppunit/TestCaller.h>
10 #include <cppunit/TestSuite.h>
11 
12 #include "StorageUtils.h"
13 
14 
15 StorageUtilsTest::StorageUtilsTest()
16 {
17 }
18 
19 
20 StorageUtilsTest::~StorageUtilsTest()
21 {
22 }
23 
24 
25 void
26 StorageUtilsTest::TestSwapExtensionOnPathComponent()
27 {
28 	const BString input = "/paved/path.tea";
29 
30 // ----------------------
31 	BString output = StorageUtils::SwapExtensionOnPathComponent(input, "chai");
32 // ----------------------
33 
34 	const BString expected = "/paved/path.chai";
35 	CPPUNIT_ASSERT_EQUAL(expected, output);
36 }
37 
38 
39 /*static*/ void
40 StorageUtilsTest::AddTests(BTestSuite& parent)
41 {
42 	CppUnit::TestSuite& suite = *new CppUnit::TestSuite("StorageUtilsTest");
43 
44 	suite.addTest(
45 		new CppUnit::TestCaller<StorageUtilsTest>(
46 			"StorageUtilsTest::TestSwapExtensionOnPathComponent",
47 			&StorageUtilsTest::TestSwapExtensionOnPathComponent));
48 
49 	parent.addTest("StorageUtilsTest", &suite);
50 }