From 332991c0df775c1e02ac7cc46d4b83721f114abc Mon Sep 17 00:00:00 2001 From: Evangelos Paterakis Date: Sun, 12 Nov 2023 08:33:53 +0200 Subject: [PATCH] feat(spec): check individual hashes --- spec/compare_spec.cr | 2 +- spec/hash_generator_spec.cr | 4 +++- spec/spec_helper.cr | 14 +++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/spec/compare_spec.cr b/spec/compare_spec.cr index 9e462be..11ed11c 100644 --- a/spec/compare_spec.cr +++ b/spec/compare_spec.cr @@ -3,6 +3,6 @@ require "../src/collision/functions/file_utils.cr" describe Collision::FileUtils do it "returns whether the file contains one of the hashes" do - Collision::FileUtils.compare_content(Path[__DIR__] / "test_content.txt", Collision::CLIPBOARD_HASH.values.to_a).should be_true + Collision::FileUtils.compare_content(Path[__DIR__] / "test_content.txt", Collision::CLIPBOARD_HASH.values).should be_true end end diff --git a/spec/hash_generator_spec.cr b/spec/hash_generator_spec.cr index 3c78e53..e6a649a 100644 --- a/spec/hash_generator_spec.cr +++ b/spec/hash_generator_spec.cr @@ -18,7 +18,9 @@ describe Collision::Checksum do break if Collision::CLIPBOARD_HASH.size == hashes.size || Time.utc.to_unix_ms - safe_stop > 3000 end - hashes.should eq(Collision::CLIPBOARD_HASH.to_h) + Collision::CLIPBOARD_HASH.each do |k, v| + {k, hashes[k]}.should eq({k, v}) + end end it "splits strings by 4" do diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr index 0653471..a69ca80 100644 --- a/spec/spec_helper.cr +++ b/spec/spec_helper.cr @@ -15,12 +15,12 @@ module Collision adler32: "Adler32", } CLIPBOARD_HASH = { - md5: "f7e3f382f0382147661c82af20e274e8", - sha1: "c8f0b71214e8164aa69419b7ac0bcd8a74f529a6", - sha256: "08e3dfc089e66c44ae8abd3476b0f810f11f4cfc2ab925f1607c7df21345d639", - sha512: "2ddb9cca7753a01fcbcdbacc228ae8c314ff4e735c6fffb42286272fb460930dc74f122a9f365053a13016b22403ad4e192142e8668bc5f7d6fce865eb38ec2c", - blake3: "8a69892f0946333dbf909ecb68866d2f7116b7ba18ee7f2421afd705f9383cfc", - crc32: "592339ec", - adler32: "1ba80397", + :md5 => "f7e3f382f0382147661c82af20e274e8", + :sha1 => "c8f0b71214e8164aa69419b7ac0bcd8a74f529a6", + :sha256 => "08e3dfc089e66c44ae8abd3476b0f810f11f4cfc2ab925f1607c7df21345d639", + :sha512 => "2ddb9cca7753a01fcbcdbacc228ae8c314ff4e735c6fffb42286272fb460930dc74f122a9f365053a13016b22403ad4e192142e8668bc5f7d6fce865eb38ec2c", + :blake3 => "8a69892f0946333dbf909ecb68866d2f7116b7ba18ee7f2421afd705f9383cfc", + :crc32 => "592339ec", + :adler32 => "1ba80397", } end