Adding unit tests for std::list
This commit is contained in:
parent
bdecbda512
commit
39b76cb5c5
@ -94,7 +94,7 @@ bool deserialize(Deserializer* deserializer, std::vector<T, A>* value) {
|
||||
template <typename T, typename A>
|
||||
void serialize(Serializer* serializer, const std::list<T, A>& value) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
38
testing.cpp
38
testing.cpp
@ -36,6 +36,7 @@ using namespace metacall;
|
||||
#define TEST_C_STRING
|
||||
#define TEST_BASIC_STRING
|
||||
#define TEST_VECTOR
|
||||
#define TEST_LIST
|
||||
|
||||
|
||||
//
|
||||
@ -109,7 +110,7 @@ static void testBasicString(Binding* binding, Protocol* protocol) {
|
||||
#ifdef TEST_VECTOR
|
||||
|
||||
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) {
|
||||
printf("%f ", *iter);
|
||||
@ -132,6 +133,37 @@ static void testVector(Binding* binding, Protocol* protocol) {
|
||||
#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
|
||||
//
|
||||
@ -167,6 +199,10 @@ int main(int, char *[]) {
|
||||
testVector(&binding, &protocol);
|
||||
#endif
|
||||
|
||||
#ifdef TEST_LIST
|
||||
testList(&binding, &protocol);
|
||||
#endif
|
||||
|
||||
server.advance();
|
||||
client.advance();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user