<commit_before>/* Copyright (c) 2015, <NAME> <<EMAIL>> */
/* See LICENSE for licensing information */

package xurls

import (
	"testing"
)

func TestWebURL(t *testing.T) {
	for _, c := range [...]struct {
		in   string
		want string
	}{
		{``, ``},
		{`foo`, ``},
		{`foo.a`, ``},
		{`foo.random`, ``},
		{`foo.com`, `foo.com`},
		{`foo.com bar.com`, `foo.com`},
		{`foo.onion`, `foo.onion`},
		{`foo.i2p`, `foo.i2p`},
		{`中国.中国`, `中国.中国`},
		{`foo.com/`, `foo.com/`},
		{`1.1.1.1`, `1.1.1.1`},
		{`172.16.58.3`, `172.16.58.3`},
		{`255.1.1.1`, `255.1.1.1`},
		{`300.1.1.1`, ``},
		{`1.1.1`, ``},
		{`1.1..1`, ``},
		{`test.foo.com`, `test.foo.com`},
		{`test.foo.com/path`, `test.foo.com/path`},
		{`TEST.FOO.COM/PATH`, `TEST.FOO.COM/PATH`},
		{`test.foo.com/path_(more)`, `test.foo.com/path_(more)`},
		{`http://foo.com`, `http://foo.com`},
		{` http://foo.com `, `http://foo.com`},
		{`,http://foo.com,`, `http://foo.com`},
		{`(http://foo.com)`, `http://foo.com`},
		{`<http://foo.com>`, `http://foo.com`},
		{`"http://foo.com"`, `http://foo.com`},
		{`http://foo.com`, `http://foo.com`},
		{`http://test.foo.com/`, `http://test.foo.com/`},
		{`http://foo.com/path`, `http://foo.com/path`},
		{`http://1.1.1.1/path`, `http://1.1.1.1/path`},
		{`www.foo.com`, `www.foo.com`},
		{` foo.com/bar `, `foo.com/bar`},
		{`,foo.com/bar,`, `foo.com/bar,`},
		{`(foo.com/bar)`, `foo.com/bar)`},
		{`<foo.com/bar>`, `foo.com/bar`},
		{`"foo.com/bar"`, `foo.com/bar`},
	} {
		got := WebURL.FindString(c.in)
		if got != c.want {
			t.Errorf(`WebURL.FindString("%s") got "%s", want "%s"`, c.in, got, c.want)
		}
	}
}

func TestEmail(t *testing.T) {
	for _, c := range [...]struct {
		in   string<commit_msg>Add a port url test<commit_after>/* Copyright (c) 2015, <NAME> <<EMAIL>> */
/* See LICENSE for licensing information */

package xurls

import (
	"testing"
)

func TestWebURL(t *testing.T) {
	for _, c := range [...]struct {
		in   string
		want string
	}{
		{``, ``},
		{`foo`, ``},
		{`foo.a`, ``},
		{`foo.random`, ``},
		{`foo.com`, `foo.com`},
		{`foo.com bar.com`, `foo.com`},
		{`foo.onion`, `foo.onion`},
		{`foo.i2p`, `foo.i2p`},
		{`中国.中国`, `中国.中国`},
		{`foo.com/`, `foo.com/`},
		{`1.1.1.1`, `1.1.1.1`},
		{`172.16.58.3`, `172.16.58.3`},
		{`25172.16.58.3`, `25172.16.58.3`},
		{`300.1.1.1`, ``},
		{`1.1.1`, ``},
		{`1.1..1`, ``},
		{`test.foo.com`, `test.foo.com`},
		{`test.foo.com/path`, `test.foo.com/path`},
		{`TEST.FOO.COM/PATH`, `TEST.FOO.COM/PATH`},
		{`test.foo.com/path_(more)`, `test.foo.com/path_(more)`},
		{`http://foo.com`, `http://foo.com`},
		{` http://foo.com `, `http://foo.com`},
		{`,http://foo.com,`, `http://foo.com`},
		{`(http://foo.com)`, `http://foo.com`},
		{`<http://foo.com>`, `http://foo.com`},
		{`"http://foo.com"`, `http://foo.com`},
		{`http://foo.com`, `http://foo.com`},
		{`http://test.foo.com/`, `http://test.foo.com/`},
		{`http://foo.com/path`, `http://foo.com/path`},
		{`http://foo.com:8080/path`, `http://foo.com:8080/path`},
		{`http://1.1.1.1/path`, `http://1.1.1.1/path`},
		{`www.foo.com`, `www.foo.com`},
		{` foo.com/bar `, `foo.com/bar`},
		{`,foo.com/bar,`, `foo.com/bar,`},
		{`(foo.com/bar)`, `foo.com/bar)`},
		{`<foo.com/bar>`, `foo.com/bar`},
		{`"foo.com/bar"`, `foo.com/bar`},
	} {
		got := WebURL.FindString(c.in)
		if got != c.want {
			t.Errorf(`WebURL.FindString("%s") got "%s", want "%s"`, c.in, got, c.want)
		}
	}
}

func TestEmail(t *testing.T) {
	for _, c := range [...]struct {
		in   string
{'fraction_non_alphanumeric': 0.34178674351585014, 'fraction_numerical': 0.040345821325648415, 'mean_word_length': 2.985074626865672, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 18, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '175051', 'n_tokens_mistral': 1846, 'n_tokens_neox': 1708, 'n_words': 231}