From a3888065556b1fa455969aa69f9d2c71aea811e6 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Tue, 22 Sep 2015 17:02:58 +0200 Subject: [PATCH] enable additional CommandLineParser tests --- modules/core/test/test_utils.cpp | 36 +++++++++++++++++--------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/modules/core/test/test_utils.cpp b/modules/core/test/test_utils.cpp index 86387eb9d1..f961b93446 100644 --- a/modules/core/test/test_utils.cpp +++ b/modules/core/test/test_utils.cpp @@ -137,12 +137,14 @@ TEST(CommandLineParser, testPositional_noArgs) const char* argv[] = {""}; const int argc = 1; cv::CommandLineParser parser(argc, argv, keys2); - //EXPECT_FALSE(parser.has("arg1")); - //EXPECT_FALSE(parser.has("arg2")); - //EXPECT_EQ("default1", parser.get("arg1")); + EXPECT_TRUE(parser.has("@arg1")); + EXPECT_FALSE(parser.has("@arg2")); + EXPECT_EQ("default1", parser.get("@arg1")); EXPECT_EQ("default1", parser.get(0)); - //??? EXPECT_ANY_THROW(parser.get("arg2")); - //??? EXPECT_ANY_THROW(parser.get(1)); + + parser.get("@arg2"); + parser.get(1); + EXPECT_TRUE(parser.check()); } TEST(CommandLineParser, testPositional_default) @@ -150,10 +152,10 @@ TEST(CommandLineParser, testPositional_default) const char* argv[] = {"", "test1", "test2"}; const int argc = 3; cv::CommandLineParser parser(argc, argv, keys2); - //EXPECT_TRUE(parser.has("arg1")); - //EXPECT_TRUE(parser.has("arg2")); - //EXPECT_EQ("test1", parser.get("arg1")); - //EXPECT_EQ("test2", parser.get("arg2")); + EXPECT_TRUE(parser.has("@arg1")); + EXPECT_TRUE(parser.has("@arg2")); + EXPECT_EQ("test1", parser.get("@arg1")); + EXPECT_EQ("test2", parser.get("@arg2")); EXPECT_EQ("test1", parser.get(0)); EXPECT_EQ("test2", parser.get(1)); } @@ -163,10 +165,10 @@ TEST(CommandLineParser, testPositional_withFlagsBefore) const char* argv[] = {"", "-h", "test1", "test2"}; const int argc = 4; cv::CommandLineParser parser(argc, argv, keys2); - //EXPECT_TRUE(parser.has("arg1")); - //EXPECT_TRUE(parser.has("arg2")); - //EXPECT_EQ("test1", parser.get("arg1")); - //EXPECT_EQ("test2", parser.get("arg2")); + EXPECT_TRUE(parser.has("@arg1")); + EXPECT_TRUE(parser.has("@arg2")); + EXPECT_EQ("test1", parser.get("@arg1")); + EXPECT_EQ("test2", parser.get("@arg2")); EXPECT_EQ("test1", parser.get(0)); EXPECT_EQ("test2", parser.get(1)); } @@ -176,10 +178,10 @@ TEST(CommandLineParser, testPositional_withFlagsAfter) const char* argv[] = {"", "test1", "test2", "-h"}; const int argc = 4; cv::CommandLineParser parser(argc, argv, keys2); - //EXPECT_TRUE(parser.has("arg1")); - //EXPECT_TRUE(parser.has("arg2")); - //EXPECT_EQ("test1", parser.get("arg1")); - //EXPECT_EQ("test2", parser.get("arg2")); + EXPECT_TRUE(parser.has("@arg1")); + EXPECT_TRUE(parser.has("@arg2")); + EXPECT_EQ("test1", parser.get("@arg1")); + EXPECT_EQ("test2", parser.get("@arg2")); EXPECT_EQ("test1", parser.get(0)); EXPECT_EQ("test2", parser.get(1)); }