|
1 | 1 | package com.us.dsb.explore.algs.ttt.manual |
2 | 2 |
|
3 | 3 | import cats.syntax.option._ |
4 | | - |
| 4 | +import org.scalatest.{PrivateMethodTester, color} |
5 | 5 | import org.scalatest.funspec.AnyFunSpec |
6 | 6 | import org.scalatest.matchers.should.Matchers._ |
7 | 7 |
|
@@ -229,16 +229,32 @@ class BoardTest extends AnyFunSpec { |
229 | 229 | } |
230 | 230 |
|
231 | 231 | ignore("possibly check all lines (algorithmically)") { |
232 | | - |
233 | 232 | } |
234 | 233 |
|
235 | 234 | } |
236 | 235 |
|
237 | | - describe("Board.vectorIndex:") { |
238 | | - it("how and how hard/disruptive to test private method?") { |
239 | | - cancel() |
| 236 | + describe("Board.vectorIndex (private method we want to test directly):") { |
| 237 | + import PrivateMethodTester._ |
| 238 | + val vectorIndex = PrivateMethod[Int](Symbol("vectorIndex")) |
| 239 | + |
| 240 | + it("should compute 0 for first row, first column") { |
| 241 | + val index = Board.initial invokePrivate vectorIndex(Index(1), columnIndices.head) |
| 242 | + index shouldEqual 0 |
| 243 | + } |
| 244 | + |
| 245 | + it("should compute array length - 1 for last row, last column") { |
| 246 | + val index = Board.initial invokePrivate vectorIndex(rowIndices.last, Index(3)) |
| 247 | + index shouldEqual Order * Order - 1 |
240 | 248 | } |
241 | | - } |
242 | 249 |
|
| 250 | + describe("should compute indices in row-major order (chosen but ~isolated)") { |
| 251 | + it("1, 2 => 1") { |
| 252 | + Board.initial invokePrivate vectorIndex(Index(1), Index(2)) shouldEqual 1 |
| 253 | + } |
| 254 | + it("2, 1 => 3 (Order/row length/# columns)") { |
| 255 | + Board.initial invokePrivate vectorIndex(Index(2), Index(1)) shouldEqual Order |
| 256 | + } |
| 257 | + } |
| 258 | + } |
243 | 259 |
|
244 | 260 | } |
0 commit comments