mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 18:42:41 +01:00
integrated changes from main repository for upcoming 1.2.5 release
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// OptionSetTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Util/testsuite/src/OptionSetTest.cpp#1 $
|
||||
// $Id: //poco/1.2/Util/testsuite/src/OptionSetTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@@ -55,6 +55,14 @@ OptionSetTest::~OptionSetTest()
|
||||
void OptionSetTest::testOptionSet()
|
||||
{
|
||||
OptionSet set;
|
||||
set.addOption(
|
||||
Option("helper", "H", "start helper")
|
||||
.required(false)
|
||||
.repeatable(false));
|
||||
set.addOption(
|
||||
Option("help", "h", "print help text")
|
||||
.required(false)
|
||||
.repeatable(false));
|
||||
set.addOption(
|
||||
Option("include-dir", "I", "specify a search path for locating header files")
|
||||
.required(false)
|
||||
@@ -65,19 +73,22 @@ void OptionSetTest::testOptionSet()
|
||||
.required(false)
|
||||
.repeatable(true)
|
||||
.argument("path"));
|
||||
|
||||
set.addOption(
|
||||
Option("insert", "it", "insert something")
|
||||
.required(false)
|
||||
.repeatable(true)
|
||||
.argument("path"));
|
||||
|
||||
set.addOption(
|
||||
Option("item", "", "insert something")
|
||||
.required(false)
|
||||
.repeatable(true)
|
||||
.argument("path"));
|
||||
|
||||
set.addOption(
|
||||
Option("include", "J", "specify a search path for locating header files")
|
||||
.required(false)
|
||||
.repeatable(true)
|
||||
.argument("path"));
|
||||
|
||||
assert (set.hasOption("include", false));
|
||||
assert (set.hasOption("I", true));
|
||||
assert (set.hasOption("Include", true));
|
||||
@@ -88,14 +99,28 @@ void OptionSetTest::testOptionSet()
|
||||
assert (!set.hasOption("i", false));
|
||||
assert (!set.hasOption("in", false));
|
||||
|
||||
assert (set.hasOption("help"));
|
||||
assert (set.hasOption("h", true));
|
||||
assert (set.hasOption("helper"));
|
||||
assert (set.hasOption("H", true));
|
||||
|
||||
const Option& opt1 = set.getOption("include");
|
||||
assert (opt1.fullName() == "include-dir");
|
||||
assert (opt1.fullName() == "include");
|
||||
|
||||
const Option& opt2 = set.getOption("item");
|
||||
assert (opt2.fullName() == "item");
|
||||
|
||||
const Option& opt3 = set.getOption("I", true);
|
||||
assert (opt3.fullName() == "include-dir");
|
||||
|
||||
const Option& opt4 = set.getOption("include-d");
|
||||
assert (opt4.fullName() == "include-dir");
|
||||
|
||||
const Option& opt5 = set.getOption("help");
|
||||
assert (opt5.fullName() == "help");
|
||||
|
||||
const Option& opt6 = set.getOption("helpe");
|
||||
assert (opt6.fullName() == "helper");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -106,6 +131,15 @@ void OptionSetTest::testOptionSet()
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
set.getOption("he");
|
||||
fail("ambiguous - must throw");
|
||||
}
|
||||
catch (Poco::Util::AmbiguousOptionException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
set.getOption("i");
|
||||
|
||||
Reference in New Issue
Block a user