diff options
author | Chun-Min Chang <[email protected]> | 2017-04-07 11:44:24 +0800 |
---|---|---|
committer | Matthew Gregan <[email protected]> | 2017-04-07 15:44:24 +1200 |
commit | 2b1132b1e8aa16760fcb9d13b1f79273ac183b77 (patch) | |
tree | fe0d6353c2c76d8241f409121e379a48f836c02b /test/test_duplex.cpp | |
parent | 61aaac299d00b803452193ccffdee83dcce7cec4 (diff) | |
download | cubeb-2b1132b1e8aa16760fcb9d13b1f79273ac183b77.tar.gz cubeb-2b1132b1e8aa16760fcb9d13b1f79273ac183b77.zip |
Using gtest style's error message in cubeb (#274)
* Replace printf by fprintf
* Turn error log into gtest's style
* Avoid scan-build warning by replacing raw pointer with unique_ptr
Diffstat (limited to 'test/test_duplex.cpp')
-rw-r--r-- | test/test_duplex.cpp | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/test/test_duplex.cpp b/test/test_duplex.cpp index 42fdaf4..4117c02 100644 --- a/test/test_duplex.cpp +++ b/test/test_duplex.cpp @@ -61,13 +61,13 @@ void state_cb_duplex(cubeb_stream * stream, void * /*user*/, cubeb_state state) switch (state) { case CUBEB_STATE_STARTED: - printf("stream started\n"); break; + fprintf(stderr, "stream started\n"); break; case CUBEB_STATE_STOPPED: - printf("stream stopped\n"); break; + fprintf(stderr, "stream stopped\n"); break; case CUBEB_STATE_DRAINED: - printf("stream drained\n"); break; + fprintf(stderr, "stream drained\n"); break; default: - printf("unknown stream state %d\n", state); + fprintf(stderr, "unknown stream state %d\n", state); } return; @@ -84,10 +84,7 @@ TEST(cubeb, duplex) uint32_t latency_frames = 0; r = cubeb_init(&ctx, "Cubeb duplex example", NULL); - if (r != CUBEB_OK) { - fprintf(stderr, "Error initializing cubeb library\n"); - ASSERT_EQ(r, CUBEB_OK); - } + ASSERT_EQ(r, CUBEB_OK) << "Error initializing cubeb library"; std::unique_ptr<cubeb, decltype(&cubeb_destroy)> cleanup_cubeb_at_exit(ctx, cubeb_destroy); @@ -109,19 +106,12 @@ TEST(cubeb, duplex) output_params.layout = CUBEB_LAYOUT_STEREO; r = cubeb_get_min_latency(ctx, output_params, &latency_frames); - - if (r != CUBEB_OK) { - fprintf(stderr, "Could not get minimal latency\n"); - ASSERT_EQ(r, CUBEB_OK); - } + ASSERT_EQ(r, CUBEB_OK) << "Could not get minimal latency"; r = cubeb_stream_init(ctx, &stream, "Cubeb duplex", NULL, &input_params, NULL, &output_params, latency_frames, data_cb_duplex, state_cb_duplex, &stream_state); - if (r != CUBEB_OK) { - fprintf(stderr, "Error initializing cubeb stream\n"); - ASSERT_EQ(r, CUBEB_OK); - } + ASSERT_EQ(r, CUBEB_OK) << "Error initializing cubeb stream"; std::unique_ptr<cubeb_stream, decltype(&cubeb_stream_destroy)> cleanup_stream_at_exit(stream, cubeb_stream_destroy); |