]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Improve 添加更多测试
authorqydysky <qydysky@foxmail.com>
Mon, 15 Jan 2024 16:27:04 +0000 (00:27 +0800)
committerqydysky <qydysky@foxmail.com>
Mon, 15 Jan 2024 16:27:04 +0000 (00:27 +0800)
F/api.go
F/api_test.go
Reply/flvDecode.go
Reply/fmp4Decode.go
Reply/stream.go

index eddb0a8993d06da2b0d13bf8bd8ce7d95e6edb67..88afce94d4c85218c754202ade4ae1736da56138 100644 (file)
--- a/F/api.go
+++ b/F/api.go
@@ -326,7 +326,7 @@ func (t *GetFunc) Html() (missKey []string) {
                                if !t.Liveing {
                                        t.Live_qn = 0
                                        t.AcceptQn = t.Qn
-                                       t.Live = []c.LiveQn{}
+                                       clear(t.Live)
                                        return
                                }
 
@@ -415,7 +415,7 @@ func (t *GetFunc) configStreamType(sts []J.StreamType) {
                                        t.AcceptQn = tmp
                                }
                                //直播流链接
-                               t.Live = []c.LiveQn{}
+                               clear(t.Live)
                                for _, v1 := range v.URLInfo {
                                        item := c.LiveQn{
                                                Url: v1.Host + v.BaseURL + v1.Extra,
@@ -475,7 +475,7 @@ func (t *GetFunc) configStreamType(sts []J.StreamType) {
                                                t.AcceptQn = tmp
                                        }
                                        //直播流链接
-                                       t.Live = []c.LiveQn{}
+                                       clear(t.Live)
                                        for _, v1 := range v.URLInfo {
                                                item := c.LiveQn{
                                                        Url: v1.Host + v.BaseURL + v1.Extra,
@@ -730,7 +730,7 @@ func (t *GetFunc) getRoomPlayInfo() (missKey []string) {
                if !t.Liveing {
                        t.Live_qn = 0
                        t.AcceptQn = t.Qn
-                       t.Live = []c.LiveQn{}
+                       clear(t.Live)
                        return
                }
 
@@ -825,7 +825,7 @@ func (t *GetFunc) getRoomPlayInfoByQn() (missKey []string) {
                if !t.Liveing {
                        t.Live_qn = 0
                        t.AcceptQn = t.Qn
-                       t.Live = []c.LiveQn{}
+                       clear(t.Live)
                        return
                }
 
index 5fccaedddf604d3d8f9809146ae9074ae6c0b7cd..a5f870dc9f330789e88ba95049310d8f16610e47 100644 (file)
@@ -59,3 +59,69 @@ func Test_Title(t *testing.T) {
                t.Fatal()
        }
 }
+
+func Test_Html(t *testing.T) {
+       //获取cookie
+       Get(c.C).Get(`Cookie`)
+       //获取LIVE_BUVID
+       Get(c.C).Get(`LIVE_BUVID`)
+       c.C.Roomid = 394988
+       c.C.UpUid = 0
+       Get(c.C).Html()
+       if c.C.UpUid == 0 {
+               t.Fatal()
+       }
+}
+
+func Test_getRoomPlayInfo(t *testing.T) {
+       //获取cookie
+       Get(c.C).Get(`Cookie`)
+       //获取LIVE_BUVID
+       Get(c.C).Get(`LIVE_BUVID`)
+       c.C.Roomid = 394988
+       c.C.UpUid = 0
+       Get(c.C).getRoomPlayInfo()
+       if c.C.UpUid == 0 {
+               t.Fatal()
+       }
+}
+
+func Test_getRoomPlayInfoByQn(t *testing.T) {
+       //获取cookie
+       Get(c.C).Get(`Cookie`)
+       //获取LIVE_BUVID
+       Get(c.C).Get(`LIVE_BUVID`)
+       c.C.Roomid = 394988
+       c.C.UpUid = 0
+       Get(c.C).getRoomPlayInfoByQn()
+       if c.C.UpUid == 0 {
+               t.Fatal()
+       }
+}
+
+func Test_getDanmuInfo(t *testing.T) {
+       //获取cookie
+       Get(c.C).Get(`Cookie`)
+       //获取LIVE_BUVID
+       Get(c.C).Get(`LIVE_BUVID`)
+       c.C.Roomid = 394988
+       c.C.WSURL = []string{}
+       Get(c.C).getDanmuInfo()
+       if len(c.C.WSURL) == 0 {
+               t.Fatal()
+       }
+}
+
+func Test_Get_guardNum(t *testing.T) {
+       //获取cookie
+       Get(c.C).Get(`Cookie`)
+       //获取LIVE_BUVID
+       Get(c.C).Get(`LIVE_BUVID`)
+       c.C.Roomid = 394988
+       c.C.GuardNum = -1
+       Get(c.C).Html()
+       Get(c.C).Get_guardNum()
+       if c.C.GuardNum == -1 {
+               t.Fatal()
+       }
+}
index 68757c9f68614b687ab174ef22c95eec3bedd420..9d51843abf4d3fc27b0d0a0634b7fcd608d3dc25 100644 (file)
@@ -54,7 +54,7 @@ func Search_stream_tag(buf []byte, keyframe *slice.Buf[byte]) (front_buf []byte,
                        // if sign != 0x00 {
                        // fmt.Printf("front_buf error:%x\n", sign)
                        // }
-                       front_buf = []byte{}
+                       clear(front_buf)
                }
                if bufl := keyframe.Size(); confirm_num != bufl {
                        _ = keyframe.RemoveBack(bufl - confirm_num)
index b4955243b7d1a755958a7d357f65fe4200ee18f2..f5f0f2fe4baf946c9356092dd553ff5581bb7cc5 100644 (file)
@@ -231,7 +231,7 @@ func (t *Fmp4Decoder) Search_stream_fmp4(buf []byte, keyframe *slice.Buf[byte])
 
        ies, e := decode(buf, "moof")
        if e != nil {
-               return
+               return 0, e
        }
 
        err = deals(ies,
@@ -428,7 +428,7 @@ func decode(buf []byte, reSyncboxName string) (m []ie, err error) {
                        err = E
                        if reSyncI := bytes.Index(buf[cu:], []byte(reSyncboxName)); reSyncI != -1 {
                                cu += reSyncI - 4
-                               m = []ie{}
+                               clear(m)
                                continue
                        }
                        err = errors.New(E.Error() + " > 未能reSync")
index c7ac73ce2a2ba2946228ea784d6f3f2074e51c9e..fd06887f7de55370d21c4a902685aeb90af05948 100644 (file)
@@ -455,7 +455,7 @@ func (t *M4SStream) fetchParseM3U8(fmp4ListUpdateTo float64) (m4s_links []*m4s_l
                                        if index := bytes.Index(m3u8_addon, []byte(m4s_link.Base)); index != -1 {
                                                index += len([]byte(m4s_link.Base))
                                                if index == len(m3u8_addon) {
-                                                       m3u8_addon = []byte{}
+                                                       clear(m3u8_addon)
                                                } else {
                                                        m3u8_addon = m3u8_addon[index+1:]
                                                }