diff options
author | NicoleYarroch <nicole@livio.io> | 2017-09-12 10:57:24 -0400 |
---|---|---|
committer | NicoleYarroch <nicole@livio.io> | 2017-09-12 10:57:24 -0400 |
commit | 3e3407e9bcd0b478edf74fb4a36a13fb0fe26de5 (patch) | |
tree | 5d616e467f0bf8fbc33aa215f0ac6ca8dd169c5d /SmartDeviceLinkTests/LoggingSpecs | |
parent | 59360dd1df9987b10fb2d4b17a78860ffa580f44 (diff) | |
download | sdl_ios-3e3407e9bcd0b478edf74fb4a36a13fb0fe26de5.tar.gz |
Fixed the log level bitwise left shift assignment
Signed-off-by: NicoleYarroch <nicole@livio.io>
Diffstat (limited to 'SmartDeviceLinkTests/LoggingSpecs')
-rw-r--r-- | SmartDeviceLinkTests/LoggingSpecs/SDLLogManagerSpec.m | 68 |
1 files changed, 44 insertions, 24 deletions
diff --git a/SmartDeviceLinkTests/LoggingSpecs/SDLLogManagerSpec.m b/SmartDeviceLinkTests/LoggingSpecs/SDLLogManagerSpec.m index c06ffa062..85fc60ba4 100644 --- a/SmartDeviceLinkTests/LoggingSpecs/SDLLogManagerSpec.m +++ b/SmartDeviceLinkTests/LoggingSpecs/SDLLogManagerSpec.m @@ -137,15 +137,13 @@ describe(@"a log manager", ^{ __block NSString *testVerboseFormattedLog; __block int expectedLogCount; - + __block int testLogLevel; __block NSMutableArray<NSString *> *expectedMessages; __block NSMutableArray<NSString *> *notExpectedMessages; context(@"debug configuration", ^{ beforeEach(^{ testConfiguration = [[SDLLogConfiguration alloc] init]; - testConfiguration.modules = [NSSet setWithObject:[SDLLogFileModule moduleWithName:@"test" files:[NSSet setWithObject:@"test"]]]; - testConfiguration.filters = [NSSet setWithObject:[SDLLogFilter filterByDisallowingString:@"this string should never trigger" caseSensitive:NO]]; testConfiguration.targets = [NSSet setWithObject:testLogTarget]; testConfiguration.asynchronous = NO; testConfiguration.formatType = SDLLogFormatTypeSimple; @@ -166,62 +164,81 @@ describe(@"a log manager", ^{ testMessageVerbose = @"verboseMessage"; testVerboseFormattedLog = [NSString stringWithFormat:@"%@ ⚪ (SDL)- %@", formattedDate, testMessageVerbose]; - [expectedMessages removeAllObjects]; - [notExpectedMessages removeAllObjects]; + expectedMessages = [[NSMutableArray alloc] init]; + notExpectedMessages = [[NSMutableArray alloc] init]; }); describe(@"", ^{ beforeEach(^{ expectedLogCount = 0; - expect(testLogTarget.formattedLogMessages.count).to(equal(0)); - }); - - it(@"should log error, warn, and debug logs but not verbose", ^{ - testConfiguration.globalLogLevel = SDLLogLevelDebug; - [testManager setConfiguration:testConfiguration]; - expectedLogCount = 3; - - [expectedMessages addObject:testWarningFormattedLog]; - [expectedMessages addObject:testErrorFormattedLog]; - [expectedMessages addObject:testDebugFormattedLog]; - - [notExpectedMessages addObject:testVerboseFormattedLog]; + expect(expectedMessages.count).to(equal(0)); + expect(notExpectedMessages.count).to(equal(0)); }); it(@"should not log anything when the log level is OFF", ^{ testConfiguration.globalLogLevel = SDLLogLevelOff; - [testManager setConfiguration:testConfiguration]; + testLogLevel = SDLLogLevelOff; expectedLogCount = 0; - [notExpectedMessages addObjectsFromArray:@[testWarningFormattedLog, testErrorFormattedLog, testDebugFormattedLog, testVerboseFormattedLog]]; + [notExpectedMessages addObject:testWarningFormattedLog]; + [notExpectedMessages addObject:testErrorFormattedLog]; + [notExpectedMessages addObject:testDebugFormattedLog]; + [notExpectedMessages addObject:testVerboseFormattedLog]; }); it(@"should only log errors when the log level is ERROR", ^{ testConfiguration.globalLogLevel = SDLLogLevelError; - [testManager setConfiguration:testConfiguration]; + testLogLevel = SDLLogLevelError; expectedLogCount = 1; + + [expectedMessages addObject:testErrorFormattedLog]; + + [notExpectedMessages addObject:testWarningFormattedLog]; + [notExpectedMessages addObject:testDebugFormattedLog]; + [notExpectedMessages addObject:testVerboseFormattedLog]; }); it(@"should only log errors and warnings when the log level is WARNING", ^{ testConfiguration.globalLogLevel = SDLLogLevelWarning; - [testManager setConfiguration:testConfiguration]; + testLogLevel = SDLLogLevelWarning; expectedLogCount = 2; + + [expectedMessages addObject:testWarningFormattedLog]; + [expectedMessages addObject:testErrorFormattedLog]; + + [notExpectedMessages addObject:testDebugFormattedLog]; + [notExpectedMessages addObject:testVerboseFormattedLog]; }); it(@"should only log errors, warnings, and debug logs when the log level is DEBUG", ^{ testConfiguration.globalLogLevel = SDLLogLevelDebug; - [testManager setConfiguration:testConfiguration]; + testLogLevel = SDLLogLevelDebug; expectedLogCount = 3; + + [expectedMessages addObject:testWarningFormattedLog]; + [expectedMessages addObject:testErrorFormattedLog]; + [expectedMessages addObject:testDebugFormattedLog]; + + [notExpectedMessages addObject:testVerboseFormattedLog]; }); it(@"should log errors, warnings, debug, and verbose logs when the log level is VERBOSE", ^{ testConfiguration.globalLogLevel = SDLLogLevelVerbose; - [testManager setConfiguration:testConfiguration]; + testLogLevel = SDLLogLevelVerbose; expectedLogCount = 4; + + [expectedMessages addObject:testWarningFormattedLog]; + [expectedMessages addObject:testErrorFormattedLog]; + [expectedMessages addObject:testDebugFormattedLog]; + [expectedMessages addObject:testVerboseFormattedLog]; }); afterEach(^{ + SDLLogFileModule *module = [[SDLLogFileModule alloc] initWithName:@"test" files:[NSSet setWithObject:@"test"] level:testLogLevel]; + testConfiguration.modules = [NSSet setWithObject:module]; + [testManager setConfiguration:testConfiguration]; + // Warning [testManager logWithLevel:testLogLevelWarning timestamp:testDate file:testFileName functionName:testFunctionName line:testLineWarning queue:testQueue message:testMessageWarning]; @@ -237,6 +254,7 @@ describe(@"a log manager", ^{ }); afterEach(^{ + expect(testManager.asynchronous).to(equal(NO)); expect(testLogTarget.formattedLogMessages.count).to(equal(expectedLogCount)); for(int i = 0; i < expectedMessages.count; i += 1) { @@ -252,4 +270,6 @@ describe(@"a log manager", ^{ }); }); + + QuickSpecEnd |