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

     1  // Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
     2  
     3  package agents_test
     4  
     5  import (
     6  	"github.com/TeaOSLab/EdgeNode/internal/utils/agents"
     7  	"testing"
     8  )
     9  
    10  func TestIsAgentFromUserAgent(t *testing.T) {
    11  	t.Log(agents.IsAgentFromUserAgent("Mozilla/5.0 (Linux;u;Android 4.2.2;zh-cn;) AppleWebKit/534.46 (KHTML,like Gecko) Version/5.1 Mobile Safari/10600.6.3 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"))
    12  	t.Log(agents.IsAgentFromUserAgent("Mozilla/5.0 (Linux;u;Android 4.2.2;zh-cn;)"))
    13  }
    14  
    15  func BenchmarkIsAgentFromUserAgent(b *testing.B) {
    16  	for i := 0; i < b.N; i++ {
    17  		agents.IsAgentFromUserAgent("Mozilla/5.0 (Linux;u;Android 4.2.2;zh-cn;) AppleWebKit/534.46 (KHTML,like Gecko) Version/5.1 Mobile Safari/10600.6.3 (compatible; Yaho)")
    18  	}
    19  }