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
de862f9f
Commit
de862f9f
authored
Oct 26, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/test_mixramp: unit test for mixramp_interpolate()
parent
b5e31c89
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
0 deletions
+94
-0
.gitignore
.gitignore
+2
-0
Makefile.am
Makefile.am
+10
-0
test_mixramp.cxx
test/test_mixramp.cxx
+82
-0
No files found.
.gitignore
View file @
de862f9f
...
@@ -68,7 +68,9 @@ test/run_tcp_connect
...
@@ -68,7 +68,9 @@ test/run_tcp_connect
test/test_pcm
test/test_pcm
test/dump_rva2
test/dump_rva2
test/dump_text_file
test/dump_text_file
test/test_util
test/test_byte_reverse
test/test_byte_reverse
test/test_mixramp
test/test_vorbis_encoder
test/test_vorbis_encoder
test/DumpDatabase
test/DumpDatabase
...
...
Makefile.am
View file @
de862f9f
...
@@ -1058,6 +1058,7 @@ if ENABLE_TEST
...
@@ -1058,6 +1058,7 @@ if ENABLE_TEST
C_TESTS
=
\
C_TESTS
=
\
test
/test_util
\
test
/test_util
\
test
/test_byte_reverse
\
test
/test_byte_reverse
\
test
/test_mixramp
\
test
/test_pcm
\
test
/test_pcm
\
test
/test_queue_priority
test
/test_queue_priority
...
@@ -1483,6 +1484,15 @@ test_test_byte_reverse_LDADD = \
...
@@ -1483,6 +1484,15 @@ test_test_byte_reverse_LDADD = \
libutil.a
\
libutil.a
\
$(CPPUNIT_LIBS)
$(CPPUNIT_LIBS)
test_test_mixramp_SOURCES
=
\
src/Log.cxx
\
test
/test_mixramp.cxx
test_test_mixramp_CPPFLAGS
=
$(AM_CPPFLAGS)
$(CPPUNIT_CFLAGS)
-DCPPUNIT_HAVE_RTTI
=
0
test_test_mixramp_CXXFLAGS
=
$(AM_CXXFLAGS)
-Wno-error
=
deprecated-declarations
test_test_mixramp_LDADD
=
\
$(GLIB_LIBS)
\
$(CPPUNIT_LIBS)
test_test_pcm_SOURCES
=
\
test_test_pcm_SOURCES
=
\
test
/test_pcm_util.hxx
\
test
/test_pcm_util.hxx
\
test
/test_pcm_dither.cxx
\
test
/test_pcm_dither.cxx
\
...
...
test/test_mixramp.cxx
0 → 100644
View file @
de862f9f
/*
* Unit tests for mixramp_interpolate()
*/
#include "config.h"
#include "CrossFade.cxx"
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/extensions/HelperMacros.h>
#include <string.h>
class
MixRampTest
:
public
CppUnit
::
TestFixture
{
CPPUNIT_TEST_SUITE
(
MixRampTest
);
CPPUNIT_TEST
(
TestInterpolate
);
CPPUNIT_TEST_SUITE_END
();
public
:
void
TestInterpolate
()
{
const
char
*
input
=
"1.0 0.00;3.0 0.10;6.0 2.50;"
;
char
*
foo
=
strdup
(
input
);
CPPUNIT_ASSERT
(
!
std
::
isnan
(
mixramp_interpolate
(
foo
,
0
)));
free
(
foo
);
foo
=
strdup
(
input
);
CPPUNIT_ASSERT_EQUAL
(
float
(
0
),
mixramp_interpolate
(
foo
,
1
));
free
(
foo
);
foo
=
strdup
(
input
);
CPPUNIT_ASSERT_EQUAL
(
float
(
0.1
),
mixramp_interpolate
(
foo
,
3
));
free
(
foo
);
foo
=
strdup
(
input
);
CPPUNIT_ASSERT_EQUAL
(
float
(
2.5
),
mixramp_interpolate
(
foo
,
6
));
free
(
foo
);
foo
=
strdup
(
input
);
CPPUNIT_ASSERT
(
!
std
::
isnan
(
mixramp_interpolate
(
foo
,
3
)));
free
(
foo
);
foo
=
strdup
(
input
);
CPPUNIT_ASSERT_DOUBLES_EQUAL
(
float
(
0.05
),
mixramp_interpolate
(
foo
,
2
),
0.05
);
free
(
foo
);
foo
=
strdup
(
input
);
CPPUNIT_ASSERT_DOUBLES_EQUAL
(
float
(
1.3
),
mixramp_interpolate
(
foo
,
4.5
),
0.05
);
free
(
foo
);
foo
=
strdup
(
input
);
CPPUNIT_ASSERT_DOUBLES_EQUAL
(
float
(
0.9
),
mixramp_interpolate
(
foo
,
4
),
0.05
);
free
(
foo
);
foo
=
strdup
(
input
);
CPPUNIT_ASSERT_DOUBLES_EQUAL
(
float
(
1.7
),
mixramp_interpolate
(
foo
,
5
),
0.05
);
free
(
foo
);
}
};
CPPUNIT_TEST_SUITE_REGISTRATION
(
MixRampTest
);
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