diff options
Diffstat (limited to 'src/tests/common/ring_buffer.cpp')
| -rw-r--r-- | src/tests/common/ring_buffer.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/tests/common/ring_buffer.cpp b/src/tests/common/ring_buffer.cpp index c883c4d56..54def22da 100644 --- a/src/tests/common/ring_buffer.cpp +++ b/src/tests/common/ring_buffer.cpp | |||
| @@ -20,60 +20,60 @@ TEST_CASE("RingBuffer: Basic Tests", "[common]") { | |||
| 20 | for (std::size_t i = 0; i < 4; i++) { | 20 | for (std::size_t i = 0; i < 4; i++) { |
| 21 | const char elem = static_cast<char>(i); | 21 | const char elem = static_cast<char>(i); |
| 22 | const std::size_t count = buf.Push(&elem, 1); | 22 | const std::size_t count = buf.Push(&elem, 1); |
| 23 | REQUIRE(count == 1); | 23 | REQUIRE(count == 1U); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | REQUIRE(buf.Size() == 4); | 26 | REQUIRE(buf.Size() == 4U); |
| 27 | 27 | ||
| 28 | // Pushing values into a full ring buffer should fail. | 28 | // Pushing values into a full ring buffer should fail. |
| 29 | { | 29 | { |
| 30 | const char elem = static_cast<char>(42); | 30 | const char elem = static_cast<char>(42); |
| 31 | const std::size_t count = buf.Push(&elem, 1); | 31 | const std::size_t count = buf.Push(&elem, 1); |
| 32 | REQUIRE(count == 0); | 32 | REQUIRE(count == 0U); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | REQUIRE(buf.Size() == 4); | 35 | REQUIRE(buf.Size() == 4U); |
| 36 | 36 | ||
| 37 | // Popping multiple values from a ring buffer with values should succeed. | 37 | // Popping multiple values from a ring buffer with values should succeed. |
| 38 | { | 38 | { |
| 39 | const std::vector<char> popped = buf.Pop(2); | 39 | const std::vector<char> popped = buf.Pop(2); |
| 40 | REQUIRE(popped.size() == 2); | 40 | REQUIRE(popped.size() == 2U); |
| 41 | REQUIRE(popped[0] == 0); | 41 | REQUIRE(popped[0] == 0); |
| 42 | REQUIRE(popped[1] == 1); | 42 | REQUIRE(popped[1] == 1); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | REQUIRE(buf.Size() == 2); | 45 | REQUIRE(buf.Size() == 2U); |
| 46 | 46 | ||
| 47 | // Popping a single value from a ring buffer with values should succeed. | 47 | // Popping a single value from a ring buffer with values should succeed. |
| 48 | { | 48 | { |
| 49 | const std::vector<char> popped = buf.Pop(1); | 49 | const std::vector<char> popped = buf.Pop(1); |
| 50 | REQUIRE(popped.size() == 1); | 50 | REQUIRE(popped.size() == 1U); |
| 51 | REQUIRE(popped[0] == 2); | 51 | REQUIRE(popped[0] == 2); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | REQUIRE(buf.Size() == 1); | 54 | REQUIRE(buf.Size() == 1U); |
| 55 | 55 | ||
| 56 | // Pushing more values than space available should partially suceed. | 56 | // Pushing more values than space available should partially suceed. |
| 57 | { | 57 | { |
| 58 | std::vector<char> to_push(6); | 58 | std::vector<char> to_push(6); |
| 59 | std::iota(to_push.begin(), to_push.end(), 88); | 59 | std::iota(to_push.begin(), to_push.end(), 88); |
| 60 | const std::size_t count = buf.Push(to_push); | 60 | const std::size_t count = buf.Push(to_push); |
| 61 | REQUIRE(count == 3); | 61 | REQUIRE(count == 3U); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | REQUIRE(buf.Size() == 4); | 64 | REQUIRE(buf.Size() == 4U); |
| 65 | 65 | ||
| 66 | // Doing an unlimited pop should pop all values. | 66 | // Doing an unlimited pop should pop all values. |
| 67 | { | 67 | { |
| 68 | const std::vector<char> popped = buf.Pop(); | 68 | const std::vector<char> popped = buf.Pop(); |
| 69 | REQUIRE(popped.size() == 4); | 69 | REQUIRE(popped.size() == 4U); |
| 70 | REQUIRE(popped[0] == 3); | 70 | REQUIRE(popped[0] == 3); |
| 71 | REQUIRE(popped[1] == 88); | 71 | REQUIRE(popped[1] == 88); |
| 72 | REQUIRE(popped[2] == 89); | 72 | REQUIRE(popped[2] == 89); |
| 73 | REQUIRE(popped[3] == 90); | 73 | REQUIRE(popped[3] == 90); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | REQUIRE(buf.Size() == 0); | 76 | REQUIRE(buf.Size() == 0U); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | TEST_CASE("RingBuffer: Threaded Test", "[common]") { | 79 | TEST_CASE("RingBuffer: Threaded Test", "[common]") { |
| @@ -93,7 +93,7 @@ TEST_CASE("RingBuffer: Threaded Test", "[common]") { | |||
| 93 | std::size_t i = 0; | 93 | std::size_t i = 0; |
| 94 | while (i < count) { | 94 | while (i < count) { |
| 95 | if (const std::size_t c = buf.Push(&value[0], 1); c > 0) { | 95 | if (const std::size_t c = buf.Push(&value[0], 1); c > 0) { |
| 96 | REQUIRE(c == 1); | 96 | REQUIRE(c == 1U); |
| 97 | i++; | 97 | i++; |
| 98 | next_value(value); | 98 | next_value(value); |
| 99 | } else { | 99 | } else { |
| @@ -108,7 +108,7 @@ TEST_CASE("RingBuffer: Threaded Test", "[common]") { | |||
| 108 | std::size_t i = 0; | 108 | std::size_t i = 0; |
| 109 | while (i < count) { | 109 | while (i < count) { |
| 110 | if (const std::vector<char> v = buf.Pop(1); v.size() > 0) { | 110 | if (const std::vector<char> v = buf.Pop(1); v.size() > 0) { |
| 111 | REQUIRE(v.size() == 2); | 111 | REQUIRE(v.size() == 2U); |
| 112 | REQUIRE(v[0] == value[0]); | 112 | REQUIRE(v[0] == value[0]); |
| 113 | REQUIRE(v[1] == value[1]); | 113 | REQUIRE(v[1] == value[1]); |
| 114 | i++; | 114 | i++; |
| @@ -123,7 +123,7 @@ TEST_CASE("RingBuffer: Threaded Test", "[common]") { | |||
| 123 | producer.join(); | 123 | producer.join(); |
| 124 | consumer.join(); | 124 | consumer.join(); |
| 125 | 125 | ||
| 126 | REQUIRE(buf.Size() == 0); | 126 | REQUIRE(buf.Size() == 0U); |
| 127 | printf("RingBuffer: Threaded Test: full: %zu, empty: %zu\n", full, empty); | 127 | printf("RingBuffer: Threaded Test: full: %zu, empty: %zu\n", full, empty); |
| 128 | } | 128 | } |
| 129 | 129 | ||