Passed
Pull Request — main (#38)
by Igor
01:51
created

is/web_example_test.go   A

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 19
dl 0
loc 44
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A is_test.ExampleRelativeURL_invalidURL 0 4 1
A is_test.ExampleRelativeURL_validRelativeURL 0 4 1
A is_test.ExampleURL_validURLWithCustomProtocol 0 4 1
A is_test.ExampleURL_invalidURL 0 4 1
A is_test.ExampleURL_validAbsoluteURL 0 4 1
1
package is_test
2
3
import (
4
	"fmt"
5
6
	"github.com/muonsoft/validation/is"
7
)
8
9
func ExampleURL_validAbsoluteURL() {
10
	valid := is.URL("https://example.com")
11
12
	fmt.Println(valid)
13
	// Output:
14
	// true
15
}
16
17
func ExampleURL_validURLWithCustomProtocol() {
18
	valid := is.URL("ftp://example.com", "http", "https", "ftp")
19
20
	fmt.Println(valid)
21
	// Output:
22
	// true
23
}
24
25
func ExampleURL_invalidURL() {
26
	valid := is.URL("example.com")
27
28
	fmt.Println(valid)
29
	// Output:
30
	// false
31
}
32
33
func ExampleRelativeURL_validRelativeURL() {
34
	valid := is.RelativeURL("//example.com")
35
36
	fmt.Println(valid)
37
	// Output:
38
	// true
39
}
40
41
func ExampleRelativeURL_invalidURL() {
42
	valid := is.RelativeURL("example.com")
43
44
	fmt.Println(valid)
45
	// Output:
46
	// false
47
}
48