Skip to content

Commit b97dec9

Browse files
committed
[add] shader module tests.
1 parent 2926726 commit b97dec9

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

crates/lambda-platform/src/gfx/shader.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use gfx_hal::{
55

66
use super::gpu;
77

8+
/// The type of shader that a shader module represents. Different shader types
9+
/// are used for different operations in the rendering pipeline.
810
pub enum ShaderModuleType {
911
Vertex,
1012
Fragment,
@@ -94,6 +96,33 @@ impl<RenderBackend: gfx_hal::Backend> ShaderModule<RenderBackend> {
9496
}
9597
}
9698

99+
#[cfg(test)]
100+
mod tests {
101+
102+
/// Test that we can create a shader module builder and it has the correct
103+
/// defaults.
104+
#[test]
105+
fn shader_builder_initial_state() {
106+
let shader_builder = super::ShaderModuleBuilder::new();
107+
assert_eq!(shader_builder.entry_name, "main");
108+
assert_eq!(shader_builder.specializations.data.len(), 0);
109+
}
110+
111+
/// Test that we can create a shader module builder with a custom entry point
112+
/// & default specializations.
113+
#[test]
114+
fn shader_builder_with_properties() {
115+
let shader_builder = super::ShaderModuleBuilder::new()
116+
.with_entry_name("test")
117+
.with_specializations(super::ShaderSpecializations::default());
118+
assert_eq!(shader_builder.entry_name, "test");
119+
assert_eq!(
120+
shader_builder.specializations.data,
121+
super::ShaderSpecializations::default().data
122+
);
123+
}
124+
}
125+
97126
/// Internal functions for the shader module. User applications most likely
98127
/// should not use these functions directly nor should they need to.
99128
pub mod internal {

0 commit comments

Comments
 (0)