Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
5b5d62f1
Commit
5b5d62f1
authored
Mar 11, 2009
by
zhanyong.wan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Makes the code compile on Windows CE.
parent
93ad3551
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
6 deletions
+50
-6
gmock-actions.h
include/gmock/gmock-actions.h
+12
-0
gmock-printers.cc
src/gmock-printers.cc
+8
-4
gmock_main.cc
src/gmock_main.cc
+12
-1
gmock-actions_test.cc
test/gmock-actions_test.cc
+7
-0
gmock_link_test.h
test/gmock_link_test.h
+11
-1
No files found.
include/gmock/gmock-actions.h
View file @
5b5d62f1
...
@@ -38,7 +38,11 @@
...
@@ -38,7 +38,11 @@
#include <algorithm>
#include <algorithm>
#include <string>
#include <string>
#ifndef _WIN32_WCE
#include <errno.h>
#include <errno.h>
#endif
#include <gmock/internal/gmock-internal-utils.h>
#include <gmock/internal/gmock-internal-utils.h>
#include <gmock/internal/gmock-port.h>
#include <gmock/internal/gmock-port.h>
...
@@ -601,6 +605,8 @@ class AssignAction {
...
@@ -601,6 +605,8 @@ class AssignAction {
const
T2
value_
;
const
T2
value_
;
};
};
#ifndef _WIN32_WCE
// Implements the SetErrnoAndReturn action to simulate return from
// Implements the SetErrnoAndReturn action to simulate return from
// various system calls and libc functions.
// various system calls and libc functions.
template
<
typename
T
>
template
<
typename
T
>
...
@@ -619,6 +625,8 @@ class SetErrnoAndReturnAction {
...
@@ -619,6 +625,8 @@ class SetErrnoAndReturnAction {
const
T
result_
;
const
T
result_
;
};
};
#endif // _WIN32_WCE
// Implements the SetArgumentPointee<N>(x) action for any function
// Implements the SetArgumentPointee<N>(x) action for any function
// whose N-th argument (0-based) is a pointer to x's type. The
// whose N-th argument (0-based) is a pointer to x's type. The
// template parameter kIsProto is true iff type A is ProtocolMessage,
// template parameter kIsProto is true iff type A is ProtocolMessage,
...
@@ -878,6 +886,8 @@ PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {
...
@@ -878,6 +886,8 @@ PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {
return
MakePolymorphicAction
(
internal
::
AssignAction
<
T1
,
T2
>
(
ptr
,
val
));
return
MakePolymorphicAction
(
internal
::
AssignAction
<
T1
,
T2
>
(
ptr
,
val
));
}
}
#ifndef _WIN32_WCE
// Creates an action that sets errno and returns the appropriate error.
// Creates an action that sets errno and returns the appropriate error.
template
<
typename
T
>
template
<
typename
T
>
PolymorphicAction
<
internal
::
SetErrnoAndReturnAction
<
T
>
>
PolymorphicAction
<
internal
::
SetErrnoAndReturnAction
<
T
>
>
...
@@ -886,6 +896,8 @@ SetErrnoAndReturn(int errval, T result) {
...
@@ -886,6 +896,8 @@ SetErrnoAndReturn(int errval, T result) {
internal
::
SetErrnoAndReturnAction
<
T
>
(
errval
,
result
));
internal
::
SetErrnoAndReturnAction
<
T
>
(
errval
,
result
));
}
}
#endif // _WIN32_WCE
// Various overloads for InvokeWithoutArgs().
// Various overloads for InvokeWithoutArgs().
// Creates an action that invokes 'function_impl' with no argument.
// Creates an action that invokes 'function_impl' with no argument.
...
...
src/gmock-printers.cc
View file @
5b5d62f1
...
@@ -55,7 +55,9 @@ namespace {
...
@@ -55,7 +55,9 @@ namespace {
using
::
std
::
ostream
;
using
::
std
::
ostream
;
#if GTEST_OS_WINDOWS
#ifdef _WIN32_WCE
#define snprintf _snprintf
#elif GTEST_OS_WINDOWS
#define snprintf _snprintf_s
#define snprintf _snprintf_s
#endif
#endif
...
@@ -157,9 +159,11 @@ static void PrintAsWideCharLiteralTo(wchar_t c, ostream* os) {
...
@@ -157,9 +159,11 @@ static void PrintAsWideCharLiteralTo(wchar_t c, ostream* os) {
*
os
<<
"
\\
v"
;
*
os
<<
"
\\
v"
;
break
;
break
;
default
:
default
:
// isprint() takes an int and requires it to be either EOF or in
// Checks whether c is printable or not. Printable characters are in
// the range [0, 255]. We check that c is in this range before calling it.
// the range [0x20,0x7E].
if
((
c
&
0xFF
)
==
c
&&
isprint
(
c
))
{
// We test the value of c directly instead of calling isprint(), as
// isprint() is buggy on Windows mobile.
if
(
0x20
<=
c
&&
c
<=
0x7E
)
{
*
os
<<
static_cast
<
char
>
(
c
);
*
os
<<
static_cast
<
char
>
(
c
);
}
else
{
}
else
{
// Buffer size enough for the maximum number of digits and \0.
// Buffer size enough for the maximum number of digits and \0.
...
...
src/gmock_main.cc
View file @
5b5d62f1
...
@@ -33,7 +33,18 @@
...
@@ -33,7 +33,18 @@
#include <gmock/gmock.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
int
main
(
int
argc
,
char
**
argv
)
{
// MS C++ compiler/linker has a bug on Windows (not on Windows CE), which
// causes a link error when _tmain is defined in a static library and UNICODE
// is enabled. For this reason instead of _tmain, main function is used on
// Windows. See the following link to track the current status of this bug:
// http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=394464 // NOLINT
#ifdef _WIN32_WCE
#include <tchar.h> // NOLINT
int
_tmain
(
int
argc
,
TCHAR
**
argv
)
{
#else
int
main
(
int
argc
,
char
**
argv
)
{
#endif // _WIN32_WCE
std
::
cout
<<
"Running main() from gmock_main.cc
\n
"
;
std
::
cout
<<
"Running main() from gmock_main.cc
\n
"
;
// Since Google Mock depends on Google Test, InitGoogleMock() is
// Since Google Mock depends on Google Test, InitGoogleMock() is
// also responsible for initializing Google Test. Therefore there's
// also responsible for initializing Google Test. Therefore there's
...
...
test/gmock-actions_test.cc
View file @
5b5d62f1
...
@@ -69,7 +69,10 @@ using testing::ReturnNull;
...
@@ -69,7 +69,10 @@ using testing::ReturnNull;
using
testing
::
ReturnRef
;
using
testing
::
ReturnRef
;
using
testing
::
SetArgumentPointee
;
using
testing
::
SetArgumentPointee
;
using
testing
::
SetArrayArgument
;
using
testing
::
SetArrayArgument
;
#ifndef _WIN32_WCE
using
testing
::
SetErrnoAndReturn
;
using
testing
::
SetErrnoAndReturn
;
#endif // _WIN32_WCE
#if GMOCK_HAS_PROTOBUF_
#if GMOCK_HAS_PROTOBUF_
using
testing
::
internal
::
TestMessage
;
using
testing
::
internal
::
TestMessage
;
...
@@ -951,6 +954,8 @@ TEST(AssignTest, CompatibleTypes) {
...
@@ -951,6 +954,8 @@ TEST(AssignTest, CompatibleTypes) {
EXPECT_DOUBLE_EQ
(
5
,
x
);
EXPECT_DOUBLE_EQ
(
5
,
x
);
}
}
#ifndef _WIN32_WCE
class
SetErrnoAndReturnTest
:
public
testing
::
Test
{
class
SetErrnoAndReturnTest
:
public
testing
::
Test
{
protected
:
protected
:
virtual
void
SetUp
()
{
errno
=
0
;
}
virtual
void
SetUp
()
{
errno
=
0
;
}
...
@@ -976,4 +981,6 @@ TEST_F(SetErrnoAndReturnTest, CompatibleTypes) {
...
@@ -976,4 +981,6 @@ TEST_F(SetErrnoAndReturnTest, CompatibleTypes) {
EXPECT_EQ
(
EINVAL
,
errno
);
EXPECT_EQ
(
EINVAL
,
errno
);
}
}
#endif // _WIN32_WCE
}
// Unnamed namespace
}
// Unnamed namespace
test/gmock_link_test.h
View file @
5b5d62f1
...
@@ -116,7 +116,10 @@
...
@@ -116,7 +116,10 @@
#include <gmock/gmock.h>
#include <gmock/gmock.h>
#ifndef _WIN32_WCE
#include <errno.h>
#include <errno.h>
#endif
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <iostream>
#include <iostream>
#include <vector>
#include <vector>
...
@@ -161,7 +164,6 @@ using testing::ReturnNull;
...
@@ -161,7 +164,6 @@ using testing::ReturnNull;
using
testing
::
ReturnRef
;
using
testing
::
ReturnRef
;
using
testing
::
SetArgumentPointee
;
using
testing
::
SetArgumentPointee
;
using
testing
::
SetArrayArgument
;
using
testing
::
SetArrayArgument
;
using
testing
::
SetErrnoAndReturn
;
using
testing
::
StartsWith
;
using
testing
::
StartsWith
;
using
testing
::
StrCaseEq
;
using
testing
::
StrCaseEq
;
using
testing
::
StrCaseNe
;
using
testing
::
StrCaseNe
;
...
@@ -173,6 +175,10 @@ using testing::WithArg;
...
@@ -173,6 +175,10 @@ using testing::WithArg;
using
testing
::
WithArgs
;
using
testing
::
WithArgs
;
using
testing
::
WithoutArgs
;
using
testing
::
WithoutArgs
;
#ifndef _WIN32_WCE
using
testing
::
SetErrnoAndReturn
;
#endif // _WIN32_WCE
#if GTEST_HAS_EXCEPTIONS
#if GTEST_HAS_EXCEPTIONS
using
testing
::
Throw
;
using
testing
::
Throw
;
#endif // GTEST_HAS_EXCEPTIONS
#endif // GTEST_HAS_EXCEPTIONS
...
@@ -290,6 +296,8 @@ TEST(LinkTest, TestSetArrayArgument) {
...
@@ -290,6 +296,8 @@ TEST(LinkTest, TestSetArrayArgument) {
mock
.
VoidFromString
(
&
ch
);
mock
.
VoidFromString
(
&
ch
);
}
}
#ifndef _WIN32_WCE
// Tests the linkage of the SetErrnoAndReturn action.
// Tests the linkage of the SetErrnoAndReturn action.
TEST
(
LinkTest
,
TestSetErrnoAndReturn
)
{
TEST
(
LinkTest
,
TestSetErrnoAndReturn
)
{
Mock
mock
;
Mock
mock
;
...
@@ -300,6 +308,8 @@ TEST(LinkTest, TestSetErrnoAndReturn) {
...
@@ -300,6 +308,8 @@ TEST(LinkTest, TestSetErrnoAndReturn) {
errno
=
saved_errno
;
errno
=
saved_errno
;
}
}
#endif // _WIN32_WCE
// Tests the linkage of the Invoke(function) and Invoke(object, method) actions.
// Tests the linkage of the Invoke(function) and Invoke(object, method) actions.
TEST
(
LinkTest
,
TestInvoke
)
{
TEST
(
LinkTest
,
TestInvoke
)
{
Mock
mock
;
Mock
mock
;
...
...
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