MCPcopy Create free account
hub / github.com/Tracktion/choc / testAudioFileFormat

Function testAudioFileFormat

tests/choc_tests.h:3128–3202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3126
3127 {
3128 CHOC_TEST (StableSort)
3129
3130 for (int len = 0; len < 500; ++len)
3131 {
3132 std::vector<int> v;
3133
3134 for (int i = 0; i < len; ++i)
3135 v.push_back (rand() & 63);
3136
3137 {
3138 auto comp = [] (int a, int b) { return a / 2 < b / 2; };
3139
3140 auto v2 = v;
3141 std::stable_sort (v2.begin(), v2.end(), comp);
3142
3143 auto v3 = v;
3144 choc::sorting::stable_sort (v3.begin(), v3.end(), comp);
3145 CHOC_EXPECT_TRUE (v2 == v3);
3146
3147 auto v4 = v;
3148 choc::sorting::stable_sort (v4.data(), v4.data() + v4.size(), comp);
3149 CHOC_EXPECT_TRUE (v2 == v4);
3150 }
3151
3152 auto v2 = v;
3153 std::stable_sort (v2.begin(), v2.end());
3154
3155 auto v3 = v;
3156 choc::sorting::stable_sort (v3.begin(), v3.end());
3157 CHOC_EXPECT_TRUE (v2 == v3);
3158
3159 auto v4 = v;
3160 choc::sorting::stable_sort (v4.data(), v4.data() + v4.size());
3161 CHOC_EXPECT_TRUE (v2 == v4);
3162 }
3163 }
3164}
3165
3166//==============================================================================
3167template <typename FileFormat, typename BufferSampleType>
3168inline void testAudioFileRoundTrip (choc::test::TestProgress& progress, choc::audio::BitDepth bitDepth,
3169 double sampleRate, uint32_t numChannels, uint32_t length,
3170 std::string quality, BufferSampleType maxDiff)
3171{
3172 auto compareBuffers = [&] (const auto& buffer1, const auto& buffer2)
3173 {
3174 if (maxDiff == 0)
3175 {
3176 maxDiff = 1.0f / 1000000.0f;
3177 if (bitDepth == choc::audio::BitDepth::int8) maxDiff = 1.0f / 127.0f;
3178 if (bitDepth == choc::audio::BitDepth::int16) maxDiff = 1.0f / 32767.0f;
3179 }
3180
3181 auto size = buffer1.getSize();
3182 CHOC_EXPECT_EQ (size.numFrames, buffer2.getSize().numFrames);
3183 CHOC_EXPECT_EQ (size.numChannels, buffer2.getSize().numChannels);
3184
3185 if (size.numFrames != 0)

Callers

nothing calls this directly

Calls 3

CHOC_TESTFunction · 0.85
frontMethod · 0.80
getSupportedBitDepthsMethod · 0.45

Tested by

no test coverage detected