Skip to content

Commit

Permalink
add test cases for eq_union
Browse files Browse the repository at this point in the history
  • Loading branch information
magiclen committed Jul 30, 2019
1 parent 44a76ac commit 49c6589
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/eq_enum.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![no_std]

#[macro_use]
extern crate educe;

Expand Down
2 changes: 2 additions & 0 deletions tests/eq_struct.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![no_std]

#[macro_use]
extern crate educe;

Expand Down
68 changes: 68 additions & 0 deletions tests/eq_union.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#![no_std]

#[macro_use]
extern crate educe;

#[test]
#[allow(dead_code)]
fn basic() {
#[derive(Educe)]
#[educe(Eq)]
union Union {
f1: u8
}

impl core::cmp::PartialEq for Union {
fn eq(&self, _other: &Union) -> bool {
true
}
}
}

#[test]
#[allow(dead_code)]
fn bound_1() {
#[derive(Educe)]
#[educe(Eq(bound))]
union Union<T: Copy> {
f1: T
}

impl<T: Copy> core::cmp::PartialEq for Union<T> {
fn eq(&self, _other: &Union<T>) -> bool {
true
}
}
}

#[test]
#[allow(dead_code)]
fn bound_2() {
#[derive(Educe)]
#[educe(Eq(bound = "T: core::cmp::Eq"))]
union Union<T: Copy> {
f1: T
}

impl<T: Copy> core::cmp::PartialEq for Union<T> {
fn eq(&self, _other: &Union<T>) -> bool {
true
}
}
}

#[test]
#[allow(dead_code)]
fn bound_3() {
#[derive(Educe)]
#[educe(Eq(bound = "T: core::cmp::PartialEq"))]
union Union<T: Copy> {
f1: T
}

impl<T: Copy> core::cmp::PartialEq for Union<T> {
fn eq(&self, _other: &Union<T>) -> bool {
true
}
}
}
2 changes: 2 additions & 0 deletions tests/partial_eq_enum.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![no_std]

#[macro_use]
extern crate educe;

Expand Down
2 changes: 2 additions & 0 deletions tests/partial_eq_struct.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![no_std]

#[macro_use]
extern crate educe;

Expand Down

0 comments on commit 49c6589

Please sign in to comment.