aboutsummaryrefslogtreecommitdiff
path: root/tests/core/strings
diff options
context:
space:
mode:
authorRicardo Silva <ricardo.silva@talkdesk.com>2021-09-07 18:33:59 +0100
committerRicardo Silva <ricardo.silva@talkdesk.com>2021-09-07 18:38:10 +0100
commitf6d496c81deeff1e4b1cab1cbe41a540d82334ee (patch)
tree9020f8854a218f29477613c31682efe1e7d2bc91 /tests/core/strings
parent1dffd4ea3dc93480019016ce0a8204191f3e8b81 (diff)
Fix strings.index_any on small strings
Diffstat (limited to 'tests/core/strings')
-rw-r--r--tests/core/strings/test_core_strings.odin29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/core/strings/test_core_strings.odin b/tests/core/strings/test_core_strings.odin
new file mode 100644
index 000000000..c9da5a688
--- /dev/null
+++ b/tests/core/strings/test_core_strings.odin
@@ -0,0 +1,29 @@
+package test_core_image
+
+import "core:strings"
+import "core:testing"
+
+@test
+test_index_any_small_string_not_found :: proc(t: ^testing.T) {
+ index := strings.index_any(".", "/:\"")
+ testing.log(t, index)
+ testing.expect(t, index == -1, "index_any should be negative")
+}
+
+@test
+test_index_any_larger_string_not_found :: proc(t: ^testing.T) {
+ index := strings.index_any("aaaaaaaa.aaaaaaaa", "/:\"")
+ testing.expect(t, index == -1, "index_any should be negative")
+}
+
+@test
+test_index_any_small_string_found :: proc(t: ^testing.T) {
+ index := strings.index_any(".", "/:.\"")
+ testing.expect(t, index == 0, "index_any should be 0")
+}
+
+@test
+test_index_any_larger_string_found :: proc(t: ^testing.T) {
+ index := strings.index_any("aaaaaaaa:aaaaaaaa", "/:\"")
+ testing.expect(t, index == 8, "index_any should be 8")
+}