Verified Commit 23582a1a authored by Daniel Sonck's avatar Daniel Sonck
Browse files

Fix unit tests to use Int instead of Uint

parent 05d1c4b2
......@@ -10,12 +10,12 @@ import (
func TestListItem_Next_Prev(t *testing.T) {
var playlist Playlist
playlist.Append(&protocol.Song{
Start: rand.Uint64(),
Stop: rand.Uint64(),
Start: rand.Int63(),
Stop: rand.Int63(),
})
playlist.Append(&protocol.Song{
Start: rand.Uint64(),
Stop: rand.Uint64(),
Start: rand.Int63(),
Stop: rand.Int63(),
})
if playlist.Start().Next() != playlist.End() {
t.Fatalf("Start().Next failed")
......@@ -29,8 +29,8 @@ func TestListItem_Distance(t *testing.T) {
var playlist Playlist
count := rand.Intn(10) + 10
for I := 0; I < count; I ++ {
a, b := rand.Uint64(), rand.Uint64()
start, stop := math.MinUint64(a,b), math.MaxUint64(a,b)
a, b := rand.Int63(), rand.Int63()
start, stop := math.MinInt64(a,b), math.MaxInt64(a,b)
playlist.Append(&protocol.Song{Start: start, Stop: stop})
}
answer, err := playlist.Start().Distance(playlist.End())
......
......@@ -16,8 +16,8 @@ func TestPlaylist_Duration_Empty(t *testing.T) {
func TestPlaylist_Duration_One(t *testing.T) {
var playlist Playlist
a, b := rand.Uint64(), rand.Uint64()
start, stop := math.MinUint64(a,b), math.MaxUint64(a,b)
a, b := rand.Int63(), rand.Int63()
start, stop := math.MinInt64(a,b), math.MaxInt64(a,b)
playlist.Append(&protocol.Song{Start: start, Stop: stop})
if answer := playlist.Duration(); answer != stop - start {
t.Fatalf("Expected duration %v, got %v", stop-start, answer)
......@@ -27,10 +27,10 @@ func TestPlaylist_Duration_One(t *testing.T) {
func TestPlaylist_Duration_Multiple(t *testing.T) {
var playlist Playlist
count := rand.Intn(10)+10
sum := uint64(0)
sum := int64(0)
for I := 0; I < count; I ++ {
a, b := rand.Uint64(), rand.Uint64()
start, stop := math.MinUint64(a,b), math.MaxUint64(a,b)
a, b := rand.Int63(), rand.Int63()
start, stop := math.MinInt64(a,b), math.MaxInt64(a,b)
playlist.Append(&protocol.Song{Start: start, Stop: stop})
sum += stop-start
}
......@@ -49,8 +49,8 @@ func TestPlaylist_Start_Empty(t *testing.T) {
func TestPlaylist_Append_One(t *testing.T) {
var playlist Playlist
item := protocol.Song{
Start: rand.Uint64(),
Stop: rand.Uint64(),
Start: rand.Int63(),
Stop: rand.Int63(),
}
playlist.Append(&item)
if answer := playlist.Start().Song; answer != item {
......@@ -64,19 +64,19 @@ func TestPlaylist_Append_One(t *testing.T) {
func TestPlaylist_Append_Multiple(t *testing.T) {
var playlist Playlist
start := protocol.Song{
Start: rand.Uint64(),
Stop: rand.Uint64(),
Start: rand.Int63(),
Stop: rand.Int63(),
}
playlist.Append(&start)
count := rand.Intn(10) + 10;
for I := 0; I < count; I ++ {
a, b := rand.Uint64(), rand.Uint64()
start, stop := math.MinUint64(a,b), math.MaxUint64(a,b)
a, b := rand.Int63(), rand.Int63()
start, stop := math.MinInt64(a,b), math.MaxInt64(a,b)
playlist.Append(&protocol.Song{Start: start, Stop: stop})
}
end := protocol.Song{
Start: rand.Uint64(),
Stop: rand.Uint64(),
Start: rand.Int63(),
Stop: rand.Int63(),
}
playlist.Append(&end)
if answer := playlist.Start().Song; answer != start {
......@@ -98,12 +98,12 @@ func TestPlaylist_End_Empty(t *testing.T) {
func TestPlaylist_Erase_Start(t *testing.T) {
var playlist Playlist
playlist.Append(&protocol.Song{
Start: rand.Uint64(),
Stop: rand.Uint64(),
Start: rand.Int63(),
Stop: rand.Int63(),
})
playlist.Append(&protocol.Song{
Start: rand.Uint64(),
Stop: rand.Uint64(),
Start: rand.Int63(),
Stop: rand.Int63(),
})
first := playlist.Start()
last := playlist.End()
......@@ -122,12 +122,12 @@ func TestPlaylist_Erase_Start(t *testing.T) {
func TestPlaylist_Erase_End(t *testing.T) {
var playlist Playlist
playlist.Append(&protocol.Song{
Start: rand.Uint64(),
Stop: rand.Uint64(),
Start: rand.Int63(),
Stop: rand.Int63(),
})
playlist.Append(&protocol.Song{
Start: rand.Uint64(),
Stop: rand.Uint64(),
Start: rand.Int63(),
Stop: rand.Int63(),
})
first := playlist.Start()
last := playlist.End()
......@@ -146,16 +146,16 @@ func TestPlaylist_Erase_End(t *testing.T) {
func TestPlaylist_Erase_Middle(t *testing.T) {
var playlist Playlist
playlist.Append(&protocol.Song{
Start: rand.Uint64(),
Stop: rand.Uint64(),
Start: rand.Int63(),
Stop: rand.Int63(),
})
playlist.Append(&protocol.Song{
Start: rand.Uint64(),
Stop: rand.Uint64(),
Start: rand.Int63(),
Stop: rand.Int63(),
})
playlist.Append(&protocol.Song{
Start: rand.Uint64(),
Stop: rand.Uint64(),
Start: rand.Int63(),
Stop: rand.Int63(),
})
first := playlist.Start()
middle := first.Next()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment