]> Nishi Git Mirror - gwion.git/commitdiff
:art: Improve string coverage
authorJérémie Astor <astor.jeremie@wanadoo.fr>
Wed, 22 Jul 2020 19:13:01 +0000 (21:13 +0200)
committerJérémie Astor <astor.jeremie@wanadoo.fr>
Wed, 22 Jul 2020 19:13:01 +0000 (21:13 +0200)
src/lib/string.c
tests/string/eq.gw [new file with mode: 0644]
tests/string/erase.gw [new file with mode: 0644]

index 15fedaa3d1f6e5a2336c7714fc0d889c6a9c28ec..305a0b158f2f8edae8a550485e043ae4526a6827 100644 (file)
@@ -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 (file)
index 0000000..432f13e
--- /dev/null
@@ -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 (file)
index 0000000..5d7220b
--- /dev/null
@@ -0,0 +1,5 @@
+"test test" => string s;
+
+s.erase(-1, 0);
+s.erase(0, -1);
+s.erase(1, 1);