From 987784b62966846d6ad1a30441d636faf0b8d6fb Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 5 Jul 2022 16:22:26 +0200 Subject: [PATCH] tests: add test for s24/u24 swap --- spa/plugins/audioconvert/test-fmt-ops.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spa/plugins/audioconvert/test-fmt-ops.c b/spa/plugins/audioconvert/test-fmt-ops.c index 4049a6ab5..a0e719208 100644 --- a/spa/plugins/audioconvert/test-fmt-ops.c +++ b/spa/plugins/audioconvert/test-fmt-ops.c @@ -604,6 +604,28 @@ static void test_lossless_u32(void) } } +static void test_swaps(void) +{ + { + uint24_t v = U32_TO_U24(0x123456); + uint24_t t = U32_TO_U24(0x563412); + uint24_t s = bswap_u24(v); + spa_assert_se(memcmp(&s, &t, sizeof(t)) == 0); + } + { + int24_t v = S32_TO_S24(0xfffe1dc0); + int24_t t = S32_TO_S24(0xffc01dfe); + int24_t s = bswap_s24(v); + spa_assert_se(memcmp(&s, &t, sizeof(t)) == 0); + } + { + int24_t v = S32_TO_S24(0x123456); + int24_t t = S32_TO_S24(0x563412); + int24_t s = bswap_s24(v); + spa_assert_se(memcmp(&s, &t, sizeof(t)) == 0); + } +} + int main(int argc, char *argv[]) { cpu_flags = get_cpu_flags(); @@ -640,5 +662,7 @@ int main(int argc, char *argv[]) test_lossless_u24(); test_lossless_s32(); test_lossless_u32(); + + test_swaps(); return 0; }