Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use strings.Contains & time.Since #89

Open
wants to merge 1 commit into
base: v1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (c *C) StartTimer() {
// want to measure.
func (c *C) StopTimer() {
if c.timerOn {
c.duration += time.Now().Sub(c.start)
c.duration += time.Since(c.start)
c.timerOn = false
runtime.ReadMemStats(&memStats)
c.netAllocs += memStats.Mallocs - c.startAllocs
Expand Down
4 changes: 2 additions & 2 deletions bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (s *BootstrapS) TestLogfAndGetTestLog(c *check.C) {
func (s *BootstrapS) TestRunShowsErrors(c *check.C) {
output := String{}
check.Run(&FailHelper{}, &check.RunConf{Output: &output})
if strings.Index(output.value, "Expected failure!") == -1 {
if !strings.Contains(output.value, "Expected failure!") {
critical(fmt.Sprintf("RunWithWriter() output did not contain the "+
"expected failure! Got: %#v",
output.value))
Expand All @@ -74,7 +74,7 @@ func (s *BootstrapS) TestRunShowsErrors(c *check.C) {
func (s *BootstrapS) TestRunDoesntShowSuccesses(c *check.C) {
output := String{}
check.Run(&SuccessHelper{}, &check.RunConf{Output: &output})
if strings.Index(output.value, "Expected success!") != -1 {
if strings.Contains(output.value, "Expected success!") {
critical(fmt.Sprintf("RunWithWriter() output contained a successful "+
"test! Got: %#v",
output.value))
Expand Down
2 changes: 1 addition & 1 deletion foundation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (s *FoundationS) TestFailureHeader(c *check.C) {
"-----------------------------------\n"+
"FAIL: check_test.go:%d: FailHelper.TestLogAndFail\n",
failHelper.testLine)
if strings.Index(output.value, header) == -1 {
if !strings.Contains(output.value, header) {
c.Errorf(""+
"Failure didn't print a proper header.\n"+
"... Got:\n%s... Expected something with:\n%s",
Expand Down
2 changes: 1 addition & 1 deletion helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (c *C) Logf(format string, args ...interface{}) {
// Output enables *C to be used as a logger in functions that require only
// the minimum interface of *log.Logger.
func (c *C) Output(calldepth int, s string) error {
d := time.Now().Sub(c.startTime)
d := time.Since(c.startTime)
msec := d / time.Millisecond
sec := d / time.Second
min := d / time.Minute
Expand Down