// TestArrayEqual tests ArrayEqual
func TestArrayEqual(t *testing.T) {

	var l1 = []int{1, 2, 3}
	var l2 = []int{1, 2, 3}

	equal := goutils.ArrayEqual(l1, l2)

	if equal != true {
		t.Error("ArrayEqual Failed")
	}
}
func TestPrimeNumber(t *testing.T) {
	var tt = []goutils.TTIA{
		{6, []int{2, 3, 5, 7, 11, 13}},
	}

	for i := 0; i < len(tt); i++ {
		testIn := goutils.PrimeNumber(tt[i].Test)
		testExp := tt[i].Expt

		if goutils.ArrayEqual(testExp, testIn) == false {
			t.Error("PrimeNumber test failed")
		}
	}
}
// TestGetFactors tests the GetFactors
func TestGetFactors(t *testing.T) {
	var tt = []goutils.TTIA{
		{10, []int{2, 5}},
	}

	for i := 0; i < len(tt); i++ {
		testIn := goutils.GetFactors(tt[i].Test)
		testExp := tt[i].Expt

		if goutils.ArrayEqual(testExp, testIn) {
			t.SkipNow()
		} else {
			t.Error("Test failed")
		}
	}
}
// TestInitFilteredList tests InitFilteredList
func TestFilterList(t *testing.T) {
	var tt = []goutils.TTIA{
		{6, []int{60}},
	}

	for i := 0; i < len(tt); i++ {
		testIn := goutils.FilterList(tt[i].Test)
		testExp := tt[i].Expt

		if goutils.ArrayEqual(testExp, testIn) {
			t.SkipNow()
		} else {
			t.Error("Test failed")
		}
	}
}
예제 #5
0
func TestEuler3(t *testing.T) {
	type Euler3Test struct {
		test int   // input
		expt []int // expected result
	}

	var tt = []Euler3Test{
		{20, []int{2, 5}},
	}

	for i := 0; i < len(tt); i++ {
		testIn := euler.Euler3(tt[i].test)
		testExp := tt[i].expt

		if goutils.ArrayEqual(testIn, testExp) == false {
			t.Error("Euler 3 failed")
		}
	}
}
// TestReverseIntArray tests ReverseString
func TestReverseIntArray(t *testing.T) {
	type ReverseIntArrayTest struct {
		test []int // input
		expt []int // expected result
	}

	var tt = []ReverseIntArrayTest{
		{[]int{1, 2, 3}, []int{3, 2, 1}},
	}

	for i := 0; i < len(tt); i++ {
		testIn := goutils.ReverseIntArray(tt[i].test)
		testExp := tt[i].expt

		if goutils.ArrayEqual(testExp, testIn) == false {

			t.Error("ReverseIntArray Failed")
		}
	}
}