Add -isEqual: and -description to CPFont. Add a unit test for -isEqual:

Closes #506.
Closes #505.
This commit is contained in:
Ross Boucher committed 2010-02-27 12:00:44 -08:00
1 parent dbe0ca0adc
commit efd699a044
2 files changed
+21 -2

No files matched your search

+11 -1
View File
@@ -130,6 +130,16 @@ var _CPFonts = {},
return _name;
}
- (BOOL)isEqual:(id)anObject
{
return [anObject isKindOfClass:[CPFont class]] && [anObject cssString] === [self cssString];
}
- (CPString)description
{
return [CPString stringWithFormat:@"%@ %@ %f pt.", [super description], [self familyName], [self size]];
}
@end
var CPFontNameKey = @"CPFontNameKey",
@@ -161,4 +171,4 @@ var CPFontNameKey = @"CPFontNameKey",
[aCoder encodeBool:_isBold forKey:CPFontIsBoldKey];
}
@end
@end
+10 -1
View File
@@ -38,4 +38,13 @@
[self assert:[_boldCustomFont cssString] equals:@"bold 30px \"Helvetica\", Arial, sans-serif"];
}
@end
- (void)testIsEqual
{
[self assert:_customFont equals:_customFont];
[self assert:_systemFont equals:_systemFont];
[self assert:_systemFont notEqual:_customFont];
[self assert:_customFont notEqual:"a string"];
[self assert:_customFont notEqual:nil];
}
@end