Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Golang
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Muhammad, Hammad
Golang
Commits
cd69af19
You need to sign in or sign up before continuing.
Commit
cd69af19
authored
2 years ago
by
Muhammad, Hammad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added unit_test cases
parent
a853f759
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
dect_test.go
dect_test.go
+39
-0
go.mod
go.mod
+3
-0
No files found.
dect_test.go
0 → 100644
View file @
cd69af19
package
main
import
(
"os"
"testing"
)
func
TestNewDeck
(
t
*
testing
.
T
)
{
d
:=
newDeck
()
if
len
(
d
)
!=
16
{
t
.
Errorf
(
"Expected deck length of 16, but got %v"
,
len
(
d
))
}
if
d
[
0
]
!=
"Ace of Spades"
{
t
.
Errorf
(
"Expected first card of Ace of Spades, but got %v"
,
d
[
0
])
}
if
d
[
len
(
d
)
-
1
]
!=
"Four of Clubs"
{
t
.
Errorf
(
"Expected last card of Four of Clubs, but got %v"
,
d
[
len
(
d
)
-
1
])
}
}
func
TestSaveToDeckAndNewDeckFromFile
(
t
*
testing
.
T
)
{
os
.
Remove
(
"_decktesting"
)
deck
:=
newDeck
()
deck
.
saveToFile
(
"_decktesting"
)
loadedDeck
:=
newDeckFromFile
(
"_decktesting"
)
if
len
(
loadedDeck
)
!=
16
{
t
.
Errorf
(
"Expected 16 cards in deck, got %v"
,
len
(
loadedDeck
))
}
os
.
Remove
(
"_decktesting"
)
}
// Execute test file by this command : go test
This diff is collapsed.
Click to expand it.
go.mod
0 → 100644
View file @
cd69af19
module hello_world
go 1.20
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment