Created
March 12, 2012 23:38
-
-
Save yngwie74/2025444 to your computer and use it in GitHub Desktop.
LCD numbers' tests (java)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.vivecodigo.katas.lcd; | |
import static junit.framework.Assert.*; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.junit.runners.Suite; | |
@RunWith(Suite.class) | |
@Suite.SuiteClasses( { AllTests.TestUtils.class, AllTests.LCDTests.class }) | |
public class AllTests { | |
public static class TestUtils { | |
@Test | |
public void test_to_horiz() throws Exception { | |
String data[][] = new String[][] { { "a", "b", "c" }, | |
{ "z", "y", "x" } }; | |
String expected[] = new String[] { "az", "by", "cx" }; | |
assertAreEqual(expected, Utils.arrangeHorizontally(data)); | |
} | |
private void assertAreEqual(String[] expected, String[] actual) { | |
String mensaje = "Longitudes no coinciden"; | |
assertEquals(mensaje, expected.length, actual.length); | |
for (int i = 0; i < expected.length; i++) { | |
mensaje = String.format("Renglón %d no coincide", i); | |
assertEquals(mensaje, expected[i], actual[i]); | |
} | |
} | |
} | |
public static class LCDTests { | |
@Test | |
public void test_for_1() throws Exception { | |
assertEquals( | |
" \n" + | |
" |\n" + | |
" |", LCD.ToLCD(1)); | |
} | |
@Test | |
public void test_for_2() throws Exception { | |
assertEquals( | |
" _ \n" + | |
" _|\n" + | |
"|_ ", LCD.ToLCD(2)); | |
} | |
@Test | |
public void test_for_3() throws Exception { | |
assertEquals( | |
" _ \n" + | |
" _|\n" + | |
" _|", LCD.ToLCD(3)); | |
} | |
@Test | |
public void test_for_4() throws Exception { | |
assertEquals( | |
" \n" + | |
"|_|\n" + | |
" |", LCD.ToLCD(4)); | |
} | |
@Test | |
public void test_for_5() throws Exception { | |
assertEquals( | |
" _ \n" + | |
"|_ \n" + | |
" _|", LCD.ToLCD(5)); | |
} | |
@Test | |
public void test_for_6() throws Exception { | |
assertEquals( | |
" _ \n" + | |
"|_ \n" + | |
"|_|", LCD.ToLCD(6)); | |
} | |
@Test | |
public void test_for_7() throws Exception { | |
assertEquals( | |
" _ \n" + | |
" |\n" + | |
" |", LCD.ToLCD(7)); | |
} | |
@Test | |
public void test_for_8() throws Exception { | |
assertEquals( | |
" _ \n" + | |
"|_|\n" + | |
"|_|", LCD.ToLCD(8)); | |
} | |
@Test | |
public void test_for_9() throws Exception { | |
assertEquals( | |
" _ \n" + | |
"|_|\n" + | |
" _|", LCD.ToLCD(9)); | |
} | |
@Test | |
public void test_for_0() throws Exception { | |
assertEquals( | |
" _ \n" + | |
"| |\n" + | |
"|_|", LCD.ToLCD(0)); | |
} | |
@Test | |
public void test_for_10() throws Exception { | |
assertEquals( | |
" _ \n" + | |
" || |\n" + | |
" ||_|", LCD.ToLCD(10)); | |
} | |
@Test | |
public void test_for_85246() throws Exception { | |
assertEquals( | |
" _ _ _ _ \n" + | |
"|_||_ _||_||_ \n" + | |
"|_| _||_ ||_|", LCD.ToLCD(85246)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment