Skip to content

Commit

Permalink
Fixes test expected to fail for wasm (texture_bounds.rs)
Browse files Browse the repository at this point in the history
  • Loading branch information
haraldreingruber committed Dec 8, 2022
1 parent f4a4e1d commit 8e8ed89
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions wgpu/tests/texture_bounds.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
//! Tests for texture copy bounds checks.

use crate::common::{initialize_test, TestParameters};
use crate::common::{fail_if, initialize_test, TestParameters};
use std::num::NonZeroU32;
use wasm_bindgen_test::*;

#[test]
#[wasm_bindgen_test]
fn bad_copy_origin() {
fn try_origin(origin: wgpu::Origin3d, size: wgpu::Extent3d, should_panic: bool) {
let mut parameters = TestParameters::default();
if should_panic {
parameters = parameters.failure();
}

initialize_test(parameters, |ctx| {
let texture = ctx.device.create_texture(&TEXTURE_DESCRIPTOR);
let data = vec![255; BUFFER_SIZE as usize];
ctx.queue.write_texture(
wgpu::ImageCopyTexture {
texture: &texture,
mip_level: 0,
origin,
aspect: wgpu::TextureAspect::All,
},
&data,
BUFFER_COPY_LAYOUT,
size,
);

fail_if(&ctx.device, should_panic, || {
ctx.queue.write_texture(
wgpu::ImageCopyTexture {
texture: &texture,
mip_level: 0,
origin,
aspect: wgpu::TextureAspect::All,
},
&data,
BUFFER_COPY_LAYOUT,
size,
)
});
});
}

Expand Down

0 comments on commit 8e8ed89

Please sign in to comment.