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

Unified Diff: test/sha1_test.dart

Issue 1355223002: Change Hash subclasses to be Converters. (Closed) Base URL: git@github.com:dart-lang/crypto.git@master
Patch Set: Code review changes Created 5 years, 3 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:
Download patch
« no previous file with comments | « lib/src/sha256.dart ('k') | test/sha256_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/sha1_test.dart
diff --git a/test/sha1_test.dart b/test/sha1_test.dart
index e76c9aeb8badd714c84813f6e5b7b19568932fa8..e3471c32eb118e2bd28d2644efae23602f0af7ac 100644
--- a/test/sha1_test.dart
+++ b/test/sha1_test.dart
@@ -2,33 +2,48 @@
// 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 tag to allow dartium to run the test.
-library sha1_test;
+import "dart:async";
import "package:crypto/crypto.dart";
import "package:test/test.dart";
void main() {
- test('add may not be called after close', () {
- var sha = new SHA1();
- sha.close();
- expect(() => sha.add([0]), throwsStateError);
+ group("with the old API", () {
+ test('add may not be called after close', () {
+ var sha = new SHA1();
+ sha.close();
+ expect(() => sha.add([0]), throwsStateError);
+ });
+
+ test('close returns the same digest repeatedly', () {
+ var sha = new SHA1();
+ var digest = sha.close();
+ expect(sha.close(), equals(digest));
+ expect(sha.close(), equals(digest));
+ expect(sha.close(), equals(digest));
+ });
});
- test('close returns the same digest repeatedly', () {
- var sha = new SHA1();
- var digest = sha.close();
- expect(sha.close(), equals(digest));
- expect(sha.close(), equals(digest));
- expect(sha.close(), equals(digest));
+ group("with a chunked converter", () {
+ test('add may not be called after close', () {
+ var sink = sha1.startChunkedConversion(new StreamController().sink);
+ sink.close();
+ expect(() => sink.add([0]), throwsStateError);
+ });
+
+ test('close may be called multiple times', () {
+ var sink = sha1.startChunkedConversion(new StreamController().sink);
+ sink.close();
+ sink.close();
+ sink.close();
+ sink.close();
+ });
});
group("standard vector", () {
for (var i = 0; i < _inputs.length; i++) {
test(_digests[i], () {
- var hash = new SHA1();
- hash.add(_inputs[i]);
- expect(CryptoUtils.bytesToHex(hash.close()), equals(_digests[i]));
+ expect(sha1.convert(_inputs[i]).toString(), equals(_digests[i]));
});
}
});
« no previous file with comments | « lib/src/sha256.dart ('k') | test/sha256_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698