Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
4907f610
Commit
4907f610
authored
Sep 04, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/test_protocol: unit test for protocol/ArgParser.cxx
parent
f9d1bbbf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
0 deletions
+72
-0
.gitignore
.gitignore
+1
-0
Makefile.am
Makefile.am
+11
-0
test_protocol.cxx
test/test_protocol.cxx
+60
-0
No files found.
.gitignore
View file @
4907f610
...
...
@@ -63,6 +63,7 @@ test/run_normalize
test/tmp
test/run_inotify
test/test_queue_priority
test/test_protocol
test/run_ntp_server
test/run_resolver
test/run_tcp_connect
...
...
Makefile.am
View file @
4907f610
...
...
@@ -1064,6 +1064,7 @@ C_TESTS = \
test
/test_mixramp
\
test
/test_icy_parser
\
test
/test_pcm
\
test
/test_protocol
\
test
/test_queue_priority
if
ENABLE_ARCHIVE
...
...
@@ -1538,6 +1539,16 @@ test_test_archive_LDADD = \
$(GLIB_LIBS)
\
$(CPPUNIT_LIBS)
test_test_protocol_SOURCES
=
\
src/protocol/ArgParser.cxx
\
test
/test_protocol.cxx
test_test_protocol_CPPFLAGS
=
$(AM_CPPFLAGS)
$(CPPUNIT_CFLAGS)
-DCPPUNIT_HAVE_RTTI
=
0
test_test_protocol_CXXFLAGS
=
$(AM_CXXFLAGS)
-Wno-error
=
deprecated-declarations
test_test_protocol_LDADD
=
\
libsystem.a
\
libutil.a
\
$(CPPUNIT_LIBS)
test_test_queue_priority_SOURCES
=
\
src/Queue.cxx
\
test
/test_queue_priority.cxx
...
...
test/test_protocol.cxx
0 → 100644
View file @
4907f610
#include "config.h"
#include "protocol/ArgParser.hxx"
#include "protocol/Result.hxx"
#include "Compiler.h"
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/extensions/HelperMacros.h>
static
enum
ack
last_error
=
ack
(
-
1
);
void
command_error
(
gcc_unused
Client
&
client
,
enum
ack
error
,
gcc_unused
const
char
*
fmt
,
...)
{
last_error
=
error
;
}
class
ArgParserTest
:
public
CppUnit
::
TestFixture
{
CPPUNIT_TEST_SUITE
(
ArgParserTest
);
CPPUNIT_TEST
(
TestRange
);
CPPUNIT_TEST_SUITE_END
();
public
:
void
TestRange
();
};
void
ArgParserTest
::
TestRange
()
{
Client
&
client
=
*
(
Client
*
)
nullptr
;
unsigned
a
,
b
;
CPPUNIT_ASSERT
(
check_range
(
client
,
&
a
,
&
b
,
"1"
));
CPPUNIT_ASSERT_EQUAL
(
1u
,
a
);
CPPUNIT_ASSERT_EQUAL
(
2u
,
b
);
CPPUNIT_ASSERT
(
check_range
(
client
,
&
a
,
&
b
,
"1:5"
));
CPPUNIT_ASSERT_EQUAL
(
1u
,
a
);
CPPUNIT_ASSERT_EQUAL
(
5u
,
b
);
CPPUNIT_ASSERT
(
check_range
(
client
,
&
a
,
&
b
,
"1:"
));
CPPUNIT_ASSERT_EQUAL
(
1u
,
a
);
CPPUNIT_ASSERT
(
b
>=
999999u
);
CPPUNIT_ASSERT
(
!
check_range
(
client
,
&
a
,
&
b
,
"-2"
));
CPPUNIT_ASSERT_EQUAL
(
ACK_ERROR_ARG
,
last_error
);
}
CPPUNIT_TEST_SUITE_REGISTRATION
(
ArgParserTest
);
int
main
(
gcc_unused
int
argc
,
gcc_unused
char
**
argv
)
{
CppUnit
::
TextUi
::
TestRunner
runner
;
auto
&
registry
=
CppUnit
::
TestFactoryRegistry
::
getRegistry
();
runner
.
addTest
(
registry
.
makeTest
());
return
runner
.
run
()
?
EXIT_SUCCESS
:
EXIT_FAILURE
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment