blob: 75c1cf7a6dc7ae364f579122c344fd748f45e535 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// if2
// Make me compile!
// I AM NOT DONE
package main_test
import "testing"
func fooIfFizz(fizzish string) string {
// When the input is fizz return foo
// When the input is fuzz return bar
// When the input is neither fizz or fuzz return baz
if fizzish == "fizz" {
return "foo"
} else {
return "complete me"
}
}
func TestFooForFizz(t *testing.T) {
result := fooIfFizz("fizz")
if result != "foo" {
t.Errorf("should be 'foo' but got %s", result)
}
}
func TestBarForFuzz(t *testing.T) {
result := fooIfFizz("fuzz")
if result != "bar" {
t.Errorf("should be 'bar' but got %s", result)
}
}
func TestDefaultForBazz(t *testing.T) {
result := fooIfFizz("random stuff")
if result != "baz" {
t.Errorf("should be 'baz' but got %s", result)
}
}
|