diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f1ccb8b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +on: [pull_request] + +name: CI + +jobs: + build_and_test: + name: Rust project + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - uses: actions-rs/cargo@v1 + with: + command: build + args: --release --all-features + + - uses: actions-rs/cargo@v1 + with: + command: test \ No newline at end of file diff --git a/src/geometry/basics/Plane.rs b/src/geometry/basics/Plane.rs index 89708e4..212f2fb 100644 --- a/src/geometry/basics/Plane.rs +++ b/src/geometry/basics/Plane.rs @@ -65,7 +65,26 @@ impl PartialEq for Plane { #[cfg(test)] mod tests { + use super::*; + + #[test] + fn is_valid() + { + // Invalids + assert!(!Plane::UNSET.is_valid()); + assert!(!Plane::new(Point3d::INFINITY, Vector3d::INFINITY, Vector3d::INFINITY).is_valid()); + + // Valids + assert!(Plane::WORLDXY.is_valid()); + assert!(Plane::WORLDYZ.is_valid()); + assert!(Plane::WORLDZX.is_valid()); + } - + #[test] + fn cross_product() + { + let z = Plane::cross_product(Vector3d::XAXIS, Vector3d::YAXIS); + assert_eq!(z, Vector3d::ZAXIS); + } } \ No newline at end of file diff --git a/src/geometry/basics/Point3d.rs b/src/geometry/basics/Point3d.rs index 1fdc020..ce53dd3 100644 --- a/src/geometry/basics/Point3d.rs +++ b/src/geometry/basics/Point3d.rs @@ -4,7 +4,7 @@ use std::ops; use crate::IsValid::IsValid; /// A Point in three-dimensional space -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub struct Point3d { /// The X coordinate diff --git a/src/geometry/basics/Vector3d.rs b/src/geometry/basics/Vector3d.rs index e861bc5..0c0edd0 100644 --- a/src/geometry/basics/Vector3d.rs +++ b/src/geometry/basics/Vector3d.rs @@ -3,6 +3,7 @@ use std::ops; use crate::IsValid::IsValid; /// A Point in three-dimensional space +#[derive(Copy, Clone, Debug)] pub struct Vector3d { /// The X coordinate @@ -145,11 +146,6 @@ impl IsValid for Vector3d { } } -impl Clone for Vector3d { - fn clone(&self) -> Vector3d { - Vector3d::new(self.x, self.y, self.z) - } -} impl PartialEq for Vector3d { fn eq(&self, other: &Self) -> bool {