diff options
author | EuAndreh <eu@euandre.org> | 2025-01-22 07:36:32 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2025-01-22 07:36:32 -0300 |
commit | c0adfb70bd273a00d0a4a5f5ce19d6f4550e0b8b (patch) | |
tree | 828fafa75b9174a8fa658b58cac1c6918cd4075c | |
parent | tests/pds.go: Move benchmarks and examples to separate test files (diff) | |
download | pds-c0adfb70bd273a00d0a4a5f5ce19d6f4550e0b8b.tar.gz pds-c0adfb70bd273a00d0a4a5f5ce19d6f4550e0b8b.tar.xz |
tests/pds.go: Init removal of "testing" usage
-rw-r--r-- | tests/pds.go | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/tests/pds.go b/tests/pds.go index b1df034..049edae 100644 --- a/tests/pds.go +++ b/tests/pds.go @@ -9,20 +9,21 @@ import ( "sort" "testing" "testing/internal/testdeps" -) -var ( - veryVerbose = flag.Bool("vv", false, "very verbose") - randomN = flag.Int("random.n", 100, "number of RunRandom() iterations") + g "gobang" ) -func TestList(t *testing.T) { - t.Run("Empty", func(t *testing.T) { - if size := NewList[string]().Len(); size != 0 { - t.Fatalf("unexpected size: %d", size) - } + + +func test_NewList() { + g.TestStart("NewList[]()") + + g.Testing("a brand new list starts empty", func() { + g.TAssertEqual(NewList[int]().Len(), 0) }) +} +func TestList(t *testing.T) { t.Run("Shallow", func(t *testing.T) { list := NewList[string]() list = list.Append("foo") @@ -56,7 +57,13 @@ func TestList(t *testing.T) { } for j := range array { if got, exp := list.Get(j), array[j]; got != exp { - t.Fatalf("%d. List.Get(%d)=%d, exp %d", len(array), j, got, exp) + t.Fatalf( + "%d. List.Get(%d)=%d, exp %d", + len(array), + j, + got, + exp, + ) } } }) @@ -183,10 +190,9 @@ func TestList(t *testing.T) { }) t.Run("TestSliceFreesReferences", func(t *testing.T) { - /* Test that the leaf node in a sliced list contains zero'ed entries at - * the correct positions. To do this we directly access the internal - * tree structure of the list. - */ + // Test that the leaf node in a sliced list contains zero'ed + // entries at the correct positions. To do this we directly + // access the internal tree structure of the list. l := NewList[*int]() var ints [5]int for i := 0; i < 5; i++ { @@ -263,7 +269,8 @@ func TestList(t *testing.T) { }) } -// TList represents a list that operates on a standard Go slice & immutable list. +// TList represents a list that operates on a standard Go slice & immutable +// list. type tList struct { im, prev *List[int] builder *ListBuilder[int] @@ -1845,6 +1852,8 @@ func (m *tSortedMap) validateBackwardIterator(itr *SortedMapIterator[int, int]) return nil } +var randomN = flag.Int("random.n", 100, "number of RunRandom() iterations") + // RunRandom executes fn multiple times with a different rand. func RunRandom(t *testing.T, name string, fn func(t *testing.T, rand *rand.Rand)) { t.Run(name, func(t *testing.T) { @@ -2021,6 +2030,8 @@ func TestSortedSetBuilder(t *testing.T) { func MainTest() { + test_NewList() + tests := []testing.InternalTest{ { "TestList", TestList }, { "TestInternal_mapNode_Overwrite", TestInternal_mapNode_Overwrite }, |