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

Unified Diff: tests/lib/src/crypto/sha256Test.dart

Issue 10174041: Increase test coverage for sha1 and sha256 by using standard test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
Index: tests/lib/src/crypto/sha256Test.dart
diff --git a/tests/lib/src/crypto/sha256Test.dart b/tests/lib/src/crypto/sha256Test.dart
index 5014806cb056fa7a372143c802e0f5c39ab6f2c0..ed59d20535cf9cd6d9585029949b47c9b7207786 100644
--- a/tests/lib/src/crypto/sha256Test.dart
+++ b/tests/lib/src/crypto/sha256Test.dart
@@ -5,6 +5,9 @@
// TODO(ager): Replace with "dart:crypto" when ready.
#import("../../../../lib/crypto/crypto.dart");
+#source('sha256_long_test_vectors.dart');
+#source('sha256_short_test_vectors.dart');
+
List<int> createTestArr(int len) {
var arr = new List<int>(len);
for (var i = 0; i < len; i++) {
@@ -295,8 +298,17 @@ void testInvalidUse() {
(e) => e is CryptoHashException);
}
+void testStandardVectors(inputs, mds) {
+ for (var i = 0; i < inputs.length; i++) {
+ var d = new SHA256().update(inputs[i]).digest();
+ Expect.equals(mds[i], digestToString(d), '$i');
+ }
+}
+
void main() {
test();
testInvalidUse();
+ testStandardVectors(sha256_long_inputs, sha256_long_mds);
+ testStandardVectors(sha256_short_inputs, sha256_short_mds);
}
« no previous file with comments | « tests/lib/src/crypto/sha1_short_test_vectors.dart ('k') | tests/lib/src/crypto/sha256_short_test_vectors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698