ref: 683592180f64f5723274a9105be2f3af6208a901
parent: 271d48814912a23c7f9443bc81055cbf58ff355b
author: Marcus Asteborg <maastebo@microsoft.com>
date: Thu Jun 30 14:57:08 EDT 2022
Replace assert with test_failed function in test This will fix -Wunused-but-set-variable on gcc 9.3 release build. Also remove unused assert.h. Signed-off-by: Mark Harris <mark.hsj@gmail.com>
--- a/tests/opus_encode_regressions.c
+++ b/tests/opus_encode_regressions.c
@@ -35,7 +35,6 @@
#include <stdint.h>
#include <math.h>
#include <string.h>
-#include <assert.h>
#include "opus_multistream.h"
#include "opus.h"
#include "test_opus_common.h"
@@ -106,7 +105,7 @@
1799, 1799, 1799, 1799, -9721
};
err = opus_multistream_encode(enc, pcm, 320, data, 2460);
- assert(err > 0);
+ opus_test_assert(err > 0);
}
opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0));
@@ -144,7 +143,7 @@
-9510, -9510, -9510, -9510, -9510, -9510, -9510
};
err = opus_multistream_encode(enc, pcm, 160, data, 2460);
- assert(err > 0);
+ opus_test_assert(err > 0);
}
opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0));
@@ -182,7 +181,7 @@
-9510, -9510, -9510, -9510, -9510, -9510, -9510
};
err = opus_multistream_encode(enc, pcm, 160, data, 2460);
- assert(err > 0);
+ opus_test_assert(err > 0);
}
opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0));
@@ -220,7 +219,7 @@
-9510, -9510, -9510, -9510, -9510, -9510, -9510
};
err = opus_multistream_encode(enc, pcm, 160, data, 2460);
- assert(err > 0);
+ opus_test_assert(err > 0);
}
opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0));
@@ -256,7 +255,7 @@
5632
};
err = opus_multistream_encode(enc, pcm, 160, data, 2460);
- assert(err > 0);
+ opus_test_assert(err > 0);
}
opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE));
opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0));
@@ -281,7 +280,7 @@
0, 0, -256, 226
};
err = opus_multistream_encode(enc, pcm, 40, data, 2460);
- assert(err > 0);
+ opus_test_assert(err > 0);
/* returns -3 */
}
opus_multistream_encoder_destroy(enc);
@@ -334,7 +333,7 @@
0
};
err = opus_multistream_encode(enc, pcm, 20, data, 627300);
- assert(err > 0);
+ opus_test_assert(err > 0);
/* returns -1 */
}
opus_multistream_encoder_destroy(enc);
@@ -384,7 +383,7 @@
0
};
err = opus_multistream_encode(enc, pcm, 20, data, 472320);
- assert(err > 0);
+ opus_test_assert(err > 0);
/* returns -1 */
}
opus_multistream_encoder_destroy(enc);
@@ -740,7 +739,7 @@
-20992, 25859, 5372, 12040, 13307, -4355,-30213, -9, -6019
};
err = opus_multistream_encode(enc, pcm, 960, data, 7380);
- assert(err > 0);
+ opus_test_assert(err > 0);
}
opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(1));
@@ -885,7 +884,7 @@
};
err = opus_multistream_encode(enc, pcm, 1440, data, 7380);
/* reads uninitialized data at src/opus_multistream_encoder.c:293 */
- assert(err > 0);
+ opus_test_assert(err > 0);
}
opus_multistream_encoder_destroy(enc);
return 0;
@@ -935,7 +934,7 @@
opus_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(6));
opus_encoder_ctl(enc, OPUS_SET_BITRATE(6000));
data_len = opus_encode(enc, pcm1, 960, data, 2000);
- assert(data_len > 0);
+ opus_test_assert(data_len > 0);
opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE));
opus_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1));
@@ -943,12 +942,12 @@
opus_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1));
opus_encoder_ctl(enc, OPUS_SET_BITRATE(15600));
data_len = opus_encode(enc, pcm2, 2880, data, 122);
- assert(data_len > 0);
+ opus_test_assert(data_len > 0);
opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
opus_encoder_ctl(enc, OPUS_SET_BITRATE(27000));
data_len = opus_encode(enc, pcm3, 2880, data, 122); /* assertion failure */
- assert(data_len > 0);
+ opus_test_assert(data_len > 0);
opus_encoder_destroy(enc);
return 0;
@@ -970,7 +969,7 @@
{
static const short pcm[960] = { 0 };
data_len = opus_encode(enc, pcm, 960, data, 2000);
- assert(data_len > 0);
+ opus_test_assert(data_len > 0);
}
opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
{
@@ -980,7 +979,7 @@
-32768, -32768, 0, 0, -32768, -32768, 0, 0, -32768, -32768
};
data_len = opus_encode(enc, pcm, 480, data, 19);
- assert(data_len > 0);
+ opus_test_assert(data_len > 0);
}
opus_encoder_destroy(enc);
return 0;
@@ -1009,7 +1008,7 @@
opus_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND));
opus_encoder_ctl(enc, OPUS_SET_BITRATE(6000));
data_len = opus_encode(enc, pcm1, 160, data, 1000);
- assert(data_len > 0);
+ opus_test_assert(data_len > 0);
opus_encoder_ctl(enc, OPUS_SET_VBR(0));
opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(0));
@@ -1016,7 +1015,7 @@
opus_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_MEDIUMBAND));
opus_encoder_ctl(enc, OPUS_SET_BITRATE(2867));
data_len = opus_encode(enc, pcm2, 960, data, 1000);
- assert(data_len > 0);
+ opus_test_assert(data_len > 0);
opus_encoder_destroy(enc);
return 0;
--- a/tests/test_opus_common.h
+++ b/tests/test_opus_common.h
@@ -81,5 +81,5 @@
abort();
}
#define test_failed() _test_failed(__FILE__, __LINE__);
-
+#define opus_test_assert(cond) {if (!(cond)) {test_failed();}}
void regression_test(void);
--- a/tests/test_opus_projection.c
+++ b/tests/test_opus_projection.c
@@ -29,7 +29,6 @@
#include "config.h"
#endif
-#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>