We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 73f5f1b commit a65a734Copy full SHA for a65a734
1 file changed
ocaml/libs/xapi-stdext/lib/xapi-stdext-std/xstringext_test.ml
@@ -72,4 +72,27 @@ let test_rtrim =
72
in
73
("rtrim", List.map test spec)
74
75
-let () = Alcotest.run "Xstringext" [test_split; test_rtrim]
+let test_replace =
76
+ let spec =
77
+ [
78
+ (("*", "WILDCHAR", ""), "")
79
+ ; (("*", "", "*"), "")
80
+ ; (("*", "WILDCHAR", "*"), "WILDCHAR")
81
+ ; (("*", "WILDCHAR", "**"), "WILDCHARWILDCHAR")
82
+ ; (("*", "WILDCHAR", "***"), "WILDCHARWILDCHARWILDCHAR")
83
+ ; (({|"|}, "", ""), "")
84
+ ; (({|"|}, "", "a"), "a")
85
+ ; (({|"|}, "", {|"a"|}), "a")
86
+ ; (({|"|}, "", {|a"a|}), "aa")
87
+ ]
88
+ in
89
+ let test ((char, by, case), expected) =
90
+ let name =
91
+ Printf.sprintf "replace %S by %S in %S is %S" char (String.escaped by)
92
+ (String.escaped case) (String.escaped expected)
93
94
+ test_string (XString.replace char by) (name, case, expected)
95
96
+ ("replace", List.map test spec)
97
+
98
+let () = Alcotest.run "Xstringext" [test_split; test_rtrim; test_replace]
0 commit comments