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
e12bd00b
Commit
e12bd00b
authored
Jun 22, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/TestFs: new unit test for libfs.a
parent
50eac9b4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
0 deletions
+116
-0
Makefile.am
Makefile.am
+9
-0
TestFs.cxx
test/TestFs.cxx
+107
-0
No files found.
Makefile.am
View file @
e12bd00b
...
...
@@ -1514,6 +1514,7 @@ C_TESTS = \
test
/test_pcm
\
test
/test_protocol
\
test
/test_queue_priority
\
test
/TestFs
\
test
/TestIcu
if
ENABLE_CURL
...
...
@@ -2164,6 +2165,14 @@ test_test_queue_priority_LDADD = \
libutil.a
\
$(CPPUNIT_LIBS)
test_TestFs_SOURCES
=
\
test
/TestFs.cxx
test_TestFs_CPPFLAGS
=
$(AM_CPPFLAGS)
$(CPPUNIT_CFLAGS)
-DCPPUNIT_HAVE_RTTI
=
0
test_TestFs_CXXFLAGS
=
$(AM_CXXFLAGS)
-Wno-error
=
deprecated-declarations
test_TestFs_LDADD
=
\
$(FS_LIBS)
\
$(CPPUNIT_LIBS)
test_TestIcu_SOURCES
=
\
test
/TestIcu.cxx
test_TestIcu_CPPFLAGS
=
$(AM_CPPFLAGS)
$(CPPUNIT_CFLAGS)
-DCPPUNIT_HAVE_RTTI
=
0
...
...
test/TestFs.cxx
0 → 100644
View file @
e12bd00b
/*
* Unit tests for src/fs/
*/
#include "config.h"
#include "fs/Glob.hxx"
#include "util/Error.hxx"
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/extensions/HelperMacros.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_CLASS_GLOB
class
TestGlob
:
public
CppUnit
::
TestFixture
{
CPPUNIT_TEST_SUITE
(
TestGlob
);
CPPUNIT_TEST
(
Basic
);
CPPUNIT_TEST
(
Asterisk
);
CPPUNIT_TEST
(
QuestionMark
);
CPPUNIT_TEST
(
Wildcard
);
CPPUNIT_TEST
(
PrefixWildcard
);
CPPUNIT_TEST
(
SuffixWildcard
);
CPPUNIT_TEST_SUITE_END
();
public
:
void
Basic
()
{
const
Glob
glob
(
"foo"
);
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo"
));
CPPUNIT_ASSERT
(
!
glob
.
Check
(
"fooo"
));
CPPUNIT_ASSERT
(
!
glob
.
Check
(
"_foo"
));
CPPUNIT_ASSERT
(
!
glob
.
Check
(
"a/foo"
));
CPPUNIT_ASSERT
(
!
glob
.
Check
(
""
));
CPPUNIT_ASSERT
(
!
glob
.
Check
(
"*"
));
}
void
Asterisk
()
{
const
Glob
glob
(
"*"
);
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"bar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"*"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"?"
));
}
void
QuestionMark
()
{
const
Glob
glob
(
"foo?bar"
);
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo_bar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo?bar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo bar"
));
CPPUNIT_ASSERT
(
!
glob
.
Check
(
"foobar"
));
CPPUNIT_ASSERT
(
!
glob
.
Check
(
"foo__bar"
));
}
void
Wildcard
()
{
const
Glob
glob
(
"foo*bar"
);
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo_bar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo?bar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo bar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foobar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo__bar"
));
CPPUNIT_ASSERT
(
!
glob
.
Check
(
"_foobar"
));
CPPUNIT_ASSERT
(
!
glob
.
Check
(
"foobar_"
));
}
void
PrefixWildcard
()
{
const
Glob
glob
(
"*bar"
);
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo_bar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo?bar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo bar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foobar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo__bar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"_foobar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"bar"
));
CPPUNIT_ASSERT
(
!
glob
.
Check
(
"foobar_"
));
}
void
SuffixWildcard
()
{
const
Glob
glob
(
"foo*"
);
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo_bar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo?bar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo bar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foobar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo__bar"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foobar_"
));
CPPUNIT_ASSERT
(
glob
.
Check
(
"foo"
));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION
(
TestGlob
);
#endif
int
main
(
gcc_unused
int
argc
,
gcc_unused
char
**
argv
)
{
#ifdef HAVE_CLASS_GLOB
CppUnit
::
TextUi
::
TestRunner
runner
;
auto
&
registry
=
CppUnit
::
TestFactoryRegistry
::
getRegistry
();
runner
.
addTest
(
registry
.
makeTest
());
return
runner
.
run
()
?
EXIT_SUCCESS
:
EXIT_FAILURE
;
#else
return
EXIT_SUCCESS
;
#endif
}
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