tests/test_version.cpp

Go to the documentation of this file.
00001 /* $Id: test_version.cpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2008 - 2012 by Ignacio R. Morelle <shadowm2006@gmail.com>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #define GETTEXT_DOMAIN "wesnoth-test"
00017 
00018 #include <boost/test/unit_test.hpp>
00019 #include "version.hpp"
00020 
00021 BOOST_AUTO_TEST_SUITE( version )
00022 
00023 BOOST_AUTO_TEST_CASE( test_version_info )
00024 {
00025     version_info invalid(0,0,0,false,'!',"d'oh");
00026 
00027     BOOST_CHECK( !invalid.good() );
00028 
00029     version_info canonical("1.2.3");
00030 
00031     BOOST_CHECK( canonical.is_canonical() );
00032 
00033     version_info canonical_suffixed("1.2.3+svn");
00034 
00035     BOOST_CHECK( canonical_suffixed > canonical );
00036     BOOST_CHECK( canonical < canonical_suffixed );
00037 
00038     version_info non_canonical("1.2.3.4.5.7.8.9");
00039 
00040     BOOST_CHECK( !non_canonical.is_canonical() );
00041 
00042     version_info non_canonical_suffixed("1.2.3.4.5.7.8.9+svn");
00043 
00044     BOOST_CHECK( non_canonical_suffixed > non_canonical );
00045     BOOST_CHECK( non_canonical < non_canonical_suffixed );
00046 
00047     version_info right_zero("1.2.0");
00048     version_info no_right_zero("1.2");
00049 
00050     BOOST_CHECK( right_zero == no_right_zero );
00051 
00052     version_info left_zero("0.1.4");
00053     version_info no_left_zero("1.4");
00054 
00055     BOOST_CHECK( left_zero != no_left_zero );
00056 
00057     const std::string bad_version_info_string_1 = "Viva la revolución!";
00058     const std::string bad_version_info_string_2 = "To infinity and beyond!";
00059 
00060     const version_info bad_version_info1( bad_version_info_string_1 );
00061     const version_info bad_version_info2( bad_version_info_string_2 );
00062 
00063     BOOST_CHECK( bad_version_info1.str() == ("0.0.0"+bad_version_info_string_1) );
00064     BOOST_CHECK( bad_version_info2.str() == ("0.0.0"+bad_version_info_string_2) );
00065 
00066     version_info somewhat_complex("1.5.10-1.6beta2");
00067     BOOST_CHECK( somewhat_complex.major_version() == 1 && somewhat_complex.minor_version() == 5 && somewhat_complex.revision_level() == 10 && somewhat_complex.special_version() == "1.6beta2" && somewhat_complex.special_version_separator() == '-' );
00068 }
00069 
00070 BOOST_AUTO_TEST_SUITE_END()
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:12 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs