manperf_test.go
von paedubucher- SNIPPET_DESC:
- Tests für manperf.go
- SNIPPET_CREATION_TIME:
- 19.06.2022 17:21:12
- SNIPPET_PRUNE_TIME:
- Unendlich
- SNIPPET_TEXT:
-
- package dfdegoregexp
- import (
- "testing"
- )
- var expectedSections = []string{"NAME", "SYNOPSIS", "DESCRIPTION", "EXAMPLES",
- "OVERVIEW", "DEFAULTS", "OPTIONS", "EXIT STATUS", "ENVIRONMENT", "FILES",
- "SEE ALSO", "HISTORY"}
- func TestExtractSectionsBad(t *testing.T) {
- lines := CommandOutput("man", "man")
- actual := ExtractSectionsBad(lines)
- for i, e := range expectedSections {
- if actual[i] != e {
- t.Errorf("expected actual[%d]==%s, was %s", i, e, actual[i])
- }
- }
- }
- func TestExtractSectionsBetter(t *testing.T) {
- lines := CommandOutput("man", "man")
- actual := ExtractSectionsBetter(lines)
- for i, e := range expectedSections {
- if actual[i] != e {
- t.Errorf("expected actual[%d]==%s, was %s", i, e, actual[i])
- }
- }
- }
- func BenchmarkExtractSectionsBad(b *testing.B) {
- b.StopTimer()
- lines := CommandOutput("man", "man")
- b.StartTimer()
- for i := 0; i < b.N; i++ {
- ExtractSectionsBad(lines)
- }
- }
- func BenchmarkExtractSectionsBetter(b *testing.B) {
- b.StopTimer()
- lines := CommandOutput("man", "man")
- b.StartTimer()
- for i := 0; i < b.N; i++ {
- ExtractSectionsBetter(lines)
- }
- }
Quellcode
Hier kannst du den Code kopieren und ihn in deinen bevorzugten Editor einfügen. PASTEBIN_DOWNLOAD_SNIPPET_EXPLAIN