Remove wrapper aliases generation and use -namespace in the tests
The -namespace option provides a better way of using the wrapped API, so drop the optional wrapper generation, which is useless when this option is used and just generates many lines of unwanted junk in the header. Update the test suite and the examples to compensate to not rely on being able to define SWIG_DEFINE_WRAPPER_ALIASES and add -namespace option to all C++ tests, as it's done for C# test suite, and update them to use the correct prefix and also use the accessors for the global variables rather than using them directly, as this is impossible when namespace prefix is used (it would have been possible to define a preprocessor symbol corresponding to the real variable name, but it's arguably not worth it). fixup! Remove wrapper aliases generation and use -namespace in the tests
This commit is contained in:
parent
3ebf1c1769
commit
e8f9bdba80
30 changed files with 294 additions and 311 deletions
|
|
@ -104,6 +104,8 @@ include $(srcdir)/../common.mk
|
|||
# Overridden variables here
|
||||
SWIGOPT += -w524 # Suppress SWIGWARN_LANG_EXPERIMENTAL warning
|
||||
|
||||
%.cpptest: SWIGOPT += -namespace $*
|
||||
|
||||
SRCDIR = ../$(srcdir)/
|
||||
|
||||
# Rules for the different types of tests
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
#include <assert.h>
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
D *d = D_new();
|
||||
abstract_access_D *d = abstract_access_D_new();
|
||||
|
||||
assert(D_do_x(d) == 1);
|
||||
assert(abstract_access_D_do_x(d) == 1);
|
||||
|
||||
D_delete(d);
|
||||
abstract_access_D_delete(d);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
#include <assert.h>
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
Engine *e = Engine_new();
|
||||
A *a = A_new();
|
||||
abstract_typedef_Engine *e = abstract_typedef_Engine_new();
|
||||
abstract_typedef_A *a = abstract_typedef_A_new();
|
||||
|
||||
assert(AbstractBaseClass_write((AbstractBaseClass*)a, e) == true);
|
||||
assert(abstract_typedef_AbstractBaseClass_write((abstract_typedef_AbstractBaseClass*)a, e) == true);
|
||||
|
||||
A_delete(a);
|
||||
Engine_delete(e);
|
||||
abstract_typedef_A_delete(a);
|
||||
abstract_typedef_Engine_delete(e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,17 +2,17 @@
|
|||
#include <assert.h>
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
B *b = B_new();
|
||||
D *d = D_new();
|
||||
E *e = E_new();
|
||||
abstract_virtual_B *b = abstract_virtual_B_new();
|
||||
abstract_virtual_D *d = abstract_virtual_D_new();
|
||||
abstract_virtual_E *e = abstract_virtual_E_new();
|
||||
|
||||
assert(B_foo(b) == 0);
|
||||
assert(D_foo(d) == 0);
|
||||
assert(E_foo(e) == 0);
|
||||
assert(abstract_virtual_B_foo(b) == 0);
|
||||
assert(abstract_virtual_D_foo(d) == 0);
|
||||
assert(abstract_virtual_E_foo(e) == 0);
|
||||
|
||||
B_delete(b);
|
||||
D_delete(d);
|
||||
E_delete(e);
|
||||
abstract_virtual_B_delete(b);
|
||||
abstract_virtual_D_delete(d);
|
||||
abstract_virtual_E_delete(e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
#include <assert.h>
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
Foo *f = Foo_new();
|
||||
Foo *f2 = Foo_blah(f);
|
||||
add_link_Foo *f = add_link_Foo_new();
|
||||
add_link_Foo *f2 = add_link_Foo_blah(f);
|
||||
|
||||
assert(f2 != 0);
|
||||
|
||||
Foo_delete(f);
|
||||
Foo_delete(f2);
|
||||
add_link_Foo_delete(f);
|
||||
add_link_Foo_delete(f2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,28 +2,28 @@
|
|||
#include <assert.h>
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
Foo *f = Foo_new();
|
||||
anonymous_bitfield_Foo *f = anonymous_bitfield_Foo_new();
|
||||
|
||||
assert(f != 0);
|
||||
|
||||
Foo_x_set(f, 1);
|
||||
assert(Foo_x_get(f) == 1);
|
||||
assert(Foo_y_get(f) == 0);
|
||||
anonymous_bitfield_Foo_x_set(f, 1);
|
||||
assert(anonymous_bitfield_Foo_x_get(f) == 1);
|
||||
assert(anonymous_bitfield_Foo_y_get(f) == 0);
|
||||
|
||||
Foo_y_set(f, 0);
|
||||
assert(Foo_x_get(f) == 1);
|
||||
assert(Foo_y_get(f) == 0);
|
||||
anonymous_bitfield_Foo_y_set(f, 0);
|
||||
assert(anonymous_bitfield_Foo_x_get(f) == 1);
|
||||
assert(anonymous_bitfield_Foo_y_get(f) == 0);
|
||||
|
||||
Foo_f_set(f, 1);
|
||||
assert(Foo_f_get(f) == 1);
|
||||
anonymous_bitfield_Foo_f_set(f, 1);
|
||||
assert(anonymous_bitfield_Foo_f_get(f) == 1);
|
||||
|
||||
Foo_z_set(f, 1);
|
||||
assert(Foo_z_get(f) == 1);
|
||||
anonymous_bitfield_Foo_z_set(f, 1);
|
||||
assert(anonymous_bitfield_Foo_z_get(f) == 1);
|
||||
|
||||
Foo_seq_set(f, 1);
|
||||
assert(Foo_seq_get(f) == 1);
|
||||
anonymous_bitfield_Foo_seq_set(f, 1);
|
||||
assert(anonymous_bitfield_Foo_seq_get(f) == 1);
|
||||
|
||||
Foo_delete(f);
|
||||
anonymous_bitfield_Foo_delete(f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
#include <assert.h>
|
||||
|
||||
#define SWIG_DEFINE_WRAPPER_ALIASES
|
||||
#include "c_backend_cpp_exception/c_backend_cpp_exception_wrap.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(checkVal == 0);
|
||||
throwSomeKnownException();
|
||||
assert(checkVal == 1);
|
||||
throwSomeUnknownException();
|
||||
assert(checkVal == 2);
|
||||
assert(c_backend_cpp_exception_checkVal_get() == 0);
|
||||
c_backend_cpp_exception_throwSomeKnownException();
|
||||
assert(c_backend_cpp_exception_checkVal_get() == 1);
|
||||
c_backend_cpp_exception_throwSomeUnknownException();
|
||||
assert(c_backend_cpp_exception_checkVal_get() == 2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2,12 +2,11 @@
|
|||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#define SWIG_DEFINE_WRAPPER_ALIASES
|
||||
#include "c_backend_cpp_natural_std_string/c_backend_cpp_natural_std_string_wrap.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
char *myComposedString = myStringAppend("World, ", "Hello!");
|
||||
char *myComposedString = c_backend_cpp_natural_std_string_myStringAppend("World, ", "Hello!");
|
||||
|
||||
assert(myComposedString);
|
||||
assert(strcmp(myComposedString, "World, Hello!") == 0);
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
#include "cast_operator/cast_operator_wrap.h"
|
||||
|
||||
int main() {
|
||||
A *a = A_new();
|
||||
if (strcmp(A_tochar(a), "hi"))
|
||||
cast_operator_A *a = cast_operator_A_new();
|
||||
if (strcmp(cast_operator_A_tochar(a), "hi"))
|
||||
fprintf(stderr, "cast failed\n");
|
||||
A_delete(a);
|
||||
cast_operator_A_delete(a);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define SWIG_DEFINE_WRAPPER_ALIASES
|
||||
#include "char_strings/char_strings_wrap.h"
|
||||
|
||||
int main() {
|
||||
|
|
@ -14,25 +13,25 @@ int main() {
|
|||
|
||||
// get functions
|
||||
for (i=0; i<count; i++) {
|
||||
char *str = GetCharHeapString();
|
||||
char *str = char_strings_GetCharHeapString();
|
||||
if (strcmp(str, CPLUSPLUS_MSG) != 0) {
|
||||
fprintf(stderr, "Test char get 1 failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
}
|
||||
DeleteCharHeapString();
|
||||
char_strings_DeleteCharHeapString();
|
||||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
const char *str = GetConstCharProgramCodeString();
|
||||
const char *str = char_strings_GetConstCharProgramCodeString();
|
||||
if (strcmp(str, CPLUSPLUS_MSG) != 0) {
|
||||
fprintf(stderr, "Test char get 2 failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
}
|
||||
DeleteCharHeapString();
|
||||
char_strings_DeleteCharHeapString();
|
||||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
char *str = GetCharStaticString();
|
||||
char *str = char_strings_GetCharStaticString();
|
||||
if (strcmp(str, CPLUSPLUS_MSG) != 0) {
|
||||
fprintf(stderr, "Test char get 3 failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
|
|
@ -40,7 +39,7 @@ int main() {
|
|||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
char *str = GetCharStaticStringFixed();
|
||||
char *str = char_strings_GetCharStaticStringFixed();
|
||||
if (strcmp(str, CPLUSPLUS_MSG) != 0) {
|
||||
fprintf(stderr, "Test char get 4 failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
|
|
@ -48,7 +47,7 @@ int main() {
|
|||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
const char *str = GetConstCharStaticStringFixed();
|
||||
const char *str = char_strings_GetConstCharStaticStringFixed();
|
||||
if (strcmp(str, CPLUSPLUS_MSG) != 0) {
|
||||
fprintf(stderr, "Test char get 5 failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
|
|
@ -59,7 +58,7 @@ int main() {
|
|||
for (i=0; i<count; i++) {
|
||||
char str[256];
|
||||
sprintf(str, "%s%d", OTHERLAND_MSG, i);
|
||||
if (!SetCharHeapString(str, i)) {
|
||||
if (!char_strings_SetCharHeapString(str, i)) {
|
||||
fprintf(stderr, "Test char set 1 failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -69,7 +68,7 @@ int main() {
|
|||
for (i=0; i<count; i++) {
|
||||
char str[256];
|
||||
sprintf(str, "%s%d", OTHERLAND_MSG, i);
|
||||
if (!SetCharStaticString(str, i)) {
|
||||
if (!char_strings_SetCharStaticString(str, i)) {
|
||||
fprintf(stderr, "Test char set 2 failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -78,7 +77,7 @@ int main() {
|
|||
for (i=0; i<count; i++) {
|
||||
char str[256];
|
||||
sprintf(str, "%s%d", OTHERLAND_MSG, i);
|
||||
if (!SetCharArrayStaticString(str, i)) {
|
||||
if (!char_strings_SetCharArrayStaticString(str, i)) {
|
||||
fprintf(stderr, "Test char set 3 failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -87,7 +86,7 @@ int main() {
|
|||
for (i=0; i<count; i++) {
|
||||
char str[256];
|
||||
sprintf(str, "%s%d", OTHERLAND_MSG, i);
|
||||
if (!SetConstCharHeapString(str, i)) {
|
||||
if (!char_strings_SetConstCharHeapString(str, i)) {
|
||||
fprintf(stderr, "Test char set 4 failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -96,7 +95,7 @@ int main() {
|
|||
for (i=0; i<count; i++) {
|
||||
char str[256];
|
||||
sprintf(str, "%s%d", OTHERLAND_MSG, i);
|
||||
if (!SetConstCharStaticString(str, i)) {
|
||||
if (!char_strings_SetConstCharStaticString(str, i)) {
|
||||
fprintf(stderr, "Test char set 5 failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -105,7 +104,7 @@ int main() {
|
|||
for (i=0; i<count; i++) {
|
||||
char str[256];
|
||||
sprintf(str, "%s%d", OTHERLAND_MSG, i);
|
||||
if (!SetConstCharArrayStaticString(str, i)) {
|
||||
if (!char_strings_SetConstCharArrayStaticString(str, i)) {
|
||||
fprintf(stderr, "Test char set 6 failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -115,7 +114,7 @@ int main() {
|
|||
for (i=0; i<count; i++) {
|
||||
char ping[256];
|
||||
sprintf(ping, "%s%d", OTHERLAND_MSG, i);
|
||||
char *pong = CharPingPong(ping);
|
||||
char *pong = char_strings_CharPingPong(ping);
|
||||
if (strcmp(ping, pong) != 0) {
|
||||
fprintf(stderr, "Test PingPong 1 failed.\nExpected:%d\nReceived:%d\n", ping, pong);
|
||||
exit(1);
|
||||
|
|
@ -127,8 +126,8 @@ int main() {
|
|||
for (i=0; i<count; i++) {
|
||||
char str[256];
|
||||
sprintf(str, "%s%d", OTHERLAND_MSG, i);
|
||||
global_char = str;
|
||||
if (strcmp(global_char, str) != 0) {
|
||||
char_strings_global_char_set(str);
|
||||
if (strcmp(char_strings_global_char_get(), str) != 0) {
|
||||
fprintf(stderr, "Test variables 1 failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -137,8 +136,8 @@ int main() {
|
|||
for (i=0; i<count; i++) {
|
||||
char str[256];
|
||||
sprintf(str, "%s%d", OTHERLAND_MSG, i);
|
||||
sprintf(global_char_array1, "%s%d", OTHERLAND_MSG, i);
|
||||
if (strcmp(global_char_array1, str) != 0) {
|
||||
sprintf(char_strings_global_char_array1_get(), "%s%d", OTHERLAND_MSG, i);
|
||||
if (strcmp(char_strings_global_char_array1_get(), str) != 0) {
|
||||
fprintf(stderr, "Test variables 2 failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -147,15 +146,15 @@ int main() {
|
|||
for (i=0; i<count; i++) {
|
||||
char str[256];
|
||||
sprintf(str, "%s%d", OTHERLAND_MSG, i);
|
||||
sprintf(global_char_array2, "%s%d", OTHERLAND_MSG, i);
|
||||
if (strcmp(global_char_array2, str) != 0) {
|
||||
sprintf(char_strings_global_char_array2_get(), "%s%d", OTHERLAND_MSG, i);
|
||||
if (strcmp(char_strings_global_char_array2_get(), str) != 0) {
|
||||
fprintf(stderr, "Test variables 3 failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
if (strcmp(global_const_char, CPLUSPLUS_MSG) != 0) {
|
||||
if (strcmp(char_strings_global_const_char_get(), CPLUSPLUS_MSG) != 0) {
|
||||
fprintf(stderr, "Test variables 3 failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -180,7 +179,7 @@ int main() {
|
|||
// char *& tests
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
const char **str = GetConstCharPointerRef();
|
||||
const char **str = char_strings_GetConstCharPointerRef();
|
||||
if (strcmp(*str, CPLUSPLUS_MSG) != 0) {
|
||||
fprintf(stderr, "Test char pointer ref get failed, iteration %d\n",i);
|
||||
exit(1);
|
||||
|
|
@ -190,7 +189,7 @@ int main() {
|
|||
for (i=0; i<count; i++) {
|
||||
char *str = (char*) malloc(sizeof(char) * 256);
|
||||
sprintf(str, "%s%d", OTHERLAND_MSG, i);
|
||||
if (!SetConstCharPointerRef((const char **)&str, i)) {
|
||||
if (!char_strings_SetConstCharPointerRef((const char **)&str, i)) {
|
||||
fprintf(stderr, "Test char pointer ref set failed, iteration %d\n", i);
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,15 +2,15 @@
|
|||
#include <assert.h>
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
Foo* f;
|
||||
Foo* f2;
|
||||
cpp11_shared_ptr_const_Foo* f;
|
||||
cpp11_shared_ptr_const_Foo* f2;
|
||||
|
||||
f = Foo_new(17);
|
||||
assert(Foo_get_m(f) == 17);
|
||||
f = cpp11_shared_ptr_const_Foo_new(17);
|
||||
assert(cpp11_shared_ptr_const_Foo_get_m(f) == 17);
|
||||
f2 = cpp11_shared_ptr_const_foo(f);
|
||||
assert(Foo_get_m(f2) == 17);
|
||||
Foo_delete(f2);
|
||||
Foo_delete(f);
|
||||
assert(cpp11_shared_ptr_const_Foo_get_m(f2) == 17);
|
||||
cpp11_shared_ptr_const_Foo_delete(f2);
|
||||
cpp11_shared_ptr_const_Foo_delete(f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,23 +3,23 @@
|
|||
|
||||
int main(int argc, const char *argv[]) {
|
||||
{
|
||||
Derived* d;
|
||||
cpp11_shared_ptr_upcast_Derived* d;
|
||||
|
||||
d = Derived_new_i(17);
|
||||
assert( cpp11_shared_ptr_upcast_base_num1((Base *)d) == -1 );
|
||||
d = cpp11_shared_ptr_upcast_Derived_new_i(17);
|
||||
assert( cpp11_shared_ptr_upcast_base_num1((cpp11_shared_ptr_upcast_Base *)d) == -1 );
|
||||
assert( cpp11_shared_ptr_upcast_derived_num1(d) == 17 );
|
||||
|
||||
Derived_delete(d);
|
||||
cpp11_shared_ptr_upcast_Derived_delete(d);
|
||||
}
|
||||
|
||||
{
|
||||
Derived2* d2;
|
||||
cpp11_shared_ptr_upcast_Derived2* d2;
|
||||
|
||||
d2 = Derived2_new_i(289);
|
||||
assert( cpp11_shared_ptr_upcast_base2_num1((Base2 *)d2) == -1 );
|
||||
d2 = cpp11_shared_ptr_upcast_Derived2_new_i(289);
|
||||
assert( cpp11_shared_ptr_upcast_base2_num1((cpp11_shared_ptr_upcast_Base2 *)d2) == -1 );
|
||||
assert( cpp11_shared_ptr_upcast_derived2_num1(d2) == 289 );
|
||||
|
||||
Derived2_delete(d2);
|
||||
cpp11_shared_ptr_upcast_Derived2_delete(d2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
#define SWIG_DEFINE_WRAPPER_ALIASES
|
||||
#include "cpp_basic/cpp_basic_wrap.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
Foo *f = Foo_new(5);
|
||||
cpp_basic_Foo *f = cpp_basic_Foo_new(5);
|
||||
|
||||
// test global static variables
|
||||
// TODO: Implement or document as not available
|
||||
|
|
@ -12,98 +11,98 @@ int main(int argc, const char *argv[]) {
|
|||
assert(init_ref != 0);
|
||||
|
||||
global_fptr_set(f);
|
||||
assert(Foo_num_get(global_fptr_get()) == 5);
|
||||
assert(cpp_basic_Foo_num_get(global_fptr_get()) == 5);
|
||||
|
||||
assert(Foo_num_get(global_fref_get()) == -4);
|
||||
Foo_num_set(f, 6);
|
||||
assert(cpp_basic_Foo_num_get(global_fref_get()) == -4);
|
||||
cpp_basic_Foo_num_set(f, 6);
|
||||
global_fref_set(f);
|
||||
assert(Foo_num_get(global_fref_get()) == 6);
|
||||
assert(cpp_basic_Foo_num_get(global_fref_get()) == 6);
|
||||
|
||||
Foo_num_set(f, 7);
|
||||
cpp_basic_Foo_num_set(f, 7);
|
||||
global_fval_set(f);
|
||||
assert(Foo_num_get(global_fval_get()) == 7);
|
||||
assert(cpp_basic_Foo_num_get(global_fval_get()) == 7);
|
||||
*/
|
||||
|
||||
Foo_num_set(f, 5);
|
||||
assert(Foo_num_get(f) == 5);
|
||||
assert(Foo_func1(f, 2) == 20);
|
||||
assert(Foo_func2(f, 2) == -10);
|
||||
cpp_basic_Foo_num_set(f, 5);
|
||||
assert(cpp_basic_Foo_num_get(f) == 5);
|
||||
assert(cpp_basic_Foo_func1(f, 2) == 20);
|
||||
assert(cpp_basic_Foo_func2(f, 2) == -10);
|
||||
|
||||
// function pointer set/get tests are missing
|
||||
// because of unclear implementation details
|
||||
//foo_func_ptr_set(f, &Foo_func1);
|
||||
//foo_func_ptr_set(f, &cpp_basic_Foo_func1);
|
||||
|
||||
// test of global static variable is missing
|
||||
// because of unclear implementation details
|
||||
//assert(c_init_ref != 0);
|
||||
|
||||
Bar *b = Bar_new();
|
||||
cpp_basic_Bar *b = cpp_basic_Bar_new();
|
||||
|
||||
// check default value set by constructor
|
||||
assert(Bar_cint_get(b) == 3);
|
||||
assert(cpp_basic_Bar_cint_get(b) == 3);
|
||||
|
||||
// check default value set by Bar initializer
|
||||
assert(Foo_num_get(Bar_fval_get(b)) == 15);
|
||||
// check default value set by cpp_basic_Bar initializer
|
||||
assert(cpp_basic_Foo_num_get(cpp_basic_Bar_fval_get(b)) == 15);
|
||||
// change, recheck
|
||||
Foo_num_set(Bar_fval_get(b), 2);
|
||||
assert(Foo_num_get(Bar_fval_get(b)) == 2);
|
||||
cpp_basic_Foo_num_set(cpp_basic_Bar_fval_get(b), 2);
|
||||
assert(cpp_basic_Foo_num_get(cpp_basic_Bar_fval_get(b)) == 2);
|
||||
|
||||
// check references
|
||||
assert(Bar_fref_get(b) != 0);
|
||||
assert(cpp_basic_Bar_fref_get(b) != 0);
|
||||
|
||||
// check global static value and references
|
||||
assert(Foo_num_get(Bar_fref_get(b)) == -4);
|
||||
Foo_num_set(Bar_fref_get(b), 1);
|
||||
assert(Foo_num_get(Bar_fref_get(b)) == 1);
|
||||
// create new Bar instance and check static member value
|
||||
Bar *b2 = Bar_new();
|
||||
assert(Foo_num_get(Bar_fref_get(b2)) == 1);
|
||||
Bar_delete(b2);
|
||||
assert(cpp_basic_Foo_num_get(cpp_basic_Bar_fref_get(b)) == -4);
|
||||
cpp_basic_Foo_num_set(cpp_basic_Bar_fref_get(b), 1);
|
||||
assert(cpp_basic_Foo_num_get(cpp_basic_Bar_fref_get(b)) == 1);
|
||||
// create new cpp_basic_Bar instance and check static member value
|
||||
cpp_basic_Bar *b2 = cpp_basic_Bar_new();
|
||||
assert(cpp_basic_Foo_num_get(cpp_basic_Bar_fref_get(b2)) == 1);
|
||||
cpp_basic_Bar_delete(b2);
|
||||
b2 = 0;
|
||||
|
||||
// Try to set a pointer
|
||||
Bar_fptr_set(b, f);
|
||||
cpp_basic_Bar_fptr_set(b, f);
|
||||
|
||||
assert(Bar_test(b, 2, f) == 9);
|
||||
assert(Bar_test(b, 2, 0) == 4);
|
||||
assert(cpp_basic_Bar_test(b, 2, f) == 9);
|
||||
assert(cpp_basic_Bar_test(b, 2, 0) == 4);
|
||||
|
||||
Foo *f2 = Bar_testFoo(b, 2, f);
|
||||
assert(Foo_num_get(f2) == 11);
|
||||
Foo_delete(f2);
|
||||
cpp_basic_Foo *f2 = cpp_basic_Bar_testFoo(b, 2, f);
|
||||
assert(cpp_basic_Foo_num_get(f2) == 11);
|
||||
cpp_basic_Foo_delete(f2);
|
||||
f2 = 0;
|
||||
|
||||
// test static variables
|
||||
Bar_global_fptr_set(f);
|
||||
assert(Foo_num_get(Bar_global_fptr_get()) == 5);
|
||||
cpp_basic_Bar_global_fptr_set(f);
|
||||
assert(cpp_basic_Foo_num_get(cpp_basic_Bar_global_fptr_get()) == 5);
|
||||
|
||||
Foo_num_set(f, 6);
|
||||
Bar_global_fref_set(f);
|
||||
assert(Foo_num_get(Bar_global_fref_get()) == 6);
|
||||
cpp_basic_Foo_num_set(f, 6);
|
||||
cpp_basic_Bar_global_fref_set(f);
|
||||
assert(cpp_basic_Foo_num_get(cpp_basic_Bar_global_fref_get()) == 6);
|
||||
|
||||
Foo_num_set(f, 7);
|
||||
Bar_global_fval_set(f);
|
||||
assert(Foo_num_get(Bar_global_fval_get()) == 7);
|
||||
cpp_basic_Foo_num_set(f, 7);
|
||||
cpp_basic_Bar_global_fval_set(f);
|
||||
assert(cpp_basic_Foo_num_get(cpp_basic_Bar_global_fval_get()) == 7);
|
||||
|
||||
// getting, setting and calling function pointers isn't supported yet
|
||||
#if 0
|
||||
SomeTypeForMemFnPtr func1 = get_func1_ptr();
|
||||
Foo_func_ptr_set(f, func1);
|
||||
cpp_basic_Foo_func_ptr_set(f, func1);
|
||||
assert(test_func_ptr(f, 2) == 28);
|
||||
SomeTypeForMemFnPtr func2 = get_func2_ptr();
|
||||
Foo_func_ptr_set(f, func2);
|
||||
cpp_basic_Foo_func_ptr_set(f, func2);
|
||||
assert(test_func_ptr(f, 2) == -14);
|
||||
#endif
|
||||
|
||||
Bar_delete(b);
|
||||
Foo_delete(f);
|
||||
cpp_basic_Bar_delete(b);
|
||||
cpp_basic_Foo_delete(f);
|
||||
|
||||
Fl_Window *w = Fl_Window_new();
|
||||
cpp_basic_Fl_Window *w = cpp_basic_Fl_Window_new();
|
||||
// Test whether macro worked for code extension
|
||||
// and test optional function parameters
|
||||
Fl_Window_show(w);
|
||||
Fl_Window_show_pv(w, 0);
|
||||
Fl_Window_show_pv_pv(w, 0, 0);
|
||||
Fl_Window_delete(w);
|
||||
cpp_basic_Fl_Window_show(w);
|
||||
cpp_basic_Fl_Window_show_pv(w, 0);
|
||||
cpp_basic_Fl_Window_show_pv_pv(w, 0, 0);
|
||||
cpp_basic_Fl_Window_delete(w);
|
||||
w = 0;
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -5,67 +5,67 @@
|
|||
int main(int argc, const char *argv[]) {
|
||||
|
||||
// We don't have "enum SOME_ENUM"
|
||||
int e = ENUM_ONE, *p;
|
||||
int e = cpp_enum_ENUM_ONE, *p;
|
||||
|
||||
// check the constructor's default value
|
||||
StructWithEnums *s = StructWithEnums_new();
|
||||
assert(StructWithEnums_some_enum_get(s) == ENUM_ONE);
|
||||
cpp_enum_StructWithEnums *s = cpp_enum_StructWithEnums_new();
|
||||
assert(cpp_enum_StructWithEnums_some_enum_get(s) == cpp_enum_ENUM_ONE);
|
||||
|
||||
// check setter
|
||||
StructWithEnums_some_enum_set(s, ENUM_TWO);
|
||||
assert(StructWithEnums_some_enum_get(s) == ENUM_TWO);
|
||||
cpp_enum_StructWithEnums_some_enum_set(s, cpp_enum_ENUM_TWO);
|
||||
assert(cpp_enum_StructWithEnums_some_enum_get(s) == cpp_enum_ENUM_TWO);
|
||||
|
||||
// check function call
|
||||
StructWithEnums_enum_test1(s, e, &e, &e);
|
||||
cpp_enum_StructWithEnums_enum_test1(s, e, &e, &e);
|
||||
|
||||
// check function call
|
||||
StructWithEnums_enum_test2(s, e, &e, &e);
|
||||
cpp_enum_StructWithEnums_enum_test2(s, e, &e, &e);
|
||||
|
||||
// check function call
|
||||
assert(StructWithEnums_enum_test3(s) == ENUM_ONE);
|
||||
assert(cpp_enum_StructWithEnums_enum_test3(s) == cpp_enum_ENUM_ONE);
|
||||
|
||||
// check function call
|
||||
assert(StructWithEnums_enum_test4(s) == ENUM_TWO);
|
||||
assert(cpp_enum_StructWithEnums_enum_test4(s) == cpp_enum_ENUM_TWO);
|
||||
|
||||
// check function call
|
||||
p = StructWithEnums_enum_test5(s);
|
||||
assert(*p == ENUM_TWO);
|
||||
p = cpp_enum_StructWithEnums_enum_test5(s);
|
||||
assert(*p == cpp_enum_ENUM_TWO);
|
||||
|
||||
// check function call
|
||||
p = StructWithEnums_enum_test6(s);
|
||||
assert(*p == ENUM_TWO);
|
||||
p = cpp_enum_StructWithEnums_enum_test6(s);
|
||||
assert(*p == cpp_enum_ENUM_TWO);
|
||||
|
||||
// check function call
|
||||
p = StructWithEnums_enum_test7(s);
|
||||
assert(*p == ENUM_TWO);
|
||||
p = cpp_enum_StructWithEnums_enum_test7(s);
|
||||
assert(*p == cpp_enum_ENUM_TWO);
|
||||
|
||||
// check function call
|
||||
p = StructWithEnums_enum_test8(s);
|
||||
assert(*p == ENUM_TWO);
|
||||
p = cpp_enum_StructWithEnums_enum_test8(s);
|
||||
assert(*p == cpp_enum_ENUM_TWO);
|
||||
|
||||
StructWithEnums_delete(s);
|
||||
cpp_enum_StructWithEnums_delete(s);
|
||||
|
||||
Foo *f = Foo_new();
|
||||
cpp_enum_Foo *f = cpp_enum_Foo_new();
|
||||
|
||||
// check the constructor's default value
|
||||
assert(Foo_hola_get(f) == Foo_Hello);
|
||||
assert(cpp_enum_Foo_hola_get(f) == cpp_enum_Foo_Hello);
|
||||
|
||||
Foo_hola_set(f, Foo_Hi);
|
||||
assert(Foo_hola_get(f) == Foo_Hi);
|
||||
cpp_enum_Foo_hola_set(f, cpp_enum_Foo_Hi);
|
||||
assert(cpp_enum_Foo_hola_get(f) == cpp_enum_Foo_Hi);
|
||||
|
||||
Foo_delete(f);
|
||||
cpp_enum_Foo_delete(f);
|
||||
|
||||
//check C enum
|
||||
hi = Hi;
|
||||
hi = Hello;
|
||||
cpp_enum_hi_set(cpp_enum_Hi);
|
||||
cpp_enum_hi_set(cpp_enum_Hello);
|
||||
|
||||
// check typedef enum
|
||||
play_state t;
|
||||
cpp_enum_play_state t;
|
||||
|
||||
t = PLAY;
|
||||
t = cpp_enum_PLAY;
|
||||
assert(t == 1);
|
||||
|
||||
t = STOP;
|
||||
t = cpp_enum_STOP;
|
||||
assert(t == 0);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
#include "enum_rename/enum_rename_wrap.h"
|
||||
|
||||
int main() {
|
||||
assert(M_Jan == 0);
|
||||
assert(May == 1);
|
||||
assert(M_Dec == 2);
|
||||
assert(enum_rename_M_Jan == 0);
|
||||
assert(enum_rename_May == 1);
|
||||
assert(enum_rename_M_Dec == 2);
|
||||
|
||||
assert(S_Can == 1);
|
||||
assert(S_Must == 2);
|
||||
assert(enum_rename_S_Can == 1);
|
||||
assert(enum_rename_S_Must == 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define SWIG_DEFINE_WRAPPER_ALIASES
|
||||
#include "enums/enums_wrap.h"
|
||||
|
||||
int main() {
|
||||
assert(GlobalInstance == globalinstance1);
|
||||
assert(iFoo_Char == 'a');
|
||||
bar2(1);
|
||||
bar3(1);
|
||||
bar1(1);
|
||||
enums_bar2(1);
|
||||
enums_bar3(1);
|
||||
enums_bar1(1);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,45 +1,44 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define SWIG_DEFINE_WRAPPER_ALIASES
|
||||
#include "exception_order/exception_order_wrap.h"
|
||||
|
||||
int main() {
|
||||
A* a = A_new();
|
||||
exception_order_A* a = exception_order_A_new();
|
||||
|
||||
A_foo(a);
|
||||
if (!SWIG_PendingException_get()) {
|
||||
exception_order_A_foo(a);
|
||||
if (!exception_order_SWIG_PendingException_get()) {
|
||||
fprintf(stderr, "foo: bad exception order\n");
|
||||
} else {
|
||||
SWIG_PendingException_reset();
|
||||
exception_order_SWIG_PendingException_reset();
|
||||
}
|
||||
|
||||
A_bar(a);
|
||||
if (!SWIG_PendingException_get()) {
|
||||
exception_order_A_bar(a);
|
||||
if (!exception_order_SWIG_PendingException_get()) {
|
||||
fprintf(stderr, "bar: bad exception order\n");
|
||||
} else {
|
||||
SWIG_PendingException_reset();
|
||||
exception_order_SWIG_PendingException_reset();
|
||||
}
|
||||
|
||||
A_foobar(a);
|
||||
if (!SWIG_PendingException_get()) {
|
||||
exception_order_A_foobar(a);
|
||||
if (!exception_order_SWIG_PendingException_get()) {
|
||||
fprintf(stderr, "foobar: bad exception order\n");
|
||||
} else {
|
||||
SWIG_PendingException_reset();
|
||||
exception_order_SWIG_PendingException_reset();
|
||||
}
|
||||
|
||||
A_barfoo(a, 1);
|
||||
if (!SWIG_PendingException_get()) {
|
||||
exception_order_A_barfoo(a, 1);
|
||||
if (!exception_order_SWIG_PendingException_get()) {
|
||||
fprintf(stderr, "barfoo(1): bad exception order\n");
|
||||
} else {
|
||||
SWIG_PendingException_reset();
|
||||
exception_order_SWIG_PendingException_reset();
|
||||
}
|
||||
|
||||
A_barfoo(a, 2);
|
||||
if (!SWIG_PendingException_get()) {
|
||||
exception_order_A_barfoo(a, 2);
|
||||
if (!exception_order_SWIG_PendingException_get()) {
|
||||
fprintf(stderr, "barfoo(2): bad exception order\n");
|
||||
} else {
|
||||
SWIG_PendingException_reset();
|
||||
exception_order_SWIG_PendingException_reset();
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ int main(int argc, const char *argv[])
|
|||
{
|
||||
global_vars_init();
|
||||
|
||||
assert(strcmp(b_get(), "string b") == 0);
|
||||
assert(x == 1234);
|
||||
assert(strcmp(global_vars_b_get(), "string b") == 0);
|
||||
assert(global_vars_x_get() == 1234);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
|
||||
int main(int argc, const char *argv[]) {
|
||||
{
|
||||
Klass* k = Klass_new_rcstd_string("me oh my");
|
||||
assert( strcmp(Klass_getValue(k), "me oh my") == 0 );
|
||||
Klass_delete(k);
|
||||
li_boost_shared_ptr_Klass* k = li_boost_shared_ptr_Klass_new_rcstd_string("me oh my");
|
||||
assert( strcmp(li_boost_shared_ptr_Klass_getValue(k), "me oh my") == 0 );
|
||||
li_boost_shared_ptr_Klass_delete(k);
|
||||
}
|
||||
|
||||
{
|
||||
Klass* k = li_boost_shared_ptr_factorycreate();
|
||||
assert( strcmp(Klass_getValue(k), "factorycreate") == 0 );
|
||||
Klass_delete(k);
|
||||
li_boost_shared_ptr_Klass* k = li_boost_shared_ptr_factorycreate();
|
||||
assert( strcmp(li_boost_shared_ptr_Klass_getValue(k), "factorycreate") == 0 );
|
||||
li_boost_shared_ptr_Klass_delete(k);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,25 +2,25 @@
|
|||
#include <assert.h>
|
||||
|
||||
int main() {
|
||||
A* a1 = A_new_i(3);
|
||||
A* a2 = A_new_i(7);
|
||||
li_std_map_A* a1 = li_std_map_A_new_i(3);
|
||||
li_std_map_A* a2 = li_std_map_A_new_i(7);
|
||||
|
||||
mapA* mA = mapA_new();
|
||||
mapA_set(mA, 1, a1);
|
||||
mapA_set(mA, 2, a2);
|
||||
li_std_map_mapA* mA = li_std_map_mapA_new();
|
||||
li_std_map_mapA_set(mA, 1, a1);
|
||||
li_std_map_mapA_set(mA, 2, a2);
|
||||
|
||||
assert( mapA_size(mA) == 2 );
|
||||
assert( li_std_map_mapA_size(mA) == 2 );
|
||||
|
||||
{
|
||||
A* a = mapA_get(mA, 1);
|
||||
assert( A_val_get(a) == 3 );
|
||||
li_std_map_A* a = li_std_map_mapA_get(mA, 1);
|
||||
assert( li_std_map_A_val_get(a) == 3 );
|
||||
}
|
||||
|
||||
assert( !mapA_has_key(mA, 3) );
|
||||
assert( !li_std_map_mapA_has_key(mA, 3) );
|
||||
|
||||
mapA_delete(mA);
|
||||
A_delete(a2);
|
||||
A_delete(a1);
|
||||
li_std_map_mapA_delete(mA);
|
||||
li_std_map_A_delete(a2);
|
||||
li_std_map_A_delete(a1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,43 +1,42 @@
|
|||
#define SWIG_DEFINE_WRAPPER_ALIASES
|
||||
#include "li_std_pair/li_std_pair_wrap.h"
|
||||
#include <assert.h>
|
||||
|
||||
int main() {
|
||||
{
|
||||
IntPair* intPair = makeIntPair(7, 6);
|
||||
assert(IntPair_first_get(intPair)==7 && IntPair_second_get(intPair)==6);
|
||||
li_std_pair_IntPair* intPair = li_std_pair_makeIntPair(7, 6);
|
||||
assert(li_std_pair_IntPair_first_get(intPair)==7 && li_std_pair_IntPair_second_get(intPair)==6);
|
||||
|
||||
assert(product1(intPair) == 42);
|
||||
assert(product2(intPair) == 42);
|
||||
assert(product3(intPair) == 42);
|
||||
assert(li_std_pair_product1(intPair) == 42);
|
||||
assert(li_std_pair_product2(intPair) == 42);
|
||||
assert(li_std_pair_product3(intPair) == 42);
|
||||
|
||||
IntPair_delete(intPair);
|
||||
li_std_pair_IntPair_delete(intPair);
|
||||
}
|
||||
|
||||
{
|
||||
IntPair* intPairPtr = makeIntPairPtr(7, 6);
|
||||
assert(IntPair_first_get(intPairPtr)==7 && IntPair_second_get(intPairPtr)==6);
|
||||
li_std_pair_IntPair* intPairPtr = li_std_pair_makeIntPairPtr(7, 6);
|
||||
assert(li_std_pair_IntPair_first_get(intPairPtr)==7 && li_std_pair_IntPair_second_get(intPairPtr)==6);
|
||||
|
||||
assert(product1(intPairPtr) == 42);
|
||||
assert(product2(intPairPtr) == 42);
|
||||
assert(product3(intPairPtr) == 42);
|
||||
assert(li_std_pair_product1(intPairPtr) == 42);
|
||||
assert(li_std_pair_product2(intPairPtr) == 42);
|
||||
assert(li_std_pair_product3(intPairPtr) == 42);
|
||||
}
|
||||
|
||||
{
|
||||
IntPair* intPairRef = makeIntPairRef(7, 6);
|
||||
assert(IntPair_first_get(intPairRef)==7 && IntPair_second_get(intPairRef)==6);
|
||||
li_std_pair_IntPair* intPairRef = li_std_pair_makeIntPairRef(7, 6);
|
||||
assert(li_std_pair_IntPair_first_get(intPairRef)==7 && li_std_pair_IntPair_second_get(intPairRef)==6);
|
||||
|
||||
assert(product1(intPairRef) == 42);
|
||||
assert(product2(intPairRef) == 42);
|
||||
assert(product3(intPairRef) == 42);
|
||||
assert(li_std_pair_product1(intPairRef) == 42);
|
||||
assert(li_std_pair_product2(intPairRef) == 42);
|
||||
assert(li_std_pair_product3(intPairRef) == 42);
|
||||
}
|
||||
|
||||
{
|
||||
IntPair* intPairConstRef = makeIntPairConstRef(7, 6);
|
||||
assert(IntPair_first_get(intPairConstRef)==7 && IntPair_second_get(intPairConstRef)==6);
|
||||
li_std_pair_IntPair* intPairConstRef = li_std_pair_makeIntPairConstRef(7, 6);
|
||||
assert(li_std_pair_IntPair_first_get(intPairConstRef)==7 && li_std_pair_IntPair_second_get(intPairConstRef)==6);
|
||||
|
||||
assert(product1(intPairConstRef) == 42);
|
||||
assert(product2(intPairConstRef) == 42);
|
||||
assert(product3(intPairConstRef) == 42);
|
||||
assert(li_std_pair_product1(intPairConstRef) == 42);
|
||||
assert(li_std_pair_product2(intPairConstRef) == 42);
|
||||
assert(li_std_pair_product3(intPairConstRef) == 42);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,30 +3,30 @@
|
|||
|
||||
int main() {
|
||||
{
|
||||
IntSet* is = IntSet_new();
|
||||
li_std_set_IntSet* is = li_std_set_IntSet_new();
|
||||
|
||||
IntSet_add(is, 1);
|
||||
IntSet_add(is, 4);
|
||||
IntSet_add(is, 9);
|
||||
li_std_set_IntSet_add(is, 1);
|
||||
li_std_set_IntSet_add(is, 4);
|
||||
li_std_set_IntSet_add(is, 9);
|
||||
|
||||
assert( IntSet_size(is) == 3 );
|
||||
assert( IntSet_has(is, 4) );
|
||||
assert( !IntSet_has(is, 16) );
|
||||
assert( li_std_set_IntSet_size(is) == 3 );
|
||||
assert( li_std_set_IntSet_has(is, 4) );
|
||||
assert( !li_std_set_IntSet_has(is, 16) );
|
||||
|
||||
IntSet_delete(is);
|
||||
li_std_set_IntSet_delete(is);
|
||||
}
|
||||
|
||||
{
|
||||
StringSet* ss = StringSet_new();
|
||||
li_std_set_StringSet* ss = li_std_set_StringSet_new();
|
||||
|
||||
StringSet_add(ss, "foo");
|
||||
StringSet_add(ss, "bar");
|
||||
li_std_set_StringSet_add(ss, "foo");
|
||||
li_std_set_StringSet_add(ss, "bar");
|
||||
|
||||
assert( StringSet_size(ss) == 2 );
|
||||
assert( StringSet_has(ss, "bar") );
|
||||
assert( !StringSet_has(ss, "baz") );
|
||||
assert( li_std_set_StringSet_size(ss) == 2 );
|
||||
assert( li_std_set_StringSet_has(ss, "bar") );
|
||||
assert( !li_std_set_StringSet_has(ss, "baz") );
|
||||
|
||||
StringSet_delete(ss);
|
||||
li_std_set_StringSet_delete(ss);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -4,19 +4,19 @@
|
|||
int main() {
|
||||
size_t i;
|
||||
|
||||
IntVector* iv = IntVector_new();
|
||||
assert( IntVector_size(iv) == 0 );
|
||||
li_std_vector_IntVector* iv = li_std_vector_IntVector_new();
|
||||
assert( li_std_vector_IntVector_size(iv) == 0 );
|
||||
|
||||
IntVector_push_back(iv, 1);
|
||||
IntVector_push_back(iv, 4);
|
||||
IntVector_push_back(iv, 9);
|
||||
assert( IntVector_size(iv) == 3 );
|
||||
li_std_vector_IntVector_push_back(iv, 1);
|
||||
li_std_vector_IntVector_push_back(iv, 4);
|
||||
li_std_vector_IntVector_push_back(iv, 9);
|
||||
assert( li_std_vector_IntVector_size(iv) == 3 );
|
||||
|
||||
for ( i = 0; i < 3; i++ ) {
|
||||
assert( IntVector_get(iv, i) == (i + 1)*(i + 1) );
|
||||
assert( li_std_vector_IntVector_get(iv, i) == (i + 1)*(i + 1) );
|
||||
}
|
||||
|
||||
IntVector_delete(iv);
|
||||
li_std_vector_IntVector_delete(iv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,26 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define SWIG_DEFINE_WRAPPER_ALIASES
|
||||
#include "operator_overload/operator_overload_wrap.h"
|
||||
|
||||
#define assert(x,msg) if (!x) { printf("%d: %s\n", x, msg); exit(1); }
|
||||
|
||||
int main() {
|
||||
Op_sanity_check();
|
||||
operator_overload_Op_sanity_check();
|
||||
|
||||
Op *op1 = Op_new_i(1), *op2 = Op_new_i(2), *op3 = Op_copy(op1);
|
||||
operator_overload_Op *op1 = operator_overload_Op_new_i(1), *op2 = operator_overload_Op_new_i(2), *op3 = operator_overload_Op_copy(op1);
|
||||
|
||||
assert(Op_NotEqual(op1, op2), "neq failed");
|
||||
Op_PlusPlusPrefix(op3);
|
||||
assert(Op_EqualEqual(op2, op3), "eqeq failed");
|
||||
assert(Op_GreaterThanEqual(op2, op1), "geq failed");
|
||||
Op_PlusEqual(op3, op1);
|
||||
assert(Op_LessThan(op1, op2) && Op_LessThan(op2, op3), "lt failed");
|
||||
assert(3 == *Op_IndexInto(op3, Op_IndexIntoConst(op2, Op_Functor(op1))), "[] or () failed");
|
||||
assert(5 == Op_Functor_i(op3, 2), "f(x) failed");
|
||||
assert(operator_overload_Op_NotEqual(op1, op2), "neq failed");
|
||||
operator_overload_Op_PlusPlusPrefix(op3);
|
||||
assert(operator_overload_Op_EqualEqual(op2, op3), "eqeq failed");
|
||||
assert(operator_overload_Op_GreaterThanEqual(op2, op1), "geq failed");
|
||||
operator_overload_Op_PlusEqual(op3, op1);
|
||||
assert(operator_overload_Op_LessThan(op1, op2) && operator_overload_Op_LessThan(op2, op3), "lt failed");
|
||||
assert(3 == *operator_overload_Op_IndexInto(op3, operator_overload_Op_IndexIntoConst(op2, operator_overload_Op_Functor(op1))), "[] or () failed");
|
||||
assert(5 == operator_overload_Op_Functor_i(op3, 2), "f(x) failed");
|
||||
|
||||
Op_delete(op1);
|
||||
Op_delete(op2);
|
||||
Op_delete(op3);
|
||||
operator_overload_Op_delete(op1);
|
||||
operator_overload_Op_delete(op2);
|
||||
operator_overload_Op_delete(op3);
|
||||
exit(0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue