PageRenderTime 32ms CodeModel.GetById 27ms RepoModel.GetById 0ms 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
Possible License(s): Apache-2.0, BSD-3-Clause, GPL-2.0
  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. #import "GTMDefines.h"
  19. #import <Foundation/Foundation.h>
  20. // GTMUnitTestDevLog tracks what messages are logged to verify that you only
  21. // log what you expect to log during the running of unittests. This allows you
  22. // to log with impunity from your actual core implementations and still be able
  23. // to find unexpected logs in your output when running unittests.
  24. // In your unittests you tell GTMUnitTestDevLog what messages you expect your
  25. // test to spit out, and it will cause any that don't match to appear as errors
  26. // in your unittest run output. You can match on exact strings or standard
  27. // regexps.
  28. // Set GTM_SHOW_UNITTEST_DEVLOGS in the environment to show the logs that that
  29. // are expected and encountered. Otherwise they aren't display to keep the
  30. // unit test results easier to read.
  31. @interface GTMUnitTestDevLog : NSObject
  32. // Log a message
  33. + (void)log:(NSString*)format, ... NS_FORMAT_FUNCTION(1,2);
  34. + (void)log:(NSString*)format args:(va_list)args NS_FORMAT_FUNCTION(1,0);
  35. // Turn tracking on/off
  36. + (void)enableTracking;
  37. + (void)disableTracking;
  38. + (BOOL)isTrackingEnabled;
  39. // Note that you are expecting a string that has an exact match. No need to
  40. // escape any pattern characters.
  41. + (void)expectString:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);
  42. // Note that you are expecting a pattern. Pattern characters that you want
  43. // exact matches on must be escaped. See [GTMRegex escapedPatternForString].
  44. // Patterns match across newlines (kGTMRegexOptionSupressNewlineSupport) making
  45. // it easier to match output from the descriptions of NS collection types such
  46. // as NSArray and NSDictionary.
  47. + (void)expectPattern:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);
  48. // Note that you are expecting exactly 'n' strings
  49. + (void)expect:(NSUInteger)n
  50. casesOfString:(NSString *)format, ... NS_FORMAT_FUNCTION(2,3);
  51. // Note that you are expecting exactly 'n' patterns
  52. + (void)expect:(NSUInteger)n
  53. casesOfPattern:(NSString*)format, ... NS_FORMAT_FUNCTION(2,3);
  54. + (void)expect:(NSUInteger)n
  55. casesOfPattern:(NSString*)format args:(va_list)args NS_FORMAT_FUNCTION(2,0);
  56. // Call when you want to verify that you have matched all the logs you expect
  57. // to match. If your unittests inherit from GTMTestcase (like they should) you
  58. // will get this called for free.
  59. + (void)verifyNoMoreLogsExpected;
  60. // Resets the expected logs so that you don't have anything expected.
  61. // In general should not be needed, unless you have a variable logging case
  62. // of some sort.
  63. + (void)resetExpectedLogs;
  64. @end
  65. // Does the same as GTMUnitTestDevLog, but the logs are only expected in debug.
  66. // ie-the expect requests don't count in release builds.
  67. @interface GTMUnitTestDevLogDebug : GTMUnitTestDevLog
  68. @end