summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-10-06 10:10:01 +0200
committerCarl Hetherington <cth@carlh.net>2020-10-13 18:51:11 +0200
commit58db95ab6a40c67ebf961ff243adb9e4dac4444c (patch)
tree234f110773075ed7f88f20e68adeb7d53a1497cb
parent387488c4d18ce616e3f0f64e8339ca20b843fb7e (diff)
Remove dependency on srand() and predictable output from rand()
to work around a strange problem on Windows where this test would fail with the random values offset by 1 step.
-rw-r--r--test/audio_analysis_test.cc11
1 files changed, 4 insertions, 7 deletions
diff --git a/test/audio_analysis_test.cc b/test/audio_analysis_test.cc
index 5cf8c0271..c3a83186e 100644
--- a/test/audio_analysis_test.cc
+++ b/test/audio_analysis_test.cc
@@ -55,8 +55,6 @@ BOOST_AUTO_TEST_CASE (audio_analysis_serialisation_test)
int const channels = 3;
int const points = 4096;
- srand (1);
-
AudioAnalysis a (3);
for (int i = 0; i < channels; ++i) {
for (int j = 0; j < points; ++j) {
@@ -77,15 +75,14 @@ BOOST_AUTO_TEST_CASE (audio_analysis_serialisation_test)
a.set_sample_rate (48000);
a.write ("build/test/audio_analysis_serialisation_test");
- srand (1);
-
AudioAnalysis b ("build/test/audio_analysis_serialisation_test");
for (int i = 0; i < channels; ++i) {
BOOST_CHECK_EQUAL (b.points(i), points);
for (int j = 0; j < points; ++j) {
- AudioPoint p = b.get_point (i, j);
- BOOST_CHECK_CLOSE (p[AudioPoint::PEAK], random_float (), 1);
- BOOST_CHECK_CLOSE (p[AudioPoint::RMS], random_float (), 1);
+ AudioPoint p = a.get_point (i, j);
+ AudioPoint q = b.get_point (i, j);
+ BOOST_CHECK_CLOSE (p[AudioPoint::PEAK], q[AudioPoint::PEAK], 1);
+ BOOST_CHECK_CLOSE (p[AudioPoint::RMS], q[AudioPoint::RMS], 1);
}
}