Skip to content

Commit

Permalink
Added pre/post comments for deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
crnbarr93 committed Mar 12, 2024
1 parent 091d59a commit 272d1f8
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions contracts/sumtree-orderbook/src/sumtree/test/test_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@ fn test_node_deletion_valid() {
let book_id = 1;
let tick_id = 1;
let test_cases: Vec<NodeDeletionTestCase> = vec![
// Pre
// ---
// 1: 10 1-11
// ┌────────
// ->2: 1 10
//
// Post
// ----
// No tree
NodeDeletionTestCase {
name: "Remove only node",
Expand All @@ -294,6 +302,14 @@ fn test_node_deletion_valid() {
expected: vec![],
print: true,
},
// Pre
// ---
// 1: 15 1-16
// ┌────────────────┐
// ->2: 1 10 3: 11 5
//
// Post
// ----
// 1: 5 11-16
// ────────┐
// 3: 11 5
Expand All @@ -304,6 +320,16 @@ fn test_node_deletion_valid() {
expected: vec![1, 3],
print: true,
},
// Pre
// ---
// 1: 25 1-26
// ┌────────────────────────────────┐
// 5: 20 1-21 3: 21 5
// ┌────────────────┐
// ->2: 1 10 4: 11 10
//
// Post
// ----
// 1: 15 11-26
// ┌────────────────────────────────┐
// 5: 10 11-21 3: 21 5
Expand All @@ -320,6 +346,16 @@ fn test_node_deletion_valid() {
expected: vec![1, 5, 4, 3],
print: true,
},
// Pre
// ---
// 1: 25 1-26
// ┌────────────────────────────────┐
// 5: 20 1-21 3: 21 5
// ┌────────────────┐
// ->2: 1 10 ->4: 11 10
//
// Post
// ----
// 1: 5 21-26
// ────────┐
// 3: 21 5
Expand All @@ -334,6 +370,30 @@ fn test_node_deletion_valid() {
expected: vec![1, 3],
print: true,
},
// Pre
// ---
// 1: 25 1-26
// ┌────────────────────────────────┐
// ->5: 20 1-21 3: 21 5
// ┌────────────────┐
// 2: 1 10 4: 11 10
//
// Post
// ----
// 1: 5 21-26
// ────────┐
// 3: 21 5
NodeDeletionTestCase {
name: "Remove parent node",
nodes: vec![
NodeType::leaf(1u32, 10u32),
NodeType::leaf(21u32, 5u32),
NodeType::leaf(11u32, 10u32),
],
delete: vec![5],
expected: vec![1, 3],
print: true,
},
];

for test in test_cases {
Expand Down

0 comments on commit 272d1f8

Please sign in to comment.