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
c6e674db
"googlemock/vscode:/vscode.git/clone" did not exist on "56ef07a20308b57f940936c6979f5d6d3837d8c6"
Commit
c6e674db
authored
Aug 20, 2008
by
shiqian
Browse files
Adds a sample on using Google Test as a Mac framework. By Preston Jackson.
parent
d5f13d4a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
553 additions
and
0 deletions
+553
-0
xcode/Samples/FrameworkSample/Info.plist
xcode/Samples/FrameworkSample/Info.plist
+28
-0
xcode/Samples/FrameworkSample/WidgetFramework.xcodeproj/project.pbxproj
...FrameworkSample/WidgetFramework.xcodeproj/project.pbxproj
+335
-0
xcode/Samples/FrameworkSample/widget.cc
xcode/Samples/FrameworkSample/widget.cc
+63
-0
xcode/Samples/FrameworkSample/widget.h
xcode/Samples/FrameworkSample/widget.h
+59
-0
xcode/Samples/FrameworkSample/widget_test.cc
xcode/Samples/FrameworkSample/widget_test.cc
+68
-0
No files found.
xcode/Samples/FrameworkSample/Info.plist
0 → 100644
View file @
c6e674db
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
CFBundleDevelopmentRegion
</key>
<string>
English
</string>
<key>
CFBundleExecutable
</key>
<string>
${EXECUTABLE_NAME}
</string>
<key>
CFBundleIconFile
</key>
<string></string>
<key>
CFBundleIdentifier
</key>
<string>
com.google.gtest.${PRODUCT_NAME:identifier}
</string>
<key>
CFBundleInfoDictionaryVersion
</key>
<string>
6.0
</string>
<key>
CFBundleName
</key>
<string>
${PRODUCT_NAME}
</string>
<key>
CFBundlePackageType
</key>
<string>
FMWK
</string>
<key>
CFBundleShortVersionString
</key>
<string>
1.0
</string>
<key>
CFBundleSignature
</key>
<string>
????
</string>
<key>
CFBundleVersion
</key>
<string>
1.0
</string>
<key>
CSResourcesFileMapped
</key>
<true/>
</dict>
</plist>
xcode/Samples/FrameworkSample/WidgetFramework.xcodeproj/project.pbxproj
0 → 100644
View file @
c6e674db
// !$*UTF8*$!
{
archiveVersion
=
1
;
classes
=
{
};
objectVersion
=
45
;
objects
=
{
/* Begin PBXBuildFile section */
3B7EB1250E5AEE3500C7F239
/* widget.cc in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3B7EB1230E5AEE3500C7F239
/* widget.cc */
;
};
3B7EB1260E5AEE3500C7F239
/* widget.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3B7EB1240E5AEE3500C7F239
/* widget.h */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
3B7EB1280E5AEE4600C7F239
/* widget_test.cc in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3B7EB1270E5AEE4600C7F239
/* widget_test.cc */
;
};
3B7EB1480E5AF3B400C7F239
/* Widget.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8D07F2C80486CC7A007CD1D0
/* Widget.framework */
;
};
3B7F0C8D0E567CC5009CA236
/* gtest.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3BA867DC0E561B7C00326077
/* gtest.framework */
;
};
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
3B07BDF00E3F3FAE00647869
/* PBXContainerItemProxy */
=
{
isa
=
PBXContainerItemProxy
;
containerPortal
=
0867D690FE84028FC02AAC07
/* Project object */
;
proxyType
=
1
;
remoteGlobalIDString
=
8D07F2BC0486CC7A007CD1D0
;
remoteInfo
=
gTestExample
;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
3B07BDEA0E3F3F9E00647869
/* WidgetFrameworkTest */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
"compiled.mach-o.executable"
;
includeInIndex
=
0
;
path
=
WidgetFrameworkTest
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
3B7EB1230E5AEE3500C7F239
/* widget.cc */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.cpp.cpp
;
path
=
widget.cc
;
sourceTree
=
"<group>"
;
};
3B7EB1240E5AEE3500C7F239
/* widget.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
widget.h
;
sourceTree
=
"<group>"
;
};
3B7EB1270E5AEE4600C7F239
/* widget_test.cc */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.cpp.cpp
;
path
=
widget_test.cc
;
sourceTree
=
"<group>"
;
};
3BA867DC0E561B7C00326077
/* gtest.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
name
=
gtest.framework
;
path
=
../../build/Debug/gtest.framework
;
sourceTree
=
"<group>"
;
};
8D07F2C70486CC7A007CD1D0
/* Info.plist */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.plist
;
path
=
Info.plist
;
sourceTree
=
"<group>"
;
};
8D07F2C80486CC7A007CD1D0
/* Widget.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
includeInIndex
=
0
;
path
=
Widget.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
3B07BDE80E3F3F9E00647869
/* Frameworks */
=
{
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
3B7EB1480E5AF3B400C7F239
/* Widget.framework in Frameworks */
,
3B7F0C8D0E567CC5009CA236
/* gtest.framework in Frameworks */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
8D07F2C30486CC7A007CD1D0
/* Frameworks */
=
{
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
);
runOnlyForDeploymentPostprocessing
=
0
;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
034768DDFF38A45A11DB9C8B
/* Products */
=
{
isa
=
PBXGroup
;
children
=
(
8D07F2C80486CC7A007CD1D0
/* Widget.framework */
,
3B07BDEA0E3F3F9E00647869
/* WidgetFrameworkTest */
,
);
name
=
Products
;
sourceTree
=
"<group>"
;
};
0867D691FE84028FC02AAC07
/* gTestExample */
=
{
isa
=
PBXGroup
;
children
=
(
08FB77ACFE841707C02AAC07
/* Source */
,
089C1665FE841158C02AAC07
/* Resources */
,
3B07BE350E4094E400647869
/* Test */
,
0867D69AFE84028FC02AAC07
/* External Frameworks and Libraries */
,
034768DDFF38A45A11DB9C8B
/* Products */
,
);
name
=
gTestExample
;
sourceTree
=
"<group>"
;
};
0867D69AFE84028FC02AAC07
/* External Frameworks and Libraries */
=
{
isa
=
PBXGroup
;
children
=
(
3BA867DC0E561B7C00326077
/* gtest.framework */
,
);
name
=
"External Frameworks and Libraries"
;
sourceTree
=
"<group>"
;
};
089C1665FE841158C02AAC07
/* Resources */
=
{
isa
=
PBXGroup
;
children
=
(
8D07F2C70486CC7A007CD1D0
/* Info.plist */
,
);
name
=
Resources
;
sourceTree
=
"<group>"
;
};
08FB77ACFE841707C02AAC07
/* Source */
=
{
isa
=
PBXGroup
;
children
=
(
3B7EB1230E5AEE3500C7F239
/* widget.cc */
,
3B7EB1240E5AEE3500C7F239
/* widget.h */
,
);
name
=
Source
;
sourceTree
=
"<group>"
;
};
3B07BE350E4094E400647869
/* Test */
=
{
isa
=
PBXGroup
;
children
=
(
3B7EB1270E5AEE4600C7F239
/* widget_test.cc */
,
);
name
=
Test
;
sourceTree
=
"<group>"
;
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
8D07F2BD0486CC7A007CD1D0
/* Headers */
=
{
isa
=
PBXHeadersBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
3B7EB1260E5AEE3500C7F239
/* widget.h in Headers */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
3B07BDE90E3F3F9E00647869
/* WidgetFrameworkTest */
=
{
isa
=
PBXNativeTarget
;
buildConfigurationList
=
3B07BDF40E3F3FB600647869
/* Build configuration list for PBXNativeTarget "WidgetFrameworkTest" */
;
buildPhases
=
(
3B07BDE70E3F3F9E00647869
/* Sources */
,
3B07BDE80E3F3F9E00647869
/* Frameworks */
,
);
buildRules
=
(
);
dependencies
=
(
3B07BDF10E3F3FAE00647869
/* PBXTargetDependency */
,
);
name
=
WidgetFrameworkTest
;
productName
=
gTestExampleTest
;
productReference
=
3B07BDEA0E3F3F9E00647869
/* WidgetFrameworkTest */
;
productType
=
"com.apple.product-type.tool"
;
};
8D07F2BC0486CC7A007CD1D0
/* WidgetFramework */
=
{
isa
=
PBXNativeTarget
;
buildConfigurationList
=
4FADC24208B4156D00ABE55E
/* Build configuration list for PBXNativeTarget "WidgetFramework" */
;
buildPhases
=
(
8D07F2C10486CC7A007CD1D0
/* Sources */
,
8D07F2C30486CC7A007CD1D0
/* Frameworks */
,
8D07F2BD0486CC7A007CD1D0
/* Headers */
,
8D07F2BF0486CC7A007CD1D0
/* Resources */
,
8D07F2C50486CC7A007CD1D0
/* Rez */
,
);
buildRules
=
(
);
dependencies
=
(
);
name
=
WidgetFramework
;
productInstallPath
=
"$(HOME)/Library/Frameworks"
;
productName
=
gTestExample
;
productReference
=
8D07F2C80486CC7A007CD1D0
/* Widget.framework */
;
productType
=
"com.apple.product-type.framework"
;
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
0867D690FE84028FC02AAC07
/* Project object */
=
{
isa
=
PBXProject
;
buildConfigurationList
=
4FADC24608B4156D00ABE55E
/* Build configuration list for PBXProject "WidgetFramework" */
;
compatibilityVersion
=
"Xcode 3.1"
;
hasScannedForEncodings
=
1
;
mainGroup
=
0867D691FE84028FC02AAC07
/* gTestExample */
;
productRefGroup
=
034768DDFF38A45A11DB9C8B
/* Products */
;
projectDirPath
=
""
;
projectRoot
=
""
;
targets
=
(
8D07F2BC0486CC7A007CD1D0
/* WidgetFramework */
,
3B07BDE90E3F3F9E00647869
/* WidgetFrameworkTest */
,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
8D07F2BF0486CC7A007CD1D0
/* Resources */
=
{
isa
=
PBXResourcesBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
);
runOnlyForDeploymentPostprocessing
=
0
;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXRezBuildPhase section */
8D07F2C50486CC7A007CD1D0
/* Rez */
=
{
isa
=
PBXRezBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
);
runOnlyForDeploymentPostprocessing
=
0
;
};
/* End PBXRezBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
3B07BDE70E3F3F9E00647869
/* Sources */
=
{
isa
=
PBXSourcesBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
3B7EB1280E5AEE4600C7F239
/* widget_test.cc in Sources */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
8D07F2C10486CC7A007CD1D0
/* Sources */
=
{
isa
=
PBXSourcesBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
3B7EB1250E5AEE3500C7F239
/* widget.cc in Sources */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
3B07BDF10E3F3FAE00647869
/* PBXTargetDependency */
=
{
isa
=
PBXTargetDependency
;
target
=
8D07F2BC0486CC7A007CD1D0
/* WidgetFramework */
;
targetProxy
=
3B07BDF00E3F3FAE00647869
/* PBXContainerItemProxy */
;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
3B07BDEC0E3F3F9F00647869
/* Debug */
=
{
isa
=
XCBuildConfiguration
;
buildSettings
=
{
FRAMEWORK_SEARCH_PATHS
=
(
"$(inherited)"
,
"\"$(SRCROOT)/externals/googletest/xcode/build/Debug\""
,
"\"$(SRCROOT)/../../build/Debug\""
,
);
INSTALL_PATH
=
/usr/local/bin
;
PRODUCT_NAME
=
WidgetFrameworkTest
;
};
name
=
Debug
;
};
3B07BDED0E3F3F9F00647869
/* Release */
=
{
isa
=
XCBuildConfiguration
;
buildSettings
=
{
FRAMEWORK_SEARCH_PATHS
=
(
"$(inherited)"
,
"\"$(SRCROOT)/externals/googletest/xcode/build/Debug\""
,
"\"$(SRCROOT)/../../build/Debug\""
,
);
INSTALL_PATH
=
/usr/local/bin
;
PRODUCT_NAME
=
WidgetFrameworkTest
;
};
name
=
Release
;
};
4FADC24308B4156D00ABE55E
/* Debug */
=
{
isa
=
XCBuildConfiguration
;
buildSettings
=
{
DYLIB_COMPATIBILITY_VERSION
=
1
;
DYLIB_CURRENT_VERSION
=
1
;
FRAMEWORK_VERSION
=
A
;
INFOPLIST_FILE
=
Info.plist
;
INSTALL_PATH
=
"@loader_path/../Frameworks"
;
LIBRARY_STYLE
=
DYNAMIC
;
MACH_O_TYPE
=
mh_dylib
;
PRODUCT_NAME
=
Widget
;
WRAPPER_EXTENSION
=
framework
;
};
name
=
Debug
;
};
4FADC24408B4156D00ABE55E
/* Release */
=
{
isa
=
XCBuildConfiguration
;
buildSettings
=
{
DYLIB_COMPATIBILITY_VERSION
=
1
;
DYLIB_CURRENT_VERSION
=
1
;
FRAMEWORK_VERSION
=
A
;
INFOPLIST_FILE
=
Info.plist
;
INSTALL_PATH
=
"@loader_path/../Frameworks"
;
LIBRARY_STYLE
=
DYNAMIC
;
MACH_O_TYPE
=
mh_dylib
;
PRODUCT_NAME
=
Widget
;
WRAPPER_EXTENSION
=
framework
;
};
name
=
Release
;
};
4FADC24708B4156D00ABE55E
/* Debug */
=
{
isa
=
XCBuildConfiguration
;
buildSettings
=
{
ARCHS
=
"$(ARCHS_STANDARD_32_BIT)"
;
ONLY_ACTIVE_ARCH
=
YES
;
SDKROOT
=
macosx10.5
;
};
name
=
Debug
;
};
4FADC24808B4156D00ABE55E
/* Release */
=
{
isa
=
XCBuildConfiguration
;
buildSettings
=
{
ARCHS
=
"$(ARCHS_STANDARD_32_BIT)"
;
SDKROOT
=
macosx10.5
;
};
name
=
Release
;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
3B07BDF40E3F3FB600647869
/* Build configuration list for PBXNativeTarget "WidgetFrameworkTest" */
=
{
isa
=
XCConfigurationList
;
buildConfigurations
=
(
3B07BDEC0E3F3F9F00647869
/* Debug */
,
3B07BDED0E3F3F9F00647869
/* Release */
,
);
defaultConfigurationIsVisible
=
0
;
defaultConfigurationName
=
Release
;
};
4FADC24208B4156D00ABE55E
/* Build configuration list for PBXNativeTarget "WidgetFramework" */
=
{
isa
=
XCConfigurationList
;
buildConfigurations
=
(
4FADC24308B4156D00ABE55E
/* Debug */
,
4FADC24408B4156D00ABE55E
/* Release */
,
);
defaultConfigurationIsVisible
=
0
;
defaultConfigurationName
=
Release
;
};
4FADC24608B4156D00ABE55E
/* Build configuration list for PBXProject "WidgetFramework" */
=
{
isa
=
XCConfigurationList
;
buildConfigurations
=
(
4FADC24708B4156D00ABE55E
/* Debug */
,
4FADC24808B4156D00ABE55E
/* Release */
,
);
defaultConfigurationIsVisible
=
0
;
defaultConfigurationName
=
Release
;
};
/* End XCConfigurationList section */
};
rootObject
=
0867D690FE84028FC02AAC07
/* Project object */
;
}
xcode/Samples/FrameworkSample/widget.cc
0 → 100644
View file @
c6e674db
// 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: preston.jackson@gmail.com (Preston Jackson)
//
// Google Test - FrameworkSample
// widget.cc
//
// Widget is a very simple class used for demonstrating the use of gtest
#include "widget.h"
Widget
::
Widget
(
int
number
,
const
std
::
string
&
name
)
:
number_
(
number
),
name_
(
name
)
{}
Widget
::~
Widget
()
{}
float
Widget
::
GetFloatValue
()
const
{
return
number_
;
}
int
Widget
::
GetIntValue
()
const
{
return
static_cast
<
int
>
(
number_
);
}
std
::
string
Widget
::
GetStringValue
()
const
{
return
name_
;
}
void
Widget
::
GetCharPtrValue
(
char
*
buffer
,
size_t
max_size
)
const
{
// Copy the char* representation of name_ into buffer, up to max_size.
strncpy
(
buffer
,
name_
.
c_str
(),
max_size
-
1
);
buffer
[
max_size
-
1
]
=
'\0'
;
return
;
}
xcode/Samples/FrameworkSample/widget.h
0 → 100644
View file @
c6e674db
// 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: preston.jackson@gmail.com (Preston Jackson)
//
// Google Test - FrameworkSample
// widget.h
//
// Widget is a very simple class used for demonstrating the use of gtest. It
// simply stores two values a string and an integer, which are returned via
// public accessors in multiple forms.
#import <string>
class
Widget
{
public:
Widget
(
int
number
,
const
std
::
string
&
name
);
~
Widget
();
// Public accessors to number data
float
GetFloatValue
()
const
;
int
GetIntValue
()
const
;
// Public accessors to the string data
std
::
string
GetStringValue
()
const
;
void
GetCharPtrValue
(
char
*
buffer
,
size_t
max_size
)
const
;
private:
// Data members
float
number_
;
std
::
string
name_
;
};
xcode/Samples/FrameworkSample/widget_test.cc
0 → 100644
View file @
c6e674db
// 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: preston.jackson@gmail.com (Preston Jackson)
//
// Google Test - FrameworkSample
// widget_test.cc
//
// This is a simple test file for the Widget class in the Widget.framework
#include <string>
#include <gtest/gtest.h>
#include <Widget/widget.h>
// This test verifies that the constructor sets the internal state of the
// Widget class correctly.
TEST
(
WidgetInitializerTest
,
TestConstructor
)
{
Widget
widget
(
1.0
f
,
"name"
);
EXPECT_FLOAT_EQ
(
1.0
f
,
widget
.
GetFloatValue
());
EXPECT_EQ
(
std
::
string
(
"name"
),
widget
.
GetStringValue
());
}
// This test verifies the conversion of the float and string values to int and
// char*, respectively.
TEST
(
WidgetInitializerTest
,
TestConversion
)
{
Widget
widget
(
1.0
f
,
"name"
);
EXPECT_EQ
(
1
,
widget
.
GetIntValue
());
size_t
max_size
=
128
;
char
buffer
[
max_size
];
widget
.
GetCharPtrValue
(
buffer
,
max_size
);
EXPECT_STREQ
(
"name"
,
buffer
);
}
// Use the Google Test main that is linked into the framework. It does something
// like this:
// int main(int argc, char** argv) {
// testing::InitGoogleTest(&argc, argv);
// return RUN_ALL_TESTS();
// }
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