summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-07-27 10:32:47 +0000
committerbors <bors@rust-lang.org>2019-07-27 10:32:47 +0000
commit1890b0019ddeb1002a56e0597f77cd36632cb48e (patch)
tree46e62337487349a218a775ee9242cab6d5c7026b /exercises
parent1c789dda08a57e1a3292d42e2d63f2c4d631057d (diff)
parenta750e4a1a3006227292bb17d57d78ce84da6bfc6 (diff)
Auto merge of #198 - nkanderson:160_options1-add-test, r=komaeda
fix(option1): Add test for prematurely passing exercise Fixes the bug referenced in #160, but does not address the larger feature work referenced by the issue.
Diffstat (limited to 'exercises')
-rw-r--r--exercises/error_handling/option1.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/exercises/error_handling/option1.rs b/exercises/error_handling/option1.rs
index 13fc720..d96a871 100644
--- a/exercises/error_handling/option1.rs
+++ b/exercises/error_handling/option1.rs
@@ -4,7 +4,7 @@
// on `None`. Handle this in a more graceful way than calling `unwrap`!
// Scroll down for hints :)
-fn main() {
+pub fn pop_too_much() -> bool {
let mut list = vec![3];
let last = list.pop().unwrap();
@@ -15,9 +15,18 @@ fn main() {
"The second-to-last item in the list is {:?}",
second_to_last
);
+ true
}
+#[cfg(test)]
+mod tests {
+ use super::*;
+ #[test]
+ fn should_not_panic() {
+ assert!(pop_too_much(), true);
+ }
+}