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
ee7282ce
Commit
ee7282ce
authored
Aug 12, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/test_pcm: add PcmExport unit test
parent
d0263673
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
149 additions
and
0 deletions
+149
-0
Makefile.am
Makefile.am
+1
-0
test_pcm_all.hxx
test/test_pcm_all.hxx
+15
-0
test_pcm_export.cxx
test/test_pcm_export.cxx
+132
-0
test_pcm_main.cxx
test/test_pcm_main.cxx
+1
-0
No files found.
Makefile.am
View file @
ee7282ce
...
@@ -1979,6 +1979,7 @@ test_test_pcm_SOURCES = \
...
@@ -1979,6 +1979,7 @@ test_test_pcm_SOURCES = \
test
/test_pcm_format.cxx
\
test
/test_pcm_format.cxx
\
test
/test_pcm_volume.cxx
\
test
/test_pcm_volume.cxx
\
test
/test_pcm_mix.cxx
\
test
/test_pcm_mix.cxx
\
test
/test_pcm_export.cxx
\
test
/test_pcm_all.hxx
\
test
/test_pcm_all.hxx
\
test
/test_pcm_main.cxx
test
/test_pcm_main.cxx
test_test_pcm_CPPFLAGS
=
$(AM_CPPFLAGS)
$(CPPUNIT_CFLAGS)
-DCPPUNIT_HAVE_RTTI
=
0
test_test_pcm_CPPFLAGS
=
$(AM_CPPFLAGS)
$(CPPUNIT_CFLAGS)
-DCPPUNIT_HAVE_RTTI
=
0
...
...
test/test_pcm_all.hxx
View file @
ee7282ce
...
@@ -103,4 +103,19 @@ public:
...
@@ -103,4 +103,19 @@ public:
void
TestMix32
();
void
TestMix32
();
};
};
class
PcmExportTest
:
public
CppUnit
::
TestFixture
{
CPPUNIT_TEST_SUITE
(
PcmExportTest
);
CPPUNIT_TEST
(
TestShift8
);
CPPUNIT_TEST
(
TestPack24
);
CPPUNIT_TEST
(
TestReverseEndian
);
CPPUNIT_TEST
(
TestDsdUsb
);
CPPUNIT_TEST_SUITE_END
();
public
:
void
TestShift8
();
void
TestPack24
();
void
TestReverseEndian
();
void
TestDsdUsb
();
};
#endif
#endif
test/test_pcm_export.cxx
0 → 100644
View file @
ee7282ce
/*
* Copyright (C) 2003-2014 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "test_pcm_all.hxx"
#include "pcm/PcmExport.hxx"
#include "system/ByteOrder.hxx"
#include <string.h>
void
PcmExportTest
::
TestShift8
()
{
static
constexpr
int32_t
src
[]
=
{
0x0
,
0x1
,
0x100
,
0x10000
,
0xffffff
};
static
constexpr
uint32_t
expected
[]
=
{
0x0
,
0x100
,
0x10000
,
0x1000000
,
0xffffff00
};
PcmExport
e
;
e
.
Open
(
SampleFormat
::
S24_P32
,
2
,
false
,
true
,
false
,
false
);
size_t
dest_size
;
auto
dest
=
e
.
Export
(
src
,
sizeof
(
src
),
dest_size
);
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected
),
dest_size
);
CPPUNIT_ASSERT
(
memcmp
(
dest
,
expected
,
dest_size
)
==
0
);
}
void
PcmExportTest
::
TestPack24
()
{
static
constexpr
int32_t
src
[]
=
{
0x0
,
0x1
,
0x100
,
0x10000
,
0xffffff
};
static
constexpr
uint8_t
expected_be
[]
=
{
0
,
0
,
0x0
,
0
,
0
,
0x1
,
0
,
0x1
,
0x00
,
0x1
,
0x00
,
0x00
,
0xff
,
0xff
,
0xff
,
};
static
constexpr
uint8_t
expected_le
[]
=
{
0
,
0
,
0x0
,
0x1
,
0
,
0
,
0x00
,
0x1
,
0
,
0
,
0x00
,
0x01
,
0xff
,
0xff
,
0xff
,
};
static
constexpr
size_t
expected_size
=
sizeof
(
expected_be
);
static
const
uint8_t
*
const
expected
=
IsBigEndian
()
?
expected_be
:
expected_le
;
PcmExport
e
;
e
.
Open
(
SampleFormat
::
S24_P32
,
2
,
false
,
false
,
true
,
false
);
size_t
dest_size
;
auto
dest
=
e
.
Export
(
src
,
sizeof
(
src
),
dest_size
);
CPPUNIT_ASSERT_EQUAL
(
expected_size
,
dest_size
);
CPPUNIT_ASSERT
(
memcmp
(
dest
,
expected
,
dest_size
)
==
0
);
}
void
PcmExportTest
::
TestReverseEndian
()
{
static
constexpr
uint8_t
src
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
};
static
constexpr
uint8_t
expected2
[]
=
{
2
,
1
,
4
,
3
,
6
,
5
,
8
,
7
,
10
,
9
,
12
,
11
};
static
constexpr
uint8_t
expected4
[]
=
{
4
,
3
,
2
,
1
,
8
,
7
,
6
,
5
,
12
,
11
,
10
,
9
,
};
PcmExport
e
;
e
.
Open
(
SampleFormat
::
S8
,
2
,
false
,
false
,
false
,
true
);
size_t
dest_size
;
auto
dest
=
e
.
Export
(
src
,
sizeof
(
src
),
dest_size
);
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
src
),
dest_size
);
CPPUNIT_ASSERT
(
memcmp
(
dest
,
src
,
dest_size
)
==
0
);
e
.
Open
(
SampleFormat
::
S16
,
2
,
false
,
false
,
false
,
true
);
dest
=
e
.
Export
(
src
,
sizeof
(
src
),
dest_size
);
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected2
),
dest_size
);
CPPUNIT_ASSERT
(
memcmp
(
dest
,
expected2
,
dest_size
)
==
0
);
e
.
Open
(
SampleFormat
::
S32
,
2
,
false
,
false
,
false
,
true
);
dest
=
e
.
Export
(
src
,
sizeof
(
src
),
dest_size
);
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected4
),
dest_size
);
CPPUNIT_ASSERT
(
memcmp
(
dest
,
expected4
,
dest_size
)
==
0
);
}
void
PcmExportTest
::
TestDsdUsb
()
{
static
constexpr
uint8_t
src
[]
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
,
};
static
constexpr
uint32_t
expected
[]
=
{
0xff050145
,
0xff052367
,
0xfffa89cd
,
0xfffaabef
,
};
PcmExport
e
;
e
.
Open
(
SampleFormat
::
DSD
,
2
,
true
,
false
,
false
,
false
);
size_t
dest_size
;
auto
dest
=
e
.
Export
(
src
,
sizeof
(
src
),
dest_size
);
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected
),
dest_size
);
CPPUNIT_ASSERT
(
memcmp
(
dest
,
expected
,
dest_size
)
==
0
);
}
test/test_pcm_main.cxx
View file @
ee7282ce
...
@@ -31,6 +31,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(PcmChannelsTest);
...
@@ -31,6 +31,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(PcmChannelsTest);
CPPUNIT_TEST_SUITE_REGISTRATION
(
PcmVolumeTest
);
CPPUNIT_TEST_SUITE_REGISTRATION
(
PcmVolumeTest
);
CPPUNIT_TEST_SUITE_REGISTRATION
(
PcmFormatTest
);
CPPUNIT_TEST_SUITE_REGISTRATION
(
PcmFormatTest
);
CPPUNIT_TEST_SUITE_REGISTRATION
(
PcmMixTest
);
CPPUNIT_TEST_SUITE_REGISTRATION
(
PcmMixTest
);
CPPUNIT_TEST_SUITE_REGISTRATION
(
PcmExportTest
);
int
int
main
(
gcc_unused
int
argc
,
gcc_unused
char
**
argv
)
main
(
gcc_unused
int
argc
,
gcc_unused
char
**
argv
)
...
...
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