提交 1ec5650a 编写于 作者: J Jorge Aparicio

libcoretest: fix unit tests

上级 a672b27c
......@@ -64,11 +64,11 @@ fn test_is_negative() {
#[test]
fn test_bitwise_operators() {
assert!(0b1110 as $T == (0b1100 as $T).bitor(&(0b1010 as $T)));
assert!(0b1000 as $T == (0b1100 as $T).bitand(&(0b1010 as $T)));
assert!(0b0110 as $T == (0b1100 as $T).bitxor(&(0b1010 as $T)));
assert!(0b1110 as $T == (0b0111 as $T).shl(&1));
assert!(0b0111 as $T == (0b1110 as $T).shr(&1));
assert!(0b1110 as $T == (0b1100 as $T).bitor(0b1010 as $T));
assert!(0b1000 as $T == (0b1100 as $T).bitand(0b1010 as $T));
assert!(0b0110 as $T == (0b1100 as $T).bitxor(0b1010 as $T));
assert!(0b1110 as $T == (0b0111 as $T).shl(1));
assert!(0b0111 as $T == (0b1110 as $T).shr(1));
assert!(-(0b11 as $T) - (1 as $T) == (0b11 as $T).not());
}
......
......@@ -12,6 +12,7 @@
use core::fmt::Show;
use core::num::{NumCast, cast};
use core::ops::{Add, Sub, Mul, Div, Rem};
use core::kinds::Copy;
mod int_macros;
mod i8;
......@@ -32,18 +33,19 @@ pub fn test_num<T>(ten: T, two: T) where
+ Add<T, T> + Sub<T, T>
+ Mul<T, T> + Div<T, T>
+ Rem<T, T> + Show
+ Copy
{
assert_eq!(ten.add(&two), cast(12i).unwrap());
assert_eq!(ten.sub(&two), cast(8i).unwrap());
assert_eq!(ten.mul(&two), cast(20i).unwrap());
assert_eq!(ten.div(&two), cast(5i).unwrap());
assert_eq!(ten.rem(&two), cast(0i).unwrap());
assert_eq!(ten.add(two), cast(12i).unwrap());
assert_eq!(ten.sub(two), cast(8i).unwrap());
assert_eq!(ten.mul(two), cast(20i).unwrap());
assert_eq!(ten.div(two), cast(5i).unwrap());
assert_eq!(ten.rem(two), cast(0i).unwrap());
assert_eq!(ten.add(&two), ten + two);
assert_eq!(ten.sub(&two), ten - two);
assert_eq!(ten.mul(&two), ten * two);
assert_eq!(ten.div(&two), ten / two);
assert_eq!(ten.rem(&two), ten % two);
assert_eq!(ten.add(two), ten + two);
assert_eq!(ten.sub(two), ten - two);
assert_eq!(ten.mul(two), ten * two);
assert_eq!(ten.div(two), ten / two);
assert_eq!(ten.rem(two), ten % two);
}
#[cfg(test)]
......
......@@ -31,11 +31,11 @@ fn test_num() {
#[test]
fn test_bitwise_operators() {
assert!(0b1110 as $T == (0b1100 as $T).bitor(&(0b1010 as $T)));
assert!(0b1000 as $T == (0b1100 as $T).bitand(&(0b1010 as $T)));
assert!(0b0110 as $T == (0b1100 as $T).bitxor(&(0b1010 as $T)));
assert!(0b1110 as $T == (0b0111 as $T).shl(&1u));
assert!(0b0111 as $T == (0b1110 as $T).shr(&1u));
assert!(0b1110 as $T == (0b1100 as $T).bitor(0b1010 as $T));
assert!(0b1000 as $T == (0b1100 as $T).bitand(0b1010 as $T));
assert!(0b0110 as $T == (0b1100 as $T).bitxor(0b1010 as $T));
assert!(0b1110 as $T == (0b0111 as $T).shl(1u));
assert!(0b0111 as $T == (0b1110 as $T).shr(1u));
assert!(MAX - (0b1011 as $T) == (0b1011 as $T).not());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册