Skip to content

Commit 45e3e53

Browse files
committed
feat: add tests
1 parent 47b3bd9 commit 45e3e53

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ members = [
4949
"stone_game_vii",
5050
"minumum_number_of_refueling_stops",
5151
"palindrome_pairs",
52+
"matchsticks_to_square",
5253
]

matchsticks_to_square/Cargo.toml

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

matchsticks_to_square/src/lib.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
pub struct Solution {}
2+
3+
impl Solution {
4+
pub fn makesquare(matchsticks: Vec<i32>) -> bool {}
5+
}
6+
7+
#[cfg(test)]
8+
mod tests {
9+
use super::*;
10+
11+
#[test]
12+
fn example_1() {
13+
let matchsticks = [1, 1, 2, 2, 2];
14+
assert!(Solution::makesquare(matchsticks.to_vec()));
15+
}
16+
17+
#[test]
18+
fn example_2() {
19+
let matchsticks = [3, 3, 3, 3, 4];
20+
assert!(!Solution::makesquare(matchsticks.to_vec()));
21+
}
22+
}

0 commit comments

Comments
 (0)