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

Unified Diff: test/mock_util.dart

Issue 1852983002: Fix issues with protobuf equality comparisons (Closed) Base URL: git@github.com:dart-lang/dart-protobuf.git@master
Patch Set: tweak _deepEquals, improve tests 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/message_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mock_util.dart
diff --git a/test/mock_util.dart b/test/mock_util.dart
index 8dc1c54067ffa2f94c66dc7d00e6ea3e3e5ce674..a5ac749f966db38e655809c5b7ff5831fd7f40ea 100644
--- a/test/mock_util.dart
+++ b/test/mock_util.dart
@@ -5,15 +5,20 @@
library mock_util;
import 'package:protobuf/protobuf.dart'
- show GeneratedMessage, BuilderInfo, PbFieldType;
+ show GeneratedMessage, BuilderInfo, CreateBuilderFunc, PbFieldType;
+
+BuilderInfo mockInfo(String className, CreateBuilderFunc create) {
+ return new BuilderInfo(className)
+ ..a(1, "val", PbFieldType.O3, 42)
+ ..a(2, "str", PbFieldType.OS)
+ ..a(3, "child", PbFieldType.OM, create, create)
+ ..p(4, "int32s", PbFieldType.P3);
+}
/// A minimal protobuf implementation for testing.
abstract class MockMessage extends GeneratedMessage {
- BuilderInfo _infoCache;
-
// subclasses must provide these
- String get className;
- MockMessage create();
+ BuilderInfo get info_;
int get val => $_get(0, 1, 42);
set val(x) => setField(1, x);
@@ -26,16 +31,8 @@ abstract class MockMessage extends GeneratedMessage {
List<int> get int32s => $_get(3, 4, null);
- @override
- BuilderInfo get info_ {
- if (_infoCache != null) return _infoCache;
- _infoCache = new BuilderInfo(className)
- ..a(1, "val", PbFieldType.O3, 42)
- ..a(2, "str", PbFieldType.OS)
- ..a(3, "child", PbFieldType.OM, create, create)
- ..p(4, "int32s", PbFieldType.P3);
- return _infoCache;
+ clone() {
+ CreateBuilderFunc create = info_.byName["child"].subBuilder;
+ return create()..mergeFromMessage(this);
}
-
- clone() => create()..mergeFromMessage(this);
}
« no previous file with comments | « test/message_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698