A4Tester (8)_Solutions - } /** Test the translation...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 import junit.framework.TestCase import java.awt.* /** * A JUnit test case class. * Every method starting with the word "test" will be called when running * the test with JUnit. */ public class A4Tester extends TestCase { /** Test methods complement, truncateTo5, toString(Color rgb), toString(HSV hsv), and toString(CMYK cmyk) */ public void testStrings() { assertEquals(new Color(5, 255, 255-71), A4Methods.complementRGB(new Color(250, 0, 71))) assertEquals("", A4Methods.truncateTo5("")) assertEquals("A", A4Methods.truncateTo5("A")) assertEquals("ABCDE", A4Methods.truncateTo5("ABCDE")) assertEquals("ABCDE", A4Methods.truncateTo5("ABCDEF")) assertEquals("ABCDE", A4Methods.truncateTo5("ABCDEFGHI")) assertEquals("[30, 240, 230]", A4Methods.toString(new Color(30, 240, 230)))
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } /** Test the translation functions */ public void testTranslations() { Color rgb= new Color(255, 255, 255) CMYK cmyk= A4Methods.RGBtoCMYK(rgb) assertEquals(0.0, cmyk.c) assertEquals(0.0, cmyk.m) assertEquals(0.0, cmyk.y) assertEquals(0.0, cmyk.k) rgb= new Color(0, 0, 0) cmyk= A4Methods.RGBtoCMYK(rgb) assertEquals(0.0, cmyk.c) assertEquals(0.0, cmyk.m) assertEquals(0.0, cmyk.y) assertEquals(1.0, cmyk.k) rgb= new Color(217, 43, 164) cmyk= A4Methods.RGBtoCMYK(rgb) assertEquals("0.0", A4Methods.truncateTo5("" + cmyk.c)) assertEquals("0.801", A4Methods.truncateTo5("" + cmyk.m)) assertEquals("0.244", A4Methods.truncateTo5("" + cmyk.y)) assertEquals("0.149", A4Methods.truncateTo5("" + cmyk.k)) } Sheet1 Page 2 }...
View Full Document

Page1 / 2

A4Tester (8)_Solutions - } /** Test the translation...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online