-
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.
Create test file and write test fucn and shuffling random func
- Loading branch information
1 parent
4933dc0
commit 55bd1a4
Showing
5 changed files
with
128 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,66 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestDeckFileNewDeckFunction(t *testing.T) { | ||
|
||
d := NewDeckFunc() | ||
|
||
if len(d) != 4 { | ||
t.Errorf("Expected length 4, but got %d", len(d)) | ||
} | ||
|
||
if d[0] != "Pankaj of Jaipur" { | ||
t.Errorf("Expected d[0] value is Pankaj , But got %s ", d[0]) | ||
} | ||
} | ||
|
||
func TestNewDecFileCreateChec(t *testing.T) { | ||
os.Remove("_DeckFile") | ||
|
||
deck := NewDeckFunc() | ||
deck.SavedFile("_DeckFile") | ||
loadDeckFile := ReadStringFile("_DeckFile") | ||
|
||
if len(loadDeckFile) != 13 { | ||
t.Errorf("Expectd File Length 13 but Expected %v", len(loadDeckFile)) | ||
} | ||
|
||
os.Remove("_DeckFile") | ||
|
||
} | ||
|
||
// check even and odd nuber | ||
func TestCheckEvenOrOddNumber(t *testing.T) { | ||
tests := []struct { | ||
input ResultNuber | ||
output []string | ||
}{ | ||
{ | ||
input: ResultNuber{2, 7, 4, 9, 6}, | ||
output: []string{"2 is even", "7 is odd", "4 is even", "9 is odd", "6 is even"}, | ||
}, | ||
// Add more test cases as needed | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(fmt.Sprintf("Input: %v", test.input), func(t *testing.T) { | ||
result := test.input.checkEvenOrOddNuber() | ||
|
||
if len(result) != len(test.output) { | ||
t.Errorf("Expected %d messages, but got %d", len(test.output), len(result)) | ||
return | ||
} | ||
|
||
for i, expectedMessage := range test.output { | ||
if result[i] != expectedMessage { | ||
t.Errorf("Expected: %s, Got: %s", expectedMessage, result[i]) | ||
} | ||
} | ||
}) | ||
} | ||
} |
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,3 @@ | ||
module cards | ||
|
||
go 1.21.6 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
Pankaj of Jaipur,Pankaj of Bundi,Pankaj of New Delhi,Pankaj of Roorkee,suri of Jaipur,suri of Bundi,suri of New Delhi,suri of Roorkee,Arjun of Jaipur,Arjun of Bundi,Arjun of New Delhi,Arjun of Roorkee,Meena of Jaipur,Meena of Bundi,Meena of New Delhi,Meena of Roorkee | ||
Pankaj of Jaipur,Pankaj of Bundi,suri of Jaipur,suri of Bundi |