* Made Test.h work with regular C99 without GCC extensions.
* Copied the necessary Google Toolbox source files into the project, so users don't have to download an additional library.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/GoogleToolboxSubset/GTMDefines.h Sun Jun 01 14:01:44 2008 -0700
1.3 @@ -0,0 +1,138 @@
1.4 +//
1.5 +// GTMDefines.h
1.6 +//
1.7 +// Copyright 2008 Google Inc.
1.8 +//
1.9 +// Licensed under the Apache License, Version 2.0 (the "License"); you may not
1.10 +// use this file except in compliance with the License. You may obtain a copy
1.11 +// of the License at
1.12 +//
1.13 +// http://www.apache.org/licenses/LICENSE-2.0
1.14 +//
1.15 +// Unless required by applicable law or agreed to in writing, software
1.16 +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
1.17 +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1.18 +// License for the specific language governing permissions and limitations under
1.19 +// the License.
1.20 +//
1.21 +
1.22 +// ============================================================================
1.23 +
1.24 +// ----------------------------------------------------------------------------
1.25 +// CPP symbols that can be overridden in a prefix to control how the toolbox
1.26 +// is compiled.
1.27 +// ----------------------------------------------------------------------------
1.28 +
1.29 +
1.30 +// GTMHTTPFetcher will support logging by default but only hook its input
1.31 +// stream support for logging when requested. You can control the inclusion of
1.32 +// the code by providing your own definitions for these w/in a prefix header.
1.33 +//
1.34 +#ifndef GTM_HTTPFETCHER_ENABLE_LOGGING
1.35 +# define GTM_HTTPFETCHER_ENABLE_LOGGING 1
1.36 +#endif // GTM_HTTPFETCHER_ENABLE_LOGGING
1.37 +#ifndef GTM_HTTPFETCHER_ENABLE_INPUTSTREAM_LOGGING
1.38 +# define GTM_HTTPFETCHER_ENABLE_INPUTSTREAM_LOGGING 0
1.39 +#endif // GTM_HTTPFETCHER_ENABLE_INPUTSTREAM_LOGGING
1.40 +
1.41 +
1.42 +// _GTMDevLog & _GTMDevAssert
1.43 +//
1.44 +// _GTMDevLog & _GTMDevAssert are meant to be a very lightweight shell for
1.45 +// developer level errors. This implementation simply macros to NSLog/NSAssert.
1.46 +// It is not intended to be a general logging/reporting system.
1.47 +//
1.48 +// Please see http://code.google.com/p/google-toolbox-for-mac/wiki/DevLogNAssert
1.49 +// for a little more background on the usage of these macros.
1.50 +//
1.51 +// _GTMDevLog log some error/problem in debug builds
1.52 +// _GTMDevAssert assert if conditon isn't met w/in a method/function
1.53 +// in all builds.
1.54 +//
1.55 +// To replace this system, just provide different macro definitions in your
1.56 +// prefix header. Remember, any implementation you provide *must* be thread
1.57 +// safe since this could be called by anything in what ever situtation it has
1.58 +// been placed in.
1.59 +//
1.60 +
1.61 +// We only define the simple macros if nothing else has defined this.
1.62 +#ifndef _GTMDevLog
1.63 +
1.64 +#ifdef DEBUG
1.65 + #define _GTMDevLog(...) NSLog(__VA_ARGS__)
1.66 +#else
1.67 + #define _GTMDevLog(...) do { } while (0)
1.68 +#endif
1.69 +
1.70 +// we directly invoke the NSAssert handler so we can pass on the varargs
1.71 +// (NSAssert doesn't have a macro we can use that takes varargs)
1.72 +#if !defined(NS_BLOCK_ASSERTIONS)
1.73 +#define _GTMDevAssert(condition, ...) \
1.74 + do { \
1.75 + if (!(condition)) { \
1.76 + [[NSAssertionHandler currentHandler] \
1.77 + handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__] \
1.78 + file:[NSString stringWithCString:__FILE__] \
1.79 + lineNumber:__LINE__ \
1.80 + description:__VA_ARGS__]; \
1.81 + } \
1.82 + } while(0)
1.83 +#else // !defined(NS_BLOCK_ASSERTIONS)
1.84 +#define _GTMDevAssert(condition, ...) do { } while (0)
1.85 +#endif // !defined(NS_BLOCK_ASSERTIONS)
1.86 +
1.87 +#endif // _GTMDevLog
1.88 +
1.89 +// ============================================================================
1.90 +
1.91 +// ----------------------------------------------------------------------------
1.92 +// CPP symbols defined based on the project settings so the GTM code has
1.93 +// simple things to test against w/o scattering the knowledge of project
1.94 +// setting through all the code.
1.95 +// ----------------------------------------------------------------------------
1.96 +
1.97 +// Provide a single constant CPP symbol that all of GTM uses for ifdefing
1.98 +// iPhone code.
1.99 +#include <TargetConditionals.h>
1.100 +#if TARGET_OS_IPHONE // iPhone SDK
1.101 + // For iPhone specific stuff
1.102 + #define GTM_IPHONE_SDK 1
1.103 +#else
1.104 + // For MacOS specific stuff
1.105 + #define GTM_MACOS_SDK 1
1.106 +#endif
1.107 +
1.108 +// To simplify support for 64bit (and Leopard in general), we provide the type
1.109 +// defines for non Leopard SDKs
1.110 +#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
1.111 + // NSInteger/NSUInteger and Max/Mins
1.112 + #ifndef NSINTEGER_DEFINED
1.113 + #if __LP64__ || NS_BUILD_32_LIKE_64
1.114 + typedef long NSInteger;
1.115 + typedef unsigned long NSUInteger;
1.116 + #else
1.117 + typedef int NSInteger;
1.118 + typedef unsigned int NSUInteger;
1.119 + #endif
1.120 + #define NSIntegerMax LONG_MAX
1.121 + #define NSIntegerMin LONG_MIN
1.122 + #define NSUIntegerMax ULONG_MAX
1.123 + #define NSINTEGER_DEFINED 1
1.124 + #endif // NSINTEGER_DEFINED
1.125 + // CGFloat
1.126 + #ifndef CGFLOAT_DEFINED
1.127 + #if defined(__LP64__) && __LP64__
1.128 + // This really is an untested path (64bit on Tiger?)
1.129 + typedef double CGFloat;
1.130 + #define CGFLOAT_MIN DBL_MIN
1.131 + #define CGFLOAT_MAX DBL_MAX
1.132 + #define CGFLOAT_IS_DOUBLE 1
1.133 + #else /* !defined(__LP64__) || !__LP64__ */
1.134 + typedef float CGFloat;
1.135 + #define CGFLOAT_MIN FLT_MIN
1.136 + #define CGFLOAT_MAX FLT_MAX
1.137 + #define CGFLOAT_IS_DOUBLE 0
1.138 + #endif /* !defined(__LP64__) || !__LP64__ */
1.139 + #define CGFLOAT_DEFINED 1
1.140 + #endif // CGFLOAT_DEFINED
1.141 +#endif // MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/GoogleToolboxSubset/GTMNSData+zlib.h Sun Jun 01 14:01:44 2008 -0700
2.3 @@ -0,0 +1,84 @@
2.4 +//
2.5 +// GTMNSData+zlib.h
2.6 +//
2.7 +// Copyright 2007-2008 Google Inc.
2.8 +//
2.9 +// Licensed under the Apache License, Version 2.0 (the "License"); you may not
2.10 +// use this file except in compliance with the License. You may obtain a copy
2.11 +// of the License at
2.12 +//
2.13 +// http://www.apache.org/licenses/LICENSE-2.0
2.14 +//
2.15 +// Unless required by applicable law or agreed to in writing, software
2.16 +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
2.17 +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
2.18 +// License for the specific language governing permissions and limitations under
2.19 +// the License.
2.20 +//
2.21 +
2.22 +#import <Foundation/Foundation.h>
2.23 +#import "GTMDefines.h"
2.24 +
2.25 +/// Helpers for dealing w/ zlib inflate/deflate calls.
2.26 +@interface NSData (GTMZLibAdditions)
2.27 +
2.28 +/// Return an autoreleased NSData w/ the result of gzipping the bytes.
2.29 +//
2.30 +// Uses the default compression level.
2.31 ++ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
2.32 + length:(NSUInteger)length;
2.33 +
2.34 +/// Return an autoreleased NSData w/ the result of gzipping the payload of |data|.
2.35 +//
2.36 +// Uses the default compression level.
2.37 ++ (NSData *)gtm_dataByGzippingData:(NSData *)data;
2.38 +
2.39 +/// Return an autoreleased NSData w/ the result of gzipping the bytes using |level| compression level.
2.40 +//
2.41 +// |level| can be 1-9, any other values will be clipped to that range.
2.42 ++ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
2.43 + length:(NSUInteger)length
2.44 + compressionLevel:(int)level;
2.45 +
2.46 +/// Return an autoreleased NSData w/ the result of gzipping the payload of |data| using |level| compression level.
2.47 ++ (NSData *)gtm_dataByGzippingData:(NSData *)data
2.48 + compressionLevel:(int)level;
2.49 +
2.50 +// NOTE: deflate is *NOT* gzip. deflate is a "zlib" stream. pick which one
2.51 +// you really want to create. (the inflate api will handle either)
2.52 +
2.53 +/// Return an autoreleased NSData w/ the result of deflating the bytes.
2.54 +//
2.55 +// Uses the default compression level.
2.56 ++ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
2.57 + length:(NSUInteger)length;
2.58 +
2.59 +/// Return an autoreleased NSData w/ the result of deflating the payload of |data|.
2.60 +//
2.61 +// Uses the default compression level.
2.62 ++ (NSData *)gtm_dataByDeflatingData:(NSData *)data;
2.63 +
2.64 +/// Return an autoreleased NSData w/ the result of deflating the bytes using |level| compression level.
2.65 +//
2.66 +// |level| can be 1-9, any other values will be clipped to that range.
2.67 ++ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
2.68 + length:(NSUInteger)length
2.69 + compressionLevel:(int)level;
2.70 +
2.71 +/// Return an autoreleased NSData w/ the result of deflating the payload of |data| using |level| compression level.
2.72 ++ (NSData *)gtm_dataByDeflatingData:(NSData *)data
2.73 + compressionLevel:(int)level;
2.74 +
2.75 +
2.76 +/// Return an autoreleased NSData w/ the result of decompressing the bytes.
2.77 +//
2.78 +// The bytes to decompress can be zlib or gzip payloads.
2.79 ++ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes
2.80 + length:(NSUInteger)length;
2.81 +
2.82 +/// Return an autoreleased NSData w/ the result of decompressing the payload of |data|.
2.83 +//
2.84 +// The data to decompress can be zlib or gzip payloads.
2.85 ++ (NSData *)gtm_dataByInflatingData:(NSData *)data;
2.86 +
2.87 +@end
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/GoogleToolboxSubset/GTMNSData+zlib.m Sun Jun 01 14:01:44 2008 -0700
3.3 @@ -0,0 +1,267 @@
3.4 +//
3.5 +// GTMNSData+zlib.m
3.6 +//
3.7 +// Copyright 2007-2008 Google Inc.
3.8 +//
3.9 +// Licensed under the Apache License, Version 2.0 (the "License"); you may not
3.10 +// use this file except in compliance with the License. You may obtain a copy
3.11 +// of the License at
3.12 +//
3.13 +// http://www.apache.org/licenses/LICENSE-2.0
3.14 +//
3.15 +// Unless required by applicable law or agreed to in writing, software
3.16 +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
3.17 +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
3.18 +// License for the specific language governing permissions and limitations under
3.19 +// the License.
3.20 +//
3.21 +
3.22 +#import "GTMNSData+zlib.h"
3.23 +#import <zlib.h>
3.24 +#import "GTMDefines.h"
3.25 +
3.26 +#define kChunkSize 1024
3.27 +
3.28 +@interface NSData (GTMZlibAdditionsPrivate)
3.29 ++ (NSData *)gtm_dataByCompressingBytes:(const void *)bytes
3.30 + length:(NSUInteger)length
3.31 + compressionLevel:(int)level
3.32 + useGzip:(BOOL)useGzip;
3.33 +@end
3.34 +
3.35 +@implementation NSData (GTMZlibAdditionsPrivate)
3.36 ++ (NSData *)gtm_dataByCompressingBytes:(const void *)bytes
3.37 + length:(NSUInteger)length
3.38 + compressionLevel:(int)level
3.39 + useGzip:(BOOL)useGzip {
3.40 + if (!bytes || !length) {
3.41 + return nil;
3.42 + }
3.43 +
3.44 + // TODO: support 64bit inputs
3.45 + // avail_in is a uInt, so if length > UINT_MAX we actually need to loop
3.46 + // feeding the data until we've gotten it all in. not supporting this
3.47 + // at the moment.
3.48 + _GTMDevAssert(length <= UINT_MAX, @"Currently don't support >32bit lengths");
3.49 +
3.50 + if (level == Z_DEFAULT_COMPRESSION) {
3.51 + // the default value is actually outside the range, so we have to let it
3.52 + // through specifically.
3.53 + } else if (level < Z_BEST_SPEED) {
3.54 + level = Z_BEST_SPEED;
3.55 + } else if (level > Z_BEST_COMPRESSION) {
3.56 + level = Z_BEST_COMPRESSION;
3.57 + }
3.58 +
3.59 + z_stream strm;
3.60 + bzero(&strm, sizeof(z_stream));
3.61 +
3.62 + int windowBits = 15; // the default
3.63 + int memLevel = 8; // the default
3.64 + if (useGzip) {
3.65 + windowBits += 16; // enable gzip header instead of zlib header
3.66 + }
3.67 + int retCode;
3.68 + if ((retCode = deflateInit2(&strm, level, Z_DEFLATED, windowBits,
3.69 + memLevel, Z_DEFAULT_STRATEGY)) != Z_OK) {
3.70 + // COV_NF_START - no real way to force this in a unittest (we guard all args)
3.71 + _GTMDevLog(@"Failed to init for deflate w/ level %d, error %d",
3.72 + level, retCode);
3.73 + return nil;
3.74 + // COV_NF_END
3.75 + }
3.76 +
3.77 + // hint the size at 1/4 the input size
3.78 + NSMutableData *result = [NSMutableData dataWithCapacity:(length/4)];
3.79 + unsigned char output[kChunkSize];
3.80 +
3.81 + // setup the input
3.82 + strm.avail_in = (unsigned int)length;
3.83 + strm.next_in = (unsigned char*)bytes;
3.84 +
3.85 + // loop to collect the data
3.86 + do {
3.87 + // update what we're passing in
3.88 + strm.avail_out = kChunkSize;
3.89 + strm.next_out = output;
3.90 + retCode = deflate(&strm, Z_FINISH);
3.91 + if ((retCode != Z_OK) && (retCode != Z_STREAM_END)) {
3.92 + // COV_NF_START - no real way to force this in a unittest
3.93 + // (in inflate, we can feed bogus/truncated data to test, but an error
3.94 + // here would be some internal issue w/in zlib, and there isn't any real
3.95 + // way to test it)
3.96 + _GTMDevLog(@"Error trying to deflate some of the payload, error %d",
3.97 + retCode);
3.98 + deflateEnd(&strm);
3.99 + return nil;
3.100 + // COV_NF_END
3.101 + }
3.102 + // collect what we got
3.103 + unsigned gotBack = kChunkSize - strm.avail_out;
3.104 + if (gotBack > 0) {
3.105 + [result appendBytes:output length:gotBack];
3.106 + }
3.107 +
3.108 + } while (retCode == Z_OK);
3.109 +
3.110 + // if the loop exits, we used all input and the stream ended
3.111 + _GTMDevAssert(strm.avail_in == 0,
3.112 + @"thought we finished deflate w/o using all input, %u bytes left",
3.113 + strm.avail_in);
3.114 + _GTMDevAssert(retCode == Z_STREAM_END,
3.115 + @"thought we finished deflate w/o getting a result of stream end, code %d",
3.116 + retCode);
3.117 +
3.118 + // clean up
3.119 + deflateEnd(&strm);
3.120 +
3.121 + return result;
3.122 +} // gtm_dataByCompressingBytes:length:compressionLevel:useGzip:
3.123 +
3.124 +
3.125 +@end
3.126 +
3.127 +
3.128 +@implementation NSData (GTMZLibAdditions)
3.129 +
3.130 ++ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
3.131 + length:(NSUInteger)length {
3.132 + return [self gtm_dataByCompressingBytes:bytes
3.133 + length:length
3.134 + compressionLevel:Z_DEFAULT_COMPRESSION
3.135 + useGzip:YES];
3.136 +} // gtm_dataByGzippingBytes:length:
3.137 +
3.138 ++ (NSData *)gtm_dataByGzippingData:(NSData *)data {
3.139 + return [self gtm_dataByCompressingBytes:[data bytes]
3.140 + length:[data length]
3.141 + compressionLevel:Z_DEFAULT_COMPRESSION
3.142 + useGzip:YES];
3.143 +} // gtm_dataByGzippingData:
3.144 +
3.145 ++ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
3.146 + length:(NSUInteger)length
3.147 + compressionLevel:(int)level {
3.148 + return [self gtm_dataByCompressingBytes:bytes
3.149 + length:length
3.150 + compressionLevel:level
3.151 + useGzip:YES];
3.152 +} // gtm_dataByGzippingBytes:length:level:
3.153 +
3.154 ++ (NSData *)gtm_dataByGzippingData:(NSData *)data
3.155 + compressionLevel:(int)level {
3.156 + return [self gtm_dataByCompressingBytes:[data bytes]
3.157 + length:[data length]
3.158 + compressionLevel:level
3.159 + useGzip:YES];
3.160 +} // gtm_dataByGzippingData:level:
3.161 +
3.162 ++ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
3.163 + length:(NSUInteger)length {
3.164 + return [self gtm_dataByCompressingBytes:bytes
3.165 + length:length
3.166 + compressionLevel:Z_DEFAULT_COMPRESSION
3.167 + useGzip:NO];
3.168 +} // gtm_dataByDeflatingBytes:length:
3.169 +
3.170 ++ (NSData *)gtm_dataByDeflatingData:(NSData *)data {
3.171 + return [self gtm_dataByCompressingBytes:[data bytes]
3.172 + length:[data length]
3.173 + compressionLevel:Z_DEFAULT_COMPRESSION
3.174 + useGzip:NO];
3.175 +} // gtm_dataByDeflatingData:
3.176 +
3.177 ++ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
3.178 + length:(NSUInteger)length
3.179 + compressionLevel:(int)level {
3.180 + return [self gtm_dataByCompressingBytes:bytes
3.181 + length:length
3.182 + compressionLevel:level
3.183 + useGzip:NO];
3.184 +} // gtm_dataByDeflatingBytes:length:level:
3.185 +
3.186 ++ (NSData *)gtm_dataByDeflatingData:(NSData *)data
3.187 + compressionLevel:(int)level {
3.188 + return [self gtm_dataByCompressingBytes:[data bytes]
3.189 + length:[data length]
3.190 + compressionLevel:level
3.191 + useGzip:NO];
3.192 +} // gtm_dataByDeflatingData:level:
3.193 +
3.194 ++ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes
3.195 + length:(NSUInteger)length {
3.196 + if (!bytes || !length) {
3.197 + return nil;
3.198 + }
3.199 +
3.200 + // TODO: support 64bit inputs
3.201 + // avail_in is a uInt, so if length > UINT_MAX we actually need to loop
3.202 + // feeding the data until we've gotten it all in. not supporting this
3.203 + // at the moment.
3.204 + _GTMDevAssert(length <= UINT_MAX, @"Currently don't support >32bit lengths");
3.205 +
3.206 + z_stream strm;
3.207 + bzero(&strm, sizeof(z_stream));
3.208 +
3.209 + // setup the input
3.210 + strm.avail_in = (unsigned int)length;
3.211 + strm.next_in = (unsigned char*)bytes;
3.212 +
3.213 + int windowBits = 15; // 15 to enable any window size
3.214 + windowBits += 32; // and +32 to enable zlib or gzip header detection.
3.215 + int retCode;
3.216 + if ((retCode = inflateInit2(&strm, windowBits)) != Z_OK) {
3.217 + // COV_NF_START - no real way to force this in a unittest (we guard all args)
3.218 + _GTMDevLog(@"Failed to init for inflate, error %d", retCode);
3.219 + return nil;
3.220 + // COV_NF_END
3.221 + }
3.222 +
3.223 + // hint the size at 4x the input size
3.224 + NSMutableData *result = [NSMutableData dataWithCapacity:(length*4)];
3.225 + unsigned char output[kChunkSize];
3.226 +
3.227 + // loop to collect the data
3.228 + do {
3.229 + // update what we're passing in
3.230 + strm.avail_out = kChunkSize;
3.231 + strm.next_out = output;
3.232 + retCode = inflate(&strm, Z_NO_FLUSH);
3.233 + if ((retCode != Z_OK) && (retCode != Z_STREAM_END)) {
3.234 + _GTMDevLog(@"Error trying to inflate some of the payload, error %d",
3.235 + retCode);
3.236 + inflateEnd(&strm);
3.237 + return nil;
3.238 + }
3.239 + // collect what we got
3.240 + unsigned gotBack = kChunkSize - strm.avail_out;
3.241 + if (gotBack > 0) {
3.242 + [result appendBytes:output length:gotBack];
3.243 + }
3.244 +
3.245 + } while (retCode == Z_OK);
3.246 +
3.247 + // make sure there wasn't more data tacked onto the end of a valid compressed
3.248 + // stream.
3.249 + if (strm.avail_in != 0) {
3.250 + _GTMDevLog(@"thought we finished inflate w/o using all input, %u bytes left",
3.251 + strm.avail_in);
3.252 + result = nil;
3.253 + }
3.254 + // the only way out of the loop was by hitting the end of the stream
3.255 + _GTMDevAssert(retCode == Z_STREAM_END,
3.256 + @"thought we finished inflate w/o getting a result of stream end, code %d",
3.257 + retCode);
3.258 +
3.259 + // clean up
3.260 + inflateEnd(&strm);
3.261 +
3.262 + return result;
3.263 +} // gtm_dataByInflatingBytes:length:
3.264 +
3.265 ++ (NSData *)gtm_dataByInflatingData:(NSData *)data {
3.266 + return [self gtm_dataByInflatingBytes:[data bytes]
3.267 + length:[data length]];
3.268 +} // gtm_dataByInflatingData:
3.269 +
3.270 +@end
4.1 --- a/Test.h Sat May 31 11:26:17 2008 -0700
4.2 +++ b/Test.h Sun Jun 01 14:01:44 2008 -0700
4.3 @@ -66,6 +66,7 @@
4.4 IN_SEGMENT_NORETURN(Logging) {_AssertFailed(nil, _name, __FILE__, __LINE__,\
4.5 #COND,##MSG,NULL);} } }while(0)
4.6
4.7 +// AssertEqual is for Obj-C objects
4.8 #define AssertEqual(VAL,EXPECTED) do{ id _val = VAL, _expected = EXPECTED;\
4.9 Assert(_val==_expected || [_val isEqual: _expected], @"Unexpected value for %s: %@ (expected %@)", #VAL,_val,_expected); \
4.10 }while(0)
4.11 @@ -74,11 +75,10 @@
4.12 }while(0)
4.13
4.14 // AssertEq is for scalars (int, float...)
4.15 -// Note: "typeof()" builtin function requires settingn C language dialect to GNU99.
4.16 -#define AssertEq(VAL,EXPECTED) do{ typeof(VAL) _val = VAL; typeof(EXPECTED) _expected = EXPECTED;\
4.17 +#define AssertEq(VAL,EXPECTED) do{ __typeof(VAL) _val = VAL; __typeof(EXPECTED) _expected = EXPECTED;\
4.18 Assert(_val==_expected, @"Unexpected value for %s: %@ (expected %@)", #VAL,$object(_val),$object(_expected)); \
4.19 }while(0)
4.20 -#define CAssertEq(VAL,EXPECTED) do{ typeof(VAL) _val = VAL; typeof(EXPECTED) _expected = EXPECTED;\
4.21 +#define CAssertEq(VAL,EXPECTED) do{ __typeof(VAL) _val = VAL; __typeof(EXPECTED) _expected = EXPECTED;\
4.22 CAssert(_val==_expected, @"Unexpected value for %s: %@ (expected %@)", #VAL,$object(_val),$object(_expected)); \
4.23 }while(0)
4.24