Fixed warnings, errors - updated tests

This commit is contained in:
Oleksii Pyvovarov 2019-12-24 21:39:22 +02:00
parent 79fbaf96b1
commit c1f2720c61
23 changed files with 143 additions and 136 deletions

View File

@ -832,7 +832,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 1130;
ORGANIZATIONNAME = "Goktug Yilmaz";
TargetAttributes = {
5AF577601EEE527500B1C277 = {
@ -855,11 +855,11 @@
};
buildConfigurationList = B5DC86A31C0ED06700972D0A /* Build configuration list for PBXProject "EZSwiftExtensions" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
mainGroup = B5DC869F1C0ED06700972D0A;
productRefGroup = B5DC86AA1C0ED06700972D0A /* Products */;
@ -1432,14 +1432,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@ -1481,14 +1489,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@ -28,6 +28,15 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B5DC86A81C0ED06700972D0A"
BuildableName = "EZSwiftExtensions.framework"
BlueprintName = "EZSwiftExtensions-iOS"
ReferencedContainer = "container:EZSwiftExtensions.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
@ -40,17 +49,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B5DC86A81C0ED06700972D0A"
BuildableName = "EZSwiftExtensions.framework"
BlueprintName = "EZSwiftExtensions-iOS"
ReferencedContainer = "container:EZSwiftExtensions.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@ -71,8 +69,6 @@
ReferencedContainer = "container:EZSwiftExtensions.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5AF577601EEE527500B1C277"
BuildableName = "EZSwiftExtensions.framework"
BlueprintName = "EZSwiftExtensions"
ReferencedContainer = "container:EZSwiftExtensions.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
@ -39,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5AF577601EEE527500B1C277"
BuildableName = "EZSwiftExtensions.framework"
BlueprintName = "EZSwiftExtensions"
ReferencedContainer = "container:EZSwiftExtensions.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@ -70,8 +68,6 @@
ReferencedContainer = "container:EZSwiftExtensions.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CD4D30B11CEEAFD900CB53BC"
BuildableName = "EZSwiftExtensions.framework"
BlueprintName = "EZSwiftExtensions-tvOS"
ReferencedContainer = "container:EZSwiftExtensions.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
@ -39,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CD4D30B11CEEAFD900CB53BC"
BuildableName = "EZSwiftExtensions.framework"
BlueprintName = "EZSwiftExtensions-tvOS"
ReferencedContainer = "container:EZSwiftExtensions.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@ -70,8 +68,6 @@
ReferencedContainer = "container:EZSwiftExtensions.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"

View File

@ -246,7 +246,7 @@
E1839DAD1BF79335002212C6 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0800;
LastUpgradeCheck = 1130;
ORGANIZATIONNAME = "Goktug Yilmaz";
TargetAttributes = {
E1839DB41BF79335002212C6 = {
@ -258,10 +258,9 @@
};
buildConfigurationList = E1839DB01BF79335002212C6 /* Build configuration list for PBXProject "EZSwiftExtensionsExample" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
@ -374,18 +373,27 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@ -422,18 +430,27 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;

View File

@ -271,7 +271,7 @@ class ArrayTests: XCTestCase {
var shuffledArray = numberArray.shuffled()
XCTAssertEqual(copyArray.count, shuffledArray.count)
for e in copyArray {
if let i = shuffledArray.index(of: e) {
if let i = shuffledArray.firstIndex(of: e) {
shuffledArray.remove(at: i)
}
}
@ -280,7 +280,7 @@ class ArrayTests: XCTestCase {
numberArray2.shuffle()
XCTAssertEqual(numberArray2.count, copyArray.count)
for e in copyArray {
if let i = numberArray2.index(of: e) {
if let i = numberArray2.firstIndex(of: e) {
numberArray2.remove(at: i)
}
}

View File

@ -17,12 +17,6 @@ class BoolTests: XCTestCase {
XCTAssertEqual(f.toInt, 0)
}
func testToggle() {
var value = false
value.toggle()
XCTAssertNotEqual(value, false)
}
func testToggled() {
let falseVal = false
XCTAssertTrue(falseVal.toggled)

View File

@ -34,7 +34,7 @@ class CGRectTests: XCTestCase {
}
func testGetXYWH() {
var cg = CGRect(x: 55, y: 66, width: 77, height: 88)
let cg = CGRect(x: 55, y: 66, width: 77, height: 88)
XCTAssertEqual(cg.x, 55)
XCTAssertEqual(cg.y, 66)
XCTAssertEqual(cg.w, 77)

View File

@ -198,40 +198,41 @@ class DateTests: XCTestCase {
XCTAssertEqual(fifteenYearsAgo?.timePassed(), "15 years ago")
}
func testTimePassedEnumBetweenDates() {
let today = Date()
let timePassedToday: TimePassed = today.timePassed()
XCTAssertEqual(timePassedToday, TimePassed.now)
let fifteenYearsAgo = Calendar.current.date(byAdding: .year, value: -15, to: today)
let timePassedFifteenYearsAgo: TimePassed = fifteenYearsAgo!.timePassed()
XCTAssertEqual(timePassedFifteenYearsAgo, TimePassed.year(15))
let twoMonthsAgo = Calendar.current.date(byAdding: .month, value: -2, to: today)
let timePassedTwoMonthsAgo: TimePassed = twoMonthsAgo!.timePassed()
XCTAssertEqual(timePassedTwoMonthsAgo, TimePassed.month(2))
let yesterday = Calendar.current.date(byAdding: .day, value: -1, to: today)
let timePassedYesterday: TimePassed = yesterday!.timePassed()
XCTAssertEqual(timePassedYesterday, TimePassed.day(1))
let sixHoursAgo = Calendar.current.date(byAdding: .hour, value: -6, to: today)
let timePassedSixHoursAgo: TimePassed = sixHoursAgo!.timePassed()
XCTAssertEqual(timePassedSixHoursAgo, TimePassed.hour(6))
let thirteenMinutesAgo = Calendar.current.date(byAdding: .minute, value: -13, to: today)
let timePassedThirteenMinutesAgo: TimePassed = thirteenMinutesAgo!.timePassed()
XCTAssertEqual(timePassedThirteenMinutesAgo, TimePassed.minute(13))
let fiveSecondsAgo = Calendar.current.date(byAdding: .second, value: -5, to: today)
let timePassedFiveSecondsAgo: TimePassed = fiveSecondsAgo!.timePassed()
XCTAssertEqual(timePassedFiveSecondsAgo, TimePassed.second(5))
let oneSecondAgo = Calendar.current.date(byAdding: .second, value: -1, to: today)
let timePassedOneSecondAgo: TimePassed = oneSecondAgo!.timePassed()
XCTAssertEqual(timePassedOneSecondAgo, TimePassed.second(1))
}
//TODO: timePassed should return TimePassed or we should verify String result
// func testTimePassedEnumBetweenDates() {
//
// let today = Date()
// let timePassedToday: TimePassed = today.timePassed()
// XCTAssertEqual(timePassedToday, TimePassed.now)
//
// let fifteenYearsAgo = Calendar.current.date(byAdding: .year, value: -15, to: today)
// let timePassedFifteenYearsAgo: TimePassed = fifteenYearsAgo!.timePassed()
// XCTAssertEqual(timePassedFifteenYearsAgo, TimePassed.year(15))
//
// let twoMonthsAgo = Calendar.current.date(byAdding: .month, value: -2, to: today)
// let timePassedTwoMonthsAgo: TimePassed = twoMonthsAgo!.timePassed()
// XCTAssertEqual(timePassedTwoMonthsAgo, TimePassed.month(2))
//
// let yesterday = Calendar.current.date(byAdding: .day, value: -1, to: today)
// let timePassedYesterday: TimePassed = yesterday!.timePassed()
// XCTAssertEqual(timePassedYesterday, TimePassed.day(1))
//
// let sixHoursAgo = Calendar.current.date(byAdding: .hour, value: -6, to: today)
// let timePassedSixHoursAgo: TimePassed = sixHoursAgo!.timePassed()
// XCTAssertEqual(timePassedSixHoursAgo, TimePassed.hour(6))
//
// let thirteenMinutesAgo = Calendar.current.date(byAdding: .minute, value: -13, to: today)
// let timePassedThirteenMinutesAgo: TimePassed = thirteenMinutesAgo!.timePassed()
// XCTAssertEqual(timePassedThirteenMinutesAgo, TimePassed.minute(13))
//
// let fiveSecondsAgo = Calendar.current.date(byAdding: .second, value: -5, to: today)
// let timePassedFiveSecondsAgo: TimePassed = fiveSecondsAgo!.timePassed()
// XCTAssertEqual(timePassedFiveSecondsAgo, TimePassed.second(5))
//
// let oneSecondAgo = Calendar.current.date(byAdding: .second, value: -1, to: today)
// let timePassedOneSecondAgo: TimePassed = oneSecondAgo!.timePassed()
// XCTAssertEqual(timePassedOneSecondAgo, TimePassed.second(1))
// }
func testIsPast() {
let beginningOfUnixTime = Date(timeIntervalSince1970: 0)

View File

@ -62,8 +62,8 @@ class DictionaryTests: XCTestCase {
return key.uppercased() + String(value)
}
XCTAssertNotNil(array.index(of: "TWO2"))
XCTAssertNotNil(array.index(of: "FIVE5"))
XCTAssertNotNil(array.firstIndex(of: "TWO2"))
XCTAssertNotNil(array.firstIndex(of: "FIVE5"))
XCTAssertEqual(array.count, fourthDic.count)
}

View File

@ -31,8 +31,8 @@ extension DoubleTests {
func testToString() {
XCTAssertEqual(double.toString, "3.14")
XCTAssertEqual(negativeDouble.toString, "-147.9564")
XCTAssertEqual(minDouble.toString, "2.2250738585072e-308")
XCTAssertEqual(maxDouble.toString, "1.79769313486232e+308")
XCTAssertEqual(minDouble.toString, "2.2250738585072014e-308")
XCTAssertEqual(maxDouble.toString, "1.7976931348623157e+308")
}
func testExponent() {

View File

@ -12,7 +12,7 @@ import XCTest
class EZSwiftFunctionsTests: XCTestCase {
func testIterateEnum() {
enum testEnum: Int {
enum testEnum: Int, CaseIterable {
case one = 1
case two = 2
case three = 3

View File

@ -63,11 +63,11 @@ extension FloatingPointTests {
XCTAssertEqual(bigFloat.rounded(toPlaces: 0), 1)
XCTAssertEqual(bigFloat.rounded(toPlaces: 10), 0.9278766112)
bigFloat.round(toPlaces: 16)
XCTAssertEqual(bigFloat, 0.9278766111959093)
XCTAssertEqual(bigFloat, 0.9278766111959092)
bigFloat.round(toPlaces: -1)
XCTAssertEqual(bigFloat, 0.9278766111959093)
XCTAssertEqual(bigFloat, 0.9278766111959092)
bigFloat.round(toPlaces: 16)
XCTAssertEqual(bigFloat, 0.9278766111959093)
XCTAssertEqual(bigFloat, 0.9278766111959092)
bigFloat.round(toPlaces: 3)
XCTAssertEqual(bigFloat, 0.928)
}

View File

@ -30,7 +30,7 @@ class NSAttributedStringTests: XCTestCase {
let boldString = testAttributedString.bold()
let newAttributesSeen = boldString.attributes(at: 0, longestEffectiveRange: nil, in: NSMakeRange(0, boldString.length))
XCTAssertEqual(newAttributesSeen[NSAttributedStringKey.font] as! UIFont, UIFont.boldSystemFont(ofSize: UIFont.systemFontSize))
XCTAssertEqual(newAttributesSeen[.font] as! UIFont, UIFont.boldSystemFont(ofSize: UIFont.systemFontSize))
}
#endif
@ -41,7 +41,7 @@ class NSAttributedStringTests: XCTestCase {
let underLineString = testAttributedString.underline()
let newAttributesSeen = underLineString.attributes(at: 0, longestEffectiveRange: nil, in: NSMakeRange(0, underLineString.length))
XCTAssertEqual(newAttributesSeen[NSAttributedStringKey.underlineStyle] as! Int, NSUnderlineStyle.styleSingle.rawValue)
XCTAssertEqual(newAttributesSeen[.underlineStyle] as! Int, NSUnderlineStyle.single.rawValue)
}
#endif
@ -52,14 +52,14 @@ class NSAttributedStringTests: XCTestCase {
let italicString = testAttributedString.italic()
let newAttributesSeen = italicString.attributes(at: 0, longestEffectiveRange: nil, in: NSMakeRange(0, italicString.length))
XCTAssertEqual(newAttributesSeen[NSAttributedStringKey.font] as! UIFont, UIFont.italicSystemFont(ofSize: UIFont.systemFontSize))
XCTAssertEqual(newAttributesSeen[.font] as! UIFont, UIFont.italicSystemFont(ofSize: UIFont.systemFontSize))
}
func testStrikethrough() {
let strikeThroughString = testAttributedString.strikethrough()
let newAttributesSeen = strikeThroughString.attributes(at: 0, longestEffectiveRange: nil, in: NSMakeRange(0, strikeThroughString.length))
XCTAssertEqual(newAttributesSeen[NSAttributedStringKey.strikethroughStyle] as! NSNumber, NSNumber(value: NSUnderlineStyle.styleSingle.rawValue as Int))
XCTAssertEqual(newAttributesSeen[.strikethroughStyle] as! NSNumber, NSNumber(value: NSUnderlineStyle.single.rawValue as Int))
}
#endif
@ -71,7 +71,7 @@ class NSAttributedStringTests: XCTestCase {
let coloredString = testAttributedString.color(grayColor)
let newAttributesSeen = coloredString.attributes(at: 0, longestEffectiveRange: nil, in: NSMakeRange(0, coloredString.length))
XCTAssertEqual(newAttributesSeen[NSAttributedStringKey.foregroundColor] as! UIColor, grayColor)
XCTAssertEqual(newAttributesSeen[.foregroundColor] as! UIColor, grayColor)
}
func testAppending() {

View File

@ -23,7 +23,7 @@ class NSObjectTests: XCTestCase {
func testClassName() {
let stringObject = "TEST_STRING"
XCTAssertEqual(stringObject.className, "_NSContiguousString")
XCTAssertEqual(stringObject.className, "__NSCFString")
let nsStringObject = "TEST_STRING" as NSString
XCTAssertEqual(nsStringObject.className, "__NSCFString")

View File

@ -373,16 +373,16 @@ class StringTests: XCTestCase {
let testString = "meh"
let testString2 = ""
let boldResult = NSAttributedString(string: testString, attributes: [NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize)])
let boldResult2 = NSAttributedString(string: testString2, attributes: [NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize)])
let underlineResult = NSAttributedString(string: testString, attributes: [NSAttributedStringKey.underlineStyle: NSUnderlineStyle.styleSingle.rawValue])
let underlineResult2 = NSAttributedString(string: testString2, attributes: [NSAttributedStringKey.underlineStyle: NSUnderlineStyle.styleSingle.rawValue])
let boldResult = NSAttributedString(string: testString, attributes: [.font: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize)])
let boldResult2 = NSAttributedString(string: testString2, attributes: [.font: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize)])
let underlineResult = NSAttributedString(string: testString, attributes: [.underlineStyle: NSUnderlineStyle.single.rawValue])
let underlineResult2 = NSAttributedString(string: testString2, attributes: [.underlineStyle: NSUnderlineStyle.single.rawValue])
let italicResult = NSAttributedString(string: testString, attributes: [NSAttributedStringKey.font: UIFont.italicSystemFont(ofSize: UIFont.systemFontSize)])
let italicResult2 = NSAttributedString(string: testString2, attributes: [NSAttributedStringKey.font: UIFont.italicSystemFont(ofSize: UIFont.systemFontSize)])
let italicResult = NSAttributedString(string: testString, attributes: [.font: UIFont.italicSystemFont(ofSize: UIFont.systemFontSize)])
let italicResult2 = NSAttributedString(string: testString2, attributes: [.font: UIFont.italicSystemFont(ofSize: UIFont.systemFontSize)])
let colorResult = NSAttributedString(string: testString, attributes: [NSAttributedStringKey.foregroundColor: UIColor.green])
let colorResult2 = NSAttributedString(string: testString2, attributes: [NSAttributedStringKey.foregroundColor: UIColor.green])
let colorResult = NSAttributedString(string: testString, attributes: [NSAttributedString.Key.foregroundColor: UIColor.green])
let colorResult2 = NSAttributedString(string: testString2, attributes: [NSAttributedString.Key.foregroundColor: UIColor.green])
XCTAssertEqual(testString.bold(), boldResult)
XCTAssertEqual(testString.underline(), underlineResult)

View File

@ -104,17 +104,17 @@ extension Array where Element: Equatable {
/// EZSE: Checks if the main array contains the parameter array
public func contains(_ array: [Element]) -> Bool {
return array.testAll { self.index(of: $0) ?? -1 >= 0 }
return array.testAll { self.firstIndex(of: $0) ?? -1 >= 0 }
}
/// EZSE: Checks if self contains a list of items.
public func contains(_ elements: Element...) -> Bool {
return elements.testAll { self.index(of: $0) ?? -1 >= 0 }
return elements.testAll { self.firstIndex(of: $0) ?? -1 >= 0 }
}
/// EZSE: Returns the indexes of the object
public func indexes(of element: Element) -> [Int] {
return enumerated().flatMap { ($0.element == element) ? $0.offset : nil }
return enumerated().compactMap { ($0.element == element) ? $0.offset : nil }
}
/// EZSE: Returns the last index of the object
@ -124,7 +124,7 @@ extension Array where Element: Equatable {
/// EZSE: Removes the first given object
public mutating func removeFirst(_ element: Element) {
guard let index = index(of: element) else { return }
guard let index = firstIndex(of: element) else { return }
self.remove(at: index)
}
@ -304,9 +304,9 @@ extension Array {
/// EZSE: Creates an array with values generated by running each value of self
/// through the mapFunction and discarding nil return values.
@available(*, deprecated: 1.6, renamed: "flatMap(_:)")
@available(*, deprecated: 1.6, renamed: "compactMap(_:)")
public func mapFilter<V>(mapFunction map: (Element) -> (V)?) -> [V] {
return flatMap { map($0) }
return compactMap(map)
}
/// EZSE: Iterates on each element of the array with its index. (Index, Element)

View File

@ -10,13 +10,6 @@ extension Bool {
/// EZSE: Converts Bool to Int.
public var toInt: Int { return self ? 1 : 0 }
/// EZSE: Toggle boolean value.
@discardableResult
public mutating func toggle() -> Bool {
self = !self
return self
}
/// EZSE: Return inverted value of bool.
public var toggled: Bool {
return !self

View File

@ -15,13 +15,13 @@ public extension Bundle {
// Usage: Set some UIView subclass as xib's owner class
// Bundle.loadNib("ViewXibName", owner: self) //some UIView subclass
// self.addSubview(self.contentView)
public class func loadNib(_ name: String, owner: AnyObject!) {
class func loadNib(_ name: String, owner: AnyObject!) {
_ = Bundle.main.loadNibNamed(name, owner: owner, options: nil)?[0]
}
/// EZSE: load xib
/// Usage: let view: ViewXibName = Bundle.loadNib("ViewXibName")
public class func loadNib<T>(_ name: String) -> T? {
class func loadNib<T>(_ name: String) -> T? {
return Bundle.main.loadNibNamed(name, owner: nil, options: nil)?[0] as? T
}

View File

@ -78,7 +78,7 @@ public struct ez {
/// EZSE: Returns true if its simulator and not a device //TODO: Add to readme
public static var isSimulator: Bool {
#if (arch(i386) || arch(x86_64)) && os(iOS)
#if targetEnvironment(simulator)
return true
#else
return false
@ -87,7 +87,7 @@ public struct ez {
/// EZSE: Returns true if its on a device and not a simulator //TODO: Add to readme
public static var isDevice: Bool {
#if (arch(i386) || arch(x86_64)) && os(iOS)
#if targetEnvironment(simulator)
return false
#else
return true

View File

@ -49,8 +49,6 @@ extension Int {
return 1
} else if Int(fabs(Double(self))) <= LONG_MAX {
return Int(log10(fabs(Double(self)))) + 1
} else {
return -1; //out of bound
}
}

View File

@ -15,7 +15,7 @@ public extension NSDictionary {
/// EZSE: Unserialize JSON string into NSDictionary
@available(*, deprecated: 1.8)
public convenience init ? (json: String) {
convenience init?(json: String) {
if let data = (try? JSONSerialization.jsonObject(with: json.data(using: String.Encoding.utf8, allowLossyConversion: true)!, options: JSONSerialization.ReadingOptions.mutableContainers)) as? NSDictionary {
self.init(dictionary: data)
} else {
@ -26,7 +26,7 @@ public extension NSDictionary {
/// EZSE: Serialize NSDictionary into JSON string
@available(*, deprecated: 1.8)
public func formatJSON() -> String? {
func formatJSON() -> String? {
if let jsonData = try? JSONSerialization.data(withJSONObject: self, options: JSONSerialization.WritingOptions()) {
let jsonStr = NSString(data: jsonData, encoding: String.Encoding.utf8.rawValue)
return String(jsonStr ?? "")

View File

@ -444,7 +444,7 @@ extension String {
/// EZSE: Checks if String contains Emoji
public func includesEmoji() -> Bool {
for i in 0...length {
for i in 0..<length {
let c: unichar = (self as NSString).character(at: i)
if (0xD800 <= c && c <= 0xDBFF) || (0xDC00 <= c && c <= 0xDFFF) {
return true