Supports building gtest as a DLL (by Vlad Losev).
This commit is contained in:
parent
542b41e5d0
commit
83589cca34
@ -54,10 +54,10 @@ endif()
|
||||
#
|
||||
# Defines the gtest & gtest_main libraries. User tests should link
|
||||
# with one of them.
|
||||
|
||||
function(cxx_library name cxx_flags)
|
||||
function(cxx_library_with_type name type cxx_flags)
|
||||
# type can be either STATIC or SHARED to denote a static or shared library.
|
||||
# ARGN refers to additional arguments after 'cxx_flags'.
|
||||
add_library(${name} STATIC ${ARGN})
|
||||
add_library(${name} ${type} ${ARGN})
|
||||
set_target_properties(${name}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${cxx_flags}")
|
||||
@ -66,8 +66,22 @@ function(cxx_library name cxx_flags)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
cxx_library(gtest "${cxx_default}" src/gtest-all.cc)
|
||||
cxx_library(gtest_main "${cxx_default}" src/gtest_main.cc)
|
||||
function(cxx_static_library name cxx_flags)
|
||||
cxx_library_with_type(${name} STATIC "${cxx_flags}" ${ARGN})
|
||||
endfunction()
|
||||
|
||||
function(cxx_shared_library name cxx_flags)
|
||||
cxx_library_with_type(${name} SHARED "${cxx_flags}" ${ARGN})
|
||||
endfunction()
|
||||
|
||||
function(cxx_library name cxx_flags)
|
||||
# TODO(vladl@google.com): Make static/shared a user option.
|
||||
cxx_static_library(${name} "${cxx_flags}" ${ARGN})
|
||||
endfunction()
|
||||
|
||||
# Static versions of Google Test libraries.
|
||||
cxx_static_library(gtest "${cxx_default}" src/gtest-all.cc)
|
||||
cxx_static_library(gtest_main "${cxx_default}" src/gtest_main.cc)
|
||||
target_link_libraries(gtest_main gtest)
|
||||
|
||||
########################################################################
|
||||
@ -85,16 +99,22 @@ option(build_gtest_samples "Build gtest's sample programs." OFF)
|
||||
# creates a named target that depends on the given lib and is built
|
||||
# from the given source files. dir/name.cc is implicitly included in
|
||||
# the source file list.
|
||||
function(cxx_executable name dir lib)
|
||||
function(cxx_executable_with_flags name dir cxx_flags lib)
|
||||
add_executable(${name}
|
||||
${dir}/${name}.cc
|
||||
${ARGN})
|
||||
set_target_properties(${name}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${cxx_default}")
|
||||
if (cxx_flags)
|
||||
set_target_properties(${name}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${cxx_flags}")
|
||||
endif()
|
||||
target_link_libraries(${name} ${lib})
|
||||
endfunction()
|
||||
|
||||
function(cxx_executable name dir lib)
|
||||
cxx_executable_with_flags(${name} ${dir} "${cxx_default}" ${lib} ${ARGN})
|
||||
endfunction()
|
||||
|
||||
if (build_gtest_samples)
|
||||
cxx_executable(sample1_unittest samples gtest_main samples/sample1.cc)
|
||||
cxx_executable(sample2_unittest samples gtest_main samples/sample2.cc)
|
||||
@ -207,6 +227,25 @@ if (build_all_gtest_tests)
|
||||
cxx_test_with_flags(gtest_no_rtti_unittest "${cxx_no_rtti}"
|
||||
gtest_main_no_rtti test/gtest_unittest.cc)
|
||||
|
||||
set(cxx_use_shared_gtest "${cxx_default} -DGTEST_LINKED_AS_SHARED_LIBRARY=1")
|
||||
set(cxx_build_shared_gtest "${cxx_default} -DGTEST_CREATE_SHARED_LIBRARY=1")
|
||||
if (MSVC)
|
||||
# Disables the "class 'X' needs to have dll-interface to be used
|
||||
# by clients of class 'Y'" warning. This particularly concerns generic
|
||||
# classes like vector that MS doesn't mark as exported.
|
||||
set(cxx_use_shared_gtest "${cxx_use_shared_gtest} -wd4251")
|
||||
set(cxx_build_shared_gtest "${cxx_build_shared_gtest} -wd4251")
|
||||
endif()
|
||||
|
||||
cxx_shared_library(gtest_dll "${cxx_build_shared_gtest}"
|
||||
src/gtest-all.cc)
|
||||
|
||||
# TODO(vladl): This and the next tests may not run in the hermetic
|
||||
# environment on Windows. Re-evaluate and possibly make them
|
||||
# platform-conditional after implementing hermetic builds.
|
||||
cxx_test_with_flags(gtest_dll_test_ "${cxx_use_shared_gtest}"
|
||||
gtest_dll test/gtest_dll_test_.cc)
|
||||
|
||||
if (NOT(MSVC AND (MSVC_VERSION EQUAL 1600)))
|
||||
# The C++ Standard specifies tuple_element<int, class>.
|
||||
# Yet MSVC 10's <utility> declares tuple_element<size_t, class>.
|
||||
|
@ -176,7 +176,7 @@ GTEST_DECLARE_string_(death_test_style);
|
||||
// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
|
||||
|
||||
// Tests that an exit code describes a normal exit with a given exit code.
|
||||
class ExitedWithCode {
|
||||
class GTEST_API_ ExitedWithCode {
|
||||
public:
|
||||
explicit ExitedWithCode(int exit_code);
|
||||
bool operator()(int exit_status) const;
|
||||
@ -190,7 +190,7 @@ class ExitedWithCode {
|
||||
#if !GTEST_OS_WINDOWS
|
||||
// Tests that an exit code describes an exit due to termination by a
|
||||
// given signal.
|
||||
class KilledBySignal {
|
||||
class GTEST_API_ KilledBySignal {
|
||||
public:
|
||||
explicit KilledBySignal(int signum);
|
||||
bool operator()(int exit_status) const;
|
||||
|
@ -79,7 +79,7 @@ namespace testing {
|
||||
// latter (it causes an access violation if you do). The Message
|
||||
// class hides this difference by treating a NULL char pointer as
|
||||
// "(null)".
|
||||
class Message {
|
||||
class GTEST_API_ Message {
|
||||
private:
|
||||
// The type of basic IO manipulators (endl, ends, and flush) for
|
||||
// narrow streams.
|
||||
|
@ -48,7 +48,7 @@ namespace testing {
|
||||
// generated in the same thread that created this object or it can intercept
|
||||
// all generated failures. The scope of this mock object can be controlled with
|
||||
// the second argument to the two arguments constructor.
|
||||
class ScopedFakeTestPartResultReporter
|
||||
class GTEST_API_ ScopedFakeTestPartResultReporter
|
||||
: public TestPartResultReporterInterface {
|
||||
public:
|
||||
// The two possible mocking modes of this object.
|
||||
@ -93,7 +93,7 @@ namespace internal {
|
||||
// TestPartResultArray contains exactly one failure that has the given
|
||||
// type and contains the given substring. If that's not the case, a
|
||||
// non-fatal failure will be generated.
|
||||
class SingleFailureChecker {
|
||||
class GTEST_API_ SingleFailureChecker {
|
||||
public:
|
||||
// The constructor remembers the arguments.
|
||||
SingleFailureChecker(const TestPartResultArray* results,
|
||||
|
@ -44,7 +44,7 @@ namespace testing {
|
||||
// assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).
|
||||
//
|
||||
// Don't inherit from TestPartResult as its destructor is not virtual.
|
||||
class TestPartResult {
|
||||
class GTEST_API_ TestPartResult {
|
||||
public:
|
||||
// The possible outcomes of a test part (i.e. an assertion or an
|
||||
// explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
|
||||
@ -120,7 +120,7 @@ std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
|
||||
//
|
||||
// Don't inherit from TestPartResultArray as its destructor is not
|
||||
// virtual.
|
||||
class TestPartResultArray {
|
||||
class GTEST_API_ TestPartResultArray {
|
||||
public:
|
||||
TestPartResultArray() {}
|
||||
|
||||
@ -155,7 +155,8 @@ namespace internal {
|
||||
// reported, it only delegates the reporting to the former result reporter.
|
||||
// The original result reporter is restored in the destructor.
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
class HasNewFatalFailureHelper : public TestPartResultReporterInterface {
|
||||
class GTEST_API_ HasNewFatalFailureHelper
|
||||
: public TestPartResultReporterInterface {
|
||||
public:
|
||||
HasNewFatalFailureHelper();
|
||||
virtual ~HasNewFatalFailureHelper();
|
||||
|
@ -251,7 +251,7 @@ String StreamableToString(const T& streamable) {
|
||||
// Expected: Foo() is even
|
||||
// Actual: it's 5
|
||||
//
|
||||
class AssertionResult {
|
||||
class GTEST_API_ AssertionResult {
|
||||
public:
|
||||
// Copy constructor.
|
||||
// Used in EXPECT_TRUE/FALSE(assertion_result).
|
||||
@ -306,14 +306,14 @@ AssertionResult& AssertionResult::operator<<(const T& value) {
|
||||
}
|
||||
|
||||
// Makes a successful assertion result.
|
||||
AssertionResult AssertionSuccess();
|
||||
GTEST_API_ AssertionResult AssertionSuccess();
|
||||
|
||||
// Makes a failed assertion result.
|
||||
AssertionResult AssertionFailure();
|
||||
GTEST_API_ AssertionResult AssertionFailure();
|
||||
|
||||
// Makes a failed assertion result with the given failure message.
|
||||
// Deprecated; use AssertionFailure() << msg.
|
||||
AssertionResult AssertionFailure(const Message& msg);
|
||||
GTEST_API_ AssertionResult AssertionFailure(const Message& msg);
|
||||
|
||||
// The abstract class that all tests inherit from.
|
||||
//
|
||||
@ -338,7 +338,7 @@ AssertionResult AssertionFailure(const Message& msg);
|
||||
// TEST_F(FooTest, Baz) { ... }
|
||||
//
|
||||
// Test is not copyable.
|
||||
class Test {
|
||||
class GTEST_API_ Test {
|
||||
public:
|
||||
friend class internal::TestInfoImpl;
|
||||
|
||||
@ -486,7 +486,7 @@ class TestProperty {
|
||||
// the Test.
|
||||
//
|
||||
// TestResult is not copyable.
|
||||
class TestResult {
|
||||
class GTEST_API_ TestResult {
|
||||
public:
|
||||
// Creates an empty TestResult.
|
||||
TestResult();
|
||||
@ -604,7 +604,7 @@ class TestResult {
|
||||
// The constructor of TestInfo registers itself with the UnitTest
|
||||
// singleton such that the RUN_ALL_TESTS() macro knows which tests to
|
||||
// run.
|
||||
class TestInfo {
|
||||
class GTEST_API_ TestInfo {
|
||||
public:
|
||||
// Destructs a TestInfo object. This function is not virtual, so
|
||||
// don't inherit from TestInfo.
|
||||
@ -686,7 +686,7 @@ class TestInfo {
|
||||
// A test case, which consists of a vector of TestInfos.
|
||||
//
|
||||
// TestCase is not copyable.
|
||||
class TestCase {
|
||||
class GTEST_API_ TestCase {
|
||||
public:
|
||||
// Creates a TestCase with the given name.
|
||||
//
|
||||
@ -924,7 +924,7 @@ class EmptyTestEventListener : public TestEventListener {
|
||||
};
|
||||
|
||||
// TestEventListeners lets users add listeners to track events in Google Test.
|
||||
class TestEventListeners {
|
||||
class GTEST_API_ TestEventListeners {
|
||||
public:
|
||||
TestEventListeners();
|
||||
~TestEventListeners();
|
||||
@ -1011,7 +1011,7 @@ class TestEventListeners {
|
||||
//
|
||||
// This class is thread-safe as long as the methods are called
|
||||
// according to their specification.
|
||||
class UnitTest {
|
||||
class GTEST_API_ UnitTest {
|
||||
public:
|
||||
// Gets the singleton UnitTest object. The first time this method
|
||||
// is called, a UnitTest object is constructed and returned.
|
||||
@ -1198,34 +1198,34 @@ inline Environment* AddGlobalTestEnvironment(Environment* env) {
|
||||
// updated.
|
||||
//
|
||||
// Calling the function for the second time has no user-visible effect.
|
||||
void InitGoogleTest(int* argc, char** argv);
|
||||
GTEST_API_ void InitGoogleTest(int* argc, char** argv);
|
||||
|
||||
// This overloaded version can be used in Windows programs compiled in
|
||||
// UNICODE mode.
|
||||
void InitGoogleTest(int* argc, wchar_t** argv);
|
||||
GTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv);
|
||||
|
||||
namespace internal {
|
||||
|
||||
// These overloaded versions handle ::std::string and ::std::wstring.
|
||||
inline String FormatForFailureMessage(const ::std::string& str) {
|
||||
GTEST_API_ inline String FormatForFailureMessage(const ::std::string& str) {
|
||||
return (Message() << '"' << str << '"').GetString();
|
||||
}
|
||||
|
||||
#if GTEST_HAS_STD_WSTRING
|
||||
inline String FormatForFailureMessage(const ::std::wstring& wstr) {
|
||||
GTEST_API_ inline String FormatForFailureMessage(const ::std::wstring& wstr) {
|
||||
return (Message() << "L\"" << wstr << '"').GetString();
|
||||
}
|
||||
#endif // GTEST_HAS_STD_WSTRING
|
||||
|
||||
// These overloaded versions handle ::string and ::wstring.
|
||||
#if GTEST_HAS_GLOBAL_STRING
|
||||
inline String FormatForFailureMessage(const ::string& str) {
|
||||
GTEST_API_ inline String FormatForFailureMessage(const ::string& str) {
|
||||
return (Message() << '"' << str << '"').GetString();
|
||||
}
|
||||
#endif // GTEST_HAS_GLOBAL_STRING
|
||||
|
||||
#if GTEST_HAS_GLOBAL_WSTRING
|
||||
inline String FormatForFailureMessage(const ::wstring& wstr) {
|
||||
GTEST_API_ inline String FormatForFailureMessage(const ::wstring& wstr) {
|
||||
return (Message() << "L\"" << wstr << '"').GetString();
|
||||
}
|
||||
#endif // GTEST_HAS_GLOBAL_WSTRING
|
||||
@ -1391,51 +1391,51 @@ GTEST_IMPL_CMP_HELPER_(GT, > )
|
||||
// The helper function for {ASSERT|EXPECT}_STREQ.
|
||||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
AssertionResult CmpHelperSTREQ(const char* expected_expression,
|
||||
const char* actual_expression,
|
||||
const char* expected,
|
||||
const char* actual);
|
||||
GTEST_API_ AssertionResult CmpHelperSTREQ(const char* expected_expression,
|
||||
const char* actual_expression,
|
||||
const char* expected,
|
||||
const char* actual);
|
||||
|
||||
// The helper function for {ASSERT|EXPECT}_STRCASEEQ.
|
||||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression,
|
||||
const char* actual_expression,
|
||||
const char* expected,
|
||||
const char* actual);
|
||||
GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression,
|
||||
const char* actual_expression,
|
||||
const char* expected,
|
||||
const char* actual);
|
||||
|
||||
// The helper function for {ASSERT|EXPECT}_STRNE.
|
||||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
AssertionResult CmpHelperSTRNE(const char* s1_expression,
|
||||
const char* s2_expression,
|
||||
const char* s1,
|
||||
const char* s2);
|
||||
GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
|
||||
const char* s2_expression,
|
||||
const char* s1,
|
||||
const char* s2);
|
||||
|
||||
// The helper function for {ASSERT|EXPECT}_STRCASENE.
|
||||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
|
||||
const char* s2_expression,
|
||||
const char* s1,
|
||||
const char* s2);
|
||||
GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
|
||||
const char* s2_expression,
|
||||
const char* s1,
|
||||
const char* s2);
|
||||
|
||||
|
||||
// Helper function for *_STREQ on wide strings.
|
||||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
AssertionResult CmpHelperSTREQ(const char* expected_expression,
|
||||
const char* actual_expression,
|
||||
const wchar_t* expected,
|
||||
const wchar_t* actual);
|
||||
GTEST_API_ AssertionResult CmpHelperSTREQ(const char* expected_expression,
|
||||
const char* actual_expression,
|
||||
const wchar_t* expected,
|
||||
const wchar_t* actual);
|
||||
|
||||
// Helper function for *_STRNE on wide strings.
|
||||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
AssertionResult CmpHelperSTRNE(const char* s1_expression,
|
||||
const char* s2_expression,
|
||||
const wchar_t* s1,
|
||||
const wchar_t* s2);
|
||||
GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
|
||||
const char* s2_expression,
|
||||
const wchar_t* s1,
|
||||
const wchar_t* s2);
|
||||
|
||||
} // namespace internal
|
||||
|
||||
@ -1513,16 +1513,16 @@ AssertionResult CmpHelperFloatingPointEQ(const char* expected_expression,
|
||||
// Helper function for implementing ASSERT_NEAR.
|
||||
//
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
|
||||
AssertionResult DoubleNearPredFormat(const char* expr1,
|
||||
const char* expr2,
|
||||
const char* abs_error_expr,
|
||||
double val1,
|
||||
double val2,
|
||||
double abs_error);
|
||||
GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1,
|
||||
const char* expr2,
|
||||
const char* abs_error_expr,
|
||||
double val1,
|
||||
double val2,
|
||||
double abs_error);
|
||||
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
|
||||
// A class that enables one to stream messages to assertion macros
|
||||
class AssertHelper {
|
||||
class GTEST_API_ AssertHelper {
|
||||
public:
|
||||
// Constructor.
|
||||
AssertHelper(TestPartResult::Type type,
|
||||
@ -1853,10 +1853,10 @@ const T* TestWithParam<T>::parameter_ = NULL;
|
||||
|
||||
// Asserts that val1 is less than, or almost equal to, val2. Fails
|
||||
// otherwise. In particular, it fails if either val1 or val2 is NaN.
|
||||
AssertionResult FloatLE(const char* expr1, const char* expr2,
|
||||
float val1, float val2);
|
||||
AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
||||
double val1, double val2);
|
||||
GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2,
|
||||
float val1, float val2);
|
||||
GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
|
||||
double val1, double val2);
|
||||
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
|
@ -64,7 +64,7 @@ const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
|
||||
// by wait(2)
|
||||
// exit code: The integer code passed to exit(3), _exit(2), or
|
||||
// returned from main()
|
||||
class DeathTest {
|
||||
class GTEST_API_ DeathTest {
|
||||
public:
|
||||
// Create returns false if there was an error determining the
|
||||
// appropriate action to take for the current death test; for example,
|
||||
@ -147,7 +147,7 @@ class DefaultDeathTestFactory : public DeathTestFactory {
|
||||
|
||||
// Returns true if exit_status describes a process that was terminated
|
||||
// by a signal, or exited normally with a nonzero exit code.
|
||||
bool ExitedUnsuccessfully(int exit_status);
|
||||
GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
|
||||
|
||||
// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
|
||||
// ASSERT_EXIT*, and EXPECT_EXIT*.
|
||||
|
@ -161,7 +161,7 @@ String AppendUserMessage(const String& gtest_msg,
|
||||
const Message& user_msg);
|
||||
|
||||
// A helper class for creating scoped traces in user programs.
|
||||
class ScopedTrace {
|
||||
class GTEST_API_ ScopedTrace {
|
||||
public:
|
||||
// The c'tor pushes the given source file location and message onto
|
||||
// a trace stack maintained by Google Test.
|
||||
@ -240,8 +240,8 @@ inline String FormatForFailureMessage(T* pointer) {
|
||||
#endif // GTEST_NEEDS_IS_POINTER_
|
||||
|
||||
// These overloaded versions handle narrow and wide characters.
|
||||
String FormatForFailureMessage(char ch);
|
||||
String FormatForFailureMessage(wchar_t wchar);
|
||||
GTEST_API_ String FormatForFailureMessage(char ch);
|
||||
GTEST_API_ String FormatForFailureMessage(wchar_t wchar);
|
||||
|
||||
// When this operand is a const char* or char*, and the other operand
|
||||
// is a ::std::string or ::string, we print this operand as a C string
|
||||
@ -287,17 +287,18 @@ GTEST_FORMAT_IMPL_(::wstring, String::ShowWideCStringQuoted)
|
||||
// The ignoring_case parameter is true iff the assertion is a
|
||||
// *_STRCASEEQ*. When it's true, the string " (ignoring case)" will
|
||||
// be inserted into the message.
|
||||
AssertionResult EqFailure(const char* expected_expression,
|
||||
const char* actual_expression,
|
||||
const String& expected_value,
|
||||
const String& actual_value,
|
||||
bool ignoring_case);
|
||||
GTEST_API_ AssertionResult EqFailure(const char* expected_expression,
|
||||
const char* actual_expression,
|
||||
const String& expected_value,
|
||||
const String& actual_value,
|
||||
bool ignoring_case);
|
||||
|
||||
// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
|
||||
String GetBoolAssertionFailureMessage(const AssertionResult& assertion_result,
|
||||
const char* expression_text,
|
||||
const char* actual_predicate_value,
|
||||
const char* expected_predicate_value);
|
||||
GTEST_API_ String GetBoolAssertionFailureMessage(
|
||||
const AssertionResult& assertion_result,
|
||||
const char* expression_text,
|
||||
const char* actual_predicate_value,
|
||||
const char* expected_predicate_value);
|
||||
|
||||
// This template class represents an IEEE floating-point number
|
||||
// (either single-precision or double-precision, depending on the
|
||||
@ -517,7 +518,7 @@ TypeId GetTypeId() {
|
||||
// ::testing::Test, as the latter may give the wrong result due to a
|
||||
// suspected linker bug when compiling Google Test as a Mac OS X
|
||||
// framework.
|
||||
TypeId GetTestTypeId();
|
||||
GTEST_API_ TypeId GetTestTypeId();
|
||||
|
||||
// Defines the abstract factory interface that creates instances
|
||||
// of a Test object.
|
||||
@ -550,8 +551,10 @@ class TestFactoryImpl : public TestFactoryBase {
|
||||
// {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}
|
||||
// We pass a long instead of HRESULT to avoid causing an
|
||||
// include dependency for the HRESULT type.
|
||||
AssertionResult IsHRESULTSuccess(const char* expr, long hr); // NOLINT
|
||||
AssertionResult IsHRESULTFailure(const char* expr, long hr); // NOLINT
|
||||
GTEST_API_ AssertionResult IsHRESULTSuccess(const char* expr,
|
||||
long hr); // NOLINT
|
||||
GTEST_API_ AssertionResult IsHRESULTFailure(const char* expr,
|
||||
long hr); // NOLINT
|
||||
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
|
||||
@ -590,7 +593,7 @@ typedef void (*TearDownTestCaseFunc)();
|
||||
// factory: pointer to the factory that creates a test object.
|
||||
// The newly created TestInfo instance will assume
|
||||
// ownership of the factory object.
|
||||
TestInfo* MakeAndRegisterTestInfo(
|
||||
GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
|
||||
const char* test_case_name, const char* name,
|
||||
const char* test_case_comment, const char* comment,
|
||||
TypeId fixture_class_id,
|
||||
@ -606,7 +609,7 @@ bool SkipPrefix(const char* prefix, const char** pstr);
|
||||
#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
|
||||
|
||||
// State of the definition of a type-parameterized test case.
|
||||
class TypedTestCasePState {
|
||||
class GTEST_API_ TypedTestCasePState {
|
||||
public:
|
||||
TypedTestCasePState() : registered_(false) {}
|
||||
|
||||
@ -753,7 +756,7 @@ String GetCurrentOsStackTraceExceptTop(UnitTest* unit_test, int skip_count);
|
||||
// condition.
|
||||
|
||||
// Always returns true.
|
||||
bool AlwaysTrue();
|
||||
GTEST_API_ bool AlwaysTrue();
|
||||
|
||||
// Always returns false.
|
||||
inline bool AlwaysFalse() { return !AlwaysTrue(); }
|
||||
|
@ -77,7 +77,7 @@ namespace testing {
|
||||
namespace internal {
|
||||
|
||||
// Protects copying of all linked_ptr objects.
|
||||
GTEST_DECLARE_STATIC_MUTEX_(g_linked_ptr_mutex);
|
||||
GTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_linked_ptr_mutex);
|
||||
|
||||
// This is used internally by all instances of linked_ptr<>. It needs to be
|
||||
// a non-template class because different types of linked_ptr<> can refer to
|
||||
|
@ -60,8 +60,8 @@ namespace internal {
|
||||
// fixture class for the same test case. This may happen when
|
||||
// TEST_P macro is used to define two tests with the same name
|
||||
// but in different namespaces.
|
||||
void ReportInvalidTestCaseType(const char* test_case_name,
|
||||
const char* file, int line);
|
||||
GTEST_API_ void ReportInvalidTestCaseType(const char* test_case_name,
|
||||
const char* file, int line);
|
||||
|
||||
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
|
||||
//
|
||||
|
@ -66,6 +66,13 @@
|
||||
// Test's own tr1 tuple implementation should be
|
||||
// used. Unused when the user sets
|
||||
// GTEST_HAS_TR1_TUPLE to 0.
|
||||
// GTEST_LINKED_AS_SHARED_LIBRARY
|
||||
// - Define to 1 when compiling tests that use
|
||||
// Google Test as a shared library (known as
|
||||
// DLL on Windows).
|
||||
// GTEST_CREATE_SHARED_LIBRARY
|
||||
// - Define to 1 when compiling Google Test itself
|
||||
// as a shared library.
|
||||
|
||||
// This header defines the following utilities:
|
||||
//
|
||||
@ -558,6 +565,20 @@
|
||||
|
||||
#endif // GTEST_HAS_SEH
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#if GTEST_LINKED_AS_SHARED_LIBRARY
|
||||
#define GTEST_API_ __declspec(dllimport)
|
||||
#elif GTEST_CREATE_SHARED_LIBRARY
|
||||
#define GTEST_API_ __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
#endif // _MSC_VER
|
||||
|
||||
#ifndef GTEST_API_
|
||||
#define GTEST_API_
|
||||
#endif
|
||||
|
||||
namespace testing {
|
||||
|
||||
class Message;
|
||||
@ -570,7 +591,7 @@ typedef ::std::stringstream StrStream;
|
||||
|
||||
// A helper for suppressing warnings on constant condition. It just
|
||||
// returns 'condition'.
|
||||
bool IsTrue(bool condition);
|
||||
GTEST_API_ bool IsTrue(bool condition);
|
||||
|
||||
// Defines scoped_ptr.
|
||||
|
||||
@ -612,7 +633,7 @@ class scoped_ptr {
|
||||
|
||||
// A simple C++ wrapper for <regex.h>. It uses the POSIX Enxtended
|
||||
// Regular Expression syntax.
|
||||
class RE {
|
||||
class GTEST_API_ RE {
|
||||
public:
|
||||
// Constructs an RE from a string.
|
||||
RE(const ::std::string& regex) { Init(regex.c_str()); } // NOLINT
|
||||
@ -688,7 +709,7 @@ enum GTestLogSeverity {
|
||||
// Formats log entry severity, provides a stream object for streaming the
|
||||
// log message, and terminates the message with a newline when going out of
|
||||
// scope.
|
||||
class GTestLog {
|
||||
class GTEST_API_ GTestLog {
|
||||
public:
|
||||
GTestLog(GTestLogSeverity severity, const char* file, int line);
|
||||
|
||||
@ -1330,19 +1351,19 @@ typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds.
|
||||
#define GTEST_FLAG(name) FLAGS_gtest_##name
|
||||
|
||||
// Macros for declaring flags.
|
||||
#define GTEST_DECLARE_bool_(name) extern bool GTEST_FLAG(name)
|
||||
#define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
|
||||
#define GTEST_DECLARE_int32_(name) \
|
||||
extern ::testing::internal::Int32 GTEST_FLAG(name)
|
||||
GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)
|
||||
#define GTEST_DECLARE_string_(name) \
|
||||
extern ::testing::internal::String GTEST_FLAG(name)
|
||||
GTEST_API_ extern ::testing::internal::String GTEST_FLAG(name)
|
||||
|
||||
// Macros for defining flags.
|
||||
#define GTEST_DEFINE_bool_(name, default_val, doc) \
|
||||
bool GTEST_FLAG(name) = (default_val)
|
||||
GTEST_API_ bool GTEST_FLAG(name) = (default_val)
|
||||
#define GTEST_DEFINE_int32_(name, default_val, doc) \
|
||||
::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
|
||||
GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
|
||||
#define GTEST_DEFINE_string_(name, default_val, doc) \
|
||||
::testing::internal::String GTEST_FLAG(name) = (default_val)
|
||||
GTEST_API_ ::testing::internal::String GTEST_FLAG(name) = (default_val)
|
||||
|
||||
// Parses 'str' for a 32-bit signed integer. If successful, writes the result
|
||||
// to *value and returns true; otherwise leaves *value unchanged and returns
|
||||
|
@ -73,7 +73,7 @@ namespace internal {
|
||||
//
|
||||
// In order to make the representation efficient, the d'tor of String
|
||||
// is not virtual. Therefore DO NOT INHERIT FROM String.
|
||||
class String {
|
||||
class GTEST_API_ String {
|
||||
public:
|
||||
// Static utility methods
|
||||
|
||||
@ -326,7 +326,7 @@ inline ::std::ostream& operator<<(::std::ostream& os, const String& str) {
|
||||
|
||||
// Gets the content of the StrStream's buffer as a String. Each '\0'
|
||||
// character in the buffer is replaced with "\\0".
|
||||
String StrStreamToString(StrStream* stream);
|
||||
GTEST_API_ String StrStreamToString(StrStream* stream);
|
||||
|
||||
// Converts a streamable value to a String. A NULL pointer is
|
||||
// converted to "(null)". When the input value is a ::string,
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
GTEST_API_ int main(int argc, char **argv) {
|
||||
std::cout << "Running main() from gtest_main.cc\n";
|
||||
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
@ -29,21 +29,24 @@
|
||||
// Author: vladl@google.com (Vlad Losev)
|
||||
//
|
||||
// Tests for Google Test itself. This verifies that Google Test can be
|
||||
// linked into an executable successfully when built as a DLL on Windows.
|
||||
// The test is not meant to check the success of test assertions employed in
|
||||
// it. It only checks that constructs in them can be successfully linked.
|
||||
// linked into an executable successfully when built as a shared library (a
|
||||
// DLL on Windows). The test is not meant to check the success of test
|
||||
// assertions employed in it. It only checks that constructs in them can be
|
||||
// successfully linked.
|
||||
//
|
||||
// If you add new features to Google Test's documented interface, you need to
|
||||
// add tests exercising them to this file.
|
||||
//
|
||||
// If you start having 'unresolved external symbol' linker errors in this file
|
||||
// after the changes you have made, re-generate src/gtest.def by running
|
||||
// scripts/generate_gtest_def.py.
|
||||
// after the changes you have made, you have to modify your source code to
|
||||
// export the new symbols.
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <gtest/gtest-spi.h>
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <vector>
|
||||
|
||||
using ::std::vector;
|
||||
@ -297,18 +300,20 @@ TEST(FloatingPointComparisonAssertionTest, LinksSuccessfully) {
|
||||
EXPECT_PRED_FORMAT2(::testing::DoubleLE, 0.0, 0.001);
|
||||
}
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
// Tests linking of HRESULT assertions.
|
||||
TEST(HresultAssertionTest, LinksSuccessfully) {
|
||||
EXPECT_HRESULT_SUCCEEDED(S_OK);
|
||||
EXPECT_HRESULT_FAILED(E_FAIL);
|
||||
}
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
|
||||
#if GTEST_HAS_EXCEPTIONS
|
||||
// Tests linking of exception assertions.
|
||||
TEST(ExceptionAssertionTest, LinksSuccessfully) {
|
||||
EXPECT_THROW(throw 1, int);
|
||||
EXPECT_ANY_THROW(throw 1);
|
||||
EXPECT_NO_THROW(int x = 1);
|
||||
EXPECT_NO_THROW(std::vector<int> v);
|
||||
}
|
||||
#endif // GTEST_HAS_EXCEPTIONS
|
||||
|
||||
@ -498,6 +503,7 @@ int main(int argc, char **argv) {
|
||||
listener = listeners.default_result_printer();
|
||||
listener = listeners.default_xml_generator();
|
||||
|
||||
RUN_ALL_TESTS();
|
||||
int ret_val = RUN_ALL_TESTS();
|
||||
static_cast<void>(ret_val);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user