Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TouHou.FM
Radio Go
Playlist
Commits
23582a1a
Verified
Commit
23582a1a
authored
Sep 02, 2020
by
Daniel Sonck
Browse files
Fix unit tests to use Int instead of Uint
parent
05d1c4b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
internal/playlist/item_test.go
View file @
23582a1a
...
...
@@ -10,12 +10,12 @@ import (
func
TestListItem_Next_Prev
(
t
*
testing
.
T
)
{
var
playlist
Playlist
playlist
.
Append
(
&
protocol
.
Song
{
Start
:
rand
.
Ui
nt6
4
(),
Stop
:
rand
.
Ui
nt6
4
(),
Start
:
rand
.
I
nt6
3
(),
Stop
:
rand
.
I
nt6
3
(),
})
playlist
.
Append
(
&
protocol
.
Song
{
Start
:
rand
.
Ui
nt6
4
(),
Stop
:
rand
.
Ui
nt6
4
(),
Start
:
rand
.
I
nt6
3
(),
Stop
:
rand
.
I
nt6
3
(),
})
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
.
Ui
nt6
4
(),
rand
.
Ui
nt6
4
()
start
,
stop
:=
math
.
Min
Ui
nt64
(
a
,
b
),
math
.
Max
Ui
nt64
(
a
,
b
)
a
,
b
:=
rand
.
I
nt6
3
(),
rand
.
I
nt6
3
()
start
,
stop
:=
math
.
Min
I
nt64
(
a
,
b
),
math
.
Max
I
nt64
(
a
,
b
)
playlist
.
Append
(
&
protocol
.
Song
{
Start
:
start
,
Stop
:
stop
})
}
answer
,
err
:=
playlist
.
Start
()
.
Distance
(
playlist
.
End
())
...
...
internal/playlist/playlist_test.go
View file @
23582a1a
...
...
@@ -16,8 +16,8 @@ func TestPlaylist_Duration_Empty(t *testing.T) {
func
TestPlaylist_Duration_One
(
t
*
testing
.
T
)
{
var
playlist
Playlist
a
,
b
:=
rand
.
Ui
nt6
4
(),
rand
.
Ui
nt6
4
()
start
,
stop
:=
math
.
Min
Ui
nt64
(
a
,
b
),
math
.
Max
Ui
nt64
(
a
,
b
)
a
,
b
:=
rand
.
I
nt6
3
(),
rand
.
I
nt6
3
()
start
,
stop
:=
math
.
Min
I
nt64
(
a
,
b
),
math
.
Max
I
nt64
(
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
:=
u
int64
(
0
)
sum
:=
int64
(
0
)
for
I
:=
0
;
I
<
count
;
I
++
{
a
,
b
:=
rand
.
Ui
nt6
4
(),
rand
.
Ui
nt6
4
()
start
,
stop
:=
math
.
Min
Ui
nt64
(
a
,
b
),
math
.
Max
Ui
nt64
(
a
,
b
)
a
,
b
:=
rand
.
I
nt6
3
(),
rand
.
I
nt6
3
()
start
,
stop
:=
math
.
Min
I
nt64
(
a
,
b
),
math
.
Max
I
nt64
(
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
.
Ui
nt6
4
(),
Stop
:
rand
.
Ui
nt6
4
(),
Start
:
rand
.
I
nt6
3
(),
Stop
:
rand
.
I
nt6
3
(),
}
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
.
Ui
nt6
4
(),
Stop
:
rand
.
Ui
nt6
4
(),
Start
:
rand
.
I
nt6
3
(),
Stop
:
rand
.
I
nt6
3
(),
}
playlist
.
Append
(
&
start
)
count
:=
rand
.
Intn
(
10
)
+
10
;
for
I
:=
0
;
I
<
count
;
I
++
{
a
,
b
:=
rand
.
Ui
nt6
4
(),
rand
.
Ui
nt6
4
()
start
,
stop
:=
math
.
Min
Ui
nt64
(
a
,
b
),
math
.
Max
Ui
nt64
(
a
,
b
)
a
,
b
:=
rand
.
I
nt6
3
(),
rand
.
I
nt6
3
()
start
,
stop
:=
math
.
Min
I
nt64
(
a
,
b
),
math
.
Max
I
nt64
(
a
,
b
)
playlist
.
Append
(
&
protocol
.
Song
{
Start
:
start
,
Stop
:
stop
})
}
end
:=
protocol
.
Song
{
Start
:
rand
.
Ui
nt6
4
(),
Stop
:
rand
.
Ui
nt6
4
(),
Start
:
rand
.
I
nt6
3
(),
Stop
:
rand
.
I
nt6
3
(),
}
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
.
Ui
nt6
4
(),
Stop
:
rand
.
Ui
nt6
4
(),
Start
:
rand
.
I
nt6
3
(),
Stop
:
rand
.
I
nt6
3
(),
})
playlist
.
Append
(
&
protocol
.
Song
{
Start
:
rand
.
Ui
nt6
4
(),
Stop
:
rand
.
Ui
nt6
4
(),
Start
:
rand
.
I
nt6
3
(),
Stop
:
rand
.
I
nt6
3
(),
})
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
.
Ui
nt6
4
(),
Stop
:
rand
.
Ui
nt6
4
(),
Start
:
rand
.
I
nt6
3
(),
Stop
:
rand
.
I
nt6
3
(),
})
playlist
.
Append
(
&
protocol
.
Song
{
Start
:
rand
.
Ui
nt6
4
(),
Stop
:
rand
.
Ui
nt6
4
(),
Start
:
rand
.
I
nt6
3
(),
Stop
:
rand
.
I
nt6
3
(),
})
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
.
Ui
nt6
4
(),
Stop
:
rand
.
Ui
nt6
4
(),
Start
:
rand
.
I
nt6
3
(),
Stop
:
rand
.
I
nt6
3
(),
})
playlist
.
Append
(
&
protocol
.
Song
{
Start
:
rand
.
Ui
nt6
4
(),
Stop
:
rand
.
Ui
nt6
4
(),
Start
:
rand
.
I
nt6
3
(),
Stop
:
rand
.
I
nt6
3
(),
})
playlist
.
Append
(
&
protocol
.
Song
{
Start
:
rand
.
Ui
nt6
4
(),
Stop
:
rand
.
Ui
nt6
4
(),
Start
:
rand
.
I
nt6
3
(),
Stop
:
rand
.
I
nt6
3
(),
})
first
:=
playlist
.
Start
()
middle
:=
first
.
Next
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment