diff --git a/state/cursor_test.go b/state/cursor_test.go index a73731d..f373196 100644 --- a/state/cursor_test.go +++ b/state/cursor_test.go @@ -82,12 +82,12 @@ func TestCursor(t *testing.T) { }) Convey("You can't move up beyond the top", func() { - s.CursorCellUp() + s.CursorSectionUp() So(*s.cursor, ShouldResemble, Point{0, 0}) }) Convey("You can't move left beyond the edge", func() { - s.CursorCellLeft() + s.CursorSectionLeft() So(*s.cursor, ShouldResemble, Point{0, 0}) }) diff --git a/state/field_test.go b/state/field_test.go index 9c9ade9..7129b7b 100644 --- a/state/field_test.go +++ b/state/field_test.go @@ -23,6 +23,10 @@ func TestField(t *testing.T) { 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() { So(f.String(), ShouldEqual, "\x00\x00\x00\x00") }) diff --git a/state/history.go b/state/history.go index f96bab9..57fdde9 100644 --- a/state/history.go +++ b/state/history.go @@ -127,13 +127,7 @@ func (s *State) historyPoint(index int) (Point, int) { break } - pX, err := strconv.Atoi(x) - if err != nil { - panic(err) - } - pY, err := strconv.Atoi(y) - if err != nil { - panic(err) - } + pX, _ := strconv.Atoi(x) + pY, _ := strconv.Atoi(y) return Point{pX, pY}, index } diff --git a/state/state.go b/state/state.go index ae491b3..dbf91b3 100644 --- a/state/state.go +++ b/state/state.go @@ -114,9 +114,6 @@ func (s *State) Clear() { s.clear(*s.cursor, true) } -func (s *State) view(cursor []int) { -} - func (s *State) initSection(p Point) { s.history += fmt.Sprintf("i%s", p) 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. func (s *State) updateHeaders(p Point) { var rowHeader, colHeader header diff --git a/state/state_test.go b/state/state_test.go index 47cade6..a8a34d3 100644 --- a/state/state_test.go +++ b/state/state_test.go @@ -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() { s.cells.vivify(Point{0, 0}) s.cells.vivify(Point{2, 0})