Changeset 8bce750 for variable.c
- Timestamp:
- Aug 17, 2009, 9:52:16 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- e30ed92
- Parents:
- a2b3289
- git-author:
- Nelson Elhage <nelhage@mit.edu> (08/17/09 21:51:29)
- git-committer:
- Nelson Elhage <nelhage@mit.edu> (08/17/09 21:52:16)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
variable.c
r01ff87d r8bce750 5 5 #include <ctype.h> 6 6 #include "owl.h" 7 8 static int in_regtest = 0;9 7 10 8 #define OWLVAR_BOOL(name,default,summary,description) \ … … 434 432 int owl_variable_disable_ctrl_d_set(owl_variable *v, const void *newval) 435 433 { 436 437 if (in_regtest) return owl_variable_int_set_default(v, newval);438 439 434 if (newval && !owl_context_is_startup(owl_global_get_context(&g))) { 440 435 if (*(const int*)newval == 2) { … … 1001 996 } 1002 997 1003 1004 1005 /**************************************************************************/1006 /************************* REGRESSION TESTS *******************************/1007 /**************************************************************************/1008 1009 #ifdef OWL_INCLUDE_REG_TESTS1010 1011 #include "test.h"1012 1013 int owl_variable_regtest(void) {1014 owl_vardict vd;1015 int numfailed=0;1016 char buf[1024];1017 const void *v;1018 1019 in_regtest = 1;1020 1021 printf("# BEGIN testing owl_variable\n");1022 FAIL_UNLESS("setup", 0==owl_variable_dict_setup(&vd));1023 1024 FAIL_UNLESS("get bool", 0==owl_variable_get_bool(&vd,"rxping"));1025 FAIL_UNLESS("get bool (no such)", -1==owl_variable_get_bool(&vd,"mumble"));1026 FAIL_UNLESS("get bool as string 1", 0==owl_variable_get_tostring(&vd,"rxping", buf, 1024));1027 FAIL_UNLESS("get bool as string 2", 0==strcmp(buf,"off"));1028 FAIL_UNLESS("set bool 1", 0==owl_variable_set_bool_on(&vd,"rxping"));1029 FAIL_UNLESS("get bool 2", 1==owl_variable_get_bool(&vd,"rxping"));1030 FAIL_UNLESS("set bool 3", 0==owl_variable_set_fromstring(&vd,"rxping","off",0,0));1031 FAIL_UNLESS("get bool 4", 0==owl_variable_get_bool(&vd,"rxping"));1032 FAIL_UNLESS("set bool 5", -1==owl_variable_set_fromstring(&vd,"rxping","xxx",0,0));1033 FAIL_UNLESS("get bool 6", 0==owl_variable_get_bool(&vd,"rxping"));1034 1035 1036 FAIL_UNLESS("get string", 0==strcmp("~/zlog/people", owl_variable_get_string(&vd,"logpath")));1037 FAIL_UNLESS("set string 7", 0==owl_variable_set_string(&vd,"logpath","whee"));1038 FAIL_UNLESS("get string", 0==strcmp("whee", owl_variable_get_string(&vd,"logpath")));1039 1040 FAIL_UNLESS("get int", 8==owl_variable_get_int(&vd,"typewinsize"));1041 FAIL_UNLESS("get int (no such)", -1==owl_variable_get_int(&vd,"mmble"));1042 FAIL_UNLESS("get int as string 1", 0==owl_variable_get_tostring(&vd,"typewinsize", buf, 1024));1043 FAIL_UNLESS("get int as string 2", 0==strcmp(buf,"8"));1044 FAIL_UNLESS("set int 1", 0==owl_variable_set_int(&vd,"typewinsize",12));1045 FAIL_UNLESS("get int 2", 12==owl_variable_get_int(&vd,"typewinsize"));1046 FAIL_UNLESS("set int 1b", -1==owl_variable_set_int(&vd,"typewinsize",-3));1047 FAIL_UNLESS("get int 2b", 12==owl_variable_get_int(&vd,"typewinsize"));1048 FAIL_UNLESS("set int 3", 0==owl_variable_set_fromstring(&vd,"typewinsize","9",0,0));1049 FAIL_UNLESS("get int 4", 9==owl_variable_get_int(&vd,"typewinsize"));1050 FAIL_UNLESS("set int 5", -1==owl_variable_set_fromstring(&vd,"typewinsize","xxx",0,0));1051 FAIL_UNLESS("set int 6", -1==owl_variable_set_fromstring(&vd,"typewinsize","",0,0));1052 FAIL_UNLESS("get int 7", 9==owl_variable_get_int(&vd,"typewinsize"));1053 1054 owl_variable_dict_newvar_string(&vd, "stringvar", "", "", "testval");1055 FAIL_UNLESS("get new string var", NULL != (v = owl_variable_get(&vd, "stringvar", OWL_VARIABLE_STRING)));1056 FAIL_UNLESS("get new string val", !strcmp("testval", owl_variable_get_string(&vd, "stringvar")));1057 owl_variable_set_string(&vd, "stringvar", "new val");1058 FAIL_UNLESS("update string val", !strcmp("new val", owl_variable_get_string(&vd, "stringvar")));1059 1060 owl_variable_dict_newvar_int(&vd, "intvar", "", "", 47);1061 FAIL_UNLESS("get new int var", NULL != (v = owl_variable_get(&vd, "intvar", OWL_VARIABLE_INT)));1062 FAIL_UNLESS("get new int val", 47 == owl_variable_get_int(&vd, "intvar"));1063 owl_variable_set_int(&vd, "intvar", 17);1064 FAIL_UNLESS("update bool val", 17 == owl_variable_get_int(&vd, "intvar"));1065 1066 owl_variable_dict_newvar_bool(&vd, "boolvar", "", "", 1);1067 FAIL_UNLESS("get new bool var", NULL != (v = owl_variable_get(&vd, "boolvar", OWL_VARIABLE_BOOL)));1068 FAIL_UNLESS("get new bool val", owl_variable_get_bool(&vd, "boolvar"));1069 owl_variable_set_bool_off(&vd, "boolvar");1070 FAIL_UNLESS("update string val", !owl_variable_get_bool(&vd, "boolvar"));1071 1072 owl_variable_dict_free(&vd);1073 1074 /* if (numfailed) printf("*** WARNING: failures encountered with owl_variable\n"); */1075 printf("# END testing owl_variable (%d failures)\n", numfailed);1076 return(numfailed);1077 }1078 1079 1080 #endif /* OWL_INCLUDE_REG_TESTS */
Note: See TracChangeset
for help on using the changeset viewer.