TM-SGNL-iOS/Signal/test/util/MiscTest.swift
TeleMessage developers dde0620daf initial commit
2025-05-03 12:28:28 -07:00

18 lines
526 B
Swift

//
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import XCTest
class MiscTest: XCTestCase {
func test_uintRotation() {
XCTAssertEqual(UInt(0b10), UInt(0b1).rotateLeft(1))
XCTAssertEqual(UInt(0b101000), UInt(0b101).rotateLeft(3))
// Max bit should wrap around.
XCTAssertTrue(UInt.highestBit > 0)
XCTAssertEqual(UInt(0b1), UInt.highestBit.rotateLeft(1))
XCTAssertEqual(UInt(0b11), (UInt.highestBit | UInt(0b1)).rotateLeft(1))
}
}