pitivi r1175 - in branches/SOC_2008_BLEWIS: . tests
- From: blewis svn gnome org
- To: svn-commits-list gnome org
- Subject: pitivi r1175 - in branches/SOC_2008_BLEWIS: . tests
- Date: Wed, 16 Jul 2008 23:26:55 +0000 (UTC)
Author: blewis
Date: Wed Jul 16 23:26:55 2008
New Revision: 1175
URL: http://svn.gnome.org/viewvc/pitivi?rev=1175&view=rev
Log:
* tests/runtests.py:
changed name of ingnored test
* tests/test_binary_search.py:
added test suite for binary search
Added:
branches/SOC_2008_BLEWIS/tests/test_binary_search.py
Modified:
branches/SOC_2008_BLEWIS/ChangeLog
branches/SOC_2008_BLEWIS/tests/runtests.py
Modified: branches/SOC_2008_BLEWIS/tests/runtests.py
==============================================================================
--- branches/SOC_2008_BLEWIS/tests/runtests.py (original)
+++ branches/SOC_2008_BLEWIS/tests/runtests.py Wed Jul 16 23:26:55 2008
@@ -3,7 +3,7 @@
import sys
import unittest
-SKIP_FILES = ['common', 'runtests', 'testcomplex', 'testHList', 'testdrag']
+SKIP_FILES = ['common', 'runtests', 'testcomplex', 'testHList', 'testmagets']
def gettestnames(which):
if not which:
Added: branches/SOC_2008_BLEWIS/tests/test_binary_search.py
==============================================================================
--- (empty file)
+++ branches/SOC_2008_BLEWIS/tests/test_binary_search.py Wed Jul 16 23:26:55 2008
@@ -0,0 +1,44 @@
+import unittest
+import pitivi
+from pitivi.pitivi import Pitivi
+from pitivi.utils import binary_search
+
+class BasicTest(unittest.TestCase):
+ """
+ Basic test to create the proper creation of the Pitivi object
+ """
+
+ def testBinarySearch(self):
+ # binary_search always returns an index, so we do the comparison here
+ def found(A, result, value):
+ if ((result < len(A)) and (A[result] == value)):
+ return result
+ else:
+ return False
+
+ for offset in xrange(1, 5):
+ for length in xrange(1, 2049, 300):
+ A = [i * offset for i in xrange(0, length)]
+
+## check negative hits
+
+ # search value too low
+ # error if value is found
+ # if search returns non-negative index, fail
+ value = A[0] - 1
+ self.assertFalse(found(A, binary_search(A, value), value))
+
+ # search value too high
+ # error if value is found
+ # if search returns non-negative index, fail
+ value = A[-1] + 1
+ self.assertFalse(found(A, binary_search(A, value), value))
+
+## check positive hits
+ for i, a in enumerate(A):
+ # error if value is NOT found
+ # if search does not return correct value, fail
+ self.assertEquals(binary_search(A, A[i]), i)
+
+if __name__ == "__main__":
+ unittest.main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]