Skip to content

Commit 8b2513f

Browse files
committed
Allow running tests with --no-default-features
1 parent 9156a07 commit 8b2513f

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ jobs:
3232
- name: Run tests
3333
run: cargo test --verbose
3434

35+
test_no_default_features:
36+
runs-on: ubuntu-latest
37+
strategy:
38+
matrix:
39+
rust:
40+
- stable
41+
- beta
42+
- nightly
43+
steps:
44+
- uses: actions/checkout@v4
45+
- uses: dtolnay/rust-toolchain@master
46+
with:
47+
toolchain: ${{ matrix.rust }}
48+
- name: Build
49+
run: cargo build --no-default-features --verbose
50+
- name: Run tests
51+
run: cargo test --no-default-features --verbose
52+
3553
# We have to test the MSRV without the zip crate, since the zip crate has a higher MSRV and
3654
# doesn't consider a MSRV update to be a breaking change.
3755
test_msrv:

tests/integration/examples.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use ndarray_npy::{
77
write_zeroed_npy, ReadNpyError, ReadNpyExt, ViewMutNpyExt, ViewNpyError, ViewNpyExt,
88
WriteNpyExt,
99
};
10+
#[cfg(feature = "num-complex-0_4")]
1011
use num_complex_0_4::Complex;
1112
use std::fs::{self, File};
1213
use std::io::{Read, Seek, SeekFrom, Write};
@@ -29,6 +30,7 @@ fn write_f64_standard() {
2930
assert_eq!(&correct, &writer);
3031
}
3132

33+
#[cfg(feature = "num-complex-0_4")]
3234
#[test]
3335
fn write_c64_standard() {
3436
#[cfg(target_endian = "little")]
@@ -65,6 +67,7 @@ fn write_f64_fortran() {
6567
assert_eq!(&correct[..], &writer[..]);
6668
}
6769

70+
#[cfg(feature = "num-complex-0_4")]
6871
#[test]
6972
fn write_c64_fortran() {
7073
#[cfg(target_endian = "little")]
@@ -103,6 +106,7 @@ fn write_f64_discontiguous() {
103106
assert_eq!(&correct, &writer);
104107
}
105108

109+
#[cfg(feature = "num-complex-0_4")]
106110
#[test]
107111
fn write_c64_discontiguous() {
108112
#[cfg(target_endian = "little")]
@@ -141,6 +145,7 @@ fn read_f64_standard() {
141145
}
142146
}
143147

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

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

239+
#[cfg(feature = "num-complex-0_4")]
233240
#[test]
234241
fn view_c64_standard() {
235242
#[cfg(target_endian = "little")]
@@ -266,6 +273,7 @@ fn view_f64_fortran() {
266273
assert!(view.t().is_standard_layout());
267274
}
268275

276+
#[cfg(feature = "num-complex-0_4")]
269277
#[test]
270278
fn view_c64_fortran() {
271279
#[cfg(target_endian = "little")]

tests/integration/round_trip.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use ndarray_npy::{
77
ReadNpyExt, ReadableElement, ViewElement, ViewMutElement, ViewMutNpyExt, ViewNpyExt,
88
WritableElement, WriteNpyExt,
99
};
10+
#[cfg(feature = "num-complex-0_4")]
1011
use num_complex_0_4::Complex;
1112
use std::fmt::Debug;
1213
use std::mem;
@@ -149,6 +150,7 @@ fn round_trip_f64() {
149150
);
150151
}
151152

153+
#[cfg(feature = "num-complex-0_4")]
152154
#[test]
153155
fn round_trip_c32() {
154156
test_round_trip_multiple_layouts(

0 commit comments

Comments
 (0)