OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [objc/] [execute/] [class-tests-2.h] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* 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 <stdlib.h>
5
 
6
/*
7
 * Standard Tests For Methods of Classes and Objects - abort upon
8
 * failing; return normally if all is well.
9
 */
10
 
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)
14
{
15
  Class class = objc_lookup_class (class_name);
16
 
17
  if (class_get_instance_method (class, selector) == NULL)
18
    {
19
      printf ("test_class_has_instance_method failed\n");
20
      abort ();
21
    }
22
}
23
 
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)
27
{
28
  Class meta_class = objc_get_meta_class (class_name);
29
 
30
  if (class_get_class_method (meta_class, selector) == NULL)
31
    {
32
      printf ("test_class_has_class_method failed\n");
33
      abort ();
34
    }
35
}
36
 
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)
44
{
45
  if ([object state] != initial_state)
46
    {
47
      printf ("test_accessor_method (initial state) failed\n");
48
      abort ();
49
    }
50
 
51
  [object setState: new_state_0];
52
  if ([object state] != expected_result_0)
53
    {
54
      printf ("test_accessor_method (new_state_0) failed\n");
55
      abort ();
56
    }
57
 
58
  [object setState: new_state_1];
59
  if ([object state] != expected_result_1)
60
    {
61
      printf ("test_accessor_method (new_state_1) failed\n");
62
      abort ();
63
    }
64
}
65
#endif /* CLASS_WITH_ACCESSOR_METHOD */
66
 
67
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.