Skip to content

Commit 4c3587f

Browse files
committed
Fixed NSLog() formatting and unit test problems.
1 parent d6e5748 commit 4c3587f

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

components/Buttons/ButtonsTests/ButtonsTests.m

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ - (void)testUppercaseTitleNo {
6060
XCTAssertEqualObjects(button.currentTitle, originalTitle);
6161
}
6262

63-
- (void)testUppercaseTitleNOChangedToYes {
63+
- (void)testUppercaseTitleNoChangedToYes {
6464
// Given
6565
MDCButton *button = [[MDCButton alloc] init];
6666
NSString *originalTitle = @"some Text";
@@ -74,7 +74,7 @@ - (void)testUppercaseTitleNOChangedToYes {
7474
XCTAssertEqualObjects(button.currentTitle, [originalTitle uppercaseStringWithLocale:[NSLocale currentLocale]]);
7575
}
7676

77-
- (void)testSetEnabledAnimatedNO {
77+
- (void)testSetEnabledAnimatedNo {
7878
// Given
7979
MDCButton *button = [[MDCButton alloc] init];
8080

@@ -123,9 +123,11 @@ - (void)testResetElevationForState {
123123

124124
// Then
125125
if (controlState & UIControlStateSelected) {
126-
XCTAssertNotEqualWithAccuracy([button elevationForState:controlState], MDCShadowElevationNone, kEpsilonAccuracy);
126+
XCTAssertNotEqualWithAccuracy([button elevationForState:controlState], MDCShadowElevationNone,
127+
kEpsilonAccuracy);
127128
} else {
128-
XCTAssertEqualWithAccuracy([button elevationForState:controlState], MDCShadowElevationNone, kEpsilonAccuracy);
129+
XCTAssertEqualWithAccuracy([button elevationForState:controlState], MDCShadowElevationNone,
130+
kEpsilonAccuracy);
129131
}
130132
}
131133
}
@@ -155,7 +157,7 @@ - (void)testCurrentBackgroundColor {
155157
button.highlighted = (controlState & UIControlStateHighlighted) == UIControlStateHighlighted;
156158
button.selected = (controlState & UIControlStateSelected) == UIControlStateSelected;
157159
button.enabled = (controlState & UIControlStateDisabled) != UIControlStateDisabled;
158-
NSLog(@"controlstate:%i", button.state);
160+
NSLog(@"controlstate:%lu", (unsigned long)button.state);
159161

160162
// Then
161163
XCTAssertEqual(button.state, controlState);
@@ -225,7 +227,8 @@ - (UIControlState)randomControlState {
225227
return UIControlStateSelected; // Test selected the second most.
226228
}
227229
// Everything else including overlapping states.
228-
return arc4random_uniform(UIControlStateDisabled | UIControlStateHighlighted | UIControlStateSelected + 1);
230+
return arc4random_uniform(UIControlStateDisabled | UIControlStateHighlighted |
231+
UIControlStateSelected + 1);
229232
// UIButton *button = [[UIButton alloc] init];
230233
// button.enabled = arc4random_uniform(2);
231234
// button.highlighted = arc4random_uniform(2);
@@ -371,7 +374,8 @@ - (void)testButtonState {
371374
button.enabled = (controlState & UIControlStateDisabled) != UIControlStateDisabled;
372375

373376
// Then
374-
NSLog(@"controlstate:%i==%i highlight:%i enabled:%i selected:%i", controlState, button.state, button.highlighted, button.enabled, button.selected);
377+
NSLog(@"controlstate:%lu==%lu highlight:%i enabled:%i selected:%i", (unsigned long)controlState,
378+
(unsigned long)button.state, button.highlighted, button.enabled, button.selected);
375379
XCTAssertEqual(button.state, controlState);
376380
}
377381
}

components/Buttons/src/MDCButton.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ - (void)setUppercaseTitle:(BOOL)uppercaseTitle {
309309
// This ensures existing titles will get upper cased
310310
UIControlState allControlStates =
311311
(UIControlStateHighlighted | UIControlStateDisabled | UIControlStateSelected);
312-
for (UIControlState state; state < allControlStates; ++state) {
312+
for (UIControlState state = 0; state < allControlStates; ++state) {
313313
NSString *title = [self titleForState:state];
314314
if (title) {
315315
[self setTitle:title forState:state];

0 commit comments

Comments
 (0)