Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 // Copyright 2007, Google Inc. | 1 // Copyright 2007, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 GMOCK_DECLARE_KIND_(unsigned int, kInteger); | 251 GMOCK_DECLARE_KIND_(unsigned int, kInteger); |
252 GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT | 252 GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT |
253 GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT | 253 GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT |
254 | 254 |
255 // Symbian compilation can be done with wchar_t a type or a typedef. | 255 // Symbian compilation can be done with wchar_t a type or a typedef. |
256 // Using GoogleMock with OpenC without wchar_t should require the | 256 // Using GoogleMock with OpenC without wchar_t should require the |
257 // definition of _STLP_NO_WCHAR_T. | 257 // definition of _STLP_NO_WCHAR_T. |
258 // MSVC can be configured to define wchar_t as a typedef of unsigned | 258 // MSVC can be configured to define wchar_t as a typedef of unsigned |
259 // short. It defines _NATIVE_WCHAR_T_DEFINED symbol when wchar_t is a | 259 // short. It defines _NATIVE_WCHAR_T_DEFINED symbol when wchar_t is a |
260 // native type. | 260 // native type. |
261 #if defined(__SYMBIAN32__) && defined(_STLP_NO_WCHAR_T) | 261 #if (GTEST_OS_SYMBIAN && defined(_STLP_NO_WCHAR_T)) || \ |
262 // Do nothing. | 262 (defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)) |
263 #elif !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) | 263 // wchar_t is a typedef - do nothing. |
264 #else | |
264 GMOCK_DECLARE_KIND_(wchar_t, kInteger); | 265 GMOCK_DECLARE_KIND_(wchar_t, kInteger); |
265 #endif | 266 #endif |
266 | 267 |
267 // Non-standard integer types. | 268 // Non-standard integer types. |
268 GMOCK_DECLARE_KIND_(Int64, kInteger); | 269 GMOCK_DECLARE_KIND_(Int64, kInteger); |
269 GMOCK_DECLARE_KIND_(UInt64, kInteger); | 270 GMOCK_DECLARE_KIND_(UInt64, kInteger); |
270 | 271 |
271 // All standard floating-point types. | 272 // All standard floating-point types. |
272 GMOCK_DECLARE_KIND_(float, kFloatingPoint); | 273 GMOCK_DECLARE_KIND_(float, kFloatingPoint); |
273 GMOCK_DECLARE_KIND_(double, kFloatingPoint); | 274 GMOCK_DECLARE_KIND_(double, kFloatingPoint); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
691 // {lval} const char *[4], long, testing::internal::RelationToSource)' | 692 // {lval} const char *[4], long, testing::internal::RelationToSource)' |
692 // does not match | 693 // does not match |
693 // 'testing::internal::NativeArray<char *>::NativeArray( | 694 // 'testing::internal::NativeArray<char *>::NativeArray( |
694 // char *const *, unsigned int, testing::internal::RelationToSource)' | 695 // char *const *, unsigned int, testing::internal::RelationToSource)' |
695 // (instantiating: 'testing::internal::ContainsMatcherImpl | 696 // (instantiating: 'testing::internal::ContainsMatcherImpl |
696 // <const char * (&)[4]>::Matches(const char * (&)[4]) const') | 697 // <const char * (&)[4]>::Matches(const char * (&)[4]) const') |
697 // (instantiating: 'testing::internal::StlContainerView<char *[4]>:: | 698 // (instantiating: 'testing::internal::StlContainerView<char *[4]>:: |
698 // ConstReference(const char * (&)[4])') | 699 // ConstReference(const char * (&)[4])') |
699 // (and though the N parameter type is mismatched in the above explicit | 700 // (and though the N parameter type is mismatched in the above explicit |
700 // conversion of it doesn't help - only the conversion of the array). | 701 // conversion of it doesn't help - only the conversion of the array). |
701 return type(const_cast<Element*>(&array[0]), N, kReference); | 702 return type(const_cast<Element*>(&array[0]), N, kReference); |
Zhanyong Wan
2009/09/21 19:34:05
I think the compiler is parsing &array[0] as (&arr
mika.raento
2009/09/22 12:13:34
I did start out with type(array, N, kReference). N
Zhanyong Wan
2009/09/22 22:16:24
const_cast bypasses the type system and can easily
Zhanyong Wan
2009/09/22 22:20:29
Is it this one?
TEST(NativeArrayTest, WorksForTwo
Zhanyong Wan
2009/09/23 00:04:33
I took a closer look at the compiler error you sup
Zhanyong Wan
2009/09/23 06:53:48
This appears to work on both Symbian and non-Symbi
mika.raento
2009/09/23 07:21:56
It does work for the case that causes the original
mika.raento
2009/09/23 07:21:56
const Element -> Element const doesn't help, the e
Zhanyong Wan
2009/09/23 17:29:13
ICE! Silent crash!! Holy crap!!!
OK, I throw up
Zhanyong Wan
2009/09/23 17:29:13
Yes, this particular use of const_cast is safe. M
| |
702 #else // !GTEST_OS_SYMBIAN | 703 #else // !GTEST_OS_SYMBIAN |
703 return type(array, N, kReference); | 704 return type(array, N, kReference); |
704 #endif // GTEST_OS_SYMBIAN | 705 #endif // GTEST_OS_SYMBIAN |
705 } | 706 } |
706 static type Copy(const Element (&array)[N]) { | 707 static type Copy(const Element (&array)[N]) { |
707 #if GTEST_OS_SYMBIAN | 708 #if GTEST_OS_SYMBIAN |
708 return type(const_cast<Element*>(&array[0]), N, kCopy); | 709 return type(const_cast<Element*>(&array[0]), N, kCopy); |
Zhanyong Wan
2009/09/21 19:34:05
The same.
| |
709 #else // !GTEST_OS_SYMBIAN | 710 #else // !GTEST_OS_SYMBIAN |
710 return type(array, N, kCopy); | 711 return type(array, N, kCopy); |
711 #endif // GTEST_OS_SYMBIAN | 712 #endif // GTEST_OS_SYMBIAN |
712 } | 713 } |
713 }; | 714 }; |
714 | 715 |
715 // This specialization is used when RawContainer is a native array | 716 // This specialization is used when RawContainer is a native array |
716 // represented as a (pointer, size) tuple. | 717 // represented as a (pointer, size) tuple. |
717 template <typename ElementPointer, typename Size> | 718 template <typename ElementPointer, typename Size> |
718 class StlContainerView< ::std::tr1::tuple<ElementPointer, Size> > { | 719 class StlContainerView< ::std::tr1::tuple<ElementPointer, Size> > { |
(...skipping 15 matching lines...) Expand all Loading... | |
734 }; | 735 }; |
735 | 736 |
736 // The following specialization prevents the user from instantiating | 737 // The following specialization prevents the user from instantiating |
737 // StlContainer with a reference type. | 738 // StlContainer with a reference type. |
738 template <typename T> class StlContainerView<T&>; | 739 template <typename T> class StlContainerView<T&>; |
739 | 740 |
740 } // namespace internal | 741 } // namespace internal |
741 } // namespace testing | 742 } // namespace testing |
742 | 743 |
743 #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ | 744 #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ |
LEFT | RIGHT |