package main import ( "fmt" "runtime" "testing" ) //Namenskonvention: Test… func TestMeineIrgendwieBenannteTestingFunction(t *testing.T) { // Die Globals werden auch im Test benötigt! maxThreads = int8(runtime.NumCPU()) maxRoutines = maxThreads * ThreadFaktor runtime.GOMAXPROCS(int(maxThreads)) testpaar := [...][2]int{{8978793242417717171, 1}, {5769977777, 0}} for i, v := range testpaar { ergebnisSoll := func(a int) bool { if a > 0 { return true } else { return false } }(v[1]) ergebnisIst := is_prime(&v[0]) if ergebnisIst != ergebnisSoll { t.Error("Erwartung:", ergebnisSoll, "Ergebnis:", ergebnisIst) } else { fmt.Printf("Test %v OK: (%v = %v)\n", i, ergebnisSoll, ergebnisIst) } } }