summaryrefslogtreecommitdiff
path: root/if
diff options
context:
space:
mode:
authorDaan van Berkel <daan.v.berkel.1980@gmail.com>2016-06-14 17:07:36 +0200
committerDaan van Berkel <daan.v.berkel.1980@gmail.com>2016-06-14 17:07:36 +0200
commit0cc668c0129f33b5e05600954d18afa96760052e (patch)
tree2236925c9f26a5cb9fca37c7d227246db8b41929 /if
parent502952559454f68085d95e1b1a068d0d7289d5a2 (diff)
Create tests for if1.rs
This provides standardize feedback if a solution is correct. Fixes #46.
Diffstat (limited to 'if')
-rw-r--r--if/if1.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/if/if1.rs b/if/if1.rs
index c5d2bbf..c2ea734 100644
--- a/if/if1.rs
+++ b/if/if1.rs
@@ -1,4 +1,4 @@
-fn bigger(a: i32, b:i32) -> i32 {
+pub fn bigger(a: i32, b:i32) -> i32 {
// Complete this function to return the bigger number!
// Do not use:
// - return
@@ -7,11 +7,20 @@ fn bigger(a: i32, b:i32) -> i32 {
// Scroll down for hints.
}
-fn main() {
- assert_eq!(10, bigger(10, 8));
- assert_eq!(42, bigger(32, 42));
-}
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn ten_is_bigger_than_eight() {
+ assert_eq!(10, bigger(10, 8));
+ }
+ #[test]
+ fn fortytwo_is_bigger_than_thirtytwo() {
+ assert_eq!(42, bigger(32, 42));
+ }
+}