feat: cargo + testing
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
name = "rust-by-example"
|
name = "rust-by-example"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
default-run = "rust-by-example"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# clap = "2.27.1" # from crates.io
|
# clap = "2.27.1" # from crates.io
|
||||||
|
|||||||
4
src/bin/secondary_main.rs
Normal file
4
src/bin/secondary_main.rs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
fn main() {
|
||||||
|
println!("This was ran with '$ cargo run --bin secondary_main'");
|
||||||
|
println!("This is a secondary main!");
|
||||||
|
}
|
||||||
@@ -18,6 +18,10 @@
|
|||||||
// mod exercises;
|
// mod exercises;
|
||||||
mod concepts;
|
mod concepts;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
#[path = "./test/basic_test.rs"]
|
||||||
|
mod test;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// helloworld::hello_world_module();
|
// helloworld::hello_world_module();
|
||||||
// primitives::primitives_module();
|
// primitives::primitives_module();
|
||||||
|
|||||||
14
src/test/basic_test.rs
Normal file
14
src/test/basic_test.rs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
#[test]
|
||||||
|
fn test_success() {
|
||||||
|
let my_hello = "Hello world!";
|
||||||
|
assert_eq!(my_hello, "Hello world!");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_failure() {
|
||||||
|
let my_hello = "ef u world!";
|
||||||
|
assert_eq!(my_hello, "Hello world!");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user