diff --git a/test/dart_kollection_test.dart b/test/dart_kollection_test.dart index 63f387a7..29f09263 100644 --- a/test/dart_kollection_test.dart +++ b/test/dart_kollection_test.dart @@ -18,6 +18,8 @@ import 'collections_test.dart' as collections_test; import 'comparisons_test.dart' as comparisons_test; import 'exceptions_test.dart' as exceptions_test; import 'tuples_test.dart' as tuples_test; +import 'util/annotation_test.dart' as annotation_test; +import 'util/hash_test.dart' as hash_test; void main() { collection_mutable_test.main(); @@ -38,4 +40,6 @@ void main() { comparisons_test.main(); exceptions_test.main(); tuples_test.main(); + annotation_test.main(); + hash_test.main(); } diff --git a/test/util/annotation_test.dart b/test/util/annotation_test.dart new file mode 100644 index 00000000..81ea2177 --- /dev/null +++ b/test/util/annotation_test.dart @@ -0,0 +1,19 @@ +import 'package:dart_kollection/src/util/annotations.dart'; +import 'package:test/test.dart'; + +void main() { + test("nullable is _Nullable", () { + expect(nullable.runtimeType.toString(), equals("_Nullable")); + }); + test("nonNull is _NonNull", () { + expect(nonNull.runtimeType.toString(), equals("_NonNull")); + }); + test("tooGeneric is TooGeneric", () { + expect(tooGeneric, equals(const TypeMatcher())); + }); + test("TooGeneric has extensionForType property", () { + const annotation = TooGeneric(extensionForType: "SomeType"); + expect(annotation, equals(const TypeMatcher())); + expect(annotation.extensionForType, equals("SomeType")); + }); +} diff --git a/test/util/hash_test.dart b/test/util/hash_test.dart new file mode 100644 index 00000000..8a474da4 --- /dev/null +++ b/test/util/hash_test.dart @@ -0,0 +1,23 @@ +import 'package:dart_kollection/src/util/hash.dart'; +import 'package:test/test.dart'; + +void main() { + test("hash2", () { + expect(hash2("foo", "bar"), equals(422905972)); + expect(hashObjects(["foo", "bar"]), equals(422905972)); + expect(hash2("bar", "foo"), equals(293502445)); + expect(hashObjects(["bar", "foo"]), equals(293502445)); + }); + test("hash3", () { + expect(hash3("foo", "bar", "baz"), equals(247754790)); + expect(hashObjects(["foo", "bar", "baz"]), equals(247754790)); + expect(hash3("baz", "bar", "foo"), equals(413548564)); + expect(hashObjects(["baz", "bar", "foo"]), equals(413548564)); + }); + test("hash4", () { + expect(hash4("foo", "bar", "baz", "qux"), equals(263375993)); + expect(hashObjects(["foo", "bar", "baz", "qux"]), equals(263375993)); + expect(hash4("baz", "bar", "foo", "qux"), equals(264235936)); + expect(hashObjects(["baz", "bar", "foo", "qux"]), equals(264235936)); + }); +}