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
02a77f67
Commit
02a77f67
authored
Dec 04, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/test_util: add unit test for DivideString
parent
77b316cd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
0 deletions
+47
-0
Makefile.am
Makefile.am
+1
-0
DivideStringTest.hxx
test/DivideStringTest.hxx
+44
-0
test_util.cxx
test/test_util.cxx
+2
-0
No files found.
Makefile.am
View file @
02a77f67
...
...
@@ -2001,6 +2001,7 @@ test_run_inotify_LDADD = \
endif
test_test_util_SOURCES
=
\
test
/DivideStringTest.hxx
\
test
/UriUtilTest.hxx
\
test
/TestCircularBuffer.hxx
\
test
/test_util.cxx
...
...
test/DivideStringTest.hxx
0 → 100644
View file @
02a77f67
/*
* Unit tests for src/util/
*/
#include "check.h"
#include "util/DivideString.hxx"
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include <string.h>
class
DivideStringTest
:
public
CppUnit
::
TestFixture
{
CPPUNIT_TEST_SUITE
(
DivideStringTest
);
CPPUNIT_TEST
(
TestBasic
);
CPPUNIT_TEST
(
TestEmpty
);
CPPUNIT_TEST
(
TestFail
);
CPPUNIT_TEST_SUITE_END
();
public
:
void
TestBasic
()
{
constexpr
char
input
[]
=
"foo.bar"
;
const
DivideString
ds
(
input
,
'.'
);
CPPUNIT_ASSERT
(
ds
.
IsDefined
());
CPPUNIT_ASSERT
(
!
ds
.
IsEmpty
());
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
ds
.
GetFirst
(),
"foo"
));
CPPUNIT_ASSERT_EQUAL
(
input
+
4
,
ds
.
GetSecond
());
}
void
TestEmpty
()
{
constexpr
char
input
[]
=
".bar"
;
const
DivideString
ds
(
input
,
'.'
);
CPPUNIT_ASSERT
(
ds
.
IsDefined
());
CPPUNIT_ASSERT
(
ds
.
IsEmpty
());
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
ds
.
GetFirst
(),
""
));
CPPUNIT_ASSERT_EQUAL
(
input
+
1
,
ds
.
GetSecond
());
}
void
TestFail
()
{
constexpr
char
input
[]
=
"foo!bar"
;
const
DivideString
ds
(
input
,
'.'
);
CPPUNIT_ASSERT
(
!
ds
.
IsDefined
());
}
};
test/test_util.cxx
View file @
02a77f67
...
...
@@ -3,6 +3,7 @@
*/
#include "config.h"
#include "DivideStringTest.hxx"
#include "UriUtilTest.hxx"
#include "TestCircularBuffer.hxx"
...
...
@@ -13,6 +14,7 @@
#include <stdlib.h>
CPPUNIT_TEST_SUITE_REGISTRATION
(
DivideStringTest
);
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