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
4658bd82
Commit
4658bd82
authored
Dec 01, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/TestIcu: new unit test for lib/icu/*
parent
6eb1caa4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
1 deletion
+94
-1
Makefile.am
Makefile.am
+12
-1
TestIcu.cxx
test/TestIcu.cxx
+82
-0
No files found.
Makefile.am
View file @
4658bd82
...
...
@@ -465,6 +465,7 @@ libicu_a_CPPFLAGS = $(AM_CPPFLAGS) \
$(ICU_CFLAGS)
ICU_LDADD
=
libicu.a
$(ICU_LIBS)
ICU_LDADD
+=
$(GLIB_LIBS)
# PCM library
...
...
@@ -1484,7 +1485,8 @@ C_TESTS = \
test
/test_mixramp
\
test
/test_pcm
\
test
/test_protocol
\
test
/test_queue_priority
test
/test_queue_priority
\
test
/TestIcu
if
ENABLE_CURL
C_TESTS
+=
test
/test_icy_parser
...
...
@@ -2121,6 +2123,15 @@ test_test_queue_priority_LDADD = \
libutil.a
\
$(CPPUNIT_LIBS)
test_TestIcu_SOURCES
=
\
test
/TestIcu.cxx
test_TestIcu_CPPFLAGS
=
$(AM_CPPFLAGS)
$(CPPUNIT_CFLAGS)
-DCPPUNIT_HAVE_RTTI
=
0
test_TestIcu_CXXFLAGS
=
$(AM_CXXFLAGS)
-Wno-error
=
deprecated-declarations
test_TestIcu_LDADD
=
\
$(ICU_LDADD)
\
libutil.a
\
$(CPPUNIT_LIBS)
if
ENABLE_DSD
noinst_PROGRAMS
+=
src/pcm/dsd2pcm/dsd2pcm
...
...
test/TestIcu.cxx
0 → 100644
View file @
4658bd82
/*
* Unit tests for src/util/
*/
#include "config.h"
#include "lib/icu/Converter.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_ICU_CONVERTER
static
const
char
*
const
invalid_utf8
[]
=
{
"
\xfc
"
,
};
struct
StringPair
{
const
char
*
utf8
,
*
other
;
};
static
constexpr
StringPair
latin1_tests
[]
=
{
{
"foo"
,
"foo"
},
{
"
\xc3\xbc
"
,
"
\xfc
"
},
};
class
TestIcuConverter
:
public
CppUnit
::
TestFixture
{
CPPUNIT_TEST_SUITE
(
TestIcuConverter
);
CPPUNIT_TEST
(
TestInvalidCharset
);
CPPUNIT_TEST
(
TestLatin1
);
CPPUNIT_TEST_SUITE_END
();
public
:
void
TestInvalidCharset
()
{
CPPUNIT_ASSERT_EQUAL
((
IcuConverter
*
)
nullptr
,
IcuConverter
::
Create
(
"doesntexist"
,
IgnoreError
()));
}
void
TestLatin1
()
{
IcuConverter
*
const
converter
=
IcuConverter
::
Create
(
"iso-8859-1"
,
IgnoreError
());
CPPUNIT_ASSERT
(
converter
!=
nullptr
);
for
(
const
auto
i
:
invalid_utf8
)
{
auto
f
=
converter
->
FromUTF8
(
i
);
CPPUNIT_ASSERT_EQUAL
(
true
,
f
.
empty
());
}
for
(
const
auto
i
:
latin1_tests
)
{
auto
f
=
converter
->
FromUTF8
(
i
.
utf8
);
CPPUNIT_ASSERT_EQUAL
(
true
,
f
==
i
.
other
);
auto
t
=
converter
->
ToUTF8
(
i
.
other
);
CPPUNIT_ASSERT_EQUAL
(
true
,
t
==
i
.
utf8
);
}
delete
converter
;
}
};
CPPUNIT_TEST_SUITE_REGISTRATION
(
TestIcuConverter
);
#endif
int
main
(
gcc_unused
int
argc
,
gcc_unused
char
**
argv
)
{
#ifdef HAVE_ICU_CONVERTER
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