32 lines
496 B
Go
32 lines
496 B
Go
|
package ytid
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestGetID(t *testing.T) {
|
||
|
inputs := []string{
|
||
|
"https://www.youtube.com/watch?v=m4U232MuTG4",
|
||
|
"https://youtu.be/dVtehSbLO8M",
|
||
|
"https://www.youtube.com/embed/Kt-tLuszKBA",
|
||
|
}
|
||
|
|
||
|
for n, i := range inputs {
|
||
|
switch n {
|
||
|
case 0:
|
||
|
if GetID(i) != "m4U232MuTG4" {
|
||
|
t.Fatal("failed", n)
|
||
|
}
|
||
|
case 1:
|
||
|
if GetID(i) != "dVtehSbLO8M" {
|
||
|
t.Fatal("failed", n)
|
||
|
}
|
||
|
case 2:
|
||
|
if GetID(i) != "Kt-tLuszKBA" {
|
||
|
t.Fatal("failed", n)
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|