//
// Test.h
// MYUtilities
//
// Created by Jens Alfke on 1/5/08.
// Copyright 2008 Jens Alfke. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "CollectionUtils.h"
#import "Logging.h"
/** Call this first thing in main() to run tests.
This function is a no-op if the DEBUG macro is not defined (i.e. in a release build).
At runtime, to cause a particular test "X" to run, add a command-line argument "Test_X".
To run all tests, add the argument "Test_All".
To run only tests without starting the main program, add the argument "Test_Only". */
#if DEBUG
void RunTestCases( int argc, const char **argv );
extern BOOL gRunningTestCase;
#else
#define RunTestCases(ARGC,ARGV)
#define gRunningTestCase NO
#endif
/** The TestCase() macro declares a test case.
Its argument is a name for the test case (without quotes), and it's followed with a block
of code implementing the test.
The code should raise an exception if anything fails.
The CAssert, CAssertEqual and CAssertEq macros, below, are the most useful way to do this.
A test case can register a dependency on another test case by calling RequireTestCase().
Example:
TestCase(MyLib) {
RequireTestCase("LibIDependOn");
CAssertEq( myFunction(), 12345 );
}
Test cases are disabled if the DEBUG macro is not defined (i.e. in a release build). */
#if DEBUG
#define TestCase(NAME) __attribute__ ((section ("__TEXT, Tests"))) void Test_##NAME(void); \
struct TestCaseLink linkToTest##NAME = {&Test_##NAME,#NAME}; \
__attribute__((constructor)) static void registerTestCase##NAME() \
{linkToTest##NAME.next = gAllTestCases; gAllTestCases=&linkToTest##NAME; } \
void Test_##NAME(void)
#else
#define TestCase(NAME) __attribute__((unused)) static void Test_##NAME(void)
#endif
/** Can call this in a test case to indicate a prerequisite.
The prerequisite test will be run first, and if it fails, the current test case will be skipped. */
#if DEBUG
#define RequireTestCase(NAME) _RequireTestCase(#NAME)
void _RequireTestCase( const char *name );
#else
#define RequireTestCase(NAME)
#endif
/** General-purpose assertions, replacing NSAssert etc.. You can use these outside test cases. */
#define Assert(COND,MSG...) do{ if( __builtin_expect(!(COND),NO) ) { \
IN_SEGMENT_NORETURN(Logging) {_AssertFailed(self,_cmd, __FILE__, __LINE__,\
#COND,##MSG,NULL);} } }while(0)
#define CAssert(COND,MSG...) do{ if( __builtin_expect(!(COND),NO) ) { \
static const char *_name = __PRETTY_FUNCTION__;\
IN_SEGMENT_NORETURN(Logging) {_AssertFailed(nil, _name, __FILE__, __LINE__,\
#COND,##MSG,NULL);} } }while(0)
// AssertEqual is for Obj-C objects
#define AssertEqual(VAL,EXPECTED) do{ id _val = VAL, _expected = EXPECTED;\
Assert(_val==_expected || [_val isEqual: _expected], @"Unexpected value for %s: %@ (expected %@)", #VAL,_val,_expected); \
}while(0)
#define CAssertEqual(VAL,EXPECTED) do{ id _val = (VAL), _expected = (EXPECTED);\
CAssert(_val==_expected || [_val isEqual: _expected], @"Unexpected value for %s: %@ (expected %@)", #VAL,_val,_expected); \
}while(0)
// AssertEq is for scalars (int, float...)
#define AssertEq(VAL,EXPECTED) do{ __typeof(VAL) _val = VAL; __typeof(EXPECTED) _expected = EXPECTED;\
Assert(_val==_expected, @"Unexpected value for %s: %@ (expected %@)", #VAL,$object(_val),$object(_expected)); \
}while(0)
#define CAssertEq(VAL,EXPECTED) do{ __typeof(VAL) _val = VAL; __typeof(EXPECTED) _expected = EXPECTED;\
CAssert(_val==_expected, @"Unexpected value for %s: %@ (expected %@)", #VAL,$object(_val),$object(_expected)); \
}while(0)
#define AssertNil(VAL) AssertEq((VAL),nil)
#define CAssertNil(VAL) CAssertEq((VAL),nil)
#define AssertAbstractMethod() _AssertAbstractMethodFailed(self,_cmd);
// Nasty internals ...
#if DEBUG
void _RunTestCase( void (*testptr)(), const char *name );
struct TestCaseLink {void (*testptr)(); const char *name; BOOL passed; struct TestCaseLink *next;};
extern struct TestCaseLink *gAllTestCases;
#endif // DEBUG
void _AssertFailed( id rcvr, const void *selOrFn, const char *sourceFile, int sourceLine,
const char *condString, NSString *message, ... ) __attribute__((noreturn));
void _AssertAbstractMethodFailed( id rcvr, SEL cmd) __attribute__((noreturn));
没有合适的资源?快使用搜索试试~ 我知道了~
IOS应用源码之bryansum-iPong-8c15a5f.zip
共75个文件
m:24个
h:23个
png:9个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 119 浏览量
2022-06-22
07:31:03
上传
评论
收藏 734KB ZIP 举报
温馨提示
IOS应用源码之bryansum-iPong-8c15a5f.zip
资源推荐
资源详情
资源评论
收起资源包目录
IOS应用源码之bryansum-iPong-8c15a5f.zip (75个子文件)
bryansum-iPong-8c15a5f
MYUtilities
Test.h 5KB
Logging.h 4KB
ConcurrentOperation.h 287B
IntegerArray.h 475B
ConcurrentOperation.m 3KB
MYUtilities_Release.xcconfig 321B
CollectionUtils.m 11KB
ExceptionUtils.m 6KB
Logging.m 6KB
MYUtilitiesTest_main.m 247B
MYUtilities_Prefix.pch 190B
CollectionUtils.h 4KB
KVUtils.h 1KB
MYUtilities.xcconfig 841B
Test.m 6KB
Target.m 6KB
ExceptionUtils.h 2KB
With.h 480B
With.m 2KB
MYUtilities_Debug.xcconfig 275B
Target.h 531B
IntegerArray.m 912B
KVUtils.m 5KB
main.m 380B
white.png 6KB
back-button.png 4KB
lost-point.wav 173KB
iPong-Info.plist 848B
hit.wav 57KB
empty-dot.png 4KB
scoreboard.png 4KB
bounce.wav 35KB
.DS_Store 6KB
iPong_Prefix.pch 256B
pingpong.mp3 18KB
glowing-dot.png 4KB
iPong.xcodeproj
project.pbxproj 31KB
bsummersett.mode2v3 43KB
scoreboard-bg.png 4KB
won-point.wav 259KB
tap.aif 22KB
scoreboard-divider.png 3KB
.gitignore 161B
happy.wav 170KB
English.lproj
Localizable.strings 2KB
bg-pattern.png 51KB
6002b.jpg 33KB
Classes
AccelerometerHandler.h 507B
iPongAppDelegate.h 448B
SwingTimer.m 2KB
InGameView.h 743B
VCView.m 614B
Jukebox.m 2KB
Utilities.m 391B
AIOpponent.m 4KB
InGameViewController.h 2KB
AccelerometerHandler.m 2KB
ScoreKeeper.m 1KB
InGameViewController.m 13KB
VCView.h 477B
ScoreKeeper.h 724B
InGameView.m 5KB
SwingTimer.h 1KB
AIOpponent.h 1KB
Jukebox.h 320B
PongEvent.m 2KB
Opponent
BluetoothOpponent.h 957B
BluetoothOpponent.m 16KB
NetOpponent.h 1KB
NetOpponent.m 903B
Opponent.h 961B
Utilities.h 281B
iPongAppDelegate.m 1KB
PongEvent.h 1010B
paddle.png 60KB
共 75 条
- 1
资源评论
BryanDing
- 粉丝: 299
- 资源: 5583
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功