Coverage 100%

This commit is contained in:
Madison Rye Progress
2026-03-18 14:33:57 -07:00
parent 3f1053ea61
commit bbc87afee1
5 changed files with 15 additions and 20 deletions

View File

@ -82,12 +82,12 @@ func TestCursor(t *testing.T) {
}) })
Convey("You can't move up beyond the top", func() { Convey("You can't move up beyond the top", func() {
s.CursorCellUp() s.CursorSectionUp()
So(*s.cursor, ShouldResemble, Point{0, 0}) So(*s.cursor, ShouldResemble, Point{0, 0})
}) })
Convey("You can't move left beyond the edge", func() { Convey("You can't move left beyond the edge", func() {
s.CursorCellLeft() s.CursorSectionLeft()
So(*s.cursor, ShouldResemble, Point{0, 0}) So(*s.cursor, ShouldResemble, Point{0, 0})
}) })

View File

@ -23,6 +23,10 @@ func TestField(t *testing.T) {
So(f.i(Point{1, 1}), ShouldEqual, 3) So(f.i(Point{1, 1}), ShouldEqual, 3)
}) })
Convey("You can get the byte for a particular cell", func() {
So(f.cell(Point{0, 0}), ShouldEqual, cell(0))
})
Convey("You can get a string representation of the field", func() { Convey("You can get a string representation of the field", func() {
So(f.String(), ShouldEqual, "\x00\x00\x00\x00") So(f.String(), ShouldEqual, "\x00\x00\x00\x00")
}) })

View File

@ -127,13 +127,7 @@ func (s *State) historyPoint(index int) (Point, int) {
break break
} }
pX, err := strconv.Atoi(x) pX, _ := strconv.Atoi(x)
if err != nil { pY, _ := strconv.Atoi(y)
panic(err)
}
pY, err := strconv.Atoi(y)
if err != nil {
panic(err)
}
return Point{pX, pY}, index return Point{pX, pY}, index
} }

View File

@ -114,9 +114,6 @@ func (s *State) Clear() {
s.clear(*s.cursor, true) s.clear(*s.cursor, true)
} }
func (s *State) view(cursor []int) {
}
func (s *State) initSection(p Point) { func (s *State) initSection(p Point) {
s.history += fmt.Sprintf("i%s", p) s.history += fmt.Sprintf("i%s", p)
s.sections.clear(p, false) s.sections.clear(p, false)
@ -213,13 +210,6 @@ func (s *State) scoreValidCompletedSections() {
} }
} }
// updateAllHeaders runs updateHeaders for every row/column.
func (s *State) updateAllHeaders() {
for i := 0; i < s.size(); i++ {
s.updateHeaders(Point{i, i})
}
}
// updateHeaders makes sure that the counts of alive cells in rows/columns are accurate, and whether or not the row/column is complete. // updateHeaders makes sure that the counts of alive cells in rows/columns are accurate, and whether or not the row/column is complete.
func (s *State) updateHeaders(p Point) { func (s *State) updateHeaders(p Point) {
var rowHeader, colHeader header var rowHeader, colHeader header

View File

@ -48,6 +48,13 @@ func TestState(t *testing.T) {
}) })
}) })
Convey("You can get the score", func() {
score := s.Score()
So(score.Clears, ShouldEqual, 0)
So(score.Score, ShouldEqual, 0)
So(score.Blackout, ShouldResemble, []bool{false, false, false, false})
})
Convey("You can complete sections and clear portions of the board", func() { Convey("You can complete sections and clear portions of the board", func() {
s.cells.vivify(Point{0, 0}) s.cells.vivify(Point{0, 0})
s.cells.vivify(Point{2, 0}) s.cells.vivify(Point{2, 0})