summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Asteborg <maastebo@microsoft.com>2022-06-30 18:57:08 -0700
committerMark Harris <mark.hsj@gmail.com>2022-07-05 19:07:43 -0700
commit683592180f64f5723274a9105be2f3af6208a901 (patch)
tree5c61d85ca034181dbd6fee7c7a91b406c7df67e6
parent271d48814912a23c7f9443bc81055cbf58ff355b (diff)
downloadopus-683592180f64f5723274a9105be2f3af6208a901.tar.gz
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>
-rw-r--r--tests/opus_encode_regressions.c35
-rw-r--r--tests/test_opus_common.h2
-rw-r--r--tests/test_opus_projection.c1
3 files changed, 18 insertions, 20 deletions
diff --git a/tests/opus_encode_regressions.c b/tests/opus_encode_regressions.c
index 29234730..4d506eb6 100644
--- 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 @@ static int celt_ec_internal_error(void)
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 @@ static int celt_ec_internal_error(void)
-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 @@ static int celt_ec_internal_error(void)
-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 @@ static int celt_ec_internal_error(void)
-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 @@ static int celt_ec_internal_error(void)
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 @@ static int celt_ec_internal_error(void)
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 @@ static int mscbr_encode_fail10(void)
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 @@ static int mscbr_encode_fail(void)
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 @@ static int surround_analysis_uninit(void)
-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 @@ static int surround_analysis_uninit(void)
};
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 @@ static int ec_enc_shrink_assert(void)
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 @@ static int ec_enc_shrink_assert(void)
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 int ec_enc_shrink_assert2(void)
{
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 @@ static int ec_enc_shrink_assert2(void)
-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,14 +1008,14 @@ static int silk_gain_assert(void)
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));
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;
diff --git a/tests/test_opus_common.h b/tests/test_opus_common.h
index d96c7d84..5fb924f4 100644
--- a/tests/test_opus_common.h
+++ b/tests/test_opus_common.h
@@ -81,5 +81,5 @@ static OPUS_INLINE void _test_failed(const char *file, int line)
abort();
}
#define test_failed() _test_failed(__FILE__, __LINE__);
-
+#define opus_test_assert(cond) {if (!(cond)) {test_failed();}}
void regression_test(void);
diff --git a/tests/test_opus_projection.c b/tests/test_opus_projection.c
index 5f0d672c..4e06613e 100644
--- 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>