File tree Expand file tree Collapse file tree 2 files changed +26
-22
lines changed Expand file tree Collapse file tree 2 files changed +26
-22
lines changed Original file line number Diff line number Diff line change 1
1
// TODO: Fix the compiler error on this function.
2
- fn foo_if_fizz ( fizzish : & str ) -> & str {
3
- if fizzish == "fizz " {
4
- "foo "
2
+ fn picky_eater ( food : & str ) -> & str {
3
+ if food == "strawberry " {
4
+ "Yummy! "
5
5
} else {
6
6
1
7
7
}
@@ -18,18 +18,20 @@ mod tests {
18
18
use super :: * ;
19
19
20
20
#[ test]
21
- fn foo_for_fizz ( ) {
22
- // This means that calling `foo_if_fizz ` with the argument "fizz " should return "foo ".
23
- assert_eq ! ( foo_if_fizz ( "fizz ") , "foo " ) ;
21
+ fn yummy_food ( ) {
22
+ // This means that calling `picky_eater ` with the argument "food " should return "Yummy! ".
23
+ assert_eq ! ( picky_eater ( "strawberry ") , "Yummy! " ) ;
24
24
}
25
25
26
26
#[ test]
27
- fn bar_for_fuzz ( ) {
28
- assert_eq ! ( foo_if_fizz ( "fuzz ") , "bar " ) ;
27
+ fn neutral_food ( ) {
28
+ assert_eq ! ( picky_eater ( "potato ") , "I guess I can eat that. " ) ;
29
29
}
30
30
31
31
#[ test]
32
- fn default_to_baz ( ) {
33
- assert_eq ! ( foo_if_fizz( "literally anything" ) , "baz" ) ;
32
+ fn default_disliked_food ( ) {
33
+ assert_eq ! ( picky_eater( "broccoli" ) , "No thanks!" ) ;
34
+ assert_eq ! ( picky_eater( "gummy bears" ) , "No thanks!" ) ;
35
+ assert_eq ! ( picky_eater( "literally anything" ) , "No thanks!" ) ;
34
36
}
35
37
}
Original file line number Diff line number Diff line change 1
- fn foo_if_fizz ( fizzish : & str ) -> & str {
2
- if fizzish == "fizz " {
3
- "foo "
4
- } else if fizzish == "fuzz " {
5
- "bar "
1
+ fn picky_eater ( food : & str ) -> & str {
2
+ if food == "strawberry " {
3
+ "Yummy! "
4
+ } else if food == "potato " {
5
+ "I guess I can eat that. "
6
6
} else {
7
- "baz "
7
+ "No thanks! "
8
8
}
9
9
}
10
10
@@ -17,17 +17,19 @@ mod tests {
17
17
use super :: * ;
18
18
19
19
#[ test]
20
- fn foo_for_fizz ( ) {
21
- assert_eq ! ( foo_if_fizz ( "fizz ") , "foo " ) ;
20
+ fn yummy_food ( ) {
21
+ assert_eq ! ( picky_eater ( "strawberry ") , "Yummy! " ) ;
22
22
}
23
23
24
24
#[ test]
25
- fn bar_for_fuzz ( ) {
26
- assert_eq ! ( foo_if_fizz ( "fuzz ") , "bar " ) ;
25
+ fn neutral_food ( ) {
26
+ assert_eq ! ( picky_eater ( "potato ") , "I guess I can eat that. " ) ;
27
27
}
28
28
29
29
#[ test]
30
- fn default_to_baz ( ) {
31
- assert_eq ! ( foo_if_fizz( "literally anything" ) , "baz" ) ;
30
+ fn default_disliked_food ( ) {
31
+ assert_eq ! ( picky_eater( "broccoli" ) , "No thanks!" ) ;
32
+ assert_eq ! ( picky_eater( "gummy bears" ) , "No thanks!" ) ;
33
+ assert_eq ! ( picky_eater( "literally anything" ) , "No thanks!" ) ;
32
34
}
33
35
}
You can’t perform that action at this time.
0 commit comments