nsoperation.m 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (c) 2008-2011 Apple Inc. All rights reserved.
  3. *
  4. * @APPLE_APACHE_LICENSE_HEADER_START@
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. * @APPLE_APACHE_LICENSE_HEADER_END@
  19. */
  20. #include <stdlib.h>
  21. #include <assert.h>
  22. #include <stdio.h>
  23. #include <string.h>
  24. #include <Foundation/Foundation.h>
  25. #include <dispatch/dispatch.h>
  26. #include <bsdtests.h>
  27. #include "dispatch_test.h"
  28. @interface MYOperation : NSOperation
  29. {
  30. }
  31. @end
  32. @implementation MYOperation
  33. - (id) init
  34. {
  35. self = [super init];
  36. return self;
  37. }
  38. - (void)main
  39. {
  40. test_stop();
  41. }
  42. @end
  43. int
  44. main(void)
  45. {
  46. dispatch_test_start("NSOperation");
  47. NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  48. NSOperationQueue *queue = [[[NSOperationQueue alloc] init] autorelease];
  49. test_ptr_notnull("NSOperationQueue", queue);
  50. MYOperation *operation = [[MYOperation alloc] init];
  51. test_ptr_notnull("NSOperation", operation);
  52. [queue addOperation:operation];
  53. [operation release];
  54. [[NSRunLoop mainRunLoop] run];
  55. [pool release];
  56. return 0;
  57. }