Commits

Shlomi Fish committed 66cd5d1

Add a test suite.

Fixed a bug in the output where there was a whitespace between the
solutions.

Comments (0)

Files changed (4)

kakurasu-solver/Makefile

+all:
+
+test:
+	runprove t/*.t

kakurasu-solver/kakurasu-solver.py

 
     for y in range(0,height):
         for x in range(0,width):
-            print ('█' if (sol[y*height+x] != 0) else '⨯'),
-        print
+            sys.stdout.write ('█' if (sol[y*height+x] != 0) else '⨯')
+        sys.stdout.write("\n")
 
     return 0
 

kakurasu-solver/t/data/expected/brainbashers-4x4-medium-2010-09-25.kakurasu.expected

+███⨯
+█⨯█⨯
+⨯██⨯
+⨯⨯⨯█

kakurasu-solver/t/kakurasu-system-tests.t

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+use Test::Differences;
+
+use IO::All;
+
+{
+    my $got = `python kakurasu-solver.py layouts/brainbashers-4x4-medium-2010-09-25.kakurasu.board`;
+    my $expected = io->file('t/data/expected/brainbashers-4x4-medium-2010-09-25.kakurasu.expected')->slurp();
+
+    # TEST
+    eq_or_diff( $got, $expected, "4x4-medium-2010-09-25");
+}