-
Notifications
You must be signed in to change notification settings - Fork 166
/
hello_server_test.go
34 lines (26 loc) · 841 Bytes
/
hello_server_test.go
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
package main
import "testing"
func TestGreetingSpecificJohn(t *testing.T) {
greeting := CreateGreeting("John")
if greeting != "Hello, John\n" {
t.Errorf("Greeting was incorrect, got: %s, want: %s.", greeting, "Hello, John\n")
}
}
func TestGreetingSpecificDemo(t *testing.T) {
greeting := CreateGreeting("Demo")
if greeting != "Hello, Demo\n" {
t.Errorf("Greeting was incorrect, got: %s, want: %s.", greeting, "Hello, Demo\n")
}
}
func TestShowFailure(t *testing.T) {
greeting := CreateGreeting("Demo1")
if greeting != "Hello, Demo\n" {
t.Errorf("Intentional failure. got: %s, want: %s.", greeting, "Hello, Demo\n")
}
}
func TestGreetingDefault(t *testing.T) {
greeting := CreateGreeting("")
if greeting != "Hello, Guest\n" {
t.Errorf("Greeting was incorrect, got: %s, want: %s.", greeting, "Hello, Guest\n")
}
}