container_test Namespace Reference

Unit tests for the container namespace based on the googletest framework. More...


Classes

class  Entity_test
 Unit tests for Entity. More...
class  List_test
 Polymorphic code for testing concrete sub-classes of container::List. More...
class  OrderedArrayList_test
 Test cases for concrete class container::OrderedArrayList. More...
class  OrderedLinkedList_test
 Test cases for concrete class container::OrderedLinkedList. More...
class  OrderedList_test
 Polymorphic code for testing concrete sub-classes of container::OrderedList. More...
class  Person
 A type of Entity that represents a person. More...
class  QueueImpl_test
 Unit tests for QueueImpl. More...
class  SortedArrayList_test
 Unit tests for SortedArrayList. More...
class  SortedLinkedList_test
 Unit tests for SortedLinkedList. More...
class  SortedList_test
 Polymorphic code for testing concrete sub-classes of container::SortedList. More...
class  StackImpl_test
 Unit tests for StackImpl. More...

Functions

 TEST_F (Entity_test, DefaultConstructor)
 TEST_F (Entity_test, AssignmentOperator)
 TEST_F (Entity_test, CopyConstructor)
 TEST_F (OrderedArrayList_test, DefaultConstructor)
 TEST_F (OrderedArrayList_test, append)
 TEST_F (OrderedArrayList_test, cursorControl)
 TEST_F (OrderedArrayList_test, insertingAndRemoving)
 TEST_F (OrderedArrayList_test, purgeConents)
 TEST_F (OrderedArrayList_test, locateEntity)
 TEST_F (OrderedArrayList_test, entityAt)
 TEST_F (OrderedLinkedList_test, DefaultConstructor)
 TEST_F (OrderedLinkedList_test, append)
 TEST_F (OrderedLinkedList_test, cursorControl)
 TEST_F (OrderedLinkedList_test, insertingAndRemoving)
 TEST_F (OrderedLinkedList_test, purgeConents)
 TEST_F (OrderedLinkedList_test, locateEntity)
 TEST_F (OrderedLinkedList_test, entityAt)
 TEST_F (QueueImpl_test, factories)
 TEST_F (QueueImpl_test, enqueueDequeueLinked)
 TEST_F (QueueImpl_test, enqueueDequeueArray)
 TEST_F (QueueImpl_test, purgeContentsLinked)
 TEST_F (QueueImpl_test, purgeContentsArray)
 TEST_F (QueueImpl_test, shallowVersusDeepArray)
 TEST_F (SortedArrayList_test, DefaultConstructor)
 TEST_F (SortedArrayList_test, cursorControl)
 TEST_F (SortedArrayList_test, insertSorted)
 TEST_F (SortedArrayList_test, insertingAndRemoving)
 TEST_F (SortedArrayList_test, purgeConents)
 TEST_F (SortedArrayList_test, locateEntity)
 TEST_F (SortedArrayList_test, entityAt)
 TEST_F (SortedLinkedList_test, DefaultConstructor)
 TEST_F (SortedLinkedList_test, cursorControl)
 TEST_F (SortedLinkedList_test, insertSorted)
 TEST_F (SortedLinkedList_test, insertingAndRemoving)
 TEST_F (SortedLinkedList_test, purgeConents)
 TEST_F (SortedLinkedList_test, locateEntity)
 TEST_F (SortedLinkedList_test, entityAt)
 TEST_F (StackImpl_test, factories)
 TEST_F (StackImpl_test, pushPopLinked)
 TEST_F (StackImpl_test, pushPopArray)
 TEST_F (StackImpl_test, purgeContentsLinked)
 TEST_F (StackImpl_test, purgeContentsArray)
ListlistFactory (const Object::Info *type)
 Create one of the known concrete classes ultimately derived from container::List.
OrderedListorderedListFactory (const Object::Info *type)
 Create one of the known concrete classes derived from container::OrderedList.
SortedListsortedListFactory (const Object::Info *type)
 Create one of the known concrete classes derived from container::SortedList.


Detailed Description

Unit tests for the container namespace based on the googletest framework.


Function Documentation

List * container_test::listFactory ( const Object::Info type  ) 

Create one of the known concrete classes ultimately derived from container::List.

00048                                           {
00049    List *list = orderedListFactory(type);
00050    if (list != NULL) {
00051       return list;
00052    }
00053 
00054    return sortedListFactory(type);
00055 }

Here is the call graph for this function:

Here is the caller graph for this function:

OrderedList * container_test::orderedListFactory ( const Object::Info type  ) 

Create one of the known concrete classes derived from container::OrderedList.

00057                                                         {
00058    if (type == OrderedLinkedList::TYPE_INFO) {
00059       return new OrderedLinkedList();
00060    } else if (type == OrderedArrayList::TYPE_INFO) {
00061       return new OrderedArrayList();
00062    } else {
00063       return NULL;
00064    }
00065 }

Here is the caller graph for this function:

SortedList * container_test::sortedListFactory ( const Object::Info type  ) 

Create one of the known concrete classes derived from container::SortedList.

00067                                                       {
00068    if (type == SortedLinkedList::TYPE_INFO) {
00069       return new SortedLinkedList();
00070    } else if (type == SortedArrayList::TYPE_INFO) {
00071       return new SortedArrayList();
00072    } else {
00073       return NULL;
00074    }
00075 }

Here is the caller graph for this function:

container_test::TEST_F ( StackImpl_test  ,
purgeContentsArray   
)

00268                                            {
00269    purgeContentsTest(StackImpl::factoryArrayComposition());
00270 }

container_test::TEST_F ( StackImpl_test  ,
purgeContentsLinked   
)

00264                                             {
00265    purgeContentsTest(StackImpl::factoryLinkedComposition());
00266 }

container_test::TEST_F ( StackImpl_test  ,
pushPopArray   
)

00260                                      {
00261    pushPopTest(StackImpl::factoryArrayComposition());
00262 }

container_test::TEST_F ( StackImpl_test  ,
pushPopLinked   
)

00256                                       {
00257    pushPopTest(StackImpl::factoryLinkedComposition());
00258 }

container_test::TEST_F ( StackImpl_test  ,
factories   
)

00211                                   {
00212 
00213    cout << "Factory creation of a stack composed with an underlying linked list" << endl;
00214    Stack* sLinked = StackImpl::factoryLinkedComposition();
00215    EXPECT_EQ(StackImpl::TYPE_INFO, sLinked->typeInfo());
00216    cout << "   " << sLinked << endl;
00217 
00218    cout << "Factory creation of a stack composed with an underlying array list" << endl;
00219    Stack* sArray = StackImpl::factoryArrayComposition();
00220    EXPECT_EQ(StackImpl::TYPE_INFO, sArray->typeInfo());
00221    cout << "   " << sArray << endl;
00222 
00223    verifyStackCoherence(sLinked);
00224    verifyStackCoherence(sArray);
00225 
00226    Person* p = new Person("Leo", "Tolstoy");
00227 
00228    sLinked->push(p);
00229    sArray->push(p);
00230 
00231    cout << "Both stacks loaded with the same Person object" << endl;
00232    cout << "   " << sLinked << endl;
00233    cout << "   " << sArray << endl;
00234 
00235    verifyStackCoherence(sLinked, 1);
00236    verifyStackCoherence(sArray, 1);
00237 
00238    Entity* p2 = sLinked->pop();
00239    Entity* p3 = sArray->pop();
00240 
00241    EXPECT_EQ(p, p2);
00242    EXPECT_EQ(p, p3);
00243 
00244    cout << "Both with the Person popped" << endl;
00245    cout << "   " << sLinked << endl;
00246    cout << "   " << sArray << endl;
00247 
00248    verifyStackCoherence(sLinked);
00249    verifyStackCoherence(sArray);
00250 
00251    delete p;
00252    delete sLinked;
00253    delete sArray;
00254 }

Here is the call graph for this function:

container_test::TEST_F ( SortedLinkedList_test  ,
entityAt   
)

00094                                         {
00095    locateEntity(SortedLinkedList::TYPE_INFO);
00096 }

container_test::TEST_F ( SortedLinkedList_test  ,
locateEntity   
)

00090                                             {
00091    locateEntity(SortedLinkedList::TYPE_INFO);
00092 }

container_test::TEST_F ( SortedLinkedList_test  ,
purgeConents   
)

00086                                             {
00087    purgeConents(SortedLinkedList::TYPE_INFO);
00088 }

container_test::TEST_F ( SortedLinkedList_test  ,
insertingAndRemoving   
)

00082                                                     {
00083    insertingAndRemoving(SortedLinkedList::TYPE_INFO);
00084 }

container_test::TEST_F ( SortedLinkedList_test  ,
insertSorted   
)

00078                                             {
00079    insertSorted(SortedLinkedList::TYPE_INFO);
00080 }

container_test::TEST_F ( SortedLinkedList_test  ,
cursorControl   
)

00074                                              {
00075    cursorControl(SortedLinkedList::TYPE_INFO);
00076 }

container_test::TEST_F ( SortedLinkedList_test  ,
DefaultConstructor   
)

00070                                                   {
00071    defaultConstructor(SortedLinkedList::TYPE_INFO);
00072 }

container_test::TEST_F ( SortedArrayList_test  ,
entityAt   
)

00096                                        {
00097    locateEntity(SortedArrayList::TYPE_INFO);
00098 }

container_test::TEST_F ( SortedArrayList_test  ,
locateEntity   
)

00092                                            {
00093    locateEntity(SortedArrayList::TYPE_INFO);
00094 }

container_test::TEST_F ( SortedArrayList_test  ,
purgeConents   
)

00088                                            {
00089    purgeConents(SortedArrayList::TYPE_INFO);
00090 }

container_test::TEST_F ( SortedArrayList_test  ,
insertingAndRemoving   
)

00084                                                    {
00085    insertingAndRemoving(SortedArrayList::TYPE_INFO);
00086 }

container_test::TEST_F ( SortedArrayList_test  ,
insertSorted   
)

00080                                            {
00081    insertSorted(SortedArrayList::TYPE_INFO);
00082 }

container_test::TEST_F ( SortedArrayList_test  ,
cursorControl   
)

00076                                             {
00077    cursorControl(SortedArrayList::TYPE_INFO);
00078 }

container_test::TEST_F ( SortedArrayList_test  ,
DefaultConstructor   
)

00072                                                  {
00073    defaultConstructor(SortedArrayList::TYPE_INFO);
00074 }

container_test::TEST_F ( QueueImpl_test  ,
shallowVersusDeepArray   
)

00344                                                {
00345    shallowVersusDeepTest(QueueImpl::factoryArrayComposition());
00346 }

container_test::TEST_F ( QueueImpl_test  ,
purgeContentsArray   
)

00340                                            {
00341    purgeContentsTest(QueueImpl::factoryArrayComposition());
00342 }

container_test::TEST_F ( QueueImpl_test  ,
purgeContentsLinked   
)

00336                                             {
00337    purgeContentsTest(QueueImpl::factoryLinkedComposition());
00338 }

container_test::TEST_F ( QueueImpl_test  ,
enqueueDequeueArray   
)

00332                                             {
00333    enqueueDequeueTest(QueueImpl::factoryArrayComposition());
00334 }

container_test::TEST_F ( QueueImpl_test  ,
enqueueDequeueLinked   
)

00328                                              {
00329    enqueueDequeueTest(QueueImpl::factoryLinkedComposition());
00330 }

container_test::TEST_F ( QueueImpl_test  ,
factories   
)

00283                                   {
00284 
00285    cout << "Factory creation of a queue composed with an underlying linked list" << endl;
00286    Queue* qLinked = QueueImpl::factoryLinkedComposition();
00287    EXPECT_EQ(QueueImpl::TYPE_INFO, qLinked->typeInfo());
00288    cout << "   " << qLinked << endl;
00289 
00290    cout << "Factory creation of a queue composed with an underlying array list" << endl;
00291    Queue* qArray = QueueImpl::factoryArrayComposition();
00292    EXPECT_EQ(QueueImpl::TYPE_INFO, qArray->typeInfo());
00293    cout << "   " << qArray << endl;
00294 
00295    verifyQueueCoherence(qLinked);
00296    verifyQueueCoherence(qArray);
00297 
00298    Person* p = new Person("Herman", "Melville");
00299 
00300    qLinked->enqueue(p);
00301    qArray->enqueue(p);
00302 
00303    cout << "Both queues loaded with the same Person object" << endl;
00304    cout << "   " << qLinked << endl;
00305    cout << "   " << qArray << endl;
00306 
00307    verifyQueueCoherence(qLinked, 1);
00308    verifyQueueCoherence(qArray, 1);
00309 
00310    Entity* p2 = qLinked->dequeue();
00311    Entity* p3 = qArray->dequeue();
00312 
00313    EXPECT_EQ(p, p2);
00314    EXPECT_EQ(p, p3);
00315 
00316    cout << "Both with the Person dequeued" << endl;
00317    cout << "   " << qLinked << endl;
00318    cout << "   " << qArray << endl;
00319 
00320    verifyQueueCoherence(qLinked);
00321    verifyQueueCoherence(qArray);
00322 
00323    delete p;
00324    delete qLinked;
00325    delete qArray;
00326 }

Here is the call graph for this function:

container_test::TEST_F ( OrderedLinkedList_test  ,
entityAt   
)

00073                                          {
00074    locateEntity(OrderedLinkedList::TYPE_INFO);
00075 }

container_test::TEST_F ( OrderedLinkedList_test  ,
locateEntity   
)

00069                                              {
00070    locateEntity(OrderedLinkedList::TYPE_INFO);
00071 }

container_test::TEST_F ( OrderedLinkedList_test  ,
purgeConents   
)

00065                                              {
00066    purgeConents(OrderedLinkedList::TYPE_INFO);
00067 }

container_test::TEST_F ( OrderedLinkedList_test  ,
insertingAndRemoving   
)

00061                                                      {
00062    insertingAndRemoving(OrderedLinkedList::TYPE_INFO);
00063 }

container_test::TEST_F ( OrderedLinkedList_test  ,
cursorControl   
)

00057                                               {
00058    cursorControl(OrderedLinkedList::TYPE_INFO);
00059 }

container_test::TEST_F ( OrderedLinkedList_test  ,
append   
)

00053                                        {
00054    append(OrderedLinkedList::TYPE_INFO);
00055 }

container_test::TEST_F ( OrderedLinkedList_test  ,
DefaultConstructor   
)

00049                                                    {
00050    defaultConstructor(OrderedLinkedList::TYPE_INFO);
00051 }

container_test::TEST_F ( OrderedArrayList_test  ,
entityAt   
)

00078                                         {
00079    locateEntity(OrderedArrayList::TYPE_INFO);
00080 }

container_test::TEST_F ( OrderedArrayList_test  ,
locateEntity   
)

00074                                             {
00075    locateEntity(OrderedArrayList::TYPE_INFO);
00076 }

container_test::TEST_F ( OrderedArrayList_test  ,
purgeConents   
)

00070                                             {
00071    purgeConents(OrderedArrayList::TYPE_INFO);
00072 }

container_test::TEST_F ( OrderedArrayList_test  ,
insertingAndRemoving   
)

00066                                                     {
00067    insertingAndRemoving(OrderedArrayList::TYPE_INFO);
00068 }

container_test::TEST_F ( OrderedArrayList_test  ,
cursorControl   
)

00062                                              {
00063    cursorControl(OrderedArrayList::TYPE_INFO);
00064 }

container_test::TEST_F ( OrderedArrayList_test  ,
append   
)

00058                                       {
00059    append(OrderedArrayList::TYPE_INFO);
00060 }

container_test::TEST_F ( OrderedArrayList_test  ,
DefaultConstructor   
)

00054                                                   {
00055    defaultConstructor(OrderedArrayList::TYPE_INFO);
00056 }

container_test::TEST_F ( Entity_test  ,
CopyConstructor   
)

00178                                      {
00179    Entity b;
00180    copyConstructorTestCore(b);
00181 
00182    Entity c;
00183    c.getKeyAsString(); // force member keyAsString to lazy initialize
00184    copyConstructorTestCore(c);
00185 }

Here is the call graph for this function:

container_test::TEST_F ( Entity_test  ,
AssignmentOperator   
)

00156                                         {
00157    Entity a;
00158    Entity b;
00159    assignmentOperatorTestCore(a, b);
00160 
00161    Entity c;
00162    Entity d;
00163    c.getKeyAsString(); // force member keyAsString to lazy initialize
00164    assignmentOperatorTestCore(c, d);
00165 
00166    Entity e;
00167    Entity f;
00168    f.getKeyAsString(); // force member keyAsString to lazy initialize
00169    assignmentOperatorTestCore(e, f);
00170 
00171    Entity g;
00172    Entity h;
00173    g.getKeyAsString(); // force member keyAsString to lazy initialize
00174    h.getKeyAsString(); // force member keyAsString to lazy initialize
00175    assignmentOperatorTestCore(g, h);
00176 }

Here is the call graph for this function:

container_test::TEST_F ( Entity_test  ,
DefaultConstructor   
)

00124                                         {
00125 
00126    // Null check, probably not necessary, but I'm just trying to figure
00127    // out this new framework.
00128    Entity* a = new Entity();
00129    Entity* n = NULL;
00130    EXPECT_NE(n, a);
00131 
00132    // I'm relearning the language. Just making sure I understand what's
00133    // going on. a and b should be pointing to two different places.
00134    Entity* b = new Entity();
00135    EXPECT_NE(a, b);
00136 
00137    // A real test. Each Entity should have a unique key.
00138    cout << "Constructor should assign a unique key automatically" << endl;
00139    cout << "a " << *a << endl;
00140    cout << "b " << *b << endl;
00141    EXPECT_FALSE(a->compareKeyTo(*b) == 0);
00142 
00143    Entity c;
00144    Entity d;
00145 
00146    // Testing my understanding if C++ again. I think the default constructor
00147    // is called automatically for c an d.
00148    cout << "c " << c << endl;
00149    cout << "d " << d << endl;
00150    EXPECT_FALSE(c.compareKeyTo(d) == 0);
00151 
00152    delete a;
00153    delete b;
00154 }

Here is the call graph for this function:


Generated on Tue Jun 16 23:13:02 2009 by  doxygen 1.5.9