2
* This file is part of the dis-Emi-A HaXe Library. Copyright © edA-qa mort-ora-y
3
* For full copyright and license information please refer to doc/license.txt.
11
class BoardTest extends haxe.unit.TestCaseX
13
static var sampleBoard = [
14
[1,2,3, 4,5,6, 7,8,9],
15
[4,5,6, 7,8,9, 1,2,3],
16
[7,8,9, 1,2,3, 4,5,6],
18
[2,3,1, 5,6,4, 8,9,7],
19
[5,6,4, 8,9,7, 2,3,1],
20
[8,9,7, 2,3,1, 5,6,4],
22
[3,1,2, 6,4,5, 9,7,8],
23
[6,4,5, 9,7,8, 3,1,2],
27
public function testValid()
29
var m = mathx.Matrix.fromArrayMat(sampleBoard);
30
var s = new Board( m );
31
assertTrue( s.isValid() );
32
assertTrue( s.isComplete() );
34
//check that simple validity checks are working
36
assertFalse( s.isValid() );
38
s.set( 3, 7, sudoku.GConst.cellUnset );
39
assertTrue( s.isValid() );
40
assertFalse( s.isComplete() );
42
//check the the grouping check is working
45
assertFalse( s.isValid() );
48
public function testCreate()
50
//track steps to solution
51
var solveCounts = new Array<Int>();
56
for( i in 0...10 ) //do a few to be sure
58
var c = s.fillRandom();
60
assertTrue( s.isValid() );
61
assertTrue( s.isComplete() );
64
//trace( solveCounts );
67
public function testSolve()
70
for( i in 1...(GConst.boardSize-2) )
74
assertFalse( s.isComplete() );
75
assertFalse( s.findSolution() == -1 );
76
assertTrue( s.isValid() );