Merge pull request #9 from kichikuou/string

Add tests for #8
This commit is contained in:
Nunuhara Cabbage
2021-02-13 13:21:10 -08:00
committed by GitHub
+10
View File
@@ -95,9 +95,19 @@ void test_strings(void)
test_bool("(4.222).String(2)", (f = 4.222, f.String(2) == "4.22"), true);
// C_REF
test_equal("abあいう[3]", (s = "abあいう", s[3]), 'い');
test_equal("abc[3]", (s = "abc", s[3]), 0);
test_equal("abあいう[5]", (s = "abあいう", s[5]), 0);
test_equal("abあいう[8]", (s = "abあいう", s[8]), 0);
// This throws
// test_equal("abあいう[9]", (s = "abあいう", s[9]), 0);
// C_ASSIGN
test_string("abあいう[1] = 'c'", (s = "abあいう", s[1] = 'c', s), "acあいう");
test_string("abあいう[3] = 'あ'", (s = "abあいう", s[3] = 'あ', s), "abああう");
test_string("abあいう[1] = 'あ'", (s = "abあいう", s[1] = 'あ', s), "aああいう");
test_string("abあいう[3] = 'c'", (s = "abあいう", s[3] = 'c', s), "abあcう");
test_string("abあいう[5] = 'c'", (s = "abあいう", s[5] = 'c', s), "abあいう");
test_string("abあいう[7] = 'c'", (s = "abあいう", s[7] = 'c', s), "abあいう");
// This throws
// test_string("abあいう[8] = 'c'", (s = "abあいう", s[8] = 'c', s), "abあいう");
}