refactor: vertex_index_common: elide tests alloc. w/ Itertools::cartesian_product

This commit is contained in:
Erich Gubler 2024-06-18 15:53:56 -04:00
parent 7600c61b72
commit 764b15a556
4 changed files with 20 additions and 23 deletions

1
Cargo.lock generated
View File

@ -4384,6 +4384,7 @@ dependencies = [
"env_logger",
"futures-lite",
"image",
"itertools",
"js-sys",
"libtest-mimic",
"log",

View File

@ -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

View File

@ -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

View File

@ -5,6 +5,7 @@
use std::{num::NonZeroU64, ops::Range};
use itertools::Itertools;
use strum::IntoEnumIterator;
use wgpu::util::{BufferInitDescriptor, DeviceExt, RenderEncoder};
@ -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();