OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import symbol_extractor | 6 import symbol_extractor |
7 import unittest | 7 import unittest |
8 | 8 |
9 class TestSymbolInfo(unittest.TestCase): | 9 class TestSymbolInfo(unittest.TestCase): |
10 def testIgnoresBlankLine(self): | 10 def testIgnoresBlankLine(self): |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 def testCreateNameToSymbolInfo(self): | 97 def testCreateNameToSymbolInfo(self): |
98 name_to_symbol_info = symbol_extractor.CreateNameToSymbolInfo( | 98 name_to_symbol_info = symbol_extractor.CreateNameToSymbolInfo( |
99 self.symbol_infos) | 99 self.symbol_infos) |
100 self.assertEquals(len(name_to_symbol_info), 3) | 100 self.assertEquals(len(name_to_symbol_info), 3) |
101 for i in range(3): | 101 for i in range(3): |
102 name = self.symbol_infos[i].name | 102 name = self.symbol_infos[i].name |
103 self.assertIn(name, name_to_symbol_info) | 103 self.assertIn(name, name_to_symbol_info) |
104 self.assertEquals(self.symbol_infos[i], name_to_symbol_info[name]) | 104 self.assertEquals(self.symbol_infos[i], name_to_symbol_info[name]) |
105 | 105 |
| 106 def testSymbolCollisions(self): |
| 107 symbol_infos_with_collision = list(self.symbol_infos) |
| 108 symbol_infos_with_collision.append(symbol_extractor.SymbolInfo( |
| 109 'secondNameAtOffset', 0x84, 42, '.text')) |
| 110 |
| 111 # The symbol added above should not affect the output. |
| 112 name_to_symbol_info = symbol_extractor.CreateNameToSymbolInfo( |
| 113 self.symbol_infos) |
| 114 self.assertEquals(len(name_to_symbol_info), 3) |
| 115 for i in range(3): |
| 116 name = self.symbol_infos[i].name |
| 117 self.assertIn(name, name_to_symbol_info) |
| 118 self.assertEquals(self.symbol_infos[i], name_to_symbol_info[name]) |
106 | 119 |
107 if __name__ == '__main__': | 120 if __name__ == '__main__': |
108 unittest.main() | 121 unittest.main() |
OLD | NEW |