1 |
/*
|
2 |
* TestStringOperations.h
|
3 |
*
|
4 |
* Created on: 11 Aug 2010
|
5 |
* Author: kreczko
|
6 |
*/
|
7 |
|
8 |
#include "cute/cute.h"
|
9 |
#include "cute/cute_suite.h"
|
10 |
#include "../interface/HistHelpers/StringOperations.h"
|
11 |
|
12 |
using namespace BAT;
|
13 |
|
14 |
struct TestStringOperations {
|
15 |
public:
|
16 |
TestStringOperations() {
|
17 |
|
18 |
}
|
19 |
~TestStringOperations() {
|
20 |
|
21 |
}
|
22 |
|
23 |
void testGetDirectoriesFromSimplePath() {
|
24 |
ASSERT_EQUAL(1, getDirectoriesFromPath("dir").size());
|
25 |
ASSERT_EQUAL("dir", getDirectoriesFromPath("dir").at(0));
|
26 |
}
|
27 |
|
28 |
void testGetDirectoriesFromSimplePathWithEndingSlash() {
|
29 |
ASSERT_EQUAL(1, getDirectoriesFromPath("dir/").size());
|
30 |
ASSERT_EQUAL("dir", getDirectoriesFromPath("dir/").at(0));
|
31 |
}
|
32 |
|
33 |
void testGetDirectoriesFromNestedPath() {
|
34 |
ASSERT_EQUAL(2, getDirectoriesFromPath("dir/dir2").size());
|
35 |
ASSERT_EQUAL("dir", getDirectoriesFromPath("dir/dir2").at(0));
|
36 |
ASSERT_EQUAL("dir2", getDirectoriesFromPath("dir/dir2").at(1));
|
37 |
}
|
38 |
|
39 |
void testGetDirectoriesFromEmptyPath() {
|
40 |
ASSERT_EQUAL(0, getDirectoriesFromPath("").size());
|
41 |
}
|
42 |
|
43 |
void testGetDirectoriesFromEmptyPathWithSlash() {
|
44 |
ASSERT_EQUAL(0, getDirectoriesFromPath("/").size());
|
45 |
}
|
46 |
};
|
47 |
extern cute::suite make_suite_TestStringOperations() {
|
48 |
cute::suite s;
|
49 |
|
50 |
s.push_back(CUTE_SMEMFUN(TestStringOperations, testGetDirectoriesFromSimplePath));
|
51 |
s.push_back(CUTE_SMEMFUN(TestStringOperations, testGetDirectoriesFromSimplePathWithEndingSlash));
|
52 |
s.push_back(CUTE_SMEMFUN(TestStringOperations, testGetDirectoriesFromNestedPath));
|
53 |
s.push_back(CUTE_SMEMFUN(TestStringOperations, testGetDirectoriesFromEmptyPath));
|
54 |
s.push_back(CUTE_SMEMFUN(TestStringOperations, testGetDirectoriesFromEmptyPathWithSlash));
|
55 |
|
56 |
return s;
|
57 |
}
|