forked from dart-archive/dart-protoc-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprotoc_options_test.dart
42 lines (36 loc) · 1.3 KB
/
protoc_options_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library protoc_options_test;
import 'package:protoc_plugin/src/plugin.pb.dart';
import 'package:protoc_plugin/protoc.dart';
import 'package:test/test.dart';
void main() {
test('testValidGeneratorOptions', () {
checkValid(String parameter) {
var request = new CodeGeneratorRequest();
if (parameter != null) request.parameter = parameter;
var response = new CodeGeneratorResponse();
var options = parseGenerationOptions(request, response);
expect(options, new TypeMatcher<GenerationOptions>());
expect(response.error, '');
}
checkValid(null);
checkValid('');
checkValid(',');
checkValid(',,,');
checkValid(' , , ,');
});
test('testInvalidGeneratorOptions', () {
checkInvalid(String parameter) {
var request = new CodeGeneratorRequest();
if (parameter != null) request.parameter = parameter;
var response = new CodeGeneratorResponse();
var options = parseGenerationOptions(request, response);
expect(options, isNull);
}
checkInvalid('abc');
checkInvalid('abc,def');
});
}