summaryrefslogtreecommitdiffstats
path: root/tests/libsample
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-08-25 02:56:00 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-08-25 02:56:00 -0300
commit2132a3eb82830d0719d19eaadb32e39222948bca (patch)
treef0de40997a45a36e0c92d52a6beeab0a98ee01b3 /tests/libsample
parent64243890de689d10d04fdcdeedfe16c1ee612fb8 (diff)
downloadshiboken-2132a3eb82830d0719d19eaadb32e39222948bca.tar.gz
shiboken-2132a3eb82830d0719d19eaadb32e39222948bca.tar.xz
shiboken-2132a3eb82830d0719d19eaadb32e39222948bca.zip
added mapping example to test lib as well as unit tests
Diffstat (limited to 'tests/libsample')
-rw-r--r--tests/libsample/CMakeLists.txt1
-rw-r--r--tests/libsample/mapuser.cpp41
-rw-r--r--tests/libsample/mapuser.h28
3 files changed, 70 insertions, 0 deletions
diff --git a/tests/libsample/CMakeLists.txt b/tests/libsample/CMakeLists.txt
index a630b3cb..83c48077 100644
--- a/tests/libsample/CMakeLists.txt
+++ b/tests/libsample/CMakeLists.txt
@@ -9,6 +9,7 @@ implicitconv.cpp
kindergarten.cpp
listuser.cpp
modifications.cpp
+mapuser.cpp
pairuser.cpp
point.cpp
reference.cpp
diff --git a/tests/libsample/mapuser.cpp b/tests/libsample/mapuser.cpp
new file mode 100644
index 00000000..d028b7cb
--- /dev/null
+++ b/tests/libsample/mapuser.cpp
@@ -0,0 +1,41 @@
+#include <iostream>
+#include "mapuser.h"
+
+using namespace std;
+
+std::map<const char*, std::pair<Complex, int> >
+MapUser::callCreateMap()
+{
+ return createMap();
+}
+
+
+std::map<const char*, std::pair<Complex, int> >
+MapUser::createMap()
+{
+ std::map<const char*, std::pair<Complex, int> > retval;
+
+ std::pair<const char *, std::pair<Complex, int> >
+ item0("zero", std::pair<Complex, int>(Complex(1.2, 3.4), 2));
+ retval.insert(item0);
+
+ std::pair<const char *, std::pair<Complex, int> >
+ item1("one", std::pair<Complex, int>(Complex(5.6, 7.8), 3));
+ retval.insert(item1);
+
+ std::pair<const char *, std::pair<Complex, int> >
+ item2("two", std::pair<Complex, int>(Complex(9.1, 2.3), 5));
+ retval.insert(item2);
+
+ return retval;
+}
+
+void
+MapUser::showMap(std::map<const char*, int> mapping)
+{
+ std::map<const char*, int>::iterator it;
+ cout << __FUNCTION__ << endl;
+ for (it = mapping.begin() ; it != mapping.end(); it++)
+ cout << (*it).first << " => " << (*it).second << endl;
+}
+
diff --git a/tests/libsample/mapuser.h b/tests/libsample/mapuser.h
new file mode 100644
index 00000000..a5ddfe05
--- /dev/null
+++ b/tests/libsample/mapuser.h
@@ -0,0 +1,28 @@
+#ifndef MAPUSER_H
+#define MAPUSER_H
+
+#include <map>
+#include <list>
+#include <utility>
+#include "complex.h"
+
+class MapUser
+{
+public:
+ MapUser() {}
+ ~MapUser() {}
+
+ virtual std::map<const char*, std::pair<Complex, int> > createMap();
+ std::map<const char*, std::pair<Complex, int> > callCreateMap();
+
+ void showMap(std::map<const char*, int> mapping);
+
+ void setMap(std::map<const char*, std::list<int> > map) { m_map = map; }
+ std::map<const char*, std::list<int> > getMap() { return m_map; }
+
+private:
+ std::map<const char*, std::list<int> > m_map;
+};
+
+#endif // MAPUSER_H
+