--- /dev/null
+import static org.junit.Assert.*;
+
+import java.awt.Color;
+import java.awt.image.BufferedImage;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ */
+
+/**
+ * @author chingyichang
+ *
+ */
+public class TestColor {
+
+ BufferedImage input_image;
+ BufferedImage output_image;
+ BufferedImage image;
+ int width;
+ int height;
+
+ @Before
+ public void setUp() throws Exception {
+ LoadFile file = new LoadFile();
+ input_image = file.Load_File("test.jpg");
+
+ BlackandWhite bw_image = new BlackandWhite();
+ output_image = bw_image.Black_and_White(input_image);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testBlackandWhite() {
+
+ try {
+
+ width = output_image.getWidth();
+ height = output_image.getHeight();
+
+ for(int i=0; i<height; i++){
+
+ for(int j=0; j<width; j++){
+
+ Color c = new Color(output_image.getRGB(j, i));
+
+ int red = (int)c.getRed();
+ int green = (int)c.getGreen();
+ int blue = (int)c.getBlue();
+ int average = (red+green+blue) / 3;
+
+ assertTrue(average==0||average==255);
+
+ }
+ }
+ } catch (Exception e) {}
+
+ }
+
+}