From 8e603271d4cbc1e64a0fb953db5b65b5c362dfe1 Mon Sep 17 00:00:00 2001 From: dcodesdev <101001810+dcodesdev@users.noreply.github.com> Date: Thu, 6 Jun 2024 18:54:26 +0300 Subject: [PATCH] declaring vars tests --- challenges/declaring-variables/src/lib.rs | 7 +------ challenges/declaring-variables/tests/tests.rs | 11 ++++++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/challenges/declaring-variables/src/lib.rs b/challenges/declaring-variables/src/lib.rs index 4e13e25..a1c34cc 100644 --- a/challenges/declaring-variables/src/lib.rs +++ b/challenges/declaring-variables/src/lib.rs @@ -1,11 +1,6 @@ pub fn calculate_area() -> u32 { - // Declare width and height as immutable variables let width = 10; let height = 5; - // Calculate the area of the rectangle - let area = width * height; - - // Return the calculated area - area + width * height } diff --git a/challenges/declaring-variables/tests/tests.rs b/challenges/declaring-variables/tests/tests.rs index 36d74ba..ec15ebe 100644 --- a/challenges/declaring-variables/tests/tests.rs +++ b/challenges/declaring-variables/tests/tests.rs @@ -1,5 +1,5 @@ use declaring_variables::*; -use syntest::Syntest; +use syntest::{LocalValue, Syntest}; #[test] fn test_calculate_area() { @@ -9,4 +9,13 @@ fn test_calculate_area() { #[test] fn test_variable_width() { let syntest = Syntest::from("./src/lib.rs"); + + assert_eq!( + syntest.get_local_value("calculate_area", "width").unwrap(), + LocalValue::Int(10) + ); + assert_eq!( + syntest.get_local_value("calculate_area", "height").unwrap(), + LocalValue::Int(5) + ); }