Skip to content

Commit

Permalink
Allow running tests with --no-default-features (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
jturner314 authored Sep 14, 2024
1 parent 08bef59 commit dd0dc26
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@ jobs:
- name: Run tests
run: cargo test --verbose

test_no_default_features:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- beta
- nightly
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Build
run: cargo build --no-default-features --verbose
- name: Run tests
run: cargo test --no-default-features --verbose

# We have to test the MSRV without the zip crate, since the zip crate has a higher MSRV and
# doesn't consider a MSRV update to be a breaking change.
test_msrv:
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use ndarray_npy::{
write_zeroed_npy, ReadNpyError, ReadNpyExt, ViewMutNpyExt, ViewNpyError, ViewNpyExt,
WriteNpyExt,
};
#[cfg(feature = "num-complex-0_4")]
use num_complex_0_4::Complex;
use std::fs::{self, File};
use std::io::{Read, Seek, SeekFrom, Write};
Expand All @@ -29,6 +30,7 @@ fn write_f64_standard() {
assert_eq!(&correct, &writer);
}

#[cfg(feature = "num-complex-0_4")]
#[test]
fn write_c64_standard() {
#[cfg(target_endian = "little")]
Expand Down Expand Up @@ -65,6 +67,7 @@ fn write_f64_fortran() {
assert_eq!(&correct[..], &writer[..]);
}

#[cfg(feature = "num-complex-0_4")]
#[test]
fn write_c64_fortran() {
#[cfg(target_endian = "little")]
Expand Down Expand Up @@ -103,6 +106,7 @@ fn write_f64_discontiguous() {
assert_eq!(&correct, &writer);
}

#[cfg(feature = "num-complex-0_4")]
#[test]
fn write_c64_discontiguous() {
#[cfg(target_endian = "little")]
Expand Down Expand Up @@ -141,6 +145,7 @@ fn read_f64_standard() {
}
}

#[cfg(feature = "num-complex-0_4")]
#[test]
fn read_c64_standard() {
let mut correct = Array3::<Complex<f64>>::zeros((2, 3, 4));
Expand Down Expand Up @@ -175,6 +180,7 @@ fn read_f64_fortran() {
}
}

#[cfg(feature = "num-complex-0_4")]
#[test]
fn read_c64_fortran() {
let mut correct = Array3::<Complex<f64>>::zeros((2, 3, 4).f());
Expand Down Expand Up @@ -230,6 +236,7 @@ fn view_f64_standard() {
assert!(view.is_standard_layout());
}

#[cfg(feature = "num-complex-0_4")]
#[test]
fn view_c64_standard() {
#[cfg(target_endian = "little")]
Expand Down Expand Up @@ -266,6 +273,7 @@ fn view_f64_fortran() {
assert!(view.t().is_standard_layout());
}

#[cfg(feature = "num-complex-0_4")]
#[test]
fn view_c64_fortran() {
#[cfg(target_endian = "little")]
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/round_trip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use ndarray_npy::{
ReadNpyExt, ReadableElement, ViewElement, ViewMutElement, ViewMutNpyExt, ViewNpyExt,
WritableElement, WriteNpyExt,
};
#[cfg(feature = "num-complex-0_4")]
use num_complex_0_4::Complex;
use std::fmt::Debug;
use std::mem;
Expand Down Expand Up @@ -149,6 +150,7 @@ fn round_trip_f64() {
);
}

#[cfg(feature = "num-complex-0_4")]
#[test]
fn round_trip_c32() {
test_round_trip_multiple_layouts(
Expand Down

0 comments on commit dd0dc26

Please sign in to comment.