Skip to content

Commit

Permalink
Update acknowledgements sorting for Swift 3 syntax, add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
vtourraine committed Jun 28, 2016
1 parent 4c687fa commit 155ae8f
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
4 changes: 4 additions & 0 deletions AcknowList.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
1AA3C37F1CAC35190071A7FD /* AcknowList.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA3C3741CAC35190071A7FD /* AcknowList.framework */; };
1AD73B921CAC3B1C0084F8CA /* Pods-acknowledgements.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1AD73B901CAC3B140084F8CA /* Pods-acknowledgements.plist */; };
1AD73BBE1CAC54C60084F8CA /* AcknowList.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 1AD73BBD1CAC54C60084F8CA /* AcknowList.bundle */; };
D7CCBD131D22624B0013F696 /* Pods-acknowledgements-multi.plist in Resources */ = {isa = PBXBuildFile; fileRef = D7CCBD121D22624B0013F696 /* Pods-acknowledgements-multi.plist */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -47,6 +48,7 @@
1AA3C3851CAC35190071A7FD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
1AD73B901CAC3B140084F8CA /* Pods-acknowledgements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "Pods-acknowledgements.plist"; path = "Tests/Pods-acknowledgements.plist"; sourceTree = SOURCE_ROOT; };
1AD73BBD1CAC54C60084F8CA /* AcknowList.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = AcknowList.bundle; path = Resources/AcknowList.bundle; sourceTree = SOURCE_ROOT; };
D7CCBD121D22624B0013F696 /* Pods-acknowledgements-multi.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Pods-acknowledgements-multi.plist"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -118,6 +120,7 @@
isa = PBXGroup;
children = (
1AD73B901CAC3B140084F8CA /* Pods-acknowledgements.plist */,
D7CCBD121D22624B0013F696 /* Pods-acknowledgements-multi.plist */,
1AA3C3851CAC35190071A7FD /* Info.plist */,
);
name = "Supporting Files";
Expand Down Expand Up @@ -240,6 +243,7 @@
buildActionMask = 2147483647;
files = (
1AD73B921CAC3B1C0084F8CA /* Pods-acknowledgements.plist in Resources */,
D7CCBD131D22624B0013F696 /* Pods-acknowledgements-multi.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion Source/AcknowListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public class AcknowListViewController: UITableViewController {
options: [],
range: nil,
locale: Locale.current())
return (result.rawValue == ComparisonResult.orderedAscending.rawValue)
return (result == ComparisonResult.orderedAscending)
})

self.acknowledgements = sortedAcknowledgements
Expand Down
12 changes: 11 additions & 1 deletion Tests/AcknowListViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import XCTest
class AcknowListViewControllerTests: XCTestCase {

func testConfigureTableView() {

let bundle = Bundle(for: AcknowListViewControllerTests.self)
let plistPath = bundle.pathForResource("Pods-acknowledgements", ofType: "plist")

Expand All @@ -26,4 +25,15 @@ class AcknowListViewControllerTests: XCTestCase {
let cell = viewController.tableView(viewController.tableView, cellForRowAt: IndexPath(row: 0, section: 0))
XCTAssertEqual(cell.textLabel?.text, "AcknowList")
}

func testSortsAcknowledgementsByTitle() {
let bundle = Bundle(for: AcknowListViewControllerTests.self)
let plistPath = bundle.pathForResource("Pods-acknowledgements-multi", ofType: "plist")

let viewController = AcknowListViewController(acknowledgementsPlistPath: plistPath)
XCTAssertEqual(viewController.acknowledgements?.count, 3)
XCTAssertEqual(viewController.acknowledgements?[0].title, "A title")
XCTAssertEqual(viewController.acknowledgements?[1].title, "B title")
XCTAssertEqual(viewController.acknowledgements?[2].title, "C title")
}
}
53 changes: 53 additions & 0 deletions Tests/Pods-acknowledgements-multi.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>FooterText</key>
<string>This application makes use of the following third party libraries:</string>
<key>Title</key>
<string>Acknowledgements</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Copyright (c) 2015-2016 Vincent Tourraine (http://www.vtourraine.net) ...</string>
<key>Title</key>
<string>A title</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Copyright (c) 2015-2016 Vincent Tourraine (http://www.vtourraine.net) ...</string>
<key>Title</key>
<string>C title</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Copyright (c) 2015-2016 Vincent Tourraine (http://www.vtourraine.net) ...</string>
<key>Title</key>
<string>B title</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Generated by CocoaPods - https://cocoapods.org</string>
<key>Title</key>
<string></string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
</array>
<key>StringsTable</key>
<string>Acknowledgements</string>
<key>Title</key>
<string>Acknowledgements</string>
</dict>
</plist>

0 comments on commit 155ae8f

Please sign in to comment.