Author: ArcRiley
Date: 2008-02-17 13:15:26 -0500 (Sun, 17 Feb 2008)
New Revision: 927

Added:
   trunk/pysoy/tests/TestAll.py
   trunk/pysoy/tests/TestColor.py
Log:
Adding TestColor, which currently only tests comparisons and some hex output


Added: trunk/pysoy/tests/TestAll.py
===================================================================
--- trunk/pysoy/tests/TestAll.py                                (rev 0)
+++ trunk/pysoy/tests/TestAll.py        2008-02-17 18:15:26 UTC (rev 927)
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+
+'''Test everything
+
+    This script provides the convience of running every test at once.
+'''
+__credits__ = '''Copyright (C) 2006,2007,2008 PySoy Group
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, see http://www.gnu.org/licenses
+'''
+__author__  = 'PySoy Group'
+__date__    = 'Last change on '+ \
+              '$Date: 2008-02-15 03:16:28 -0500 (Fri, 15 Feb 2008) $'[7:-20]+ \
+              'by '+'$Author: ArcRiley $'[9:-2]
+__version__ = 'Trunk (r'+'$Rev: 898 $'[6:-2]+')'
+
+import unittest
+
+import TestColor
+import TestMesh
+
+TestAll = unittest.TestSuite()
+TestAll.addTests((
+  TestColor.TestColorSuite(),
+  TestMesh.TestMeshSuite(),
+))  
+
+if __name__=='__main__':
+  runner = unittest.TextTestRunner()
+  runner.run(TestAll)


Property changes on: trunk/pysoy/tests/TestAll.py
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/pysoy/tests/TestColor.py
===================================================================
--- trunk/pysoy/tests/TestColor.py                              (rev 0)
+++ trunk/pysoy/tests/TestColor.py      2008-02-17 18:15:26 UTC (rev 927)
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+
+'''Tests for soy.colors.Color
+
+    These tests verify the sanity of Color comparison, math, and str() output.
+'''
+__credits__ = '''Copyright (C) 2006,2007,2008 PySoy Group
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, see http://www.gnu.org/licenses
+'''
+__author__  = 'PySoy Group'
+__date__    = 'Last change on '+ \
+              '$Date: 2008-02-15 03:16:28 -0500 (Fri, 15 Feb 2008) $'[7:-20]+ \
+              'by '+'$Author: ArcRiley $'[9:-2]
+__version__ = 'Trunk (r'+'$Rev: 898 $'[6:-2]+')'
+
+import soy
+import unittest
+
+class TestColor(unittest.TestCase):
+  def testEqual(self) :
+    self.failUnless(soy.colors.white.floats == (1.0, 1.0, 1.0),
+                    "white.floats == (1.0, 1.0, 1.0) compared float values")
+    self.failUnless(soy.colors.white == soy.colors.Color('#ffffff'),
+                    "white == '#ffffff', tested __richcmp__ with same hex")
+    self.failUnless(soy.colors.white == soy.colors.Color('#fff'),
+                    "white == '#fff', compared 12bit to 24bit hex values")
+    self.failUnless(soy.colors.Color('#3f3') == 
+                    soy.colors.Color((0.2, 1.0, 0.2)),
+                    "'#3f3' == (.2, 1.0, .2), nonwhite hex/float compared")
+    self.failUnless(soy.colors.Color('#3f3f') ==
+                    soy.colors.Color((1.0, 0.2, 1.0, 0.2)),
+                    "'#3f3f' == (1.0, .2, 1.0, .2), alpha hex/float compared")
+    self.failIf(soy.colors.black == 0,
+                'comparing Color to non-Color should return NotImplemented')
+
+  def testNotEqual(self) :
+    self.failUnless(soy.colors.Color('#000') !=
+                    soy.colors.Color((1.0, 1.0, 1.0)),
+                    "'#000' != (1.0, 1.0, 1.0), black is not white")
+    self.failUnless(soy.colors.Color('#000') !=
+                    soy.colors.Color((0.0, 0.0, 0.0, 0.0)),
+                    "'#000' != (.0, .0, .0, .0), alpha 1.0 (default) != 0.0")
+
+  def testLess(self) :
+    self.failUnless(soy.colors.black < soy.colors.white,
+                    'black should be less than white, check alpha compare')
+    self.failUnless(soy.colors.clear < soy.colors.Color('#111'),
+                    "clear ('#0000') should be less than ('#f111')")
+    self.failIf(soy.colors.Color('#211') < soy.colors.Color('#222'),
+                'no channel can be == with < operator')
+    self.failIf(soy.colors.Color('#311') <= soy.colors.Color('#222'),
+                'no channel can be > with < operator')
+
+  def testLessEqual(self) :
+    self.failUnless(soy.colors.black <= soy.colors.white,
+                    'all channels can be < with <= operator')
+    self.failUnless(soy.colors.Color('#222') <= soy.colors.Color('#222'),
+                    'both colors can be == with <= operator')
+    self.failUnless(soy.colors.Color('#210') <= soy.colors.Color('#222'),
+                    'each channel can be <= with <= operator')
+    self.failIf(soy.colors.Color('#321') <= soy.colors.Color('#222'),
+                'no channel can be > whith <= operator')
+
+  def testGreater(self) :
+    self.failUnless(soy.colors.white > soy.colors.black,
+                    'white should be > than black, check alpha compare')
+    self.failIf(soy.colors.Color('#233') > soy.colors.Color('#222'),
+                'no channel can be == with > operator')
+    self.failIf(soy.colors.Color('#133') > soy.colors.Color('#222'),
+                'no channel can be < with > operator')
+
+  def testGreaterEqual(self) :
+    self.failUnless(soy.colors.white >= soy.colors.black,
+                    'all channels can be > with >= operator')
+    self.failUnless(soy.colors.Color('#222') >= soy.colors.Color('#222'),
+                    'both colors can be == with >= operator')
+    self.failUnless(soy.colors.Color('#234') >= soy.colors.Color('#222'),
+                    'each channel can be >= with >= operator')
+    self.failIf(soy.colors.Color('#321') >= soy.colors.Color('#222'),
+                'no channel can be < whith >= operator')
+
+
+
+def TestColorSuite() :
+  return unittest.TestLoader().loadTestsFromTestCase(TestColor)
+
+
+if __name__=='__main__':
+  unittest.main()


Property changes on: trunk/pysoy/tests/TestColor.py
___________________________________________________________________
Name: svn:executable
   + *

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to