1#!/usr/bin/env python 2# Copyright 2014 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 6import unittest 7 8from pylib.gtest import gtest_test_instance 9 10 11class GtestTestInstanceTests(unittest.TestCase): 12 13 def testParseGTestListTests_simple(self): 14 raw_output = [ 15 'TestCaseOne.', 16 ' testOne', 17 ' testTwo', 18 'TestCaseTwo.', 19 ' testThree', 20 ' testFour', 21 ] 22 actual = gtest_test_instance.ParseGTestListTests(raw_output) 23 expected = [ 24 'TestCaseOne.testOne', 25 'TestCaseOne.testTwo', 26 'TestCaseTwo.testThree', 27 'TestCaseTwo.testFour', 28 ] 29 self.assertEqual(expected, actual) 30 31 def testParseGTestListTests_typeParameterized_old(self): 32 raw_output = [ 33 'TPTestCase/WithTypeParam/0.', 34 ' testOne', 35 ' testTwo', 36 ] 37 actual = gtest_test_instance.ParseGTestListTests(raw_output) 38 expected = [ 39 'TPTestCase/WithTypeParam/0.testOne', 40 'TPTestCase/WithTypeParam/0.testTwo', 41 ] 42 self.assertEqual(expected, actual) 43 44 def testParseGTestListTests_typeParameterized_new(self): 45 raw_output = [ 46 'TPTestCase/WithTypeParam/0. # TypeParam = TypeParam0', 47 ' testOne', 48 ' testTwo', 49 ] 50 actual = gtest_test_instance.ParseGTestListTests(raw_output) 51 expected = [ 52 'TPTestCase/WithTypeParam/0.testOne', 53 'TPTestCase/WithTypeParam/0.testTwo', 54 ] 55 self.assertEqual(expected, actual) 56 57 def testParseGTestListTests_valueParameterized_old(self): 58 raw_output = [ 59 'VPTestCase.', 60 ' testWithValueParam/0', 61 ' testWithValueParam/1', 62 ] 63 actual = gtest_test_instance.ParseGTestListTests(raw_output) 64 expected = [ 65 'VPTestCase.testWithValueParam/0', 66 'VPTestCase.testWithValueParam/1', 67 ] 68 self.assertEqual(expected, actual) 69 70 def testParseGTestListTests_valueParameterized_new(self): 71 raw_output = [ 72 'VPTestCase.', 73 ' testWithValueParam/0 # GetParam() = 0', 74 ' testWithValueParam/1 # GetParam() = 1', 75 ] 76 actual = gtest_test_instance.ParseGTestListTests(raw_output) 77 expected = [ 78 'VPTestCase.testWithValueParam/0', 79 'VPTestCase.testWithValueParam/1', 80 ] 81 self.assertEqual(expected, actual) 82 83 84if __name__ == '__main__': 85 unittest.main(verbosity=2) 86 87