1 /* Contributed by Nicola Pero on Tue Mar 6 23:05:53 CET 2001 */
4 #include "../../objc-obj-c++-shared/runtime.h"
7 * Standard Tests For Methods of Classes and Objects - abort upon
8 * failing; return normally if all is well.
11 /* Test that `class' has an instance method for the selector `selector' */
12 void test_that_class_has_instance_method (const char *class_name
,
15 Class
class = objc_getClass (class_name
);
17 if (class_getInstanceMethod (class, selector
) == NULL
)
19 printf ("test_class_has_instance_method failed\n");
24 /* Test that `class' has a class method for the selector `selector' */
25 void test_that_class_has_class_method (const char *class_name
,
28 Class
class = objc_getClass (class_name
);
30 if (class_getClassMethod (class, selector
) == NULL
)
32 printf ("test_class_has_class_method failed\n");
37 /* Test the accessor methods (called -state and -setState:) on the
39 #ifdef TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD
40 void test_accessor_method (TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD object
,
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");
51 [object setState
: new_state_0
];
52 if ([object state
] != expected_result_0
)
54 printf ("test_accessor_method (new_state_0) failed\n");
58 [object setState
: new_state_1
];
59 if ([object state
] != expected_result_1
)
61 printf ("test_accessor_method (new_state_1) failed\n");
65 #endif /* CLASS_WITH_ACCESSOR_METHOD */