Skip to content

Commit

Permalink
refactor: vertex_index_common: elide tests alloc. w/ `Itertools::…
Browse files Browse the repository at this point in the history
…cartesian_product`
  • Loading branch information
ErichDonGubler committed Jul 4, 2024
1 parent 0d448cf commit 08128fd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ getrandom = "0.2"
glam = "0.27"
heck = "0.5.0"
image = { version = "0.24", default-features = false, features = ["png"] }
itertools = { version = "0.10.5" }
ktx2 = "0.3"
libc = "0.2"
# libloading 0.8 switches from `winapi` to `windows-sys`; permit either
Expand Down
3 changes: 2 additions & 1 deletion tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ bytemuck.workspace = true
cfg-if.workspace = true
ctor.workspace = true
futures-lite.workspace = true
itertools.workspace = true
libtest-mimic.workspace = true
log.workspace = true
parking_lot.workspace = true
Expand All @@ -37,7 +38,7 @@ serde_json.workspace = true
serde.workspace = true
strum = { workspace = true, features = ["derive"] }
wgpu-macros.workspace = true
wgpu.workspace = true
wgpu = { workspace = true, features = ["wgsl"] }
wgt = { workspace = true, features = ["serde"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
40 changes: 17 additions & 23 deletions tests/tests/vertex_indices/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use std::{num::NonZeroU64, ops::Range};

use itertools::Itertools;
use strum::IntoEnumIterator;
use wgpu::util::{BufferInitDescriptor, DeviceExt, RenderEncoder};

Expand Down Expand Up @@ -337,30 +338,23 @@ async fn vertex_index_common(ctx: TestingContext) {
)
.create_view(&wgpu::TextureViewDescriptor::default());

let mut tests = Vec::with_capacity(
TestCase::iter().count()
* IdSource::iter().count()
* DrawCallKind::iter().count()
* EncoderKind::iter().count()
* [false, true].iter().count(),
);
for case in TestCase::iter() {
for id_source in IdSource::iter() {
for draw_call_kind in DrawCallKind::iter() {
for encoder_kind in EncoderKind::iter() {
for vertex_pulling_transform in [false, true] {
tests.push(Test {
case,
id_source,
draw_call_kind,
encoder_kind,
vertex_pulling_transform,
})
}
let tests = TestCase::iter()
.cartesian_product(IdSource::iter())
.cartesian_product(DrawCallKind::iter())
.cartesian_product(EncoderKind::iter())
.cartesian_product([false, true])
.map(
|((((case, id_source), draw_call_kind), encoder_kind), vertex_pulling_transform)| {
Test {
case,
id_source,
draw_call_kind,
encoder_kind,
vertex_pulling_transform,
}
}
}
}
},
)
.collect::<Vec<_>>();

let features = ctx.adapter.features();

Expand Down

0 comments on commit 08128fd

Please sign in to comment.