package lab.games; import static org.junit.Assert.*; import java.util.Random; import org.junit.Test; public class FrameTest { private static int HEIGHT = 0x5; private static int WIDTH = 0x50; @Test public void testHEIGHT() { assertEquals("The value of HEIGHT is incorrect", FrameTest.HEIGHT, Frame.HEIGHT); } @Test public void testWIDTH() { assertEquals("The value of WIDTH is incorrect", FrameTest.WIDTH, Frame.WIDTH); } @Test public void testConstructorAndToString() { Random random = new Random(System.currentTimeMillis()); final int NUMBER = 100; final int MAX = 256; for (int n = 0; n < NUMBER; n++) { StringBuffer content = new StringBuffer(); for (int h = 0; h < HEIGHT; h++) { int width = 1 + random.nextInt(WIDTH); for (int w = 0; w < width; w++) { char c; do { c = (char) random.nextInt(MAX); } while (c == '\n'); content.append(Character.toString(c)); } content.append("\n"); } Frame frame = new Frame(content.toString()); assertEquals("The constructor or the toString method is incorrect", content.toString(), frame.toString()); } } }