Source

talks / test-debug-prof / table / math_test.go

package math

import "testing"

// START1 OMIT
func checkMul(t *testing.T, a, b, expected float64) {
	t.Logf("Testing Mul(%f, %f)", a, b)
	if Mul(a, b) != expected {
		t.Fatalf("Mul(%f, %f) failed", a, b) // FIXME: Better error
	}
}

var mulTestCases = []struct {
	a, b, expected float64
}{
	{1., 2., 2.},
	{-2., -3., 6.},
}

func TestMul(t *testing.T) {  // HL
	for _, tc := range mulTestCases {
		checkMul(t, tc.a, tc.b, tc.expected)
	}
}
// END1 OMIT
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.