[pitivi] tests: Rename test_binary_search to test_misc so it can be found easier



commit 86e209847d3c0019e4d7bf04d73b9bb8101c653a
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Sun Dec 15 10:55:30 2013 +0100

    tests: Rename test_binary_search to test_misc so it can be found easier

 tests/Makefile.am           |    2 +-
 tests/test_binary_search.py |   28 ----------------------------
 tests/test_misc.py          |   43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 29 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b257d08..b1a13d3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,9 +3,9 @@
 # http://www.gnu.org/software/automake/manual/automake.html#Wildcards
 # Keep this list sorted!
 tests =        test_basic.py \
-       test_binary_search.py \
        test_common.py \
        test_log.py \
+       test_misc.py \
        test_preset.py \
        test_projectmanager.py \
        test_projectsettings.py \
diff --git a/tests/test_misc.py b/tests/test_misc.py
new file mode 100644
index 0000000..ffa847c
--- /dev/null
+++ b/tests/test_misc.py
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2013, Alex Băluț <alexandru balut gmail com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+import unittest
+
+from pitivi.utils.misc import binary_search
+
+
+class BinarySearchTest(unittest.TestCase):
+
+    def testEmptyList(self):
+        self.assertEquals(binary_search([], 10), -1)
+
+    def testExisting(self):
+        A = [10, 20, 30]
+        for index, element in enumerate(A):
+            self.assertEquals(binary_search([10, 20, 30], element), index)
+
+    def testMissingLeft(self):
+        self.assertEquals(binary_search([10, 20, 30], 1), 0)
+        self.assertEquals(binary_search([10, 20, 30], 16), 1)
+        self.assertEquals(binary_search([10, 20, 30], 29), 2)
+
+    def testMissingRight(self):
+        self.assertEquals(binary_search([10, 20, 30], 11), 0)
+        self.assertEquals(binary_search([10, 20, 30], 24), 1)
+        self.assertEquals(binary_search([10, 20, 30], 40), 2)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]