2010-01-07 16:28:47 +01:00
|
|
|
/* SOGoTest.h - this file is part of SOGo
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Inverse inc.
|
|
|
|
*
|
|
|
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
|
|
|
*
|
|
|
|
* This file is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SOGOTEST_H
|
|
|
|
#define SOGOTEST_H
|
|
|
|
|
|
|
|
#import <Foundation/NSObject.h>
|
2010-01-07 17:37:36 +01:00
|
|
|
#import <Foundation/NSString.h>
|
2015-08-25 16:41:38 +02:00
|
|
|
#import <Foundation/NSArray.h>
|
|
|
|
#import <Foundation/NSData.h>
|
2012-04-23 20:39:26 +02:00
|
|
|
#import <Foundation/NSValue.h>
|
2010-01-07 16:28:47 +01:00
|
|
|
|
|
|
|
@class NSArray;
|
|
|
|
@class NSMutableArray;
|
|
|
|
|
2010-01-08 16:46:00 +01:00
|
|
|
@class SOGoTestRunner;
|
2010-01-07 16:28:47 +01:00
|
|
|
|
|
|
|
@interface SOGoTest : NSObject
|
|
|
|
{
|
2010-01-08 16:46:00 +01:00
|
|
|
SOGoTestRunner *testRunner;
|
2010-01-07 16:28:47 +01:00
|
|
|
BOOL hasFailed;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSArray *) allTestClasses;
|
|
|
|
|
2010-01-08 16:46:00 +01:00
|
|
|
- (void) setTestRunner: (SOGoTestRunner *) newTestRunner;
|
|
|
|
|
2010-01-07 16:28:47 +01:00
|
|
|
- (void) setUp;
|
|
|
|
- (void) tearDown;
|
|
|
|
|
|
|
|
- (void) test: (BOOL) condition
|
|
|
|
message: (NSString *) message
|
|
|
|
file: (const char *) file
|
|
|
|
line: (int) line;
|
|
|
|
|
|
|
|
- (BOOL) run;
|
|
|
|
|
2015-08-30 14:13:05 +02:00
|
|
|
- (NSString*) stringFromDiffBetween: (NSString*) str1
|
|
|
|
and: (NSString*) str2;
|
2010-01-07 16:28:47 +01:00
|
|
|
@end
|
|
|
|
|
|
|
|
#define test(c) { \
|
2011-07-19 22:01:13 +02:00
|
|
|
[self test: (c) message: @"assertion failure" \
|
2010-01-07 16:28:47 +01:00
|
|
|
file: __FILE__ line: __LINE__]; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define testWithMessage(c,m) { \
|
|
|
|
[self test: (c) message: (m) \
|
|
|
|
file: __FILE__ line: __LINE__]; \
|
|
|
|
}
|
|
|
|
|
2011-07-19 22:01:13 +02:00
|
|
|
#define failIf(c) test(!(c))
|
2010-01-07 16:28:47 +01:00
|
|
|
|
|
|
|
#define testEquals(a,b) \
|
2012-04-23 20:39:26 +02:00
|
|
|
testWithMessage((((a) == (b)) || ([(a) isEqual: (b)]) \
|
|
|
|
|| ([(a) isKindOfClass: [NSNumber class]] \
|
|
|
|
&& [(b) isKindOfClass: [NSNumber class]] \
|
|
|
|
&& [(NSNumber *) (a) isEqualToNumber: (NSNumber *) (b)])), \
|
2010-01-07 17:37:36 +01:00
|
|
|
([NSString stringWithFormat: @"objects '%@' and '%@' differs", (a), (b)]))
|
2010-01-07 16:28:47 +01:00
|
|
|
|
|
|
|
#define testEqualsWithMessage(a,b,m) \
|
2011-07-19 22:01:13 +02:00
|
|
|
testWithMessage(([(a) isEqual: (b)]), (m))
|
2010-01-07 16:28:47 +01:00
|
|
|
|
|
|
|
#endif /* SOGOTEST_H */
|