[test] add specs for RM-468 and RM-457

This commit is contained in:
Watson
2014-04-15 10:27:21 +09:00
parent e4c78ae0a0
commit 8d54d73794
3 changed files with 82 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
describe "BOOL Type Encoding" do
it "should be converted when a method has BOOL pointer" do
# RM-468
ptr = Pointer.new(:bool)
ptr.assign(true)
obj = TestBoolType.alloc.initWithBoolPtr(ptr)
obj.value.should == true
ptr.assign(false)
obj = TestBoolType.alloc.initWithBoolPtr(ptr)
obj.value.should == false
end
it "should be converted when a structure name has 'c' characters" do
# RM-457
obj = MyStructHasBool.new
obj.bool_value = true
obj = TestBoolType.alloc.initWithStruct(obj)
obj.value.should == true
obj = MyUnionHasBool.new
obj.st.bool_value = true
obj = TestBoolType.alloc.initWithUnion(obj)
obj.value.should == true
end
it "should be converted when BOOL is contained in return value" do
obj = TestBoolType.alloc.init
obj.returnBool.should == true
end
end

View File

@@ -100,3 +100,26 @@ void KreateStackBlock(void (^inputBlock)(ReturnsIntBlock));
ReturnsIntBlock KreateMallocBlock(int input);
ReturnsIntBlock KreateGlobalBlock();
typedef struct MyStructHasBool {
BOOL bool_value;
} MyStructHasBool;
typedef struct MyUnionHasBool {
MyStructHasBool st;
int value;
} MyUnionHasBool;
@interface TestBoolType : NSObject
{
NSNumber *_value;
}
@property (nonatomic, strong) NSNumber *value;
- (id)initWithBoolPtr:(BOOL*)val;
- (id)initWithStruct:(MyStructHasBool)val;
- (id)initWithUnion:(MyUnionHasBool)val;
- (BOOL)returnBool;
@end

View File

@@ -180,3 +180,31 @@ ReturnsIntBlock KreateGlobalBlock()
return ^{ return 42; };
}
/* Test for RM-468, RM-457 */
@implementation TestBoolType : NSObject
@synthesize value;
- (id)initWithBoolPtr:(BOOL*)ptr
{
self.value = [NSNumber numberWithBool:*ptr];
return self;
}
- (id)initWithStruct:(MyStructHasBool)val
{
self.value = [NSNumber numberWithBool:val.bool_value];
return self;
}
- (id)initWithUnion:(MyUnionHasBool)val
{
self.value = [NSNumber numberWithBool:val.st.bool_value];
return self;
}
- (BOOL)returnBool
{
return YES;
}
@end