From 682f21a3bdfe379494d7e88c9ee40e33ca09aabc Mon Sep 17 00:00:00 2001 From: Nikita Hasert Date: Thu, 8 Mar 2018 15:57:21 +0100 Subject: [PATCH] Create getState test --- .../chip8/hardware/memory/ScreenMemoryTest.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/test/java/de/nihas101/chip8/hardware/memory/ScreenMemoryTest.java b/src/test/java/de/nihas101/chip8/hardware/memory/ScreenMemoryTest.java index bf2a429..9ee1ef7 100644 --- a/src/test/java/de/nihas101/chip8/hardware/memory/ScreenMemoryTest.java +++ b/src/test/java/de/nihas101/chip8/hardware/memory/ScreenMemoryTest.java @@ -14,12 +14,27 @@ public void getMemory() { assertEquals(false, aBoolean); } + @Test + public void getStateTest() { + int skipScreenMemoryString = 14; + ScreenMemory screenMemory = new ScreenMemory(); + String screenMemoryState = screenMemory.getState(); + String screenMemoryString = screenMemoryState.substring(skipScreenMemoryString).trim(); + + checkForZeroes(screenMemoryString.split("\\s+")); + } + @Test public void toStringTest() { - String zero = "0"; ScreenMemory screenMemory = new ScreenMemory(); String[] screenMemoryStrings = screenMemory.toString().trim().split("\\s+"); + checkForZeroes(screenMemoryStrings); + } + + private void checkForZeroes(String[] screenMemoryStrings) { + String zero = "0"; + for (String screenMemoryString : screenMemoryStrings) assertEquals(zero, screenMemoryString.trim()); }