Skip to content

Commit 8de86be

Browse files
committed
Fix for off-by-one bug.
With a bunch of unit tests
1 parent 61621d4 commit 8de86be

File tree

7 files changed

+319
-42
lines changed

7 files changed

+319
-42
lines changed

Example/BSGridCollectionViewLayout.xcodeproj/project.pbxproj

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
553DE6751CABBFCD006C4C9F /* LastRowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 553DE6741CABBFCD006C4C9F /* LastRowTests.swift */; };
11+
553DE6771CABC7FA006C4C9F /* FirstIndexTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 553DE6761CABC7FA006C4C9F /* FirstIndexTests.swift */; };
12+
553DE6791CABCC14006C4C9F /* LastIndexTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 553DE6781CABCC14006C4C9F /* LastIndexTests.swift */; };
1013
59708DABA4977941E5622E9F /* Pods_BSGridCollectionViewLayout_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A8CB884C5A9A71517E747B0 /* Pods_BSGridCollectionViewLayout_Tests.framework */; };
1114
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; };
1215
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; };
1316
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; };
1417
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
1518
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
16-
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; };
19+
607FACEC1AFB9204008FA782 /* FirstRowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* FirstRowTests.swift */; };
1720
EB69147FBBE49F808C3FB6F2 /* Pods_BSGridCollectionViewLayout_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AF8FCAAFF35FF4BB989081B /* Pods_BSGridCollectionViewLayout_Example.framework */; };
1821
/* End PBXBuildFile section */
1922

@@ -31,6 +34,9 @@
3134
0A8CB884C5A9A71517E747B0 /* Pods_BSGridCollectionViewLayout_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_BSGridCollectionViewLayout_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3235
1271D170BACE76AAF61B953E /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
3336
4DD8060D12E59B1B67378F47 /* Pods-BSGridCollectionViewLayout_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BSGridCollectionViewLayout_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-BSGridCollectionViewLayout_Tests/Pods-BSGridCollectionViewLayout_Tests.release.xcconfig"; sourceTree = "<group>"; };
37+
553DE6741CABBFCD006C4C9F /* LastRowTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LastRowTests.swift; sourceTree = "<group>"; };
38+
553DE6761CABC7FA006C4C9F /* FirstIndexTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirstIndexTests.swift; sourceTree = "<group>"; };
39+
553DE6781CABCC14006C4C9F /* LastIndexTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LastIndexTests.swift; sourceTree = "<group>"; };
3440
607FACD01AFB9204008FA782 /* BSGridCollectionViewLayout_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BSGridCollectionViewLayout_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
3541
607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3642
607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -40,7 +46,7 @@
4046
607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
4147
607FACE51AFB9204008FA782 /* BSGridCollectionViewLayout_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BSGridCollectionViewLayout_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
4248
607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
43-
607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = "<group>"; };
49+
607FACEB1AFB9204008FA782 /* FirstRowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirstRowTests.swift; sourceTree = "<group>"; };
4450
62621CB8A78F5398E3B938B5 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
4551
9AF8FCAAFF35FF4BB989081B /* Pods_BSGridCollectionViewLayout_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_BSGridCollectionViewLayout_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4652
B87BF5ECE1FED6612E07787A /* BSGridCollectionViewLayout.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = BSGridCollectionViewLayout.podspec; path = ../BSGridCollectionViewLayout.podspec; sourceTree = "<group>"; };
@@ -124,7 +130,10 @@
124130
607FACE81AFB9204008FA782 /* Tests */ = {
125131
isa = PBXGroup;
126132
children = (
127-
607FACEB1AFB9204008FA782 /* Tests.swift */,
133+
607FACEB1AFB9204008FA782 /* FirstRowTests.swift */,
134+
553DE6741CABBFCD006C4C9F /* LastRowTests.swift */,
135+
553DE6761CABC7FA006C4C9F /* FirstIndexTests.swift */,
136+
553DE6781CABCC14006C4C9F /* LastIndexTests.swift */,
128137
607FACE91AFB9204008FA782 /* Supporting Files */,
129138
);
130139
path = Tests;
@@ -218,7 +227,6 @@
218227
};
219228
607FACE41AFB9204008FA782 = {
220229
CreatedOnToolsVersion = 6.3.1;
221-
TestTargetID = 607FACCF1AFB9204008FA782;
222230
};
223231
};
224232
};
@@ -368,7 +376,10 @@
368376
isa = PBXSourcesBuildPhase;
369377
buildActionMask = 2147483647;
370378
files = (
371-
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */,
379+
553DE6751CABBFCD006C4C9F /* LastRowTests.swift in Sources */,
380+
607FACEC1AFB9204008FA782 /* FirstRowTests.swift in Sources */,
381+
553DE6791CABCC14006C4C9F /* LastIndexTests.swift in Sources */,
382+
553DE6771CABC7FA006C4C9F /* FirstIndexTests.swift in Sources */,
372383
);
373384
runOnlyForDeploymentPostprocessing = 0;
374385
};
@@ -516,7 +527,6 @@
516527
isa = XCBuildConfiguration;
517528
baseConfigurationReference = F04D8B05088B4DF749D43009 /* Pods-BSGridCollectionViewLayout_Tests.debug.xcconfig */;
518529
buildSettings = {
519-
BUNDLE_LOADER = "$(TEST_HOST)";
520530
GCC_PREPROCESSOR_DEFINITIONS = (
521531
"DEBUG=1",
522532
"$(inherited)",
@@ -525,20 +535,17 @@
525535
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
526536
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
527537
PRODUCT_NAME = "$(TARGET_NAME)";
528-
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/BSGridCollectionViewLayout_Example.app/BSGridCollectionViewLayout_Example";
529538
};
530539
name = Debug;
531540
};
532541
607FACF41AFB9204008FA782 /* Release */ = {
533542
isa = XCBuildConfiguration;
534543
baseConfigurationReference = 4DD8060D12E59B1B67378F47 /* Pods-BSGridCollectionViewLayout_Tests.release.xcconfig */;
535544
buildSettings = {
536-
BUNDLE_LOADER = "$(TEST_HOST)";
537545
INFOPLIST_FILE = Tests/Info.plist;
538546
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
539547
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
540548
PRODUCT_NAME = "$(TARGET_NAME)";
541-
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/BSGridCollectionViewLayout_Example.app/BSGridCollectionViewLayout_Example";
542549
};
543550
name = Release;
544551
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// The MIT License (MIT)
2+
//
3+
// Copyright (c) 2016 Joakim Gyllström
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in all
13+
// copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
// SOFTWARE.
22+
23+
import XCTest
24+
@testable import BSGridCollectionViewLayout
25+
26+
class FirstIndexTests: XCTestCase {
27+
func testFirstIndexFirstRow() {
28+
let index = GridCollectionViewLayout.firstIndexInRow(0, withItemsPerRow: 3)
29+
XCTAssertEqual(index, 0)
30+
}
31+
32+
func testFirstIndexThirdRow() {
33+
let index = GridCollectionViewLayout.firstIndexInRow(3, withItemsPerRow: 3)
34+
XCTAssertEqual(index, 9)
35+
}
36+
}

Example/Tests/FirstRowTests.swift

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// The MIT License (MIT)
2+
//
3+
// Copyright (c) 2016 Joakim Gyllström
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in all
13+
// copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
// SOFTWARE.
22+
23+
import UIKit
24+
import XCTest
25+
@testable import BSGridCollectionViewLayout
26+
27+
class FirstRowTests: XCTestCase {
28+
29+
func testFirstRowInZeroRect() {
30+
let firstRow = GridCollectionViewLayout.firstRowInRect(CGRectZero, withRowHeight: 100.0)
31+
XCTAssertEqual(firstRow, 0)
32+
}
33+
34+
func testFirstRowWithoutOffset() {
35+
let firstRow = GridCollectionViewLayout.firstRowInRect(CGRect(x: 0, y: 0, width: 100, height: 300), withRowHeight: 100.0)
36+
XCTAssertEqual(firstRow, 0)
37+
}
38+
39+
func testFirstRowWith1RowOffset() {
40+
let firstRow = GridCollectionViewLayout.firstRowInRect(CGRect(x: 0, y: 100, width: 100, height: 300), withRowHeight: 100.0)
41+
XCTAssertEqual(firstRow, 1)
42+
}
43+
44+
func testFirstRowWithHalfRowOffset() {
45+
let firstRow = GridCollectionViewLayout.firstRowInRect(CGRect(x: 0, y: 50, width: 100, height: 300), withRowHeight: 100.0)
46+
XCTAssertEqual(firstRow, 0)
47+
}
48+
49+
func testFirstRowWith2RowOffset() {
50+
let firstRow = GridCollectionViewLayout.firstRowInRect(CGRect(x: 0, y: 200, width: 100, height: 300), withRowHeight: 100.0)
51+
XCTAssertEqual(firstRow, 2)
52+
}
53+
54+
func testFirstRowWithNegativeRectOffset() {
55+
let firstRow = GridCollectionViewLayout.firstRowInRect(CGRect(x: 0, y: -200, width: 100, height: 300), withRowHeight: 100.0)
56+
XCTAssertEqual(firstRow, 0)
57+
}
58+
}

Example/Tests/LastIndexTests.swift

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// The MIT License (MIT)
2+
//
3+
// Copyright (c) 2016 Joakim Gyllström
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in all
13+
// copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
// SOFTWARE.
22+
23+
import XCTest
24+
@testable import BSGridCollectionViewLayout
25+
26+
class LastIndexTests: XCTestCase {
27+
func testLastIndexFirstRowLowNumberOfItems() {
28+
let index = GridCollectionViewLayout.lastIndexInRow(0, withItemsPerRow: 3, numberOfItems: 2)
29+
XCTAssertEqual(index, 1)
30+
}
31+
32+
func testLastIndexFirstRowMediumNumberOfItems() {
33+
let index = GridCollectionViewLayout.lastIndexInRow(0, withItemsPerRow: 3, numberOfItems: 6)
34+
XCTAssertEqual(index, 2)
35+
}
36+
37+
func testLastIndexFirstRowLargeNumberOfItems() {
38+
let index = GridCollectionViewLayout.lastIndexInRow(0, withItemsPerRow: 3, numberOfItems: 500)
39+
XCTAssertEqual(index, 2)
40+
}
41+
42+
func testLastIndexThirdRowLowNumberOfItems() {
43+
let index = GridCollectionViewLayout.lastIndexInRow(2, withItemsPerRow: 3, numberOfItems: 7)
44+
XCTAssertEqual(index, 6)
45+
}
46+
47+
func testLastIndexThirdRowMediumNumberOfItems() {
48+
let index = GridCollectionViewLayout.lastIndexInRow(2, withItemsPerRow: 3, numberOfItems: 8)
49+
XCTAssertEqual(index, 7)
50+
}
51+
52+
func testLastIndexThirdRowLargeNumberOfItems() {
53+
let index = GridCollectionViewLayout.lastIndexInRow(2, withItemsPerRow: 3, numberOfItems: 500)
54+
XCTAssertEqual(index, 8)
55+
}
56+
}

Example/Tests/LastRowTests.swift

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// The MIT License (MIT)
2+
//
3+
// Copyright (c) 2016 Joakim Gyllström
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in all
13+
// copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
// SOFTWARE.
22+
23+
import XCTest
24+
@testable import BSGridCollectionViewLayout
25+
26+
class LastRowTests: XCTestCase {
27+
28+
func testLastRowInZeroRect() {
29+
let lastRow = GridCollectionViewLayout.lastRowInRect(CGRectZero, withRowHeight: 100, max: 3)
30+
XCTAssertEqual(lastRow, 0)
31+
}
32+
33+
func testLastRowWithoutOffsetSmallMax() {
34+
let max = 2
35+
let lastRow = GridCollectionViewLayout.lastRowInRect(CGRect(x: 0, y: 0, width: 100, height: 300), withRowHeight: 100, max: max)
36+
XCTAssertEqual(lastRow, 1)
37+
}
38+
39+
func testLastRowWithoutOffsetMediumMax() {
40+
let max = 3
41+
let lastRow = GridCollectionViewLayout.lastRowInRect(CGRect(x: 0, y: 0, width: 100, height: 300), withRowHeight: 100, max: max)
42+
XCTAssertEqual(lastRow, 2)
43+
}
44+
45+
func testLastRowWithoutOffsetLargeMax() {
46+
let max = 8
47+
let lastRow = GridCollectionViewLayout.lastRowInRect(CGRect(x: 0, y: 0, width: 100, height: 300), withRowHeight: 100, max: max)
48+
XCTAssertEqual(lastRow, 2)
49+
}
50+
51+
func testLastRowWith1RowOffsetSmallMax() {
52+
let max = 2
53+
let lastRow = GridCollectionViewLayout.lastRowInRect(CGRect(x: 0, y: 100, width: 100, height: 300), withRowHeight: 100, max: max)
54+
XCTAssertEqual(lastRow, 1)
55+
}
56+
57+
func testLastRowWith1RowOffsetMediumMax() {
58+
let max = 3
59+
let lastRow = GridCollectionViewLayout.lastRowInRect(CGRect(x: 0, y: 100, width: 100, height: 300), withRowHeight: 100, max: max)
60+
XCTAssertEqual(lastRow, 2)
61+
}
62+
63+
func testLastRowWith1RowOffsetLargeMax() {
64+
let max = 8
65+
let lastRow = GridCollectionViewLayout.lastRowInRect(CGRect(x: 0, y: 100, width: 100, height: 300), withRowHeight: 100, max: max)
66+
XCTAssertEqual(lastRow, 3)
67+
}
68+
69+
func testLastRowWithHalfRowOffsetSmallMax() {
70+
let max = 2
71+
let lastRow = GridCollectionViewLayout.lastRowInRect(CGRect(x: 0, y: 50, width: 100, height: 300), withRowHeight: 100, max: max)
72+
XCTAssertEqual(lastRow, 1)
73+
}
74+
75+
func testLastRowWithHalfRowOffsetMediumMax() {
76+
let max = 3
77+
let lastRow = GridCollectionViewLayout.lastRowInRect(CGRect(x: 0, y: 50, width: 100, height: 300), withRowHeight: 100, max: max)
78+
XCTAssertEqual(lastRow, 2)
79+
}
80+
81+
func testLastRowWithHalfRowOffsetLargeMax() {
82+
let max = 8
83+
let lastRow = GridCollectionViewLayout.lastRowInRect(CGRect(x: 0, y: 50, width: 100, height: 300), withRowHeight: 100, max: max)
84+
XCTAssertEqual(lastRow, 3)
85+
}
86+
}

Example/Tests/Tests.swift

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)