diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-07-24 22:37:17 +0200 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-07-24 22:37:17 +0200 |
| commit | b5db256384f981833f85ad9019be6e212fffcc6b (patch) | |
| tree | fa2f6048c408a7fa885786f236cd3c3f604bea97 /src/unit_tests.cc | |
| parent | d6425f1d5090c3225665fff9dcf36e64ff54fb06 (diff) | |
string escaping support functions
the split function now takes an additional escape parameter and
does not split on separators that have the escaper before it.
An utility escape function that adds escape before separators
is also added.
Diffstat (limited to 'src/unit_tests.cc')
| -rw-r--r-- | src/unit_tests.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/unit_tests.cc b/src/unit_tests.cc index e0537123..5058bb91 100644 --- a/src/unit_tests.cc +++ b/src/unit_tests.cc @@ -120,11 +120,15 @@ void test_string() { kak_assert(String("youpi ") + "matin" == "youpi matin"); - std::vector<String> splited = split("youpi:matin::tchou", ':'); + std::vector<String> splited = split("youpi:matin::tchou\\:kanaky:hihi\\:", ':', '\\'); kak_assert(splited[0] == "youpi"); kak_assert(splited[1] == "matin"); kak_assert(splited[2] == ""); - kak_assert(splited[3] == "tchou"); + kak_assert(splited[3] == "tchou:kanaky"); + kak_assert(splited[4] == "hihi:"); + + String escaped = escape("youpi:matin:tchou:", ':', '\\'); + kak_assert(escaped == "youpi\\:matin\\:tchou\\:"); } void test_keys() |
