Adding unit tests for std::list

This commit is contained in:
Alex Yatskov 2012-04-14 19:32:30 -07:00
parent bdecbda512
commit 39b76cb5c5
2 changed files with 38 additions and 2 deletions

View File

@ -94,7 +94,7 @@ bool deserialize(Deserializer* deserializer, std::vector<T, A>* value) {
template <typename T, typename A> template <typename T, typename A>
void serialize(Serializer* serializer, const std::list<T, A>& value) { void serialize(Serializer* serializer, const std::list<T, A>& value) {
serializer->write(value.size()); serializer->write(value.size());
for (const typename std::list<T, A>::const_iterator iter = value.begin(); iter != value.end(); ++iter) { for (typename std::list<T, A>::const_iterator iter = value.begin(); iter != value.end(); ++iter) {
serializer->write(*iter); serializer->write(*iter);
} }
} }

View File

@ -36,6 +36,7 @@ using namespace metacall;
#define TEST_C_STRING #define TEST_C_STRING
#define TEST_BASIC_STRING #define TEST_BASIC_STRING
#define TEST_VECTOR #define TEST_VECTOR
#define TEST_LIST
// //
@ -109,7 +110,7 @@ static void testBasicString(Binding* binding, Protocol* protocol) {
#ifdef TEST_VECTOR #ifdef TEST_VECTOR
static void testVectorImp(const std::vector<float>& vec) { static void testVectorImp(const std::vector<float>& vec) {
printf("[testStdVector]: "); printf("[testVectorImp]: ");
for (std::vector<float>::const_iterator iter = vec.begin(); iter != vec.end(); ++iter) { for (std::vector<float>::const_iterator iter = vec.begin(); iter != vec.end(); ++iter) {
printf("%f ", *iter); printf("%f ", *iter);
@ -132,6 +133,37 @@ static void testVector(Binding* binding, Protocol* protocol) {
#endif #endif
//
// std::list
//
#ifdef TEST_LIST
static void testListImp(const std::list<float>& lst) {
printf("[testListImp]: ");
for (std::list<float>::const_iterator iter = lst.begin(); iter != lst.end(); ++iter) {
printf("%f ", *iter);
}
printf("\n");
}
static void testList(Binding* binding, Protocol* protocol) {
binding->bind(FPARAM(testListImp));
std::list<float> lst;
lst.push_back(3.14159f);
lst.push_back(2.71828f);
lst.push_back(1.61803f);
protocol->invoke("testListImp", lst);
}
#endif
// //
// Program entry // Program entry
// //
@ -167,6 +199,10 @@ int main(int, char *[]) {
testVector(&binding, &protocol); testVector(&binding, &protocol);
#endif #endif
#ifdef TEST_LIST
testList(&binding, &protocol);
#endif
server.advance(); server.advance();
client.advance(); client.advance();
} }