Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Side by Side Diff: tools/json_to_struct/struct_generator_test.py

Issue 11293291: Revert 167793 - Moving prepopulated search engines to a JSON file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/json_to_struct/struct_generator.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 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 from struct_generator import GenerateField
7 from struct_generator import GenerateStruct
8 import unittest
9
10 class StructGeneratorTest(unittest.TestCase):
11 def testGenerateIntField(self):
12 self.assertEquals('const int foo_bar',
13 GenerateField({'type': 'int', 'field': 'foo_bar'}))
14
15 def testGenerateStringField(self):
16 self.assertEquals('const char* const bar_foo',
17 GenerateField({'type': 'string', 'field': 'bar_foo'}))
18
19 def testGenerateString16Field(self):
20 self.assertEquals('const wchar_t* const foo_bar',
21 GenerateField({'type': 'string16', 'field': 'foo_bar'}))
22
23 def testGenerateEnumField(self):
24 self.assertEquals('const MyEnumType foo_foo',
25 GenerateField({'type': 'enum',
26 'field': 'foo_foo',
27 'ctype': 'MyEnumType'}))
28
29 def testGenerateArrayField(self):
30 self.assertEquals('const int * bar_bar;\n'
31 ' const size_t bar_bar_size',
32 GenerateField({'type': 'array',
33 'field': 'bar_bar',
34 'contents': {'type': 'int'}}))
35
36 def testGenerateStruct(self):
37 schema = [
38 {'type': 'int', 'field': 'foo_bar'},
39 {'type': 'string', 'field': 'bar_foo', 'default': 'dummy'},
40 {
41 'type': 'array',
42 'field': 'bar_bar',
43 'contents': {
44 'type': 'enum',
45 'ctype': 'MyEnumType'
46 }
47 }
48 ]
49 struct = ('struct MyTypeName {\n'
50 ' const int foo_bar;\n'
51 ' const char* const bar_foo;\n'
52 ' const MyEnumType * bar_bar;\n'
53 ' const size_t bar_bar_size;\n'
54 '};\n')
55 self.assertEquals(struct, GenerateStruct('MyTypeName', schema))
56
57 if __name__ == '__main__':
58 unittest.main()
OLDNEW
« no previous file with comments | « tools/json_to_struct/struct_generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698