You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by ve...@apache.org on 2012/01/12 11:06:25 UTC

svn commit: r1230465 - in /incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu: ./ include/capu/ include/capu/container/ test/container/

Author: veithm
Date: Thu Jan 12 10:06:25 2012
New Revision: 1230465

URL: http://svn.apache.org/viewvc?rev=1230465&view=rev
Log:
ETCH-135 CAPU Double Linked List Implementation and Test

Change-Id: I99380706ee38ab7034e89c82b56d30eb8f69e15a

Added:
    incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/
    incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Comparator.h
      - copied, changed from r1230464, incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Error.h
    incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/List.h
    incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/test/container/
    incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/test/container/ListTest.cpp
Modified:
    incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/CMakeLists.txt
    incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Error.h

Modified: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/CMakeLists.txt?rev=1230465&r1=1230464&r2=1230465&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/CMakeLists.txt (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/CMakeLists.txt Thu Jan 12 10:06:25 2012
@@ -23,6 +23,7 @@ ADD_CLASS(util/SmartPointer)
 ADD_CLASS(os/Thread SOURCE_GROUP arch_source_group)
 ADD_CLASS(os/CondVar SOURCE_GROUP arch_source_group)
 ADD_CLASS(os/StringUtils SOURCE_GROUP arch_source_group)
+ADD_CLASS(container/List)
 
 REQUIRED_PACKAGE(Thread)
 

Modified: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Error.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Error.h?rev=1230465&r1=1230464&r2=1230465&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Error.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Error.h Thu Jan 12 10:06:25 2012
@@ -35,7 +35,8 @@ namespace capu
         CAPU_SOCKET_ECONNECT    = 7,
         CAPU_SOCKET_ELISTEN     = 8,
         CAPU_SOCKET_ECLOSE      = 9,
-        CAPU_SOCKET_EADDR       = 10
+        CAPU_SOCKET_EADDR       = 10,
+        CAPU_ENO_MEMORY         = 11
     };
 }
 #endif

Copied: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Comparator.h (from r1230464, incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Error.h)
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Comparator.h?p2=incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Comparator.h&p1=incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Error.h&r1=1230464&r2=1230465&rev=1230465&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/Error.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/Comparator.h Thu Jan 12 10:06:25 2012
@@ -16,27 +16,23 @@
  * limitations under the License.
  */
 
-#ifndef __ERROR_H__
-#define __ERROR_H__
+#ifndef __COMPARATOR_H__
+#define __COMPARATOR_H__
 
-#include "Config.h"
+#include "capu/Config.h"
 
-namespace capu
-{
-    typedef int32_t status_t;
-    enum {
-        CAPU_OK                 = 0,
-        CAPU_EUNIMPL            = 1,
-        CAPU_ERANGE             = 2,
-        CAPU_EINVAL             = 3,
-        CAPU_ERROR              = 4,
-        CAPU_SOCKET_EBIND       = 5,
-        CAPU_SOCKET_ESOCKET     = 6,
-        CAPU_SOCKET_ECONNECT    = 7,
-        CAPU_SOCKET_ELISTEN     = 8,
-        CAPU_SOCKET_ECLOSE      = 9,
-        CAPU_SOCKET_EADDR       = 10
+namespace capu {
+
+    template <class T>
+    class Comparator {
+
+    public:
+
+        bool_t operator () (const T& x, const T& y) const {
+            return x == y;
+        }
     };
 }
-#endif
+
+#endif /* COMPARATOR_H */
 

Added: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/List.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/List.h?rev=1230465&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/List.h (added)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/include/capu/container/List.h Thu Jan 12 10:06:25 2012
@@ -0,0 +1,473 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LIST_H__
+#define __LIST_H__
+#include "capu/Error.h"
+#include "capu/Config.h"
+#include "capu/container/Comparator.h"
+
+namespace capu {
+
+  template <class T, class C = Comparator<T> >
+  class List {
+  private:
+
+    class ListNode {
+    public:
+
+      ListNode() {
+        mNext = NULL;
+        mPrev = NULL;
+      }
+
+      ListNode(T data) {
+        mNext = NULL;
+        mPrev = NULL;
+        this->mData = data;
+      }
+
+      T mData;
+      ListNode * mNext;
+      ListNode * mPrev;
+
+    };
+
+    class ListIterator {
+    public:
+
+      /**
+       * Default Constructor
+       */
+      ListIterator();
+
+      /**
+       * constructor
+       * @param initial_node where the iterator will be pointing
+       */
+      ListIterator(ListNode *initialNode);
+
+      /**
+       * destructor
+       */
+      ~ListIterator();
+
+      /**
+       * Check if iterator has next element.
+       * @return false if the next of current node that is pointed, is null otherwise true
+       */
+      bool_t hasNext();
+
+      /**
+       * Get next iterator element.
+       * @param element point to the next element
+       * @return CAPU_ERANGE if the next of current node that is pointed, is null
+       *         CAPU_EINVAL if the value is NULL
+       *         CAPU_OK if the next element has been gotten
+       *
+       */
+      status_t next(T* element);
+
+    private:
+      ListNode *mNextPosition;
+    };
+
+    ListNode *mHead;
+    ListNode *mTail;
+    int32_t mSize;
+
+  public:
+
+    typedef typename List<T, C>::ListIterator Iterator;
+
+    /**
+     * Default Constructor
+     */
+    List();
+
+    /**
+     * Destructor
+     */
+    virtual ~List();
+
+    /**
+     * Add element to the end of list
+     * @param element element that will be added
+     * @return CAPU_ENO_MEMORY if allocation of element is failed
+     *         CAPU_OK if the element is successfully added
+     */
+    status_t add(const T element);
+
+    /**
+     * It will insert new element to specified position only the element at specified index with given element
+     *
+     * @param index index of element which will be inserted
+     * @param element new value that will replace the old value
+     *
+     * @return CAPU_EINVAL if given index is invalid.
+     *         CAPU_ENO_MEMORY if allocation of element is failed
+     *         CAPU_OK if the element is successfully added
+     *         CAPU_ERROR otherwise
+     */
+    status_t add(int32_t index, const T element);
+
+    /**
+     * remove the element in the specified index and if the element_old
+     * parameter is not NULL, the removed element will be put to element_old
+     * @param index index of element that will be removed
+     * @param elementOld the buffer which will keep the copy of the removed element
+     * @return CAPU_EINVAL invalid index
+     *         CAPU_OK if the element is successfully removed
+     */
+    status_t removeAt(int32_t index, T* elementOld = NULL);
+
+    /**
+     * get a single element on specified index
+     * @param index index of element that will be get
+     * @param result the buffer that the retrieved element will be stored
+     * @return CAPU_EINVAL invalid index
+     *         CAPU_OK otherwise
+     */
+    status_t get(int32_t index, T* result);
+
+    /**
+     * return size of list
+     * @return return the size of list
+     */
+    int32_t size();
+
+    /**
+     * check the list is empty or not
+     * @return true if empty
+     *         false otherwise
+     */
+    bool_t isEmpty();
+
+    /**
+     * returns an iterator pointing to the beginning of list
+     * @return iterator
+     */
+    Iterator begin();
+
+    /**
+     * finds the index of given element in the link list
+     * if you are using an object you need to overload == operator
+     *
+     * @param element the value that will be searched
+     * @return -1 if the value either does not exist or given value is NULL
+     *          otherwise index of value on linked list
+     */
+    int32_t find(const T element);
+
+    /**
+     *
+     * @param index the index of element that will be replaced
+     * @param element element that will be overwritten to existing place
+     * @param elementOld the buffer to keep the existing
+     * @return CAPU_EINVAL if the index is not valid
+     *         CAPU_OK otherwise
+     */
+    status_t set(int32_t index, T element, T* elementOld = NULL);
+
+    /**
+     * check that if the list contains the given parameter or not
+     * if you are using an object you need to overload == operator
+     * @param element element that will be checked
+     * @return true list contains it
+     *         false otherwise
+     */
+    bool_t contains(const T element);
+
+    /**
+     * removes all elements from linked list
+     *
+     * @return CAPU_OK if all of the elements are deleted
+     *
+     */
+    status_t clear();
+  };
+
+  template <class T, class C>
+  List<T, C>::List()
+  : mHead(NULL),
+  mTail(NULL),
+  mSize(0) {
+    //init linked list
+  }
+
+  template <class T, class C>
+  List<T, C>::~List() {
+    clear();
+  }
+
+  template <class T, class C>
+  status_t List<T, C>::clear() {
+    //on the deallocation delete all elements in the list
+    ListNode *cursor = mHead;
+    ListNode *tmp = NULL;
+
+    while (cursor != NULL) {
+      tmp = cursor;
+      cursor = cursor->mNext;
+      delete tmp;
+    }
+    mSize = 0;
+    mHead = NULL;
+    mTail = NULL;
+    return CAPU_OK;
+  }
+
+  template <class T, class C>
+  int32_t List<T, C>::find(const T element) {
+    int32_t counter = 0;
+    ListNode * cursor = mHead;
+    C comparator;
+    while (cursor != NULL) {
+      if (comparator(cursor->mData, element)) {
+        return counter;
+      }
+      cursor = cursor->mNext;
+      ++counter;
+    }
+    return -1;
+  }
+
+  template <class T, class C>
+  bool_t List<T, C>::contains(const T element) {
+    return (find(element) != -1);
+  }
+
+  //add elements to the end of list
+
+  template <class T, class C>
+  status_t List<T, C>::add(const T element) {
+    ListNode *listElem = NULL;
+    listElem = new ListNode(element);
+    //NOT ALLOCATED
+    if (listElem == NULL) {
+      return CAPU_ENO_MEMORY;
+    }
+    //list is empty
+    if (mHead == NULL) {
+      mHead = listElem;
+      mTail = mHead;
+    } else {
+      //list contains some elements so add it to the end of list
+      mTail->mNext = listElem;
+      listElem->mPrev = mTail;
+      mTail = listElem;
+      mTail->mNext = NULL;
+    }
+    ++mSize;
+    return CAPU_OK;
+  }
+
+  template <class T, class C>
+  status_t List<T, C>::add(int32_t index, const T element) {
+    if ((index > mSize) || (index < 0)) {
+      return CAPU_EINVAL;
+    }
+
+    ListNode *listElem = NULL;
+    listElem = new ListNode(element);
+    //NOT ALLOCATED
+    if (listElem == NULL) {
+      return CAPU_ENO_MEMORY;
+    }
+
+    int32_t counter = 0;
+    ListNode * cursor = mHead;
+    if (cursor == NULL) {
+      //empty list
+      mHead = listElem;
+      mTail = listElem;
+      mHead->mPrev = NULL;
+      mTail->mNext = NULL;
+      ++mSize;
+      return CAPU_OK;
+    } else if (index == mSize) {
+      //list contains some elements so add it to the end of list
+      mTail->mNext = listElem;
+      listElem->mPrev = mTail;
+      mTail = listElem;
+      mTail->mNext = NULL;
+      ++mSize;
+      return CAPU_OK;
+    }
+    while (cursor != NULL) {
+      if (index == counter) {
+
+        if (cursor == mHead) // add to the front of list
+        {
+          listElem->mNext = mHead;
+          mHead->mPrev = listElem;
+          listElem->mPrev = NULL;
+          mHead = listElem;
+        } else {
+          listElem->mNext = cursor;
+          listElem->mPrev = cursor->mPrev;
+          if (cursor->mPrev != NULL)
+            cursor->mPrev->mNext = listElem;
+          cursor->mPrev = listElem;
+        }
+        ++mSize;
+        return CAPU_OK;
+      }
+      ++counter;
+      cursor = cursor->mNext;
+    }
+    return CAPU_ERROR;
+  }
+
+  //remove the specific element indicated by the index in the list
+
+  template <class T, class C>
+  status_t List<T, C>::removeAt(int32_t index, T* elementOld) {
+    if ((index < 0) || (index >= mSize)) {
+      return CAPU_EINVAL;
+    }
+    ListNode * tmp = NULL;
+    if (mHead == mTail) {
+      tmp = mHead;
+      mHead = NULL;
+      mTail = NULL;
+    } else if (index == 0) {
+
+      tmp = mHead;
+      mHead = mHead->mNext;
+      mHead->mPrev = NULL;
+    } else if (index == mSize - 1) {
+      tmp = mTail;
+      mTail = mTail->mPrev;
+      mTail->mNext = NULL;
+    } else {
+      tmp = mHead;
+      for (int32_t i = 0; i < index; ++i) {
+        tmp = tmp->mNext;
+      }
+      tmp->mNext->mPrev = tmp->mPrev;
+      tmp->mPrev->mNext = tmp->mNext;
+    }
+    if (elementOld != NULL)
+      *elementOld = tmp->mData;
+    delete tmp;
+    mSize--;
+    return CAPU_OK;
+  }
+
+  //get the specified element from list
+
+  template <class T, class C>
+  status_t List<T, C>::get(int32_t index, T* result) {
+    if (((index < 0) || (index >= mSize)) || (result == NULL)) {
+      return CAPU_EINVAL;
+    }
+
+    if (index == 0) {
+      *result = mHead->mData;
+      return CAPU_OK;
+    } else if (index == mSize - 1) {
+      *result = mTail->mData;
+      return CAPU_OK;
+    }
+
+    ListNode *cursor = mHead;
+    for (int32_t i = 0; i < index; ++i) {
+      cursor = cursor->mNext;
+    }
+    *result = cursor->mData;
+    return CAPU_OK;
+  }
+
+  template <class T, class C>
+  status_t List<T, C>::set(int32_t index, T element, T* elementOld) {
+    if ((index < 0) || (index >= mSize))
+      return CAPU_EINVAL;
+
+    ListNode *cursor = mHead;
+    for (int32_t i = 0; i < index; ++i) {
+      cursor = cursor->mNext;
+    }
+    if (elementOld != NULL)
+      *elementOld = cursor->mData;
+    cursor->mData = element;
+    return CAPU_OK;
+  }
+
+  //Return element count of list
+
+  template <class T, class C>
+  int32_t List<T, C>::size() {
+    return mSize;
+  }
+
+  //checks if the list is empty or not
+
+  template <class T, class C>
+  bool_t List<T, C>::isEmpty() {
+    if (mSize == 0)
+      return true;
+    else
+      return false;
+  }
+
+  template <class T, class C>
+  typename List<T, C>::Iterator List<T, C>::begin() {
+    return ListIterator(mHead);
+  }
+
+  template <class T, class C>
+  List<T, C>::ListIterator::ListIterator()
+  : mNextPosition(NULL) {
+
+  }
+
+  template <class T, class C>
+  List<T, C>::ListIterator::~ListIterator() {
+
+  }
+
+  template <class T, class C>
+  List<T, C>::ListIterator::ListIterator(ListNode *initialNode) {
+    mNextPosition = initialNode;
+  }
+
+  template <class T, class C>
+  bool_t List<T, C>::ListIterator::hasNext() {
+    if (mNextPosition == NULL) {
+      return false;
+    }
+    return true;
+  }
+
+  template <class T, class C>
+  status_t List<T, C>::ListIterator::next(T* element) {
+    if (mNextPosition == NULL) {
+      return CAPU_ERANGE;
+    } else if (element == NULL) {
+      return CAPU_EINVAL;
+    } else {
+      *element = mNextPosition->mData;
+      mNextPosition = mNextPosition->mNext;
+      return CAPU_OK;
+    }
+  }
+}
+
+#endif /* DOUBLELINKEDLIST_H */
+

Added: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/test/container/ListTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/test/container/ListTest.cpp?rev=1230465&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/test/container/ListTest.cpp (added)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/test/container/ListTest.cpp Thu Jan 12 10:06:25 2012
@@ -0,0 +1,398 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <gtest/gtest.h>
+#include "capu/container/List.h"
+#include "capu/Error.h"
+#include "capu/Config.h"
+
+TEST(List, Constructor_Default) {
+  //create an empty linked list
+  capu::List<capu::int32_t*>* list = NULL;
+  list = new capu::List<capu::int32_t*>();
+  EXPECT_TRUE(list != NULL);
+  delete list;
+}
+
+TEST(List, addTest) {
+  capu::List<capu::int32_t>* list = new capu::List<capu::int32_t > ();
+  capu::int32_t data1;
+  capu::int32_t data2;
+  capu::int32_t data3;
+  capu::status_t result;
+
+  data1 = 32;
+  data2 = 43;
+  //append element to the linked list
+  result = list->add(data1);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  //append another element to linked list
+  result = list->add(data2);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  //Get added elements to compare that if they are correctly added or not
+  list->get(0, &data3);
+  EXPECT_TRUE(data3 == data1);
+
+  list->get(1, &data3);
+  EXPECT_TRUE(data3 == data2);
+
+  delete list;
+}
+
+TEST(List, addIndexTest) {
+  capu::List<capu::int32_t>* list = new capu::List<capu::int32_t > ();
+  capu::int32_t data1;
+  capu::int32_t data2;
+  capu::int32_t data3;
+  capu::status_t result;
+
+  data1 = 32;
+  data2 = 43;
+
+  result = list->add(10, data1);
+  EXPECT_TRUE(result == capu::CAPU_EINVAL);
+
+
+  result = list->add(0, data2);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  result = list->add(1, data2);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  result = list->add(0, data2);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  result = list->add(1, data1);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  //Get added elements to compare that if they are correctly added or not
+  list->get(0, &data3);
+  EXPECT_TRUE(data3 == data2);
+
+  list->get(1, &data3);
+  EXPECT_TRUE(data3 == data1);
+
+  delete list;
+}
+
+TEST(List, removeAt) {
+  capu::List<capu::int32_t>* list = new capu::List<capu::int32_t > ();
+  capu::int32_t data1;
+  capu::int32_t data2;
+  capu::int32_t data3;
+  capu::status_t result;
+
+  data1 = 32;
+  data2 = 43;
+  data3 = 56;
+  //add some elements to linked list
+  result = list->add(data1);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  result = list->add(data3);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  result = list->add(data2);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  //removing element at index 1
+  result = list->removeAt(1);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  //removing element at index 1
+  result = list->removeAt(1);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  //removing element at index 0 (HEAD)
+  result = list->removeAt(0, &data1);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+  EXPECT_TRUE(data1 == 32);
+
+  //remove element from out of index
+  result = list->removeAt(1000);
+  EXPECT_TRUE(result == capu::CAPU_EINVAL);
+
+  //check size of list
+  EXPECT_TRUE(list->size() == 0);
+
+  delete list;
+}
+
+TEST(List, get) {
+  capu::List<capu::int32_t>* list = new capu::List<capu::int32_t > ();
+  capu::int32_t data1;
+  capu::int32_t data2;
+  capu::int32_t data3;
+  capu::int32_t data4;
+
+  capu::status_t result;
+
+  data1 = 32;
+  data2 = 43;
+  data3 = 56;
+
+  //add some element to the linked list
+  result = list->add(data1);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  result = list->add(data3);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  result = list->add(data2);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  //get the added elements by using its index and compare the values with inserted elements
+  result = list->get(0, &data4);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+  EXPECT_TRUE(data1 == data4);
+
+  result = list->get(1, &data4);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+  EXPECT_TRUE(data3 == data4);
+
+  result = list->get(2, &data4);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+  EXPECT_TRUE(data2 == data4);
+
+  result = list->get(123, NULL);
+  EXPECT_TRUE(result == capu::CAPU_EINVAL);
+
+  delete list;
+}
+
+TEST(List, size) {
+  capu::List<capu::int32_t>* list = new capu::List<capu::int32_t > ();
+  capu::int32_t data1;
+  capu::int32_t data2;
+  capu::int32_t data3;
+
+  capu::int32_t result;
+
+  data1 = 32;
+  data2 = 43;
+  data3 = 56;
+
+  //size of empty list
+  result = list->size();
+  EXPECT_TRUE(result == 0);
+
+  //add some elements and check the size for each step
+  list->add(data1);
+  result = list->size();
+  EXPECT_TRUE(result == 1);
+
+  list->add(data1);
+  result = list->size();
+  EXPECT_TRUE(result == 2);
+
+  list->add(data1);
+  result = list->size();
+  EXPECT_TRUE(result == 3);
+
+  list->removeAt(0);
+  result = list->size();
+  EXPECT_TRUE(result == 2);
+
+  list->removeAt(1);
+  result = list->size();
+  EXPECT_TRUE(result == 1);
+
+  delete list;
+}
+
+TEST(List, empty) {
+  capu::List<capu::int32_t>* list = new capu::List<capu::int32_t > ();
+  capu::int32_t data1;
+  capu::int32_t data2;
+  capu::int32_t data3;
+
+  capu::bool_t result;
+
+  data1 = 32;
+  data2 = 43;
+  data3 = 56;
+
+  //check the empty list
+  result = list->isEmpty();
+  EXPECT_TRUE(result == true);
+
+  //add some element
+  list->add(data1);
+  result = list->isEmpty();
+  EXPECT_TRUE(result == false);
+
+  delete list;
+}
+
+TEST(List, find) {
+  capu::List<capu::int32_t>* list = new capu::List<capu::int32_t > ();
+  capu::int32_t data1;
+  capu::int32_t data2;
+  capu::int32_t data3;
+  capu::int32_t result;
+
+  data1 = 32;
+  data2 = 43;
+  data3 = 44;
+
+  //check empty list
+  result = list->find(data1);
+  EXPECT_TRUE(result == -1);
+
+  //add some elements
+  list->add(data1);
+  list->add(data2);
+  list->add(data3);
+
+  //find the elements
+  result = list->find(data1);
+  EXPECT_TRUE(result == 0);
+
+  result = list->find(data2);
+  EXPECT_TRUE(result == 1);
+
+  result = list->find(data3);
+  EXPECT_TRUE(result == 2);
+
+  delete list;
+}
+
+TEST(List, contains) {
+  capu::List<capu::int32_t>* list = new capu::List<capu::int32_t > ();
+  capu::int32_t data1;
+  capu::int32_t data2;
+  capu::int32_t data3;
+
+  capu::int32_t check_value = 0;
+  capu::bool_t result;
+
+  data1 = 32;
+  data2 = 43;
+  data3 = 44;
+
+  //check empty list
+  result = list->contains(check_value);
+  EXPECT_TRUE(result == false);
+
+  // fill the linke
+  list->add(data1);
+  list->add(data1);
+  list->add(data2);
+  list->add(data3);
+
+  //check an elements to be contained by linked list or not
+  result = list->contains(check_value);
+  EXPECT_TRUE(result == false);
+
+  result = list->contains(data3);
+  EXPECT_TRUE(result == true);
+
+  delete list;
+}
+
+TEST(List, clear) {
+  capu::List<capu::int32_t>* list = new capu::List<capu::int32_t > ();
+  capu::int32_t data1;
+  capu::int32_t data2;
+  capu::int32_t data3;
+  capu::status_t result;
+
+  data1 = 32;
+  data2 = 43;
+  data3 = 44;
+
+  //add some dummy values to the linked list
+  list->add(data1);
+  list->add(data1);
+  list->add(data2);
+  list->add(data3);
+
+  //remove all elements from the linked list
+  result = list->clear();
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  result = list->add(data1);
+  EXPECT_TRUE(result == capu::CAPU_OK);
+
+  result = list->get(0, &data2);
+  EXPECT_TRUE(data1 == data2);
+  delete list;
+}
+
+TEST(List, set) {
+  capu::List<capu::int32_t>* list = new capu::List<capu::int32_t > ();
+  capu::int32_t data1;
+  capu::int32_t data2;
+
+  data1 = 32;
+  data2 = 43;
+
+  EXPECT_TRUE(list->add(data1) == capu::CAPU_OK);
+  EXPECT_TRUE(list->add(data2) == capu::CAPU_OK);
+  EXPECT_TRUE(list->set(1, data1) == capu::CAPU_OK);
+  EXPECT_TRUE(list->set(0, data1) == capu::CAPU_OK);
+  EXPECT_TRUE(list->get(1, &data2) == capu::CAPU_OK);
+  EXPECT_TRUE(list->set(2, data1) == capu::CAPU_EINVAL);
+  EXPECT_TRUE(data2 == data1);
+  delete list;
+}
+
+TEST(ListIterator, hasNext) {
+  capu::List<capu::int32_t>* list = new capu::List<capu::int32_t > ();
+  capu::int32_t data1;
+  capu::int32_t data2;
+  capu::List<capu::int32_t>::Iterator it = list->begin();
+  EXPECT_TRUE(it.hasNext() == false);
+
+  data1 = 32;
+  data2 = 43;
+
+  list->add(data1);
+  list->add(data2);
+
+  it = list->begin();
+  capu::bool_t resultb = it.hasNext();
+  EXPECT_TRUE(resultb == true);
+  delete list;
+}
+
+TEST(ListIterator, next) {
+  capu::List<capu::int32_t>* list = new capu::List<capu::int32_t > ();
+  capu::int32_t data1;
+  capu::int32_t data2;
+  capu::int32_t data3;
+  capu::List<capu::int32_t>::Iterator it = list->begin();
+  int cnt = 0;
+  EXPECT_TRUE(it.hasNext() == false);
+  data1 = 32;
+  data2 = 43;
+  list->add(data1);
+  list->add(data2);
+  it = list->begin();
+  while (it.hasNext()) {
+    it.next(&data3);
+    if (cnt == 0)
+      EXPECT_TRUE(data3 == data1);
+    else
+      EXPECT_TRUE(data3 == data2);
+    cnt++;
+  }
+  delete list;
+}
+