use vyre::ir::{BufferAccess, BufferDecl, DataType, LinearType, ShapePredicate};
#[test]
fn empty_buffer_name_is_constructible() {
let buf = BufferDecl::storage("", 0, BufferAccess::ReadWrite, DataType::U32).with_count(1);
assert_eq!(buf.name(), "");
}
#[test]
fn unicode_buffer_name_is_constructible() {
let buf = BufferDecl::storage("缓冲区", 0, BufferAccess::ReadWrite, DataType::U32).with_count(1);
assert_eq!(buf.name(), "缓冲区");
}
#[test]
fn buffer_name_with_newline_is_constructible() {
let buf = BufferDecl::storage("line\nbreak", 0, BufferAccess::ReadWrite, DataType::U32).with_count(1);
assert_eq!(buf.name(), "line\nbreak");
}
#[test]
fn binding_slot_max_u32_is_constructible() {
let buf = BufferDecl::storage("x", u32::MAX, BufferAccess::ReadWrite, DataType::U32).with_count(1);
assert_eq!(buf.binding(), u32::MAX);
}
#[test]
fn workgroup_buffer_with_zero_count_is_constructible() {
let buf = BufferDecl::workgroup("scratch", 0, DataType::U32);
assert_eq!(buf.count(), 0);
assert_eq!(buf.access(), BufferAccess::Workgroup);
}
#[test]
fn workgroup_buffer_with_max_count_is_constructible() {
let buf = BufferDecl::workgroup("scratch", u32::MAX, DataType::U32);
assert_eq!(buf.count(), u32::MAX);
}
#[test]
fn pipeline_live_out_on_non_output_buffer_is_constructible() {
let buf = BufferDecl::read("in", 0, DataType::U32)
.with_count(1)
.with_pipeline_live_out(true);
assert!(buf.is_pipeline_live_out());
}
#[test]
fn bytes_extraction_on_scalar_buffer_is_constructible() {
let buf = BufferDecl::storage("raw", 0, BufferAccess::ReadWrite, DataType::U32)
.with_count(1)
.with_bytes_extraction(true);
assert!(buf.bytes_extraction);
}
#[test]
fn output_byte_range_on_non_output_buffer_is_constructible() {
let buf = BufferDecl::read("in", 0, DataType::U32)
.with_count(1)
.with_output_byte_range(0..16);
assert_eq!(buf.output_byte_range(), Some(0..16));
}
#[test]
fn linear_type_restricted_is_constructible() {
let buf = BufferDecl::storage("linear", 0, BufferAccess::ReadWrite, DataType::U32)
.with_count(1)
.with_linear_type(LinearType::Linear);
assert_eq!(buf.linear_type(), LinearType::Linear);
}
#[test]
fn shape_predicate_is_constructible() {
let buf = BufferDecl::storage("shaped", 0, BufferAccess::ReadWrite, DataType::U32)
.with_count(64)
.with_shape_predicate(ShapePredicate::Exactly(64));
assert!(buf.shape_predicate().is_some());
}