Implement some test cases for the C backend
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13211 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c4ae9c169c
commit
f18a62f57d
6 changed files with 125 additions and 0 deletions
12
Examples/test-suite/c/abstract_access_runme.c
Normal file
12
Examples/test-suite/c/abstract_access_runme.c
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "abstract_access/abstract_access_proxy.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
int main(int argc, const char *argv[]) {
|
||||||
|
D *d = new_D();
|
||||||
|
|
||||||
|
assert(D_do_x(d) == 1);
|
||||||
|
|
||||||
|
delete_D(d);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
34
Examples/test-suite/c/abstract_change_runme.c
Normal file
34
Examples/test-suite/c/abstract_change_runme.c
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
#include "abstract_typedef2/abstract_change_proxy.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
int main(int argc, const char *argv[]) {
|
||||||
|
Base *ba = new_Base();
|
||||||
|
Derived *d = new_Derived();
|
||||||
|
Bottom *bo = new_Bottom();
|
||||||
|
|
||||||
|
assert(Base_PublicProtectedPublic1(ba) == 0);
|
||||||
|
assert(Base_PublicProtectedPublic2(ba) == 0);
|
||||||
|
assert(Base_PublicProtectedPublic3(ba) == 0);
|
||||||
|
assert(Base_PublicProtectedPublic4(ba) == 0);
|
||||||
|
|
||||||
|
assert(Derived_WasProtected1(ba) == 0);
|
||||||
|
assert(Derived_WasProtected2(ba) == 0);
|
||||||
|
assert(Derived_WasProtected3(ba) == 0);
|
||||||
|
assert(Derived_WasProtected4(ba) == 0);
|
||||||
|
|
||||||
|
assert(Bottom_PublicProtectedPublic1(ba) == 0);
|
||||||
|
assert(Bottom_PublicProtectedPublic2(ba) == 0);
|
||||||
|
assert(Bottom_PublicProtectedPublic3(ba) == 0);
|
||||||
|
assert(Bottom_PublicProtectedPublic4(ba) == 0);
|
||||||
|
|
||||||
|
assert(Bottom_WasProtected1(ba) == 0);
|
||||||
|
assert(Bottom_WasProtected2(ba) == 0);
|
||||||
|
assert(Bottom_WasProtected3(ba) == 0);
|
||||||
|
assert(Bottom_WasProtected4(ba) == 0);
|
||||||
|
|
||||||
|
delete_Base(ba);
|
||||||
|
delete_Derived(d);
|
||||||
|
delete_Bottom(bo);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
18
Examples/test-suite/c/abstract_typedef_runme.c
Normal file
18
Examples/test-suite/c/abstract_typedef_runme.c
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include "abstract_typedef/abstract_typedef_proxy.h"
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
int main(int argc, const char *argv[]) {
|
||||||
|
Engine *e = new_Engine();
|
||||||
|
PerseEngine *pe = new_PersEngine();
|
||||||
|
A *a = new_A();
|
||||||
|
|
||||||
|
assert(A_write(e) == true);
|
||||||
|
assert(A_write(pe) == true);
|
||||||
|
|
||||||
|
delete_A(a);
|
||||||
|
delete_PerseEngine(pe);
|
||||||
|
delete_Engine(e);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
18
Examples/test-suite/c/abstract_virtual_runme.c
Normal file
18
Examples/test-suite/c/abstract_virtual_runme.c
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include "abstract_virtual/abstract_virtual_proxy.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
int main(int argc, const char *argv[]) {
|
||||||
|
B *b = new_B();
|
||||||
|
D *d = new_D();
|
||||||
|
E *e = new_E();
|
||||||
|
|
||||||
|
assert(B_foo(b) == 0);
|
||||||
|
assert(D_foo(d) == 0);
|
||||||
|
assert(E_foo(e) == 0);
|
||||||
|
|
||||||
|
delete_B(b);
|
||||||
|
delete_D(b);
|
||||||
|
delete_E(b);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
14
Examples/test-suite/c/add_link_runme.c
Normal file
14
Examples/test-suite/c/add_link_runme.c
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#include "abstract_typedef2/abstract_change_proxy.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
int main(int argc, const char *argv[]) {
|
||||||
|
Foo *f = new_Foo();
|
||||||
|
Foo *f2 = Foo_blah(f);
|
||||||
|
|
||||||
|
assert(f2 != 0);
|
||||||
|
|
||||||
|
delete_Foo(f);
|
||||||
|
delete_Foo(f2);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
29
Examples/test-suite/c/anonymous_bitfield_runme.c
Normal file
29
Examples/test-suite/c/anonymous_bitfield_runme.c
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#include "abstract_typedef2/abstract_change_proxy.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
int main(int argc, const char *argv[]) {
|
||||||
|
Foo *f = new_Foo();
|
||||||
|
|
||||||
|
assert(f != 0);
|
||||||
|
|
||||||
|
Foo_x_set(f, 1);
|
||||||
|
assert(Foo_x_get(f) == 1);
|
||||||
|
assert(Foo_y_get(f) == 1);
|
||||||
|
|
||||||
|
Foo_y_set(f, 0);
|
||||||
|
assert(Foo_x_get(f) == 0);
|
||||||
|
assert(Foo_y_get(f) == 0);
|
||||||
|
|
||||||
|
Foo_f_set(f, 1);
|
||||||
|
assert(Foo_f_get(f) == 1);
|
||||||
|
|
||||||
|
Foo_z_set(f, 1);
|
||||||
|
assert(Foo_z_get(f) == 1);
|
||||||
|
|
||||||
|
Foo_seq_set(f, 1);
|
||||||
|
assert(Foo_seq_get(f) == 1);
|
||||||
|
|
||||||
|
delete_Foo(f);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue