Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Unified Diff: platform_tools/android/tests/ordered_set_tests.py

Issue 140503007: Scripts to generate Android.mk for framework Skia. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Respond to Elliot's comments in patch set 20. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « platform_tools/android/tests/gyp_to_android_tests.py ('k') | platform_tools/android/tests/run_all.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: platform_tools/android/tests/ordered_set_tests.py
diff --git a/platform_tools/android/tests/ordered_set_tests.py b/platform_tools/android/tests/ordered_set_tests.py
new file mode 100644
index 0000000000000000000000000000000000000000..248f0f6f6c342d87eb83501a0fd128921ca05214
--- /dev/null
+++ b/platform_tools/android/tests/ordered_set_tests.py
@@ -0,0 +1,69 @@
+#!/usr/bin/python
+
+# Copyright 2014 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Test OrderedSet.
+"""
+
+import sys
+import test_variables
+import unittest
+
+sys.path.append(test_variables.GYP_GEN_DIR)
+
+from vars_dict_lib import OrderedSet
+
+
+def create_dummy_var(i):
+ return 'dummy_var' + str(i)
+
+
+class OrderedSetTest(unittest.TestCase):
+
+ def setUp(self):
+ self.__set = OrderedSet()
+
+ def test_methods(self):
+ """
+ Test methods on OrderedSet.
+ """
+ RANGE = 10
+ for i in range(RANGE):
+ dummy_var = create_dummy_var(i)
+ # Add to the list. This should succeed.
+ self.__set.add(dummy_var)
+ self.assertEqual(len(self.__set), i+1)
+ self.assertTrue(dummy_var in self.__set)
+ self.assertEqual(self.__set[i], dummy_var)
+
+ # Now attempt to add it again. This should fail.
+ self.__set.add(dummy_var)
+ self.assertEqual(len(self.__set), i+1)
+ self.assertEqual(self.__set[i], dummy_var)
+
+ # Test iterator.
+ counter = 0
+ for set_member in self.__set:
+ self.assertEqual(create_dummy_var(counter), set_member)
+ counter += 1
+ self.assertEqual(counter, len(self.__set))
+
+ # Now test removal.
+ for i in range(RANGE):
+ dummy_var = create_dummy_var(i)
+ self.__set.remove(dummy_var)
+ self.assertEqual(len(self.__set), RANGE-i-1)
+ self.assertFalse(dummy_var in self.__set)
+
+def main():
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromTestCase(OrderedSetTest)
+ unittest.TextTestRunner(verbosity=2).run(suite)
+
+if __name__ == "__main__":
+ main()
+
« no previous file with comments | « platform_tools/android/tests/gyp_to_android_tests.py ('k') | platform_tools/android/tests/run_all.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698