hello_test.gno
0.53 Kb · 26 lines
1package hello
2
3import (
4 "strings"
5 "testing"
6)
7
8func TestGreetAndCount(cur realm, t *testing.T) {
9 if got := Count(); got != 0 {
10 t.Fatalf("initial count = %d, want 0", got)
11 }
12 if got := Greet(cross(cur), "moul"); got != "Hello, moul!" {
13 t.Errorf("Greet = %q, want %q", got, "Hello, moul!")
14 }
15 Greet(cross(cur), "")
16 if got := Count(); got != 2 {
17 t.Errorf("count = %d, want 2", got)
18 }
19}
20
21func TestRender(t *testing.T) {
22 out := Render("")
23 if !strings.Contains(out, "r/moul/hello/v0") {
24 t.Errorf("render missing header: %q", out)
25 }
26}