bevy/crates/bevy_crevice/tests/test.rs
François 79d36e7c28 Prepare crevice for vendored release (#3394)
# Objective

- Our crevice is still called "crevice", which we can't use for a release
- Users would need to use our "crevice" directly to be able to use the derive macro

## Solution

- Rename crevice to bevy_crevice, and crevice-derive to bevy-crevice-derive
- Re-export it from bevy_render, and use it from bevy_render everywhere
- Fix derive macro to work either from bevy_render, from bevy_crevice, or from bevy

## Remaining

- It is currently re-exported as `bevy::render::bevy_crevice`, is it the path we want?
- After a brief suggestion to Cart, I changed the version to follow Bevy version instead of crevice, do we want that?
- Crevice README.md need to be updated
- in the `Cargo.toml`, there are a few things to change. How do we want to change them? How do we keep attributions to original Crevice?
```
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
documentation = "https://docs.rs/crevice"
homepage = "https://github.com/LPGhatguy/crevice"
repository = "https://github.com/LPGhatguy/crevice"
```


Co-authored-by: François <8672791+mockersf@users.noreply.github.com>
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-12-23 22:49:12 +00:00

61 lines
1.4 KiB
Rust

use bevy_crevice::glsl::GlslStruct;
use bevy_crevice::std140::AsStd140;
#[test]
fn there_and_back_again() {
#[derive(AsStd140, Debug, PartialEq)]
struct ThereAndBackAgain {
view: mint::ColumnMatrix3<f32>,
origin: mint::Vector3<f32>,
}
let x = ThereAndBackAgain {
view: mint::ColumnMatrix3 {
x: mint::Vector3 {
x: 1.0,
y: 0.0,
z: 0.0,
},
y: mint::Vector3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
z: mint::Vector3 {
x: 0.0,
y: 0.0,
z: 1.0,
},
},
origin: mint::Vector3 {
x: 0.0,
y: 1.0,
z: 2.0,
},
};
let x_as = x.as_std140();
assert_eq!(<ThereAndBackAgain as AsStd140>::from_std140(x_as), x);
}
#[test]
fn generate_struct_glsl() {
#[allow(dead_code)]
#[derive(GlslStruct)]
struct TestGlsl {
foo: mint::Vector3<f32>,
bar: mint::ColumnMatrix2<f32>,
}
insta::assert_display_snapshot!(TestGlsl::glsl_definition());
}
#[test]
fn generate_struct_array_glsl() {
#[allow(dead_code)]
#[derive(GlslStruct)]
struct TestGlsl {
foo: [[mint::Vector3<f32>; 8]; 4],
}
insta::assert_display_snapshot!(TestGlsl::glsl_definition());
}