2020-05-23 Fred Gleason <fredg@paravelsystems.com>

* Added a 'cmdline_parser_test' test harness.
	* Fixed a bug in 'RDCmdSwitch' that caused value-only arguments
	containing '=' characters to be incorrectly parsed.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2020-05-23 10:02:45 -04:00
parent f51f39be11
commit 18dd09378b
6 changed files with 110 additions and 8 deletions

View File

@@ -31,6 +31,7 @@ noinst_PROGRAMS = audio_convert_test\
audio_import_test\
audio_metadata_test\
audio_peaks_test\
cmdline_parser_test\
datedecode_test\
dateparse_test\
db_charset_test\
@@ -65,6 +66,9 @@ audio_metadata_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT4_LIBS@ @MUSICBRAINZ_LIB
dist_audio_peaks_test_SOURCES = audio_peaks_test.cpp audio_peaks_test.h
audio_peaks_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT4_LIBS@ @MUSICBRAINZ_LIBS@ -lQt3Support
dist_cmdline_parser_test_SOURCES = cmdline_parser_test.cpp cmdline_parser_test.h
cmdline_parser_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT4_LIBS@ @MUSICBRAINZ_LIBS@ -lQt3Support
dist_datedecode_test_SOURCES = datedecode_test.cpp datedecode_test.h
datedecode_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT4_LIBS@ @MUSICBRAINZ_LIBS@ -lQt3Support

View File

@@ -0,0 +1,52 @@
// cmdline_parser_test.cpp
//
// Test the Rivendell command-line parser routines.
//
// (C) Copyright 2020 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <stdlib.h>
#include <stdio.h>
#include <qapplication.h>
#include <rdcmd_switch.h>
#include "cmdline_parser_test.h"
MainObject::MainObject(QObject *parent)
:QObject(parent)
{
//
// Read Command Options
//
RDCmdSwitch *cmd=
new RDCmdSwitch(qApp->argc(),qApp->argv(),"cmdline_parser_test",
CMDLINE_PARSER_TEST_USAGE);
for(unsigned i=0;i<cmd->keys();i++) {
printf(" key[%d]: %s\n",i,cmd->key(i).utf8().constData());
printf("value[%d]: %s\n",i,cmd->value(i).toUtf8().constData());
}
exit(0);
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv,false);
new MainObject();
return a.exec();
}

View File

@@ -0,0 +1,35 @@
// cmdline_parser_test.h
//
// Test the Rivendell command-line parser routines.
//
// (C) Copyright 2020 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef CMDLINE_PARSER_TEST_H
#define CMDLINE_PARSER_TEST_H
#include <qobject.h>
#define CMDLINE_PARSER_TEST_USAGE "<test-args> ...\n\n"
class MainObject : public QObject
{
public:
MainObject(QObject *parent=0);
};
#endif // CMDLINE_PARSER_TEST_H