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 enum_generator_test; | 6 library enum_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('testEnumGenerator', () { | 14 test('testEnumGenerator', () { |
15 String expected = r''' | 15 String expected = r''' |
16 class PhoneType extends ProtobufEnum { | 16 class PhoneType extends ProtobufEnum { |
17 static const PhoneType MOBILE = const PhoneType._(0, 'MOBILE'); | 17 static const PhoneType MOBILE = const PhoneType._(0, 'MOBILE'); |
18 static const PhoneType HOME = const PhoneType._(1, 'HOME'); | 18 static const PhoneType HOME = const PhoneType._(1, 'HOME'); |
19 static const PhoneType WORK = const PhoneType._(2, 'WORK'); | 19 static const PhoneType WORK = const PhoneType._(2, 'WORK'); |
20 | 20 |
(...skipping 22 matching lines...) Expand all Loading... |
43 ..name = 'HOME' | 43 ..name = 'HOME' |
44 ..number = 1, | 44 ..number = 1, |
45 new EnumValueDescriptorProto() | 45 new EnumValueDescriptorProto() |
46 ..name = 'WORK' | 46 ..name = 'WORK' |
47 ..number = 2, | 47 ..number = 2, |
48 new EnumValueDescriptorProto() | 48 new EnumValueDescriptorProto() |
49 ..name = 'BUSINESS' | 49 ..name = 'BUSINESS' |
50 ..number = 2]); | 50 ..number = 2]); |
51 MemoryWriter buffer = new MemoryWriter(); | 51 MemoryWriter buffer = new MemoryWriter(); |
52 IndentingWriter writer = new IndentingWriter(' ', buffer); | 52 IndentingWriter writer = new IndentingWriter(' ', buffer); |
53 var options = | 53 var options = parseGenerationOptions( |
54 new GenerationOptions( | 54 new CodeGeneratorRequest(), new CodeGeneratorResponse()); |
55 new CodeGeneratorRequest(), new CodeGeneratorResponse()); | 55 EnumGenerator eg = new EnumGenerator(ed, null, |
56 EnumGenerator eg = | 56 new GenerationContext(options, new DefaultOutputConfiguration())); |
57 new EnumGenerator( | |
58 ed, null, new GenerationContext(options)); | |
59 eg.generate(writer); | 57 eg.generate(writer); |
60 expect(buffer.toString(), expected); | 58 expect(buffer.toString(), expected); |
61 }); | 59 }); |
62 } | 60 } |
OLD | NEW |