-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
63 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,65 @@ | ||
import gleam/int | ||
import gleam/option.{None, Some} | ||
import gleeunit | ||
import gleeunit/should | ||
import priorityq | ||
|
||
pub fn main() { | ||
gleeunit.main() | ||
} | ||
|
||
// gleeunit test functions end in `_test` | ||
pub fn hello_world_test() { | ||
1 | ||
|> should.equal(1) | ||
pub fn peek_test() { | ||
priorityq.from_list([3, 10, 1], int.compare) | ||
|> priorityq.peek | ||
|> should.equal(Some(10)) | ||
|
||
priorityq.new(int.compare) | ||
|> priorityq.peek | ||
|> should.equal(None) | ||
} | ||
|
||
pub fn push_test() { | ||
let pq = | ||
priorityq.from_list([3, 10, 1], int.compare) | ||
|> priorityq.push(15) | ||
|
||
pq | ||
|> priorityq.size | ||
|> should.equal(4) | ||
pq | ||
|> priorityq.peek | ||
|> should.equal(Some(15)) | ||
} | ||
|
||
pub fn pop_test() { | ||
let pq = | ||
priorityq.from_list([3, 10, 1], int.compare) | ||
|> priorityq.pop | ||
|
||
pq | ||
|> priorityq.size | ||
|> should.equal(2) | ||
pq | ||
|> priorityq.peek | ||
|> should.equal(Some(3)) | ||
} | ||
|
||
pub fn is_empty_test() { | ||
priorityq.new(int.compare) | ||
|> priorityq.is_empty | ||
|> should.be_true | ||
|
||
priorityq.from_list([3, 1, 2], int.compare) | ||
|> priorityq.is_empty | ||
|> should.be_false | ||
} | ||
|
||
pub fn size_test() { | ||
priorityq.new(int.compare) | ||
|> priorityq.size | ||
|> should.equal(0) | ||
|
||
priorityq.from_list([3, 1, 2], int.compare) | ||
|> priorityq.size | ||
|> should.equal(3) | ||
} |