Javier Cicchelli 9bcdaa697b [Setup] Basic project structure (#1)
This PR contains all the work related to setting up this project as required to implement the [Assignment](https://repo.rock-n-code.com/rock-n-code/deep-linking-assignment/wiki/Assignment) on top, as intended.

To summarise this work:
- [x] created a new **Xcode** project;
- [x] cloned the `Wikipedia` app and inserted it into the **Xcode** project;
- [x] created the `Locations` app and also, its `Libraries` package;
- [x] created the `Shared` package to share dependencies between the apps;
- [x] added a `Makefile` file and implemented some **environment** and **help** commands.

Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Reviewed-on: rock-n-code/deep-linking-assignment#1
2023-04-08 18:37:13 +00:00

38 lines
1.7 KiB
Objective-C

#import <XCTest/XCTest.h>
@import WMF;
@interface CircularBitwiseRotationTests : XCTestCase
@end
@implementation CircularBitwiseRotationTests
- (void)testMatchesCorrespondingPowerOfTwo {
for (NSUInteger rotation; rotation < NSUINT_BIT; rotation++) {
NSUInteger actualResult = flipBitsWithAdditionalRotation(1, rotation);
// add by NSUINT_BIT_2 to model the "flipping," then modulo for rotation
NSUInteger exponent = (rotation + NSUINT_BIT_2) % NSUINT_BIT;
NSUInteger expectedResult = powl(2, exponent);
XCTAssertEqual(actualResult, expectedResult,
@"Rotating 1 by %lu should be equal to 2^%lu (%lu). Got %lu instead",
(unsigned long)rotation, (unsigned long)exponent, (unsigned long)expectedResult, (unsigned long)actualResult);
}
}
- (void)testSymmetrical {
for (NSUInteger i; i < 50; i++) {
NSUInteger testValue = arc4random();
for (NSUInteger rotation; rotation < NSUINT_BIT; rotation++) {
NSUInteger symmetricalRotation = rotation + NSUINT_BIT;
NSUInteger original = flipBitsWithAdditionalRotation(testValue, rotation);
NSUInteger symmetrical = flipBitsWithAdditionalRotation(testValue, symmetricalRotation);
XCTAssertEqual(original, symmetrical,
@"Rotating %lu by %lu should be the same as rotating by %lu + NSUINT_BIT (%lu)."
"Got %lu expected %lu",
(unsigned long)testValue, (unsigned long)rotation, (unsigned long)rotation, (unsigned long)symmetricalRotation, (unsigned long)symmetrical, (unsigned long)original);
}
}
}
@end