OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import unittest | 5 import unittest |
6 | 6 |
7 import module as mojom | 7 import module as mojom |
8 import generator | 8 import generator |
9 | 9 |
10 class TestGenerator(unittest.TestCase): | 10 class TestGenerator(unittest.TestCase): |
11 | 11 |
12 def testGetUnionsAddsOrdinals(self): | 12 def testGetUnionsAddsOrdinals(self): |
13 module = mojom.Module() | 13 module = mojom.Module() |
14 union = module.AddUnion('a') | 14 union = module.AddUnion('a') |
15 union.AddField('a', mojom.BOOL) | 15 union.AddField('a', mojom.BOOL) |
16 union.AddField('b', mojom.BOOL) | 16 union.AddField('b', mojom.BOOL) |
17 union.AddField('c', mojom.BOOL, ordinal=10) | 17 union.AddField('c', mojom.BOOL, ordinal=10) |
18 union.AddField('d', mojom.BOOL) | 18 union.AddField('d', mojom.BOOL) |
19 | 19 |
20 gen = generator.Generator(module) | 20 gen = generator.Generator(module) |
21 union = gen.GetUnions()[0] | 21 union = gen.GetUnions()[0] |
22 ordinals = [field.ordinal for field in union.fields] | 22 ordinals = [field.ordinal for field in union.fields] |
23 | 23 |
24 self.assertEquals([0, 1, 10, 11], ordinals) | 24 self.assertEquals([0, 1, 10, 11], ordinals) |
OLD | NEW |