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", "env_logger",
"futures-lite", "futures-lite",
"image", "image",
"itertools",
"js-sys", "js-sys",
"libtest-mimic", "libtest-mimic",
"log", "log",

View File

@ -91,6 +91,7 @@ getrandom = "0.2"
glam = "0.27" glam = "0.27"
heck = "0.5.0" heck = "0.5.0"
image = { version = "0.24", default-features = false, features = ["png"] } image = { version = "0.24", default-features = false, features = ["png"] }
itertools = { version = "0.10.5" }
ktx2 = "0.3" ktx2 = "0.3"
libc = "0.2" libc = "0.2"
# libloading 0.8 switches from `winapi` to `windows-sys`; permit either # libloading 0.8 switches from `winapi` to `windows-sys`; permit either

View File

@ -27,6 +27,7 @@ bytemuck.workspace = true
cfg-if.workspace = true cfg-if.workspace = true
ctor.workspace = true ctor.workspace = true
futures-lite.workspace = true futures-lite.workspace = true
itertools.workspace = true
libtest-mimic.workspace = true libtest-mimic.workspace = true
log.workspace = true log.workspace = true
parking_lot.workspace = true parking_lot.workspace = true

View File

@ -5,6 +5,7 @@
use std::{num::NonZeroU64, ops::Range}; use std::{num::NonZeroU64, ops::Range};
use itertools::Itertools;
use strum::IntoEnumIterator; use strum::IntoEnumIterator;
use wgpu::util::{BufferInitDescriptor, DeviceExt, RenderEncoder}; use wgpu::util::{BufferInitDescriptor, DeviceExt, RenderEncoder};
@ -337,30 +338,23 @@ async fn vertex_index_common(ctx: TestingContext) {
) )
.create_view(&wgpu::TextureViewDescriptor::default()); .create_view(&wgpu::TextureViewDescriptor::default());
let mut tests = Vec::with_capacity( let tests = TestCase::iter()
TestCase::iter().count() .cartesian_product(IdSource::iter())
* IdSource::iter().count() .cartesian_product(DrawCallKind::iter())
* DrawCallKind::iter().count() .cartesian_product(EncoderKind::iter())
* EncoderKind::iter().count() .cartesian_product([false, true])
* [false, true].iter().count(), .map(
); |((((case, id_source), draw_call_kind), encoder_kind), vertex_pulling_transform)| {
for case in TestCase::iter() { Test {
for id_source in IdSource::iter() { case,
for draw_call_kind in DrawCallKind::iter() { id_source,
for encoder_kind in EncoderKind::iter() { draw_call_kind,
for vertex_pulling_transform in [false, true] { encoder_kind,
tests.push(Test { vertex_pulling_transform,
case,
id_source,
draw_call_kind,
encoder_kind,
vertex_pulling_transform,
})
}
} }
} },
} )
} .collect::<Vec<_>>();
let features = ctx.adapter.features(); let features = ctx.adapter.features();