-
-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial test for main function in dalfox_test.go
Signed-off-by: HAHWUL <[email protected]>
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
Code by @hahwul | ||
Happy hacking :D | ||
*/ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func Test_main(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
}{ | ||
{name: "Test case 1"}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
// Redirect stdout to capture output | ||
old := os.Stdout | ||
r, w, _ := os.Pipe() | ||
os.Stdout = w | ||
|
||
// Call the main function | ||
main() | ||
|
||
// Capture the output | ||
w.Close() | ||
var buf bytes.Buffer | ||
buf.ReadFrom(r) | ||
os.Stdout = old | ||
|
||
// Check the output | ||
got := buf.String() | ||
if len(got) > 0 { | ||
t.Errorf("main() = %v, want %v", got, nil) | ||
} | ||
}) | ||
} | ||
} |