開発環境
- macOS Mojave - Apple (OS)
- Emacs (Text Editor)
- Windows 10 Pro (OS)
- Visual Studio Code (Text Editor)
- Go (プログラミング言語)
Head First Go (Jay McGavren(著)、O'Reilly Media)のChapter 14(code quality assurance - Automated Testing)、Exercise(409)の解答を求めてみる。
コード
math_test.go
package arithmetic
import "testing"
func TestAdd(t *testing.T) {
if Add(1, 2) != 3 {
t.Error("1 + 2 did not equal 3")
}
}
func TestSubtract(t *testing.T) {
if Subtract(8, 4) != 4 {
t.Error("8 - 4 did not equal 4")
}
}
入出力結果(Bash、cmd.exe(コマンドプロンプト)、Terminal)
$ go test headfirstgo/arithmetic ok headfirstgo/arithmetic 0.005s $
0 コメント:
コメントを投稿