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

Side by Side Diff: test/enum_generator_test.dart

Issue 1829573002: Fix all strong mode warnings in protoc-plugin (Closed) Base URL: git@github.com:dart-lang/dart-protoc-plugin.git@master
Patch Set: regenerate pb.dart files Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « test/bazel_test.dart ('k') | test/file_generator_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/indenting_writer.dart'; 8 import 'package:protoc_plugin/indenting_writer.dart';
9 import 'package:protoc_plugin/protoc.dart'; 9 import 'package:protoc_plugin/protoc.dart';
10 import 'package:protoc_plugin/src/descriptor.pb.dart'; 10 import 'package:protoc_plugin/src/descriptor.pb.dart';
11 import 'package:test/test.dart'; 11 import 'package:test/test.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
21 static const PhoneType BUSINESS = WORK; 21 static const PhoneType BUSINESS = WORK;
22 22
23 static const List<PhoneType> values = const <PhoneType> [ 23 static const List<PhoneType> values = const <PhoneType> [
24 MOBILE, 24 MOBILE,
25 HOME, 25 HOME,
26 WORK, 26 WORK,
27 ]; 27 ];
28 28
29 static final Map<int, PhoneType> _byValue = ProtobufEnum.initByValue(values); 29 static final Map<int, dynamic> _byValue = ProtobufEnum.initByValue(values);
30 static PhoneType valueOf(int value) => _byValue[value]; 30 static PhoneType valueOf(int value) => _byValue[value] as PhoneType;
31 static void $checkItem(PhoneType v) { 31 static void $checkItem(PhoneType v) {
32 if (v is !PhoneType) checkItemFailed(v, 'PhoneType'); 32 if (v is !PhoneType) checkItemFailed(v, 'PhoneType');
33 } 33 }
34 34
35 const PhoneType._(int v, String n) : super(v, n); 35 const PhoneType._(int v, String n) : super(v, n);
36 } 36 }
37 37
38 '''; 38 ''';
39 EnumDescriptorProto ed = new EnumDescriptorProto() 39 EnumDescriptorProto ed = new EnumDescriptorProto()
40 ..name = 'PhoneType' 40 ..name = 'PhoneType'
41 ..value.addAll([ 41 ..value.addAll([
42 new EnumValueDescriptorProto() 42 new EnumValueDescriptorProto()
43 ..name = 'MOBILE' 43 ..name = 'MOBILE'
44 ..number = 0, 44 ..number = 0,
45 new EnumValueDescriptorProto() 45 new EnumValueDescriptorProto()
46 ..name = 'HOME' 46 ..name = 'HOME'
47 ..number = 1, 47 ..number = 1,
48 new EnumValueDescriptorProto() 48 new EnumValueDescriptorProto()
49 ..name = 'WORK' 49 ..name = 'WORK'
50 ..number = 2, 50 ..number = 2,
51 new EnumValueDescriptorProto() 51 new EnumValueDescriptorProto()
52 ..name = 'BUSINESS' 52 ..name = 'BUSINESS'
53 ..number = 2]); 53 ..number = 2
54 ]);
54 IndentingWriter writer = new IndentingWriter(); 55 IndentingWriter writer = new IndentingWriter();
55 EnumGenerator eg = new EnumGenerator(ed, null); 56 EnumGenerator eg = new EnumGenerator(ed, null);
56 eg.generate(writer); 57 eg.generate(writer);
57 expect(writer.toString(), expected); 58 expect(writer.toString(), expected);
58 }); 59 });
59 } 60 }
OLDNEW
« no previous file with comments | « test/bazel_test.dart ('k') | test/file_generator_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698