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
2abfc7b8
Commit
2abfc7b8
authored
Dec 04, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/test_util: move class UriUtilTest to UriUtilTest.hxx
parent
050f0c3d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
57 deletions
+68
-57
Makefile.am
Makefile.am
+1
-0
UriUtilTest.hxx
test/UriUtilTest.hxx
+66
-0
test_util.cxx
test/test_util.cxx
+1
-57
No files found.
Makefile.am
View file @
2abfc7b8
...
...
@@ -2001,6 +2001,7 @@ test_run_inotify_LDADD = \
endif
test_test_util_SOURCES
=
\
test
/UriUtilTest.hxx
\
test
/TestCircularBuffer.hxx
\
test
/test_util.cxx
test_test_util_CPPFLAGS
=
$(AM_CPPFLAGS)
$(CPPUNIT_CFLAGS)
-DCPPUNIT_HAVE_RTTI
=
0
...
...
test/UriUtilTest.hxx
0 → 100644
View file @
2abfc7b8
/*
* Unit tests for src/util/
*/
#include "check.h"
#include "util/UriUtil.hxx"
#include <cppunit/TestFixture.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"
));
CPPUNIT_ASSERT_EQUAL
((
const
char
*
)
nullptr
,
uri_get_suffix
(
".jpg"
));
CPPUNIT_ASSERT_EQUAL
((
const
char
*
)
nullptr
,
uri_get_suffix
(
"/foo/.jpg"
));
/* the first overload does not eliminate the query
string */
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
uri_get_suffix
(
"/foo/bar.jpg?query_string"
),
"jpg?query_string"
));
/* ... but the second one does */
UriSuffixBuffer
buffer
;
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
uri_get_suffix
(
"/foo/bar.jpg?query_string"
,
buffer
),
"jpg"
));
/* repeat some of the above tests with the second overload */
CPPUNIT_ASSERT_EQUAL
((
const
char
*
)
nullptr
,
uri_get_suffix
(
"/foo/bar"
,
buffer
));
CPPUNIT_ASSERT_EQUAL
((
const
char
*
)
nullptr
,
uri_get_suffix
(
"/foo.jpg/bar"
,
buffer
));
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
uri_get_suffix
(
"/foo/bar.jpg"
,
buffer
),
"jpg"
));
}
void
TestRemoveAuth
()
{
CPPUNIT_ASSERT_EQUAL
(
std
::
string
(),
uri_remove_auth
(
"http://www.example.com/"
));
CPPUNIT_ASSERT_EQUAL
(
std
::
string
(
"http://www.example.com/"
),
uri_remove_auth
(
"http://foo:bar@www.example.com/"
));
CPPUNIT_ASSERT_EQUAL
(
std
::
string
(
"http://www.example.com/"
),
uri_remove_auth
(
"http://foo@www.example.com/"
));
CPPUNIT_ASSERT_EQUAL
(
std
::
string
(),
uri_remove_auth
(
"http://www.example.com/f:oo@bar"
));
CPPUNIT_ASSERT_EQUAL
(
std
::
string
(
"ftp://ftp.example.com/"
),
uri_remove_auth
(
"ftp://foo:bar@ftp.example.com/"
));
}
};
test/test_util.cxx
View file @
2abfc7b8
...
...
@@ -3,7 +3,7 @@
*/
#include "config.h"
#include "
util/UriUtil
.hxx"
#include "
UriUtilTest
.hxx"
#include "TestCircularBuffer.hxx"
#include <cppunit/TestFixture.h>
...
...
@@ -11,64 +11,8 @@
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/extensions/HelperMacros.h>
#include <string.h>
#include <stdlib.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"
));
CPPUNIT_ASSERT_EQUAL
((
const
char
*
)
nullptr
,
uri_get_suffix
(
".jpg"
));
CPPUNIT_ASSERT_EQUAL
((
const
char
*
)
nullptr
,
uri_get_suffix
(
"/foo/.jpg"
));
/* the first overload does not eliminate the query
string */
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
uri_get_suffix
(
"/foo/bar.jpg?query_string"
),
"jpg?query_string"
));
/* ... but the second one does */
UriSuffixBuffer
buffer
;
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
uri_get_suffix
(
"/foo/bar.jpg?query_string"
,
buffer
),
"jpg"
));
/* repeat some of the above tests with the second overload */
CPPUNIT_ASSERT_EQUAL
((
const
char
*
)
nullptr
,
uri_get_suffix
(
"/foo/bar"
,
buffer
));
CPPUNIT_ASSERT_EQUAL
((
const
char
*
)
nullptr
,
uri_get_suffix
(
"/foo.jpg/bar"
,
buffer
));
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
uri_get_suffix
(
"/foo/bar.jpg"
,
buffer
),
"jpg"
));
}
void
TestRemoveAuth
()
{
CPPUNIT_ASSERT_EQUAL
(
std
::
string
(),
uri_remove_auth
(
"http://www.example.com/"
));
CPPUNIT_ASSERT_EQUAL
(
std
::
string
(
"http://www.example.com/"
),
uri_remove_auth
(
"http://foo:bar@www.example.com/"
));
CPPUNIT_ASSERT_EQUAL
(
std
::
string
(
"http://www.example.com/"
),
uri_remove_auth
(
"http://foo@www.example.com/"
));
CPPUNIT_ASSERT_EQUAL
(
std
::
string
(),
uri_remove_auth
(
"http://www.example.com/f:oo@bar"
));
CPPUNIT_ASSERT_EQUAL
(
std
::
string
(
"ftp://ftp.example.com/"
),
uri_remove_auth
(
"ftp://foo:bar@ftp.example.com/"
));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION
(
UriUtilTest
);
CPPUNIT_TEST_SUITE_REGISTRATION
(
TestCircularBuffer
);
...
...
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