Chromium Code Reviews| 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 def testMatchesSymbols(self): | |
| 14 symbol_infos = [ | |
|
pasko
2015/02/02 10:00:30
using this list as a global constant in the test f
Benoit L
2015/02/02 13:11:45
Done.
| |
| 15 symbol_extractor.SymbolInfo('first', 0x1, 0, ''), | |
| 16 symbol_extractor.SymbolInfo('second', 0x2, 0, ''), | |
| 17 symbol_extractor.SymbolInfo('third', 0x3, 0, ''), | |
| 18 symbol_extractor.SymbolInfo('notProfiled', 0x3, 0, '')] | |
| 19 symbols = ['second', 'third', 'first'] | |
| 20 (_, matched_count, _) = check_orderfile._CountMisorderedSymbols( | |
|
pasko
2015/02/02 10:00:30
wouldn't it be good to check the other counts here
Benoit L
2015/02/02 13:11:45
Done.
| |
| 21 symbols, symbol_infos) | |
| 22 self.assertEquals(matched_count, 3) | |
| 23 | |
| 24 def testMissingMatches(self): | |
| 25 symbol_infos = [ | |
| 26 symbol_extractor.SymbolInfo('first', 0x1, 0, ''), | |
| 27 symbol_extractor.SymbolInfo('second', 0x2, 0, ''), | |
| 28 symbol_extractor.SymbolInfo('third', 0x3, 0, ''), | |
| 29 symbol_extractor.SymbolInfo('notProfiled', 0x4, 0, '')] | |
| 30 symbols = ['second', 'third', 'other', 'first'] | |
| 31 (_, matched_count, unmatched_count) = ( | |
| 32 check_orderfile._CountMisorderedSymbols(symbols, symbol_infos)) | |
| 33 self.assertEquals(matched_count, 3) | |
| 34 self.assertEquals(unmatched_count, 1) | |
| 35 | |
| 36 def testNoUnorderedSymbols(self): | |
| 37 symbol_infos = [ | |
| 38 symbol_extractor.SymbolInfo('first', 0x1, 0, ''), | |
| 39 symbol_extractor.SymbolInfo('second', 0x2, 0, ''), | |
| 40 symbol_extractor.SymbolInfo('third', 0x3, 0, ''), | |
| 41 symbol_extractor.SymbolInfo('notProfiled', 0x4, 0, '')] | |
| 42 symbols = ['first', 'other', 'second', 'third', 'noMatchEither'] | |
| 43 (misordered_pairs_count, _, _) = ( | |
| 44 check_orderfile._CountMisorderedSymbols(symbols, symbol_infos)) | |
| 45 self.assertEquals(misordered_pairs_count, 0) | |
| 46 | |
| 47 def testUnorderedSymbols(self): | |
| 48 symbol_infos = [ | |
| 49 symbol_extractor.SymbolInfo('first', 0x1, 0, ''), | |
| 50 symbol_extractor.SymbolInfo('second', 0x2, 0, ''), | |
| 51 symbol_extractor.SymbolInfo('third', 0x3, 0, ''), | |
| 52 symbol_extractor.SymbolInfo('notProfiled', 0x4, 0, '')] | |
| 53 symbols = ['first', 'other', 'third', 'second', 'noMatchEither'] | |
| 54 (misordered_pairs_count, _, _) = ( | |
| 55 check_orderfile._CountMisorderedSymbols(symbols, symbol_infos)) | |
| 56 self.assertEquals(misordered_pairs_count, 1) | |
| 57 | |
| 58 | |
| 59 if __name__ == '__main__': | |
| 60 unittest.main() | |
| OLD | NEW |