summaryrefslogtreecommitdiffstats
path: root/third_party/ocmock/OCMock/OCMockObjectTests.m
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/ocmock/OCMock/OCMockObjectTests.m')
-rw-r--r--third_party/ocmock/OCMock/OCMockObjectTests.m32
1 files changed, 31 insertions, 1 deletions
diff --git a/third_party/ocmock/OCMock/OCMockObjectTests.m b/third_party/ocmock/OCMock/OCMockObjectTests.m
index 942cffd..cd8dbe3 100644
--- a/third_party/ocmock/OCMock/OCMockObjectTests.m
+++ b/third_party/ocmock/OCMock/OCMockObjectTests.m
@@ -1,5 +1,5 @@
//---------------------------------------------------------------------------------------
-// $Id: OCMockObjectTests.m 54 2009-08-18 06:27:36Z erik $
+// $Id: OCMockObjectTests.m 55 2009-10-16 06:42:18Z erik $
// Copyright (c) 2004-2008 by Mulle Kybernetik. See License file for details.
//---------------------------------------------------------------------------------------
@@ -217,6 +217,36 @@ static NSString *TestNotification = @"TestNotification";
}
+- (void)testCanPassMocksAsArguments
+{
+ id mockArg = [OCMockObject mockForClass:[NSString class]];
+ [[mock stub] stringByAppendingString:[OCMArg any]];
+ [mock stringByAppendingString:mockArg];
+}
+
+- (void)testCanStubWithMockArguments
+{
+ id mockArg = [OCMockObject mockForClass:[NSString class]];
+ [[mock stub] stringByAppendingString:mockArg];
+ [mock stringByAppendingString:mockArg];
+}
+
+- (void)testRaisesExceptionWhenStubbedMockArgIsNotUsed
+{
+ id mockArg = [OCMockObject mockForClass:[NSString class]];
+ [[mock stub] stringByAppendingString:mockArg];
+ STAssertThrows([mock stringByAppendingString:@"foo"], @"Should have raised an exception.");
+}
+
+- (void)testRaisesExceptionWhenDifferentMockArgumentIsPassed
+{
+ id expectedArg = [OCMockObject mockForClass:[NSString class]];
+ id otherArg = [OCMockObject mockForClass:[NSString class]];
+ [[mock stub] stringByAppendingString:otherArg];
+ STAssertThrows([mock stringByAppendingString:expectedArg], @"Should have raised an exception.");
+}
+
+
// --------------------------------------------------------------------------------------
// returning values from stubbed methods
// --------------------------------------------------------------------------------------