-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2a7f73
commit 3de3480
Showing
4 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package align | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/zeebo/assert" | ||
) | ||
|
||
func TestIsLeft(t *testing.T) { | ||
Register("name") | ||
assert.Equal(t, true, IsLeft("name")) | ||
assert.Equal(t, false, IsLeft("name1")) | ||
} | ||
|
||
func TestIsLeftHeaderFooter(t *testing.T) { | ||
RegisterHeaderFooter("name") | ||
assert.Equal(t, true, IsLeftHeaderFooter("name")) | ||
assert.Equal(t, false, IsLeftHeaderFooter("name1")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package util | ||
|
||
import ( | ||
"sync" | ||
"testing" | ||
) | ||
|
||
func TestSlice_AppendTo(t *testing.T) { | ||
s := NewSlice[int](10) | ||
s.AppendTo(1) | ||
s.AppendTo(2) | ||
s.AppendTo(3) | ||
if s.Len() != 3 { | ||
t.Errorf("AppendTo failed") | ||
} | ||
} | ||
|
||
func TestSlice_At(t *testing.T) { | ||
s := Slice[int]{ | ||
data: []int{1, 2, 3}, | ||
m: sync.RWMutex{}, | ||
} | ||
if s.At(1) != 2 { | ||
t.Errorf("At failed") | ||
} | ||
} | ||
|
||
func TestSlice_Clear(t *testing.T) { | ||
s := Slice[int]{ | ||
data: []int{1, 2, 3}, | ||
m: sync.RWMutex{}, | ||
} | ||
s.Clear() | ||
if s.Len() != 0 { | ||
t.Errorf("Clear failed") | ||
} | ||
} | ||
|
||
func TestSlice_GetRaw(t *testing.T) { | ||
s := Slice[int]{ | ||
data: []int{1, 2, 3}, | ||
m: sync.RWMutex{}, | ||
} | ||
gotRaw := s.GetRaw() | ||
if len(*gotRaw) != 3 { | ||
t.Errorf("GetRaw failed") | ||
} | ||
if gotRaw != &s.data { | ||
t.Errorf("GetRaw failed") | ||
} | ||
} | ||
|
||
func TestSlice_GetCopy(t *testing.T) { | ||
s := Slice[int]{ | ||
data: []int{1, 2, 3}, | ||
m: sync.RWMutex{}, | ||
} | ||
copied := s.GetCopy() | ||
if len(copied) != 3 { | ||
t.Errorf("GetCopy failed") | ||
} | ||
if &copied == &s.data { | ||
t.Errorf("GetCopy failed") | ||
} | ||
} | ||
|
||
func TestSlice_Len(t *testing.T) { | ||
s := Slice[int]{ | ||
data: []int{1, 2, 3}, | ||
m: sync.RWMutex{}, | ||
} | ||
if s.Len() != 3 { | ||
t.Errorf("Len failed") | ||
} | ||
} | ||
|
||
func TestSlice_Set(t *testing.T) { | ||
s := Slice[int]{ | ||
data: []int{1, 2, 3}, | ||
m: sync.RWMutex{}, | ||
} | ||
s.Set(1, 4) | ||
if s.At(1) != 4 { | ||
t.Errorf("Set failed") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package util | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestSafeSet(t *testing.T) { | ||
set := NewSet[string]() | ||
set.Add("name") | ||
if !set.Contains("name") { | ||
t.Errorf("Add failed") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters