]> rtime.felk.cvut.cz Git - sysless.git/commitdiff
Add tests for space separated parameters
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 31 Jul 2013 08:29:23 +0000 (10:29 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 31 Jul 2013 08:29:23 +0000 (10:29 +0200)
libs4c/cmdproc/cmdproc_test.c

index 083cf26f1638ba7d659f0641b0088632df8ef27d..ea85d0c9f3f6c6ffdb2a937774986aff11d44ace 100644 (file)
@@ -20,6 +20,21 @@ int cmd_do_testopchar(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]
   return 0;
 }
 
+int cmd_do_spacesep(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+{
+  if (des->mode & CDESM_OPCHR) {
+    int opchar;
+    opchar=cmd_opchar_check(cmd_io,des,param);
+    if(opchar<0) return opchar;
+  }
+
+  int i;
+  for (i = 0; param[i] || (des->mode & CDESM_OPCHR && i == 1); i++)
+    printf("param[%d]=%s\n", i, param[i]);
+
+  return 0;
+}
+
 int cmd_do_testparam(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
 {
   printf(
@@ -129,6 +144,21 @@ cmd_des_t const cmd_des_error={
     "testerror","should produce an error",
     cmd_do_testerror};
 
+cmd_des_t const cmd_des_spacesep={
+    0, CDESM_SPACE_SEP,
+    "spacesep","Test for space separated parameters",
+    cmd_do_spacesep};
+
+cmd_des_t const cmd_des_spacesepop={
+    0, CDESM_SPACE_SEP|CDESM_OPCHR|CDESM_RW,
+    "spacesepop","Test for space separated parameters and an opchar",
+    cmd_do_spacesep};
+
+cmd_des_t const cmd_des_spacesepwild={
+    0, CDESM_SPACE_SEP,
+    "spacesep#","Test for space separated parameters and a wildcard",
+    cmd_do_spacesep};
+
 /* Command lists */
 
 cmd_des_t const *cmd_list_1[]={
@@ -148,6 +178,9 @@ cmd_des_t const *cmd_list_2[]={
     &cmd_des_num,
     &cmd_des_char,
     &cmd_des_charmid,
+    &cmd_des_spacesep,
+    &cmd_des_spacesepop,
+    &cmd_des_spacesepwild,
     NULL
     };