github.com/TeaOSLab/EdgeNode@v1.3.8/internal/utils/net_test.go (about)

     1  // Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
     2  
     3  package utils_test
     4  
     5  import (
     6  	"github.com/TeaOSLab/EdgeNode/internal/utils"
     7  	"testing"
     8  )
     9  
    10  func TestParseAddrHost(t *testing.T) {
    11  	for _, addr := range []string{"a", "example.com", "example.com:1234", "::1", "[::1]", "[::1]:8080"} {
    12  		t.Log(addr + " => " + utils.ParseAddrHost(addr))
    13  	}
    14  }
    15  
    16  func TestMergePorts(t *testing.T) {
    17  	for _, ports := range [][]int{
    18  		{},
    19  		{80},
    20  		{80, 83, 85},
    21  		{80, 81, 83, 85, 86, 87, 88, 90},
    22  		{0, 0, 1, 1, 2, 2, 2, 3, 3, 3},
    23  	} {
    24  		t.Log(ports, "=>", utils.MergePorts(ports))
    25  	}
    26  }