2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / objc / execute / class-tests-2.h
blob7f6f54000f73da98f9fa8ee4baa84642b08dc52b
1 /* Contributed by Nicola Pero on Tue Mar 6 23:05:53 CET 2001 */
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include "../../objc-obj-c++-shared/runtime.h"
6 /*
7 * Standard Tests For Methods of Classes and Objects - abort upon
8 * failing; return normally if all is well.
9 */
11 /* Test that `class' has an instance method for the selector `selector' */
12 void test_that_class_has_instance_method (const char *class_name,
13 SEL selector)
15 Class class = objc_getClass (class_name);
17 if (class_getInstanceMethod (class, selector) == NULL)
19 printf ("test_class_has_instance_method failed\n");
20 abort ();
24 /* Test that `class' has a class method for the selector `selector' */
25 void test_that_class_has_class_method (const char *class_name,
26 SEL selector)
28 Class class = objc_getClass (class_name);
30 if (class_getClassMethod (class, selector) == NULL)
32 printf ("test_class_has_class_method failed\n");
33 abort ();
37 /* Test the accessor methods (called -state and -setState:) on the
38 object `object'. */
39 #ifdef TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD
40 void test_accessor_method (TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD object,
41 int initial_state,
42 int new_state_0, int expected_result_0,
43 int new_state_1, int expected_result_1)
45 if ([object state] != initial_state)
47 printf ("test_accessor_method (initial state) failed\n");
48 abort ();
51 [object setState: new_state_0];
52 if ([object state] != expected_result_0)
54 printf ("test_accessor_method (new_state_0) failed\n");
55 abort ();
58 [object setState: new_state_1];
59 if ([object state] != expected_result_1)
61 printf ("test_accessor_method (new_state_1) failed\n");
62 abort ();
65 #endif /* CLASS_WITH_ACCESSOR_METHOD */