aboutsummaryrefslogtreecommitdiffstats
path: root/tests/libsample
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-08-24 21:58:56 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:18:27 -0300
commit7ae96ccd9b11f918b392accc7e5048c5c8905a0a (patch)
tree37a7a8b2a239bedbcce834ab871679c6725d1478 /tests/libsample
parentb72430b834aee0d9bc4cdcd8442e336716d42db4 (diff)
New conversions for containers.
Diffstat (limited to 'tests/libsample')
-rw-r--r--tests/libsample/list.h16
-rw-r--r--tests/libsample/photon.cpp8
-rw-r--r--tests/libsample/photon.h14
-rw-r--r--tests/libsample/samplenamespace.h4
-rw-r--r--tests/libsample/strlist.cpp1
-rw-r--r--tests/libsample/strlist.h20
6 files changed, 54 insertions, 9 deletions
diff --git a/tests/libsample/list.h b/tests/libsample/list.h
index d9a52c31f..9eb03452f 100644
--- a/tests/libsample/list.h
+++ b/tests/libsample/list.h
@@ -34,8 +34,22 @@ class List : public std::list<T>
class IntList : public List<int>
{
public:
+ enum CtorEnum {
+ NoParamsCtor,
+ IntCtor,
+ CopyCtor,
+ ListOfIntCtor
+ };
+
+ inline IntList() : m_ctorUsed(NoParamsCtor) {}
+ inline explicit IntList(int val) : m_ctorUsed(IntCtor) { push_back(val); }
+ inline IntList(const IntList& lst) : List<int>(lst), m_ctorUsed(CopyCtor) {}
+ inline IntList(const List<int>& lst) : List<int>(lst), m_ctorUsed(ListOfIntCtor) {}
+
inline void append(int v) { insert(end(), v); }
+ CtorEnum constructorUsed() { return m_ctorUsed; }
+private:
+ CtorEnum m_ctorUsed;
};
#endif // LIST_H
-
diff --git a/tests/libsample/photon.cpp b/tests/libsample/photon.cpp
index 6467f6cc0..2b55bb7a1 100644
--- a/tests/libsample/photon.cpp
+++ b/tests/libsample/photon.cpp
@@ -32,4 +32,12 @@ int callCalculateForValueDuplicatorReference(ValueDuplicator& value)
{
return value.calculate();
}
+int countValueIdentities(const std::list<ValueIdentity>& values)
+{
+ return values.size();
+}
+int countValueDuplicators(const std::list<TemplateBase<DuplicatorType> >& values)
+{
+ return values.size();
+}
} // namespace Photon
diff --git a/tests/libsample/photon.h b/tests/libsample/photon.h
index 8707c71af..749e10e4b 100644
--- a/tests/libsample/photon.h
+++ b/tests/libsample/photon.h
@@ -23,6 +23,7 @@
#ifndef PHOTON_H
#define PHOTON_H
+#include <list>
#include "libsamplemacros.h"
// This namespace and classes simulate
@@ -50,10 +51,17 @@ public:
inline int sumValueUsingPointer(TemplateBase<CLASS_TYPE>* other) const { return m_value + other->m_value; }
inline int sumValueUsingReference(TemplateBase<CLASS_TYPE>& other) const { return m_value + other.m_value; }
+ inline std::list<TemplateBase<CLASS_TYPE> > getListOfThisTemplateBase()
+ {
+ std::list<TemplateBase<CLASS_TYPE> >objs;
+ objs.push_back(*this);
+ objs.push_back(*this);
+ return objs;
+ }
+
+
static inline TemplateBase<CLASS_TYPE>* passPointerThrough(TemplateBase<CLASS_TYPE>* obj) { return obj; }
private:
- TemplateBase(const TemplateBase&);
- TemplateBase& operator=(const TemplateBase&);
int m_value;
};
@@ -61,6 +69,8 @@ typedef TemplateBase<IdentityType> ValueIdentity;
typedef TemplateBase<DuplicatorType> ValueDuplicator;
LIBSAMPLE_API int callCalculateForValueDuplicatorPointer(ValueDuplicator* value);
LIBSAMPLE_API int callCalculateForValueDuplicatorReference(ValueDuplicator& value);
+LIBSAMPLE_API int countValueIdentities(const std::list<ValueIdentity>& values);
+LIBSAMPLE_API int countValueDuplicators(const std::list<TemplateBase<DuplicatorType> >& values);
} // namespace Photon
diff --git a/tests/libsample/samplenamespace.h b/tests/libsample/samplenamespace.h
index 85ce8409f..88269b454 100644
--- a/tests/libsample/samplenamespace.h
+++ b/tests/libsample/samplenamespace.h
@@ -23,6 +23,7 @@
#ifndef SAMPLENAMESPACE_H
#define SAMPLENAMESPACE_H
+#include <list>
#include "libsamplemacros.h"
#include "str.h"
#include "point.h"
@@ -105,6 +106,9 @@ public:
virtual OkThisIsRecursiveEnough* someVirtualMethod(OkThisIsRecursiveEnough* arg) { return arg; }
};
};
+ struct SomeOtherInnerClass {
+ std::list<SomeInnerClass> someInnerClasses;
+ };
};
class DerivedFromNamespace : public SomeClass::SomeInnerClass::OkThisIsRecursiveEnough
diff --git a/tests/libsample/strlist.cpp b/tests/libsample/strlist.cpp
index 2e487f5e8..6a9eb23bd 100644
--- a/tests/libsample/strlist.cpp
+++ b/tests/libsample/strlist.cpp
@@ -49,4 +49,3 @@ StrList::join(const Str& sep) const
}
return result;
}
-
diff --git a/tests/libsample/strlist.h b/tests/libsample/strlist.h
index 5845d06b5..98dfdee13 100644
--- a/tests/libsample/strlist.h
+++ b/tests/libsample/strlist.h
@@ -31,17 +31,27 @@
class LIBSAMPLE_API StrList : public std::list<Str>
{
public:
- inline StrList() {}
- inline explicit StrList(const Str& str) { push_back(str); }
- inline StrList(const StrList& lst) : std::list<Str>(lst) { }
- inline StrList(const std::list<Str>& lst) : std::list<Str>(lst) { }
+ enum CtorEnum {
+ NoParamsCtor,
+ StrCtor,
+ CopyCtor,
+ ListOfStrCtor
+ };
+
+ inline StrList() : m_ctorUsed(NoParamsCtor) {}
+ inline explicit StrList(const Str& str) : m_ctorUsed(StrCtor) { push_back(str); }
+ inline StrList(const StrList& lst) : std::list<Str>(lst), m_ctorUsed(CopyCtor) {}
+ inline StrList(const std::list<Str>& lst) : std::list<Str>(lst), m_ctorUsed(ListOfStrCtor) {}
inline void append(Str str) { push_back(str); }
Str join(const Str& sep) const;
bool operator==(const std::list<Str>& other) const;
inline bool operator!=(const std::list<Str>& other) const { return !(*this == other); }
+
+ CtorEnum constructorUsed() { return m_ctorUsed; }
+private:
+ CtorEnum m_ctorUsed;
};
#endif // STRLIST_H
-