Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
22a5c65c
Commit
22a5c65c
authored
Feb 18, 2025
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests.
parent
cff683a1
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
9441 additions
and
124 deletions
+9441
-124
external/fs/fs.c
external/fs/fs.c
+8207
-0
external/fs/fs.h
external/fs/fs.h
+1177
-0
tests/test_automated/ma_test_automated.c
tests/test_automated/ma_test_automated.c
+2
-26
tests/test_common/ma_test_common.c
tests/test_common/ma_test_common.c
+36
-1
tests/test_filtering/ma_test_filtering.c
tests/test_filtering/ma_test_filtering.c
+12
-63
tests/test_generation/ma_test_generation.c
tests/test_generation/ma_test_generation.c
+3
-31
tests/test_generation/ma_test_generation_noise.c
tests/test_generation/ma_test_generation_noise.c
+4
-3
No files found.
external/fs/fs.c
0 → 100644
View file @
22a5c65c
This diff is collapsed.
Click to expand it.
external/fs/fs.h
0 → 100644
View file @
22a5c65c
This diff is collapsed.
Click to expand it.
tests/test_automated/ma_test_automated.c
View file @
22a5c65c
...
...
@@ -4,31 +4,7 @@
int
main
(
int
argc
,
char
**
argv
)
{
ma_result
result
;
ma_bool32
hasError
=
MA_FALSE
;
size_t
iTest
;
ma_register_test
(
"Data Conversion"
,
test_entry__data_converter
);
(
void
)
argc
;
(
void
)
argv
;
result
=
ma_register_test
(
"Data Conversion"
,
test_entry__data_converter
);
if
(
result
!=
MA_SUCCESS
)
{
return
result
;
}
for
(
iTest
=
0
;
iTest
<
g_Tests
.
count
;
iTest
+=
1
)
{
printf
(
"=== BEGIN %s ===
\n
"
,
g_Tests
.
pTests
[
iTest
].
pName
);
result
=
g_Tests
.
pTests
[
iTest
].
onEntry
(
argc
,
argv
);
printf
(
"=== END %s : %s ===
\n
"
,
g_Tests
.
pTests
[
iTest
].
pName
,
(
result
==
0
)
?
"PASSED"
:
"FAILED"
);
if
(
result
!=
0
)
{
hasError
=
MA_TRUE
;
}
}
if
(
hasError
)
{
return
-
1
;
/* Something failed. */
}
else
{
return
0
;
/* Everything passed. */
}
return
ma_run_tests
(
argc
,
argv
);
}
tests/test_common/ma_test_common.c
View file @
22a5c65c
#include "../../miniaudio.c"
#include "../../external/fs/fs.c"
#include <stdio.h>
#define MAX_TESTS 64
#define TEST_OUTPUT_DIR "
res/
output"
#define TEST_OUTPUT_DIR "output"
typedef
int
(
*
ma_test_entry_proc
)(
int
argc
,
char
**
argv
);
...
...
@@ -36,3 +37,37 @@ ma_result ma_register_test(const char* pName, ma_test_entry_proc onEntry)
return
MA_SUCCESS
;
}
int
ma_run_tests
(
int
argc
,
char
**
argv
)
{
int
result
;
ma_bool32
hasError
=
MA_FALSE
;
size_t
iTest
;
fs
*
pFS
;
if
(
fs_init
(
NULL
,
&
pFS
)
!=
FS_SUCCESS
)
{
printf
(
"Failed to initialize the file system.
\n
"
);
return
1
;
}
fs_mkdir
(
pFS
,
TEST_OUTPUT_DIR
);
for
(
iTest
=
0
;
iTest
<
g_Tests
.
count
;
iTest
+=
1
)
{
printf
(
"=== BEGIN %s ===
\n
"
,
g_Tests
.
pTests
[
iTest
].
pName
);
result
=
g_Tests
.
pTests
[
iTest
].
onEntry
(
argc
,
argv
);
printf
(
"=== END %s : %s ===
\n
"
,
g_Tests
.
pTests
[
iTest
].
pName
,
(
result
==
0
)
?
"PASSED"
:
"FAILED"
);
if
(
result
!=
0
)
{
hasError
=
MA_TRUE
;
}
}
fs_uninit
(
pFS
);
pFS
=
NULL
;
if
(
hasError
)
{
return
1
;
/* Something failed. */
}
else
{
return
0
;
/* Everything passed. */
}
}
tests/test_filtering/ma_test_filtering.c
View file @
22a5c65c
...
...
@@ -9,12 +9,14 @@ ma_result filtering_init_decoder_and_encoder(const char* pInputFilePath, const c
decoderConfig
=
ma_decoder_config_init
(
format
,
channels
,
sampleRate
);
result
=
ma_decoder_init_file
(
pInputFilePath
,
&
decoderConfig
,
pDecoder
);
if
(
result
!=
MA_SUCCESS
)
{
printf
(
"Failed to open
\"
%s
\"
for decoding. %s
\n
"
,
pInputFilePath
,
ma_result_description
(
result
));
return
result
;
}
encoderConfig
=
ma_encoder_config_init
(
ma_encoding_format_wav
,
pDecoder
->
outputFormat
,
pDecoder
->
outputChannels
,
pDecoder
->
outputSampleRate
);
result
=
ma_encoder_init_file
(
pOutputFilePath
,
&
encoderConfig
,
pEncoder
);
if
(
result
!=
MA_SUCCESS
)
{
printf
(
"Failed to open
\"
%s
\"
for encoding. %s
\n
"
,
pOutputFilePath
,
ma_result_description
(
result
));
ma_decoder_uninit
(
pDecoder
);
return
result
;
}
...
...
@@ -33,67 +35,14 @@ ma_result filtering_init_decoder_and_encoder(const char* pInputFilePath, const c
int
main
(
int
argc
,
char
**
argv
)
{
ma_result
result
;
ma_bool32
hasError
=
MA_FALSE
;
size_t
iTest
;
(
void
)
argc
;
(
void
)
argv
;
result
=
ma_register_test
(
"Dithering"
,
test_entry__dithering
);
if
(
result
!=
MA_SUCCESS
)
{
hasError
=
MA_TRUE
;
}
result
=
ma_register_test
(
"Low-Pass Filtering"
,
test_entry__lpf
);
if
(
result
!=
MA_SUCCESS
)
{
hasError
=
MA_TRUE
;
}
result
=
ma_register_test
(
"High-Pass Filtering"
,
test_entry__hpf
);
if
(
result
!=
MA_SUCCESS
)
{
hasError
=
MA_TRUE
;
}
result
=
ma_register_test
(
"Band-Pass Filtering"
,
test_entry__bpf
);
if
(
result
!=
MA_SUCCESS
)
{
hasError
=
MA_TRUE
;
}
result
=
ma_register_test
(
"Notching Filtering"
,
test_entry__notch
);
if
(
result
!=
MA_SUCCESS
)
{
hasError
=
MA_TRUE
;
}
result
=
ma_register_test
(
"Peaking EQ Filtering"
,
test_entry__peak
);
if
(
result
!=
MA_SUCCESS
)
{
hasError
=
MA_TRUE
;
}
result
=
ma_register_test
(
"Low Shelf Filtering"
,
test_entry__loshelf
);
if
(
result
!=
MA_SUCCESS
)
{
hasError
=
MA_TRUE
;
}
result
=
ma_register_test
(
"High Shelf Filtering"
,
test_entry__hishelf
);
if
(
result
!=
MA_SUCCESS
)
{
hasError
=
MA_TRUE
;
}
for
(
iTest
=
0
;
iTest
<
g_Tests
.
count
;
iTest
+=
1
)
{
printf
(
"=== BEGIN %s ===
\n
"
,
g_Tests
.
pTests
[
iTest
].
pName
);
result
=
g_Tests
.
pTests
[
iTest
].
onEntry
(
argc
,
argv
);
printf
(
"=== END %s : %s ===
\n
"
,
g_Tests
.
pTests
[
iTest
].
pName
,
(
result
==
0
)
?
"PASSED"
:
"FAILED"
);
if
(
result
!=
0
)
{
hasError
=
MA_TRUE
;
}
}
if
(
hasError
)
{
return
-
1
;
/* Something failed. */
}
else
{
return
0
;
/* Everything passed. */
}
ma_register_test
(
"Dithering"
,
test_entry__dithering
);
ma_register_test
(
"Low-Pass Filtering"
,
test_entry__lpf
);
ma_register_test
(
"High-Pass Filtering"
,
test_entry__hpf
);
ma_register_test
(
"Band-Pass Filtering"
,
test_entry__bpf
);
ma_register_test
(
"Notching Filtering"
,
test_entry__notch
);
ma_register_test
(
"Peaking EQ Filtering"
,
test_entry__peak
);
ma_register_test
(
"Low Shelf Filtering"
,
test_entry__loshelf
);
ma_register_test
(
"High Shelf Filtering"
,
test_entry__hishelf
);
return
ma_run_tests
(
argc
,
argv
);
}
tests/test_generation/ma_test_generation.c
View file @
22a5c65c
...
...
@@ -6,36 +6,8 @@
int
main
(
int
argc
,
char
**
argv
)
{
ma_result
result
;
ma_bool32
hasError
=
MA_FALSE
;
size_t
iTest
;
ma_register_test
(
"Noise"
,
test_entry__noise
);
ma_register_test
(
"Waveform"
,
test_entry__waveform
);
(
void
)
argc
;
(
void
)
argv
;
result
=
ma_register_test
(
"Noise"
,
test_entry__noise
);
if
(
result
!=
MA_SUCCESS
)
{
return
result
;
}
result
=
ma_register_test
(
"Waveform"
,
test_entry__waveform
);
if
(
result
!=
MA_SUCCESS
)
{
return
result
;
}
for
(
iTest
=
0
;
iTest
<
g_Tests
.
count
;
iTest
+=
1
)
{
printf
(
"=== BEGIN %s ===
\n
"
,
g_Tests
.
pTests
[
iTest
].
pName
);
result
=
g_Tests
.
pTests
[
iTest
].
onEntry
(
argc
,
argv
);
printf
(
"=== END %s : %s ===
\n
"
,
g_Tests
.
pTests
[
iTest
].
pName
,
(
result
==
0
)
?
"PASSED"
:
"FAILED"
);
if
(
result
!=
0
)
{
hasError
=
MA_TRUE
;
}
}
if
(
hasError
)
{
return
-
1
;
/* Something failed. */
}
else
{
return
0
;
/* Everything passed. */
}
return
ma_run_tests
(
argc
,
argv
);
}
tests/test_generation/ma_test_generation_noise.c
View file @
22a5c65c
...
...
@@ -19,6 +19,7 @@ ma_result test_noise__by_format_and_type(ma_format format, ma_noise_type type, c
encoderConfig
=
ma_encoder_config_init
(
ma_encoding_format_wav
,
format
,
noiseConfig
.
channels
,
48000
);
result
=
ma_encoder_init_file
(
pFileName
,
&
encoderConfig
,
&
encoder
);
if
(
result
!=
MA_SUCCESS
)
{
printf
(
"Failed to open
\"
%s
\"
for writing. %s
\n
"
,
pFileName
,
ma_result_description
(
result
));
return
result
;
}
...
...
@@ -65,17 +66,17 @@ ma_result test_noise__s16()
ma_result
result
;
ma_bool32
hasError
=
MA_FALSE
;
result
=
test_noise__by_format_and_type
(
ma_format_s16
,
ma_noise_type_white
,
TEST_OUTPUT_DIR
"/
output/
noise_s16_white.wav"
);
result
=
test_noise__by_format_and_type
(
ma_format_s16
,
ma_noise_type_white
,
TEST_OUTPUT_DIR
"/noise_s16_white.wav"
);
if
(
result
!=
MA_SUCCESS
)
{
hasError
=
MA_TRUE
;
}
result
=
test_noise__by_format_and_type
(
ma_format_s16
,
ma_noise_type_pink
,
TEST_OUTPUT_DIR
"/
output/
noise_s16_pink.wav"
);
result
=
test_noise__by_format_and_type
(
ma_format_s16
,
ma_noise_type_pink
,
TEST_OUTPUT_DIR
"/noise_s16_pink.wav"
);
if
(
result
!=
MA_SUCCESS
)
{
hasError
=
MA_TRUE
;
}
result
=
test_noise__by_format_and_type
(
ma_format_s16
,
ma_noise_type_brownian
,
TEST_OUTPUT_DIR
"/
output/
noise_s16_brownian.wav"
);
result
=
test_noise__by_format_and_type
(
ma_format_s16
,
ma_noise_type_brownian
,
TEST_OUTPUT_DIR
"/noise_s16_brownian.wav"
);
if
(
result
!=
MA_SUCCESS
)
{
hasError
=
MA_TRUE
;
}
...
...
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