scilab: remove li_std_vector_as_argument (will be replaced by more generic test)
This commit is contained in:
parent
1eb7474b72
commit
15f0624216
3 changed files with 0 additions and 194 deletions
|
|
@ -493,7 +493,6 @@ CPP_STD_TEST_CASES += \
|
||||||
li_std_set_as_argument \
|
li_std_set_as_argument \
|
||||||
li_std_string \
|
li_std_string \
|
||||||
li_std_vector \
|
li_std_vector \
|
||||||
li_std_vector_as_argument \
|
|
||||||
li_std_vector_enum \
|
li_std_vector_enum \
|
||||||
li_std_vector_member_var\
|
li_std_vector_member_var\
|
||||||
naturalvar \
|
naturalvar \
|
||||||
|
|
|
||||||
|
|
@ -1,115 +0,0 @@
|
||||||
%module li_std_vector_as_argument
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include <vector>
|
|
||||||
#include <iostream>
|
|
||||||
#include <iterator>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <numeric>
|
|
||||||
|
|
||||||
%}
|
|
||||||
|
|
||||||
%{
|
|
||||||
class classA
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
classA() : a(0) {}
|
|
||||||
classA(int _a) : a(_a) {}
|
|
||||||
classA(const classA& c) : a(c.a) {}
|
|
||||||
int a;
|
|
||||||
};
|
|
||||||
%}
|
|
||||||
|
|
||||||
%include stl.i
|
|
||||||
|
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
%template(IntVector) vector<int>;
|
|
||||||
%template(DoubleVector) vector<double>;
|
|
||||||
%template(StringVector) vector<std::string>;
|
|
||||||
%template(BoolVector) vector<bool>;
|
|
||||||
%template(ClassAPtrVector) vector<classA*>;
|
|
||||||
}
|
|
||||||
|
|
||||||
%ignore concat_vector;
|
|
||||||
|
|
||||||
class classA
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
classA() : a(0) {}
|
|
||||||
classA(int _a) : a(_a) {}
|
|
||||||
classA(const classA& c) : a(c.a) {}
|
|
||||||
int a;
|
|
||||||
};
|
|
||||||
|
|
||||||
%inline %{
|
|
||||||
template <typename T>
|
|
||||||
std::vector<T> concat_vector(const std::vector<T> vector, const std::vector<T> other_vector) {
|
|
||||||
std::vector<T> out_vector(vector);
|
|
||||||
out_vector.insert(out_vector.end(), other_vector.begin(), other_vector.end());
|
|
||||||
return out_vector;
|
|
||||||
}
|
|
||||||
|
|
||||||
// double vectors
|
|
||||||
|
|
||||||
std::vector<double> create_double_vector(const int size, const double value) {
|
|
||||||
return std::vector<double>(size, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
double sum_double_vector(const std::vector<double>& vector) {
|
|
||||||
return std::accumulate(vector.begin(), vector.end(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<double> concat_double_vector(const std::vector<double> vector, const std::vector<double> other_vector) {
|
|
||||||
return concat_vector<double>(vector, other_vector);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int vectors
|
|
||||||
|
|
||||||
std::vector<int> create_integer_vector(const int size, const int value) {
|
|
||||||
return std::vector<int>(size, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
int sum_integer_vector(const std::vector<int>& vector) {
|
|
||||||
return std::accumulate(vector.begin(), vector.end(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<int> concat_integer_vector(const std::vector<int> vector, const std::vector<int> other_vector) {
|
|
||||||
return concat_vector<int>(vector, other_vector);
|
|
||||||
}
|
|
||||||
|
|
||||||
// string vectors
|
|
||||||
|
|
||||||
std::vector<std::string> create_string_vector(const int size, const char *value) {
|
|
||||||
return std::vector<std::string>(size, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> concat_string_vector(const std::vector<std::string> vector, const std::vector<std::string> other_vector) {
|
|
||||||
return concat_vector<std::string>(vector, other_vector);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bool vectors
|
|
||||||
|
|
||||||
std::vector<bool> create_bool_vector(const int size, const bool value) {
|
|
||||||
return std::vector<bool>(size, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<bool> concat_bool_vector(const std::vector<bool> vector, const std::vector<bool> other_vector) {
|
|
||||||
return concat_vector<bool>(vector, other_vector);
|
|
||||||
}
|
|
||||||
|
|
||||||
// pointer (on object) vectors
|
|
||||||
|
|
||||||
std::vector<classA*> create_classAPtr_vector(const int size, classA *aClassAPtr) {
|
|
||||||
std::vector<classA*> out_vector;
|
|
||||||
for (int i=0; i<size; i++) {
|
|
||||||
out_vector.push_back(aClassAPtr);
|
|
||||||
}
|
|
||||||
return out_vector;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<classA*> concat_classAPtr_vector(const std::vector<classA*> vector, const std::vector<classA*> other_vector) {
|
|
||||||
return concat_vector<classA*>(vector, other_vector);
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
|
|
||||||
|
|
@ -1,78 +0,0 @@
|
||||||
// Tests C++ fonctions with STL vectors as arguments
|
|
||||||
|
|
||||||
exec("swigtest.start", -1);
|
|
||||||
|
|
||||||
// double vectors
|
|
||||||
|
|
||||||
// Test of using vector<double> arguments of C++ functions
|
|
||||||
// Get a vector of double {2.0, 2.0, 2.0, 2.0} from create_double_vector()
|
|
||||||
dv = create_double_vector(4, 2.0);
|
|
||||||
if ~exists("dv") | (dv <> [2. 2. 2. 2.]) then swigtesterror(); end
|
|
||||||
// Get sum this vector elements with sum_double_vector()
|
|
||||||
ds = sum_double_vector(dv);
|
|
||||||
if ~exists("ds") | (ds <> 8.) then swigtesterror(); end
|
|
||||||
// Get a vector of double {5.0, 5.0} from create_double_vector()
|
|
||||||
dv2 = create_double_vector(2, 5.0);
|
|
||||||
if ~exists("dv2") | (dv2 <> [5. 5.]) then swigtesterror(); end
|
|
||||||
// Concat the two vectors with concat_double_vector()
|
|
||||||
dv3 = concat_double_vector(dv, dv2);
|
|
||||||
if ~exists("dv3") | (dv3 <> [dv dv2]) then swigtesterror(); end
|
|
||||||
|
|
||||||
// integer vectors
|
|
||||||
|
|
||||||
// Test of using vector<int> arguments of C++ functions.");
|
|
||||||
// Get a vector of int {3, 3, 3, 3} from create_integer_vector()
|
|
||||||
iv = create_integer_vector(3, 3);
|
|
||||||
if ~exists("iv") | (iv <> int32([3 3 3])) then swigtesterror(); end
|
|
||||||
// Get the sum of this vector elements with sum_integer_vector()
|
|
||||||
is = sum_integer_vector(iv);
|
|
||||||
if ~exists("is") | (is <> int32(9)) then swigtesterror(); end
|
|
||||||
// Get a vector of int {1, 1} from create_integer_vector()
|
|
||||||
iv2 = create_integer_vector(2, 1);
|
|
||||||
// Concat the two vectors with concat_integer_vector()
|
|
||||||
iv3 = concat_integer_vector(iv, iv2);
|
|
||||||
if ~exists("iv3") | (iv3 <> int32([iv iv2])) then swigtesterror(); end
|
|
||||||
|
|
||||||
// std::string vectors
|
|
||||||
|
|
||||||
// Test of using vector<std::string> arguments of C++ functions.
|
|
||||||
// Get a vector of string {''aa'', ''aa''} with create_string_vector()
|
|
||||||
sv = create_string_vector(2, "aa");
|
|
||||||
if ~exists("sv") | (sv <> ["aa"; "aa"]) then swigtesterror(); end
|
|
||||||
// Get a vector of string {''bb'', ''bb''} with create_string_vector()
|
|
||||||
sv2 = create_string_vector(2, "bb");
|
|
||||||
if ~exists("sv2") | (sv2 <> ["bb"; "bb"]) then swigtesterror(); end
|
|
||||||
// Concat the two vectors with concat_string_vector()
|
|
||||||
sv3 = concat_string_vector(sv, sv2);
|
|
||||||
if ~exists("sv3") | (sv3 <> [sv; sv2]) then swigtesterror(); end
|
|
||||||
|
|
||||||
// bool vectors
|
|
||||||
|
|
||||||
// Test of using vector<bool> arguments of C++ functions.
|
|
||||||
// Get a vector of bool {true, true} with create_bool_vector()
|
|
||||||
bv = create_bool_vector(2, %T);
|
|
||||||
if ~exists("bv") | (bv <> [%T %T]) then swigtesterror(); end
|
|
||||||
// Get a vector of bool {false, false, false} with create_bool_vector()
|
|
||||||
bv2 = create_bool_vector(3, %F);
|
|
||||||
if ~exists("bv2") | (bv2 <> [%F %F %F]) then swigtesterror(); end
|
|
||||||
// Concat the two vectors with concat_bool_vector()
|
|
||||||
bv3 = concat_bool_vector(bv, bv2);
|
|
||||||
if ~exists("bv3") | (bv3 <> [bv bv2]) then swigtesterror(); end
|
|
||||||
|
|
||||||
// Pointer (on object) vectors
|
|
||||||
|
|
||||||
// Test of using vector of pointers (on object) arguments of C++ functions.
|
|
||||||
// Get a vector of pointers on object {<classA* a:10>, <classA* a:10>, <classA* a:10>} with create_classAPtr_vector()
|
|
||||||
classA_1 = new_classA(10);
|
|
||||||
pv = create_classAPtr_vector(3, classA_1);
|
|
||||||
if ~exists("pv") | (size(pv) <> 3) | (classA_a_get(pv(1)) <> 10) then swigtesterror(); end
|
|
||||||
// Get a vector of pointers on object {<classA* a:5>, <classA* a:5>} with create_classAPtr_vector()
|
|
||||||
classA_2 = new_classA(5);
|
|
||||||
pv2 = create_classAPtr_vector(2, classA_2);
|
|
||||||
if ~exists("pv2") | (size(pv2) <> 2) | (classA_a_get(pv2(1)) <> 5) then swigtesterror(); end
|
|
||||||
// Concat the two vectors with concat_classAPtr_vector()
|
|
||||||
pv3 = concat_classAPtr_vector(pv, pv2);
|
|
||||||
if ~exists("pv3") | (size(pv3) <> 5) | (classA_a_get(pv3(1)) <> 10) | (classA_a_get(pv3(4)) <> 5) then swigtesterror(); end
|
|
||||||
|
|
||||||
exec("swigtest.quit", -1);
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue