From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- media/libcubeb/tests/test_utils.cpp | 80 +++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 media/libcubeb/tests/test_utils.cpp (limited to 'media/libcubeb/tests/test_utils.cpp') diff --git a/media/libcubeb/tests/test_utils.cpp b/media/libcubeb/tests/test_utils.cpp new file mode 100644 index 000000000..f52cd3196 --- /dev/null +++ b/media/libcubeb/tests/test_utils.cpp @@ -0,0 +1,80 @@ +#include +#include "cubeb_utils.h" + +int test_auto_array() +{ + auto_array array; + auto_array array2(10); + uint32_t a[10]; + + assert(array2.length() == 0); + assert(array2.capacity() == 10); + + + for (uint32_t i = 0; i < 10; i++) { + a[i] = i; + } + + assert(array.capacity() == 0); + assert(array.length() == 0); + + array.push(a, 10); + + assert(!array.reserve(9)); + + for (uint32_t i = 0; i < 10; i++) { + assert(array.data()[i] == i); + } + + assert(array.capacity() == 10); + assert(array.length() == 10); + + uint32_t b[10]; + + array.pop(b, 5); + + assert(array.capacity() == 10); + assert(array.length() == 5); + for (uint32_t i = 0; i < 5; i++) { + assert(b[i] == i); + assert(array.data()[i] == 5 + i); + } + uint32_t* bb = b + 5; + array.pop(bb, 5); + + assert(array.capacity() == 10); + assert(array.length() == 0); + for (uint32_t i = 0; i < 5; i++) { + assert(bb[i] == 5 + i); + } + + assert(!array.pop(nullptr, 1)); + + array.push(a, 10); + array.push(a, 10); + + for (uint32_t j = 0; j < 2; j++) { + for (uint32_t i = 0; i < 10; i++) { + assert(array.data()[10 * j + i] == i); + } + } + assert(array.length() == 20); + assert(array.capacity() == 20); + array.pop(nullptr, 5); + + for (uint32_t i = 0; i < 5; i++) { + assert(array.data()[i] == 5 + i); + } + + assert(array.length() == 15); + assert(array.capacity() == 20); + + return 0; +} + + +int main() +{ + test_auto_array(); + return 0; +} -- cgit v1.2.3