Add runtime C++ test for enums.
What does not (entirely) work:
- 'extern "C"' enum declaration
- 'typedef enum {...} play_state'
- C++ class enums value definition in proxy
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13310 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
8e66df1b5a
commit
f4ebc3068d
1 changed files with 72 additions and 0 deletions
72
Examples/test-suite/c/cpp_enum_runme.c
Normal file
72
Examples/test-suite/c/cpp_enum_runme.c
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#include "cpp_basic/cpp_basic_proxy.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
|
||||
// We don't have "enum SOME_ENUM"
|
||||
int e = ENUM_ONE, *p;
|
||||
|
||||
// check the constructor's default value
|
||||
StructWithEnums *s = new_StructWithEnums();
|
||||
assert(StructWithEnums_some_enum_get(s) == ENUM_ONE);
|
||||
|
||||
// check setter
|
||||
StructWithEnums_some_enum_set(s, ENUM_TWO);
|
||||
assert(StructWithEnums_some_enum_get(s) == ENUM_TWO);
|
||||
|
||||
// check function call
|
||||
StructWithEnums_some_enum_test1(s, &e, &e, &e);
|
||||
|
||||
// check function call
|
||||
StructWithEnums_some_enum_test2(s, &e, &e, &e);
|
||||
|
||||
// check function call
|
||||
assert(StructWithEnums_enum_test3(s) == ENUM_ONE);
|
||||
|
||||
// check function call
|
||||
assert(StructWithEnums_enum_test4(s) == ENUM_TWO);
|
||||
|
||||
// check function call
|
||||
p = StructWithEnums_enum_test5(s);
|
||||
assert(*p == ENUM_TWO);
|
||||
|
||||
// check function call
|
||||
p = StructWithEnums_enum_test6(s);
|
||||
assert(*p == ENUM_TWO);
|
||||
|
||||
// check function call
|
||||
p = StructWithEnums_enum_test7(s);
|
||||
assert(*p == ENUM_TWO);
|
||||
|
||||
// check function call
|
||||
p = StructWithEnums_enum_test8(s);
|
||||
assert(*p == ENUM_TWO);
|
||||
|
||||
delete_StructWithEnums(s);
|
||||
|
||||
Foo *f = new_Foo();
|
||||
|
||||
// check the constructor's default value
|
||||
assert(Foo_hola_get(f) == Foo_Hello);
|
||||
|
||||
Foo_hola_set(f, Foo_Hi);
|
||||
assert(Foo_hola_get(f) == Foo_Hi);
|
||||
|
||||
delete_Foo(f);
|
||||
|
||||
//check C enum
|
||||
hi = Hi;
|
||||
hi = Hello;
|
||||
|
||||
// check typedef enum
|
||||
play_state t;
|
||||
|
||||
t = PLAY;
|
||||
assert(t == true);
|
||||
|
||||
t = STOP;
|
||||
assert(t == false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue