├── test
├── gtest
│ ├── xcode
│ │ ├── Config
│ │ │ ├── TestTarget.xcconfig
│ │ │ ├── FrameworkTarget.xcconfig
│ │ │ ├── StaticLibraryTarget.xcconfig
│ │ │ ├── DebugProject.xcconfig
│ │ │ ├── ReleaseProject.xcconfig
│ │ │ └── General.xcconfig
│ │ ├── Samples
│ │ │ └── FrameworkSample
│ │ │ │ ├── Info.plist
│ │ │ │ ├── widget.h
│ │ │ │ ├── widget.cc
│ │ │ │ ├── runtests.sh
│ │ │ │ └── widget_test.cc
│ │ ├── Resources
│ │ │ └── Info.plist
│ │ └── Scripts
│ │ │ └── runtests.sh
│ ├── m4
│ │ ├── ltversion.m4
│ │ ├── gtest.m4
│ │ └── ltsugar.m4
│ ├── CONTRIBUTORS
│ ├── COPYING
│ ├── test
│ │ ├── production.cc
│ │ ├── gtest_main_unittest.cc
│ │ ├── gtest_uninitialized_test_.cc
│ │ ├── gtest_xml_outfile1_test_.cc
│ │ ├── gtest_xml_outfile2_test_.cc
│ │ ├── gtest-typed-test2_test.cc
│ │ ├── gtest_help_test_.cc
│ │ ├── production.h
│ │ ├── gtest_all_test.cc
│ │ ├── gtest_prod_test.cc
│ │ ├── gtest_sole_header_test.cc
│ │ ├── gtest-param-test_test.h
│ │ ├── gtest_no_test_unittest.cc
│ │ ├── gtest-typed-test_test.h
│ │ ├── gtest_throw_on_failure_test_.cc
│ │ ├── gtest_uninitialized_test.py
│ │ ├── gtest_list_tests_unittest_.cc
│ │ ├── gtest-param-test2_test.cc
│ │ ├── gtest_color_test_.cc
│ │ ├── gtest_break_on_failure_unittest_.cc
│ │ ├── gtest_throw_on_failure_ex_test.cc
│ │ ├── gtest_shuffle_test_.cc
│ │ ├── gtest_env_var_test.py
│ │ ├── gtest-death-test_ex_test.cc
│ │ ├── gtest_env_var_test_.cc
│ │ ├── gtest_filter_unittest_.cc
│ │ └── gtest-linked_ptr_test.cc
│ ├── src
│ │ ├── gtest_main.cc
│ │ ├── gtest-all.cc
│ │ ├── gtest-typed-test.cc
│ │ └── gtest-test-part.cc
│ ├── fused-src
│ │ └── gtest
│ │ │ └── gtest_main.cc
│ ├── codegear
│ │ ├── gtest_all.cc
│ │ ├── gtest_link.cc
│ │ └── gtest.groupproj
│ ├── scripts
│ │ └── test
│ │ │ └── Makefile
│ ├── samples
│ │ ├── sample4_unittest.cc
│ │ ├── sample1.h
│ │ ├── sample4.cc
│ │ ├── sample4.h
│ │ ├── sample2.cc
│ │ ├── sample1.cc
│ │ ├── sample2.h
│ │ ├── sample2_unittest.cc
│ │ └── prime_tables.h
│ ├── build-aux
│ │ └── config.h.in
│ ├── include
│ │ └── gtest
│ │ │ └── gtest_prod.h
│ ├── msvc
│ │ ├── gtest.sln
│ │ ├── gtest-md.sln
│ │ ├── gtest.vcproj
│ │ ├── gtest-md.vcproj
│ │ ├── gtest_main.vcproj
│ │ ├── gtest_main-md.vcproj
│ │ ├── gtest_unittest.vcproj
│ │ └── gtest_unittest-md.vcproj
│ ├── configure.ac
│ └── make
│ │ └── Makefile
└── example.cpp
├── .gitignore
├── src
└── utils
│ ├── metadata.hpp
│ └── wholeFunctionVectorizationAAW.hpp
├── include
├── packetizerAPI_C.h
└── packetizerAPI.hpp
├── COPYING
└── CODINGSTANDARDS
/test/gtest/xcode/Config/TestTarget.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // TestTarget.xcconfig
3 | //
4 | // These are Test target settings for the gtest framework and examples. It
5 | // is set in the "Based On:" dropdown in the "Target" info dialog.
6 |
7 | PRODUCT_NAME = $(TARGET_NAME)
8 | HEADER_SEARCH_PATHS = ../include
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *~
2 | *.o
3 | .sconsign.dblite
4 | *.so
5 | *.bak
6 | *.os
7 | *.a
8 | build
9 | *.bc
10 | packetizeFunction
11 | wfvTestSuite
12 | wfvUnitTests
13 | packetizeFunction.exe
14 | wfvTestSuite.exe
15 | wfvUnitTests.exe
16 | *.ll
17 | *.pdb
18 | obj
19 | lib
20 | test/gtest/make/sample1_unittest*
21 |
22 | # eclipse
23 | .project
24 | .cproject
25 |
26 | # vim
27 | *.swp
28 |
29 | # netbeans
30 | nbproject
31 |
--------------------------------------------------------------------------------
/src/utils/metadata.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * @file: metadata.hpp
3 | * @date 02.12.2011
4 | * @author Ralf Karrenberg
5 | *
6 | * This file is distributed under the University of Illinois Open Source
7 | * License. See the COPYING file in the root directory for details.
8 | *
9 | * Copyright (C) 2011 Saarland University
10 | */
11 |
12 | #ifndef METADATA_HPP
13 | #define METADATA_HPP
14 |
15 | namespace Packetizer {
16 |
17 | static const char* WFV_META_ARG_CAST = "wfv_arg_cast";
18 |
19 | }
20 |
21 | #endif /* METADATA_HPP */
22 |
23 |
--------------------------------------------------------------------------------
/test/gtest/xcode/Config/FrameworkTarget.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // FrameworkTarget.xcconfig
3 | //
4 | // These are Framework target settings for the gtest framework and examples. It
5 | // is set in the "Based On:" dropdown in the "Target" info dialog.
6 | // This file is based on the Xcode Configuration files in:
7 | // http://code.google.com/p/google-toolbox-for-mac/
8 | //
9 |
10 | // Dynamic libs need to be position independent
11 | GCC_DYNAMIC_NO_PIC = NO
12 |
13 | // Dynamic libs should not have their external symbols stripped.
14 | STRIP_STYLE = non-global
15 |
16 | // Let the user install by specifying the $DSTROOT with xcodebuild
17 | SKIP_INSTALL = NO
18 |
--------------------------------------------------------------------------------
/test/gtest/xcode/Config/StaticLibraryTarget.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // StaticLibraryTarget.xcconfig
3 | //
4 | // These are static library target settings for libgtest.a. It
5 | // is set in the "Based On:" dropdown in the "Target" info dialog.
6 | // This file is based on the Xcode Configuration files in:
7 | // http://code.google.com/p/google-toolbox-for-mac/
8 | //
9 |
10 | // Static libs can be included in bundles so make them position independent
11 | GCC_DYNAMIC_NO_PIC = NO
12 |
13 | // Static libs should not have their internal globals or external symbols
14 | // stripped.
15 | STRIP_STYLE = debugging
16 |
17 | // Let the user install by specifying the $DSTROOT with xcodebuild
18 | SKIP_INSTALL = NO
19 |
--------------------------------------------------------------------------------
/test/gtest/m4/ltversion.m4:
--------------------------------------------------------------------------------
1 | # ltversion.m4 -- version numbers -*- Autoconf -*-
2 | #
3 | # Copyright (C) 2004 Free Software Foundation, Inc.
4 | # Written by Scott James Remnant, 2004
5 | #
6 | # This file is free software; the Free Software Foundation gives
7 | # unlimited permission to copy and/or distribute it, with or without
8 | # modifications, as long as this notice is preserved.
9 |
10 | # Generated from ltversion.in.
11 |
12 | # serial 3017 ltversion.m4
13 | # This file is part of GNU Libtool
14 |
15 | m4_define([LT_PACKAGE_VERSION], [2.2.6b])
16 | m4_define([LT_PACKAGE_REVISION], [1.3017])
17 |
18 | AC_DEFUN([LTVERSION_VERSION],
19 | [macro_version='2.2.6b'
20 | macro_revision='1.3017'
21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
22 | _LT_DECL(, macro_revision, 0)
23 | ])
24 |
--------------------------------------------------------------------------------
/test/gtest/xcode/Samples/FrameworkSample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | com.google.gtest.${PRODUCT_NAME:identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | FMWK
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | CSResourcesFileMapped
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/test/gtest/xcode/Config/DebugProject.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // DebugProject.xcconfig
3 | //
4 | // These are Debug Configuration project settings for the gtest framework and
5 | // examples. It is set in the "Based On:" dropdown in the "Project" info
6 | // dialog.
7 | // This file is based on the Xcode Configuration files in:
8 | // http://code.google.com/p/google-toolbox-for-mac/
9 | //
10 |
11 | #include "General.xcconfig"
12 |
13 | // No optimization
14 | GCC_OPTIMIZATION_LEVEL = 0
15 |
16 | // Deployment postprocessing is what triggers Xcode to strip, turn it off
17 | DEPLOYMENT_POSTPROCESSING = NO
18 |
19 | // Dead code stripping off
20 | DEAD_CODE_STRIPPING = NO
21 |
22 | // Debug symbols should be on obviously
23 | GCC_GENERATE_DEBUGGING_SYMBOLS = YES
24 |
25 | // Define the DEBUG macro in all debug builds
26 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DDEBUG=1
27 |
28 | // These are turned off to avoid STL incompatibilities with client code
29 | // // Turns on special C++ STL checks to "encourage" good STL use
30 | // GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) _GLIBCXX_DEBUG_PEDANTIC _GLIBCXX_DEBUG _GLIBCPP_CONCEPT_CHECKS
31 |
--------------------------------------------------------------------------------
/test/gtest/xcode/Resources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | com.google.${PRODUCT_NAME}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | GTEST_VERSIONINFO_LONG
21 | CFBundleShortVersionString
22 | GTEST_VERSIONINFO_SHORT
23 | CFBundleGetInfoString
24 | ${PRODUCT_NAME} GTEST_VERSIONINFO_LONG, ${GTEST_VERSIONINFO_ABOUT}
25 | NSHumanReadableCopyright
26 | ${GTEST_VERSIONINFO_ABOUT}
27 | CSResourcesFileMapped
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/test/gtest/xcode/Config/ReleaseProject.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // ReleaseProject.xcconfig
3 | //
4 | // These are Release Configuration project settings for the gtest framework
5 | // and examples. It is set in the "Based On:" dropdown in the "Project" info
6 | // dialog.
7 | // This file is based on the Xcode Configuration files in:
8 | // http://code.google.com/p/google-toolbox-for-mac/
9 | //
10 |
11 | #include "General.xcconfig"
12 |
13 | // subconfig/Release.xcconfig
14 |
15 | // Optimize for space and size (Apple recommendation)
16 | GCC_OPTIMIZATION_LEVEL = s
17 |
18 | // Deploment postprocessing is what triggers Xcode to strip
19 | DEPLOYMENT_POSTPROCESSING = YES
20 |
21 | // No symbols
22 | GCC_GENERATE_DEBUGGING_SYMBOLS = NO
23 |
24 | // Dead code strip does not affect ObjC code but can help for C
25 | DEAD_CODE_STRIPPING = YES
26 |
27 | // NDEBUG is used by things like assert.h, so define it for general compat.
28 | // ASSERT going away in release tends to create unused vars.
29 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DNDEBUG=1 -Wno-unused-variable
30 |
31 | // When we strip we want to strip all symbols in release, but save externals.
32 | STRIP_STYLE = all
33 |
--------------------------------------------------------------------------------
/test/gtest/xcode/Config/General.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // General.xcconfig
3 | //
4 | // These are General configuration settings for the gtest framework and
5 | // examples.
6 | // This file is based on the Xcode Configuration files in:
7 | // http://code.google.com/p/google-toolbox-for-mac/
8 | //
9 |
10 | // Build for PPC and Intel, 32- and 64-bit
11 | ARCHS = i386 x86_64 ppc ppc64
12 |
13 | // Zerolink prevents link warnings so turn it off
14 | ZERO_LINK = NO
15 |
16 | // Prebinding considered unhelpful in 10.3 and later
17 | PREBINDING = NO
18 |
19 | // Strictest warning policy
20 | WARNING_CFLAGS = -Wall -Werror -Wendif-labels -Wnewline-eof -Wno-sign-compare -Wshadow
21 |
22 | // Work around Xcode bugs by using external strip. See:
23 | // http://lists.apple.com/archives/Xcode-users/2006/Feb/msg00050.html
24 | SEPARATE_STRIP = YES
25 |
26 | // Force C99 dialect
27 | GCC_C_LANGUAGE_STANDARD = c99
28 |
29 | // not sure why apple defaults this on, but it's pretty risky
30 | ALWAYS_SEARCH_USER_PATHS = NO
31 |
32 | // Turn on position dependent code for most cases (overridden where appropriate)
33 | GCC_DYNAMIC_NO_PIC = YES
34 |
35 | // Default SDK and minimum OS version is 10.4
36 | SDKROOT = $(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk
37 | MACOSX_DEPLOYMENT_TARGET = 10.4
38 | GCC_VERSION = 4.0
39 |
40 | // VERSIONING BUILD SETTINGS (used in Info.plist)
41 | GTEST_VERSIONINFO_ABOUT = © 2008 Google Inc.
42 |
--------------------------------------------------------------------------------
/test/gtest/CONTRIBUTORS:
--------------------------------------------------------------------------------
1 | # This file contains a list of people who've made non-trivial
2 | # contribution to the Google C++ Testing Framework project. People
3 | # who commit code to the project are encouraged to add their names
4 | # here. Please keep the list sorted by first names.
5 |
6 | Ajay Joshi
7 | Balázs Dán
8 | Bharat Mediratta
9 | Chandler Carruth
10 | Chris Prince
11 | Chris Taylor
12 | Dan Egnor
13 | Eric Roman
14 | Hady Zalek
15 | Jeffrey Yasskin
16 | Jói Sigurðsson
17 | Keir Mierle
18 | Keith Ray
19 | Kenton Varda
20 | Manuel Klimek
21 | Markus Heule
22 | Mika Raento
23 | Miklós Fazekas
24 | Pasi Valminen
25 | Patrick Hanna
26 | Patrick Riley
27 | Peter Kaminski
28 | Preston Jackson
29 | Rainer Klaffenboeck
30 | Russ Cox
31 | Russ Rufer
32 | Sean Mcafee
33 | Sigurður Ásgeirsson
34 | Tracy Bialik
35 | Vadim Berman
36 | Vlad Losev
37 | Zhanyong Wan
38 |
--------------------------------------------------------------------------------
/test/gtest/COPYING:
--------------------------------------------------------------------------------
1 | Copyright 2008, Google Inc.
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are
6 | met:
7 |
8 | * Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 | * Redistributions in binary form must reproduce the above
11 | copyright notice, this list of conditions and the following disclaimer
12 | in the documentation and/or other materials provided with the
13 | distribution.
14 | * Neither the name of Google Inc. nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
--------------------------------------------------------------------------------
/test/example.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file example.cpp
3 | * @date 19.07.2010
4 | * @author Ralf Karrenberg
5 | *
6 | * This file is distributed under the University of Illinois Open Source
7 | * License. See the COPYING file in the root directory for details.
8 | *
9 | * Copyright (C) 2010 Saarland University
10 | *
11 | *
12 | * Compile with:
13 | * clang -emit-llvm -c -Wall example.cpp -o example.bc
14 | *
15 | * Test packetizer:
16 | * packetizeFunction -m example.bc -f test_scalar -t test_to_be_generated
17 | *
18 | */
19 |
20 | #include
21 | #include
22 |
23 | extern "C" __m128 test_to_be_generated(__m128 a, __m128 b);
24 |
25 | // implementierung
26 | extern "C" float test_scalar(float a, float b) {
27 | float x = a * b;
28 | return x;
29 | }
30 |
31 | int main(void) {
32 |
33 | float a0 = 1.01f;
34 | float a1 = 1.02f;
35 | float a2 = 1.03f;
36 | float a3 = 1.04f;
37 | float b0 = 13.33f;
38 | float b1 = 13.34f;
39 | float b2 = 13.35f;
40 | float b3 = 13.36f;
41 |
42 | float res0 = test_scalar(a0, b0);
43 | float res1 = test_scalar(a1, b1);
44 | float res2 = test_scalar(a2, b2);
45 | float res3 = test_scalar(a3, b3);
46 |
47 | __m128 av = _mm_set_ps(a0, a1, a2, a3);
48 | __m128 bv = _mm_set_ps(b0, b1, b2, b3);
49 |
50 | // fake use to prevent deletion of target function
51 | __m128 resv = test_to_be_generated(av, bv);
52 |
53 | printf("res (scalar): %f %f %f %f\n", res0, res1, res2, res3);
54 | printf("res (packetized): %f %f %f %f\n", ((float*)&resv)[0], ((float*)&resv)[1], ((float*)&resv)[2], ((float*)&resv)[3]);
55 |
56 | return 0;
57 | }
58 |
--------------------------------------------------------------------------------
/test/gtest/test/production.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2006, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 | //
32 | // This is part of the unit test for include/gtest/gtest_prod.h.
33 |
34 | #include "production.h"
35 |
36 | PrivateCode::PrivateCode() : x_(0) {}
37 |
--------------------------------------------------------------------------------
/test/gtest/src/gtest_main.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2006, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 | #include
31 |
32 | #include "gtest/gtest.h"
33 |
34 | GTEST_API_ int main(int argc, char **argv) {
35 | std::cout << "Running main() from gtest_main.cc\n";
36 |
37 | testing::InitGoogleTest(&argc, argv);
38 | return RUN_ALL_TESTS();
39 | }
40 |
--------------------------------------------------------------------------------
/test/gtest/fused-src/gtest/gtest_main.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2006, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 | #include
31 |
32 | #include "gtest/gtest.h"
33 |
34 | GTEST_API_ int main(int argc, char **argv) {
35 | std::cout << "Running main() from gtest_main.cc\n";
36 |
37 | testing::InitGoogleTest(&argc, argv);
38 | return RUN_ALL_TESTS();
39 | }
40 |
--------------------------------------------------------------------------------
/test/gtest/codegear/gtest_all.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2009, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: Josh Kelley (joshkel@gmail.com)
31 | //
32 | // Google C++ Testing Framework (Google Test)
33 | //
34 | // C++Builder's IDE cannot build a static library from files with hyphens
35 | // in their name. See http://qc.codegear.com/wc/qcmain.aspx?d=70977 .
36 | // This file serves as a workaround.
37 |
38 | #include "src/gtest-all.cc"
39 |
--------------------------------------------------------------------------------
/test/gtest/scripts/test/Makefile:
--------------------------------------------------------------------------------
1 | # A Makefile for fusing Google Test and building a sample test against it.
2 | #
3 | # SYNOPSIS:
4 | #
5 | # make [all] - makes everything.
6 | # make TARGET - makes the given target.
7 | # make check - makes everything and runs the built sample test.
8 | # make clean - removes all files generated by make.
9 |
10 | # Points to the root of fused Google Test, relative to where this file is.
11 | FUSED_GTEST_DIR = output
12 |
13 | # Paths to the fused gtest files.
14 | FUSED_GTEST_H = $(FUSED_GTEST_DIR)/gtest/gtest.h
15 | FUSED_GTEST_ALL_CC = $(FUSED_GTEST_DIR)/gtest/gtest-all.cc
16 |
17 | # Where to find the sample test.
18 | SAMPLE_DIR = ../../samples
19 |
20 | # Where to find gtest_main.cc.
21 | GTEST_MAIN_CC = ../../src/gtest_main.cc
22 |
23 | # Flags passed to the preprocessor.
24 | # We have no idea here whether pthreads is available in the system, so
25 | # disable its use.
26 | CPPFLAGS += -I$(FUSED_GTEST_DIR) -DGTEST_HAS_PTHREAD=0
27 |
28 | # Flags passed to the C++ compiler.
29 | CXXFLAGS += -g
30 |
31 | all : sample1_unittest
32 |
33 | check : all
34 | ./sample1_unittest
35 |
36 | clean :
37 | rm -rf $(FUSED_GTEST_DIR) sample1_unittest *.o
38 |
39 | $(FUSED_GTEST_H) :
40 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR)
41 |
42 | $(FUSED_GTEST_ALL_CC) :
43 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR)
44 |
45 | gtest-all.o : $(FUSED_GTEST_H) $(FUSED_GTEST_ALL_CC)
46 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(FUSED_GTEST_DIR)/gtest/gtest-all.cc
47 |
48 | gtest_main.o : $(FUSED_GTEST_H) $(GTEST_MAIN_CC)
49 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_MAIN_CC)
50 |
51 | sample1.o : $(SAMPLE_DIR)/sample1.cc $(SAMPLE_DIR)/sample1.h
52 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1.cc
53 |
54 | sample1_unittest.o : $(SAMPLE_DIR)/sample1_unittest.cc \
55 | $(SAMPLE_DIR)/sample1.h $(FUSED_GTEST_H)
56 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1_unittest.cc
57 |
58 | sample1_unittest : sample1.o sample1_unittest.o gtest-all.o gtest_main.o
59 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@
60 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_main_unittest.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2006, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | #include "gtest/gtest.h"
33 |
34 | // Tests that we don't have to define main() when we link to
35 | // gtest_main instead of gtest.
36 |
37 | namespace {
38 |
39 | TEST(GTestMainTest, ShouldSucceed) {
40 | }
41 |
42 | } // namespace
43 |
44 | // We are using the main() function defined in src/gtest_main.cc, so
45 | // we don't define it here.
46 |
--------------------------------------------------------------------------------
/test/gtest/samples/sample4_unittest.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2005, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | #include "gtest/gtest.h"
33 | #include "sample4.h"
34 |
35 | // Tests the Increment() method.
36 | TEST(Counter, Increment) {
37 | Counter c;
38 |
39 | // EXPECT_EQ() evaluates its arguments exactly once, so they
40 | // can have side effects.
41 |
42 | EXPECT_EQ(0, c.Increment());
43 | EXPECT_EQ(1, c.Increment());
44 | EXPECT_EQ(2, c.Increment());
45 | }
46 |
--------------------------------------------------------------------------------
/test/gtest/samples/sample1.h:
--------------------------------------------------------------------------------
1 | // Copyright 2005, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 | // A sample program demonstrating using Google C++ testing framework.
31 | //
32 | // Author: wan@google.com (Zhanyong Wan)
33 |
34 | #ifndef GTEST_SAMPLES_SAMPLE1_H_
35 | #define GTEST_SAMPLES_SAMPLE1_H_
36 |
37 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1.
38 | int Factorial(int n);
39 |
40 | // Returns true iff n is a prime number.
41 | bool IsPrime(int n);
42 |
43 | #endif // GTEST_SAMPLES_SAMPLE1_H_
44 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_uninitialized_test_.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | #include "gtest/gtest.h"
33 |
34 | TEST(DummyTest, Dummy) {
35 | // This test doesn't verify anything. We just need it to create a
36 | // realistic stage for testing the behavior of Google Test when
37 | // RUN_ALL_TESTS() is called without testing::InitGoogleTest() being
38 | // called first.
39 | }
40 |
41 | int main() {
42 | return RUN_ALL_TESTS();
43 | }
44 |
--------------------------------------------------------------------------------
/test/gtest/samples/sample4.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2005, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 | // A sample program demonstrating using Google C++ testing framework.
31 | //
32 | // Author: wan@google.com (Zhanyong Wan)
33 |
34 | #include
35 |
36 | #include "sample4.h"
37 |
38 | // Returns the current counter value, and increments it.
39 | int Counter::Increment() {
40 | return counter_++;
41 | }
42 |
43 | // Prints the current counter value to STDOUT.
44 | void Counter::Print() const {
45 | printf("%d", counter_);
46 | }
47 |
--------------------------------------------------------------------------------
/test/gtest/build-aux/config.h.in:
--------------------------------------------------------------------------------
1 | /* build-aux/config.h.in. Generated from configure.ac by autoheader. */
2 |
3 | /* Define to 1 if you have the header file. */
4 | #undef HAVE_DLFCN_H
5 |
6 | /* Define to 1 if you have the header file. */
7 | #undef HAVE_INTTYPES_H
8 |
9 | /* Define to 1 if you have the header file. */
10 | #undef HAVE_MEMORY_H
11 |
12 | /* Define if you have POSIX threads libraries and header files. */
13 | #undef HAVE_PTHREAD
14 |
15 | /* Define to 1 if you have the header file. */
16 | #undef HAVE_STDINT_H
17 |
18 | /* Define to 1 if you have the header file. */
19 | #undef HAVE_STDLIB_H
20 |
21 | /* Define to 1 if you have the header file. */
22 | #undef HAVE_STRINGS_H
23 |
24 | /* Define to 1 if you have the header file. */
25 | #undef HAVE_STRING_H
26 |
27 | /* Define to 1 if you have the header file. */
28 | #undef HAVE_SYS_STAT_H
29 |
30 | /* Define to 1 if you have the header file. */
31 | #undef HAVE_SYS_TYPES_H
32 |
33 | /* Define to 1 if you have the header file. */
34 | #undef HAVE_UNISTD_H
35 |
36 | /* Define to the sub-directory in which libtool stores uninstalled libraries.
37 | */
38 | #undef LT_OBJDIR
39 |
40 | /* Name of package */
41 | #undef PACKAGE
42 |
43 | /* Define to the address where bug reports for this package should be sent. */
44 | #undef PACKAGE_BUGREPORT
45 |
46 | /* Define to the full name of this package. */
47 | #undef PACKAGE_NAME
48 |
49 | /* Define to the full name and version of this package. */
50 | #undef PACKAGE_STRING
51 |
52 | /* Define to the one symbol short name of this package. */
53 | #undef PACKAGE_TARNAME
54 |
55 | /* Define to the home page for this package. */
56 | #undef PACKAGE_URL
57 |
58 | /* Define to the version of this package. */
59 | #undef PACKAGE_VERSION
60 |
61 | /* Define to necessary symbol if this constant uses a non-standard name on
62 | your system. */
63 | #undef PTHREAD_CREATE_JOINABLE
64 |
65 | /* Define to 1 if you have the ANSI C header files. */
66 | #undef STDC_HEADERS
67 |
68 | /* Version number of package */
69 | #undef VERSION
70 |
--------------------------------------------------------------------------------
/test/gtest/codegear/gtest_link.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2009, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: Josh Kelley (joshkel@gmail.com)
31 | //
32 | // Google C++ Testing Framework (Google Test)
33 | //
34 | // Links gtest.lib and gtest_main.lib into the current project in C++Builder.
35 | // This means that these libraries can't be renamed, but it's the only way to
36 | // ensure that Debug versus Release test builds are linked against the
37 | // appropriate Debug or Release build of the libraries.
38 |
39 | #pragma link "gtest.lib"
40 | #pragma link "gtest_main.lib"
41 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_xml_outfile1_test_.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: keith.ray@gmail.com (Keith Ray)
31 | //
32 | // gtest_xml_outfile1_test_ writes some xml via TestProperty used by
33 | // gtest_xml_outfiles_test.py
34 |
35 | #include "gtest/gtest.h"
36 |
37 | class PropertyOne : public testing::Test {
38 | protected:
39 | virtual void SetUp() {
40 | RecordProperty("SetUpProp", 1);
41 | }
42 | virtual void TearDown() {
43 | RecordProperty("TearDownProp", 1);
44 | }
45 | };
46 |
47 | TEST_F(PropertyOne, TestSomeProperties) {
48 | RecordProperty("TestSomeProperty", 1);
49 | }
50 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_xml_outfile2_test_.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: keith.ray@gmail.com (Keith Ray)
31 | //
32 | // gtest_xml_outfile2_test_ writes some xml via TestProperty used by
33 | // gtest_xml_outfiles_test.py
34 |
35 | #include "gtest/gtest.h"
36 |
37 | class PropertyTwo : public testing::Test {
38 | protected:
39 | virtual void SetUp() {
40 | RecordProperty("SetUpProp", 2);
41 | }
42 | virtual void TearDown() {
43 | RecordProperty("TearDownProp", 2);
44 | }
45 | };
46 |
47 | TEST_F(PropertyTwo, TestSomeProperties) {
48 | RecordProperty("TestSomeProperty", 2);
49 | }
50 |
--------------------------------------------------------------------------------
/test/gtest/codegear/gtest.groupproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | {c1d923e0-6cba-4332-9b6f-3420acbf5091}
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | Default.Personality
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest-typed-test2_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2008 Google Inc.
2 | // All Rights Reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | #include
33 |
34 | #include "test/gtest-typed-test_test.h"
35 | #include "gtest/gtest.h"
36 |
37 | #if GTEST_HAS_TYPED_TEST_P
38 |
39 | // Tests that the same type-parameterized test case can be
40 | // instantiated in different translation units linked together.
41 | // (ContainerTest is also instantiated in gtest-typed-test_test.cc.)
42 | INSTANTIATE_TYPED_TEST_CASE_P(Vector, ContainerTest,
43 | testing::Types >);
44 |
45 | #endif // GTEST_HAS_TYPED_TEST_P
46 |
--------------------------------------------------------------------------------
/test/gtest/samples/sample4.h:
--------------------------------------------------------------------------------
1 | // Copyright 2005, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 | // A sample program demonstrating using Google C++ testing framework.
31 | //
32 | // Author: wan@google.com (Zhanyong Wan)
33 |
34 | #ifndef GTEST_SAMPLES_SAMPLE4_H_
35 | #define GTEST_SAMPLES_SAMPLE4_H_
36 |
37 | // A simple monotonic counter.
38 | class Counter {
39 | private:
40 | int counter_;
41 |
42 | public:
43 | // Creates a counter that starts at 0.
44 | Counter() : counter_(0) {}
45 |
46 | // Returns the current counter value, and increments it.
47 | int Increment();
48 |
49 | // Prints the current counter value to STDOUT.
50 | void Print() const;
51 | };
52 |
53 | #endif // GTEST_SAMPLES_SAMPLE4_H_
54 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_help_test_.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2009, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | // This program is meant to be run by gtest_help_test.py. Do not run
33 | // it directly.
34 |
35 | #include "gtest/gtest.h"
36 |
37 | // When a help flag is specified, this program should skip the tests
38 | // and exit with 0; otherwise the following test will be executed,
39 | // causing this program to exit with a non-zero code.
40 | TEST(HelpFlagTest, ShouldNotBeRun) {
41 | ASSERT_TRUE(false) << "Tests shouldn't be run when --help is specified.";
42 | }
43 |
44 | #if GTEST_HAS_DEATH_TEST
45 | TEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {}
46 | #endif
47 |
--------------------------------------------------------------------------------
/test/gtest/src/gtest-all.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: mheule@google.com (Markus Heule)
31 | //
32 | // Google C++ Testing Framework (Google Test)
33 | //
34 | // Sometimes it's desirable to build Google Test by compiling a single file.
35 | // This file serves this purpose.
36 |
37 | // This line ensures that gtest.h can be compiled on its own, even
38 | // when it's fused.
39 | #include "gtest/gtest.h"
40 |
41 | // The following lines pull in the real gtest *.cc files.
42 | #include "src/gtest.cc"
43 | #include "src/gtest-death-test.cc"
44 | #include "src/gtest-filepath.cc"
45 | #include "src/gtest-port.cc"
46 | #include "src/gtest-printers.cc"
47 | #include "src/gtest-test-part.cc"
48 | #include "src/gtest-typed-test.cc"
49 |
--------------------------------------------------------------------------------
/test/gtest/test/production.h:
--------------------------------------------------------------------------------
1 | // Copyright 2006, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 | //
32 | // This is part of the unit test for include/gtest/gtest_prod.h.
33 |
34 | #ifndef GTEST_TEST_PRODUCTION_H_
35 | #define GTEST_TEST_PRODUCTION_H_
36 |
37 | #include "gtest/gtest_prod.h"
38 |
39 | class PrivateCode {
40 | public:
41 | // Declares a friend test that does not use a fixture.
42 | FRIEND_TEST(PrivateCodeTest, CanAccessPrivateMembers);
43 |
44 | // Declares a friend test that uses a fixture.
45 | FRIEND_TEST(PrivateCodeFixtureTest, CanAccessPrivateMembers);
46 |
47 | PrivateCode();
48 |
49 | int x() const { return x_; }
50 | private:
51 | void set_x(int an_x) { x_ = an_x; }
52 | int x_;
53 | };
54 |
55 | #endif // GTEST_TEST_PRODUCTION_H_
56 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_all_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2009, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 | //
32 | // Tests for Google C++ Testing Framework (Google Test)
33 | //
34 | // Sometimes it's desirable to build most of Google Test's own tests
35 | // by compiling a single file. This file serves this purpose.
36 | #include "test/gtest-filepath_test.cc"
37 | #include "test/gtest-linked_ptr_test.cc"
38 | #include "test/gtest-message_test.cc"
39 | #include "test/gtest-options_test.cc"
40 | #include "test/gtest-port_test.cc"
41 | #include "test/gtest_pred_impl_unittest.cc"
42 | #include "test/gtest_prod_test.cc"
43 | #include "test/gtest-test-part_test.cc"
44 | #include "test/gtest-typed-test_test.cc"
45 | #include "test/gtest-typed-test2_test.cc"
46 | #include "test/gtest_unittest.cc"
47 | #include "test/production.cc"
48 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_prod_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2006, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 | //
32 | // Unit test for include/gtest/gtest_prod.h.
33 |
34 | #include "gtest/gtest.h"
35 | #include "test/production.h"
36 |
37 | // Tests that private members can be accessed from a TEST declared as
38 | // a friend of the class.
39 | TEST(PrivateCodeTest, CanAccessPrivateMembers) {
40 | PrivateCode a;
41 | EXPECT_EQ(0, a.x_);
42 |
43 | a.set_x(1);
44 | EXPECT_EQ(1, a.x_);
45 | }
46 |
47 | typedef testing::Test PrivateCodeFixtureTest;
48 |
49 | // Tests that private members can be accessed from a TEST_F declared
50 | // as a friend of the class.
51 | TEST_F(PrivateCodeFixtureTest, CanAccessPrivateMembers) {
52 | PrivateCode a;
53 | EXPECT_EQ(0, a.x_);
54 |
55 | a.set_x(2);
56 | EXPECT_EQ(2, a.x_);
57 | }
58 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_sole_header_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: mheule@google.com (Markus Heule)
31 | //
32 | // This test verifies that it's possible to use Google Test by including
33 | // the gtest.h header file alone.
34 |
35 | #include "gtest/gtest.h"
36 |
37 | namespace {
38 |
39 | void Subroutine() {
40 | EXPECT_EQ(42, 42);
41 | }
42 |
43 | TEST(NoFatalFailureTest, ExpectNoFatalFailure) {
44 | EXPECT_NO_FATAL_FAILURE(;);
45 | EXPECT_NO_FATAL_FAILURE(SUCCEED());
46 | EXPECT_NO_FATAL_FAILURE(Subroutine());
47 | EXPECT_NO_FATAL_FAILURE({ SUCCEED(); });
48 | }
49 |
50 | TEST(NoFatalFailureTest, AssertNoFatalFailure) {
51 | ASSERT_NO_FATAL_FAILURE(;);
52 | ASSERT_NO_FATAL_FAILURE(SUCCEED());
53 | ASSERT_NO_FATAL_FAILURE(Subroutine());
54 | ASSERT_NO_FATAL_FAILURE({ SUCCEED(); });
55 | }
56 |
57 | } // namespace
58 |
--------------------------------------------------------------------------------
/include/packetizerAPI_C.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file packetizerAPI_C.hpp
3 | * @date 14.05.2011
4 | * @author Ralf Karrenberg
5 | *
6 | * This file is distributed under the University of Illinois Open Source
7 | * License. See the COPYING file in the root directory for details.
8 | *
9 | * Copyright (C) 2011 Saarland University
10 | *
11 | */
12 | #ifndef _PACKETIZERAPI_C_H_
13 | #define _PACKETIZERAPI_C_H_
14 | // C bindings for libPacketizer
15 |
16 |
17 | #include "llvm-c/Core.h"
18 |
19 | #ifdef __cplusplus
20 | extern "C" {
21 | #endif
22 |
23 | typedef struct OpaquePacketizer *PKTPacketizerRef;
24 |
25 | PKTPacketizerRef
26 | PKTCreatePacketizer(LLVMModuleRef module,
27 | LLVMContextRef context,
28 | const unsigned simdWidth, const unsigned packetizationSize,
29 | const bool use_sse41, const bool use_avx,
30 | const bool verbose);
31 |
32 | bool
33 | PKTAddFunction(PKTPacketizerRef packetizerRef,
34 | const char* functionName, const char* simdFunctionName);
35 |
36 | bool
37 | PKTAddVaryingFunctionMapping(PKTPacketizerRef packetizerRef,
38 | const char* scalarFunctionName, const int maskPosition,
39 | LLVMValueRef packetFunction);
40 |
41 | bool
42 | PKTAddUniformVaryingInfo(PKTPacketizerRef packetizerRef,
43 | LLVMValueRef value, const bool uniform,
44 | const bool consecutive, const bool aligned);
45 |
46 | void
47 | PKTRun(PKTPacketizerRef packetizerRef);
48 |
49 | bool
50 | PKTSuccessful(PKTPacketizerRef packetizerRef,
51 | const char* simdFunctionName,
52 | LLVMModuleRef module);
53 |
54 |
55 | #ifdef __cplusplus
56 | }
57 |
58 | namespace Packetizer {
59 | class Packetizer;
60 |
61 | #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
62 | inline ty *unwrap(ref P) { \
63 | return reinterpret_cast(P); \
64 | } \
65 | \
66 | inline ref wrap(const ty *P) { \
67 | return reinterpret_cast[(const_cast(P)); \
68 | }
69 |
70 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Packetizer, PKTPacketizerRef)
71 |
72 | #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS
73 | }
74 |
75 | #endif /* defined(__cplusplus) */
76 |
77 | #endif /* _PACKETIZERAPI_C_H_ */
78 |
--------------------------------------------------------------------------------
/test/gtest/samples/sample2.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2005, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 | // A sample program demonstrating using Google C++ testing framework.
31 | //
32 | // Author: wan@google.com (Zhanyong Wan)
33 |
34 | #include "sample2.h"
35 |
36 | #include
37 |
38 | // Clones a 0-terminated C string, allocating memory using new.
39 | const char* MyString::CloneCString(const char* a_c_string) {
40 | if (a_c_string == NULL) return NULL;
41 |
42 | const size_t len = strlen(a_c_string);
43 | char* const clone = new char[ len + 1 ];
44 | memcpy(clone, a_c_string, len + 1);
45 |
46 | return clone;
47 | }
48 |
49 | // Sets the 0-terminated C string this MyString object
50 | // represents.
51 | void MyString::Set(const char* a_c_string) {
52 | // Makes sure this works when c_string == c_string_
53 | const char* const temp = MyString::CloneCString(a_c_string);
54 | delete[] c_string_;
55 | c_string_ = temp;
56 | }
57 |
--------------------------------------------------------------------------------
/test/gtest/xcode/Samples/FrameworkSample/widget.h:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: preston.a.jackson@gmail.com (Preston Jackson)
31 | //
32 | // Google Test - FrameworkSample
33 | // widget.h
34 | //
35 |
36 | // Widget is a very simple class used for demonstrating the use of gtest. It
37 | // simply stores two values a string and an integer, which are returned via
38 | // public accessors in multiple forms.
39 |
40 | #import
41 |
42 | class Widget {
43 | public:
44 | Widget(int number, const std::string& name);
45 | ~Widget();
46 |
47 | // Public accessors to number data
48 | float GetFloatValue() const;
49 | int GetIntValue() const;
50 |
51 | // Public accessors to the string data
52 | std::string GetStringValue() const;
53 | void GetCharPtrValue(char* buffer, size_t max_size) const;
54 |
55 | private:
56 | // Data members
57 | float number_;
58 | std::string name_;
59 | };
60 |
--------------------------------------------------------------------------------
/test/gtest/include/gtest/gtest_prod.h:
--------------------------------------------------------------------------------
1 | // Copyright 2006, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 | //
32 | // Google C++ Testing Framework definitions useful in production code.
33 |
34 | #ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_
35 | #define GTEST_INCLUDE_GTEST_GTEST_PROD_H_
36 |
37 | // When you need to test the private or protected members of a class,
38 | // use the FRIEND_TEST macro to declare your tests as friends of the
39 | // class. For example:
40 | //
41 | // class MyClass {
42 | // private:
43 | // void MyMethod();
44 | // FRIEND_TEST(MyClassTest, MyMethod);
45 | // };
46 | //
47 | // class MyClassTest : public testing::Test {
48 | // // ...
49 | // };
50 | //
51 | // TEST_F(MyClassTest, MyMethod) {
52 | // // Can call MyClass::MyMethod() here.
53 | // }
54 |
55 | #define FRIEND_TEST(test_case_name, test_name)\
56 | friend class test_case_name##_##test_name##_Test
57 |
58 | #endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_
59 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest-param-test_test.h:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Authors: vladl@google.com (Vlad Losev)
31 | //
32 | // The Google C++ Testing Framework (Google Test)
33 | //
34 | // This header file provides classes and functions used internally
35 | // for testing Google Test itself.
36 |
37 | #ifndef GTEST_TEST_GTEST_PARAM_TEST_TEST_H_
38 | #define GTEST_TEST_GTEST_PARAM_TEST_TEST_H_
39 |
40 | #include "gtest/gtest.h"
41 |
42 | #if GTEST_HAS_PARAM_TEST
43 |
44 | // Test fixture for testing definition and instantiation of a test
45 | // in separate translation units.
46 | class ExternalInstantiationTest : public ::testing::TestWithParam {};
47 |
48 | // Test fixture for testing instantiation of a test in multiple
49 | // translation units.
50 | class InstantiationInMultipleTranslaionUnitsTest
51 | : public ::testing::TestWithParam {};
52 |
53 | #endif // GTEST_HAS_PARAM_TEST
54 |
55 | #endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_
56 |
--------------------------------------------------------------------------------
/test/gtest/xcode/Samples/FrameworkSample/widget.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: preston.a.jackson@gmail.com (Preston Jackson)
31 | //
32 | // Google Test - FrameworkSample
33 | // widget.cc
34 | //
35 |
36 | // Widget is a very simple class used for demonstrating the use of gtest
37 |
38 | #include "widget.h"
39 |
40 | Widget::Widget(int number, const std::string& name)
41 | : number_(number),
42 | name_(name) {}
43 |
44 | Widget::~Widget() {}
45 |
46 | float Widget::GetFloatValue() const {
47 | return number_;
48 | }
49 |
50 | int Widget::GetIntValue() const {
51 | return static_cast(number_);
52 | }
53 |
54 | std::string Widget::GetStringValue() const {
55 | return name_;
56 | }
57 |
58 | void Widget::GetCharPtrValue(char* buffer, size_t max_size) const {
59 | // Copy the char* representation of name_ into buffer, up to max_size.
60 | strncpy(buffer, name_.c_str(), max_size-1);
61 | buffer[max_size-1] = '\0';
62 | return;
63 | }
64 |
--------------------------------------------------------------------------------
/test/gtest/msvc/gtest.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 8.00
2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest", "gtest.vcproj", "{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}"
3 | ProjectSection(ProjectDependencies) = postProject
4 | EndProjectSection
5 | EndProject
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_main", "gtest_main.vcproj", "{3AF54C8A-10BF-4332-9147-F68ED9862032}"
7 | ProjectSection(ProjectDependencies) = postProject
8 | EndProjectSection
9 | EndProject
10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_unittest", "gtest_unittest.vcproj", "{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}"
11 | ProjectSection(ProjectDependencies) = postProject
12 | EndProjectSection
13 | EndProject
14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_prod_test", "gtest_prod_test.vcproj", "{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}"
15 | ProjectSection(ProjectDependencies) = postProject
16 | EndProjectSection
17 | EndProject
18 | Global
19 | GlobalSection(SolutionConfiguration) = preSolution
20 | Debug = Debug
21 | Release = Release
22 | EndGlobalSection
23 | GlobalSection(ProjectConfiguration) = postSolution
24 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.ActiveCfg = Debug|Win32
25 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.Build.0 = Debug|Win32
26 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.ActiveCfg = Release|Win32
27 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.Build.0 = Release|Win32
28 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.ActiveCfg = Debug|Win32
29 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.Build.0 = Debug|Win32
30 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.ActiveCfg = Release|Win32
31 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.Build.0 = Release|Win32
32 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.ActiveCfg = Debug|Win32
33 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.Build.0 = Debug|Win32
34 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.ActiveCfg = Release|Win32
35 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.Build.0 = Release|Win32
36 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.ActiveCfg = Debug|Win32
37 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.Build.0 = Debug|Win32
38 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.ActiveCfg = Release|Win32
39 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.Build.0 = Release|Win32
40 | EndGlobalSection
41 | GlobalSection(ExtensibilityGlobals) = postSolution
42 | EndGlobalSection
43 | GlobalSection(ExtensibilityAddIns) = postSolution
44 | EndGlobalSection
45 | EndGlobal
46 |
--------------------------------------------------------------------------------
/test/gtest/msvc/gtest-md.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 8.00
2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest-md", "gtest-md.vcproj", "{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}"
3 | ProjectSection(ProjectDependencies) = postProject
4 | EndProjectSection
5 | EndProject
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_main-md", "gtest_main-md.vcproj", "{3AF54C8A-10BF-4332-9147-F68ED9862033}"
7 | ProjectSection(ProjectDependencies) = postProject
8 | EndProjectSection
9 | EndProject
10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_prod_test-md", "gtest_prod_test-md.vcproj", "{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}"
11 | ProjectSection(ProjectDependencies) = postProject
12 | EndProjectSection
13 | EndProject
14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_unittest-md", "gtest_unittest-md.vcproj", "{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}"
15 | ProjectSection(ProjectDependencies) = postProject
16 | EndProjectSection
17 | EndProject
18 | Global
19 | GlobalSection(SolutionConfiguration) = preSolution
20 | Debug = Debug
21 | Release = Release
22 | EndGlobalSection
23 | GlobalSection(ProjectConfiguration) = postSolution
24 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.ActiveCfg = Debug|Win32
25 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.Build.0 = Debug|Win32
26 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.ActiveCfg = Release|Win32
27 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.Build.0 = Release|Win32
28 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.ActiveCfg = Debug|Win32
29 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.Build.0 = Debug|Win32
30 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.ActiveCfg = Release|Win32
31 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.Build.0 = Release|Win32
32 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.ActiveCfg = Debug|Win32
33 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.Build.0 = Debug|Win32
34 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.ActiveCfg = Release|Win32
35 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.Build.0 = Release|Win32
36 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.ActiveCfg = Debug|Win32
37 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.Build.0 = Debug|Win32
38 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.ActiveCfg = Release|Win32
39 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.Build.0 = Release|Win32
40 | EndGlobalSection
41 | GlobalSection(ExtensibilityGlobals) = postSolution
42 | EndGlobalSection
43 | GlobalSection(ExtensibilityAddIns) = postSolution
44 | EndGlobalSection
45 | EndGlobal
46 |
--------------------------------------------------------------------------------
/test/gtest/xcode/Samples/FrameworkSample/runtests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Copyright 2008, Google Inc.
4 | # All rights reserved.
5 | #
6 | # Redistribution and use in source and binary forms, with or without
7 | # modification, are permitted provided that the following conditions are
8 | # met:
9 | #
10 | # * Redistributions of source code must retain the above copyright
11 | # notice, this list of conditions and the following disclaimer.
12 | # * Redistributions in binary form must reproduce the above
13 | # copyright notice, this list of conditions and the following disclaimer
14 | # in the documentation and/or other materials provided with the
15 | # distribution.
16 | # * Neither the name of Google Inc. nor the names of its
17 | # contributors may be used to endorse or promote products derived from
18 | # this software without specific prior written permission.
19 | #
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 |
32 | # Executes the samples and tests for the Google Test Framework.
33 |
34 | # Help the dynamic linker find the path to the libraries.
35 | export DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR
36 | export DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR
37 |
38 | # Create some executables.
39 | test_executables=$@
40 |
41 | # Now execute each one in turn keeping track of how many succeeded and failed.
42 | succeeded=0
43 | failed=0
44 | failed_list=()
45 | for test in ${test_executables[*]}; do
46 | "$test"
47 | result=$?
48 | if [ $result -eq 0 ]; then
49 | succeeded=$(( $succeeded + 1 ))
50 | else
51 | failed=$(( failed + 1 ))
52 | failed_list="$failed_list $test"
53 | fi
54 | done
55 |
56 | # Report the successes and failures to the console.
57 | echo "Tests complete with $succeeded successes and $failed failures."
58 | if [ $failed -ne 0 ]; then
59 | echo "The following tests failed:"
60 | echo $failed_list
61 | fi
62 | exit $failed
63 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_no_test_unittest.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2006, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 | // Tests that a Google Test program that has no test defined can run
31 | // successfully.
32 | //
33 | // Author: wan@google.com (Zhanyong Wan)
34 |
35 | #include "gtest/gtest.h"
36 |
37 |
38 | int main(int argc, char **argv) {
39 | testing::InitGoogleTest(&argc, argv);
40 |
41 | // An ad-hoc assertion outside of all tests.
42 | //
43 | // This serves three purposes:
44 | //
45 | // 1. It verifies that an ad-hoc assertion can be executed even if
46 | // no test is defined.
47 | // 2. It verifies that a failed ad-hoc assertion causes the test
48 | // program to fail.
49 | // 3. We had a bug where the XML output won't be generated if an
50 | // assertion is executed before RUN_ALL_TESTS() is called, even
51 | // though --gtest_output=xml is specified. This makes sure the
52 | // bug is fixed and doesn't regress.
53 | EXPECT_EQ(1, 2);
54 |
55 | // The above EXPECT_EQ() should cause RUN_ALL_TESTS() to return non-zero.
56 | return RUN_ALL_TESTS() ? 0 : 1;
57 | }
58 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest-typed-test_test.h:
--------------------------------------------------------------------------------
1 | // Copyright 2008 Google Inc.
2 | // All Rights Reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | #ifndef GTEST_TEST_GTEST_TYPED_TEST_TEST_H_
33 | #define GTEST_TEST_GTEST_TYPED_TEST_TEST_H_
34 |
35 | #include "gtest/gtest.h"
36 |
37 | #if GTEST_HAS_TYPED_TEST_P
38 |
39 | using testing::Test;
40 |
41 | // For testing that the same type-parameterized test case can be
42 | // instantiated in different translation units linked together.
43 | // ContainerTest will be instantiated in both gtest-typed-test_test.cc
44 | // and gtest-typed-test2_test.cc.
45 |
46 | template
47 | class ContainerTest : public Test {
48 | };
49 |
50 | TYPED_TEST_CASE_P(ContainerTest);
51 |
52 | TYPED_TEST_P(ContainerTest, CanBeDefaultConstructed) {
53 | TypeParam container;
54 | }
55 |
56 | TYPED_TEST_P(ContainerTest, InitialSizeIsZero) {
57 | TypeParam container;
58 | EXPECT_EQ(0U, container.size());
59 | }
60 |
61 | REGISTER_TYPED_TEST_CASE_P(ContainerTest,
62 | CanBeDefaultConstructed, InitialSizeIsZero);
63 |
64 | #endif // GTEST_HAS_TYPED_TEST_P
65 |
66 | #endif // GTEST_TEST_GTEST_TYPED_TEST_TEST_H_
67 |
--------------------------------------------------------------------------------
/test/gtest/samples/sample1.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2005, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 | // A sample program demonstrating using Google C++ testing framework.
31 | //
32 | // Author: wan@google.com (Zhanyong Wan)
33 |
34 | #include "sample1.h"
35 |
36 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1.
37 | int Factorial(int n) {
38 | int result = 1;
39 | for (int i = 1; i <= n; i++) {
40 | result *= i;
41 | }
42 |
43 | return result;
44 | }
45 |
46 | // Returns true iff n is a prime number.
47 | bool IsPrime(int n) {
48 | // Trivial case 1: small numbers
49 | if (n <= 1) return false;
50 |
51 | // Trivial case 2: even numbers
52 | if (n % 2 == 0) return n == 2;
53 |
54 | // Now, we have that n is odd and n >= 3.
55 |
56 | // Try to divide n by every odd number i, starting from 3
57 | for (int i = 3; ; i += 2) {
58 | // We only have to try i up to the squre root of n
59 | if (i > n/i) break;
60 |
61 | // Now, we have i <= n/i < n.
62 | // If n is divisible by i, n is not prime.
63 | if (n % i == 0) return false;
64 | }
65 |
66 | // n has no integer factor in the range (1, n), and thus is prime.
67 | return true;
68 | }
69 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_throw_on_failure_test_.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2009, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | // Tests Google Test's throw-on-failure mode with exceptions disabled.
33 | //
34 | // This program must be compiled with exceptions disabled. It will be
35 | // invoked by gtest_throw_on_failure_test.py, and is expected to exit
36 | // with non-zero in the throw-on-failure mode or 0 otherwise.
37 |
38 | #include "gtest/gtest.h"
39 |
40 | int main(int argc, char** argv) {
41 | testing::InitGoogleTest(&argc, argv);
42 |
43 | // We want to ensure that people can use Google Test assertions in
44 | // other testing frameworks, as long as they initialize Google Test
45 | // properly and set the thrown-on-failure mode. Therefore, we don't
46 | // use Google Test's constructs for defining and running tests
47 | // (e.g. TEST and RUN_ALL_TESTS) here.
48 |
49 | // In the throw-on-failure mode with exceptions disabled, this
50 | // assertion will cause the program to exit with a non-zero code.
51 | EXPECT_EQ(2, 3);
52 |
53 | // When not in the throw-on-failure mode, the control will reach
54 | // here.
55 | return 0;
56 | }
57 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_uninitialized_test.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2008, Google Inc.
4 | # All rights reserved.
5 | #
6 | # Redistribution and use in source and binary forms, with or without
7 | # modification, are permitted provided that the following conditions are
8 | # met:
9 | #
10 | # * Redistributions of source code must retain the above copyright
11 | # notice, this list of conditions and the following disclaimer.
12 | # * Redistributions in binary form must reproduce the above
13 | # copyright notice, this list of conditions and the following disclaimer
14 | # in the documentation and/or other materials provided with the
15 | # distribution.
16 | # * Neither the name of Google Inc. nor the names of its
17 | # contributors may be used to endorse or promote products derived from
18 | # this software without specific prior written permission.
19 | #
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 |
32 | """Verifies that Google Test warns the user when not initialized properly."""
33 |
34 | __author__ = 'wan@google.com (Zhanyong Wan)'
35 |
36 | import gtest_test_utils
37 |
38 |
39 | COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_uninitialized_test_')
40 |
41 |
42 | def Assert(condition):
43 | if not condition:
44 | raise AssertionError
45 |
46 |
47 | def AssertEq(expected, actual):
48 | if expected != actual:
49 | print 'Expected: %s' % (expected,)
50 | print ' Actual: %s' % (actual,)
51 | raise AssertionError
52 |
53 |
54 | def TestExitCodeAndOutput(command):
55 | """Runs the given command and verifies its exit code and output."""
56 |
57 | # Verifies that 'command' exits with code 1.
58 | p = gtest_test_utils.Subprocess(command)
59 | Assert(p.exited)
60 | AssertEq(1, p.exit_code)
61 | Assert('InitGoogleTest' in p.output)
62 |
63 |
64 | class GTestUninitializedTest(gtest_test_utils.TestCase):
65 | def testExitCodeAndOutput(self):
66 | TestExitCodeAndOutput(COMMAND)
67 |
68 |
69 | if __name__ == '__main__':
70 | gtest_test_utils.Main()
71 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_list_tests_unittest_.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2006, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: phanna@google.com (Patrick Hanna)
31 |
32 | // Unit test for Google Test's --gtest_list_tests flag.
33 | //
34 | // A user can ask Google Test to list all tests that will run
35 | // so that when using a filter, a user will know what
36 | // tests to look for. The tests will not be run after listing.
37 | //
38 | // This program will be invoked from a Python unit test.
39 | // Don't run it directly.
40 |
41 | #include "gtest/gtest.h"
42 |
43 | namespace {
44 |
45 | // Several different test cases and tests that will be listed.
46 | TEST(Foo, Bar1) {
47 | }
48 |
49 | TEST(Foo, Bar2) {
50 | }
51 |
52 | TEST(Foo, DISABLED_Bar3) {
53 | }
54 |
55 | TEST(Abc, Xyz) {
56 | }
57 |
58 | TEST(Abc, Def) {
59 | }
60 |
61 | TEST(FooBar, Baz) {
62 | }
63 |
64 | class FooTest : public testing::Test {
65 | };
66 |
67 | TEST_F(FooTest, Test1) {
68 | }
69 |
70 | TEST_F(FooTest, DISABLED_Test2) {
71 | }
72 |
73 | TEST_F(FooTest, Test3) {
74 | }
75 |
76 | TEST(FooDeathTest, Test1) {
77 | }
78 |
79 | } // namespace
80 |
81 | int main(int argc, char **argv) {
82 | ::testing::InitGoogleTest(&argc, argv);
83 |
84 | return RUN_ALL_TESTS();
85 | }
86 |
--------------------------------------------------------------------------------
/test/gtest/configure.ac:
--------------------------------------------------------------------------------
1 | m4_include(m4/acx_pthread.m4)
2 |
3 | # At this point, the Xcode project assumes the version string will be three
4 | # integers separated by periods and surrounded by square brackets (e.g.
5 | # "[1.0.1]"). It also asumes that there won't be any closing parenthesis
6 | # between "AC_INIT(" and the closing ")" including comments and strings.
7 | AC_INIT([Google C++ Testing Framework],
8 | [1.6.0],
9 | [googletestframework@googlegroups.com],
10 | [gtest])
11 |
12 | # Provide various options to initialize the Autoconf and configure processes.
13 | AC_PREREQ([2.59])
14 | AC_CONFIG_SRCDIR([./COPYING])
15 | AC_CONFIG_MACRO_DIR([m4])
16 | AC_CONFIG_AUX_DIR([build-aux])
17 | AC_CONFIG_HEADERS([build-aux/config.h])
18 | AC_CONFIG_FILES([Makefile])
19 | AC_CONFIG_FILES([scripts/gtest-config], [chmod +x scripts/gtest-config])
20 |
21 | # Initialize Automake with various options. We require at least v1.9, prevent
22 | # pedantic complaints about package files, and enable various distribution
23 | # targets.
24 | AM_INIT_AUTOMAKE([1.9 dist-bzip2 dist-zip foreign subdir-objects])
25 |
26 | # Check for programs used in building Google Test.
27 | AC_PROG_CC
28 | AC_PROG_CXX
29 | AC_LANG([C++])
30 | AC_PROG_LIBTOOL
31 |
32 | # TODO(chandlerc@google.com): Currently we aren't running the Python tests
33 | # against the interpreter detected by AM_PATH_PYTHON, and so we condition
34 | # HAVE_PYTHON by requiring "python" to be in the PATH, and that interpreter's
35 | # version to be >= 2.3. This will allow the scripts to use a "/usr/bin/env"
36 | # hashbang.
37 | PYTHON= # We *do not* allow the user to specify a python interpreter
38 | AC_PATH_PROG([PYTHON],[python],[:])
39 | AS_IF([test "$PYTHON" != ":"],
40 | [AM_PYTHON_CHECK_VERSION([$PYTHON],[2.3],[:],[PYTHON=":"])])
41 | AM_CONDITIONAL([HAVE_PYTHON],[test "$PYTHON" != ":"])
42 |
43 | # Configure pthreads.
44 | AC_ARG_WITH([pthreads],
45 | [AS_HELP_STRING([--with-pthreads],
46 | [use pthreads (default is yes)])],
47 | [with_pthreads=$withval],
48 | [with_pthreads=check])
49 |
50 | have_pthreads=no
51 | AS_IF([test "x$with_pthreads" != "xno"],
52 | [ACX_PTHREAD(
53 | [],
54 | [AS_IF([test "x$with_pthreads" != "xcheck"],
55 | [AC_MSG_FAILURE(
56 | [--with-pthreads was specified, but unable to be used])])])
57 | have_pthreads="$acx_pthread_ok"])
58 | AM_CONDITIONAL([HAVE_PTHREADS],[test "x$have_pthreads" == "xyes"])
59 | AC_SUBST(PTHREAD_CFLAGS)
60 | AC_SUBST(PTHREAD_LIBS)
61 |
62 | # TODO(chandlerc@google.com) Check for the necessary system headers.
63 |
64 | # TODO(chandlerc@google.com) Check the types, structures, and other compiler
65 | # and architecture characteristics.
66 |
67 | # Output the generated files. No further autoconf macros may be used.
68 | AC_OUTPUT
69 |
--------------------------------------------------------------------------------
/test/gtest/xcode/Scripts/runtests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Copyright 2008, Google Inc.
4 | # All rights reserved.
5 | #
6 | # Redistribution and use in source and binary forms, with or without
7 | # modification, are permitted provided that the following conditions are
8 | # met:
9 | #
10 | # * Redistributions of source code must retain the above copyright
11 | # notice, this list of conditions and the following disclaimer.
12 | # * Redistributions in binary form must reproduce the above
13 | # copyright notice, this list of conditions and the following disclaimer
14 | # in the documentation and/or other materials provided with the
15 | # distribution.
16 | # * Neither the name of Google Inc. nor the names of its
17 | # contributors may be used to endorse or promote products derived from
18 | # this software without specific prior written permission.
19 | #
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 |
32 | # Executes the samples and tests for the Google Test Framework.
33 |
34 | # Help the dynamic linker find the path to the libraries.
35 | export DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR
36 | export DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR
37 |
38 | # Create some executables.
39 | test_executables=("$BUILT_PRODUCTS_DIR/gtest_unittest-framework"
40 | "$BUILT_PRODUCTS_DIR/gtest_unittest"
41 | "$BUILT_PRODUCTS_DIR/sample1_unittest-framework"
42 | "$BUILT_PRODUCTS_DIR/sample1_unittest-static")
43 |
44 | # Now execute each one in turn keeping track of how many succeeded and failed.
45 | succeeded=0
46 | failed=0
47 | failed_list=()
48 | for test in ${test_executables[*]}; do
49 | "$test"
50 | result=$?
51 | if [ $result -eq 0 ]; then
52 | succeeded=$(( $succeeded + 1 ))
53 | else
54 | failed=$(( failed + 1 ))
55 | failed_list="$failed_list $test"
56 | fi
57 | done
58 |
59 | # Report the successes and failures to the console.
60 | echo "Tests complete with $succeeded successes and $failed failures."
61 | if [ $failed -ne 0 ]; then
62 | echo "The following tests failed:"
63 | echo $failed_list
64 | fi
65 | exit $failed
66 |
--------------------------------------------------------------------------------
/test/gtest/make/Makefile:
--------------------------------------------------------------------------------
1 | # A sample Makefile for building Google Test and using it in user
2 | # tests. Please tweak it to suit your environment and project. You
3 | # may want to move it to your project's root directory.
4 | #
5 | # SYNOPSIS:
6 | #
7 | # make [all] - makes everything.
8 | # make TARGET - makes the given target.
9 | # make clean - removes all files generated by make.
10 |
11 | # Please tweak the following variable definitions as needed by your
12 | # project, except GTEST_HEADERS, which you can use in your own targets
13 | # but shouldn't modify.
14 |
15 | # Points to the root of Google Test, relative to where this file is.
16 | # Remember to tweak this if you move this file.
17 | GTEST_DIR = ..
18 |
19 | # Where to find user code.
20 | USER_DIR = ../samples
21 |
22 | # Flags passed to the preprocessor.
23 | CPPFLAGS += -I$(GTEST_DIR)/include
24 |
25 | # Flags passed to the C++ compiler.
26 | CXXFLAGS += -g -Wall -Wextra
27 |
28 | # All tests produced by this Makefile. Remember to add new tests you
29 | # created to the list.
30 | TESTS = sample1_unittest
31 |
32 | # All Google Test headers. Usually you shouldn't change this
33 | # definition.
34 | GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
35 | $(GTEST_DIR)/include/gtest/internal/*.h
36 |
37 | # House-keeping build targets.
38 |
39 | all : $(TESTS)
40 |
41 | clean :
42 | rm -f $(TESTS) gtest.a gtest_main.a *.o
43 |
44 | # Builds gtest.a and gtest_main.a.
45 |
46 | # Usually you shouldn't tweak such internal variables, indicated by a
47 | # trailing _.
48 | GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)
49 |
50 | # For simplicity and to avoid depending on Google Test's
51 | # implementation details, the dependencies specified below are
52 | # conservative and not optimized. This is fine as Google Test
53 | # compiles fast and for ordinary users its source rarely changes.
54 | gtest-all.o : $(GTEST_SRCS_)
55 | $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
56 | $(GTEST_DIR)/src/gtest-all.cc
57 |
58 | gtest_main.o : $(GTEST_SRCS_)
59 | $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
60 | $(GTEST_DIR)/src/gtest_main.cc
61 |
62 | gtest.a : gtest-all.o
63 | $(AR) $(ARFLAGS) $@ $^
64 |
65 | gtest_main.a : gtest-all.o gtest_main.o
66 | $(AR) $(ARFLAGS) $@ $^
67 |
68 | # Builds a sample test. A test should link with either gtest.a or
69 | # gtest_main.a, depending on whether it defines its own main()
70 | # function.
71 |
72 | sample1.o : $(USER_DIR)/sample1.cc $(USER_DIR)/sample1.h $(GTEST_HEADERS)
73 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/sample1.cc
74 |
75 | sample1_unittest.o : $(USER_DIR)/sample1_unittest.cc \
76 | $(USER_DIR)/sample1.h $(GTEST_HEADERS)
77 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/sample1_unittest.cc
78 |
79 | sample1_unittest : sample1.o sample1_unittest.o gtest_main.a
80 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -pthread $^ -o $@
81 |
--------------------------------------------------------------------------------
/test/gtest/xcode/Samples/FrameworkSample/widget_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: preston.a.jackson@gmail.com (Preston Jackson)
31 | //
32 | // Google Test - FrameworkSample
33 | // widget_test.cc
34 | //
35 |
36 | // This is a simple test file for the Widget class in the Widget.framework
37 |
38 | #include
39 | #include "gtest/gtest.h"
40 |
41 | #include
42 |
43 | // This test verifies that the constructor sets the internal state of the
44 | // Widget class correctly.
45 | TEST(WidgetInitializerTest, TestConstructor) {
46 | Widget widget(1.0f, "name");
47 | EXPECT_FLOAT_EQ(1.0f, widget.GetFloatValue());
48 | EXPECT_EQ(std::string("name"), widget.GetStringValue());
49 | }
50 |
51 | // This test verifies the conversion of the float and string values to int and
52 | // char*, respectively.
53 | TEST(WidgetInitializerTest, TestConversion) {
54 | Widget widget(1.0f, "name");
55 | EXPECT_EQ(1, widget.GetIntValue());
56 |
57 | size_t max_size = 128;
58 | char buffer[max_size];
59 | widget.GetCharPtrValue(buffer, max_size);
60 | EXPECT_STREQ("name", buffer);
61 | }
62 |
63 | // Use the Google Test main that is linked into the framework. It does something
64 | // like this:
65 | // int main(int argc, char** argv) {
66 | // testing::InitGoogleTest(&argc, argv);
67 | // return RUN_ALL_TESTS();
68 | // }
69 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest-param-test2_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: vladl@google.com (Vlad Losev)
31 | //
32 | // Tests for Google Test itself. This verifies that the basic constructs of
33 | // Google Test work.
34 |
35 | #include "gtest/gtest.h"
36 |
37 | #include "test/gtest-param-test_test.h"
38 |
39 | #if GTEST_HAS_PARAM_TEST
40 |
41 | using ::testing::Values;
42 | using ::testing::internal::ParamGenerator;
43 |
44 | // Tests that generators defined in a different translation unit
45 | // are functional. The test using extern_gen is defined
46 | // in gtest-param-test_test.cc.
47 | ParamGenerator extern_gen = Values(33);
48 |
49 | // Tests that a parameterized test case can be defined in one translation unit
50 | // and instantiated in another. The test is defined in gtest-param-test_test.cc
51 | // and ExternalInstantiationTest fixture class is defined in
52 | // gtest-param-test_test.h.
53 | INSTANTIATE_TEST_CASE_P(MultiplesOf33,
54 | ExternalInstantiationTest,
55 | Values(33, 66));
56 |
57 | // Tests that a parameterized test case can be instantiated
58 | // in multiple translation units. Another instantiation is defined
59 | // in gtest-param-test_test.cc and InstantiationInMultipleTranslaionUnitsTest
60 | // fixture is defined in gtest-param-test_test.h
61 | INSTANTIATE_TEST_CASE_P(Sequence2,
62 | InstantiationInMultipleTranslaionUnitsTest,
63 | Values(42*3, 42*4, 42*5));
64 |
65 | #endif // GTEST_HAS_PARAM_TEST
66 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_color_test_.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | // A helper program for testing how Google Test determines whether to use
33 | // colors in the output. It prints "YES" and returns 1 if Google Test
34 | // decides to use colors, and prints "NO" and returns 0 otherwise.
35 |
36 | #include
37 |
38 | #include "gtest/gtest.h"
39 |
40 | // Indicates that this translation unit is part of Google Test's
41 | // implementation. It must come before gtest-internal-inl.h is
42 | // included, or there will be a compiler error. This trick is to
43 | // prevent a user from accidentally including gtest-internal-inl.h in
44 | // his code.
45 | #define GTEST_IMPLEMENTATION_ 1
46 | #include "src/gtest-internal-inl.h"
47 | #undef GTEST_IMPLEMENTATION_
48 |
49 | using testing::internal::ShouldUseColor;
50 |
51 | // The purpose of this is to ensure that the UnitTest singleton is
52 | // created before main() is entered, and thus that ShouldUseColor()
53 | // works the same way as in a real Google-Test-based test. We don't actual
54 | // run the TEST itself.
55 | TEST(GTestColorTest, Dummy) {
56 | }
57 |
58 | int main(int argc, char** argv) {
59 | testing::InitGoogleTest(&argc, argv);
60 |
61 | if (ShouldUseColor(true)) {
62 | // Google Test decides to use colors in the output (assuming it
63 | // goes to a TTY).
64 | printf("YES\n");
65 | return 1;
66 | } else {
67 | // Google Test decides not to use colors in the output.
68 | printf("NO\n");
69 | return 0;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | ==============================================================================
2 | WFV Release License
3 | ==============================================================================
4 | University of Illinois/NCSA
5 | Open Source License
6 |
7 | Copyright (c) 2008-2011 Compiler Design Lab, Saarland University,
8 | All rights reserved.
9 |
10 | Developed by:
11 |
12 | Compiler Design Lab
13 |
14 | Saarland University
15 |
16 | http://www.cdl.uni-saarland.de/projects/wfv/
17 |
18 | Permission is hereby granted, free of charge, to any person obtaining a copy of
19 | this software and associated documentation files (the "Software"), to deal with
20 | the Software without restriction, including without limitation the rights to
21 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
22 | of the Software, and to permit persons to whom the Software is furnished to do
23 | so, subject to the following conditions:
24 |
25 | * Redistributions of source code must retain the above copyright notice,
26 | this list of conditions and the following disclaimers.
27 |
28 | * Redistributions in binary form must reproduce the above copyright notice,
29 | this list of conditions and the following disclaimers in the
30 | documentation and/or other materials provided with the distribution.
31 |
32 | * Neither the names of the Compiler Design Lab, Saarland University, nor
33 | the names of its contributors may be used to endorse or promote products
34 | derived from this Software without specific prior written permission.
35 |
36 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
37 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
38 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
39 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
40 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
41 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
42 | SOFTWARE.
43 |
44 | ==============================================================================
45 | Copyrights and Licenses for Third Party Software Distributed with WFV:
46 | ==============================================================================
47 | The WFV software contains code written by third parties. Such software will
48 | have its own individual COPYING file in the directory in which it appears.
49 | This file will describe the copyrights, license, and restrictions which apply
50 | to that code.
51 |
52 | The disclaimer of warranty in the University of Illinois Open Source License
53 | applies to all code in the WFV Distribution, and nothing in any of the
54 | other licenses gives permission to use the names of the Compiler Design Lab
55 | or Saarland University to endorse or promote products derived from this
56 | Software.
57 |
58 | The following pieces of software have additional or alternate copyrights,
59 | licenses, and/or restrictions:
60 |
61 | Program Directory
62 | ------- ---------
63 | Google Test test/gtest
64 | SSE Math functions src/utils/nativeSSEMathFunctions.hpp
65 | src/utils/nativeAVXMathFunctions.hpp
66 |
--------------------------------------------------------------------------------
/test/gtest/samples/sample2.h:
--------------------------------------------------------------------------------
1 | // Copyright 2005, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 | // A sample program demonstrating using Google C++ testing framework.
31 | //
32 | // Author: wan@google.com (Zhanyong Wan)
33 |
34 | #ifndef GTEST_SAMPLES_SAMPLE2_H_
35 | #define GTEST_SAMPLES_SAMPLE2_H_
36 |
37 | #include
38 |
39 |
40 | // A simple string class.
41 | class MyString {
42 | private:
43 | const char* c_string_;
44 | const MyString& operator=(const MyString& rhs);
45 |
46 | public:
47 |
48 | // Clones a 0-terminated C string, allocating memory using new.
49 | static const char* CloneCString(const char* a_c_string);
50 |
51 | ////////////////////////////////////////////////////////////
52 | //
53 | // C'tors
54 |
55 | // The default c'tor constructs a NULL string.
56 | MyString() : c_string_(NULL) {}
57 |
58 | // Constructs a MyString by cloning a 0-terminated C string.
59 | explicit MyString(const char* a_c_string) : c_string_(NULL) {
60 | Set(a_c_string);
61 | }
62 |
63 | // Copy c'tor
64 | MyString(const MyString& string) : c_string_(NULL) {
65 | Set(string.c_string_);
66 | }
67 |
68 | ////////////////////////////////////////////////////////////
69 | //
70 | // D'tor. MyString is intended to be a final class, so the d'tor
71 | // doesn't need to be virtual.
72 | ~MyString() { delete[] c_string_; }
73 |
74 | // Gets the 0-terminated C string this MyString object represents.
75 | const char* c_string() const { return c_string_; }
76 |
77 | size_t Length() const {
78 | return c_string_ == NULL ? 0 : strlen(c_string_);
79 | }
80 |
81 | // Sets the 0-terminated C string this MyString object represents.
82 | void Set(const char* c_string);
83 | };
84 |
85 |
86 | #endif // GTEST_SAMPLES_SAMPLE2_H_
87 |
--------------------------------------------------------------------------------
/CODINGSTANDARDS:
--------------------------------------------------------------------------------
1 | /**
2 | * @file CODINGSTANDARDS
3 | * @date 30.11.2011
4 | * @author Ralf Karrenberg
5 | *
6 | * This file is distributed under the University of Illinois Open Source
7 | * License. See the COPYING file in the root directory for details.
8 | *
9 | * Copyright (C) 2011 Saarland University
10 | *
11 | */
12 |
13 | ================================================================================
14 | 0. INTRODUCTION
15 |
16 | These are Just some randomly gathered remarks of how I would like to see the
17 | code in this project.
18 | This does not necessarily reflect the current state but should be obeyed for
19 | new code.
20 | The only exception from this is the "tabs to spaces" convention, which should
21 | be changed for all files at once at some point.
22 |
23 | ================================================================================
24 | 1. NAMING
25 |
26 | - camelcase
27 | - give meaningful names, even if the variable name becomes excessively long!
28 | - Types start with a capital letter
29 | - Variables start with a lowercase letter
30 | - Class members should start with a lowercase 'm', e.g. mVerbose
31 | - Output parameters of functions should start with a lowercase 'o', e.g. oPosition
32 | - Method names start with a small letter
33 | - Static method names start with a capital letter
34 | - #defined values and macros are in uppercase with underscores, e.g. SIMD_WIDTH
35 | - static constants are in uppercase with underscores
36 |
37 | ================================================================================
38 | 2. FORMATTING
39 |
40 | - tabsize 4, tabs to spaces (currently *not* the case!)
41 | - maximum line width of 100
42 | - no indentation inside namespaces
43 | - no indentation of "private"/"public"/"protected"
44 |
45 | - function declarations (should somehow depend on #parameters):
46 | void classFun(T param1, T param2, T param3,
47 | T param4, T param5) const;
48 |
49 | - function implementations (should somehow depend on #parameters):
50 | void
51 | ClassName::classFun(T param1,
52 | T param2,
53 | T param3,
54 | T param4,
55 | T param5) const
56 | {
57 | // body
58 | }
59 |
60 | - switch:
61 | switch (someVal)
62 | {
63 | case VAL1:
64 | {
65 | // ...
66 | }
67 | case VAL2:
68 | {
69 | // ...
70 | }
71 | }
72 |
73 | ================================================================================
74 | 3. MISC
75 |
76 | - try to prevent unnecessary indentation by using break/continue/return
77 |
78 |
79 | ================================================================================
80 | 4. CONTRIBUTING CODE (USING THE GIT REPOSITORY)
81 |
82 | This does not really belong here, but is worthwile mentioning.
83 |
84 | - try to keep the history linear, i.e. use "git pull --rebase"
85 | - don't push multiple commits that revert each other
86 | - instead, use "git reset" and fix your commits upfront
87 | - one batch of commits should never introduce code and remove it again
88 | - keep commits separated (use git add -p and git commit --amend)
89 | - never push unless all test suites succeed
90 | - *always* write detailed commit messages
91 | - formatting of commit messages:
92 | - one short description in the first line
93 | - one blank line
94 | - detailed description of what this commit does
95 | - reference/close issues with "refs #12345" and "closes #12345"
96 | - whenever the code adds functionality or fixes a bug, include a test in the
97 | commit if none existed so far
98 |
--------------------------------------------------------------------------------
/test/gtest/m4/gtest.m4:
--------------------------------------------------------------------------------
1 | dnl GTEST_LIB_CHECK([minimum version [,
2 | dnl action if found [,action if not found]]])
3 | dnl
4 | dnl Check for the presence of the Google Test library, optionally at a minimum
5 | dnl version, and indicate a viable version with the HAVE_GTEST flag. It defines
6 | dnl standard variables for substitution including GTEST_CPPFLAGS,
7 | dnl GTEST_CXXFLAGS, GTEST_LDFLAGS, and GTEST_LIBS. It also defines
8 | dnl GTEST_VERSION as the version of Google Test found. Finally, it provides
9 | dnl optional custom action slots in the event GTEST is found or not.
10 | AC_DEFUN([GTEST_LIB_CHECK],
11 | [
12 | dnl Provide a flag to enable or disable Google Test usage.
13 | AC_ARG_ENABLE([gtest],
14 | [AS_HELP_STRING([--enable-gtest],
15 | [Enable tests using the Google C++ Testing Framework.
16 | (Default is enabled.)])],
17 | [],
18 | [enable_gtest=])
19 | AC_ARG_VAR([GTEST_CONFIG],
20 | [The exact path of Google Test's 'gtest-config' script.])
21 | AC_ARG_VAR([GTEST_CPPFLAGS],
22 | [C-like preprocessor flags for Google Test.])
23 | AC_ARG_VAR([GTEST_CXXFLAGS],
24 | [C++ compile flags for Google Test.])
25 | AC_ARG_VAR([GTEST_LDFLAGS],
26 | [Linker path and option flags for Google Test.])
27 | AC_ARG_VAR([GTEST_LIBS],
28 | [Library linking flags for Google Test.])
29 | AC_ARG_VAR([GTEST_VERSION],
30 | [The version of Google Test available.])
31 | HAVE_GTEST="no"
32 | AS_IF([test "x${enable_gtest}" != "xno"],
33 | [AC_MSG_CHECKING([for 'gtest-config'])
34 | AS_IF([test "x${enable_gtest}" != "xyes"],
35 | [AS_IF([test -x "${enable_gtest}/scripts/gtest-config"],
36 | [GTEST_CONFIG="${enable_gtest}/scripts/gtest-config"],
37 | [GTEST_CONFIG="${enable_gtest}/bin/gtest-config"])
38 | AS_IF([test -x "${GTEST_CONFIG}"], [],
39 | [AC_MSG_RESULT([no])
40 | AC_MSG_ERROR([dnl
41 | Unable to locate either a built or installed Google Test.
42 | The specific location '${enable_gtest}' was provided for a built or installed
43 | Google Test, but no 'gtest-config' script could be found at this location.])
44 | ])],
45 | [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])])
46 | AS_IF([test -x "${GTEST_CONFIG}"],
47 | [AC_MSG_RESULT([${GTEST_CONFIG}])
48 | m4_ifval([$1],
49 | [_gtest_min_version="--min-version=$1"
50 | AC_MSG_CHECKING([for Google Test at least version >= $1])],
51 | [_gtest_min_version="--min-version=0"
52 | AC_MSG_CHECKING([for Google Test])])
53 | AS_IF([${GTEST_CONFIG} ${_gtest_min_version}],
54 | [AC_MSG_RESULT([yes])
55 | HAVE_GTEST='yes'],
56 | [AC_MSG_RESULT([no])])],
57 | [AC_MSG_RESULT([no])])
58 | AS_IF([test "x${HAVE_GTEST}" = "xyes"],
59 | [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`
60 | GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`
61 | GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
62 | GTEST_LIBS=`${GTEST_CONFIG} --libs`
63 | GTEST_VERSION=`${GTEST_CONFIG} --version`
64 | AC_DEFINE([HAVE_GTEST],[1],[Defined when Google Test is available.])],
65 | [AS_IF([test "x${enable_gtest}" = "xyes"],
66 | [AC_MSG_ERROR([dnl
67 | Google Test was enabled, but no viable version could be found.])
68 | ])])])
69 | AC_SUBST([HAVE_GTEST])
70 | AM_CONDITIONAL([HAVE_GTEST],[test "x$HAVE_GTEST" = "xyes"])
71 | AS_IF([test "x$HAVE_GTEST" = "xyes"],
72 | [m4_ifval([$2], [$2])],
73 | [m4_ifval([$3], [$3])])
74 | ])
75 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_break_on_failure_unittest_.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2006, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | // Unit test for Google Test's break-on-failure mode.
33 | //
34 | // A user can ask Google Test to seg-fault when an assertion fails, using
35 | // either the GTEST_BREAK_ON_FAILURE environment variable or the
36 | // --gtest_break_on_failure flag. This file is used for testing such
37 | // functionality.
38 | //
39 | // This program will be invoked from a Python unit test. It is
40 | // expected to fail. Don't run it directly.
41 |
42 | #include "gtest/gtest.h"
43 |
44 | #if GTEST_OS_WINDOWS
45 | # include
46 | # include
47 | #endif
48 |
49 | namespace {
50 |
51 | // A test that's expected to fail.
52 | TEST(Foo, Bar) {
53 | EXPECT_EQ(2, 3);
54 | }
55 |
56 | #if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE
57 | // On Windows Mobile global exception handlers are not supported.
58 | LONG WINAPI ExitWithExceptionCode(
59 | struct _EXCEPTION_POINTERS* exception_pointers) {
60 | exit(exception_pointers->ExceptionRecord->ExceptionCode);
61 | }
62 | #endif
63 |
64 | } // namespace
65 |
66 | int main(int argc, char **argv) {
67 | #if GTEST_OS_WINDOWS
68 | // Suppresses display of the Windows error dialog upon encountering
69 | // a general protection fault (segment violation).
70 | SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS);
71 |
72 | # if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE
73 |
74 | // The default unhandled exception filter does not always exit
75 | // with the exception code as exit code - for example it exits with
76 | // 0 for EXCEPTION_ACCESS_VIOLATION and 1 for EXCEPTION_BREAKPOINT
77 | // if the application is compiled in debug mode. Thus we use our own
78 | // filter which always exits with the exception code for unhandled
79 | // exceptions.
80 | SetUnhandledExceptionFilter(ExitWithExceptionCode);
81 |
82 | # endif
83 | #endif
84 |
85 | testing::InitGoogleTest(&argc, argv);
86 |
87 | return RUN_ALL_TESTS();
88 | }
89 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_throw_on_failure_ex_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2009, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | // Tests Google Test's throw-on-failure mode with exceptions enabled.
33 |
34 | #include "gtest/gtest.h"
35 |
36 | #include
37 | #include
38 | #include
39 | #include
40 |
41 | // Prints the given failure message and exits the program with
42 | // non-zero. We use this instead of a Google Test assertion to
43 | // indicate a failure, as the latter is been tested and cannot be
44 | // relied on.
45 | void Fail(const char* msg) {
46 | printf("FAILURE: %s\n", msg);
47 | fflush(stdout);
48 | exit(1);
49 | }
50 |
51 | // Tests that an assertion failure throws a subclass of
52 | // std::runtime_error.
53 | void TestFailureThrowsRuntimeError() {
54 | testing::GTEST_FLAG(throw_on_failure) = true;
55 |
56 | // A successful assertion shouldn't throw.
57 | try {
58 | EXPECT_EQ(3, 3);
59 | } catch(...) {
60 | Fail("A successful assertion wrongfully threw.");
61 | }
62 |
63 | // A failed assertion should throw a subclass of std::runtime_error.
64 | try {
65 | EXPECT_EQ(2, 3) << "Expected failure";
66 | } catch(const std::runtime_error& e) {
67 | if (strstr(e.what(), "Expected failure") != NULL)
68 | return;
69 |
70 | printf("%s",
71 | "A failed assertion did throw an exception of the right type, "
72 | "but the message is incorrect. Instead of containing \"Expected "
73 | "failure\", it is:\n");
74 | Fail(e.what());
75 | } catch(...) {
76 | Fail("A failed assertion threw the wrong type of exception.");
77 | }
78 | Fail("A failed assertion should've thrown but didn't.");
79 | }
80 |
81 | int main(int argc, char** argv) {
82 | testing::InitGoogleTest(&argc, argv);
83 |
84 | // We want to ensure that people can use Google Test assertions in
85 | // other testing frameworks, as long as they initialize Google Test
86 | // properly and set the thrown-on-failure mode. Therefore, we don't
87 | // use Google Test's constructs for defining and running tests
88 | // (e.g. TEST and RUN_ALL_TESTS) here.
89 |
90 | TestFailureThrowsRuntimeError();
91 | return 0;
92 | }
93 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_shuffle_test_.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2009, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | // Verifies that test shuffling works.
33 |
34 | #include "gtest/gtest.h"
35 |
36 | namespace {
37 |
38 | using ::testing::EmptyTestEventListener;
39 | using ::testing::InitGoogleTest;
40 | using ::testing::Message;
41 | using ::testing::Test;
42 | using ::testing::TestEventListeners;
43 | using ::testing::TestInfo;
44 | using ::testing::UnitTest;
45 | using ::testing::internal::String;
46 | using ::testing::internal::scoped_ptr;
47 |
48 | // The test methods are empty, as the sole purpose of this program is
49 | // to print the test names before/after shuffling.
50 |
51 | class A : public Test {};
52 | TEST_F(A, A) {}
53 | TEST_F(A, B) {}
54 |
55 | TEST(ADeathTest, A) {}
56 | TEST(ADeathTest, B) {}
57 | TEST(ADeathTest, C) {}
58 |
59 | TEST(B, A) {}
60 | TEST(B, B) {}
61 | TEST(B, C) {}
62 | TEST(B, DISABLED_D) {}
63 | TEST(B, DISABLED_E) {}
64 |
65 | TEST(BDeathTest, A) {}
66 | TEST(BDeathTest, B) {}
67 |
68 | TEST(C, A) {}
69 | TEST(C, B) {}
70 | TEST(C, C) {}
71 | TEST(C, DISABLED_D) {}
72 |
73 | TEST(CDeathTest, A) {}
74 |
75 | TEST(DISABLED_D, A) {}
76 | TEST(DISABLED_D, DISABLED_B) {}
77 |
78 | // This printer prints the full test names only, starting each test
79 | // iteration with a "----" marker.
80 | class TestNamePrinter : public EmptyTestEventListener {
81 | public:
82 | virtual void OnTestIterationStart(const UnitTest& /* unit_test */,
83 | int /* iteration */) {
84 | printf("----\n");
85 | }
86 |
87 | virtual void OnTestStart(const TestInfo& test_info) {
88 | printf("%s.%s\n", test_info.test_case_name(), test_info.name());
89 | }
90 | };
91 |
92 | } // namespace
93 |
94 | int main(int argc, char **argv) {
95 | InitGoogleTest(&argc, argv);
96 |
97 | // Replaces the default printer with TestNamePrinter, which prints
98 | // the test name only.
99 | TestEventListeners& listeners = UnitTest::GetInstance()->listeners();
100 | delete listeners.Release(listeners.default_result_printer());
101 | listeners.Append(new TestNamePrinter);
102 |
103 | return RUN_ALL_TESTS();
104 | }
105 |
--------------------------------------------------------------------------------
/src/utils/wholeFunctionVectorizationAAW.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * @file wholeFunctionVectorizationAAW.hpp
3 | * @date 17.05.2011
4 | * @author Ralf Karrenberg
5 | *
6 | * This file is distributed under the University of Illinois Open Source
7 | * License. See the COPYING file in the root directory for details.
8 | *
9 | * Copyright (C) 2011 Saarland University
10 | *
11 | * This custom assembly annotation writer allows us to print analysis results.
12 | *
13 | */
14 |
15 | #ifndef WHOLEFUNCTIONVECTORIZATIONAAW_HPP
16 | #define WHOLEFUNCTIONVECTORIZATIONAAW_HPP
17 |
18 | // the following include is only required for single-file compilation
19 | #include "llvm/Value.h" // has to come before AAW.h
20 |
21 | #include "llvm/Assembly/AssemblyAnnotationWriter.h"
22 | #include "llvm/Support/FormattedStream.h"
23 |
24 | #include "utils/analysisResults.hpp"
25 |
26 | namespace {
27 |
28 | class WholeFunctionVectorizationAAW : public AssemblyAnnotationWriter {
29 | public:
30 | WholeFunctionVectorizationAAW(const AnalysisResults& va)
31 | : analysisResults(va)
32 | {}
33 |
34 | /// emitFunctionAnnot - This may be implemented to emit a string right before
35 | /// the start of a function.
36 | //virtual void emitFunctionAnnot(const Function *F,
37 | //formatted_raw_ostream &OS)
38 | //{}
39 |
40 | /// emitBasicBlockStartAnnot - This may be implemented to emit a string right
41 | /// after the basic block label, but before the first instruction in the
42 | /// block.
43 | virtual void emitBasicBlockStartAnnot(const BasicBlock *BB,
44 | formatted_raw_ostream &OS)
45 | {
46 | const AnalysisResults::BlockInfo* bi =
47 | analysisResults.getBlockInfo(BB);
48 | OS << analysisResults.getBlockInfoString(bi) << "\n";
49 | }
50 |
51 | /// emitBasicBlockEndAnnot - This may be implemented to emit a string right
52 | /// after the basic block.
53 | //virtual void emitBasicBlockEndAnnot(const BasicBlock *BB,
54 | //formatted_raw_ostream &OS)
55 | //{}
56 |
57 | /// emitInstructionAnnot - This may be implemented to emit a string right
58 | /// before an instruction is emitted.
59 | //virtual void emitInstructionAnnot(const Instruction *I,
60 | //formatted_raw_ostream &OS)
61 | //{}
62 |
63 | /// printInfoComment - This may be implemented to emit a comment to the
64 | /// right of an instruction or global value.
65 | virtual void printInfoComment(const llvm::Value &V, formatted_raw_ostream &OS)
66 | {
67 | if (isa(V)) return;
68 |
69 | const AnalysisResults::ValueInfo* info =
70 | analysisResults.getValueInfo(&V);
71 |
72 | // print value information
73 | if (info) {
74 | // print uniform info
75 | const AnalysisResults::UniformInfo& ui = info->uniformInfo;
76 | const std::string& uis = analysisResults.getUniformInfoString(ui);
77 | OS << " ; " << uis;
78 |
79 | // print index info
80 | const AnalysisResults::IndexInfo& ii = info->indexInfo;
81 | const std::string& iis = analysisResults.getIndexInfoString(ii);
82 | OS << ", " << iis;
83 |
84 | // print alignment info
85 | const AnalysisResults::AlignmentInfo& ai = info->alignmentInfo;
86 | const std::string& ais = analysisResults.getAlignmentInfoString(ai);
87 | OS << ", " << ais;
88 |
89 | // print split info
90 | const AnalysisResults::SplitInfo& si = info->splitInfo;
91 | const std::string& sis = analysisResults.getSplitInfoString(si);
92 | OS << ", " << sis;
93 |
94 | // print mask info
95 | if (info->isMask) OS << ", MASK";
96 | }
97 |
98 | // print type and #uses
99 | OS << " " << *V.getType() << " [" << V.getNumUses() << "]";
100 | }
101 |
102 | private:
103 | const AnalysisResults& analysisResults;
104 | };
105 |
106 | } // unnamed namespace
107 |
108 | #endif /* WHOLEFUNCTIONVECTORIZATIONAAW_HPP */
109 |
110 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_env_var_test.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2008, Google Inc.
4 | # All rights reserved.
5 | #
6 | # Redistribution and use in source and binary forms, with or without
7 | # modification, are permitted provided that the following conditions are
8 | # met:
9 | #
10 | # * Redistributions of source code must retain the above copyright
11 | # notice, this list of conditions and the following disclaimer.
12 | # * Redistributions in binary form must reproduce the above
13 | # copyright notice, this list of conditions and the following disclaimer
14 | # in the documentation and/or other materials provided with the
15 | # distribution.
16 | # * Neither the name of Google Inc. nor the names of its
17 | # contributors may be used to endorse or promote products derived from
18 | # this software without specific prior written permission.
19 | #
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 |
32 | """Verifies that Google Test correctly parses environment variables."""
33 |
34 | __author__ = 'wan@google.com (Zhanyong Wan)'
35 |
36 | import os
37 | import gtest_test_utils
38 |
39 |
40 | IS_WINDOWS = os.name == 'nt'
41 | IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
42 |
43 | COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_env_var_test_')
44 |
45 | environ = os.environ.copy()
46 |
47 |
48 | def AssertEq(expected, actual):
49 | if expected != actual:
50 | print 'Expected: %s' % (expected,)
51 | print ' Actual: %s' % (actual,)
52 | raise AssertionError
53 |
54 |
55 | def SetEnvVar(env_var, value):
56 | """Sets the env variable to 'value'; unsets it when 'value' is None."""
57 |
58 | if value is not None:
59 | environ[env_var] = value
60 | elif env_var in environ:
61 | del environ[env_var]
62 |
63 |
64 | def GetFlag(flag):
65 | """Runs gtest_env_var_test_ and returns its output."""
66 |
67 | args = [COMMAND]
68 | if flag is not None:
69 | args += [flag]
70 | return gtest_test_utils.Subprocess(args, env=environ).output
71 |
72 |
73 | def TestFlag(flag, test_val, default_val):
74 | """Verifies that the given flag is affected by the corresponding env var."""
75 |
76 | env_var = 'GTEST_' + flag.upper()
77 | SetEnvVar(env_var, test_val)
78 | AssertEq(test_val, GetFlag(flag))
79 | SetEnvVar(env_var, None)
80 | AssertEq(default_val, GetFlag(flag))
81 |
82 |
83 | class GTestEnvVarTest(gtest_test_utils.TestCase):
84 | def testEnvVarAffectsFlag(self):
85 | """Tests that environment variable should affect the corresponding flag."""
86 |
87 | TestFlag('break_on_failure', '1', '0')
88 | TestFlag('color', 'yes', 'auto')
89 | TestFlag('filter', 'FooTest.Bar', '*')
90 | TestFlag('output', 'xml:tmp/foo.xml', '')
91 | TestFlag('print_time', '0', '1')
92 | TestFlag('repeat', '999', '1')
93 | TestFlag('throw_on_failure', '1', '0')
94 | TestFlag('death_test_style', 'threadsafe', 'fast')
95 | TestFlag('catch_exceptions', '0', '1')
96 |
97 | if IS_LINUX:
98 | TestFlag('death_test_use_fork', '1', '0')
99 | TestFlag('stack_trace_depth', '0', '100')
100 |
101 |
102 | if __name__ == '__main__':
103 | gtest_test_utils.Main()
104 |
--------------------------------------------------------------------------------
/test/gtest/msvc/gtest.vcproj:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
11 |
12 |
13 |
20 |
31 |
33 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
55 |
62 |
70 |
72 |
75 |
77 |
79 |
81 |
83 |
85 |
87 |
89 |
91 |
93 |
94 |
95 |
96 |
97 |
98 |
102 |
104 |
106 |
109 |
110 |
112 |
115 |
116 |
117 |
118 |
122 |
123 |
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/test/gtest/msvc/gtest-md.vcproj:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
11 |
12 |
13 |
20 |
31 |
33 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
55 |
62 |
70 |
72 |
75 |
77 |
79 |
81 |
83 |
85 |
87 |
89 |
91 |
93 |
94 |
95 |
96 |
97 |
98 |
102 |
104 |
106 |
109 |
110 |
112 |
115 |
116 |
117 |
118 |
122 |
123 |
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest-death-test_ex_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2010, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: vladl@google.com (Vlad Losev)
31 | //
32 | // Tests that verify interaction of exceptions and death tests.
33 |
34 | #include "gtest/gtest-death-test.h"
35 | #include "gtest/gtest.h"
36 |
37 | #if GTEST_HAS_DEATH_TEST
38 |
39 | # if GTEST_HAS_SEH
40 | # include // For RaiseException().
41 | # endif
42 |
43 | # include "gtest/gtest-spi.h"
44 |
45 | # if GTEST_HAS_EXCEPTIONS
46 |
47 | # include // For std::exception.
48 |
49 | // Tests that death tests report thrown exceptions as failures and that the
50 | // exceptions do not escape death test macros.
51 | TEST(CxxExceptionDeathTest, ExceptionIsFailure) {
52 | try {
53 | EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw 1, ""), "threw an exception");
54 | } catch (...) { // NOLINT
55 | FAIL() << "An exception escaped a death test macro invocation "
56 | << "with catch_exceptions "
57 | << (testing::GTEST_FLAG(catch_exceptions) ? "enabled" : "disabled");
58 | }
59 | }
60 |
61 | class TestException : public std::exception {
62 | public:
63 | virtual const char* what() const throw() { return "exceptional message"; }
64 | };
65 |
66 | TEST(CxxExceptionDeathTest, PrintsMessageForStdExceptions) {
67 | // Verifies that the exception message is quoted in the failure text.
68 | EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw TestException(), ""),
69 | "exceptional message");
70 | // Verifies that the location is mentioned in the failure text.
71 | EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw TestException(), ""),
72 | "gtest-death-test_ex_test.cc");
73 | }
74 | # endif // GTEST_HAS_EXCEPTIONS
75 |
76 | # if GTEST_HAS_SEH
77 | // Tests that enabling interception of SEH exceptions with the
78 | // catch_exceptions flag does not interfere with SEH exceptions being
79 | // treated as death by death tests.
80 | TEST(SehExceptionDeasTest, CatchExceptionsDoesNotInterfere) {
81 | EXPECT_DEATH(RaiseException(42, 0x0, 0, NULL), "")
82 | << "with catch_exceptions "
83 | << (testing::GTEST_FLAG(catch_exceptions) ? "enabled" : "disabled");
84 | }
85 | # endif
86 |
87 | #endif // GTEST_HAS_DEATH_TEST
88 |
89 | int main(int argc, char** argv) {
90 | testing::InitGoogleTest(&argc, argv);
91 | testing::GTEST_FLAG(catch_exceptions) = GTEST_ENABLE_CATCH_EXCEPTIONS_ != 0;
92 | return RUN_ALL_TESTS();
93 | }
94 |
--------------------------------------------------------------------------------
/test/gtest/msvc/gtest_main.vcproj:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
11 |
12 |
13 |
20 |
31 |
33 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
55 |
62 |
70 |
72 |
75 |
77 |
79 |
81 |
83 |
85 |
87 |
89 |
91 |
93 |
94 |
95 |
96 |
99 |
100 |
101 |
105 |
107 |
109 |
112 |
113 |
115 |
118 |
119 |
120 |
121 |
125 |
126 |
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/test/gtest/msvc/gtest_main-md.vcproj:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
11 |
12 |
13 |
20 |
31 |
33 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
55 |
62 |
70 |
72 |
75 |
77 |
79 |
81 |
83 |
85 |
87 |
89 |
91 |
93 |
94 |
95 |
96 |
99 |
100 |
101 |
105 |
107 |
109 |
112 |
113 |
115 |
118 |
119 |
120 |
121 |
125 |
126 |
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_env_var_test_.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | // A helper program for testing that Google Test parses the environment
33 | // variables correctly.
34 |
35 | #include "gtest/gtest.h"
36 |
37 | #include
38 |
39 | #define GTEST_IMPLEMENTATION_ 1
40 | #include "src/gtest-internal-inl.h"
41 | #undef GTEST_IMPLEMENTATION_
42 |
43 | using ::std::cout;
44 |
45 | namespace testing {
46 |
47 | // The purpose of this is to make the test more realistic by ensuring
48 | // that the UnitTest singleton is created before main() is entered.
49 | // We don't actual run the TEST itself.
50 | TEST(GTestEnvVarTest, Dummy) {
51 | }
52 |
53 | void PrintFlag(const char* flag) {
54 | if (strcmp(flag, "break_on_failure") == 0) {
55 | cout << GTEST_FLAG(break_on_failure);
56 | return;
57 | }
58 |
59 | if (strcmp(flag, "catch_exceptions") == 0) {
60 | cout << GTEST_FLAG(catch_exceptions);
61 | return;
62 | }
63 |
64 | if (strcmp(flag, "color") == 0) {
65 | cout << GTEST_FLAG(color);
66 | return;
67 | }
68 |
69 | if (strcmp(flag, "death_test_style") == 0) {
70 | cout << GTEST_FLAG(death_test_style);
71 | return;
72 | }
73 |
74 | if (strcmp(flag, "death_test_use_fork") == 0) {
75 | cout << GTEST_FLAG(death_test_use_fork);
76 | return;
77 | }
78 |
79 | if (strcmp(flag, "filter") == 0) {
80 | cout << GTEST_FLAG(filter);
81 | return;
82 | }
83 |
84 | if (strcmp(flag, "output") == 0) {
85 | cout << GTEST_FLAG(output);
86 | return;
87 | }
88 |
89 | if (strcmp(flag, "print_time") == 0) {
90 | cout << GTEST_FLAG(print_time);
91 | return;
92 | }
93 |
94 | if (strcmp(flag, "repeat") == 0) {
95 | cout << GTEST_FLAG(repeat);
96 | return;
97 | }
98 |
99 | if (strcmp(flag, "stack_trace_depth") == 0) {
100 | cout << GTEST_FLAG(stack_trace_depth);
101 | return;
102 | }
103 |
104 | if (strcmp(flag, "throw_on_failure") == 0) {
105 | cout << GTEST_FLAG(throw_on_failure);
106 | return;
107 | }
108 |
109 | cout << "Invalid flag name " << flag
110 | << ". Valid names are break_on_failure, color, filter, etc.\n";
111 | exit(1);
112 | }
113 |
114 | } // namespace testing
115 |
116 | int main(int argc, char** argv) {
117 | testing::InitGoogleTest(&argc, argv);
118 |
119 | if (argc != 2) {
120 | cout << "Usage: gtest_env_var_test_ NAME_OF_FLAG\n";
121 | return 1;
122 | }
123 |
124 | testing::PrintFlag(argv[1]);
125 | return 0;
126 | }
127 |
--------------------------------------------------------------------------------
/test/gtest/src/gtest-typed-test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2008 Google Inc.
2 | // All Rights Reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | #include "gtest/gtest-typed-test.h"
33 | #include "gtest/gtest.h"
34 |
35 | namespace testing {
36 | namespace internal {
37 |
38 | #if GTEST_HAS_TYPED_TEST_P
39 |
40 | // Skips to the first non-space char in str. Returns an empty string if str
41 | // contains only whitespace characters.
42 | static const char* SkipSpaces(const char* str) {
43 | while (IsSpace(*str))
44 | str++;
45 | return str;
46 | }
47 |
48 | // Verifies that registered_tests match the test names in
49 | // defined_test_names_; returns registered_tests if successful, or
50 | // aborts the program otherwise.
51 | const char* TypedTestCasePState::VerifyRegisteredTestNames(
52 | const char* file, int line, const char* registered_tests) {
53 | typedef ::std::set::const_iterator DefinedTestIter;
54 | registered_ = true;
55 |
56 | // Skip initial whitespace in registered_tests since some
57 | // preprocessors prefix stringizied literals with whitespace.
58 | registered_tests = SkipSpaces(registered_tests);
59 |
60 | Message errors;
61 | ::std::set tests;
62 | for (const char* names = registered_tests; names != NULL;
63 | names = SkipComma(names)) {
64 | const String name = GetPrefixUntilComma(names);
65 | if (tests.count(name) != 0) {
66 | errors << "Test " << name << " is listed more than once.\n";
67 | continue;
68 | }
69 |
70 | bool found = false;
71 | for (DefinedTestIter it = defined_test_names_.begin();
72 | it != defined_test_names_.end();
73 | ++it) {
74 | if (name == *it) {
75 | found = true;
76 | break;
77 | }
78 | }
79 |
80 | if (found) {
81 | tests.insert(name);
82 | } else {
83 | errors << "No test named " << name
84 | << " can be found in this test case.\n";
85 | }
86 | }
87 |
88 | for (DefinedTestIter it = defined_test_names_.begin();
89 | it != defined_test_names_.end();
90 | ++it) {
91 | if (tests.count(*it) == 0) {
92 | errors << "You forgot to list test " << *it << ".\n";
93 | }
94 | }
95 |
96 | const String& errors_str = errors.GetString();
97 | if (errors_str != "") {
98 | fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
99 | errors_str.c_str());
100 | fflush(stderr);
101 | posix::Abort();
102 | }
103 |
104 | return registered_tests;
105 | }
106 |
107 | #endif // GTEST_HAS_TYPED_TEST_P
108 |
109 | } // namespace internal
110 | } // namespace testing
111 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest_filter_unittest_.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2005, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | // Unit test for Google Test test filters.
33 | //
34 | // A user can specify which test(s) in a Google Test program to run via
35 | // either the GTEST_FILTER environment variable or the --gtest_filter
36 | // flag. This is used for testing such functionality.
37 | //
38 | // The program will be invoked from a Python unit test. Don't run it
39 | // directly.
40 |
41 | #include "gtest/gtest.h"
42 |
43 | namespace {
44 |
45 | // Test case FooTest.
46 |
47 | class FooTest : public testing::Test {
48 | };
49 |
50 | TEST_F(FooTest, Abc) {
51 | }
52 |
53 | TEST_F(FooTest, Xyz) {
54 | FAIL() << "Expected failure.";
55 | }
56 |
57 | // Test case BarTest.
58 |
59 | TEST(BarTest, TestOne) {
60 | }
61 |
62 | TEST(BarTest, TestTwo) {
63 | }
64 |
65 | TEST(BarTest, TestThree) {
66 | }
67 |
68 | TEST(BarTest, DISABLED_TestFour) {
69 | FAIL() << "Expected failure.";
70 | }
71 |
72 | TEST(BarTest, DISABLED_TestFive) {
73 | FAIL() << "Expected failure.";
74 | }
75 |
76 | // Test case BazTest.
77 |
78 | TEST(BazTest, TestOne) {
79 | FAIL() << "Expected failure.";
80 | }
81 |
82 | TEST(BazTest, TestA) {
83 | }
84 |
85 | TEST(BazTest, TestB) {
86 | }
87 |
88 | TEST(BazTest, DISABLED_TestC) {
89 | FAIL() << "Expected failure.";
90 | }
91 |
92 | // Test case HasDeathTest
93 |
94 | TEST(HasDeathTest, Test1) {
95 | EXPECT_DEATH_IF_SUPPORTED(exit(1), ".*");
96 | }
97 |
98 | // We need at least two death tests to make sure that the all death tests
99 | // aren't on the first shard.
100 | TEST(HasDeathTest, Test2) {
101 | EXPECT_DEATH_IF_SUPPORTED(exit(1), ".*");
102 | }
103 |
104 | // Test case FoobarTest
105 |
106 | TEST(DISABLED_FoobarTest, Test1) {
107 | FAIL() << "Expected failure.";
108 | }
109 |
110 | TEST(DISABLED_FoobarTest, DISABLED_Test2) {
111 | FAIL() << "Expected failure.";
112 | }
113 |
114 | // Test case FoobarbazTest
115 |
116 | TEST(DISABLED_FoobarbazTest, TestA) {
117 | FAIL() << "Expected failure.";
118 | }
119 |
120 | #if GTEST_HAS_PARAM_TEST
121 | class ParamTest : public testing::TestWithParam {
122 | };
123 |
124 | TEST_P(ParamTest, TestX) {
125 | }
126 |
127 | TEST_P(ParamTest, TestY) {
128 | }
129 |
130 | INSTANTIATE_TEST_CASE_P(SeqP, ParamTest, testing::Values(1, 2));
131 | INSTANTIATE_TEST_CASE_P(SeqQ, ParamTest, testing::Values(5, 6));
132 | #endif // GTEST_HAS_PARAM_TEST
133 |
134 | } // namespace
135 |
136 | int main(int argc, char **argv) {
137 | ::testing::InitGoogleTest(&argc, argv);
138 |
139 | return RUN_ALL_TESTS();
140 | }
141 |
--------------------------------------------------------------------------------
/test/gtest/samples/sample2_unittest.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2005, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 | // A sample program demonstrating using Google C++ testing framework.
31 | //
32 | // Author: wan@google.com (Zhanyong Wan)
33 |
34 |
35 | // This sample shows how to write a more complex unit test for a class
36 | // that has multiple member functions.
37 | //
38 | // Usually, it's a good idea to have one test for each method in your
39 | // class. You don't have to do that exactly, but it helps to keep
40 | // your tests organized. You may also throw in additional tests as
41 | // needed.
42 |
43 | #include "sample2.h"
44 | #include "gtest/gtest.h"
45 |
46 | // In this example, we test the MyString class (a simple string).
47 |
48 | // Tests the default c'tor.
49 | TEST(MyString, DefaultConstructor) {
50 | const MyString s;
51 |
52 | // Asserts that s.c_string() returns NULL.
53 | //
54 | //
55 | //
56 | // If we write NULL instead of
57 | //
58 | // static_cast(NULL)
59 | //
60 | // in this assertion, it will generate a warning on gcc 3.4. The
61 | // reason is that EXPECT_EQ needs to know the types of its
62 | // arguments in order to print them when it fails. Since NULL is
63 | // #defined as 0, the compiler will use the formatter function for
64 | // int to print it. However, gcc thinks that NULL should be used as
65 | // a pointer, not an int, and therefore complains.
66 | //
67 | // The root of the problem is C++'s lack of distinction between the
68 | // integer number 0 and the null pointer constant. Unfortunately,
69 | // we have to live with this fact.
70 | //
71 | //
72 | EXPECT_STREQ(NULL, s.c_string());
73 |
74 | EXPECT_EQ(0u, s.Length());
75 | }
76 |
77 | const char kHelloString[] = "Hello, world!";
78 |
79 | // Tests the c'tor that accepts a C string.
80 | TEST(MyString, ConstructorFromCString) {
81 | const MyString s(kHelloString);
82 | EXPECT_TRUE(strcmp(s.c_string(), kHelloString) == 0);
83 | EXPECT_EQ(sizeof(kHelloString)/sizeof(kHelloString[0]) - 1,
84 | s.Length());
85 | }
86 |
87 | // Tests the copy c'tor.
88 | TEST(MyString, CopyConstructor) {
89 | const MyString s1(kHelloString);
90 | const MyString s2 = s1;
91 | EXPECT_TRUE(strcmp(s2.c_string(), kHelloString) == 0);
92 | }
93 |
94 | // Tests the Set method.
95 | TEST(MyString, Set) {
96 | MyString s;
97 |
98 | s.Set(kHelloString);
99 | EXPECT_TRUE(strcmp(s.c_string(), kHelloString) == 0);
100 |
101 | // Set should work when the input pointer is the same as the one
102 | // already in the MyString object.
103 | s.Set(s.c_string());
104 | EXPECT_TRUE(strcmp(s.c_string(), kHelloString) == 0);
105 |
106 | // Can we set the MyString to NULL?
107 | s.Set(NULL);
108 | EXPECT_STREQ(NULL, s.c_string());
109 | }
110 |
--------------------------------------------------------------------------------
/include/packetizerAPI.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file packetizerAPI.hpp
3 | * @date 10.12.2008
4 | * @author Ralf Karrenberg
5 | *
6 | * This file is distributed under the University of Illinois Open Source
7 | * License. See the COPYING file in the root directory for details.
8 | *
9 | * Copyright (C) 2008, 2009, 2010, 2011 Saarland University
10 | *
11 | */
12 | #ifndef _PACKETIZERAPI_HPP
13 | #define _PACKETIZERAPI_HPP
14 |
15 | #include
16 |
17 | //----------------------------------------------------------------------------//
18 | // necessary definitions for library compilation
19 | //----------------------------------------------------------------------------//
20 |
21 | #if defined(_WIN32)
22 |
23 | #if !defined(PACKETIZER_STATIC_LIBS)
24 | #define PACKETIZER_DLL_EXPORT __declspec(dllexport)
25 | #define PACKETIZER_DLL_IMPORT __declspec(dllimport)
26 | #else
27 | #define PACKETIZER_DLL_EXPORT
28 | #define PACKETIZER_DLL_IMPORT
29 | #endif
30 |
31 | #else
32 |
33 | // POSIX, etc.
34 | #define PACKETIZER_DLL_EXPORT
35 | #define PACKETIZER_DLL_IMPORT
36 |
37 | #endif
38 |
39 | #if defined(PACKETIZER_LIB)
40 | #define PACKETIZER_API PACKETIZER_DLL_EXPORT
41 | #else
42 | #define PACKETIZER_API PACKETIZER_DLL_IMPORT
43 | #endif
44 |
45 | //----------------------------------------------------------------------------//
46 | //----------------------------------------------------------------------------//
47 |
48 | // LLVM forward declarations
49 | namespace llvm {
50 | class Module;
51 | class LLVMContext;
52 | class Function;
53 | class Value;
54 |
55 | class BasicBlock;
56 | class Instruction;
57 | }
58 |
59 | // WFV forward declaration
60 | class WholeFunctionVectorizer;
61 |
62 |
63 | namespace Packetizer {
64 |
65 | PACKETIZER_API class Packetizer {
66 | public:
67 | PACKETIZER_API Packetizer(llvm::Module& module, llvm::LLVMContext& context, const unsigned simdWidth, const unsigned packetizationSize, const bool use_sse41, const bool use_avx, const bool verbose);
68 | PACKETIZER_API ~Packetizer();
69 |
70 | PACKETIZER_API bool addFunction(const std::string& functionName, const std::string& simdFunctionName);
71 | PACKETIZER_API bool addVaryingFunctionMapping(const std::string& scalarFunctionName, const int maskPosition, llvm::Function* packetFunction);
72 | PACKETIZER_API bool addValueInfo(llvm::Value* value, const bool uniform, const bool consecutive, const bool aligned);
73 | PACKETIZER_API void run();
74 | PACKETIZER_API bool wfvSuccessful(const std::string& simdFunctionName, const llvm::Module& module) const;
75 |
76 | private:
77 | WholeFunctionVectorizer* wfv; // TODO: hide somehow?
78 |
79 | public:
80 | ////////////////////////////////////////////////////////////////////////////
81 | // The following functions are currently only used for testing purposes. //
82 | ////////////////////////////////////////////////////////////////////////////
83 |
84 | // TODO: put these into their own "analysis header"
85 | PACKETIZER_API bool analyzeFunction(const std::string& functionName, const std::string& newName);
86 |
87 | PACKETIZER_API bool isUniform(const llvm::Value* value) const;
88 | PACKETIZER_API bool isSame(const llvm::Value* value) const;
89 | PACKETIZER_API bool isConsecutive(const llvm::Value* value) const;
90 | PACKETIZER_API bool isRandom(const llvm::Value* value) const;
91 | PACKETIZER_API bool isAligned(const llvm::Value* value) const;
92 | PACKETIZER_API bool isMask(const llvm::Value* value) const;
93 |
94 | PACKETIZER_API bool requiresReplication(const llvm::Value* value) const;
95 | PACKETIZER_API bool requiresSplitResult(const llvm::Value* value) const;
96 | PACKETIZER_API bool requiresSplitFull(const llvm::Value* value) const;
97 | PACKETIZER_API bool requiresSplitFullGuarded(const llvm::Value* value) const;
98 |
99 | PACKETIZER_API bool isNonDivergent(const llvm::BasicBlock* block) const;
100 | PACKETIZER_API bool isFullyNonDivergent(const llvm::BasicBlock* block) const;
101 | PACKETIZER_API bool hasUniformExit(const llvm::BasicBlock* block) const;
102 | PACKETIZER_API bool hasFullyUniformExit(const llvm::BasicBlock* block) const;
103 |
104 | PACKETIZER_API bool isInputIndependent(const llvm::Instruction* value) const;
105 | };
106 |
107 |
108 | } //namespace Packetizer
109 |
110 |
111 | #endif /* _PACKETIZERAPI_HPP */
112 |
--------------------------------------------------------------------------------
/test/gtest/samples/prime_tables.h:
--------------------------------------------------------------------------------
1 | // Copyright 2008 Google Inc.
2 | // All Rights Reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 | // Author: vladl@google.com (Vlad Losev)
32 |
33 | // This provides interface PrimeTable that determines whether a number is a
34 | // prime and determines a next prime number. This interface is used
35 | // in Google Test samples demonstrating use of parameterized tests.
36 |
37 | #ifndef GTEST_SAMPLES_PRIME_TABLES_H_
38 | #define GTEST_SAMPLES_PRIME_TABLES_H_
39 |
40 | #include
41 |
42 | // The prime table interface.
43 | class PrimeTable {
44 | public:
45 | virtual ~PrimeTable() {}
46 |
47 | // Returns true iff n is a prime number.
48 | virtual bool IsPrime(int n) const = 0;
49 |
50 | // Returns the smallest prime number greater than p; or returns -1
51 | // if the next prime is beyond the capacity of the table.
52 | virtual int GetNextPrime(int p) const = 0;
53 | };
54 |
55 | // Implementation #1 calculates the primes on-the-fly.
56 | class OnTheFlyPrimeTable : public PrimeTable {
57 | public:
58 | virtual bool IsPrime(int n) const {
59 | if (n <= 1) return false;
60 |
61 | for (int i = 2; i*i <= n; i++) {
62 | // n is divisible by an integer other than 1 and itself.
63 | if ((n % i) == 0) return false;
64 | }
65 |
66 | return true;
67 | }
68 |
69 | virtual int GetNextPrime(int p) const {
70 | for (int n = p + 1; n > 0; n++) {
71 | if (IsPrime(n)) return n;
72 | }
73 |
74 | return -1;
75 | }
76 | };
77 |
78 | // Implementation #2 pre-calculates the primes and stores the result
79 | // in an array.
80 | class PreCalculatedPrimeTable : public PrimeTable {
81 | public:
82 | // 'max' specifies the maximum number the prime table holds.
83 | explicit PreCalculatedPrimeTable(int max)
84 | : is_prime_size_(max + 1), is_prime_(new bool[max + 1]) {
85 | CalculatePrimesUpTo(max);
86 | }
87 | virtual ~PreCalculatedPrimeTable() { delete[] is_prime_; }
88 |
89 | virtual bool IsPrime(int n) const {
90 | return 0 <= n && n < is_prime_size_ && is_prime_[n];
91 | }
92 |
93 | virtual int GetNextPrime(int p) const {
94 | for (int n = p + 1; n < is_prime_size_; n++) {
95 | if (is_prime_[n]) return n;
96 | }
97 |
98 | return -1;
99 | }
100 |
101 | private:
102 | void CalculatePrimesUpTo(int max) {
103 | ::std::fill(is_prime_, is_prime_ + is_prime_size_, true);
104 | is_prime_[0] = is_prime_[1] = false;
105 |
106 | for (int i = 2; i <= max; i++) {
107 | if (!is_prime_[i]) continue;
108 |
109 | // Marks all multiples of i (except i itself) as non-prime.
110 | for (int j = 2*i; j <= max; j += i) {
111 | is_prime_[j] = false;
112 | }
113 | }
114 | }
115 |
116 | const int is_prime_size_;
117 | bool* const is_prime_;
118 |
119 | // Disables compiler warning "assignment operator could not be generated."
120 | void operator=(const PreCalculatedPrimeTable& rhs);
121 | };
122 |
123 | #endif // GTEST_SAMPLES_PRIME_TABLES_H_
124 |
--------------------------------------------------------------------------------
/test/gtest/src/gtest-test-part.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: mheule@google.com (Markus Heule)
31 | //
32 | // The Google C++ Testing Framework (Google Test)
33 |
34 | #include "gtest/gtest-test-part.h"
35 |
36 | // Indicates that this translation unit is part of Google Test's
37 | // implementation. It must come before gtest-internal-inl.h is
38 | // included, or there will be a compiler error. This trick is to
39 | // prevent a user from accidentally including gtest-internal-inl.h in
40 | // his code.
41 | #define GTEST_IMPLEMENTATION_ 1
42 | #include "src/gtest-internal-inl.h"
43 | #undef GTEST_IMPLEMENTATION_
44 |
45 | namespace testing {
46 |
47 | using internal::GetUnitTestImpl;
48 |
49 | // Gets the summary of the failure message by omitting the stack trace
50 | // in it.
51 | internal::String TestPartResult::ExtractSummary(const char* message) {
52 | const char* const stack_trace = strstr(message, internal::kStackTraceMarker);
53 | return stack_trace == NULL ? internal::String(message) :
54 | internal::String(message, stack_trace - message);
55 | }
56 |
57 | // Prints a TestPartResult object.
58 | std::ostream& operator<<(std::ostream& os, const TestPartResult& result) {
59 | return os
60 | << result.file_name() << ":" << result.line_number() << ": "
61 | << (result.type() == TestPartResult::kSuccess ? "Success" :
62 | result.type() == TestPartResult::kFatalFailure ? "Fatal failure" :
63 | "Non-fatal failure") << ":\n"
64 | << result.message() << std::endl;
65 | }
66 |
67 | // Appends a TestPartResult to the array.
68 | void TestPartResultArray::Append(const TestPartResult& result) {
69 | array_.push_back(result);
70 | }
71 |
72 | // Returns the TestPartResult at the given index (0-based).
73 | const TestPartResult& TestPartResultArray::GetTestPartResult(int index) const {
74 | if (index < 0 || index >= size()) {
75 | printf("\nInvalid index (%d) into TestPartResultArray.\n", index);
76 | internal::posix::Abort();
77 | }
78 |
79 | return array_[index];
80 | }
81 |
82 | // Returns the number of TestPartResult objects in the array.
83 | int TestPartResultArray::size() const {
84 | return static_cast(array_.size());
85 | }
86 |
87 | namespace internal {
88 |
89 | HasNewFatalFailureHelper::HasNewFatalFailureHelper()
90 | : has_new_fatal_failure_(false),
91 | original_reporter_(GetUnitTestImpl()->
92 | GetTestPartResultReporterForCurrentThread()) {
93 | GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(this);
94 | }
95 |
96 | HasNewFatalFailureHelper::~HasNewFatalFailureHelper() {
97 | GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(
98 | original_reporter_);
99 | }
100 |
101 | void HasNewFatalFailureHelper::ReportTestPartResult(
102 | const TestPartResult& result) {
103 | if (result.fatally_failed())
104 | has_new_fatal_failure_ = true;
105 | original_reporter_->ReportTestPartResult(result);
106 | }
107 |
108 | } // namespace internal
109 |
110 | } // namespace testing
111 |
--------------------------------------------------------------------------------
/test/gtest/msvc/gtest_unittest.vcproj:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
11 |
12 |
13 |
19 |
30 |
32 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
61 |
67 |
75 |
77 |
86 |
88 |
90 |
92 |
94 |
96 |
98 |
100 |
102 |
104 |
106 |
107 |
108 |
109 |
112 |
113 |
114 |
118 |
120 |
122 |
129 |
130 |
132 |
136 |
137 |
138 |
139 |
143 |
144 |
145 |
146 |
147 |
148 |
--------------------------------------------------------------------------------
/test/gtest/msvc/gtest_unittest-md.vcproj:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
11 |
12 |
13 |
19 |
30 |
32 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
61 |
67 |
75 |
77 |
86 |
88 |
90 |
92 |
94 |
96 |
98 |
100 |
102 |
104 |
106 |
107 |
108 |
109 |
112 |
113 |
114 |
118 |
120 |
122 |
129 |
130 |
132 |
136 |
137 |
138 |
139 |
143 |
144 |
145 |
146 |
147 |
148 |
--------------------------------------------------------------------------------
/test/gtest/test/gtest-linked_ptr_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2003, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Authors: Dan Egnor (egnor@google.com)
31 | // Ported to Windows: Vadim Berman (vadimb@google.com)
32 |
33 | #include "gtest/internal/gtest-linked_ptr.h"
34 |
35 | #include
36 | #include "gtest/gtest.h"
37 |
38 | namespace {
39 |
40 | using testing::Message;
41 | using testing::internal::linked_ptr;
42 |
43 | int num;
44 | Message* history = NULL;
45 |
46 | // Class which tracks allocation/deallocation
47 | class A {
48 | public:
49 | A(): mynum(num++) { *history << "A" << mynum << " ctor\n"; }
50 | virtual ~A() { *history << "A" << mynum << " dtor\n"; }
51 | virtual void Use() { *history << "A" << mynum << " use\n"; }
52 | protected:
53 | int mynum;
54 | };
55 |
56 | // Subclass
57 | class B : public A {
58 | public:
59 | B() { *history << "B" << mynum << " ctor\n"; }
60 | ~B() { *history << "B" << mynum << " dtor\n"; }
61 | virtual void Use() { *history << "B" << mynum << " use\n"; }
62 | };
63 |
64 | class LinkedPtrTest : public testing::Test {
65 | public:
66 | LinkedPtrTest() {
67 | num = 0;
68 | history = new Message;
69 | }
70 |
71 | virtual ~LinkedPtrTest() {
72 | delete history;
73 | history = NULL;
74 | }
75 | };
76 |
77 | TEST_F(LinkedPtrTest, GeneralTest) {
78 | {
79 | linked_ptr a0, a1, a2;
80 | // Use explicit function call notation here to suppress self-assign warning.
81 | a0.operator=(a0);
82 | a1 = a2;
83 | ASSERT_EQ(a0.get(), static_cast(NULL));
84 | ASSERT_EQ(a1.get(), static_cast(NULL));
85 | ASSERT_EQ(a2.get(), static_cast(NULL));
86 | ASSERT_TRUE(a0 == NULL);
87 | ASSERT_TRUE(a1 == NULL);
88 | ASSERT_TRUE(a2 == NULL);
89 |
90 | {
91 | linked_ptr a3(new A);
92 | a0 = a3;
93 | ASSERT_TRUE(a0 == a3);
94 | ASSERT_TRUE(a0 != NULL);
95 | ASSERT_TRUE(a0.get() == a3);
96 | ASSERT_TRUE(a0 == a3.get());
97 | linked_ptr a4(a0);
98 | a1 = a4;
99 | linked_ptr a5(new A);
100 | ASSERT_TRUE(a5.get() != a3);
101 | ASSERT_TRUE(a5 != a3.get());
102 | a2 = a5;
103 | linked_ptr b0(new B);
104 | linked_ptr a6(b0);
105 | ASSERT_TRUE(b0 == a6);
106 | ASSERT_TRUE(a6 == b0);
107 | ASSERT_TRUE(b0 != NULL);
108 | a5 = b0;
109 | a5 = b0;
110 | a3->Use();
111 | a4->Use();
112 | a5->Use();
113 | a6->Use();
114 | b0->Use();
115 | (*b0).Use();
116 | b0.get()->Use();
117 | }
118 |
119 | a0->Use();
120 | a1->Use();
121 | a2->Use();
122 |
123 | a1 = a2;
124 | a2.reset(new A);
125 | a0.reset();
126 |
127 | linked_ptr a7;
128 | }
129 |
130 | ASSERT_STREQ(
131 | "A0 ctor\n"
132 | "A1 ctor\n"
133 | "A2 ctor\n"
134 | "B2 ctor\n"
135 | "A0 use\n"
136 | "A0 use\n"
137 | "B2 use\n"
138 | "B2 use\n"
139 | "B2 use\n"
140 | "B2 use\n"
141 | "B2 use\n"
142 | "B2 dtor\n"
143 | "A2 dtor\n"
144 | "A0 use\n"
145 | "A0 use\n"
146 | "A1 use\n"
147 | "A3 ctor\n"
148 | "A0 dtor\n"
149 | "A3 dtor\n"
150 | "A1 dtor\n",
151 | history->GetString().c_str()
152 | );
153 | }
154 |
155 | } // Unnamed namespace
156 |
--------------------------------------------------------------------------------
/test/gtest/m4/ltsugar.m4:
--------------------------------------------------------------------------------
1 | # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
2 | #
3 | # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
4 | # Written by Gary V. Vaughan, 2004
5 | #
6 | # This file is free software; the Free Software Foundation gives
7 | # unlimited permission to copy and/or distribute it, with or without
8 | # modifications, as long as this notice is preserved.
9 |
10 | # serial 6 ltsugar.m4
11 |
12 | # This is to help aclocal find these macros, as it can't see m4_define.
13 | AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
14 |
15 |
16 | # lt_join(SEP, ARG1, [ARG2...])
17 | # -----------------------------
18 | # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
19 | # associated separator.
20 | # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
21 | # versions in m4sugar had bugs.
22 | m4_define([lt_join],
23 | [m4_if([$#], [1], [],
24 | [$#], [2], [[$2]],
25 | [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
26 | m4_define([_lt_join],
27 | [m4_if([$#$2], [2], [],
28 | [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
29 |
30 |
31 | # lt_car(LIST)
32 | # lt_cdr(LIST)
33 | # ------------
34 | # Manipulate m4 lists.
35 | # These macros are necessary as long as will still need to support
36 | # Autoconf-2.59 which quotes differently.
37 | m4_define([lt_car], [[$1]])
38 | m4_define([lt_cdr],
39 | [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
40 | [$#], 1, [],
41 | [m4_dquote(m4_shift($@))])])
42 | m4_define([lt_unquote], $1)
43 |
44 |
45 | # lt_append(MACRO-NAME, STRING, [SEPARATOR])
46 | # ------------------------------------------
47 | # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
48 | # Note that neither SEPARATOR nor STRING are expanded; they are appended
49 | # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
50 | # No SEPARATOR is output if MACRO-NAME was previously undefined (different
51 | # than defined and empty).
52 | #
53 | # This macro is needed until we can rely on Autoconf 2.62, since earlier
54 | # versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
55 | m4_define([lt_append],
56 | [m4_define([$1],
57 | m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
58 |
59 |
60 |
61 | # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
62 | # ----------------------------------------------------------
63 | # Produce a SEP delimited list of all paired combinations of elements of
64 | # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
65 | # has the form PREFIXmINFIXSUFFIXn.
66 | # Needed until we can rely on m4_combine added in Autoconf 2.62.
67 | m4_define([lt_combine],
68 | [m4_if(m4_eval([$# > 3]), [1],
69 | [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
70 | [[m4_foreach([_Lt_prefix], [$2],
71 | [m4_foreach([_Lt_suffix],
72 | ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
73 | [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
74 |
75 |
76 | # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
77 | # -----------------------------------------------------------------------
78 | # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
79 | # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
80 | m4_define([lt_if_append_uniq],
81 | [m4_ifdef([$1],
82 | [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
83 | [lt_append([$1], [$2], [$3])$4],
84 | [$5])],
85 | [lt_append([$1], [$2], [$3])$4])])
86 |
87 |
88 | # lt_dict_add(DICT, KEY, VALUE)
89 | # -----------------------------
90 | m4_define([lt_dict_add],
91 | [m4_define([$1($2)], [$3])])
92 |
93 |
94 | # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
95 | # --------------------------------------------
96 | m4_define([lt_dict_add_subkey],
97 | [m4_define([$1($2:$3)], [$4])])
98 |
99 |
100 | # lt_dict_fetch(DICT, KEY, [SUBKEY])
101 | # ----------------------------------
102 | m4_define([lt_dict_fetch],
103 | [m4_ifval([$3],
104 | m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
105 | m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
106 |
107 |
108 | # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
109 | # -----------------------------------------------------------------
110 | m4_define([lt_if_dict_fetch],
111 | [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
112 | [$5],
113 | [$6])])
114 |
115 |
116 | # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
117 | # --------------------------------------------------------------
118 | m4_define([lt_dict_filter],
119 | [m4_if([$5], [], [],
120 | [lt_join(m4_quote(m4_default([$4], [[, ]])),
121 | lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
122 | [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
123 | ])
124 |
--------------------------------------------------------------------------------
]