Skip to content

Commit

Permalink
Correction of word assert spelling mistakes (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
feng6917 authored Nov 12, 2024
1 parent a769257 commit d1a8f37
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
16 changes: 8 additions & 8 deletions algorithm/lrucache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ import (

func TestLRUCache(t *testing.T) {
t.Parallel()
asssert := internal.NewAssert(t, "TestLRUCache")
assert := internal.NewAssert(t, "TestLRUCache")

cache := NewLRUCache[int, int](3)

cache.Put(1, 1)
cache.Put(2, 2)
cache.Put(3, 3)

asssert.Equal(3, cache.Len())
assert.Equal(3, cache.Len())

v, ok := cache.Get(1)
asssert.Equal(true, ok)
asssert.Equal(1, v)
assert.Equal(true, ok)
assert.Equal(1, v)

v, ok = cache.Get(2)
asssert.Equal(true, ok)
asssert.Equal(2, v)
assert.Equal(true, ok)
assert.Equal(2, v)

ok = cache.Delete(2)
asssert.Equal(true, ok)
assert.Equal(true, ok)

_, ok = cache.Get(2)
asssert.Equal(false, ok)
assert.Equal(false, ok)
}
18 changes: 9 additions & 9 deletions algorithm/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,34 @@ import (

func TestLinearSearch(t *testing.T) {
t.Parallel()
asssert := internal.NewAssert(t, "TestLinearSearch")
assert := internal.NewAssert(t, "TestLinearSearch")

numbers := []int{3, 4, 5, 3, 2, 1}
equalFunc := func(a, b int) bool {
return a == b
}

asssert.Equal(0, LinearSearch(numbers, 3, equalFunc))
asssert.Equal(-1, LinearSearch(numbers, 6, equalFunc))
assert.Equal(0, LinearSearch(numbers, 3, equalFunc))
assert.Equal(-1, LinearSearch(numbers, 6, equalFunc))
}

func TestBinarySearch(t *testing.T) {
t.Parallel()
asssert := internal.NewAssert(t, "TestBinarySearch")
assert := internal.NewAssert(t, "TestBinarySearch")

sortedNumbers := []int{1, 2, 3, 4, 5, 6, 7, 8}
comparator := &intComparator{}

asssert.Equal(4, BinarySearch(sortedNumbers, 5, 0, len(sortedNumbers)-1, comparator))
asssert.Equal(-1, BinarySearch(sortedNumbers, 9, 0, len(sortedNumbers)-1, comparator))
assert.Equal(4, BinarySearch(sortedNumbers, 5, 0, len(sortedNumbers)-1, comparator))
assert.Equal(-1, BinarySearch(sortedNumbers, 9, 0, len(sortedNumbers)-1, comparator))
}

func TestBinaryIterativeSearch(t *testing.T) {
asssert := internal.NewAssert(t, "TestBinaryIterativeSearch")
assert := internal.NewAssert(t, "TestBinaryIterativeSearch")

sortedNumbers := []int{1, 2, 3, 4, 5, 6, 7, 8}
comparator := &intComparator{}

asssert.Equal(4, BinaryIterativeSearch(sortedNumbers, 5, 0, len(sortedNumbers)-1, comparator))
asssert.Equal(-1, BinaryIterativeSearch(sortedNumbers, 9, 0, len(sortedNumbers)-1, comparator))
assert.Equal(4, BinaryIterativeSearch(sortedNumbers, 5, 0, len(sortedNumbers)-1, comparator))
assert.Equal(-1, BinaryIterativeSearch(sortedNumbers, 9, 0, len(sortedNumbers)-1, comparator))
}
36 changes: 18 additions & 18 deletions algorithm/sort_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (c *intComparator) Compare(v1 any, v2 any) int {

func TestBubbleSortForStructSlice(t *testing.T) {
t.Parallel()
asssert := internal.NewAssert(t, "TestBubbleSortForStructSlice")
assert := internal.NewAssert(t, "TestBubbleSortForStructSlice")

peoples := []people{
{Name: "a", Age: 20},
Expand All @@ -62,23 +62,23 @@ func TestBubbleSortForStructSlice(t *testing.T) {
expected := "[{d 8} {b 10} {c 17} {a 20} {e 28}]"
actual := fmt.Sprintf("%v", peoples)

asssert.Equal(expected, actual)
assert.Equal(expected, actual)
}

func TestBubbleSortForIntSlice(t *testing.T) {
t.Parallel()
asssert := internal.NewAssert(t, "TestBubbleSortForIntSlice")
assert := internal.NewAssert(t, "TestBubbleSortForIntSlice")

numbers := []int{2, 1, 5, 3, 6, 4}
comparator := &intComparator{}
BubbleSort(numbers, comparator)

asssert.Equal([]int{1, 2, 3, 4, 5, 6}, numbers)
assert.Equal([]int{1, 2, 3, 4, 5, 6}, numbers)
}

func TestInsertionSort(t *testing.T) {
t.Parallel()
asssert := internal.NewAssert(t, "TestInsertionSort")
assert := internal.NewAssert(t, "TestInsertionSort")

peoples := []people{
{Name: "a", Age: 20},
Expand All @@ -93,12 +93,12 @@ func TestInsertionSort(t *testing.T) {
expected := "[{d 8} {b 10} {c 17} {a 20} {e 28}]"
actual := fmt.Sprintf("%v", peoples)

asssert.Equal(expected, actual)
assert.Equal(expected, actual)
}

func TestSelectionSort(t *testing.T) {
t.Parallel()
asssert := internal.NewAssert(t, "TestSelectionSort")
assert := internal.NewAssert(t, "TestSelectionSort")

peoples := []people{
{Name: "a", Age: 20},
Expand All @@ -113,12 +113,12 @@ func TestSelectionSort(t *testing.T) {
expected := "[{d 8} {b 10} {c 17} {a 20} {e 28}]"
actual := fmt.Sprintf("%v", peoples)

asssert.Equal(expected, actual)
assert.Equal(expected, actual)
}

func TestShellSort(t *testing.T) {
t.Parallel()
asssert := internal.NewAssert(t, "TestShellSort")
assert := internal.NewAssert(t, "TestShellSort")

peoples := []people{
{Name: "a", Age: 20},
Expand All @@ -133,12 +133,12 @@ func TestShellSort(t *testing.T) {
expected := "[{d 8} {b 10} {c 17} {a 20} {e 28}]"
actual := fmt.Sprintf("%v", peoples)

asssert.Equal(expected, actual)
assert.Equal(expected, actual)
}

func TestQuickSort(t *testing.T) {
t.Parallel()
asssert := internal.NewAssert(t, "TestQuickSort")
assert := internal.NewAssert(t, "TestQuickSort")

peoples := []people{
{Name: "a", Age: 20},
Expand All @@ -153,12 +153,12 @@ func TestQuickSort(t *testing.T) {
expected := "[{d 8} {b 10} {c 17} {a 20} {e 28}]"
actual := fmt.Sprintf("%v", peoples)

asssert.Equal(expected, actual)
assert.Equal(expected, actual)
}

func TestHeapSort(t *testing.T) {
t.Parallel()
asssert := internal.NewAssert(t, "TestHeapSort")
assert := internal.NewAssert(t, "TestHeapSort")

peoples := []people{
{Name: "a", Age: 20},
Expand All @@ -173,12 +173,12 @@ func TestHeapSort(t *testing.T) {
expected := "[{d 8} {b 10} {c 17} {a 20} {e 28}]"
actual := fmt.Sprintf("%v", peoples)

asssert.Equal(expected, actual)
assert.Equal(expected, actual)
}

func TestMergeSort(t *testing.T) {
t.Parallel()
asssert := internal.NewAssert(t, "TestMergeSort")
assert := internal.NewAssert(t, "TestMergeSort")

peoples := []people{
{Name: "a", Age: 20},
Expand All @@ -193,12 +193,12 @@ func TestMergeSort(t *testing.T) {
expected := "[{d 8} {b 10} {c 17} {a 20} {e 28}]"
actual := fmt.Sprintf("%v", peoples)

asssert.Equal(expected, actual)
assert.Equal(expected, actual)
}

func TestCountSort(t *testing.T) {
t.Parallel()
asssert := internal.NewAssert(t, "TestCountSort")
assert := internal.NewAssert(t, "TestCountSort")

peoples := []people{
{Name: "a", Age: 20},
Expand All @@ -213,5 +213,5 @@ func TestCountSort(t *testing.T) {
expected := "[{d 8} {b 10} {c 17} {a 20} {e 28}]"
actual := fmt.Sprintf("%v", sortedPeopleByAge)

asssert.Equal(expected, actual)
assert.Equal(expected, actual)
}

0 comments on commit d1a8f37

Please sign in to comment.