Skip to content

Commit 1dca437

Browse files
committed
test:hash: use temp dir method
1 parent e54c78f commit 1dca437

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

Readme.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Matlab or
1010
users coming from other languages will benefit from the functionality contained within this user-developed, unofficial "stdlib" standard library of functions.
1111
These system, filesystem, and HDF5 / HDF4 / NetCDF functions are used across numerous projects.
1212

13-
Matlab ≥ R2021a has full functionality.
13+
Matlab ≥ R2022a is required to run the self-test suite.
1414
Matlab R2019b is the minimum required due to use of
1515
[arguments](https://www.mathworks.com/help/matlab/ref/arguments.html)
1616
syntax.
@@ -21,10 +21,8 @@ Self-tests can be run from that matlab-stdlib/ directory:
2121
buildtool test
2222
```
2323

24-
## MEX C++
25-
26-
Several functions are sped up with C++ Matlab MEX build.
27-
A couple functions are only available with C++ MEX build.
24+
Functions requiring or optionally benefiting from MEX are indicated in the
25+
[API Documentation](https://geospace-code.github.io/matlab-stdlib).
2826

2927
```matlab
3028
buildtool mex
@@ -38,7 +36,6 @@ legacy_mex_build()
3836

3937
URLs (e.g. https://, s3:// and similar) are treated as not existing.
4038

41-
[API Documentation](https://geospace-code.github.io/matlab-stdlib)
4239

4340
## Java-based functions
4441

test/TestHash.m

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
classdef TestHash < matlab.unittest.TestCase
22

3+
properties
4+
Folder
5+
end
6+
37
properties (TestParameter)
48
type = {'sha256', 'md5'}
59
hash = {"36c1bbbdfd8d04ef546ffb15b9c0a65767fd1fe9a6135a257847e3a51fb1426c", "d58cfb32e075781ba59082a8b18287f9"}
@@ -11,14 +15,17 @@ function java_required(tc)
1115
end
1216
end
1317

18+
methods(TestMethodSetup)
19+
function setup_tempdir(tc)
20+
tc.Folder = stdlib.posix(tc.createTemporaryFolder());
21+
end
22+
end
23+
24+
1425
methods (Test, ParameterCombination = 'sequential')
1526

1627
function test_extract(tc)
1728
import matlab.unittest.constraints.IsFile
18-
import matlab.unittest.fixtures.TemporaryFolderFixture
19-
20-
fixture = tc.applyFixture(TemporaryFolderFixture);
21-
tmpDir = fixture.Folder;
2229

2330
r = fileparts(mfilename('fullpath'));
2431
fn = stdlib.posix(r) + "/hello.tar.zst";
@@ -27,8 +34,8 @@ function test_extract(tc)
2734

2835
tc.assumeNotEmpty(stdlib.which("cmake"), "CMake not available")
2936

30-
stdlib.extract_zstd(fn, tmpDir)
31-
tc.verifyThat(stdlib.posix(tmpDir) + "/test/hello.txt", IsFile)
37+
stdlib.extract_zstd(fn, tc.Folder)
38+
tc.verifyThat( tc.Folder + "/test/hello.txt", IsFile)
3239

3340
end
3441

@@ -50,14 +57,14 @@ function test_hash(tc, type, hash)
5057

5158
function test_hash_text(tc)
5259
import matlab.unittest.constraints.IsFile
53-
import matlab.unittest.fixtures.TemporaryFolderFixture
54-
fixture = tc.applyFixture(TemporaryFolderFixture);
5560

56-
fn = stdlib.posix(fixture.Folder) + "/hello";
61+
fn = tc.Folder + "/hello";
5762
fid = fopen(fn, "w");
63+
tc.addTeardown(@fclose, fid)
64+
5865
tc.assumeGreaterThan(fid, 0);
5966
fprintf(fid, "hello");
60-
fclose(fid);
67+
6168
tc.assumeThat(fn, IsFile)
6269

6370
tc.verifyEqual(stdlib.file_checksum(fn, "md5"), "5d41402abc4b2a76b9719d911017c592")

0 commit comments

Comments
 (0)