aboutsummaryrefslogtreecommitdiffstats
path: root/tests/utility/pathTest.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2014-01-19 16:25:25 +0000
committerVincent Richard <[email protected]>2014-01-19 16:25:25 +0000
commit58bad6e4887bd41c17f3b89a70a1837356a12ebf (patch)
treeec8238632d6f15b34473fedd235f75b2d0501267 /tests/utility/pathTest.cpp
parentBetter error message. (diff)
downloadvmime-58bad6e4887bd41c17f3b89a70a1837356a12ebf.tar.gz
vmime-58bad6e4887bd41c17f3b89a70a1837356a12ebf.zip
Path to/from string conversion.
Diffstat (limited to 'tests/utility/pathTest.cpp')
-rw-r--r--tests/utility/pathTest.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/utility/pathTest.cpp b/tests/utility/pathTest.cpp
index d0c1c091..ef1b773d 100644
--- a/tests/utility/pathTest.cpp
+++ b/tests/utility/pathTest.cpp
@@ -53,6 +53,10 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VMIME_TEST(testIsParentOf_EquivalentCharset)
VMIME_TEST(testRenameParent)
+
+ VMIME_TEST(testFromString)
+ VMIME_TEST(testFromString_IgnoreLeadingOrTrailingSep)
+ VMIME_TEST(testToString)
VMIME_TEST_LIST_END
@@ -313,5 +317,41 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("6", "d", p.getComponentAt(4).getBuffer());
}
+ void testFromString()
+ {
+ path p = path::fromString("ab/cde/f", "/", vmime::charset("my-charset"));
+
+ VASSERT_EQ("count", 3, p.getSize());
+ VASSERT_EQ("buffer1", "ab", p.getComponentAt(0).getBuffer());
+ VASSERT_EQ("charset1", "my-charset", p.getComponentAt(0).getCharset().getName());
+ VASSERT_EQ("buffer2", "cde", p.getComponentAt(1).getBuffer());
+ VASSERT_EQ("charset2", "my-charset", p.getComponentAt(1).getCharset().getName());
+ VASSERT_EQ("buffer3", "f", p.getComponentAt(2).getBuffer());
+ VASSERT_EQ("charset3", "my-charset", p.getComponentAt(2).getCharset().getName());
+ }
+
+ void testFromString_IgnoreLeadingOrTrailingSep()
+ {
+ path p = path::fromString("//ab/cde/f////", "/", vmime::charset("my-charset"));
+
+ VASSERT_EQ("count", 3, p.getSize());
+ VASSERT_EQ("buffer1", "ab", p.getComponentAt(0).getBuffer());
+ VASSERT_EQ("charset1", "my-charset", p.getComponentAt(0).getCharset().getName());
+ VASSERT_EQ("buffer2", "cde", p.getComponentAt(1).getBuffer());
+ VASSERT_EQ("charset2", "my-charset", p.getComponentAt(1).getCharset().getName());
+ VASSERT_EQ("buffer3", "f", p.getComponentAt(2).getBuffer());
+ VASSERT_EQ("charset3", "my-charset", p.getComponentAt(2).getCharset().getName());
+ }
+
+ void testToString()
+ {
+ path p;
+ p.appendComponent(comp("ab"));
+ p.appendComponent(comp("cde"));
+ p.appendComponent(comp("f"));
+
+ VASSERT_EQ("string", "ab/cde/f", p.toString("/", vmime::charset("us-ascii")));
+ }
+
VMIME_TEST_SUITE_END