Added support for unit tests.
Added support for unit tests.

--- /dev/null
+++ b/runallunittests.sh
@@ -1,1 +1,17 @@
+#!/bin/bash
 
+for i in tests/*.txt
+do
+    TEST=`basename $i .txt`
+    if [ -f "tests/${TEST}.png" ]
+    then
+	echo -n "Running test: ${TEST}"
+	./rununittest.py ${TEST} >/dev/null 2>/dev/null
+	if [[ $? -eq 0 ]]
+	then
+	    echo -e "\tFAIL"
+	else
+	    echo -e "\tPASS"
+	fi
+    fi
+done

file:b/rununittest.py (new)
--- /dev/null
+++ b/rununittest.py
@@ -1,1 +1,66 @@
+#!/usr/bin/python
 
+import Image
+import os,sys
+import os.path
+import math
+
+if(len(sys.argv)!=2):
+    print 'usage: '+os.path.basename(sys.argv[0])+' testname'
+    sys.exit(-1)
+
+imbase=sys.argv[1]
+im1='tests/'+imbase+'.png'
+im2='tests/'+imbase+'.ppm'
+scene=imbase+'.txt'
+
+if(not os.path.exists('tests/'+scene)):
+    print imbase+': Test does not exist'
+    sys.exit(2)
+
+os.system('make')
+os.system('cd tests && ../raytracer '+scene)
+
+if(not os.path.exists(im1)):
+    print imbase+': No PNG image exists'
+    sys.exit(2)
+
+if(not os.path.exists(im2)):
+    print imbase+': No PPM image exists'
+    sys.exit(2)
+
+im1=Image.open(im1)
+im2=Image.open(im2)
+
+if(im1.size!=im2.size):
+    print imbase+": Sizes aren't equal"
+    sys.exit(0);
+
+im1_data=im1.load()
+im2_data=im2.load()
+
+diff=Image.new(im1.mode,im1.size)
+diff_data=diff.load()
+
+images_are_same=True
+for x in range(0,im1.size[0]):
+    for y in range(0,im1.size[1]):
+        pixel1=im1_data[x,y]
+        pixel2=im2_data[x,y]
+        pixeldiff=(int(math.fabs(pixel1[0]-pixel2[0])),
+                   int(math.fabs(pixel1[1]-pixel2[1])),
+                   int(math.fabs(pixel1[2]-pixel2[2])))
+        if(pixeldiff!=(0,0,0)):
+            images_are_same=False
+        diff_data[x,y]=pixeldiff
+
+if(images_are_same):
+    if(os.path.exists('tests/'+imbase+'.diff.png')):
+        os.remove('tests/'+imbase+'.diff.png')
+    sys.exit(1)
+else:
+    diff.save('tests/'+imbase+'.diff.png')
+    print imbase+": Difference"
+    sys.exit(0)
+    
+

Binary files a/tests/axisalignedboxtest2.png and b/tests/axisalignedboxtest2.png differ

Binary files a/tests/minecraft.png and b/tests/minecraft.png differ

Binary files a/tests/normalmapsample.png and b/tests/normalmapsample.png differ

Binary files a/tests/normalmaptest1.png and b/tests/normalmaptest1.png differ

Binary files a/tests/refractionsample.png and b/tests/refractionsample.png differ

Binary files a/tests/refractiontest.png and b/tests/refractiontest.png differ

Binary files a/tests/sample3.png and b/tests/sample3.png differ

Binary files a/tests/sample4.png and b/tests/sample4.png differ

Binary files a/tests/sample5.png and b/tests/sample5.png differ

Binary files a/tests/spotlightsample1.png and b/tests/spotlightsample1.png differ

Binary files a/tests/subpixelsample.png and b/tests/subpixelsample.png differ

Binary files a/tests/transparencytest.png and b/tests/transparencytest.png differ