This commit is contained in:
2024-09-16 20:24:30 +08:00
parent c3ed9a2b53
commit f4555c21e5
6 changed files with 723 additions and 1 deletions

62
bluray_test.go Normal file
View File

@@ -0,0 +1,62 @@
package bluray
import (
"encoding/json"
"fmt"
"testing"
)
func TestGetBDVersion(t *testing.T) {
version := GetBDVersion()
if version == "" {
t.Errorf("Expected non-empty version string, got empty string")
}
fmt.Printf("libbluray version: %s\n", version)
}
func TestBD(t *testing.T) {
db := BDOpen("path")
if db == nil {
t.Errorf("Expected non-nil DBStruct, got nil")
return
}
info, err := db.GetDiscInfo()
if err != nil {
t.Errorf("Expected non-nil BlurayDiscInfo, got nil")
return
}
res, err := json.Marshal(info)
if err != nil {
t.Errorf("json.Marshal failed: %v", err)
return
}
fmt.Println(string(res))
num, err := db.GetTitles(TitlesAll, 0)
if err != nil {
t.Errorf("Expected non-nil BlurayTitle, got nil")
return
}
fmt.Printf("titles: %v\n", num)
mainTitle, err := db.GetMainTitle()
if err != nil {
t.Errorf("Expected non-nil BlurayTitle, got nil")
return
}
fmt.Printf("main title: %v\n", mainTitle)
tInfo, err := db.GetTitleInfo(mainTitle, 0)
if err != nil {
t.Errorf("Expected non-nil BlurayTitle, got nil")
return
}
res, err = json.Marshal(tInfo)
if err != nil {
t.Errorf("json.Marshal failed: %v", err)
return
}
fmt.Println(string(res))
}