開発環境
- 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 3(call me - Functions)、Exercise(109)の解答を求めてみる。
コード
sample4_test.go
package main
import "testing"
func TestNegate(t *testing.T) {
truth := true
negate(&truth)
if truth != false {
t.Errorf("truth: %v", truth)
}
lies := false
negate(&lies)
if lies != true {
t.Errorf("truth: %v", lies)
}
}
sample4.go
package main
func negate(myBooleanPointer *bool) {
*myBooleanPointer = !*myBooleanPointer
}
func main() {}
入出力結果(Bash、cmd.exe(コマンドプロンプト)、Terminal)
$ go test # _/.../Head_First_Go/ch3/sample4 [_/.../Head_First_Go/ch3/sample4.test] ./sample4_test.go:7:2: undefined: negate ./sample4_test.go:12:2: undefined: negate FAIL _/.../Head_First_Go/ch3/sample4 [build failed] $ go test PASS ok _/.../Head_First_Go/ch3/sample4 0.005s $
0 コメント:
コメントを投稿