From 301151e287f4d39307429c047cd6e7ab77641e7e Mon Sep 17 00:00:00 2001 From: ddaniel27 Date: Wed, 25 Sep 2024 10:46:59 -0500 Subject: [PATCH] update tests to match code style --- dynamic/subsetsum_test.go | 7 ++----- math/matrix/matrix_test.go | 4 ++-- math/matrix/strassenmatrixmultiply_test.go | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/dynamic/subsetsum_test.go b/dynamic/subsetsum_test.go index 2fdfb6cc5..acb24f18e 100644 --- a/dynamic/subsetsum_test.go +++ b/dynamic/subsetsum_test.go @@ -1,9 +1,6 @@ package dynamic -import ( - "fmt" - "testing" -) +import "testing" func TestSubsetSum(t *testing.T) { @@ -74,7 +71,7 @@ func TestSubsetSum(t *testing.T) { for i := range subsetSumTestData { - t.Run(fmt.Sprintf(subsetSumTestData[i].description), func(t *testing.T) { + t.Run(subsetSumTestData[i].description, func(t *testing.T) { array := subsetSumTestData[i].array sum := subsetSumTestData[i].sum diff --git a/math/matrix/matrix_test.go b/math/matrix/matrix_test.go index 1425bf933..b8c0f7c72 100644 --- a/math/matrix/matrix_test.go +++ b/math/matrix/matrix_test.go @@ -32,7 +32,7 @@ func TestNewFromElements(t *testing.T) { for j := 0; j < len(validElements[0]); j++ { err := expectedm1.Set(i, j, validElements[i][j]) if err != nil { - t.Errorf("copyMatrix.Set error: " + err.Error()) + t.Errorf("copyMatrix.Set error: %s", err.Error()) } } } @@ -73,7 +73,7 @@ func TestMatrixGet(t *testing.T) { matrix := matrix.New(3, 3, 0) err := matrix.Set(1, 1, 42) // Set a specific value for testing if err != nil { - t.Errorf("copyMatrix.Set error: " + err.Error()) + t.Errorf("copyMatrix.Set error: %s", err.Error()) } // Test case 1: Valid Get val1, err1 := matrix.Get(1, 1) diff --git a/math/matrix/strassenmatrixmultiply_test.go b/math/matrix/strassenmatrixmultiply_test.go index a3e58d87a..b47b4c8fc 100644 --- a/math/matrix/strassenmatrixmultiply_test.go +++ b/math/matrix/strassenmatrixmultiply_test.go @@ -66,7 +66,7 @@ func TestStrassenMatrixMultiply(t *testing.T) { } } func TestMatrixMultiplication(t *testing.T) { - rand.Seed(time.Now().UnixNano()) + rand.New(rand.NewSource(time.Now().UnixNano())) // Generate random matrices for testing size := 1 << (rand.Intn(8) + 1) // tests for matrix with n as power of 2 @@ -103,7 +103,7 @@ func TestMatrixMultiplication(t *testing.T) { } func MakeRandomMatrix[T constraints.Integer](rows, columns int) matrix.Matrix[T] { - rand.Seed(time.Now().UnixNano()) + rand.New(rand.NewSource(time.Now().UnixNano())) matrixData := make([][]T, rows) for i := 0; i < rows; i++ {