Changeset 366badc for tester.c


Ignore:
Timestamp:
Feb 23, 2013, 5:44:22 PM (8 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master
Children:
f0a7c09
Parents:
bbc31e4
git-author:
David Benjamin <davidben@mit.edu> (02/21/13 16:59:23)
git-committer:
David Benjamin <davidben@mit.edu> (02/23/13 17:44:22)
Message:
Add some unit tests for enum variables

So we don't break them again.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tester.c

    r1a4508b r366badc  
    376376  FAIL_UNLESS("get int 7", 9 == owl_variable_get_int(var));
    377377
     378  FAIL_UNLESS("get enum var", NULL != (var = owl_variable_get_var(&vd, "scrollmode")));
     379  FAIL_UNLESS("get enum", OWL_SCROLLMODE_NORMAL == owl_variable_get_int(var));
     380  FAIL_UNLESS("get enum as string",
     381              !strcmp((value = owl_variable_get_tostring(var)), "normal"));
     382  g_free(value);
     383  FAIL_UNLESS("set enum 1", 0 == owl_variable_set_int(var, OWL_SCROLLMODE_TOP));
     384  FAIL_UNLESS("get enum 1", OWL_SCROLLMODE_TOP == owl_variable_get_int(var));
     385  FAIL_UNLESS("set enum 2a", -1 == owl_variable_set_int(var, -1));
     386  FAIL_UNLESS("set enum 2b", -1 == owl_variable_set_int(var, OWL_SCROLLMODE_PAGEDCENTER + 1));
     387  FAIL_UNLESS("get enum 2", OWL_SCROLLMODE_TOP == owl_variable_get_int(var));
     388  FAIL_UNLESS("set enum 3", 0 == owl_variable_set_fromstring(var, "center", 0));
     389  FAIL_UNLESS("get enum 4", OWL_SCROLLMODE_CENTER == owl_variable_get_int(var));
     390  FAIL_UNLESS("set enum 5", -1 == owl_variable_set_fromstring(var, "bogus", 0));
     391  FAIL_UNLESS("set enum 6", -1 == owl_variable_set_fromstring(var, "", 0));
     392  FAIL_UNLESS("get enum 7", OWL_SCROLLMODE_CENTER == owl_variable_get_int(var));
     393
    378394  owl_variable_dict_newvar_string(&vd, "stringvar", "testval", "", "");
    379395  FAIL_UNLESS("get new string var", NULL != (var = owl_variable_get_var(&vd, "stringvar")));
     
    401417  FAIL_UNLESS("get string (NULL) 2", NULL == (value = owl_variable_get_tostring(var)));
    402418  g_free(value);
     419
     420  owl_variable_dict_newvar_enum(&vd, "enumvar", 0, "", "", "a,b,c,d");
     421  FAIL_UNLESS("get new enum var", NULL != (var = owl_variable_get_var(&vd, "enumvar")));
     422  FAIL_UNLESS("get new enum val", 0 == owl_variable_get_int(var));
     423  owl_variable_set_fromstring(var, "c", 0);
     424  FAIL_UNLESS("update enum val", 2 == owl_variable_get_int(var));
    403425
    404426  owl_variable_dict_cleanup(&vd);
Note: See TracChangeset for help on using the changeset viewer.