Ssrc C++ Binding for Spread 1.0.9 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.9 Unit Tests Lines: 38 38 100.0 %
Date: 2011-05-11 Functions: 16 16 100.0 %
Branches: 121 246 49.2 %

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