Ssrc C++ Binding for Spread 1.0.6 Unit Test Coverage
Current view: top level - tests/spread - GroupListTest.cc (source / functions) Hit Total Coverage
Test: Ssrc C++/Lua/Perl/Python/Ruby Bindings for Spread 1.0.6 Unit Tests Lines: 44 44 100.0 %
Date: 2010-05-26 Functions: 15 16 93.8 %
Branches: 204 416 49.0 %

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