mirror of
https://github.com/jstemmer/go-junit-report.git
synced 2025-07-06 14:02:52 -05:00
Addressing code review comments.
Mainly: * Moving the averaging/merging of benchmarks from the parser to the formatter package * Tightening up the regex so it only captures the numeric values (no more of trimming spaces and the ns/op) * Deleting the writing up in xml file the benchmark memory sections of B/op and Allocs/op Also added a test case for parseNanoseconds().
This commit is contained in:
@ -24,3 +24,24 @@ func TestParseSeconds(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseNanoseconds(t *testing.T) {
|
||||
tests := []struct {
|
||||
in string
|
||||
d time.Duration
|
||||
}{
|
||||
{"", 0},
|
||||
{"0.1", 0 * time.Nanosecond},
|
||||
{"0.9", 0 * time.Nanosecond},
|
||||
{"4", 4 * time.Nanosecond},
|
||||
{"5000", 5 * time.Microsecond},
|
||||
{"2000003", 2*time.Millisecond + 3*time.Nanosecond},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
d := parseNanoseconds(test.in)
|
||||
if d != test.d {
|
||||
t.Errorf("parseSeconds(%q) == %v, want %v\n", test.in, d, test.d)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user