Added support for the 64-bit Apple Objective-C runtime
[official-gcc.git] / gcc / testsuite / objc / execute / class-tests-2.h
blob1aa73947d635437defe480db9bcdfa416e50a661
1 /* Contributed by Nicola Pero on Tue Mar 6 23:05:53 CET 2001 */
2 #include <objc/objc.h>
3 #include <objc/objc-api.h>
4 #include <stdio.h>
5 #include <stdlib.h>
7 /*
8 * Standard Tests For Methods of Classes and Objects - abort upon
9 * failing; return normally if all is well.
12 /* Test that `class' has an instance method for the selector `selector' */
13 void test_that_class_has_instance_method (const char *class_name,
14 SEL selector)
16 Class class = objc_lookup_class (class_name);
18 if (class_get_instance_method (class, selector) == NULL)
20 printf ("test_class_has_instance_method failed\n");
21 abort ();
25 /* Test that `class' has a class method for the selector `selector' */
26 void test_that_class_has_class_method (const char *class_name,
27 SEL selector)
29 Class meta_class = objc_get_meta_class (class_name);
31 if (class_get_class_method (meta_class, selector) == NULL)
33 printf ("test_class_has_class_method failed\n");
34 abort ();
38 /* Test the accessor methods (called -state and -setState:) on the
39 object `object'. */
40 #ifdef TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD
41 void test_accessor_method (TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD object,
42 int initial_state,
43 int new_state_0, int expected_result_0,
44 int new_state_1, int expected_result_1)
46 if ([object state] != initial_state)
48 printf ("test_accessor_method (initial state) failed\n");
49 abort ();
52 [object setState: new_state_0];
53 if ([object state] != expected_result_0)
55 printf ("test_accessor_method (new_state_0) failed\n");
56 abort ();
59 [object setState: new_state_1];
60 if ([object state] != expected_result_1)
62 printf ("test_accessor_method (new_state_1) failed\n");
63 abort ();
66 #endif /* CLASS_WITH_ACCESSOR_METHOD */