aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/test_ring_array.cpp
diff options
context:
space:
mode:
authorMatthew Gregan <[email protected]>2016-11-10 15:48:17 +1300
committerMatthew Gregan <[email protected]>2016-11-11 09:44:29 +1300
commit55ed801cfd9063ea6f18fb7578866cee8ce474c7 (patch)
tree70c29c27faca586a79b3d1f9331922f915c089b5 /test/test_ring_array.cpp
parent0d45a294eed3a1631afb35ee2b41bfe64c44b67f (diff)
downloadcubeb-55ed801cfd9063ea6f18fb7578866cee8ce474c7.tar.gz
cubeb-55ed801cfd9063ea6f18fb7578866cee8ce474c7.zip
Convert tests to gtests.
Diffstat (limited to 'test/test_ring_array.cpp')
-rw-r--r--test/test_ring_array.cpp46
1 files changed, 18 insertions, 28 deletions
diff --git a/test/test_ring_array.cpp b/test/test_ring_array.cpp
index 718e863..7135a02 100644
--- a/test/test_ring_array.cpp
+++ b/test/test_ring_array.cpp
@@ -1,19 +1,17 @@
+#include "gtest/gtest.h"
#ifdef __APPLE__
-
-#include <assert.h>
#include <string.h>
#include <iostream>
#include <CoreAudio/CoreAudioTypes.h>
-
#include "cubeb/cubeb.h"
#include "cubeb_ring_array.h"
-int test_ring_array()
+void test_ring_array()
{
ring_array ra;
- assert(ring_array_init(&ra, 0, 0, 1, 1) == CUBEB_ERROR_INVALID_PARAMETER);
- assert(ring_array_init(&ra, 1, 0, 0, 1) == CUBEB_ERROR_INVALID_PARAMETER);
+ ASSERT_TRUE(ring_array_init(&ra, 0, 0, 1, 1) == CUBEB_ERROR_INVALID_PARAMETER);
+ ASSERT_TRUE(ring_array_init(&ra, 1, 0, 0, 1) == CUBEB_ERROR_INVALID_PARAMETER);
unsigned int capacity = 8;
ring_array_init(&ra, capacity, sizeof(int), 1, 1);
@@ -23,64 +21,56 @@ int test_ring_array()
for (unsigned int i = 0; i < capacity; ++i) {
verify_data[i] = i; // in case capacity change value
*(int*)ra.buffer_array[i].mData = i;
- assert(ra.buffer_array[i].mDataByteSize == 1 * sizeof(int));
- assert(ra.buffer_array[i].mNumberChannels == 1);
+ ASSERT_TRUE(ra.buffer_array[i].mDataByteSize == 1 * sizeof(int));
+ ASSERT_TRUE(ra.buffer_array[i].mNumberChannels == 1);
}
/* Get store buffers*/
for (unsigned int i = 0; i < capacity; ++i) {
p_data = ring_array_get_free_buffer(&ra);
- assert(p_data && *(int*)p_data->mData == verify_data[i]);
+ ASSERT_TRUE(p_data && *(int*)p_data->mData == verify_data[i]);
}
/*Now array is full extra store should give NULL*/
- assert(NULL == ring_array_get_free_buffer(&ra));
+ ASSERT_TRUE(NULL == ring_array_get_free_buffer(&ra));
/* Get fetch buffers*/
for (unsigned int i = 0; i < capacity; ++i) {
p_data = ring_array_get_data_buffer(&ra);
- assert(p_data && *(int*)p_data->mData == verify_data[i]);
+ ASSERT_TRUE(p_data && *(int*)p_data->mData == verify_data[i]);
}
/*Now array is empty extra fetch should give NULL*/
- assert(NULL == ring_array_get_data_buffer(&ra));
+ ASSERT_TRUE(NULL == ring_array_get_data_buffer(&ra));
p_data = NULL;
/* Repeated store fetch should can go for ever*/
for (unsigned int i = 0; i < 2*capacity; ++i) {
p_data = ring_array_get_free_buffer(&ra);
- assert(p_data);
- assert(ring_array_get_data_buffer(&ra) == p_data);
+ ASSERT_TRUE(p_data);
+ ASSERT_TRUE(ring_array_get_data_buffer(&ra) == p_data);
}
p_data = NULL;
/* Verify/modify buffer data*/
for (unsigned int i = 0; i < capacity; ++i) {
p_data = ring_array_get_free_buffer(&ra);
- assert(p_data);
- assert(*((int*)p_data->mData) == verify_data[i]);
+ ASSERT_TRUE(p_data);
+ ASSERT_TRUE(*((int*)p_data->mData) == verify_data[i]);
(*((int*)p_data->mData))++; // Modify data
}
for (unsigned int i = 0; i < capacity; ++i) {
p_data = ring_array_get_data_buffer(&ra);
- assert(p_data);
- assert(*((int*)p_data->mData) == verify_data[i]+1); // Verify modified data
+ ASSERT_TRUE(p_data);
+ ASSERT_TRUE(*((int*)p_data->mData) == verify_data[i]+1); // Verify modified data
}
ring_array_destroy(&ra);
-
- return 0;
}
-
-int main()
+TEST(ring_array, main)
{
test_ring_array();
- return 0;
}
-
#else
-
-int main()
+TEST(ring_array, main)
{
- return 0;
}
-
#endif