Skip to content

Commit

Permalink
fix(test): guess storage format based on extension regardless of trai…
Browse files Browse the repository at this point in the history
…ling separator
  • Loading branch information
cmhulbert committed Mar 4, 2024
1 parent 42f76f8 commit 05cb1a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,8 @@ enum KeyValueAccessBackend implements Predicate<URI>, BiFunction<URI, N5Factory,
}

public enum StorageFormat {
ZARR(Pattern.compile("zarr", Pattern.CASE_INSENSITIVE), uri -> Pattern.compile("\\.zarr$", Pattern.CASE_INSENSITIVE).matcher(uri.getPath()).find()),
N5(Pattern.compile("n5", Pattern.CASE_INSENSITIVE), uri -> Pattern.compile("\\.n5$", Pattern.CASE_INSENSITIVE).matcher(uri.getPath()).find()),
ZARR(Pattern.compile("zarr", Pattern.CASE_INSENSITIVE), uri -> Pattern.compile("\\.zarr(" + FileSystems.getDefault().getSeparator() + ")?$", Pattern.CASE_INSENSITIVE).matcher(uri.getPath()).find()),
N5(Pattern.compile("n5", Pattern.CASE_INSENSITIVE), uri -> Pattern.compile("\\.n5(" + FileSystems.getDefault().getSeparator() + ")?$", Pattern.CASE_INSENSITIVE).matcher(uri.getPath()).find()),
HDF5(Pattern.compile("h(df)?5", Pattern.CASE_INSENSITIVE), uri -> {
final boolean hasHdf5Extension = Pattern.compile("\\.h(df)?5$", Pattern.CASE_INSENSITIVE).matcher(uri.getPath()).find();
return hasHdf5Extension || HDF5Utils.isHDF5(uri.getPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;

Expand Down Expand Up @@ -85,8 +86,9 @@ public void testWriterTypeByExtension() {

final String[] ext = new String[]{".h5", ".hdf5", ".n5", ".n5", ".zarr", ".zarr"};

// necessary because new File() removes trailing slash
final String[] trailing = new String[]{"", "", "", "/", "", "/"};
// necessary because new File() removes trailing separator
final String separator = FileSystems.getDefault().getSeparator();
final String[] trailing = new String[]{"", "", "", separator, "", separator};

final Class<?>[] readerTypes = new Class[]{
N5HDF5Writer.class,
Expand Down

0 comments on commit 05cb1a2

Please sign in to comment.