github.com/Asutorufa/yuhaiin@v0.3.6-0.20240502055049-7984da7023a0/pkg/net/proxy/quic/frag_test.go (about) 1 package quic 2 3 import ( 4 "fmt" 5 "testing" 6 ) 7 8 func compareConstantTime(num int) int { 9 fmt.Println(num | -num) 10 fmt.Println((num | -num) >> 31) 11 return ((num | -num) >> 31) & 1 12 } 13 14 func TestFrag(t *testing.T) { 15 t.Log(compareConstantTime(100)) 16 t.Log(compareConstantTime(102)) 17 t.Log(compareConstantTime(1022)) 18 t.Log(compareConstantTime(0)) 19 20 f := Frag{} 21 22 x := []byte(` 23 sdadsacsacas 24 VvsPKBDZyYauFZ0OvjsBrn3jUFpLZw4VJLwlXI6PKMvgJwPiiWcbwvSjbcUVkUBu 25 MQswCQYDVQQGEwJVQTAgFw0yMzEwMTEwMDAwMDBaGA8yMTIzMTAxMTAzMjczNVowRjESMBAGA1UE 26 AwwJMTI3LjAuMC4xMSMwIQYDVQQKDBpSZWdlcnksIGh0dHBzOi8vcmVnZXJ5LmNvbTELMAkGA1UE 27 sdadsacsacasa 28 w7dd9uyDlVMFmHiNBlVDeLxMPJCyO7O13ktYY6td 29 Adda 30 w7dd9uyDlVMFmHiNBlVDeLxMPJCyO7O13ktYY6td 31 irtlS23Zr1qium5zAjrmk6eV4igiewV4AagcBnB9ydSEcf`) 32 33 datas := f.Split(x, 50) 34 35 t.Log(len(datas), len(x)) 36 37 for i, v := range datas { 38 t.Log(i, v.Len()) 39 if x := f.Merge(v.Bytes()); x != nil { 40 t.Log(string(x.Bytes())) 41 } 42 } 43 }