1 /* Contributed by Nicola Pero on Tue Mar 6 23:05:53 CET 2001 */
3 #include <objc/objc-api.h>
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
,
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");
25 /* Test that `class' has a class method for the selector `selector' */
26 void test_that_class_has_class_method (const char *class_name
,
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");
38 /* Test the accessor methods (called -state and -setState:) on the
40 #ifdef TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD
41 void test_accessor_method (TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD object
,
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");
52 [object setState
: new_state_0
];
53 if ([object state
] != expected_result_0
)
55 printf ("test_accessor_method (new_state_0) failed\n");
59 [object setState
: new_state_1
];
60 if ([object state
] != expected_result_1
)
62 printf ("test_accessor_method (new_state_1) failed\n");
66 #endif /* CLASS_WITH_ACCESSOR_METHOD */