Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A598D2004C8 for ; Mon, 9 May 2016 12:12:20 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A43CA16098A; Mon, 9 May 2016 10:12:20 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 61C4A160A0F for ; Mon, 9 May 2016 12:12:18 +0200 (CEST) Received: (qmail 30857 invoked by uid 500); 9 May 2016 10:12:17 -0000 Mailing-List: contact commits-help@hawq.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hawq.incubator.apache.org Delivered-To: mailing list commits@hawq.incubator.apache.org Received: (qmail 30848 invoked by uid 99); 9 May 2016 10:12:17 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 May 2016 10:12:17 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 165921A0014 for ; Mon, 9 May 2016 10:12:17 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.221 X-Spam-Level: X-Spam-Status: No, score=-3.221 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id QuynSY3-mbYy for ; Mon, 9 May 2016 10:12:05 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 825DF60D56 for ; Mon, 9 May 2016 10:11:48 +0000 (UTC) Received: (qmail 27128 invoked by uid 99); 9 May 2016 10:11:47 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 May 2016 10:11:47 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 455BBDFFB9; Mon, 9 May 2016 10:11:47 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: huor@apache.org To: commits@hawq.incubator.apache.org Date: Mon, 09 May 2016 10:12:06 -0000 Message-Id: <65c32eb0113f4b748fd91dacba840831@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [21/52] [abbrv] [partial] incubator-hawq git commit: HAWQ-707. Remove gtest/gmock dependency from libyarn/libhdfs3 archived-at: Mon, 09 May 2016 10:12:20 -0000 http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a5b68bab/depends/googletest/googlemock/test/gmock_link2_test.cc ---------------------------------------------------------------------- diff --git a/depends/googletest/googlemock/test/gmock_link2_test.cc b/depends/googletest/googlemock/test/gmock_link2_test.cc deleted file mode 100644 index 4c310c3..0000000 --- a/depends/googletest/googlemock/test/gmock_link2_test.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file is for verifying that various Google Mock constructs do not -// produce linker errors when instantiated in different translation units. -// Please see gmock_link_test.h for details. - -#define LinkTest LinkTest2 - -#include "test/gmock_link_test.h" http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a5b68bab/depends/googletest/googlemock/test/gmock_link_test.cc ---------------------------------------------------------------------- diff --git a/depends/googletest/googlemock/test/gmock_link_test.cc b/depends/googletest/googlemock/test/gmock_link_test.cc deleted file mode 100644 index 61e97d1..0000000 --- a/depends/googletest/googlemock/test/gmock_link_test.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file is for verifying that various Google Mock constructs do not -// produce linker errors when instantiated in different translation units. -// Please see gmock_link_test.h for details. - -#define LinkTest LinkTest1 - -#include "test/gmock_link_test.h" http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a5b68bab/depends/googletest/googlemock/test/gmock_link_test.h ---------------------------------------------------------------------- diff --git a/depends/googletest/googlemock/test/gmock_link_test.h b/depends/googletest/googlemock/test/gmock_link_test.h deleted file mode 100644 index 1f55f5b..0000000 --- a/depends/googletest/googlemock/test/gmock_link_test.h +++ /dev/null @@ -1,669 +0,0 @@ -// Copyright 2009, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: vladl@google.com (Vlad Losev) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file tests that: -// a. A header file defining a mock class can be included in multiple -// translation units without causing a link error. -// b. Actions and matchers can be instantiated with identical template -// arguments in different translation units without causing link -// errors. -// The following constructs are currently tested: -// Actions: -// Return() -// Return(value) -// ReturnNull -// ReturnRef -// Assign -// SetArgPointee -// SetArrayArgument -// SetErrnoAndReturn -// Invoke(function) -// Invoke(object, method) -// InvokeWithoutArgs(function) -// InvokeWithoutArgs(object, method) -// InvokeArgument -// WithArg -// WithArgs -// WithoutArgs -// DoAll -// DoDefault -// IgnoreResult -// Throw -// ACTION()-generated -// ACTION_P()-generated -// ACTION_P2()-generated -// Matchers: -// _ -// A -// An -// Eq -// Gt, Lt, Ge, Le, Ne -// NotNull -// Ref -// TypedEq -// DoubleEq -// FloatEq -// NanSensitiveDoubleEq -// NanSensitiveFloatEq -// ContainsRegex -// MatchesRegex -// EndsWith -// HasSubstr -// StartsWith -// StrCaseEq -// StrCaseNe -// StrEq -// StrNe -// ElementsAre -// ElementsAreArray -// ContainerEq -// Field -// Property -// ResultOf(function) -// Pointee -// Truly(predicate) -// AllOf -// AnyOf -// Not -// MatcherCast -// -// Please note: this test does not verify the functioning of these -// constructs, only that the programs using them will link successfully. -// -// Implementation note: -// This test requires identical definitions of Interface and Mock to be -// included in different translation units. We achieve this by writing -// them in this header and #including it in gmock_link_test.cc and -// gmock_link2_test.cc. Because the symbols generated by the compiler for -// those constructs must be identical in both translation units, -// definitions of Interface and Mock tests MUST be kept in the SAME -// NON-ANONYMOUS namespace in this file. The test fixture class LinkTest -// is defined as LinkTest1 in gmock_link_test.cc and as LinkTest2 in -// gmock_link2_test.cc to avoid producing linker errors. - -#ifndef GMOCK_TEST_GMOCK_LINK_TEST_H_ -#define GMOCK_TEST_GMOCK_LINK_TEST_H_ - -#include "gmock/gmock.h" - -#if !GTEST_OS_WINDOWS_MOBILE -# include -#endif - -#include "gmock/internal/gmock-port.h" -#include "gtest/gtest.h" -#include -#include - -using testing::_; -using testing::A; -using testing::AllOf; -using testing::AnyOf; -using testing::Assign; -using testing::ContainerEq; -using testing::DoAll; -using testing::DoDefault; -using testing::DoubleEq; -using testing::ElementsAre; -using testing::ElementsAreArray; -using testing::EndsWith; -using testing::Eq; -using testing::Field; -using testing::FloatEq; -using testing::Ge; -using testing::Gt; -using testing::HasSubstr; -using testing::IgnoreResult; -using testing::Invoke; -using testing::InvokeArgument; -using testing::InvokeWithoutArgs; -using testing::IsNull; -using testing::Le; -using testing::Lt; -using testing::Matcher; -using testing::MatcherCast; -using testing::NanSensitiveDoubleEq; -using testing::NanSensitiveFloatEq; -using testing::Ne; -using testing::Not; -using testing::NotNull; -using testing::Pointee; -using testing::Property; -using testing::Ref; -using testing::ResultOf; -using testing::Return; -using testing::ReturnNull; -using testing::ReturnRef; -using testing::SetArgPointee; -using testing::SetArrayArgument; -using testing::StartsWith; -using testing::StrCaseEq; -using testing::StrCaseNe; -using testing::StrEq; -using testing::StrNe; -using testing::Truly; -using testing::TypedEq; -using testing::WithArg; -using testing::WithArgs; -using testing::WithoutArgs; - -#if !GTEST_OS_WINDOWS_MOBILE -using testing::SetErrnoAndReturn; -#endif - -#if GTEST_HAS_EXCEPTIONS -using testing::Throw; -#endif - -using testing::ContainsRegex; -using testing::MatchesRegex; - -class Interface { - public: - virtual ~Interface() {} - virtual void VoidFromString(char* str) = 0; - virtual char* StringFromString(char* str) = 0; - virtual int IntFromString(char* str) = 0; - virtual int& IntRefFromString(char* str) = 0; - virtual void VoidFromFunc(void(*func)(char* str)) = 0; - virtual void VoidFromIntRef(int& n) = 0; // NOLINT - virtual void VoidFromFloat(float n) = 0; - virtual void VoidFromDouble(double n) = 0; - virtual void VoidFromVector(const std::vector& v) = 0; -}; - -class Mock: public Interface { - public: - Mock() {} - - MOCK_METHOD1(VoidFromString, void(char* str)); - MOCK_METHOD1(StringFromString, char*(char* str)); - MOCK_METHOD1(IntFromString, int(char* str)); - MOCK_METHOD1(IntRefFromString, int&(char* str)); - MOCK_METHOD1(VoidFromFunc, void(void(*func)(char* str))); - MOCK_METHOD1(VoidFromIntRef, void(int& n)); // NOLINT - MOCK_METHOD1(VoidFromFloat, void(float n)); - MOCK_METHOD1(VoidFromDouble, void(double n)); - MOCK_METHOD1(VoidFromVector, void(const std::vector& v)); - - private: - GTEST_DISALLOW_COPY_AND_ASSIGN_(Mock); -}; - -class InvokeHelper { - public: - static void StaticVoidFromVoid() {} - void VoidFromVoid() {} - static void StaticVoidFromString(char* /* str */) {} - void VoidFromString(char* /* str */) {} - static int StaticIntFromString(char* /* str */) { return 1; } - static bool StaticBoolFromString(const char* /* str */) { return true; } -}; - -class FieldHelper { - public: - explicit FieldHelper(int a_field) : field_(a_field) {} - int field() const { return field_; } - int field_; // NOLINT -- need external access to field_ to test - // the Field matcher. -}; - -// Tests the linkage of the ReturnVoid action. -TEST(LinkTest, TestReturnVoid) { - Mock mock; - - EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return()); - mock.VoidFromString(NULL); -} - -// Tests the linkage of the Return action. -TEST(LinkTest, TestReturn) { - Mock mock; - char ch = 'x'; - - EXPECT_CALL(mock, StringFromString(_)).WillOnce(Return(&ch)); - mock.StringFromString(NULL); -} - -// Tests the linkage of the ReturnNull action. -TEST(LinkTest, TestReturnNull) { - Mock mock; - - EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return()); - mock.VoidFromString(NULL); -} - -// Tests the linkage of the ReturnRef action. -TEST(LinkTest, TestReturnRef) { - Mock mock; - int n = 42; - - EXPECT_CALL(mock, IntRefFromString(_)).WillOnce(ReturnRef(n)); - mock.IntRefFromString(NULL); -} - -// Tests the linkage of the Assign action. -TEST(LinkTest, TestAssign) { - Mock mock; - char ch = 'x'; - - EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Assign(&ch, 'y')); - mock.VoidFromString(NULL); -} - -// Tests the linkage of the SetArgPointee action. -TEST(LinkTest, TestSetArgPointee) { - Mock mock; - char ch = 'x'; - - EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArgPointee<0>('y')); - mock.VoidFromString(&ch); -} - -// Tests the linkage of the SetArrayArgument action. -TEST(LinkTest, TestSetArrayArgument) { - Mock mock; - char ch = 'x'; - char ch2 = 'y'; - - EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArrayArgument<0>(&ch2, - &ch2 + 1)); - mock.VoidFromString(&ch); -} - -#if !GTEST_OS_WINDOWS_MOBILE - -// Tests the linkage of the SetErrnoAndReturn action. -TEST(LinkTest, TestSetErrnoAndReturn) { - Mock mock; - - int saved_errno = errno; - EXPECT_CALL(mock, IntFromString(_)).WillOnce(SetErrnoAndReturn(1, -1)); - mock.IntFromString(NULL); - errno = saved_errno; -} - -#endif // !GTEST_OS_WINDOWS_MOBILE - -// Tests the linkage of the Invoke(function) and Invoke(object, method) actions. -TEST(LinkTest, TestInvoke) { - Mock mock; - InvokeHelper test_invoke_helper; - - EXPECT_CALL(mock, VoidFromString(_)) - .WillOnce(Invoke(&InvokeHelper::StaticVoidFromString)) - .WillOnce(Invoke(&test_invoke_helper, &InvokeHelper::VoidFromString)); - mock.VoidFromString(NULL); - mock.VoidFromString(NULL); -} - -// Tests the linkage of the InvokeWithoutArgs action. -TEST(LinkTest, TestInvokeWithoutArgs) { - Mock mock; - InvokeHelper test_invoke_helper; - - EXPECT_CALL(mock, VoidFromString(_)) - .WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid)) - .WillOnce(InvokeWithoutArgs(&test_invoke_helper, - &InvokeHelper::VoidFromVoid)); - mock.VoidFromString(NULL); - mock.VoidFromString(NULL); -} - -// Tests the linkage of the InvokeArgument action. -TEST(LinkTest, TestInvokeArgument) { - Mock mock; - char ch = 'x'; - - EXPECT_CALL(mock, VoidFromFunc(_)).WillOnce(InvokeArgument<0>(&ch)); - mock.VoidFromFunc(InvokeHelper::StaticVoidFromString); -} - -// Tests the linkage of the WithArg action. -TEST(LinkTest, TestWithArg) { - Mock mock; - - EXPECT_CALL(mock, VoidFromString(_)) - .WillOnce(WithArg<0>(Invoke(&InvokeHelper::StaticVoidFromString))); - mock.VoidFromString(NULL); -} - -// Tests the linkage of the WithArgs action. -TEST(LinkTest, TestWithArgs) { - Mock mock; - - EXPECT_CALL(mock, VoidFromString(_)) - .WillOnce(WithArgs<0>(Invoke(&InvokeHelper::StaticVoidFromString))); - mock.VoidFromString(NULL); -} - -// Tests the linkage of the WithoutArgs action. -TEST(LinkTest, TestWithoutArgs) { - Mock mock; - - EXPECT_CALL(mock, VoidFromString(_)).WillOnce(WithoutArgs(Return())); - mock.VoidFromString(NULL); -} - -// Tests the linkage of the DoAll action. -TEST(LinkTest, TestDoAll) { - Mock mock; - char ch = 'x'; - - EXPECT_CALL(mock, VoidFromString(_)) - .WillOnce(DoAll(SetArgPointee<0>('y'), Return())); - mock.VoidFromString(&ch); -} - -// Tests the linkage of the DoDefault action. -TEST(LinkTest, TestDoDefault) { - Mock mock; - char ch = 'x'; - - ON_CALL(mock, VoidFromString(_)).WillByDefault(Return()); - EXPECT_CALL(mock, VoidFromString(_)).WillOnce(DoDefault()); - mock.VoidFromString(&ch); -} - -// Tests the linkage of the IgnoreResult action. -TEST(LinkTest, TestIgnoreResult) { - Mock mock; - - EXPECT_CALL(mock, VoidFromString(_)).WillOnce(IgnoreResult(Return(42))); - mock.VoidFromString(NULL); -} - -#if GTEST_HAS_EXCEPTIONS -// Tests the linkage of the Throw action. -TEST(LinkTest, TestThrow) { - Mock mock; - - EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Throw(42)); - EXPECT_THROW(mock.VoidFromString(NULL), int); -} -#endif // GTEST_HAS_EXCEPTIONS - -// The ACTION*() macros trigger warning C4100 (unreferenced formal -// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in -// the macro definition, as the warnings are generated when the macro -// is expanded and macro expansion cannot contain #pragma. Therefore -// we suppress them here. -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4100) -#endif - -// Tests the linkage of actions created using ACTION macro. -namespace { -ACTION(Return1) { return 1; } -} - -TEST(LinkTest, TestActionMacro) { - Mock mock; - - EXPECT_CALL(mock, IntFromString(_)).WillOnce(Return1()); - mock.IntFromString(NULL); -} - -// Tests the linkage of actions created using ACTION_P macro. -namespace { -ACTION_P(ReturnArgument, ret_value) { return ret_value; } -} - -TEST(LinkTest, TestActionPMacro) { - Mock mock; - - EXPECT_CALL(mock, IntFromString(_)).WillOnce(ReturnArgument(42)); - mock.IntFromString(NULL); -} - -// Tests the linkage of actions created using ACTION_P2 macro. -namespace { -ACTION_P2(ReturnEqualsEitherOf, first, second) { - return arg0 == first || arg0 == second; -} -} - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -TEST(LinkTest, TestActionP2Macro) { - Mock mock; - char ch = 'x'; - - EXPECT_CALL(mock, IntFromString(_)) - .WillOnce(ReturnEqualsEitherOf("one", "two")); - mock.IntFromString(&ch); -} - -// Tests the linkage of the "_" matcher. -TEST(LinkTest, TestMatcherAnything) { - Mock mock; - - ON_CALL(mock, VoidFromString(_)).WillByDefault(Return()); -} - -// Tests the linkage of the A matcher. -TEST(LinkTest, TestMatcherA) { - Mock mock; - - ON_CALL(mock, VoidFromString(A())).WillByDefault(Return()); -} - -// Tests the linkage of the Eq and the "bare value" matcher. -TEST(LinkTest, TestMatchersEq) { - Mock mock; - const char* p = "x"; - - ON_CALL(mock, VoidFromString(Eq(p))).WillByDefault(Return()); - ON_CALL(mock, VoidFromString(const_cast("y"))) - .WillByDefault(Return()); -} - -// Tests the linkage of the Lt, Gt, Le, Ge, and Ne matchers. -TEST(LinkTest, TestMatchersRelations) { - Mock mock; - - ON_CALL(mock, VoidFromFloat(Lt(1.0f))).WillByDefault(Return()); - ON_CALL(mock, VoidFromFloat(Gt(1.0f))).WillByDefault(Return()); - ON_CALL(mock, VoidFromFloat(Le(1.0f))).WillByDefault(Return()); - ON_CALL(mock, VoidFromFloat(Ge(1.0f))).WillByDefault(Return()); - ON_CALL(mock, VoidFromFloat(Ne(1.0f))).WillByDefault(Return()); -} - -// Tests the linkage of the NotNull matcher. -TEST(LinkTest, TestMatcherNotNull) { - Mock mock; - - ON_CALL(mock, VoidFromString(NotNull())).WillByDefault(Return()); -} - -// Tests the linkage of the IsNull matcher. -TEST(LinkTest, TestMatcherIsNull) { - Mock mock; - - ON_CALL(mock, VoidFromString(IsNull())).WillByDefault(Return()); -} - -// Tests the linkage of the Ref matcher. -TEST(LinkTest, TestMatcherRef) { - Mock mock; - int a = 0; - - ON_CALL(mock, VoidFromIntRef(Ref(a))).WillByDefault(Return()); -} - -// Tests the linkage of the TypedEq matcher. -TEST(LinkTest, TestMatcherTypedEq) { - Mock mock; - long a = 0; - - ON_CALL(mock, VoidFromIntRef(TypedEq(a))).WillByDefault(Return()); -} - -// Tests the linkage of the FloatEq, DoubleEq, NanSensitiveFloatEq and -// NanSensitiveDoubleEq matchers. -TEST(LinkTest, TestMatchersFloatingPoint) { - Mock mock; - float a = 0; - - ON_CALL(mock, VoidFromFloat(FloatEq(a))).WillByDefault(Return()); - ON_CALL(mock, VoidFromDouble(DoubleEq(a))).WillByDefault(Return()); - ON_CALL(mock, VoidFromFloat(NanSensitiveFloatEq(a))).WillByDefault(Return()); - ON_CALL(mock, VoidFromDouble(NanSensitiveDoubleEq(a))) - .WillByDefault(Return()); -} - -// Tests the linkage of the ContainsRegex matcher. -TEST(LinkTest, TestMatcherContainsRegex) { - Mock mock; - - ON_CALL(mock, VoidFromString(ContainsRegex(".*"))).WillByDefault(Return()); -} - -// Tests the linkage of the MatchesRegex matcher. -TEST(LinkTest, TestMatcherMatchesRegex) { - Mock mock; - - ON_CALL(mock, VoidFromString(MatchesRegex(".*"))).WillByDefault(Return()); -} - -// Tests the linkage of the StartsWith, EndsWith, and HasSubstr matchers. -TEST(LinkTest, TestMatchersSubstrings) { - Mock mock; - - ON_CALL(mock, VoidFromString(StartsWith("a"))).WillByDefault(Return()); - ON_CALL(mock, VoidFromString(EndsWith("c"))).WillByDefault(Return()); - ON_CALL(mock, VoidFromString(HasSubstr("b"))).WillByDefault(Return()); -} - -// Tests the linkage of the StrEq, StrNe, StrCaseEq, and StrCaseNe matchers. -TEST(LinkTest, TestMatchersStringEquality) { - Mock mock; - ON_CALL(mock, VoidFromString(StrEq("a"))).WillByDefault(Return()); - ON_CALL(mock, VoidFromString(StrNe("a"))).WillByDefault(Return()); - ON_CALL(mock, VoidFromString(StrCaseEq("a"))).WillByDefault(Return()); - ON_CALL(mock, VoidFromString(StrCaseNe("a"))).WillByDefault(Return()); -} - -// Tests the linkage of the ElementsAre matcher. -TEST(LinkTest, TestMatcherElementsAre) { - Mock mock; - - ON_CALL(mock, VoidFromVector(ElementsAre('a', _))).WillByDefault(Return()); -} - -// Tests the linkage of the ElementsAreArray matcher. -TEST(LinkTest, TestMatcherElementsAreArray) { - Mock mock; - char arr[] = { 'a', 'b' }; - - ON_CALL(mock, VoidFromVector(ElementsAreArray(arr))).WillByDefault(Return()); -} - -// Tests the linkage of the ContainerEq matcher. -TEST(LinkTest, TestMatcherContainerEq) { - Mock mock; - std::vector v; - - ON_CALL(mock, VoidFromVector(ContainerEq(v))).WillByDefault(Return()); -} - -// Tests the linkage of the Field matcher. -TEST(LinkTest, TestMatcherField) { - FieldHelper helper(0); - - Matcher m = Field(&FieldHelper::field_, Eq(0)); - EXPECT_TRUE(m.Matches(helper)); - - Matcher m2 = Field(&FieldHelper::field_, Eq(0)); - EXPECT_TRUE(m2.Matches(&helper)); -} - -// Tests the linkage of the Property matcher. -TEST(LinkTest, TestMatcherProperty) { - FieldHelper helper(0); - - Matcher m = Property(&FieldHelper::field, Eq(0)); - EXPECT_TRUE(m.Matches(helper)); - - Matcher m2 = Property(&FieldHelper::field, Eq(0)); - EXPECT_TRUE(m2.Matches(&helper)); -} - -// Tests the linkage of the ResultOf matcher. -TEST(LinkTest, TestMatcherResultOf) { - Matcher m = ResultOf(&InvokeHelper::StaticIntFromString, Eq(1)); - EXPECT_TRUE(m.Matches(NULL)); -} - -// Tests the linkage of the ResultOf matcher. -TEST(LinkTest, TestMatcherPointee) { - int n = 1; - - Matcher m = Pointee(Eq(1)); - EXPECT_TRUE(m.Matches(&n)); -} - -// Tests the linkage of the Truly matcher. -TEST(LinkTest, TestMatcherTruly) { - Matcher m = Truly(&InvokeHelper::StaticBoolFromString); - EXPECT_TRUE(m.Matches(NULL)); -} - -// Tests the linkage of the AllOf matcher. -TEST(LinkTest, TestMatcherAllOf) { - Matcher m = AllOf(_, Eq(1)); - EXPECT_TRUE(m.Matches(1)); -} - -// Tests the linkage of the AnyOf matcher. -TEST(LinkTest, TestMatcherAnyOf) { - Matcher m = AnyOf(_, Eq(1)); - EXPECT_TRUE(m.Matches(1)); -} - -// Tests the linkage of the Not matcher. -TEST(LinkTest, TestMatcherNot) { - Matcher m = Not(_); - EXPECT_FALSE(m.Matches(1)); -} - -// Tests the linkage of the MatcherCast() function. -TEST(LinkTest, TestMatcherCast) { - Matcher m = MatcherCast(_); - EXPECT_TRUE(m.Matches(NULL)); -} - -#endif // GMOCK_TEST_GMOCK_LINK_TEST_H_ http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a5b68bab/depends/googletest/googlemock/test/gmock_output_test.py ---------------------------------------------------------------------- diff --git a/depends/googletest/googlemock/test/gmock_output_test.py b/depends/googletest/googlemock/test/gmock_output_test.py deleted file mode 100755 index eced8a8..0000000 --- a/depends/googletest/googlemock/test/gmock_output_test.py +++ /dev/null @@ -1,180 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2008, Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -"""Tests the text output of Google C++ Mocking Framework. - -SYNOPSIS - gmock_output_test.py --build_dir=BUILD/DIR --gengolden - # where BUILD/DIR contains the built gmock_output_test_ file. - gmock_output_test.py --gengolden - gmock_output_test.py -""" - -__author__ = 'wan@google.com (Zhanyong Wan)' - -import os -import re -import sys - -import gmock_test_utils - - -# The flag for generating the golden file -GENGOLDEN_FLAG = '--gengolden' - -PROGRAM_PATH = gmock_test_utils.GetTestExecutablePath('gmock_output_test_') -COMMAND = [PROGRAM_PATH, '--gtest_stack_trace_depth=0', '--gtest_print_time=0'] -GOLDEN_NAME = 'gmock_output_test_golden.txt' -GOLDEN_PATH = os.path.join(gmock_test_utils.GetSourceDir(), GOLDEN_NAME) - - -def ToUnixLineEnding(s): - """Changes all Windows/Mac line endings in s to UNIX line endings.""" - - return s.replace('\r\n', '\n').replace('\r', '\n') - - -def RemoveReportHeaderAndFooter(output): - """Removes Google Test result report's header and footer from the output.""" - - output = re.sub(r'.*gtest_main.*\n', '', output) - output = re.sub(r'\[.*\d+ tests.*\n', '', output) - output = re.sub(r'\[.* test environment .*\n', '', output) - output = re.sub(r'\[=+\] \d+ tests .* ran.*', '', output) - output = re.sub(r'.* FAILED TESTS\n', '', output) - return output - - -def RemoveLocations(output): - """Removes all file location info from a Google Test program's output. - - Args: - output: the output of a Google Test program. - - Returns: - output with all file location info (in the form of - 'DIRECTORY/FILE_NAME:LINE_NUMBER: 'or - 'DIRECTORY\\FILE_NAME(LINE_NUMBER): ') replaced by - 'FILE:#: '. - """ - - return re.sub(r'.*[/\\](.+)(\:\d+|\(\d+\))\:', 'FILE:#:', output) - - -def NormalizeErrorMarker(output): - """Normalizes the error marker, which is different on Windows vs on Linux.""" - - return re.sub(r' error: ', ' Failure\n', output) - - -def RemoveMemoryAddresses(output): - """Removes memory addresses from the test output.""" - - return re.sub(r'@\w+', '@0x#', output) - - -def RemoveTestNamesOfLeakedMocks(output): - """Removes the test names of leaked mock objects from the test output.""" - - return re.sub(r'\(used in test .+\) ', '', output) - - -def GetLeakyTests(output): - """Returns a list of test names that leak mock objects.""" - - # findall() returns a list of all matches of the regex in output. - # For example, if '(used in test FooTest.Bar)' is in output, the - # list will contain 'FooTest.Bar'. - return re.findall(r'\(used in test (.+)\)', output) - - -def GetNormalizedOutputAndLeakyTests(output): - """Normalizes the output of gmock_output_test_. - - Args: - output: The test output. - - Returns: - A tuple (the normalized test output, the list of test names that have - leaked mocks). - """ - - output = ToUnixLineEnding(output) - output = RemoveReportHeaderAndFooter(output) - output = NormalizeErrorMarker(output) - output = RemoveLocations(output) - output = RemoveMemoryAddresses(output) - return (RemoveTestNamesOfLeakedMocks(output), GetLeakyTests(output)) - - -def GetShellCommandOutput(cmd): - """Runs a command in a sub-process, and returns its STDOUT in a string.""" - - return gmock_test_utils.Subprocess(cmd, capture_stderr=False).output - - -def GetNormalizedCommandOutputAndLeakyTests(cmd): - """Runs a command and returns its normalized output and a list of leaky tests. - - Args: - cmd: the shell command. - """ - - # Disables exception pop-ups on Windows. - os.environ['GTEST_CATCH_EXCEPTIONS'] = '1' - return GetNormalizedOutputAndLeakyTests(GetShellCommandOutput(cmd)) - - -class GMockOutputTest(gmock_test_utils.TestCase): - def testOutput(self): - (output, leaky_tests) = GetNormalizedCommandOutputAndLeakyTests(COMMAND) - golden_file = open(GOLDEN_PATH, 'rb') - golden = golden_file.read() - golden_file.close() - - # The normalized output should match the golden file. - self.assertEquals(golden, output) - - # The raw output should contain 2 leaked mock object errors for - # test GMockOutputTest.CatchesLeakedMocks. - self.assertEquals(['GMockOutputTest.CatchesLeakedMocks', - 'GMockOutputTest.CatchesLeakedMocks'], - leaky_tests) - - -if __name__ == '__main__': - if sys.argv[1:] == [GENGOLDEN_FLAG]: - (output, _) = GetNormalizedCommandOutputAndLeakyTests(COMMAND) - golden_file = open(GOLDEN_PATH, 'wb') - golden_file.write(output) - golden_file.close() - else: - gmock_test_utils.Main() http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a5b68bab/depends/googletest/googlemock/test/gmock_output_test_.cc ---------------------------------------------------------------------- diff --git a/depends/googletest/googlemock/test/gmock_output_test_.cc b/depends/googletest/googlemock/test/gmock_output_test_.cc deleted file mode 100644 index 44cba34..0000000 --- a/depends/googletest/googlemock/test/gmock_output_test_.cc +++ /dev/null @@ -1,291 +0,0 @@ -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Tests Google Mock's output in various scenarios. This ensures that -// Google Mock's messages are readable and useful. - -#include "gmock/gmock.h" - -#include -#include - -#include "gtest/gtest.h" - -using testing::_; -using testing::AnyNumber; -using testing::Ge; -using testing::InSequence; -using testing::NaggyMock; -using testing::Ref; -using testing::Return; -using testing::Sequence; - -class MockFoo { - public: - MockFoo() {} - - MOCK_METHOD3(Bar, char(const std::string& s, int i, double x)); - MOCK_METHOD2(Bar2, bool(int x, int y)); - MOCK_METHOD2(Bar3, void(int x, int y)); - - private: - GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo); -}; - -class GMockOutputTest : public testing::Test { - protected: - NaggyMock foo_; -}; - -TEST_F(GMockOutputTest, ExpectedCall) { - testing::GMOCK_FLAG(verbose) = "info"; - - EXPECT_CALL(foo_, Bar2(0, _)); - foo_.Bar2(0, 0); // Expected call - - testing::GMOCK_FLAG(verbose) = "warning"; -} - -TEST_F(GMockOutputTest, ExpectedCallToVoidFunction) { - testing::GMOCK_FLAG(verbose) = "info"; - - EXPECT_CALL(foo_, Bar3(0, _)); - foo_.Bar3(0, 0); // Expected call - - testing::GMOCK_FLAG(verbose) = "warning"; -} - -TEST_F(GMockOutputTest, ExplicitActionsRunOut) { - EXPECT_CALL(foo_, Bar2(_, _)) - .Times(2) - .WillOnce(Return(false)); - foo_.Bar2(2, 2); - foo_.Bar2(1, 1); // Explicit actions in EXPECT_CALL run out. -} - -TEST_F(GMockOutputTest, UnexpectedCall) { - EXPECT_CALL(foo_, Bar2(0, _)); - - foo_.Bar2(1, 0); // Unexpected call - foo_.Bar2(0, 0); // Expected call -} - -TEST_F(GMockOutputTest, UnexpectedCallToVoidFunction) { - EXPECT_CALL(foo_, Bar3(0, _)); - - foo_.Bar3(1, 0); // Unexpected call - foo_.Bar3(0, 0); // Expected call -} - -TEST_F(GMockOutputTest, ExcessiveCall) { - EXPECT_CALL(foo_, Bar2(0, _)); - - foo_.Bar2(0, 0); // Expected call - foo_.Bar2(0, 1); // Excessive call -} - -TEST_F(GMockOutputTest, ExcessiveCallToVoidFunction) { - EXPECT_CALL(foo_, Bar3(0, _)); - - foo_.Bar3(0, 0); // Expected call - foo_.Bar3(0, 1); // Excessive call -} - -TEST_F(GMockOutputTest, UninterestingCall) { - foo_.Bar2(0, 1); // Uninteresting call -} - -TEST_F(GMockOutputTest, UninterestingCallToVoidFunction) { - foo_.Bar3(0, 1); // Uninteresting call -} - -TEST_F(GMockOutputTest, RetiredExpectation) { - EXPECT_CALL(foo_, Bar2(_, _)) - .RetiresOnSaturation(); - EXPECT_CALL(foo_, Bar2(0, 0)); - - foo_.Bar2(1, 1); - foo_.Bar2(1, 1); // Matches a retired expectation - foo_.Bar2(0, 0); -} - -TEST_F(GMockOutputTest, UnsatisfiedPrerequisite) { - { - InSequence s; - EXPECT_CALL(foo_, Bar(_, 0, _)); - EXPECT_CALL(foo_, Bar2(0, 0)); - EXPECT_CALL(foo_, Bar2(1, _)); - } - - foo_.Bar2(1, 0); // Has one immediate unsatisfied pre-requisite - foo_.Bar("Hi", 0, 0); - foo_.Bar2(0, 0); - foo_.Bar2(1, 0); -} - -TEST_F(GMockOutputTest, UnsatisfiedPrerequisites) { - Sequence s1, s2; - - EXPECT_CALL(foo_, Bar(_, 0, _)) - .InSequence(s1); - EXPECT_CALL(foo_, Bar2(0, 0)) - .InSequence(s2); - EXPECT_CALL(foo_, Bar2(1, _)) - .InSequence(s1, s2); - - foo_.Bar2(1, 0); // Has two immediate unsatisfied pre-requisites - foo_.Bar("Hi", 0, 0); - foo_.Bar2(0, 0); - foo_.Bar2(1, 0); -} - -TEST_F(GMockOutputTest, UnsatisfiedWith) { - EXPECT_CALL(foo_, Bar2(_, _)).With(Ge()); -} - -TEST_F(GMockOutputTest, UnsatisfiedExpectation) { - EXPECT_CALL(foo_, Bar(_, _, _)); - EXPECT_CALL(foo_, Bar2(0, _)) - .Times(2); - - foo_.Bar2(0, 1); -} - -TEST_F(GMockOutputTest, MismatchArguments) { - const std::string s = "Hi"; - EXPECT_CALL(foo_, Bar(Ref(s), _, Ge(0))); - - foo_.Bar("Ho", 0, -0.1); // Mismatch arguments - foo_.Bar(s, 0, 0); -} - -TEST_F(GMockOutputTest, MismatchWith) { - EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1))) - .With(Ge()); - - foo_.Bar2(2, 3); // Mismatch With() - foo_.Bar2(2, 1); -} - -TEST_F(GMockOutputTest, MismatchArgumentsAndWith) { - EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1))) - .With(Ge()); - - foo_.Bar2(1, 3); // Mismatch arguments and mismatch With() - foo_.Bar2(2, 1); -} - -TEST_F(GMockOutputTest, UnexpectedCallWithDefaultAction) { - ON_CALL(foo_, Bar2(_, _)) - .WillByDefault(Return(true)); // Default action #1 - ON_CALL(foo_, Bar2(1, _)) - .WillByDefault(Return(false)); // Default action #2 - - EXPECT_CALL(foo_, Bar2(2, 2)); - foo_.Bar2(1, 0); // Unexpected call, takes default action #2. - foo_.Bar2(0, 0); // Unexpected call, takes default action #1. - foo_.Bar2(2, 2); // Expected call. -} - -TEST_F(GMockOutputTest, ExcessiveCallWithDefaultAction) { - ON_CALL(foo_, Bar2(_, _)) - .WillByDefault(Return(true)); // Default action #1 - ON_CALL(foo_, Bar2(1, _)) - .WillByDefault(Return(false)); // Default action #2 - - EXPECT_CALL(foo_, Bar2(2, 2)); - EXPECT_CALL(foo_, Bar2(1, 1)); - - foo_.Bar2(2, 2); // Expected call. - foo_.Bar2(2, 2); // Excessive call, takes default action #1. - foo_.Bar2(1, 1); // Expected call. - foo_.Bar2(1, 1); // Excessive call, takes default action #2. -} - -TEST_F(GMockOutputTest, UninterestingCallWithDefaultAction) { - ON_CALL(foo_, Bar2(_, _)) - .WillByDefault(Return(true)); // Default action #1 - ON_CALL(foo_, Bar2(1, _)) - .WillByDefault(Return(false)); // Default action #2 - - foo_.Bar2(2, 2); // Uninteresting call, takes default action #1. - foo_.Bar2(1, 1); // Uninteresting call, takes default action #2. -} - -TEST_F(GMockOutputTest, ExplicitActionsRunOutWithDefaultAction) { - ON_CALL(foo_, Bar2(_, _)) - .WillByDefault(Return(true)); // Default action #1 - - EXPECT_CALL(foo_, Bar2(_, _)) - .Times(2) - .WillOnce(Return(false)); - foo_.Bar2(2, 2); - foo_.Bar2(1, 1); // Explicit actions in EXPECT_CALL run out. -} - -TEST_F(GMockOutputTest, CatchesLeakedMocks) { - MockFoo* foo1 = new MockFoo; - MockFoo* foo2 = new MockFoo; - - // Invokes ON_CALL on foo1. - ON_CALL(*foo1, Bar(_, _, _)).WillByDefault(Return('a')); - - // Invokes EXPECT_CALL on foo2. - EXPECT_CALL(*foo2, Bar2(_, _)); - EXPECT_CALL(*foo2, Bar2(1, _)); - EXPECT_CALL(*foo2, Bar3(_, _)).Times(AnyNumber()); - foo2->Bar2(2, 1); - foo2->Bar2(1, 1); - - // Both foo1 and foo2 are deliberately leaked. -} - -void TestCatchesLeakedMocksInAdHocTests() { - MockFoo* foo = new MockFoo; - - // Invokes EXPECT_CALL on foo. - EXPECT_CALL(*foo, Bar2(_, _)); - foo->Bar2(2, 1); - - // foo is deliberately leaked. -} - -int main(int argc, char **argv) { - testing::InitGoogleMock(&argc, argv); - - // Ensures that the tests pass no matter what value of - // --gmock_catch_leaked_mocks and --gmock_verbose the user specifies. - testing::GMOCK_FLAG(catch_leaked_mocks) = true; - testing::GMOCK_FLAG(verbose) = "warning"; - - TestCatchesLeakedMocksInAdHocTests(); - return RUN_ALL_TESTS(); -} http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a5b68bab/depends/googletest/googlemock/test/gmock_output_test_golden.txt ---------------------------------------------------------------------- diff --git a/depends/googletest/googlemock/test/gmock_output_test_golden.txt b/depends/googletest/googlemock/test/gmock_output_test_golden.txt deleted file mode 100644 index 689d5ee..0000000 --- a/depends/googletest/googlemock/test/gmock_output_test_golden.txt +++ /dev/null @@ -1,310 +0,0 @@ -[ RUN ] GMockOutputTest.ExpectedCall - -FILE:#: EXPECT_CALL(foo_, Bar2(0, _)) invoked -Stack trace: - -FILE:#: Mock function call matches EXPECT_CALL(foo_, Bar2(0, _))... - Function call: Bar2(0, 0) - Returns: false -Stack trace: -[ OK ] GMockOutputTest.ExpectedCall -[ RUN ] GMockOutputTest.ExpectedCallToVoidFunction - -FILE:#: EXPECT_CALL(foo_, Bar3(0, _)) invoked -Stack trace: - -FILE:#: Mock function call matches EXPECT_CALL(foo_, Bar3(0, _))... - Function call: Bar3(0, 0) -Stack trace: -[ OK ] GMockOutputTest.ExpectedCallToVoidFunction -[ RUN ] GMockOutputTest.ExplicitActionsRunOut - -GMOCK WARNING: -FILE:#: Too few actions specified in EXPECT_CALL(foo_, Bar2(_, _))... -Expected to be called twice, but has only 1 WillOnce(). -GMOCK WARNING: -FILE:#: Actions ran out in EXPECT_CALL(foo_, Bar2(_, _))... -Called 2 times, but only 1 WillOnce() is specified - returning default value. -Stack trace: -[ OK ] GMockOutputTest.ExplicitActionsRunOut -[ RUN ] GMockOutputTest.UnexpectedCall -unknown file: Failure - -Unexpected mock function call - returning default value. - Function call: Bar2(1, 0) - Returns: false -Google Mock tried the following 1 expectation, but it didn't match: - -FILE:#: EXPECT_CALL(foo_, Bar2(0, _))... - Expected arg #0: is equal to 0 - Actual: 1 - Expected: to be called once - Actual: never called - unsatisfied and active -[ FAILED ] GMockOutputTest.UnexpectedCall -[ RUN ] GMockOutputTest.UnexpectedCallToVoidFunction -unknown file: Failure - -Unexpected mock function call - returning directly. - Function call: Bar3(1, 0) -Google Mock tried the following 1 expectation, but it didn't match: - -FILE:#: EXPECT_CALL(foo_, Bar3(0, _))... - Expected arg #0: is equal to 0 - Actual: 1 - Expected: to be called once - Actual: never called - unsatisfied and active -[ FAILED ] GMockOutputTest.UnexpectedCallToVoidFunction -[ RUN ] GMockOutputTest.ExcessiveCall -FILE:#: Failure -Mock function called more times than expected - returning default value. - Function call: Bar2(0, 1) - Returns: false - Expected: to be called once - Actual: called twice - over-saturated and active -[ FAILED ] GMockOutputTest.ExcessiveCall -[ RUN ] GMockOutputTest.ExcessiveCallToVoidFunction -FILE:#: Failure -Mock function called more times than expected - returning directly. - Function call: Bar3(0, 1) - Expected: to be called once - Actual: called twice - over-saturated and active -[ FAILED ] GMockOutputTest.ExcessiveCallToVoidFunction -[ RUN ] GMockOutputTest.UninterestingCall - -GMOCK WARNING: -Uninteresting mock function call - returning default value. - Function call: Bar2(0, 1) - Returns: false -NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md#knowing-when-to-expect for details. -[ OK ] GMockOutputTest.UninterestingCall -[ RUN ] GMockOutputTest.UninterestingCallToVoidFunction - -GMOCK WARNING: -Uninteresting mock function call - returning directly. - Function call: Bar3(0, 1) -NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md#knowing-when-to-expect for details. -[ OK ] GMockOutputTest.UninterestingCallToVoidFunction -[ RUN ] GMockOutputTest.RetiredExpectation -unknown file: Failure - -Unexpected mock function call - returning default value. - Function call: Bar2(1, 1) - Returns: false -Google Mock tried the following 2 expectations, but none matched: - -FILE:#: tried expectation #0: EXPECT_CALL(foo_, Bar2(_, _))... - Expected: the expectation is active - Actual: it is retired - Expected: to be called once - Actual: called once - saturated and retired -FILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(0, 0))... - Expected arg #0: is equal to 0 - Actual: 1 - Expected arg #1: is equal to 0 - Actual: 1 - Expected: to be called once - Actual: never called - unsatisfied and active -[ FAILED ] GMockOutputTest.RetiredExpectation -[ RUN ] GMockOutputTest.UnsatisfiedPrerequisite -unknown file: Failure - -Unexpected mock function call - returning default value. - Function call: Bar2(1, 0) - Returns: false -Google Mock tried the following 2 expectations, but none matched: - -FILE:#: tried expectation #0: EXPECT_CALL(foo_, Bar2(0, 0))... - Expected arg #0: is equal to 0 - Actual: 1 - Expected: to be called once - Actual: never called - unsatisfied and active -FILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(1, _))... - Expected: all pre-requisites are satisfied - Actual: the following immediate pre-requisites are not satisfied: -FILE:#: pre-requisite #0 - (end of pre-requisites) - Expected: to be called once - Actual: never called - unsatisfied and active -[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisite -[ RUN ] GMockOutputTest.UnsatisfiedPrerequisites -unknown file: Failure - -Unexpected mock function call - returning default value. - Function call: Bar2(1, 0) - Returns: false -Google Mock tried the following 2 expectations, but none matched: - -FILE:#: tried expectation #0: EXPECT_CALL(foo_, Bar2(0, 0))... - Expected arg #0: is equal to 0 - Actual: 1 - Expected: to be called once - Actual: never called - unsatisfied and active -FILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(1, _))... - Expected: all pre-requisites are satisfied - Actual: the following immediate pre-requisites are not satisfied: -FILE:#: pre-requisite #0 -FILE:#: pre-requisite #1 - (end of pre-requisites) - Expected: to be called once - Actual: never called - unsatisfied and active -[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisites -[ RUN ] GMockOutputTest.UnsatisfiedWith -FILE:#: Failure -Actual function call count doesn't match EXPECT_CALL(foo_, Bar2(_, _))... - Expected args: are a pair where the first >= the second - Expected: to be called once - Actual: never called - unsatisfied and active -[ FAILED ] GMockOutputTest.UnsatisfiedWith -[ RUN ] GMockOutputTest.UnsatisfiedExpectation -FILE:#: Failure -Actual function call count doesn't match EXPECT_CALL(foo_, Bar2(0, _))... - Expected: to be called twice - Actual: called once - unsatisfied and active -FILE:#: Failure -Actual function call count doesn't match EXPECT_CALL(foo_, Bar(_, _, _))... - Expected: to be called once - Actual: never called - unsatisfied and active -[ FAILED ] GMockOutputTest.UnsatisfiedExpectation -[ RUN ] GMockOutputTest.MismatchArguments -unknown file: Failure - -Unexpected mock function call - returning default value. - Function call: Bar(@0x# "Ho", 0, -0.1) - Returns: '\0' -Google Mock tried the following 1 expectation, but it didn't match: - -FILE:#: EXPECT_CALL(foo_, Bar(Ref(s), _, Ge(0)))... - Expected arg #0: references the variable @0x# "Hi" - Actual: "Ho", which is located @0x# - Expected arg #2: is >= 0 - Actual: -0.1 - Expected: to be called once - Actual: never called - unsatisfied and active -[ FAILED ] GMockOutputTest.MismatchArguments -[ RUN ] GMockOutputTest.MismatchWith -unknown file: Failure - -Unexpected mock function call - returning default value. - Function call: Bar2(2, 3) - Returns: false -Google Mock tried the following 1 expectation, but it didn't match: - -FILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))... - Expected args: are a pair where the first >= the second - Actual: don't match - Expected: to be called once - Actual: never called - unsatisfied and active -[ FAILED ] GMockOutputTest.MismatchWith -[ RUN ] GMockOutputTest.MismatchArgumentsAndWith -unknown file: Failure - -Unexpected mock function call - returning default value. - Function call: Bar2(1, 3) - Returns: false -Google Mock tried the following 1 expectation, but it didn't match: - -FILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))... - Expected arg #0: is >= 2 - Actual: 1 - Expected args: are a pair where the first >= the second - Actual: don't match - Expected: to be called once - Actual: never called - unsatisfied and active -[ FAILED ] GMockOutputTest.MismatchArgumentsAndWith -[ RUN ] GMockOutputTest.UnexpectedCallWithDefaultAction -unknown file: Failure - -Unexpected mock function call - taking default action specified at: -FILE:#: - Function call: Bar2(1, 0) - Returns: false -Google Mock tried the following 1 expectation, but it didn't match: - -FILE:#: EXPECT_CALL(foo_, Bar2(2, 2))... - Expected arg #0: is equal to 2 - Actual: 1 - Expected arg #1: is equal to 2 - Actual: 0 - Expected: to be called once - Actual: never called - unsatisfied and active -unknown file: Failure - -Unexpected mock function call - taking default action specified at: -FILE:#: - Function call: Bar2(0, 0) - Returns: true -Google Mock tried the following 1 expectation, but it didn't match: - -FILE:#: EXPECT_CALL(foo_, Bar2(2, 2))... - Expected arg #0: is equal to 2 - Actual: 0 - Expected arg #1: is equal to 2 - Actual: 0 - Expected: to be called once - Actual: never called - unsatisfied and active -[ FAILED ] GMockOutputTest.UnexpectedCallWithDefaultAction -[ RUN ] GMockOutputTest.ExcessiveCallWithDefaultAction -FILE:#: Failure -Mock function called more times than expected - taking default action specified at: -FILE:#: - Function call: Bar2(2, 2) - Returns: true - Expected: to be called once - Actual: called twice - over-saturated and active -FILE:#: Failure -Mock function called more times than expected - taking default action specified at: -FILE:#: - Function call: Bar2(1, 1) - Returns: false - Expected: to be called once - Actual: called twice - over-saturated and active -[ FAILED ] GMockOutputTest.ExcessiveCallWithDefaultAction -[ RUN ] GMockOutputTest.UninterestingCallWithDefaultAction - -GMOCK WARNING: -Uninteresting mock function call - taking default action specified at: -FILE:#: - Function call: Bar2(2, 2) - Returns: true -NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md#knowing-when-to-expect for details. - -GMOCK WARNING: -Uninteresting mock function call - taking default action specified at: -FILE:#: - Function call: Bar2(1, 1) - Returns: false -NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md#knowing-when-to-expect for details. -[ OK ] GMockOutputTest.UninterestingCallWithDefaultAction -[ RUN ] GMockOutputTest.ExplicitActionsRunOutWithDefaultAction - -GMOCK WARNING: -FILE:#: Too few actions specified in EXPECT_CALL(foo_, Bar2(_, _))... -Expected to be called twice, but has only 1 WillOnce(). -GMOCK WARNING: -FILE:#: Actions ran out in EXPECT_CALL(foo_, Bar2(_, _))... -Called 2 times, but only 1 WillOnce() is specified - taking default action specified at: -FILE:#: -Stack trace: -[ OK ] GMockOutputTest.ExplicitActionsRunOutWithDefaultAction -[ RUN ] GMockOutputTest.CatchesLeakedMocks -[ OK ] GMockOutputTest.CatchesLeakedMocks -[ FAILED ] GMockOutputTest.UnexpectedCall -[ FAILED ] GMockOutputTest.UnexpectedCallToVoidFunction -[ FAILED ] GMockOutputTest.ExcessiveCall -[ FAILED ] GMockOutputTest.ExcessiveCallToVoidFunction -[ FAILED ] GMockOutputTest.RetiredExpectation -[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisite -[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisites -[ FAILED ] GMockOutputTest.UnsatisfiedWith -[ FAILED ] GMockOutputTest.UnsatisfiedExpectation -[ FAILED ] GMockOutputTest.MismatchArguments -[ FAILED ] GMockOutputTest.MismatchWith -[ FAILED ] GMockOutputTest.MismatchArgumentsAndWith -[ FAILED ] GMockOutputTest.UnexpectedCallWithDefaultAction -[ FAILED ] GMockOutputTest.ExcessiveCallWithDefaultAction - - -FILE:#: ERROR: this mock object should be deleted but never is. Its address is @0x#. -FILE:#: ERROR: this mock object should be deleted but never is. Its address is @0x#. -FILE:#: ERROR: this mock object should be deleted but never is. Its address is @0x#. -ERROR: 3 leaked mock objects found at program exit. http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a5b68bab/depends/googletest/googlemock/test/gmock_stress_test.cc ---------------------------------------------------------------------- diff --git a/depends/googletest/googlemock/test/gmock_stress_test.cc b/depends/googletest/googlemock/test/gmock_stress_test.cc deleted file mode 100644 index 0e97aee..0000000 --- a/depends/googletest/googlemock/test/gmock_stress_test.cc +++ /dev/null @@ -1,322 +0,0 @@ -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Tests that Google Mock constructs can be used in a large number of -// threads concurrently. - -#include "gmock/gmock.h" -#include "gtest/gtest.h" - -namespace testing { -namespace { - -// From . -using ::testing::internal::ThreadWithParam; - -// The maximum number of test threads (not including helper threads) -// to create. -const int kMaxTestThreads = 50; - -// How many times to repeat a task in a test thread. -const int kRepeat = 50; - -class MockFoo { - public: - MOCK_METHOD1(Bar, int(int n)); // NOLINT - MOCK_METHOD2(Baz, char(const char* s1, const internal::string& s2)); // NOLINT -}; - -// Helper for waiting for the given thread to finish and then deleting it. -template -void JoinAndDelete(ThreadWithParam* t) { - t->Join(); - delete t; -} - -using internal::linked_ptr; - -// Helper classes for testing using linked_ptr concurrently. - -class Base { - public: - explicit Base(int a_x) : x_(a_x) {} - virtual ~Base() {} - int x() const { return x_; } - private: - int x_; -}; - -class Derived1 : public Base { - public: - Derived1(int a_x, int a_y) : Base(a_x), y_(a_y) {} - int y() const { return y_; } - private: - int y_; -}; - -class Derived2 : public Base { - public: - Derived2(int a_x, int a_z) : Base(a_x), z_(a_z) {} - int z() const { return z_; } - private: - int z_; -}; - -linked_ptr pointer1(new Derived1(1, 2)); -linked_ptr pointer2(new Derived2(3, 4)); - -struct Dummy {}; - -// Tests that we can copy from a linked_ptr and read it concurrently. -void TestConcurrentCopyAndReadLinkedPtr(Dummy /* dummy */) { - // Reads pointer1 and pointer2 while they are being copied from in - // another thread. - EXPECT_EQ(1, pointer1->x()); - EXPECT_EQ(2, pointer1->y()); - EXPECT_EQ(3, pointer2->x()); - EXPECT_EQ(4, pointer2->z()); - - // Copies from pointer1. - linked_ptr p1(pointer1); - EXPECT_EQ(1, p1->x()); - EXPECT_EQ(2, p1->y()); - - // Assigns from pointer2 where the LHS was empty. - linked_ptr p2; - p2 = pointer1; - EXPECT_EQ(1, p2->x()); - - // Assigns from pointer2 where the LHS was not empty. - p2 = pointer2; - EXPECT_EQ(3, p2->x()); -} - -const linked_ptr p0(new Derived1(1, 2)); - -// Tests that we can concurrently modify two linked_ptrs that point to -// the same object. -void TestConcurrentWriteToEqualLinkedPtr(Dummy /* dummy */) { - // p1 and p2 point to the same, shared thing. One thread resets p1. - // Another thread assigns to p2. This will cause the same - // underlying "ring" to be updated concurrently. - linked_ptr p1(p0); - linked_ptr p2(p0); - - EXPECT_EQ(1, p1->x()); - EXPECT_EQ(2, p1->y()); - - EXPECT_EQ(1, p2->x()); - EXPECT_EQ(2, p2->y()); - - p1.reset(); - p2 = p0; - - EXPECT_EQ(1, p2->x()); - EXPECT_EQ(2, p2->y()); -} - -// Tests that different mock objects can be used in their respective -// threads. This should generate no Google Test failure. -void TestConcurrentMockObjects(Dummy /* dummy */) { - // Creates a mock and does some typical operations on it. - MockFoo foo; - ON_CALL(foo, Bar(_)) - .WillByDefault(Return(1)); - ON_CALL(foo, Baz(_, _)) - .WillByDefault(Return('b')); - ON_CALL(foo, Baz(_, "you")) - .WillByDefault(Return('a')); - - EXPECT_CALL(foo, Bar(0)) - .Times(AtMost(3)); - EXPECT_CALL(foo, Baz(_, _)); - EXPECT_CALL(foo, Baz("hi", "you")) - .WillOnce(Return('z')) - .WillRepeatedly(DoDefault()); - - EXPECT_EQ(1, foo.Bar(0)); - EXPECT_EQ(1, foo.Bar(0)); - EXPECT_EQ('z', foo.Baz("hi", "you")); - EXPECT_EQ('a', foo.Baz("hi", "you")); - EXPECT_EQ('b', foo.Baz("hi", "me")); -} - -// Tests invoking methods of the same mock object in multiple threads. - -struct Helper1Param { - MockFoo* mock_foo; - int* count; -}; - -void Helper1(Helper1Param param) { - for (int i = 0; i < kRepeat; i++) { - const char ch = param.mock_foo->Baz("a", "b"); - if (ch == 'a') { - // It was an expected call. - (*param.count)++; - } else { - // It was an excessive call. - EXPECT_EQ('\0', ch); - } - - // An unexpected call. - EXPECT_EQ('\0', param.mock_foo->Baz("x", "y")) << "Expected failure."; - - // An uninteresting call. - EXPECT_EQ(1, param.mock_foo->Bar(5)); - } -} - -// This should generate 3*kRepeat + 1 failures in total. -void TestConcurrentCallsOnSameObject(Dummy /* dummy */) { - MockFoo foo; - - ON_CALL(foo, Bar(_)) - .WillByDefault(Return(1)); - EXPECT_CALL(foo, Baz(_, "b")) - .Times(kRepeat) - .WillRepeatedly(Return('a')); - EXPECT_CALL(foo, Baz(_, "c")); // Expected to be unsatisfied. - - // This chunk of code should generate kRepeat failures about - // excessive calls, and 2*kRepeat failures about unexpected calls. - int count1 = 0; - const Helper1Param param = { &foo, &count1 }; - ThreadWithParam* const t = - new ThreadWithParam(Helper1, param, NULL); - - int count2 = 0; - const Helper1Param param2 = { &foo, &count2 }; - Helper1(param2); - JoinAndDelete(t); - - EXPECT_EQ(kRepeat, count1 + count2); - - // foo's destructor should generate one failure about unsatisfied - // expectation. -} - -// Tests using the same mock object in multiple threads when the -// expectations are partially ordered. - -void Helper2(MockFoo* foo) { - for (int i = 0; i < kRepeat; i++) { - foo->Bar(2); - foo->Bar(3); - } -} - -// This should generate no Google Test failures. -void TestPartiallyOrderedExpectationsWithThreads(Dummy /* dummy */) { - MockFoo foo; - Sequence s1, s2; - - { - InSequence dummy; - EXPECT_CALL(foo, Bar(0)); - EXPECT_CALL(foo, Bar(1)) - .InSequence(s1, s2); - } - - EXPECT_CALL(foo, Bar(2)) - .Times(2*kRepeat) - .InSequence(s1) - .RetiresOnSaturation(); - EXPECT_CALL(foo, Bar(3)) - .Times(2*kRepeat) - .InSequence(s2); - - { - InSequence dummy; - EXPECT_CALL(foo, Bar(2)) - .InSequence(s1, s2); - EXPECT_CALL(foo, Bar(4)); - } - - foo.Bar(0); - foo.Bar(1); - - ThreadWithParam* const t = - new ThreadWithParam(Helper2, &foo, NULL); - Helper2(&foo); - JoinAndDelete(t); - - foo.Bar(2); - foo.Bar(4); -} - -// Tests using Google Mock constructs in many threads concurrently. -TEST(StressTest, CanUseGMockWithThreads) { - void (*test_routines[])(Dummy dummy) = { - &TestConcurrentCopyAndReadLinkedPtr, - &TestConcurrentWriteToEqualLinkedPtr, - &TestConcurrentMockObjects, - &TestConcurrentCallsOnSameObject, - &TestPartiallyOrderedExpectationsWithThreads, - }; - - const int kRoutines = sizeof(test_routines)/sizeof(test_routines[0]); - const int kCopiesOfEachRoutine = kMaxTestThreads / kRoutines; - const int kTestThreads = kCopiesOfEachRoutine * kRoutines; - ThreadWithParam* threads[kTestThreads] = {}; - for (int i = 0; i < kTestThreads; i++) { - // Creates a thread to run the test function. - threads[i] = - new ThreadWithParam(test_routines[i % kRoutines], Dummy(), NULL); - GTEST_LOG_(INFO) << "Thread #" << i << " running . . ."; - } - - // At this point, we have many threads running. - for (int i = 0; i < kTestThreads; i++) { - JoinAndDelete(threads[i]); - } - - // Ensures that the correct number of failures have been reported. - const TestInfo* const info = UnitTest::GetInstance()->current_test_info(); - const TestResult& result = *info->result(); - const int kExpectedFailures = (3*kRepeat + 1)*kCopiesOfEachRoutine; - GTEST_CHECK_(kExpectedFailures == result.total_part_count()) - << "Expected " << kExpectedFailures << " failures, but got " - << result.total_part_count(); -} - -} // namespace -} // namespace testing - -int main(int argc, char **argv) { - testing::InitGoogleMock(&argc, argv); - - const int exit_code = RUN_ALL_TESTS(); // Expected to fail. - GTEST_CHECK_(exit_code != 0) << "RUN_ALL_TESTS() did not fail as expected"; - - printf("\nPASS\n"); - return 0; -} http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a5b68bab/depends/googletest/googlemock/test/gmock_test.cc ---------------------------------------------------------------------- diff --git a/depends/googletest/googlemock/test/gmock_test.cc b/depends/googletest/googlemock/test/gmock_test.cc deleted file mode 100644 index d8d0c57..0000000 --- a/depends/googletest/googlemock/test/gmock_test.cc +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) - -// Google Mock - a framework for writing C++ mock classes. -// -// This file tests code in gmock.cc. - -#include "gmock/gmock.h" - -#include -#include "gtest/gtest.h" - -#if !defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) - -using testing::GMOCK_FLAG(verbose); -using testing::InitGoogleMock; - -// Verifies that calling InitGoogleMock() on argv results in new_argv, -// and the gmock_verbose flag's value is set to expected_gmock_verbose. -template -void TestInitGoogleMock(const Char* (&argv)[M], const Char* (&new_argv)[N], - const ::std::string& expected_gmock_verbose) { - const ::std::string old_verbose = GMOCK_FLAG(verbose); - - int argc = M; - InitGoogleMock(&argc, const_cast(argv)); - ASSERT_EQ(N, argc) << "The new argv has wrong number of elements."; - - for (int i = 0; i < N; i++) { - EXPECT_STREQ(new_argv[i], argv[i]); - } - - EXPECT_EQ(expected_gmock_verbose, GMOCK_FLAG(verbose).c_str()); - GMOCK_FLAG(verbose) = old_verbose; // Restores the gmock_verbose flag. -} - -TEST(InitGoogleMockTest, ParsesInvalidCommandLine) { - const char* argv[] = { - NULL - }; - - const char* new_argv[] = { - NULL - }; - - TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose)); -} - -TEST(InitGoogleMockTest, ParsesEmptyCommandLine) { - const char* argv[] = { - "foo.exe", - NULL - }; - - const char* new_argv[] = { - "foo.exe", - NULL - }; - - TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose)); -} - -TEST(InitGoogleMockTest, ParsesSingleFlag) { - const char* argv[] = { - "foo.exe", - "--gmock_verbose=info", - NULL - }; - - const char* new_argv[] = { - "foo.exe", - NULL - }; - - TestInitGoogleMock(argv, new_argv, "info"); -} - -TEST(InitGoogleMockTest, ParsesUnrecognizedFlag) { - const char* argv[] = { - "foo.exe", - "--non_gmock_flag=blah", - NULL - }; - - const char* new_argv[] = { - "foo.exe", - "--non_gmock_flag=blah", - NULL - }; - - TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose)); -} - -TEST(InitGoogleMockTest, ParsesGoogleMockFlagAndUnrecognizedFlag) { - const char* argv[] = { - "foo.exe", - "--non_gmock_flag=blah", - "--gmock_verbose=error", - NULL - }; - - const char* new_argv[] = { - "foo.exe", - "--non_gmock_flag=blah", - NULL - }; - - TestInitGoogleMock(argv, new_argv, "error"); -} - -TEST(WideInitGoogleMockTest, ParsesInvalidCommandLine) { - const wchar_t* argv[] = { - NULL - }; - - const wchar_t* new_argv[] = { - NULL - }; - - TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose)); -} - -TEST(WideInitGoogleMockTest, ParsesEmptyCommandLine) { - const wchar_t* argv[] = { - L"foo.exe", - NULL - }; - - const wchar_t* new_argv[] = { - L"foo.exe", - NULL - }; - - TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose)); -} - -TEST(WideInitGoogleMockTest, ParsesSingleFlag) { - const wchar_t* argv[] = { - L"foo.exe", - L"--gmock_verbose=info", - NULL - }; - - const wchar_t* new_argv[] = { - L"foo.exe", - NULL - }; - - TestInitGoogleMock(argv, new_argv, "info"); -} - -TEST(WideInitGoogleMockTest, ParsesUnrecognizedFlag) { - const wchar_t* argv[] = { - L"foo.exe", - L"--non_gmock_flag=blah", - NULL - }; - - const wchar_t* new_argv[] = { - L"foo.exe", - L"--non_gmock_flag=blah", - NULL - }; - - TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose)); -} - -TEST(WideInitGoogleMockTest, ParsesGoogleMockFlagAndUnrecognizedFlag) { - const wchar_t* argv[] = { - L"foo.exe", - L"--non_gmock_flag=blah", - L"--gmock_verbose=error", - NULL - }; - - const wchar_t* new_argv[] = { - L"foo.exe", - L"--non_gmock_flag=blah", - NULL - }; - - TestInitGoogleMock(argv, new_argv, "error"); -} - -#endif // !defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) - -// Makes sure Google Mock flags can be accessed in code. -TEST(FlagTest, IsAccessibleInCode) { - bool dummy = testing::GMOCK_FLAG(catch_leaked_mocks) && - testing::GMOCK_FLAG(verbose) == ""; - (void)dummy; // Avoids the "unused local variable" warning. -} http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a5b68bab/depends/googletest/googlemock/test/gmock_test_utils.py ---------------------------------------------------------------------- diff --git a/depends/googletest/googlemock/test/gmock_test_utils.py b/depends/googletest/googlemock/test/gmock_test_utils.py deleted file mode 100755 index 20e3d3d..0000000 --- a/depends/googletest/googlemock/test/gmock_test_utils.py +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006, Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -"""Unit test utilities for Google C++ Mocking Framework.""" - -__author__ = 'wan@google.com (Zhanyong Wan)' - -import os -import sys - - -# Determines path to gtest_test_utils and imports it. -SCRIPT_DIR = os.path.dirname(__file__) or '.' - -# isdir resolves symbolic links. -gtest_tests_util_dir = os.path.join(SCRIPT_DIR, '../gtest/test') -if os.path.isdir(gtest_tests_util_dir): - GTEST_TESTS_UTIL_DIR = gtest_tests_util_dir -else: - GTEST_TESTS_UTIL_DIR = os.path.join(SCRIPT_DIR, '../../gtest/test') - -sys.path.append(GTEST_TESTS_UTIL_DIR) -import gtest_test_utils # pylint: disable-msg=C6204 - - -def GetSourceDir(): - """Returns the absolute path of the directory where the .py files are.""" - - return gtest_test_utils.GetSourceDir() - - -def GetTestExecutablePath(executable_name): - """Returns the absolute path of the test binary given its name. - - The function will print a message and abort the program if the resulting file - doesn't exist. - - Args: - executable_name: name of the test binary that the test script runs. - - Returns: - The absolute path of the test binary. - """ - - return gtest_test_utils.GetTestExecutablePath(executable_name) - - -def GetExitStatus(exit_code): - """Returns the argument to exit(), or -1 if exit() wasn't called. - - Args: - exit_code: the result value of os.system(command). - """ - - if os.name == 'nt': - # On Windows, os.WEXITSTATUS() doesn't work and os.system() returns - # the argument to exit() directly. - return exit_code - else: - # On Unix, os.WEXITSTATUS() must be used to extract the exit status - # from the result of os.system(). - if os.WIFEXITED(exit_code): - return os.WEXITSTATUS(exit_code) - else: - return -1 - - -# Suppresses the "Invalid const name" lint complaint -# pylint: disable-msg=C6409 - -# Exposes utilities from gtest_test_utils. -Subprocess = gtest_test_utils.Subprocess -TestCase = gtest_test_utils.TestCase -environ = gtest_test_utils.environ -SetEnvVar = gtest_test_utils.SetEnvVar -PREMATURE_EXIT_FILE_ENV_VAR = gtest_test_utils.PREMATURE_EXIT_FILE_ENV_VAR - -# pylint: enable-msg=C6409 - - -def Main(): - """Runs the unit test.""" - - gtest_test_utils.Main() http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a5b68bab/depends/googletest/googletest/.gitignore ---------------------------------------------------------------------- diff --git a/depends/googletest/googletest/.gitignore b/depends/googletest/googletest/.gitignore deleted file mode 100644 index 4b7be4b..0000000 --- a/depends/googletest/googletest/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# python -*.pyc http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a5b68bab/depends/googletest/googletest/CHANGES ---------------------------------------------------------------------- diff --git a/depends/googletest/googletest/CHANGES b/depends/googletest/googletest/CHANGES deleted file mode 100644 index 0552132..0000000 --- a/depends/googletest/googletest/CHANGES +++ /dev/null @@ -1,157 +0,0 @@ -Changes for 1.7.0: - -* New feature: death tests are supported on OpenBSD and in iOS - simulator now. -* New feature: Google Test now implements a protocol to allow - a test runner to detect that a test program has exited - prematurely and report it as a failure (before it would be - falsely reported as a success if the exit code is 0). -* New feature: Test::RecordProperty() can now be used outside of the - lifespan of a test method, in which case it will be attributed to - the current test case or the test program in the XML report. -* New feature (potentially breaking): --gtest_list_tests now prints - the type parameters and value parameters for each test. -* Improvement: char pointers and char arrays are now escaped properly - in failure messages. -* Improvement: failure summary in XML reports now includes file and - line information. -* Improvement: the XML element now has a timestamp attribute. -* Improvement: When --gtest_filter is specified, XML report now doesn't - contain information about tests that are filtered out. -* Fixed the bug where long --gtest_filter flag values are truncated in - death tests. -* Potentially breaking change: RUN_ALL_TESTS() is now implemented as a - function instead of a macro in order to work better with Clang. -* Compatibility fixes with C++ 11 and various platforms. -* Bug/warning fixes. - -Changes for 1.6.0: - -* New feature: ADD_FAILURE_AT() for reporting a test failure at the - given source location -- useful for writing testing utilities. -* New feature: the universal value printer is moved from Google Mock - to Google Test. -* New feature: type parameters and value parameters are reported in - the XML report now. -* A gtest_disable_pthreads CMake option. -* Colored output works in GNU Screen sessions now. -* Parameters of value-parameterized tests are now printed in the - textual output. -* Failures from ad hoc test assertions run before RUN_ALL_TESTS() are - now correctly reported. -* Arguments of ASSERT_XY and EXPECT_XY no longer need to support << to - ostream. -* More complete handling of exceptions. -* GTEST_ASSERT_XY can be used instead of ASSERT_XY in case the latter - name is already used by another library. -* --gtest_catch_exceptions is now true by default, allowing a test - program to continue after an exception is thrown. -* Value-parameterized test fixtures can now derive from Test and - WithParamInterface separately, easing conversion of legacy tests. -* Death test messages are clearly marked to make them more - distinguishable from other messages. -* Compatibility fixes for Android, Google Native Client, MinGW, HP UX, - PowerPC, Lucid autotools, libCStd, Sun C++, Borland C++ Builder (Code Gear), - IBM XL C++ (Visual Age C++), and C++0x. -* Bug fixes and implementation clean-ups. -* Potentially incompatible changes: disables the harmful 'make install' - command in autotools. - -Changes for 1.5.0: - - * New feature: assertions can be safely called in multiple threads - where the pthreads library is available. - * New feature: predicates used inside EXPECT_TRUE() and friends - can now generate custom failure messages. - * New feature: Google Test can now be compiled as a DLL. - * New feature: fused source files are included. - * New feature: prints help when encountering unrecognized Google Test flags. - * Experimental feature: CMake build script (requires CMake 2.6.4+). - * Experimental feature: the Pump script for meta programming. - * double values streamed to an assertion are printed with enough precision - to differentiate any two different values. - * Google Test now works on Solaris and AIX. - * Build and test script improvements. - * Bug fixes and implementation clean-ups. - - Potentially breaking changes: - - * Stopped supporting VC++ 7.1 with exceptions disabled. - * Dropped support for 'make install'. - -Changes for 1.4.0: - - * New feature: the event listener API - * New feature: test shuffling - * New feature: the XML report format is closer to junitreport and can - be parsed by Hudson now. - * New feature: when a test runs under Visual Studio, its failures are - integrated in the IDE. - * New feature: /MD(d) versions of VC++ projects. - * New feature: elapsed time for the tests is printed by default. - * New feature: comes with a TR1 tuple implementation such that Boost - is no longer needed for Combine(). - * New feature: EXPECT_DEATH_IF_SUPPORTED macro and friends. - * New feature: the Xcode project can now produce static gtest - libraries in addition to a framework. - * Compatibility fixes for Solaris, Cygwin, minGW, Windows Mobile, - Symbian, gcc, and C++Builder. - * Bug fixes and implementation clean-ups. - -Changes for 1.3.0: - - * New feature: death tests on Windows, Cygwin, and Mac. - * New feature: ability to use Google Test assertions in other testing - frameworks. - * New feature: ability to run disabled test via - --gtest_also_run_disabled_tests. - * New feature: the --help flag for printing the usage. - * New feature: access to Google Test flag values in user code. - * New feature: a script that packs Google Test into one .h and one - .cc file for easy deployment. - * New feature: support for distributing test functions to multiple - machines (requires support from the test runner). - * Bug fixes and implementation clean-ups. - -Changes for 1.2.1: - - * Compatibility fixes for Linux IA-64 and IBM z/OS. - * Added support for using Boost and other TR1 implementations. - * Changes to the build scripts to support upcoming release of Google C++ - Mocking Framework. - * Added Makefile to the distribution package. - * Improved build instructions in README. - -Changes for 1.2.0: - - * New feature: value-parameterized tests. - * New feature: the ASSERT/EXPECT_(NON)FATAL_FAILURE(_ON_ALL_THREADS) - macros. - * Changed the XML report format to match JUnit/Ant's. - * Added tests to the Xcode project. - * Added scons/SConscript for building with SCons. - * Added src/gtest-all.cc for building Google Test from a single file. - * Fixed compatibility with Solaris and z/OS. - * Enabled running Python tests on systems with python 2.3 installed, - e.g. Mac OS X 10.4. - * Bug fixes. - -Changes for 1.1.0: - - * New feature: type-parameterized tests. - * New feature: exception assertions. - * New feature: printing elapsed time of tests. - * Improved the robustness of death tests. - * Added an Xcode project and samples. - * Adjusted the output format on Windows to be understandable by Visual Studio. - * Minor bug fixes. - -Changes for 1.0.1: - - * Added project files for Visual Studio 7.1. - * Fixed issues with compiling on Mac OS X. - * Fixed issues with compiling on Cygwin. - -Changes for 1.0.0: - - * Initial Open Source release of Google Test