From 2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:50 +0200 Subject: Merging upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/overload/tests/assignment.rs | 89 +++++++++++++++++++++++++++++++++++++ vendor/overload/tests/binary.rs | 72 ++++++++++++++++++++++++++++++ vendor/overload/tests/unary.rs | 21 +++++++++ 3 files changed, 182 insertions(+) create mode 100644 vendor/overload/tests/assignment.rs create mode 100644 vendor/overload/tests/binary.rs create mode 100644 vendor/overload/tests/unary.rs (limited to 'vendor/overload/tests') diff --git a/vendor/overload/tests/assignment.rs b/vendor/overload/tests/assignment.rs new file mode 100644 index 000000000..9657b4bd4 --- /dev/null +++ b/vendor/overload/tests/assignment.rs @@ -0,0 +1,89 @@ +extern crate overload; +use overload::overload; +use std::ops; + +#[derive(PartialEq, Debug)] +struct A(i32); + +#[derive(PartialEq, Debug)] +struct B(i32); + +overload!((a: &mut A) += (b: B) { a.0 += b.0; }); +#[test] +fn add_assign() { + let mut a = A(3); + a += B(4); + assert_eq!(A(3 + 4), a); +} + +overload!((a: &mut A) -= (b: B) { a.0 -= b.0; }); +#[test] +fn sub_assign() { + let mut a = A(3); + a -= B(4); + assert_eq!(A(3 - 4), a); +} + +overload!((a: &mut A) *= (b: B) { a.0 *= b.0; }); +#[test] +fn mul_assign() { + let mut a = A(3); + a *= B(4); + assert_eq!(A(3 * 4), a); +} + +overload!((a: &mut A) /= (b: B) { a.0 /= b.0; }); +#[test] +fn div_assign() { + let mut a = A(6); + a /= B(3); + assert_eq!(A(6 / 3), a); +} + +overload!((a: &mut A) %= (b: B) { a.0 %= b.0; }); +#[test] +fn rem_assign() { + let mut a = A(6); + a %= B(4); + assert_eq!(A(6 % 4), a); +} + +overload!((a: &mut A) &= (b: B) { a.0 &= b.0; }); +#[test] +fn bitand_assign() { + let mut a = A(6); + a &= B(4); + assert_eq!(A(6 & 4), a); +} + +overload!((a: &mut A) |= (b: B) { a.0 |= b.0; }); +#[test] +fn bitor_assign() { + let mut a = A(6); + a |= B(4); + assert_eq!(A(6 | 4), a); +} + +overload!((a: &mut A) ^= (b: B) { a.0 ^= b.0; }); +#[test] +fn bitxor_assign() { + let mut a = A(6); + a ^= B(4); + assert_eq!(A(6 ^ 4), a); +} + +overload!((a: &mut A) <<= (b: B) { a.0 <<= b.0; }); +#[test] +fn shl_assign() { + let mut a = A(6); + a <<= B(4); + assert_eq!(A(6 << 4), a); +} + +overload!((a: &mut A) >>= (b: B) { a.0 >>= b.0; }); +#[test] +fn shr_assign() { + let mut a = A(6); + a >>= B(4); + assert_eq!(A(6 >> 4), a); +} diff --git a/vendor/overload/tests/binary.rs b/vendor/overload/tests/binary.rs new file mode 100644 index 000000000..2fb209ad3 --- /dev/null +++ b/vendor/overload/tests/binary.rs @@ -0,0 +1,72 @@ +extern crate overload; +use overload::overload; +use std::ops; + +#[derive(PartialEq, Debug)] +struct A(i32); + +#[derive(PartialEq, Debug)] +struct B(i32); + +#[derive(PartialEq, Debug)] +struct C(i32); + +overload!((a: A) + (b: B) -> C { C(a.0 + b.0) }); +#[test] +fn add() { + assert_eq!(A(3) + B(4), C(3 + 4)); +} + +overload!((a: A) - (b: B) -> C { C(a.0 - b.0) }); +#[test] +fn sub() { + assert_eq!(A(3) - B(4), C(3 - 4)); +} + +overload!((a: A) * (b: B) -> C { C(a.0 * b.0) }); +#[test] +fn mul() { + assert_eq!(A(3) * B(4), C(3 * 4)); +} + +overload!((a: A) / (b: B) -> C { C(a.0 / b.0) }); +#[test] +fn div() { + assert_eq!(A(6) / B(3), C(6 / 3)); +} + +overload!((a: A) % (b: B) -> C { C(a.0 % b.0) }); +#[test] +fn rem() { + assert_eq!(A(6) % B(4), C(6 % 4)); +} + +overload!((a: A) & (b: B) -> C { C(a.0 & b.0) }); +#[test] +fn bitand() { + assert_eq!(A(6) & B(4), C(6 & 4)); +} + +overload!((a: A) | (b: B) -> C { C(a.0 | b.0) }); +#[test] +fn bitor() { + assert_eq!(A(6) | B(4), C(6 | 4)); +} + +overload!((a: A) ^ (b: B) -> C { C(a.0 ^ b.0) }); +#[test] +fn bitxor() { + assert_eq!(A(6) ^ B(4), C(6 ^ 4)); +} + +overload!((a: A) << (b: B) -> C { C(a.0 << b.0) }); +#[test] +fn shl() { + assert_eq!(A(6) << B(4), C(6 << 4)); +} + +overload!((a: A) >> (b: B) -> C { C(a.0 >> b.0) }); +#[test] +fn shr() { + assert_eq!(A(6) >> B(4), C(6 >> 4)); +} diff --git a/vendor/overload/tests/unary.rs b/vendor/overload/tests/unary.rs new file mode 100644 index 000000000..76a3925fe --- /dev/null +++ b/vendor/overload/tests/unary.rs @@ -0,0 +1,21 @@ +extern crate overload; +use overload::overload; +use std::ops; + +#[derive(PartialEq, Debug)] +struct A(i32); + +#[derive(PartialEq, Debug)] +struct B(i32); + +overload!(- (a: A) -> B { B(-a.0) }); +#[test] +fn neg() { + assert_eq!(-A(3), B(-3)); +} + +overload!(! (a: A) -> B { B(!a.0) }); +#[test] +fn not() { + assert_eq!(!A(3), B(!3)); +} -- cgit v1.2.3