...
1rsc.io/quote@v1.5.2
2
3-- .mod --
4module "rsc.io/quote"
5
6require "rsc.io/sampler" v1.3.0
7-- .info --
8{"Version":"v1.5.2","Name":"c4d4236f92427c64bfbcf1cc3f8142ab18f30b22","Short":"c4d4236f9242","Time":"2018-02-14T15:44:20Z"}
9-- buggy/buggy_test.go --
10// Copyright 2018 The Go Authors. All rights reserved.
11// Use of this source code is governed by a BSD-style
12// license that can be found in the LICENSE file.
13
14package buggy
15
16import "testing"
17
18func Test(t *testing.T) {
19 t.Fatal("buggy!")
20}
21-- go.mod --
22module "rsc.io/quote"
23
24require "rsc.io/sampler" v1.3.0
25-- quote.go --
26// Copyright 2018 The Go Authors. All rights reserved.
27// Use of this source code is governed by a BSD-style
28// license that can be found in the LICENSE file.
29
30// Package quote collects pithy sayings.
31package quote // import "rsc.io/quote"
32
33import "rsc.io/sampler"
34
35// Hello returns a greeting.
36func Hello() string {
37 return sampler.Hello()
38}
39
40// Glass returns a useful phrase for world travelers.
41func Glass() string {
42 // See http://www.oocities.org/nodotus/hbglass.html.
43 return "I can eat glass and it doesn't hurt me."
44}
45
46// Go returns a Go proverb.
47func Go() string {
48 return "Don't communicate by sharing memory, share memory by communicating."
49}
50
51// Opt returns an optimization truth.
52func Opt() string {
53 // Wisdom from ken.
54 return "If a program is too slow, it must have a loop."
55}
56-- quote_test.go --
57// Copyright 2018 The Go Authors. All rights reserved.
58// Use of this source code is governed by a BSD-style
59// license that can be found in the LICENSE file.
60
61package quote
62
63import (
64 "os"
65 "testing"
66)
67
68func init() {
69 os.Setenv("LC_ALL", "en")
70}
71
72func TestHello(t *testing.T) {
73 hello := "Hello, world."
74 if out := Hello(); out != hello {
75 t.Errorf("Hello() = %q, want %q", out, hello)
76 }
77}
78
79func TestGlass(t *testing.T) {
80 glass := "I can eat glass and it doesn't hurt me."
81 if out := Glass(); out != glass {
82 t.Errorf("Glass() = %q, want %q", out, glass)
83 }
84}
85
86func TestGo(t *testing.T) {
87 go1 := "Don't communicate by sharing memory, share memory by communicating."
88 if out := Go(); out != go1 {
89 t.Errorf("Go() = %q, want %q", out, go1)
90 }
91}
92
93func TestOpt(t *testing.T) {
94 opt := "If a program is too slow, it must have a loop."
95 if out := Opt(); out != opt {
96 t.Errorf("Opt() = %q, want %q", out, opt)
97 }
98}
View as plain text