OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 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 |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import unittest |
| 7 |
| 8 import check_orderfile |
| 9 import symbol_extractor |
| 10 |
| 11 |
| 12 class TestCheckOrderFile(unittest.TestCase): |
| 13 _SYMBOL_INFOS = [symbol_extractor.SymbolInfo('first', 0x1, 0, ''), |
| 14 symbol_extractor.SymbolInfo('second', 0x2, 0, ''), |
| 15 symbol_extractor.SymbolInfo('notProfiled', 0x4, 0, ''), |
| 16 symbol_extractor.SymbolInfo('third', 0x3, 0, ''),] |
| 17 |
| 18 def testMatchesSymbols(self): |
| 19 symbols = ['first', 'second', 'third'] |
| 20 (misordered_pairs_count, matched_count, missing_count) = ( |
| 21 check_orderfile._CountMisorderedSymbols(symbols, self._SYMBOL_INFOS)) |
| 22 self.assertEquals( |
| 23 (misordered_pairs_count, matched_count, missing_count), (0, 3, 0)) |
| 24 |
| 25 def testMissingMatches(self): |
| 26 symbols = ['second', 'third', 'other', 'first'] |
| 27 (_, matched_count, unmatched_count) = ( |
| 28 check_orderfile._CountMisorderedSymbols(symbols, self._SYMBOL_INFOS)) |
| 29 self.assertEquals(matched_count, 3) |
| 30 self.assertEquals(unmatched_count, 1) |
| 31 |
| 32 def testNoUnorderedSymbols(self): |
| 33 symbols = ['first', 'other', 'second', 'third', 'noMatchEither'] |
| 34 (misordered_pairs_count, _, _) = ( |
| 35 check_orderfile._CountMisorderedSymbols(symbols, self._SYMBOL_INFOS)) |
| 36 self.assertEquals(misordered_pairs_count, 0) |
| 37 |
| 38 def testUnorderedSymbols(self): |
| 39 symbols = ['first', 'other', 'third', 'second', 'noMatchEither'] |
| 40 (misordered_pairs_count, _, _) = ( |
| 41 check_orderfile._CountMisorderedSymbols(symbols, self._SYMBOL_INFOS)) |
| 42 self.assertEquals(misordered_pairs_count, 1) |
| 43 |
| 44 |
| 45 if __name__ == '__main__': |
| 46 unittest.main() |
OLD | NEW |