403Webshell
Server IP : 157.230.181.24  /  Your IP : 216.73.217.11
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux conductive 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64
User :  ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/go/src/cmd/go/testdata/script/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/go/src/cmd/go/testdata/script/testing_coverage.txt
# Rudimentary test of testing.Coverage().

[short] skip
[!GOEXPERIMENT:coverageredesign] skip

# Simple test.
go test -v -cover -count=1

# Make sure test still passes when test executable is built and
# run outside the go command.
go test -c -o t.exe -cover
exec ./t.exe

-- go.mod --
module hello

go 1.20
-- hello.go --
package hello

func Hello() {
	println("hello")
}

// contents not especially interesting, just need some code
func foo(n int) int {
	t := 0
	for i := 0; i < n; i++ {
		for j := 0; j < i; j++ {
			t += i ^ j
			if t == 1010101 {
				break
			}
		}
	}
	return t
}

-- hello_test.go --
package hello

import "testing"

func TestTestCoverage(t *testing.T) {
	Hello()
	C1 := testing.Coverage()
	foo(29)
	C2 := testing.Coverage()
	if C1 == 0.0 || C2 == 0.0 {
		t.Errorf("unexpected zero values C1=%f C2=%f", C1, C2)
	}
	if C1 >= C2 {
		t.Errorf("testing.Coverage() not monotonically increasing C1=%f C2=%f", C1, C2)
	}
}


Youez - 2016 - github.com/yon3zu
LinuXploit