Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
c0037332
Commit
c0037332
authored
Aug 28, 2017
by
Alyssa Wilk
Browse files
Merge branch 'refs/heads/master' into flag-default
parents
a2803bc3
b43bfcf4
Changes
115
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
209 additions
and
325 deletions
+209
-325
googletest/msvc/gtest_unittest-md.vcproj
googletest/msvc/gtest_unittest-md.vcproj
+0
-147
googletest/msvc/gtest_unittest.vcproj
googletest/msvc/gtest_unittest.vcproj
+0
-147
googletest/samples/sample10_unittest.cc
googletest/samples/sample10_unittest.cc
+0
-3
googletest/samples/sample1_unittest.cc
googletest/samples/sample1_unittest.cc
+2
-1
googletest/samples/sample2_unittest.cc
googletest/samples/sample2_unittest.cc
+2
-1
googletest/samples/sample3_unittest.cc
googletest/samples/sample3_unittest.cc
+6
-5
googletest/samples/sample4_unittest.cc
googletest/samples/sample4_unittest.cc
+2
-1
googletest/samples/sample5_unittest.cc
googletest/samples/sample5_unittest.cc
+2
-2
googletest/samples/sample6_unittest.cc
googletest/samples/sample6_unittest.cc
+2
-1
googletest/samples/sample7_unittest.cc
googletest/samples/sample7_unittest.cc
+10
-10
googletest/samples/sample8_unittest.cc
googletest/samples/sample8_unittest.cc
+2
-1
googletest/samples/sample9_unittest.cc
googletest/samples/sample9_unittest.cc
+0
-3
googletest/src/gtest.cc
googletest/src/gtest.cc
+31
-3
googletest/test/BUILD.bazel
googletest/test/BUILD.bazel
+118
-0
googletest/test/gtest-printers_test.cc
googletest/test/gtest-printers_test.cc
+32
-0
No files found.
googletest/msvc/gtest_unittest-md.vcproj
deleted
100644 → 0
View file @
a2803bc3
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType=
"Visual C++"
Version=
"7.10"
Name=
"gtest_unittest-md"
ProjectGUID=
"{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}"
Keyword=
"Win32Proj"
>
<Platforms>
<Platform
Name=
"Win32"
/>
</Platforms>
<Configurations>
<Configuration
Name=
"Debug|Win32"
OutputDirectory=
"$(SolutionName)/$(ConfigurationName)"
IntermediateDirectory=
"$(OutDir)/$(ProjectName)"
ConfigurationType=
"1"
CharacterSet=
"2"
>
<Tool
Name=
"VCCLCompilerTool"
Optimization=
"0"
PreprocessorDefinitions=
"WIN32;_DEBUG;_CONSOLE"
MinimalRebuild=
"TRUE"
BasicRuntimeChecks=
"3"
RuntimeLibrary=
"3"
UsePrecompiledHeader=
"3"
WarningLevel=
"3"
Detect64BitPortabilityProblems=
"FALSE"
DebugInformationFormat=
"4"
/>
<Tool
Name=
"VCCustomBuildTool"
/>
<Tool
Name=
"VCLinkerTool"
OutputFile=
"$(OutDir)/gtest_unittest.exe"
LinkIncremental=
"2"
GenerateDebugInformation=
"TRUE"
ProgramDatabaseFile=
"$(OutDir)/gtest_unittest.pdb"
SubSystem=
"1"
TargetMachine=
"1"
/>
<Tool
Name=
"VCMIDLTool"
/>
<Tool
Name=
"VCPostBuildEventTool"
/>
<Tool
Name=
"VCPreBuildEventTool"
/>
<Tool
Name=
"VCPreLinkEventTool"
/>
<Tool
Name=
"VCResourceCompilerTool"
/>
<Tool
Name=
"VCWebServiceProxyGeneratorTool"
/>
<Tool
Name=
"VCXMLDataGeneratorTool"
/>
<Tool
Name=
"VCWebDeploymentTool"
/>
<Tool
Name=
"VCManagedWrapperGeneratorTool"
/>
<Tool
Name=
"VCAuxiliaryManagedWrapperGeneratorTool"
/>
</Configuration>
<Configuration
Name=
"Release|Win32"
OutputDirectory=
"$(SolutionName)/$(ConfigurationName)"
IntermediateDirectory=
"$(OutDir)/$(ProjectName)"
ConfigurationType=
"1"
CharacterSet=
"2"
>
<Tool
Name=
"VCCLCompilerTool"
PreprocessorDefinitions=
"WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary=
"2"
UsePrecompiledHeader=
"3"
WarningLevel=
"3"
Detect64BitPortabilityProblems=
"FALSE"
DebugInformationFormat=
"3"
/>
<Tool
Name=
"VCCustomBuildTool"
/>
<Tool
Name=
"VCLinkerTool"
OutputFile=
"$(OutDir)/gtest_unittest.exe"
LinkIncremental=
"1"
GenerateDebugInformation=
"TRUE"
SubSystem=
"1"
OptimizeReferences=
"2"
EnableCOMDATFolding=
"2"
TargetMachine=
"1"
/>
<Tool
Name=
"VCMIDLTool"
/>
<Tool
Name=
"VCPostBuildEventTool"
/>
<Tool
Name=
"VCPreBuildEventTool"
/>
<Tool
Name=
"VCPreLinkEventTool"
/>
<Tool
Name=
"VCResourceCompilerTool"
/>
<Tool
Name=
"VCWebServiceProxyGeneratorTool"
/>
<Tool
Name=
"VCXMLDataGeneratorTool"
/>
<Tool
Name=
"VCWebDeploymentTool"
/>
<Tool
Name=
"VCManagedWrapperGeneratorTool"
/>
<Tool
Name=
"VCAuxiliaryManagedWrapperGeneratorTool"
/>
</Configuration>
</Configurations>
<References>
<ProjectReference
ReferencedProjectIdentifier=
"{3AF54C8A-10BF-4332-9147-F68ED9862033}"
Name=
"gtest_main-md"
/>
</References>
<Files>
<Filter
Name=
"Source Files"
Filter=
"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier=
"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=
"..\test\gtest_unittest.cc"
>
<FileConfiguration
Name=
"Debug|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
Optimization=
"1"
AdditionalIncludeDirectories=
""..";"..\include""
BasicRuntimeChecks=
"0"
UsePrecompiledHeader=
"0"
DebugInformationFormat=
"3"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
AdditionalIncludeDirectories=
""..";"..\include""
UsePrecompiledHeader=
"0"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name=
"Header Files"
Filter=
"h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier=
"{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
googletest/msvc/gtest_unittest.vcproj
deleted
100644 → 0
View file @
a2803bc3
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType=
"Visual C++"
Version=
"7.10"
Name=
"gtest_unittest"
ProjectGUID=
"{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}"
Keyword=
"Win32Proj"
>
<Platforms>
<Platform
Name=
"Win32"
/>
</Platforms>
<Configurations>
<Configuration
Name=
"Debug|Win32"
OutputDirectory=
"$(SolutionName)/$(ConfigurationName)"
IntermediateDirectory=
"$(OutDir)/$(ProjectName)"
ConfigurationType=
"1"
CharacterSet=
"2"
>
<Tool
Name=
"VCCLCompilerTool"
Optimization=
"0"
PreprocessorDefinitions=
"WIN32;_DEBUG;_CONSOLE"
MinimalRebuild=
"TRUE"
BasicRuntimeChecks=
"3"
RuntimeLibrary=
"5"
UsePrecompiledHeader=
"3"
WarningLevel=
"3"
Detect64BitPortabilityProblems=
"FALSE"
DebugInformationFormat=
"4"
/>
<Tool
Name=
"VCCustomBuildTool"
/>
<Tool
Name=
"VCLinkerTool"
OutputFile=
"$(OutDir)/gtest_unittest.exe"
LinkIncremental=
"2"
GenerateDebugInformation=
"TRUE"
ProgramDatabaseFile=
"$(OutDir)/gtest_unittest.pdb"
SubSystem=
"1"
TargetMachine=
"1"
/>
<Tool
Name=
"VCMIDLTool"
/>
<Tool
Name=
"VCPostBuildEventTool"
/>
<Tool
Name=
"VCPreBuildEventTool"
/>
<Tool
Name=
"VCPreLinkEventTool"
/>
<Tool
Name=
"VCResourceCompilerTool"
/>
<Tool
Name=
"VCWebServiceProxyGeneratorTool"
/>
<Tool
Name=
"VCXMLDataGeneratorTool"
/>
<Tool
Name=
"VCWebDeploymentTool"
/>
<Tool
Name=
"VCManagedWrapperGeneratorTool"
/>
<Tool
Name=
"VCAuxiliaryManagedWrapperGeneratorTool"
/>
</Configuration>
<Configuration
Name=
"Release|Win32"
OutputDirectory=
"$(SolutionName)/$(ConfigurationName)"
IntermediateDirectory=
"$(OutDir)/$(ProjectName)"
ConfigurationType=
"1"
CharacterSet=
"2"
>
<Tool
Name=
"VCCLCompilerTool"
PreprocessorDefinitions=
"WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary=
"4"
UsePrecompiledHeader=
"3"
WarningLevel=
"3"
Detect64BitPortabilityProblems=
"FALSE"
DebugInformationFormat=
"3"
/>
<Tool
Name=
"VCCustomBuildTool"
/>
<Tool
Name=
"VCLinkerTool"
OutputFile=
"$(OutDir)/gtest_unittest.exe"
LinkIncremental=
"1"
GenerateDebugInformation=
"TRUE"
SubSystem=
"1"
OptimizeReferences=
"2"
EnableCOMDATFolding=
"2"
TargetMachine=
"1"
/>
<Tool
Name=
"VCMIDLTool"
/>
<Tool
Name=
"VCPostBuildEventTool"
/>
<Tool
Name=
"VCPreBuildEventTool"
/>
<Tool
Name=
"VCPreLinkEventTool"
/>
<Tool
Name=
"VCResourceCompilerTool"
/>
<Tool
Name=
"VCWebServiceProxyGeneratorTool"
/>
<Tool
Name=
"VCXMLDataGeneratorTool"
/>
<Tool
Name=
"VCWebDeploymentTool"
/>
<Tool
Name=
"VCManagedWrapperGeneratorTool"
/>
<Tool
Name=
"VCAuxiliaryManagedWrapperGeneratorTool"
/>
</Configuration>
</Configurations>
<References>
<ProjectReference
ReferencedProjectIdentifier=
"{3AF54C8A-10BF-4332-9147-F68ED9862032}"
Name=
"gtest_main"
/>
</References>
<Files>
<Filter
Name=
"Source Files"
Filter=
"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier=
"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=
"..\test\gtest_unittest.cc"
>
<FileConfiguration
Name=
"Debug|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
Optimization=
"1"
AdditionalIncludeDirectories=
""..";"..\include""
BasicRuntimeChecks=
"0"
UsePrecompiledHeader=
"0"
DebugInformationFormat=
"3"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
AdditionalIncludeDirectories=
""..";"..\include""
UsePrecompiledHeader=
"0"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name=
"Header Files"
Filter=
"h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier=
"{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
googletest/samples/sample10_unittest.cc
View file @
c0037332
...
...
@@ -35,7 +35,6 @@
#include <stdlib.h>
#include "gtest/gtest.h"
using
::
testing
::
EmptyTestEventListener
;
using
::
testing
::
InitGoogleTest
;
using
::
testing
::
Test
;
...
...
@@ -46,7 +45,6 @@ using ::testing::TestPartResult;
using
::
testing
::
UnitTest
;
namespace
{
// We will track memory used by this class.
class
Water
{
public:
...
...
@@ -106,7 +104,6 @@ TEST(ListenersTest, LeaksWater) {
Water
*
water
=
new
Water
;
EXPECT_TRUE
(
water
!=
NULL
);
}
}
// namespace
int
main
(
int
argc
,
char
**
argv
)
{
...
...
googletest/samples/sample1_unittest.cc
View file @
c0037332
...
...
@@ -46,7 +46,7 @@
#include <limits.h>
#include "sample1.h"
#include "gtest/gtest.h"
namespace
{
// Step 2. Use the TEST macro to define your tests.
//
...
...
@@ -139,6 +139,7 @@ TEST(IsPrimeTest, Positive) {
EXPECT_FALSE
(
IsPrime
(
6
));
EXPECT_TRUE
(
IsPrime
(
23
));
}
}
// namespace
// Step 3. Call RUN_ALL_TESTS() in main().
//
...
...
googletest/samples/sample2_unittest.cc
View file @
c0037332
...
...
@@ -42,7 +42,7 @@
#include "sample2.h"
#include "gtest/gtest.h"
namespace
{
// In this example, we test the MyString class (a simple string).
// Tests the default c'tor.
...
...
@@ -107,3 +107,4 @@ TEST(MyString, Set) {
s
.
Set
(
NULL
);
EXPECT_STREQ
(
NULL
,
s
.
c_string
());
}
}
// namespace
googletest/samples/sample3_unittest.cc
View file @
c0037332
...
...
@@ -65,9 +65,9 @@
#include "sample3-inl.h"
#include "gtest/gtest.h"
namespace
{
// To use a test fixture, derive a class from testing::Test.
class
QueueTest
:
public
testing
::
Test
{
class
QueueTest
Smpl3
:
public
testing
::
Test
{
protected:
// You should make the members protected s.t. they can be
// accessed from sub-classes.
...
...
@@ -120,13 +120,13 @@ class QueueTest : public testing::Test {
// instead of TEST.
// Tests the default c'tor.
TEST_F
(
QueueTest
,
DefaultConstructor
)
{
TEST_F
(
QueueTest
Smpl3
,
DefaultConstructor
)
{
// You can access data in the test fixture here.
EXPECT_EQ
(
0u
,
q0_
.
Size
());
}
// Tests Dequeue().
TEST_F
(
QueueTest
,
Dequeue
)
{
TEST_F
(
QueueTest
Smpl3
,
Dequeue
)
{
int
*
n
=
q0_
.
Dequeue
();
EXPECT_TRUE
(
n
==
NULL
);
...
...
@@ -144,8 +144,9 @@ TEST_F(QueueTest, Dequeue) {
}
// Tests the Queue::Map() function.
TEST_F
(
QueueTest
,
Map
)
{
TEST_F
(
QueueTest
Smpl3
,
Map
)
{
MapTester
(
&
q0_
);
MapTester
(
&
q1_
);
MapTester
(
&
q2_
);
}
}
// namespace
googletest/samples/sample4_unittest.cc
View file @
c0037332
...
...
@@ -31,7 +31,7 @@
#include "gtest/gtest.h"
#include "sample4.h"
namespace
{
// Tests the Increment() method.
TEST
(
Counter
,
Increment
)
{
Counter
c
;
...
...
@@ -43,3 +43,4 @@ TEST(Counter, Increment) {
EXPECT_EQ
(
1
,
c
.
Increment
());
EXPECT_EQ
(
2
,
c
.
Increment
());
}
}
// namespace
googletest/samples/sample5_unittest.cc
View file @
c0037332
...
...
@@ -49,7 +49,7 @@
#include "sample3-inl.h"
#include "gtest/gtest.h"
#include "sample1.h"
namespace
{
// In this sample, we want to ensure that every test finishes within
// ~5 seconds. If a test takes longer to run, we consider it a
// failure.
...
...
@@ -191,7 +191,7 @@ TEST_F(QueueTest, Dequeue) {
EXPECT_EQ
(
1u
,
q2_
.
Size
());
delete
n
;
}
}
// namespace
// If necessary, you can derive further test fixtures from a derived
// fixture itself. For example, you can derive another fixture from
// QueueTest. Google Test imposes no limit on how deep the hierarchy
...
...
googletest/samples/sample6_unittest.cc
View file @
c0037332
...
...
@@ -36,7 +36,7 @@
#include "prime_tables.h"
#include "gtest/gtest.h"
namespace
{
// First, we define some factory functions for creating instances of
// the implementations. You may be able to skip this step if all your
// implementations can be constructed the same way.
...
...
@@ -222,3 +222,4 @@ INSTANTIATE_TYPED_TEST_CASE_P(OnTheFlyAndPreCalculated, // Instance name
PrimeTableImplementations
);
// Type list
#endif // GTEST_HAS_TYPED_TEST_P
}
// namespace
googletest/samples/sample7_unittest.cc
View file @
c0037332
...
...
@@ -39,7 +39,7 @@
#include "prime_tables.h"
#include "gtest/gtest.h"
namespace
{
#if GTEST_HAS_PARAM_TEST
using
::
testing
::
TestWithParam
;
...
...
@@ -65,9 +65,9 @@ PrimeTable* CreatePreCalculatedPrimeTable() {
// can refer to the test parameter by GetParam(). In this case, the test
// parameter is a factory function which we call in fixture's SetUp() to
// create and store an instance of PrimeTable.
class
PrimeTableTest
:
public
TestWithParam
<
CreatePrimeTableFunc
*>
{
class
PrimeTableTest
Smpl7
:
public
TestWithParam
<
CreatePrimeTableFunc
*>
{
public:
virtual
~
PrimeTableTest
()
{
delete
table_
;
}
virtual
~
PrimeTableTest
Smpl7
()
{
delete
table_
;
}
virtual
void
SetUp
()
{
table_
=
(
*
GetParam
())();
}
virtual
void
TearDown
()
{
delete
table_
;
...
...
@@ -78,7 +78,7 @@ class PrimeTableTest : public TestWithParam<CreatePrimeTableFunc*> {
PrimeTable
*
table_
;
};
TEST_P
(
PrimeTableTest
,
ReturnsFalseForNonPrimes
)
{
TEST_P
(
PrimeTableTest
Smpl7
,
ReturnsFalseForNonPrimes
)
{
EXPECT_FALSE
(
table_
->
IsPrime
(
-
5
));
EXPECT_FALSE
(
table_
->
IsPrime
(
0
));
EXPECT_FALSE
(
table_
->
IsPrime
(
1
));
...
...
@@ -87,7 +87,7 @@ TEST_P(PrimeTableTest, ReturnsFalseForNonPrimes) {
EXPECT_FALSE
(
table_
->
IsPrime
(
100
));
}
TEST_P
(
PrimeTableTest
,
ReturnsTrueForPrimes
)
{
TEST_P
(
PrimeTableTest
Smpl7
,
ReturnsTrueForPrimes
)
{
EXPECT_TRUE
(
table_
->
IsPrime
(
2
));
EXPECT_TRUE
(
table_
->
IsPrime
(
3
));
EXPECT_TRUE
(
table_
->
IsPrime
(
5
));
...
...
@@ -96,7 +96,7 @@ TEST_P(PrimeTableTest, ReturnsTrueForPrimes) {
EXPECT_TRUE
(
table_
->
IsPrime
(
131
));
}
TEST_P
(
PrimeTableTest
,
CanGetNextPrime
)
{
TEST_P
(
PrimeTableTest
Smpl7
,
CanGetNextPrime
)
{
EXPECT_EQ
(
2
,
table_
->
GetNextPrime
(
0
));
EXPECT_EQ
(
3
,
table_
->
GetNextPrime
(
2
));
EXPECT_EQ
(
5
,
table_
->
GetNextPrime
(
3
));
...
...
@@ -112,10 +112,9 @@ TEST_P(PrimeTableTest, CanGetNextPrime) {
//
// Here, we instantiate our tests with a list of two PrimeTable object
// factory functions:
INSTANTIATE_TEST_CASE_P
(
OnTheFlyAndPreCalculated
,
PrimeTableTest
,
Values
(
&
CreateOnTheFlyPrimeTable
,
&
CreatePreCalculatedPrimeTable
<
1000
>
));
INSTANTIATE_TEST_CASE_P
(
OnTheFlyAndPreCalculated
,
PrimeTableTestSmpl7
,
Values
(
&
CreateOnTheFlyPrimeTable
,
&
CreatePreCalculatedPrimeTable
<
1000
>
));
#else
...
...
@@ -128,3 +127,4 @@ INSTANTIATE_TEST_CASE_P(
TEST
(
DummyTest
,
ValueParameterizedTestsAreNotSupportedOnThisPlatform
)
{}
#endif // GTEST_HAS_PARAM_TEST
}
// namespace
googletest/samples/sample8_unittest.cc
View file @
c0037332
...
...
@@ -37,7 +37,7 @@
#include "prime_tables.h"
#include "gtest/gtest.h"
namespace
{
#if GTEST_HAS_COMBINE
// Suppose we want to introduce a new, improved implementation of PrimeTable
...
...
@@ -171,3 +171,4 @@ INSTANTIATE_TEST_CASE_P(MeaningfulTestParameters,
TEST
(
DummyTest
,
CombineIsNotSupportedOnThisPlatform
)
{}
#endif // GTEST_HAS_COMBINE
}
// namespace
googletest/samples/sample9_unittest.cc
View file @
c0037332
...
...
@@ -44,9 +44,7 @@ using ::testing::TestEventListeners;
using
::
testing
::
TestInfo
;
using
::
testing
::
TestPartResult
;
using
::
testing
::
UnitTest
;
namespace
{
// Provides alternative output mode which produces minimal amount of
// information about tests.
class
TersePrinter
:
public
EmptyTestEventListener
{
...
...
@@ -102,7 +100,6 @@ TEST(CustomOutputTest, Fails) {
EXPECT_EQ
(
1
,
2
)
<<
"This test fails in order to demonstrate alternative failure messages"
;
}
}
// namespace
int
main
(
int
argc
,
char
**
argv
)
{
...
...
googletest/src/gtest.cc
View file @
c0037332
...
...
@@ -2895,6 +2895,33 @@ WORD GetColorAttribute(GTestColor color) {
}
}
int
GetBitOffset
(
WORD
color_mask
)
{
if
(
color_mask
==
0
)
return
0
;
int
bitOffset
=
0
;
while
((
color_mask
&
1
)
==
0
)
{
color_mask
>>=
1
;
++
bitOffset
;
}
return
bitOffset
;
}
WORD
GetNewColor
(
GTestColor
color
,
WORD
old_color_attrs
)
{
// Let's reuse the BG
static
const
WORD
background_mask
=
BACKGROUND_BLUE
|
BACKGROUND_GREEN
|
BACKGROUND_RED
|
BACKGROUND_INTENSITY
;
static
const
WORD
foreground_mask
=
FOREGROUND_BLUE
|
FOREGROUND_GREEN
|
FOREGROUND_RED
|
FOREGROUND_INTENSITY
;
const
WORD
existing_bg
=
old_color_attrs
&
background_mask
;
WORD
new_color
=
GetColorAttribute
(
color
)
|
existing_bg
|
FOREGROUND_INTENSITY
;
static
const
int
bg_bitOffset
=
GetBitOffset
(
background_mask
);
static
const
int
fg_bitOffset
=
GetBitOffset
(
foreground_mask
);
if
(((
new_color
&
background_mask
)
>>
bg_bitOffset
)
==
((
new_color
&
foreground_mask
)
>>
fg_bitOffset
))
{
new_color
^=
FOREGROUND_INTENSITY
;
//invert intensity
}
return
new_color
;
}
#else
// Returns the ANSI color code for the given color. COLOR_DEFAULT is
...
...
@@ -2980,13 +3007,14 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
CONSOLE_SCREEN_BUFFER_INFO
buffer_info
;
GetConsoleScreenBufferInfo
(
stdout_handle
,
&
buffer_info
);
const
WORD
old_color_attrs
=
buffer_info
.
wAttributes
;
const
WORD
new_color
=
GetNewColor
(
color
,
old_color_attrs
);
// We need to flush the stream buffers into the console before each
// SetConsoleTextAttribute call lest it affect the text that is already
// printed but has not yet reached the console.
fflush
(
stdout
);
SetConsoleTextAttribute
(
stdout_handle
,
GetColorAttribute
(
color
)
|
FOREGROUND_INTENSITY
);
SetConsoleTextAttribute
(
stdout_handle
,
new_color
);
vprintf
(
fmt
,
args
);
fflush
(
stdout
);
...
...
googletest/test/BUILD.bazel
0 → 100644
View file @
c0037332
# Copyright 2017 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: misterg@google.com (Gennadiy Civil)
#
# Bazel BUILD for The Google C++ Testing Framework (Google Test)
licenses
([
"notice"
])
""" gtest own tests """
#on windows exclude gtest-tuple.h and gtest-tuple_test.cc
cc_test
(
name
=
"gtest_all_test"
,
size
=
"small"
,
srcs
=
glob
(
include
=
[
"gtest-*.cc"
,
"*.h"
,
"googletest/include/gtest/**/*.h"
,
],
exclude
=
[
"gtest-unittest-api_test.cc"
,
"gtest-tuple_test.cc"
,
"googletest/src/gtest-all.cc"
,
"gtest_all_test.cc"
,
"gtest-death-test_ex_test.cc"
,
"gtest-listener_test.cc"
,
"gtest-unittest-api_test.cc"
,
"gtest-param-test_test.cc"
,
],
)
+
select
({
"//:win"
:
[],
"//conditions:default"
:
[
"gtest-tuple_test.cc"
,
],
}),
copts
=
select
({
"//:win"
:
[
"-DGTEST_USE_OWN_TR1_TUPLE=0"
],
"//conditions:default"
:
[
"-DGTEST_USE_OWN_TR1_TUPLE=1"
],
}),
includes
=
[
"googletest"
,
"googletest/include"
,
"googletest/include/internal"
,
"googletest/test"
,
],
linkopts
=
select
({
"//:win"
:
[],
"//conditions:default"
:
[
"-pthread"
,
],
}),
deps
=
[
"//:gtest_main"
],
)
#These googletest tests have their own main()
cc_test
(
name
=
"gtest-listener_test"
,
size
=
"small"
,
srcs
=
[
"gtest-listener_test.cc"
,
],
deps
=
[
"//:gtest"
,
],
)
cc_test
(
name
=
"gtest-unittest-api_test"
,
size
=
"small"
,
srcs
=
[
"gtest-unittest-api_test.cc"
,
],
deps
=
[
"//:gtest"
,
],
)
cc_test
(
name
=
"gtest-param-test_test"
,
size
=
"small"
,
srcs
=
[
"gtest-param-test2_test.cc"
,
"gtest-param-test_test.cc"
,
"gtest-param-test_test.h"
,
],
deps
=
[
"//:gtest"
,
],
)
googletest/test/gtest-printers_test.cc
View file @
c0037332
...
...
@@ -187,6 +187,29 @@ inline ::std::ostream& operator<<(::std::ostream& os,
return
os
<<
"StreamableTemplateInFoo: "
<<
x
.
value
();
}
// A user-defined streamable but recursivly-defined container type in
// a user namespace, it mimics therefore std::filesystem::path or
// boost::filesystem::path.
class
PathLike
{
public:
struct
iterator
{
typedef
PathLike
value_type
;
};
typedef
iterator
const_iterator
;
PathLike
()
{}
iterator
begin
()
const
{
return
iterator
();
}
iterator
end
()
const
{
return
iterator
();
}
friend
::
std
::
ostream
&
operator
<<
(
::
std
::
ostream
&
os
,
const
PathLike
&
)
{
return
os
<<
"Streamable-PathLike"
;
}
};
}
// namespace foo
namespace
testing
{
...
...
@@ -1161,6 +1184,15 @@ TEST(PrintStreamableTypeTest, TemplateTypeInUserNamespace) {
Print
(
::
foo
::
StreamableTemplateInFoo
<
int
>
()));
}
// Tests printing a user-defined recursive container type that has a <<
// operator.
TEST
(
PrintStreamableTypeTest
,
PathLikeInUserNamespace
)
{
::
foo
::
PathLike
x
;
EXPECT_EQ
(
"Streamable-PathLike"
,
Print
(
x
));
const
::
foo
::
PathLike
cx
;
EXPECT_EQ
(
"Streamable-PathLike"
,
Print
(
cx
));
}
// Tests printing user-defined types that have a PrintTo() function.
TEST
(
PrintPrintableTypeTest
,
InUserNamespace
)
{
EXPECT_EQ
(
"PrintableViaPrintTo: 0"
,
...
...
Prev
1
2
3
4
5
6
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment