LCOV - code coverage report
Current view: top level - tests - any.cpp (source / functions) Hit Total Coverage
Test: Lunchbox Lines: 23 23 100.0 %
Date: 2016-03-29 17:09:06 Functions: 3 3 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2012, Daniel Nachbaur <danielnachbaur@gmail.com>
       3             :  *
       4             :  * This library is free software; you can redistribute it and/or modify it under
       5             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       6             :  * by the Free Software Foundation.
       7             :  *
       8             :  * This library is distributed in the hope that it will be useful, but WITHOUT
       9             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      10             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      11             :  * details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      15             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      16             :  */
      17             : 
      18             : #include "test.h"
      19             : 
      20             : #include <lunchbox/any.h>
      21             : 
      22           1 : int main( int, char** )
      23             : {
      24           1 :     lunchbox::Any any;
      25           2 :     lunchbox::Any otherAny;
      26           1 :     TEST( any.empty( ));
      27           1 :     TEST( any.type() == typeid(void));
      28           1 :     TEST( any == otherAny );
      29             : 
      30           1 :     any = 5;
      31           1 :     otherAny = any;
      32           1 :     TEST( lunchbox::any_cast< int >( any ) == 5 );
      33           1 :     TEST( any.type() == typeid(int));
      34           1 :     TEST( any == otherAny );
      35             : 
      36           1 :     any = 42;
      37           1 :     otherAny = 42;
      38           1 :     TEST( lunchbox::any_cast< int >( any ) == 42 );
      39           1 :     TEST( any == otherAny );
      40             : 
      41           1 :     any = std::string( "blablub" );
      42           1 :     TEST( lunchbox::any_cast< std::string >( any ) == "blablub" );
      43           1 :     TEST( any.type() == typeid(std::string));
      44           1 :     TEST( any != otherAny );
      45             : 
      46           1 :     try { TEST( lunchbox::any_cast< int >( any ) != 42 ); }
      47           1 :     catch( const lunchbox::bad_any_cast& ) {}
      48             : 
      49           2 :     return EXIT_SUCCESS;
      50           3 : }

Generated by: LCOV version 1.11