From b29a6c8538004233954a88282ee20ffda528cec7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Wed, 22 Jul 2020 21:13:01 +0200 Subject: [PATCH] :art: Improve string coverage --- src/lib/string.c | 14 -------------- tests/string/eq.gw | 8 ++++++++ tests/string/erase.gw | 5 +++++ 3 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 tests/string/eq.gw create mode 100644 tests/string/erase.gw diff --git a/src/lib/string.c b/src/lib/string.c index 15fedaa3..305a0b15 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -457,14 +457,6 @@ static MFUN(string_erase) { STRING(o) = s_name(insert_symbol(shred->info->vm->gwion->st, c)); } -static MFUN(string_toInt) { - *(m_uint*)RETURN = strtol(STRING(o), NULL, 10); -} - -static MFUN(string_toFloat) { - *(m_float*)RETURN = atof(STRING(o)); -} - GWION_IMPORT(string) { const Type t_string = gwi_class_ini(gwi, "string", NULL); gwi_class_xtor(gwi, string_ctor, NULL); @@ -558,12 +550,6 @@ GWION_IMPORT(string) { gwi_func_arg(gwi, "int", "length"); GWI_BB(gwi_func_end(gwi, string_erase, ae_flag_none)) - gwi_func_ini(gwi, "int", "toInt"); - GWI_BB(gwi_func_end(gwi, string_toInt, ae_flag_none)) - - gwi_func_ini(gwi, "float", "toFloat"); - GWI_BB(gwi_func_end(gwi, string_toFloat, ae_flag_none)) - GWI_BB(gwi_class_end(gwi)) GWI_BB(gwi_oper_ini(gwi, "string", "nonnull string", "nonnull string")) diff --git a/tests/string/eq.gw b/tests/string/eq.gw new file mode 100644 index 00000000..432f13e6 --- /dev/null +++ b/tests/string/eq.gw @@ -0,0 +1,8 @@ +"test" @=> string s0; +"_test" @=> string s1; + +<<< s0 == s0 >>>; +<<< s0 == s1 >>>; + +<<< s0 != s0 >>>; +<<< s0 != s1 >>>; diff --git a/tests/string/erase.gw b/tests/string/erase.gw new file mode 100644 index 00000000..5d7220b1 --- /dev/null +++ b/tests/string/erase.gw @@ -0,0 +1,5 @@ +"test test" => string s; + +s.erase(-1, 0); +s.erase(0, -1); +s.erase(1, 1); -- 2.43.0