github.com/TeaOSLab/EdgeNode@v1.3.8/internal/caches/partial_ranges_queue_test.go (about) 1 // Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . 2 3 package caches_test 4 5 import ( 6 "github.com/TeaOSLab/EdgeNode/internal/caches" 7 "github.com/iwind/TeaGo/assert" 8 "testing" 9 ) 10 11 func TestNewPartialRangesQueue(t *testing.T) { 12 var a = assert.NewAssertion(t) 13 14 var queue = caches.NewPartialRangesQueue() 15 queue.Put("a", []byte{1, 2, 3}) 16 t.Log("add 'a':", queue.Len()) 17 t.Log(queue.Get("a")) 18 a.IsTrue(queue.Len() == 1) 19 20 queue.Put("a", nil) 21 t.Log("add 'a':", queue.Len()) 22 a.IsTrue(queue.Len() == 1) 23 24 queue.Put("b", nil) 25 t.Log("add 'b':", queue.Len()) 26 a.IsTrue(queue.Len() == 2) 27 28 queue.Delete("a") 29 t.Log("delete 'a':", queue.Len()) 30 a.IsTrue(queue.Len() == 1) 31 }