aboutsummaryrefslogtreecommitdiff
path: root/objectivec/Tests
diff options
context:
space:
mode:
authorThomas Van Lenten <thomasvl@google.com>2018-01-31 11:59:57 -0500
committerThomas Van Lenten <thomasvl@google.com>2018-01-31 12:36:54 -0500
commit953adb16ff2f982d54dd812b51df5fdb392732f8 (patch)
treef6a855939173eaf8a5a4d6bfc84a87fff8255a0e /objectivec/Tests
parentb718551571983f281d065e818da4fd9ca5723d89 (diff)
downloadprotobuf-953adb16ff2f982d54dd812b51df5fdb392732f8.tar.gz
protobuf-953adb16ff2f982d54dd812b51df5fdb392732f8.tar.bz2
protobuf-953adb16ff2f982d54dd812b51df5fdb392732f8.zip
Add casts to removed undefined behaviors around shifts.
Fixes #4246 Fixes #4247
Diffstat (limited to 'objectivec/Tests')
-rw-r--r--objectivec/Tests/GPBCodedInputStreamTests.m2
-rw-r--r--objectivec/Tests/GPBCodedOuputStreamTests.m2
-rw-r--r--objectivec/Tests/GPBUtilitiesTests.m8
3 files changed, 6 insertions, 6 deletions
diff --git a/objectivec/Tests/GPBCodedInputStreamTests.m b/objectivec/Tests/GPBCodedInputStreamTests.m
index 11f7ceaf..f5aa6903 100644
--- a/objectivec/Tests/GPBCodedInputStreamTests.m
+++ b/objectivec/Tests/GPBCodedInputStreamTests.m
@@ -220,7 +220,7 @@
0xa6, 0x01)
value:(0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) |
(0x3bLL << 28) | (0x56LL << 35) | (0x00LL << 42) |
- (0x05LL << 49) | (0x26LL << 56) | (0x01LL << 63)];
+ (0x05LL << 49) | (0x26LL << 56) | (0x01ULL << 63)];
// Failures
[self assertReadVarintFailure:bytes(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
diff --git a/objectivec/Tests/GPBCodedOuputStreamTests.m b/objectivec/Tests/GPBCodedOuputStreamTests.m
index 2ad326be..878e7aa9 100644
--- a/objectivec/Tests/GPBCodedOuputStreamTests.m
+++ b/objectivec/Tests/GPBCodedOuputStreamTests.m
@@ -266,7 +266,7 @@
value:(0x1b << 0) | (0x28 << 7) | (0x79 << 14) |
(0x42 << 21) | (0x3bLL << 28) | (0x56LL << 35) |
(0x00LL << 42) | (0x05LL << 49) | (0x26LL << 56) |
- (0x01LL << 63)];
+ (0x01ULL << 63)];
}
- (void)testWriteLittleEndian {
diff --git a/objectivec/Tests/GPBUtilitiesTests.m b/objectivec/Tests/GPBUtilitiesTests.m
index 2e206a54..8a8ba93e 100644
--- a/objectivec/Tests/GPBUtilitiesTests.m
+++ b/objectivec/Tests/GPBUtilitiesTests.m
@@ -52,12 +52,12 @@
- (void)testRightShiftFunctions {
XCTAssertEqual((1UL << 31) >> 31, 1UL);
- XCTAssertEqual((1 << 31) >> 31, -1);
+ XCTAssertEqual((int32_t)(1U << 31) >> 31, -1);
XCTAssertEqual((1ULL << 63) >> 63, 1ULL);
- XCTAssertEqual((1LL << 63) >> 63, -1LL);
+ XCTAssertEqual((int64_t)(1ULL << 63) >> 63, -1LL);
- XCTAssertEqual(GPBLogicalRightShift32((1 << 31), 31), 1);
- XCTAssertEqual(GPBLogicalRightShift64((1LL << 63), 63), 1LL);
+ XCTAssertEqual(GPBLogicalRightShift32((1U << 31), 31), 1);
+ XCTAssertEqual(GPBLogicalRightShift64((1ULL << 63), 63), 1LL);
}
- (void)testGPBDecodeTextFormatName {