aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorDan Glastonbury <[email protected]>2017-05-24 11:06:09 +1000
committerDan Glastonbury <[email protected]>2017-08-29 19:05:30 +1000
commit608affca8b436cd9864e5a525f61b90400a9fa43 (patch)
tree8ad0841ed77833d4b316bb22937144a4415fba27 /test
parenta9290a21c56fd721f1ce329f2c7bc083ca70dc48 (diff)
downloadcubeb-608affca8b436cd9864e5a525f61b90400a9fa43.tar.gz
cubeb-608affca8b436cd9864e5a525f61b90400a9fa43.zip
test_sanity: Assert devid are same between two cubeb_eumerate_devices.
Diffstat (limited to 'test')
-rw-r--r--test/test_sanity.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/test_sanity.cpp b/test/test_sanity.cpp
index b630c43..db441d4 100644
--- a/test/test_sanity.cpp
+++ b/test/test_sanity.cpp
@@ -633,3 +633,42 @@ TEST(cubeb, DISABLED_stream_destroy_pending_drain)
{
// This test needs to be implemented.
}
+
+TEST(cubeb, stable_devid)
+{
+ /* Test that the devid field of cubeb_device_info is stable
+ * (ie. compares equal) over two invocations of
+ * cubeb_enumerate_devices(). */
+
+ int r;
+ cubeb * ctx;
+ cubeb_device_collection first;
+ cubeb_device_collection second;
+ cubeb_device_type all_devices =
+ (cubeb_device_type) (CUBEB_DEVICE_TYPE_INPUT | CUBEB_DEVICE_TYPE_OUTPUT);
+ size_t n;
+
+ r = common_init(&ctx, "test_sanity");
+ ASSERT_EQ(r, CUBEB_OK);
+ ASSERT_NE(ctx, nullptr);
+
+ r = cubeb_enumerate_devices(ctx, all_devices, &first);
+ if (r == CUBEB_ERROR_NOT_SUPPORTED)
+ return;
+
+ ASSERT_EQ(r, CUBEB_OK);
+
+ r = cubeb_enumerate_devices(ctx, all_devices, &second);
+ ASSERT_EQ(r, CUBEB_OK);
+
+ ASSERT_EQ(first.count, second.count);
+ for (n = 0; n < first.count; n++) {
+ ASSERT_EQ(first.device[n].devid, second.device[n].devid);
+ }
+
+ r = cubeb_device_collection_destroy(ctx, &first);
+ ASSERT_EQ(r, CUBEB_OK);
+ r = cubeb_device_collection_destroy(ctx, &second);
+ ASSERT_EQ(r, CUBEB_OK);
+ cubeb_destroy(ctx);
+}