Skip to content

Commit

Permalink
test: add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hadelive committed Jan 12, 2024
1 parent 2c39d2d commit f8edf81
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/linkedlist/linked_list.ak
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ use linkedlist/utils

pub fn init(common: Common) -> Bool {
let must_spend_nodes = list.length(common.node_inputs) > 0
let must_exactly_one_node_outputs = list.length(common.node_outputs) == 1
let must_exactly_one_node_output = list.length(common.node_outputs) == 1
let must_mint_correctly =
utils.validate_mint(
common.mint,
common.own_cs,
constants.origin_node_token_name,
1,
)
must_spend_nodes? && must_exactly_one_node_outputs? && must_mint_correctly?
must_spend_nodes? && must_exactly_one_node_output? && must_mint_correctly?
}

pub fn deinit(common: Common) -> Bool {
Expand Down
25 changes: 25 additions & 0 deletions lib/linkedlist/tests.ak
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use linkedlist/utils.{div_ceil}

// Test Case 1
// Test when a is divisible by b
test div_ceil_1() {
div_ceil(10, 5) == 2
}

// Test Case 2
// Test when a is not divisible by b
test div_ceil_2() {
div_ceil(7, 3) == 3
}

// Test Case 3
// Test when a is 0
test div_ceil_3() {
div_ceil(0, 5) == 0
}

// Test Case 4
// Test when b is 1
test div_ceil_4() {
div_ceil(10, 1) == 10
}

0 comments on commit f8edf81

Please sign in to comment.