Changeset 010a951 for tester.c


Ignore:
Timestamp:
Mar 5, 2011, 3:25:29 PM (10 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
e3a75ed
Parents:
9620c8d
git-author:
David Benjamin <davidben@mit.edu> (02/28/11 10:53:18)
git-committer:
David Benjamin <davidben@mit.edu> (03/05/11 15:25:29)
Message:
Make owl_variable's get_tostring_fn return a newly allocated string

The mess with buffer lengths and whatnot is obnoxious. Note that this
does change semantics slightly: instead of (optionally) filling a buffer
and giving a return code for good vs no-variable/invalid, we now return
NULL for missing variables and always return a string if the variable
exists. This also appears to be more accurate from the perspective of
the calls anyway.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tester.c

    rddbbcffa r010a951  
    269269  owl_vardict vd;
    270270  int numfailed=0;
    271   char buf[1024];
     271  char *value;
    272272  const void *v;
    273273
     
    277277  FAIL_UNLESS("get bool", 0==owl_variable_get_bool(&vd,"rxping"));
    278278  FAIL_UNLESS("get bool (no such)", -1==owl_variable_get_bool(&vd,"mumble"));
    279   FAIL_UNLESS("get bool as string 1", 0==owl_variable_get_tostring(&vd,"rxping", buf, 1024));
    280   FAIL_UNLESS("get bool as string 2", 0==strcmp(buf,"off"));
     279  FAIL_UNLESS("get bool as string",
     280              !strcmp((value = owl_variable_get_tostring(&vd,"rxping")), "off"));
     281  g_free(value);
    281282  FAIL_UNLESS("set bool 1", 0==owl_variable_set_bool_on(&vd,"rxping"));
    282283  FAIL_UNLESS("get bool 2", 1==owl_variable_get_bool(&vd,"rxping"));
     
    293294  FAIL_UNLESS("get int", 8==owl_variable_get_int(&vd,"typewinsize"));
    294295  FAIL_UNLESS("get int (no such)", -1==owl_variable_get_int(&vd,"mmble"));
    295   FAIL_UNLESS("get int as string 1", 0==owl_variable_get_tostring(&vd,"typewinsize", buf, 1024));
    296   FAIL_UNLESS("get int as string 2", 0==strcmp(buf,"8"));
     296  FAIL_UNLESS("get int as string",
     297              !strcmp((value = owl_variable_get_tostring(&vd,"typewinsize")), "8"));
     298  g_free(value);
    297299  FAIL_UNLESS("set int 1", 0==owl_variable_set_int(&vd,"typewinsize",12));
    298300  FAIL_UNLESS("get int 2", 12==owl_variable_get_int(&vd,"typewinsize"));
Note: See TracChangeset for help on using the changeset viewer.