summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/darwin/src/NSDate+MGLAdditions.mm5
-rw-r--r--platform/darwin/test/MGLNSDateAdditionsTests.mm14
-rw-r--r--platform/ios/ios.xcodeproj/project.pbxproj8
-rw-r--r--platform/ios/test/MGLNSDateAdditionsTests.mm26
-rw-r--r--platform/macos/macos.xcodeproj/project.pbxproj8
-rw-r--r--platform/macos/test/MGLNSDateAdditionsTests.mm26
6 files changed, 23 insertions, 64 deletions
diff --git a/platform/darwin/src/NSDate+MGLAdditions.mm b/platform/darwin/src/NSDate+MGLAdditions.mm
index 1739805e7c..b45b41f836 100644
--- a/platform/darwin/src/NSDate+MGLAdditions.mm
+++ b/platform/darwin/src/NSDate+MGLAdditions.mm
@@ -7,8 +7,5 @@ mbgl::Duration MGLDurationFromTimeInterval(NSTimeInterval duration)
NSTimeInterval MGLTimeIntervalFromDuration(mbgl::Duration duration)
{
- std::chrono::nanoseconds nano(duration.count());
- std::chrono::seconds sec = std::chrono::duration_cast<std::chrono::seconds>(nano);
-
- return sec.count();
+ return std::chrono::duration<NSTimeInterval, std::ratio<1>>(duration).count();
}
diff --git a/platform/darwin/test/MGLNSDateAdditionsTests.mm b/platform/darwin/test/MGLNSDateAdditionsTests.mm
index 474fe763ff..6d8d951024 100644
--- a/platform/darwin/test/MGLNSDateAdditionsTests.mm
+++ b/platform/darwin/test/MGLNSDateAdditionsTests.mm
@@ -17,9 +17,23 @@ using namespace std::chrono_literals;
NSTimeInterval durationTimeInterval = MGLTimeIntervalFromDuration(duration);
mbgl::Duration expectedDuration = 5s;
+ mbgl::Duration expectedDurationMiliSeconds = 5000ms;
+ mbgl::Duration expectedDurationMicroSeconds = 5000000us;
+ mbgl::Duration expectedDurationNanoSeconds = 5000000000ns;
XCTAssertEqual(timeInterval, durationTimeInterval);
XCTAssertEqual(timeInterval, MGLTimeIntervalFromDuration(expectedDuration));
+ XCTAssertEqual(timeInterval, MGLTimeIntervalFromDuration(expectedDurationMiliSeconds));
+ XCTAssertEqual(timeInterval, MGLTimeIntervalFromDuration(expectedDurationMicroSeconds));
+ XCTAssertEqual(timeInterval, MGLTimeIntervalFromDuration(expectedDurationNanoSeconds));
+
+ mbgl::Duration durationMiliSeconds = 2500ms;
+ mbgl::Duration durationMicroSeconds = 2500000us;
+ mbgl::Duration durationNanoSeconds = 2500000000ns;
+
+ XCTAssertEqual(NSTimeInterval(2.5), MGLTimeIntervalFromDuration(durationMiliSeconds));
+ XCTAssertEqual(NSTimeInterval(2.5), MGLTimeIntervalFromDuration(durationMicroSeconds));
+ XCTAssertEqual(NSTimeInterval(2.5), MGLTimeIntervalFromDuration(durationNanoSeconds));
}
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj
index bb69a3761e..d7ca6f0643 100644
--- a/platform/ios/ios.xcodeproj/project.pbxproj
+++ b/platform/ios/ios.xcodeproj/project.pbxproj
@@ -9,7 +9,7 @@
/* Begin PBXBuildFile section */
1753ED421E53CE6F00A9FD90 /* MGLConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 1753ED411E53CE6F00A9FD90 /* MGLConversion.h */; };
1753ED431E53CE6F00A9FD90 /* MGLConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 1753ED411E53CE6F00A9FD90 /* MGLConversion.h */; };
- 1F131E341E6A35EC0055AF5B /* MGLNSDateAdditionsTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F131E331E6A35EC0055AF5B /* MGLNSDateAdditionsTests.mm */; };
+ 1F95931D1E6DE2E900D5B294 /* MGLNSDateAdditionsTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F95931C1E6DE2E900D5B294 /* MGLNSDateAdditionsTests.mm */; };
30E578171DAA85520050F07E /* UIImage+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 30E578111DAA7D690050F07E /* UIImage+MGLAdditions.h */; };
30E578181DAA85520050F07E /* UIImage+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 30E578111DAA7D690050F07E /* UIImage+MGLAdditions.h */; };
30E578191DAA855E0050F07E /* UIImage+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 30E578121DAA7D690050F07E /* UIImage+MGLAdditions.mm */; };
@@ -531,7 +531,7 @@
/* Begin PBXFileReference section */
1753ED411E53CE6F00A9FD90 /* MGLConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLConversion.h; sourceTree = "<group>"; };
- 1F131E331E6A35EC0055AF5B /* MGLNSDateAdditionsTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLNSDateAdditionsTests.mm; sourceTree = "<group>"; };
+ 1F95931C1E6DE2E900D5B294 /* MGLNSDateAdditionsTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLNSDateAdditionsTests.mm; path = ../../darwin/test/MGLNSDateAdditionsTests.mm; sourceTree = "<group>"; };
20DABE861DF78148007AC5FF /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Foundation.strings"; sourceTree = "<group>"; };
20DABE881DF78148007AC5FF /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
20DABE8A1DF78149007AC5FF /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Root.strings"; sourceTree = "<group>"; };
@@ -1196,7 +1196,7 @@
DA0CD58F1CF56F6A00A5F5A5 /* MGLFeatureTests.mm */,
DA2E885C1CC0382C00F24E7B /* MGLGeometryTests.mm */,
35E208A61D24210F00EC9A46 /* MGLNSDataAdditionsTests.m */,
- 1F131E331E6A35EC0055AF5B /* MGLNSDateAdditionsTests.mm */,
+ 1F95931C1E6DE2E900D5B294 /* MGLNSDateAdditionsTests.mm */,
DAE7DEC11E245455007505A6 /* MGLNSStringAdditionsTests.m */,
DA2E885D1CC0382C00F24E7B /* MGLOfflinePackTests.m */,
DA2E885E1CC0382C00F24E7B /* MGLOfflineRegionTests.m */,
@@ -2099,7 +2099,7 @@
40CFA6511D7875BB008103BD /* MGLShapeSourceTests.mm in Sources */,
DA35A2C51CCA9F8300E826B2 /* MGLClockDirectionFormatterTests.m in Sources */,
35B8E08C1D6C8B5100E768D2 /* MGLPredicateTests.mm in Sources */,
- 1F131E341E6A35EC0055AF5B /* MGLNSDateAdditionsTests.mm in Sources */,
+ 1F95931D1E6DE2E900D5B294 /* MGLNSDateAdditionsTests.mm in Sources */,
DD58A4C61D822BD000E1F038 /* MGLExpressionTests.mm in Sources */,
3575798B1D502B0C000B822E /* MGLBackgroundStyleLayerTests.mm in Sources */,
DA2E88621CC0382C00F24E7B /* MGLOfflinePackTests.m in Sources */,
diff --git a/platform/ios/test/MGLNSDateAdditionsTests.mm b/platform/ios/test/MGLNSDateAdditionsTests.mm
deleted file mode 100644
index 474fe763ff..0000000000
--- a/platform/ios/test/MGLNSDateAdditionsTests.mm
+++ /dev/null
@@ -1,26 +0,0 @@
-#import <XCTest/XCTest.h>
-
-#include <mbgl/util/chrono.hpp>
-#import "../../darwin/src/NSDate+MGLAdditions.h"
-
-using namespace std::chrono_literals;
-
-@interface MGLNSDateAdditionsTests : XCTestCase
-@end
-
-@implementation MGLNSDateAdditionsTests
-
-- (void)testDurationToNSTimeInterval {
-
- NSTimeInterval timeInterval = 5;
- mbgl::Duration duration = MGLDurationFromTimeInterval(timeInterval);
- NSTimeInterval durationTimeInterval = MGLTimeIntervalFromDuration(duration);
-
- mbgl::Duration expectedDuration = 5s;
-
- XCTAssertEqual(timeInterval, durationTimeInterval);
- XCTAssertEqual(timeInterval, MGLTimeIntervalFromDuration(expectedDuration));
-
-}
-
-@end
diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj
index d76a225edb..4a2cc0e71a 100644
--- a/platform/macos/macos.xcodeproj/project.pbxproj
+++ b/platform/macos/macos.xcodeproj/project.pbxproj
@@ -8,7 +8,7 @@
/* Begin PBXBuildFile section */
1753ED401E53CE6100A9FD90 /* MGLConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 1753ED3F1E53CE5200A9FD90 /* MGLConversion.h */; };
- 1F131E361E6A36170055AF5B /* MGLNSDateAdditionsTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F131E351E6A36170055AF5B /* MGLNSDateAdditionsTests.mm */; };
+ 1F95931B1E6DE2B600D5B294 /* MGLNSDateAdditionsTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F95931A1E6DE2B600D5B294 /* MGLNSDateAdditionsTests.mm */; };
30E5781B1DAA857E0050F07E /* NSImage+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 30E578141DAA7D920050F07E /* NSImage+MGLAdditions.h */; };
3508EC641D749D39009B0EE4 /* NSExpression+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3508EC621D749D39009B0EE4 /* NSExpression+MGLAdditions.h */; };
3508EC651D749D39009B0EE4 /* NSExpression+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3508EC631D749D39009B0EE4 /* NSExpression+MGLAdditions.mm */; };
@@ -264,7 +264,7 @@
/* Begin PBXFileReference section */
1753ED3F1E53CE5200A9FD90 /* MGLConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLConversion.h; sourceTree = "<group>"; };
- 1F131E351E6A36170055AF5B /* MGLNSDateAdditionsTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLNSDateAdditionsTests.mm; sourceTree = "<group>"; };
+ 1F95931A1E6DE2B600D5B294 /* MGLNSDateAdditionsTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLNSDateAdditionsTests.mm; path = ../../darwin/test/MGLNSDateAdditionsTests.mm; sourceTree = "<group>"; };
30E578141DAA7D920050F07E /* NSImage+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSImage+MGLAdditions.h"; path = "src/NSImage+MGLAdditions.h"; sourceTree = SOURCE_ROOT; };
3508EC621D749D39009B0EE4 /* NSExpression+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSExpression+MGLAdditions.h"; sourceTree = "<group>"; };
3508EC631D749D39009B0EE4 /* NSExpression+MGLAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSExpression+MGLAdditions.mm"; sourceTree = "<group>"; };
@@ -959,8 +959,8 @@
DA35A2A71CC9F41600E826B2 /* MGLCoordinateFormatterTests.m */,
DA2987591E1A4290002299F5 /* MGLDocumentationExampleTests.swift */,
DD58A4C71D822C6200E1F038 /* MGLExpressionTests.mm */,
- 1F131E351E6A36170055AF5B /* MGLNSDateAdditionsTests.mm */,
35C6DF861E214C1800ACA483 /* MGLDistanceFormatterTests.m */,
+ 1F95931A1E6DE2B600D5B294 /* MGLNSDateAdditionsTests.mm */,
DA0CD58D1CF56F5800A5F5A5 /* MGLFeatureTests.mm */,
DAE6C3C81CC34BD800DB3429 /* MGLGeometryTests.mm */,
DAE7DEC31E24549F007505A6 /* MGLNSStringAdditionsTests.m */,
@@ -1423,7 +1423,7 @@
DAE6C3D21CC34C9900DB3429 /* MGLGeometryTests.mm in Sources */,
DA87A9A41DCACC5000810D09 /* MGLSymbolStyleLayerTests.mm in Sources */,
40E1601D1DF217D6005EA6D9 /* MGLStyleLayerTests.m in Sources */,
- 1F131E361E6A36170055AF5B /* MGLNSDateAdditionsTests.mm in Sources */,
+ 1F95931B1E6DE2B600D5B294 /* MGLNSDateAdditionsTests.mm in Sources */,
DA87A9A61DCACC5000810D09 /* MGLCircleStyleLayerTests.mm in Sources */,
DA87A99E1DC9DC2100810D09 /* MGLPredicateTests.mm in Sources */,
DD58A4C91D822C6700E1F038 /* MGLExpressionTests.mm in Sources */,
diff --git a/platform/macos/test/MGLNSDateAdditionsTests.mm b/platform/macos/test/MGLNSDateAdditionsTests.mm
deleted file mode 100644
index 474fe763ff..0000000000
--- a/platform/macos/test/MGLNSDateAdditionsTests.mm
+++ /dev/null
@@ -1,26 +0,0 @@
-#import <XCTest/XCTest.h>
-
-#include <mbgl/util/chrono.hpp>
-#import "../../darwin/src/NSDate+MGLAdditions.h"
-
-using namespace std::chrono_literals;
-
-@interface MGLNSDateAdditionsTests : XCTestCase
-@end
-
-@implementation MGLNSDateAdditionsTests
-
-- (void)testDurationToNSTimeInterval {
-
- NSTimeInterval timeInterval = 5;
- mbgl::Duration duration = MGLDurationFromTimeInterval(timeInterval);
- NSTimeInterval durationTimeInterval = MGLTimeIntervalFromDuration(duration);
-
- mbgl::Duration expectedDuration = 5s;
-
- XCTAssertEqual(timeInterval, durationTimeInterval);
- XCTAssertEqual(timeInterval, MGLTimeIntervalFromDuration(expectedDuration));
-
-}
-
-@end