/core/externals/google-toolbox-for-mac/UnitTesting/GTMDevLogUnitTestingBridge.m

http://macfuse.googlecode.com/ · Objective C · 44 lines · 12 code · 2 blank · 30 comment · 2 complexity · 71765df0da103f2002668cc7e37c2574 MD5 · raw file

  1. //
  2. // GTMDevLogUnitTestingBridge.m
  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. #include "GTMUnitTestDevLog.h"
  19. //
  20. // NOTE: Odds are this file should not be included in your project. It is
  21. // only needed for some enhanced unit testing.
  22. //
  23. // By adding:
  24. // #define _GTMDevLog _GTMUnitTestDevLog
  25. // to your prefix header (like the GTM Framework does), this function then
  26. // works to forward logging messages to the GTMUnitTestDevLog class to
  27. // allow logging validation during unittest, otherwise the messages go to
  28. // NSLog like normal.
  29. //
  30. // See GTMUnitTestDevLog.h for more information on checking logs in unittests.
  31. //
  32. void _GTMUnitTestDevLog(NSString *format, ...) {
  33. Class devLogClass = NSClassFromString(@"GTMUnitTestDevLog");
  34. va_list argList;
  35. va_start(argList, format);
  36. if (devLogClass) {
  37. [devLogClass log:format args:argList];
  38. } else {
  39. NSLogv(format, argList); // COV_NF_LINE the class is in all our unittest setups
  40. }
  41. va_end(argList);
  42. }