feat: cargo + testing

This commit is contained in:
2025-01-28 17:57:14 +01:00
parent 0962166a06
commit 47313f061e
4 changed files with 23 additions and 0 deletions

View File

@@ -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

View File

@@ -0,0 +1,4 @@
fn main() {
println!("This was ran with '$ cargo run --bin secondary_main'");
println!("This is a secondary main!");
}

View File

@@ -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
View 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!");
}
}