PageRenderTime 37ms CodeModel.GetById 27ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/google-toolbox-for-mac/UnitTesting/GTMUnitTestDevLog.h

http://macfuse.googlecode.com/
C++ Header | 79 lines | 21 code | 11 blank | 47 comment | 0 complexity | 483eba82d38b158fc3c702059dcd53b0 MD5 | raw file
 1//
 2//  GTMUnitTestDevLog.h
 3//  
 4//  Copyright 2008 Google Inc.
 5//
 6//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
 7//  use this file except in compliance with the License.  You may obtain a copy
 8//  of the License at
 9// 
10//  http://www.apache.org/licenses/LICENSE-2.0
11// 
12//  Unless required by applicable law or agreed to in writing, software
13//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
15//  License for the specific language governing permissions and limitations under
16//  the License.
17//
18
19#import "GTMDefines.h"
20#import <Foundation/Foundation.h>
21
22// GTMUnitTestDevLog tracks what messages are logged to verify that you only
23// log what you expect to log during the running of unittests. This allows you
24// to log with impunity from your actual core implementations and still be able
25// to find unexpected logs in your output when running unittests.
26// In your unittests you tell GTMUnitTestDevLog what messages you expect your
27// test to spit out, and it will cause any that don't match to appear as errors
28// in your unittest run output. You can match on exact strings or standard 
29// regexps.
30// Set GTM_SHOW_UNITTEST_DEVLOGS in the environment to show the logs that that
31// are expected and encountered.  Otherwise they aren't display to keep the
32// unit test results easier to read.
33
34@interface GTMUnitTestDevLog : NSObject
35// Log a message
36+ (void)log:(NSString*)format, ... NS_FORMAT_FUNCTION(1,2);
37+ (void)log:(NSString*)format args:(va_list)args NS_FORMAT_FUNCTION(1,0);
38
39// Turn tracking on/off
40+ (void)enableTracking;
41+ (void)disableTracking;
42+ (BOOL)isTrackingEnabled;
43
44// Note that you are expecting a string that has an exact match. No need to
45// escape any pattern characters.
46+ (void)expectString:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);
47
48// Note that you are expecting a pattern. Pattern characters that you want
49// exact matches on must be escaped. See [GTMRegex escapedPatternForString].
50// Patterns match across newlines (kGTMRegexOptionSupressNewlineSupport) making
51// it easier to match output from the descriptions of NS collection types such
52// as NSArray and NSDictionary.
53+ (void)expectPattern:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);
54
55// Note that you are expecting exactly 'n' strings
56+ (void)expect:(NSUInteger)n 
57    casesOfString:(NSString *)format, ... NS_FORMAT_FUNCTION(2,3);
58
59// Note that you are expecting exactly 'n' patterns
60+ (void)expect:(NSUInteger)n 
61    casesOfPattern:(NSString*)format, ... NS_FORMAT_FUNCTION(2,3);
62+ (void)expect:(NSUInteger)n 
63    casesOfPattern:(NSString*)format args:(va_list)args NS_FORMAT_FUNCTION(2,0);
64
65// Call when you want to verify that you have matched all the logs you expect
66// to match. If your unittests inherit from GTMTestcase (like they should) you
67// will get this called for free.
68+ (void)verifyNoMoreLogsExpected;
69
70// Resets the expected logs so that you don't have anything expected.
71// In general should not be needed, unless you have a variable logging case
72// of some sort.
73+ (void)resetExpectedLogs;
74@end
75
76// Does the same as GTMUnitTestDevLog, but the logs are only expected in debug.
77// ie-the expect requests don't count in release builds.
78@interface GTMUnitTestDevLogDebug : GTMUnitTestDevLog
79@end