Improve C# std::map tests to do the bulk of the testing on a map where the key and value types are different
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11232 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
07ed699ef3
commit
f3a70a1a03
2 changed files with 53 additions and 41 deletions
|
|
@ -15,19 +15,27 @@
|
|||
// Add an inline function to test
|
||||
%inline %{
|
||||
|
||||
double keyAverage(std::map<int, int> m) {
|
||||
double valueAverage(std::map<std::string, int> m) {
|
||||
if (m.size() == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double a = 0.0;
|
||||
for (std::map<int, int>::iterator i = m.begin(); i != m.end(); i++) {
|
||||
a += i->first;
|
||||
for (std::map<std::string, int>::iterator i = m.begin(); i != m.end(); i++) {
|
||||
a += i->second;
|
||||
}
|
||||
|
||||
return a / m.size();
|
||||
}
|
||||
|
||||
std::string stringifyKeys(std::map<std::string, int> m) {
|
||||
std::string a;
|
||||
for (std::map<std::string, int>::iterator i = m.begin(); i != m.end(); i++) {
|
||||
a += " " + i->first;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
struct Struct {
|
||||
double num;
|
||||
Struct() : num(0.0) {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue