| OLD | NEW |
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 library message_generator_test; | 6 library message_generator_test; |
| 7 | 7 |
| 8 import 'package:protoc-plugin/src/descriptor.pb.dart'; | 8 import 'package:protoc_plugin/src/descriptor.pb.dart'; |
| 9 import 'package:protoc-plugin/src/plugin.pb.dart'; | 9 import 'package:protoc_plugin/src/plugin.pb.dart'; |
| 10 import 'package:protoc-plugin/protoc.dart'; | 10 import 'package:protoc_plugin/protoc.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 12 | 12 |
| 13 void main() { | 13 void main() { |
| 14 test('testMessageGenerator', () { | 14 test('testMessageGenerator', () { |
| 15 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. | 15 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. |
| 16 String expected = r''' | 16 String expected = r''' |
| 17 class PhoneNumber_PhoneType extends ProtobufEnum { | 17 class PhoneNumber_PhoneType extends ProtobufEnum { |
| 18 static const PhoneNumber_PhoneType MOBILE = const PhoneNumber_PhoneType._(0, '
MOBILE'); | 18 static const PhoneNumber_PhoneType MOBILE = const PhoneNumber_PhoneType._(0, '
MOBILE'); |
| 19 static const PhoneNumber_PhoneType HOME = const PhoneNumber_PhoneType._(1, 'HO
ME'); | 19 static const PhoneNumber_PhoneType HOME = const PhoneNumber_PhoneType._(1, 'HO
ME'); |
| 20 static const PhoneNumber_PhoneType WORK = const PhoneNumber_PhoneType._(2, 'WO
RK'); | 20 static const PhoneNumber_PhoneType WORK = const PhoneNumber_PhoneType._(2, 'WO
RK'); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 new FieldDescriptorProto() | 98 new FieldDescriptorProto() |
| 99 ..name = 'name' | 99 ..name = 'name' |
| 100 ..number = 3 | 100 ..number = 3 |
| 101 ..label = FieldDescriptorProto_Label.LABEL_OPTIONAL | 101 ..label = FieldDescriptorProto_Label.LABEL_OPTIONAL |
| 102 ..type = FieldDescriptorProto_Type.TYPE_STRING | 102 ..type = FieldDescriptorProto_Type.TYPE_STRING |
| 103 ..defaultValue = r'$' | 103 ..defaultValue = r'$' |
| 104 ]) | 104 ]) |
| 105 ..enumType.add(ed); | 105 ..enumType.add(ed); |
| 106 MemoryWriter buffer = new MemoryWriter(); | 106 MemoryWriter buffer = new MemoryWriter(); |
| 107 IndentingWriter writer = new IndentingWriter(' ', buffer); | 107 IndentingWriter writer = new IndentingWriter(' ', buffer); |
| 108 var options = | 108 var options = parseGenerationOptions( |
| 109 new GenerationOptions( | 109 new CodeGeneratorRequest(), new CodeGeneratorResponse()); |
| 110 new CodeGeneratorRequest(), new CodeGeneratorResponse()); | 110 var context = new GenerationContext(options, |
| 111 var context = new GenerationContext(options); | 111 new DefaultOutputConfiguration()); |
| 112 FileGenerator fg = new FileGenerator(fd, null, context); | 112 FileGenerator fg = new FileGenerator(fd, null, context); |
| 113 MessageGenerator mg = new MessageGenerator(md, fg, context); | 113 MessageGenerator mg = new MessageGenerator(md, fg, context); |
| 114 mg.initializeFields(); | 114 mg.initializeFields(); |
| 115 mg.generate(writer); | 115 mg.generate(writer); |
| 116 expect(buffer.toString(), expected); | 116 expect(buffer.toString(), expected); |
| 117 }); | 117 }); |
| 118 } | 118 } |
| OLD | NEW |