summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorRyan Stein <ryan.stein@gmx.com>2019-05-09 11:11:53 -0400
committerRĂ©mi Verschelde <rverschelde@gmail.com>2019-05-11 09:03:19 +0200
commit42d6205e8cb7775a901e280a9984c7c5b7da172a (patch)
treeb9419314fde6951771297054c826d426de5caeba /main
parent06d28a7722143639b10b35341ae6b37bb7355fb1 (diff)
Add RegEx substitution testcase and fix relevant docs
(cherry picked from commit a31bbb4bd920e28cbb2c737a785e91da5e7a599f)
Diffstat (limited to 'main')
-rw-r--r--main/tests/test_string.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp
index dcbb930d1b..531887a452 100644
--- a/main/tests/test_string.cpp
+++ b/main/tests/test_string.cpp
@@ -33,6 +33,7 @@
//#include "core/math/math_funcs.h"
#include "core/io/ip_address.h"
#include "core/os/os.h"
+#include "modules/regex/regex.h"
#include <stdio.h>
#include "test_string.h"
@@ -429,9 +430,20 @@ bool test_25() {
bool test_26() {
- //TODO: Do replacement RegEx test
- return true;
-};
+ OS::get_singleton()->print("\n\nTest 26: RegEx substitution\n");
+
+ String s = "Double all the vowels.";
+
+ OS::get_singleton()->print("\tString: %ls\n", s.c_str());
+ OS::get_singleton()->print("\tRepeating instances of 'aeiou' once\n");
+
+ RegEx re("(?<vowel>[aeiou])");
+ s = re.sub(s, "$0$vowel", true);
+
+ OS::get_singleton()->print("\tResult: %ls\n", s.c_str());
+
+ return (s == "Doouublee aall thee vooweels.");
+}
struct test_27_data {
char const *data;