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
c3e72027
Commit
c3e72027
authored
Oct 23, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/test_util: unit test for libutil.a
parent
f1027ed1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
0 deletions
+64
-0
Makefile.am
Makefile.am
+10
-0
test_util.cxx
test/test_util.cxx
+54
-0
No files found.
Makefile.am
View file @
c3e72027
...
...
@@ -1056,6 +1056,7 @@ sparse-check:
if
ENABLE_TEST
C_TESTS
=
\
test
/test_util
\
test
/test_byte_reverse
\
test
/test_pcm
\
test
/test_queue_priority
...
...
@@ -1466,6 +1467,15 @@ test_run_inotify_LDADD = \
$(GLIB_LIBS)
endif
test_test_util_SOURCES
=
\
test
/test_util.cxx
test_test_util_CPPFLAGS
=
$(AM_CPPFLAGS)
$(CPPUNIT_CFLAGS)
-DCPPUNIT_HAVE_RTTI
=
0
test_test_util_CXXFLAGS
=
$(AM_CXXFLAGS)
-Wno-error
=
deprecated-declarations
test_test_util_LDADD
=
\
libutil.a
\
$(GLIB_LIBS)
\
$(CPPUNIT_LIBS)
test_test_byte_reverse_SOURCES
=
\
test
/test_byte_reverse.cxx
test_test_byte_reverse_CPPFLAGS
=
$(AM_CPPFLAGS)
$(CPPUNIT_CFLAGS)
-DCPPUNIT_HAVE_RTTI
=
0
...
...
test/test_util.cxx
0 → 100644
View file @
c3e72027
/*
* Unit tests for src/util/
*/
#include "config.h"
#include "util/UriUtil.hxx"
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/extensions/HelperMacros.h>
#include <string.h>
class
UriUtilTest
:
public
CppUnit
::
TestFixture
{
CPPUNIT_TEST_SUITE
(
UriUtilTest
);
CPPUNIT_TEST
(
TestSuffix
);
CPPUNIT_TEST
(
TestRemoveAuth
);
CPPUNIT_TEST_SUITE_END
();
public
:
void
TestSuffix
()
{
CPPUNIT_ASSERT_EQUAL
((
const
char
*
)
nullptr
,
uri_get_suffix
(
"/foo/bar"
));
CPPUNIT_ASSERT_EQUAL
((
const
char
*
)
nullptr
,
uri_get_suffix
(
"/foo.jpg/bar"
));
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
uri_get_suffix
(
"/foo/bar.jpg"
),
"jpg"
));
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
uri_get_suffix
(
"/foo.png/bar.jpg"
),
"jpg"
));
}
void
TestRemoveAuth
()
{
CPPUNIT_ASSERT_EQUAL
((
char
*
)
nullptr
,
uri_remove_auth
(
"http://www.example.com/"
));
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
uri_remove_auth
(
"http://foo:bar@www.example.com/"
),
"http://www.example.com/"
));
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
uri_remove_auth
(
"http://foo@www.example.com/"
),
"http://www.example.com/"
));
CPPUNIT_ASSERT_EQUAL
((
char
*
)
nullptr
,
uri_remove_auth
(
"http://www.example.com/f:oo@bar"
));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION
(
UriUtilTest
);
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