File: parser_test.go

package info (click to toggle)
golang-github-integrii-flaggy 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 292 kB
  • sloc: makefile: 3
file content (33 lines) | stat: -rw-r--r-- 723 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package flaggy

import "testing"

func TestDoubleParse(t *testing.T) {
	ResetParser()
	DefaultParser.ShowHelpOnUnexpected = false

	err := DefaultParser.Parse()
	if err != nil {
		t.Fatal(err)
	}
	err = DefaultParser.Parse()
	if err == nil {
		t.Fatal(err)
	}
}

func TestDisableShowVersionFlag(t *testing.T) {
	ResetParser()

	// if this fails the function tested might be useless.
	// Review if it's still useful and adjust.
	if DefaultParser.ShowVersionWithVersionFlag != true {
		t.Fatal("The tested function might not make sense any more.")
	}

	DefaultParser.DisableShowVersionWithVersion()

	if DefaultParser.ShowVersionWithVersionFlag != false {
		t.Fatal("ShowVersionWithVersionFlag should have been false.")
	}
}