34 lines
558 B
Go
Executable File
34 lines
558 B
Go
Executable File
package calculator_test
|
|
|
|
import (
|
|
"calculator"
|
|
"testing"
|
|
)
|
|
|
|
func TestAdd(t *testing.T) {
|
|
t.Parallel()
|
|
var want float64 = 4
|
|
got := calculator.Add(2, 2)
|
|
if want != got {
|
|
t.Errorf("want %f, got %f", want, got)
|
|
}
|
|
}
|
|
|
|
func TestSubtract(t *testing.T) {
|
|
t.Parallel()
|
|
var want float64 = 2
|
|
got := calculator.Subtract(4, 2)
|
|
if want != got {
|
|
t.Errorf("want %f, got %f", want, got)
|
|
}
|
|
}
|
|
|
|
func TestMultiply(t *testing.T) {
|
|
t.Parallel()
|
|
var want float64 = 6
|
|
got := calculator.Multiply(2, 3)
|
|
if want != got {
|
|
t.Errorf("want %f, got %f", want, got)
|
|
}
|
|
}
|