Change fail_unless! to assert!.
This commit is contained in:
@@ -80,7 +80,7 @@ impl<ElemRefType:AbstractCFTypeRef> Index<uint,ElemRefType> for CFArray<ElemRefT
|
||||
// Generally, when array elements are Core Foundation objects (not
|
||||
// always true), they need to be wrapped with CFWrapper::wrap_shared.
|
||||
fn index(&self, idx: uint) -> ElemRefType {
|
||||
fail_unless!(idx < self.len());
|
||||
assert!(idx < self.len());
|
||||
unsafe {
|
||||
let elem = CFArrayGetValueAtIndex(*self.borrow_ref(), idx as CFIndex);
|
||||
// Don't return a wrapped thing, since we don't know whether
|
||||
@@ -136,11 +136,11 @@ fn should_box_and_unbox() {
|
||||
sum += CFWrapper::wrap_shared(*elem).to_i32();
|
||||
}
|
||||
|
||||
fail_unless!(sum == 15);
|
||||
assert!(sum == 15);
|
||||
|
||||
for arr.each |elem: &CFNumberRef| {
|
||||
sum += CFWrapper::wrap_shared(*elem).to_i32();
|
||||
}
|
||||
|
||||
fail_unless!(sum == 30);
|
||||
assert!(sum == 30);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ impl AbstractCFTypeRef for CFTypeRef {
|
||||
|
||||
pub fn downcast<T:AbstractCFTypeRef>(r: CFTypeRef) -> T {
|
||||
unsafe {
|
||||
fail_unless!(CFGetTypeID(r) == AbstractCFTypeRef::type_id::<T>());
|
||||
assert!(CFGetTypeID(r) == AbstractCFTypeRef::type_id::<T>());
|
||||
cast::transmute::<CFTypeRef, T>(r)
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ impl<T,E1,E2> Drop for CFWrapper<T,E1,E2> {
|
||||
// cannot make virtual method calls using trait
|
||||
// types. Instead, just transmute the bugger.
|
||||
let this: &RawCFWrapper = cast::transmute::<&CFWrapper<T,E1,E2>, &RawCFWrapper>(self);
|
||||
fail_unless!(CFGetRetainCount(this.obj) > 0 as CFIndex);
|
||||
assert!(CFGetRetainCount(this.obj) > 0 as CFIndex);
|
||||
CFRelease(this.obj)
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ pub impl<T:Copy + AbstractCFTypeRef, E1, E2> CFWrapper<T,E1,E2> {
|
||||
|
||||
fn from_CFType(wrapper: CFType) -> CFWrapper<T,E1,E2> {
|
||||
unsafe {
|
||||
fail_unless!(wrapper.type_id() == AbstractCFTypeRef::type_id::<T>());
|
||||
assert!(wrapper.type_id() == AbstractCFTypeRef::type_id::<T>());
|
||||
cast::transmute::<CFType,CFWrapper<T,E1,E2>>(wrapper)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ pub impl<KeyRefType: Copy + AbstractCFTypeRef, ValueRefType: Copy + AbstractCFTy
|
||||
}
|
||||
}
|
||||
|
||||
fail_unless!(keys.len() == values.len());
|
||||
assert!(keys.len() == values.len());
|
||||
|
||||
let dictionary_ref : CFDictionaryRef;
|
||||
unsafe {
|
||||
|
||||
@@ -59,7 +59,7 @@ pub impl CFNumber {
|
||||
|
||||
fn to_i8(&self) -> i8 {
|
||||
let ty = kCFNumberSInt8Type;
|
||||
fail_unless!(self.has_number_type(ty));
|
||||
assert!(self.has_number_type(ty));
|
||||
unsafe {
|
||||
let val: i8 = 0i8;
|
||||
if !CFNumberGetValue(self.obj, ty, cast::transmute::<&i8, *c_void>(&val)) {
|
||||
@@ -71,7 +71,7 @@ pub impl CFNumber {
|
||||
|
||||
fn to_i16(&self) -> i16 {
|
||||
let ty = kCFNumberSInt16Type;
|
||||
fail_unless!(self.has_number_type(ty));
|
||||
assert!(self.has_number_type(ty));
|
||||
unsafe {
|
||||
let val: i16 = 0i16;
|
||||
if !CFNumberGetValue(self.obj, ty, cast::transmute::<&i16, *c_void>(&val)) {
|
||||
@@ -83,7 +83,7 @@ pub impl CFNumber {
|
||||
|
||||
fn to_i32(&self) -> i32 {
|
||||
let ty = kCFNumberSInt32Type;
|
||||
fail_unless!(self.has_number_type(ty));
|
||||
assert!(self.has_number_type(ty));
|
||||
unsafe {
|
||||
let val: i32 = 0i32;
|
||||
if !CFNumberGetValue(self.obj, ty, cast::transmute::<&i32, *c_void>(&val)) {
|
||||
@@ -95,7 +95,7 @@ pub impl CFNumber {
|
||||
|
||||
fn to_float(&self) -> float {
|
||||
unsafe {
|
||||
fail_unless!(self.has_float_type());
|
||||
assert!(self.has_float_type());
|
||||
let ty = CFNumberGetType(self.obj);
|
||||
if ty == kCFNumberFloat32Type || ty == kCFNumberFloatType {
|
||||
let mut val: libc::c_float = 0.0f as libc::c_float;
|
||||
|
||||
@@ -283,10 +283,10 @@ impl ToStr for CFString {
|
||||
buffer.len() as CFIndex,
|
||||
ptr::to_unsafe_ptr(&bytes_used)) as uint;
|
||||
|
||||
fail_unless!(chars_written == char_len);
|
||||
assert!(chars_written == char_len);
|
||||
// this is dangerous; we over-allocate and nul-terminate the string (during
|
||||
// initialization)
|
||||
fail_unless!(bytes_used + 1 == buffer.len() as CFIndex);
|
||||
assert!(bytes_used + 1 == buffer.len() as CFIndex);
|
||||
// then, reinterpret it as as string. you have been warned!
|
||||
let casted_str : ~str = cast::transmute::<~[u8], ~str>(buffer);
|
||||
// sanity check.
|
||||
@@ -414,5 +414,5 @@ fn string_and_back() {
|
||||
let original = "The quick brown fox jumped over the slow lazy dog.";
|
||||
let cfstr = CFString::new_static(original);
|
||||
let converted = cfstr.to_str();
|
||||
fail_unless!(original == converted);
|
||||
assert!(original == converted);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user