|
1 | | -//! Comprehensive tests for 100% code coverage of platform-trees |
| 1 | +//! Shared test implementations for integration tests. |
| 2 | +//! |
| 3 | +//! These test fixtures provide concrete implementations of the library's traits |
| 4 | +//! for use in testing. They serve as clear examples of how to implement each trait. |
2 | 5 |
|
3 | | -use crate::{ |
4 | | - AbsoluteCircularLinkedList, AbsoluteLinkedList, IterativeSizeBalancedTree, LinkType, |
5 | | - LinkedList, RecursiveSizeBalancedTree, RelativeCircularLinkedList, RelativeLinkedList, |
6 | | -}; |
| 6 | +#![allow(dead_code)] |
7 | 7 |
|
8 | | -mod list_tests; |
9 | | -mod tree_tests; |
| 8 | +use platform_trees::{ |
| 9 | + AbsoluteCircularLinkedList, AbsoluteLinkedList, IterativeSizeBalancedTree, LinkedList, |
| 10 | + RecursiveSizeBalancedTree, RelativeCircularLinkedList, RelativeLinkedList, |
| 11 | +}; |
10 | 12 |
|
11 | 13 | // ============================================================================= |
12 | 14 | // Test implementations |
13 | 15 | // ============================================================================= |
14 | 16 |
|
15 | 17 | /// A simple node structure for testing linked lists |
16 | 18 | #[derive(Debug, Clone, Copy, Default)] |
17 | | -struct Node { |
18 | | - prev: usize, |
19 | | - next: usize, |
| 19 | +pub struct Node { |
| 20 | + pub prev: usize, |
| 21 | + pub next: usize, |
20 | 22 | } |
21 | 23 |
|
22 | 24 | /// A simple absolute linked list implementation for testing |
23 | | -struct TestAbsoluteList { |
24 | | - nodes: Vec<Node>, |
25 | | - first: usize, |
26 | | - last: usize, |
27 | | - size: usize, |
| 25 | +pub struct TestAbsoluteList { |
| 26 | + pub nodes: Vec<Node>, |
| 27 | + pub first: usize, |
| 28 | + pub last: usize, |
| 29 | + pub size: usize, |
28 | 30 | } |
29 | 31 |
|
30 | 32 | impl TestAbsoluteList { |
31 | | - fn new(capacity: usize) -> Self { |
| 33 | + pub fn new(capacity: usize) -> Self { |
32 | 34 | let mut nodes = Vec::with_capacity(capacity + 1); |
33 | 35 | // Index 0 is reserved as "null" |
34 | 36 | nodes.resize(capacity + 1, Node::default()); |
@@ -88,14 +90,14 @@ impl AbsoluteLinkedList<usize> for TestAbsoluteList { |
88 | 90 | impl AbsoluteCircularLinkedList<usize> for TestAbsoluteList {} |
89 | 91 |
|
90 | 92 | /// A relative linked list implementation for testing (list head stored in element) |
91 | | -struct TestRelativeList { |
92 | | - nodes: Vec<Node>, |
| 93 | +pub struct TestRelativeList { |
| 94 | + pub nodes: Vec<Node>, |
93 | 95 | // Store first/last/size for each "head" element |
94 | | - heads: Vec<(usize, usize, usize)>, // (first, last, size) |
| 96 | + pub heads: Vec<(usize, usize, usize)>, // (first, last, size) |
95 | 97 | } |
96 | 98 |
|
97 | 99 | impl TestRelativeList { |
98 | | - fn new(capacity: usize) -> Self { |
| 100 | + pub fn new(capacity: usize) -> Self { |
99 | 101 | let mut nodes = Vec::with_capacity(capacity + 1); |
100 | 102 | nodes.resize(capacity + 1, Node::default()); |
101 | 103 | let mut heads = Vec::with_capacity(capacity + 1); |
@@ -152,19 +154,19 @@ impl RelativeCircularLinkedList<usize> for TestRelativeList {} |
152 | 154 |
|
153 | 155 | /// A tree node structure for testing `SizeBalancedTree` |
154 | 156 | #[derive(Debug, Clone, Copy, Default)] |
155 | | -struct TreeNode { |
156 | | - left: usize, |
157 | | - right: usize, |
158 | | - size: usize, |
| 157 | +pub struct TreeNode { |
| 158 | + pub left: usize, |
| 159 | + pub right: usize, |
| 160 | + pub size: usize, |
159 | 161 | } |
160 | 162 |
|
161 | 163 | /// A simple `SizeBalancedTree` implementation for testing |
162 | | -struct TestTree { |
163 | | - nodes: Vec<TreeNode>, |
| 164 | +pub struct TestTree { |
| 165 | + pub nodes: Vec<TreeNode>, |
164 | 166 | } |
165 | 167 |
|
166 | 168 | impl TestTree { |
167 | | - fn new(capacity: usize) -> Self { |
| 169 | + pub fn new(capacity: usize) -> Self { |
168 | 170 | let mut nodes = Vec::with_capacity(capacity + 1); |
169 | 171 | nodes.resize(capacity + 1, TreeNode::default()); |
170 | 172 | Self { nodes } |
|
0 commit comments