Skip to content

Commit

Permalink
Add first unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
qoqosz committed Aug 12, 2024
1 parent b2db970 commit 4e8363e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "orderbook"
version = "0.2.0"
authors = ["Łukasz Bednarski <[email protected]>"]
edition = "2021"
rust-version = "1.80.1"
rust-version = "1.70"

[dependencies]
either = "1.13.0"
Expand Down
16 changes: 16 additions & 0 deletions src/book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,19 @@ fn is_deeper(a: f64, b: f64, side: &Side) -> bool {
Side::Ask => a + EPSILON < b,
}
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn test_empty_order_book() {
let ob = OrderBook::new();
assert!(ob.get_ladder(&Side::Bid).is_empty());
assert!(ob.get_ladder(&Side::Ask).is_empty());
assert_eq!(ob.best_bid(), None);
assert_eq!(ob.best_bid_size(), None);
assert_eq!(ob.best_ask(), None);
assert_eq!(ob.best_ask_size(), None);
}
}

0 comments on commit 4e8363e

Please sign in to comment.