Skip to content

Commit

Permalink
declaring vars tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodesdev committed Jun 6, 2024
1 parent f4361ee commit 8e60327
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 1 addition & 6 deletions challenges/declaring-variables/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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
}
11 changes: 10 additions & 1 deletion challenges/declaring-variables/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use declaring_variables::*;
use syntest::Syntest;
use syntest::{LocalValue, Syntest};

#[test]
fn test_calculate_area() {
Expand All @@ -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)
);
}

0 comments on commit 8e60327

Please sign in to comment.