[jetrix-cvs] jetrix/src/test/net/jetrix FieldTest.java,1.2,1.3
Brought to you by:
smanux
From: Emmanuel B. <sm...@us...> - 2005-05-10 02:39:32
|
Update of /cvsroot/jetrix/jetrix/src/test/net/jetrix In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4057/src/test/net/jetrix Modified Files: FieldTest.java Log Message: more tests Index: FieldTest.java =================================================================== RCS file: /cvsroot/jetrix/jetrix/src/test/net/jetrix/FieldTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FieldTest.java 4 Apr 2005 09:36:19 -0000 1.2 --- FieldTest.java 10 May 2005 02:39:23 -0000 1.3 *************** *** 1,5 **** /** * Jetrix TetriNET Server ! * Copyright (C) 2001-2003 Emmanuel Bourg * * This program is free software; you can redistribute it and/or --- 1,5 ---- /** * Jetrix TetriNET Server ! * Copyright (C) 2001-2005 Emmanuel Bourg * * This program is free software; you can redistribute it and/or *************** *** 20,23 **** --- 20,25 ---- package net.jetrix; + import static net.jetrix.config.Special.*; + import junit.framework.*; import net.jetrix.messages.*; *************** *** 112,118 **** field.update(message); ! assertEquals("block at (0, 0)", Field.SPECIAL_SWITCHFIELD, field.getBlock(0, 0)); ! assertEquals("block at (1, 0)", Field.SPECIAL_GRAVITY, field.getBlock(1, 0)); ! assertEquals("block at (2, 0)", Field.SPECIAL_QUAKEFIELD, field.getBlock(2, 0)); } --- 114,120 ---- field.update(message); ! assertEquals("block at (0, 0)", SWITCHFIELD.getLetter(), field.getBlock(0, 0)); ! assertEquals("block at (1, 0)", GRAVITY.getLetter(), field.getBlock(1, 0)); ! assertEquals("block at (2, 0)", QUAKEFIELD.getLetter(), field.getBlock(2, 0)); } *************** *** 151,153 **** --- 153,196 ---- } + public void testGetHighest() + { + byte[][] array = new byte[Field.WIDTH][Field.HEIGHT]; + + field = new Field(array); + field.clear(); + + array[5][15] = Field.BLOCK_BLUE; + array[0][0] = Field.BLOCK_RED; + + assertEquals("highest block", 15, field.getHighest()); + } + + public void testIsEmpty() + { + assertTrue("the field is not empty", field.isEmpty()); + + field.update(new FieldMessage("+3H-4H.5H")); + + assertFalse("the field is empty", field.isEmpty()); + } + + public void testHasHoles() + { + byte[][] array = new byte[Field.WIDTH][Field.HEIGHT]; + + field = new Field(array); + field.clear(); + + for (int i = 0; i < Field.WIDTH; i++) + { + array[i][0] = Field.BLOCK_RED; + array[i][1] = Field.BLOCK_BLUE; + } + + assertFalse("no holes", field.hasHoles()); + + array[6][0] = Field.BLOCK_VOID; + + assertTrue("one hole", field.hasHoles()); + } } |