Author: zaroth
Date: Thu Jun 9 11:52:35 2011
New Revision: 49805
URL: http://svn.gna.org/viewcvs/wesnoth?rev=49805&view=rev
Log:
completed unit test to current functionality and fixed a few options on
the way
Modified:
trunk/src/commandline_options.cpp
trunk/src/tests/test_commandline_options.cpp
Modified: trunk/src/commandline_options.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/commandline_options.cpp?rev=49805&r1=49804&r2=49805&view=diff
==============================================================================
--- trunk/src/commandline_options.cpp (original)
+++ trunk/src/commandline_options.cpp Thu Jun 9 11:52:35 2011
@@ -6,7 +6,7 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ (at your option) any lfooater version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
@@ -111,7 +111,7 @@
display_opts.add_options()
("bpp", po::value<int>(), "sets BitsPerPixel value. Example:
--bpp 32")
("fps", "displays the number of frames per second the game is
currently running at, in a corner of the screen.")
- ("max-fps", "the maximum fps the game tries to run at. Values
should be between 1 and 1000, the default is 50.")
+ ("max-fps", po::value<int>(), "the maximum fps the game tries
to run at. Values should be between 1 and 1000, the default is 50.")
;
po::options_description multiplayer_opts("Multiplayer options");
@@ -121,7 +121,7 @@
;
hidden_.add_options()
- ("new_storyscreens", "")
+ ("new-storyscreens", "")
("new-widgets", "")
;
visible_.add(general_opts).add(display_opts).add(multiplayer_opts);
@@ -133,7 +133,6 @@
if (vm.count("ai-config"))
multiplayer_ai_config =
parse_to_int_string_tuples_(vm["ai-config"].as<std::vector<std::string> >());
-
if (vm.count("bpp"))
bpp = vm["bpp"].as<int>();
if (vm.count("config-dir"))
Modified: trunk/src/tests/test_commandline_options.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/test_commandline_options.cpp?rev=49805&r1=49804&r2=49805&view=diff
==============================================================================
--- trunk/src/tests/test_commandline_options.cpp (original)
+++ trunk/src/tests/test_commandline_options.cpp Thu Jun 9 11:52:35 2011
@@ -22,8 +22,8 @@
BOOST_AUTO_TEST_CASE (test_empty_options)
{
- int argc = 1;
const char *argv[] = {"wesnoth"};
+ const int argc = sizeof(argv)/sizeof(const char *);
commandline_options co(argc,const_cast<char**>(argv));
BOOST_CHECK(!co.bpp);
@@ -93,4 +93,101 @@
}
+BOOST_AUTO_TEST_CASE (test_full_options)
+{
+ const char *argv[] =
+ {
+ "wesnoth",
+ "--ai-config=1:aifoo",
+ "--ai-config=2:aibar",
+ "--bpp=32",
+ "--config-dir=configdirfoo",
+ "--data-dir=datadirfoo",
+ "--debug",
+ "--fps",
+ "--help",
+ "--load=loadfoo",
+ "--max-fps=100",
+ "--multiplayer",
+ "--new-storyscreens",
+ "--new-syntax",
+ "--new-widgets",
+ "--nocache",
+ "--path",
+ "--validcache",
+ "--version",
+ "--with-replay"
+ };
+ const int argc = sizeof(argv)/sizeof(const char *);
+ commandline_options co(argc,const_cast<char**>(argv));
+
+ BOOST_CHECK(co.bpp && *co.bpp == 32);
+ BOOST_CHECK(!co.campaign);
+ BOOST_CHECK(!co.campaign_difficulty);
+ BOOST_CHECK(!co.campaign_scenario);
+ BOOST_CHECK(!co.clock);
+ BOOST_CHECK(!co.config_path);
+ BOOST_CHECK(co.config_dir && *co.config_dir == "configdirfoo");
+ BOOST_CHECK(co.data_dir && *co.data_dir == "datadirfoo");
+ BOOST_CHECK(co.debug);
+#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
+ BOOST_CHECK(!co.debug_dot_level);
+ BOOST_CHECK(!co.debug_dot_domain);
+#endif
+ BOOST_CHECK(!co.editor);
+ BOOST_CHECK(co.fps);
+ BOOST_CHECK(!co.fullscreen);
+ BOOST_CHECK(!co.gunzip);
+ BOOST_CHECK(!co.gzip);
+ BOOST_CHECK(co.help);
+ BOOST_CHECK(!co.log);
+ BOOST_CHECK(co.load && *co.load == "loadfoo");
+ BOOST_CHECK(!co.logdomains);
+ BOOST_CHECK(co.multiplayer);
+ BOOST_CHECK(co.multiplayer_ai_config);
+ BOOST_CHECK((*co.multiplayer_ai_config).size() == 2);
+ BOOST_CHECK((*co.multiplayer_ai_config)[0].get<0>() == 1 &&
(*co.multiplayer_ai_config)[0].get<1>() == "aifoo");
+ BOOST_CHECK((*co.multiplayer_ai_config)[1].get<0>() == 2 &&
(*co.multiplayer_ai_config)[1].get<1>() == "aibar");
+ BOOST_CHECK(!co.multiplayer_algorithm);
+ BOOST_CHECK(!co.multiplayer_controller);
+ BOOST_CHECK(!co.multiplayer_era);
+ BOOST_CHECK(!co.multiplayer_label);
+ BOOST_CHECK(!co.multiplayer_parm);
+ BOOST_CHECK(!co.multiplayer_side);
+ BOOST_CHECK(!co.multiplayer_turns);
+ BOOST_CHECK(co.max_fps && *co.max_fps == 100);
+ BOOST_CHECK(co.nocache);
+ BOOST_CHECK(!co.nodelay);
+ BOOST_CHECK(!co.nogui);
+ BOOST_CHECK(!co.nomusic);
+ BOOST_CHECK(!co.nosound);
+ BOOST_CHECK(co.new_storyscreens);
+ BOOST_CHECK(co.new_syntax);
+ BOOST_CHECK(co.new_widgets);
+ BOOST_CHECK(co.path);
+ BOOST_CHECK(!co.preprocess);
+ BOOST_CHECK(!co.preprocess_defines);
+ BOOST_CHECK(!co.preprocess_input_macros);
+ BOOST_CHECK(!co.preprocess_output_macros);
+ BOOST_CHECK(!co.preprocess_path);
+ BOOST_CHECK(!co.preprocess_target);
+ BOOST_CHECK(!co.proxy);
+ BOOST_CHECK(!co.proxy_address);
+ BOOST_CHECK(!co.proxy_password);
+ BOOST_CHECK(!co.proxy_port);
+ BOOST_CHECK(!co.proxy_user);
+ BOOST_CHECK(!co.resolution);
+ BOOST_CHECK(!co.rng_seed);
+ BOOST_CHECK(!co.server);
+ BOOST_CHECK(!co.screenshot);
+ BOOST_CHECK(!co.screenshot_map_file);
+ BOOST_CHECK(!co.screenshot_output_file);
+ BOOST_CHECK(!co.smallgui);
+ BOOST_CHECK(!co.test);
+ BOOST_CHECK(co.validcache);
+ BOOST_CHECK(co.version);
+ BOOST_CHECK(!co.windowed);
+ BOOST_CHECK(co.with_replay);
+}
+
BOOST_AUTO_TEST_SUITE_END()
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits