From 3286c5ec19ea5fb7ded81d047da5f8594108a490 Mon Sep 17 00:00:00 2001 From: Ryan McQuen Date: Mon, 7 Sep 2020 10:09:27 -0700 Subject: [PATCH] fix(using_as): Add test so that proper type is returned. (#512) --- exercises/conversions/using_as.rs | 11 +++++++++++ info.toml | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/exercises/conversions/using_as.rs b/exercises/conversions/using_as.rs index b3c197f..821309e 100644 --- a/exercises/conversions/using_as.rs +++ b/exercises/conversions/using_as.rs @@ -3,6 +3,7 @@ // It also helps with renaming imports. // // The goal is to make sure that the division does not fail to compile +// and returns the proper type. // I AM NOT DONE @@ -15,3 +16,13 @@ fn main() { let values = [3.5, 0.3, 13.0, 11.7]; println!("{}", average(&values)); } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn returns_proper_type_and_value() { + assert_eq!(average(&[3.5, 0.3, 13.0, 11.7]), 7.125); + } +} diff --git a/info.toml b/info.toml index a64509e..2e90f13 100644 --- a/info.toml +++ b/info.toml @@ -787,7 +787,7 @@ what you've learned :)""" [[exercises]] name = "using_as" path = "exercises/conversions/using_as.rs" -mode = "compile" +mode = "test" hint = """ Use the `as` operator to cast one of the operands in the last line of the `average` function into the expected return type."""