GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — horsepaste/game_test.go at master · jbowens/horsepaste

Expand file tree

/

game_test.go

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
58 lines (50 loc) · 1.09 KB
/

game_test.go

Copy path

File metadata and controls

58 lines (50 loc) · 1.09 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package horsepaste
import (
"encoding/json"
"testing"
"github.com/jbowens/dictionary"
)
var testWords []string
func init() {
d, err := dictionary.Load("assets/original.txt")
if err != nil {
panic(err)
}
testWords = d.Words()
}
func BenchmarkGameMarshal(b *testing.B) {
b.StopTimer()
d, err := dictionary.Load("assets/original.txt")
if err != nil {
b.Fatal(err)
}
g := newGame("foo", GameState{
Seed: 1,
Round: 0,
Revealed: make([]bool, 25),
WordSet: d.Words(),
}, GameOptions{})
b.StartTimer()
for i := 0; i < b.N; i++ {
_, err = json.Marshal(g)
if err != nil {
b.Fatal(err)
}
}
}
func TestGameShuffle(t *testing.T) {
gamesWithoutRepeats := len(testWords)/25 - 1
initialState := randomState(testWords)
currState := initialState
m := map[string]int{}
for i := 0; i < gamesWithoutRepeats; i++ {
g := newGame("foo", currState, GameOptions{})
for _, w := range g.Words {
if prevI, ok := m[w]; ok {
t.Errorf("Word %q appeared twice, once in game %d and once in game %d.", w, prevI, i)
}
m[w] = i
}
currState = nextGameState(currState)
}
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.