summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/DevAPISpecs/NSArray+ExtensionsSpec.m
diff options
context:
space:
mode:
authorFrank Elias <francois.elias@livio.io>2021-03-04 14:09:18 -0500
committerFrank Elias <francois.elias@livio.io>2021-03-04 14:09:18 -0500
commit3baa380fc9dd7f1945f2126671cf4e931e45e71e (patch)
treedc0b0ebb7031750478b633547c8ada3c612541e7 /SmartDeviceLinkTests/DevAPISpecs/NSArray+ExtensionsSpec.m
parentab95191870654e556caa5448dbccfb1d72cef612 (diff)
parent19055a83e82f5883335aafbf646e750022055ac9 (diff)
downloadsdl_ios-3baa380fc9dd7f1945f2126671cf4e931e45e71e.tar.gz
Merge branch 'develop' into bugfix/issue-1928-main-menu-ui-updates-do-not-take-textFieldName-imageFieldName-into-consideration
Diffstat (limited to 'SmartDeviceLinkTests/DevAPISpecs/NSArray+ExtensionsSpec.m')
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/NSArray+ExtensionsSpec.m60
1 files changed, 60 insertions, 0 deletions
diff --git a/SmartDeviceLinkTests/DevAPISpecs/NSArray+ExtensionsSpec.m b/SmartDeviceLinkTests/DevAPISpecs/NSArray+ExtensionsSpec.m
new file mode 100644
index 000000000..7a8bf1277
--- /dev/null
+++ b/SmartDeviceLinkTests/DevAPISpecs/NSArray+ExtensionsSpec.m
@@ -0,0 +1,60 @@
+//
+// NSArray+ExtensionsSpec.m
+// SmartDeviceLinkTests
+//
+// Created by Joel Fischer on 2/22/21.
+// Copyright © 2021 smartdevicelink. All rights reserved.
+//
+
+#import "NSArray+Extensions.h"
+
+#import <Quick/Quick.h>
+#import <Nimble/Nimble.h>
+
+QuickSpecBegin(NSArray_ExtensionsSpec)
+
+describe(@"checking the dynamic hash of an array", ^{
+ __block NSArray *testArray = nil;
+
+ beforeEach(^{
+ testArray = nil;
+ });
+
+ context(@"when the array has no objects", ^{
+ beforeEach(^{
+ testArray = @[];
+ });
+
+ it(@"should return a dynamic hash of 0", ^{
+ expect(testArray.dynamicHash).to(equal(0));
+ });
+ });
+
+ context(@"when the array contains one string", ^{
+ beforeEach(^{
+ testArray = @[@"test string"];
+ });
+
+ it(@"should return a consistent dynamic hash", ^{
+ expect(testArray.dynamicHash).to(equal(testArray.dynamicHash));
+ });
+
+ it(@"should return a different hash than the normal hash function", ^{
+ expect(testArray.dynamicHash).toNot(equal(testArray.hash));
+ });
+ });
+
+ context(@"when the array contains multiple strings", ^{
+ it(@"should return different numbers depending on where the strings are in the array", ^{
+ testArray = @[@"test string", @"test string 2"];
+ NSUInteger hash1 = testArray.dynamicHash;
+
+ testArray = @[@"test string 2", @"test string"];
+ NSUInteger hash2 = testArray.dynamicHash;
+
+ expect(hash1).toNot(equal(hash2));
+ });
+ });
+});
+
+QuickSpecEnd