...
1rsc.io/quote@v1.3.0
2
3-- .mod --
4module "rsc.io/quote"
5-- .info --
6{"Version":"v1.3.0","Name":"84de74b35823c1e49634f2262f1a58cfc951ebae","Short":"84de74b35823","Time":"2018-02-14T00:54:53Z"}
7-- go.mod --
8module "rsc.io/quote"
9-- quote.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
14// Package quote collects pithy sayings.
15package quote // import "rsc.io/quote"
16
17// Hello returns a greeting.
18func Hello() string {
19 return "Hello, world."
20}
21
22// Glass returns a useful phrase for world travelers.
23func Glass() string {
24 // See http://www.oocities.org/nodotus/hbglass.html.
25 return "I can eat glass and it doesn't hurt me."
26}
27
28// Go returns a Go proverb.
29func Go() string {
30 return "Don't communicate by sharing memory, share memory by communicating."
31}
32
33// Opt returns an optimization truth.
34func Opt() string {
35 // Wisdom from ken.
36 return "If a program is too slow, it must have a loop."
37}
38-- quote_test.go --
39// Copyright 2018 The Go Authors. All rights reserved.
40// Use of this source code is governed by a BSD-style
41// license that can be found in the LICENSE file.
42
43package quote
44
45import "testing"
46
47func TestHello(t *testing.T) {
48 hello := "Hello, world."
49 if out := Hello(); out != hello {
50 t.Errorf("Hello() = %q, want %q", out, hello)
51 }
52}
53
54func TestGlass(t *testing.T) {
55 glass := "I can eat glass and it doesn't hurt me."
56 if out := Glass(); out != glass {
57 t.Errorf("Glass() = %q, want %q", out, glass)
58 }
59}
60
61func TestGo(t *testing.T) {
62 go1 := "Don't communicate by sharing memory, share memory by communicating."
63 if out := Go(); out != go1 {
64 t.Errorf("Go() = %q, want %q", out, go1)
65 }
66}
67
68func TestOpt(t *testing.T) {
69 opt := "If a program is too slow, it must have a loop."
70 if out := Opt(); out != opt {
71 t.Errorf("Opt() = %q, want %q", out, opt)
72 }
73}
View as plain text