Advanced Chunk Processing Library
0.2.0
A comprehensive C++ library for advanced data chunking strategies and processing operations
Loading...
Searching...
No Matches
data_structures_test.cpp
Go to the documentation of this file.
1
#include "
data_structures.hpp
"
2
#include "gtest/gtest.h"
3
4
TEST
(CircularBufferTest, BasicOperations) {
5
CircularBuffer<int>
buffer(3);
6
EXPECT_TRUE(buffer.
empty
());
7
EXPECT_FALSE(buffer.
full
());
8
9
buffer.
push
(1);
10
EXPECT_EQ(buffer.
size
(), 1);
11
12
buffer.
push
(2);
13
buffer.
push
(3);
14
EXPECT_TRUE(buffer.
full
());
15
16
buffer.
push
(4);
// Should overwrite 1
17
auto
vec = buffer.
to_vector
();
18
EXPECT_EQ(vec.size(), 3);
19
EXPECT_EQ(vec[0], 2);
20
EXPECT_EQ(vec[2], 4);
21
}
22
23
TEST
(SlidingWindowTest, Average) {
24
SlidingWindow<double>
window(3);
25
window.
push
(1.0);
26
window.
push
(2.0);
27
window.
push
(3.0);
28
EXPECT_DOUBLE_EQ(window.
average
(), 2.0);
29
30
window.
push
(4.0);
31
EXPECT_DOUBLE_EQ(window.
average
(), 3.0);
32
}
33
34
TEST
(ChunkListTest, Operations) {
35
ChunkList<int>
list;
36
list.
append_chunk
({1, 2});
37
list.
append_chunk
({3, 4});
38
list.
prepend_chunk
({-1, 0});
39
40
auto
flat = list.
flatten
();
41
EXPECT_EQ(flat.size(), 6);
42
EXPECT_EQ(flat[0], -1);
43
EXPECT_EQ(flat[5], 4);
44
}
45
46
TEST
(PriorityQueueTest, Ordering) {
47
PriorityQueue<int>
pq;
48
pq.
push
(3);
49
pq.
push
(1);
50
pq.
push
(4);
51
52
EXPECT_EQ(pq.
pop
(), 4);
53
EXPECT_EQ(pq.
pop
(), 3);
54
EXPECT_EQ(pq.
pop
(), 1);
55
EXPECT_TRUE(pq.
empty
());
56
}
ChunkList
Definition
data_structures.hpp:192
ChunkList::flatten
std::vector< T > flatten() const
Definition
data_structures.hpp:223
ChunkList::prepend_chunk
void prepend_chunk(const std::vector< T > &chunk_data)
Definition
data_structures.hpp:211
ChunkList::append_chunk
void append_chunk(const std::vector< T > &chunk_data)
Definition
data_structures.hpp:199
CircularBuffer
Definition
data_structures.hpp:11
CircularBuffer::to_vector
std::vector< T > to_vector() const
Definition
data_structures.hpp:57
CircularBuffer::full
bool full() const
Definition
data_structures.hpp:47
CircularBuffer::push
void push(const T &item)
Definition
data_structures.hpp:25
CircularBuffer::size
size_t size() const
Definition
data_structures.hpp:50
CircularBuffer::empty
bool empty() const
Definition
data_structures.hpp:44
PriorityQueue
Definition
data_structures.hpp:71
PriorityQueue::push
void push(const T &item)
Definition
data_structures.hpp:111
PriorityQueue::empty
bool empty() const
Definition
data_structures.hpp:128
PriorityQueue::pop
T pop()
Definition
data_structures.hpp:116
SlidingWindow
Definition
data_structures.hpp:138
SlidingWindow::push
void push(const T &value)
Definition
data_structures.hpp:150
SlidingWindow::average
T average() const
Definition
data_structures.hpp:160
data_structures.hpp
TEST
TEST(CircularBufferTest, BasicOperations)
Definition
data_structures_test.cpp:4
tests
data_structures_test.cpp
Generated on Sat Dec 28 2024 01:08:54 for Advanced Chunk Processing Library by
1.9.8