Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test util package #53

Merged
merged 2 commits into from
Jan 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/dart_kollection_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -38,4 +40,6 @@ void main() {
comparisons_test.main();
exceptions_test.main();
tuples_test.main();
annotation_test.main();
hash_test.main();
}
19 changes: 19 additions & 0 deletions test/util/annotation_test.dart
Original file line number Diff line number Diff line change
@@ -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<TooGeneric>()));
});
test("TooGeneric has extensionForType property", () {
const annotation = TooGeneric(extensionForType: "SomeType");
expect(annotation, equals(const TypeMatcher<TooGeneric>()));
expect(annotation.extensionForType, equals("SomeType"));
});
}
23 changes: 23 additions & 0 deletions test/util/hash_test.dart
Original file line number Diff line number Diff line change
@@ -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));
});
}