]> Nishi Git Mirror - gwion.git/commitdiff
:white_check_mark: Some string tests
authorfennecdjay <fennecdjay@gwion.tk>
Thu, 5 Nov 2020 17:00:04 +0000 (18:00 +0100)
committerfennecdjay <fennecdjay@gwion.tk>
Thu, 5 Nov 2020 17:00:04 +0000 (18:00 +0100)
src/lib/string.c
tests/string/charAt.gw [new file with mode: 0644]
tests/string/eq.gw
tests/string/lower.gw [new file with mode: 0644]
tests/string/ltrim.gw [new file with mode: 0644]
tests/string/rtrim.gw [new file with mode: 0644]
tests/string/size.gw [new file with mode: 0644]
tests/string/trim.gw [new file with mode: 0644]
tests/string/upper.gw [new file with mode: 0644]

index 98422c1fbd8e5c6ff68a1f243cce28dbfb7649b6..b87a31d2e35b1144f55abbef68d22f84fb911e26 100644 (file)
@@ -483,11 +483,11 @@ GWION_IMPORT(string) {
   gwi_func_ini(gwi, "string", "trim");
   GWI_BB(gwi_func_end(gwi, string_trim, ae_flag_none))
 
-  gwi_func_ini(gwi, "int", "charAt");
+  gwi_func_ini(gwi, "char", "charAt");
   gwi_func_arg(gwi, "int", "pos");
   GWI_BB(gwi_func_end(gwi, string_charAt, ae_flag_none))
 
-  gwi_func_ini(gwi, "int", "charAt");
+  gwi_func_ini(gwi, "char", "charAt");
   gwi_func_arg(gwi, "int", "pos");
   gwi_func_arg(gwi, "char", "c");
   GWI_BB(gwi_func_end(gwi, string_setCharAt, ae_flag_none))
diff --git a/tests/string/charAt.gw b/tests/string/charAt.gw
new file mode 100644 (file)
index 0000000..93eb65a
--- /dev/null
@@ -0,0 +1,7 @@
+<<< "".charAt(-1) >>>;
+<<< "".charAt(2) >>>;
+<<< "  test String  ".charAt(2) >>>;
+
+<<< "test".charAt(-1, 'c') >>>;
+<<< "test".charAt(12, 'c') >>>;
+<<< "test".charAt(2, 'c') >>>;
index 14ace8085bdae309a0f5d9f105a3f48b15fbc849..f2b95b86ee40914980b72ec737c0f7eb0fdd88d3 100644 (file)
@@ -6,3 +6,12 @@
 
 <<< s0 != s0 >>>;
 <<< s0 != s1 >>>;
+
+<<< null == s0 >>>;
+<<< null != s0 >>>;
+
+<<< s0 == null >>>;
+<<< s0 != null >>>;
+
+<<< null == null >>>;
+<<< null != null >>>;
diff --git a/tests/string/lower.gw b/tests/string/lower.gw
new file mode 100644 (file)
index 0000000..9336a2b
--- /dev/null
@@ -0,0 +1 @@
+<<< "Test String".lower() >>>;
diff --git a/tests/string/ltrim.gw b/tests/string/ltrim.gw
new file mode 100644 (file)
index 0000000..937fcb1
--- /dev/null
@@ -0,0 +1,2 @@
+<<< "".ltrim() >>>;
+<<< "  test String  ".ltrim() >>>;
diff --git a/tests/string/rtrim.gw b/tests/string/rtrim.gw
new file mode 100644 (file)
index 0000000..cf0645c
--- /dev/null
@@ -0,0 +1,2 @@
+<<< "".rtrim() >>>;
+<<< "  test String  ".rtrim() >>>;
diff --git a/tests/string/size.gw b/tests/string/size.gw
new file mode 100644 (file)
index 0000000..3f7539a
--- /dev/null
@@ -0,0 +1 @@
+<<< "test".size() >>>;
diff --git a/tests/string/trim.gw b/tests/string/trim.gw
new file mode 100644 (file)
index 0000000..32adde6
--- /dev/null
@@ -0,0 +1,2 @@
+<<< "".trim() >>>;
+<<< "  test String  ".trim() >>>;
diff --git a/tests/string/upper.gw b/tests/string/upper.gw
new file mode 100644 (file)
index 0000000..f8081c9
--- /dev/null
@@ -0,0 +1 @@
+<<< "test String".upper() >>>;