-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Port first Obj-C file to Swift (#186)
- Loading branch information
1 parent
e2bb3bc
commit 18b1e1c
Showing
8 changed files
with
132 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// NSNumber+MPFormatterTests.m | ||
// mParticle-Apple-SDK | ||
// | ||
// Created by Ben Baron on 3/9/23. | ||
// Copyright © 2023 mParticle, Inc. All rights reserved. | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
#import "MPBaseTestCase.h" | ||
#import <mParticle_Apple_SDK/mParticle_Apple_SDK-Swift.h> | ||
|
||
@interface NSNumber_MPFormatterTests : MPBaseTestCase | ||
|
||
@end | ||
|
||
@implementation NSNumber_MPFormatterTests | ||
|
||
- (void)setUp { | ||
[super setUp]; | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
- (void)tearDown { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
[super tearDown]; | ||
} | ||
|
||
- (void)testFormatZero { | ||
NSNumber *number = @(0); | ||
NSNumber *formattedNumber = [number formatWithNonScientificNotation]; | ||
XCTAssertEqualObjects(formattedNumber, @(0)); | ||
} | ||
|
||
- (void)testFormatCloseToZero { | ||
NSNumber *number = @(1.0E-6); | ||
NSNumber *formattedNumber = [number formatWithNonScientificNotation]; | ||
XCTAssertEqualObjects(formattedNumber, @(0)); | ||
} | ||
|
||
- (void)testFormatOneDecimalPlace { | ||
NSNumber *number = @(0.1); | ||
NSNumber *formattedNumber = [number formatWithNonScientificNotation]; | ||
XCTAssertEqualObjects(formattedNumber, @(0.1)); | ||
} | ||
|
||
- (void)testFormatTwoDecimalPlaces { | ||
NSNumber *number = @(0.01); | ||
NSNumber *formattedNumber = [number formatWithNonScientificNotation]; | ||
XCTAssertEqualObjects(formattedNumber, @(0.01)); | ||
} | ||
|
||
- (void)testFormatRoundUp { | ||
NSNumber *number = @(10.01534634); | ||
NSNumber *formattedNumber = [number formatWithNonScientificNotation]; | ||
XCTAssertEqualObjects(formattedNumber, @(10.02)); | ||
} | ||
|
||
- (void)testFormatRoundDown { | ||
NSNumber *number = @(10.01434634); | ||
NSNumber *formattedNumber = [number formatWithNonScientificNotation]; | ||
XCTAssertEqualObjects(formattedNumber, @(10.01)); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.