Skip to content

Commit 27ee2e8

Browse files
authored
Merge pull request #25 from linksplatform/issue-24-7c0a881baf8d
Move all tests from src/tests to tests/ folder and ensure 100% tests coverage
2 parents 9865f04 + 7a63995 commit 27ee2e8

6 files changed

Lines changed: 580 additions & 440 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
bump: patch
3+
---
4+
5+
### Changed
6+
- Moved all tests from `src/tests/` to `tests/` folder (integration tests)
7+
- Added 10 new tests for improved code coverage of edge cases and unsafe code paths

src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ mod link_type;
44
mod lists;
55
mod trees;
66

7-
#[cfg(test)]
8-
mod tests;
9-
107
pub use link_type::LinkType;
118
pub use lists::{
129
AbsoluteCircularLinkedList, AbsoluteLinkedList, LinkedList, RelativeCircularLinkedList,

src/tests/mod.rs renamed to tests/common/mod.rs

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
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.
25
3-
use crate::{
4-
AbsoluteCircularLinkedList, AbsoluteLinkedList, IterativeSizeBalancedTree, LinkType,
5-
LinkedList, RecursiveSizeBalancedTree, RelativeCircularLinkedList, RelativeLinkedList,
6-
};
6+
#![allow(dead_code)]
77

8-
mod list_tests;
9-
mod tree_tests;
8+
use platform_trees::{
9+
AbsoluteCircularLinkedList, AbsoluteLinkedList, IterativeSizeBalancedTree, LinkedList,
10+
RecursiveSizeBalancedTree, RelativeCircularLinkedList, RelativeLinkedList,
11+
};
1012

1113
// =============================================================================
1214
// Test implementations
1315
// =============================================================================
1416

1517
/// A simple node structure for testing linked lists
1618
#[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,
2022
}
2123

2224
/// 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,
2830
}
2931

3032
impl TestAbsoluteList {
31-
fn new(capacity: usize) -> Self {
33+
pub fn new(capacity: usize) -> Self {
3234
let mut nodes = Vec::with_capacity(capacity + 1);
3335
// Index 0 is reserved as "null"
3436
nodes.resize(capacity + 1, Node::default());
@@ -88,14 +90,14 @@ impl AbsoluteLinkedList<usize> for TestAbsoluteList {
8890
impl AbsoluteCircularLinkedList<usize> for TestAbsoluteList {}
8991

9092
/// 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>,
9395
// 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)
9597
}
9698

9799
impl TestRelativeList {
98-
fn new(capacity: usize) -> Self {
100+
pub fn new(capacity: usize) -> Self {
99101
let mut nodes = Vec::with_capacity(capacity + 1);
100102
nodes.resize(capacity + 1, Node::default());
101103
let mut heads = Vec::with_capacity(capacity + 1);
@@ -152,19 +154,19 @@ impl RelativeCircularLinkedList<usize> for TestRelativeList {}
152154

153155
/// A tree node structure for testing `SizeBalancedTree`
154156
#[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,
159161
}
160162

161163
/// A simple `SizeBalancedTree` implementation for testing
162-
struct TestTree {
163-
nodes: Vec<TreeNode>,
164+
pub struct TestTree {
165+
pub nodes: Vec<TreeNode>,
164166
}
165167

166168
impl TestTree {
167-
fn new(capacity: usize) -> Self {
169+
pub fn new(capacity: usize) -> Self {
168170
let mut nodes = Vec::with_capacity(capacity + 1);
169171
nodes.resize(capacity + 1, TreeNode::default());
170172
Self { nodes }

0 commit comments

Comments
 (0)