use ferray_core::DType;
use ferray_core::dtype::casting::{CastKind, can_cast};
#[test]
fn same_kind_int8_to_uint8_matches_numpy() {
assert!(
!can_cast(DType::I8, DType::U8, CastKind::SameKind).unwrap(),
"np.can_cast('int8','uint8','same_kind') == False (signed 'i'>unsigned 'u')"
);
}
#[test]
fn same_kind_int16_to_uint8_matches_numpy() {
assert!(
!can_cast(DType::I16, DType::U8, CastKind::SameKind).unwrap(),
"np.can_cast('int16','uint8','same_kind') == False (signed -> unsigned)"
);
}
#[test]
fn same_kind_int32_to_uint16_matches_numpy() {
assert!(
!can_cast(DType::I32, DType::U16, CastKind::SameKind).unwrap(),
"np.can_cast('int32','uint16','same_kind') == False (signed -> unsigned)"
);
}
#[test]
fn same_kind_int64_to_uint32_matches_numpy() {
assert!(
!can_cast(DType::I64, DType::U32, CastKind::SameKind).unwrap(),
"np.can_cast('int64','uint32','same_kind') == False (signed -> unsigned)"
);
}
#[test]
fn same_kind_int64_to_uint64_matches_numpy() {
assert!(
!can_cast(DType::I64, DType::U64, CastKind::SameKind).unwrap(),
"np.can_cast('int64','uint64','same_kind') == False (signed -> unsigned)"
);
}
#[test]
fn same_kind_int32_to_float32_matches_numpy() {
assert!(
can_cast(DType::I32, DType::F32, CastKind::SameKind).unwrap(),
"np.can_cast('int32','float32','same_kind') == True (ord int 2 <= float 4)"
);
}
#[test]
fn same_kind_int64_to_float32_matches_numpy() {
assert!(
can_cast(DType::I64, DType::F32, CastKind::SameKind).unwrap(),
"np.can_cast('int64','float32','same_kind') == True (ord int 2 <= float 4)"
);
}
#[test]
fn same_kind_uint32_to_float32_matches_numpy() {
assert!(
can_cast(DType::U32, DType::F32, CastKind::SameKind).unwrap(),
"np.can_cast('uint32','float32','same_kind') == True (ord uint 1 <= float 4)"
);
}
#[test]
fn same_kind_uint64_to_float32_matches_numpy() {
assert!(
can_cast(DType::U64, DType::F32, CastKind::SameKind).unwrap(),
"np.can_cast('uint64','float32','same_kind') == True (ord uint 1 <= float 4)"
);
}
#[test]
fn same_kind_int32_to_complex64_matches_numpy() {
assert!(
can_cast(DType::I32, DType::Complex32, CastKind::SameKind).unwrap(),
"np.can_cast('int32','complex64','same_kind') == True (ord int 2 <= complex 5)"
);
}
#[test]
fn same_kind_int64_to_complex64_matches_numpy() {
assert!(
can_cast(DType::I64, DType::Complex32, CastKind::SameKind).unwrap(),
"np.can_cast('int64','complex64','same_kind') == True (ord int 2 <= complex 5)"
);
}
#[test]
fn same_kind_uint32_to_complex64_matches_numpy() {
assert!(
can_cast(DType::U32, DType::Complex32, CastKind::SameKind).unwrap(),
"np.can_cast('uint32','complex64','same_kind') == True (ord uint 1 <= complex 5)"
);
}
#[test]
fn same_kind_uint64_to_complex64_matches_numpy() {
assert!(
can_cast(DType::U64, DType::Complex32, CastKind::SameKind).unwrap(),
"np.can_cast('uint64','complex64','same_kind') == True (ord uint 1 <= complex 5)"
);
}
#[test]
fn same_kind_float64_to_complex64_matches_numpy() {
assert!(
can_cast(DType::F64, DType::Complex32, CastKind::SameKind).unwrap(),
"np.can_cast('float64','complex64','same_kind') == True (ord float 4 <= complex 5)"
);
}
#[test]
fn control_same_kind_uint8_to_int8_true() {
assert!(
can_cast(DType::U8, DType::I8, CastKind::SameKind).unwrap(),
"np.can_cast('uint8','int8','same_kind') == True (ord uint 1 <= int 2)"
);
}
#[test]
fn control_same_kind_complex64_to_float64_false() {
assert!(
!can_cast(DType::Complex32, DType::F64, CastKind::SameKind).unwrap(),
"np.can_cast('complex64','float64','same_kind') == False (ord complex 5 > float 4)"
);
}
#[test]
fn control_same_kind_float64_to_int32_false() {
assert!(
!can_cast(DType::F64, DType::I32, CastKind::SameKind).unwrap(),
"np.can_cast('float64','int32','same_kind') == False (ord float 4 > int 2)"
);
}