From a647827eb79ca5d13571f7ae9e7fb54c3449619d Mon Sep 17 00:00:00 2001 From: Mark Ayers Date: Thu, 16 Nov 2023 13:37:37 -0500 Subject: [PATCH] Prepare the ground --- .gitignore | 28 +++++++++++++++++++++++ aria/aria.go | 1 + aria/aria_test.go | 3 +++ aria/go.mod | 3 +++ aria/taskfile.yaml | 19 ++++++++++++++++ dice/dice_test.go | 45 +++++++++++++++++++++++++++++++++++++ dice/taskfile.yaml | 19 ++++++++++++++++ traveller/go.mod | 3 +++ traveller/taskfile.yaml | 19 ++++++++++++++++ traveller/traveller.go | 1 + traveller/traveller_test.go | 3 +++ 11 files changed, 144 insertions(+) create mode 100644 .gitignore create mode 100644 aria/aria.go create mode 100644 aria/aria_test.go create mode 100644 aria/go.mod create mode 100644 aria/taskfile.yaml create mode 100644 dice/taskfile.yaml create mode 100644 traveller/go.mod create mode 100644 traveller/taskfile.yaml create mode 100644 traveller/traveller.go create mode 100644 traveller/traveller_test.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd545ca --- /dev/null +++ b/.gitignore @@ -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 diff --git a/aria/aria.go b/aria/aria.go new file mode 100644 index 0000000..785db0f --- /dev/null +++ b/aria/aria.go @@ -0,0 +1 @@ +package aria diff --git a/aria/aria_test.go b/aria/aria_test.go new file mode 100644 index 0000000..cd1b170 --- /dev/null +++ b/aria/aria_test.go @@ -0,0 +1,3 @@ +package aria_test + +func EmptyTest() {} diff --git a/aria/go.mod b/aria/go.mod new file mode 100644 index 0000000..7dd0ea1 --- /dev/null +++ b/aria/go.mod @@ -0,0 +1,3 @@ +module github.com/philoserf/go/aria + +go 1.21 diff --git a/aria/taskfile.yaml b/aria/taskfile.yaml new file mode 100644 index 0000000..e1de552 --- /dev/null +++ b/aria/taskfile.yaml @@ -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 . diff --git a/dice/dice_test.go b/dice/dice_test.go index 5433a5e..7d5347f 100644 --- a/dice/dice_test.go +++ b/dice/dice_test.go @@ -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}, @@ -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) + } + } +} diff --git a/dice/taskfile.yaml b/dice/taskfile.yaml new file mode 100644 index 0000000..e1de552 --- /dev/null +++ b/dice/taskfile.yaml @@ -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 . diff --git a/traveller/go.mod b/traveller/go.mod new file mode 100644 index 0000000..5338b72 --- /dev/null +++ b/traveller/go.mod @@ -0,0 +1,3 @@ +module github.com/philoserf/go/traveller + +go 1.21 diff --git a/traveller/taskfile.yaml b/traveller/taskfile.yaml new file mode 100644 index 0000000..e1de552 --- /dev/null +++ b/traveller/taskfile.yaml @@ -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 . diff --git a/traveller/traveller.go b/traveller/traveller.go new file mode 100644 index 0000000..75b12e8 --- /dev/null +++ b/traveller/traveller.go @@ -0,0 +1 @@ +package traveller diff --git a/traveller/traveller_test.go b/traveller/traveller_test.go new file mode 100644 index 0000000..4cddff7 --- /dev/null +++ b/traveller/traveller_test.go @@ -0,0 +1,3 @@ +package traveller_test + +func EmptyTest() {}