From 6796e8a11352b96a37c86301a35c6e2f3d2d26e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZIGETI=20J=C3=A1nos?= Date: Wed, 28 Jun 2023 11:24:31 +0200 Subject: [PATCH 1/2] [tests]: tests on CommandLine / Option; minor changes (checks) in CommandLine --- src/CommandLine.cc | 18 +++-- tests/CommandLine_test.cc | 166 ++++++++++++++++++++++++++++++++++++++ tests/Makefile.am | 6 +- 3 files changed, 180 insertions(+), 10 deletions(-) create mode 100644 tests/CommandLine_test.cc diff --git a/src/CommandLine.cc b/src/CommandLine.cc index 0f7b24d..c2b28a2 100644 --- a/src/CommandLine.cc +++ b/src/CommandLine.cc @@ -28,7 +28,7 @@ using namespace std; /// strict weak ordering by flag (lexicographic). bool Option::operator<(const _Option &b) const { - return std::strcmp(flag, b.flag) < 0; + return (flag && b.flag) ? std::strcmp(flag, b.flag) < 0 : (flag < b.flag); } ostream &operator<<(ostream &a, const Option &b) { @@ -50,8 +50,12 @@ ostream &operator<<(ostream &a, const Option &b) { CommandLine::CommandLine(const set