Skip to content

Commit 3d1b379

Browse files
committed
remove extract_zstd
it was moved to https://github.com/gemini3d/mat_gemini
1 parent ee712a0 commit 3d1b379

File tree

4 files changed

+16
-90
lines changed

4 files changed

+16
-90
lines changed

+stdlib/extract_zstd.m

Lines changed: 0 additions & 46 deletions
This file was deleted.

+stdlib/file_checksum.m

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
method (1,1) string
1818
end
1919

20-
hash = [];
21-
22-
if stdlib.is_url(file), return, end
20+
try
21+
hash = string.empty;
22+
catch
23+
hash = [];
24+
end
2325

2426
if strcmp(method, "sha256") || strcmp(method, "SHA256")
2527
method = "SHA-256";
@@ -34,7 +36,11 @@
3436
end
3537

3638
fid = fopen(file, 'r');
37-
if fid < 1, return, end
39+
if fid < 1
40+
warning(strcat("could not open ", file))
41+
return
42+
end
43+
disp(strcat("computing ", method, " hash of ", file))
3844

3945
while ~feof(fid)
4046
% https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/MessageDigest.html#update(byte)

test/TestHash.m

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
classdef TestHash < matlab.unittest.TestCase
22

33
properties (TestParameter)
4-
type = {'sha256', 'md5'}
5-
hash = {"36c1bbbdfd8d04ef546ffb15b9c0a65767fd1fe9a6135a257847e3a51fb1426c", "d58cfb32e075781ba59082a8b18287f9"}
4+
Ph = {{"md5", "5d41402abc4b2a76b9719d911017c592"}, {"sha-256", "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"}}
65
Pe = {"", "/"}
76
end
87

@@ -13,57 +12,24 @@ function java_required(tc)
1312
end
1413

1514

16-
methods (Test, ParameterCombination = 'sequential')
17-
18-
function test_extract(tc)
19-
import matlab.unittest.constraints.IsFile
20-
21-
r = fileparts(mfilename('fullpath'));
22-
fn = stdlib.posix(r) + "/hello.tar.zst";
23-
24-
tc.assumeThat(fn, IsFile)
25-
26-
tc.assumeNotEmpty(stdlib.which("cmake"), "CMake not available")
27-
28-
td = stdlib.posix(tc.createTemporaryFolder());
29-
30-
stdlib.extract_zstd(fn, td)
31-
tc.verifyThat(td + "/test/hello.txt", IsFile)
32-
33-
end
34-
35-
36-
function test_hash(tc, type, hash)
37-
38-
r = fileparts(mfilename('fullpath'));
39-
fn = fullfile(r, "hello.tar.zst");
40-
41-
switch type
42-
case 'sha256', h = stdlib.sha256sum(fn);
43-
case 'md5', h = stdlib.md5sum(fn);
44-
end
45-
46-
tc.verifyEqual(h, hash)
47-
48-
end
15+
methods (Test)
4916

5017

51-
function test_hash_text(tc)
18+
function test_hash_text(tc, Ph)
5219
import matlab.unittest.constraints.IsFile
5320

54-
td = stdlib.posix(tc.createTemporaryFolder());
21+
td = tc.createTemporaryFolder();
5522

5623
fn = td + "/hello";
5724
fid = fopen(fn, "w");
58-
tc.addTeardown(@fclose, fid)
5925

6026
tc.assumeGreaterThan(fid, 0);
6127
fprintf(fid, "hello");
28+
fclose(fid);
6229

6330
tc.assumeThat(fn, IsFile)
6431

65-
tc.verifyEqual(stdlib.file_checksum(fn, "md5"), "5d41402abc4b2a76b9719d911017c592")
66-
tc.verifyEqual(stdlib.file_checksum(fn, "sha256"), "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824")
32+
tc.verifyEqual(stdlib.file_checksum(fn, Ph{1}), Ph{2})
6733

6834
end
6935

test/hello.tar.zst

-121 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)