Skip to content

Commit 3286c5e

Browse files
authored
fix(using_as): Add test so that proper type is returned. (#512)
1 parent ee7cdc6 commit 3286c5e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

exercises/conversions/using_as.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// It also helps with renaming imports.
44
//
55
// The goal is to make sure that the division does not fail to compile
6+
// and returns the proper type.
67

78
// I AM NOT DONE
89

@@ -15,3 +16,13 @@ fn main() {
1516
let values = [3.5, 0.3, 13.0, 11.7];
1617
println!("{}", average(&values));
1718
}
19+
20+
#[cfg(test)]
21+
mod tests {
22+
use super::*;
23+
24+
#[test]
25+
fn returns_proper_type_and_value() {
26+
assert_eq!(average(&[3.5, 0.3, 13.0, 11.7]), 7.125);
27+
}
28+
}

info.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ what you've learned :)"""
787787
[[exercises]]
788788
name = "using_as"
789789
path = "exercises/conversions/using_as.rs"
790-
mode = "compile"
790+
mode = "test"
791791
hint = """
792792
Use the `as` operator to cast one of the operands in the last line of the
793793
`average` function into the expected return type."""

0 commit comments

Comments
 (0)