mirror of
https://gitee.com/willfree/mlsr.git
synced 2026-06-18 14:06:06 +08:00
64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
// Package Calculator
|
|
// @Author: Wang Feng
|
|
// @Description:
|
|
// @Version: 0.1.0
|
|
// @Date: 2022/5/10 16:53
|
|
// @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
|
//
|
|
|
|
package route
|
|
|
|
import (
|
|
"fmt"
|
|
"minlib/component"
|
|
"testing"
|
|
)
|
|
|
|
//
|
|
// TestRouterMap_Store
|
|
// @Description: 测试RouterMap
|
|
// @param t
|
|
//
|
|
func TestRouterMap_Store(t *testing.T) {
|
|
iden, _ := component.CreateIdentifierByString("/test/weforever")
|
|
iden1, _ := component.CreateIdentifierByString("/test/weforever1")
|
|
iden2, _ := component.CreateIdentifierByString("/test/weforever2")
|
|
// 存入
|
|
rmap := new(RouterMap)
|
|
rmap.Init()
|
|
rmap.Store(iden)
|
|
rmap.Store(iden1)
|
|
rmap.Store(iden2)
|
|
|
|
// 取出标识
|
|
index, b := rmap.GetMappingNoByRouterName(iden2)
|
|
fmt.Println(index, b)
|
|
|
|
// 取出一个同URI的标识
|
|
idenNew2, _ := component.CreateIdentifierByString("/test/weforever2")
|
|
index, b = rmap.GetMappingNoByRouterName(idenNew2)
|
|
fmt.Println(index, b)
|
|
|
|
// 取出Iden
|
|
idenCat, bb := rmap.GetRouterNameByMappingNo(0)
|
|
fmt.Println(idenCat.ToUri(), bb)
|
|
idenCat, bb = rmap.GetRouterNameByMappingNo(1)
|
|
fmt.Println(idenCat.ToUri(), bb)
|
|
idenCat, bb = rmap.GetRouterNameByMappingNo(2)
|
|
fmt.Println(idenCat.ToUri(), bb)
|
|
idenCat, bb = rmap.GetRouterNameByMappingNo(3)
|
|
fmt.Println(bb)
|
|
|
|
// 查看map大小
|
|
fmt.Println(rmap.GetMapSize())
|
|
|
|
// 删除后再查看
|
|
rmap.delete(iden)
|
|
rmap.delete(idenNew2)
|
|
fmt.Println(rmap.GetMapSize())
|
|
idenCat, bb = rmap.GetRouterNameByMappingNo(0)
|
|
fmt.Println(bb)
|
|
idenCat, bb = rmap.GetRouterNameByMappingNo(2)
|
|
fmt.Println(bb)
|
|
}
|