fluidsynth/test
getraid-gg 1cdeebef37 Enable the use of UTF-8 filenames under Windows (#718)
While `fopen` (used through the macro `FLUID_FOPEN`) uses UTF-8 on *nix, it's restricted to ANSI on Windows. A change to enable using paths containing non-ANSI characters was suggested before in issue #128 but was rejected due to requiring large parts of both the public API and private implementation to be modified to accommodate Windows.

This PR instead changes the macro definition for `FLUID_FOPEN` from `fopen` to a new wrapper, `fluid_fopen`. This wrapper is defined in `fluidsynth_priv.h` and defined in `fluid_sys.c` (following the pattern of `fluid_alloc`). Under Windows, it converts the `const char*` UTF-8 parameters to Unicode `wchar_t*` strings using the Windows API function `MultiByteToWideChar` and opens the file using the Windows API-specific `_wfopen`. On all other platforms, it simply calls `fopen`.

The public API is unchanged. This solution will require Windows users of the API to convert UTF-16 strings to UTF-8 (which then get converted back into UTF-16 anyway), but that's still an improvement over only being able to use ANSI paths.

This PR also adds a new test, `test_utf8_open`, which tests `FLUID_FOPEN` directly and through `fluid_is_soundfont` and `fluid_synth_sfload` using a new soundfont file, `sf2/â– VintageDreamsWaves-v2â– .sf2`, which is just a copy of `VintageDreamsWaves-v2.sf2` with Unicode characters in the filename.
2020-12-22 11:30:14 +01:00
..
CMakeLists.txt Enable the use of UTF-8 filenames under Windows (#718) 2020-12-22 11:30:14 +01:00
README.md
test.h Suppress abort() dialog on windows (#549) 2019-08-06 17:29:49 +02:00
test_bug_635.c Add regression test for #635 2020-05-23 15:30:27 +02:00
test_ct2hz.c More efficient implementation of fluid_ct2hz() (#569) 2019-10-22 13:09:42 +02:00
test_jack_obtaining_synth.c Workaround for jack sample rate mismatch (#607) 2020-01-19 15:36:15 +01:00
test_pointer_alignment.c
test_preset_pinning.c Add public API to pin and unpin presets to the sample cache (#698) 2020-10-31 13:23:15 +01:00
test_preset_sample_loading.c Reactivate test_preset_sample_loading 2020-05-23 14:40:41 +02:00
test_sample_cache.c fix building CoreAudio on OSX 10.4 2019-02-15 17:55:02 +01:00
test_sample_rate_change.c fix building CoreAudio on OSX 10.4 2019-02-15 17:55:02 +01:00
test_sample_validate.c Add a unit test for fluid_sample_validate() 2020-01-24 15:57:08 +01:00
test_seq_event_queue_remove.c Remove fluid_event_any_control_change() from public API (#674) 2020-09-12 10:40:57 +02:00
test_seq_event_queue_sort.c Revise the sequencer's event queue (#604) 2020-05-26 17:16:22 +02:00
test_seq_evt_order.c Revise the sequencer's event queue (#604) 2020-05-26 17:16:22 +02:00
test_seq_scale.c Revise the sequencer's event queue (#604) 2020-05-26 17:16:22 +02:00
test_seqbind_unregister.c Update unregistering unit test 2020-01-18 09:51:19 +01:00
test_sf3_sfont_loading.c fix building CoreAudio on OSX 10.4 2019-02-15 17:55:02 +01:00
test_sfont_loading.c Slightly extend test_sfont_loading.c 2020-01-24 13:33:41 +01:00
test_snprintf.c fix building CoreAudio on OSX 10.4 2019-02-15 17:55:02 +01:00
test_synth_chorus_reverb.c Fx unit api (#673) 2020-11-22 21:02:06 +01:00
test_synth_process.c Add a unit test for fluid_synth_write_float 2019-10-22 16:08:41 +02:00
test_utf8_open.c Enable the use of UTF-8 filenames under Windows (#718) 2020-12-22 11:30:14 +01:00

This directory contains small executables to verify fluidsynths correct behaviour, i.e. unit tests.

Do not blindly use the tests as template for your application!

Although some tests might serve as educational demonstration of how to use certain parts of fluidsynth, they are not intended to do so! It is most likely that those tests will consist of many hacky parts that are necessary to test fluidsynth (e.g. including fluidsynth's private headers to access internal data types and functions). For user applications this programming style is strongly discouraged! Keep referring to the documentation and code examples listed in the API documentation.

Developers

To add a unit test just duplicate an existing one, give it a unique name and update the CMakeLists.txt by

  • adding a call to ADD_FLUID_TEST() and
  • a dependency to the custom check target.

Execute the tests via make check. Unit tests should use the VintageDreamsWaves-v2.sf2 as test soundfont. Use the TEST_SOUNDFONT macro to access it.