File: TestCase.h

package info (click to toggle)
gnustep-base 1.31.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,580 kB
  • sloc: objc: 239,446; ansic: 36,519; cpp: 122; sh: 112; makefile: 100; xml: 32
file content (129 lines) | stat: -rw-r--r-- 3,554 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* -*- objc -*- 
 *
 *  Author: Sergei Golovin <svgdev@mail.ru>
 */

#import <Foundation/Foundation.h>

/* the initial (reset) state of any flag set */
#define NORESULTS     0

/**
 *  A class representing some test case and implementing
 *  the protocol TestProgress allows descendants to have two sets
 *  of flags: the reference one and the actual one.
 *  The reference flag set is what the class's instance's
 *  state supposed to be if the test was successfull.
 *  The actual flag set is the current state of the class's
 *  instance during execution of the test.
 *  Both can be used in conjuction to decide about test's
 *  success or fail by checking at the end of the test
 *  whether the sets are identical.
 */ 
@protocol TestProgress

/**
 * Resets the actual flags to the pristine state (NORESULTS).
 */
- (void)resetFlags;

/**
 * Sets the actual flags defined by the supplied mask.
 */
- (void)setFlags:(NSUInteger)mask;

/**
 * Unset the actual flags defined by the supplied mask.
 */
- (void)unsetFlags:(NSUInteger)mask;

/**
 * Returns YES if the actual flags defined by the supplied mask are
 * set.
 */
- (BOOL)isFlagSet:(NSUInteger)mask;

/**
 * Resets the reference flags to the pristine state (NORESULTS).
 */
- (void)resetReferenceFlags;

/**
 * Stores the supplied mask as the reference flags state.
 * The actual flags state equal to the reference one signifies
 * a success.
 */
- (void)setReferenceFlags:(NSUInteger)mask;

/**
 * Unset the reference flags defined by the supplied mask.
 */
- (void)unsetReferenceFlags:(NSUInteger)mask;

/**
 * Returns YES if the reference flags defined by the supplied mask are
 * set.
 */
- (BOOL)isReferenceFlagSet:(NSUInteger)mask;

/**
 * Returns YES if all conditions are met (by default if the actual flag set
 * is equal to the reference flag set).
 */
- (BOOL)isSuccess;

@end /* TestProgress */

/**
 *  The abstract class representing a test case and implementing
 *  the protocol TestProgress.
 */
@interface TestCase : NSObject <TestProgress>
{
  /* the flags indicating test progress (the actual one) */
  NSUInteger         _flags;
  /* the reference flag set signifying the test's successful state */
  NSUInteger      _refFlags;
  /* the particular flag indicating a failure not related to the test */
  BOOL             _failed;
  /* the particular flag signifying the test has been done */
  BOOL _done;
  /* keeps the extra which can likely be of NSDictionary class in which case
   * it's keys hold parameters of the test */
  id _extra;
  /* the debug mode flag */
  BOOL _debug;
}

- (id)init;

/**
 *  A descendant class can place in the own implementation of the method
 *  some preliminary code needed to conduct the test case. The argument
 *  'extra' is for future enhancements. The extra is only retained within
 *  the method for descendants (the abstarct class doesn't do anything
 *  with this argument).
 *  So descendant's implementation MUST call the super's one.
 */
- (void)setUpTest:(id)extra;

/**
 *  A descendant class should place the code conducting the test in
 *  the own implementation of the method. The argument 'extra' is for
 *  future enhancements.
 */
- (void)startTest:(id)extra;

/**
 *  A descendant class can place in the own implementation of the method
 *  some cleaning code. The argument 'extra' is for future enhancements.
 *  Descendant's implementation MUST call the super's one.
 */
- (void)tearDownTest:(id)extra;

/**
 *  Raises the verbosity level if supplied with YES.
 */
- (void)setDebug:(BOOL)flag;

@end /* TestCase */