diff options
author | thomasvl <thomasvl@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2008-06-13 19:21:50 +0000 |
---|---|---|
committer | thomasvl <thomasvl@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2008-06-13 19:21:50 +0000 |
commit | c53ec5520e39096e0804ce8d89a21378c0904481 (patch) | |
tree | d36a0055b59b1376d86c4ba4a01f9c479c2101a7 /Foundation/GTMNSAppleEventDescriptor+HandlerTest.m | |
parent | 80d493da05c8d461d74bfaa919ffc487be03ffe6 (diff) |
Landing a log of AppleScript/AppleEvent support code.
Landing GTMHTTPServer as a simple server but mainly for use in unittesting.
_GTMCompileAssert for doing compile time assertions to GTMDefines.h
Lots of improvments for UnitTesting, Dave's gonna put up a wiki page shortly with the full details of what can be done.
Diffstat (limited to 'Foundation/GTMNSAppleEventDescriptor+HandlerTest.m')
-rw-r--r-- | Foundation/GTMNSAppleEventDescriptor+HandlerTest.m | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/Foundation/GTMNSAppleEventDescriptor+HandlerTest.m b/Foundation/GTMNSAppleEventDescriptor+HandlerTest.m new file mode 100644 index 0000000..769e014 --- /dev/null +++ b/Foundation/GTMNSAppleEventDescriptor+HandlerTest.m @@ -0,0 +1,70 @@ +// +// NSAppleEventDescriptor+HandlerTest.m +// +// Copyright 2008 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +#import <Carbon/Carbon.h> +#import "GTMSenTestCase.h" +#import "GTMNSAppleEventDescriptor+Foundation.h" +#import "GTMNSAppleEventDescriptor+Handler.h" +#import "GTMUnitTestDevLog.h" + +@interface GTMNSAppleEventDescriptor_HandlerTest : GTMTestCase +@end + +@implementation GTMNSAppleEventDescriptor_HandlerTest +// Most of this gets tested by the NSAppleScript+Handler tests. +- (void)testPositionalHandlers { + NSAppleEventDescriptor *desc + = [NSAppleEventDescriptor gtm_descriptorWithPositionalHandler:nil + parametersArray:[NSArray array]]; + STAssertNil(desc, @"got a desc?"); + + desc = [NSAppleEventDescriptor gtm_descriptorWithPositionalHandler:@"happy" + parametersDescriptor:nil]; + STAssertNotNil(desc, @"didn't get a desc?"); + + desc = [NSAppleEventDescriptor gtm_descriptorWithLabeledHandler:nil + labels:nil + parameters:nil + count:0]; + STAssertNil(desc, @"got a desc?"); + + AEKeyword keys[] = { keyASPrepositionGiven }; + NSString *string = @"foo"; + [GTMUnitTestDevLog expectString:@"Must pass in dictionary for " + "keyASPrepositionGiven (got foo)"]; + desc = [NSAppleEventDescriptor gtm_descriptorWithLabeledHandler:@"happy" + labels:keys + parameters:&string + count:1]; + STAssertNil(desc, @"got a desc?"); + + NSDictionary *dict = [NSDictionary dictionaryWithObject:@"bart" + forKey:[NSNumber numberWithInt:4]]; + [GTMUnitTestDevLog expectString:@"Keys must be of type NSString or " + "GTMFourCharCode: 4"]; + [GTMUnitTestDevLog expectPattern:@"Dictionary for keyASPrepositionGiven must " + "be a user record field dictionary \\(got .*"]; + desc = [NSAppleEventDescriptor gtm_descriptorWithLabeledHandler:@"happy" + labels:keys + parameters:&dict + count:1]; + STAssertNil(desc, @"got a desc?"); + +} + +@end |