Helper function to load test audio file into memory
| 20 | |
| 21 | // Helper function to load test audio file into memory |
| 22 | static fl::vector<fl::u8> loadTestAudioFile() { |
| 23 | fl::FILE* f = fl::fopen(TEST_AUDIO_PATH, "rb"); |
| 24 | if (!f) { |
| 25 | return fl::vector<fl::u8>(); |
| 26 | } |
| 27 | |
| 28 | // Get file size |
| 29 | fl::fseek(f, 0, fl::io::seek_end); |
| 30 | long fileSize = fl::ftell(f); |
| 31 | fl::fseek(f, 0, fl::io::seek_set); |
| 32 | |
| 33 | if (fileSize <= 0) { |
| 34 | fl::fclose(f); |
| 35 | return fl::vector<fl::u8>(); |
| 36 | } |
| 37 | |
| 38 | // Read file into vector |
| 39 | fl::vector<fl::u8> data(static_cast<fl::size>(fileSize)); |
| 40 | fl::size bytesRead = fl::fread(data.data(), 1, static_cast<fl::size>(fileSize), f); |
| 41 | fl::fclose(f); |
| 42 | |
| 43 | if (bytesRead != static_cast<fl::size>(fileSize)) { |
| 44 | return fl::vector<fl::u8>(); |
| 45 | } |
| 46 | |
| 47 | return data; |
| 48 | } |
| 49 | |
| 50 | FL_TEST_CASE("Vorbis - factory creation") { |
| 51 | // Test that the factory can create a decoder |