Skip to content

Commit

Permalink
Prepare the ground (#21)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Ayers <[email protected]>
  • Loading branch information
philoserf and Mark Ayers authored Nov 16, 2023
1 parent c46d6ef commit 6d3cb05
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Created by https://www.toptal.com/developers/gitignore/api/go
# Edit at https://www.toptal.com/developers/gitignore?templates=go

### Go ###
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work

# End of https://www.toptal.com/developers/gitignore/api/go
coverage.html
1 change: 1 addition & 0 deletions aria/aria.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package aria
3 changes: 3 additions & 0 deletions aria/aria_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package aria_test

func EmptyTest() {}
3 changes: 3 additions & 0 deletions aria/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/philoserf/go/aria

go 1.21
19 changes: 19 additions & 0 deletions aria/taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# https://taskfile.dev
version: '3'
tasks:
default:
vars:
COVER_NAME: coverage
COVER_FILE: "{{.COVER_NAME}}.out"
COVER_HTML: "{{.COVER_NAME}}.html"
cmds:
- go vet ./...
- go fmt ./...
- go test -v -race -coverprofile={{.COVER_FILE}} --covermode=atomic ./...
- go tool cover -html={{.COVER_FILE}} -o {{.COVER_HTML}}
next:
cmds:
- go get -u ./...
- go mod tidy
- gofumpt -e -l -w -extra .
- golangci-lint run --fix .
45 changes: 45 additions & 0 deletions dice/dice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func TestD(t *testing.T) {
upper int
lower int
}{
{"D2 is between 1 and 2", 2, 1},
{"D6 is between 1 and 6", 6, 1},
{"D10 is between 1 and 10", 10, 1},
{"D100 is between 1 and 100", 100, 1},
Expand All @@ -31,3 +32,47 @@ func TestD(t *testing.T) {
})
}
}

func TestD2(t *testing.T) {
t.Parallel()

for range [1000]int{} {
got := dice.D2()
if !(got <= 2) || !(got >= 1) {
t.Errorf("D2() got %v, want a number between 1 and 2", got)
}
}
}

func TestD6(t *testing.T) {
t.Parallel()

for range [1000]int{} {
got := dice.D6()
if !(got <= 6) || !(got >= 1) {
t.Errorf("D6() got %v, want a number between 1 and 6", got)
}
}
}

func TestD10(t *testing.T) {
t.Parallel()

for range [1000]int{} {
got := dice.D10()
if !(got <= 10) || !(got >= 1) {
t.Errorf("D10() got %v, want a number between 1 and 10", got)
}
}
}

func TestD100(t *testing.T) {
t.Parallel()

for range [1000]int{} {
got := dice.D100()
if !(got <= 100) || !(got >= 1) {
t.Errorf("D100() got %v, want a number between 1 and 100", got)
}
}
}
19 changes: 19 additions & 0 deletions dice/taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# https://taskfile.dev
version: '3'
tasks:
default:
vars:
COVER_NAME: coverage
COVER_FILE: "{{.COVER_NAME}}.out"
COVER_HTML: "{{.COVER_NAME}}.html"
cmds:
- go vet ./...
- go fmt ./...
- go test -v -race -coverprofile={{.COVER_FILE}} --covermode=atomic ./...
- go tool cover -html={{.COVER_FILE}} -o {{.COVER_HTML}}
next:
cmds:
- go get -u ./...
- go mod tidy
- gofumpt -e -l -w -extra .
- golangci-lint run --fix .
3 changes: 3 additions & 0 deletions traveller/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/philoserf/go/traveller

go 1.21
19 changes: 19 additions & 0 deletions traveller/taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# https://taskfile.dev
version: '3'
tasks:
default:
vars:
COVER_NAME: coverage
COVER_FILE: "{{.COVER_NAME}}.out"
COVER_HTML: "{{.COVER_NAME}}.html"
cmds:
- go vet ./...
- go fmt ./...
- go test -v -race -coverprofile={{.COVER_FILE}} --covermode=atomic ./...
- go tool cover -html={{.COVER_FILE}} -o {{.COVER_HTML}}
next:
cmds:
- go get -u ./...
- go mod tidy
- gofumpt -e -l -w -extra .
- golangci-lint run --fix .
1 change: 1 addition & 0 deletions traveller/traveller.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package traveller
3 changes: 3 additions & 0 deletions traveller/traveller_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package traveller_test

func EmptyTest() {}

0 comments on commit 6d3cb05

Please sign in to comment.