Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions test/unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ add_executable(unittest)
target_sources(unittest
PRIVATE
cstring_array.h
custom_a.h
custom_b.h
custom.h
main.cpp
test_argument_parser.cpp
test_error_message.cpp
Expand Down
6 changes: 3 additions & 3 deletions test/unittest/custom_a.h → test/unittest/custom.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef CUSTOMA_H
#define CUSTOMA_H
#ifndef CUSTOM_H
#define CUSTOM_H

#include "argparse.hpp"
#include <string>
Expand Down Expand Up @@ -45,4 +45,4 @@ class Converter<foo::Custom>
};
}

#endif /* CUSTOMA_H */
#endif /* CUSTOM_H */
48 changes: 0 additions & 48 deletions test/unittest/custom_b.h

This file was deleted.

30 changes: 11 additions & 19 deletions test/unittest/test_parsing_optional.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "argparse.hpp"

#include "cstring_array.h"
#include "custom_a.h"
#include "custom_b.h"
#include "custom.h"

#include "doctest.h"

Expand All @@ -19,13 +18,6 @@ inline auto operator==(Custom const & lhs, Custom const & rhs) -> bool
return lhs.m_text == rhs.m_text;
}
}
namespace bar
{
inline auto operator==(Custom const & lhs, Custom const & rhs) -> bool
{
return lhs.m_text == rhs.m_text;
}
}

TEST_CASE("Parsing an optional argument yields false when it's missing")
{
Expand Down Expand Up @@ -95,7 +87,7 @@ TEST_CASE("Parsing an optional argument with store false action yields false whe
CHECK(args.get_value<bool>("o") == false);
}

TEST_CASE_TEMPLATE("Parsing an optional argument with store const action yields false when it's missing", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom, bar::Custom)
TEST_CASE_TEMPLATE("Parsing an optional argument with store const action yields false when it's missing", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom)
{
auto parser = argparse::ArgumentParser();

Expand All @@ -117,7 +109,7 @@ TEST_CASE_TEMPLATE("Parsing an optional argument with store const action yields
CHECK(!args.get("o"));
}

TEST_CASE_TEMPLATE("Parsing an optional argument with store const action yields const value", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom, bar::Custom)
TEST_CASE_TEMPLATE("Parsing an optional argument with store const action yields const value", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom)
{
auto parser = argparse::ArgumentParser();

Expand Down Expand Up @@ -248,7 +240,7 @@ TEST_CASE("Parsing an optional argument with append action yields a list of argu
CHECK(args.get_value<std::vector<std::string>>("a") == std::vector<std::string>{"one", "two", "three"});
}

TEST_CASE_TEMPLATE("Parsing an optional argument with append action yields its requested type", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, foo::Custom, bar::Custom)
TEST_CASE_TEMPLATE("Parsing an optional argument with append action yields its requested type", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, foo::Custom)
{
auto parser = argparse::ArgumentParser();
parser.add_argument("-a").action(argparse::append).type<T>();
Expand Down Expand Up @@ -339,7 +331,7 @@ TEST_CASE("Optional argument can be used with its long name")
CHECK(args.get_value("option") == "val");
}

TEST_CASE_TEMPLATE("Parsing an optional argument yields its requested type", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, foo::Custom, bar::Custom)
TEST_CASE_TEMPLATE("Parsing an optional argument yields its requested type", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, foo::Custom)
{
auto parser = argparse::ArgumentParser();
parser.add_argument("-o").type<T>();
Expand Down Expand Up @@ -379,7 +371,7 @@ TEST_CASE("Parsing an optional argument with invalid value throws an exception")
CHECK_THROWS_WITH_AS(parser.parse_args(3, cstr_arr{"prog", "-o", "10gibberish"}), "argument -o: invalid value: '10gibberish'", argparse::parsing_error);
}

TEST_CASE_TEMPLATE("Parsing an optional argument with default value yields the default value when it's missing", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom, bar::Custom)
TEST_CASE_TEMPLATE("Parsing an optional argument with default value yields the default value when it's missing", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom)
{
auto parser = argparse::ArgumentParser();

Expand Down Expand Up @@ -412,7 +404,7 @@ TEST_CASE_TEMPLATE("Parsing an optional argument with default value yields the d
}
}

TEST_CASE_TEMPLATE("Parsing an optional argument with default value yields value of the argument's type", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom, bar::Custom)
TEST_CASE_TEMPLATE("Parsing an optional argument with default value yields value of the argument's type", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom)
{
auto parser = argparse::ArgumentParser();

Expand Down Expand Up @@ -525,7 +517,7 @@ TEST_CASE("Parsing a missing optional argument with required false does not thro
CHECK_NOTHROW(parser.parse_args(1, cstr_arr{"prog"}));
}

TEST_CASE_TEMPLATE("Parsing an optional argument with choices set accepts one of the values", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom, bar::Custom)
TEST_CASE_TEMPLATE("Parsing an optional argument with choices set accepts one of the values", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom)
{
auto parser = argparse::ArgumentParser().handle(argparse::Handle::none);

Expand Down Expand Up @@ -559,7 +551,7 @@ TEST_CASE_TEMPLATE("Parsing an optional argument with choices set accepts one of
}
}

TEST_CASE_TEMPLATE("Parsing an optional argument with choices set throws an exception on incorrect value", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom, bar::Custom)
TEST_CASE_TEMPLATE("Parsing an optional argument with choices set throws an exception on incorrect value", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom)
{
auto parser = argparse::ArgumentParser().handle(argparse::Handle::none);

Expand Down Expand Up @@ -2568,7 +2560,7 @@ TEST_CASE("Parsing long option with joined argument yields its value")
CHECK(args.get_value("long") == "value");
}

TEST_CASE_TEMPLATE("Parsing long option with joined argument yields its value", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, foo::Custom, bar::Custom)
TEST_CASE_TEMPLATE("Parsing long option with joined argument yields its value", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, foo::Custom)
{
auto parser = argparse::ArgumentParser();
parser.add_argument("--long").type<T>();
Expand Down Expand Up @@ -2639,7 +2631,7 @@ TEST_CASE("Parsing short option with joined argument yields its value")
CHECK(args.get_value("o") == "value");
}

TEST_CASE_TEMPLATE("Parsing short option with joined argument yields its value", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, foo::Custom, bar::Custom)
TEST_CASE_TEMPLATE("Parsing short option with joined argument yields its value", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, foo::Custom)
{
auto parser = argparse::ArgumentParser();
parser.add_argument("-o").type<T>();
Expand Down
16 changes: 4 additions & 12 deletions test/unittest/test_parsing_positional.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "argparse.hpp"

#include "cstring_array.h"
#include "custom_a.h"
#include "custom_b.h"
#include "custom.h"

#include "doctest.h"

Expand All @@ -19,13 +18,6 @@ inline auto operator==(Custom const & lhs, Custom const & rhs) -> bool
return lhs.m_text == rhs.m_text;
}
}
namespace bar
{
inline auto operator==(Custom const & lhs, Custom const & rhs) -> bool
{
return lhs.m_text == rhs.m_text;
}
}

TEST_CASE("Parsing a positional argument yields its value")
{
Expand All @@ -37,7 +29,7 @@ TEST_CASE("Parsing a positional argument yields its value")
CHECK(args.get_value("p1") == "v1");
}

TEST_CASE_TEMPLATE("Parsing a positional argument yields its requested type", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, foo::Custom, bar::Custom)
TEST_CASE_TEMPLATE("Parsing a positional argument yields its requested type", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, foo::Custom)
{
auto parser = argparse::ArgumentParser();
parser.add_argument("pos").type<T>();
Expand Down Expand Up @@ -147,7 +139,7 @@ TEST_CASE("The resulting attribute name for positional argument is based on dest
CHECK(args.get("bar"));
}

TEST_CASE_TEMPLATE("Parsing a positional argument with choices set accepts one of the values", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom, bar::Custom)
TEST_CASE_TEMPLATE("Parsing a positional argument with choices set accepts one of the values", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom)
{
auto parser = argparse::ArgumentParser().handle(argparse::Handle::none);

Expand Down Expand Up @@ -181,7 +173,7 @@ TEST_CASE_TEMPLATE("Parsing a positional argument with choices set accepts one o
}
}

TEST_CASE_TEMPLATE("Parsing a positional argument with choices set throws an exception on incorrect value", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom, bar::Custom)
TEST_CASE_TEMPLATE("Parsing a positional argument with choices set throws an exception on incorrect value", T, char, signed char, unsigned char, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int, float, double, long double, std::string, foo::Custom)
{
auto parser = argparse::ArgumentParser().handle(argparse::Handle::none);

Expand Down