37 lines
726 B
Go
37 lines
726 B
Go
package primes
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestLCM(t *testing.T) {
|
|
var tests = []struct {
|
|
Expected int64
|
|
A, B int64
|
|
}{
|
|
{2 * 3 * 5 * 7, 2 * 3 * 5, 2 * 3 * 7},
|
|
{2 * 2 * 3 * 5 * 7, 2 * 3 * 5, 2 * 2 * 7},
|
|
}
|
|
for _, test := range tests {
|
|
assert.Equal(t, test.Expected, LCM(test.A, test.B))
|
|
assert.Equal(t, test.Expected, LCM(test.B, test.A))
|
|
}
|
|
}
|
|
|
|
func TestGCD(t *testing.T) {
|
|
var tests = []struct {
|
|
Expected int64
|
|
A, B int64
|
|
}{
|
|
{2 * 3, 2 * 3 * 5, 2 * 3 * 7},
|
|
{2, 2 * 3 * 5, 2 * 2 * 7},
|
|
{1, 3 * 5, 2 * 2 * 7},
|
|
}
|
|
for _, test := range tests {
|
|
assert.Equal(t, test.Expected, GCD(test.A, test.B))
|
|
assert.Equal(t, test.Expected, GCD(test.B, test.A))
|
|
}
|
|
}
|