From 03a338768d748fb182e907c587aacad8225c5a8e Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Thu, 5 Nov 2020 18:00:04 +0100 Subject: [PATCH] :white_check_mark: Some string tests --- src/lib/string.c | 4 ++-- tests/string/charAt.gw | 7 +++++++ tests/string/eq.gw | 9 +++++++++ tests/string/lower.gw | 1 + tests/string/ltrim.gw | 2 ++ tests/string/rtrim.gw | 2 ++ tests/string/size.gw | 1 + tests/string/trim.gw | 2 ++ tests/string/upper.gw | 1 + 9 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 tests/string/charAt.gw create mode 100644 tests/string/lower.gw create mode 100644 tests/string/ltrim.gw create mode 100644 tests/string/rtrim.gw create mode 100644 tests/string/size.gw create mode 100644 tests/string/trim.gw create mode 100644 tests/string/upper.gw diff --git a/src/lib/string.c b/src/lib/string.c index 98422c1f..b87a31d2 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -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 index 00000000..93eb65ab --- /dev/null +++ b/tests/string/charAt.gw @@ -0,0 +1,7 @@ +<<< "".charAt(-1) >>>; +<<< "".charAt(2) >>>; +<<< " test String ".charAt(2) >>>; + +<<< "test".charAt(-1, 'c') >>>; +<<< "test".charAt(12, 'c') >>>; +<<< "test".charAt(2, 'c') >>>; diff --git a/tests/string/eq.gw b/tests/string/eq.gw index 14ace808..f2b95b86 100644 --- a/tests/string/eq.gw +++ b/tests/string/eq.gw @@ -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 index 00000000..9336a2bf --- /dev/null +++ b/tests/string/lower.gw @@ -0,0 +1 @@ +<<< "Test String".lower() >>>; diff --git a/tests/string/ltrim.gw b/tests/string/ltrim.gw new file mode 100644 index 00000000..937fcb12 --- /dev/null +++ b/tests/string/ltrim.gw @@ -0,0 +1,2 @@ +<<< "".ltrim() >>>; +<<< " test String ".ltrim() >>>; diff --git a/tests/string/rtrim.gw b/tests/string/rtrim.gw new file mode 100644 index 00000000..cf0645c0 --- /dev/null +++ b/tests/string/rtrim.gw @@ -0,0 +1,2 @@ +<<< "".rtrim() >>>; +<<< " test String ".rtrim() >>>; diff --git a/tests/string/size.gw b/tests/string/size.gw new file mode 100644 index 00000000..3f7539a9 --- /dev/null +++ b/tests/string/size.gw @@ -0,0 +1 @@ +<<< "test".size() >>>; diff --git a/tests/string/trim.gw b/tests/string/trim.gw new file mode 100644 index 00000000..32adde6e --- /dev/null +++ b/tests/string/trim.gw @@ -0,0 +1,2 @@ +<<< "".trim() >>>; +<<< " test String ".trim() >>>; diff --git a/tests/string/upper.gw b/tests/string/upper.gw new file mode 100644 index 00000000..f8081c9b --- /dev/null +++ b/tests/string/upper.gw @@ -0,0 +1 @@ +<<< "test String".upper() >>>; -- 2.43.0