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

Unified Diff: tools/json_to_struct/struct_generator_test.py

Issue 1209733002: Add the ability to code generated prepopulated static nested structs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test Created 5 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/json_to_struct/struct_generator.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_to_struct/struct_generator_test.py
diff --git a/tools/json_to_struct/struct_generator_test.py b/tools/json_to_struct/struct_generator_test.py
index 8566c335bcd8b198ca03e5e0ba8ac914e2648163..bff5db73af89a778c267bedfe717e76f78beb3c7 100755
--- a/tools/json_to_struct/struct_generator_test.py
+++ b/tools/json_to_struct/struct_generator_test.py
@@ -54,5 +54,32 @@ class StructGeneratorTest(unittest.TestCase):
'};\n')
self.assertEquals(struct, GenerateStruct('MyTypeName', schema))
+ def testGenerateArrayOfStruct(self):
+ schema = [
+ {
+ 'type': 'array',
+ 'field': 'bar_bar',
+ 'contents': {
+ 'type': 'struct',
+ 'type_name': 'InnerTypeName',
+ 'fields': [
+ {'type': 'string', 'field': 'key'},
+ {'type': 'string', 'field': 'value'},
+ ]
+ }
+ }
+ ]
+ struct = (
+ 'struct InnerTypeName {\n'
+ ' const char* const key;\n'
+ ' const char* const value;\n'
+ '};\n'
+ '\n'
+ 'struct MyTypeName {\n'
+ ' const InnerTypeName * bar_bar;\n'
+ ' const size_t bar_bar_size;\n'
+ '};\n')
+ self.assertEquals(struct, GenerateStruct('MyTypeName', schema))
+
if __name__ == '__main__':
unittest.main()
« 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