From 665f31f4b4e050270604d9b534058fa9b9d39adc Mon Sep 17 00:00:00 2001 From: Patrick Roy Date: Wed, 30 Aug 2023 15:58:11 +0100 Subject: [PATCH] Add Rust unittest so that test_coverage properly self-tests Using kcov, a coverage of 33.3% was reported, even though that are no rust-test code in the dummy crate that is included in this repository. This commit adds an actual unit test, so that the test_coverage test actually properly self-tests here. Signed-off-by: Patrick Roy --- coverage_config_x86_64.json | 2 +- src/lib.rs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/coverage_config_x86_64.json b/coverage_config_x86_64.json index d80d206..cc4b78b 100644 --- a/coverage_config_x86_64.json +++ b/coverage_config_x86_64.json @@ -1,5 +1,5 @@ { - "coverage_score": 33.3, + "coverage_score": 100.0, "exclude_path": "", "crate_features": "" } diff --git a/src/lib.rs b/src/lib.rs index a285917..553f088 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,11 @@ -pub fn main() { - println!("It works!"); +pub fn add(a: u32, b: u32) -> u32 { + a + b +} + +#[cfg(test)] +mod tests { + #[test] + fn test_add() { + assert_eq!(super::add(1, 2), 3) + } }