7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for string operations"
10 #include <boost/test/unit_test.hpp>
12 #include <boost/algorithm/string.hpp>
18 using namespace boost;
22 BOOST_AUTO_TEST_SUITE( String_TestSuite )
30 string parts[] = {
"one",
"two",
"three"};
31 string str =
" HeLLo World 123 ";
33 vector<string> myVector;
36 BOOST_CHECK_EQUAL(algorithm::join(parts,
" "),
"one two three");
40 algorithm::to_lower(tmpStr);
41 BOOST_CHECK_EQUAL(tmpStr,
" hello world 123 ");
45 algorithm::to_upper(tmpStr);
46 BOOST_CHECK_EQUAL(tmpStr,
" HELLO WORLD 123 ");
50 algorithm::replace_all(tmpStr,
"World",
"User");
51 BOOST_CHECK_EQUAL(tmpStr,
" HeLLo User 123 ");
55 algorithm::trim_left(tmpStr);
56 BOOST_CHECK_EQUAL(tmpStr,
"HeLLo World 123 ");
60 algorithm::trim_right(tmpStr);
61 BOOST_CHECK_EQUAL(tmpStr,
" HeLLo World 123");
65 algorithm::trim(tmpStr);
66 BOOST_CHECK_EQUAL(tmpStr,
"HeLLo World 123");
69 algorithm::split(myVector, str, algorithm::is_any_of(
" "), token_compress_on);
70 BOOST_CHECK_EQUAL(myVector.size(), (
unsigned int) 5);
71 BOOST_CHECK_EQUAL(myVector[0],
"");
72 BOOST_CHECK_EQUAL(myVector[1],
"HeLLo");
73 BOOST_CHECK_EQUAL(myVector[2],
"World");
74 BOOST_CHECK_EQUAL(myVector[3],
"123");
75 BOOST_CHECK_EQUAL(myVector[4],
"");
78 BOOST_CHECK(algorithm::starts_with(str,
" HeLLo"));
81 BOOST_CHECK(algorithm::ends_with(str,
"World 123 "));
87 BOOST_CHECK_EQUAL(
to_str(42),
"42");
88 BOOST_CHECK(boost::starts_with(
to_str(3.14),
"3.14000"));
94 BOOST_CHECK_EQUAL(from_str<cf3::Real>(
"3.14"), 3.14);
99 URI uri(
"file://hostname");
100 uri /=
"file_name.txt";
102 BOOST_CHECK_EQUAL(uri.
string(),
"file://hostname/file_name.txt");
106 BOOST_CHECK(uri2.is_relative());
107 BOOST_CHECK_EQUAL(uri2.string(),
"file:file_name.txt");
109 URI uri3(
"cpath:/hostname");
111 BOOST_CHECK(uri3.is_absolute());
112 BOOST_CHECK_EQUAL(uri3.string(),
"cpath:/hostname/component");
113 BOOST_CHECK_EQUAL(uri3.base_path().string(),
"cpath:/hostname");
116 BOOST_AUTO_TEST_SUITE_END()
external boost library namespace
common::URI uri(ComponentWrapper &self)
Conversions from and to std::string.
Common_API std::string to_str(const T &v)
Converts to std::string.
BOOST_AUTO_TEST_CASE(boostFunctions)
Uniform Resource Identifier (see http://en.wikipedia.org/wiki/Uniform_Resource_Identifier) ...
Top-level namespace for coolfluid.
Common_API int from_str< int >(const std::string &str)
Most basic kernel library.
std::string string() const