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

Unified Diff: test/message_test.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/map_mixin_test.dart ('k') | test/mock_util.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/message_test.dart
diff --git a/test/message_test.dart b/test/message_test.dart
index 62af81c3e0c1a018d3530e0113431fb94ef12ec3..4a541d77905daf4d8a0e67cd91bba57ceefbb121 100644
--- a/test/message_test.dart
+++ b/test/message_test.dart
@@ -7,19 +7,19 @@ library message_test;
import 'package:test/test.dart' show test, expect, predicate, throwsA;
-import 'mock_util.dart' show MockMessage;
+import 'mock_util.dart' show MockMessage, mockInfo;
class Rec extends MockMessage {
- get className => "Rec";
- Rec create() => new Rec();
+ get info_ => _info;
+ static final _info = mockInfo("Rec", () => new Rec());
}
-throwsError(Type expectedType, String expectedMessage) => throwsA(
- predicate((x) {
- expect(x.runtimeType, expectedType);
- expect(x.message, expectedMessage);
- return true;
-}));
+throwsError(Type expectedType, String expectedMessage) =>
+ throwsA(predicate((x) {
+ expect(x.runtimeType, expectedType);
+ expect(x.message, expectedMessage);
+ return true;
+ }));
main() {
test('getField with invalid tag throws exception', () {
@@ -35,4 +35,26 @@ main() {
r.getDefaultForField(123);
}, throwsError(ArgumentError, "tag 123 not defined in Rec"));
});
+
+ test('operator== and hashCode work for a simple record', () {
+ var a = new Rec();
+ expect(a == a, true);
+
+ var b = new Rec();
+ expect(a.info_ == b.info_, true, reason: "BuilderInfo should be the same");
+ expect(a == b, true);
+ expect(a.hashCode, b.hashCode);
+
+ a.val = 123;
+ expect(a == b, false);
+ b.val = 123;
+ expect(a == b, true);
+ expect(a.hashCode, b.hashCode);
+
+ a.child = new Rec();
+ expect(a == b, false);
+ b.child = new Rec();
+ expect(a == b, true);
+ expect(a.hashCode, b.hashCode);
+ });
}
« no previous file with comments | « test/map_mixin_test.dart ('k') | test/mock_util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698