Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright 2014 Google Inc. | 3 # Copyright 2014 Google Inc. |
| 4 # | 4 # |
| 5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
| 7 | 7 |
| 8 """ | 8 """ |
| 9 Test the VarsDict. | 9 Test the VarsDict. |
| 10 """ | 10 """ |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 self.assertIsInstance(v_dict[key], OrderedSet) | 53 self.assertIsInstance(v_dict[key], OrderedSet) |
| 54 self.assertEqual(len(v_dict[key]), 0) | 54 self.assertEqual(len(v_dict[key]), 0) |
| 55 self.assert_consistency(v_dict) | 55 self.assert_consistency(v_dict) |
| 56 | 56 |
| 57 def test_intersection(self): | 57 def test_intersection(self): |
| 58 v_dict_list = [] | 58 v_dict_list = [] |
| 59 RANGE = 10 | 59 RANGE = 10 |
| 60 for i in range(RANGE): | 60 for i in range(RANGE): |
| 61 v_dict = VarsDict() | 61 v_dict = VarsDict() |
| 62 # Add something common to each field, as well as a unique entry | 62 # Add something common to each field, as well as a unique entry |
| 63 v_dict.LOCAL_CFLAGS.add('cflag') | 63 v_dict.LOCAL_CFLAGS.add('cflag') |
|
scroggo
2014/03/25 22:03:00
Could simplify this by looping over v_dict.keys()
| |
| 64 v_dict.LOCAL_CFLAGS.add(str(i)) | 64 v_dict.LOCAL_CFLAGS.add(str(i)) |
| 65 | 65 |
| 66 v_dict.LOCAL_CPPFLAGS.add('cppflag') | 66 v_dict.LOCAL_CPPFLAGS.add('cppflag') |
| 67 v_dict.LOCAL_CPPFLAGS.add(str(i)) | 67 v_dict.LOCAL_CPPFLAGS.add(str(i)) |
| 68 | 68 |
| 69 v_dict.LOCAL_SRC_FILES.add('src') | 69 v_dict.LOCAL_SRC_FILES.add('src') |
| 70 v_dict.LOCAL_SRC_FILES.add(str(i)) | 70 v_dict.LOCAL_SRC_FILES.add(str(i)) |
| 71 | 71 |
| 72 v_dict.LOCAL_SHARED_LIBRARIES.add('shared') | 72 v_dict.LOCAL_SHARED_LIBRARIES.add('shared') |
| 73 v_dict.LOCAL_SHARED_LIBRARIES.add(str(i)) | 73 v_dict.LOCAL_SHARED_LIBRARIES.add(str(i)) |
| 74 | 74 |
| 75 v_dict.LOCAL_STATIC_LIBRARIES.add('static') | 75 v_dict.LOCAL_STATIC_LIBRARIES.add('static') |
| 76 v_dict.LOCAL_STATIC_LIBRARIES.add(str(i)) | 76 v_dict.LOCAL_STATIC_LIBRARIES.add(str(i)) |
| 77 | 77 |
| 78 v_dict.LOCAL_C_INCLUDES.add('includes') | 78 v_dict.LOCAL_C_INCLUDES.add('includes') |
| 79 v_dict.LOCAL_C_INCLUDES.add(str(i)) | 79 v_dict.LOCAL_C_INCLUDES.add(str(i)) |
| 80 | 80 |
| 81 v_dict.LOCAL_EXPORT_C_INCLUDE_DIRS.add('exports') | 81 v_dict.LOCAL_EXPORT_C_INCLUDE_DIRS.add('exports') |
| 82 v_dict.LOCAL_EXPORT_C_INCLUDE_DIRS.add(str(i)) | 82 v_dict.LOCAL_EXPORT_C_INCLUDE_DIRS.add(str(i)) |
| 83 | 83 |
| 84 v_dict.DEFINES.add('defines') | |
| 85 v_dict.DEFINES.add(str(i)) | |
| 86 | |
| 84 v_dict.KNOWN_TARGETS.add('known') | 87 v_dict.KNOWN_TARGETS.add('known') |
| 85 v_dict.KNOWN_TARGETS.add(str(i)) | 88 v_dict.KNOWN_TARGETS.add(str(i)) |
| 86 | 89 |
| 87 self.assert_consistency(v_dict) | 90 self.assert_consistency(v_dict) |
| 88 | 91 |
| 89 v_dict_list.append(v_dict) | 92 v_dict_list.append(v_dict) |
| 90 | 93 |
| 91 intersection = vars_dict_lib.intersect(v_dict_list) | 94 intersection = vars_dict_lib.intersect(v_dict_list) |
| 92 | 95 |
| 93 self.assert_consistency(intersection) | 96 self.assert_consistency(intersection) |
| 94 | 97 |
| 95 for key in intersection.keys(): | 98 for key in intersection.keys(): |
| 96 # Each field had one common item | 99 # Each field had one common item |
| 97 self.assertEqual(len(intersection[key]), 1) | 100 self.assertEqual(len(intersection[key]), 1) |
| 98 for item in intersection[key]: | 101 for item in intersection[key]: |
| 99 for other_v_dict in v_dict_list: | 102 for other_v_dict in v_dict_list: |
| 100 self.assertNotIn(item, other_v_dict[key]) | 103 self.assertNotIn(item, other_v_dict[key]) |
| 101 | 104 |
| 102 | 105 |
| 103 def main(): | 106 def main(): |
| 104 loader = unittest.TestLoader() | 107 loader = unittest.TestLoader() |
| 105 suite = loader.loadTestsFromTestCase(VarsDictTest) | 108 suite = loader.loadTestsFromTestCase(VarsDictTest) |
| 106 unittest.TextTestRunner(verbosity=2).run(suite) | 109 unittest.TextTestRunner(verbosity=2).run(suite) |
| 107 | 110 |
| 108 if __name__ == "__main__": | 111 if __name__ == "__main__": |
| 109 main() | 112 main() |
| 110 | 113 |
| OLD | NEW |