-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
do-i-need-a-username
committed
Nov 29, 2023
1 parent
3359cf0
commit cc85bed
Showing
2 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestOutputFlag(t *testing.T) { | ||
// Save the original command-line arguments and restore them at the end of the test. | ||
origArgs := os.Args | ||
defer func() { os.Args = origArgs }() | ||
|
||
// Set the command-line arguments for this test. | ||
os.Args = []string{"cmd", "-output", "test_output"} | ||
|
||
// Parse the flags. | ||
flag.Parse() | ||
|
||
// Check that the output flag was correctly parsed. | ||
if *output != "test_output" { | ||
t.Errorf("Expected output flag to be 'test_output', but got '%s'", *output) | ||
} | ||
} |