circular_queue.test.cc (13482:6af7a10675b4) circular_queue.test.cc (13796:ca1eed45ebe5)
1/*
2 * Copyright (c) 2018 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 198 unchanged lines hidden (view full) ---

207 ASSERT_FALSE(it_1 > it_2);
208 ASSERT_FALSE(it_1 >= it_2);
209 ASSERT_TRUE(it_1 < it_2);
210 ASSERT_TRUE(it_1 <= it_2);
211 ASSERT_EQ(*it_1, first_value);
212 ASSERT_EQ(it_1 + 1, it_2);
213 ASSERT_EQ(it_1, it_2 - 1);
214 ASSERT_EQ(it_2 - it_1, 1);
1/*
2 * Copyright (c) 2018 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 198 unchanged lines hidden (view full) ---

207 ASSERT_FALSE(it_1 > it_2);
208 ASSERT_FALSE(it_1 >= it_2);
209 ASSERT_TRUE(it_1 < it_2);
210 ASSERT_TRUE(it_1 <= it_2);
211 ASSERT_EQ(*it_1, first_value);
212 ASSERT_EQ(it_1 + 1, it_2);
213 ASSERT_EQ(it_1, it_2 - 1);
214 ASSERT_EQ(it_2 - it_1, 1);
215 ASSERT_EQ(it_1 - it_2, -1);
215
216 auto temp_it = it_1;
217 ASSERT_EQ(++temp_it, it_2);
218 ASSERT_EQ(--temp_it, it_1);
219 ASSERT_EQ(temp_it++, it_1);
220 ASSERT_EQ(temp_it, it_2);
221 ASSERT_EQ(temp_it--, it_2);
222 ASSERT_EQ(temp_it, it_1);

--- 13 unchanged lines hidden (view full) ---

236 // ending_it does a full loop and points at the same
237 // index as starting_it but with a different round
238 auto starting_it = cq.begin();
239 auto ending_it = starting_it + cq_size;
240
241 ASSERT_EQ(starting_it._idx, ending_it._idx);
242 ASSERT_TRUE(starting_it != ending_it);
243}
216
217 auto temp_it = it_1;
218 ASSERT_EQ(++temp_it, it_2);
219 ASSERT_EQ(--temp_it, it_1);
220 ASSERT_EQ(temp_it++, it_1);
221 ASSERT_EQ(temp_it, it_2);
222 ASSERT_EQ(temp_it--, it_2);
223 ASSERT_EQ(temp_it, it_1);

--- 13 unchanged lines hidden (view full) ---

237 // ending_it does a full loop and points at the same
238 // index as starting_it but with a different round
239 auto starting_it = cq.begin();
240 auto ending_it = starting_it + cq_size;
241
242 ASSERT_EQ(starting_it._idx, ending_it._idx);
243 ASSERT_TRUE(starting_it != ending_it);
244}
245
246/**
247 * Testing correct behaviour when rounding multiple times:
248 * - Round indexes in sync
249 * - Difference between begin() and end() iterator is still
250 * equal to the CircularQueue size.
251 */
252TEST(CircularQueueTest, MultipleRound)
253{
254 const auto cq_size = 8;
255 CircularQueue<uint32_t> cq(cq_size);
256
257 // Filling the queue making it round multiple times
258 auto items_added = cq_size * 3;
259 for (auto idx = 0; idx < items_added; idx++) {
260 cq.push_back(0);
261 }
262
263 auto starting_it = cq.begin();
264 auto ending_it = cq.end();
265
266 ASSERT_EQ(starting_it._round + 1, ending_it._round);
267 ASSERT_EQ(ending_it - starting_it, cq_size);
268}