~ubuntu-branches/debian/squeeze/protobuf/squeeze

« back to all changes in this revision

Viewing changes to src/gtest/gtest.cc

  • Committer: Bazaar Package Importer
  • Author(s): Julien Cristau
  • Date: 2009-06-02 16:19:00 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090602161900-vm176i3ryt35yk91
Tags: 2.0.3-2.2
* Non-maintainer upload.
* Fix FTBFS from -2.1: don't fail when we can't clean up the java build,
  such as when openjdk isn't installed.
* Disable parallel builds, because libtool is made of fail (if binary-arch
  and build-indep run concurrently, we relink a library while it's being
  used; that doesn't work so well).

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
#include <stdio.h>
41
41
#include <stdlib.h>
42
42
#include <string.h>
 
43
#include <wchar.h>
43
44
 
44
45
#ifdef GTEST_OS_LINUX
45
46
 
112
113
 
113
114
namespace testing {
114
115
 
 
116
// Calling ForEach(internal::Delete<T>) doesn't work on HP C++ / Tru64.  So,
 
117
// we must define a separate non-template function for each type.
 
118
static void DeleteTestCase(TestCase *x)
 
119
{
 
120
 delete x;
 
121
}
 
122
static void DeleteEnvironment(Environment *x)
 
123
{
 
124
 delete x;
 
125
}
 
126
static void DeleteTestInfo(TestInfo *x)
 
127
{
 
128
 delete x;
 
129
}
 
130
 
115
131
// Constants.
116
132
 
117
133
// A test that matches this pattern is disabled and not run.
799
815
                        ch_as_uint, ch_as_uint);
800
816
}
801
817
 
802
 
// For a wchar_t value, we print it as a C++ wchar_t literal and as an
803
 
// unsigned integer (both in decimal and in hexidecimal).
804
 
String FormatForFailureMessage(wchar_t wchar) {
805
 
  // The C++ standard doesn't specify the exact size of the wchar_t
806
 
  // type.  It just says that it shall have the same size as another
807
 
  // integral type, called its underlying type.
808
 
  //
809
 
  // Therefore, in order to print a wchar_t value in the numeric form,
810
 
  // we first convert it to the largest integral type (UInt64) and
811
 
  // then print the converted value.
812
 
  //
813
 
  // We use streaming to print the value as "%llu" doesn't work
814
 
  // correctly with MSVC 7.1.
815
 
  const UInt64 wchar_as_uint64 = wchar;
816
 
  Message msg;
817
 
  // A String object cannot contain '\0', so we print "\\0" when wchar is
818
 
  // L'\0'.
819
 
  msg << "L'" << (wchar ? ToUtf8String(wchar).c_str() : "\\0") << "' ("
820
 
      << wchar_as_uint64 << ", 0x" << ::std::setbase(16)
821
 
      << wchar_as_uint64 << ")";
822
 
  return msg.GetString();
823
 
}
824
818
 
825
819
}  // namespace internal
826
820
 
2059
2053
// Destructor of TestCase.
2060
2054
TestCase::~TestCase() {
2061
2055
  // Deletes every Test in the collection.
2062
 
  test_info_list_->ForEach(internal::Delete<TestInfo>);
 
2056
  test_info_list_->ForEach(DeleteTestInfo);
2063
2057
 
2064
2058
  // Then deletes the Test collection.
2065
2059
  delete test_info_list_;
3039
3033
 
3040
3034
UnitTestImpl::~UnitTestImpl() {
3041
3035
  // Deletes every TestCase.
3042
 
  test_cases_.ForEach(internal::Delete<TestCase>);
 
3036
  test_cases_.ForEach(DeleteTestCase);
3043
3037
 
3044
3038
  // Deletes every Environment.
3045
 
  environments_.ForEach(internal::Delete<Environment>);
 
3039
  environments_.ForEach(DeleteEnvironment);
3046
3040
 
3047
3041
  // Deletes the current test result printer.
3048
3042
  delete result_printer_;