quoridor/src/test/java/cz/xelfi/quoridor/BoardCase.java
author Jaroslav Tulach <jtulach@netbeans.org>
Wed, 29 Jul 2009 21:35:04 +0200
changeset 40 e45bc8ad2eaf
parent 31 8e6a6857c7b5
child 75 6802034b7a6f
permissions -rw-r--r--
Rotating the display of the board - north is on top. Enhancing the display with row ids and column numbers and compass directions.
jtulach@8
     1
/*
jtulach@8
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
jtulach@8
     3
 *
jtulach@8
     4
 * The contents of this file are subject to the terms of either the GNU
jtulach@8
     5
 * General Public License Version 2 only ("GPL") or the Common
jtulach@8
     6
 * Development and Distribution License("CDDL") (collectively, the
jtulach@8
     7
 * "License"). You may not use this file except in compliance with the
jtulach@8
     8
 * License. You can obtain a copy of the License at
jtulach@8
     9
 * http://www.netbeans.org/cddl-gplv2.html
jtulach@8
    10
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
jtulach@8
    11
 * specific language governing permissions and limitations under the
jtulach@8
    12
 * License.  When distributing the software, include this License Header
jtulach@8
    13
 * Notice in each file and include the License file at
jtulach@8
    14
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
jtulach@8
    15
 * particular file as subject to the "Classpath" exception as provided
jtulach@8
    16
 * by Sun in the GPL Version 2 section of the License file that
jtulach@8
    17
 * accompanied this code. If applicable, add the following below the
jtulach@8
    18
 * License Header, with the fields enclosed by brackets [] replaced by
jtulach@8
    19
 * your own identifying information:
jtulach@8
    20
 * "Portions Copyrighted [year] [name of copyright owner]"
jtulach@8
    21
 *
jtulach@8
    22
 * Contributor(s):
jtulach@8
    23
 *
jtulach@8
    24
 * Portions Copyrighted 2009 Jaroslav Tulach
jtulach@8
    25
 */
jtulach@0
    26
package cz.xelfi.quoridor;
jtulach@0
    27
jtulach@23
    28
import cz.xelfi.quoridor.Fence.Orientation;
jtulach@30
    29
import cz.xelfi.quoridor.Player.Direction;
jtulach@5
    30
import java.util.List;
jtulach@6
    31
import junit.framework.TestCase;
jtulach@0
    32
jtulach@6
    33
/**
jtulach@0
    34
 *
jtulach@6
    35
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jtulach@0
    36
 */
jtulach@6
    37
public abstract class BoardCase extends TestCase {
jtulach@6
    38
    protected Board board;
jtulach@6
    39
jtulach@6
    40
    protected BoardCase(String n) {
jtulach@6
    41
        super(n);
jtulach@16
    42
        board = Board.empty();
jtulach@0
    43
    }
jtulach@0
    44
jtulach@15
    45
    protected abstract Board move(Board b, int player, Player.Direction... where)
jtulach@6
    46
    throws IllegalPositionException;
jtulach@6
    47
jtulach@15
    48
    protected abstract Board fence(Board b, int player, char x, int y, Fence.Orientation orie)
jtulach@6
    49
    throws IllegalPositionException;
jtulach@6
    50
jtulach@13
    51
    protected abstract Board apply(Board b, Move move) throws IllegalPositionException;
jtulach@13
    52
jtulach@0
    53
jtulach@0
    54
    public void testTwoPlayers () {
jtulach@15
    55
        List<Player> list = board.getPlayers();
jtulach@0
    56
        assertEquals ("Two", 2, list.size ());
jtulach@0
    57
        assertFalse ("Both are non-null", list.contains (null));
jtulach@0
    58
        try {
jtulach@0
    59
            list.add (null);
jtulach@0
    60
            fail ("Modifications are not allowed");
jtulach@0
    61
        } catch (UnsupportedOperationException ex) {
jtulach@0
    62
            // ok
jtulach@0
    63
        }
jtulach@0
    64
        try {
jtulach@0
    65
            list.remove (0);
jtulach@0
    66
            fail ("Modifications are not allowed");
jtulach@0
    67
        } catch (UnsupportedOperationException ex) {
jtulach@0
    68
            // ok
jtulach@0
    69
        }
jtulach@0
    70
        
jtulach@0
    71
        
jtulach@26
    72
        assertEquals (8, list.get (0).getXInternal());
jtulach@26
    73
        assertEquals (0, list.get (0).getYInternal());
jtulach@0
    74
        assertEquals (10, list.get (0).getFences ());
jtulach@26
    75
        assertEquals (8, list.get (1).getXInternal());
jtulach@26
    76
        assertEquals (16, list.get (1).getYInternal());
jtulach@0
    77
        assertEquals (10, list.get (1).getFences ());
jtulach@0
    78
    }
jtulach@0
    79
    
jtulach@23
    80
    public void testFences () throws IllegalPositionException {
jtulach@0
    81
        assertEquals ("No on board", 0, board.getFences ().size ());
jtulach@0
    82
        try {
jtulach@0
    83
            board.getFences ().add (null);
jtulach@0
    84
            fail ("Should be unmodifiable");
jtulach@0
    85
        } catch (java.lang.UnsupportedOperationException ex) {
jtulach@0
    86
            // ok
jtulach@0
    87
        }
jtulach@23
    88
jtulach@23
    89
        {
jtulach@23
    90
            Board b = board.apply(Move.fence('A', 1, Orientation.HORIZONTAL));
jtulach@23
    91
            assertEquals("One fence placed: ", 1, b.getFences().size());
jtulach@23
    92
            Fence f = b.getFences().iterator().next();
jtulach@23
    93
            assertEquals("Row", 1, f.getRow());
jtulach@23
    94
            assertEquals("Column", 'A', f.getColumn());
jtulach@23
    95
        }
jtulach@23
    96
jtulach@23
    97
        {
jtulach@23
    98
            Board b = board.apply(Move.fence('A', 1, Orientation.VERTICAL));
jtulach@23
    99
            assertEquals("One fence placed: ", 1, b.getFences().size());
jtulach@23
   100
            Fence f = b.getFences().iterator().next();
jtulach@23
   101
            assertEquals("Row", 1, f.getRow());
jtulach@23
   102
            assertEquals("Column", 'A', f.getColumn());
jtulach@23
   103
        }
jtulach@23
   104
jtulach@23
   105
        {
jtulach@23
   106
            Board b = board.apply(Move.fence('H', 8, Orientation.HORIZONTAL));
jtulach@23
   107
            assertEquals("One fence placed: ", 1, b.getFences().size());
jtulach@23
   108
            Fence f = b.getFences().iterator().next();
jtulach@23
   109
            assertEquals("Row", 8, f.getRow());
jtulach@23
   110
            assertEquals("Column", 'H', f.getColumn());
jtulach@23
   111
        }
jtulach@23
   112
jtulach@23
   113
        {
jtulach@23
   114
            Board b = board.apply(Move.fence('H', 8, Orientation.VERTICAL));
jtulach@23
   115
            assertEquals("One fence placed: ", 1, b.getFences().size());
jtulach@23
   116
            Fence f = b.getFences().iterator().next();
jtulach@23
   117
            assertEquals("Row", 8, f.getRow());
jtulach@23
   118
            assertEquals("Column", 'H', f.getColumn());
jtulach@23
   119
        }
jtulach@0
   120
    }
jtulach@0
   121
    
jtulach@0
   122
    public void testFourTimesInAgainstEachOtherResultsInInvalidPosition () throws Exception {
jtulach@0
   123
        Board b = board;
jtulach@0
   124
        
jtulach@0
   125
        for (int i = 0; i < 3; i++) {
jtulach@15
   126
            b = move(b, 0, Player.Direction.NORTH);
jtulach@15
   127
            b = move(b, 1, Player.Direction.SOUTH);
jtulach@0
   128
        }
jtulach@0
   129
        
jtulach@15
   130
        b = move(b, 0, Player.Direction.NORTH);
jtulach@0
   131
        try {
jtulach@15
   132
            b = move(b, 1, Player.Direction.SOUTH);
jtulach@0
   133
            fail ("Now the positions of two players are supposed to be the same, this results in exception");
jtulach@0
   134
        } catch (IllegalPositionException ex) {
jtulach@0
   135
            // ok
jtulach@0
   136
        }
jtulach@0
   137
        
jtulach@0
   138
    }
jtulach@0
   139
jtulach@0
   140
    public void testCrossFences () throws Exception {
jtulach@15
   141
        Board b1 = board.fence (board.getPlayers ().get(0), 'A', 1, Fence.Orientation.HORIZONTAL);
jtulach@0
   142
        
jtulach@0
   143
        try {
jtulach@15
   144
            b1.fence (b1.getPlayers ().get(1), 'A', 1, Fence.Orientation.VERTICAL);
jtulach@0
   145
            fail ("This must fail, as the fences overlap");
jtulach@0
   146
        } catch (IllegalPositionException ex) {
jtulach@0
   147
            // ok
jtulach@0
   148
        }
jtulach@0
   149
    }
jtulach@0
   150
    
jtulach@0
   151
    public void testPawnsCanJumpOverEachOther () throws Exception {
jtulach@0
   152
        Board b = board;
jtulach@0
   153
        
jtulach@0
   154
        for (int i = 0; i < 3; i++) {
jtulach@15
   155
            b = move(b, 0, Player.Direction.NORTH);
jtulach@15
   156
            b = move(b, 1, Player.Direction.SOUTH);
jtulach@0
   157
        }
jtulach@0
   158
        
jtulach@15
   159
        b = move(b, 0, Player.Direction.NORTH);
jtulach@0
   160
        
jtulach@0
   161
        // jump over
jtulach@15
   162
        b = move(b, 1, Player.Direction.SOUTH, Player.Direction.SOUTH);
jtulach@0
   163
    }
jtulach@0
   164
jtulach@0
   165
    public void testCannotJumpOverFence () throws Exception {
jtulach@15
   166
        Board b = fence (board, 0, 'D', 8, Fence.Orientation.HORIZONTAL);
jtulach@21
   167
        assertEquals("One fence is present", 1, b.getFences().size());
jtulach@21
   168
        final Fence f = b.getFences().iterator().next();
jtulach@21
   169
        assertEquals("Row is 8", 8, f.getRow());
jtulach@21
   170
        assertEquals("Column is D", 'D', f.getColumn());
jtulach@0
   171
        try {
jtulach@15
   172
            move(b, 1, Player.Direction.SOUTH);
jtulach@0
   173
            fail ("This shall not be allowed, as there is the fence");
jtulach@0
   174
        } catch (IllegalPositionException ex) {
jtulach@0
   175
            // ok
jtulach@0
   176
        }
jtulach@0
   177
    }
jtulach@0
   178
    
jtulach@0
   179
jtulach@0
   180
    public void testSideJumpsNotAllowedWhenThereIsNoFence () throws Exception {
jtulach@0
   181
        Board b = board;
jtulach@0
   182
        
jtulach@0
   183
        for (int i = 0; i < 3; i++) {
jtulach@15
   184
            b = move(b, 0, Player.Direction.NORTH);
jtulach@15
   185
            b = move(b, 1, Player.Direction.SOUTH);
jtulach@0
   186
        }
jtulach@0
   187
        
jtulach@15
   188
        b = move(b, 0, Player.Direction.NORTH);
jtulach@0
   189
        
jtulach@0
   190
        try {
jtulach@15
   191
            b = move(b, 1, Player.Direction.SOUTH, Player.Direction.WEST);
jtulach@0
   192
            fail ("Cannot just jump aside");
jtulach@0
   193
        } catch (IllegalPositionException ex) {
jtulach@0
   194
            // ok
jtulach@0
   195
        }
jtulach@0
   196
    }
jtulach@0
   197
    
jtulach@0
   198
    public void testSideJumpsAllowedWhenThereAFence () throws Exception {
jtulach@0
   199
        Board b = board;
jtulach@0
   200
        
jtulach@0
   201
        for (int i = 0; i < 3; i++) {
jtulach@15
   202
            b = move(b, 0, Player.Direction.NORTH);
jtulach@15
   203
            b = move(b, 1, Player.Direction.SOUTH);
jtulach@0
   204
        }
jtulach@0
   205
        
jtulach@15
   206
        b = move(b, 0, Player.Direction.NORTH);
jtulach@0
   207
        
jtulach@26
   208
        assertEquals (8, b.getPlayers ().get (0).getXInternal());
jtulach@26
   209
        assertEquals (8, b.getPlayers ().get (0).getYInternal());
jtulach@0
   210
        
jtulach@15
   211
        b = fence(b, 0, 'D', 4, Fence.Orientation.HORIZONTAL);
jtulach@0
   212
        
jtulach@0
   213
        // we can over jump to west
jtulach@15
   214
        move(b, 1, Player.Direction.SOUTH, Player.Direction.WEST);
jtulach@0
   215
        // as well as east
jtulach@15
   216
        move(b, 1, Player.Direction.SOUTH, Player.Direction.EAST);
jtulach@0
   217
    }
jtulach@11
   218
jtulach@11
   219
    public void testPlaceAllFences() throws Exception {
jtulach@11
   220
        doPlaceAllFences(0);
jtulach@11
   221
    }
jtulach@11
   222
    public void testPlaceAllFences2() throws Exception {
jtulach@11
   223
        doPlaceAllFences(1);
jtulach@11
   224
    }
jtulach@11
   225
jtulach@11
   226
    private void doPlaceAllFences(int player) throws Exception {
jtulach@11
   227
        Board b = board;
jtulach@11
   228
jtulach@11
   229
        int cnt = 10;
jtulach@11
   230
        for (int i = 1; i <= 5; i++) {
jtulach@15
   231
            b = fence(b, player, 'A', i, Fence.Orientation.HORIZONTAL);
jtulach@15
   232
            b = fence(b, player, 'D', i, Fence.Orientation.HORIZONTAL);
jtulach@11
   233
            cnt -= 2;
jtulach@11
   234
            assertEquals("Two less" + i, cnt, b.getPlayers().get(player).getFences());
jtulach@11
   235
        }
jtulach@11
   236
jtulach@11
   237
        try {
jtulach@15
   238
            fence(b, player, 'F', 7, Fence.Orientation.VERTICAL);
jtulach@11
   239
            fail("We shall run out of fences");
jtulach@11
   240
        } catch (IllegalPositionException ex) {
jtulach@11
   241
            // OK
jtulach@11
   242
        }
jtulach@11
   243
    }
jtulach@0
   244
    
jtulach@0
   245
    public void testAlwaysHasToHaveAccessToEndLine () throws Exception {
jtulach@0
   246
        Board b = board;
jtulach@0
   247
        
jtulach@15
   248
        b = b.fence (b.getPlayers ().get (0), 'E', 1, Fence.Orientation.HORIZONTAL);
jtulach@15
   249
        b = b.fence (b.getPlayers ().get (0), 'F', 1, Fence.Orientation.VERTICAL);
jtulach@0
   250
jtulach@0
   251
        try {
jtulach@15
   252
            b = b.fence (b.getPlayers ().get (0), 'D', 1, Fence.Orientation.VERTICAL);
jtulach@0
   253
            fail ("This is not allowed as player 0 cannot now reach the final line");
jtulach@0
   254
        } catch (IllegalPositionException ex) {
jtulach@0
   255
            // ok
jtulach@0
   256
        }
jtulach@0
   257
        
jtulach@0
   258
    }
jtulach@0
   259
    
jtulach@0
   260
    public void testEqualsOfPlayers () throws Exception {
jtulach@15
   261
        Player p1 = new Player (1, 1, 10, Player.Direction.EAST);
jtulach@15
   262
        Player p2 = new Player (1, 1, 10, Player.Direction.EAST);
jtulach@15
   263
        Player p3 = new Player (2, 1, 10, Player.Direction.EAST);
jtulach@15
   264
        Player p4 = new Player (1, 1, 10, Player.Direction.WEST);
jtulach@15
   265
        Player p5 = new Player (1, 2, 10, Player.Direction.EAST);
jtulach@15
   266
        Player p6 = new Player (1, 1, 5, Player.Direction.EAST);
jtulach@0
   267
        
jtulach@0
   268
        assertEquals ("p1 == p2", p1, p2);
jtulach@0
   269
        if (p2.equals (p3)) fail ();
jtulach@0
   270
        if (p2.equals (p4)) fail ();
jtulach@0
   271
        if (p2.equals (p5)) fail ();
jtulach@0
   272
        if (p2.equals (p6)) fail ();
jtulach@0
   273
        if (p3.equals (p6)) fail ();
jtulach@0
   274
        if (p4.equals (p3)) fail ();
jtulach@0
   275
        if (p6.equals (p3)) fail ();
jtulach@0
   276
        if (p5.equals (p3)) fail ();
jtulach@0
   277
        if (p5.equals (p3)) fail ();
jtulach@0
   278
        if (p4.equals (p3)) fail ();
jtulach@0
   279
        if (p3.equals (p4)) fail ();
jtulach@0
   280
        if (p3.equals (p5)) fail ();
jtulach@0
   281
        if (p4.equals (p5)) fail ();
jtulach@0
   282
        if (p5.equals (p4)) fail ();
jtulach@0
   283
    }
jtulach@0
   284
    
jtulach@0
   285
    public void testEqualsOfFences () throws Exception {
jtulach@15
   286
        Fence f1 = new Fence (1, 1, Fence.Orientation.HORIZONTAL);
jtulach@15
   287
        Fence f2 = new Fence (1, 1, Fence.Orientation.HORIZONTAL);
jtulach@15
   288
        Fence f3 = new Fence (3, 1, Fence.Orientation.HORIZONTAL);
jtulach@15
   289
        Fence f4 = new Fence (1, 3, Fence.Orientation.HORIZONTAL);
jtulach@15
   290
        Fence f5 = new Fence (1, 1, Fence.Orientation.VERTICAL);
jtulach@0
   291
        
jtulach@0
   292
        assertEquals ("f1 == f2", f1, f2);
jtulach@0
   293
        if (f1.equals (f3)) fail ();
jtulach@0
   294
        if (f3.equals (f1)) fail ();
jtulach@0
   295
        if (f5.equals (f1)) fail ();
jtulach@0
   296
        if (f1.equals (f5)) fail ();
jtulach@0
   297
        if (f4.equals (f1)) fail ();
jtulach@0
   298
        if (f1.equals (f4)) fail ();
jtulach@0
   299
    }
jtulach@0
   300
    
jtulach@0
   301
    public void testEqualsOfBoards1 () throws Exception {
jtulach@15
   302
        Board b1 = board.move (board.getPlayers ().get (0), Player.Direction.NORTH);
jtulach@15
   303
        Board b2 = board.move (board.getPlayers ().get (0), Player.Direction.NORTH);
jtulach@15
   304
        Board b3 = board.move (board.getPlayers ().get (0), Player.Direction.EAST);
jtulach@0
   305
        
jtulach@0
   306
        if (b1.equals (b3)) fail ();
jtulach@0
   307
        if (b3.equals (b1)) fail ();
jtulach@0
   308
        
jtulach@0
   309
        assertEquals ("b1 == b2", b1, b2);
jtulach@0
   310
    }
jtulach@0
   311
    public void testEqualsOfBoards2 () throws Exception {
jtulach@15
   312
        Board b1 = board.fence (board.getPlayers ().get (0), 'E', 3, Fence.Orientation.HORIZONTAL);
jtulach@15
   313
        Board b2 = board.fence (board.getPlayers ().get (0), 'E', 3, Fence.Orientation.HORIZONTAL);
jtulach@15
   314
        Board b3 = board.fence (board.getPlayers ().get (0), 'D', 3, Fence.Orientation.HORIZONTAL);
jtulach@15
   315
        Board b4 = board.fence (board.getPlayers ().get (0), 'E', 4, Fence.Orientation.HORIZONTAL);
jtulach@15
   316
        Board b5 = board.fence (board.getPlayers ().get (0), 'E', 3, Fence.Orientation.VERTICAL);
jtulach@0
   317
        
jtulach@0
   318
        if (b1.equals (b3)) fail ();
jtulach@0
   319
        if (b3.equals (b1)) fail ();
jtulach@0
   320
        if (b1.equals (b4)) fail ();
jtulach@0
   321
        if (b1.equals (b5)) fail ();
jtulach@0
   322
        if (b5.equals (b1)) fail ();
jtulach@0
   323
        if (b4.equals (b1)) fail ();
jtulach@0
   324
        
jtulach@0
   325
        assertEquals ("b1 == b2", b1, b2);
jtulach@0
   326
    }
jtulach@0
   327
    public void testEqualsOfBoardsWhenJumpOver () throws Exception {
jtulach@0
   328
        Board b = board;
jtulach@0
   329
        
jtulach@0
   330
        for (int i = 0; i < 3; i++) {
jtulach@15
   331
            b = move(b, 0, Player.Direction.NORTH);
jtulach@15
   332
            b = move(b, 1, Player.Direction.SOUTH);
jtulach@0
   333
        }
jtulach@0
   334
        
jtulach@15
   335
        Board b1 = move(b, 0, Player.Direction.NORTH);
jtulach@0
   336
        
jtulach@15
   337
        Board b2 = move(b, 1, Player.Direction.SOUTH);
jtulach@15
   338
        b2 = b2.move (b2.getPlayers ().get (0), Player.Direction.NORTH, Player.Direction.NORTH);
jtulach@0
   339
        
jtulach@0
   340
        if (b1.equals (b2)) fail ("Not the same, pawns are reverted");
jtulach@0
   341
        if (b2.equals (b1)) fail ("Not the same, pawns are reverted");
jtulach@0
   342
    }
jtulach@11
   343
jtulach@13
   344
    public void testMoveAltersCurrentPlayer() throws Exception {
jtulach@13
   345
        assertEquals("First player ready", board.getCurrentPlayer(), board.getPlayers().get(0));
jtulach@13
   346
        Board b = apply(board, Move.EAST);
jtulach@13
   347
jtulach@14
   348
        for (int i = 0; i < 7; i++) {
jtulach@13
   349
            assertEquals("Snd player ready", b.getCurrentPlayer(), b.getPlayers().get(1));
jtulach@13
   350
            b = apply(b, Move.SOUTH);
jtulach@13
   351
            assertEquals("First player ready", b.getCurrentPlayer(), b.getPlayers().get(0));
jtulach@13
   352
            b = apply(b, Move.NORTH);
jtulach@13
   353
        }
jtulach@14
   354
jtulach@14
   355
        Board fin = b.apply(Move.NORTH).apply(Move.NORTH);
jtulach@14
   356
        assertNotNull("There is a winner", fin.getWinner());
jtulach@14
   357
        assertEquals("And the winner is", fin.getPlayers().get(0), fin.getWinner());
jtulach@14
   358
jtulach@17
   359
        assertFalse("No next move can be applied", fin.isApplicable(Move.fence('D', 3, Fence.Orientation.HORIZONTAL)));
jtulach@17
   360
jtulach@14
   361
        try {
jtulach@14
   362
            fin.apply(Move.EAST);
jtulach@14
   363
            fail("No moves allow when we are in final position");
jtulach@14
   364
        } catch (IllegalPositionException ex) {
jtulach@14
   365
            // OK
jtulach@14
   366
        }
jtulach@14
   367
jtulach@13
   368
    }
jtulach@30
   369
jtulach@31
   370
    public void testDetectInvalidFence() {
jtulach@31
   371
        try {
jtulach@31
   372
            Move m = Move.fence('D', 9, Orientation.HORIZONTAL);
jtulach@31
   373
            fail("Move shall not be allowed: " + m);
jtulach@31
   374
        } catch (IllegalPositionException ex) {
jtulach@31
   375
            // OK
jtulach@31
   376
        }
jtulach@31
   377
    }
jtulach@31
   378
jtulach@30
   379
    public void testEqualityOfMoves() throws Exception {
jtulach@30
   380
jtulach@30
   381
        for (Direction m1 : Direction.values()) {
jtulach@30
   382
            for (Direction m2 : Direction.values()) {
jtulach@30
   383
                Move both1 = Move.jump(m1, m2);
jtulach@30
   384
                Move both2 = Move.jump(m1, m2);
jtulach@30
   385
                Move opposite = Move.jump(m2, m1);
jtulach@30
   386
jtulach@30
   387
                assertTrue("Both boths are equal", both1.equals(both2));
jtulach@30
   388
                assertFalse("Not north", Move.NORTH.equals(both1));
jtulach@30
   389
                assertFalse("Not east", Move.EAST.equals(both1));
jtulach@30
   390
                assertFalse("Not west", Move.WEST.equals(both1));
jtulach@30
   391
                assertFalse("Not south", Move.SOUTH.equals(both1));
jtulach@30
   392
                if (m1 == m2) {
jtulach@30
   393
                    continue;
jtulach@30
   394
                }
jtulach@30
   395
                assertFalse("Not equal to opposite", both1.equals(opposite));
jtulach@30
   396
            }
jtulach@30
   397
        }
jtulach@30
   398
jtulach@30
   399
        Move f1 = Move.fence('D', 6, Orientation.HORIZONTAL);
jtulach@30
   400
        Move f2 = Move.fence('D', 6, Orientation.HORIZONTAL);
jtulach@30
   401
        Move f3 = Move.fence('D', 6, Orientation.VERTICAL);
jtulach@30
   402
        Move f4 = Move.fence('E', 6, Orientation.VERTICAL);
jtulach@30
   403
        Move f5 = Move.fence('E', 5, Orientation.VERTICAL);
jtulach@30
   404
jtulach@30
   405
        assertEquals(f1, f2);
jtulach@30
   406
        assertFalse(f1.equals(f3));
jtulach@30
   407
        assertFalse(f4.equals(f5));
jtulach@30
   408
        assertFalse(f3.equals(f5));
jtulach@30
   409
    }
jtulach@0
   410
}