Warning, /games/kolorfill/autotests/tst_fill.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * Copyright (c) 2018 Sune Vuorela <sune@vuorela.dk>
0003  *
0004  * Permission is hereby granted, free of charge, to any person
0005  * obtaining a copy of this software and associated documentation
0006  * files (the "Software"), to deal in the Software without
0007  * restriction, including without limitation the rights to use,
0008  * copy, modify, merge, publish, distribute, sublicense, and/or sell
0009  * copies of the Software, and to permit persons to whom the
0010  * Software is furnished to do so, subject to the following
0011  * conditions:
0012  *
0013  * The above copyright notice and this permission notice shall be
0014  * included in all copies or substantial portions of the Software.
0015  *
0016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0017  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
0018  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0019  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
0020  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
0021  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
0022  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0023  * OTHER DEALINGS IN THE SOFTWARE.
0024  */
0025 
0026 import QtTest 1.0
0027 import "../src/qml/KolorFillUtils.js" as Utils
0028 
0029 TestCase {
0030     name: "fill"
0031     function test_fill_small_board() {
0032         var board = Utils.createBoard(1, ["black"]);
0033         var changed = Utils.fill("blue",board);
0034         compare(changed, true, "board changed");
0035         compare(board.length, 1, "wrong one dimension");
0036         compare(board[0].length, 1, "wrong other dimension");
0037         compare(board[0][0], "blue", "wrong content");
0038     }
0039 
0040     function test_fill_small_board_unchanged() {
0041         var board = Utils.createBoard(1, ["black"]);
0042         var changed = Utils.fill("black",board);
0043         compare(changed, false, "board changed");
0044         compare(board.length, 1, "wrong one dimension");
0045         compare(board[0].length, 1, "wrong other dimension");
0046         compare(board[0][0], "black", "wrong content");
0047     }
0048 
0049     function test_fill_u_shape() {
0050         var board = Utils.createBoard(3, ["black"]);
0051         board[1][0] = "blue";
0052         board[2][0] = "blue";
0053         var changed = Utils.fill("blue",board)
0054         compare(changed, true, "board changed");
0055         var win = Utils.checkWin(board);
0056         compare(win, true, "board we are supposed to have a board here");
0057 
0058     }
0059 
0060 }
0061