Skip to content

Commit 475ca4f

Browse files
committed
feat: add tests
1 parent f402289 commit 475ca4f

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

Cargo.lock

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ members = [
3434
"partitioning_into_minimum_number_of_deci_binary_numbers",
3535
"maximum_product_of_word_lengths",
3636
"maximum_erasure_value",
37+
"maximum_gap",
3738
]

maximum_gap/Cargo.toml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "maximum_gap"
3+
version = "0.1.0"
4+
authors = ["Ryan Li <conbas2019@gmail.com>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]

maximum_gap/src/lib.rs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
pub struct Solution {}
2+
3+
impl Solution {
4+
pub fn maximum_gap(nums: Vec<i32>) -> i32 {}
5+
}
6+
7+
#[cfg(test)]
8+
mod tests {
9+
use super::*;
10+
11+
fn it_works(nums: Vec<i32>, expected: i32) {
12+
assert_eq!(Solution::maximum_gap(nums), expected);
13+
}
14+
15+
#[test]
16+
fn example_1() {
17+
let nums = vec![3, 6, 9, 1];
18+
let expected = 3;
19+
it_works(nums, expected);
20+
}
21+
22+
#[test]
23+
fn example_2() {
24+
let nums = vec![10];
25+
let expected = 0;
26+
it_works(nums, expected);
27+
}
28+
}

0 commit comments

Comments
 (0)