Savarese Software Research CorporationSava C++ Binding for Spread 1.0.2 Unit Test Coverage
Current view: directory - tests/spread - GroupListTest.cc
Test: Sava C++/Lua/Perl/Python/Ruby Bindings for Spread 1.0.2 C++ Unit Tests
Date: 2008-04-13 Instrumented lines: 45
Code covered: 100.0 % Executed lines: 45

       1                 : /*
       2                 :  * $Id: GroupListTest.cc 362 2006-09-26 17:16:34Z dfs $
       3                 :  *
       4                 :  * Copyright 2006 Savarese Software Research Corporation
       5                 :  *
       6                 :  * Licensed under the Apache License, Version 2.0 (the "License");
       7                 :  * you may not use this file except in compliance with the License.
       8                 :  * You may obtain a copy of the License at
       9                 :  *
      10                 :  *     http://www.savarese.com/software/ApacheLicense-2.0
      11                 :  *
      12                 :  * Unless required by applicable law or agreed to in writing, software
      13                 :  * distributed under the License is distributed on an "AS IS" BASIS,
      14                 :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      15                 :  * See the License for the specific language governing permissions and
      16                 :  * limitations under the License.
      17                 :  */
      18                 : 
      19                 : #include <tests/TestCommon.h>
      20                 : 
      21                 : using namespace std::rel_ops;
      22                 : 
      23               6 : class GroupListTest : public TestCase {
      24                 : 
      25                 :   GroupList *groups;
      26                 : 
      27                 : public:
      28                 : 
      29               3 :   virtual void setUp() {
      30               3 :     groups = new GroupList();
      31               3 :   }
      32                 : 
      33               3 :   virtual void tearDown() {
      34               3 :     delete groups;
      35               3 :     groups = 0;
      36               3 :   }
      37                 : 
      38               1 :   void test_add() {
      39               1 :     CPPUNIT_ASSERT_EQUAL(0u, groups->size());
      40               2 :     groups->add("foo");
      41               2 :     CPPUNIT_ASSERT_EQUAL(1u, groups->size());
      42               2 :     CPPUNIT_ASSERT((*groups)[0] == "foo");
      43               2 :     groups->add("bar");
      44               2 :     CPPUNIT_ASSERT_EQUAL(2u, groups->size());
      45               2 :     CPPUNIT_ASSERT(groups->group(1) == "bar");
      46               1 :   }
      47                 : 
      48               1 :   void test_add_group_list() {
      49               1 :     groups->add("foo");
      50               2 :     groups->add("bar");
      51                 : 
      52               1 :     GroupList g;
      53                 : 
      54               2 :     g.add("foobar");
      55               2 :     g.add("blah");
      56               2 :     g.add("blargh");
      57                 : 
      58               1 :     groups->add(g);
      59                 : 
      60               1 :     CPPUNIT_ASSERT_EQUAL(5u, groups->size());
      61               2 :     CPPUNIT_ASSERT(groups->group(4) == "blargh" && groups->group(1) == "bar");
      62                 : 
      63               2 :     CPPUNIT_ASSERT(g != *groups);
      64                 : 
      65               1 :     groups->clear();
      66               1 :     groups->add(g);
      67                 : 
      68               1 :     CPPUNIT_ASSERT(g == *groups);
      69               1 :   }
      70                 : 
      71               1 :   void test_split_private_group() {
      72               1 :     std::pair<string,string> name = split_private_group("#foo#bar");
      73               2 :     CPPUNIT_ASSERT("foo" == name.first);
      74               2 :     CPPUNIT_ASSERT("bar" == name.second);
      75               1 :   }
      76                 : 
      77               3 :   CPPUNIT_TEST_SUITE(GroupListTest);
      78               1 :   CPPUNIT_TEST(test_add);
      79               2 :   CPPUNIT_TEST(test_add_group_list);
      80               2 :   CPPUNIT_TEST(test_split_private_group);
      81               2 :   CPPUNIT_TEST_SUITE_END();
      82                 : };
      83                 : 
      84               2 : CPPUNIT_TEST_SUITE_REGISTRATION(GroupListTest);
      85               3 : LIBSAVASPREAD_TEST_MAIN()

Savarese Software Research Corporation