Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -27,10 +27,11 @@ OFObjectTests.m \ OFPropertyListTests.m \ OFSetTests.m \ OFStreamTests.m \ OFStringTests.m \ + OFSystemInfoTests.m \ OFURLTests.m \ OFValueTests.m \ OFXMLElementBuilderTests.m \ OFXMLNodeTests.m \ OFXMLParserTests.m \ Index: tests/OFLocalizationTests.m ================================================================== --- tests/OFLocalizationTests.m +++ tests/OFLocalizationTests.m @@ -19,37 +19,25 @@ #import "OFLocalization.h" #import "OFAutoreleasePool.h" #import "TestsAppDelegate.h" + +static OFString *module = @"OFLocalization"; @implementation TestsAppDelegate (OFLocalizationTests) - (void)localizationTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFString *msg; - - msg = [OFString stringWithFormat: - @"[OFLocalization] Language: %@\n", [OFLocalization language]]; - [self outputString: msg - inColor: GREEN]; - - msg = [OFString stringWithFormat: - @"[OFLocalization] Territory: %@\n", [OFLocalization territory]]; - [self outputString: msg - inColor: GREEN]; - - msg = [OFString stringWithFormat: - @"[OFLocalization] Encoding: %@\n", - of_string_name_of_encoding([OFLocalization encoding])]; - [self outputString: msg - inColor: GREEN]; - - msg = [OFString stringWithFormat: - @"[OFLocalization] Decimal point: %@\n", - [OFLocalization decimalPoint]]; - [self outputString: msg - inColor: GREEN]; + + PRINT(GREEN, @"Language: %@", [OFLocalization language]); + + PRINT(GREEN, @"Territory: %@", [OFLocalization territory]); + + PRINT(GREEN, @"Encoding: %@", + of_string_name_of_encoding([OFLocalization encoding])); + + PRINT(GREEN, @"Decimal point: %@", [OFLocalization decimalPoint]); [pool drain]; } @end ADDED tests/OFSystemInfoTests.m Index: tests/OFSystemInfoTests.m ================================================================== --- tests/OFSystemInfoTests.m +++ tests/OFSystemInfoTests.m @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, + * 2018 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#import "OFSystemInfo.h" +#import "OFAutoreleasePool.h" + +#import "TestsAppDelegate.h" + +static OFString *module = @"OFSystemInfo"; + +@implementation TestsAppDelegate (OFSystemInfoTests) +- (void)systemInfoTests +{ + OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + + PRINT(GREEN, @"Page size: %zd", [OFSystemInfo pageSize]); + + PRINT(GREEN, @"Number of CPUs: %zd", [OFSystemInfo numberOfCPUs]); + + PRINT(GREEN, @"Operating system name: %@", + [OFSystemInfo operatingSystemName]); + + PRINT(GREEN, @"Operating system version: %@", + [OFSystemInfo operatingSystemVersion]); + +#ifdef OF_HAVE_FILES + PRINT(GREEN, @"User data path: %@", [OFSystemInfo userDataPath]); + + PRINT(GREEN, @"User config path: %@", [OFSystemInfo userDataPath]); +#endif + + PRINT(GREEN, @"CPU vendor: %@", [OFSystemInfo CPUVendor]); + +#if defined(OF_X86_64) || defined(OF_X86) + PRINT(GREEN, @"Supports MMX: %d", [OFSystemInfo supportsMMX]); + + PRINT(GREEN, @"Supports SSE: %d", [OFSystemInfo supportsSSE]); + + PRINT(GREEN, @"Supports SSE2: %d", [OFSystemInfo supportsSSE2]); + + PRINT(GREEN, @"Supports SSE3: %d", [OFSystemInfo supportsSSE3]); + + PRINT(GREEN, @"Supports SSSE3: %d", [OFSystemInfo supportsSSSE3]); + + PRINT(GREEN, @"Supports SSE4.1: %d", [OFSystemInfo supportsSSE41]); + + PRINT(GREEN, @"Supports SSE4.2: %d", [OFSystemInfo supportsSSE42]); + + PRINT(GREEN, @"Supports AVX: %d", [OFSystemInfo supportsAVX]); + + PRINT(GREEN, @"Supports AVX2: %d", [OFSystemInfo supportsAVX2]); +#endif + +#ifdef OF_POWERPC + PRINT(GREEN, @"Supports AltiVec: %d", [OFSystemInfo supportsAltiVec]); +#endif + + [pool drain]; +} +@end Index: tests/TestsAppDelegate.h ================================================================== --- tests/TestsAppDelegate.h +++ tests/TestsAppDelegate.h @@ -53,10 +53,17 @@ inModule: module]; \ _fails++; \ } \ } #define R(...) (__VA_ARGS__, 1) +#define PRINT(color, fmt, ...) \ + { \ + OFString *msg = [OFString stringWithFormat: \ + @"[%@] " fmt @"\n", module, __VA_ARGS__]; \ + [self outputString: msg \ + inColor: color]; \ + } @class OFString; enum { NO_COLOR, @@ -205,10 +212,14 @@ @end @interface TestsAppDelegate (OFSHA512HashTests) - (void)SHA512HashTests; @end + +@interface TestsAppDelegate (OFSystemInfoTests) +- (void)systemInfoTests; +@end @interface TestsAppDelegate (OFHMACTests) - (void)HMACTests; @end Index: tests/TestsAppDelegate.m ================================================================== --- tests/TestsAppDelegate.m +++ tests/TestsAppDelegate.m @@ -433,10 +433,11 @@ [self propertyListTests]; #if defined(OF_HAVE_PLUGINS) [self pluginTests]; #endif + [self systemInfoTests]; [self localizationTests]; #if defined(OF_IOS) [self outputString: [OFString stringWithFormat: @"%d tests failed!", _fails]