[
  {
    "path": ".clang-format",
    "content": "---\nBasedOnStyle:  LLVM\nStandard: Cpp11\nPointerAlignment: Left\n...\n"
  },
  {
    "path": ".dockerignore",
    "content": ".dockerignore\n# Pass `.git` directory so that\n# `jfs --version` gives git hash.\n#.git\n**/.*.swp\n**/*.Dockerfile\nscripts/Dockerfiles/*.patched\nscripts/Dockerfiles/build.sh\nutils/SMT-COMP\n"
  },
  {
    "path": ".gitignore",
    "content": "# Vim swap files\n*.swp\n*.swo\nscripts/Dockerfiles/*.patched\n*.pyc\n"
  },
  {
    "path": ".idea/codeStyleSettings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"ProjectCodeStyleSettingsManager\">\n    <option name=\"PER_PROJECT_SETTINGS\">\n      <value>\n        <Objective-C>\n          <option name=\"INDENT_NAMESPACE_MEMBERS\" value=\"2\" />\n          <option name=\"INDENT_C_STRUCT_MEMBERS\" value=\"2\" />\n          <option name=\"INDENT_CLASS_MEMBERS\" value=\"2\" />\n          <option name=\"INDENT_INSIDE_CODE_BLOCK\" value=\"2\" />\n        </Objective-C>\n        <Objective-C-extensions>\n          <file>\n            <option name=\"com.jetbrains.cidr.lang.util.OCDeclarationKind\" value=\"Import\" />\n            <option name=\"com.jetbrains.cidr.lang.util.OCDeclarationKind\" value=\"Macro\" />\n            <option name=\"com.jetbrains.cidr.lang.util.OCDeclarationKind\" value=\"Typedef\" />\n            <option name=\"com.jetbrains.cidr.lang.util.OCDeclarationKind\" value=\"Enum\" />\n            <option name=\"com.jetbrains.cidr.lang.util.OCDeclarationKind\" value=\"Constant\" />\n            <option name=\"com.jetbrains.cidr.lang.util.OCDeclarationKind\" value=\"Global\" />\n            <option name=\"com.jetbrains.cidr.lang.util.OCDeclarationKind\" value=\"Struct\" />\n            <option name=\"com.jetbrains.cidr.lang.util.OCDeclarationKind\" value=\"FunctionPredecl\" />\n            <option name=\"com.jetbrains.cidr.lang.util.OCDeclarationKind\" value=\"Function\" />\n          </file>\n          <class>\n            <option name=\"com.jetbrains.cidr.lang.util.OCDeclarationKind\" value=\"Property\" />\n            <option name=\"com.jetbrains.cidr.lang.util.OCDeclarationKind\" value=\"Synthesize\" />\n            <option name=\"com.jetbrains.cidr.lang.util.OCDeclarationKind\" value=\"InitMethod\" />\n            <option name=\"com.jetbrains.cidr.lang.util.OCDeclarationKind\" value=\"StaticMethod\" />\n            <option name=\"com.jetbrains.cidr.lang.util.OCDeclarationKind\" value=\"InstanceMethod\" />\n            <option name=\"com.jetbrains.cidr.lang.util.OCDeclarationKind\" value=\"DeallocMethod\" />\n          </class>\n          <extensions>\n            <pair source=\"cpp\" header=\"h\" />\n            <pair source=\"c\" header=\"h\" />\n          </extensions>\n        </Objective-C-extensions>\n        <codeStyleSettings language=\"ObjectiveC\">\n          <indentOptions>\n            <option name=\"INDENT_SIZE\" value=\"2\" />\n            <option name=\"CONTINUATION_INDENT_SIZE\" value=\"2\" />\n            <option name=\"TAB_SIZE\" value=\"2\" />\n          </indentOptions>\n        </codeStyleSettings>\n      </value>\n    </option>\n    <option name=\"USE_PER_PROJECT_SETTINGS\" value=\"true\" />\n  </component>\n</project>"
  },
  {
    "path": "CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n\n###############################################################################\n# Minimum CMake version and policies\n###############################################################################\ncmake_minimum_required(VERSION 2.8.12)\nif (POLICY CMP0054)\n  # FIXME: This is horrible. With the old behaviour,\n  # quoted strings like \"MSVC\" in if() conditionals\n  # get implicitly dereferenced. The NEW behaviour\n  # doesn't do this but CMP0054 was only introduced\n  # in CMake 3.1 and we support lower versions as the\n  # minimum. We could set NEW here but it would be very\n  # confusing to use NEW for some builds and OLD for others\n  # which could lead to some subtle bugs. Instead when the\n  # minimum version is 3.1 change this policy to NEW and remove\n  # the hacks in place to work around it.\n  cmake_policy(SET CMP0054 OLD)\nendif()\n\nif (POLICY CMP0042)\n  # Enable `MACOSX_RPATH` by default.\n  cmake_policy(SET CMP0042 NEW)\nendif()\n\nif (POLICY CMP0037)\n  # Disallow reserved target names\n  cmake_policy(SET CMP0037 NEW)\nendif()\n\n# This overrides the default flags for the different CMAKE_BUILD_TYPEs\nset(CMAKE_USER_MAKE_RULES_OVERRIDE_C\n  \"${CMAKE_CURRENT_SOURCE_DIR}/cmake/c_flags_override.cmake\")\nset(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX\n  \"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cxx_flags_override.cmake\")\nproject(JFS CXX C)\n\n###############################################################################\n# Project version\n###############################################################################\nset(JFS_VERSION_MAJOR 0)\nset(JFS_VERSION_MINOR 0)\nset(JFS_VERSION_PATCH 0)\nset(JFS_VERSION_TWEAK 0)\nset(JFS_VERSION \"${JFS_VERSION_MAJOR}.${JFS_VERSION_MINOR}.${JFS_VERSION_PATCH}.${JFS_VERSION_TWEAK}\")\nmessage(STATUS \"JFS version ${JFS_VERSION}\")\n\n################################################################################\n# Set various useful variables depending on CMake version\n################################################################################\nif ((\"${CMAKE_VERSION}\" VERSION_EQUAL \"3.2\") OR (\"${CMAKE_VERSION}\" VERSION_GREATER \"3.2\"))\n  # In CMake >= 3.2 add_custom_command() supports a ``USES_TERMINAL`` argument\n  set(ADD_CUSTOM_COMMAND_USES_TERMINAL_ARG \"USES_TERMINAL\")\nelse()\n  set(ADD_CUSTOM_COMMAND_USES_TERMINAL_ARG \"\")\nendif()\n\nif ((\"${CMAKE_VERSION}\" VERSION_EQUAL \"3.4\") OR (\"${CMAKE_VERSION}\" VERSION_GREATER \"3.4\"))\n  # In CMake >= 3.4 ExternalProject_Add_Step() supports a `USES_TERMINAL` argument\n  set(EXTERNAL_PROJECT_ADD_STEP_USES_TERMINAL_ARG \"USES_TERMINAL\" \"1\")\nelse()\n  set(EXTERNAL_PROJECT_ADD_STEP_USES_TERMINAL_ARG \"\")\nendif()\n\n################################################################################\n# Sanity check - Disallow building in source.\n################################################################################\nif (\"${CMAKE_SOURCE_DIR}\" STREQUAL \"${CMAKE_BINARY_DIR}\")\n  message(FATAL_ERROR \"In source builds are not allowed. You should invoke \"\n          \"CMake from a different directory.\")\nendif()\n\n################################################################################\n# Build type\n################################################################################\nmessage(STATUS \"CMake generator: ${CMAKE_GENERATOR}\")\nif (DEFINED CMAKE_CONFIGURATION_TYPES)\n  # Multi-configuration build (e.g. Xcode). Here\n  # CMAKE_BUILD_TYPE doesn't matter\n  message(STATUS \"Available configurations: ${CMAKE_CONFIGURATION_TYPES}\")\nelse()\n  # Single configuration generator (e.g. Unix Makefiles, Ninja)\n  set(available_build_types Debug Release RelWithDebInfo MinSizeRel)\n  if(NOT CMAKE_BUILD_TYPE)\n    message(STATUS \"CMAKE_BUILD_TYPE is not set. Setting default\")\n    message(STATUS \"The available build types are: ${available_build_types}\")\n    set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE String\n        \"Options are ${available_build_types}\"\n        FORCE)\n    # Provide drop down menu options in cmake-gui\n    set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${available_build_types})\n  endif()\n  message(STATUS \"Build type: ${CMAKE_BUILD_TYPE}\")\n\n  # Check the selected build type is valid\n  list(FIND available_build_types \"${CMAKE_BUILD_TYPE}\" _build_type_index)\n  if (\"${_build_type_index}\" EQUAL \"-1\")\n    message(FATAL_ERROR \"\\\"${CMAKE_BUILD_TYPE}\\\" is an invalid build type.\\n\"\n      \"Use one of the following build types ${available_build_types}\")\n  endif()\nendif()\n\n################################################################################\n# Add our CMake module directory to the list of module search directories\n################################################################################\nlist(APPEND CMAKE_MODULE_PATH \"${CMAKE_SOURCE_DIR}/cmake/modules\")\n\n################################################################################\n# Compiler flags for JFS components\n# Subsequent commands will append to these. These are used instead of\n# directly modifying CMAKE_CXX_FLAGS so that other code can be easily built with\n# different flags.\n################################################################################\nset(JFS_COMPONENT_EXTRA_INCLUDE_DIRS \"\")\nset(JFS_COMPONENT_CXX_DEFINES \"\")\nset(JFS_COMPONENT_CXX_FLAGS \"\")\nset(JFS_SOLVER_LIBRARIES \"\")\nset(JFS_COMPONENT_EXTRA_LIBRARIES \"\")\ninclude(\"${CMAKE_SOURCE_DIR}/cmake/jfs_component_add_cxx_flag.cmake\")\n\n################################################################################\n# JFS include directories\n################################################################################\nlist(APPEND JFS_COMPONENT_EXTRA_INCLUDE_DIRS\n  \"${CMAKE_BINARY_DIR}/include\"\n  \"${CMAKE_SOURCE_DIR}/include\"\n)\n\n################################################################################\n# Assertions\n################################################################################\noption(ENABLE_JFS_ASSERTS \"Enable JFS assertions\" ON)\nif (ENABLE_JFS_ASSERTS)\n  message(STATUS \"JFS assertions enabled\")\n  # Assume that -DNDEBUG isn't set.\nelse()\n  message(STATUS \"JFS assertions disabled\")\n  list(APPEND JFS_COMPONENT_CXX_DEFINES \"NDEBUG\")\nendif()\n\n################################################################################\n# Find LLVM\n################################################################################\nfind_package(LLVM 6.0.0\n  CONFIG\n)\nset(NEEDED_LLVM_VARS\n  LLVM_PACKAGE_VERSION\n  LLVM_VERSION_MAJOR\n  LLVM_VERSION_MINOR\n  LLVM_VERSION_PATCH\n  LLVM_DEFINITIONS\n  LLVM_ENABLE_ASSERTIONS\n  LLVM_ENABLE_EH\n  LLVM_ENABLE_RTTI\n  LLVM_INCLUDE_DIRS\n  LLVM_LIBRARY_DIRS\n  LLVM_TOOLS_BINARY_DIR\n)\n\nforeach (vname ${NEEDED_LLVM_VARS})\n  message(STATUS \"${vname}: \\\"${${vname}}\\\"\")\n  if (NOT (DEFINED \"${vname}\"))\n    message(FATAL_ERROR \"${vname} was not defined\")\n  endif()\nendforeach()\nmessage(STATUS \"LLVM_DIR: \\\"${LLVM_DIR}\\\"\")\n\n# Find Clang\n# FIXME: This won't work if LLVM was built with a multi-configuration generator.\nset(LLVM_CLANG_CXX_TOOL \"${LLVM_TOOLS_BINARY_DIR}/clang++\")\nif (NOT EXISTS \"${LLVM_CLANG_CXX_TOOL}\")\n  message(FATAL_ERROR \"Failed to find clang++ at \\\"${LLVM_CLANG_CXX_TOOL}\\\"\")\nelse()\n  message(STATUS \"Found clang++ at \\\"${LLVM_CLANG_CXX_TOOL}\\\"\")\nendif()\n\nif (LLVM_ENABLE_ASSERTIONS)\n  # Certain LLVM debugging macros only work when LLVM was built with asserts\n  set(ENABLE_JFS_DEBUG 1) # for config.h\nelse()\n  unset(ENABLE_JFS_DEBUG) # for config.h\nendif()\n\n# LLVM_DEFINITIONS aren't lists. Instead they are space separated\nstring(REPLACE \" \" \";\" LLVM_DEFINITIONS_AS_LIST \"${LLVM_DEFINITIONS}\")\nlist(APPEND JFS_COMPONENT_CXX_DEFINES ${LLVM_DEFINITIONS_AS_LIST})\n\n# LLVM_INCLUDE_DIRS aren't lists. Instead they are space separated\nstring(REPLACE \" \" \";\" LLVM_INCLUDE_DIRS_AS_LIST \"${LLVM_INCLUDE_DIRS}\")\nlist(APPEND JFS_COMPONENT_EXTRA_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS_AS_LIST})\n\nif (NOT LLVM_ENABLE_EH)\n  if ((\"${CMAKE_CXX_COMPILER_ID}\" MATCHES \"Clang\") OR (\"${CMAKE_CXX_COMPILER_ID}\" MATCHES \"GNU\"))\n    jfs_component_add_cxx_flag(\"-fno-exceptions\" REQUIRED)\n  else()\n    message(FATAL_ERROR \"${CMAKE_CXX_COMPILER_ID} not supported\")\n  endif()\nendif()\n\nif (NOT LLVM_ENABLE_RTTI)\n  if ((\"${CMAKE_CXX_COMPILER_ID}\" MATCHES \"Clang\") OR (\"${CMAKE_CXX_COMPILER_ID}\" MATCHES \"GNU\"))\n    jfs_component_add_cxx_flag(\"-fno-rtti\" REQUIRED)\n  else()\n    message(FATAL_ERROR \"${CMAKE_CXX_COMPILER_ID} not supported\")\n  endif()\nendif()\ninclude(\"${CMAKE_SOURCE_DIR}/cmake/jfs_get_llvm_components.cmake\")\n\n################################################################################\n# Find Z3\n################################################################################\n# FIXME: Specify version. Need to upstream support for config setting version.\nfind_package(Z3 CONFIG)\nset(NEEDED_Z3_VARS\n  Z3_VERSION_MAJOR\n  Z3_VERSION_MINOR\n  Z3_VERSION_PATCH\n  Z3_VERSION_TWEAK\n  Z3_VERSION_STRING\n  Z3_C_INCLUDE_DIRS\n  Z3_LIBRARIES\n)\nforeach (vname ${NEEDED_Z3_VARS})\n  message(STATUS \"${vname}: \\\"${${vname}}\\\"\")\n  if (NOT (DEFINED \"${vname}\"))\n    message(FATAL_ERROR \"${vname} was not defined\")\n  endif()\nendforeach()\nif (\"${Z3_VERSION_STRING}\" VERSION_LESS \"4.6\")\n  message(FATAL_ERROR \"Need Z3 4.6 or newer\")\nendif()\n\nlist(APPEND JFS_COMPONENT_EXTRA_INCLUDE_DIRS ${Z3_C_INCLUDE_DIRS})\n\n################################################################################\n# C++ version\n################################################################################\n# FIXME: Use CMake's support for this\nif ((\"${CMAKE_CXX_COMPILER_ID}\" MATCHES \"Clang\") OR (\"${CMAKE_CXX_COMPILER_ID}\" MATCHES \"GNU\"))\n  set(JFS_USE_CXX_FLAG \"-std=c++11\")\n  jfs_component_add_cxx_flag(\"${JFS_USE_CXX_FLAG}\" REQUIRED)\nelse()\n  set(JFS_USE_CXX_FLAG \"\")\nendif()\n\n################################################################################\n# Warnings\n################################################################################\ninclude(\"${CMAKE_SOURCE_DIR}/cmake/compiler_warnings.cmake\")\n\n################################################################################\n# Report flags\n################################################################################\nmessage(STATUS \"JFS_COMPONENT_CXX_DEFINES: \\\"${JFS_COMPONENT_CXX_DEFINES}\\\"\")\nmessage(STATUS \"JFS_COMPONENT_EXTRA_INCLUDE_DIRS: \\\"${JFS_COMPONENT_EXTRA_INCLUDE_DIRS}\\\"\")\nmessage(STATUS \"JFS_COMPONENT_CXX_FLAGS: \\\"${JFS_COMPONENT_CXX_FLAGS}\\\"\")\nmessage(STATUS \"JFS_COMPONENT_EXTRA_LIBRARIES: \\\"${JFS_COMPONENT_EXTRA_LIBRARIES}\\\"\")\n\n################################################################################\n# Report default CMake flags\n################################################################################\n# This is mainly for debugging.\nmessage(STATUS \"CMAKE_CXX_FLAGS: \\\"${CMAKE_CXX_FLAGS}\\\"\")\nmessage(STATUS \"CMAKE_EXE_LINKER_FLAGS: \\\"${CMAKE_EXE_LINKER_FLAGS}\\\"\")\nmessage(STATUS \"CMAKE_STATIC_LINKER_FLAGS: \\\"${CMAKE_STATIC_LINKER_FLAGS}\\\"\")\nmessage(STATUS \"CMAKE_SHARED_LINKER_FLAGS: \\\"${CMAKE_SHARED_LINKER_FLAGS}\\\"\")\nif (DEFINED CMAKE_CONFIGURATION_TYPES)\n  # Multi configuration generator\n  string(TOUPPER \"${available_build_types}\" build_types_to_report)\nelse()\n  # Single configuration generator\n  string(TOUPPER \"${CMAKE_BUILD_TYPE}\" build_types_to_report)\nendif()\nforeach (_build_type ${build_types_to_report})\n  message(STATUS \"CMAKE_CXX_FLAGS_${_build_type}: \\\"${CMAKE_CXX_FLAGS_${_build_type}}\\\"\")\n  message(STATUS \"CMAKE_EXE_LINKER_FLAGS_${_build_type}: \\\"${CMAKE_EXE_LINKER_FLAGS_${_build_type}}\\\"\")\n  message(STATUS \"CMAKE_SHARED_LINKER_FLAGS_${_build_type}: \\\"${CMAKE_SHARED_LINKER_FLAGS_${_build_type}}\\\"\")\n  message(STATUS \"CMAKE_STATIC_LINKER_FLAGS_${_build_type}: \\\"${CMAKE_STATIC_LINKER_FLAGS_${_build_type}}\\\"\")\nendforeach()\n\n################################################################################\n# Handle git hash and description\n################################################################################\ninclude(${CMAKE_SOURCE_DIR}/cmake/git_utils.cmake)\nmacro(disable_git_describe)\n  message(WARNING \"Disabling INCLUDE_GIT_DESCRIBE\")\n  set(INCLUDE_GIT_DESCRIBE OFF CACHE BOOL \"Include git describe output in version output\" FORCE)\nendmacro()\nmacro(disable_git_hash)\n  message(WARNING \"Disabling INCLUDE_GIT_HASH\")\n  set(INCLUDE_GIT_HASH OFF CACHE BOOL \"Include git hash in version output\" FORCE)\n  unset(Z3GITHASH) # Used in configure_file()\nendmacro()\noption(INCLUDE_GIT_HASH \"Include git hash in version output\" ON)\noption(INCLUDE_GIT_DESCRIBE \"Include git describe output in version output\" ON)\n\nset(GIT_DIR \"${CMAKE_SOURCE_DIR}/.git\")\nif (EXISTS \"${GIT_DIR}\")\n  # Try to make CMake configure depend on the current git HEAD so that\n  # a re-configure is triggered when the HEAD changes.\n  add_git_dir_dependency(\"${GIT_DIR}\" ADD_GIT_DEP_SUCCESS)\n  if (ADD_GIT_DEP_SUCCESS)\n    if (INCLUDE_GIT_HASH)\n      get_git_head_hash(\"${GIT_DIR}\" JFS_GIT_HASH)\n      if (NOT JFS_GIT_HASH)\n        message(WARNING \"Failed to get Git hash\")\n        disable_git_hash()\n      endif()\n      message(STATUS \"Using Git hash in version output: ${JFS_GIT_HASH}\")\n    else()\n      message(STATUS \"Not using Git hash in version output\")\n      unset(JFS_GIT_HASH) # Used in configure_file()\n    endif()\n    if (INCLUDE_GIT_DESCRIBE)\n      get_git_head_describe(\"${GIT_DIR}\" JFS_GIT_DESCRIPTION)\n      if (NOT Z3_GIT_DESCRIPTION)\n        message(WARNING \"Failed to get Git description\")\n        disable_git_describe()\n      endif()\n      message(STATUS \"Using Git description in version output: ${JFS_GIT_DESCRIPTION}\")\n    else()\n      message(STATUS \"Not including git descrption in version\")\n    endif()\n  else()\n    message(WARNING \"Failed to add git dependency.\")\n    disable_git_describe()\n    disable_git_hash()\n  endif()\nelse()\n  message(STATUS \"Failed to find git directory.\")\n  disable_git_describe()\n  disable_git_hash()\nendif()\n\n################################################################################\n# Generate configuration header files\n################################################################################\nset(AUTO_GEN_MSG \"Automatically generated. DO NOT EDIT\")\nset(configuration_files \"version.h\" \"depsVersion.h\" \"config.h\")\nforeach (configuration_file ${configuration_files})\n  configure_file(\n    \"${CMAKE_SOURCE_DIR}/include/jfs/Config/${configuration_file}.in\"\n    \"${CMAKE_BINARY_DIR}/include/jfs/Config/${configuration_file}\"\n  )\nendforeach()\n\n################################################################################\n# Set default location for targets in the build directory\n################################################################################\nset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)\nset(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)\nset(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)\n\n\n################################################################################\n# Top level unit test target\n################################################################################\n# This is top level because there are multiple unit test suites to run\nadd_custom_target(unittests)\n\n################################################################################\n# Detect lit tool\n################################################################################\n# This can't belong in `tests/` because `runtime/` needs to run its own tests.\noption(ENABLE_SYSTEM_TESTS \"Enable system tests\" ON)\noption(ENABLE_UNIT_TESTS \"Enable unit tests\" ON)\nif (ENABLE_SYSTEM_TESTS OR ENABLE_UNIT_TESTS)\n  # Find lit\n  set(LIT_TOOL_NAMES \"llvm-lit\" \"lit\")\n  find_program(\n    LIT_TOOL\n    NAMES ${LIT_TOOL_NAMES}\n    HINTS \"${LLVM_TOOLS_BINARY_DIR}\"\n    DOC \"Path to lit tool\"\n  )\n\n  set(LIT_ARGS\n    \"-v;-s\"\n    CACHE\n    STRING\n    \"Lit arguments\"\n  )\n\n  if ((NOT LIT_TOOL) OR (NOT EXISTS \"${LIT_TOOL}\"))\n    message(FATAL_ERROR \"The lit tool is required for testing.\")\n  else()\n    message(STATUS \"Using lit: ${LIT_TOOL}\")\n  endif()\nendif()\n\n################################################################################\n# Utilities\n################################################################################\nset(GTEST_SRC_DIR \"${CMAKE_SOURCE_DIR}/utils/googletest/googletest\")\nadd_subdirectory(utils)\n\n################################################################################\n# Runtime\n################################################################################\nadd_subdirectory(runtime)\n# Sanity checks\nif (\"${JFS_LLVM_CLANG_CXX_TOOL}\" STREQUAL \"\")\n  message(FATAL_ERROR \"JFS_LLVM_CLANG_CXX_TOOL not set\")\nendif()\nif (NOT (EXISTS \"${JFS_LLVM_CLANG_CXX_TOOL}\"))\n  message(FATAL_ERROR \"JFS_LLVM_CLANG_CXX_TOOL (\\\"${JFS_LLVM_CLANG_CXX_TOOL}\\\") doest not exist\")\nendif()\nmessage(STATUS \"JFS_LLVM_CLANG_CXX_TOOL: ${JFS_LLVM_CLANG_CXX_TOOL}\")\n\n################################################################################\n# Libraries\n################################################################################\ninclude(\"${CMAKE_SOURCE_DIR}/cmake/jfs_add_component.cmake\")\nadd_subdirectory(lib)\n\n################################################################################\n# Tools\n################################################################################\nadd_subdirectory(tools)\n\n################################################################################\n# Tests\n################################################################################\nadd_subdirectory(tests)\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "Copyright 2017 Daniel Liew\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# JFS\n\nJFS (Just Fuzz it Solver) (originally JIT Fuzzing Solver) is an experimental\nconstraint solver designed to investigate using __coverage guided fuzzing__ as\nan incomplete strategy for solving boolean, BitVector, and floating-point\nconstraints.\n\nJFS supports constraints in the [SMT-LIBv2][1] constraint langauge in the\n`QF_BV`, `QF_BVFP`, and `QF_FP` logics. JFS's primary purpose however is\nsolve floating-point constraints.\n\nJFS is built on top of the following projects\n\n* [LLVM](https://llvm.org/)\n* [Clang](http://clang.llvm.org/)\n* [Z3](https://github.com/Z3Prover/z3)\n* [LibFuzzer](https://llvm.org/docs/LibFuzzer.html)\n\n[1]: http://smtlib.cs.uiowa.edu/\n\n## FSE 2019 paper\n\n[A paper on JFS](https://srg.doc.ic.ac.uk/files/papers/jfs-esecfse-19.pdf) was presented and published at ESEC/FSE 2019.\n\nAdditional resources:\n\n* [artifact](https://github.com/mc-imperial/jfs-fse-2019-artifact)\n* [slides](https://docs.google.com/presentation/d/1wPxNJ3rXVqLRCm9jRMZTsL5sEW5aW9WZ583TPpb2Ffo/edit?usp=sharing)\n\nThe [Docker image](https://cloud.docker.com/u/delcypher/repository/docker/delcypher/jfs_build) with the tag `fse_2019`\n\n## Using JFS Docker image\n\nIf you want to get started with JFS with minimal effort the easiest thing to do\nis download the latest Docker image for JFS. Note this image may not be up-to-date\nso you might not the latest changes.\n\nTo obtain the image run (replace `fse_2019` with the tag you wish to use).\n\n```\ndocker pull delcypher/jfs_build:fse_2019\n```\n\nThe simplest invocation is something like this which will show JFS's help output.\n\n```\ndocker run --user 1000 --rm -t delcypher/jfs_build:fse_2019 /home/user/jfs/build/bin/jfs --help\n```\n\nTo run JFS on a SMT-LIBv2 file that exists outside the container (`/path/to/simple.smt2` in this example) run this command below.\n\n```\ndocker run --rm -t -v /path/to/simple.smt2:/tmp/simple.smt2 delcypher/jfs_build:fse_2019 /home/user/jfs/build/bin/jfs /tmp/simple.smt2\n```\n\nNote that the `docker run` command creates a new container and destroys it\nafterwards which has notable overhead. For better performance consider running\nJFS outside of a docker container or creating a single container and spawning a\nshell inside it and then launch JFS from there.\n\n## Building JFS\n\nJFS has been tested on Linux and macOS.\nWindows support would likely require a lot more work and is dependent on getting\nLibFuzzer to work on Windows.\n\n### Using Docker (the easy way)\n\nThe easiest way is just to use our Dockerfile. To do this simply run\n\n```\nscripts/Dockerfiles/build.sh\n```\n\nonce the script completes you will have a Docker image on your system\nnamed `jfs_build:ubuntu1604`. In this image you will find the JFS binaries\nin the `/home/user/jfs/build/bin` directory.\n\n## From source (the hard way)\n\nJFS has the following build dependencies:\n\n* LLVM/Clang/compiler-rt 6.0\n* Z3 4.6.0\n* CMake\n* Ninja\n\n\nHere are the steps to build JFS.\n\n1. Build Z3 4.6.0. Note you must build this using Z3's CMake build system\nand not its legacy build system because JFS's build system depends on files\nemitted by Z3's CMake build system.\n\nA convenience script is provided for this\n\n```bash\nexport Z3_SRC_DIR=/home/user/z3/src\nexport Z3_BUILD_DIR=/home/user/z3/build\nexport Z3_BUILD_TYPE=Release\nscripts/dist/build_z3.sh\n```\n\nSet the `Z3_SRC_DIR`, `Z3_BUILD_DIR` to paths to empty or non-existant\ndirectories. The `Z3_BUILD_TYPE` can be set to `Release`, `RelWithDebInfo`,\nor `Debug`.\n\n2. Build or install LLVM, Clang, and compiler-rt 6.0\n\n\nA convenience script is provided to build LLVM.\n\n```bash\nexport LLVM_SRC_DIR=/home/user/llvm/src\nexport LLVM_BUILD_DIR=/home/user/llvm/src\nexport LLVM_BUILD_TYPE=Release\nscripts/dist/build_llvm.sh\n```\n\nSet the `LLVM_SRC_DIR`, `LLVM_BUILD_DIR` to paths to empty or non-existant\ndirectories. The `LLVM_BUILD_TYPE` can be set to `Release`, `RelWithDebInfo`,\nor `Debug`.\n\n3. Build JFS\n\nA convenience script is provided to build JFS.\n\n```bash\nexport JFS_SRC_DIR=/home/user/jfs/src\nexport JFS_BUILD_DIR=/home/user/jfs/build\nexport JFS_BUILD_TYPE=Release\nscripts/dist/build_jfs.sh\n```\n\n`JFS_SRC_DIR` should be the absolute path to an already cloned copy of the JFS\nrepo. `JFS_BUILD_DIR` should be a path to an empty or non-existant directory.\nThe `JFS_BUILD_TYPE` can be set to `Release`, `RelWithDebInfo`, or `Debug`.\n\nNote that `Z3_BUILD_DIR` and `LLVM_BUILD_DIR` must also be set.\n\n4. Test JFS\n\n```\ncd ${JFS_BUILD_DIR}\nninja check\n```\n\n\n## FAQs\n\n### Aren't there already a bunch of search based floating-point constraint solvers?\n\nYes. However as far as we're aware, JFS is the first to try to use an\n\"off the shelf\" coverage guided fuzzer as a search strategy.\n\nHere's a non-exhaustive list:\n\n* [coral][2] is a constraint solver that\n  supports various search strategies over floating point constraints.  It uses\n  its own constraint language which is only partially overlaps with `QF_FP`\n  constraints in the SMT-LIBv2 language. The [smt2coral][3] tool provides a way\n  to run coral on SMT-LIBv2 constraints.\n\n* [XSat][4] transform constraints into a mathematical global optimization\n problem. Unfortunately this tool is not open source.\n\n* [goSAT][5] takes the ideas behind XSat but\n  uses different optimization libraries and uses LLVM's JIT to generate code.\n\nWe are currently in the process of performing an evaluation of JFS against\nthese solvers and we will report these results in the not to distant future.\n\n[2]: http://pan.cin.ufpe.br/coral/index.html\n[3]: https://github.com/delcypher/smt2coral\n[4]: https://www.researchgate.net/publication/305252908_XSat_A_Fast_Floating-Point_Satisfiability_Solver\n[5]: https://github.com/abenkhadra/gosat\n\n### How does JFS work?\n\nTo see how JFS works let's walk through a small example.\n\n1. Parse SMT-LIB constraints using Z3.\n\n```\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n(define-fun a_b_rne () (_ FloatingPoint 11 53) (fp.div RNE a b))\n(define-fun a_b_rtp () (_ FloatingPoint 11 53) (fp.div RTP a b))\n(assert (not (fp.isNaN a)))\n(assert (not (fp.isNaN b)))\n(assert (not (fp.eq a_b_rne a_b_rtp)))\n(assert (not (fp.isNaN a_b_rne)))\n(assert (not (fp.isNaN a_b_rtp)))\n(check-sat)\n```\n\n2. Perform some simplifications on the constraints (e.g. constant folding).\n\n**NOTE: You can use the jfs-opt tool to experiment with these simplifications.**\n\n3. Generate a C++ program where the reachability of an `abort()` statement is\nequivalent to finding a satisfying assignment to the constraints.\n\n**NOTE: You can use the `jfs-smt2cxx` tool to convert SMT-LIBv2 constraints\ninto a program.**\n\n```c++\nextern \"C\" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {\n  if (size < 16) {\n    return 0;\n  }\n  BufferRef<const uint8_t> jfs_buffer_ref =\n      BufferRef<const uint8_t>(data, size);\n  const Float<11, 53> a = makeFloatFrom<11, 53>(jfs_buffer_ref, 0, 63);\n  const Float<11, 53> b = makeFloatFrom<11, 53>(jfs_buffer_ref, 64, 127);\n  const bool jfs_ssa_0 = a.isNaN();\n  const bool jfs_ssa_1 = !(jfs_ssa_0);\n  if (jfs_ssa_1) {\n  } else {\n    return 0;\n  }\n  const bool jfs_ssa_2 = b.isNaN();\n  const bool jfs_ssa_3 = !(jfs_ssa_2);\n  if (jfs_ssa_3) {\n  } else {\n    return 0;\n  }\n  const Float<11, 53> jfs_ssa_4 = a.div(JFS_RM_RNE, b);\n  const Float<11, 53> jfs_ssa_5 = a.div(JFS_RM_RTP, b);\n  const bool jfs_ssa_6 = jfs_ssa_4.ieeeEquals(jfs_ssa_5);\n  const bool jfs_ssa_7 = !(jfs_ssa_6);\n  if (jfs_ssa_7) {\n  } else {\n    return 0;\n  }\n  const bool jfs_ssa_8 = jfs_ssa_4.isNaN();\n  const bool jfs_ssa_9 = !(jfs_ssa_8);\n  if (jfs_ssa_9) {\n  } else {\n    return 0;\n  }\n  const bool jfs_ssa_10 = jfs_ssa_5.isNaN();\n  const bool jfs_ssa_11 = !(jfs_ssa_10);\n  if (jfs_ssa_11) {\n  } else {\n    return 0;\n  }\n  // Fuzzing target\n  abort();\n}\n```\n\n4. This program is then compiled by Clang with coverage instrumentation\n  and linked against LibFuzzer and a small runtime library. The runtime\n  library implements the `Float` and `BitVector` SMT-LIBv2 types.\n\n5. A set of seeds are generated for the fuzzer.\n\n6. The compiled binary is invoked with the given seeds.\n  If the fuzzer generates an input that reaches the `abort()` a satisfying\n  assignment has been found and JFS terminates reporting `sat`.\n\nNote this strategy will never find a satisfying assignment if one does not exist\n(i.e. the constraints are unsatisfiable). This is why we say JFS is \"incomplete\"\nbecause it cannot show that unsatisfiable constraints are unsatisfiable.\n\nThere is one exception to this. JFS can show unsatisfiable constraints to be\nunsatisfiable if its simplications show one or more constraints to be `false`\n(i.e. trivially unsatisfiable).\n"
  },
  {
    "path": "cmake/add_jfs_unit_test.cmake",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\nif (NOT DEFINED GTEST_SRC_DIR)\n  message(FATAL_ERROR \"GTEST_SRC_DIR must be defined\")\nendif()\nif (NOT EXISTS \"${GTEST_SRC_DIR}\")\n  message(FATAL_ERROR \"GTEST_SRC_DIR (${GTEST_SRC_DIR}) must exist\")\nendif()\n\n# This keeps track of all the unit test\n# targets so we can ensure they are built\n# before trying to run them.\ndefine_property(GLOBAL\n  PROPERTY JFS_UNIT_TEST_TARGETS\n  BRIEF_DOCS \"JFS unit tests\"\n  FULL_DOCS \"JFS unit tests\"\n)\n\nset(GTEST_INCLUDE_DIR \"${GTEST_SRC_DIR}/include\")\n\nif (NOT IS_DIRECTORY \"${GTEST_INCLUDE_DIR}\")\n  message(FATAL_ERROR\n    \"Cannot find GTest include directory \\\"${GTEST_INCLUDE_DIR}\\\"\")\nendif()\n\nset (UNIT_TEST_EXE_SUFFIX \"Test\")\nfunction(add_jfs_unit_test target_name)\n  add_executable(${target_name}${UNIT_TEST_EXE_SUFFIX} ${ARGN})\n  target_link_libraries(${target_name}${UNIT_TEST_EXE_SUFFIX} PRIVATE jfs_gtest_main)\n  target_include_directories(${target_name}${UNIT_TEST_EXE_SUFFIX} BEFORE PRIVATE \"${GTEST_INCLUDE_DIR}\")\n  set_target_properties(${target_name}${UNIT_TEST_EXE_SUFFIX}\n    PROPERTIES\n    RUNTIME_OUTPUT_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}\"\n  )\n  set_property(GLOBAL\n    APPEND\n    PROPERTY JFS_UNIT_TEST_TARGETS\n    ${target_name}${UNIT_TEST_EXE_SUFFIX}\n  )\nendfunction()\n"
  },
  {
    "path": "cmake/c_flags_override.cmake",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n#\n# This file overrides the default compiler flags for CMake's built-in\n# configurations (CMAKE_BUILD_TYPE). Most compiler flags should not be set\n# here.  The main purpose is to make sure ``-DNDEBUG`` is never set by default.\n#\n#===------------------------------------------------------------------------===#\nif ((\"${CMAKE_C_COMPILER_ID}\" MATCHES \"Clang\") OR (\"${CMAKE_C_COMPILER_ID}\" MATCHES \"GNU\"))\n  # Taken from Modules/Compiler/GNU.cmake but -DNDEBUG is removed\n  set(CMAKE_C_FLAGS_INIT \"\")\n  set(CMAKE_C_FLAGS_DEBUG_INIT \"-O0 -g\")\n  set(CMAKE_C_FLAGS_MINSIZEREL_INIT \"-Os\")\n  set(CMAKE_C_FLAGS_RELEASE_INIT \"-O3\")\n  set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT \"-O2 -g\")\nelse()\n  message(FATAL_ERROR \"Overrides not set for compiler ${CMAKE_C_COMPILER_ID}\")\nendif()\n"
  },
  {
    "path": "cmake/compiler_warnings.cmake",
    "content": "set(GCC_AND_CLANG_WARNINGS\n    \"-Wall\"\n)\nset(GCC_ONLY_WARNINGS \"\")\nset(CLANG_ONLY_WARNINGS \"\")\nset(MSVC_WARNINGS \"/W3\")\n\nset(WARNING_FLAGS_TO_CHECK \"\")\nif (\"${CMAKE_CXX_COMPILER_ID}\" MATCHES \"GNU\")\n  list(APPEND WARNING_FLAGS_TO_CHECK ${GCC_AND_CLANG_WARNINGS})\n  list(APPEND WARNING_FLAGS_TO_CHECK ${GCC_ONLY_WARNINGS})\nelseif (\"${CMAKE_CXX_COMPILER_ID}\" MATCHES \"Clang\")\n  list(APPEND WARNING_FLAGS_TO_CHECK ${GCC_AND_CLANG_WARNINGS})\n  list(APPEND WARNING_FLAGS_TO_CHECK ${CLANG_ONLY_WARNINGS})\n  # FIXME: Remove \"x..\" when CMP0054 is set to NEW\nelseif (\"x${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"xMSVC\")\n  list(APPEND WARNING_FLAGS_TO_CHECK ${MSVC_WARNINGS})\n\n  # CMake's default flags include /W3 already so remove them if\n  # they already exist.\n  if (\"${CMAKE_CXX_FLAGS}\" MATCHES \"/W3\")\n    string(REPLACE \"/W3\" \"\" _cmake_cxx_flags_remove_w3 \"${CMAKE_CXX_FLAGS}\")\n    set(CMAKE_CXX_FLAGS \"${_cmake_cxx_flags_remove_w3}\" CACHE STRING \"\" FORCE)\n  endif()\nelse()\n  message(AUTHOR_WARNING \"Unknown compiler\")\nendif()\n\n# Loop through flags and use the ones which the compiler supports\nforeach (flag ${WARNING_FLAGS_TO_CHECK})\n  jfs_component_add_cxx_flag(\"${flag}\")\nendforeach()\n"
  },
  {
    "path": "cmake/cxx_flags_override.cmake",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n#\n# This file overrides the default compiler flags for CMake's built-in\n# configurations (CMAKE_BUILD_TYPE). Most compiler flags should not be set\n# here.  The main purpose is to make sure ``-DNDEBUG`` is never set by default.\n#\n#===------------------------------------------------------------------------===#\n\nif ((\"${CMAKE_CXX_COMPILER_ID}\" MATCHES \"Clang\") OR (\"${CMAKE_CXX_COMPILER_ID}\" MATCHES \"GNU\"))\n  # Taken from Modules/Compiler/GNU.cmake but -DNDEBUG is removed\n  set(CMAKE_CXX_FLAGS_INIT \"\")\n  set(CMAKE_CXX_FLAGS_DEBUG_INIT \"-O0 -g\")\n  set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT \"-Os\")\n  set(CMAKE_CXX_FLAGS_RELEASE_INIT \"-O3\")\n  set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT \"-O2 -g\")\nelse()\n  message(FATAL_ERROR \"Overrides not set for compiler ${CMAKE_CXX_COMPILER_ID}\")\nendif()\n"
  },
  {
    "path": "cmake/git_utils.cmake",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n\n# add_git_dir_dependency(GIT_DIR SUCCESS_VAR)\n#\n# Adds a configure time dependency on the git directory such that if the HEAD\n# of the git directory changes CMake will be forced to re-run. This useful\n# for fetching the current git hash and including it in the build.\n#\n# `GIT_DIR` is the path to the git directory (i.e. the `.git` directory)\n# `SUCCESS_VAR` is the name of the variable to set. It will be set to TRUE\n# if the dependency was successfully added and FALSE otherwise.\nfunction(add_git_dir_dependency GIT_DIR SUCCESS_VAR)\n  if (NOT \"${ARGC}\" EQUAL 2)\n    message(FATAL_ERROR \"Invalid number (${ARGC}) of arguments\")\n  endif()\n\n  if (NOT IS_ABSOLUTE \"${GIT_DIR}\")\n    message(FATAL_ERROR \"GIT_DIR (\\\"${GIT_DIR}\\\") is not an absolute path\")\n  endif()\n\n  if (NOT IS_DIRECTORY \"${GIT_DIR}\")\n    message(FATAL_ERROR \"GIT_DIR (\\\"${GIT_DIR}\\\") is not a directory\")\n  endif()\n\n  set(GIT_HEAD_FILE \"${GIT_DIR}/HEAD\")\n  if (NOT EXISTS \"${GIT_HEAD_FILE}\")\n    message(AUTHOR_WARNING \"Git head file \\\"${GIT_HEAD_FILE}\\\" cannot be found\")\n    set(${SUCCESS_VAR} FALSE PARENT_SCOPE)\n    return()\n  endif()\n\n  # List of files in the git tree that CMake configuration should depend on\n  set(GIT_FILE_DEPS \"${GIT_HEAD_FILE}\")\n\n  # Examine the HEAD and workout what additional dependencies there are.\n  file(READ \"${GIT_HEAD_FILE}\" GIT_HEAD_DATA LIMIT 128)\n  string(STRIP \"${GIT_HEAD_DATA}\" GIT_HEAD_DATA_STRIPPED)\n\n  if (\"${GIT_HEAD_DATA_STRIPPED}\" MATCHES \"^ref:[ ]*(.+)$\")\n    # HEAD points at a reference.\n    set(GIT_REF \"${CMAKE_MATCH_1}\")\n    if (EXISTS \"${GIT_DIR}/${GIT_REF}\")\n      # Unpacked reference. The file contains the commit hash\n      # so add a dependency on this file so that if we stay on this\n      # reference (i.e. branch) but change commit CMake will be forced\n      # to reconfigure.\n      list(APPEND GIT_FILE_DEPS \"${GIT_DIR}/${GIT_REF}\")\n    elseif(EXISTS \"${GIT_DIR}/packed-refs\")\n      # The ref must be packed (see `man git-pack-refs`).\n      list(APPEND GIT_FILE_DEPS \"${GIT_DIR}/packed-refs\")\n    else()\n      # Fail\n      message(AUTHOR_WARNING \"Unhandled git reference\")\n      set(${SUCCESS_VAR} FALSE PARENT_SCOPE)\n      return()\n    endif()\n  else()\n    # Detached HEAD.\n    # No other dependencies needed\n  endif()\n\n  # FIXME:\n  # This is the directory we will copy (via `configure_file()`) git files\n  # into. This is a hack. It would be better to use the\n  # `CMAKE_CONFIGURE_DEPENDS` directory property but that feature is not\n  # available in CMake 2.8.12. So we use `configure_file()` to effectively\n  # do the same thing. When the source file to `configure_file()` changes\n  # it will trigger a re-run of CMake.\n  set(GIT_CMAKE_FILES_DIR \"${CMAKE_CURRENT_BINARY_DIR}/git_cmake_files\")\n  file(MAKE_DIRECTORY \"${GIT_CMAKE_FILES_DIR}\")\n\n  foreach (git_dependency ${GIT_FILE_DEPS})\n    message(STATUS \"Adding git dependency \\\"${git_dependency}\\\"\")\n    configure_file(\n      \"${git_dependency}\"\n      \"${GIT_CMAKE_FILES_DIR}\"\n      COPYONLY\n    )\n  endforeach()\n\n  set(${SUCCESS_VAR} TRUE PARENT_SCOPE)\nendfunction()\n\n# get_git_head_hash(GIT_DIR OUTPUT_VAR)\n#\n# Retrieve the current commit hash for a git working directory where `GIT_DIR`\n# is the `.git` directory in the root of the git working directory.\n#\n# `OUTPUT_VAR` should be the name of the variable to put the result in. If this\n# function fails then either a fatal error will be raised or `OUTPUT_VAR` will\n# contain a string with the suffix `NOTFOUND` which can be used in CMake `if()`\n# commands.\nfunction(get_git_head_hash GIT_DIR OUTPUT_VAR)\n  if (NOT \"${ARGC}\" EQUAL 2)\n    message(FATAL_ERROR \"Invalid number of arguments\")\n  endif()\n  if (NOT IS_DIRECTORY \"${GIT_DIR}\")\n    message(FATAL_ERROR \"\\\"${GIT_DIR}\\\" is not a directory\")\n  endif()\n  if (NOT IS_ABSOLUTE \"${GIT_DIR}\")\n    message(FATAL_ERROR \\\"\"${GIT_DIR}\\\" is not an absolute path\")\n  endif()\n  find_package(Git)\n  if (NOT Git_FOUND)\n    set(${OUTPUT_VAR} \"GIT-NOTFOUND\" PARENT_SCOPE)\n    return()\n  endif()\n  get_filename_component(GIT_WORKING_DIR \"${GIT_DIR}\" DIRECTORY)\n  execute_process(\n    COMMAND\n      \"${GIT_EXECUTABLE}\"\n      \"rev-parse\"\n      \"-q\" # Quiet\n      \"HEAD\"\n    WORKING_DIRECTORY\n      \"${GIT_WORKING_DIR}\"\n    RESULT_VARIABLE\n      GIT_EXIT_CODE\n    OUTPUT_VARIABLE\n      Z3_GIT_HASH\n    OUTPUT_STRIP_TRAILING_WHITESPACE\n  )\n  if (NOT \"${GIT_EXIT_CODE}\" EQUAL 0)\n    message(WARNING \"Failed to execute git\")\n    set(${OUTPUT_VAR} NOTFOUND PARENT_SCOPE)\n    return()\n  endif()\n  set(${OUTPUT_VAR} \"${Z3_GIT_HASH}\" PARENT_SCOPE)\nendfunction()\n\n# get_git_head_describe(GIT_DIR OUTPUT_VAR)\n#\n# Retrieve the output of `git describe` for a git working directory where\n# `GIT_DIR` is the `.git` directory in the root of the git working directory.\n#\n# `OUTPUT_VAR` should be the name of the variable to put the result in. If this\n# function fails then either a fatal error will be raised or `OUTPUT_VAR` will\n# contain a string with the suffix `NOTFOUND` which can be used in CMake `if()`\n# commands.\nfunction(get_git_head_describe GIT_DIR OUTPUT_VAR)\n  if (NOT \"${ARGC}\" EQUAL 2)\n    message(FATAL_ERROR \"Invalid number of arguments\")\n  endif()\n  if (NOT IS_DIRECTORY \"${GIT_DIR}\")\n    message(FATAL_ERROR \"\\\"${GIT_DIR}\\\" is not a directory\")\n  endif()\n  if (NOT IS_ABSOLUTE \"${GIT_DIR}\")\n    message(FATAL_ERROR \\\"\"${GIT_DIR}\\\" is not an absolute path\")\n  endif()\n  find_package(Git)\n  if (NOT Git_FOUND)\n    set(${OUTPUT_VAR} \"GIT-NOTFOUND\" PARENT_SCOPE)\n    return()\n  endif()\n  get_filename_component(GIT_WORKING_DIR \"${GIT_DIR}\" DIRECTORY)\n  execute_process(\n    COMMAND\n      \"${GIT_EXECUTABLE}\"\n      \"describe\"\n      \"--long\"\n    WORKING_DIRECTORY\n      \"${GIT_WORKING_DIR}\"\n    RESULT_VARIABLE\n      GIT_EXIT_CODE\n    OUTPUT_VARIABLE\n      Z3_GIT_DESCRIPTION\n    OUTPUT_STRIP_TRAILING_WHITESPACE\n  )\n  if (NOT \"${GIT_EXIT_CODE}\" EQUAL 0)\n    message(WARNING \"Failed to execute git\")\n    set(${OUTPUT_VAR} NOTFOUND PARENT_SCOPE)\n    return()\n  endif()\n  set(${OUTPUT_VAR} \"${Z3_GIT_DESCRIPTION}\" PARENT_SCOPE)\nendfunction()\n"
  },
  {
    "path": "cmake/jfs_add_component.cmake",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n\nfunction(jfs_add_component target_name)\n  # Components are explicitly STATIC because we don't support building them\n  # as shared libraries.\n  add_library(${target_name} STATIC ${ARGN})\n  # Use of `PUBLIC` means these will propagate to targets that use this component.\n  if ((\"${CMAKE_VERSION}\" VERSION_EQUAL \"3.3\") OR (\"${CMAKE_VERSION}\" VERSION_GREATER \"3.3\"))\n    # In newer CMakes we can make sure that the flags are only used when compiling C++\n    target_compile_options(${target_name} PUBLIC\n      $<$<COMPILE_LANGUAGE:CXX>:${JFS_COMPONENT_CXX_FLAGS}>)\n  else()\n    # For older CMakes just live with the warnings we get for passing C++ only flags\n    # to the C compiler.\n    target_compile_options(${target_name} PUBLIC ${JFS_COMPONENT_CXX_FLAGS})\n  endif()\n  target_include_directories(${target_name} PUBLIC ${JFS_COMPONENT_EXTRA_INCLUDE_DIRS})\n  target_compile_definitions(${target_name} PUBLIC ${JFS_COMPONENT_CXX_DEFINES})\n  target_link_libraries(${target_name} PUBLIC ${JFS_COMPONENT_EXTRA_LIBRARIES})\nendfunction()\n"
  },
  {
    "path": "cmake/jfs_component_add_cxx_flag.cmake",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\ninclude(CheckCXXCompilerFlag)\ninclude(CMakeParseArguments)\n\nfunction(jfs_component_add_cxx_flag flag)\n  CMAKE_PARSE_ARGUMENTS(jfs_component_add_cxx_flag \"REQUIRED\" \"\" \"\" ${ARGN})\n  string(REPLACE \"-\" \"_\" SANITIZED_FLAG_NAME \"${flag}\")\n  string(REPLACE \"/\" \"_\" SANITIZED_FLAG_NAME \"${SANITIZED_FLAG_NAME}\")\n  string(REPLACE \"=\" \"_\" SANITIZED_FLAG_NAME \"${SANITIZED_FLAG_NAME}\")\n  string(REPLACE \" \" \"_\" SANITIZED_FLAG_NAME \"${SANITIZED_FLAG_NAME}\")\n  string(REPLACE \"+\" \"_\" SANITIZED_FLAG_NAME \"${SANITIZED_FLAG_NAME}\")\n  unset(HAS_${SANITIZED_FLAG_NAME})\n  CHECK_CXX_COMPILER_FLAG(\"${flag}\" HAS_${SANITIZED_FLAG_NAME})\n  if (jfs_component_add_cxx_flag_REQUIRED AND NOT HAS_${SANITIZED_FLAG_NAME})\n    message(FATAL_ERROR \"The flag \\\"${flag}\\\" is required but your C++ compiler doesn't support it\")\n  endif()\n  if (HAS_${SANITIZED_FLAG_NAME})\n    message(STATUS \"C++ compiler supports ${flag}\")\n    list(APPEND JFS_COMPONENT_CXX_FLAGS \"${flag}\")\n    set(JFS_COMPONENT_CXX_FLAGS ${JFS_COMPONENT_CXX_FLAGS} PARENT_SCOPE)\n  else()\n    message(STATUS \"C++ compiler does not support ${flag}\")\n  endif()\nendfunction()\n"
  },
  {
    "path": "cmake/jfs_external_project_utils.cmake",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\nfunction(jfs_get_external_project_build_command OUTPUT_VAR BUILD_DIR)\n  if (\"${CMAKE_GENERATOR}\" STREQUAL \"Unix Makefiles\")\n    # HACK: This hack means that if the build generator for JFS\n    # is Make then `-j` value will passed through to make run\n    # to build the external project.\n    # See\n    # http://cmake.3232098.n2.nabble.com/How-would-I-use-parallel-make-on-ExternalProjects-td5609078.html\n    #\n    set(JFS_EXTERNAL_PROJECT_BUILD_COMMAND \"BUILD_COMMAND\" \"$(MAKE)\")\n  else()\n    include(ProcessorCount)\n    ProcessorCount(NUM_CPUS)\n    message(STATUS \"Detected ${NUM_CPUS} CPUS. Will run this many jobs when building runtime tests\")\n    set(JFS_EXTERNAL_PROJECT_BUILD_COMMAND\n      \"BUILD_COMMAND\" \"${CMAKE_COMMAND}\" \"--build\" \"${BUILD_DIR}\" \"--\" \"-j${NUM_CPUS}\")\n  endif()\n  set(${OUTPUT_VAR} ${JFS_EXTERNAL_PROJECT_BUILD_COMMAND} PARENT_SCOPE)\nendfunction()\n"
  },
  {
    "path": "cmake/jfs_get_llvm_components.cmake",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n\nfunction(jfs_get_llvm_components DESTVAR)\n  if (${ARGC} LESS 2)\n    message(FATAL_ERROR \"Insufficent number of argument\")\n  endif()\n  llvm_map_components_to_libnames(llvm_components ${ARGN})\n  set(${DESTVAR} ${llvm_components} PARENT_SCOPE)\nendfunction()\n"
  },
  {
    "path": "docs/tutorial/0-basics-example.smt2",
    "content": "(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n(define-fun a_b_rne () (_ FloatingPoint 11 53) (fp.div RNE a b))\n(define-fun a_b_rtp () (_ FloatingPoint 11 53) (fp.div RTP a b))\n(assert (not (fp.isNaN a)))\n(assert (not (fp.isNaN b)))\n(assert (not (fp.eq a_b_rne a_b_rtp)))\n(assert (not (fp.isNaN a_b_rne)))\n(assert (not (fp.isNaN a_b_rtp)))\n(check-sat)\n"
  },
  {
    "path": "docs/tutorial/0-basics.md",
    "content": "# JFS basics\n\nThis tutorial will walk you through the basics of using JFS.\n\nJFS is designed to solve constraints in the [SMT-LIBv2.6 format](http://smtlib.cs.uiowa.edu/).\nMore specifically it is designed to solve constraints that\nuse any combination of Booleans, BitVectors, and floating-point\ntypes.\n\nLet's walk through running JFS on the constraints in the [0-basics-example.smt2](0-basics-example.smt2) file.\n\nTry running the following. **NOTE the $ symbol indicates a shell\nprompt and it should not be typed.**\n\n```\n$ jfs 0-basics-example.smt2\nsat\n```\n\nWe can see that the tool responded with `sat` meaning that JFS found\na satisfying assignment to the constraints in `0-basics-example.smt2`.\n\n## Verbose output\n\nHow do we see what happened? We can use the `-v=1` to see more information. The `-v` sets the verbosity level.\n\n```\n$ jfs -v=1 -keep-output-dir 0-basics-example.smt2\n(WorkingDirectoryManager \"/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2\", deleteOnDestruction: 1)\npathToBinary: \"/home/user/dev/jfs/jfs/builds/upgrades/gcc_rel/runtime/bin/clang++\"\npathToRuntimeIncludeDir: \"/home/user/dev/jfs/jfs/builds/upgrades/gcc_rel/runtime/include\"\npathToLibFuzzerLib: \"/home/user/dev/jfs/jfs/builds/upgrades/gcc_rel/runtime/LibFuzzer_RelWithDebInfo/Fuzzer/libLLVMFuzzer.a\"\noptimizationLevel: O0\ndebug symbols:false\nuseASan: false\nuseUBSan: false\nsanitizerCoverageOptions: TRACE_PC_GUARD\n(Parser starting)\n(Parser finished)\n(QueryPassManager starting)\n(QueryPassManager \"AndHoisting\")\n(QueryPassManager \"Simplification\")\n(QueryPassManager \"AndHoisting\")\n(QueryPassManager \"Simplification\")\n(QueryPassManager \"ConstantPropagation\")\n(QueryPassManager \"AndHoisting\")\n(QueryPassManager \"Simplification\")\n(QueryPassManager \"ConstantPropagation\")\n(QueryPassManager \"Simplification\")\n(QueryPassManager \"AndHoisting\")\n(QueryPassManager \"DuplicateConstraintElimination\")\n(QueryPassManager \"TrueConstraintElimination\")\n(QueryPassManager \"SimpleContradictionsToFalse\")\n(QueryPassManager \"DuplicateConstraintElimination\")\n(QueryPassManager finished)\n(using solver \"CXXFuzzingSolver\")\n(QueryPassManager starting)\n(QueryPassManager \"EqualityExtractionPass\")\n(QueryPassManager \"FreeVariableToBufferAssignmentPass\")\n(QueryPassManager finished)\n(QueryPassManager starting)\n(QueryPassManager \"SortConformanceCheckPass\")\n(QueryPassManager finished)\n(QueryPassManager starting)\n(QueryPassManager \"CXXProgramBuilder\")\n(QueryPassManager finished)\n(ClangInvocationManager\n [\"/home/user/dev/jfs/jfs/builds/upgrades/gcc_rel/runtime/bin/clang++\", \"-std=c++11\", \"-I\", \"/home/user/dev/jfs/jfs/builds/upgrades/gcc_rel/runtime/include\", \"-O0\", \"-fno-omit-frame-pointer\", \"-fsanitize-coverage=trace-pc-guard\", \"/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/program.cpp\", \"/home/user/dev/jfs/jfs/builds/upgrades/gcc_rel/runtime/SMTLIB/SMTLIB__DebugSymbols_Optimized_TracePCGuard/libJFSSMTLIBRuntime.a\", \"/home/user/dev/jfs/jfs/builds/upgrades/gcc_rel/runtime/LibFuzzer_RelWithDebInfo/Fuzzer/libLLVMFuzzer.a\", \"-o\", \"/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/fuzzer\", ]\n)\n(SeedManager effectiveBound:18446744073709551615)\n(SeedManager creating seed \"/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/corpus/zeros_0\")\n(SeedManager creating seed \"/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/corpus/ones_0\")\n(SeedManager active generators exhausted)\n(SeedManager wrote 2 seeds (16 bytes each))\n(LibFuzzerInvocationManager\n[\"/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/fuzzer\", \"-runs=-1\", \"-seed=1\", \"-mutate_depth=5\", \"-cross_over=1\", \"-max_len=16\", \"-use_cmp=0\", \"-print_final_stats=1\", \"-reduce_inputs=0\", \"-default_mutators_resize_input=0\", \"-handle_abrt=1\", \"-handle_bus=0\", \"-handle_fpe=0\", \"-handle_ill=0\", \"-handle_int=1\", \"-handle_segv=0\", \"-handle_term=1\", \"-handle_xfsz=1\", \"-artifact_prefix=/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/artifacts/\", \"-error_exitcode=77\", \"-timeout_exitcode=88\", \"/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/corpus\", ]\n)\nINFO: Seed: 1\nINFO: HACK: Mutators that resize input DISABLED!\nINFO: Loaded 1 modules   (443 guards): 443 [0x677fd0, 0x6786bc),\nINFO:        2 files found in /home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/corpus\nJFS WARNING: Wrong sized input tried.\nINFO: seed corpus: files: 2 min: 16b max: 16b total: 32b rss: 33Mb\n#3      INITED cov: 23 ft: 23 corp: 2/32b exec/s: 0 rss: 33Mb\n#6      NEW    cov: 24 ft: 26 corp: 3/48b exec/s: 0 rss: 33Mb L: 16/16 MS: 3 CopyPart-CopyPart-ChangeBinInt-\n#9      NEW    cov: 25 ft: 27 corp: 4/64b exec/s: 0 rss: 33Mb L: 16/16 MS: 3 CrossOver-CopyPart-CrossOver-\n==24758== ERROR: libFuzzer: deadly signal\n    #0 0x42bcd3 in __sanitizer_print_stack_trace /home/user/dev/jfs/llvm6/src/projects/compiler-rt/lib/ubsan/ubsan_diag_standalone.cc:29\n    #1 0x43e811 in fuzzer::Fuzzer::CrashCallback() /home/user/dev/jfs/jfs/src/runtime/LibFuzzer/Fuzzer/FuzzerLoop.cpp:233:5\n    #2 0x43e7df in fuzzer::Fuzzer::StaticCrashSignalCallback() /home/user/dev/jfs/jfs/src/runtime/LibFuzzer/Fuzzer/FuzzerLoop.cpp:206:6\n    #3 0x151b23c44b8f  (/usr/lib/libpthread.so.0+0x11b8f)\n    #4 0x151b23289efa in __GI_raise (/usr/lib/libc.so.6+0x34efa)\n    #5 0x151b2328b2c0 in __GI_abort (/usr/lib/libc.so.6+0x362c0)\n    #6 0x42e4a5 in LLVMFuzzerTestOneInput (/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/fuzzer+0x42e4a5)\n    #7 0x43fa13 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /home/user/dev/jfs/jfs/src/runtime/LibFuzzer/Fuzzer/FuzzerLoop.cpp:524:13\n    #8 0x43f2ab in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /home/user/dev/jfs/jfs/src/runtime/LibFuzzer/Fuzzer/FuzzerLoop.cpp:449:3\n    #9 0x44043d in fuzzer::Fuzzer::MutateAndTestOne() /home/user/dev/jfs/jfs/src/runtime/LibFuzzer/Fuzzer/FuzzerLoop.cpp:657:19\n    #10 0x440c75 in fuzzer::Fuzzer::Loop(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, fuzzer::fuzzer_allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) /home/user/dev/jfs/jfs/src/runtime/LibFuzzer/Fuzzer/FuzzerLoop.cpp:784:5\n    #11 0x437a6b in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /home/user/dev/jfs/jfs/src/runtime/LibFuzzer/Fuzzer/FuzzerDriver.cpp:755:6\n    #12 0x4331a0 in main /home/user/dev/jfs/jfs/src/runtime/LibFuzzer/Fuzzer/FuzzerMain.cpp:20:10\n    #13 0x151b232769a6 in __libc_start_main (/usr/lib/libc.so.6+0x219a6)\n    #14 0x406af9 in _start (/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/fuzzer+0x406af9)\n\nNOTE: libFuzzer has rudimentary signal handlers.\n      Combine libFuzzer with AddressSanitizer or similar for better crash reports.\nSUMMARY: libFuzzer: deadly signal\nMS: 1 CopyPart-; base unit: 1519e74668a11df04e90de531274a5929990d1fa\n0x0,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0,0xff,0xff,0xff,0x0,\n\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\x00\\x00\\x00\\x00\\xff\\xff\\xff\\x00\nartifact_prefix='/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/artifacts/'; Test unit written to /home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/artifacts/crash-26f92ccb5076c2b6534271d13d4ac70dc5c26f2f\nBase64: AP///////wAAAAAA////AA==\nstat::number_of_executed_units: 25\nstat::average_exec_per_sec:     0\nstat::new_units_added:          2\nstat::slowest_unit_time_sec:    0\nstat::peak_rss_mb:              38\nsat\n```\n\nThe verbose output shows a lot of internal implementation details of JFS.\nWe'll now highlight some of the important information.\n\nThe line below informs us where JFS's temporary working directory will be\nlocated (note this can be set by using the `-output-dir` option).\nNote that `deleteOnDestruction` is set to 1 which means the temporary working\ndirectory will be deleted when JFS exits. To prevent this use the `-keep-output-dir` command line option.\n\n```\n(WorkingDirectoryManager \"/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2\", deleteOnDestruction: 1)\n```\n\nThe following lines indicate that the SMT-LIB parser is running.\n\n```\n(Parser starting)\n(Parser finished)\n```\n\nAfter parsing the next step is to run a set of simplification passes\non the constraints. We can see this in the `(QueryPassManager ...)` lines.\n\nAfter this we see the line `(using solver \"CXXFuzzingSolver\")`. This informs\nus that the CXXFuzzingSolver back-end is being used. Note this can be changed\non the command line. See `--help`, e.g. `-z3` causes Z3 to be used to solve the simplified constraints.\n\nAfter this we see the `QueryPassManager` running again. This is running\nsome passes that are specific to the CXXFuzzingSolver backend. Notice that\na pass named `CXXProgramBuilder` is executed. This pass reads the constraints\nand constructs a C++ program that encodes the constraints as a path\nreachability problem.\n\nAfter this we see the following.\n\n```\n(ClangInvocationManager\n [\"/home/user/dev/jfs/jfs/builds/upgrades/gcc_rel/runtime/bin/clang++\", \"-std=c++11\", \"-I\", \"/home/user/dev/jfs/jfs/builds/upgrades/gcc_rel/runtime/include\", \"-O0\", \"-fno-omit-frame-pointer\", \"-fsanitize-coverage=trace-pc-guard\", \"/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/program.cpp\", \"/home/user/dev/jfs/jfs/builds/upgrades/gcc_rel/runtime/SMTLIB/SMTLIB__DebugSymbols_Optimized_TracePCGuard/libJFSSMTLIBRuntime.a\",\n \"/home/user/dev/jfs/jfs/builds/upgrades/gcc_rel/runtime/LibFuzzer_RelWithDebInfo/Fuzzer/libLLVMFuzzer.a\", \"-o\", \"/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/fuzzer\", ]\n)\n```\n\nThis shows us how the Clang compiler is invoked to take the generated C++ programs and generate native code that is linked with [LibFuzzer](https://llvm.org/docs/LibFuzzer.html).\n\nAfter this we then see the following.\n\n```\n(SeedManager effectiveBound:18446744073709551615)\n(SeedManager creating seed \"/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/corpus/zeros_0\")\n(SeedManager creating seed \"/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/corpus/ones_0\")\n(SeedManager active generators exhausted)\n(SeedManager wrote 2 seeds (16 bytes each))\n```\n\nThis is informing us that JFS has created two seeds to fuzz the generated\nprograms and that each seed is 16 bytes.\n\nAfter this we see then the following.\n\n```\n(LibFuzzerInvocationManager\n[\"/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/fuzzer\", \"-runs=-1\", \"-seed=1\", \"-mutate_depth=5\", \"-cross_over=1\", \"-max_len=16\", \"-use_cmp=0\", \"-print_final_stats=1\", \"-reduce_inputs=0\", \"-default_mutators_resize_input=0\", \"-handle_abrt=1\", \"-handle_bus=0\", \"-handle_fpe=0\", \"-handle_ill=0\", \"-handle_int=1\", \"-handle_segv=0\", \"-handle_term=1\", \"-handle_xfsz=1\", \"-artifact_prefix=/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/artifacts/\", \"-error_exitcode=77\", \"-timeout_exitcode=88\", \"/home/user/dev/jfs/jfs/src/0-basics-example.smt2-2/corpus\", ]\n)\n```\n\nThis shows us how the generated binary is invoked to run LibFuzzer.\n\nThe output that follows this is [LibFuzzer's output](https://llvm.org/docs/LibFuzzer.html#output). Here we can see that\nLibFuzzer catches a deadly signal.\n\n```\n==24758== ERROR: libFuzzer: deadly signal\n```\n\nDue to the way the generated program is constructed, this indicates that\na satisfying assignment to constraints has been found.\n\n## Working directory\n\nWe can run the example again but this time keeping the working directory and\ngiving it a fixed name.\n\n```\n$ jfs -keep-output-dir -output-dir=wd 0-basics-example.smt2\nsat\n$ cd wd\n$ ls\nartifacts  clang.stderr.txt  clang.stdout.txt  corpus  fuzzer  libfuzzer.stderr.txt  libfuzzer.stdout.txt  program.cpp\n```\n\n* `artifacts/` - Contains the input that is a satisfying assignment (if any).\n* `clang.stderr.txt` - Contains any standard error output from the Clang invocation.\n* `clang.stdout.txt` - Contains any standard output from the Clang invocation.\n* `corpus/` - Contains the fuzzing corpus (seeds + found inputs).\n* `fuzzer` - Is the fuzzing binary that is executed by JFS\n* `libfuzzer.stderr.txt` - Contains any standard output from running the `fuzzer` binary.\n* `libfuzzer.stderr.txt` - Contains any standard error output from running the `fuzzer` binary.\n* `program.cpp` - The generated C++ program that is compiled using Clang.\n\nNote that the `*.stdout.txt` and `*.stderr.txt` files will not be created\nif JFS is used in verbose mode because the output goes to JFS's standard output and standard error output respectively. This behaviour can be changed\nby using the `-redirect-clang-output` and `-redirect-libfuzzer-output` options.\n"
  },
  {
    "path": "docs/tutorial/1-setting-resource-limits.md",
    "content": "# Setting JFS resource limits\n\nTODO\n"
  },
  {
    "path": "docs/tutorial/2-compilation-options-and-runtimes.md",
    "content": "# Compilation options and runtimes\n\nTODO\n"
  },
  {
    "path": "docs/tutorial/3-resumming-fuzzing.md",
    "content": "# Resumming fuzzing\n\nTODO\n"
  },
  {
    "path": "docs/tutorial/4-getting-models.md",
    "content": "# Getting a model from JFS\n\nTODO\n"
  },
  {
    "path": "docs/tutorial/5-jfs-smt2cxx.md",
    "content": "# The `jfs-smt2cxx` tool\n\nTODO\n"
  },
  {
    "path": "docs/tutorial/6-jfs-opt.md",
    "content": "# The `jfs-opt` tool\n\nTODO\n"
  },
  {
    "path": "include/jfs/CXXFuzzingBackend/CXXFuzzingSolver.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CXX_FUZZING_BACKEND_FUZZING_SOLVER_H\n#define JFS_CXX_FUZZING_BACKEND_FUZZING_SOLVER_H\n#include \"jfs/FuzzingCommon/FuzzingSolver.h\"\n\nnamespace jfs {\nnamespace cxxfb {\n\nclass CXXFuzzingSolverImpl;\nclass CXXFuzzingSolverOptions;\n\n// This solver emits a CXX program and fuzzes it to find a satisfying\n// assignment.\nclass CXXFuzzingSolver : public jfs::fuzzingCommon::FuzzingSolver {\nprivate:\n  std::unique_ptr<CXXFuzzingSolverImpl> impl;\n\nprotected:\n  std::unique_ptr<jfs::core::SolverResponse>\n  fuzz(jfs::core::Query& q, bool produceModel,\n       std::shared_ptr<jfs::fuzzingCommon::FuzzingAnalysisInfo> info) override;\n\npublic:\n  CXXFuzzingSolver(\n      std::unique_ptr<CXXFuzzingSolverOptions> options,\n      std::unique_ptr<jfs::fuzzingCommon::WorkingDirectoryManager> wdm,\n      jfs::core::JFSContext& ctx);\n  ~CXXFuzzingSolver();\n  llvm::StringRef getName() const override;\n  void cancel() override;\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/CXXFuzzingBackend/CXXFuzzingSolverOptions.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CXX_FUZZING_BACKEND_FUZZING_SOLVER_OPTIONS_H\n#define JFS_CXX_FUZZING_BACKEND_FUZZING_SOLVER_OPTIONS_H\n#include \"jfs/CXXFuzzingBackend/CXXProgramBuilderOptions.h\"\n#include \"jfs/CXXFuzzingBackend/ClangOptions.h\"\n#include \"jfs/Core/SolverOptions.h\"\n#include \"jfs/FuzzingCommon/FuzzingSolverOptions.h\"\n#include \"jfs/FuzzingCommon/LibFuzzerOptions.h\"\n#include \"jfs/FuzzingCommon/SeedManagerOptions.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace cxxfb {\n\nclass CXXFuzzingSolver;\nclass CXXFuzzingSolverImpl;\n\nclass CXXFuzzingSolverOptions\n    : public jfs::fuzzingCommon::FuzzingSolverOptions {\nprivate:\n  // Options\n  std::unique_ptr<ClangOptions> clangOpt;\n  std::unique_ptr<jfs::fuzzingCommon::LibFuzzerOptions> libFuzzerOpt;\n  std::unique_ptr<CXXProgramBuilderOptions> cxxProgramBuilderOpt;\n  std::unique_ptr<jfs::fuzzingCommon::SeedManagerOptions> seedManagerOpt;\n\npublic:\n  CXXFuzzingSolverOptions(\n      std::unique_ptr<\n          jfs::fuzzingCommon::FreeVariableToBufferAssignmentPassOptions>\n          fvtbapOptions,\n      std::unique_ptr<ClangOptions> clangOpt,\n      std::unique_ptr<jfs::fuzzingCommon::LibFuzzerOptions> libFuzzerOpt,\n      std::unique_ptr<CXXProgramBuilderOptions> cxxProgramBuilderOpt,\n      std::unique_ptr<jfs::fuzzingCommon::SeedManagerOptions> seedManagerOpt,\n      bool debugSaveModel);\n  static bool classof(const SolverOptions* so) {\n    return so->getKind() == CXX_FUZZING_SOLVER_KIND;\n  }\n  const ClangOptions* getClangOptions() const { return clangOpt.get(); }\n  // FIXME: This needs rethinking. This isn't const because the options\n  // need to be populated with internal implementation details before being\n  // used.\n  jfs::fuzzingCommon::LibFuzzerOptions* getLibFuzzerOptions() {\n    return libFuzzerOpt.get();\n  }\n  const CXXProgramBuilderOptions* getCXXProgramBuilderOptions() const {\n    return cxxProgramBuilderOpt.get();\n  }\n  friend class CXXFuzzingSolver;\n  friend class CXXFuzzingSolverImpl;\n\n  // public for convenience.\n  bool redirectClangOutput;\n  bool redirectLibFuzzerOutput;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/CXXFuzzingBackend/CXXProgram.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CXX_FUZZING_BACKEND_CXX_PROGRAM\n#define JFS_CXX_FUZZING_BACKEND_CXX_PROGRAM\n#include \"llvm/Support/raw_ostream.h\"\n#include <list>\n#include <memory>\n#include <string>\n#include <vector>\n\nnamespace jfs {\nnamespace cxxfb {\n\nclass CXXDecl;\nclass CXXCodeBlock;\nclass CXXType;\nclass CXXFunctionArgument;\nclass CXXFunctionDecl;\nclass CXXStatement;\nusing CXXDeclRef = std::shared_ptr<CXXDecl>;\nusing CXXCodeBlockRef = std::shared_ptr<CXXCodeBlock>;\nusing CXXTypeRef = std::shared_ptr<CXXType>;\nusing CXXFunctionArgumentRef = std::shared_ptr<CXXFunctionArgument>;\nusing CXXStatementRef = std::shared_ptr<CXXStatement>;\nusing CXXFunctionDeclRef = std::shared_ptr<CXXFunctionDecl>;\n\n// Base class for all declarations\nclass CXXDecl {\nprotected:\n  // CXXDecl's form a tree with parents owning the children.\n  // Therefore we don't need to partcipate in ownership (like\n  // CXXDeclRef would) and raw pointers are fine.\n  CXXDecl* parent;\n\npublic:\n  CXXDecl(CXXDecl* parent);\n  virtual ~CXXDecl();\n  virtual void print(llvm::raw_ostream&) const = 0;\n  CXXDecl* getParent() const;\n  void dump() const;\n};\n\n// Include\nclass CXXIncludeDecl : public CXXDecl {\nprivate:\n  std::string path;\n  bool isSystemInclude;\n\npublic:\n  CXXIncludeDecl(CXXDecl* parent, llvm::StringRef path, bool systemHeader);\n  ~CXXIncludeDecl() {}\n  void print(llvm::raw_ostream&) const override;\n  const std::string& getPath() const { return path; }\n};\n\n// Statement (for use inside code blocks)\nclass CXXStatement : public CXXDecl {\npublic:\n  CXXStatement(CXXDecl* parent) : CXXDecl(parent) {}\n  ~CXXStatement();\n};\n\n// Comment block\nclass CXXCommentBlock : public CXXStatement {\nprivate:\n  std::string comment;\n\npublic:\n  CXXCommentBlock(CXXDecl* parent, llvm::StringRef comment)\n      : CXXStatement(parent), comment(comment) {}\n  void print(llvm::raw_ostream&) const override;\n  const std::string& getComment() const { return comment; }\n};\n\nclass CXXCodeBlock;\nclass CXXType;\nclass CXXFunctionArgument;\n// Function definition\nclass CXXFunctionDecl : public CXXDecl {\nprivate:\n  std::string name;\n  CXXTypeRef returnTy;\n  std::vector<CXXFunctionArgumentRef> arguments;\n  bool hasCVisibility;\n\npublic:\n  // FIXME: shouldn't be public\n  CXXCodeBlockRef defn;\n  // Declaration\n  CXXFunctionDecl(CXXDecl* parent, llvm::StringRef name, CXXTypeRef returnTy,\n                  std::vector<CXXFunctionArgumentRef>& arguments,\n                  bool hasCVisibility);\n  // Definition\n  ~CXXFunctionDecl();\n  void print(llvm::raw_ostream&) const override;\n  bool isDecl() const { return defn.get() == nullptr; }\n  bool isDefn() const { return !isDecl(); }\n};\n\n// CXXType\nclass CXXType : public CXXDecl {\nprivate:\n  std::string name;\n  bool isConst;\n\npublic:\n  CXXType(CXXDecl* parent, llvm::StringRef name, bool isConst);\n  CXXType(CXXDecl* parent, llvm::StringRef name);\n  ~CXXType();\n  void print(llvm::raw_ostream&) const override;\n  llvm::StringRef getName() const { return name; }\n};\n\n// CXXFunctionArgument\nclass CXXFunctionArgument : public CXXDecl {\nprivate:\n  std::string name;\n  CXXTypeRef argType;\n\npublic:\n  CXXFunctionArgument(CXXDecl* parent, llvm::StringRef name,\n                      CXXTypeRef argType);\n  ~CXXFunctionArgument();\n  void print(llvm::raw_ostream&) const override;\n};\n\n// CXXCodeBlock\nclass CXXCodeBlock : public CXXDecl {\npublic:\n  // FIXME: shouldn't be public but its easier to just write to this\n  std::list<CXXStatementRef> statements;\n  CXXCodeBlock(CXXDecl* parent);\n  ~CXXCodeBlock();\n  void print(llvm::raw_ostream&) const override;\n};\n\n// CXXIfStatement\nclass CXXIfStatement : public CXXStatement {\nprivate:\n  std::string condition;\n\npublic:\n  CXXIfStatement(CXXCodeBlock* parent, llvm::StringRef condition);\n  void print(llvm::raw_ostream&) const override;\n  // FIXME: shouldn't be public\n  CXXCodeBlockRef trueBlock;\n  CXXCodeBlockRef falseBlock;\n};\n\n// CXXReturnIntStatement\nclass CXXReturnIntStatement : public CXXStatement {\nprivate:\n  int returnValue;\n\npublic:\n  CXXReturnIntStatement(CXXCodeBlock* parent, int returnValue);\n  void print(llvm::raw_ostream&) const override;\n};\n\n// CXXDeclAndDefnVarStatement\nclass CXXDeclAndDefnVarStatement : public CXXStatement {\nprivate:\n  CXXTypeRef ty;\n  std::string name;\n  std::string valueExpr;\n\npublic:\n  CXXDeclAndDefnVarStatement(CXXDecl* parent, CXXTypeRef ty,\n                             llvm::StringRef name, llvm::StringRef valueExpr);\n  llvm::StringRef getName() const { return valueExpr; }\n  void print(llvm::raw_ostream&) const override;\n};\n\n// This is a hack\n// CXXGenericStatement\nclass CXXGenericStatement : public CXXStatement {\nprivate:\n  std::string statement;\n\npublic:\n  CXXGenericStatement(CXXDecl* parent, llvm::StringRef statement);\n  void print(llvm::raw_ostream&) const override;\n};\n\nclass CXXProgram : public CXXDecl {\nprivate:\n  typedef std::vector<CXXDeclRef> declStorageTy;\n  declStorageTy decls;\n  // FIXME: This should really be a set but we want the order that libraries\n  // are requested to be preserved.\n  typedef std::vector<std::string> libNameStoreageTy;\n  libNameStoreageTy requiredLibs;\n  bool recordsRuntimeStats;\n\npublic:\n  CXXProgram() : CXXDecl(nullptr), recordsRuntimeStats(false) {}\n  void print(llvm::raw_ostream&) const override;\n  void appendDecl(CXXDeclRef);\n  void addRequiredLibrary(llvm::StringRef name); // FIXME: Remove unused feature\n  bool\n  libraryIsRequired(llvm::StringRef name) const; // FIXME: Remove unused feature\n  bool getRecordsRuntimeStats() const { return recordsRuntimeStats; }\n  void setRecordsRuntimeStats(bool v) { recordsRuntimeStats = v; }\n  // Iterators\n  declStorageTy::const_iterator cbegin() const { return decls.cbegin(); }\n  declStorageTy::const_iterator cend() const { return decls.cend(); }\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/CXXFuzzingBackend/CXXProgramBuilderOptions.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CXX_FUZZING_BACKEND_CXX_PROGRAM_BUILDER_OPTIONS_H\n#define JFS_CXX_FUZZING_BACKEND_CXX_PROGRAM_BUILDER_OPTIONS_H\n#include <memory>\n\nnamespace jfs {\nnamespace cxxfb {\n\nclass CXXProgramBuilderOptions {\nprivate:\n  bool recordMaxNumSatisifiedConstraints = false;\n  bool recordNumberOfInputs = false;\n  bool recordNumberOfWrongSizedInputs = false;\n  bool traceIncreaseMaxNumSatisfiedConstraints = false;\n  bool traceWrongSizedInputs = false;\n\npublic:\n  CXXProgramBuilderOptions();\n  bool getRecordMaxNumSatisfiedConstraints() const {\n    return recordMaxNumSatisifiedConstraints;\n  }\n  void setRecordMaxNumSatisfiedConstraints(bool v) {\n    recordMaxNumSatisifiedConstraints = v;\n  }\n\n  bool getRecordNumberOfInputs() const { return recordNumberOfInputs; }\n  void setRecordNumberOfInputs(bool v) { recordNumberOfInputs = v; }\n\n  bool getRecordNumberOfWrongSizedInputs() const {\n    return recordNumberOfWrongSizedInputs;\n  }\n  void setRecordNumberOfWrongSizedInputs(bool v) {\n    recordNumberOfWrongSizedInputs = v;\n  }\n\n  bool getTraceIncreaseMaxNumSatisfiedConstraints() const {\n    return traceIncreaseMaxNumSatisfiedConstraints;\n  }\n  void setTraceIncreaseMaxNumSatisfiedConstraints(bool v) {\n    traceIncreaseMaxNumSatisfiedConstraints = v;\n  }\n\n  bool getTraceWrongSizedInputs() const { return traceWrongSizedInputs; }\n  void setTraceWrongSizedInputs(bool v) { traceWrongSizedInputs = v; }\n\n  enum class BranchEncodingTy {\n    // Fail fast encoding\n    //\n    // If a constraint is found to be unsatisfiable fuzzing\n    // the current input is immediately halted without checking\n    // the remaining constraints.\n    //\n    // There are several problems with this encoding.\n    //\n    // * It is sensitive to the order constraints are checked.\n    // * Potentially prevents partially satisfying inputs from\n    //   being observed which then prevents the input corpus\n    //   from growing.\n    //\n    //   In essence the encoding forces constraints to be solved\n    //   in particular order.\n    FAIL_FAST,\n    // Try all encoding\n    //\n    // This is the \"Serebryany encoding\", named after\n    // Kostya Serebryany who proposed this.\n    //\n    // This encoding evaluates all constraints. This encoding\n    // addresses problems from the `TRY_ALL` encoding because\n    // this approach means that the order that constraints are\n    // checked do not matter.\n    //\n    // However it introduces a new problem in that in some cases\n    // inputs that increase the number of satisfied constraints\n    // are not added to the input corpus.\n    //\n    // For example. Let's say there are three constraints C0, C1, C2, C3.\n    // Let's say that Input A satisfies {C0, C1} and Input B satisfies {C2}. So\n    // Inputs A and B get added to the corpus. Then we try Input C which\n    // satisfies {C0, C1, C2}. This input will not be added to the input corpus\n    // because the branches for C0, C1, and C2 were already covered.\n    TRY_ALL,\n    // Try all IMNCSF\n    //\n    // IMNCSF - Increase in Maximum Number of Constraints Solved is a Feature\n    //\n    // This is the \"Cadar encoding\", named after Cristian Cadar\n    // who proposed this.\n    //\n    // This is an enhancement to the `TRY_ALL` encoding that addresses\n    // the issue where some inputs that increase the number of solved\n    // constraints\n    // might not be added to the corpus.\n    //\n    // This relies on an experimental LibFuzzer feature to treat an increase in\n    // the number of solved constraints as a \"feature\".\n    //\n    // At the time of writing this feature on works on Linux.\n    //\n    // FIXME: We should guard this so it is only available on Linux.\n    TRY_ALL_IMNCSF,\n  };\n\nprivate:\n  BranchEncodingTy branchEncoding = BranchEncodingTy::FAIL_FAST;\n\npublic:\n  BranchEncodingTy getBranchEncoding() const { return branchEncoding; }\n  void setBranchEncoding(BranchEncodingTy ty) { branchEncoding = ty; }\n};\n} // namespace cxxfb\n} // namespace jfs\n#endif\n"
  },
  {
    "path": "include/jfs/CXXFuzzingBackend/CXXProgramBuilderPass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CXX_FUZZING_BACKEND_CXX_PROGRAM_BUILDER_PASS_H\n#define JFS_CXX_FUZZING_BACKEND_CXX_PROGRAM_BUILDER_PASS_H\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/FuzzingCommon/FuzzingAnalysisInfo.h\"\n#include \"jfs/Transform/QueryPass.h\"\n\nnamespace jfs {\nnamespace cxxfb {\n\nclass CXXProgram;\nclass CXXProgramBuilderPassImpl;\nclass CXXProgramBuilderOptions;\n\nclass CXXProgramBuilderPass : public jfs::transform::QueryPass {\nprivate:\n  std::unique_ptr<CXXProgramBuilderPassImpl> impl;\n\npublic:\n  CXXProgramBuilderPass(\n      std::shared_ptr<jfs::fuzzingCommon::FuzzingAnalysisInfo> info,\n      const CXXProgramBuilderOptions* options, jfs::core::JFSContext& ctx);\n  ~CXXProgramBuilderPass();\n  bool run(jfs::core::Query& q) override;\n  virtual llvm::StringRef getName() override;\n  // FIXME: Should be a const CXXProgram\n  std::shared_ptr<CXXProgram> getProgram();\n  virtual bool convertModel(jfs::core::Model* m) override;\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/CXXFuzzingBackend/ClangInvocationManager.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CXX_FUZZING_BACKEND_CLANG_INVOCATION_MANAGER_H\n#define JFS_CXX_FUZZING_BACKEND_CLANG_INVOCATION_MANAGER_H\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Support/ICancellable.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace cxxfb {\n\n// Forward declarations\nstruct ClangOptions;\nclass ClangInvocationManagerImpl;\nclass CXXProgram;\n\nclass ClangInvocationManager : public jfs::support::ICancellable {\nprivate:\n  std::unique_ptr<ClangInvocationManagerImpl> impl;\n\npublic:\n  ClangInvocationManager(jfs::core::JFSContext& ctx);\n  virtual ~ClangInvocationManager();\n  // Compile `program`. If `sourceFile` is non-empty the source file\n  // will be written to disk before being read by Clang. If `sourceFile`\n  // is empty the implementation is allowed to pipe the program directly\n  // to Clang.\n  bool compile(const CXXProgram* program, llvm::StringRef sourceFile,\n               llvm::StringRef outputFile, const ClangOptions* options,\n               llvm::StringRef stdOutFile, llvm::StringRef stdErrFile);\n  void cancel() override;\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/CXXFuzzingBackend/ClangOptions.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CXX_FUZZING_BACKEND_CLANG_OPTIONS_H\n#define JFS_CXX_FUZZING_BACKEND_CLANG_OPTIONS_H\n#include \"jfs/Core/JFSContext.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <string>\n#include <vector>\n\nnamespace jfs {\nnamespace cxxfb {\n\nstruct ClangOptions {\n  // Paths should be absolute\n  std::string pathToBinary;\n  std::string pathToRuntimeDir;\n  std::string pathToRuntimeIncludeDir;\n  std::string pathToLibFuzzerLib;\n  enum class OptimizationLevel { O0, O1, O2, O3 };\n  OptimizationLevel optimizationLevel;\n  bool debugSymbols;\n  bool useASan;\n  bool useUBSan;\n  bool useJFSRuntimeAsserts;\n  enum class SanitizerCoverageTy {\n    TRACE_PC_GUARD,\n    TRACE_CMP,\n    // TODO: Add more\n  };\n  std::vector<SanitizerCoverageTy> sanitizerCoverageOptions;\n  // FIXME: We should populate this enum from the CMake\n  // runtime declarations.\n  enum class LibFuzzerBuildType {\n    REL_WITH_DEB_INFO,\n  };\n  bool pureRandomFuzzer;\n  // If `pathToExecutable` is not empty then paths will be\n  // inferred assuming that `pathToExecutable` is the absolute\n  // path to the `jfs` binary.\n  ClangOptions(llvm::StringRef pathToExecutable, LibFuzzerBuildType lfbt,\n               bool pureRandomFuzzer);\n  ClangOptions(bool pureRandomFuzzer);\n  void appendSanitizerCoverageOption(SanitizerCoverageTy opt);\n  void dump() const;\n  void print(llvm::raw_ostream& os) const;\n  bool checkPaths(jfs::core::JFSContext& ctx) const;\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/CXXFuzzingBackend/CmdLine/CXXProgramBuilderOptionsBuilder.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CXX_FUZZING_BACKEND_CMDLINE_CXX_PROGRAM_BUILDER_OPTIONS_BUILDER\n#define JFS_CXX_FUZZING_BACKEND_CMDLINE_CXX_PROGRAM_BUILDER_OPTIONS_BUILDER\n#include \"jfs/CXXFuzzingBackend/CXXProgramBuilderOptions.h\"\n#include \"jfs/Core/JFSContext.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace cxxfb {\nnamespace cl {\n\nstd::unique_ptr<jfs::cxxfb::CXXProgramBuilderOptions>\nbuildCXXProgramBuilderOptionsFromCmdLine();\n}\n} // namespace cxxfb\n} // namespace jfs\n\n#endif\n"
  },
  {
    "path": "include/jfs/CXXFuzzingBackend/CmdLine/ClangOptionsBuilder.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CXX_FUZZING_BACKEND_CMDLINE_CLANG_OPTIONS_BUILDER_H\n#define JFS_CXX_FUZZING_BACKEND_CMDLINE_CLANG_OPTIONS_BUILDER_H\n#include \"jfs/CXXFuzzingBackend/ClangOptions.h\"\n#include \"jfs/Core/JFSContext.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace cxxfb {\nnamespace cl {\n\nstd::unique_ptr<jfs::cxxfb::ClangOptions>\nbuildClangOptionsFromCmdLine(llvm::StringRef pathToExecutable);\n}\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/CXXFuzzingBackend/CmdLine/CommandLineCategory.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CXX_FUZZING_BACKEND_CMDLINE_COMMAND_LINE_CATEGORY_H\n#define JFS_CXX_FUZZING_BACKEND_CMDLINE_COMMAND_LINE_CATEGORY_H\n#include \"llvm/Support/CommandLine.h\"\n\nnamespace jfs {\nnamespace cxxfb {\nnamespace cl {\n\nextern llvm::cl::OptionCategory CommandLineCategory;\n}\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/CXXFuzzingBackend/JFSCXXProgramStat.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CXX_FUZZING_BACKEND_JFS_CXX_PROGRAM_STAT_H\n#define JFS_CXX_FUZZING_BACKEND_JFS_CXX_PROGRAM_STAT_H\n#endif\n#include \"jfs/Support/JFSStat.h\"\n\nnamespace jfs {\nnamespace cxxfb {\nclass JFSCXXProgramStat : public jfs::support::JFSStat {\npublic:\n  JFSCXXProgramStat(llvm::StringRef name);\n  virtual ~JFSCXXProgramStat();\n  void printYAML(llvm::ScopedPrinter& os) const override;\n  static bool classof(const JFSStat* s) { return s->getKind() == CXX_PROGRAM; }\n\n  // FIMXE: Should not be public\n  uint64_t numConstraints = 0;\n  uint64_t numEntryFuncStatements = 0;\n  // FIXME: Doesn't really belong here. The FuzzingAnalysisInfo should have its\n  // own stat\n  uint64_t numFreeVars = 0;\n  uint64_t bufferStoredWidth = 0;\n  uint64_t bufferTypeWidth = 0; // Sum of the type widths of each BufferElement\n  uint64_t numEqualitySets = 0;\n};\n}\n}\n"
  },
  {
    "path": "include/jfs/Config/config.h.in",
    "content": "#ifndef JFS_CONFIG_CONFIG_H\n#define JFS_CONFIG_CONFIG_H\n\n// TODO\n\n#endif\n"
  },
  {
    "path": "include/jfs/Config/depsVersion.h.in",
    "content": "#ifndef JFS_CONFIG_DEPS_VERSION_H\n#define JFS_CONFIG_DEPS_VERSION_H\n\n/* LLVM major version number */\n#define LLVM_VERSION_MAJOR @LLVM_VERSION_MAJOR@\n\n/* LLVM minor version number */\n#define LLVM_VERSION_MINOR @LLVM_VERSION_MINOR@\n\n/* Z3 major version number */\n#define Z3_VERSION_MAJOR @Z3_VERSION_MAJOR@\n\n/* Z3 minor version number */\n#define Z3_VERSION_MINOR @Z3_VERSION_MINOR@\n\n/* Useful macro to compile code depending on LLVM version */\n#define LLVM_VERSION(major, minor) (((major) << 8) | (minor))\n#define LLVM_VERSION_CODE LLVM_VERSION(LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR)\n\n#endif\n"
  },
  {
    "path": "include/jfs/Config/version.h.in",
    "content": "#ifndef JFS_CONFIG_VERSION_H\n#define JFS_CONFIG_VERSION_H\n\n/* JFS major version number */\n#define JFS_VERSION_MAJOR @JFS_VERSION_MAJOR@\n\n/* JFS minor version number */\n#define JFS_VERSION_MINOR @JFS_VERSION_MINOR@\n\n/* JFS patch version number */\n#define JFS_VERSION_PATCH @JFS_VERSION_PATCH@\n\n/* JFS tweak version number */\n#define JFS_VERSION_TWEAK @JFS_VERSION_TWEAK@\n\n/* JFS git description */\n#cmakedefine JFS_GIT_DESCRIPTION @JFS_GIT_DESCRIPTION@\n\n/* JFS git hash */\n#cmakedefine JFS_GIT_HASH @JFS_GIT_HASH@\n\n#endif\n"
  },
  {
    "path": "include/jfs/Core/IfVerbose.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_IF_VERBOSE_H\n#define JFS_CORE_IF_VERBOSE_H\n\n#define IF_VERB_GT(CTX, VALUE, ACTION)                                         \\\n  do {                                                                         \\\n    if (CTX.getVerbosity() > VALUE) {                                          \\\n      ACTION;                                                                  \\\n    }                                                                          \\\n  } while (0)\n\n#define IF_VERB(CTX, ACTION) IF_VERB_GT(CTX, 0, ACTION)\n\n#endif\n"
  },
  {
    "path": "include/jfs/Core/JFSContext.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_JFSCONTEXT_H\n#define JFS_CORE_JFSCONTEXT_H\n#include \"z3.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include \"llvm/Support/raw_ostream.h\"\n\nnamespace jfs {\nnamespace support {\nclass StatisticsManager;\n}\n}\n\nnamespace jfs {\nnamespace core {\nstruct JFSContextConfig {\n  unsigned verbosity = 0;\n  bool gathericStatistics = false;\n  uint64_t seed = 1;\n};\n\nclass JFSContext;\nclass JFSContextErrorHandler {\npublic:\n  enum ErrorAction { STOP, CONTINUE };\n  virtual ErrorAction handleZ3error(JFSContext& ctx, Z3_error_code ec) = 0;\n  virtual ErrorAction handleFatalError(JFSContext& ctx,\n                                       llvm::StringRef msg) = 0;\n  virtual ErrorAction handleGenericError(JFSContext& ctx,\n                                         llvm::StringRef msg) = 0;\n  JFSContextErrorHandler();\n  virtual ~JFSContextErrorHandler();\n};\n\nclass JFSContextImpl;\nclass RNG;\n\nclass JFSContext {\nprivate:\n  const std::unique_ptr<JFSContextImpl> impl;\n\npublic:\n  JFSContext(const JFSContextConfig& ctxCfg);\n  ~JFSContext();\n\n  // Don't allow copying\n  JFSContext(const JFSContext&) = delete;\n  JFSContext(const JFSContext&&) = delete;\n  JFSContext& operator=(const JFSContext&) = delete;\n\n  bool operator==(const JFSContext& other) const;\n\n  bool registerErrorHandler(JFSContextErrorHandler* h);\n  bool unRegisterErrorHandler(JFSContextErrorHandler* h);\n\n  Z3_context getZ3Ctx() const;\n  // TODO: Rethink this API.\n  unsigned getVerbosity() const;\n  // Message streams\n  llvm::raw_ostream& getErrorStream();\n  llvm::raw_ostream& getWarningStream();\n  llvm::raw_ostream& getDebugStream();\n\n  // FIXME: Should check compiler supports attribute\n  // Unlike Z3 errors it is guaranteed that execution will\n  // not leave this function.\n  __attribute__((noreturn)) void raiseFatalError(llvm::StringRef msg);\n\n  void raiseError(llvm::StringRef msg);\n  jfs::support::StatisticsManager* getStats() const;\n  const JFSContextConfig& getConfig() const;\n  RNG& getRNG() const;\n};\n}\n}\n#endif // JFS_JFSCONTEXT_H\n"
  },
  {
    "path": "include/jfs/Core/JFSTimerMacros.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_JFS_TIMER_MACROS_H\n#define JFS_CORE_JFS_TIMER_MACROS_H\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Support/JFSStat.h\"\n#include \"jfs/Support/ScopedJFSTimerStatAppender.h\"\n#include \"jfs/Support/StatisticsManager.h\"\n\n#define JFS_SM_TIMER(NAME, CTX)                                                \\\n  jfs::support::ScopedJFSTimerStatAppender<jfs::support::StatisticsManager>    \\\n      NAME##_timer(((CTX).getConfig().gathericStatistics) ? (CTX.getStats())   \\\n                                                          : nullptr,           \\\n                   #NAME)\n\n#define JFS_AG_TIMER(DECL_NAME, NAME, AG, CTX)                                 \\\n  jfs::support::ScopedJFSTimerStatAppender<                                    \\\n      jfs::support::JFSAggregateTimerStat>                                     \\\n      DECL_NAME##_timer(                                                       \\\n          ((CTX).getConfig().gathericStatistics) ? (AG.stats.get()) : nullptr, \\\n          (NAME))\n\n#define JFS_AG_COL(NAME, CTX)                                                  \\\n  jfs::support::ScopedJFSAggregateTimerStatAppender<                           \\\n      jfs::support::StatisticsManager>                                         \\\n      NAME(((CTX).getConfig().gathericStatistics) ? (CTX.getStats())           \\\n                                                  : nullptr,                   \\\n           #NAME)\n#endif\n"
  },
  {
    "path": "include/jfs/Core/Model.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_MODEL_H\n#define JFS_CORE_MODEL_H\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include <string>\n\nnamespace jfs {\nnamespace core {\n\nstruct ModelPrintOptions {\n  bool sortDecls = false;\n  bool useModelKeyword = false;\n};\n\nclass Model {\nprotected:\n  jfs::core::Z3ModelHandle z3Model;\n  JFSContext& ctx;\n  Model(JFSContext& ctx);\n\npublic:\n  // The idea behind this interface is to allow implementations\n  // to defer working with Z3ModelHandle and only forcing use when\n  // `getRepr()` is called. At the time of writing no implementations\n  // actually do this so perhaps we should remove this complexity?\n  virtual Z3ASTHandle getAssignmentFor(Z3FuncDeclHandle);\n  virtual bool addAssignmentFor(Z3FuncDeclHandle decl, Z3ASTHandle e,\n                                bool allowOverwrite = false);\n  virtual std::string getSMTLIBString(ModelPrintOptions* opts = nullptr);\n  virtual bool hasAssignmentFor(Z3FuncDeclHandle decl);\n  virtual Z3ModelHandle getRepr() { return z3Model; }\n  virtual bool replaceRepr(Z3ModelHandle replacement);\n  virtual Z3ASTHandle evaluate(Z3ASTHandle e, bool modelCompletion);\n\n  JFSContext& getContext();\n  virtual ~Model();\n\n  static Z3ASTHandle getDefaultValueFor(Z3SortHandle sort);\n};\n\n} // namespace core\n} // namespace jfs\n#endif\n"
  },
  {
    "path": "include/jfs/Core/ModelValidator.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Alastair Donaldson\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_MODEL_VALIDATOR_H\n#define JFS_CORE_MODEL_VALIDATOR_H\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Core/Model.h\"\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include <string>\n\nnamespace jfs {\nnamespace core {\n\nclass ValidationFailureInfo {\npublic:\n  enum ReasonTy {\n    NO_REASON,\n    EVALUATED_TO_FALSE,\n    EVALUATED_TO_NON_CONSTANT,\n    EVALUATED_TO_NON_BOOL_SORT,\n  };\n  ReasonTy reason;\n  uint64_t index;\n  Z3ASTHandle constraint;\n  Model* model;\n  // TODO: Add methods to allow further debugging.\n  // It would be useful to recursively walk the AST\n  // to find which assignments are responsible and\n  // which part of the subtree is causing the constraint\n  // to evaluate to false.\n  ValidationFailureInfo(ReasonTy reason, uint64_t index, Z3ASTHandle constraint,\n                        Model* model);\n  ValidationFailureInfo();\n  static const char* reasonAsString(ReasonTy reason);\n};\n\nclass ModelValidationOptions {\npublic:\n  bool warnOnVariablesMissingAssignment = true;\n};\n\nclass ModelValidator {\npublic:\n  using VFIContainerTy = std::vector<ValidationFailureInfo>;\n\nprivate:\n  VFIContainerTy failures;\n\npublic:\n  ModelValidator();\n  ~ModelValidator();\n  VFIContainerTy::const_iterator cbegin() const { return failures.cbegin(); }\n  VFIContainerTy::const_iterator cend() const { return failures.cend(); }\n  VFIContainerTy::iterator begin() { return failures.begin(); }\n  VFIContainerTy::iterator end() { return failures.end(); }\n  uint64_t getNumberOfFailures() const { return failures.size(); }\n  void reset();\n  bool validate(const Query& q, Model* m,\n                const ModelValidationOptions* options = nullptr);\n  std::string toStr() const;\n};\n} // namespace core\n} // namespace jfs\n#endif\n"
  },
  {
    "path": "include/jfs/Core/Query.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_QUERY_H\n#define JFS_CORE_QUERY_H\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <vector>\n\nnamespace jfs {\nnamespace core {\nclass Query {\nprivate:\n  JFSContext& ctx;\n\npublic:\n  std::vector<Z3ASTHandle> constraints;\n  Query(JFSContext& ctx);\n  ~Query();\n  Query(const Query& other);\n  // In principle there's no reason we can't have these deleted methods.\n  // However we don't need them yet and I don't want the implicit declarations\n  // to accidently be called.\n  Query(const Query&&) = delete;\n  Query& operator=(const Query&) = delete;\n  Query& operator=(const Query&&) = delete;\n  void dump() const;\n  void collectFuncDecls(Z3FuncDeclSet& variables) const;\n  void print(llvm::raw_ostream& os) const;\n  JFSContext& getContext() const { return ctx; }\n\n  static bool areSame(std::vector<Z3ASTHandle>& a, std::vector<Z3ASTHandle>& b,\n                      bool ignoreOrder = false);\n};\n\n// Operator overload for easy printing of queries\nllvm::raw_ostream& operator<<(llvm::raw_ostream& os, const Query& q);\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Core/RNG.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef JFS_CORE_RNG_H\n#define JFS_CORE_RNG_H\n\n#include <cstdint>\n#include <random>\n\nnamespace jfs {\nnamespace core {\n\nclass RNG {\nprivate:\n  std::mt19937_64 generator;\n\npublic:\n  RNG(uint64_t seed)\n      : generator(seed ? seed : std::mt19937_64::default_seed) {}\n\n  // Produce an integer in the range [0, limit).\n  uint64_t generate(uint64_t limit);\n};\n\n} // jfs\n} // core\n\n#endif // JFS_CORE_RNG_H"
  },
  {
    "path": "include/jfs/Core/SMTLIB2Parser.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_SMTLIB2PARSER_H\n#define JFS_CORE_SMTLIB2PARSER_H\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Core/Query.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include <memory>\n\nnamespace llvm {\nclass MemoryBuffer;\n}\n\nnamespace jfs {\nnamespace core {\nclass SMTLIB2Parser : public JFSContextErrorHandler {\npublic:\n  SMTLIB2Parser(JFSContext& ctx);\n  ~SMTLIB2Parser();\n  std::shared_ptr<Query> parseFile(llvm::StringRef fileName);\n  std::shared_ptr<Query> parseStr(llvm::StringRef str);\n  std::shared_ptr<Query>\n  parseMemoryBuffer(std::unique_ptr<llvm::MemoryBuffer> buffer);\n  ErrorAction handleZ3error(JFSContext& ctx, Z3_error_code ec) override;\n  ErrorAction handleFatalError(JFSContext& ctx, llvm::StringRef msg) override;\n  ErrorAction handleGenericError(JFSContext& ctx, llvm::StringRef msg) override;\n  unsigned getErrorCount() const;\n  void resetErrorCount();\n\nprivate:\n  JFSContext& ctx;\n  unsigned errorCount;\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Core/ScopedJFSContextErrorHandler.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_SCOPED_JFS_CONTEXT_ERROR_HANDLER_H\n#define JFS_CORE_SCOPED_JFS_CONTEXT_ERROR_HANDLER_H\n#include \"jfs/Core/JFSContext.h\"\nnamespace jfs {\nnamespace core {\nclass ScopedJFSContextErrorHandler {\nprivate:\n  JFSContext& ctx;\n  JFSContextErrorHandler* handler;\n\npublic:\n  ScopedJFSContextErrorHandler(JFSContext& ctx, JFSContextErrorHandler* h)\n      : ctx(ctx), handler(h) {\n    ctx.registerErrorHandler(handler);\n  }\n  ~ScopedJFSContextErrorHandler() { ctx.unRegisterErrorHandler(handler); }\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Core/SimpleModel.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Alastair Donaldson\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_SIMPLE_MODEL_H\n#define JFS_CORE_SIMPLE_MODEL_H\n#include \"jfs/Core/Model.h\"\n\nnamespace jfs {\nnamespace core {\n\n// A model that on creation is empty\nclass SimpleModel : public Model {\npublic:\n  SimpleModel(JFSContext& ctx);\n};\n\n} // namespace core\n} // namespace jfs\n\n#endif\n"
  },
  {
    "path": "include/jfs/Core/Solver.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_SOLVER_H\n#define JFS_CORE_SOLVER_H\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Core/SolverOptions.h\"\n#include \"jfs/Support/ICancellable.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include <memory>\n#include <stdint.h>\n\nnamespace jfs {\nnamespace core {\n\nclass Model;\n\nclass SolverResponse {\npublic:\n  enum SolverSatisfiability { SAT, UNSAT, UNKNOWN };\n  SolverResponse(SolverSatisfiability sat);\n  virtual ~SolverResponse();\n  const SolverSatisfiability sat;\n  virtual Model* getModel() = 0;\n  static llvm::StringRef getSatString(SolverSatisfiability);\n};\n\nclass Solver : public jfs::support::ICancellable {\nprotected:\n  std::unique_ptr<SolverOptions> options;\n  JFSContext& ctx;\n\npublic:\n  Solver(std::unique_ptr<SolverOptions> options, JFSContext& ctx);\n  virtual ~Solver();\n  Solver(const Solver&) = delete;\n  Solver(const Solver&&) = delete;\n  Solver& operator=(const Solver&) = delete;\n  // Determine the satisfiability of the query.\n  // Iff `produceModel` is false then only satisfiability will\n  // be available.\n  virtual std::unique_ptr<SolverResponse> solve(const Query& q,\n                                                bool produceModel) = 0;\n  const SolverOptions* getOptions() const;\n  virtual llvm::StringRef getName() const = 0;\n  JFSContext& getContext() { return ctx; }\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Core/SolverOptions.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_SOLVER_OPTIONS_H\n#define JFS_CORE_SOLVER_OPTIONS_H\n#include \"llvm/Support/Casting.h\"\n#include <stdint.h>\n\nnamespace jfs {\nnamespace core {\n\nclass SolverOptions {\n  // START: LLVM RTTI boilerplate code\npublic:\n  // NOTE: When updating this enum make sure you update all implementations\n  // of `classof(const SolverOptions* so)`.\n  enum SolverOptionKind {\n    SOLVER_OPTIONS_KIND,\n    FUZZING_SOLVER_KIND,\n    CXX_FUZZING_SOLVER_KIND,\n    LAST_FUZZING_SOLVER_KIND // This is a dummy entry\n  };\n\nprivate:\n  const SolverOptionKind kind;\n\nprotected:\n  SolverOptions(SolverOptionKind kind) : kind(kind) {}\n\npublic:\n  SolverOptions() : SolverOptions(SOLVER_OPTIONS_KIND) {}\n  virtual ~SolverOptions() {}\n  SolverOptionKind getKind() const { return kind; }\n  static bool classof(const SolverOptions* so) {\n    return so->getKind() == SOLVER_OPTIONS_KIND;\n  }\n  // END: LLVM RTTI boilerplate code\n  // Options common to all solvers\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Core/ToolErrorHandler.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_TOOL_ERROR_HANDLER_H\n#define JFS_CORE_TOOL_ERROR_HANDLER_H\n#include \"jfs/Core/JFSContext.h\"\n\nnamespace jfs {\nnamespace core {\n\nclass ToolErrorHandler : public JFSContextErrorHandler {\nprivate:\n  bool ignoreCanceled;\n\npublic:\n  ToolErrorHandler(bool ignoreCanceled) : ignoreCanceled(ignoreCanceled) {}\n\n  JFSContextErrorHandler::ErrorAction handleZ3error(JFSContext& ctx,\n                                                    Z3_error_code ec) override;\n  ErrorAction handleFatalError(JFSContext& ctx, llvm::StringRef msg) override;\n  ErrorAction handleGenericError(JFSContext& ctx, llvm::StringRef msg) override;\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Core/Z3ASTCmp.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_Z3_AST_CMP\n#define JFS_CORE_Z3_AST_CMP\n#include \"jfs/Core/Z3Node.h\"\n#include <z3.h>\n\nnamespace jfs {\nnamespace core {\nstruct Z3ASTHashGet {\n  size_t operator()(const Z3ASTHandle& h) const {\n    return ::Z3_get_ast_hash(h.getContext(), h);\n  }\n};\n\nstruct Z3ASTCmp {\n  bool operator()(const Z3ASTHandle& a, const Z3ASTHandle b) const {\n    assert(a.getContext() == b.getContext() && \"Contexts must be equal\");\n    return ::Z3_is_eq_ast(a.getContext(), a, b);\n  }\n};\n\nstruct Z3SortHashGet {\n  size_t operator()(const Z3SortHandle& h) const {\n    return ::Z3_get_ast_hash(h.getContext(), h.asAST());\n  }\n};\n\nstruct Z3SortCmp {\n  bool operator()(const Z3SortHandle& a, const Z3SortHandle b) const {\n    assert(a.getContext() == b.getContext() && \"Contexts must be equal\");\n    return ::Z3_is_eq_ast(a.getContext(), a.asAST(), b.asAST());\n  }\n};\n\nstruct Z3FuncDeclHashGet {\n  size_t operator()(const Z3FuncDeclHandle& h) const {\n    return ::Z3_get_ast_hash(h.getContext(),\n                             ::Z3_func_decl_to_ast(h.getContext(), h));\n  }\n};\n\nstruct Z3FuncDeclCmp {\n  bool operator()(const Z3FuncDeclHandle& a, const Z3FuncDeclHandle b) const {\n    assert(a.getContext() == b.getContext() && \"Contexts must be equal\");\n    return ::Z3_is_eq_ast(a.getContext(),\n                          ::Z3_func_decl_to_ast(a.getContext(), a),\n                          ::Z3_func_decl_to_ast(b.getContext(), b));\n  }\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Core/Z3ASTVisitor.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_Z3_AST_VISITOR_H\n#define JFS_CORE_Z3_AST_VISITOR_H\n#include \"jfs/Core/Z3Node.h\"\n\nnamespace jfs {\nnamespace core {\n\n// FIXME: This design only works for\n// read only traversal. It needs rethinking\n// for Z3AST modification and traversal order\nclass Z3ASTVisitor {\npublic:\n  Z3ASTVisitor();\n  virtual ~Z3ASTVisitor();\n  void visit(Z3ASTHandle e);\n\nprotected:\n  // TODO: Add more methods for different Z3 application kinds\n\n  // Uninterpreted function\n  virtual void visitUninterpretedFunc(Z3AppHandle e) = 0;\n\n  // Constants\n  virtual void visitBoolConstant(Z3AppHandle e) = 0;\n  virtual void visitBitVector(Z3AppHandle e) = 0;\n  virtual void visitFloatingPointConstant(Z3AppHandle e) = 0;\n\n  // Overloaded operations\n  virtual void visitEqual(Z3AppHandle e) = 0;\n  virtual void visitDistinct(Z3AppHandle e) = 0;\n  virtual void visitIfThenElse(Z3AppHandle e) = 0;\n  virtual void visitImplies(Z3AppHandle e) = 0;\n  // This isn't part of the core SMT-LIBv2 theory. Is this a Z3 extension?\n  virtual void visitIff(Z3AppHandle e) = 0;\n\n  // Boolean operations\n  virtual void visitAnd(Z3AppHandle e) = 0;\n  virtual void visitOr(Z3AppHandle e) = 0;\n  virtual void visitXor(Z3AppHandle e) = 0;\n  virtual void visitNot(Z3AppHandle e) = 0;\n\n  // Arithmetic BitVector operations\n  virtual void visitBvNeg(Z3AppHandle e) = 0;\n  virtual void visitBvAdd(Z3AppHandle e) = 0;\n  virtual void visitBvSub(Z3AppHandle e) = 0;\n  virtual void visitBvMul(Z3AppHandle e) = 0;\n  virtual void visitBvSDiv(Z3AppHandle e) = 0;\n  virtual void visitBvUDiv(Z3AppHandle e) = 0;\n  virtual void visitBvSRem(Z3AppHandle e) = 0;\n  virtual void visitBvURem(Z3AppHandle e) = 0;\n  virtual void visitBvSMod(Z3AppHandle e) = 0;\n\n  // Comparison BitVector operations\n  virtual void visitBvULE(Z3AppHandle e) = 0;\n  virtual void visitBvSLE(Z3AppHandle e) = 0;\n  virtual void visitBvUGE(Z3AppHandle e) = 0;\n  virtual void visitBvSGE(Z3AppHandle e) = 0;\n  virtual void visitBvULT(Z3AppHandle e) = 0;\n  virtual void visitBvSLT(Z3AppHandle e) = 0;\n  virtual void visitBvUGT(Z3AppHandle e) = 0;\n  virtual void visitBvSGT(Z3AppHandle e) = 0;\n  virtual void visitBvComp(Z3AppHandle e) = 0;\n\n  // Bitwise BitVector operations\n  virtual void visitBvAnd(Z3AppHandle e) = 0;\n  virtual void visitBvOr(Z3AppHandle e) = 0;\n  virtual void visitBvNot(Z3AppHandle e) = 0;\n  virtual void visitBvXor(Z3AppHandle e) = 0;\n  virtual void visitBvNand(Z3AppHandle e) = 0;\n  virtual void visitBvNor(Z3AppHandle e) = 0;\n  virtual void visitBvXnor(Z3AppHandle e) = 0;\n\n  // Shift and rotation BitVector operations\n  virtual void visitBvShl(Z3AppHandle e) = 0;\n  virtual void visitBvLShr(Z3AppHandle e) = 0;\n  virtual void visitBvAShr(Z3AppHandle e) = 0;\n  virtual void visitBvRotateLeft(Z3AppHandle e) = 0;\n  virtual void visitBvRotateRight(Z3AppHandle e) = 0;\n\n  // Sort changing BitVector operations\n  virtual void visitBvConcat(Z3AppHandle e) = 0;\n  virtual void visitBvSignExtend(Z3AppHandle e) = 0;\n  virtual void visitBvZeroExtend(Z3AppHandle e) = 0;\n  virtual void visitBvExtract(Z3AppHandle e) = 0;\n\n  // Floating point operations\n  virtual void visitFloatingPointFromTriple(Z3AppHandle e) = 0;\n  virtual void visitFloatingPointFromIEEEBitVector(Z3AppHandle e) = 0;\n  virtual void visitFloatIsNaN(Z3AppHandle e) = 0;\n  virtual void visitFloatIsNormal(Z3AppHandle e) = 0;\n  virtual void visitFloatIsSubnormal(Z3AppHandle e) = 0;\n  virtual void visitFloatIsZero(Z3AppHandle e) = 0;\n  virtual void visitFloatIsPositive(Z3AppHandle e) = 0;\n  virtual void visitFloatIsNegative(Z3AppHandle e) = 0;\n  virtual void visitFloatIsInfinite(Z3AppHandle e) = 0;\n\n  virtual void visitFloatIEEEEquals(Z3AppHandle e) = 0;\n  virtual void visitFloatLessThan(Z3AppHandle e) = 0;\n  virtual void visitFloatLessThanOrEqual(Z3AppHandle e) = 0;\n  virtual void visitFloatGreaterThan(Z3AppHandle e) = 0;\n  virtual void visitFloatGreaterThanOrEqual(Z3AppHandle e) = 0;\n\n  virtual void visitFloatPositiveZero(Z3AppHandle e) = 0;\n  virtual void visitFloatNegativeZero(Z3AppHandle e) = 0;\n  virtual void visitFloatPositiveInfinity(Z3AppHandle e) = 0;\n  virtual void visitFloatNegativeInfinity(Z3AppHandle e) = 0;\n  virtual void visitFloatNaN(Z3AppHandle e) = 0;\n\n  virtual void visitFloatAbs(Z3AppHandle e) = 0;\n  virtual void visitFloatNeg(Z3AppHandle e) = 0;\n  virtual void visitFloatMin(Z3AppHandle e) = 0;\n  virtual void visitFloatMax(Z3AppHandle e) = 0;\n  virtual void visitFloatAdd(Z3AppHandle e) = 0;\n  virtual void visitFloatSub(Z3AppHandle e) = 0;\n  virtual void visitFloatMul(Z3AppHandle e) = 0;\n  virtual void visitFloatDiv(Z3AppHandle e) = 0;\n  virtual void visitFloatFMA(Z3AppHandle e) = 0;\n  virtual void visitFloatSqrt(Z3AppHandle e) = 0;\n  virtual void visitFloatRem(Z3AppHandle e) = 0;\n  virtual void visitFloatRoundToIntegral(Z3AppHandle e) = 0;\n  virtual void visitConvertToFloatFromFloat(Z3AppHandle e) = 0;\n  virtual void visitConvertToFloatFromUnsignedBitVector(Z3AppHandle e) = 0;\n  virtual void visitConvertToFloatFromSignedBitVector(Z3AppHandle e) = 0;\n  virtual void visitConvertToUnsignedBitVectorFromFloat(Z3AppHandle e) = 0;\n  virtual void visitConvertToSignedBitVectorFromFloat(Z3AppHandle e) = 0;\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Core/Z3Node.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_Z3NODE_H\n#define JFS_CORE_Z3NODE_H\n#include \"z3.h\"\n#include <assert.h>\n#include <string>\n#include <vector>\n\nnamespace jfs {\nnamespace core {\n\ntemplate <typename T> class Z3NodeHandle {\n  // Internally these Z3 types are pointers\n  // so storing these should be cheap.\n  // It would be nice if we could infer the Z3_context from the node\n  // but I can't see a way to do this from Z3's API.\nprotected:\n  T node;\n  ::Z3_context context;\n\nprivate:\n  // To be specialised\n  inline void inc_ref(T node);\n  inline void dec_ref(T node);\n\npublic:\n  Z3NodeHandle() : node(NULL), context(NULL) {}\n  Z3NodeHandle(const T _node, const ::Z3_context _context)\n      : node(_node), context(_context) {\n    if (node && context) {\n      inc_ref(node);\n    }\n  };\n  ~Z3NodeHandle() {\n    if (node && context) {\n      dec_ref(node);\n    }\n  }\n  Z3NodeHandle(const Z3NodeHandle& b) : node(b.node), context(b.context) {\n    if (node && context) {\n      inc_ref(node);\n    }\n  }\n  Z3NodeHandle& operator=(const Z3NodeHandle& b) {\n    if (node == NULL && context == NULL) {\n      // Special case for when this object was constructed\n      // using the default constructor. Try to inherit a non null\n      // context.\n      context = b.context;\n    }\n    assert(context == b.context && \"Mismatched Z3 contexts!\");\n    // node != nullptr ==> context != NULL\n    assert((node == NULL || context) &&\n           \"Can't have non nullptr node with nullptr context\");\n\n    if (node && context) {\n      dec_ref(node);\n    }\n    node = b.node;\n    if (node && context) {\n      inc_ref(node);\n    }\n    return *this;\n  }\n  // To be specialised\n  void dump() const;\n  std::string toStr() const;\n\n  operator T() const { return node; }\n\n  Z3_context getContext() const { return context; }\n  bool isNull() const { return node == nullptr; }\n};\n\n// Instantiate templates\n\n// Specialise for Z3_sort\ntemplate <> inline void Z3NodeHandle<Z3_sort>::inc_ref(Z3_sort node) {\n  // In Z3 internally this call is just a cast. We could just do that\n  // instead to simplify our implementation but this seems cleaner.\n  ::Z3_inc_ref(context, ::Z3_sort_to_ast(context, node));\n}\ntemplate <> inline void Z3NodeHandle<Z3_sort>::dec_ref(Z3_sort node) {\n  // In Z3 internally this call is just a cast. We could just do that\n  // instead to simplify our implementation but this seems cleaner.\n  ::Z3_dec_ref(context, ::Z3_sort_to_ast(context, node));\n}\ntemplate <> void Z3NodeHandle<Z3_sort>::dump() const __attribute__((used));\ntemplate <>\nstd::string Z3NodeHandle<Z3_sort>::toStr() const __attribute__((used));\n\nclass Z3ASTHandle;\n\nclass Z3SortHandle : public Z3NodeHandle<Z3_sort> {\npublic:\n  // Inherit constructors\n  using Z3NodeHandle<Z3_sort>::Z3NodeHandle;\n  // Helper methods\n  Z3_sort_kind getKind() const;\n  bool isBoolTy() const;\n  bool isBitVectorTy() const;\n  bool isFloatingPointTy() const;\n  // Return 0 if not bitvector, floating point, or bool\n  unsigned getWidth() const;\n  // Return 0 if not a bitvector\n  unsigned getBitVectorWidth() const;\n  // Return 0 if not floating point\n  unsigned getFloatingPointBitWidth() const;\n  unsigned getFloatingPointExponentBitWidth() const;\n  unsigned getFloatingPointSignificandBitWidth() const; // Includes implicit bit\n  Z3ASTHandle asAST() const;\n\n  static Z3SortHandle getBoolTy(Z3_context ctx);\n  static Z3SortHandle getBitVectorTy(Z3_context, unsigned bitWidth);\n  static Z3SortHandle getFloat32Ty(Z3_context ctx);\n  static Z3SortHandle getFloat64Ty(Z3_context ctx);\n};\n\n// Specialise for Z3_ast\ntemplate <> inline void Z3NodeHandle<Z3_ast>::inc_ref(Z3_ast node) {\n  ::Z3_inc_ref(context, node);\n}\ntemplate <> inline void Z3NodeHandle<Z3_ast>::dec_ref(Z3_ast node) {\n  ::Z3_dec_ref(context, node);\n}\ntemplate <> void Z3NodeHandle<Z3_ast>::dump() const __attribute__((used));\ntemplate <>\nstd::string Z3NodeHandle<Z3_ast>::toStr() const __attribute__((used));\n\nclass Z3AppHandle;\nclass Z3FuncDeclHandle;\n\n// Provide a class rather than a typedef so we can add\n// additional helper methods.\nclass Z3ASTHandle : public Z3NodeHandle<Z3_ast> {\npublic:\n  // Inherit constructors\n  using Z3NodeHandle<Z3_ast>::Z3NodeHandle;\n\n  // Helper methods\n  Z3_ast_kind getKind() const;\n  bool isApp() const;\n  bool isFuncDecl() const;\n  bool isSort() const;\n  bool isNumeral() const;\n\n  bool isTrue() const;\n  bool isFalse() const;\n  bool isConstant() const;\n  // FIXME: Should be renamed isAppOfFreeVariable\n  bool isFreeVariable() const;\n  bool isAppOf(Z3_decl_kind) const;\n  bool isStructurallyEqualTo(Z3ASTHandle other) const;\n  Z3SortHandle getSort() const;\n\n  Z3AppHandle asApp() const;\n  Z3FuncDeclHandle asFuncDecl() const;\n\n  static Z3ASTHandle getTrue(Z3_context ctx);\n  static Z3ASTHandle getFalse(Z3_context ctx);\n  static Z3ASTHandle getBVZero(Z3_context, unsigned width);\n  static Z3ASTHandle getBVZero(Z3SortHandle sort);\n  static Z3ASTHandle getBV(Z3SortHandle sort, uint64_t value);\n  static Z3ASTHandle getFloatAbsoluteSmallestSubnormal(Z3SortHandle sort,\n                                                       bool positive);\n  static Z3ASTHandle getFloatAbsoluteLargestSubnormal(Z3SortHandle sort,\n                                                      bool positive);\n  static Z3ASTHandle getFloatAbsoluteSmallestNormal(Z3SortHandle sort,\n                                                    bool positive);\n  static Z3ASTHandle getFloatAbsoluteLargestNormal(Z3SortHandle sort,\n                                                   bool positive);\n  static Z3ASTHandle getFloatZero(Z3SortHandle sort, bool positive = true);\n  static Z3ASTHandle getFloatInfinity(Z3SortHandle sort, bool positive = true);\n  static Z3ASTHandle getFloatNAN(Z3SortHandle sort);\n  static Z3ASTHandle getFloatFromInt(Z3SortHandle sort, signed value);\n};\n\n// Specialise for Z3_app\ntemplate <> inline void Z3NodeHandle<Z3_app>::inc_ref(Z3_app node) {\n  ::Z3_inc_ref(context, ::Z3_app_to_ast(context, node));\n}\ntemplate <> inline void Z3NodeHandle<Z3_app>::dec_ref(Z3_app node) {\n  ::Z3_dec_ref(context, ::Z3_app_to_ast(context, node));\n}\ntemplate <> void Z3NodeHandle<Z3_app>::dump() const __attribute__((used));\ntemplate <>\nstd::string Z3NodeHandle<Z3_app>::toStr() const __attribute__((used));\n\n// FIXME: It's silly that Z3AppHandle does not inherit from Z3ASTHandle\n// to reflect the hierarchy in Z3.\n// Provide a class rather than a typedef so we can add\n// additional helper methods.\nclass Z3AppHandle : public Z3NodeHandle<Z3_app> {\npublic:\n  // Inherit constructors\n  using Z3NodeHandle<Z3_app>::Z3NodeHandle;\n\n  // Helper methods\n  Z3FuncDeclHandle getFuncDecl() const;\n  Z3_decl_kind getKind() const;\n  unsigned getNumKids() const;\n  Z3ASTHandle getKid(unsigned) const;\n\n  bool isConstant() const;\n  // FIXME: Should be renamed isAppOfFreeVariable\n  bool isFreeVariable() const;\n  bool isSpecialFPConstant() const;\n  Z3ASTHandle asAST() const;\n  Z3SortHandle getSort() const;\n\n  bool getConstantAsUInt64(uint64_t* out) const;\n};\n\n// Specialise for Z3_func_decl\ntemplate <> inline void Z3NodeHandle<Z3_func_decl>::inc_ref(Z3_func_decl node) {\n  ::Z3_inc_ref(context, ::Z3_func_decl_to_ast(context, node));\n}\ntemplate <> inline void Z3NodeHandle<Z3_func_decl>::dec_ref(Z3_func_decl node) {\n  ::Z3_dec_ref(context, ::Z3_func_decl_to_ast(context, node));\n}\ntemplate <> void Z3NodeHandle<Z3_func_decl>::dump() const __attribute__((used));\ntemplate <>\nstd::string Z3NodeHandle<Z3_func_decl>::toStr() const __attribute__((used));\n\n// FIXME: It's silly that Z3FuncDeclHandle does not inherit from Z3ASTHandle\n// to reflect the hierarchy in Z3.\n// Provide a class rather than a typedef so we can add\n// additional helper methods.\nclass Z3FuncDeclHandle : public Z3NodeHandle<Z3_func_decl> {\n  // Inherit constructors\npublic:\n  using Z3NodeHandle<Z3_func_decl>::Z3NodeHandle;\n  Z3_decl_kind getKind() const;\n  Z3SortHandle getSort() const;\n  std::string getName() const;\n  Z3ASTHandle asAST() const;\n\n  // Parameters\n  unsigned getNumParams() const;\n  Z3_parameter_kind getParamKind(unsigned index) const;\n  int getIntParam(unsigned index) const;\n};\n\n// Specialise for Z3_solver\ntemplate <> inline void Z3NodeHandle<Z3_solver>::inc_ref(Z3_solver node) {\n  ::Z3_solver_inc_ref(context, node);\n}\ntemplate <> inline void Z3NodeHandle<Z3_solver>::dec_ref(Z3_solver node) {\n  ::Z3_solver_dec_ref(context, node);\n}\ntypedef Z3NodeHandle<Z3_solver> Z3SolverHandle;\ntemplate <> void Z3NodeHandle<Z3_solver>::dump() const __attribute__((used));\ntemplate <>\nstd::string Z3NodeHandle<Z3_solver>::toStr() const __attribute__((used));\n\n// Specialise for Z3_params\ntemplate <> inline void Z3NodeHandle<Z3_params>::inc_ref(Z3_params node) {\n  ::Z3_params_inc_ref(context, node);\n}\ntemplate <> inline void Z3NodeHandle<Z3_params>::dec_ref(Z3_params node) {\n  ::Z3_params_dec_ref(context, node);\n}\ntypedef Z3NodeHandle<Z3_params> Z3ParamsHandle;\ntemplate <> void Z3NodeHandle<Z3_params>::dump() const __attribute__((used));\ntemplate <>\nstd::string Z3NodeHandle<Z3_params>::toStr() const __attribute__((used));\n\n// Specialise for Z3_model\ntemplate <> inline void Z3NodeHandle<Z3_model>::inc_ref(Z3_model node) {\n  ::Z3_model_inc_ref(context, node);\n}\ntemplate <> inline void Z3NodeHandle<Z3_model>::dec_ref(Z3_model node) {\n  ::Z3_model_dec_ref(context, node);\n}\ntemplate <> void Z3NodeHandle<Z3_model>::dump() const __attribute__((used));\ntemplate <>\nstd::string Z3NodeHandle<Z3_model>::toStr() const __attribute__((used));\n\nclass Z3ModelHandle : public Z3NodeHandle<Z3_model> {\n  // Inherit constructors\npublic:\n  using Z3NodeHandle<Z3_model>::Z3NodeHandle;\n  Z3ASTHandle getAssignmentFor(Z3FuncDeclHandle);\n  bool hasAssignmentFor(Z3FuncDeclHandle d) const;\n  bool addAssignmentFor(Z3FuncDeclHandle decl, Z3ASTHandle e,\n                        bool allowOverwrite = false);\n  uint64_t getNumAssignments() const;\n  Z3FuncDeclHandle getVariableDeclForIndex(uint64_t index);\n  Z3ASTHandle evaluate(Z3ASTHandle e, bool modelCompletion);\n  bool isEmpty() const;\n};\n\n// Specialise for Z3_goal\ntemplate <> inline void Z3NodeHandle<Z3_goal>::inc_ref(Z3_goal node) {\n  ::Z3_goal_inc_ref(context, node);\n}\ntemplate <> inline void Z3NodeHandle<Z3_goal>::dec_ref(Z3_goal node) {\n  ::Z3_goal_dec_ref(context, node);\n}\ntemplate <> void Z3NodeHandle<Z3_goal>::dump() const __attribute__((used));\ntemplate <>\nstd::string Z3NodeHandle<Z3_goal>::toStr() const __attribute__((used));\n\nclass Z3GoalHandle : public Z3NodeHandle<Z3_goal> {\n  // Inherit constructors\npublic:\n  using Z3NodeHandle<Z3_goal>::Z3NodeHandle;\n  void addFormula(Z3ASTHandle);\n  unsigned getNumFormulas() const;\n  Z3ASTHandle getFormula(unsigned index) const;\n};\n\nclass Z3ApplyResultHandle;\n\n// Specialise for Z3_tactic\ntemplate <> inline void Z3NodeHandle<Z3_tactic>::inc_ref(Z3_tactic node) {\n  ::Z3_tactic_inc_ref(context, node);\n}\ntemplate <> inline void Z3NodeHandle<Z3_tactic>::dec_ref(Z3_tactic node) {\n  ::Z3_tactic_dec_ref(context, node);\n}\ntemplate <> void Z3NodeHandle<Z3_tactic>::dump() const __attribute__((used));\ntemplate <>\nstd::string Z3NodeHandle<Z3_tactic>::toStr() const __attribute__((used));\n\nclass Z3TacticHandle : public Z3NodeHandle<Z3_tactic> {\n  // Inherit constructors\npublic:\n  using Z3NodeHandle<Z3_tactic>::Z3NodeHandle;\n  Z3ApplyResultHandle apply(Z3GoalHandle goal);\n  Z3ApplyResultHandle applyWithParams(Z3GoalHandle goal, Z3ParamsHandle params);\n};\n\n// Specialise for Z3_apply_result\ntemplate <>\ninline void Z3NodeHandle<Z3_apply_result>::inc_ref(Z3_apply_result node) {\n  ::Z3_apply_result_inc_ref(context, node);\n}\ntemplate <>\ninline void Z3NodeHandle<Z3_apply_result>::dec_ref(Z3_apply_result node) {\n  ::Z3_apply_result_dec_ref(context, node);\n}\ntemplate <>\nvoid Z3NodeHandle<Z3_apply_result>::dump() const __attribute__((used));\ntemplate <>\nstd::string Z3NodeHandle<Z3_apply_result>::toStr() const __attribute__((used));\n\nclass Z3ApplyResultHandle : public Z3NodeHandle<Z3_apply_result> {\n  // Inherit constructors\npublic:\n  using Z3NodeHandle<Z3_apply_result>::Z3NodeHandle;\n  unsigned getNumGoals() const;\n  Z3GoalHandle getGoal(unsigned index) const;\n  void collectAllFormulas(std::vector<Z3ASTHandle>&) const;\n  Z3ModelHandle convertModelForGoal(unsigned index, Z3ModelHandle toConvert);\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Core/Z3NodeMap.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_Z3_NODE_MAP_H\n#define JFS_CORE_Z3_NODE_MAP_H\n#include \"jfs/Core/Z3ASTCmp.h\"\n#include <unordered_map>\n\nnamespace jfs {\nnamespace core {\n\ntemplate <typename T>\nusing Z3ASTMap = std::unordered_map<Z3ASTHandle, T, Z3ASTHashGet, Z3ASTCmp>;\n\ntemplate <typename T>\nusing Z3SortMap = std::unordered_map<Z3SortHandle, T, Z3SortHashGet, Z3SortCmp>;\n\ntemplate <typename T>\nusing Z3FuncDeclMap =\n    std::unordered_map<Z3FuncDeclHandle, T, Z3FuncDeclHashGet, Z3FuncDeclCmp>;\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Core/Z3NodeSet.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_Z3_AST_SET_H\n#define JFS_CORE_Z3_AST_SET_H\n#include \"jfs/Core/Z3ASTCmp.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include <assert.h>\n#include <unordered_set>\n\nnamespace jfs {\nnamespace core {\n\n// We don't provide a templated Z3NodeSet because not all Z3Node's are ASTs.\n// For now doing these aliases is simpler.\nusing Z3ASTSet = std::unordered_set<Z3ASTHandle, Z3ASTHashGet, Z3ASTCmp>;\n\nusing Z3FuncDeclSet =\n    std::unordered_set<Z3FuncDeclHandle, Z3FuncDeclHashGet, Z3FuncDeclCmp>;\n\nusing Z3SortSet = std::unordered_set<Z3SortHandle, Z3SortHashGet, Z3SortCmp>;\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Core/Z3NodeUtil.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Alastair Donaldson\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CORE_Z3NODE_UTIL_H\n#define JFS_CORE_Z3NODE_UTIL_H\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include <list>\n\nnamespace jfs {\nnamespace core {\n\nclass Z3NodeUtil {\npublic:\n  static void collectFuncDecls(Z3FuncDeclSet& addTo,\n                               std::list<Z3ASTHandle>& workList);\n\n  static void collectFuncDecls(Z3FuncDeclSet& addTo, Z3ASTHandle e);\n\n  template <typename IteratorTy>\n  static void collectFuncDecls(Z3FuncDeclSet& addTo, IteratorTy begin,\n                               IteratorTy end) {\n    std::list<Z3ASTHandle> workList;\n    for (IteratorTy b = begin, e = end; b != e; ++b) {\n      workList.push_back(*b);\n    }\n    collectFuncDecls(addTo, workList);\n  }\n};\n\n} // namespace core\n} // namespace jfs\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/BufferAssignment.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_BUFFER_ASSIGNMENT\n#define JFS_FUZZING_COMMON_BUFFER_ASSIGNMENT\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/Core/Z3NodeMap.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include \"jfs/FuzzingCommon/BufferElement.h\"\n#include <vector>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nclass BufferAssignment {\nprivate:\n  typedef std::vector<BufferElement> ChunksTy;\n  ChunksTy chunks;\n  uint64_t cachedTypeBitWidth;\n  uint64_t cachedStoreBitWidth;\n  uint64_t computeTypeBitWidth() const;\n  uint64_t computeStoreBitWidth() const;\n\npublic:\n  BufferAssignment() : cachedTypeBitWidth(0), cachedStoreBitWidth(0) {}\n  ~BufferAssignment() {}\n  void appendElement(BufferElement&);\n  uint64_t getTypeBitWidth() const { return cachedTypeBitWidth; }\n  uint64_t getStoreBitWidth() const { return cachedStoreBitWidth; }\n  uint64_t getRequiredStoreBytes() const {\n    return (getStoreBitWidth() + 7) / 8;\n  }\n  ChunksTy::const_iterator cbegin() const { return chunks.begin(); }\n  ChunksTy::const_iterator cend() const { return chunks.end(); }\n  ChunksTy::const_iterator begin() const { return cbegin(); }\n  ChunksTy::const_iterator end() const { return cend(); }\n  size_t size() const { return chunks.size(); }\n  void print(llvm::raw_ostream&) const;\n  void dump() const;\n};\n\n} // namespace fuzzingCommon\n} // namespace jfs\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/BufferElement.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_BUFFER_ELEMENT\n#define JFS_FUZZING_COMMON_BUFFER_ELEMENT\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/Core/Z3NodeMap.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include <vector>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nclass BufferElement {\nprivate:\n  size_t storeBitAlignment;\n\npublic:\n  const jfs::core::Z3ASTHandle declApp;\n  BufferElement(const jfs::core::Z3ASTHandle declApp,\n                size_t storeBitAlignment = 1);\n  unsigned getTypeBitWidth() const;  // Does not include padding\n  unsigned getStoreBitWidth() const; // Includes any required padding\n  size_t getStoreBitAlignment() const { return storeBitAlignment; }\n  // FIXME: put this behind an interface once we know the requirements\n  std::vector<jfs::core::Z3ASTHandle> equalities;\n  void print(llvm::raw_ostream&) const;\n  void dump() const;\n  jfs::core::Z3FuncDeclHandle getDecl() const;\n  std::string getName() const;\n  jfs::core::Z3SortHandle getSort() const;\n};\n\n} // namespace fuzzingCommon\n} // namespace jfs\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/CmdLine/FreeVariableToBufferAssignmentPassOptionsBuilder.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_CMDLINE_FVTBAPOB_H\n#define JFS_FUZZING_COMMON_CMDLINE_FVTBAPOB_H\n#include \"jfs/FuzzingCommon/FreeVariableToBufferAssignmentPassOptions.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace fuzzingCommon {\nnamespace cl {\n\nstd::unique_ptr<jfs::fuzzingCommon::FreeVariableToBufferAssignmentPassOptions>\nbuildFVTBAPOptionsFromCmdLine();\n}\n} // namespace fuzzingCommon\n} // namespace jfs\n\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/CmdLine/LibFuzzerOptionsBuilder.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_CMDLINE_LIBFUZZER_OPTIONS_BUILDER_H\n#define JFS_FUZZING_COMMON_CMDLINE_LIBFUZZER_OPTIONS_BUILDER_H\n#include \"jfs/FuzzingCommon/LibFuzzerOptions.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace fuzzingCommon {\nnamespace cl {\n\nstd::unique_ptr<jfs::fuzzingCommon::LibFuzzerOptions>\nbuildLibFuzzerOptionsFromCmdLine();\n}\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/CmdLine/SeedManagerOptionsBuilder.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_CMDLINE_SEED_MANAGER_OPTIONS_BUILDER_H\n#define JFS_FUZZING_COMMON_CMDLINE_SEED_MANAGER_OPTIONS_BUILDER_H\n#include \"jfs/FuzzingCommon/SeedManager.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace fuzzingCommon {\nnamespace cl {\n\nstd::unique_ptr<jfs::fuzzingCommon::SeedManagerOptions>\nbuildSeedManagerOptionsFromCmdLine();\n}\n} // namespace fuzzingCommon\n} // namespace jfs\n\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/CommandLineCategory.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_COMMAND_LINE_CATEGORY_H\n#define JFS_FUZZING_COMMON_COMMAND_LINE_CATEGORY_H\n#include \"llvm/Support/CommandLine.h\"\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nextern llvm::cl::OptionCategory CommandLineCategory;\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/DummyFuzzingSolver.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_DUMMY_FUZZING_SOLVER\n#define JFS_FUZZING_COMMON_DUMMY_FUZZING_SOLVER\n#include \"jfs/FuzzingCommon/FuzzingSolver.h\"\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\n// This solver doesn't do any fuzzing so in effect\n// it can only solve trivial constraints\nclass DummyFuzzingSolver : public FuzzingSolver {\nprotected:\n  std::unique_ptr<jfs::core::SolverResponse>\n  fuzz(jfs::core::Query& q, bool produceModel,\n       std::shared_ptr<FuzzingAnalysisInfo> info) override;\n\npublic:\n  DummyFuzzingSolver(std::unique_ptr<jfs::core::SolverOptions> options,\n                     std::unique_ptr<WorkingDirectoryManager> wdm,\n                     jfs::core::JFSContext& ctx);\n  ~DummyFuzzingSolver();\n  llvm::StringRef getName() const override;\n  void cancel() override;\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/EqualityExtractionPass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_EQUALITY_EXTRACTION_PASS_H\n#define JFS_FUZZING_COMMON_EQUALITY_EXTRACTION_PASS_H\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/Core/Z3NodeMap.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include \"jfs/Transform/QueryPass.h\"\n#include <vector>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\n// This pass looks for simple equalities (e.g. `(= a b)`), removes them from\n// the query and adds them to the known set of equalites. The motivation is\n// that the fuzzer is very unlikely to guess at random to make two expressions\n// equal. Instead of enforcing them as branch conditions we can construct the\n// input program such the equality always holds in some simple cases.\nclass EqualityExtractionPass : public jfs::transform::QueryPass {\nprivate:\n  void cleanUp();\n\npublic:\n  // TODO: Put this behind an interface once we know what the requirements\n  // are.\n  jfs::core::Z3ASTMap<std::shared_ptr<jfs::core::Z3ASTSet>> mapping;\n  std::unordered_set<std::shared_ptr<jfs::core::Z3ASTSet>> equalities;\n  EqualityExtractionPass();\n  ~EqualityExtractionPass() {}\n  bool run(jfs::core::Query& q) override;\n  virtual llvm::StringRef getName() override;\n  virtual bool convertModel(jfs::core::Model* m) override;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/FileSerializableModel.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Alastair Donaldson\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_FILE_SERIALIZABLE_MODEL_H\n#define JFS_FUZZING_COMMON_FILE_SERIALIZABLE_MODEL_H\n#include \"jfs/Core/Model.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/FuzzingCommon/BufferAssignment.h\"\n#include \"llvm/Support/FileOutputBuffer.h\"\n#include \"llvm/Support/MemoryBuffer.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nclass FileSerializableModel : public jfs::core::Model {\npublic:\n  // Empty model\n  FileSerializableModel(jfs::core::JFSContext& ctx);\n\n  static std::unique_ptr<FileSerializableModel>\n  loadFrom(const llvm::MemoryBuffer* buf, const BufferAssignment* ba,\n           jfs::core::JFSContext& ctx);\n\n  bool saveTo(llvm::FileOutputBuffer* buf, const BufferAssignment* ba,\n              jfs::core::JFSContext& ctx);\n};\n\n} // namespace fuzzingCommon\n} // namespace jfs\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/FreeVariableToBufferAssignmentPass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_FREE_VARIABLE_TO_BUFFER_ASSIGNMENT_PASS_H\n#define JFS_FUZZING_COMMON_FREE_VARIABLE_TO_BUFFER_ASSIGNMENT_PASS_H\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/Core/Z3NodeMap.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include \"jfs/FuzzingCommon/BufferAssignment.h\"\n#include \"jfs/FuzzingCommon/EqualityExtractionPass.h\"\n#include \"jfs/FuzzingCommon/FreeVariableToBufferAssignmentPassOptions.h\"\n#include \"jfs/Transform/QueryPass.h\"\n#include <vector>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nclass ConstantAssignment {\npublic:\n  // TODO: Put this behind an interface\n  jfs::core::Z3ASTMap<jfs::core::Z3ASTHandle> assignments;\n  void print(llvm::raw_ostream&) const;\n  void dump() const;\n};\n\nclass FreeVariableToBufferAssignmentPass : public jfs::transform::QueryPass {\nprivate:\n  const EqualityExtractionPass& eep;\n  // raw ptr because we don't own storage\n  FreeVariableToBufferAssignmentPassOptions* options;\n  std::unique_ptr<FreeVariableToBufferAssignmentPassOptions> defaultOptions;\n\npublic:\n  FreeVariableToBufferAssignmentPass(\n      const EqualityExtractionPass&,\n      FreeVariableToBufferAssignmentPassOptions* options);\n  ~FreeVariableToBufferAssignmentPass() {}\n  bool run(jfs::core::Query& q) override;\n  virtual llvm::StringRef getName() override;\n  // TODO: Put these behind an interface\n  std::shared_ptr<BufferAssignment> bufferAssignment;\n  // FIXME: It's debatable whether we actually need this. The\n  // ConstantPropagation pass\n  // means that equalities like this will already be expanded in constraints.\n  // This means\n  // the free variables that have constant assignments will never be used once\n  // the\n  // EqualityExtractionPass has run and so constantAssignment is always empty.\n  std::shared_ptr<ConstantAssignment> constantAssignments;\n\n  virtual bool convertModel(jfs::core::Model* m) override;\n};\n} // namespace fuzzingCommon\n} // namespace jfs\n\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/FreeVariableToBufferAssignmentPassOptions.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_FREE_VARIABLE_TO_BUFFER_ASSIGNMENT_PASS_OPTIONS_H\n#define JFS_FUZZING_COMMON_FREE_VARIABLE_TO_BUFFER_ASSIGNMENT_PASS_OPTIONS_H\n#include <cstddef>\n\nnamespace jfs {\nnamespace fuzzingCommon {\nclass FreeVariableToBufferAssignmentPassOptions {\npublic:\n  enum class FreeVariableSortStrategyTy {\n    ALPHABETICAL,\n    FIRST_OBSERVED,\n    NONE, // Warning: Will likely be non-deterministic\n  };\n  size_t bufferElementBitAlignment = 1;\n  FreeVariableSortStrategyTy sortStrategy =\n      FreeVariableSortStrategyTy::FIRST_OBSERVED;\n  FreeVariableToBufferAssignmentPassOptions();\n};\n} // namespace fuzzingCommon\n} // namespace jfs\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/FuzzingAnalysisInfo.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_FUZZING_ANALYSIS_INFO_H\n#define JFS_FUZZING_COMMON_FUZZING_ANALYSIS_INFO_H\n#include \"jfs/FuzzingCommon/EqualityExtractionPass.h\"\n#include \"jfs/FuzzingCommon/FreeVariableToBufferAssignmentPass.h\"\n#include \"jfs/Transform/QueryPassManager.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\n// This contains the necessary analysis info\n// that a fuzzing solver needs.\nclass FuzzingAnalysisInfo {\npublic:\n  std::shared_ptr<EqualityExtractionPass> equalityExtraction;\n  std::shared_ptr<FreeVariableToBufferAssignmentPass> freeVariableAssignment;\n  void addTo(jfs::transform::QueryPassManager& pm);\n  FuzzingAnalysisInfo(FreeVariableToBufferAssignmentPassOptions* fvtbapOptions);\n  ~FuzzingAnalysisInfo();\n};\n} // namespace fuzzingCommon\n} // namespace jfs\n\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/FuzzingSolver.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_FUZZING_SOLVER_H\n#define JFS_FUZZING_COMMON_FUZZING_SOLVER_H\n#include \"jfs/Core/Solver.h\"\n#include \"jfs/FuzzingCommon/WorkingDirectoryManager.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nclass FuzzingAnalysisInfo;\nclass FuzzingSolverImpl;\nclass FuzzingSolver : public jfs::core::Solver {\nprivate:\n  std::unique_ptr<FuzzingSolverImpl> impl;\n\nprotected:\n  virtual std::unique_ptr<jfs::core::SolverResponse>\n  fuzz(jfs::core::Query& q, bool produceModel,\n       std::shared_ptr<FuzzingAnalysisInfo> info) = 0;\n  std::unique_ptr<WorkingDirectoryManager> wdm;\n\npublic:\n  FuzzingSolver(std::unique_ptr<jfs::core::SolverOptions> options,\n                std::unique_ptr<WorkingDirectoryManager> wdm,\n                jfs::core::JFSContext& ctx);\n  ~FuzzingSolver();\n  std::unique_ptr<jfs::core::SolverResponse> solve(const jfs::core::Query& q,\n                                                   bool produceModel) override;\n  void cancel() override;\n  friend class FuzzingSolverImpl;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/FuzzingSolverOptions.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_FUZZING_SOLVER_OPTIONS_H\n#define JFS_FUZZING_COMMON_FUZZING_SOLVER_OPTIONS_H\n#include \"jfs/Core/SolverOptions.h\"\n#include \"jfs/FuzzingCommon/FreeVariableToBufferAssignmentPassOptions.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace fuzzingCommon {\nclass FuzzingSolverOptions : public jfs::core::SolverOptions {\nprivate:\n  std::unique_ptr<FreeVariableToBufferAssignmentPassOptions> fvtbapOptions;\n\nprotected:\n  // For subclasses\n  FuzzingSolverOptions(\n      std::unique_ptr<FreeVariableToBufferAssignmentPassOptions> fvtbapOptions,\n      bool debugSaveModel,\n      jfs::core::SolverOptions::SolverOptionKind thisKind);\n\npublic:\n  bool debugSaveModel;\n  FuzzingSolverOptions(\n      std::unique_ptr<FreeVariableToBufferAssignmentPassOptions> fvtbapOptions,\n      bool debugSaveModel);\n  static bool classof(const SolverOptions* so) {\n    return so->getKind() >= jfs::core::SolverOptions::FUZZING_SOLVER_KIND &&\n           so->getKind() < jfs::core::SolverOptions::LAST_FUZZING_SOLVER_KIND;\n  }\n  FreeVariableToBufferAssignmentPassOptions*\n  getFreeVariableToBufferAssignmentOptions() const;\n};\n} // namespace fuzzingCommon\n} // namespace jfs\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/JFSRuntimeFuzzingStat.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_JFS_RUNTIME_FUZZING_STAT\n#define JFS_FUZZING_COMMON_JFS_RUNTIME_FUZZING_STAT\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/FuzzingCommon/FuzzingSolver.h\"\n#include \"jfs/Support/JFSStat.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace fuzzingCommon {\nstruct JFSRuntimeFuzzingStat : public jfs::support::JFSStat {\n\n  uint64_t maxNumConstraintsSatisfied;\n  static const char* maxNumConstraintsSatisfiedKeyName;\n\n  uint64_t numberOfInputsTried;\n  static const char* numberOfInputsTriedKeyName;\n\n  uint64_t numberOfWrongSizedInputsTried;\n  static const char* numberOfWrongSizedInputsTriedKeyName;\n\n  JFSRuntimeFuzzingStat(llvm::StringRef name);\n  virtual ~JFSRuntimeFuzzingStat();\n  void printYAML(llvm::ScopedPrinter& os) const override;\n  static bool classof(const JFSStat* s) { return s->getKind() == RUNTIME; }\n  static std::unique_ptr<JFSRuntimeFuzzingStat>\n  LoadFromYAML(llvm::StringRef filePath, llvm::StringRef name,\n               jfs::core::JFSContext& ctx);\n};\n} // namespace fuzzingCommon\n} // namespace jfs\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/LibFuzzerInvocationManager.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_LIBFUZZER_INVOCATION_MANAGER_H\n#define JFS_FUZZING_COMMON_LIBFUZZER_INVOCATION_MANAGER_H\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/FuzzingCommon/LibFuzzerOptions.h\"\n#include \"jfs/Support/ICancellable.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include \"llvm/Support/MemoryBuffer.h\"\n#include <memory>\n#include <string>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nstruct LibFuzzerResponse {\n  enum class ResponseTy {\n    TARGET_FOUND,\n    SINGLE_RUN_TARGET_NOT_FOUND,\n    RUN_BOUND_REACHED,\n    CANCELLED,\n    UNKNOWN,\n  };\n  ResponseTy outcome;\n  std::string pathToInput;\n  LibFuzzerResponse();\n  ~LibFuzzerResponse();\n  // Returns nullptr if outcome was not `TARGET_FOUND`.\n  std::unique_ptr<llvm::MemoryBuffer> getInputForTarget() const;\n};\n\nclass LibFuzzerInvocationManagerImpl;\n\nclass LibFuzzerInvocationManager : public jfs::support::ICancellable {\nprivate:\n  const std::unique_ptr<LibFuzzerInvocationManagerImpl> impl;\n\npublic:\n  LibFuzzerInvocationManager(jfs::core::JFSContext& ctx);\n  ~LibFuzzerInvocationManager();\n  void cancel();\n  std::unique_ptr<LibFuzzerResponse> fuzz(const LibFuzzerOptions* options,\n                                          llvm::StringRef stdOutFile,\n                                          llvm::StringRef stdErrFile);\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/LibFuzzerOptions.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_LIBFUZZER_OPTIONS_H\n#define JFS_FUZZING_COMMON_LIBFUZZER_OPTIONS_H\n#include <stdint.h>\n#include <string>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\n// FIXME: This design is broken. Some of these options are used internally and\n// will get overwritten and others are public and can be changed. We need\n// to separate these two concerns.\nstruct LibFuzzerOptions {\n  // NOTE: `runs` value of `0` means an infinite number of runs.\n  size_t runs; // Approximately corresponds to `-runs=<N>` option.\n  uint64_t mutationDepth; // Corresponds to `-mutate_depth=<N>`\n  bool crossOver;         // Corresponds to `-cross_over` option\n  uint64_t maxLength;     // Corresponds to `-max_len=<N>` option (bytes).\n  bool useCmp;            // Corresponds to `-use_cmp` option\n  bool printFinalStats;   // Corresponds to `-print_final_stats=1`\n  bool reduceInputs;      // Corresponds to `-reduce_inputs=1`\n  bool defaultMutationsResizeInput; // Corresponds to `default_mutators_resize_input=1`\n  bool handleSIGABRT;\n  bool handleSIGBUS;\n  bool handleSIGFPE;\n  bool handleSIGILL;\n  bool handleSIGINT;\n  bool handleSIGSEGV;\n  bool handleSIGTERM;\n  bool handleSIGXFSZ;\n\n  std::string targetBinary;\n  std::string artifactDir;\n  std::string corpusDir;\n  std::string jfsRuntimeLogFile;\n\n  // TODO: We should support LibFuzzer jobs/workers. This\n  // will require a vector of seeds rather than a single seed\n  LibFuzzerOptions();\n};\n} // namespace fuzzingCommon\n} // namespace jfs\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/SeedGenerator.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_SEED_GENERATOR_H\n#define JFS_FUZZING_COMMON_SEED_GENERATOR_H\n#include \"llvm/ADT/StringRef.h\"\n#include <string>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nclass FuzzingAnalysisInfo;\nclass SeedManager;\n\nclass SeedGenerator {\nprivate:\n  std::string name;\n\npublic:\n  SeedGenerator(llvm::StringRef name);\n  virtual ~SeedGenerator();\n  // Called once by the SeedManager before any seeds are requested\n  virtual void preGenerationCallBack(SeedManager& sm);\n  // Called once by the SeedManager after all seeds are requested\n  virtual void postGenerationCallBack(SeedManager& sm);\n  // Returns true on success\n  virtual bool writeSeed(SeedManager& sm) = 0;\n  virtual llvm::StringRef getName() const { return name; }\n  virtual bool empty() const = 0;\n};\n\n// A generator that emits a single seed with all bytes set to\n// the supplied byte value.\nclass AllBytesEqualGenerator : public SeedGenerator {\nprivate:\n  uint8_t byteValue;\n  bool seedWritten;\n\npublic:\n  AllBytesEqualGenerator(llvm::StringRef name, uint8_t byteValue);\n  void preGenerationCallBack(SeedManager& sm) override {}\n  void postGenerationCallBack(SeedManager& sm) override {}\n  bool writeSeed(SeedManager& sm) override;\n  bool empty() const override;\n};\n\n} // namespace fuzzingCommon\n} // namespace jfs\n\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/SeedManager.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_SEED_MANAGER_H\n#define JFS_FUZZING_COMMON_SEED_MANAGER_H\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Support/ICancellable.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include \"llvm/Support/FileOutputBuffer.h\"\n#include <list>\n#include <memory>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nclass SeedGenerator;\nclass SeedManagerImpl;\nclass FuzzingAnalysisInfo;\nclass SeedManagerOptions;\n\nclass SeedManager : jfs::support::ICancellable {\nprivate:\n  std::unique_ptr<SeedManagerImpl> impl;\n\npublic:\n  SeedManager(llvm::StringRef seedDir, jfs::core::JFSContext& ctx);\n  SeedManager(const SeedManager&) = delete;\n  ~SeedManager();\n  void cancel() override;\n  void configureFrom(std::unique_ptr<SeedManagerOptions> options);\n  void addSeedGenerator(std::unique_ptr<SeedGenerator> sg);\n  // Returns number of written seeds.\n  uint64_t writeSeeds(const FuzzingAnalysisInfo* info,\n                      const jfs::core::Query* q);\n\n  void setSpaceLimit(uint64_t maxSeedSpaceInBytes);\n  uint64_t getSpaceLimit() const;\n  void setMaxNumSeeds(uint64_t maxNumSeeds);\n  uint64_t getMaxNumSeeds() const;\n\n  // Create a FileOutputBuffer with the appropriate size and filename for the\n  // seed. The caller is responsible for calling commit.\n  //\n  // This is the preferred method writing a seed\n  std::unique_ptr<llvm::FileOutputBuffer>\n  getBufferForSeed(llvm::StringRef prefix);\n\n  // Get and reserve a seed ID but don't actually create it.\n  std::string getAndReserveSeedID(llvm::StringRef prefix);\n  std::string getAndReserveSeedID();\n\n  jfs::core::JFSContext& getContext() const;\n  const FuzzingAnalysisInfo* getCurrentFuzzingAnalysisInfo() const;\n  const jfs::core::Query* getCurrentQuery() const;\n};\n\n} // namespace fuzzingCommon\n} // namespace jfs\n\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/SeedManagerOptions.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_SEED_MANAGER_OPTIONS_H\n#define JFS_FUZZING_COMMON_SEED_MANAGER_OPTIONS_H\n#include \"jfs/FuzzingCommon/SeedGenerator.h\"\n#include <list>\n#include <memory>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nclass SeedGenerator;\n\nclass SeedManagerOptions {\npublic:\n  uint64_t maxSeedSpaceInBytes;\n  uint64_t maxNumSeeds;\n  std::list<std::unique_ptr<SeedGenerator>> generators;\n};\n\n} // namespace fuzzingCommon\n} // namespace jfs\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/SeedManagerStat.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_SEED_MANAGER_STAT_H\n#define JFS_FUZZING_COMMON_SEED_MANAGER_STAT_H\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/FuzzingCommon/FuzzingSolver.h\"\n#include \"jfs/Support/JFSStat.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace fuzzingCommon {\nstruct SeedManagerStat : public jfs::support::JFSStat {\n  uint64_t numSeedsGenerated = 0;\n  SeedManagerStat(llvm::StringRef name);\n  virtual ~SeedManagerStat();\n  void printYAML(llvm::ScopedPrinter& os) const override;\n  static bool classof(const JFSStat* s) { return s->getKind() == SEED_MANAGER; }\n};\n} // namespace fuzzingCommon\n} // namespace jfs\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/SortConformanceCheckPass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_SORT_CONFORMANCE_PASS_H\n#define JFS_FUZZING_COMMON_SORT_CONFORMANCE_PASS_H\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Transform/QueryPass.h\"\n#include <functional>\n\nnamespace jfs {\nnamespace fuzzingCommon {\nclass SortConformanceCheckPass : public jfs::transform::QueryPass {\n  bool predicateHeld;\n  std::function<bool(jfs::core::Z3SortHandle)> predicate;\n\npublic:\n  SortConformanceCheckPass(\n      std::function<bool(jfs::core::Z3SortHandle)> predicate);\n  ~SortConformanceCheckPass() {}\n  bool run(jfs::core::Query& q) override;\n  virtual llvm::StringRef getName() override;\n  bool predicateAlwaysHeld() const { return predicateHeld; }\n  void reset() { predicateHeld = false; }\n  virtual bool convertModel(jfs::core::Model* m) override;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/SpecialConstantSeedGenerator.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_SPECIAL_CONSTANT_SEED_GENERATOR_H\n#define JFS_FUZZING_COMMON_SPECIAL_CONSTANT_SEED_GENERATOR_H\n\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/Core/Z3NodeMap.h\"\n#include \"jfs/FuzzingCommon/SeedGenerator.h\"\n#include \"jfs/FuzzingCommon/SpecialConstantSeedGeneratorStat.h\"\n#include <vector>\n\nnamespace jfs {\nnamespace core {\nclass JFSContext;\nclass Model;\n}\n}\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nclass BufferElement;\nclass SeedManager;\n\n// A seed generator that emits special constants based on the sorts used in the\n// constraints of the query.\nclass SpecialConstantSeedGenerator : public SeedGenerator {\n  // Inherit constructor\n  using SeedGenerator::SeedGenerator;\n\n  void preGenerationCallBack(SeedManager& sm) override;\n  void postGenerationCallBack(SeedManager& sm) override;\n  bool writeSeed(SeedManager& sm) override;\n  bool empty() const override;\n\nprivate:\n  // Track vectors of constants found in constraints by sort.\n  jfs::core::Z3SortMap<std::vector<jfs::core::Z3ASTHandle>>\n      sortToConstraintConstantMap;\n  std::unique_ptr<SpecialConstantSeedGeneratorStat> stats;\n\n  bool chooseBool(core::JFSContext& ctx, const BufferElement& be,\n                  core::Model& model);\n  bool chooseBitVector(core::JFSContext& ctx, const BufferElement& be,\n                       core::Model& model);\n  bool chooseFloatingPoint(core::JFSContext& ctx, const BufferElement& be,\n                       core::Model& model);\n};\n\n} // namespace fuzzingCommon\n} // namespace jfs\n\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/SpecialConstantSeedGeneratorStat.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Alastair Donaldson\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_SEED_GENERATOR_STAT_H\n#define JFS_FUZZING_COMMON_SEED_GENERATOR_STAT_H\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Core/Z3NodeMap.h\"\n#include \"jfs/Support/JFSStat.h\"\n\nnamespace jfs {\nnamespace fuzzingCommon {\nstruct SpecialConstantSeedGeneratorStat : public jfs::support::JFSStat {\n  jfs::core::Z3SortMap<uint64_t> foundConstantsCount;\n  uint64_t totalNumBuiltInBVConstants = 0;\n  uint64_t numCoveredBVConstants = 0;\n  uint64_t totalNumBuiltInFPConstants = 0;\n  uint64_t numCoveredFPConstants = 0;\n  uint64_t totalNumBuiltInBoolConstants = 0;\n  uint64_t numCoveredBoolConstants = 0;\n\n  SpecialConstantSeedGeneratorStat(llvm::StringRef name);\n  virtual ~SpecialConstantSeedGeneratorStat();\n  void printYAML(llvm::ScopedPrinter& os) const override;\n  static bool classof(const JFSStat* s) {\n    return s->getKind() == SEED_GENERATOR;\n  }\n};\n} // namespace fuzzingCommon\n} // namespace jfs\n#endif\n"
  },
  {
    "path": "include/jfs/FuzzingCommon/WorkingDirectoryManager.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_WORKING_DIRECTORY_MANAGER_H\n#define JFS_FUZZING_COMMON_WORKING_DIRECTORY_MANAGER_H\n#include \"jfs/Core/JFSContext.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include <memory>\n#include <string>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nclass WorkingDirectoryManager {\nprivate:\n  const std::string path;\n  jfs::core::JFSContext& ctx;\n  const bool deleteOnDestruction;\n  WorkingDirectoryManager(llvm::StringRef path, jfs::core::JFSContext& ctx,\n                          bool deleteOnDestruction);\n\npublic:\n  // Don't allow copying\n  ~WorkingDirectoryManager();\n  WorkingDirectoryManager(const WorkingDirectoryManager&) = delete;\n  WorkingDirectoryManager(const WorkingDirectoryManager&&) = delete;\n  WorkingDirectoryManager& operator=(const WorkingDirectoryManager&) = delete;\n\n  llvm::StringRef getPath() const { return path; }\n  std::string getPathToFileInDirectory(llvm::StringRef fileName) const;\n  std::string makeNewDirectoryInDirectory(llvm::StringRef dirName);\n\n  // Make at `path`. `path` should not already exist, but its\n  // parent directory should.\n  // If the fails a nullptr will be returned.\n  static std::unique_ptr<WorkingDirectoryManager>\n  makeAtPath(llvm::StringRef path, jfs::core::JFSContext& ctx,\n             bool deleteOnDestruction);\n\n  // Make at `<directory>/<prefix>-N` where `N` is an integer.\n  // This function will start with `N == 0` an keep incrementing\n  // `N` until a directory is successfully created `N == maxN`.\n  // If the fails a nullptr will be returned.\n  static std::unique_ptr<WorkingDirectoryManager>\n  makeInDirectory(llvm::StringRef directory, llvm::StringRef prefix,\n                  jfs::core::JFSContext& ctx, bool deleteOnDestruction,\n                  uint16_t maxN = 100);\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Support/CancellableProcess.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_SUPPORT_CANCELLABLE_PROCESS_H\n#define JFS_SUPPORT_CANCELLABLE_PROCESS_H\n#include \"jfs/Support/ICancellable.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include <memory>\n#include <string>\n#include <vector>\n\nnamespace jfs {\n\nnamespace support {\n\nclass CancellableProcessImpl;\n\n// This is a thin wrapper around LLVM's\n// `llvm::sys::ExecuteAndWait()` that supports\n// cancellation.\nclass CancellableProcess : public ICancellable {\nprivate:\n  const std::unique_ptr<CancellableProcessImpl> impl;\n\npublic:\n  CancellableProcess();\n  ~CancellableProcess();\n  void cancel() override;\n  // Return values >= 0 is program exit code.\n  // Negative value indicates failure.\n  int execute(llvm::StringRef program, std::vector<const char*>& args,\n              std::vector<llvm::StringRef>& redirects,\n              const char** envp = nullptr);\n};\n} // namespace support\n} // namespace jfs\n#endif\n"
  },
  {
    "path": "include/jfs/Support/ErrorMessages.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_SUPPORT_ERROR_MESSAGES_H\n#define JFS_SUPPORT_ERROR_MESSAGES_H\n#include \"llvm/ADT/StringRef.h\"\n#include <string>\n#include <system_error>\n\nnamespace jfs {\n\nnamespace support {\nstd::string getMessageForFailedOpenFileOrSTDIN(llvm::StringRef inputFileName,\n                                               std::error_code ec);\n\nstd::string\ngetMessageForFailedOpenFileForWriting(llvm::StringRef outputFileName,\n                                      std::error_code ec);\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Support/FileUtils.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_SUPPORT_ERROR_MESSAGES_H\n#define JFS_SUPPORT_ERROR_MESSAGES_H\n#include \"llvm/ADT/StringRef.h\"\n#include <string>\n#include <system_error>\n\nnamespace jfs {\n\nnamespace support {\nstd::error_code recursive_remove(llvm::StringRef path, bool IgnoreNonExisting);\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Support/ICancellable.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_SUPPORT_ICANCELLABLE_H\n#define JFS_SUPPORT_ICANCELLABLE_H\n\nnamespace jfs {\n\nnamespace support {\n// This is a simple interface that classes can implement to cancel their\n// currently assigned work. It is not defined what the state of the instance\n// will be after making this call.\nclass ICancellable {\npublic:\n  virtual void cancel() = 0;\n  virtual ~ICancellable();\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Support/JFSStat.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_SUPPORT_JFS_STAT_H\n#define JFS_SUPPORT_JFS_STAT_H\n#include \"llvm/ADT/StringRef.h\"\n#include \"llvm/Support/Casting.h\"\n#include \"llvm/Support/ScopedPrinter.h\"\n#include \"llvm/Support/Timer.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <list>\n#include <memory>\n#include <string>\n\nnamespace jfs {\nnamespace support {\n\nclass JFSStat {\npublic:\n  enum JFSStatKind {\n    SINGLE_TIMER,\n    AGGREGATE_TIMER,\n    CXX_PROGRAM,\n    RUNTIME,\n    SEED_MANAGER,\n    SEED_GENERATOR\n  };\n\nprivate:\n  const JFSStatKind kind;\n  std::string name;\n\nprotected:\n  JFSStat(JFSStatKind kind, llvm::StringRef name);\n\npublic:\n  virtual ~JFSStat();\n  JFSStatKind getKind() const { return kind; }\n  // FIXME: We should switch to llvm::yaml API.\n  virtual void printYAML(llvm::ScopedPrinter& os) const = 0;\n  void dump() const;\n  llvm::StringRef getName() const;\n};\n\nclass JFSAggregateTimerStat;\nclass JFSTimerStat : public JFSStat {\nprivate:\n  using RecordTy = llvm::TimeRecord;\n  RecordTy record;\n\npublic:\n  friend class JFSAggregateTimerStat;\n  JFSTimerStat(RecordTy record, llvm::StringRef name);\n  ~JFSTimerStat();\n  void printYAML(llvm::ScopedPrinter& os) const override;\n  static bool classof(const JFSStat* s) { return s->getKind() == SINGLE_TIMER; }\n};\n\nclass JFSAggregateTimerStat : public JFSStat {\nprivate:\n  std::list<std::unique_ptr<const JFSTimerStat>> timers;\n\npublic:\n  JFSAggregateTimerStat(llvm::StringRef name);\n  ~JFSAggregateTimerStat();\n  void append(std::unique_ptr<JFSTimerStat> t);\n  void clear();\n  void printYAML(llvm::ScopedPrinter& os) const override;\n  static bool classof(const JFSStat* s) {\n    return s->getKind() == AGGREGATE_TIMER;\n  }\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Support/ScopedJFSTimerStatAppender.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_SUPPORT_SCOPED_JFS_TIMER_STAT_APPENDER_H\n#define JFS_SUPPORT_SCOPED_JFS_TIMER_STAT_APPENDER_H\n#include \"jfs/Support/JFSStat.h\"\n#include \"jfs/Support/Timer.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace support {\n\ntemplate <typename T> class ScopedJFSTimerStatAppender {\npublic:\n  T* receiver;\n  Timer timer;\n  llvm::StringRef name;\n  std::unique_ptr<JFSTimerStat> result;\n  ScopedJFSTimerStatAppender(T* receiver, llvm::StringRef name)\n      : receiver(receiver), timer(), name(name), result(nullptr) {\n    if (receiver == nullptr)\n      return;\n    // Start timer\n    timer.startTimer();\n  }\n  ~ScopedJFSTimerStatAppender() {\n    if (receiver == nullptr)\n      return;\n    timer.stopTimer();\n    result.reset(new JFSTimerStat(timer.getTotalTime(), name));\n    receiver->append(std::move(result));\n  }\n};\n\ntemplate <typename T> class ScopedJFSAggregateTimerStatAppender {\npublic:\n  T* receiver;\n  std::unique_ptr<JFSAggregateTimerStat> stats;\n  ScopedJFSAggregateTimerStatAppender(T* receiver, llvm::StringRef name)\n      : receiver(receiver), stats(nullptr) {\n    if (receiver == nullptr)\n      return;\n    stats.reset(new JFSAggregateTimerStat(name));\n  }\n  ~ScopedJFSAggregateTimerStatAppender() {\n    if (receiver == nullptr)\n      return;\n    receiver->append(std::move(stats));\n  }\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Support/ScopedTimer.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_SUPPORT_SCOPED_TIMER_H\n#define JFS_SUPPORT_SCOPED_TIMER_H\n#include <functional>\n#include <memory>\n#include <stdint.h>\n\nnamespace jfs {\nnamespace support {\n\nclass ScopedTimerImpl;\n\nclass ScopedTimer {\nprivate:\n  std::unique_ptr<ScopedTimerImpl> impl;\n\npublic:\n  typedef std::function<void(void)> CallBackTy;\n  // Will call `callBack` if wall clock time exceeds\n  // `maxTime`. If `maxTime` is == 0 then `callBack`\n  // will never be called.\n  ScopedTimer(uint64_t maxTime, CallBackTy callBack);\n  ~ScopedTimer();\n  uint64_t getRemainingTime() const;\n  uint64_t getMaxTime() const;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Support/StatisticsManager.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_SUPPORT_STATISTICS_MANAGER_H\n#define JFS_SUPPORT_STATISTICS_MANAGER_H\n#include \"llvm/Support/raw_ostream.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace support {\n\nclass JFSStat;\nclass StatisticsManagerImpl;\nclass StatisticsManager {\nprivate:\n  const std::unique_ptr<StatisticsManagerImpl> impl;\n\npublic:\n  // FIXME: Figure out how to add iterators without leaking\n  // implementation details\n  StatisticsManager();\n  ~StatisticsManager();\n  void append(std::unique_ptr<JFSStat> stat);\n  void clear();\n  size_t size() const;\n  void printYAML(llvm::raw_ostream& os) const;\n  void dump() const;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Support/Timer.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_SUPPORT_TIMER_H\n#define JFS_SUPPORT_TIMER_H\n#include \"llvm/Support/Timer.h\" // For llvm::TimeRecord\n\nnamespace jfs {\nnamespace support {\n\n// This is timer inspired by `llvm::Timer`. Unfortunately `llvm::Timer` is a\n// bit cumbersome to use due to the way it's tied to `TimerGroup`. We could\n// potentially create `TimerGroup` for `StatisticsManager` and for each\n// `JFSAggregateTimerStat` but we would need to keep all the `llvm::Timer`s\n// alive so that the implicit dumping of stats to stderr happens properly.\n// This seems wasteful so implementing our own seems simpler.\nclass Timer {\npublic:\n  typedef llvm::TimeRecord RecordTy;\n\nprivate:\n  RecordTy Time;      ///< The total time captured.\n  RecordTy StartTime; ///< The time startTimer() was last called.\n  bool Running;       ///< Is the timer currently running?\n  bool Triggered;     ///< Has the timer ever been triggered?\npublic:\n  Timer();\n  ~Timer();\n  Timer(const Timer& RHS) = delete;\n\n  /// Check if the timer is currently running.\n  bool isRunning() const { return Running; }\n\n  /// Check if startTimer() has ever been called on this timer.\n  bool hasTriggered() const { return Triggered; }\n\n  /// Start the timer running.  Time between calls to startTimer/stopTimer is\n  /// counted by the Timer class.  Note that these calls must be correctly\n  /// paired.\n  void startTimer();\n\n  /// Stop the timer.\n  void stopTimer();\n\n  /// Clear the timer state.\n  void clear();\n\n  /// Return the duration for which this timer has been running.\n  RecordTy getTotalTime() const { return Time; }\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Support/version.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_SUPPORT_VERSION_H\n#define JFS_SUPPORT_VERSION_H\n\nnamespace jfs {\n\nnamespace support {\n\nconst char* getVersionString();\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Transform/AndHoistingPass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_TRANSFORM_AND_HOISTING_PASS_H\n#define JFS_TRANSFORM_AND_HOISTING_PASS_H\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Transform/QueryPass.h\"\n\nnamespace jfs {\nnamespace transform {\nclass AndHoistingPass : public QueryPass {\npublic:\n  AndHoistingPass() {}\n  ~AndHoistingPass() {}\n  bool run(jfs::core::Query& q) override;\n  virtual llvm::StringRef getName() override;\n  virtual bool convertModel(jfs::core::Model* m) override;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Transform/BitBlastPass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_TRANSFORM_BIT_BLAST_PASS_H\n#define JFS_TRANSFORM_BIT_BLAST_PASS_H\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Transform/Z3QueryPass.h\"\n\nnamespace jfs {\nnamespace transform {\nclass BitBlastPass : public Z3QueryPass {\npublic:\n  BitBlastPass() {}\n  ~BitBlastPass() {}\n  bool run(jfs::core::Query& q) override;\n  virtual llvm::StringRef getName() override;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Transform/BvBoundPropagationPass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_TRANSFORM_BV_BOUND_PROPAGATION_PASS_H\n#define JFS_TRANSFORM_BV_BOUND_PROPAGATION_PASS_H\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Transform/Z3QueryPass.h\"\n\nnamespace jfs {\nnamespace transform {\n// NOTE: This pass only supports bvule and bvsle\n// currently so simplifier must be run first.\nclass BvBoundPropagationPass : public Z3QueryPass {\npublic:\n  BvBoundPropagationPass() {}\n  ~BvBoundPropagationPass() {}\n  bool run(jfs::core::Query& q) override;\n  virtual llvm::StringRef getName() override;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Transform/ConstantPropagationPass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_TRANSFORM_CONSTANT_PROPAGATION_PASS_H\n#define JFS_TRANSFORM_CONSTANT_PROPAGATION_PASS_H\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Transform/Z3QueryPass.h\"\n\nnamespace jfs {\nnamespace transform {\nclass ConstantPropagationPass : public Z3QueryPass {\npublic:\n  ConstantPropagationPass() {}\n  ~ConstantPropagationPass() {}\n  bool run(jfs::core::Query& q) override;\n  virtual llvm::StringRef getName() override;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Transform/DIMACSOutputPass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_TRANSFORM_DIMACS_OUTPUT_PASS_H\n#define JFS_TRANSFORM_DIMACS_OUTPUT_PASS_H\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Transform/Z3QueryPass.h\"\n\nnamespace jfs {\nnamespace transform {\nclass DIMACSOutputPass : public Z3QueryPass {\npublic:\n  DIMACSOutputPass() {}\n  ~DIMACSOutputPass() {}\n  bool run(jfs::core::Query& q) override;\n  virtual llvm::StringRef getName() override;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Transform/DuplicateConstraintEliminationPass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_TRANSFORM_DUPLICATE_CONSTRAINT_ELIMINATION_PASS_H\n#define JFS_TRANSFORM_DUPLICATE_CONSTRAINT_ELIMINATION_PASS_H\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Transform/QueryPass.h\"\n\nnamespace jfs {\nnamespace transform {\nclass DuplicateConstraintEliminationPass : public QueryPass {\npublic:\n  DuplicateConstraintEliminationPass() {}\n  ~DuplicateConstraintEliminationPass() {}\n  bool run(jfs::core::Query& q) override;\n  virtual llvm::StringRef getName() override;\n  virtual bool convertModel(jfs::core::Model* m) override;\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Transform/FpToBvPass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_TRANSFORM_FP_TO_BV_PASS_H\n#define JFS_TRANSFORM_FP_TO_BV_PASS_H\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Transform/Z3QueryPass.h\"\n\nnamespace jfs {\nnamespace transform {\nclass FpToBvPass : public Z3QueryPass {\npublic:\n  FpToBvPass() {}\n  ~FpToBvPass() {}\n  bool run(jfs::core::Query& q) override;\n  virtual llvm::StringRef getName() override;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Transform/Passes.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Transform/AndHoistingPass.h\"\n#include \"jfs/Transform/BitBlastPass.h\"\n#include \"jfs/Transform/BvBoundPropagationPass.h\"\n#include \"jfs/Transform/ConstantPropagationPass.h\"\n#include \"jfs/Transform/DIMACSOutputPass.h\"\n#include \"jfs/Transform/DuplicateConstraintEliminationPass.h\"\n#include \"jfs/Transform/FpToBvPass.h\"\n#include \"jfs/Transform/SimpleContradictionsToFalsePass.h\"\n#include \"jfs/Transform/SimplificationPass.h\"\n#include \"jfs/Transform/TrueConstraintEliminationPass.h\"\n"
  },
  {
    "path": "include/jfs/Transform/QueryPass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_TRANSFORM_QUERY_PASS_H\n#define JFS_TRANSFORM_QUERY_PASS_H\n#include \"jfs/Core/Model.h\"\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Support/ICancellable.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include <atomic>\n\nnamespace jfs {\nnamespace transform {\nclass QueryPass : jfs::support::ICancellable {\nprotected:\n  std::atomic<bool> cancelled;\n\npublic:\n  QueryPass() : cancelled(false) {}\n  virtual ~QueryPass() {}\n  // returns `true` if changed, `false` otherwise.\n  virtual bool run(jfs::core::Query&) = 0;\n  virtual llvm::StringRef getName() = 0;\n  void cancel() override { cancelled = true; }\n  virtual bool convertModel(jfs::core::Model* m) = 0;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Transform/QueryPassManager.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_TRANSFORM_QUERY_PASS_MANAGER_H\n#define JFS_TRANSFORM_QUERY_PASS_MANAGER_H\n#include \"jfs/Core/Model.h\"\n#include \"jfs/Support/ICancellable.h\"\n#include \"jfs/Transform/QueryPass.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace transform {\n\nclass QueryPassManagerImpl;\nclass QueryPassManager : public jfs::support::ICancellable {\nprivate:\n  std::unique_ptr<QueryPassManagerImpl> impl;\npublic:\n  QueryPassManager();\n  virtual ~QueryPassManager();\n  // This not a std::unique_ptr<QueryPass> because some passes just collect\n  // information so clients will need to hold on to a pointer to those\n  // passes.  This means we can't have unique ownership (otherwise clients\n  // would have to hold on to raw pointers which is dangerous).\n  void add(std::shared_ptr<QueryPass> pass);\n  void run(jfs::core::Query& q);\n  void cancel() override;\n  void clear();\n  // Modify (in-place) the provided model so that it is a solution to the Query\n  // passed to the last call to `run()` before it was modified. It is assumed\n  // that the provided model already satisfies the modified query.\n  bool convertModel(jfs::core::Model* m);\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Transform/SimpleContradictionsToFalsePass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_TRANSFORM_SIMPLE_CONTRADICTIONS_TO_FALSE_H\n#define JFS_TRANSFORM_SIMPLE_CONTRADICTIONS_TO_FALSE_H\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Transform/QueryPass.h\"\n\nnamespace jfs {\nnamespace transform {\nclass SimpleContradictionsToFalsePass : public QueryPass {\npublic:\n  SimpleContradictionsToFalsePass() {}\n  ~SimpleContradictionsToFalsePass() {}\n  bool run(jfs::core::Query& q) override;\n  virtual llvm::StringRef getName() override;\n  virtual bool convertModel(jfs::core::Model* m) override;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Transform/SimplificationPass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_TRANSFORM_SIMPLIFICATION_PASS_H\n#define JFS_TRANSFORM_SIMPLIFICATION_PASS_H\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Transform/Z3QueryPass.h\"\n\nnamespace jfs {\nnamespace transform {\nclass SimplificationPass : public Z3QueryPass {\npublic:\n  SimplificationPass() {}\n  ~SimplificationPass() {}\n  bool run(jfs::core::Query& q) override;\n  virtual llvm::StringRef getName() override;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Transform/StandardPasses.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_TRANSFORM_STANDARD_PASSES_H\n#define JFS_TRANSFORM_STANDARD_PASSES_H\n#include \"jfs/Transform/QueryPassManager.h\"\n\nnamespace jfs {\nnamespace transform {\nvoid AddStandardPasses(QueryPassManager& pm);\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Transform/TrueConstraintEliminationPass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_TRANSFORM_TRUE_CONSTRAINT_ELIMINATION_PASS_H\n#define JFS_TRANSFORM_TRUE_CONSTRAINT_ELIMINATION_PASS_H\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Transform/QueryPass.h\"\n\nnamespace jfs {\nnamespace transform {\nclass TrueConstraintEliminationPass : public QueryPass {\npublic:\n  TrueConstraintEliminationPass() {}\n  ~TrueConstraintEliminationPass() {}\n  bool run(jfs::core::Query& q) override;\n  virtual llvm::StringRef getName() override;\n  virtual bool convertModel(jfs::core::Model* m) override;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "include/jfs/Transform/Z3QueryPass.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_TRANSFORM_Z3_QUERY_PASS_H\n#define JFS_TRANSFORM_Z3_QUERY_PASS_H\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/Transform/QueryPass.h\"\n\nnamespace jfs {\nnamespace transform {\nclass Z3QueryPass : public QueryPass {\nprotected:\n  Z3_context z3Ctx;\n  jfs::core::Z3ApplyResultHandle result;\n\npublic:\n  Z3QueryPass() : z3Ctx(nullptr) {}\n  ~Z3QueryPass() {}\n  void cancel() override;\n  virtual bool convertModel(jfs::core::Model* m) override;\n};\n}\n}\n#endif\n"
  },
  {
    "path": "include/jfs/Z3Backend/Z3Solver.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_Z3BACKEND_Z3_SOLVER_H\n#define JFS_Z3BACKEND_Z3_SOLVER_H\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Core/Solver.h\"\n#include <memory>\n\nnamespace jfs {\nnamespace z3Backend {\nclass Z3Solver : public jfs::core::Solver {\nprivate:\n  Z3_context z3Ctx;\n  bool cancelled;\n\npublic:\n  Z3Solver(std::unique_ptr<jfs::core::SolverOptions> options,\n           jfs::core::JFSContext& ctx);\n  ~Z3Solver();\n  std::unique_ptr<jfs::core::SolverResponse> solve(const jfs::core::Query& q,\n                                                   bool produceModel) override;\n  llvm::StringRef getName() const override;\n  void cancel() override;\n};\n}\n}\n\n#endif\n"
  },
  {
    "path": "lib/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\nadd_subdirectory(Support)\nadd_subdirectory(Core)\nadd_subdirectory(Transform)\nadd_subdirectory(Z3Backend)\nadd_subdirectory(FuzzingCommon)\nadd_subdirectory(CXXFuzzingBackend)\n"
  },
  {
    "path": "lib/CXXFuzzingBackend/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\njfs_add_component(JFSCXXFuzzingBackend\n  ClangInvocationManager.cpp\n  ClangOptions.cpp\n  CXXFuzzingSolver.cpp\n  CXXFuzzingSolverOptions.cpp\n  CXXProgram.cpp\n  CXXProgramBuilderPass.cpp\n  CXXProgramBuilderPassImpl.cpp\n  CXXProgramBuilderOptions.cpp\n  JFSCXXProgramStat.cpp\n)\ntarget_link_libraries(JFSCXXFuzzingBackend PUBLIC JFSFuzzingCommon)\n\njfs_get_llvm_components(llvm_components support)\n\ntarget_link_libraries(JFSCXXFuzzingBackend PUBLIC ${llvm_components})\n\nadd_subdirectory(CmdLine)\n"
  },
  {
    "path": "lib/CXXFuzzingBackend/CXXFuzzingSolver.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/CXXFuzzingBackend/CXXFuzzingSolver.h\"\n#include \"jfs/CXXFuzzingBackend/CXXFuzzingSolverOptions.h\"\n#include \"jfs/CXXFuzzingBackend/CXXProgram.h\"\n#include \"jfs/CXXFuzzingBackend/CXXProgramBuilderPass.h\"\n#include \"jfs/CXXFuzzingBackend/ClangInvocationManager.h\"\n#include \"jfs/CXXFuzzingBackend/ClangOptions.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/JFSTimerMacros.h\"\n#include \"jfs/FuzzingCommon/FileSerializableModel.h\"\n#include \"jfs/FuzzingCommon/JFSRuntimeFuzzingStat.h\"\n#include \"jfs/FuzzingCommon/LibFuzzerInvocationManager.h\"\n#include \"jfs/FuzzingCommon/SeedManager.h\"\n#include \"jfs/FuzzingCommon/SortConformanceCheckPass.h\"\n#include \"jfs/FuzzingCommon/WorkingDirectoryManager.h\"\n#include \"jfs/Transform/QueryPass.h\"\n#include \"jfs/Transform/QueryPassManager.h\"\n#include \"llvm/Support/CommandLine.h\"\n#include <algorithm>\n#include <atomic>\n#include <mutex>\n#include <unordered_set>\n\nusing namespace jfs::core;\nusing namespace jfs::fuzzingCommon;\nusing namespace jfs::transform;\n\nnamespace {\n// FIXME: Should use an OptionCategory but\n// we shouldn't pull in `jfs::cxxfb::cl::CommandLineCategory` because\n// that defeats the purpose of having the separate libraries. So instead\n// just hide the option by default. It's only meant for internal testing\n// anyway.\nllvm::cl::opt<bool> DebugStopAfterCompilation(\n    \"debug-stop-after-compile\", llvm::cl::init(false),\n    llvm::cl::desc(\"Stop CXXFuzzingSolver after clang compilation\"),\n    llvm::cl::Hidden);\n\nllvm::cl::opt<bool> DebugStopAfterSeedGeneration(\n    \"debug-stop-after-seed-gen\", llvm::cl::init(false),\n    llvm::cl::desc(\"Stop CXXFuzzingSolver after seed generation\"),\n    llvm::cl::Hidden);\n}\n\nnamespace jfs {\nnamespace cxxfb {\n\nclass CXXFuzzingSolverImpl;\n\nclass CXXFuzzingSolverResponse : public SolverResponse {\nprivate:\n  std::unique_ptr<FileSerializableModel> model;\n\npublic:\n  CXXFuzzingSolverResponse(SolverResponse::SolverSatisfiability sat)\n      : SolverResponse(sat) {}\n  Model* getModel() override { return model.get(); }\n  friend class CXXFuzzingSolverImpl;\n};\n\nclass CXXFuzzingSolverImpl {\n  std::mutex cancellablePassesMutex; // protects `cancellablePasses`\n  std::unordered_set<jfs::transform::QueryPass*> cancellablePasses;\n  std::atomic<bool> cancelled;\n  JFSContext& ctx;\n  // Raw pointer because we don't own the storage.\n  CXXFuzzingSolverOptions* options;\n  ClangInvocationManager cim;\n  LibFuzzerInvocationManager lim;\n  WorkingDirectoryManager* wdm;\n  std::unique_ptr<jfs::fuzzingCommon::SeedManager> seedManager;\n\npublic:\n  friend class CXXFuzzingSolver;\n  CXXFuzzingSolverImpl(JFSContext& ctx, CXXFuzzingSolverOptions* options,\n                       WorkingDirectoryManager* wdm)\n      : cancelled(false), ctx(ctx), options(options), cim(ctx), lim(ctx),\n        wdm(wdm) {\n    assert(this->wdm != nullptr);\n    assert(this->options != nullptr);\n    // Check paths\n    bool clangPathsOkay = options->getClangOptions()->checkPaths(ctx);\n    if (!clangPathsOkay) {\n      ctx.raiseFatalError(\"One or more Clang paths do not exist\");\n    }\n  }\n  ~CXXFuzzingSolverImpl() {}\n\n  llvm::StringRef getName() { return \"CXXFuzzingSolver\"; }\n  void cancel() {\n    cancelled = true;\n    // Cancel any active passes\n    {\n      std::lock_guard<std::mutex> lock(cancellablePassesMutex);\n      for (const auto& pass : cancellablePasses) {\n        pass->cancel();\n      }\n    }\n    // Cancel active Clang invocation\n    cim.cancel();\n    // Cancel active LibFuzzer invocation\n    lim.cancel();\n    // Cancel active SeedManager invocation\n    if (seedManager) {\n      seedManager->cancel();\n    }\n  }\n\n  // FIXME: Should be const Query.\n  bool sortsAreSupported(Query& q) {\n    JFSContext &ctx = q.getContext();\n    auto p = std::make_shared<SortConformanceCheckPass>([&ctx](Z3SortHandle s) {\n      switch (s.getKind()) {\n      case Z3_BOOL_SORT: {\n        return true;\n      }\n      case Z3_BV_SORT: {\n        unsigned width = s.getBitVectorWidth();\n        if (width <= 64) {\n          return true;\n        }\n        // Too wide\n        IF_VERB(ctx,\n                ctx.getWarningStream()\n                    << \"(BitVector width \" << width << \" not supported)\\n\");\n        return false;\n      }\n      case Z3_FLOATING_POINT_SORT: {\n        unsigned ebits = s.getFloatingPointExponentBitWidth();\n        unsigned sbits = s.getFloatingPointSignificandBitWidth();\n        if (ebits == 8 && sbits == 24) {\n          // Float32\n          return true;\n        } else if (ebits == 11 && sbits == 53) {\n          // Float64\n          return true;\n        }\n        IF_VERB(ctx, ctx.getWarningStream()\n                         << \"(FloatingPoint sort \\\"\" << s.toStr()\n                         << \"\\\" not supported)\\n\");\n        return false;\n      }\n      case Z3_ROUNDING_MODE_SORT:\n        return true;\n      default: {\n        // Sort not supported\n        IF_VERB(ctx,\n                ctx.getWarningStream()\n                    << \"(Sort \\\"\" << s.toStr() << \"\\\" not supported)\\n\");\n        return false;\n      }\n      }\n    });\n\n    QueryPassManager pm;\n    {\n      // Make the pass cancellable\n      std::lock_guard<std::mutex> lock(cancellablePassesMutex);\n      cancellablePasses.insert(p.get());\n      pm.add(p);\n    }\n\n    pm.run(q);\n\n    {\n      // The pass is done remove it from set of cancellable passes\n      std::lock_guard<std::mutex> lock(cancellablePassesMutex);\n      cancellablePasses.erase(p.get());\n    }\n    return p->predicateAlwaysHeld();\n  }\n\n  std::unique_ptr<jfs::core::SolverResponse>\n  fuzz(jfs::core::Query& q, bool produceModel,\n       std::shared_ptr<FuzzingAnalysisInfo> info) {\n    assert(ctx == q.getContext());\n#define CHECK_CANCELLED()                                                      \\\n  if (cancelled) {                                                             \\\n    IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\"); \\\n    return std::unique_ptr<SolverResponse>(                                    \\\n        new CXXFuzzingSolverResponse(SolverResponse::UNKNOWN));                \\\n  }\n\n    // Check types are supported\n    if (!sortsAreSupported(q)) {\n      IF_VERB(ctx, ctx.getDebugStream() << \"(unsupported sorts)\\n\");\n      return std::unique_ptr<SolverResponse>(\n          new CXXFuzzingSolverResponse(SolverResponse::UNKNOWN));\n    }\n\n    // Cancellation point\n    CHECK_CANCELLED();\n\n    // Generate program\n    QueryPassManager pm;\n    auto pbp = std::make_shared<CXXProgramBuilderPass>(\n        info, options->getCXXProgramBuilderOptions(), ctx);\n\n    {\n      // Make the pass cancellable\n      std::lock_guard<std::mutex> lock(cancellablePassesMutex);\n      cancellablePasses.insert(pbp.get());\n      pm.add(pbp);\n    }\n    pm.run(q);\n    {\n      // Pass is done. Remove from the set of cancellable passes\n      std::lock_guard<std::mutex> lock(cancellablePassesMutex);\n      cancellablePasses.insert(pbp.get());\n    }\n\n    // Cancellation point\n    CHECK_CANCELLED();\n\n    // Build program\n    // FIXME: We should teach ClangInvocationManager to pipe the program\n    // directly\n    // to Clang so we don't need to write it disk and then immediatly read it\n    // back.\n    std::string outputFilePath;\n    {\n      JFS_SM_TIMER(compile, ctx);\n      std::string sourceFilePath = wdm->getPathToFileInDirectory(\"program.cpp\");\n      outputFilePath = wdm->getPathToFileInDirectory(\"fuzzer\");\n      std::string clangStdOutFile;\n      std::string clangStdErrFile;\n      if (options->redirectClangOutput) {\n        // When being quiet redirect to files\n        clangStdOutFile = wdm->getPathToFileInDirectory(\"clang.stdout.txt\");\n        clangStdErrFile = wdm->getPathToFileInDirectory(\"clang.stderr.txt\");\n      }\n      bool compileSuccess = cim.compile(\n          /*program=*/pbp->getProgram().get(), /*sourceFile=*/sourceFilePath,\n          /*outputFile=*/outputFilePath,\n          /*clangOptions=*/options->getClangOptions(),\n          /*stdOutFile=*/clangStdOutFile,\n          /*stdErrFile=*/clangStdErrFile);\n      if (!compileSuccess) {\n        return std::unique_ptr<SolverResponse>(\n            new CXXFuzzingSolverResponse(SolverResponse::UNKNOWN));\n      }\n    }\n    // Cancellation point\n    CHECK_CANCELLED();\n\n    if (DebugStopAfterCompilation) {\n      // For debugging it can be useful to check that JFS can successfully\n      // run and compile the fuzzing program without actually fuzzing.\n      IF_VERB(ctx, ctx.getDebugStream() << \"(DebugStopAfterCompilation)\\n\");\n      return std::unique_ptr<SolverResponse>(\n          new CXXFuzzingSolverResponse(SolverResponse::UNKNOWN));\n    }\n\n    // Set LibFuzzer options\n    LibFuzzerOptions* lfo = options->getLibFuzzerOptions();\n    lfo->maxLength =\n        info->freeVariableAssignment->bufferAssignment->getRequiredStoreBytes();\n    lfo->targetBinary = outputFilePath;\n    std::string corpusDir = wdm->makeNewDirectoryInDirectory(\"corpus\");\n    lfo->corpusDir = corpusDir;\n    std::string artifactDir = wdm->makeNewDirectoryInDirectory(\"artifacts\");\n    lfo->artifactDir = artifactDir;\n    std::string libFuzzerStdOutFile;\n    std::string libFuzzerStdErrFile;\n    lfo->useCmp = false;\n    // FIXME: This is O(N). We should probably change sanitizerCoverageOptions\n    // to be a set.\n    if (std::find(options->getClangOptions()->sanitizerCoverageOptions.begin(),\n                  options->getClangOptions()->sanitizerCoverageOptions.end(),\n                  ClangOptions::SanitizerCoverageTy::TRACE_CMP) !=\n        options->getClangOptions()->sanitizerCoverageOptions.end()) {\n      lfo->useCmp = true;\n    }\n    // FIXME: The fact that our fuzzing target is `abort()` is really fragile.\n    lfo->handleSIGABRT =\n        true; // Our target is an `abort()` so we want to catch this.\n    lfo->handleSIGBUS = false; // We don't want to confuse this with the target.\n    lfo->handleSIGFPE = false; // We don't want to confuse this with the target.\n    lfo->handleSIGILL = false; // We don't want to confuse this with the target.\n    lfo->handleSIGINT =\n        true; // This doesn't trigger LibFuzzer's error handler so this is fine.\n    lfo->handleSIGSEGV =\n        false; // We don't want to confuse this with the target.\n    lfo->handleSIGTERM =\n        true; // This doesn't trigger LibFuzzer's error handler so this is fine.\n    lfo->handleSIGXFSZ =\n        true; // This doesn't trigger LibFuzzer's error handler so this is fine.\n\n    if (options->redirectLibFuzzerOutput) {\n      // When being quiet redirect to files\n      libFuzzerStdOutFile =\n          wdm->getPathToFileInDirectory(\"libfuzzer.stdout.txt\");\n      libFuzzerStdErrFile =\n          wdm->getPathToFileInDirectory(\"libfuzzer.stderr.txt\");\n    }\n\n    if (pbp->getProgram()->getRecordsRuntimeStats()) {\n      // Tell LibFuzzerInvocationManager that it needs to log runtime statistics\n      lfo->jfsRuntimeLogFile =\n          wdm->getPathToFileInDirectory(\"jfs_runtime_stats.yml\");\n    }\n\n    // Create seeds\n    seedManager.reset(\n        new jfs::fuzzingCommon::SeedManager(/*seedDir=*/lfo->corpusDir, ctx));\n    seedManager->configureFrom(std::move(options->seedManagerOpt));\n    seedManager->writeSeeds(info.get(), &q);\n\n    if (DebugStopAfterSeedGeneration) {\n      // For debugging it can be useful to check that JFS can successfully\n      // run and compile the fuzzing program and generate seeds without actually\n      // fuzzing.\n      IF_VERB(ctx, ctx.getDebugStream() << \"(DebugStopAfterSeedGeneration)\\n\");\n      return std::unique_ptr<SolverResponse>(\n          new CXXFuzzingSolverResponse(SolverResponse::UNKNOWN));\n    }\n\n    // Fuzz\n    JFS_SM_TIMER(fuzz, ctx);\n    auto fuzzingResponse =\n        lim.fuzz(lfo, libFuzzerStdOutFile, libFuzzerStdErrFile);\n\n    // Get runtime stastics\n    std::unique_ptr<JFSRuntimeFuzzingStat> rfs;\n    if (lfo->jfsRuntimeLogFile.size() > 0) {\n      rfs = JFSRuntimeFuzzingStat::LoadFromYAML(lfo->jfsRuntimeLogFile,\n                                                \"runtime_fuzzing_stats\", ctx);\n      if (rfs != nullptr && ctx.getStats() != nullptr) {\n        ctx.getStats()->append(std::move(rfs));\n      } else {\n        ctx.getWarningStream()\n            << \"(warning Failed to retrive runtime fuzzing stats)\\n\";\n      }\n    }\n\n    switch (fuzzingResponse->outcome) {\n    case LibFuzzerResponse::ResponseTy::RUN_BOUND_REACHED:\n    case LibFuzzerResponse::ResponseTy::UNKNOWN:\n    case LibFuzzerResponse::ResponseTy::CANCELLED: {\n      return std::unique_ptr<SolverResponse>(\n          new CXXFuzzingSolverResponse(SolverResponse::UNKNOWN));\n    }\n    case LibFuzzerResponse::ResponseTy::SINGLE_RUN_TARGET_NOT_FOUND: {\n      // Special case where the fuzzer only does a single run due to\n      // empty buffer.\n      return std::unique_ptr<SolverResponse>(\n          new CXXFuzzingSolverResponse(SolverResponse::UNSAT));\n    }\n    case LibFuzzerResponse::ResponseTy::TARGET_FOUND: {\n      // Solution found\n      std::unique_ptr<CXXFuzzingSolverResponse> resp(\n          new CXXFuzzingSolverResponse(SolverResponse::SAT));\n      if (produceModel) {\n        auto mb = fuzzingResponse->getInputForTarget();\n        if (mb.get() == nullptr) {\n          ctx.raiseFatalError(\"Failed to get model\");\n        }\n        resp->model = FileSerializableModel::loadFrom(\n            mb.get(), info->freeVariableAssignment->bufferAssignment.get(),\n            ctx);\n      }\n      // Save model back to disk for testing if requested\n      if (options->debugSaveModel) {\n        BufferAssignment* ba =\n            info->freeVariableAssignment->bufferAssignment.get();\n\n        auto modelOutputPath =\n          wdm->getPathToFileInDirectory(\"model-output\");\n        llvm::StringRef moduleOutputPathRef(modelOutputPath);\n        auto expectedModelOutputBuffer = llvm::FileOutputBuffer::create(\n            moduleOutputPathRef, ba->getRequiredStoreBytes());\n\n        std::unique_ptr<llvm::FileOutputBuffer> modelOutputBuffer = nullptr;\n        if (expectedModelOutputBuffer) {\n          modelOutputBuffer = std::move(*expectedModelOutputBuffer);\n        } else {\n          // Failed\n          ctx.getErrorStream()\n              << \"(error Failed to created FileOutputBuffer for model)\\n\";\n        }\n\n        resp->model->saveTo(modelOutputBuffer.get(), ba, ctx);\n      }\n      return resp;\n    }\n    default:\n      llvm_unreachable(\"Unhandled LibFuzzerResponse\");\n    }\n    return nullptr;\n  }\n};\n\nCXXFuzzingSolver::CXXFuzzingSolver(\n    std::unique_ptr<CXXFuzzingSolverOptions> options,\n    std::unique_ptr<WorkingDirectoryManager> wdm, JFSContext& ctx)\n    : jfs::fuzzingCommon::FuzzingSolver(std::move(options), std::move(wdm),\n                                        ctx),\n      impl(new CXXFuzzingSolverImpl(\n          ctx, static_cast<CXXFuzzingSolverOptions*>(this->options.get()),\n          this->wdm.get())) {}\n\nCXXFuzzingSolver::~CXXFuzzingSolver() {}\n\nstd::unique_ptr<jfs::core::SolverResponse>\nCXXFuzzingSolver::fuzz(jfs::core::Query& q, bool produceModel,\n                       std::shared_ptr<FuzzingAnalysisInfo> info) {\n  return impl->fuzz(q, produceModel, info);\n}\n\nllvm::StringRef CXXFuzzingSolver::getName() const { return \"CXXFuzzingSolver\"; }\n\nvoid CXXFuzzingSolver::cancel() {\n  // Call parent\n  FuzzingSolver::cancel();\n  // Notify implementation\n  impl->cancel();\n}\n}\n}\n"
  },
  {
    "path": "lib/CXXFuzzingBackend/CXXFuzzingSolverOptions.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/CXXFuzzingBackend/CXXFuzzingSolverOptions.h\"\n#include \"jfs/CXXFuzzingBackend/ClangOptions.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"llvm/ADT/SmallVector.h\"\n#include \"llvm/ADT/Twine.h\"\n#include \"llvm/Support/FileSystem.h\"\n#include \"llvm/Support/Path.h\"\nnamespace jfs {\nnamespace cxxfb {\n\nCXXFuzzingSolverOptions::CXXFuzzingSolverOptions(\n    std::unique_ptr<\n        jfs::fuzzingCommon::FreeVariableToBufferAssignmentPassOptions>\n        fvtbapOptions,\n    std::unique_ptr<ClangOptions> clangOpt,\n    std::unique_ptr<jfs::fuzzingCommon::LibFuzzerOptions> libFuzzerOpt,\n    std::unique_ptr<CXXProgramBuilderOptions> cxxProgramBuilderOpt,\n    std::unique_ptr<jfs::fuzzingCommon::SeedManagerOptions> seedManagerOpt,\n    bool debugSaveModel)\n    : jfs::fuzzingCommon::FuzzingSolverOptions(std::move(fvtbapOptions),\n                                               debugSaveModel,\n                                               CXX_FUZZING_SOLVER_KIND),\n      clangOpt(std::move(clangOpt)), libFuzzerOpt(std::move(libFuzzerOpt)),\n      cxxProgramBuilderOpt(std::move(cxxProgramBuilderOpt)),\n      seedManagerOpt(std::move(seedManagerOpt)), redirectClangOutput(false),\n      redirectLibFuzzerOutput(false) {}\n} // namespace cxxfb\n} // namespace jfs\n"
  },
  {
    "path": "lib/CXXFuzzingBackend/CXXProgram.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/CXXFuzzingBackend/CXXProgram.h\"\n\nnamespace jfs {\nnamespace cxxfb {\n\n// CXXDecl\nvoid CXXDecl::dump() const { print(llvm::errs()); }\n\nCXXDecl* CXXDecl::getParent() const { return parent; }\n\nCXXDecl::CXXDecl(CXXDecl* parent) : parent(parent) {}\n\nCXXDecl::~CXXDecl() {}\n\n// CXXIncludeDecl\n\nCXXIncludeDecl::CXXIncludeDecl(CXXDecl* parent, llvm::StringRef path,\n                               bool systemHeader)\n    : CXXDecl(parent), path(path.str()), isSystemInclude(systemHeader) {}\n\nvoid CXXIncludeDecl::print(llvm::raw_ostream& os) const {\n  os << \"#include \" << (isSystemInclude ? \"<\" : \"\\\"\") << path\n     << (isSystemInclude ? \">\" : \"\\\"\") << \"\\n\";\n}\n\n// CXXStatement\n\nCXXStatement::~CXXStatement() {}\n\n// CXXCommentBlock\n\nvoid CXXCommentBlock::print(llvm::raw_ostream& os) const {\n  os << \"// \" << comment << \"\\n\";\n}\n\n// CXXFunctionDecl\n\nCXXFunctionDecl::CXXFunctionDecl(CXXDecl* parent, llvm::StringRef name,\n                                 CXXTypeRef returnTy,\n                                 std::vector<CXXFunctionArgumentRef>& arguments,\n                                 bool hasCVisibility)\n    : CXXDecl(parent), name(name.str()), returnTy(returnTy),\n      arguments(arguments), hasCVisibility(hasCVisibility), defn(nullptr) {}\n\nCXXFunctionDecl::~CXXFunctionDecl() {}\n\nvoid CXXFunctionDecl::print(llvm::raw_ostream& os) const {\n  if (hasCVisibility)\n    os << \"extern \\\"C\\\" \";\n\n  returnTy->print(os);\n  os << \" \" << name << \"(\";\n  for (unsigned index = 0; index < arguments.size(); ++index) {\n    arguments[index]->print(os);\n    if (index != (arguments.size() - 1)) {\n      os << \", \";\n    }\n  }\n  os << \")\";\n  if (defn.get() == nullptr) {\n    // Just a declaration\n    os << \";\\n\";\n    return;\n  }\n  // print block\n  os << \"\\n\";\n  defn->print(os);\n}\n\n// CXXType\nCXXType::CXXType(CXXDecl* parent, llvm::StringRef name, bool isConst)\n    : CXXDecl(parent), name(name.str()), isConst(isConst) {}\n\nCXXType::CXXType(CXXDecl* parent, llvm::StringRef name)\n    : CXXType(parent, name, /*isConst=*/false) {}\n\nCXXType::~CXXType() {}\n\nvoid CXXType::print(llvm::raw_ostream& os) const {\n  if (isConst) {\n    os << \"const \";\n  }\n  os << name;\n}\n\n// CXXFunctionArgument\nCXXFunctionArgument::CXXFunctionArgument(CXXDecl* parent, llvm::StringRef name,\n                                         CXXTypeRef argType)\n    : CXXDecl(parent), name(name.str()), argType(argType) {}\n\nCXXFunctionArgument::~CXXFunctionArgument() {}\n\nvoid CXXFunctionArgument::print(llvm::raw_ostream& os) const {\n  argType->print(os);\n  os << \" \" << name;\n}\n\n// CXXCodeBlock\nCXXCodeBlock::CXXCodeBlock(CXXDecl* parent) : CXXDecl(parent) {}\nCXXCodeBlock::~CXXCodeBlock() {}\n\nvoid CXXCodeBlock::print(llvm::raw_ostream& os) const {\n  os << \"{\\n\";\n  for (const auto& st : statements) {\n    st->print(os);\n  }\n  os << \"}\\n\";\n}\n\n// CXXIfStatement\nCXXIfStatement::CXXIfStatement(CXXCodeBlock* parent, llvm::StringRef condition)\n    : CXXStatement(parent), condition(condition.str()), trueBlock(nullptr),\n      falseBlock(nullptr) {}\n\nvoid CXXIfStatement::print(llvm::raw_ostream& os) const {\n  os << \"if (\" << condition << \")\";\n  if (trueBlock) {\n    os << \"\\n\";\n    trueBlock->print(os);\n  } else {\n    os << \" {}\\n\";\n  }\n  if (falseBlock) {\n    os << \"else \";\n    falseBlock->print(os);\n  }\n}\n\n// CXXReturnIntStatement\nCXXReturnIntStatement::CXXReturnIntStatement(CXXCodeBlock* parent,\n                                             int returnValue)\n    : CXXStatement(parent), returnValue(returnValue) {}\n\nvoid CXXReturnIntStatement::print(llvm::raw_ostream& os) const {\n  os << \"return \" << returnValue << \";\\n\";\n}\n\n// CXXDeclAndDefnVarStatement\nCXXDeclAndDefnVarStatement::CXXDeclAndDefnVarStatement(\n    CXXDecl* parent, CXXTypeRef ty, llvm::StringRef name,\n    llvm::StringRef valueExpr)\n    : CXXStatement(parent), ty(ty), name(name.str()),\n      valueExpr(valueExpr.str()) {}\n\nvoid CXXDeclAndDefnVarStatement::print(llvm::raw_ostream& os) const {\n  ty->print(os);\n  os << \" \" << name << \" = \" << valueExpr << \";\\n\";\n}\n\n// CXXGenericStatement\nCXXGenericStatement::CXXGenericStatement(CXXDecl* parent,\n                                         llvm::StringRef statement)\n    : CXXStatement(parent), statement(statement.str()) {}\n\nvoid CXXGenericStatement::print(llvm::raw_ostream& os) const {\n  os << statement << \";\\n\";\n}\n\n// CXXProgram\n\nvoid CXXProgram::print(llvm::raw_ostream& os) const {\n  os << \"// Begin program\\n\";\n  for (const auto& decl : decls) {\n    decl->print(os);\n  }\n  os << \"// End program\\n\";\n}\n\nvoid CXXProgram::appendDecl(CXXDeclRef decl) { decls.push_back(decl); }\n\nvoid CXXProgram::addRequiredLibrary(llvm::StringRef name) {\n  requiredLibs.emplace_back(name.data(), name.size());\n}\n\nbool CXXProgram::libraryIsRequired(llvm::StringRef name) const {\n  // FIXME: We should use a set to avoid being O(N).\n  for (const auto& libName : requiredLibs) {\n    if (libName == name) {\n      return true;\n    }\n  }\n  return false;\n}\n}\n}\n"
  },
  {
    "path": "lib/CXXFuzzingBackend/CXXProgramBuilderOptions.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/CXXFuzzingBackend/CXXProgramBuilderOptions.h\"\n\nnamespace jfs {\nnamespace cxxfb {\nCXXProgramBuilderOptions::CXXProgramBuilderOptions() {}\n} // namespace cxxfb\n} // namespace jfs\n"
  },
  {
    "path": "lib/CXXFuzzingBackend/CXXProgramBuilderPass.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/CXXFuzzingBackend/CXXProgramBuilderPass.h\"\n#include \"CXXProgramBuilderPassImpl.h\"\n#include \"jfs/CXXFuzzingBackend/CXXProgram.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/Core/Z3NodeMap.h\"\n\nusing namespace jfs::core;\nusing namespace jfs::fuzzingCommon;\n\nnamespace jfs {\nnamespace cxxfb {\n\nCXXProgramBuilderPass::CXXProgramBuilderPass(\n    std::shared_ptr<FuzzingAnalysisInfo> info,\n    const CXXProgramBuilderOptions* options, JFSContext& ctx)\n    : impl(new CXXProgramBuilderPassImpl(info, options, ctx)) {\n  assert(options != nullptr);\n}\n\nstd::shared_ptr<CXXProgram> CXXProgramBuilderPass::getProgram() {\n  return impl->program;\n}\n\nCXXProgramBuilderPass::~CXXProgramBuilderPass() {}\n\nllvm::StringRef CXXProgramBuilderPass::getName() { return \"CXXProgramBuilder\"; }\n\nbool CXXProgramBuilderPass::run(Query& q) {\n  JFSContext& ctx = q.getContext();\n  impl->build(q);\n\n  // Print final result\n  if (ctx.getVerbosity() >= 2) {\n    ctx.getDebugStream() << \"(\" << getName() << \"\\n\\n\";\n    impl->program->print(ctx.getDebugStream());\n    ctx.getDebugStream() << \"\\n)\\n\";\n  }\n  return false;\n}\n\nbool CXXProgramBuilderPass::convertModel(jfs::core::Model* m) {\n  return impl->convertModel(m);\n}\n}\n}\n"
  },
  {
    "path": "lib/CXXFuzzingBackend/CXXProgramBuilderPassImpl.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"CXXProgramBuilderPassImpl.h\"\n#include \"jfs/CXXFuzzingBackend/CXXProgram.h\"\n#include \"jfs/CXXFuzzingBackend/JFSCXXProgramStat.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/Core/Z3NodeMap.h\"\n#include \"jfs/FuzzingCommon/JFSRuntimeFuzzingStat.h\"\n#include \"jfs/Support/StatisticsManager.h\"\n#include <ctype.h>\n#include <list>\n\nusing namespace jfs::core;\nusing namespace jfs::fuzzingCommon;\n\nnamespace jfs {\nnamespace cxxfb {\n\nCXXProgramBuilderPassImpl::CXXProgramBuilderPassImpl(\n    std::shared_ptr<FuzzingAnalysisInfo> info,\n    const CXXProgramBuilderOptions* options, JFSContext& ctx)\n    : ctx(ctx), options(options), info(info), counterTy(nullptr) {\n  program = std::make_shared<CXXProgram>();\n\n  // Setup early exit code block\n  earlyExitBlock = std::make_shared<CXXCodeBlock>(program.get());\n  auto returnStmt =\n      std::make_shared<CXXReturnIntStatement>(earlyExitBlock.get(), 0);\n  earlyExitBlock->statements.push_front(returnStmt);\n  entryPointMainBlock = nullptr;\n\n  if (isTrackingNumConstraintsSatisfied()) {\n    numConstraintsSatisfiedSymbolName = insertSymbol(\"jfs_num_const_sat\");\n  }\n  if (isTrackingMaxNumConstraintsSatisfied()) {\n    maxNumConstraintsSatisfiedSymbolName =\n        insertSymbol(jfs::fuzzingCommon::JFSRuntimeFuzzingStat::\n                         maxNumConstraintsSatisfiedKeyName);\n    assert(isTrackingNumConstraintsSatisfied());\n  }\n  if (isTrackingNumberOfInputsTried()) {\n    numInputsTriedSymbolName = insertSymbol(\n        jfs::fuzzingCommon::JFSRuntimeFuzzingStat::numberOfInputsTriedKeyName);\n  }\n  if (isTrackingNumberOfWrongSizedInputsTried()) {\n    numWrongSizedInputsTriedSymbolName =\n        insertSymbol(jfs::fuzzingCommon::JFSRuntimeFuzzingStat::\n                         numberOfWrongSizedInputsTriedKeyName);\n  }\n  libFuzzerCustomCounterArraySymbolName =\n      insertSymbol(\"jfs_libfuzzer_custom_counter\");\n}\n\nbool CXXProgramBuilderPassImpl::convertModel(jfs::core::Model* m) {\n  // This pass preserves equivalence so the model does not need to be\n  // converted.\n  return true;\n}\n\nCXXCodeBlockRef CXXProgramBuilderPassImpl::getConstraintIsFalseBlock() {\n  if (options->getBranchEncoding() ==\n      CXXProgramBuilderOptions::BranchEncodingTy::FAIL_FAST) {\n    return earlyExitBlock;\n  }\n  // No-op block\n  return nullptr;\n}\n\nCXXCodeBlockRef CXXProgramBuilderPassImpl::getConstraintIsTrueBlock() {\n  if (!isTrackingNumConstraintsSatisfied()) {\n    // Empty block (no-op)\n    return nullptr;\n  }\n  if (trueBlock != nullptr) {\n    return trueBlock;\n  }\n  // HACK: We cheat because we can re-use the same codeblock for\n  // all constraint `CXXIfStatement`, so we just make the parent\n  // nullptr.\n  trueBlock = std::make_shared<CXXCodeBlock>(nullptr);\n  // Add statement to increment the local constraint counter.\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  ss << \"++\" << numConstraintsSatisfiedSymbolName;\n  trueBlock->statements.push_back(\n      std::make_shared<CXXGenericStatement>(trueBlock.get(), ss.str()));\n  if (isTrackingMaxNumConstraintsSatisfied() &&\n      !isUpdatingMaxNumConstraintsSatisfiedAtEnd()) {\n    insertUpdateMaxNumConstraintsSatisfiedToBlock(trueBlock);\n  }\n  return trueBlock;\n}\n\nvoid CXXProgramBuilderPassImpl::insertUpdateMaxNumConstraintsSatisfiedToBlock(\n    CXXCodeBlockRef cb) {\n  // Emit code to increment `maxNumConstraintsSatisfiedSymbolName`\n  // if the number of constraints satisfied so far is greater than\n  // what had been observed previously.\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  ss << maxNumConstraintsSatisfiedSymbolName << \" < \"\n     << numConstraintsSatisfiedSymbolName;\n  auto maxNumGuard = std::make_shared<CXXIfStatement>(cb.get(),\n                                                      /*condition=*/ss.str());\n  maxNumGuard->falseBlock = nullptr; // Do nothing is condition false.\n  // Construct block with code to update\n  // `maxNumConstraintsSatisfiedSymbolName`\n  auto incrementMaxNumConstraintsSatisfiedBlock =\n      std::make_shared<CXXCodeBlock>(maxNumGuard.get());\n  underlyingString.clear();\n\n  if (options->getTraceIncreaseMaxNumSatisfiedConstraints()) {\n    ss << \"jfs_info(\\\"Max num constraints satisfied increased from %\" PRId64\n          \" to %\" PRId64 \" (out of %\" PRId64 \")\\\\n\\\",\"\n       << maxNumConstraintsSatisfiedSymbolName << \",\"\n       << numConstraintsSatisfiedSymbolName << \",\"\n       << \"UINT64_C(\" << numberOfConstraints << \"))\";\n    incrementMaxNumConstraintsSatisfiedBlock->statements.push_back(\n        std::make_shared<CXXGenericStatement>(\n            incrementMaxNumConstraintsSatisfiedBlock.get(), ss.str()));\n    underlyingString.clear();\n  }\n\n  // HACK: Do assign. We should make a CXXDecl to do this.\n  ss << maxNumConstraintsSatisfiedSymbolName << \" = \"\n     << numConstraintsSatisfiedSymbolName;\n  incrementMaxNumConstraintsSatisfiedBlock->statements.push_back(\n      std::make_shared<CXXGenericStatement>(\n          incrementMaxNumConstraintsSatisfiedBlock.get(), ss.str()));\n\n  maxNumGuard->trueBlock = incrementMaxNumConstraintsSatisfiedBlock;\n  cb->statements.push_back(maxNumGuard);\n}\n\nbool CXXProgramBuilderPassImpl::isTrackingNumConstraintsSatisfied() const {\n  return isTrackingMaxNumConstraintsSatisfied() ||\n         options->getBranchEncoding() ==\n             CXXProgramBuilderOptions::BranchEncodingTy::TRY_ALL;\n}\n\nbool CXXProgramBuilderPassImpl::isTrackingMaxNumConstraintsSatisfied() const {\n  return options->getRecordMaxNumSatisfiedConstraints() ||\n         options->getTraceIncreaseMaxNumSatisfiedConstraints() ||\n         options->getBranchEncoding() ==\n             CXXProgramBuilderOptions::BranchEncodingTy::TRY_ALL_IMNCSF;\n}\n\nbool CXXProgramBuilderPassImpl::isTrackingNumberOfInputsTried() const {\n  return options->getRecordNumberOfInputs();\n}\n\nbool CXXProgramBuilderPassImpl::isTrackingNumberOfWrongSizedInputsTried()\n    const {\n  return options->getRecordNumberOfWrongSizedInputs();\n}\n\nbool CXXProgramBuilderPassImpl::isTrackingWithLibFuzzerCustomCounter() const {\n  // This is a little nasty. Unlikely other `isTracking*()` functions this\n  // function will only return the correct value after `build(Query)` is called\n  // because until then we don't know how many constraints there are.\n  return numberOfConstraints > 0 &&\n         options->getBranchEncoding() ==\n             CXXProgramBuilderOptions::BranchEncodingTy::TRY_ALL_IMNCSF;\n}\n\nbool CXXProgramBuilderPassImpl::isRecordingStats() const {\n  // Note we can't use `isTrackingMaxNumConstraintsSatisfied()` because\n  // that is used for other encodings even when stats are not being recorded.\n  return options->getRecordMaxNumSatisfiedConstraints() ||\n         isTrackingNumberOfInputsTried() ||\n         isTrackingNumberOfWrongSizedInputsTried();\n}\n\nbool CXXProgramBuilderPassImpl::isTracing() const {\n  return options->getTraceIncreaseMaxNumSatisfiedConstraints() ||\n         options->getTraceWrongSizedInputs();\n}\n\nbool CXXProgramBuilderPassImpl::isUpdatingMaxNumConstraintsSatisfiedAtEnd()\n    const {\n  if (!isTrackingMaxNumConstraintsSatisfied()) {\n    return false;\n  }\n  if (options->getBranchEncoding() ==\n      CXXProgramBuilderOptions::BranchEncodingTy::FAIL_FAST) {\n    return false;\n  }\n  // All other encodings can update the \"maximum number of satisfied\n  // constraints\" counter after evaluating all constraints.\n  return true;\n}\n\nCXXTypeRef CXXProgramBuilderPassImpl::getCounterTy() {\n  if (counterTy != nullptr)\n    return counterTy;\n  counterTy =\n      std::make_shared<CXXType>(program.get(), \"uint64_t\", /*isConst=*/false);\n  return counterTy;\n}\n\nCXXTypeRef CXXProgramBuilderPassImpl::getOrInsertTy(Z3SortHandle sort) {\n  auto cachedIt = sortToCXXTypeCache.find(sort);\n  if (cachedIt != sortToCXXTypeCache.end()) {\n    return cachedIt->second;\n  }\n  // Don't have the sort cached. Construct the matching CXXType.\n  switch (sort.getKind()) {\n  case Z3_BOOL_SORT: {\n    // Make const type so that Compiler enforces SSA.\n    auto ty =\n        std::make_shared<CXXType>(program.get(), \"bool\", /*isConst=*/true);\n    sortToCXXTypeCache.insert(std::make_pair(sort, ty));\n    return ty;\n  }\n  case Z3_BV_SORT: {\n    unsigned width = sort.getBitVectorWidth();\n    std::string underlyingString;\n    llvm::raw_string_ostream ss(underlyingString);\n    ss << \"BitVector<\" << width << \">\";\n    ss.flush();\n    // Make const type so that Compiler enforces SSA.\n    auto ty = std::make_shared<CXXType>(program.get(), underlyingString,\n                                        /*isConst=*/true);\n    sortToCXXTypeCache.insert(std::make_pair(sort, ty));\n    return ty;\n  }\n  case Z3_FLOATING_POINT_SORT: {\n    unsigned exponentBits = sort.getFloatingPointExponentBitWidth();\n    unsigned significandBits = sort.getFloatingPointSignificandBitWidth();\n    std::string underlyingString;\n    llvm::raw_string_ostream ss(underlyingString);\n    ss << \"Float<\" << exponentBits << \",\" << significandBits << \">\";\n    ss.flush();\n    // Make const type so that Compiler enforces SSA.\n    auto ty = std::make_shared<CXXType>(program.get(), underlyingString,\n                                        /*isConst=*/true);\n    sortToCXXTypeCache.insert(std::make_pair(sort, ty));\n    return ty;\n  }\n  default:\n    llvm_unreachable(\"Unhandled sort\");\n  }\n}\n\nvoid CXXProgramBuilderPassImpl::insertHeaderIncludes() {\n  // Runtime header includes\n  // FIXME: We should probe the query and only emit these header includes\n  // if we actually need them.\n  program->appendDecl(std::make_shared<CXXIncludeDecl>(program.get(),\n                                                       \"SMTLIB/Core.h\",\n                                                       /*systemHeader=*/false));\n  program->appendDecl(std::make_shared<CXXIncludeDecl>(\n      program.get(), \"SMTLIB/BitVector.h\", /*systemHeader=*/false));\n  program->appendDecl(std::make_shared<CXXIncludeDecl>(\n      program.get(), \"SMTLIB/Float.h\", /*systemHeader=*/false));\n\n  if (isRecordingStats()) {\n    program->appendDecl(std::make_shared<CXXIncludeDecl>(\n        program.get(), \"SMTLIB/Logger.h\", /*systemHeader=*/false));\n  }\n\n  if (isTracing()) {\n    program->appendDecl(std::make_shared<CXXIncludeDecl>(\n        program.get(), \"SMTLIB/Messages.h\", /*systemHeader=*/false));\n  }\n\n  // Int types header for LibFuzzer entry point definition.\n  program->appendDecl(std::make_shared<CXXIncludeDecl>(program.get(),\n                                                       \"stdint.h\",\n                                                       /*systemHeader=*/true));\n  program->appendDecl(std::make_shared<CXXIncludeDecl>(program.get(),\n                                                       \"stdlib.h\",\n                                                       /*systemHeader=*/true));\n}\n\nCXXFunctionDeclRef CXXProgramBuilderPassImpl::buildEntryPoint() {\n  // Build entry point for LibFuzzer\n  auto retTy = std::make_shared<CXXType>(program.get(), \"int\");\n  auto firstArgTy = std::make_shared<CXXType>(program.get(), \"const uint8_t*\");\n  auto secondArgTy = std::make_shared<CXXType>(program.get(), \"size_t\");\n  entryPointFirstArgName = insertSymbol(\"data\");\n  auto firstArg = std::make_shared<CXXFunctionArgument>(\n      program.get(), entryPointFirstArgName, firstArgTy);\n  entryPointSecondArgName = insertSymbol(\"size\");\n  auto secondArg = std::make_shared<CXXFunctionArgument>(\n      program.get(), entryPointSecondArgName, secondArgTy);\n  auto funcArguments = std::vector<CXXFunctionArgumentRef>();\n  funcArguments.push_back(firstArg);\n  funcArguments.push_back(secondArg);\n  auto funcDefn = std::make_shared<CXXFunctionDecl>(\n      program.get(), \"LLVMFuzzerTestOneInput\", retTy, funcArguments,\n      /*hasCVisibility=*/true);\n  auto funcBody = std::make_shared<CXXCodeBlock>(funcDefn.get());\n  funcDefn->defn = funcBody; // FIXME: shouldn't be done like this\n  program->appendDecl(funcDefn);\n  return funcDefn;\n}\n\nvoid CXXProgramBuilderPassImpl::insertMaxNumConstraintsSatisfiedCounterInit() {\n  if (!isTrackingMaxNumConstraintsSatisfied())\n    return;\n  // Add global variable to track the maximum number of constraints that\n  // have been satisfied.\n  auto initDecl = std::make_shared<CXXDeclAndDefnVarStatement>(\n      program.get(), getCounterTy(), maxNumConstraintsSatisfiedSymbolName, \"0\");\n  program->appendDecl(initDecl);\n}\n\nvoid CXXProgramBuilderPassImpl::insertNumInputsCounterInit() {\n  if (!isTrackingNumberOfInputsTried())\n    return;\n  // Add global variable to track the number of inputs tried\n  auto initDecl = std::make_shared<CXXDeclAndDefnVarStatement>(\n      program.get(), getCounterTy(), numInputsTriedSymbolName, \"0\");\n  program->appendDecl(initDecl);\n}\n\nvoid CXXProgramBuilderPassImpl::insertNumWrongSizedInputsCounterInit() {\n  if (!isTrackingNumberOfWrongSizedInputsTried())\n    return;\n  // Add global variable to track the number of inputs tried\n  auto initDecl = std::make_shared<CXXDeclAndDefnVarStatement>(\n      program.get(), getCounterTy(), numWrongSizedInputsTriedSymbolName, \"0\");\n  program->appendDecl(initDecl);\n}\n\nvoid CXXProgramBuilderPassImpl::insertAtExitHandler() {\n  if (!isRecordingStats())\n    return;\n  auto retTy = std::make_shared<CXXType>(program.get(), \"void\");\n  std::vector<CXXFunctionArgumentRef> funcArguments;\n  // FIXME: LibFuzzer doesn't support this yet.\n  auto funcDefn = std::make_shared<CXXFunctionDecl>(\n      program.get(), \"LLVMFuzzerAtExit\", retTy, funcArguments,\n      /*hasCVisibility=*/true);\n  auto funcBody = std::make_shared<CXXCodeBlock>(funcDefn.get());\n  funcDefn->defn = funcBody; // FIXME: shouldn't be done like this\n  program->appendDecl(funcDefn);\n  auto loggerTy = std::make_shared<CXXType>(program.get(), \"jfs_nr_logger_ty\");\n  const char* loggerSymbolName = \"logger\";\n  // Add statement to create a logger\n  funcBody->statements.push_back(std::make_shared<CXXDeclAndDefnVarStatement>(\n      funcBody.get(), loggerTy, loggerSymbolName,\n      \"jfs_nr_mk_logger_from_env()\"));\n\n  // Add statement to log the observed maxNumConstraintsSatisfied\n  // value.\n  // HACK\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  if (isTrackingMaxNumConstraintsSatisfied()) {\n    ss << \"jfs_nr_log_uint64(\" << loggerSymbolName << \",\"\n       << \"\\\"\" << maxNumConstraintsSatisfiedSymbolName << \"\\\",\"\n       << maxNumConstraintsSatisfiedSymbolName << \")\";\n    funcBody->statements.push_back(\n        std::make_shared<CXXGenericStatement>(funcBody.get(), ss.str()));\n    underlyingString.clear();\n  }\n\n  // Add statement to log the observed number of inputs tried\n  if (isTrackingNumberOfInputsTried()) {\n    ss << \"jfs_nr_log_uint64(\" << loggerSymbolName << \",\"\n       << \"\\\"\" << numInputsTriedSymbolName << \"\\\",\" << numInputsTriedSymbolName\n       << \")\";\n    funcBody->statements.push_back(\n        std::make_shared<CXXGenericStatement>(funcBody.get(), ss.str()));\n    underlyingString.clear();\n  }\n\n  // Add statement to log the observed number of wrong size inputs tried\n  if (isTrackingNumberOfWrongSizedInputsTried()) {\n    ss << \"jfs_nr_log_uint64(\" << loggerSymbolName << \",\"\n       << \"\\\"\" << numWrongSizedInputsTriedSymbolName << \"\\\",\"\n       << numWrongSizedInputsTriedSymbolName << \")\";\n    funcBody->statements.push_back(\n        std::make_shared<CXXGenericStatement>(funcBody.get(), ss.str()));\n    underlyingString.clear();\n  }\n\n  ss << \"jfs_nr_del_logger(\" << loggerSymbolName << \")\";\n  funcBody->statements.push_back(\n      std::make_shared<CXXGenericStatement>(funcBody.get(), ss.str()));\n}\n\nvoid CXXProgramBuilderPassImpl::insertBufferSizeGuard(CXXCodeBlockRef cb) {\n  uint64_t bufferWidthInBytes =\n      info->freeVariableAssignment->bufferAssignment->getRequiredStoreBytes();\n  if (bufferWidthInBytes == 0) {\n    // Don't add guard to avoid Clang warning about\n    // checking `size < 0`\n    return;\n  }\n  std::string underlyingString;\n  llvm::raw_string_ostream condition(underlyingString);\n  condition << \"size != \" << bufferWidthInBytes;\n  condition.flush();\n  auto ifStatement =\n      std::make_shared<CXXIfStatement>(cb.get(), underlyingString);\n  underlyingString.clear();\n\n  auto wrongSizeExitBlock = std::make_shared<CXXCodeBlock>(program.get());\n  if (isTrackingNumberOfWrongSizedInputsTried()) {\n    // Add code to increment counter that tracks the number of wrong\n    // sized inputs tried.\n    llvm::raw_string_ostream ss(underlyingString);\n    ss << \"++\" << numWrongSizedInputsTriedSymbolName;\n    wrongSizeExitBlock->statements.push_back(\n        std::make_shared<CXXGenericStatement>(wrongSizeExitBlock.get(),\n                                              ss.str()));\n    underlyingString.clear();\n  }\n\n  if (options->getTraceWrongSizedInputs()) {\n    // FIXME: Due to LibFuzzer's implementation it tries a zero size input\n    // once during INIT. We'll emit a spurious warning then. It would be\n    // better if we didn't do this.\n    wrongSizeExitBlock->statements.push_back(\n        std::make_shared<CXXGenericStatement>(\n            wrongSizeExitBlock.get(),\n            \"jfs_warning(\\\"Wrong sized input tried.\\\\n\\\")\"));\n  }\n  auto returnStmt =\n      std::make_shared<CXXReturnIntStatement>(earlyExitBlock.get(), 0);\n  wrongSizeExitBlock->statements.push_back(returnStmt);\n\n  ifStatement->trueBlock = wrongSizeExitBlock;\n  cb->statements.push_back(ifStatement);\n}\n\nstd::string\nCXXProgramBuilderPassImpl::getSanitizedVariableName(const std::string& name) {\n  // NOTE: Z3's implementation doesn't include the `|` in quoted symbol\n  // names. So both quoted and un-quoted symbols are handled in the same\n  // way.\n  if (name.size() == 0) {\n    // This is silly but SMT-LIB seems to allow the empty string (when quoted\n    // i.e. `||`) as a symbol name so pick our own name for this.\n    return \"jfs__empty__\";\n  }\n  std::string buffer;\n  // Walkthrough string copying across allowed characters\n  // and replacing disallowed characters\n  bool requiredChange = false;\n  for (const auto& character : name) {\n    if (isalnum(character) || character == '_') {\n      buffer += character;\n      continue;\n    }\n    requiredChange = true;\n    // Valid Simple symbol character in SMT-LIBv2 but not\n    // valid for use as an identifier in C++.\n    switch (character) {\n#define ACTION(SEARCH, REPL)                                                   \\\n  case SEARCH:                                                                 \\\n    buffer += REPL;                                                            \\\n    continue;\n      ACTION('~', \"_t_\");\n      ACTION('!', \"_ex_\");\n      ACTION('@', \"_at_\");\n      ACTION('$', \"_ds_\");\n      ACTION('%', \"_pc_\");\n      ACTION('^', \"_c_\");\n      ACTION('&', \"_a_\");\n      ACTION('*', \"_s_\");\n      ACTION('-', \"_m_\");\n      ACTION('+', \"_p_\");\n      ACTION('=', \"_e_\");\n      ACTION('<', \"_lt_\");\n      ACTION('>', \"_gt_\");\n      ACTION('.', \"_d_\");\n      ACTION('?', \"_q_\");\n      ACTION('/', \"_fs_\");\n#undef ACTION\n    default:\n      // In all other cases just use `_`.\n      buffer += '_';\n    }\n  }\n\n  if (!requiredChange) {\n    assert(name.size() > 0);\n    return name;\n  }\n\n  // FIXME: We need to avoid clashes with our own internal symbols names\n  // and C++ keywords.\n  assert(buffer.size() > 0);\n  return buffer;\n}\n\nllvm::StringRef\nCXXProgramBuilderPassImpl::insertSymbol(const std::string& symbolName) {\n  std::string sanitizedName = getSanitizedVariableName(symbolName);\n  // Check the sanitized name isn't already used. If it is\n  // apply naive algorithm\n  if (usedSymbols.count(sanitizedName) > 0) {\n    sanitizedName += \"_\";\n    ssize_t indexToStartAt = sanitizedName.size() - 1;\n    char toWrite = '0';\n    do {\n      if (toWrite == '0') {\n        sanitizedName += 'X'; // Write place holder\n        ++indexToStartAt;\n      }\n      sanitizedName[indexToStartAt] = toWrite;\n      ++toWrite;\n      if (toWrite == ('9' + 1)) {\n        // Wrap around\n        toWrite = '0';\n      }\n    } while (usedSymbols.count(sanitizedName) > 0);\n  }\n  auto statusPair = usedSymbols.insert(sanitizedName);\n  assert(statusPair.second && \"cannot insert already used symbolName\");\n  return llvm::StringRef(*(statusPair.first));\n}\n\nllvm::StringRef CXXProgramBuilderPassImpl::insertSSASymbolForExpr(\n    Z3ASTHandle e, const std::string& symbolName) {\n  llvm::StringRef symbolNameRef = insertSymbol(symbolName);\n  assert(!(e.isNull()));\n  auto statusPair = exprToSymbolName.insert(std::make_pair(e, symbolNameRef));\n  assert(statusPair.second && \"expr already has symbol\");\n  return symbolNameRef;\n}\n\nvoid CXXProgramBuilderPassImpl::insertFreeVariableConstruction(\n    CXXCodeBlockRef cb) {\n  llvm::StringRef bufferRefName = insertSymbol(\"jfs_buffer_ref\");\n  const BufferAssignment& ba =\n      *(info->freeVariableAssignment->bufferAssignment.get());\n  if (ba.size() == 0) {\n    // Don't emit anything if the buffer is empty to avoid\n    // clang warnings about unused variables.\n    return;\n  }\n\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  // Insert bufferRef.\n  // FIXME: We should probably just use C++'s constructor syntax\n  // BufferRef<const uint8_t> jfs_buffer_ref<const uint8_t>(data, size)\n  auto bufferRefTy =\n      std::make_shared<CXXType>(program.get(), \"BufferRef<const uint8_t>\");\n  // Build `BufferRef<uint8_t>(data, size)` string.\n  ss << bufferRefTy->getName() << \"(\" << entryPointFirstArgName << \", \"\n     << entryPointSecondArgName << \")\";\n  ss.flush();\n  auto bufferRefAssignment = std::make_shared<CXXDeclAndDefnVarStatement>(\n      cb.get(), bufferRefTy, bufferRefName, underlyingString);\n  cb->statements.push_back(bufferRefAssignment);\n  unsigned currentBufferBit = 0;\n\n  // Walk through free variables and construct CXX code to initialize them\n  // from the buffer.\n  for (const auto& be : ba) {\n    // Add assignment\n    auto assignmentTy = getOrInsertTy(be.getSort());\n    llvm::StringRef sanitizedSymbolName =\n        insertSSASymbolForExpr(be.declApp, be.getName());\n    unsigned endBufferBit = (currentBufferBit + be.getTypeBitWidth()) - 1;\n\n    // Build string `makeBitVectorFrom<a,b>(jfs_buffer_ref)`\n    // where a is min bit and b is max bit from `jfs_buffer_ref`.\n    underlyingString.clear();\n    switch (be.getSort().getKind()) {\n    case Z3_BOOL_SORT: {\n      assert((endBufferBit - currentBufferBit + 1) <= 8);\n      ss << \"makeBoolFrom(\" << bufferRefName << \", \" << currentBufferBit << \", \"\n         << endBufferBit << \")\";\n      break;\n    }\n    case Z3_BV_SORT: {\n      ss << \"makeBitVectorFrom\"\n         << \"<\" << be.getTypeBitWidth() << \">(\" << bufferRefName << \", \"\n         << currentBufferBit << \", \" << endBufferBit << \")\";\n      break;\n    }\n    case Z3_FLOATING_POINT_SORT: {\n      ss << \"makeFloatFrom<\" << be.getSort().getFloatingPointExponentBitWidth()\n         << \",\" << be.getSort().getFloatingPointSignificandBitWidth() << \">(\"\n         << bufferRefName << \", \" << currentBufferBit << \", \" << endBufferBit\n         << \")\";\n      break;\n    }\n    default:\n      llvm_unreachable(\"Unhandled sort\");\n    }\n    ss.flush();\n    auto assignmentStmt = std::make_shared<CXXDeclAndDefnVarStatement>(\n        cb.get(), assignmentTy, sanitizedSymbolName, underlyingString);\n    cb->statements.push_back(assignmentStmt);\n\n    // Notice we use `getStoreBitWidth() and not `getTypeBitWidth()`.\n    // This means that if the type has alignment that we will skip\n    // some bits.\n    currentBufferBit += be.getStoreBitWidth();\n    // Add equalities\n    // FIXME: When we support casts this code will need to be fixed\n    for (const auto& e : be.equalities) {\n      assert(e.isFreeVariable() && \"should be free variable\");\n\n      llvm::StringRef otherVarName =\n          insertSSASymbolForExpr(e, e.asApp().getFuncDecl().getName());\n      assert(e.getSort() == be.getSort() && \"sorts don't match\");\n      auto equalityAssignmentStmt =\n          std::make_shared<CXXDeclAndDefnVarStatement>(\n              cb.get(), assignmentTy, otherVarName, sanitizedSymbolName);\n      cb->statements.push_back(equalityAssignmentStmt);\n    }\n  }\n}\n\nvoid CXXProgramBuilderPassImpl::insertConstantAssignments(CXXCodeBlockRef cb) {\n  // FIXME: Due to constant propagation constant assignments should not be\n  // present. We probably should just remove this entirely.\n  const ConstantAssignment& ca =\n      *(info->freeVariableAssignment->constantAssignments);\n  for (const auto& keyPair : ca.assignments) {\n    Z3ASTHandle key = keyPair.first;\n    Z3ASTHandle constantExpr = keyPair.second;\n    assert(key.isFreeVariable());\n    assert(constantExpr.isConstant());\n    std::string symbolName = key.asApp().getFuncDecl().getName();\n    std::string exprAsStr;\n    Z3AppHandle constantExprAsApp = constantExpr.asApp();\n    switch (constantExprAsApp.getSort().getKind()) {\n    case Z3_BOOL_SORT:\n      exprAsStr = getboolConstantStr(constantExprAsApp);\n      break;\n    case Z3_BV_SORT:\n      exprAsStr = getBitVectorConstantStr(constantExprAsApp);\n      break;\n    case Z3_FLOATING_POINT_SORT:\n      exprAsStr = getFloatingPointConstantStr(constantExprAsApp);\n      break;\n    default:\n      llvm_unreachable(\"Unhandled sort\");\n    }\n    insertSSAStmt(key, exprAsStr, symbolName);\n  }\n}\n\nvoid CXXProgramBuilderPassImpl::insertNumConstraintsSatisifedCounterInit(\n    CXXCodeBlockRef cb) {\n  if (!isTrackingNumConstraintsSatisfied())\n    return;\n  auto initDecl = std::make_shared<CXXDeclAndDefnVarStatement>(\n      cb.get(), getCounterTy(), numConstraintsSatisfiedSymbolName, \"0\");\n  cb->statements.push_back(initDecl);\n}\n\nvoid CXXProgramBuilderPassImpl::insertBranchForConstraint(\n    Z3ASTHandle constraint) {\n  assert(constraint.getSort().isBoolTy());\n  // TODO: investigate whether it is better to construct\n  // if (!e) { return 0; }\n  //\n  // or\n  //\n  // if (e) {} else { return 0;}\n\n  // Construct all SSA variables to get the constraint as a symbol\n  doDFSPostOrderTraversal(constraint);\n  assert(exprToSymbolName.count(constraint) > 0);\n\n  llvm::StringRef symbolForConstraint = getSymbolFor(constraint);\n  auto ifStatement = std::make_shared<CXXIfStatement>(getCurrentBlock().get(),\n                                                      symbolForConstraint);\n  ifStatement->trueBlock = getConstraintIsTrueBlock();\n  ifStatement->falseBlock = getConstraintIsFalseBlock();\n  getCurrentBlock()->statements.push_back(ifStatement);\n}\n\nvoid CXXProgramBuilderPassImpl::insertFuzzingTarget(CXXCodeBlockRef cb) {\n  // FIXME: Replace this with something that we can use to\n  // communicate LibFuzzer's outcome\n  CXXCodeBlockRef blockForAbort = cb;\n  CXXProgramBuilderOptions::BranchEncodingTy bet = options->getBranchEncoding();\n  if (bet == CXXProgramBuilderOptions::BranchEncodingTy::TRY_ALL ||\n      bet == CXXProgramBuilderOptions::BranchEncodingTy::TRY_ALL_IMNCSF) {\n    // In these encodings we need to guard the abort to make sure all\n    // the constraints are satisfied\n    std::string underlyingString;\n    llvm::raw_string_ostream ss(underlyingString);\n    ss << numConstraintsSatisfiedSymbolName << \" == \" << numberOfConstraints;\n    auto ifStatement = std::make_shared<CXXIfStatement>(cb.get(), ss.str());\n    blockForAbort = std::make_shared<CXXCodeBlock>(cb.get());\n    ifStatement->trueBlock = blockForAbort;\n    // This is necessary so we don't fall off the end of the function without\n    // returning a value.\n    ifStatement->falseBlock = earlyExitBlock;\n    cb->statements.push_back(ifStatement);\n  }\n  blockForAbort->statements.push_back(\n      std::make_shared<CXXCommentBlock>(cb.get(), \"Fuzzing target\"));\n  blockForAbort->statements.push_back(\n      std::make_shared<CXXGenericStatement>(cb.get(), \"abort()\"));\n}\n\nvoid CXXProgramBuilderPassImpl::insertNumInputsTriedIncrement(\n    CXXCodeBlockRef cb) {\n  if (!isTrackingNumberOfInputsTried())\n    return;\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  ss << \"++\" << numInputsTriedSymbolName;\n  cb->statements.push_back(\n      std::make_shared<CXXGenericStatement>(cb.get(), ss.str()));\n}\n\nvoid CXXProgramBuilderPassImpl::insertLibFuzzerCustomCounterDecl() {\n  if (!isTrackingWithLibFuzzerCustomCounter()) {\n    return;\n  }\n  assert(numberOfConstraints > 0 && \"array can't be zero sized\");\n  // Emit LibFuzzer specific custom counters. These are only supported\n  // on Linux.\n  // HACK:\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  ss << \"#ifdef \"\n        \"__linux__\\n__attribute__((section(\\\"__libfuzzer_extra_counters\\\")))\\n#\"\n        \"endif\\n\"\n        \"static uint8_t \"\n     << libFuzzerCustomCounterArraySymbolName << \"[\" << numberOfConstraints\n     << \"]\";\n  program->appendDecl(\n      std::make_shared<CXXGenericStatement>(program.get(), ss.str()));\n}\n\nvoid CXXProgramBuilderPassImpl::insertLibFuzzerCustomCounterInc(\n    CXXCodeBlockRef cb) {\n  if (!isTrackingWithLibFuzzerCustomCounter()) {\n    return;\n  }\n\n  // We emit\n  //\n  // if (jfs_max_num_const_sat > 1) {\n  //   jfs_libfuzzer_custom_counter[jfs_max_num_const_sat -1] = 1\n  // }\n  //\n  // In `jfs_libfuzzer_custom_counter` each byte at index `i` is used as a flag\n  // to indicate that `i+1` constraints have been satisfied. The\n  // `jfs_libfuzzer_custom_counter` array is special in that it gets reset to\n  // all zeros on every call and that changing an element to a non-zero value\n  // is treated by LibFuzzer as a \"feature\" (more coverage).\n  //\n  // This is not very efficient (i.e.  wasting 7 bits) but we can't use a more\n  // compact representation because LibFuzzer's treatment of counter values is\n  // such that not every bit is treated as a feature.\n  //\n  // See https://reviews.llvm.org/D40565\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  ss << maxNumConstraintsSatisfiedSymbolName << \" > 0\";\n  auto ifStatement = std::make_shared<CXXIfStatement>(cb.get(), ss.str());\n  cb->statements.push_back(ifStatement);\n  auto trueBlock = std::make_shared<CXXCodeBlock>(ifStatement.get());\n  ifStatement->trueBlock = trueBlock;\n\n  underlyingString.clear();\n  ss << libFuzzerCustomCounterArraySymbolName << \"[\"\n     << maxNumConstraintsSatisfiedSymbolName << \" -1] = 1\";\n  trueBlock->statements.push_back(\n      std::make_shared<CXXGenericStatement>(trueBlock.get(), ss.str()));\n}\n\nvoid CXXProgramBuilderPassImpl::build(const Query& q) {\n  numberOfConstraints = q.constraints.size();\n  program = std::make_shared<CXXProgram>();\n  // Record if stats are going to be tracked.\n  program->setRecordsRuntimeStats(isRecordingStats());\n\n  insertHeaderIncludes();\n  insertMaxNumConstraintsSatisfiedCounterInit();\n  insertNumInputsCounterInit();\n  insertNumWrongSizedInputsCounterInit();\n  insertAtExitHandler();\n  insertLibFuzzerCustomCounterDecl();\n  auto fuzzFn = buildEntryPoint();\n  entryPointMainBlock = fuzzFn->defn;\n\n  insertBufferSizeGuard(fuzzFn->defn);\n  // Note we insert this after the buffer guard check\n  // so that we only count correctly sized inputs.\n  insertNumInputsTriedIncrement(fuzzFn->defn);\n\n  insertFreeVariableConstruction(fuzzFn->defn);\n  insertConstantAssignments(fuzzFn->defn);\n  insertNumConstraintsSatisifedCounterInit(fuzzFn->defn);\n\n  // Generate constraint branches\n  for (const auto& constraint : q.constraints) {\n    insertBranchForConstraint(constraint);\n  }\n  if (isTrackingNumConstraintsSatisfied() &&\n      isUpdatingMaxNumConstraintsSatisfiedAtEnd()) {\n    // Insert code to handle increases in the number of constraints satisfied.\n    insertUpdateMaxNumConstraintsSatisfiedToBlock(fuzzFn->defn);\n  }\n  insertLibFuzzerCustomCounterInc(fuzzFn->defn);\n  insertFuzzingTarget(fuzzFn->defn);\n\n  // Add stats\n  if (ctx.getStats() != nullptr) {\n    std::unique_ptr<JFSCXXProgramStat> progStats(\n        new JFSCXXProgramStat(\"CXXProgramBuilderPassImpl\"));\n    progStats->numConstraints = q.constraints.size();\n    progStats->numEntryFuncStatements = fuzzFn->defn->statements.size();\n    progStats->numFreeVars =\n        info->freeVariableAssignment->bufferAssignment->size();\n    progStats->bufferStoredWidth =\n        info->freeVariableAssignment->bufferAssignment->getStoreBitWidth();\n    progStats->bufferTypeWidth =\n        info->freeVariableAssignment->bufferAssignment->getTypeBitWidth();\n    progStats->numEqualitySets = info->equalityExtraction->equalities.size();\n    ctx.getStats()->append(std::move(progStats));\n  }\n}\n\nconst char* CXXProgramBuilderPassImpl::getboolConstantStr(Z3AppHandle e) const {\n  switch (e.getKind()) {\n  case Z3_OP_TRUE:\n    return \"true\";\n  case Z3_OP_FALSE:\n    return \"false\";\n  default:\n    llvm_unreachable(\"Unexpected expr\");\n  }\n}\n\nstd::string\nCXXProgramBuilderPassImpl::getBitVectorConstantStr(Z3AppHandle e) const {\n  assert(e.isConstant());\n  Z3SortHandle sort = e.getSort();\n  assert(sort.isBitVectorTy());\n  unsigned bitWidth = sort.getBitVectorWidth();\n  assert(bitWidth <= 64 && \"Support for wide bitvectors not implemented\");\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n\n  ss << \"BitVector<\" << bitWidth << \">(UINT64_C(\";\n  // Get constant\n  uint64_t value = 0;\n  bool success = e.getConstantAsUInt64(&value);\n  assert(success && \"Failed to get numeral value\");\n  ss << value;\n  ss << \"))\";\n  ss.flush();\n  return underlyingString;\n}\n\nstd::string CXXProgramBuilderPassImpl::getFloatingPointConstantStr(\n    jfs::core::Z3AppHandle e) const {\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  auto sort = e.getSort();\n  assert(sort.isFloatingPointTy());\n  ss << \"Float<\" << sort.getFloatingPointExponentBitWidth() << \",\"\n     << sort.getFloatingPointSignificandBitWidth() << \">\";\n\n  // Handle special constants\n  bool wasSpecialConstant = true;\n  switch (e.getKind()) {\n  case Z3_OP_FPA_PLUS_ZERO:\n    ss << \"::getPositiveZero()\";\n    break;\n  case Z3_OP_FPA_MINUS_ZERO:\n    ss << \"::getNegativeZero()\";\n    break;\n  case Z3_OP_FPA_PLUS_INF:\n    ss << \"::getPositiveInfinity()\";\n    break;\n  case Z3_OP_FPA_MINUS_INF:\n    ss << \"::getNegativeInfinity()\";\n    break;\n  case Z3_OP_FPA_NAN:\n    ss << \"::getNaN()\";\n    break;\n  default:\n    wasSpecialConstant = false;\n  }\n  if (wasSpecialConstant) {\n    return ss.str();\n  }\n\n  // Handle numeric constants\n  ss << \"(\";\n  Z3ASTHandle signExpr;\n  Z3ASTHandle exponentExpr;\n  Z3ASTHandle significandExpr;\n  switch (e.getKind()) {\n  case Z3_OP_FPA_FP: {\n    // Non constant folded form with three kids\n    assert(e.getNumKids() == 3);\n    signExpr = e.getKid(0);\n    exponentExpr = e.getKid(1);\n    significandExpr = e.getKid(2);\n    break;\n  }\n  case Z3_OP_FPA_NUM: {\n    // Constant folded form with no kids\n    assert(e.getNumKids() == 0);\n    signExpr =\n        Z3ASTHandle(::Z3_fpa_get_numeral_sign_bv(e.getContext(), e.asAST()),\n                    e.getContext());\n    exponentExpr =\n        Z3ASTHandle(::Z3_fpa_get_numeral_exponent_bv(e.getContext(), e.asAST(),\n                                                     /*biased=*/true),\n                    e.getContext());\n    significandExpr = Z3ASTHandle(\n        ::Z3_fpa_get_numeral_significand_bv(e.getContext(), e.asAST()),\n        e.getContext());\n    break;\n  }\n  default:\n    llvm_unreachable(\"Unhandled floating point constant kind\");\n  }\n  assert(signExpr.isConstant());\n  assert(signExpr.getSort().isBitVectorTy());\n  assert(signExpr.isApp());\n  assert(exponentExpr.isConstant());\n  assert(exponentExpr.getSort().isBitVectorTy());\n  assert(exponentExpr.isApp());\n  assert(significandExpr.isConstant());\n  assert(significandExpr.getSort().isBitVectorTy());\n  assert(significandExpr.isApp());\n  ss << getBitVectorConstantStr(signExpr.asApp()) << \", \"\n     << getBitVectorConstantStr(exponentExpr.asApp()) << \", \"\n     << getBitVectorConstantStr(significandExpr.asApp()) << \")\";\n  return ss.str();\n}\n\nstd::string CXXProgramBuilderPassImpl::getFreshSymbol() {\n  // TODO: Do something more sophisticatd\n  static uint64_t counter = 0;\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  ss << \"jfs_ssa_\" << counter;\n  ss.flush();\n  ++counter;\n  assert(getSanitizedVariableName(underlyingString) == underlyingString);\n  assert(usedSymbols.count(underlyingString) == 0);\n  return underlyingString;\n}\n\nvoid CXXProgramBuilderPassImpl::insertSSAStmt(\n    jfs::core::Z3ASTHandle e, llvm::StringRef expr,\n    llvm::StringRef preferredSymbolName) {\n  auto assignmentTy = getOrInsertTy(e.getSort());\n  std::string requestedSymbolName;\n  if (preferredSymbolName.data() == nullptr) {\n    requestedSymbolName = getFreshSymbol();\n  } else {\n    requestedSymbolName = preferredSymbolName;\n    if (usedSymbols.count(requestedSymbolName) > 0) {\n      requestedSymbolName = getFreshSymbol();\n    }\n  }\n  llvm::StringRef usedSymbol = insertSSASymbolForExpr(e, requestedSymbolName);\n  auto assignmentStmt = std::make_shared<CXXDeclAndDefnVarStatement>(\n      getCurrentBlock().get(), assignmentTy, usedSymbol, expr);\n  getCurrentBlock()->statements.push_back(assignmentStmt);\n}\n\nbool CXXProgramBuilderPassImpl::hasBeenVisited(jfs::core::Z3ASTHandle e) const {\n  return exprToSymbolName.count(e) > 0;\n}\n\nbool CXXProgramBuilderPassImpl::shouldTraverseNode(\n    jfs::core::Z3ASTHandle e) const {\n  if (!e.isApp())\n    return true;\n\n  switch (e.asApp().getKind()) {\n  case Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN:\n  case Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY:\n  case Z3_OP_FPA_RM_TOWARD_POSITIVE:\n  case Z3_OP_FPA_RM_TOWARD_NEGATIVE:\n  case Z3_OP_FPA_RM_TOWARD_ZERO:\n    // Do not visit rounding modes\n    return false;\n  default:\n    return true;\n  }\n}\n\nvoid CXXProgramBuilderPassImpl::doDFSPostOrderTraversal(Z3ASTHandle e) {\n  // Do post-order DFS traversal. We do this non-recursively to avoid\n  // hitting any recursion bounds.\n  std::list<Z3ASTHandle> queue;\n  // Used to keep track of when we examine a node with children\n  // for a second time. This indicates that the children have been\n  // travsersed so that we can now do the \"post order\" visit\n  std::list<Z3ASTHandle> traversingBackUpQueue;\n  queue.push_front(e);\n  while (queue.size() > 0) {\n    Z3ASTHandle node = queue.front();\n    assert(node.isApp());\n\n    // Check for leaf node\n    if (node.asApp().getNumKids() == 0) {\n      queue.pop_front();\n      // Do \"post order\" visit\n      if (!hasBeenVisited(node) && shouldTraverseNode(node)) {\n        visit(node);\n      }\n      continue;\n    }\n\n    // Must be an internal node\n    if (!traversingBackUpQueue.empty() &&\n        traversingBackUpQueue.front() == node) {\n      // We are visiting the node for a second time. Do \"post order\" visit\n      queue.pop_front();\n      traversingBackUpQueue.pop_front();\n      if (!hasBeenVisited(node) && shouldTraverseNode(node)) {\n        visit(node);\n      }\n      continue;\n    }\n    // Visit an internal node for the first time. Add the children to the front\n    // of the queue but don't pop this node from the stack so we can visit it a\n    // second time when are walking back up the tree.\n    traversingBackUpQueue.push_front(node);\n    Z3AppHandle nodeAsApp = node.asApp();\n    const unsigned numKids = nodeAsApp.getNumKids();\n    for (unsigned index = 0; index < numKids; ++index) {\n      // Add the operands from right to left so that they popped\n      // off in left to right order\n      Z3ASTHandle childExpr = nodeAsApp.getKid((numKids - 1) - index);\n      // Only add the child expr to the queue if it has not been visited\n      // before. This is to avoid traversing down a large AST subtree\n      // that we've visited before.\n      if (!hasBeenVisited(childExpr) && shouldTraverseNode(node)) {\n        queue.push_front(childExpr);\n      }\n    }\n  }\n  assert(traversingBackUpQueue.size() == 0);\n}\n\nllvm::StringRef\nCXXProgramBuilderPassImpl::getSymbolFor(jfs::core::Z3ASTHandle e) const {\n  // This is a helper for visitor methods so they can grab symbols without\n  // having to check themselves that the key is present. Due to the post\n  // order DFS traversal the abort should never be called unless there's\n  // a bug in the DFS traversal or visitor methods.\n  auto it = exprToSymbolName.find(e);\n  if (it == exprToSymbolName.end()) {\n    ctx.getErrorStream()\n        << \"(error attempt to use symbol before it has been defined)\\n\";\n    abort();\n  }\n  return it->second;\n}\n\n// Visitor methods\nvoid CXXProgramBuilderPassImpl::visitUninterpretedFunc(Z3AppHandle e) {\n  // We can't really model uninterpreted functions in CXX very well.\n  // Unfortunately Z3 doesn't provide a great API for examining these\n  // so we examine the string value and try to guess what interpretation\n  // to give if we know of one. Otherwise we give up.\n  auto eAsStr = e.toStr();\n  llvm::StringRef eStrRef(eAsStr); // For better API\n\n  // TODO: We could experiment with functions here that aren't part\n  // of the SMT-LIBv2 standard (e.g. sin, cos, tan, etc...).\n\n  ctx.getErrorStream() << \"(error Unhandled uninterpreted function \\\"\"\n                       << eStrRef << \"\\\")\\n\";\n  abort();\n}\n\nvoid CXXProgramBuilderPassImpl::visitEqual(jfs::core::Z3AppHandle e) {\n  assert(e.getNumKids() == 2);\n  auto arg0 = e.getKid(0);\n  auto arg1 = e.getKid(1);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  ss << getSymbolFor(arg0) << \" == \" << getSymbolFor(arg1);\n  insertSSAStmt(e.asAST(), ss.str());\n}\nvoid CXXProgramBuilderPassImpl::visitDistinct(Z3AppHandle e) {\n  const unsigned numArgs = e.getNumKids();\n  assert(numArgs >= 2);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n\n  // FIXME: This is terrible and quadratically explodes.  It also doesn't look\n  // like the rest of our \"three address code\" style statements.\n  // Output pairwise `!=` combinations.\n  bool isFirst = true;\n  for (unsigned firstArgIndex = 0; firstArgIndex < numArgs; ++firstArgIndex) {\n    for (unsigned secondArgIndex = firstArgIndex + 1; secondArgIndex < numArgs;\n         ++secondArgIndex) {\n      auto arg0 = e.getKid(firstArgIndex);\n      auto arg1 = e.getKid(secondArgIndex);\n      if (isFirst) {\n        isFirst = false;\n      } else {\n        ss << \" && \";\n      }\n      ss << \"( \" << getSymbolFor(arg0) << \" != \" << getSymbolFor(arg1) << \" )\";\n    }\n  }\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitIfThenElse(jfs::core::Z3AppHandle e) {\n  assert(e.getNumKids() == 3);\n  auto condition = e.getKid(0);\n  auto trueExpr = e.getKid(1);\n  auto falseExpr = e.getKid(2);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  ss << \"(\" << getSymbolFor(condition) << \")?(\" << getSymbolFor(trueExpr)\n     << \"):(\" << getSymbolFor(falseExpr) << \")\";\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitImplies(jfs::core::Z3AppHandle e) {\n  assert(e.getNumKids() == 2);\n  auto antecdent = e.getKid(0);\n  auto consequent = e.getKid(1);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  // (a => b) === (!a) | b\n  ss << \"(!\" << getSymbolFor(antecdent) << \") || \" << getSymbolFor(consequent);\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitIff(jfs::core::Z3AppHandle e) {\n  assert(e.getNumKids() == 2);\n  auto arg0 = e.getKid(0);\n  auto arg1 = e.getKid(1);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  // (a <=> b) === (a == b)\n  ss << getSymbolFor(arg0) << \" == \" << getSymbolFor(arg1);\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitAnd(Z3AppHandle e) {\n  const unsigned numArgs = e.getNumKids();\n  assert(numArgs >= 2);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  for (unsigned index = 0; index < numArgs; ++index) {\n    if (index != 0)\n      ss << \" && \";\n    auto arg = e.getKid(index);\n    ss << getSymbolFor(arg);\n  }\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitOr(jfs::core::Z3AppHandle e) {\n  const unsigned numArgs = e.getNumKids();\n  assert(numArgs >= 2);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  for (unsigned index = 0; index < numArgs; ++index) {\n    if (index != 0)\n      ss << \" || \";\n    auto arg = e.getKid(index);\n    assert(exprToSymbolName.count(arg) > 0);\n    ss << getSymbolFor(arg);\n  }\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitXor(jfs::core::Z3AppHandle e) {\n  assert(e.getNumKids() == 2);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  auto arg0 = e.getKid(0);\n  auto arg1 = e.getKid(1);\n  ss << getSymbolFor(arg0) << \" ^ \" << getSymbolFor(arg1);\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitNot(jfs::core::Z3AppHandle e) {\n  assert(e.getNumKids() == 1);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  auto arg0 = e.getKid(0);\n  assert(exprToSymbolName.count(arg0) > 0);\n  ss << \"!(\" << getSymbolFor(arg0) << \")\";\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\n#define BV_UNARY_OP(NAME, CALL_NAME)                                           \\\n  void CXXProgramBuilderPassImpl::NAME(Z3AppHandle e) {                        \\\n    assert(e.getNumKids() == 1);                                               \\\n    auto arg0 = e.getKid(0);                                                   \\\n    std::string underlyingString;                                              \\\n    llvm::raw_string_ostream ss(underlyingString);                             \\\n    ss << getSymbolFor(arg0) << \".\" #CALL_NAME \"()\";                           \\\n    insertSSAStmt(e.asAST(), ss.str());                                        \\\n  }\nBV_UNARY_OP(visitBvNeg, bvneg)\nBV_UNARY_OP(visitBvNot, bvnot)\n#undef BV_UNARY_OP\n\n// Convenience macro to avoid writing lots of duplicate code\n#define BV_BIN_OP(NAME, CALL_NAME)                                             \\\n  void CXXProgramBuilderPassImpl::NAME(Z3AppHandle e) {                        \\\n    assert(e.getNumKids() == 2);                                               \\\n    auto arg0 = e.getKid(0);                                                   \\\n    auto arg1 = e.getKid(1);                                                   \\\n    std::string underlyingString;                                              \\\n    llvm::raw_string_ostream ss(underlyingString);                             \\\n    ss << getSymbolFor(arg0) << \".\" #CALL_NAME \"(\" << getSymbolFor(arg1)       \\\n       << \")\";                                                                 \\\n    insertSSAStmt(e.asAST(), ss.str());                                        \\\n  }\n\n#define BV_NARY_OP(NAME, CALL_NAME)                                            \\\n  void CXXProgramBuilderPassImpl::NAME(Z3AppHandle e) {                        \\\n    const unsigned numArgs = e.getNumKids();                                   \\\n    assert(numArgs >= 2);                                                      \\\n    std::string underlyingString;                                              \\\n    llvm::raw_string_ostream ss(underlyingString);                             \\\n    auto arg0 = e.getKid(0);                                                   \\\n    /* Correct number of opening braces*/                                      \\\n    for (unsigned index = 2; index < numArgs; ++index) {                       \\\n      ss << \"(\";                                                               \\\n    }                                                                          \\\n                                                                               \\\n    for (unsigned index = 1; index < numArgs; ++index) {                       \\\n      if (index == 1) {                                                        \\\n        ss << getSymbolFor(arg0);                                              \\\n      }                                                                        \\\n      auto argN = e.getKid(index);                                             \\\n      if (index > 1) {                                                         \\\n        /* Closing brace for previous operation */                             \\\n        ss << \")\";                                                             \\\n      }                                                                        \\\n      ss << \".\" #CALL_NAME \"(\" << getSymbolFor(argN) << \")\";                   \\\n    }                                                                          \\\n    insertSSAStmt(e.asAST(), ss.str());                                        \\\n  }\n\nBV_BIN_OP(visitBvSub, bvsub)\nBV_BIN_OP(visitBvSDiv, bvsdiv)\nBV_BIN_OP(visitBvUDiv, bvudiv)\nBV_BIN_OP(visitBvSRem, bvsrem)\nBV_BIN_OP(visitBvURem, bvurem)\nBV_BIN_OP(visitBvSMod, bvsmod)\nBV_BIN_OP(visitBvULE, bvule)\nBV_BIN_OP(visitBvSLE, bvsle)\nBV_BIN_OP(visitBvUGE, bvuge)\nBV_BIN_OP(visitBvSGE, bvsge)\nBV_BIN_OP(visitBvULT, bvult)\nBV_BIN_OP(visitBvSLT, bvslt)\nBV_BIN_OP(visitBvUGT, bvugt)\nBV_BIN_OP(visitBvSGT, bvsgt)\nBV_BIN_OP(visitBvComp, bvcomp)\nBV_BIN_OP(visitBvNand, bvnand)\nBV_BIN_OP(visitBvNor, bvnor)\nBV_BIN_OP(visitBvXnor, bvxnor)\nBV_BIN_OP(visitBvShl, bvshl)\nBV_BIN_OP(visitBvLShr, bvlshr)\nBV_BIN_OP(visitBvAShr, bvashr)\n\n// Bitvector NAry operations. Even though in SMT-LIBv2 these ops are binary Z3\n// allows n-ary versions which could be introduced by its simplication steps.\n// We assume these operations are associative so it doesn't matter the order we\n// apply them in.\nBV_NARY_OP(visitBvOr, bvor)\nBV_NARY_OP(visitBvAnd, bvand)\nBV_NARY_OP(visitBvXor, bvxor)\nBV_NARY_OP(visitBvAdd, bvadd)\nBV_NARY_OP(visitBvMul, bvmul)\n\n#undef BV_BIN_OP\n#undef BV_NARY_OP\n\nvoid CXXProgramBuilderPassImpl::visitBvRotateLeft(Z3AppHandle e) {\n  // The rotation amount is not an argument\n  assert(e.getNumKids() == 1);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  auto arg0 = e.getKid(0);\n  auto funcDecl = e.getFuncDecl();\n\n  // Get the rotation count. This is a paramter on the function\n  // declaration rather an argument in the application\n  assert(funcDecl.getNumParams() == 1);\n  assert(funcDecl.getParamKind(0) == Z3_PARAMETER_INT);\n  int rotation = funcDecl.getIntParam(0);\n\n  ss << getSymbolFor(arg0) << \".rotate_left(\" << rotation << \")\";\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitBvRotateRight(Z3AppHandle e) {\n  // The rotation amount is not an argument\n  assert(e.getNumKids() == 1);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  auto arg0 = e.getKid(0);\n  auto funcDecl = e.getFuncDecl();\n\n  // Get the rotation count. This is a paramter on the function\n  // declaration rather an argument in the application\n  assert(funcDecl.getNumParams() == 1);\n  assert(funcDecl.getParamKind(0) == Z3_PARAMETER_INT);\n  int rotation = funcDecl.getIntParam(0);\n\n  ss << getSymbolFor(arg0) << \".rotate_right(\" << rotation << \")\";\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitBvConcat(jfs::core::Z3AppHandle e) {\n  const unsigned numArgs = e.getNumKids();\n  assert(numArgs >= 2);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  auto arg0 = e.getKid(0);\n\n  // Correct number of opening braces\n  for (unsigned index = 2; index < numArgs; ++index) {\n    ss << \"(\";\n  }\n\n  for (unsigned index = 1; index < numArgs; ++index) {\n    if (index == 1) {\n      ss << getSymbolFor(arg0);\n    }\n    auto argN = e.getKid(index);\n    if (index > 1) {\n      // Closing brace for previous concat\n      ss << \")\";\n    }\n    ss << \".concat(\" << getSymbolFor(argN) << \")\";\n  }\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitBvSignExtend(Z3AppHandle e) {\n  // The extension amount is not an argument\n  assert(e.getNumKids() == 1);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  auto arg0 = e.getKid(0);\n  auto funcDecl = e.getFuncDecl();\n\n  // Get the extension count. This is a paramter on the function\n  // declaration rather an argument in the application\n  assert(funcDecl.getNumParams() == 1);\n  assert(funcDecl.getParamKind(0) == Z3_PARAMETER_INT);\n  int numberOfNewBits = funcDecl.getIntParam(0);\n\n  ss << getSymbolFor(arg0) << \".signExtend<\" << numberOfNewBits << \">()\";\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitBvZeroExtend(Z3AppHandle e) {\n  // The extension amount is not an argument\n  assert(e.getNumKids() == 1);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  auto arg0 = e.getKid(0);\n  auto funcDecl = e.getFuncDecl();\n\n  // Get the extension count. This is a paramter on the function\n  // declaration rather an argument in the application\n  assert(funcDecl.getNumParams() == 1);\n  assert(funcDecl.getParamKind(0) == Z3_PARAMETER_INT);\n  int numberOfNewBits = funcDecl.getIntParam(0);\n\n  ss << getSymbolFor(arg0) << \".zeroExtend<\" << numberOfNewBits << \">()\";\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitBvExtract(Z3AppHandle e) {\n  // The bit indices are not arguments\n  assert(e.getNumKids() == 1);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  auto arg0 = e.getKid(0);\n  auto funcDecl = e.getFuncDecl();\n\n  // Get the indicies\n  // Get the extension count. This is a paramter on the function\n  // declaration rather an argument in the application\n  assert(funcDecl.getNumParams() == 2);\n  assert(funcDecl.getParamKind(0) == Z3_PARAMETER_INT);\n  assert(funcDecl.getParamKind(1) == Z3_PARAMETER_INT);\n  int highBit = funcDecl.getIntParam(0);\n  int lowBit = funcDecl.getIntParam(1);\n  assert(highBit >= lowBit);\n\n  ss << getSymbolFor(arg0) << \".extract<\" << ((highBit - lowBit) + 1) << \">(\"\n     << highBit << \",\" << lowBit << \")\";\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitBoolConstant(Z3AppHandle e) {\n  insertSSAStmt(e.asAST(), getboolConstantStr(e));\n}\n\nvoid CXXProgramBuilderPassImpl::visitBitVector(Z3AppHandle e) {\n  insertSSAStmt(e.asAST(), getBitVectorConstantStr(e));\n}\n\n// Floating point\nvoid CXXProgramBuilderPassImpl::visitFloatingPointFromTriple(\n    jfs::core::Z3AppHandle e) {\n  assert(e.getNumKids() == 3);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  auto sort = e.getSort();\n  auto signValue = e.getKid(0);\n  auto exponentValue = e.getKid(1);\n  auto significandValue = e.getKid(2);\n  ss << \"Float<\" << sort.getFloatingPointExponentBitWidth() << \",\"\n     << sort.getFloatingPointSignificandBitWidth() << \">(\"\n     << getSymbolFor(signValue) << \", \" << getSymbolFor(exponentValue) << \", \"\n     << getSymbolFor(significandValue) << \")\";\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitFloatingPointFromIEEEBitVector(\n    Z3AppHandle e) {\n  assert(e.getNumKids() == 1);\n  auto bvExpr = e.getKid(0);\n  assert(bvExpr.getSort().isBitVectorTy());\n  auto resultSort = e.getSort();\n  assert(resultSort.isFloatingPointTy());\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  ss << \"Float<\" << resultSort.getFloatingPointExponentBitWidth() << \",\"\n     << resultSort.getFloatingPointSignificandBitWidth() << \">(\"\n     << getSymbolFor(bvExpr) << \")\";\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\n#define FP_UNARY_OP(NAME, CALL_NAME)                                       \\\n  void CXXProgramBuilderPassImpl::NAME(Z3AppHandle e) {                        \\\n    assert(e.getNumKids() == 1);                                               \\\n    auto arg = e.getKid(0);                                                    \\\n    std::string underlyingString;                                              \\\n    llvm::raw_string_ostream ss(underlyingString);                             \\\n    ss << getSymbolFor(arg) << \".\" #CALL_NAME \"()\";                            \\\n    insertSSAStmt(e.asAST(), ss.str());                                        \\\n  }\nFP_UNARY_OP(visitFloatIsNaN, isNaN)\nFP_UNARY_OP(visitFloatIsNormal, isNormal)\nFP_UNARY_OP(visitFloatIsSubnormal, isSubnormal)\nFP_UNARY_OP(visitFloatIsZero, isZero)\nFP_UNARY_OP(visitFloatIsPositive, isPositive)\nFP_UNARY_OP(visitFloatIsNegative, isNegative)\nFP_UNARY_OP(visitFloatIsInfinite, isInfinite)\nFP_UNARY_OP(visitFloatAbs, abs)\nFP_UNARY_OP(visitFloatNeg, neg)\n\n#undef FP_UNARY_OP\n\n#define FP_BIN_OP(NAME, CALL_NAME)                                             \\\n  void CXXProgramBuilderPassImpl::NAME(Z3AppHandle e) {                        \\\n    assert(e.getNumKids() == 2);                                               \\\n    auto lhs = e.getKid(0);                                                    \\\n    auto rhs = e.getKid(1);                                                    \\\n    assert(lhs.getSort().isFloatingPointTy());                                 \\\n    assert(rhs.getSort().isFloatingPointTy());                                 \\\n    std::string underlyingString;                                              \\\n    llvm::raw_string_ostream ss(underlyingString);                             \\\n    ss << getSymbolFor(lhs) << \".\" #CALL_NAME \"(\" << getSymbolFor(rhs) << \")\"; \\\n    insertSSAStmt(e.asAST(), ss.str());                                        \\\n  }\n\nFP_BIN_OP(visitFloatIEEEEquals, ieeeEquals)\nFP_BIN_OP(visitFloatLessThan, fplt)\nFP_BIN_OP(visitFloatLessThanOrEqual, fpleq)\nFP_BIN_OP(visitFloatGreaterThan, fpgt)\nFP_BIN_OP(visitFloatGreaterThanOrEqual, fpgeq)\n\nFP_BIN_OP(visitFloatRem, rem)\nFP_BIN_OP(visitFloatMin, min)\nFP_BIN_OP(visitFloatMax, max)\n\n#undef FP_BIN_OP\n\n#define FP_SPECIAL_CONST(NAME, CALL_NAME)                                      \\\n  void CXXProgramBuilderPassImpl::NAME(jfs::core::Z3AppHandle e) {             \\\n    assert(e.getNumKids() == 0);                                               \\\n    auto sort = e.getSort();                                                   \\\n    assert(sort.isFloatingPointTy());                                          \\\n    auto cxxType = getOrInsertTy(sort);                                        \\\n    std::string underlyingString;                                              \\\n    llvm::raw_string_ostream ss(underlyingString);                             \\\n    ss << cxxType->getName() << \"::\" #CALL_NAME \"()\";                          \\\n    insertSSAStmt(e.asAST(), ss.str());                                        \\\n  }\n\nFP_SPECIAL_CONST(visitFloatPositiveZero, getPositiveZero)\nFP_SPECIAL_CONST(visitFloatNegativeZero, getNegativeZero)\nFP_SPECIAL_CONST(visitFloatPositiveInfinity, getPositiveInfinity)\nFP_SPECIAL_CONST(visitFloatNegativeInfinity, getNegativeInfinity)\nFP_SPECIAL_CONST(visitFloatNaN, getNaN)\n\n#undef FP_SPECIAL_CONST\n\nvoid CXXProgramBuilderPassImpl::visitFloatingPointConstant(Z3AppHandle e) {\n  assert(e.getNumKids() == 0);\n  insertSSAStmt(e.asAST(), getFloatingPointConstantStr(e));\n}\n\nllvm::StringRef CXXProgramBuilderPassImpl::roundingModeToString(\n    jfs::core::Z3AppHandle rm) const {\n  switch (rm.getKind()) {\n  case Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN:\n    return \"JFS_RM_RNE\";\n  case Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY:\n    return \"JFS_RM_RNA\";\n  case Z3_OP_FPA_RM_TOWARD_POSITIVE:\n    return \"JFS_RM_RTP\";\n  case Z3_OP_FPA_RM_TOWARD_NEGATIVE:\n    return \"JFS_RM_RTN\";\n  case Z3_OP_FPA_RM_TOWARD_ZERO:\n    return \"JFS_RM_RTZ\";\n  default:\n    llvm_unreachable(\"Unhandled argument\");\n    return \"\";\n  }\n}\n\n#define FP_BIN_WITH_RM_OP(NAME, CALL_NAME)                                     \\\n  void CXXProgramBuilderPassImpl::NAME(Z3AppHandle e) {                        \\\n    assert(e.getNumKids() == 3);                                               \\\n    assert(e.getKid(0).isApp());                                               \\\n    auto roundingMode = roundingModeToString(e.getKid(0).asApp());             \\\n    auto lhs = e.getKid(1);                                                    \\\n    assert(lhs.getSort().isFloatingPointTy());                                 \\\n    auto rhs = e.getKid(2);                                                    \\\n    assert(rhs.getSort().isFloatingPointTy());                                 \\\n    std::string underlyingString;                                              \\\n    llvm::raw_string_ostream ss(underlyingString);                             \\\n    ss << getSymbolFor(lhs) << \".\" #CALL_NAME \"(\" << roundingMode << \", \"      \\\n       << getSymbolFor(rhs) << \")\";                                            \\\n    insertSSAStmt(e.asAST(), ss.str());                                        \\\n  }\n\nFP_BIN_WITH_RM_OP(visitFloatAdd, add)\nFP_BIN_WITH_RM_OP(visitFloatSub, sub)\nFP_BIN_WITH_RM_OP(visitFloatMul, mul)\nFP_BIN_WITH_RM_OP(visitFloatDiv, div)\n#undef FP_BIN_WITH_RM_OP\n\nvoid CXXProgramBuilderPassImpl::visitFloatFMA(Z3AppHandle e) {\n  assert(e.getNumKids() == 4);\n  assert(e.getKid(0).isApp());\n  auto roundingMode = roundingModeToString(e.getKid(0).asApp());\n  auto a = e.getKid(1);\n  auto b = e.getKid(2);\n  auto c = e.getKid(3);\n  std::string underlyingString;\n  llvm::raw_string_ostream ss(underlyingString);\n  ss << getSymbolFor(a) << \".fma(\" << roundingMode << \", \" << getSymbolFor(b)\n     << \", \" << getSymbolFor(c) << \")\";\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\n#define FP_UNARY_WITH_RM_OP(NAME, CALL_NAME)                                   \\\n  void CXXProgramBuilderPassImpl::NAME(Z3AppHandle e) {                        \\\n    assert(e.getNumKids() == 2);                                               \\\n    assert(e.getKid(0).isApp());                                               \\\n    auto roundingMode = roundingModeToString(e.getKid(0).asApp());             \\\n    auto arg = e.getKid(1);                                                    \\\n    std::string underlyingString;                                              \\\n    llvm::raw_string_ostream ss(underlyingString);                             \\\n    ss << getSymbolFor(arg) << \".\" #CALL_NAME \"(\" << roundingMode << \")\";      \\\n    insertSSAStmt(e.asAST(), ss.str());                                        \\\n  }\nFP_UNARY_WITH_RM_OP(visitFloatSqrt, sqrt)\nFP_UNARY_WITH_RM_OP(visitFloatRoundToIntegral, roundToIntegral)\n#undef FP_UNARY_WITH_RM_OP\n\nvoid CXXProgramBuilderPassImpl::visitConvertToFloatFromFloat(\n    jfs::core::Z3AppHandle e) {\n  assert(e.getNumKids() == 2);\n  assert(e.getKid(0).isApp());\n  auto roundingMode = roundingModeToString(e.getKid(0).asApp());\n  auto arg = e.getKid(1);\n  std::string underlyingString;\n  auto resultSort = e.getSort();\n  assert(resultSort.isFloatingPointTy());\n  llvm::raw_string_ostream ss(underlyingString);\n  ss << getSymbolFor(arg) << \".convertToFloat<\"\n     << resultSort.getFloatingPointExponentBitWidth() << \",\"\n     << resultSort.getFloatingPointSignificandBitWidth() << \">(\" << roundingMode\n     << \")\";\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitConvertToFloatFromUnsignedBitVector(\n    jfs::core::Z3AppHandle e) {\n  assert(e.getNumKids() == 2);\n  assert(e.getKid(0).isApp());\n  auto roundingMode = roundingModeToString(e.getKid(0).asApp());\n  auto arg = e.getKid(1);\n  auto argSort = arg.getSort();\n  assert(argSort.isBitVectorTy());\n  std::string underlyingString;\n  auto resultSort = e.getSort();\n  assert(resultSort.isFloatingPointTy());\n  auto cxxType = getOrInsertTy(resultSort);\n  llvm::raw_string_ostream ss(underlyingString);\n  ss << cxxType->getName() << \"::convertFromUnsignedBV<\"\n     << argSort.getBitVectorWidth() << \">(\" << roundingMode << \", \"\n     << getSymbolFor(arg) << \")\";\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\nvoid CXXProgramBuilderPassImpl::visitConvertToFloatFromSignedBitVector(\n    jfs::core::Z3AppHandle e) {\n  assert(e.getNumKids() == 2);\n  assert(e.getKid(0).isApp());\n  auto roundingMode = roundingModeToString(e.getKid(0).asApp());\n  auto arg = e.getKid(1);\n  auto argSort = arg.getSort();\n  assert(argSort.isBitVectorTy());\n  std::string underlyingString;\n  auto resultSort = e.getSort();\n  assert(resultSort.isFloatingPointTy());\n  auto cxxType = getOrInsertTy(resultSort);\n  llvm::raw_string_ostream ss(underlyingString);\n  ss << cxxType->getName() << \"::convertFromSignedBV<\"\n     << argSort.getBitVectorWidth() << \">(\" << roundingMode << \", \"\n     << getSymbolFor(arg) << \")\";\n  insertSSAStmt(e.asAST(), ss.str());\n}\n\n#define FP_CONVERT_TO_BV_OP(NAME, CALL_NAME)                                   \\\n  void CXXProgramBuilderPassImpl::NAME(Z3AppHandle e) {                        \\\n    assert(e.getNumKids() == 2);                                               \\\n    assert(e.getKid(0).isApp());                                               \\\n    auto roundingMode = roundingModeToString(e.getKid(0).asApp());             \\\n    auto arg = e.getKid(1);                                                    \\\n    std::string underlyingString;                                              \\\n    auto resultSort = e.getSort();                                             \\\n    assert(resultSort.isBitVectorTy());                                        \\\n    llvm::raw_string_ostream ss(underlyingString);                             \\\n    ss << getSymbolFor(arg) << \".\" #CALL_NAME \"<\"                              \\\n       << resultSort.getBitVectorWidth() << \">(\" << roundingMode << \")\";       \\\n    insertSSAStmt(e.asAST(), ss.str());                                        \\\n  }\nFP_CONVERT_TO_BV_OP(visitConvertToUnsignedBitVectorFromFloat,\n                    convertToUnsignedBV)\nFP_CONVERT_TO_BV_OP(visitConvertToSignedBitVectorFromFloat, convertToSignedBV)\n#undef FP_CONVERT_TO_BV_OP\n}\n}\n"
  },
  {
    "path": "lib/CXXFuzzingBackend/CXXProgramBuilderPassImpl.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_CXX_FUZZING_BACKEND_CXX_PROGRAM_BUILDER_PASS_IMPL_H\n#define JFS_CXX_FUZZING_BACKEND_CXX_PROGRAM_BUILDER_PASS_IMPL_H\n#include \"jfs/CXXFuzzingBackend/CXXProgram.h\"\n#include \"jfs/CXXFuzzingBackend/CXXProgramBuilderOptions.h\"\n#include \"jfs/CXXFuzzingBackend/CXXProgramBuilderPass.h\"\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Core/Z3ASTVisitor.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/Core/Z3NodeMap.h\"\nnamespace jfs {\nnamespace cxxfb {\n\nclass CXXProgramBuilderPassImpl : public jfs::core::Z3ASTVisitor {\nprivate:\n  uint64_t numberOfConstraints = 0;\n  jfs::core::JFSContext& ctx;\n  // Not unique_ptr because CXXFuzzingSolverOptions usually owns this.\n  const CXXProgramBuilderOptions* options;\n  std::shared_ptr<CXXProgram> program;\n  std::shared_ptr<jfs::fuzzingCommon::FuzzingAnalysisInfo> info;\n  CXXCodeBlockRef earlyExitBlock;\n  CXXCodeBlockRef entryPointMainBlock;\n  CXXCodeBlockRef trueBlock;\n  jfs::core::Z3SortMap<CXXTypeRef> sortToCXXTypeCache;\n\n  jfs::core::Z3ASTMap<llvm::StringRef>\n      exprToSymbolName; // References strings in `usedSymbols`.\n  std::unordered_set<std::string> usedSymbols;\n  llvm::StringRef entryPointFirstArgName;\n  llvm::StringRef entryPointSecondArgName;\n  llvm::StringRef numConstraintsSatisfiedSymbolName;\n  llvm::StringRef maxNumConstraintsSatisfiedSymbolName;\n  llvm::StringRef numInputsTriedSymbolName;\n  llvm::StringRef numWrongSizedInputsTriedSymbolName;\n  llvm::StringRef libFuzzerCustomCounterArraySymbolName;\n\n  CXXProgramBuilderPassImpl(\n      std::shared_ptr<jfs::fuzzingCommon::FuzzingAnalysisInfo> info,\n      const CXXProgramBuilderOptions* options, jfs::core::JFSContext& ctx);\n\n  bool convertModel(jfs::core::Model* m);\n  void build(const jfs::core::Query& q);\n\n  CXXCodeBlockRef getConstraintIsFalseBlock();\n  CXXCodeBlockRef getConstraintIsTrueBlock();\n  bool isTrackingNumConstraintsSatisfied() const;\n  bool isTrackingMaxNumConstraintsSatisfied() const;\n  bool isTrackingNumberOfInputsTried() const;\n  bool isTrackingNumberOfWrongSizedInputsTried() const;\n  bool isTrackingWithLibFuzzerCustomCounter() const;\n  bool isRecordingStats() const;\n  bool isTracing() const;\n  bool isUpdatingMaxNumConstraintsSatisfiedAtEnd() const;\n  CXXTypeRef getCounterTy();\n  CXXTypeRef counterTy;\n\n  // Helpers for inserting SSA variables and types\n  CXXTypeRef getOrInsertTy(jfs::core::Z3SortHandle sort);\n  std::string getSanitizedVariableName(const std::string& name);\n  llvm::StringRef insertSymbol(const std::string& symbolName);\n  llvm::StringRef insertSSASymbolForExpr(jfs::core::Z3ASTHandle e,\n                                         const std::string& symbolName);\n\n  // Function for building various parts of the CXXProgram\n  CXXFunctionDeclRef buildEntryPoint();\n  void insertHeaderIncludes();\n  void insertMaxNumConstraintsSatisfiedCounterInit();\n  void insertNumInputsCounterInit();\n  void insertNumWrongSizedInputsCounterInit();\n  void insertAtExitHandler();\n  void insertBufferSizeGuard(CXXCodeBlockRef cb);\n  void insertNumConstraintsSatisifedCounterInit(CXXCodeBlockRef cb);\n  void insertFreeVariableConstruction(CXXCodeBlockRef cb);\n  void insertConstantAssignments(CXXCodeBlockRef cb);\n  void insertBranchForConstraint(jfs::core::Z3ASTHandle constraint);\n  void insertFuzzingTarget(CXXCodeBlockRef cb);\n  void insertNumInputsTriedIncrement(CXXCodeBlockRef cb);\n  void insertLibFuzzerCustomCounterDecl();\n  void insertLibFuzzerCustomCounterInc(CXXCodeBlockRef cb);\n\n  void insertUpdateMaxNumConstraintsSatisfiedToBlock(CXXCodeBlockRef cb);\n\n  // Only let CXXProgramBuilderPass use the implementation.\n  friend class CXXProgramBuilderPass;\n\n  // Visitor and ConstantAssignment helper methods\n  const char* getboolConstantStr(jfs::core::Z3AppHandle e) const;\n  std::string getBitVectorConstantStr(jfs::core::Z3AppHandle e) const;\n  std::string getFloatingPointConstantStr(jfs::core::Z3AppHandle e) const;\n  std::string getFreshSymbol();\n  void insertSSAStmt(jfs::core::Z3ASTHandle e, llvm::StringRef expr,\n                     llvm::StringRef preferredSymbolName);\n  void insertSSAStmt(jfs::core::Z3ASTHandle e, llvm::StringRef expr) {\n    insertSSAStmt(e, expr, llvm::StringRef());\n    return;\n  }\n  void doDFSPostOrderTraversal(jfs::core::Z3ASTHandle e);\n  bool hasBeenVisited(jfs::core::Z3ASTHandle e) const;\n  CXXCodeBlockRef getCurrentBlock() { return entryPointMainBlock; }\n  llvm::StringRef getSymbolFor(jfs::core::Z3ASTHandle e) const;\n\n  // Visitor methods\n  bool shouldTraverseNode(jfs::core::Z3ASTHandle e) const;\n  llvm::StringRef roundingModeToString(jfs::core::Z3AppHandle rm) const;\n\n  void visitUninterpretedFunc(jfs::core::Z3AppHandle e) override;\n\n  // Overloaded operations\n  void visitEqual(jfs::core::Z3AppHandle e) override;\n  void visitDistinct(jfs::core::Z3AppHandle e) override;\n  void visitIfThenElse(jfs::core::Z3AppHandle e) override;\n  void visitImplies(jfs::core::Z3AppHandle e) override;\n  void visitIff(jfs::core::Z3AppHandle e) override;\n\n  // Boolean operations\n  void visitAnd(jfs::core::Z3AppHandle e) override;\n  void visitOr(jfs::core::Z3AppHandle e) override;\n  void visitXor(jfs::core::Z3AppHandle e) override;\n  void visitNot(jfs::core::Z3AppHandle e) override;\n\n  // Arithmetic BitVector operations\n  void visitBvNeg(jfs::core::Z3AppHandle e) override;\n  void visitBvAdd(jfs::core::Z3AppHandle e) override;\n  void visitBvSub(jfs::core::Z3AppHandle e) override;\n  void visitBvMul(jfs::core::Z3AppHandle e) override;\n  void visitBvSDiv(jfs::core::Z3AppHandle e) override;\n  void visitBvUDiv(jfs::core::Z3AppHandle e) override;\n  void visitBvSRem(jfs::core::Z3AppHandle e) override;\n  void visitBvURem(jfs::core::Z3AppHandle e) override;\n  void visitBvSMod(jfs::core::Z3AppHandle e) override;\n\n  // Comparison BitVector operations\n  void visitBvULE(jfs::core::Z3AppHandle e) override;\n  void visitBvSLE(jfs::core::Z3AppHandle e) override;\n  void visitBvUGE(jfs::core::Z3AppHandle e) override;\n  void visitBvSGE(jfs::core::Z3AppHandle e) override;\n  void visitBvULT(jfs::core::Z3AppHandle e) override;\n  void visitBvSLT(jfs::core::Z3AppHandle e) override;\n  void visitBvUGT(jfs::core::Z3AppHandle e) override;\n  void visitBvSGT(jfs::core::Z3AppHandle e) override;\n  void visitBvComp(jfs::core::Z3AppHandle e) override;\n\n  // Bitwise BitVector operations\n  void visitBvAnd(jfs::core::Z3AppHandle e) override;\n  void visitBvOr(jfs::core::Z3AppHandle e) override;\n  void visitBvNot(jfs::core::Z3AppHandle e) override;\n  void visitBvXor(jfs::core::Z3AppHandle e) override;\n  void visitBvNand(jfs::core::Z3AppHandle e) override;\n  void visitBvNor(jfs::core::Z3AppHandle e) override;\n  void visitBvXnor(jfs::core::Z3AppHandle e) override;\n\n  // Shift and rotation BitVector operations\n  void visitBvShl(jfs::core::Z3AppHandle e) override;\n  void visitBvLShr(jfs::core::Z3AppHandle e) override;\n  void visitBvAShr(jfs::core::Z3AppHandle e) override;\n  void visitBvRotateLeft(jfs::core::Z3AppHandle e) override;\n  void visitBvRotateRight(jfs::core::Z3AppHandle e) override;\n\n  // Sort changing BitVector operations\n  void visitBvConcat(jfs::core::Z3AppHandle e) override;\n  void visitBvSignExtend(jfs::core::Z3AppHandle e) override;\n  void visitBvZeroExtend(jfs::core::Z3AppHandle e) override;\n  void visitBvExtract(jfs::core::Z3AppHandle e) override;\n\n  // Constants\n  void visitBoolConstant(jfs::core::Z3AppHandle e) override;\n  void visitBitVector(jfs::core::Z3AppHandle e) override;\n\n  // Floating point\n  void visitFloatingPointFromTriple(jfs::core::Z3AppHandle e) override;\n  void visitFloatingPointFromIEEEBitVector(jfs::core::Z3AppHandle e) override;\n  void visitFloatIsNaN(jfs::core::Z3AppHandle e) override;\n  void visitFloatIsNormal(jfs::core::Z3AppHandle e) override;\n  void visitFloatIsSubnormal(jfs::core::Z3AppHandle e) override;\n  void visitFloatIsZero(jfs::core::Z3AppHandle e) override;\n  void visitFloatIsPositive(jfs::core::Z3AppHandle e) override;\n  void visitFloatIsNegative(jfs::core::Z3AppHandle e) override;\n  void visitFloatIsInfinite(jfs::core::Z3AppHandle e) override;\n\n  void visitFloatIEEEEquals(jfs::core::Z3AppHandle e) override;\n  void visitFloatLessThan(jfs::core::Z3AppHandle e) override;\n  void visitFloatLessThanOrEqual(jfs::core::Z3AppHandle e) override;\n  void visitFloatGreaterThan(jfs::core::Z3AppHandle e) override;\n  void visitFloatGreaterThanOrEqual(jfs::core::Z3AppHandle e) override;\n\n  void visitFloatPositiveZero(jfs::core::Z3AppHandle e) override;\n  void visitFloatNegativeZero(jfs::core::Z3AppHandle e) override;\n  void visitFloatPositiveInfinity(jfs::core::Z3AppHandle e) override;\n  void visitFloatNegativeInfinity(jfs::core::Z3AppHandle e) override;\n  void visitFloatNaN(jfs::core::Z3AppHandle e) override;\n  void visitFloatingPointConstant(jfs::core::Z3AppHandle e) override;\n\n  void visitFloatAbs(jfs::core::Z3AppHandle e) override;\n  void visitFloatNeg(jfs::core::Z3AppHandle e) override;\n  void visitFloatMin(jfs::core::Z3AppHandle e) override;\n  void visitFloatMax(jfs::core::Z3AppHandle e) override;\n  void visitFloatAdd(jfs::core::Z3AppHandle e) override;\n  void visitFloatSub(jfs::core::Z3AppHandle e) override;\n  void visitFloatMul(jfs::core::Z3AppHandle e) override;\n  void visitFloatDiv(jfs::core::Z3AppHandle e) override;\n  void visitFloatFMA(jfs::core::Z3AppHandle e) override;\n  void visitFloatSqrt(jfs::core::Z3AppHandle e) override;\n  void visitFloatRem(jfs::core::Z3AppHandle e) override;\n  void visitFloatRoundToIntegral(jfs::core::Z3AppHandle e) override;\n  void visitConvertToFloatFromFloat(jfs::core::Z3AppHandle e) override;\n  void\n  visitConvertToFloatFromUnsignedBitVector(jfs::core::Z3AppHandle e) override;\n  void\n  visitConvertToFloatFromSignedBitVector(jfs::core::Z3AppHandle e) override;\n  void\n  visitConvertToUnsignedBitVectorFromFloat(jfs::core::Z3AppHandle e) override;\n  void\n  visitConvertToSignedBitVectorFromFloat(jfs::core::Z3AppHandle e) override;\n};\n}\n}\n#endif\n"
  },
  {
    "path": "lib/CXXFuzzingBackend/ClangInvocationManager.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/CXXFuzzingBackend/ClangInvocationManager.h\"\n#include \"jfs/CXXFuzzingBackend/CXXProgram.h\"\n#include \"jfs/CXXFuzzingBackend/ClangOptions.h\"\n#include \"jfs/Config/depsVersion.h\" // For HACK\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/FuzzingCommon/SMTLIBRuntimes.h\"\n#include \"jfs/Support/CancellableProcess.h\"\n#include \"llvm/ADT/SmallVector.h\"\n#include \"llvm/Support/FileSystem.h\"\n#include \"llvm/Support/Path.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <atomic>\n#include <string>\n#include <vector>\nnamespace jfs {\nnamespace cxxfb {\n\nusing namespace jfs::core;\nusing namespace jfs::support;\n\nclass ClangInvocationManagerImpl : public jfs::support::ICancellable {\nprivate:\n  JFSContext& ctx;\n  std::atomic<bool> cancelled;\n  CancellableProcess proc;\n\npublic:\n  ClangInvocationManagerImpl(JFSContext& ctx) : ctx(ctx), cancelled(false) {}\n\n  void cancel() override {\n    cancelled = true;\n    // Cancel Clang invocation\n    IF_VERB(ctx,\n            ctx.getDebugStream() << \"(ClangInvocationManager cancel called)\\n\");\n    proc.cancel();\n  }\n\n  // FIXME: Not sure if this belongs here or in ClangOptions\n  jfs::fuzzingCommon::SMTLIBRuntimeTy\n  computeSMTLIBRuntime(const ClangOptions* options) const {\n    if (options->pureRandomFuzzer) {\n      if (options->useJFSRuntimeAsserts || options->useASan ||\n          options->useUBSan) {\n        // FIXME: We just don't build these combinations right now so we can\n        // easily fix this if desired.\n        ctx.raiseFatalError(\"Can't use pure random fuzzer with runtime asserts,\"\n                            \" ASan, or UBSan.\");\n      }\n      return jfs::fuzzingCommon::SMTLIBRuntimeTy::DEBUGSYMBOLS_OPTIMIZED;\n    }\n\n    assert((std::find(options->sanitizerCoverageOptions.cbegin(),\n                      options->sanitizerCoverageOptions.cend(),\n                      ClangOptions::SanitizerCoverageTy::TRACE_PC_GUARD) !=\n            options->sanitizerCoverageOptions.end()) &&\n           \"must use trace-pc-guard\");\n    // FIXME: We ignore `debugSymbols` and `optimizationLevel` clang options\n    // right now because we don't produce separate runtimes for these\n    // combinations.\n    if (!options->useJFSRuntimeAsserts) {\n      if (options->useASan || options->useUBSan) {\n        // FIXME: We just don't build these combinations right now so we can\n        // easily fix this. This isn't a configuration we should really be using\n        // though. If we're debugging we should really have the asserts on.\n        ctx.raiseFatalError(\"Can't use ASan/UBSan without JFS runtime asserts\");\n      }\n      return jfs::fuzzingCommon::SMTLIBRuntimeTy::\n          DEBUGSYMBOLS_OPTIMIZED_TRACEPCGUARD;\n    }\n\n    // Build has runtime asserts\n    if (options->useASan && options->useUBSan) {\n      return jfs::fuzzingCommon::SMTLIBRuntimeTy::\n          DEBUGSYMBOLS_OPTIMIZED_RUNTIMEASSERTS_ASAN_UBSAN_TRACEPCGUARD;\n    } else if (options->useASan) {\n      return jfs::fuzzingCommon::SMTLIBRuntimeTy::\n          DEBUGSYMBOLS_OPTIMIZED_RUNTIMEASSERTS_ASAN_TRACEPCGUARD;\n    } else if (options->useUBSan) {\n      return jfs::fuzzingCommon::SMTLIBRuntimeTy::\n          DEBUGSYMBOLS_OPTIMIZED_RUNTIMEASSERTS_UBSAN_TRACEPCGUARD;\n    }\n    // Just with runtime asserts\n    return jfs::fuzzingCommon::SMTLIBRuntimeTy::\n        DEBUGSYMBOLS_OPTIMIZED_RUNTIMEASSERTS_TRACEPCGUARD;\n  }\n\n  // FIXME: Not sure if this belongs here or in ClangOptions\n  std::string computeSMTLIBRuntimePath(const ClangOptions* options) const {\n    jfs::fuzzingCommon::SMTLIBRuntimeTy runtimeTy =\n        computeSMTLIBRuntime(options);\n    llvm::SmallVector<char, 256> mutablePath(options->pathToRuntimeDir.cbegin(),\n                                             options->pathToRuntimeDir.cend());\n    llvm::sys::path::append(\n        mutablePath, jfs::fuzzingCommon::getSMTLIBRuntimePath(runtimeTy));\n    std::string path(mutablePath.data(), mutablePath.size());\n    return path;\n  }\n\n  bool compile(const CXXProgram* program, llvm::StringRef sourceFile,\n               llvm::StringRef outputFile, const ClangOptions* options,\n               llvm::StringRef stdoutFile, llvm::StringRef stdErrFile) {\n    // FIXME: Implement pipe building mode.\n    assert(sourceFile.size() > 0 &&\n           \"Support for non sourceFile build not implemented\");\n\n#define CHECK_CANCELLED()                                                      \\\n  if (cancelled) {                                                             \\\n    IF_VERB(ctx,                                                               \\\n            ctx.getDebugStream() << \"(ClangInvocationManager cancelled)\\n\");   \\\n    return false;                                                              \\\n  }\n    // Cancelation point\n    CHECK_CANCELLED();\n\n    // Write source file to disk\n    std::error_code ec;\n    llvm::raw_fd_ostream sourceStream(sourceFile, ec,\n                                      llvm::sys::fs::OpenFlags::F_Excl);\n    if (ec) {\n      // Failed to open file for writing\n      // FIXME: Call `jfs::support::getMessageForFailedOpenFileForWriting()`\n      std::string underlyingString;\n      llvm::raw_string_ostream ss(underlyingString);\n      ss << \"Failed to open \" << sourceFile << \" for writing because \"\n         << ec.message();\n      ss.flush();\n      ctx.raiseFatalError(underlyingString);\n    }\n    // FIXME: We need to be able to cancel writing to the file.\n    program->print(sourceStream);\n    assert(!(sourceStream.has_error()));\n    sourceStream.close();\n\n    CHECK_CANCELLED();\n\n    // Invoke Clang\n\n    // Build up command line arguments\n    std::vector<const char*> cmdLineArgs;\n    // arg0 should be the program name itself\n    cmdLineArgs.push_back(options->pathToBinary.c_str());\n\n    // Set C++ standard\n    cmdLineArgs.push_back(\"-std=c++11\");\n\n    // Include path\n    cmdLineArgs.push_back(\"-I\");\n    cmdLineArgs.push_back(options->pathToRuntimeIncludeDir.c_str());\n\n    // Optimization level\n    switch (options->optimizationLevel) {\n    case ClangOptions::OptimizationLevel::O0:\n      cmdLineArgs.push_back(\"-O0\");\n      break;\n    case ClangOptions::OptimizationLevel::O1:\n      cmdLineArgs.push_back(\"-O1\");\n      break;\n    case ClangOptions::OptimizationLevel::O2:\n      cmdLineArgs.push_back(\"-O2\");\n      break;\n    case ClangOptions::OptimizationLevel::O3:\n      cmdLineArgs.push_back(\"-O3\");\n      break;\n    default:\n      llvm_unreachable(\"Unhandled optimization level\");\n    }\n\n    // Debug symbols\n    if (options->debugSymbols) {\n      cmdLineArgs.push_back(\"-g\");\n    }\n\n    // TODO: Do we actually need this?\n    cmdLineArgs.push_back(\"-fno-omit-frame-pointer\");\n\n    // ASan\n    if (options->useASan) {\n      cmdLineArgs.push_back(\"-fsanitize=address\");\n    }\n\n    // UBSan\n    if (options->useUBSan) {\n      cmdLineArgs.push_back(\"-fsanitize=undefined\");\n    }\n    // SanitizerCoverage options\n    if (options->pureRandomFuzzer) {\n      assert(options->sanitizerCoverageOptions.size() == 0);\n    } else {\n      assert(options->sanitizerCoverageOptions.size() > 0);\n    }\n    for (const auto& sanitizerCovOpt : options->sanitizerCoverageOptions) {\n      switch (sanitizerCovOpt) {\n      case ClangOptions::SanitizerCoverageTy::TRACE_PC_GUARD:\n        cmdLineArgs.push_back(\"-fsanitize-coverage=trace-pc-guard\");\n        break;\n      case ClangOptions::SanitizerCoverageTy::TRACE_CMP:\n        cmdLineArgs.push_back(\"-fsanitize-coverage=trace-cmp\");\n        break;\n      default:\n        llvm_unreachable(\"Unhandled SanitizerCoverageTy\");\n      }\n    }\n\n    // JFS runtime asserts\n    if (options->useJFSRuntimeAsserts) {\n      cmdLineArgs.push_back(\"-DENABLE_JFS_RUNTIME_ASSERTS\");\n    }\n\n    // Source file to compile\n    cmdLineArgs.push_back(sourceFile.data());\n\n    // Link against SMTLIB runtime\n    std::string smtlibRuntimePath = computeSMTLIBRuntimePath(options);\n    cmdLineArgs.push_back(smtlibRuntimePath.c_str());\n\n    // Link against LibFuzzer\n    cmdLineArgs.push_back(options->pathToLibFuzzerLib.c_str());\n\n    // Set output path\n    cmdLineArgs.push_back(\"-o\");\n    cmdLineArgs.push_back(outputFile.data());\n\n    if (ctx.getVerbosity() > 0) {\n      ctx.getDebugStream() << \"(ClangInvocationManager \\n [\";\n      for (const auto& arg : cmdLineArgs) {\n        ctx.getDebugStream() << \"\\\"\" << arg << \"\\\", \";\n      }\n      ctx.getDebugStream() << \"]\\n)\\n\";\n    }\n\n    // Null terminates args\n    cmdLineArgs.push_back(nullptr);\n\n    CHECK_CANCELLED();\n    std::vector<llvm::StringRef> redirects;\n    if (stdoutFile.size() > 0 || stdErrFile.size() > 0) {\n      // Redirect stdin\n      redirects.push_back(\"\");         // STDIN goes to /dev/null\n      redirects.push_back(stdoutFile); // STDOUT\n      redirects.push_back(stdErrFile); // STDERR\n    }\n    int exitCode = proc.execute(\n        /*program=*/options->pathToBinary,\n        /*args=*/cmdLineArgs,\n        /*redirects=*/redirects);\n\n    if (exitCode == 0) {\n      // Success\n      return true;\n    }\n    if (exitCode == -2) {\n      // Cancelled\n      return false;\n    }\n    std::string underlyingString;\n    llvm::raw_string_ostream ss(underlyingString);\n    ss << \"Clang invocation has exit code \" << exitCode;\n    ss.flush();\n    ctx.raiseError(underlyingString);\n    return false;\n  }\n};\n\nClangInvocationManager::ClangInvocationManager(JFSContext& ctx)\n    : impl(new ClangInvocationManagerImpl(ctx)) {}\n\nClangInvocationManager::~ClangInvocationManager() {}\n\nvoid ClangInvocationManager::cancel() { impl->cancel(); }\n\nbool ClangInvocationManager::compile(const CXXProgram* program,\n                                     llvm::StringRef sourceFile,\n                                     llvm::StringRef outputFile,\n                                     const ClangOptions* options,\n                                     llvm::StringRef stdOutFile,\n                                     llvm::StringRef stdErrFile) {\n  return impl->compile(program, sourceFile, outputFile, options, stdOutFile,\n                       stdErrFile);\n}\n}\n}\n"
  },
  {
    "path": "lib/CXXFuzzingBackend/ClangOptions.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/CXXFuzzingBackend/ClangOptions.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"llvm/ADT/SmallVector.h\"\n#include \"llvm/ADT/Twine.h\"\n#include \"llvm/Support/FileSystem.h\"\n#include \"llvm/Support/Path.h\"\nnamespace jfs {\nnamespace cxxfb {\n\nClangOptions::ClangOptions(bool pureRandomFuzzer)\n    : pathToBinary(\"\"), pathToRuntimeDir(\"\"), pathToRuntimeIncludeDir(\"\"),\n      pathToLibFuzzerLib(\"\"), optimizationLevel(OptimizationLevel::O0),\n      debugSymbols(false), useASan(false), useUBSan(false),\n      useJFSRuntimeAsserts(false), pureRandomFuzzer(pureRandomFuzzer) {}\n\nbool ClangOptions::checkPaths(jfs::core::JFSContext& ctx) const {\n  bool ok = true;\n  if (!llvm::sys::fs::exists(pathToBinary)) {\n    IF_VERB(ctx,\n            ctx.getWarningStream() << \"(warning path to clang \\\"\"\n                                   << pathToBinary << \"\\\" does not exist)\\n\");\n    ok = false;\n  }\n\n  if (!llvm::sys::fs::exists(pathToLibFuzzerLib)) {\n    IF_VERB(ctx,\n            ctx.getWarningStream()\n                << \"(warning path to LibFuzzer library \\\"\" << pathToLibFuzzerLib\n                << \"\\\" does not exist)\\n\");\n    ok = false;\n  }\n  bool isDirectory = llvm::sys::fs::is_directory(pathToRuntimeIncludeDir);\n  if (!isDirectory) {\n    IF_VERB(ctx,\n            ctx.getWarningStream()\n                << \"(warning path to runtime include directory \\\"\"\n                << pathToRuntimeIncludeDir << \"\\\" does not exist)\\n\");\n    ok = false;\n  }\n  isDirectory = llvm::sys::fs::is_directory(pathToRuntimeDir);\n  if (!isDirectory) {\n    IF_VERB(ctx,\n            ctx.getWarningStream()\n                << \"(warning path to runtime directory \\\"\" << pathToRuntimeDir\n                << \"\\\" does not exist)\\n\");\n    ok = false;\n  }\n  return ok;\n}\n\nClangOptions::ClangOptions(llvm::StringRef pathToExecutable,\n                           LibFuzzerBuildType lfbt, bool pureRandomFuzzer)\n    : ClangOptions(pureRandomFuzzer) {\n  // Try to infer paths\n  assert(pathToExecutable.data() != nullptr);\n  assert(pathToExecutable.size() > 0);\n  assert(llvm::sys::path::is_absolute(llvm::Twine(pathToExecutable)));\n  llvm::SmallVector<char, 256> mutablePath(pathToExecutable.begin(),\n                                           pathToExecutable.end());\n  // Remove \"/bin/jfs\"\n  llvm::sys::path::remove_filename(mutablePath);\n  llvm::sys::path::remove_filename(mutablePath);\n\n  // Set path to runtime directory\n  llvm::sys::path::append(mutablePath, \"runtime\");\n  pathToRuntimeDir = std::string(mutablePath.data(), mutablePath.size());\n\n  // Set path to Clang\n  llvm::sys::path::append(mutablePath, \"bin\", \"clang++\");\n  pathToBinary = std::string(mutablePath.data(), mutablePath.size());\n\n  // Remove \"bin/clang++\"\n  llvm::sys::path::remove_filename(mutablePath);\n  llvm::sys::path::remove_filename(mutablePath);\n\n  // Set path to runtime include directory\n  llvm::sys::path::append(mutablePath, \"include\");\n  pathToRuntimeIncludeDir = std::string(mutablePath.data(), mutablePath.size());\n  // Remove \"include\"\n  llvm::sys::path::remove_filename(mutablePath);\n\n  // Set path to fuzzer library\n  std::string fuzzerDirPrefix;\n  if (pureRandomFuzzer) {\n    fuzzerDirPrefix = \"LibPureRandomFuzzer_\";\n  } else {\n    fuzzerDirPrefix = \"LibFuzzer_\";\n  }\n  switch (lfbt) {\n  case LibFuzzerBuildType::REL_WITH_DEB_INFO:\n    llvm::sys::path::append(mutablePath, fuzzerDirPrefix + \"RelWithDebInfo\");\n    break;\n  default:\n    llvm_unreachable(\"Unhandled fuzzer build type\");\n  }\n  // FIXME: This won't work on Windows\n  if (pureRandomFuzzer) {\n    llvm::sys::path::append(mutablePath, \"libPureRandomFuzzer.a\");\n  } else {\n    llvm::sys::path::append(mutablePath, \"Fuzzer\", \"libLLVMFuzzer.a\");\n  }\n  pathToLibFuzzerLib = std::string(mutablePath.data(), mutablePath.size());\n}\n\nvoid ClangOptions::appendSanitizerCoverageOption(SanitizerCoverageTy opt) {\n  sanitizerCoverageOptions.push_back(opt);\n}\n\nvoid ClangOptions::dump() const { print(llvm::errs()); }\n\nvoid ClangOptions::print(llvm::raw_ostream& os) const {\n  os << \"pathToBinary: \\\"\" << pathToBinary << \"\\\"\\n\";\n  os << \"pathToRuntimeIncludeDir: \\\"\" << pathToRuntimeIncludeDir << \"\\\"\\n\";\n  os << \"pathToLibFuzzerLib: \\\"\" << pathToLibFuzzerLib << \"\\\"\\n\";\n  os << \"optimizationLevel: \";\n  switch (optimizationLevel) {\n#define HANDLE_LEVEL(X)                                                        \\\n  case OptimizationLevel::X:                                                   \\\n    os << #X << \"\\n\";                                                          \\\n    break;\n    HANDLE_LEVEL(O0);\n    HANDLE_LEVEL(O1);\n    HANDLE_LEVEL(O2);\n    HANDLE_LEVEL(O3);\n#undef HANDLE_LEVEL\n  }\n  os << \"debug symbols:\" << (debugSymbols ? \"true\" : \"false\") << \"\\n\";\n  os << \"useASan: \" << (useASan ? \"true\" : \"false\") << \"\\n\";\n  os << \"useUBSan: \" << (useUBSan ? \"true\" : \"false\") << \"\\n\";\n  os << \"sanitizerCoverageOptions:\";\n  for (const auto& opt : sanitizerCoverageOptions) {\n    switch (opt) {\n    case SanitizerCoverageTy::TRACE_PC_GUARD:\n      os << \" TRACE_PC_GUARD\";\n      break;\n    case SanitizerCoverageTy::TRACE_CMP:\n      os << \" TRACE_CMP\";\n      break;\n    default:\n      llvm_unreachable(\"Unhandled sanitizer coverage option\");\n    }\n  }\n  os << \"\\n\";\n  os << \"pureRandomFuzzer: \" << (pureRandomFuzzer ? \"true\" : \"false\") << \"\\n\";\n}\n}\n}\n"
  },
  {
    "path": "lib/CXXFuzzingBackend/CmdLine/CMakeLists.txt",
    "content": "jfs_add_component(JFSCXXFuzzingBackendCmdLine\n  ClangOptionsBuilder.cpp\n  CommandLineCategory.cpp\n  CXXProgramBuilderOptionsBuilder.cpp\n)\n\ntarget_link_libraries(JFSCXXFuzzingBackendCmdLine\n  PUBLIC\n  JFSCXXFuzzingBackend\n)\njfs_get_llvm_components(llvm_components support)\n\ntarget_link_libraries(JFSCXXFuzzingBackendCmdLine PUBLIC ${llvm_components})\n"
  },
  {
    "path": "lib/CXXFuzzingBackend/CmdLine/CXXProgramBuilderOptionsBuilder.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/CXXFuzzingBackend/CmdLine/CXXProgramBuilderOptionsBuilder.h\"\n#include \"jfs/CXXFuzzingBackend/CmdLine/CommandLineCategory.h\"\n#include \"llvm/Support/CommandLine.h\"\n#include <string>\n\nusing namespace jfs::cxxfb;\nusing namespace jfs::core;\n\nnamespace {\n\nllvm::cl::opt<bool> RecordMaxNumSatisfiedConstraints(\n    \"record-max-num-satisfied-constraints\",\n    llvm::cl::desc(\n        \"Record the maximum number of satisfied constraints (default: false)\"),\n    llvm::cl::init(false), llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\n\nllvm::cl::opt<bool> RecordNumberOfInputs(\n    \"record-num-inputs\",\n    llvm::cl::desc(\"Record the number of inputs tried (default: false)\"),\n    llvm::cl::init(false), llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\n\nllvm::cl::opt<bool> RecordNumberOfWrongSizedInputs(\n    \"record-num-wrong-sized-inputs\",\n    llvm::cl::desc(\n        \"Record the number of wrong sized inputs tried (default: false)\"),\n    llvm::cl::init(false), llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\n\nllvm::cl::opt<CXXProgramBuilderOptions::BranchEncodingTy> BranchEncoding(\n    \"branch-encoding\", llvm::cl::desc(\"Encoding used for constraint branches\"),\n    llvm::cl::values(\n        clEnumValN(CXXProgramBuilderOptions::BranchEncodingTy::FAIL_FAST,\n                   \"fail-fast\",\n                   \"Stop trying input at first unsat branch (default)\"),\n        clEnumValN(CXXProgramBuilderOptions::BranchEncodingTy::TRY_ALL,\n                   \"try-all\", \"Serebrayany encoding. Evaluate all branches\")\n#ifdef __linux__\n            ,\n        clEnumValN(CXXProgramBuilderOptions::BranchEncodingTy::TRY_ALL_IMNCSF,\n                   \"try-all-imncsf\",\n                   \"Cadar encoding. Like `try-all` except increases in the \"\n                   \"maximum number of \"\n                   \"constraints solved are treated as increase in coverage \"\n                   \"(linux only)\")\n#endif\n            ),\n    llvm::cl::init(CXXProgramBuilderOptions::BranchEncodingTy::FAIL_FAST),\n    llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\n\nllvm::cl::opt<bool> TraceIncreaseMaxNumSatisfiedConstraints(\n    \"trace-max-num-satisfied-constraints\",\n    llvm::cl::desc(\"Report when the maximum number of satisfied constraints \"\n                   \"increases (default: false)\"),\n    llvm::cl::init(false), llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\n\nllvm::cl::opt<bool> TraceWrongSizedInputs(\n    \"trace-wrong-sized-inputs\",\n    llvm::cl::desc(\"Report when the fuzzer tries an input of the wrong size \"\n                   \"increases (default: true)\"),\n    llvm::cl::init(true), llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\n}\n\nnamespace jfs {\nnamespace cxxfb {\nnamespace cl {\n\nstd::unique_ptr<CXXProgramBuilderOptions>\nbuildCXXProgramBuilderOptionsFromCmdLine() {\n  std::unique_ptr<CXXProgramBuilderOptions> opts(\n      new CXXProgramBuilderOptions());\n\n  opts->setRecordMaxNumSatisfiedConstraints(RecordMaxNumSatisfiedConstraints);\n  opts->setRecordNumberOfInputs(RecordNumberOfInputs);\n  opts->setRecordNumberOfWrongSizedInputs(RecordNumberOfWrongSizedInputs);\n  opts->setBranchEncoding(BranchEncoding);\n  opts->setTraceIncreaseMaxNumSatisfiedConstraints(\n      TraceIncreaseMaxNumSatisfiedConstraints);\n  opts->setTraceWrongSizedInputs(TraceWrongSizedInputs);\n\n  return opts;\n}\n} // namespace cl\n} // namespace cxxfb\n} // namespace jfs\n"
  },
  {
    "path": "lib/CXXFuzzingBackend/CmdLine/ClangOptionsBuilder.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/CXXFuzzingBackend/CmdLine/ClangOptionsBuilder.h\"\n#include \"jfs/CXXFuzzingBackend/CmdLine/CommandLineCategory.h\"\n#include \"llvm/Support/CommandLine.h\"\n#include <string>\n\nusing namespace jfs::cxxfb;\nusing namespace jfs::core;\n\nnamespace {\nllvm::cl::opt<ClangOptions::LibFuzzerBuildType> LibFuzzerBuildTypeToLinkAgainst(\n    \"libfuzzer-build-type\",\n    llvm::cl::desc(\"The build type of LibFuzzer to link against\"),\n    llvm::cl::values(\n        clEnumValN(ClangOptions::LibFuzzerBuildType::REL_WITH_DEB_INFO,\n                   \"RELWITHDEBINFO\", \"Release with debug symbols (default)\")),\n    llvm::cl::init(ClangOptions::LibFuzzerBuildType::REL_WITH_DEB_INFO),\n    llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\n\nllvm::cl::opt<ClangOptions::OptimizationLevel> OptimizationLevel(\n    llvm::cl::desc(\"Optimization level\"),\n    llvm::cl::values(clEnumValN(ClangOptions::OptimizationLevel::O0, \"O0\",\n                                \"No optimization (default)\"),\n                     clEnumValN(ClangOptions::OptimizationLevel::O1, \"O1\", \"\"),\n                     clEnumValN(ClangOptions::OptimizationLevel::O2, \"O2\", \"\"),\n                     clEnumValN(ClangOptions::OptimizationLevel::O3, \"O3\", \"\")),\n    llvm::cl::init(ClangOptions::OptimizationLevel::O0),\n    llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\n\nllvm::cl::opt<bool> DebugSymbols(\n    \"g\", llvm::cl::desc(\"Build with debug symbols (default: false)\"),\n    llvm::cl::init(false), llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\n\nllvm::cl::opt<bool> UseAsan(\n    \"asan\", llvm::cl::desc(\"Build with AddressSanitizer (default: false)\"),\n    llvm::cl::init(false), llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\n\nllvm::cl::opt<bool> UseUBSan(\n    \"ubsan\",\n    llvm::cl::desc(\"Build with Undefined Behavior Sanitizer (default: false)\"),\n    llvm::cl::init(false), llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\n\nllvm::cl::list<ClangOptions::SanitizerCoverageTy> SanitizerCoverageOptions(\n    \"sanitizer-coverage\",\n    llvm::cl::desc(\"Sanitizer Coverage flags. Comma separated\"),\n    llvm::cl::CommaSeparated,\n    llvm::cl::values(\n        clEnumValN(ClangOptions::SanitizerCoverageTy::TRACE_PC_GUARD,\n                   \"trace-pc-guard\", \"Trace PC Guard (default)\"),\n        clEnumValN(ClangOptions::SanitizerCoverageTy::TRACE_CMP, \"trace-cmp\",\n                   \"Trace Comparisions. Must be used in conjuction with \"\n                   \"another coverage type.\")),\n    llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\n\nllvm::cl::opt<bool> UseJFSRuntimeAsserts(\n    \"runtime-asserts\",\n    llvm::cl::desc(\"Build JFS runtime asserts enabled (default: false)\"),\n    llvm::cl::init(false), llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\n\nllvm::cl::opt<bool> PureRandomFuzzer(\n    \"libfuzzer-pure-random\",\n    llvm::cl::desc(\"Replace LibFuzzer with LibPureRandomFuzzer for use as a \"\n                   \"control group (default: false)\"),\n    llvm::cl::init(false), llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\n}\n\nnamespace jfs {\nnamespace cxxfb {\nnamespace cl {\n\nstd::unique_ptr<ClangOptions>\nbuildClangOptionsFromCmdLine(llvm::StringRef pathToExecutable) {\n  // Tell ClangOptions to try and infer all paths\n  std::unique_ptr<ClangOptions> clangOptions(\n      new ClangOptions(pathToExecutable, LibFuzzerBuildTypeToLinkAgainst,\n                       PureRandomFuzzer));\n\n  // Sanitizer coverage options\n  if (SanitizerCoverageOptions.size() == 0) {\n    // Default (depends on fuzzer library)\n    if (!PureRandomFuzzer) {\n      clangOptions->appendSanitizerCoverageOption(\n          ClangOptions::SanitizerCoverageTy::TRACE_PC_GUARD);\n    }\n  } else {\n    for (const auto& flag : SanitizerCoverageOptions) {\n      clangOptions->appendSanitizerCoverageOption(flag);\n    }\n  }\n\n  // Debug symbols\n  clangOptions->debugSymbols = DebugSymbols;\n  // Optimization level\n  clangOptions->optimizationLevel = OptimizationLevel;\n  // ASan\n  clangOptions->useASan = UseAsan;\n  // UBSan\n  clangOptions->useUBSan = UseUBSan;\n  // JFS runtime asserts\n  clangOptions->useJFSRuntimeAsserts = UseJFSRuntimeAsserts;\n\n  return clangOptions;\n}\n}\n}\n}\n"
  },
  {
    "path": "lib/CXXFuzzingBackend/CmdLine/CommandLineCategory.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/CXXFuzzingBackend/CmdLine/CommandLineCategory.h\"\n\nnamespace jfs {\nnamespace cxxfb {\nnamespace cl {\n\nllvm::cl::OptionCategory\n    CommandLineCategory(\"CXXFuzzingBackend\",\n                        \"Options that control the CXXFuzzingBackend\");\n}\n}\n}\n"
  },
  {
    "path": "lib/CXXFuzzingBackend/JFSCXXProgramStat.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/CXXFuzzingBackend/JFSCXXProgramStat.h\"\n\nnamespace jfs {\nnamespace cxxfb {\n\nJFSCXXProgramStat::JFSCXXProgramStat(llvm::StringRef name)\n    : jfs::support::JFSStat(CXX_PROGRAM, name) {}\nJFSCXXProgramStat::~JFSCXXProgramStat() {}\n\nvoid JFSCXXProgramStat::printYAML(llvm::ScopedPrinter& sp) const {\n  sp.indent();\n  auto& os = sp.getOStream();\n  os << \"\\n\";\n  sp.startLine() << \"name: \" << getName() << \"\\n\";\n  sp.startLine() << \"num_constraints: \" << numConstraints << \"\\n\";\n  sp.startLine() << \"num_entry_func_statements: \" << numEntryFuncStatements\n                 << \"\\n\";\n  sp.startLine() << \"num_free_vars: \" << numFreeVars << \"\\n\";\n  sp.startLine() << \"buffer_stored_width: \" << bufferStoredWidth << \"\\n\";\n  sp.startLine() << \"buffer_type_width: \" << bufferTypeWidth << \"\\n\";\n  sp.startLine() << \"num_equality_sets: \" << numEqualitySets << \"\\n\";\n  sp.unindent();\n}\n}\n}\n"
  },
  {
    "path": "lib/Core/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\njfs_add_component(JFSCore\n  JFSContext.cpp\n  Model.cpp\n  ModelValidator.cpp\n  Query.cpp\n  RNG.cpp\n  SimpleModel.cpp\n  SMTLIB2Parser.cpp\n  Solver.cpp\n  ToolErrorHandler.cpp\n  Z3ASTVisitor.cpp\n  Z3Node.cpp\n  Z3NodeUtil.cpp\n)\n# Needed for command line support\njfs_get_llvm_components(llvm_components support)\n\ntarget_link_libraries(JFSCore PUBLIC JFSSupport \"${Z3_LIBRARIES}\" ${llvm_components})\n"
  },
  {
    "path": "lib/Core/JFSContext.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Core/RNG.h\"\n#include \"jfs/Support/StatisticsManager.h\"\n#include \"llvm/Support/raw_os_ostream.h\"\n#include <assert.h>\n#include <list>\n#include <mutex>\n#include <unordered_map>\n\nnamespace {\n// Forward decl\nvoid z3_error_handler(Z3_context ctx, Z3_error_code ec);\n}\n\nnamespace jfs {\nnamespace core {\n\nJFSContextErrorHandler::JFSContextErrorHandler() {}\nJFSContextErrorHandler::~JFSContextErrorHandler() {}\n\nclass JFSContextImpl {\npublic:\n  // Really this should be private but seeing as this decl is\n  // in an implementation file it doesn't matter.\n  JFSContext* publicContext;\n  std::list<JFSContextErrorHandler*> errorHandlers;\n  Z3_context z3Ctx;\n  JFSContextConfig config;\n  std::unique_ptr<jfs::support::StatisticsManager> stats;\n  RNG rng;\n  // Global to all instances\n  static std::unordered_map<Z3_context, jfs::core::JFSContextImpl*>\n      activeContexts;\n  static std::mutex activeContextsMutex; // protects\npublic:\n  JFSContextImpl(JFSContext* ctx, const JFSContextConfig& ctxCfg)\n      : publicContext(ctx), config(ctxCfg), stats(nullptr),\n        rng(ctxCfg.seed) {\n    std::lock_guard<std::mutex> lock(activeContextsMutex);\n    // TODO use ctxCfg\n    Z3_config z3Cfg = Z3_mk_config();\n    // Do ref counting of ASTs ourselves\n    z3Ctx = Z3_mk_context_rc(z3Cfg);\n    Z3_set_error_handler(z3Ctx, z3_error_handler);\n    // When emitting Z3 expressions make them SMT-LIBv2 compliant\n    Z3_set_ast_print_mode(z3Ctx, Z3_PRINT_SMTLIB2_COMPLIANT);\n    Z3_del_config(z3Cfg);\n    auto success = activeContexts.insert(std::make_pair(z3Ctx, this));\n    assert(success.second && \"insert failed\");\n\n    // Set up stats\n    if (config.gathericStatistics) {\n      stats.reset(new jfs::support::StatisticsManager());\n    }\n  }\n\n  ~JFSContextImpl() {\n    std::lock_guard<std::mutex> lock(activeContextsMutex);\n    // We have to delete stats before we destroy the Z3\n    // context because it might be holding on to Z3 objects.\n    stats.reset(nullptr);\n    auto it = activeContexts.find(z3Ctx);\n    if (it == activeContexts.end()) {\n      llvm::errs() << \"Context not registered\\n\";\n      abort();\n    }\n    activeContexts.erase(it);\n    Z3_del_context(z3Ctx);\n  }\n\n  // Don't allow copying\n  JFSContextImpl(const JFSContextImpl&) = delete;\n  JFSContextImpl(const JFSContextImpl&&) = delete;\n  JFSContextImpl& operator=(const JFSContextImpl&) = delete;\n\n  bool registerErrorHandler(JFSContextErrorHandler* h) {\n    errorHandlers.push_front(h);\n    return true;\n  }\n\n  bool unRegisterErrorHandler(JFSContextErrorHandler* h) {\n    bool removed = false;\n    for (auto bi = errorHandlers.begin(), be = errorHandlers.end(); bi != be;\n         ++bi) {\n      if (*bi == h) {\n        removed = true;\n        errorHandlers.erase(bi);\n        break;\n      }\n    }\n    return removed;\n  }\n  void z3ErrorHandler(Z3_error_code ec) {\n    // Call the error handlers in order.\n    for (auto bi = errorHandlers.begin(), be = errorHandlers.end(); bi != be;\n         ++bi) {\n      JFSContextErrorHandler::ErrorAction action =\n          (*bi)->handleZ3error(*publicContext, ec);\n      if (action == JFSContextErrorHandler::STOP) {\n        return;\n      }\n    }\n\n    // Default behaviour\n    getErrorStream() << \"JFSContext: Received unhandled Z3 error \\\"\"\n                     << Z3_get_error_msg(z3Ctx, ec) << \"\\\"\\n\";\n    abort();\n  }\n\n  // TODO: Rethink this API.\n  unsigned getVerbosity() const { return config.verbosity; }\n  // Message streams\n  // TODO: Make these customisable\n  llvm::raw_ostream& getErrorStream() { return llvm::errs(); }\n  llvm::raw_ostream& getWarningStream() { return llvm::errs(); }\n  llvm::raw_ostream& getDebugStream() { return llvm::errs(); }\n\n  // FIXME: Should check compiler supports attribute\n  // Unlike Z3 errors it is guaranteed that execution will\n  // not leave this function.\n  __attribute__((noreturn)) void raiseFatalError(llvm::StringRef msg) {\n    // Call the error handlers in order.\n    for (const auto& eh : errorHandlers) {\n      auto action = eh->handleFatalError(*publicContext, msg);\n      if (action == JFSContextErrorHandler::STOP) {\n        break;\n      }\n    }\n    // Guarantee that execution does not continue\n    abort();\n  }\n\n  void raiseError(llvm::StringRef msg) {\n    // Call the error handlers in order.\n    for (const auto& eh : errorHandlers) {\n      auto action = eh->handleFatalError(*publicContext, msg);\n      if (action == JFSContextErrorHandler::STOP) {\n        return;\n      }\n    }\n  }\n\n  jfs::support::StatisticsManager* getStats() const { return stats.get(); }\n  const JFSContextConfig& getConfig() const { return config; }\n};\n\nstd::unordered_map<Z3_context, jfs::core::JFSContextImpl*>\n    JFSContextImpl::activeContexts;\nstd::mutex JFSContextImpl::activeContextsMutex;\n}\n}\n\nnamespace {\n// We can't give Z3 a pointer to member function so instead this global\n// function handles calling the right JFSContext\nvoid z3_error_handler(Z3_context ctx, Z3_error_code ec) {\n  std::lock_guard<std::mutex> lock(\n      jfs::core::JFSContextImpl::activeContextsMutex);\n  // Find the appropriate JFSContextImpl and notify of error\n  auto it = jfs::core::JFSContextImpl::activeContexts.find(ctx);\n  if (it == jfs::core::JFSContextImpl::activeContexts.end()) {\n    llvm::errs() << \"Context not registered\\n\";\n    abort();\n  }\n  it->second->z3ErrorHandler(ec);\n}\n}\n\nnamespace jfs {\nnamespace core {\n\n// JFSContext\n\nJFSContext::JFSContext(const JFSContextConfig& ctxCfg)\n    : impl(new JFSContextImpl(this, ctxCfg)) {}\n\nJFSContext::~JFSContext() {}\n\nbool JFSContext::operator==(const JFSContext& other) const {\n  // We don't allow copying of a JFSContext so the only\n  // way a context can be the same is if it has the same\n  // memory address.\n  return this == &(other);\n}\n\nbool JFSContext::registerErrorHandler(JFSContextErrorHandler *h) {\n  return impl->registerErrorHandler(h);\n}\n\nbool JFSContext::unRegisterErrorHandler(JFSContextErrorHandler *h) {\n  return impl->unRegisterErrorHandler(h);\n}\n\nvoid JFSContext::raiseFatalError(llvm::StringRef msg) {\n  impl->raiseFatalError(msg);\n}\n\nvoid JFSContext::raiseError(llvm::StringRef msg) { impl->raiseError(msg); }\n\nZ3_context JFSContext::getZ3Ctx() const { return impl->z3Ctx; }\n\nunsigned JFSContext::getVerbosity() const { return impl->config.verbosity; }\n\nllvm::raw_ostream &JFSContext::getErrorStream() {\n  return impl->getErrorStream();\n}\n\nllvm::raw_ostream &JFSContext::getWarningStream() {\n  return impl->getWarningStream();\n}\n\nllvm::raw_ostream &JFSContext::getDebugStream() {\n  return impl->getDebugStream();\n}\n\njfs::support::StatisticsManager* JFSContext::getStats() const {\n  return impl->getStats();\n}\n\nconst JFSContextConfig& JFSContext::getConfig() const {\n  return impl->getConfig();\n}\n\nRNG& JFSContext::getRNG() const { return impl->rng; }\n}\n}\n"
  },
  {
    "path": "lib/Core/Model.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Core/Model.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <string>\n\nnamespace {\njfs::core::ModelPrintOptions defaultModelPrintOptions;\n}\n\nnamespace jfs {\nnamespace core {\n\nModel::Model(JFSContext& ctx) : ctx(ctx) {}\nModel::~Model() {}\n\nJFSContext& Model::getContext() { return ctx; }\n\nZ3ASTHandle Model::getAssignmentFor(Z3FuncDeclHandle funcDecl) {\n  return getRepr().getAssignmentFor(funcDecl);\n}\n\nbool Model::hasAssignmentFor(Z3FuncDeclHandle decl) {\n  return getRepr().hasAssignmentFor(decl);\n}\n\nbool Model::addAssignmentFor(Z3FuncDeclHandle decl, Z3ASTHandle e,\n                             bool allowOverwrite) {\n  return getRepr().addAssignmentFor(decl, e, allowOverwrite);\n}\n\nZ3ASTHandle Model::evaluate(Z3ASTHandle e, bool modelCompletion) {\n  return getRepr().evaluate(e, modelCompletion);\n}\n\nstd::string Model::getSMTLIBString(ModelPrintOptions* opts) {\n  if (opts == nullptr) {\n    // Use default options if none provided.\n    opts = &defaultModelPrintOptions;\n  }\n  std::string storage;\n  llvm::raw_string_ostream ss(storage);\n  ss << \"(\"; // Model opening bracket\n  if (opts->useModelKeyword) {\n    // This doesn't seem to be mentioned in the SMT-LIB v2.5 or v2.6\n    // standard but Z3 seems to do it.\n    ss << \"model \";\n  }\n  if (!(opts->sortDecls)) {\n    // Fast path. Just use Z3's API\n    ss << z3Model.toStr();\n  } else {\n    // Need to collect assignments and sort them by decl name\n    using AssignmentPairTy = std::pair<Z3FuncDeclHandle, Z3ASTHandle>;\n    std::vector<AssignmentPairTy> assignments;\n    uint64_t numAssignments = z3Model.getNumAssignments();\n    assignments.reserve(numAssignments);\n    for (uint64_t index = 0; index < numAssignments; ++index) {\n      auto decl = z3Model.getVariableDeclForIndex(index);\n      auto assignment = z3Model.getAssignmentFor(decl);\n      assignments.emplace_back(AssignmentPairTy(decl, assignment));\n    }\n    // Now sort the assignments\n    std::sort(assignments.begin(), assignments.end(),\n              [](const AssignmentPairTy& a, const AssignmentPairTy& b) {\n                return a.first.getName() < b.first.getName();\n              });\n    const char* indent = \"  \";\n    if (assignments.size() > 0)\n      ss << \"\\n\";\n    // Now print the assignments in order\n    for (auto& assignmentPair : assignments) {\n      auto& decl = assignmentPair.first;\n      auto& assignment = assignmentPair.second;\n      // TODO: Add options to ModelPrintOptions to control how we show\n      // constants (e.g. the format of bitvectors).\n      ss << indent << \"(define-fun \" << decl.getName() << \" () \"\n         << decl.getSort().toStr() << \" \" << assignment.toStr() << \")\\n\";\n    }\n  }\n  ss << \")\"; // Model closing bracket\n  return ss.str();\n}\n\nbool Model::replaceRepr(Z3ModelHandle replacement) {\n  if (replacement.isNull()) {\n    return false;\n  }\n  if (replacement.getContext() != z3Model.getContext()) {\n    return false;\n  }\n  z3Model = replacement;\n  return true;\n}\n\nZ3ASTHandle Model::getDefaultValueFor(Z3SortHandle sort) {\n  switch (sort.getKind()) {\n  case Z3_BOOL_SORT: {\n    return Z3ASTHandle::getTrue(sort.getContext());\n  }\n  case Z3_FLOATING_POINT_SORT: {\n    return Z3ASTHandle::getFloatZero(sort);\n  }\n  case Z3_BV_SORT: {\n    return Z3ASTHandle::getBVZero(sort);\n  }\n  default: { llvm_unreachable(\"Unhandled sort\"); }\n  }\n}\n\n} // namespace core\n} // namespace jfs\n"
  },
  {
    "path": "lib/Core/ModelValidator.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Alastair Donaldson\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Core/ModelValidator.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include \"jfs/Core/Z3NodeUtil.h\"\n#include \"llvm/Support/raw_ostream.h\"\n\nnamespace {\njfs::core::ModelValidationOptions defaultModelValidationOptions;\n}\n\nnamespace jfs {\nnamespace core {\n\nconst char*\nValidationFailureInfo::reasonAsString(ValidationFailureInfo::ReasonTy reason) {\n  switch (reason) {\n#define RET_REASON(X)                                                          \\\n  case ValidationFailureInfo::ReasonTy::X:                                     \\\n    return #X\n    RET_REASON(NO_REASON);\n    RET_REASON(EVALUATED_TO_FALSE);\n    RET_REASON(EVALUATED_TO_NON_CONSTANT);\n    RET_REASON(EVALUATED_TO_NON_BOOL_SORT);\n  default:\n    llvm_unreachable(\"Unhandled ValidationFailureInfo::ReasonTy\");\n#undef RET_REASON\n  }\n}\n\nValidationFailureInfo::ValidationFailureInfo(ReasonTy reason, uint64_t index,\n                                             Z3ASTHandle constraint,\n                                             Model* model)\n    : reason(reason), index(index), constraint(constraint), model(model) {}\n\nValidationFailureInfo::ValidationFailureInfo()\n    : reason(ValidationFailureInfo::NO_REASON), index(0), constraint(),\n      model(nullptr) {}\n\nModelValidator::ModelValidator() {}\nModelValidator::~ModelValidator() {}\n\nvoid ModelValidator::reset() { failures.clear(); }\n\nstd::string ModelValidator::toStr() const {\n  std::string storage;\n  llvm::raw_string_ostream ss(storage);\n  ss << \"(ModelValidator \" << getNumberOfFailures() << \" failures\";\n  if (getNumberOfFailures() == 0) {\n    ss << \")\\n\";\n    return ss.str();\n  }\n  // There were failures\n  ss << \"\\n\";\n  for (const auto& failure : failures) {\n    // TODO: Give a better diagnosis\n    ss << \"constraint \" << failure.index << \" : \"\n       << ValidationFailureInfo::reasonAsString(failure.reason) << \"\\n\";\n  }\n  ss << \")\\n\";\n  return ss.str();\n}\n\nbool ModelValidator::validate(const Query& q, Model* m,\n                              const ModelValidationOptions* options) {\n  if (m == nullptr) {\n    return false;\n  }\n  if (options == nullptr) {\n    options = &defaultModelValidationOptions;\n  }\n  JFSContext& ctx = q.getContext();\n  Z3FuncDeclSet foundDecls;\n  if (options->warnOnVariablesMissingAssignment) {\n    // Collect the variables used in the query\n    Z3NodeUtil::collectFuncDecls(foundDecls, q.constraints.begin(),\n                                 q.constraints.end());\n    for (const auto& decl : foundDecls) {\n      if (!m->hasAssignmentFor(decl)) {\n        // TODO: Should we add an option to turn this into a failure?\n        // A missing assignment doesn't necessarily indicate a problem.\n        // A missing assignment usually means that any assignment should do.\n        // Are there any cases where it doesn't?\n        ctx.getWarningStream()\n            << \"(warning model is missing assignment for \" << decl.toStr()\n            << \" )\\n\";\n      }\n    }\n  }\n  for (uint64_t index = 0; index < q.constraints.size(); ++index) {\n    Z3ASTHandle constraint = q.constraints[index];\n    Z3ASTHandle evaluation = m->evaluate(constraint, /*modelCompletion=*/true);\n    IF_VERB(ctx, ctx.getDebugStream()\n                     << \"(ModelValidator constraint index \" << index\n                     << \" evaluated to \" << evaluation.toStr() << \")\\n\");\n    if (!evaluation.isConstant()) {\n      // Should be a constant\n      failures.emplace_back(ValidationFailureInfo::EVALUATED_TO_NON_CONSTANT,\n                            index, constraint, m);\n      continue;\n    }\n    if (!evaluation.getSort().isBoolTy()) {\n      failures.emplace_back(ValidationFailureInfo::EVALUATED_TO_NON_BOOL_SORT,\n                            index, constraint, m);\n      continue;\n    }\n    // Check the constraint evaluated to true\n    if (evaluation.isFalse()) {\n      failures.emplace_back(ValidationFailureInfo::EVALUATED_TO_FALSE, index,\n                            constraint, m);\n    }\n\n    // Constraint evaluated to true\n    assert(evaluation.isTrue());\n  }\n  return true;\n}\n\n} // namespace core\n} // namespace jfs\n"
  },
  {
    "path": "lib/Core/Query.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Core/Query.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include \"jfs/Core/Z3NodeUtil.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <algorithm>\n#include <list>\n\nnamespace jfs {\nnamespace core {\n\nllvm::raw_ostream& operator<<(llvm::raw_ostream& os, const Query& q) {\n  q.print(os);\n  return os;\n}\n\nQuery::Query(JFSContext &ctx) : ctx(ctx) {}\n\nQuery::~Query() {}\n\nQuery::Query(const Query &other) : ctx(other.ctx) {\n  this->constraints.reserve(other.constraints.size());\n  this->constraints.insert(this->constraints.begin(),\n                           other.constraints.cbegin(),\n                           other.constraints.cend());\n}\n\nvoid Query::dump() const {\n  llvm::errs() << *this;\n}\n\nvoid Query::collectFuncDecls(Z3FuncDeclSet& variables) const {\n  std::list<Z3ASTHandle> workList;\n  for (auto bi = constraints.begin(), be = constraints.end(); bi != be; ++bi) {\n    workList.push_front(*bi);\n  }\n  Z3NodeUtil::collectFuncDecls(variables, workList);\n}\n\nvoid Query::print(llvm::raw_ostream& os) const {\n  Z3_context z3Ctx = ctx.getZ3Ctx();\n\n  // Do DFS to collect variables\n  jfs::core::Z3FuncDeclSet variables; // Use a set to avoid duplicates\n  collectFuncDecls(variables);\n\n  // Created a sorted list of variables for printing\n  std::vector<Z3FuncDeclHandle> sortedVariables(variables.begin(),\n                                                variables.end());\n  std::sort(sortedVariables.begin(), sortedVariables.end(),\n            [](const Z3FuncDeclHandle &a, const Z3FuncDeclHandle &b) {\n              Z3_symbol aName = ::Z3_get_decl_name(a.getContext(), a);\n              Z3_symbol bName = ::Z3_get_decl_name(b.getContext(), b);\n              // std::string Allocation is necessary because\n              // ::Z3_get_symbol_string uses a static\n              // allocated buffer that changes between calls.\n              std::string aStr(::Z3_get_symbol_string(a.getContext(), aName));\n              std::string bStr(::Z3_get_symbol_string(b.getContext(), bName));\n              return aStr < bStr;\n            });\n  // Print variables\n  os << \"; Start decls (\" << variables.size() << \")\\n\";\n  for (auto vi = sortedVariables.begin(), ve = sortedVariables.end(); vi != ve;\n       ++vi) {\n    Z3ASTHandle asAst = Z3ASTHandle(::Z3_func_decl_to_ast(z3Ctx, *vi), z3Ctx);\n    // FIXME: should really use .toStr() method but I want to avoid alloc\n    // overhead for now.\n    os << ::Z3_ast_to_string(z3Ctx, asAst) << \"\\n\";\n  }\n  os << \"; End decls\\n\";\n  // Print constraints\n  os << \"; Start constraints (\" << constraints.size() << \")\\n\";\n  for (auto bi = constraints.begin(), be = constraints.end(); bi != be; ++bi) {\n    // FIXME: should really use .toStr() method but I want to avoid alloc\n    // overhead for now.\n    os << \"(assert \" << ::Z3_ast_to_string(z3Ctx, *bi) << \")\\n\";\n  }\n  os << \"; End constraints\\n\";\n}\n\nbool Query::areSame(std::vector<Z3ASTHandle> &a, std::vector<Z3ASTHandle> &b,\n                    bool ignoreOrder) {\n  if (a.size() != b.size())\n    return false;\n\n  if (ignoreOrder) {\n    Z3ASTSet aExpr(a.cbegin(), a.cend());\n    for (auto ci = b.cbegin(), ce = b.cend(); ci != ce; ++ci) {\n      if (aExpr.count(*ci) == 0)\n        return false;\n    }\n    return true;\n  }\n\n  // Do order sensitive comparison\n  for (unsigned index = 0; index < a.size(); ++index) {\n    Z3ASTHandle aExpr = a[index];\n    Z3ASTHandle bExpr = b[index];\n    if (!aExpr.isStructurallyEqualTo(bExpr))\n      return false;\n  }\n  return true;\n}\n}\n}\n"
  },
  {
    "path": "lib/Core/RNG.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#include \"jfs/Core/RNG.h\"\n#include <random>\n\nnamespace jfs {\nnamespace core {\n\nuint64_t RNG::generate(uint64_t limit) {\n  std::uniform_int_distribution<uint64_t> distribution(0, limit - 1);\n  return distribution(generator);\n}\n\n} // jfs\n} // core"
  },
  {
    "path": "lib/Core/SMTLIB2Parser.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Core/SMTLIB2Parser.h\"\n#include \"jfs/Core/ScopedJFSContextErrorHandler.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include \"z3.h\"\n#include \"llvm/Support/MemoryBuffer.h\"\n#include <assert.h>\n\nusing namespace jfs::core;\n\nnamespace {\nvoid addConstraints(std::shared_ptr<Query> q, Z3ASTHandle constraint) {\n  if (!constraint.isAppOf(Z3_OP_AND)) {\n    // Not a top-level and\n    q->constraints.push_back(constraint);\n    return;\n  }\n  assert(constraint.isApp());\n  Z3AppHandle app = constraint.asApp();\n  unsigned numArgs = app.getNumKids();\n  assert(numArgs >= 2 && \"Unexpected number of args\");\n  for (unsigned index = 0; index < numArgs; ++index) {\n    q->constraints.push_back(app.getKid(index));\n  }\n}\n}\n\nnamespace jfs {\nnamespace core {\nSMTLIB2Parser::SMTLIB2Parser(JFSContext &ctx) : ctx(ctx), errorCount(0) {}\nSMTLIB2Parser::~SMTLIB2Parser() {}\n\nstd::shared_ptr<Query> SMTLIB2Parser::parseFile(llvm::StringRef fileName) {\n  Z3ASTHandle constraint;\n  Z3_context z3Ctx = ctx.getZ3Ctx();\n  ScopedJFSContextErrorHandler errorHandler(ctx, this);\n  constraint = Z3ASTHandle(Z3_parse_smtlib2_file(z3Ctx, fileName.str().c_str(),\n                                                 /*num_sorts=*/0,\n                                                 /*sort_names=*/0,\n                                                 /*sorts=*/0,\n                                                 /*num_decls=*/0,\n                                                 /*decl_names=*/0,\n                                                 /*decls=*/0),\n                           z3Ctx);\n  if (errorCount > 0) {\n    return nullptr;\n  }\n\n  // FIXME: We have no way of parsing solver options\n  // and SMT-LIB commands.\n  std::shared_ptr<Query> query(new Query(ctx));\n  addConstraints(query, constraint);\n  return query;\n}\n\nstd::shared_ptr<Query> SMTLIB2Parser::parseStr(llvm::StringRef str) {\n  Z3_context z3Ctx = ctx.getZ3Ctx();\n  Z3ASTHandle constraint;\n  ScopedJFSContextErrorHandler errorHandler(ctx, this);\n  constraint = Z3ASTHandle(Z3_parse_smtlib2_string(z3Ctx, str.data(),\n                                                   /*num_sorts=*/0,\n                                                   /*sort_names=*/0,\n                                                   /*sorts=*/0,\n                                                   /*num_decls=*/0,\n                                                   /*decl_names=*/0,\n                                                   /*decls=*/0),\n                           z3Ctx);\n  if (errorCount > 0) {\n    return nullptr;\n  }\n\n  // FIXME: We have no way of parsing solver options\n  // and SMT-LIB commands.\n  std::shared_ptr<Query> query(new Query(ctx));\n  addConstraints(query, constraint);\n  return query;\n}\n\nJFSContextErrorHandler::ErrorAction\nSMTLIB2Parser::handleZ3error(JFSContext &ctx, Z3_error_code ec) {\n  ++errorCount;\n  return JFSContextErrorHandler::CONTINUE;\n}\n\nJFSContextErrorHandler::ErrorAction\nSMTLIB2Parser::handleFatalError(JFSContext& ctx, llvm::StringRef msg) {\n  ++errorCount;\n  // Let another handler deal with this.\n  return JFSContextErrorHandler::CONTINUE;\n}\n\nJFSContextErrorHandler::ErrorAction\nSMTLIB2Parser::handleGenericError(JFSContext& ctx, llvm::StringRef msg) {\n  ++errorCount;\n  // Let another handler deal with this.\n  return JFSContextErrorHandler::CONTINUE;\n}\n\nstd::shared_ptr<Query>\nSMTLIB2Parser::parseMemoryBuffer(std::unique_ptr<llvm::MemoryBuffer> buffer) {\n  llvm::StringRef strRef = buffer->getBuffer();\n  return parseStr(strRef);\n}\n\nunsigned SMTLIB2Parser::getErrorCount() const { return errorCount; }\n\nvoid SMTLIB2Parser::resetErrorCount() { errorCount = 0; }\n}\n}\n"
  },
  {
    "path": "lib/Core/SimpleModel.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Alastair Donaldson\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Core/SimpleModel.h\"\n\nnamespace jfs {\nnamespace core {\n\nSimpleModel::SimpleModel(JFSContext& ctx) : Model(ctx) {\n  z3Model = Z3ModelHandle(::Z3_mk_model(ctx.getZ3Ctx()), ctx.getZ3Ctx());\n}\n} // namespace core\n} // namespace jfs\n"
  },
  {
    "path": "lib/Core/Solver.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Core/Solver.h\"\n\nnamespace jfs {\n  namespace core {\n\n  SolverResponse::SolverResponse(SolverSatisfiability sat) : sat(sat) {}\n  SolverResponse::~SolverResponse() {}\n\n  Solver::Solver(std::unique_ptr<SolverOptions> options, JFSContext& ctx)\n      : options(std::move(options)), ctx(ctx) {}\n\n  Solver::~Solver() {}\n\n  const SolverOptions* Solver::getOptions() const { return options.get(); }\n\n  llvm::StringRef SolverResponse::getSatString(SolverSatisfiability sat) {\n    switch (sat) {\n      case SolverResponse::SAT:\n        return \"sat\";\n      case SolverResponse::UNSAT:\n        return \"unsat\";\n      case SolverResponse::UNKNOWN:\n        return \"unknown\";\n      default:\n        llvm_unreachable(\"unknown sat type\");\n    }\n    return \"unknown\";\n  }\n}\n}\n"
  },
  {
    "path": "lib/Core/ToolErrorHandler.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Core/ToolErrorHandler.h\"\n#include \"jfs/Core/IfVerbose.h\"\n\nnamespace jfs {\nnamespace core {\n\nJFSContextErrorHandler::ErrorAction\nToolErrorHandler::handleZ3error(JFSContext& ctx, Z3_error_code ec) {\n  auto msg = Z3_get_error_msg(ctx.getZ3Ctx(), ec);\n  if (strcmp(msg, \"canceled\") == 0 && ignoreCanceled) {\n    // Ignore\n    IF_VERB(ctx, ctx.getDebugStream() << \"(ignore \\\"Z3 canceled event\\\")\\n\");\n    return JFSContextErrorHandler::STOP;\n  }\n\n  ctx.getErrorStream() << \"(error \\\"\" << msg << \"\\\")\\n\";\n  exit(1);\n  return JFSContextErrorHandler::STOP; // Unreachable.\n}\n\nJFSContextErrorHandler::ErrorAction\nToolErrorHandler::handleFatalError(JFSContext& ctx, llvm::StringRef msg) {\n  ctx.getErrorStream() << \"(error \\\"\" << msg << \"\\\")\\n\";\n  exit(1);\n  return JFSContextErrorHandler::STOP; // Unreachable.\n}\n\nJFSContextErrorHandler::ErrorAction\nToolErrorHandler::handleGenericError(JFSContext& ctx, llvm::StringRef msg) {\n  // Just treat as a fatal error\n  return handleFatalError(ctx, msg);\n}\n}\n}\n"
  },
  {
    "path": "lib/Core/Z3ASTVisitor.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Core/Z3ASTVisitor.h\"\n#include \"llvm/Support/ErrorHandling.h\"\n#include \"llvm/Support/Compiler.h\"\n\nnamespace jfs {\nnamespace core {\n\nZ3ASTVisitor::Z3ASTVisitor() {}\n\nZ3ASTVisitor::~Z3ASTVisitor() {}\n\n// Macro to avoid accidental drop through and typos\n#define ACTION(X)                                                              \\\n  {                                                                            \\\n    X;                                                                         \\\n    return;                                                                    \\\n  }\n// Dispatch to appropriate visitor method\nvoid Z3ASTVisitor::visit(Z3ASTHandle e) {\n  assert(e.isApp() && \"expr should be an application\");\n  Z3AppHandle asApp = e.asApp();\n  switch (asApp.getKind()) {\n  case Z3_OP_TRUE:\n    ACTION(visitBoolConstant(asApp))\n  case Z3_OP_FALSE:\n    ACTION(visitBoolConstant(asApp))\n  case Z3_OP_BNUM:\n    ACTION(visitBitVector(asApp))\n  case Z3_OP_FPA_NUM:\n    ACTION(visitFloatingPointConstant(asApp))\n  // Overloaded operations\n  case Z3_OP_EQ:\n    ACTION(visitEqual(asApp))\n  case Z3_OP_DISTINCT:\n    ACTION(visitDistinct(asApp))\n  case Z3_OP_ITE:\n    ACTION(visitIfThenElse(asApp))\n  // Boolean operations\n  case Z3_OP_AND:\n    ACTION(visitAnd(asApp))\n  case Z3_OP_OR:\n    ACTION(visitOr(asApp))\n  case Z3_OP_XOR:\n    ACTION(visitXor(asApp))\n  case Z3_OP_NOT:\n    ACTION(visitNot(asApp))\n  case Z3_OP_IMPLIES:\n    ACTION(visitImplies(asApp))\n  case Z3_OP_IFF:\n    ACTION(visitIff(asApp))\n  // Arithmetic BitVector operations\n  case Z3_OP_BNEG:\n    ACTION(visitBvNeg(asApp))\n  case Z3_OP_BADD:\n    ACTION(visitBvAdd(asApp))\n  case Z3_OP_BSUB:\n    ACTION(visitBvSub(asApp))\n  case Z3_OP_BMUL:\n    ACTION(visitBvMul(asApp))\n  case Z3_OP_BSDIV_I:\n    LLVM_FALLTHROUGH;\n  case Z3_OP_BSDIV:\n    ACTION(visitBvSDiv(asApp))\n  case Z3_OP_BUDIV:\n    LLVM_FALLTHROUGH;\n  case Z3_OP_BUDIV_I:\n    ACTION(visitBvUDiv(asApp))\n  case Z3_OP_BSREM_I:\n    LLVM_FALLTHROUGH;\n  case Z3_OP_BSREM:\n    ACTION(visitBvSRem(asApp))\n  case Z3_OP_BUREM_I:\n    LLVM_FALLTHROUGH;\n  case Z3_OP_BUREM:\n    ACTION(visitBvURem(asApp))\n  case Z3_OP_BSMOD_I:\n    LLVM_FALLTHROUGH;\n  case Z3_OP_BSMOD:\n    ACTION(visitBvSMod(asApp))\n  // Comparison BitVector operations\n  case Z3_OP_ULEQ:\n    ACTION(visitBvULE(asApp))\n  case Z3_OP_SLEQ:\n    ACTION(visitBvSLE(asApp))\n  case Z3_OP_UGEQ:\n    ACTION(visitBvUGE(asApp))\n  case Z3_OP_SGEQ:\n    ACTION(visitBvSGE(asApp))\n  case Z3_OP_ULT:\n    ACTION(visitBvULT(asApp))\n  case Z3_OP_SLT:\n    ACTION(visitBvSLT(asApp))\n  case Z3_OP_UGT:\n    ACTION(visitBvUGT(asApp))\n  case Z3_OP_SGT:\n    ACTION(visitBvSGT(asApp))\n  case Z3_OP_BCOMP:\n    ACTION(visitBvComp(asApp))\n  // Bitwise BitVector operations\n  case Z3_OP_BAND:\n    ACTION(visitBvAnd(asApp))\n  case Z3_OP_BOR:\n    ACTION(visitBvOr(asApp))\n  case Z3_OP_BNOT:\n    ACTION(visitBvNot(asApp))\n  case Z3_OP_BXOR:\n    ACTION(visitBvXor(asApp))\n  case Z3_OP_BNAND:\n    ACTION(visitBvNand(asApp))\n  case Z3_OP_BNOR:\n    ACTION(visitBvNor(asApp))\n  case Z3_OP_BXNOR:\n    ACTION(visitBvXnor(asApp))\n  // Shift and rotation BitVector operations\n  case Z3_OP_BSHL:\n    ACTION(visitBvShl(asApp))\n  case Z3_OP_BLSHR:\n    ACTION(visitBvLShr(asApp))\n  case Z3_OP_BASHR:\n    ACTION(visitBvAShr(asApp))\n  case Z3_OP_ROTATE_LEFT:\n    ACTION(visitBvRotateLeft(asApp))\n  case Z3_OP_ROTATE_RIGHT:\n    ACTION(visitBvRotateRight(asApp))\n  // Sort changing BitVector operations\n  case Z3_OP_CONCAT:\n    ACTION(visitBvConcat(asApp))\n  case Z3_OP_SIGN_EXT:\n    ACTION(visitBvSignExtend(asApp))\n  case Z3_OP_ZERO_EXT:\n    ACTION(visitBvZeroExtend(asApp))\n  case Z3_OP_EXTRACT:\n    ACTION(visitBvExtract(asApp))\n  // TODO: Add more application kinds\n  // Floating point operations\n  case Z3_OP_FPA_FP:\n    ACTION(visitFloatingPointFromTriple(asApp));\n  case Z3_OP_FPA_TO_FP: {\n    if (asApp.getNumKids() == 1) {\n      assert(asApp.getKid(0).getSort().isBitVectorTy());\n      visitFloatingPointFromIEEEBitVector(asApp);\n      return;\n    }\n    assert(asApp.getNumKids() == 2);\n    assert(asApp.getKid(0).getSort().getKind() == Z3_ROUNDING_MODE_SORT);\n    auto argSort = asApp.getKid(1).getSort();\n    if (argSort.isFloatingPointTy()) {\n      visitConvertToFloatFromFloat(asApp);\n    } else {\n      assert(argSort.isBitVectorTy());\n      visitConvertToFloatFromSignedBitVector(asApp);\n    }\n    return;\n  }\n  case Z3_OP_FPA_TO_FP_UNSIGNED:\n    ACTION(visitConvertToFloatFromUnsignedBitVector(asApp))\n  case Z3_OP_FPA_IS_NAN:\n    ACTION(visitFloatIsNaN(asApp))\n  case Z3_OP_FPA_IS_NORMAL:\n    ACTION(visitFloatIsNormal(asApp))\n  case Z3_OP_FPA_IS_SUBNORMAL:\n    ACTION(visitFloatIsSubnormal(asApp))\n  case Z3_OP_FPA_IS_ZERO:\n    ACTION(visitFloatIsZero(asApp))\n  case Z3_OP_FPA_IS_POSITIVE:\n    ACTION(visitFloatIsPositive(asApp))\n  case Z3_OP_FPA_IS_NEGATIVE:\n    ACTION(visitFloatIsNegative(asApp))\n  case Z3_OP_FPA_IS_INF:\n    ACTION(visitFloatIsInfinite(asApp))\n  case Z3_OP_FPA_EQ:\n    ACTION(visitFloatIEEEEquals(asApp))\n  case Z3_OP_FPA_LT:\n    ACTION(visitFloatLessThan(asApp))\n  case Z3_OP_FPA_LE:\n    ACTION(visitFloatLessThanOrEqual(asApp))\n  case Z3_OP_FPA_GT:\n    ACTION(visitFloatGreaterThan(asApp))\n  case Z3_OP_FPA_GE:\n    ACTION(visitFloatGreaterThanOrEqual(asApp))\n  case Z3_OP_FPA_PLUS_ZERO:\n    ACTION(visitFloatPositiveZero(asApp))\n  case Z3_OP_FPA_MINUS_ZERO:\n    ACTION(visitFloatNegativeZero(asApp))\n  case Z3_OP_FPA_PLUS_INF:\n    ACTION(visitFloatPositiveInfinity(asApp))\n  case Z3_OP_FPA_MINUS_INF:\n    ACTION(visitFloatNegativeInfinity(asApp))\n  case Z3_OP_FPA_NAN:\n    ACTION(visitFloatNaN(asApp))\n  case Z3_OP_FPA_ABS:\n    ACTION(visitFloatAbs(asApp))\n  case Z3_OP_FPA_NEG:\n    ACTION(visitFloatNeg(asApp))\n  case Z3_OP_FPA_MIN:\n    ACTION(visitFloatMin(asApp))\n  case Z3_OP_FPA_MAX:\n    ACTION(visitFloatMax(asApp))\n  case Z3_OP_FPA_ADD:\n    ACTION(visitFloatAdd(asApp))\n  case Z3_OP_FPA_SUB:\n    ACTION(visitFloatSub(asApp))\n  case Z3_OP_FPA_MUL:\n    ACTION(visitFloatMul(asApp))\n  case Z3_OP_FPA_DIV:\n    ACTION(visitFloatDiv(asApp))\n  case Z3_OP_FPA_FMA:\n    ACTION(visitFloatFMA(asApp))\n  case Z3_OP_FPA_SQRT:\n    ACTION(visitFloatSqrt(asApp))\n  case Z3_OP_FPA_REM:\n    ACTION(visitFloatRem(asApp))\n  case Z3_OP_FPA_ROUND_TO_INTEGRAL:\n    ACTION(visitFloatRoundToIntegral(asApp))\n  case Z3_OP_FPA_TO_UBV:\n    ACTION(visitConvertToUnsignedBitVectorFromFloat(asApp))\n  case Z3_OP_FPA_TO_SBV:\n    ACTION(visitConvertToSignedBitVectorFromFloat(asApp))\n  case Z3_OP_UNINTERPRETED:\n    ACTION(visitUninterpretedFunc(asApp))\n  case Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN:\n  case Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY:\n  case Z3_OP_FPA_RM_TOWARD_POSITIVE:\n  case Z3_OP_FPA_RM_TOWARD_NEGATIVE:\n  case Z3_OP_FPA_RM_TOWARD_ZERO:\n  default:\n    llvm_unreachable(\"unsupported kind\");\n  }\n#undef ACTION\n}\n}\n}\n"
  },
  {
    "path": "lib/Core/Z3Node.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/Core/Model.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <assert.h>\n\nnamespace jfs {\nnamespace core {\n\ntemplate <> void Z3NodeHandle<Z3_sort>::dump() const {\n  llvm::errs() << \"Z3SortHandle:\\n\" << toStr() << \"\\n\";\n}\ntemplate <> std::string Z3NodeHandle<Z3_sort>::toStr() const {\n  // FIXME: We need to grab a lock over all calls to `Z3_*_to_string()`\n  // to make this thread safe.\n  return ::Z3_sort_to_string(context, node);\n}\n\ntemplate <> void Z3NodeHandle<Z3_ast>::dump() const {\n  llvm::errs() << \"Z3ASTHandle:\\n\" << toStr() << \"\\n\";\n}\ntemplate <> std::string Z3NodeHandle<Z3_ast>::toStr() const {\n  // FIXME: We need to grab a lock over all calls to `Z3_*_to_string()`\n  // to make this thread safe.\n  return ::Z3_ast_to_string(context, node);\n}\n\ntemplate <> void Z3NodeHandle<Z3_app>::dump() const {\n  llvm::errs() << \"Z3AppHandle:\\n\" << toStr() << \"\\n\";\n}\ntemplate <> std::string Z3NodeHandle<Z3_app>::toStr() const {\n  // FIXME: We need to grab a lock over all calls to `Z3_*_to_string()`\n  // to make this thread safe.\n  return ::Z3_ast_to_string(context, ::Z3_app_to_ast(context, node));\n}\n\ntemplate <> void Z3NodeHandle<Z3_func_decl>::dump() const {\n  llvm::errs() << \"Z3FuncDeclHandle:\\n\" << toStr() << \"\\n\";\n}\ntemplate <> std::string Z3NodeHandle<Z3_func_decl>::toStr() const {\n  // FIXME: We need to grab a lock over all calls to `Z3_*_to_string()`\n  // to make this thread safe.\n  return ::Z3_ast_to_string(context, ::Z3_func_decl_to_ast(context, node));\n}\n\ntemplate <> void Z3NodeHandle<Z3_solver>::dump() const {\n  llvm::errs() << \"Z3SolverHandle:\\n\" << toStr() << \"\\n\";\n}\ntemplate <> std::string Z3NodeHandle<Z3_solver>::toStr() const {\n  // FIXME: We need to grab a lock over all calls to `Z3_*_to_string()`\n  // to make this thread safe.\n  return ::Z3_solver_to_string(context, node);\n}\n\ntemplate <> void Z3NodeHandle<Z3_params>::dump() const {\n  llvm::errs() << \"Z3ParamsHandle:\\n\" << toStr() << \"\\n\";\n}\ntemplate <> std::string Z3NodeHandle<Z3_params>::toStr() const {\n  // FIXME: We need to grab a lock over all calls to `Z3_*_to_string()`\n  // to make this thread safe.\n  return ::Z3_params_to_string(context, node);\n}\n\n// Z3ModelHandle helper methods\ntemplate <> void Z3NodeHandle<Z3_model>::dump() const {\n  llvm::errs() << \"Z3ModelHandle:\\n\" << toStr() << \"\\n\";\n}\ntemplate <> std::string Z3NodeHandle<Z3_model>::toStr() const {\n  // FIXME: We need to grab a lock over all calls to `Z3_*_to_string()`\n  // to make this thread safe.\n  return ::Z3_model_to_string(context, node);\n}\n\nZ3ASTHandle Z3ModelHandle::getAssignmentFor(Z3FuncDeclHandle funcDecl) {\n  assert(funcDecl.getContext() == context && \"mismatched contexts\");\n  // TODO: Do we want to support assignments to uninterpreted functions too?\n  return Z3ASTHandle(::Z3_model_get_const_interp(context, node, funcDecl),\n                     context);\n}\n\nbool Z3ModelHandle::hasAssignmentFor(Z3FuncDeclHandle decl) const {\n  assert(decl.getContext() == context && \"mismached contexts\");\n  return ::Z3_model_has_interp(context, node, decl);\n}\n\nbool Z3ModelHandle::addAssignmentFor(Z3FuncDeclHandle decl, Z3ASTHandle e,\n                                     bool allowOverwrite) {\n  assert(decl.getContext() == context && \"mistached decl and model context\");\n  assert(e.getContext() == context &&\n         \"mismatched assignment and model context\");\n  if (!allowOverwrite) {\n    // Check if an assignment already exists\n    if (hasAssignmentFor(decl)) {\n      return false;\n    }\n  }\n  if (!e.isConstant()) {\n    // We only support constant assignments right now.\n    // Z3's API allows giving assignments to arrays and\n    // uninterpreted functions but let's not worry about that\n    // right now.\n    return false;\n  }\n  Z3_add_const_interp(context, node, decl, e);\n  return true;\n}\n\nuint64_t Z3ModelHandle::getNumAssignments() const {\n  if (context == nullptr || node == nullptr) {\n    return 0;\n  }\n  return Z3_model_get_num_consts(context, node);\n}\n\nZ3FuncDeclHandle Z3ModelHandle::getVariableDeclForIndex(uint64_t index) {\n  assert(index < getNumAssignments());\n  return Z3FuncDeclHandle(::Z3_model_get_const_decl(context, node, index),\n                          context);\n}\n\nZ3ASTHandle Z3ModelHandle::evaluate(Z3ASTHandle e, bool modelCompletion) {\n  assert(e.getContext() == context);\n  assert(!e.isNull());\n  Z3_ast raw_ast = nullptr;\n  bool success = ::Z3_model_eval(context, node, e,\n                                 /*modelCompletion=*/modelCompletion, &raw_ast);\n  if (!success) {\n    return Z3ASTHandle();\n  }\n  return Z3ASTHandle(raw_ast, context);\n}\n\nbool Z3ModelHandle::isEmpty() const {\n  return getNumAssignments() == 0;\n}\n\n// Z3SortHandle helper methods\nZ3_sort_kind Z3SortHandle::getKind() const {\n  return ::Z3_get_sort_kind(context, node);\n}\n\nbool Z3SortHandle::isBoolTy() const { return getKind() == Z3_BOOL_SORT; }\n\nbool Z3SortHandle::isBitVectorTy() const { return getKind() == Z3_BV_SORT; }\n\nbool Z3SortHandle::isFloatingPointTy() const {\n  return getKind() == Z3_FLOATING_POINT_SORT;\n}\n\nunsigned Z3SortHandle::getWidth() const {\n  switch (getKind()) {\n  case Z3_BOOL_SORT:\n    return 1;\n  case Z3_BV_SORT:\n    return getBitVectorWidth();\n  case Z3_FLOATING_POINT_SORT:\n    return getFloatingPointBitWidth();\n  default:\n    return 0;\n  }\n}\n\nunsigned Z3SortHandle::getBitVectorWidth() const {\n  if (getKind() != Z3_BV_SORT)\n    return 0;\n  unsigned width = ::Z3_get_bv_sort_size(context, node);\n  return width;\n}\n\nunsigned Z3SortHandle::getFloatingPointExponentBitWidth() const {\n  if (!isFloatingPointTy())\n    return 0;\n  return ::Z3_fpa_get_ebits(context, node);\n}\n\nunsigned Z3SortHandle::getFloatingPointSignificandBitWidth() const {\n  if (!isFloatingPointTy())\n    return 0;\n  return ::Z3_fpa_get_sbits(context, node);\n}\n\nunsigned Z3SortHandle::getFloatingPointBitWidth() const {\n  if (!isFloatingPointTy())\n    return 0;\n  return getFloatingPointExponentBitWidth() +\n         getFloatingPointSignificandBitWidth();\n}\n\nZ3ASTHandle Z3SortHandle::asAST() const {\n  return Z3ASTHandle(::Z3_sort_to_ast(context, node), context);\n}\n\nZ3SortHandle Z3SortHandle::getBoolTy(Z3_context ctx) {\n  return Z3SortHandle(Z3_mk_bool_sort(ctx), ctx);\n}\n\nZ3SortHandle Z3SortHandle::getBitVectorTy(Z3_context ctx, unsigned bitWidth) {\n  return Z3SortHandle(Z3_mk_bv_sort(ctx, bitWidth), ctx);\n}\n\nZ3SortHandle Z3SortHandle::getFloat32Ty(Z3_context ctx) {\n  return Z3SortHandle(Z3_mk_fpa_sort_32(ctx), ctx);\n}\n\nZ3SortHandle Z3SortHandle::getFloat64Ty(Z3_context ctx) {\n  return Z3SortHandle(Z3_mk_fpa_sort_64(ctx), ctx);\n}\n\n// Z3ASTHandle helper methods\nZ3_ast_kind Z3ASTHandle::getKind() const {\n  return ::Z3_get_ast_kind(context, node);\n}\n\nbool Z3ASTHandle::isApp() const {\n  bool condition = ::Z3_is_app(context, node);\n#ifndef NDEBUG\n  if (condition)\n    assert(getKind() == Z3_APP_AST || getKind() == Z3_NUMERAL_AST);\n#endif\n  return condition;\n}\n\nbool Z3ASTHandle::isFuncDecl() const { return getKind() == Z3_FUNC_DECL_AST; }\n\nbool Z3ASTHandle::isSort() const { return getKind() == Z3_SORT_AST; }\n\nbool Z3ASTHandle::isNumeral() const { return getKind() == Z3_NUMERAL_AST; }\n\nbool Z3ASTHandle::isTrue() const {\n#ifdef NDEBUG\n  return isAppOf(Z3_OP_TRUE);\n#else\n  bool condition = isAppOf(Z3_OP_TRUE);\n  if (condition)\n    assert(isConstant() && \"should be constant\");\n\n  return condition;\n#endif\n}\n\nbool Z3ASTHandle::isFalse() const {\n#ifdef NDEBUG\n  return isAppOf(Z3_OP_FALSE);\n#else\n  bool condition = isAppOf(Z3_OP_FALSE);\n  if (condition)\n    assert(isConstant() && \"should be constant\");\n\n  return condition;\n#endif\n}\n\nbool Z3ASTHandle::isConstant() const {\n  if (!isApp())\n    return false;\n  return asApp().isConstant();\n}\n\nbool Z3ASTHandle::isFreeVariable() const {\n  if (!isApp())\n    return false;\n  return asApp().isFreeVariable();\n}\n\nbool Z3ASTHandle::isAppOf(Z3_decl_kind kind) const {\n  if (!isApp())\n    return false;\n\n  return asApp().getKind() == kind;\n}\n\nbool Z3ASTHandle::isStructurallyEqualTo(Z3ASTHandle other) const {\n  // Compare pointers\n  if (this->node == other.node)\n    return true;\n\n  // This is a handle to nullptr. Given the above\n  // check failed (i.e. the other is not a handle to nullptr)\n  // we can't be equal.\n  if (this->node == nullptr)\n    return false;\n\n  assert(this->context == other.context && \"context mismatch\");\n  return ::Z3_is_eq_ast(context, *this, other);\n}\n\nZ3SortHandle Z3ASTHandle::getSort() const {\n  if (isFuncDecl()) {\n    // We assume that the client wants the range of the function declaration.\n    return asFuncDecl().getSort();\n  }\n  return Z3SortHandle(::Z3_get_sort(context, node), context);\n}\n\nZ3AppHandle Z3ASTHandle::asApp() const {\n  if (!isApp())\n    return Z3AppHandle();\n  return Z3AppHandle(::Z3_to_app(context, node), context);\n}\n\nZ3FuncDeclHandle Z3ASTHandle::asFuncDecl() const {\n  if (!isFuncDecl())\n    return Z3FuncDeclHandle();\n  return Z3FuncDeclHandle(::Z3_to_func_decl(context, node), context);\n}\n\nZ3ASTHandle Z3ASTHandle::getTrue(Z3_context ctx) {\n  return Z3ASTHandle(::Z3_mk_true(ctx), ctx);\n}\n\nZ3ASTHandle Z3ASTHandle::getFalse(Z3_context ctx) {\n  return Z3ASTHandle(::Z3_mk_false(ctx), ctx);\n}\n\nZ3ASTHandle Z3ASTHandle::getBVZero(Z3_context ctx, unsigned width) {\n  assert(width > 0);\n  return getBVZero(Z3SortHandle::getBitVectorTy(ctx, width));\n}\n\nZ3ASTHandle Z3ASTHandle::getBVZero(Z3SortHandle sort) {\n  return getBV(sort, 0);\n}\n\nZ3ASTHandle Z3ASTHandle::getBV(Z3SortHandle sort, uint64_t value) {\n  assert(sort.isBitVectorTy());\n  assert(sort.getBitVectorWidth() > 0);\n  assert(sort.getBitVectorWidth() <= 64);\n  return Z3ASTHandle(::Z3_mk_unsigned_int64(sort.getContext(), value, sort),\n                     sort.getContext());\n}\n\nZ3ASTHandle Z3ASTHandle::getFloatZero(Z3SortHandle sort, bool positive) {\n  assert(sort.isFloatingPointTy());\n  return Z3ASTHandle(\n      ::Z3_mk_fpa_zero(sort.getContext(), sort, /*negative=*/!positive),\n      sort.getContext());\n}\n\nZ3ASTHandle Z3ASTHandle::getFloatInfinity(Z3SortHandle sort, bool positive) {\n  assert(sort.isFloatingPointTy());\n  return Z3ASTHandle(\n      ::Z3_mk_fpa_inf(sort.getContext(), sort, /*negative=*/!positive),\n      sort.getContext());\n}\n\nZ3ASTHandle Z3ASTHandle::getFloatNAN(Z3SortHandle sort) {\n  assert(sort.isFloatingPointTy());\n  return Z3ASTHandle(::Z3_mk_fpa_nan(sort.getContext(), sort),\n                     sort.getContext());\n}\n\nZ3ASTHandle Z3ASTHandle::getFloatFromInt(Z3SortHandle sort, signed value) {\n  assert(sort.isFloatingPointTy());\n  return Z3ASTHandle(::Z3_mk_fpa_numeral_int(sort.getContext(), value, sort),\n                     sort.getContext());\n}\n\nstatic size_t getEMax(Z3SortHandle fpSort) {\n  assert(fpSort.isFloatingPointTy());\n  // IEEE-754 3.4 defines e_max equal to the bias which is\n  // 2^(w-1) -1, where `w` is the exponent bit width.\n  size_t eBits = fpSort.getFloatingPointExponentBitWidth();\n  size_t eMax = (1 << (eBits - 1)) - 1;\n  return eMax;\n}\n\nstatic size_t getEMin(Z3SortHandle fpSort) {\n  assert(fpSort.isFloatingPointTy());\n  // Compute e_min for the floating point sort.\n  // IEEE-754 2008 3.3, defines this as (1 - e_max)\n  size_t eMax = getEMax(fpSort);\n  size_t eMin = 1 - eMax;\n  return eMin;\n}\nZ3ASTHandle Z3ASTHandle::getFloatAbsoluteSmallestSubnormal(Z3SortHandle sort,\n                                                           bool positive) {\n  assert(sort.isFloatingPointTy());\n  size_t eMin = getEMin(sort);\n  // Z3's `Z3_mk_fpa_numeral_int64_uint64(..)` is super unclear here.\n  // It is not clear if the exponent is biased and whether or not\n  // the implicit bit is included in the significand.\n  //\n  // Observations:\n  // * `sig` does not include the implicit bit.\n  // * `exp` appears to be signed and is the IEEE-754 binary encoding of the\n  //   exponent  minus the bias.\n  //\n  // Note that the true exponent for the subnormal numbers and normals with the\n  // smallest exponent is the same (e.g. for Float32 it's -126).\n  //\n  // Normals with smallest exp: 1.<significand bits> x 2^(-126)\n  // Subnormals               : 0.<significand bits> x 2^(-126)\n  //\n  // However because the implicit bit is missing in the `sig` argument, the\n  // only way to differentiate between subnormal and normal numbers is for the\n  // value of `exp` to be different from the smallest exponent for normal\n  // numbers. Using the smallest exponent for normal numbers -1 seems to work\n  // but this API design is profoundly confusing.\n  //\n  // I guess the easiest way to think about this is that the `exp` argument is\n  // the representation of the exponent in the IEEE-754 binary encoding minus\n  // the bias. This is different from the true exponent.\n  return Z3ASTHandle(Z3_mk_fpa_numeral_int64_uint64(\n                         /*context=*/sort.getContext(),\n                         /*sgn=*/!positive,\n                         /*exp=*/eMin - 1,\n                         /*sig=*/1,\n                         /*typ=*/sort),\n                     sort.getContext());\n}\n\nZ3ASTHandle Z3ASTHandle::getFloatAbsoluteLargestSubnormal(Z3SortHandle sort,\n                                                          bool positive) {\n  assert(sort.isFloatingPointTy());\n  size_t eMin = getEMin(sort);\n  // Z3's `Z3_mk_fpa_numeral_int64_uint64(..)` is super unclear here.\n  // See getFloatAbsoluteSmallestSubnormal(...) for a discussion.\n  // Note: Z3 seems to ignore the irrelevant bits for the sort in `sig`\n  // so passing `UINT64_MAX` seems to be okay.\n  return Z3ASTHandle(Z3_mk_fpa_numeral_int64_uint64(\n                         /*context=*/sort.getContext(),\n                         /*sgn=*/!positive,\n                         /*exp=*/eMin - 1,\n                         /*sig=*/UINT64_MAX,\n                         /*typ=*/sort),\n                     sort.getContext());\n}\n\nZ3ASTHandle Z3ASTHandle::getFloatAbsoluteSmallestNormal(Z3SortHandle sort,\n                                                        bool positive) {\n  assert(sort.isFloatingPointTy());\n  size_t eMin = getEMin(sort);\n  // Z3's `Z3_mk_fpa_numeral_int64_uint64(..)` is super unclear here.\n  // See getFloatAbsoluteSmallestSubnormal(...) for a discussion.\n  return Z3ASTHandle(Z3_mk_fpa_numeral_int64_uint64(\n                         /*context=*/sort.getContext(),\n                         /*sgn=*/!positive,\n                         /*exp=*/eMin,\n                         /*sig=*/0,\n                         /*typ=*/sort),\n                     sort.getContext());\n}\n\nZ3ASTHandle Z3ASTHandle::getFloatAbsoluteLargestNormal(Z3SortHandle sort,\n                                                       bool positive) {\n  assert(sort.isFloatingPointTy());\n  size_t eMax = getEMax(sort);\n  // Z3's `Z3_mk_fpa_numeral_int64_uint64(..)` is super unclear here.\n  // See getFloatAbsoluteSmallestSubnormal(...) for a discussion.\n  // Note: Z3 seems to ignore the irrelevant bits for the sort in `sig`\n  // so passing `UINT64_MAX` seems to be okay.\n  return Z3ASTHandle(Z3_mk_fpa_numeral_int64_uint64(\n                         /*context=*/sort.getContext(),\n                         /*sgn=*/!positive,\n                         /*exp=*/eMax,\n                         /*sig=*/UINT64_MAX,\n                         /*typ=*/sort),\n                     sort.getContext());\n}\n\n// Z3AppHandle helpers\nZ3FuncDeclHandle Z3AppHandle::getFuncDecl() const {\n  return Z3FuncDeclHandle(::Z3_get_app_decl(context, node), context);\n}\n\nZ3_decl_kind Z3AppHandle::getKind() const { return getFuncDecl().getKind(); }\n\nunsigned Z3AppHandle::getNumKids() const {\n  return ::Z3_get_app_num_args(context, node);\n}\n\nZ3ASTHandle Z3AppHandle::getKid(unsigned index) const {\n  assert(index < getNumKids() && \"accessing invalid kid index\");\n  return Z3ASTHandle(::Z3_get_app_arg(context, node, index), context);\n}\n\nbool Z3AppHandle::isConstant() const {\n  if (getKind() == Z3_OP_FPA_FP) {\n    // This is weird. If floating point constants have not\n    // been run through the simplifier then they are Z3_OP_FPA_FP\n    // rather than Z3_OP_FPA_NUM.\n    //\n    // To handle this case (it is not guaranteed that the simplifier was run) if\n    // the operation is of this kind and all\n    // three operands are constant then we treat this as a constant\n    assert(getNumKids() == 3);\n    if (getKid(0).isConstant() && getKid(1).isConstant() &&\n        getKid(2).isConstant()) {\n      return true;\n    }\n    return false;\n  }\n  if (getNumKids() != 0)\n    return false;\n\n  if (!::Z3_is_numeral_ast(context, ::Z3_app_to_ast(context, node)))\n    return false; // Is free variable\n\n  return true;\n}\n\nbool Z3AppHandle::isFreeVariable() const {\n  if (getNumKids() != 0)\n    return false;\n\n  if (::Z3_is_numeral_ast(context, ::Z3_app_to_ast(context, node)))\n    return false; // Is constant\n\n  return true;\n}\n\nbool Z3AppHandle::isSpecialFPConstant() const {\n  auto kind = getKind();\n  return kind == Z3_OP_FPA_PLUS_ZERO || kind == Z3_OP_FPA_MINUS_ZERO ||\n         kind == Z3_OP_FPA_PLUS_INF || kind == Z3_OP_FPA_MINUS_INF ||\n         kind == Z3_OP_FPA_NAN;\n}\n\nZ3ASTHandle Z3AppHandle::asAST() const {\n  return Z3ASTHandle(::Z3_app_to_ast(context, node), context);\n}\n\nZ3SortHandle Z3AppHandle::getSort() const { return asAST().getSort(); }\n\nbool Z3AppHandle::getConstantAsUInt64(uint64_t* out) const {\n  if (!isConstant())\n    return false;\n\n  __uint64 value = 0;\n  static_assert(sizeof(__uint64) == sizeof(uint64_t), \"size mismatch\");\n  bool success =\n      Z3_get_numeral_uint64(context, ::Z3_app_to_ast(context, node), &value);\n  if (success && out)\n    *out = value;\n  return success;\n}\n\n// Z3FuncDeclHandle helpers\n\nZ3_decl_kind Z3FuncDeclHandle::getKind() const {\n  return ::Z3_get_decl_kind(context, node);\n}\n\nZ3SortHandle Z3FuncDeclHandle::getSort() const {\n  return Z3SortHandle(::Z3_get_range(context, node), context);\n}\n\nstd::string Z3FuncDeclHandle::getName() const {\n  Z3_symbol sym = ::Z3_get_decl_name(context, node);\n  // We have to allocate storage because ::Z3_get_decl_name uses\n  // a statically allocated buffer which is invalidated when the\n  // next call occurs.\n  return std::string(::Z3_get_symbol_string(context, sym));\n}\n\nZ3ASTHandle Z3FuncDeclHandle::asAST() const {\n  return Z3ASTHandle(::Z3_func_decl_to_ast(context, node), context);\n}\n\nunsigned Z3FuncDeclHandle::getNumParams() const {\n  return ::Z3_get_decl_num_parameters(context, node);\n}\n\nZ3_parameter_kind Z3FuncDeclHandle::getParamKind(unsigned index) const {\n  assert(index < getNumParams());\n  return ::Z3_get_decl_parameter_kind(context, node, index);\n}\n\nint Z3FuncDeclHandle::getIntParam(unsigned index) const {\n  assert(getParamKind(index) == Z3_PARAMETER_INT);\n  return ::Z3_get_decl_int_parameter(context, node, index);\n}\n\n// Z3GoalHandle\n\ntemplate <> void Z3NodeHandle<Z3_goal>::dump() const {\n  llvm::errs() << \"Z3GoalHandle:\\n\" << toStr() << \"\\n\";\n}\n\ntemplate <> std::string Z3NodeHandle<Z3_goal>::toStr() const {\n  return ::Z3_goal_to_string(context, node);\n}\n\nvoid Z3GoalHandle::addFormula(Z3ASTHandle e) {\n  assert(e.getContext() == context && \"mismatched contexts\");\n  ::Z3_goal_assert(context, node, e);\n}\n\nunsigned Z3GoalHandle::getNumFormulas() const {\n  return ::Z3_goal_size(context, node);\n}\n\nZ3ASTHandle Z3GoalHandle::getFormula(unsigned index) const {\n  assert(index < getNumFormulas() && \"bad index\");\n  return Z3ASTHandle(::Z3_goal_formula(context, node, index), context);\n}\n\n// Z3TacticHandle\ntemplate <> void Z3NodeHandle<Z3_tactic>::dump() const {\n  llvm::errs() << \"Z3TacticHandle:\\n\" << toStr() << \"\\n\";\n}\n\ntemplate <> std::string Z3NodeHandle<Z3_tactic>::toStr() const {\n  return \"<not-available>\"; // FIXME\n}\n\nZ3ApplyResultHandle Z3TacticHandle::apply(Z3GoalHandle goal) {\n  return Z3ApplyResultHandle(::Z3_tactic_apply(context, node, goal), context);\n}\n\nZ3ApplyResultHandle Z3TacticHandle::applyWithParams(Z3GoalHandle goal,\n                                                    Z3ParamsHandle params) {\n  return Z3ApplyResultHandle(::Z3_tactic_apply_ex(context, node, goal, params),\n                             context);\n}\n\n// Z3ApplyResultHandle\ntemplate <> void Z3NodeHandle<Z3_apply_result>::dump() const {\n  llvm::errs() << \"Z3ApplyResultHandle:\\n\" << toStr() << \"\\n\";\n}\n\ntemplate <> std::string Z3NodeHandle<Z3_apply_result>::toStr() const {\n  return ::Z3_apply_result_to_string(context, node);\n}\n\nunsigned Z3ApplyResultHandle::getNumGoals() const {\n  return ::Z3_apply_result_get_num_subgoals(context, node);\n}\n\nZ3GoalHandle Z3ApplyResultHandle::getGoal(unsigned index) const {\n  assert(index < getNumGoals());\n  return Z3GoalHandle(::Z3_apply_result_get_subgoal(context, node, index),\n                      context);\n}\n\nvoid Z3ApplyResultHandle::collectAllFormulas(\n    std::vector<Z3ASTHandle> &formulas) const {\n  for (unsigned subGoalIndex = 0; subGoalIndex < this->getNumGoals();\n       ++subGoalIndex) {\n    Z3GoalHandle subGoal = this->getGoal(subGoalIndex);\n    for (unsigned formulaIndex = 0; formulaIndex < subGoal.getNumFormulas();\n         ++formulaIndex) {\n      formulas.push_back(subGoal.getFormula(formulaIndex));\n    }\n  }\n}\n\nZ3ModelHandle\nZ3ApplyResultHandle::convertModelForGoal(unsigned index,\n                                         Z3ModelHandle toConvert) {\n  assert(index < getNumGoals());\n  assert(!toConvert.isNull());\n  assert(toConvert.getContext() == context);\n  return Z3ModelHandle(\n      Z3_apply_result_convert_model(context, node, index, toConvert), context);\n}\n}\n}\n"
  },
  {
    "path": "lib/Core/Z3NodeUtil.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Alastair Donaldson\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Core/Z3NodeUtil.h\"\nnamespace jfs {\nnamespace core {\n\nvoid Z3NodeUtil::collectFuncDecls(Z3FuncDeclSet& variables,\n                                  std::list<Z3ASTHandle>& workList) {\n  // Do DFS to collect variables\n  // FIXME: Not collecting custom sorts or functions\n  Z3ASTSet seenExpr;\n  while (workList.size() != 0) {\n    Z3ASTHandle node = workList.front();\n    workList.pop_front();\n    if (seenExpr.count(node) > 0) {\n      // Already visited\n      continue;\n    }\n    seenExpr.insert(node);\n\n    if (node.isFreeVariable()) {\n      variables.insert(node.asApp().getFuncDecl());\n      continue;\n    }\n    if (!node.isApp())\n      continue;\n    // Must be a function application. Traverse the arguments\n    Z3AppHandle app = node.asApp();\n    for (unsigned index = 0; index < app.getNumKids(); ++index) {\n      workList.push_front(app.getKid(index));\n    }\n  }\n}\n\nvoid Z3NodeUtil::collectFuncDecls(Z3FuncDeclSet& addTo, Z3ASTHandle e) {\n  std::list<Z3ASTHandle> workList;\n  workList.push_front(e);\n  collectFuncDecls(addTo, workList);\n}\n\n} // namespace core\n} // namespace jfs\n"
  },
  {
    "path": "lib/FuzzingCommon/BufferAssignment.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/BufferAssignment.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include \"jfs/FuzzingCommon/CommandLineCategory.h\"\n#include \"llvm/Support/CommandLine.h\"\n#include <algorithm>\n#include <list>\n#include <vector>\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nvoid BufferAssignment::appendElement(BufferElement& el) {\n  chunks.push_back(el);\n  cachedTypeBitWidth += el.getTypeBitWidth();\n  cachedStoreBitWidth += el.getStoreBitWidth();\n  assert(cachedTypeBitWidth == computeTypeBitWidth() && \"bitwidth mismatch\");\n  assert(cachedStoreBitWidth == computeStoreBitWidth() && \"bitwidth mismatch\");\n}\n\nuint64_t BufferAssignment::computeTypeBitWidth() const {\n  uint64_t totalWidth = 0;\n  for (const auto& ba : chunks) {\n    totalWidth += ba.getTypeBitWidth();\n  }\n  return totalWidth;\n}\n\nuint64_t BufferAssignment::computeStoreBitWidth() const {\n  uint64_t totalWidth = 0;\n  for (const auto& ba : chunks) {\n    totalWidth += ba.getStoreBitWidth();\n  }\n  return totalWidth;\n}\n\nvoid BufferAssignment::print(llvm::raw_ostream& os) const {\n  os << \"(BufferAssignment \" << getTypeBitWidth() << \" type bits, \"\n     << getStoreBitWidth() << \" store bits)\";\n  if (chunks.size() > 0) {\n    os << \"\\n\";\n  }\n  for (const auto& be : chunks) {\n    os << \"  \";\n    be.print(os);\n  }\n  os << \")\\n\";\n}\n\nvoid BufferAssignment::dump() const { print(llvm::errs()); }\n\n} // namespace fuzzingCommon\n} // namespace jfs\n"
  },
  {
    "path": "lib/FuzzingCommon/BufferElement.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/BufferElement.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include \"jfs/FuzzingCommon/CommandLineCategory.h\"\n#include \"llvm/Support/CommandLine.h\"\n#include <algorithm>\n#include <list>\n#include <vector>\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nBufferElement::BufferElement(const Z3ASTHandle declApp,\n                             size_t storeBitAlignment)\n    : storeBitAlignment(storeBitAlignment), declApp(declApp) {\n  assert(declApp.isApp() && \"should be an application\");\n  assert(declApp.asApp().isFreeVariable() && \"should be an application\");\n  assert(this->storeBitAlignment > 0 && \"Alignment must be > 0\");\n}\n\nunsigned BufferElement::getTypeBitWidth() const {\n  Z3SortHandle sort = declApp.getSort();\n  switch (sort.getKind()) {\n  case Z3_BOOL_SORT:\n    return 1;\n  case Z3_BV_SORT:\n    return sort.getBitVectorWidth();\n  case Z3_FLOATING_POINT_SORT:\n    return sort.getFloatingPointBitWidth();\n  default:\n    llvm_unreachable(\"Unhandled sort\");\n  }\n}\n\nunsigned BufferElement::getStoreBitWidth() const {\n  assert(storeBitAlignment > 0);\n  unsigned result =\n      ((getTypeBitWidth() + (storeBitAlignment - 1)) / storeBitAlignment) *\n      storeBitAlignment;\n  assert((result % storeBitAlignment) == 0);\n  return result;\n}\n\nZ3FuncDeclHandle BufferElement::getDecl() const {\n  return declApp.asApp().getFuncDecl();\n}\n\nstd::string BufferElement::getName() const { return getDecl().getName(); }\n\nZ3SortHandle BufferElement::getSort() const { return declApp.getSort(); }\n\nvoid BufferElement::print(llvm::raw_ostream& os) const {\n  os << \"(\" << getDecl().getName() << \":\" << getTypeBitWidth();\n  if (getStoreBitWidth() != getTypeBitWidth()) {\n    os << \" (store width:\" << getStoreBitWidth() << \")\";\n  }\n  if (equalities.size() > 0) {\n    os << \" equalities: \";\n    for (const auto& e : equalities) {\n      os << \" (\" << e.toStr() << \")\";\n    }\n  }\n  os << \")\\n\";\n}\n\nvoid BufferElement::dump() const { print(llvm::errs()); }\n\n} // namespace fuzzingCommon\n} // namespace jfs\n"
  },
  {
    "path": "lib/FuzzingCommon/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n\n################################################################################\n# Generate SMTLIBRuntimes.h\n################################################################################\nget_property(\n  JFS_AVAILABLE_RUNTIMES\n  GLOBAL\n  PROPERTY JFS_AVAILABLE_RUNTIMES\n)\nget_property(\n  JFS_STATIC_RUNTIME_PATH\n  GLOBAL\n  PROPERTY JFS_STATIC_RUNTIME_PATH\n)\nset(SMTLIB_RUNTIME_ENUM_ENTRIES \"\")\nforeach (runtime ${JFS_AVAILABLE_RUNTIMES})\n  string(APPEND SMTLIB_RUNTIME_ENUM_ENTRIES \"  ${runtime},\\n\")\nendforeach()\nconfigure_file(\n  \"SMTLIBRuntimes.h.in\"\n  \"${CMAKE_BINARY_DIR}/include/jfs/FuzzingCommon/SMTLIBRuntimes.h\"\n  @ONLY\n)\nunset(SMTLIB_RUNTIME_ENUM_ENTRIES)\n################################################################################\n# Generate SMTLIBRuntimes.cpp\n################################################################################\nset(getSMTLIBRuntimeAsCStringEntries \"\")\nset(getSMTLIBRuntimePathEntries \"\")\nlist(LENGTH JFS_AVAILABLE_RUNTIMES JFS_AVAILABLE_RUNTIMES_LENGTH)\nlist(LENGTH JFS_STATIC_RUNTIME_PATH JFS_STATIC_RUNTIME_PATH_LENGTH)\nif (NOT (\"${JFS_AVAILABLE_RUNTIMES_LENGTH}\" EQUAL \"${JFS_STATIC_RUNTIME_PATH_LENGTH}\"))\n  message(FATAL_ERROR \"Length mismatch\")\nendif()\nset(index 0)\nwhile (\"${index}\" LESS \"${JFS_AVAILABLE_RUNTIMES_LENGTH}\")\n  list(GET JFS_AVAILABLE_RUNTIMES ${index} runtime_enum)\n  list(GET JFS_STATIC_RUNTIME_PATH ${index} runtime_path)\n\n  string(APPEND getSMTLIBRuntimeAsCStringEntries\n    \"  case SMTLIBRuntimeTy::${runtime_enum}:\\n    return \\\"${runtime_enum}\\\";\\n\"\n  )\n  string(APPEND getSMTLIBRuntimePathEntries\n    \"  case SMTLIBRuntimeTy::${runtime_enum}:\\n    return \\\"${runtime_path}\\\";\\n\"\n  )\n  math(EXPR index \"${index}+1\")\nendwhile()\nconfigure_file(\n  \"SMTLIBRuntimes.cpp.in\"\n  \"${CMAKE_CURRENT_BINARY_DIR}/SMTLIBRuntimes.cpp\"\n  @ONLY\n)\nmessage(STATUS \"JFS_AVAILABLE_RUNTIMES: ${JFS_AVAILABLE_RUNTIMES}\")\nmessage(STATUS \"JFS_STATIC_RUNTIME_PATH: ${JFS_STATIC_RUNTIME_PATH}\")\n\n################################################################################\n# JFSFuzzingCommon component\n################################################################################\n\njfs_add_component(JFSFuzzingCommon\n  BufferAssignment.cpp\n  BufferElement.cpp\n  CommandLineCategory.cpp\n  DummyFuzzingSolver.cpp\n  EqualityExtractionPass.cpp\n  FileSerializableModel.cpp\n  FreeVariableToBufferAssignmentPass.cpp\n  FreeVariableToBufferAssignmentPassOptions.cpp\n  FuzzingSolver.cpp\n  FuzzingSolverOptions.cpp\n  FuzzingAnalysisInfo.cpp\n  JFSRuntimeFuzzingStat.cpp\n  LibFuzzerInvocationManager.cpp\n  LibFuzzerOptions.cpp\n  \"${CMAKE_CURRENT_BINARY_DIR}/SMTLIBRuntimes.cpp\"\n  SeedGenerator.cpp\n  SeedManager.cpp\n  SeedManagerStat.cpp\n  SortConformanceCheckPass.cpp\n  SpecialConstantSeedGenerator.cpp\n  SpecialConstantSeedGeneratorStat.cpp\n  WorkingDirectoryManager.cpp\n  # FIXME: This is a hack. Can we do this in a cleaner way?\n  # Runtime code\n  ${CMAKE_SOURCE_DIR}/runtime/SMTLIB/SMTLIB/NativeBitVector.cpp\n  ${CMAKE_SOURCE_DIR}/runtime/SMTLIB/SMTLIB/NativeFloat.cpp\n)\n\n# JFSFuzzingCommon needs to build some of the runtime functions\n# into itself so add the include the head path\ntarget_include_directories(JFSFuzzingCommon\n  PRIVATE\n  \"${CMAKE_SOURCE_DIR}/runtime/SMTLIB\"\n)\n# HACK: Make runtime asserts into aborts so that when we use runtime\n# functions directly we always use its asserts.\ntarget_compile_definitions(JFSFuzzingCommon\n  PRIVATE\n  JFS_RUNTIME_FAILURE_CALLS_ABORT\n  ENABLE_JFS_RUNTIME_ASSERTS\n)\n\n\ntarget_link_libraries(JFSFuzzingCommon\n  PUBLIC\n  JFSTransform\n  JFSCore\n  JFSSupport\n)\n\nadd_subdirectory(CmdLine)\n"
  },
  {
    "path": "lib/FuzzingCommon/CmdLine/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\njfs_add_component(JFSFuzzingCommonCmdLine\n  FreeVariableToBufferAssignmentPassOptionsBuilder.cpp\n  LibFuzzerOptionsBuilder.cpp\n  SeedManagerOptionsBuilder.cpp\n)\ntarget_link_libraries(JFSFuzzingCommonCmdLine\n  PUBLIC\n  JFSFuzzingCommon\n)\njfs_get_llvm_components(llvm_components support)\n\ntarget_link_libraries(JFSFuzzingCommonCmdLine PUBLIC ${llvm_components})\n"
  },
  {
    "path": "lib/FuzzingCommon/CmdLine/FreeVariableToBufferAssignmentPassOptionsBuilder.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/CmdLine/FreeVariableToBufferAssignmentPassOptionsBuilder.h\"\n#include \"jfs/FuzzingCommon/CommandLineCategory.h\"\n#include \"llvm/Support/CommandLine.h\"\n\nusing namespace jfs::fuzzingCommon;\n\nnamespace {\n\nllvm::cl::opt<bool> ByteAlignedBufferElements(\n    \"byte-aligned-buffer-elements\",\n    llvm::cl::desc(\n        \"If enabled buffer elements are byte aligned (default: false)\"),\n    llvm::cl::init(false),\n    llvm::cl::cat(jfs::fuzzingCommon::CommandLineCategory));\n\nllvm::cl::opt<jfs::fuzzingCommon::FreeVariableToBufferAssignmentPassOptions::\n                  FreeVariableSortStrategyTy>\n    FreeVariableSortStrategy(\n        \"sort-free-variable-strategy\",\n        llvm::cl::desc(\"Ordering of free variables in fuzzing buffer\"),\n        llvm::cl::values(\n            clEnumValN(\n                jfs::fuzzingCommon::FreeVariableToBufferAssignmentPassOptions::\n                    FreeVariableSortStrategyTy::ALPHABETICAL,\n                \"alphabetical\", \"Sort free variables alphabetically (slow)\"),\n            clEnumValN(\n                jfs::fuzzingCommon::FreeVariableToBufferAssignmentPassOptions::\n                    FreeVariableSortStrategyTy::FIRST_OBSERVED,\n                \"first_observed\",\n                \"sort free variables by observation order (default)\"),\n            clEnumValN(\n                jfs::fuzzingCommon::FreeVariableToBufferAssignmentPassOptions::\n                    FreeVariableSortStrategyTy::NONE,\n                \"none\", \"Do not order. This is non-deterministic\")),\n        llvm::cl::init(\n            jfs::fuzzingCommon::FreeVariableToBufferAssignmentPassOptions::\n                FreeVariableSortStrategyTy::FIRST_OBSERVED),\n        llvm::cl::cat(jfs::fuzzingCommon::CommandLineCategory));\n}\n\nnamespace jfs {\nnamespace fuzzingCommon {\nnamespace cl {\n\nstd::unique_ptr<jfs::fuzzingCommon::FreeVariableToBufferAssignmentPassOptions>\nbuildFVTBAPOptionsFromCmdLine() {\n  auto opts = std::unique_ptr<\n      jfs::fuzzingCommon::FreeVariableToBufferAssignmentPassOptions>(\n      new FreeVariableToBufferAssignmentPassOptions());\n\n  if (ByteAlignedBufferElements) {\n    opts->bufferElementBitAlignment = 8;\n  } else {\n    opts->bufferElementBitAlignment = 1;\n  }\n\n  opts->sortStrategy = FreeVariableSortStrategy;\n  return opts;\n}\n} // namespace cl\n} // namespace fuzzingCommon\n} // namespace jfs\n"
  },
  {
    "path": "lib/FuzzingCommon/CmdLine/LibFuzzerOptionsBuilder.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/CmdLine/LibFuzzerOptionsBuilder.h\"\n#include \"jfs/FuzzingCommon/CommandLineCategory.h\"\n#include \"llvm/Support/CommandLine.h\"\n\nusing namespace jfs::fuzzingCommon;\n\nnamespace {\n// Only provide options for fields that are intended to be modified\n// publicly.\n\nllvm::cl::opt<unsigned long long> FuzzerRuns(\n    \"libfuzzer-runs\",\n    llvm::cl::desc(\n        \"Number of LibFuzzer input runs (0 means unbounded) (default: 0)\"),\n    llvm::cl::init(0), llvm::cl::cat(jfs::fuzzingCommon::CommandLineCategory));\n\nllvm::cl::opt<unsigned> MutationDepth(\n    \"libfuzzer-mutation-depth\",\n    llvm::cl::desc(\"Number of mutations to apply to an input (default: 5)\"),\n    llvm::cl::init(5), llvm::cl::cat(jfs::fuzzingCommon::CommandLineCategory));\n\nllvm::cl::opt<bool>\n    CrossOver(\"libfuzzer-crossover\",\n              llvm::cl::desc(\"Enable crossover mutation (default: true)\"),\n              llvm::cl::init(true),\n              llvm::cl::cat(jfs::fuzzingCommon::CommandLineCategory));\n\nllvm::cl::opt<bool> PrintFinalStats(\n    \"libfuzzer-print-final-stats\",\n    llvm::cl::desc(\"Print LibFuzzer stats on exit (default: true)\"),\n    llvm::cl::init(true),\n    llvm::cl::cat(jfs::fuzzingCommon::CommandLineCategory));\n\nllvm::cl::opt<bool> DefaultMutationsResizeInput(\n    \"libfuzzer-default-mutations-resize-input\",\n    llvm::cl::desc(\"LibFuzzer mutations resize input (default: false)\"),\n    llvm::cl::init(false),\n    llvm::cl::cat(jfs::fuzzingCommon::CommandLineCategory));\n}\n\nnamespace jfs {\nnamespace fuzzingCommon {\nnamespace cl {\n\nstd::unique_ptr<jfs::fuzzingCommon::LibFuzzerOptions>\nbuildLibFuzzerOptionsFromCmdLine() {\n  std::unique_ptr<jfs::fuzzingCommon::LibFuzzerOptions> libFuzzerOptions(\n      new jfs::fuzzingCommon::LibFuzzerOptions());\n  // Fuzzing runs\n  libFuzzerOptions->runs = FuzzerRuns;\n\n  // Mutation depth\n  libFuzzerOptions->mutationDepth = MutationDepth;\n\n  // Crossover\n  libFuzzerOptions->crossOver = CrossOver;\n\n  // LibFuzzer statistics printing\n  libFuzzerOptions->printFinalStats = PrintFinalStats;\n\n  // In our context it doesn't make sense to reduce inputs\n  // because our inputs are always of fixed size.\n  libFuzzerOptions->reduceInputs = false;\n\n  libFuzzerOptions->defaultMutationsResizeInput = DefaultMutationsResizeInput;\n\n  return libFuzzerOptions;\n}\n}\n}\n}\n"
  },
  {
    "path": "lib/FuzzingCommon/CmdLine/SeedManagerOptionsBuilder.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/CmdLine/SeedManagerOptionsBuilder.h\"\n#include \"jfs/FuzzingCommon/CommandLineCategory.h\"\n#include \"jfs/FuzzingCommon/SeedGenerator.h\"\n#include \"jfs/FuzzingCommon/SeedManagerOptions.h\"\n#include \"jfs/FuzzingCommon/SpecialConstantSeedGenerator.h\"\n#include \"llvm/Support/CommandLine.h\"\n\nnamespace {\n\nllvm::cl::opt<unsigned> MaxSeedSpaceInBytes(\n    \"sm-max-seed-space\",\n    llvm::cl::desc(\"Maximum space total space for seeds in bytes. 0 means no \"\n                   \"limit (default: 50 MiB)\"),\n    llvm::cl::init(50 * 1024 * 1024),\n    llvm::cl::cat(jfs::fuzzingCommon::CommandLineCategory));\n\nllvm::cl::opt<unsigned> MaxNumSeed(\n    \"sm-max-num-seed\",\n    llvm::cl::desc(\"Maximum number of seeds. 0 means no limit (default: 100)\"),\n    llvm::cl::init(100), llvm::cl::cat(jfs::fuzzingCommon::CommandLineCategory));\n\nllvm::cl::opt<bool>\n    AddAllZerosSeed(\"sm-all-zeros-seed\",\n                    llvm::cl::desc(\"Add seed of all zero bits (default: true)\"),\n                    llvm::cl::init(true),\n                    llvm::cl::cat(jfs::fuzzingCommon::CommandLineCategory));\n\nllvm::cl::opt<bool>\n    AddAllOnesSeed(\"sm-all-ones-seed\",\n                   llvm::cl::desc(\"Add seed of all one bits (default: true)\"),\n                   llvm::cl::init(true),\n                   llvm::cl::cat(jfs::fuzzingCommon::CommandLineCategory));\n\nllvm::cl::opt<bool> AddSpecialConstantSeeds(\n    \"sm-special-constant-seeds\",\n    llvm::cl::desc(\n        \"Add special constant seeds based on constraints (default: false)\"),\n    llvm::cl::init(false),\n    llvm::cl::cat(jfs::fuzzingCommon::CommandLineCategory));\n} // namespace\n\nnamespace jfs {\nnamespace fuzzingCommon {\nnamespace cl {\n\nstd::unique_ptr<jfs::fuzzingCommon::SeedManagerOptions>\nbuildSeedManagerOptionsFromCmdLine() {\n  std::unique_ptr<SeedManagerOptions> opts(new SeedManagerOptions());\n  opts->maxSeedSpaceInBytes = MaxSeedSpaceInBytes;\n  opts->maxNumSeeds = MaxNumSeed;\n\n  if (AddAllZerosSeed) {\n    auto abeGen = std::unique_ptr<SeedGenerator>(\n        new AllBytesEqualGenerator(\"zeros\", /*byteValue=*/0));\n    opts->generators.push_back(std::move(abeGen));\n  }\n\n  if (AddAllOnesSeed) {\n    auto abeGen = std::unique_ptr<SeedGenerator>(\n        new AllBytesEqualGenerator(\"ones\", /*byteValue=*/0xff));\n    opts->generators.push_back(std::move(abeGen));\n  }\n\n  if (AddSpecialConstantSeeds) {\n    auto scsGen = std::unique_ptr<SeedGenerator>(\n        new SpecialConstantSeedGenerator(\"special-constant\"));\n    opts->generators.push_back(std::move(scsGen));\n  }\n\n  return opts;\n}\n} // namespace cl\n} // namespace fuzzingCommon\n} // namespace jfs\n"
  },
  {
    "path": "lib/FuzzingCommon/CommandLineCategory.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/CommandLineCategory.h\"\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nllvm::cl::OptionCategory CommandLineCategory(\n    \"Fuzzing Common options\",\n    \"These are options that are common to all fuzzing backends\");\n}\n}\n"
  },
  {
    "path": "lib/FuzzingCommon/DummyFuzzingSolver.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/DummyFuzzingSolver.h\"\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace fuzzingCommon {\nDummyFuzzingSolver::DummyFuzzingSolver(\n    std::unique_ptr<SolverOptions> options,\n    std::unique_ptr<WorkingDirectoryManager> wdm, JFSContext& ctx)\n    : FuzzingSolver(std::move(options), std::move(wdm), ctx) {}\n\nDummyFuzzingSolver::~DummyFuzzingSolver() {}\n\nllvm::StringRef DummyFuzzingSolver::getName() const {\n  return \"DummyFuzzingSolver\";\n}\n\nvoid DummyFuzzingSolver::cancel() {\n  // Dummy solver, so nothing to cancel\n}\n\nclass DummyFuzzingSolverResponse : public SolverResponse {\npublic:\n  DummyFuzzingSolverResponse() : SolverResponse(SolverResponse::UNKNOWN) {}\n  Model* getModel() override {\n    // There is no model\n    return nullptr;\n  }\n};\n\nstd::unique_ptr<jfs::core::SolverResponse>\nDummyFuzzingSolver::fuzz(jfs::core::Query& q, bool produceModel,\n                         std::shared_ptr<FuzzingAnalysisInfo> info) {\n  // Don't try to fuzz. Just give up immediately\n  return std::unique_ptr<SolverResponse>(new DummyFuzzingSolverResponse());\n}\n}\n}\n"
  },
  {
    "path": "lib/FuzzingCommon/EqualityExtractionPass.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/EqualityExtractionPass.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include <algorithm>\n#include <memory>\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nEqualityExtractionPass::EqualityExtractionPass() {}\n\nllvm::StringRef EqualityExtractionPass::getName() {\n  return \"EqualityExtractionPass\";\n}\n\nvoid EqualityExtractionPass::cleanUp() {\n  mapping.clear();\n  equalities.clear();\n}\n\nbool EqualityExtractionPass::run(jfs::core::Query& q) {\n  JFSContext& ctx = q.getContext();\n  Z3_context z3Ctx = ctx.getZ3Ctx();\n  mapping.clear();\n  equalities.clear();\n  // Maps from expr to set of equivalent expressions.\n  // NOTE: Multiple keys will map to the same Z3ASTSet\n  std::vector<Z3ASTHandle> newConstraints;\n  newConstraints.reserve(q.constraints.size());\n\n  for (auto bi = q.constraints.begin(), be = q.constraints.end(); bi != be;\n       ++bi) {\n    Z3ASTHandle node = *bi;\n\n    // TODO: We probably should add more cancellation points.\n    if (cancelled) {\n      IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\");\n      cleanUp();\n      return false;\n    }\n    // Now pattern match the equality for the cases we\n    // know we can help the fuzzer\n    std::vector<Z3ASTHandle> equalOperands;\n    equalOperands.reserve(2);\n\n    if (node.isFreeVariable() && node.getSort().isBoolTy()) {\n      // Match\n      // `<variable>` where <variable> has boolean sort\n      // this is equivalent to\n      // `(= <variable> true)`\n      equalOperands.push_back(node);\n      equalOperands.push_back(Z3ASTHandle(::Z3_mk_true(z3Ctx), z3Ctx));\n    } else if (node.isAppOf(Z3_OP_NOT)) {\n      // Match\n      // `(not <variable>)` where <variable> has boolean sort\n      // this is equivalent to\n      // `(= <variable> false)`\n      Z3ASTHandle child = node.asApp().getKid(0);\n      if (child.isFreeVariable() && child.getSort().isBoolTy()) {\n        equalOperands.push_back(child);\n        equalOperands.push_back(Z3ASTHandle(::Z3_mk_false(z3Ctx), z3Ctx));\n      }\n    } else if (node.isAppOf(Z3_OP_EQ)) {\n      // Match\n      // `(= <variable> <variable>)`\n      // `(= <variable> <constant>)`\n      // TODO: Match `(= <variable> <sort cast of variable>)`\n      // TODO: Match `(= <sort cast of variable> <sort cast of variable>)`\n      Z3AppHandle eqApp = node.asApp();\n      assert(eqApp.getKind() == Z3_OP_EQ);\n      for (unsigned index = 0; index < eqApp.getNumKids(); ++index) {\n        Z3ASTHandle kid = eqApp.getKid(index);\n        if (kid.isFreeVariable()) {\n          // free variable\n          equalOperands.push_back(kid);\n          continue;\n        } else if (kid.isConstant()) {\n          // constant operand\n          equalOperands.push_back(kid);\n          continue;\n        }\n        // Operand is not accepted.\n        // Failed to match the pattern\n        equalOperands.clear();\n        break;\n      }\n    }\n\n    if (equalOperands.size() == 0) {\n      // Equality didn't match patterns. Keep the constraint\n      newConstraints.push_back(node);\n      continue;\n    }\n\n    // Pattern is matched. We won't keep this constraint\n    // and will instead record this equality\n\n    // See if we have an existing equality sets.\n    // If we match more than one equality set we need to destory\n    // one of the existing sets and do a union\n    std::vector<std::shared_ptr<Z3ASTSet>> matchingEqualitySets;\n    for (const auto& e : equalOperands) {\n      auto kv = mapping.find(e);\n      if (kv != mapping.end()) {\n        matchingEqualitySets.push_back(kv->second);\n      }\n    }\n    std::shared_ptr<Z3ASTSet> equalitySet = nullptr;\n    if (matchingEqualitySets.size() <= 1) {\n      if (matchingEqualitySets.size() == 0) {\n        // Simple case there are no existing equality sets\n        // that match. Need to create new equality set\n        equalitySet = std::make_shared<Z3ASTSet>();\n        equalities.insert(equalitySet);\n      } else {\n        // Simple case there is just one matching equality set\n        equalitySet = matchingEqualitySets[0];\n      }\n      for (auto ei = equalOperands.begin(), ee = equalOperands.end(); ei != ee;\n           ++ei) {\n        equalitySet->insert(*ei);\n      }\n      // Now insert the keys into the mapping\n      for (auto ei = equalOperands.begin(), ee = equalOperands.end(); ei != ee;\n           ++ei) {\n        mapping.insert(std::make_pair(*ei, equalitySet));\n      }\n    } else if (matchingEqualitySets.size() > 1) {\n      // Complex case. There are multiple existing equality\n      // sets that match. That means we need to union them\n      // and remove all the old mappings.\n\n      // Find the largest set and make that the set which will\n      // become the union of the other sets.\n      equalitySet = *(std::max_element(matchingEqualitySets.begin(),\n                                       matchingEqualitySets.end(),\n                                       [](const std::shared_ptr<Z3ASTSet>& a,\n                                          const std::shared_ptr<Z3ASTSet>& b) {\n                                         return a->size() < b->size();\n                                       }));\n\n      // Add the equal operands\n      equalitySet->insert(equalOperands.begin(), equalOperands.end());\n\n      // Now union with other sets\n      for (const auto& otherEqualitySet : matchingEqualitySets) {\n        if (otherEqualitySet.get() == equalitySet.get()) {\n          continue;\n        }\n        // Union otherEqualitySet and equalitySet\n        equalitySet->insert(otherEqualitySet->begin(), otherEqualitySet->end());\n        // Erase the old equality set\n        equalities.erase(otherEqualitySet);\n      }\n      // Now update all mappings.\n      for (const auto& expr : *equalitySet) {\n        mapping[expr] = equalitySet;\n      }\n    }\n  }\n\n  if (mapping.size() == 0) {\n    // No equalites were found so nothing was changed.\n    return false;\n  }\n\n  // Do we really want this? Preprocessing steps will probably mean\n  // we don't hit this case.\n  // Sanity check the equality sets. If there are multiple constants\n  // in an equality set we've found an inconsistency.\n  for (auto mi = mapping.cbegin(), me = mapping.cend(); mi != me; ++mi) {\n    auto equalitySet = mi->second;\n    unsigned constantCount =\n        std::count_if(equalitySet->cbegin(), equalitySet->cend(),\n                      [](Z3ASTHandle e) { return e.isConstant(); });\n    if (constantCount > 1) {\n      // Found inconsistency. Replace constraints with false\n      q.constraints.clear();\n      q.constraints.push_back(Z3ASTHandle(::Z3_mk_false(z3Ctx), z3Ctx));\n      return true;\n    }\n  }\n\n  // Modify constraints\n  q.constraints = std::move(newConstraints);\n\n  if (ctx.getVerbosity() > 1) {\n    auto& ss = ctx.getDebugStream();\n    ss << \"(\" << getName() << \"\\n\";\n    ss << \"  equality sets: \" << equalities.size() << \"\\n\";\n    if (equalities.size() > 0) {\n      ss << \"  (\\n\";\n      for (auto& es : equalities) {\n        ss << \"    (\\n\";\n        const Z3ASTSet& eqSet = *(es.get());\n        for (auto& ee : eqSet) {\n          ss << \"      \" << ee.toStr() << \"\\n\";\n        }\n        ss << \"    )\\n\";\n      }\n      ss << \"  )\\n\";\n    }\n  }\n  return true;\n}\n\nbool EqualityExtractionPass::convertModel(jfs::core::Model* model) {\n  for (auto& es : equalities) {\n    Z3FuncDeclSet needsAssignment;\n    Z3ASTSet assignment;\n    for (auto& e : *es) {\n      if (e.isConstant()) {\n        // This is a constant to assign\n        assert(assignment.size() == 0);\n        auto successIteratorPair = assignment.insert(e);\n        assert(successIteratorPair.second && \"insertion failed\");\n        continue;\n      }\n      assert(e.isFreeVariable());\n      // Get the corresponding Z3FuncDecl.\n      Z3FuncDeclHandle decl = e.asApp().getFuncDecl();\n      if (model->hasAssignmentFor(decl)) {\n        // We already have an assignment for this.\n        // This implies that all other variables in the equality\n        // set should get this assignment.\n        assert(assignment.size() == 0);\n        Z3ASTHandle assignmentForSet = model->getAssignmentFor(decl);\n        assert(!assignmentForSet.isNull());\n        auto successIteratorPair = assignment.insert(assignmentForSet);\n        assert(successIteratorPair.second && \"insertion failed\");\n        continue;\n      }\n\n      // This variable needs an assignment\n      auto successIteratorPair = needsAssignment.insert(decl);\n      assert(successIteratorPair.second && \"insertion failed\");\n    }\n    if (needsAssignment.size() == 0) {\n      // Nothing to do\n      continue;\n    }\n    assert(assignment.size() == 0 || assignment.size() == 1);\n    if (assignment.size() == 0) {\n      // Special case: The supplied model didn't provide an assignment\n      // to any decl in the equality set. This implies we can pick any value.\n      // We have to add the assignment because model completion won't know\n      // the relationship between these variables.\n      Z3SortHandle sort = needsAssignment.begin()->getSort();\n      // Based on the sort pick a sensible value\n      Z3ASTHandle assignmentToUse = Model::getDefaultValueFor(sort);\n      auto successIteratorPair = assignment.insert(assignmentToUse);\n      assert(successIteratorPair.second && \"insertion failed\");\n    }\n\n    // Now add assignments to model\n    assert(assignment.size() == 1);\n    Z3ASTHandle assignmentForSet = *(assignment.begin());\n    for (auto& decl : needsAssignment) {\n      model->addAssignmentFor(decl, assignmentForSet);\n    }\n  }\n  return true;\n}\n}\n}\n"
  },
  {
    "path": "lib/FuzzingCommon/FileSerializableModel.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Alastair Donaldson\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/FileSerializableModel.h\"\n\n// We reuse the runtime code to also save and load assignments on disk.\n#include \"SMTLIB/NativeBitVector.h\"\n#include \"SMTLIB/NativeFloat.h\"\n\nusing namespace jfs::core;\n\nnamespace {\n\nbool accessInRange(size_t bufferSize, unsigned startBit, unsigned endBit) {\n  unsigned startByte = startBit / 8;\n  unsigned endByte = endBit / 8;\n  return endBit >= startBit && startByte < bufferSize && endByte < bufferSize;\n}\n\nbool accessInRange(const llvm::MemoryBuffer* mb, unsigned startBit,\n                   unsigned endBit) {\n  return accessInRange(mb->getBufferSize(), startBit, endBit);\n}\n\nbool accessInRange(const llvm::FileOutputBuffer* buf, unsigned startBit,\n                   unsigned bitWidth) {\n  unsigned endBit = startBit + bitWidth - 1;\n  return accessInRange(buf->getBufferSize(), startBit, endBit);\n}\n\nZ3ASTHandle loadBool(JFSContext& ctx, const llvm::MemoryBuffer* mb,\n                     Z3SortHandle sort, unsigned startBit, unsigned endBit) {\n  assert(sort.isBoolTy());\n  if (!accessInRange(mb, startBit, endBit)) {\n    ctx.raiseFatalError(\"load out of range of buffer\");\n    return Z3ASTHandle();\n  }\n  unsigned bitWidth = (endBit - startBit) + 1;\n  assert(bitWidth <= 8);\n  assert(bitWidth > 0);\n  jfs_nr_bitvector_ty rawBits = jfs_nr_make_bitvector(\n      /*bufferData=*/reinterpret_cast<const uint8_t*>(mb->getBufferStart()),\n      /*bufferSize=*/mb->getBufferSize(),\n      /*lowBit=*/startBit,\n      /*highBit=*/endBit);\n  if (rawBits)\n    return Z3ASTHandle::getTrue(ctx.getZ3Ctx());\n  return Z3ASTHandle::getFalse(ctx.getZ3Ctx());\n}\n\nbool saveBool(JFSContext& ctx, llvm::FileOutputBuffer* buf, Z3SortHandle sort,\n              Z3AppHandle assignment, unsigned startBit, unsigned bitWidth) {\n  assert(sort.isBoolTy());\n  if (!accessInRange(buf, startBit, bitWidth)) {\n    ctx.raiseFatalError(\"save out of range of buffer\");\n    return false;\n  }\n  assert(bitWidth <= 8);\n  assert(bitWidth > 0);\n  jfs_nr_bitvector_ty rawBits = 0;\n  if (assignment.asAST().isTrue()) {\n    rawBits = 1;\n  }\n  jfs_nr_write_bitvector(\n      /*bv=*/rawBits,\n      /*bitWidth=*/bitWidth,\n      /*bufferData=*/reinterpret_cast<uint8_t*>(buf->getBufferStart()),\n      /*bufferSize=*/buf->getBufferSize(),\n      /*bitOffset=*/startBit);\n  return true;\n}\n\nZ3ASTHandle loadBitVector(JFSContext& ctx, const llvm::MemoryBuffer* mb,\n                          Z3SortHandle sort, unsigned startBit,\n                          unsigned endBit) {\n  assert(sort.isBitVectorTy());\n  if (!accessInRange(mb, startBit, endBit)) {\n    ctx.raiseFatalError(\"load out of range of buffer\");\n    return Z3ASTHandle();\n  }\n  auto bitWidth = sort.getBitVectorWidth(); // In bits\n  assert(bitWidth == (endBit - startBit + 1));\n  assert(bitWidth > 0);\n  if (bitWidth > 64) {\n    // TODO: When we support larger sorts add support here to load them\n    // from the buffer.\n    ctx.raiseFatalError(\"Can't load > 64 bit wide bitvector\");\n    return Z3ASTHandle();\n  }\n  jfs_nr_bitvector_ty rawBits = jfs_nr_make_bitvector(\n      /*bufferData=*/reinterpret_cast<const uint8_t*>(mb->getBufferStart()),\n      /*bufferSize=*/mb->getBufferSize(),\n      /*lowBit=*/startBit,\n      /*highBit=*/endBit);\n  return Z3ASTHandle(Z3_mk_unsigned_int64(ctx.getZ3Ctx(), rawBits, sort),\n                     ctx.getZ3Ctx());\n}\n\nbool saveBitVector(JFSContext& ctx, llvm::FileOutputBuffer* buf,\n                   Z3SortHandle sort, Z3AppHandle assignment, unsigned startBit,\n                   unsigned bitWidth) {\n  assert(sort.isBitVectorTy());\n  if (!accessInRange(buf, startBit, bitWidth)) {\n    ctx.raiseFatalError(\"save out of range of buffer\");\n    return false;\n  }\n  assert(bitWidth == sort.getBitVectorWidth());\n  assert(bitWidth > 0);\n  if (bitWidth > 64) {\n    // TODO: When we support larger sorts add support here to save them\n    // to the buffer.\n    ctx.raiseFatalError(\"Can't save > 64 bit wide bitvector\");\n    return false;\n  }\n  jfs_nr_bitvector_ty bv;\n  if (!assignment.getConstantAsUInt64(&bv)) {\n    ctx.raiseFatalError(\"Failed to get bitvector constant while saving\");\n    return false;\n  }\n  jfs_nr_write_bitvector(\n      /*bv=*/bv,\n      /*bitWidth=*/bitWidth,\n      /*bufferData=*/reinterpret_cast<uint8_t*>(buf->getBufferStart()),\n      /*bufferSize=*/buf->getBufferSize(),\n      /*bitOffset=*/startBit);\n  return true;\n}\n\nZ3ASTHandle loadFloatingPoint(JFSContext& ctx, const llvm::MemoryBuffer* mb,\n                              Z3SortHandle sort, unsigned startBit,\n                              unsigned endBit,\n                              bool convertedBvAssignment = false) {\n  assert(sort.isFloatingPointTy());\n  unsigned ebits = sort.getFloatingPointExponentBitWidth();\n  unsigned sbits = sort.getFloatingPointSignificandBitWidth();\n  Z3ASTHandle e;\n  // TODO: When we support other floating-point types add support here too.\n  if (ebits == 8 && sbits == 24) {\n    // Float32\n    e = loadBitVector(ctx, mb, Z3SortHandle::getBitVectorTy(ctx.getZ3Ctx(), 32),\n                      startBit, endBit);\n  } else if (ebits == 11 && sbits == 53) {\n    // Float64\n    e = loadBitVector(ctx, mb, Z3SortHandle::getBitVectorTy(ctx.getZ3Ctx(), 64),\n                      startBit, endBit);\n  } else {\n    ctx.raiseFatalError(\"Can't load unsupported floating-point type\");\n    return Z3ASTHandle();\n  }\n\n  // Create conversion AST node\n  Z3ASTHandle convToFp =\n      Z3ASTHandle(Z3_mk_fpa_to_fp_bv(ctx.getZ3Ctx(), e, sort), ctx.getZ3Ctx());\n  if (convertedBvAssignment) {\n    // Return non-constant expression (conversion of a constant)\n    return convToFp;\n  }\n  // Simplify the expression so we have a plain constant.\n  Z3ASTHandle simplified =\n      Z3ASTHandle(Z3_simplify(ctx.getZ3Ctx(), convToFp), ctx.getZ3Ctx());\n  assert(simplified.isConstant());\n  return simplified;\n}\n\nbool saveFloatingPointSpecial32(JFSContext& ctx, llvm::FileOutputBuffer* buf,\n                                Z3SortHandle sort, Z3AppHandle assignment,\n                                unsigned startBit, unsigned bitWidth) {\n  jfs_nr_float32 value;\n  switch (assignment.getKind()) {\n  case Z3_OP_FPA_PLUS_ZERO:\n    value = jfs_nr_float32_get_zero(/*positive=*/true);\n    break;\n  case Z3_OP_FPA_MINUS_ZERO:\n    value = jfs_nr_float32_get_zero(/*positive=*/false);\n    break;\n  case Z3_OP_FPA_PLUS_INF:\n    value = jfs_nr_float32_get_infinity(/*positive=*/true);\n    break;\n  case Z3_OP_FPA_MINUS_INF:\n    value = jfs_nr_float32_get_infinity(/*positive=*/false);\n    break;\n  case Z3_OP_FPA_NAN:\n    value = jfs_nr_float32_get_nan(/*quiet=*/true);\n    break;\n  default:\n    llvm_unreachable(\"Expected special floating point constant\");\n  }\n  jfs_nr_bitvector_ty valueAsBits = 0;\n  std::memcpy(&valueAsBits, &value, sizeof value);\n  jfs_nr_write_bitvector(\n      /*bv=*/valueAsBits,\n      /*bitWidth=*/bitWidth,\n      /*bufferData=*/reinterpret_cast<uint8_t*>(buf->getBufferStart()),\n      /*bufferSize=*/buf->getBufferSize(),\n      /*bitOffset=*/startBit);\n  return true;\n}\n\nbool saveFloatingPointSpecial64(JFSContext& ctx, llvm::FileOutputBuffer* buf,\n                                Z3SortHandle sort, Z3AppHandle assignment,\n                                unsigned startBit, unsigned bitWidth) {\n  jfs_nr_float64 value;\n  switch (assignment.getKind()) {\n  case Z3_OP_FPA_PLUS_ZERO:\n    value = jfs_nr_float64_get_zero(/*positive=*/true);\n    break;\n  case Z3_OP_FPA_MINUS_ZERO:\n    value = jfs_nr_float64_get_zero(/*positive=*/false);\n    break;\n  case Z3_OP_FPA_PLUS_INF:\n    value = jfs_nr_float64_get_infinity(/*positive=*/true);\n    break;\n  case Z3_OP_FPA_MINUS_INF:\n    value = jfs_nr_float64_get_infinity(/*positive=*/false);\n    break;\n  case Z3_OP_FPA_NAN:\n    value = jfs_nr_float64_get_nan(/*quiet=*/true);\n    break;\n  default:\n    llvm_unreachable(\"Expected special floating point constant\");\n  }\n  jfs_nr_bitvector_ty valueAsBits = 0;\n  std::memcpy(&valueAsBits, &value, sizeof value);\n  jfs_nr_write_bitvector(\n      /*bv=*/valueAsBits,\n      /*bitWidth=*/bitWidth,\n      /*bufferData=*/reinterpret_cast<uint8_t*>(buf->getBufferStart()),\n      /*bufferSize=*/buf->getBufferSize(),\n      /*bitOffset=*/startBit);\n  return true;\n}\n\nbool saveFloatingPoint(JFSContext& ctx, llvm::FileOutputBuffer* buf,\n                       Z3SortHandle sort, Z3AppHandle assignment,\n                       unsigned startBit, unsigned bitWidth) {\n  assert(sort.isFloatingPointTy());\n  unsigned ebits = sort.getFloatingPointExponentBitWidth();\n  unsigned sbits = sort.getFloatingPointSignificandBitWidth();\n\n  // Handle special constants\n  if (assignment.isSpecialFPConstant()) {\n    if (ebits == 8 && sbits == 24) {\n      // Float32\n      return saveFloatingPointSpecial32(ctx, buf, sort, assignment, startBit,\n                                        bitWidth);\n    } else if (ebits == 11 && sbits == 53) {\n      // Float64\n      return saveFloatingPointSpecial64(ctx, buf, sort, assignment, startBit,\n                                        bitWidth);\n    } else {\n      ctx.raiseFatalError(\"Can't save unsupported floating-point type\");\n      return false;\n    }\n  }\n\n  // Handle numeric constants through conversion to a bit vector.\n  Z3ASTHandle convToBv = Z3ASTHandle(\n      Z3_mk_fpa_to_ieee_bv(ctx.getZ3Ctx(), assignment.asAST()), ctx.getZ3Ctx());\n  // Simplify the expression so we have a bit vector.\n  Z3ASTHandle assignmentBv =\n      Z3ASTHandle(Z3_simplify(ctx.getZ3Ctx(), convToBv), ctx.getZ3Ctx());\n\n  assert(assignmentBv.isConstant());\n  sort = assignmentBv.getSort();\n  assert(sort.isBitVectorTy());\n\n  return saveBitVector(ctx, buf, sort, assignmentBv.asApp(), startBit,\n                       bitWidth);\n}\n} // namespace\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nFileSerializableModel::FileSerializableModel(JFSContext& ctx)\n    : jfs::core::Model(ctx) {\n  // Empty model\n  z3Model = Z3ModelHandle(Z3_mk_model(ctx.getZ3Ctx()), ctx.getZ3Ctx());\n}\n\nstd::unique_ptr<FileSerializableModel>\nFileSerializableModel::loadFrom(const llvm::MemoryBuffer* buf,\n                                const BufferAssignment* ba, JFSContext& ctx) {\n  assert(buf != nullptr);\n  assert(ba != nullptr);\n  std::unique_ptr<FileSerializableModel> fsm(new FileSerializableModel(ctx));\n  auto z3Model = fsm->z3Model;\n\n  // Check buffer size is as expected\n  if (buf->getBufferSize() != ba->getRequiredStoreBytes()) {\n    ctx.getWarningStream()\n        << \"(warning Failed to load model from file due to size mismatch.\"\n           \"expected:\"\n        << ba->getRequiredStoreBytes() << \" actual:\" << buf->getBufferSize()\n        << \" bytes)\";\n    return nullptr;\n  }\n\n  unsigned currentBufferBit = 0;\n  for (const auto& be : *ba) {\n    // Add assignment\n    unsigned endBufferBit = (currentBufferBit + be.getTypeBitWidth()) - 1;\n\n    Z3ASTHandle assignmentExpr;\n    // Dispatch to the appropriate helper function for the expr sort\n    switch (be.getSort().getKind()) {\n    case Z3_BOOL_SORT: {\n      assignmentExpr =\n          loadBool(ctx, buf, be.getSort(), currentBufferBit, endBufferBit);\n      break;\n    }\n    case Z3_BV_SORT: {\n      assignmentExpr =\n          loadBitVector(ctx, buf, be.getSort(), currentBufferBit, endBufferBit);\n      break;\n    }\n    case Z3_FLOATING_POINT_SORT: {\n      assignmentExpr = loadFloatingPoint(ctx, buf, be.getSort(),\n                                         currentBufferBit, endBufferBit);\n      break;\n    }\n    default:\n      llvm_unreachable(\"Unhandled sort\");\n    }\n\n    // FIXME: Provide option to fold model assignments to pure constants.\n    // Add assignment to Z3 model\n    assert(!assignmentExpr.isNull());\n    assert(assignmentExpr.isConstant());\n    bool success = fsm->addAssignmentFor(be.getDecl(), assignmentExpr);\n    assert(success);\n\n    // Notice we use `getStoreBitWidth() and not `getTypeBitWidth()`.\n    // This means that if the type has alignment that we will skip\n    // some bits.\n    currentBufferBit += be.getStoreBitWidth();\n  }\n  return fsm;\n}\n\nbool FileSerializableModel::saveTo(llvm::FileOutputBuffer* buf,\n                                   const BufferAssignment* ba,\n                                   jfs::core::JFSContext& ctx) {\n  assert(buf != nullptr);\n  assert(ba != nullptr);\n\n  // Check buffer size is as expected\n  if (buf->getBufferSize() != ba->getRequiredStoreBytes()) {\n    ctx.getWarningStream()\n        << \"(warning Failed to save model to file due to size mismatch.\"\n           \"expected:\"\n        << ba->getRequiredStoreBytes() << \" actual:\" << buf->getBufferSize()\n        << \" bytes)\";\n    return false;\n  }\n\n  // Initialize the buffer to all zeros because later steps won't write to the\n  // padding bits. If we don't do this, those bits will be left uninitialized\n  // which could cause non-determinism when seeding the fuzzer with the\n  // serialized model.\n  memset(buf->getBufferStart(), 0, buf->getBufferSize());\n\n  unsigned currentBufferBit = 0;\n  for (const auto& be : *ba) {\n    // Save assignment to buffer.\n    const unsigned bitWidth = be.getTypeBitWidth();\n\n    Z3ASTHandle assignment = getAssignmentFor(be.getDecl());\n    assert(!assignment.isNull());\n\n    // Dispatch to the appropriate helper function for the expr sort\n    bool success;\n    switch (be.getSort().getKind()) {\n    case Z3_BOOL_SORT: {\n      success = saveBool(ctx, buf, be.getSort(), assignment.asApp(),\n                         currentBufferBit, bitWidth);\n      break;\n    }\n    case Z3_BV_SORT: {\n      success = saveBitVector(ctx, buf, be.getSort(), assignment.asApp(),\n                              currentBufferBit, bitWidth);\n      break;\n    }\n    case Z3_FLOATING_POINT_SORT: {\n      success = saveFloatingPoint(ctx, buf, be.getSort(), assignment.asApp(),\n                                  currentBufferBit, bitWidth);\n      break;\n    }\n    default:\n      llvm_unreachable(\"Unhandled sort\");\n    }\n\n    assert(success);\n\n    // Notice we use `getStoreBitWidth() and not `getTypeBitWidth()`.\n    // This means that if the type has alignment that we will skip\n    // some bits.\n    currentBufferBit += be.getStoreBitWidth();\n  }\n\n  // Commit saved contents to disk.\n  if (auto error = buf->commit()) {\n    auto errCode = llvm::errorToErrorCode(std::move(error));\n    ctx.getErrorStream()\n        << \"(error Failed to commit model because \\\"\" << errCode.message()\n        << \"\\\")\\n\";\n    return false;\n  }\n\n  return true;\n};\n} // namespace fuzzingCommon\n} // namespace jfs\n"
  },
  {
    "path": "lib/FuzzingCommon/FreeVariableToBufferAssignmentPass.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/FreeVariableToBufferAssignmentPass.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include \"jfs/FuzzingCommon/CommandLineCategory.h\"\n#include \"llvm/Support/CommandLine.h\"\n#include <algorithm>\n#include <list>\n#include <vector>\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nvoid ConstantAssignment::print(llvm::raw_ostream& os) const {\n  os << \"(ConstantAssignment \" << assignments.size() << \" entries\";\n  if (assignments.size() > 0)\n    os << \"\\n\";\n  for (const auto& kvp : assignments) {\n    assert(kvp.first.isApp() && \"key must be application\");\n    assert(kvp.first.isFreeVariable() && \"key must be free variable\");\n    os << \"  [\" << kvp.first.asApp().getFuncDecl().getName()\n       << \"] = \" << kvp.second.toStr() << \"\\n\";\n  }\n  os << \")\\n\";\n}\n\nvoid ConstantAssignment::dump() const { print(llvm::errs()); }\n\nFreeVariableToBufferAssignmentPass::FreeVariableToBufferAssignmentPass(\n    const EqualityExtractionPass& eep,\n    FreeVariableToBufferAssignmentPassOptions* options)\n    : eep(eep), options(options) {\n  if (options == nullptr) {\n    // Use default options if not set.\n    defaultOptions.reset(new FreeVariableToBufferAssignmentPassOptions());\n    this->options = defaultOptions.get();\n  }\n}\n\nllvm::StringRef FreeVariableToBufferAssignmentPass::getName() {\n  return \"FreeVariableToBufferAssignmentPass\";\n}\n\nbool FreeVariableToBufferAssignmentPass::run(jfs::core::Query& q) {\n  JFSContext& ctx = q.getContext();\n  // Do DFS to find all free variables\n  Z3ASTSet seenExpr;\n  // NOTE: We don't store the Z3FuncDeclHandle, instead we\n  // store the applications of it and assume that Z3, \"uniques\"\n  // these for us.\n  Z3ASTSet freeVariableApps;\n  // This contains the same ASTs as `freeVariableApps` but gives\n  // a deterministic ordering.\n  std::vector<Z3ASTHandle> orderedFreeVariableApps;\n\n  auto sortStrategy = FreeVariableToBufferAssignmentPassOptions::\n      FreeVariableSortStrategyTy::FIRST_OBSERVED;\n  if (options) {\n    sortStrategy = options->sortStrategy;\n  }\n\n  std::list<Z3ASTHandle> workList;\n  for (const auto& c : q.constraints) {\n    workList.push_back(c);\n  }\n  while (workList.size() > 0) {\n    Z3ASTHandle node = workList.front();\n    workList.pop_front();\n\n    // TODO: Should probably add more cancellation points.\n    if (cancelled) {\n      IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\");\n      return false;\n    }\n\n    if (seenExpr.count(node) > 0) {\n      // Visited this Expr before\n      continue;\n    }\n    seenExpr.insert(node);\n    if (node.isFreeVariable()) {\n      auto itSucPair = freeVariableApps.insert(node);\n      if (itSucPair.second &&\n          sortStrategy == FreeVariableToBufferAssignmentPassOptions::\n                              FreeVariableSortStrategyTy::FIRST_OBSERVED) {\n        // This is the first time we've observed this free variable\n        // and we are using the \"first observed\" ordering strategy\n        // so add the free variable to the ordered list.\n        orderedFreeVariableApps.push_back(node);\n      }\n      continue;\n    }\n    if (!node.isApp()) {\n      continue;\n    }\n    Z3AppHandle asApp = node.asApp();\n    // Must be an application. Add its arguments to the work list\n    for (unsigned index = 0; index < asApp.getNumKids(); ++index) {\n      workList.push_front(asApp.getKid((asApp.getNumKids() - 1) - index));\n    }\n  }\n\n  // Now pick a deterministic ordering\n  // FIXME: We should implement another strategy that is optimal (minimise\n  // wasted bits) when buffer elements are byte aligned. We could also tightly\n  // pack booleans together (slightly violating the buffer alignment).\n  switch (sortStrategy) {\n  case FreeVariableToBufferAssignmentPassOptions::FreeVariableSortStrategyTy::\n      ALPHABETICAL: {\n    // This strategy scales very poorly with a large number of free variables.\n    assert(orderedFreeVariableApps.size() == 0);\n    orderedFreeVariableApps.insert(orderedFreeVariableApps.end(),\n                                   freeVariableApps.cbegin(),\n                                   freeVariableApps.cend());\n    std::sort(orderedFreeVariableApps.begin(), orderedFreeVariableApps.end(),\n              [](const Z3ASTHandle& a, const Z3ASTHandle& b) {\n                return a.asApp().getFuncDecl().toStr() <\n                       b.asApp().getFuncDecl().toStr();\n              });\n    break;\n  }\n  case FreeVariableToBufferAssignmentPassOptions::FreeVariableSortStrategyTy::\n      NONE: {\n    assert(orderedFreeVariableApps.size() == 0);\n    orderedFreeVariableApps.insert(orderedFreeVariableApps.end(),\n                                   freeVariableApps.cbegin(),\n                                   freeVariableApps.cend());\n    // Add with non-deterministic ordering\n    break;\n  }\n  case FreeVariableToBufferAssignmentPassOptions::FreeVariableSortStrategyTy::\n      FIRST_OBSERVED: {\n    // Nothing to do\n    assert(orderedFreeVariableApps.size() == freeVariableApps.size());\n    break;\n  }\n  default:\n    llvm_unreachable(\"Unknown sort strategy\");\n  }\n\n  // Pick the alignment\n  size_t bufferElStoreBitAlignment = 1;\n  if (options) {\n    bufferElStoreBitAlignment = options->bufferElementBitAlignment;\n  }\n\n  // Now record the buffer assignment taking into account equalities\n  // NOTE: This approach means that equalities that aren't used in\n  // the query are not added. From a fuzzing perspective this means\n  // those equalites don't need to be considered because they can be\n  // trivialled satisfied.\n  bufferAssignment = std::make_shared<BufferAssignment>();\n  constantAssignments = std::make_shared<ConstantAssignment>();\n  Z3ASTSet alreadyAssigned; // Already assigned to constant map or buffer\n  for (const auto& freeVarApp : orderedFreeVariableApps) {\n    if (cancelled) {\n      IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\");\n      return false;\n    }\n\n    if (alreadyAssigned.count(freeVarApp) > 0) {\n      // We have already assigned this variable a position\n      // in the buffer.\n      continue;\n    }\n    alreadyAssigned.insert(freeVarApp);\n\n    assert(freeVarApp.isFreeVariable());\n    // See if this variable belongs to a set of known equalities.\n    const auto equalitySetsIt = eep.mapping.find(freeVarApp);\n    if (equalitySetsIt == eep.mapping.end()) {\n      // No equalites so append to buffer\n      BufferElement el(freeVarApp, bufferElStoreBitAlignment);\n      bufferAssignment->appendElement(el);\n      continue;\n    }\n\n    // Equalites\n    // We need to now decide which free variable is represent\n    // in the buffer and what will be derived from it.\n    // FIXME: We are very tightly coupled to the EqualityExtractionPass\n    // here. Can this be fixed?\n\n    // Handle constant assignment case.\n    Z3ASTHandle foundConstant;\n    const Z3ASTSet& equalitySet = *((*equalitySetsIt).second.get());\n    // FIXME: Should add assert that we only see one constant\n    for (const auto& e : equalitySet) {\n      if (e.isConstant()) {\n        foundConstant = e;\n        break;\n      }\n    }\n    if (!foundConstant.isNull()) {\n      // This variable belongs to an equality set that contains\n      // a constant. This means that we shouldn't assign this\n      // variable to the buffer. Instead we should add it to\n      // constant assignment map\n      for (const auto& e : equalitySet) {\n        if (e == foundConstant) {\n          continue;\n        }\n        // FIXME: When EqualityExtractionPass supports free variable\n        // casts we will need to figure out how to handle this.\n        assert(e.isFreeVariable() && \"key must be free variable\");\n        auto itSuc = constantAssignments->assignments.insert(\n            std::make_pair(e, foundConstant));\n        assert(itSuc.second && \"constant table cannot already have assignment\");\n        alreadyAssigned.insert(e);\n      }\n      continue;\n    }\n\n    // The variable needs to be assigned to the buffer but there\n    // are equalities that need to be enforced.\n    BufferElement el(freeVarApp, bufferElStoreBitAlignment);\n    for (const auto& e : equalitySet) {\n      if (e == freeVarApp) {\n        continue;\n      }\n      el.equalities.push_back(e);\n      alreadyAssigned.insert(e);\n    }\n    bufferAssignment->appendElement(el);\n  }\n\n  if (ctx.getVerbosity() > 1) {\n    bufferAssignment->print(ctx.getDebugStream());\n    constantAssignments->print(ctx.getDebugStream());\n  }\n  return false;\n}\n\nbool FreeVariableToBufferAssignmentPass::convertModel(jfs::core::Model* m) {\n  // This pass preserves equivalence so the model does not need to be\n  // converted.\n  return true;\n}\n}\n}\n"
  },
  {
    "path": "lib/FuzzingCommon/FreeVariableToBufferAssignmentPassOptions.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/FreeVariableToBufferAssignmentPassOptions.h\"\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nFreeVariableToBufferAssignmentPassOptions::\n    FreeVariableToBufferAssignmentPassOptions() {}\n} // namespace fuzzingCommon\n} // namespace jfs\n"
  },
  {
    "path": "lib/FuzzingCommon/FuzzingAnalysisInfo.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/FuzzingAnalysisInfo.h\"\n#include \"jfs/FuzzingCommon/FreeVariableToBufferAssignmentPassOptions.h\"\n#include \"llvm/Support/CommandLine.h\"\n\nnamespace {\n\nllvm::cl::opt<bool> DisableEqualityExtraction(\n    \"disable-equality-extraction\", llvm::cl::init(false),\n    llvm::cl::desc(\"Do not run equality extraction (default false)\"));\n}\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nFuzzingAnalysisInfo::FuzzingAnalysisInfo(\n    FreeVariableToBufferAssignmentPassOptions* fvtbapOptions)\n    : equalityExtraction(std::make_shared<EqualityExtractionPass>()) {\n  freeVariableAssignment = std::make_shared<FreeVariableToBufferAssignmentPass>(\n      *equalityExtraction, fvtbapOptions);\n}\n\nFuzzingAnalysisInfo::~FuzzingAnalysisInfo() {}\n\nvoid FuzzingAnalysisInfo::addTo(jfs::transform::QueryPassManager &pm) {\n  // TODO: Enforce that this can only be called once\n\n  // Look for equalities, extract them and remove them from the constraints\n  if (!DisableEqualityExtraction) {\n    pm.add(equalityExtraction);\n  }\n  pm.add(freeVariableAssignment);\n}\n}\n}\n"
  },
  {
    "path": "lib/FuzzingCommon/FuzzingSolver.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/FuzzingSolver.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/SimpleModel.h\"\n#include \"jfs/FuzzingCommon/FuzzingAnalysisInfo.h\"\n#include \"jfs/FuzzingCommon/FuzzingSolverOptions.h\"\n#include \"jfs/Transform/QueryPassManager.h\"\n#include \"llvm/Support/Casting.h\"\n#include <atomic>\n#include <mutex>\n\nusing namespace jfs::core;\nusing namespace jfs::transform;\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nclass FuzzingSolverImpl;\n\n// This response type is used for the trivial queries\n// that we can solve without fuzzing\nclass TrivialFuzzingSolverResponse : public jfs::core::SolverResponse {\nprivate:\n  friend class FuzzingSolverImpl;\n  std::unique_ptr<jfs::core::Model> model;\n  void setModel(std::unique_ptr<jfs::core::Model> m) { model = std::move(m); }\n\npublic:\n  TrivialFuzzingSolverResponse(SolverResponse::SolverSatisfiability sat)\n      : SolverResponse(sat) {}\n  Model* getModel() override {\n    if (sat != SolverSatisfiability::SAT)\n      return nullptr;\n    return model.get();\n  }\n};\n\n// FIXME: This complication exists because I don't want to expose the\n// implementation details to the client. This might be too complicated.\nclass FuzzingSolverImpl {\n  std::atomic<bool> cancelled;\n  FuzzingSolver* interF;\n  std::mutex cancellablePassManagerMutex;\n  QueryPassManager* cancellablePassManager;\n  llvm::StringRef getName() const { return \"FuzzingSolver\"; }\n\npublic:\n  FuzzingSolverImpl(FuzzingSolver* interF)\n      : cancelled(false), interF(interF), cancellablePassManager(nullptr) {}\n  void cancel() {\n    cancelled = true;\n    std::lock_guard<std::mutex> lock(cancellablePassManagerMutex);\n    if (cancellablePassManager) {\n      cancellablePassManager->cancel();\n    }\n  }\n\n  std::unique_ptr<SolverResponse> solve(const jfs::core::Query& q,\n                                        bool produceModel) {\n    assert(q.getContext() == interF->ctx);\n#define CHECK_CANCELLED()                                                      \\\n  if (cancelled) {                                                             \\\n    JFSContext& ctx = q.getContext();                                          \\\n    IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\"); \\\n    return std::unique_ptr<SolverResponse>(                                    \\\n        new TrivialFuzzingSolverResponse(SolverResponse::UNKNOWN));            \\\n  }\n    // Use dyn_cast because the options provided aren't neccessarily\n    // an instance of `FuzzingSolverOptions`.\n    const FuzzingSolverOptions* fuzzingOptions =\n        llvm::dyn_cast<FuzzingSolverOptions>(interF->options.get());\n\n    // Check for trivial SAT\n    if (q.constraints.size() == 0) {\n      // Empty constraint set is trivially satisifiable\n\n      auto resp = std::unique_ptr<TrivialFuzzingSolverResponse>(\n          new TrivialFuzzingSolverResponse(SolverResponse::SAT));\n      if (produceModel) {\n        // Make empty model\n        auto model =\n            std::unique_ptr<SimpleModel>(new SimpleModel(q.getContext()));\n        resp->setModel(std::move(model));\n      }\n      if (fuzzingOptions && fuzzingOptions->debugSaveModel) {\n        JFSContext& ctx = q.getContext();\n        IF_VERB(ctx, ctx.getDebugStream()\n            << \"(model save request ignored, not serializable\");\n      }\n      return resp;\n    }\n\n    CHECK_CANCELLED()\n\n    // Check for trivial UNSAT\n    bool isUnsat = false;\n    for (auto ci = q.constraints.cbegin(), ce = q.constraints.cend(); ci != ce;\n         ++ci) {\n      Z3ASTHandle e = *ci;\n      if (e.isFalse()) {\n        isUnsat = true;\n        break;\n      }\n    }\n    if (isUnsat) {\n      return std::unique_ptr<SolverResponse>(\n          new TrivialFuzzingSolverResponse(SolverResponse::UNSAT));\n    }\n\n    CHECK_CANCELLED()\n\n    // FIXME: Not sure we need to modify the query yet. If not we should\n    // change the pass hierarchy so we can have analysis only passes that\n    // work on `const Query`.\n    // Make a copy of the query to work on. This is so that the client's\n    // copy of the query doesn't unexpectedly change.\n    Query qCopy(q);\n\n    // Can't trivially prove sat/unsat, so we have to fuzz.\n    // Collect the information we need to fuzz and start fuzz\n    FuzzingSolverOptions* fsOpts =\n        llvm::dyn_cast<FuzzingSolverOptions>(interF->options.get());\n    auto fai = std::make_shared<FuzzingAnalysisInfo>(\n        (fsOpts != nullptr) ? fsOpts->getFreeVariableToBufferAssignmentOptions()\n                            : nullptr);\n    QueryPassManager preprocessingPassses;\n    {\n      // Make the pass manager cancellable\n      std::lock_guard<std::mutex> lock(cancellablePassManagerMutex);\n      cancellablePassManager = &preprocessingPassses;\n    }\n\n    fai->addTo(preprocessingPassses);\n    if (!cancelled) {\n      preprocessingPassses.run(qCopy);\n    }\n\n    {\n      // Make the pass manager uncancellable\n      std::lock_guard<std::mutex> lock(cancellablePassManagerMutex);\n      cancellablePassManager = nullptr;\n    }\n\n    // Check for trivial SAT. This can happen if the query only consists\n    // of equalities.\n    if (qCopy.constraints.size() == 0) {\n      // Empty constraint set is trivially satisifiable\n      auto resp = std::unique_ptr<TrivialFuzzingSolverResponse>(\n          new TrivialFuzzingSolverResponse(SolverResponse::SAT));\n      if (produceModel) {\n        // Make empty model\n        auto model = std::unique_ptr<Model>(new SimpleModel(q.getContext()));\n        // Now convert model so that it satisfies the query given to the\n        // preprocessing passes.\n        bool convertModelSuccess =\n            preprocessingPassses.convertModel(model.get());\n        if (!convertModelSuccess) {\n          // FIXME: Should we try to recover instead?\n          q.getContext().raiseFatalError(\"Failed to convert model\");\n        }\n        resp->setModel(std::move(model));\n      }\n      if (fuzzingOptions && fuzzingOptions->debugSaveModel) {\n        JFSContext& ctx = q.getContext();\n        IF_VERB(ctx, ctx.getDebugStream()\n            << \"(model save request ignored, not serializable\");\n\n      }\n      return resp;\n    }\n\n    // Check if equalities simplified to false\n    if (qCopy.constraints.size() == 1 && qCopy.constraints[0].isFalse()) {\n      return std::unique_ptr<SolverResponse>(\n          new TrivialFuzzingSolverResponse(SolverResponse::UNSAT));\n    }\n\n    CHECK_CANCELLED()\n    // Have to performing fuzzing\n    auto resp = interF->fuzz(qCopy, produceModel, fai);\n    if (resp->sat == SolverResponse::SAT) {\n      if (produceModel) {\n        // Now convert model so that it satisfies the query given to the\n        // preprocessing passes.\n        bool convertModelSuccess =\n            preprocessingPassses.convertModel(resp->getModel());\n        if (!convertModelSuccess) {\n          // FIXME: Should we try to recover instead?\n          q.getContext().raiseFatalError(\"Failed to convert model\");\n        }\n      }\n    }\n    return resp;\n  }\n#undef CHECK_CANCELLED\n};\n\nFuzzingSolver::FuzzingSolver(std::unique_ptr<SolverOptions> options,\n                             std::unique_ptr<WorkingDirectoryManager> wdm,\n                             JFSContext& ctx)\n    : Solver(std::move(options), ctx), impl(new FuzzingSolverImpl(this)),\n      wdm(std::move(wdm)) {}\nFuzzingSolver::~FuzzingSolver() {}\nstd::unique_ptr<jfs::core::SolverResponse>\nFuzzingSolver::solve(const jfs::core::Query& q, bool produceModel) {\n  return impl->solve(q, produceModel);\n}\nvoid FuzzingSolver::cancel() { impl->cancel(); }\n}\n}\n"
  },
  {
    "path": "lib/FuzzingCommon/FuzzingSolverOptions.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/FuzzingSolverOptions.h\"\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nFuzzingSolverOptions::FuzzingSolverOptions(\n    std::unique_ptr<FreeVariableToBufferAssignmentPassOptions> fvtbapOptions,\n    bool debugSaveModel,\n    SolverOptions::SolverOptionKind thisKind)\n    : SolverOptions(thisKind), fvtbapOptions(std::move(fvtbapOptions)),\n      debugSaveModel(debugSaveModel) {}\nFuzzingSolverOptions::FuzzingSolverOptions(\n    std::unique_ptr<FreeVariableToBufferAssignmentPassOptions> fvtbapOptions,\n    bool debugSaveModel)\n    : FuzzingSolverOptions(std::move(fvtbapOptions),\n                           debugSaveModel,\n                           SolverOptions::FUZZING_SOLVER_KIND) {}\n\nFreeVariableToBufferAssignmentPassOptions*\nFuzzingSolverOptions::getFreeVariableToBufferAssignmentOptions() const {\n  return fvtbapOptions.get();\n}\n\n} // namespace fuzzingCommon\n} // namespace jfs\n"
  },
  {
    "path": "lib/FuzzingCommon/JFSRuntimeFuzzingStat.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/JFSRuntimeFuzzingStat.h\"\n#include \"jfs/Support/ErrorMessages.h\"\n#include \"llvm/Support/MemoryBuffer.h\"\n#include \"llvm/Support/YAMLTraits.h\"\n\nnamespace llvm {\nnamespace yaml {\n\ntemplate <> struct MappingTraits<jfs::fuzzingCommon::JFSRuntimeFuzzingStat> {\n  static void mapping(IO& io,\n                      jfs::fuzzingCommon::JFSRuntimeFuzzingStat& stats) {\n    io.mapOptional(jfs::fuzzingCommon::JFSRuntimeFuzzingStat::\n                       maxNumConstraintsSatisfiedKeyName,\n                   stats.maxNumConstraintsSatisfied);\n\n    io.mapOptional(\n        jfs::fuzzingCommon::JFSRuntimeFuzzingStat::numberOfInputsTriedKeyName,\n        stats.numberOfInputsTried);\n\n    io.mapOptional(jfs::fuzzingCommon::JFSRuntimeFuzzingStat::\n                       numberOfWrongSizedInputsTriedKeyName,\n                   stats.numberOfWrongSizedInputsTried);\n  }\n};\n} // namespace yaml\n} // namespace llvm\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nconst char* JFSRuntimeFuzzingStat::maxNumConstraintsSatisfiedKeyName =\n    \"jfs_max_num_const_sat\";\n\nconst char* JFSRuntimeFuzzingStat::numberOfInputsTriedKeyName =\n    \"jfs_num_inputs\";\n\nconst char* JFSRuntimeFuzzingStat::numberOfWrongSizedInputsTriedKeyName =\n    \"jfs_num_wrong_size_inputs\";\n\n// FIXME: We need sentinel values for these stats so we know if they\n// weren't set vs their value actually is 0.\nJFSRuntimeFuzzingStat::JFSRuntimeFuzzingStat(llvm::StringRef name)\n    : JFSStat(RUNTIME, name), maxNumConstraintsSatisfied(0),\n      numberOfInputsTried(0), numberOfWrongSizedInputsTried(0) {}\n\nJFSRuntimeFuzzingStat::~JFSRuntimeFuzzingStat() {}\n\nvoid JFSRuntimeFuzzingStat::printYAML(llvm::ScopedPrinter& sp) const {\n  sp.indent();\n  auto& os = sp.getOStream();\n  // NOTE: Can't use `llvm::yaml::Output` here due to\n  //\n  // * Document delimiters it adds.\n  // * A mismtach between what we parse and load (the `name` field).\n  // * Indentation not being respected\n  os << \"\\n\";\n  sp.startLine() << \"name: \" << getName() << \"\\n\";\n  sp.startLine() << maxNumConstraintsSatisfiedKeyName << \": \"\n                 << maxNumConstraintsSatisfied << \"\\n\";\n  sp.startLine() << numberOfInputsTriedKeyName << \": \" << numberOfInputsTried\n                 << \"\\n\";\n  sp.startLine() << numberOfWrongSizedInputsTriedKeyName << \": \"\n                 << numberOfWrongSizedInputsTried << \"\\n\";\n  sp.unindent();\n}\n\nstd::unique_ptr<JFSRuntimeFuzzingStat>\nJFSRuntimeFuzzingStat::LoadFromYAML(llvm::StringRef filePath,\n                                    llvm::StringRef name,\n                                    jfs::core::JFSContext& ctx) {\n  auto bufferOrError = llvm::MemoryBuffer::getFile(filePath);\n  if (auto error = bufferOrError.getError()) {\n    ctx.getErrorStream() << jfs::support::getMessageForFailedOpenFileOrSTDIN(\n        filePath, error);\n    return nullptr;\n  }\n  auto buffer(std::move(bufferOrError.get()));\n  auto mbr = buffer->getMemBufferRef();\n  llvm::yaml::Input yin(mbr);\n  std::unique_ptr<JFSRuntimeFuzzingStat> stats(new JFSRuntimeFuzzingStat(name));\n  yin >> *stats;\n  if (auto error = yin.error()) {\n    ctx.getErrorStream() << \"(error parsing failure \\\"\" << error.message()\n                         << \"\\\")\\n\";\n    return nullptr;\n  }\n  return stats;\n}\n\n} // namespace fuzzingCommon\n} // namespace jfs\n"
  },
  {
    "path": "lib/FuzzingCommon/LibFuzzerInvocationManager.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/LibFuzzerInvocationManager.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/JFSTimerMacros.h\"\n#include \"jfs/Support/CancellableProcess.h\"\n#include \"llvm/ADT/SmallVector.h\"\n#include \"llvm/ADT/StringExtras.h\"\n#include \"llvm/ADT/Twine.h\"\n#include \"llvm/Support/FileSystem.h\"\n#include \"llvm/Support/Path.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <atomic>\n#include <vector>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nusing namespace jfs::core;\nusing namespace jfs::support;\n\nclass LibFuzzerInvocationManagerImpl {\nprivate:\n  JFSContext& ctx;\n  static const int targetFoundExitCode = 77;\n  static const int unitTimeoutExitCode = 88;\n  static const int singleRunTargetNotFoundExitCode = 0;\n  static const int runBoundReachedExitCode = 0;\n  std::atomic<bool> cancelled;\n  CancellableProcess proc;\n\npublic:\n  LibFuzzerInvocationManagerImpl(JFSContext& ctx)\n      : ctx(ctx), cancelled(false) {}\n  ~LibFuzzerInvocationManagerImpl() {}\n  void cancel() {\n    IF_VERB(ctx,\n            ctx.getDebugStream()\n                << \"(LibFuzzerInvocationManager cancel called)\\n\");\n    cancelled = true;\n    proc.cancel();\n  }\n  std::unique_ptr<LibFuzzerResponse> fuzz(const LibFuzzerOptions* options,\n                                          llvm::StringRef stdOutFile,\n                                          llvm::StringRef stdErrFile) {\n    // TODO: Assert paths exist\n    std::vector<const char*> cmdLineArgs;\n\n    // If previous steps failed to perform complete constant folding\n    // then we might end up with an empty buffer. In that case we only\n    // we only need to run the program once to determine sat/unsat.\n    bool emptyBuffer = options->maxLength == 0;\n\n    std::string underlyingString;\n    llvm::raw_string_ostream ss(underlyingString);\n\n#define SET_ARG(NAME, X)                                                       \\\n  ss << X;                                                                     \\\n  std::string NAME(ss.str());                                                  \\\n  cmdLineArgs.push_back(NAME.data());                                          \\\n  underlyingString.clear();\n\n    // First arg must be fuzzing binary\n    assert(llvm::sys::fs::exists(options->targetBinary));\n    cmdLineArgs.push_back(options->targetBinary.data());\n\n    std::string numRunsAsStr;\n    if (emptyBuffer) {\n      // If the buffer is empty we always try one run and ignore\n      // `options->runs`.\n      // TODO: Should we emit a warning if we do this?\n      numRunsAsStr = \"1\";\n    } else {\n      if (options->runs == 0) {\n        // Unbounded number of runs\n        numRunsAsStr = \"-1\";\n      } else {\n        // Use whatever the client actually asked for\n        numRunsAsStr = llvm::utostr(options->runs, /*isNeg=*/false);\n      }\n    }\n\n    // Number of fuzzing runs\n    SET_ARG(numberOfRunsArgs, \"-runs=\" << numRunsAsStr);\n\n    // Seed\n    // NOTE: `seed` value of 0 is special in that is causes LibFuzzer to pick a\n    // random seed. To ensure determistic behavior, we adjust the seed here if\n    // it is 0.\n    uint32_t seed = ctx.getConfig().seed;\n    if (!seed) {\n      seed = 1;\n    }\n    SET_ARG(seedArg, \"-seed=\" << seed);\n\n    // Mutation depth\n    SET_ARG(mutationDepthArg, \"-mutate_depth=\" << options->mutationDepth);\n\n    // Crossover\n    SET_ARG(crossOverArg, \"-cross_over=\" << (options->crossOver ? \"1\" : \"0\"));\n\n    // Max length\n    SET_ARG(maxLengthArg, \"-max_len=\" << options->maxLength);\n\n    // Use trace comparison\n    SET_ARG(useCmpArg, \"-use_cmp=\" << (options->useCmp ? \"1\" : \"0\"));\n\n    // Log stats\n    SET_ARG(printFinalStats,\n            \"-print_final_stats=\" << (options->printFinalStats ? \"1\" : \"0\"));\n\n    // Reduce inputs\n    SET_ARG(reduceInputs,\n            \"-reduce_inputs=\" << (options->reduceInputs ? \"1\" : \"0\"));\n\n    // Control whether LibFuzzer's default mutators resize input.\n    // Generally resizing the inputs is not desirable.\n    //\n    // Disabling mutations that resize the input is highly experimental.\n    SET_ARG(defaultMutationsResizeInput,\n            \"-default_mutators_resize_input=\"\n                << (options->defaultMutationsResizeInput ? \"1\" : \"0\"));\n\n    // handle SIGABRT\n    SET_ARG(handleSIGABRTArg,\n            \"-handle_abrt=\" << (options->handleSIGABRT ? \"1\" : \"0\"));\n\n    // handle SIGBUS\n    SET_ARG(handleSIGBUSArg,\n            \"-handle_bus=\" << (options->handleSIGBUS ? \"1\" : \"0\"));\n\n    // handle SIGFPE\n    SET_ARG(handleSIGFPEArg,\n            \"-handle_fpe=\" << (options->handleSIGFPE ? \"1\" : \"0\"));\n\n    // handle SIGILL\n    SET_ARG(handleSIGILLArg,\n            \"-handle_ill=\" << (options->handleSIGILL ? \"1\" : \"0\"));\n\n    // handle SIGINT\n    SET_ARG(handleSIGIntArg,\n            \"-handle_int=\" << (options->handleSIGINT ? \"1\" : \"0\"));\n\n    // handle SIGSEGV\n    SET_ARG(handleSIGSEGVArg,\n            \"-handle_segv=\" << (options->handleSIGSEGV ? \"1\" : \"0\"));\n\n    // handle SIGTERM\n    SET_ARG(handleSIGTERMArg,\n            \"-handle_term=\" << (options->handleSIGTERM ? \"1\" : \"0\"));\n\n    // handle SIGXFSZ\n    SET_ARG(handleSIGXFSZArg,\n            \"-handle_xfsz=\" << (options->handleSIGXFSZ ? \"1\" : \"0\"));\n\n    // Artifact dir\n    // TODO: Use Twine?\n    std::string artifactPathWithSlash(options->artifactDir);\n    artifactPathWithSlash += \"/\";\n    artifactPathWithSlash =\n        llvm::sys::path::convert_to_slash(artifactPathWithSlash);\n    assert(llvm::sys::fs::is_directory(artifactPathWithSlash));\n    SET_ARG(artifactArg, \"-artifact_prefix=\" << artifactPathWithSlash);\n\n    // Set exit codes. We use this to work out what the outcome was\n    SET_ARG(errorExitCodeArg, \"-error_exitcode=\" << targetFoundExitCode);\n    SET_ARG(unitTimeoutExitCodeArg,\n            \"-timeout_exitcode=\" << unitTimeoutExitCode);\n\n    // Corpus directory\n    assert(llvm::sys::fs::is_directory(options->corpusDir));\n    cmdLineArgs.push_back(options->corpusDir.data());\n\n#undef SET_ARG\n    if (ctx.getVerbosity() > 0) {\n      ctx.getDebugStream() << \"(LibFuzzerInvocationManager\\n[\";\n      for (const auto& arg : cmdLineArgs) {\n        ctx.getDebugStream() << \"\\\"\" << arg << \"\\\", \";\n      }\n      ctx.getDebugStream() << \"]\\n)\\n\";\n    }\n    std::unique_ptr<LibFuzzerResponse> response(new LibFuzzerResponse());\n\n    // cmdLineArgs must be null terminated\n    cmdLineArgs.push_back(nullptr);\n\n    // Redirects\n    std::vector<llvm::StringRef> redirects;\n    if (stdOutFile.size() > 0 || stdErrFile.size() > 0) {\n      redirects.push_back(\"\");         // STDIN goes to /dev/null\n      redirects.push_back(stdOutFile); // STDOUT\n      redirects.push_back(stdErrFile); // STDERR\n    }\n\n    // Set up environment variable to tell the program where to\n    // log runtime statistics if required.\n    const char** envp = nullptr;\n    std::string jfsRuntimeEnv;\n    if (options->jfsRuntimeLogFile.size() > 0) {\n      jfsRuntimeEnv = \"JFS_RUNTIME_LOG_PATH=\";\n      jfsRuntimeEnv += options->jfsRuntimeLogFile;\n    }\n    const char* envpLogging[] = {jfsRuntimeEnv.c_str(), nullptr};\n    if (options->jfsRuntimeLogFile.size() > 0) {\n      envp = envpLogging;\n    }\n\n    // Invoke Fuzzer\n    int exitCode = proc.execute(/*program=*/options->targetBinary,\n                                /*args=*/cmdLineArgs, /*redirects=*/redirects,\n                                /*envp=*/envp);\n\n    if (exitCode == -2) {\n      response->outcome = LibFuzzerResponse::ResponseTy::CANCELLED;\n      return response;\n    }\n    if (emptyBuffer) {\n      if (exitCode == singleRunTargetNotFoundExitCode) {\n        response->outcome =\n            LibFuzzerResponse::ResponseTy::SINGLE_RUN_TARGET_NOT_FOUND;\n        return response;\n      }\n    } else {\n      if (options->runs > 0 && exitCode == runBoundReachedExitCode) {\n        response->outcome = LibFuzzerResponse::ResponseTy::RUN_BOUND_REACHED;\n        return response;\n      }\n    }\n    if (exitCode != targetFoundExitCode) {\n      ctx.getErrorStream() << \"(error Unexpected exit code from LibFuzzer \"\n                           << exitCode << \")\\n\";\n      response->outcome = LibFuzzerResponse::ResponseTy::UNKNOWN;\n      return response;\n    }\n\n    // Populate response with information on the target\n    response->outcome = LibFuzzerResponse::ResponseTy::TARGET_FOUND;\n    // Find the artifact file\n    {\n      // Keep all the filesystem stuff scoped.\n      std::error_code ec;\n      llvm::sys::fs::directory_iterator artifactDirIt(options->artifactDir, ec);\n      for (llvm::sys::fs::directory_iterator endIt; artifactDirIt != endIt;\n           artifactDirIt.increment(ec)) {\n        if (ec) {\n          ctx.getWarningStream()\n              << \"(warning Failed to find artifact:\" << ec.message() << \")\\n\";\n          break;\n        }\n        auto fileStatusOrError = artifactDirIt->status();\n        if (auto ec = fileStatusOrError.getError()) {\n          ctx.getWarningStream()\n              << \"(warning Failed to find artifact:\" << ec.message() << \")\\n\";\n          break;\n        }\n        if (fileStatusOrError->type() !=\n            llvm::sys::fs::file_type::regular_file) {\n          continue;\n        }\n        // Regular file. For now just assume this is the artifact file because\n        // that should be the only regular file in the directory.\n        response->pathToInput = artifactDirIt->path();\n        IF_VERB(ctx, ctx.getDebugStream()\n                         << \"(LibFuzzerInvocationManager found artifact: \"\n                         << response->pathToInput << \")\\n\");\n        break;\n      }\n    }\n    return response;\n  }\n};\n\n// LibFuzzerResponse\n\nLibFuzzerResponse::LibFuzzerResponse() : outcome(ResponseTy::UNKNOWN) {}\nLibFuzzerResponse::~LibFuzzerResponse() {}\n\nstd::unique_ptr<llvm::MemoryBuffer>\nLibFuzzerResponse::getInputForTarget() const {\n  if (pathToInput.size() == 0)\n    return nullptr;\n  auto bufferOrError =\n      llvm::MemoryBuffer::getFile(pathToInput, /*FileSize=*/-1,\n                                  /*RequiresNullTerminator=*/false);\n  if (auto ec = bufferOrError.getError()) {\n    return nullptr;\n  }\n  return std::move(*bufferOrError);\n}\n\n// LibFuzzerInvocationManager\nLibFuzzerInvocationManager::LibFuzzerInvocationManager(JFSContext& ctx)\n    : impl(new LibFuzzerInvocationManagerImpl(ctx)) {}\n\nLibFuzzerInvocationManager::~LibFuzzerInvocationManager() {}\n\nvoid LibFuzzerInvocationManager::cancel() { impl->cancel(); }\n\nstd::unique_ptr<LibFuzzerResponse>\nLibFuzzerInvocationManager::fuzz(const LibFuzzerOptions* options,\n                                 llvm::StringRef stdOutFile,\n                                 llvm::StringRef stdErrFile) {\n  return impl->fuzz(options, stdOutFile, stdErrFile);\n}\n}\n}\n"
  },
  {
    "path": "lib/FuzzingCommon/LibFuzzerOptions.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/LibFuzzerOptions.h\"\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nLibFuzzerOptions::LibFuzzerOptions()\n    : runs(-1L), mutationDepth(5), crossOver(true), maxLength(0), useCmp(false),\n      printFinalStats(true), reduceInputs(false),\n      defaultMutationsResizeInput(true), handleSIGABRT(true),\n      handleSIGBUS(true), handleSIGFPE(true), handleSIGILL(true),\n      handleSIGINT(true), handleSIGSEGV(true), handleSIGXFSZ(true) {}\n} // namespace fuzzingCommon\n} // namespace jfs\n"
  },
  {
    "path": "lib/FuzzingCommon/SMTLIBRuntimes.cpp.in",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n// @AUTO_GEN_MSG@\n#include \"jfs/FuzzingCommon/SMTLIBRuntimes.h\"\n#include \"llvm/Support/ErrorHandling.h\"\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\n\nconst char* getSMTLIBRuntimeAsCString(SMTLIBRuntimeTy runtimeType) {\n  switch(runtimeType) {\n@getSMTLIBRuntimeAsCStringEntries@\n    default:\n      llvm_unreachable(\"Unhandled SMTLIBRuntimeTy\");\n  }\n};\n\nconst char* getSMTLIBRuntimePath(SMTLIBRuntimeTy runtimeType) {\n  switch(runtimeType) {\n@getSMTLIBRuntimePathEntries@\n    default:\n      llvm_unreachable(\"Unhandled SMTLIBRuntimeTy\");\n  }\n}\n\n}\n}\n"
  },
  {
    "path": "lib/FuzzingCommon/SMTLIBRuntimes.h.in",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_FUZZING_COMMON_SMTLIB_RUNTIMES_H\n#define JFS_FUZZING_COMMON_SMTLIB_RUNTIMES_H\n// @AUTO_GEN_MSG@\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nenum class SMTLIBRuntimeTy {\n@SMTLIB_RUNTIME_ENUM_ENTRIES@\n};\n\nconst char* getSMTLIBRuntimeAsCString(SMTLIBRuntimeTy runtimeType);\n\n// Returns path to runtime library relative to the `runtime/`\n// directory.\nconst char* getSMTLIBRuntimePath(SMTLIBRuntimeTy runtimeType);\n\n}\n}\n\n#endif\n"
  },
  {
    "path": "lib/FuzzingCommon/SeedGenerator.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/SeedGenerator.h\"\n#include \"jfs/FuzzingCommon/SeedManager.h\"\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nvoid SeedGenerator::preGenerationCallBack(SeedManager& sm) {}\nvoid SeedGenerator::postGenerationCallBack(SeedManager& sm) {}\n\nSeedGenerator::SeedGenerator(llvm::StringRef name) : name(name) {}\n\nSeedGenerator::~SeedGenerator() {}\n\n// AllBytesEqualGenerator\n\nAllBytesEqualGenerator::AllBytesEqualGenerator(llvm::StringRef name,\n                                               uint8_t byteValue)\n    : SeedGenerator(name), byteValue(byteValue), seedWritten(false) {}\n\nbool AllBytesEqualGenerator::writeSeed(SeedManager& sm) {\n  auto fob = sm.getBufferForSeed(/*prefix=*/getName());\n  if (!fob) {\n    return false;\n  }\n  memset(fob->getBufferStart(), byteValue, fob->getBufferSize());\n  if (auto error = fob->commit()) {\n    // FIXME: This probably isn't the right way to handle the errors\n    // but this is good enough to suppress warnings about not using\n    // the return value of `commit()`.\n    auto errCode = llvm::errorToErrorCode(std::move(error));\n    sm.getContext().getErrorStream()\n        << \"(error Failed to commit seed because \\\"\" << errCode.message()\n        << \"\\\")\\n\";\n    return false;\n  }\n  seedWritten = true;\n  return true;\n}\n\nbool AllBytesEqualGenerator::empty() const { return seedWritten; }\n\n} // namespace fuzzingCommon\n} // namespace jfs\n"
  },
  {
    "path": "lib/FuzzingCommon/SeedManager.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/SeedManager.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/JFSTimerMacros.h\"\n#include \"jfs/FuzzingCommon/FuzzingAnalysisInfo.h\"\n#include \"jfs/FuzzingCommon/SeedGenerator.h\"\n#include \"jfs/FuzzingCommon/SeedManagerOptions.h\"\n#include \"jfs/FuzzingCommon/SeedManagerStat.h\"\n#include \"llvm/Support/Path.h\"\n#include <list>\n#include <unordered_map>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nusing namespace jfs::core;\n\nclass SeedManagerImpl {\npublic:\n  using GeneratorContainerTy = std::list<std::unique_ptr<SeedGenerator>>;\n  bool cancelled = false;\n  SeedManager* wrapper;\n  GeneratorContainerTy activeGenerators;\n  GeneratorContainerTy emptyGenerators;\n  std::string seedDir;\n  JFSContext& ctx;\n  // Right now we don't actually store the seedIDs. We could do\n  // in the future if for some reason we need to iterate over them\n  // but the current algorithm means we can actually infer the used\n  // seed IDs from `prefixToCounterMap`.\n  std::unordered_map<std::string, uint64_t> prefixToCounterMap;\n  uint64_t numRequestedIDs = 0;\n  uint64_t maxSeedSpaceInBytes = 0;\n  uint64_t maxNumSeeds = 0;\n  uint64_t seedSize = 0;\n  const FuzzingAnalysisInfo* fai;\n  const Query* query;\n  llvm::SmallVector<char, 256> mutablePath;\n  SeedManagerImpl(SeedManager* wrapper, llvm::StringRef seedDir,\n                  jfs::core::JFSContext& ctx)\n      : wrapper(wrapper), seedDir(seedDir), ctx(ctx), fai(nullptr),\n        query(nullptr) {\n    assert(llvm::sys::path::is_absolute(llvm::Twine(seedDir)));\n    mutablePath.insert(mutablePath.begin(), seedDir.begin(), seedDir.end());\n  }\n\n  ~SeedManagerImpl() {}\n\n  void cancel() { cancelled = true; }\n\n  void configureFrom(std::unique_ptr<SeedManagerOptions> options) {\n    setSpaceLimit(options->maxSeedSpaceInBytes);\n    setMaxNumSeeds(options->maxNumSeeds);\n    if (activeGenerators.size() == 0) {\n      activeGenerators = std::move(options->generators);\n    } else {\n      for (auto& genPtr : options->generators) {\n        activeGenerators.push_back(std::move(genPtr));\n      }\n    }\n  }\n\n  void addSeedGenerator(std::unique_ptr<SeedGenerator> sg) {\n    assert(sg && \"SeedGenerator cannot be null\");\n    activeGenerators.push_back(std::move(sg));\n  }\n\n  uint64_t writeSeeds(const FuzzingAnalysisInfo* info,\n                      const jfs::core::Query* q) {\n    uint64_t numSeedsWritten = 0;\n    auto bufferAssignment = info->freeVariableAssignment->bufferAssignment;\n    this->seedSize = bufferAssignment->getRequiredStoreBytes();\n    this->fai = info;\n    this->query = q;\n    if (seedSize == 0) {\n      // The buffer is empty so we don't generate any seeds.\n      return numSeedsWritten;\n    }\n    uint64_t boundBasedOnSpace = getSpaceLimit() / seedSize;\n    uint64_t effectiveBound =\n        std::min(((getSpaceLimit() > 0) ? boundBasedOnSpace : UINT64_MAX),\n                 ((getMaxNumSeeds() > 0) ? getMaxNumSeeds() : UINT64_MAX));\n\n    IF_VERB(ctx, ctx.getDebugStream() << \"(SeedManager effectiveBound:\"\n                                      << effectiveBound << \")\\n\");\n\n#define CHECK_CANCELLED()                                                      \\\n  if (cancelled) {                                                             \\\n    IF_VERB(ctx, ctx.getDebugStream() << \"(SeedManager cancelled)\\n\");         \\\n    return numSeedsWritten;                                                    \\\n  }\n    {\n      JFS_SM_TIMER(add_fuzzer_seeds, ctx);\n      // Do call back on all generators\n      for (auto& g : activeGenerators) {\n        CHECK_CANCELLED();\n        g->preGenerationCallBack(*wrapper);\n      }\n\n      // Go through the seed generators round robin until we hit a bound or\n      // we've exhausted the seed generators\n      GeneratorContainerTy::iterator gen = activeGenerators.begin();\n      while (numSeedsWritten < effectiveBound) {\n        CHECK_CANCELLED();\n        if (activeGenerators.size() == 0) {\n          IF_VERB(ctx, ctx.getDebugStream()\n                           << \"(SeedManager active generators exhausted)\\n\");\n          break;\n        }\n        if (gen == activeGenerators.end()) {\n          // Hit the end of list of generators. Start again from the beginning.\n          gen = activeGenerators.begin();\n          continue;\n        }\n        if ((*gen)->empty()) {\n          // This seed generator is empty. Remove it from list of active\n          // generators.\n          emptyGenerators.push_back(std::move(*gen));\n          gen = activeGenerators.erase(gen);\n          continue;\n        }\n        // Generate seed\n        assert(!((*gen)->empty()) && \"SeedGenerator cannot be empty\");\n        bool success = (*gen)->writeSeed(*wrapper);\n        if (!success) {\n          ctx.raiseFatalError(\"Failed to write seed\");\n        } else {\n          ++numSeedsWritten;\n        }\n      }\n      // Do post seed generation call backs\n      for (auto& g : activeGenerators) {\n        CHECK_CANCELLED();\n        g->postGenerationCallBack(*wrapper);\n      }\n      for (auto& g : emptyGenerators) {\n        CHECK_CANCELLED();\n        g->postGenerationCallBack(*wrapper);\n      }\n    }\n\n    IF_VERB(ctx, ctx.getDebugStream()\n                     << \"(SeedManager wrote \" << numSeedsWritten << \" seeds (\"\n                     << seedSize << \" bytes each))\\n\");\n    // Add Stats\n    if (ctx.getStats() != nullptr) {\n      std::unique_ptr<SeedManagerStat> smStats(\n          new SeedManagerStat(\"SeedManager\"));\n      smStats->numSeedsGenerated = numSeedsWritten;\n      ctx.getStats()->append(std::move(smStats));\n    }\n    return numSeedsWritten;\n  }\n\n  void setSpaceLimit(uint64_t maxSeedSpaceInBytes) {\n    this->maxSeedSpaceInBytes = maxSeedSpaceInBytes;\n  }\n  uint64_t getSpaceLimit() const { return maxSeedSpaceInBytes; }\n  void setMaxNumSeeds(uint64_t maxNumSeeds) { this->maxNumSeeds = maxNumSeeds; }\n  uint64_t getMaxNumSeeds() const { return maxNumSeeds; }\n\n  std::unique_ptr<llvm::FileOutputBuffer>\n  getBufferForSeed(llvm::StringRef prefix) {\n    assert(seedSize > 0);\n    std::string seedID = getAndReserveSeedID(prefix);\n    llvm::sys::path::append(mutablePath, seedID);\n    // Apparently it's okay for a null terminator to not be included in the size\n    llvm::StringRef fullPathToSeed(mutablePath.data(), mutablePath.size());\n    IF_VERB(ctx, ctx.getDebugStream() << \"(SeedManager creating seed \\\"\"\n                                      << fullPathToSeed << \"\\\")\\n\");\n    auto expectFob = llvm::FileOutputBuffer::create(fullPathToSeed, seedSize);\n    std::unique_ptr<llvm::FileOutputBuffer> fob = nullptr;\n    if (expectFob) {\n      fob = std::move(*expectFob);\n    } else {\n      // Failed\n      ctx.getErrorStream()\n          << \"(error Failed to created FileOutputBuffer for seed)\\n\";\n    }\n\n    // Reset for next call\n    llvm::sys::path::remove_filename(mutablePath);\n    return fob;\n  }\n\n  std::string getAndReserveSeedID(llvm::StringRef prefix) {\n    ++numRequestedIDs;\n    std::string key(prefix);\n    std::string underlyingString;\n    llvm::raw_string_ostream ss(underlyingString);\n    ss << prefix << \"_\";\n    uint64_t suffixInt = 0;\n    auto it = prefixToCounterMap.find(key);\n    if (it == prefixToCounterMap.end()) {\n      prefixToCounterMap[key] = 0;\n    } else {\n      suffixInt = ++(it->second);\n    }\n    ss << suffixInt;\n    return ss.str();\n    ;\n  }\n\n  jfs::core::JFSContext& getContext() const { return ctx; }\n\n  const FuzzingAnalysisInfo* getCurrentFuzzingAnalysisInfo() const {\n    return fai;\n  }\n\n  const jfs::core::Query* getCurrentQuery() const { return query; }\n};\n\nSeedManager::SeedManager(llvm::StringRef seedDir, JFSContext& ctx)\n    : impl(new SeedManagerImpl(this, seedDir, ctx)) {}\n\nSeedManager::~SeedManager() {}\n\nvoid SeedManager::configureFrom(std::unique_ptr<SeedManagerOptions> options) {\n  impl->configureFrom(std::move(options));\n}\n\nvoid SeedManager::addSeedGenerator(std::unique_ptr<SeedGenerator> sg) {\n  impl->addSeedGenerator(std::move(sg));\n}\n// Returns number of written seeds.\nuint64_t SeedManager::writeSeeds(const FuzzingAnalysisInfo* info,\n                                 const jfs::core::Query* q) {\n  return impl->writeSeeds(info, q);\n}\n\nvoid SeedManager::setSpaceLimit(uint64_t maxTotalInBytes) {\n  impl->setSpaceLimit(maxTotalInBytes);\n}\n\nuint64_t SeedManager::getSpaceLimit() const { return impl->getSpaceLimit(); }\n\nvoid SeedManager::setMaxNumSeeds(uint64_t maxNumSeeds) {\n  impl->setMaxNumSeeds(maxNumSeeds);\n}\nuint64_t SeedManager::getMaxNumSeeds() const { return impl->getMaxNumSeeds(); }\n\nstd::unique_ptr<llvm::FileOutputBuffer>\nSeedManager::getBufferForSeed(llvm::StringRef prefix) {\n  return impl->getBufferForSeed(prefix);\n}\n\nstd::string SeedManager::getAndReserveSeedID(llvm::StringRef prefix) {\n  return impl->getAndReserveSeedID(prefix);\n}\n\nstd::string SeedManager::getAndReserveSeedID() {\n  return impl->getAndReserveSeedID(\"\");\n}\n\njfs::core::JFSContext& SeedManager::getContext() const {\n  return impl->getContext();\n}\n\nconst FuzzingAnalysisInfo* SeedManager::getCurrentFuzzingAnalysisInfo() const {\n  return impl->getCurrentFuzzingAnalysisInfo();\n}\nconst jfs::core::Query* SeedManager::getCurrentQuery() const {\n  return impl->getCurrentQuery();\n}\n\nvoid SeedManager::cancel() { impl->cancel(); }\n\n} // namespace fuzzingCommon\n} // namespace jfs\n"
  },
  {
    "path": "lib/FuzzingCommon/SeedManagerStat.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/SeedManagerStat.h\"\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nSeedManagerStat::SeedManagerStat(llvm::StringRef name)\n    : JFSStat(SEED_MANAGER, name) {}\nSeedManagerStat::~SeedManagerStat() {}\n\nvoid SeedManagerStat::printYAML(llvm::ScopedPrinter& sp) const {\n  sp.indent();\n  auto& os = sp.getOStream();\n  os << \"\\n\";\n  sp.startLine() << \"name: \" << getName() << \"\\n\";\n  sp.startLine() << \"num_seeds_generated: \" << numSeedsGenerated << \"\\n\";\n  sp.unindent();\n}\n} // namespace fuzzingCommon\n} // namespace jfs\n"
  },
  {
    "path": "lib/FuzzingCommon/SortConformanceCheckPass.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/SortConformanceCheckPass.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include <list>\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nSortConformanceCheckPass::SortConformanceCheckPass(\n    std::function<bool(jfs::core::Z3SortHandle)> predicate)\n    : predicateHeld(false), predicate(predicate) {}\n\nbool SortConformanceCheckPass::run(Query &q) {\n  JFSContext& ctx = q.getContext();\n  std::list<Z3ASTHandle> workList;\n  for (auto bi = q.constraints.begin(), be = q.constraints.end(); bi != be;\n       ++bi) {\n    workList.push_front(*bi);\n  }\n  // Do DFS to collect variables\n  jfs::core::Z3FuncDeclSet variables; // Use a set to avoid duplicates\n  Z3ASTSet visited;\n  predicateHeld = true;\n  while (workList.size() != 0) {\n    Z3ASTHandle node = workList.front();\n    workList.pop_front();\n\n    if (cancelled) {\n      IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\");\n      return false;\n    }\n\n    if (visited.count(node) > 0) {\n      // Already visited. Skip\n      continue;\n    }\n\n    // Check sort\n    bool predicateAnswer = predicate(node.getSort());\n    if (!predicateAnswer) {\n      predicateHeld = false;\n      break;\n    }\n    visited.insert(node);\n\n    // Add children to the worklist\n    if (!node.isApp())\n      continue;\n    Z3AppHandle app = node.asApp();\n    for (unsigned index = 0; index < app.getNumKids(); ++index) {\n      workList.push_front(app.getKid(index));\n    }\n  }\n\n  return false;\n}\n\nllvm::StringRef SortConformanceCheckPass::getName() {\n  return \"SortConformanceCheckPass\";\n}\n\nbool SortConformanceCheckPass::convertModel(jfs::core::Model* m) {\n  // This pass preserves equivalence so the model does not need to be\n  // converted.\n  return true;\n}\n}\n}\n"
  },
  {
    "path": "lib/FuzzingCommon/SpecialConstantSeedGenerator.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#include \"jfs/FuzzingCommon/SpecialConstantSeedGenerator.h\"\n#include \"jfs/Core/RNG.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include \"jfs/FuzzingCommon/BufferElement.h\"\n#include \"jfs/FuzzingCommon/FileSerializableModel.h\"\n#include \"jfs/FuzzingCommon/FuzzingAnalysisInfo.h\"\n#include \"jfs/FuzzingCommon/SeedManager.h\"\n#include \"jfs/Support/StatisticsManager.h\"\n#include <climits>\n\nusing namespace jfs::core;\nusing namespace jfs::fuzzingCommon;\n\nnamespace {\n\nenum class SpecialConstantBitVector : size_t {\n  ZERO,\n  ONE,\n  MAX_UNSIGNED_INT,\n  MAX_SIGNED_INT,\n  SIZE, // Marks the size of the enum (must be the last entry)\n};\n\nenum class SpecialConstantFloatingPoint : size_t {\n  POSITIVE_ZERO,\n  NEGATIVE_ZERO,\n  POSITIVE_INFINITY,\n  NEGATIVE_INFINITY,\n  NOT_A_NUMBER,\n  POSITIVE_ONE,\n  NEGATIVE_ONE,\n  SMALLEST_POSITIVE_SUBNORMAL,\n  LARGEST_POSITIVE_SUBNORMAL,\n  SMALLEST_POSITIVE_NORMAL,\n  LARGEST_POSITIVE_NORMAL,\n  SMALLEST_NEGATIVE_SUBNORMAL,\n  LARGEST_NEGATIVE_SUBNORMAL,\n  SMALLEST_NEGATIVE_NORMAL,\n  LARGEST_NEGATIVE_NORMAL,\n  SIZE, // Marks the size of the enum (must be the last entry)\n};\n\nuint64_t getMask(const unsigned bitWidth) {\n  assert(bitWidth <= 64);\n  return (bitWidth >= 64) ? UINT64_MAX : ((UINT64_C(1) << bitWidth) - 1);\n}\n}\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\n#define INCREMENT_ON_COVER(variable)                                           \\\n  do {                                                                         \\\n    static bool has_been_covered = false;                                      \\\n    if (!has_been_covered) {                                                   \\\n      has_been_covered = true;                                                 \\\n      ++(variable);                                                            \\\n    }                                                                          \\\n  } while (false)\n\nbool SpecialConstantSeedGenerator::chooseBool(JFSContext& ctx,\n                                              const BufferElement& be,\n                                              Model& model) {\n  assert(be.getSort().isBoolTy());\n  bool value = ctx.getRNG().generate(2);\n  Z3ASTHandle valueAsAST;\n  if (value) {\n    INCREMENT_ON_COVER(stats->numCoveredBoolConstants);\n    valueAsAST = Z3ASTHandle::getTrue(ctx.getZ3Ctx());\n  } else {\n    INCREMENT_ON_COVER(stats->numCoveredBoolConstants);\n    valueAsAST = Z3ASTHandle::getFalse(ctx.getZ3Ctx());\n  }\n  return model.addAssignmentFor(be.getDecl(), valueAsAST);\n}\n\nbool SpecialConstantSeedGenerator::chooseBitVector(JFSContext& ctx,\n                                                   const BufferElement& be,\n                                                   Model& model) {\n  auto sort = be.getSort();\n  unsigned width = sort.getBitVectorWidth();\n  assert(sort.isBitVectorTy());\n  assert(width > 0);\n  assert(width <= 64);\n\n  // Select from special constants for the sort and also any values for the sort\n  // found in the constraints.\n  const auto& valuesFromConstraints = sortToConstraintConstantMap[be.getSort()];\n  const size_t specialConstantsSize =\n      static_cast<size_t>(SpecialConstantBitVector::SIZE);\n  size_t limit = specialConstantsSize + valuesFromConstraints.size();\n  auto value =\n      static_cast<SpecialConstantBitVector>(ctx.getRNG().generate(limit));\n\n  // If we selected a value inside the range of the enum, create the selected\n  // special constant. Otherwise, we selected a constant from the constraints.\n  Z3ASTHandle valueAsAST;\n  switch (value) {\n  case SpecialConstantBitVector::ZERO: {\n    INCREMENT_ON_COVER(stats->numCoveredBVConstants);\n    valueAsAST = Z3ASTHandle::getBV(sort, 0);\n    break;\n  }\n  case SpecialConstantBitVector::ONE: {\n    INCREMENT_ON_COVER(stats->numCoveredBVConstants);\n    valueAsAST = Z3ASTHandle::getBV(sort, 1);\n    break;\n  }\n  case SpecialConstantBitVector::MAX_UNSIGNED_INT: {\n    INCREMENT_ON_COVER(stats->numCoveredBVConstants);\n    // Max unsigned int is of the form 0b11..11.\n    // This is equal to a mask for the full width of the bit vector.\n    valueAsAST = Z3ASTHandle::getBV(sort, getMask(width));\n    break;\n  }\n  case SpecialConstantBitVector::MAX_SIGNED_INT: {\n    INCREMENT_ON_COVER(stats->numCoveredBVConstants);\n    // Max unsigned int is of the form 0b01..11.\n    // This is equal to a mask for one less than the width of the bit vector.\n    valueAsAST = Z3ASTHandle::getBV(sort, getMask(width - 1));\n    break;\n  }\n  default:\n    auto index = static_cast<size_t>(value) - specialConstantsSize;\n    valueAsAST = valuesFromConstraints[index];\n    break;\n  }\n\n  return model.addAssignmentFor(be.getDecl(), valueAsAST);\n}\n\nbool SpecialConstantSeedGenerator::chooseFloatingPoint(JFSContext& ctx,\n                                                       const BufferElement& be,\n                                                       Model& model) {\n  auto sort = be.getSort();\n  assert(sort.isFloatingPointTy());\n  unsigned ebits = sort.getFloatingPointExponentBitWidth();\n  unsigned sbits = sort.getFloatingPointSignificandBitWidth();\n  assert((ebits == 8 && sbits == 24) || (ebits == 11 && sbits == 53));\n\n  // Select from special constants for the sort and also any values for the sort\n  // found in the constraints.\n  const auto& valuesFromConstraints = sortToConstraintConstantMap[be.getSort()];\n  const size_t specialConstantsSize =\n      static_cast<size_t>(SpecialConstantFloatingPoint::SIZE);\n  size_t limit = specialConstantsSize + valuesFromConstraints.size();\n  auto value =\n      static_cast<SpecialConstantFloatingPoint>(ctx.getRNG().generate(limit));\n\n  // If we selected a value inside the range of the enum, create the selected\n  // special constant. Otherwise, we selected a constant from the constraints.\n  Z3ASTHandle valueAsAST;\n  switch (value) {\n  case SpecialConstantFloatingPoint::POSITIVE_ZERO: {\n    INCREMENT_ON_COVER(stats->numCoveredFPConstants);\n    valueAsAST = Z3ASTHandle::getFloatZero(sort, /*positive=*/true);\n    break;\n  }\n  case SpecialConstantFloatingPoint::NEGATIVE_ZERO: {\n    INCREMENT_ON_COVER(stats->numCoveredFPConstants);\n    valueAsAST = Z3ASTHandle::getFloatZero(sort, /*positive=*/false);\n    break;\n  }\n  case SpecialConstantFloatingPoint::POSITIVE_INFINITY: {\n    INCREMENT_ON_COVER(stats->numCoveredFPConstants);\n    valueAsAST = Z3ASTHandle::getFloatInfinity(sort, /*positive=*/true);\n    break;\n  }\n  case SpecialConstantFloatingPoint::NEGATIVE_INFINITY: {\n    INCREMENT_ON_COVER(stats->numCoveredFPConstants);\n    valueAsAST = Z3ASTHandle::getFloatInfinity(sort, /*positive=*/false);\n    break;\n  }\n  case SpecialConstantFloatingPoint::NOT_A_NUMBER: {\n    INCREMENT_ON_COVER(stats->numCoveredFPConstants);\n    valueAsAST = Z3ASTHandle::getFloatNAN(sort);\n    break;\n  }\n  case SpecialConstantFloatingPoint::POSITIVE_ONE: {\n    INCREMENT_ON_COVER(stats->numCoveredFPConstants);\n    valueAsAST = Z3ASTHandle::getFloatFromInt(sort, 1);\n    break;\n  }\n  case SpecialConstantFloatingPoint::NEGATIVE_ONE: {\n    INCREMENT_ON_COVER(stats->numCoveredFPConstants);\n    valueAsAST = Z3ASTHandle::getFloatFromInt(sort, -1);\n    break;\n  }\n  case SpecialConstantFloatingPoint::SMALLEST_POSITIVE_SUBNORMAL: {\n    INCREMENT_ON_COVER(stats->numCoveredFPConstants);\n    valueAsAST =\n        Z3ASTHandle::getFloatAbsoluteSmallestSubnormal(sort, /*positive=*/true);\n    break;\n  }\n  case SpecialConstantFloatingPoint::LARGEST_POSITIVE_SUBNORMAL: {\n    INCREMENT_ON_COVER(stats->numCoveredFPConstants);\n    valueAsAST =\n        Z3ASTHandle::getFloatAbsoluteLargestSubnormal(sort, /*positive=*/true);\n    break;\n  }\n  case SpecialConstantFloatingPoint::SMALLEST_POSITIVE_NORMAL: {\n    INCREMENT_ON_COVER(stats->numCoveredFPConstants);\n    valueAsAST =\n        Z3ASTHandle::getFloatAbsoluteSmallestNormal(sort, /*positive=*/true);\n    break;\n  }\n  case SpecialConstantFloatingPoint::LARGEST_POSITIVE_NORMAL: {\n    INCREMENT_ON_COVER(stats->numCoveredFPConstants);\n    valueAsAST =\n        Z3ASTHandle::getFloatAbsoluteLargestNormal(sort, /*positive=*/true);\n    break;\n  }\n  case SpecialConstantFloatingPoint::SMALLEST_NEGATIVE_SUBNORMAL: {\n    INCREMENT_ON_COVER(stats->numCoveredFPConstants);\n    valueAsAST =\n        Z3ASTHandle::getFloatAbsoluteLargestSubnormal(sort, /*positive=*/false);\n    break;\n  }\n  case SpecialConstantFloatingPoint::LARGEST_NEGATIVE_SUBNORMAL: {\n    INCREMENT_ON_COVER(stats->numCoveredFPConstants);\n    valueAsAST = Z3ASTHandle::getFloatAbsoluteSmallestSubnormal(\n        sort, /*positive=*/false);\n    break;\n  }\n  case SpecialConstantFloatingPoint::SMALLEST_NEGATIVE_NORMAL: {\n    INCREMENT_ON_COVER(stats->numCoveredFPConstants);\n    valueAsAST =\n        Z3ASTHandle::getFloatAbsoluteLargestNormal(sort, /*positive=*/false);\n    break;\n  }\n  case SpecialConstantFloatingPoint::LARGEST_NEGATIVE_NORMAL: {\n    INCREMENT_ON_COVER(stats->numCoveredFPConstants);\n    valueAsAST =\n        Z3ASTHandle::getFloatAbsoluteSmallestNormal(sort, /*positive=*/false);\n    break;\n  }\n  default:\n    auto index = static_cast<size_t>(value) - specialConstantsSize;\n    valueAsAST = valuesFromConstraints[index];\n    break;\n  }\n\n  return model.addAssignmentFor(be.getDecl(), valueAsAST);\n}\n\nvoid SpecialConstantSeedGenerator::postGenerationCallBack(SeedManager& sm) {\n  sortToConstraintConstantMap.clear();\n  // Add stats\n  if (sm.getContext().getStats()) {\n    sm.getContext().getStats()->append(std::move(stats));\n  }\n}\n\nvoid SpecialConstantSeedGenerator::preGenerationCallBack(SeedManager& sm) {\n  auto query = sm.getCurrentQuery();\n  auto& ctx = sm.getContext();\n  stats.reset(\n      new SpecialConstantSeedGeneratorStat(\"special_constant_seed_generator\"));\n  stats->totalNumBuiltInBVConstants =\n      static_cast<uint64_t>(SpecialConstantBitVector::SIZE);\n  stats->totalNumBuiltInFPConstants =\n      static_cast<uint64_t>(SpecialConstantFloatingPoint::SIZE);\n  stats->totalNumBuiltInBoolConstants = 2;\n\n  // Do a DFS to find any constants in the constraints.\n  std::list<Z3ASTHandle> workList;\n  Z3ASTSet seenExpr;\n  for (const auto& c : query->constraints) {\n    workList.push_back(c);\n  }\n  while (workList.size() != 0) {\n    Z3ASTHandle node = workList.front();\n    workList.pop_front();\n    if (seenExpr.count(node) > 0) {\n      // Already visited\n      continue;\n    }\n    seenExpr.insert(node);\n\n    // If this is a constant, track it by sort.\n    if (node.isConstant()) {\n      auto sort = node.getSort();\n      if (!sort.isBitVectorTy() && !sort.isFloatingPointTy()) {\n        continue;\n      }\n      auto& constants = sortToConstraintConstantMap[sort];\n      constants.push_back(node);\n      // Update stats\n      auto& count = stats->foundConstantsCount.emplace(sort, 0).first->second;\n      ++count;\n      continue;\n    }\n\n    // If this is a function application, visit the arguments.\n    if (node.isApp()) {\n      Z3AppHandle app = node.asApp();\n      for (size_t index = 0; index < app.getNumKids(); index++) {\n        workList.push_front(app.getKid(index));\n      }\n      continue;\n    }\n\n    llvm_unreachable(\"Unexpected node type\");\n  }\n\n  if (ctx.getVerbosity() > 1) {\n    ctx.getDebugStream() << \"(Constants found in constraints:)\\n\";\n    for (const auto& sortVectorPair : sortToConstraintConstantMap) {\n      const auto& sort = sortVectorPair.first;\n      ctx.getDebugStream() << \"(Stored for sort: \" << sort.toStr() << \")\\n\";\n      for (const auto& constant : sortVectorPair.second) {\n        ctx.getDebugStream() << \"  (\" << constant.toStr() << \")\\n\";\n      }\n    }\n  }\n}\n\nbool SpecialConstantSeedGenerator::writeSeed(SeedManager& sm) {\n  auto& ctx = sm.getContext();\n  auto fai = sm.getCurrentFuzzingAnalysisInfo();\n  const BufferAssignment* ba =\n      fai->freeVariableAssignment->bufferAssignment.get();\n\n  FileSerializableModel fsm(ctx);\n\n  // For each buffer element, randomly choose an assignment from special\n  // constants for its sort as well as any constants seen in the constraints.\n  for (const auto& be : *ba) {\n    auto sort = be.getSort();\n\n    // Dispatch to the appropriate helper function for the expr sort\n    bool success;\n    switch (sort.getKind()) {\n    case Z3_BOOL_SORT: {\n      success = chooseBool(ctx, be, fsm);\n      break;\n    }\n    case Z3_BV_SORT: {\n      success = chooseBitVector(ctx, be, fsm);\n      break;\n    }\n    case Z3_FLOATING_POINT_SORT: {\n      success = chooseFloatingPoint(ctx, be, fsm);\n      break;\n    }\n    default:\n      llvm_unreachable(\"Unhandled sort\");\n    }\n\n    if (!success) {\n      std::string underlyingString;\n      llvm::raw_string_ostream ss(underlyingString);\n      ss << \"Failed to generate assignment for \\\"\";\n      be.print(ss);\n      ss << \"\\\"\";\n      ctx.raiseError(ss.str());\n      return false;\n    }\n\n    if (ctx.getVerbosity() > 1) {\n      if (fsm.hasAssignmentFor(be.getDecl())) {\n        ctx.getDebugStream()\n            << \"(Sort: \" << sort.toStr()\n            << \", Assignment: \" << fsm.getAssignmentFor(be.getDecl()).toStr()\n            << \")\\n\";\n      } else {\n        ctx.getDebugStream() << \"(Sort: \" << sort.toStr() << \", Unassigned)\\n\";\n      }\n    }\n  }\n\n  // FIXME: Consider tracking what has been generated to avoid duplicates. For\n  // complex benchmarks, it seems simpler to keep selecting seeds randomly up to\n  // whatever limit the `SeedManager` has. (This implies though that it must\n  // have _some_ limit or else we'll select forever.)\n\n  // Save seed value to disk via the model.\n  return fsm.saveTo(sm.getBufferForSeed(getName()).get(), ba, ctx);\n}\n\nbool SpecialConstantSeedGenerator::empty() const { return false; }\n\n} // namespace fuzzingCommon\n} // namespace jfs\n"
  },
  {
    "path": "lib/FuzzingCommon/SpecialConstantSeedGeneratorStat.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Alastair Donaldson\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/SpecialConstantSeedGeneratorStat.h\"\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nSpecialConstantSeedGeneratorStat::SpecialConstantSeedGeneratorStat(\n    llvm::StringRef name)\n    : JFSStat(SEED_GENERATOR, name) {}\n\nSpecialConstantSeedGeneratorStat::~SpecialConstantSeedGeneratorStat() {}\n\nvoid SpecialConstantSeedGeneratorStat::printYAML(\n    llvm::ScopedPrinter& sp) const {\n  sp.indent();\n  auto& os = sp.getOStream();\n  os << \"\\n\";\n  sp.startLine() << \"name: \" << getName() << \"\\n\";\n  sp.startLine() << \"total_built_in_bv_constants: \"\n                 << totalNumBuiltInBVConstants << \"\\n\";\n  sp.startLine() << \"num_covered_built_in_bv_constant: \"\n                 << numCoveredBVConstants << \"\\n\";\n  assert(numCoveredBVConstants <= totalNumBuiltInBVConstants);\n  sp.startLine() << \"total_built_in_fp_constants: \"\n                 << totalNumBuiltInFPConstants << \"\\n\";\n  sp.startLine() << \"num_covered_built_in_fp_constant: \"\n                 << numCoveredFPConstants << \"\\n\";\n  assert(numCoveredFPConstants <= totalNumBuiltInFPConstants);\n  sp.startLine() << \"total_built_in_bool_constants: \"\n                 << totalNumBuiltInBoolConstants << \"\\n\";\n  sp.startLine() << \"num_covered_built_in_bv_constant: \"\n                 << numCoveredBoolConstants << \"\\n\";\n  assert(numCoveredBoolConstants <= totalNumBuiltInBVConstants);\n  if (foundConstantsCount.size() > 0) {\n    sp.startLine() << \"num_constants_by_sort:\\n\";\n    sp.indent();\n    for (const auto& pair : foundConstantsCount) {\n      sp.startLine() << \"\\\"\" << pair.first.toStr() << \"\\\": \" << pair.second\n                     << \"\\n\";\n    }\n    sp.unindent();\n  }\n  sp.unindent();\n}\n\n} // namespace fuzzingCommon\n} // namespace jfs\n"
  },
  {
    "path": "lib/FuzzingCommon/WorkingDirectoryManager.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/FuzzingCommon/WorkingDirectoryManager.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Support/FileUtils.h\"\n#include \"llvm/ADT/SmallVector.h\"\n#include \"llvm/Support/FileSystem.h\"\n#include \"llvm/Support/Path.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <assert.h>\n\nnamespace jfs {\nnamespace fuzzingCommon {\n\nWorkingDirectoryManager::WorkingDirectoryManager(llvm::StringRef path,\n                                                 jfs::core::JFSContext& ctx,\n                                                 bool deleteOnDestruction)\n    : path(path.str()), ctx(ctx), deleteOnDestruction(deleteOnDestruction) {\n\n  assert(llvm::sys::path::is_absolute(this->path));\n  assert(llvm::sys::fs::is_directory(this->path));\n  // TODO: Assert directory is empty\n  IF_VERB(ctx,\n          ctx.getDebugStream()\n              << \"(WorkingDirectoryManager \\\"\" << this->path\n              << \"\\\", deleteOnDestruction: \" << deleteOnDestruction << \")\\n\");\n}\n\nWorkingDirectoryManager::~WorkingDirectoryManager() {\n  if (!deleteOnDestruction)\n    return;\n  IF_VERB(ctx,\n          ctx.getDebugStream() << \"(Removing directory \\\"\" << path << \"\\\")\\n\");\n  auto error =\n      jfs::support::recursive_remove(path, /*IgnoreNonExisting=*/false);\n  if (error) {\n    std::string msg;\n    llvm::raw_string_ostream ss(msg);\n    ss << \"Failed to remove directory \" << path << \" because \"\n       << error.message();\n    ss.flush();\n    ctx.raiseError(msg);\n  }\n}\n\nstd::unique_ptr<WorkingDirectoryManager>\nWorkingDirectoryManager::makeAtPath(llvm::StringRef path,\n                                    jfs::core::JFSContext& ctx,\n                                    bool deleteOnDestruction) {\n\n  std::unique_ptr<WorkingDirectoryManager> toReturn(nullptr);\n  llvm::SmallVector<char, 256> mutablePath(path.begin(), path.end());\n  if (auto error = llvm::sys::fs::make_absolute(mutablePath)) {\n    std::string msg;\n    llvm::raw_string_ostream ss(msg);\n    ss << \"Failed to make \" << path << \" absolute\";\n    ss.flush();\n    ctx.raiseFatalError(msg);\n  }\n  if (auto error = llvm::sys::fs::create_directory(mutablePath,\n                                                   /*IgnoreExisting=*/false)) {\n    std::string msg;\n    llvm::raw_string_ostream ss(msg);\n    ss << \"Failed to make \" << path << \" because \" << error.message();\n    ss.flush();\n    ctx.raiseFatalError(msg);\n  }\n  llvm::StringRef pathAsStringRef(mutablePath.data(), mutablePath.size());\n  toReturn.reset(\n      new WorkingDirectoryManager(pathAsStringRef, ctx, deleteOnDestruction));\n  return toReturn;\n}\n\nstd::unique_ptr<WorkingDirectoryManager>\nWorkingDirectoryManager::makeInDirectory(llvm::StringRef directory,\n                                         llvm::StringRef prefix,\n                                         jfs::core::JFSContext& ctx,\n                                         bool deleteOnDestruction,\n                                         uint16_t maxN) {\n  assert(directory.size() > 0);\n  assert(prefix.size() > 0);\n  std::unique_ptr<WorkingDirectoryManager> toReturn(nullptr);\n  llvm::SmallVector<char, 256> mutablePath(directory.begin(), directory.end());\n  // Get `directory` as an absolute path.\n  if (auto error = llvm::sys::fs::make_absolute(mutablePath)) {\n    std::string msg;\n    llvm::raw_string_ostream ss(msg);\n    ss << \"Failed to make \" << directory << \" absolute\";\n    ss.flush();\n    ctx.raiseFatalError(msg);\n  }\n  // Check directory exists\n  llvm::StringRef directoryAsStringRef(mutablePath.data(), mutablePath.size());\n  if (!llvm::sys::fs::is_directory(directoryAsStringRef)) {\n    std::string msg;\n    llvm::raw_string_ostream ss(msg);\n    ss << directoryAsStringRef << \" is not an existing directory\";\n    ss.flush();\n    ctx.raiseFatalError(msg);\n    return toReturn;\n  }\n  // Add prefix\n  llvm::sys::path::append(mutablePath, prefix);\n  // Now loop through prefixes\n  for (unsigned index = 0; index < maxN; ++index) {\n    llvm::Twine tempNum(index);\n    auto tempPath = llvm::Twine(mutablePath).concat(\"-\");\n    auto tempPathWithNum = tempPath.concat(tempNum);\n    if (auto error =\n            llvm::sys::fs::create_directory(tempPathWithNum,\n                                            /*IgnoreExisting=*/false)) {\n      if (error == std::errc::file_exists) {\n        continue;\n      }\n      std::string msg;\n      llvm::raw_string_ostream ss(msg);\n      ss << \"Failed to create \" << tempPath << \" because \" << error.message();\n      ss.flush();\n      ctx.raiseFatalError(msg);\n      return toReturn;\n    }\n    // Suceeded\n    llvm::SmallVector<char, 256> tempBuffer;\n    llvm::StringRef finalPathAsStringRef = tempPathWithNum.toStringRef(tempBuffer);\n    toReturn.reset(new WorkingDirectoryManager(finalPathAsStringRef, ctx,\n                                               deleteOnDestruction));\n    return toReturn;\n  }\n  std::string msg;\n  llvm::raw_string_ostream ss(msg);\n  ss << \"Failed to create directory in \" << directory\n     << \" due to exhausting N (\" << maxN << \")\";\n  ss.flush();\n  ctx.raiseFatalError(msg);\n  return toReturn;\n}\n\nstd::string WorkingDirectoryManager::getPathToFileInDirectory(\n    llvm::StringRef fileName) const {\n  llvm::SmallVector<char, 256> mutablePath(path.begin(), path.end());\n  llvm::sys::path::append(mutablePath, fileName);\n  return llvm::Twine(mutablePath).str();\n}\n\nstd::string\nWorkingDirectoryManager::makeNewDirectoryInDirectory(llvm::StringRef dirName) {\n  assert(dirName.size() > 0);\n  std::string fullDirPath = getPathToFileInDirectory(dirName);\n  if (auto error = llvm::sys::fs::create_directory(fullDirPath,\n                                                   /*IgnoreExisting=*/false)) {\n    std::string msg;\n    llvm::raw_string_ostream ss(msg);\n    ss << \"Failed to create \" << fullDirPath << \" because \" << error.message();\n    ss.flush();\n    ctx.raiseFatalError(msg);\n  }\n  return fullDirPath;\n}\n}\n}\n"
  },
  {
    "path": "lib/Support/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\njfs_add_component(JFSSupport\n  CancellableProcess.cpp\n  ErrorMessages.cpp\n  FileUtils.cpp\n  ICancellable.cpp\n  JFSStat.cpp\n  ScopedTimer.cpp\n  StatisticsManager.cpp\n  Timer.cpp\n  version.cpp\n)\n\n# Needed for command line support\njfs_get_llvm_components(llvm_components support)\n\ntarget_link_libraries(JFSSupport PUBLIC ${llvm_components})\n"
  },
  {
    "path": "lib/Support/CancellableProcess.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Support/CancellableProcess.h\"\n#include \"llvm/Support/Program.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <atomic>\n#include <mutex>\n#include <signal.h>\n#include <sys/types.h>\n#include <unistd.h>\n\nnamespace jfs {\nnamespace support {\n\nclass CancellableProcessImpl {\nprivate:\n  std::atomic<bool> cancelled;\n  llvm::sys::ProcessInfo processInfo;\n  std::mutex processInfoMutex;\n\npublic:\n  CancellableProcessImpl() : cancelled(false) {\n    // HACK: This is for the implementation of `kill()`.\n    setpgid(0, 0); // Try to make ourselves the process group leader.\n    cleanUp();\n  }\n  ~CancellableProcessImpl() {}\n\n  void cleanUp() { processInfo.Pid = llvm::sys::ProcessInfo::InvalidPid; }\n\n  void cancel() {\n    cancelled = true;\n    // Kill the process if necessary.\n    kill();\n  }\n\n  void kill() {\n    {\n      // Only read the PID when we hold the mutex\n      std::lock_guard<std::mutex> lock(processInfoMutex);\n      auto pid = processInfo.Pid;\n      if (pid == llvm::sys::ProcessInfo::InvalidPid)\n        return;\n      // FIXME: This is POSIX specific\n\n      // HACK: Processes like Clang fork and so just doing `kill(pid, SIGTERM)`\n      // won't kill the child processes. To workaround this we temporarily\n      // ignore SIGTERM ourselves and then send SIGTERM to our process group\n      // and then set the handler for SIGTERM to whatever it was before.\n      // This sucks because this is only really safe if JFS is launched as\n      // the leader of the process group. This is the case when jfs is launched\n      // from a shell but probably not in other cases (e.g. Python script using\n      // subprocess). Therefore the constructor of this class enforces that\n      // we are the group leader.\n\n      struct sigaction oldHandler;\n      // Get the current\n      int result = ::sigaction(SIGTERM, nullptr, &oldHandler);\n      assert((result == 0) && \"Failed to get current signal handler\");\n      // Set the new handler to ignore SIGTERM\n      struct sigaction newHandler = oldHandler;\n      newHandler.sa_handler = SIG_IGN;\n      result = ::sigaction(SIGTERM, &newHandler, nullptr);\n      assert((result == 0) && \"Failed to change signal handler\");\n\n      // Send SIGTERM to the process group\n      pid_t processGroupID = getpgrp();\n      // llvm::errs() << \"Sending SIGTERM to process group \" << processGroupID\n      // << \"\\n\";\n      result = ::kill(-processGroupID, SIGTERM);\n      // llvm::errs() << \"kill result: \" << result << \"\\n\";\n      // Set the handler back\n      result = ::sigaction(SIGTERM, &oldHandler, nullptr);\n      assert((result == 0) && \"Failed to change signal handler back\");\n    }\n  }\n\n  int execute(llvm::StringRef program, std::vector<const char*>& args,\n              std::vector<llvm::StringRef>& redirects, const char** envp) {\n    if (cancelled) {\n      return -1;\n    }\n    assert(args[args.size() - 1] == nullptr && \"args must be null termianted\");\n\n    // FIXME: This awkwardness is due to r313155 in LLVM. We should just fix\n    // our function signature to use LLVM's use of\n    // ArrayRef<Optional<StringRef>> to simplify things.\n    llvm::Optional<llvm::StringRef> redirectOptionals[3] = {\n        llvm::None, llvm::None, llvm::None};\n    if (redirects.size() > 0) {\n      assert(redirects.size() == 3);\n      unsigned optionalIndex = 0;\n      for (const auto& sf : redirects) {\n        assert(optionalIndex < 3);\n        redirectOptionals[optionalIndex] = llvm::Optional<llvm::StringRef>(sf);\n        ++optionalIndex;\n      }\n    }\n\n    std::string errorMsg;\n    bool executionFailed = false;\n    {\n      // Only write when the mutex is held.\n      std::lock_guard<std::mutex> lock(processInfoMutex);\n      // Execute without waiting so that the `ProcessInfo`\n      // is stored so we can kill it from `cancel()`.\n      processInfo = llvm::sys::ExecuteNoWait(\n          /*Program=*/program,\n          /*args=*/args.data(),\n          /*env=*/envp,\n          /*redirects=*/\n          ((redirects.size() == 0)\n               ? (llvm::ArrayRef<llvm::Optional<llvm::StringRef>>())\n               : redirectOptionals),\n          /*memoryLimit=*/0,\n          /*ErrMsg=*/&errorMsg,\n          /*ExecutionFailed=*/&executionFailed);\n    }\n\n    if (executionFailed) {\n      // FIXME: emit to an interface\n      // llvm::errs() << \"Execution failed: \" << errorMsg << \"\\n\";\n      cleanUp(); // FIXME: Should use RAII style clean up.\n      return -1;\n    }\n\n    llvm::sys::ProcessInfo tempProcessInfo =\n        llvm::sys::Wait(processInfo,\n                        /*secondsToWait=*/0,\n                        /*WaitUntilTerminates=*/true,\n                        /*ErrMsg=*/\n                        &errorMsg);\n    {\n      // Only write when the mutex is held.\n      std::lock_guard<std::mutex> lock(processInfoMutex);\n      processInfo = tempProcessInfo;\n    }\n\n    if (errorMsg.size() != 0 && !cancelled) {\n      cleanUp();\n      // llvm::errs() << \"Execution failed: \" << errorMsg << \"\\n\";\n      return -1;\n    }\n\n    if (cancelled) {\n      cleanUp();\n      return -2;\n    }\n    cleanUp();\n    return processInfo.ReturnCode;\n  }\n};\n\nCancellableProcess::CancellableProcess() : impl(new CancellableProcessImpl()) {}\nCancellableProcess::~CancellableProcess() {}\n\nvoid CancellableProcess::cancel() { impl->cancel(); }\nint CancellableProcess::execute(llvm::StringRef program,\n                                std::vector<const char*>& args,\n                                std::vector<llvm::StringRef>& redirects,\n                                const char** envp) {\n  return impl->execute(program, args, redirects, envp);\n}\n}\n}\n"
  },
  {
    "path": "lib/Support/ErrorMessages.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Support/ErrorMessages.h\"\n#include \"llvm/Support/raw_ostream.h\"\n\nnamespace jfs {\nnamespace support {\n\nstd::string getMessageForFailedOpenFileOrSTDIN(llvm::StringRef inputFileName,\n                                               std::error_code ec) {\n  std::string s;\n  llvm::raw_string_ostream ss(s);\n  ss << \"(error \\\"Could not open \" << inputFileName << \" because \"\n     << ec.message() << \"\\\")\\n\";\n  return ss.str();\n}\n\nstd::string\ngetMessageForFailedOpenFileForWriting(llvm::StringRef outputFileName,\n                                      std::error_code ec) {\n  std::string s;\n  llvm::raw_string_ostream ss(s);\n  ss << \"(error \\\"Could not open \" << outputFileName << \" for writing because \"\n     << ec.message() << \"\\\")\\n\";\n  return ss.str();\n}\n}\n}\n"
  },
  {
    "path": "lib/Support/FileUtils.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Support/FileUtils.h\"\n#include \"llvm/ADT/StringRef.h\"\n#include \"llvm/Support/FileSystem.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <system_error>\n\nnamespace {\nstd::error_code recursive_remove_impl(llvm::StringRef path,\n                                      llvm::sys::fs::file_type ft) {\n  if (ft == llvm::sys::fs::file_type::directory_file) {\n    std::error_code ec;\n    llvm::sys::fs::directory_iterator i(path, ec);\n    if (ec)\n      return ec;\n    for (llvm::sys::fs::directory_iterator endIt; i != endIt; i.increment(ec)) {\n      if (ec)\n        return ec;\n      llvm::ErrorOr<llvm::sys::fs::basic_file_status> st = i->status();\n      if (auto ec = st.getError()) {\n        return ec;\n      }\n      // Remove contents of this directory first\n      if (auto ec = recursive_remove_impl(i->path(), st->type())) {\n        return ec;\n      }\n    }\n    // Directory should now be empty. We can remove it now.\n    return llvm::sys::fs::remove(path, /*IgnoreNonExisting=*/false);\n  } else {\n    return llvm::sys::fs::remove(path, /*IgnoreNonExisting=*/false);\n  }\n  return std::error_code();\n}\n}\n\nnamespace jfs {\nnamespace support {\n\n// This based on code that was removed from LLVM in\n// r198955 ( 217c714a6779841ae06f420f384b87e12454b1a1 ).\nstd::error_code recursive_remove(llvm::StringRef path, bool IgnoreNonExisting) {\n  llvm::sys::fs::file_status status;\n  if (auto error = llvm::sys::fs::status(path, status)) {\n    if (IgnoreNonExisting && error == std::errc::no_such_file_or_directory) {\n      return std::error_code();\n    }\n    return error;\n  }\n  return recursive_remove_impl(path, status.type());\n}\n}\n}\n"
  },
  {
    "path": "lib/Support/ICancellable.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Support/ICancellable.h\"\n\nnamespace jfs {\nnamespace support {\n\nICancellable::~ICancellable() {}\n\n} // namespace support\n} // namespace jfs\n"
  },
  {
    "path": "lib/Support/JFSStat.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Support/JFSStat.h\"\n#include \"llvm/Support/Format.h\"\n\nnamespace jfs {\nnamespace support {\n\n// JFSStat\nJFSStat::JFSStat(JFSStatKind kind, llvm::StringRef name) : kind(kind) {\n  this->name.assign(name.begin(), name.end());\n}\n\nJFSStat::~JFSStat() {}\n\nvoid JFSStat::dump() const {\n  llvm::ScopedPrinter sp(llvm::errs());\n  printYAML(sp);\n}\n\nllvm::StringRef JFSStat::getName() const { return name; }\n\n// JFSTimerStat\nJFSTimerStat::JFSTimerStat(RecordTy record, llvm::StringRef name)\n    : JFSStat(SINGLE_TIMER, name), record(record) {}\nJFSTimerStat::~JFSTimerStat() {}\n\nvoid JFSTimerStat::printYAML(llvm::ScopedPrinter& sp) const {\n  sp.indent();\n  auto& os = sp.getOStream();\n  os << \"\\n\";\n  sp.startLine() << \"name: \" << getName() << \"\\n\";\n#define TIME_FMT_STR \"%.6f\"\n  sp.startLine() << \"user_time: \"\n                 << llvm::format(TIME_FMT_STR, record.getUserTime()) << \"\\n\";\n  sp.startLine() << \"sys_time: \"\n                 << llvm::format(TIME_FMT_STR, record.getSystemTime()) << \"\\n\";\n  sp.startLine() << \"wall_time: \"\n                 << llvm::format(TIME_FMT_STR, record.getWallTime()) << \"\\n\";\n  sp.startLine() << \"mem_use: \" << record.getMemUsed() << \"\\n\";\n#undef TIME_FMT_STR\n  sp.unindent();\n}\n\n// JFSAggregateTimerStat\nJFSAggregateTimerStat::JFSAggregateTimerStat(llvm::StringRef name)\n    : JFSStat(AGGREGATE_TIMER, name) {}\n\nJFSAggregateTimerStat::~JFSAggregateTimerStat() {}\n\nvoid JFSAggregateTimerStat::append(std::unique_ptr<JFSTimerStat> t) {\n  timers.push_back(std::move(t));\n}\n\nvoid JFSAggregateTimerStat::clear() { timers.clear(); }\n\nvoid JFSAggregateTimerStat::printYAML(llvm::ScopedPrinter& sp) const {\n  sp.indent();\n  auto& os = sp.getOStream();\n  os << \"\\n\";\n  sp.startLine() << \"name: \" << getName() << \"\\n\";\n  sp.startLine() << \"stats:\";\n  if (timers.size() == 0) {\n    os << \" []\\n\";\n    return;\n  }\n  os << \"\\n\";\n  sp.indent();\n  for (const auto& stat : timers) {\n    sp.startLine() << \"-\";\n    stat->printYAML(sp);\n  }\n  sp.unindent();\n  sp.unindent();\n}\n}\n}\n"
  },
  {
    "path": "lib/Support/ScopedTimer.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Support/ScopedTimer.h\"\n#include <chrono>\n#include <condition_variable>\n#include <thread>\n\nnamespace jfs {\nnamespace support {\n\nclass ScopedTimerImpl {\nprivate:\n  uint64_t maxTime;\n  ScopedTimer::CallBackTy callBack;\n  std::unique_ptr<std::thread> waiter;\n  std::condition_variable cv;\n  std::mutex cvMutex;\n  bool realWakeUp;\n  std::chrono::time_point<std::chrono::steady_clock> startTime;\n  std::chrono::time_point<std::chrono::steady_clock> endTime;\n  bool waiterStarted;\n\npublic:\n  void waiterFunction() {\n    std::unique_lock<std::mutex> lock(cvMutex);\n    waiterStarted = true;\n    // Loop just in case there are spurious wake ups\n    while (true) {\n      std::cv_status status = cv.wait_until(lock, endTime);\n      if (status == std::cv_status::timeout) {\n        callBack();\n        break;\n      }\n      if (realWakeUp) {\n        break;\n      }\n      // Spurious wake up. Just sleep again\n    }\n  }\n  ScopedTimerImpl(uint64_t maxTime, ScopedTimer::CallBackTy callBack)\n      : maxTime(maxTime), callBack(callBack), waiter(nullptr),\n        realWakeUp(false), waiterStarted(false) {\n    startTime = std::chrono::steady_clock::now();\n    std::chrono::seconds timeout(maxTime);\n    endTime = startTime + timeout;\n\n    if (maxTime == 0) {\n      return;\n    }\n    waiter.reset(new std::thread(&ScopedTimerImpl::waiterFunction, this));\n  }\n  ~ScopedTimerImpl() {\n    if (waiter == nullptr)\n      return;\n\n    // Spin until `waiterFunction()` is waiting.  If we don't do this we might\n    // call `notify_one()` before `waiterFunction()` is waiting and thus the\n    // signal will be lost resulting in a deadlock when `waiter->join()` is\n    // called.\n    //\n    // Given `waiterFunction()`'s implementation if `waiterStarted` is true\n    // and we managed to grab the mutex then `waiter` thread must be waiting.\n    while (true) {\n      std::lock_guard<std::mutex> lock(cvMutex);\n      if (waiterStarted) {\n        // Wake up the thread if it's still running\n        realWakeUp = true;\n        break;\n      }\n    }\n    cv.notify_one();\n    if (waiter->joinable())\n      waiter->join();\n  }\n\n  uint64_t getRemainingTime() const {\n    auto now = std::chrono::steady_clock::now();\n    auto remaining = endTime - now;\n    auto remainingAsSecs =\n        std::chrono::duration_cast<std::chrono::seconds>(remaining);\n    int64_t remainingNativeTy = remainingAsSecs.count();\n    if (remainingNativeTy < 0) {\n      return 0;\n    }\n    return remainingNativeTy;\n  }\n\n  uint64_t getMaxTime() const { return maxTime; }\n};\n\nScopedTimer::ScopedTimer(uint64_t maxTime, CallBackTy callBack)\n    : impl(new ScopedTimerImpl(maxTime, callBack)) {}\n\nScopedTimer::~ScopedTimer() {\n  // Let ~ScopedTimerImpl() do the work\n}\n\nuint64_t ScopedTimer::getRemainingTime() const {\n  return impl->getRemainingTime();\n}\n\nuint64_t ScopedTimer::getMaxTime() const { return impl->getMaxTime(); }\n}\n}\n"
  },
  {
    "path": "lib/Support/StatisticsManager.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Support/StatisticsManager.h\"\n#include \"jfs/Support/JFSStat.h\"\n#include <assert.h>\n#include <list>\n#include <memory>\n\nnamespace jfs {\nnamespace support {\n\nclass StatisticsManagerImpl {\nprivate:\n  std::list<std::unique_ptr<const JFSStat>> stats;\n\npublic:\n  StatisticsManagerImpl() {}\n  ~StatisticsManagerImpl() {}\n  void append(std::unique_ptr<JFSStat> stat) {\n    assert(stat.get() != nullptr);\n    stats.push_back(std::move(stat));\n  }\n  void clear() { stats.clear(); }\n  size_t size() const { return stats.size(); }\n  void printYAML(llvm::raw_ostream& os) const {\n    llvm::ScopedPrinter sp(os);\n    sp.getOStream() << \"stats:\";\n\n    if (stats.size() == 0) {\n      sp.getOStream() << \"[]\\n\";\n      return;\n    }\n    sp.getOStream() << \"\\n\";\n\n    sp.indent();\n    for (const auto& stat : stats) {\n      sp.printIndent();\n      sp.getOStream() << \"-\";\n      stat->printYAML(sp);\n    }\n    sp.unindent();\n  }\n  void dump() const { printYAML(llvm::errs()); }\n};\n\nStatisticsManager::StatisticsManager() : impl(new StatisticsManagerImpl()) {}\n\nStatisticsManager::~StatisticsManager() {}\n\nvoid StatisticsManager::append(std::unique_ptr<JFSStat> stat) {\n  impl->append(std::move(stat));\n}\n\nvoid StatisticsManager::clear() { impl->clear(); }\n\nsize_t StatisticsManager::size() const { return impl->size(); }\n\nvoid StatisticsManager::printYAML(llvm::raw_ostream& os) const {\n  return impl->printYAML(os);\n}\n\nvoid StatisticsManager::dump() const { impl->dump(); }\n}\n}\n"
  },
  {
    "path": "lib/Support/Timer.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Support/Timer.h\"\n\nusing namespace llvm;\n\nnamespace jfs {\nnamespace support {\n\nTimer::Timer() : Running(false), Triggered(false) {}\nTimer::~Timer() {}\n\nvoid Timer::startTimer() {\n  assert(!Running && \"Cannot start a running timer\");\n  Running = Triggered = true;\n  StartTime = TimeRecord::getCurrentTime(true);\n}\n\nvoid Timer::stopTimer() {\n  assert(Running && \"Cannot stop a paused timer\");\n  Running = false;\n  Time += TimeRecord::getCurrentTime(false);\n  Time -= StartTime;\n}\n\nvoid Timer::clear() {\n  Running = Triggered = false;\n  Time = StartTime = TimeRecord();\n}\n}\n}\n"
  },
  {
    "path": "lib/Support/version.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Support/version.h\"\n#include \"jfs/Config/version.h\"\n\n#define STR_TOKENIZE(X) STR_TOKENIZER(X)\n#define STR_TOKENIZER(X) #X\n\nnamespace jfs {\nnamespace support {\nconst char *getVersionString() {\n  return \"JFS \"\n    STR_TOKENIZE(JFS_VERSION_MAJOR) \".\"\n    STR_TOKENIZE(JFS_VERSION_MINOR) \".\"\n    STR_TOKENIZE(JFS_VERSION_PATCH) \".\"\n    STR_TOKENIZE(JFS_VERSION_TWEAK)\n#ifdef JFS_GIT_HASH\n      \" (\" STR_TOKENIZE(JFS_GIT_HASH) \")\"\n#endif\n#ifdef JFS_GIT_DESCRIPTION\n      \" (\" STR_TOKENIZE(JFS_GIT_DESCRIPTION) \")\"\n#endif\n      ;\n}\n}\n}\n"
  },
  {
    "path": "lib/Transform/AndHoistingPass.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Transform/AndHoistingPass.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include <list>\n#include <vector>\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace transform {\n\nbool AndHoistingPass::run(Query &q) {\n  JFSContext& ctx = q.getContext();\n  bool changed = false;\n  std::vector<Z3ASTHandle> newConstraints;\n  newConstraints.reserve(q.constraints.size());\n  std::list<Z3ASTHandle> workList;\n  for (auto ci = q.constraints.cbegin(), ce = q.constraints.cend(); ci != ce;\n       ++ci) {\n    workList.push_back(*ci);\n  }\n  while (workList.size() > 0) {\n    Z3ASTHandle e = workList.front();\n    workList.pop_front();\n    if (cancelled) {\n      IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\");\n      return false;\n    }\n    if (!e.isAppOf(Z3_OP_AND)) {\n      // Not an logical and application.\n      // Just add as a constraint\n      newConstraints.push_back(e);\n      continue;\n    }\n    // This is an and expression. Push on to work list so we walk the AST.\n    changed = true;\n    assert(e.isApp() && \"should be an application\");\n    Z3AppHandle app = e.asApp();\n\n    unsigned numKids = app.getNumKids();\n    assert(numKids >= 2 && \"Unexpected number of args\");\n    for (unsigned index = 0; index < numKids; ++index) {\n      // We invert the index so we add the kids right to left to the work list\n      // which means when popping from the work list we'll handle the nodes\n      // left to right.\n      assert(numKids >= (index + 1) && \"underflow\");\n      unsigned invertedIndex = numKids - 1 - index;\n      workList.push_front(app.getKid(invertedIndex));\n    }\n  }\n\n  // We didn't do any hoisting or a cancel was triggered\n  // so leave Query untouched.\n  if (cancelled) {\n    IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\");\n    return false;\n  }\n  if (!changed)\n    return false;\n\n  q.constraints = std::move(newConstraints);\n  return true;\n}\n\nllvm::StringRef AndHoistingPass::getName() { return \"AndHoisting\"; }\n\nbool AndHoistingPass::convertModel(jfs::core::Model* m) {\n  // This pass preserves equivalence so the model does not need to be\n  // converted.\n  return true;\n}\n}\n\n} // namespace jfs\n"
  },
  {
    "path": "lib/Transform/BitBlastPass.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Transform/BitBlastPass.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include <list>\n#include <vector>\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace transform {\n\nbool BitBlastPass::run(Query &q) {\n  JFSContext& ctx = q.getContext();\n  std::vector<Z3ASTHandle> newConstraints;\n  z3Ctx = ctx.getZ3Ctx();\n\n  Z3TacticHandle tactic(::Z3_mk_tactic(z3Ctx, \"bit-blast\"), z3Ctx);\n\n  Z3GoalHandle initialGoal(::Z3_mk_goal(z3Ctx, /*models=*/false,\n                                        /*unsat_cores=*/false,\n                                        /*proofs=*/false),\n                           z3Ctx);\n\n  for (auto ci = q.constraints.cbegin(), ce = q.constraints.cend(); ci != ce;\n       ++ci) {\n    initialGoal.addFormula(*ci);\n  }\n\n#define CHECK_CANCELED()                                                       \\\n  if (cancelled) {                                                             \\\n    IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\"); \\\n    return false;                                                              \\\n  }\n\n  CHECK_CANCELED();\n\n  // Apply the tactic and store it for use in convertModel()\n  result = tactic.apply(initialGoal);\n\n  CHECK_CANCELED();\n\n  // Collect all the resulting formulas\n  result.collectAllFormulas(newConstraints);\n\n  if (Query::areSame(q.constraints, newConstraints, /*ignoreOrder=*/true))\n    return false;\n\n  // Something changed\n  q.constraints = std::move(newConstraints);\n  return true;\n}\n\nllvm::StringRef BitBlastPass::getName() { return \"BitBlast\"; }\n}\n}\n"
  },
  {
    "path": "lib/Transform/BvBoundPropagationPass.cpp",
    "content": "\n//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Transform/BvBoundPropagationPass.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include <list>\n#include <vector>\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace transform {\n\nbool BvBoundPropagationPass::run(Query &q) {\n  JFSContext& ctx = q.getContext();\n  std::vector<Z3ASTHandle> newConstraints;\n  z3Ctx = ctx.getZ3Ctx();\n  // NOTE: This tactic only modifies bvule and bvsle so the SimplificationPass\n  // needs to be run first.\n  Z3TacticHandle propagateValuesTactic(\n      ::Z3_mk_tactic(z3Ctx, \"propagate-bv-bounds\"), z3Ctx);\n\n  Z3GoalHandle initialGoal(::Z3_mk_goal(z3Ctx, /*models=*/false,\n                                        /*unsat_cores=*/false,\n                                        /*proofs=*/false),\n                           z3Ctx);\n\n  // Add the constraints to the goal\n  for (auto ci = q.constraints.cbegin(), ce = q.constraints.cend(); ci != ce;\n       ++ci) {\n    initialGoal.addFormula(*ci);\n  }\n\n  if (cancelled) {\n    IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\");\n    return false;\n  }\n\n  // Apply the tactic and store it for use in convertModel()\n  result = propagateValuesTactic.apply(initialGoal);\n\n  if (cancelled) {\n    IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\");\n    return false;\n  }\n\n  // Collect all the resulting formulas\n  result.collectAllFormulas(newConstraints);\n\n  if (Query::areSame(q.constraints, newConstraints, /*ignoreOrder=*/true))\n    return false;\n\n  // Something changed\n  q.constraints = std::move(newConstraints);\n  return true;\n}\n\nllvm::StringRef BvBoundPropagationPass::getName() {\n  return \"BvBoundPropagation\";\n}\n}\n}\n"
  },
  {
    "path": "lib/Transform/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\njfs_add_component(JFSTransform\n  AndHoistingPass.cpp\n  BitBlastPass.cpp\n  BvBoundPropagationPass.cpp\n  ConstantPropagationPass.cpp\n  DIMACSOutputPass.cpp\n  DuplicateConstraintEliminationPass.cpp\n  FpToBvPass.cpp\n  QueryPassManager.cpp\n  SimpleContradictionsToFalsePass.cpp\n  SimplificationPass.cpp\n  StandardPasses.cpp\n  TrueConstraintEliminationPass.cpp\n  Z3QueryPass.cpp\n)\ntarget_link_libraries(JFSTransform PUBLIC JFSCore)\n"
  },
  {
    "path": "lib/Transform/ConstantPropagationPass.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Transform/ConstantPropagationPass.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include <list>\n#include <vector>\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace transform {\n\nbool ConstantPropagationPass::run(Query &q) {\n  JFSContext& ctx = q.getContext();\n  std::vector<Z3ASTHandle> newConstraints;\n  z3Ctx = ctx.getZ3Ctx();\n  Z3TacticHandle propagateValuesTactic(\n      ::Z3_mk_tactic(z3Ctx, \"propagate-values\"), z3Ctx);\n\n  Z3GoalHandle initialGoal(::Z3_mk_goal(z3Ctx, /*models=*/false,\n                                        /*unsat_cores=*/false,\n                                        /*proofs=*/false),\n                           z3Ctx);\n\n  for (auto ci = q.constraints.cbegin(), ce = q.constraints.cend(); ci != ce;\n       ++ci) {\n    initialGoal.addFormula(*ci);\n  }\n\n  if (cancelled) {\n    IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\");\n    return false;\n  }\n\n  // Apply the tactic and store it for use in convertModel()\n  result = propagateValuesTactic.apply(initialGoal);\n\n  if (cancelled) {\n    IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\");\n    return false;\n  }\n\n  // Collect all the resulting formulas\n  result.collectAllFormulas(newConstraints);\n\n  if (Query::areSame(q.constraints, newConstraints, /*ignoreOrder=*/true))\n    return false;\n\n  // Something changed\n  q.constraints = std::move(newConstraints);\n  return true;\n}\n\nllvm::StringRef ConstantPropagationPass::getName() {\n  return \"ConstantPropagation\";\n}\n}\n}\n"
  },
  {
    "path": "lib/Transform/DIMACSOutputPass.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Transform/DIMACSOutputPass.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include <list>\n#include <vector>\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace transform {\n\nbool DIMACSOutputPass::run(Query &q) {\n  JFSContext& ctx = q.getContext();\n  std::vector<Z3ASTHandle> newConstraints;\n  z3Ctx = ctx.getZ3Ctx();\n\n  Z3TacticHandle tactic(::Z3_mk_tactic(z3Ctx, \"sat\"), z3Ctx);\n\n  Z3GoalHandle initialGoal(::Z3_mk_goal(z3Ctx, /*models=*/false,\n                                        /*unsat_cores=*/false,\n                                        /*proofs=*/false),\n                           z3Ctx);\n\n  for (auto ci = q.constraints.cbegin(), ce = q.constraints.cend(); ci != ce;\n       ++ci) {\n    initialGoal.addFormula(*ci);\n  }\n\n#define CHECK_CANCELED()                                                       \\\n  if (cancelled) {                                                             \\\n    IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\"); \\\n    return false;                                                              \\\n  }\n\n  CHECK_CANCELED();\n\n  // Enable `dimacs.display` which writes CNF in DIMACS format to stdout without\n  // solving satisfiability.\n  // FIXME: This option has been removed in newer versions of Z3, so some care\n  // is needed when upgrading Z3 here. Newer Z3 offers a\n  // `Z3_goal_to_dimacs_string` API which should work as a replacement.  It may\n  // require an additional `tseitin-cnf` pass for valid results.\n  // NOTE: Z3's DIMACS output includes comment lines that map constraints to CNF\n  // variables, but it has an off-by-one error in this output. Since they are\n  // comment lines, there is no functional impact on consumers that read this\n  // format.\n  Z3ParamsHandle params(::Z3_mk_params(z3Ctx), z3Ctx);\n  Z3_symbol dimacs_display = ::Z3_mk_string_symbol(z3Ctx, \"dimacs.display\");\n  Z3_params_set_bool(z3Ctx, params, dimacs_display, true);\n\n  // Apply the tactic and store it for use in convertModel()\n  result = tactic.applyWithParams(initialGoal, params);\n\n  CHECK_CANCELED();\n\n  // This is an output pass only, so we skip updating the constraints\n  return false;\n}\n\nllvm::StringRef DIMACSOutputPass::getName() { return \"DIMACSOutput\"; }\n}\n}\n"
  },
  {
    "path": "lib/Transform/DuplicateConstraintEliminationPass.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Transform/DuplicateConstraintEliminationPass.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include <vector>\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace transform {\n\nbool DuplicateConstraintEliminationPass::run(Query &q) {\n  JFSContext& ctx = q.getContext();\n  bool changed = false;\n  std::vector<Z3ASTHandle> newConstraints;\n  newConstraints.reserve(q.constraints.size());\n  Z3ASTSet seenConstraints;\n  for (auto ci = q.constraints.cbegin(), ce = q.constraints.cend(); ci != ce;\n       ++ci) {\n    if (cancelled) {\n      IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\");\n      return false;\n    }\n\n    if (seenConstraints.count(*ci) > 0) {\n      changed = true;\n      continue;\n    }\n    // Not seen before\n    seenConstraints.insert(*ci);\n    newConstraints.push_back(*ci);\n  }\n\n  if (cancelled) {\n    IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\");\n    return false;\n  }\n\n  if (!changed)\n    return false;\n\n  q.constraints = std::move(newConstraints);\n  return true;\n}\n\nllvm::StringRef DuplicateConstraintEliminationPass::getName() {\n  return \"DuplicateConstraintElimination\";\n}\n\nbool DuplicateConstraintEliminationPass::convertModel(jfs::core::Model* m) {\n  // This pass preserves equivalence so the model does not need to be\n  // converted.\n  return true;\n}\n}\n}\n"
  },
  {
    "path": "lib/Transform/FpToBvPass.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Transform/FpToBvPass.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include <list>\n#include <vector>\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace transform {\n\nbool FpToBvPass::run(Query &q) {\n  JFSContext& ctx = q.getContext();\n  std::vector<Z3ASTHandle> newConstraints;\n  z3Ctx = ctx.getZ3Ctx();\n\n  Z3TacticHandle tactic(::Z3_mk_tactic(z3Ctx, \"fpa2bv\"), z3Ctx);\n\n  Z3GoalHandle initialGoal(::Z3_mk_goal(z3Ctx, /*models=*/false,\n                                        /*unsat_cores=*/false,\n                                        /*proofs=*/false),\n                           z3Ctx);\n\n  for (auto ci = q.constraints.cbegin(), ce = q.constraints.cend(); ci != ce;\n       ++ci) {\n    initialGoal.addFormula(*ci);\n  }\n\n#define CHECK_CANCELED()                                                       \\\n  if (cancelled) {                                                             \\\n    IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\"); \\\n    return false;                                                              \\\n  }\n\n  CHECK_CANCELED();\n\n  // Apply the tactic and store it for use in convertModel()\n  result = tactic.apply(initialGoal);\n\n  CHECK_CANCELED();\n\n  // Collect all the resulting formulas\n  result.collectAllFormulas(newConstraints);\n\n  if (Query::areSame(q.constraints, newConstraints, /*ignoreOrder=*/true))\n    return false;\n\n  // Something changed\n  q.constraints = std::move(newConstraints);\n  return true;\n}\n\nllvm::StringRef FpToBvPass::getName() { return \"FpToBv\"; }\n}\n}\n"
  },
  {
    "path": "lib/Transform/QueryPassManager.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Transform/QueryPassManager.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/JFSTimerMacros.h\"\n#include <atomic>\n#include <mutex>\n#include <vector>\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace transform {\nclass QueryPassManagerImpl : public jfs::support::ICancellable {\nprivate:\n  // This not a std::unique_ptr<QueryPass> because some passes just collect\n  // information so clients will need to hold on to a pointer to those\n  // passes.  This means we can't have unique ownership (otherwise clients\n  // would have to hold on to raw pointers which is dangerous).\n  std::vector<std::shared_ptr<QueryPass>> passes;\n  std::mutex passesMutex;\n  std::atomic<bool> cancelled;\n\npublic:\n  QueryPassManagerImpl() : cancelled(false) {}\n  ~QueryPassManagerImpl() {}\n  void add(std::shared_ptr<QueryPass> pass) {\n    std::lock_guard<std::mutex> lock(passesMutex);\n    passes.push_back(pass);\n  }\n  // The mutex currently exists just to prevent a race\n  // between cancel() and clear().\n  void clear() {\n    std::lock_guard<std::mutex> lock(passesMutex);\n    passes.clear();\n  }\n  void cancel() {\n    std::lock_guard<std::mutex> lock(passesMutex);\n    cancelled = true;\n    for (auto const& pass : passes) {\n      pass->cancel();\n    }\n  }\n  void run(Query &q) {\n    // FIXME: We can't hold passesMutex here otherwise `cancel` will not\n    // cancel until this method finishes.\n    JFSContext &ctx = q.getContext();\n    JFS_AG_COL(pass_times, ctx);\n    IF_VERB(ctx, ctx.getDebugStream() << \"(QueryPassManager starting)\\n\";);\n    for (auto pi = passes.begin(), pe = passes.end(); pi != pe; ++pi) {\n      IF_VERB(ctx,\n              ctx.getDebugStream()\n                  << \"(QueryPassManager \\\"\" << (*pi)->getName() << \"\\\")\\n\";);\n      IF_VERB_GT(ctx, 1,\n                 ctx.getDebugStream()\n                     << \";Before \\\"\" << (*pi)->getName() << \"\\n\"\n                     << q << \"\\n\";);\n      if (cancelled) {\n        IF_VERB(ctx, ctx.getDebugStream() << \"(QueryPassManager cancelled)\\n\";);\n        return;\n      }\n      {\n        JFS_AG_TIMER(pass_timer, (*pi)->getName(), pass_times, ctx);\n        // Now run the pass\n        (*pi)->run(q);\n      }\n\n      IF_VERB_GT(ctx, 1,\n                 ctx.getDebugStream() << \";After \\\"\" << (*pi)->getName() << \"\\n\"\n                                      << q << \"\\n\";);\n    }\n    IF_VERB(ctx, ctx.getDebugStream() << \"(QueryPassManager finished)\\n\";);\n  }\n\n  // FIXME: We should probably make this cancellable.\n  bool convertModel(jfs::core::Model* m) {\n    std::lock_guard<std::mutex> lock(passesMutex);\n    assert(m != nullptr);\n    JFSContext& ctx = m->getContext();\n    JFS_AG_COL(convert_model_pass_times, ctx);\n    IF_VERB(ctx, ctx.getDebugStream()\n                     << \"(QueryPassManager::convertModel starting)\\n\";);\n    // We have to walk through the passes backwards so that we perform model\n    // conversion in the right order.\n    for (auto pi = passes.rbegin(), pe = passes.rend(); pi != pe; ++pi) {\n      IF_VERB(ctx, ctx.getDebugStream() << \"(QueryPassManager::convertModel \\\"\"\n                                        << (*pi)->getName() << \"\\\")\\n\";);\n      IF_VERB_GT(ctx, 1,\n                 ctx.getDebugStream()\n                     << \";Before \\\"\" << (*pi)->getName() << \"\\n\"\n                     << m->getSMTLIBString() << \"\\n\";);\n      // FIXME: In an asserts build we should hold on to a copy of the final\n      // query and original query and check that the models satisfy the\n      // constraints.\n      {\n        JFS_AG_TIMER(convert_modenl_pass_timer, (*pi)->getName(),\n                     convert_model_pass_times, ctx);\n        // Now ask the pass to convert the model.\n        bool success = (*pi)->convertModel(m);\n        if (!success) {\n          ctx.getErrorStream()\n              << \"(QueryPassManager::convertModel conversion failed with pass \"\n              << (*pi)->getName() << \")\\n\";\n          return false;\n        }\n      }\n\n      IF_VERB_GT(ctx, 1,\n                 ctx.getDebugStream() << \";After \\\"\" << (*pi)->getName() << \"\\n\"\n                                      << m->getSMTLIBString() << \"\\n\";);\n    }\n    IF_VERB(ctx, ctx.getDebugStream()\n                     << \"(QueryPassManager::convertModel finished)\\n\";);\n    return true;\n  }\n};\n\nQueryPassManager::QueryPassManager() : impl(new QueryPassManagerImpl()) {}\nQueryPassManager::~QueryPassManager() {}\nvoid QueryPassManager::add(std::shared_ptr<QueryPass> pass) { impl->add(pass); }\nvoid QueryPassManager::run(Query &q) { impl->run(q); }\nvoid QueryPassManager::cancel() { impl->cancel(); }\nvoid QueryPassManager::clear() { impl->clear(); }\nbool QueryPassManager::convertModel(jfs::core::Model* m) {\n  return impl->convertModel(m);\n}\n}\n}\n"
  },
  {
    "path": "lib/Transform/SimpleContradictionsToFalsePass.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Transform/SimpleContradictionsToFalsePass.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include <vector>\n\nusing namespace jfs::core;\n\nnamespace {\n// (a) and (not a) are contradictions\nbool simplifyTopLevelNot(Query& q, std::atomic<bool>* cancelled) {\n  Z3ASTSet seenExpr;\n  seenExpr.reserve(q.constraints.size());\n  const JFSContext &ctx = q.getContext();\n  // First gather all the expressions\n  for (auto ci = q.constraints.cbegin(), ce = q.constraints.cend(); ci != ce;\n       ++ci) {\n    seenExpr.insert(*ci);\n  }\n\n  // Now walk through again seeing if we see (not <expr>) where `<expr>` is\n  // something we've already seen.\n  Z3ASTSet contradictingConstraints;\n  for (auto ci = q.constraints.cbegin(), ce = q.constraints.cend(); ci != ce;\n       ++ci) {\n    Z3ASTHandle e = *ci;\n\n    if (*cancelled) {\n      return false;\n    }\n\n    if (!e.isAppOf(Z3_OP_NOT))\n      continue;\n\n    // Not expr\n    assert(e.isApp());\n    Z3AppHandle app = e.asApp();\n    assert(app.getNumKids() == 1 && \"wrong number of child args\");\n\n    Z3ASTHandle notExprChild = app.getKid(0);\n    if (seenExpr.count(notExprChild) == 0)\n      continue;\n\n    // Found a contradiction. The constraints contain\n    // (e) and (not e).\n    contradictingConstraints.insert(e);\n    contradictingConstraints.insert(notExprChild);\n  }\n\n  if (contradictingConstraints.size() == 0)\n    return false;\n\n  // There were contradictions\n  std::vector<Z3ASTHandle> newConstraints;\n  assert(q.constraints.size() >= newConstraints.size() &&\n         \"newConstraints was too large\");\n  newConstraints.reserve(q.constraints.size() - newConstraints.size());\n  Z3_context z3Ctx = ctx.getZ3Ctx();\n  Z3ASTHandle falseExpr = Z3ASTHandle(::Z3_mk_false(z3Ctx), z3Ctx);\n  for (auto ci = q.constraints.cbegin(), ce = q.constraints.cend(); ci != ce;\n       ++ci) {\n\n    if (*cancelled) {\n      return false;\n    }\n\n    if (contradictingConstraints.count(*ci) > 0) {\n      // Replace contradicting constraint with false\n      newConstraints.push_back(falseExpr);\n      continue;\n    }\n    // Not detected as a contradiction. Keep this constraint\n    newConstraints.push_back(*ci);\n  }\n  q.constraints = std::move(newConstraints);\n  return true;\n}\n}\n\nnamespace jfs {\nnamespace transform {\n\nbool SimpleContradictionsToFalsePass::run(Query &q) {\n  JFSContext& ctx = q.getContext();\n  bool changed = false;\n  // TODO: Look for other patterns that are contradictions\n  changed |= simplifyTopLevelNot(q, &cancelled);\n  // TODO: Look for equality contradictions\n  // TODO: Look for range contradictions. e.g. x> 5 and x < 5\n  if (cancelled) {\n    IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\");\n  }\n  return changed;\n}\n\nllvm::StringRef SimpleContradictionsToFalsePass::getName() {\n  return \"SimpleContradictionsToFalse\";\n}\n\nbool SimpleContradictionsToFalsePass::convertModel(jfs::core::Model* m) {\n  // This pass preserves equivalence so the model does not need to be\n  // converted.\n  return true;\n}\n}\n}\n"
  },
  {
    "path": "lib/Transform/SimplificationPass.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Transform/SimplificationPass.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include <list>\n#include <vector>\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace transform {\n\nbool SimplificationPass::run(Query &q) {\n  JFSContext& ctx = q.getContext();\n  std::vector<Z3ASTHandle> newConstraints;\n  z3Ctx = ctx.getZ3Ctx();\n\n  Z3TacticHandle simplifyTactic(::Z3_mk_tactic(z3Ctx, \"simplify\"), z3Ctx);\n\n  Z3GoalHandle initialGoal(::Z3_mk_goal(z3Ctx, /*models=*/false,\n                                        /*unsat_cores=*/false,\n                                        /*proofs=*/false),\n                           z3Ctx);\n\n  for (auto ci = q.constraints.cbegin(), ce = q.constraints.cend(); ci != ce;\n       ++ci) {\n    initialGoal.addFormula(*ci);\n  }\n\n#define CHECK_CANCELED()                                                       \\\n  if (cancelled) {                                                             \\\n    IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\"); \\\n    return false;                                                              \\\n  }\n\n  CHECK_CANCELED();\n\n  // TODO: Investigate the different simplifier parameters and see what\n  // is relevant in our use case.\n  Z3ParamsHandle params(::Z3_mk_params(z3Ctx), z3Ctx);\n  // Enable `bv_ite2id`.\n  Z3_symbol bv_ite2id = ::Z3_mk_string_symbol(z3Ctx, \"bv_ite2id\");\n  Z3_params_set_bool(z3Ctx, params, bv_ite2id, true);\n\n  // Apply the tactic and store it for use in convertModel()\n  result = simplifyTactic.applyWithParams(initialGoal, params);\n\n  CHECK_CANCELED();\n\n  // Collect all the resulting formulas\n  result.collectAllFormulas(newConstraints);\n\n  if (Query::areSame(q.constraints, newConstraints, /*ignoreOrder=*/true))\n    return false;\n\n  // Something changed\n  q.constraints = std::move(newConstraints);\n  return true;\n}\n\nllvm::StringRef SimplificationPass::getName() { return \"Simplification\"; }\n}\n}\n"
  },
  {
    "path": "lib/Transform/StandardPasses.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Transform/StandardPasses.h\"\n#include \"jfs/Transform/Passes.h\"\n\nnamespace jfs {\nnamespace transform {\nvoid AddStandardPasses(QueryPassManager &pm) {\n\n  // Seperate out into as many constraints as possible.\n  pm.add(std::make_shared<AndHoistingPass>());\n\n  // TODO: This should probably be iterated to a fixed point. This just became\n  // much harder because now we have to support model generation. The current\n  // implementation can only have convertModel() called on a pass once (i.e.\n  // we can't reuse a pass because it stores the model conversion information\n  // for that step).\n\n  // FIXME: BvBoundPropagationPass shouldn't be here. There seems to be some\n  // issues when combining simplifier and propagate-bv-bounds\n  // https://github.com/Z3Prover/z3/issues/1054\n  // FIXME: BvBoundPropagationPass is broken. On some benchmarks it gets stuck\n  // see https://github.com/Z3Prover/z3/issues/1078\n  // Simplify bounds\n  //pm.add(std::make_shared<BvBoundPropagationPass>());\n  // Simplify constraints.\n  pm.add(std::make_shared<SimplificationPass>());\n  // Hoist any ands introduced\n  pm.add(std::make_shared<AndHoistingPass>());\n  // Simplify bounds\n  // FIXME: BvBoundPropagationPass is broken. On some benchmarks it gets stuck\n  // see https://github.com/Z3Prover/z3/issues/1078\n  //pm.add(std::make_shared<BvBoundPropagationPass>());\n  // Simplify again\n  pm.add(std::make_shared<SimplificationPass>());\n  // Propagate constants\n  pm.add(std::make_shared<ConstantPropagationPass>());\n  // Hoist any ands introduced\n  pm.add(std::make_shared<AndHoistingPass>());\n  // Simplify again\n  pm.add(std::make_shared<SimplificationPass>());\n  // Propagate constants\n  pm.add(std::make_shared<ConstantPropagationPass>());\n  // Simplify again\n  pm.add(std::make_shared<SimplificationPass>());\n  // Hoist any ands introduced\n  pm.add(std::make_shared<AndHoistingPass>());\n\n  // Remove duplicate constraints\n  pm.add(std::make_shared<DuplicateConstraintEliminationPass>());\n\n  // FIXME: The `ConstantPropagationPass` actually removes\n  // `true` constraints too. Is `TrueConstraintEliminationPass` now redundant?\n  //\n  // Remove any \"true\" constraints that were in the original constraints\n  // or come from simplification.\n  pm.add(std::make_shared<TrueConstraintEliminationPass>());\n\n  // TODO: We should do expression canonicalization so we can do a better job\n  // of spotting patterns.\n\n  // Try to replace some simple contradictions that we know\n  // how to recognise with false.\n  pm.add(std::make_shared<SimpleContradictionsToFalsePass>());\n\n  // Remove any duplicate \"false\" expressions that were introduced\n  pm.add(std::make_shared<DuplicateConstraintEliminationPass>());\n}\n}\n}\n"
  },
  {
    "path": "lib/Transform/TrueConstraintEliminationPass.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Transform/TrueConstraintEliminationPass.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include <vector>\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace transform {\n\nbool TrueConstraintEliminationPass::run(Query &q) {\n  JFSContext& ctx = q.getContext();\n  bool changed = false;\n  std::vector<Z3ASTHandle> newConstraints;\n  for (auto ci = q.constraints.cbegin(), ce = q.constraints.cend(); ci != ce;\n       ++ci) {\n    Z3ASTHandle e = *ci;\n\n    if (cancelled) {\n      IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\");\n      return false;\n    }\n\n    if (e.isTrue()) {\n      // Don't add \"true\" to constraint set.\n      changed = true;\n      continue;\n    }\n    newConstraints.push_back(e);\n  }\n\n  if (!changed)\n    return false;\n\n  q.constraints = std::move(newConstraints);\n  return true;\n};\n\nllvm::StringRef TrueConstraintEliminationPass::getName() {\n  return \"TrueConstraintElimination\";\n}\n\nbool TrueConstraintEliminationPass::convertModel(jfs::core::Model* m) {\n  // This pass preserves equivalence so the model does not need to be\n  // converted.\n  return true;\n}\n}\n}\n"
  },
  {
    "path": "lib/Transform/Z3QueryPass.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Transform/Z3QueryPass.h\"\n\nusing namespace jfs::core;\n\nnamespace jfs {\nnamespace transform {\n\nvoid Z3QueryPass::cancel() {\n  cancelled = true;\n  // Interupt Z3 just in case we are in the middle\n  // of an application.\n  // FIXME: This is racey\n  if (z3Ctx) {\n    ::Z3_interrupt(z3Ctx);\n  }\n}\n\nbool Z3QueryPass::convertModel(jfs::core::Model* m) {\n  // FIXME: We should prevent interruption with a lock.\n\n  // We assume that the sub class stored the Z3ApplyResultHandle\n  // from applying a tactic in `result`.\n  assert(!result.isNull());\n\n  // Is this the right approach? Z3's API applies model conversion for\n  // model intended for each sub-goal. We don't solve that way though so\n  // we have only one model. Just try to iteratively apply model conversion\n  // of the same model for each sub-goal.\n  Z3ModelHandle mh = m->getRepr();\n  for (unsigned goalIndex = 0; goalIndex < result.getNumGoals(); ++goalIndex) {\n    assert(!mh.isNull());\n    mh = result.convertModelForGoal(goalIndex, mh);\n  }\n  assert(!mh.isNull());\n  // AFAICT Z3's implementation copies the provided model rather than modifying\n  // in-place. This means we have to modify the `jfs::core::Model` to use the\n  // copy.\n  bool success = m->replaceRepr(mh);\n  if (!success) {\n    m->getContext().raiseFatalError(\"Failed to replace model representation\");\n  }\n  return success;\n}\n}\n}\n"
  },
  {
    "path": "lib/Z3Backend/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\njfs_add_component(JFSZ3Backend\n  Z3Solver.cpp\n)\ntarget_link_libraries(JFSZ3Backend PUBLIC JFSTransform JFSCore)\n"
  },
  {
    "path": "lib/Z3Backend/Z3Solver.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Z3Backend/Z3Solver.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/Model.h\"\n\nusing namespace jfs::core;\n\nnamespace jfs {\n  namespace z3Backend {\n\n  Z3Solver::Z3Solver(std::unique_ptr<SolverOptions> options, JFSContext& ctx)\n      : jfs::core::Solver(std::move(options), ctx), z3Ctx(ctx.getZ3Ctx()),\n        cancelled(false) {}\n  Z3Solver::~Z3Solver() {}\n\n  llvm::StringRef Z3Solver::getName() const { return \"Z3Solver\"; }\n\n  class Z3Model : public jfs::core::Model {\n  public:\n    Z3Model(JFSContext& ctx, Z3ModelHandle m) : Model(ctx) { z3Model = m; }\n    ~Z3Model() {}\n  };\n\n  class Z3SolverResponse : public SolverResponse {\n    private:\n      std::unique_ptr<Model> model;\n\n    public:\n    Z3SolverResponse(SolverSatisfiability sat) : SolverResponse(sat), model(nullptr) {}\n    ~Z3SolverResponse() {}\n    Model* getModel() override { return model.get(); }\n    friend class Z3Solver;\n    // To be used by Z3Solver only\n    void setModel(JFSContext& ctx, Z3ModelHandle m) {\n      model.reset(new Z3Model(ctx, m));\n    }\n  };\n\n  void Z3Solver::cancel() {\n    cancelled = true;\n    if (z3Ctx) {\n      ::Z3_interrupt(z3Ctx);\n    }\n  }\n\n  std::unique_ptr<SolverResponse> Z3Solver::solve(const Query& q,\n                                                  bool getModel) {\n    assert(&ctx == &(q.getContext()));\n    assert(z3Ctx == q.getContext().getZ3Ctx());\n    // Use default solver behaviour\n    Z3SolverHandle solver = Z3SolverHandle(::Z3_mk_solver(z3Ctx), z3Ctx);\n\n    for (auto ci = q.constraints.cbegin(), ce = q.constraints.cend(); ci != ce;\n         ++ci) {\n      ::Z3_solver_assert(z3Ctx, solver, *ci);\n    }\n    Z3_lbool satisfiable = Z3_L_UNDEF;\n    if (!cancelled) {\n      satisfiable = Z3_solver_check(z3Ctx, solver);\n    }\n\n    SolverResponse::SolverSatisfiability sat = SolverResponse::UNKNOWN;\n    switch (satisfiable) {\n      case Z3_L_TRUE:\n        sat = SolverResponse::SAT;\n        break;\n      case Z3_L_FALSE:\n        sat = SolverResponse::UNSAT;\n        break;\n      default:\n        sat = SolverResponse::UNKNOWN;\n    }\n\n    if (cancelled) {\n      IF_VERB(ctx, ctx.getDebugStream() << \"(\" << getName() << \" cancelled)\\n\");\n    }\n\n    std::unique_ptr<SolverResponse> resp(new Z3SolverResponse(sat));\n    if (getModel && sat == SolverResponse::SAT) {\n      // Add the model\n      Z3ModelHandle model = Z3ModelHandle(::Z3_solver_get_model(z3Ctx, solver), z3Ctx);\n      static_cast<Z3SolverResponse*>(resp.get())->setModel(ctx, model);\n    }\n    return resp;\n  }\n}\n}\n"
  },
  {
    "path": "runtime/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n\n###############################################################################\n# Runtime copy of Clang++ and dependent libraries\n###############################################################################\nfile(MAKE_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}/bin\")\n# `clang++` might be a symlink so resolve to real path\nget_filename_component(LLVM_CLANG_CXX_TOOL_REAL_PATH\n  \"${LLVM_CLANG_CXX_TOOL}\" REALPATH\n)\nget_filename_component(LLVM_CLANG_CXX_TOOL_NAME\n  \"${LLVM_CLANG_CXX_TOOL}\"\n  NAME\n)\n# FIXME: Creating symlinks won't work on Windows\nset(JFS_LLVM_CLANG_CXX_TOOL\n  \"${CMAKE_CURRENT_BINARY_DIR}/bin/${LLVM_CLANG_CXX_TOOL_NAME}\"\n)\nexecute_process(COMMAND\n  \"${CMAKE_COMMAND}\" -E create_symlink \"${LLVM_CLANG_CXX_TOOL_REAL_PATH}\"\n  \"${JFS_LLVM_CLANG_CXX_TOOL}\"\n)\n# Handle Clang runtime\nfile(MAKE_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}/lib\")\nget_filename_component(LLVM_BIN_DIR\n  \"${LLVM_CLANG_CXX_TOOL_REAL_PATH}\"\n  DIRECTORY\n)\nget_filename_component(LLVM_ROOT_DIR\n  \"${LLVM_BIN_DIR}\"\n  DIRECTORY\n)\nset(CLANG_RUNTIME_DIR \"${LLVM_ROOT_DIR}/lib/clang\")\nif (NOT (EXISTS \"${CLANG_RUNTIME_DIR}\"))\n  message(FATAL_ERROR\n    \"Cannot find Clang runtime directory \\\"${CLANG_RUNTIME_DIR}\\\"\"\n  )\nendif()\n# FIXME: Creating symlinks won't work on Windows\nexecute_process(COMMAND\n  \"${CMAKE_COMMAND}\" -E create_symlink \"${CLANG_RUNTIME_DIR}\"\n  \"${CMAKE_CURRENT_BINARY_DIR}/lib/clang\"\n)\n# Make availble to main `CMakeLists.txt` so we can use this elsewhere.\nset(JFS_LLVM_CLANG_CXX_TOOL \"${JFS_LLVM_CLANG_CXX_TOOL}\" PARENT_SCOPE)\n\n###############################################################################\n# Build LibFuzzer\n###############################################################################\n# We build LibFuzzer as an external project using Clang. We\n# build it in different configurations.\ninclude(ExternalProject)\ninclude(${CMAKE_SOURCE_DIR}/cmake/jfs_external_project_utils.cmake)\n\n# TODO: Add more\nset(LibFuzzerBuildTypes RelWithDebInfo)\n\nforeach (buildType ${LibFuzzerBuildTypes})\n  set(buildDir \"${CMAKE_CURRENT_BINARY_DIR}/LibFuzzer_${buildType}\")\n  jfs_get_external_project_build_command(JFS_EXTERNAL_PROJECT_BUILD_COMMAND ${buildDir})\n  ExternalProject_Add(BuildLibFuzzerRuntime_${buildType}\n    SOURCE_DIR \"${CMAKE_CURRENT_SOURCE_DIR}/LibFuzzer\"\n    # FIXME: We should allow other generators\n    CMAKE_GENERATOR \"Unix Makefiles\"\n    CMAKE_ARGS\n      \"-DCMAKE_CXX_COMPILER=${LLVM_CLANG_CXX_TOOL}\"\n      \"-DCMAKE_BUILD_TYPE=${buildType}\"\n    BINARY_DIR \"${buildDir}\"\n    BUILD_ALWAYS 1\n    ${JFS_EXTERNAL_PROJECT_BUILD_COMMAND}\n    # Don't run install command\n    INSTALL_COMMAND \"\"\n    # FIXME: Guard these based on CMake version\n    USES_TERMINAL_BUILD 1\n    USES_TERMINAL_CONFIGURE 1\n  )\nendforeach()\n\n###############################################################################\n# Build LibPureRandomFuzzer\n###############################################################################\n# We build LibPureRandomFuzzer as an external project using Clang. We\n# build it in different configurations.\ninclude(ExternalProject)\ninclude(${CMAKE_SOURCE_DIR}/cmake/jfs_external_project_utils.cmake)\n\n# TODO: Add more\nset(LibPureRandomFuzzerBuildTypes RelWithDebInfo)\n\nforeach (buildType ${LibPureRandomFuzzerBuildTypes})\n  set(buildDir \"${CMAKE_CURRENT_BINARY_DIR}/LibPureRandomFuzzer_${buildType}\")\n  jfs_get_external_project_build_command(JFS_EXTERNAL_PROJECT_BUILD_COMMAND ${buildDir})\n  ExternalProject_Add(BuildLibPureRandomFuzzerRuntime_${buildType}\n    SOURCE_DIR \"${CMAKE_CURRENT_SOURCE_DIR}/LibPureRandomFuzzer\"\n    # FIXME: We should allow other generators\n    CMAKE_GENERATOR \"Unix Makefiles\"\n    CMAKE_ARGS\n      \"-DCMAKE_CXX_COMPILER=${LLVM_CLANG_CXX_TOOL}\"\n      \"-DCMAKE_BUILD_TYPE=${buildType}\"\n    BINARY_DIR \"${buildDir}\"\n    BUILD_ALWAYS 1\n    ${JFS_EXTERNAL_PROJECT_BUILD_COMMAND}\n    # Don't run install command\n    INSTALL_COMMAND \"\"\n    # FIXME: Guard these based on CMake version\n    USES_TERMINAL_BUILD 1\n    USES_TERMINAL_CONFIGURE 1\n  )\nendforeach()\n\n###############################################################################\n# SMTLIB runtime\n###############################################################################\nadd_subdirectory(SMTLIB)\n"
  },
  {
    "path": "runtime/LibFuzzer/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\nproject(LibFuzzer CXX C)\n\n###############################################################################\n# Minimum CMake version and policies\n###############################################################################\ncmake_minimum_required(VERSION 2.8.12)\n\n###############################################################################\n# Language version\n###############################################################################\ninclude(CheckCXXCompilerFlag)\nCHECK_CXX_COMPILER_FLAG(\"-std=c++11\" HAS_CXX_11_FLAG)\n\n# We should use C++11\nif (HAS_CXX_11_FLAG)\n  string(APPEND CMAKE_CXX_FLAGS \" -std=c++11\")\nelse()\n  message(FATAL_ERROR \"Compiler does not support C++11\")\nendif()\n\n###############################################################################\n# No omit frame pointer flag\n###############################################################################\n# LibFuzzer's build instructions pass this flag. I guess it's needed to get\n# better backtraces on a crash\nCHECK_CXX_COMPILER_FLAG(\"-fno-omit-frame-pointer\" HAS_NO_OMIT_FRAME_POINTER_FLAG)\nif (HAS_NO_OMIT_FRAME_POINTER_FLAG)\n  string(APPEND CMAKE_CXX_FLAGS \" -fno-omit-frame-pointer\")\nelse()\n  message(FATAL_ERROR \"Compiler does not support -fno-omit-frame-pointer\")\nendif()\n\n###############################################################################\n# Compiler info\n###############################################################################\nmessage(STATUS \"Using CXX compiler : ${CMAKE_CXX_COMPILER}\")\nmessage(STATUS \"Global CXX flags : \\\"${CMAKE_CXX_FLAGS}\\\"\")\n\n###############################################################################\n# Sanitizer support\n###############################################################################\nOPTION(USE_UBSAN \"Build with UBSan\" OFF)\nif (USE_UBSAN)\n  message(STATUS \"Building with UBSan\")\n  string(APPEND CMAKE_CXX_FLAGS \" -fsanitize=undefined -fno-omit-frame-pointer\")\nelse()\n  message(STATUS \"Not building with UBSan\")\nendif()\n\nOPTION(USE_ASAN \"Build with ASan\" OFF)\nif (USE_ASAN)\n  message(STATUS \"Building with ASan\")\n  string(APPEND CMAKE_CXX_FLAGS \" -fsanitize=address -fno-omit-frame-pointer\")\nelse()\n  message(STATUS \"Not building with ASan\")\nendif()\n\n###############################################################################\n# LibFuzzer\n###############################################################################\nset(LLVM_USE_SANITIZE_COVERAGE ON)\nset(LLVM_INCLUDE_TESTS OFF)\nadd_subdirectory(Fuzzer)\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/CMakeLists.txt",
    "content": "add_library(LLVMFuzzer STATIC\n  FuzzerClangCounters.cpp\n  FuzzerCrossOver.cpp\n  FuzzerDriver.cpp\n  FuzzerExtFunctionsDlsym.cpp\n  FuzzerExtFunctionsDlsymWin.cpp\n  FuzzerExtFunctionsWeakAlias.cpp\n  FuzzerExtFunctionsWeak.cpp\n  FuzzerExtraCounters.cpp\n  FuzzerIO.cpp\n  FuzzerIOPosix.cpp\n  FuzzerIOWindows.cpp\n  FuzzerLoop.cpp\n  FuzzerMain.cpp\n  FuzzerMerge.cpp\n  FuzzerMutate.cpp\n  FuzzerSHA1.cpp\n  FuzzerShmemFuchsia.cpp\n  FuzzerShmemPosix.cpp\n  FuzzerShmemWindows.cpp\n  FuzzerTracePC.cpp\n  FuzzerUtil.cpp\n  FuzzerUtilDarwin.cpp\n  FuzzerUtilFuchsia.cpp\n  FuzzerUtilLinux.cpp\n  FuzzerUtilPosix.cpp\n  FuzzerUtilWindows.cpp\n)\n\nCHECK_CXX_SOURCE_COMPILES(\"\n  static thread_local int blah;\n  int main() {\n  return 0;\n  }\n  \" HAS_THREAD_LOCAL)\n\nif(NOT HAS_THREAD_LOCAL)\n  target_compile_definitions(LLVMFuzzer PRIVATE -Dthread_local=__thread)\nendif()\n\ntarget_link_libraries(LLVMFuzzer PRIVATE ${PTHREAD_LIB})\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerClangCounters.cpp",
    "content": "//===- FuzzerExtraCounters.cpp - Extra coverage counters ------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Coverage counters from Clang's SourceBasedCodeCoverage.\n//===----------------------------------------------------------------------===//\n\n// Support for SourceBasedCodeCoverage is experimental:\n// * Works only for the main binary, not DSOs yet.\n// * Works only on Linux.\n// * Does not implement print_pcs/print_coverage yet.\n// * Is not fully evaluated for performance and sensitivity.\n//   We expect large performance drop due to 64-bit counters,\n//   and *maybe* better sensitivity due to more fine-grained counters.\n//   Preliminary comparison on a single benchmark (RE2) shows\n//   a bit worse sensitivity though.\n\n#include \"FuzzerDefs.h\"\n\n#if LIBFUZZER_LINUX\n__attribute__((weak)) extern uint64_t __start___llvm_prf_cnts;\n__attribute__((weak)) extern uint64_t __stop___llvm_prf_cnts;\nnamespace fuzzer {\nuint64_t *ClangCountersBegin() { return &__start___llvm_prf_cnts; }\nuint64_t *ClangCountersEnd() { return &__stop___llvm_prf_cnts; }\n}  // namespace fuzzer\n#else\n// TODO: Implement on Mac (if the data shows it's worth it).\n//__attribute__((visibility(\"hidden\")))\n//extern uint64_t CountersStart __asm(\"section$start$__DATA$__llvm_prf_cnts\");\n//__attribute__((visibility(\"hidden\")))\n//extern uint64_t CountersEnd __asm(\"section$end$__DATA$__llvm_prf_cnts\");\nnamespace fuzzer {\nuint64_t *ClangCountersBegin() { return nullptr; }\nuint64_t *ClangCountersEnd() { return  nullptr; }\n}  // namespace fuzzer\n#endif\n\nnamespace fuzzer {\nATTRIBUTE_NO_SANITIZE_ALL\nvoid ClearClangCounters() {  // hand-written memset, don't asan-ify.\n  for (auto P = ClangCountersBegin(); P < ClangCountersEnd(); P++)\n    *P = 0;\n}\n}\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerCommand.h",
    "content": "//===- FuzzerCommand.h - Interface representing a process -------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// FuzzerCommand represents a command to run in a subprocess.  It allows callers\n// to manage command line arguments and output and error streams.\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_COMMAND_H\n#define LLVM_FUZZER_COMMAND_H\n\n#include \"FuzzerDefs.h\"\n#include \"FuzzerIO.h\"\n\n#include <algorithm>\n#include <sstream>\n#include <string>\n#include <vector>\n\nnamespace fuzzer {\n\nclass Command final {\npublic:\n  // This command line flag is used to indicate that the remaining command line\n  // is immutable, meaning this flag effectively marks the end of the mutable\n  // argument list.\n  static inline const char *ignoreRemainingArgs() {\n    static const char *kIgnoreRemaining = \"-ignore_remaining_args=1\";\n    return kIgnoreRemaining;\n  }\n\n  Command() : CombinedOutAndErr(false) {}\n\n  explicit Command(const Vector<std::string> &ArgsToAdd)\n      : Args(ArgsToAdd), CombinedOutAndErr(false) {}\n\n  explicit Command(const Command &Other)\n      : Args(Other.Args), CombinedOutAndErr(Other.CombinedOutAndErr),\n        OutputFile(Other.OutputFile) {}\n\n  Command &operator=(const Command &Other) {\n    Args = Other.Args;\n    CombinedOutAndErr = Other.CombinedOutAndErr;\n    OutputFile = Other.OutputFile;\n    return *this;\n  }\n\n  ~Command() {}\n\n  // Returns true if the given Arg is present in Args.  Only checks up to\n  // \"-ignore_remaining_args=1\".\n  bool hasArgument(const std::string &Arg) const {\n    auto i = endMutableArgs();\n    return std::find(Args.begin(), i, Arg) != i;\n  }\n\n  // Gets all of the current command line arguments, **including** those after\n  // \"-ignore-remaining-args=1\".\n  const Vector<std::string> &getArguments() const { return Args; }\n\n  // Adds the given argument before \"-ignore_remaining_args=1\", or at the end\n  // if that flag isn't present.\n  void addArgument(const std::string &Arg) {\n    Args.insert(endMutableArgs(), Arg);\n  }\n\n  // Adds all given arguments before \"-ignore_remaining_args=1\", or at the end\n  // if that flag isn't present.\n  void addArguments(const Vector<std::string> &ArgsToAdd) {\n    Args.insert(endMutableArgs(), ArgsToAdd.begin(), ArgsToAdd.end());\n  }\n\n  // Removes the given argument from the command argument list.  Ignores any\n  // occurrences after \"-ignore_remaining_args=1\", if present.\n  void removeArgument(const std::string &Arg) {\n    auto i = endMutableArgs();\n    Args.erase(std::remove(Args.begin(), i, Arg), i);\n  }\n\n  // Like hasArgument, but checks for \"-[Flag]=...\".\n  bool hasFlag(const std::string &Flag) {\n    std::string Arg(\"-\" + Flag + \"=\");\n    auto IsMatch = [&](const std::string &Other) {\n      return Arg.compare(0, std::string::npos, Other, 0, Arg.length()) == 0;\n    };\n    return std::any_of(Args.begin(), endMutableArgs(), IsMatch);\n  }\n\n  // Returns the value of the first instance of a given flag, or an empty string\n  // if the flag isn't present.  Ignores any occurrences after\n  // \"-ignore_remaining_args=1\", if present.\n  std::string getFlagValue(const std::string &Flag) {\n    std::string Arg(\"-\" + Flag + \"=\");\n    auto IsMatch = [&](const std::string &Other) {\n      return Arg.compare(0, std::string::npos, Other, 0, Arg.length()) == 0;\n    };\n    auto i = endMutableArgs();\n    auto j = std::find_if(Args.begin(), i, IsMatch);\n    std::string result;\n    if (j != i) {\n      result = j->substr(Arg.length());\n    }\n    return result;\n  }\n\n  // Like AddArgument, but adds \"-[Flag]=[Value]\".\n  void addFlag(const std::string &Flag, const std::string &Value) {\n    addArgument(\"-\" + Flag + \"=\" + Value);\n  }\n\n  // Like RemoveArgument, but removes \"-[Flag]=...\".\n  void removeFlag(const std::string &Flag) {\n    std::string Arg(\"-\" + Flag + \"=\");\n    auto IsMatch = [&](const std::string &Other) {\n      return Arg.compare(0, std::string::npos, Other, 0, Arg.length()) == 0;\n    };\n    auto i = endMutableArgs();\n    Args.erase(std::remove_if(Args.begin(), i, IsMatch), i);\n  }\n\n  // Returns whether the command's stdout is being written to an output file.\n  bool hasOutputFile() const { return !OutputFile.empty(); }\n\n  // Returns the currently set output file.\n  const std::string &getOutputFile() const { return OutputFile; }\n\n  // Configures the command to redirect its output to the name file.\n  void setOutputFile(const std::string &FileName) { OutputFile = FileName; }\n\n  // Returns whether the command's stderr is redirected to stdout.\n  bool isOutAndErrCombined() const { return CombinedOutAndErr; }\n\n  // Sets whether to redirect the command's stderr to its stdout.\n  void combineOutAndErr(bool combine = true) { CombinedOutAndErr = combine; }\n\n  // Returns a string representation of the command.  On many systems this will\n  // be the equivalent command line.\n  std::string toString() const {\n    std::stringstream SS;\n    for (auto arg : getArguments())\n      SS << arg << \" \";\n    if (hasOutputFile())\n      SS << \">\" << getOutputFile() << \" \";\n    if (isOutAndErrCombined())\n      SS << \"2>&1 \";\n    std::string result = SS.str();\n    if (!result.empty())\n      result = result.substr(0, result.length() - 1);\n    return result;\n  }\n\nprivate:\n  Command(Command &&Other) = delete;\n  Command &operator=(Command &&Other) = delete;\n\n  Vector<std::string>::iterator endMutableArgs() {\n    return std::find(Args.begin(), Args.end(), ignoreRemainingArgs());\n  }\n\n  Vector<std::string>::const_iterator endMutableArgs() const {\n    return std::find(Args.begin(), Args.end(), ignoreRemainingArgs());\n  }\n\n  // The command arguments.  Args[0] is the command name.\n  Vector<std::string> Args;\n\n  // True indicates stderr is redirected to stdout.\n  bool CombinedOutAndErr;\n\n  // If not empty, stdout is redirected to the named file.\n  std::string OutputFile;\n};\n\n} // namespace fuzzer\n\n#endif // LLVM_FUZZER_COMMAND_H\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerCorpus.h",
    "content": "//===- FuzzerCorpus.h - Internal header for the Fuzzer ----------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// fuzzer::InputCorpus\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_CORPUS\n#define LLVM_FUZZER_CORPUS\n\n#include \"FuzzerDefs.h\"\n#include \"FuzzerIO.h\"\n#include \"FuzzerRandom.h\"\n#include \"FuzzerSHA1.h\"\n#include \"FuzzerTracePC.h\"\n#include <algorithm>\n#include <numeric>\n#include <random>\n#include <unordered_set>\n\nnamespace fuzzer {\n\nstruct InputInfo {\n  Unit U;  // The actual input data.\n  uint8_t Sha1[kSHA1NumBytes];  // Checksum.\n  // Number of features that this input has and no smaller input has.\n  size_t NumFeatures = 0;\n  size_t Tmp = 0; // Used by ValidateFeatureSet.\n  // Stats.\n  size_t NumExecutedMutations = 0;\n  size_t NumSuccessfullMutations = 0;\n  bool MayDeleteFile = false;\n  bool Reduced = false;\n  Vector<uint32_t> UniqFeatureSet;\n  float FeatureFrequencyScore = 1.0;\n};\n\nclass InputCorpus {\n  static const size_t kFeatureSetSize = 1 << 21;\n public:\n  InputCorpus(const std::string &OutputCorpus) : OutputCorpus(OutputCorpus) {\n    memset(InputSizesPerFeature, 0, sizeof(InputSizesPerFeature));\n    memset(SmallestElementPerFeature, 0, sizeof(SmallestElementPerFeature));\n    memset(FeatureFrequency, 0, sizeof(FeatureFrequency));\n  }\n  ~InputCorpus() {\n    for (auto II : Inputs)\n      delete II;\n  }\n  size_t size() const { return Inputs.size(); }\n  size_t SizeInBytes() const {\n    size_t Res = 0;\n    for (auto II : Inputs)\n      Res += II->U.size();\n    return Res;\n  }\n  size_t NumActiveUnits() const {\n    size_t Res = 0;\n    for (auto II : Inputs)\n      Res += !II->U.empty();\n    return Res;\n  }\n  size_t MaxInputSize() const {\n    size_t Res = 0;\n    for (auto II : Inputs)\n        Res = std::max(Res, II->U.size());\n    return Res;\n  }\n  bool empty() const { return Inputs.empty(); }\n  const Unit &operator[] (size_t Idx) const { return Inputs[Idx]->U; }\n  void AddToCorpus(const Unit &U, size_t NumFeatures, bool MayDeleteFile,\n                   const Vector<uint32_t> &FeatureSet) {\n    assert(!U.empty());\n    if (FeatureDebug)\n      Printf(\"ADD_TO_CORPUS %zd NF %zd\\n\", Inputs.size(), NumFeatures);\n    Inputs.push_back(new InputInfo());\n    InputInfo &II = *Inputs.back();\n    II.U = U;\n    II.NumFeatures = NumFeatures;\n    II.MayDeleteFile = MayDeleteFile;\n    II.UniqFeatureSet = FeatureSet;\n    std::sort(II.UniqFeatureSet.begin(), II.UniqFeatureSet.end());\n    ComputeSHA1(U.data(), U.size(), II.Sha1);\n    Hashes.insert(Sha1ToString(II.Sha1));\n    UpdateCorpusDistribution();\n    PrintCorpus();\n    // ValidateFeatureSet();\n  }\n\n  // Debug-only\n  void PrintUnit(const Unit &U) {\n    if (!FeatureDebug) return;\n    for (uint8_t C : U) {\n      if (C != 'F' && C != 'U' && C != 'Z')\n        C = '.';\n      Printf(\"%c\", C);\n    }\n  }\n\n  // Debug-only\n  void PrintFeatureSet(const Vector<uint32_t> &FeatureSet) {\n    if (!FeatureDebug) return;\n    Printf(\"{\");\n    for (uint32_t Feature: FeatureSet)\n      Printf(\"%u,\", Feature);\n    Printf(\"}\");\n  }\n\n  // Debug-only\n  void PrintCorpus() {\n    if (!FeatureDebug) return;\n    Printf(\"======= CORPUS:\\n\");\n    int i = 0;\n    for (auto II : Inputs) {\n      if (std::find(II->U.begin(), II->U.end(), 'F') != II->U.end()) {\n        Printf(\"[%2d] \", i);\n        Printf(\"%s sz=%zd \", Sha1ToString(II->Sha1).c_str(), II->U.size());\n        PrintUnit(II->U);\n        Printf(\" \");\n        PrintFeatureSet(II->UniqFeatureSet);\n        Printf(\"\\n\");\n      }\n      i++;\n    }\n  }\n\n  void Replace(InputInfo *II, const Unit &U) {\n    assert(II->U.size() > U.size());\n    Hashes.erase(Sha1ToString(II->Sha1));\n    DeleteFile(*II);\n    ComputeSHA1(U.data(), U.size(), II->Sha1);\n    Hashes.insert(Sha1ToString(II->Sha1));\n    II->U = U;\n    II->Reduced = true;\n    UpdateCorpusDistribution();\n  }\n\n  bool HasUnit(const Unit &U) { return Hashes.count(Hash(U)); }\n  bool HasUnit(const std::string &H) { return Hashes.count(H); }\n  InputInfo &ChooseUnitToMutate(Random &Rand) {\n    InputInfo &II = *Inputs[ChooseUnitIdxToMutate(Rand)];\n    assert(!II.U.empty());\n    return II;\n  };\n\n  // Returns an index of random unit from the corpus to mutate.\n  size_t ChooseUnitIdxToMutate(Random &Rand) {\n    size_t Idx = static_cast<size_t>(CorpusDistribution(Rand));\n    assert(Idx < Inputs.size());\n    return Idx;\n  }\n\n  void PrintStats() {\n    for (size_t i = 0; i < Inputs.size(); i++) {\n      const auto &II = *Inputs[i];\n      Printf(\"  [%zd %s]\\tsz: %zd\\truns: %zd\\tsucc: %zd\\n\", i,\n             Sha1ToString(II.Sha1).c_str(), II.U.size(),\n             II.NumExecutedMutations, II.NumSuccessfullMutations);\n    }\n  }\n\n  void PrintFeatureSet() {\n    for (size_t i = 0; i < kFeatureSetSize; i++) {\n      if(size_t Sz = GetFeature(i))\n        Printf(\"[%zd: id %zd sz%zd] \", i, SmallestElementPerFeature[i], Sz);\n    }\n    Printf(\"\\n\\t\");\n    for (size_t i = 0; i < Inputs.size(); i++)\n      if (size_t N = Inputs[i]->NumFeatures)\n        Printf(\" %zd=>%zd \", i, N);\n    Printf(\"\\n\");\n  }\n\n  void DeleteFile(const InputInfo &II) {\n    if (!OutputCorpus.empty() && II.MayDeleteFile)\n      RemoveFile(DirPlusFile(OutputCorpus, Sha1ToString(II.Sha1)));\n  }\n\n  void DeleteInput(size_t Idx) {\n    InputInfo &II = *Inputs[Idx];\n    DeleteFile(II);\n    Unit().swap(II.U);\n    if (FeatureDebug)\n      Printf(\"EVICTED %zd\\n\", Idx);\n  }\n\n  bool AddFeature(size_t Idx, uint32_t NewSize, bool Shrink) {\n    assert(NewSize);\n    Idx = Idx % kFeatureSetSize;\n    uint32_t OldSize = GetFeature(Idx);\n    if (OldSize == 0 || (Shrink && OldSize > NewSize)) {\n      if (OldSize > 0) {\n        size_t OldIdx = SmallestElementPerFeature[Idx];\n        InputInfo &II = *Inputs[OldIdx];\n        assert(II.NumFeatures > 0);\n        II.NumFeatures--;\n        if (II.NumFeatures == 0)\n          DeleteInput(OldIdx);\n      } else {\n        NumAddedFeatures++;\n      }\n      NumUpdatedFeatures++;\n      if (FeatureDebug)\n        Printf(\"ADD FEATURE %zd sz %d\\n\", Idx, NewSize);\n      SmallestElementPerFeature[Idx] = Inputs.size();\n      InputSizesPerFeature[Idx] = NewSize;\n      return true;\n    }\n    return false;\n  }\n\n  void UpdateFeatureFrequency(size_t Idx) {\n    FeatureFrequency[Idx % kFeatureSetSize]++;\n  }\n  float GetFeatureFrequency(size_t Idx) const {\n    return FeatureFrequency[Idx % kFeatureSetSize];\n  }\n  void UpdateFeatureFrequencyScore(InputInfo *II) {\n    const float kMin = 0.01, kMax = 100.;\n    II->FeatureFrequencyScore = kMin;\n    for (auto Idx : II->UniqFeatureSet)\n      II->FeatureFrequencyScore += 1. / (GetFeatureFrequency(Idx) + 1.);\n    II->FeatureFrequencyScore = Min(II->FeatureFrequencyScore, kMax);\n  }\n\n  size_t NumFeatures() const { return NumAddedFeatures; }\n  size_t NumFeatureUpdates() const { return NumUpdatedFeatures; }\n\nprivate:\n\n  static const bool FeatureDebug = false;\n\n  size_t GetFeature(size_t Idx) const { return InputSizesPerFeature[Idx]; }\n\n  void ValidateFeatureSet() {\n    if (FeatureDebug)\n      PrintFeatureSet();\n    for (size_t Idx = 0; Idx < kFeatureSetSize; Idx++)\n      if (GetFeature(Idx))\n        Inputs[SmallestElementPerFeature[Idx]]->Tmp++;\n    for (auto II: Inputs) {\n      if (II->Tmp != II->NumFeatures)\n        Printf(\"ZZZ %zd %zd\\n\", II->Tmp, II->NumFeatures);\n      assert(II->Tmp == II->NumFeatures);\n      II->Tmp = 0;\n    }\n  }\n\n  // Updates the probability distribution for the units in the corpus.\n  // Must be called whenever the corpus or unit weights are changed.\n  //\n  // Hypothesis: units added to the corpus last are more interesting.\n  //\n  // Hypothesis: inputs with infrequent features are more interesting.\n  void UpdateCorpusDistribution() {\n    size_t N = Inputs.size();\n    assert(N);\n    Intervals.resize(N + 1);\n    Weights.resize(N);\n    std::iota(Intervals.begin(), Intervals.end(), 0);\n    for (size_t i = 0; i < N; i++)\n      Weights[i] = Inputs[i]->NumFeatures\n                       ? (i + 1) * Inputs[i]->FeatureFrequencyScore\n                       : 0.;\n    if (FeatureDebug) {\n      for (size_t i = 0; i < N; i++)\n        Printf(\"%zd \", Inputs[i]->NumFeatures);\n      Printf(\"NUM\\n\");\n      for (size_t i = 0; i < N; i++)\n        Printf(\"%f \", Inputs[i]->FeatureFrequencyScore);\n      Printf(\"SCORE\\n\");\n      for (size_t i = 0; i < N; i++)\n        Printf(\"%f \", Weights[i]);\n      Printf(\"Weights\\n\");\n    }\n    CorpusDistribution = std::piecewise_constant_distribution<double>(\n        Intervals.begin(), Intervals.end(), Weights.begin());\n  }\n  std::piecewise_constant_distribution<double> CorpusDistribution;\n\n  Vector<double> Intervals;\n  Vector<double> Weights;\n\n  std::unordered_set<std::string> Hashes;\n  Vector<InputInfo*> Inputs;\n\n  size_t NumAddedFeatures = 0;\n  size_t NumUpdatedFeatures = 0;\n  uint32_t InputSizesPerFeature[kFeatureSetSize];\n  uint32_t SmallestElementPerFeature[kFeatureSetSize];\n  float FeatureFrequency[kFeatureSetSize];\n\n  std::string OutputCorpus;\n};\n\n}  // namespace fuzzer\n\n#endif  // LLVM_FUZZER_CORPUS\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerCrossOver.cpp",
    "content": "//===- FuzzerCrossOver.cpp - Cross over two test inputs -------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Cross over test inputs.\n//===----------------------------------------------------------------------===//\n\n#include \"FuzzerDefs.h\"\n#include \"FuzzerMutate.h\"\n#include \"FuzzerRandom.h\"\n#include <cstring>\n\nnamespace fuzzer {\n\n// Cross Data1 and Data2, store the result (up to MaxOutSize bytes) in Out.\nsize_t MutationDispatcher::CrossOver(const uint8_t *Data1, size_t Size1,\n                                     const uint8_t *Data2, size_t Size2,\n                                     uint8_t *Out, size_t MaxOutSize) {\n  assert(Size1 || Size2);\n  if (Options.DefaultMutatorsResizeInput) {\n    MaxOutSize = Rand(MaxOutSize) + 1;\n  }\n  size_t OutPos = 0;\n  size_t Pos1 = 0;\n  size_t Pos2 = 0;\n  size_t *InPos = &Pos1;\n  size_t InSize = Size1;\n  const uint8_t *Data = Data1;\n  bool CurrentlyUsingFirstData = true;\n  while (OutPos < MaxOutSize && (Pos1 < Size1 || Pos2 < Size2)) {\n    // Merge a part of Data into Out.\n    size_t OutSizeLeft = MaxOutSize - OutPos;\n    if (*InPos < InSize) {\n      size_t InSizeLeft = InSize - *InPos;\n      size_t MaxExtraSize = std::min(OutSizeLeft, InSizeLeft);\n      size_t ExtraSize = Rand(MaxExtraSize) + 1;\n      memcpy(Out + OutPos, Data + *InPos, ExtraSize);\n      OutPos += ExtraSize;\n      (*InPos) += ExtraSize;\n    }\n    // Use the other input data on the next iteration.\n    InPos  = CurrentlyUsingFirstData ? &Pos2 : &Pos1;\n    InSize = CurrentlyUsingFirstData ? Size2 : Size1;\n    Data   = CurrentlyUsingFirstData ? Data2 : Data1;\n    CurrentlyUsingFirstData = !CurrentlyUsingFirstData;\n  }\n  return OutPos;\n}\n\n}  // namespace fuzzer\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerDefs.h",
    "content": "//===- FuzzerDefs.h - Internal header for the Fuzzer ------------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Basic definitions.\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_DEFS_H\n#define LLVM_FUZZER_DEFS_H\n\n#include <cassert>\n#include <cstddef>\n#include <cstdint>\n#include <cstring>\n#include <string>\n#include <vector>\n#include <set>\n#include <memory>\n\n// Platform detection.\n#ifdef __linux__\n#define LIBFUZZER_APPLE 0\n#define LIBFUZZER_FUCHSIA 0\n#define LIBFUZZER_LINUX 1\n#define LIBFUZZER_NETBSD 0\n#define LIBFUZZER_WINDOWS 0\n#elif __APPLE__\n#define LIBFUZZER_APPLE 1\n#define LIBFUZZER_FUCHSIA 0\n#define LIBFUZZER_LINUX 0\n#define LIBFUZZER_NETBSD 0\n#define LIBFUZZER_WINDOWS 0\n#elif __NetBSD__\n#define LIBFUZZER_APPLE 0\n#define LIBFUZZER_FUCHSIA 0\n#define LIBFUZZER_LINUX 0\n#define LIBFUZZER_NETBSD 1\n#define LIBFUZZER_WINDOWS 0\n#elif _WIN32\n#define LIBFUZZER_APPLE 0\n#define LIBFUZZER_FUCHSIA 0\n#define LIBFUZZER_LINUX 0\n#define LIBFUZZER_NETBSD 0\n#define LIBFUZZER_WINDOWS 1\n#elif __Fuchsia__\n#define LIBFUZZER_APPLE 0\n#define LIBFUZZER_FUCHSIA 1\n#define LIBFUZZER_LINUX 0\n#define LIBFUZZER_NETBSD 0\n#define LIBFUZZER_WINDOWS 0\n#else\n#error \"Support for your platform has not been implemented\"\n#endif\n\n#ifndef __has_attribute\n#  define __has_attribute(x) 0\n#endif\n\n#define LIBFUZZER_POSIX (LIBFUZZER_APPLE || LIBFUZZER_LINUX || LIBFUZZER_NETBSD)\n\n#ifdef __x86_64\n#  if __has_attribute(target)\n#    define ATTRIBUTE_TARGET_POPCNT __attribute__((target(\"popcnt\")))\n#  else\n#    define ATTRIBUTE_TARGET_POPCNT\n#  endif\n#else\n#  define ATTRIBUTE_TARGET_POPCNT\n#endif\n\n\n#ifdef __clang__  // avoid gcc warning.\n#  if __has_attribute(no_sanitize)\n#    define ATTRIBUTE_NO_SANITIZE_MEMORY __attribute__((no_sanitize(\"memory\")))\n#  else\n#    define ATTRIBUTE_NO_SANITIZE_MEMORY\n#  endif\n#  define ALWAYS_INLINE __attribute__((always_inline))\n#else\n#  define ATTRIBUTE_NO_SANITIZE_MEMORY\n#  define ALWAYS_INLINE\n#endif // __clang__\n\n#define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))\n\n#if defined(__has_feature)\n#  if __has_feature(address_sanitizer)\n#    define ATTRIBUTE_NO_SANITIZE_ALL ATTRIBUTE_NO_SANITIZE_ADDRESS\n#  elif __has_feature(memory_sanitizer)\n#    define ATTRIBUTE_NO_SANITIZE_ALL ATTRIBUTE_NO_SANITIZE_MEMORY\n#  else\n#    define ATTRIBUTE_NO_SANITIZE_ALL\n#  endif\n#else\n#  define ATTRIBUTE_NO_SANITIZE_ALL\n#endif\n\n#if LIBFUZZER_WINDOWS\n#define ATTRIBUTE_INTERFACE __declspec(dllexport)\n#else\n#define ATTRIBUTE_INTERFACE __attribute__((visibility(\"default\")))\n#endif\n\nnamespace fuzzer {\n\ntemplate <class T> T Min(T a, T b) { return a < b ? a : b; }\ntemplate <class T> T Max(T a, T b) { return a > b ? a : b; }\n\nclass Random;\nclass Dictionary;\nclass DictionaryEntry;\nclass MutationDispatcher;\nstruct FuzzingOptions;\nclass InputCorpus;\nstruct InputInfo;\nstruct ExternalFunctions;\n\n// Global interface to functions that may or may not be available.\nextern ExternalFunctions *EF;\n\n// We are using a custom allocator to give a different symbol name to STL\n// containers in order to avoid ODR violations.\ntemplate<typename T>\n  class fuzzer_allocator: public std::allocator<T> {\n    public:\n      template<class Other>\n      struct rebind { typedef fuzzer_allocator<Other> other;  };\n  };\n\ntemplate<typename T>\nusing Vector = std::vector<T, fuzzer_allocator<T>>;\n\ntemplate<typename T>\nusing Set = std::set<T, std::less<T>, fuzzer_allocator<T>>;\n\ntypedef Vector<uint8_t> Unit;\ntypedef Vector<Unit> UnitVector;\ntypedef int (*UserCallback)(const uint8_t *Data, size_t Size);\n\nint FuzzerDriver(int *argc, char ***argv, UserCallback Callback);\n\nstruct ScopedDoingMyOwnMemOrStr {\n  ScopedDoingMyOwnMemOrStr() { DoingMyOwnMemOrStr++; }\n  ~ScopedDoingMyOwnMemOrStr() { DoingMyOwnMemOrStr--; }\n  static int DoingMyOwnMemOrStr;\n};\n\ninline uint8_t  Bswap(uint8_t x)  { return x; }\ninline uint16_t Bswap(uint16_t x) { return __builtin_bswap16(x); }\ninline uint32_t Bswap(uint32_t x) { return __builtin_bswap32(x); }\ninline uint64_t Bswap(uint64_t x) { return __builtin_bswap64(x); }\n\nuint8_t *ExtraCountersBegin();\nuint8_t *ExtraCountersEnd();\nvoid ClearExtraCounters();\n\nuint64_t *ClangCountersBegin();\nuint64_t *ClangCountersEnd();\nvoid ClearClangCounters();\n\n}  // namespace fuzzer\n\n#endif  // LLVM_FUZZER_DEFS_H\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerDictionary.h",
    "content": "//===- FuzzerDictionary.h - Internal header for the Fuzzer ------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// fuzzer::Dictionary\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_DICTIONARY_H\n#define LLVM_FUZZER_DICTIONARY_H\n\n#include \"FuzzerDefs.h\"\n#include \"FuzzerIO.h\"\n#include \"FuzzerUtil.h\"\n#include <algorithm>\n#include <limits>\n\nnamespace fuzzer {\n// A simple POD sized array of bytes.\ntemplate <size_t kMaxSizeT> class FixedWord {\npublic:\n  static const size_t kMaxSize = kMaxSizeT;\n  FixedWord() {}\n  FixedWord(const uint8_t *B, uint8_t S) { Set(B, S); }\n\n  void Set(const uint8_t *B, uint8_t S) {\n    assert(S <= kMaxSize);\n    memcpy(Data, B, S);\n    Size = S;\n  }\n\n  bool operator==(const FixedWord<kMaxSize> &w) const {\n    ScopedDoingMyOwnMemOrStr scoped_doing_my_own_mem_os_str;\n    return Size == w.Size && 0 == memcmp(Data, w.Data, Size);\n  }\n\n  bool operator<(const FixedWord<kMaxSize> &w) const {\n    ScopedDoingMyOwnMemOrStr scoped_doing_my_own_mem_os_str;\n    if (Size != w.Size)\n      return Size < w.Size;\n    return memcmp(Data, w.Data, Size) < 0;\n  }\n\n  static size_t GetMaxSize() { return kMaxSize; }\n  const uint8_t *data() const { return Data; }\n  uint8_t size() const { return Size; }\n\nprivate:\n  uint8_t Size = 0;\n  uint8_t Data[kMaxSize];\n};\n\ntypedef FixedWord<64> Word;\n\nclass DictionaryEntry {\n public:\n  DictionaryEntry() {}\n  DictionaryEntry(Word W) : W(W) {}\n  DictionaryEntry(Word W, size_t PositionHint) : W(W), PositionHint(PositionHint) {}\n  const Word &GetW() const { return W; }\n\n  bool HasPositionHint() const { return PositionHint != std::numeric_limits<size_t>::max(); }\n  size_t GetPositionHint() const {\n    assert(HasPositionHint());\n    return PositionHint;\n  }\n  void IncUseCount() { UseCount++; }\n  void IncSuccessCount() { SuccessCount++; }\n  size_t GetUseCount() const { return UseCount; }\n  size_t GetSuccessCount() const {return SuccessCount; }\n\n  void Print(const char *PrintAfter = \"\\n\") {\n    PrintASCII(W.data(), W.size());\n    if (HasPositionHint())\n      Printf(\"@%zd\", GetPositionHint());\n    Printf(\"%s\", PrintAfter);\n  }\n\nprivate:\n  Word W;\n  size_t PositionHint = std::numeric_limits<size_t>::max();\n  size_t UseCount = 0;\n  size_t SuccessCount = 0;\n};\n\nclass Dictionary {\n public:\n  static const size_t kMaxDictSize = 1 << 14;\n\n  bool ContainsWord(const Word &W) const {\n    return std::any_of(begin(), end(), [&](const DictionaryEntry &DE) {\n      return DE.GetW() == W;\n    });\n  }\n  const DictionaryEntry *begin() const { return &DE[0]; }\n  const DictionaryEntry *end() const { return begin() + Size; }\n  DictionaryEntry & operator[] (size_t Idx) {\n    assert(Idx < Size);\n    return DE[Idx];\n  }\n  void push_back(DictionaryEntry DE) {\n    if (Size < kMaxDictSize)\n      this->DE[Size++] = DE;\n  }\n  void clear() { Size = 0; }\n  bool empty() const { return Size == 0; }\n  size_t size() const { return Size; }\n\nprivate:\n  DictionaryEntry DE[kMaxDictSize];\n  size_t Size = 0;\n};\n\n// Parses one dictionary entry.\n// If successfull, write the enty to Unit and returns true,\n// otherwise returns false.\nbool ParseOneDictionaryEntry(const std::string &Str, Unit *U);\n// Parses the dictionary file, fills Units, returns true iff all lines\n// were parsed succesfully.\nbool ParseDictionaryFile(const std::string &Text, Vector<Unit> *Units);\n\n}  // namespace fuzzer\n\n#endif  // LLVM_FUZZER_DICTIONARY_H\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerDriver.cpp",
    "content": "//===- FuzzerDriver.cpp - FuzzerDriver function and flags -----------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// FuzzerDriver and flag parsing.\n//===----------------------------------------------------------------------===//\n\n#include \"FuzzerCommand.h\"\n#include \"FuzzerCorpus.h\"\n#include \"FuzzerIO.h\"\n#include \"FuzzerInterface.h\"\n#include \"FuzzerInternal.h\"\n#include \"FuzzerMutate.h\"\n#include \"FuzzerRandom.h\"\n#include \"FuzzerShmem.h\"\n#include \"FuzzerTracePC.h\"\n#include <algorithm>\n#include <atomic>\n#include <chrono>\n#include <cstdlib>\n#include <cstring>\n#include <mutex>\n#include <string>\n#include <thread>\n\n// This function should be present in the libFuzzer so that the client\n// binary can test for its existence.\nextern \"C\" __attribute__((used)) void __libfuzzer_is_present() {}\n\nnamespace fuzzer {\n\n// Program arguments.\nstruct FlagDescription {\n  const char *Name;\n  const char *Description;\n  int   Default;\n  int   *IntFlag;\n  const char **StrFlag;\n  unsigned int *UIntFlag;\n};\n\nstruct {\n#define FUZZER_DEPRECATED_FLAG(Name)\n#define FUZZER_FLAG_INT(Name, Default, Description) int Name;\n#define FUZZER_FLAG_UNSIGNED(Name, Default, Description) unsigned int Name;\n#define FUZZER_FLAG_STRING(Name, Description) const char *Name;\n#include \"FuzzerFlags.def\"\n#undef FUZZER_DEPRECATED_FLAG\n#undef FUZZER_FLAG_INT\n#undef FUZZER_FLAG_UNSIGNED\n#undef FUZZER_FLAG_STRING\n} Flags;\n\nstatic const FlagDescription FlagDescriptions [] {\n#define FUZZER_DEPRECATED_FLAG(Name)                                           \\\n  {#Name, \"Deprecated; don't use\", 0, nullptr, nullptr, nullptr},\n#define FUZZER_FLAG_INT(Name, Default, Description)                            \\\n  {#Name, Description, Default, &Flags.Name, nullptr, nullptr},\n#define FUZZER_FLAG_UNSIGNED(Name, Default, Description)                       \\\n  {#Name,   Description, static_cast<int>(Default),                            \\\n   nullptr, nullptr, &Flags.Name},\n#define FUZZER_FLAG_STRING(Name, Description)                                  \\\n  {#Name, Description, 0, nullptr, &Flags.Name, nullptr},\n#include \"FuzzerFlags.def\"\n#undef FUZZER_DEPRECATED_FLAG\n#undef FUZZER_FLAG_INT\n#undef FUZZER_FLAG_UNSIGNED\n#undef FUZZER_FLAG_STRING\n};\n\nstatic const size_t kNumFlags =\n    sizeof(FlagDescriptions) / sizeof(FlagDescriptions[0]);\n\nstatic Vector<std::string> *Inputs;\nstatic std::string *ProgName;\n\nstatic void PrintHelp() {\n  Printf(\"Usage:\\n\");\n  auto Prog = ProgName->c_str();\n  Printf(\"\\nTo run fuzzing pass 0 or more directories.\\n\");\n  Printf(\"%s [-flag1=val1 [-flag2=val2 ...] ] [dir1 [dir2 ...] ]\\n\", Prog);\n\n  Printf(\"\\nTo run individual tests without fuzzing pass 1 or more files:\\n\");\n  Printf(\"%s [-flag1=val1 [-flag2=val2 ...] ] file1 [file2 ...]\\n\", Prog);\n\n  Printf(\"\\nFlags: (strictly in form -flag=value)\\n\");\n  size_t MaxFlagLen = 0;\n  for (size_t F = 0; F < kNumFlags; F++)\n    MaxFlagLen = std::max(strlen(FlagDescriptions[F].Name), MaxFlagLen);\n\n  for (size_t F = 0; F < kNumFlags; F++) {\n    const auto &D = FlagDescriptions[F];\n    if (strstr(D.Description, \"internal flag\") == D.Description) continue;\n    Printf(\" %s\", D.Name);\n    for (size_t i = 0, n = MaxFlagLen - strlen(D.Name); i < n; i++)\n      Printf(\" \");\n    Printf(\"\\t\");\n    Printf(\"%d\\t%s\\n\", D.Default, D.Description);\n  }\n  Printf(\"\\nFlags starting with '--' will be ignored and \"\n            \"will be passed verbatim to subprocesses.\\n\");\n}\n\nstatic const char *FlagValue(const char *Param, const char *Name) {\n  size_t Len = strlen(Name);\n  if (Param[0] == '-' && strstr(Param + 1, Name) == Param + 1 &&\n      Param[Len + 1] == '=')\n      return &Param[Len + 2];\n  return nullptr;\n}\n\n// Avoid calling stol as it triggers a bug in clang/glibc build.\nstatic long MyStol(const char *Str) {\n  long Res = 0;\n  long Sign = 1;\n  if (*Str == '-') {\n    Str++;\n    Sign = -1;\n  }\n  for (size_t i = 0; Str[i]; i++) {\n    char Ch = Str[i];\n    if (Ch < '0' || Ch > '9')\n      return Res;\n    Res = Res * 10 + (Ch - '0');\n  }\n  return Res * Sign;\n}\n\nstatic bool ParseOneFlag(const char *Param) {\n  if (Param[0] != '-') return false;\n  if (Param[1] == '-') {\n    static bool PrintedWarning = false;\n    if (!PrintedWarning) {\n      PrintedWarning = true;\n      Printf(\"INFO: libFuzzer ignores flags that start with '--'\\n\");\n    }\n    for (size_t F = 0; F < kNumFlags; F++)\n      if (FlagValue(Param + 1, FlagDescriptions[F].Name))\n        Printf(\"WARNING: did you mean '%s' (single dash)?\\n\", Param + 1);\n    return true;\n  }\n  for (size_t F = 0; F < kNumFlags; F++) {\n    const char *Name = FlagDescriptions[F].Name;\n    const char *Str = FlagValue(Param, Name);\n    if (Str)  {\n      if (FlagDescriptions[F].IntFlag) {\n        int Val = MyStol(Str);\n        *FlagDescriptions[F].IntFlag = Val;\n        if (Flags.verbosity >= 2)\n          Printf(\"Flag: %s %d\\n\", Name, Val);\n        return true;\n      } else if (FlagDescriptions[F].UIntFlag) {\n        unsigned int Val = std::stoul(Str);\n        *FlagDescriptions[F].UIntFlag = Val;\n        if (Flags.verbosity >= 2)\n          Printf(\"Flag: %s %u\\n\", Name, Val);\n        return true;\n      } else if (FlagDescriptions[F].StrFlag) {\n        *FlagDescriptions[F].StrFlag = Str;\n        if (Flags.verbosity >= 2)\n          Printf(\"Flag: %s %s\\n\", Name, Str);\n        return true;\n      } else {  // Deprecated flag.\n        Printf(\"Flag: %s: deprecated, don't use\\n\", Name);\n        return true;\n      }\n    }\n  }\n  Printf(\"\\n\\nWARNING: unrecognized flag '%s'; \"\n         \"use -help=1 to list all flags\\n\\n\", Param);\n  return true;\n}\n\n// We don't use any library to minimize dependencies.\nstatic void ParseFlags(const Vector<std::string> &Args) {\n  for (size_t F = 0; F < kNumFlags; F++) {\n    if (FlagDescriptions[F].IntFlag)\n      *FlagDescriptions[F].IntFlag = FlagDescriptions[F].Default;\n    if (FlagDescriptions[F].UIntFlag)\n      *FlagDescriptions[F].UIntFlag =\n          static_cast<unsigned int>(FlagDescriptions[F].Default);\n    if (FlagDescriptions[F].StrFlag)\n      *FlagDescriptions[F].StrFlag = nullptr;\n  }\n  Inputs = new Vector<std::string>;\n  for (size_t A = 1; A < Args.size(); A++) {\n    if (ParseOneFlag(Args[A].c_str())) {\n      if (Flags.ignore_remaining_args)\n        break;\n      continue;\n    }\n    Inputs->push_back(Args[A]);\n  }\n}\n\nstatic std::mutex Mu;\n\nstatic void PulseThread() {\n  while (true) {\n    SleepSeconds(600);\n    std::lock_guard<std::mutex> Lock(Mu);\n    Printf(\"pulse...\\n\");\n  }\n}\n\nstatic void WorkerThread(const Command &BaseCmd, std::atomic<unsigned> *Counter,\n                         unsigned NumJobs, std::atomic<bool> *HasErrors) {\n  while (true) {\n    unsigned C = (*Counter)++;\n    if (C >= NumJobs) break;\n    std::string Log = \"fuzz-\" + std::to_string(C) + \".log\";\n    Command Cmd(BaseCmd);\n    Cmd.setOutputFile(Log);\n    Cmd.combineOutAndErr();\n    if (Flags.verbosity) {\n      std::string CommandLine = Cmd.toString();\n      Printf(\"%s\\n\", CommandLine.c_str());\n    }\n    int ExitCode = ExecuteCommand(Cmd);\n    if (ExitCode != 0)\n      *HasErrors = true;\n    std::lock_guard<std::mutex> Lock(Mu);\n    Printf(\"================== Job %u exited with exit code %d ============\\n\",\n           C, ExitCode);\n    fuzzer::CopyFileToErr(Log);\n  }\n}\n\nstd::string CloneArgsWithoutX(const Vector<std::string> &Args,\n                              const char *X1, const char *X2) {\n  std::string Cmd;\n  for (auto &S : Args) {\n    if (FlagValue(S.c_str(), X1) || FlagValue(S.c_str(), X2))\n      continue;\n    Cmd += S + \" \";\n  }\n  return Cmd;\n}\n\nstatic int RunInMultipleProcesses(const Vector<std::string> &Args,\n                                  unsigned NumWorkers, unsigned NumJobs) {\n  std::atomic<unsigned> Counter(0);\n  std::atomic<bool> HasErrors(false);\n  Command Cmd(Args);\n  Cmd.removeFlag(\"jobs\");\n  Cmd.removeFlag(\"workers\");\n  Vector<std::thread> V;\n  std::thread Pulse(PulseThread);\n  Pulse.detach();\n  for (unsigned i = 0; i < NumWorkers; i++)\n    V.push_back(std::thread(WorkerThread, std::ref(Cmd), &Counter, NumJobs, &HasErrors));\n  for (auto &T : V)\n    T.join();\n  return HasErrors ? 1 : 0;\n}\n\nstatic void RssThread(Fuzzer *F, size_t RssLimitMb) {\n  while (true) {\n    SleepSeconds(1);\n    size_t Peak = GetPeakRSSMb();\n    if (Peak > RssLimitMb)\n      F->RssLimitCallback();\n  }\n}\n\nstatic void StartRssThread(Fuzzer *F, size_t RssLimitMb) {\n  if (!RssLimitMb) return;\n  std::thread T(RssThread, F, RssLimitMb);\n  T.detach();\n}\n\nint RunOneTest(Fuzzer *F, const char *InputFilePath, size_t MaxLen) {\n  Unit U = FileToVector(InputFilePath);\n  if (MaxLen && MaxLen < U.size())\n    U.resize(MaxLen);\n  F->ExecuteCallback(U.data(), U.size());\n  F->TryDetectingAMemoryLeak(U.data(), U.size(), true);\n  return 0;\n}\n\nstatic bool AllInputsAreFiles() {\n  if (Inputs->empty()) return false;\n  for (auto &Path : *Inputs)\n    if (!IsFile(Path))\n      return false;\n  return true;\n}\n\nstatic std::string GetDedupTokenFromFile(const std::string &Path) {\n  auto S = FileToString(Path);\n  auto Beg = S.find(\"DEDUP_TOKEN:\");\n  if (Beg == std::string::npos)\n    return \"\";\n  auto End = S.find('\\n', Beg);\n  if (End == std::string::npos)\n    return \"\";\n  return S.substr(Beg, End - Beg);\n}\n\nint CleanseCrashInput(const Vector<std::string> &Args,\n                       const FuzzingOptions &Options) {\n  if (Inputs->size() != 1 || !Flags.exact_artifact_path) {\n    Printf(\"ERROR: -cleanse_crash should be given one input file and\"\n          \" -exact_artifact_path\\n\");\n    exit(1);\n  }\n  std::string InputFilePath = Inputs->at(0);\n  std::string OutputFilePath = Flags.exact_artifact_path;\n  Command Cmd(Args);\n  Cmd.removeFlag(\"cleanse_crash\");\n\n  assert(Cmd.hasArgument(InputFilePath));\n  Cmd.removeArgument(InputFilePath);\n\n  auto LogFilePath = DirPlusFile(\n      TmpDir(), \"libFuzzerTemp.\" + std::to_string(GetPid()) + \".txt\");\n  auto TmpFilePath = DirPlusFile(\n      TmpDir(), \"libFuzzerTemp.\" + std::to_string(GetPid()) + \".repro\");\n  Cmd.addArgument(TmpFilePath);\n  Cmd.setOutputFile(LogFilePath);\n  Cmd.combineOutAndErr();\n\n  std::string CurrentFilePath = InputFilePath;\n  auto U = FileToVector(CurrentFilePath);\n  size_t Size = U.size();\n\n  const Vector<uint8_t> ReplacementBytes = {' ', 0xff};\n  for (int NumAttempts = 0; NumAttempts < 5; NumAttempts++) {\n    bool Changed = false;\n    for (size_t Idx = 0; Idx < Size; Idx++) {\n      Printf(\"CLEANSE[%d]: Trying to replace byte %zd of %zd\\n\", NumAttempts,\n             Idx, Size);\n      uint8_t OriginalByte = U[Idx];\n      if (ReplacementBytes.end() != std::find(ReplacementBytes.begin(),\n                                              ReplacementBytes.end(),\n                                              OriginalByte))\n        continue;\n      for (auto NewByte : ReplacementBytes) {\n        U[Idx] = NewByte;\n        WriteToFile(U, TmpFilePath);\n        auto ExitCode = ExecuteCommand(Cmd);\n        RemoveFile(TmpFilePath);\n        if (!ExitCode) {\n          U[Idx] = OriginalByte;\n        } else {\n          Changed = true;\n          Printf(\"CLEANSE: Replaced byte %zd with 0x%x\\n\", Idx, NewByte);\n          WriteToFile(U, OutputFilePath);\n          break;\n        }\n      }\n    }\n    if (!Changed) break;\n  }\n  RemoveFile(LogFilePath);\n  return 0;\n}\n\nint MinimizeCrashInput(const Vector<std::string> &Args,\n                       const FuzzingOptions &Options) {\n  if (Inputs->size() != 1) {\n    Printf(\"ERROR: -minimize_crash should be given one input file\\n\");\n    exit(1);\n  }\n  std::string InputFilePath = Inputs->at(0);\n  Command BaseCmd(Args);\n  BaseCmd.removeFlag(\"minimize_crash\");\n  BaseCmd.removeFlag(\"exact_artifact_path\");\n  assert(BaseCmd.hasArgument(InputFilePath));\n  BaseCmd.removeArgument(InputFilePath);\n  if (Flags.runs <= 0 && Flags.max_total_time == 0) {\n    Printf(\"INFO: you need to specify -runs=N or \"\n           \"-max_total_time=N with -minimize_crash=1\\n\"\n           \"INFO: defaulting to -max_total_time=600\\n\");\n    BaseCmd.addFlag(\"max_total_time\", \"600\");\n  }\n\n  auto LogFilePath = DirPlusFile(\n      TmpDir(), \"libFuzzerTemp.\" + std::to_string(GetPid()) + \".txt\");\n  BaseCmd.setOutputFile(LogFilePath);\n  BaseCmd.combineOutAndErr();\n\n  std::string CurrentFilePath = InputFilePath;\n  while (true) {\n    Unit U = FileToVector(CurrentFilePath);\n    Printf(\"CRASH_MIN: minimizing crash input: '%s' (%zd bytes)\\n\",\n           CurrentFilePath.c_str(), U.size());\n\n    Command Cmd(BaseCmd);\n    Cmd.addArgument(CurrentFilePath);\n\n    std::string CommandLine = Cmd.toString();\n    Printf(\"CRASH_MIN: executing: %s\\n\", CommandLine.c_str());\n    int ExitCode = ExecuteCommand(Cmd);\n    if (ExitCode == 0) {\n      Printf(\"ERROR: the input %s did not crash\\n\", CurrentFilePath.c_str());\n      exit(1);\n    }\n    Printf(\"CRASH_MIN: '%s' (%zd bytes) caused a crash. Will try to minimize \"\n           \"it further\\n\",\n           CurrentFilePath.c_str(), U.size());\n    auto DedupToken1 = GetDedupTokenFromFile(LogFilePath);\n    if (!DedupToken1.empty())\n      Printf(\"CRASH_MIN: DedupToken1: %s\\n\", DedupToken1.c_str());\n\n    std::string ArtifactPath =\n        Flags.exact_artifact_path\n            ? Flags.exact_artifact_path\n            : Options.ArtifactPrefix + \"minimized-from-\" + Hash(U);\n    Cmd.addFlag(\"minimize_crash_internal_step\", \"1\");\n    Cmd.addFlag(\"exact_artifact_path\", ArtifactPath);\n    CommandLine = Cmd.toString();\n    Printf(\"CRASH_MIN: executing: %s\\n\", CommandLine.c_str());\n    ExitCode = ExecuteCommand(Cmd);\n    CopyFileToErr(LogFilePath);\n    if (ExitCode == 0) {\n      if (Flags.exact_artifact_path) {\n        CurrentFilePath = Flags.exact_artifact_path;\n        WriteToFile(U, CurrentFilePath);\n      }\n      Printf(\"CRASH_MIN: failed to minimize beyond %s (%d bytes), exiting\\n\",\n             CurrentFilePath.c_str(), U.size());\n      break;\n    }\n    auto DedupToken2 = GetDedupTokenFromFile(LogFilePath);\n    if (!DedupToken2.empty())\n      Printf(\"CRASH_MIN: DedupToken2: %s\\n\", DedupToken2.c_str());\n\n    if (DedupToken1 != DedupToken2) {\n      if (Flags.exact_artifact_path) {\n        CurrentFilePath = Flags.exact_artifact_path;\n        WriteToFile(U, CurrentFilePath);\n      }\n      Printf(\"CRASH_MIN: mismatch in dedup tokens\"\n             \" (looks like a different bug). Won't minimize further\\n\");\n      break;\n    }\n\n    CurrentFilePath = ArtifactPath;\n    Printf(\"*********************************\\n\");\n  }\n  RemoveFile(LogFilePath);\n  return 0;\n}\n\nint MinimizeCrashInputInternalStep(Fuzzer *F, InputCorpus *Corpus) {\n  assert(Inputs->size() == 1);\n  std::string InputFilePath = Inputs->at(0);\n  Unit U = FileToVector(InputFilePath);\n  Printf(\"INFO: Starting MinimizeCrashInputInternalStep: %zd\\n\", U.size());\n  if (U.size() < 2) {\n    Printf(\"INFO: The input is small enough, exiting\\n\");\n    exit(0);\n  }\n  F->SetMaxInputLen(U.size());\n  F->SetMaxMutationLen(U.size() - 1);\n  F->MinimizeCrashLoop(U);\n  Printf(\"INFO: Done MinimizeCrashInputInternalStep, no crashes found\\n\");\n  exit(0);\n  return 0;\n}\n\nint AnalyzeDictionary(Fuzzer *F, const Vector<Unit>& Dict,\n                      UnitVector& Corpus) {\n  Printf(\"Started dictionary minimization (up to %d tests)\\n\",\n         Dict.size() * Corpus.size() * 2);\n\n  // Scores and usage count for each dictionary unit.\n  Vector<int> Scores(Dict.size());\n  Vector<int> Usages(Dict.size());\n\n  Vector<size_t> InitialFeatures;\n  Vector<size_t> ModifiedFeatures;\n  for (auto &C : Corpus) {\n    // Get coverage for the testcase without modifications.\n    F->ExecuteCallback(C.data(), C.size());\n    InitialFeatures.clear();\n    TPC.CollectFeatures([&](size_t Feature) {\n      InitialFeatures.push_back(Feature);\n    });\n\n    for (size_t i = 0; i < Dict.size(); ++i) {\n      Vector<uint8_t> Data = C;\n      auto StartPos = std::search(Data.begin(), Data.end(),\n                                  Dict[i].begin(), Dict[i].end());\n      // Skip dictionary unit, if the testcase does not contain it.\n      if (StartPos == Data.end())\n        continue;\n\n      ++Usages[i];\n      while (StartPos != Data.end()) {\n        // Replace all occurrences of dictionary unit in the testcase.\n        auto EndPos = StartPos + Dict[i].size();\n        for (auto It = StartPos; It != EndPos; ++It)\n          *It ^= 0xFF;\n\n        StartPos = std::search(EndPos, Data.end(),\n                               Dict[i].begin(), Dict[i].end());\n      }\n\n      // Get coverage for testcase with masked occurrences of dictionary unit.\n      F->ExecuteCallback(Data.data(), Data.size());\n      ModifiedFeatures.clear();\n      TPC.CollectFeatures([&](size_t Feature) {\n        ModifiedFeatures.push_back(Feature);\n      });\n\n      if (InitialFeatures == ModifiedFeatures)\n        --Scores[i];\n      else\n        Scores[i] += 2;\n    }\n  }\n\n  Printf(\"###### Useless dictionary elements. ######\\n\");\n  for (size_t i = 0; i < Dict.size(); ++i) {\n    // Dictionary units with positive score are treated as useful ones.\n    if (Scores[i] > 0)\n       continue;\n\n    Printf(\"\\\"\");\n    PrintASCII(Dict[i].data(), Dict[i].size(), \"\\\"\");\n    Printf(\" # Score: %d, Used: %d\\n\", Scores[i], Usages[i]);\n  }\n  Printf(\"###### End of useless dictionary elements. ######\\n\");\n  return 0;\n}\n\nint FuzzerDriver(int *argc, char ***argv, UserCallback Callback) {\n  using namespace fuzzer;\n  assert(argc && argv && \"Argument pointers cannot be nullptr\");\n  std::string Argv0((*argv)[0]);\n  EF = new ExternalFunctions();\n  if (EF->LLVMFuzzerInitialize)\n    EF->LLVMFuzzerInitialize(argc, argv);\n  const Vector<std::string> Args(*argv, *argv + *argc);\n  assert(!Args.empty());\n  ProgName = new std::string(Args[0]);\n  if (Argv0 != *ProgName) {\n    Printf(\"ERROR: argv[0] has been modified in LLVMFuzzerInitialize\\n\");\n    exit(1);\n  }\n  ParseFlags(Args);\n  if (Flags.help) {\n    PrintHelp();\n    return 0;\n  }\n\n  if (Flags.close_fd_mask & 2)\n    DupAndCloseStderr();\n  if (Flags.close_fd_mask & 1)\n    CloseStdout();\n\n  if (Flags.jobs > 0 && Flags.workers == 0) {\n    Flags.workers = std::min(NumberOfCpuCores() / 2, Flags.jobs);\n    if (Flags.workers > 1)\n      Printf(\"Running %u workers\\n\", Flags.workers);\n  }\n\n  if (Flags.workers > 0 && Flags.jobs > 0)\n    return RunInMultipleProcesses(Args, Flags.workers, Flags.jobs);\n\n  FuzzingOptions Options;\n  Options.Verbosity = Flags.verbosity;\n  Options.MaxLen = Flags.max_len;\n  Options.ExperimentalLenControl = Flags.experimental_len_control;\n  Options.UnitTimeoutSec = Flags.timeout;\n  Options.ErrorExitCode = Flags.error_exitcode;\n  Options.TimeoutExitCode = Flags.timeout_exitcode;\n  Options.MaxTotalTimeSec = Flags.max_total_time;\n  Options.DoCrossOver = Flags.cross_over;\n  Options.MutateDepth = Flags.mutate_depth;\n  Options.ReduceDepth = Flags.reduce_depth;\n  Options.UseCounters = Flags.use_counters;\n  Options.UseMemmem = Flags.use_memmem;\n  Options.UseCmp = Flags.use_cmp;\n  Options.UseValueProfile = Flags.use_value_profile;\n  Options.Shrink = Flags.shrink;\n  Options.ReduceInputs = Flags.reduce_inputs;\n  Options.ShuffleAtStartUp = Flags.shuffle;\n  Options.PreferSmall = Flags.prefer_small;\n  Options.ReloadIntervalSec = Flags.reload;\n  Options.OnlyASCII = Flags.only_ascii;\n  Options.DetectLeaks = Flags.detect_leaks;\n  Options.PurgeAllocatorIntervalSec = Flags.purge_allocator_interval;\n  Options.TraceMalloc = Flags.trace_malloc;\n  Options.RssLimitMb = Flags.rss_limit_mb;\n  Options.MallocLimitMb = Flags.malloc_limit_mb;\n  if (!Options.MallocLimitMb)\n    Options.MallocLimitMb = Options.RssLimitMb;\n  if (Flags.runs >= 0)\n    Options.MaxNumberOfRuns = Flags.runs;\n  if (!Inputs->empty() && !Flags.minimize_crash_internal_step)\n    Options.OutputCorpus = (*Inputs)[0];\n  Options.ReportSlowUnits = Flags.report_slow_units;\n  if (Flags.artifact_prefix)\n    Options.ArtifactPrefix = Flags.artifact_prefix;\n  if (Flags.exact_artifact_path)\n    Options.ExactArtifactPath = Flags.exact_artifact_path;\n  Vector<Unit> Dictionary;\n  if (Flags.dict)\n    if (!ParseDictionaryFile(FileToString(Flags.dict), &Dictionary))\n      return 1;\n  if (Flags.verbosity > 0 && !Dictionary.empty())\n    Printf(\"Dictionary: %zd entries\\n\", Dictionary.size());\n  bool DoPlainRun = AllInputsAreFiles();\n  Options.SaveArtifacts =\n      !DoPlainRun || Flags.minimize_crash_internal_step;\n  Options.PrintNewCovPcs = Flags.print_pcs;\n  Options.PrintNewCovFuncs = Flags.print_funcs;\n  Options.PrintFinalStats = Flags.print_final_stats;\n  Options.PrintCorpusStats = Flags.print_corpus_stats;\n  Options.PrintCoverage = Flags.print_coverage;\n  Options.DumpCoverage = Flags.dump_coverage;\n  Options.UseClangCoverage = Flags.use_clang_coverage;\n  Options.UseFeatureFrequency = Flags.use_feature_frequency;\n  Options.DefaultMutatorsResizeInput = Flags.default_mutators_resize_input;\n  if (Flags.exit_on_src_pos)\n    Options.ExitOnSrcPos = Flags.exit_on_src_pos;\n  if (Flags.exit_on_item)\n    Options.ExitOnItem = Flags.exit_on_item;\n\n  unsigned Seed = Flags.seed;\n  // Initialize Seed.\n  if (Seed == 0)\n    Seed =\n        std::chrono::system_clock::now().time_since_epoch().count() + GetPid();\n  if (Flags.verbosity)\n    Printf(\"INFO: Seed: %u\\n\", Seed);\n\n  Random Rand(Seed);\n  auto *MD = new MutationDispatcher(Rand, Options);\n  auto *Corpus = new InputCorpus(Options.OutputCorpus);\n  auto *F = new Fuzzer(Callback, *Corpus, *MD, Options);\n\n  for (auto &U: Dictionary)\n    if (U.size() <= Word::GetMaxSize())\n      MD->AddWordToManualDictionary(Word(U.data(), U.size()));\n\n  StartRssThread(F, Flags.rss_limit_mb);\n\n  Options.HandleAbrt = Flags.handle_abrt;\n  Options.HandleBus = Flags.handle_bus;\n  Options.HandleFpe = Flags.handle_fpe;\n  Options.HandleIll = Flags.handle_ill;\n  Options.HandleInt = Flags.handle_int;\n  Options.HandleSegv = Flags.handle_segv;\n  Options.HandleTerm = Flags.handle_term;\n  Options.HandleXfsz = Flags.handle_xfsz;\n  Options.HandleUsr1 = Flags.handle_usr1;\n  Options.HandleUsr2 = Flags.handle_usr2;\n  SetSignalHandler(Options);\n\n  std::atexit(Fuzzer::StaticExitCallback);\n\n  if (Flags.minimize_crash)\n    return MinimizeCrashInput(Args, Options);\n\n  if (Flags.minimize_crash_internal_step)\n    return MinimizeCrashInputInternalStep(F, Corpus);\n\n  if (Flags.cleanse_crash)\n    return CleanseCrashInput(Args, Options);\n\n  if (auto Name = Flags.run_equivalence_server) {\n    SMR.Destroy(Name);\n    if (!SMR.Create(Name)) {\n       Printf(\"ERROR: can't create shared memory region\\n\");\n      return 1;\n    }\n    Printf(\"INFO: EQUIVALENCE SERVER UP\\n\");\n    while (true) {\n      SMR.WaitClient();\n      size_t Size = SMR.ReadByteArraySize();\n      SMR.WriteByteArray(nullptr, 0);\n      const Unit tmp(SMR.GetByteArray(), SMR.GetByteArray() + Size);\n      F->ExecuteCallback(tmp.data(), tmp.size());\n      SMR.PostServer();\n    }\n    return 0;\n  }\n\n  if (auto Name = Flags.use_equivalence_server) {\n    if (!SMR.Open(Name)) {\n      Printf(\"ERROR: can't open shared memory region\\n\");\n      return 1;\n    }\n    Printf(\"INFO: EQUIVALENCE CLIENT UP\\n\");\n  }\n\n  if (DoPlainRun) {\n    Options.SaveArtifacts = false;\n    int Runs = std::max(1, Flags.runs);\n    Printf(\"%s: Running %zd inputs %d time(s) each.\\n\", ProgName->c_str(),\n           Inputs->size(), Runs);\n    for (auto &Path : *Inputs) {\n      auto StartTime = system_clock::now();\n      Printf(\"Running: %s\\n\", Path.c_str());\n      for (int Iter = 0; Iter < Runs; Iter++)\n        RunOneTest(F, Path.c_str(), Options.MaxLen);\n      auto StopTime = system_clock::now();\n      auto MS = duration_cast<milliseconds>(StopTime - StartTime).count();\n      Printf(\"Executed %s in %zd ms\\n\", Path.c_str(), (long)MS);\n    }\n    Printf(\"***\\n\"\n           \"*** NOTE: fuzzing was not performed, you have only\\n\"\n           \"***       executed the target code on a fixed set of inputs.\\n\"\n           \"***\\n\");\n    F->PrintFinalStats();\n    exit(0);\n  }\n\n  if (Flags.merge) {\n    F->CrashResistantMerge(Args, *Inputs,\n                           Flags.load_coverage_summary,\n                           Flags.save_coverage_summary,\n                           Flags.merge_control_file);\n    exit(0);\n  }\n\n  if (Flags.merge_inner) {\n    const size_t kDefaultMaxMergeLen = 1 << 20;\n    if (Options.MaxLen == 0)\n      F->SetMaxInputLen(kDefaultMaxMergeLen);\n    assert(Flags.merge_control_file);\n    F->CrashResistantMergeInternalStep(Flags.merge_control_file);\n    exit(0);\n  }\n\n  if (Flags.analyze_dict) {\n    size_t MaxLen = INT_MAX;  // Large max length.\n    UnitVector InitialCorpus;\n    for (auto &Inp : *Inputs) {\n      Printf(\"Loading corpus dir: %s\\n\", Inp.c_str());\n      ReadDirToVectorOfUnits(Inp.c_str(), &InitialCorpus, nullptr,\n                             MaxLen, /*ExitOnError=*/false);\n    }\n\n    if (Dictionary.empty() || Inputs->empty()) {\n      Printf(\"ERROR: can't analyze dict without dict and corpus provided\\n\");\n      return 1;\n    }\n    if (AnalyzeDictionary(F, Dictionary, InitialCorpus)) {\n      Printf(\"Dictionary analysis failed\\n\");\n      exit(1);\n    }\n    Printf(\"Dictionary analysis suceeded\\n\");\n    exit(0);\n  }\n\n  F->Loop(*Inputs);\n\n  if (Flags.verbosity)\n    Printf(\"Done %zd runs in %zd second(s)\\n\", F->getTotalNumberOfRuns(),\n           F->secondsSinceProcessStartUp());\n  F->PrintFinalStats();\n  if (EF->LLVMFuzzerAtExit) {\n    EF->LLVMFuzzerAtExit();\n  }\n  exit(0);  // Don't let F destroy itself.\n}\n\n// Storage for global ExternalFunctions object.\nExternalFunctions *EF = nullptr;\n\n}  // namespace fuzzer\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerExtFunctions.def",
    "content": "//===- FuzzerExtFunctions.def - External functions --------------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// This defines the external function pointers that\n// ``fuzzer::ExternalFunctions`` should contain and try to initialize.  The\n// EXT_FUNC macro must be defined at the point of inclusion. The signature of\n// the macro is:\n//\n// EXT_FUNC(<name>, <return_type>, <function_signature>, <warn_if_missing>)\n//===----------------------------------------------------------------------===//\n\n// Optional user functions\nEXT_FUNC(LLVMFuzzerInitialize, int, (int *argc, char ***argv), false);\nEXT_FUNC(LLVMFuzzerCustomMutator, size_t,\n         (uint8_t * Data, size_t Size, size_t MaxSize, unsigned int Seed),\n         false);\nEXT_FUNC(LLVMFuzzerCustomCrossOver, size_t,\n         (const uint8_t * Data1, size_t Size1,\n          const uint8_t * Data2, size_t Size2,\n          uint8_t * Out, size_t MaxOutSize, unsigned int Seed),\n         false);\nEXT_FUNC(LLVMFuzzerAtExit, void, (), false);\n\n// Sanitizer functions\nEXT_FUNC(__lsan_enable, void, (), false);\nEXT_FUNC(__lsan_disable, void, (), false);\nEXT_FUNC(__lsan_do_recoverable_leak_check, int, (), false);\nEXT_FUNC(__sanitizer_install_malloc_and_free_hooks, int,\n         (void (*malloc_hook)(const volatile void *, size_t),\n          void (*free_hook)(const volatile void *)),\n         false);\nEXT_FUNC(__sanitizer_purge_allocator, void, (), false);\nEXT_FUNC(__sanitizer_print_memory_profile, int, (size_t, size_t), false);\nEXT_FUNC(__sanitizer_print_stack_trace, void, (), true);\nEXT_FUNC(__sanitizer_symbolize_pc, void,\n         (void *, const char *fmt, char *out_buf, size_t out_buf_size), false);\nEXT_FUNC(__sanitizer_get_module_and_offset_for_pc, int,\n         (void *pc, char *module_path,\n         size_t module_path_len,void **pc_offset), false);\nEXT_FUNC(__sanitizer_set_death_callback, void, (void (*)(void)), true);\nEXT_FUNC(__sanitizer_set_report_fd, void, (void*), false);\nEXT_FUNC(__sanitizer_dump_coverage, void, (const uintptr_t *, uintptr_t),\n         false);\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerExtFunctions.h",
    "content": "//===- FuzzerExtFunctions.h - Interface to external functions ---*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Defines an interface to (possibly optional) functions.\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_EXT_FUNCTIONS_H\n#define LLVM_FUZZER_EXT_FUNCTIONS_H\n\n#include <stddef.h>\n#include <stdint.h>\n\nnamespace fuzzer {\n\nstruct ExternalFunctions {\n  // Initialize function pointers. Functions that are not available will be set\n  // to nullptr.  Do not call this constructor  before ``main()`` has been\n  // entered.\n  ExternalFunctions();\n\n#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN)                            \\\n  RETURN_TYPE(*NAME) FUNC_SIG = nullptr\n\n#include \"FuzzerExtFunctions.def\"\n\n#undef EXT_FUNC\n};\n} // namespace fuzzer\n\n#endif\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerExtFunctionsDlsym.cpp",
    "content": "//===- FuzzerExtFunctionsDlsym.cpp - Interface to external functions ------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Implementation for operating systems that support dlsym(). We only use it on\n// Apple platforms for now. We don't use this approach on Linux because it\n// requires that clients of LibFuzzer pass ``--export-dynamic`` to the linker.\n// That is a complication we don't wish to expose to clients right now.\n//===----------------------------------------------------------------------===//\n#include \"FuzzerDefs.h\"\n#if LIBFUZZER_APPLE\n\n#include \"FuzzerExtFunctions.h\"\n#include \"FuzzerIO.h\"\n#include <dlfcn.h>\n\nusing namespace fuzzer;\n\ntemplate <typename T>\nstatic T GetFnPtr(const char *FnName, bool WarnIfMissing) {\n  dlerror(); // Clear any previous errors.\n  void *Fn = dlsym(RTLD_DEFAULT, FnName);\n  if (Fn == nullptr) {\n    if (WarnIfMissing) {\n      const char *ErrorMsg = dlerror();\n      Printf(\"WARNING: Failed to find function \\\"%s\\\".\", FnName);\n      if (ErrorMsg)\n        Printf(\" Reason %s.\", ErrorMsg);\n      Printf(\"\\n\");\n    }\n  }\n  return reinterpret_cast<T>(Fn);\n}\n\nnamespace fuzzer {\n\nExternalFunctions::ExternalFunctions() {\n#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN)                            \\\n  this->NAME = GetFnPtr<decltype(ExternalFunctions::NAME)>(#NAME, WARN)\n\n#include \"FuzzerExtFunctions.def\"\n\n#undef EXT_FUNC\n}\n\n} // namespace fuzzer\n\n#endif // LIBFUZZER_APPLE\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerExtFunctionsDlsymWin.cpp",
    "content": "//===- FuzzerExtFunctionsDlsymWin.cpp - Interface to external functions ---===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Implementation using dynamic loading for Windows.\n//===----------------------------------------------------------------------===//\n#include \"FuzzerDefs.h\"\n#if LIBFUZZER_WINDOWS\n\n#include \"FuzzerExtFunctions.h\"\n#include \"FuzzerIO.h\"\n#include \"Windows.h\"\n\n// This must be included after Windows.h.\n#include \"Psapi.h\"\n\nnamespace fuzzer {\n\nExternalFunctions::ExternalFunctions() {\n  HMODULE Modules[1024];\n  DWORD BytesNeeded;\n  HANDLE CurrentProcess = GetCurrentProcess();\n\n  if (!EnumProcessModules(CurrentProcess, Modules, sizeof(Modules),\n                          &BytesNeeded)) {\n    Printf(\"EnumProcessModules failed (error: %d).\\n\", GetLastError());\n    exit(1);\n  }\n\n  if (sizeof(Modules) < BytesNeeded) {\n    Printf(\"Error: the array is not big enough to hold all loaded modules.\\n\");\n    exit(1);\n  }\n\n  for (size_t i = 0; i < (BytesNeeded / sizeof(HMODULE)); i++)\n  {\n    FARPROC Fn;\n#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN)                            \\\n    if (this->NAME == nullptr) {                                               \\\n      Fn = GetProcAddress(Modules[i], #NAME);                                  \\\n      if (Fn == nullptr)                                                       \\\n         Fn = GetProcAddress(Modules[i], #NAME \"__dll\");                       \\\n      this->NAME = (decltype(ExternalFunctions::NAME)) Fn;                     \\\n    }\n#include \"FuzzerExtFunctions.def\"\n#undef EXT_FUNC\n  }\n\n#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN)                            \\\n  if (this->NAME == nullptr && WARN)                                           \\\n    Printf(\"WARNING: Failed to find function \\\"%s\\\".\\n\", #NAME);\n#include \"FuzzerExtFunctions.def\"\n#undef EXT_FUNC\n}\n\n} // namespace fuzzer\n\n#endif // LIBFUZZER_WINDOWS\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerExtFunctionsWeak.cpp",
    "content": "//===- FuzzerExtFunctionsWeak.cpp - Interface to external functions -------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Implementation for Linux. This relies on the linker's support for weak\n// symbols. We don't use this approach on Apple platforms because it requires\n// clients of LibFuzzer to pass ``-U _<symbol_name>`` to the linker to allow\n// weak symbols to be undefined. That is a complication we don't want to expose\n// to clients right now.\n//===----------------------------------------------------------------------===//\n#include \"FuzzerDefs.h\"\n#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FUCHSIA\n\n#include \"FuzzerExtFunctions.h\"\n#include \"FuzzerIO.h\"\n\nextern \"C\" {\n// Declare these symbols as weak to allow them to be optionally defined.\n#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN)                            \\\n  __attribute__((weak)) RETURN_TYPE NAME FUNC_SIG\n\n#include \"FuzzerExtFunctions.def\"\n\n#undef EXT_FUNC\n}\n\nusing namespace fuzzer;\n\nstatic void CheckFnPtr(void *FnPtr, const char *FnName, bool WarnIfMissing) {\n  if (FnPtr == nullptr && WarnIfMissing) {\n    Printf(\"WARNING: Failed to find function \\\"%s\\\".\\n\", FnName);\n  }\n}\n\nnamespace fuzzer {\n\nExternalFunctions::ExternalFunctions() {\n#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN)                            \\\n  this->NAME = ::NAME;                                                         \\\n  CheckFnPtr(reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(::NAME)),    \\\n             #NAME, WARN);\n\n#include \"FuzzerExtFunctions.def\"\n\n#undef EXT_FUNC\n}\n\n} // namespace fuzzer\n\n#endif // LIBFUZZER_LINUX || LIBFUZZER_NETBSD\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerExtFunctionsWeakAlias.cpp",
    "content": "//===- FuzzerExtFunctionsWeakAlias.cpp - Interface to external functions --===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Implementation using weak aliases. Works for Windows.\n//===----------------------------------------------------------------------===//\n#include \"FuzzerDefs.h\"\n#if LIBFUZZER_WINDOWS\n\n#include \"FuzzerExtFunctions.h\"\n#include \"FuzzerIO.h\"\n\nusing namespace fuzzer;\n\nextern \"C\" {\n// Declare these symbols as weak to allow them to be optionally defined.\n#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN)                            \\\n  RETURN_TYPE NAME##Def FUNC_SIG {                                             \\\n    Printf(\"ERROR: Function \\\"%s\\\" not defined.\\n\", #NAME);                    \\\n    exit(1);                                                                   \\\n  }                                                                            \\\n  RETURN_TYPE NAME FUNC_SIG __attribute__((weak, alias(#NAME \"Def\")));\n\n#include \"FuzzerExtFunctions.def\"\n\n#undef EXT_FUNC\n}\n\ntemplate <typename T>\nstatic T *GetFnPtr(T *Fun, T *FunDef, const char *FnName, bool WarnIfMissing) {\n  if (Fun == FunDef) {\n    if (WarnIfMissing)\n      Printf(\"WARNING: Failed to find function \\\"%s\\\".\\n\", FnName);\n    return nullptr;\n  }\n  return Fun;\n}\n\nnamespace fuzzer {\n\nExternalFunctions::ExternalFunctions() {\n#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN)                            \\\n  this->NAME = GetFnPtr<decltype(::NAME)>(::NAME, ::NAME##Def, #NAME, WARN);\n\n#include \"FuzzerExtFunctions.def\"\n\n#undef EXT_FUNC\n}\n\n} // namespace fuzzer\n\n#endif // LIBFUZZER_WINDOWS\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerExtraCounters.cpp",
    "content": "//===- FuzzerExtraCounters.cpp - Extra coverage counters ------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Extra coverage counters defined by user code.\n//===----------------------------------------------------------------------===//\n\n#include \"FuzzerDefs.h\"\n\n#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD\n__attribute__((weak)) extern uint8_t __start___libfuzzer_extra_counters;\n__attribute__((weak)) extern uint8_t __stop___libfuzzer_extra_counters;\n\nnamespace fuzzer {\nuint8_t *ExtraCountersBegin() { return &__start___libfuzzer_extra_counters; }\nuint8_t *ExtraCountersEnd() { return &__stop___libfuzzer_extra_counters; }\nATTRIBUTE_NO_SANITIZE_ALL\nvoid ClearExtraCounters() {  // hand-written memset, don't asan-ify.\n  uintptr_t *Beg = reinterpret_cast<uintptr_t*>(ExtraCountersBegin());\n  uintptr_t *End = reinterpret_cast<uintptr_t*>(ExtraCountersEnd());\n  for (; Beg < End; Beg++) {\n    *Beg = 0;\n    __asm__ __volatile__(\"\" : : : \"memory\");\n  }\n}\n\n}  // namespace fuzzer\n\n#else\n// TODO: implement for other platforms.\nnamespace fuzzer {\nuint8_t *ExtraCountersBegin() { return nullptr; }\nuint8_t *ExtraCountersEnd() { return nullptr; }\nvoid ClearExtraCounters() {}\n}  // namespace fuzzer\n\n#endif\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerFlags.def",
    "content": "//===- FuzzerFlags.def - Run-time flags -------------------------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Flags. FUZZER_FLAG_INT/FUZZER_FLAG_STRING macros should be defined at the\n// point of inclusion. We are not using any flag parsing library for better\n// portability and independence.\n//===----------------------------------------------------------------------===//\nFUZZER_FLAG_INT(verbosity, 1, \"Verbosity level.\")\nFUZZER_FLAG_UNSIGNED(seed, 0, \"Random seed. If 0, seed is generated.\")\nFUZZER_FLAG_INT(runs, -1,\n            \"Number of individual test runs (-1 for infinite runs).\")\nFUZZER_FLAG_INT(max_len, 0, \"Maximum length of the test input. \"\n    \"If 0, libFuzzer tries to guess a good value based on the corpus \"\n    \"and reports it. \")\nFUZZER_FLAG_INT(experimental_len_control, 0, \"experimental flag\")\nFUZZER_FLAG_INT(cross_over, 1, \"If 1, cross over inputs.\")\nFUZZER_FLAG_INT(mutate_depth, 5,\n            \"Apply this number of consecutive mutations to each input.\")\nFUZZER_FLAG_INT(reduce_depth, 0, \"Experimental/internal. \"\n                \"Reduce depth if mutations lose unique features\")\nFUZZER_FLAG_INT(shuffle, 1, \"Shuffle inputs at startup\")\nFUZZER_FLAG_INT(prefer_small, 1,\n    \"If 1, always prefer smaller inputs during the corpus shuffle.\")\nFUZZER_FLAG_INT(\n    timeout, 1200,\n    \"Timeout in seconds (if positive). \"\n    \"If one unit runs more than this number of seconds the process will abort.\")\nFUZZER_FLAG_INT(error_exitcode, 77, \"When libFuzzer itself reports a bug \"\n  \"this exit code will be used.\")\nFUZZER_FLAG_INT(timeout_exitcode, 77, \"When libFuzzer reports a timeout \"\n  \"this exit code will be used.\")\nFUZZER_FLAG_INT(max_total_time, 0, \"If positive, indicates the maximal total \"\n                                   \"time in seconds to run the fuzzer.\")\nFUZZER_FLAG_INT(help, 0, \"Print help.\")\nFUZZER_FLAG_INT(merge, 0, \"If 1, the 2-nd, 3-rd, etc corpora will be \"\n  \"merged into the 1-st corpus. Only interesting units will be taken. \"\n  \"This flag can be used to minimize a corpus.\")\nFUZZER_FLAG_STRING(merge_inner, \"internal flag\")\nFUZZER_FLAG_STRING(merge_control_file,\n                   \"Specify a control file used for the merge proccess. \"\n                   \"If a merge process gets killed it tries to leave this file \"\n                   \"in a state suitable for resuming the merge. \"\n                   \"By default a temporary file will be used.\")\nFUZZER_FLAG_STRING(save_coverage_summary, \"Experimental:\"\n                   \" save coverage summary to a given file.\"\n                   \" Used with -merge=1\")\nFUZZER_FLAG_STRING(load_coverage_summary, \"Experimental:\"\n                   \" load coverage summary from a given file.\"\n                   \" Treat this coverage as belonging to the first corpus. \"\n                   \" Used with -merge=1\")\nFUZZER_FLAG_INT(minimize_crash, 0, \"If 1, minimizes the provided\"\n  \" crash input. Use with -runs=N or -max_total_time=N to limit \"\n  \"the number attempts.\"\n  \" Use with -exact_artifact_path to specify the output.\"\n  \" Combine with ASAN_OPTIONS=dedup_token_length=3 (or similar) to ensure that\"\n  \" the minimized input triggers the same crash.\"\n  )\nFUZZER_FLAG_INT(cleanse_crash, 0, \"If 1, tries to cleanse the provided\"\n  \" crash input to make it contain fewer original bytes.\"\n  \" Use with -exact_artifact_path to specify the output.\"\n  )\nFUZZER_FLAG_INT(minimize_crash_internal_step, 0, \"internal flag\")\nFUZZER_FLAG_INT(use_counters, 1, \"Use coverage counters\")\nFUZZER_FLAG_INT(use_memmem, 1,\n                \"Use hints from intercepting memmem, strstr, etc\")\nFUZZER_FLAG_INT(use_value_profile, 0,\n                \"Experimental. Use value profile to guide fuzzing.\")\nFUZZER_FLAG_INT(use_cmp, 1, \"Use CMP traces to guide mutations\")\nFUZZER_FLAG_INT(shrink, 0, \"Experimental. Try to shrink corpus inputs.\")\nFUZZER_FLAG_INT(reduce_inputs, 1,\n  \"Try to reduce the size of inputs while preserving their full feature sets\")\nFUZZER_FLAG_UNSIGNED(jobs, 0, \"Number of jobs to run. If jobs >= 1 we spawn\"\n                          \" this number of jobs in separate worker processes\"\n                          \" with stdout/stderr redirected to fuzz-JOB.log.\")\nFUZZER_FLAG_UNSIGNED(workers, 0,\n            \"Number of simultaneous worker processes to run the jobs.\"\n            \" If zero, \\\"min(jobs,NumberOfCpuCores()/2)\\\" is used.\")\nFUZZER_FLAG_INT(reload, 1,\n                \"Reload the main corpus every <N> seconds to get new units\"\n                \" discovered by other processes. If 0, disabled\")\nFUZZER_FLAG_INT(report_slow_units, 10,\n    \"Report slowest units if they run for more than this number of seconds.\")\nFUZZER_FLAG_INT(only_ascii, 0,\n                \"If 1, generate only ASCII (isprint+isspace) inputs.\")\nFUZZER_FLAG_STRING(dict, \"Experimental. Use the dictionary file.\")\nFUZZER_FLAG_STRING(artifact_prefix, \"Write fuzzing artifacts (crash, \"\n                                    \"timeout, or slow inputs) as \"\n                                    \"$(artifact_prefix)file\")\nFUZZER_FLAG_STRING(exact_artifact_path,\n                   \"Write the single artifact on failure (crash, timeout) \"\n                   \"as $(exact_artifact_path). This overrides -artifact_prefix \"\n                   \"and will not use checksum in the file name. Do not \"\n                   \"use the same path for several parallel processes.\")\nFUZZER_FLAG_INT(print_pcs, 0, \"If 1, print out newly covered PCs.\")\nFUZZER_FLAG_INT(print_funcs, 2, \"If >=1, print out at most this number of \"\n                                \"newly covered functions.\")\nFUZZER_FLAG_INT(print_final_stats, 0, \"If 1, print statistics at exit.\")\nFUZZER_FLAG_INT(print_corpus_stats, 0,\n  \"If 1, print statistics on corpus elements at exit.\")\nFUZZER_FLAG_INT(print_coverage, 0, \"If 1, print coverage information as text\"\n                                   \" at exit.\")\nFUZZER_FLAG_INT(dump_coverage, 0, \"Deprecated.\"\n                                  \" If 1, dump coverage information as a\"\n                                  \" .sancov file at exit.\")\nFUZZER_FLAG_INT(handle_segv, 1, \"If 1, try to intercept SIGSEGV.\")\nFUZZER_FLAG_INT(handle_bus, 1, \"If 1, try to intercept SIGBUS.\")\nFUZZER_FLAG_INT(handle_abrt, 1, \"If 1, try to intercept SIGABRT.\")\nFUZZER_FLAG_INT(handle_ill, 1, \"If 1, try to intercept SIGILL.\")\nFUZZER_FLAG_INT(handle_fpe, 1, \"If 1, try to intercept SIGFPE.\")\nFUZZER_FLAG_INT(handle_int, 1, \"If 1, try to intercept SIGINT.\")\nFUZZER_FLAG_INT(handle_term, 1, \"If 1, try to intercept SIGTERM.\")\nFUZZER_FLAG_INT(handle_xfsz, 1, \"If 1, try to intercept SIGXFSZ.\")\nFUZZER_FLAG_INT(handle_usr1, 1, \"If 1, try to intercept SIGUSR1.\")\nFUZZER_FLAG_INT(handle_usr2, 1, \"If 1, try to intercept SIGUSR2.\")\nFUZZER_FLAG_INT(close_fd_mask, 0, \"If 1, close stdout at startup; \"\n    \"if 2, close stderr; if 3, close both. \"\n    \"Be careful, this will also close e.g. stderr of asan.\")\nFUZZER_FLAG_INT(detect_leaks, 1, \"If 1, and if LeakSanitizer is enabled \"\n    \"try to detect memory leaks during fuzzing (i.e. not only at shut down).\")\nFUZZER_FLAG_INT(purge_allocator_interval, 1, \"Purge allocator caches and \"\n    \"quarantines every <N> seconds. When rss_limit_mb is specified (>0), \"\n    \"purging starts when RSS exceeds 50% of rss_limit_mb. Pass \"\n    \"purge_allocator_interval=-1 to disable this functionality.\")\nFUZZER_FLAG_INT(trace_malloc, 0, \"If >= 1 will print all mallocs/frees. \"\n    \"If >= 2 will also print stack traces.\")\nFUZZER_FLAG_INT(rss_limit_mb, 2048, \"If non-zero, the fuzzer will exit upon\"\n    \"reaching this limit of RSS memory usage.\")\nFUZZER_FLAG_INT(malloc_limit_mb, 0, \"If non-zero, the fuzzer will exit \"\n    \"if the target tries to allocate this number of Mb with one malloc call. \"\n    \"If zero (default) same limit as rss_limit_mb is applied.\")\nFUZZER_FLAG_STRING(exit_on_src_pos, \"Exit if a newly found PC originates\"\n    \" from the given source location. Example: -exit_on_src_pos=foo.cc:123. \"\n    \"Used primarily for testing libFuzzer itself.\")\nFUZZER_FLAG_STRING(exit_on_item, \"Exit if an item with a given sha1 sum\"\n    \" was added to the corpus. \"\n    \"Used primarily for testing libFuzzer itself.\")\nFUZZER_FLAG_INT(ignore_remaining_args, 0, \"If 1, ignore all arguments passed \"\n                \"after this one. Useful for fuzzers that need to do their own \"\n                \"argument parsing.\")\n\nFUZZER_FLAG_STRING(run_equivalence_server, \"Experimental\")\nFUZZER_FLAG_STRING(use_equivalence_server, \"Experimental\")\nFUZZER_FLAG_INT(analyze_dict, 0, \"Experimental\")\nFUZZER_FLAG_INT(use_clang_coverage, 0, \"Experimental\")\nFUZZER_FLAG_INT(use_feature_frequency, 0, \"Experimental/internal\")\nFUZZER_FLAG_INT(default_mutators_resize_input, 1, \"HACK: Default mutators will resize input\")\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerIO.cpp",
    "content": "//===- FuzzerIO.cpp - IO utils. -------------------------------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// IO functions.\n//===----------------------------------------------------------------------===//\n\n#include \"FuzzerIO.h\"\n#include \"FuzzerDefs.h\"\n#include \"FuzzerExtFunctions.h\"\n#include <algorithm>\n#include <cstdarg>\n#include <fstream>\n#include <iterator>\n#include <sys/stat.h>\n#include <sys/types.h>\n\nnamespace fuzzer {\n\nstatic FILE *OutputFile = stderr;\n\nlong GetEpoch(const std::string &Path) {\n  struct stat St;\n  if (stat(Path.c_str(), &St))\n    return 0;  // Can't stat, be conservative.\n  return St.st_mtime;\n}\n\nUnit FileToVector(const std::string &Path, size_t MaxSize, bool ExitOnError) {\n  std::ifstream T(Path);\n  if (ExitOnError && !T) {\n    Printf(\"No such directory: %s; exiting\\n\", Path.c_str());\n    exit(1);\n  }\n\n  T.seekg(0, T.end);\n  auto EndPos = T.tellg();\n  if (EndPos < 0) return {};\n  size_t FileLen = EndPos;\n  if (MaxSize)\n    FileLen = std::min(FileLen, MaxSize);\n\n  T.seekg(0, T.beg);\n  Unit Res(FileLen);\n  T.read(reinterpret_cast<char *>(Res.data()), FileLen);\n  return Res;\n}\n\nstd::string FileToString(const std::string &Path) {\n  std::ifstream T(Path);\n  return std::string((std::istreambuf_iterator<char>(T)),\n                     std::istreambuf_iterator<char>());\n}\n\nvoid CopyFileToErr(const std::string &Path) {\n  Printf(\"%s\", FileToString(Path).c_str());\n}\n\nvoid WriteToFile(const Unit &U, const std::string &Path) {\n  // Use raw C interface because this function may be called from a sig handler.\n  FILE *Out = fopen(Path.c_str(), \"w\");\n  if (!Out) return;\n  fwrite(U.data(), sizeof(U[0]), U.size(), Out);\n  fclose(Out);\n}\n\nvoid ReadDirToVectorOfUnits(const char *Path, Vector<Unit> *V,\n                            long *Epoch, size_t MaxSize, bool ExitOnError) {\n  long E = Epoch ? *Epoch : 0;\n  Vector<std::string> Files;\n  ListFilesInDirRecursive(Path, Epoch, &Files, /*TopDir*/true);\n  size_t NumLoaded = 0;\n  for (size_t i = 0; i < Files.size(); i++) {\n    auto &X = Files[i];\n    if (Epoch && GetEpoch(X) < E) continue;\n    NumLoaded++;\n    if ((NumLoaded & (NumLoaded - 1)) == 0 && NumLoaded >= 1024)\n      Printf(\"Loaded %zd/%zd files from %s\\n\", NumLoaded, Files.size(), Path);\n    auto S = FileToVector(X, MaxSize, ExitOnError);\n    if (!S.empty())\n      V->push_back(S);\n  }\n}\n\n\nvoid GetSizedFilesFromDir(const std::string &Dir, Vector<SizedFile> *V) {\n  Vector<std::string> Files;\n  ListFilesInDirRecursive(Dir, 0, &Files, /*TopDir*/true);\n  for (auto &File : Files)\n    if (size_t Size = FileSize(File))\n      V->push_back({File, Size});\n}\n\nstd::string DirPlusFile(const std::string &DirPath,\n                        const std::string &FileName) {\n  return DirPath + GetSeparator() + FileName;\n}\n\nvoid DupAndCloseStderr() {\n  int OutputFd = DuplicateFile(2);\n  if (OutputFd > 0) {\n    FILE *NewOutputFile = OpenFile(OutputFd, \"w\");\n    if (NewOutputFile) {\n      OutputFile = NewOutputFile;\n      if (EF->__sanitizer_set_report_fd)\n        EF->__sanitizer_set_report_fd(\n            reinterpret_cast<void *>(GetHandleFromFd(OutputFd)));\n      DiscardOutput(2);\n    }\n  }\n}\n\nvoid CloseStdout() {\n  DiscardOutput(1);\n}\n\nvoid Printf(const char *Fmt, ...) {\n  va_list ap;\n  va_start(ap, Fmt);\n  vfprintf(OutputFile, Fmt, ap);\n  va_end(ap);\n  fflush(OutputFile);\n}\n\n}  // namespace fuzzer\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerIO.h",
    "content": "//===- FuzzerIO.h - Internal header for IO utils ----------------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// IO interface.\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_IO_H\n#define LLVM_FUZZER_IO_H\n\n#include \"FuzzerDefs.h\"\n\nnamespace fuzzer {\n\nlong GetEpoch(const std::string &Path);\n\nUnit FileToVector(const std::string &Path, size_t MaxSize = 0,\n                  bool ExitOnError = true);\n\nstd::string FileToString(const std::string &Path);\n\nvoid CopyFileToErr(const std::string &Path);\n\nvoid WriteToFile(const Unit &U, const std::string &Path);\n\nvoid ReadDirToVectorOfUnits(const char *Path, Vector<Unit> *V,\n                            long *Epoch, size_t MaxSize, bool ExitOnError);\n\n// Returns \"Dir/FileName\" or equivalent for the current OS.\nstd::string DirPlusFile(const std::string &DirPath,\n                        const std::string &FileName);\n\n// Returns the name of the dir, similar to the 'dirname' utility.\nstd::string DirName(const std::string &FileName);\n\n// Returns path to a TmpDir.\nstd::string TmpDir();\n\nbool IsInterestingCoverageFile(const std::string &FileName);\n\nvoid DupAndCloseStderr();\n\nvoid CloseStdout();\n\nvoid Printf(const char *Fmt, ...);\n\n// Print using raw syscalls, useful when printing at early init stages.\nvoid RawPrint(const char *Str);\n\n// Platform specific functions:\nbool IsFile(const std::string &Path);\nsize_t FileSize(const std::string &Path);\n\nvoid ListFilesInDirRecursive(const std::string &Dir, long *Epoch,\n                             Vector<std::string> *V, bool TopDir);\n\nstruct SizedFile {\n  std::string File;\n  size_t Size;\n  bool operator<(const SizedFile &B) const { return Size < B.Size; }\n};\n\nvoid GetSizedFilesFromDir(const std::string &Dir, Vector<SizedFile> *V);\n\nchar GetSeparator();\n\nFILE* OpenFile(int Fd, const char *Mode);\n\nint CloseFile(int Fd);\n\nint DuplicateFile(int Fd);\n\nvoid RemoveFile(const std::string &Path);\n\nvoid DiscardOutput(int Fd);\n\nintptr_t GetHandleFromFd(int fd);\n\n}  // namespace fuzzer\n\n#endif  // LLVM_FUZZER_IO_H\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerIOPosix.cpp",
    "content": "//===- FuzzerIOPosix.cpp - IO utils for Posix. ----------------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// IO functions implementation using Posix API.\n//===----------------------------------------------------------------------===//\n#include \"FuzzerDefs.h\"\n#if LIBFUZZER_POSIX || LIBFUZZER_FUCHSIA\n\n#include \"FuzzerExtFunctions.h\"\n#include \"FuzzerIO.h\"\n#include <cstdarg>\n#include <cstdio>\n#include <dirent.h>\n#include <fstream>\n#include <iterator>\n#include <libgen.h>\n#include <sys/stat.h>\n#include <sys/types.h>\n#include <unistd.h>\n\nnamespace fuzzer {\n\nbool IsFile(const std::string &Path) {\n  struct stat St;\n  if (stat(Path.c_str(), &St))\n    return false;\n  return S_ISREG(St.st_mode);\n}\n\nstatic bool IsDirectory(const std::string &Path) {\n  struct stat St;\n  if (stat(Path.c_str(), &St))\n    return false;\n  return S_ISDIR(St.st_mode);\n}\n\nsize_t FileSize(const std::string &Path) {\n  struct stat St;\n  if (stat(Path.c_str(), &St))\n    return 0;\n  return St.st_size;\n}\n\nvoid ListFilesInDirRecursive(const std::string &Dir, long *Epoch,\n                             Vector<std::string> *V, bool TopDir) {\n  auto E = GetEpoch(Dir);\n  if (Epoch)\n    if (E && *Epoch >= E) return;\n\n  DIR *D = opendir(Dir.c_str());\n  if (!D) {\n    Printf(\"No such directory: %s; exiting\\n\", Dir.c_str());\n    exit(1);\n  }\n  while (auto E = readdir(D)) {\n    std::string Path = DirPlusFile(Dir, E->d_name);\n    if (E->d_type == DT_REG || E->d_type == DT_LNK ||\n        (E->d_type == DT_UNKNOWN && IsFile(Path)))\n      V->push_back(Path);\n    else if ((E->d_type == DT_DIR ||\n             (E->d_type == DT_UNKNOWN && IsDirectory(Path))) &&\n             *E->d_name != '.')\n      ListFilesInDirRecursive(Path, Epoch, V, false);\n  }\n  closedir(D);\n  if (Epoch && TopDir)\n    *Epoch = E;\n}\n\nchar GetSeparator() {\n  return '/';\n}\n\nFILE* OpenFile(int Fd, const char* Mode) {\n  return fdopen(Fd, Mode);\n}\n\nint CloseFile(int fd) {\n  return close(fd);\n}\n\nint DuplicateFile(int Fd) {\n  return dup(Fd);\n}\n\nvoid RemoveFile(const std::string &Path) {\n  unlink(Path.c_str());\n}\n\nvoid DiscardOutput(int Fd) {\n  FILE* Temp = fopen(\"/dev/null\", \"w\");\n  if (!Temp)\n    return;\n  dup2(fileno(Temp), Fd);\n  fclose(Temp);\n}\n\nintptr_t GetHandleFromFd(int fd) {\n  return static_cast<intptr_t>(fd);\n}\n\nstd::string DirName(const std::string &FileName) {\n  char *Tmp = new char[FileName.size() + 1];\n  memcpy(Tmp, FileName.c_str(), FileName.size() + 1);\n  std::string Res = dirname(Tmp);\n  delete [] Tmp;\n  return Res;\n}\n\nstd::string TmpDir() {\n  if (auto Env = getenv(\"TMPDIR\"))\n    return Env;\n  return \"/tmp\";\n}\n\nbool IsInterestingCoverageFile(const std::string &FileName) {\n  if (FileName.find(\"compiler-rt/lib/\") != std::string::npos)\n    return false; // sanitizer internal.\n  if (FileName.find(\"/usr/lib/\") != std::string::npos)\n    return false;\n  if (FileName.find(\"/usr/include/\") != std::string::npos)\n    return false;\n  if (FileName == \"<null>\")\n    return false;\n  return true;\n}\n\n\nvoid RawPrint(const char *Str) {\n  write(2, Str, strlen(Str));\n}\n\n}  // namespace fuzzer\n\n#endif // LIBFUZZER_POSIX\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerIOWindows.cpp",
    "content": "//===- FuzzerIOWindows.cpp - IO utils for Windows. ------------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// IO functions implementation for Windows.\n//===----------------------------------------------------------------------===//\n#include \"FuzzerDefs.h\"\n#if LIBFUZZER_WINDOWS\n\n#include \"FuzzerExtFunctions.h\"\n#include \"FuzzerIO.h\"\n#include <cstdarg>\n#include <cstdio>\n#include <fstream>\n#include <io.h>\n#include <iterator>\n#include <sys/stat.h>\n#include <sys/types.h>\n#include <windows.h>\n\nnamespace fuzzer {\n\nstatic bool IsFile(const std::string &Path, const DWORD &FileAttributes) {\n\n  if (FileAttributes & FILE_ATTRIBUTE_NORMAL)\n    return true;\n\n  if (FileAttributes & FILE_ATTRIBUTE_DIRECTORY)\n    return false;\n\n  HANDLE FileHandle(\n      CreateFileA(Path.c_str(), 0, FILE_SHARE_READ, NULL, OPEN_EXISTING,\n                  FILE_FLAG_BACKUP_SEMANTICS, 0));\n\n  if (FileHandle == INVALID_HANDLE_VALUE) {\n    Printf(\"CreateFileA() failed for \\\"%s\\\" (Error code: %lu).\\n\", Path.c_str(),\n        GetLastError());\n    return false;\n  }\n\n  DWORD FileType = GetFileType(FileHandle);\n\n  if (FileType == FILE_TYPE_UNKNOWN) {\n    Printf(\"GetFileType() failed for \\\"%s\\\" (Error code: %lu).\\n\", Path.c_str(),\n        GetLastError());\n    CloseHandle(FileHandle);\n    return false;\n  }\n\n  if (FileType != FILE_TYPE_DISK) {\n    CloseHandle(FileHandle);\n    return false;\n  }\n\n  CloseHandle(FileHandle);\n  return true;\n}\n\nbool IsFile(const std::string &Path) {\n  DWORD Att = GetFileAttributesA(Path.c_str());\n\n  if (Att == INVALID_FILE_ATTRIBUTES) {\n    Printf(\"GetFileAttributesA() failed for \\\"%s\\\" (Error code: %lu).\\n\",\n        Path.c_str(), GetLastError());\n    return false;\n  }\n\n  return IsFile(Path, Att);\n}\n\nvoid ListFilesInDirRecursive(const std::string &Dir, long *Epoch,\n                             Vector<std::string> *V, bool TopDir) {\n  auto E = GetEpoch(Dir);\n  if (Epoch)\n    if (E && *Epoch >= E) return;\n\n  std::string Path(Dir);\n  assert(!Path.empty());\n  if (Path.back() != '\\\\')\n      Path.push_back('\\\\');\n  Path.push_back('*');\n\n  // Get the first directory entry.\n  WIN32_FIND_DATAA FindInfo;\n  HANDLE FindHandle(FindFirstFileA(Path.c_str(), &FindInfo));\n  if (FindHandle == INVALID_HANDLE_VALUE)\n  {\n    if (GetLastError() == ERROR_FILE_NOT_FOUND)\n      return;\n    Printf(\"No such directory: %s; exiting\\n\", Dir.c_str());\n    exit(1);\n  }\n\n  do {\n    std::string FileName = DirPlusFile(Dir, FindInfo.cFileName);\n\n    if (FindInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {\n      size_t FilenameLen = strlen(FindInfo.cFileName);\n      if ((FilenameLen == 1 && FindInfo.cFileName[0] == '.') ||\n          (FilenameLen == 2 && FindInfo.cFileName[0] == '.' &&\n                               FindInfo.cFileName[1] == '.'))\n        continue;\n\n      ListFilesInDirRecursive(FileName, Epoch, V, false);\n    }\n    else if (IsFile(FileName, FindInfo.dwFileAttributes))\n      V->push_back(FileName);\n  } while (FindNextFileA(FindHandle, &FindInfo));\n\n  DWORD LastError = GetLastError();\n  if (LastError != ERROR_NO_MORE_FILES)\n    Printf(\"FindNextFileA failed (Error code: %lu).\\n\", LastError);\n\n  FindClose(FindHandle);\n\n  if (Epoch && TopDir)\n    *Epoch = E;\n}\n\nchar GetSeparator() {\n  return '\\\\';\n}\n\nFILE* OpenFile(int Fd, const char* Mode) {\n  return _fdopen(Fd, Mode);\n}\n\nint CloseFile(int Fd) {\n  return _close(Fd);\n}\n\nint DuplicateFile(int Fd) {\n  return _dup(Fd);\n}\n\nvoid RemoveFile(const std::string &Path) {\n  _unlink(Path.c_str());\n}\n\nvoid DiscardOutput(int Fd) {\n  FILE* Temp = fopen(\"nul\", \"w\");\n  if (!Temp)\n    return;\n  _dup2(_fileno(Temp), Fd);\n  fclose(Temp);\n}\n\nintptr_t GetHandleFromFd(int fd) {\n  return _get_osfhandle(fd);\n}\n\nstatic bool IsSeparator(char C) {\n  return C == '\\\\' || C == '/';\n}\n\n// Parse disk designators, like \"C:\\\". If Relative == true, also accepts: \"C:\".\n// Returns number of characters considered if successful.\nstatic size_t ParseDrive(const std::string &FileName, const size_t Offset,\n                         bool Relative = true) {\n  if (Offset + 1 >= FileName.size() || FileName[Offset + 1] != ':')\n    return 0;\n  if (Offset + 2 >= FileName.size() || !IsSeparator(FileName[Offset + 2])) {\n    if (!Relative) // Accept relative path?\n      return 0;\n    else\n      return 2;\n  }\n  return 3;\n}\n\n// Parse a file name, like: SomeFile.txt\n// Returns number of characters considered if successful.\nstatic size_t ParseFileName(const std::string &FileName, const size_t Offset) {\n  size_t Pos = Offset;\n  const size_t End = FileName.size();\n  for(; Pos < End && !IsSeparator(FileName[Pos]); ++Pos)\n    ;\n  return Pos - Offset;\n}\n\n// Parse a directory ending in separator, like: `SomeDir\\`\n// Returns number of characters considered if successful.\nstatic size_t ParseDir(const std::string &FileName, const size_t Offset) {\n  size_t Pos = Offset;\n  const size_t End = FileName.size();\n  if (Pos >= End || IsSeparator(FileName[Pos]))\n    return 0;\n  for(; Pos < End && !IsSeparator(FileName[Pos]); ++Pos)\n    ;\n  if (Pos >= End)\n    return 0;\n  ++Pos; // Include separator.\n  return Pos - Offset;\n}\n\n// Parse a servername and share, like: `SomeServer\\SomeShare\\`\n// Returns number of characters considered if successful.\nstatic size_t ParseServerAndShare(const std::string &FileName,\n                                  const size_t Offset) {\n  size_t Pos = Offset, Res;\n  if (!(Res = ParseDir(FileName, Pos)))\n    return 0;\n  Pos += Res;\n  if (!(Res = ParseDir(FileName, Pos)))\n    return 0;\n  Pos += Res;\n  return Pos - Offset;\n}\n\n// Parse the given Ref string from the position Offset, to exactly match the given\n// string Patt.\n// Returns number of characters considered if successful.\nstatic size_t ParseCustomString(const std::string &Ref, size_t Offset,\n                                const char *Patt) {\n  size_t Len = strlen(Patt);\n  if (Offset + Len > Ref.size())\n    return 0;\n  return Ref.compare(Offset, Len, Patt) == 0 ? Len : 0;\n}\n\n// Parse a location, like:\n// \\\\?\\UNC\\Server\\Share\\  \\\\?\\C:\\  \\\\Server\\Share\\  \\  C:\\  C:\n// Returns number of characters considered if successful.\nstatic size_t ParseLocation(const std::string &FileName) {\n  size_t Pos = 0, Res;\n\n  if ((Res = ParseCustomString(FileName, Pos, R\"(\\\\?\\)\"))) {\n    Pos += Res;\n    if ((Res = ParseCustomString(FileName, Pos, R\"(UNC\\)\"))) {\n      Pos += Res;\n      if ((Res = ParseServerAndShare(FileName, Pos)))\n        return Pos + Res;\n      return 0;\n    }\n    if ((Res = ParseDrive(FileName, Pos, false)))\n      return Pos + Res;\n    return 0;\n  }\n\n  if (Pos < FileName.size() && IsSeparator(FileName[Pos])) {\n    ++Pos;\n    if (Pos < FileName.size() && IsSeparator(FileName[Pos])) {\n      ++Pos;\n      if ((Res = ParseServerAndShare(FileName, Pos)))\n        return Pos + Res;\n      return 0;\n    }\n    return Pos;\n  }\n\n  if ((Res = ParseDrive(FileName, Pos)))\n    return Pos + Res;\n\n  return Pos;\n}\n\nstd::string DirName(const std::string &FileName) {\n  size_t LocationLen = ParseLocation(FileName);\n  size_t DirLen = 0, Res;\n  while ((Res = ParseDir(FileName, LocationLen + DirLen)))\n    DirLen += Res;\n  size_t FileLen = ParseFileName(FileName, LocationLen + DirLen);\n\n  if (LocationLen + DirLen + FileLen != FileName.size()) {\n    Printf(\"DirName() failed for \\\"%s\\\", invalid path.\\n\", FileName.c_str());\n    exit(1);\n  }\n\n  if (DirLen) {\n    --DirLen; // Remove trailing separator.\n    if (!FileLen) { // Path ended in separator.\n      assert(DirLen);\n      // Remove file name from Dir.\n      while (DirLen && !IsSeparator(FileName[LocationLen + DirLen - 1]))\n        --DirLen;\n      if (DirLen) // Remove trailing separator.\n        --DirLen;\n    }\n  }\n\n  if (!LocationLen) { // Relative path.\n    if (!DirLen)\n      return \".\";\n    return std::string(\".\\\\\").append(FileName, 0, DirLen);\n  }\n\n  return FileName.substr(0, LocationLen + DirLen);\n}\n\nstd::string TmpDir() {\n  std::string Tmp;\n  Tmp.resize(MAX_PATH + 1);\n  DWORD Size = GetTempPathA(Tmp.size(), &Tmp[0]);\n  if (Size == 0) {\n    Printf(\"Couldn't get Tmp path.\\n\");\n    exit(1);\n  }\n  Tmp.resize(Size);\n  return Tmp;\n}\n\nbool IsInterestingCoverageFile(const std::string &FileName) {\n  if (FileName.find(\"Program Files\") != std::string::npos)\n    return false;\n  if (FileName.find(\"compiler-rt\\\\lib\\\\\") != std::string::npos)\n    return false; // sanitizer internal.\n  if (FileName == \"<null>\")\n    return false;\n  return true;\n}\n\nvoid RawPrint(const char *Str) {\n  // Not tested, may or may not work. Fix if needed.\n  Printf(\"%s\", Str);\n}\n\n}  // namespace fuzzer\n\n#endif // LIBFUZZER_WINDOWS\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerInterface.h",
    "content": "//===- FuzzerInterface.h - Interface header for the Fuzzer ------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Define the interface between libFuzzer and the library being tested.\n//===----------------------------------------------------------------------===//\n\n// NOTE: the libFuzzer interface is thin and in the majority of cases\n// you should not include this file into your target. In 95% of cases\n// all you need is to define the following function in your file:\n// extern \"C\" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);\n\n// WARNING: keep the interface in C.\n\n#ifndef LLVM_FUZZER_INTERFACE_H\n#define LLVM_FUZZER_INTERFACE_H\n\n#include <stddef.h>\n#include <stdint.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif  // __cplusplus\n\n// Mandatory user-provided target function.\n// Executes the code under test with [Data, Data+Size) as the input.\n// libFuzzer will invoke this function *many* times with different inputs.\n// Must return 0.\nint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);\n\n// Optional user-provided initialization function.\n// If provided, this function will be called by libFuzzer once at startup.\n// It may read and modify argc/argv.\n// Must return 0.\nint LLVMFuzzerInitialize(int *argc, char ***argv);\n\n// Optional user-provided custom mutator.\n// Mutates raw data in [Data, Data+Size) inplace.\n// Returns the new size, which is not greater than MaxSize.\n// Given the same Seed produces the same mutation.\nsize_t LLVMFuzzerCustomMutator(uint8_t *Data, size_t Size, size_t MaxSize,\n                               unsigned int Seed);\n\n// Optional user-provided custom cross-over function.\n// Combines pieces of Data1 & Data2 together into Out.\n// Returns the new size, which is not greater than MaxOutSize.\n// Should produce the same mutation given the same Seed.\nsize_t LLVMFuzzerCustomCrossOver(const uint8_t *Data1, size_t Size1,\n                                 const uint8_t *Data2, size_t Size2,\n                                 uint8_t *Out, size_t MaxOutSize,\n                                 unsigned int Seed);\n\n// Experimental, may go away in future.\n// libFuzzer-provided function to be used inside LLVMFuzzerCustomMutator.\n// Mutates raw data in [Data, Data+Size) inplace.\n// Returns the new size, which is not greater than MaxSize.\nsize_t LLVMFuzzerMutate(uint8_t *Data, size_t Size, size_t MaxSize);\n\n#ifdef __cplusplus\n}  // extern \"C\"\n#endif  // __cplusplus\n\n#endif  // LLVM_FUZZER_INTERFACE_H\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerInternal.h",
    "content": "//===- FuzzerInternal.h - Internal header for the Fuzzer --------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Define the main class fuzzer::Fuzzer and most functions.\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_INTERNAL_H\n#define LLVM_FUZZER_INTERNAL_H\n\n#include \"FuzzerDefs.h\"\n#include \"FuzzerExtFunctions.h\"\n#include \"FuzzerInterface.h\"\n#include \"FuzzerOptions.h\"\n#include \"FuzzerSHA1.h\"\n#include \"FuzzerValueBitMap.h\"\n#include <algorithm>\n#include <atomic>\n#include <chrono>\n#include <climits>\n#include <cstdlib>\n#include <string.h>\n\nnamespace fuzzer {\n\nusing namespace std::chrono;\n\nclass Fuzzer {\npublic:\n\n  Fuzzer(UserCallback CB, InputCorpus &Corpus, MutationDispatcher &MD,\n         FuzzingOptions Options);\n  ~Fuzzer();\n  void Loop(const Vector<std::string> &CorpusDirs);\n  void ReadAndExecuteSeedCorpora(const Vector<std::string> &CorpusDirs);\n  void MinimizeCrashLoop(const Unit &U);\n  void RereadOutputCorpus(size_t MaxSize);\n\n  size_t secondsSinceProcessStartUp() {\n    return duration_cast<seconds>(system_clock::now() - ProcessStartTime)\n        .count();\n  }\n\n  bool TimedOut() {\n    return Options.MaxTotalTimeSec > 0 &&\n           secondsSinceProcessStartUp() >\n               static_cast<size_t>(Options.MaxTotalTimeSec);\n  }\n\n  size_t execPerSec() {\n    size_t Seconds = secondsSinceProcessStartUp();\n    return Seconds ? TotalNumberOfRuns / Seconds : 0;\n  }\n\n  size_t getTotalNumberOfRuns() { return TotalNumberOfRuns; }\n\n  static void StaticAlarmCallback();\n  static void StaticCrashSignalCallback();\n  static void StaticExitCallback();\n  static void StaticInterruptCallback();\n  static void StaticFileSizeExceedCallback();\n  static void StaticGracefulExitCallback();\n\n  void ExecuteCallback(const uint8_t *Data, size_t Size);\n  bool RunOne(const uint8_t *Data, size_t Size, bool MayDeleteFile = false,\n              InputInfo *II = nullptr, bool *FoundUniqFeatures = nullptr);\n\n  // Merge Corpora[1:] into Corpora[0].\n  void Merge(const Vector<std::string> &Corpora);\n  void CrashResistantMerge(const Vector<std::string> &Args,\n                           const Vector<std::string> &Corpora,\n                           const char *CoverageSummaryInputPathOrNull,\n                           const char *CoverageSummaryOutputPathOrNull,\n                           const char *MergeControlFilePathOrNull);\n  void CrashResistantMergeInternalStep(const std::string &ControlFilePath);\n  MutationDispatcher &GetMD() { return MD; }\n  void PrintFinalStats();\n  void SetMaxInputLen(size_t MaxInputLen);\n  void SetMaxMutationLen(size_t MaxMutationLen);\n  void RssLimitCallback();\n\n  bool InFuzzingThread() const { return IsMyThread; }\n  size_t GetCurrentUnitInFuzzingThead(const uint8_t **Data) const;\n  void TryDetectingAMemoryLeak(const uint8_t *Data, size_t Size,\n                               bool DuringInitialCorpusExecution);\n\n  void HandleMalloc(size_t Size);\n  void AnnounceOutput(const uint8_t *Data, size_t Size);\n\nprivate:\n  void AlarmCallback();\n  void CrashCallback();\n  void ExitCallback();\n  void MaybeExitGracefully();\n  void CrashOnOverwrittenData();\n  void InterruptCallback();\n  void MutateAndTestOne();\n  void PurgeAllocator();\n  void ReportNewCoverage(InputInfo *II, const Unit &U);\n  void PrintPulseAndReportSlowInput(const uint8_t *Data, size_t Size);\n  void WriteToOutputCorpus(const Unit &U);\n  void WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix);\n  void PrintStats(const char *Where, const char *End = \"\\n\", size_t Units = 0);\n  void PrintStatusForNewUnit(const Unit &U, const char *Text);\n  void CheckExitOnSrcPosOrItem();\n\n  static void StaticDeathCallback();\n  void DumpCurrentUnit(const char *Prefix);\n  void DeathCallback();\n\n  void AllocateCurrentUnitData();\n  uint8_t *CurrentUnitData = nullptr;\n  std::atomic<size_t> CurrentUnitSize;\n  uint8_t BaseSha1[kSHA1NumBytes];  // Checksum of the base unit.\n  bool RunningCB = false;\n\n  bool GracefulExitRequested = false;\n\n  size_t TotalNumberOfRuns = 0;\n  size_t NumberOfNewUnitsAdded = 0;\n\n  size_t LastCorpusUpdateRun = 0;\n\n  bool HasMoreMallocsThanFrees = false;\n  size_t NumberOfLeakDetectionAttempts = 0;\n\n  system_clock::time_point LastAllocatorPurgeAttemptTime = system_clock::now();\n\n  UserCallback CB;\n  InputCorpus &Corpus;\n  MutationDispatcher &MD;\n  FuzzingOptions Options;\n\n  system_clock::time_point ProcessStartTime = system_clock::now();\n  system_clock::time_point UnitStartTime, UnitStopTime;\n  long TimeOfLongestUnitInSeconds = 0;\n  long EpochOfLastReadOfOutputCorpus = 0;\n\n  size_t MaxInputLen = 0;\n  size_t MaxMutationLen = 0;\n  size_t TmpMaxMutationLen = 0;\n\n  Vector<uint32_t> UniqFeatureSetTmp;\n\n  // Need to know our own thread.\n  static thread_local bool IsMyThread;\n};\n\n} // namespace fuzzer\n\n#endif // LLVM_FUZZER_INTERNAL_H\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerLoop.cpp",
    "content": "//===- FuzzerLoop.cpp - Fuzzer's main loop --------------------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Fuzzer's main loop.\n//===----------------------------------------------------------------------===//\n\n#include \"FuzzerCorpus.h\"\n#include \"FuzzerIO.h\"\n#include \"FuzzerInternal.h\"\n#include \"FuzzerMutate.h\"\n#include \"FuzzerRandom.h\"\n#include \"FuzzerShmem.h\"\n#include \"FuzzerTracePC.h\"\n#include <algorithm>\n#include <cstring>\n#include <memory>\n#include <mutex>\n#include <set>\n\n#if defined(__has_include)\n#if __has_include(<sanitizer / lsan_interface.h>)\n#include <sanitizer/lsan_interface.h>\n#endif\n#endif\n\n#define NO_SANITIZE_MEMORY\n#if defined(__has_feature)\n#if __has_feature(memory_sanitizer)\n#undef NO_SANITIZE_MEMORY\n#define NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory))\n#endif\n#endif\n\nnamespace fuzzer {\nstatic const size_t kMaxUnitSizeToPrint = 256;\n\nthread_local bool Fuzzer::IsMyThread;\n\nSharedMemoryRegion SMR;\n\n// Only one Fuzzer per process.\nstatic Fuzzer *F;\n\n// Leak detection is expensive, so we first check if there were more mallocs\n// than frees (using the sanitizer malloc hooks) and only then try to call lsan.\nstruct MallocFreeTracer {\n  void Start(int TraceLevel) {\n    this->TraceLevel = TraceLevel;\n    if (TraceLevel)\n      Printf(\"MallocFreeTracer: START\\n\");\n    Mallocs = 0;\n    Frees = 0;\n  }\n  // Returns true if there were more mallocs than frees.\n  bool Stop() {\n    if (TraceLevel)\n      Printf(\"MallocFreeTracer: STOP %zd %zd (%s)\\n\", Mallocs.load(),\n             Frees.load(), Mallocs == Frees ? \"same\" : \"DIFFERENT\");\n    bool Result = Mallocs > Frees;\n    Mallocs = 0;\n    Frees = 0;\n    TraceLevel = 0;\n    return Result;\n  }\n  std::atomic<size_t> Mallocs;\n  std::atomic<size_t> Frees;\n  int TraceLevel = 0;\n\n  std::recursive_mutex TraceMutex;\n  bool TraceDisabled = false;\n};\n\nstatic MallocFreeTracer AllocTracer;\n\n// Locks printing and avoids nested hooks triggered from mallocs/frees in\n// sanitizer.\nclass TraceLock {\npublic:\n  TraceLock() : Lock(AllocTracer.TraceMutex) {\n    AllocTracer.TraceDisabled = !AllocTracer.TraceDisabled;\n  }\n  ~TraceLock() { AllocTracer.TraceDisabled = !AllocTracer.TraceDisabled; }\n\n  bool IsDisabled() const {\n    // This is already inverted value.\n    return !AllocTracer.TraceDisabled;\n  }\n\nprivate:\n  std::lock_guard<std::recursive_mutex> Lock;\n};\n\nATTRIBUTE_NO_SANITIZE_MEMORY\nvoid MallocHook(const volatile void *ptr, size_t size) {\n  size_t N = AllocTracer.Mallocs++;\n  F->HandleMalloc(size);\n  if (int TraceLevel = AllocTracer.TraceLevel) {\n    TraceLock Lock;\n    if (Lock.IsDisabled())\n      return;\n    Printf(\"MALLOC[%zd] %p %zd\\n\", N, ptr, size);\n    if (TraceLevel >= 2 && EF)\n      EF->__sanitizer_print_stack_trace();\n  }\n}\n\nATTRIBUTE_NO_SANITIZE_MEMORY\nvoid FreeHook(const volatile void *ptr) {\n  size_t N = AllocTracer.Frees++;\n  if (int TraceLevel = AllocTracer.TraceLevel) {\n    TraceLock Lock;\n    if (Lock.IsDisabled())\n      return;\n    Printf(\"FREE[%zd]   %p\\n\", N, ptr);\n    if (TraceLevel >= 2 && EF)\n      EF->__sanitizer_print_stack_trace();\n  }\n}\n\n// Crash on a single malloc that exceeds the rss limit.\nvoid Fuzzer::HandleMalloc(size_t Size) {\n  if (!Options.MallocLimitMb || (Size >> 20) < (size_t)Options.MallocLimitMb)\n    return;\n  Printf(\"==%d== ERROR: libFuzzer: out-of-memory (malloc(%zd))\\n\", GetPid(),\n         Size);\n  Printf(\"   To change the out-of-memory limit use -rss_limit_mb=<N>\\n\\n\");\n  if (EF->__sanitizer_print_stack_trace)\n    EF->__sanitizer_print_stack_trace();\n  DumpCurrentUnit(\"oom-\");\n  Printf(\"SUMMARY: libFuzzer: out-of-memory\\n\");\n  PrintFinalStats();\n  _Exit(Options.ErrorExitCode); // Stop right now.\n}\n\nFuzzer::Fuzzer(UserCallback CB, InputCorpus &Corpus, MutationDispatcher &MD,\n               FuzzingOptions Options)\n    : CB(CB), Corpus(Corpus), MD(MD), Options(Options) {\n  if (EF->__sanitizer_set_death_callback)\n    EF->__sanitizer_set_death_callback(StaticDeathCallback);\n  assert(!F);\n  F = this;\n  TPC.ResetMaps();\n  IsMyThread = true;\n  if (Options.DetectLeaks && EF->__sanitizer_install_malloc_and_free_hooks)\n    EF->__sanitizer_install_malloc_and_free_hooks(MallocHook, FreeHook);\n  TPC.SetUseCounters(Options.UseCounters);\n  TPC.SetUseValueProfile(Options.UseValueProfile);\n  TPC.SetUseClangCoverage(Options.UseClangCoverage);\n\n  if (Options.Verbosity)\n    TPC.PrintModuleInfo();\n  if (!Options.OutputCorpus.empty() && Options.ReloadIntervalSec)\n    EpochOfLastReadOfOutputCorpus = GetEpoch(Options.OutputCorpus);\n  MaxInputLen = MaxMutationLen = Options.MaxLen;\n  TmpMaxMutationLen = Max(size_t(4), Corpus.MaxInputSize());\n  AllocateCurrentUnitData();\n  CurrentUnitSize = 0;\n  memset(BaseSha1, 0, sizeof(BaseSha1));\n}\n\nFuzzer::~Fuzzer() {}\n\nvoid Fuzzer::AllocateCurrentUnitData() {\n  if (CurrentUnitData || MaxInputLen == 0)\n    return;\n  CurrentUnitData = new uint8_t[MaxInputLen];\n}\n\nvoid Fuzzer::StaticDeathCallback() {\n  assert(F);\n  F->DeathCallback();\n}\n\nvoid Fuzzer::DumpCurrentUnit(const char *Prefix) {\n  if (!CurrentUnitData)\n    return; // Happens when running individual inputs.\n  MD.PrintMutationSequence();\n  Printf(\"; base unit: %s\\n\", Sha1ToString(BaseSha1).c_str());\n  size_t UnitSize = CurrentUnitSize;\n  if (UnitSize <= kMaxUnitSizeToPrint) {\n    PrintHexArray(CurrentUnitData, UnitSize, \"\\n\");\n    PrintASCII(CurrentUnitData, UnitSize, \"\\n\");\n  }\n  WriteUnitToFileWithPrefix({CurrentUnitData, CurrentUnitData + UnitSize},\n                            Prefix);\n}\n\nNO_SANITIZE_MEMORY\nvoid Fuzzer::DeathCallback() {\n  DumpCurrentUnit(\"crash-\");\n  PrintFinalStats();\n}\n\nvoid Fuzzer::StaticAlarmCallback() {\n  assert(F);\n  F->AlarmCallback();\n}\n\nvoid Fuzzer::StaticCrashSignalCallback() {\n  assert(F);\n  F->CrashCallback();\n}\n\nvoid Fuzzer::StaticExitCallback() {\n  assert(F);\n  F->ExitCallback();\n}\n\nvoid Fuzzer::StaticInterruptCallback() {\n  assert(F);\n  F->InterruptCallback();\n}\n\nvoid Fuzzer::StaticGracefulExitCallback() {\n  assert(F);\n  F->GracefulExitRequested = true;\n  Printf(\"INFO: signal received, trying to exit gracefully\\n\");\n}\n\nvoid Fuzzer::StaticFileSizeExceedCallback() {\n  Printf(\"==%lu== ERROR: libFuzzer: file size exceeded\\n\", GetPid());\n  exit(1);\n}\n\nvoid Fuzzer::CrashCallback() {\n  Printf(\"==%lu== ERROR: libFuzzer: deadly signal\\n\", GetPid());\n  if (EF->__sanitizer_print_stack_trace)\n    EF->__sanitizer_print_stack_trace();\n  Printf(\"NOTE: libFuzzer has rudimentary signal handlers.\\n\"\n         \"      Combine libFuzzer with AddressSanitizer or similar for better \"\n         \"crash reports.\\n\");\n  Printf(\"SUMMARY: libFuzzer: deadly signal\\n\");\n  DumpCurrentUnit(\"crash-\");\n  PrintFinalStats();\n  if (EF->LLVMFuzzerAtExit) {\n    EF->LLVMFuzzerAtExit();\n  }\n  _Exit(Options.ErrorExitCode); // Stop right now.\n}\n\nvoid Fuzzer::ExitCallback() {\n  if (!RunningCB)\n    return; // This exit did not come from the user callback\n  Printf(\"==%lu== ERROR: libFuzzer: fuzz target exited\\n\", GetPid());\n  if (EF->__sanitizer_print_stack_trace)\n    EF->__sanitizer_print_stack_trace();\n  Printf(\"SUMMARY: libFuzzer: fuzz target exited\\n\");\n  DumpCurrentUnit(\"crash-\");\n  PrintFinalStats();\n  if (EF->LLVMFuzzerAtExit) {\n    EF->LLVMFuzzerAtExit();\n  }\n  _Exit(Options.ErrorExitCode);\n}\n\nvoid Fuzzer::MaybeExitGracefully() {\n  if (!GracefulExitRequested) return;\n  Printf(\"==%lu== INFO: libFuzzer: exiting as requested\\n\", GetPid());\n  PrintFinalStats();\n  _Exit(0);\n}\n\nvoid Fuzzer::InterruptCallback() {\n  Printf(\"==%lu== libFuzzer: run interrupted; exiting\\n\", GetPid());\n  PrintFinalStats();\n  if (EF->LLVMFuzzerAtExit) {\n    EF->LLVMFuzzerAtExit();\n  }\n  _Exit(0); // Stop right now, don't perform any at-exit actions.\n}\n\nNO_SANITIZE_MEMORY\nvoid Fuzzer::AlarmCallback() {\n  assert(Options.UnitTimeoutSec > 0);\n  // In Windows Alarm callback is executed by a different thread.\n#if !LIBFUZZER_WINDOWS\n  if (!InFuzzingThread())\n    return;\n#endif\n  if (!RunningCB)\n    return; // We have not started running units yet.\n  size_t Seconds =\n      duration_cast<seconds>(system_clock::now() - UnitStartTime).count();\n  if (Seconds == 0)\n    return;\n  if (Options.Verbosity >= 2)\n    Printf(\"AlarmCallback %zd\\n\", Seconds);\n  if (Seconds >= (size_t)Options.UnitTimeoutSec) {\n    Printf(\"ALARM: working on the last Unit for %zd seconds\\n\", Seconds);\n    Printf(\"       and the timeout value is %d (use -timeout=N to change)\\n\",\n           Options.UnitTimeoutSec);\n    DumpCurrentUnit(\"timeout-\");\n    Printf(\"==%lu== ERROR: libFuzzer: timeout after %d seconds\\n\", GetPid(),\n           Seconds);\n    if (EF->__sanitizer_print_stack_trace)\n      EF->__sanitizer_print_stack_trace();\n    Printf(\"SUMMARY: libFuzzer: timeout\\n\");\n    PrintFinalStats();\n    _Exit(Options.TimeoutExitCode); // Stop right now.\n  }\n}\n\nvoid Fuzzer::RssLimitCallback() {\n  Printf(\n      \"==%lu== ERROR: libFuzzer: out-of-memory (used: %zdMb; limit: %zdMb)\\n\",\n      GetPid(), GetPeakRSSMb(), Options.RssLimitMb);\n  Printf(\"   To change the out-of-memory limit use -rss_limit_mb=<N>\\n\\n\");\n  if (EF->__sanitizer_print_memory_profile)\n    EF->__sanitizer_print_memory_profile(95, 8);\n  DumpCurrentUnit(\"oom-\");\n  Printf(\"SUMMARY: libFuzzer: out-of-memory\\n\");\n  PrintFinalStats();\n  _Exit(Options.ErrorExitCode); // Stop right now.\n}\n\nvoid Fuzzer::PrintStats(const char *Where, const char *End, size_t Units) {\n  size_t ExecPerSec = execPerSec();\n  if (!Options.Verbosity)\n    return;\n  Printf(\"#%zd\\t%s\", TotalNumberOfRuns, Where);\n  if (size_t N = TPC.GetTotalPCCoverage())\n    Printf(\" cov: %zd\", N);\n  if (size_t N = Corpus.NumFeatures())\n    Printf(\" ft: %zd\", N);\n  if (!Corpus.empty()) {\n    Printf(\" corp: %zd\", Corpus.NumActiveUnits());\n    if (size_t N = Corpus.SizeInBytes()) {\n      if (N < (1 << 14))\n        Printf(\"/%zdb\", N);\n      else if (N < (1 << 24))\n        Printf(\"/%zdKb\", N >> 10);\n      else\n        Printf(\"/%zdMb\", N >> 20);\n    }\n  }\n  if (Units)\n    Printf(\" units: %zd\", Units);\n\n  Printf(\" exec/s: %zd\", ExecPerSec);\n  Printf(\" rss: %zdMb\", GetPeakRSSMb());\n  Printf(\"%s\", End);\n}\n\nvoid Fuzzer::PrintFinalStats() {\n  if (Options.PrintCoverage)\n    TPC.PrintCoverage();\n  if (Options.DumpCoverage)\n    TPC.DumpCoverage();\n  if (Options.PrintCorpusStats)\n    Corpus.PrintStats();\n  if (!Options.PrintFinalStats)\n    return;\n  size_t ExecPerSec = execPerSec();\n  Printf(\"stat::number_of_executed_units: %zd\\n\", TotalNumberOfRuns);\n  Printf(\"stat::average_exec_per_sec:     %zd\\n\", ExecPerSec);\n  Printf(\"stat::new_units_added:          %zd\\n\", NumberOfNewUnitsAdded);\n  Printf(\"stat::slowest_unit_time_sec:    %zd\\n\", TimeOfLongestUnitInSeconds);\n  Printf(\"stat::peak_rss_mb:              %zd\\n\", GetPeakRSSMb());\n}\n\nvoid Fuzzer::SetMaxInputLen(size_t MaxInputLen) {\n  assert(this->MaxInputLen == 0); // Can only reset MaxInputLen from 0 to non-0.\n  assert(MaxInputLen);\n  this->MaxInputLen = MaxInputLen;\n  this->MaxMutationLen = MaxInputLen;\n  AllocateCurrentUnitData();\n  Printf(\"INFO: -max_len is not provided; \"\n         \"libFuzzer will not generate inputs larger than %zd bytes\\n\",\n         MaxInputLen);\n}\n\nvoid Fuzzer::SetMaxMutationLen(size_t MaxMutationLen) {\n  assert(MaxMutationLen && MaxMutationLen <= MaxInputLen);\n  this->MaxMutationLen = MaxMutationLen;\n}\n\nvoid Fuzzer::CheckExitOnSrcPosOrItem() {\n  if (!Options.ExitOnSrcPos.empty()) {\n    static auto *PCsSet = new Set<uintptr_t>;\n    auto HandlePC = [&](uintptr_t PC) {\n      if (!PCsSet->insert(PC).second)\n        return;\n      std::string Descr = DescribePC(\"%F %L\", PC + 1);\n      if (Descr.find(Options.ExitOnSrcPos) != std::string::npos) {\n        Printf(\"INFO: found line matching '%s', exiting.\\n\",\n               Options.ExitOnSrcPos.c_str());\n        _Exit(0);\n      }\n    };\n    TPC.ForEachObservedPC(HandlePC);\n  }\n  if (!Options.ExitOnItem.empty()) {\n    if (Corpus.HasUnit(Options.ExitOnItem)) {\n      Printf(\"INFO: found item with checksum '%s', exiting.\\n\",\n             Options.ExitOnItem.c_str());\n      _Exit(0);\n    }\n  }\n}\n\nvoid Fuzzer::RereadOutputCorpus(size_t MaxSize) {\n  if (Options.OutputCorpus.empty() || !Options.ReloadIntervalSec)\n    return;\n  Vector<Unit> AdditionalCorpus;\n  ReadDirToVectorOfUnits(Options.OutputCorpus.c_str(), &AdditionalCorpus,\n                         &EpochOfLastReadOfOutputCorpus, MaxSize,\n                         /*ExitOnError*/ false);\n  if (Options.Verbosity >= 2)\n    Printf(\"Reload: read %zd new units.\\n\", AdditionalCorpus.size());\n  bool Reloaded = false;\n  for (auto &U : AdditionalCorpus) {\n    if (U.size() > MaxSize)\n      U.resize(MaxSize);\n    if (!Corpus.HasUnit(U)) {\n      if (RunOne(U.data(), U.size())) {\n        CheckExitOnSrcPosOrItem();\n        Reloaded = true;\n      }\n    }\n  }\n  if (Reloaded)\n    PrintStats(\"RELOAD\");\n}\n\nvoid Fuzzer::PrintPulseAndReportSlowInput(const uint8_t *Data, size_t Size) {\n  auto TimeOfUnit =\n      duration_cast<seconds>(UnitStopTime - UnitStartTime).count();\n  if (!(TotalNumberOfRuns & (TotalNumberOfRuns - 1)) &&\n      secondsSinceProcessStartUp() >= 2)\n    PrintStats(\"pulse \");\n  if (TimeOfUnit > TimeOfLongestUnitInSeconds * 1.1 &&\n      TimeOfUnit >= Options.ReportSlowUnits) {\n    TimeOfLongestUnitInSeconds = TimeOfUnit;\n    Printf(\"Slowest unit: %zd s:\\n\", TimeOfLongestUnitInSeconds);\n    WriteUnitToFileWithPrefix({Data, Data + Size}, \"slow-unit-\");\n  }\n}\n\nbool Fuzzer::RunOne(const uint8_t *Data, size_t Size, bool MayDeleteFile,\n                    InputInfo *II, bool *FoundUniqFeatures) {\n  if (!Size)\n    return false;\n\n  ExecuteCallback(Data, Size);\n\n  UniqFeatureSetTmp.clear();\n  size_t FoundUniqFeaturesOfII = 0;\n  size_t NumUpdatesBefore = Corpus.NumFeatureUpdates();\n  TPC.CollectFeatures([&](size_t Feature) {\n    if (Options.UseFeatureFrequency)\n      Corpus.UpdateFeatureFrequency(Feature);\n    if (Corpus.AddFeature(Feature, Size, Options.Shrink))\n      UniqFeatureSetTmp.push_back(Feature);\n    if (Options.ReduceInputs && II)\n      if (std::binary_search(II->UniqFeatureSet.begin(),\n                             II->UniqFeatureSet.end(), Feature))\n        FoundUniqFeaturesOfII++;\n  });\n  if (FoundUniqFeatures)\n    *FoundUniqFeatures = FoundUniqFeaturesOfII;\n  PrintPulseAndReportSlowInput(Data, Size);\n  size_t NumNewFeatures = Corpus.NumFeatureUpdates() - NumUpdatesBefore;\n  if (NumNewFeatures) {\n    TPC.UpdateObservedPCs();\n    Corpus.AddToCorpus({Data, Data + Size}, NumNewFeatures, MayDeleteFile,\n                       UniqFeatureSetTmp);\n    return true;\n  }\n  if (II && FoundUniqFeaturesOfII &&\n      FoundUniqFeaturesOfII == II->UniqFeatureSet.size() &&\n      II->U.size() > Size) {\n    Corpus.Replace(II, {Data, Data + Size});\n    return true;\n  }\n  return false;\n}\n\nsize_t Fuzzer::GetCurrentUnitInFuzzingThead(const uint8_t **Data) const {\n  assert(InFuzzingThread());\n  *Data = CurrentUnitData;\n  return CurrentUnitSize;\n}\n\nvoid Fuzzer::CrashOnOverwrittenData() {\n  Printf(\"==%d== ERROR: libFuzzer: fuzz target overwrites it's const input\\n\",\n         GetPid());\n  DumpCurrentUnit(\"crash-\");\n  Printf(\"SUMMARY: libFuzzer: out-of-memory\\n\");\n  _Exit(Options.ErrorExitCode); // Stop right now.\n}\n\n// Compare two arrays, but not all bytes if the arrays are large.\nstatic bool LooseMemeq(const uint8_t *A, const uint8_t *B, size_t Size) {\n  const size_t Limit = 64;\n  if (Size <= 64)\n    return !memcmp(A, B, Size);\n  // Compare first and last Limit/2 bytes.\n  return !memcmp(A, B, Limit / 2) &&\n         !memcmp(A + Size - Limit / 2, B + Size - Limit / 2, Limit / 2);\n}\n\nvoid Fuzzer::ExecuteCallback(const uint8_t *Data, size_t Size) {\n  TPC.RecordInitialStack();\n  TotalNumberOfRuns++;\n  assert(InFuzzingThread());\n  if (SMR.IsClient())\n    SMR.WriteByteArray(Data, Size);\n  // We copy the contents of Unit into a separate heap buffer\n  // so that we reliably find buffer overflows in it.\n  uint8_t *DataCopy = new uint8_t[Size];\n  memcpy(DataCopy, Data, Size);\n  if (CurrentUnitData && CurrentUnitData != Data)\n    memcpy(CurrentUnitData, Data, Size);\n  CurrentUnitSize = Size;\n  AllocTracer.Start(Options.TraceMalloc);\n  UnitStartTime = system_clock::now();\n  TPC.ResetMaps();\n  RunningCB = true;\n  int Res = CB(DataCopy, Size);\n  RunningCB = false;\n  UnitStopTime = system_clock::now();\n  (void)Res;\n  assert(Res == 0);\n  HasMoreMallocsThanFrees = AllocTracer.Stop();\n  if (!LooseMemeq(DataCopy, Data, Size))\n    CrashOnOverwrittenData();\n  CurrentUnitSize = 0;\n  delete[] DataCopy;\n}\n\nvoid Fuzzer::WriteToOutputCorpus(const Unit &U) {\n  if (Options.OnlyASCII)\n    assert(IsASCII(U));\n  if (Options.OutputCorpus.empty())\n    return;\n  std::string Path = DirPlusFile(Options.OutputCorpus, Hash(U));\n  WriteToFile(U, Path);\n  if (Options.Verbosity >= 2)\n    Printf(\"Written %zd bytes to %s\\n\", U.size(), Path.c_str());\n}\n\nvoid Fuzzer::WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix) {\n  if (!Options.SaveArtifacts)\n    return;\n  std::string Path = Options.ArtifactPrefix + Prefix + Hash(U);\n  if (!Options.ExactArtifactPath.empty())\n    Path = Options.ExactArtifactPath; // Overrides ArtifactPrefix.\n  WriteToFile(U, Path);\n  Printf(\"artifact_prefix='%s'; Test unit written to %s\\n\",\n         Options.ArtifactPrefix.c_str(), Path.c_str());\n  if (U.size() <= kMaxUnitSizeToPrint)\n    Printf(\"Base64: %s\\n\", Base64(U).c_str());\n}\n\nvoid Fuzzer::PrintStatusForNewUnit(const Unit &U, const char *Text) {\n  if (!Options.PrintNEW)\n    return;\n  PrintStats(Text, \"\");\n  if (Options.Verbosity) {\n    Printf(\" L: %zd/%zd \", U.size(), Corpus.MaxInputSize());\n    MD.PrintMutationSequence();\n    Printf(\"\\n\");\n  }\n}\n\nvoid Fuzzer::ReportNewCoverage(InputInfo *II, const Unit &U) {\n  II->NumSuccessfullMutations++;\n  MD.RecordSuccessfulMutationSequence();\n  PrintStatusForNewUnit(U, II->Reduced ? \"REDUCE\" : \"NEW   \");\n  WriteToOutputCorpus(U);\n  NumberOfNewUnitsAdded++;\n  CheckExitOnSrcPosOrItem(); // Check only after the unit is saved to corpus.\n  LastCorpusUpdateRun = TotalNumberOfRuns;\n}\n\n// Tries detecting a memory leak on the particular input that we have just\n// executed before calling this function.\nvoid Fuzzer::TryDetectingAMemoryLeak(const uint8_t *Data, size_t Size,\n                                     bool DuringInitialCorpusExecution) {\n  if (!HasMoreMallocsThanFrees)\n    return; // mallocs==frees, a leak is unlikely.\n  if (!Options.DetectLeaks)\n    return;\n  if (!DuringInitialCorpusExecution &&\n      TotalNumberOfRuns >= Options.MaxNumberOfRuns)\n    return;\n  if (!&(EF->__lsan_enable) || !&(EF->__lsan_disable) ||\n      !(EF->__lsan_do_recoverable_leak_check))\n    return; // No lsan.\n  // Run the target once again, but with lsan disabled so that if there is\n  // a real leak we do not report it twice.\n  EF->__lsan_disable();\n  ExecuteCallback(Data, Size);\n  EF->__lsan_enable();\n  if (!HasMoreMallocsThanFrees)\n    return; // a leak is unlikely.\n  if (NumberOfLeakDetectionAttempts++ > 1000) {\n    Options.DetectLeaks = false;\n    Printf(\"INFO: libFuzzer disabled leak detection after every mutation.\\n\"\n           \"      Most likely the target function accumulates allocated\\n\"\n           \"      memory in a global state w/o actually leaking it.\\n\"\n           \"      You may try running this binary with -trace_malloc=[12]\"\n           \"      to get a trace of mallocs and frees.\\n\"\n           \"      If LeakSanitizer is enabled in this process it will still\\n\"\n           \"      run on the process shutdown.\\n\");\n    return;\n  }\n  // Now perform the actual lsan pass. This is expensive and we must ensure\n  // we don't call it too often.\n  if (EF->__lsan_do_recoverable_leak_check()) { // Leak is found, report it.\n    if (DuringInitialCorpusExecution)\n      Printf(\"\\nINFO: a leak has been found in the initial corpus.\\n\\n\");\n    Printf(\"INFO: to ignore leaks on libFuzzer side use -detect_leaks=0.\\n\\n\");\n    CurrentUnitSize = Size;\n    DumpCurrentUnit(\"leak-\");\n    PrintFinalStats();\n    _Exit(Options.ErrorExitCode); // not exit() to disable lsan further on.\n  }\n}\n\nvoid Fuzzer::MutateAndTestOne() {\n  MD.StartMutationSequence();\n\n  auto &II = Corpus.ChooseUnitToMutate(MD.GetRand());\n  if (Options.UseFeatureFrequency)\n    Corpus.UpdateFeatureFrequencyScore(&II);\n  const auto &U = II.U;\n  memcpy(BaseSha1, II.Sha1, sizeof(BaseSha1));\n  assert(CurrentUnitData);\n  size_t Size = U.size();\n  assert(Size <= MaxInputLen && \"Oversized Unit\");\n  memcpy(CurrentUnitData, U.data(), Size);\n\n  assert(MaxMutationLen > 0);\n\n  size_t CurrentMaxMutationLen =\n      Min(MaxMutationLen, Max(U.size(), TmpMaxMutationLen));\n  assert(CurrentMaxMutationLen > 0);\n\n  for (int i = 0; i < Options.MutateDepth; i++) {\n    if (TotalNumberOfRuns >= Options.MaxNumberOfRuns)\n      break;\n    MaybeExitGracefully();\n    size_t NewSize = 0;\n    NewSize = MD.Mutate(CurrentUnitData, Size, CurrentMaxMutationLen);\n    assert(NewSize > 0 && \"Mutator returned empty unit\");\n    assert(NewSize <= CurrentMaxMutationLen && \"Mutator return oversized unit\");\n    Size = NewSize;\n    II.NumExecutedMutations++;\n\n    bool FoundUniqFeatures = false;\n    bool NewCov = RunOne(CurrentUnitData, Size, /*MayDeleteFile=*/true, &II,\n                         &FoundUniqFeatures);\n    TryDetectingAMemoryLeak(CurrentUnitData, Size,\n                            /*DuringInitialCorpusExecution*/ false);\n    if (NewCov) {\n      ReportNewCoverage(&II, {CurrentUnitData, CurrentUnitData + Size});\n      break;  // We will mutate this input more in the next rounds.\n    }\n    if (Options.ReduceDepth && !FoundUniqFeatures)\n        break;\n  }\n}\n\nvoid Fuzzer::PurgeAllocator() {\n  if (Options.PurgeAllocatorIntervalSec < 0 || !EF->__sanitizer_purge_allocator)\n    return;\n  if (duration_cast<seconds>(system_clock::now() -\n                             LastAllocatorPurgeAttemptTime)\n          .count() < Options.PurgeAllocatorIntervalSec)\n    return;\n\n  if (Options.RssLimitMb <= 0 ||\n      GetPeakRSSMb() > static_cast<size_t>(Options.RssLimitMb) / 2)\n    EF->__sanitizer_purge_allocator();\n\n  LastAllocatorPurgeAttemptTime = system_clock::now();\n}\n\nvoid Fuzzer::ReadAndExecuteSeedCorpora(const Vector<std::string> &CorpusDirs) {\n  const size_t kMaxSaneLen = 1 << 20;\n  const size_t kMinDefaultLen = 4096;\n  Vector<SizedFile> SizedFiles;\n  size_t MaxSize = 0;\n  size_t MinSize = -1;\n  size_t TotalSize = 0;\n  size_t LastNumFiles = 0;\n  for (auto &Dir : CorpusDirs) {\n    GetSizedFilesFromDir(Dir, &SizedFiles);\n    Printf(\"INFO: % 8zd files found in %s\\n\", SizedFiles.size() - LastNumFiles,\n           Dir.c_str());\n    LastNumFiles = SizedFiles.size();\n  }\n  for (auto &File : SizedFiles) {\n    MaxSize = Max(File.Size, MaxSize);\n    MinSize = Min(File.Size, MinSize);\n    TotalSize += File.Size;\n  }\n  if (Options.MaxLen == 0)\n    SetMaxInputLen(std::min(std::max(kMinDefaultLen, MaxSize), kMaxSaneLen));\n  assert(MaxInputLen > 0);\n\n  // Test the callback with empty input and never try it again.\n  uint8_t dummy = 0;\n  ExecuteCallback(&dummy, 0);\n\n  if (SizedFiles.empty()) {\n    Printf(\"INFO: A corpus is not provided, starting from an empty corpus\\n\");\n    Unit U({'\\n'}); // Valid ASCII input.\n    RunOne(U.data(), U.size());\n  } else {\n    Printf(\"INFO: seed corpus: files: %zd min: %zdb max: %zdb total: %zdb\"\n           \" rss: %zdMb\\n\",\n           SizedFiles.size(), MinSize, MaxSize, TotalSize, GetPeakRSSMb());\n    if (Options.ShuffleAtStartUp)\n      std::shuffle(SizedFiles.begin(), SizedFiles.end(), MD.GetRand());\n\n    if (Options.PreferSmall) {\n      std::stable_sort(SizedFiles.begin(), SizedFiles.end());\n      assert(SizedFiles.front().Size <= SizedFiles.back().Size);\n    }\n\n    // Load and execute inputs one by one.\n    for (auto &SF : SizedFiles) {\n      auto U = FileToVector(SF.File, MaxInputLen, /*ExitOnError=*/false);\n      assert(U.size() <= MaxInputLen);\n      RunOne(U.data(), U.size());\n      CheckExitOnSrcPosOrItem();\n      TryDetectingAMemoryLeak(U.data(), U.size(),\n                              /*DuringInitialCorpusExecution*/ true);\n    }\n  }\n\n  PrintStats(\"INITED\");\n  if (Corpus.empty()) {\n    Printf(\"ERROR: no interesting inputs were found. \"\n           \"Is the code instrumented for coverage? Exiting.\\n\");\n    exit(1);\n  }\n}\n\nvoid Fuzzer::Loop(const Vector<std::string> &CorpusDirs) {\n  ReadAndExecuteSeedCorpora(CorpusDirs);\n  TPC.SetPrintNewPCs(Options.PrintNewCovPcs);\n  TPC.SetPrintNewFuncs(Options.PrintNewCovFuncs);\n  system_clock::time_point LastCorpusReload = system_clock::now();\n  if (Options.DoCrossOver)\n    MD.SetCorpus(&Corpus);\n  while (true) {\n    auto Now = system_clock::now();\n    if (duration_cast<seconds>(Now - LastCorpusReload).count() >=\n        Options.ReloadIntervalSec) {\n      RereadOutputCorpus(MaxInputLen);\n      LastCorpusReload = system_clock::now();\n    }\n    if (TotalNumberOfRuns >= Options.MaxNumberOfRuns)\n      break;\n    if (TimedOut())\n      break;\n\n    // Update TmpMaxMutationLen\n    if (Options.ExperimentalLenControl) {\n      if (TmpMaxMutationLen < MaxMutationLen &&\n          TotalNumberOfRuns - LastCorpusUpdateRun >\n              Options.ExperimentalLenControl * Log(TmpMaxMutationLen)) {\n        TmpMaxMutationLen =\n            Min(MaxMutationLen, TmpMaxMutationLen + Log(TmpMaxMutationLen));\n        if (TmpMaxMutationLen <= MaxMutationLen)\n          Printf(\"#%zd\\tTEMP_MAX_LEN: %zd (%zd %zd)\\n\", TotalNumberOfRuns,\n                 TmpMaxMutationLen, Options.ExperimentalLenControl,\n                 LastCorpusUpdateRun);\n        LastCorpusUpdateRun = TotalNumberOfRuns;\n      }\n    } else {\n      TmpMaxMutationLen = MaxMutationLen;\n    }\n\n    // Perform several mutations and runs.\n    MutateAndTestOne();\n\n    PurgeAllocator();\n  }\n\n  PrintStats(\"DONE  \", \"\\n\");\n  MD.PrintRecommendedDictionary();\n}\n\nvoid Fuzzer::MinimizeCrashLoop(const Unit &U) {\n  if (U.size() <= 1)\n    return;\n  while (!TimedOut() && TotalNumberOfRuns < Options.MaxNumberOfRuns) {\n    MD.StartMutationSequence();\n    memcpy(CurrentUnitData, U.data(), U.size());\n    for (int i = 0; i < Options.MutateDepth; i++) {\n      size_t NewSize = MD.Mutate(CurrentUnitData, U.size(), MaxMutationLen);\n      assert(NewSize > 0 && NewSize <= MaxMutationLen);\n      ExecuteCallback(CurrentUnitData, NewSize);\n      PrintPulseAndReportSlowInput(CurrentUnitData, NewSize);\n      TryDetectingAMemoryLeak(CurrentUnitData, NewSize,\n                              /*DuringInitialCorpusExecution*/ false);\n    }\n  }\n}\n\nvoid Fuzzer::AnnounceOutput(const uint8_t *Data, size_t Size) {\n  if (SMR.IsServer()) {\n    SMR.WriteByteArray(Data, Size);\n  } else if (SMR.IsClient()) {\n    SMR.PostClient();\n    SMR.WaitServer();\n    size_t OtherSize = SMR.ReadByteArraySize();\n    uint8_t *OtherData = SMR.GetByteArray();\n    if (Size != OtherSize || memcmp(Data, OtherData, Size) != 0) {\n      size_t i = 0;\n      for (i = 0; i < Min(Size, OtherSize); i++)\n        if (Data[i] != OtherData[i])\n          break;\n      Printf(\"==%lu== ERROR: libFuzzer: equivalence-mismatch. Sizes: %zd %zd; \"\n             \"offset %zd\\n\",\n             GetPid(), Size, OtherSize, i);\n      DumpCurrentUnit(\"mismatch-\");\n      Printf(\"SUMMARY: libFuzzer: equivalence-mismatch\\n\");\n      PrintFinalStats();\n      _Exit(Options.ErrorExitCode);\n    }\n  }\n}\n\n} // namespace fuzzer\n\nextern \"C\" {\n\nsize_t LLVMFuzzerMutate(uint8_t *Data, size_t Size, size_t MaxSize) {\n  assert(fuzzer::F);\n  return fuzzer::F->GetMD().DefaultMutate(Data, Size, MaxSize);\n}\n\n// Experimental\nvoid LLVMFuzzerAnnounceOutput(const uint8_t *Data, size_t Size) {\n  assert(fuzzer::F);\n  fuzzer::F->AnnounceOutput(Data, Size);\n}\n} // extern \"C\"\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerMain.cpp",
    "content": "//===- FuzzerMain.cpp - main() function and flags -------------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// main() and flags.\n//===----------------------------------------------------------------------===//\n\n#include \"FuzzerDefs.h\"\n\nextern \"C\" {\n// This function should be defined by the user.\nint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);\n}  // extern \"C\"\n\nint main(int argc, char **argv) {\n  return fuzzer::FuzzerDriver(&argc, &argv, LLVMFuzzerTestOneInput);\n}\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerMerge.cpp",
    "content": "//===- FuzzerMerge.cpp - merging corpora ----------------------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Merging corpora.\n//===----------------------------------------------------------------------===//\n\n#include \"FuzzerCommand.h\"\n#include \"FuzzerMerge.h\"\n#include \"FuzzerIO.h\"\n#include \"FuzzerInternal.h\"\n#include \"FuzzerTracePC.h\"\n#include \"FuzzerUtil.h\"\n\n#include <fstream>\n#include <iterator>\n#include <set>\n#include <sstream>\n\nnamespace fuzzer {\n\nbool Merger::Parse(const std::string &Str, bool ParseCoverage) {\n  std::istringstream SS(Str);\n  return Parse(SS, ParseCoverage);\n}\n\nvoid Merger::ParseOrExit(std::istream &IS, bool ParseCoverage) {\n  if (!Parse(IS, ParseCoverage)) {\n    Printf(\"MERGE: failed to parse the control file (unexpected error)\\n\");\n    exit(1);\n  }\n}\n\n// The control file example:\n//\n// 3 # The number of inputs\n// 1 # The number of inputs in the first corpus, <= the previous number\n// file0\n// file1\n// file2  # One file name per line.\n// STARTED 0 123  # FileID, file size\n// DONE 0 1 4 6 8  # FileID COV1 COV2 ...\n// STARTED 1 456  # If DONE is missing, the input crashed while processing.\n// STARTED 2 567\n// DONE 2 8 9\nbool Merger::Parse(std::istream &IS, bool ParseCoverage) {\n  LastFailure.clear();\n  std::string Line;\n\n  // Parse NumFiles.\n  if (!std::getline(IS, Line, '\\n')) return false;\n  std::istringstream L1(Line);\n  size_t NumFiles = 0;\n  L1 >> NumFiles;\n  if (NumFiles == 0 || NumFiles > 10000000) return false;\n\n  // Parse NumFilesInFirstCorpus.\n  if (!std::getline(IS, Line, '\\n')) return false;\n  std::istringstream L2(Line);\n  NumFilesInFirstCorpus = NumFiles + 1;\n  L2 >> NumFilesInFirstCorpus;\n  if (NumFilesInFirstCorpus > NumFiles) return false;\n\n  // Parse file names.\n  Files.resize(NumFiles);\n  for (size_t i = 0; i < NumFiles; i++)\n    if (!std::getline(IS, Files[i].Name, '\\n'))\n      return false;\n\n  // Parse STARTED and DONE lines.\n  size_t ExpectedStartMarker = 0;\n  const size_t kInvalidStartMarker = -1;\n  size_t LastSeenStartMarker = kInvalidStartMarker;\n  Vector<uint32_t> TmpFeatures;\n  while (std::getline(IS, Line, '\\n')) {\n    std::istringstream ISS1(Line);\n    std::string Marker;\n    size_t N;\n    ISS1 >> Marker;\n    ISS1 >> N;\n    if (Marker == \"STARTED\") {\n      // STARTED FILE_ID FILE_SIZE\n      if (ExpectedStartMarker != N)\n        return false;\n      ISS1 >> Files[ExpectedStartMarker].Size;\n      LastSeenStartMarker = ExpectedStartMarker;\n      assert(ExpectedStartMarker < Files.size());\n      ExpectedStartMarker++;\n    } else if (Marker == \"DONE\") {\n      // DONE FILE_ID COV1 COV2 COV3 ...\n      size_t CurrentFileIdx = N;\n      if (CurrentFileIdx != LastSeenStartMarker)\n        return false;\n      LastSeenStartMarker = kInvalidStartMarker;\n      if (ParseCoverage) {\n        TmpFeatures.clear();  // use a vector from outer scope to avoid resizes.\n        while (ISS1 >> std::hex >> N)\n          TmpFeatures.push_back(N);\n        std::sort(TmpFeatures.begin(), TmpFeatures.end());\n        Files[CurrentFileIdx].Features = TmpFeatures;\n      }\n    } else {\n      return false;\n    }\n  }\n  if (LastSeenStartMarker != kInvalidStartMarker)\n    LastFailure = Files[LastSeenStartMarker].Name;\n\n  FirstNotProcessedFile = ExpectedStartMarker;\n  return true;\n}\n\nsize_t Merger::ApproximateMemoryConsumption() const  {\n  size_t Res = 0;\n  for (const auto &F: Files)\n    Res += sizeof(F) + F.Features.size() * sizeof(F.Features[0]);\n  return Res;\n}\n\n// Decides which files need to be merged (add thost to NewFiles).\n// Returns the number of new features added.\nsize_t Merger::Merge(const Set<uint32_t> &InitialFeatures,\n                     Vector<std::string> *NewFiles) {\n  NewFiles->clear();\n  assert(NumFilesInFirstCorpus <= Files.size());\n  Set<uint32_t> AllFeatures(InitialFeatures);\n\n  // What features are in the initial corpus?\n  for (size_t i = 0; i < NumFilesInFirstCorpus; i++) {\n    auto &Cur = Files[i].Features;\n    AllFeatures.insert(Cur.begin(), Cur.end());\n  }\n  size_t InitialNumFeatures = AllFeatures.size();\n\n  // Remove all features that we already know from all other inputs.\n  for (size_t i = NumFilesInFirstCorpus; i < Files.size(); i++) {\n    auto &Cur = Files[i].Features;\n    Vector<uint32_t> Tmp;\n    std::set_difference(Cur.begin(), Cur.end(), AllFeatures.begin(),\n                        AllFeatures.end(), std::inserter(Tmp, Tmp.begin()));\n    Cur.swap(Tmp);\n  }\n\n  // Sort. Give preference to\n  //   * smaller files\n  //   * files with more features.\n  std::sort(Files.begin() + NumFilesInFirstCorpus, Files.end(),\n            [&](const MergeFileInfo &a, const MergeFileInfo &b) -> bool {\n              if (a.Size != b.Size)\n                return a.Size < b.Size;\n              return a.Features.size() > b.Features.size();\n            });\n\n  // One greedy pass: add the file's features to AllFeatures.\n  // If new features were added, add this file to NewFiles.\n  for (size_t i = NumFilesInFirstCorpus; i < Files.size(); i++) {\n    auto &Cur = Files[i].Features;\n    // Printf(\"%s -> sz %zd ft %zd\\n\", Files[i].Name.c_str(),\n    //       Files[i].Size, Cur.size());\n    size_t OldSize = AllFeatures.size();\n    AllFeatures.insert(Cur.begin(), Cur.end());\n    if (AllFeatures.size() > OldSize)\n      NewFiles->push_back(Files[i].Name);\n  }\n  return AllFeatures.size() - InitialNumFeatures;\n}\n\nvoid Merger::PrintSummary(std::ostream &OS) {\n  for (auto &File : Files) {\n    OS << std::hex;\n    OS << File.Name << \" size: \" << File.Size << \" features: \";\n    for (auto Feature : File.Features)\n      OS << \" \" << Feature;\n    OS << \"\\n\";\n  }\n}\n\nSet<uint32_t> Merger::AllFeatures() const {\n  Set<uint32_t> S;\n  for (auto &File : Files)\n    S.insert(File.Features.begin(), File.Features.end());\n  return S;\n}\n\nSet<uint32_t> Merger::ParseSummary(std::istream &IS) {\n  std::string Line, Tmp;\n  Set<uint32_t> Res;\n  while (std::getline(IS, Line, '\\n')) {\n    size_t N;\n    std::istringstream ISS1(Line);\n    ISS1 >> Tmp;  // Name\n    ISS1 >> Tmp;  // size:\n    assert(Tmp == \"size:\" && \"Corrupt summary file\");\n    ISS1 >> std::hex;\n    ISS1 >> N;    // File Size\n    ISS1 >> Tmp;  // features:\n    assert(Tmp == \"features:\" && \"Corrupt summary file\");\n    while (ISS1 >> std::hex >> N)\n      Res.insert(N);\n  }\n  return Res;\n}\n\n// Inner process. May crash if the target crashes.\nvoid Fuzzer::CrashResistantMergeInternalStep(const std::string &CFPath) {\n  Printf(\"MERGE-INNER: using the control file '%s'\\n\", CFPath.c_str());\n  Merger M;\n  std::ifstream IF(CFPath);\n  M.ParseOrExit(IF, false);\n  IF.close();\n  if (!M.LastFailure.empty())\n    Printf(\"MERGE-INNER: '%s' caused a failure at the previous merge step\\n\",\n           M.LastFailure.c_str());\n\n  Printf(\"MERGE-INNER: %zd total files;\"\n         \" %zd processed earlier; will process %zd files now\\n\",\n         M.Files.size(), M.FirstNotProcessedFile,\n         M.Files.size() - M.FirstNotProcessedFile);\n\n  std::ofstream OF(CFPath, std::ofstream::out | std::ofstream::app);\n  Set<size_t> AllFeatures;\n  for (size_t i = M.FirstNotProcessedFile; i < M.Files.size(); i++) {\n    MaybeExitGracefully();\n    auto U = FileToVector(M.Files[i].Name);\n    if (U.size() > MaxInputLen) {\n      U.resize(MaxInputLen);\n      U.shrink_to_fit();\n    }\n    std::ostringstream StartedLine;\n    // Write the pre-run marker.\n    OF << \"STARTED \" << std::dec << i << \" \" << U.size() << \"\\n\";\n    OF.flush();  // Flush is important since Command::Execute may crash.\n    // Run.\n    TPC.ResetMaps();\n    ExecuteCallback(U.data(), U.size());\n    // Collect coverage. We are iterating over the files in this order:\n    // * First, files in the initial corpus ordered by size, smallest first.\n    // * Then, all other files, smallest first.\n    // So it makes no sense to record all features for all files, instead we\n    // only record features that were not seen before.\n    Set<size_t> UniqFeatures;\n    TPC.CollectFeatures([&](size_t Feature) {\n      if (AllFeatures.insert(Feature).second)\n        UniqFeatures.insert(Feature);\n    });\n    // Show stats.\n    if (!(TotalNumberOfRuns & (TotalNumberOfRuns - 1)))\n      PrintStats(\"pulse \");\n    // Write the post-run marker and the coverage.\n    OF << \"DONE \" << i;\n    for (size_t F : UniqFeatures)\n      OF << \" \" << std::hex << F;\n    OF << \"\\n\";\n    OF.flush();\n  }\n}\n\nstatic void WriteNewControlFile(const std::string &CFPath,\n                                const Vector<SizedFile> &AllFiles,\n                                size_t NumFilesInFirstCorpus) {\n  RemoveFile(CFPath);\n  std::ofstream ControlFile(CFPath);\n  ControlFile << AllFiles.size() << \"\\n\";\n  ControlFile << NumFilesInFirstCorpus << \"\\n\";\n  for (auto &SF: AllFiles)\n    ControlFile << SF.File << \"\\n\";\n  if (!ControlFile) {\n    Printf(\"MERGE-OUTER: failed to write to the control file: %s\\n\",\n           CFPath.c_str());\n    exit(1);\n  }\n}\n\n// Outer process. Does not call the target code and thus sohuld not fail.\nvoid Fuzzer::CrashResistantMerge(const Vector<std::string> &Args,\n                                 const Vector<std::string> &Corpora,\n                                 const char *CoverageSummaryInputPathOrNull,\n                                 const char *CoverageSummaryOutputPathOrNull,\n                                 const char *MergeControlFilePathOrNull) {\n  if (Corpora.size() <= 1) {\n    Printf(\"Merge requires two or more corpus dirs\\n\");\n    return;\n  }\n  auto CFPath =\n      MergeControlFilePathOrNull\n          ? MergeControlFilePathOrNull\n          : DirPlusFile(TmpDir(),\n                        \"libFuzzerTemp.\" + std::to_string(GetPid()) + \".txt\");\n\n  size_t NumAttempts = 0;\n  if (MergeControlFilePathOrNull && FileSize(MergeControlFilePathOrNull)) {\n    Printf(\"MERGE-OUTER: non-empty control file provided: '%s'\\n\",\n           MergeControlFilePathOrNull);\n    Merger M;\n    std::ifstream IF(MergeControlFilePathOrNull);\n    if (M.Parse(IF, /*ParseCoverage=*/false)) {\n      Printf(\"MERGE-OUTER: control file ok, %zd files total,\"\n             \" first not processed file %zd\\n\",\n             M.Files.size(), M.FirstNotProcessedFile);\n      if (!M.LastFailure.empty())\n        Printf(\"MERGE-OUTER: '%s' will be skipped as unlucky \"\n               \"(merge has stumbled on it the last time)\\n\",\n               M.LastFailure.c_str());\n      if (M.FirstNotProcessedFile >= M.Files.size()) {\n        Printf(\"MERGE-OUTER: nothing to do, merge has been completed before\\n\");\n        exit(0);\n      }\n\n      NumAttempts = M.Files.size() - M.FirstNotProcessedFile;\n    } else {\n      Printf(\"MERGE-OUTER: bad control file, will overwrite it\\n\");\n    }\n  }\n\n  if (!NumAttempts) {\n    // The supplied control file is empty or bad, create a fresh one.\n    Vector<SizedFile> AllFiles;\n    GetSizedFilesFromDir(Corpora[0], &AllFiles);\n    size_t NumFilesInFirstCorpus = AllFiles.size();\n    std::sort(AllFiles.begin(), AllFiles.end());\n    for (size_t i = 1; i < Corpora.size(); i++)\n      GetSizedFilesFromDir(Corpora[i], &AllFiles);\n    std::sort(AllFiles.begin() + NumFilesInFirstCorpus, AllFiles.end());\n    Printf(\"MERGE-OUTER: %zd files, %zd in the initial corpus\\n\",\n           AllFiles.size(), NumFilesInFirstCorpus);\n    WriteNewControlFile(CFPath, AllFiles, NumFilesInFirstCorpus);\n    NumAttempts = AllFiles.size();\n  }\n\n  // Execute the inner process until it passes.\n  // Every inner process should execute at least one input.\n  Command BaseCmd(Args);\n  BaseCmd.removeFlag(\"merge\");\n  bool Success = false;\n  for (size_t Attempt = 1; Attempt <= NumAttempts; Attempt++) {\n    MaybeExitGracefully();\n    Printf(\"MERGE-OUTER: attempt %zd\\n\", Attempt);\n    Command Cmd(BaseCmd);\n    Cmd.addFlag(\"merge_control_file\", CFPath);\n    Cmd.addFlag(\"merge_inner\", \"1\");\n    auto ExitCode = ExecuteCommand(Cmd);\n    if (!ExitCode) {\n      Printf(\"MERGE-OUTER: succesfull in %zd attempt(s)\\n\", Attempt);\n      Success = true;\n      break;\n    }\n  }\n  if (!Success) {\n    Printf(\"MERGE-OUTER: zero succesfull attempts, exiting\\n\");\n    exit(1);\n  }\n  // Read the control file and do the merge.\n  Merger M;\n  std::ifstream IF(CFPath);\n  IF.seekg(0, IF.end);\n  Printf(\"MERGE-OUTER: the control file has %zd bytes\\n\", (size_t)IF.tellg());\n  IF.seekg(0, IF.beg);\n  M.ParseOrExit(IF, true);\n  IF.close();\n  Printf(\"MERGE-OUTER: consumed %zdMb (%zdMb rss) to parse the control file\\n\",\n         M.ApproximateMemoryConsumption() >> 20, GetPeakRSSMb());\n  if (CoverageSummaryOutputPathOrNull) {\n    Printf(\"MERGE-OUTER: writing coverage summary for %zd files to %s\\n\",\n           M.Files.size(), CoverageSummaryOutputPathOrNull);\n    std::ofstream SummaryOut(CoverageSummaryOutputPathOrNull);\n    M.PrintSummary(SummaryOut);\n  }\n  Vector<std::string> NewFiles;\n  Set<uint32_t> InitialFeatures;\n  if (CoverageSummaryInputPathOrNull) {\n    std::ifstream SummaryIn(CoverageSummaryInputPathOrNull);\n    InitialFeatures = M.ParseSummary(SummaryIn);\n    Printf(\"MERGE-OUTER: coverage summary loaded from %s, %zd features found\\n\",\n           CoverageSummaryInputPathOrNull, InitialFeatures.size());\n  }\n  size_t NumNewFeatures = M.Merge(InitialFeatures, &NewFiles);\n  Printf(\"MERGE-OUTER: %zd new files with %zd new features added\\n\",\n         NewFiles.size(), NumNewFeatures);\n  for (auto &F: NewFiles)\n    WriteToOutputCorpus(FileToVector(F, MaxInputLen));\n  // We are done, delete the control file if it was a temporary one.\n  if (!MergeControlFilePathOrNull)\n    RemoveFile(CFPath);\n}\n\n} // namespace fuzzer\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerMerge.h",
    "content": "//===- FuzzerMerge.h - merging corpa ----------------------------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Merging Corpora.\n//\n// The task:\n//   Take the existing corpus (possibly empty) and merge new inputs into\n//   it so that only inputs with new coverage ('features') are added.\n//   The process should tolerate the crashes, OOMs, leaks, etc.\n//\n// Algorithm:\n//   The outter process collects the set of files and writes their names\n//   into a temporary \"control\" file, then repeatedly launches the inner\n//   process until all inputs are processed.\n//   The outer process does not actually execute the target code.\n//\n//   The inner process reads the control file and sees a) list of all the inputs\n//   and b) the last processed input. Then it starts processing the inputs one\n//   by one. Before processing every input it writes one line to control file:\n//   STARTED INPUT_ID INPUT_SIZE\n//   After processing an input it write another line:\n//   DONE INPUT_ID Feature1 Feature2 Feature3 ...\n//   If a crash happens while processing an input the last line in the control\n//   file will be \"STARTED INPUT_ID\" and so the next process will know\n//   where to resume.\n//\n//   Once all inputs are processed by the innner process(es) the outer process\n//   reads the control files and does the merge based entirely on the contents\n//   of control file.\n//   It uses a single pass greedy algorithm choosing first the smallest inputs\n//   within the same size the inputs that have more new features.\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_MERGE_H\n#define LLVM_FUZZER_MERGE_H\n\n#include \"FuzzerDefs.h\"\n\n#include <istream>\n#include <ostream>\n#include <set>\n#include <vector>\n\nnamespace fuzzer {\n\nstruct MergeFileInfo {\n  std::string Name;\n  size_t Size = 0;\n  Vector<uint32_t> Features;\n};\n\nstruct Merger {\n  Vector<MergeFileInfo> Files;\n  size_t NumFilesInFirstCorpus = 0;\n  size_t FirstNotProcessedFile = 0;\n  std::string LastFailure;\n\n  bool Parse(std::istream &IS, bool ParseCoverage);\n  bool Parse(const std::string &Str, bool ParseCoverage);\n  void ParseOrExit(std::istream &IS, bool ParseCoverage);\n  void PrintSummary(std::ostream &OS);\n  Set<uint32_t> ParseSummary(std::istream &IS);\n  size_t Merge(const Set<uint32_t> &InitialFeatures,\n               Vector<std::string> *NewFiles);\n  size_t Merge(Vector<std::string> *NewFiles) {\n    return Merge(Set<uint32_t>{}, NewFiles);\n  }\n  size_t ApproximateMemoryConsumption() const;\n  Set<uint32_t> AllFeatures() const;\n};\n\n}  // namespace fuzzer\n\n#endif  // LLVM_FUZZER_MERGE_H\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerMutate.cpp",
    "content": "//===- FuzzerMutate.cpp - Mutate a test input -----------------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Mutate a test input.\n//===----------------------------------------------------------------------===//\n\n#include \"FuzzerMutate.h\"\n#include \"FuzzerCorpus.h\"\n#include \"FuzzerDefs.h\"\n#include \"FuzzerExtFunctions.h\"\n#include \"FuzzerIO.h\"\n#include \"FuzzerOptions.h\"\n\nnamespace fuzzer {\n\nconst size_t Dictionary::kMaxDictSize;\n\nstatic void PrintASCII(const Word &W, const char *PrintAfter) {\n  PrintASCII(W.data(), W.size(), PrintAfter);\n}\n\nMutationDispatcher::MutationDispatcher(Random &Rand,\n                                       const FuzzingOptions &Options)\n    : Rand(Rand), Options(Options) {\n  if (Options.DefaultMutatorsResizeInput) {\n    Printf(\"INFO: Mutators that resize input enabled\\n\");\n    DefaultMutators.insert(\n        DefaultMutators.end(),\n        {\n            {&MutationDispatcher::Mutate_EraseBytes, \"EraseBytes\"},\n            {&MutationDispatcher::Mutate_InsertByte, \"InsertByte\"},\n            {&MutationDispatcher::Mutate_InsertRepeatedBytes,\n             \"InsertRepeatedBytes\"},\n        });\n  } else {\n    Printf(\"INFO: HACK: Mutators that resize input DISABLED!\\n\");\n  }\n\n  // These mutators don't change the input size (I think...)\n  // Okay technically MutateCopyPart will but it won't in the\n  // case that MaxSize == Size.\n  DefaultMutators.insert(\n      DefaultMutators.end(),\n      {\n          {&MutationDispatcher::Mutate_ChangeByte, \"ChangeByte\"},\n          {&MutationDispatcher::Mutate_ChangeBit, \"ChangeBit\"},\n          {&MutationDispatcher::Mutate_ShuffleBytes, \"ShuffleBytes\"},\n          {&MutationDispatcher::Mutate_ChangeASCIIInteger, \"ChangeASCIIInt\"},\n          {&MutationDispatcher::Mutate_ChangeBinaryInteger, \"ChangeBinInt\"},\n          {&MutationDispatcher::Mutate_CopyPart, \"CopyPart\"},\n          {&MutationDispatcher::Mutate_CrossOver, \"CrossOver\"},\n          {&MutationDispatcher::Mutate_AddWordFromManualDictionary,\n           \"ManualDict\"},\n          {&MutationDispatcher::Mutate_AddWordFromPersistentAutoDictionary,\n           \"PersAutoDict\"},\n      });\n  if(Options.UseCmp)\n    DefaultMutators.push_back(\n        {&MutationDispatcher::Mutate_AddWordFromTORC, \"CMP\"});\n\n  if (EF->LLVMFuzzerCustomMutator)\n    Mutators.push_back({&MutationDispatcher::Mutate_Custom, \"Custom\"});\n  else\n    Mutators = DefaultMutators;\n\n  if (EF->LLVMFuzzerCustomCrossOver)\n    Mutators.push_back(\n        {&MutationDispatcher::Mutate_CustomCrossOver, \"CustomCrossOver\"});\n}\n\nstatic char RandCh(Random &Rand) {\n  if (Rand.RandBool()) return Rand(256);\n  const char *Special = \"!*'();:@&=+$,/?%#[]012Az-`~.\\xff\\x00\";\n  return Special[Rand(sizeof(Special) - 1)];\n}\n\nsize_t MutationDispatcher::Mutate_Custom(uint8_t *Data, size_t Size,\n                                         size_t MaxSize) {\n  return EF->LLVMFuzzerCustomMutator(Data, Size, MaxSize, Rand.Rand());\n}\n\nsize_t MutationDispatcher::Mutate_CustomCrossOver(uint8_t *Data, size_t Size,\n                                                  size_t MaxSize) {\n  if (!Corpus || Corpus->size() < 2 || Size == 0)\n    return 0;\n  size_t Idx = Rand(Corpus->size());\n  const Unit &Other = (*Corpus)[Idx];\n  if (Other.empty())\n    return 0;\n  CustomCrossOverInPlaceHere.resize(MaxSize);\n  auto &U = CustomCrossOverInPlaceHere;\n  size_t NewSize = EF->LLVMFuzzerCustomCrossOver(\n      Data, Size, Other.data(), Other.size(), U.data(), U.size(), Rand.Rand());\n  if (!NewSize)\n    return 0;\n  assert(NewSize <= MaxSize && \"CustomCrossOver returned overisized unit\");\n  memcpy(Data, U.data(), NewSize);\n  return NewSize;\n}\n\nsize_t MutationDispatcher::Mutate_ShuffleBytes(uint8_t *Data, size_t Size,\n                                               size_t MaxSize) {\n  if (Size > MaxSize || Size == 0) return 0;\n  size_t ShuffleAmount =\n      Rand(std::min(Size, (size_t)8)) + 1; // [1,8] and <= Size.\n  size_t ShuffleStart = Rand(Size - ShuffleAmount);\n  assert(ShuffleStart + ShuffleAmount <= Size);\n  std::shuffle(Data + ShuffleStart, Data + ShuffleStart + ShuffleAmount, Rand);\n  return Size;\n}\n\nsize_t MutationDispatcher::Mutate_EraseBytes(uint8_t *Data, size_t Size,\n                                             size_t MaxSize) {\n  if (Size <= 1) return 0;\n  size_t N = Rand(Size / 2) + 1;\n  assert(N < Size);\n  size_t Idx = Rand(Size - N + 1);\n  // Erase Data[Idx:Idx+N].\n  memmove(Data + Idx, Data + Idx + N, Size - Idx - N);\n  // Printf(\"Erase: %zd %zd => %zd; Idx %zd\\n\", N, Size, Size - N, Idx);\n  return Size - N;\n}\n\nsize_t MutationDispatcher::Mutate_InsertByte(uint8_t *Data, size_t Size,\n                                             size_t MaxSize) {\n  if (Size >= MaxSize) return 0;\n  size_t Idx = Rand(Size + 1);\n  // Insert new value at Data[Idx].\n  memmove(Data + Idx + 1, Data + Idx, Size - Idx);\n  Data[Idx] = RandCh(Rand);\n  return Size + 1;\n}\n\nsize_t MutationDispatcher::Mutate_InsertRepeatedBytes(uint8_t *Data,\n                                                      size_t Size,\n                                                      size_t MaxSize) {\n  const size_t kMinBytesToInsert = 3;\n  if (Size + kMinBytesToInsert >= MaxSize) return 0;\n  size_t MaxBytesToInsert = std::min(MaxSize - Size, (size_t)128);\n  size_t N = Rand(MaxBytesToInsert - kMinBytesToInsert + 1) + kMinBytesToInsert;\n  assert(Size + N <= MaxSize && N);\n  size_t Idx = Rand(Size + 1);\n  // Insert new values at Data[Idx].\n  memmove(Data + Idx + N, Data + Idx, Size - Idx);\n  // Give preference to 0x00 and 0xff.\n  uint8_t Byte = Rand.RandBool() ? Rand(256) : (Rand.RandBool() ? 0 : 255);\n  for (size_t i = 0; i < N; i++)\n    Data[Idx + i] = Byte;\n  return Size + N;\n}\n\nsize_t MutationDispatcher::Mutate_ChangeByte(uint8_t *Data, size_t Size,\n                                             size_t MaxSize) {\n  if (Size > MaxSize) return 0;\n  size_t Idx = Rand(Size);\n  Data[Idx] = RandCh(Rand);\n  return Size;\n}\n\nsize_t MutationDispatcher::Mutate_ChangeBit(uint8_t *Data, size_t Size,\n                                            size_t MaxSize) {\n  if (Size > MaxSize) return 0;\n  size_t Idx = Rand(Size);\n  Data[Idx] ^= 1 << Rand(8);\n  return Size;\n}\n\nsize_t MutationDispatcher::Mutate_AddWordFromManualDictionary(uint8_t *Data,\n                                                              size_t Size,\n                                                              size_t MaxSize) {\n  return AddWordFromDictionary(ManualDictionary, Data, Size, MaxSize);\n}\n\nsize_t MutationDispatcher::ApplyDictionaryEntry(uint8_t *Data, size_t Size,\n                                                size_t MaxSize,\n                                                DictionaryEntry &DE) {\n  const Word &W = DE.GetW();\n  bool UsePositionHint = DE.HasPositionHint() &&\n                         DE.GetPositionHint() + W.size() < Size &&\n                         Rand.RandBool();\n  if (Rand.RandBool()) {  // Insert W.\n    if (Size + W.size() > MaxSize) return 0;\n    size_t Idx = UsePositionHint ? DE.GetPositionHint() : Rand(Size + 1);\n    memmove(Data + Idx + W.size(), Data + Idx, Size - Idx);\n    memcpy(Data + Idx, W.data(), W.size());\n    Size += W.size();\n  } else {  // Overwrite some bytes with W.\n    if (W.size() > Size) return 0;\n    size_t Idx = UsePositionHint ? DE.GetPositionHint() : Rand(Size - W.size());\n    memcpy(Data + Idx, W.data(), W.size());\n  }\n  return Size;\n}\n\n// Somewhere in the past we have observed a comparison instructions\n// with arguments Arg1 Arg2. This function tries to guess a dictionary\n// entry that will satisfy that comparison.\n// It first tries to find one of the arguments (possibly swapped) in the\n// input and if it succeeds it creates a DE with a position hint.\n// Otherwise it creates a DE with one of the arguments w/o a position hint.\nDictionaryEntry MutationDispatcher::MakeDictionaryEntryFromCMP(\n    const void *Arg1, const void *Arg2,\n    const void *Arg1Mutation, const void *Arg2Mutation,\n    size_t ArgSize, const uint8_t *Data,\n    size_t Size) {\n  ScopedDoingMyOwnMemOrStr scoped_doing_my_own_mem_os_str;\n  bool HandleFirst = Rand.RandBool();\n  const void *ExistingBytes, *DesiredBytes;\n  Word W;\n  const uint8_t *End = Data + Size;\n  for (int Arg = 0; Arg < 2; Arg++) {\n    ExistingBytes = HandleFirst ? Arg1 : Arg2;\n    DesiredBytes = HandleFirst ? Arg2Mutation : Arg1Mutation;\n    HandleFirst = !HandleFirst;\n    W.Set(reinterpret_cast<const uint8_t*>(DesiredBytes), ArgSize);\n    const size_t kMaxNumPositions = 8;\n    size_t Positions[kMaxNumPositions];\n    size_t NumPositions = 0;\n    for (const uint8_t *Cur = Data;\n         Cur < End && NumPositions < kMaxNumPositions; Cur++) {\n      Cur =\n          (const uint8_t *)SearchMemory(Cur, End - Cur, ExistingBytes, ArgSize);\n      if (!Cur) break;\n      Positions[NumPositions++] = Cur - Data;\n    }\n    if (!NumPositions) continue;\n    return DictionaryEntry(W, Positions[Rand(NumPositions)]);\n  }\n  DictionaryEntry DE(W);\n  return DE;\n}\n\n\ntemplate <class T>\nDictionaryEntry MutationDispatcher::MakeDictionaryEntryFromCMP(\n    T Arg1, T Arg2, const uint8_t *Data, size_t Size) {\n  if (Rand.RandBool()) Arg1 = Bswap(Arg1);\n  if (Rand.RandBool()) Arg2 = Bswap(Arg2);\n  T Arg1Mutation = Arg1 + Rand(-1, 1);\n  T Arg2Mutation = Arg2 + Rand(-1, 1);\n  return MakeDictionaryEntryFromCMP(&Arg1, &Arg2, &Arg1Mutation, &Arg2Mutation,\n                                    sizeof(Arg1), Data, Size);\n}\n\nDictionaryEntry MutationDispatcher::MakeDictionaryEntryFromCMP(\n    const Word &Arg1, const Word &Arg2, const uint8_t *Data, size_t Size) {\n  return MakeDictionaryEntryFromCMP(Arg1.data(), Arg2.data(), Arg1.data(),\n                                    Arg2.data(), Arg1.size(), Data, Size);\n}\n\nsize_t MutationDispatcher::Mutate_AddWordFromTORC(\n    uint8_t *Data, size_t Size, size_t MaxSize) {\n  Word W;\n  DictionaryEntry DE;\n  switch (Rand(4)) {\n  case 0: {\n    auto X = TPC.TORC8.Get(Rand.Rand());\n    DE = MakeDictionaryEntryFromCMP(X.A, X.B, Data, Size);\n  } break;\n  case 1: {\n    auto X = TPC.TORC4.Get(Rand.Rand());\n    if ((X.A >> 16) == 0 && (X.B >> 16) == 0 && Rand.RandBool())\n      DE = MakeDictionaryEntryFromCMP((uint16_t)X.A, (uint16_t)X.B, Data, Size);\n    else\n      DE = MakeDictionaryEntryFromCMP(X.A, X.B, Data, Size);\n  } break;\n  case 2: {\n    auto X = TPC.TORCW.Get(Rand.Rand());\n    DE = MakeDictionaryEntryFromCMP(X.A, X.B, Data, Size);\n  } break;\n  case 3: if (Options.UseMemmem) {\n    auto X = TPC.MMT.Get(Rand.Rand());\n    DE = DictionaryEntry(X);\n  } break;\n  default:\n    assert(0);\n  }\n  if (!DE.GetW().size()) return 0;\n  Size = ApplyDictionaryEntry(Data, Size, MaxSize, DE);\n  if (!Size) return 0;\n  DictionaryEntry &DERef =\n      CmpDictionaryEntriesDeque[CmpDictionaryEntriesDequeIdx++ %\n                                kCmpDictionaryEntriesDequeSize];\n  DERef = DE;\n  CurrentDictionaryEntrySequence.push_back(&DERef);\n  return Size;\n}\n\nsize_t MutationDispatcher::Mutate_AddWordFromPersistentAutoDictionary(\n    uint8_t *Data, size_t Size, size_t MaxSize) {\n  return AddWordFromDictionary(PersistentAutoDictionary, Data, Size, MaxSize);\n}\n\nsize_t MutationDispatcher::AddWordFromDictionary(Dictionary &D, uint8_t *Data,\n                                                 size_t Size, size_t MaxSize) {\n  if (Size > MaxSize) return 0;\n  if (D.empty()) return 0;\n  DictionaryEntry &DE = D[Rand(D.size())];\n  Size = ApplyDictionaryEntry(Data, Size, MaxSize, DE);\n  if (!Size) return 0;\n  DE.IncUseCount();\n  CurrentDictionaryEntrySequence.push_back(&DE);\n  return Size;\n}\n\n// Overwrites part of To[0,ToSize) with a part of From[0,FromSize).\n// Returns ToSize.\nsize_t MutationDispatcher::CopyPartOf(const uint8_t *From, size_t FromSize,\n                                      uint8_t *To, size_t ToSize) {\n  // Copy From[FromBeg, FromBeg + CopySize) into To[ToBeg, ToBeg + CopySize).\n  size_t ToBeg = Rand(ToSize);\n  size_t CopySize = Rand(ToSize - ToBeg) + 1;\n  assert(ToBeg + CopySize <= ToSize);\n  CopySize = std::min(CopySize, FromSize);\n  size_t FromBeg = Rand(FromSize - CopySize + 1);\n  assert(FromBeg + CopySize <= FromSize);\n  memmove(To + ToBeg, From + FromBeg, CopySize);\n  return ToSize;\n}\n\n// Inserts part of From[0,ToSize) into To.\n// Returns new size of To on success or 0 on failure.\nsize_t MutationDispatcher::InsertPartOf(const uint8_t *From, size_t FromSize,\n                                        uint8_t *To, size_t ToSize,\n                                        size_t MaxToSize) {\n  if (ToSize >= MaxToSize) return 0;\n  size_t AvailableSpace = MaxToSize - ToSize;\n  size_t MaxCopySize = std::min(AvailableSpace, FromSize);\n  size_t CopySize = Rand(MaxCopySize) + 1;\n  size_t FromBeg = Rand(FromSize - CopySize + 1);\n  assert(FromBeg + CopySize <= FromSize);\n  size_t ToInsertPos = Rand(ToSize + 1);\n  assert(ToInsertPos + CopySize <= MaxToSize);\n  size_t TailSize = ToSize - ToInsertPos;\n  if (To == From) {\n    MutateInPlaceHere.resize(MaxToSize);\n    memcpy(MutateInPlaceHere.data(), From + FromBeg, CopySize);\n    memmove(To + ToInsertPos + CopySize, To + ToInsertPos, TailSize);\n    memmove(To + ToInsertPos, MutateInPlaceHere.data(), CopySize);\n  } else {\n    memmove(To + ToInsertPos + CopySize, To + ToInsertPos, TailSize);\n    memmove(To + ToInsertPos, From + FromBeg, CopySize);\n  }\n  return ToSize + CopySize;\n}\n\nsize_t MutationDispatcher::Mutate_CopyPart(uint8_t *Data, size_t Size,\n                                           size_t MaxSize) {\n  if (Size > MaxSize || Size == 0) return 0;\n  // FIXME: Upstream this change. If Size == MaxSize, InsertPartOf will\n  // fail so there's no point using it in that case.\n  if (Size == MaxSize || Rand.RandBool())\n    return CopyPartOf(Data, Size, Data, Size);\n  else\n    return InsertPartOf(Data, Size, Data, Size, MaxSize);\n}\n\nsize_t MutationDispatcher::Mutate_ChangeASCIIInteger(uint8_t *Data, size_t Size,\n                                                     size_t MaxSize) {\n  if (Size > MaxSize) return 0;\n  size_t B = Rand(Size);\n  while (B < Size && !isdigit(Data[B])) B++;\n  if (B == Size) return 0;\n  size_t E = B;\n  while (E < Size && isdigit(Data[E])) E++;\n  assert(B < E);\n  // now we have digits in [B, E).\n  // strtol and friends don't accept non-zero-teminated data, parse it manually.\n  uint64_t Val = Data[B] - '0';\n  for (size_t i = B + 1; i < E; i++)\n    Val = Val * 10 + Data[i] - '0';\n\n  // Mutate the integer value.\n  switch(Rand(5)) {\n    case 0: Val++; break;\n    case 1: Val--; break;\n    case 2: Val /= 2; break;\n    case 3: Val *= 2; break;\n    case 4: Val = Rand(Val * Val); break;\n    default: assert(0);\n  }\n  // Just replace the bytes with the new ones, don't bother moving bytes.\n  for (size_t i = B; i < E; i++) {\n    size_t Idx = E + B - i - 1;\n    assert(Idx >= B && Idx < E);\n    Data[Idx] = (Val % 10) + '0';\n    Val /= 10;\n  }\n  return Size;\n}\n\ntemplate<class T>\nsize_t ChangeBinaryInteger(uint8_t *Data, size_t Size, Random &Rand) {\n  if (Size < sizeof(T)) return 0;\n  size_t Off = Rand(Size - sizeof(T) + 1);\n  assert(Off + sizeof(T) <= Size);\n  T Val;\n  if (Off < 64 && !Rand(4)) {\n    Val = Size;\n    if (Rand.RandBool())\n      Val = Bswap(Val);\n  } else {\n    memcpy(&Val, Data + Off, sizeof(Val));\n    T Add = Rand(21);\n    Add -= 10;\n    if (Rand.RandBool())\n      Val = Bswap(T(Bswap(Val) + Add)); // Add assuming different endiannes.\n    else\n      Val = Val + Add;               // Add assuming current endiannes.\n    if (Add == 0 || Rand.RandBool()) // Maybe negate.\n      Val = -Val;\n  }\n  memcpy(Data + Off, &Val, sizeof(Val));\n  return Size;\n}\n\nsize_t MutationDispatcher::Mutate_ChangeBinaryInteger(uint8_t *Data,\n                                                      size_t Size,\n                                                      size_t MaxSize) {\n  if (Size > MaxSize) return 0;\n  switch (Rand(4)) {\n    case 3: return ChangeBinaryInteger<uint64_t>(Data, Size, Rand);\n    case 2: return ChangeBinaryInteger<uint32_t>(Data, Size, Rand);\n    case 1: return ChangeBinaryInteger<uint16_t>(Data, Size, Rand);\n    case 0: return ChangeBinaryInteger<uint8_t>(Data, Size, Rand);\n    default: assert(0);\n  }\n  return 0;\n}\n\nsize_t MutationDispatcher::Mutate_CrossOver(uint8_t *Data, size_t Size,\n                                            size_t MaxSize) {\n  if (Size > MaxSize) return 0;\n  if (!Corpus || Corpus->size() < 2 || Size == 0) return 0;\n  size_t Idx = Rand(Corpus->size());\n  const Unit &O = (*Corpus)[Idx];\n  if (O.empty()) return 0;\n  MutateInPlaceHere.resize(MaxSize);\n  auto &U = MutateInPlaceHere;\n  size_t NewSize = 0;\n  switch(Rand(3)) {\n    case 0:\n      NewSize = CrossOver(Data, Size, O.data(), O.size(), U.data(), U.size());\n      break;\n    case 1:\n      if (Options.DefaultMutatorsResizeInput) {\n        NewSize = InsertPartOf(O.data(), O.size(), U.data(), U.size(), MaxSize);\n        if (!NewSize)\n          NewSize = CopyPartOf(O.data(), O.size(), U.data(), U.size());\n        break;\n      }\n      // Fall through when !DefaultMutatorsResizeInput\n    case 2:\n      NewSize = CopyPartOf(O.data(), O.size(), U.data(), U.size());\n      break;\n    default: assert(0);\n  }\n  assert(NewSize > 0 && \"CrossOver returned empty unit\");\n  assert(NewSize <= MaxSize && \"CrossOver returned overisized unit\");\n  memcpy(Data, U.data(), NewSize);\n  return NewSize;\n}\n\nvoid MutationDispatcher::StartMutationSequence() {\n  CurrentMutatorSequence.clear();\n  CurrentDictionaryEntrySequence.clear();\n}\n\n// Copy successful dictionary entries to PersistentAutoDictionary.\nvoid MutationDispatcher::RecordSuccessfulMutationSequence() {\n  for (auto DE : CurrentDictionaryEntrySequence) {\n    // PersistentAutoDictionary.AddWithSuccessCountOne(DE);\n    DE->IncSuccessCount();\n    assert(DE->GetW().size());\n    // Linear search is fine here as this happens seldom.\n    if (!PersistentAutoDictionary.ContainsWord(DE->GetW()))\n      PersistentAutoDictionary.push_back({DE->GetW(), 1});\n  }\n}\n\nvoid MutationDispatcher::PrintRecommendedDictionary() {\n  Vector<DictionaryEntry> V;\n  for (auto &DE : PersistentAutoDictionary)\n    if (!ManualDictionary.ContainsWord(DE.GetW()))\n      V.push_back(DE);\n  if (V.empty()) return;\n  Printf(\"###### Recommended dictionary. ######\\n\");\n  for (auto &DE: V) {\n    assert(DE.GetW().size());\n    Printf(\"\\\"\");\n    PrintASCII(DE.GetW(), \"\\\"\");\n    Printf(\" # Uses: %zd\\n\", DE.GetUseCount());\n  }\n  Printf(\"###### End of recommended dictionary. ######\\n\");\n}\n\nvoid MutationDispatcher::PrintMutationSequence() {\n  Printf(\"MS: %zd \", CurrentMutatorSequence.size());\n  for (auto M : CurrentMutatorSequence)\n    Printf(\"%s-\", M.Name);\n  if (!CurrentDictionaryEntrySequence.empty()) {\n    Printf(\" DE: \");\n    for (auto DE : CurrentDictionaryEntrySequence) {\n      Printf(\"\\\"\");\n      PrintASCII(DE->GetW(), \"\\\"-\");\n    }\n  }\n}\n\nsize_t MutationDispatcher::Mutate(uint8_t *Data, size_t Size, size_t MaxSize) {\n  return MutateImpl(Data, Size, MaxSize, Mutators);\n}\n\nsize_t MutationDispatcher::DefaultMutate(uint8_t *Data, size_t Size,\n                                         size_t MaxSize) {\n  return MutateImpl(Data, Size, MaxSize, DefaultMutators);\n}\n\n// Mutates Data in place, returns new size.\nsize_t MutationDispatcher::MutateImpl(uint8_t *Data, size_t Size,\n                                      size_t MaxSize,\n                                      Vector<Mutator> &Mutators) {\n  assert(MaxSize > 0);\n  // Some mutations may fail (e.g. can't insert more bytes if Size == MaxSize),\n  // in which case they will return 0.\n  // Try several times before returning un-mutated data.\n  for (int Iter = 0; Iter < 100; Iter++) {\n    auto M = Mutators[Rand(Mutators.size())];\n    size_t NewSize = (this->*(M.Fn))(Data, Size, MaxSize);\n    if (NewSize && NewSize <= MaxSize) {\n      if (Options.OnlyASCII)\n        ToASCII(Data, NewSize);\n      CurrentMutatorSequence.push_back(M);\n      return NewSize;\n    }\n  }\n  *Data = ' ';\n  return 1;   // Fallback, should not happen frequently.\n}\n\nvoid MutationDispatcher::AddWordToManualDictionary(const Word &W) {\n  ManualDictionary.push_back(\n      {W, std::numeric_limits<size_t>::max()});\n}\n\n}  // namespace fuzzer\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerMutate.h",
    "content": "//===- FuzzerMutate.h - Internal header for the Fuzzer ----------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// fuzzer::MutationDispatcher\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_MUTATE_H\n#define LLVM_FUZZER_MUTATE_H\n\n#include \"FuzzerDefs.h\"\n#include \"FuzzerDictionary.h\"\n#include \"FuzzerOptions.h\"\n#include \"FuzzerRandom.h\"\n\nnamespace fuzzer {\n\nclass MutationDispatcher {\npublic:\n  MutationDispatcher(Random &Rand, const FuzzingOptions &Options);\n  ~MutationDispatcher() {}\n  /// Indicate that we are about to start a new sequence of mutations.\n  void StartMutationSequence();\n  /// Print the current sequence of mutations.\n  void PrintMutationSequence();\n  /// Indicate that the current sequence of mutations was successfull.\n  void RecordSuccessfulMutationSequence();\n  /// Mutates data by invoking user-provided mutator.\n  size_t Mutate_Custom(uint8_t *Data, size_t Size, size_t MaxSize);\n  /// Mutates data by invoking user-provided crossover.\n  size_t Mutate_CustomCrossOver(uint8_t *Data, size_t Size, size_t MaxSize);\n  /// Mutates data by shuffling bytes.\n  size_t Mutate_ShuffleBytes(uint8_t *Data, size_t Size, size_t MaxSize);\n  /// Mutates data by erasing bytes.\n  size_t Mutate_EraseBytes(uint8_t *Data, size_t Size, size_t MaxSize);\n  /// Mutates data by inserting a byte.\n  size_t Mutate_InsertByte(uint8_t *Data, size_t Size, size_t MaxSize);\n  /// Mutates data by inserting several repeated bytes.\n  size_t Mutate_InsertRepeatedBytes(uint8_t *Data, size_t Size, size_t MaxSize);\n  /// Mutates data by chanding one byte.\n  size_t Mutate_ChangeByte(uint8_t *Data, size_t Size, size_t MaxSize);\n  /// Mutates data by chanding one bit.\n  size_t Mutate_ChangeBit(uint8_t *Data, size_t Size, size_t MaxSize);\n  /// Mutates data by copying/inserting a part of data into a different place.\n  size_t Mutate_CopyPart(uint8_t *Data, size_t Size, size_t MaxSize);\n\n  /// Mutates data by adding a word from the manual dictionary.\n  size_t Mutate_AddWordFromManualDictionary(uint8_t *Data, size_t Size,\n                                            size_t MaxSize);\n\n  /// Mutates data by adding a word from the TORC.\n  size_t Mutate_AddWordFromTORC(uint8_t *Data, size_t Size, size_t MaxSize);\n\n  /// Mutates data by adding a word from the persistent automatic dictionary.\n  size_t Mutate_AddWordFromPersistentAutoDictionary(uint8_t *Data, size_t Size,\n                                                    size_t MaxSize);\n\n  /// Tries to find an ASCII integer in Data, changes it to another ASCII int.\n  size_t Mutate_ChangeASCIIInteger(uint8_t *Data, size_t Size, size_t MaxSize);\n  /// Change a 1-, 2-, 4-, or 8-byte integer in interesting ways.\n  size_t Mutate_ChangeBinaryInteger(uint8_t *Data, size_t Size, size_t MaxSize);\n\n  /// CrossOver Data with some other element of the corpus.\n  size_t Mutate_CrossOver(uint8_t *Data, size_t Size, size_t MaxSize);\n\n  /// Applies one of the configured mutations.\n  /// Returns the new size of data which could be up to MaxSize.\n  size_t Mutate(uint8_t *Data, size_t Size, size_t MaxSize);\n  /// Applies one of the default mutations. Provided as a service\n  /// to mutation authors.\n  size_t DefaultMutate(uint8_t *Data, size_t Size, size_t MaxSize);\n\n  /// Creates a cross-over of two pieces of Data, returns its size.\n  size_t CrossOver(const uint8_t *Data1, size_t Size1, const uint8_t *Data2,\n                   size_t Size2, uint8_t *Out, size_t MaxOutSize);\n\n  void AddWordToManualDictionary(const Word &W);\n\n  void PrintRecommendedDictionary();\n\n  void SetCorpus(const InputCorpus *Corpus) { this->Corpus = Corpus; }\n\n  Random &GetRand() { return Rand; }\n\nprivate:\n\n  struct Mutator {\n    size_t (MutationDispatcher::*Fn)(uint8_t *Data, size_t Size, size_t Max);\n    const char *Name;\n  };\n\n  size_t AddWordFromDictionary(Dictionary &D, uint8_t *Data, size_t Size,\n                               size_t MaxSize);\n  size_t MutateImpl(uint8_t *Data, size_t Size, size_t MaxSize,\n                    Vector<Mutator> &Mutators);\n\n  size_t InsertPartOf(const uint8_t *From, size_t FromSize, uint8_t *To,\n                      size_t ToSize, size_t MaxToSize);\n  size_t CopyPartOf(const uint8_t *From, size_t FromSize, uint8_t *To,\n                    size_t ToSize);\n  size_t ApplyDictionaryEntry(uint8_t *Data, size_t Size, size_t MaxSize,\n                              DictionaryEntry &DE);\n\n  template <class T>\n  DictionaryEntry MakeDictionaryEntryFromCMP(T Arg1, T Arg2,\n                                             const uint8_t *Data, size_t Size);\n  DictionaryEntry MakeDictionaryEntryFromCMP(const Word &Arg1, const Word &Arg2,\n                                             const uint8_t *Data, size_t Size);\n  DictionaryEntry MakeDictionaryEntryFromCMP(const void *Arg1, const void *Arg2,\n                                             const void *Arg1Mutation,\n                                             const void *Arg2Mutation,\n                                             size_t ArgSize,\n                                             const uint8_t *Data, size_t Size);\n\n  Random &Rand;\n  const FuzzingOptions Options;\n\n  // Dictionary provided by the user via -dict=DICT_FILE.\n  Dictionary ManualDictionary;\n  // Temporary dictionary modified by the fuzzer itself,\n  // recreated periodically.\n  Dictionary TempAutoDictionary;\n  // Persistent dictionary modified by the fuzzer, consists of\n  // entries that led to successfull discoveries in the past mutations.\n  Dictionary PersistentAutoDictionary;\n\n  Vector<Mutator> CurrentMutatorSequence;\n  Vector<DictionaryEntry *> CurrentDictionaryEntrySequence;\n\n  static const size_t kCmpDictionaryEntriesDequeSize = 16;\n  DictionaryEntry CmpDictionaryEntriesDeque[kCmpDictionaryEntriesDequeSize];\n  size_t CmpDictionaryEntriesDequeIdx = 0;\n\n  const InputCorpus *Corpus = nullptr;\n  Vector<uint8_t> MutateInPlaceHere;\n  // CustomCrossOver needs its own buffer as a custom implementation may call\n  // LLVMFuzzerMutate, which in turn may resize MutateInPlaceHere.\n  Vector<uint8_t> CustomCrossOverInPlaceHere;\n\n  Vector<Mutator> Mutators;\n  Vector<Mutator> DefaultMutators;\n};\n\n}  // namespace fuzzer\n\n#endif  // LLVM_FUZZER_MUTATE_H\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerOptions.h",
    "content": "//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// fuzzer::FuzzingOptions\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_OPTIONS_H\n#define LLVM_FUZZER_OPTIONS_H\n\n#include \"FuzzerDefs.h\"\n\nnamespace fuzzer {\n\nstruct FuzzingOptions {\n  int Verbosity = 1;\n  size_t MaxLen = 0;\n  size_t ExperimentalLenControl = 0;\n  int UnitTimeoutSec = 300;\n  int TimeoutExitCode = 77;\n  int ErrorExitCode = 77;\n  int MaxTotalTimeSec = 0;\n  int RssLimitMb = 0;\n  int MallocLimitMb = 0;\n  bool DoCrossOver = true;\n  int MutateDepth = 5;\n  bool ReduceDepth = false;\n  bool UseCounters = false;\n  bool UseMemmem = true;\n  bool UseCmp = false;\n  bool UseValueProfile = false;\n  bool Shrink = false;\n  bool ReduceInputs = false;\n  int ReloadIntervalSec = 1;\n  bool ShuffleAtStartUp = true;\n  bool PreferSmall = true;\n  size_t MaxNumberOfRuns = -1L;\n  int ReportSlowUnits = 10;\n  bool OnlyASCII = false;\n  std::string OutputCorpus;\n  std::string ArtifactPrefix = \"./\";\n  std::string ExactArtifactPath;\n  std::string ExitOnSrcPos;\n  std::string ExitOnItem;\n  bool SaveArtifacts = true;\n  bool PrintNEW = true; // Print a status line when new units are found;\n  bool PrintNewCovPcs = false;\n  int PrintNewCovFuncs = 0;\n  bool PrintFinalStats = false;\n  bool PrintCorpusStats = false;\n  bool PrintCoverage = false;\n  bool DumpCoverage = false;\n  bool UseClangCoverage = false;\n  bool DetectLeaks = true;\n  int PurgeAllocatorIntervalSec = 1;\n  int UseFeatureFrequency = false;\n  int  TraceMalloc = 0;\n  bool HandleAbrt = false;\n  bool HandleBus = false;\n  bool HandleFpe = false;\n  bool HandleIll = false;\n  bool HandleInt = false;\n  bool HandleSegv = false;\n  bool HandleTerm = false;\n  bool HandleXfsz = false;\n  bool HandleUsr1 = false;\n  bool HandleUsr2 = false;\n  bool DefaultMutatorsResizeInput = true;\n};\n\n}  // namespace fuzzer\n\n#endif  // LLVM_FUZZER_OPTIONS_H\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerRandom.h",
    "content": "//===- FuzzerRandom.h - Internal header for the Fuzzer ----------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// fuzzer::Random\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_RANDOM_H\n#define LLVM_FUZZER_RANDOM_H\n\n#include <random>\n\nnamespace fuzzer {\nclass Random : public std::mt19937 {\n public:\n  Random(unsigned int seed) : std::mt19937(seed) {}\n  result_type operator()() { return this->std::mt19937::operator()(); }\n  size_t Rand() { return this->operator()(); }\n  size_t RandBool() { return Rand() % 2; }\n  size_t operator()(size_t n) { return n ? Rand() % n : 0; }\n  intptr_t operator()(intptr_t From, intptr_t To) {\n    assert(From < To);\n    intptr_t RangeSize = To - From + 1;\n    return operator()(RangeSize) + From;\n  }\n};\n\n}  // namespace fuzzer\n\n#endif  // LLVM_FUZZER_RANDOM_H\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerSHA1.cpp",
    "content": "//===- FuzzerSHA1.h - Private copy of the SHA1 implementation ---*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// This code is taken from public domain\n// (http://oauth.googlecode.com/svn/code/c/liboauth/src/sha1.c)\n// and modified by adding anonymous namespace, adding an interface\n// function fuzzer::ComputeSHA1() and removing unnecessary code.\n//\n// lib/Fuzzer can not use SHA1 implementation from openssl because\n// openssl may not be available and because we may be fuzzing openssl itself.\n// For the same reason we do not want to depend on SHA1 from LLVM tree.\n//===----------------------------------------------------------------------===//\n\n#include \"FuzzerSHA1.h\"\n#include \"FuzzerDefs.h\"\n\n/* This code is public-domain - it is based on libcrypt\n * placed in the public domain by Wei Dai and other contributors.\n */\n\n#include <iomanip>\n#include <sstream>\n#include <stdint.h>\n#include <string.h>\n\nnamespace {  // Added for LibFuzzer\n\n#ifdef __BIG_ENDIAN__\n# define SHA_BIG_ENDIAN\n#elif defined __LITTLE_ENDIAN__\n/* override */\n#elif defined __BYTE_ORDER\n# if __BYTE_ORDER__ ==  __ORDER_BIG_ENDIAN__\n# define SHA_BIG_ENDIAN\n# endif\n#else // ! defined __LITTLE_ENDIAN__\n# include <endian.h> // machine/endian.h\n# if __BYTE_ORDER__ ==  __ORDER_BIG_ENDIAN__\n#  define SHA_BIG_ENDIAN\n# endif\n#endif\n\n\n/* header */\n\n#define HASH_LENGTH 20\n#define BLOCK_LENGTH 64\n\ntypedef struct sha1nfo {\n\tuint32_t buffer[BLOCK_LENGTH/4];\n\tuint32_t state[HASH_LENGTH/4];\n\tuint32_t byteCount;\n\tuint8_t bufferOffset;\n\tuint8_t keyBuffer[BLOCK_LENGTH];\n\tuint8_t innerHash[HASH_LENGTH];\n} sha1nfo;\n\n/* public API - prototypes - TODO: doxygen*/\n\n/**\n */\nvoid sha1_init(sha1nfo *s);\n/**\n */\nvoid sha1_writebyte(sha1nfo *s, uint8_t data);\n/**\n */\nvoid sha1_write(sha1nfo *s, const char *data, size_t len);\n/**\n */\nuint8_t* sha1_result(sha1nfo *s);\n\n\n/* code */\n#define SHA1_K0  0x5a827999\n#define SHA1_K20 0x6ed9eba1\n#define SHA1_K40 0x8f1bbcdc\n#define SHA1_K60 0xca62c1d6\n\nvoid sha1_init(sha1nfo *s) {\n\ts->state[0] = 0x67452301;\n\ts->state[1] = 0xefcdab89;\n\ts->state[2] = 0x98badcfe;\n\ts->state[3] = 0x10325476;\n\ts->state[4] = 0xc3d2e1f0;\n\ts->byteCount = 0;\n\ts->bufferOffset = 0;\n}\n\nuint32_t sha1_rol32(uint32_t number, uint8_t bits) {\n\treturn ((number << bits) | (number >> (32-bits)));\n}\n\nvoid sha1_hashBlock(sha1nfo *s) {\n\tuint8_t i;\n\tuint32_t a,b,c,d,e,t;\n\n\ta=s->state[0];\n\tb=s->state[1];\n\tc=s->state[2];\n\td=s->state[3];\n\te=s->state[4];\n\tfor (i=0; i<80; i++) {\n\t\tif (i>=16) {\n\t\t\tt = s->buffer[(i+13)&15] ^ s->buffer[(i+8)&15] ^ s->buffer[(i+2)&15] ^ s->buffer[i&15];\n\t\t\ts->buffer[i&15] = sha1_rol32(t,1);\n\t\t}\n\t\tif (i<20) {\n\t\t\tt = (d ^ (b & (c ^ d))) + SHA1_K0;\n\t\t} else if (i<40) {\n\t\t\tt = (b ^ c ^ d) + SHA1_K20;\n\t\t} else if (i<60) {\n\t\t\tt = ((b & c) | (d & (b | c))) + SHA1_K40;\n\t\t} else {\n\t\t\tt = (b ^ c ^ d) + SHA1_K60;\n\t\t}\n\t\tt+=sha1_rol32(a,5) + e + s->buffer[i&15];\n\t\te=d;\n\t\td=c;\n\t\tc=sha1_rol32(b,30);\n\t\tb=a;\n\t\ta=t;\n\t}\n\ts->state[0] += a;\n\ts->state[1] += b;\n\ts->state[2] += c;\n\ts->state[3] += d;\n\ts->state[4] += e;\n}\n\nvoid sha1_addUncounted(sha1nfo *s, uint8_t data) {\n\tuint8_t * const b = (uint8_t*) s->buffer;\n#ifdef SHA_BIG_ENDIAN\n\tb[s->bufferOffset] = data;\n#else\n\tb[s->bufferOffset ^ 3] = data;\n#endif\n\ts->bufferOffset++;\n\tif (s->bufferOffset == BLOCK_LENGTH) {\n\t\tsha1_hashBlock(s);\n\t\ts->bufferOffset = 0;\n\t}\n}\n\nvoid sha1_writebyte(sha1nfo *s, uint8_t data) {\n\t++s->byteCount;\n\tsha1_addUncounted(s, data);\n}\n\nvoid sha1_write(sha1nfo *s, const char *data, size_t len) {\n\tfor (;len--;) sha1_writebyte(s, (uint8_t) *data++);\n}\n\nvoid sha1_pad(sha1nfo *s) {\n\t// Implement SHA-1 padding (fips180-2 §5.1.1)\n\n\t// Pad with 0x80 followed by 0x00 until the end of the block\n\tsha1_addUncounted(s, 0x80);\n\twhile (s->bufferOffset != 56) sha1_addUncounted(s, 0x00);\n\n\t// Append length in the last 8 bytes\n\tsha1_addUncounted(s, 0); // We're only using 32 bit lengths\n\tsha1_addUncounted(s, 0); // But SHA-1 supports 64 bit lengths\n\tsha1_addUncounted(s, 0); // So zero pad the top bits\n\tsha1_addUncounted(s, s->byteCount >> 29); // Shifting to multiply by 8\n\tsha1_addUncounted(s, s->byteCount >> 21); // as SHA-1 supports bitstreams as well as\n\tsha1_addUncounted(s, s->byteCount >> 13); // byte.\n\tsha1_addUncounted(s, s->byteCount >> 5);\n\tsha1_addUncounted(s, s->byteCount << 3);\n}\n\nuint8_t* sha1_result(sha1nfo *s) {\n\t// Pad to complete the last block\n\tsha1_pad(s);\n\n#ifndef SHA_BIG_ENDIAN\n\t// Swap byte order back\n\tint i;\n\tfor (i=0; i<5; i++) {\n\t\ts->state[i]=\n\t\t\t  (((s->state[i])<<24)& 0xff000000)\n\t\t\t| (((s->state[i])<<8) & 0x00ff0000)\n\t\t\t| (((s->state[i])>>8) & 0x0000ff00)\n\t\t\t| (((s->state[i])>>24)& 0x000000ff);\n\t}\n#endif\n\n\t// Return pointer to hash (20 characters)\n\treturn (uint8_t*) s->state;\n}\n\n}  // namespace; Added for LibFuzzer\n\nnamespace fuzzer {\n\n// The rest is added for LibFuzzer\nvoid ComputeSHA1(const uint8_t *Data, size_t Len, uint8_t *Out) {\n  sha1nfo s;\n  sha1_init(&s);\n  sha1_write(&s, (const char*)Data, Len);\n  memcpy(Out, sha1_result(&s), HASH_LENGTH);\n}\n\nstd::string Sha1ToString(const uint8_t Sha1[kSHA1NumBytes]) {\n  std::stringstream SS;\n  for (int i = 0; i < kSHA1NumBytes; i++)\n    SS << std::hex << std::setfill('0') << std::setw(2) << (unsigned)Sha1[i];\n  return SS.str();\n}\n\nstd::string Hash(const Unit &U) {\n  uint8_t Hash[kSHA1NumBytes];\n  ComputeSHA1(U.data(), U.size(), Hash);\n  return Sha1ToString(Hash);\n}\n\n}\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerSHA1.h",
    "content": "//===- FuzzerSHA1.h - Internal header for the SHA1 utils --------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// SHA1 utils.\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_SHA1_H\n#define LLVM_FUZZER_SHA1_H\n\n#include \"FuzzerDefs.h\"\n#include <cstddef>\n#include <stdint.h>\n\nnamespace fuzzer {\n\n// Private copy of SHA1 implementation.\nstatic const int kSHA1NumBytes = 20;\n\n// Computes SHA1 hash of 'Len' bytes in 'Data', writes kSHA1NumBytes to 'Out'.\nvoid ComputeSHA1(const uint8_t *Data, size_t Len, uint8_t *Out);\n\nstd::string Sha1ToString(const uint8_t Sha1[kSHA1NumBytes]);\n\nstd::string Hash(const Unit &U);\n\n}  // namespace fuzzer\n\n#endif  // LLVM_FUZZER_SHA1_H\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerShmem.h",
    "content": "//===- FuzzerShmem.h - shared memory interface ------------------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// SharedMemoryRegion\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_SHMEM_H\n#define LLVM_FUZZER_SHMEM_H\n\n#include <algorithm>\n#include <cstring>\n#include <string>\n\n#include \"FuzzerDefs.h\"\n\nnamespace fuzzer {\n\nclass SharedMemoryRegion {\n public:\n  bool Create(const char *Name);\n  bool Open(const char *Name);\n  bool Destroy(const char *Name);\n  uint8_t *GetData() { return Data; }\n  void PostServer() {Post(0);}\n  void WaitServer() {Wait(0);}\n  void PostClient() {Post(1);}\n  void WaitClient() {Wait(1);}\n\n  size_t WriteByteArray(const uint8_t *Bytes, size_t N) {\n    assert(N <= kShmemSize - sizeof(N));\n    memcpy(GetData(), &N, sizeof(N));\n    memcpy(GetData() + sizeof(N), Bytes, N);\n    assert(N == ReadByteArraySize());\n    return N;\n  }\n  size_t ReadByteArraySize() {\n    size_t Res;\n    memcpy(&Res, GetData(), sizeof(Res));\n    return Res;\n  }\n  uint8_t *GetByteArray() { return GetData() + sizeof(size_t); }\n\n  bool IsServer() const { return Data && IAmServer; }\n  bool IsClient() const { return Data && !IAmServer; }\n\nprivate:\n\n  static const size_t kShmemSize = 1 << 22;\n  bool IAmServer;\n  std::string Path(const char *Name);\n  std::string SemName(const char *Name, int Idx);\n  void Post(int Idx);\n  void Wait(int Idx);\n\n  bool Map(int fd);\n  uint8_t *Data = nullptr;\n  void *Semaphore[2];\n};\n\nextern SharedMemoryRegion SMR;\n\n}  // namespace fuzzer\n\n#endif  // LLVM_FUZZER_SHMEM_H\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerShmemFuchsia.cpp",
    "content": "//===- FuzzerShmemPosix.cpp - Posix shared memory ---------------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// SharedMemoryRegion.  For Fuchsia, this is just stubs as equivalence servers\n// are not currently supported.\n//===----------------------------------------------------------------------===//\n#include \"FuzzerDefs.h\"\n\n#if LIBFUZZER_FUCHSIA\n\n#include \"FuzzerShmem.h\"\n\nnamespace fuzzer {\n\nbool SharedMemoryRegion::Create(const char *Name) {\n  return false;\n}\n\nbool SharedMemoryRegion::Open(const char *Name) {\n  return false;\n}\n\nbool SharedMemoryRegion::Destroy(const char *Name) {\n  return false;\n}\n\nvoid SharedMemoryRegion::Post(int Idx) {}\n\nvoid SharedMemoryRegion::Wait(int Idx) {}\n\n}  // namespace fuzzer\n\n#endif  // LIBFUZZER_FUCHSIA\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerShmemPosix.cpp",
    "content": "//===- FuzzerShmemPosix.cpp - Posix shared memory ---------------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// SharedMemoryRegion\n//===----------------------------------------------------------------------===//\n#include \"FuzzerDefs.h\"\n#if LIBFUZZER_POSIX\n\n#include \"FuzzerIO.h\"\n#include \"FuzzerShmem.h\"\n\n#include <errno.h>\n#include <fcntl.h>\n#include <semaphore.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <sys/mman.h>\n#include <sys/stat.h>\n#include <sys/types.h>\n#include <unistd.h>\n\nnamespace fuzzer {\n\nstd::string SharedMemoryRegion::Path(const char *Name) {\n  return DirPlusFile(TmpDir(), Name);\n}\n\nstd::string SharedMemoryRegion::SemName(const char *Name, int Idx) {\n  std::string Res(Name);\n  return Res + (char)('0' + Idx);\n}\n\nbool SharedMemoryRegion::Map(int fd) {\n  Data =\n      (uint8_t *)mmap(0, kShmemSize, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0);\n  if (Data == (uint8_t*)-1)\n    return false;\n  return true;\n}\n\nbool SharedMemoryRegion::Create(const char *Name) {\n  int fd = open(Path(Name).c_str(), O_CREAT | O_RDWR, 0777);\n  if (fd < 0) return false;\n  if (ftruncate(fd, kShmemSize) < 0) return false;\n  if (!Map(fd))\n    return false;\n  for (int i = 0; i < 2; i++) {\n    sem_unlink(SemName(Name, i).c_str());\n    Semaphore[i] = sem_open(SemName(Name, i).c_str(), O_CREAT, 0644, 0);\n    if (Semaphore[i] == (void *)-1)\n      return false;\n  }\n  IAmServer = true;\n  return true;\n}\n\nbool SharedMemoryRegion::Open(const char *Name) {\n  int fd = open(Path(Name).c_str(), O_RDWR);\n  if (fd < 0) return false;\n  struct stat stat_res;\n  if (0 != fstat(fd, &stat_res))\n    return false;\n  assert(stat_res.st_size == kShmemSize);\n  if (!Map(fd))\n    return false;\n  for (int i = 0; i < 2; i++) {\n    Semaphore[i] = sem_open(SemName(Name, i).c_str(), 0);\n    if (Semaphore[i] == (void *)-1)\n      return false;\n  }\n  IAmServer = false;\n  return true;\n}\n\nbool SharedMemoryRegion::Destroy(const char *Name) {\n  return 0 == unlink(Path(Name).c_str());\n}\n\nvoid SharedMemoryRegion::Post(int Idx) {\n  assert(Idx == 0 || Idx == 1);\n  sem_post((sem_t*)Semaphore[Idx]);\n}\n\nvoid SharedMemoryRegion::Wait(int Idx) {\n  assert(Idx == 0 || Idx == 1);\n  for (int i = 0; i < 10 && sem_wait((sem_t*)Semaphore[Idx]); i++) {\n    // sem_wait may fail if interrupted by a signal.\n    sleep(i);\n    if (i)\n      Printf(\"%s: sem_wait[%d] failed %s\\n\", i < 9 ? \"WARNING\" : \"ERROR\", i,\n             strerror(errno));\n    if (i == 9) abort();\n  }\n}\n\n}  // namespace fuzzer\n\n#endif  // LIBFUZZER_POSIX\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerShmemWindows.cpp",
    "content": "//===- FuzzerShmemWindows.cpp - Posix shared memory -------------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// SharedMemoryRegion\n//===----------------------------------------------------------------------===//\n#include \"FuzzerDefs.h\"\n#if LIBFUZZER_WINDOWS\n\n#include \"FuzzerIO.h\"\n#include \"FuzzerShmem.h\"\n\n#include <fcntl.h>\n#include <stdio.h>\n#include <sys/stat.h>\n#include <sys/types.h>\n\nnamespace fuzzer {\n\nstd::string SharedMemoryRegion::Path(const char *Name) {\n  return DirPlusFile(TmpDir(), Name);\n}\n\nstd::string SharedMemoryRegion::SemName(const char *Name, int Idx) {\n  std::string Res(Name);\n  return Res + (char)('0' + Idx);\n}\n\nbool SharedMemoryRegion::Map(int fd) {\n  assert(0 && \"UNIMPLEMENTED\");\n  return false;\n}\n\nbool SharedMemoryRegion::Create(const char *Name) {\n  assert(0 && \"UNIMPLEMENTED\");\n  return false;\n}\n\nbool SharedMemoryRegion::Open(const char *Name) {\n  assert(0 && \"UNIMPLEMENTED\");\n  return false;\n}\n\nbool SharedMemoryRegion::Destroy(const char *Name) {\n  assert(0 && \"UNIMPLEMENTED\");\n  return false;\n}\n\nvoid SharedMemoryRegion::Post(int Idx) {\n  assert(0 && \"UNIMPLEMENTED\");\n}\n\nvoid SharedMemoryRegion::Wait(int Idx) {\n  Semaphore[1] = nullptr;\n  assert(0 && \"UNIMPLEMENTED\");\n}\n\n}  // namespace fuzzer\n\n#endif  // LIBFUZZER_WINDOWS\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerTracePC.cpp",
    "content": "//===- FuzzerTracePC.cpp - PC tracing--------------------------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Trace PCs.\n// This module implements __sanitizer_cov_trace_pc_guard[_init],\n// the callback required for -fsanitize-coverage=trace-pc-guard instrumentation.\n//\n//===----------------------------------------------------------------------===//\n\n#include \"FuzzerTracePC.h\"\n#include \"FuzzerCorpus.h\"\n#include \"FuzzerDefs.h\"\n#include \"FuzzerDictionary.h\"\n#include \"FuzzerExtFunctions.h\"\n#include \"FuzzerIO.h\"\n#include \"FuzzerUtil.h\"\n#include \"FuzzerValueBitMap.h\"\n#include <set>\n\n// The coverage counters and PCs.\n// These are declared as global variables named \"__sancov_*\" to simplify\n// experiments with inlined instrumentation.\nalignas(64) ATTRIBUTE_INTERFACE\nuint8_t __sancov_trace_pc_guard_8bit_counters[fuzzer::TracePC::kNumPCs];\n\nATTRIBUTE_INTERFACE\nuintptr_t __sancov_trace_pc_pcs[fuzzer::TracePC::kNumPCs];\n\n// Used by -fsanitize-coverage=stack-depth to track stack depth\nATTRIBUTE_INTERFACE __attribute__((tls_model(\"initial-exec\")))\nthread_local uintptr_t __sancov_lowest_stack;\n\nnamespace fuzzer {\n\nTracePC TPC;\n\nint ScopedDoingMyOwnMemOrStr::DoingMyOwnMemOrStr;\n\nuint8_t *TracePC::Counters() const {\n  return __sancov_trace_pc_guard_8bit_counters;\n}\n\nuintptr_t *TracePC::PCs() const {\n  return __sancov_trace_pc_pcs;\n}\n\nsize_t TracePC::GetTotalPCCoverage() {\n  if (ObservedPCs.size())\n    return ObservedPCs.size();\n  size_t Res = 0;\n  for (size_t i = 1, N = GetNumPCs(); i < N; i++)\n    if (PCs()[i])\n      Res++;\n  return Res;\n}\n\n\nvoid TracePC::HandleInline8bitCountersInit(uint8_t *Start, uint8_t *Stop) {\n  if (Start == Stop) return;\n  if (NumModulesWithInline8bitCounters &&\n      ModuleCounters[NumModulesWithInline8bitCounters-1].Start == Start) return;\n  assert(NumModulesWithInline8bitCounters <\n         sizeof(ModuleCounters) / sizeof(ModuleCounters[0]));\n  ModuleCounters[NumModulesWithInline8bitCounters++] = {Start, Stop};\n  NumInline8bitCounters += Stop - Start;\n}\n\nvoid TracePC::HandlePCsInit(const uintptr_t *Start, const uintptr_t *Stop) {\n  const PCTableEntry *B = reinterpret_cast<const PCTableEntry *>(Start);\n  const PCTableEntry *E = reinterpret_cast<const PCTableEntry *>(Stop);\n  if (NumPCTables && ModulePCTable[NumPCTables - 1].Start == B) return;\n  assert(NumPCTables < sizeof(ModulePCTable) / sizeof(ModulePCTable[0]));\n  ModulePCTable[NumPCTables++] = {B, E};\n  NumPCsInPCTables += E - B;\n}\n\nvoid TracePC::HandleInit(uint32_t *Start, uint32_t *Stop) {\n  if (Start == Stop || *Start) return;\n  assert(NumModules < sizeof(Modules) / sizeof(Modules[0]));\n  for (uint32_t *P = Start; P < Stop; P++) {\n    NumGuards++;\n    if (NumGuards == kNumPCs) {\n      RawPrint(\n          \"WARNING: The binary has too many instrumented PCs.\\n\"\n          \"         You may want to reduce the size of the binary\\n\"\n          \"         for more efficient fuzzing and precise coverage data\\n\");\n    }\n    *P = NumGuards % kNumPCs;\n  }\n  Modules[NumModules].Start = Start;\n  Modules[NumModules].Stop = Stop;\n  NumModules++;\n}\n\nvoid TracePC::PrintModuleInfo() {\n  if (NumGuards) {\n    Printf(\"INFO: Loaded %zd modules   (%zd guards): \", NumModules, NumGuards);\n    for (size_t i = 0; i < NumModules; i++)\n      Printf(\"%zd [%p, %p), \", Modules[i].Stop - Modules[i].Start,\n             Modules[i].Start, Modules[i].Stop);\n    Printf(\"\\n\");\n  }\n  if (NumModulesWithInline8bitCounters) {\n    Printf(\"INFO: Loaded %zd modules   (%zd inline 8-bit counters): \",\n           NumModulesWithInline8bitCounters, NumInline8bitCounters);\n    for (size_t i = 0; i < NumModulesWithInline8bitCounters; i++)\n      Printf(\"%zd [%p, %p), \", ModuleCounters[i].Stop - ModuleCounters[i].Start,\n             ModuleCounters[i].Start, ModuleCounters[i].Stop);\n    Printf(\"\\n\");\n  }\n  if (NumPCTables) {\n    Printf(\"INFO: Loaded %zd PC tables (%zd PCs): \", NumPCTables,\n           NumPCsInPCTables);\n    for (size_t i = 0; i < NumPCTables; i++) {\n      Printf(\"%zd [%p,%p), \", ModulePCTable[i].Stop - ModulePCTable[i].Start,\n             ModulePCTable[i].Start, ModulePCTable[i].Stop);\n    }\n    Printf(\"\\n\");\n\n    if ((NumGuards && NumGuards != NumPCsInPCTables) ||\n        (NumInline8bitCounters && NumInline8bitCounters != NumPCsInPCTables)) {\n      Printf(\"ERROR: The size of coverage PC tables does not match the\\n\"\n             \"number of instrumented PCs. This might be a compiler bug,\\n\"\n             \"please contact the libFuzzer developers.\\n\"\n             \"Also check https://bugs.llvm.org/show_bug.cgi?id=34636\\n\"\n             \"for possible workarounds (tl;dr: don't use the old GNU ld)\\n\");\n      _Exit(1);\n    }\n  }\n  if (size_t NumClangCounters = ClangCountersEnd() - ClangCountersBegin())\n    Printf(\"INFO: %zd Clang Coverage Counters\\n\", NumClangCounters);\n\n  // FIXME: We should upstream this\n  if (size_t NumExtraCounters = ExtraCountersEnd() - ExtraCountersBegin())\n    Printf(\"INFO: %zd Extra Counters\\n\", NumExtraCounters);\n}\n\nATTRIBUTE_NO_SANITIZE_ALL\nvoid TracePC::HandleCallerCallee(uintptr_t Caller, uintptr_t Callee) {\n  const uintptr_t kBits = 12;\n  const uintptr_t kMask = (1 << kBits) - 1;\n  uintptr_t Idx = (Caller & kMask) | ((Callee & kMask) << kBits);\n  ValueProfileMap.AddValueModPrime(Idx);\n}\n\nvoid TracePC::UpdateObservedPCs() {\n  Vector<uintptr_t> CoveredFuncs;\n  auto ObservePC = [&](uintptr_t PC) {\n    if (ObservedPCs.insert(PC).second && DoPrintNewPCs)\n      PrintPC(\"\\tNEW_PC: %p %F %L\\n\", \"\\tNEW_PC: %p\\n\", PC + 1);\n  };\n\n  auto Observe = [&](const PCTableEntry &TE) {\n    if (TE.PCFlags & 1)\n      if (ObservedFuncs.insert(TE.PC).second && NumPrintNewFuncs)\n        CoveredFuncs.push_back(TE.PC);\n    ObservePC(TE.PC);\n  };\n\n  if (NumPCsInPCTables) {\n    if (NumInline8bitCounters == NumPCsInPCTables) {\n      for (size_t i = 0; i < NumModulesWithInline8bitCounters; i++) {\n        uint8_t *Beg = ModuleCounters[i].Start;\n        size_t Size = ModuleCounters[i].Stop - Beg;\n        assert(Size ==\n               (size_t)(ModulePCTable[i].Stop - ModulePCTable[i].Start));\n        for (size_t j = 0; j < Size; j++)\n          if (Beg[j])\n            Observe(ModulePCTable[i].Start[j]);\n      }\n    } else if (NumGuards == NumPCsInPCTables) {\n      size_t GuardIdx = 1;\n      for (size_t i = 0; i < NumModules; i++) {\n        uint32_t *Beg = Modules[i].Start;\n        size_t Size = Modules[i].Stop - Beg;\n        assert(Size ==\n               (size_t)(ModulePCTable[i].Stop - ModulePCTable[i].Start));\n        for (size_t j = 0; j < Size; j++, GuardIdx++)\n          if (Counters()[GuardIdx])\n            Observe(ModulePCTable[i].Start[j]);\n      }\n    }\n  }\n  if (size_t NumClangCounters =\n      ClangCountersEnd() - ClangCountersBegin()) {\n    auto P = ClangCountersBegin();\n    for (size_t Idx = 0; Idx < NumClangCounters; Idx++)\n      if (P[Idx])\n        ObservePC((uintptr_t)Idx);\n  }\n\n  for (size_t i = 0, N = Min(CoveredFuncs.size(), NumPrintNewFuncs); i < N; i++) {\n    Printf(\"\\tNEW_FUNC[%zd/%zd]: \", i, CoveredFuncs.size());\n    PrintPC(\"%p %F %L\\n\", \"%p\\n\", CoveredFuncs[i] + 1);\n  }\n}\n\ninline ALWAYS_INLINE uintptr_t GetPreviousInstructionPc(uintptr_t PC) {\n  // TODO: this implementation is x86 only.\n  // see sanitizer_common GetPreviousInstructionPc for full implementation.\n  return PC - 1;\n}\n\ninline ALWAYS_INLINE uintptr_t GetNextInstructionPc(uintptr_t PC) {\n  // TODO: this implementation is x86 only.\n  // see sanitizer_common GetPreviousInstructionPc for full implementation.\n  return PC + 1;\n}\n\nstatic std::string GetModuleName(uintptr_t PC) {\n  char ModulePathRaw[4096] = \"\";  // What's PATH_MAX in portable C++?\n  void *OffsetRaw = nullptr;\n  if (!EF->__sanitizer_get_module_and_offset_for_pc(\n      reinterpret_cast<void *>(PC), ModulePathRaw,\n      sizeof(ModulePathRaw), &OffsetRaw))\n    return \"\";\n  return ModulePathRaw;\n}\n\nvoid TracePC::PrintCoverage() {\n  if (!EF->__sanitizer_symbolize_pc ||\n      !EF->__sanitizer_get_module_and_offset_for_pc) {\n    Printf(\"INFO: __sanitizer_symbolize_pc or \"\n           \"__sanitizer_get_module_and_offset_for_pc is not available,\"\n           \" not printing coverage\\n\");\n    return;\n  }\n  Printf(\"COVERAGE:\\n\");\n  std::string LastFunctionName = \"\";\n  std::string LastFileStr = \"\";\n  Set<size_t> UncoveredLines;\n  Set<size_t> CoveredLines;\n\n  auto FunctionEndCallback = [&](const std::string &CurrentFunc,\n                                 const std::string &CurrentFile) {\n    if (LastFunctionName != CurrentFunc) {\n      if (CoveredLines.empty() && !UncoveredLines.empty()) {\n        Printf(\"UNCOVERED_FUNC: %s\\n\", LastFunctionName.c_str());\n      } else {\n        for (auto Line : UncoveredLines) {\n          if (!CoveredLines.count(Line))\n            Printf(\"UNCOVERED_LINE: %s %s:%zd\\n\", LastFunctionName.c_str(),\n                   LastFileStr.c_str(), Line);\n        }\n      }\n\n      UncoveredLines.clear();\n      CoveredLines.clear();\n      LastFunctionName = CurrentFunc;\n      LastFileStr = CurrentFile;\n    }\n  };\n\n  for (size_t i = 0; i < NumPCTables; i++) {\n    auto &M = ModulePCTable[i];\n    assert(M.Start < M.Stop);\n    auto ModuleName = GetModuleName(M.Start->PC);\n    for (auto Ptr = M.Start; Ptr < M.Stop; Ptr++) {\n      auto PC = Ptr->PC;\n      auto VisualizePC = GetNextInstructionPc(PC);\n      bool IsObserved = ObservedPCs.count(PC);\n      std::string FileStr = DescribePC(\"%s\", VisualizePC);\n      if (!IsInterestingCoverageFile(FileStr)) continue;\n      std::string FunctionStr = DescribePC(\"%F\", VisualizePC);\n      FunctionEndCallback(FunctionStr, FileStr);\n      std::string LineStr = DescribePC(\"%l\", VisualizePC);\n      size_t Line = std::stoul(LineStr);\n      if (IsObserved && CoveredLines.insert(Line).second)\n        Printf(\"COVERED: %s %s:%zd\\n\", FunctionStr.c_str(), FileStr.c_str(),\n               Line);\n      else\n        UncoveredLines.insert(Line);\n    }\n  }\n  FunctionEndCallback(\"\", \"\");\n}\n\nvoid TracePC::DumpCoverage() {\n  if (EF->__sanitizer_dump_coverage) {\n    Vector<uintptr_t> PCsCopy(GetNumPCs());\n    for (size_t i = 0; i < GetNumPCs(); i++)\n      PCsCopy[i] = PCs()[i] ? GetPreviousInstructionPc(PCs()[i]) : 0;\n    EF->__sanitizer_dump_coverage(PCsCopy.data(), PCsCopy.size());\n  }\n}\n\n// Value profile.\n// We keep track of various values that affect control flow.\n// These values are inserted into a bit-set-based hash map.\n// Every new bit in the map is treated as a new coverage.\n//\n// For memcmp/strcmp/etc the interesting value is the length of the common\n// prefix of the parameters.\n// For cmp instructions the interesting value is a XOR of the parameters.\n// The interesting value is mixed up with the PC and is then added to the map.\n\nATTRIBUTE_NO_SANITIZE_ALL\nvoid TracePC::AddValueForMemcmp(void *caller_pc, const void *s1, const void *s2,\n                                size_t n, bool StopAtZero) {\n  if (!n) return;\n  size_t Len = std::min(n, Word::GetMaxSize());\n  const uint8_t *A1 = reinterpret_cast<const uint8_t *>(s1);\n  const uint8_t *A2 = reinterpret_cast<const uint8_t *>(s2);\n  uint8_t B1[Word::kMaxSize];\n  uint8_t B2[Word::kMaxSize];\n  // Copy the data into locals in this non-msan-instrumented function\n  // to avoid msan complaining further.\n  size_t Hash = 0;  // Compute some simple hash of both strings.\n  for (size_t i = 0; i < Len; i++) {\n    B1[i] = A1[i];\n    B2[i] = A2[i];\n    size_t T = B1[i];\n    Hash ^= (T << 8) | B2[i];\n  }\n  size_t I = 0;\n  for (; I < Len; I++)\n    if (B1[I] != B2[I] || (StopAtZero && B1[I] == 0))\n      break;\n  size_t PC = reinterpret_cast<size_t>(caller_pc);\n  size_t Idx = (PC & 4095) | (I << 12);\n  ValueProfileMap.AddValue(Idx);\n  TORCW.Insert(Idx ^ Hash, Word(B1, Len), Word(B2, Len));\n}\n\ntemplate <class T>\nATTRIBUTE_TARGET_POPCNT ALWAYS_INLINE\nATTRIBUTE_NO_SANITIZE_ALL\nvoid TracePC::HandleCmp(uintptr_t PC, T Arg1, T Arg2) {\n  uint64_t ArgXor = Arg1 ^ Arg2;\n  uint64_t ArgDistance = __builtin_popcountll(ArgXor) + 1; // [1,65]\n  uintptr_t Idx = ((PC & 4095) + 1) * ArgDistance;\n  if (sizeof(T) == 4)\n      TORC4.Insert(ArgXor, Arg1, Arg2);\n  else if (sizeof(T) == 8)\n      TORC8.Insert(ArgXor, Arg1, Arg2);\n  ValueProfileMap.AddValue(Idx);\n}\n\nstatic size_t InternalStrnlen(const char *S, size_t MaxLen) {\n  size_t Len = 0;\n  for (; Len < MaxLen && S[Len]; Len++) {}\n  return Len;\n}\n\n// Finds min of (strlen(S1), strlen(S2)).\n// Needed bacause one of these strings may actually be non-zero terminated.\nstatic size_t InternalStrnlen2(const char *S1, const char *S2) {\n  size_t Len = 0;\n  for (; S1[Len] && S2[Len]; Len++)  {}\n  return Len;\n}\n\nvoid TracePC::ClearInlineCounters() {\n  for (size_t i = 0; i < NumModulesWithInline8bitCounters; i++) {\n    uint8_t *Beg = ModuleCounters[i].Start;\n    size_t Size = ModuleCounters[i].Stop - Beg;\n    memset(Beg, 0, Size);\n  }\n}\n\nATTRIBUTE_NO_SANITIZE_ALL\nvoid TracePC::RecordInitialStack() {\n  int stack;\n  __sancov_lowest_stack = InitialStack = reinterpret_cast<uintptr_t>(&stack);\n}\n\nuintptr_t TracePC::GetMaxStackOffset() const {\n  return InitialStack - __sancov_lowest_stack;  // Stack grows down\n}\n\n} // namespace fuzzer\n\nextern \"C\" {\nATTRIBUTE_INTERFACE\nATTRIBUTE_NO_SANITIZE_ALL\nvoid __sanitizer_cov_trace_pc_guard(uint32_t *Guard) {\n  uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));\n  uint32_t Idx = *Guard;\n  __sancov_trace_pc_pcs[Idx] = PC;\n  __sancov_trace_pc_guard_8bit_counters[Idx]++;\n}\n\n// Best-effort support for -fsanitize-coverage=trace-pc, which is available\n// in both Clang and GCC.\nATTRIBUTE_INTERFACE\nATTRIBUTE_NO_SANITIZE_ALL\nvoid __sanitizer_cov_trace_pc() {\n  uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));\n  uintptr_t Idx = PC & (((uintptr_t)1 << fuzzer::TracePC::kTracePcBits) - 1);\n  __sancov_trace_pc_pcs[Idx] = PC;\n  __sancov_trace_pc_guard_8bit_counters[Idx]++;\n}\n\nATTRIBUTE_INTERFACE\nvoid __sanitizer_cov_trace_pc_guard_init(uint32_t *Start, uint32_t *Stop) {\n  fuzzer::TPC.HandleInit(Start, Stop);\n}\n\nATTRIBUTE_INTERFACE\nvoid __sanitizer_cov_8bit_counters_init(uint8_t *Start, uint8_t *Stop) {\n  fuzzer::TPC.HandleInline8bitCountersInit(Start, Stop);\n}\n\nATTRIBUTE_INTERFACE\nvoid __sanitizer_cov_pcs_init(const uintptr_t *pcs_beg,\n                              const uintptr_t *pcs_end) {\n  fuzzer::TPC.HandlePCsInit(pcs_beg, pcs_end);\n}\n\nATTRIBUTE_INTERFACE\nATTRIBUTE_NO_SANITIZE_ALL\nvoid __sanitizer_cov_trace_pc_indir(uintptr_t Callee) {\n  uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));\n  fuzzer::TPC.HandleCallerCallee(PC, Callee);\n}\n\nATTRIBUTE_INTERFACE\nATTRIBUTE_NO_SANITIZE_ALL\nATTRIBUTE_TARGET_POPCNT\nvoid __sanitizer_cov_trace_cmp8(uint64_t Arg1, uint64_t Arg2) {\n  uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));\n  fuzzer::TPC.HandleCmp(PC, Arg1, Arg2);\n}\n\nATTRIBUTE_INTERFACE\nATTRIBUTE_NO_SANITIZE_ALL\nATTRIBUTE_TARGET_POPCNT\n// Now the __sanitizer_cov_trace_const_cmp[1248] callbacks just mimic\n// the behaviour of __sanitizer_cov_trace_cmp[1248] ones. This, however,\n// should be changed later to make full use of instrumentation.\nvoid __sanitizer_cov_trace_const_cmp8(uint64_t Arg1, uint64_t Arg2) {\n  uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));\n  fuzzer::TPC.HandleCmp(PC, Arg1, Arg2);\n}\n\nATTRIBUTE_INTERFACE\nATTRIBUTE_NO_SANITIZE_ALL\nATTRIBUTE_TARGET_POPCNT\nvoid __sanitizer_cov_trace_cmp4(uint32_t Arg1, uint32_t Arg2) {\n  uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));\n  fuzzer::TPC.HandleCmp(PC, Arg1, Arg2);\n}\n\nATTRIBUTE_INTERFACE\nATTRIBUTE_NO_SANITIZE_ALL\nATTRIBUTE_TARGET_POPCNT\nvoid __sanitizer_cov_trace_const_cmp4(uint32_t Arg1, uint32_t Arg2) {\n  uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));\n  fuzzer::TPC.HandleCmp(PC, Arg1, Arg2);\n}\n\nATTRIBUTE_INTERFACE\nATTRIBUTE_NO_SANITIZE_ALL\nATTRIBUTE_TARGET_POPCNT\nvoid __sanitizer_cov_trace_cmp2(uint16_t Arg1, uint16_t Arg2) {\n  uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));\n  fuzzer::TPC.HandleCmp(PC, Arg1, Arg2);\n}\n\nATTRIBUTE_INTERFACE\nATTRIBUTE_NO_SANITIZE_ALL\nATTRIBUTE_TARGET_POPCNT\nvoid __sanitizer_cov_trace_const_cmp2(uint16_t Arg1, uint16_t Arg2) {\n  uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));\n  fuzzer::TPC.HandleCmp(PC, Arg1, Arg2);\n}\n\nATTRIBUTE_INTERFACE\nATTRIBUTE_NO_SANITIZE_ALL\nATTRIBUTE_TARGET_POPCNT\nvoid __sanitizer_cov_trace_cmp1(uint8_t Arg1, uint8_t Arg2) {\n  uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));\n  fuzzer::TPC.HandleCmp(PC, Arg1, Arg2);\n}\n\nATTRIBUTE_INTERFACE\nATTRIBUTE_NO_SANITIZE_ALL\nATTRIBUTE_TARGET_POPCNT\nvoid __sanitizer_cov_trace_const_cmp1(uint8_t Arg1, uint8_t Arg2) {\n  uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));\n  fuzzer::TPC.HandleCmp(PC, Arg1, Arg2);\n}\n\nATTRIBUTE_INTERFACE\nATTRIBUTE_NO_SANITIZE_ALL\nATTRIBUTE_TARGET_POPCNT\nvoid __sanitizer_cov_trace_switch(uint64_t Val, uint64_t *Cases) {\n  uint64_t N = Cases[0];\n  uint64_t ValSizeInBits = Cases[1];\n  uint64_t *Vals = Cases + 2;\n  // Skip the most common and the most boring case.\n  if (Vals[N - 1]  < 256 && Val < 256)\n    return;\n  uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));\n  size_t i;\n  uint64_t Token = 0;\n  for (i = 0; i < N; i++) {\n    Token = Val ^ Vals[i];\n    if (Val < Vals[i])\n      break;\n  }\n\n  if (ValSizeInBits == 16)\n    fuzzer::TPC.HandleCmp(PC + i, static_cast<uint16_t>(Token), (uint16_t)(0));\n  else if (ValSizeInBits == 32)\n    fuzzer::TPC.HandleCmp(PC + i, static_cast<uint32_t>(Token), (uint32_t)(0));\n  else\n    fuzzer::TPC.HandleCmp(PC + i, Token, (uint64_t)(0));\n}\n\nATTRIBUTE_INTERFACE\nATTRIBUTE_NO_SANITIZE_ALL\nATTRIBUTE_TARGET_POPCNT\nvoid __sanitizer_cov_trace_div4(uint32_t Val) {\n  uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));\n  fuzzer::TPC.HandleCmp(PC, Val, (uint32_t)0);\n}\n\nATTRIBUTE_INTERFACE\nATTRIBUTE_NO_SANITIZE_ALL\nATTRIBUTE_TARGET_POPCNT\nvoid __sanitizer_cov_trace_div8(uint64_t Val) {\n  uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));\n  fuzzer::TPC.HandleCmp(PC, Val, (uint64_t)0);\n}\n\nATTRIBUTE_INTERFACE\nATTRIBUTE_NO_SANITIZE_ALL\nATTRIBUTE_TARGET_POPCNT\nvoid __sanitizer_cov_trace_gep(uintptr_t Idx) {\n  uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));\n  fuzzer::TPC.HandleCmp(PC, Idx, (uintptr_t)0);\n}\n\nATTRIBUTE_INTERFACE ATTRIBUTE_NO_SANITIZE_MEMORY\nvoid __sanitizer_weak_hook_memcmp(void *caller_pc, const void *s1,\n                                  const void *s2, size_t n, int result) {\n  if (fuzzer::ScopedDoingMyOwnMemOrStr::DoingMyOwnMemOrStr) return;\n  if (result == 0) return;  // No reason to mutate.\n  if (n <= 1) return;  // Not interesting.\n  fuzzer::TPC.AddValueForMemcmp(caller_pc, s1, s2, n, /*StopAtZero*/false);\n}\n\nATTRIBUTE_INTERFACE ATTRIBUTE_NO_SANITIZE_MEMORY\nvoid __sanitizer_weak_hook_strncmp(void *caller_pc, const char *s1,\n                                   const char *s2, size_t n, int result) {\n  if (fuzzer::ScopedDoingMyOwnMemOrStr::DoingMyOwnMemOrStr) return;\n  if (result == 0) return;  // No reason to mutate.\n  size_t Len1 = fuzzer::InternalStrnlen(s1, n);\n  size_t Len2 = fuzzer::InternalStrnlen(s2, n);\n  n = std::min(n, Len1);\n  n = std::min(n, Len2);\n  if (n <= 1) return;  // Not interesting.\n  fuzzer::TPC.AddValueForMemcmp(caller_pc, s1, s2, n, /*StopAtZero*/true);\n}\n\nATTRIBUTE_INTERFACE ATTRIBUTE_NO_SANITIZE_MEMORY\nvoid __sanitizer_weak_hook_strcmp(void *caller_pc, const char *s1,\n                                   const char *s2, int result) {\n  if (fuzzer::ScopedDoingMyOwnMemOrStr::DoingMyOwnMemOrStr) return;\n  if (result == 0) return;  // No reason to mutate.\n  size_t N = fuzzer::InternalStrnlen2(s1, s2);\n  if (N <= 1) return;  // Not interesting.\n  fuzzer::TPC.AddValueForMemcmp(caller_pc, s1, s2, N, /*StopAtZero*/true);\n}\n\nATTRIBUTE_INTERFACE ATTRIBUTE_NO_SANITIZE_MEMORY\nvoid __sanitizer_weak_hook_strncasecmp(void *called_pc, const char *s1,\n                                       const char *s2, size_t n, int result) {\n  if (fuzzer::ScopedDoingMyOwnMemOrStr::DoingMyOwnMemOrStr) return;\n  return __sanitizer_weak_hook_strncmp(called_pc, s1, s2, n, result);\n}\n\nATTRIBUTE_INTERFACE ATTRIBUTE_NO_SANITIZE_MEMORY\nvoid __sanitizer_weak_hook_strcasecmp(void *called_pc, const char *s1,\n                                      const char *s2, int result) {\n  if (fuzzer::ScopedDoingMyOwnMemOrStr::DoingMyOwnMemOrStr) return;\n  return __sanitizer_weak_hook_strcmp(called_pc, s1, s2, result);\n}\n\nATTRIBUTE_INTERFACE ATTRIBUTE_NO_SANITIZE_MEMORY\nvoid __sanitizer_weak_hook_strstr(void *called_pc, const char *s1,\n                                  const char *s2, char *result) {\n  if (fuzzer::ScopedDoingMyOwnMemOrStr::DoingMyOwnMemOrStr) return;\n  fuzzer::TPC.MMT.Add(reinterpret_cast<const uint8_t *>(s2), strlen(s2));\n}\n\nATTRIBUTE_INTERFACE ATTRIBUTE_NO_SANITIZE_MEMORY\nvoid __sanitizer_weak_hook_strcasestr(void *called_pc, const char *s1,\n                                      const char *s2, char *result) {\n  if (fuzzer::ScopedDoingMyOwnMemOrStr::DoingMyOwnMemOrStr) return;\n  fuzzer::TPC.MMT.Add(reinterpret_cast<const uint8_t *>(s2), strlen(s2));\n}\n\nATTRIBUTE_INTERFACE ATTRIBUTE_NO_SANITIZE_MEMORY\nvoid __sanitizer_weak_hook_memmem(void *called_pc, const void *s1, size_t len1,\n                                  const void *s2, size_t len2, void *result) {\n  if (fuzzer::ScopedDoingMyOwnMemOrStr::DoingMyOwnMemOrStr) return;\n  fuzzer::TPC.MMT.Add(reinterpret_cast<const uint8_t *>(s2), len2);\n}\n}  // extern \"C\"\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerTracePC.h",
    "content": "//===- FuzzerTracePC.h - Internal header for the Fuzzer ---------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// fuzzer::TracePC\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_TRACE_PC\n#define LLVM_FUZZER_TRACE_PC\n\n#include \"FuzzerDefs.h\"\n#include \"FuzzerDictionary.h\"\n#include \"FuzzerValueBitMap.h\"\n\n#include <set>\n\nnamespace fuzzer {\n\n// TableOfRecentCompares (TORC) remembers the most recently performed\n// comparisons of type T.\n// We record the arguments of CMP instructions in this table unconditionally\n// because it seems cheaper this way than to compute some expensive\n// conditions inside __sanitizer_cov_trace_cmp*.\n// After the unit has been executed we may decide to use the contents of\n// this table to populate a Dictionary.\ntemplate<class T, size_t kSizeT>\nstruct TableOfRecentCompares {\n  static const size_t kSize = kSizeT;\n  struct Pair {\n    T A, B;\n  };\n  ATTRIBUTE_NO_SANITIZE_ALL\n  void Insert(size_t Idx, const T &Arg1, const T &Arg2) {\n    Idx = Idx % kSize;\n    Table[Idx].A = Arg1;\n    Table[Idx].B = Arg2;\n  }\n\n  Pair Get(size_t I) { return Table[I % kSize]; }\n\n  Pair Table[kSize];\n};\n\ntemplate <size_t kSizeT>\nstruct MemMemTable {\n  static const size_t kSize = kSizeT;\n  Word MemMemWords[kSize];\n  Word EmptyWord;\n\n  void Add(const uint8_t *Data, size_t Size) {\n    if (Size <= 2) return;\n    Size = std::min(Size, Word::GetMaxSize());\n    size_t Idx = SimpleFastHash(Data, Size) % kSize;\n    MemMemWords[Idx].Set(Data, Size);\n  }\n  const Word &Get(size_t Idx) {\n    for (size_t i = 0; i < kSize; i++) {\n      const Word &W = MemMemWords[(Idx + i) % kSize];\n      if (W.size()) return W;\n    }\n    EmptyWord.Set(nullptr, 0);\n    return EmptyWord;\n  }\n};\n\nclass TracePC {\n public:\n  static const size_t kNumPCs = 1 << 21;\n  // How many bits of PC are used from __sanitizer_cov_trace_pc.\n  static const size_t kTracePcBits = 18;\n\n  void HandleInit(uint32_t *Start, uint32_t *Stop);\n  void HandleInline8bitCountersInit(uint8_t *Start, uint8_t *Stop);\n  void HandlePCsInit(const uintptr_t *Start, const uintptr_t *Stop);\n  void HandleCallerCallee(uintptr_t Caller, uintptr_t Callee);\n  template <class T> void HandleCmp(uintptr_t PC, T Arg1, T Arg2);\n  size_t GetTotalPCCoverage();\n  void SetUseCounters(bool UC) { UseCounters = UC; }\n  void SetUseClangCoverage(bool UCC) { UseClangCoverage = UCC; }\n  void SetUseValueProfile(bool VP) { UseValueProfile = VP; }\n  void SetPrintNewPCs(bool P) { DoPrintNewPCs = P; }\n  void SetPrintNewFuncs(size_t P) { NumPrintNewFuncs = P; }\n  void UpdateObservedPCs();\n  template <class Callback> void CollectFeatures(Callback CB) const;\n\n  void ResetMaps() {\n    ValueProfileMap.Reset();\n    if (NumModules)\n      memset(Counters(), 0, GetNumPCs());\n    ClearExtraCounters();\n    ClearInlineCounters();\n    if (UseClangCoverage)\n      ClearClangCounters();\n  }\n\n  void ClearInlineCounters();\n\n  void UpdateFeatureSet(size_t CurrentElementIdx, size_t CurrentElementSize);\n  void PrintFeatureSet();\n\n  void PrintModuleInfo();\n\n  void PrintCoverage();\n  void DumpCoverage();\n\n  void AddValueForMemcmp(void *caller_pc, const void *s1, const void *s2,\n                         size_t n, bool StopAtZero);\n\n  TableOfRecentCompares<uint32_t, 32> TORC4;\n  TableOfRecentCompares<uint64_t, 32> TORC8;\n  TableOfRecentCompares<Word, 32> TORCW;\n  MemMemTable<1024> MMT;\n\n  size_t GetNumPCs() const {\n    return NumGuards == 0 ? (1 << kTracePcBits) : Min(kNumPCs, NumGuards + 1);\n  }\n  uintptr_t GetPC(size_t Idx) {\n    assert(Idx < GetNumPCs());\n    return PCs()[Idx];\n  }\n\n  void RecordInitialStack();\n  uintptr_t GetMaxStackOffset() const;\n\n  template<class CallBack>\n  void ForEachObservedPC(CallBack CB) {\n    for (auto PC : ObservedPCs)\n      CB(PC);\n  }\n\nprivate:\n  bool UseCounters = false;\n  bool UseValueProfile = false;\n  bool UseClangCoverage = false;\n  bool DoPrintNewPCs = false;\n  size_t NumPrintNewFuncs = 0;\n\n  struct Module {\n    uint32_t *Start, *Stop;\n  };\n\n  Module Modules[4096];\n  size_t NumModules;  // linker-initialized.\n  size_t NumGuards;  // linker-initialized.\n\n  struct { uint8_t *Start, *Stop; } ModuleCounters[4096];\n  size_t NumModulesWithInline8bitCounters;  // linker-initialized.\n  size_t NumInline8bitCounters;\n\n  struct PCTableEntry {\n    uintptr_t PC, PCFlags;\n  };\n\n  struct { const PCTableEntry *Start, *Stop; } ModulePCTable[4096];\n  size_t NumPCTables;\n  size_t NumPCsInPCTables;\n\n  uint8_t *Counters() const;\n  uintptr_t *PCs() const;\n\n  Set<uintptr_t> ObservedPCs;\n  Set<uintptr_t> ObservedFuncs;\n\n  ValueBitMap ValueProfileMap;\n  uintptr_t InitialStack;\n};\n\ntemplate <class Callback>\n// void Callback(size_t FirstFeature, size_t Idx, uint8_t Value);\nATTRIBUTE_NO_SANITIZE_ALL\nvoid ForEachNonZeroByte(const uint8_t *Begin, const uint8_t *End,\n                        size_t FirstFeature, Callback Handle8bitCounter) {\n  typedef uintptr_t LargeType;\n  const size_t Step = sizeof(LargeType) / sizeof(uint8_t);\n  const size_t StepMask = Step - 1;\n  auto P = Begin;\n  // Iterate by 1 byte until either the alignment boundary or the end.\n  for (; reinterpret_cast<uintptr_t>(P) & StepMask && P < End; P++)\n    if (uint8_t V = *P)\n      Handle8bitCounter(FirstFeature, P - Begin, V);\n\n  // Iterate by Step bytes at a time.\n  for (; P < End; P += Step)\n    if (LargeType Bundle = *reinterpret_cast<const LargeType *>(P))\n      for (size_t I = 0; I < Step; I++, Bundle >>= 8)\n        if (uint8_t V = Bundle & 0xff)\n          Handle8bitCounter(FirstFeature, P - Begin + I, V);\n\n  // Iterate by 1 byte until the end.\n  for (; P < End; P++)\n    if (uint8_t V = *P)\n      Handle8bitCounter(FirstFeature, P - Begin, V);\n}\n\n// Given a non-zero Counter returns a number in the range [0,7].\ntemplate<class T>\nunsigned CounterToFeature(T Counter) {\n    // Returns a feature number by placing Counters into buckets as illustrated\n    // below.\n    //\n    // Counter bucket: [1] [2] [3] [4-7] [8-15] [16-31] [32-127] [128+]\n    // Feature number:  0   1   2    3     4       5       6       7\n    //\n    // This is a heuristic taken from AFL (see\n    // http://lcamtuf.coredump.cx/afl/technical_details.txt).\n    //\n    // This implementation may change in the future so clients should\n    // not rely on it.\n    assert(Counter);\n    unsigned Bit = 0;\n    /**/ if (Counter >= 128) Bit = 7;\n    else if (Counter >= 32) Bit = 6;\n    else if (Counter >= 16) Bit = 5;\n    else if (Counter >= 8) Bit = 4;\n    else if (Counter >= 4) Bit = 3;\n    else if (Counter >= 3) Bit = 2;\n    else if (Counter >= 2) Bit = 1;\n    return Bit;\n}\n\ntemplate <class Callback>  // void Callback(size_t Feature)\nATTRIBUTE_NO_SANITIZE_ADDRESS\n__attribute__((noinline))\nvoid TracePC::CollectFeatures(Callback HandleFeature) const {\n  uint8_t *Counters = this->Counters();\n  size_t N = GetNumPCs();\n  auto Handle8bitCounter = [&](size_t FirstFeature,\n                               size_t Idx, uint8_t Counter) {\n    if (UseCounters)\n      HandleFeature(FirstFeature + Idx * 8 + CounterToFeature(Counter));\n    else\n      HandleFeature(FirstFeature + Idx);\n  };\n\n  size_t FirstFeature = 0;\n\n  if (!NumInline8bitCounters) {\n    ForEachNonZeroByte(Counters, Counters + N, FirstFeature, Handle8bitCounter);\n    FirstFeature += N * 8;\n  }\n\n  if (NumInline8bitCounters) {\n    for (size_t i = 0; i < NumModulesWithInline8bitCounters; i++) {\n      ForEachNonZeroByte(ModuleCounters[i].Start, ModuleCounters[i].Stop,\n                         FirstFeature, Handle8bitCounter);\n      FirstFeature += 8 * (ModuleCounters[i].Stop - ModuleCounters[i].Start);\n    }\n  }\n\n  if (size_t NumClangCounters = ClangCountersEnd() - ClangCountersBegin()) {\n    auto P = ClangCountersBegin();\n    for (size_t Idx = 0; Idx < NumClangCounters; Idx++)\n      if (auto Cnt = P[Idx]) {\n        if (UseCounters)\n          HandleFeature(FirstFeature + Idx * 8 + CounterToFeature(Cnt));\n        else\n          HandleFeature(FirstFeature + Idx);\n      }\n    FirstFeature += NumClangCounters;\n  }\n\n  ForEachNonZeroByte(ExtraCountersBegin(), ExtraCountersEnd(), FirstFeature,\n                     Handle8bitCounter);\n  FirstFeature += (ExtraCountersEnd() - ExtraCountersBegin()) * 8;\n\n  if (UseValueProfile) {\n    ValueProfileMap.ForEach([&](size_t Idx) {\n      HandleFeature(FirstFeature + Idx);\n    });\n    FirstFeature += ValueProfileMap.SizeInBits();\n  }\n\n  // Step function, grows similar to 8 * Log_2(A).\n  auto StackDepthStepFunction = [](uint32_t A) -> uint32_t {\n    if (!A) return A;\n    uint32_t Log2 = Log(A);\n    if (Log2 < 3) return A;\n    Log2 -= 3;\n    return (Log2 + 1) * 8 + ((A >> Log2) & 7);\n  };\n  assert(StackDepthStepFunction(1024) == 64);\n  assert(StackDepthStepFunction(1024 * 4) == 80);\n  assert(StackDepthStepFunction(1024 * 1024) == 144);\n\n  if (auto MaxStackOffset = GetMaxStackOffset())\n    HandleFeature(FirstFeature + StackDepthStepFunction(MaxStackOffset / 8));\n}\n\nextern TracePC TPC;\n\n}  // namespace fuzzer\n\n#endif  // LLVM_FUZZER_TRACE_PC\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerUtil.cpp",
    "content": "//===- FuzzerUtil.cpp - Misc utils ----------------------------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Misc utils.\n//===----------------------------------------------------------------------===//\n\n#include \"FuzzerUtil.h\"\n#include \"FuzzerIO.h\"\n#include \"FuzzerInternal.h\"\n#include <cassert>\n#include <chrono>\n#include <cstring>\n#include <errno.h>\n#include <signal.h>\n#include <sstream>\n#include <stdio.h>\n#include <sys/types.h>\n#include <thread>\n\nnamespace fuzzer {\n\nvoid PrintHexArray(const uint8_t *Data, size_t Size,\n                   const char *PrintAfter) {\n  for (size_t i = 0; i < Size; i++)\n    Printf(\"0x%x,\", (unsigned)Data[i]);\n  Printf(\"%s\", PrintAfter);\n}\n\nvoid Print(const Unit &v, const char *PrintAfter) {\n  PrintHexArray(v.data(), v.size(), PrintAfter);\n}\n\nvoid PrintASCIIByte(uint8_t Byte) {\n  if (Byte == '\\\\')\n    Printf(\"\\\\\\\\\");\n  else if (Byte == '\"')\n    Printf(\"\\\\\\\"\");\n  else if (Byte >= 32 && Byte < 127)\n    Printf(\"%c\", Byte);\n  else\n    Printf(\"\\\\x%02x\", Byte);\n}\n\nvoid PrintASCII(const uint8_t *Data, size_t Size, const char *PrintAfter) {\n  for (size_t i = 0; i < Size; i++)\n    PrintASCIIByte(Data[i]);\n  Printf(\"%s\", PrintAfter);\n}\n\nvoid PrintASCII(const Unit &U, const char *PrintAfter) {\n  PrintASCII(U.data(), U.size(), PrintAfter);\n}\n\nbool ToASCII(uint8_t *Data, size_t Size) {\n  bool Changed = false;\n  for (size_t i = 0; i < Size; i++) {\n    uint8_t &X = Data[i];\n    auto NewX = X;\n    NewX &= 127;\n    if (!isspace(NewX) && !isprint(NewX))\n      NewX = ' ';\n    Changed |= NewX != X;\n    X = NewX;\n  }\n  return Changed;\n}\n\nbool IsASCII(const Unit &U) { return IsASCII(U.data(), U.size()); }\n\nbool IsASCII(const uint8_t *Data, size_t Size) {\n  for (size_t i = 0; i < Size; i++)\n    if (!(isprint(Data[i]) || isspace(Data[i]))) return false;\n  return true;\n}\n\nbool ParseOneDictionaryEntry(const std::string &Str, Unit *U) {\n  U->clear();\n  if (Str.empty()) return false;\n  size_t L = 0, R = Str.size() - 1;  // We are parsing the range [L,R].\n  // Skip spaces from both sides.\n  while (L < R && isspace(Str[L])) L++;\n  while (R > L && isspace(Str[R])) R--;\n  if (R - L < 2) return false;\n  // Check the closing \"\n  if (Str[R] != '\"') return false;\n  R--;\n  // Find the opening \"\n  while (L < R && Str[L] != '\"') L++;\n  if (L >= R) return false;\n  assert(Str[L] == '\\\"');\n  L++;\n  assert(L <= R);\n  for (size_t Pos = L; Pos <= R; Pos++) {\n    uint8_t V = (uint8_t)Str[Pos];\n    if (!isprint(V) && !isspace(V)) return false;\n    if (V =='\\\\') {\n      // Handle '\\\\'\n      if (Pos + 1 <= R && (Str[Pos + 1] == '\\\\' || Str[Pos + 1] == '\"')) {\n        U->push_back(Str[Pos + 1]);\n        Pos++;\n        continue;\n      }\n      // Handle '\\xAB'\n      if (Pos + 3 <= R && Str[Pos + 1] == 'x'\n           && isxdigit(Str[Pos + 2]) && isxdigit(Str[Pos + 3])) {\n        char Hex[] = \"0xAA\";\n        Hex[2] = Str[Pos + 2];\n        Hex[3] = Str[Pos + 3];\n        U->push_back(strtol(Hex, nullptr, 16));\n        Pos += 3;\n        continue;\n      }\n      return false;  // Invalid escape.\n    } else {\n      // Any other character.\n      U->push_back(V);\n    }\n  }\n  return true;\n}\n\nbool ParseDictionaryFile(const std::string &Text, Vector<Unit> *Units) {\n  if (Text.empty()) {\n    Printf(\"ParseDictionaryFile: file does not exist or is empty\\n\");\n    return false;\n  }\n  std::istringstream ISS(Text);\n  Units->clear();\n  Unit U;\n  int LineNo = 0;\n  std::string S;\n  while (std::getline(ISS, S, '\\n')) {\n    LineNo++;\n    size_t Pos = 0;\n    while (Pos < S.size() && isspace(S[Pos])) Pos++;  // Skip spaces.\n    if (Pos == S.size()) continue;  // Empty line.\n    if (S[Pos] == '#') continue;  // Comment line.\n    if (ParseOneDictionaryEntry(S, &U)) {\n      Units->push_back(U);\n    } else {\n      Printf(\"ParseDictionaryFile: error in line %d\\n\\t\\t%s\\n\", LineNo,\n             S.c_str());\n      return false;\n    }\n  }\n  return true;\n}\n\nstd::string Base64(const Unit &U) {\n  static const char Table[] = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n                              \"abcdefghijklmnopqrstuvwxyz\"\n                              \"0123456789+/\";\n  std::string Res;\n  size_t i;\n  for (i = 0; i + 2 < U.size(); i += 3) {\n    uint32_t x = (U[i] << 16) + (U[i + 1] << 8) + U[i + 2];\n    Res += Table[(x >> 18) & 63];\n    Res += Table[(x >> 12) & 63];\n    Res += Table[(x >> 6) & 63];\n    Res += Table[x & 63];\n  }\n  if (i + 1 == U.size()) {\n    uint32_t x = (U[i] << 16);\n    Res += Table[(x >> 18) & 63];\n    Res += Table[(x >> 12) & 63];\n    Res += \"==\";\n  } else if (i + 2 == U.size()) {\n    uint32_t x = (U[i] << 16) + (U[i + 1] << 8);\n    Res += Table[(x >> 18) & 63];\n    Res += Table[(x >> 12) & 63];\n    Res += Table[(x >> 6) & 63];\n    Res += \"=\";\n  }\n  return Res;\n}\n\nstd::string DescribePC(const char *SymbolizedFMT, uintptr_t PC) {\n  if (!EF->__sanitizer_symbolize_pc) return \"<can not symbolize>\";\n  char PcDescr[1024] = {};\n  EF->__sanitizer_symbolize_pc(reinterpret_cast<void*>(PC),\n                               SymbolizedFMT, PcDescr, sizeof(PcDescr));\n  PcDescr[sizeof(PcDescr) - 1] = 0;  // Just in case.\n  return PcDescr;\n}\n\nvoid PrintPC(const char *SymbolizedFMT, const char *FallbackFMT, uintptr_t PC) {\n  if (EF->__sanitizer_symbolize_pc)\n    Printf(\"%s\", DescribePC(SymbolizedFMT, PC).c_str());\n  else\n    Printf(FallbackFMT, PC);\n}\n\nunsigned NumberOfCpuCores() {\n  unsigned N = std::thread::hardware_concurrency();\n  if (!N) {\n    Printf(\"WARNING: std::thread::hardware_concurrency not well defined for \"\n           \"your platform. Assuming CPU count of 1.\\n\");\n    N = 1;\n  }\n  return N;\n}\n\nsize_t SimpleFastHash(const uint8_t *Data, size_t Size) {\n  size_t Res = 0;\n  for (size_t i = 0; i < Size; i++)\n    Res = Res * 11 + Data[i];\n  return Res;\n}\n\n}  // namespace fuzzer\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerUtil.h",
    "content": "//===- FuzzerUtil.h - Internal header for the Fuzzer Utils ------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Util functions.\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_UTIL_H\n#define LLVM_FUZZER_UTIL_H\n\n#include \"FuzzerDefs.h\"\n#include \"FuzzerCommand.h\"\n\nnamespace fuzzer {\n\nvoid PrintHexArray(const Unit &U, const char *PrintAfter = \"\");\n\nvoid PrintHexArray(const uint8_t *Data, size_t Size,\n                   const char *PrintAfter = \"\");\n\nvoid PrintASCII(const uint8_t *Data, size_t Size, const char *PrintAfter = \"\");\n\nvoid PrintASCII(const Unit &U, const char *PrintAfter = \"\");\n\n// Changes U to contain only ASCII (isprint+isspace) characters.\n// Returns true iff U has been changed.\nbool ToASCII(uint8_t *Data, size_t Size);\n\nbool IsASCII(const Unit &U);\n\nbool IsASCII(const uint8_t *Data, size_t Size);\n\nstd::string Base64(const Unit &U);\n\nvoid PrintPC(const char *SymbolizedFMT, const char *FallbackFMT, uintptr_t PC);\n\nstd::string DescribePC(const char *SymbolizedFMT, uintptr_t PC);\n\nunsigned NumberOfCpuCores();\n\n// Platform specific functions.\nvoid SetSignalHandler(const FuzzingOptions& Options);\n\nvoid SleepSeconds(int Seconds);\n\nunsigned long GetPid();\n\nsize_t GetPeakRSSMb();\n\nint ExecuteCommand(const Command &Cmd);\n\nFILE *OpenProcessPipe(const char *Command, const char *Mode);\n\nconst void *SearchMemory(const void *haystack, size_t haystacklen,\n                         const void *needle, size_t needlelen);\n\nstd::string CloneArgsWithoutX(const Vector<std::string> &Args,\n                              const char *X1, const char *X2);\n\ninline std::string CloneArgsWithoutX(const Vector<std::string> &Args,\n                                     const char *X) {\n  return CloneArgsWithoutX(Args, X, X);\n}\n\ninline std::pair<std::string, std::string> SplitBefore(std::string X,\n                                                       std::string S) {\n  auto Pos = S.find(X);\n  if (Pos == std::string::npos)\n    return std::make_pair(S, \"\");\n  return std::make_pair(S.substr(0, Pos), S.substr(Pos));\n}\n\nstd::string DisassembleCmd(const std::string &FileName);\n\nstd::string SearchRegexCmd(const std::string &Regex);\n\nsize_t SimpleFastHash(const uint8_t *Data, size_t Size);\n\ninline uint32_t Log(uint32_t X) { return 32 - __builtin_clz(X) - 1; }\n\n}  // namespace fuzzer\n\n#endif  // LLVM_FUZZER_UTIL_H\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerUtilDarwin.cpp",
    "content": "//===- FuzzerUtilDarwin.cpp - Misc utils ----------------------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Misc utils for Darwin.\n//===----------------------------------------------------------------------===//\n#include \"FuzzerDefs.h\"\n#if LIBFUZZER_APPLE\n#include \"FuzzerCommand.h\"\n#include \"FuzzerIO.h\"\n#include <mutex>\n#include <signal.h>\n#include <spawn.h>\n#include <stdlib.h>\n#include <string.h>\n#include <sys/wait.h>\n\n// There is no header for this on macOS so declare here\nextern \"C\" char **environ;\n\nnamespace fuzzer {\n\nstatic std::mutex SignalMutex;\n// Global variables used to keep track of how signal handling should be\n// restored. They should **not** be accessed without holding `SignalMutex`.\nstatic int ActiveThreadCount = 0;\nstatic struct sigaction OldSigIntAction;\nstatic struct sigaction OldSigQuitAction;\nstatic sigset_t OldBlockedSignalsSet;\n\n// This is a reimplementation of Libc's `system()`. On Darwin the Libc\n// implementation contains a mutex which prevents it from being used\n// concurrently. This implementation **can** be used concurrently. It sets the\n// signal handlers when the first thread enters and restores them when the last\n// thread finishes execution of the function and ensures this is not racey by\n// using a mutex.\nint ExecuteCommand(const Command &Cmd) {\n  std::string CmdLine = Cmd.toString();\n  posix_spawnattr_t SpawnAttributes;\n  if (posix_spawnattr_init(&SpawnAttributes))\n    return -1;\n  // Block and ignore signals of the current process when the first thread\n  // enters.\n  {\n    std::lock_guard<std::mutex> Lock(SignalMutex);\n    if (ActiveThreadCount == 0) {\n      static struct sigaction IgnoreSignalAction;\n      sigset_t BlockedSignalsSet;\n      memset(&IgnoreSignalAction, 0, sizeof(IgnoreSignalAction));\n      IgnoreSignalAction.sa_handler = SIG_IGN;\n\n      if (sigaction(SIGINT, &IgnoreSignalAction, &OldSigIntAction) == -1) {\n        Printf(\"Failed to ignore SIGINT\\n\");\n        (void)posix_spawnattr_destroy(&SpawnAttributes);\n        return -1;\n      }\n      if (sigaction(SIGQUIT, &IgnoreSignalAction, &OldSigQuitAction) == -1) {\n        Printf(\"Failed to ignore SIGQUIT\\n\");\n        // Try our best to restore the signal handlers.\n        (void)sigaction(SIGINT, &OldSigIntAction, NULL);\n        (void)posix_spawnattr_destroy(&SpawnAttributes);\n        return -1;\n      }\n\n      (void)sigemptyset(&BlockedSignalsSet);\n      (void)sigaddset(&BlockedSignalsSet, SIGCHLD);\n      if (sigprocmask(SIG_BLOCK, &BlockedSignalsSet, &OldBlockedSignalsSet) ==\n          -1) {\n        Printf(\"Failed to block SIGCHLD\\n\");\n        // Try our best to restore the signal handlers.\n        (void)sigaction(SIGQUIT, &OldSigQuitAction, NULL);\n        (void)sigaction(SIGINT, &OldSigIntAction, NULL);\n        (void)posix_spawnattr_destroy(&SpawnAttributes);\n        return -1;\n      }\n    }\n    ++ActiveThreadCount;\n  }\n\n  // NOTE: Do not introduce any new `return` statements past this\n  // point. It is important that `ActiveThreadCount` always be decremented\n  // when leaving this function.\n\n  // Make sure the child process uses the default handlers for the\n  // following signals rather than inheriting what the parent has.\n  sigset_t DefaultSigSet;\n  (void)sigemptyset(&DefaultSigSet);\n  (void)sigaddset(&DefaultSigSet, SIGQUIT);\n  (void)sigaddset(&DefaultSigSet, SIGINT);\n  (void)posix_spawnattr_setsigdefault(&SpawnAttributes, &DefaultSigSet);\n  // Make sure the child process doesn't block SIGCHLD\n  (void)posix_spawnattr_setsigmask(&SpawnAttributes, &OldBlockedSignalsSet);\n  short SpawnFlags = POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK;\n  (void)posix_spawnattr_setflags(&SpawnAttributes, SpawnFlags);\n\n  pid_t Pid;\n  char **Environ = environ; // Read from global\n  const char *CommandCStr = CmdLine.c_str();\n  char *const Argv[] = {\n    strdup(\"sh\"),\n    strdup(\"-c\"),\n    strdup(CommandCStr),\n    NULL\n  };\n  int ErrorCode = 0, ProcessStatus = 0;\n  // FIXME: We probably shouldn't hardcode the shell path.\n  ErrorCode = posix_spawn(&Pid, \"/bin/sh\", NULL, &SpawnAttributes,\n                          Argv, Environ);\n  (void)posix_spawnattr_destroy(&SpawnAttributes);\n  if (!ErrorCode) {\n    pid_t SavedPid = Pid;\n    do {\n      // Repeat until call completes uninterrupted.\n      Pid = waitpid(SavedPid, &ProcessStatus, /*options=*/0);\n    } while (Pid == -1 && errno == EINTR);\n    if (Pid == -1) {\n      // Fail for some other reason.\n      ProcessStatus = -1;\n    }\n  } else if (ErrorCode == ENOMEM || ErrorCode == EAGAIN) {\n    // Fork failure.\n    ProcessStatus = -1;\n  } else {\n    // Shell execution failure.\n    ProcessStatus = W_EXITCODE(127, 0);\n  }\n  for (unsigned i = 0, n = sizeof(Argv) / sizeof(Argv[0]); i < n; ++i)\n    free(Argv[i]);\n\n  // Restore the signal handlers of the current process when the last thread\n  // using this function finishes.\n  {\n    std::lock_guard<std::mutex> Lock(SignalMutex);\n    --ActiveThreadCount;\n    if (ActiveThreadCount == 0) {\n      bool FailedRestore = false;\n      if (sigaction(SIGINT, &OldSigIntAction, NULL) == -1) {\n        Printf(\"Failed to restore SIGINT handling\\n\");\n        FailedRestore = true;\n      }\n      if (sigaction(SIGQUIT, &OldSigQuitAction, NULL) == -1) {\n        Printf(\"Failed to restore SIGQUIT handling\\n\");\n        FailedRestore = true;\n      }\n      if (sigprocmask(SIG_BLOCK, &OldBlockedSignalsSet, NULL) == -1) {\n        Printf(\"Failed to unblock SIGCHLD\\n\");\n        FailedRestore = true;\n      }\n      if (FailedRestore)\n        ProcessStatus = -1;\n    }\n  }\n  return ProcessStatus;\n}\n\n} // namespace fuzzer\n\n#endif // LIBFUZZER_APPLE\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerUtilFuchsia.cpp",
    "content": "//===- FuzzerUtilFuchsia.cpp - Misc utils for Fuchsia. --------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Misc utils implementation using Fuchsia/Zircon APIs.\n//===----------------------------------------------------------------------===//\n#include \"FuzzerDefs.h\"\n\n#if LIBFUZZER_FUCHSIA\n\n#include \"FuzzerInternal.h\"\n#include \"FuzzerUtil.h\"\n#include <cerrno>\n#include <cinttypes>\n#include <cstdint>\n#include <fbl/unique_fd.h>\n#include <fcntl.h>\n#include <launchpad/launchpad.h>\n#include <string>\n#include <thread>\n#include <zircon/errors.h>\n#include <zircon/status.h>\n#include <zircon/syscalls.h>\n#include <zircon/syscalls/port.h>\n#include <zircon/types.h>\n#include <zx/object.h>\n#include <zx/port.h>\n#include <zx/process.h>\n#include <zx/time.h>\n\nnamespace fuzzer {\n\nnamespace {\n\n// A magic value for the Zircon exception port, chosen to spell 'FUZZING'\n// when interpreted as a byte sequence on little-endian platforms.\nconst uint64_t kFuzzingCrash = 0x474e495a5a5546;\n\nvoid AlarmHandler(int Seconds) {\n  while (true) {\n    SleepSeconds(Seconds);\n    Fuzzer::StaticAlarmCallback();\n  }\n}\n\nvoid InterruptHandler() {\n  // Ctrl-C sends ETX in Zircon.\n  while (getchar() != 0x03);\n  Fuzzer::StaticInterruptCallback();\n}\n\nvoid CrashHandler(zx::port *Port) {\n  std::unique_ptr<zx::port> ExceptionPort(Port);\n  zx_port_packet_t Packet;\n  ExceptionPort->wait(ZX_TIME_INFINITE, &Packet, 0);\n  // Unbind as soon as possible so we don't receive exceptions from this thread.\n  if (zx_task_bind_exception_port(ZX_HANDLE_INVALID, ZX_HANDLE_INVALID,\n                                  kFuzzingCrash, 0) != ZX_OK) {\n    // Shouldn't happen; if it does the safest option is to just exit.\n    Printf(\"libFuzzer: unable to unbind exception port; aborting!\\n\");\n    exit(1);\n  }\n  if (Packet.key != kFuzzingCrash) {\n    Printf(\"libFuzzer: invalid crash key: %\" PRIx64 \"; aborting!\\n\",\n           Packet.key);\n    exit(1);\n  }\n  // CrashCallback should not return from this call\n  Fuzzer::StaticCrashSignalCallback();\n}\n\n} // namespace\n\n// Platform specific functions.\nvoid SetSignalHandler(const FuzzingOptions &Options) {\n  zx_status_t rc;\n\n  // Set up alarm handler if needed.\n  if (Options.UnitTimeoutSec > 0) {\n    std::thread T(AlarmHandler, Options.UnitTimeoutSec / 2 + 1);\n    T.detach();\n  }\n\n  // Set up interrupt handler if needed.\n  if (Options.HandleInt || Options.HandleTerm) {\n    std::thread T(InterruptHandler);\n    T.detach();\n  }\n\n  // Early exit if no crash handler needed.\n  if (!Options.HandleSegv && !Options.HandleBus && !Options.HandleIll &&\n      !Options.HandleFpe && !Options.HandleAbrt)\n    return;\n\n  // Create an exception port\n  zx::port *ExceptionPort = new zx::port();\n  if ((rc = zx::port::create(0, ExceptionPort)) != ZX_OK) {\n    Printf(\"libFuzzer: zx_port_create failed: %s\\n\", zx_status_get_string(rc));\n    exit(1);\n  }\n\n  // Bind the port to receive exceptions from our process\n  if ((rc = zx_task_bind_exception_port(zx_process_self(), ExceptionPort->get(),\n                                        kFuzzingCrash, 0)) != ZX_OK) {\n    Printf(\"libFuzzer: unable to bind exception port: %s\\n\",\n           zx_status_get_string(rc));\n    exit(1);\n  }\n\n  // Set up the crash handler.\n  std::thread T(CrashHandler, ExceptionPort);\n  T.detach();\n}\n\nvoid SleepSeconds(int Seconds) {\n  zx::nanosleep(zx::deadline_after(ZX_SEC(Seconds)));\n}\n\nunsigned long GetPid() {\n  zx_status_t rc;\n  zx_info_handle_basic_t Info;\n  if ((rc = zx_object_get_info(zx_process_self(), ZX_INFO_HANDLE_BASIC, &Info,\n                               sizeof(Info), NULL, NULL)) != ZX_OK) {\n    Printf(\"libFuzzer: unable to get info about self: %s\\n\",\n           zx_status_get_string(rc));\n    exit(1);\n  }\n  return Info.koid;\n}\n\nsize_t GetPeakRSSMb() {\n  zx_status_t rc;\n  zx_info_task_stats_t Info;\n  if ((rc = zx_object_get_info(zx_process_self(), ZX_INFO_TASK_STATS, &Info,\n                               sizeof(Info), NULL, NULL)) != ZX_OK) {\n    Printf(\"libFuzzer: unable to get info about self: %s\\n\",\n           zx_status_get_string(rc));\n    exit(1);\n  }\n  return (Info.mem_private_bytes + Info.mem_shared_bytes) >> 20;\n}\n\nint ExecuteCommand(const Command &Cmd) {\n  zx_status_t rc;\n\n  // Convert arguments to C array\n  auto Args = Cmd.getArguments();\n  size_t Argc = Args.size();\n  assert(Argc != 0);\n  std::unique_ptr<const char *[]> Argv(new const char *[Argc]);\n  for (size_t i = 0; i < Argc; ++i)\n    Argv[i] = Args[i].c_str();\n\n  // Create the basic launchpad.  Clone everything except stdio.\n  launchpad_t *lp;\n  launchpad_create(ZX_HANDLE_INVALID, Argv[0], &lp);\n  launchpad_load_from_file(lp, Argv[0]);\n  launchpad_set_args(lp, Argc, Argv.get());\n  launchpad_clone(lp, LP_CLONE_ALL & (~LP_CLONE_FDIO_STDIO));\n\n  // Determine stdout\n  int FdOut = STDOUT_FILENO;\n  fbl::unique_fd OutputFile;\n  if (Cmd.hasOutputFile()) {\n    auto Filename = Cmd.getOutputFile();\n    OutputFile.reset(open(Filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0));\n    if (!OutputFile) {\n      Printf(\"libFuzzer: failed to open %s: %s\\n\", Filename.c_str(),\n             strerror(errno));\n      return ZX_ERR_IO;\n    }\n    FdOut = OutputFile.get();\n  }\n\n  // Determine stderr\n  int FdErr = STDERR_FILENO;\n  if (Cmd.isOutAndErrCombined())\n    FdErr = FdOut;\n\n  // Clone the file descriptors into the new process\n  if ((rc = launchpad_clone_fd(lp, STDIN_FILENO, STDIN_FILENO)) != ZX_OK ||\n      (rc = launchpad_clone_fd(lp, FdOut, STDOUT_FILENO)) != ZX_OK ||\n      (rc = launchpad_clone_fd(lp, FdErr, STDERR_FILENO)) != ZX_OK) {\n    Printf(\"libFuzzer: failed to clone FDIO: %s\\n\", zx_status_get_string(rc));\n    return rc;\n  }\n\n  // Start the process\n  zx_handle_t ProcessHandle = ZX_HANDLE_INVALID;\n  const char *ErrorMsg = nullptr;\n  if ((rc = launchpad_go(lp, &ProcessHandle, &ErrorMsg)) != ZX_OK) {\n    Printf(\"libFuzzer: failed to launch '%s': %s, %s\\n\", Argv[0], ErrorMsg,\n           zx_status_get_string(rc));\n    return rc;\n  }\n  zx::process Process(ProcessHandle);\n\n  // Now join the process and return the exit status.\n  if ((rc = Process.wait_one(ZX_PROCESS_TERMINATED, ZX_TIME_INFINITE,\n                             nullptr)) != ZX_OK) {\n    Printf(\"libFuzzer: failed to join '%s': %s\\n\", Argv[0],\n           zx_status_get_string(rc));\n    return rc;\n  }\n\n  zx_info_process_t Info;\n  if ((rc = Process.get_info(ZX_INFO_PROCESS, &Info, sizeof(Info), nullptr,\n                             nullptr)) != ZX_OK) {\n    Printf(\"libFuzzer: unable to get return code from '%s': %s\\n\", Argv[0],\n           zx_status_get_string(rc));\n    return rc;\n  }\n\n  return Info.return_code;\n}\n\nconst void *SearchMemory(const void *Data, size_t DataLen, const void *Patt,\n                         size_t PattLen) {\n  return memmem(Data, DataLen, Patt, PattLen);\n}\n\n} // namespace fuzzer\n\n#endif // LIBFUZZER_FUCHSIA\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerUtilLinux.cpp",
    "content": "//===- FuzzerUtilLinux.cpp - Misc utils for Linux. ------------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Misc utils for Linux.\n//===----------------------------------------------------------------------===//\n#include \"FuzzerDefs.h\"\n#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD\n#include \"FuzzerCommand.h\"\n\n#include <stdlib.h>\n\nnamespace fuzzer {\n\nint ExecuteCommand(const Command &Cmd) {\n  std::string CmdLine = Cmd.toString();\n  return system(CmdLine.c_str());\n}\n\n} // namespace fuzzer\n\n#endif // LIBFUZZER_LINUX || LIBFUZZER_NETBSD\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerUtilPosix.cpp",
    "content": "//===- FuzzerUtilPosix.cpp - Misc utils for Posix. ------------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Misc utils implementation using Posix API.\n//===----------------------------------------------------------------------===//\n#include \"FuzzerDefs.h\"\n#if LIBFUZZER_POSIX\n#include \"FuzzerIO.h\"\n#include \"FuzzerInternal.h\"\n#include <cassert>\n#include <chrono>\n#include <cstring>\n#include <errno.h>\n#include <iomanip>\n#include <signal.h>\n#include <stdio.h>\n#include <sys/resource.h>\n#include <sys/syscall.h>\n#include <sys/time.h>\n#include <sys/types.h>\n#include <thread>\n#include <unistd.h>\n\nnamespace fuzzer {\n\nstatic void AlarmHandler(int, siginfo_t *, void *) {\n  Fuzzer::StaticAlarmCallback();\n}\n\nstatic void CrashHandler(int, siginfo_t *, void *) {\n  Fuzzer::StaticCrashSignalCallback();\n}\n\nstatic void InterruptHandler(int, siginfo_t *, void *) {\n  Fuzzer::StaticInterruptCallback();\n}\n\nstatic void GracefulExitHandler(int, siginfo_t *, void *) {\n  Fuzzer::StaticGracefulExitCallback();\n}\n\nstatic void FileSizeExceedHandler(int, siginfo_t *, void *) {\n  Fuzzer::StaticFileSizeExceedCallback();\n}\n\nstatic void SetSigaction(int signum,\n                         void (*callback)(int, siginfo_t *, void *)) {\n  struct sigaction sigact = {};\n  if (sigaction(signum, nullptr, &sigact)) {\n    Printf(\"libFuzzer: sigaction failed with %d\\n\", errno);\n    exit(1);\n  }\n  if (sigact.sa_flags & SA_SIGINFO) {\n    if (sigact.sa_sigaction)\n      return;\n  } else {\n    if (sigact.sa_handler != SIG_DFL && sigact.sa_handler != SIG_IGN &&\n        sigact.sa_handler != SIG_ERR)\n      return;\n  }\n\n  sigact = {};\n  sigact.sa_sigaction = callback;\n  if (sigaction(signum, &sigact, 0)) {\n    Printf(\"libFuzzer: sigaction failed with %d\\n\", errno);\n    exit(1);\n  }\n}\n\nvoid SetTimer(int Seconds) {\n  struct itimerval T {\n    {Seconds, 0}, { Seconds, 0 }\n  };\n  if (setitimer(ITIMER_REAL, &T, nullptr)) {\n    Printf(\"libFuzzer: setitimer failed with %d\\n\", errno);\n    exit(1);\n  }\n  SetSigaction(SIGALRM, AlarmHandler);\n}\n\nvoid SetSignalHandler(const FuzzingOptions& Options) {\n  if (Options.UnitTimeoutSec > 0)\n    SetTimer(Options.UnitTimeoutSec / 2 + 1);\n  if (Options.HandleInt)\n    SetSigaction(SIGINT, InterruptHandler);\n  if (Options.HandleTerm)\n    SetSigaction(SIGTERM, InterruptHandler);\n  if (Options.HandleSegv)\n    SetSigaction(SIGSEGV, CrashHandler);\n  if (Options.HandleBus)\n    SetSigaction(SIGBUS, CrashHandler);\n  if (Options.HandleAbrt)\n    SetSigaction(SIGABRT, CrashHandler);\n  if (Options.HandleIll)\n    SetSigaction(SIGILL, CrashHandler);\n  if (Options.HandleFpe)\n    SetSigaction(SIGFPE, CrashHandler);\n  if (Options.HandleXfsz)\n    SetSigaction(SIGXFSZ, FileSizeExceedHandler);\n  if (Options.HandleUsr1)\n    SetSigaction(SIGUSR1, GracefulExitHandler);\n  if (Options.HandleUsr2)\n    SetSigaction(SIGUSR2, GracefulExitHandler);\n}\n\nvoid SleepSeconds(int Seconds) {\n  sleep(Seconds); // Use C API to avoid coverage from instrumented libc++.\n}\n\nunsigned long GetPid() { return (unsigned long)getpid(); }\n\nsize_t GetPeakRSSMb() {\n  struct rusage usage;\n  if (getrusage(RUSAGE_SELF, &usage))\n    return 0;\n  if (LIBFUZZER_LINUX) {\n    // ru_maxrss is in KiB\n    return usage.ru_maxrss >> 10;\n  } else if (LIBFUZZER_APPLE) {\n    // ru_maxrss is in bytes\n    return usage.ru_maxrss >> 20;\n  }\n  assert(0 && \"GetPeakRSSMb() is not implemented for your platform\");\n  return 0;\n}\n\nFILE *OpenProcessPipe(const char *Command, const char *Mode) {\n  return popen(Command, Mode);\n}\n\nconst void *SearchMemory(const void *Data, size_t DataLen, const void *Patt,\n                         size_t PattLen) {\n  return memmem(Data, DataLen, Patt, PattLen);\n}\n\nstd::string DisassembleCmd(const std::string &FileName) {\n  return \"objdump -d \" + FileName;\n}\n\nstd::string SearchRegexCmd(const std::string &Regex) {\n  return \"grep '\" + Regex + \"'\";\n}\n\n}  // namespace fuzzer\n\n#endif // LIBFUZZER_POSIX\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerUtilWindows.cpp",
    "content": "//===- FuzzerUtilWindows.cpp - Misc utils for Windows. --------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Misc utils implementation for Windows.\n//===----------------------------------------------------------------------===//\n#include \"FuzzerDefs.h\"\n#if LIBFUZZER_WINDOWS\n#include \"FuzzerCommand.h\"\n#include \"FuzzerIO.h\"\n#include \"FuzzerInternal.h\"\n#include <cassert>\n#include <chrono>\n#include <cstring>\n#include <errno.h>\n#include <iomanip>\n#include <signal.h>\n#include <stdio.h>\n#include <sys/types.h>\n#include <windows.h>\n\n// This must be included after windows.h.\n#include <Psapi.h>\n\nnamespace fuzzer {\n\nstatic const FuzzingOptions* HandlerOpt = nullptr;\n\nstatic LONG CALLBACK ExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo) {\n  switch (ExceptionInfo->ExceptionRecord->ExceptionCode) {\n    case EXCEPTION_ACCESS_VIOLATION:\n    case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:\n    case EXCEPTION_STACK_OVERFLOW:\n      if (HandlerOpt->HandleSegv)\n        Fuzzer::StaticCrashSignalCallback();\n      break;\n    case EXCEPTION_DATATYPE_MISALIGNMENT:\n    case EXCEPTION_IN_PAGE_ERROR:\n      if (HandlerOpt->HandleBus)\n        Fuzzer::StaticCrashSignalCallback();\n      break;\n    case EXCEPTION_ILLEGAL_INSTRUCTION:\n    case EXCEPTION_PRIV_INSTRUCTION:\n      if (HandlerOpt->HandleIll)\n        Fuzzer::StaticCrashSignalCallback();\n      break;\n    case EXCEPTION_FLT_DENORMAL_OPERAND:\n    case EXCEPTION_FLT_DIVIDE_BY_ZERO:\n    case EXCEPTION_FLT_INEXACT_RESULT:\n    case EXCEPTION_FLT_INVALID_OPERATION:\n    case EXCEPTION_FLT_OVERFLOW:\n    case EXCEPTION_FLT_STACK_CHECK:\n    case EXCEPTION_FLT_UNDERFLOW:\n    case EXCEPTION_INT_DIVIDE_BY_ZERO:\n    case EXCEPTION_INT_OVERFLOW:\n      if (HandlerOpt->HandleFpe)\n        Fuzzer::StaticCrashSignalCallback();\n      break;\n    // TODO: handle (Options.HandleXfsz)\n  }\n  return EXCEPTION_CONTINUE_SEARCH;\n}\n\nBOOL WINAPI CtrlHandler(DWORD dwCtrlType) {\n  switch (dwCtrlType) {\n    case CTRL_C_EVENT:\n      if (HandlerOpt->HandleInt)\n        Fuzzer::StaticInterruptCallback();\n      return TRUE;\n    case CTRL_BREAK_EVENT:\n      if (HandlerOpt->HandleTerm)\n        Fuzzer::StaticInterruptCallback();\n      return TRUE;\n  }\n  return FALSE;\n}\n\nvoid CALLBACK AlarmHandler(PVOID, BOOLEAN) {\n  Fuzzer::StaticAlarmCallback();\n}\n\nclass TimerQ {\n  HANDLE TimerQueue;\n public:\n  TimerQ() : TimerQueue(NULL) {};\n  ~TimerQ() {\n    if (TimerQueue)\n      DeleteTimerQueueEx(TimerQueue, NULL);\n  };\n  void SetTimer(int Seconds) {\n    if (!TimerQueue) {\n      TimerQueue = CreateTimerQueue();\n      if (!TimerQueue) {\n        Printf(\"libFuzzer: CreateTimerQueue failed.\\n\");\n        exit(1);\n      }\n    }\n    HANDLE Timer;\n    if (!CreateTimerQueueTimer(&Timer, TimerQueue, AlarmHandler, NULL,\n        Seconds*1000, Seconds*1000, 0)) {\n      Printf(\"libFuzzer: CreateTimerQueueTimer failed.\\n\");\n      exit(1);\n    }\n  };\n};\n\nstatic TimerQ Timer;\n\nstatic void CrashHandler(int) { Fuzzer::StaticCrashSignalCallback(); }\n\nvoid SetSignalHandler(const FuzzingOptions& Options) {\n  HandlerOpt = &Options;\n\n  if (Options.UnitTimeoutSec > 0)\n    Timer.SetTimer(Options.UnitTimeoutSec / 2 + 1);\n\n  if (Options.HandleInt || Options.HandleTerm)\n    if (!SetConsoleCtrlHandler(CtrlHandler, TRUE)) {\n      DWORD LastError = GetLastError();\n      Printf(\"libFuzzer: SetConsoleCtrlHandler failed (Error code: %lu).\\n\",\n        LastError);\n      exit(1);\n    }\n\n  if (Options.HandleSegv || Options.HandleBus || Options.HandleIll ||\n      Options.HandleFpe)\n    SetUnhandledExceptionFilter(ExceptionHandler);\n\n  if (Options.HandleAbrt)\n    if (SIG_ERR == signal(SIGABRT, CrashHandler)) {\n      Printf(\"libFuzzer: signal failed with %d\\n\", errno);\n      exit(1);\n    }\n}\n\nvoid SleepSeconds(int Seconds) { Sleep(Seconds * 1000); }\n\nunsigned long GetPid() { return GetCurrentProcessId(); }\n\nsize_t GetPeakRSSMb() {\n  PROCESS_MEMORY_COUNTERS info;\n  if (!GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info)))\n    return 0;\n  return info.PeakWorkingSetSize >> 20;\n}\n\nFILE *OpenProcessPipe(const char *Command, const char *Mode) {\n  return _popen(Command, Mode);\n}\n\nint ExecuteCommand(const Command &Cmd) {\n  std::string CmdLine = Cmd.toString();\n  return system(CmdLine.c_str());\n}\n\nconst void *SearchMemory(const void *Data, size_t DataLen, const void *Patt,\n                         size_t PattLen) {\n  // TODO: make this implementation more efficient.\n  const char *Cdata = (const char *)Data;\n  const char *Cpatt = (const char *)Patt;\n\n  if (!Data || !Patt || DataLen == 0 || PattLen == 0 || DataLen < PattLen)\n    return NULL;\n\n  if (PattLen == 1)\n    return memchr(Data, *Cpatt, DataLen);\n\n  const char *End = Cdata + DataLen - PattLen + 1;\n\n  for (const char *It = Cdata; It < End; ++It)\n    if (It[0] == Cpatt[0] && memcmp(It, Cpatt, PattLen) == 0)\n      return It;\n\n  return NULL;\n}\n\nstd::string DisassembleCmd(const std::string &FileName) {\n  if (ExecuteCommand(\"dumpbin /summary > nul\") == 0)\n    return \"dumpbin /disasm \" + FileName;\n  Printf(\"libFuzzer: couldn't find tool to disassemble (dumpbin)\\n\");\n  exit(1);\n}\n\nstd::string SearchRegexCmd(const std::string &Regex) {\n  return \"findstr /r \\\"\" + Regex + \"\\\"\";\n}\n\n} // namespace fuzzer\n\n#endif // LIBFUZZER_WINDOWS\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/FuzzerValueBitMap.h",
    "content": "//===- FuzzerValueBitMap.h - INTERNAL - Bit map -----------------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// ValueBitMap.\n//===----------------------------------------------------------------------===//\n\n#ifndef LLVM_FUZZER_VALUE_BIT_MAP_H\n#define LLVM_FUZZER_VALUE_BIT_MAP_H\n\n#include \"FuzzerDefs.h\"\n\nnamespace fuzzer {\n\n// A bit map containing kMapSizeInWords bits.\nstruct ValueBitMap {\n  static const size_t kMapSizeInBits = 1 << 16;\n  static const size_t kMapPrimeMod = 65371;  // Largest Prime < kMapSizeInBits;\n  static const size_t kBitsInWord = (sizeof(uintptr_t) * 8);\n  static const size_t kMapSizeInWords = kMapSizeInBits / kBitsInWord;\n public:\n\n  // Clears all bits.\n  void Reset() { memset(Map, 0, sizeof(Map)); }\n\n  // Computes a hash function of Value and sets the corresponding bit.\n  // Returns true if the bit was changed from 0 to 1.\n  ATTRIBUTE_NO_SANITIZE_ALL\n  inline bool AddValue(uintptr_t Value) {\n    uintptr_t Idx = Value % kMapSizeInBits;\n    uintptr_t WordIdx = Idx / kBitsInWord;\n    uintptr_t BitIdx = Idx % kBitsInWord;\n    uintptr_t Old = Map[WordIdx];\n    uintptr_t New = Old | (1UL << BitIdx);\n    Map[WordIdx] = New;\n    return New != Old;\n  }\n\n  ATTRIBUTE_NO_SANITIZE_ALL\n  inline bool AddValueModPrime(uintptr_t Value) {\n    return AddValue(Value % kMapPrimeMod);\n  }\n\n  inline bool Get(uintptr_t Idx) {\n    assert(Idx < kMapSizeInBits);\n    uintptr_t WordIdx = Idx / kBitsInWord;\n    uintptr_t BitIdx = Idx % kBitsInWord;\n    return Map[WordIdx] & (1UL << BitIdx);\n  }\n\n  size_t SizeInBits() const { return kMapSizeInBits; }\n\n  template <class Callback>\n  ATTRIBUTE_NO_SANITIZE_ALL\n  void ForEach(Callback CB) const {\n    for (size_t i = 0; i < kMapSizeInWords; i++)\n      if (uintptr_t M = Map[i])\n        for (size_t j = 0; j < sizeof(M) * 8; j++)\n          if (M & ((uintptr_t)1 << j))\n            CB(i * sizeof(M) * 8 + j);\n  }\n\n private:\n  uintptr_t Map[kMapSizeInWords] __attribute__((aligned(512)));\n};\n\n}  // namespace fuzzer\n\n#endif  // LLVM_FUZZER_VALUE_BIT_MAP_H\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/README.txt",
    "content": "See http://llvm.org/docs/LibFuzzer.html\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/afl/afl_driver.cpp",
    "content": "//===- afl_driver.cpp - a glue between AFL and libFuzzer --------*- C++ -* ===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//===----------------------------------------------------------------------===//\n\n/* This file allows to fuzz libFuzzer-style target functions\n (LLVMFuzzerTestOneInput) with AFL using AFL's persistent (in-process) mode.\n\nUsage:\n################################################################################\ncat << EOF > test_fuzzer.cc\n#include <stddef.h>\n#include <stdint.h>\nextern \"C\" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {\n  if (size > 0 && data[0] == 'H')\n    if (size > 1 && data[1] == 'I')\n       if (size > 2 && data[2] == '!')\n       __builtin_trap();\n  return 0;\n}\nEOF\n# Build your target with -fsanitize-coverage=trace-pc-guard using fresh clang.\nclang -g -fsanitize-coverage=trace-pc-guard test_fuzzer.cc -c\n# Build afl-llvm-rt.o.c from the AFL distribution.\nclang -c -w $AFL_HOME/llvm_mode/afl-llvm-rt.o.c\n# Build this file, link it with afl-llvm-rt.o.o and the target code.\nclang++ afl_driver.cpp test_fuzzer.o afl-llvm-rt.o.o\n# Run AFL:\nrm -rf IN OUT; mkdir IN OUT; echo z > IN/z;\n$AFL_HOME/afl-fuzz -i IN -o OUT ./a.out\n################################################################################\nEnvironment Variables:\nThere are a few environment variables that can be set to use features that\nafl-fuzz doesn't have.\n\nAFL_DRIVER_STDERR_DUPLICATE_FILENAME: Setting this *appends* stderr to the file\nspecified. If the file does not exist, it is created. This is useful for getting\nstack traces (when using ASAN for example) or original error messages on hard to\nreproduce bugs.\n\nAFL_DRIVER_EXTRA_STATS_FILENAME: Setting this causes afl_driver to write extra\nstatistics to the file specified. Currently these are peak_rss_mb\n(the peak amount of virtual memory used in MB) and slowest_unit_time_secs. If\nthe file does not exist it is created. If the file does exist then\nafl_driver assumes it was restarted by afl-fuzz and will try to read old\nstatistics from the file. If that fails then the process will quit.\n\n*/\n#include <assert.h>\n#include <errno.h>\n#include <signal.h>\n#include <stdint.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <sys/resource.h>\n#include <sys/time.h>\n#include <unistd.h>\n\n#include <fstream>\n#include <iostream>\n#include <vector>\n\n// Platform detection. Copied from FuzzerInternal.h\n#ifdef __linux__\n#define LIBFUZZER_LINUX 1\n#define LIBFUZZER_APPLE 0\n#define LIBFUZZER_NETBSD 0\n#elif __APPLE__\n#define LIBFUZZER_LINUX 0\n#define LIBFUZZER_APPLE 1\n#define LIBFUZZER_NETBSD 0\n#elif __NetBSD__\n#define LIBFUZZER_LINUX 0\n#define LIBFUZZER_APPLE 0\n#define LIBFUZZER_NETBSD 1\n#else\n#error \"Support for your platform has not been implemented\"\n#endif\n\n// Used to avoid repeating error checking boilerplate. If cond is false, a\n// fatal error has occured in the program. In this event print error_message\n// to stderr and abort(). Otherwise do nothing. Note that setting\n// AFL_DRIVER_STDERR_DUPLICATE_FILENAME may cause error_message to be appended\n// to the file as well, if the error occurs after the duplication is performed.\n#define CHECK_ERROR(cond, error_message)                                       \\\n  if (!(cond)) {                                                               \\\n    fprintf(stderr, \"%s\\n\", (error_message));                                  \\\n    abort();                                                                   \\\n  }\n\n// libFuzzer interface is thin, so we don't include any libFuzzer headers.\nextern \"C\" {\nint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);\n__attribute__((weak)) int LLVMFuzzerInitialize(int *argc, char ***argv);\n}\n\n// Notify AFL about persistent mode.\nstatic volatile char AFL_PERSISTENT[] = \"##SIG_AFL_PERSISTENT##\";\nextern \"C\" int __afl_persistent_loop(unsigned int);\nstatic volatile char suppress_warning2 = AFL_PERSISTENT[0];\n\n// Notify AFL about deferred forkserver.\nstatic volatile char AFL_DEFER_FORKSVR[] = \"##SIG_AFL_DEFER_FORKSRV##\";\nextern \"C\" void  __afl_manual_init();\nstatic volatile char suppress_warning1 = AFL_DEFER_FORKSVR[0];\n\n// Input buffer.\nstatic const size_t kMaxAflInputSize = 1 << 20;\nstatic uint8_t AflInputBuf[kMaxAflInputSize];\n\n// Variables we need for writing to the extra stats file.\nstatic FILE *extra_stats_file = NULL;\nstatic uint32_t previous_peak_rss = 0;\nstatic time_t slowest_unit_time_secs = 0;\nstatic const int kNumExtraStats = 2;\nstatic const char *kExtraStatsFormatString = \"peak_rss_mb            : %u\\n\"\n                                             \"slowest_unit_time_sec  : %u\\n\";\n\n// Copied from FuzzerUtil.cpp.\nsize_t GetPeakRSSMb() {\n  struct rusage usage;\n  if (getrusage(RUSAGE_SELF, &usage))\n    return 0;\n  if (LIBFUZZER_LINUX || LIBFUZZER_NETBSD) {\n    // ru_maxrss is in KiB\n    return usage.ru_maxrss >> 10;\n  } else if (LIBFUZZER_APPLE) {\n    // ru_maxrss is in bytes\n    return usage.ru_maxrss >> 20;\n  }\n  assert(0 && \"GetPeakRSSMb() is not implemented for your platform\");\n  return 0;\n}\n\n// Based on SetSigaction in FuzzerUtil.cpp\nstatic void SetSigaction(int signum,\n                         void (*callback)(int, siginfo_t *, void *)) {\n  struct sigaction sigact;\n  memset(&sigact, 0, sizeof(sigact));\n  sigact.sa_sigaction = callback;\n  if (sigaction(signum, &sigact, 0)) {\n    fprintf(stderr, \"libFuzzer: sigaction failed with %d\\n\", errno);\n    exit(1);\n  }\n}\n\n// Write extra stats to the file specified by the user. If none is specified\n// this function will never be called.\nstatic void write_extra_stats() {\n  uint32_t peak_rss = GetPeakRSSMb();\n\n  if (peak_rss < previous_peak_rss)\n    peak_rss = previous_peak_rss;\n\n  int chars_printed = fprintf(extra_stats_file, kExtraStatsFormatString,\n                              peak_rss, slowest_unit_time_secs);\n\n  CHECK_ERROR(chars_printed != 0, \"Failed to write extra_stats_file\");\n\n  CHECK_ERROR(fclose(extra_stats_file) == 0,\n              \"Failed to close extra_stats_file\");\n}\n\n// Call write_extra_stats before we exit.\nstatic void crash_handler(int, siginfo_t *, void *) {\n  // Make sure we don't try calling write_extra_stats again if we crashed while\n  // trying to call it.\n  static bool first_crash = true;\n  CHECK_ERROR(first_crash,\n              \"Crashed in crash signal handler. This is a bug in the fuzzer.\");\n\n  first_crash = false;\n  write_extra_stats();\n}\n\n// If the user has specified an extra_stats_file through the environment\n// variable AFL_DRIVER_EXTRA_STATS_FILENAME, then perform necessary set up\n// to write stats to it on exit. If no file is specified, do nothing. Otherwise\n// install signal and exit handlers to write to the file when the process exits.\n// Then if the file doesn't exist create it and set extra stats to 0. But if it\n// does exist then read the initial values of the extra stats from the file\n// and check that the file is writable.\nstatic void maybe_initialize_extra_stats() {\n  // If AFL_DRIVER_EXTRA_STATS_FILENAME isn't set then we have nothing to do.\n  char *extra_stats_filename = getenv(\"AFL_DRIVER_EXTRA_STATS_FILENAME\");\n  if (!extra_stats_filename)\n    return;\n\n  // Open the file and find the previous peak_rss_mb value.\n  // This is necessary because the fuzzing process is restarted after N\n  // iterations are completed. So we may need to get this value from a previous\n  // process to be accurate.\n  extra_stats_file = fopen(extra_stats_filename, \"r\");\n\n  // If extra_stats_file already exists: read old stats from it.\n  if (extra_stats_file) {\n    int matches = fscanf(extra_stats_file, kExtraStatsFormatString,\n                         &previous_peak_rss, &slowest_unit_time_secs);\n\n    // Make sure we have read a real extra stats file and that we have used it\n    // to set slowest_unit_time_secs and previous_peak_rss.\n    CHECK_ERROR(matches == kNumExtraStats, \"Extra stats file is corrupt\");\n\n    CHECK_ERROR(fclose(extra_stats_file) == 0, \"Failed to close file\");\n\n    // Now open the file for writing.\n    extra_stats_file = fopen(extra_stats_filename, \"w\");\n    CHECK_ERROR(extra_stats_file,\n                \"Failed to open extra stats file for writing\");\n  } else {\n    // Looks like this is the first time in a fuzzing job this is being called.\n    extra_stats_file = fopen(extra_stats_filename, \"w+\");\n    CHECK_ERROR(extra_stats_file, \"failed to create extra stats file\");\n  }\n\n  // Make sure that crash_handler gets called on any kind of fatal error.\n  int crash_signals[] = {SIGSEGV, SIGBUS, SIGABRT, SIGILL, SIGFPE,  SIGINT,\n                         SIGTERM};\n\n  const size_t num_signals = sizeof(crash_signals) / sizeof(crash_signals[0]);\n\n  for (size_t idx = 0; idx < num_signals; idx++)\n    SetSigaction(crash_signals[idx], crash_handler);\n\n  // Make sure it gets called on other kinds of exits.\n  atexit(write_extra_stats);\n}\n\n// If the user asks us to duplicate stderr, then do it.\nstatic void maybe_duplicate_stderr() {\n  char* stderr_duplicate_filename =\n      getenv(\"AFL_DRIVER_STDERR_DUPLICATE_FILENAME\");\n\n  if (!stderr_duplicate_filename)\n    return;\n\n  FILE* stderr_duplicate_stream =\n      freopen(stderr_duplicate_filename, \"a+\", stderr);\n\n  if (!stderr_duplicate_stream) {\n    fprintf(\n        stderr,\n        \"Failed to duplicate stderr to AFL_DRIVER_STDERR_DUPLICATE_FILENAME\");\n    abort();\n  }\n}\n\n// Define LLVMFuzzerMutate to avoid link failures for targets that use it\n// with libFuzzer's LLVMFuzzerCustomMutator.\nextern \"C\" size_t LLVMFuzzerMutate(uint8_t *Data, size_t Size, size_t MaxSize) {\n  assert(false && \"LLVMFuzzerMutate should not be called from afl_driver\");\n  return 0;\n}\n\n// Execute any files provided as parameters.\nint ExecuteFilesOnyByOne(int argc, char **argv) {\n  for (int i = 1; i < argc; i++) {\n    std::ifstream in(argv[i]);\n    in.seekg(0, in.end);\n    size_t length = in.tellg();\n    in.seekg (0, in.beg);\n    std::cout << \"Reading \" << length << \" bytes from \" << argv[i] << std::endl;\n    // Allocate exactly length bytes so that we reliably catch buffer overflows.\n    std::vector<char> bytes(length);\n    in.read(bytes.data(), bytes.size());\n    assert(in);\n    LLVMFuzzerTestOneInput(reinterpret_cast<const uint8_t *>(bytes.data()),\n                           bytes.size());\n    std::cout << \"Execution successfull\" << std::endl;\n  }\n  return 0;\n}\n\nint main(int argc, char **argv) {\n  fprintf(stderr,\n      \"======================= INFO =========================\\n\"\n      \"This binary is built for AFL-fuzz.\\n\"\n      \"To run the target function on individual input(s) execute this:\\n\"\n      \"  %s < INPUT_FILE\\n\"\n      \"or\\n\"\n      \"  %s INPUT_FILE1 [INPUT_FILE2 ... ]\\n\"\n      \"To fuzz with afl-fuzz execute this:\\n\"\n      \"  afl-fuzz [afl-flags] %s [-N]\\n\"\n      \"afl-fuzz will run N iterations before \"\n      \"re-spawning the process (default: 1000)\\n\"\n      \"======================================================\\n\",\n          argv[0], argv[0], argv[0]);\n  if (LLVMFuzzerInitialize)\n    LLVMFuzzerInitialize(&argc, &argv);\n  // Do any other expensive one-time initialization here.\n\n  maybe_duplicate_stderr();\n  maybe_initialize_extra_stats();\n\n  __afl_manual_init();\n\n  int N = 1000;\n  if (argc == 2 && argv[1][0] == '-')\n      N = atoi(argv[1] + 1);\n  else if(argc == 2 && (N = atoi(argv[1])) > 0)\n      fprintf(stderr, \"WARNING: using the deprecated call style `%s %d`\\n\",\n              argv[0], N);\n  else if (argc > 1)\n    return ExecuteFilesOnyByOne(argc, argv);\n\n  assert(N > 0);\n\n  // Call LLVMFuzzerTestOneInput here so that coverage caused by initialization\n  // on the first execution of LLVMFuzzerTestOneInput is ignored.\n  uint8_t dummy_input[1] = {0};\n  LLVMFuzzerTestOneInput(dummy_input, 1);\n\n  time_t unit_time_secs;\n  int num_runs = 0;\n  while (__afl_persistent_loop(N)) {\n    ssize_t n_read = read(0, AflInputBuf, kMaxAflInputSize);\n    if (n_read > 0) {\n      // Copy AflInputBuf into a separate buffer to let asan find buffer\n      // overflows. Don't use unique_ptr/etc to avoid extra dependencies.\n      uint8_t *copy = new uint8_t[n_read];\n      memcpy(copy, AflInputBuf, n_read);\n\n      struct timeval unit_start_time;\n      CHECK_ERROR(gettimeofday(&unit_start_time, NULL) == 0,\n                  \"Calling gettimeofday failed\");\n\n      num_runs++;\n      LLVMFuzzerTestOneInput(copy, n_read);\n\n      struct timeval unit_stop_time;\n      CHECK_ERROR(gettimeofday(&unit_stop_time, NULL) == 0,\n                  \"Calling gettimeofday failed\");\n\n      // Update slowest_unit_time_secs if we see a new max.\n      unit_time_secs = unit_stop_time.tv_sec - unit_start_time.tv_sec;\n      if (slowest_unit_time_secs < unit_time_secs)\n        slowest_unit_time_secs = unit_time_secs;\n\n      delete[] copy;\n    }\n  }\n  fprintf(stderr, \"%s: successfully executed %d input(s)\\n\", argv[0], num_runs);\n}\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/build.sh",
    "content": "#!/bin/bash\nLIBFUZZER_SRC_DIR=$(dirname $0)\nCXX=\"${CXX:-clang}\"\nfor f in $LIBFUZZER_SRC_DIR/*.cpp; do\n  $CXX -g -O2 -fno-omit-frame-pointer -std=c++11 $f -c &\ndone\nwait\nrm -f libFuzzer.a\nar ru libFuzzer.a Fuzzer*.o\nrm -f Fuzzer*.o\n\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/scripts/unbalanced_allocs.py",
    "content": "#!/usr/bin/env python\n#===- lib/fuzzer/scripts/unbalanced_allocs.py ------------------------------===#\n#\n#                     The LLVM Compiler Infrastructure\n#\n# This file is distributed under the University of Illinois Open Source\n# License. See LICENSE.TXT for details.\n#\n#===------------------------------------------------------------------------===#\n#\n# Post-process -trace_malloc=2 output and printout only allocations and frees\n# unbalanced inside of fuzzer runs.\n# Usage:\n#   my_fuzzer -trace_malloc=2 -runs=10 2>&1 | unbalanced_allocs.py -skip=5\n#\n#===------------------------------------------------------------------------===#\n\nimport argparse\nimport sys\n\n_skip = 0\n\ndef PrintStack(line, stack):\n  global _skip\n  if _skip > 0:\n    return\n  print 'Unbalanced ' + line.rstrip();\n  for l in stack:\n    print l.rstrip()\n\ndef ProcessStack(line, f):\n  stack = []\n  while line and line.startswith('    #'):\n    stack += [line]\n    line = f.readline()\n  return line, stack\n\ndef ProcessFree(line, f, allocs):\n  if not line.startswith('FREE['):\n    return f.readline()\n\n  addr = int(line.split()[1], 16)\n  next_line, stack = ProcessStack(f.readline(), f)\n  if addr in allocs:\n    del allocs[addr]\n  else:\n    PrintStack(line, stack)\n  return next_line\n\ndef ProcessMalloc(line, f, allocs):\n  if not line.startswith('MALLOC['):\n    return ProcessFree(line, f, allocs)\n\n  addr = int(line.split()[1], 16)\n  assert not addr in allocs\n\n  next_line, stack = ProcessStack(f.readline(), f)\n  allocs[addr] = (line, stack)\n  return next_line\n\ndef ProcessRun(line, f):\n  if not line.startswith('MallocFreeTracer: START'):\n    return ProcessMalloc(line, f, {})\n\n  allocs = {}\n  print line.rstrip()\n  line = f.readline()\n  while line:\n    if line.startswith('MallocFreeTracer: STOP'):\n      global _skip\n      _skip = _skip - 1\n      for _, (l, s) in allocs.iteritems():\n        PrintStack(l, s)\n      print line.rstrip()\n      return f.readline()\n    line = ProcessMalloc(line, f, allocs)\n  return line\n\ndef ProcessFile(f):\n  line = f.readline()\n  while line:\n    line = ProcessRun(line, f);\n\ndef main(argv):\n  parser = argparse.ArgumentParser()\n  parser.add_argument('--skip', default=0, help='number of runs to ignore')\n  args = parser.parse_args()\n  global _skip\n  _skip = int(args.skip) + 1\n  ProcessFile(sys.stdin)\n\nif __name__ == '__main__':\n  main(sys.argv)\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/standalone/StandaloneFuzzTargetMain.c",
    "content": "/*===- StandaloneFuzzTargetMain.c - standalone main() for fuzz targets. ---===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// This main() function can be linked to a fuzz target (i.e. a library\n// that exports LLVMFuzzerTestOneInput() and possibly LLVMFuzzerInitialize())\n// instead of libFuzzer. This main() function will not perform any fuzzing\n// but will simply feed all input files one by one to the fuzz target.\n//\n// Use this file to provide reproducers for bugs when linking against libFuzzer\n// or other fuzzing engine is undesirable.\n//===----------------------------------------------------------------------===*/\n#include <assert.h>\n#include <stdio.h>\n#include <stdlib.h>\n\nextern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size);\n__attribute__((weak)) extern int LLVMFuzzerInitialize(int *argc, char ***argv);\nint main(int argc, char **argv) {\n  fprintf(stderr, \"StandaloneFuzzTargetMain: running %d inputs\\n\", argc - 1);\n  if (LLVMFuzzerInitialize)\n    LLVMFuzzerInitialize(&argc, &argv);\n  for (int i = 1; i < argc; i++) {\n    fprintf(stderr, \"Running: %s\\n\", argv[i]);\n    FILE *f = fopen(argv[i], \"r\");\n    assert(f);\n    fseek(f, 0, SEEK_END);\n    size_t len = ftell(f);\n    fseek(f, 0, SEEK_SET);\n    unsigned char *buf = (unsigned char*)malloc(len);\n    size_t n_read = fread(buf, 1, len, f);\n    assert(n_read == len);\n    LLVMFuzzerTestOneInput(buf, len);\n    free(buf);\n    fprintf(stderr, \"Done:    %s: (%zd bytes)\\n\", argv[i], n_read);\n  }\n}\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/tests/CMakeLists.txt",
    "content": "set(LIBFUZZER_UNITTEST_CFLAGS\n  ${COMPILER_RT_UNITTEST_CFLAGS}\n  ${COMPILER_RT_GTEST_CFLAGS}\n  -I${COMPILER_RT_SOURCE_DIR}/lib/fuzzer\n  -fno-rtti\n  -Werror\n  -O2)\n\nadd_custom_target(FuzzerUnitTests)\nset_target_properties(FuzzerUnitTests PROPERTIES FOLDER \"Compiler-RT Tests\")\n\nset(LIBFUZZER_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_LINK_FLAGS})\nlist(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS --driver-mode=g++)\n\nif(APPLE)\n  list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -lc++)\nelse()\n  list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -lstdc++ -lpthread)\nendif()\n\nforeach(arch ${FUZZER_SUPPORTED_ARCH})\n  set(LIBFUZZER_TEST_RUNTIME RTFuzzerTest.${arch})\n  if(APPLE)\n    set(LIBFUZZER_TEST_RUNTIME_OBJECTS\n      $<TARGET_OBJECTS:RTfuzzer.osx>)\n  else()\n    set(LIBFUZZER_TEST_RUNTIME_OBJECTS\n      $<TARGET_OBJECTS:RTfuzzer.${arch}>)\n  endif()\n  add_library(${LIBFUZZER_TEST_RUNTIME} STATIC\n    ${LIBFUZZER_TEST_RUNTIME_OBJECTS})\n  set_target_properties(${LIBFUZZER_TEST_RUNTIME} PROPERTIES\n    ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}\n    FOLDER \"Compiler-RT Runtime tests\")\n\n  set(FuzzerTestObjects)\n  generate_compiler_rt_tests(FuzzerTestObjects\n    FuzzerUnitTests \"Fuzzer-${arch}-Test\" ${arch}\n    SOURCES FuzzerUnittest.cpp ${COMPILER_RT_GTEST_SOURCE}\n    RUNTIME ${LIBFUZZER_TEST_RUNTIME}\n    DEPS gtest\n    CFLAGS ${LIBFUZZER_UNITTEST_CFLAGS}\n    LINK_FLAGS ${LIBFUZZER_UNITTEST_LINK_FLAGS})\n  set_target_properties(FuzzerUnitTests PROPERTIES\n    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})\nendforeach()\n"
  },
  {
    "path": "runtime/LibFuzzer/Fuzzer/tests/FuzzerUnittest.cpp",
    "content": "// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n\n// Avoid ODR violations (LibFuzzer is built without ASan and this test is built\n// with ASan) involving C++ standard library types when using libcxx.\n#define _LIBCPP_HAS_NO_ASAN\n\n// Do not attempt to use LLVM ostream from gtest.\n#define GTEST_NO_LLVM_RAW_OSTREAM 1\n\n#include \"FuzzerCorpus.h\"\n#include \"FuzzerDictionary.h\"\n#include \"FuzzerInternal.h\"\n#include \"FuzzerMerge.h\"\n#include \"FuzzerMutate.h\"\n#include \"FuzzerRandom.h\"\n#include \"FuzzerTracePC.h\"\n#include \"gtest/gtest.h\"\n#include <memory>\n#include <set>\n#include <sstream>\n\nusing namespace fuzzer;\n\n// For now, have LLVMFuzzerTestOneInput just to make it link.\n// Later we may want to make unittests that actually call LLVMFuzzerTestOneInput.\nextern \"C\" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {\n  abort();\n}\n\nTEST(Fuzzer, CrossOver) {\n  std::unique_ptr<ExternalFunctions> t(new ExternalFunctions());\n  fuzzer::EF = t.get();\n  Random Rand(0);\n  std::unique_ptr<MutationDispatcher> MD(new MutationDispatcher(Rand, {}));\n  Unit A({0, 1, 2}), B({5, 6, 7});\n  Unit C;\n  Unit Expected[] = {\n       { 0 },\n       { 0, 1 },\n       { 0, 5 },\n       { 0, 1, 2 },\n       { 0, 1, 5 },\n       { 0, 5, 1 },\n       { 0, 5, 6 },\n       { 0, 1, 2, 5 },\n       { 0, 1, 5, 2 },\n       { 0, 1, 5, 6 },\n       { 0, 5, 1, 2 },\n       { 0, 5, 1, 6 },\n       { 0, 5, 6, 1 },\n       { 0, 5, 6, 7 },\n       { 0, 1, 2, 5, 6 },\n       { 0, 1, 5, 2, 6 },\n       { 0, 1, 5, 6, 2 },\n       { 0, 1, 5, 6, 7 },\n       { 0, 5, 1, 2, 6 },\n       { 0, 5, 1, 6, 2 },\n       { 0, 5, 1, 6, 7 },\n       { 0, 5, 6, 1, 2 },\n       { 0, 5, 6, 1, 7 },\n       { 0, 5, 6, 7, 1 },\n       { 0, 1, 2, 5, 6, 7 },\n       { 0, 1, 5, 2, 6, 7 },\n       { 0, 1, 5, 6, 2, 7 },\n       { 0, 1, 5, 6, 7, 2 },\n       { 0, 5, 1, 2, 6, 7 },\n       { 0, 5, 1, 6, 2, 7 },\n       { 0, 5, 1, 6, 7, 2 },\n       { 0, 5, 6, 1, 2, 7 },\n       { 0, 5, 6, 1, 7, 2 },\n       { 0, 5, 6, 7, 1, 2 }\n  };\n  for (size_t Len = 1; Len < 8; Len++) {\n    Set<Unit> FoundUnits, ExpectedUnitsWitThisLength;\n    for (int Iter = 0; Iter < 3000; Iter++) {\n      C.resize(Len);\n      size_t NewSize = MD->CrossOver(A.data(), A.size(), B.data(), B.size(),\n                                     C.data(), C.size());\n      C.resize(NewSize);\n      FoundUnits.insert(C);\n    }\n    for (const Unit &U : Expected)\n      if (U.size() <= Len)\n        ExpectedUnitsWitThisLength.insert(U);\n    EXPECT_EQ(ExpectedUnitsWitThisLength, FoundUnits);\n  }\n}\n\nTEST(Fuzzer, Hash) {\n  uint8_t A[] = {'a', 'b', 'c'};\n  fuzzer::Unit U(A, A + sizeof(A));\n  EXPECT_EQ(\"a9993e364706816aba3e25717850c26c9cd0d89d\", fuzzer::Hash(U));\n  U.push_back('d');\n  EXPECT_EQ(\"81fe8bfe87576c3ecb22426f8e57847382917acf\", fuzzer::Hash(U));\n}\n\ntypedef size_t (MutationDispatcher::*Mutator)(uint8_t *Data, size_t Size,\n                                              size_t MaxSize);\n\nvoid TestEraseBytes(Mutator M, int NumIter) {\n  std::unique_ptr<ExternalFunctions> t(new ExternalFunctions());\n  fuzzer::EF = t.get();\n  uint8_t REM0[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};\n  uint8_t REM1[8] = {0x00, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};\n  uint8_t REM2[8] = {0x00, 0x11, 0x33, 0x44, 0x55, 0x66, 0x77};\n  uint8_t REM3[8] = {0x00, 0x11, 0x22, 0x44, 0x55, 0x66, 0x77};\n  uint8_t REM4[8] = {0x00, 0x11, 0x22, 0x33, 0x55, 0x66, 0x77};\n  uint8_t REM5[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x66, 0x77};\n  uint8_t REM6[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x77};\n  uint8_t REM7[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66};\n\n  uint8_t REM8[6] = {0x22, 0x33, 0x44, 0x55, 0x66, 0x77};\n  uint8_t REM9[6] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55};\n  uint8_t REM10[6] = {0x00, 0x11, 0x22, 0x55, 0x66, 0x77};\n\n  uint8_t REM11[5] = {0x33, 0x44, 0x55, 0x66, 0x77};\n  uint8_t REM12[5] = {0x00, 0x11, 0x22, 0x33, 0x44};\n  uint8_t REM13[5] = {0x00, 0x44, 0x55, 0x66, 0x77};\n\n\n  Random Rand(0);\n  std::unique_ptr<MutationDispatcher> MD(new MutationDispatcher(Rand, {}));\n  int FoundMask = 0;\n  for (int i = 0; i < NumIter; i++) {\n    uint8_t T[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};\n    size_t NewSize = (*MD.*M)(T, sizeof(T), sizeof(T));\n    if (NewSize == 7 && !memcmp(REM0, T, 7)) FoundMask |= 1 << 0;\n    if (NewSize == 7 && !memcmp(REM1, T, 7)) FoundMask |= 1 << 1;\n    if (NewSize == 7 && !memcmp(REM2, T, 7)) FoundMask |= 1 << 2;\n    if (NewSize == 7 && !memcmp(REM3, T, 7)) FoundMask |= 1 << 3;\n    if (NewSize == 7 && !memcmp(REM4, T, 7)) FoundMask |= 1 << 4;\n    if (NewSize == 7 && !memcmp(REM5, T, 7)) FoundMask |= 1 << 5;\n    if (NewSize == 7 && !memcmp(REM6, T, 7)) FoundMask |= 1 << 6;\n    if (NewSize == 7 && !memcmp(REM7, T, 7)) FoundMask |= 1 << 7;\n\n    if (NewSize == 6 && !memcmp(REM8, T, 6)) FoundMask |= 1 << 8;\n    if (NewSize == 6 && !memcmp(REM9, T, 6)) FoundMask |= 1 << 9;\n    if (NewSize == 6 && !memcmp(REM10, T, 6)) FoundMask |= 1 << 10;\n\n    if (NewSize == 5 && !memcmp(REM11, T, 5)) FoundMask |= 1 << 11;\n    if (NewSize == 5 && !memcmp(REM12, T, 5)) FoundMask |= 1 << 12;\n    if (NewSize == 5 && !memcmp(REM13, T, 5)) FoundMask |= 1 << 13;\n  }\n  EXPECT_EQ(FoundMask, (1 << 14) - 1);\n}\n\nTEST(FuzzerMutate, EraseBytes1) {\n  TestEraseBytes(&MutationDispatcher::Mutate_EraseBytes, 200);\n}\nTEST(FuzzerMutate, EraseBytes2) {\n  TestEraseBytes(&MutationDispatcher::Mutate, 2000);\n}\n\nvoid TestInsertByte(Mutator M, int NumIter) {\n  std::unique_ptr<ExternalFunctions> t(new ExternalFunctions());\n  fuzzer::EF = t.get();\n  Random Rand(0);\n  std::unique_ptr<MutationDispatcher> MD(new MutationDispatcher(Rand, {}));\n  int FoundMask = 0;\n  uint8_t INS0[8] = {0xF1, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66};\n  uint8_t INS1[8] = {0x00, 0xF2, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66};\n  uint8_t INS2[8] = {0x00, 0x11, 0xF3, 0x22, 0x33, 0x44, 0x55, 0x66};\n  uint8_t INS3[8] = {0x00, 0x11, 0x22, 0xF4, 0x33, 0x44, 0x55, 0x66};\n  uint8_t INS4[8] = {0x00, 0x11, 0x22, 0x33, 0xF5, 0x44, 0x55, 0x66};\n  uint8_t INS5[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0xF6, 0x55, 0x66};\n  uint8_t INS6[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0xF7, 0x66};\n  uint8_t INS7[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0xF8};\n  for (int i = 0; i < NumIter; i++) {\n    uint8_t T[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66};\n    size_t NewSize = (*MD.*M)(T, 7, 8);\n    if (NewSize == 8 && !memcmp(INS0, T, 8)) FoundMask |= 1 << 0;\n    if (NewSize == 8 && !memcmp(INS1, T, 8)) FoundMask |= 1 << 1;\n    if (NewSize == 8 && !memcmp(INS2, T, 8)) FoundMask |= 1 << 2;\n    if (NewSize == 8 && !memcmp(INS3, T, 8)) FoundMask |= 1 << 3;\n    if (NewSize == 8 && !memcmp(INS4, T, 8)) FoundMask |= 1 << 4;\n    if (NewSize == 8 && !memcmp(INS5, T, 8)) FoundMask |= 1 << 5;\n    if (NewSize == 8 && !memcmp(INS6, T, 8)) FoundMask |= 1 << 6;\n    if (NewSize == 8 && !memcmp(INS7, T, 8)) FoundMask |= 1 << 7;\n  }\n  EXPECT_EQ(FoundMask, 255);\n}\n\nTEST(FuzzerMutate, InsertByte1) {\n  TestInsertByte(&MutationDispatcher::Mutate_InsertByte, 1 << 15);\n}\nTEST(FuzzerMutate, InsertByte2) {\n  TestInsertByte(&MutationDispatcher::Mutate, 1 << 17);\n}\n\nvoid TestInsertRepeatedBytes(Mutator M, int NumIter) {\n  std::unique_ptr<ExternalFunctions> t(new ExternalFunctions());\n  fuzzer::EF = t.get();\n  Random Rand(0);\n  std::unique_ptr<MutationDispatcher> MD(new MutationDispatcher(Rand, {}));\n  int FoundMask = 0;\n  uint8_t INS0[7] = {0x00, 0x11, 0x22, 0x33, 'a', 'a', 'a'};\n  uint8_t INS1[7] = {0x00, 0x11, 0x22, 'a', 'a', 'a', 0x33};\n  uint8_t INS2[7] = {0x00, 0x11, 'a', 'a', 'a', 0x22, 0x33};\n  uint8_t INS3[7] = {0x00, 'a', 'a', 'a', 0x11, 0x22, 0x33};\n  uint8_t INS4[7] = {'a', 'a', 'a', 0x00, 0x11, 0x22, 0x33};\n\n  uint8_t INS5[8] = {0x00, 0x11, 0x22, 0x33, 'b', 'b', 'b', 'b'};\n  uint8_t INS6[8] = {0x00, 0x11, 0x22, 'b', 'b', 'b', 'b', 0x33};\n  uint8_t INS7[8] = {0x00, 0x11, 'b', 'b', 'b', 'b', 0x22, 0x33};\n  uint8_t INS8[8] = {0x00, 'b', 'b', 'b', 'b', 0x11, 0x22, 0x33};\n  uint8_t INS9[8] = {'b', 'b', 'b', 'b', 0x00, 0x11, 0x22, 0x33};\n\n  for (int i = 0; i < NumIter; i++) {\n    uint8_t T[8] = {0x00, 0x11, 0x22, 0x33};\n    size_t NewSize = (*MD.*M)(T, 4, 8);\n    if (NewSize == 7 && !memcmp(INS0, T, 7)) FoundMask |= 1 << 0;\n    if (NewSize == 7 && !memcmp(INS1, T, 7)) FoundMask |= 1 << 1;\n    if (NewSize == 7 && !memcmp(INS2, T, 7)) FoundMask |= 1 << 2;\n    if (NewSize == 7 && !memcmp(INS3, T, 7)) FoundMask |= 1 << 3;\n    if (NewSize == 7 && !memcmp(INS4, T, 7)) FoundMask |= 1 << 4;\n\n    if (NewSize == 8 && !memcmp(INS5, T, 8)) FoundMask |= 1 << 5;\n    if (NewSize == 8 && !memcmp(INS6, T, 8)) FoundMask |= 1 << 6;\n    if (NewSize == 8 && !memcmp(INS7, T, 8)) FoundMask |= 1 << 7;\n    if (NewSize == 8 && !memcmp(INS8, T, 8)) FoundMask |= 1 << 8;\n    if (NewSize == 8 && !memcmp(INS9, T, 8)) FoundMask |= 1 << 9;\n\n  }\n  EXPECT_EQ(FoundMask, (1 << 10) - 1);\n}\n\nTEST(FuzzerMutate, InsertRepeatedBytes1) {\n  TestInsertRepeatedBytes(&MutationDispatcher::Mutate_InsertRepeatedBytes, 10000);\n}\nTEST(FuzzerMutate, InsertRepeatedBytes2) {\n  TestInsertRepeatedBytes(&MutationDispatcher::Mutate, 300000);\n}\n\nvoid TestChangeByte(Mutator M, int NumIter) {\n  std::unique_ptr<ExternalFunctions> t(new ExternalFunctions());\n  fuzzer::EF = t.get();\n  Random Rand(0);\n  std::unique_ptr<MutationDispatcher> MD(new MutationDispatcher(Rand, {}));\n  int FoundMask = 0;\n  uint8_t CH0[8] = {0xF0, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};\n  uint8_t CH1[8] = {0x00, 0xF1, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};\n  uint8_t CH2[8] = {0x00, 0x11, 0xF2, 0x33, 0x44, 0x55, 0x66, 0x77};\n  uint8_t CH3[8] = {0x00, 0x11, 0x22, 0xF3, 0x44, 0x55, 0x66, 0x77};\n  uint8_t CH4[8] = {0x00, 0x11, 0x22, 0x33, 0xF4, 0x55, 0x66, 0x77};\n  uint8_t CH5[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0xF5, 0x66, 0x77};\n  uint8_t CH6[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0xF5, 0x77};\n  uint8_t CH7[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0xF7};\n  for (int i = 0; i < NumIter; i++) {\n    uint8_t T[9] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};\n    size_t NewSize = (*MD.*M)(T, 8, 9);\n    if (NewSize == 8 && !memcmp(CH0, T, 8)) FoundMask |= 1 << 0;\n    if (NewSize == 8 && !memcmp(CH1, T, 8)) FoundMask |= 1 << 1;\n    if (NewSize == 8 && !memcmp(CH2, T, 8)) FoundMask |= 1 << 2;\n    if (NewSize == 8 && !memcmp(CH3, T, 8)) FoundMask |= 1 << 3;\n    if (NewSize == 8 && !memcmp(CH4, T, 8)) FoundMask |= 1 << 4;\n    if (NewSize == 8 && !memcmp(CH5, T, 8)) FoundMask |= 1 << 5;\n    if (NewSize == 8 && !memcmp(CH6, T, 8)) FoundMask |= 1 << 6;\n    if (NewSize == 8 && !memcmp(CH7, T, 8)) FoundMask |= 1 << 7;\n  }\n  EXPECT_EQ(FoundMask, 255);\n}\n\nTEST(FuzzerMutate, ChangeByte1) {\n  TestChangeByte(&MutationDispatcher::Mutate_ChangeByte, 1 << 15);\n}\nTEST(FuzzerMutate, ChangeByte2) {\n  TestChangeByte(&MutationDispatcher::Mutate, 1 << 17);\n}\n\nvoid TestChangeBit(Mutator M, int NumIter) {\n  std::unique_ptr<ExternalFunctions> t(new ExternalFunctions());\n  fuzzer::EF = t.get();\n  Random Rand(0);\n  std::unique_ptr<MutationDispatcher> MD(new MutationDispatcher(Rand, {}));\n  int FoundMask = 0;\n  uint8_t CH0[8] = {0x01, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};\n  uint8_t CH1[8] = {0x00, 0x13, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};\n  uint8_t CH2[8] = {0x00, 0x11, 0x02, 0x33, 0x44, 0x55, 0x66, 0x77};\n  uint8_t CH3[8] = {0x00, 0x11, 0x22, 0x37, 0x44, 0x55, 0x66, 0x77};\n  uint8_t CH4[8] = {0x00, 0x11, 0x22, 0x33, 0x54, 0x55, 0x66, 0x77};\n  uint8_t CH5[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x54, 0x66, 0x77};\n  uint8_t CH6[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x76, 0x77};\n  uint8_t CH7[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0xF7};\n  for (int i = 0; i < NumIter; i++) {\n    uint8_t T[9] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};\n    size_t NewSize = (*MD.*M)(T, 8, 9);\n    if (NewSize == 8 && !memcmp(CH0, T, 8)) FoundMask |= 1 << 0;\n    if (NewSize == 8 && !memcmp(CH1, T, 8)) FoundMask |= 1 << 1;\n    if (NewSize == 8 && !memcmp(CH2, T, 8)) FoundMask |= 1 << 2;\n    if (NewSize == 8 && !memcmp(CH3, T, 8)) FoundMask |= 1 << 3;\n    if (NewSize == 8 && !memcmp(CH4, T, 8)) FoundMask |= 1 << 4;\n    if (NewSize == 8 && !memcmp(CH5, T, 8)) FoundMask |= 1 << 5;\n    if (NewSize == 8 && !memcmp(CH6, T, 8)) FoundMask |= 1 << 6;\n    if (NewSize == 8 && !memcmp(CH7, T, 8)) FoundMask |= 1 << 7;\n  }\n  EXPECT_EQ(FoundMask, 255);\n}\n\nTEST(FuzzerMutate, ChangeBit1) {\n  TestChangeBit(&MutationDispatcher::Mutate_ChangeBit, 1 << 16);\n}\nTEST(FuzzerMutate, ChangeBit2) {\n  TestChangeBit(&MutationDispatcher::Mutate, 1 << 18);\n}\n\nvoid TestShuffleBytes(Mutator M, int NumIter) {\n  std::unique_ptr<ExternalFunctions> t(new ExternalFunctions());\n  fuzzer::EF = t.get();\n  Random Rand(0);\n  std::unique_ptr<MutationDispatcher> MD(new MutationDispatcher(Rand, {}));\n  int FoundMask = 0;\n  uint8_t CH0[7] = {0x00, 0x22, 0x11, 0x33, 0x44, 0x55, 0x66};\n  uint8_t CH1[7] = {0x11, 0x00, 0x33, 0x22, 0x44, 0x55, 0x66};\n  uint8_t CH2[7] = {0x00, 0x33, 0x11, 0x22, 0x44, 0x55, 0x66};\n  uint8_t CH3[7] = {0x00, 0x11, 0x22, 0x44, 0x55, 0x66, 0x33};\n  uint8_t CH4[7] = {0x00, 0x11, 0x22, 0x33, 0x55, 0x44, 0x66};\n  for (int i = 0; i < NumIter; i++) {\n    uint8_t T[7] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66};\n    size_t NewSize = (*MD.*M)(T, 7, 7);\n    if (NewSize == 7 && !memcmp(CH0, T, 7)) FoundMask |= 1 << 0;\n    if (NewSize == 7 && !memcmp(CH1, T, 7)) FoundMask |= 1 << 1;\n    if (NewSize == 7 && !memcmp(CH2, T, 7)) FoundMask |= 1 << 2;\n    if (NewSize == 7 && !memcmp(CH3, T, 7)) FoundMask |= 1 << 3;\n    if (NewSize == 7 && !memcmp(CH4, T, 7)) FoundMask |= 1 << 4;\n  }\n  EXPECT_EQ(FoundMask, 31);\n}\n\nTEST(FuzzerMutate, ShuffleBytes1) {\n  TestShuffleBytes(&MutationDispatcher::Mutate_ShuffleBytes, 1 << 16);\n}\nTEST(FuzzerMutate, ShuffleBytes2) {\n  TestShuffleBytes(&MutationDispatcher::Mutate, 1 << 20);\n}\n\nvoid TestCopyPart(Mutator M, int NumIter) {\n  std::unique_ptr<ExternalFunctions> t(new ExternalFunctions());\n  fuzzer::EF = t.get();\n  Random Rand(0);\n  std::unique_ptr<MutationDispatcher> MD(new MutationDispatcher(Rand, {}));\n  int FoundMask = 0;\n  uint8_t CH0[7] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x00, 0x11};\n  uint8_t CH1[7] = {0x55, 0x66, 0x22, 0x33, 0x44, 0x55, 0x66};\n  uint8_t CH2[7] = {0x00, 0x55, 0x66, 0x33, 0x44, 0x55, 0x66};\n  uint8_t CH3[7] = {0x00, 0x11, 0x22, 0x00, 0x11, 0x22, 0x66};\n  uint8_t CH4[7] = {0x00, 0x11, 0x11, 0x22, 0x33, 0x55, 0x66};\n\n  for (int i = 0; i < NumIter; i++) {\n    uint8_t T[7] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66};\n    size_t NewSize = (*MD.*M)(T, 7, 7);\n    if (NewSize == 7 && !memcmp(CH0, T, 7)) FoundMask |= 1 << 0;\n    if (NewSize == 7 && !memcmp(CH1, T, 7)) FoundMask |= 1 << 1;\n    if (NewSize == 7 && !memcmp(CH2, T, 7)) FoundMask |= 1 << 2;\n    if (NewSize == 7 && !memcmp(CH3, T, 7)) FoundMask |= 1 << 3;\n    if (NewSize == 7 && !memcmp(CH4, T, 7)) FoundMask |= 1 << 4;\n  }\n\n  uint8_t CH5[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x00, 0x11, 0x22};\n  uint8_t CH6[8] = {0x22, 0x33, 0x44, 0x00, 0x11, 0x22, 0x33, 0x44};\n  uint8_t CH7[8] = {0x00, 0x11, 0x22, 0x00, 0x11, 0x22, 0x33, 0x44};\n  uint8_t CH8[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x22, 0x33, 0x44};\n  uint8_t CH9[8] = {0x00, 0x11, 0x22, 0x22, 0x33, 0x44, 0x33, 0x44};\n\n  for (int i = 0; i < NumIter; i++) {\n    uint8_t T[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};\n    size_t NewSize = (*MD.*M)(T, 5, 8);\n    if (NewSize == 8 && !memcmp(CH5, T, 8)) FoundMask |= 1 << 5;\n    if (NewSize == 8 && !memcmp(CH6, T, 8)) FoundMask |= 1 << 6;\n    if (NewSize == 8 && !memcmp(CH7, T, 8)) FoundMask |= 1 << 7;\n    if (NewSize == 8 && !memcmp(CH8, T, 8)) FoundMask |= 1 << 8;\n    if (NewSize == 8 && !memcmp(CH9, T, 8)) FoundMask |= 1 << 9;\n  }\n\n  EXPECT_EQ(FoundMask, 1023);\n}\n\nTEST(FuzzerMutate, CopyPart1) {\n  TestCopyPart(&MutationDispatcher::Mutate_CopyPart, 1 << 10);\n}\nTEST(FuzzerMutate, CopyPart2) {\n  TestCopyPart(&MutationDispatcher::Mutate, 1 << 13);\n}\n\nvoid TestAddWordFromDictionary(Mutator M, int NumIter) {\n  std::unique_ptr<ExternalFunctions> t(new ExternalFunctions());\n  fuzzer::EF = t.get();\n  Random Rand(0);\n  std::unique_ptr<MutationDispatcher> MD(new MutationDispatcher(Rand, {}));\n  uint8_t Word1[4] = {0xAA, 0xBB, 0xCC, 0xDD};\n  uint8_t Word2[3] = {0xFF, 0xEE, 0xEF};\n  MD->AddWordToManualDictionary(Word(Word1, sizeof(Word1)));\n  MD->AddWordToManualDictionary(Word(Word2, sizeof(Word2)));\n  int FoundMask = 0;\n  uint8_t CH0[7] = {0x00, 0x11, 0x22, 0xAA, 0xBB, 0xCC, 0xDD};\n  uint8_t CH1[7] = {0x00, 0x11, 0xAA, 0xBB, 0xCC, 0xDD, 0x22};\n  uint8_t CH2[7] = {0x00, 0xAA, 0xBB, 0xCC, 0xDD, 0x11, 0x22};\n  uint8_t CH3[7] = {0xAA, 0xBB, 0xCC, 0xDD, 0x00, 0x11, 0x22};\n  uint8_t CH4[6] = {0x00, 0x11, 0x22, 0xFF, 0xEE, 0xEF};\n  uint8_t CH5[6] = {0x00, 0x11, 0xFF, 0xEE, 0xEF, 0x22};\n  uint8_t CH6[6] = {0x00, 0xFF, 0xEE, 0xEF, 0x11, 0x22};\n  uint8_t CH7[6] = {0xFF, 0xEE, 0xEF, 0x00, 0x11, 0x22};\n  for (int i = 0; i < NumIter; i++) {\n    uint8_t T[7] = {0x00, 0x11, 0x22};\n    size_t NewSize = (*MD.*M)(T, 3, 7);\n    if (NewSize == 7 && !memcmp(CH0, T, 7)) FoundMask |= 1 << 0;\n    if (NewSize == 7 && !memcmp(CH1, T, 7)) FoundMask |= 1 << 1;\n    if (NewSize == 7 && !memcmp(CH2, T, 7)) FoundMask |= 1 << 2;\n    if (NewSize == 7 && !memcmp(CH3, T, 7)) FoundMask |= 1 << 3;\n    if (NewSize == 6 && !memcmp(CH4, T, 6)) FoundMask |= 1 << 4;\n    if (NewSize == 6 && !memcmp(CH5, T, 6)) FoundMask |= 1 << 5;\n    if (NewSize == 6 && !memcmp(CH6, T, 6)) FoundMask |= 1 << 6;\n    if (NewSize == 6 && !memcmp(CH7, T, 6)) FoundMask |= 1 << 7;\n  }\n  EXPECT_EQ(FoundMask, 255);\n}\n\nTEST(FuzzerMutate, AddWordFromDictionary1) {\n  TestAddWordFromDictionary(\n      &MutationDispatcher::Mutate_AddWordFromManualDictionary, 1 << 15);\n}\n\nTEST(FuzzerMutate, AddWordFromDictionary2) {\n  TestAddWordFromDictionary(&MutationDispatcher::Mutate, 1 << 15);\n}\n\nvoid TestChangeASCIIInteger(Mutator M, int NumIter) {\n  std::unique_ptr<ExternalFunctions> t(new ExternalFunctions());\n  fuzzer::EF = t.get();\n  Random Rand(0);\n  std::unique_ptr<MutationDispatcher> MD(new MutationDispatcher(Rand, {}));\n\n  uint8_t CH0[8] = {'1', '2', '3', '4', '5', '6', '7', '7'};\n  uint8_t CH1[8] = {'1', '2', '3', '4', '5', '6', '7', '9'};\n  uint8_t CH2[8] = {'2', '4', '6', '9', '1', '3', '5', '6'};\n  uint8_t CH3[8] = {'0', '6', '1', '7', '2', '8', '3', '9'};\n  int FoundMask = 0;\n  for (int i = 0; i < NumIter; i++) {\n    uint8_t T[8] = {'1', '2', '3', '4', '5', '6', '7', '8'};\n    size_t NewSize = (*MD.*M)(T, 8, 8);\n    /**/ if (NewSize == 8 && !memcmp(CH0, T, 8)) FoundMask |= 1 << 0;\n    else if (NewSize == 8 && !memcmp(CH1, T, 8)) FoundMask |= 1 << 1;\n    else if (NewSize == 8 && !memcmp(CH2, T, 8)) FoundMask |= 1 << 2;\n    else if (NewSize == 8 && !memcmp(CH3, T, 8)) FoundMask |= 1 << 3;\n    else if (NewSize == 8)                       FoundMask |= 1 << 4;\n  }\n  EXPECT_EQ(FoundMask, 31);\n}\n\nTEST(FuzzerMutate, ChangeASCIIInteger1) {\n  TestChangeASCIIInteger(&MutationDispatcher::Mutate_ChangeASCIIInteger,\n                         1 << 15);\n}\n\nTEST(FuzzerMutate, ChangeASCIIInteger2) {\n  TestChangeASCIIInteger(&MutationDispatcher::Mutate, 1 << 15);\n}\n\nvoid TestChangeBinaryInteger(Mutator M, int NumIter) {\n  std::unique_ptr<ExternalFunctions> t(new ExternalFunctions());\n  fuzzer::EF = t.get();\n  Random Rand(0);\n  std::unique_ptr<MutationDispatcher> MD(new MutationDispatcher(Rand, {}));\n\n  uint8_t CH0[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x79};\n  uint8_t CH1[8] = {0x00, 0x11, 0x22, 0x31, 0x44, 0x55, 0x66, 0x77};\n  uint8_t CH2[8] = {0xff, 0x10, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};\n  uint8_t CH3[8] = {0x00, 0x11, 0x2a, 0x33, 0x44, 0x55, 0x66, 0x77};\n  uint8_t CH4[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x4f, 0x66, 0x77};\n  uint8_t CH5[8] = {0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88};\n  uint8_t CH6[8] = {0x00, 0x11, 0x22, 0x00, 0x00, 0x00, 0x08, 0x77}; // Size\n  uint8_t CH7[8] = {0x00, 0x08, 0x00, 0x33, 0x44, 0x55, 0x66, 0x77}; // Sw(Size)\n\n  int FoundMask = 0;\n  for (int i = 0; i < NumIter; i++) {\n    uint8_t T[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};\n    size_t NewSize = (*MD.*M)(T, 8, 8);\n    /**/ if (NewSize == 8 && !memcmp(CH0, T, 8)) FoundMask |= 1 << 0;\n    else if (NewSize == 8 && !memcmp(CH1, T, 8)) FoundMask |= 1 << 1;\n    else if (NewSize == 8 && !memcmp(CH2, T, 8)) FoundMask |= 1 << 2;\n    else if (NewSize == 8 && !memcmp(CH3, T, 8)) FoundMask |= 1 << 3;\n    else if (NewSize == 8 && !memcmp(CH4, T, 8)) FoundMask |= 1 << 4;\n    else if (NewSize == 8 && !memcmp(CH5, T, 8)) FoundMask |= 1 << 5;\n    else if (NewSize == 8 && !memcmp(CH6, T, 8)) FoundMask |= 1 << 6;\n    else if (NewSize == 8 && !memcmp(CH7, T, 8)) FoundMask |= 1 << 7;\n  }\n  EXPECT_EQ(FoundMask, 255);\n}\n\nTEST(FuzzerMutate, ChangeBinaryInteger1) {\n  TestChangeBinaryInteger(&MutationDispatcher::Mutate_ChangeBinaryInteger,\n                         1 << 12);\n}\n\nTEST(FuzzerMutate, ChangeBinaryInteger2) {\n  TestChangeBinaryInteger(&MutationDispatcher::Mutate, 1 << 15);\n}\n\n\nTEST(FuzzerDictionary, ParseOneDictionaryEntry) {\n  Unit U;\n  EXPECT_FALSE(ParseOneDictionaryEntry(\"\", &U));\n  EXPECT_FALSE(ParseOneDictionaryEntry(\" \", &U));\n  EXPECT_FALSE(ParseOneDictionaryEntry(\"\\t  \", &U));\n  EXPECT_FALSE(ParseOneDictionaryEntry(\"  \\\" \", &U));\n  EXPECT_FALSE(ParseOneDictionaryEntry(\"  zz\\\" \", &U));\n  EXPECT_FALSE(ParseOneDictionaryEntry(\"  \\\"zz \", &U));\n  EXPECT_FALSE(ParseOneDictionaryEntry(\"  \\\"\\\" \", &U));\n  EXPECT_TRUE(ParseOneDictionaryEntry(\"\\\"a\\\"\", &U));\n  EXPECT_EQ(U, Unit({'a'}));\n  EXPECT_TRUE(ParseOneDictionaryEntry(\"\\\"abc\\\"\", &U));\n  EXPECT_EQ(U, Unit({'a', 'b', 'c'}));\n  EXPECT_TRUE(ParseOneDictionaryEntry(\"abc=\\\"abc\\\"\", &U));\n  EXPECT_EQ(U, Unit({'a', 'b', 'c'}));\n  EXPECT_FALSE(ParseOneDictionaryEntry(\"\\\"\\\\\\\"\", &U));\n  EXPECT_TRUE(ParseOneDictionaryEntry(\"\\\"\\\\\\\\\\\"\", &U));\n  EXPECT_EQ(U, Unit({'\\\\'}));\n  EXPECT_TRUE(ParseOneDictionaryEntry(\"\\\"\\\\xAB\\\"\", &U));\n  EXPECT_EQ(U, Unit({0xAB}));\n  EXPECT_TRUE(ParseOneDictionaryEntry(\"\\\"\\\\xABz\\\\xDE\\\"\", &U));\n  EXPECT_EQ(U, Unit({0xAB, 'z', 0xDE}));\n  EXPECT_TRUE(ParseOneDictionaryEntry(\"\\\"#\\\"\", &U));\n  EXPECT_EQ(U, Unit({'#'}));\n  EXPECT_TRUE(ParseOneDictionaryEntry(\"\\\"\\\\\\\"\\\"\", &U));\n  EXPECT_EQ(U, Unit({'\"'}));\n}\n\nTEST(FuzzerDictionary, ParseDictionaryFile) {\n  Vector<Unit> Units;\n  EXPECT_FALSE(ParseDictionaryFile(\"zzz\\n\", &Units));\n  EXPECT_FALSE(ParseDictionaryFile(\"\", &Units));\n  EXPECT_TRUE(ParseDictionaryFile(\"\\n\", &Units));\n  EXPECT_EQ(Units.size(), 0U);\n  EXPECT_TRUE(ParseDictionaryFile(\"#zzzz a b c d\\n\", &Units));\n  EXPECT_EQ(Units.size(), 0U);\n  EXPECT_TRUE(ParseDictionaryFile(\" #zzzz\\n\", &Units));\n  EXPECT_EQ(Units.size(), 0U);\n  EXPECT_TRUE(ParseDictionaryFile(\"  #zzzz\\n\", &Units));\n  EXPECT_EQ(Units.size(), 0U);\n  EXPECT_TRUE(ParseDictionaryFile(\"  #zzzz\\naaa=\\\"aa\\\"\", &Units));\n  EXPECT_EQ(Units, Vector<Unit>({Unit({'a', 'a'})}));\n  EXPECT_TRUE(\n      ParseDictionaryFile(\"  #zzzz\\naaa=\\\"aa\\\"\\n\\nabc=\\\"abc\\\"\", &Units));\n  EXPECT_EQ(Units,\n            Vector<Unit>({Unit({'a', 'a'}), Unit({'a', 'b', 'c'})}));\n}\n\nTEST(FuzzerUtil, Base64) {\n  EXPECT_EQ(\"\", Base64({}));\n  EXPECT_EQ(\"YQ==\", Base64({'a'}));\n  EXPECT_EQ(\"eA==\", Base64({'x'}));\n  EXPECT_EQ(\"YWI=\", Base64({'a', 'b'}));\n  EXPECT_EQ(\"eHk=\", Base64({'x', 'y'}));\n  EXPECT_EQ(\"YWJj\", Base64({'a', 'b', 'c'}));\n  EXPECT_EQ(\"eHl6\", Base64({'x', 'y', 'z'}));\n  EXPECT_EQ(\"YWJjeA==\", Base64({'a', 'b', 'c', 'x'}));\n  EXPECT_EQ(\"YWJjeHk=\", Base64({'a', 'b', 'c', 'x', 'y'}));\n  EXPECT_EQ(\"YWJjeHl6\", Base64({'a', 'b', 'c', 'x', 'y', 'z'}));\n}\n\nTEST(Corpus, Distribution) {\n  Random Rand(0);\n  std::unique_ptr<InputCorpus> C(new InputCorpus(\"\"));\n  size_t N = 10;\n  size_t TriesPerUnit = 1<<16;\n  for (size_t i = 0; i < N; i++)\n    C->AddToCorpus(Unit{ static_cast<uint8_t>(i) }, 1, false, {});\n\n  Vector<size_t> Hist(N);\n  for (size_t i = 0; i < N * TriesPerUnit; i++) {\n    Hist[C->ChooseUnitIdxToMutate(Rand)]++;\n  }\n  for (size_t i = 0; i < N; i++) {\n    // A weak sanity check that every unit gets invoked.\n    EXPECT_GT(Hist[i], TriesPerUnit / N / 3);\n  }\n}\n\nTEST(Merge, Bad) {\n  const char *kInvalidInputs[] = {\n    \"\",\n    \"x\",\n    \"3\\nx\",\n    \"2\\n3\",\n    \"2\\n2\",\n    \"2\\n2\\nA\\n\",\n    \"2\\n2\\nA\\nB\\nC\\n\",\n    \"0\\n0\\n\",\n    \"1\\n1\\nA\\nDONE 0\",\n    \"1\\n1\\nA\\nSTARTED 1\",\n  };\n  Merger M;\n  for (auto S : kInvalidInputs) {\n    // fprintf(stderr, \"TESTING:\\n%s\\n\", S);\n    EXPECT_FALSE(M.Parse(S, false));\n  }\n}\n\nvoid EQ(const Vector<uint32_t> &A, const Vector<uint32_t> &B) {\n  EXPECT_EQ(A, B);\n}\n\nvoid EQ(const Vector<std::string> &A, const Vector<std::string> &B) {\n  Set<std::string> a(A.begin(), A.end());\n  Set<std::string> b(B.begin(), B.end());\n  EXPECT_EQ(a, b);\n}\n\nstatic void Merge(const std::string &Input,\n                  const Vector<std::string> Result,\n                  size_t NumNewFeatures) {\n  Merger M;\n  Vector<std::string> NewFiles;\n  EXPECT_TRUE(M.Parse(Input, true));\n  std::stringstream SS;\n  M.PrintSummary(SS);\n  EXPECT_EQ(NumNewFeatures, M.Merge(&NewFiles));\n  EXPECT_EQ(M.AllFeatures(), M.ParseSummary(SS));\n  EQ(NewFiles, Result);\n}\n\nTEST(Merge, Good) {\n  Merger M;\n\n  EXPECT_TRUE(M.Parse(\"1\\n0\\nAA\\n\", false));\n  EXPECT_EQ(M.Files.size(), 1U);\n  EXPECT_EQ(M.NumFilesInFirstCorpus, 0U);\n  EXPECT_EQ(M.Files[0].Name, \"AA\");\n  EXPECT_TRUE(M.LastFailure.empty());\n  EXPECT_EQ(M.FirstNotProcessedFile, 0U);\n\n  EXPECT_TRUE(M.Parse(\"2\\n1\\nAA\\nBB\\nSTARTED 0 42\\n\", false));\n  EXPECT_EQ(M.Files.size(), 2U);\n  EXPECT_EQ(M.NumFilesInFirstCorpus, 1U);\n  EXPECT_EQ(M.Files[0].Name, \"AA\");\n  EXPECT_EQ(M.Files[1].Name, \"BB\");\n  EXPECT_EQ(M.LastFailure, \"AA\");\n  EXPECT_EQ(M.FirstNotProcessedFile, 1U);\n\n  EXPECT_TRUE(M.Parse(\"3\\n1\\nAA\\nBB\\nC\\n\"\n                        \"STARTED 0 1000\\n\"\n                        \"DONE 0 1 2 3\\n\"\n                        \"STARTED 1 1001\\n\"\n                        \"DONE 1 4 5 6 \\n\"\n                        \"STARTED 2 1002\\n\"\n                        \"\", true));\n  EXPECT_EQ(M.Files.size(), 3U);\n  EXPECT_EQ(M.NumFilesInFirstCorpus, 1U);\n  EXPECT_EQ(M.Files[0].Name, \"AA\");\n  EXPECT_EQ(M.Files[0].Size, 1000U);\n  EXPECT_EQ(M.Files[1].Name, \"BB\");\n  EXPECT_EQ(M.Files[1].Size, 1001U);\n  EXPECT_EQ(M.Files[2].Name, \"C\");\n  EXPECT_EQ(M.Files[2].Size, 1002U);\n  EXPECT_EQ(M.LastFailure, \"C\");\n  EXPECT_EQ(M.FirstNotProcessedFile, 3U);\n  EQ(M.Files[0].Features, {1, 2, 3});\n  EQ(M.Files[1].Features, {4, 5, 6});\n\n\n  Vector<std::string> NewFiles;\n\n  EXPECT_TRUE(M.Parse(\"3\\n2\\nAA\\nBB\\nC\\n\"\n                        \"STARTED 0 1000\\nDONE 0 1 2 3\\n\"\n                        \"STARTED 1 1001\\nDONE 1 4 5 6 \\n\"\n                        \"STARTED 2 1002\\nDONE 2 6 1 3 \\n\"\n                        \"\", true));\n  EXPECT_EQ(M.Files.size(), 3U);\n  EXPECT_EQ(M.NumFilesInFirstCorpus, 2U);\n  EXPECT_TRUE(M.LastFailure.empty());\n  EXPECT_EQ(M.FirstNotProcessedFile, 3U);\n  EQ(M.Files[0].Features, {1, 2, 3});\n  EQ(M.Files[1].Features, {4, 5, 6});\n  EQ(M.Files[2].Features, {1, 3, 6});\n  EXPECT_EQ(0U, M.Merge(&NewFiles));\n  EQ(NewFiles, {});\n\n  EXPECT_TRUE(M.Parse(\"3\\n1\\nA\\nB\\nC\\n\"\n                        \"STARTED 0 1000\\nDONE 0 1 2 3\\n\"\n                        \"STARTED 1 1001\\nDONE 1 4 5 6 \\n\"\n                        \"STARTED 2 1002\\nDONE 2 6 1 3\\n\"\n                        \"\", true));\n  EQ(M.Files[0].Features, {1, 2, 3});\n  EQ(M.Files[1].Features, {4, 5, 6});\n  EQ(M.Files[2].Features, {1, 3, 6});\n  EXPECT_EQ(3U, M.Merge(&NewFiles));\n  EQ(NewFiles, {\"B\"});\n\n  // Same as the above, but with InitialFeatures.\n  EXPECT_TRUE(M.Parse(\"2\\n0\\nB\\nC\\n\"\n                        \"STARTED 0 1001\\nDONE 0 4 5 6 \\n\"\n                        \"STARTED 1 1002\\nDONE 1 6 1 3\\n\"\n                        \"\", true));\n  EQ(M.Files[0].Features, {4, 5, 6});\n  EQ(M.Files[1].Features, {1, 3, 6});\n  Set<uint32_t> InitialFeatures;\n  InitialFeatures.insert(1);\n  InitialFeatures.insert(2);\n  InitialFeatures.insert(3);\n  EXPECT_EQ(3U, M.Merge(InitialFeatures, &NewFiles));\n  EQ(NewFiles, {\"B\"});\n}\n\nTEST(Merge, Merge) {\n\n  Merge(\"3\\n1\\nA\\nB\\nC\\n\"\n        \"STARTED 0 1000\\nDONE 0 1 2 3\\n\"\n        \"STARTED 1 1001\\nDONE 1 4 5 6 \\n\"\n        \"STARTED 2 1002\\nDONE 2 6 1 3 \\n\",\n        {\"B\"}, 3);\n\n  Merge(\"3\\n0\\nA\\nB\\nC\\n\"\n        \"STARTED 0 2000\\nDONE 0 1 2 3\\n\"\n        \"STARTED 1 1001\\nDONE 1 4 5 6 \\n\"\n        \"STARTED 2 1002\\nDONE 2 6 1 3 \\n\",\n        {\"A\", \"B\", \"C\"}, 6);\n\n  Merge(\"4\\n0\\nA\\nB\\nC\\nD\\n\"\n        \"STARTED 0 2000\\nDONE 0 1 2 3\\n\"\n        \"STARTED 1 1101\\nDONE 1 4 5 6 \\n\"\n        \"STARTED 2 1102\\nDONE 2 6 1 3 100 \\n\"\n        \"STARTED 3 1000\\nDONE 3 1  \\n\",\n        {\"A\", \"B\", \"C\", \"D\"}, 7);\n\n  Merge(\"4\\n1\\nA\\nB\\nC\\nD\\n\"\n        \"STARTED 0 2000\\nDONE 0 4 5 6 7 8\\n\"\n        \"STARTED 1 1100\\nDONE 1 1 2 3 \\n\"\n        \"STARTED 2 1100\\nDONE 2 2 3 \\n\"\n        \"STARTED 3 1000\\nDONE 3 1  \\n\",\n        {\"B\", \"D\"}, 3);\n}\n\nTEST(Fuzzer, ForEachNonZeroByte) {\n  const size_t N = 64;\n  alignas(64) uint8_t Ar[N + 8] = {\n    0, 0, 0, 0, 0, 0, 0, 0,\n    1, 2, 0, 0, 0, 0, 0, 0,\n    0, 0, 3, 0, 4, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 5, 0, 6, 0, 0,\n    0, 0, 0, 0, 0, 0, 7, 0,\n    0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 8,\n    9, 9, 9, 9, 9, 9, 9, 9,\n  };\n  typedef Vector<std::pair<size_t, uint8_t> > Vec;\n  Vec Res, Expected;\n  auto CB = [&](size_t FirstFeature, size_t Idx, uint8_t V) {\n    Res.push_back({FirstFeature + Idx, V});\n  };\n  ForEachNonZeroByte(Ar, Ar + N, 100, CB);\n  Expected = {{108, 1}, {109, 2}, {118, 3}, {120, 4},\n              {135, 5}, {137, 6}, {146, 7}, {163, 8}};\n  EXPECT_EQ(Res, Expected);\n\n  Res.clear();\n  ForEachNonZeroByte(Ar + 9, Ar + N, 109, CB);\n  Expected = {          {109, 2}, {118, 3}, {120, 4},\n              {135, 5}, {137, 6}, {146, 7}, {163, 8}};\n  EXPECT_EQ(Res, Expected);\n\n  Res.clear();\n  ForEachNonZeroByte(Ar + 9, Ar + N - 9, 109, CB);\n  Expected = {          {109, 2}, {118, 3}, {120, 4},\n              {135, 5}, {137, 6}, {146, 7}};\n  EXPECT_EQ(Res, Expected);\n}\n\n// FuzzerCommand unit tests. The arguments in the two helper methods below must\n// match.\nstatic void makeCommandArgs(Vector<std::string> *ArgsToAdd) {\n  assert(ArgsToAdd);\n  ArgsToAdd->clear();\n  ArgsToAdd->push_back(\"foo\");\n  ArgsToAdd->push_back(\"-bar=baz\");\n  ArgsToAdd->push_back(\"qux\");\n  ArgsToAdd->push_back(Command::ignoreRemainingArgs());\n  ArgsToAdd->push_back(\"quux\");\n  ArgsToAdd->push_back(\"-grault=garply\");\n}\n\nstatic std::string makeCmdLine(const char *separator, const char *suffix) {\n  std::string CmdLine(\"foo -bar=baz qux \");\n  if (strlen(separator) != 0) {\n    CmdLine += separator;\n    CmdLine += \" \";\n  }\n  CmdLine += Command::ignoreRemainingArgs();\n  CmdLine += \" quux -grault=garply\";\n  if (strlen(suffix) != 0) {\n    CmdLine += \" \";\n    CmdLine += suffix;\n  }\n  return CmdLine;\n}\n\nTEST(FuzzerCommand, Create) {\n  std::string CmdLine;\n\n  // Default constructor\n  Command DefaultCmd;\n\n  CmdLine = DefaultCmd.toString();\n  EXPECT_EQ(CmdLine, \"\");\n\n  // Explicit constructor\n  Vector<std::string> ArgsToAdd;\n  makeCommandArgs(&ArgsToAdd);\n  Command InitializedCmd(ArgsToAdd);\n\n  CmdLine = InitializedCmd.toString();\n  EXPECT_EQ(CmdLine, makeCmdLine(\"\", \"\"));\n\n  // Compare each argument\n  auto InitializedArgs = InitializedCmd.getArguments();\n  auto i = ArgsToAdd.begin();\n  auto j = InitializedArgs.begin();\n  while (i != ArgsToAdd.end() && j != InitializedArgs.end()) {\n    EXPECT_EQ(*i++, *j++);\n  }\n  EXPECT_EQ(i, ArgsToAdd.end());\n  EXPECT_EQ(j, InitializedArgs.end());\n\n  // Copy constructor\n  Command CopiedCmd(InitializedCmd);\n\n  CmdLine = CopiedCmd.toString();\n  EXPECT_EQ(CmdLine, makeCmdLine(\"\", \"\"));\n\n  // Assignment operator\n  Command AssignedCmd;\n  AssignedCmd = CopiedCmd;\n\n  CmdLine = AssignedCmd.toString();\n  EXPECT_EQ(CmdLine, makeCmdLine(\"\", \"\"));\n}\n\nTEST(FuzzerCommand, ModifyArguments) {\n  Vector<std::string> ArgsToAdd;\n  makeCommandArgs(&ArgsToAdd);\n  Command Cmd;\n  std::string CmdLine;\n\n  Cmd.addArguments(ArgsToAdd);\n  CmdLine = Cmd.toString();\n  EXPECT_EQ(CmdLine, makeCmdLine(\"\", \"\"));\n\n  Cmd.addArgument(\"waldo\");\n  EXPECT_TRUE(Cmd.hasArgument(\"waldo\"));\n\n  CmdLine = Cmd.toString();\n  EXPECT_EQ(CmdLine, makeCmdLine(\"waldo\", \"\"));\n\n  Cmd.removeArgument(\"waldo\");\n  EXPECT_FALSE(Cmd.hasArgument(\"waldo\"));\n\n  CmdLine = Cmd.toString();\n  EXPECT_EQ(CmdLine, makeCmdLine(\"\", \"\"));\n}\n\nTEST(FuzzerCommand, ModifyFlags) {\n  Vector<std::string> ArgsToAdd;\n  makeCommandArgs(&ArgsToAdd);\n  Command Cmd(ArgsToAdd);\n  std::string Value, CmdLine;\n  ASSERT_FALSE(Cmd.hasFlag(\"fred\"));\n\n  Value = Cmd.getFlagValue(\"fred\");\n  EXPECT_EQ(Value, \"\");\n\n  CmdLine = Cmd.toString();\n  EXPECT_EQ(CmdLine, makeCmdLine(\"\", \"\"));\n\n  Cmd.addFlag(\"fred\", \"plugh\");\n  EXPECT_TRUE(Cmd.hasFlag(\"fred\"));\n\n  Value = Cmd.getFlagValue(\"fred\");\n  EXPECT_EQ(Value, \"plugh\");\n\n  CmdLine = Cmd.toString();\n  EXPECT_EQ(CmdLine, makeCmdLine(\"-fred=plugh\", \"\"));\n\n  Cmd.removeFlag(\"fred\");\n  EXPECT_FALSE(Cmd.hasFlag(\"fred\"));\n\n  Value = Cmd.getFlagValue(\"fred\");\n  EXPECT_EQ(Value, \"\");\n\n  CmdLine = Cmd.toString();\n  EXPECT_EQ(CmdLine, makeCmdLine(\"\", \"\"));\n}\n\nTEST(FuzzerCommand, SetOutput) {\n  Vector<std::string> ArgsToAdd;\n  makeCommandArgs(&ArgsToAdd);\n  Command Cmd(ArgsToAdd);\n  std::string CmdLine;\n  ASSERT_FALSE(Cmd.hasOutputFile());\n  ASSERT_FALSE(Cmd.isOutAndErrCombined());\n\n  Cmd.combineOutAndErr(true);\n  EXPECT_TRUE(Cmd.isOutAndErrCombined());\n\n  CmdLine = Cmd.toString();\n  EXPECT_EQ(CmdLine, makeCmdLine(\"\", \"2>&1\"));\n\n  Cmd.combineOutAndErr(false);\n  EXPECT_FALSE(Cmd.isOutAndErrCombined());\n\n  Cmd.setOutputFile(\"xyzzy\");\n  EXPECT_TRUE(Cmd.hasOutputFile());\n\n  CmdLine = Cmd.toString();\n  EXPECT_EQ(CmdLine, makeCmdLine(\"\", \">xyzzy\"));\n\n  Cmd.setOutputFile(\"thud\");\n  EXPECT_TRUE(Cmd.hasOutputFile());\n\n  CmdLine = Cmd.toString();\n  EXPECT_EQ(CmdLine, makeCmdLine(\"\", \">thud\"));\n\n  Cmd.combineOutAndErr();\n  EXPECT_TRUE(Cmd.isOutAndErrCombined());\n\n  CmdLine = Cmd.toString();\n  EXPECT_EQ(CmdLine, makeCmdLine(\"\", \">thud 2>&1\"));\n}\n\nint main(int argc, char **argv) {\n  testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "runtime/LibFuzzer/README-JFS.md",
    "content": "# LibFuzzer\n\nThis is a copy of LibFuzzer from the LLVM 6.0 SVN (prior to 6.0 release)\n\nThis is at\n\nSVN: r321544\ngit-svn: 803a9a0208b46cff21135c1a81b53b2b6cc54ea6\n\nbut it is patched with features that JFS needs. We should\nupstream these at some point.\n\n# Why are you embedding your own copy!? You MONSTER!\n\nThis is an early research project. We needed to modify\nLibFuzzer to suit our needs.\n"
  },
  {
    "path": "runtime/LibPureRandomFuzzer/API.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#include \"API.h\"\n\n#include \"Log.h\"\n#include <dlfcn.h>\n\nnamespace prf {\n\nAPI::API() : TestOneInput(LLVMFuzzerTestOneInput) {\n#ifdef __APPLE__\n  // On macOS, `dlsym` can access any optional symbols by default\n  atExit = reinterpret_cast<AtExitT*>(\n    dlsym(RTLD_DEFAULT, \"LLVMFuzzerAtExit\"));\n#elif __linux__\n  // On Linux, weak symbols will resolve this to a value only if defined\n  atExit = LLVMFuzzerAtExit;\n#else\n#error \"Unsupported platform\"\n#endif\n  if (atExit) {\n    Debug(\"Optional user-provided function LLVMFuzzerAtExit found\");\n  }\n}\n\nvoid API::AtExit() {\n  if (!atExit) {\n    return;\n  }\n  atExit();\n}\n\n} // prf"
  },
  {
    "path": "runtime/LibPureRandomFuzzer/API.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef PRF_API_H\n#define PRF_API_H\n\n#include <stddef.h>\n#include <stdint.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif // __cplusplus\n\n#ifdef __APPLE__\n// On macOS, the symbols don't need any special annotation\n#define PRF_OPTIONAL\n#elif __linux__\n// On Linux, use weak symbols to make the definition optional\n#define PRF_OPTIONAL __attribute__((weak))\n#else\n#error \"Unsupported platform\"\n#endif\n\n// user-provided, required\nint LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size);\ntypedef int TestOneInputT(const uint8_t* Data, size_t Size);\n// user-provided, optional\nPRF_OPTIONAL void LLVMFuzzerAtExit();\ntypedef void AtExitT();\n\n#undef PRF_OPTIONAL\n\n#ifdef __cplusplus\n}\n#endif // __cplusplus\n\nnamespace prf {\n\nclass API {\nprivate:\n  AtExitT* atExit;\n\npublic:\n  API();\n  TestOneInputT* TestOneInput;\n  AtExitT AtExit;\n};\n\n} // prf\n\n#endif // PRF_API_H"
  },
  {
    "path": "runtime/LibPureRandomFuzzer/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2018 J. Ryan Stinnett\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\nproject(LibPureRandomFuzzer CXX C)\n\n###############################################################################\n# Minimum CMake version and policies\n###############################################################################\ncmake_minimum_required(VERSION 2.8.12)\n\n###############################################################################\n# Language version\n###############################################################################\ninclude(CheckCXXCompilerFlag)\nCHECK_CXX_COMPILER_FLAG(\"-std=c++11\" HAS_CXX_11_FLAG)\n\n# We should use C++11\nif (HAS_CXX_11_FLAG)\n  string(APPEND CMAKE_CXX_FLAGS \" -std=c++11\")\nelse()\n  message(FATAL_ERROR \"Compiler does not support C++11\")\nendif()\n\n###############################################################################\n# Compiler info\n###############################################################################\nmessage(STATUS \"Using CXX compiler : ${CMAKE_CXX_COMPILER}\")\nmessage(STATUS \"Global CXX flags : \\\"${CMAKE_CXX_FLAGS}\\\"\")\n\n###############################################################################\n# Sanitizer support\n###############################################################################\nOPTION(USE_UBSAN \"Build with UBSan\" OFF)\nif (USE_UBSAN)\n  message(STATUS \"Building with UBSan\")\n  string(APPEND CMAKE_CXX_FLAGS \" -fsanitize=undefined -fno-omit-frame-pointer\")\nelse()\n  message(STATUS \"Not building with UBSan\")\nendif()\n\nOPTION(USE_ASAN \"Build with ASan\" OFF)\nif (USE_ASAN)\n  message(STATUS \"Building with ASan\")\n  string(APPEND CMAKE_CXX_FLAGS \" -fsanitize=address -fno-omit-frame-pointer\")\nelse()\n  message(STATUS \"Not building with ASan\")\nendif()\n\n###############################################################################\n# LibPureRandomFuzzer\n###############################################################################\nadd_library(PureRandomFuzzer STATIC\n  API.cpp\n  Driver.cpp\n  Main.cpp\n  Signals.cpp\n  TestInput.cpp\n)\n"
  },
  {
    "path": "runtime/LibPureRandomFuzzer/Driver.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#include \"Driver.h\"\n\n#include \"API.h\"\n#include \"Log.h\"\n#include \"Signals.h\"\n#include \"TestInput.h\"\n#include <cassert>\n#include <chrono>\n#include <cstddef>\n#include <cstdio>\n#include <fstream>\n#include <sstream>\n#include <string>\n#include <vector>\n\nnamespace prf {\n\ntypedef std::chrono::system_clock::time_point time_point;\n\nstruct Fuzzer {\n  const time_point startTime = std::chrono::system_clock::now();\n  Options opts;\n  TestInput* testInput;\n  uint runs;\n  time_point runStartTime;\n  API* API;\n};\nstatic Fuzzer gFuzzer;\n\nint Driver(int& argc, char**& argv) {\n  gFuzzer.opts = BuildOptions(argc, argv);\n  const Options& opts = gFuzzer.opts;\n\n  const size_t& dataLength = opts.dataLength;\n  // Allow zero data length only in special case where we are doing a single\n  // run. JFS will do this when constraints consist only of constant\n  // expressions and constant folding is disabled.\n  if (!dataLength && opts.maxRuns != 1) {\n    Debug(\"Test data length currently required\");\n    exit(1);\n  }\n\n  gFuzzer.testInput = new TestInput(dataLength, opts.seed);\n\n  // Set all appropriate signal and timer handlers\n  Signals signals(opts);\n\n  // Load any optional functions\n  gFuzzer.API = new API();\n\n  // Start testing loop\n  const size_t& maxRuns = opts.maxRuns;\n  TestOneInputT* runTest = gFuzzer.API->TestOneInput;\n  TestInput& testInput = *gFuzzer.testInput;\n  uint& runs = gFuzzer.runs;\n  time_point& runStartTime = gFuzzer.runStartTime;\n  for (runs = 0; runs < maxRuns; runs++) {\n    runStartTime = std::chrono::system_clock::now();\n    testInput.generate();\n    runTest(testInput.get(), dataLength);\n  }\n\n  PrintFinalStats();\n  gFuzzer.API->AtExit();\n  return 0;\n}\n\nvoid PrintFinalStats() {\n  if (!gFuzzer.opts.printFinalStats) {\n    return;\n  }\n  Print(\"Runs: \", gFuzzer.runs);\n  std::chrono::duration<float> elapsed =\n      std::chrono::system_clock::now() - gFuzzer.startTime;\n  Print(\"Elapsed Time: \", elapsed.count(), \"s\");\n}\n\nOptions BuildOptions(int& argc, char**& argv) {\n  std::vector<std::string> args(argv + 1, argv + argc);\n  assert(args.size() == argc - 1);\n\n  Options opts;\n\n  for (auto arg : args) {\n    int equals = arg.find('=');\n    if (arg[0] != '-' || equals < 2) {\n      Debug(\"Ignored unknown option: \", arg);\n      continue;\n    }\n    auto flagInput = arg.substr(1, equals - 1);\n    auto valueInput = arg.substr(equals + 1);\n#define PRF_OPTION_SIZE_T(flag, name, _)                                       \\\n    if (flagInput == #flag) {                                                  \\\n      opts.name = stoul(valueInput);                                           \\\n      Debug(\"opts.\", #name, \" = \", opts.name);                                 \\\n      continue;                                                                \\\n    }\n#define PRF_OPTION_UINT(flag, name, _)                                         \\\n    if (flagInput == #flag) {                                                  \\\n      opts.name = stoul(valueInput);                                           \\\n      Debug(\"opts.\", #name, \" = \", opts.name);                                 \\\n      continue;                                                                \\\n    }\n#define PRF_OPTION_INT(flag, name, _)                                          \\\n    if (flagInput == #flag) {                                                  \\\n      opts.name = stoi(valueInput);                                            \\\n      Debug(\"opts.\", #name, \" = \", opts.name);                                 \\\n      continue;                                                                \\\n    }\n#define PRF_OPTION_BOOL(flag, name, _)                                         \\\n    if (flagInput == #flag) {                                                  \\\n      opts.name = !!stoul(valueInput);                                         \\\n      Debug(\"opts.\", #name, \" = \", opts.name);                                 \\\n      continue;                                                                \\\n    }\n#define PRF_OPTION_STRING(flag, name, _)                                       \\\n    if (flagInput == #flag) {                                                  \\\n      opts.name = std::move(valueInput);                                       \\\n      Debug(\"opts.\", #name, \" = \", opts.name);                                 \\\n      continue;                                                                \\\n    }\n#include \"Options.def\"\n#undef PRF_OPTION_SIZE_T\n#undef PRF_OPTION_UINT\n#undef PRF_OPTION_INT\n#undef PRF_OPTION_BOOL\n#undef PRF_OPTION_STRING\n    Debug(\"Ignored unknown option: \", arg);\n  }\n\n  return opts;\n}\n\nvoid WriteArtifact(const char* artifactType) {\n  static uint fileIndex = 0;\n  const std::string& artifactDir = gFuzzer.opts.artifactPrefix;\n  if (artifactDir.empty()) {\n    return;\n  }\n  std::stringstream filePath;\n  filePath << artifactDir << artifactType << \"-\" << (fileIndex++);\n  Debug(\"Writing arifact to: \", filePath.str());\n  std::fstream file(filePath.str(), std::ios::binary | std::ios::out);\n  file << gFuzzer.testInput->str();\n}\n\nvoid AbortHandler(int sig) {\n  Debug(\"Abort occurred!\");\n  Debug(\"Found artifact: \", gFuzzer.testInput->str());\n  WriteArtifact(\"abort\");\n  PrintFinalStats();\n  gFuzzer.API->AtExit();\n  exit(gFuzzer.opts.errorExitCode);\n}\n\nvoid TimeoutHandler(int sig) {\n  std::chrono::duration<float> elapsedForRun =\n      std::chrono::system_clock::now() - gFuzzer.runStartTime;\n  float elapsedSecsForRun = elapsedForRun.count();\n  if (elapsedSecsForRun < gFuzzer.opts.timeout) {\n    return;\n  }\n  Debug(\"Timeout occurred!\");\n  PrintFinalStats();\n  gFuzzer.API->AtExit();\n  exit(gFuzzer.opts.timeoutExitCode);\n}\n\n} // namespace prf\n"
  },
  {
    "path": "runtime/LibPureRandomFuzzer/Driver.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef PRF_DRIVER_H\n#define PRF_DRIVER_H\n\n#include \"Types.h\"\n#include <cstddef>\n#include <string>\n\nnamespace prf {\n\nstruct Options {\n#define PRF_OPTION_SIZE_T(_, name, value)                                      \\\n  size_t name = value;\n#define PRF_OPTION_UINT(_, name, value)                                        \\\n  uint name = value;\n#define PRF_OPTION_INT(_, name, value)                                         \\\n  int name = value;\n#define PRF_OPTION_BOOL(_, name, value)                                        \\\n  bool name = value;\n#define PRF_OPTION_STRING(_, name, value)                                      \\\n  std::string name = value;\n#include \"Options.def\"\n#undef PRF_OPTION_SIZE_T\n#undef PRF_OPTION_UINT\n#undef PRF_OPTION_INT\n#undef PRF_OPTION_BOOL\n#undef PRF_OPTION_STRING\n};\n\nint Driver(int& argc, char**& argv);\n\nvoid PrintFinalStats();\n\nOptions BuildOptions(int& argc, char**& argv);\n\nvoid WriteArtifact(const char* artifactType);\n\nvoid AbortHandler(int sig);\nvoid TimeoutHandler(int sig);\n\n} // prf\n\n#endif // PRF_DRIVER_H\n"
  },
  {
    "path": "runtime/LibPureRandomFuzzer/Log.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef PRF_LOG_H\n#define PRF_LOG_H\n\n#include <iostream>\n\nnamespace prf {\n\ntemplate<typename... Ts>\nvoid Print(Ts... args) {\n  int dummy[] = {0, (std::cout << args, 0)...};\n  std::cout << std::endl;\n}\n\ntemplate<typename... Ts>\nvoid Debug(Ts... args) {\n  int dummy[] = {0, (std::cerr << args, 0)...};\n  std::cerr << std::endl;\n}\n\n} // prf\n\n#endif // PRF_LOG_H"
  },
  {
    "path": "runtime/LibPureRandomFuzzer/Main.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#include \"Driver.h\"\n\nint main(int argc, char** argv) {\n  return prf::Driver(argc, argv);\n}\n"
  },
  {
    "path": "runtime/LibPureRandomFuzzer/Options.def",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n// PRF_OPTION_<TYPE>(flag, name, default value)\n\nPRF_OPTION_SIZE_T(max_len, dataLength, 0)\nPRF_OPTION_SIZE_T(runs, maxRuns, UINT64_MAX)\nPRF_OPTION_UINT(seed, seed, 0)\nPRF_OPTION_INT(timeout, timeout, 1200)\nPRF_OPTION_INT(timeout_exitcode, timeoutExitCode, 77)\nPRF_OPTION_BOOL(handle_abrt, handleSIGABRT, true)\nPRF_OPTION_INT(error_exitcode, errorExitCode, 77)\nPRF_OPTION_BOOL(print_final_stats, printFinalStats, false)\nPRF_OPTION_STRING(artifact_prefix, artifactPrefix, \"\")\n"
  },
  {
    "path": "runtime/LibPureRandomFuzzer/README.md",
    "content": "# LibPureRandomFuzzer\n\nA fuzzer that throws random values at the target and hopes for the best.  This\nis not meant for production use, but it is instead useful as a control group for\ncomparison with JFS.\n\nThis fuzzer generally follows the same API as `LibFuzzer` from LLVM and intends\nto be a replacement for it.  However, only a subset of the `LibFuzzer` API is\ncurrently implemented to match what's needed for JFS.\n\n## Functions\n\n- [x] `LLVMFuzzerTestOneInput` (user-provided, required)\n- [ ] `LLVMFuzzerInitialize` (user-provided, optional)\n- [ ] `LLVMFuzzerCustomMutator` (user-provided, optional)\n- [ ] `LLVMFuzzerCustomCrossOver` (user-provided, optional)\n- [x] `LLVMFuzzerAtExit` (user-provided, optional)\n- [ ] `LLVMFuzzerMutate` (fuzzer-provided)\n- [ ] `LLVMFuzzerAnnounceOutput` (fuzzer-provided)\n\n## Options\n\n- [ ] `verbosity`\n- [ ] `seed`\n- [x] `runs`\n- [x] `max_len`\n- [ ] `experimental_len_control`\n- [ ] `cross_over`\n- [ ] `mutate_depth`\n- [ ] `reduce_depth`\n- [ ] `shuffle`\n- [ ] `prefer_small`\n- [x] `timeout`\n- [x] `error_exitcode`\n- [x] `timeout_exitcode`\n- [ ] `max_total_time`\n- [ ] `help`\n- [ ] `merge`\n- [ ] `merge_inner`\n- [ ] `merge_control_file`\n- [ ] `save_coverage_summary`\n- [ ] `load_coverage_summary`\n- [ ] `minimize_crash`\n- [ ] `cleanse_crash`\n- [ ] `minimize_crash_internal_step`\n- [ ] `use_counters`\n- [ ] `use_memmem`\n- [ ] `use_value_profile`\n- [ ] `use_cmp`\n- [ ] `shrink`\n- [ ] `reduce_inputs`\n- [ ] `jobs`\n- [ ] `workers`\n- [ ] `reload`\n- [ ] `report_slow_units`\n- [ ] `only_ascii`\n- [ ] `dict`\n- [x] `artifact_prefix`\n- [ ] `exact_artifact_path`\n- [ ] `print_pcs`\n- [ ] `print_funcs`\n- [x] `print_final_stats`\n- [ ] `print_corpus_stats`\n- [ ] `print_coverage`\n- [ ] `dump_coverage`\n- [ ] `handle_segv`\n- [ ] `handle_bus`\n- [x] `handle_abrt`\n- [ ] `handle_ill`\n- [ ] `handle_fpe`\n- [ ] `handle_int`\n- [ ] `handle_term`\n- [ ] `handle_xfsz`\n- [ ] `handle_usr1`\n- [ ] `handle_usr2`\n- [ ] `close_fd_mask`\n- [ ] `detect_leaks`\n- [ ] `purge_allocator_interval`\n- [ ] `trace_malloc`\n- [ ] `rss_limit_mb`\n- [ ] `malloc_limit_mb`\n- [ ] `exit_on_src_pos`\n- [ ] `exit_on_item`\n- [ ] `ignore_remaining_args`\n- [ ] `run_equivalence_server`\n- [ ] `use_equivalence_server`\n- [ ] `analyze_dict`\n- [ ] `use_clang_coverage`\n- [ ] `use_feature_frequency`\n- [ ] `default_mutators_resize_input`\n\n## Exit Codes\n\n- [x] Normal: `0`\n- [x] Error: `77` or `error_exitcode`\n- [x] Timeout: `77` or `timeout_exitcode`\n"
  },
  {
    "path": "runtime/LibPureRandomFuzzer/Signals.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#include \"Signals.h\"\n\n#include \"Log.h\"\n#include <sys/time.h>\n#include <signal.h>\n\nnamespace prf {\n\nSignals::Signals(const Options& opts) {\n  if (opts.timeout > 0) {\n    SetSignalHandler(SIGALRM, &TimeoutHandler);\n    // Just like LibFuzzer, we set a repeating OS level timer to just over half\n    // the requested timeout value.  When the timer callback fires, we'll\n    // compare time spent on the current run with the requested timeout, so in\n    // the worst case, a run might continue for `~1.5 * timeout` before\n    // aborting.\n    int timeout = opts.timeout / 2 + 1;\n    itimerval timer = {{timeout, 0}, {timeout, 0}};\n    if (setitimer(ITIMER_REAL, &timer, nullptr)) {\n      Debug(\"Unable to set timeout handler\");\n      exit(1);\n    }\n  }\n  if (opts.handleSIGABRT) {\n    SetSignalHandler(SIGABRT, &AbortHandler);\n  }\n}\n\nvoid Signals::SetSignalHandler(uint sig, SignalHandler* handler) {\n  const struct sigaction action = {handler, sig, 0};\n  if (sigaction(sig, &action, nullptr)) {\n    Debug(\"Unable to set handler for signal: \", sig);\n    exit(1);\n  }\n}\n\n} // prf"
  },
  {
    "path": "runtime/LibPureRandomFuzzer/Signals.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef PRF_SIGNALS_H\n#define PRF_SIGNALS_H\n\n#include \"Driver.h\"\n#include \"Types.h\"\n\nnamespace prf {\n\ntypedef void SignalHandler(int);\n\nclass Signals {\nprivate:\n  void SetSignalHandler(uint sig, SignalHandler* handler);\npublic:\n  Signals(const Options& opts);\n};\n\n} // prf\n\n#endif // PRF_SIGNALS_H"
  },
  {
    "path": "runtime/LibPureRandomFuzzer/TestInput.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#include \"TestInput.h\"\n\n#include <algorithm>\n#include <cstring>\n\nnamespace prf {\n\nvoid TestInput::generate() {\n  uint8_t* dest = data.data();\n  for (uint i = 0; i < data.size(); i += 4) {\n    uint32_t newData = randGen();\n    std::size_t length = std::min(data.size() - i, 4UL);\n    std::memcpy(dest + i, &newData, length);\n  }\n}\n\n} // prf"
  },
  {
    "path": "runtime/LibPureRandomFuzzer/TestInput.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef PRF_TEST_INPUT_H\n#define PRF_TEST_INPUT_H\n\n#include <random>\n#include <string>\n#include <vector>\n\nnamespace prf {\n\nclass TestInput {\nprivate:\n  std::vector<uint8_t> data;\n  std::mt19937 randGen;\n\npublic:\n  TestInput(std::size_t length, uint seed)\n      : data(length), randGen(seed ? seed : std::mt19937::default_seed) {}\n  void generate();\n  const uint8_t* get() { return data.data(); }\n  const std::string str() { return std::string(data.begin(), data.end()); }\n  std::size_t size() { return data.size(); }\n};\n\n} // prf\n\n#endif // PRF_TEST_INPUT_H"
  },
  {
    "path": "runtime/LibPureRandomFuzzer/Types.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#ifndef PRF_TYPES_H\n#define PRF_TYPES_H\n\nnamespace prf {\n\ntypedef unsigned int uint;\n\n} // prf\n\n#endif // PRF_TYPES_H"
  },
  {
    "path": "runtime/SMTLIB/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n\n# TODO: This copy should be moved into the external project\nfile(MAKE_DIRECTORY \"${CMAKE_BINARY_DIR}/runtime/include\")\nfile(MAKE_DIRECTORY \"${CMAKE_BINARY_DIR}/runtime/include/SMTLIB\")\nset(RUNTIME_HEADERS\n  \"BitVector.h\"\n  \"BufferRef.h\"\n  \"Core.h\"\n  \"Float.h\"\n  \"Messages.h\"\n  \"NativeBitVector.h\"\n  \"NativeFloat.h\"\n  \"jassert.h\"\n  \"Logger.h\"\n)\nforeach (runtime_header ${RUNTIME_HEADERS})\n  # Use configure_file() so that changes to the files in the source tree\n  # trigger CMake to re-configure itself which will then cause the copies\n  # of the headers in the build tree to be updated.\n  configure_file(\n    \"${CMAKE_CURRENT_SOURCE_DIR}/SMTLIB/${runtime_header}\"\n    \"${CMAKE_BINARY_DIR}/runtime/include/SMTLIB/${runtime_header}\"\n    COPYONLY\n  )\nendforeach()\n\n# Build runtime as external project. This allows us to use a different\n# compiler from the host and also build multiple variants of the runtime.\ninclude(ExternalProject)\ninclude(CMakeParseArguments)\ninclude(${CMAKE_SOURCE_DIR}/cmake/jfs_external_project_utils.cmake)\n\n# Build a copy of GTest using the runtime compiler. All the runtime\n# builds share this. The reason for not using the other build of GTest\n# is because that might get built with ASan which will break these builds.\n# TODO: Consider moving the build into each runtime itself so the GTest\n# is built appropriately.\nset(RuntimeGTestBuildDir \"${CMAKE_CURRENT_BINARY_DIR}/gtest\")\njfs_get_external_project_build_command(JFS_EXTERNAL_PROJECT_BUILD_COMMAND ${RuntimeGTestBuildDir})\nExternalProject_Add(BuildRuntimeGTest\n  SOURCE_DIR \"${CMAKE_CURRENT_SOURCE_DIR}/gtest\"\n  # FIXME: We should allow other generators\n  CMAKE_GENERATOR \"Unix Makefiles\"\n  CMAKE_ARGS\n    \"-DCMAKE_CXX_COMPILER=${LLVM_CLANG_CXX_TOOL}\"\n    \"-DGTEST_SRC_DIR=${GTEST_SRC_DIR}\"\n  BINARY_DIR\n    \"${RuntimeGTestBuildDir}\"\n  BUILD_ALWAYS 1\n  ${JFS_EXTERNAL_PROJECT_BUILD_COMMAND}\n  # Don't run install command\n  INSTALL_COMMAND \"\"\n  # FIXME: Guard these based on CMake version\n  USES_TERMINAL_BUILD 1\n  USES_TERMINAL_CONFIGURE 1\n)\nset(JFS_GTEST_EXPORT_FILE\n  \"${RuntimeGTestBuildDir}/jfs_gtest_exported_targets.cmake\")\n\n\n# Properties populated by the `AddJFSRuntimeBuild()` macro.\n# They need to be global properties so that they can be consumed from\n# other parts of the build system\ndefine_property(\n  GLOBAL\n  PROPERTY\n  JFS_AVAILABLE_RUNTIMES\n  BRIEF_DOCS \"List of available JFS runtimes\"\n  FULL_DOCS \"List of available JFS runtimes\"\n)\ndefine_property(\n  GLOBAL\n  PROPERTY\n  JFS_STATIC_RUNTIME_PATH\n  BRIEF_DOCS \"List of JFS static runtime library paths relative to runtime directory\"\n  FULL_DOCS \"List of JFS static runtime library paths relative to runtime directory\"\n)\n\nmacro(AddJFSRuntimeBuild)\n  cmake_parse_arguments(jfs_runtime_arg\n    \"ASAN;UBSAN;RUNTIME_ASSERTS;DEBUG_SYMBOLS;OPTIMIZED;RUN_UNIT_TESTS;TRACE_PC_GUARD;TRACE_CMP\"\n    \"\"\n    \"\"\n    ${ARGN}\n  )\n  # Compute build name from arguments\n  set(buildName \"\")\n  if (jfs_runtime_arg_DEBUG_SYMBOLS)\n    string(APPEND buildName \"_DebugSymbols\")\n  endif()\n  if (jfs_runtime_arg_OPTIMIZED)\n    string(APPEND buildName \"_Optimized\")\n  endif()\n  if (jfs_runtime_arg_RUNTIME_ASSERTS)\n    string(APPEND buildName \"_RuntimeAsserts\")\n  endif()\n  if (jfs_runtime_arg_ASAN)\n    string(APPEND buildName \"_ASan\")\n  endif()\n  if (jfs_runtime_arg_UBSAN)\n    string(APPEND buildName \"_UBSan\")\n  endif()\n  if (jfs_runtime_arg_TRACE_PC_GUARD)\n    string(APPEND buildName \"_TracePCGuard\")\n  endif()\n  if (jfs_runtime_arg_TRACE_CMP)\n    string(APPEND buildName \"_TraceCmp\")\n  endif()\n  message(STATUS \"Adding JFS runtime ${buildName}\")\n  set(buildDir \"${CMAKE_CURRENT_BINARY_DIR}/SMTLIB_${buildName}\")\n\n  # Compute CMake build type\n  if (jfs_runtime_arg_OPTIMIZED)\n    if (jfs_runtime_arg_DEBUG_SYMBOLS)\n      set(jfs_runtime_cmake_build_type \"RelWithDebInfo\")\n    else()\n      set(jfs_runtime_cmake_build_type \"Release\")\n    endif()\n  else()\n    set(jfs_runtime_cmake_build_type \"Debug\")\n  endif()\n\n  # Compute SANITIZER_COVERAGE_OPTS\n  set(SANITIZER_COVERAGE_OPTS \"\")\n  if (jfs_runtime_arg_TRACE_PC_GUARD)\n    list(APPEND SANITIZER_COVERAGE_OPTS \"TRACE_PC_GUARD\")\n  endif()\n  if (jfs_runtime_arg_TRACE_CMP)\n    list(APPEND SANITIZER_COVERAGE_OPTS \"TRACE_CMP\")\n  endif()\n\n  jfs_get_external_project_build_command(JFS_EXTERNAL_PROJECT_BUILD_COMMAND ${buildDir})\n  set(external_project_target_name \"BuildSMTLIBRuntime${buildName}\")\n  ExternalProject_Add(${external_project_target_name}\n    DEPENDS BuildRuntimeGTest\n    SOURCE_DIR \"${CMAKE_CURRENT_SOURCE_DIR}/SMTLIB\"\n    # FIXME: We should allow other generators\n    CMAKE_GENERATOR \"Unix Makefiles\"\n    CMAKE_ARGS\n      \"-DCMAKE_CXX_COMPILER=${LLVM_CLANG_CXX_TOOL}\"\n      \"-DCMAKE_BUILD_TYPE=${jfs_runtime_cmake_build_type}\"\n      \"-DJFS_BINARY_ROOT=${CMAKE_BINARY_DIR}\"\n      \"-DJFS_SOURCE_ROOT=${CMAKE_SOURCE_DIR}\"\n      \"-DJFS_GTEST_EXPORT_FILE=${JFS_GTEST_EXPORT_FILE}\"\n      \"-DGTEST_SRC_DIR=${GTEST_SRC_DIR}\"\n      \"-DLIT_TOOL:string=${LIT_TOOL}\"\n      \"-DUSE_ASAN=${jfs_runtime_arg_ASAN}\"\n      \"-DUSE_UBSAN=${jfs_runtime_arg_UBSAN}\"\n      \"-DENABLE_JFS_RUNTIME_ASSERTS=${jfs_runtime_arg_RUNTIME_ASSERTS}\"\n      \"-DJFS_RUNTIME_ASSERTS_CALL_ABORT=OFF\"\n    CMAKE_CACHE_ARGS\n      # HACK: We have to pass `LIT_ARGS` this way because\n      # its a list and passing it in `CMAKE_ARGS` doesn't\n      # seem to work.\n      \"-DLIT_ARGS:string=${LIT_ARGS}\"\n      \"-DENABLE_UNIT_TESTS:bool=${jfs_runtime_arg_RUN_UNIT_TESTS}\"\n      \"-DSANITIZER_COVERAGE:string=${SANITIZER_COVERAGE_OPTS}\"\n    BINARY_DIR \"${buildDir}\"\n    BUILD_ALWAYS 1\n    ${JFS_EXTERNAL_PROJECT_BUILD_COMMAND}\n    # Don't run install command\n    INSTALL_COMMAND \"\"\n    # FIXME: Guard these based on CMake version\n    USES_TERMINAL_BUILD 1\n    USES_TERMINAL_CONFIGURE 1\n  )\n  if (jfs_runtime_arg_RUN_UNIT_TESTS)\n    message(STATUS \"Enabling unit tests for JFS runtime ${buildName}\")\n    # Add custom target that invokes the unit teset target inside the external project\n    add_custom_target(jfs_runtime_${buildName}_unittests\n      COMMENT \"Runing JFS ${buildName} Runtime unittests\"\n      COMMAND\n      \"${CMAKE_COMMAND}\" --build \"${buildDir}/unittests\" --target jfs_runtime_unittests\n      DEPENDS ${external_project_target_name}\n      USES_TERMINAL\n    )\n    add_dependencies(unittests jfs_runtime_${buildName}_unittests)\n  endif()\n\n  # Append to JFS_AVAILABLE_RUNTIMES\n  string(TOUPPER \"${buildName}\" CAPITALIZED_BUILD_NAME)\n  string(REGEX REPLACE\n    \"^_\"\n    \"\"\n    CAPITALIZED_BUILD_NAME_NO_LEADING_UNDERSCORE\n    \"${CAPITALIZED_BUILD_NAME}\"\n  )\n  set_property(\n    GLOBAL\n    APPEND\n    PROPERTY JFS_AVAILABLE_RUNTIMES\n    \"${CAPITALIZED_BUILD_NAME_NO_LEADING_UNDERSCORE}\"\n  )\n  # Append to JFS_STATIC_RUNTIME_PATH\n  # This path will be relative to the `runtime`\n  file(RELATIVE_PATH\n    RUNTIME_LIBRARY_PATH\n    \"${CMAKE_BINARY_DIR}/runtime\" # Relative to\n    \"${buildDir}/libJFSSMTLIBRuntime.a\" # FIXME: Not portable\n  )\n  set_property(\n    GLOBAL\n    APPEND\n    PROPERTY JFS_STATIC_RUNTIME_PATH\n    \"${RUNTIME_LIBRARY_PATH}\"\n  )\nendmacro()\n\n\n# TODO: Add more configurations so we can experiment with them from jfs.\n\n# For debugging\nAddJFSRuntimeBuild(\n  DEBUG_SYMBOLS\n  RUN_UNIT_TESTS\n  TRACE_PC_GUARD\n)\n\nAddJFSRuntimeBuild(\n  OPTIMIZED\n  DEBUG_SYMBOLS\n  RUN_UNIT_TESTS\n)\n\nAddJFSRuntimeBuild(\n  OPTIMIZED\n  DEBUG_SYMBOLS\n  RUN_UNIT_TESTS\n  TRACE_PC_GUARD\n)\n\nAddJFSRuntimeBuild(\n  OPTIMIZED\n  DEBUG_SYMBOLS\n  RUNTIME_ASSERTS\n  RUN_UNIT_TESTS\n  TRACE_PC_GUARD\n)\n# NOTE: There's no config to run with ASan/UBSan but not have runtime\n# asserts. It's unlikely we'd want to do that so don't build that\n# config for now.\nAddJFSRuntimeBuild(\n  DEBUG_SYMBOLS\n  OPTIMIZED\n  RUNTIME_ASSERTS\n  ASAN\n  UBSAN\n  RUN_UNIT_TESTS\n  TRACE_PC_GUARD\n)\nAddJFSRuntimeBuild(\n  DEBUG_SYMBOLS\n  OPTIMIZED\n  RUNTIME_ASSERTS\n  ASAN\n  TRACE_PC_GUARD\n  # Don't run tests as covered by config that mixes ASan and UBSan together\n)\nAddJFSRuntimeBuild(\n  DEBUG_SYMBOLS\n  OPTIMIZED\n  RUNTIME_ASSERTS\n  UBSAN\n  TRACE_PC_GUARD\n  # Don't run tests as covered by config that mixes ASan and UBSan together\n)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/BitVector.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_RUNTIME_SMTLIB_BITVECTOR_H\n#define JFS_RUNTIME_SMTLIB_BITVECTOR_H\n#include \"BufferRef.h\"\n#include \"NativeBitVector.h\"\n#include \"jassert.h\"\n#include <stdint.h>\n#include <stdlib.h>\n#include <string.h>\n#include <type_traits>\n\n\n// Arbitary precision bitvector of width N\n// that mimics the semantics of SMT-LIBv2\ntemplate <uint64_t N, typename = void> class BitVector {};\n\n// Foward declaration\ntemplate <uint64_t EB, uint64_t SB> class Float;\n\n// Use template magic to specialize BitVector for widths\n// <= 64 bits. This implementation uses native machine operations\n// for speed.\ntemplate <uint64_t N>\nclass BitVector<\n    N, typename std::enable_if<(N <= JFS_NR_BITVECTOR_TY_BITWIDTH)>::type> {\nprivate:\n  typedef jfs_nr_bitvector_ty dataTy;\n  dataTy data;\n  constexpr dataTy mask() const {\n    return (N >= 64) ? UINT64_MAX : ((UINT64_C(1) << N) - 1);\n  }\n  dataTy doMod(dataTy value) const {\n    if (N >= 64)\n      return value;\n    else\n      return value % (UINT64_C(1) << N);\n  }\n  constexpr dataTy mostSignificantBitMask() const {\n    return (UINT64_C(1) << (N - 1));\n  }\n\n  constexpr dataTy computeSignExtendMask(uint64_t bits) const {\n    return ((N + bits) >= 64) ? UINT64_MAX : ((UINT64_C(1) << (N + bits)) - 1);\n  }\n\npublic:\n  BitVector(uint64_t value) {\n    static_assert(N > 0 && N <= JFS_NR_BITVECTOR_TY_BITWIDTH,\n                  \"Invalid value for N\");\n    data = doMod(value);\n    jassert(data == value);\n  }\n\n  BitVector() : BitVector(0) {\n    static_assert(N > 0 && N <= JFS_NR_BITVECTOR_TY_BITWIDTH,\n                  \"Invalid value for N\");\n  }\n  BitVector(const BitVector<N>& other) : data(other.data) {\n    static_assert(N > 0 && N <= JFS_NR_BITVECTOR_TY_BITWIDTH,\n                  \"Invalid value for N\");\n  }\n  BufferRef<uint8_t> getBuffer() const {\n    return BufferRef<uint8_t>(\n        reinterpret_cast<uint8_t*>(const_cast<dataTy*>(&data)), sizeof(dataTy));\n  }\n  // Operators producing values of width != N\n\n  // Repeat operation producing a width that is native\n  template <\n      uint64_t M,\n      typename std::enable_if<(((N * M) <= JFS_NR_BITVECTOR_TY_BITWIDTH) &&\n                               (N * M) > 0)>::type* = nullptr>\n  BitVector<(N * M)> repeat() const {\n    // TODO:\n    JFS_RUNTIME_FAIL();\n    return BitVector<N * M>(0);\n  }\n\n  // Repeat operation producing a width that is not native\n  template <uint64_t M,\n            typename std::enable_if<\n                ((N * M) > JFS_NR_BITVECTOR_TY_BITWIDTH)>::type* = nullptr>\n  BitVector<(N * M)> repeat() const {\n    // TODO:\n    JFS_RUNTIME_FAIL();\n    return BitVector<N * M>(0);\n  }\n\n  // Concat [this][rhs]\n  // this is conceptually in MSB.\n  // rhs is in conceptually in LSB.\n  //\n  // Implementation for where result is a native BitVector\n  template <uint64_t M,\n            typename std::enable_if<\n                ((N + M) <= JFS_NR_BITVECTOR_TY_BITWIDTH)>::type* = nullptr>\n  BitVector<N + M> concat(const BitVector<M>& rhs) const {\n    // Concatentation produces native BitVector.\n    static_assert((N + M) <= 64, \"Too many bits\");\n    return BitVector<N + M>(jfs_nr_concat(data, N, rhs.data, M));\n  }\n\n  // Implementation for where result is not a native BitVector\n  template <uint64_t M,\n            typename std::enable_if<\n                ((N + M) > JFS_NR_BITVECTOR_TY_BITWIDTH)>::type* = nullptr>\n  BitVector<N + M> concat(const BitVector<M>& rhs) const {\n    // Concat produces bitvector that we can't represent natively.\n    constexpr size_t bufferSize = (N + M + 7) / 8;\n    uint8_t rawData[bufferSize];\n\n    // Copy across rhs\n    memcpy(rawData, rhs.getBuffer().get(), rhs.getBuffer().getSize());\n\n    const size_t lhsByteStart = M / 8;\n    const size_t shiftOffset = M % 8;\n    const size_t lookBackShiftOffset = 8 - shiftOffset;\n    if (shiftOffset == 0) {\n      // On byte boundary\n      for (unsigned int index = lhsByteStart; index < bufferSize; ++index) {\n        if ((index * 8) < (N + M)) {\n          const uint8_t* lhsByte =\n              reinterpret_cast<const uint8_t*>(&data) + (index - lhsByteStart);\n          // We are writing a byte from lhs\n          rawData[index] = *lhsByte;\n          continue;\n        }\n        // Zero the data\n        rawData[index] = 0;\n      }\n    } else {\n      // Not on byte boundary. More complicated\n      for (unsigned int index = lhsByteStart; index < bufferSize; ++index) {\n        if ((index * 8) < (N + M)) {\n          // We are writing at least 1 bit for lhs\n          const uint8_t* lhsByte =\n              reinterpret_cast<const uint8_t*>(&data) + (index - lhsByteStart);\n          if (index == lhsByteStart) {\n            // First byte has to be done specially because we writing\n            // to a byte that contains bits from rhs (hence `|=`).\n            rawData[index] |= ((*lhsByte) << shiftOffset);\n            continue;\n          }\n          // Not doing the first byte. This means we need to also grab the bits\n          // from the previous iteration that we shifted out.\n          const uint8_t* lhsBytePrevIter = lhsByte - 1;\n          uint8_t lhsByteValue = 0;\n          if ((index - lhsByteStart) < sizeof(dataTy)) {\n            // Guard accessing this byte. On the last iteration\n            // we may need to still copy bits from the previous iteration\n            // but reading `*lhsByte` would be an out of bounds access.\n            lhsByteValue = *lhsByte;\n          }\n          rawData[index] = (lhsByteValue << shiftOffset) |\n                           ((*lhsBytePrevIter) >> lookBackShiftOffset);\n          continue;\n        }\n        // Not writing any bits from lhs so just zero the data\n        rawData[index] = 0;\n      }\n    }\n    BufferRef<uint8_t> rawDataRef(reinterpret_cast<uint8_t*>(rawData),\n                                  bufferSize);\n    return BitVector<N + M>(rawDataRef);\n  }\n\n  template <uint64_t BITS>\n  BitVector<BITS> extract(uint64_t highBit, uint64_t lowBit) const {\n    return BitVector<BITS>(jfs_nr_extract(data, N, highBit, lowBit));\n  }\n\n  // Implementation for where result is a native BitVector\n  template <uint64_t BITS,\n            typename std::enable_if<\n                ((N + BITS) <= JFS_NR_BITVECTOR_TY_BITWIDTH)>::type* = nullptr>\n  BitVector<N + BITS> zeroExtend() const {\n    static_assert((N + BITS) <= JFS_NR_BITVECTOR_TY_BITWIDTH, \"too many bits\");\n    return BitVector<N + BITS>(jfs_nr_zero_extend(data, N, BITS));\n  }\n\n  // Implementation for where result is not a native BitVector\n  template <uint64_t BITS,\n            typename std::enable_if<\n                ((N + BITS) > JFS_NR_BITVECTOR_TY_BITWIDTH)>::type* = nullptr>\n  BitVector<N + BITS> zeroExtend() const {\n    constexpr size_t bufferSize = (N + BITS + 7) / 8;\n    uint8_t rawData[bufferSize];\n    // Zero the buffer\n    memset(rawData, 0, bufferSize);\n    // Copy in this bits\n    memcpy(rawData, &data, sizeof(dataTy));\n    BufferRef<uint8_t> bufferRef(rawData, bufferSize);\n    return BitVector<N + BITS>(bufferRef);\n  }\n\n  // Implementation for where result is a native BitVector\n  template <uint64_t BITS,\n            typename std::enable_if<\n                ((N + BITS) <= JFS_NR_BITVECTOR_TY_BITWIDTH)>::type* = nullptr>\n  BitVector<N + BITS> signExtend() const {\n    static_assert((N + BITS) <= JFS_NR_BITVECTOR_TY_BITWIDTH, \"too many bits\");\n    return BitVector<N + BITS>(jfs_nr_sign_extend(data, N, BITS));\n  }\n\n  // Implementation for where result is not a native BitVector\n  template <uint64_t BITS,\n            typename std::enable_if<\n                ((N + BITS) > JFS_NR_BITVECTOR_TY_BITWIDTH)>::type* = nullptr>\n  BitVector<N + BITS> signExtend() const {\n    static_assert((N + BITS) > JFS_NR_BITVECTOR_TY_BITWIDTH, \"too few bits\");\n    if ((data & mostSignificantBitMask()) == 0) {\n      // Can just zero extend\n      return zeroExtend<BITS>();\n    }\n    // Have to sign extend\n    constexpr size_t bufferSize = (N + BITS + 7) / 8;\n    uint8_t rawData[bufferSize];\n    uint64_t resultMask = computeSignExtendMask(BITS);\n    uint64_t signExtendedOriginal = (data | (~mask())) & resultMask;\n    // Copy in signExtended\n    memcpy(rawData, &signExtendedOriginal, sizeof(dataTy));\n    // Now set remaining bytes to all ones.\n    memset(rawData + sizeof(dataTy), 0xff, bufferSize - sizeof(dataTy));\n    // Modify last byte if necessary. We need to maintain invariant\n    // that bits in the buffer outside of the bitvector we want to represent\n    // are zero.\n    if (((N + BITS) % 8) != 0) {\n      uint8_t lastByteMask = 0xff;\n      lastByteMask >>= (8 - ((N + BITS) % 8));\n      rawData[bufferSize - 1] &= lastByteMask;\n    }\n    BufferRef<uint8_t> buffer(rawData, bufferSize);\n    return BitVector<N + BITS>(buffer);\n  }\n\n  // Arithmetic operators\n  BitVector<N> bvneg() const { return BitVector<N>(jfs_nr_bvneg(data, N)); }\n\n  BitVector<N> bvadd(const BitVector<N>& other) const {\n    return BitVector<N>(jfs_nr_bvadd(data, other.data, N));\n  }\n\n  BitVector<N> bvsub(const BitVector<N>& other) const {\n    return BitVector<N>(jfs_nr_bvsub(data, other.data, N));\n  }\n\n  BitVector<N> bvmul(const BitVector<N>& other) const {\n    return BitVector<N>(jfs_nr_bvmul(data, other.data, N));\n  }\n\n  BitVector<N> bvudiv(const BitVector<N>& divisor) const {\n    return BitVector<N>(jfs_nr_bvudiv(data, divisor.data, N));\n  }\n\n  BitVector<N> bvurem(const BitVector<N>& divisor) const {\n    return BitVector<N>(jfs_nr_bvurem(data, divisor.data, N));\n  }\n\n  BitVector<N> bvsdiv(const BitVector<N>& divisor) const {\n    return BitVector<N>(jfs_nr_bvsdiv(data, divisor.data, N));\n  }\n\n  BitVector<N> bvsrem(const BitVector<N>& divisor) const {\n    return BitVector<N>(jfs_nr_bvsrem(data, divisor.data, N));\n  }\n\n  BitVector<N> bvsmod(const BitVector<N>& divisor) const {\n    return BitVector<N>(jfs_nr_bvsmod(data, divisor.data, N));\n  }\n\n  // Shift operators\n\n  BitVector<N> bvshl(const BitVector<N>& shift) const {\n    return BitVector<N>(jfs_nr_bvshl(data, shift.data, N));\n  }\n\n  BitVector<N> bvlshr(const BitVector<N>& shift) const {\n    return BitVector<N>(jfs_nr_bvlshr(data, shift.data, N));\n  }\n\n  BitVector<N> bvashr(const BitVector<N>& shift) const {\n    return BitVector<N>(jfs_nr_bvashr(data, shift.data, N));\n  }\n\n  BitVector<N> rotate_left(uint64_t shift) const {\n    return BitVector<N>(jfs_nr_rotate_left(data, shift, N));\n  }\n\n  BitVector<N> rotate_right(uint64_t shift) const {\n    return BitVector<N>(jfs_nr_rotate_right(data, shift, N));\n  }\n\n  // Bitwise operators\n  BitVector<N> bvand(const BitVector<N>& other) const {\n    return BitVector<N>(jfs_nr_bvand(data, other.data, N));\n  }\n\n  BitVector<N> bvor(const BitVector<N>& other) const {\n    return BitVector<N>(jfs_nr_bvor(data, other.data, N));\n  }\n\n  BitVector<N> bvnot() const { return BitVector<N>(jfs_nr_bvnot(data, N)); }\n\n  BitVector<N> bvnand(const BitVector<N>& other) const {\n    return BitVector<N>(jfs_nr_bvnand(data, other.data, N));\n  }\n\n  BitVector<N> bvnor(const BitVector<N>& other) const {\n    return BitVector<N>(jfs_nr_bvnor(data, other.data, N));\n  }\n\n  BitVector<N> bvxor(const BitVector<N>& other) const {\n    return BitVector<N>(jfs_nr_bvxor(data, other.data, N));\n  }\n\n  BitVector<N> bvxnor(const BitVector<N>& other) const {\n    return BitVector<N>(jfs_nr_bvxnor(data, other.data, N));\n  }\n\n  // Comparison operators\n  bool operator==(const BitVector<N>& rhs) const { return data == rhs.data; }\n  bool operator!=(const BitVector<N>& rhs) const { return data != rhs.data; }\n\n  bool bvult(const BitVector<N>& rhs) const {\n    return jfs_nr_bvult(data, rhs.data, N);\n  }\n  bool bvule(const BitVector<N>& rhs) const {\n    return jfs_nr_bvule(data, rhs.data, N);\n  }\n  bool bvugt(const BitVector<N>& rhs) const {\n    return jfs_nr_bvugt(data, rhs.data, N);\n  }\n  bool bvuge(const BitVector<N>& rhs) const {\n    return jfs_nr_bvuge(data, rhs.data, N);\n  }\n\n  bool bvslt(const BitVector<N>& rhs) const {\n    return jfs_nr_bvslt(data, rhs.data, N);\n  }\n\n  bool bvsle(const BitVector<N>& rhs) const {\n    return jfs_nr_bvsle(data, rhs.data, N);\n  }\n\n  bool bvsgt(const BitVector<N>& rhs) const {\n    return jfs_nr_bvsgt(data, rhs.data, N);\n  }\n\n  bool bvsge(const BitVector<N>& rhs) const {\n    return jfs_nr_bvsge(data, rhs.data, N);\n  }\n\n  BitVector<1> bvcomp(const BitVector<N>& rhs) const {\n    // SMTLIB gives this recursive definition:\n    // (bvcomp s t) abbreviates (bvxnor s t) if m = 1, and\n    //   (bvand (bvxnor ((_ extract |m-1| |m-1|) s) ((_ extract |m-1| |m-1|) t))\n    //          (bvcomp ((_ extract |m-2| 0) s) ((_ extract |m-2| 0) t)))\n    //          otherwise\n    //\n    // But we can just do this.\n    if (data == rhs.data) {\n      return BitVector<1>(1);\n    }\n    return BitVector<1>(0);\n  }\n  // This template is friends with all other instantiations\n  // FIXME: It would be better if we were only friends where\n  // N <= 64.\n  template <uint64_t W, typename T> friend class BitVector;\n  // Float needs raw access\n  template <uint64_t EB, uint64_t SB> friend class Float;\n};\n\ntemplate <uint64_t N>\nclass BitVector<\n    N, typename std::enable_if<(N > JFS_NR_BITVECTOR_TY_BITWIDTH)>::type> {\nprivate:\n  uint8_t* data;\n  constexpr size_t numBytesRequired(size_t bits) const {\n    return (bits + 7) / 8;\n  }\n\npublic:\n  // FIXME: We make this more efficient by lazily allocating memory.\n  // Initialize from array\n  BitVector(uint8_t* bytesToCopy, size_t numBytes) : data(nullptr) {\n    data = reinterpret_cast<uint8_t*>(malloc(numBytesRequired(N)));\n    jassert(data);\n    jassert(bytesToCopy);\n    jassert(numBytes <= numBytesRequired(N));\n    memcpy(data, bytesToCopy, numBytesRequired(N));\n  }\n  BitVector(BufferRef<uint8_t> bufferRef)\n      : BitVector(bufferRef.get(), bufferRef.getSize()) {}\n  // Initialize to zero\n  BitVector() {\n    data = reinterpret_cast<uint8_t*>(malloc(numBytesRequired(N)));\n    jassert(data);\n    memset(data, 0, numBytesRequired(N));\n  }\n  BitVector(uint64_t value) : BitVector() {\n    memcpy(data, &value, sizeof(uint64_t));\n  }\n  ~BitVector() {\n    if (data)\n      free(data);\n  }\n  BufferRef<uint8_t> getBuffer() const {\n    return BufferRef<uint8_t>(data, numBytesRequired(N));\n  }\n  // TODO:\n};\n\n// Convenience function for creating a BitVector\n// from any arbitrary bit offset in a buffer. Offset\n// is [lowbit, highbit].\n// Implementation for native BitVector\ntemplate <uint64_t BITWIDTH,\n          typename std::enable_if<\n              (BITWIDTH <= JFS_NR_BITVECTOR_TY_BITWIDTH)>::type* = nullptr>\nBitVector<BITWIDTH> makeBitVectorFrom(BufferRef<const uint8_t> buffer,\n                                      uint64_t lowBit, uint64_t highBit) {\n  jassert(highBit >= lowBit && \"invalid lowBit and highBit\");\n  jassert(((highBit - lowBit) + 1) == BITWIDTH);\n  jassert(highBit < (buffer.getSize() * 8));\n  jfs_nr_bitvector_ty data =\n      jfs_nr_make_bitvector(buffer.get(), buffer.getSize(), lowBit, highBit);\n  return BitVector<BITWIDTH>(data);\n}\n\n#endif\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/BufferRef.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_RUNTIME_SMTLIB_BUFFER_REF_H\n#define JFS_RUNTIME_SMTLIB_BUFFER_REF_H\n#include <stdlib.h>\n\ntemplate <typename T> class BufferRef {\nprivate:\n  T* data;\n  size_t size;\n\npublic:\n  BufferRef(T* data, size_t size) : data(data), size(size) {}\n  T* get() const { return data; }\n  operator T*() const { return get(); }\n  size_t getSize() const { return size; }\n};\n\n#endif\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\nproject(SMTLIBRuntime CXX)\n\n###############################################################################\n# Minimum CMake version and policies\n###############################################################################\ncmake_minimum_required(VERSION 2.8.12)\n\nif (NOT DEFINED JFS_SOURCE_ROOT)\n  message(FATAL_ERROR \"JFS_SOURCE_ROOT must be defined\")\nendif()\nif (NOT EXISTS \"${JFS_SOURCE_ROOT}\")\n  message(FATAL_ERROR \"JFS_SOURCE_ROOT (${JFS_SOURCE_ROOT}) must exist\")\nendif()\n\nif (NOT DEFINED JFS_BINARY_ROOT)\n  message(FATAL_ERROR \"JFS_BINARY_ROOT must be defined\")\nendif()\nif (NOT EXISTS \"${JFS_BINARY_ROOT}\")\n  message(FATAL_ERROR \"JFS_BINARY_ROOT (${JFS_BINARY_ROOT}) must exist\")\nendif()\n\nif (NOT DEFINED JFS_GTEST_EXPORT_FILE)\n  message(FATAL_ERROR \"JFS_GTEST_EXPORT_FILE must be defined\")\nendif()\n\nif (NOT DEFINED LIT_TOOL)\n  message(FATAL_ERROR \"LIT_TOOL must be defined\")\nelse()\n  message(STATUS \"LIT_TOOL: \\\"${LIT_TOOL}\\\"\")\nendif()\n\nif (NOT DEFINED LIT_ARGS)\n  message(FATAL_ERROR \"LIT_ARGS must be defined\")\nelse()\n  message(STATUS \"LIT_ARGS: \\\"${LIT_ARGS}\\\"\")\nendif()\n\n###############################################################################\n# Language version\n###############################################################################\ninclude(CheckCXXCompilerFlag)\nCHECK_CXX_COMPILER_FLAG(\"-std=c++11\" HAS_CXX_11_FLAG)\n\n# We should use C++11\nif (HAS_CXX_11_FLAG)\n  string(APPEND CMAKE_CXX_FLAGS \" -std=c++11\")\nelse()\n  message(FATAL_ERROR \"Compiler does not support C++11\")\nendif()\nmessage(STATUS \"Using CXX compiler : ${CMAKE_CXX_COMPILER}\")\n\n###############################################################################\n# Sanitizer support\n###############################################################################\nOPTION(USE_UBSAN \"Build with UBSan\" OFF)\nif (USE_UBSAN)\n  message(STATUS \"Building with UBSan\")\n  string(APPEND CMAKE_CXX_FLAGS \" -fsanitize=undefined -fno-omit-frame-pointer\")\nelse()\n  message(STATUS \"Not building with UBSan\")\nendif()\n\nOPTION(USE_ASAN \"Build with ASan\" OFF)\nif (USE_ASAN)\n  message(STATUS \"Building with ASan\")\n  string(APPEND CMAKE_CXX_FLAGS \" -fsanitize=address -fno-omit-frame-pointer\")\nelse()\n  message(STATUS \"Not building with ASan\")\nendif()\n\n###############################################################################\n# Sanitizer Coverage\n###############################################################################\nset(SANITIZER_COVERAGE_valid_options \"TRACE_PC_GUARD;TRACE_CMP\")\nset(SANITIZER_COVERAGE\n  \"\"\n  CACHE\n  STRING\n  \"Valid values: ${SANITIZER_COVERAGE_valid_options}\"\n)\nforeach (sanitizer_cov_opt ${SANITIZER_COVERAGE})\n  message(STATUS \"Enable SanitizerCoverage: ${sanitizer_cov_opt}\")\n  if (\"${sanitizer_cov_opt}\" STREQUAL \"TRACE_PC_GUARD\")\n    string(APPEND CMAKE_CXX_FLAGS \" -fsanitize-coverage=trace-pc-guard\")\n  elseif (\"${sanitizer_cov_opt}\" STREQUAL \"TRACE_CMP\")\n    string(APPEND CMAKE_CXX_FLAGS \" -fsanitize-coverage=trace-cmp\")\n  else()\n    message(FATAL_ERROR \"Unsupported SANITIZER_COVERAGE value \\\"${sanitizer_cov_opt}\\\"\")\n  endif()\nendforeach()\n\n###############################################################################\n# SMTLIB runtime\n###############################################################################\n\nadd_library(JFSSMTLIBRuntime\n  STATIC\n  Core.cpp\n  Float.cpp\n  Logger.cpp\n  Messages.cpp\n  NativeBitVector.cpp\n  NativeFloat.cpp\n)\n\n# FIXME: We shouldn't be relying on external to set this up.\ntarget_include_directories(JFSSMTLIBRuntime\n  PUBLIC \"${JFS_BINARY_ROOT}/runtime/include\"\n)\n\n# Header should use C++11\ntarget_compile_options(JFSSMTLIBRuntime\n  INTERFACE \"${JFS_USE_CXX_FLAG}\"\n)\n\n# Runtime asserts\noption(ENABLE_JFS_RUNTIME_ASSERTS \"Enable runtime assertions\" ON)\nif (ENABLE_JFS_RUNTIME_ASSERTS)\n  message(STATUS \"JFS runtime asserts enabled\")\n  target_compile_definitions(JFSSMTLIBRuntime\n    PUBLIC\n    \"-DENABLE_JFS_RUNTIME_ASSERTS\"\n  )\nelse()\n  message(STATUS \"JFS runtime asserts disabled\")\nendif()\n\noption(JFS_RUNTIME_ASSERTS_CALL_ABORT \"JFS runtime asserts call abort on failure\" OFF)\nif (JFS_RUNTIME_ASSERTS_CALL_ABORT)\n  message(STATUS \"JFS runtime asserts call abort()\")\n  target_compile_definitions(JFSSMTLIBRuntime\n    PUBLIC\n    \"-DJFS_RUNTIME_FAILURE_CALLS_ABORT\"\n  )\nendif()\n\n###############################################################################\n# Unit tests\n###############################################################################\noption(ENABLE_UNIT_TESTS \"Enable unit tests\" ON)\nif (ENABLE_UNIT_TESTS)\n  add_subdirectory(unittests)\nendif()\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/Core.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n// FIXME: Make the layout consistent between srcdir and build directory\n#include \"SMTLIB/Core.h\"\n#include \"jassert.h\"\n\n// FIXME: Should we specialise for byte aligned access?\nbool makeBoolFrom(BufferRef<const uint8_t> buffer, const uint64_t lowBit,\n                  const uint64_t highBit) {\n  jassert(highBit >= lowBit && \"invalid lowBit and highBit\");\n  const size_t bitWidth = (highBit - lowBit) + 1;\n  jassert(bitWidth <= 8 && \"Too many bits\");\n  const size_t lowBitByte = lowBit / 8;\n  const size_t highBitByte = highBit / 8;\n  jassert(lowBitByte < buffer.getSize());\n  jassert(highBitByte < buffer.getSize());\n  uint8_t data = 0;\n  const size_t shiftOffset = lowBit % 8;\n  uint8_t dataMask = 0;\n  if (bitWidth < 8) {\n    dataMask = (UINT8_C(1) << bitWidth) - 1;\n  } else {\n    dataMask = UINT8_MAX;\n  }\n  // Read from firstByte\n  uint8_t bufferByte = buffer.get()[lowBitByte];\n  data = (bufferByte >> shiftOffset);\n  // If necessary read bits from the subsequent byte if we\n  // are stradling bytes\n  if (highBitByte > lowBitByte) {\n    jassert(shiftOffset > 0);\n    jassert(highBitByte < buffer.getSize());\n    uint8_t nextBufferByte = buffer.get()[highBitByte];\n    data |= (nextBufferByte << (8 - shiftOffset));\n  }\n  data &= dataMask;\n  if (data == 0)\n    return false;\n  return true;\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/Core.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_RUNTIME_SMTLIB_CORE_H\n#define JFS_RUNTIME_SMTLIB_CORE_H\n#include \"BufferRef.h\"\n#include <stdint.h>\n\n// We just use the `bool` type to model SMTLIB semantics\n// The mapping is trivial so we don't provide many runtime\n// functions.\n\nbool makeBoolFrom(BufferRef<const uint8_t> buffer, const uint64_t lowBit,\n                  const uint64_t highBit);\n#endif\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/Float.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n\ntemplate <>\nFloat32 makeFloatFrom(BufferRef<const uint8_t> buffer, uint64_t lowBit,\n                      uint64_t highBit) {\n  jassert((lowBit + 31) == highBit);\n  return jfs_nr_make_float32_from_buffer(buffer.get(), buffer.getSize(),\n                                         lowBit);\n}\n\ntemplate <>\nFloat64 makeFloatFrom(BufferRef<const uint8_t> buffer, uint64_t lowBit,\n                      uint64_t highBit) {\n  jassert((lowBit + 63) == highBit);\n  return jfs_nr_make_float64_from_buffer(buffer.get(), buffer.getSize(),\n                                         lowBit);\n}\n\ntemplate <> Float64 Float32::convertToFloat<11, 53>(JFS_NR_RM rm) const {\n  // No rounding mode needed\n  return jfs_nr_convert_float32_to_float64(data);\n}\n\ntemplate <> Float32 Float32::convertToFloat<8, 24>(JFS_NR_RM rm) const {\n  // No-op\n  return data;\n}\n\ntemplate <> Float32 Float64::convertToFloat<8, 24>(JFS_NR_RM rm) const {\n  return jfs_nr_convert_float64_to_float32(rm, data);\n}\n\ntemplate <> Float64 Float64::convertToFloat<11, 53>(JFS_NR_RM rm) const {\n  // No-op\n  return data;\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/Float.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_RUNTIME_SMTLIB_FLOAT_H\n#define JFS_RUNTIME_SMTLIB_FLOAT_H\n#include \"BitVector.h\"\n#include \"BufferRef.h\"\n#include \"NativeFloat.h\"\n#include <stdint.h>\n#include <type_traits>\n\n// Arbitary precision floating point with\n// EB exponent bits and SB significand bits (includes implicit bit)\n// that mimics the semantics of SMT-LIBv2\n// TODO: Implement genric version\ntemplate <uint64_t EB, uint64_t SB> class Float {};\n\ntypedef Float<8, 24> Float32;\ntypedef Float<11, 53> Float64;\n\n// FIXME: Refactor this so we don't duplicate code\n// Specialize for native types\ntemplate <> class Float<8, 24> {\nprivate:\n  jfs_nr_float32 data;\n\npublic:\n  Float(jfs_nr_float32 value) : data(value) {}\n  Float() : data(0.0f) {}\n  Float(const Float<8, 24>& other) { data = other.data; }\n  Float(BitVector<1> sign, BitVector<8> exponent, BitVector<23> significand) {\n    data = jfs_nr_make_float32_from_triple(sign.data, exponent.data,\n                                           significand.data);\n  }\n  Float(const BitVector<32> bits)\n      : data(jfs_nr_bitcast_bv_to_float32(bits.data)) {}\n\n  // Conversion\n  template <uint64_t NEW_EB, uint64_t NEW_SB>\n  Float<NEW_EB, NEW_SB> convertToFloat(JFS_NR_RM rm) const;\n\n  // TODO: Need to support non native BitVector\n  template <uint64_t BVWIDTH,\n            typename = typename std::enable_if<\n                (BVWIDTH <= JFS_NR_BITVECTOR_TY_BITWIDTH)>::type>\n  static Float32 convertFromUnsignedBV(JFS_NR_RM rm,\n                                       const BitVector<BVWIDTH> bvValue) {\n    return jfs_nr_convert_from_unsigned_bv_to_float32(rm, bvValue.data,\n                                                      BVWIDTH);\n  }\n  template <uint64_t BVWIDTH,\n            typename = typename std::enable_if<\n                (BVWIDTH <= JFS_NR_BITVECTOR_TY_BITWIDTH)>::type>\n  static Float32 convertFromSignedBV(JFS_NR_RM rm,\n                                     const BitVector<BVWIDTH> bvValue) {\n    return jfs_nr_convert_from_signed_bv_to_float32(rm, bvValue.data, BVWIDTH);\n  }\n  template <uint64_t BVWIDTH,\n            typename = typename std::enable_if<\n                (BVWIDTH <= JFS_NR_BITVECTOR_TY_BITWIDTH)>::type>\n  BitVector<BVWIDTH> convertToUnsignedBV(JFS_NR_RM rm) const {\n    return BitVector<BVWIDTH>(\n        jfs_nr_float32_convert_to_unsigned_bv(rm, data, BVWIDTH));\n  }\n  template <uint64_t BVWIDTH,\n            typename = typename std::enable_if<\n                (BVWIDTH <= JFS_NR_BITVECTOR_TY_BITWIDTH)>::type>\n  BitVector<BVWIDTH> convertToSignedBV(JFS_NR_RM rm) const {\n    return BitVector<BVWIDTH>(\n        jfs_nr_float32_convert_to_signed_bv(rm, data, BVWIDTH));\n  }\n\n  // Special constants\n  static Float32 getPositiveInfinity() {\n    return jfs_nr_float32_get_infinity(true);\n  }\n  static Float32 getNegativeInfinity() {\n    return jfs_nr_float32_get_infinity(false);\n  }\n  static Float32 getPositiveZero() { return jfs_nr_float32_get_zero(true); }\n  static Float32 getNegativeZero() { return jfs_nr_float32_get_zero(false); }\n  static Float32 getNaN() { return jfs_nr_float32_get_nan(true); }\n\n  // SMT-LIBv2 bit comparison\n  bool operator==(const Float32& other) const {\n    return jfs_nr_float32_smtlib_equals(data, other.data);\n  }\n\n  bool ieeeEquals(const Float32& other) const {\n    return jfs_nr_float32_ieee_equals(data, other.data);\n  }\n\n  bool fplt(const Float32& other) const {\n    return jfs_nr_float32_lt(data, other.data);\n  }\n  bool fpleq(const Float32& other) const {\n    return jfs_nr_float32_leq(data, other.data);\n  }\n  bool fpgt(const Float32& other) const {\n    return jfs_nr_float32_gt(data, other.data);\n  }\n  bool fpgeq(const Float32& other) const {\n    return jfs_nr_float32_geq(data, other.data);\n  }\n\n  // Arithmetic\n  Float32 abs() const { return jfs_nr_float32_abs(data); }\n  Float32 neg() const { return jfs_nr_float32_neg(data); }\n  Float32 add(JFS_NR_RM rm, const Float32& other) const {\n    return jfs_nr_float32_add(rm, data, other.data);\n  };\n  Float32 sub(JFS_NR_RM rm, const Float32& other) const {\n    return jfs_nr_float32_sub(rm, data, other.data);\n  };\n  Float32 mul(JFS_NR_RM rm, const Float32& other) const {\n    return jfs_nr_float32_mul(rm, data, other.data);\n  };\n  Float32 div(JFS_NR_RM rm, const Float32& other) const {\n    return jfs_nr_float32_div(rm, data, other.data);\n  };\n  Float32 fma(JFS_NR_RM rm, const Float32& b, const Float32& c) const {\n    return jfs_nr_float32_fma(rm, data, b.data, c.data);\n  };\n  Float32 sqrt(JFS_NR_RM rm) const { return jfs_nr_float32_sqrt(rm, data); }\n  Float32 rem(const Float32& other) const {\n    return jfs_nr_float32_rem(data, other.data);\n  };\n  Float32 roundToIntegral(JFS_NR_RM rm) const {\n    return jfs_nr_float32_round_to_integral(rm, data);\n  }\n  Float32 min(const Float32& other) const {\n    return jfs_nr_float32_min(data, other.data);\n  }\n  Float32 max(const Float32& other) const {\n    return jfs_nr_float32_max(data, other.data);\n  }\n\n  // Prediactes\n  bool isNormal() const { return jfs_nr_float32_is_normal(data); }\n  bool isSubnormal() const { return jfs_nr_float32_is_subnormal(data); }\n  bool isZero() const { return jfs_nr_float32_is_zero(data); }\n  bool isInfinite() const { return jfs_nr_float32_is_infinite(data); }\n  bool isPositive() const { return jfs_nr_float32_is_positive(data); }\n  bool isNegative() const { return jfs_nr_float32_is_negative(data); }\n  bool isNaN() const { return jfs_nr_float32_is_nan(data); }\n\n  // For testing\n  uint32_t getRawBits() const { return jfs_nr_float32_get_raw_bits(data); }\n  jfs_nr_float32 getRawData() const { return data; }\n};\n\ntemplate <> class Float<11, 53> {\nprivate:\n  jfs_nr_float64 data;\n\npublic:\n  Float(jfs_nr_float64 value) : data(value) {}\n  Float() : data(0.0) {}\n  Float(const Float<11, 53>& other) { data = other.data; }\n  Float(BitVector<1> sign, BitVector<11> exponent, BitVector<52> significand) {\n    data = jfs_nr_make_float64_from_triple(sign.data, exponent.data,\n                                           significand.data);\n  }\n  Float(const BitVector<64> bits)\n      : data(jfs_nr_bitcast_bv_to_float64(bits.data)) {}\n\n  // Conversion\n  template <uint64_t NEW_EB, uint64_t NEW_SB>\n  Float<NEW_EB, NEW_SB> convertToFloat(JFS_NR_RM rm) const;\n\n  // TODO: Need to support non native BitVector\n  template <uint64_t BVWIDTH,\n            typename = typename std::enable_if<\n                (BVWIDTH <= JFS_NR_BITVECTOR_TY_BITWIDTH)>::type>\n  static Float64 convertFromUnsignedBV(JFS_NR_RM rm,\n                                       const BitVector<BVWIDTH> bvValue) {\n    return jfs_nr_convert_from_unsigned_bv_to_float64(rm, bvValue.data,\n                                                      BVWIDTH);\n  }\n  template <uint64_t BVWIDTH,\n            typename = typename std::enable_if<\n                (BVWIDTH <= JFS_NR_BITVECTOR_TY_BITWIDTH)>::type>\n  static Float64 convertFromSignedBV(JFS_NR_RM rm,\n                                     const BitVector<BVWIDTH> bvValue) {\n    return jfs_nr_convert_from_signed_bv_to_float64(rm, bvValue.data, BVWIDTH);\n  }\n  template <uint64_t BVWIDTH,\n            typename = typename std::enable_if<\n                (BVWIDTH <= JFS_NR_BITVECTOR_TY_BITWIDTH)>::type>\n  BitVector<BVWIDTH> convertToUnsignedBV(JFS_NR_RM rm) const {\n    return BitVector<BVWIDTH>(\n        jfs_nr_float64_convert_to_unsigned_bv(rm, data, BVWIDTH));\n  }\n  template <uint64_t BVWIDTH,\n            typename = typename std::enable_if<\n                (BVWIDTH <= JFS_NR_BITVECTOR_TY_BITWIDTH)>::type>\n  BitVector<BVWIDTH> convertToSignedBV(JFS_NR_RM rm) const {\n    return BitVector<BVWIDTH>(\n        jfs_nr_float64_convert_to_signed_bv(rm, data, BVWIDTH));\n  }\n\n  // Special constants\n  static Float64 getPositiveInfinity() {\n    return jfs_nr_float64_get_infinity(true);\n  }\n  static Float64 getNegativeInfinity() {\n    return jfs_nr_float64_get_infinity(false);\n  }\n  static Float64 getPositiveZero() { return jfs_nr_float64_get_zero(true); }\n  static Float64 getNegativeZero() { return jfs_nr_float64_get_zero(false); }\n  static Float64 getNaN() { return jfs_nr_float64_get_nan(true); }\n\n  // SMT-LIBv2 bit comparison\n  bool operator==(const Float64& other) const {\n    return jfs_nr_float64_smtlib_equals(data, other.data);\n  }\n\n  bool ieeeEquals(const Float64& other) const {\n    return jfs_nr_float64_ieee_equals(data, other.data);\n  }\n\n  bool fplt(const Float64& other) const {\n    return jfs_nr_float64_lt(data, other.data);\n  }\n  bool fpleq(const Float64& other) const {\n    return jfs_nr_float64_leq(data, other.data);\n  }\n  bool fpgt(const Float64& other) const {\n    return jfs_nr_float64_gt(data, other.data);\n  }\n  bool fpgeq(const Float64& other) const {\n    return jfs_nr_float64_geq(data, other.data);\n  }\n\n  // Arithmetic\n  Float64 abs() const { return jfs_nr_float64_abs(data); }\n  Float64 neg() const { return jfs_nr_float64_neg(data); }\n  Float64 add(JFS_NR_RM rm, const Float64& other) const {\n    return jfs_nr_float64_add(rm, data, other.data);\n  };\n  Float64 sub(JFS_NR_RM rm, const Float64& other) const {\n    return jfs_nr_float64_sub(rm, data, other.data);\n  };\n  Float64 mul(JFS_NR_RM rm, const Float64& other) const {\n    return jfs_nr_float64_mul(rm, data, other.data);\n  };\n  Float64 div(JFS_NR_RM rm, const Float64& other) const {\n    return jfs_nr_float64_div(rm, data, other.data);\n  };\n  Float64 fma(JFS_NR_RM rm, const Float64& b, const Float64& c) const {\n    return jfs_nr_float64_fma(rm, data, b.data, c.data);\n  };\n  Float64 sqrt(JFS_NR_RM rm) const { return jfs_nr_float64_sqrt(rm, data); }\n  Float64 rem(const Float64& other) const {\n    return jfs_nr_float64_rem(data, other.data);\n  };\n  Float64 roundToIntegral(JFS_NR_RM rm) const {\n    return jfs_nr_float64_round_to_integral(rm, data);\n  }\n  Float64 min(const Float64& other) const {\n    return jfs_nr_float64_min(data, other.data);\n  }\n  Float64 max(const Float64& other) const {\n    return jfs_nr_float64_max(data, other.data);\n  }\n\n  // Predicates\n  bool isNormal() const { return jfs_nr_float64_is_normal(data); }\n  bool isSubnormal() const { return jfs_nr_float64_is_subnormal(data); }\n  bool isZero() const { return jfs_nr_float64_is_zero(data); }\n  bool isInfinite() const { return jfs_nr_float64_is_infinite(data); }\n  bool isPositive() const { return jfs_nr_float64_is_positive(data); }\n  bool isNegative() const { return jfs_nr_float64_is_negative(data); }\n  bool isNaN() const { return jfs_nr_float64_is_nan(data); }\n\n  // For testing\n  uint64_t getRawBits() const { return jfs_nr_float64_get_raw_bits(data); }\n  jfs_nr_float64 getRawData() const { return data; }\n};\n\ntemplate <uint64_t EB, uint64_t SB>\nFloat<EB, SB> makeFloatFrom(BufferRef<const uint8_t> buffer, uint64_t lowBit,\n                            uint64_t highBit);\n\n// Specialize for Float32\ntemplate <>\nFloat32 makeFloatFrom(BufferRef<const uint8_t> buffer, uint64_t lowBit,\n                      uint64_t highBit);\n\n// Specialize for Float64\ntemplate <>\nFloat64 makeFloatFrom(BufferRef<const uint8_t> buffer, uint64_t lowBit,\n                      uint64_t highBit);\n#endif\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/Logger.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"Logger.h\"\n#include \"jassert.h\"\n#include <cstdio>\n#include <cstdlib>\n#include <inttypes.h>\n#include <string>\n#include <unordered_map>\n\nnamespace {\n\nclass LoggerImpl {\nprivate:\n  std::string logPath;\n  std::unordered_map<const char*, uint64_t> stats;\n\npublic:\n  LoggerImpl(const char* path) : logPath(path) {}\n  ~LoggerImpl() {\n    // Log stats to file.\n    // TODO: Rewrite using std classes\n    FILE* f = fopen(logPath.c_str(), /*mode=*/\"w\");\n    if (f == NULL) {\n      JFS_RUNTIME_FAIL_WITH_REASON(\"Failed to open log file\");\n    }\n    for (const auto& pair : stats) {\n      fprintf(f, \"%s: %\" PRIu64 \"\\n\", pair.first, pair.second);\n    }\n    fclose(f);\n  }\n  void log_uint64(const char* name, uint64_t value) {\n    jassert(name != nullptr);\n    stats[name] = value;\n  }\n};\n\n} // namespace\n\nextern \"C\" {\njfs_nr_logger_ty jfs_nr_mk_logger(const char* path) {\n  LoggerImpl* l = new LoggerImpl(path);\n  return reinterpret_cast<jfs_nr_logger_ty>(l);\n}\n\njfs_nr_logger_ty jfs_nr_mk_logger_from_env() {\n  const char* path = getenv(\"JFS_RUNTIME_LOG_PATH\");\n  if (path == nullptr) {\n    JFS_RUNTIME_FAIL_WITH_REASON(\n        \"Failed to get log file path from JFS_RUNTIME_LOG_PATH \"\n        \"environment variable\\n\");\n  }\n  return jfs_nr_mk_logger(path);\n}\n\nvoid jfs_nr_log_uint64(jfs_nr_logger_ty logger, const char* name,\n                       uint64_t value) {\n  LoggerImpl* l = (LoggerImpl*)logger;\n  l->log_uint64(name, value);\n}\n\nvoid jfs_nr_del_logger(jfs_nr_logger_ty logger) {\n  LoggerImpl* l = (LoggerImpl*)logger;\n  delete l;\n}\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/Logger.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_RUNTIME_STAT_LOG_LOGGER_H\n#define JFS_RUNTIME_STAT_LOG_LOGGER_H\n#include <stdint.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef void* jfs_nr_logger_ty;\n\njfs_nr_logger_ty jfs_nr_mk_logger(const char* path);\njfs_nr_logger_ty jfs_nr_mk_logger_from_env();\n\n// NOTE: `name` is not stored so this memory must remained unmodified.\nvoid jfs_nr_log_uint64(jfs_nr_logger_ty logger, const char* name,\n                       uint64_t value);\n\nvoid jfs_nr_del_logger(jfs_nr_logger_ty logger);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/Messages.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"Messages.h\"\n#include <stdarg.h>\n#include <stdio.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n// Right now these are just a thin wrappers around fprintf.  In the future\n// though we could log the messages to a file.\n\nvoid jfs_info(const char* fmt, ...) {\n  va_list args;\n  va_start(args, fmt);\n  fprintf(stderr, \"JFS INFO: \");\n  vfprintf(stderr, fmt, args);\n  va_end(args);\n}\n\nvoid jfs_warning(const char* fmt, ...) {\n  va_list args;\n  va_start(args, fmt);\n  fprintf(stderr, \"JFS WARNING: \");\n  vfprintf(stderr, fmt, args);\n  va_end(args);\n}\n\n#ifdef __cplusplus\n}\n#endif\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/Messages.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_RUNTIME_MESSAGES_H\n#define JFS_RUNTIME_MESSAGES_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define JFS_PRINTF_ATRRIBUTE __attribute__((format(printf, 1, 2)))\n\nvoid jfs_info(const char* fmt, ...) JFS_PRINTF_ATRRIBUTE;\nvoid jfs_warning(const char* fmt, ...) JFS_PRINTF_ATRRIBUTE;\n\n#undef JFS_PRINTF_ATRRIBUTE\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/NativeBitVector.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n// This is the implemenation of the runtime for SMTLIB BitVectors that\n// uses native machine operations. It is written with a C compatible interface\n// so that in the future we can easily use LLVM's JIT.\n\n#include \"SMTLIB/NativeBitVector.h\"\n#include \"SMTLIB/jassert.h\"\n\n// Helper constants/functions\nnamespace {\n\nconst jfs_nr_width_ty jfs_nr_bitvector_ty_bit_width =\n    sizeof(jfs_nr_bitvector_ty) * 8;\n\njfs_nr_bitvector_ty jfs_nr_get_bitvector_mask(const jfs_nr_width_ty bitWidth) {\n  static_assert(jfs_nr_bitvector_ty_bit_width <= 64, \"Wrong width\");\n  jassert(bitWidth <= jfs_nr_bitvector_ty_bit_width);\n  return (bitWidth >= jfs_nr_bitvector_ty_bit_width)\n             ? UINT64_MAX\n             : ((UINT64_C(1) << bitWidth) - 1);\n}\n\n\njfs_nr_bitvector_ty\njfs_nr_get_most_signficiant_bit_mask(const jfs_nr_width_ty bitWidth) {\n  jassert(bitWidth <= jfs_nr_bitvector_ty_bit_width);\n  return (UINT64_C(1) << (bitWidth - 1));\n}\n\n}\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n// Public functions\n\njfs_nr_bitvector_ty jfs_nr_get_bitvector_mod(const jfs_nr_bitvector_ty value,\n                                             const jfs_nr_width_ty bitWidth) {\n  static_assert(jfs_nr_bitvector_ty_bit_width <= 64, \"Wrong width\");\n  if (bitWidth >= jfs_nr_bitvector_ty_bit_width) {\n    return value;\n  } else {\n    return value % (UINT64_C(1) << bitWidth);\n  }\n}\n\nbool jfs_nr_is_valid(const jfs_nr_bitvector_ty value,\n                     const jfs_nr_width_ty width) {\n  return jfs_nr_get_bitvector_mod(value, width) == value;\n}\n\njfs_nr_bitvector_ty jfs_nr_concat(const jfs_nr_bitvector_ty lhs,\n                                  const jfs_nr_width_ty lhsBitWidth,\n                                  const jfs_nr_bitvector_ty rhs,\n                                  const jfs_nr_width_ty rhsBitWidth) {\n  jassert(jfs_nr_is_valid(lhs, lhsBitWidth));\n  jassert(jfs_nr_is_valid(rhs, rhsBitWidth));\n  jassert(((lhsBitWidth + rhsBitWidth) <= jfs_nr_bitvector_ty_bit_width) &&\n          \"concat too wide\");\n  jfs_nr_bitvector_ty newValue = rhs;\n  newValue |= (lhs << rhsBitWidth);\n  return newValue;\n}\n\n// Extract bits [highBit, lowBit]\njfs_nr_bitvector_ty jfs_nr_extract(const jfs_nr_bitvector_ty value,\n                                   const jfs_nr_width_ty bitWidth,\n                                   const jfs_nr_width_ty highBit,\n                                   const jfs_nr_width_ty lowBit) {\n  jassert(jfs_nr_is_valid(value, bitWidth));\n  jassert(highBit >= lowBit && \"Invalid highBit and/or lowBit value\");\n  jassert(highBit < bitWidth && \"Invalid highBit bit\");\n  jassert(lowBit < bitWidth && \"Invalid lowBit bit\");\n  const jfs_nr_width_ty newWidth = (highBit - lowBit) + 1;\n  if (newWidth == bitWidth)\n    return value;\n  jfs_nr_bitvector_ty temp = value;\n  // Remove higher bits that we don't want\n  jfs_nr_bitvector_ty mask = jfs_nr_get_bitvector_mask(highBit + 1);\n  temp &= mask;\n\n  // Remove lower bits that we don't want.\n  temp >>= lowBit;\n  jassert(jfs_nr_is_valid(temp, newWidth));\n  return temp;\n}\n\n// Zero extend to bitvector (bitWidth + extraBits) wide\njfs_nr_bitvector_ty jfs_nr_zero_extend(const jfs_nr_bitvector_ty value,\n                                       const jfs_nr_width_ty bitWidth,\n                                       const jfs_nr_width_ty extraBits) {\n  // No really work to do provided internal invariant that unused biits\n  // are zero is maintained.\n  jassert(jfs_nr_is_valid(value, bitWidth));\n  jassert((bitWidth + extraBits) <= jfs_nr_bitvector_ty_bit_width);\n  return value;\n}\n\njfs_nr_bitvector_ty jfs_nr_sign_extend(const jfs_nr_bitvector_ty value,\n                                       const jfs_nr_width_ty bitWidth,\n                                       const jfs_nr_width_ty extraBits) {\n  jassert(jfs_nr_is_valid(value, bitWidth));\n  jassert((bitWidth + extraBits) <= jfs_nr_bitvector_ty_bit_width);\n  if (value & jfs_nr_get_most_signficiant_bit_mask(bitWidth)) {\n    // msb is not zero. Must do sign extend with ones.\n    const jfs_nr_bitvector_ty currentWidthMask =\n        jfs_nr_get_bitvector_mask(bitWidth);\n    const jfs_nr_bitvector_ty newWidthMask =\n        jfs_nr_get_bitvector_mask(bitWidth + extraBits);\n    return (value | (~currentWidthMask)) & newWidthMask;\n  } else {\n    // Just do zero extend\n    return jfs_nr_zero_extend(value, bitWidth, extraBits);\n  }\n}\n\njfs_nr_bitvector_ty jfs_nr_bvneg(const jfs_nr_bitvector_ty value,\n                                 const jfs_nr_width_ty bitWidth) {\n  // [[(bvneg s)]] := nat2bv[m](2^m - bv2nat([[s]]))\n  jassert(jfs_nr_is_valid(value, bitWidth));\n  if (value == 0) {\n    return 0;\n  }\n\n  // In two's complement, flipping bits and adding one negates\n  // the number.\n  return ((~value) & jfs_nr_get_bitvector_mask(bitWidth)) + 1;\n}\n\njfs_nr_bitvector_ty jfs_nr_bvadd(const jfs_nr_bitvector_ty lhs,\n                                 const jfs_nr_bitvector_ty rhs,\n                                 const jfs_nr_width_ty bitWidth) {\n  // [[(bvadd s t)]] := nat2bv[m](bv2nat([[s]]) + bv2nat([[t]]))\n  jassert(jfs_nr_is_valid(lhs, bitWidth));\n  jassert(jfs_nr_is_valid(rhs, bitWidth));\n  return jfs_nr_get_bitvector_mod(lhs + rhs, bitWidth);\n}\n\njfs_nr_bitvector_ty jfs_nr_bvsub(const jfs_nr_bitvector_ty lhs,\n                                 const jfs_nr_bitvector_ty rhs,\n                                 const jfs_nr_width_ty bitWidth) {\n  // (bvsub s t) abbreviates (bvadd s (bvneg t))\n  jassert(jfs_nr_is_valid(lhs, bitWidth));\n  jassert(jfs_nr_is_valid(rhs, bitWidth));\n  // TODO: Verify the implementation is semantically equivalent\n  // to SMT-LIBv2\n  return jfs_nr_get_bitvector_mod(lhs - rhs, bitWidth);\n}\n\njfs_nr_bitvector_ty jfs_nr_bvmul(const jfs_nr_bitvector_ty lhs,\n                                 const jfs_nr_bitvector_ty rhs,\n                                 const jfs_nr_width_ty bitWidth) {\n  // [[(bvmul s t)]] := nat2bv[m](bv2nat([[s]]) * bv2nat([[t]]))\n  jassert(jfs_nr_is_valid(lhs, bitWidth));\n  jassert(jfs_nr_is_valid(rhs, bitWidth));\n  return jfs_nr_get_bitvector_mod(lhs * rhs, bitWidth);\n}\n\njfs_nr_bitvector_ty jfs_nr_bvudiv(const jfs_nr_bitvector_ty dividend,\n                                  const jfs_nr_bitvector_ty divisor,\n                                  const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(dividend, bitWidth));\n  jassert(jfs_nr_is_valid(divisor, bitWidth));\n  //   [[(bvudiv s t)]] := if bv2nat([[t]]) = 0\n  //                       then λx:[0, m). 1\n  //                       else nat2bv[m](bv2nat([[s]]) div bv2nat([[t]]))\n  if (divisor == 0) {\n    return jfs_nr_get_bitvector_mask(bitWidth);\n  }\n  jfs_nr_bitvector_ty result = dividend / divisor;\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_bvurem(const jfs_nr_bitvector_ty dividend,\n                                  const jfs_nr_bitvector_ty divisor,\n                                  const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(dividend, bitWidth));\n  jassert(jfs_nr_is_valid(divisor, bitWidth));\n  //  [[(bvurem s t)]] := if bv2nat([[t]]) = 0\n  //                      then [[s]]\n  //                      else nat2bv[m](bv2nat([[s]]) rem bv2nat([[t]]))\n  jfs_nr_bitvector_ty result = 0;\n  if (divisor == 0) {\n    result = dividend;\n  } else {\n    result = dividend % divisor;\n  }\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_bvsdiv(const jfs_nr_bitvector_ty dividend,\n                                  const jfs_nr_bitvector_ty divisor,\n                                  const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(dividend, bitWidth));\n  jassert(jfs_nr_is_valid(divisor, bitWidth));\n  // (bvsdiv s t) abbreviates\n  //  (let ((?msb_s ((_ extract |m-1| |m-1|) s))\n  //        (?msb_t ((_ extract |m-1| |m-1|) t)))\n  //    (ite (and (= ?msb_s #b0) (= ?msb_t #b0))\n  //         (bvudiv s t)\n  //    (ite (and (= ?msb_s #b1) (= ?msb_t #b0))\n  //         (bvneg (bvudiv (bvneg s) t))\n  //    (ite (and (= ?msb_s #b0) (= ?msb_t #b1))\n  //         (bvneg (bvudiv s (bvneg t)))\n  //         (bvudiv (bvneg s) (bvneg t))))))\n  const jfs_nr_bitvector_ty msbMask =\n      jfs_nr_get_most_signficiant_bit_mask(bitWidth);\n  bool msb_s = dividend & msbMask;\n  bool msb_t = divisor & msbMask;\n  jfs_nr_bitvector_ty result = 0;\n  // TODO: Can we write this more efficiently?\n  if (!msb_s && !msb_t) {\n    // Both operands are postive in two's complement\n    result = jfs_nr_bvudiv(dividend, divisor, bitWidth);\n  } else if (msb_s && !msb_t) {\n    // lhs is negative and rhs is positive in two's complement\n    result = jfs_nr_bvneg(\n        jfs_nr_bvudiv(jfs_nr_bvneg(dividend, bitWidth), divisor, bitWidth),\n        bitWidth);\n  } else if (!msb_s && msb_t) {\n    // lhs is positive and rhs is negative in two's complement\n    result = jfs_nr_bvneg(\n        jfs_nr_bvudiv(dividend, jfs_nr_bvneg(divisor, bitWidth), bitWidth),\n        bitWidth);\n  } else {\n    // Both operands are negative in two's complement\n    result = jfs_nr_bvudiv(jfs_nr_bvneg(dividend, bitWidth),\n                           jfs_nr_bvneg(divisor, bitWidth), bitWidth);\n  }\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_bvsrem(const jfs_nr_bitvector_ty dividend,\n                                  const jfs_nr_bitvector_ty divisor,\n                                  const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(dividend, bitWidth));\n  jassert(jfs_nr_is_valid(divisor, bitWidth));\n  // 2's complement signed remainder (sign follows dividend)\n  // (bvsrem s t) abbreviates\n  //  (let ((?msb_s ((_ extract |m-1| |m-1|) s))\n  //        (?msb_t ((_ extract |m-1| |m-1|) t)))\n  //    (ite (and (= ?msb_s #b0) (= ?msb_t #b0))\n  //         (bvurem s t)\n  //    (ite (and (= ?msb_s #b1) (= ?msb_t #b0))\n  //         (bvneg (bvurem (bvneg s) t))\n  //    (ite (and (= ?msb_s #b0) (= ?msb_t #b1))\n  //         (bvurem s (bvneg t)))\n  //         (bvneg (bvurem (bvneg s) (bvneg t))))))\n  const jfs_nr_bitvector_ty msbMask =\n      jfs_nr_get_most_signficiant_bit_mask(bitWidth);\n  bool msb_s = dividend & msbMask;\n  bool msb_t = divisor & msbMask;\n  jfs_nr_bitvector_ty result = 0;\n  // TODO: Can we write this more efficiently?\n  if (!msb_s && !msb_t) {\n    // Both operands are postive in two's complement\n    result = jfs_nr_bvurem(dividend, divisor, bitWidth);\n  } else if (msb_s && !msb_t) {\n    // lhs is negative and rhs is positive in two's complement\n    result = jfs_nr_bvneg(\n        jfs_nr_bvurem(jfs_nr_bvneg(dividend, bitWidth), divisor, bitWidth),\n        bitWidth);\n  } else if (!msb_s && msb_t) {\n    // lhs is positive and rhs is negative in two's complement\n    result = jfs_nr_bvurem(dividend, jfs_nr_bvneg(divisor, bitWidth), bitWidth);\n  } else {\n    // Both operands are negative in two's complement\n    result =\n        jfs_nr_bvneg(jfs_nr_bvurem(jfs_nr_bvneg(dividend, bitWidth),\n                                   jfs_nr_bvneg(divisor, bitWidth), bitWidth),\n                     bitWidth);\n  }\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_bvsmod(const jfs_nr_bitvector_ty dividend,\n                                  const jfs_nr_bitvector_ty divisor,\n                                  const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(dividend, bitWidth));\n  jassert(jfs_nr_is_valid(divisor, bitWidth));\n  // 2's complement signed remainder (sign follows divisor)\n  // (bvsmod s t) abbreviates\n  //  (let ((?msb_s ((_ extract |m-1| |m-1|) s))\n  //        (?msb_t ((_ extract |m-1| |m-1|) t)))\n  //    (let ((abs_s (ite (= ?msb_s #b0) s (bvneg s)))\n  //          (abs_t (ite (= ?msb_t #b0) t (bvneg t))))\n  //      (let ((u (bvurem abs_s abs_t)))\n  //        (ite (= u (_ bv0 m))\n  //             u\n  //        (ite (and (= ?msb_s #b0) (= ?msb_t #b0))\n  //             u\n  //        (ite (and (= ?msb_s #b1) (= ?msb_t #b0))\n  //             (bvadd (bvneg u) t)\n  //        (ite (and (= ?msb_s #b0) (= ?msb_t #b1))\n  //             (bvadd u t)\n  //             (bvneg u))))))))\n  // TODO: Can we write this more efficiently?\n  const jfs_nr_bitvector_ty msbMask =\n      jfs_nr_get_most_signficiant_bit_mask(bitWidth);\n  bool msb_s = dividend & msbMask;\n  bool msb_t = divisor & msbMask;\n  jfs_nr_bitvector_ty abs_s =\n      msb_s ? jfs_nr_bvneg(dividend, bitWidth) : dividend;\n  jfs_nr_bitvector_ty abs_t = msb_t ? jfs_nr_bvneg(divisor, bitWidth) : divisor;\n  jfs_nr_bitvector_ty u = jfs_nr_bvurem(abs_s, abs_t, bitWidth);\n  jfs_nr_bitvector_ty result = 0;\n  if (u == 0) {\n    result = u;\n  } else if (!msb_s && !msb_t) {\n    // Both operands are postive in two's complement\n    result = u;\n  } else if (msb_s && !msb_t) {\n    // lhs is negative and rhs is positive in two's complement\n    result = jfs_nr_bvadd(jfs_nr_bvneg(u, bitWidth), divisor, bitWidth);\n  } else if (!msb_s && msb_t) {\n    // lhs is positive and rhs is negative in two's complement\n    result = jfs_nr_bvadd(u, divisor, bitWidth);\n  } else {\n    // Both operands are negative in two's complement\n    result = jfs_nr_bvneg(u, bitWidth);\n  }\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_bvshl(const jfs_nr_bitvector_ty value,\n                                 const jfs_nr_bitvector_ty shift,\n                                 const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(value, bitWidth));\n  jassert(jfs_nr_is_valid(shift, bitWidth));\n  //  [[(bvshl s t)]] := nat2bv[m](bv2nat([[s]]) * 2^(bv2nat([[t]])))\n  jfs_nr_bitvector_ty result = 0;\n  if (shift >= bitWidth) {\n    // Overshift to zero\n    result = 0;\n  } else {\n    result = jfs_nr_get_bitvector_mod(value << shift, bitWidth);\n  }\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_bvlshr(const jfs_nr_bitvector_ty value,\n                                  const jfs_nr_bitvector_ty shift,\n                                  const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(value, bitWidth));\n  jassert(jfs_nr_is_valid(shift, bitWidth));\n  // [[(bvlshr s t)]] := nat2bv[m](bv2nat([[s]]) div 2^(bv2nat([[t]])))\n  jfs_nr_bitvector_ty result = 0;\n  if (shift >= bitWidth) {\n    // Overshift to zero\n    result = 0;\n  } else {\n    result = jfs_nr_get_bitvector_mod(value >> shift, bitWidth);\n  }\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_bvashr(const jfs_nr_bitvector_ty value,\n                                  const jfs_nr_bitvector_ty shift,\n                                  const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(value, bitWidth));\n  jassert(jfs_nr_is_valid(shift, bitWidth));\n  // (bvashr s t) abbreviates\n  //  (ite (= ((_ extract |m-1| |m-1|) s) #b0)\n  //       (bvlshr s t)\n  //       (bvnot (bvlshr (bvnot s) t)))\n  // TODO: Can we do this more efficiently?\n  bool lhsNeg = value & jfs_nr_get_most_signficiant_bit_mask(bitWidth);\n  jfs_nr_bitvector_ty result = 0;\n  if (!lhsNeg) {\n    result = jfs_nr_bvlshr(value, shift, bitWidth);\n  } else {\n    result = jfs_nr_bvnot(\n        jfs_nr_bvlshr(jfs_nr_bvnot(value, bitWidth), shift, bitWidth),\n        bitWidth);\n  }\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_rotate_left(const jfs_nr_bitvector_ty value,\n                                       const jfs_nr_width_ty shift,\n                                       const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(value, bitWidth));\n  // ((_ rotate_left 0) t) stands for t\n  // ((_ rotate_left i) t) abbreviates t if m = 1, and\n  //   ((_ rotate_left |i-1|)\n  //     (concat ((_ extract |m-2| 0) t) ((_ extract |m-1| |m-1|) t))\n  //   otherwise\n  jfs_nr_bitvector_ty effective_shift = shift % bitWidth;\n  // Shift bits to the left\n  jassert(effective_shift < jfs_nr_bitvector_ty_bit_width);\n  jfs_nr_bitvector_ty result = value << effective_shift;\n  // bitwise or with the bits that got shifted out and\n  // should now appear in the lsb.\n  jassert((bitWidth - effective_shift) < jfs_nr_bitvector_ty_bit_width);\n  result |= value >> (bitWidth - effective_shift);\n  result &= jfs_nr_get_bitvector_mask(bitWidth);\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_rotate_right(const jfs_nr_bitvector_ty value,\n                                        const jfs_nr_width_ty shift,\n                                        const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(value, bitWidth));\n  // ((_ rotate_right 0) t) stands for t\n  // ((_ rotate_right i) t) abbreviates t if m = 1, and\n  //   ((_ rotate_right |i-1|)\n  //     (concat ((_ extract 0 0) t) ((_ extract |m-1| 1) t)))\n  //   otherwise\n  jfs_nr_bitvector_ty effective_shift = shift % bitWidth;\n  // Shift bits to the right\n  jassert(effective_shift < jfs_nr_bitvector_ty_bit_width);\n  jfs_nr_bitvector_ty result = value >> effective_shift;\n  // bitwise or with the bits that got shifted out and\n  // should now appear in the msb.\n  jassert((bitWidth - effective_shift) < jfs_nr_bitvector_ty_bit_width);\n  result |= value << (bitWidth - effective_shift);\n  result &= jfs_nr_get_bitvector_mask(bitWidth);\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_bvand(const jfs_nr_bitvector_ty lhs,\n                                 const jfs_nr_bitvector_ty rhs,\n                                 const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(lhs, bitWidth));\n  jassert(jfs_nr_is_valid(rhs, bitWidth));\n  jfs_nr_bitvector_ty result = lhs & rhs;\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_bvor(const jfs_nr_bitvector_ty lhs,\n                                const jfs_nr_bitvector_ty rhs,\n                                const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(lhs, bitWidth));\n  jassert(jfs_nr_is_valid(rhs, bitWidth));\n  jfs_nr_bitvector_ty result = lhs | rhs;\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_bvnand(const jfs_nr_bitvector_ty lhs,\n                                  const jfs_nr_bitvector_ty rhs,\n                                  const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(lhs, bitWidth));\n  jassert(jfs_nr_is_valid(rhs, bitWidth));\n  jfs_nr_bitvector_ty result =\n      (~(lhs & rhs)) & jfs_nr_get_bitvector_mask(bitWidth);\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_bvnor(const jfs_nr_bitvector_ty lhs,\n                                 const jfs_nr_bitvector_ty rhs,\n                                 const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(lhs, bitWidth));\n  jassert(jfs_nr_is_valid(rhs, bitWidth));\n  jfs_nr_bitvector_ty result =\n      (~(lhs | rhs)) & jfs_nr_get_bitvector_mask(bitWidth);\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_bvxor(const jfs_nr_bitvector_ty lhs,\n                                 const jfs_nr_bitvector_ty rhs,\n                                 const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(lhs, bitWidth));\n  jassert(jfs_nr_is_valid(rhs, bitWidth));\n  jfs_nr_bitvector_ty result =\n      (lhs ^ rhs) & jfs_nr_get_bitvector_mask(bitWidth);\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_bvxnor(const jfs_nr_bitvector_ty lhs,\n                                  const jfs_nr_bitvector_ty rhs,\n                                  const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(lhs, bitWidth));\n  jassert(jfs_nr_is_valid(rhs, bitWidth));\n  jfs_nr_bitvector_ty result =\n      (~(lhs ^ rhs)) & jfs_nr_get_bitvector_mask(bitWidth);\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\njfs_nr_bitvector_ty jfs_nr_bvnot(const jfs_nr_bitvector_ty value,\n                                 const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(value, bitWidth));\n  jfs_nr_bitvector_ty result = (~value) & jfs_nr_get_bitvector_mask(bitWidth);\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\nbool jfs_nr_bvult(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(lhs, bitWidth));\n  jassert(jfs_nr_is_valid(rhs, bitWidth));\n  return lhs < rhs;\n}\n\nbool jfs_nr_bvule(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(lhs, bitWidth));\n  jassert(jfs_nr_is_valid(rhs, bitWidth));\n  return lhs <= rhs;\n}\n\nbool jfs_nr_bvugt(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(lhs, bitWidth));\n  jassert(jfs_nr_is_valid(rhs, bitWidth));\n  return lhs > rhs;\n}\n\nbool jfs_nr_bvuge(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(lhs, bitWidth));\n  jassert(jfs_nr_is_valid(rhs, bitWidth));\n  return lhs >= rhs;\n}\n\nbool jfs_nr_bvslt(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(lhs, bitWidth));\n  jassert(jfs_nr_is_valid(rhs, bitWidth));\n  // (bvslt s t) abbreviates:\n  //  (or (and (= ((_ extract |m-1| |m-1|) s) #b1)\n  //           (= ((_ extract |m-1| |m-1|) t) #b0))\n  //      (and (= ((_ extract |m-1| |m-1|) s) ((_ extract |m-1| |m-1|) t))\n  //           (bvult s t)))\n  bool lhsNeg = lhs & jfs_nr_get_most_signficiant_bit_mask(bitWidth);\n  bool rhsNeg = rhs & jfs_nr_get_most_signficiant_bit_mask(bitWidth);\n  if (lhsNeg && !rhsNeg) {\n    return true;\n  }\n  return (lhsNeg == rhsNeg) && jfs_nr_bvult(lhs, rhs, bitWidth);\n}\n\nbool jfs_nr_bvsle(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(lhs, bitWidth));\n  jassert(jfs_nr_is_valid(rhs, bitWidth));\n  // (bvsle s t) abbreviates:\n  //  (or (and (= ((_ extract |m-1| |m-1|) s) #b1)\n  //           (= ((_ extract |m-1| |m-1|) t) #b0))\n  //      (and (= ((_ extract |m-1| |m-1|) s) ((_ extract |m-1| |m-1|) t))\n  //           (bvule s t)))\n  bool lhsNeg = lhs & jfs_nr_get_most_signficiant_bit_mask(bitWidth);\n  bool rhsNeg = rhs & jfs_nr_get_most_signficiant_bit_mask(bitWidth);\n  if (lhsNeg && !rhsNeg) {\n    return true;\n  }\n  return (lhsNeg == rhsNeg) && jfs_nr_bvule(lhs, rhs, bitWidth);\n}\n\nbool jfs_nr_bvsgt(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth) {\n  // (bvsgt s t) abbreviates (bvslt t s)\n  return jfs_nr_bvslt(rhs, lhs, bitWidth);\n}\n\nbool jfs_nr_bvsge(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth) {\n  // (bvsge s t) abbreviates (bvsle t s)\n  return jfs_nr_bvsle(rhs, lhs, bitWidth);\n}\n\n// FIXME: We should either handle byte aligned access specially, or provide\n// another function for this.\n// Convenience function for creating a BitVector\n// from any arbitrary bit offset in a buffer. Offset\n// is [lowbit, highbit].\njfs_nr_bitvector_ty jfs_nr_make_bitvector(const uint8_t* bufferData,\n                                          const uint64_t bufferSize,\n                                          const uint64_t lowBit,\n                                          const uint64_t highBit) {\n  jassert(highBit >= lowBit && \"invalid lowBit and highBit\");\n  jassert(highBit < (bufferSize * 8));\n  const uint64_t bitWidth = ((highBit - lowBit) + 1);\n  const size_t lowBitByte = lowBit / 8;\n  const size_t shiftOffset = lowBit % 8;\n  // NOTE: doing `highBit / 8` to compute `highBitByte` is wrong. For [1,8]\n  // that gives a highBit of 1 which is wrong for the loop below (should be 0).\n  // const size_t highBitByte = (lowBitByte + ((BITWIDTH + 7) / 8)) - 1;\n  const size_t highBitByte = (lowBitByte + (((highBit - lowBit) + 8) / 8)) - 1;\n  jassert(lowBitByte < bufferSize);\n  jassert(highBitByte < bufferSize);\n  jfs_nr_bitvector_ty data = 0;\n  uint8_t* dataView = reinterpret_cast<uint8_t*>(&data);\n  jfs_nr_bitvector_ty dataMask = jfs_nr_get_bitvector_mask(bitWidth);\n  // Copy byte-by-byte shifting if necessary\n  for (size_t index = lowBitByte; index <= highBitByte; ++index) {\n    const size_t viewIndex = index - lowBitByte;\n    jassert(index < bufferSize);\n    jassert(viewIndex < sizeof(data));\n    uint8_t bufferByte = bufferData[index];\n    dataView[viewIndex] |= (bufferByte >> shiftOffset);\n    if (shiftOffset == 0) {\n      // If there is no shift offset then we didn't shift any bits\n      // out.\n      continue;\n    }\n    // Doing the shift means we have zero bits in MSB rather than the actually\n    // bits we want.\n    uint8_t nextIterByteValue = 0;\n    if ((index + 1) < bufferSize) {\n      // Avoid out of bounds access\n      nextIterByteValue = bufferData[index + 1];\n    }\n    dataView[viewIndex] |= (nextIterByteValue << (8 - shiftOffset));\n  }\n  // Now mask off the data\n  data &= dataMask;\n  return data;\n}\n\nvoid jfs_nr_write_bitvector(const jfs_nr_bitvector_ty bv,\n                            const jfs_nr_width_ty bitWidth,\n                            uint8_t* bufferData,\n                            const uint64_t bufferSize,\n                            const uint64_t bitOffset) {\n  // Copy the bit vector so we can shift bits off as we go.\n  // TODO: Or just mark it not const in the params...?\n  // FIXME: Rework this algorithm to avoid the copy and shifting here if it\n  // appears to be a bottleneck. (It seems okay since bit vectors are a small,\n  // fixed size.)\n  jfs_nr_bitvector_ty tempBv = bv;\n  jassert(jfs_nr_is_valid(tempBv, bitWidth));\n  const uint64_t endBit = bitOffset + bitWidth - 1;\n  jassert(bufferData != nullptr);\n  jassert(bitOffset < (bufferSize * 8));\n  jassert(endBit < (bufferSize * 8));\n  const size_t startByte = bitOffset / 8;\n  const size_t endByte = endBit / 8;\n  jassert(startByte < bufferSize);\n  jassert(endByte < bufferSize);\n  // Track the current bit offset over time as well as the bits left to write.\n  uint64_t currentBitOffset = bitOffset;\n  jfs_nr_width_ty bitsRemaining = bitWidth;\n  // Track a view of the first byte of the bit vector.\n  const uint8_t* bvByteView = reinterpret_cast<const uint8_t*>(&tempBv);\n  // Write in the buffer byte by byte while preserving surrounding bits.\n  for (size_t currentByte = startByte; currentByte <= endByte; ++currentByte) {\n    // Example: `currentBitOffset` is 6. We can take bits [1, 0] from the BV and\n    // write them to bits [7, 6] in buffer.\n    const size_t offsetInByte = currentBitOffset % 8;\n    size_t bitsToWrite = 8 - offsetInByte;\n    // For the end byte, we have to cap `bitsToWrite` at the amount remaining.\n    if (bitsToWrite > bitsRemaining) {\n      bitsToWrite = bitsRemaining;\n    }\n    jassert(currentBitOffset < (bufferSize * 8));\n    jassert(currentBitOffset + bitsToWrite - 1 <= endBit);\n    const uint8_t bvMask = jfs_nr_get_bitvector_mask(bitsToWrite);\n    const uint8_t bufferMask = ~(bvMask << offsetInByte);\n    bufferData[currentByte] = (bufferData[currentByte] & bufferMask) |\n                              ((*bvByteView & bvMask) << offsetInByte);\n    // Shift the bits written off the bit vector.\n    tempBv >>= bitsToWrite;\n    currentBitOffset += bitsToWrite;\n    bitsRemaining -= bitsToWrite;\n  }\n}\n\n#ifdef __cplusplus\n}\n#endif\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/NativeBitVector.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_RUNTIME_SMTLIB_NATIVE_BITVECTOR_H\n#define JFS_RUNTIME_SMTLIB_NATIVE_BITVECTOR_H\n#include <stdint.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef uint64_t jfs_nr_bitvector_ty;\ntypedef uint64_t jfs_nr_width_ty;\n\n#define JFS_NR_BITVECTOR_TY_BITWIDTH (sizeof(jfs_nr_bitvector_ty) * 8)\n\nbool jfs_nr_is_valid(const jfs_nr_bitvector_ty value,\n                     const jfs_nr_width_ty width);\n\n// FIXME: This should not be public but NativeFloat needs this.\njfs_nr_bitvector_ty jfs_nr_get_bitvector_mod(const jfs_nr_bitvector_ty value,\n                                             const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_concat(const jfs_nr_bitvector_ty lhs,\n                                  const jfs_nr_width_ty lhsBitWidth,\n                                  const jfs_nr_bitvector_ty rhs,\n                                  const jfs_nr_width_ty rhsBitWidth);\n\njfs_nr_bitvector_ty jfs_nr_extract(const jfs_nr_bitvector_ty value,\n                                   const jfs_nr_width_ty bitWidth,\n                                   const jfs_nr_width_ty highBit,\n                                   const jfs_nr_width_ty lowBit);\n\njfs_nr_bitvector_ty jfs_nr_zero_extend(const jfs_nr_bitvector_ty value,\n                                       const jfs_nr_width_ty bitWidth,\n                                       const jfs_nr_width_ty extraBits);\n\njfs_nr_bitvector_ty jfs_nr_sign_extend(const jfs_nr_bitvector_ty value,\n                                       const jfs_nr_width_ty bitWidth,\n                                       const jfs_nr_width_ty extraBits);\n\njfs_nr_bitvector_ty jfs_nr_bvneg(const jfs_nr_bitvector_ty value,\n                                 const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvadd(const jfs_nr_bitvector_ty lhs,\n                                 const jfs_nr_bitvector_ty rhs,\n                                 const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvsub(const jfs_nr_bitvector_ty lhs,\n                                 const jfs_nr_bitvector_ty rhs,\n                                 const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvmul(const jfs_nr_bitvector_ty lhs,\n                                 const jfs_nr_bitvector_ty rhs,\n                                 const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvudiv(const jfs_nr_bitvector_ty dividend,\n                                  const jfs_nr_bitvector_ty divisor,\n                                  const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvurem(const jfs_nr_bitvector_ty dividend,\n                                  const jfs_nr_bitvector_ty divisor,\n                                  const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvsdiv(const jfs_nr_bitvector_ty dividend,\n                                  const jfs_nr_bitvector_ty divisor,\n                                  const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvsrem(const jfs_nr_bitvector_ty dividend,\n                                  const jfs_nr_bitvector_ty divisor,\n                                  const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvsmod(const jfs_nr_bitvector_ty dividend,\n                                  const jfs_nr_bitvector_ty divisor,\n                                  const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvshl(const jfs_nr_bitvector_ty value,\n                                 const jfs_nr_bitvector_ty shift,\n                                 const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvlshr(const jfs_nr_bitvector_ty value,\n                                  const jfs_nr_bitvector_ty shift,\n                                  const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvashr(const jfs_nr_bitvector_ty value,\n                                  const jfs_nr_bitvector_ty shift,\n                                  const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_rotate_left(const jfs_nr_bitvector_ty value,\n                                       const jfs_nr_bitvector_ty shift,\n                                       const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_rotate_right(const jfs_nr_bitvector_ty value,\n                                        const jfs_nr_bitvector_ty shift,\n                                        const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvand(const jfs_nr_bitvector_ty lhs,\n                                 const jfs_nr_bitvector_ty rhs,\n                                 const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvor(const jfs_nr_bitvector_ty lhs,\n                                const jfs_nr_bitvector_ty rhs,\n                                const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvnand(const jfs_nr_bitvector_ty lhs,\n                                  const jfs_nr_bitvector_ty rhs,\n                                  const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvnor(const jfs_nr_bitvector_ty lhs,\n                                 const jfs_nr_bitvector_ty rhs,\n                                 const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvxor(const jfs_nr_bitvector_ty lhs,\n                                 const jfs_nr_bitvector_ty rhs,\n                                 const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvxnor(const jfs_nr_bitvector_ty lhs,\n                                  const jfs_nr_bitvector_ty rhs,\n                                  const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_bvnot(const jfs_nr_bitvector_ty value,\n                                 const jfs_nr_width_ty bitWidth);\n\nbool jfs_nr_bvult(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth);\n\nbool jfs_nr_bvule(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth);\n\nbool jfs_nr_bvugt(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth);\n\nbool jfs_nr_bvuge(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth);\n\nbool jfs_nr_bvslt(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth);\n\nbool jfs_nr_bvsle(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth);\n\nbool jfs_nr_bvsgt(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth);\n\nbool jfs_nr_bvsge(const jfs_nr_bitvector_ty lhs, const jfs_nr_bitvector_ty rhs,\n                  const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty jfs_nr_make_bitvector(const uint8_t* bufferData,\n                                          const uint64_t bufferSize,\n                                          const uint64_t lowBit,\n                                          const uint64_t highBit);\n\nvoid jfs_nr_write_bitvector(const jfs_nr_bitvector_ty bv,\n                            const jfs_nr_width_ty bitWidth,\n                            uint8_t* bufferData,\n                            const uint64_t bufferSize,\n                            const uint64_t bitOffset);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/NativeFloat.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n// This is the implemenation of the runtime for SMTLIB Floats that\n// uses native machine operations. It is written with a C compatible interface\n// so that in the future we can easily use LLVM's JIT.\n#pragma STDC FENV_ACCESS ON\n#include \"SMTLIB/NativeFloat.h\"\n#include \"SMTLIB/NativeBitVector.h\"\n#include \"SMTLIB/jassert.h\"\n#include <fenv.h>\n#include <math.h>\n#include <string.h>\n\nnamespace {\n\n// Generic version\ntemplate <typename T>\nT jfs_nr_internal_make_float_from_buffer(const uint8_t* bufferData,\n                                         const uint64_t bufferSize,\n                                         const uint64_t lowBit) {\n  // Just re-use bitvector method for now.\n  // This assume little-endian which might things on other architectures.\n  uint64_t highBit = lowBit + (sizeof(T) * 8) - 1;\n  jassert((((highBit - lowBit) + 1) % 8) == 0 &&\n          \"Width requested should be whole bytes\");\n  jfs_nr_bitvector_ty rawBits =\n      jfs_nr_make_bitvector(bufferData, bufferSize, lowBit, highBit);\n  T result;\n  // Copy into result\n  memcpy(&result, &rawBits, sizeof(T));\n  return result;\n}\n\n// Generic version\ntemplate <typename RetTy, typename ArgTy>\nRetTy jfs_nr_internal_float_get_raw_bits(const ArgTy value) {\n  static_assert(sizeof(RetTy) == sizeof(ArgTy), \"Size mismatch\");\n  RetTy data = 0;\n  memcpy(&data, &value, sizeof(RetTy));\n  return data;\n}\n}\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nuint32_t jfs_nr_float32_get_raw_bits(const jfs_nr_float32 value) {\n  return jfs_nr_internal_float_get_raw_bits<uint32_t, jfs_nr_float32>(value);\n}\n\nuint64_t jfs_nr_float64_get_raw_bits(const jfs_nr_float64 value) {\n  return jfs_nr_internal_float_get_raw_bits<uint64_t, jfs_nr_float64>(value);\n}\n\njfs_nr_float32 jfs_nr_float32_get_infinity(bool positive) {\n  if (positive)\n    return INFINITY;\n  return -INFINITY;\n}\n\njfs_nr_float64 jfs_nr_float64_get_infinity(bool positive) {\n  if (positive)\n    return INFINITY;\n  return -INFINITY;\n}\n\njfs_nr_float32 jfs_nr_float32_get_zero(bool positive) {\n  if (positive)\n    return jfs_nr_bitcast_bv_to_float32(0x0);\n  return jfs_nr_bitcast_bv_to_float32(UINT32_C(0x80000000));\n}\n\njfs_nr_float64 jfs_nr_float64_get_zero(bool positive) {\n  if (positive)\n    return jfs_nr_bitcast_bv_to_float64(0x0);\n  return jfs_nr_bitcast_bv_to_float64(UINT64_C(0x8000000000000000));\n}\n\njfs_nr_float32 jfs_nr_float32_get_nan(bool quiet) {\n  if (quiet)\n    return jfs_nr_bitcast_bv_to_float32(UINT64_C(0x7fc00000));\n  return jfs_nr_bitcast_bv_to_float32(UINT64_C(0x7f800001));\n}\n\njfs_nr_float64 jfs_nr_float64_get_nan(bool quiet) {\n  if (quiet)\n    return jfs_nr_bitcast_bv_to_float64(UINT64_C(0x7ff8000000000000));\n  return jfs_nr_bitcast_bv_to_float64(UINT64_C(0x7ff0000000000001));\n}\n\nbool jfs_nr_float32_is_normal(const jfs_nr_float32 value) {\n  return isnormal(value) != 0;\n}\nbool jfs_nr_float64_is_normal(const jfs_nr_float64 value) {\n  return isnormal(value) != 0;\n}\n\nbool jfs_nr_float32_is_subnormal(const jfs_nr_float32 value) {\n  return fpclassify(value) == FP_SUBNORMAL;\n}\n\nbool jfs_nr_float64_is_subnormal(const jfs_nr_float64 value) {\n  return fpclassify(value) == FP_SUBNORMAL;\n}\n\nbool jfs_nr_float32_is_zero(const jfs_nr_float32 value) {\n  return fpclassify(value) == FP_ZERO;\n}\n\nbool jfs_nr_float64_is_zero(const jfs_nr_float64 value) {\n  return fpclassify(value) == FP_ZERO;\n}\n\nbool jfs_nr_float32_is_infinite(const jfs_nr_float32 value) {\n  return fpclassify(value) == FP_INFINITE;\n}\n\nbool jfs_nr_float64_is_infinite(const jfs_nr_float64 value) {\n  return fpclassify(value) == FP_INFINITE;\n}\n\nbool jfs_nr_float32_is_positive(const jfs_nr_float32 value) {\n  // +zero is treated as positive\n  if (jfs_nr_float32_get_raw_bits(value) == UINT64_C(0x0))\n    return true;\n  return jfs_nr_float32_get_zero(/*positive=*/true) < value;\n}\n\nbool jfs_nr_float64_is_positive(const jfs_nr_float64 value) {\n  // +zero is treated as positive\n  if (jfs_nr_float64_get_raw_bits(value) == UINT64_C(0x0))\n    return true;\n  return jfs_nr_float64_get_zero(/*positive=*/true) < value;\n}\n\nbool jfs_nr_float32_is_negative(const jfs_nr_float32 value) {\n  // -zero is treated as negative\n  if (jfs_nr_float32_get_raw_bits(value) == UINT32_C(0x80000000))\n    return true;\n  return value < jfs_nr_float32_get_zero(/*positive=*/false);\n}\n\nbool jfs_nr_float64_is_negative(const jfs_nr_float64 value) {\n  // -zero is treated as negative\n  if (jfs_nr_float64_get_raw_bits(value) == UINT64_C(0x8000000000000000))\n    return true;\n  return value < jfs_nr_float64_get_zero(/*positive=*/false);\n}\n\nbool jfs_nr_float32_is_nan(const jfs_nr_float32 value) { return isnan(value); }\n\nbool jfs_nr_float64_is_nan(const jfs_nr_float64 value) { return isnan(value); }\n\nbool jfs_nr_float32_ieee_equals(const jfs_nr_float32 lhs,\n                                const jfs_nr_float32 rhs) {\n  return lhs == rhs;\n}\n\nbool jfs_nr_float64_ieee_equals(const jfs_nr_float64 lhs,\n                                const jfs_nr_float64 rhs) {\n  return lhs == rhs;\n}\n\nbool jfs_nr_float32_smtlib_equals(const jfs_nr_float32 lhs,\n                                  const jfs_nr_float32 rhs) {\n  // In SMT-LIBv2 no distinction is made between the different types of NaN\n  /*\n   *  (set-logic QF_FPBV)\n      (declare-const x (_ BitVec 32))\n      (declare-const y (_ BitVec 32))\n      (assert (not (= x y)))\n      (assert (fp.isNaN ((_ to_fp 8 24) x)))\n      (assert (fp.isNaN ((_ to_fp 8 24) y)))\n      (assert\n        (not\n          (=\n            ((_ to_fp 8 24) x)\n            ((_ to_fp 8 24) y)\n          )\n        )\n      )\n      (check-sat)\n      unsat\n  */\n  bool lhsIsNaN = isnan(lhs);\n  bool rhsIsNaN = isnan(rhs);\n  if (lhsIsNaN && rhsIsNaN) {\n    return true;\n  }\n  // Positive and negative 0 are distinct but C's `==` operator considers them\n  // equal so just do bit comparison.\n  return jfs_nr_float32_get_raw_bits(lhs) == jfs_nr_float32_get_raw_bits(rhs);\n}\n\nbool jfs_nr_float64_smtlib_equals(const jfs_nr_float64 lhs,\n                                  const jfs_nr_float64 rhs) {\n  // In SMT-LIBv2 no distinction is made between the different types of NaN\n  bool lhsIsNaN = isnan(lhs);\n  bool rhsIsNaN = isnan(rhs);\n  if (lhsIsNaN && rhsIsNaN) {\n    return true;\n  }\n  // Positive and negative 0 are distinct but C's `==` operator considers them\n  // equal so just do bit comparison.\n  return jfs_nr_float64_get_raw_bits(lhs) == jfs_nr_float64_get_raw_bits(rhs);\n}\n\njfs_nr_float32 jfs_nr_float32_abs(const jfs_nr_float32 value) {\n  return ::fabsf(value);\n}\n\njfs_nr_float64 jfs_nr_float64_abs(const jfs_nr_float64 value) {\n  return ::fabs(value);\n}\n\njfs_nr_float32 jfs_nr_float32_neg(const jfs_nr_float32 value) {\n  uint32_t rawBits = jfs_nr_float32_get_raw_bits(value);\n  // Flip sign bit\n  rawBits ^= UINT32_C(0x80000000);\n  return jfs_nr_bitcast_bv_to_float32(rawBits);\n}\n\n// FIXME: We are assuming that FE_TONEAREST is RNE but it could be\n// RNA which would be wrong. We should build a target specific version\n#ifndef __x86_64\n#error FIXME UNSUPPORTED PLATFORM\n#endif\n// FIXME: Do we need a barrier here to prevent Clang moving around the calls?\n#define JFS_NR_SET_RM(X)                                                       \\\n  {                                                                            \\\n    switch (X) {                                                               \\\n    case JFS_RM_RNE: {                                                         \\\n      /* This is the default so do nothing */                                  \\\n      break;                                                                   \\\n    }                                                                          \\\n    case JFS_RM_RNA: {                                                         \\\n      /* FIXME: Not supported by C */                                          \\\n      JFS_RUNTIME_FAIL()                                                       \\\n      break;                                                                   \\\n    }                                                                          \\\n    case JFS_RM_RTP: {                                                         \\\n      int failed = fesetround(FE_UPWARD);                                      \\\n      jassert(failed == 0);                                                    \\\n      break;                                                                   \\\n    }                                                                          \\\n    case JFS_RM_RTN: {                                                         \\\n      int failed = fesetround(FE_DOWNWARD);                                    \\\n      jassert(failed == 0);                                                    \\\n      break;                                                                   \\\n    }                                                                          \\\n    case JFS_RM_RTZ: {                                                         \\\n      int failed = fesetround(FE_TOWARDZERO);                                  \\\n      jassert(failed == 0);                                                    \\\n      break;                                                                   \\\n    }                                                                          \\\n    default:                                                                   \\\n      JFS_RUNTIME_FAIL()                                                       \\\n    }                                                                          \\\n  }\n#define JFS_NR_RESET_RM(PREVIOUS)                                              \\\n  {                                                                            \\\n    switch (PREVIOUS) {                                                        \\\n    case JFS_RM_RNE: {                                                         \\\n      /* The rounding mode switched was the default so do nothing */           \\\n      break;                                                                   \\\n    }                                                                          \\\n    case JFS_RM_RTP:                                                           \\\n    case JFS_RM_RTN:                                                           \\\n    case JFS_RM_RTZ: {                                                         \\\n      int failed = fesetround(FE_TONEAREST);                                   \\\n      jassert(failed == 0);                                                    \\\n      break;                                                                   \\\n    }                                                                          \\\n    default:                                                                   \\\n      JFS_RUNTIME_FAIL();                                                      \\\n    }                                                                          \\\n  }\n\n// FIXME: This is a hack. Clang doesn't support the FENV_ACCESS pragma\n// and so incorrectly optimizes the code so the rounding mode change and\n// floating point operation get re-ordered. Using `asm volatile (\"\" : : :\n// \"memory\")`\n// didn't seem to work unfortunately so for now put this attribute on all\n// functions\n// that might change the rounding mode.\n// See https://bugs.llvm.org/show_bug.cgi?id=8100\n#define NO_OPT __attribute__((optnone))\n\nNO_OPT jfs_nr_float32 jfs_nr_float32_add(JFS_NR_RM rm, const jfs_nr_float32 lhs,\n                                         const jfs_nr_float32 rhs) {\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float32 result = lhs + rhs;\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\nNO_OPT jfs_nr_float64 jfs_nr_float64_add(JFS_NR_RM rm, const jfs_nr_float64 lhs,\n                                         const jfs_nr_float64 rhs) {\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float64 result = lhs + rhs;\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\nNO_OPT jfs_nr_float32 jfs_nr_float32_sub(JFS_NR_RM rm, const jfs_nr_float32 lhs,\n                                         const jfs_nr_float32 rhs) {\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float32 result = lhs - rhs;\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\nNO_OPT jfs_nr_float64 jfs_nr_float64_sub(JFS_NR_RM rm, const jfs_nr_float64 lhs,\n                                         const jfs_nr_float64 rhs) {\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float64 result = lhs - rhs;\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\nNO_OPT jfs_nr_float32 jfs_nr_float32_mul(JFS_NR_RM rm, const jfs_nr_float32 lhs,\n                                         const jfs_nr_float32 rhs) {\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float32 result = lhs * rhs;\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\nNO_OPT jfs_nr_float64 jfs_nr_float64_mul(JFS_NR_RM rm, const jfs_nr_float64 lhs,\n                                         const jfs_nr_float64 rhs) {\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float64 result = lhs * rhs;\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\n// Use the attribute to prevent UBSan from raising errors when doing floating\n// point division by zero.\n#define ALLOW_DIV_BY_ZERO __attribute__((no_sanitize(\"float-divide-by-zero\")))\nNO_OPT ALLOW_DIV_BY_ZERO jfs_nr_float32 jfs_nr_float32_div(\n    JFS_NR_RM rm, const jfs_nr_float32 lhs, const jfs_nr_float32 rhs) {\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float32 result = lhs / rhs;\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\nNO_OPT ALLOW_DIV_BY_ZERO jfs_nr_float64 jfs_nr_float64_div(\n    JFS_NR_RM rm, const jfs_nr_float64 lhs, const jfs_nr_float64 rhs) {\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float64 result = lhs / rhs;\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n#undef ALLOW_DIV_BY_ZERO\n\nNO_OPT jfs_nr_float32 jfs_nr_float32_fma(JFS_NR_RM rm, const jfs_nr_float32 a,\n                                         const jfs_nr_float32 b,\n                                         const jfs_nr_float32 c) {\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float32 result = fmaf(a, b, c);\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\nNO_OPT jfs_nr_float64 jfs_nr_float64_fma(JFS_NR_RM rm, const jfs_nr_float64 a,\n                                         const jfs_nr_float64 b,\n                                         const jfs_nr_float64 c) {\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float64 result = fma(a, b, c);\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\nNO_OPT jfs_nr_float32 jfs_nr_float32_sqrt(JFS_NR_RM rm,\n                                          const jfs_nr_float32 value) {\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float32 result = sqrtf(value);\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\nNO_OPT jfs_nr_float64 jfs_nr_float64_sqrt(JFS_NR_RM rm,\n                                          const jfs_nr_float64 value) {\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float64 result = sqrt(value);\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\nNO_OPT jfs_nr_float32\njfs_nr_float32_round_to_integral(JFS_NR_RM rm, const jfs_nr_float32 value) {\n  // FIXME: We can use the `round()` C math library function to support\n  // JFS_RM_RNA\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float32 result = nearbyintf(value);\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\nNO_OPT jfs_nr_float64\njfs_nr_float64_round_to_integral(JFS_NR_RM rm, const jfs_nr_float64 value) {\n  // FIXME: We can use the `round()` C math library function to support\n  // JFS_RM_RNA\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float64 result = nearbyint(value);\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\n// Use this attribute to prevent UBSan from raising errors when doing float\n// casts.\n#define ALLOW_OVERFLOW __attribute__((no_sanitize(\"float-cast-overflow\")))\n\nNO_OPT ALLOW_OVERFLOW jfs_nr_float32\njfs_nr_convert_float64_to_float32(JFS_NR_RM rm, const jfs_nr_float64 value) {\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float32 result = (jfs_nr_float32)value;\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\njfs_nr_float64 jfs_nr_convert_float32_to_float64(const jfs_nr_float32 value) {\n  // No rounding mode is required because every jfs_nr_float32 value can be\n  // precisely represented as a jfs_nr_float64.\n  return (jfs_nr_float64)value;\n}\n\nNO_OPT jfs_nr_float32 jfs_nr_convert_from_unsigned_bv_to_float32(\n    JFS_NR_RM rm, const jfs_nr_bitvector_ty value,\n    const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(value, bitWidth));\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float32 result = (jfs_nr_float32)value;\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\nNO_OPT jfs_nr_float64 jfs_nr_convert_from_unsigned_bv_to_float64(\n    JFS_NR_RM rm, const jfs_nr_bitvector_ty value,\n    const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(value, bitWidth));\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float64 result = (jfs_nr_float64)value;\n  JFS_NR_RESET_RM(rm)\n  return result;\n}\n\nNO_OPT jfs_nr_float32 jfs_nr_convert_from_signed_bv_to_float32(\n    JFS_NR_RM rm, const jfs_nr_bitvector_ty value,\n    const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(value, bitWidth));\n  // If the bitvector is negative turn it into a positive value and negate\n  // the float afterwards.\n  bool shouldNegateFloat = false;\n  jfs_nr_bitvector_ty positiveBv = value;\n  if (jfs_nr_bvslt(positiveBv, 0, bitWidth)) {\n    shouldNegateFloat = true;\n    positiveBv = jfs_nr_bvneg(value, bitWidth);\n  }\n  jassert(jfs_nr_bvsge(positiveBv, 0, bitWidth));\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float32 result = (jfs_nr_float32)positiveBv;\n  JFS_NR_RESET_RM(rm)\n  if (shouldNegateFloat) {\n    result = jfs_nr_float32_neg(result);\n  }\n  return result;\n}\n\nNO_OPT jfs_nr_float64 jfs_nr_convert_from_signed_bv_to_float64(\n    JFS_NR_RM rm, const jfs_nr_bitvector_ty value,\n    const jfs_nr_width_ty bitWidth) {\n  jassert(jfs_nr_is_valid(value, bitWidth));\n  // If the bitvector is negative turn it into a positive value and negate\n  // the float afterwards.\n  bool shouldNegateFloat = false;\n  jfs_nr_bitvector_ty positiveBv = value;\n  if (jfs_nr_bvslt(positiveBv, 0, bitWidth)) {\n    shouldNegateFloat = true;\n    positiveBv = jfs_nr_bvneg(value, bitWidth);\n  }\n  jassert(jfs_nr_bvsge(positiveBv, 0, bitWidth));\n  JFS_NR_SET_RM(rm)\n  jfs_nr_float64 result = (jfs_nr_float64)positiveBv;\n  JFS_NR_RESET_RM(rm)\n  if (shouldNegateFloat) {\n    result = jfs_nr_float64_neg(result);\n  }\n  return result;\n}\n\n// FIXME: We should probably pick a single value to represent the\n// undefined case so we can test for it.\nNO_OPT ALLOW_OVERFLOW jfs_nr_bitvector_ty jfs_nr_float32_convert_to_unsigned_bv(\n    JFS_NR_RM rm, jfs_nr_float32 value, const jfs_nr_width_ty bitWidth) {\n  JFS_NR_SET_RM(rm)\n  jfs_nr_bitvector_ty result = (jfs_nr_bitvector_ty)value;\n  JFS_NR_RESET_RM(rm)\n  // Mask off result\n  result = jfs_nr_get_bitvector_mod(result, bitWidth);\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\n// FIXME: We should probably pick a single value to represent the\n// undefined case so we can test for it.\nNO_OPT ALLOW_OVERFLOW jfs_nr_bitvector_ty jfs_nr_float64_convert_to_unsigned_bv(\n    JFS_NR_RM rm, jfs_nr_float64 value, const jfs_nr_width_ty bitWidth) {\n  JFS_NR_SET_RM(rm)\n  jfs_nr_bitvector_ty result = (jfs_nr_bitvector_ty)value;\n  JFS_NR_RESET_RM(rm)\n  // Mask off result\n  result = jfs_nr_get_bitvector_mod(result, bitWidth);\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\n// FIXME: We should probably pick a single value to represent the\n// undefined case so we can test for it.\nNO_OPT ALLOW_OVERFLOW jfs_nr_bitvector_ty jfs_nr_float32_convert_to_signed_bv(\n    JFS_NR_RM rm, jfs_nr_float32 value, const jfs_nr_width_ty bitWidth) {\n  bool shouldNegateResult = false;\n  jfs_nr_float32 positiveFloat = value;\n  // if float is negative turn it into a positive value and negate the\n  // bitvector afterwards.\n  if (jfs_nr_float32_is_negative(value)) {\n    positiveFloat = jfs_nr_float32_neg(value);\n    shouldNegateResult = true;\n  }\n  jassert(jfs_nr_float32_is_positive(positiveFloat));\n  JFS_NR_SET_RM(rm)\n  jfs_nr_bitvector_ty result = (jfs_nr_bitvector_ty)positiveFloat;\n  JFS_NR_RESET_RM(rm)\n  // Mask off result\n  result = jfs_nr_get_bitvector_mod(result, bitWidth);\n  if (shouldNegateResult) {\n    result = jfs_nr_bvneg(result, bitWidth);\n  }\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\n// FIXME: We should probably pick a single value to represent the\n// undefined case so we can test for it.\nNO_OPT ALLOW_OVERFLOW jfs_nr_bitvector_ty jfs_nr_float64_convert_to_signed_bv(\n    JFS_NR_RM rm, jfs_nr_float64 value, const jfs_nr_width_ty bitWidth) {\n  bool shouldNegateResult = false;\n  jfs_nr_float64 positiveFloat = value;\n  // if float is negative turn it into a positive value and negate the\n  // bitvector afterwards.\n  if (jfs_nr_float64_is_negative(value)) {\n    positiveFloat = jfs_nr_float64_neg(value);\n    shouldNegateResult = true;\n  }\n  jassert(jfs_nr_float64_is_positive(positiveFloat));\n  JFS_NR_SET_RM(rm)\n  jfs_nr_bitvector_ty result = (jfs_nr_bitvector_ty)positiveFloat;\n  JFS_NR_RESET_RM(rm)\n  // Mask off result\n  result = jfs_nr_get_bitvector_mod(result, bitWidth);\n  if (shouldNegateResult) {\n    result = jfs_nr_bvneg(result, bitWidth);\n  }\n  jassert(jfs_nr_is_valid(result, bitWidth));\n  return result;\n}\n\n#undef JFS_NR_SET_RM\n#undef JFS_NR_RESET_RM\n#undef ALLOW_OVERFLOW\n\njfs_nr_float32 jfs_nr_float32_rem(const jfs_nr_float32 lhs,\n                                  const jfs_nr_float32 rhs) {\n  return remainderf(lhs, rhs);\n}\n\njfs_nr_float64 jfs_nr_float64_rem(const jfs_nr_float64 lhs,\n                                  const jfs_nr_float64 rhs) {\n  return remainder(lhs, rhs);\n}\n\njfs_nr_float64 jfs_nr_float64_neg(const jfs_nr_float64 value) {\n  uint64_t rawBits = jfs_nr_float64_get_raw_bits(value);\n  // Flip sign bit\n  rawBits ^= UINT64_C(0x8000000000000000);\n  return jfs_nr_bitcast_bv_to_float64(rawBits);\n}\n\njfs_nr_float32 jfs_nr_float32_min(const jfs_nr_float32 lhs,\n                                  const jfs_nr_float32 rhs) {\n  return ::fminf(lhs, rhs);\n}\n\njfs_nr_float64 jfs_nr_float64_min(const jfs_nr_float64 lhs,\n                                  const jfs_nr_float64 rhs) {\n  return ::fmin(lhs, rhs);\n}\n\njfs_nr_float32 jfs_nr_float32_max(const jfs_nr_float32 lhs,\n                                  const jfs_nr_float32 rhs) {\n  return ::fmaxf(lhs, rhs);\n}\n\njfs_nr_float64 jfs_nr_float64_max(const jfs_nr_float64 lhs,\n                                  const jfs_nr_float64 rhs) {\n  return ::fmax(lhs, rhs);\n}\n\nbool jfs_nr_float32_leq(const jfs_nr_float32 lhs, const jfs_nr_float32 rhs) {\n  return lhs <= rhs;\n}\n\nbool jfs_nr_float64_leq(const jfs_nr_float64 lhs, const jfs_nr_float64 rhs) {\n  return lhs <= rhs;\n}\n\nbool jfs_nr_float32_lt(const jfs_nr_float32 lhs, const jfs_nr_float32 rhs) {\n  return lhs < rhs;\n}\n\nbool jfs_nr_float64_lt(const jfs_nr_float64 lhs, const jfs_nr_float64 rhs) {\n  return lhs < rhs;\n}\n\nbool jfs_nr_float32_gt(const jfs_nr_float32 lhs, const jfs_nr_float32 rhs) {\n  return lhs > rhs;\n}\n\nbool jfs_nr_float64_gt(const jfs_nr_float64 lhs, const jfs_nr_float64 rhs) {\n  return lhs > rhs;\n}\n\nbool jfs_nr_float32_geq(const jfs_nr_float32 lhs, const jfs_nr_float32 rhs) {\n  return lhs >= rhs;\n}\n\nbool jfs_nr_float64_geq(const jfs_nr_float64 lhs, const jfs_nr_float64 rhs) {\n  return lhs >= rhs;\n}\n\njfs_nr_float32 jfs_nr_bitcast_bv_to_float32(const jfs_nr_bitvector_ty value) {\n  jassert((value & UINT64_C(0xffffffff00000000)) == 0);\n  jfs_nr_float32 data = 0.0;\n  memcpy(&data, &value, sizeof(data));\n  return data;\n}\n\njfs_nr_float64 jfs_nr_bitcast_bv_to_float64(const jfs_nr_bitvector_ty value) {\n  jfs_nr_float64 data = 0.0;\n  memcpy(&data, &value, sizeof(data));\n  return data;\n}\n\n// Note significand does not contain implicit bit\njfs_nr_float32\njfs_nr_make_float32_from_triple(const jfs_nr_bitvector_ty sign,\n                                const jfs_nr_bitvector_ty exponent,\n                                const jfs_nr_bitvector_ty significand) {\n  static_assert((sizeof(jfs_nr_bitvector_ty) * 8) >= 32, \"not enough bits\");\n  jassert((sign & (~(UINT64_C(0x1)))) == 0);             // only 1 bit\n  jassert((exponent & (~(UINT64_C(0xff)))) == 0);        // only 8-bits\n  jassert((significand & (~(UINT64_C(0x7fffff)))) == 0); // only 23-bits\n  jfs_nr_bitvector_ty rawBits = significand;\n  rawBits |= (exponent << 23);\n  rawBits |= (sign << 31);\n  return jfs_nr_bitcast_bv_to_float32(rawBits);\n}\n\njfs_nr_float64\njfs_nr_make_float64_from_triple(const jfs_nr_bitvector_ty sign,\n                                const jfs_nr_bitvector_ty exponent,\n                                const jfs_nr_bitvector_ty significand) {\n  // TODO: Finish!\n  static_assert((sizeof(jfs_nr_bitvector_ty) * 8) >= 64, \"not enough bits\");\n  jassert((sign & (~(UINT64_C(0x1)))) == 0);       // only 1 bit\n  jassert((exponent & (~(UINT64_C(0x7ff)))) == 0); // only 11-bits\n  jassert((significand & (~(UINT64_C(0x000fffffffffffff)))) ==\n          0); // only 52-bits\n  jfs_nr_bitvector_ty rawBits = significand;\n  rawBits |= (exponent << 52);\n  rawBits |= (sign << 63);\n  return jfs_nr_bitcast_bv_to_float64(rawBits);\n}\n\njfs_nr_float32 jfs_nr_make_float32_from_buffer(const uint8_t* bufferData,\n                                               const uint64_t bufferSize,\n                                               const uint64_t lowBit) {\n  return jfs_nr_internal_make_float_from_buffer<jfs_nr_float32>(\n      bufferData, bufferSize, lowBit);\n}\n\njfs_nr_float64 jfs_nr_make_float64_from_buffer(const uint8_t* bufferData,\n                                               const uint64_t bufferSize,\n                                               const uint64_t lowBit) {\n  return jfs_nr_internal_make_float_from_buffer<jfs_nr_float64>(\n      bufferData, bufferSize, lowBit);\n}\n\n#ifdef __cplusplus\n}\n#endif\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/NativeFloat.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_RUNTIME_SMTLIB_NATIVE_FLOAT_H\n#define JFS_RUNTIME_SMTLIB_NATIVE_FLOAT_H\n#include \"SMTLIB/NativeBitVector.h\"\n#include <stdint.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef float jfs_nr_float32;\ntypedef double jfs_nr_float64;\n\nenum JFS_NR_RM {\n  JFS_RM_RNE, // Round to nearest ties to even\n  JFS_RM_RNA, // Round to nearest ties away from zero\n  JFS_RM_RTP, // Round toward +inf\n  JFS_RM_RTN, // Round toward -inf\n  JFS_RM_RTZ, // Round toward zero\n};\n\nuint32_t jfs_nr_float32_get_raw_bits(const jfs_nr_float32 value);\nuint64_t jfs_nr_float64_get_raw_bits(const jfs_nr_float64 value);\n\njfs_nr_float32 jfs_nr_float32_get_infinity(bool positive);\njfs_nr_float64 jfs_nr_float64_get_infinity(bool positive);\njfs_nr_float32 jfs_nr_float32_get_zero(bool positive);\njfs_nr_float64 jfs_nr_float64_get_zero(bool positive);\njfs_nr_float32 jfs_nr_float32_get_nan(bool quiet);\njfs_nr_float64 jfs_nr_float64_get_nan(bool quiet);\n\nbool jfs_nr_float32_is_normal(const jfs_nr_float32 value);\nbool jfs_nr_float64_is_normal(const jfs_nr_float64 value);\nbool jfs_nr_float32_is_subnormal(const jfs_nr_float32 value);\nbool jfs_nr_float64_is_subnormal(const jfs_nr_float64 value);\nbool jfs_nr_float32_is_zero(const jfs_nr_float32 value);\nbool jfs_nr_float64_is_zero(const jfs_nr_float64 value);\nbool jfs_nr_float32_is_infinite(const jfs_nr_float32 value);\nbool jfs_nr_float64_is_infinite(const jfs_nr_float64 value);\nbool jfs_nr_float32_is_positive(const jfs_nr_float32 value);\nbool jfs_nr_float64_is_positive(const jfs_nr_float64 value);\nbool jfs_nr_float32_is_negative(const jfs_nr_float32 value);\nbool jfs_nr_float64_is_negative(const jfs_nr_float64 value);\nbool jfs_nr_float32_is_nan(const jfs_nr_float32 value);\nbool jfs_nr_float64_is_nan(const jfs_nr_float64 value);\n\nbool jfs_nr_float32_ieee_equals(const jfs_nr_float32 lhs,\n                                const jfs_nr_float32 rhs);\nbool jfs_nr_float64_ieee_equals(const jfs_nr_float64 lhs,\n                                const jfs_nr_float64 rhs);\n\nbool jfs_nr_float32_smtlib_equals(const jfs_nr_float32 lhs,\n                                  const jfs_nr_float32 rhs);\nbool jfs_nr_float64_smtlib_equals(const jfs_nr_float64 lhs,\n                                  const jfs_nr_float64 rhs);\n\njfs_nr_float32 jfs_nr_float32_abs(const jfs_nr_float32 value);\njfs_nr_float64 jfs_nr_float64_abs(const jfs_nr_float64 value);\njfs_nr_float32 jfs_nr_float32_neg(const jfs_nr_float32 value);\njfs_nr_float64 jfs_nr_float64_neg(const jfs_nr_float64 value);\n\njfs_nr_float32 jfs_nr_float32_add(JFS_NR_RM rm, const jfs_nr_float32 lhs,\n                                  const jfs_nr_float32 rhs);\njfs_nr_float64 jfs_nr_float64_add(JFS_NR_RM rm, const jfs_nr_float64 lhs,\n                                  const jfs_nr_float64 rhs);\njfs_nr_float32 jfs_nr_float32_sub(JFS_NR_RM rm, const jfs_nr_float32 lhs,\n                                  const jfs_nr_float32 rhs);\njfs_nr_float64 jfs_nr_float64_sub(JFS_NR_RM rm, const jfs_nr_float64 lhs,\n                                  const jfs_nr_float64 rhs);\njfs_nr_float32 jfs_nr_float32_mul(JFS_NR_RM rm, const jfs_nr_float32 lhs,\n                                  const jfs_nr_float32 rhs);\njfs_nr_float64 jfs_nr_float64_mul(JFS_NR_RM rm, const jfs_nr_float64 lhs,\n                                  const jfs_nr_float64 rhs);\njfs_nr_float32 jfs_nr_float32_div(JFS_NR_RM rm, const jfs_nr_float32 lhs,\n                                  const jfs_nr_float32 rhs);\njfs_nr_float64 jfs_nr_float64_div(JFS_NR_RM rm, const jfs_nr_float64 lhs,\n                                  const jfs_nr_float64 rhs);\n// Computes (a * b) + c\njfs_nr_float32 jfs_nr_float32_fma(JFS_NR_RM rm, const jfs_nr_float32 a,\n                                  const jfs_nr_float32 b,\n                                  const jfs_nr_float32 c);\njfs_nr_float64 jfs_nr_float64_fma(JFS_NR_RM rm, const jfs_nr_float64 a,\n                                  const jfs_nr_float64 b,\n                                  const jfs_nr_float64 c);\njfs_nr_float32 jfs_nr_float32_sqrt(JFS_NR_RM rm, const jfs_nr_float32 value);\njfs_nr_float64 jfs_nr_float64_sqrt(JFS_NR_RM rm, const jfs_nr_float64 value);\njfs_nr_float32 jfs_nr_float32_rem(const jfs_nr_float32 lhs,\n                                  const jfs_nr_float32 rhs);\njfs_nr_float64 jfs_nr_float64_rem(const jfs_nr_float64 lhs,\n                                  const jfs_nr_float64 rhs);\njfs_nr_float32 jfs_nr_float32_round_to_integral(JFS_NR_RM rm,\n                                                const jfs_nr_float32 value);\njfs_nr_float64 jfs_nr_float64_round_to_integral(JFS_NR_RM rm,\n                                                const jfs_nr_float64 value);\n\njfs_nr_float32 jfs_nr_float32_min(const jfs_nr_float32 lhs,\n                                  const jfs_nr_float32 rhs);\njfs_nr_float64 jfs_nr_float64_min(const jfs_nr_float64 lhs,\n                                  const jfs_nr_float64 rhs);\njfs_nr_float32 jfs_nr_float32_max(const jfs_nr_float32 lhs,\n                                  const jfs_nr_float32 rhs);\njfs_nr_float64 jfs_nr_float64_max(const jfs_nr_float64 lhs,\n                                  const jfs_nr_float64 rhs);\n\nbool jfs_nr_float32_leq(const jfs_nr_float32 lhs, const jfs_nr_float32 rhs);\nbool jfs_nr_float64_leq(const jfs_nr_float64 lhs, const jfs_nr_float64 rhs);\nbool jfs_nr_float32_lt(const jfs_nr_float32 lhs, const jfs_nr_float32 rhs);\nbool jfs_nr_float64_lt(const jfs_nr_float64 lhs, const jfs_nr_float64 rhs);\nbool jfs_nr_float32_gt(const jfs_nr_float32 lhs, const jfs_nr_float32 rhs);\nbool jfs_nr_float64_gt(const jfs_nr_float64 lhs, const jfs_nr_float64 rhs);\nbool jfs_nr_float32_geq(const jfs_nr_float32 lhs, const jfs_nr_float32 rhs);\nbool jfs_nr_float64_geq(const jfs_nr_float64 lhs, const jfs_nr_float64 rhs);\n\njfs_nr_float32 jfs_nr_bitcast_bv_to_float32(const jfs_nr_bitvector_ty value);\njfs_nr_float64 jfs_nr_bitcast_bv_to_float64(const jfs_nr_bitvector_ty value);\n\njfs_nr_float32 jfs_nr_convert_float64_to_float32(JFS_NR_RM rm,\n                                                 const jfs_nr_float64 value);\njfs_nr_float64 jfs_nr_convert_float32_to_float64(const jfs_nr_float32 value);\n\njfs_nr_float32\njfs_nr_convert_from_unsigned_bv_to_float32(JFS_NR_RM rm,\n                                           const jfs_nr_bitvector_ty value,\n                                           const jfs_nr_width_ty bitWidth);\njfs_nr_float64\njfs_nr_convert_from_unsigned_bv_to_float64(JFS_NR_RM rm,\n                                           const jfs_nr_bitvector_ty value,\n                                           const jfs_nr_width_ty bitWidth);\njfs_nr_float32\njfs_nr_convert_from_signed_bv_to_float32(JFS_NR_RM rm,\n                                         const jfs_nr_bitvector_ty value,\n                                         const jfs_nr_width_ty bitWidth);\njfs_nr_float64\njfs_nr_convert_from_signed_bv_to_float64(JFS_NR_RM rm,\n                                         const jfs_nr_bitvector_ty value,\n                                         const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty\njfs_nr_float32_convert_to_unsigned_bv(JFS_NR_RM rm, jfs_nr_float32 value,\n                                      const jfs_nr_width_ty bitWidth);\njfs_nr_bitvector_ty\njfs_nr_float64_convert_to_unsigned_bv(JFS_NR_RM rm, jfs_nr_float64 value,\n                                      const jfs_nr_width_ty bitWidth);\n\njfs_nr_bitvector_ty\njfs_nr_float32_convert_to_signed_bv(JFS_NR_RM rm, jfs_nr_float32 value,\n                                    const jfs_nr_width_ty bitWidth);\njfs_nr_bitvector_ty\njfs_nr_float64_convert_to_signed_bv(JFS_NR_RM rm, jfs_nr_float64 value,\n                                    const jfs_nr_width_ty bitWidth);\n\n// Note significand does not contain implicit bit\njfs_nr_float32\njfs_nr_make_float32_from_triple(const jfs_nr_bitvector_ty sign,\n                                const jfs_nr_bitvector_ty exponent,\n                                const jfs_nr_bitvector_ty significand);\n\n// Note significand does not contain implicit bit\njfs_nr_float64\njfs_nr_make_float64_from_triple(const jfs_nr_bitvector_ty sign,\n                                const jfs_nr_bitvector_ty exponent,\n                                const jfs_nr_bitvector_ty significand);\n\njfs_nr_float32 jfs_nr_make_float32_from_buffer(const uint8_t* bufferData,\n                                               const uint64_t bufferSize,\n                                               const uint64_t lowBit);\n\njfs_nr_float64 jfs_nr_make_float64_from_buffer(const uint8_t* bufferData,\n                                               const uint64_t bufferSize,\n                                               const uint64_t lowBit);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/jassert.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_RUNTIME_SMTLIB_JFS_ASSERTS_H\n#define JFS_RUNTIME_SMTLIB_JFS_ASSERTS_H\n#include <stdio.h>\n#include <stdlib.h>\n\n// This is a hack. We use `abort()` as the fuzzing target so we can't have\n// anything else in generated programs call it. C's `assert()` macro calls it\n// so we use our own macro that will cause LibFuzzer to terminate abnormally in\n// a way we can distinguish from the fuzzing target being found.\n#ifdef JFS_RUNTIME_FAILURE_CALLS_ABORT\n#define JFS_RUNTIME_FAIL() abort();\n#else\n#define JFS_RUNTIME_FAIL() exit(99);\n#endif\n\n#define JFS_RUNTIME_FAIL_WITH_REASON(R)                                        \\\n  do {                                                                         \\\n    fprintf(stderr, \"Error: %s\\n\", R);                                         \\\n    JFS_RUNTIME_FAIL();                                                        \\\n  } while (0);\n\n#ifdef ENABLE_JFS_RUNTIME_ASSERTS\n#define jassert(X)                                                             \\\n  do {                                                                         \\\n    if (!(X)) {                                                                \\\n      fprintf(stderr, \"JFS runtime assertion failure `%s` at %s:%d\\n\", #X,     \\\n              __FILE__, __LINE__);                                             \\\n      JFS_RUNTIME_FAIL();                                                      \\\n    }                                                                          \\\n  } while (0)\n#else\n// No-op\n#define jassert(X)\n#endif\n\n#endif\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n\nadd_jfs_unit_test(BitVector\n  Native/BvAShr.cpp\n  Native/BvAlloc.cpp\n  Native/BvAdd.cpp\n  Native/BvAnd.cpp\n  Native/BvComp.cpp\n  Native/BvLShr.cpp\n  Native/BvMul.cpp\n  Native/BvNand.cpp\n  Native/BvNeg.cpp\n  Native/BvNor.cpp\n  Native/BvNot.cpp\n  Native/BvOr.cpp\n  Native/BvShl.cpp\n  Native/BvSub.cpp\n  Native/BvUDiv.cpp\n  Native/BvSDiv.cpp\n  Native/BvSRem.cpp\n  Native/BvSMod.cpp\n  Native/BvSge.cpp\n  Native/BvSgt.cpp\n  Native/BvSlt.cpp\n  Native/BvSle.cpp\n  Native/BvUgt.cpp\n  Native/BvUge.cpp\n  Native/BvUle.cpp\n  Native/BvUlt.cpp\n  Native/BvXor.cpp\n  Native/BvXNor.cpp\n  Native/Concat.cpp\n  Native/Equal.cpp\n  Native/Extract.cpp\n  Native/MakeFromBuffer.cpp\n  Native/ZeroExtend.cpp\n  Native/SignExtend.cpp\n  Native/RotateLeft.cpp\n  Native/RotateRight.cpp\n  Native/WriteToBuffer.cpp\n  NonNative/Concat.cpp\n  NonNative/ZeroExtend.cpp\n  NonNative/SignExtend.cpp\n)\ntarget_link_libraries(BitVector${UNIT_TEST_EXE_SUFFIX} PRIVATE JFSSMTLIBRuntime)\ntarget_link_libraries(BitVector${UNIT_TEST_EXE_SUFFIX} PRIVATE JFSSMTLIBRuntimeTestUtil)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvAShr.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"SMTLIBRuntimeTestUtil.h\"\n#include \"gtest/gtest.h\"\n\n#define BVASHR_BRUTE(N)                                                        \\\n  TEST(bvashr, BruteForceBv##N) {                                              \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        uint64_t mask = (UINT64_C(1) << N) - 1;                                \\\n        int64_t xAsSigned =                                                    \\\n            jfs::smtlib_runtime_test_util::to_signed_value(x, N);              \\\n        int64_t yAsSigned =                                                    \\\n            jfs::smtlib_runtime_test_util::to_signed_value(y, N);              \\\n        int64_t expected = 0;                                                  \\\n        if (yAsSigned >= 0 && yAsSigned < N) {                                 \\\n          expected = (xAsSigned >> yAsSigned);                                 \\\n        } else if (xAsSigned < 0) {                                            \\\n          /* SMTLIB's definition means if we overshift the result              \\\n           * will be all ones */                                               \\\n          expected = -1;                                                       \\\n        } else {                                                               \\\n          /* SMTLIB's definition means if we overshift the result              \\\n           * will be 0 */                                                      \\\n          expected = 0;                                                        \\\n        }                                                                      \\\n        uint64_t expectedBits =                                                \\\n            jfs::smtlib_runtime_test_util::to_expected_bits_from_signed_value( \\\n                expected, N);                                                  \\\n        BitVector<N> result = xBv.bvashr(yBv);                                 \\\n        ASSERT_EQ(result, expectedBits);                                       \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVASHR_BRUTE(1);\nBVASHR_BRUTE(2);\nBVASHR_BRUTE(3);\nBVASHR_BRUTE(4);\nBVASHR_BRUTE(5);\nBVASHR_BRUTE(6);\nBVASHR_BRUTE(7);\nBVASHR_BRUTE(8);\nBVASHR_BRUTE(9);\nBVASHR_BRUTE(10);\n\n#define BVASHR(N, X, Y, E)                                                     \\\n  TEST(bvashr, AShr##N##_##X##_##Y) {                                          \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvashr(y), E);                                                 \\\n  }\n// TODO: Add more tests\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvAdd.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVADD_BRUTE(N)                                                         \\\n  TEST(bvadd, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        uint64_t expected = (x + y) % (1 << N);                                \\\n        EXPECT_EQ(xBv.bvadd(yBv), expected);                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVADD_BRUTE(1);\nBVADD_BRUTE(2);\nBVADD_BRUTE(3);\nBVADD_BRUTE(4);\nBVADD_BRUTE(5);\nBVADD_BRUTE(6);\nBVADD_BRUTE(7);\nBVADD_BRUTE(8);\nBVADD_BRUTE(9);\nBVADD_BRUTE(10);\n\n#define BVADD(N, X, Y, E)                                                      \\\n  TEST(bvadd, Add##N##_##X##_##Y) {                                            \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvadd(y), E);                                                  \\\n  }\n\n// Bv64\nBVADD(64, 0, 0, 0)\n// Simple addition\nBVADD(64, 0, 1, 1)\nBVADD(64, 1, 0, 1)\n// Overflow\nBVADD(64, UINT64_MAX, 1, 0)\nBVADD(64, 1, UINT64_MAX, 0)\nBVADD(64, UINT64_MAX, 2, 1)\nBVADD(64, 2, UINT64_MAX, 1)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvAlloc.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n#include <stdint.h>\n\nTEST(bvalloc, defaultZero8) {\n  BitVector<8> x;\n  EXPECT_EQ(x, 0);\n}\n\nTEST(bvalloc, maxValue8) {\n  BitVector<8> x(255);\n  EXPECT_EQ(x, 255);\n}\n\nTEST(bvalloc, defaultZero64) {\n  BitVector<64> x;\n  EXPECT_EQ(x, 0);\n}\n\nTEST(bvalloc, maxValue64) {\n  BitVector<64> x(UINT64_MAX);\n  EXPECT_EQ(x, UINT64_MAX);\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvAnd.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVAND_BRUTE(N)                                                         \\\n  TEST(bvand, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        uint64_t expected = (x & y);                                           \\\n        EXPECT_EQ(xBv.bvand(yBv), expected);                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVAND_BRUTE(1);\nBVAND_BRUTE(2);\nBVAND_BRUTE(3);\nBVAND_BRUTE(4);\nBVAND_BRUTE(5);\nBVAND_BRUTE(6);\nBVAND_BRUTE(7);\nBVAND_BRUTE(8);\nBVAND_BRUTE(9);\nBVAND_BRUTE(10);\n\n#define BVAND(N, X, Y, E)                                                      \\\n  TEST(bvand, And##N##_##X##_##Y) {                                            \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvand(y), E);                                                  \\\n  }\n// Bv64\nBVAND(64, 0, 0, 0)\n// Simple and\nBVAND(64, 8, 9, 8)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvComp.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVCOMP_BRUTE(N)                                                        \\\n  TEST(bvcomp, BruteForceBv##N) {                                              \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        if (x == y) {                                                          \\\n          ASSERT_EQ(xBv.bvcomp(yBv), BitVector<1>(1));                         \\\n        } else {                                                               \\\n          ASSERT_EQ(xBv.bvcomp(yBv), BitVector<1>(0));                         \\\n        }                                                                      \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVCOMP_BRUTE(1);\nBVCOMP_BRUTE(2);\nBVCOMP_BRUTE(3);\nBVCOMP_BRUTE(4);\nBVCOMP_BRUTE(5);\nBVCOMP_BRUTE(6);\nBVCOMP_BRUTE(7);\nBVCOMP_BRUTE(8);\nBVCOMP_BRUTE(9);\nBVCOMP_BRUTE(10);\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvLShr.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVLSHR_BRUTE(N)                                                        \\\n  TEST(bvlshr, BruteForceBv##N) {                                              \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        uint64_t mask = (UINT64_C(1) << N) - 1;                                \\\n        uint64_t expected = (y >= N) ? 0 : ((x >> y) & mask);                  \\\n        EXPECT_EQ(xBv.bvlshr(yBv), expected);                                  \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVLSHR_BRUTE(1);\nBVLSHR_BRUTE(2);\nBVLSHR_BRUTE(3);\nBVLSHR_BRUTE(4);\nBVLSHR_BRUTE(5);\nBVLSHR_BRUTE(6);\nBVLSHR_BRUTE(7);\nBVLSHR_BRUTE(8);\nBVLSHR_BRUTE(9);\nBVLSHR_BRUTE(10);\n\n#define BVLSHR(N, X, Y, E)                                                     \\\n  TEST(bvlshr, LShr##N##_##X##_##Y) {                                          \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvlshr(y), E);                                                 \\\n  }\n// Bv8\nBVLSHR(8, 255, 1, 127)\nBVLSHR(8, 255, 2, 63)\n\n// Bv64\nBVLSHR(64, 0, 0, 0)\n// Simple shifts\nBVLSHR(64, 1, 1, 0)\nBVLSHR(64, 1, 2, 0)\nBVLSHR(64, 1, 3, 0)\nBVLSHR(64, 1, 4, 0)\n\n// Overshift\nBVLSHR(64, 1, 64, 0)\nBVLSHR(64, 1, 65, 0)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvMul.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVMUL_BRUTE(N)                                                         \\\n  TEST(bvmul, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        uint64_t expected = (x * y) % (1 << N);                                \\\n        EXPECT_EQ(xBv.bvmul(yBv), expected);                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVMUL_BRUTE(1);\nBVMUL_BRUTE(2);\nBVMUL_BRUTE(3);\nBVMUL_BRUTE(4);\nBVMUL_BRUTE(5);\nBVMUL_BRUTE(6);\nBVMUL_BRUTE(7);\nBVMUL_BRUTE(8);\nBVMUL_BRUTE(9);\nBVMUL_BRUTE(10);\n\n#define BVMUL(N, X, Y, E)                                                      \\\n  TEST(bvmul, Mul##N##_##X##_##Y) {                                            \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvmul(y), E);                                                  \\\n  }\n// Bv64\nBVMUL(64, 0, 0, 0)\n// Simple multiplication\nBVMUL(64, 0, 1, 0)\nBVMUL(64, 1, 0, 0)\nBVMUL(64, 1, 1, 1)\nBVMUL(64, 2, 1, 2)\nBVMUL(64, 1, 2, 2)\n// Overflow\nBVMUL(64, UINT64_MAX, 2, UINT64_MAX - 1)\nBVMUL(64, 2, UINT64_MAX, UINT64_MAX - 1)\nBVMUL(64, UINT64_MAX, 3, UINT64_MAX - 2)\nBVMUL(64, 3, UINT64_MAX, UINT64_MAX - 2)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvNand.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVNAND_BRUTE(N)                                                        \\\n  TEST(bvnand, BruteForceBv##N) {                                              \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        uint64_t mask = (1 << N) - 1;                                          \\\n        uint64_t expected = (~(x & y)) & mask;                                 \\\n        EXPECT_EQ(xBv.bvnand(yBv), expected);                                  \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVNAND_BRUTE(1);\nBVNAND_BRUTE(2);\nBVNAND_BRUTE(3);\nBVNAND_BRUTE(4);\nBVNAND_BRUTE(5);\nBVNAND_BRUTE(6);\nBVNAND_BRUTE(7);\nBVNAND_BRUTE(8);\nBVNAND_BRUTE(9);\nBVNAND_BRUTE(10);\n\n#define BVNAND(N, X, Y, E)                                                     \\\n  TEST(bvnand, Nand##N##_##X##_##Y) {                                          \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvnand(y), E);                                                 \\\n  }\n// Bv64\nBVNAND(64, 0, 0, UINT64_MAX)\n// Simple and\nBVNAND(64, 8, 9, 0xfffffffffffffff7UL)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvNeg.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVNEG_BRUTE(N)                                                         \\\n  TEST(bvneg, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      BitVector<N> xBv(x);                                                     \\\n      static_assert(N < 64, \"not safe\");                                       \\\n      uint64_t mask = (UINT64_C(1) << N) - 1;                                  \\\n      uint64_t expected = (x == 0) ? (0) : (((~x) & mask) + 1);                \\\n      EXPECT_EQ(xBv.bvneg(), expected);                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVNEG_BRUTE(1);\nBVNEG_BRUTE(2);\nBVNEG_BRUTE(3);\nBVNEG_BRUTE(4);\nBVNEG_BRUTE(5);\nBVNEG_BRUTE(6);\nBVNEG_BRUTE(7);\nBVNEG_BRUTE(8);\nBVNEG_BRUTE(9);\nBVNEG_BRUTE(10);\n\n#define BVNEG(N, X, E)                                                         \\\n  TEST(bvneg, BvNeg##N##_##X) {                                                \\\n    BitVector<N> x(X);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(x.bvneg(), E);                                                   \\\n  }\n\n// Bv16\nBVNEG(16, 0, 0)\nBVNEG(16, 1, (UINT64_C(1) << 16) - 1)\nBVNEG(16, 2, (UINT64_C(1) << 16) - 2)\n\n// Bv64\nBVNEG(64, 0, 0)\nBVNEG(64, 1, UINT64_MAX)\nBVNEG(64, UINT64_MAX, 1)\n// 18446744073709551614 == (UINT64_MAX - 1)\nBVNEG(64, 18446744073709551614UL, 2)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvNor.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVNOR_BRUTE(N)                                                         \\\n  TEST(bvnor, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        uint64_t mask = (1 << N) - 1;                                          \\\n        uint64_t expected = (~(x | y)) & mask;                                 \\\n        EXPECT_EQ(xBv.bvnor(yBv), expected);                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVNOR_BRUTE(1);\nBVNOR_BRUTE(2);\nBVNOR_BRUTE(3);\nBVNOR_BRUTE(4);\nBVNOR_BRUTE(5);\nBVNOR_BRUTE(6);\nBVNOR_BRUTE(7);\nBVNOR_BRUTE(8);\nBVNOR_BRUTE(9);\nBVNOR_BRUTE(10);\n\n#define BVNOR(N, X, Y, E)                                                      \\\n  TEST(bvnor, Nor##N##_##X##_##Y) {                                            \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvnor(y), E);                                                  \\\n  }\n// Bv64\nBVNOR(64, 0, 0, UINT64_MAX)\nBVNOR(64, 8, 9, 0xfffffffffffffff6UL)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvNot.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVNOT_BRUTE(N)                                                         \\\n  TEST(bvnot, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      BitVector<N> xBv(x);                                                     \\\n      uint64_t mask = (UINT64_C(1) << N) - 1;                                  \\\n      uint64_t expected = (~x) & mask;                                         \\\n      EXPECT_EQ(xBv.bvnot(), expected);                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVNOT_BRUTE(1);\nBVNOT_BRUTE(2);\nBVNOT_BRUTE(3);\nBVNOT_BRUTE(4);\nBVNOT_BRUTE(5);\nBVNOT_BRUTE(6);\nBVNOT_BRUTE(7);\nBVNOT_BRUTE(8);\nBVNOT_BRUTE(9);\nBVNOT_BRUTE(10);\n\n#define BVNOT(N, X, E)                                                         \\\n  TEST(bvnot, Not##N##_##X) {                                                  \\\n    BitVector<N> x(X);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(x.bvnot(), E);                                                   \\\n  }\n// Bv64\nBVNOT(64, 0, UINT64_MAX)\n// 18446744073709551615 == UINT64_MAX\nBVNOT(64, 18446744073709551615UL, 0)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvOr.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVOR_BRUTE(N)                                                          \\\n  TEST(bvor, BruteForceBv##N) {                                                \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        uint64_t expected = (x | y);                                           \\\n        EXPECT_EQ(xBv.bvor(yBv), expected);                                    \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVOR_BRUTE(1);\nBVOR_BRUTE(2);\nBVOR_BRUTE(3);\nBVOR_BRUTE(4);\nBVOR_BRUTE(5);\nBVOR_BRUTE(6);\nBVOR_BRUTE(7);\nBVOR_BRUTE(8);\nBVOR_BRUTE(9);\nBVOR_BRUTE(10);\n\n#define BVOR(N, X, Y, E)                                                       \\\n  TEST(bvor, Or##N##_##X##_##Y) {                                              \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvor(y), E);                                                   \\\n  }\n// Bv64\nBVOR(64, 0, 0, 0)\n// Simple and\nBVOR(64, 8, 9, 9)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvSDiv.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"SMTLIBRuntimeTestUtil.h\"\n#include \"gtest/gtest.h\"\n\nuint64_t getNegBits(uint64_t v, uint64_t N) {\n  uint64_t mask = (UINT64_C(1) << N) - 1;\n  return ((~v) + 1) & mask;\n}\n\n// FIXME: Use\n// jfs::smtlib_runtime_test_util::to_expected_bits_from_signed_value()\n#define BVSDIV_BRUTE(N)                                                        \\\n  TEST(bvsdiv, BruteForceBv##N) {                                              \\\n    assert(N < 64 && \"too many bits\");                                         \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        uint64_t mask = (UINT64_C(1) << N) - 1;                                \\\n        int64_t negativeMSB = (int64_t(UINT64_C(1) << (N - 1))) * -1;          \\\n        uint64_t maskOnlyPositiveBits = mask >> 1;                             \\\n        int64_t xAsSigned =                                                    \\\n            jfs::smtlib_runtime_test_util::to_signed_value(x, N);              \\\n        int64_t yAsSigned =                                                    \\\n            jfs::smtlib_runtime_test_util::to_signed_value(y, N);              \\\n        /* SMT-LIB returns all ones if division by zero with bvudiv but        \\\n           their definition means that if the dividend is negative then the    \\\n           result of bvudiv gets negated giving `1`.*/                         \\\n        int64_t divByZeroRetValue =                                            \\\n            (xAsSigned < 0) ? 1 : ((UINT64_C(1) << N) - 1);                    \\\n        int64_t expected =                                                     \\\n            (yAsSigned == 0) ? divByZeroRetValue : (xAsSigned / yAsSigned);    \\\n        uint64_t expectedBits = (expected < 0) ? getNegBits(expected * -1, N)  \\\n                                               : ((uint64_t)expected);         \\\n        BitVector<N> result = xBv.bvsdiv(yBv);                                 \\\n        EXPECT_EQ(result, expectedBits);                                       \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVSDIV_BRUTE(1);\nBVSDIV_BRUTE(2);\nBVSDIV_BRUTE(3);\nBVSDIV_BRUTE(4);\nBVSDIV_BRUTE(5);\nBVSDIV_BRUTE(6);\nBVSDIV_BRUTE(7);\nBVSDIV_BRUTE(8);\nBVSDIV_BRUTE(9);\nBVSDIV_BRUTE(10);\n\n#define BVSDIV(N, X, Y, E)                                                     \\\n  TEST(bvsdiv, SDiv##N##_##X##_##Y) {                                          \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvsdiv(y), E);                                                 \\\n  }\n// TODO: Test some values using the macro\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvSMod.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVSMOD(N, X, Y, E)                                                     \\\n  TEST(bvsmod, SMod##N##_##X##_##Y) {                                          \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvsmod(y), E);                                                 \\\n  }\n\n/* NOTE: Can use SMT solver to generate test values\n (declare-fun x () (_ BitVec 3))\n (assert (= x (bvsrem (_ bv7 3) (_ bv5 3))))\n (check-sat)\n (get-model)\n*/\n\n// Division by zero\nBVSMOD(3, 0, 0, 0)\nBVSMOD(3, 1, 0, 1)\nBVSMOD(3, 2, 0, 2)\nBVSMOD(3, 3, 0, 3)\nBVSMOD(3, 4, 0, 4)\nBVSMOD(3, 5, 0, 5)\nBVSMOD(3, 6, 0, 6)\nBVSMOD(3, 7, 0, 7)\n\n// +ve operands\nBVSMOD(3, 0, 1, 0)\nBVSMOD(3, 1, 1, 0)\nBVSMOD(3, 0, 2, 0)\nBVSMOD(3, 1, 2, 1)\nBVSMOD(3, 2, 2, 0)\nBVSMOD(3, 3, 2, 1)\n\n// lhs -ve, rhs +ve\nBVSMOD(3, 4, 2, 0)\nBVSMOD(3, 5, 2, 1)\nBVSMOD(3, 6, 2, 0)\nBVSMOD(3, 7, 2, 1)\n\n// lhs +ve, rhs -ve\nBVSMOD(3, 0, 5, 0)\nBVSMOD(3, 1, 5, 6)\nBVSMOD(3, 2, 5, 7)\nBVSMOD(3, 3, 5, 0)\n\n// lhs -ve, rhs -ve\nBVSMOD(3, 4, 5, 7)\nBVSMOD(3, 5, 5, 0)\nBVSMOD(3, 6, 5, 6)\nBVSMOD(3, 7, 5, 7)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvSRem.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVSREM(N, X, Y, E)                                                     \\\n  TEST(bvsrem, SRem##N##_##X##_##Y) {                                          \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvsrem(y), E);                                                 \\\n  }\n\n/* NOTE: Can use SMT solver to generate test values\n (declare-fun x () (_ BitVec 3))\n (assert (= x (bvsrem (_ bv7 3) (_ bv5 3))))\n (check-sat)\n (get-model)\n*/\n\n// Division by zero\nBVSREM(3, 0, 0, 0)\nBVSREM(3, 1, 0, 1)\nBVSREM(3, 2, 0, 2)\nBVSREM(3, 3, 0, 3)\nBVSREM(3, 4, 0, 4)\nBVSREM(3, 5, 0, 5)\nBVSREM(3, 6, 0, 6)\nBVSREM(3, 7, 0, 7)\n\n// +ve operands\nBVSREM(3, 0, 1, 0)\nBVSREM(3, 1, 1, 0)\nBVSREM(3, 0, 2, 0)\nBVSREM(3, 1, 2, 1)\nBVSREM(3, 2, 2, 0)\nBVSREM(3, 3, 2, 1)\n\n// lhs -ve, rhs +ve\nBVSREM(3, 4, 2, 0)\nBVSREM(3, 5, 2, 7)\nBVSREM(3, 6, 2, 0)\nBVSREM(3, 7, 2, 7)\n\n// lhs +ve, rhs -ve\nBVSREM(3, 0, 5, 0)\nBVSREM(3, 1, 5, 1)\nBVSREM(3, 2, 5, 2)\nBVSREM(3, 3, 5, 0)\n\n// lhs -ve, rhs -ve\nBVSREM(3, 4, 5, 7)\nBVSREM(3, 5, 5, 0)\nBVSREM(3, 6, 5, 6)\nBVSREM(3, 7, 5, 7)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvSge.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"SMTLIBRuntimeTestUtil.h\"\n#include \"gtest/gtest.h\"\n\n#define BVSGE_BRUTE(N)                                                         \\\n  TEST(bvsge, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        int64_t xAsSigned =                                                    \\\n            jfs::smtlib_runtime_test_util::to_signed_value(x, N);              \\\n        int64_t yAsSigned =                                                    \\\n            jfs::smtlib_runtime_test_util::to_signed_value(y, N);              \\\n        bool expected = xAsSigned >= yAsSigned;                                \\\n        ASSERT_EQ(xBv.bvsge(yBv), expected);                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVSGE_BRUTE(1);\nBVSGE_BRUTE(2);\nBVSGE_BRUTE(3);\nBVSGE_BRUTE(4);\nBVSGE_BRUTE(5);\nBVSGE_BRUTE(6);\nBVSGE_BRUTE(7);\nBVSGE_BRUTE(8);\nBVSGE_BRUTE(9);\nBVSGE_BRUTE(10);\n\n#define BVSGE(N, X, Y, E)                                                      \\\n  TEST(bvsge, Cmp##N##_##X##_##Y) {                                            \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvsge(y), E);                                                  \\\n  }\n// Bv64\nBVSGE(64, 0, 0, true)\nBVSGE(64, 1, 0, true)\nBVSGE(64, 0, 1, false)\nBVSGE(64, 1, 1, true)\nBVSGE(64, UINT64_MAX, 1, false)\nBVSGE(64, 1, UINT64_MAX, true)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvSgt.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"SMTLIBRuntimeTestUtil.h\"\n#include \"gtest/gtest.h\"\n\n#define BVSGT_BRUTE(N)                                                         \\\n  TEST(bvsgt, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        int64_t xAsSigned =                                                    \\\n            jfs::smtlib_runtime_test_util::to_signed_value(x, N);              \\\n        int64_t yAsSigned =                                                    \\\n            jfs::smtlib_runtime_test_util::to_signed_value(y, N);              \\\n        bool expected = xAsSigned > yAsSigned;                                 \\\n        ASSERT_EQ(xBv.bvsgt(yBv), expected);                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVSGT_BRUTE(1);\nBVSGT_BRUTE(2);\nBVSGT_BRUTE(3);\nBVSGT_BRUTE(4);\nBVSGT_BRUTE(5);\nBVSGT_BRUTE(6);\nBVSGT_BRUTE(7);\nBVSGT_BRUTE(8);\nBVSGT_BRUTE(9);\nBVSGT_BRUTE(10);\n\n#define BVSGT(N, X, Y, E)                                                      \\\n  TEST(bvsgt, Cmp##N##_##X##_##Y) {                                            \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvsgt(y), E);                                                  \\\n  }\n// Bv64\nBVSGT(64, 0, 0, false)\nBVSGT(64, 1, 0, true)\nBVSGT(64, 0, 1, false)\nBVSGT(64, 1, 1, false)\nBVSGT(64, UINT64_MAX, 1, false)\nBVSGT(64, 1, UINT64_MAX, true)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvShl.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVSHL_BRUTE(N)                                                         \\\n  TEST(bvshl, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        uint64_t mask = (UINT64_C(1) << N) - 1;                                \\\n        uint64_t expected = (y >= N) ? 0 : ((x << y) & mask);                  \\\n        EXPECT_EQ(xBv.bvshl(yBv), expected);                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVSHL_BRUTE(1);\nBVSHL_BRUTE(2);\nBVSHL_BRUTE(3);\nBVSHL_BRUTE(4);\nBVSHL_BRUTE(5);\nBVSHL_BRUTE(6);\nBVSHL_BRUTE(7);\nBVSHL_BRUTE(8);\nBVSHL_BRUTE(9);\nBVSHL_BRUTE(10);\n\n#define BVSHL(N, X, Y, E)                                                      \\\n  TEST(bvshl, Shl##N##_##X##_##Y) {                                            \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvshl(y), E);                                                  \\\n  }\n\n// Bv8\nBVSHL(8, 255, 1, 254)\nBVSHL(8, 255, 2, 252)\n\n// Bv64\nBVSHL(64, 0, 0, 0)\n// Simple shifts\nBVSHL(64, 1, 1, 2)\nBVSHL(64, 1, 2, 4)\nBVSHL(64, 1, 3, 8)\nBVSHL(64, 1, 4, 16)\n\n// Overshift\nBVSHL(64, 1, 64, 0)\nBVSHL(64, 1, 65, 0)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvSle.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"SMTLIBRuntimeTestUtil.h\"\n#include \"gtest/gtest.h\"\n\n#define BVSLE_BRUTE(N)                                                         \\\n  TEST(bvsle, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        int64_t xAsSigned =                                                    \\\n            jfs::smtlib_runtime_test_util::to_signed_value(x, N);              \\\n        int64_t yAsSigned =                                                    \\\n            jfs::smtlib_runtime_test_util::to_signed_value(y, N);              \\\n        bool expected = xAsSigned <= yAsSigned;                                \\\n        ASSERT_EQ(xBv.bvsle(yBv), expected);                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVSLE_BRUTE(1);\nBVSLE_BRUTE(2);\nBVSLE_BRUTE(3);\nBVSLE_BRUTE(4);\nBVSLE_BRUTE(5);\nBVSLE_BRUTE(6);\nBVSLE_BRUTE(7);\nBVSLE_BRUTE(8);\nBVSLE_BRUTE(9);\nBVSLE_BRUTE(10);\n\n#define BVSLE(N, X, Y, E)                                                      \\\n  TEST(bvsle, Cmp##N##_##X##_##Y) {                                            \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvsle(y), E);                                                  \\\n  }\n// Bv64\nBVSLE(64, 0, 0, true)\nBVSLE(64, 1, 0, false)\nBVSLE(64, 0, 1, true)\nBVSLE(64, 1, 1, true)\nBVSLE(64, UINT64_MAX, 1, true)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvSlt.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"SMTLIBRuntimeTestUtil.h\"\n#include \"gtest/gtest.h\"\n\n#define BVSLT_BRUTE(N)                                                         \\\n  TEST(bvslt, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        int64_t xAsSigned =                                                    \\\n            jfs::smtlib_runtime_test_util::to_signed_value(x, N);              \\\n        int64_t yAsSigned =                                                    \\\n            jfs::smtlib_runtime_test_util::to_signed_value(y, N);              \\\n        bool expected = xAsSigned < yAsSigned;                                 \\\n        ASSERT_EQ(xBv.bvslt(yBv), expected);                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVSLT_BRUTE(1);\nBVSLT_BRUTE(2);\nBVSLT_BRUTE(3);\nBVSLT_BRUTE(4);\nBVSLT_BRUTE(5);\nBVSLT_BRUTE(6);\nBVSLT_BRUTE(7);\nBVSLT_BRUTE(8);\nBVSLT_BRUTE(9);\nBVSLT_BRUTE(10);\n\n#define BVSLT(N, X, Y, E)                                                      \\\n  TEST(bvslt, Cmp##N##_##X##_##Y) {                                            \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvslt(y), E);                                                  \\\n  }\n// Bv64\nBVSLT(64, 0, 0, false)\nBVSLT(64, 1, 0, false)\nBVSLT(64, 0, 1, true)\nBVSLT(64, 1, 1, false)\nBVSLT(64, UINT64_MAX, 1, true)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvSub.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVSUB_BRUTE(N)                                                         \\\n  TEST(bvsub, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        uint64_t expected = (x - y) % (1 << N);                                \\\n        EXPECT_EQ(xBv.bvsub(yBv), expected);                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVSUB_BRUTE(1);\nBVSUB_BRUTE(2);\nBVSUB_BRUTE(3);\nBVSUB_BRUTE(4);\nBVSUB_BRUTE(5);\nBVSUB_BRUTE(6);\nBVSUB_BRUTE(7);\nBVSUB_BRUTE(8);\nBVSUB_BRUTE(9);\nBVSUB_BRUTE(10);\n\n#define BVSUB(N, X, Y, E)                                                      \\\n  TEST(bvsub, Sub##N##_##X##_##Y) {                                            \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvsub(y), E);                                                  \\\n  }\n// Bv64\nBVSUB(64, 0, 0, 0)\n// Simple subtraction\nBVSUB(64, 1, 0, 1)\n// Underflow\nBVSUB(64, 0, 1, UINT64_MAX)\nBVSUB(64, 0, 2, UINT64_MAX - 1)\nBVSUB(64, 0, 3, UINT64_MAX - 2)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvUDiv.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVUDIV_BRUTE(N)                                                        \\\n  TEST(bvudiv, BruteForceBv##N) {                                              \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        uint64_t expected = (y == 0) ? ((1 << N) - 1) : (x / y);               \\\n        EXPECT_EQ(xBv.bvudiv(yBv), expected);                                  \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVUDIV_BRUTE(1);\nBVUDIV_BRUTE(2);\nBVUDIV_BRUTE(3);\nBVUDIV_BRUTE(4);\nBVUDIV_BRUTE(5);\nBVUDIV_BRUTE(6);\nBVUDIV_BRUTE(7);\nBVUDIV_BRUTE(8);\nBVUDIV_BRUTE(9);\nBVUDIV_BRUTE(10);\n\n#define BVUDIV(N, X, Y, E)                                                     \\\n  TEST(bvudiv, UDiv##N##_##X##_##Y) {                                          \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvudiv(y), E);                                                 \\\n  }\n// Bv64\nBVUDIV(64, 0, 0, UINT64_MAX)\n// Simple divisor\nBVUDIV(64, 0, 1, 0)\nBVUDIV(64, 1, 0, UINT64_MAX)\nBVUDIV(64, 1, 1, 1)\nBVUDIV(64, 2, 1, 2)\nBVUDIV(64, 1, 2, 0)\nBVUDIV(64, 256, 7, 36)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvURem.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVUREM_BRUTE(N)                                                        \\\n  TEST(bvurem, BruteForceBv##N) {                                              \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        uint64_t expected = (y == 0) ? (x) : (x % y);                          \\\n        EXPECT_EQ(xBv.bvurem(yBv), expected);                                  \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVUREM_BRUTE(1);\nBVUREM_BRUTE(2);\nBVUREM_BRUTE(3);\nBVUREM_BRUTE(4);\nBVUREM_BRUTE(5);\nBVUREM_BRUTE(6);\nBVUREM_BRUTE(7);\nBVUREM_BRUTE(8);\nBVUREM_BRUTE(9);\nBVUREM_BRUTE(10);\n\n#define BVUREM(N, X, Y, E)                                                     \\\n  TEST(bvurem, URem##N##_##X##_##Y) {                                          \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvurem(y), E);                                                 \\\n  }\n\n// Bv64\nBVUREM(64, 0, 0, 0)\n// Simple divisor\nBVUREM(64, 0, 1, 0)\nBVUREM(64, 1, 0, 1)\nBVUREM(64, 1, 1, 0)\nBVUREM(64, 2, 1, 0)\nBVUREM(64, 1, 2, 1)\nBVUREM(64, 256, 7, 4)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvUge.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVUGE_BRUTE(N)                                                         \\\n  TEST(bvuge, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        bool expected = x >= y;                                                \\\n        EXPECT_EQ(xBv.bvuge(yBv), expected);                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVUGE_BRUTE(1);\nBVUGE_BRUTE(2);\nBVUGE_BRUTE(3);\nBVUGE_BRUTE(4);\nBVUGE_BRUTE(5);\nBVUGE_BRUTE(6);\nBVUGE_BRUTE(7);\nBVUGE_BRUTE(8);\nBVUGE_BRUTE(9);\nBVUGE_BRUTE(10);\n\n#define BVUGE(N, X, Y, E)                                                      \\\n  TEST(bvuge, Cmp##N##_##X##_##Y) {                                            \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvuge(y), E);                                                  \\\n  }\n// Bv64\nBVUGE(64, 0, 0, true)\nBVUGE(64, 1, 0, true)\nBVUGE(64, 0, 1, false)\nBVUGE(64, 1, 1, true)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvUgt.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVUGT_BRUTE(N)                                                         \\\n  TEST(bvugt, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        bool expected = x > y;                                                 \\\n        EXPECT_EQ(xBv.bvugt(yBv), expected);                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVUGT_BRUTE(1);\nBVUGT_BRUTE(2);\nBVUGT_BRUTE(3);\nBVUGT_BRUTE(4);\nBVUGT_BRUTE(5);\nBVUGT_BRUTE(6);\nBVUGT_BRUTE(7);\nBVUGT_BRUTE(8);\nBVUGT_BRUTE(9);\nBVUGT_BRUTE(10);\n\n#define BVUGT(N, X, Y, E)                                                      \\\n  TEST(bvugt, Cmp##N##_##X##_##Y) {                                            \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvugt(y), E);                                                  \\\n  }\n// Bv64\nBVUGT(64, 0, 0, false)\nBVUGT(64, 1, 0, true)\nBVUGT(64, 0, 1, false)\nBVUGT(64, 1, 1, false)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvUle.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVULE_BRUTE(N)                                                         \\\n  TEST(bvule, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        bool expected = x <= y;                                                \\\n        EXPECT_EQ(xBv.bvule(yBv), expected);                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVULE_BRUTE(1);\nBVULE_BRUTE(2);\nBVULE_BRUTE(3);\nBVULE_BRUTE(4);\nBVULE_BRUTE(5);\nBVULE_BRUTE(6);\nBVULE_BRUTE(7);\nBVULE_BRUTE(8);\nBVULE_BRUTE(9);\nBVULE_BRUTE(10);\n\n#define BVULE(N, X, Y, E)                                                      \\\n  TEST(bvule, Cmp##N##_##X##_##Y) {                                            \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvule(y), E);                                                  \\\n  }\n// Bv64\nBVULE(64, 0, 0, true)\nBVULE(64, 1, 0, false)\nBVULE(64, 0, 1, true)\nBVULE(64, 1, 1, true)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvUlt.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVULT_BRUTE(N)                                                         \\\n  TEST(bvult, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        bool expected = x < y;                                                 \\\n        EXPECT_EQ(xBv.bvult(yBv), expected);                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVULT_BRUTE(1);\nBVULT_BRUTE(2);\nBVULT_BRUTE(3);\nBVULT_BRUTE(4);\nBVULT_BRUTE(5);\nBVULT_BRUTE(6);\nBVULT_BRUTE(7);\nBVULT_BRUTE(8);\nBVULT_BRUTE(9);\nBVULT_BRUTE(10);\n\n#define BVULT(N, X, Y, E)                                                      \\\n  TEST(bvult, Cmp##N##_##X##_##Y) {                                            \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvult(y), E);                                                  \\\n  }\n// Bv64\nBVULT(64, 0, 0, false)\nBVULT(64, 1, 0, false)\nBVULT(64, 0, 1, true)\nBVULT(64, 1, 1, false)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvXNor.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVXNOR_BRUTE(N)                                                        \\\n  TEST(bvxnor, BruteForceBv##N) {                                              \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        uint64_t mask = (1 << N) - 1;                                          \\\n        uint64_t expected = ((~(x ^ y))) & mask;                               \\\n        EXPECT_EQ(xBv.bvxnor(yBv), expected);                                  \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVXNOR_BRUTE(1);\nBVXNOR_BRUTE(2);\nBVXNOR_BRUTE(3);\nBVXNOR_BRUTE(4);\nBVXNOR_BRUTE(5);\nBVXNOR_BRUTE(6);\nBVXNOR_BRUTE(7);\nBVXNOR_BRUTE(8);\nBVXNOR_BRUTE(9);\nBVXNOR_BRUTE(10);\n\n#define BVXNOR(N, X, Y, E)                                                     \\\n  TEST(bvxnor, XNor##N##_##X##_##Y) {                                          \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvxnor(y), E);                                                 \\\n  }\n// Bv64\nBVXNOR(64, 0, 0, UINT64_MAX)\n// UINT64_MAX - 1\nBVXNOR(64, 8, 9, 0xfffffffffffffffeUL)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/BvXor.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVXOR_BRUTE(N)                                                         \\\n  TEST(bvxor, BruteForceBv##N) {                                               \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        uint64_t mask = (1 << N) - 1;                                          \\\n        uint64_t expected = ((x ^ y)) & mask;                                  \\\n        EXPECT_EQ(xBv.bvxor(yBv), expected);                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nBVXOR_BRUTE(1);\nBVXOR_BRUTE(2);\nBVXOR_BRUTE(3);\nBVXOR_BRUTE(4);\nBVXOR_BRUTE(5);\nBVXOR_BRUTE(6);\nBVXOR_BRUTE(7);\nBVXOR_BRUTE(8);\nBVXOR_BRUTE(9);\nBVXOR_BRUTE(10);\n\n#define BVXOR(N, X, Y, E)                                                      \\\n  TEST(bvxor, Xor##N##_##X##_##Y) {                                            \\\n    BitVector<N> x(X);                                                         \\\n    BitVector<N> y(Y);                                                         \\\n    EXPECT_EQ(x, X);                                                           \\\n    EXPECT_EQ(y, Y);                                                           \\\n    EXPECT_EQ(x.bvxor(y), E);                                                  \\\n  }\n// Bv64\nBVXOR(64, 0, 0, 0)\nBVXOR(64, 8, 9, 1)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/Concat.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BVCONCAT_BRUTE(XW, YW)                                                 \\\n  TEST(bvconcat, concat_##XW##_##YW) {                                         \\\n    for (unsigned xvalue = 0; xvalue < (UINT64_C(1) << XW) - 1; ++xvalue) {    \\\n      for (unsigned yvalue = 0; yvalue < (UINT64_C(1) << YW) - 1; ++yvalue) {  \\\n        BitVector<XW> x(xvalue);                                               \\\n        BitVector<YW> y(yvalue);                                               \\\n        EXPECT_EQ(x, xvalue);                                                  \\\n        EXPECT_EQ(y, yvalue);                                                  \\\n        BitVector<XW + YW> result = x.concat(y);                               \\\n        uint64_t expected = (xvalue << YW) | yvalue;                           \\\n        EXPECT_EQ(result, expected);                                           \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// FIXME: Express this in a more compact way\n// Brute force the combinations\nBVCONCAT_BRUTE(1, 2)\nBVCONCAT_BRUTE(1, 3)\nBVCONCAT_BRUTE(1, 4)\nBVCONCAT_BRUTE(1, 5)\nBVCONCAT_BRUTE(1, 6)\nBVCONCAT_BRUTE(1, 7)\nBVCONCAT_BRUTE(1, 8)\nBVCONCAT_BRUTE(2, 1)\nBVCONCAT_BRUTE(2, 2)\nBVCONCAT_BRUTE(2, 3)\nBVCONCAT_BRUTE(2, 4)\nBVCONCAT_BRUTE(2, 5)\nBVCONCAT_BRUTE(2, 6)\nBVCONCAT_BRUTE(2, 7)\nBVCONCAT_BRUTE(2, 8)\nBVCONCAT_BRUTE(3, 1)\nBVCONCAT_BRUTE(3, 2)\nBVCONCAT_BRUTE(3, 3)\nBVCONCAT_BRUTE(3, 4)\nBVCONCAT_BRUTE(3, 5)\nBVCONCAT_BRUTE(3, 6)\nBVCONCAT_BRUTE(3, 7)\nBVCONCAT_BRUTE(3, 8)\nBVCONCAT_BRUTE(4, 1)\nBVCONCAT_BRUTE(4, 2)\nBVCONCAT_BRUTE(4, 3)\nBVCONCAT_BRUTE(4, 4)\nBVCONCAT_BRUTE(4, 5)\nBVCONCAT_BRUTE(4, 6)\nBVCONCAT_BRUTE(4, 7)\nBVCONCAT_BRUTE(4, 8)\nBVCONCAT_BRUTE(5, 1)\nBVCONCAT_BRUTE(5, 2)\nBVCONCAT_BRUTE(5, 3)\nBVCONCAT_BRUTE(5, 4)\nBVCONCAT_BRUTE(5, 5)\nBVCONCAT_BRUTE(5, 6)\nBVCONCAT_BRUTE(5, 7)\nBVCONCAT_BRUTE(5, 8)\nBVCONCAT_BRUTE(6, 1)\nBVCONCAT_BRUTE(6, 2)\nBVCONCAT_BRUTE(6, 3)\nBVCONCAT_BRUTE(6, 4)\nBVCONCAT_BRUTE(6, 5)\nBVCONCAT_BRUTE(6, 6)\nBVCONCAT_BRUTE(6, 7)\nBVCONCAT_BRUTE(6, 8)\nBVCONCAT_BRUTE(7, 1)\nBVCONCAT_BRUTE(7, 2)\nBVCONCAT_BRUTE(7, 3)\nBVCONCAT_BRUTE(7, 4)\nBVCONCAT_BRUTE(7, 5)\nBVCONCAT_BRUTE(7, 6)\nBVCONCAT_BRUTE(7, 7)\nBVCONCAT_BRUTE(7, 8)\nBVCONCAT_BRUTE(8, 1)\nBVCONCAT_BRUTE(8, 2)\nBVCONCAT_BRUTE(8, 3)\nBVCONCAT_BRUTE(8, 4)\nBVCONCAT_BRUTE(8, 5)\nBVCONCAT_BRUTE(8, 6)\nBVCONCAT_BRUTE(8, 7)\nBVCONCAT_BRUTE(8, 8)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/Equal.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define EQ_BRUTE(N)                                                            \\\n  TEST(bveq, BruteForceBv##N) {                                                \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        BitVector<N> yBv(y);                                                   \\\n        if (x == y) {                                                          \\\n          ASSERT_TRUE(xBv == yBv);                                             \\\n        } else {                                                               \\\n          ASSERT_TRUE(!(xBv == yBv));                                          \\\n        }                                                                      \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nEQ_BRUTE(1);\nEQ_BRUTE(2);\nEQ_BRUTE(3);\nEQ_BRUTE(4);\nEQ_BRUTE(5);\nEQ_BRUTE(6);\nEQ_BRUTE(7);\nEQ_BRUTE(8);\nEQ_BRUTE(9);\nEQ_BRUTE(10);\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/Extract.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n// FIXME: We need to use some macro tricks to try all possible\n// extraction values.\n#define BVEXTRACT_BRUTE(W)                                                     \\\n  TEST(bvextract, brute##W) {                                                  \\\n    for (unsigned value = 0; value < ((UINT64_C(1) << W) - 1); ++value) {      \\\n      BitVector<W> x(value);                                                   \\\n      auto noOp = x.extract<W>(W - 1, 0);                                      \\\n      ASSERT_EQ(noOp, value);                                                  \\\n    }                                                                          \\\n  }\n\nBVEXTRACT_BRUTE(1)\nBVEXTRACT_BRUTE(2)\nBVEXTRACT_BRUTE(3)\nBVEXTRACT_BRUTE(4)\nBVEXTRACT_BRUTE(5)\nBVEXTRACT_BRUTE(6)\nBVEXTRACT_BRUTE(7)\nBVEXTRACT_BRUTE(8)\n\nTEST(bvextract, simple) {\n  BitVector<4> x(10);\n  auto result = x.extract<2>(3, 2);\n  ASSERT_EQ(result, 2);\n  auto result2 = x.extract<4>(3, 0);\n  ASSERT_EQ(result2, 10);\n  auto result3 = x.extract<1>(3, 3);\n  ASSERT_EQ(result3, 1);\n  auto result4 = x.extract<3>(2, 0);\n  ASSERT_EQ(result4, 2);\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/MakeFromBuffer.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n#include <memory>\n#include <string.h>\n\nTEST(MakeFromBuffer, WholeBuffer64) {\n  uint8_t buffer[sizeof(uint64_t)];\n  uint64_t* view = reinterpret_cast<uint64_t*>(buffer);\n  *view = UINT64_MAX;\n  BufferRef<const uint8_t> bufferRef(buffer, sizeof(uint64_t));\n  BitVector<64> x = makeBitVectorFrom<64>(bufferRef, 0, 63);\n  ASSERT_EQ(x, UINT64_MAX);\n}\n\nTEST(MakeFromBuffer, HalfBuffer64) {\n  uint8_t buffer[sizeof(uint64_t)];\n  uint64_t* view = reinterpret_cast<uint64_t*>(buffer);\n  *view = (UINT64_MAX << 32); // Lower half is zero, upper half is all ones\n  BufferRef<const uint8_t> bufferRef(buffer, sizeof(uint64_t));\n  BitVector<32> lower = makeBitVectorFrom<32>(bufferRef, 0, 31);\n  ASSERT_EQ(lower, 0);\n  BitVector<32> upper = makeBitVectorFrom<32>(bufferRef, 32, 63);\n  ASSERT_EQ(upper, (UINT64_MAX >> 32));\n}\n\nTEST(MakeFromBuffer, IndividualBits) {\n  uint8_t buffer[1];\n  buffer[0] = 0b10000001;\n  BufferRef<const uint8_t> bufferRef(buffer, 1);\n#define CHECK_BIT(N, VALUE)                                                    \\\n  BitVector<1> bit##N = makeBitVectorFrom<1>(bufferRef, N, N);                 \\\n  ASSERT_EQ(bit##N, VALUE);\n  CHECK_BIT(0, 1)\n  CHECK_BIT(1, 0)\n  CHECK_BIT(2, 0)\n  CHECK_BIT(3, 0)\n  CHECK_BIT(4, 0)\n  CHECK_BIT(5, 0)\n  CHECK_BIT(6, 0)\n  CHECK_BIT(7, 1)\n#undef CHECK_BIT\n}\n\nTEST(MakeFromBuffer, NonByteAlignedOffset) {\n  uint8_t buffer[2];\n  buffer[0] = 0b11111111;\n  buffer[1] = 0b00000011;\n  BufferRef<const uint8_t> bufferRef(buffer, 2);\n  BitVector<2> a = makeBitVectorFrom<2>(bufferRef, 7, 8);\n  ASSERT_EQ(a, 3);\n  BitVector<3> b = makeBitVectorFrom<3>(bufferRef, 7, 9);\n  ASSERT_EQ(b, 7);\n  BitVector<4> c = makeBitVectorFrom<4>(bufferRef, 7, 10);\n  ASSERT_EQ(c, 7);\n  BitVector<6> d = makeBitVectorFrom<6>(bufferRef, 10, 15);\n  ASSERT_EQ(d, 0);\n}\n\nTEST(MakeFromBuffer, LargeBuffer) {\n  const size_t numBytes = 128;\n  std::unique_ptr<uint8_t, decltype(std::free)*> buffer(\n      reinterpret_cast<uint8_t*>(malloc(numBytes)), std::free);\n  // All ones\n  memset(buffer.get(), 255, numBytes);\n  BufferRef<const uint8_t> bufferRef(buffer.get(), numBytes);\n  for (unsigned bitOffset = 0; bitOffset <= ((numBytes * 8) - 8); ++bitOffset) {\n    BitVector<8> a = makeBitVectorFrom<8>(bufferRef, bitOffset, bitOffset + 7);\n    ASSERT_EQ(a, 255);\n  }\n}\n\n#define MAKE_FROM_LARGE(N, BUFFER_SIZE, ALL_BITS_ONE)                          \\\n  TEST(MakeFromBuffer, LargeBuffer_##N##_##BUFFER_SIZE##_##ALL_BITS_ONE) {     \\\n    const size_t numBytes = BUFFER_SIZE;                                       \\\n    static_assert(BUFFER_SIZE > 0, \"invalid buffer size\");                     \\\n    static_assert(N >= 0 && N <= 64, \"invalid N value\");                       \\\n    std::unique_ptr<uint8_t, decltype(std::free)*> buffer(                     \\\n        reinterpret_cast<uint8_t*>(malloc(numBytes)), std::free);              \\\n    if (ALL_BITS_ONE) {                                                        \\\n      memset(buffer.get(), 255, numBytes);                                     \\\n    } else {                                                                   \\\n      memset(buffer.get(), 0, numBytes);                                       \\\n    }                                                                          \\\n    ASSERT_LE(N, 64);                                                          \\\n    uint64_t maxValue = 0;                                                     \\\n    if (N >= 64) {                                                             \\\n      maxValue = UINT64_MAX;                                                   \\\n    } else {                                                                   \\\n      maxValue = (UINT64_MAX) >> (64 - N);                                     \\\n    }                                                                          \\\n                                                                               \\\n    BufferRef<const uint8_t> bufferRef(buffer.get(), numBytes);                \\\n    for (unsigned bitOffset = 0; bitOffset <= ((numBytes * 8) - N);            \\\n         ++bitOffset) {                                                        \\\n      const BitVector<N> a =                                                   \\\n          makeBitVectorFrom<N>(bufferRef, bitOffset, bitOffset + (N - 1));     \\\n      if (ALL_BITS_ONE) {                                                      \\\n        ASSERT_EQ(a, maxValue);                                                \\\n      } else {                                                                 \\\n        ASSERT_EQ(a, 0);                                                       \\\n      }                                                                        \\\n    }                                                                          \\\n  }\nMAKE_FROM_LARGE(64, 1990, true)\nMAKE_FROM_LARGE(64, 1990, false)\nMAKE_FROM_LARGE(1, 1990, true)\nMAKE_FROM_LARGE(1, 1990, false)\nMAKE_FROM_LARGE(2, 1990, true)\nMAKE_FROM_LARGE(2, 1990, false)\nMAKE_FROM_LARGE(3, 1990, true)\nMAKE_FROM_LARGE(3, 1990, false)\nMAKE_FROM_LARGE(4, 1990, true)\nMAKE_FROM_LARGE(4, 1990, false)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/RotateLeft.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define ROTATE_LEFT_BRUTE(N)                                                   \\\n  TEST(rotate_left, BruteForceBv##N) {                                         \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        int originalOneBitCount = __builtin_popcount(x);                       \\\n        uint64_t mask = (UINT64_C(1) << N) - 1;                                \\\n        uint64_t shift = y % N;                                                \\\n        uint64_t expected = ((x << shift) | (x >> (N - shift))) & mask;        \\\n        BitVector<N> result = xBv.rotate_left(y);                              \\\n        auto buffer = result.getBuffer();                                      \\\n        uint64_t resultData = *(reinterpret_cast<uint64_t *>(buffer.get()));   \\\n        int resultOneBitCount = __builtin_popcount(resultData);                \\\n        ASSERT_EQ(result, expected);                                           \\\n        ASSERT_EQ(originalOneBitCount, resultOneBitCount);                     \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nROTATE_LEFT_BRUTE(1);\nROTATE_LEFT_BRUTE(2);\nROTATE_LEFT_BRUTE(3);\nROTATE_LEFT_BRUTE(4);\nROTATE_LEFT_BRUTE(5);\nROTATE_LEFT_BRUTE(6);\nROTATE_LEFT_BRUTE(7);\nROTATE_LEFT_BRUTE(8);\nROTATE_LEFT_BRUTE(9);\nROTATE_LEFT_BRUTE(10);\n\n#define ROTATE_LEFT(N, X, Y, E)                                                \\\n  TEST(rotate_left, Rot_##N##_##X##_##Y) {                                     \\\n    int originalOneBitCount = __builtin_popcount(X);                           \\\n    BitVector<N> x(X);                                                         \\\n    ASSERT_EQ(x, X);                                                           \\\n    BitVector<N> result = x.rotate_left(Y);                                    \\\n    auto buffer = result.getBuffer();                                          \\\n    ASSERT_EQ(buffer.getSize(), sizeof(uint64_t));                             \\\n    uint64_t resultData = *(reinterpret_cast<uint64_t *>(buffer.get()));       \\\n    int resultOneBitCount = __builtin_popcount(resultData);                    \\\n    ASSERT_EQ(result, E);                                                      \\\n    /* check we didn't loose any bits */                                       \\\n    ASSERT_EQ(originalOneBitCount, resultOneBitCount);                         \\\n  }\n\n// Bv4\n// Rotation of zero does nothing\nROTATE_LEFT(4, 0, 0, 0)\nROTATE_LEFT(4, 0, 1, 0)\nROTATE_LEFT(4, 0, 2, 0)\nROTATE_LEFT(4, 0, 3, 0)\nROTATE_LEFT(4, 0, 4, 0)\nROTATE_LEFT(4, 0, 5, 0)\n\n// Rotate single bit\nROTATE_LEFT(4, 1, 0, 1)\nROTATE_LEFT(4, 1, 1, 2)\nROTATE_LEFT(4, 1, 2, 4)\nROTATE_LEFT(4, 1, 3, 8)\nROTATE_LEFT(4, 1, 4, 1)\n\n// Rotate 0b1001\nROTATE_LEFT(4, 0b1001, 0, 0b1001)\nROTATE_LEFT(4, 0b1001, 1, 0b0011)\nROTATE_LEFT(4, 0b1001, 2, 0b0110)\nROTATE_LEFT(4, 0b1001, 3, 0b1100)\nROTATE_LEFT(4, 0b1001, 4, 0b1001)\n\n// TODO: Write more tests\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/RotateRight.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define ROTATE_RIGHT_BRUTE(N)                                                  \\\n  TEST(rotate_right, BruteForceBv##N) {                                        \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      for (unsigned y = 0; y < (1 << N); ++y) {                                \\\n        BitVector<N> xBv(x);                                                   \\\n        int originalOneBitCount = __builtin_popcount(x);                       \\\n        uint64_t mask = (UINT64_C(1) << N) - 1;                                \\\n        uint64_t shift = y % N;                                                \\\n        uint64_t expected = ((x >> shift) | (x << (N - shift))) & mask;        \\\n        BitVector<N> result = xBv.rotate_right(y);                             \\\n        auto buffer = result.getBuffer();                                      \\\n        uint64_t resultData = *(reinterpret_cast<uint64_t *>(buffer.get()));   \\\n        int resultOneBitCount = __builtin_popcount(resultData);                \\\n        ASSERT_EQ(result, expected);                                           \\\n        ASSERT_EQ(originalOneBitCount, resultOneBitCount);                     \\\n      }                                                                        \\\n    }                                                                          \\\n  }\n\n// Brute force test the smaller bvs\nROTATE_RIGHT_BRUTE(1);\nROTATE_RIGHT_BRUTE(2);\nROTATE_RIGHT_BRUTE(3);\nROTATE_RIGHT_BRUTE(4);\nROTATE_RIGHT_BRUTE(5);\nROTATE_RIGHT_BRUTE(6);\nROTATE_RIGHT_BRUTE(7);\nROTATE_RIGHT_BRUTE(8);\nROTATE_RIGHT_BRUTE(9);\nROTATE_RIGHT_BRUTE(10);\n\n#define ROTATE_RIGHT(N, X, Y, E)                                               \\\n  TEST(rotate_right, Rot_##N##_##X##_##Y) {                                    \\\n    int originalOneBitCount = __builtin_popcount(X);                           \\\n    BitVector<N> x(X);                                                         \\\n    ASSERT_EQ(x, X);                                                           \\\n    BitVector<N> result = x.rotate_right(Y);                                   \\\n    auto buffer = result.getBuffer();                                          \\\n    ASSERT_EQ(buffer.getSize(), sizeof(uint64_t));                             \\\n    uint64_t resultData = *(reinterpret_cast<uint64_t *>(buffer.get()));       \\\n    int resultOneBitCount = __builtin_popcount(resultData);                    \\\n    ASSERT_EQ(result, E);                                                      \\\n    /* check we didn't loose any bits */                                       \\\n    ASSERT_EQ(originalOneBitCount, resultOneBitCount);                         \\\n  }\n\n// Bv4\n// Rotation of zero does nothing\nROTATE_RIGHT(4, 0, 0, 0)\nROTATE_RIGHT(4, 0, 1, 0)\nROTATE_RIGHT(4, 0, 2, 0)\nROTATE_RIGHT(4, 0, 3, 0)\nROTATE_RIGHT(4, 0, 4, 0)\nROTATE_RIGHT(4, 0, 5, 0)\n\n// Rotate single bit\nROTATE_RIGHT(4, 1, 0, 1)\nROTATE_RIGHT(4, 1, 1, 8)\nROTATE_RIGHT(4, 1, 2, 4)\nROTATE_RIGHT(4, 1, 3, 2)\nROTATE_RIGHT(4, 1, 4, 1)\n\n// Rotate 0b1001\nROTATE_RIGHT(4, 0b1001, 0, 0b1001)\nROTATE_RIGHT(4, 0b1001, 1, 0b1100)\nROTATE_RIGHT(4, 0b1001, 2, 0b0110)\nROTATE_RIGHT(4, 0b1001, 3, 0b0011)\nROTATE_RIGHT(4, 0b1001, 4, 0b1001)\n\n// TODO: Write more tests\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/SignExtend.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BV_SIGN_EXTEND_BRUTE(N, E)                                             \\\n  TEST(bvsignextend, BruteForceBv##N##_##E) {                                  \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      BitVector<N> xBv(x);                                                     \\\n      static_assert(N + E < 64, \"not safe\");                                   \\\n      uint64_t mask = (UINT64_C(1) << (N + E)) - 1;                            \\\n      uint64_t msbMask = UINT64_C(1) << (N - 1);                               \\\n      uint64_t expected = 0;                                                   \\\n      if ((x & msbMask) == 0) {                                                \\\n        /* zero extend */                                                      \\\n        expected = x & mask;                                                   \\\n      } else {                                                                 \\\n        /*sign extend*/                                                        \\\n        uint64_t xMask = (UINT64_C(1) << N) - 1;                               \\\n        expected = (x | (~xMask)) & mask;                                      \\\n      }                                                                        \\\n      BitVector<N + E> result = xBv.signExtend<E>();                           \\\n      EXPECT_EQ(result, expected);                                             \\\n    }                                                                          \\\n  }\n\nBV_SIGN_EXTEND_BRUTE(1, 0)\nBV_SIGN_EXTEND_BRUTE(1, 1)\nBV_SIGN_EXTEND_BRUTE(1, 2)\nBV_SIGN_EXTEND_BRUTE(1, 3)\nBV_SIGN_EXTEND_BRUTE(1, 4)\nBV_SIGN_EXTEND_BRUTE(1, 5)\nBV_SIGN_EXTEND_BRUTE(1, 6)\nBV_SIGN_EXTEND_BRUTE(1, 7)\nBV_SIGN_EXTEND_BRUTE(1, 8)\nBV_SIGN_EXTEND_BRUTE(2, 0)\nBV_SIGN_EXTEND_BRUTE(2, 1)\nBV_SIGN_EXTEND_BRUTE(2, 2)\nBV_SIGN_EXTEND_BRUTE(2, 3)\nBV_SIGN_EXTEND_BRUTE(2, 4)\nBV_SIGN_EXTEND_BRUTE(2, 5)\nBV_SIGN_EXTEND_BRUTE(2, 6)\nBV_SIGN_EXTEND_BRUTE(2, 7)\nBV_SIGN_EXTEND_BRUTE(2, 8)\nBV_SIGN_EXTEND_BRUTE(3, 0)\nBV_SIGN_EXTEND_BRUTE(3, 1)\nBV_SIGN_EXTEND_BRUTE(3, 2)\nBV_SIGN_EXTEND_BRUTE(3, 3)\nBV_SIGN_EXTEND_BRUTE(3, 4)\nBV_SIGN_EXTEND_BRUTE(3, 5)\nBV_SIGN_EXTEND_BRUTE(3, 6)\nBV_SIGN_EXTEND_BRUTE(3, 7)\nBV_SIGN_EXTEND_BRUTE(3, 8)\nBV_SIGN_EXTEND_BRUTE(4, 0)\nBV_SIGN_EXTEND_BRUTE(4, 1)\nBV_SIGN_EXTEND_BRUTE(4, 2)\nBV_SIGN_EXTEND_BRUTE(4, 3)\nBV_SIGN_EXTEND_BRUTE(4, 4)\nBV_SIGN_EXTEND_BRUTE(4, 5)\nBV_SIGN_EXTEND_BRUTE(4, 6)\nBV_SIGN_EXTEND_BRUTE(4, 7)\nBV_SIGN_EXTEND_BRUTE(4, 8)\nBV_SIGN_EXTEND_BRUTE(5, 0)\nBV_SIGN_EXTEND_BRUTE(5, 1)\nBV_SIGN_EXTEND_BRUTE(5, 2)\nBV_SIGN_EXTEND_BRUTE(5, 3)\nBV_SIGN_EXTEND_BRUTE(5, 4)\nBV_SIGN_EXTEND_BRUTE(5, 5)\nBV_SIGN_EXTEND_BRUTE(5, 6)\nBV_SIGN_EXTEND_BRUTE(5, 7)\nBV_SIGN_EXTEND_BRUTE(5, 8)\nBV_SIGN_EXTEND_BRUTE(6, 0)\nBV_SIGN_EXTEND_BRUTE(6, 1)\nBV_SIGN_EXTEND_BRUTE(6, 2)\nBV_SIGN_EXTEND_BRUTE(6, 3)\nBV_SIGN_EXTEND_BRUTE(6, 4)\nBV_SIGN_EXTEND_BRUTE(6, 5)\nBV_SIGN_EXTEND_BRUTE(6, 6)\nBV_SIGN_EXTEND_BRUTE(6, 7)\nBV_SIGN_EXTEND_BRUTE(6, 8)\nBV_SIGN_EXTEND_BRUTE(7, 0)\nBV_SIGN_EXTEND_BRUTE(7, 1)\nBV_SIGN_EXTEND_BRUTE(7, 2)\nBV_SIGN_EXTEND_BRUTE(7, 3)\nBV_SIGN_EXTEND_BRUTE(7, 4)\nBV_SIGN_EXTEND_BRUTE(7, 5)\nBV_SIGN_EXTEND_BRUTE(7, 6)\nBV_SIGN_EXTEND_BRUTE(7, 7)\nBV_SIGN_EXTEND_BRUTE(7, 8)\nBV_SIGN_EXTEND_BRUTE(8, 0)\nBV_SIGN_EXTEND_BRUTE(8, 1)\nBV_SIGN_EXTEND_BRUTE(8, 2)\nBV_SIGN_EXTEND_BRUTE(8, 3)\nBV_SIGN_EXTEND_BRUTE(8, 4)\nBV_SIGN_EXTEND_BRUTE(8, 5)\nBV_SIGN_EXTEND_BRUTE(8, 6)\nBV_SIGN_EXTEND_BRUTE(8, 7)\nBV_SIGN_EXTEND_BRUTE(8, 8)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/WriteToBuffer.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/NativeBitVector.h\"\n#include \"gtest/gtest.h\"\n#include <memory>\n#include <string.h>\n\nTEST(WriteToBuffer, ByteAligned) {\n  const jfs_nr_bitvector_ty input = 0b10110001;\n  const jfs_nr_width_ty bitWidth = 8;\n\n  const uint64_t bufferSize = 3;\n  uint8_t buffer[bufferSize];\n  // Initialize the buffer with surrounding data that should be preserved.\n  buffer[0] = 0b00111111;\n  buffer[1] = 0b10101010;\n  buffer[2] = 0b11000011;\n\n  jfs_nr_write_bitvector(input, bitWidth, buffer, bufferSize, 8);\n\n  ASSERT_EQ(buffer[0], 0b00111111); // Unchanged\n  ASSERT_EQ(buffer[1], 0b10110001);\n  ASSERT_EQ(buffer[2], 0b11000011); // Unchanged\n\n  const jfs_nr_bitvector_ty output =\n      jfs_nr_make_bitvector(buffer, bufferSize, 8, 15);\n\n  ASSERT_EQ(input, output);\n}\n\nTEST(WriteToBuffer, SplitBytes) {\n  const jfs_nr_bitvector_ty input = 0b101100011011;\n  const jfs_nr_width_ty bitWidth = 12;\n\n  const uint64_t bufferSize = 3;\n  uint8_t buffer[bufferSize];\n  // Initialize the buffer with surrounding data that should be preserved.\n  buffer[0] = 0b00111111;\n  buffer[1] = 0b10101010;\n  buffer[2] = 0b11000011;\n\n  jfs_nr_write_bitvector(input, bitWidth, buffer, bufferSize, 6);\n\n  ASSERT_EQ(buffer[0], 0b11111111);\n  ASSERT_EQ(buffer[1], 0b11000110);\n  ASSERT_EQ(buffer[2], 0b11000010);\n\n  const jfs_nr_bitvector_ty output =\n      jfs_nr_make_bitvector(buffer, bufferSize, 6, 17);\n\n  ASSERT_EQ(input, output);\n}\n\nTEST(WriteToBuffer, MiddleOfBuffer) {\n  const jfs_nr_bitvector_ty input = 0b101100;\n  const jfs_nr_width_ty bitWidth = 6;\n\n  const uint64_t bufferSize = 4;\n  uint8_t buffer[bufferSize];\n  // Initialize the buffer with surrounding data that should be preserved.\n  buffer[0] = 0b00111111;\n  buffer[1] = 0b10101010;\n  buffer[2] = 0b11000011;\n  buffer[3] = 0b11110000;\n\n  jfs_nr_write_bitvector(input, bitWidth, buffer, bufferSize, 13);\n\n  ASSERT_EQ(buffer[0], 0b00111111); // Unchanged\n  ASSERT_EQ(buffer[1], 0b10001010);\n  ASSERT_EQ(buffer[2], 0b11000101);\n  ASSERT_EQ(buffer[3], 0b11110000); // Unchanged\n\n  const jfs_nr_bitvector_ty output =\n      jfs_nr_make_bitvector(buffer, bufferSize, 13, 18);\n\n  ASSERT_EQ(input, output);\n}\n\nTEST(WriteToBuffer, SeveralVectors) {\n  const jfs_nr_bitvector_ty in1 = 0b101100;\n  const jfs_nr_width_ty width1 = 6;\n  const jfs_nr_bitvector_ty in2 = 0b101;\n  const jfs_nr_width_ty width2 = 3;\n  const jfs_nr_bitvector_ty in3 = 0b1100001;\n  const jfs_nr_width_ty width3 = 7;\n\n\n  const uint64_t bufferSize = 3;\n  uint8_t buffer[bufferSize];\n  // Initialize the buffer with surrounding data that should be preserved.\n  buffer[0] = 0b00111111;\n  buffer[1] = 0b10101010;\n  buffer[2] = 0b11000001;\n\n  jfs_nr_write_bitvector(in1, width1, buffer, bufferSize, 2);\n  jfs_nr_write_bitvector(in2, width2, buffer, bufferSize, 8);\n  jfs_nr_write_bitvector(in3, width3, buffer, bufferSize, 11);\n\n\n  ASSERT_EQ(buffer[0], 0b10110011);\n  ASSERT_EQ(buffer[1], 0b00001101);\n  ASSERT_EQ(buffer[2], 0b11000011);\n\n  const jfs_nr_bitvector_ty out1 =\n      jfs_nr_make_bitvector(buffer, bufferSize, 2, 7);\n  const jfs_nr_bitvector_ty out2 =\n      jfs_nr_make_bitvector(buffer, bufferSize, 8, 10);\n  const jfs_nr_bitvector_ty out3 =\n      jfs_nr_make_bitvector(buffer, bufferSize, 11, 17);\n\n  ASSERT_EQ(in1, out1);\n  ASSERT_EQ(in2, out2);\n  ASSERT_EQ(in3, out3);\n}"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/Native/ZeroExtend.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\n#define BV_ZERO_EXTEND_BRUTE(N, E)                                             \\\n  TEST(bvzeroextend, BruteForceBv##N##_##E) {                                  \\\n    for (unsigned x = 0; x < (1 << N); ++x) {                                  \\\n      BitVector<N> xBv(x);                                                     \\\n      static_assert((N + E) < 64, \"not safe\");                                 \\\n      uint64_t mask = (UINT64_C(1) << (N + E)) - 1;                            \\\n      uint64_t expected = x & mask;                                            \\\n      BitVector<N + E> result = xBv.zeroExtend<E>();                           \\\n      EXPECT_EQ(result, expected);                                             \\\n    }                                                                          \\\n  }\n\nBV_ZERO_EXTEND_BRUTE(1, 0)\nBV_ZERO_EXTEND_BRUTE(1, 1)\nBV_ZERO_EXTEND_BRUTE(1, 2)\nBV_ZERO_EXTEND_BRUTE(1, 3)\nBV_ZERO_EXTEND_BRUTE(1, 4)\nBV_ZERO_EXTEND_BRUTE(1, 5)\nBV_ZERO_EXTEND_BRUTE(1, 6)\nBV_ZERO_EXTEND_BRUTE(1, 7)\nBV_ZERO_EXTEND_BRUTE(1, 8)\nBV_ZERO_EXTEND_BRUTE(2, 0)\nBV_ZERO_EXTEND_BRUTE(2, 1)\nBV_ZERO_EXTEND_BRUTE(2, 2)\nBV_ZERO_EXTEND_BRUTE(2, 3)\nBV_ZERO_EXTEND_BRUTE(2, 4)\nBV_ZERO_EXTEND_BRUTE(2, 5)\nBV_ZERO_EXTEND_BRUTE(2, 6)\nBV_ZERO_EXTEND_BRUTE(2, 7)\nBV_ZERO_EXTEND_BRUTE(2, 8)\nBV_ZERO_EXTEND_BRUTE(3, 0)\nBV_ZERO_EXTEND_BRUTE(3, 1)\nBV_ZERO_EXTEND_BRUTE(3, 2)\nBV_ZERO_EXTEND_BRUTE(3, 3)\nBV_ZERO_EXTEND_BRUTE(3, 4)\nBV_ZERO_EXTEND_BRUTE(3, 5)\nBV_ZERO_EXTEND_BRUTE(3, 6)\nBV_ZERO_EXTEND_BRUTE(3, 7)\nBV_ZERO_EXTEND_BRUTE(3, 8)\nBV_ZERO_EXTEND_BRUTE(4, 0)\nBV_ZERO_EXTEND_BRUTE(4, 1)\nBV_ZERO_EXTEND_BRUTE(4, 2)\nBV_ZERO_EXTEND_BRUTE(4, 3)\nBV_ZERO_EXTEND_BRUTE(4, 4)\nBV_ZERO_EXTEND_BRUTE(4, 5)\nBV_ZERO_EXTEND_BRUTE(4, 6)\nBV_ZERO_EXTEND_BRUTE(4, 7)\nBV_ZERO_EXTEND_BRUTE(4, 8)\nBV_ZERO_EXTEND_BRUTE(5, 0)\nBV_ZERO_EXTEND_BRUTE(5, 1)\nBV_ZERO_EXTEND_BRUTE(5, 2)\nBV_ZERO_EXTEND_BRUTE(5, 3)\nBV_ZERO_EXTEND_BRUTE(5, 4)\nBV_ZERO_EXTEND_BRUTE(5, 5)\nBV_ZERO_EXTEND_BRUTE(5, 6)\nBV_ZERO_EXTEND_BRUTE(5, 7)\nBV_ZERO_EXTEND_BRUTE(5, 8)\nBV_ZERO_EXTEND_BRUTE(6, 0)\nBV_ZERO_EXTEND_BRUTE(6, 1)\nBV_ZERO_EXTEND_BRUTE(6, 2)\nBV_ZERO_EXTEND_BRUTE(6, 3)\nBV_ZERO_EXTEND_BRUTE(6, 4)\nBV_ZERO_EXTEND_BRUTE(6, 5)\nBV_ZERO_EXTEND_BRUTE(6, 6)\nBV_ZERO_EXTEND_BRUTE(6, 7)\nBV_ZERO_EXTEND_BRUTE(6, 8)\nBV_ZERO_EXTEND_BRUTE(7, 0)\nBV_ZERO_EXTEND_BRUTE(7, 1)\nBV_ZERO_EXTEND_BRUTE(7, 2)\nBV_ZERO_EXTEND_BRUTE(7, 3)\nBV_ZERO_EXTEND_BRUTE(7, 4)\nBV_ZERO_EXTEND_BRUTE(7, 5)\nBV_ZERO_EXTEND_BRUTE(7, 6)\nBV_ZERO_EXTEND_BRUTE(7, 7)\nBV_ZERO_EXTEND_BRUTE(7, 8)\nBV_ZERO_EXTEND_BRUTE(8, 0)\nBV_ZERO_EXTEND_BRUTE(8, 1)\nBV_ZERO_EXTEND_BRUTE(8, 2)\nBV_ZERO_EXTEND_BRUTE(8, 3)\nBV_ZERO_EXTEND_BRUTE(8, 4)\nBV_ZERO_EXTEND_BRUTE(8, 5)\nBV_ZERO_EXTEND_BRUTE(8, 6)\nBV_ZERO_EXTEND_BRUTE(8, 7)\nBV_ZERO_EXTEND_BRUTE(8, 8)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/NonNative/Concat.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\nTEST(BvConcat, simpleBig) {\n  BitVector<64> x(5);\n  BitVector<3> y(1);\n  EXPECT_EQ(x, 5);\n  EXPECT_EQ(y, 1);\n  BitVector<67> result = x.concat(y);\n  auto data = result.getBuffer();\n  ASSERT_EQ(data.getSize(), 9);\n  uint8_t expectedData[] = {0b00101001, 0, 0, 0, 0, 0, 0, 0, 0};\n  // Do byte-wise comparison\n  for (unsigned index = 0; index < data.getSize(); ++index) {\n    ASSERT_EQ(data.get()[index], expectedData[index]);\n  }\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/NonNative/SignExtend.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\nTEST(bvsignextend, simpleZeroExt) {\n  BitVector<64> a(1);\n  BitVector<65> b = a.signExtend<1>();\n  auto buffer = b.getBuffer();\n  ASSERT_EQ(buffer.getSize(), 9);\n  ASSERT_EQ(buffer.get()[0], 0x01);\n  for (unsigned index = 1; index < buffer.getSize(); ++index) {\n    ASSERT_EQ(buffer.get()[index], 0x00);\n  }\n}\n\nTEST(bvsignextend, simpleSignExt) {\n  BitVector<64> a(UINT64_MAX);\n  BitVector<65> b = a.signExtend<1>();\n  auto buffer = b.getBuffer();\n  ASSERT_EQ(buffer.getSize(), 9);\n  for (unsigned index = 0; index < (buffer.getSize() - 1); ++index) {\n    ASSERT_EQ(buffer.get()[index], 0xff);\n  }\n  // 65th bit is one but the rest should be zero inside the buffer.\n  ASSERT_EQ(buffer.get()[buffer.getSize() - 1], 0x01);\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/BitVector/NonNative/ZeroExtend.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/BitVector.h\"\n#include \"gtest/gtest.h\"\n\nTEST(bvzeroexend, simpleNonNative) {\n  BitVector<64> x(255);\n  BitVector<67> extended = x.zeroExtend<3>();\n  auto rawData = extended.getBuffer();\n  ASSERT_EQ(rawData.getSize(), 9);\n  ASSERT_EQ(rawData.get()[0], 255);\n  for (unsigned index = 1; index < rawData.getSize(); ++index) {\n    ASSERT_EQ(rawData.get()[index], 0);\n  }\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n\n###############################################################################\n# Utility library\n###############################################################################\nadd_library(JFSSMTLIBRuntimeTestUtil\n  SMTLIBRuntimeTestUtil.cpp\n)\ntarget_include_directories(JFSSMTLIBRuntimeTestUtil\n  PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}\n)\n\n###############################################################################\n# Import GTest targets\n###############################################################################\n# FIXME:\n# This assumes that the runtime compiler and host compiler are ABI compatible.\n# You would hope that they are but maybe we should build GTest again with the\n# runtime compiler?\nif (NOT EXISTS \"${JFS_GTEST_EXPORT_FILE}\")\n  message(FATAL_ERROR \"Cannot find JFS_GTEST_EXPORT_FILE: \\\"${JFS_GTEST_EXPORT_FILE}\\\"\")\nendif()\ninclude(\"${JFS_GTEST_EXPORT_FILE}\")\n\n###############################################################################\n# Declare unit tests\n###############################################################################\ninclude(\"${JFS_SOURCE_ROOT}/cmake/add_jfs_unit_test.cmake\")\nadd_subdirectory(BitVector)\nadd_subdirectory(Core)\nadd_subdirectory(Float)\nadd_subdirectory(Logger)\n\n###############################################################################\n# Setup targets for running unittests with lit\n###############################################################################\n# Set up lit configuration\n# Set test suite name\nset(UNIT_TEST_SUITE_NAME \"JFS \")\nif (USE_ASAN)\n  string(APPEND UNIT_TEST_SUITE_NAME \"ASan \")\nendif()\nif (USE_ASAN)\n  string(APPEND UNIT_TEST_SUITE_NAME \"UBSan \")\nendif()\nstring(APPEND UNIT_TEST_SUITE_NAME \"${CMAKE_BUILD_TYPE} Runtime unit tests\")\nconfigure_file(\n  \"lit-unit-tests-common.site.cfg.in\"\n  \"lit.site.cfg\"\n  @ONLY\n)\n\nif (NOT EXISTS \"${LIT_TOOL}\")\n  message(FATAL_ERROR \"LIT_TOOL \\\"${LIT_TOOL}\\\" does not exist\")\nendif()\n\nget_property(UNIT_TEST_DEPENDS\n  GLOBAL\n  PROPERTY JFS_UNIT_TEST_TARGETS\n)\nadd_custom_target(jfs_runtime_unittests\n  COMMAND\n    \"${CMAKE_COMMAND}\" -E env\n      \"UBSAN_OPTIONS=halt_on_error=1\"\n      \"${LIT_TOOL}\" ${LIT_ARGS} \"${CMAKE_CURRENT_BINARY_DIR}\"\n    DEPENDS ${UNIT_TEST_DEPENDS}\n    ${ADD_CUSTOM_COMMAND_USES_TERMINAL_ARG}\n)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Core/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\nadd_jfs_unit_test(Core\n  MakeFromBuffer.cpp\n)\n\ntarget_link_libraries(Core${UNIT_TEST_EXE_SUFFIX} PRIVATE JFSSMTLIBRuntime)\ntarget_link_libraries(Core${UNIT_TEST_EXE_SUFFIX} PRIVATE JFSSMTLIBRuntimeTestUtil)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Core/MakeFromBuffer.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Core.h\"\n#include \"gtest/gtest.h\"\n\nTEST(MakeFromBuffer, singleBitFromUniformBuffer) {\n  uint8_t buffer[sizeof(uint64_t)];\n  uint64_t* view = reinterpret_cast<uint64_t*>(buffer);\n  BufferRef<const uint8_t> bufferRef(buffer, sizeof(uint64_t));\n#define TEST_MAKE_BOOL(L, B, VALUE)                                            \\\n  bool test_##L##_##B = makeBoolFrom(bufferRef, L, B);                         \\\n  ASSERT_EQ(test_##L##_##B, VALUE);\n\n  for (unsigned i = 0; i < 2; ++i) {\n    bool expected;\n    if (i == 0) {\n      expected = false;\n      // All zeros\n      *view = 0;\n    } else {\n      expected = true;\n      // All ones\n      *view = UINT64_MAX;\n    }\n\n    TEST_MAKE_BOOL(0, 0, expected);\n    TEST_MAKE_BOOL(1, 1, expected);\n    TEST_MAKE_BOOL(2, 2, expected);\n    TEST_MAKE_BOOL(3, 3, expected);\n    TEST_MAKE_BOOL(4, 4, expected);\n    TEST_MAKE_BOOL(5, 5, expected);\n    TEST_MAKE_BOOL(6, 6, expected);\n    TEST_MAKE_BOOL(7, 7, expected);\n    TEST_MAKE_BOOL(8, 8, expected);\n    TEST_MAKE_BOOL(9, 9, expected);\n    TEST_MAKE_BOOL(10, 10, expected);\n    TEST_MAKE_BOOL(11, 11, expected);\n    TEST_MAKE_BOOL(12, 12, expected);\n    TEST_MAKE_BOOL(13, 13, expected);\n    TEST_MAKE_BOOL(14, 14, expected);\n    TEST_MAKE_BOOL(15, 15, expected);\n    TEST_MAKE_BOOL(16, 16, expected);\n    TEST_MAKE_BOOL(17, 17, expected);\n    TEST_MAKE_BOOL(18, 18, expected);\n    TEST_MAKE_BOOL(19, 19, expected);\n    TEST_MAKE_BOOL(20, 20, expected);\n    TEST_MAKE_BOOL(21, 21, expected);\n    TEST_MAKE_BOOL(22, 22, expected);\n    TEST_MAKE_BOOL(23, 23, expected);\n    TEST_MAKE_BOOL(24, 24, expected);\n    TEST_MAKE_BOOL(25, 25, expected);\n    TEST_MAKE_BOOL(26, 26, expected);\n    TEST_MAKE_BOOL(27, 27, expected);\n    TEST_MAKE_BOOL(28, 28, expected);\n    TEST_MAKE_BOOL(29, 29, expected);\n    TEST_MAKE_BOOL(30, 30, expected);\n    TEST_MAKE_BOOL(31, 31, expected);\n    TEST_MAKE_BOOL(32, 32, expected);\n    TEST_MAKE_BOOL(33, 33, expected);\n    TEST_MAKE_BOOL(34, 34, expected);\n    TEST_MAKE_BOOL(35, 35, expected);\n    TEST_MAKE_BOOL(36, 36, expected);\n    TEST_MAKE_BOOL(37, 37, expected);\n    TEST_MAKE_BOOL(38, 38, expected);\n    TEST_MAKE_BOOL(39, 39, expected);\n    TEST_MAKE_BOOL(40, 40, expected);\n    TEST_MAKE_BOOL(41, 41, expected);\n    TEST_MAKE_BOOL(42, 42, expected);\n    TEST_MAKE_BOOL(43, 43, expected);\n    TEST_MAKE_BOOL(44, 44, expected);\n    TEST_MAKE_BOOL(45, 45, expected);\n    TEST_MAKE_BOOL(46, 46, expected);\n    TEST_MAKE_BOOL(47, 47, expected);\n    TEST_MAKE_BOOL(48, 48, expected);\n    TEST_MAKE_BOOL(49, 49, expected);\n    TEST_MAKE_BOOL(50, 50, expected);\n    TEST_MAKE_BOOL(51, 51, expected);\n    TEST_MAKE_BOOL(52, 52, expected);\n    TEST_MAKE_BOOL(53, 53, expected);\n    TEST_MAKE_BOOL(54, 54, expected);\n    TEST_MAKE_BOOL(55, 55, expected);\n    TEST_MAKE_BOOL(56, 56, expected);\n    TEST_MAKE_BOOL(57, 57, expected);\n    TEST_MAKE_BOOL(58, 58, expected);\n    TEST_MAKE_BOOL(59, 59, expected);\n    TEST_MAKE_BOOL(60, 60, expected);\n    TEST_MAKE_BOOL(61, 61, expected);\n    TEST_MAKE_BOOL(62, 62, expected);\n    TEST_MAKE_BOOL(63, 63, expected);\n  }\n#undef TEST_MAKE_BOOL\n}\n\nTEST(MakeFromBuffer, IndividualBits) {\n  uint8_t buffer[1];\n  buffer[0] = 0b10000001;\n  BufferRef<const uint8_t> bufferRef(buffer, 1);\n#define CHECK_BIT(N, VALUE)                                                    \\\n  bool bit##N = makeBoolFrom(bufferRef, N, N);                                 \\\n  ASSERT_EQ(bit##N, VALUE);\n  CHECK_BIT(0, 1)\n  CHECK_BIT(1, 0)\n  CHECK_BIT(2, 0)\n  CHECK_BIT(3, 0)\n  CHECK_BIT(4, 0)\n  CHECK_BIT(5, 0)\n  CHECK_BIT(6, 0)\n  CHECK_BIT(7, 1)\n#undef CHECK_BIT\n}\n\nTEST(MakeFromBuffer, AcrossByteBoundaryFalse) {\n  uint8_t buffer[2];\n  buffer[0] = 0b00000000;\n  buffer[1] = 0b11111110;\n  BufferRef<const uint8_t> bufferRef(buffer, 2);\n  bool bits = makeBoolFrom(bufferRef, 7, 7);\n  ASSERT_EQ(bits, false);\n  bool bits2 = makeBoolFrom(bufferRef, 7, 8);\n  ASSERT_EQ(bits2, false);\n  bool bits3 = makeBoolFrom(bufferRef, 7, 9);\n  ASSERT_EQ(bits3, true);\n}\n\n#define MAKE_FROM_LARGE(N, BUFFER_SIZE, ALL_BITS_ONE)                          \\\n  TEST(MakeFromBuffer, LargeBuffer_##N##_##BUFFER_SIZE##_##ALL_BITS_ONE) {     \\\n    static_assert(BUFFER_SIZE > 0, \"invalid buffer size\");                     \\\n    static_assert(N <= 8 && N >= 0, \"invalid N value\");                        \\\n    const size_t numBytes = BUFFER_SIZE;                                       \\\n    std::unique_ptr<uint8_t, decltype(std::free)*> buffer(                     \\\n        reinterpret_cast<uint8_t*>(malloc(numBytes)), std::free);              \\\n    if (ALL_BITS_ONE) {                                                        \\\n      memset(buffer.get(), 255, numBytes);                                     \\\n    } else {                                                                   \\\n      memset(buffer.get(), 0, numBytes);                                       \\\n    }                                                                          \\\n    BufferRef<const uint8_t> bufferRef(buffer.get(), numBytes);                \\\n    for (unsigned bitOffset = 0; bitOffset <= ((numBytes * 8) - N);            \\\n         ++bitOffset) {                                                        \\\n      bool a = makeBoolFrom(bufferRef, bitOffset, bitOffset + (N - 1));        \\\n      if (ALL_BITS_ONE) {                                                      \\\n        ASSERT_EQ(a, true);                                                    \\\n      } else {                                                                 \\\n        ASSERT_EQ(a, false);                                                   \\\n      }                                                                        \\\n    }                                                                          \\\n  }\nMAKE_FROM_LARGE(1, 1024, true)\nMAKE_FROM_LARGE(2, 1024, true)\nMAKE_FROM_LARGE(3, 1024, true)\nMAKE_FROM_LARGE(4, 1024, true)\nMAKE_FROM_LARGE(5, 1024, true)\nMAKE_FROM_LARGE(6, 1024, true)\nMAKE_FROM_LARGE(7, 1024, true)\nMAKE_FROM_LARGE(8, 1024, true)\nMAKE_FROM_LARGE(1, 1024, false)\nMAKE_FROM_LARGE(2, 1024, false)\nMAKE_FROM_LARGE(3, 1024, false)\nMAKE_FROM_LARGE(4, 1024, false)\nMAKE_FROM_LARGE(5, 1024, false)\nMAKE_FROM_LARGE(6, 1024, false)\nMAKE_FROM_LARGE(7, 1024, false)\nMAKE_FROM_LARGE(8, 1024, false)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\nadd_jfs_unit_test(Float\n  Native/Add.cpp\n  Native/Abs.cpp\n  Native/ConvertToFloatFromFloat.cpp\n  Native/ConvertToFloatFromUnsignedBV.cpp\n  Native/ConvertToFloatFromSignedBV.cpp\n  Native/ConvertToUnsignedBVFromFloat.cpp\n  Native/ConvertToSignedBVFromFloat.cpp\n  Native/Div.cpp\n  Native/FMA.cpp\n  Native/GreaterThan.cpp\n  Native/GreaterThanOrEqual.cpp\n  Native/IEEEEquals.cpp\n  Native/IsInfinite.cpp\n  Native/IsNegative.cpp\n  Native/IsPositive.cpp\n  Native/IsNaN.cpp\n  Native/IsNormal.cpp\n  Native/IsSubnormal.cpp\n  Native/IsZero.cpp\n  Native/LessThan.cpp\n  Native/LessThanOrEqual.cpp\n  Native/MakeFromIEEEBitVector.cpp\n  Native/MakeFromBuffer.cpp\n  Native/MakeFromTriple.cpp\n  Native/Max.cpp\n  Native/Min.cpp\n  Native/Mul.cpp\n  Native/Neg.cpp\n  Native/Rem.cpp\n  Native/RoundToIntegral.cpp\n  Native/SMTLIBEquals.cpp\n  Native/Sub.cpp\n  Native/SpecialConstants.cpp\n  Native/Sqrt.cpp\n)\n\ntarget_link_libraries(Float${UNIT_TEST_EXE_SUFFIX} PRIVATE JFSSMTLIBRuntime)\ntarget_link_libraries(Float${UNIT_TEST_EXE_SUFFIX} PRIVATE JFSSMTLIBRuntimeTestUtil)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/Abs.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\n// FIXME: IEEE-754 2008 (5.5.1 Sign bit operations) says just the sign bit gets\n// set to zero so really we should just test that.\n\nTEST(Abs, NaN) {\n  ASSERT_TRUE(Float32::getNaN().abs().isNaN());\n  ASSERT_TRUE(Float64::getNaN().abs().isNaN());\n}\n\nTEST(Abs, NegativeZero) {\n  auto absFloat32 = Float32::getNegativeZero().abs();\n  ASSERT_TRUE(absFloat32.isPositive());\n  ASSERT_TRUE(absFloat32.isZero());\n  auto absFloat64 = Float64::getNegativeZero().abs();\n  ASSERT_TRUE(absFloat64.isPositive());\n  ASSERT_TRUE(absFloat64.isZero());\n}\n\nTEST(Abs, PositiveZero) {\n  auto absFloat32 = Float32::getPositiveZero().abs();\n  ASSERT_TRUE(absFloat32.isPositive());\n  ASSERT_TRUE(absFloat32.isZero());\n  auto absFloat64 = Float64::getPositiveZero().abs();\n  ASSERT_TRUE(absFloat64.isPositive());\n  ASSERT_TRUE(absFloat64.isZero());\n}\n\nTEST(Abs, NegativeInfinity) {\n  auto absFloat32 = Float32::getNegativeInfinity().abs();\n  ASSERT_TRUE(absFloat32.isPositive());\n  ASSERT_TRUE(absFloat32.isInfinite());\n  auto absFloat64 = Float64::getNegativeInfinity().abs();\n  ASSERT_TRUE(absFloat64.isPositive());\n  ASSERT_TRUE(absFloat64.isInfinite());\n}\n\nTEST(Abs, PositiveInfinity) {\n  auto absFloat32 = Float32::getPositiveInfinity().abs();\n  ASSERT_TRUE(absFloat32.isPositive());\n  ASSERT_TRUE(absFloat32.isInfinite());\n  auto absFloat64 = Float64::getPositiveInfinity().abs();\n  ASSERT_TRUE(absFloat64.isPositive());\n  ASSERT_TRUE(absFloat64.isInfinite());\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/Add.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(Add, NaN) {\n  ASSERT_TRUE(Float32::getNaN().add(JFS_RM_RNE, Float32(0.0f)).isNaN());\n  ASSERT_TRUE(Float64::getNaN().add(JFS_RM_RNE, Float64(0.0)).isNaN());\n}\n\nTEST(Add, Simple) {\n  ASSERT_EQ(3.0f, Float32(1.0f).add(JFS_RM_RNE, Float32(2.0f)).getRawData());\n}\n\nTEST(Add, DiffResultRNE_RTP_Float32) {\n  // These values are derived from a Z3 model run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (declare-fun b () (_ FloatingPoint 8 24))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert\n      (not\n        (fp.eq\n          (fp.add RNE a b)\n          (fp.add RTP a b)\n        )\n      )\n    )\n    (check-sat)\n    (get-model)\n  */\n  Float32 a(1, 0xbc, 0b00110000000000010011111);\n  Float32 b(1, 0xc3, 0b11111101101000000000000);\n  Float32 addRNE = a.add(JFS_RM_RNE, b);\n  Float32 addRTP = a.add(JFS_RM_RTP, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTP));\n  // FIXME: Check the result values\n}\n\nTEST(Add, DiffResultRNE_RTP_Float64) {\n  // These values are derived from a Z3 model run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (declare-fun b () (_ FloatingPoint 11 53))\n    (define-fun a_b_rne () (_ FloatingPoint 11 53) (fp.add RNE a b))\n    (define-fun a_b_rtp () (_ FloatingPoint 11 53) (fp.add RTP a b))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.eq a_b_rne a_b_rtp)))\n    (assert (not (fp.isNaN a_b_rne)))\n    (assert (not (fp.isNaN a_b_rtp)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(0, 0x02, UINT64_C(0xff5edfffe64e7));\n  Float64 b(0, 0x02, UINT64_C(0xff7effffe6566));\n  Float64 addRNE = a.add(JFS_RM_RNE, b);\n  Float64 addRTP = a.add(JFS_RM_RTP, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTP));\n  // FIXME: Check the result values\n}\n\nTEST(Add, DiffResultRNE_RTN_Float32) {\n  // These values are derived from a Z3 model run on the following query\n  /*\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (declare-fun b () (_ FloatingPoint 8 24))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert\n      (not\n        (fp.eq\n          (fp.add RNE a b)\n          (fp.add RTN a b)\n        )\n      )\n    )\n    (check-sat)\n    (get-model)\n   */\n  Float32 a(0, 0x86, 0b00000000000000100100011);\n  Float32 b(0, 0x85, 0b11111111111111000111101);\n  Float32 addRNE = a.add(JFS_RM_RNE, b);\n  Float32 addRTN = a.add(JFS_RM_RTN, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTN));\n  // FIXME: Check the result values\n}\n\nTEST(Add, DiffResultRNE_RTN_Float64) {\n  // These values are derived from a Z3 model run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (declare-fun b () (_ FloatingPoint 11 53))\n    (define-fun a_b_rne () (_ FloatingPoint 11 53) (fp.add RNE a b))\n    (define-fun a_b_rtn () (_ FloatingPoint 11 53) (fp.add RTN a b))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.eq a_b_rne a_b_rtn)))\n    (assert (not (fp.isNaN a_b_rne)))\n    (assert (not (fp.isNaN a_b_rtn)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(1, 0b10000110111, UINT64_C(0xfffffffffffff));\n  Float64 b(1, 0b01101111100, UINT64_C(0x9ffffffffffff));\n  Float64 addRNE = a.add(JFS_RM_RNE, b);\n  Float64 addRTN = a.add(JFS_RM_RTN, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTN));\n  // FIXME: Check the result values\n}\n\nTEST(Add, DiffResultRNE_RTZ_Float32) {\n  // These values are derived from a Z3 model run on the following query\n  /*\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (declare-fun b () (_ FloatingPoint 8 24))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert\n      (not\n        (fp.eq\n          (fp.add RNE a b)\n          (fp.add RTZ a b)\n        )\n      )\n    )\n    (check-sat)\n    (get-model)\n   */\n  Float32 a(1, 0x3f, 0b10000001000000000011111);\n  Float32 b(1, 0x3d, 0b11111111100000000000010);\n  Float32 addRNE = a.add(JFS_RM_RNE, b);\n  Float32 addRTZ = a.add(JFS_RM_RTZ, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTZ));\n  // FIXME: Check the result values\n}\n\nTEST(Add, DiffResultRNE_RTZ_Float64) {\n  // These values are derived from a Z3 model run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (declare-fun b () (_ FloatingPoint 11 53))\n    (define-fun a_b_rne () (_ FloatingPoint 11 53) (fp.add RNE a b))\n    (define-fun a_b_rtz () (_ FloatingPoint 11 53) (fp.add RTZ a b))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.eq a_b_rne a_b_rtz)))\n    (assert (not (fp.isNaN a_b_rne)))\n    (assert (not (fp.isNaN a_b_rtz)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(0, 0b11100010010, UINT64_C(0xb68bfefffffe0));\n  Float64 b(0, 0b11011101010, UINT64_C(0x9ffffffffffff));\n  Float64 addRNE = a.add(JFS_RM_RNE, b);\n  Float64 addRTZ = a.add(JFS_RM_RTZ, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTZ));\n  // FIXME: Check the result values\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/ConvertToFloatFromFloat.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(ConvertToFloatFromFloat, NaN) {\n  ASSERT_TRUE(((Float32::getNaN()).convertToFloat<11, 53>(JFS_RM_RNE)).isNaN());\n  // No-op\n  ASSERT_TRUE(((Float32::getNaN()).convertToFloat<8, 24>(JFS_RM_RNE)).isNaN());\n\n  ASSERT_TRUE(((Float64::getNaN()).convertToFloat<8, 24>(JFS_RM_RNE)).isNaN());\n  // No-op\n  ASSERT_TRUE(((Float64::getNaN()).convertToFloat<11, 53>(JFS_RM_RNE)).isNaN());\n}\n\nTEST(ConvertToFloatFromFloat, Float64ToFloat32_Diff_RNE_RTP) {\n  // These values are derived from a Z3 model run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (define-fun result_rne () (_ FloatingPoint 8 24) ((_ to_fp 8 24) RNE a))\n    (define-fun result_rtp () (_ FloatingPoint 8 24) ((_ to_fp 8 24) RTP a))\n    (assert (not (fp.isNaN a)))\n    (assert\n      (not\n        (fp.eq\n          result_rne\n          result_rtp\n        )\n      )\n    )\n    (assert (not (fp.isNaN result_rne)))\n    (assert (not (fp.isNaN result_rtp)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(1, 0b01110000000, UINT64_C(0x0111fe0000000));\n  Float32 resultRNE = a.convertToFloat<8, 24>(JFS_RM_RNE);\n  Float32 resultRTP = a.convertToFloat<8, 24>(JFS_RM_RTP);\n  ASSERT_FALSE(resultRNE.ieeeEquals(resultRTP));\n  ASSERT_EQ(resultRNE, Float32(1, 0x00, UINT32_C(0b10000000100010010000000)));\n  ASSERT_EQ(resultRTP, Float32(1, 0x00, UINT32_C(0b10000000100010001111111)));\n}\n\nTEST(ConvertToFloatFromFloat, Float64ToFloat32_Diff_RNE_RTN) {\n  // These values are derived from a Z3 model run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (define-fun result_rne () (_ FloatingPoint 8 24) ((_ to_fp 8 24) RNE a))\n    (define-fun result_rtn () (_ FloatingPoint 8 24) ((_ to_fp 8 24) RTN a))\n    (assert (not (fp.isNaN a)))\n    (assert\n      (not\n        (fp.eq\n          result_rne\n          result_rtn\n        )\n      )\n    )\n    (assert (not (fp.isNaN result_rne)))\n    (assert (not (fp.isNaN result_rtn)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(1, 0b01000000000, UINT64_C(0xfff0ff8000103));\n  Float32 resultRNE = a.convertToFloat<8, 24>(JFS_RM_RNE);\n  Float32 resultRTN = a.convertToFloat<8, 24>(JFS_RM_RTN);\n  ASSERT_FALSE(resultRNE.ieeeEquals(resultRTN));\n  ASSERT_EQ(resultRNE, Float32::getNegativeZero());\n  ASSERT_EQ(resultRTN, Float32(1, 0x00, UINT32_C(0b00000000000000000000001)));\n}\n\nTEST(ConvertToFloatFromFloat, Float64ToFloat32_Diff_RNE_RTZ) {\n  // These values are derived from a Z3 model run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (define-fun result_rne () (_ FloatingPoint 8 24) ((_ to_fp 8 24) RNE a))\n    (define-fun result_rtz () (_ FloatingPoint 8 24) ((_ to_fp 8 24) RTZ a))\n    (assert (not (fp.isNaN a)))\n    (assert\n      (not\n        (fp.eq\n          result_rne\n          result_rtz\n        )\n      )\n    )\n    (assert (not (fp.isNaN result_rne)))\n    (assert (not (fp.isNaN result_rtz)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(0, 0b10101111110, UINT64_C(0xffffff5004187));\n  Float32 resultRNE = a.convertToFloat<8, 24>(JFS_RM_RNE);\n  Float32 resultRTZ = a.convertToFloat<8, 24>(JFS_RM_RTZ);\n  ASSERT_FALSE(resultRNE.ieeeEquals(resultRTZ));\n  ASSERT_EQ(resultRNE, Float32::getPositiveInfinity());\n  ASSERT_EQ(resultRTZ, Float32(0, 0xfe, UINT32_C(0b11111111111111111111111)));\n}\n\n// FIXME: Write more tests\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/ConvertToFloatFromSignedBV.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(ConvertToFloatFromSignedBV, zero) {\n  ASSERT_TRUE((Float32::convertFromSignedBV<32>(JFS_RM_RNE, BitVector<32>(0)))\n                  .isZero());\n  ASSERT_TRUE((Float64::convertFromSignedBV<64>(JFS_RM_RNE, BitVector<64>(0)))\n                  .isZero());\n}\n\nTEST(ConvertToFloatFromSignedBV, TwoFiveSix) {\n  ASSERT_EQ((Float32::convertFromSignedBV<32>(JFS_RM_RNE, BitVector<32>(256))),\n            Float32(256.0f));\n  ASSERT_EQ((Float64::convertFromSignedBV<32>(JFS_RM_RNE, BitVector<32>(256))),\n            Float64(256.0));\n}\n\nTEST(ConvertToFloatFromSignedBV, MinusOne) {\n  BitVector<8> minusOne(0xff);\n  ASSERT_EQ(Float32::convertFromSignedBV<8>(JFS_RM_RNE, minusOne),\n            Float32(-1.0f));\n  ASSERT_EQ(Float64::convertFromSignedBV<8>(JFS_RM_RNE, minusOne),\n            Float64(-1.0));\n}\n\n// FIXME: Write more tests to test the different rounding modes\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/ConvertToFloatFromUnsignedBV.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(ConvertToFloatFromUnsignedBV, zero) {\n  ASSERT_TRUE((Float32::convertFromUnsignedBV<32>(JFS_RM_RNE, BitVector<32>(0)))\n                  .isZero());\n  ASSERT_TRUE((Float64::convertFromUnsignedBV<64>(JFS_RM_RNE, BitVector<64>(0)))\n                  .isZero());\n}\n\nTEST(ConvertToFloatFromUnsignedBV, TwoFiveSix) {\n  ASSERT_EQ(\n      (Float32::convertFromUnsignedBV<32>(JFS_RM_RNE, BitVector<32>(256))),\n      Float32(256.0f));\n  ASSERT_EQ(\n      (Float64::convertFromUnsignedBV<32>(JFS_RM_RNE, BitVector<32>(256))),\n      Float64(256.0));\n}\n\nTEST(ConvertToFloatFromUnsignedBV, Float32RoundedRTE) {\n  // These values are derived by running Z3 on the following query\n  /*\n    (declare-fun a () (_ BitVec 64))\n    (define-fun result () (_ FloatingPoint 8 24) ((_ to_fp_unsigned 8 24) RNE\n    a))\n    (define-fun conv_back () (_ BitVec 64) ((_ fp.to_ubv 64) RNE result))\n    (assert (not (fp.isNaN result)))\n    (assert (not (= a conv_back)))\n    (check-sat)\n    (get-value (a))\n    (get-value (result))\n    (get-value (conv_back))\n   */\n  BitVector<64> initialValue(UINT64_C(0xfe000f8000000000));\n  Float32 value = Float32::convertFromUnsignedBV<64>(JFS_RM_RNE, initialValue);\n  ASSERT_EQ(value, Float32(0, 0xbe, UINT32_C(0b11111100000000000010000)));\n}\n\nTEST(ConvertToFloatFromUnsignedBV, Float64RoundedRTE) {\n  // These values are derived by running Z3 on the following query\n  /*\n    (declare-fun a () (_ BitVec 64))\n    (define-fun result () (_ FloatingPoint 11 53) ((_ to_fp_unsigned 11 53) RNE\n    a))\n    (define-fun conv_back () (_ BitVec 64) ((_ fp.to_ubv 64) RNE result))\n    (assert (not (fp.isNaN result)))\n    (assert (not (= a conv_back)))\n    (check-sat)\n    (get-value (a))\n    (get-value (result))\n    (get-value (conv_back))\n   */\n  BitVector<64> initialValue(UINT64_C(0x8000000000000400));\n  Float64 value = Float64::convertFromUnsignedBV<64>(JFS_RM_RNE, initialValue);\n  ASSERT_EQ(value, Float64(0, 0b10000111110, UINT64_C(0x0000000000000)));\n}\n\n// FIXME: Write more tests to test the different rounding modes\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/ConvertToSignedBVFromFloat.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(ConvertToSignedBVFromFloat, positiveZero) {\n  ASSERT_EQ(Float32::getPositiveZero().convertToSignedBV<32>(JFS_RM_RNE),\n            BitVector<32>(0));\n  ASSERT_EQ(Float64::getPositiveZero().convertToSignedBV<32>(JFS_RM_RNE),\n            BitVector<32>(0));\n}\n\nTEST(ConvertToSignedBVFromFloat, negativeZero) {\n  ASSERT_EQ(Float32::getNegativeZero().convertToSignedBV<32>(JFS_RM_RNE),\n            BitVector<32>(0));\n  ASSERT_EQ(Float64::getNegativeZero().convertToSignedBV<32>(JFS_RM_RNE),\n            BitVector<32>(0));\n}\n\nTEST(ConvertToSignedBVFromFloat, TwoFiveSixPointTwo) {\n  ASSERT_EQ(Float32(256.2f).convertToSignedBV<32>(JFS_RM_RNE),\n            BitVector<32>(256));\n  ASSERT_EQ(Float64(256.2).convertToSignedBV<32>(JFS_RM_RNE),\n            BitVector<32>(256));\n}\n\nTEST(ConvertToSignedBVFromFloat, MinusOne) {\n  ASSERT_EQ(Float32(-1.0f).convertToSignedBV<8>(JFS_RM_RNE),\n            BitVector<8>(0xff));\n  ASSERT_EQ(Float64(-1.0f).convertToSignedBV<8>(JFS_RM_RNE),\n            BitVector<8>(0xff));\n}\n\n// FIXME: Write more tests to test the different rounding modes\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/ConvertToUnsignedBVFromFloat.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(ConvertToUnsignedBVFromFloat, zero) {\n  ASSERT_EQ(Float32::getPositiveZero().convertToUnsignedBV<32>(JFS_RM_RNE),\n            BitVector<32>(0));\n  ASSERT_EQ(Float64::getPositiveZero().convertToUnsignedBV<32>(JFS_RM_RNE),\n            BitVector<32>(0));\n}\n\nTEST(ConvertToUnsignedBVFromFloat, TwoFiveSixPointTwo) {\n  ASSERT_EQ(Float32(256.2f).convertToUnsignedBV<32>(JFS_RM_RNE),\n            BitVector<32>(256));\n  ASSERT_EQ(Float64(256.2).convertToUnsignedBV<32>(JFS_RM_RNE),\n            BitVector<32>(256));\n}\n\n// FIXME: Write more tests to test the different rounding modes\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/Div.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(Div, NaN) {\n  ASSERT_TRUE(Float32::getNaN().div(JFS_RM_RNE, Float32(1.0f)).isNaN());\n  ASSERT_TRUE(Float64::getNaN().div(JFS_RM_RNE, Float64(1.0)).isNaN());\n}\n\nTEST(Div, DivByZero) {\n  ASSERT_TRUE(\n      Float32::getPositiveZero().div(JFS_RM_RNE, Float32(0.0f)).isNaN());\n  ASSERT_TRUE(\n      Float32::getNegativeZero().div(JFS_RM_RNE, Float32(0.0f)).isNaN());\n  ASSERT_TRUE(Float64::getPositiveZero().div(JFS_RM_RNE, Float64(0.0)).isNaN());\n  ASSERT_TRUE(Float64::getNegativeZero().div(JFS_RM_RNE, Float64(0.0)).isNaN());\n}\n\nTEST(Div, Simple) {\n  ASSERT_EQ(4.0f, Float32(8.0f).div(JFS_RM_RNE, Float32(2.0f)).getRawData());\n  ASSERT_EQ(4.0, Float64(8.0).div(JFS_RM_RNE, Float64(2.0)).getRawData());\n}\n\nTEST(Div, DiffResultRNE_RTP_Float32) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (declare-fun b () (_ FloatingPoint 8 24))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert\n      (not\n        (fp.eq\n          (fp.div RNE a b)\n          (fp.div RTP a b)\n        )\n      )\n    )\n    (check-sat)\n    (get-model)\n  */\n  Float32 a(0, 0x7f, 0b00000000000000000000000);\n  Float32 b(1, 0x7e, 0b11111111111000000000000);\n  Float32 addRNE = a.div(JFS_RM_RNE, b);\n  Float32 addRTP = a.div(JFS_RM_RTP, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTP));\n  // FIXME: Check the result values\n}\n\nTEST(Div, DiffResultRNE_RTP_Float64) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (declare-fun b () (_ FloatingPoint 11 53))\n    (define-fun a_b_rne () (_ FloatingPoint 11 53) (fp.div RNE a b))\n    (define-fun a_b_rtp () (_ FloatingPoint 11 53) (fp.div RTP a b))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.eq a_b_rne a_b_rtp)))\n    (assert (not (fp.isNaN a_b_rne)))\n    (assert (not (fp.isNaN a_b_rtp)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(0, 0b00000000000, UINT64_C(0x410815d750e65));\n  Float64 b(0, 0b10000011011, UINT64_C(0x021c1b000e7c0));\n  Float64 addRNE = a.div(JFS_RM_RNE, b);\n  Float64 addRTP = a.div(JFS_RM_RTP, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTP));\n  // FIXME: Check the result values\n}\n\nTEST(Div, DiffResultRNE_RTN_Float32) {\n  // These values are derived from Z3 being run on the following query\n  /*\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (declare-fun b () (_ FloatingPoint 8 24))\n    (define-fun a_b_rne () (_ FloatingPoint 8 24) (fp.div RNE a b))\n    (define-fun a_b_rtn () (_ FloatingPoint 8 24) (fp.div RTN a b))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert\n      (not\n        (fp.eq\n          a_b_rne\n          a_b_rtn\n        )\n      )\n    )\n    (assert (not (fp.isNaN a_b_rne)))\n    (assert (not (fp.isNaN a_b_rtn)))\n    (check-sat)\n    (get-model)\n   */\n  Float32 a(0, 0x3e, 0b10010010000011110111111);\n  Float32 b(1, 0xd9, 0b10001101110101011000000);\n  Float32 addRNE = a.div(JFS_RM_RNE, b);\n  Float32 addRTN = a.div(JFS_RM_RTN, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTN));\n  // FIXME: Check the result values\n}\n\nTEST(Div, DiffResultRNE_RTN_Float64) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (declare-fun b () (_ FloatingPoint 11 53))\n    (define-fun a_b_rne () (_ FloatingPoint 11 53) (fp.div RNE a b))\n    (define-fun a_b_rtn () (_ FloatingPoint 11 53) (fp.div RTN a b))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.eq a_b_rne a_b_rtn)))\n    (assert (not (fp.isNaN a_b_rne)))\n    (assert (not (fp.isNaN a_b_rtn)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(1, 0b00000000000, UINT64_C(0x410815d750e65));\n  Float64 b(0, 0b10000011011, UINT64_C(0x021c1b000e7c0));\n  Float64 addRNE = a.div(JFS_RM_RNE, b);\n  Float64 addRTN = a.div(JFS_RM_RTN, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTN));\n  // FIXME: Check the result values\n}\n\nTEST(Div, DiffResultRNE_RTZ_Float32) {\n  // These values are derived from Z3 being run on the following query\n  /*\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (declare-fun b () (_ FloatingPoint 8 24))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert\n      (not\n        (fp.eq\n          (fp.div RNE a b)\n          (fp.div RTZ a b)\n        )\n      )\n    )\n    (check-sat)\n    (get-model)\n   */\n  Float32 a(1, 0x00, UINT32_C(0b01000010010001100110011));\n  Float32 b(1, 0x7f, UINT32_C(0b00010000000000000110001));\n  Float32 addRNE = a.div(JFS_RM_RNE, b);\n  Float32 addRTZ = a.div(JFS_RM_RTZ, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTZ));\n  // FIXME: Check the result values\n}\n\nTEST(Div, DiffResultRNE_RTZ_Float64) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (declare-fun b () (_ FloatingPoint 11 53))\n    (define-fun a_b_rne () (_ FloatingPoint 11 53) (fp.div RNE a b))\n    (define-fun a_b_rtz () (_ FloatingPoint 11 53) (fp.div RTZ a b))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.eq a_b_rne a_b_rtz)))\n    (assert (not (fp.isNaN a_b_rne)))\n    (assert (not (fp.isNaN a_b_rtz)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(1, 0b00101111110, UINT64_C(0xcfb924e8e8e89));\n  Float64 b(1, 0b10101111101, UINT64_C(0x0cb1d4012c003));\n  Float64 addRNE = a.div(JFS_RM_RNE, b);\n  Float64 addRTZ = a.div(JFS_RM_RTZ, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTZ));\n  // FIXME: Check the result values\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/FMA.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(FMA, NaN) {\n  ASSERT_TRUE(\n      Float32::getNaN().fma(JFS_RM_RNE, Float32(1.0f), Float32(1.0f)).isNaN());\n  ASSERT_TRUE(\n      Float64::getNaN().fma(JFS_RM_RNE, Float64(1.0f), Float64(1.0f)).isNaN());\n}\n\nTEST(FMA, Simple) {\n  ASSERT_EQ(\n      7.0f,\n      Float32(2.0f).fma(JFS_RM_RNE, Float32(3.0f), Float32(1.0f)).getRawData());\n  ASSERT_EQ(\n      7.0,\n      Float64(2.0).fma(JFS_RM_RNE, Float64(3.0), Float64(1.0)).getRawData());\n}\n\nTEST(FMA, DiffResultRNE_RTP_Float32) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (declare-fun b () (_ FloatingPoint 8 24))\n    (declare-fun c () (_ FloatingPoint 8 24))\n    (define-fun result_rne () (_ FloatingPoint 8 24) (fp.fma RNE a b c))\n    (define-fun result_rtp () (_ FloatingPoint 8 24) (fp.fma RTP a b c))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.isNaN c)))\n    (assert\n      (not\n        (fp.eq\n          result_rne\n          result_rtp\n        )\n      )\n    )\n    (assert (not (fp.isNaN result_rne)))\n    (assert (not (fp.isNaN result_rtp)))\n    (check-sat)\n    (get-model)\n  */\n  Float32 a(0, 0x7e, 0b00000111111111010000000);\n  Float32 b(0, 0x00, 0b00000000000000001111101);\n  Float32 c(1, 0x98, 0b00000000000100011000000);\n  Float32 resultRNE = a.fma(JFS_RM_RNE, b, c);\n  Float32 resultRTP = a.fma(JFS_RM_RTP, b, c);\n  ASSERT_FALSE(resultRNE.ieeeEquals(resultRTP));\n  // FIXME: Check the result values\n}\n\nTEST(FMA, DiffResultRNE_RTP_Float64) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (declare-fun b () (_ FloatingPoint 11 53))\n    (declare-fun c () (_ FloatingPoint 11 53))\n    (define-fun result_rne () (_ FloatingPoint 11 53) (fp.fma RNE a b c))\n    (define-fun result_rtp () (_ FloatingPoint 11 53) (fp.fma RTP a b c))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.isNaN c)))\n    (assert\n      (not\n        (fp.eq\n          result_rne\n          result_rtp\n        )\n      )\n    )\n    (assert (not (fp.isNaN result_rne)))\n    (assert (not (fp.isNaN result_rtp)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(1, 0b11111111101, UINT64_C(0x036919b77c30c));\n  Float64 b(0, 0b11111111100, UINT64_C(0x10000005b5620));\n  Float64 c(0, 0b01110011111, UINT64_C(0x0000000000000));\n  Float64 resultRNE = a.fma(JFS_RM_RNE, b, c);\n  Float64 resultRTP = a.fma(JFS_RM_RTP, b, c);\n  ASSERT_FALSE(resultRNE.ieeeEquals(resultRTP));\n  // FIXME: Check the result values\n}\n\nTEST(FMA, DiffResultRNE_RTN_Float32) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (declare-fun b () (_ FloatingPoint 8 24))\n    (declare-fun c () (_ FloatingPoint 8 24))\n    (define-fun result_rne () (_ FloatingPoint 8 24) (fp.fma RNE a b c))\n    (define-fun result_rtn () (_ FloatingPoint 8 24) (fp.fma RTN a b c))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.isNaN c)))\n    (assert\n      (not\n        (fp.eq\n          result_rne\n          result_rtn\n        )\n      )\n    )\n    (assert (not (fp.isNaN result_rne)))\n    (assert (not (fp.isNaN result_rtn)))\n    (check-sat)\n    (get-model)\n  */\n  Float32 a(0, 0xfe, 0b11111011110001000001110);\n  Float32 b(0, 0x05, 0b00000000000000000000000);\n  Float32 c(0, 0x80, 0b01111000000101111111111);\n  Float32 resultRNE = a.fma(JFS_RM_RNE, b, c);\n  Float32 resultRTN = a.fma(JFS_RM_RTN, b, c);\n  ASSERT_FALSE(resultRNE.ieeeEquals(resultRTN));\n  // FIXME: Check the result values\n}\n\nTEST(FMA, DiffResultRNE_RTN_Float64) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (declare-fun b () (_ FloatingPoint 11 53))\n    (declare-fun c () (_ FloatingPoint 11 53))\n    (define-fun result_rne () (_ FloatingPoint 11 53) (fp.fma RNE a b c))\n    (define-fun result_rtn () (_ FloatingPoint 11 53) (fp.fma RTN a b c))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.isNaN c)))\n    (assert\n      (not\n        (fp.eq\n          result_rne\n          result_rtn\n        )\n      )\n    )\n    (assert (not (fp.isNaN result_rne)))\n    (assert (not (fp.isNaN result_rtn)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(0, 0b00000000000, UINT64_C(0x8204000000010));\n  Float64 b(1, 0b11111111110, UINT64_C(0x0000000010000));\n  Float64 c(0, 0b10001111111, UINT64_C(0x0000000000000));\n  Float64 resultRNE = a.fma(JFS_RM_RNE, b, c);\n  Float64 resultRTN = a.fma(JFS_RM_RTN, b, c);\n  ASSERT_FALSE(resultRNE.ieeeEquals(resultRTN));\n  // FIXME: Check the result values\n}\n\nTEST(FMA, DiffResultRNE_RTZ_Float32) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (declare-fun b () (_ FloatingPoint 8 24))\n    (declare-fun c () (_ FloatingPoint 8 24))\n    (define-fun result_rne () (_ FloatingPoint 8 24) (fp.fma RNE a b c))\n    (define-fun result_rtz () (_ FloatingPoint 8 24) (fp.fma RTZ a b c))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.isNaN c)))\n    (assert\n      (not\n        (fp.eq\n          result_rne\n          result_rtz\n        )\n      )\n    )\n    (assert (not (fp.isNaN result_rne)))\n    (assert (not (fp.isNaN result_rtz)))\n    (check-sat)\n    (get-model)\n  */\n  Float32 a(1, 0x00, UINT32_C(0b00000000000000100100000));\n  Float32 b(1, 0x88, UINT32_C(0b01101010001110001110000));\n  Float32 c(0, 0x07, UINT32_C(0b00000001100010101000101));\n  Float32 resultRNE = a.fma(JFS_RM_RNE, b, c);\n  Float32 resultRTZ = a.fma(JFS_RM_RTZ, b, c);\n  ASSERT_FALSE(resultRNE.ieeeEquals(resultRTZ));\n  // FIXME: Check the result values\n}\n\nTEST(FMA, DiffResultRNE_RTZ_Float64) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (declare-fun b () (_ FloatingPoint 11 53))\n    (declare-fun c () (_ FloatingPoint 11 53))\n    (define-fun result_rne () (_ FloatingPoint 11 53) (fp.fma RNE a b c))\n    (define-fun result_rtz () (_ FloatingPoint 11 53) (fp.fma RTZ a b c))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.isNaN c)))\n    (assert\n      (not\n        (fp.eq\n          result_rne\n          result_rtz\n        )\n      )\n    )\n    (assert (not (fp.isNaN result_rne)))\n    (assert (not (fp.isNaN result_rtz)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(1, 0b00101000000, UINT64_C(0xf723129ff9530));\n  Float64 b(0, 0b11110111111, UINT64_C(0x3f670f9f1dff0));\n  Float64 c(0, 0b10011111111, UINT64_C(0xf4cfc0fdffbb7));\n  Float64 resultRNE = a.fma(JFS_RM_RNE, b, c);\n  Float64 resultRTZ = a.fma(JFS_RM_RTZ, b, c);\n  ASSERT_FALSE(resultRNE.ieeeEquals(resultRTZ));\n  ASSERT_EQ(resultRNE, Float64(1, 0b10100000000, UINT64_C(0x795761869e022)));\n  ASSERT_EQ(resultRTZ, Float64(1, 0b10100000000, UINT64_C(0x795761869e021)));\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/GreaterThan.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(GreaterThan, NaNCmpNaN) {\n  ASSERT_FALSE(Float32::getNaN().fpgt(Float32::getNaN()));\n  ASSERT_FALSE(Float64::getNaN().fpgt(Float64::getNaN()));\n}\n\nTEST(GreaterThan, SameValues) {\n  ASSERT_FALSE(Float32(1.0f).fpgt(1.0f));\n  ASSERT_FALSE(Float64(1.0).fpgt(1.0));\n}\n\nTEST(GreaterThan, SmallLessBig) {\n  ASSERT_FALSE(Float32(1.0f).fpgt(255.0f));\n  ASSERT_FALSE(Float64(1.0).fpgt(255.0));\n}\n\nTEST(GreaterThan, BigLessSmall) {\n  ASSERT_TRUE(Float32(255.0f).fpgt(1.0f));\n  ASSERT_TRUE(Float64(255.0).fpgt(1.0));\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/GreaterThanOrEqual.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(GreaterThanOrEqual, NaNCmpNaN) {\n  ASSERT_FALSE(Float32::getNaN().fpgeq(Float32::getNaN()));\n  ASSERT_FALSE(Float64::getNaN().fpgeq(Float64::getNaN()));\n}\n\nTEST(GreaterThanOrEqual, SameValues) {\n  ASSERT_TRUE(Float32(1.0f).fpgeq(1.0f));\n  ASSERT_TRUE(Float64(1.0).fpgeq(1.0));\n}\n\nTEST(GreaterThanOrEqual, SmallLessBig) {\n  ASSERT_FALSE(Float32(1.0f).fpgeq(255.0f));\n  ASSERT_FALSE(Float64(1.0).fpgeq(255.0));\n}\n\nTEST(GreaterThanOrEqual, BigLessSmall) {\n  ASSERT_TRUE(Float32(255.0f).fpgeq(1.0f));\n  ASSERT_TRUE(Float64(255.0).fpgeq(1.0));\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/IEEEEquals.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nnamespace {\n\ntemplate <typename T> void checkCommonConstants() {\n  ASSERT_TRUE(T::getPositiveZero().ieeeEquals(T::getPositiveZero()));\n  ASSERT_TRUE(T::getPositiveZero().ieeeEquals(T::getNegativeZero()));\n  ASSERT_TRUE(T::getNegativeZero().ieeeEquals(T::getPositiveZero()));\n  ASSERT_TRUE(T::getNegativeZero().ieeeEquals(T::getNegativeZero()));\n\n  ASSERT_TRUE(T::getPositiveInfinity().ieeeEquals(T::getPositiveInfinity()));\n  ASSERT_TRUE(T::getNegativeInfinity().ieeeEquals(T::getNegativeInfinity()));\n\n  ASSERT_FALSE(T::getNaN().ieeeEquals(T::getNaN()));\n  ASSERT_FALSE(T::getPositiveZero().ieeeEquals(T::getNaN()));\n  ASSERT_FALSE(T::getNaN().ieeeEquals(T::getPositiveZero()));\n\n  ASSERT_TRUE(T(1.5).ieeeEquals(T(1.5)));\n}\n}\n\nTEST(IEEEEquals, DisjointConstantsDisjointFloat32) {\n  checkCommonConstants<Float32>();\n}\n\nTEST(IEEEEquals, DisjointConstantsDisjointFloat64) {\n  checkCommonConstants<Float64>();\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/IsInfinite.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n#include <math.h>\n\nTEST(IsInfinite, Float32) {\n  ASSERT_FALSE(Float32::getNaN().isInfinite());\n  ASSERT_FALSE(Float32::getPositiveZero().isInfinite());\n  ASSERT_FALSE(Float32::getNegativeZero().isInfinite());\n  ASSERT_TRUE(Float32::getPositiveInfinity().isInfinite());\n  ASSERT_TRUE(Float32::getNegativeInfinity().isInfinite());\n  ASSERT_FALSE(Float32(0.0f).isInfinite());\n  ASSERT_FALSE(Float32(1.0f).isInfinite());\n  ASSERT_FALSE(Float32(-1.0f).isInfinite());\n  Float32 subnormal(BitVector<1>(0x0), BitVector<8>(0x0), BitVector<23>(0x1));\n  ASSERT_FALSE(subnormal.isInfinite());\n  Float32 subnormalNeg(BitVector<1>(0x1), BitVector<8>(0x0),\n                       BitVector<23>(0x1));\n  ASSERT_FALSE(subnormalNeg.isInfinite());\n  Float32 negNaN(BitVector<1>(0x1), BitVector<8>(0xff), BitVector<23>(0x1));\n  ASSERT_FALSE(negNaN.isInfinite());\n  Float32 posNaN(BitVector<1>(0x0), BitVector<8>(0xff), BitVector<23>(0x1));\n  ASSERT_FALSE(posNaN.isInfinite());\n}\n\nTEST(IsInfinite, Float64) {\n  ASSERT_FALSE(Float64::getNaN().isInfinite());\n  ASSERT_FALSE(Float64::getPositiveZero().isInfinite());\n  ASSERT_FALSE(Float64::getNegativeZero().isInfinite());\n  ASSERT_TRUE(Float64::getPositiveInfinity().isInfinite());\n  ASSERT_TRUE(Float64::getNegativeInfinity().isInfinite());\n  ASSERT_FALSE(Float64(0.0).isInfinite());\n  ASSERT_FALSE(Float64(-0.0).isInfinite());\n  ASSERT_FALSE(Float64(1.0).isInfinite());\n  ASSERT_FALSE(Float64(-1.0).isInfinite());\n  Float64 subnormal(BitVector<1>(0x0), BitVector<11>(0x0), BitVector<52>(0x1));\n  ASSERT_FALSE(subnormal.isInfinite());\n  Float64 subnormalNeg(BitVector<1>(0x1), BitVector<11>(0x0),\n                       BitVector<52>(0x1));\n  ASSERT_FALSE(subnormalNeg.isInfinite());\n  Float64 negNaN(BitVector<1>(0x1), BitVector<11>(0x7ff), BitVector<52>(0x1));\n  ASSERT_FALSE(negNaN.isInfinite());\n  Float64 posNaN(BitVector<1>(0x0), BitVector<11>(0x7ff), BitVector<52>(0x1));\n  ASSERT_FALSE(posNaN.isInfinite());\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/IsNaN.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n#include <math.h>\n\nTEST(IsNaN, fromFloat32API) {\n  Float32 n = Float32::getNaN();\n  ASSERT_TRUE(n.isNaN());\n}\n\nTEST(IsNaN, fromFloat64API) {\n  Float64 n = Float64::getNaN();\n  ASSERT_TRUE(n.isNaN());\n}\n\nTEST(IsNaN, onZeroFloat32) {\n  Float32 n(0.0f);\n  ASSERT_FALSE(n.isNaN());\n}\n\nTEST(IsNaN, onZeroFloat64) {\n  Float64 n(0.0f);\n  ASSERT_FALSE(n.isNaN());\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/IsNegative.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n#include <math.h>\n\nTEST(IsNegative, Float32) {\n  ASSERT_FALSE(Float32::getNaN().isNegative());\n  ASSERT_FALSE(Float32::getPositiveZero().isNegative());\n  ASSERT_TRUE(Float32::getNegativeZero().isNegative());\n  ASSERT_FALSE(Float32::getPositiveInfinity().isNegative());\n  ASSERT_TRUE(Float32::getNegativeInfinity().isNegative());\n  ASSERT_FALSE(Float32(0.0f).isNegative());\n  ASSERT_FALSE(Float32(1.0f).isNegative());\n  ASSERT_TRUE(Float32(-1.0f).isNegative());\n  Float32 subnormal(BitVector<1>(0x0), BitVector<8>(0x0), BitVector<23>(0x1));\n  ASSERT_FALSE(subnormal.isNegative());\n  Float32 subnormalNeg(BitVector<1>(0x1), BitVector<8>(0x0),\n                       BitVector<23>(0x1));\n  ASSERT_TRUE(subnormalNeg.isNegative());\n  Float32 negNaN(BitVector<1>(0x1), BitVector<8>(0xff), BitVector<23>(0x1));\n  ASSERT_FALSE(negNaN.isNegative());\n  Float32 posNaN(BitVector<1>(0x0), BitVector<8>(0xff), BitVector<23>(0x1));\n  ASSERT_FALSE(posNaN.isNegative());\n}\n\nTEST(IsNegative, Float64) {\n  ASSERT_FALSE(Float64::getNaN().isNegative());\n  ASSERT_FALSE(Float64::getPositiveZero().isNegative());\n  ASSERT_TRUE(Float64::getNegativeZero().isNegative());\n  ASSERT_FALSE(Float64::getPositiveInfinity().isNegative());\n  ASSERT_TRUE(Float64::getNegativeInfinity().isNegative());\n  ASSERT_FALSE(Float64(0.0).isNegative());\n  ASSERT_TRUE(Float64(-0.0).isNegative());\n  ASSERT_FALSE(Float64(1.0).isNegative());\n  ASSERT_TRUE(Float64(-1.0).isNegative());\n  Float64 subnormal(BitVector<1>(0x0), BitVector<11>(0x0), BitVector<52>(0x1));\n  ASSERT_FALSE(subnormal.isNegative());\n  Float64 subnormalNeg(BitVector<1>(0x1), BitVector<11>(0x0),\n                       BitVector<52>(0x1));\n  ASSERT_TRUE(subnormalNeg.isNegative());\n  Float64 negNaN(BitVector<1>(0x1), BitVector<11>(0x7ff), BitVector<52>(0x1));\n  ASSERT_FALSE(negNaN.isNegative());\n  Float64 posNaN(BitVector<1>(0x0), BitVector<11>(0x7ff), BitVector<52>(0x1));\n  ASSERT_FALSE(posNaN.isNegative());\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/IsNormal.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n#include <math.h>\n\nTEST(IsNormal, Float32) {\n  ASSERT_FALSE(Float32::getNaN().isNormal());\n  ASSERT_FALSE(Float32::getPositiveZero().isNormal());\n  ASSERT_FALSE(Float32::getNegativeZero().isNormal());\n  ASSERT_FALSE(Float32::getPositiveInfinity().isNormal());\n  ASSERT_FALSE(Float32::getNegativeInfinity().isNormal());\n  ASSERT_FALSE(Float32(0.0f).isNormal());\n  ASSERT_TRUE(Float32(1.0f).isNormal());\n  Float32 subnormal(BitVector<1>(0x0), BitVector<8>(0x0), BitVector<23>(0x1));\n  ASSERT_FALSE(subnormal.isNormal());\n}\n\nTEST(IsNormal, Float64) {\n  ASSERT_FALSE(Float64::getNaN().isNormal());\n  ASSERT_FALSE(Float64::getPositiveZero().isNormal());\n  ASSERT_FALSE(Float64::getNegativeZero().isNormal());\n  ASSERT_FALSE(Float64::getPositiveInfinity().isNormal());\n  ASSERT_FALSE(Float64::getNegativeInfinity().isNormal());\n  ASSERT_FALSE(Float64(0.0f).isNormal());\n  ASSERT_TRUE(Float64(1.0f).isNormal());\n  Float64 subnormal(BitVector<1>(0x0), BitVector<11>(0x0), BitVector<52>(0x1));\n  ASSERT_FALSE(subnormal.isNormal());\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/IsPositive.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n#include <math.h>\n\nTEST(IsPositive, Float32) {\n  ASSERT_FALSE(Float32::getNaN().isPositive());\n  ASSERT_TRUE(Float32::getPositiveZero().isPositive());\n  ASSERT_FALSE(Float32::getNegativeZero().isPositive());\n  ASSERT_TRUE(Float32::getPositiveInfinity().isPositive());\n  ASSERT_FALSE(Float32::getNegativeInfinity().isPositive());\n  ASSERT_TRUE(Float32(0.0f).isPositive());\n  ASSERT_TRUE(Float32(1.0f).isPositive());\n  Float32 subnormal(BitVector<1>(0x0), BitVector<8>(0x0), BitVector<23>(0x1));\n  ASSERT_TRUE(subnormal.isPositive());\n  Float32 subnormalNeg(BitVector<1>(0x1), BitVector<8>(0x0),\n                       BitVector<23>(0x1));\n  ASSERT_FALSE(subnormalNeg.isPositive());\n  Float32 negNaN(BitVector<1>(0x1), BitVector<8>(0xff), BitVector<23>(0x1));\n  ASSERT_FALSE(negNaN.isPositive());\n  Float32 posNaN(BitVector<1>(0x0), BitVector<8>(0xff), BitVector<23>(0x1));\n  ASSERT_FALSE(posNaN.isPositive());\n}\n\nTEST(IsPositive, Float64) {\n  ASSERT_FALSE(Float64::getNaN().isPositive());\n  ASSERT_TRUE(Float64::getPositiveZero().isPositive());\n  ASSERT_FALSE(Float64::getNegativeZero().isPositive());\n  ASSERT_TRUE(Float64::getPositiveInfinity().isPositive());\n  ASSERT_FALSE(Float64::getNegativeInfinity().isPositive());\n  ASSERT_TRUE(Float64(0.0).isPositive());\n  ASSERT_FALSE(Float64(-0.0).isPositive());\n  ASSERT_TRUE(Float64(1.0f).isPositive());\n  Float64 subnormal(BitVector<1>(0x0), BitVector<11>(0x0), BitVector<52>(0x1));\n  ASSERT_TRUE(subnormal.isPositive());\n  Float64 subnormalNeg(BitVector<1>(0x1), BitVector<11>(0x0),\n                       BitVector<52>(0x1));\n  ASSERT_FALSE(subnormalNeg.isPositive());\n  Float64 negNaN(BitVector<1>(0x1), BitVector<11>(0x7ff), BitVector<52>(0x1));\n  ASSERT_FALSE(negNaN.isPositive());\n  Float64 posNaN(BitVector<1>(0x0), BitVector<11>(0x7ff), BitVector<52>(0x1));\n  ASSERT_FALSE(posNaN.isPositive());\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/IsSubnormal.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n#include <math.h>\n\nTEST(IsSubnormal, Float32) {\n  ASSERT_FALSE(Float32::getNaN().isSubnormal());\n  ASSERT_FALSE(Float32::getPositiveZero().isSubnormal());\n  ASSERT_FALSE(Float32::getNegativeZero().isSubnormal());\n  ASSERT_FALSE(Float32::getPositiveInfinity().isSubnormal());\n  ASSERT_FALSE(Float32::getNegativeInfinity().isSubnormal());\n  ASSERT_FALSE(Float32(0.0f).isSubnormal());\n  ASSERT_FALSE(Float32(1.0f).isSubnormal());\n  Float32 subnormal(BitVector<1>(0x0), BitVector<8>(0x0), BitVector<23>(0x1));\n  ASSERT_TRUE(subnormal.isSubnormal());\n}\n\nTEST(IsSubnormal, Float64) {\n  ASSERT_FALSE(Float64::getNaN().isSubnormal());\n  ASSERT_FALSE(Float64::getPositiveZero().isSubnormal());\n  ASSERT_FALSE(Float64::getNegativeZero().isSubnormal());\n  ASSERT_FALSE(Float64::getPositiveInfinity().isSubnormal());\n  ASSERT_FALSE(Float64::getNegativeInfinity().isSubnormal());\n  ASSERT_FALSE(Float64(0.0f).isSubnormal());\n  ASSERT_FALSE(Float64(1.0f).isSubnormal());\n  Float64 subnormal(BitVector<1>(0x0), BitVector<11>(0x0), BitVector<52>(0x1));\n  ASSERT_TRUE(subnormal.isSubnormal());\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/IsZero.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n#include <math.h>\n\nTEST(IsZero, Float32) {\n  ASSERT_FALSE(Float32::getNaN().isZero());\n  ASSERT_TRUE(Float32::getPositiveZero().isZero());\n  ASSERT_TRUE(Float32::getNegativeZero().isZero());\n  ASSERT_FALSE(Float32::getPositiveInfinity().isZero());\n  ASSERT_FALSE(Float32::getNegativeInfinity().isZero());\n  ASSERT_TRUE(Float32(0.0f).isZero());\n  ASSERT_FALSE(Float32(1.0f).isZero());\n  Float32 subnormal(BitVector<1>(0x0), BitVector<8>(0x0), BitVector<23>(0x1));\n  ASSERT_FALSE(subnormal.isZero());\n}\n\nTEST(IsZero, Float64) {\n  ASSERT_FALSE(Float64::getNaN().isZero());\n  ASSERT_TRUE(Float64::getPositiveZero().isZero());\n  ASSERT_TRUE(Float64::getNegativeZero().isZero());\n  ASSERT_FALSE(Float64::getPositiveInfinity().isZero());\n  ASSERT_FALSE(Float64::getNegativeInfinity().isZero());\n  ASSERT_TRUE(Float64(0.0f).isZero());\n  ASSERT_FALSE(Float64(1.0f).isZero());\n  Float64 subnormal(BitVector<1>(0x0), BitVector<11>(0x0), BitVector<52>(0x1));\n  ASSERT_FALSE(subnormal.isZero());\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/LessThan.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(LessThan, NaNCmpNaN) {\n  ASSERT_FALSE(Float32::getNaN().fplt(Float32::getNaN()));\n  ASSERT_FALSE(Float64::getNaN().fplt(Float64::getNaN()));\n}\n\nTEST(LessThan, SameValues) {\n  ASSERT_FALSE(Float32(1.0f).fplt(1.0f));\n  ASSERT_FALSE(Float64(1.0).fplt(1.0));\n}\n\nTEST(LessThan, SmallLessBig) {\n  ASSERT_TRUE(Float32(1.0f).fplt(255.0f));\n  ASSERT_TRUE(Float64(1.0).fplt(255.0));\n}\n\nTEST(LessThan, BigLessSmall) {\n  ASSERT_FALSE(Float32(255.0f).fplt(1.0f));\n  ASSERT_FALSE(Float64(255.0).fplt(1.0));\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/LessThanOrEqual.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(LessThanOrEqual, NaNCmpNaN) {\n  ASSERT_FALSE(Float32::getNaN().fpleq(Float32::getNaN()));\n  ASSERT_FALSE(Float64::getNaN().fpleq(Float64::getNaN()));\n}\n\nTEST(LessThanOrEqual, SameValues) {\n  ASSERT_TRUE(Float32(1.0f).fpleq(1.0f));\n  ASSERT_TRUE(Float64(1.0).fpleq(1.0));\n}\n\nTEST(LessThanOrEqual, SmallLessBig) {\n  ASSERT_TRUE(Float32(1.0f).fpleq(255.0f));\n  ASSERT_TRUE(Float64(1.0).fpleq(255.0));\n}\n\nTEST(LessThanOrEqual, BigLessSmall) {\n  ASSERT_FALSE(Float32(255.0f).fpleq(1.0f));\n  ASSERT_FALSE(Float64(255.0).fpleq(1.0));\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/MakeFromBuffer.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n#include <math.h>\n#include <memory>\n#include <string.h>\n\nnamespace {\nvoid testFloat32Bits(jfs_nr_float32 initialValue, uint32_t expectedBits) {\n  uint8_t buffer[sizeof(jfs_nr_float32)];\n  jfs_nr_float32* view = reinterpret_cast<jfs_nr_float32*>(buffer);\n  *view = initialValue;\n  BufferRef<const uint8_t> bufferRef(buffer, sizeof(jfs_nr_float32));\n  Float32 x = makeFloatFrom<8, 24>(bufferRef, 0, 31);\n  ASSERT_EQ(x.getRawBits(), expectedBits);\n}\n\nvoid testFloat32Value(jfs_nr_float32 initialValue) {\n  uint8_t buffer[sizeof(jfs_nr_float32)];\n  jfs_nr_float32* view = reinterpret_cast<jfs_nr_float32*>(buffer);\n  *view = initialValue;\n  BufferRef<const uint8_t> bufferRef(buffer, sizeof(jfs_nr_float32));\n  Float32 x = makeFloatFrom<8, 24>(bufferRef, 0, 31);\n  ASSERT_EQ(x.getRawData(), initialValue);\n}\n\nvoid testFloat64Bits(jfs_nr_float64 initialValue, uint64_t expectedBits) {\n  uint8_t buffer[sizeof(jfs_nr_float64)];\n  jfs_nr_float64* view = reinterpret_cast<jfs_nr_float64*>(buffer);\n  *view = initialValue;\n  BufferRef<const uint8_t> bufferRef(buffer, sizeof(jfs_nr_float64));\n  Float64 x = makeFloatFrom<11, 53>(bufferRef, 0, 63);\n  ASSERT_EQ(x.getRawBits(), expectedBits);\n}\n\nvoid testFloat64Value(jfs_nr_float64 initialValue) {\n  uint8_t buffer[sizeof(jfs_nr_float64)];\n  jfs_nr_float64* view = reinterpret_cast<jfs_nr_float64*>(buffer);\n  *view = initialValue;\n  BufferRef<const uint8_t> bufferRef(buffer, sizeof(jfs_nr_float64));\n  Float64 x = makeFloatFrom<11, 53>(bufferRef, 0, 63);\n  ASSERT_EQ(x.getRawData(), initialValue);\n}\n}\n\nTEST(MakeFromBuffer, PositiveZero) {\n  testFloat32Bits(0.0f, UINT32_C(0x0));\n  testFloat64Bits(0.0, UINT64_C(0x0));\n}\n\nTEST(MakeFromBuffer, NegativeZero) {\n  testFloat32Bits(-0.0f, UINT32_C(0x80000000));\n  testFloat64Bits(-0.0, UINT64_C(0x8000000000000000));\n}\n\nTEST(MakeFromBuffer, PositiveInf) {\n  testFloat32Bits(INFINITY, UINT32_C(0x7f800000));\n  testFloat64Bits(INFINITY, UINT64_C(0x7ff0000000000000));\n}\n\nTEST(MakeFromBuffer, NegativeInf) {\n  testFloat32Bits(-INFINITY, UINT32_C(0xff800000));\n  testFloat64Bits(-INFINITY, UINT64_C(0xfff0000000000000));\n}\n\nTEST(MakeFromBuffer, PositiveOnes) {\n  testFloat32Value(1.0f);\n  testFloat64Value(1.0);\n}\n\nTEST(MakeFromBuffer, NegativeOnes) {\n  testFloat32Value(-1.0f);\n  testFloat64Value(-1.0);\n}\n\nTEST(MakeFromBuffer, NaN) {\n  testFloat32Bits(NAN, jfs_nr_float32_get_raw_bits(NAN));\n  testFloat64Bits(NAN, jfs_nr_float64_get_raw_bits(NAN));\n}\n\nTEST(MakeFromBuffer, simpleValuesFloat32) {\n  float values[] = {1.0f, 2.0f, 0.1f, 256.0f};\n  uint8_t* view = reinterpret_cast<uint8_t*>(values);\n  const size_t viewSize = sizeof(values);\n  BufferRef<const uint8_t> bufferRef(view, viewSize);\n  Float32 repr[]{\n      makeFloatFrom<8, 24>(bufferRef, 0, 31),\n      makeFloatFrom<8, 24>(bufferRef, 32, 63),\n      makeFloatFrom<8, 24>(bufferRef, 64, 95),\n      makeFloatFrom<8, 24>(bufferRef, 96, 127),\n  };\n  // Check bits\n  for (unsigned index = 0; index < sizeof(values) / sizeof(float); ++index) {\n    ASSERT_EQ(repr[index].getRawBits(),\n              jfs_nr_float32_get_raw_bits(values[index]));\n  }\n}\n\nTEST(MakeFromBuffer, simpleValuesFloat64) {\n  double values[] = {1.0, 2.0, 0.1, 256.0};\n  uint8_t* view = reinterpret_cast<uint8_t*>(values);\n  const size_t viewSize = sizeof(values);\n  BufferRef<const uint8_t> bufferRef(view, viewSize);\n  Float64 repr[]{\n      makeFloatFrom<11, 53>(bufferRef, 0, 63),\n      makeFloatFrom<11, 53>(bufferRef, 64, 127),\n      makeFloatFrom<11, 53>(bufferRef, 128, 191),\n      makeFloatFrom<11, 53>(bufferRef, 192, 255),\n  };\n  // Check bits\n  for (unsigned index = 0; index < sizeof(values) / sizeof(double); ++index) {\n    ASSERT_EQ(repr[index].getRawBits(),\n              jfs_nr_float64_get_raw_bits(values[index]));\n  }\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/MakeFromIEEEBitVector.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n#include <cmath>\n\nTEST(MakeFromIEEEBitVector, PositiveZeroFloat32) {\n  Float32 f(BitVector<32>(0x0));\n  ASSERT_EQ(f.getRawData(), 0.0f);\n  ASSERT_FALSE(std::signbit(f.getRawData()));\n  Float32 zero = Float32::getPositiveZero();\n  ASSERT_EQ(zero, f);\n}\n\nTEST(MakeFromIEEEBitVector, PositiveZeroFloat64) {\n  Float64 f(BitVector<64>(0x0));\n  ASSERT_EQ(f.getRawData(), 0.0);\n  ASSERT_FALSE(std::signbit(f.getRawData()));\n  Float64 zero = Float64::getPositiveZero();\n  ASSERT_EQ(zero, f);\n}\n\nTEST(MakeFromIEEEBitVector, NegativeZeroFloat32) {\n  Float32 f(BitVector<32>(UINT32_C(0x80000000)));\n  ASSERT_EQ(f.getRawData(), 0.0f);\n  ASSERT_TRUE(std::signbit(f.getRawData()));\n  Float32 zero = Float32::getNegativeZero();\n  ASSERT_EQ(zero, f);\n}\n\nTEST(MakeFromIEEEBitVector, NegativeZeroFloat64) {\n  Float64 f(BitVector<64>(UINT64_C(0x8000000000000000)));\n  ASSERT_EQ(f.getRawData(), 0.0);\n  ASSERT_TRUE(std::signbit(f.getRawData()));\n  Float64 zero = Float64::getNegativeZero();\n  ASSERT_EQ(zero, f);\n}\n\nTEST(MakeFromIEEEBitVector, PositiveInfinityFloat32) {\n  Float32 f(BitVector<32>(UINT32_C(0x7f800000)));\n  ASSERT_TRUE(std::isinf(f.getRawData()));\n  ASSERT_FALSE(std::signbit(f.getRawData()));\n  Float32 inf = Float32::getPositiveInfinity();\n  ASSERT_EQ(inf, f);\n}\n\nTEST(MakeFromIEEEBitVector, PositiveInfinityFloat64) {\n  Float64 f(BitVector<64>(UINT64_C(0x7ff0000000000000)));\n  ASSERT_TRUE(std::isinf(f.getRawData()));\n  ASSERT_FALSE(std::signbit(f.getRawData()));\n  Float64 inf = Float64::getPositiveInfinity();\n  ASSERT_EQ(inf, f);\n}\n\nTEST(MakeFromIEEEBitVector, NegativeInfinityFloat32) {\n  Float32 f(BitVector<32>(UINT32_C(0xff800000)));\n  ASSERT_TRUE(std::isinf(f.getRawData()));\n  ASSERT_TRUE(std::signbit(f.getRawData()));\n  Float32 inf = Float32::getNegativeInfinity();\n  ASSERT_EQ(inf, f);\n}\n\nTEST(MakeFromIEEEBitVector, NegativeInfinityFloat64) {\n  Float64 f(BitVector<64>(UINT64_C(0xfff0000000000000)));\n  ASSERT_TRUE(std::isinf(f.getRawData()));\n  ASSERT_TRUE(std::signbit(f.getRawData()));\n  Float64 inf = Float64::getNegativeInfinity();\n  ASSERT_EQ(inf, f);\n}\n\nTEST(MakeFromIEEEBitVector, NaNFloat32) {\n  Float32 f(BitVector<32>(jfs_nr_float32_get_raw_bits(NAN)));\n  ASSERT_TRUE(std::isnan(f.getRawData()));\n  auto NaN = Float32::getNaN();\n  ASSERT_EQ(NaN, f);\n}\n\nTEST(MakeFromIEEEBitVector, NaNFloat64) {\n  Float64 f(BitVector<64>(jfs_nr_float64_get_raw_bits(NAN)));\n  ASSERT_TRUE(std::isnan(f.getRawData()));\n  auto NaN = Float64::getNaN();\n  ASSERT_EQ(NaN, f);\n}\n\nTEST(MakeFromIEEEBitVector, onePointTwoFiveFloat32) {\n  Float32 f(BitVector<32>(UINT32_C(0x3fa00000)));\n  ASSERT_EQ(f.getRawData(), 1.25f);\n}\n\nTEST(MakeFromIEEEBitVector, onePointTwoFiveFloat64) {\n  Float64 f(BitVector<64>(UINT64_C(0x3ff4000000000000)));\n  ASSERT_EQ(f.getRawData(), 1.25);\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/MakeFromTriple.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n#include <math.h>\n#include <memory>\n#include <string.h>\n\nnamespace {\n\nvoid testFloat32Bits(jfs_nr_bitvector_ty sign, jfs_nr_bitvector_ty exponent,\n                     jfs_nr_bitvector_ty significand,\n                     jfs_nr_bitvector_ty expectedBits) {\n  BitVector<1> signBv(sign);\n  BitVector<8> exponentBv(exponent);\n  BitVector<23> significandBv(significand);\n  Float32 repr = Float32(signBv, exponentBv, significandBv);\n  ASSERT_EQ(repr.getRawBits(), expectedBits);\n}\n\nvoid testFloat64Bits(jfs_nr_bitvector_ty sign, jfs_nr_bitvector_ty exponent,\n                     jfs_nr_bitvector_ty significand,\n                     jfs_nr_bitvector_ty expectedBits) {\n  BitVector<1> signBv(sign);\n  BitVector<11> exponentBv(exponent);\n  BitVector<52> significandBv(significand);\n  Float64 repr = Float64(signBv, exponentBv, significandBv);\n  ASSERT_EQ(repr.getRawBits(), expectedBits);\n}\n}\n\nTEST(MakeFromTriple, PositiveZero) {\n  testFloat32Bits(0, 0, 0, UINT64_C(0x0));\n  testFloat64Bits(0, 0, 0, UINT64_C(0x0));\n}\n\nTEST(MakeFromTriple, NegativeZero) {\n  testFloat32Bits(1, 0, 0, UINT64_C(0x80000000));\n  testFloat64Bits(1, 0, 0, UINT64_C(0x8000000000000000));\n}\n\nTEST(MakeFromTriple, PositiveInf) {\n  testFloat32Bits(0, UINT64_C(0xff), UINT64_C(0), UINT32_C(0x7f800000));\n  testFloat64Bits(0, UINT64_C(0x7ff), UINT64_C(0),\n                  UINT64_C(0x7ff0000000000000));\n}\n\nTEST(MakeFromTriple, NegativeInf) {\n  testFloat32Bits(1, UINT64_C(0xff), UINT64_C(0), UINT32_C(0xff800000));\n  testFloat64Bits(1, UINT64_C(0x7ff), UINT64_C(0),\n                  UINT64_C(0xfff0000000000000));\n}\n\nTEST(MakeFromTriple, PositiveOne) {\n  testFloat32Bits(0, UINT64_C(0x7f), 0, UINT64_C(0x3f800000));\n  testFloat64Bits(0, UINT64_C(0x3ff), 0, UINT64_C(0x3ff0000000000000));\n}\n\nTEST(MakeFromTriple, NegativeOne) {\n  testFloat32Bits(1, UINT64_C(0x7f), 0, UINT64_C(0xbf800000));\n  testFloat64Bits(1, UINT64_C(0x3ff), 0, UINT64_C(0xbff0000000000000));\n}\n\nTEST(MakeFromTriple, NaN) {\n  testFloat32Bits(0, UINT64_C(0xff), UINT64_C(1), UINT32_C(0x7f800001));\n  testFloat64Bits(0, UINT64_C(0x7ff), UINT64_C(1),\n                  UINT64_C(0x7ff0000000000001));\n}\n\nTEST(MakeFromTriple, OnePointTwoFive) {\n  testFloat32Bits(0, UINT64_C(0x7f), UINT64_C(0x200000), UINT64_C(0x3fa00000));\n  testFloat64Bits(0, UINT64_C(0x3ff), UINT64_C(0x4000000000000),\n                  UINT64_C(0x3ff4000000000000));\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/Max.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(Max, Float32) {\n  Float32 a = Float32(100.0f);\n  Float32 b = Float32(0.0f);\n  ASSERT_TRUE(a.max(b) == a);\n  ASSERT_TRUE(b.max(a) == a);\n  ASSERT_TRUE(a.max(a) == a);\n  ASSERT_TRUE(b.max(b) == b);\n  Float32 nan = Float32::getNaN();\n\n  // One arg NaN\n  ASSERT_TRUE(nan.max(a) == a);\n  ASSERT_TRUE(nan.max(a) == a);\n  ASSERT_TRUE(a.max(nan) == a);\n\n  // Both NaN\n  ASSERT_TRUE(nan.max(nan) == nan);\n}\n\nTEST(Max, Float64) {\n  Float64 a = Float64(100.0);\n  Float64 b = Float64(0.0);\n  ASSERT_TRUE(a.max(b) == a);\n  ASSERT_TRUE(b.max(a) == a);\n  ASSERT_TRUE(a.max(a) == a);\n  ASSERT_TRUE(b.max(b) == b);\n  Float64 nan = Float64::getNaN();\n\n  // One arg NaN\n  ASSERT_TRUE(nan.max(a) == a);\n  ASSERT_TRUE(nan.max(a) == a);\n  ASSERT_TRUE(a.max(nan) == a);\n\n  // Both NaN\n  ASSERT_TRUE(nan.max(nan) == nan);\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/Min.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(Min, Float32) {\n  Float32 a = Float32(0.0f);\n  Float32 b = Float32(100.0f);\n  ASSERT_TRUE(a.min(b) == a);\n  ASSERT_TRUE(b.min(a) == a);\n  ASSERT_TRUE(a.min(a) == a);\n  ASSERT_TRUE(b.min(b) == b);\n  Float32 nan = Float32::getNaN();\n\n  // One arg NaN\n  ASSERT_TRUE(nan.min(a) == a);\n  ASSERT_TRUE(nan.min(a) == a);\n  ASSERT_TRUE(a.min(nan) == a);\n\n  // Both NaN\n  ASSERT_TRUE(nan.min(nan) == nan);\n}\n\nTEST(Min, Float64) {\n  Float64 a = Float64(0.0);\n  Float64 b = Float64(100.0);\n  ASSERT_TRUE(a.min(b) == a);\n  ASSERT_TRUE(b.min(a) == a);\n  ASSERT_TRUE(a.min(a) == a);\n  ASSERT_TRUE(b.min(b) == b);\n  Float64 nan = Float64::getNaN();\n\n  // One arg NaN\n  ASSERT_TRUE(nan.min(a) == a);\n  ASSERT_TRUE(nan.min(a) == a);\n  ASSERT_TRUE(a.min(nan) == a);\n\n  // Both NaN\n  ASSERT_TRUE(nan.min(nan) == nan);\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/Mul.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(Mul, NaN) {\n  ASSERT_TRUE(Float32::getNaN().mul(JFS_RM_RNE, Float32(0.0f)).isNaN());\n  ASSERT_TRUE(Float64::getNaN().mul(JFS_RM_RNE, Float64(0.0)).isNaN());\n}\n\nTEST(Mul, Simple) {\n  ASSERT_EQ(6.0f, Float32(2.0f).mul(JFS_RM_RNE, Float32(3.0f)).getRawData());\n  ASSERT_EQ(6.0, Float64(2.0).mul(JFS_RM_RNE, Float64(3.0)).getRawData());\n}\n\nTEST(Mul, DiffResultRNE_RTP_Float32) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (declare-fun b () (_ FloatingPoint 8 24))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert\n      (not\n        (fp.eq\n          (fp.mul RNE a b)\n          (fp.mul RTP a b)\n        )\n      )\n    )\n    (check-sat)\n    (get-model)\n  */\n  Float32 a(1, 0x85, 0b11111000111111110101110);\n  Float32 b(1, 0x00, 0b00000000001000000000000);\n  Float32 addRNE = a.mul(JFS_RM_RNE, b);\n  Float32 addRTP = a.mul(JFS_RM_RTP, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTP));\n  // FIXME: Check the result values\n}\n\nTEST(Mul, DiffResultRNE_RTP_Float64) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (declare-fun b () (_ FloatingPoint 11 53))\n    (define-fun a_b_rne () (_ FloatingPoint 11 53) (fp.mul RNE a b))\n    (define-fun a_b_rtp () (_ FloatingPoint 11 53) (fp.mul RTP a b))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.eq a_b_rne a_b_rtp)))\n    (assert (not (fp.isNaN a_b_rne)))\n    (assert (not (fp.isNaN a_b_rtp)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(1, 0b10000001100, UINT64_C(0xccff68c7f86bc));\n  Float64 b(1, 0x0, UINT64_C(0x00000203f001d));\n  Float64 addRNE = a.mul(JFS_RM_RNE, b);\n  Float64 addRTP = a.mul(JFS_RM_RTP, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTP));\n  // FIXME: Check the result values\n}\n\nTEST(Mul, DiffResultRNE_RTN_Float32) {\n  // These values are derived from Z3 being run on the following query\n  /*\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (declare-fun b () (_ FloatingPoint 8 24))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert\n      (not\n        (fp.eq\n          (fp.mul RNE a b)\n          (fp.mul RTN a b)\n        )\n      )\n    )\n    (check-sat)\n    (get-model)\n   */\n  Float32 a(0, 0x86, 0b00000000000000100100011);\n  Float32 b(1, 0x85, 0b11111111111111000111101);\n  Float32 addRNE = a.mul(JFS_RM_RNE, b);\n  Float32 addRTN = a.mul(JFS_RM_RTN, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTN));\n  // FIXME: Check the result values\n}\n\nTEST(Mul, DiffResultRNE_RTN_Float64) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (declare-fun b () (_ FloatingPoint 11 53))\n    (define-fun a_b_rne () (_ FloatingPoint 11 53) (fp.mul RNE a b))\n    (define-fun a_b_rtn () (_ FloatingPoint 11 53) (fp.mul RTN a b))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.eq a_b_rne a_b_rtn)))\n    (assert (not (fp.isNaN a_b_rne)))\n    (assert (not (fp.isNaN a_b_rtn)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(1, 0b10000110111, UINT64_C(0xfffffffffffff));\n  Float64 b(0, 0b01101111100, UINT64_C(0x9ffffffffffff));\n  Float64 addRNE = a.mul(JFS_RM_RNE, b);\n  Float64 addRTN = a.mul(JFS_RM_RTN, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTN));\n  // FIXME: Check the result values\n}\n\nTEST(Mul, DiffResultRNE_RTZ_Float32) {\n  // These values are derived from Z3 being run on the following query\n  /*\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (declare-fun b () (_ FloatingPoint 8 24))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert\n      (not\n        (fp.eq\n          (fp.mul RNE a b)\n          (fp.mul RTZ a b)\n        )\n      )\n    )\n    (check-sat)\n    (get-model)\n   */\n  Float32 a(0, 0x7b, 0b11101011000110111100001);\n  Float32 b(0, 0x00, 0b00011110000000110011101);\n  Float32 addRNE = a.mul(JFS_RM_RNE, b);\n  Float32 addRTZ = a.mul(JFS_RM_RTZ, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTZ));\n  // FIXME: Check the result values\n}\n\nTEST(Mul, DiffResultRNE_RTZ_Float64) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (declare-fun b () (_ FloatingPoint 11 53))\n    (define-fun a_b_rne () (_ FloatingPoint 11 53) (fp.mul RNE a b))\n    (define-fun a_b_rtz () (_ FloatingPoint 11 53) (fp.mul RTZ a b))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.eq a_b_rne a_b_rtz)))\n    (assert (not (fp.isNaN a_b_rne)))\n    (assert (not (fp.isNaN a_b_rtz)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(0, 0b11100010010, UINT64_C(0xb68bfefffffe0));\n  Float64 b(1, 0b11011101010, UINT64_C(0x9ffffffffffff));\n  Float64 addRNE = a.mul(JFS_RM_RNE, b);\n  Float64 addRTZ = a.mul(JFS_RM_RTZ, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTZ));\n  // FIXME: Check the result values\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/Neg.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\n\nTEST(Neg, NaN) {\n  auto f32NaN = Float32::getNaN();\n  auto f32NaNNegated = f32NaN.neg();\n  // msBit32 will only be true if the msb was flipped\n  bool msBit32 = ((f32NaN.getRawBits() ^ f32NaNNegated.getRawBits()) >> 31);\n  ASSERT_TRUE(msBit32);\n  auto f64NaN = Float64::getNaN();\n  auto f64NaNNegated = f64NaN.neg();\n  // msBit64 will only be true if the msb was flipped\n  bool msBit64 = ((f64NaN.getRawBits() ^ f64NaNNegated.getRawBits()) >> 63);\n  ASSERT_TRUE(msBit64);\n}\n\nTEST(Neg, NegativeZero) {\n  auto absFloat32 = Float32::getNegativeZero().neg();\n  ASSERT_TRUE(absFloat32.isPositive());\n  ASSERT_TRUE(absFloat32.isZero());\n  auto absFloat64 = Float64::getNegativeZero().neg();\n  ASSERT_TRUE(absFloat64.isPositive());\n  ASSERT_TRUE(absFloat64.isZero());\n}\n\nTEST(Neg, PositiveZero) {\n  auto absFloat32 = Float32::getPositiveZero().neg();\n  ASSERT_TRUE(absFloat32.isNegative());\n  ASSERT_TRUE(absFloat32.isZero());\n  auto absFloat64 = Float64::getPositiveZero().neg();\n  ASSERT_TRUE(absFloat64.isNegative());\n  ASSERT_TRUE(absFloat64.isZero());\n}\n\nTEST(Neg, NegativeInfinity) {\n  auto absFloat32 = Float32::getNegativeInfinity().neg();\n  ASSERT_TRUE(absFloat32.isPositive());\n  ASSERT_TRUE(absFloat32.isInfinite());\n  auto absFloat64 = Float64::getNegativeInfinity().neg();\n  ASSERT_TRUE(absFloat64.isPositive());\n  ASSERT_TRUE(absFloat64.isInfinite());\n}\n\nTEST(Neg, PositiveInfinity) {\n  auto absFloat32 = Float32::getPositiveInfinity().neg();\n  ASSERT_TRUE(absFloat32.isNegative());\n  ASSERT_TRUE(absFloat32.isInfinite());\n  auto absFloat64 = Float64::getPositiveInfinity().neg();\n  ASSERT_TRUE(absFloat64.isNegative());\n  ASSERT_TRUE(absFloat64.isInfinite());\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/Rem.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(Rem, NaN) {\n  ASSERT_TRUE(Float32::getNaN().rem(Float32(1.0f)).isNaN());\n  ASSERT_TRUE(Float64::getNaN().rem(Float64(1.0)).isNaN());\n}\n\nTEST(Rem, Simple) {\n  ASSERT_EQ(-1.0f, Float32(-7.0f).rem(Float32(3.0f)).getRawData());\n  ASSERT_EQ(-1.0, Float64(-7.0f).rem(Float64(3.0f)).getRawData());\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/RoundToIntegral.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(RoundToIntegral, NaN) {\n  ASSERT_TRUE(Float32::getNaN().roundToIntegral(JFS_RM_RNE).isNaN());\n  ASSERT_TRUE(Float64::getNaN().roundToIntegral(JFS_RM_RNE).isNaN());\n}\n\nTEST(RoundToIntegral, SimpleFloat32) {\n  ASSERT_EQ(0.0f, Float32(-0.1f).roundToIntegral(JFS_RM_RNE).getRawData());\n  ASSERT_EQ(0.0f, Float32(-0.1f).roundToIntegral(JFS_RM_RTP).getRawData());\n  ASSERT_EQ(-1.0f, Float32(-0.1f).roundToIntegral(JFS_RM_RTN).getRawData());\n  ASSERT_EQ(0.0f, Float32(-0.1f).roundToIntegral(JFS_RM_RTZ).getRawData());\n}\n\nTEST(RoundToIntegral, SimpleFloat64) {\n  ASSERT_EQ(0.0, Float64(-0.1).roundToIntegral(JFS_RM_RNE).getRawData());\n  ASSERT_EQ(0.0, Float64(-0.1).roundToIntegral(JFS_RM_RTP).getRawData());\n  ASSERT_EQ(-1.0, Float64(-0.1).roundToIntegral(JFS_RM_RTN).getRawData());\n  ASSERT_EQ(0.0, Float64(-0.1).roundToIntegral(JFS_RM_RTZ).getRawData());\n}\n\n// FIXME: Write more tests\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/SMTLIBEquals.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nnamespace {\n\ntemplate <typename T> void checkDisjointConstantsDisjoint() {\n  T values[] = {T::getPositiveZero(),\n                T::getNegativeZero(),\n                T::getPositiveInfinity(),\n                T::getNegativeInfinity(),\n                T::getNaN(),\n                T(1.5),\n                T(-1.5)};\n  for (unsigned index = 0; index < sizeof(values) / sizeof(T); ++index) {\n    for (unsigned indexOther = 0; indexOther < sizeof(values) / sizeof(T);\n         ++indexOther) {\n      if (index == indexOther) {\n        ASSERT_TRUE(values[index] == values[indexOther]);\n      } else {\n        ASSERT_FALSE(values[index] == values[indexOther]);\n      }\n    }\n  }\n}\n}\n\nTEST(SMTLIBEquals, DisjointConstantsDisjointFloat32) {\n  checkDisjointConstantsDisjoint<Float32>();\n}\n\nTEST(SMTLIBEquals, DisjointConstantsDisjointFloat64) {\n  checkDisjointConstantsDisjoint<Float64>();\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/SpecialConstants.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n#include <cmath>\n\nTEST(SpecialConstants, PositiveZeroFloat32) {\n  Float32 zero = Float32::getPositiveZero();\n  ASSERT_EQ(zero.getRawData(), 0.0f);\n  ASSERT_FALSE(std::signbit(zero.getRawData()));\n}\n\nTEST(SpecialConstants, PositiveZeroFloat64) {\n  Float64 zero = Float64::getPositiveZero();\n  ASSERT_EQ(zero.getRawData(), 0.0);\n  ASSERT_FALSE(std::signbit(zero.getRawData()));\n}\n\nTEST(SpecialConstants, NegativeZeroFloat32) {\n  Float32 zero = Float32::getNegativeZero();\n  ASSERT_EQ(zero.getRawData(), 0.0f);\n  ASSERT_TRUE(std::signbit(zero.getRawData()));\n}\n\nTEST(SpecialConstants, NegativeZeroFloat64) {\n  Float64 zero = Float64::getNegativeZero();\n  ASSERT_EQ(zero.getRawData(), 0.0);\n  ASSERT_TRUE(std::signbit(zero.getRawData()));\n}\n\nTEST(SpecialConstants, PositiveInfinityFloat32) {\n  Float32 infinity = Float32::getPositiveInfinity();\n  ASSERT_TRUE(std::isinf(infinity.getRawData()));\n  ASSERT_FALSE(std::signbit(infinity.getRawData()));\n}\n\nTEST(SpecialConstants, PositiveInfinityFloat64) {\n  Float64 infinity = Float64::getPositiveInfinity();\n  ASSERT_TRUE(std::isinf(infinity.getRawData()));\n  ASSERT_FALSE(std::signbit(infinity.getRawData()));\n}\n\nTEST(SpecialConstants, NegativeInfinityFloat32) {\n  Float32 infinity = Float32::getNegativeInfinity();\n  ASSERT_TRUE(std::isinf(infinity.getRawData()));\n  ASSERT_TRUE(std::signbit(infinity.getRawData()));\n}\n\nTEST(SpecialConstants, NegativeInfinityFloat64) {\n  Float64 infinity = Float64::getNegativeInfinity();\n  ASSERT_TRUE(std::isinf(infinity.getRawData()));\n  ASSERT_TRUE(std::signbit(infinity.getRawData()));\n}\n\nTEST(SpecialConstants, NaNFloat32) {\n  Float32 num = Float32::getNaN();\n  ASSERT_TRUE(std::isnan(num.getRawData()));\n}\n\nTEST(SpecialConstants, NaNFloat64) {\n  Float64 num = Float64::getNaN();\n  ASSERT_TRUE(std::isnan(num.getRawData()));\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/Sqrt.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(Sqrt, NaN) {\n  ASSERT_TRUE(Float32::getNaN().sqrt(JFS_RM_RNE).isNaN());\n  ASSERT_TRUE(Float64::getNaN().sqrt(JFS_RM_RNE).isNaN());\n}\n\nTEST(Sqrt, Simple) {\n  ASSERT_EQ(2.0f, Float32(4.0f).sqrt(JFS_RM_RNE).getRawData());\n  ASSERT_EQ(2.0, Float64(4.0).sqrt(JFS_RM_RNE).getRawData());\n}\n\nTEST(Sqrt, DiffResultRNE_RTP_Float32) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (define-fun result_rne () (_ FloatingPoint 8 24) (fp.sqrt RNE a))\n    (define-fun result_rtp () (_ FloatingPoint 8 24) (fp.sqrt RTP a))\n    (assert (not (fp.isNaN a)))\n    (assert\n      (not\n        (fp.eq\n          result_rne\n          result_rtp\n        )\n      )\n    )\n    (assert (not (fp.isNaN result_rne)))\n    (assert (not (fp.isNaN result_rtp)))\n    (check-sat)\n    (get-model)\n    (get-value (result_rne))\n    (get-value (result_rtp))\n  */\n  Float32 a(0, 0xf5, UINT32_C(0b10000011011110111001001));\n  Float32 resultRNE = a.sqrt(JFS_RM_RNE);\n  Float32 resultRTP = a.sqrt(JFS_RM_RTP);\n  ASSERT_FALSE(resultRNE.ieeeEquals(resultRTP));\n  ASSERT_EQ(resultRNE, Float32(0, 0xba, UINT32_C(0b00111010111101000000101)));\n  ASSERT_EQ(resultRTP, Float32(0, 0xba, UINT32_C(0b00111010111101000000110)));\n}\n\nTEST(Sqrt, DiffResultRNE_RTP_Float64) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (define-fun result_rne () (_ FloatingPoint 11 53) (fp.sqrt RNE a))\n    (define-fun result_rtp () (_ FloatingPoint 11 53) (fp.sqrt RTP a))\n    (assert (not (fp.isNaN a)))\n    (assert\n      (not\n        (fp.eq\n          result_rne\n          result_rtp\n        )\n      )\n    )\n    (assert (not (fp.isNaN result_rne)))\n    (assert (not (fp.isNaN result_rtp)))\n    (check-sat)\n    (get-model)\n    (get-value (result_rne))\n    (get-value (result_rtp))\n  */\n  Float64 a(0, 0b00000000100, UINT64_C(0x26a5a80660dbe));\n  Float64 resultRNE = a.sqrt(JFS_RM_RNE);\n  Float64 resultRTP = a.sqrt(JFS_RM_RTP);\n  ASSERT_FALSE(resultRNE.ieeeEquals(resultRTP));\n  ASSERT_EQ(resultRNE, Float64(0, 0b01000000001, UINT64_C(0x8467f75d9d7b2)));\n  ASSERT_EQ(resultRTP, Float64(0, 0b01000000001, UINT64_C(0x8467f75d9d7b3)));\n}\n\n// FIXME: Write tests for other rounding modes and types\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Float/Native/Sub.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Float.h\"\n#include \"gtest/gtest.h\"\n\nTEST(Sub, NaN) {\n  ASSERT_TRUE(Float32::getNaN().sub(JFS_RM_RNE, Float32(0.0f)).isNaN());\n  ASSERT_TRUE(Float64::getNaN().sub(JFS_RM_RNE, Float64(0.0)).isNaN());\n}\n\nTEST(Sub, Simple) {\n  ASSERT_EQ(2.0f, Float32(3.0f).sub(JFS_RM_RNE, Float32(1.0f)).getRawData());\n  ASSERT_EQ(2.0, Float64(3.0).sub(JFS_RM_RNE, Float64(1.0)).getRawData());\n}\n\nTEST(Sub, DiffResultRNE_RTP_Float32) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (declare-fun b () (_ FloatingPoint 8 24))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert\n      (not\n        (fp.eq\n          (fp.sub RNE a b)\n          (fp.sub RTP a b)\n        )\n      )\n    )\n    (check-sat)\n    (get-model)\n  */\n  Float32 a(1, 0xbc, 0b00110000000000010011111);\n  Float32 b(0, 0xc3, 0b11111101101000000000000);\n  Float32 addRNE = a.sub(JFS_RM_RNE, b);\n  Float32 addRTP = a.sub(JFS_RM_RTP, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTP));\n  // FIXME: Check the result values\n}\n\nTEST(Sub, DiffResultRNE_RTP_Float64) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (declare-fun b () (_ FloatingPoint 11 53))\n    (define-fun a_b_rne () (_ FloatingPoint 11 53) (fp.sub RNE a b))\n    (define-fun a_b_rtp () (_ FloatingPoint 11 53) (fp.sub RTP a b))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.eq a_b_rne a_b_rtp)))\n    (assert (not (fp.isNaN a_b_rne)))\n    (assert (not (fp.isNaN a_b_rtp)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(0, 0x02, UINT64_C(0xff5edfffe64e7));\n  Float64 b(1, 0x02, UINT64_C(0xff7effffe6566));\n  Float64 addRNE = a.sub(JFS_RM_RNE, b);\n  Float64 addRTP = a.sub(JFS_RM_RTP, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTP));\n  // FIXME: Check the result values\n}\n\nTEST(Sub, DiffResultRNE_RTN_Float32) {\n  // These values are derived from Z3 being run on the following query\n  /*\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (declare-fun b () (_ FloatingPoint 8 24))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert\n      (not\n        (fp.eq\n          (fp.sub RNE a b)\n          (fp.sub RTN a b)\n        )\n      )\n    )\n    (check-sat)\n    (get-model)\n   */\n  Float32 a(0, 0x86, 0b00000000000000100100011);\n  Float32 b(1, 0x85, 0b11111111111111000111101);\n  Float32 addRNE = a.sub(JFS_RM_RNE, b);\n  Float32 addRTN = a.sub(JFS_RM_RTN, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTN));\n  // FIXME: Check the result values\n}\n\nTEST(Sub, DiffResultRNE_RTN_Float64) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (declare-fun b () (_ FloatingPoint 11 53))\n    (define-fun a_b_rne () (_ FloatingPoint 11 53) (fp.sub RNE a b))\n    (define-fun a_b_rtn () (_ FloatingPoint 11 53) (fp.sub RTN a b))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.eq a_b_rne a_b_rtn)))\n    (assert (not (fp.isNaN a_b_rne)))\n    (assert (not (fp.isNaN a_b_rtn)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(1, 0b10000110111, UINT64_C(0xfffffffffffff));\n  Float64 b(0, 0b01101111100, UINT64_C(0x9ffffffffffff));\n  Float64 addRNE = a.sub(JFS_RM_RNE, b);\n  Float64 addRTN = a.sub(JFS_RM_RTN, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTN));\n  // FIXME: Check the result values\n}\n\nTEST(Sub, DiffResultRNE_RTZ_Float32) {\n  // These values are derived from Z3 being run on the following query\n  /*\n    (declare-fun a () (_ FloatingPoint 8 24))\n    (declare-fun b () (_ FloatingPoint 8 24))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert\n      (not\n        (fp.eq\n          (fp.sub RNE a b)\n          (fp.sub RTZ a b)\n        )\n      )\n    )\n    (check-sat)\n    (get-model)\n   */\n  Float32 a(1, 0x3f, 0b10000001000000000011111);\n  Float32 b(0, 0x3d, 0b11111111100000000000010);\n  Float32 addRNE = a.sub(JFS_RM_RNE, b);\n  Float32 addRTZ = a.sub(JFS_RM_RTZ, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTZ));\n  // FIXME: Check the result values\n}\n\nTEST(Sub, DiffResultRNE_RTZ_Float64) {\n  // These values are derived from Z3 being run on the following query\n  /*\n   *\n    (declare-fun a () (_ FloatingPoint 11 53))\n    (declare-fun b () (_ FloatingPoint 11 53))\n    (define-fun a_b_rne () (_ FloatingPoint 11 53) (fp.sub RNE a b))\n    (define-fun a_b_rtz () (_ FloatingPoint 11 53) (fp.sub RTZ a b))\n    (assert (not (fp.isNaN a)))\n    (assert (not (fp.isNaN b)))\n    (assert (not (fp.eq a_b_rne a_b_rtz)))\n    (assert (not (fp.isNaN a_b_rne)))\n    (assert (not (fp.isNaN a_b_rtz)))\n    (check-sat)\n    (get-model)\n  */\n  Float64 a(0, 0b11100010010, UINT64_C(0xb68bfefffffe0));\n  Float64 b(1, 0b11011101010, UINT64_C(0x9ffffffffffff));\n  Float64 addRNE = a.sub(JFS_RM_RNE, b);\n  Float64 addRTZ = a.sub(JFS_RM_RTZ, b);\n  ASSERT_FALSE(addRNE.ieeeEquals(addRTZ));\n  // FIXME: Check the result values\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Logger/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\nadd_jfs_unit_test(Logger\n  LoggerTests.cpp\n)\n\nset(PATH_TO_LOG_FILE \"${CMAKE_CURRENT_BINARY_DIR}/test_log.yml\")\ntarget_compile_definitions(Logger${UNIT_TEST_EXE_SUFFIX}\n  PRIVATE\n  \"-DPATH_TO_LOG_FILE=${PATH_TO_LOG_FILE}\"\n)\n\ntarget_link_libraries(Logger${UNIT_TEST_EXE_SUFFIX} PRIVATE JFSSMTLIBRuntime)\ntarget_link_libraries(Logger${UNIT_TEST_EXE_SUFFIX} PRIVATE JFSSMTLIBRuntimeTestUtil)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/Logger/LoggerTests.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIB/Logger.h\"\n#include \"gtest/gtest.h\"\n#include <cstdio>\n#include <fstream>\n#include <iostream>\n#include <string.h>\n#include <unistd.h>\n\n#define STRINGIFY_(X) #X\n#define STRINGIFY(X) STRINGIFY_(X)\n\n// TODO: Write more tests\n\nTEST(Logger, createLog) {\n  const char* logFilePath = STRINGIFY(PATH_TO_LOG_FILE);\n  // Remove old log file\n  int removeLogFileResult = unlink(logFilePath);\n  if (removeLogFileResult == -1) {\n    printf(\"Removal %s failed\\n\", logFilePath);\n  }\n\n  // Do logging\n  setenv(\"JFS_RUNTIME_LOG_PATH\", logFilePath, /*overwrite=*/1);\n  auto logger = jfs_nr_mk_logger_from_env();\n  jfs_nr_log_uint64(logger, \"foo\", 1);\n  jfs_nr_del_logger(logger);\n\n  // Now read file back\n  std::ifstream lfs(logFilePath);\n  ASSERT_TRUE(lfs.good());\n  char data[100];\n  const uint64_t dataLength = sizeof(data) / sizeof(char);\n  memset(data, 0, dataLength);\n  lfs.getline(data, dataLength);\n  ASSERT_STREQ(data, \"foo: 1\");\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/SMTLIBRuntimeTestUtil.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"SMTLIBRuntimeTestUtil.h\"\n#include <assert.h>\n\nnamespace jfs {\nnamespace smtlib_runtime_test_util {\nint64_t to_signed_value(uint64_t bits, uint64_t N) {\n  assert(N < 64);\n  uint64_t mask = (UINT64_C(1) << N) - 1;\n  int64_t negativeMSB = ((int64_t)(UINT64_C(1) << (N - 1))) * -1;\n  uint64_t maskOnlyPositiveBits = mask >> 1;\n  int64_t valueAsSigned =\n      (bits & (UINT64_C(1) << (N - 1)))\n          ? (((int64_t)(bits & maskOnlyPositiveBits)) + negativeMSB)\n          : ((int64_t)bits);\n  return valueAsSigned;\n}\n\nuint64_t get_neg_bits(uint64_t v, uint64_t N) {\n  assert(N < 64);\n  uint64_t mask = (UINT64_C(1) << N) - 1;\n  return ((~v) + 1) & mask;\n}\n\nuint64_t to_expected_bits_from_signed_value(int64_t bits, uint64_t N) {\n  assert(N < 64);\n  uint64_t mask = (UINT64_C(1) << N) - 1;\n  uint64_t expectedBits = *(reinterpret_cast<uint64_t *>(&bits));\n  expectedBits &= mask;\n  return expectedBits;\n}\n}\n}\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/SMTLIBRuntimeTestUtil.h",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#ifndef JFS_SMTLIB_RUNTIME_TEST_UTIL_H\n#define JFS_SMTLIB_RUNTIME_TEST_UTIL_H\n#include <stdint.h>\nnamespace jfs {\nnamespace smtlib_runtime_test_util {\n\nint64_t to_signed_value(uint64_t bits, uint64_t N);\n\nuint64_t get_neg_bits(uint64_t v, uint64_t N);\n\nuint64_t to_expected_bits_from_signed_value(int64_t bits, uint64_t N);\n}\n}\n#endif\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/lit-unit-tests-common.cfg",
    "content": "# Configuration file for the 'lit' test runner.\n\nimport os\n\nimport lit.formats\n\n# suffixes: A list of file extensions to treat as test files.\nconfig.suffixes = []\n\n# testFormat: The test format to use to interpret tests.\nconfig.test_format = lit.formats.GoogleTest('.', config.unit_test_exe_suffix)\n"
  },
  {
    "path": "runtime/SMTLIB/SMTLIB/unittests/lit-unit-tests-common.site.cfg.in",
    "content": "import sys\nimport os\n\n## @AUTO_GEN_MSG@\n# TODO: Should put something about config in here\nconfig.name = '@UNIT_TEST_SUITE_NAME@'\nconfig.unit_test_exe_suffix = \"@UNIT_TEST_EXE_SUFFIX@\"\n\n# Let the main config do the real work.\nlit_config.load_config(config, \"@CMAKE_CURRENT_SOURCE_DIR@/lit-unit-tests-common.cfg\")\n"
  },
  {
    "path": "runtime/SMTLIB/gtest/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n# This is a simple wrapper around the GTest CMake build that\n# exports its targets. The purpose of this is so this file can\n# be used as the root CMakeLists.txt of an external project build.\nproject(GTEST_WRAPPER)\ncmake_minimum_required(VERSION 2.6.2)\n\nif (NOT EXISTS \"${GTEST_SRC_DIR}\")\n  message(FATAL_ERROR \"GTEST_SRC_DIR \\\"${GTEST_SRC_DIR}\\\" does not exist\")\nendif()\n\nadd_subdirectory(\n  \"${GTEST_SRC_DIR}\"\n  \"${CMAKE_CURRENT_BINARY_DIR}/gtest_build\"\n)\n\nset(JFS_GTEST_EXPORT_FILE \"${CMAKE_CURRENT_BINARY_DIR}/jfs_gtest_exported_targets.cmake\")\n# Export the gtest targets so that other external projects can re-use the build\nexport(TARGETS jfs_gtest_main jfs_gtest\n  FILE \"${JFS_GTEST_EXPORT_FILE}\"\n  EXPORT_LINK_INTERFACE_LIBRARIES\n)\n"
  },
  {
    "path": "scripts/Dockerfiles/build.sh",
    "content": "#!/bin/bash\nset -e\nset -x\nSCRIPT_DIR=\"$( cd ${BASH_SOURCE[0]%/*} ; echo $PWD )\"\nROOT_DIR=\"$(cd \"${SCRIPT_DIR}/../../\" ; echo $PWD)\"\n\nBASE_TAG=\"jfs_build_base:ubuntu1604\"\nFINAL_TAG=\"jfs_build:ubuntu1604\"\n\n# Build base that we can use for other tools\ndocker build -t \"${BASE_TAG}\" - < \"${SCRIPT_DIR}/jfs_base_ubuntu_16.04.Dockerfile\"\n\nDOCKER_MAJOR_VERSION=$(docker --version | sed 's/^Docker version \\([0-9]\\+\\)\\.\\([0-9]\\+\\).*$/\\1/')\nDOCKER_MINOR_VERSION=$(docker --version | sed 's/^Docker version \\([0-9]\\+\\)\\.\\([0-9]\\+\\).*$/\\2/')\nDOCKER_BUILD_FILE=\"${SCRIPT_DIR}/jfs_build_ubuntu_16.04.Dockerfile\"\n\nBUILD_OPTS=()\nif [ \"${DOCKER_MAJOR_VERSION}${DOCKER_MINOR_VERSION}\" -lt 1705 ]; then\n  # Workaround limitation in older Docker versions where the FROM\n  # command cannot be parameterized with an ARG.\n  sed \\\n    -e '/^ARG BASE_IMAGE/d' \\\n    -e 's/${BASE_IMAGE}/'\"${BASE_TAG}/\" \\\n    \"${DOCKER_BUILD_FILE}\" > \"${DOCKER_BUILD_FILE}.patched\"\n  DOCKER_BUILD_FILE=\"${DOCKER_BUILD_FILE}.patched\"\nelse\n  # This feature landed in Docker 17.05\n  # See https://github.com/moby/moby/pull/31352\n  BUILD_OPTS+=( \\\n    \"--build-arg\" \\\n    \"BASE_IMAGE=${BASE_TAG}\" \\\n  )\nfi\n\nif [ -n \"${BUILD_CPU_SETS}\" ]; then\n  BUILD_OPTS+=( \\\n    \"--cpuset-cpus\" \\\n    \"${BUILD_CPU_SETS}\" \\\n  )\nfi\n\ndocker build \\\n  -t \"${FINAL_TAG}\" \\\n  -f \"${DOCKER_BUILD_FILE}\" \\\n  \"${BUILD_OPTS[@]}\" \\\n  \"${ROOT_DIR}\"\n\n# Run tests. We do this separate from the build because\n# we need SYS_PTRACE which we can't set via `docker build`.\n# NOTE: SYS_PTRACE is required by LSan. We use it\n# when using the asanified runtime.\n# See: https://github.com/google/sanitizers/issues/764\ndocker run \\\n  --rm \\\n  --cap-add SYS_PTRACE \\\n  \"${FINAL_TAG}\" \\\n  \"/bin/bash\" \\\n  \"/home/user/jfs/src/scripts/dist/test_jfs.sh\"\n\n\n# TODO: Should squash image\n"
  },
  {
    "path": "scripts/Dockerfiles/jfs_base_ubuntu_16.04.Dockerfile",
    "content": "FROM ubuntu:16.04\n\nRUN apt-get update && \\\n    apt-get -y --no-install-recommends install \\\n        binutils \\\n        cmake \\\n        curl \\\n        ca-certificates \\\n        gcc-multilib \\\n        gcc-5-multilib \\\n        git \\\n        g++-multilib \\\n        g++-5-multilib \\\n        libgmp-dev \\\n        libgomp1 \\\n        libomp5 \\\n        libomp-dev \\\n        make \\\n        ninja-build \\\n        python3 \\\n        python3-setuptools \\\n        sudo && \\\n    apt-get clean && \\\n    ln -s /usr/bin/python3 /usr/bin/python\n\n# Create `user` user for container with password `user`.  and give it\n# password-less sudo access\nRUN useradd -m user && \\\n    echo user:user | chpasswd && \\\n    cp /etc/sudoers /etc/sudoers.bak && \\\n    echo 'user  ALL=(root) NOPASSWD: ALL' >> /etc/sudoers\nUSER user\nWORKDIR /home/user\n"
  },
  {
    "path": "scripts/Dockerfiles/jfs_build_ubuntu_16.04.Dockerfile",
    "content": "ARG BASE_IMAGE\nFROM ${BASE_IMAGE}\nLABEL maintainer \"dan@su-root.co.uk\"\n\n# Install lit\nRUN curl \"https://bootstrap.pypa.io/pip/3.5/get-pip.py\" -o \"get-pip.py\" && \\\n  sudo python3 get-pip.py && \\\n  sudo pip install lit==0.5.0\n\n# NOTE: We stagger copying across files (i.e. don't do `ADD / ${JFS_SRC_DIR}`\n# first) to avoid triggering a rebuild of CMake/Z3/LLVM unnecessarily.\n\n# This is unlikely to change (i.e. doing so would trigger rebuilds)\n# so its okay to have this declared early.\nENV \\\n  JFS_SRC_DIR=/home/user/jfs/src\n\n# Make directory for JFS source tree\nRUN mkdir -p \"${JFS_SRC_DIR}\"\n\n# Build Z3\nENV \\\n  Z3_SRC_DIR=/home/user/z3/src \\\n  Z3_BUILD_DIR=/home/user/z3/build \\\n  Z3_BUILD_TYPE=Release \\\n  Z3_STATIC_BUILD=1 \\\n  Z3_CMAKE_GENERATOR=\"Ninja\"\nADD /scripts/dist/build_z3.sh ${JFS_SRC_DIR}/scripts/dist/\nRUN ${JFS_SRC_DIR}/scripts/dist/build_z3.sh\n\n# Build LLVM\nENV \\\n  LLVM_SRC_DIR=/home/user/llvm/src \\\n  LLVM_BUILD_DIR=/home/user/llvm/build \\\n  LLVM_BUILD_TYPE=Release \\\n  LLVM_CMAKE_GENERATOR=\"Ninja\"\nADD /scripts/dist/build_llvm.sh ${JFS_SRC_DIR}/scripts/dist/\nRUN ${JFS_SRC_DIR}/scripts/dist/build_llvm.sh\n\n# Build JFS\n# Now finally copy across all the other sources\n# FIXME: For final solver build we should disable assertions\nADD / ${JFS_SRC_DIR}\nENV \\\n  JFS_BUILD_DIR=/home/user/jfs/build \\\n  JFS_BUILD_TYPE=Release \\\n  JFS_CMAKE_GENERATOR=\"Ninja\" \\\n  JFS_ENABLE_ASSERTIONS=ON\nRUN ${JFS_SRC_DIR}/scripts/dist/build_jfs.sh\n"
  },
  {
    "path": "scripts/dist/build_and_install_cmake.sh",
    "content": "#!/bin/bash\n\n# This script builds and installs CMake\nset -x\nset -e\nset -o pipefail\n: ${CMAKE_SRC_DIR?\"CMAKE_SRC_DIR must be specified\"}\n: ${CMAKE_INSTALL?\"CMAKE_INSTALL must be specified\"}\n\n# Set values if not already set externally\nCMAKE_GENERATOR=\"${CMAKE_CMAKE_GENERATOR:-Ninja}\"\nCMAKE_VERSION=\"${CMAKE_VERSION:-3.8.2}\"\nCMAKE_TARBALL_URL=\"${CMAKE_TARBALL_URL:-https://cmake.org/files/v3.8/cmake-${CMAKE_VERSION}.tar.gz}\"\n\n\n# Setup source tree\nmkdir -p \"${CMAKE_SRC_DIR}\"\ncd \"${CMAKE_SRC_DIR}\"\ncurl -L \"${CMAKE_TARBALL_URL}\" -o \"cmake-${CMAKE_VERSION}.tar.gz\"\ntar -xvf \"cmake-${CMAKE_VERSION}.tar.gz\"\ncd \"cmake-${CMAKE_VERSION}\"\n# Do a bootstrap so that we don't require CMake to be already installed\n./bootstrap --parallel=$(nproc)\nmake -j$(nproc)\n\nif [ \"X${CMAKE_INSTALL}\" = \"X1\" ]; then\n  sudo make install\nfi\n"
  },
  {
    "path": "scripts/dist/build_and_install_ninja.sh",
    "content": "#!/bin/bash\n\n# This script builds and installs ninja\nset -x\nset -e\nset -o pipefail\n: ${NINJA_SRC_DIR?\"NINJA_SRC_DIR must be specified\"}\n: ${NINJA_INSTALL?\"NINJA_INSTALL must be specified\"}\n\n# Set values if not already set externally\nNINJA_VERSION=\"${NINJA_VERSION:-1.7.2}\"\nNINJA_TARBALL_URL=\"${NINJA_TARBALL_URL:-https://github.com/ninja-build/ninja/archive/v${NINJA_VERSION}.tar.gz}\"\n\n# Setup source tree\nmkdir -p \"${NINJA_SRC_DIR}\"\ncd \"${NINJA_SRC_DIR}\"\ncurl -L \"${NINJA_TARBALL_URL}\" -o \"v${NINJA_VERSION}.tar.gz\"\ntar -xvf \"v${NINJA_VERSION}.tar.gz\"\ncd \"ninja-${NINJA_VERSION}\"\n./configure.py --bootstrap\n\nif [ \"X${NINJA_INSTALL}\" = \"X1\" ]; then\n  sudo install ninja /usr/bin/\nfi\n"
  },
  {
    "path": "scripts/dist/build_jfs.sh",
    "content": "#!/bin/bash\n# This script builds JFS\nset -x\nset -e\nset -o pipefail\n: ${JFS_SRC_DIR?\"JFS_SRC_DIR must be specified\"}\n: ${JFS_BUILD_DIR?\"JFS_BUILD_DIR must be specified\"}\n: ${JFS_BUILD_TYPE?\"JFS_BUILD_TYPE must be specified\"}\n: ${LLVM_BUILD_DIR?\"LLVM_BUILD_DIR must be specified\"}\n: ${Z3_BUILD_DIR?\"Z3_BUILD_DIR must be specified\"}\n\n# Set values if not already set externally\nJFS_CMAKE_GENERATOR=\"${JFS_CMAKE_GENERATOR:-Ninja}\"\nJFS_ENABLE_ASSERTIONS=\"${JFS_ENABLE_ASSERTIONS:-ON}\"\n\n# Setup source dir\n# TODO: Support fetching from source repo\n\n# Setup build dir\nmkdir -p \"${JFS_BUILD_DIR}\"\ncd \"${JFS_BUILD_DIR}\"\n\n# Configure\ncmake \\\n  -G \"${JFS_CMAKE_GENERATOR}\" \\\n  -DCMAKE_BUILD_TYPE=${JFS_BUILD_TYPE} \\\n  -DLLVM_DIR=${LLVM_BUILD_DIR}/lib/cmake/llvm \\\n  -DZ3_DIR=${Z3_BUILD_DIR} \\\n  -DENABLE_JFS_ASSERTS=${JFS_ENABLE_ASSERTIONS} \\\n  \"${JFS_SRC_DIR}\"\n\n# Build\nif [ \"${JFS_CMAKE_GENERATOR}\" = \"Ninja\" ]; then\n  ninja\nelse\n  make -j$(nproc)\nfi\n"
  },
  {
    "path": "scripts/dist/build_llvm.sh",
    "content": "#!/bin/bash\n\n# This script builds LLVM\nset -x\nset -e\nset -o pipefail\n: ${LLVM_SRC_DIR?\"LLVM_SRC_DIR must be specified\"}\n: ${LLVM_BUILD_DIR?\"LLVM_BUILD_DIR must be specified\"}\n: ${LLVM_BUILD_TYPE?\"LLVM_BUILD_TYPE must be specified\"}\n\n# Set values if not already set externally\nLLVM_CMAKE_GENERATOR=\"${LLVM_CMAKE_GENERATOR:-Ninja}\"\nLLVM_BRANCH=release_60\nLLVM_GIT_URL=\"${LLVM_GIT_URL:-https://github.com/llvm-mirror/llvm.git}\"\nCLANG_GIT_URL=\"${CLANG_GIT_URL:-https://github.com/llvm-mirror/clang.git}\"\nCOMPILER_RT_GIT_URL=\"${COMPILER_RT_GIT_URL:-https://github.com/llvm-mirror/compiler-rt.git}\"\nLIBCXX_GIT_URL=\"${LIBCXX_GIT_URL:-https://github.com/llvm-mirror/libcxx.git}\"\nLIBCXXABI_GIT_URL=\"${LIBCXXABI_GIT_URL:-https://github.com/llvm-mirror/libcxxabi.git}\"\n\nADDITIONAL_LLVM_OPTS=()\n\nif [ \"X${LLVM_ENABLE_ASSERTIONS}\" = \"X1\" ]; then\n  ADDITIONAL_LLVM_OPTS+=('-DLLVM_ENABLE_ASSERTIONS=ON')\nfi\n\n# Setup source tree\nmkdir -p \"${LLVM_SRC_DIR}\"\ngit clone --depth 1 -b \"${LLVM_BRANCH}\" \"${LLVM_GIT_URL}\" \"${LLVM_SRC_DIR}\"\ncd \"${LLVM_SRC_DIR}/tools\"\ngit clone --depth 1 -b \"${LLVM_BRANCH}\" \"${CLANG_GIT_URL}\" \"clang\"\ncd \"${LLVM_SRC_DIR}/projects\"\ngit clone --depth 1 -b \"${LLVM_BRANCH}\" \"${COMPILER_RT_GIT_URL}\" \"compiler-rt\"\n\n# Add libcxx and libcxxabi for macOS only\n# Ensures that the freshly built clang can find C++ headers on macOS\nif [[ \"$OSTYPE\" == darwin* ]]; then\n  git clone --depth 1 -b \"${LLVM_BRANCH}\" \"${LIBCXX_GIT_URL}\" \"libcxx\"\n  git clone --depth 1 -b \"${LLVM_BRANCH}\" \"${LIBCXXABI_GIT_URL}\" \"libcxxabi\"\nfi\n\n# Make build tree\nmkdir -p \"${LLVM_BUILD_DIR}\"\ncd \"${LLVM_BUILD_DIR}\"\n\n# Configure\ncmake \\\n  -G \"${LLVM_CMAKE_GENERATOR}\" \\\n  -DCMAKE_BUILD_TYPE=${LLVM_BUILD_TYPE} \\\n  -DLLVM_TARGETS_TO_BUILD=X86 \\\n  -DLLVM_ENABLE_RTTI=OFF \\\n  -DLLVM_ENABLE_EH=OFF \\\n  -DLLVM_ENABLE_LTO=OFF \\\n  -DLLVM_BUILD_LLVM_DYLIB=OFF \\\n  -DBUILD_SHARED_LIBS=OFF \\\n  \"${ADDITIONAL_LLVM_OPTS[@]}\" \\\n  \"${LLVM_SRC_DIR}\"\n\n# Build\nif [ \"${LLVM_CMAKE_GENERATOR}\" = \"Ninja\" ]; then\n  ninja\nelse\n  make -j$(nproc)\nfi\n"
  },
  {
    "path": "scripts/dist/build_z3.sh",
    "content": "#!/bin/bash\n\n# This script builds Z3\nset -x\nset -e\nset -o pipefail\n: ${Z3_SRC_DIR?\"Z3_SRC_DIR must be specified\"}\n: ${Z3_BUILD_DIR?\"Z3_BUILD_DIR must be specified\"}\n: ${Z3_BUILD_TYPE?\"Z3_BUILD_TYPE must be specified\"}\n\n# Set values if not already set externally\nZ3_GIT_REVISION=\"${Z3_GIT_REVISION:-b0aaa4c6d7a739eb5e8e56a73e0486df46483222}\"\nZ3_GIT_URL=\"${Z3_GIT_URL:-https://github.com/Z3Prover/z3.git}\"\nZ3_CMAKE_GENERATOR=\"${Z3_CMAKE_GENERATOR:-Ninja}\"\n\nADDITIONAL_Z3_OPTS=()\n\n# Static or dynamic libz3\nif [ \"X${Z3_STATIC_BUILD}\" = \"X1\" ]; then\n  ADDITIONAL_Z3_OPTS+=('-DBUILD_LIBZ3_SHARED=OFF')\nelse\n  ADDITIONAL_Z3_OPTS+=('-DBUILD_LIBZ3_SHARED=ON')\nfi\n\n# Setup source tree\nmkdir -p \"${Z3_SRC_DIR}\"\ngit clone \"${Z3_GIT_URL}\" \"${Z3_SRC_DIR}\"\ncd \"${Z3_SRC_DIR}\"\ngit reset --hard \"${Z3_GIT_REVISION}\"\n\n# Make build tree\nmkdir -p \"${Z3_BUILD_DIR}\"\ncd \"${Z3_BUILD_DIR}\"\n\n# Configure\ncmake \\\n  -G \"${Z3_CMAKE_GENERATOR}\" \\\n  -DCMAKE_BUILD_TYPE=${Z3_BUILD_TYPE} \\\n  -DUSE_OPENMP=ON\"${Z3_SRC_DIR}\" \\\n  -DUSE_LIB_GMP=FALSE \\\n  \"${ADDITIONAL_Z3_OPTS[@]}\" \\\n  \"${Z3_SRC_DIR}\"\n\n# Build\nif [ \"${Z3_CMAKE_GENERATOR}\" = \"Ninja\" ]; then\n  ninja\nelse\n  make -j$(nproc)\nfi\n"
  },
  {
    "path": "scripts/dist/test_jfs.sh",
    "content": "#!/bin/bash\n# This script tests JFS\nset -x\nset -e\nset -o pipefail\n: ${JFS_SRC_DIR?\"JFS_SRC_DIR must be specified\"}\n: ${JFS_BUILD_DIR?\"JFS_BUILD_DIR must be specified\"}\n\n# Set values if not already set externally\nJFS_CMAKE_GENERATOR=\"${JFS_CMAKE_GENERATOR:-Ninja}\"\n\ncd \"${JFS_BUILD_DIR}\"\n\n# Test\nif [ \"${JFS_CMAKE_GENERATOR}\" = \"Ninja\" ]; then\n  ninja check\nelse\n  make -j$(nproc) check\nfi\n"
  },
  {
    "path": "tests/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n\n  # Add global test target\n  add_custom_target(check\n    COMMENT \"Running tests\"\n  )\nif (ENABLE_SYSTEM_TESTS)\n  message(STATUS \"System tests enabled\")\n  add_subdirectory(system_tests)\n  add_dependencies(check systemtests)\nelse()\n  message(STATUS \"System tests disabled\")\nendif()\n\nif (ENABLE_UNIT_TESTS)\n  message(STATUS \"Unit tests enabled\")\n  add_subdirectory(unit_tests)\n  add_dependencies(check unittests)\nelse()\n  message(STATUS \"Unit tests disabled\")\nendif()\n"
  },
  {
    "path": "tests/system_tests/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n###############################################################################\n# LLVM testing tools\n###############################################################################\n# FIXME: This is not portable\nset(FILECHECK_BIN_PATH \"${CMAKE_BINARY_DIR}/bin/FileCheck\")\n\n# FIXME: This is not portable\nset(NOT_BIN_PATH \"${CMAKE_BINARY_DIR}/bin/not\")\n\n###############################################################################\n# JFS testing tools\n###############################################################################\n# FIXME: This is not portable\nset(YAML_SYNTAX_CHECK_PATH \"${CMAKE_BINARY_DIR}/bin/yaml-syntax-check\")\n\n###############################################################################\n# Configure lit test suite\n###############################################################################\n\n# FIXME: This is not portable\nset(JFS_TOOL_PATH \"${CMAKE_BINARY_DIR}/bin/jfs\")\nset(JFS_OPT_TOOL_PATH \"${CMAKE_BINARY_DIR}/bin/jfs-opt\")\nset(JFS_SMT_TO_CNF_TOOL_PATH \"${CMAKE_BINARY_DIR}/bin/jfs-smt2cnf\")\nset(JFS_SMT_TO_CXX_TOOL_PATH \"${CMAKE_BINARY_DIR}/bin/jfs-smt2cxx\")\n\nconfigure_file(lit.site.cfg.in\n  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg\n  @ONLY\n)\n\nadd_custom_target(systemtests\n  COMMAND \"${LIT_TOOL}\" ${LIT_ARGS} \"${CMAKE_CURRENT_BINARY_DIR}\"\n  DEPENDS jfs_tool jfs-opt yaml-syntax-check FileCheck not\n  COMMENT \"Running system tests\"\n  ${ADD_CUSTOM_COMMAND_USES_TERMINAL_ARG}\n)\n\n# CXXFuzzingBackend customizes the testing harness\nadd_subdirectory(CXXFuzzingBackend)"
  },
  {
    "path": "tests/system_tests/CNF/2017-09-02-float-constant-regression.smt2",
    "content": "; RUN: %jfs-smt2cnf %s | %FileCheck %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n(assert (fp.eq a (fp #b0 #x86 #b00000000000000000000000)))\n(assert (fp.eq b (fp #b0 #x86 #b00000000000000000000001)))\n; CHECK: p cnf 68 132\n; CHECK-NEXT: -67 0\n; CHECK-NEXT: -68 0\n; CHECK-NEXT: -34 0\n; CHECK-NEXT: 43 0\n; CHECK-NEXT: -1 0\n; CHECK-NEXT: -10 0\n; CHECK-NEXT: 35 0\n; CHECK-NEXT: 36 0\n; CHECK-NEXT: -37 0\n; CHECK-NEXT: -38 0\n; CHECK-NEXT: -39 0\n; CHECK-NEXT: -40 0\n; CHECK-NEXT: 41 0\n; CHECK-NEXT: -44 0\n; CHECK-NEXT: -45 0\n; CHECK-NEXT: -46 0\n; CHECK-NEXT: -47 0\n; CHECK-NEXT: -48 0\n; CHECK-NEXT: -49 0\n; CHECK-NEXT: -50 0\n; CHECK-NEXT: -51 0\n; CHECK-NEXT: -52 0\n; CHECK-NEXT: -53 0\n; CHECK-NEXT: -54 0\n; CHECK-NEXT: -55 0\n; CHECK-NEXT: -56 0\n; CHECK-NEXT: -57 0\n; CHECK-NEXT: -58 0\n; CHECK-NEXT: -59 0\n; CHECK-NEXT: -60 0\n; CHECK-NEXT: -61 0\n; CHECK-NEXT: -62 0\n; CHECK-NEXT: -63 0\n; CHECK-NEXT: -64 0\n; CHECK-NEXT: -65 0\n; CHECK-NEXT: 2 0\n; CHECK-NEXT: 3 0\n; CHECK-NEXT: -4 0\n; CHECK-NEXT: -5 0\n; CHECK-NEXT: -6 0\n; CHECK-NEXT: -7 0\n; CHECK-NEXT: 8 0\n; CHECK-NEXT: -11 0\n; CHECK-NEXT: -12 0\n; CHECK-NEXT: -13 0\n; CHECK-NEXT: -14 0\n; CHECK-NEXT: -15 0\n; CHECK-NEXT: -16 0\n; CHECK-NEXT: -17 0\n; CHECK-NEXT: -18 0\n; CHECK-NEXT: -19 0\n; CHECK-NEXT: -20 0\n; CHECK-NEXT: -21 0\n; CHECK-NEXT: -22 0\n; CHECK-NEXT: -23 0\n; CHECK-NEXT: -24 0\n; CHECK-NEXT: -25 0\n; CHECK-NEXT: -26 0\n; CHECK-NEXT: -27 0\n; CHECK-NEXT: -28 0\n; CHECK-NEXT: -29 0\n; CHECK-NEXT: -30 0\n; CHECK-NEXT: -31 0\n; CHECK-NEXT: -32 0\n; CHECK-NEXT: 1 9 0\n; CHECK-NEXT: 2 9 0\n; CHECK-NEXT: 3 9 0\n; CHECK-NEXT: 4 9 0\n; CHECK-NEXT: 5 9 0\n; CHECK-NEXT: 6 9 0\n; CHECK-NEXT: 7 9 0\n; CHECK-NEXT: 8 9 0\n; CHECK-NEXT: 9 -33 0\n; CHECK-NEXT: -10 33 0\n; CHECK-NEXT: -11 33 0\n; CHECK-NEXT: -12 33 0\n; CHECK-NEXT: -13 33 0\n; CHECK-NEXT: -14 33 0\n; CHECK-NEXT: -15 33 0\n; CHECK-NEXT: -16 33 0\n; CHECK-NEXT: -17 33 0\n; CHECK-NEXT: -18 33 0\n; CHECK-NEXT: -19 33 0\n; CHECK-NEXT: -20 33 0\n; CHECK-NEXT: -21 33 0\n; CHECK-NEXT: -22 33 0\n; CHECK-NEXT: -23 33 0\n; CHECK-NEXT: -24 33 0\n; CHECK-NEXT: -25 33 0\n; CHECK-NEXT: -26 33 0\n; CHECK-NEXT: -27 33 0\n; CHECK-NEXT: -28 33 0\n; CHECK-NEXT: -29 33 0\n; CHECK-NEXT: -30 33 0\n; CHECK-NEXT: -31 33 0\n; CHECK-NEXT: -32 33 0\n; CHECK-NEXT: 34 42 0\n; CHECK-NEXT: 35 42 0\n; CHECK-NEXT: 36 42 0\n; CHECK-NEXT: 37 42 0\n; CHECK-NEXT: 38 42 0\n; CHECK-NEXT: 39 42 0\n; CHECK-NEXT: 40 42 0\n; CHECK-NEXT: 41 42 0\n; CHECK-NEXT: 42 -66 0\n; CHECK-NEXT: -43 66 0\n; CHECK-NEXT: -44 66 0\n; CHECK-NEXT: -45 66 0\n; CHECK-NEXT: -46 66 0\n; CHECK-NEXT: -47 66 0\n; CHECK-NEXT: -48 66 0\n; CHECK-NEXT: -49 66 0\n; CHECK-NEXT: -50 66 0\n; CHECK-NEXT: -51 66 0\n; CHECK-NEXT: -52 66 0\n; CHECK-NEXT: -53 66 0\n; CHECK-NEXT: -54 66 0\n; CHECK-NEXT: -55 66 0\n; CHECK-NEXT: -56 66 0\n; CHECK-NEXT: -57 66 0\n; CHECK-NEXT: -58 66 0\n; CHECK-NEXT: -59 66 0\n; CHECK-NEXT: -60 66 0\n; CHECK-NEXT: -61 66 0\n; CHECK-NEXT: -62 66 0\n; CHECK-NEXT: -63 66 0\n; CHECK-NEXT: -64 66 0\n; CHECK-NEXT: -65 66 0\n; CHECK-NEXT: -1 -2 -3 -4 -5 -6 -7 -8 -9 0\n; CHECK-NEXT: 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 -33 0\n; CHECK-NEXT: -34 -35 -36 -37 -38 -39 -40 -41 -42 0\n; CHECK-NEXT: 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 -66 0\n; NOTE: Z3 also prints comment lines that map constraints to CNF variables, but\n; it has an off-by-one error in this output, so we omit from the test.\n"
  },
  {
    "path": "tests/system_tests/CNF/imperial_synthetic_sqrt_klee_bug.x86_64_query.05.smt2",
    "content": "; RUN: %jfs-smt2cnf %s | %FileCheck %s\n(set-info :smt-lib-version 2.5)\n(set-logic QF_FPBV)\n(set-info :source |\nGenerated by: Daniel Liew, Daniel Schemmel, Cristian Cadar, Alastair Donaldson, and Rafael Zähl\nGenerated on: 2017-4-28\nGenerator: KLEE\nApplication: Branch satisfiability check for symbolic execution of C programs\nTarget solver: Z3 or MathSAT5\nCorresponding query: An equisatisfiable query (bitvectors replaced with reads from arrays of bitvectors) is available at QF_FPABV/liew/imperial_synthetic_sqrt_klee_bug.x86_64/query.05.smt2\n|)\n(set-info :license \"https://creativecommons.org/licenses/by/4.0/\")\n(set-info :category \"industrial\")\n(set-info :status sat)\n(declare-fun x_ackermann!0 () (_ BitVec 32))\n(assert\n (not (fp.isNaN ((_ to_fp 8 24) x_ackermann!0))))\n(assert\n (not (fp.lt ((_ to_fp 8 24) x_ackermann!0) ((_ to_fp 8 24) (_ bv0 32)))))\n(assert\n (not (fp.gt ((_ to_fp 8 24) x_ackermann!0) ((_ to_fp 8 24) (_ bv1120403456 32)))))\n(assert\n (let ((?x8 ((_ to_fp 8 24) x_ackermann!0)))\n(let ((?x23 (fp.mul roundNearestTiesToEven (fp.add roundNearestTiesToEven ?x8 ((_ to_fp 8 24) (_ bv0 32))) ((_ to_fp 8 24) (_ bv1056964608 32)))))\n(let (($x28 (fp.lt (fp.abs (fp.sub roundNearestTiesToEven ?x23 ?x8)) ((_ to_fp 8 24) (_ bv869711765 32)))))\n(not $x28)))))\n; CHECK: p cnf 3854 22927"
  },
  {
    "path": "tests/system_tests/CNF/less_variables_than_bits.smt2",
    "content": "; The bit-blasted form uses 15 booleans, while JFS uses 16 bits in the buffer.\n; RUN: %jfs-smt2cnf %s | %FileCheck %s\n(declare-fun a () (_ FloatingPoint 5 11))\n(assert (not (fp.isNaN a)))\n; CHECK: p cnf 17 18\n; CHECK-NEXT: 1 6 0\n; CHECK-NEXT: 2 6 0\n; CHECK-NEXT: 3 6 0\n; CHECK-NEXT: 4 6 0\n; CHECK-NEXT: 5 6 0\n; CHECK-NEXT: 6 -17 0\n; CHECK-NEXT: -7 17 0\n; CHECK-NEXT: -8 17 0\n; CHECK-NEXT: -9 17 0\n; CHECK-NEXT: -10 17 0\n; CHECK-NEXT: -11 17 0\n; CHECK-NEXT: -12 17 0\n; CHECK-NEXT: -13 17 0\n; CHECK-NEXT: -14 17 0\n; CHECK-NEXT: -15 17 0\n; CHECK-NEXT: -16 17 0\n; CHECK-NEXT: -1 -2 -3 -4 -5 -6 0\n; CHECK-NEXT: 7 8 9 10 11 12 13 14 15 16 -17 0\n; NOTE: Z3 also prints comment lines that map constraints to CNF variables, but\n; it has an off-by-one error in this output, so we omit from the test.\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n\n# Fuzz customizes the testing harness\nadd_subdirectory(Fuzz)"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/SingleConstantAssignment.smt2",
    "content": "; RUN: %jfs-smt2cxx %s | %cxx-rt-syntax -\n(declare-fun a () (_ BitVec 32))\n(assert (= a (_ bv0 32)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/SingleUnconstraintedBool.smt2",
    "content": "; RUN: %jfs-smt2cxx %s | %cxx-rt-syntax -\n(declare-fun a () Bool)\n(assert (or a (not a)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/UsedConstantAssignment.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun c () (_ BitVec 32))\n(declare-fun d () (_ BitVec 32))\n; This constant assignment should be used\n; Note if constant propagation is used as a\n; preprocessing step this will break.\n; CHECK: BitVector<32> d = BitVector<32>(UINT64_C(13));\n(assert (= d (_ bv13 32)))\n(assert (bvugt c d))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/UsedConstantFloatingPointAssignment.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n(declare-fun c () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> a = Float<8,24>(BitVector<1>(UINT64_C(0)), BitVector<8>(UINT64_C(134)), BitVector<23>(UINT64_C(0)))\n(assert (= a (fp #b0 #x86 #b00000000000000000000000)))\n(assert (= b (fp #b0 #x86 #b00000000000000000000001)))\n(assert (not (fp.isNaN a)))\n(assert (not (fp.isNaN (fp.add RNE a c))))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/branch_encodings/fail_fast.smt2",
    "content": "; RUN: %jfs-smt2cxx -branch-encoding=fail-fast -record-max-num-satisfied-constraints=0 -record-num-inputs=0 %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(declare-fun c () Bool)\n(assert (or a b))\n(assert (or b c))\n(check-sat)\n\n; FIXME: These checks for braces are really fragile.\n\n; CHECK: LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)\n; CHECK-NEXT: {\n\n; CHECK: const bool jfs_ssa_0 = a || b;\n; CHECK-NEXT: if (jfs_ssa_0) {}\n; CHECK-NEXT: else {\n; CHECK-NEXT: return 0;\n; CHECK-NEXT: }\n\n; CHECK: const bool jfs_ssa_1 = b || c;\n; CHECK-NEXT: if (jfs_ssa_1) {}\n; CHECK-NEXT: else {\n; CHECK-NEXT: return 0;\n; CHECK-NEXT: }\n\n; CHECK:// Fuzzing target\n; CHECK-NEXT: abort();\n\n; CHECK: }\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/branch_encodings/try_all.smt2",
    "content": "; RUN: %jfs-smt2cxx -branch-encoding=try-all -record-max-num-satisfied-constraints=0 -record-num-inputs=0 %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(declare-fun c () Bool)\n(assert (or a b))\n(assert (or b c))\n(check-sat)\n\n; FIXME: These checks for braces are really fragile.\n\n; CHECK: LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)\n; CHECK-NEXT: {\n\n\n; CHECK: uint64_t jfs_num_const_sat = 0;\n; CHECK: const bool jfs_ssa_0 = a || b;\n; CHECK-NEXT: if (jfs_ssa_0)\n; CHECK-NEXT: {\n; CHECK-NEXT: ++jfs_num_const_sat;\n; CHECK-NEXT: }\n\n; CHECK: const bool jfs_ssa_1 = b || c;\n; CHECK-NEXT: if (jfs_ssa_1)\n; CHECK-NEXT: {\n; CHECK-NEXT: ++jfs_num_const_sat;\n; CHECK-NEXT: }\n\n; CHECK: if (jfs_num_const_sat == 2)\n; CHECK-NEXT: {\n; CHECK-NEXT: // Fuzzing target\n; CHECK-NEXT: abort();\n; CHECK-NEXT: }\n; CHECK-NEXT: else {\n; CHECK-NEXT: return 0;\n; CHECK-NEXT: }\n\n; CHECK: }\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/branch_encodings/try_all_imncsf.smt2",
    "content": "; NOTE: try-all-imncsf uses an experimental LibFuzzer feature (custom counters)\n; which currently only works on Linux.\n; REQUIRES: linux\n; RUN: %jfs-smt2cxx -branch-encoding=try-all-imncsf %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n; RUN: %FileCheck -check-prefix=PASS -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(declare-fun c () Bool)\n(assert (or a b))\n(assert (or b c))\n(check-sat)\n\n; PASS-NOT: extern \"C\" void LLVMFuzzerAtExit()\n\n; FIXME: These checks for braces are really fragile.\n; CHECK: uint64_t jfs_max_num_const_sat = 0;\n\n; CHECK: #ifdef __linux__\n; CHECK-NEXT: __attribute__((section(\"__libfuzzer_extra_counters\")))\n; CHECK-NEXT: #endif\n; CHECK-NEXT: static uint8_t jfs_libfuzzer_custom_counter[2];\n\n\n; CHECK: LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)\n; CHECK-NEXT: {\n\n; CHECK: uint64_t jfs_num_const_sat = 0;\n; CHECK: const bool jfs_ssa_0 = a || b;\n; CHECK-NEXT: if (jfs_ssa_0)\n; CHECK-NEXT: {\n; CHECK-NEXT:   ++jfs_num_const_sat;\n; CHECK-NEXT: }\n\n; CHECK: const bool jfs_ssa_1 = b || c;\n; CHECK-NEXT: if (jfs_ssa_1)\n; CHECK-NEXT: {\n; CHECK-NEXT:   ++jfs_num_const_sat;\n; CHECK-NEXT: }\n\n; CHECK-NEXT: if (jfs_max_num_const_sat < jfs_num_const_sat)\n; CHECK-NEXT: {\n; CHECK-NEXT:   jfs_max_num_const_sat = jfs_num_const_sat;\n; CHECK-NEXT: }\n\n; CHECK-NEXT: if (jfs_max_num_const_sat > 0)\n; CHECK-NEXT: {\n; CHECK-NEXT:   jfs_libfuzzer_custom_counter[jfs_max_num_const_sat -1] = 1;\n; CHECK-NEXT: }\n\n; CHECK:      if (jfs_num_const_sat == 2)\n; CHECK-NEXT: {\n; CHECK-NEXT:   // Fuzzing target\n; CHECK-NEXT:   abort();\n; CHECK-NEXT: }\n; CHECK-NEXT: else {\n; CHECK-NEXT:   return 0;\n; CHECK-NEXT: }\n\n; CHECK: }\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/buffer_element_alignment/bv_bool_bv_bool.smt2",
    "content": "; RUN: %jfs-smt2cxx -byte-aligned-buffer-elements=false %s > %t-no-align.cpp\n; RUN: %cxx-rt-syntax %t-no-align.cpp\n; RUN: %FileCheck -check-prefixes CHECK-COMMON,CHECK-NO-ALIGN -input-file=%t-no-align.cpp %s\n; RUN: %jfs-smt2cxx -byte-aligned-buffer-elements %s > %t-align.cpp\n; RUN: %cxx-rt-syntax %t-align.cpp\n; RUN: %FileCheck -check-prefixes CHECK-COMMON,CHECK-ALIGN -input-file=%t-align.cpp %s\n\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(declare-fun c () Bool)\n(declare-fun d () (_ BitVec 2))\n(declare-fun e () (_ BitVec 19))\n(assert (or a b))\n(assert (bvult d #b11))\n(assert (bvult e #b1010101010101001011))\n(assert (or b c))\n(check-sat)\n\n; CHECK-COMMON: LLVMFuzzerTestOneInput\n\n; CHECK-NO-ALIGN: bool a = makeBoolFrom(jfs_buffer_ref, 0, 0);\n; CHECK-NO-ALIGN: bool b = makeBoolFrom(jfs_buffer_ref, 1, 1);\n; CHECK-NO-ALIGN: BitVector<2> d = makeBitVectorFrom<2>(jfs_buffer_ref, 2, 3);\n; CHECK-NO-ALIGN: BitVector<19> e = makeBitVectorFrom<19>(jfs_buffer_ref, 4, 22);\n; CHECK-NO-ALIGN: bool c = makeBoolFrom(jfs_buffer_ref, 23, 23);\n\n\n; CHECK-ALIGN: bool a = makeBoolFrom(jfs_buffer_ref, 0, 0);\n; CHECK-ALIGN: bool b = makeBoolFrom(jfs_buffer_ref, 8, 8);\n; CHECK-ALIGN: BitVector<2> d = makeBitVectorFrom<2>(jfs_buffer_ref, 16, 17);\n; CHECK-ALIGN: BitVector<19> e = makeBitVectorFrom<19>(jfs_buffer_ref, 24, 42);\n; CHECK-ALIGN: bool c = makeBoolFrom(jfs_buffer_ref, 48, 48);\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/buffer_element_alignment/bv_bool_bv_bool_float.smt2",
    "content": "; RUN: %jfs-smt2cxx -byte-aligned-buffer-elements=false %s > %t-no-align.cpp\n; RUN: %cxx-rt-syntax %t-no-align.cpp\n; RUN: %FileCheck -check-prefixes CHECK-COMMON,CHECK-NO-ALIGN -input-file=%t-no-align.cpp %s\n; RUN: %jfs-smt2cxx -byte-aligned-buffer-elements %s > %t-align.cpp\n; RUN: %cxx-rt-syntax %t-align.cpp\n; RUN: %FileCheck -check-prefixes CHECK-COMMON,CHECK-ALIGN -input-file=%t-align.cpp %s\n\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(declare-fun c () Bool)\n(declare-fun d () (_ BitVec 2))\n(declare-fun e () (_ BitVec 19))\n(declare-fun f () Float32)\n(assert (or a b))\n(assert (bvult d #b11))\n(assert (bvult e #b1010101010101001011))\n(assert (fp.eq f f))\n(assert (or b c))\n(check-sat)\n\n; CHECK-COMMON: LLVMFuzzerTestOneInput\n\n; CHECK-NO-ALIGN: bool a = makeBoolFrom(jfs_buffer_ref, 0, 0);\n; CHECK-NO-ALIGN: bool b = makeBoolFrom(jfs_buffer_ref, 1, 1);\n; CHECK-NO-ALIGN: BitVector<2> d = makeBitVectorFrom<2>(jfs_buffer_ref, 2, 3);\n; CHECK-NO-ALIGN: BitVector<19> e = makeBitVectorFrom<19>(jfs_buffer_ref, 4, 22);\n; CHECK-NO-ALIGN: const Float<8,24> f = makeFloatFrom<8,24>(jfs_buffer_ref, 23, 54);\n; CHECK-NO-ALIGN: bool c = makeBoolFrom(jfs_buffer_ref, 55, 55);\n\n\n; CHECK-ALIGN: bool a = makeBoolFrom(jfs_buffer_ref, 0, 0);\n; CHECK-ALIGN: bool b = makeBoolFrom(jfs_buffer_ref, 8, 8);\n; CHECK-ALIGN: BitVector<2> d = makeBitVectorFrom<2>(jfs_buffer_ref, 16, 17);\n; CHECK-ALIGN: BitVector<19> e = makeBitVectorFrom<19>(jfs_buffer_ref, 24, 42);\n; CHECK-ALIGN: Float<8,24> f = makeFloatFrom<8,24>(jfs_buffer_ref, 48, 79);\n; CHECK-ALIGN: bool c = makeBoolFrom(jfs_buffer_ref, 80, 80);\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/buffer_element_alignment/three_bools.smt2",
    "content": "; RUN: %jfs-smt2cxx -byte-aligned-buffer-elements=false %s > %t-no-align.cpp\n; RUN: %cxx-rt-syntax %t-no-align.cpp\n; RUN: %FileCheck -check-prefixes CHECK-COMMON,CHECK-NO-ALIGN -input-file=%t-no-align.cpp %s\n; RUN: %jfs-smt2cxx -byte-aligned-buffer-elements %s > %t-align.cpp\n; RUN: %cxx-rt-syntax %t-align.cpp\n; RUN: %FileCheck -check-prefixes CHECK-COMMON,CHECK-ALIGN -input-file=%t-align.cpp %s\n\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(declare-fun c () Bool)\n(assert (or a b))\n(assert (or b c))\n(check-sat)\n\n; CHECK-COMMON: LLVMFuzzerTestOneInput\n\n; CHECK-NO-ALIGN: bool a = makeBoolFrom(jfs_buffer_ref, 0, 0);\n; CHECK-NO-ALIGN: const bool b = makeBoolFrom(jfs_buffer_ref, 1, 1);\n; CHECK-NO-ALIGN: const bool c = makeBoolFrom(jfs_buffer_ref, 2, 2);\n\n; CHECK-ALIGN: bool a = makeBoolFrom(jfs_buffer_ref, 0, 0);\n; CHECK-ALIGN: const bool b = makeBoolFrom(jfs_buffer_ref, 8, 8);\n; CHECK-ALIGN: const bool c = makeBoolFrom(jfs_buffer_ref, 16, 16);\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/inconsistent_equalities.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun c () (_ BitVec 32))\n; This is probably the best we can do.\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = false;\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (= c (_ bv13 32)))\n(assert (= c (_ bv0 32)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bool/and.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(declare-fun c () Bool)\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a && b;\n; CHECK-NEXT: if ([[SSA0]]) {}\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = b && c;\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert (and (and a b) (and b c)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bool/distinct_bool.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = ( a != b );\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (distinct a b))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bool/equal_bool.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(declare-fun c () Bool)\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a == b;\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = a == c;\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] || [[SSA1]];\n; CHECK-NEXT: if ([[SSA2]]) {}\n; Note: We have to use or here to avoid equalities being\n; removed.\n(assert (or (= a b) (= a c)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bool/iff.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a == b;\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (iff a b))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bool/implies.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = (!a) || b;\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (=> a b))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bool/ite_bool.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(declare-fun c () Bool)\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = (a)?(b):(c);\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (ite a b c))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bool/not.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(assert (not (or a b)))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a || b;\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = !([[SSA0]]);\n; CHECK-NEXT: if ([[SSA1]]) {}\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bool/or.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(declare-fun c () Bool)\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a || b || c;\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (or a b c))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bool/xor.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(declare-fun c () Bool)\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a ^ b;\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (xor a b))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvadd.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvadd(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvadd a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvadd_nary.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n(declare-fun c () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = (a.bvadd(b)).bvadd(c);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvadd a b c) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvand.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvand(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvand a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvand_nary.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n(declare-fun c () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = (a.bvand(b)).bvand(c);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvand a b c) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvashr.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvashr(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvashr a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvcomp.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvcomp(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvcomp a b) (_ bv0 1)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvlshr.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvlshr(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvlshr a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvmul.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvmul(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvmul a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvmul_nary.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n(declare-fun c () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = (a.bvmul(b)).bvmul(c);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvmul a b c) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvnand.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvnand(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvnand a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvneg.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n; CHECK: BitVector<8> [[SSA0:[a-z_0-9]+]] = a.bvneg();\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvneg a) (_ bv255 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvnor.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvnor(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvnor a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvnot.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n; CHECK: BitVector<8> [[SSA0:[a-z_0-9]+]] = a.bvnot();\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvnot a) (_ bv255 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvor.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvor(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvor a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvor_nary.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n(declare-fun c () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = (a.bvor(b)).bvor(c);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvor a b c) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvsdiv.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvsdiv(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvsdiv a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvsdiv0.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n; CHECK: const BitVector<8> [[SSA0:[a-z_0-9]+]] = BitVector<8>(UINT64_C(0));\n; CHECK: const BitVector<8> [[SSA1:[a-z_0-9]+]] = a.bvsdiv([[SSA0]]);\n; CHECK: const bool [[SSA2:[a-z_0-9]+]] = [[SSA1]] == [[SSA0]];\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvsdiv a (_ bv0 8)) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvsdiv_i.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvsdiv(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvsdiv_i a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvsge.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvsge(b);\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (bvsge a b))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvsgt.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvsgt(b);\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (bvsgt a b))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvshl.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvshl(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvshl a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvsle.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvsle(b);\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (bvsle a b))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvslt.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvslt(b);\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (bvslt a b))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvsmod.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvsmod(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvsmod a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvsmod_i.smt2",
    "content": "; NOTE: This test will fail for Z3 versions that have the bug fixed by\n; https://github.com/Z3Prover/z3/pull/1144\n; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvsmod(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvsmod_i a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvsrem.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvsrem(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvsrem a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvsrem_i.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvsrem(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvsrem_i a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvsub.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvsub(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvsub a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvudiv.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvudiv(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvudiv a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvudiv0.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n; CHECK: const BitVector<8> [[SSA0:[a-z_0-9]+]] = BitVector<8>(UINT64_C(0));\n; CHECK: const BitVector<8> [[SSA1:[a-z_0-9]+]] = a.bvudiv([[SSA0]]);\n; CHECK: const bool [[SSA2:[a-z_0-9]+]] = [[SSA1]] == [[SSA0]];\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvudiv a (_ bv0 8)) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvudiv_i.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvudiv(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvudiv_i a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvuge.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvuge(b);\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (bvuge a b))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvugt.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvugt(b);\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (bvugt a b))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvule.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvule(b);\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (bvule a b))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvult.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvult(b);\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (bvult a b))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvurem.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvurem(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvurem a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvurem_i.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvurem(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvurem_i a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvxnor.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvxnor(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvxnor a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvxor.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.bvxor(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvxor a b) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/bvxor_nary.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n(declare-fun c () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = (a.bvxor(b)).bvxor(c);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (bvxor a b c) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/concat.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: BitVector<16> [[SSA0:[a-z_0-9]+]] = a.concat(b);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (concat a b) (_ bv0 16)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/concat_large.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n(declare-fun c () (_ BitVec 8))\n(declare-fun d () (_ BitVec 8))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = ((a.concat(b)).concat(c)).concat(d);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= (concat a b c d) (_ bv0 32)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/distinct_bitvector.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n(declare-fun c () (_ BitVec 8))\n(declare-fun d () (_ BitVec 8))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = ( a != b ) && ( a != c ) && ( a != d ) && ( b != c ) && ( b != d ) && ( c != d );\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert (distinct a b c d))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/equal_bitvector.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n(declare-fun c () (_ BitVec 8))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a == b;\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = a == c;\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] || [[SSA1]];\n; CHECK-NEXT: if ([[SSA2]]) {}\n; Note: We have to use or here to avoid equalities being\n; removed.\n(assert (or (= a b) (= a c)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/extract.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n; CHECK: BitVector<2> [[SSA0:[a-z_0-9]+]] = a.extract<2>(7,6);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= ((_ extract 7 6) a) (_ bv0 2)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/ite_bitvector.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () (_ BitVec 8))\n(declare-fun c () (_ BitVec 8))\n; CHECK: BitVector<8> [[SSA0:[a-z_0-9]+]] = (a)?(b):(c);\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = b == [[SSA0]];\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert (= b (ite a b c)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/rotate_left.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.rotate_left(3);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= ((_ rotate_left 3) a) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/rotate_right.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n(declare-fun b () (_ BitVec 8))\n; CHECK: [[SSA0:[a-z_0-9]+]] = a.rotate_right(3);\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= ((_ rotate_right 3) a) (_ bv0 8)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/sign_extend.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n; CHECK: BitVector<12> [[SSA0:[a-z_0-9]+]] = a.signExtend<4>();\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= ((_ sign_extend 4) a) (_ bv0 12)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/bv/zero_extend.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 8))\n; CHECK: BitVector<12> [[SSA0:[a-z_0-9]+]] = a.zeroExtend<4>();\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == {{[a-z_0-9]+}};\n; CHECK: if ([[SSA2]]) {}\n(assert (= ((_ zero_extend 4) a) (_ bv0 12)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/abs_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.abs()\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN (fp.abs a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/abs_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.abs()\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN (fp.abs a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/add_rna_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.add(JFS_RM_RNA, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.add RNA a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/add_rna_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.add(JFS_RM_RNA, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.add RNA a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/add_rne_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.add(JFS_RM_RNE, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.add RNE a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/add_rne_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.add(JFS_RM_RNE, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.add RNE a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/add_rtn_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.add(JFS_RM_RTN, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.add RTN a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/add_rtn_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.add(JFS_RM_RTN, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.add RTN a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/add_rtp_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.add(JFS_RM_RTP, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.add RTP a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/add_rtp_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.add(JFS_RM_RTP, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.add RTP a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/add_rtz_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.add(JFS_RM_RTZ, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.add RTZ a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/add_rtz_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.add(JFS_RM_RTZ, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.add RTZ a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/cast_bv32_to_float.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; FIXME: Add FileCheck test. Not doing now because\n; design is in flux\n(declare-fun a () (_ BitVec 32))\n(assert\n  (or\n    (=\n      ((_ to_fp 8 24) a)\n      (fp #b0 #b00000000 #b00000000000000000000000)\n    )\n    (=\n      ((_ to_fp 8 24) a)\n      (fp #b1 #b00000000 #b00000000000000000000000)\n    )\n  )\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/constant_nan_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = Float<8,24>::getNaN()\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = a.fpgeq([[SSA0]])\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.geq a (_ NaN 8 24))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/constant_nan_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = Float<11,53>::getNaN()\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = a.fpgeq([[SSA0]])\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.geq a (_ NaN 11 53))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/constant_negative_infinity_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = Float<8,24>::getNegativeInfinity()\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = a.fpgeq([[SSA0]])\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.geq a (_ -oo 8 24))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/constant_negative_infinity_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = Float<11,53>::getNegativeInfinity()\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = a.fpgeq([[SSA0]])\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.geq a (_ -oo 11 53))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/constant_negative_zero_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = Float<8,24>::getNegativeZero()\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = a.fpgeq([[SSA0]])\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.geq a (_ -zero 8 24))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/constant_negative_zero_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = Float<11,53>::getNegativeZero()\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = a.fpgeq([[SSA0]])\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.geq a (_ -zero 11 53))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/constant_plus_infinity_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = Float<8,24>::getPositiveInfinity()\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = a.fpleq([[SSA0]])\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.leq a (_ +oo 8 24))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/constant_plus_infinity_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = Float<11,53>::getPositiveInfinity()\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = a.fpleq([[SSA0]])\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.leq a (_ +oo 11 53))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/constant_plus_zero_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = Float<8,24>::getPositiveZero()\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = a.fpgeq([[SSA0]])\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.geq a (_ +zero 8 24))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/constant_plus_zero_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = Float<11,53>::getPositiveZero()\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = a.fpgeq([[SSA0]])\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.geq a (_ +zero 11 53))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/constants_from_triple.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; FIXME: Add FileCheck test. Not doing now because\n; design is in flux\n(declare-fun a () (_ FloatingPoint 8 24))\n(assert\n  (or\n    (= a (fp #b0 #b00000000 #b00000000000000000000000))\n    (= a (fp #b1 #b00000000 #b00000000000000000000000))\n  )\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_float32_rna.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<8,24>(JFS_RM_RNA)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 8 24) RNA a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_float32_rne.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<8,24>(JFS_RM_RNE)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 8 24) RNE a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_float32_rtn.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<8,24>(JFS_RM_RTN)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 8 24) RTN a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_float32_rtp.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<8,24>(JFS_RM_RTP)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 8 24) RTP a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_float32_rtz.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<8,24>(JFS_RM_RTZ)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 8 24) RTZ a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_float64_rna.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<8,24>(JFS_RM_RNA)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 8 24) RNA a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_float64_rne.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<8,24>(JFS_RM_RNE)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 8 24) RNE a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_float64_rtn.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<8,24>(JFS_RM_RTN)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 8 24) RTN a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_float64_rtp.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<8,24>(JFS_RM_RTP)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 8 24) RTP a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_float64_rtz.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<8,24>(JFS_RM_RTZ)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 8 24) RTZ a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_signed_bv_rna.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = Float<8,24>::convertFromSignedBV<64>(JFS_RM_RNA, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 8 24) RNA a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_signed_bv_rne.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = Float<8,24>::convertFromSignedBV<64>(JFS_RM_RNE, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 8 24) RNE a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_signed_bv_rtn.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = Float<8,24>::convertFromSignedBV<64>(JFS_RM_RTN, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 8 24) RTN a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_signed_bv_rtp.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = Float<8,24>::convertFromSignedBV<64>(JFS_RM_RTP, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 8 24) RTP a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_signed_bv_rtz.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = Float<8,24>::convertFromSignedBV<64>(JFS_RM_RTZ, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 8 24) RTZ a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_unsigned_bv_rna.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = Float<8,24>::convertFromUnsignedBV<64>(JFS_RM_RNA, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp_unsigned 8 24) RNA a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_unsigned_bv_rne.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = Float<8,24>::convertFromUnsignedBV<64>(JFS_RM_RNE, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp_unsigned 8 24) RNE a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_unsigned_bv_rtn.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = Float<8,24>::convertFromUnsignedBV<64>(JFS_RM_RTN, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp_unsigned 8 24) RTN a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_unsigned_bv_rtp.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = Float<8,24>::convertFromUnsignedBV<64>(JFS_RM_RTP, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp_unsigned 8 24) RTP a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float32_from_unsigned_bv_rtz.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = Float<8,24>::convertFromUnsignedBV<64>(JFS_RM_RTZ, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp_unsigned 8 24) RTZ a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_float32_rna.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<11,53>(JFS_RM_RNA)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 11 53) RNA a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_float32_rne.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<11,53>(JFS_RM_RNE)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 11 53) RNE a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_float32_rtn.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<11,53>(JFS_RM_RTN)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 11 53) RTN a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_float32_rtp.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<11,53>(JFS_RM_RTP)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 11 53) RTP a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_float32_rtz.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<11,53>(JFS_RM_RTZ)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 11 53) RTZ a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_float64_rna.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<11,53>(JFS_RM_RNA)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 11 53) RNA a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_float64_rne.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<11,53>(JFS_RM_RNE)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 11 53) RNE a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_float64_rtn.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<11,53>(JFS_RM_RTN)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 11 53) RTN a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_float64_rtp.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<11,53>(JFS_RM_RTP)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 11 53) RTP a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_float64_rtz.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.convertToFloat<11,53>(JFS_RM_RTZ)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 11 53) RTZ a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_signed_bv_rna.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = Float<11,53>::convertFromSignedBV<64>(JFS_RM_RNA, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 11 53) RNA a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_signed_bv_rne.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = Float<11,53>::convertFromSignedBV<64>(JFS_RM_RNE, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 11 53) RNE a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_signed_bv_rtn.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = Float<11,53>::convertFromSignedBV<64>(JFS_RM_RTN, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 11 53) RTN a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_signed_bv_rtp.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = Float<11,53>::convertFromSignedBV<64>(JFS_RM_RTP, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 11 53) RTP a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_signed_bv_rtz.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = Float<11,53>::convertFromSignedBV<64>(JFS_RM_RTZ, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp 11 53) RTZ a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_unsigned_bv_rna.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = Float<11,53>::convertFromUnsignedBV<64>(JFS_RM_RNA, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp_unsigned 11 53) RNA a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_unsigned_bv_rne.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = Float<11,53>::convertFromUnsignedBV<64>(JFS_RM_RNE, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp_unsigned 11 53) RNE a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_unsigned_bv_rtn.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = Float<11,53>::convertFromUnsignedBV<64>(JFS_RM_RTN, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp_unsigned 11 53) RTN a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_unsigned_bv_rtp.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = Float<11,53>::convertFromUnsignedBV<64>(JFS_RM_RTP, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp_unsigned 11 53) RTP a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_float64_from_unsigned_bv_rtz.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ BitVec 64))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = Float<11,53>::convertFromUnsignedBV<64>(JFS_RM_RTZ, a)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN ((_ to_fp_unsigned 11 53) RTZ a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_signed_bv_from_float32_rna.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToSignedBV<32>(JFS_RM_RNA)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_sbv 32) RNA a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_signed_bv_from_float32_rne.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToSignedBV<32>(JFS_RM_RNE)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_sbv 32) RNE a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_signed_bv_from_float32_rtn.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToSignedBV<32>(JFS_RM_RTN)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_sbv 32) RTN a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_signed_bv_from_float32_rtp.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToSignedBV<32>(JFS_RM_RTP)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_sbv 32) RTP a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_signed_bv_from_float32_rtz.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToSignedBV<32>(JFS_RM_RTZ)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_sbv 32) RTZ a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_signed_bv_from_float64_rna.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToSignedBV<32>(JFS_RM_RNA)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_sbv 32) RNA a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_signed_bv_from_float64_rne.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToSignedBV<32>(JFS_RM_RNE)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_sbv 32) RNE a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_signed_bv_from_float64_rtn.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToSignedBV<32>(JFS_RM_RTN)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_sbv 32) RTN a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_signed_bv_from_float64_rtp.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToSignedBV<32>(JFS_RM_RTP)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_sbv 32) RTP a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_signed_bv_from_float64_rtz.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToSignedBV<32>(JFS_RM_RTZ)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_sbv 32) RTZ a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_unsigned_bv_from_float32_rna.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToUnsignedBV<32>(JFS_RM_RNA)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_ubv 32) RNA a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_unsigned_bv_from_float32_rne.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToUnsignedBV<32>(JFS_RM_RNE)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_ubv 32) RNE a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_unsigned_bv_from_float32_rtn.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToUnsignedBV<32>(JFS_RM_RTN)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_ubv 32) RTN a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_unsigned_bv_from_float32_rtp.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToUnsignedBV<32>(JFS_RM_RTP)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_ubv 32) RTP a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_unsigned_bv_from_float32_rtz.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToUnsignedBV<32>(JFS_RM_RTZ)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_ubv 32) RTZ a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_unsigned_bv_from_float64_rna.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToUnsignedBV<32>(JFS_RM_RNA)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_ubv 32) RNA a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_unsigned_bv_from_float64_rne.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToUnsignedBV<32>(JFS_RM_RNE)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_ubv 32) RNE a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_unsigned_bv_from_float64_rtn.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToUnsignedBV<32>(JFS_RM_RTN)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_ubv 32) RTN a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_unsigned_bv_from_float64_rtp.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToUnsignedBV<32>(JFS_RM_RTP)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_ubv 32) RTP a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/convert_to_unsigned_bv_from_float64_rtz.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: BitVector<32> [[SSA0:[a-z_0-9]+]] = a.convertToUnsignedBV<32>(JFS_RM_RTZ)\n; CHECK: [[SSA1:[a-z_0-9+]+]] = BitVector<32>(UINT64_C(0))\n; CHECK: bool [[SSA2:[a-z_0-9]+]] = [[SSA0]] == [[SSA1]]\n; CHECK-NEXT: if ([[SSA2]]) {}\n(assert\n  (= ((_ fp.to_ubv 32) RTZ a) (_ bv0 32))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/div_rna_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.div(JFS_RM_RNA, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.div RNA a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/div_rna_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.div(JFS_RM_RNA, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.div RNA a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/div_rne_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.div(JFS_RM_RNE, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.div RNE a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/div_rne_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.div(JFS_RM_RNE, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.div RNE a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/div_rtn_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.div(JFS_RM_RTN, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.div RTN a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/div_rtn_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.div(JFS_RM_RTN, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.div RTN a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/div_rtp_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.div(JFS_RM_RTP, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.div RTP a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/div_rtp_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.div(JFS_RM_RTP, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.div RTP a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/div_rtz_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.div(JFS_RM_RTZ, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.div RTZ a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/div_rtz_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.div(JFS_RM_RTZ, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.div RTZ a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fma_rna_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n(declare-fun c () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.fma(JFS_RM_RNA, b, c)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.fma RNA a b c) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fma_rna_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n(declare-fun c () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.fma(JFS_RM_RNA, b, c)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.fma RNA a b c) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fma_rne_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n(declare-fun c () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.fma(JFS_RM_RNE, b, c)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.fma RNE a b c) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fma_rne_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n(declare-fun c () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.fma(JFS_RM_RNE, b, c)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.fma RNE a b c) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fma_rtn_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n(declare-fun c () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.fma(JFS_RM_RTN, b, c)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.fma RTN a b c) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fma_rtn_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n(declare-fun c () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.fma(JFS_RM_RTN, b, c)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.fma RTN a b c) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fma_rtp_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n(declare-fun c () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.fma(JFS_RM_RTP, b, c)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.fma RTP a b c) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fma_rtp_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n(declare-fun c () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.fma(JFS_RM_RTP, b, c)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.fma RTP a b c) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fma_rtz_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n(declare-fun c () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.fma(JFS_RM_RTZ, b, c)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.fma RTZ a b c) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fma_rtz_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n(declare-fun c () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.fma(JFS_RM_RTZ, b, c)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.fma RTZ a b c) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fpgeq_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.fpgeq(b)\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.geq a b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fpgeq_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.fpgeq(b)\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.geq a b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fpgt_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.fpgt(b)\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.gt a b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fpgt_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.fpgt(b)\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.gt a b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fpleq_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.fpleq(b)\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.leq a b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fpleq_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.fpleq(b)\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.leq a b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fplt_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.fplt(b)\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.lt a b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/fplt_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.fplt(b)\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.lt a b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/ieee_equals_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.eq a b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/ieee_equals_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.eq a b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/is_infinite_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.isInfinite()\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.isInfinite a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/is_infinite_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.isInfinite()\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.isInfinite a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/is_nan_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.isNaN()\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.isNaN a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/is_nan_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.isNaN()\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.isNaN a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/is_negative_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.isNegative()\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.isNegative a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/is_negative_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.isNegative()\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.isNegative a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/is_normal_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.isNormal()\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.isNormal a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/is_normal_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.isNormal()\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.isNormal a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/is_positive_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.isPositive()\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.isPositive a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/is_positive_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.isPositive()\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.isPositive a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/is_subnormal_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.isSubnormal()\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.isSubnormal a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/is_subnormal_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.isSubnormal()\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.isSubnormal a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/is_zero_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.isZero()\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.isZero a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/is_zero_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a.isZero()\n; CHECK-NEXT: if ([[SSA0]]) {}\n(assert\n  (fp.isZero a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/max_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.max(b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]] == b\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (= (fp.max a b) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/max_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.max(b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]] == b\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (= (fp.max a b) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/min_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.min(b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]] == b\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (= (fp.min a b) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/min_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.min(b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]] == b\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (= (fp.min a b) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/mul_rna_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.mul(JFS_RM_RNA, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.mul RNA a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/mul_rna_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.mul(JFS_RM_RNA, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.mul RNA a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/mul_rne_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.mul(JFS_RM_RNE, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.mul RNE a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/mul_rne_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.mul(JFS_RM_RNE, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.mul RNE a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/mul_rtn_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.mul(JFS_RM_RTN, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.mul RTN a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/mul_rtn_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.mul(JFS_RM_RTN, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.mul RTN a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/mul_rtp_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.mul(JFS_RM_RTP, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.mul RTP a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/mul_rtp_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.mul(JFS_RM_RTP, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.mul RTP a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/mul_rtz_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.mul(JFS_RM_RTZ, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.mul RTZ a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/mul_rtz_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.mul(JFS_RM_RTZ, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.mul RTZ a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/neg_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.neg()\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN (fp.neg a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/neg_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.neg()\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].isNaN()\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.isNaN (fp.neg a))\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/print_fp_const_minus_inf_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cxx\n; RUN: %cxx-rt-syntax %t.cxx\n; RUN: %FileCheck -input-file=%t.cxx %s\n\n; This example is constructed such that the CXXProgramBuilder\n; has to emit the `d` constant. This requires that constant\n; propagation has not run.\n\n(declare-fun c () (_ FloatingPoint 11 53))\n(declare-fun d () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> d = Float<11,53>::getNegativeInfinity()\n(assert (= d (_ -oo 11 53)))\n(assert (not (fp.isNaN (fp.add RNE c d))))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/print_fp_const_minus_zero_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cxx\n; RUN: %cxx-rt-syntax %t.cxx\n; RUN: %FileCheck -input-file=%t.cxx %s\n\n; This example is constructed such that the CXXProgramBuilder\n; has to emit the `d` constant. This requires that constant\n; propagation has not run.\n\n(declare-fun c () (_ FloatingPoint 11 53))\n(declare-fun d () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> d = Float<11,53>::getNegativeZero()\n(assert (= d (_ -zero 11 53)))\n(assert (not (fp.isNaN (fp.add RNE c d))))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/print_fp_const_nan_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cxx\n; RUN: %cxx-rt-syntax %t.cxx\n; RUN: %FileCheck -input-file=%t.cxx %s\n\n; This example is constructed such that the CXXProgramBuilder\n; has to emit the `d` constant. This requires that constant\n; propagation has not run.\n\n(declare-fun c () (_ FloatingPoint 11 53))\n(declare-fun d () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> d = Float<11,53>::getNaN()\n(assert (= d (_ NaN 11 53)))\n(assert (not (fp.isNaN (fp.add RNE c d))))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/print_fp_const_plus_inf_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cxx\n; RUN: %cxx-rt-syntax %t.cxx\n; RUN: %FileCheck -input-file=%t.cxx %s\n\n; This example is constructed such that the CXXProgramBuilder\n; has to emit the `d` constant. This requires that constant\n; propagation has not run.\n\n(declare-fun c () (_ FloatingPoint 11 53))\n(declare-fun d () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> d = Float<11,53>::getPositiveInfinity()\n(assert (= d (_ +oo 11 53)))\n(assert (not (fp.isNaN (fp.add RNE c d))))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/print_fp_const_plus_zero_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cxx\n; RUN: %cxx-rt-syntax %t.cxx\n; RUN: %FileCheck -input-file=%t.cxx %s\n\n; This example is constructed such that the CXXProgramBuilder\n; has to emit the `d` constant. This requires that constant\n; propagation has not run.\n\n(declare-fun c () (_ FloatingPoint 11 53))\n(declare-fun d () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> d = Float<11,53>::getPositiveZero()\n(assert (= d (_ +zero 11 53)))\n(assert (not (fp.isNaN (fp.add RNE c d))))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/rem_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.rem(b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.rem a b) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/rem_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.rem(b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.rem a b) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/round_to_integral_rna_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.roundToIntegral(JFS_RM_RNA)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.roundToIntegral RNA a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/round_to_integral_rna_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.roundToIntegral(JFS_RM_RNA)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.roundToIntegral RNA a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/round_to_integral_rne_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.roundToIntegral(JFS_RM_RNE)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.roundToIntegral RNE a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/round_to_integral_rne_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.roundToIntegral(JFS_RM_RNE)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.roundToIntegral RNE a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/round_to_integral_rtn_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.roundToIntegral(JFS_RM_RTN)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.roundToIntegral RTN a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/round_to_integral_rtn_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.roundToIntegral(JFS_RM_RTN)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.roundToIntegral RTN a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/round_to_integral_rtp_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.roundToIntegral(JFS_RM_RTP)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.roundToIntegral RTP a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/round_to_integral_rtp_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.roundToIntegral(JFS_RM_RTP)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.roundToIntegral RTP a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/round_to_integral_rtz_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.roundToIntegral(JFS_RM_RTZ)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.roundToIntegral RTZ a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/round_to_integral_rtz_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.roundToIntegral(JFS_RM_RTZ)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.roundToIntegral RTZ a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sqrt_rna_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.sqrt(JFS_RM_RNA)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sqrt RNA a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sqrt_rna_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.sqrt(JFS_RM_RNA)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sqrt RNA a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sqrt_rne_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.sqrt(JFS_RM_RNE)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sqrt RNE a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sqrt_rne_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.sqrt(JFS_RM_RNE)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sqrt RNE a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sqrt_rtn_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.sqrt(JFS_RM_RTN)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sqrt RTN a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sqrt_rtn_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.sqrt(JFS_RM_RTN)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sqrt RTN a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sqrt_rtp_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.sqrt(JFS_RM_RTP)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sqrt RTP a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sqrt_rtp_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.sqrt(JFS_RM_RTP)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sqrt RTP a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sqrt_rtz_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.sqrt(JFS_RM_RTZ)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sqrt RTZ a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sqrt_rtz_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.sqrt(JFS_RM_RTZ)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(b)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sqrt RTZ a) b)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sub_rna_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.sub(JFS_RM_RNA, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sub RNA a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sub_rna_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.sub(JFS_RM_RNA, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sub RNA a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sub_rne_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.sub(JFS_RM_RNE, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sub RNE a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sub_rne_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.sub(JFS_RM_RNE, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sub RNE a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sub_rtn_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.sub(JFS_RM_RTN, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sub RTN a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sub_rtn_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.sub(JFS_RM_RTN, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sub RTN a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sub_rtp_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.sub(JFS_RM_RTP, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sub RTP a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sub_rtp_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.sub(JFS_RM_RTP, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sub RTP a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sub_rtz_float32.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n; CHECK: Float<8,24> [[SSA0:[a-z_0-9]+]] = a.sub(JFS_RM_RTZ, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sub RTZ a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/operations/fp/sub_rtz_float64.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () (_ FloatingPoint 11 53))\n(declare-fun b () (_ FloatingPoint 11 53))\n; CHECK: Float<11,53> [[SSA0:[a-z_0-9]+]] = a.sub(JFS_RM_RTZ, b)\n; CHECK: bool [[SSA1:[a-z_0-9]+]] = [[SSA0]].ieeeEquals(a)\n; CHECK-NEXT: if ([[SSA1]]) {}\n(assert\n  (fp.eq (fp.sub RTZ a b) a)\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/quoted_symbol.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun |abcFOO! | () Bool)\n(declare-fun |abcFOO! @| () Bool)\n(assert (or |abcFOO! | |abcFOO! @|))\n; CHECK:  bool abcFOO_ex__ = makeBoolFrom\n; CHECK:  bool abcFOO_ex___at_ = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abcABC0123 () Bool)\n(declare-fun abcABC0124 () Bool)\n(assert (or abcABC0123 abcABC0124))\n; CHECK:  bool abcABC0123 = makeBoolFrom\n; CHECK:  bool abcABC0124 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_ampersand.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc&ABC0123 () Bool)\n(declare-fun abc&&ABC0123 () Bool)\n(assert (or abc&ABC0123 abc&&ABC0123))\n; CHECK:  bool abc_a_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_a__a_ABC0123 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_asterisk.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc*ABC0123 () Bool)\n(declare-fun abc**ABC0123 () Bool)\n(assert (or abc*ABC0123 abc**ABC0123))\n; CHECK:  bool abc_s_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_s__s_ABC0123 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_at.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc@ABC0123 () Bool)\n(declare-fun abc@@ABC0123 () Bool)\n(assert (or abc@ABC0123 abc@@ABC0123))\n; CHECK:  bool abc_at_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_at__at_ABC0123 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_caret.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc^ABC0123 () Bool)\n(declare-fun abc^^ABC0123 () Bool)\n(assert (or abc^ABC0123 abc^^ABC0123))\n; CHECK:  bool abc_c_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_c__c_ABC0123 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_dollar_sign.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc$ABC0123 () Bool)\n(declare-fun abc$$ABC0123 () Bool)\n(assert (or abc$ABC0123 abc$$ABC0123))\n; CHECK:  bool abc_ds_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_ds__ds_ABC0123 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_dot.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc.ABC0123 () Bool)\n(declare-fun abc..ABC0123 () Bool)\n(assert (or abc.ABC0123 abc..ABC0123))\n; CHECK:  bool abc_d_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_d__d_ABC0123 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_equal.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc=ABC0123 () Bool)\n(declare-fun abc==ABC0123 () Bool)\n(assert (or abc=ABC0123 abc==ABC0123))\n; CHECK:  bool abc_e_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_e__e_ABC0123 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_exclaimation_mark.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc!ABC0123 () Bool)\n(declare-fun abc!!ABC0123 () Bool)\n(assert (or abc!ABC0123 abc!!ABC0123))\n; CHECK:  bool abc_ex_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_ex__ex_ABC0123 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_gt.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc>ABC0123 () Bool)\n(declare-fun abc>>ABC0123 () Bool)\n(assert (or abc>ABC0123 abc>>ABC0123))\n; CHECK:  bool abc_gt_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_gt__gt_ABC0123 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_lt.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc<ABC0123 () Bool)\n(declare-fun abc<<ABC0123 () Bool)\n(assert (or abc<ABC0123 abc<<ABC0123))\n; CHECK:  bool abc_lt_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_lt__lt_ABC0123 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_minus.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc-ABC0123 () Bool)\n(declare-fun abc-ABC0124 () Bool)\n(assert (or abc-ABC0123 abc-ABC0124))\n; CHECK:  bool abc_m_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_m_ABC0124 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_minus_clash.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc-ABC0123 () Bool)\n(declare-fun abc_m_ABC0123 () Bool) ; This name deliberately causes a clash\n(declare-fun abc-ABC0123_0 () Bool) ; This name deliberately causes a clash\n(assert (or abc-ABC0123 abc-ABC0123_0 abc_m_ABC0123))\n; CHECK:  bool abc_m_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_m_ABC0123_0 = makeBoolFrom\n; CHECK:  bool abc_m_ABC0123_1 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_percent.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc%ABC0123 () Bool)\n(declare-fun abc%%ABC0123 () Bool)\n(assert (or abc%ABC0123 abc%%ABC0123))\n; CHECK:  bool abc_pc_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_pc__pc_ABC0123 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_plus.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc+ABC0123 () Bool)\n(declare-fun abc++ABC0123 () Bool)\n(assert (or abc+ABC0123 abc++ABC0123))\n; CHECK:  bool abc_p_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_p__p_ABC0123 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_question_foward_slash.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc/ABC0123 () Bool)\n(declare-fun abc//ABC0123 () Bool)\n(assert (or abc/ABC0123 abc//ABC0123))\n; CHECK:  bool abc_fs_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_fs__fs_ABC0123 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_question_mark.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc?ABC0123 () Bool)\n(declare-fun abc??ABC0123 () Bool)\n(assert (or abc?ABC0123 abc??ABC0123))\n; CHECK:  bool abc_q_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_q__q_ABC0123 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/simple_alphanumeric_tilda.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun abc~ABC0123 () Bool)\n(declare-fun abc~~ABC0123 () Bool)\n(assert (or abc~ABC0123 abc~~ABC0123))\n; CHECK:  bool abc_t_ABC0123 = makeBoolFrom\n; CHECK:  bool abc_t__t_ABC0123 = makeBoolFrom\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/symbol_names/stress_test.smt2",
    "content": "; RUN: %jfs-smt2cxx %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n(set-info :smt-lib-version 2.6)\n(set-logic QF_BV)\n(set-info :source |\n\tConstructed by Trevor Hansen to test edge case parsing\n|)\n(set-info :category \"check\")\n(set-info :status sat)\n\n;The SMT-LIB Standard Version 2.0, Release: March 30, 2010\n\n; :notes is a reserved keyword; but not notes without the colon.\n(declare-fun notes () (_ BitVec 4))\n\n;Symbols. A symbol is either a non-empty sequence of letters, digits and the characters\n;~ ! @ $ % ^ & * _ - + = < > . ? / that does not start with a digit, or a sequence of\n;printable ASCII characters, including white spaces, that starts and ends with | and does\n;not otherwise contain | .\n\n; Other more difficult things that are allowed, but seem ridiculous are:\n; Having /n in symbol names.\n; Having symbol names that are functions in other theories: +, /\n\n(declare-fun | | () (_ BitVec 4))\n(declare-fun || () (_ BitVec 4))\n(declare-fun ?v0 () (_ BitVec 4))\n(declare-fun v0 () (_ BitVec 4))\n(declare-fun |v1| () (_ BitVec 4))\n(declare-fun V0 () (_ BitVec 4))\n(declare-fun ~!@$%^&*_-+=><.?/() (_ BitVec 4))\n; We put () inside the ||'s 'cause you can.\n(declare-fun |~!@$%^&*_-+=<>.?/()|() (_ BitVec 4))\n(declare-fun |~!@$%^&*_-+=<>.?/|() (_ BitVec 4))\n(assert (distinct notes || |~!@$%^&*_-+=<>.?/()| ?v0 |v0| v1 V0 ~!@$%^&*_-+=><.?/))\n(assert (not (= v0 V0)))\n(assert (not (= |~!@$%^&*_-+=<>.?/| ~!@$%^&*_-+=><.?/)))\n(assert (not (= || | |)))\n(assert (distinct (distinct || | | )(distinct |~!@$%^&*_-+=<>.?/|  v0)))\n(check-sat)\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/track_num_constraints/track_max_num_solved_fail_fast.smt2",
    "content": "; RUN: %jfs-smt2cxx -branch-encoding=fail-fast -record-max-num-satisfied-constraints %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(assert (or a b))\n(check-sat)\n\n; FIXME: These checks for braces are really fragile.\n; CHECK: uint64_t jfs_max_num_const_sat = 0;\n; CHECK: extern \"C\" void LLVMFuzzerAtExit()\n; CHECK-NEXT: {\n; CHECK-NEXT: jfs_nr_logger_ty logger = jfs_nr_mk_logger_from_env();\n; CHECK-NEXT: jfs_nr_log_uint64(logger,\"jfs_max_num_const_sat\",jfs_max_num_const_sat);\n; CHECK-NEXT: jfs_nr_del_logger(logger);\n; CHECK-NEXT: }\n\n; CHECK: extern \"C\" int LLVMFuzzerTestOneInput\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a || b;\n; CHECK-NEXT: if ([[SSA0]])\n; CHECK-NEXT: {\n; CHECK-NEXT: ++jfs_num_const_sat;\n; CHECK-NEXT: if (jfs_max_num_const_sat < jfs_num_const_sat)\n; CHECK-NEXT: {\n; CHECK-NEXT: jfs_max_num_const_sat = jfs_num_const_sat;\n; CHECK-NEXT: }\n; CHECK-NEXT: }\n\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/track_num_constraints/track_max_num_solved_try_all.smt2",
    "content": "; RUN: %jfs-smt2cxx -branch-encoding=try-all -record-max-num-satisfied-constraints %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(assert (or a b))\n(check-sat)\n\n; FIXME: These checks for braces are really fragile.\n; CHECK: uint64_t jfs_max_num_const_sat = 0;\n; CHECK: extern \"C\" void LLVMFuzzerAtExit()\n; CHECK-NEXT: {\n; CHECK-NEXT: jfs_nr_logger_ty logger = jfs_nr_mk_logger_from_env();\n; CHECK-NEXT: jfs_nr_log_uint64(logger,\"jfs_max_num_const_sat\",jfs_max_num_const_sat);\n; CHECK-NEXT: jfs_nr_del_logger(logger);\n; CHECK-NEXT: }\n\n; CHECK: extern \"C\" int LLVMFuzzerTestOneInput\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a || b;\n; CHECK-NEXT: if ([[SSA0]])\n; CHECK-NEXT: {\n; CHECK-NEXT: ++jfs_num_const_sat;\n; CHECK-NEXT: }\n\n; CHECK-NEXT: if (jfs_max_num_const_sat < jfs_num_const_sat)\n; CHECK-NEXT: {\n; CHECK-NEXT: jfs_max_num_const_sat = jfs_num_const_sat;\n; CHECK-NEXT: }\n\n; CHECK-NEXT: if (jfs_num_const_sat == 1)\n; CHECK-NEXT: {\n; CHECK-NEXT: // Fuzzing target\n; CHECK-NEXT: abort();\n; CHECK-NEXT: }\n; CHECK-NEXT: else {\n; CHECK-NEXT: return 0;\n; CHECK-NEXT: }\n\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/track_num_constraints/track_max_num_solved_try_all_imncsf.smt2",
    "content": "; RUN: %jfs-smt2cxx -branch-encoding=try-all-imncsf -record-max-num-satisfied-constraints %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(assert (or a b))\n(check-sat)\n\n; FIXME: These checks for braces are really fragile.\n; CHECK: uint64_t jfs_max_num_const_sat = 0;\n; CHECK: extern \"C\" void LLVMFuzzerAtExit()\n; CHECK-NEXT: {\n; CHECK-NEXT: jfs_nr_logger_ty logger = jfs_nr_mk_logger_from_env();\n; CHECK-NEXT: jfs_nr_log_uint64(logger,\"jfs_max_num_const_sat\",jfs_max_num_const_sat);\n; CHECK-NEXT: jfs_nr_del_logger(logger);\n; CHECK-NEXT: }\n\n; CHECK: extern \"C\" int LLVMFuzzerTestOneInput\n; CHECK: bool [[SSA0:[a-z_0-9]+]] = a || b;\n; CHECK-NEXT: if ([[SSA0]])\n; CHECK-NEXT: {\n; CHECK-NEXT: ++jfs_num_const_sat;\n; CHECK-NEXT: }\n\n; CHECK-NEXT: if (jfs_max_num_const_sat < jfs_num_const_sat)\n; CHECK-NEXT: {\n; CHECK-NEXT: jfs_max_num_const_sat = jfs_num_const_sat;\n; CHECK-NEXT: }\n\n; NOTE: It's important that the `jfs_max_num_const_sat` update above happen before the custom\n; counter code below.\n; CHECK-NEXT: if (jfs_max_num_const_sat > 0)\n; CHECK-NEXT: {\n; CHECK-NEXT: jfs_libfuzzer_custom_counter[jfs_max_num_const_sat -1] = 1;\n; CHECK-NEXT: }\n\n\n; CHECK-NEXT: if (jfs_num_const_sat == 1)\n; CHECK-NEXT: {\n; CHECK-NEXT: // Fuzzing target\n; CHECK-NEXT: abort();\n; CHECK-NEXT: }\n; CHECK-NEXT: else {\n; CHECK-NEXT: return 0;\n; CHECK-NEXT: }\n\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/track_num_inputs/track_num_inputs.smt2",
    "content": "; RUN: %jfs-smt2cxx -record-num-inputs %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(assert (or a b))\n(check-sat)\n\n; FIXME: These checks for braces are really fragile.\n; CHECK: uint64_t jfs_num_inputs = 0;\n; CHECK: extern \"C\" void LLVMFuzzerAtExit()\n; CHECK-NEXT: {\n; CHECK-NEXT: jfs_nr_logger_ty logger = jfs_nr_mk_logger_from_env();\n; CHECK-NEXT: jfs_nr_log_uint64(logger,\"jfs_num_inputs\",jfs_num_inputs);\n; CHECK-NEXT: jfs_nr_del_logger(logger);\n; CHECK-NEXT: }\n\n; CHECK: extern \"C\" int LLVMFuzzerTestOneInput\n; CHECK-NEXT: {\n; CHECK-NEXT: if (size != 1)\n; CHECK-NEXT: {\n; CHECK-NEXT: jfs_warning(\"Wrong sized input tried.\\n\");\n; CHECK-NEXT: return 0;\n; CHECK-NEXT: }\n; CHECK-NEXT: ++jfs_num_inputs;\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/CXXProgramBuilder/track_num_inputs/track_num_wrong_size_inputs.smt2",
    "content": "; RUN: %jfs-smt2cxx -record-num-wrong-sized-inputs %s > %t.cpp\n; RUN: %cxx-rt-syntax %t.cpp\n; RUN: %FileCheck -input-file=%t.cpp %s\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(assert (or a b))\n(check-sat)\n\n; FIXME: These checks for braces are really fragile.\n; CHECK: uint64_t jfs_num_wrong_size_inputs = 0;\n; CHECK: extern \"C\" void LLVMFuzzerAtExit()\n; CHECK-NEXT: {\n; CHECK-NEXT: jfs_nr_logger_ty logger = jfs_nr_mk_logger_from_env();\n; CHECK-NEXT: jfs_nr_log_uint64(logger,\"jfs_num_wrong_size_inputs\",jfs_num_wrong_size_inputs);\n; CHECK-NEXT: jfs_nr_del_logger(logger);\n; CHECK-NEXT: }\n\n; CHECK: extern \"C\" int LLVMFuzzerTestOneInput\n; CHECK-NEXT: {\n; CHECK-NEXT: if (size != 1)\n; CHECK-NEXT: {\n; CHECK-NEXT: ++jfs_num_wrong_size_inputs;\n; CHECK-NEXT: jfs_warning(\"Wrong sized input tried.\\n\");\n; CHECK-NEXT: return 0;\n; CHECK-NEXT: }\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n\n# This directory uses a customized test format\nconfigure_file(lit.local.cfg\n  lit.local.cfg\n  COPYONLY\n)\nconfigure_file(test_format.py\n  test_format.py\n  COPYONLY\n)"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/branch_encodings/try_all_imncsf.smt2",
    "content": "; NOTE: try-all-imncsf uses an experimental LibFuzzer feature (custom counters)\n; which currently only works on Linux.\n; REQUIRES: linux && LibFuzzer\n; RUN: rm -rf %t-output-dir\n; RUN: %jfs -branch-encoding=try-all-imncsf -cxx -disable-equality-extraction -disable-standard-passes -keep-output-dir -output-dir=%t-output-dir %s | %FileCheck %s\n\n; RUN: %FileCheck -check-prefix=CHECK-LIBFUZZER -input-file=%t-output-dir/libfuzzer.stderr.txt %s\n\n; NOTE: This output is not part of upstream LibFuzzer.\n; CHECK-LIBFUZZER: INFO: 16 Extra Counters\n\n\n(set-logic QF_BV)\n(set-info :source |\nBit-vector benchmarks from Dawson Engler's tool contributed by Vijay Ganesh\n(vganesh@stanford.edu).  Translated into SMT-LIB format by Clark Barrett using\nCVC3.\n\n|)\n(set-info :smt-lib-version 2.0)\n(set-info :category \"industrial\")\n(set-info :status sat)\n(declare-fun buffer_0 () (_ BitVec 8))\n(declare-fun buffer_1 () (_ BitVec 8))\n(declare-fun buffer_2 () (_ BitVec 8))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv43 32))))\n(assert (= ((_ sign_extend 24) buffer_0) (_ bv37 32)))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv37 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv45 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv48 32))))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_1)))\n(assert (bvsle ((_ sign_extend 24) buffer_1) (_ bv57 32)))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_2)))\n(assert (not (bvsle ((_ sign_extend 24) buffer_2) (_ bv57 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv115 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv100 32))))\n(assert (= ((_ sign_extend 24) buffer_2) (_ bv120 32)))\n(assert (not (bvsle (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (_ bv7 32))))\n(assert (not (bvslt (_ bv0 32) (bvadd (bvadd (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (bvneg (_ bv7 32))) (bvneg (_ bv1 32))))))\n(check-sat)\n; CHECK: {{^sat$}}\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/buffer_element_alignment/bv_bool_bv_bool_float.smt2",
    "content": "; RUN: %jfs -byte-aligned-buffer-elements=false %s | %FileCheck %s\n; RUN: %jfs -byte-aligned-buffer-elements %s | %FileCheck %s\n\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(declare-fun c () Bool)\n(declare-fun d () (_ BitVec 2))\n(declare-fun e () (_ BitVec 19))\n(declare-fun f () Float32)\n(assert (or a b))\n(assert (bvult d #b11))\n(assert (bvult e #b1010101010101001011))\n(assert (fp.eq f f))\n(assert (or b c))\n(check-sat)\n; CHECK: {{^sat}}\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/lit.local.cfg",
    "content": "import site\nsite.addsitedir(os.path.dirname(__file__))\nimport test_format\n\n# Override test format for Fuzz directory\n# This specialized test format runs each test multiple times: once for each fuzzing library\nconfig.test_format = test_format.JFSFuzzTestFormat()\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/models/equality_extraction/all_assignments.smt2",
    "content": "; RUN: %jfs -get-model %s | %FileCheck %s\n(declare-const a Float32)\n(declare-const b Float32)\n(declare-const c Float32)\n(declare-const d Float32)\n(declare-const e Float32)\n(declare-const f Float32)\n(declare-const g Float32)\n(assert (= a (fp #b0 #x7f #b00000000000000000000000)))\n(assert (= b (fp #b1 #x7f #b00000000000000000000000)))\n(assert (= c (_ NaN 8 24)))\n(assert (= d (_ +zero 8 24)))\n(assert (= e (_ -zero 8 24)))\n(assert (= f (_ +oo 8 24)))\n(assert (= g (_ -oo 8 24)))\n(check-sat)\n; CHECK: {{^sat}}\n; CHECK: (\n; CHECK-NEXT: (define-fun a () (_ FloatingPoint 8 24) (fp #b0 #x7f #b00000000000000000000000))\n; CHECK-NEXT:  (define-fun b () (_ FloatingPoint 8 24) (fp #b1 #x7f #b00000000000000000000000))\n; CHECK-NEXT:  (define-fun c () (_ FloatingPoint 8 24) (_ NaN 8 24))\n; CHECK-NEXT:  (define-fun d () (_ FloatingPoint 8 24) (_ +zero 8 24))\n; CHECK-NEXT:  (define-fun e () (_ FloatingPoint 8 24) (_ -zero 8 24))\n; CHECK-NEXT:  (define-fun f () (_ FloatingPoint 8 24) (_ +oo 8 24))\n; CHECK-NEXT:  (define-fun g () (_ FloatingPoint 8 24) (_ -oo 8 24))\n; CHECK-NEXT: )\n\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/models/equality_extraction/empty.smt2",
    "content": "; RUN: %jfs -get-model %s | %FileCheck %s\n; FIXME: jfs doesn't actually use this option.\n(set-option :produce-models true)\n(check-sat)\n; FIXME: The parser fails on (get-model) so comment out for now.\n;(get-model)\n; CHECK: {{^sat}}\n; Empty model\n; CHECK-NEXT: ()\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/models/equality_extraction/equalities_with_model_from_fuzzer.smt2",
    "content": "; RUN: %jfs -cxx -get-model -validate-model %s | %FileCheck %s\n; FIXME: Make LibPureRandomFuzzer work on this example?\n; REQUIRES: LibFuzzer\n(declare-fun a () (_ BitVec 32))\n(declare-fun b () (_ BitVec 32))\n(declare-fun c () (_ BitVec 32))\n; Equality extraction should determine on model conversion that\n; the no assignment is provided and that it should provide its own\n; in order to enforce the equalities.\n(assert (= a b))\n(assert (= b c))\n; These two constraints imply that value of c must be (_ bv1 32)\n(assert (bvult c (_ bv2 32)))\n(assert (bvugt c (_ bv0 32)))\n(check-sat)\n; CHECK: {{^sat}}\n; CHECK-NEXT: (\n; CHECK-NEXT: (define-fun a () (_ BitVec 32) #x00000001)\n; CHECK-NEXT: (define-fun b () (_ BitVec 32) #x00000001)\n; CHECK-NEXT: (define-fun c () (_ BitVec 32) #x00000001)\n; CHECK-NEXT: )\n\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/models/equality_extraction/trivial_equalities.smt2",
    "content": "; RUN: %jfs -cxx -get-model %s | %FileCheck %s\n(declare-fun a () (_ BitVec 32))\n(declare-fun b () (_ BitVec 32))\n(declare-fun c () (_ BitVec 32))\n; Equality extraction should determine on model conversion that\n; the no assignment is provided and that it should provide its own\n; in order to enforce the equalities.\n(assert (= a b))\n(assert (= b c))\n(check-sat)\n; CHECK: {{^sat}}\n; CHECK-NEXT: (\n; CHECK-NEXT: (define-fun a () (_ BitVec 32) #x00000000)\n; CHECK-NEXT: (define-fun b () (_ BitVec 32) #x00000000)\n; CHECK-NEXT: (define-fun c () (_ BitVec 32) #x00000000)\n; CHECK-NEXT: )\n\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/models/simple/3_bv_const.smt2",
    "content": "; RUN: rm -rf %t-output-dir\n; RUN: %jfs %jfs_no_opt_options -get-model -debug-save-model -keep-output-dir -output-dir=%t-output-dir %s | %FileCheck %s\n(declare-const a (_ BitVec 8))\n(declare-const b (_ BitVec 8))\n(declare-const c (_ BitVec 8))\n(assert (= a #xff))\n(assert (= b #x0a))\n(assert (= c #x00))\n(check-sat)\n; CHECK: {{^sat}}\n; CHECK: (\n; CHECK-NEXT: (define-fun a () (_ BitVec 8) #xff)\n; CHECK-NEXT: (define-fun b () (_ BitVec 8) #x0a)\n; CHECK-NEXT: (define-fun c () (_ BitVec 8) #x00)\n; CHECK-NEXT: )\n\n; RUN: base64 -i %t-output-dir/model-output | %FileCheck -check-prefix=CHECK-MODEL %s\n; CHECK-MODEL: /woA\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/models/simple/3_true.smt2",
    "content": "; RUN: rm -rf %t-output-dir\n; RUN: %jfs %jfs_no_opt_options -get-model -debug-save-model -keep-output-dir -output-dir=%t-output-dir %s | %FileCheck %s\n(declare-const a Bool)\n(declare-const b Bool)\n(declare-const c Bool)\n(assert (and a b c))\n(check-sat)\n; CHECK: {{^sat}}\n; CHECK-NEXT: (\n; CHECK-NEXT: (define-fun a () Bool true)\n; CHECK-NEXT: (define-fun b () Bool true)\n; CHECK-NEXT: (define-fun c () Bool true)\n; CHECK-NEXT: )\n\n; RUN: base64 -i %t-output-dir/model-output | %FileCheck -check-prefix=CHECK-MODEL %s\n; CHECK-MODEL: Bw==\n; NOTE: This differs from the loaded fuzzer artifact (0xFF) because it only\n; saves the bits needed to represent the 3 bools (0x07).\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/models/simple/README.md",
    "content": "These tests are intended to bypass JFS's optimisation passes to perform\nbasic testing of loading models from a LibFuzzer input.\n\nThis rather crude and we need to come up with a better way of testing\nthis component of JFS.\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/models/simple/empty.smt2",
    "content": "; RUN: %jfs %jfs_no_opt_options -get-model %s | %FileCheck %s\n; FIXME: jfs doesn't actually use this option.\n(set-option :produce-models true)\n(check-sat)\n; FIXME: The parser fails on (get-model) so comment out for now.\n;(get-model)\n; CHECK: {{^sat}}\n; Empty model\n; CHECK-NEXT: ()\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/models/simple/float_nan.smt2",
    "content": "; RUN: rm -rf %t-output-dir\n; RUN: %jfs %jfs_no_opt_options -get-model -debug-save-model -keep-output-dir -output-dir=%t-output-dir %s | %FileCheck %s\n(declare-const a Float32)\n(assert (= a (_ NaN 8 24)))\n(check-sat)\n; CHECK: {{^sat}}\n; CHECK-NEXT: (\n; CHECK-NEXT: (define-fun a () (_ FloatingPoint 8 24) (_ NaN 8 24))\n; CHECK-NEXT: )\n\n; RUN: base64 -i %t-output-dir/model-output | %FileCheck -check-prefix=CHECK-MODEL %s\n; CHECK-MODEL: AADAfw==\n; NOTE: This differs from the loaded fuzzer artifact (0xFFFFFFFF), which is one\n; of many possible NaN representations.  When saving, we use a canonical NaN\n; representation (0x7FC00000).\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/models/simple/float_neg_inf.smt2",
    "content": "; RUN: rm -rf %t-output-dir\n; RUN: %jfs %jfs_no_opt_options -seed=1 -get-model -debug-save-model -keep-output-dir -output-dir=%t-output-dir %s | %FileCheck %s\n; FIXME: Make LibPureRandomFuzzer work on this example?\n; REQUIRES: LibFuzzer\n(declare-const a Float32)\n(assert (= a (_ -oo 8 24)))\n(check-sat)\n; CHECK: {{^sat}}\n; CHECK-NEXT: (\n; CHECK-NEXT: (define-fun a () (_ FloatingPoint 8 24) (_ -oo 8 24))\n; CHECK-NEXT: )\n\n; RUN: base64 -i %t-output-dir/model-output | %FileCheck -check-prefix=CHECK-MODEL %s\n; CHECK-MODEL: AACA/w==\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/models/simple/float_neg_one.smt2",
    "content": "; RUN: rm -rf %t-output-dir\n; RUN: %jfs %jfs_no_opt_options -seed=1 -get-model -debug-save-model -keep-output-dir -output-dir=%t-output-dir %s | %FileCheck %s\n; FIXME: Make LibPureRandomFuzzer work on this example?\n; REQUIRES: LibFuzzer\n(declare-const a Float32)\n(assert (= a (fp #b1 #x7f #b00000000000000000000000)))\n(check-sat)\n; CHECK: {{^sat}}\n; CHECK-NEXT: (\n; CHECK-NEXT: (define-fun a () (_ FloatingPoint 8 24) (fp #b1 #x7f #b00000000000000000000000))\n; CHECK-NEXT: )\n\n; RUN: base64 -i %t-output-dir/model-output | %FileCheck -check-prefix=CHECK-MODEL %s\n; CHECK-MODEL: AACAvw==\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/models/simple/float_neg_zero.smt2",
    "content": "; RUN: rm -rf %t-output-dir\n; RUN: %jfs %jfs_no_opt_options -seed=1 -get-model -debug-save-model -keep-output-dir -output-dir=%t-output-dir %s | %FileCheck %s\n; FIXME: Make LibPureRandomFuzzer work on this example?\n; REQUIRES: LibFuzzer\n(declare-const a Float32)\n(assert (= a (_ -zero 8 24)))\n(check-sat)\n; CHECK: {{^sat}}\n; CHECK-NEXT: (\n; CHECK-NEXT: (define-fun a () (_ FloatingPoint 8 24) (_ -zero 8 24))\n; CHECK-NEXT: )\n\n; RUN: base64 -i %t-output-dir/model-output | %FileCheck -check-prefix=CHECK-MODEL %s\n; CHECK-MODEL: AAAAgA==\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/models/simple/float_pos_inf.smt2",
    "content": "; RUN: rm -rf %t-output-dir\n; RUN: %jfs %jfs_no_opt_options -seed=1 -get-model -debug-save-model -keep-output-dir -output-dir=%t-output-dir %s | %FileCheck %s\n; FIXME: Make LibPureRandomFuzzer work on this example?\n; REQUIRES: LibFuzzer\n(declare-const a Float32)\n(assert (= a (_ +oo 8 24)))\n(check-sat)\n; CHECK: {{^sat}}\n; CHECK-NEXT: (\n; CHECK-NEXT: (define-fun a () (_ FloatingPoint 8 24) (_ +oo 8 24))\n; CHECK-NEXT: )\n\n; RUN: base64 -i %t-output-dir/model-output | %FileCheck -check-prefix=CHECK-MODEL %s\n; CHECK-MODEL: AACAfw==\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/models/simple/float_pos_one.smt2",
    "content": "; RUN: rm -rf %t-output-dir\n; RUN: %jfs %jfs_no_opt_options -seed=1 -get-model -debug-save-model -keep-output-dir -output-dir=%t-output-dir %s | %FileCheck %s\n; FIXME: Make LibPureRandomFuzzer work on this example?\n; REQUIRES: LibFuzzer\n(declare-const a Float32)\n(assert (= a (fp #b0 #x7f #b00000000000000000000000)))\n(check-sat)\n; CHECK: {{^sat}}\n; CHECK-NEXT: (\n; CHECK-NEXT: (define-fun a () (_ FloatingPoint 8 24) (fp #b0 #x7f #b00000000000000000000000))\n; CHECK-NEXT: )\n\n; RUN: base64 -i %t-output-dir/model-output | %FileCheck -check-prefix=CHECK-MODEL %s\n; CHECK-MODEL: AACAPw==\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/models/simple/float_pos_zero.smt2",
    "content": "; RUN: rm -rf %t-output-dir\n; RUN: %jfs %jfs_no_opt_options -seed=1 -get-model -debug-save-model -keep-output-dir -output-dir=%t-output-dir %s | %FileCheck %s\n; FIXME: Make LibPureRandomFuzzer work on this example?\n; REQUIRES: LibFuzzer\n(declare-const a Float32)\n(assert (= a (_ +zero 8 24)))\n(check-sat)\n; CHECK: {{^sat}}\n; CHECK-NEXT: (\n; CHECK-NEXT: (define-fun a () (_ FloatingPoint 8 24) (_ +zero 8 24))\n; CHECK-NEXT: )\n\n; RUN: base64 -i %t-output-dir/model-output | %FileCheck -check-prefix=CHECK-MODEL %s\n; CHECK-MODEL: AAAAAA==\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/runtimes/a629test0052.smt2",
    "content": "; This test just checks that the different flags can be used to change the runtime\n; NOTE: We currently only generate the the runtimes that enable one or more of\n; runtime asserts, ASan, or UBSan with coverage instrumentation included, so\n; this means they require LibFuzzer.\n; REQUIRES: LibFuzzer\n; FIXME: we don't actually check the right runtime gets used.\n; RUN: %jfs -cxx %s | %FileCheck %s\n; RUN: %jfs -cxx -runtime-asserts %s | %FileCheck %s\n; RUN: %jfs -cxx -asan -runtime-asserts %s | %FileCheck %s\n; RUN: %jfs -cxx -ubsan -runtime-asserts %s | %FileCheck %s\n; RUN: %jfs -cxx -asan -ubsan -runtime-asserts %s | %FileCheck %s\n(set-logic QF_BV)\n(set-info :source |\nBit-vector benchmarks from Dawson Engler's tool contributed by Vijay Ganesh\n(vganesh@stanford.edu).  Translated into SMT-LIB format by Clark Barrett using\nCVC3.\n\n|)\n(set-info :smt-lib-version 2.0)\n(set-info :category \"industrial\")\n(set-info :status sat)\n(declare-fun buffer_0 () (_ BitVec 8))\n(declare-fun buffer_1 () (_ BitVec 8))\n(declare-fun buffer_2 () (_ BitVec 8))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv43 32))))\n(assert (= ((_ sign_extend 24) buffer_0) (_ bv37 32)))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv37 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv45 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv48 32))))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_1)))\n(assert (bvsle ((_ sign_extend 24) buffer_1) (_ bv57 32)))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_2)))\n(assert (not (bvsle ((_ sign_extend 24) buffer_2) (_ bv57 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv115 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv100 32))))\n(assert (= ((_ sign_extend 24) buffer_2) (_ bv120 32)))\n(assert (not (bvsle (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (_ bv7 32))))\n(assert (not (bvslt (_ bv0 32) (bvadd (bvadd (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (bvneg (_ bv7 32))) (bvneg (_ bv1 32))))))\n(check-sat)\n; CHECK: {{^sat$}}\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/sat/2017-09-02-float-constant-regression.smt2",
    "content": "; NOTE: LibPureRandomFuzzer can't reach the target in a reasonable time.\n; XFAIL: LibPureRandomFuzzer\n; RUN: %jfs -cxx -max-time=8 %s | %FileCheck %s\n(declare-fun a () (_ FloatingPoint 8 24))\n(declare-fun b () (_ FloatingPoint 8 24))\n(assert (fp.eq a (fp #b0 #x86 #b00000000000000000000000)))\n(assert (fp.eq b (fp #b0 #x86 #b00000000000000000000001)))\n(check-sat)\n; CHECK: {{^sat$}}\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/sat/a629test0052.smt2",
    "content": "; RUN: %jfs -branch-encoding=fail-fast -cxx %s | %FileCheck %s\n; RUN: %jfs -branch-encoding=try-all -cxx %s | %FileCheck %s\n(set-logic QF_BV)\n(set-info :source |\nBit-vector benchmarks from Dawson Engler's tool contributed by Vijay Ganesh\n(vganesh@stanford.edu).  Translated into SMT-LIB format by Clark Barrett using\nCVC3.\n\n|)\n(set-info :smt-lib-version 2.0)\n(set-info :category \"industrial\")\n(set-info :status sat)\n(declare-fun buffer_0 () (_ BitVec 8))\n(declare-fun buffer_1 () (_ BitVec 8))\n(declare-fun buffer_2 () (_ BitVec 8))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv43 32))))\n(assert (= ((_ sign_extend 24) buffer_0) (_ bv37 32)))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv37 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv45 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv48 32))))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_1)))\n(assert (bvsle ((_ sign_extend 24) buffer_1) (_ bv57 32)))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_2)))\n(assert (not (bvsle ((_ sign_extend 24) buffer_2) (_ bv57 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv115 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv100 32))))\n(assert (= ((_ sign_extend 24) buffer_2) (_ bv120 32)))\n(assert (not (bvsle (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (_ bv7 32))))\n(assert (not (bvslt (_ bv0 32) (bvadd (bvadd (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (bvneg (_ bv7 32))) (bvneg (_ bv1 32))))))\n(check-sat)\n; CHECK: {{^sat$}}\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/sat/max-has-solution-12341.smt2",
    "content": "; This benchmark causes problems because Z3's simplifier fails to\n; constant fold the values. This required special handling of this\n; case when invoking LibFuzzer.\n; See https://github.com/Z3Prover/z3/issues/1242\n\n; RUN: %jfs -cxx %s | %FileCheck %s\n\n(set-info :smt-lib-version 2.6)\n(set-info :category \"crafted\")\n(set-info :source |Christoph M. Wintersteiger (cwinter@microsoft.com). Randomly generated floating-point testcases.|)\n; Rounding mode: to negative\n; Precision: double (11/53)\n; X = 1.6908442241812353667995694195269607007503509521484375p-775 {+ 3111285790593671 -775 (8.50858e-234)}\n; Y = -1.25849312345896446885262776049785315990447998046875p-663 {- 1164149534487628 -663 (-3.28824e-200)}\n; 1.6908442241812353667995694195269607007503509521484375p-775 M -1.25849312345896446885262776049785315990447998046875p-663 == 1.6908442241812353667995694195269607007503509521484375p-775\n; [HW: 1.6908442241812353667995694195269607007503509521484375p-775] \n\n; mpf : + 3111285790593671 -775\n; mpfd: + 3111285790593671 -775 (8.50858e-234) class: Pos. norm. non-zero\n; hwf : + 3111285790593671 -775 (8.50858e-234) class: Pos. norm. non-zero\n\n(set-logic QF_FP)\n(set-info :status sat)\n(define-sort FPN () (_ FloatingPoint 11 53))\n(declare-fun x () FPN)\n(declare-fun y () FPN)\n(declare-fun r () FPN)\n(assert (= x (fp #b0 #b00011111000 #b1011000011011011001010101100010101111101001010000111)))\n(assert (= y (fp #b1 #b00101101000 #b0100001000101100100110101111011101111111010001001100)))\n(assert (= r (fp #b0 #b00011111000 #b1011000011011011001010101100010101111101001010000111)))\n(assert (= (fp.max x y) r))\n(check-sat)\n; CHECK: {{^sat$}}\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/sat/min-has-solution-1235.smt2",
    "content": "; This benchmark causes problems because Z3's simplifier fails to\n; constant fold the values. This required special handling of this\n; case when invoking LibFuzzer.\n; See https://github.com/Z3Prover/z3/issues/1242\n\n; RUN: %jfs -cxx %s | %FileCheck %s\n\n(set-info :smt-lib-version 2.6)\n(set-info :category \"crafted\")\n(set-info :source |Christoph M. Wintersteiger (cwinter@microsoft.com). Randomly generated floating-point testcases.|)\n; Rounding mode: to zero\n; Precision: double (11/53)\n; X = 1.24692151349674151816770972800441086292266845703125p-850 {+ 1112035636173684 -850 (1.6609e-256)}\n; Y = -1.7185126679306905739252897546975873410701751708984375p-150 {- 3235893383553639 -150 (-1.20407e-045)}\n; 1.24692151349674151816770972800441086292266845703125p-850 m -1.7185126679306905739252897546975873410701751708984375p-150 == -1.7185126679306905739252897546975873410701751708984375p-150\n; [HW: -1.7185126679306905739252897546975873410701751708984375p-150] \n\n; mpf : - 3235893383553639 -150\n; mpfd: - 3235893383553639 -150 (-1.20407e-045) class: Neg. norm. non-zero\n; hwf : - 3235893383553639 -150 (-1.20407e-045) class: Neg. norm. non-zero\n\n(set-logic QF_FP)\n(set-info :status sat)\n(define-sort FPN () (_ FloatingPoint 11 53))\n(declare-fun x () FPN)\n(declare-fun y () FPN)\n(declare-fun r () FPN)\n(assert (= x (fp #b0 #b00010101101 #b0011111100110110001111111001000100100101101101110100)))\n(assert (= y (fp #b1 #b01101101001 #b1011011111110000011100100011101010000110001001100111)))\n(assert (= r (fp #b1 #b01101101001 #b1011011111110000011100100011101010000110001001100111)))\n(assert (= (fp.min x y) r))\n; CHECK: {{^sat$}}\n(check-sat)\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/sat/simple_bool.smt2",
    "content": "; RUN: %jfs -cxx %s | %FileCheck %s\n(declare-fun buffer_0 () Bool)\n(declare-fun buffer_1 () Bool)\n(declare-fun buffer_2 () Bool)\n(assert (or buffer_0 (or buffer_1 buffer_2)))\n(check-sat)\n; CHECK: {{^sat$}}\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/sat/simplifer_makes_consts.smt2",
    "content": "; RUN: %jfs -cxx %s | %FileCheck %s\n(declare-fun a () (_ FloatingPoint 11 53))\n; FIXME: We need to figure out a way to write the test better.\n; It seems that Z3's simplifier will fold Z3_OP_FPA_TO_FP operations\n; into Z3_OP_FPA_NUM when all three args are constant. For some reason\n; Z3's parser doesn't fold this at parse time.\n(assert (fp.lt (fp #b0 #b10000000000 #x0000000000000) a))\n; CHECK: {{^sat$}}\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/stats/can_write_to_stdout.smt2",
    "content": "; RUN: rm -f %t.yml\n; Check that writing to stdout works without error\n; RUN: %jfs -cxx -stats-file=- %s\n(set-logic QF_BV)\n(set-info :source |\nBit-vector benchmarks from Dawson Engler's tool contributed by Vijay Ganesh\n(vganesh@stanford.edu).  Translated into SMT-LIB format by Clark Barrett using\nCVC3.\n\n|)\n(set-info :smt-lib-version 2.0)\n(set-info :category \"industrial\")\n(set-info :status sat)\n(declare-fun buffer_0 () (_ BitVec 8))\n(declare-fun buffer_1 () (_ BitVec 8))\n(declare-fun buffer_2 () (_ BitVec 8))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv43 32))))\n(assert (= ((_ sign_extend 24) buffer_0) (_ bv37 32)))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv37 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv45 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv48 32))))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_1)))\n(assert (bvsle ((_ sign_extend 24) buffer_1) (_ bv57 32)))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_2)))\n(assert (not (bvsle ((_ sign_extend 24) buffer_2) (_ bv57 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv115 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv100 32))))\n(assert (= ((_ sign_extend 24) buffer_2) (_ bv120 32)))\n(assert (not (bvsle (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (_ bv7 32))))\n(assert (not (bvslt (_ bv0 32) (bvadd (bvadd (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (bvneg (_ bv7 32))) (bvneg (_ bv1 32))))))\n(check-sat)\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/stats/valid_yaml.smt2",
    "content": "; RUN: rm -f %t.yml\n; RUN: %jfs -cxx -stats-file=%t.yml %s | %FileCheck %s\n; RUN: %yaml-syntax-check %t.yml\n(set-logic QF_BV)\n(set-info :source |\nBit-vector benchmarks from Dawson Engler's tool contributed by Vijay Ganesh\n(vganesh@stanford.edu).  Translated into SMT-LIB format by Clark Barrett using\nCVC3.\n\n|)\n(set-info :smt-lib-version 2.0)\n(set-info :category \"industrial\")\n(set-info :status sat)\n(declare-fun buffer_0 () (_ BitVec 8))\n(declare-fun buffer_1 () (_ BitVec 8))\n(declare-fun buffer_2 () (_ BitVec 8))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv43 32))))\n(assert (= ((_ sign_extend 24) buffer_0) (_ bv37 32)))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv37 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv45 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv48 32))))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_1)))\n(assert (bvsle ((_ sign_extend 24) buffer_1) (_ bv57 32)))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_2)))\n(assert (not (bvsle ((_ sign_extend 24) buffer_2) (_ bv57 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv115 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv100 32))))\n(assert (= ((_ sign_extend 24) buffer_2) (_ bv120 32)))\n(assert (not (bvsle (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (_ bv7 32))))\n(assert (not (bvslt (_ bv0 32) (bvadd (bvadd (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (bvneg (_ bv7 32))) (bvneg (_ bv1 32))))))\n(check-sat)\n; CHECK: {{^sat$}}\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/test_format.py",
    "content": "import copy\nimport os\n\nimport lit.formats\nimport lit.formats.base\nimport lit.Test\n\nclass JFSFuzzTestFormat(lit.formats.ShTest):\n  \"\"\"\n  A specialized test format that runs each test multiple times: once for each fuzzing library\n  \"\"\"\n  def getTestsInDirectory(self, testSuite, path_in_suite, litConfig, localConfig):\n    source_path = testSuite.getSourcePath(path_in_suite)\n    for filename in os.listdir(source_path):\n      # Ignore dot files and excluded tests.\n      if (filename.startswith('.') or filename in localConfig.excludes):\n        continue\n\n      filepath = os.path.join(source_path, filename)\n      if os.path.isdir(filepath):\n        continue\n\n      base,ext = os.path.splitext(filename)\n      if not ext in localConfig.suffixes:\n        continue\n\n      # Run test with LibFuzzer\n      config = copy.deepcopy(localConfig)\n      config.available_features.add('LibFuzzer')\n      yield JFSFuzzTest(testSuite, path_in_suite + (filename,), config, 'LibFuzzer')\n      # Run test with LibPureRandomFuzzer\n      config = copy.deepcopy(localConfig)\n      for n, sub in enumerate(config.substitutions):\n        if sub[0] == '%jfs':\n          config.substitutions[n] = (sub[0], sub[1] + ' -libfuzzer-pure-random')\n      config.available_features.add('LibPureRandomFuzzer')\n      yield JFSFuzzTest(testSuite, path_in_suite + (filename,), config, 'LibPureRandomFuzzer')\n\nclass JFSFuzzTest(lit.Test.Test):\n  \"\"\"\n  Extends the basic lit Test class to add a descriptive label to distinguish different variants of\n  the same test file.\n  \"\"\"\n  def __init__(self, suite, path_in_suite, config, label = None):\n    lit.Test.Test.__init__(self, suite, path_in_suite, config)\n    self.label = label\n\n  def getFullName(self):\n    name = lit.Test.Test.getFullName(self)\n    if self.label:\n      name += ' :: ' + self.label\n    return name\n\n  def getExecPath(self):\n    path = lit.Test.Test.getExecPath(self)\n    if self.label:\n      # Insert the label as an extra directory to isolate test variants\n      dirname, testname = os.path.split(path)\n      path = os.path.join(dirname, self.label, testname)\n    return path\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/tracing/increase_in_max_num_constraints_sat.smt2",
    "content": "; RUN: rm -rf %t-output-dir\n; RUN: %jfs -disable-standard-passes -redirect-libfuzzer-output=1 -output-dir=%t-output-dir -keep-output-dir -trace-max-num-satisfied-constraints -cxx %s | %FileCheck -check-prefix=CHECK-SAT %s\n\n; RUN: %FileCheck -check-prefix=CHECK-LIBFUZZER -input-file=%t-output-dir/libfuzzer.stderr.txt %s\n(declare-fun buffer_0 () Bool)\n(declare-fun buffer_1 () Bool)\n(declare-fun buffer_2 () Bool)\n(declare-fun buffer_3 () Bool)\n(assert (or buffer_0 buffer_1))\n(assert (or buffer_1 buffer_2))\n(assert (or buffer_2 buffer_3))\n(check-sat)\n\n; CHECK-SAT: {{^sat$}}\n\n; CHECK-LIBFUZZER: JFS INFO: Max num constraints satisfied increased from 0 to 1 (out of 3)\n; CHECK-LIBFUZZER: JFS INFO: Max num constraints satisfied increased from 1 to 2 (out of 3)\n; CHECK-LIBFUZZER: JFS INFO: Max num constraints satisfied increased from 2 to 3 (out of 3)\n\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/tracing/trace_wrong_sized_input.smt2",
    "content": "; NOTE: This test depends on warnings only triggered with LibFuzzer.\n; REQUIRES: LibFuzzer\n; RUN: rm -rf %t-output-dir\n\n; RUN: %jfs -libfuzzer-runs=20 -seed=1 -sm-special-constant-seeds=false -redirect-libfuzzer-output=1 -output-dir=%t-output-dir -keep-output-dir -libfuzzer-default-mutations-resize-input=1 -trace-wrong-sized-inputs -cxx %s | %FileCheck -check-prefix=CHECK-SAT %s\n\n; RUN: %FileCheck -check-prefix=CHECK-LIBFUZZER -input-file=%t-output-dir/libfuzzer.stderr.txt %s\n\n; CHECK-SAT: {{^unknown$}}\n\n; The first warning is spurious because LibFuzzer tries a zero-sized input\n; during INIT. However the second warning should be genuine and is very likely\n; to occur when `-libfuzzer-default-mutations-resize-input=1`. (The second\n; warning goes away if special constant seeds are enabled, likely because the\n; fuzzer reaches the target before trying a mutation.)\n\n; CHECK-LIBFUZZER: JFS WARNING: Wrong sized input tried.\n; CHECK-LIBFUZZER: JFS WARNING: Wrong sized input tried.\n\n(set-info :smt-lib-version 2.6)\n(set-logic QF_BV)\n(set-info :source |\n more info in 'N. P. Lopes, L. Aksoy, V. Manquinho, J. Monteiro.\n Optimally Solving the MCM Problem Using Pseudo-Boolean Satisfiability.\n Technical Report RT/43/2010, INESC-ID, Nov. 2010'. |)\n(set-info :category \"industrial\")\n(set-info :status sat)\n(declare-fun X0 () (_ BitVec 11))\n(declare-fun X1 () (_ BitVec 11))\n(declare-fun X2 () (_ BitVec 11))\n(declare-fun X3 () (_ BitVec 11))\n(declare-fun X4 () (_ BitVec 11))\n(declare-fun X5 () (_ BitVec 11))\n(declare-fun X6 () (_ BitVec 11))\n(declare-fun X7 () (_ BitVec 11))\n(declare-fun X8 () (_ BitVec 11))\n(declare-fun X9 () (_ BitVec 11))\n(declare-fun X10 () (_ BitVec 11))\n(declare-fun X11 () (_ BitVec 11))\n(declare-fun X12 () (_ BitVec 11))\n(declare-fun S0 () (_ BitVec 11))\n(declare-fun S1 () (_ BitVec 11))\n(declare-fun S2 () (_ BitVec 11))\n(declare-fun S3 () (_ BitVec 11))\n(declare-fun S4 () (_ BitVec 11))\n(declare-fun S5 () (_ BitVec 11))\n(declare-fun S6 () (_ BitVec 11))\n(declare-fun S7 () (_ BitVec 11))\n(declare-fun S8 () (_ BitVec 11))\n(declare-fun S9 () (_ BitVec 11))\n(declare-fun S10 () (_ BitVec 11))\n(declare-fun S11 () (_ BitVec 11))\n(declare-fun S12 () (_ BitVec 11))\n(declare-fun S13 () (_ BitVec 11))\n(declare-fun S14 () (_ BitVec 11))\n(declare-fun S15 () (_ BitVec 11))\n(declare-fun S16 () (_ BitVec 11))\n(declare-fun S17 () (_ BitVec 11))\n(declare-fun S18 () (_ BitVec 11))\n(declare-fun S19 () (_ BitVec 11))\n(declare-fun S20 () (_ BitVec 11))\n(declare-fun S21 () (_ BitVec 11))\n(declare-fun S22 () (_ BitVec 11))\n(declare-fun S23 () (_ BitVec 11))\n(declare-fun S24 () (_ BitVec 11))\n(declare-fun S25 () (_ BitVec 11))\n(define-fun mask1 ((x (_ BitVec 11))) (_ BitVec 11)\n (ite (= x (_ bv1 11)) (_ bv1024 11)\n (ite (= x (_ bv2 11)) (_ bv1536 11)\n (ite (= x (_ bv3 11)) (_ bv1792 11)\n (ite (= x (_ bv4 11)) (_ bv1920 11)\n (ite (= x (_ bv5 11)) (_ bv1984 11)\n (ite (= x (_ bv6 11)) (_ bv2016 11)\n (ite (= x (_ bv7 11)) (_ bv2032 11)\n (ite (= x (_ bv8 11)) (_ bv2040 11)\n (ite (= x (_ bv9 11)) (_ bv2044 11)\n (ite (= x (_ bv10 11)) (_ bv2046 11)\n (_ bv0 11)\n)))))))))))\n(define-fun notpow ((x (_ BitVec 11))) Bool\n (not (= (bvand x (bvsub x (_ bv1 11))) (_ bv0 11))))\n(define-fun shlok ((x (_ BitVec 11)) (y (_ BitVec 11))) Bool\n  (= (bvand x (mask1 y)) (_ bv0 11)))\n(define-fun addok ((x (_ BitVec 11)) (y (_ BitVec 11))) Bool\n  (and\n       (= (bvand (bvlshr x (_ bv10 11)) (bvlshr y (_ bv10 11))) (_ bv0 11))\n       (= ((_ extract 11 11) (bvadd ((_ zero_extend 1) x) ((_ zero_extend 1) y))) (_ bv0 1))))\n(assert (or\n (and (bvugt S0 S1) (= X0 (bvor (bvshl (_ bv1 11) S0) (bvshl (_ bv1 11) S1))))\n (and (bvugt S0 S1) (= X0 (bvsub (bvshl (_ bv1 11) S0) (bvshl (_ bv1 11) S1))))\n))\n(assert (or\n (and (bvugt S2 S3) (= X1 (bvor (bvshl (_ bv1 11) S2) (bvshl (_ bv1 11) S3))))\n (and (bvugt S2 S3) (= X1 (bvsub (bvshl (_ bv1 11) S2) (bvshl (_ bv1 11) S3))))\n (and (shlok X0 S2) (addok (bvshl X0 S2) (bvshl (_ bv1 11) S3)) (= X1 (bvadd (bvshl X0 S2) (bvshl (_ bv1 11) S3))))\n (and (shlok X0 S2) (bvugt (bvshl X0 S2) (bvshl (_ bv1 11) S3)) (= X1 (bvsub (bvshl X0 S2) (bvshl (_ bv1 11) S3))))\n (and (shlok X0 S3) (bvugt (bvshl (_ bv1 11) S2) (bvshl X0 S3)) (= X1 (bvsub (bvshl (_ bv1 11) S2) (bvshl X0 S3))))\n (and (bvugt S2 S3) (shlok X0 S2) (addok (bvshl X0 S2) (bvshl X0 S3)) (= X1 (bvadd (bvshl X0 S2) (bvshl X0 S3))))\n (and (bvugt S2 S3) (shlok X0 S2) (= X1 (bvsub (bvshl X0 S2) (bvshl X0 S3))))\n))\n(assert (or\n (and (bvugt S4 S5) (= X2 (bvor (bvshl (_ bv1 11) S4) (bvshl (_ bv1 11) S5))))\n (and (bvugt S4 S5) (= X2 (bvsub (bvshl (_ bv1 11) S4) (bvshl (_ bv1 11) S5))))\n (and (shlok X0 S4) (addok (bvshl X0 S4) (bvshl (_ bv1 11) S5)) (= X2 (bvadd (bvshl X0 S4) (bvshl (_ bv1 11) S5))))\n (and (shlok X0 S4) (bvugt (bvshl X0 S4) (bvshl (_ bv1 11) S5)) (= X2 (bvsub (bvshl X0 S4) (bvshl (_ bv1 11) S5))))\n (and (shlok X0 S5) (bvugt (bvshl (_ bv1 11) S4) (bvshl X0 S5)) (= X2 (bvsub (bvshl (_ bv1 11) S4) (bvshl X0 S5))))\n (and (bvugt S4 S5) (shlok X0 S4) (addok (bvshl X0 S4) (bvshl X0 S5)) (= X2 (bvadd (bvshl X0 S4) (bvshl X0 S5))))\n (and (bvugt S4 S5) (shlok X0 S4) (= X2 (bvsub (bvshl X0 S4) (bvshl X0 S5))))\n (and (shlok X0 S4) (shlok X1 S5) (addok (bvshl X0 S4) (bvshl X1 S5)) (= X2 (bvadd (bvshl X0 S4) (bvshl X1 S5))))\n (and (shlok X0 S4) (shlok X1 S5) (bvugt (bvshl X0 S4) (bvshl X1 S5)) (= X2 (bvsub (bvshl X0 S4) (bvshl X1 S5))))\n (and (shlok X1 S4) (shlok X0 S5) (bvugt (bvshl X1 S4) (bvshl X0 S5)) (= X2 (bvsub (bvshl X1 S4) (bvshl X0 S5))))\n (and (shlok X1 S4) (addok (bvshl X1 S4) (bvshl (_ bv1 11) S5)) (= X2 (bvadd (bvshl X1 S4) (bvshl (_ bv1 11) S5))))\n (and (shlok X1 S4) (bvugt (bvshl X1 S4) (bvshl (_ bv1 11) S5)) (= X2 (bvsub (bvshl X1 S4) (bvshl (_ bv1 11) S5))))\n (and (shlok X1 S5) (bvugt (bvshl (_ bv1 11) S4) (bvshl X1 S5)) (= X2 (bvsub (bvshl (_ bv1 11) S4) (bvshl X1 S5))))\n (and (bvugt S4 S5) (shlok X1 S4) (addok (bvshl X1 S4) (bvshl X1 S5)) (= X2 (bvadd (bvshl X1 S4) (bvshl X1 S5))))\n (and (bvugt S4 S5) (shlok X1 S4) (= X2 (bvsub (bvshl X1 S4) (bvshl X1 S5))))\n))\n(assert (or\n (and (shlok X0 S6) (addok (bvshl X0 S6) (bvshl (_ bv1 11) S7)) (= X3 (bvadd (bvshl X0 S6) (bvshl (_ bv1 11) S7))))\n (and (shlok X0 S6) (bvugt (bvshl X0 S6) (bvshl (_ bv1 11) S7)) (= X3 (bvsub (bvshl X0 S6) (bvshl (_ bv1 11) S7))))\n (and (shlok X0 S7) (bvugt (bvshl (_ bv1 11) S6) (bvshl X0 S7)) (= X3 (bvsub (bvshl (_ bv1 11) S6) (bvshl X0 S7))))\n (and (bvugt S6 S7) (shlok X0 S6) (addok (bvshl X0 S6) (bvshl X0 S7)) (= X3 (bvadd (bvshl X0 S6) (bvshl X0 S7))))\n (and (bvugt S6 S7) (shlok X0 S6) (= X3 (bvsub (bvshl X0 S6) (bvshl X0 S7))))\n (and (shlok X0 S6) (shlok X1 S7) (addok (bvshl X0 S6) (bvshl X1 S7)) (= X3 (bvadd (bvshl X0 S6) (bvshl X1 S7))))\n (and (shlok X0 S6) (shlok X1 S7) (bvugt (bvshl X0 S6) (bvshl X1 S7)) (= X3 (bvsub (bvshl X0 S6) (bvshl X1 S7))))\n (and (shlok X1 S6) (shlok X0 S7) (bvugt (bvshl X1 S6) (bvshl X0 S7)) (= X3 (bvsub (bvshl X1 S6) (bvshl X0 S7))))\n (and (shlok X0 S6) (shlok X2 S7) (addok (bvshl X0 S6) (bvshl X2 S7)) (= X3 (bvadd (bvshl X0 S6) (bvshl X2 S7))))\n (and (shlok X0 S6) (shlok X2 S7) (bvugt (bvshl X0 S6) (bvshl X2 S7)) (= X3 (bvsub (bvshl X0 S6) (bvshl X2 S7))))\n (and (shlok X2 S6) (shlok X0 S7) (bvugt (bvshl X2 S6) (bvshl X0 S7)) (= X3 (bvsub (bvshl X2 S6) (bvshl X0 S7))))\n (and (shlok X1 S6) (addok (bvshl X1 S6) (bvshl (_ bv1 11) S7)) (= X3 (bvadd (bvshl X1 S6) (bvshl (_ bv1 11) S7))))\n (and (shlok X1 S6) (bvugt (bvshl X1 S6) (bvshl (_ bv1 11) S7)) (= X3 (bvsub (bvshl X1 S6) (bvshl (_ bv1 11) S7))))\n (and (shlok X1 S7) (bvugt (bvshl (_ bv1 11) S6) (bvshl X1 S7)) (= X3 (bvsub (bvshl (_ bv1 11) S6) (bvshl X1 S7))))\n (and (bvugt S6 S7) (shlok X1 S6) (addok (bvshl X1 S6) (bvshl X1 S7)) (= X3 (bvadd (bvshl X1 S6) (bvshl X1 S7))))\n (and (bvugt S6 S7) (shlok X1 S6) (= X3 (bvsub (bvshl X1 S6) (bvshl X1 S7))))\n (and (shlok X1 S6) (shlok X2 S7) (addok (bvshl X1 S6) (bvshl X2 S7)) (= X3 (bvadd (bvshl X1 S6) (bvshl X2 S7))))\n (and (shlok X1 S6) (shlok X2 S7) (bvugt (bvshl X1 S6) (bvshl X2 S7)) (= X3 (bvsub (bvshl X1 S6) (bvshl X2 S7))))\n (and (shlok X2 S6) (shlok X1 S7) (bvugt (bvshl X2 S6) (bvshl X1 S7)) (= X3 (bvsub (bvshl X2 S6) (bvshl X1 S7))))\n (and (shlok X2 S6) (addok (bvshl X2 S6) (bvshl (_ bv1 11) S7)) (= X3 (bvadd (bvshl X2 S6) (bvshl (_ bv1 11) S7))))\n (and (shlok X2 S6) (bvugt (bvshl X2 S6) (bvshl (_ bv1 11) S7)) (= X3 (bvsub (bvshl X2 S6) (bvshl (_ bv1 11) S7))))\n (and (shlok X2 S7) (bvugt (bvshl (_ bv1 11) S6) (bvshl X2 S7)) (= X3 (bvsub (bvshl (_ bv1 11) S6) (bvshl X2 S7))))\n (and (bvugt S6 S7) (shlok X2 S6) (addok (bvshl X2 S6) (bvshl X2 S7)) (= X3 (bvadd (bvshl X2 S6) (bvshl X2 S7))))\n (and (bvugt S6 S7) (shlok X2 S6) (= X3 (bvsub (bvshl X2 S6) (bvshl X2 S7))))\n))\n(assert (or\n (and (shlok X0 S8) (addok (bvshl X0 S8) (bvshl (_ bv1 11) S9)) (= X4 (bvadd (bvshl X0 S8) (bvshl (_ bv1 11) S9))))\n (and (shlok X0 S8) (bvugt (bvshl X0 S8) (bvshl (_ bv1 11) S9)) (= X4 (bvsub (bvshl X0 S8) (bvshl (_ bv1 11) S9))))\n (and (shlok X0 S9) (bvugt (bvshl (_ bv1 11) S8) (bvshl X0 S9)) (= X4 (bvsub (bvshl (_ bv1 11) S8) (bvshl X0 S9))))\n (and (bvugt S8 S9) (shlok X0 S8) (addok (bvshl X0 S8) (bvshl X0 S9)) (= X4 (bvadd (bvshl X0 S8) (bvshl X0 S9))))\n (and (bvugt S8 S9) (shlok X0 S8) (= X4 (bvsub (bvshl X0 S8) (bvshl X0 S9))))\n (and (shlok X0 S8) (shlok X1 S9) (addok (bvshl X0 S8) (bvshl X1 S9)) (= X4 (bvadd (bvshl X0 S8) (bvshl X1 S9))))\n (and (shlok X0 S8) (shlok X1 S9) (bvugt (bvshl X0 S8) (bvshl X1 S9)) (= X4 (bvsub (bvshl X0 S8) (bvshl X1 S9))))\n (and (shlok X1 S8) (shlok X0 S9) (bvugt (bvshl X1 S8) (bvshl X0 S9)) (= X4 (bvsub (bvshl X1 S8) (bvshl X0 S9))))\n (and (shlok X0 S8) (shlok X2 S9) (addok (bvshl X0 S8) (bvshl X2 S9)) (= X4 (bvadd (bvshl X0 S8) (bvshl X2 S9))))\n (and (shlok X0 S8) (shlok X2 S9) (bvugt (bvshl X0 S8) (bvshl X2 S9)) (= X4 (bvsub (bvshl X0 S8) (bvshl X2 S9))))\n (and (shlok X2 S8) (shlok X0 S9) (bvugt (bvshl X2 S8) (bvshl X0 S9)) (= X4 (bvsub (bvshl X2 S8) (bvshl X0 S9))))\n (and (shlok X0 S8) (shlok X3 S9) (addok (bvshl X0 S8) (bvshl X3 S9)) (= X4 (bvadd (bvshl X0 S8) (bvshl X3 S9))))\n (and (shlok X0 S8) (shlok X3 S9) (bvugt (bvshl X0 S8) (bvshl X3 S9)) (= X4 (bvsub (bvshl X0 S8) (bvshl X3 S9))))\n (and (shlok X3 S8) (shlok X0 S9) (bvugt (bvshl X3 S8) (bvshl X0 S9)) (= X4 (bvsub (bvshl X3 S8) (bvshl X0 S9))))\n (and (shlok X1 S8) (addok (bvshl X1 S8) (bvshl (_ bv1 11) S9)) (= X4 (bvadd (bvshl X1 S8) (bvshl (_ bv1 11) S9))))\n (and (shlok X1 S8) (bvugt (bvshl X1 S8) (bvshl (_ bv1 11) S9)) (= X4 (bvsub (bvshl X1 S8) (bvshl (_ bv1 11) S9))))\n (and (shlok X1 S9) (bvugt (bvshl (_ bv1 11) S8) (bvshl X1 S9)) (= X4 (bvsub (bvshl (_ bv1 11) S8) (bvshl X1 S9))))\n (and (bvugt S8 S9) (shlok X1 S8) (addok (bvshl X1 S8) (bvshl X1 S9)) (= X4 (bvadd (bvshl X1 S8) (bvshl X1 S9))))\n (and (bvugt S8 S9) (shlok X1 S8) (= X4 (bvsub (bvshl X1 S8) (bvshl X1 S9))))\n (and (shlok X1 S8) (shlok X2 S9) (addok (bvshl X1 S8) (bvshl X2 S9)) (= X4 (bvadd (bvshl X1 S8) (bvshl X2 S9))))\n (and (shlok X1 S8) (shlok X2 S9) (bvugt (bvshl X1 S8) (bvshl X2 S9)) (= X4 (bvsub (bvshl X1 S8) (bvshl X2 S9))))\n (and (shlok X2 S8) (shlok X1 S9) (bvugt (bvshl X2 S8) (bvshl X1 S9)) (= X4 (bvsub (bvshl X2 S8) (bvshl X1 S9))))\n (and (shlok X1 S8) (shlok X3 S9) (addok (bvshl X1 S8) (bvshl X3 S9)) (= X4 (bvadd (bvshl X1 S8) (bvshl X3 S9))))\n (and (shlok X1 S8) (shlok X3 S9) (bvugt (bvshl X1 S8) (bvshl X3 S9)) (= X4 (bvsub (bvshl X1 S8) (bvshl X3 S9))))\n (and (shlok X3 S8) (shlok X1 S9) (bvugt (bvshl X3 S8) (bvshl X1 S9)) (= X4 (bvsub (bvshl X3 S8) (bvshl X1 S9))))\n (and (shlok X2 S8) (addok (bvshl X2 S8) (bvshl (_ bv1 11) S9)) (= X4 (bvadd (bvshl X2 S8) (bvshl (_ bv1 11) S9))))\n (and (shlok X2 S8) (bvugt (bvshl X2 S8) (bvshl (_ bv1 11) S9)) (= X4 (bvsub (bvshl X2 S8) (bvshl (_ bv1 11) S9))))\n (and (shlok X2 S9) (bvugt (bvshl (_ bv1 11) S8) (bvshl X2 S9)) (= X4 (bvsub (bvshl (_ bv1 11) S8) (bvshl X2 S9))))\n (and (bvugt S8 S9) (shlok X2 S8) (addok (bvshl X2 S8) (bvshl X2 S9)) (= X4 (bvadd (bvshl X2 S8) (bvshl X2 S9))))\n (and (bvugt S8 S9) (shlok X2 S8) (= X4 (bvsub (bvshl X2 S8) (bvshl X2 S9))))\n (and (shlok X2 S8) (shlok X3 S9) (addok (bvshl X2 S8) (bvshl X3 S9)) (= X4 (bvadd (bvshl X2 S8) (bvshl X3 S9))))\n (and (shlok X2 S8) (shlok X3 S9) (bvugt (bvshl X2 S8) (bvshl X3 S9)) (= X4 (bvsub (bvshl X2 S8) (bvshl X3 S9))))\n (and (shlok X3 S8) (shlok X2 S9) (bvugt (bvshl X3 S8) (bvshl X2 S9)) (= X4 (bvsub (bvshl X3 S8) (bvshl X2 S9))))\n (and (shlok X3 S8) (addok (bvshl X3 S8) (bvshl (_ bv1 11) S9)) (= X4 (bvadd (bvshl X3 S8) (bvshl (_ bv1 11) S9))))\n (and (shlok X3 S8) (bvugt (bvshl X3 S8) (bvshl (_ bv1 11) S9)) (= X4 (bvsub (bvshl X3 S8) (bvshl (_ bv1 11) S9))))\n (and (shlok X3 S9) (bvugt (bvshl (_ bv1 11) S8) (bvshl X3 S9)) (= X4 (bvsub (bvshl (_ bv1 11) S8) (bvshl X3 S9))))\n (and (bvugt S8 S9) (shlok X3 S8) (addok (bvshl X3 S8) (bvshl X3 S9)) (= X4 (bvadd (bvshl X3 S8) (bvshl X3 S9))))\n (and (bvugt S8 S9) (shlok X3 S8) (= X4 (bvsub (bvshl X3 S8) (bvshl X3 S9))))\n))\n(assert (or\n (and (shlok X0 S10) (addok (bvshl X0 S10) (bvshl (_ bv1 11) S11)) (= X5 (bvadd (bvshl X0 S10) (bvshl (_ bv1 11) S11))))\n (and (shlok X0 S10) (bvugt (bvshl X0 S10) (bvshl (_ bv1 11) S11)) (= X5 (bvsub (bvshl X0 S10) (bvshl (_ bv1 11) S11))))\n (and (shlok X0 S11) (bvugt (bvshl (_ bv1 11) S10) (bvshl X0 S11)) (= X5 (bvsub (bvshl (_ bv1 11) S10) (bvshl X0 S11))))\n (and (bvugt S10 S11) (shlok X0 S10) (addok (bvshl X0 S10) (bvshl X0 S11)) (= X5 (bvadd (bvshl X0 S10) (bvshl X0 S11))))\n (and (bvugt S10 S11) (shlok X0 S10) (= X5 (bvsub (bvshl X0 S10) (bvshl X0 S11))))\n (and (shlok X0 S10) (shlok X1 S11) (addok (bvshl X0 S10) (bvshl X1 S11)) (= X5 (bvadd (bvshl X0 S10) (bvshl X1 S11))))\n (and (shlok X0 S10) (shlok X1 S11) (bvugt (bvshl X0 S10) (bvshl X1 S11)) (= X5 (bvsub (bvshl X0 S10) (bvshl X1 S11))))\n (and (shlok X1 S10) (shlok X0 S11) (bvugt (bvshl X1 S10) (bvshl X0 S11)) (= X5 (bvsub (bvshl X1 S10) (bvshl X0 S11))))\n (and (shlok X0 S10) (shlok X2 S11) (addok (bvshl X0 S10) (bvshl X2 S11)) (= X5 (bvadd (bvshl X0 S10) (bvshl X2 S11))))\n (and (shlok X0 S10) (shlok X2 S11) (bvugt (bvshl X0 S10) (bvshl X2 S11)) (= X5 (bvsub (bvshl X0 S10) (bvshl X2 S11))))\n (and (shlok X2 S10) (shlok X0 S11) (bvugt (bvshl X2 S10) (bvshl X0 S11)) (= X5 (bvsub (bvshl X2 S10) (bvshl X0 S11))))\n (and (shlok X0 S10) (shlok X3 S11) (addok (bvshl X0 S10) (bvshl X3 S11)) (= X5 (bvadd (bvshl X0 S10) (bvshl X3 S11))))\n (and (shlok X0 S10) (shlok X3 S11) (bvugt (bvshl X0 S10) (bvshl X3 S11)) (= X5 (bvsub (bvshl X0 S10) (bvshl X3 S11))))\n (and (shlok X3 S10) (shlok X0 S11) (bvugt (bvshl X3 S10) (bvshl X0 S11)) (= X5 (bvsub (bvshl X3 S10) (bvshl X0 S11))))\n (and (shlok X0 S10) (shlok X4 S11) (addok (bvshl X0 S10) (bvshl X4 S11)) (= X5 (bvadd (bvshl X0 S10) (bvshl X4 S11))))\n (and (shlok X0 S10) (shlok X4 S11) (bvugt (bvshl X0 S10) (bvshl X4 S11)) (= X5 (bvsub (bvshl X0 S10) (bvshl X4 S11))))\n (and (shlok X4 S10) (shlok X0 S11) (bvugt (bvshl X4 S10) (bvshl X0 S11)) (= X5 (bvsub (bvshl X4 S10) (bvshl X0 S11))))\n (and (shlok X1 S10) (addok (bvshl X1 S10) (bvshl (_ bv1 11) S11)) (= X5 (bvadd (bvshl X1 S10) (bvshl (_ bv1 11) S11))))\n (and (shlok X1 S10) (bvugt (bvshl X1 S10) (bvshl (_ bv1 11) S11)) (= X5 (bvsub (bvshl X1 S10) (bvshl (_ bv1 11) S11))))\n (and (shlok X1 S11) (bvugt (bvshl (_ bv1 11) S10) (bvshl X1 S11)) (= X5 (bvsub (bvshl (_ bv1 11) S10) (bvshl X1 S11))))\n (and (bvugt S10 S11) (shlok X1 S10) (addok (bvshl X1 S10) (bvshl X1 S11)) (= X5 (bvadd (bvshl X1 S10) (bvshl X1 S11))))\n (and (bvugt S10 S11) (shlok X1 S10) (= X5 (bvsub (bvshl X1 S10) (bvshl X1 S11))))\n (and (shlok X1 S10) (shlok X2 S11) (addok (bvshl X1 S10) (bvshl X2 S11)) (= X5 (bvadd (bvshl X1 S10) (bvshl X2 S11))))\n (and (shlok X1 S10) (shlok X2 S11) (bvugt (bvshl X1 S10) (bvshl X2 S11)) (= X5 (bvsub (bvshl X1 S10) (bvshl X2 S11))))\n (and (shlok X2 S10) (shlok X1 S11) (bvugt (bvshl X2 S10) (bvshl X1 S11)) (= X5 (bvsub (bvshl X2 S10) (bvshl X1 S11))))\n (and (shlok X1 S10) (shlok X3 S11) (addok (bvshl X1 S10) (bvshl X3 S11)) (= X5 (bvadd (bvshl X1 S10) (bvshl X3 S11))))\n (and (shlok X1 S10) (shlok X3 S11) (bvugt (bvshl X1 S10) (bvshl X3 S11)) (= X5 (bvsub (bvshl X1 S10) (bvshl X3 S11))))\n (and (shlok X3 S10) (shlok X1 S11) (bvugt (bvshl X3 S10) (bvshl X1 S11)) (= X5 (bvsub (bvshl X3 S10) (bvshl X1 S11))))\n (and (shlok X1 S10) (shlok X4 S11) (addok (bvshl X1 S10) (bvshl X4 S11)) (= X5 (bvadd (bvshl X1 S10) (bvshl X4 S11))))\n (and (shlok X1 S10) (shlok X4 S11) (bvugt (bvshl X1 S10) (bvshl X4 S11)) (= X5 (bvsub (bvshl X1 S10) (bvshl X4 S11))))\n (and (shlok X4 S10) (shlok X1 S11) (bvugt (bvshl X4 S10) (bvshl X1 S11)) (= X5 (bvsub (bvshl X4 S10) (bvshl X1 S11))))\n (and (shlok X2 S10) (addok (bvshl X2 S10) (bvshl (_ bv1 11) S11)) (= X5 (bvadd (bvshl X2 S10) (bvshl (_ bv1 11) S11))))\n (and (shlok X2 S10) (bvugt (bvshl X2 S10) (bvshl (_ bv1 11) S11)) (= X5 (bvsub (bvshl X2 S10) (bvshl (_ bv1 11) S11))))\n (and (shlok X2 S11) (bvugt (bvshl (_ bv1 11) S10) (bvshl X2 S11)) (= X5 (bvsub (bvshl (_ bv1 11) S10) (bvshl X2 S11))))\n (and (bvugt S10 S11) (shlok X2 S10) (addok (bvshl X2 S10) (bvshl X2 S11)) (= X5 (bvadd (bvshl X2 S10) (bvshl X2 S11))))\n (and (bvugt S10 S11) (shlok X2 S10) (= X5 (bvsub (bvshl X2 S10) (bvshl X2 S11))))\n (and (shlok X2 S10) (shlok X3 S11) (addok (bvshl X2 S10) (bvshl X3 S11)) (= X5 (bvadd (bvshl X2 S10) (bvshl X3 S11))))\n (and (shlok X2 S10) (shlok X3 S11) (bvugt (bvshl X2 S10) (bvshl X3 S11)) (= X5 (bvsub (bvshl X2 S10) (bvshl X3 S11))))\n (and (shlok X3 S10) (shlok X2 S11) (bvugt (bvshl X3 S10) (bvshl X2 S11)) (= X5 (bvsub (bvshl X3 S10) (bvshl X2 S11))))\n (and (shlok X2 S10) (shlok X4 S11) (addok (bvshl X2 S10) (bvshl X4 S11)) (= X5 (bvadd (bvshl X2 S10) (bvshl X4 S11))))\n (and (shlok X2 S10) (shlok X4 S11) (bvugt (bvshl X2 S10) (bvshl X4 S11)) (= X5 (bvsub (bvshl X2 S10) (bvshl X4 S11))))\n (and (shlok X4 S10) (shlok X2 S11) (bvugt (bvshl X4 S10) (bvshl X2 S11)) (= X5 (bvsub (bvshl X4 S10) (bvshl X2 S11))))\n (and (shlok X3 S10) (addok (bvshl X3 S10) (bvshl (_ bv1 11) S11)) (= X5 (bvadd (bvshl X3 S10) (bvshl (_ bv1 11) S11))))\n (and (shlok X3 S10) (bvugt (bvshl X3 S10) (bvshl (_ bv1 11) S11)) (= X5 (bvsub (bvshl X3 S10) (bvshl (_ bv1 11) S11))))\n (and (shlok X3 S11) (bvugt (bvshl (_ bv1 11) S10) (bvshl X3 S11)) (= X5 (bvsub (bvshl (_ bv1 11) S10) (bvshl X3 S11))))\n (and (bvugt S10 S11) (shlok X3 S10) (addok (bvshl X3 S10) (bvshl X3 S11)) (= X5 (bvadd (bvshl X3 S10) (bvshl X3 S11))))\n (and (bvugt S10 S11) (shlok X3 S10) (= X5 (bvsub (bvshl X3 S10) (bvshl X3 S11))))\n (and (shlok X3 S10) (shlok X4 S11) (addok (bvshl X3 S10) (bvshl X4 S11)) (= X5 (bvadd (bvshl X3 S10) (bvshl X4 S11))))\n (and (shlok X3 S10) (shlok X4 S11) (bvugt (bvshl X3 S10) (bvshl X4 S11)) (= X5 (bvsub (bvshl X3 S10) (bvshl X4 S11))))\n (and (shlok X4 S10) (shlok X3 S11) (bvugt (bvshl X4 S10) (bvshl X3 S11)) (= X5 (bvsub (bvshl X4 S10) (bvshl X3 S11))))\n (and (shlok X4 S10) (addok (bvshl X4 S10) (bvshl (_ bv1 11) S11)) (= X5 (bvadd (bvshl X4 S10) (bvshl (_ bv1 11) S11))))\n (and (shlok X4 S10) (bvugt (bvshl X4 S10) (bvshl (_ bv1 11) S11)) (= X5 (bvsub (bvshl X4 S10) (bvshl (_ bv1 11) S11))))\n (and (shlok X4 S11) (bvugt (bvshl (_ bv1 11) S10) (bvshl X4 S11)) (= X5 (bvsub (bvshl (_ bv1 11) S10) (bvshl X4 S11))))\n (and (bvugt S10 S11) (shlok X4 S10) (addok (bvshl X4 S10) (bvshl X4 S11)) (= X5 (bvadd (bvshl X4 S10) (bvshl X4 S11))))\n (and (bvugt S10 S11) (shlok X4 S10) (= X5 (bvsub (bvshl X4 S10) (bvshl X4 S11))))\n))\n(assert (or\n (and (shlok X0 S12) (addok (bvshl X0 S12) (bvshl (_ bv1 11) S13)) (= X6 (bvadd (bvshl X0 S12) (bvshl (_ bv1 11) S13))))\n (and (shlok X0 S12) (bvugt (bvshl X0 S12) (bvshl (_ bv1 11) S13)) (= X6 (bvsub (bvshl X0 S12) (bvshl (_ bv1 11) S13))))\n (and (shlok X0 S13) (bvugt (bvshl (_ bv1 11) S12) (bvshl X0 S13)) (= X6 (bvsub (bvshl (_ bv1 11) S12) (bvshl X0 S13))))\n (and (bvugt S12 S13) (shlok X0 S12) (addok (bvshl X0 S12) (bvshl X0 S13)) (= X6 (bvadd (bvshl X0 S12) (bvshl X0 S13))))\n (and (bvugt S12 S13) (shlok X0 S12) (= X6 (bvsub (bvshl X0 S12) (bvshl X0 S13))))\n (and (shlok X0 S12) (shlok X1 S13) (addok (bvshl X0 S12) (bvshl X1 S13)) (= X6 (bvadd (bvshl X0 S12) (bvshl X1 S13))))\n (and (shlok X0 S12) (shlok X1 S13) (bvugt (bvshl X0 S12) (bvshl X1 S13)) (= X6 (bvsub (bvshl X0 S12) (bvshl X1 S13))))\n (and (shlok X1 S12) (shlok X0 S13) (bvugt (bvshl X1 S12) (bvshl X0 S13)) (= X6 (bvsub (bvshl X1 S12) (bvshl X0 S13))))\n (and (shlok X0 S12) (shlok X2 S13) (addok (bvshl X0 S12) (bvshl X2 S13)) (= X6 (bvadd (bvshl X0 S12) (bvshl X2 S13))))\n (and (shlok X0 S12) (shlok X2 S13) (bvugt (bvshl X0 S12) (bvshl X2 S13)) (= X6 (bvsub (bvshl X0 S12) (bvshl X2 S13))))\n (and (shlok X2 S12) (shlok X0 S13) (bvugt (bvshl X2 S12) (bvshl X0 S13)) (= X6 (bvsub (bvshl X2 S12) (bvshl X0 S13))))\n (and (shlok X0 S12) (shlok X3 S13) (addok (bvshl X0 S12) (bvshl X3 S13)) (= X6 (bvadd (bvshl X0 S12) (bvshl X3 S13))))\n (and (shlok X0 S12) (shlok X3 S13) (bvugt (bvshl X0 S12) (bvshl X3 S13)) (= X6 (bvsub (bvshl X0 S12) (bvshl X3 S13))))\n (and (shlok X3 S12) (shlok X0 S13) (bvugt (bvshl X3 S12) (bvshl X0 S13)) (= X6 (bvsub (bvshl X3 S12) (bvshl X0 S13))))\n (and (shlok X0 S12) (shlok X4 S13) (addok (bvshl X0 S12) (bvshl X4 S13)) (= X6 (bvadd (bvshl X0 S12) (bvshl X4 S13))))\n (and (shlok X0 S12) (shlok X4 S13) (bvugt (bvshl X0 S12) (bvshl X4 S13)) (= X6 (bvsub (bvshl X0 S12) (bvshl X4 S13))))\n (and (shlok X4 S12) (shlok X0 S13) (bvugt (bvshl X4 S12) (bvshl X0 S13)) (= X6 (bvsub (bvshl X4 S12) (bvshl X0 S13))))\n (and (shlok X0 S12) (shlok X5 S13) (addok (bvshl X0 S12) (bvshl X5 S13)) (= X6 (bvadd (bvshl X0 S12) (bvshl X5 S13))))\n (and (shlok X0 S12) (shlok X5 S13) (bvugt (bvshl X0 S12) (bvshl X5 S13)) (= X6 (bvsub (bvshl X0 S12) (bvshl X5 S13))))\n (and (shlok X5 S12) (shlok X0 S13) (bvugt (bvshl X5 S12) (bvshl X0 S13)) (= X6 (bvsub (bvshl X5 S12) (bvshl X0 S13))))\n (and (shlok X1 S12) (addok (bvshl X1 S12) (bvshl (_ bv1 11) S13)) (= X6 (bvadd (bvshl X1 S12) (bvshl (_ bv1 11) S13))))\n (and (shlok X1 S12) (bvugt (bvshl X1 S12) (bvshl (_ bv1 11) S13)) (= X6 (bvsub (bvshl X1 S12) (bvshl (_ bv1 11) S13))))\n (and (shlok X1 S13) (bvugt (bvshl (_ bv1 11) S12) (bvshl X1 S13)) (= X6 (bvsub (bvshl (_ bv1 11) S12) (bvshl X1 S13))))\n (and (bvugt S12 S13) (shlok X1 S12) (addok (bvshl X1 S12) (bvshl X1 S13)) (= X6 (bvadd (bvshl X1 S12) (bvshl X1 S13))))\n (and (bvugt S12 S13) (shlok X1 S12) (= X6 (bvsub (bvshl X1 S12) (bvshl X1 S13))))\n (and (shlok X1 S12) (shlok X2 S13) (addok (bvshl X1 S12) (bvshl X2 S13)) (= X6 (bvadd (bvshl X1 S12) (bvshl X2 S13))))\n (and (shlok X1 S12) (shlok X2 S13) (bvugt (bvshl X1 S12) (bvshl X2 S13)) (= X6 (bvsub (bvshl X1 S12) (bvshl X2 S13))))\n (and (shlok X2 S12) (shlok X1 S13) (bvugt (bvshl X2 S12) (bvshl X1 S13)) (= X6 (bvsub (bvshl X2 S12) (bvshl X1 S13))))\n (and (shlok X1 S12) (shlok X3 S13) (addok (bvshl X1 S12) (bvshl X3 S13)) (= X6 (bvadd (bvshl X1 S12) (bvshl X3 S13))))\n (and (shlok X1 S12) (shlok X3 S13) (bvugt (bvshl X1 S12) (bvshl X3 S13)) (= X6 (bvsub (bvshl X1 S12) (bvshl X3 S13))))\n (and (shlok X3 S12) (shlok X1 S13) (bvugt (bvshl X3 S12) (bvshl X1 S13)) (= X6 (bvsub (bvshl X3 S12) (bvshl X1 S13))))\n (and (shlok X1 S12) (shlok X4 S13) (addok (bvshl X1 S12) (bvshl X4 S13)) (= X6 (bvadd (bvshl X1 S12) (bvshl X4 S13))))\n (and (shlok X1 S12) (shlok X4 S13) (bvugt (bvshl X1 S12) (bvshl X4 S13)) (= X6 (bvsub (bvshl X1 S12) (bvshl X4 S13))))\n (and (shlok X4 S12) (shlok X1 S13) (bvugt (bvshl X4 S12) (bvshl X1 S13)) (= X6 (bvsub (bvshl X4 S12) (bvshl X1 S13))))\n (and (shlok X1 S12) (shlok X5 S13) (addok (bvshl X1 S12) (bvshl X5 S13)) (= X6 (bvadd (bvshl X1 S12) (bvshl X5 S13))))\n (and (shlok X1 S12) (shlok X5 S13) (bvugt (bvshl X1 S12) (bvshl X5 S13)) (= X6 (bvsub (bvshl X1 S12) (bvshl X5 S13))))\n (and (shlok X5 S12) (shlok X1 S13) (bvugt (bvshl X5 S12) (bvshl X1 S13)) (= X6 (bvsub (bvshl X5 S12) (bvshl X1 S13))))\n (and (shlok X2 S12) (addok (bvshl X2 S12) (bvshl (_ bv1 11) S13)) (= X6 (bvadd (bvshl X2 S12) (bvshl (_ bv1 11) S13))))\n (and (shlok X2 S12) (bvugt (bvshl X2 S12) (bvshl (_ bv1 11) S13)) (= X6 (bvsub (bvshl X2 S12) (bvshl (_ bv1 11) S13))))\n (and (shlok X2 S13) (bvugt (bvshl (_ bv1 11) S12) (bvshl X2 S13)) (= X6 (bvsub (bvshl (_ bv1 11) S12) (bvshl X2 S13))))\n (and (bvugt S12 S13) (shlok X2 S12) (addok (bvshl X2 S12) (bvshl X2 S13)) (= X6 (bvadd (bvshl X2 S12) (bvshl X2 S13))))\n (and (bvugt S12 S13) (shlok X2 S12) (= X6 (bvsub (bvshl X2 S12) (bvshl X2 S13))))\n (and (shlok X2 S12) (shlok X3 S13) (addok (bvshl X2 S12) (bvshl X3 S13)) (= X6 (bvadd (bvshl X2 S12) (bvshl X3 S13))))\n (and (shlok X2 S12) (shlok X3 S13) (bvugt (bvshl X2 S12) (bvshl X3 S13)) (= X6 (bvsub (bvshl X2 S12) (bvshl X3 S13))))\n (and (shlok X3 S12) (shlok X2 S13) (bvugt (bvshl X3 S12) (bvshl X2 S13)) (= X6 (bvsub (bvshl X3 S12) (bvshl X2 S13))))\n (and (shlok X2 S12) (shlok X4 S13) (addok (bvshl X2 S12) (bvshl X4 S13)) (= X6 (bvadd (bvshl X2 S12) (bvshl X4 S13))))\n (and (shlok X2 S12) (shlok X4 S13) (bvugt (bvshl X2 S12) (bvshl X4 S13)) (= X6 (bvsub (bvshl X2 S12) (bvshl X4 S13))))\n (and (shlok X4 S12) (shlok X2 S13) (bvugt (bvshl X4 S12) (bvshl X2 S13)) (= X6 (bvsub (bvshl X4 S12) (bvshl X2 S13))))\n (and (shlok X2 S12) (shlok X5 S13) (addok (bvshl X2 S12) (bvshl X5 S13)) (= X6 (bvadd (bvshl X2 S12) (bvshl X5 S13))))\n (and (shlok X2 S12) (shlok X5 S13) (bvugt (bvshl X2 S12) (bvshl X5 S13)) (= X6 (bvsub (bvshl X2 S12) (bvshl X5 S13))))\n (and (shlok X5 S12) (shlok X2 S13) (bvugt (bvshl X5 S12) (bvshl X2 S13)) (= X6 (bvsub (bvshl X5 S12) (bvshl X2 S13))))\n (and (shlok X3 S12) (addok (bvshl X3 S12) (bvshl (_ bv1 11) S13)) (= X6 (bvadd (bvshl X3 S12) (bvshl (_ bv1 11) S13))))\n (and (shlok X3 S12) (bvugt (bvshl X3 S12) (bvshl (_ bv1 11) S13)) (= X6 (bvsub (bvshl X3 S12) (bvshl (_ bv1 11) S13))))\n (and (shlok X3 S13) (bvugt (bvshl (_ bv1 11) S12) (bvshl X3 S13)) (= X6 (bvsub (bvshl (_ bv1 11) S12) (bvshl X3 S13))))\n (and (bvugt S12 S13) (shlok X3 S12) (addok (bvshl X3 S12) (bvshl X3 S13)) (= X6 (bvadd (bvshl X3 S12) (bvshl X3 S13))))\n (and (bvugt S12 S13) (shlok X3 S12) (= X6 (bvsub (bvshl X3 S12) (bvshl X3 S13))))\n (and (shlok X3 S12) (shlok X4 S13) (addok (bvshl X3 S12) (bvshl X4 S13)) (= X6 (bvadd (bvshl X3 S12) (bvshl X4 S13))))\n (and (shlok X3 S12) (shlok X4 S13) (bvugt (bvshl X3 S12) (bvshl X4 S13)) (= X6 (bvsub (bvshl X3 S12) (bvshl X4 S13))))\n (and (shlok X4 S12) (shlok X3 S13) (bvugt (bvshl X4 S12) (bvshl X3 S13)) (= X6 (bvsub (bvshl X4 S12) (bvshl X3 S13))))\n (and (shlok X3 S12) (shlok X5 S13) (addok (bvshl X3 S12) (bvshl X5 S13)) (= X6 (bvadd (bvshl X3 S12) (bvshl X5 S13))))\n (and (shlok X3 S12) (shlok X5 S13) (bvugt (bvshl X3 S12) (bvshl X5 S13)) (= X6 (bvsub (bvshl X3 S12) (bvshl X5 S13))))\n (and (shlok X5 S12) (shlok X3 S13) (bvugt (bvshl X5 S12) (bvshl X3 S13)) (= X6 (bvsub (bvshl X5 S12) (bvshl X3 S13))))\n (and (shlok X4 S12) (addok (bvshl X4 S12) (bvshl (_ bv1 11) S13)) (= X6 (bvadd (bvshl X4 S12) (bvshl (_ bv1 11) S13))))\n (and (shlok X4 S12) (bvugt (bvshl X4 S12) (bvshl (_ bv1 11) S13)) (= X6 (bvsub (bvshl X4 S12) (bvshl (_ bv1 11) S13))))\n (and (shlok X4 S13) (bvugt (bvshl (_ bv1 11) S12) (bvshl X4 S13)) (= X6 (bvsub (bvshl (_ bv1 11) S12) (bvshl X4 S13))))\n (and (bvugt S12 S13) (shlok X4 S12) (addok (bvshl X4 S12) (bvshl X4 S13)) (= X6 (bvadd (bvshl X4 S12) (bvshl X4 S13))))\n (and (bvugt S12 S13) (shlok X4 S12) (= X6 (bvsub (bvshl X4 S12) (bvshl X4 S13))))\n (and (shlok X4 S12) (shlok X5 S13) (addok (bvshl X4 S12) (bvshl X5 S13)) (= X6 (bvadd (bvshl X4 S12) (bvshl X5 S13))))\n (and (shlok X4 S12) (shlok X5 S13) (bvugt (bvshl X4 S12) (bvshl X5 S13)) (= X6 (bvsub (bvshl X4 S12) (bvshl X5 S13))))\n (and (shlok X5 S12) (shlok X4 S13) (bvugt (bvshl X5 S12) (bvshl X4 S13)) (= X6 (bvsub (bvshl X5 S12) (bvshl X4 S13))))\n (and (shlok X5 S12) (addok (bvshl X5 S12) (bvshl (_ bv1 11) S13)) (= X6 (bvadd (bvshl X5 S12) (bvshl (_ bv1 11) S13))))\n (and (shlok X5 S12) (bvugt (bvshl X5 S12) (bvshl (_ bv1 11) S13)) (= X6 (bvsub (bvshl X5 S12) (bvshl (_ bv1 11) S13))))\n (and (shlok X5 S13) (bvugt (bvshl (_ bv1 11) S12) (bvshl X5 S13)) (= X6 (bvsub (bvshl (_ bv1 11) S12) (bvshl X5 S13))))\n (and (bvugt S12 S13) (shlok X5 S12) (addok (bvshl X5 S12) (bvshl X5 S13)) (= X6 (bvadd (bvshl X5 S12) (bvshl X5 S13))))\n (and (bvugt S12 S13) (shlok X5 S12) (= X6 (bvsub (bvshl X5 S12) (bvshl X5 S13))))\n))\n(assert (or\n (and (shlok X0 S14) (addok (bvshl X0 S14) (bvshl (_ bv1 11) S15)) (= X7 (bvadd (bvshl X0 S14) (bvshl (_ bv1 11) S15))))\n (and (shlok X0 S14) (bvugt (bvshl X0 S14) (bvshl (_ bv1 11) S15)) (= X7 (bvsub (bvshl X0 S14) (bvshl (_ bv1 11) S15))))\n (and (shlok X0 S15) (bvugt (bvshl (_ bv1 11) S14) (bvshl X0 S15)) (= X7 (bvsub (bvshl (_ bv1 11) S14) (bvshl X0 S15))))\n (and (bvugt S14 S15) (shlok X0 S14) (addok (bvshl X0 S14) (bvshl X0 S15)) (= X7 (bvadd (bvshl X0 S14) (bvshl X0 S15))))\n (and (bvugt S14 S15) (shlok X0 S14) (= X7 (bvsub (bvshl X0 S14) (bvshl X0 S15))))\n (and (shlok X0 S14) (shlok X1 S15) (addok (bvshl X0 S14) (bvshl X1 S15)) (= X7 (bvadd (bvshl X0 S14) (bvshl X1 S15))))\n (and (shlok X0 S14) (shlok X1 S15) (bvugt (bvshl X0 S14) (bvshl X1 S15)) (= X7 (bvsub (bvshl X0 S14) (bvshl X1 S15))))\n (and (shlok X1 S14) (shlok X0 S15) (bvugt (bvshl X1 S14) (bvshl X0 S15)) (= X7 (bvsub (bvshl X1 S14) (bvshl X0 S15))))\n (and (shlok X0 S14) (shlok X2 S15) (addok (bvshl X0 S14) (bvshl X2 S15)) (= X7 (bvadd (bvshl X0 S14) (bvshl X2 S15))))\n (and (shlok X0 S14) (shlok X2 S15) (bvugt (bvshl X0 S14) (bvshl X2 S15)) (= X7 (bvsub (bvshl X0 S14) (bvshl X2 S15))))\n (and (shlok X2 S14) (shlok X0 S15) (bvugt (bvshl X2 S14) (bvshl X0 S15)) (= X7 (bvsub (bvshl X2 S14) (bvshl X0 S15))))\n (and (shlok X0 S14) (shlok X3 S15) (addok (bvshl X0 S14) (bvshl X3 S15)) (= X7 (bvadd (bvshl X0 S14) (bvshl X3 S15))))\n (and (shlok X0 S14) (shlok X3 S15) (bvugt (bvshl X0 S14) (bvshl X3 S15)) (= X7 (bvsub (bvshl X0 S14) (bvshl X3 S15))))\n (and (shlok X3 S14) (shlok X0 S15) (bvugt (bvshl X3 S14) (bvshl X0 S15)) (= X7 (bvsub (bvshl X3 S14) (bvshl X0 S15))))\n (and (shlok X0 S14) (shlok X4 S15) (addok (bvshl X0 S14) (bvshl X4 S15)) (= X7 (bvadd (bvshl X0 S14) (bvshl X4 S15))))\n (and (shlok X0 S14) (shlok X4 S15) (bvugt (bvshl X0 S14) (bvshl X4 S15)) (= X7 (bvsub (bvshl X0 S14) (bvshl X4 S15))))\n (and (shlok X4 S14) (shlok X0 S15) (bvugt (bvshl X4 S14) (bvshl X0 S15)) (= X7 (bvsub (bvshl X4 S14) (bvshl X0 S15))))\n (and (shlok X0 S14) (shlok X5 S15) (addok (bvshl X0 S14) (bvshl X5 S15)) (= X7 (bvadd (bvshl X0 S14) (bvshl X5 S15))))\n (and (shlok X0 S14) (shlok X5 S15) (bvugt (bvshl X0 S14) (bvshl X5 S15)) (= X7 (bvsub (bvshl X0 S14) (bvshl X5 S15))))\n (and (shlok X5 S14) (shlok X0 S15) (bvugt (bvshl X5 S14) (bvshl X0 S15)) (= X7 (bvsub (bvshl X5 S14) (bvshl X0 S15))))\n (and (shlok X0 S14) (shlok X6 S15) (addok (bvshl X0 S14) (bvshl X6 S15)) (= X7 (bvadd (bvshl X0 S14) (bvshl X6 S15))))\n (and (shlok X0 S14) (shlok X6 S15) (bvugt (bvshl X0 S14) (bvshl X6 S15)) (= X7 (bvsub (bvshl X0 S14) (bvshl X6 S15))))\n (and (shlok X6 S14) (shlok X0 S15) (bvugt (bvshl X6 S14) (bvshl X0 S15)) (= X7 (bvsub (bvshl X6 S14) (bvshl X0 S15))))\n (and (shlok X1 S14) (addok (bvshl X1 S14) (bvshl (_ bv1 11) S15)) (= X7 (bvadd (bvshl X1 S14) (bvshl (_ bv1 11) S15))))\n (and (shlok X1 S14) (bvugt (bvshl X1 S14) (bvshl (_ bv1 11) S15)) (= X7 (bvsub (bvshl X1 S14) (bvshl (_ bv1 11) S15))))\n (and (shlok X1 S15) (bvugt (bvshl (_ bv1 11) S14) (bvshl X1 S15)) (= X7 (bvsub (bvshl (_ bv1 11) S14) (bvshl X1 S15))))\n (and (bvugt S14 S15) (shlok X1 S14) (addok (bvshl X1 S14) (bvshl X1 S15)) (= X7 (bvadd (bvshl X1 S14) (bvshl X1 S15))))\n (and (bvugt S14 S15) (shlok X1 S14) (= X7 (bvsub (bvshl X1 S14) (bvshl X1 S15))))\n (and (shlok X1 S14) (shlok X2 S15) (addok (bvshl X1 S14) (bvshl X2 S15)) (= X7 (bvadd (bvshl X1 S14) (bvshl X2 S15))))\n (and (shlok X1 S14) (shlok X2 S15) (bvugt (bvshl X1 S14) (bvshl X2 S15)) (= X7 (bvsub (bvshl X1 S14) (bvshl X2 S15))))\n (and (shlok X2 S14) (shlok X1 S15) (bvugt (bvshl X2 S14) (bvshl X1 S15)) (= X7 (bvsub (bvshl X2 S14) (bvshl X1 S15))))\n (and (shlok X1 S14) (shlok X3 S15) (addok (bvshl X1 S14) (bvshl X3 S15)) (= X7 (bvadd (bvshl X1 S14) (bvshl X3 S15))))\n (and (shlok X1 S14) (shlok X3 S15) (bvugt (bvshl X1 S14) (bvshl X3 S15)) (= X7 (bvsub (bvshl X1 S14) (bvshl X3 S15))))\n (and (shlok X3 S14) (shlok X1 S15) (bvugt (bvshl X3 S14) (bvshl X1 S15)) (= X7 (bvsub (bvshl X3 S14) (bvshl X1 S15))))\n (and (shlok X1 S14) (shlok X4 S15) (addok (bvshl X1 S14) (bvshl X4 S15)) (= X7 (bvadd (bvshl X1 S14) (bvshl X4 S15))))\n (and (shlok X1 S14) (shlok X4 S15) (bvugt (bvshl X1 S14) (bvshl X4 S15)) (= X7 (bvsub (bvshl X1 S14) (bvshl X4 S15))))\n (and (shlok X4 S14) (shlok X1 S15) (bvugt (bvshl X4 S14) (bvshl X1 S15)) (= X7 (bvsub (bvshl X4 S14) (bvshl X1 S15))))\n (and (shlok X1 S14) (shlok X5 S15) (addok (bvshl X1 S14) (bvshl X5 S15)) (= X7 (bvadd (bvshl X1 S14) (bvshl X5 S15))))\n (and (shlok X1 S14) (shlok X5 S15) (bvugt (bvshl X1 S14) (bvshl X5 S15)) (= X7 (bvsub (bvshl X1 S14) (bvshl X5 S15))))\n (and (shlok X5 S14) (shlok X1 S15) (bvugt (bvshl X5 S14) (bvshl X1 S15)) (= X7 (bvsub (bvshl X5 S14) (bvshl X1 S15))))\n (and (shlok X1 S14) (shlok X6 S15) (addok (bvshl X1 S14) (bvshl X6 S15)) (= X7 (bvadd (bvshl X1 S14) (bvshl X6 S15))))\n (and (shlok X1 S14) (shlok X6 S15) (bvugt (bvshl X1 S14) (bvshl X6 S15)) (= X7 (bvsub (bvshl X1 S14) (bvshl X6 S15))))\n (and (shlok X6 S14) (shlok X1 S15) (bvugt (bvshl X6 S14) (bvshl X1 S15)) (= X7 (bvsub (bvshl X6 S14) (bvshl X1 S15))))\n (and (shlok X2 S14) (addok (bvshl X2 S14) (bvshl (_ bv1 11) S15)) (= X7 (bvadd (bvshl X2 S14) (bvshl (_ bv1 11) S15))))\n (and (shlok X2 S14) (bvugt (bvshl X2 S14) (bvshl (_ bv1 11) S15)) (= X7 (bvsub (bvshl X2 S14) (bvshl (_ bv1 11) S15))))\n (and (shlok X2 S15) (bvugt (bvshl (_ bv1 11) S14) (bvshl X2 S15)) (= X7 (bvsub (bvshl (_ bv1 11) S14) (bvshl X2 S15))))\n (and (bvugt S14 S15) (shlok X2 S14) (addok (bvshl X2 S14) (bvshl X2 S15)) (= X7 (bvadd (bvshl X2 S14) (bvshl X2 S15))))\n (and (bvugt S14 S15) (shlok X2 S14) (= X7 (bvsub (bvshl X2 S14) (bvshl X2 S15))))\n (and (shlok X2 S14) (shlok X3 S15) (addok (bvshl X2 S14) (bvshl X3 S15)) (= X7 (bvadd (bvshl X2 S14) (bvshl X3 S15))))\n (and (shlok X2 S14) (shlok X3 S15) (bvugt (bvshl X2 S14) (bvshl X3 S15)) (= X7 (bvsub (bvshl X2 S14) (bvshl X3 S15))))\n (and (shlok X3 S14) (shlok X2 S15) (bvugt (bvshl X3 S14) (bvshl X2 S15)) (= X7 (bvsub (bvshl X3 S14) (bvshl X2 S15))))\n (and (shlok X2 S14) (shlok X4 S15) (addok (bvshl X2 S14) (bvshl X4 S15)) (= X7 (bvadd (bvshl X2 S14) (bvshl X4 S15))))\n (and (shlok X2 S14) (shlok X4 S15) (bvugt (bvshl X2 S14) (bvshl X4 S15)) (= X7 (bvsub (bvshl X2 S14) (bvshl X4 S15))))\n (and (shlok X4 S14) (shlok X2 S15) (bvugt (bvshl X4 S14) (bvshl X2 S15)) (= X7 (bvsub (bvshl X4 S14) (bvshl X2 S15))))\n (and (shlok X2 S14) (shlok X5 S15) (addok (bvshl X2 S14) (bvshl X5 S15)) (= X7 (bvadd (bvshl X2 S14) (bvshl X5 S15))))\n (and (shlok X2 S14) (shlok X5 S15) (bvugt (bvshl X2 S14) (bvshl X5 S15)) (= X7 (bvsub (bvshl X2 S14) (bvshl X5 S15))))\n (and (shlok X5 S14) (shlok X2 S15) (bvugt (bvshl X5 S14) (bvshl X2 S15)) (= X7 (bvsub (bvshl X5 S14) (bvshl X2 S15))))\n (and (shlok X2 S14) (shlok X6 S15) (addok (bvshl X2 S14) (bvshl X6 S15)) (= X7 (bvadd (bvshl X2 S14) (bvshl X6 S15))))\n (and (shlok X2 S14) (shlok X6 S15) (bvugt (bvshl X2 S14) (bvshl X6 S15)) (= X7 (bvsub (bvshl X2 S14) (bvshl X6 S15))))\n (and (shlok X6 S14) (shlok X2 S15) (bvugt (bvshl X6 S14) (bvshl X2 S15)) (= X7 (bvsub (bvshl X6 S14) (bvshl X2 S15))))\n (and (shlok X3 S14) (addok (bvshl X3 S14) (bvshl (_ bv1 11) S15)) (= X7 (bvadd (bvshl X3 S14) (bvshl (_ bv1 11) S15))))\n (and (shlok X3 S14) (bvugt (bvshl X3 S14) (bvshl (_ bv1 11) S15)) (= X7 (bvsub (bvshl X3 S14) (bvshl (_ bv1 11) S15))))\n (and (shlok X3 S15) (bvugt (bvshl (_ bv1 11) S14) (bvshl X3 S15)) (= X7 (bvsub (bvshl (_ bv1 11) S14) (bvshl X3 S15))))\n (and (bvugt S14 S15) (shlok X3 S14) (addok (bvshl X3 S14) (bvshl X3 S15)) (= X7 (bvadd (bvshl X3 S14) (bvshl X3 S15))))\n (and (bvugt S14 S15) (shlok X3 S14) (= X7 (bvsub (bvshl X3 S14) (bvshl X3 S15))))\n (and (shlok X3 S14) (shlok X4 S15) (addok (bvshl X3 S14) (bvshl X4 S15)) (= X7 (bvadd (bvshl X3 S14) (bvshl X4 S15))))\n (and (shlok X3 S14) (shlok X4 S15) (bvugt (bvshl X3 S14) (bvshl X4 S15)) (= X7 (bvsub (bvshl X3 S14) (bvshl X4 S15))))\n (and (shlok X4 S14) (shlok X3 S15) (bvugt (bvshl X4 S14) (bvshl X3 S15)) (= X7 (bvsub (bvshl X4 S14) (bvshl X3 S15))))\n (and (shlok X3 S14) (shlok X5 S15) (addok (bvshl X3 S14) (bvshl X5 S15)) (= X7 (bvadd (bvshl X3 S14) (bvshl X5 S15))))\n (and (shlok X3 S14) (shlok X5 S15) (bvugt (bvshl X3 S14) (bvshl X5 S15)) (= X7 (bvsub (bvshl X3 S14) (bvshl X5 S15))))\n (and (shlok X5 S14) (shlok X3 S15) (bvugt (bvshl X5 S14) (bvshl X3 S15)) (= X7 (bvsub (bvshl X5 S14) (bvshl X3 S15))))\n (and (shlok X3 S14) (shlok X6 S15) (addok (bvshl X3 S14) (bvshl X6 S15)) (= X7 (bvadd (bvshl X3 S14) (bvshl X6 S15))))\n (and (shlok X3 S14) (shlok X6 S15) (bvugt (bvshl X3 S14) (bvshl X6 S15)) (= X7 (bvsub (bvshl X3 S14) (bvshl X6 S15))))\n (and (shlok X6 S14) (shlok X3 S15) (bvugt (bvshl X6 S14) (bvshl X3 S15)) (= X7 (bvsub (bvshl X6 S14) (bvshl X3 S15))))\n (and (shlok X4 S14) (addok (bvshl X4 S14) (bvshl (_ bv1 11) S15)) (= X7 (bvadd (bvshl X4 S14) (bvshl (_ bv1 11) S15))))\n (and (shlok X4 S14) (bvugt (bvshl X4 S14) (bvshl (_ bv1 11) S15)) (= X7 (bvsub (bvshl X4 S14) (bvshl (_ bv1 11) S15))))\n (and (shlok X4 S15) (bvugt (bvshl (_ bv1 11) S14) (bvshl X4 S15)) (= X7 (bvsub (bvshl (_ bv1 11) S14) (bvshl X4 S15))))\n (and (bvugt S14 S15) (shlok X4 S14) (addok (bvshl X4 S14) (bvshl X4 S15)) (= X7 (bvadd (bvshl X4 S14) (bvshl X4 S15))))\n (and (bvugt S14 S15) (shlok X4 S14) (= X7 (bvsub (bvshl X4 S14) (bvshl X4 S15))))\n (and (shlok X4 S14) (shlok X5 S15) (addok (bvshl X4 S14) (bvshl X5 S15)) (= X7 (bvadd (bvshl X4 S14) (bvshl X5 S15))))\n (and (shlok X4 S14) (shlok X5 S15) (bvugt (bvshl X4 S14) (bvshl X5 S15)) (= X7 (bvsub (bvshl X4 S14) (bvshl X5 S15))))\n (and (shlok X5 S14) (shlok X4 S15) (bvugt (bvshl X5 S14) (bvshl X4 S15)) (= X7 (bvsub (bvshl X5 S14) (bvshl X4 S15))))\n (and (shlok X4 S14) (shlok X6 S15) (addok (bvshl X4 S14) (bvshl X6 S15)) (= X7 (bvadd (bvshl X4 S14) (bvshl X6 S15))))\n (and (shlok X4 S14) (shlok X6 S15) (bvugt (bvshl X4 S14) (bvshl X6 S15)) (= X7 (bvsub (bvshl X4 S14) (bvshl X6 S15))))\n (and (shlok X6 S14) (shlok X4 S15) (bvugt (bvshl X6 S14) (bvshl X4 S15)) (= X7 (bvsub (bvshl X6 S14) (bvshl X4 S15))))\n (and (shlok X5 S14) (addok (bvshl X5 S14) (bvshl (_ bv1 11) S15)) (= X7 (bvadd (bvshl X5 S14) (bvshl (_ bv1 11) S15))))\n (and (shlok X5 S14) (bvugt (bvshl X5 S14) (bvshl (_ bv1 11) S15)) (= X7 (bvsub (bvshl X5 S14) (bvshl (_ bv1 11) S15))))\n (and (shlok X5 S15) (bvugt (bvshl (_ bv1 11) S14) (bvshl X5 S15)) (= X7 (bvsub (bvshl (_ bv1 11) S14) (bvshl X5 S15))))\n (and (bvugt S14 S15) (shlok X5 S14) (addok (bvshl X5 S14) (bvshl X5 S15)) (= X7 (bvadd (bvshl X5 S14) (bvshl X5 S15))))\n (and (bvugt S14 S15) (shlok X5 S14) (= X7 (bvsub (bvshl X5 S14) (bvshl X5 S15))))\n (and (shlok X5 S14) (shlok X6 S15) (addok (bvshl X5 S14) (bvshl X6 S15)) (= X7 (bvadd (bvshl X5 S14) (bvshl X6 S15))))\n (and (shlok X5 S14) (shlok X6 S15) (bvugt (bvshl X5 S14) (bvshl X6 S15)) (= X7 (bvsub (bvshl X5 S14) (bvshl X6 S15))))\n (and (shlok X6 S14) (shlok X5 S15) (bvugt (bvshl X6 S14) (bvshl X5 S15)) (= X7 (bvsub (bvshl X6 S14) (bvshl X5 S15))))\n (and (shlok X6 S14) (addok (bvshl X6 S14) (bvshl (_ bv1 11) S15)) (= X7 (bvadd (bvshl X6 S14) (bvshl (_ bv1 11) S15))))\n (and (shlok X6 S14) (bvugt (bvshl X6 S14) (bvshl (_ bv1 11) S15)) (= X7 (bvsub (bvshl X6 S14) (bvshl (_ bv1 11) S15))))\n (and (shlok X6 S15) (bvugt (bvshl (_ bv1 11) S14) (bvshl X6 S15)) (= X7 (bvsub (bvshl (_ bv1 11) S14) (bvshl X6 S15))))\n (and (bvugt S14 S15) (shlok X6 S14) (addok (bvshl X6 S14) (bvshl X6 S15)) (= X7 (bvadd (bvshl X6 S14) (bvshl X6 S15))))\n (and (bvugt S14 S15) (shlok X6 S14) (= X7 (bvsub (bvshl X6 S14) (bvshl X6 S15))))\n))\n(assert (or\n (and (shlok X0 S16) (addok (bvshl X0 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvadd (bvshl X0 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X0 S16) (bvugt (bvshl X0 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvsub (bvshl X0 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X0 S17) (bvugt (bvshl (_ bv1 11) S16) (bvshl X0 S17)) (= X8 (bvsub (bvshl (_ bv1 11) S16) (bvshl X0 S17))))\n (and (bvugt S16 S17) (shlok X0 S16) (addok (bvshl X0 S16) (bvshl X0 S17)) (= X8 (bvadd (bvshl X0 S16) (bvshl X0 S17))))\n (and (bvugt S16 S17) (shlok X0 S16) (= X8 (bvsub (bvshl X0 S16) (bvshl X0 S17))))\n (and (shlok X0 S16) (shlok X1 S17) (addok (bvshl X0 S16) (bvshl X1 S17)) (= X8 (bvadd (bvshl X0 S16) (bvshl X1 S17))))\n (and (shlok X0 S16) (shlok X1 S17) (bvugt (bvshl X0 S16) (bvshl X1 S17)) (= X8 (bvsub (bvshl X0 S16) (bvshl X1 S17))))\n (and (shlok X1 S16) (shlok X0 S17) (bvugt (bvshl X1 S16) (bvshl X0 S17)) (= X8 (bvsub (bvshl X1 S16) (bvshl X0 S17))))\n (and (shlok X0 S16) (shlok X2 S17) (addok (bvshl X0 S16) (bvshl X2 S17)) (= X8 (bvadd (bvshl X0 S16) (bvshl X2 S17))))\n (and (shlok X0 S16) (shlok X2 S17) (bvugt (bvshl X0 S16) (bvshl X2 S17)) (= X8 (bvsub (bvshl X0 S16) (bvshl X2 S17))))\n (and (shlok X2 S16) (shlok X0 S17) (bvugt (bvshl X2 S16) (bvshl X0 S17)) (= X8 (bvsub (bvshl X2 S16) (bvshl X0 S17))))\n (and (shlok X0 S16) (shlok X3 S17) (addok (bvshl X0 S16) (bvshl X3 S17)) (= X8 (bvadd (bvshl X0 S16) (bvshl X3 S17))))\n (and (shlok X0 S16) (shlok X3 S17) (bvugt (bvshl X0 S16) (bvshl X3 S17)) (= X8 (bvsub (bvshl X0 S16) (bvshl X3 S17))))\n (and (shlok X3 S16) (shlok X0 S17) (bvugt (bvshl X3 S16) (bvshl X0 S17)) (= X8 (bvsub (bvshl X3 S16) (bvshl X0 S17))))\n (and (shlok X0 S16) (shlok X4 S17) (addok (bvshl X0 S16) (bvshl X4 S17)) (= X8 (bvadd (bvshl X0 S16) (bvshl X4 S17))))\n (and (shlok X0 S16) (shlok X4 S17) (bvugt (bvshl X0 S16) (bvshl X4 S17)) (= X8 (bvsub (bvshl X0 S16) (bvshl X4 S17))))\n (and (shlok X4 S16) (shlok X0 S17) (bvugt (bvshl X4 S16) (bvshl X0 S17)) (= X8 (bvsub (bvshl X4 S16) (bvshl X0 S17))))\n (and (shlok X0 S16) (shlok X5 S17) (addok (bvshl X0 S16) (bvshl X5 S17)) (= X8 (bvadd (bvshl X0 S16) (bvshl X5 S17))))\n (and (shlok X0 S16) (shlok X5 S17) (bvugt (bvshl X0 S16) (bvshl X5 S17)) (= X8 (bvsub (bvshl X0 S16) (bvshl X5 S17))))\n (and (shlok X5 S16) (shlok X0 S17) (bvugt (bvshl X5 S16) (bvshl X0 S17)) (= X8 (bvsub (bvshl X5 S16) (bvshl X0 S17))))\n (and (shlok X0 S16) (shlok X6 S17) (addok (bvshl X0 S16) (bvshl X6 S17)) (= X8 (bvadd (bvshl X0 S16) (bvshl X6 S17))))\n (and (shlok X0 S16) (shlok X6 S17) (bvugt (bvshl X0 S16) (bvshl X6 S17)) (= X8 (bvsub (bvshl X0 S16) (bvshl X6 S17))))\n (and (shlok X6 S16) (shlok X0 S17) (bvugt (bvshl X6 S16) (bvshl X0 S17)) (= X8 (bvsub (bvshl X6 S16) (bvshl X0 S17))))\n (and (shlok X0 S16) (shlok X7 S17) (addok (bvshl X0 S16) (bvshl X7 S17)) (= X8 (bvadd (bvshl X0 S16) (bvshl X7 S17))))\n (and (shlok X0 S16) (shlok X7 S17) (bvugt (bvshl X0 S16) (bvshl X7 S17)) (= X8 (bvsub (bvshl X0 S16) (bvshl X7 S17))))\n (and (shlok X7 S16) (shlok X0 S17) (bvugt (bvshl X7 S16) (bvshl X0 S17)) (= X8 (bvsub (bvshl X7 S16) (bvshl X0 S17))))\n (and (shlok X1 S16) (addok (bvshl X1 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvadd (bvshl X1 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X1 S16) (bvugt (bvshl X1 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvsub (bvshl X1 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X1 S17) (bvugt (bvshl (_ bv1 11) S16) (bvshl X1 S17)) (= X8 (bvsub (bvshl (_ bv1 11) S16) (bvshl X1 S17))))\n (and (bvugt S16 S17) (shlok X1 S16) (addok (bvshl X1 S16) (bvshl X1 S17)) (= X8 (bvadd (bvshl X1 S16) (bvshl X1 S17))))\n (and (bvugt S16 S17) (shlok X1 S16) (= X8 (bvsub (bvshl X1 S16) (bvshl X1 S17))))\n (and (shlok X1 S16) (shlok X2 S17) (addok (bvshl X1 S16) (bvshl X2 S17)) (= X8 (bvadd (bvshl X1 S16) (bvshl X2 S17))))\n (and (shlok X1 S16) (shlok X2 S17) (bvugt (bvshl X1 S16) (bvshl X2 S17)) (= X8 (bvsub (bvshl X1 S16) (bvshl X2 S17))))\n (and (shlok X2 S16) (shlok X1 S17) (bvugt (bvshl X2 S16) (bvshl X1 S17)) (= X8 (bvsub (bvshl X2 S16) (bvshl X1 S17))))\n (and (shlok X1 S16) (shlok X3 S17) (addok (bvshl X1 S16) (bvshl X3 S17)) (= X8 (bvadd (bvshl X1 S16) (bvshl X3 S17))))\n (and (shlok X1 S16) (shlok X3 S17) (bvugt (bvshl X1 S16) (bvshl X3 S17)) (= X8 (bvsub (bvshl X1 S16) (bvshl X3 S17))))\n (and (shlok X3 S16) (shlok X1 S17) (bvugt (bvshl X3 S16) (bvshl X1 S17)) (= X8 (bvsub (bvshl X3 S16) (bvshl X1 S17))))\n (and (shlok X1 S16) (shlok X4 S17) (addok (bvshl X1 S16) (bvshl X4 S17)) (= X8 (bvadd (bvshl X1 S16) (bvshl X4 S17))))\n (and (shlok X1 S16) (shlok X4 S17) (bvugt (bvshl X1 S16) (bvshl X4 S17)) (= X8 (bvsub (bvshl X1 S16) (bvshl X4 S17))))\n (and (shlok X4 S16) (shlok X1 S17) (bvugt (bvshl X4 S16) (bvshl X1 S17)) (= X8 (bvsub (bvshl X4 S16) (bvshl X1 S17))))\n (and (shlok X1 S16) (shlok X5 S17) (addok (bvshl X1 S16) (bvshl X5 S17)) (= X8 (bvadd (bvshl X1 S16) (bvshl X5 S17))))\n (and (shlok X1 S16) (shlok X5 S17) (bvugt (bvshl X1 S16) (bvshl X5 S17)) (= X8 (bvsub (bvshl X1 S16) (bvshl X5 S17))))\n (and (shlok X5 S16) (shlok X1 S17) (bvugt (bvshl X5 S16) (bvshl X1 S17)) (= X8 (bvsub (bvshl X5 S16) (bvshl X1 S17))))\n (and (shlok X1 S16) (shlok X6 S17) (addok (bvshl X1 S16) (bvshl X6 S17)) (= X8 (bvadd (bvshl X1 S16) (bvshl X6 S17))))\n (and (shlok X1 S16) (shlok X6 S17) (bvugt (bvshl X1 S16) (bvshl X6 S17)) (= X8 (bvsub (bvshl X1 S16) (bvshl X6 S17))))\n (and (shlok X6 S16) (shlok X1 S17) (bvugt (bvshl X6 S16) (bvshl X1 S17)) (= X8 (bvsub (bvshl X6 S16) (bvshl X1 S17))))\n (and (shlok X1 S16) (shlok X7 S17) (addok (bvshl X1 S16) (bvshl X7 S17)) (= X8 (bvadd (bvshl X1 S16) (bvshl X7 S17))))\n (and (shlok X1 S16) (shlok X7 S17) (bvugt (bvshl X1 S16) (bvshl X7 S17)) (= X8 (bvsub (bvshl X1 S16) (bvshl X7 S17))))\n (and (shlok X7 S16) (shlok X1 S17) (bvugt (bvshl X7 S16) (bvshl X1 S17)) (= X8 (bvsub (bvshl X7 S16) (bvshl X1 S17))))\n (and (shlok X2 S16) (addok (bvshl X2 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvadd (bvshl X2 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X2 S16) (bvugt (bvshl X2 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvsub (bvshl X2 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X2 S17) (bvugt (bvshl (_ bv1 11) S16) (bvshl X2 S17)) (= X8 (bvsub (bvshl (_ bv1 11) S16) (bvshl X2 S17))))\n (and (bvugt S16 S17) (shlok X2 S16) (addok (bvshl X2 S16) (bvshl X2 S17)) (= X8 (bvadd (bvshl X2 S16) (bvshl X2 S17))))\n (and (bvugt S16 S17) (shlok X2 S16) (= X8 (bvsub (bvshl X2 S16) (bvshl X2 S17))))\n (and (shlok X2 S16) (shlok X3 S17) (addok (bvshl X2 S16) (bvshl X3 S17)) (= X8 (bvadd (bvshl X2 S16) (bvshl X3 S17))))\n (and (shlok X2 S16) (shlok X3 S17) (bvugt (bvshl X2 S16) (bvshl X3 S17)) (= X8 (bvsub (bvshl X2 S16) (bvshl X3 S17))))\n (and (shlok X3 S16) (shlok X2 S17) (bvugt (bvshl X3 S16) (bvshl X2 S17)) (= X8 (bvsub (bvshl X3 S16) (bvshl X2 S17))))\n (and (shlok X2 S16) (shlok X4 S17) (addok (bvshl X2 S16) (bvshl X4 S17)) (= X8 (bvadd (bvshl X2 S16) (bvshl X4 S17))))\n (and (shlok X2 S16) (shlok X4 S17) (bvugt (bvshl X2 S16) (bvshl X4 S17)) (= X8 (bvsub (bvshl X2 S16) (bvshl X4 S17))))\n (and (shlok X4 S16) (shlok X2 S17) (bvugt (bvshl X4 S16) (bvshl X2 S17)) (= X8 (bvsub (bvshl X4 S16) (bvshl X2 S17))))\n (and (shlok X2 S16) (shlok X5 S17) (addok (bvshl X2 S16) (bvshl X5 S17)) (= X8 (bvadd (bvshl X2 S16) (bvshl X5 S17))))\n (and (shlok X2 S16) (shlok X5 S17) (bvugt (bvshl X2 S16) (bvshl X5 S17)) (= X8 (bvsub (bvshl X2 S16) (bvshl X5 S17))))\n (and (shlok X5 S16) (shlok X2 S17) (bvugt (bvshl X5 S16) (bvshl X2 S17)) (= X8 (bvsub (bvshl X5 S16) (bvshl X2 S17))))\n (and (shlok X2 S16) (shlok X6 S17) (addok (bvshl X2 S16) (bvshl X6 S17)) (= X8 (bvadd (bvshl X2 S16) (bvshl X6 S17))))\n (and (shlok X2 S16) (shlok X6 S17) (bvugt (bvshl X2 S16) (bvshl X6 S17)) (= X8 (bvsub (bvshl X2 S16) (bvshl X6 S17))))\n (and (shlok X6 S16) (shlok X2 S17) (bvugt (bvshl X6 S16) (bvshl X2 S17)) (= X8 (bvsub (bvshl X6 S16) (bvshl X2 S17))))\n (and (shlok X2 S16) (shlok X7 S17) (addok (bvshl X2 S16) (bvshl X7 S17)) (= X8 (bvadd (bvshl X2 S16) (bvshl X7 S17))))\n (and (shlok X2 S16) (shlok X7 S17) (bvugt (bvshl X2 S16) (bvshl X7 S17)) (= X8 (bvsub (bvshl X2 S16) (bvshl X7 S17))))\n (and (shlok X7 S16) (shlok X2 S17) (bvugt (bvshl X7 S16) (bvshl X2 S17)) (= X8 (bvsub (bvshl X7 S16) (bvshl X2 S17))))\n (and (shlok X3 S16) (addok (bvshl X3 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvadd (bvshl X3 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X3 S16) (bvugt (bvshl X3 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvsub (bvshl X3 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X3 S17) (bvugt (bvshl (_ bv1 11) S16) (bvshl X3 S17)) (= X8 (bvsub (bvshl (_ bv1 11) S16) (bvshl X3 S17))))\n (and (bvugt S16 S17) (shlok X3 S16) (addok (bvshl X3 S16) (bvshl X3 S17)) (= X8 (bvadd (bvshl X3 S16) (bvshl X3 S17))))\n (and (bvugt S16 S17) (shlok X3 S16) (= X8 (bvsub (bvshl X3 S16) (bvshl X3 S17))))\n (and (shlok X3 S16) (shlok X4 S17) (addok (bvshl X3 S16) (bvshl X4 S17)) (= X8 (bvadd (bvshl X3 S16) (bvshl X4 S17))))\n (and (shlok X3 S16) (shlok X4 S17) (bvugt (bvshl X3 S16) (bvshl X4 S17)) (= X8 (bvsub (bvshl X3 S16) (bvshl X4 S17))))\n (and (shlok X4 S16) (shlok X3 S17) (bvugt (bvshl X4 S16) (bvshl X3 S17)) (= X8 (bvsub (bvshl X4 S16) (bvshl X3 S17))))\n (and (shlok X3 S16) (shlok X5 S17) (addok (bvshl X3 S16) (bvshl X5 S17)) (= X8 (bvadd (bvshl X3 S16) (bvshl X5 S17))))\n (and (shlok X3 S16) (shlok X5 S17) (bvugt (bvshl X3 S16) (bvshl X5 S17)) (= X8 (bvsub (bvshl X3 S16) (bvshl X5 S17))))\n (and (shlok X5 S16) (shlok X3 S17) (bvugt (bvshl X5 S16) (bvshl X3 S17)) (= X8 (bvsub (bvshl X5 S16) (bvshl X3 S17))))\n (and (shlok X3 S16) (shlok X6 S17) (addok (bvshl X3 S16) (bvshl X6 S17)) (= X8 (bvadd (bvshl X3 S16) (bvshl X6 S17))))\n (and (shlok X3 S16) (shlok X6 S17) (bvugt (bvshl X3 S16) (bvshl X6 S17)) (= X8 (bvsub (bvshl X3 S16) (bvshl X6 S17))))\n (and (shlok X6 S16) (shlok X3 S17) (bvugt (bvshl X6 S16) (bvshl X3 S17)) (= X8 (bvsub (bvshl X6 S16) (bvshl X3 S17))))\n (and (shlok X3 S16) (shlok X7 S17) (addok (bvshl X3 S16) (bvshl X7 S17)) (= X8 (bvadd (bvshl X3 S16) (bvshl X7 S17))))\n (and (shlok X3 S16) (shlok X7 S17) (bvugt (bvshl X3 S16) (bvshl X7 S17)) (= X8 (bvsub (bvshl X3 S16) (bvshl X7 S17))))\n (and (shlok X7 S16) (shlok X3 S17) (bvugt (bvshl X7 S16) (bvshl X3 S17)) (= X8 (bvsub (bvshl X7 S16) (bvshl X3 S17))))\n (and (shlok X4 S16) (addok (bvshl X4 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvadd (bvshl X4 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X4 S16) (bvugt (bvshl X4 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvsub (bvshl X4 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X4 S17) (bvugt (bvshl (_ bv1 11) S16) (bvshl X4 S17)) (= X8 (bvsub (bvshl (_ bv1 11) S16) (bvshl X4 S17))))\n (and (bvugt S16 S17) (shlok X4 S16) (addok (bvshl X4 S16) (bvshl X4 S17)) (= X8 (bvadd (bvshl X4 S16) (bvshl X4 S17))))\n (and (bvugt S16 S17) (shlok X4 S16) (= X8 (bvsub (bvshl X4 S16) (bvshl X4 S17))))\n (and (shlok X4 S16) (shlok X5 S17) (addok (bvshl X4 S16) (bvshl X5 S17)) (= X8 (bvadd (bvshl X4 S16) (bvshl X5 S17))))\n (and (shlok X4 S16) (shlok X5 S17) (bvugt (bvshl X4 S16) (bvshl X5 S17)) (= X8 (bvsub (bvshl X4 S16) (bvshl X5 S17))))\n (and (shlok X5 S16) (shlok X4 S17) (bvugt (bvshl X5 S16) (bvshl X4 S17)) (= X8 (bvsub (bvshl X5 S16) (bvshl X4 S17))))\n (and (shlok X4 S16) (shlok X6 S17) (addok (bvshl X4 S16) (bvshl X6 S17)) (= X8 (bvadd (bvshl X4 S16) (bvshl X6 S17))))\n (and (shlok X4 S16) (shlok X6 S17) (bvugt (bvshl X4 S16) (bvshl X6 S17)) (= X8 (bvsub (bvshl X4 S16) (bvshl X6 S17))))\n (and (shlok X6 S16) (shlok X4 S17) (bvugt (bvshl X6 S16) (bvshl X4 S17)) (= X8 (bvsub (bvshl X6 S16) (bvshl X4 S17))))\n (and (shlok X4 S16) (shlok X7 S17) (addok (bvshl X4 S16) (bvshl X7 S17)) (= X8 (bvadd (bvshl X4 S16) (bvshl X7 S17))))\n (and (shlok X4 S16) (shlok X7 S17) (bvugt (bvshl X4 S16) (bvshl X7 S17)) (= X8 (bvsub (bvshl X4 S16) (bvshl X7 S17))))\n (and (shlok X7 S16) (shlok X4 S17) (bvugt (bvshl X7 S16) (bvshl X4 S17)) (= X8 (bvsub (bvshl X7 S16) (bvshl X4 S17))))\n (and (shlok X5 S16) (addok (bvshl X5 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvadd (bvshl X5 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X5 S16) (bvugt (bvshl X5 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvsub (bvshl X5 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X5 S17) (bvugt (bvshl (_ bv1 11) S16) (bvshl X5 S17)) (= X8 (bvsub (bvshl (_ bv1 11) S16) (bvshl X5 S17))))\n (and (bvugt S16 S17) (shlok X5 S16) (addok (bvshl X5 S16) (bvshl X5 S17)) (= X8 (bvadd (bvshl X5 S16) (bvshl X5 S17))))\n (and (bvugt S16 S17) (shlok X5 S16) (= X8 (bvsub (bvshl X5 S16) (bvshl X5 S17))))\n (and (shlok X5 S16) (shlok X6 S17) (addok (bvshl X5 S16) (bvshl X6 S17)) (= X8 (bvadd (bvshl X5 S16) (bvshl X6 S17))))\n (and (shlok X5 S16) (shlok X6 S17) (bvugt (bvshl X5 S16) (bvshl X6 S17)) (= X8 (bvsub (bvshl X5 S16) (bvshl X6 S17))))\n (and (shlok X6 S16) (shlok X5 S17) (bvugt (bvshl X6 S16) (bvshl X5 S17)) (= X8 (bvsub (bvshl X6 S16) (bvshl X5 S17))))\n (and (shlok X5 S16) (shlok X7 S17) (addok (bvshl X5 S16) (bvshl X7 S17)) (= X8 (bvadd (bvshl X5 S16) (bvshl X7 S17))))\n (and (shlok X5 S16) (shlok X7 S17) (bvugt (bvshl X5 S16) (bvshl X7 S17)) (= X8 (bvsub (bvshl X5 S16) (bvshl X7 S17))))\n (and (shlok X7 S16) (shlok X5 S17) (bvugt (bvshl X7 S16) (bvshl X5 S17)) (= X8 (bvsub (bvshl X7 S16) (bvshl X5 S17))))\n (and (shlok X6 S16) (addok (bvshl X6 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvadd (bvshl X6 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X6 S16) (bvugt (bvshl X6 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvsub (bvshl X6 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X6 S17) (bvugt (bvshl (_ bv1 11) S16) (bvshl X6 S17)) (= X8 (bvsub (bvshl (_ bv1 11) S16) (bvshl X6 S17))))\n (and (bvugt S16 S17) (shlok X6 S16) (addok (bvshl X6 S16) (bvshl X6 S17)) (= X8 (bvadd (bvshl X6 S16) (bvshl X6 S17))))\n (and (bvugt S16 S17) (shlok X6 S16) (= X8 (bvsub (bvshl X6 S16) (bvshl X6 S17))))\n (and (shlok X6 S16) (shlok X7 S17) (addok (bvshl X6 S16) (bvshl X7 S17)) (= X8 (bvadd (bvshl X6 S16) (bvshl X7 S17))))\n (and (shlok X6 S16) (shlok X7 S17) (bvugt (bvshl X6 S16) (bvshl X7 S17)) (= X8 (bvsub (bvshl X6 S16) (bvshl X7 S17))))\n (and (shlok X7 S16) (shlok X6 S17) (bvugt (bvshl X7 S16) (bvshl X6 S17)) (= X8 (bvsub (bvshl X7 S16) (bvshl X6 S17))))\n (and (shlok X7 S16) (addok (bvshl X7 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvadd (bvshl X7 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X7 S16) (bvugt (bvshl X7 S16) (bvshl (_ bv1 11) S17)) (= X8 (bvsub (bvshl X7 S16) (bvshl (_ bv1 11) S17))))\n (and (shlok X7 S17) (bvugt (bvshl (_ bv1 11) S16) (bvshl X7 S17)) (= X8 (bvsub (bvshl (_ bv1 11) S16) (bvshl X7 S17))))\n (and (bvugt S16 S17) (shlok X7 S16) (addok (bvshl X7 S16) (bvshl X7 S17)) (= X8 (bvadd (bvshl X7 S16) (bvshl X7 S17))))\n (and (bvugt S16 S17) (shlok X7 S16) (= X8 (bvsub (bvshl X7 S16) (bvshl X7 S17))))\n))\n(assert (or\n (and (shlok X0 S18) (addok (bvshl X0 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvadd (bvshl X0 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X0 S18) (bvugt (bvshl X0 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvsub (bvshl X0 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X0 S19) (bvugt (bvshl (_ bv1 11) S18) (bvshl X0 S19)) (= X9 (bvsub (bvshl (_ bv1 11) S18) (bvshl X0 S19))))\n (and (bvugt S18 S19) (shlok X0 S18) (addok (bvshl X0 S18) (bvshl X0 S19)) (= X9 (bvadd (bvshl X0 S18) (bvshl X0 S19))))\n (and (bvugt S18 S19) (shlok X0 S18) (= X9 (bvsub (bvshl X0 S18) (bvshl X0 S19))))\n (and (shlok X0 S18) (shlok X1 S19) (addok (bvshl X0 S18) (bvshl X1 S19)) (= X9 (bvadd (bvshl X0 S18) (bvshl X1 S19))))\n (and (shlok X0 S18) (shlok X1 S19) (bvugt (bvshl X0 S18) (bvshl X1 S19)) (= X9 (bvsub (bvshl X0 S18) (bvshl X1 S19))))\n (and (shlok X1 S18) (shlok X0 S19) (bvugt (bvshl X1 S18) (bvshl X0 S19)) (= X9 (bvsub (bvshl X1 S18) (bvshl X0 S19))))\n (and (shlok X0 S18) (shlok X2 S19) (addok (bvshl X0 S18) (bvshl X2 S19)) (= X9 (bvadd (bvshl X0 S18) (bvshl X2 S19))))\n (and (shlok X0 S18) (shlok X2 S19) (bvugt (bvshl X0 S18) (bvshl X2 S19)) (= X9 (bvsub (bvshl X0 S18) (bvshl X2 S19))))\n (and (shlok X2 S18) (shlok X0 S19) (bvugt (bvshl X2 S18) (bvshl X0 S19)) (= X9 (bvsub (bvshl X2 S18) (bvshl X0 S19))))\n (and (shlok X0 S18) (shlok X3 S19) (addok (bvshl X0 S18) (bvshl X3 S19)) (= X9 (bvadd (bvshl X0 S18) (bvshl X3 S19))))\n (and (shlok X0 S18) (shlok X3 S19) (bvugt (bvshl X0 S18) (bvshl X3 S19)) (= X9 (bvsub (bvshl X0 S18) (bvshl X3 S19))))\n (and (shlok X3 S18) (shlok X0 S19) (bvugt (bvshl X3 S18) (bvshl X0 S19)) (= X9 (bvsub (bvshl X3 S18) (bvshl X0 S19))))\n (and (shlok X0 S18) (shlok X4 S19) (addok (bvshl X0 S18) (bvshl X4 S19)) (= X9 (bvadd (bvshl X0 S18) (bvshl X4 S19))))\n (and (shlok X0 S18) (shlok X4 S19) (bvugt (bvshl X0 S18) (bvshl X4 S19)) (= X9 (bvsub (bvshl X0 S18) (bvshl X4 S19))))\n (and (shlok X4 S18) (shlok X0 S19) (bvugt (bvshl X4 S18) (bvshl X0 S19)) (= X9 (bvsub (bvshl X4 S18) (bvshl X0 S19))))\n (and (shlok X0 S18) (shlok X5 S19) (addok (bvshl X0 S18) (bvshl X5 S19)) (= X9 (bvadd (bvshl X0 S18) (bvshl X5 S19))))\n (and (shlok X0 S18) (shlok X5 S19) (bvugt (bvshl X0 S18) (bvshl X5 S19)) (= X9 (bvsub (bvshl X0 S18) (bvshl X5 S19))))\n (and (shlok X5 S18) (shlok X0 S19) (bvugt (bvshl X5 S18) (bvshl X0 S19)) (= X9 (bvsub (bvshl X5 S18) (bvshl X0 S19))))\n (and (shlok X0 S18) (shlok X6 S19) (addok (bvshl X0 S18) (bvshl X6 S19)) (= X9 (bvadd (bvshl X0 S18) (bvshl X6 S19))))\n (and (shlok X0 S18) (shlok X6 S19) (bvugt (bvshl X0 S18) (bvshl X6 S19)) (= X9 (bvsub (bvshl X0 S18) (bvshl X6 S19))))\n (and (shlok X6 S18) (shlok X0 S19) (bvugt (bvshl X6 S18) (bvshl X0 S19)) (= X9 (bvsub (bvshl X6 S18) (bvshl X0 S19))))\n (and (shlok X0 S18) (shlok X7 S19) (addok (bvshl X0 S18) (bvshl X7 S19)) (= X9 (bvadd (bvshl X0 S18) (bvshl X7 S19))))\n (and (shlok X0 S18) (shlok X7 S19) (bvugt (bvshl X0 S18) (bvshl X7 S19)) (= X9 (bvsub (bvshl X0 S18) (bvshl X7 S19))))\n (and (shlok X7 S18) (shlok X0 S19) (bvugt (bvshl X7 S18) (bvshl X0 S19)) (= X9 (bvsub (bvshl X7 S18) (bvshl X0 S19))))\n (and (shlok X0 S18) (shlok X8 S19) (addok (bvshl X0 S18) (bvshl X8 S19)) (= X9 (bvadd (bvshl X0 S18) (bvshl X8 S19))))\n (and (shlok X0 S18) (shlok X8 S19) (bvugt (bvshl X0 S18) (bvshl X8 S19)) (= X9 (bvsub (bvshl X0 S18) (bvshl X8 S19))))\n (and (shlok X8 S18) (shlok X0 S19) (bvugt (bvshl X8 S18) (bvshl X0 S19)) (= X9 (bvsub (bvshl X8 S18) (bvshl X0 S19))))\n (and (shlok X1 S18) (addok (bvshl X1 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvadd (bvshl X1 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X1 S18) (bvugt (bvshl X1 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvsub (bvshl X1 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X1 S19) (bvugt (bvshl (_ bv1 11) S18) (bvshl X1 S19)) (= X9 (bvsub (bvshl (_ bv1 11) S18) (bvshl X1 S19))))\n (and (bvugt S18 S19) (shlok X1 S18) (addok (bvshl X1 S18) (bvshl X1 S19)) (= X9 (bvadd (bvshl X1 S18) (bvshl X1 S19))))\n (and (bvugt S18 S19) (shlok X1 S18) (= X9 (bvsub (bvshl X1 S18) (bvshl X1 S19))))\n (and (shlok X1 S18) (shlok X2 S19) (addok (bvshl X1 S18) (bvshl X2 S19)) (= X9 (bvadd (bvshl X1 S18) (bvshl X2 S19))))\n (and (shlok X1 S18) (shlok X2 S19) (bvugt (bvshl X1 S18) (bvshl X2 S19)) (= X9 (bvsub (bvshl X1 S18) (bvshl X2 S19))))\n (and (shlok X2 S18) (shlok X1 S19) (bvugt (bvshl X2 S18) (bvshl X1 S19)) (= X9 (bvsub (bvshl X2 S18) (bvshl X1 S19))))\n (and (shlok X1 S18) (shlok X3 S19) (addok (bvshl X1 S18) (bvshl X3 S19)) (= X9 (bvadd (bvshl X1 S18) (bvshl X3 S19))))\n (and (shlok X1 S18) (shlok X3 S19) (bvugt (bvshl X1 S18) (bvshl X3 S19)) (= X9 (bvsub (bvshl X1 S18) (bvshl X3 S19))))\n (and (shlok X3 S18) (shlok X1 S19) (bvugt (bvshl X3 S18) (bvshl X1 S19)) (= X9 (bvsub (bvshl X3 S18) (bvshl X1 S19))))\n (and (shlok X1 S18) (shlok X4 S19) (addok (bvshl X1 S18) (bvshl X4 S19)) (= X9 (bvadd (bvshl X1 S18) (bvshl X4 S19))))\n (and (shlok X1 S18) (shlok X4 S19) (bvugt (bvshl X1 S18) (bvshl X4 S19)) (= X9 (bvsub (bvshl X1 S18) (bvshl X4 S19))))\n (and (shlok X4 S18) (shlok X1 S19) (bvugt (bvshl X4 S18) (bvshl X1 S19)) (= X9 (bvsub (bvshl X4 S18) (bvshl X1 S19))))\n (and (shlok X1 S18) (shlok X5 S19) (addok (bvshl X1 S18) (bvshl X5 S19)) (= X9 (bvadd (bvshl X1 S18) (bvshl X5 S19))))\n (and (shlok X1 S18) (shlok X5 S19) (bvugt (bvshl X1 S18) (bvshl X5 S19)) (= X9 (bvsub (bvshl X1 S18) (bvshl X5 S19))))\n (and (shlok X5 S18) (shlok X1 S19) (bvugt (bvshl X5 S18) (bvshl X1 S19)) (= X9 (bvsub (bvshl X5 S18) (bvshl X1 S19))))\n (and (shlok X1 S18) (shlok X6 S19) (addok (bvshl X1 S18) (bvshl X6 S19)) (= X9 (bvadd (bvshl X1 S18) (bvshl X6 S19))))\n (and (shlok X1 S18) (shlok X6 S19) (bvugt (bvshl X1 S18) (bvshl X6 S19)) (= X9 (bvsub (bvshl X1 S18) (bvshl X6 S19))))\n (and (shlok X6 S18) (shlok X1 S19) (bvugt (bvshl X6 S18) (bvshl X1 S19)) (= X9 (bvsub (bvshl X6 S18) (bvshl X1 S19))))\n (and (shlok X1 S18) (shlok X7 S19) (addok (bvshl X1 S18) (bvshl X7 S19)) (= X9 (bvadd (bvshl X1 S18) (bvshl X7 S19))))\n (and (shlok X1 S18) (shlok X7 S19) (bvugt (bvshl X1 S18) (bvshl X7 S19)) (= X9 (bvsub (bvshl X1 S18) (bvshl X7 S19))))\n (and (shlok X7 S18) (shlok X1 S19) (bvugt (bvshl X7 S18) (bvshl X1 S19)) (= X9 (bvsub (bvshl X7 S18) (bvshl X1 S19))))\n (and (shlok X1 S18) (shlok X8 S19) (addok (bvshl X1 S18) (bvshl X8 S19)) (= X9 (bvadd (bvshl X1 S18) (bvshl X8 S19))))\n (and (shlok X1 S18) (shlok X8 S19) (bvugt (bvshl X1 S18) (bvshl X8 S19)) (= X9 (bvsub (bvshl X1 S18) (bvshl X8 S19))))\n (and (shlok X8 S18) (shlok X1 S19) (bvugt (bvshl X8 S18) (bvshl X1 S19)) (= X9 (bvsub (bvshl X8 S18) (bvshl X1 S19))))\n (and (shlok X2 S18) (addok (bvshl X2 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvadd (bvshl X2 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X2 S18) (bvugt (bvshl X2 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvsub (bvshl X2 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X2 S19) (bvugt (bvshl (_ bv1 11) S18) (bvshl X2 S19)) (= X9 (bvsub (bvshl (_ bv1 11) S18) (bvshl X2 S19))))\n (and (bvugt S18 S19) (shlok X2 S18) (addok (bvshl X2 S18) (bvshl X2 S19)) (= X9 (bvadd (bvshl X2 S18) (bvshl X2 S19))))\n (and (bvugt S18 S19) (shlok X2 S18) (= X9 (bvsub (bvshl X2 S18) (bvshl X2 S19))))\n (and (shlok X2 S18) (shlok X3 S19) (addok (bvshl X2 S18) (bvshl X3 S19)) (= X9 (bvadd (bvshl X2 S18) (bvshl X3 S19))))\n (and (shlok X2 S18) (shlok X3 S19) (bvugt (bvshl X2 S18) (bvshl X3 S19)) (= X9 (bvsub (bvshl X2 S18) (bvshl X3 S19))))\n (and (shlok X3 S18) (shlok X2 S19) (bvugt (bvshl X3 S18) (bvshl X2 S19)) (= X9 (bvsub (bvshl X3 S18) (bvshl X2 S19))))\n (and (shlok X2 S18) (shlok X4 S19) (addok (bvshl X2 S18) (bvshl X4 S19)) (= X9 (bvadd (bvshl X2 S18) (bvshl X4 S19))))\n (and (shlok X2 S18) (shlok X4 S19) (bvugt (bvshl X2 S18) (bvshl X4 S19)) (= X9 (bvsub (bvshl X2 S18) (bvshl X4 S19))))\n (and (shlok X4 S18) (shlok X2 S19) (bvugt (bvshl X4 S18) (bvshl X2 S19)) (= X9 (bvsub (bvshl X4 S18) (bvshl X2 S19))))\n (and (shlok X2 S18) (shlok X5 S19) (addok (bvshl X2 S18) (bvshl X5 S19)) (= X9 (bvadd (bvshl X2 S18) (bvshl X5 S19))))\n (and (shlok X2 S18) (shlok X5 S19) (bvugt (bvshl X2 S18) (bvshl X5 S19)) (= X9 (bvsub (bvshl X2 S18) (bvshl X5 S19))))\n (and (shlok X5 S18) (shlok X2 S19) (bvugt (bvshl X5 S18) (bvshl X2 S19)) (= X9 (bvsub (bvshl X5 S18) (bvshl X2 S19))))\n (and (shlok X2 S18) (shlok X6 S19) (addok (bvshl X2 S18) (bvshl X6 S19)) (= X9 (bvadd (bvshl X2 S18) (bvshl X6 S19))))\n (and (shlok X2 S18) (shlok X6 S19) (bvugt (bvshl X2 S18) (bvshl X6 S19)) (= X9 (bvsub (bvshl X2 S18) (bvshl X6 S19))))\n (and (shlok X6 S18) (shlok X2 S19) (bvugt (bvshl X6 S18) (bvshl X2 S19)) (= X9 (bvsub (bvshl X6 S18) (bvshl X2 S19))))\n (and (shlok X2 S18) (shlok X7 S19) (addok (bvshl X2 S18) (bvshl X7 S19)) (= X9 (bvadd (bvshl X2 S18) (bvshl X7 S19))))\n (and (shlok X2 S18) (shlok X7 S19) (bvugt (bvshl X2 S18) (bvshl X7 S19)) (= X9 (bvsub (bvshl X2 S18) (bvshl X7 S19))))\n (and (shlok X7 S18) (shlok X2 S19) (bvugt (bvshl X7 S18) (bvshl X2 S19)) (= X9 (bvsub (bvshl X7 S18) (bvshl X2 S19))))\n (and (shlok X2 S18) (shlok X8 S19) (addok (bvshl X2 S18) (bvshl X8 S19)) (= X9 (bvadd (bvshl X2 S18) (bvshl X8 S19))))\n (and (shlok X2 S18) (shlok X8 S19) (bvugt (bvshl X2 S18) (bvshl X8 S19)) (= X9 (bvsub (bvshl X2 S18) (bvshl X8 S19))))\n (and (shlok X8 S18) (shlok X2 S19) (bvugt (bvshl X8 S18) (bvshl X2 S19)) (= X9 (bvsub (bvshl X8 S18) (bvshl X2 S19))))\n (and (shlok X3 S18) (addok (bvshl X3 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvadd (bvshl X3 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X3 S18) (bvugt (bvshl X3 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvsub (bvshl X3 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X3 S19) (bvugt (bvshl (_ bv1 11) S18) (bvshl X3 S19)) (= X9 (bvsub (bvshl (_ bv1 11) S18) (bvshl X3 S19))))\n (and (bvugt S18 S19) (shlok X3 S18) (addok (bvshl X3 S18) (bvshl X3 S19)) (= X9 (bvadd (bvshl X3 S18) (bvshl X3 S19))))\n (and (bvugt S18 S19) (shlok X3 S18) (= X9 (bvsub (bvshl X3 S18) (bvshl X3 S19))))\n (and (shlok X3 S18) (shlok X4 S19) (addok (bvshl X3 S18) (bvshl X4 S19)) (= X9 (bvadd (bvshl X3 S18) (bvshl X4 S19))))\n (and (shlok X3 S18) (shlok X4 S19) (bvugt (bvshl X3 S18) (bvshl X4 S19)) (= X9 (bvsub (bvshl X3 S18) (bvshl X4 S19))))\n (and (shlok X4 S18) (shlok X3 S19) (bvugt (bvshl X4 S18) (bvshl X3 S19)) (= X9 (bvsub (bvshl X4 S18) (bvshl X3 S19))))\n (and (shlok X3 S18) (shlok X5 S19) (addok (bvshl X3 S18) (bvshl X5 S19)) (= X9 (bvadd (bvshl X3 S18) (bvshl X5 S19))))\n (and (shlok X3 S18) (shlok X5 S19) (bvugt (bvshl X3 S18) (bvshl X5 S19)) (= X9 (bvsub (bvshl X3 S18) (bvshl X5 S19))))\n (and (shlok X5 S18) (shlok X3 S19) (bvugt (bvshl X5 S18) (bvshl X3 S19)) (= X9 (bvsub (bvshl X5 S18) (bvshl X3 S19))))\n (and (shlok X3 S18) (shlok X6 S19) (addok (bvshl X3 S18) (bvshl X6 S19)) (= X9 (bvadd (bvshl X3 S18) (bvshl X6 S19))))\n (and (shlok X3 S18) (shlok X6 S19) (bvugt (bvshl X3 S18) (bvshl X6 S19)) (= X9 (bvsub (bvshl X3 S18) (bvshl X6 S19))))\n (and (shlok X6 S18) (shlok X3 S19) (bvugt (bvshl X6 S18) (bvshl X3 S19)) (= X9 (bvsub (bvshl X6 S18) (bvshl X3 S19))))\n (and (shlok X3 S18) (shlok X7 S19) (addok (bvshl X3 S18) (bvshl X7 S19)) (= X9 (bvadd (bvshl X3 S18) (bvshl X7 S19))))\n (and (shlok X3 S18) (shlok X7 S19) (bvugt (bvshl X3 S18) (bvshl X7 S19)) (= X9 (bvsub (bvshl X3 S18) (bvshl X7 S19))))\n (and (shlok X7 S18) (shlok X3 S19) (bvugt (bvshl X7 S18) (bvshl X3 S19)) (= X9 (bvsub (bvshl X7 S18) (bvshl X3 S19))))\n (and (shlok X3 S18) (shlok X8 S19) (addok (bvshl X3 S18) (bvshl X8 S19)) (= X9 (bvadd (bvshl X3 S18) (bvshl X8 S19))))\n (and (shlok X3 S18) (shlok X8 S19) (bvugt (bvshl X3 S18) (bvshl X8 S19)) (= X9 (bvsub (bvshl X3 S18) (bvshl X8 S19))))\n (and (shlok X8 S18) (shlok X3 S19) (bvugt (bvshl X8 S18) (bvshl X3 S19)) (= X9 (bvsub (bvshl X8 S18) (bvshl X3 S19))))\n (and (shlok X4 S18) (addok (bvshl X4 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvadd (bvshl X4 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X4 S18) (bvugt (bvshl X4 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvsub (bvshl X4 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X4 S19) (bvugt (bvshl (_ bv1 11) S18) (bvshl X4 S19)) (= X9 (bvsub (bvshl (_ bv1 11) S18) (bvshl X4 S19))))\n (and (bvugt S18 S19) (shlok X4 S18) (addok (bvshl X4 S18) (bvshl X4 S19)) (= X9 (bvadd (bvshl X4 S18) (bvshl X4 S19))))\n (and (bvugt S18 S19) (shlok X4 S18) (= X9 (bvsub (bvshl X4 S18) (bvshl X4 S19))))\n (and (shlok X4 S18) (shlok X5 S19) (addok (bvshl X4 S18) (bvshl X5 S19)) (= X9 (bvadd (bvshl X4 S18) (bvshl X5 S19))))\n (and (shlok X4 S18) (shlok X5 S19) (bvugt (bvshl X4 S18) (bvshl X5 S19)) (= X9 (bvsub (bvshl X4 S18) (bvshl X5 S19))))\n (and (shlok X5 S18) (shlok X4 S19) (bvugt (bvshl X5 S18) (bvshl X4 S19)) (= X9 (bvsub (bvshl X5 S18) (bvshl X4 S19))))\n (and (shlok X4 S18) (shlok X6 S19) (addok (bvshl X4 S18) (bvshl X6 S19)) (= X9 (bvadd (bvshl X4 S18) (bvshl X6 S19))))\n (and (shlok X4 S18) (shlok X6 S19) (bvugt (bvshl X4 S18) (bvshl X6 S19)) (= X9 (bvsub (bvshl X4 S18) (bvshl X6 S19))))\n (and (shlok X6 S18) (shlok X4 S19) (bvugt (bvshl X6 S18) (bvshl X4 S19)) (= X9 (bvsub (bvshl X6 S18) (bvshl X4 S19))))\n (and (shlok X4 S18) (shlok X7 S19) (addok (bvshl X4 S18) (bvshl X7 S19)) (= X9 (bvadd (bvshl X4 S18) (bvshl X7 S19))))\n (and (shlok X4 S18) (shlok X7 S19) (bvugt (bvshl X4 S18) (bvshl X7 S19)) (= X9 (bvsub (bvshl X4 S18) (bvshl X7 S19))))\n (and (shlok X7 S18) (shlok X4 S19) (bvugt (bvshl X7 S18) (bvshl X4 S19)) (= X9 (bvsub (bvshl X7 S18) (bvshl X4 S19))))\n (and (shlok X4 S18) (shlok X8 S19) (addok (bvshl X4 S18) (bvshl X8 S19)) (= X9 (bvadd (bvshl X4 S18) (bvshl X8 S19))))\n (and (shlok X4 S18) (shlok X8 S19) (bvugt (bvshl X4 S18) (bvshl X8 S19)) (= X9 (bvsub (bvshl X4 S18) (bvshl X8 S19))))\n (and (shlok X8 S18) (shlok X4 S19) (bvugt (bvshl X8 S18) (bvshl X4 S19)) (= X9 (bvsub (bvshl X8 S18) (bvshl X4 S19))))\n (and (shlok X5 S18) (addok (bvshl X5 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvadd (bvshl X5 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X5 S18) (bvugt (bvshl X5 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvsub (bvshl X5 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X5 S19) (bvugt (bvshl (_ bv1 11) S18) (bvshl X5 S19)) (= X9 (bvsub (bvshl (_ bv1 11) S18) (bvshl X5 S19))))\n (and (bvugt S18 S19) (shlok X5 S18) (addok (bvshl X5 S18) (bvshl X5 S19)) (= X9 (bvadd (bvshl X5 S18) (bvshl X5 S19))))\n (and (bvugt S18 S19) (shlok X5 S18) (= X9 (bvsub (bvshl X5 S18) (bvshl X5 S19))))\n (and (shlok X5 S18) (shlok X6 S19) (addok (bvshl X5 S18) (bvshl X6 S19)) (= X9 (bvadd (bvshl X5 S18) (bvshl X6 S19))))\n (and (shlok X5 S18) (shlok X6 S19) (bvugt (bvshl X5 S18) (bvshl X6 S19)) (= X9 (bvsub (bvshl X5 S18) (bvshl X6 S19))))\n (and (shlok X6 S18) (shlok X5 S19) (bvugt (bvshl X6 S18) (bvshl X5 S19)) (= X9 (bvsub (bvshl X6 S18) (bvshl X5 S19))))\n (and (shlok X5 S18) (shlok X7 S19) (addok (bvshl X5 S18) (bvshl X7 S19)) (= X9 (bvadd (bvshl X5 S18) (bvshl X7 S19))))\n (and (shlok X5 S18) (shlok X7 S19) (bvugt (bvshl X5 S18) (bvshl X7 S19)) (= X9 (bvsub (bvshl X5 S18) (bvshl X7 S19))))\n (and (shlok X7 S18) (shlok X5 S19) (bvugt (bvshl X7 S18) (bvshl X5 S19)) (= X9 (bvsub (bvshl X7 S18) (bvshl X5 S19))))\n (and (shlok X5 S18) (shlok X8 S19) (addok (bvshl X5 S18) (bvshl X8 S19)) (= X9 (bvadd (bvshl X5 S18) (bvshl X8 S19))))\n (and (shlok X5 S18) (shlok X8 S19) (bvugt (bvshl X5 S18) (bvshl X8 S19)) (= X9 (bvsub (bvshl X5 S18) (bvshl X8 S19))))\n (and (shlok X8 S18) (shlok X5 S19) (bvugt (bvshl X8 S18) (bvshl X5 S19)) (= X9 (bvsub (bvshl X8 S18) (bvshl X5 S19))))\n (and (shlok X6 S18) (addok (bvshl X6 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvadd (bvshl X6 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X6 S18) (bvugt (bvshl X6 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvsub (bvshl X6 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X6 S19) (bvugt (bvshl (_ bv1 11) S18) (bvshl X6 S19)) (= X9 (bvsub (bvshl (_ bv1 11) S18) (bvshl X6 S19))))\n (and (bvugt S18 S19) (shlok X6 S18) (addok (bvshl X6 S18) (bvshl X6 S19)) (= X9 (bvadd (bvshl X6 S18) (bvshl X6 S19))))\n (and (bvugt S18 S19) (shlok X6 S18) (= X9 (bvsub (bvshl X6 S18) (bvshl X6 S19))))\n (and (shlok X6 S18) (shlok X7 S19) (addok (bvshl X6 S18) (bvshl X7 S19)) (= X9 (bvadd (bvshl X6 S18) (bvshl X7 S19))))\n (and (shlok X6 S18) (shlok X7 S19) (bvugt (bvshl X6 S18) (bvshl X7 S19)) (= X9 (bvsub (bvshl X6 S18) (bvshl X7 S19))))\n (and (shlok X7 S18) (shlok X6 S19) (bvugt (bvshl X7 S18) (bvshl X6 S19)) (= X9 (bvsub (bvshl X7 S18) (bvshl X6 S19))))\n (and (shlok X6 S18) (shlok X8 S19) (addok (bvshl X6 S18) (bvshl X8 S19)) (= X9 (bvadd (bvshl X6 S18) (bvshl X8 S19))))\n (and (shlok X6 S18) (shlok X8 S19) (bvugt (bvshl X6 S18) (bvshl X8 S19)) (= X9 (bvsub (bvshl X6 S18) (bvshl X8 S19))))\n (and (shlok X8 S18) (shlok X6 S19) (bvugt (bvshl X8 S18) (bvshl X6 S19)) (= X9 (bvsub (bvshl X8 S18) (bvshl X6 S19))))\n (and (shlok X7 S18) (addok (bvshl X7 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvadd (bvshl X7 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X7 S18) (bvugt (bvshl X7 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvsub (bvshl X7 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X7 S19) (bvugt (bvshl (_ bv1 11) S18) (bvshl X7 S19)) (= X9 (bvsub (bvshl (_ bv1 11) S18) (bvshl X7 S19))))\n (and (bvugt S18 S19) (shlok X7 S18) (addok (bvshl X7 S18) (bvshl X7 S19)) (= X9 (bvadd (bvshl X7 S18) (bvshl X7 S19))))\n (and (bvugt S18 S19) (shlok X7 S18) (= X9 (bvsub (bvshl X7 S18) (bvshl X7 S19))))\n (and (shlok X7 S18) (shlok X8 S19) (addok (bvshl X7 S18) (bvshl X8 S19)) (= X9 (bvadd (bvshl X7 S18) (bvshl X8 S19))))\n (and (shlok X7 S18) (shlok X8 S19) (bvugt (bvshl X7 S18) (bvshl X8 S19)) (= X9 (bvsub (bvshl X7 S18) (bvshl X8 S19))))\n (and (shlok X8 S18) (shlok X7 S19) (bvugt (bvshl X8 S18) (bvshl X7 S19)) (= X9 (bvsub (bvshl X8 S18) (bvshl X7 S19))))\n (and (shlok X8 S18) (addok (bvshl X8 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvadd (bvshl X8 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X8 S18) (bvugt (bvshl X8 S18) (bvshl (_ bv1 11) S19)) (= X9 (bvsub (bvshl X8 S18) (bvshl (_ bv1 11) S19))))\n (and (shlok X8 S19) (bvugt (bvshl (_ bv1 11) S18) (bvshl X8 S19)) (= X9 (bvsub (bvshl (_ bv1 11) S18) (bvshl X8 S19))))\n (and (bvugt S18 S19) (shlok X8 S18) (addok (bvshl X8 S18) (bvshl X8 S19)) (= X9 (bvadd (bvshl X8 S18) (bvshl X8 S19))))\n (and (bvugt S18 S19) (shlok X8 S18) (= X9 (bvsub (bvshl X8 S18) (bvshl X8 S19))))\n))\n(assert (or\n (and (shlok X0 S20) (addok (bvshl X0 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvadd (bvshl X0 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X0 S20) (bvugt (bvshl X0 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvsub (bvshl X0 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X0 S21) (bvugt (bvshl (_ bv1 11) S20) (bvshl X0 S21)) (= X10 (bvsub (bvshl (_ bv1 11) S20) (bvshl X0 S21))))\n (and (bvugt S20 S21) (shlok X0 S20) (addok (bvshl X0 S20) (bvshl X0 S21)) (= X10 (bvadd (bvshl X0 S20) (bvshl X0 S21))))\n (and (bvugt S20 S21) (shlok X0 S20) (= X10 (bvsub (bvshl X0 S20) (bvshl X0 S21))))\n (and (shlok X0 S20) (shlok X1 S21) (addok (bvshl X0 S20) (bvshl X1 S21)) (= X10 (bvadd (bvshl X0 S20) (bvshl X1 S21))))\n (and (shlok X0 S20) (shlok X1 S21) (bvugt (bvshl X0 S20) (bvshl X1 S21)) (= X10 (bvsub (bvshl X0 S20) (bvshl X1 S21))))\n (and (shlok X1 S20) (shlok X0 S21) (bvugt (bvshl X1 S20) (bvshl X0 S21)) (= X10 (bvsub (bvshl X1 S20) (bvshl X0 S21))))\n (and (shlok X0 S20) (shlok X2 S21) (addok (bvshl X0 S20) (bvshl X2 S21)) (= X10 (bvadd (bvshl X0 S20) (bvshl X2 S21))))\n (and (shlok X0 S20) (shlok X2 S21) (bvugt (bvshl X0 S20) (bvshl X2 S21)) (= X10 (bvsub (bvshl X0 S20) (bvshl X2 S21))))\n (and (shlok X2 S20) (shlok X0 S21) (bvugt (bvshl X2 S20) (bvshl X0 S21)) (= X10 (bvsub (bvshl X2 S20) (bvshl X0 S21))))\n (and (shlok X0 S20) (shlok X3 S21) (addok (bvshl X0 S20) (bvshl X3 S21)) (= X10 (bvadd (bvshl X0 S20) (bvshl X3 S21))))\n (and (shlok X0 S20) (shlok X3 S21) (bvugt (bvshl X0 S20) (bvshl X3 S21)) (= X10 (bvsub (bvshl X0 S20) (bvshl X3 S21))))\n (and (shlok X3 S20) (shlok X0 S21) (bvugt (bvshl X3 S20) (bvshl X0 S21)) (= X10 (bvsub (bvshl X3 S20) (bvshl X0 S21))))\n (and (shlok X0 S20) (shlok X4 S21) (addok (bvshl X0 S20) (bvshl X4 S21)) (= X10 (bvadd (bvshl X0 S20) (bvshl X4 S21))))\n (and (shlok X0 S20) (shlok X4 S21) (bvugt (bvshl X0 S20) (bvshl X4 S21)) (= X10 (bvsub (bvshl X0 S20) (bvshl X4 S21))))\n (and (shlok X4 S20) (shlok X0 S21) (bvugt (bvshl X4 S20) (bvshl X0 S21)) (= X10 (bvsub (bvshl X4 S20) (bvshl X0 S21))))\n (and (shlok X0 S20) (shlok X5 S21) (addok (bvshl X0 S20) (bvshl X5 S21)) (= X10 (bvadd (bvshl X0 S20) (bvshl X5 S21))))\n (and (shlok X0 S20) (shlok X5 S21) (bvugt (bvshl X0 S20) (bvshl X5 S21)) (= X10 (bvsub (bvshl X0 S20) (bvshl X5 S21))))\n (and (shlok X5 S20) (shlok X0 S21) (bvugt (bvshl X5 S20) (bvshl X0 S21)) (= X10 (bvsub (bvshl X5 S20) (bvshl X0 S21))))\n (and (shlok X0 S20) (shlok X6 S21) (addok (bvshl X0 S20) (bvshl X6 S21)) (= X10 (bvadd (bvshl X0 S20) (bvshl X6 S21))))\n (and (shlok X0 S20) (shlok X6 S21) (bvugt (bvshl X0 S20) (bvshl X6 S21)) (= X10 (bvsub (bvshl X0 S20) (bvshl X6 S21))))\n (and (shlok X6 S20) (shlok X0 S21) (bvugt (bvshl X6 S20) (bvshl X0 S21)) (= X10 (bvsub (bvshl X6 S20) (bvshl X0 S21))))\n (and (shlok X0 S20) (shlok X7 S21) (addok (bvshl X0 S20) (bvshl X7 S21)) (= X10 (bvadd (bvshl X0 S20) (bvshl X7 S21))))\n (and (shlok X0 S20) (shlok X7 S21) (bvugt (bvshl X0 S20) (bvshl X7 S21)) (= X10 (bvsub (bvshl X0 S20) (bvshl X7 S21))))\n (and (shlok X7 S20) (shlok X0 S21) (bvugt (bvshl X7 S20) (bvshl X0 S21)) (= X10 (bvsub (bvshl X7 S20) (bvshl X0 S21))))\n (and (shlok X0 S20) (shlok X8 S21) (addok (bvshl X0 S20) (bvshl X8 S21)) (= X10 (bvadd (bvshl X0 S20) (bvshl X8 S21))))\n (and (shlok X0 S20) (shlok X8 S21) (bvugt (bvshl X0 S20) (bvshl X8 S21)) (= X10 (bvsub (bvshl X0 S20) (bvshl X8 S21))))\n (and (shlok X8 S20) (shlok X0 S21) (bvugt (bvshl X8 S20) (bvshl X0 S21)) (= X10 (bvsub (bvshl X8 S20) (bvshl X0 S21))))\n (and (shlok X0 S20) (shlok X9 S21) (addok (bvshl X0 S20) (bvshl X9 S21)) (= X10 (bvadd (bvshl X0 S20) (bvshl X9 S21))))\n (and (shlok X0 S20) (shlok X9 S21) (bvugt (bvshl X0 S20) (bvshl X9 S21)) (= X10 (bvsub (bvshl X0 S20) (bvshl X9 S21))))\n (and (shlok X9 S20) (shlok X0 S21) (bvugt (bvshl X9 S20) (bvshl X0 S21)) (= X10 (bvsub (bvshl X9 S20) (bvshl X0 S21))))\n (and (shlok X1 S20) (addok (bvshl X1 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvadd (bvshl X1 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X1 S20) (bvugt (bvshl X1 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvsub (bvshl X1 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X1 S21) (bvugt (bvshl (_ bv1 11) S20) (bvshl X1 S21)) (= X10 (bvsub (bvshl (_ bv1 11) S20) (bvshl X1 S21))))\n (and (bvugt S20 S21) (shlok X1 S20) (addok (bvshl X1 S20) (bvshl X1 S21)) (= X10 (bvadd (bvshl X1 S20) (bvshl X1 S21))))\n (and (bvugt S20 S21) (shlok X1 S20) (= X10 (bvsub (bvshl X1 S20) (bvshl X1 S21))))\n (and (shlok X1 S20) (shlok X2 S21) (addok (bvshl X1 S20) (bvshl X2 S21)) (= X10 (bvadd (bvshl X1 S20) (bvshl X2 S21))))\n (and (shlok X1 S20) (shlok X2 S21) (bvugt (bvshl X1 S20) (bvshl X2 S21)) (= X10 (bvsub (bvshl X1 S20) (bvshl X2 S21))))\n (and (shlok X2 S20) (shlok X1 S21) (bvugt (bvshl X2 S20) (bvshl X1 S21)) (= X10 (bvsub (bvshl X2 S20) (bvshl X1 S21))))\n (and (shlok X1 S20) (shlok X3 S21) (addok (bvshl X1 S20) (bvshl X3 S21)) (= X10 (bvadd (bvshl X1 S20) (bvshl X3 S21))))\n (and (shlok X1 S20) (shlok X3 S21) (bvugt (bvshl X1 S20) (bvshl X3 S21)) (= X10 (bvsub (bvshl X1 S20) (bvshl X3 S21))))\n (and (shlok X3 S20) (shlok X1 S21) (bvugt (bvshl X3 S20) (bvshl X1 S21)) (= X10 (bvsub (bvshl X3 S20) (bvshl X1 S21))))\n (and (shlok X1 S20) (shlok X4 S21) (addok (bvshl X1 S20) (bvshl X4 S21)) (= X10 (bvadd (bvshl X1 S20) (bvshl X4 S21))))\n (and (shlok X1 S20) (shlok X4 S21) (bvugt (bvshl X1 S20) (bvshl X4 S21)) (= X10 (bvsub (bvshl X1 S20) (bvshl X4 S21))))\n (and (shlok X4 S20) (shlok X1 S21) (bvugt (bvshl X4 S20) (bvshl X1 S21)) (= X10 (bvsub (bvshl X4 S20) (bvshl X1 S21))))\n (and (shlok X1 S20) (shlok X5 S21) (addok (bvshl X1 S20) (bvshl X5 S21)) (= X10 (bvadd (bvshl X1 S20) (bvshl X5 S21))))\n (and (shlok X1 S20) (shlok X5 S21) (bvugt (bvshl X1 S20) (bvshl X5 S21)) (= X10 (bvsub (bvshl X1 S20) (bvshl X5 S21))))\n (and (shlok X5 S20) (shlok X1 S21) (bvugt (bvshl X5 S20) (bvshl X1 S21)) (= X10 (bvsub (bvshl X5 S20) (bvshl X1 S21))))\n (and (shlok X1 S20) (shlok X6 S21) (addok (bvshl X1 S20) (bvshl X6 S21)) (= X10 (bvadd (bvshl X1 S20) (bvshl X6 S21))))\n (and (shlok X1 S20) (shlok X6 S21) (bvugt (bvshl X1 S20) (bvshl X6 S21)) (= X10 (bvsub (bvshl X1 S20) (bvshl X6 S21))))\n (and (shlok X6 S20) (shlok X1 S21) (bvugt (bvshl X6 S20) (bvshl X1 S21)) (= X10 (bvsub (bvshl X6 S20) (bvshl X1 S21))))\n (and (shlok X1 S20) (shlok X7 S21) (addok (bvshl X1 S20) (bvshl X7 S21)) (= X10 (bvadd (bvshl X1 S20) (bvshl X7 S21))))\n (and (shlok X1 S20) (shlok X7 S21) (bvugt (bvshl X1 S20) (bvshl X7 S21)) (= X10 (bvsub (bvshl X1 S20) (bvshl X7 S21))))\n (and (shlok X7 S20) (shlok X1 S21) (bvugt (bvshl X7 S20) (bvshl X1 S21)) (= X10 (bvsub (bvshl X7 S20) (bvshl X1 S21))))\n (and (shlok X1 S20) (shlok X8 S21) (addok (bvshl X1 S20) (bvshl X8 S21)) (= X10 (bvadd (bvshl X1 S20) (bvshl X8 S21))))\n (and (shlok X1 S20) (shlok X8 S21) (bvugt (bvshl X1 S20) (bvshl X8 S21)) (= X10 (bvsub (bvshl X1 S20) (bvshl X8 S21))))\n (and (shlok X8 S20) (shlok X1 S21) (bvugt (bvshl X8 S20) (bvshl X1 S21)) (= X10 (bvsub (bvshl X8 S20) (bvshl X1 S21))))\n (and (shlok X1 S20) (shlok X9 S21) (addok (bvshl X1 S20) (bvshl X9 S21)) (= X10 (bvadd (bvshl X1 S20) (bvshl X9 S21))))\n (and (shlok X1 S20) (shlok X9 S21) (bvugt (bvshl X1 S20) (bvshl X9 S21)) (= X10 (bvsub (bvshl X1 S20) (bvshl X9 S21))))\n (and (shlok X9 S20) (shlok X1 S21) (bvugt (bvshl X9 S20) (bvshl X1 S21)) (= X10 (bvsub (bvshl X9 S20) (bvshl X1 S21))))\n (and (shlok X2 S20) (addok (bvshl X2 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvadd (bvshl X2 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X2 S20) (bvugt (bvshl X2 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvsub (bvshl X2 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X2 S21) (bvugt (bvshl (_ bv1 11) S20) (bvshl X2 S21)) (= X10 (bvsub (bvshl (_ bv1 11) S20) (bvshl X2 S21))))\n (and (bvugt S20 S21) (shlok X2 S20) (addok (bvshl X2 S20) (bvshl X2 S21)) (= X10 (bvadd (bvshl X2 S20) (bvshl X2 S21))))\n (and (bvugt S20 S21) (shlok X2 S20) (= X10 (bvsub (bvshl X2 S20) (bvshl X2 S21))))\n (and (shlok X2 S20) (shlok X3 S21) (addok (bvshl X2 S20) (bvshl X3 S21)) (= X10 (bvadd (bvshl X2 S20) (bvshl X3 S21))))\n (and (shlok X2 S20) (shlok X3 S21) (bvugt (bvshl X2 S20) (bvshl X3 S21)) (= X10 (bvsub (bvshl X2 S20) (bvshl X3 S21))))\n (and (shlok X3 S20) (shlok X2 S21) (bvugt (bvshl X3 S20) (bvshl X2 S21)) (= X10 (bvsub (bvshl X3 S20) (bvshl X2 S21))))\n (and (shlok X2 S20) (shlok X4 S21) (addok (bvshl X2 S20) (bvshl X4 S21)) (= X10 (bvadd (bvshl X2 S20) (bvshl X4 S21))))\n (and (shlok X2 S20) (shlok X4 S21) (bvugt (bvshl X2 S20) (bvshl X4 S21)) (= X10 (bvsub (bvshl X2 S20) (bvshl X4 S21))))\n (and (shlok X4 S20) (shlok X2 S21) (bvugt (bvshl X4 S20) (bvshl X2 S21)) (= X10 (bvsub (bvshl X4 S20) (bvshl X2 S21))))\n (and (shlok X2 S20) (shlok X5 S21) (addok (bvshl X2 S20) (bvshl X5 S21)) (= X10 (bvadd (bvshl X2 S20) (bvshl X5 S21))))\n (and (shlok X2 S20) (shlok X5 S21) (bvugt (bvshl X2 S20) (bvshl X5 S21)) (= X10 (bvsub (bvshl X2 S20) (bvshl X5 S21))))\n (and (shlok X5 S20) (shlok X2 S21) (bvugt (bvshl X5 S20) (bvshl X2 S21)) (= X10 (bvsub (bvshl X5 S20) (bvshl X2 S21))))\n (and (shlok X2 S20) (shlok X6 S21) (addok (bvshl X2 S20) (bvshl X6 S21)) (= X10 (bvadd (bvshl X2 S20) (bvshl X6 S21))))\n (and (shlok X2 S20) (shlok X6 S21) (bvugt (bvshl X2 S20) (bvshl X6 S21)) (= X10 (bvsub (bvshl X2 S20) (bvshl X6 S21))))\n (and (shlok X6 S20) (shlok X2 S21) (bvugt (bvshl X6 S20) (bvshl X2 S21)) (= X10 (bvsub (bvshl X6 S20) (bvshl X2 S21))))\n (and (shlok X2 S20) (shlok X7 S21) (addok (bvshl X2 S20) (bvshl X7 S21)) (= X10 (bvadd (bvshl X2 S20) (bvshl X7 S21))))\n (and (shlok X2 S20) (shlok X7 S21) (bvugt (bvshl X2 S20) (bvshl X7 S21)) (= X10 (bvsub (bvshl X2 S20) (bvshl X7 S21))))\n (and (shlok X7 S20) (shlok X2 S21) (bvugt (bvshl X7 S20) (bvshl X2 S21)) (= X10 (bvsub (bvshl X7 S20) (bvshl X2 S21))))\n (and (shlok X2 S20) (shlok X8 S21) (addok (bvshl X2 S20) (bvshl X8 S21)) (= X10 (bvadd (bvshl X2 S20) (bvshl X8 S21))))\n (and (shlok X2 S20) (shlok X8 S21) (bvugt (bvshl X2 S20) (bvshl X8 S21)) (= X10 (bvsub (bvshl X2 S20) (bvshl X8 S21))))\n (and (shlok X8 S20) (shlok X2 S21) (bvugt (bvshl X8 S20) (bvshl X2 S21)) (= X10 (bvsub (bvshl X8 S20) (bvshl X2 S21))))\n (and (shlok X2 S20) (shlok X9 S21) (addok (bvshl X2 S20) (bvshl X9 S21)) (= X10 (bvadd (bvshl X2 S20) (bvshl X9 S21))))\n (and (shlok X2 S20) (shlok X9 S21) (bvugt (bvshl X2 S20) (bvshl X9 S21)) (= X10 (bvsub (bvshl X2 S20) (bvshl X9 S21))))\n (and (shlok X9 S20) (shlok X2 S21) (bvugt (bvshl X9 S20) (bvshl X2 S21)) (= X10 (bvsub (bvshl X9 S20) (bvshl X2 S21))))\n (and (shlok X3 S20) (addok (bvshl X3 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvadd (bvshl X3 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X3 S20) (bvugt (bvshl X3 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvsub (bvshl X3 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X3 S21) (bvugt (bvshl (_ bv1 11) S20) (bvshl X3 S21)) (= X10 (bvsub (bvshl (_ bv1 11) S20) (bvshl X3 S21))))\n (and (bvugt S20 S21) (shlok X3 S20) (addok (bvshl X3 S20) (bvshl X3 S21)) (= X10 (bvadd (bvshl X3 S20) (bvshl X3 S21))))\n (and (bvugt S20 S21) (shlok X3 S20) (= X10 (bvsub (bvshl X3 S20) (bvshl X3 S21))))\n (and (shlok X3 S20) (shlok X4 S21) (addok (bvshl X3 S20) (bvshl X4 S21)) (= X10 (bvadd (bvshl X3 S20) (bvshl X4 S21))))\n (and (shlok X3 S20) (shlok X4 S21) (bvugt (bvshl X3 S20) (bvshl X4 S21)) (= X10 (bvsub (bvshl X3 S20) (bvshl X4 S21))))\n (and (shlok X4 S20) (shlok X3 S21) (bvugt (bvshl X4 S20) (bvshl X3 S21)) (= X10 (bvsub (bvshl X4 S20) (bvshl X3 S21))))\n (and (shlok X3 S20) (shlok X5 S21) (addok (bvshl X3 S20) (bvshl X5 S21)) (= X10 (bvadd (bvshl X3 S20) (bvshl X5 S21))))\n (and (shlok X3 S20) (shlok X5 S21) (bvugt (bvshl X3 S20) (bvshl X5 S21)) (= X10 (bvsub (bvshl X3 S20) (bvshl X5 S21))))\n (and (shlok X5 S20) (shlok X3 S21) (bvugt (bvshl X5 S20) (bvshl X3 S21)) (= X10 (bvsub (bvshl X5 S20) (bvshl X3 S21))))\n (and (shlok X3 S20) (shlok X6 S21) (addok (bvshl X3 S20) (bvshl X6 S21)) (= X10 (bvadd (bvshl X3 S20) (bvshl X6 S21))))\n (and (shlok X3 S20) (shlok X6 S21) (bvugt (bvshl X3 S20) (bvshl X6 S21)) (= X10 (bvsub (bvshl X3 S20) (bvshl X6 S21))))\n (and (shlok X6 S20) (shlok X3 S21) (bvugt (bvshl X6 S20) (bvshl X3 S21)) (= X10 (bvsub (bvshl X6 S20) (bvshl X3 S21))))\n (and (shlok X3 S20) (shlok X7 S21) (addok (bvshl X3 S20) (bvshl X7 S21)) (= X10 (bvadd (bvshl X3 S20) (bvshl X7 S21))))\n (and (shlok X3 S20) (shlok X7 S21) (bvugt (bvshl X3 S20) (bvshl X7 S21)) (= X10 (bvsub (bvshl X3 S20) (bvshl X7 S21))))\n (and (shlok X7 S20) (shlok X3 S21) (bvugt (bvshl X7 S20) (bvshl X3 S21)) (= X10 (bvsub (bvshl X7 S20) (bvshl X3 S21))))\n (and (shlok X3 S20) (shlok X8 S21) (addok (bvshl X3 S20) (bvshl X8 S21)) (= X10 (bvadd (bvshl X3 S20) (bvshl X8 S21))))\n (and (shlok X3 S20) (shlok X8 S21) (bvugt (bvshl X3 S20) (bvshl X8 S21)) (= X10 (bvsub (bvshl X3 S20) (bvshl X8 S21))))\n (and (shlok X8 S20) (shlok X3 S21) (bvugt (bvshl X8 S20) (bvshl X3 S21)) (= X10 (bvsub (bvshl X8 S20) (bvshl X3 S21))))\n (and (shlok X3 S20) (shlok X9 S21) (addok (bvshl X3 S20) (bvshl X9 S21)) (= X10 (bvadd (bvshl X3 S20) (bvshl X9 S21))))\n (and (shlok X3 S20) (shlok X9 S21) (bvugt (bvshl X3 S20) (bvshl X9 S21)) (= X10 (bvsub (bvshl X3 S20) (bvshl X9 S21))))\n (and (shlok X9 S20) (shlok X3 S21) (bvugt (bvshl X9 S20) (bvshl X3 S21)) (= X10 (bvsub (bvshl X9 S20) (bvshl X3 S21))))\n (and (shlok X4 S20) (addok (bvshl X4 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvadd (bvshl X4 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X4 S20) (bvugt (bvshl X4 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvsub (bvshl X4 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X4 S21) (bvugt (bvshl (_ bv1 11) S20) (bvshl X4 S21)) (= X10 (bvsub (bvshl (_ bv1 11) S20) (bvshl X4 S21))))\n (and (bvugt S20 S21) (shlok X4 S20) (addok (bvshl X4 S20) (bvshl X4 S21)) (= X10 (bvadd (bvshl X4 S20) (bvshl X4 S21))))\n (and (bvugt S20 S21) (shlok X4 S20) (= X10 (bvsub (bvshl X4 S20) (bvshl X4 S21))))\n (and (shlok X4 S20) (shlok X5 S21) (addok (bvshl X4 S20) (bvshl X5 S21)) (= X10 (bvadd (bvshl X4 S20) (bvshl X5 S21))))\n (and (shlok X4 S20) (shlok X5 S21) (bvugt (bvshl X4 S20) (bvshl X5 S21)) (= X10 (bvsub (bvshl X4 S20) (bvshl X5 S21))))\n (and (shlok X5 S20) (shlok X4 S21) (bvugt (bvshl X5 S20) (bvshl X4 S21)) (= X10 (bvsub (bvshl X5 S20) (bvshl X4 S21))))\n (and (shlok X4 S20) (shlok X6 S21) (addok (bvshl X4 S20) (bvshl X6 S21)) (= X10 (bvadd (bvshl X4 S20) (bvshl X6 S21))))\n (and (shlok X4 S20) (shlok X6 S21) (bvugt (bvshl X4 S20) (bvshl X6 S21)) (= X10 (bvsub (bvshl X4 S20) (bvshl X6 S21))))\n (and (shlok X6 S20) (shlok X4 S21) (bvugt (bvshl X6 S20) (bvshl X4 S21)) (= X10 (bvsub (bvshl X6 S20) (bvshl X4 S21))))\n (and (shlok X4 S20) (shlok X7 S21) (addok (bvshl X4 S20) (bvshl X7 S21)) (= X10 (bvadd (bvshl X4 S20) (bvshl X7 S21))))\n (and (shlok X4 S20) (shlok X7 S21) (bvugt (bvshl X4 S20) (bvshl X7 S21)) (= X10 (bvsub (bvshl X4 S20) (bvshl X7 S21))))\n (and (shlok X7 S20) (shlok X4 S21) (bvugt (bvshl X7 S20) (bvshl X4 S21)) (= X10 (bvsub (bvshl X7 S20) (bvshl X4 S21))))\n (and (shlok X4 S20) (shlok X8 S21) (addok (bvshl X4 S20) (bvshl X8 S21)) (= X10 (bvadd (bvshl X4 S20) (bvshl X8 S21))))\n (and (shlok X4 S20) (shlok X8 S21) (bvugt (bvshl X4 S20) (bvshl X8 S21)) (= X10 (bvsub (bvshl X4 S20) (bvshl X8 S21))))\n (and (shlok X8 S20) (shlok X4 S21) (bvugt (bvshl X8 S20) (bvshl X4 S21)) (= X10 (bvsub (bvshl X8 S20) (bvshl X4 S21))))\n (and (shlok X4 S20) (shlok X9 S21) (addok (bvshl X4 S20) (bvshl X9 S21)) (= X10 (bvadd (bvshl X4 S20) (bvshl X9 S21))))\n (and (shlok X4 S20) (shlok X9 S21) (bvugt (bvshl X4 S20) (bvshl X9 S21)) (= X10 (bvsub (bvshl X4 S20) (bvshl X9 S21))))\n (and (shlok X9 S20) (shlok X4 S21) (bvugt (bvshl X9 S20) (bvshl X4 S21)) (= X10 (bvsub (bvshl X9 S20) (bvshl X4 S21))))\n (and (shlok X5 S20) (addok (bvshl X5 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvadd (bvshl X5 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X5 S20) (bvugt (bvshl X5 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvsub (bvshl X5 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X5 S21) (bvugt (bvshl (_ bv1 11) S20) (bvshl X5 S21)) (= X10 (bvsub (bvshl (_ bv1 11) S20) (bvshl X5 S21))))\n (and (bvugt S20 S21) (shlok X5 S20) (addok (bvshl X5 S20) (bvshl X5 S21)) (= X10 (bvadd (bvshl X5 S20) (bvshl X5 S21))))\n (and (bvugt S20 S21) (shlok X5 S20) (= X10 (bvsub (bvshl X5 S20) (bvshl X5 S21))))\n (and (shlok X5 S20) (shlok X6 S21) (addok (bvshl X5 S20) (bvshl X6 S21)) (= X10 (bvadd (bvshl X5 S20) (bvshl X6 S21))))\n (and (shlok X5 S20) (shlok X6 S21) (bvugt (bvshl X5 S20) (bvshl X6 S21)) (= X10 (bvsub (bvshl X5 S20) (bvshl X6 S21))))\n (and (shlok X6 S20) (shlok X5 S21) (bvugt (bvshl X6 S20) (bvshl X5 S21)) (= X10 (bvsub (bvshl X6 S20) (bvshl X5 S21))))\n (and (shlok X5 S20) (shlok X7 S21) (addok (bvshl X5 S20) (bvshl X7 S21)) (= X10 (bvadd (bvshl X5 S20) (bvshl X7 S21))))\n (and (shlok X5 S20) (shlok X7 S21) (bvugt (bvshl X5 S20) (bvshl X7 S21)) (= X10 (bvsub (bvshl X5 S20) (bvshl X7 S21))))\n (and (shlok X7 S20) (shlok X5 S21) (bvugt (bvshl X7 S20) (bvshl X5 S21)) (= X10 (bvsub (bvshl X7 S20) (bvshl X5 S21))))\n (and (shlok X5 S20) (shlok X8 S21) (addok (bvshl X5 S20) (bvshl X8 S21)) (= X10 (bvadd (bvshl X5 S20) (bvshl X8 S21))))\n (and (shlok X5 S20) (shlok X8 S21) (bvugt (bvshl X5 S20) (bvshl X8 S21)) (= X10 (bvsub (bvshl X5 S20) (bvshl X8 S21))))\n (and (shlok X8 S20) (shlok X5 S21) (bvugt (bvshl X8 S20) (bvshl X5 S21)) (= X10 (bvsub (bvshl X8 S20) (bvshl X5 S21))))\n (and (shlok X5 S20) (shlok X9 S21) (addok (bvshl X5 S20) (bvshl X9 S21)) (= X10 (bvadd (bvshl X5 S20) (bvshl X9 S21))))\n (and (shlok X5 S20) (shlok X9 S21) (bvugt (bvshl X5 S20) (bvshl X9 S21)) (= X10 (bvsub (bvshl X5 S20) (bvshl X9 S21))))\n (and (shlok X9 S20) (shlok X5 S21) (bvugt (bvshl X9 S20) (bvshl X5 S21)) (= X10 (bvsub (bvshl X9 S20) (bvshl X5 S21))))\n (and (shlok X6 S20) (addok (bvshl X6 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvadd (bvshl X6 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X6 S20) (bvugt (bvshl X6 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvsub (bvshl X6 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X6 S21) (bvugt (bvshl (_ bv1 11) S20) (bvshl X6 S21)) (= X10 (bvsub (bvshl (_ bv1 11) S20) (bvshl X6 S21))))\n (and (bvugt S20 S21) (shlok X6 S20) (addok (bvshl X6 S20) (bvshl X6 S21)) (= X10 (bvadd (bvshl X6 S20) (bvshl X6 S21))))\n (and (bvugt S20 S21) (shlok X6 S20) (= X10 (bvsub (bvshl X6 S20) (bvshl X6 S21))))\n (and (shlok X6 S20) (shlok X7 S21) (addok (bvshl X6 S20) (bvshl X7 S21)) (= X10 (bvadd (bvshl X6 S20) (bvshl X7 S21))))\n (and (shlok X6 S20) (shlok X7 S21) (bvugt (bvshl X6 S20) (bvshl X7 S21)) (= X10 (bvsub (bvshl X6 S20) (bvshl X7 S21))))\n (and (shlok X7 S20) (shlok X6 S21) (bvugt (bvshl X7 S20) (bvshl X6 S21)) (= X10 (bvsub (bvshl X7 S20) (bvshl X6 S21))))\n (and (shlok X6 S20) (shlok X8 S21) (addok (bvshl X6 S20) (bvshl X8 S21)) (= X10 (bvadd (bvshl X6 S20) (bvshl X8 S21))))\n (and (shlok X6 S20) (shlok X8 S21) (bvugt (bvshl X6 S20) (bvshl X8 S21)) (= X10 (bvsub (bvshl X6 S20) (bvshl X8 S21))))\n (and (shlok X8 S20) (shlok X6 S21) (bvugt (bvshl X8 S20) (bvshl X6 S21)) (= X10 (bvsub (bvshl X8 S20) (bvshl X6 S21))))\n (and (shlok X6 S20) (shlok X9 S21) (addok (bvshl X6 S20) (bvshl X9 S21)) (= X10 (bvadd (bvshl X6 S20) (bvshl X9 S21))))\n (and (shlok X6 S20) (shlok X9 S21) (bvugt (bvshl X6 S20) (bvshl X9 S21)) (= X10 (bvsub (bvshl X6 S20) (bvshl X9 S21))))\n (and (shlok X9 S20) (shlok X6 S21) (bvugt (bvshl X9 S20) (bvshl X6 S21)) (= X10 (bvsub (bvshl X9 S20) (bvshl X6 S21))))\n (and (shlok X7 S20) (addok (bvshl X7 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvadd (bvshl X7 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X7 S20) (bvugt (bvshl X7 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvsub (bvshl X7 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X7 S21) (bvugt (bvshl (_ bv1 11) S20) (bvshl X7 S21)) (= X10 (bvsub (bvshl (_ bv1 11) S20) (bvshl X7 S21))))\n (and (bvugt S20 S21) (shlok X7 S20) (addok (bvshl X7 S20) (bvshl X7 S21)) (= X10 (bvadd (bvshl X7 S20) (bvshl X7 S21))))\n (and (bvugt S20 S21) (shlok X7 S20) (= X10 (bvsub (bvshl X7 S20) (bvshl X7 S21))))\n (and (shlok X7 S20) (shlok X8 S21) (addok (bvshl X7 S20) (bvshl X8 S21)) (= X10 (bvadd (bvshl X7 S20) (bvshl X8 S21))))\n (and (shlok X7 S20) (shlok X8 S21) (bvugt (bvshl X7 S20) (bvshl X8 S21)) (= X10 (bvsub (bvshl X7 S20) (bvshl X8 S21))))\n (and (shlok X8 S20) (shlok X7 S21) (bvugt (bvshl X8 S20) (bvshl X7 S21)) (= X10 (bvsub (bvshl X8 S20) (bvshl X7 S21))))\n (and (shlok X7 S20) (shlok X9 S21) (addok (bvshl X7 S20) (bvshl X9 S21)) (= X10 (bvadd (bvshl X7 S20) (bvshl X9 S21))))\n (and (shlok X7 S20) (shlok X9 S21) (bvugt (bvshl X7 S20) (bvshl X9 S21)) (= X10 (bvsub (bvshl X7 S20) (bvshl X9 S21))))\n (and (shlok X9 S20) (shlok X7 S21) (bvugt (bvshl X9 S20) (bvshl X7 S21)) (= X10 (bvsub (bvshl X9 S20) (bvshl X7 S21))))\n (and (shlok X8 S20) (addok (bvshl X8 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvadd (bvshl X8 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X8 S20) (bvugt (bvshl X8 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvsub (bvshl X8 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X8 S21) (bvugt (bvshl (_ bv1 11) S20) (bvshl X8 S21)) (= X10 (bvsub (bvshl (_ bv1 11) S20) (bvshl X8 S21))))\n (and (bvugt S20 S21) (shlok X8 S20) (addok (bvshl X8 S20) (bvshl X8 S21)) (= X10 (bvadd (bvshl X8 S20) (bvshl X8 S21))))\n (and (bvugt S20 S21) (shlok X8 S20) (= X10 (bvsub (bvshl X8 S20) (bvshl X8 S21))))\n (and (shlok X8 S20) (shlok X9 S21) (addok (bvshl X8 S20) (bvshl X9 S21)) (= X10 (bvadd (bvshl X8 S20) (bvshl X9 S21))))\n (and (shlok X8 S20) (shlok X9 S21) (bvugt (bvshl X8 S20) (bvshl X9 S21)) (= X10 (bvsub (bvshl X8 S20) (bvshl X9 S21))))\n (and (shlok X9 S20) (shlok X8 S21) (bvugt (bvshl X9 S20) (bvshl X8 S21)) (= X10 (bvsub (bvshl X9 S20) (bvshl X8 S21))))\n (and (shlok X9 S20) (addok (bvshl X9 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvadd (bvshl X9 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X9 S20) (bvugt (bvshl X9 S20) (bvshl (_ bv1 11) S21)) (= X10 (bvsub (bvshl X9 S20) (bvshl (_ bv1 11) S21))))\n (and (shlok X9 S21) (bvugt (bvshl (_ bv1 11) S20) (bvshl X9 S21)) (= X10 (bvsub (bvshl (_ bv1 11) S20) (bvshl X9 S21))))\n (and (bvugt S20 S21) (shlok X9 S20) (addok (bvshl X9 S20) (bvshl X9 S21)) (= X10 (bvadd (bvshl X9 S20) (bvshl X9 S21))))\n (and (bvugt S20 S21) (shlok X9 S20) (= X10 (bvsub (bvshl X9 S20) (bvshl X9 S21))))\n))\n(assert (or\n (and (shlok X0 S22) (addok (bvshl X0 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvadd (bvshl X0 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X0 S22) (bvugt (bvshl X0 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvsub (bvshl X0 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X0 S23) (bvugt (bvshl (_ bv1 11) S22) (bvshl X0 S23)) (= X11 (bvsub (bvshl (_ bv1 11) S22) (bvshl X0 S23))))\n (and (bvugt S22 S23) (shlok X0 S22) (addok (bvshl X0 S22) (bvshl X0 S23)) (= X11 (bvadd (bvshl X0 S22) (bvshl X0 S23))))\n (and (bvugt S22 S23) (shlok X0 S22) (= X11 (bvsub (bvshl X0 S22) (bvshl X0 S23))))\n (and (shlok X0 S22) (shlok X1 S23) (addok (bvshl X0 S22) (bvshl X1 S23)) (= X11 (bvadd (bvshl X0 S22) (bvshl X1 S23))))\n (and (shlok X0 S22) (shlok X1 S23) (bvugt (bvshl X0 S22) (bvshl X1 S23)) (= X11 (bvsub (bvshl X0 S22) (bvshl X1 S23))))\n (and (shlok X1 S22) (shlok X0 S23) (bvugt (bvshl X1 S22) (bvshl X0 S23)) (= X11 (bvsub (bvshl X1 S22) (bvshl X0 S23))))\n (and (shlok X0 S22) (shlok X2 S23) (addok (bvshl X0 S22) (bvshl X2 S23)) (= X11 (bvadd (bvshl X0 S22) (bvshl X2 S23))))\n (and (shlok X0 S22) (shlok X2 S23) (bvugt (bvshl X0 S22) (bvshl X2 S23)) (= X11 (bvsub (bvshl X0 S22) (bvshl X2 S23))))\n (and (shlok X2 S22) (shlok X0 S23) (bvugt (bvshl X2 S22) (bvshl X0 S23)) (= X11 (bvsub (bvshl X2 S22) (bvshl X0 S23))))\n (and (shlok X0 S22) (shlok X3 S23) (addok (bvshl X0 S22) (bvshl X3 S23)) (= X11 (bvadd (bvshl X0 S22) (bvshl X3 S23))))\n (and (shlok X0 S22) (shlok X3 S23) (bvugt (bvshl X0 S22) (bvshl X3 S23)) (= X11 (bvsub (bvshl X0 S22) (bvshl X3 S23))))\n (and (shlok X3 S22) (shlok X0 S23) (bvugt (bvshl X3 S22) (bvshl X0 S23)) (= X11 (bvsub (bvshl X3 S22) (bvshl X0 S23))))\n (and (shlok X0 S22) (shlok X4 S23) (addok (bvshl X0 S22) (bvshl X4 S23)) (= X11 (bvadd (bvshl X0 S22) (bvshl X4 S23))))\n (and (shlok X0 S22) (shlok X4 S23) (bvugt (bvshl X0 S22) (bvshl X4 S23)) (= X11 (bvsub (bvshl X0 S22) (bvshl X4 S23))))\n (and (shlok X4 S22) (shlok X0 S23) (bvugt (bvshl X4 S22) (bvshl X0 S23)) (= X11 (bvsub (bvshl X4 S22) (bvshl X0 S23))))\n (and (shlok X0 S22) (shlok X5 S23) (addok (bvshl X0 S22) (bvshl X5 S23)) (= X11 (bvadd (bvshl X0 S22) (bvshl X5 S23))))\n (and (shlok X0 S22) (shlok X5 S23) (bvugt (bvshl X0 S22) (bvshl X5 S23)) (= X11 (bvsub (bvshl X0 S22) (bvshl X5 S23))))\n (and (shlok X5 S22) (shlok X0 S23) (bvugt (bvshl X5 S22) (bvshl X0 S23)) (= X11 (bvsub (bvshl X5 S22) (bvshl X0 S23))))\n (and (shlok X0 S22) (shlok X6 S23) (addok (bvshl X0 S22) (bvshl X6 S23)) (= X11 (bvadd (bvshl X0 S22) (bvshl X6 S23))))\n (and (shlok X0 S22) (shlok X6 S23) (bvugt (bvshl X0 S22) (bvshl X6 S23)) (= X11 (bvsub (bvshl X0 S22) (bvshl X6 S23))))\n (and (shlok X6 S22) (shlok X0 S23) (bvugt (bvshl X6 S22) (bvshl X0 S23)) (= X11 (bvsub (bvshl X6 S22) (bvshl X0 S23))))\n (and (shlok X0 S22) (shlok X7 S23) (addok (bvshl X0 S22) (bvshl X7 S23)) (= X11 (bvadd (bvshl X0 S22) (bvshl X7 S23))))\n (and (shlok X0 S22) (shlok X7 S23) (bvugt (bvshl X0 S22) (bvshl X7 S23)) (= X11 (bvsub (bvshl X0 S22) (bvshl X7 S23))))\n (and (shlok X7 S22) (shlok X0 S23) (bvugt (bvshl X7 S22) (bvshl X0 S23)) (= X11 (bvsub (bvshl X7 S22) (bvshl X0 S23))))\n (and (shlok X0 S22) (shlok X8 S23) (addok (bvshl X0 S22) (bvshl X8 S23)) (= X11 (bvadd (bvshl X0 S22) (bvshl X8 S23))))\n (and (shlok X0 S22) (shlok X8 S23) (bvugt (bvshl X0 S22) (bvshl X8 S23)) (= X11 (bvsub (bvshl X0 S22) (bvshl X8 S23))))\n (and (shlok X8 S22) (shlok X0 S23) (bvugt (bvshl X8 S22) (bvshl X0 S23)) (= X11 (bvsub (bvshl X8 S22) (bvshl X0 S23))))\n (and (shlok X0 S22) (shlok X9 S23) (addok (bvshl X0 S22) (bvshl X9 S23)) (= X11 (bvadd (bvshl X0 S22) (bvshl X9 S23))))\n (and (shlok X0 S22) (shlok X9 S23) (bvugt (bvshl X0 S22) (bvshl X9 S23)) (= X11 (bvsub (bvshl X0 S22) (bvshl X9 S23))))\n (and (shlok X9 S22) (shlok X0 S23) (bvugt (bvshl X9 S22) (bvshl X0 S23)) (= X11 (bvsub (bvshl X9 S22) (bvshl X0 S23))))\n (and (shlok X0 S22) (shlok X10 S23) (addok (bvshl X0 S22) (bvshl X10 S23)) (= X11 (bvadd (bvshl X0 S22) (bvshl X10 S23))))\n (and (shlok X0 S22) (shlok X10 S23) (bvugt (bvshl X0 S22) (bvshl X10 S23)) (= X11 (bvsub (bvshl X0 S22) (bvshl X10 S23))))\n (and (shlok X10 S22) (shlok X0 S23) (bvugt (bvshl X10 S22) (bvshl X0 S23)) (= X11 (bvsub (bvshl X10 S22) (bvshl X0 S23))))\n (and (shlok X1 S22) (addok (bvshl X1 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvadd (bvshl X1 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X1 S22) (bvugt (bvshl X1 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvsub (bvshl X1 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X1 S23) (bvugt (bvshl (_ bv1 11) S22) (bvshl X1 S23)) (= X11 (bvsub (bvshl (_ bv1 11) S22) (bvshl X1 S23))))\n (and (bvugt S22 S23) (shlok X1 S22) (addok (bvshl X1 S22) (bvshl X1 S23)) (= X11 (bvadd (bvshl X1 S22) (bvshl X1 S23))))\n (and (bvugt S22 S23) (shlok X1 S22) (= X11 (bvsub (bvshl X1 S22) (bvshl X1 S23))))\n (and (shlok X1 S22) (shlok X2 S23) (addok (bvshl X1 S22) (bvshl X2 S23)) (= X11 (bvadd (bvshl X1 S22) (bvshl X2 S23))))\n (and (shlok X1 S22) (shlok X2 S23) (bvugt (bvshl X1 S22) (bvshl X2 S23)) (= X11 (bvsub (bvshl X1 S22) (bvshl X2 S23))))\n (and (shlok X2 S22) (shlok X1 S23) (bvugt (bvshl X2 S22) (bvshl X1 S23)) (= X11 (bvsub (bvshl X2 S22) (bvshl X1 S23))))\n (and (shlok X1 S22) (shlok X3 S23) (addok (bvshl X1 S22) (bvshl X3 S23)) (= X11 (bvadd (bvshl X1 S22) (bvshl X3 S23))))\n (and (shlok X1 S22) (shlok X3 S23) (bvugt (bvshl X1 S22) (bvshl X3 S23)) (= X11 (bvsub (bvshl X1 S22) (bvshl X3 S23))))\n (and (shlok X3 S22) (shlok X1 S23) (bvugt (bvshl X3 S22) (bvshl X1 S23)) (= X11 (bvsub (bvshl X3 S22) (bvshl X1 S23))))\n (and (shlok X1 S22) (shlok X4 S23) (addok (bvshl X1 S22) (bvshl X4 S23)) (= X11 (bvadd (bvshl X1 S22) (bvshl X4 S23))))\n (and (shlok X1 S22) (shlok X4 S23) (bvugt (bvshl X1 S22) (bvshl X4 S23)) (= X11 (bvsub (bvshl X1 S22) (bvshl X4 S23))))\n (and (shlok X4 S22) (shlok X1 S23) (bvugt (bvshl X4 S22) (bvshl X1 S23)) (= X11 (bvsub (bvshl X4 S22) (bvshl X1 S23))))\n (and (shlok X1 S22) (shlok X5 S23) (addok (bvshl X1 S22) (bvshl X5 S23)) (= X11 (bvadd (bvshl X1 S22) (bvshl X5 S23))))\n (and (shlok X1 S22) (shlok X5 S23) (bvugt (bvshl X1 S22) (bvshl X5 S23)) (= X11 (bvsub (bvshl X1 S22) (bvshl X5 S23))))\n (and (shlok X5 S22) (shlok X1 S23) (bvugt (bvshl X5 S22) (bvshl X1 S23)) (= X11 (bvsub (bvshl X5 S22) (bvshl X1 S23))))\n (and (shlok X1 S22) (shlok X6 S23) (addok (bvshl X1 S22) (bvshl X6 S23)) (= X11 (bvadd (bvshl X1 S22) (bvshl X6 S23))))\n (and (shlok X1 S22) (shlok X6 S23) (bvugt (bvshl X1 S22) (bvshl X6 S23)) (= X11 (bvsub (bvshl X1 S22) (bvshl X6 S23))))\n (and (shlok X6 S22) (shlok X1 S23) (bvugt (bvshl X6 S22) (bvshl X1 S23)) (= X11 (bvsub (bvshl X6 S22) (bvshl X1 S23))))\n (and (shlok X1 S22) (shlok X7 S23) (addok (bvshl X1 S22) (bvshl X7 S23)) (= X11 (bvadd (bvshl X1 S22) (bvshl X7 S23))))\n (and (shlok X1 S22) (shlok X7 S23) (bvugt (bvshl X1 S22) (bvshl X7 S23)) (= X11 (bvsub (bvshl X1 S22) (bvshl X7 S23))))\n (and (shlok X7 S22) (shlok X1 S23) (bvugt (bvshl X7 S22) (bvshl X1 S23)) (= X11 (bvsub (bvshl X7 S22) (bvshl X1 S23))))\n (and (shlok X1 S22) (shlok X8 S23) (addok (bvshl X1 S22) (bvshl X8 S23)) (= X11 (bvadd (bvshl X1 S22) (bvshl X8 S23))))\n (and (shlok X1 S22) (shlok X8 S23) (bvugt (bvshl X1 S22) (bvshl X8 S23)) (= X11 (bvsub (bvshl X1 S22) (bvshl X8 S23))))\n (and (shlok X8 S22) (shlok X1 S23) (bvugt (bvshl X8 S22) (bvshl X1 S23)) (= X11 (bvsub (bvshl X8 S22) (bvshl X1 S23))))\n (and (shlok X1 S22) (shlok X9 S23) (addok (bvshl X1 S22) (bvshl X9 S23)) (= X11 (bvadd (bvshl X1 S22) (bvshl X9 S23))))\n (and (shlok X1 S22) (shlok X9 S23) (bvugt (bvshl X1 S22) (bvshl X9 S23)) (= X11 (bvsub (bvshl X1 S22) (bvshl X9 S23))))\n (and (shlok X9 S22) (shlok X1 S23) (bvugt (bvshl X9 S22) (bvshl X1 S23)) (= X11 (bvsub (bvshl X9 S22) (bvshl X1 S23))))\n (and (shlok X1 S22) (shlok X10 S23) (addok (bvshl X1 S22) (bvshl X10 S23)) (= X11 (bvadd (bvshl X1 S22) (bvshl X10 S23))))\n (and (shlok X1 S22) (shlok X10 S23) (bvugt (bvshl X1 S22) (bvshl X10 S23)) (= X11 (bvsub (bvshl X1 S22) (bvshl X10 S23))))\n (and (shlok X10 S22) (shlok X1 S23) (bvugt (bvshl X10 S22) (bvshl X1 S23)) (= X11 (bvsub (bvshl X10 S22) (bvshl X1 S23))))\n (and (shlok X2 S22) (addok (bvshl X2 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvadd (bvshl X2 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X2 S22) (bvugt (bvshl X2 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvsub (bvshl X2 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X2 S23) (bvugt (bvshl (_ bv1 11) S22) (bvshl X2 S23)) (= X11 (bvsub (bvshl (_ bv1 11) S22) (bvshl X2 S23))))\n (and (bvugt S22 S23) (shlok X2 S22) (addok (bvshl X2 S22) (bvshl X2 S23)) (= X11 (bvadd (bvshl X2 S22) (bvshl X2 S23))))\n (and (bvugt S22 S23) (shlok X2 S22) (= X11 (bvsub (bvshl X2 S22) (bvshl X2 S23))))\n (and (shlok X2 S22) (shlok X3 S23) (addok (bvshl X2 S22) (bvshl X3 S23)) (= X11 (bvadd (bvshl X2 S22) (bvshl X3 S23))))\n (and (shlok X2 S22) (shlok X3 S23) (bvugt (bvshl X2 S22) (bvshl X3 S23)) (= X11 (bvsub (bvshl X2 S22) (bvshl X3 S23))))\n (and (shlok X3 S22) (shlok X2 S23) (bvugt (bvshl X3 S22) (bvshl X2 S23)) (= X11 (bvsub (bvshl X3 S22) (bvshl X2 S23))))\n (and (shlok X2 S22) (shlok X4 S23) (addok (bvshl X2 S22) (bvshl X4 S23)) (= X11 (bvadd (bvshl X2 S22) (bvshl X4 S23))))\n (and (shlok X2 S22) (shlok X4 S23) (bvugt (bvshl X2 S22) (bvshl X4 S23)) (= X11 (bvsub (bvshl X2 S22) (bvshl X4 S23))))\n (and (shlok X4 S22) (shlok X2 S23) (bvugt (bvshl X4 S22) (bvshl X2 S23)) (= X11 (bvsub (bvshl X4 S22) (bvshl X2 S23))))\n (and (shlok X2 S22) (shlok X5 S23) (addok (bvshl X2 S22) (bvshl X5 S23)) (= X11 (bvadd (bvshl X2 S22) (bvshl X5 S23))))\n (and (shlok X2 S22) (shlok X5 S23) (bvugt (bvshl X2 S22) (bvshl X5 S23)) (= X11 (bvsub (bvshl X2 S22) (bvshl X5 S23))))\n (and (shlok X5 S22) (shlok X2 S23) (bvugt (bvshl X5 S22) (bvshl X2 S23)) (= X11 (bvsub (bvshl X5 S22) (bvshl X2 S23))))\n (and (shlok X2 S22) (shlok X6 S23) (addok (bvshl X2 S22) (bvshl X6 S23)) (= X11 (bvadd (bvshl X2 S22) (bvshl X6 S23))))\n (and (shlok X2 S22) (shlok X6 S23) (bvugt (bvshl X2 S22) (bvshl X6 S23)) (= X11 (bvsub (bvshl X2 S22) (bvshl X6 S23))))\n (and (shlok X6 S22) (shlok X2 S23) (bvugt (bvshl X6 S22) (bvshl X2 S23)) (= X11 (bvsub (bvshl X6 S22) (bvshl X2 S23))))\n (and (shlok X2 S22) (shlok X7 S23) (addok (bvshl X2 S22) (bvshl X7 S23)) (= X11 (bvadd (bvshl X2 S22) (bvshl X7 S23))))\n (and (shlok X2 S22) (shlok X7 S23) (bvugt (bvshl X2 S22) (bvshl X7 S23)) (= X11 (bvsub (bvshl X2 S22) (bvshl X7 S23))))\n (and (shlok X7 S22) (shlok X2 S23) (bvugt (bvshl X7 S22) (bvshl X2 S23)) (= X11 (bvsub (bvshl X7 S22) (bvshl X2 S23))))\n (and (shlok X2 S22) (shlok X8 S23) (addok (bvshl X2 S22) (bvshl X8 S23)) (= X11 (bvadd (bvshl X2 S22) (bvshl X8 S23))))\n (and (shlok X2 S22) (shlok X8 S23) (bvugt (bvshl X2 S22) (bvshl X8 S23)) (= X11 (bvsub (bvshl X2 S22) (bvshl X8 S23))))\n (and (shlok X8 S22) (shlok X2 S23) (bvugt (bvshl X8 S22) (bvshl X2 S23)) (= X11 (bvsub (bvshl X8 S22) (bvshl X2 S23))))\n (and (shlok X2 S22) (shlok X9 S23) (addok (bvshl X2 S22) (bvshl X9 S23)) (= X11 (bvadd (bvshl X2 S22) (bvshl X9 S23))))\n (and (shlok X2 S22) (shlok X9 S23) (bvugt (bvshl X2 S22) (bvshl X9 S23)) (= X11 (bvsub (bvshl X2 S22) (bvshl X9 S23))))\n (and (shlok X9 S22) (shlok X2 S23) (bvugt (bvshl X9 S22) (bvshl X2 S23)) (= X11 (bvsub (bvshl X9 S22) (bvshl X2 S23))))\n (and (shlok X2 S22) (shlok X10 S23) (addok (bvshl X2 S22) (bvshl X10 S23)) (= X11 (bvadd (bvshl X2 S22) (bvshl X10 S23))))\n (and (shlok X2 S22) (shlok X10 S23) (bvugt (bvshl X2 S22) (bvshl X10 S23)) (= X11 (bvsub (bvshl X2 S22) (bvshl X10 S23))))\n (and (shlok X10 S22) (shlok X2 S23) (bvugt (bvshl X10 S22) (bvshl X2 S23)) (= X11 (bvsub (bvshl X10 S22) (bvshl X2 S23))))\n (and (shlok X3 S22) (addok (bvshl X3 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvadd (bvshl X3 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X3 S22) (bvugt (bvshl X3 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvsub (bvshl X3 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X3 S23) (bvugt (bvshl (_ bv1 11) S22) (bvshl X3 S23)) (= X11 (bvsub (bvshl (_ bv1 11) S22) (bvshl X3 S23))))\n (and (bvugt S22 S23) (shlok X3 S22) (addok (bvshl X3 S22) (bvshl X3 S23)) (= X11 (bvadd (bvshl X3 S22) (bvshl X3 S23))))\n (and (bvugt S22 S23) (shlok X3 S22) (= X11 (bvsub (bvshl X3 S22) (bvshl X3 S23))))\n (and (shlok X3 S22) (shlok X4 S23) (addok (bvshl X3 S22) (bvshl X4 S23)) (= X11 (bvadd (bvshl X3 S22) (bvshl X4 S23))))\n (and (shlok X3 S22) (shlok X4 S23) (bvugt (bvshl X3 S22) (bvshl X4 S23)) (= X11 (bvsub (bvshl X3 S22) (bvshl X4 S23))))\n (and (shlok X4 S22) (shlok X3 S23) (bvugt (bvshl X4 S22) (bvshl X3 S23)) (= X11 (bvsub (bvshl X4 S22) (bvshl X3 S23))))\n (and (shlok X3 S22) (shlok X5 S23) (addok (bvshl X3 S22) (bvshl X5 S23)) (= X11 (bvadd (bvshl X3 S22) (bvshl X5 S23))))\n (and (shlok X3 S22) (shlok X5 S23) (bvugt (bvshl X3 S22) (bvshl X5 S23)) (= X11 (bvsub (bvshl X3 S22) (bvshl X5 S23))))\n (and (shlok X5 S22) (shlok X3 S23) (bvugt (bvshl X5 S22) (bvshl X3 S23)) (= X11 (bvsub (bvshl X5 S22) (bvshl X3 S23))))\n (and (shlok X3 S22) (shlok X6 S23) (addok (bvshl X3 S22) (bvshl X6 S23)) (= X11 (bvadd (bvshl X3 S22) (bvshl X6 S23))))\n (and (shlok X3 S22) (shlok X6 S23) (bvugt (bvshl X3 S22) (bvshl X6 S23)) (= X11 (bvsub (bvshl X3 S22) (bvshl X6 S23))))\n (and (shlok X6 S22) (shlok X3 S23) (bvugt (bvshl X6 S22) (bvshl X3 S23)) (= X11 (bvsub (bvshl X6 S22) (bvshl X3 S23))))\n (and (shlok X3 S22) (shlok X7 S23) (addok (bvshl X3 S22) (bvshl X7 S23)) (= X11 (bvadd (bvshl X3 S22) (bvshl X7 S23))))\n (and (shlok X3 S22) (shlok X7 S23) (bvugt (bvshl X3 S22) (bvshl X7 S23)) (= X11 (bvsub (bvshl X3 S22) (bvshl X7 S23))))\n (and (shlok X7 S22) (shlok X3 S23) (bvugt (bvshl X7 S22) (bvshl X3 S23)) (= X11 (bvsub (bvshl X7 S22) (bvshl X3 S23))))\n (and (shlok X3 S22) (shlok X8 S23) (addok (bvshl X3 S22) (bvshl X8 S23)) (= X11 (bvadd (bvshl X3 S22) (bvshl X8 S23))))\n (and (shlok X3 S22) (shlok X8 S23) (bvugt (bvshl X3 S22) (bvshl X8 S23)) (= X11 (bvsub (bvshl X3 S22) (bvshl X8 S23))))\n (and (shlok X8 S22) (shlok X3 S23) (bvugt (bvshl X8 S22) (bvshl X3 S23)) (= X11 (bvsub (bvshl X8 S22) (bvshl X3 S23))))\n (and (shlok X3 S22) (shlok X9 S23) (addok (bvshl X3 S22) (bvshl X9 S23)) (= X11 (bvadd (bvshl X3 S22) (bvshl X9 S23))))\n (and (shlok X3 S22) (shlok X9 S23) (bvugt (bvshl X3 S22) (bvshl X9 S23)) (= X11 (bvsub (bvshl X3 S22) (bvshl X9 S23))))\n (and (shlok X9 S22) (shlok X3 S23) (bvugt (bvshl X9 S22) (bvshl X3 S23)) (= X11 (bvsub (bvshl X9 S22) (bvshl X3 S23))))\n (and (shlok X3 S22) (shlok X10 S23) (addok (bvshl X3 S22) (bvshl X10 S23)) (= X11 (bvadd (bvshl X3 S22) (bvshl X10 S23))))\n (and (shlok X3 S22) (shlok X10 S23) (bvugt (bvshl X3 S22) (bvshl X10 S23)) (= X11 (bvsub (bvshl X3 S22) (bvshl X10 S23))))\n (and (shlok X10 S22) (shlok X3 S23) (bvugt (bvshl X10 S22) (bvshl X3 S23)) (= X11 (bvsub (bvshl X10 S22) (bvshl X3 S23))))\n (and (shlok X4 S22) (addok (bvshl X4 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvadd (bvshl X4 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X4 S22) (bvugt (bvshl X4 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvsub (bvshl X4 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X4 S23) (bvugt (bvshl (_ bv1 11) S22) (bvshl X4 S23)) (= X11 (bvsub (bvshl (_ bv1 11) S22) (bvshl X4 S23))))\n (and (bvugt S22 S23) (shlok X4 S22) (addok (bvshl X4 S22) (bvshl X4 S23)) (= X11 (bvadd (bvshl X4 S22) (bvshl X4 S23))))\n (and (bvugt S22 S23) (shlok X4 S22) (= X11 (bvsub (bvshl X4 S22) (bvshl X4 S23))))\n (and (shlok X4 S22) (shlok X5 S23) (addok (bvshl X4 S22) (bvshl X5 S23)) (= X11 (bvadd (bvshl X4 S22) (bvshl X5 S23))))\n (and (shlok X4 S22) (shlok X5 S23) (bvugt (bvshl X4 S22) (bvshl X5 S23)) (= X11 (bvsub (bvshl X4 S22) (bvshl X5 S23))))\n (and (shlok X5 S22) (shlok X4 S23) (bvugt (bvshl X5 S22) (bvshl X4 S23)) (= X11 (bvsub (bvshl X5 S22) (bvshl X4 S23))))\n (and (shlok X4 S22) (shlok X6 S23) (addok (bvshl X4 S22) (bvshl X6 S23)) (= X11 (bvadd (bvshl X4 S22) (bvshl X6 S23))))\n (and (shlok X4 S22) (shlok X6 S23) (bvugt (bvshl X4 S22) (bvshl X6 S23)) (= X11 (bvsub (bvshl X4 S22) (bvshl X6 S23))))\n (and (shlok X6 S22) (shlok X4 S23) (bvugt (bvshl X6 S22) (bvshl X4 S23)) (= X11 (bvsub (bvshl X6 S22) (bvshl X4 S23))))\n (and (shlok X4 S22) (shlok X7 S23) (addok (bvshl X4 S22) (bvshl X7 S23)) (= X11 (bvadd (bvshl X4 S22) (bvshl X7 S23))))\n (and (shlok X4 S22) (shlok X7 S23) (bvugt (bvshl X4 S22) (bvshl X7 S23)) (= X11 (bvsub (bvshl X4 S22) (bvshl X7 S23))))\n (and (shlok X7 S22) (shlok X4 S23) (bvugt (bvshl X7 S22) (bvshl X4 S23)) (= X11 (bvsub (bvshl X7 S22) (bvshl X4 S23))))\n (and (shlok X4 S22) (shlok X8 S23) (addok (bvshl X4 S22) (bvshl X8 S23)) (= X11 (bvadd (bvshl X4 S22) (bvshl X8 S23))))\n (and (shlok X4 S22) (shlok X8 S23) (bvugt (bvshl X4 S22) (bvshl X8 S23)) (= X11 (bvsub (bvshl X4 S22) (bvshl X8 S23))))\n (and (shlok X8 S22) (shlok X4 S23) (bvugt (bvshl X8 S22) (bvshl X4 S23)) (= X11 (bvsub (bvshl X8 S22) (bvshl X4 S23))))\n (and (shlok X4 S22) (shlok X9 S23) (addok (bvshl X4 S22) (bvshl X9 S23)) (= X11 (bvadd (bvshl X4 S22) (bvshl X9 S23))))\n (and (shlok X4 S22) (shlok X9 S23) (bvugt (bvshl X4 S22) (bvshl X9 S23)) (= X11 (bvsub (bvshl X4 S22) (bvshl X9 S23))))\n (and (shlok X9 S22) (shlok X4 S23) (bvugt (bvshl X9 S22) (bvshl X4 S23)) (= X11 (bvsub (bvshl X9 S22) (bvshl X4 S23))))\n (and (shlok X4 S22) (shlok X10 S23) (addok (bvshl X4 S22) (bvshl X10 S23)) (= X11 (bvadd (bvshl X4 S22) (bvshl X10 S23))))\n (and (shlok X4 S22) (shlok X10 S23) (bvugt (bvshl X4 S22) (bvshl X10 S23)) (= X11 (bvsub (bvshl X4 S22) (bvshl X10 S23))))\n (and (shlok X10 S22) (shlok X4 S23) (bvugt (bvshl X10 S22) (bvshl X4 S23)) (= X11 (bvsub (bvshl X10 S22) (bvshl X4 S23))))\n (and (shlok X5 S22) (addok (bvshl X5 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvadd (bvshl X5 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X5 S22) (bvugt (bvshl X5 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvsub (bvshl X5 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X5 S23) (bvugt (bvshl (_ bv1 11) S22) (bvshl X5 S23)) (= X11 (bvsub (bvshl (_ bv1 11) S22) (bvshl X5 S23))))\n (and (bvugt S22 S23) (shlok X5 S22) (addok (bvshl X5 S22) (bvshl X5 S23)) (= X11 (bvadd (bvshl X5 S22) (bvshl X5 S23))))\n (and (bvugt S22 S23) (shlok X5 S22) (= X11 (bvsub (bvshl X5 S22) (bvshl X5 S23))))\n (and (shlok X5 S22) (shlok X6 S23) (addok (bvshl X5 S22) (bvshl X6 S23)) (= X11 (bvadd (bvshl X5 S22) (bvshl X6 S23))))\n (and (shlok X5 S22) (shlok X6 S23) (bvugt (bvshl X5 S22) (bvshl X6 S23)) (= X11 (bvsub (bvshl X5 S22) (bvshl X6 S23))))\n (and (shlok X6 S22) (shlok X5 S23) (bvugt (bvshl X6 S22) (bvshl X5 S23)) (= X11 (bvsub (bvshl X6 S22) (bvshl X5 S23))))\n (and (shlok X5 S22) (shlok X7 S23) (addok (bvshl X5 S22) (bvshl X7 S23)) (= X11 (bvadd (bvshl X5 S22) (bvshl X7 S23))))\n (and (shlok X5 S22) (shlok X7 S23) (bvugt (bvshl X5 S22) (bvshl X7 S23)) (= X11 (bvsub (bvshl X5 S22) (bvshl X7 S23))))\n (and (shlok X7 S22) (shlok X5 S23) (bvugt (bvshl X7 S22) (bvshl X5 S23)) (= X11 (bvsub (bvshl X7 S22) (bvshl X5 S23))))\n (and (shlok X5 S22) (shlok X8 S23) (addok (bvshl X5 S22) (bvshl X8 S23)) (= X11 (bvadd (bvshl X5 S22) (bvshl X8 S23))))\n (and (shlok X5 S22) (shlok X8 S23) (bvugt (bvshl X5 S22) (bvshl X8 S23)) (= X11 (bvsub (bvshl X5 S22) (bvshl X8 S23))))\n (and (shlok X8 S22) (shlok X5 S23) (bvugt (bvshl X8 S22) (bvshl X5 S23)) (= X11 (bvsub (bvshl X8 S22) (bvshl X5 S23))))\n (and (shlok X5 S22) (shlok X9 S23) (addok (bvshl X5 S22) (bvshl X9 S23)) (= X11 (bvadd (bvshl X5 S22) (bvshl X9 S23))))\n (and (shlok X5 S22) (shlok X9 S23) (bvugt (bvshl X5 S22) (bvshl X9 S23)) (= X11 (bvsub (bvshl X5 S22) (bvshl X9 S23))))\n (and (shlok X9 S22) (shlok X5 S23) (bvugt (bvshl X9 S22) (bvshl X5 S23)) (= X11 (bvsub (bvshl X9 S22) (bvshl X5 S23))))\n (and (shlok X5 S22) (shlok X10 S23) (addok (bvshl X5 S22) (bvshl X10 S23)) (= X11 (bvadd (bvshl X5 S22) (bvshl X10 S23))))\n (and (shlok X5 S22) (shlok X10 S23) (bvugt (bvshl X5 S22) (bvshl X10 S23)) (= X11 (bvsub (bvshl X5 S22) (bvshl X10 S23))))\n (and (shlok X10 S22) (shlok X5 S23) (bvugt (bvshl X10 S22) (bvshl X5 S23)) (= X11 (bvsub (bvshl X10 S22) (bvshl X5 S23))))\n (and (shlok X6 S22) (addok (bvshl X6 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvadd (bvshl X6 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X6 S22) (bvugt (bvshl X6 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvsub (bvshl X6 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X6 S23) (bvugt (bvshl (_ bv1 11) S22) (bvshl X6 S23)) (= X11 (bvsub (bvshl (_ bv1 11) S22) (bvshl X6 S23))))\n (and (bvugt S22 S23) (shlok X6 S22) (addok (bvshl X6 S22) (bvshl X6 S23)) (= X11 (bvadd (bvshl X6 S22) (bvshl X6 S23))))\n (and (bvugt S22 S23) (shlok X6 S22) (= X11 (bvsub (bvshl X6 S22) (bvshl X6 S23))))\n (and (shlok X6 S22) (shlok X7 S23) (addok (bvshl X6 S22) (bvshl X7 S23)) (= X11 (bvadd (bvshl X6 S22) (bvshl X7 S23))))\n (and (shlok X6 S22) (shlok X7 S23) (bvugt (bvshl X6 S22) (bvshl X7 S23)) (= X11 (bvsub (bvshl X6 S22) (bvshl X7 S23))))\n (and (shlok X7 S22) (shlok X6 S23) (bvugt (bvshl X7 S22) (bvshl X6 S23)) (= X11 (bvsub (bvshl X7 S22) (bvshl X6 S23))))\n (and (shlok X6 S22) (shlok X8 S23) (addok (bvshl X6 S22) (bvshl X8 S23)) (= X11 (bvadd (bvshl X6 S22) (bvshl X8 S23))))\n (and (shlok X6 S22) (shlok X8 S23) (bvugt (bvshl X6 S22) (bvshl X8 S23)) (= X11 (bvsub (bvshl X6 S22) (bvshl X8 S23))))\n (and (shlok X8 S22) (shlok X6 S23) (bvugt (bvshl X8 S22) (bvshl X6 S23)) (= X11 (bvsub (bvshl X8 S22) (bvshl X6 S23))))\n (and (shlok X6 S22) (shlok X9 S23) (addok (bvshl X6 S22) (bvshl X9 S23)) (= X11 (bvadd (bvshl X6 S22) (bvshl X9 S23))))\n (and (shlok X6 S22) (shlok X9 S23) (bvugt (bvshl X6 S22) (bvshl X9 S23)) (= X11 (bvsub (bvshl X6 S22) (bvshl X9 S23))))\n (and (shlok X9 S22) (shlok X6 S23) (bvugt (bvshl X9 S22) (bvshl X6 S23)) (= X11 (bvsub (bvshl X9 S22) (bvshl X6 S23))))\n (and (shlok X6 S22) (shlok X10 S23) (addok (bvshl X6 S22) (bvshl X10 S23)) (= X11 (bvadd (bvshl X6 S22) (bvshl X10 S23))))\n (and (shlok X6 S22) (shlok X10 S23) (bvugt (bvshl X6 S22) (bvshl X10 S23)) (= X11 (bvsub (bvshl X6 S22) (bvshl X10 S23))))\n (and (shlok X10 S22) (shlok X6 S23) (bvugt (bvshl X10 S22) (bvshl X6 S23)) (= X11 (bvsub (bvshl X10 S22) (bvshl X6 S23))))\n (and (shlok X7 S22) (addok (bvshl X7 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvadd (bvshl X7 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X7 S22) (bvugt (bvshl X7 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvsub (bvshl X7 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X7 S23) (bvugt (bvshl (_ bv1 11) S22) (bvshl X7 S23)) (= X11 (bvsub (bvshl (_ bv1 11) S22) (bvshl X7 S23))))\n (and (bvugt S22 S23) (shlok X7 S22) (addok (bvshl X7 S22) (bvshl X7 S23)) (= X11 (bvadd (bvshl X7 S22) (bvshl X7 S23))))\n (and (bvugt S22 S23) (shlok X7 S22) (= X11 (bvsub (bvshl X7 S22) (bvshl X7 S23))))\n (and (shlok X7 S22) (shlok X8 S23) (addok (bvshl X7 S22) (bvshl X8 S23)) (= X11 (bvadd (bvshl X7 S22) (bvshl X8 S23))))\n (and (shlok X7 S22) (shlok X8 S23) (bvugt (bvshl X7 S22) (bvshl X8 S23)) (= X11 (bvsub (bvshl X7 S22) (bvshl X8 S23))))\n (and (shlok X8 S22) (shlok X7 S23) (bvugt (bvshl X8 S22) (bvshl X7 S23)) (= X11 (bvsub (bvshl X8 S22) (bvshl X7 S23))))\n (and (shlok X7 S22) (shlok X9 S23) (addok (bvshl X7 S22) (bvshl X9 S23)) (= X11 (bvadd (bvshl X7 S22) (bvshl X9 S23))))\n (and (shlok X7 S22) (shlok X9 S23) (bvugt (bvshl X7 S22) (bvshl X9 S23)) (= X11 (bvsub (bvshl X7 S22) (bvshl X9 S23))))\n (and (shlok X9 S22) (shlok X7 S23) (bvugt (bvshl X9 S22) (bvshl X7 S23)) (= X11 (bvsub (bvshl X9 S22) (bvshl X7 S23))))\n (and (shlok X7 S22) (shlok X10 S23) (addok (bvshl X7 S22) (bvshl X10 S23)) (= X11 (bvadd (bvshl X7 S22) (bvshl X10 S23))))\n (and (shlok X7 S22) (shlok X10 S23) (bvugt (bvshl X7 S22) (bvshl X10 S23)) (= X11 (bvsub (bvshl X7 S22) (bvshl X10 S23))))\n (and (shlok X10 S22) (shlok X7 S23) (bvugt (bvshl X10 S22) (bvshl X7 S23)) (= X11 (bvsub (bvshl X10 S22) (bvshl X7 S23))))\n (and (shlok X8 S22) (addok (bvshl X8 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvadd (bvshl X8 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X8 S22) (bvugt (bvshl X8 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvsub (bvshl X8 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X8 S23) (bvugt (bvshl (_ bv1 11) S22) (bvshl X8 S23)) (= X11 (bvsub (bvshl (_ bv1 11) S22) (bvshl X8 S23))))\n (and (bvugt S22 S23) (shlok X8 S22) (addok (bvshl X8 S22) (bvshl X8 S23)) (= X11 (bvadd (bvshl X8 S22) (bvshl X8 S23))))\n (and (bvugt S22 S23) (shlok X8 S22) (= X11 (bvsub (bvshl X8 S22) (bvshl X8 S23))))\n (and (shlok X8 S22) (shlok X9 S23) (addok (bvshl X8 S22) (bvshl X9 S23)) (= X11 (bvadd (bvshl X8 S22) (bvshl X9 S23))))\n (and (shlok X8 S22) (shlok X9 S23) (bvugt (bvshl X8 S22) (bvshl X9 S23)) (= X11 (bvsub (bvshl X8 S22) (bvshl X9 S23))))\n (and (shlok X9 S22) (shlok X8 S23) (bvugt (bvshl X9 S22) (bvshl X8 S23)) (= X11 (bvsub (bvshl X9 S22) (bvshl X8 S23))))\n (and (shlok X8 S22) (shlok X10 S23) (addok (bvshl X8 S22) (bvshl X10 S23)) (= X11 (bvadd (bvshl X8 S22) (bvshl X10 S23))))\n (and (shlok X8 S22) (shlok X10 S23) (bvugt (bvshl X8 S22) (bvshl X10 S23)) (= X11 (bvsub (bvshl X8 S22) (bvshl X10 S23))))\n (and (shlok X10 S22) (shlok X8 S23) (bvugt (bvshl X10 S22) (bvshl X8 S23)) (= X11 (bvsub (bvshl X10 S22) (bvshl X8 S23))))\n (and (shlok X9 S22) (addok (bvshl X9 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvadd (bvshl X9 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X9 S22) (bvugt (bvshl X9 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvsub (bvshl X9 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X9 S23) (bvugt (bvshl (_ bv1 11) S22) (bvshl X9 S23)) (= X11 (bvsub (bvshl (_ bv1 11) S22) (bvshl X9 S23))))\n (and (bvugt S22 S23) (shlok X9 S22) (addok (bvshl X9 S22) (bvshl X9 S23)) (= X11 (bvadd (bvshl X9 S22) (bvshl X9 S23))))\n (and (bvugt S22 S23) (shlok X9 S22) (= X11 (bvsub (bvshl X9 S22) (bvshl X9 S23))))\n (and (shlok X9 S22) (shlok X10 S23) (addok (bvshl X9 S22) (bvshl X10 S23)) (= X11 (bvadd (bvshl X9 S22) (bvshl X10 S23))))\n (and (shlok X9 S22) (shlok X10 S23) (bvugt (bvshl X9 S22) (bvshl X10 S23)) (= X11 (bvsub (bvshl X9 S22) (bvshl X10 S23))))\n (and (shlok X10 S22) (shlok X9 S23) (bvugt (bvshl X10 S22) (bvshl X9 S23)) (= X11 (bvsub (bvshl X10 S22) (bvshl X9 S23))))\n (and (shlok X10 S22) (addok (bvshl X10 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvadd (bvshl X10 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X10 S22) (bvugt (bvshl X10 S22) (bvshl (_ bv1 11) S23)) (= X11 (bvsub (bvshl X10 S22) (bvshl (_ bv1 11) S23))))\n (and (shlok X10 S23) (bvugt (bvshl (_ bv1 11) S22) (bvshl X10 S23)) (= X11 (bvsub (bvshl (_ bv1 11) S22) (bvshl X10 S23))))\n (and (bvugt S22 S23) (shlok X10 S22) (addok (bvshl X10 S22) (bvshl X10 S23)) (= X11 (bvadd (bvshl X10 S22) (bvshl X10 S23))))\n (and (bvugt S22 S23) (shlok X10 S22) (= X11 (bvsub (bvshl X10 S22) (bvshl X10 S23))))\n))\n(assert (or\n (and (shlok X0 S24) (addok (bvshl X0 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvadd (bvshl X0 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X0 S24) (bvugt (bvshl X0 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvsub (bvshl X0 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X0 S25) (bvugt (bvshl (_ bv1 11) S24) (bvshl X0 S25)) (= X12 (bvsub (bvshl (_ bv1 11) S24) (bvshl X0 S25))))\n (and (bvugt S24 S25) (shlok X0 S24) (addok (bvshl X0 S24) (bvshl X0 S25)) (= X12 (bvadd (bvshl X0 S24) (bvshl X0 S25))))\n (and (bvugt S24 S25) (shlok X0 S24) (= X12 (bvsub (bvshl X0 S24) (bvshl X0 S25))))\n (and (shlok X0 S24) (shlok X1 S25) (addok (bvshl X0 S24) (bvshl X1 S25)) (= X12 (bvadd (bvshl X0 S24) (bvshl X1 S25))))\n (and (shlok X0 S24) (shlok X1 S25) (bvugt (bvshl X0 S24) (bvshl X1 S25)) (= X12 (bvsub (bvshl X0 S24) (bvshl X1 S25))))\n (and (shlok X1 S24) (shlok X0 S25) (bvugt (bvshl X1 S24) (bvshl X0 S25)) (= X12 (bvsub (bvshl X1 S24) (bvshl X0 S25))))\n (and (shlok X0 S24) (shlok X2 S25) (addok (bvshl X0 S24) (bvshl X2 S25)) (= X12 (bvadd (bvshl X0 S24) (bvshl X2 S25))))\n (and (shlok X0 S24) (shlok X2 S25) (bvugt (bvshl X0 S24) (bvshl X2 S25)) (= X12 (bvsub (bvshl X0 S24) (bvshl X2 S25))))\n (and (shlok X2 S24) (shlok X0 S25) (bvugt (bvshl X2 S24) (bvshl X0 S25)) (= X12 (bvsub (bvshl X2 S24) (bvshl X0 S25))))\n (and (shlok X0 S24) (shlok X3 S25) (addok (bvshl X0 S24) (bvshl X3 S25)) (= X12 (bvadd (bvshl X0 S24) (bvshl X3 S25))))\n (and (shlok X0 S24) (shlok X3 S25) (bvugt (bvshl X0 S24) (bvshl X3 S25)) (= X12 (bvsub (bvshl X0 S24) (bvshl X3 S25))))\n (and (shlok X3 S24) (shlok X0 S25) (bvugt (bvshl X3 S24) (bvshl X0 S25)) (= X12 (bvsub (bvshl X3 S24) (bvshl X0 S25))))\n (and (shlok X0 S24) (shlok X4 S25) (addok (bvshl X0 S24) (bvshl X4 S25)) (= X12 (bvadd (bvshl X0 S24) (bvshl X4 S25))))\n (and (shlok X0 S24) (shlok X4 S25) (bvugt (bvshl X0 S24) (bvshl X4 S25)) (= X12 (bvsub (bvshl X0 S24) (bvshl X4 S25))))\n (and (shlok X4 S24) (shlok X0 S25) (bvugt (bvshl X4 S24) (bvshl X0 S25)) (= X12 (bvsub (bvshl X4 S24) (bvshl X0 S25))))\n (and (shlok X0 S24) (shlok X5 S25) (addok (bvshl X0 S24) (bvshl X5 S25)) (= X12 (bvadd (bvshl X0 S24) (bvshl X5 S25))))\n (and (shlok X0 S24) (shlok X5 S25) (bvugt (bvshl X0 S24) (bvshl X5 S25)) (= X12 (bvsub (bvshl X0 S24) (bvshl X5 S25))))\n (and (shlok X5 S24) (shlok X0 S25) (bvugt (bvshl X5 S24) (bvshl X0 S25)) (= X12 (bvsub (bvshl X5 S24) (bvshl X0 S25))))\n (and (shlok X0 S24) (shlok X6 S25) (addok (bvshl X0 S24) (bvshl X6 S25)) (= X12 (bvadd (bvshl X0 S24) (bvshl X6 S25))))\n (and (shlok X0 S24) (shlok X6 S25) (bvugt (bvshl X0 S24) (bvshl X6 S25)) (= X12 (bvsub (bvshl X0 S24) (bvshl X6 S25))))\n (and (shlok X6 S24) (shlok X0 S25) (bvugt (bvshl X6 S24) (bvshl X0 S25)) (= X12 (bvsub (bvshl X6 S24) (bvshl X0 S25))))\n (and (shlok X0 S24) (shlok X7 S25) (addok (bvshl X0 S24) (bvshl X7 S25)) (= X12 (bvadd (bvshl X0 S24) (bvshl X7 S25))))\n (and (shlok X0 S24) (shlok X7 S25) (bvugt (bvshl X0 S24) (bvshl X7 S25)) (= X12 (bvsub (bvshl X0 S24) (bvshl X7 S25))))\n (and (shlok X7 S24) (shlok X0 S25) (bvugt (bvshl X7 S24) (bvshl X0 S25)) (= X12 (bvsub (bvshl X7 S24) (bvshl X0 S25))))\n (and (shlok X0 S24) (shlok X8 S25) (addok (bvshl X0 S24) (bvshl X8 S25)) (= X12 (bvadd (bvshl X0 S24) (bvshl X8 S25))))\n (and (shlok X0 S24) (shlok X8 S25) (bvugt (bvshl X0 S24) (bvshl X8 S25)) (= X12 (bvsub (bvshl X0 S24) (bvshl X8 S25))))\n (and (shlok X8 S24) (shlok X0 S25) (bvugt (bvshl X8 S24) (bvshl X0 S25)) (= X12 (bvsub (bvshl X8 S24) (bvshl X0 S25))))\n (and (shlok X0 S24) (shlok X9 S25) (addok (bvshl X0 S24) (bvshl X9 S25)) (= X12 (bvadd (bvshl X0 S24) (bvshl X9 S25))))\n (and (shlok X0 S24) (shlok X9 S25) (bvugt (bvshl X0 S24) (bvshl X9 S25)) (= X12 (bvsub (bvshl X0 S24) (bvshl X9 S25))))\n (and (shlok X9 S24) (shlok X0 S25) (bvugt (bvshl X9 S24) (bvshl X0 S25)) (= X12 (bvsub (bvshl X9 S24) (bvshl X0 S25))))\n (and (shlok X0 S24) (shlok X10 S25) (addok (bvshl X0 S24) (bvshl X10 S25)) (= X12 (bvadd (bvshl X0 S24) (bvshl X10 S25))))\n (and (shlok X0 S24) (shlok X10 S25) (bvugt (bvshl X0 S24) (bvshl X10 S25)) (= X12 (bvsub (bvshl X0 S24) (bvshl X10 S25))))\n (and (shlok X10 S24) (shlok X0 S25) (bvugt (bvshl X10 S24) (bvshl X0 S25)) (= X12 (bvsub (bvshl X10 S24) (bvshl X0 S25))))\n (and (shlok X0 S24) (shlok X11 S25) (addok (bvshl X0 S24) (bvshl X11 S25)) (= X12 (bvadd (bvshl X0 S24) (bvshl X11 S25))))\n (and (shlok X0 S24) (shlok X11 S25) (bvugt (bvshl X0 S24) (bvshl X11 S25)) (= X12 (bvsub (bvshl X0 S24) (bvshl X11 S25))))\n (and (shlok X11 S24) (shlok X0 S25) (bvugt (bvshl X11 S24) (bvshl X0 S25)) (= X12 (bvsub (bvshl X11 S24) (bvshl X0 S25))))\n (and (shlok X1 S24) (addok (bvshl X1 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvadd (bvshl X1 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X1 S24) (bvugt (bvshl X1 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvsub (bvshl X1 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X1 S25) (bvugt (bvshl (_ bv1 11) S24) (bvshl X1 S25)) (= X12 (bvsub (bvshl (_ bv1 11) S24) (bvshl X1 S25))))\n (and (bvugt S24 S25) (shlok X1 S24) (addok (bvshl X1 S24) (bvshl X1 S25)) (= X12 (bvadd (bvshl X1 S24) (bvshl X1 S25))))\n (and (bvugt S24 S25) (shlok X1 S24) (= X12 (bvsub (bvshl X1 S24) (bvshl X1 S25))))\n (and (shlok X1 S24) (shlok X2 S25) (addok (bvshl X1 S24) (bvshl X2 S25)) (= X12 (bvadd (bvshl X1 S24) (bvshl X2 S25))))\n (and (shlok X1 S24) (shlok X2 S25) (bvugt (bvshl X1 S24) (bvshl X2 S25)) (= X12 (bvsub (bvshl X1 S24) (bvshl X2 S25))))\n (and (shlok X2 S24) (shlok X1 S25) (bvugt (bvshl X2 S24) (bvshl X1 S25)) (= X12 (bvsub (bvshl X2 S24) (bvshl X1 S25))))\n (and (shlok X1 S24) (shlok X3 S25) (addok (bvshl X1 S24) (bvshl X3 S25)) (= X12 (bvadd (bvshl X1 S24) (bvshl X3 S25))))\n (and (shlok X1 S24) (shlok X3 S25) (bvugt (bvshl X1 S24) (bvshl X3 S25)) (= X12 (bvsub (bvshl X1 S24) (bvshl X3 S25))))\n (and (shlok X3 S24) (shlok X1 S25) (bvugt (bvshl X3 S24) (bvshl X1 S25)) (= X12 (bvsub (bvshl X3 S24) (bvshl X1 S25))))\n (and (shlok X1 S24) (shlok X4 S25) (addok (bvshl X1 S24) (bvshl X4 S25)) (= X12 (bvadd (bvshl X1 S24) (bvshl X4 S25))))\n (and (shlok X1 S24) (shlok X4 S25) (bvugt (bvshl X1 S24) (bvshl X4 S25)) (= X12 (bvsub (bvshl X1 S24) (bvshl X4 S25))))\n (and (shlok X4 S24) (shlok X1 S25) (bvugt (bvshl X4 S24) (bvshl X1 S25)) (= X12 (bvsub (bvshl X4 S24) (bvshl X1 S25))))\n (and (shlok X1 S24) (shlok X5 S25) (addok (bvshl X1 S24) (bvshl X5 S25)) (= X12 (bvadd (bvshl X1 S24) (bvshl X5 S25))))\n (and (shlok X1 S24) (shlok X5 S25) (bvugt (bvshl X1 S24) (bvshl X5 S25)) (= X12 (bvsub (bvshl X1 S24) (bvshl X5 S25))))\n (and (shlok X5 S24) (shlok X1 S25) (bvugt (bvshl X5 S24) (bvshl X1 S25)) (= X12 (bvsub (bvshl X5 S24) (bvshl X1 S25))))\n (and (shlok X1 S24) (shlok X6 S25) (addok (bvshl X1 S24) (bvshl X6 S25)) (= X12 (bvadd (bvshl X1 S24) (bvshl X6 S25))))\n (and (shlok X1 S24) (shlok X6 S25) (bvugt (bvshl X1 S24) (bvshl X6 S25)) (= X12 (bvsub (bvshl X1 S24) (bvshl X6 S25))))\n (and (shlok X6 S24) (shlok X1 S25) (bvugt (bvshl X6 S24) (bvshl X1 S25)) (= X12 (bvsub (bvshl X6 S24) (bvshl X1 S25))))\n (and (shlok X1 S24) (shlok X7 S25) (addok (bvshl X1 S24) (bvshl X7 S25)) (= X12 (bvadd (bvshl X1 S24) (bvshl X7 S25))))\n (and (shlok X1 S24) (shlok X7 S25) (bvugt (bvshl X1 S24) (bvshl X7 S25)) (= X12 (bvsub (bvshl X1 S24) (bvshl X7 S25))))\n (and (shlok X7 S24) (shlok X1 S25) (bvugt (bvshl X7 S24) (bvshl X1 S25)) (= X12 (bvsub (bvshl X7 S24) (bvshl X1 S25))))\n (and (shlok X1 S24) (shlok X8 S25) (addok (bvshl X1 S24) (bvshl X8 S25)) (= X12 (bvadd (bvshl X1 S24) (bvshl X8 S25))))\n (and (shlok X1 S24) (shlok X8 S25) (bvugt (bvshl X1 S24) (bvshl X8 S25)) (= X12 (bvsub (bvshl X1 S24) (bvshl X8 S25))))\n (and (shlok X8 S24) (shlok X1 S25) (bvugt (bvshl X8 S24) (bvshl X1 S25)) (= X12 (bvsub (bvshl X8 S24) (bvshl X1 S25))))\n (and (shlok X1 S24) (shlok X9 S25) (addok (bvshl X1 S24) (bvshl X9 S25)) (= X12 (bvadd (bvshl X1 S24) (bvshl X9 S25))))\n (and (shlok X1 S24) (shlok X9 S25) (bvugt (bvshl X1 S24) (bvshl X9 S25)) (= X12 (bvsub (bvshl X1 S24) (bvshl X9 S25))))\n (and (shlok X9 S24) (shlok X1 S25) (bvugt (bvshl X9 S24) (bvshl X1 S25)) (= X12 (bvsub (bvshl X9 S24) (bvshl X1 S25))))\n (and (shlok X1 S24) (shlok X10 S25) (addok (bvshl X1 S24) (bvshl X10 S25)) (= X12 (bvadd (bvshl X1 S24) (bvshl X10 S25))))\n (and (shlok X1 S24) (shlok X10 S25) (bvugt (bvshl X1 S24) (bvshl X10 S25)) (= X12 (bvsub (bvshl X1 S24) (bvshl X10 S25))))\n (and (shlok X10 S24) (shlok X1 S25) (bvugt (bvshl X10 S24) (bvshl X1 S25)) (= X12 (bvsub (bvshl X10 S24) (bvshl X1 S25))))\n (and (shlok X1 S24) (shlok X11 S25) (addok (bvshl X1 S24) (bvshl X11 S25)) (= X12 (bvadd (bvshl X1 S24) (bvshl X11 S25))))\n (and (shlok X1 S24) (shlok X11 S25) (bvugt (bvshl X1 S24) (bvshl X11 S25)) (= X12 (bvsub (bvshl X1 S24) (bvshl X11 S25))))\n (and (shlok X11 S24) (shlok X1 S25) (bvugt (bvshl X11 S24) (bvshl X1 S25)) (= X12 (bvsub (bvshl X11 S24) (bvshl X1 S25))))\n (and (shlok X2 S24) (addok (bvshl X2 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvadd (bvshl X2 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X2 S24) (bvugt (bvshl X2 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvsub (bvshl X2 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X2 S25) (bvugt (bvshl (_ bv1 11) S24) (bvshl X2 S25)) (= X12 (bvsub (bvshl (_ bv1 11) S24) (bvshl X2 S25))))\n (and (bvugt S24 S25) (shlok X2 S24) (addok (bvshl X2 S24) (bvshl X2 S25)) (= X12 (bvadd (bvshl X2 S24) (bvshl X2 S25))))\n (and (bvugt S24 S25) (shlok X2 S24) (= X12 (bvsub (bvshl X2 S24) (bvshl X2 S25))))\n (and (shlok X2 S24) (shlok X3 S25) (addok (bvshl X2 S24) (bvshl X3 S25)) (= X12 (bvadd (bvshl X2 S24) (bvshl X3 S25))))\n (and (shlok X2 S24) (shlok X3 S25) (bvugt (bvshl X2 S24) (bvshl X3 S25)) (= X12 (bvsub (bvshl X2 S24) (bvshl X3 S25))))\n (and (shlok X3 S24) (shlok X2 S25) (bvugt (bvshl X3 S24) (bvshl X2 S25)) (= X12 (bvsub (bvshl X3 S24) (bvshl X2 S25))))\n (and (shlok X2 S24) (shlok X4 S25) (addok (bvshl X2 S24) (bvshl X4 S25)) (= X12 (bvadd (bvshl X2 S24) (bvshl X4 S25))))\n (and (shlok X2 S24) (shlok X4 S25) (bvugt (bvshl X2 S24) (bvshl X4 S25)) (= X12 (bvsub (bvshl X2 S24) (bvshl X4 S25))))\n (and (shlok X4 S24) (shlok X2 S25) (bvugt (bvshl X4 S24) (bvshl X2 S25)) (= X12 (bvsub (bvshl X4 S24) (bvshl X2 S25))))\n (and (shlok X2 S24) (shlok X5 S25) (addok (bvshl X2 S24) (bvshl X5 S25)) (= X12 (bvadd (bvshl X2 S24) (bvshl X5 S25))))\n (and (shlok X2 S24) (shlok X5 S25) (bvugt (bvshl X2 S24) (bvshl X5 S25)) (= X12 (bvsub (bvshl X2 S24) (bvshl X5 S25))))\n (and (shlok X5 S24) (shlok X2 S25) (bvugt (bvshl X5 S24) (bvshl X2 S25)) (= X12 (bvsub (bvshl X5 S24) (bvshl X2 S25))))\n (and (shlok X2 S24) (shlok X6 S25) (addok (bvshl X2 S24) (bvshl X6 S25)) (= X12 (bvadd (bvshl X2 S24) (bvshl X6 S25))))\n (and (shlok X2 S24) (shlok X6 S25) (bvugt (bvshl X2 S24) (bvshl X6 S25)) (= X12 (bvsub (bvshl X2 S24) (bvshl X6 S25))))\n (and (shlok X6 S24) (shlok X2 S25) (bvugt (bvshl X6 S24) (bvshl X2 S25)) (= X12 (bvsub (bvshl X6 S24) (bvshl X2 S25))))\n (and (shlok X2 S24) (shlok X7 S25) (addok (bvshl X2 S24) (bvshl X7 S25)) (= X12 (bvadd (bvshl X2 S24) (bvshl X7 S25))))\n (and (shlok X2 S24) (shlok X7 S25) (bvugt (bvshl X2 S24) (bvshl X7 S25)) (= X12 (bvsub (bvshl X2 S24) (bvshl X7 S25))))\n (and (shlok X7 S24) (shlok X2 S25) (bvugt (bvshl X7 S24) (bvshl X2 S25)) (= X12 (bvsub (bvshl X7 S24) (bvshl X2 S25))))\n (and (shlok X2 S24) (shlok X8 S25) (addok (bvshl X2 S24) (bvshl X8 S25)) (= X12 (bvadd (bvshl X2 S24) (bvshl X8 S25))))\n (and (shlok X2 S24) (shlok X8 S25) (bvugt (bvshl X2 S24) (bvshl X8 S25)) (= X12 (bvsub (bvshl X2 S24) (bvshl X8 S25))))\n (and (shlok X8 S24) (shlok X2 S25) (bvugt (bvshl X8 S24) (bvshl X2 S25)) (= X12 (bvsub (bvshl X8 S24) (bvshl X2 S25))))\n (and (shlok X2 S24) (shlok X9 S25) (addok (bvshl X2 S24) (bvshl X9 S25)) (= X12 (bvadd (bvshl X2 S24) (bvshl X9 S25))))\n (and (shlok X2 S24) (shlok X9 S25) (bvugt (bvshl X2 S24) (bvshl X9 S25)) (= X12 (bvsub (bvshl X2 S24) (bvshl X9 S25))))\n (and (shlok X9 S24) (shlok X2 S25) (bvugt (bvshl X9 S24) (bvshl X2 S25)) (= X12 (bvsub (bvshl X9 S24) (bvshl X2 S25))))\n (and (shlok X2 S24) (shlok X10 S25) (addok (bvshl X2 S24) (bvshl X10 S25)) (= X12 (bvadd (bvshl X2 S24) (bvshl X10 S25))))\n (and (shlok X2 S24) (shlok X10 S25) (bvugt (bvshl X2 S24) (bvshl X10 S25)) (= X12 (bvsub (bvshl X2 S24) (bvshl X10 S25))))\n (and (shlok X10 S24) (shlok X2 S25) (bvugt (bvshl X10 S24) (bvshl X2 S25)) (= X12 (bvsub (bvshl X10 S24) (bvshl X2 S25))))\n (and (shlok X2 S24) (shlok X11 S25) (addok (bvshl X2 S24) (bvshl X11 S25)) (= X12 (bvadd (bvshl X2 S24) (bvshl X11 S25))))\n (and (shlok X2 S24) (shlok X11 S25) (bvugt (bvshl X2 S24) (bvshl X11 S25)) (= X12 (bvsub (bvshl X2 S24) (bvshl X11 S25))))\n (and (shlok X11 S24) (shlok X2 S25) (bvugt (bvshl X11 S24) (bvshl X2 S25)) (= X12 (bvsub (bvshl X11 S24) (bvshl X2 S25))))\n (and (shlok X3 S24) (addok (bvshl X3 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvadd (bvshl X3 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X3 S24) (bvugt (bvshl X3 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvsub (bvshl X3 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X3 S25) (bvugt (bvshl (_ bv1 11) S24) (bvshl X3 S25)) (= X12 (bvsub (bvshl (_ bv1 11) S24) (bvshl X3 S25))))\n (and (bvugt S24 S25) (shlok X3 S24) (addok (bvshl X3 S24) (bvshl X3 S25)) (= X12 (bvadd (bvshl X3 S24) (bvshl X3 S25))))\n (and (bvugt S24 S25) (shlok X3 S24) (= X12 (bvsub (bvshl X3 S24) (bvshl X3 S25))))\n (and (shlok X3 S24) (shlok X4 S25) (addok (bvshl X3 S24) (bvshl X4 S25)) (= X12 (bvadd (bvshl X3 S24) (bvshl X4 S25))))\n (and (shlok X3 S24) (shlok X4 S25) (bvugt (bvshl X3 S24) (bvshl X4 S25)) (= X12 (bvsub (bvshl X3 S24) (bvshl X4 S25))))\n (and (shlok X4 S24) (shlok X3 S25) (bvugt (bvshl X4 S24) (bvshl X3 S25)) (= X12 (bvsub (bvshl X4 S24) (bvshl X3 S25))))\n (and (shlok X3 S24) (shlok X5 S25) (addok (bvshl X3 S24) (bvshl X5 S25)) (= X12 (bvadd (bvshl X3 S24) (bvshl X5 S25))))\n (and (shlok X3 S24) (shlok X5 S25) (bvugt (bvshl X3 S24) (bvshl X5 S25)) (= X12 (bvsub (bvshl X3 S24) (bvshl X5 S25))))\n (and (shlok X5 S24) (shlok X3 S25) (bvugt (bvshl X5 S24) (bvshl X3 S25)) (= X12 (bvsub (bvshl X5 S24) (bvshl X3 S25))))\n (and (shlok X3 S24) (shlok X6 S25) (addok (bvshl X3 S24) (bvshl X6 S25)) (= X12 (bvadd (bvshl X3 S24) (bvshl X6 S25))))\n (and (shlok X3 S24) (shlok X6 S25) (bvugt (bvshl X3 S24) (bvshl X6 S25)) (= X12 (bvsub (bvshl X3 S24) (bvshl X6 S25))))\n (and (shlok X6 S24) (shlok X3 S25) (bvugt (bvshl X6 S24) (bvshl X3 S25)) (= X12 (bvsub (bvshl X6 S24) (bvshl X3 S25))))\n (and (shlok X3 S24) (shlok X7 S25) (addok (bvshl X3 S24) (bvshl X7 S25)) (= X12 (bvadd (bvshl X3 S24) (bvshl X7 S25))))\n (and (shlok X3 S24) (shlok X7 S25) (bvugt (bvshl X3 S24) (bvshl X7 S25)) (= X12 (bvsub (bvshl X3 S24) (bvshl X7 S25))))\n (and (shlok X7 S24) (shlok X3 S25) (bvugt (bvshl X7 S24) (bvshl X3 S25)) (= X12 (bvsub (bvshl X7 S24) (bvshl X3 S25))))\n (and (shlok X3 S24) (shlok X8 S25) (addok (bvshl X3 S24) (bvshl X8 S25)) (= X12 (bvadd (bvshl X3 S24) (bvshl X8 S25))))\n (and (shlok X3 S24) (shlok X8 S25) (bvugt (bvshl X3 S24) (bvshl X8 S25)) (= X12 (bvsub (bvshl X3 S24) (bvshl X8 S25))))\n (and (shlok X8 S24) (shlok X3 S25) (bvugt (bvshl X8 S24) (bvshl X3 S25)) (= X12 (bvsub (bvshl X8 S24) (bvshl X3 S25))))\n (and (shlok X3 S24) (shlok X9 S25) (addok (bvshl X3 S24) (bvshl X9 S25)) (= X12 (bvadd (bvshl X3 S24) (bvshl X9 S25))))\n (and (shlok X3 S24) (shlok X9 S25) (bvugt (bvshl X3 S24) (bvshl X9 S25)) (= X12 (bvsub (bvshl X3 S24) (bvshl X9 S25))))\n (and (shlok X9 S24) (shlok X3 S25) (bvugt (bvshl X9 S24) (bvshl X3 S25)) (= X12 (bvsub (bvshl X9 S24) (bvshl X3 S25))))\n (and (shlok X3 S24) (shlok X10 S25) (addok (bvshl X3 S24) (bvshl X10 S25)) (= X12 (bvadd (bvshl X3 S24) (bvshl X10 S25))))\n (and (shlok X3 S24) (shlok X10 S25) (bvugt (bvshl X3 S24) (bvshl X10 S25)) (= X12 (bvsub (bvshl X3 S24) (bvshl X10 S25))))\n (and (shlok X10 S24) (shlok X3 S25) (bvugt (bvshl X10 S24) (bvshl X3 S25)) (= X12 (bvsub (bvshl X10 S24) (bvshl X3 S25))))\n (and (shlok X3 S24) (shlok X11 S25) (addok (bvshl X3 S24) (bvshl X11 S25)) (= X12 (bvadd (bvshl X3 S24) (bvshl X11 S25))))\n (and (shlok X3 S24) (shlok X11 S25) (bvugt (bvshl X3 S24) (bvshl X11 S25)) (= X12 (bvsub (bvshl X3 S24) (bvshl X11 S25))))\n (and (shlok X11 S24) (shlok X3 S25) (bvugt (bvshl X11 S24) (bvshl X3 S25)) (= X12 (bvsub (bvshl X11 S24) (bvshl X3 S25))))\n (and (shlok X4 S24) (addok (bvshl X4 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvadd (bvshl X4 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X4 S24) (bvugt (bvshl X4 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvsub (bvshl X4 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X4 S25) (bvugt (bvshl (_ bv1 11) S24) (bvshl X4 S25)) (= X12 (bvsub (bvshl (_ bv1 11) S24) (bvshl X4 S25))))\n (and (bvugt S24 S25) (shlok X4 S24) (addok (bvshl X4 S24) (bvshl X4 S25)) (= X12 (bvadd (bvshl X4 S24) (bvshl X4 S25))))\n (and (bvugt S24 S25) (shlok X4 S24) (= X12 (bvsub (bvshl X4 S24) (bvshl X4 S25))))\n (and (shlok X4 S24) (shlok X5 S25) (addok (bvshl X4 S24) (bvshl X5 S25)) (= X12 (bvadd (bvshl X4 S24) (bvshl X5 S25))))\n (and (shlok X4 S24) (shlok X5 S25) (bvugt (bvshl X4 S24) (bvshl X5 S25)) (= X12 (bvsub (bvshl X4 S24) (bvshl X5 S25))))\n (and (shlok X5 S24) (shlok X4 S25) (bvugt (bvshl X5 S24) (bvshl X4 S25)) (= X12 (bvsub (bvshl X5 S24) (bvshl X4 S25))))\n (and (shlok X4 S24) (shlok X6 S25) (addok (bvshl X4 S24) (bvshl X6 S25)) (= X12 (bvadd (bvshl X4 S24) (bvshl X6 S25))))\n (and (shlok X4 S24) (shlok X6 S25) (bvugt (bvshl X4 S24) (bvshl X6 S25)) (= X12 (bvsub (bvshl X4 S24) (bvshl X6 S25))))\n (and (shlok X6 S24) (shlok X4 S25) (bvugt (bvshl X6 S24) (bvshl X4 S25)) (= X12 (bvsub (bvshl X6 S24) (bvshl X4 S25))))\n (and (shlok X4 S24) (shlok X7 S25) (addok (bvshl X4 S24) (bvshl X7 S25)) (= X12 (bvadd (bvshl X4 S24) (bvshl X7 S25))))\n (and (shlok X4 S24) (shlok X7 S25) (bvugt (bvshl X4 S24) (bvshl X7 S25)) (= X12 (bvsub (bvshl X4 S24) (bvshl X7 S25))))\n (and (shlok X7 S24) (shlok X4 S25) (bvugt (bvshl X7 S24) (bvshl X4 S25)) (= X12 (bvsub (bvshl X7 S24) (bvshl X4 S25))))\n (and (shlok X4 S24) (shlok X8 S25) (addok (bvshl X4 S24) (bvshl X8 S25)) (= X12 (bvadd (bvshl X4 S24) (bvshl X8 S25))))\n (and (shlok X4 S24) (shlok X8 S25) (bvugt (bvshl X4 S24) (bvshl X8 S25)) (= X12 (bvsub (bvshl X4 S24) (bvshl X8 S25))))\n (and (shlok X8 S24) (shlok X4 S25) (bvugt (bvshl X8 S24) (bvshl X4 S25)) (= X12 (bvsub (bvshl X8 S24) (bvshl X4 S25))))\n (and (shlok X4 S24) (shlok X9 S25) (addok (bvshl X4 S24) (bvshl X9 S25)) (= X12 (bvadd (bvshl X4 S24) (bvshl X9 S25))))\n (and (shlok X4 S24) (shlok X9 S25) (bvugt (bvshl X4 S24) (bvshl X9 S25)) (= X12 (bvsub (bvshl X4 S24) (bvshl X9 S25))))\n (and (shlok X9 S24) (shlok X4 S25) (bvugt (bvshl X9 S24) (bvshl X4 S25)) (= X12 (bvsub (bvshl X9 S24) (bvshl X4 S25))))\n (and (shlok X4 S24) (shlok X10 S25) (addok (bvshl X4 S24) (bvshl X10 S25)) (= X12 (bvadd (bvshl X4 S24) (bvshl X10 S25))))\n (and (shlok X4 S24) (shlok X10 S25) (bvugt (bvshl X4 S24) (bvshl X10 S25)) (= X12 (bvsub (bvshl X4 S24) (bvshl X10 S25))))\n (and (shlok X10 S24) (shlok X4 S25) (bvugt (bvshl X10 S24) (bvshl X4 S25)) (= X12 (bvsub (bvshl X10 S24) (bvshl X4 S25))))\n (and (shlok X4 S24) (shlok X11 S25) (addok (bvshl X4 S24) (bvshl X11 S25)) (= X12 (bvadd (bvshl X4 S24) (bvshl X11 S25))))\n (and (shlok X4 S24) (shlok X11 S25) (bvugt (bvshl X4 S24) (bvshl X11 S25)) (= X12 (bvsub (bvshl X4 S24) (bvshl X11 S25))))\n (and (shlok X11 S24) (shlok X4 S25) (bvugt (bvshl X11 S24) (bvshl X4 S25)) (= X12 (bvsub (bvshl X11 S24) (bvshl X4 S25))))\n (and (shlok X5 S24) (addok (bvshl X5 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvadd (bvshl X5 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X5 S24) (bvugt (bvshl X5 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvsub (bvshl X5 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X5 S25) (bvugt (bvshl (_ bv1 11) S24) (bvshl X5 S25)) (= X12 (bvsub (bvshl (_ bv1 11) S24) (bvshl X5 S25))))\n (and (bvugt S24 S25) (shlok X5 S24) (addok (bvshl X5 S24) (bvshl X5 S25)) (= X12 (bvadd (bvshl X5 S24) (bvshl X5 S25))))\n (and (bvugt S24 S25) (shlok X5 S24) (= X12 (bvsub (bvshl X5 S24) (bvshl X5 S25))))\n (and (shlok X5 S24) (shlok X6 S25) (addok (bvshl X5 S24) (bvshl X6 S25)) (= X12 (bvadd (bvshl X5 S24) (bvshl X6 S25))))\n (and (shlok X5 S24) (shlok X6 S25) (bvugt (bvshl X5 S24) (bvshl X6 S25)) (= X12 (bvsub (bvshl X5 S24) (bvshl X6 S25))))\n (and (shlok X6 S24) (shlok X5 S25) (bvugt (bvshl X6 S24) (bvshl X5 S25)) (= X12 (bvsub (bvshl X6 S24) (bvshl X5 S25))))\n (and (shlok X5 S24) (shlok X7 S25) (addok (bvshl X5 S24) (bvshl X7 S25)) (= X12 (bvadd (bvshl X5 S24) (bvshl X7 S25))))\n (and (shlok X5 S24) (shlok X7 S25) (bvugt (bvshl X5 S24) (bvshl X7 S25)) (= X12 (bvsub (bvshl X5 S24) (bvshl X7 S25))))\n (and (shlok X7 S24) (shlok X5 S25) (bvugt (bvshl X7 S24) (bvshl X5 S25)) (= X12 (bvsub (bvshl X7 S24) (bvshl X5 S25))))\n (and (shlok X5 S24) (shlok X8 S25) (addok (bvshl X5 S24) (bvshl X8 S25)) (= X12 (bvadd (bvshl X5 S24) (bvshl X8 S25))))\n (and (shlok X5 S24) (shlok X8 S25) (bvugt (bvshl X5 S24) (bvshl X8 S25)) (= X12 (bvsub (bvshl X5 S24) (bvshl X8 S25))))\n (and (shlok X8 S24) (shlok X5 S25) (bvugt (bvshl X8 S24) (bvshl X5 S25)) (= X12 (bvsub (bvshl X8 S24) (bvshl X5 S25))))\n (and (shlok X5 S24) (shlok X9 S25) (addok (bvshl X5 S24) (bvshl X9 S25)) (= X12 (bvadd (bvshl X5 S24) (bvshl X9 S25))))\n (and (shlok X5 S24) (shlok X9 S25) (bvugt (bvshl X5 S24) (bvshl X9 S25)) (= X12 (bvsub (bvshl X5 S24) (bvshl X9 S25))))\n (and (shlok X9 S24) (shlok X5 S25) (bvugt (bvshl X9 S24) (bvshl X5 S25)) (= X12 (bvsub (bvshl X9 S24) (bvshl X5 S25))))\n (and (shlok X5 S24) (shlok X10 S25) (addok (bvshl X5 S24) (bvshl X10 S25)) (= X12 (bvadd (bvshl X5 S24) (bvshl X10 S25))))\n (and (shlok X5 S24) (shlok X10 S25) (bvugt (bvshl X5 S24) (bvshl X10 S25)) (= X12 (bvsub (bvshl X5 S24) (bvshl X10 S25))))\n (and (shlok X10 S24) (shlok X5 S25) (bvugt (bvshl X10 S24) (bvshl X5 S25)) (= X12 (bvsub (bvshl X10 S24) (bvshl X5 S25))))\n (and (shlok X5 S24) (shlok X11 S25) (addok (bvshl X5 S24) (bvshl X11 S25)) (= X12 (bvadd (bvshl X5 S24) (bvshl X11 S25))))\n (and (shlok X5 S24) (shlok X11 S25) (bvugt (bvshl X5 S24) (bvshl X11 S25)) (= X12 (bvsub (bvshl X5 S24) (bvshl X11 S25))))\n (and (shlok X11 S24) (shlok X5 S25) (bvugt (bvshl X11 S24) (bvshl X5 S25)) (= X12 (bvsub (bvshl X11 S24) (bvshl X5 S25))))\n (and (shlok X6 S24) (addok (bvshl X6 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvadd (bvshl X6 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X6 S24) (bvugt (bvshl X6 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvsub (bvshl X6 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X6 S25) (bvugt (bvshl (_ bv1 11) S24) (bvshl X6 S25)) (= X12 (bvsub (bvshl (_ bv1 11) S24) (bvshl X6 S25))))\n (and (bvugt S24 S25) (shlok X6 S24) (addok (bvshl X6 S24) (bvshl X6 S25)) (= X12 (bvadd (bvshl X6 S24) (bvshl X6 S25))))\n (and (bvugt S24 S25) (shlok X6 S24) (= X12 (bvsub (bvshl X6 S24) (bvshl X6 S25))))\n (and (shlok X6 S24) (shlok X7 S25) (addok (bvshl X6 S24) (bvshl X7 S25)) (= X12 (bvadd (bvshl X6 S24) (bvshl X7 S25))))\n (and (shlok X6 S24) (shlok X7 S25) (bvugt (bvshl X6 S24) (bvshl X7 S25)) (= X12 (bvsub (bvshl X6 S24) (bvshl X7 S25))))\n (and (shlok X7 S24) (shlok X6 S25) (bvugt (bvshl X7 S24) (bvshl X6 S25)) (= X12 (bvsub (bvshl X7 S24) (bvshl X6 S25))))\n (and (shlok X6 S24) (shlok X8 S25) (addok (bvshl X6 S24) (bvshl X8 S25)) (= X12 (bvadd (bvshl X6 S24) (bvshl X8 S25))))\n (and (shlok X6 S24) (shlok X8 S25) (bvugt (bvshl X6 S24) (bvshl X8 S25)) (= X12 (bvsub (bvshl X6 S24) (bvshl X8 S25))))\n (and (shlok X8 S24) (shlok X6 S25) (bvugt (bvshl X8 S24) (bvshl X6 S25)) (= X12 (bvsub (bvshl X8 S24) (bvshl X6 S25))))\n (and (shlok X6 S24) (shlok X9 S25) (addok (bvshl X6 S24) (bvshl X9 S25)) (= X12 (bvadd (bvshl X6 S24) (bvshl X9 S25))))\n (and (shlok X6 S24) (shlok X9 S25) (bvugt (bvshl X6 S24) (bvshl X9 S25)) (= X12 (bvsub (bvshl X6 S24) (bvshl X9 S25))))\n (and (shlok X9 S24) (shlok X6 S25) (bvugt (bvshl X9 S24) (bvshl X6 S25)) (= X12 (bvsub (bvshl X9 S24) (bvshl X6 S25))))\n (and (shlok X6 S24) (shlok X10 S25) (addok (bvshl X6 S24) (bvshl X10 S25)) (= X12 (bvadd (bvshl X6 S24) (bvshl X10 S25))))\n (and (shlok X6 S24) (shlok X10 S25) (bvugt (bvshl X6 S24) (bvshl X10 S25)) (= X12 (bvsub (bvshl X6 S24) (bvshl X10 S25))))\n (and (shlok X10 S24) (shlok X6 S25) (bvugt (bvshl X10 S24) (bvshl X6 S25)) (= X12 (bvsub (bvshl X10 S24) (bvshl X6 S25))))\n (and (shlok X6 S24) (shlok X11 S25) (addok (bvshl X6 S24) (bvshl X11 S25)) (= X12 (bvadd (bvshl X6 S24) (bvshl X11 S25))))\n (and (shlok X6 S24) (shlok X11 S25) (bvugt (bvshl X6 S24) (bvshl X11 S25)) (= X12 (bvsub (bvshl X6 S24) (bvshl X11 S25))))\n (and (shlok X11 S24) (shlok X6 S25) (bvugt (bvshl X11 S24) (bvshl X6 S25)) (= X12 (bvsub (bvshl X11 S24) (bvshl X6 S25))))\n (and (shlok X7 S24) (addok (bvshl X7 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvadd (bvshl X7 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X7 S24) (bvugt (bvshl X7 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvsub (bvshl X7 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X7 S25) (bvugt (bvshl (_ bv1 11) S24) (bvshl X7 S25)) (= X12 (bvsub (bvshl (_ bv1 11) S24) (bvshl X7 S25))))\n (and (bvugt S24 S25) (shlok X7 S24) (addok (bvshl X7 S24) (bvshl X7 S25)) (= X12 (bvadd (bvshl X7 S24) (bvshl X7 S25))))\n (and (bvugt S24 S25) (shlok X7 S24) (= X12 (bvsub (bvshl X7 S24) (bvshl X7 S25))))\n (and (shlok X7 S24) (shlok X8 S25) (addok (bvshl X7 S24) (bvshl X8 S25)) (= X12 (bvadd (bvshl X7 S24) (bvshl X8 S25))))\n (and (shlok X7 S24) (shlok X8 S25) (bvugt (bvshl X7 S24) (bvshl X8 S25)) (= X12 (bvsub (bvshl X7 S24) (bvshl X8 S25))))\n (and (shlok X8 S24) (shlok X7 S25) (bvugt (bvshl X8 S24) (bvshl X7 S25)) (= X12 (bvsub (bvshl X8 S24) (bvshl X7 S25))))\n (and (shlok X7 S24) (shlok X9 S25) (addok (bvshl X7 S24) (bvshl X9 S25)) (= X12 (bvadd (bvshl X7 S24) (bvshl X9 S25))))\n (and (shlok X7 S24) (shlok X9 S25) (bvugt (bvshl X7 S24) (bvshl X9 S25)) (= X12 (bvsub (bvshl X7 S24) (bvshl X9 S25))))\n (and (shlok X9 S24) (shlok X7 S25) (bvugt (bvshl X9 S24) (bvshl X7 S25)) (= X12 (bvsub (bvshl X9 S24) (bvshl X7 S25))))\n (and (shlok X7 S24) (shlok X10 S25) (addok (bvshl X7 S24) (bvshl X10 S25)) (= X12 (bvadd (bvshl X7 S24) (bvshl X10 S25))))\n (and (shlok X7 S24) (shlok X10 S25) (bvugt (bvshl X7 S24) (bvshl X10 S25)) (= X12 (bvsub (bvshl X7 S24) (bvshl X10 S25))))\n (and (shlok X10 S24) (shlok X7 S25) (bvugt (bvshl X10 S24) (bvshl X7 S25)) (= X12 (bvsub (bvshl X10 S24) (bvshl X7 S25))))\n (and (shlok X7 S24) (shlok X11 S25) (addok (bvshl X7 S24) (bvshl X11 S25)) (= X12 (bvadd (bvshl X7 S24) (bvshl X11 S25))))\n (and (shlok X7 S24) (shlok X11 S25) (bvugt (bvshl X7 S24) (bvshl X11 S25)) (= X12 (bvsub (bvshl X7 S24) (bvshl X11 S25))))\n (and (shlok X11 S24) (shlok X7 S25) (bvugt (bvshl X11 S24) (bvshl X7 S25)) (= X12 (bvsub (bvshl X11 S24) (bvshl X7 S25))))\n (and (shlok X8 S24) (addok (bvshl X8 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvadd (bvshl X8 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X8 S24) (bvugt (bvshl X8 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvsub (bvshl X8 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X8 S25) (bvugt (bvshl (_ bv1 11) S24) (bvshl X8 S25)) (= X12 (bvsub (bvshl (_ bv1 11) S24) (bvshl X8 S25))))\n (and (bvugt S24 S25) (shlok X8 S24) (addok (bvshl X8 S24) (bvshl X8 S25)) (= X12 (bvadd (bvshl X8 S24) (bvshl X8 S25))))\n (and (bvugt S24 S25) (shlok X8 S24) (= X12 (bvsub (bvshl X8 S24) (bvshl X8 S25))))\n (and (shlok X8 S24) (shlok X9 S25) (addok (bvshl X8 S24) (bvshl X9 S25)) (= X12 (bvadd (bvshl X8 S24) (bvshl X9 S25))))\n (and (shlok X8 S24) (shlok X9 S25) (bvugt (bvshl X8 S24) (bvshl X9 S25)) (= X12 (bvsub (bvshl X8 S24) (bvshl X9 S25))))\n (and (shlok X9 S24) (shlok X8 S25) (bvugt (bvshl X9 S24) (bvshl X8 S25)) (= X12 (bvsub (bvshl X9 S24) (bvshl X8 S25))))\n (and (shlok X8 S24) (shlok X10 S25) (addok (bvshl X8 S24) (bvshl X10 S25)) (= X12 (bvadd (bvshl X8 S24) (bvshl X10 S25))))\n (and (shlok X8 S24) (shlok X10 S25) (bvugt (bvshl X8 S24) (bvshl X10 S25)) (= X12 (bvsub (bvshl X8 S24) (bvshl X10 S25))))\n (and (shlok X10 S24) (shlok X8 S25) (bvugt (bvshl X10 S24) (bvshl X8 S25)) (= X12 (bvsub (bvshl X10 S24) (bvshl X8 S25))))\n (and (shlok X8 S24) (shlok X11 S25) (addok (bvshl X8 S24) (bvshl X11 S25)) (= X12 (bvadd (bvshl X8 S24) (bvshl X11 S25))))\n (and (shlok X8 S24) (shlok X11 S25) (bvugt (bvshl X8 S24) (bvshl X11 S25)) (= X12 (bvsub (bvshl X8 S24) (bvshl X11 S25))))\n (and (shlok X11 S24) (shlok X8 S25) (bvugt (bvshl X11 S24) (bvshl X8 S25)) (= X12 (bvsub (bvshl X11 S24) (bvshl X8 S25))))\n (and (shlok X9 S24) (addok (bvshl X9 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvadd (bvshl X9 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X9 S24) (bvugt (bvshl X9 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvsub (bvshl X9 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X9 S25) (bvugt (bvshl (_ bv1 11) S24) (bvshl X9 S25)) (= X12 (bvsub (bvshl (_ bv1 11) S24) (bvshl X9 S25))))\n (and (bvugt S24 S25) (shlok X9 S24) (addok (bvshl X9 S24) (bvshl X9 S25)) (= X12 (bvadd (bvshl X9 S24) (bvshl X9 S25))))\n (and (bvugt S24 S25) (shlok X9 S24) (= X12 (bvsub (bvshl X9 S24) (bvshl X9 S25))))\n (and (shlok X9 S24) (shlok X10 S25) (addok (bvshl X9 S24) (bvshl X10 S25)) (= X12 (bvadd (bvshl X9 S24) (bvshl X10 S25))))\n (and (shlok X9 S24) (shlok X10 S25) (bvugt (bvshl X9 S24) (bvshl X10 S25)) (= X12 (bvsub (bvshl X9 S24) (bvshl X10 S25))))\n (and (shlok X10 S24) (shlok X9 S25) (bvugt (bvshl X10 S24) (bvshl X9 S25)) (= X12 (bvsub (bvshl X10 S24) (bvshl X9 S25))))\n (and (shlok X9 S24) (shlok X11 S25) (addok (bvshl X9 S24) (bvshl X11 S25)) (= X12 (bvadd (bvshl X9 S24) (bvshl X11 S25))))\n (and (shlok X9 S24) (shlok X11 S25) (bvugt (bvshl X9 S24) (bvshl X11 S25)) (= X12 (bvsub (bvshl X9 S24) (bvshl X11 S25))))\n (and (shlok X11 S24) (shlok X9 S25) (bvugt (bvshl X11 S24) (bvshl X9 S25)) (= X12 (bvsub (bvshl X11 S24) (bvshl X9 S25))))\n (and (shlok X10 S24) (addok (bvshl X10 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvadd (bvshl X10 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X10 S24) (bvugt (bvshl X10 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvsub (bvshl X10 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X10 S25) (bvugt (bvshl (_ bv1 11) S24) (bvshl X10 S25)) (= X12 (bvsub (bvshl (_ bv1 11) S24) (bvshl X10 S25))))\n (and (bvugt S24 S25) (shlok X10 S24) (addok (bvshl X10 S24) (bvshl X10 S25)) (= X12 (bvadd (bvshl X10 S24) (bvshl X10 S25))))\n (and (bvugt S24 S25) (shlok X10 S24) (= X12 (bvsub (bvshl X10 S24) (bvshl X10 S25))))\n (and (shlok X10 S24) (shlok X11 S25) (addok (bvshl X10 S24) (bvshl X11 S25)) (= X12 (bvadd (bvshl X10 S24) (bvshl X11 S25))))\n (and (shlok X10 S24) (shlok X11 S25) (bvugt (bvshl X10 S24) (bvshl X11 S25)) (= X12 (bvsub (bvshl X10 S24) (bvshl X11 S25))))\n (and (shlok X11 S24) (shlok X10 S25) (bvugt (bvshl X11 S24) (bvshl X10 S25)) (= X12 (bvsub (bvshl X11 S24) (bvshl X10 S25))))\n (and (shlok X11 S24) (addok (bvshl X11 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvadd (bvshl X11 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X11 S24) (bvugt (bvshl X11 S24) (bvshl (_ bv1 11) S25)) (= X12 (bvsub (bvshl X11 S24) (bvshl (_ bv1 11) S25))))\n (and (shlok X11 S25) (bvugt (bvshl (_ bv1 11) S24) (bvshl X11 S25)) (= X12 (bvsub (bvshl (_ bv1 11) S24) (bvshl X11 S25))))\n (and (bvugt S24 S25) (shlok X11 S24) (addok (bvshl X11 S24) (bvshl X11 S25)) (= X12 (bvadd (bvshl X11 S24) (bvshl X11 S25))))\n (and (bvugt S24 S25) (shlok X11 S24) (= X12 (bvsub (bvshl X11 S24) (bvshl X11 S25))))\n))\n(assert (and (bvult S0 (_ bv11 11)) (bvult S1 (_ bv11 11)) (bvult S2 (_ bv11 11)) (bvult S3 (_ bv11 11)) (bvult S4 (_ bv11 11)) (bvult S5 (_ bv11 11)) (bvult S6 (_ bv11 11)) (bvult S7 (_ bv11 11)) (bvult S8 (_ bv11 11)) (bvult S9 (_ bv11 11)) (bvult S10 (_ bv11 11)) (bvult S11 (_ bv11 11)) (bvult S12 (_ bv11 11)) (bvult S13 (_ bv11 11)) (bvult S14 (_ bv11 11)) (bvult S15 (_ bv11 11)) (bvult S16 (_ bv11 11)) (bvult S17 (_ bv11 11)) (bvult S18 (_ bv11 11)) (bvult S19 (_ bv11 11)) (bvult S20 (_ bv11 11)) (bvult S21 (_ bv11 11)) (bvult S22 (_ bv11 11)) (bvult S23 (_ bv11 11)) (bvult S24 (_ bv11 11)) (bvult S25 (_ bv11 11))))\n(assert (or\n (= (_ bv243 11) X1)\n (= (_ bv243 11) X2)\n (= (_ bv243 11) X3)\n (= (_ bv243 11) X4)\n (= (_ bv243 11) X5)\n (= (_ bv243 11) X6)\n (= (_ bv243 11) X7)\n (= (_ bv243 11) X8)\n (= (_ bv243 11) X9)\n (= (_ bv243 11) X10)\n (= (_ bv243 11) X11)\n (= (_ bv243 11) X12)\n))\n(assert (or\n (= (_ bv813 11) X1)\n (= (_ bv813 11) X2)\n (= (_ bv813 11) X3)\n (= (_ bv813 11) X4)\n (= (_ bv813 11) X5)\n (= (_ bv813 11) X6)\n (= (_ bv813 11) X7)\n (= (_ bv813 11) X8)\n (= (_ bv813 11) X9)\n (= (_ bv813 11) X10)\n (= (_ bv813 11) X11)\n (= (_ bv813 11) X12)\n))\n(assert (or\n (= (_ bv193 11) X1)\n (= (_ bv193 11) X2)\n (= (_ bv193 11) X3)\n (= (_ bv193 11) X4)\n (= (_ bv193 11) X5)\n (= (_ bv193 11) X6)\n (= (_ bv193 11) X7)\n (= (_ bv193 11) X8)\n (= (_ bv193 11) X9)\n (= (_ bv193 11) X10)\n (= (_ bv193 11) X11)\n (= (_ bv193 11) X12)\n))\n(assert (or\n (= (_ bv101 11) X1)\n (= (_ bv101 11) X2)\n (= (_ bv101 11) X3)\n (= (_ bv101 11) X4)\n (= (_ bv101 11) X5)\n (= (_ bv101 11) X6)\n (= (_ bv101 11) X7)\n (= (_ bv101 11) X8)\n (= (_ bv101 11) X9)\n (= (_ bv101 11) X10)\n (= (_ bv101 11) X11)\n (= (_ bv101 11) X12)\n))\n(assert (or\n (= (_ bv321 11) X1)\n (= (_ bv321 11) X2)\n (= (_ bv321 11) X3)\n (= (_ bv321 11) X4)\n (= (_ bv321 11) X5)\n (= (_ bv321 11) X6)\n (= (_ bv321 11) X7)\n (= (_ bv321 11) X8)\n (= (_ bv321 11) X9)\n (= (_ bv321 11) X10)\n (= (_ bv321 11) X11)\n (= (_ bv321 11) X12)\n))\n(assert (or\n (= (_ bv501 11) X1)\n (= (_ bv501 11) X2)\n (= (_ bv501 11) X3)\n (= (_ bv501 11) X4)\n (= (_ bv501 11) X5)\n (= (_ bv501 11) X6)\n (= (_ bv501 11) X7)\n (= (_ bv501 11) X8)\n (= (_ bv501 11) X9)\n (= (_ bv501 11) X10)\n (= (_ bv501 11) X11)\n (= (_ bv501 11) X12)\n))\n(assert (or\n (= (_ bv169 11) X1)\n (= (_ bv169 11) X2)\n (= (_ bv169 11) X3)\n (= (_ bv169 11) X4)\n (= (_ bv169 11) X5)\n (= (_ bv169 11) X6)\n (= (_ bv169 11) X7)\n (= (_ bv169 11) X8)\n (= (_ bv169 11) X9)\n (= (_ bv169 11) X10)\n (= (_ bv169 11) X11)\n (= (_ bv169 11) X12)\n))\n(assert (or\n (= (_ bv367 11) X1)\n (= (_ bv367 11) X2)\n (= (_ bv367 11) X3)\n (= (_ bv367 11) X4)\n (= (_ bv367 11) X5)\n (= (_ bv367 11) X6)\n (= (_ bv367 11) X7)\n (= (_ bv367 11) X8)\n (= (_ bv367 11) X9)\n (= (_ bv367 11) X10)\n (= (_ bv367 11) X11)\n (= (_ bv367 11) X12)\n))\n(assert (or\n (= (_ bv55 11) X1)\n (= (_ bv55 11) X2)\n (= (_ bv55 11) X3)\n (= (_ bv55 11) X4)\n (= (_ bv55 11) X5)\n (= (_ bv55 11) X6)\n (= (_ bv55 11) X7)\n (= (_ bv55 11) X8)\n (= (_ bv55 11) X9)\n (= (_ bv55 11) X10)\n (= (_ bv55 11) X11)\n (= (_ bv55 11) X12)\n))\n(assert (or\n (= (_ bv649 11) X1)\n (= (_ bv649 11) X2)\n (= (_ bv649 11) X3)\n (= (_ bv649 11) X4)\n (= (_ bv649 11) X5)\n (= (_ bv649 11) X6)\n (= (_ bv649 11) X7)\n (= (_ bv649 11) X8)\n (= (_ bv649 11) X9)\n (= (_ bv649 11) X10)\n (= (_ bv649 11) X11)\n (= (_ bv649 11) X12)\n))\n(check-sat)\n\n\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/track_all/sat_fail_fast_encoding.smt2",
    "content": "; NOTE: This test depends on input size warnings only triggered with LibFuzzer.\n; REQUIRES: LibFuzzer\n; RUN: rm -f %t-stats_fail-fast.yml\n\n; Fail fast encoding\n; RUN: %jfs -cxx -branch-encoding=fail-fast -stats-file=%t-stats_fail-fast.yml -record-max-num-satisfied-constraints -record-num-inputs -record-num-wrong-sized-inputs %s | %FileCheck -check-prefix=CHECK-SAT %s\n; RUN: %yaml-syntax-check %t-stats_fail-fast.yml\n; RUN: %FileCheck -check-prefix=CHECK-STATS -input-file=%t-stats_fail-fast.yml %s\n\n; CHECK-SAT: {{^sat}}\n\n; CHECK-STATS\n; CHECK-STATS: name: CXXProgramBuilderPassImpl\n; CHECK-STATS-NEXT: num_constraints: 8\n; CHECK-STATS: name: runtime_fuzzing_stats\n; CHECK-STATS-NEXT: jfs_max_num_const_sat: 8\n; CHECK-STATS-NEXT: jfs_num_inputs: {{[0-9]+}}\n; It appears that LibFuzzer tries one wrong sized input. This is an internal\n; implementation detail that we probably shouldn't expose to users.\n; CHECK-STATS-NEXT: jfs_num_wrong_size_inputs: 1\n\n\n(set-logic QF_BV)\n(set-info :source |\nBit-vector benchmarks from Dawson Engler's tool contributed by Vijay Ganesh\n(vganesh@stanford.edu).  Translated into SMT-LIB format by Clark Barrett using\nCVC3.\n\n|)\n(set-info :smt-lib-version 2.0)\n(set-info :category \"industrial\")\n(set-info :status sat)\n(declare-fun buffer_0 () (_ BitVec 8))\n(declare-fun buffer_1 () (_ BitVec 8))\n(declare-fun buffer_2 () (_ BitVec 8))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv43 32))))\n(assert (= ((_ sign_extend 24) buffer_0) (_ bv37 32)))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv37 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv45 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv48 32))))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_1)))\n(assert (bvsle ((_ sign_extend 24) buffer_1) (_ bv57 32)))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_2)))\n(assert (not (bvsle ((_ sign_extend 24) buffer_2) (_ bv57 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv115 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv100 32))))\n(assert (= ((_ sign_extend 24) buffer_2) (_ bv120 32)))\n(assert (not (bvsle (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (_ bv7 32))))\n(assert (not (bvslt (_ bv0 32) (bvadd (bvadd (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (bvneg (_ bv7 32))) (bvneg (_ bv1 32))))))\n(check-sat)\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/track_all/sat_try_all_encodings.smt2",
    "content": "; NOTE: This test depends on input size warnings only triggered with LibFuzzer.\n; REQUIRES: LibFuzzer\n; RUN: rm -rf %t-stats_try-all.yml\n\n; Try all encoding\n; RUN: %jfs -cxx -branch-encoding=try-all -stats-file=%t-stats_try-all.yml -record-max-num-satisfied-constraints -record-num-inputs -record-num-wrong-sized-inputs %s | %FileCheck -check-prefix=CHECK-SAT %s\n; RUN: %yaml-syntax-check %t-stats_try-all.yml\n; RUN: %FileCheck -check-prefix=CHECK-STATS -input-file=%t-stats_try-all.yml %s\n\n; CHECK-SAT: {{^sat}}\n\n; CHECK-STATS\n; CHECK-STATS: name: CXXProgramBuilderPassImpl\n; CHECK-STATS-NEXT: num_constraints: 8\n; CHECK-STATS: name: runtime_fuzzing_stats\n; CHECK-STATS-NEXT: jfs_max_num_const_sat: 8\n; CHECK-STATS-NEXT: jfs_num_inputs: {{[0-9]+}}\n; It appears that LibFuzzer tries one wrong sized input. This is an internal\n; implementation detail that we probably shouldn't expose to users.\n; CHECK-STATS-NEXT: jfs_num_wrong_size_inputs: 1\n\n\n(set-logic QF_BV)\n(set-info :source |\nBit-vector benchmarks from Dawson Engler's tool contributed by Vijay Ganesh\n(vganesh@stanford.edu).  Translated into SMT-LIB format by Clark Barrett using\nCVC3.\n\n|)\n(set-info :smt-lib-version 2.0)\n(set-info :category \"industrial\")\n(set-info :status sat)\n(declare-fun buffer_0 () (_ BitVec 8))\n(declare-fun buffer_1 () (_ BitVec 8))\n(declare-fun buffer_2 () (_ BitVec 8))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv43 32))))\n(assert (= ((_ sign_extend 24) buffer_0) (_ bv37 32)))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv37 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv45 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv48 32))))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_1)))\n(assert (bvsle ((_ sign_extend 24) buffer_1) (_ bv57 32)))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_2)))\n(assert (not (bvsle ((_ sign_extend 24) buffer_2) (_ bv57 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv115 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv100 32))))\n(assert (= ((_ sign_extend 24) buffer_2) (_ bv120 32)))\n(assert (not (bvsle (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (_ bv7 32))))\n(assert (not (bvslt (_ bv0 32) (bvadd (bvadd (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (bvneg (_ bv7 32))) (bvneg (_ bv1 32))))))\n(check-sat)\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/track_all/unsat_fail_fast_encoding.smt2",
    "content": "; NOTE: This test depends on input size warnings only triggered with LibFuzzer.\n; REQUIRES: LibFuzzer\n; RUN: rm -f %t-stats_fail-fast.yml\n\n; Fail fast encoding\n; RUN: %jfs -cxx -branch-encoding=fail-fast --disable-equality-extraction --disable-standard-passes -libfuzzer-runs=200 -seed=1 -stats-file=%t-stats_fail-fast.yml -record-max-num-satisfied-constraints -record-num-inputs -record-num-wrong-sized-inputs %s | %FileCheck -check-prefix=CHECK-SAT %s\n; RUN: %yaml-syntax-check %t-stats_fail-fast.yml\n; RUN: %FileCheck -check-prefix=CHECK-STATS -input-file=%t-stats_fail-fast.yml %s\n\n; CHECK-SAT: {{^unknown}}\n\n; CHECK-STATS\n; CHECK-STATS: name: CXXProgramBuilderPassImpl\n; CHECK-STATS-NEXT: num_constraints: 3\n; CHECK-STATS: name: runtime_fuzzing_stats\n; CHECK-STATS-NEXT: jfs_max_num_const_sat: 2\n; CHECK-STATS-NEXT: jfs_num_inputs: 199\n; It appears that LibFuzzer tries one wrong sized input. This is an internal\n; implementation detail that we probably shouldn't expose to users.\n; CHECK-STATS-NEXT: jfs_num_wrong_size_inputs: 1\n\n\n(set-logic QF_BV)\n(set-info :smt-lib-version 2.5)\n(set-info :status unsat)\n(declare-const a Bool)\n(declare-const b Bool)\n(declare-const c Bool)\n(assert (and a b)) ; Should be satisfied\n(assert (xor b c)) ; Should be satisfied\n(assert c) ; can't be satisfied. The fuzzer should get stuck here\n(check-sat)\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/track_all/unsat_try_all_encoding.smt2",
    "content": "; NOTE: This test depends on input size warnings only triggered with LibFuzzer.\n; REQUIRES: LibFuzzer\n; RUN: rm -rf %t-stats_try-all.yml\n\n; Try all encoding\n; RUN: %jfs -cxx -branch-encoding=try-all --disable-equality-extraction --disable-standard-passes -libfuzzer-runs=100 -seed=1 -stats-file=%t-stats_try-all.yml -record-max-num-satisfied-constraints -record-num-inputs -record-num-wrong-sized-inputs %s | %FileCheck -check-prefix=CHECK-SAT %s\n; RUN: %yaml-syntax-check %t-stats_try-all.yml\n; RUN: %FileCheck -check-prefix=CHECK-STATS -input-file=%t-stats_try-all.yml %s\n\n; CHECK-SAT: {{^unknown}}\n\n; CHECK-STATS\n; CHECK-STATS: name: CXXProgramBuilderPassImpl\n; CHECK-STATS-NEXT: num_constraints: 3\n; CHECK-STATS: name: runtime_fuzzing_stats\n; CHECK-STATS-NEXT: jfs_max_num_const_sat: 2\n; CHECK-STATS-NEXT: jfs_num_inputs: {{[0-9]+}}\n; It appears that LibFuzzer tries one wrong sized input. This is an internal\n; implementation detail that we probably shouldn't expose to users.\n; CHECK-STATS-NEXT: jfs_num_wrong_size_inputs: 1\n\n\n(set-logic QF_BV)\n(set-info :smt-lib-version 2.5)\n(set-info :status unsat)\n(declare-const a Bool)\n(declare-const b Bool)\n(declare-const c Bool)\n(assert (and a b)) ; Should be satisfied\n(assert (xor b c)) ; Should be satisfied\n(assert c) ; can't be satisfied. The fuzzer should get stuck here\n(check-sat)\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/track_num_constraints/sat_fail_fast_encoding.smt2",
    "content": "; RUN: rm -f %t-stats.yml\n; RUN: %jfs -cxx -branch-encoding=fail-fast -stats-file=%t-stats.yml -record-max-num-satisfied-constraints %s | %FileCheck -check-prefix=CHECK-SAT %s\n; RUN: %yaml-syntax-check %t-stats.yml\n; RUN: %FileCheck -check-prefix=CHECK-STATS -input-file=%t-stats.yml %s\n; CHECK-SAT: {{^sat}}\n\n; CHECK-STATS\n; CHECK-STATS: name: CXXProgramBuilderPassImpl\n; CHECK-STATS-NEXT: num_constraints: 8\n; CHECK-STATS: name: runtime_fuzzing_stats\n; CHECK-STATS-NEXT: jfs_max_num_const_sat: 8\n\n\n(set-logic QF_BV)\n(set-info :source |\nBit-vector benchmarks from Dawson Engler's tool contributed by Vijay Ganesh\n(vganesh@stanford.edu).  Translated into SMT-LIB format by Clark Barrett using\nCVC3.\n\n|)\n(set-info :smt-lib-version 2.0)\n(set-info :category \"industrial\")\n(set-info :status sat)\n(declare-fun buffer_0 () (_ BitVec 8))\n(declare-fun buffer_1 () (_ BitVec 8))\n(declare-fun buffer_2 () (_ BitVec 8))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv43 32))))\n(assert (= ((_ sign_extend 24) buffer_0) (_ bv37 32)))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv37 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv45 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv48 32))))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_1)))\n(assert (bvsle ((_ sign_extend 24) buffer_1) (_ bv57 32)))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_2)))\n(assert (not (bvsle ((_ sign_extend 24) buffer_2) (_ bv57 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv115 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv100 32))))\n(assert (= ((_ sign_extend 24) buffer_2) (_ bv120 32)))\n(assert (not (bvsle (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (_ bv7 32))))\n(assert (not (bvslt (_ bv0 32) (bvadd (bvadd (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (bvneg (_ bv7 32))) (bvneg (_ bv1 32))))))\n(check-sat)\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/track_num_constraints/sat_try_all_encoding.smt2",
    "content": "; RUN: rm -f %t-stats.yml\n; FIXME: When we allow different encodings make sure that we specify the fail fast encoding here.\n; RUN: %jfs -cxx -branch-encoding=try-all -stats-file=%t-stats.yml -record-max-num-satisfied-constraints %s | %FileCheck -check-prefix=CHECK-SAT %s\n; RUN: %yaml-syntax-check %t-stats.yml\n; RUN: %FileCheck -check-prefix=CHECK-STATS -input-file=%t-stats.yml %s\n; CHECK-SAT: {{^sat}}\n\n; CHECK-STATS\n; CHECK-STATS: name: CXXProgramBuilderPassImpl\n; CHECK-STATS-NEXT: num_constraints: 8\n; CHECK-STATS: name: runtime_fuzzing_stats\n; CHECK-STATS-NEXT: jfs_max_num_const_sat: 8\n\n\n(set-logic QF_BV)\n(set-info :source |\nBit-vector benchmarks from Dawson Engler's tool contributed by Vijay Ganesh\n(vganesh@stanford.edu).  Translated into SMT-LIB format by Clark Barrett using\nCVC3.\n\n|)\n(set-info :smt-lib-version 2.0)\n(set-info :category \"industrial\")\n(set-info :status sat)\n(declare-fun buffer_0 () (_ BitVec 8))\n(declare-fun buffer_1 () (_ BitVec 8))\n(declare-fun buffer_2 () (_ BitVec 8))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv43 32))))\n(assert (= ((_ sign_extend 24) buffer_0) (_ bv37 32)))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv37 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv45 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv48 32))))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_1)))\n(assert (bvsle ((_ sign_extend 24) buffer_1) (_ bv57 32)))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_2)))\n(assert (not (bvsle ((_ sign_extend 24) buffer_2) (_ bv57 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv115 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv100 32))))\n(assert (= ((_ sign_extend 24) buffer_2) (_ bv120 32)))\n(assert (not (bvsle (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (_ bv7 32))))\n(assert (not (bvslt (_ bv0 32) (bvadd (bvadd (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (bvneg (_ bv7 32))) (bvneg (_ bv1 32))))))\n(check-sat)\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/track_num_constraints/unsat_fail_fast_encoding.smt2",
    "content": "; RUN: rm -f %t-stats.yml\n; RUN: %jfs -cxx --branch-encoding=fail-fast --disable-equality-extraction --disable-standard-passes -libfuzzer-runs=100 -seed=1  -stats-file=%t-stats.yml -record-max-num-satisfied-constraints %s | %FileCheck -check-prefix=CHECK-SAT %s\n; RUN: %yaml-syntax-check %t-stats.yml\n; RUN: %FileCheck -check-prefix=CHECK-STATS -input-file=%t-stats.yml %s\n; CHECK-SAT: {{^unknown}}\n\n; CHECK-STATS\n; CHECK-STATS: name: CXXProgramBuilderPassImpl\n; CHECK-STATS-NEXT: num_constraints: 3\n; CHECK-STATS: name: runtime_fuzzing_stats\n; CHECK-STATS-NEXT: jfs_max_num_const_sat: 2\n; NOTE: These stats below are technically wrong. They show as zero because they\n; aren't tracked in this test.\n; CHECK-STATS-NEXT: jfs_num_inputs: 0\n; CHECK-STATS-NEXT: jfs_num_wrong_size_inputs: 0\n\n\n\n(set-logic QF_BV)\n(set-info :smt-lib-version 2.5)\n(set-info :status unsat)\n(declare-const a Bool)\n(declare-const b Bool)\n(declare-const c Bool)\n(assert (and a b)) ; Should be satisfied\n(assert (xor b c)) ; Should be satisfied\n(assert c) ; can't be satisfied. The fuzzer should get stuck here\n(check-sat)\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/track_num_constraints/unsat_try_all_encoding.smt2",
    "content": "; RUN: rm -f %t-stats.yml\n; RUN: %jfs -cxx --branch-encoding=try-all --disable-equality-extraction --disable-standard-passes -libfuzzer-runs=100 -seed=1  -stats-file=%t-stats.yml -record-max-num-satisfied-constraints %s | %FileCheck -check-prefix=CHECK-SAT %s\n; RUN: %yaml-syntax-check %t-stats.yml\n; RUN: %FileCheck -check-prefix=CHECK-STATS -input-file=%t-stats.yml %s\n; CHECK-SAT: {{^unknown}}\n\n; CHECK-STATS\n; CHECK-STATS: name: CXXProgramBuilderPassImpl\n; CHECK-STATS-NEXT: num_constraints: 3\n; CHECK-STATS: name: runtime_fuzzing_stats\n; CHECK-STATS-NEXT: jfs_max_num_const_sat: 2\n; NOTE: These stats below are technically wrong. They show as zero because they\n; aren't tracked in this test.\n; CHECK-STATS-NEXT: jfs_num_inputs: 0\n; CHECK-STATS-NEXT: jfs_num_wrong_size_inputs: 0\n\n\n(set-logic QF_BV)\n(set-info :smt-lib-version 2.5)\n(set-info :status unsat)\n(declare-const a Bool)\n(declare-const b Bool)\n(declare-const c Bool)\n(assert (and a b)) ; Should be satisfied\n(assert (xor b c)) ; Should be satisfied\n(assert c) ; can't be satisfied. The fuzzer should get stuck here\n(check-sat)\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/unknown/bv_unsupported_size.smt2",
    "content": "; RUN: %jfs -v=1 -cxx %s > %t.stdout 2> %t.stderr\n; RUN: %FileCheck -check-prefix=CHECK-STDOUT -input-file=%t.stdout %s\n; RUN: %FileCheck -check-prefix=CHECK-STDERR -input-file=%t.stderr %s\n\n; This size is not supported natively so we should report unknown\n(declare-fun a () (_ BitVec 128))\n(declare-fun b () (_ BitVec 128))\n(declare-fun c () (_ BitVec 128))\n(assert (= c (bvadd a b)))\n(check-sat)\n\n; CHECK-STDOUT: {{^unknown$}}\n; CHECK-STDERR: BitVector width 128 not supported\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/unknown/float_unsupported_size.smt2",
    "content": "; RUN: %jfs -v=1 -cxx %s > %t.stdout 2> %t.stderr\n; RUN: %FileCheck -check-prefix=CHECK-STDOUT -input-file=%t.stdout %s\n; RUN: %FileCheck -check-prefix=CHECK-STDERR -input-file=%t.stderr %s\n\n; This size is not supported natively so we should report unknown\n(declare-fun a () (_ FloatingPoint 5 11))\n(assert (not (fp.isNaN a)))\n(check-sat)\n\n; CHECK-STDOUT: {{^unknown$}}\n; CHECK-STDERR: FloatingPoint sort \"(_ FloatingPoint 5 11)\" not supported\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/unsat/max-no-solution.smt2",
    "content": "; This benchmark causes problems because Z3's simplifier fails to\n; constant fold the values. This required special handling of this\n; case when invoking LibFuzzer.\n; See https://github.com/Z3Prover/z3/issues/1242\n\n; RUN: %jfs -cxx %s | %FileCheck %s\n\n(set-info :smt-lib-version 2.6)\n(set-logic QF_FP)\n(set-info :status sat)\n(define-sort FPN () (_ FloatingPoint 11 53))\n(declare-fun x () FPN)\n(declare-fun y () FPN)\n(declare-fun r () FPN)\n(assert (= x (fp #b0 #b00011111000 #b1011000011011011001010101100010101111101001010000111)))\n(assert (= y (fp #b1 #b00101101000 #b0100001000101100100110101111011101111111010001001100)))\n(assert (= r (fp #b1 #b00011111000 #b1011000011011011001010101100010101111101001010000111)))\n(assert (= (fp.max x y) r))\n; CHECK: {{^unsat$}}\n(check-sat)\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/Fuzz/unsat/min-no-solution.smt2",
    "content": "; This benchmark causes problems because Z3's simplifier fails to\n; constant fold the values. This required special handling of this\n; case when invoking LibFuzzer.\n; See https://github.com/Z3Prover/z3/issues/1242\n\n; RUN: %jfs -cxx %s | %FileCheck %s\n\n(set-info :smt-lib-version 2.6)\n(set-logic QF_FP)\n(set-info :status sat)\n(define-sort FPN () (_ FloatingPoint 11 53))\n(declare-fun x () FPN)\n(declare-fun y () FPN)\n(declare-fun r () FPN)\n(assert (= x (fp #b0 #b00010101101 #b0011111100110110001111111001000100100101101101110100)))\n(assert (= y (fp #b1 #b01101101001 #b1011011111110000011100100011101010000110001001100111)))\n(assert (= r (fp #b1 #b11101101001 #b1011011111110000011100100011101010000110001001100111)))\n(assert (= (fp.min x y) r))\n\n; CHECK: {{^unsat$}}\n(check-sat)\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/SeedGeneration/3b_all_ones",
    "content": ""
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/SeedGeneration/all_zeros_and_all_ones.smt2",
    "content": "; RUN: rm -rf %t.output-dir\n; RUN: %jfs -cxx -keep-output-dir -output-dir=%t.output-dir -sm-all-ones-seed -sm-all-zeros-seed -sm-max-num-seed=2 -debug-stop-after-seed-gen -disable-equality-extraction %s\n\n; Check the seeds are exactly what we expect\n; FIXME: This sucks. llvm-lit now has a built-in diff but it misbehaves\n; on binary files and doesn't support many standard flags. Hack this\n; for now by running the diff binary explicitly\n; RUN: %diff -q %t.output-dir/corpus/zeros_0 %S/3b_all_zeros\n; RUN: %diff -q %t.output-dir/corpus/ones_0 %S/3b_all_ones\n; FIXME: We should probably come up with a more elegant way of doing this.\n; RUN: ls %t.output-dir/corpus | wc -l | grep '^\\s*2$'\n\n\n(set-logic QF_BV)\n(set-info :source |\nBit-vector benchmarks from Dawson Engler's tool contributed by Vijay Ganesh\n(vganesh@stanford.edu).  Translated into SMT-LIB format by Clark Barrett using\nCVC3.\n\n|)\n(set-info :smt-lib-version 2.0)\n(set-info :category \"industrial\")\n(set-info :status sat)\n(declare-fun buffer_0 () (_ BitVec 8))\n(declare-fun buffer_1 () (_ BitVec 8))\n(declare-fun buffer_2 () (_ BitVec 8))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv43 32))))\n(assert (= ((_ sign_extend 24) buffer_0) (_ bv37 32)))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv37 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv45 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv48 32))))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_1)))\n(assert (bvsle ((_ sign_extend 24) buffer_1) (_ bv57 32)))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_2)))\n(assert (not (bvsle ((_ sign_extend 24) buffer_2) (_ bv57 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv115 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv100 32))))\n(assert (= ((_ sign_extend 24) buffer_2) (_ bv120 32)))\n(assert (not (bvsle (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (_ bv7 32))))\n(assert (not (bvslt (_ bv0 32) (bvadd (bvadd (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (bvneg (_ bv7 32))) (bvneg (_ bv1 32))))))\n(check-sat)\n; CHECK: {{^sat$}}\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/SeedGeneration/bool_bv_float.smt2",
    "content": "; FIXME: This test produces different results on Linux\n; enable on OSX only for now.\n; REQUIRES: darwin\n; RUN: %jfs -v=2 -sm-special-constant-seeds=true -sm-max-num-seed=10 %s 2>&1 | %FileCheck %s\n\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(declare-fun c () Bool)\n(declare-fun d () (_ BitVec 2))\n(declare-fun e () (_ BitVec 19))\n(declare-fun f () Float32)\n(declare-fun g () Float64)\n(assert (or a b))\n(assert (bvult d #b11))\n(assert (bvult e #b1010101010101001011))\n(assert (fp.eq f f))\n(assert (fp.eq g g))\n(assert (or b c))\n(check-sat)\n\n; CHECK: (Sort: Bool, Assignment: false)\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b11)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b0000000000000000000)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (fp #b0 #x01 #b00000000000000000000000))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (_ NaN 11 53))\n; CHECK-NEXT: (Sort: Bool, Assignment: true)\n\n; CHECK: (Sort: Bool, Assignment: false)\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b00)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b0111111111111111111)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (fp #b0 #x7f #b00000000000000000000000))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (_ -oo 11 53))\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n\n; CHECK: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b11)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b0111111111111111111)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (fp #b0 #x00 #b11111111111111111111111))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (fp #b0 #b00000000000 #x0000000000001))\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n\n; CHECK: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b11)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b0111111111111111111)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (_ -zero 8 24))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (fp #b0 #b00000000000 #xfffffffffffff))\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n\n; CHECK: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b01)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b1010101010101001011)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (fp #b1 #x01 #b00000000000000000000000))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (fp #b1 #b00000000000 #x0000000000001))\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n\n; CHECK: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b11)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b0000000000000000000)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (_ +zero 8 24))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (_ +zero 11 53))\n; CHECK-NEXT: (Sort: Bool, Assignment: true)\n\n; CHECK: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b11)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b0111111111111111111)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (_ NaN 8 24))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (_ NaN 11 53))\n; CHECK-NEXT: (Sort: Bool, Assignment: true)\n\n; CHECK: (Sort: Bool, Assignment: false)\n; CHECK-NEXT: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b01)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b0000000000000000001)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (fp #b1 #x00 #b11111111111111111111111))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (fp #b1 #b00000000000 #x0000000000001))\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/SeedGeneration/bool_bv_float_linux.smt2",
    "content": "; FIXME: This test doesn't have stable output between Darwin and Linux.\n; This is likely a difference in behaviour of the random number generator\n; between libstdc++ and libcxx.\n; REQUIRES: linux\n; RUN: %jfs -v=2 \\\n; RUN: -sm-all-ones-seed=0 \\\n; RUN: -sm-all-zeros-seed=0 \\\n; RUN: -sm-special-constant-seeds=true \\\n; RUN: -sm-max-num-seed=8 %s 2>&1 | %FileCheck %s\n\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(declare-fun c () Bool)\n(declare-fun d () (_ BitVec 2))\n(declare-fun e () (_ BitVec 19))\n(declare-fun f () Float32)\n(declare-fun g () Float64)\n(assert (or a b))\n(assert (bvult d #b11))\n(assert (bvult e #b1010101010101001011))\n(assert (fp.eq f f))\n(assert (fp.eq g g))\n(assert (or b c))\n(check-sat)\n\n; CHECK: (Sort: Bool, Assignment: false)\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b11)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b0000000000000000000)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (fp #b0 #x7f #b00000000000000000000000))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (fp #b1 #b11111111110 #xfffffffffffff))\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n\n; CHECK: (Sort: Bool, Assignment: false)\n; CHECK-NEXT: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b01)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b0000000000000000000)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (fp #b0 #x00 #b11111111111111111111111))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (fp #b1 #b00000000000 #xfffffffffffff))\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n\n; CHECK: (Sort: Bool, Assignment: false)\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b01)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b1010101010101001011)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (fp #b0 #x00 #b00000000000000000000001))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (_ NaN 11 53))\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n\n; CHECK: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b01)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b0000000000000000001)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (_ -zero 8 24))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (_ -zero 11 53))\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n\n; CHECK: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b01)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b0000000000000000001)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (fp #b0 #x00 #b00000000000000000000001))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (fp #b0 #b01111111111 #x0000000000000))\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n\n; CHECK: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b01)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b0000000000000000000)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (_ NaN 8 24))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (fp #b1 #b11111111110 #xfffffffffffff))\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n\n; CHECK: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b11)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b1010101010101001011)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (fp #b0 #x01 #b00000000000000000000000))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (fp #b1 #b11111111110 #xfffffffffffff))\n; CHECK-NEXT: (Sort: Bool, Assignment: true)\n\n; CHECK: (Sort: Bool, Assignment: false)\n; CHECK-NEXT: (Sort: Bool, Assignment: true)\n; CHECK-NEXT: (Sort: (_ BitVec 2), Assignment: #b11)\n; CHECK-NEXT: (Sort: (_ BitVec 19), Assignment: #b1111111111111111111)\n; CHECK-NEXT: (Sort: (_ FloatingPoint 8 24), Assignment: (fp #b0 #xfe #b11111111111111111111111))\n; CHECK-NEXT: (Sort: (_ FloatingPoint 11 53), Assignment: (_ +zero 11 53))\n; CHECK-NEXT: (Sort: Bool, Assignment: false)\n\n; CHECK: (SeedManager wrote 8 seeds (15 bytes each))\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/SeedGeneration/max_num_seeds_1.smt2",
    "content": "; RUN: rm -rf %t.output-dir\n; RUN: %jfs -cxx -keep-output-dir -output-dir=%t.output-dir -sm-all-ones-seed -sm-all-zeros-seed -sm-max-num-seed=1 -debug-stop-after-seed-gen -disable-equality-extraction %s\n\n; Check the seeds are exactly what we expect\n; FIXME: We should probably come up with a more elegant way of doing this.\n; RUN: ls %t.output-dir/corpus | wc -l | grep '^\\s*1$'\n\n\n(set-logic QF_BV)\n(set-info :source |\nBit-vector benchmarks from Dawson Engler's tool contributed by Vijay Ganesh\n(vganesh@stanford.edu).  Translated into SMT-LIB format by Clark Barrett using\nCVC3.\n\n|)\n(set-info :smt-lib-version 2.0)\n(set-info :category \"industrial\")\n(set-info :status sat)\n(declare-fun buffer_0 () (_ BitVec 8))\n(declare-fun buffer_1 () (_ BitVec 8))\n(declare-fun buffer_2 () (_ BitVec 8))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_0) (_ bv43 32))))\n(assert (= ((_ sign_extend 24) buffer_0) (_ bv37 32)))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv0 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv37 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv45 32))))\n(assert (not (= ((_ sign_extend 24) buffer_1) (_ bv48 32))))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_1)))\n(assert (bvsle ((_ sign_extend 24) buffer_1) (_ bv57 32)))\n(assert (bvsle (_ bv48 32) ((_ sign_extend 24) buffer_2)))\n(assert (not (bvsle ((_ sign_extend 24) buffer_2) (_ bv57 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv115 32))))\n(assert (not (= ((_ sign_extend 24) buffer_2) (_ bv100 32))))\n(assert (= ((_ sign_extend 24) buffer_2) (_ bv120 32)))\n(assert (not (bvsle (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (_ bv7 32))))\n(assert (not (bvslt (_ bv0 32) (bvadd (bvadd (bvadd (_ bv0 32) (bvadd ((_ sign_extend 24) buffer_1) (bvneg (_ bv48 32)))) (bvneg (_ bv7 32))) (bvneg (_ bv1 32))))))\n(check-sat)\n; CHECK: {{^sat$}}\n(exit)\n"
  },
  {
    "path": "tests/system_tests/CXXFuzzingBackend/SeedGeneration/special_constants_stats.smt2",
    "content": "; RUN: rm -f %t.stats.yml\n; RUN: %jfs -v=2 \\\n; RUN: -stats-file=%t.stats.yml \\\n; RUN: -sm-all-ones-seed=0 \\\n; RUN: -sm-all-zeros-seed=0 \\\n; RUN: -sm-special-constant-seeds=true \\\n; RUN: -sm-max-num-seed=9 %s | %FileCheck -check-prefix=CHECK-SAT %s\n; RUN: %yaml-syntax-check %t.stats.yml\n; RUN: %FileCheck %s -check-prefix=CHECK-STATS -input-file=%t.stats.yml\n\n(declare-fun a () Bool)\n(declare-fun b () Bool)\n(declare-fun c () Bool)\n(declare-fun d () (_ BitVec 2))\n(declare-fun e () (_ BitVec 19))\n(declare-fun f () Float32)\n(declare-fun g () Float64)\n(assert (or a b))\n(assert (bvult d #b11))\n(assert (bvult e #b1010101010101001011))\n(assert (fp.eq f f))\n(assert (fp.eq g g))\n(assert (or b c))\n(check-sat)\n\n; CHECK-SAT: {{^sat}}\n\n; CHECK-STATS: name: special_constant_seed_generator\n; CHECK-STATS: total_built_in_bv_constants: 4\n; CHECK-STATS: num_covered_built_in_bv_constant: {{[1-4]}}\n; CHECK-STATS: total_built_in_fp_constants: 15\n; CHECK-STATS: num_covered_built_in_fp_constant: {{[1-9]+}}\n; CHECK-STATS: total_built_in_bool_constants: 2\n; CHECK-STATS: num_covered_built_in_bv_constant: 2\n; CHECK-STATS: num_constants_by_sort:\n; CHECK-STATS-NEXT:   \"(_ BitVec 19)\": 1\n; CHECK-STATS-NEXT:   \"(_ BitVec 2)\": 1\n\n"
  },
  {
    "path": "tests/system_tests/CommandLine/NonExistentFile.smt2",
    "content": "; RUN: %not %jfs NON_EXISTANT_FILE 2>&1 | %FileCheck %s\n; CHECK: (error \"Could not open NON_EXISTANT_FILE because No such file or directory\")\n"
  },
  {
    "path": "tests/system_tests/CommandLine/version.smt2",
    "content": "; RUN: %jfs -version | %FileCheck %s\n; CHECK: JFS {{[0-9]+}}.{{[0-9]+}}.{{[0-9]+}}.{{[0-9]+}}\n"
  },
  {
    "path": "tests/system_tests/DummyFuzzingSolver/README.md",
    "content": "The DummyFuzzingSolver doesn't try to fuzz so\nin effect this tests how well the pre-processing\nsteps are able to make queries trivially sat/unsat.\n"
  },
  {
    "path": "tests/system_tests/DummyFuzzingSolver/sat/trivial_equalities.smt2",
    "content": "; RUN: %jfs -dummy %s | %FileCheck %s\n(declare-fun a () (_ BitVec 32))\n(declare-fun b () (_ BitVec 32))\n(declare-fun c () (_ BitVec 32))\n(assert (= a b))\n(assert (= b c))\n(check-sat)\n; CHECK: {{^sat}}\n"
  },
  {
    "path": "tests/system_tests/DummyFuzzingSolver/sat/true_elim.smt2",
    "content": "; RUN: %jfs -dummy %s | %FileCheck %s\n(declare-fun x () (_ BitVec 32))\n(assert true)\n(assert true)\n(assert true)\n(assert true)\n(check-sat)\n; CHECK: {{^sat}}\n"
  },
  {
    "path": "tests/system_tests/DummyFuzzingSolver/unknown/trivial_equality_with_non_trivial_constraint.smt2",
    "content": "; RUN: %jfs -dummy %s | %FileCheck %s\n(declare-fun a () (_ BitVec 32))\n(declare-fun b () (_ BitVec 32))\n(declare-fun c () (_ BitVec 32))\n(assert (= a b))\n(assert (= b c))\n(assert (bvugt a (_ bv2 32)))\n(check-sat)\n; CHECK: {{^unknown}}\n"
  },
  {
    "path": "tests/system_tests/DummyFuzzingSolver/unknown/unknown_ineq.smt2",
    "content": "; RUN: %jfs -dummy %s | %FileCheck %s\n(declare-fun a () (_ BitVec 32))\n(declare-fun b () (_ BitVec 32))\n(assert (bvugt a b))\n(check-sat)\n; CHECK: {{^unknown}}\n"
  },
  {
    "path": "tests/system_tests/DummyFuzzingSolver/unsat/bound_contradiction.smt2",
    "content": "; FIXME: BvBoundPropagationPass is broken\n; XFAIL: *\n; RUN: %jfs -dummy %s | %FileCheck %s\n; CHECK-NOT: (declare-fun a () (_ BitVec 8))\n(declare-fun a () (_ BitVec 8))\n\n(assert (bvule #xf0 a))\n(assert (bvule a #x08))\n(check-sat)\n; CHECK: {{^unsat}}\n"
  },
  {
    "path": "tests/system_tests/DummyFuzzingSolver/unsat/bound_contradiction2.smt2",
    "content": "; FIXME: BvBoundPropagationPass is broken\n; XFAIL: *\n; RUN: %jfs -dummy %s | %FileCheck %s\n; CHECK-NOT: (declare-fun a () (_ BitVec 8))\n(declare-fun a () (_ BitVec 8))\n\n(assert (bvugt a #xfe))\n(assert (bvult a #xff))\n(check-sat)\n; CHECK: {{^unsat}}\n"
  },
  {
    "path": "tests/system_tests/DummyFuzzingSolver/unsat/true_elim.smt2",
    "content": "; RUN: %jfs -dummy %s | %FileCheck %s\n(declare-fun x () (_ BitVec 32))\n(assert (not (= x x)))\n(assert true)\n(assert true)\n(assert true)\n(assert true)\n(check-sat)\n; CHECK: {{^unsat}}\n"
  },
  {
    "path": "tests/system_tests/Transforms/AndHoisting/nested_and.smt2",
    "content": "; RUN: %jfs-opt -and-hoist %s | %FileCheck %s\n\n; CHECK: (declare-fun x () Bool)\n; CHECK-NEXT: (declare-fun y () Bool)\n; CHECK-NEXT: (declare-fun z () Bool)\n(declare-fun x () Bool)\n(declare-fun y () Bool)\n(declare-fun z () Bool)\n\n; CHECK: (assert y)\n; CHECK-NEXT: (assert z)\n; CHECK-NEXT: (assert x)\n(assert (and (and y z) x))\n\n; CHECK-NEXT: (assert (= x x))\n(assert (= x x))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Transforms/AndHoisting/non_constant_and.smt2",
    "content": "; RUN: %jfs-opt -and-hoist %s | %FileCheck %s\n\n; CHECK: (declare-fun x () Bool)\n; CHECK-NEXT: (declare-fun y () Bool)\n; CHECK-NEXT: (declare-fun z () Bool)\n(declare-fun x () Bool)\n(declare-fun y () Bool)\n(declare-fun z () Bool)\n\n; CHECK: (assert (or y z))\n; CHECK-NEXT: (assert x)\n(assert (and (or y z) x))\n\n; CHECK-NEXT: (assert (= x x))\n(assert (= x x))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Transforms/AndHoisting/single_and.smt2",
    "content": "; RUN: %jfs-opt -and-hoist %s | %FileCheck %s\n\n; CHECK: (declare-fun x () (_ BitVec 32))\n(declare-fun x () (_ BitVec 32))\n\n; CHECK: (assert true)\n; CHECK-NEXT: (assert true)\n(assert (and true true))\n\n; CHECK-NEXT: (assert (= x x))\n(assert (= x x))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Transforms/AndHoisting/single_and_ternary.smt2",
    "content": "; RUN: %jfs-opt -and-hoist %s | %FileCheck %s\n\n; CHECK: (declare-fun x () (_ BitVec 32))\n(declare-fun x () (_ BitVec 32))\n\n; CHECK: (assert true)\n; CHECK-NEXT: (assert true)\n; CHECK-NEXT: (assert true)\n(assert (and true true true))\n\n; CHECK-NEXT: (assert (= x x))\n(assert (= x x))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Transforms/BvBoundPropagation/bound_contradiction.smt2",
    "content": "; RUN: %jfs-opt -bv-bound-propagation %s | %FileCheck %s\n; CHECK-NOT: (declare-fun a () (_ BitVec 8))\n(declare-fun a () (_ BitVec 8))\n\n; CHECK: (assert false)\n(assert (bvule #xf0 a))\n(assert (bvule a #x08))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Transforms/ConstantPropagation/constant_prop.smt2",
    "content": "; RUN: %jfs-opt -constant-propagation %s | %FileCheck %s\n; CHECK: (declare-fun x () (_ BitVec 8))\n(declare-fun x () (_ BitVec 8))\n; CHECK-NEXT: (declare-fun y () (_ BitVec 8))\n(declare-fun y () (_ BitVec 8))\n\n; CHECK: (assert (= x #xfe))\n(assert (= x #xfe))\n\n(assert (bvugt y x))\n; CHECK-NEXT: (assert (not (bvule y #xfe)))\n\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Transforms/ConstantPropagation/constant_prop_and.smt2",
    "content": "; RUN: %jfs-opt -constant-propagation %s | %FileCheck %s\n; CHECK: (declare-fun x () (_ BitVec 8))\n(declare-fun x () (_ BitVec 8))\n; CHECK-NEXT: (declare-fun y () (_ BitVec 8))\n(declare-fun y () (_ BitVec 8))\n; CHECK-NEXT: (declare-fun z () (_ BitVec 8))\n(declare-fun z () (_ BitVec 8))\n\n; NOTE: Current implementation of constant propagation hoists ands and seems\n; to do some simplication of its own. I don't actually want this as I want good\n; separation of concerns.\n\n; CHECK-DAG: (assert (= z #xfe))\n(assert (and (= x z) (= z x) ))\n\n; CHECK-DAG: (assert (= x #xfe))\n(assert (= x #xfe))\n\n(assert (bvugt y x))\n; CHECK-NEXT: (assert (not (bvule y #xfe)))\n\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Transforms/ConstantPropagation/duplicate_constraint.smt2",
    "content": "; RUN: %jfs-opt -constant-propagation %s | %FileCheck %s\n; CHECK: (declare-fun x () (_ BitVec 8))\n(declare-fun x () (_ BitVec 8))\n\n; Z3 tactic seems to remove duplicate constraints\n; CHECK: (assert (= x #xfe))\n; CHECK-NOT: (assert (= x #xfe))\n(assert (= x #xfe))\n(assert (= x #xfe))\n(assert (= x #xfe))\n(assert (= x #xfe))\n(assert (= x #xfe))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Transforms/ConstantPropagation/modulus_true-unreach-call_true-no-overflow.i_242.smt2",
    "content": "; FIXME: Write test properly. This is just to catch a crash where\n; Z3's Goal API implicitly applies de-morgan.\n; RUN: %jfs-opt -constant-propagation %s\n(set-info :smt-lib-version 2.6)\n(set-logic QF_BV)\n(set-info :source |\nGenerated by the tool Ultimate Automizer [1,2] which implements \nan automata theoretic approach [3] to software verification.\n\nThis SMT script belongs to a set of SMT scripts that was generated by \napplying Ultimate Automizer to benchmarks [4] from the SV-COMP 2017 [5,6].\n\nThis script might _not_ contain all SMT commands that are used by \nUltimate Automizer. In order to satisfy the restrictions of\nthe SMT-COMP we have to drop e.g., the commands for getting\nvalues (resp. models), unsatisfiable cores and interpolants.\n\n2017-05-01, Matthias Heizmann (heizmann@informatik.uni-freiburg.de)\n\n\n[1] https://ultimate.informatik.uni-freiburg.de/automizer/\n[2] Matthias Heizmann, Yu-Wen Chen, Daniel Dietsch, Marius Greitschus, \nAlexander Nutz, Betim Musa, Claus Schätzle, Christian Schilling, \nFrank Schüssele, Andreas Podelski:\nUltimate Automizer with an On-Demand Construction of Floyd-Hoare \nAutomata - (Competition Contribution). TACAS (2) 2017: 394-398\n[3] Matthias Heizmann, Jochen Hoenicke, Andreas Podelski: Software Model \nChecking for People Who Love Automata. CAV 2013:36-52\n[4] https://github.com/sosy-lab/sv-benchmarks\n[5] Dirk Beyer: Software Verification with Validation of Results - \n(Report on SV-COMP 2017). TACAS (2) 2017: 331-349\n[6] https://sv-comp.sosy-lab.org/2017/\n|)\n(set-info :license \"https://creativecommons.org/licenses/by/4.0/\")\n(set-info :category \"industrial\")\n(set-info :status unknown)\n(declare-fun c_main_~n~6 () (_ BitVec 32))\n(declare-fun c_main_~n~6_primed () (_ BitVec 32))\n(declare-fun c_main_~d~6 () (_ BitVec 32))\n(declare-fun c_main_~m~6 () (_ BitVec 32))\n(assert (= c_main_~n~6_primed c_main_~m~6))\n(assert (or (= (bvurem c_main_~n~6 c_main_~d~6) c_main_~m~6) (= c_main_~m~6 c_main_~d~6)))\n(assert (not (or (= (bvurem c_main_~n~6_primed c_main_~d~6) c_main_~m~6) (= c_main_~m~6 c_main_~d~6))))\n(check-sat)\n(exit)\n"
  },
  {
    "path": "tests/system_tests/Transforms/ConstantPropagation/not_preverse_multiple_false.smt2",
    "content": "; RUN: %jfs-opt -constant-propagation %s | %FileCheck %s\n\n; When false gets inserted it seems\n; Z3 ignores all formula that gets\n; inserted into goal\n(declare-fun x () (_ BitVec 8))\n\n; This gets removed too\n(assert (bvugt x #x01))\n\n; CHECK: (assert false)\n(assert false)\n(assert false)\n(assert false)\n(assert false)\n(assert false)\n\n"
  },
  {
    "path": "tests/system_tests/Transforms/ConstantPropagation/preserve_false.smt2",
    "content": "; RUN: %jfs-opt -constant-propagation %s | %FileCheck %s\n; CHECK: (assert false)\n(assert false)\n"
  },
  {
    "path": "tests/system_tests/Transforms/DuplicateConstraintElimination/duplicate_equals.smt2",
    "content": "; RUN: %jfs-opt -dce %s | %FileCheck %s\n\n; CHECK: (declare-fun x () (_ BitVec 32))\n(declare-fun x () (_ BitVec 32))\n; CHECK-NEXT: (declare-fun y () (_ BitVec 32))\n(declare-fun y () (_ BitVec 32))\n\n; CHECK: ; Start constraints (1)\n; CHECK: (assert (= x y))\n; CHECK-NOT: (assert (= x y))\n(assert (= x y))\n(assert (= x y))\n(assert (= x y))\n(assert (= x y))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Transforms/SimpleContradictionsToFalse/e_not_e.smt2",
    "content": "; RUN: %jfs-opt -sctf %s | %FileCheck %s\n\n; CHECK: (declare-fun x () (_ BitVec 32))\n; CHECK-NEXT: (declare-fun y () (_ BitVec 32))\n(declare-fun x () (_ BitVec 32))\n(declare-fun y () (_ BitVec 32))\n\n; CHECK: ; Start constraints (3)\n; CHECK-NEXT: (assert (= (bvxor x y) x))\n(assert (= (bvxor x y) x))\n; CHECK-NEXT: (assert false)\n(assert (not (= x y)))\n; CHECK-NEXT: (assert false)\n(assert (= x y))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Transforms/Simplify/constant_fold_bvadd.smt2",
    "content": "; RUN: %jfs-opt -simplify %s | %FileCheck %s\n\n; CHECK: (declare-fun x () (_ BitVec 8))\n(declare-fun x () (_ BitVec 8))\n\n; CHECK: (assert (= x #xf1))\n(assert (= x (bvadd #x01 #xf0)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Transforms/Simplify/constant_fold_ite_identity.smt2",
    "content": "; RUN: %jfs-opt -simplify %s | %FileCheck %s\n\n; CHECK-NOT: (declare-fun x () (_ BitVec 8))\n; CHECK: (declare-fun y () (_ BitVec 8))\n; CHECK: (declare-fun z () (_ BitVec 8))\n(declare-fun x () (_ BitVec 8))\n(declare-fun y () (_ BitVec 8))\n(declare-fun z () (_ BitVec 8))\n\n; CHECK: (assert (= y z))\n(assert\n  (=\n    (ite\n      (= x y)\n      x\n      y\n    )\n    z\n  )\n)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Transforms/Simplify/equal.smt2",
    "content": "; RUN: %jfs-opt -simplify %s | %FileCheck %s\n\n; CHECK-NOT: (declare-fun x\n(declare-fun x () (_ BitVec 8))\n\n; simplify now removes the constraint entirely.\n; CHECK: Start constraints (0)\n(assert (= x x))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Transforms/Simplify/not_equal.smt2",
    "content": "; RUN: %jfs-opt -simplify %s | %FileCheck %s\n\n; CHECK-NOT: (declare-fun x\n(declare-fun x () (_ BitVec 8))\n\n; CHECK: (assert false)\n(assert (not (= x x)))\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Transforms/TrueConstraintElimination/true_elim.smt2",
    "content": "; RUN: %jfs-opt -tce %s | %FileCheck %s\n; CHECK: (declare-fun x () (_ BitVec 32))\n; CHECK-NEXT: (declare-fun y () (_ BitVec 32))\n(declare-fun x () (_ BitVec 32))\n(declare-fun y () (_ BitVec 32))\n\n; CHECK: ; Start constraints (1)\n; CHECK: (assert (not (= x y)))\n(assert (not (= x y)))\n\n; CHECK-NOT: (assert true)\n(assert true)\n(assert true)\n(assert true)\n(assert true)\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Z3Backend/QF_FPBV/sat/imperial_synthetic_sqrt_klee_bug.x86_64_query.05.smt2",
    "content": "; RUN: %jfs -z3 %s | %FileCheck %s\n(set-info :smt-lib-version 2.5)\n(set-logic QF_FPBV)\n(set-info :source |\nGenerated by: Daniel Liew, Daniel Schemmel, Cristian Cadar, Alastair Donaldson, and Rafael Zähl\nGenerated on: 2017-4-28\nGenerator: KLEE\nApplication: Branch satisfiability check for symbolic execution of C programs\nTarget solver: Z3 or MathSAT5\nCorresponding query: An equisatisfiable query (bitvectors replaced with reads from arrays of bitvectors) is available at QF_FPABV/liew/imperial_synthetic_sqrt_klee_bug.x86_64/query.05.smt2\n|)\n(set-info :license \"https://creativecommons.org/licenses/by/4.0/\")\n(set-info :category \"industrial\")\n(set-info :status sat)\n(declare-fun x_ackermann!0 () (_ BitVec 32))\n(assert\n (not (fp.isNaN ((_ to_fp 8 24) x_ackermann!0))))\n(assert\n (not (fp.lt ((_ to_fp 8 24) x_ackermann!0) ((_ to_fp 8 24) (_ bv0 32)))))\n(assert\n (not (fp.gt ((_ to_fp 8 24) x_ackermann!0) ((_ to_fp 8 24) (_ bv1120403456 32)))))\n(assert\n (let ((?x8 ((_ to_fp 8 24) x_ackermann!0)))\n(let ((?x23 (fp.mul roundNearestTiesToEven (fp.add roundNearestTiesToEven ?x8 ((_ to_fp 8 24) (_ bv0 32))) ((_ to_fp 8 24) (_ bv1056964608 32)))))\n(let (($x28 (fp.lt (fp.abs (fp.sub roundNearestTiesToEven ?x23 ?x8)) ((_ to_fp 8 24) (_ bv869711765 32)))))\n(not $x28)))))\n\n; CHECK: {{^sat$}}\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/Z3Backend/QF_FPBV/unsat/imperial_synthetic_sqrt_klee_bug.x86_64_query.06.smt2",
    "content": "; RUN: %jfs -z3 %s | %FileCheck %s\n(set-info :smt-lib-version 2.5)\n(set-logic QF_FPBV)\n(set-info :source |\nGenerated by: Daniel Liew, Daniel Schemmel, Cristian Cadar, Alastair Donaldson, and Rafael Zähl\nGenerated on: 2017-4-28\nGenerator: KLEE\nApplication: Branch satisfiability check for symbolic execution of C programs\nTarget solver: Z3 or MathSAT5\nCorresponding query: An equisatisfiable query (bitvectors replaced with reads from arrays of bitvectors) is available at QF_FPABV/liew/imperial_synthetic_sqrt_klee_bug.x86_64/query.06.smt2\n|)\n(set-info :license \"https://creativecommons.org/licenses/by/4.0/\")\n(set-info :category \"industrial\")\n(set-info :status unsat)\n(declare-fun x_ackermann!0 () (_ BitVec 32))\n(assert\n (not (fp.isNaN ((_ to_fp 8 24) x_ackermann!0))))\n(assert\n (not (fp.lt ((_ to_fp 8 24) x_ackermann!0) ((_ to_fp 8 24) (_ bv0 32)))))\n(assert\n (not (fp.gt ((_ to_fp 8 24) x_ackermann!0) ((_ to_fp 8 24) (_ bv1120403456 32)))))\n(assert\n (let ((?x8 ((_ to_fp 8 24) x_ackermann!0)))\n (let ((?x23 (fp.mul roundNearestTiesToEven (fp.add roundNearestTiesToEven ?x8 ((_ to_fp 8 24) (_ bv0 32))) ((_ to_fp 8 24) (_ bv1056964608 32)))))\n (fp.lt (fp.abs (fp.sub roundNearestTiesToEven ?x23 ?x8)) ((_ to_fp 8 24) (_ bv869711765 32))))))\n(assert\n (let ((?x8 ((_ to_fp 8 24) x_ackermann!0)))\n(let ((?x23 (fp.mul roundNearestTiesToEven (fp.add roundNearestTiesToEven ?x8 ((_ to_fp 8 24) (_ bv0 32))) ((_ to_fp 8 24) (_ bv1056964608 32)))))\n(not (and (not (fp.isNaN ?x23)) (not (fp.gt ?x23 ?x8)))))))\n\n; CHECK: {{^unsat$}}\n\n(check-sat)\n"
  },
  {
    "path": "tests/system_tests/lit.cfg",
    "content": "# -*- Python -*-\n# vim: set filetype=python:\n# vim: ts=2:sts=2:sw=2:et:tw=80:\n\n# Configuration file for the 'lit' test runner.\n\nimport os\nimport sys\nimport re\nimport platform\nimport pprint\n\ntry:\n  import lit.util\n  import lit.formats\nexcept ImportError:\n  pass\n\n# name: The name of this test suite.\nconfig.name = 'JFS'\n\n# testFormat: The test format to use to interpret tests.\nconfig.test_format = lit.formats.ShTest(execute_external=False)\n\n# suffixes: A list of file extensions to treat as test files\n# Note this can be overridden by lit.local.cfg files\nconfig.suffixes = ['.smt2']\n\n# test_source_root: The root path where tests are located.\nconfig.test_source_root = os.path.dirname(__file__)\n\n# test_exec_root: The root path where tests should be run.\njfs_bin_root = getattr(config, 'jfs_bin_root', None)\n\nif jfs_bin_root is not None:\n  config.test_exec_root = os.path.join(jfs_bin_root, 'tests', 'system_tests')\n\n# Propogate some environment variable to test environment.\ndef addEnv(name):\n  if name in os.environ:\n    config.environment[name] = os.environ[name]\n\n# Sanitizer environment variables\naddEnv('ASAN_OPTIONS')\naddEnv('UBSAN_OPTIONS')\naddEnv('ASAN_SYMBOLIZER_PATH')\naddEnv('LSAN_OPTIONS')\naddEnv('MSAN_OPTIONS')\naddEnv('MSAN_SYMBOLIZER_PATH')\naddEnv('TSAN_OPTIONS')\n\n# Check that the object root is known.\nif config.test_exec_root is None:\n  lit_config.fatal('test execution root not set!')\n\n\n# Add a substitution for FileCheck\nconfig.substitutions.append(\n  ('%FileCheck', config.filecheck_tool_path)\n)\n\n# Add a substitution for not\nconfig.substitutions.append(\n  ('%not', config.not_tool_path)\n)\n\n# Add a substitution for Clang\ncxxStr = '{} -x \"c++\" -std=\"c++11\" '.format(config.clang_tool_path)\ncxxRuntimeStr = '{} -I {} '.format(\n  cxxStr,\n  os.path.join(config.jfs_bin_root, 'runtime', 'include')\n)\ncxxRuntimeSyntaxCheckStr = '{} -fsyntax-only '.format(cxxRuntimeStr)\nconfig.substitutions.append(('%cxx-rt-syntax', cxxRuntimeSyntaxCheckStr))\nconfig.substitutions.append(('%cxx-rt', cxxRuntimeStr))\nconfig.substitutions.append(('%cxx', cxxStr))\n\n# Get JFS specific parameters passed on llvm-lit cmd line\n# e.g. llvm-lit --param jfs_opts=--help\njfs_extra_params = lit_config.params.get('jfs_opts',\"\")\n\n# Get custom path to jfs binary if specified\njfs_tool_path = lit_config.params.get('jfs_tool_path', None)\nif jfs_tool_path is None:\n  # No custom path, use jfs from build tree\n  jfs_tool_path = config.jfs_tool_path\n\n# Get custom path to jfs-opt binary if specified\njfs_opt_tool_path = lit_config.params.get('jfs_opt_tool_path', None)\nif jfs_opt_tool_path is None:\n  # No custom path, use jfs-opt from build tree\n  jfs_opt_tool_path = config.jfs_opt_tool_path\n\n# Get custom path to jfs-smt2cnf binary if specified\njfs_smt_to_cnf_tool_path = lit_config.params.get('jfs_smt_to_cnf_tool_path', None)\nif jfs_smt_to_cnf_tool_path is None:\n  # No custom path, use jfs-smt2cnf from build tree\n  jfs_smt_to_cnf_tool_path = config.jfs_smt_to_cnf_tool_path\n\n# Get custom path to jfs-smt2cxx binary if specified\njfs_smt_to_cxx_tool_path = lit_config.params.get('jfs_smt_to_cxx_tool_path', None)\nif jfs_smt_to_cxx_tool_path is None:\n  # No custom path, use jfs-smt2cxx from build tree\n  jfs_smt_to_cxx_tool_path = config.jfs_smt_to_cxx_tool_path\n\nif len(jfs_extra_params) != 0:\n  print(\"Passing extra jfs command line args: {0}\".format(\n    jfs_extra_params)\n  )\n  jfs_tool_path += \" {}\".format(jfs_extra_params)\n\n# Add a substitution for jfs-opt tool\nconfig.substitutions.append(\n  ('%jfs-opt', jfs_opt_tool_path)\n)\n\n# Add a substitution for jfs-smt2cnf tool\nconfig.substitutions.append(\n  ('%jfs-smt2cnf', jfs_smt_to_cnf_tool_path)\n)\n\n# Add a substitution for jfs-smt2cxx tool\nconfig.substitutions.append(\n  ('%jfs-smt2cxx', jfs_smt_to_cxx_tool_path)\n)\n\n# Add substitution to disable optimisation passes\nconfig.substitutions.append(\n  (\n    '%jfs_no_opt_options',\n    '-disable-standard-passes -disable-equality-extraction'\n  )\n)\n\n# Add a substitution for jfs tool\n# Provide a way to automatically validate models in every run of the JFS\n# tool. Do this by default.\nvalidate_models_in_jfs = lit_config.params.get('jfs_validate_models', '1')\nvalidate_models_in_jfs = True if validate_models_in_jfs == '1' else False\nif validate_models_in_jfs:\n  jfs_tool_substitution = '{} -validate-model '.format(jfs_tool_path)\nelse:\n  jfs_tool_substitution = jfs_tool_path\n\nconfig.substitutions.append(\n  ('%jfs', jfs_tool_substitution)\n)\n\nconfig.substitutions.append(\n  ('%yaml-syntax-check', config.yaml_syntax_check_tool_path)\n)\n\n# Find diff tool\ndiff_path = lit.util.which('diff')\nif diff_path is None:\n  lit_config.error('Could not find diff tool')\nconfig.substitutions.append(\n  ('%diff', diff_path)\n)\n\n# Add features\nhost_os = platform.system().lower()\nlit_config.note('Adding feature \"{}\"'.format(host_os))\nconfig.available_features.add(host_os)\n\n# HACK:\n# Add additional features requested on the command line.\n# This exists to workaround the fact that individual tests\n# that use `JFSFuzzTestFormat` can't be run without setting\n# the right feature flag.\nfake_features_str = lit_config.params.get('jfs_fake_features', None)\nif fake_features_str is not None:\n  assert isinstance(fake_features_str, str)\n  fake_features = fake_features_str.split(',')\n  assert len(fake_features) > 0\n  for fake_feature in fake_features:\n    if len(fake_feature) == 0:\n      continue\n    lit_config.note('Adding fake feature {}'.format(fake_feature))\n    config.available_features.add(fake_feature)\n\nlit_config.note('Substitutions: {}'.format(pprint.pformat(config.substitutions)))\nlit_config.note('Features: {}'.format(pprint.pformat(config.available_features)))\n"
  },
  {
    "path": "tests/system_tests/lit.site.cfg.in",
    "content": "## Autogenerated by JFS configuration.\n# Do not edit!\nconfig.jfs_tool_path = \"@JFS_TOOL_PATH@\"\nconfig.jfs_opt_tool_path = \"@JFS_OPT_TOOL_PATH@\"\nconfig.jfs_smt_to_cnf_tool_path = \"@JFS_SMT_TO_CNF_TOOL_PATH@\"\nconfig.jfs_smt_to_cxx_tool_path = \"@JFS_SMT_TO_CXX_TOOL_PATH@\"\nconfig.filecheck_tool_path = \"@FILECHECK_BIN_PATH@\"\nconfig.not_tool_path = \"@NOT_BIN_PATH@\"\nconfig.yaml_syntax_check_tool_path = \"@YAML_SYNTAX_CHECK_PATH@\"\n\nconfig.jfs_src_root = \"@CMAKE_SOURCE_DIR@\"\nconfig.jfs_bin_root = \"@CMAKE_BINARY_DIR@\"\n\nconfig.clang_tool_path = \"@JFS_LLVM_CLANG_CXX_TOOL@\"\n\nlit_config.load_config(config, \"@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg\")\n"
  },
  {
    "path": "tests/unit_tests/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\ninclude(\"${CMAKE_SOURCE_DIR}/cmake/add_jfs_unit_test.cmake\")\n\n# Note we assume GTest is already built in `utils/CMakeLists.txt`\n\n# Unit Tests\nadd_subdirectory(Core)\nadd_subdirectory(Dummy)\nadd_subdirectory(FuzzingCommon)\n\n# Set up lit configuration\nconfigure_file(\n  \"lit-unit-tests-common.site.cfg.in\"\n  \"lit.site.cfg\"\n  @ONLY\n)\n\nget_property(UNIT_TEST_DEPENDS\n  GLOBAL\n  PROPERTY JFS_UNIT_TEST_TARGETS\n)\nadd_custom_target(jfs_lib_unittests\n  COMMAND\n    \"${CMAKE_COMMAND}\" -E env\n      \"UBSAN_OPTIONS=halt_on_error=1\"\n      \"${LIT_TOOL}\" ${LIT_ARGS} \"${CMAKE_CURRENT_BINARY_DIR}\"\n    DEPENDS ${UNIT_TEST_DEPENDS}\n    COMMENT \"Running JFS library unittests\"\n    ${ADD_CUSTOM_COMMAND_USES_TERMINAL_ARG}\n)\n# Make top level target depend on JFS library unit tests\nadd_dependencies(unittests jfs_lib_unittests)\n"
  },
  {
    "path": "tests/unit_tests/Core/CMakeLists.txt",
    "content": "add_jfs_unit_test(Core\n  FloatSpecialConstants.cpp\n)\ntarget_link_libraries(Core${UNIT_TEST_EXE_SUFFIX}\n  PRIVATE\n  JFSCore\n)\n"
  },
  {
    "path": "tests/unit_tests/Core/FloatSpecialConstants.cpp",
    "content": "#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Core/Z3Node.h\"\n#include \"gtest/gtest.h\"\n#include <memory>\n\nusing namespace jfs::core;\n\nstd::unique_ptr<JFSContext> mkContext() {\n  JFSContextConfig config;\n  std::unique_ptr<JFSContext> ctx(new JFSContext(config));\n  return std::move(ctx);\n}\n\n// Float32 subnormal special values.\n\nTEST(Z3ASTNode, Float32AbsSmallestSubnormalPositive) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat32Ty(ctx->getZ3Ctx());\n  auto e =\n      Z3ASTHandle::getFloatAbsoluteSmallestSubnormal(ty, /*positive=*/true);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b0 #x00 #b00000000000000000000001)\");\n}\n\nTEST(Z3ASTNode, Float32AbsSmallestSubnormalNegative) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat32Ty(ctx->getZ3Ctx());\n  auto e =\n      Z3ASTHandle::getFloatAbsoluteSmallestSubnormal(ty, /*positive=*/false);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b1 #x00 #b00000000000000000000001)\");\n}\n\nTEST(Z3ASTNode, Float32AbsLargestSubnormalPositive) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat32Ty(ctx->getZ3Ctx());\n  auto e = Z3ASTHandle::getFloatAbsoluteLargestSubnormal(ty, /*positive=*/true);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b0 #x00 #b11111111111111111111111)\");\n}\n\nTEST(Z3ASTNode, Float32AbsLargestSubnormalNegative) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat32Ty(ctx->getZ3Ctx());\n  auto e =\n      Z3ASTHandle::getFloatAbsoluteLargestSubnormal(ty, /*positive=*/false);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b1 #x00 #b11111111111111111111111)\");\n}\n\n// Float32 Normal special values.\n\nTEST(Z3ASTNode, Float32AbsSmallestNormalPositive) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat32Ty(ctx->getZ3Ctx());\n  auto e = Z3ASTHandle::getFloatAbsoluteSmallestNormal(ty, /*positive=*/true);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b0 #x01 #b00000000000000000000000)\");\n}\n\nTEST(Z3ASTNode, Float32AbsSmallestNormalNegative) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat32Ty(ctx->getZ3Ctx());\n  auto e = Z3ASTHandle::getFloatAbsoluteSmallestNormal(ty, /*positive=*/false);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b1 #x01 #b00000000000000000000000)\");\n}\n\nTEST(Z3ASTNode, Float32AbsLargestNormalPositive) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat32Ty(ctx->getZ3Ctx());\n  auto e = Z3ASTHandle::getFloatAbsoluteLargestNormal(ty, /*positive=*/true);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b0 #xfe #b11111111111111111111111)\");\n}\n\nTEST(Z3ASTNode, Float32AbsLargestNormalNegative) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat32Ty(ctx->getZ3Ctx());\n  auto e = Z3ASTHandle::getFloatAbsoluteLargestNormal(ty, /*positive=*/false);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b1 #xfe #b11111111111111111111111)\");\n}\n\n// Float64 subnormal special values.\n\nTEST(Z3ASTNode, Float64AbsSmallestSubnormalPositive) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat64Ty(ctx->getZ3Ctx());\n  auto e =\n      Z3ASTHandle::getFloatAbsoluteSmallestSubnormal(ty, /*positive=*/true);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b0 #b00000000000 #x0000000000001)\");\n}\n\nTEST(Z3ASTNode, Float64AbsSmallestSubnormalNegative) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat64Ty(ctx->getZ3Ctx());\n  auto e =\n      Z3ASTHandle::getFloatAbsoluteSmallestSubnormal(ty, /*positive=*/false);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b1 #b00000000000 #x0000000000001)\");\n}\n\nTEST(Z3ASTNode, Float64AbsLargestSubnormalPositive) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat64Ty(ctx->getZ3Ctx());\n  auto e = Z3ASTHandle::getFloatAbsoluteLargestSubnormal(ty, /*positive=*/true);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b0 #b00000000000 #xfffffffffffff)\");\n}\n\nTEST(Z3ASTNode, Float64AbsLargestSubnormalNegative) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat64Ty(ctx->getZ3Ctx());\n  auto e =\n      Z3ASTHandle::getFloatAbsoluteLargestSubnormal(ty, /*positive=*/false);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b1 #b00000000000 #xfffffffffffff)\");\n}\n\n// Float64 Normal special values.\n\nTEST(Z3ASTNode, Float64AbsSmallestNormalPositive) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat64Ty(ctx->getZ3Ctx());\n  auto e = Z3ASTHandle::getFloatAbsoluteSmallestNormal(ty, /*positive=*/true);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b0 #b00000000001 #x0000000000000)\");\n}\n\nTEST(Z3ASTNode, Float64AbsSmallestNormalNegative) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat64Ty(ctx->getZ3Ctx());\n  auto e = Z3ASTHandle::getFloatAbsoluteSmallestNormal(ty, /*positive=*/false);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b1 #b00000000001 #x0000000000000)\");\n}\n\nTEST(Z3ASTNode, Float64AbsLargestNormalPositive) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat64Ty(ctx->getZ3Ctx());\n  auto e = Z3ASTHandle::getFloatAbsoluteLargestNormal(ty, /*positive=*/true);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b0 #b11111111110 #xfffffffffffff)\");\n}\n\nTEST(Z3ASTNode, Float64AbsLargestNormalNegative) {\n  auto ctx = mkContext();\n  auto ty = Z3SortHandle::getFloat64Ty(ctx->getZ3Ctx());\n  auto e = Z3ASTHandle::getFloatAbsoluteLargestNormal(ty, /*positive=*/false);\n  ASSERT_STREQ(e.toStr().c_str(), \"(fp #b1 #b11111111110 #xfffffffffffff)\");\n}\n\n// TODO: Test other special constants, e.g. Inf, Nan, +zero, -zero.\n"
  },
  {
    "path": "tests/unit_tests/Dummy/CMakeLists.txt",
    "content": "# Just to check the build works\nadd_jfs_unit_test(Dummy\n  Dummy.cpp\n)\n"
  },
  {
    "path": "tests/unit_tests/Dummy/Dummy.cpp",
    "content": "#include \"gtest/gtest.h\"\n\nTEST(Dummy, DummyOne) {\n  EXPECT_EQ(1, 1);\n}\n"
  },
  {
    "path": "tests/unit_tests/FuzzingCommon/CMakeLists.txt",
    "content": "# Just to check the build works\nadd_jfs_unit_test(FuzzingCommon\n  EqualityExtractionPass.cpp\n)\ntarget_link_libraries(FuzzingCommon${UNIT_TEST_EXE_SUFFIX}\n  PRIVATE\n  JFSFuzzingCommon\n  JFSCore\n)\n"
  },
  {
    "path": "tests/unit_tests/FuzzingCommon/EqualityExtractionPass.cpp",
    "content": "#include \"jfs/FuzzingCommon/EqualityExtractionPass.h\"\n#include \"jfs/Core/SMTLIB2Parser.h\"\n#include \"gtest/gtest.h\"\n#include <memory>\n\nusing namespace jfs::core;\nusing namespace jfs::fuzzingCommon;\n\nclass ParserHelper {\nprivate:\n  std::unique_ptr<JFSContext> ctx;\n  std::unique_ptr<SMTLIB2Parser> parser;\n\npublic:\n  ParserHelper() {\n    JFSContextConfig ctxCfg;\n    ctx.reset(new JFSContext(ctxCfg));\n    parser.reset(new SMTLIB2Parser(*ctx));\n  }\n  JFSContext &getContext() { return *ctx; }\n  SMTLIB2Parser &getParser() { return *parser; }\n};\n\nTEST(EqualityExtractionPass, singleEquality) {\n  ParserHelper h;\n  auto query = h.getParser().parseStr(\n      R\"(\n    (declare-const a (_ BitVec 8))\n    (declare-const b (_ BitVec 8))\n    (assert (= a b))\n    (assert (bvugt a #x03))\n    )\");\n  ASSERT_EQ(h.getParser().getErrorCount(), 0UL);\n  ASSERT_NE(query.get(), nullptr);\n  ASSERT_EQ(query->constraints.size(), 2UL);\n  EqualityExtractionPass eep;\n  eep.run(*query);\n  ASSERT_EQ(query->constraints.size(), 1UL);\n  ASSERT_EQ(eep.equalities.size(), 1UL);\n  auto es = *(eep.equalities.cbegin());\n  // Expect that a and b are in equality set\n  ASSERT_EQ(es->size(), 2UL);\n  bool foundA = false;\n  bool foundB = false;\n  for (const auto &e : *es) {\n    if (e.toStr() == \"a\")\n      foundA = true;\n    if (e.toStr() == \"b\")\n      foundB = true;\n  }\n  ASSERT_TRUE(foundA);\n  ASSERT_TRUE(foundB);\n  // Check that remaining constraints are as expected\n  ASSERT_EQ(query->constraints[0].toStr(), \"(bvugt a #x03)\");\n}\n\nTEST(EqualityExtractionPass, ThreeEqualVars) {\n  ParserHelper h;\n  auto query = h.getParser().parseStr(\n      R\"(\n    (declare-const a (_ BitVec 8))\n    (declare-const b (_ BitVec 8))\n    (declare-const c (_ BitVec 8))\n    (assert (= a b))\n    (assert (= b c))\n    ; these are redundant equalities that should be removed by pass\n    (assert (= a c))\n    (assert (= b a))\n    (assert (= c a))\n    (assert (= a c))\n    (assert (bvugt a #x03))\n    )\");\n  ASSERT_EQ(h.getParser().getErrorCount(), 0UL);\n  ASSERT_NE(query.get(), nullptr);\n  ASSERT_EQ(query->constraints.size(), 7UL);\n  EqualityExtractionPass eep;\n  eep.run(*query);\n  ASSERT_EQ(query->constraints.size(), 1UL);\n  ASSERT_EQ(eep.equalities.size(), 1UL);\n  auto es = *(eep.equalities.cbegin());\n  // Expect that a, b, and c are in equality set\n  ASSERT_EQ(es->size(), 3UL);\n  bool foundA = false;\n  bool foundB = false;\n  bool foundC = false;\n  for (const auto &e : *es) {\n    if (e.toStr() == \"a\") {\n      foundA = true;\n      continue;\n    }\n    if (e.toStr() == \"b\") {\n      foundB = true;\n      continue;\n    }\n    if (e.toStr() == \"c\") {\n      foundC = true;\n      continue;\n    }\n  }\n  ASSERT_TRUE(foundA);\n  ASSERT_TRUE(foundB);\n  ASSERT_TRUE(foundC);\n  // Check that remaining constraints are as expected\n  ASSERT_EQ(query->constraints[0].toStr(), \"(bvugt a #x03)\");\n}\n\nTEST(EqualityExtractionPass, boolAssignmentTrue) {\n  ParserHelper h;\n  auto query = h.getParser().parseStr(\n      R\"(\n    (declare-const a Bool)\n    (assert a)\n    )\");\n  ASSERT_EQ(h.getParser().getErrorCount(), 0UL);\n  ASSERT_NE(query.get(), nullptr);\n  ASSERT_EQ(query->constraints.size(), 1UL);\n  EqualityExtractionPass eep;\n  eep.run(*query);\n  ASSERT_EQ(query->constraints.size(), 0UL);\n  ASSERT_EQ(eep.equalities.size(), 1UL);\n  auto es = *(eep.equalities.cbegin());\n  // Expect that a and true\n  ASSERT_EQ(es->size(), 2UL);\n  bool foundA = false;\n  bool foundTrue = false;\n  for (const auto& e : *es) {\n    if (e.toStr() == \"a\")\n      foundA = true;\n    if (e.isTrue())\n      foundTrue = true;\n  }\n  ASSERT_TRUE(foundA);\n  ASSERT_TRUE(foundTrue);\n}\n\nTEST(EqualityExtractionPass, boolAssignmentFalse) {\n  ParserHelper h;\n  auto query = h.getParser().parseStr(\n      R\"(\n    (declare-const a Bool)\n    (assert (not a))\n    )\");\n  ASSERT_EQ(h.getParser().getErrorCount(), 0UL);\n  ASSERT_NE(query.get(), nullptr);\n  ASSERT_EQ(query->constraints.size(), 1UL);\n  EqualityExtractionPass eep;\n  eep.run(*query);\n  ASSERT_EQ(query->constraints.size(), 0UL);\n  ASSERT_EQ(eep.equalities.size(), 1UL);\n  auto es = *(eep.equalities.cbegin());\n  // Expect that a and false\n  ASSERT_EQ(es->size(), 2UL);\n  bool foundA = false;\n  bool foundFalse = false;\n  for (const auto& e : *es) {\n    if (e.toStr() == \"a\")\n      foundA = true;\n    if (e.isFalse())\n      foundFalse = true;\n  }\n  ASSERT_TRUE(foundA);\n  ASSERT_TRUE(foundFalse);\n}\n\nTEST(EqualityExtractionPass, singleInconsistency) {\n  ParserHelper h;\n  auto query = h.getParser().parseStr(\n      R\"(\n    (declare-const a (_ BitVec 8))\n    (assert (= a #x03))\n    (assert (= a #x04))\n    )\");\n  ASSERT_EQ(h.getParser().getErrorCount(), 0UL);\n  ASSERT_NE(query.get(), nullptr);\n  ASSERT_EQ(query->constraints.size(), 2UL);\n  EqualityExtractionPass eep;\n  eep.run(*query);\n  ASSERT_EQ(query->constraints.size(), 1UL);\n  ASSERT_EQ(eep.equalities.size(), 1UL);\n  auto es = *(eep.equalities.cbegin());\n  // Expect that a, #x03, and #x04 are in equality set\n  ASSERT_EQ(es->size(), 3UL);\n  bool foundA = false;\n  bool found3 = false;\n  bool found4 = false;\n  for (const auto& e : *es) {\n    if (e.toStr() == \"a\")\n      foundA = true;\n    if (e.isConstant()) {\n      uint64_t value = 0;\n      bool success = e.asApp().getConstantAsUInt64(&value);\n      ASSERT_TRUE(success);\n      if (value == UINT64_C(3))\n        found3 = true;\n      if (value == UINT64_C(4))\n        found4 = true;\n    }\n  }\n  ASSERT_TRUE(foundA);\n  ASSERT_TRUE(found3);\n  ASSERT_TRUE(found4);\n  // Check that the constraints got replaced with false\n  ASSERT_EQ(query->constraints.size(), UINT64_C(1));\n  ASSERT_TRUE(query->constraints[0].isFalse());\n}\n\nTEST(EqualityExtractionPass, mergeSets) {\n  ParserHelper h;\n  auto query = h.getParser().parseStr(\n      R\"(\n    (declare-const a Bool)\n    (declare-const b Bool)\n    (declare-const c Bool)\n    (declare-const d Bool)\n    ; The transitive closure of equalities\n    ; should be a single set\n    (assert (= a b))\n    (assert (= c d))\n    (assert (= a c))\n    )\");\n  ASSERT_EQ(h.getParser().getErrorCount(), 0UL);\n  ASSERT_NE(query.get(), nullptr);\n  ASSERT_EQ(query->constraints.size(), 3UL);\n  EqualityExtractionPass eep;\n  eep.run(*query);\n  ASSERT_EQ(query->constraints.size(), 0UL);\n  ASSERT_EQ(eep.equalities.size(), 1UL);\n  auto es = *(eep.equalities.cbegin());\n  // Expect that a,b,c,d\n  ASSERT_EQ(es->size(), 4UL);\n  bool foundA = false;\n  bool foundB = false;\n  bool foundC = false;\n  bool foundD = false;\n  for (const auto& e : *es) {\n    if (e.toStr() == \"a\")\n      foundA = true;\n    if (e.toStr() == \"b\")\n      foundB = true;\n    if (e.toStr() == \"c\")\n      foundC = true;\n    if (e.toStr() == \"d\")\n      foundD = true;\n  }\n  ASSERT_TRUE(foundA);\n  ASSERT_TRUE(foundB);\n  ASSERT_TRUE(foundC);\n  ASSERT_TRUE(foundD);\n}\n"
  },
  {
    "path": "tests/unit_tests/lit-unit-tests-common.cfg",
    "content": "# Configuration file for the 'lit' test runner.\n\nimport os\n\nimport lit.formats\n\n# suffixes: A list of file extensions to treat as test files.\nconfig.suffixes = []\n\n# testFormat: The test format to use to interpret tests.\nconfig.test_format = lit.formats.GoogleTest('.', config.unit_test_exe_suffix)\n"
  },
  {
    "path": "tests/unit_tests/lit-unit-tests-common.site.cfg.in",
    "content": "import sys\nimport os\n\n## @AUTO_GEN_MSG@\nconfig.name = 'JFS Unit tests'\nconfig.unit_test_exe_suffix = \"@UNIT_TEST_EXE_SUFFIX@\"\n\n# Let the main config do the real work.\nlit_config.load_config(config, \"@CMAKE_SOURCE_DIR@/tests/unit_tests/lit-unit-tests-common.cfg\")\n"
  },
  {
    "path": "tools/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\nadd_subdirectory(jfs)\nadd_subdirectory(jfs-opt)\nadd_subdirectory(jfs-smt2cnf)\nadd_subdirectory(jfs-smt2cxx)\nadd_subdirectory(yaml-syntax-check)\n"
  },
  {
    "path": "tools/jfs/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\nadd_executable(jfs_tool\n  main.cpp\n)\n\n# Needed for command line support\njfs_get_llvm_components(llvm_components support)\n\ntarget_link_libraries(\n  jfs_tool\n  PRIVATE\n  ${llvm_components}\n  JFSSupport\n  JFSCore\n  JFSTransform\n  JFSFuzzingCommon\n  JFSFuzzingCommonCmdLine\n  JFSZ3Backend\n  JFSCXXFuzzingBackend\n  JFSCXXFuzzingBackendCmdLine\n)\n\n# Give shortname\nset_property(TARGET jfs_tool PROPERTY OUTPUT_NAME jfs)\n"
  },
  {
    "path": "tools/jfs/main.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/CXXFuzzingBackend/CXXFuzzingSolver.h\"\n#include \"jfs/CXXFuzzingBackend/CXXFuzzingSolverOptions.h\"\n#include \"jfs/CXXFuzzingBackend/ClangOptions.h\"\n#include \"jfs/CXXFuzzingBackend/CmdLine/CXXProgramBuilderOptionsBuilder.h\"\n#include \"jfs/CXXFuzzingBackend/CmdLine/ClangOptionsBuilder.h\"\n#include \"jfs/CXXFuzzingBackend/CmdLine/CommandLineCategory.h\"\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Core/JFSTimerMacros.h\"\n#include \"jfs/Core/Model.h\"\n#include \"jfs/Core/ModelValidator.h\"\n#include \"jfs/Core/SMTLIB2Parser.h\"\n#include \"jfs/Core/ScopedJFSContextErrorHandler.h\"\n#include \"jfs/Core/ToolErrorHandler.h\"\n#include \"jfs/FuzzingCommon/CmdLine/FreeVariableToBufferAssignmentPassOptionsBuilder.h\"\n#include \"jfs/FuzzingCommon/CmdLine/LibFuzzerOptionsBuilder.h\"\n#include \"jfs/FuzzingCommon/CmdLine/SeedManagerOptionsBuilder.h\"\n#include \"jfs/FuzzingCommon/DummyFuzzingSolver.h\"\n#include \"jfs/Support/ErrorMessages.h\"\n#include \"jfs/Support/ScopedTimer.h\"\n#include \"jfs/Support/StatisticsManager.h\"\n#include \"jfs/Support/version.h\"\n#include \"jfs/Transform/QueryPassManager.h\"\n#include \"jfs/Transform/StandardPasses.h\"\n#include \"jfs/Z3Backend/Z3Solver.h\"\n#include \"llvm/ADT/SmallVector.h\"\n#include \"llvm/Support/CommandLine.h\"\n#include \"llvm/Support/FileSystem.h\"\n#include \"llvm/Support/MemoryBuffer.h\"\n#include \"llvm/Support/Path.h\"\n#include \"llvm/Support/Signals.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <string>\n\nusing namespace jfs;\nusing namespace jfs::core;\nusing namespace jfs::transform;\n\nnamespace {\nllvm::cl::opt<std::string> InputFilename(llvm::cl::Positional,\n                                         llvm::cl::desc(\"<input file>\"),\n                                         llvm::cl::init(\"-\"));\nllvm::cl::opt<unsigned> Verbosity(\"v\", llvm::cl::desc(\"Verbosity level\"),\n                                  llvm::cl::init(0),\n                                  llvm::cl::ZeroOrMore);\n\nllvm::cl::opt<unsigned>\n    MaxTime(\"max-time\", llvm::cl::desc(\"Max allowed solver time (seconds). \"\n                                       \"Default is 0 which means no maximum\"),\n            llvm::cl::init(0));\n\nllvm::cl::opt<std::string> OutputDirectory(\n    \"output-dir\", llvm::cl::init(\"\"),\n    llvm::cl::desc(\"Output directory. If not set automatically create one\"));\n\nllvm::cl::opt<bool>\n    KeepOutputDirectory(\"keep-output-dir\", llvm::cl::init(false),\n                        llvm::cl::desc(\"Keep output directory (default false)\"),\n                        llvm::cl::ZeroOrMore);\n\nllvm::cl::opt<std::string>\n    StatsFilename(\"stats-file\",\n                  llvm::cl::desc(\"Location to write stats file. `-` writes to \"\n                                 \"stdout. (default don't write file)\"),\n                  llvm::cl::init(\"\"));\n\n// FIXME: Remove this when we provide a cleaner way to specify passes.\nllvm::cl::opt<bool> DisableStandardPasses(\n    \"disable-standard-passes\", llvm::cl::init(false),\n    llvm::cl::desc(\"Do not run standard passes (default false)\"),\n    llvm::cl::Hidden);\n\n// FIXME: llvm::cl::opt<uint64_t> doesn't work it acts like a bool\n// option.\nllvm::cl::opt<unsigned long long>\n    Seed(\"seed\", llvm::cl::init(1),\n         llvm::cl::desc(\"Seed for random number generator (default: 1)\"));\n\nenum RedirectOutputTy {\n  WHEN_NOT_VERBOSE, // Legacy\n  REDIRECT,\n  NO_REDIRECT,\n};\n\n// FIXME: These don't really belong here\nllvm::cl::opt<RedirectOutputTy> ClangOutputRedirect(\n    \"redirect-clang-output\",\n    llvm::cl::values(\n        clEnumValN(WHEN_NOT_VERBOSE, \"nv\",\n                   \"Redirect when not in verbose output mode (default)\"),\n        clEnumValN(REDIRECT, \"1\", \"Redirect Clang output\"),\n        clEnumValN(NO_REDIRECT, \"0\", \"Do not redirect Clang output\")),\n    llvm::cl::init(WHEN_NOT_VERBOSE),\n    llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\nllvm::cl::opt<RedirectOutputTy> LibFuzzerOutputRedirect(\n    \"redirect-libfuzzer-output\",\n    llvm::cl::values(\n        clEnumValN(WHEN_NOT_VERBOSE, \"nv\",\n                   \"Redirect when not in verbose output mode (default)\"),\n        clEnumValN(REDIRECT, \"1\", \"Redirect LibFuzzer output\"),\n        clEnumValN(NO_REDIRECT, \"0\", \"Do not redirect LibFuzzer output\")),\n    llvm::cl::init(WHEN_NOT_VERBOSE),\n    llvm::cl::cat(jfs::cxxfb::cl::CommandLineCategory));\n\nenum BackendTy {\n  DUMMY_FUZZING_SOLVER,\n  Z3_SOLVER,\n  CXX_FUZZING_SOLVER,\n};\n\nllvm::cl::opt<BackendTy> SolverBackend(\n    llvm::cl::desc(\"Solver backend\"),\n    llvm::cl::values(clEnumValN(DUMMY_FUZZING_SOLVER, \"dummy\", \"dummy solver\"),\n                     clEnumValN(Z3_SOLVER, \"z3\", \"Z3 backend\"),\n                     clEnumValN(CXX_FUZZING_SOLVER, \"cxx\",\n                                \"CXX fuzzing backend (default)\")),\n    llvm::cl::init(CXX_FUZZING_SOLVER));\n\nllvm::cl::opt<bool>\n    GetModel(\"get-model\", llvm::cl::init(false),\n             llvm::cl::desc(\"If sat report the found model (default false)\"));\n\nllvm::cl::opt<bool> ValidateModel(\n    \"validate-model\", llvm::cl::init(false),\n    llvm::cl::desc(\n        \"Validate model if one is found (default false). Implies -get-model\"),\n    llvm::cl::ZeroOrMore);\n\n// This is a hidden option meant for testing the model saving functionality by\n// ensuring that loading and saving models round trips as expected.\nllvm::cl::opt<bool>\n    DebugSaveModel(\"debug-save-model\", llvm::cl::init(false),\n                   llvm::cl::desc(\"Save model to disk if one is found (default \"\n                                  \"false). Implies -get-model\"),\n                   llvm::cl::Hidden);\n} // namespace\n\nbool shouldRequestModel() {\n  return GetModel || ValidateModel || DebugSaveModel;\n}\n\nvoid printVersion(llvm::raw_ostream& os) {\n  os << support::getVersionString() << \"\\n\";\n  os << \"\\n\";\n  llvm::cl::PrintVersionMessage();\n  return;\n}\n\nstd::unique_ptr<jfs::fuzzingCommon::WorkingDirectoryManager>\nmakeWorkingDirectory(JFSContext& ctx) {\n  if (OutputDirectory.size() > 0) {\n    // Use user specified path for working directory\n    return jfs::fuzzingCommon::WorkingDirectoryManager::makeAtPath(\n        OutputDirectory, ctx, !KeepOutputDirectory);\n  }\n  // Use the current working directory as the base directory\n  // and use as a prefix the name of the query.\n  llvm::SmallVector<char, 256> currentDir;\n  if (auto ec = llvm::sys::fs::current_path(currentDir)) {\n    ctx.getErrorStream()\n        << \"(error failed to get current working directory because \"\n        << ec.message() << \")\\n\";\n    exit(1);\n  }\n  llvm::StringRef currentDirAsStringRef(currentDir.data(), currentDir.size());\n  llvm::StringRef prefix;\n  if (InputFilename == \"-\") {\n    prefix = \"stdin\";\n  } else {\n    // Not on standard input so get the name\n    prefix = llvm::sys::path::filename(InputFilename);\n  }\n  return jfs::fuzzingCommon::WorkingDirectoryManager::makeInDirectory(\n      /*directory=*/currentDirAsStringRef, /*prefix=*/prefix, ctx,\n      !KeepOutputDirectory);\n}\n\nbool shouldRedirectOutput(RedirectOutputTy rot, JFSContext& ctx) {\n  switch (rot) {\n  case WHEN_NOT_VERBOSE: {\n    if (ctx.getVerbosity() > 0) {\n      return false;\n    }\n    return true;\n  }\n  case REDIRECT:\n    return true;\n  case NO_REDIRECT:\n    return false;\n  default:\n    llvm_unreachable(\"Unhandled RedirectOutputTy\");\n  }\n}\n\nstd::unique_ptr<Solver>\nmakeSolver(JFSContext& ctx,\n           std::unique_ptr<jfs::fuzzingCommon::WorkingDirectoryManager> wdm,\n           llvm::StringRef pathToExecutable) {\n  std::unique_ptr<Solver> solver;\n  switch (SolverBackend) {\n  case DUMMY_FUZZING_SOLVER: {\n    std::unique_ptr<SolverOptions> solverOptions(new SolverOptions());\n    solver.reset(new jfs::fuzzingCommon::DummyFuzzingSolver(\n        std::move(solverOptions), std::move(wdm), ctx));\n    break;\n  }\n  case Z3_SOLVER: {\n    std::unique_ptr<SolverOptions> solverOptions(new SolverOptions());\n    solver.reset(new jfs::z3Backend::Z3Solver(std::move(solverOptions), ctx));\n    break;\n  }\n  case CXX_FUZZING_SOLVER: {\n    // Tell ClangOptions to try and infer all paths\n    auto clangOptions =\n        jfs::cxxfb::cl::buildClangOptionsFromCmdLine(pathToExecutable);\n    IF_VERB(ctx, clangOptions->print(ctx.getDebugStream()));\n\n    auto seedManagerOpts =\n        jfs::fuzzingCommon::cl::buildSeedManagerOptionsFromCmdLine();\n\n    auto libFuzzerOptions =\n        jfs::fuzzingCommon::cl::buildLibFuzzerOptionsFromCmdLine();\n\n    auto cxxProgramBuilderOptions =\n        jfs::cxxfb::cl::buildCXXProgramBuilderOptionsFromCmdLine();\n\n    auto freeVariableToBufferAssignmentPassOptions =\n        jfs::fuzzingCommon::cl::buildFVTBAPOptionsFromCmdLine();\n\n    std::unique_ptr<jfs::cxxfb::CXXFuzzingSolverOptions> solverOptions(\n        new jfs::cxxfb::CXXFuzzingSolverOptions(\n            std::move(freeVariableToBufferAssignmentPassOptions),\n            std::move(clangOptions), std::move(libFuzzerOptions),\n            std::move(cxxProgramBuilderOptions), std::move(seedManagerOpts),\n            DebugSaveModel));\n    // Decide if the clang/LibFuzzer stdout/stderr should be redirected\n    solverOptions->redirectClangOutput =\n        shouldRedirectOutput(ClangOutputRedirect, ctx);\n    solverOptions->redirectLibFuzzerOutput =\n        shouldRedirectOutput(LibFuzzerOutputRedirect, ctx);\n\n    solver.reset(new jfs::cxxfb::CXXFuzzingSolver(std::move(solverOptions),\n                                                  std::move(wdm), ctx));\n    break;\n  }\n  default:\n    llvm_unreachable(\"unknown solver backend\");\n  }\n  return solver;\n}\n\nstd::function<void(void)> cancelFn;\n\nvoid handleInterrupt() {\n  if (cancelFn)\n    cancelFn();\n}\n\nint main(int argc, char** argv) {\n  llvm::cl::SetVersionPrinter(printVersion);\n  llvm::cl::ParseCommandLineOptions(argc, argv);\n\n  // Create context\n  JFSContextConfig ctxCfg;\n  ctxCfg.verbosity = Verbosity;\n  ctxCfg.gathericStatistics = (StatsFilename != \"\");\n  ctxCfg.seed = Seed;\n\n  JFSContext ctx(ctxCfg);\n  ToolErrorHandler toolHandler(/*ignoreCanceled*/ true);\n  ScopedJFSContextErrorHandler errorHandler(ctx, &toolHandler);\n\n  std::unique_ptr<llvm::raw_fd_ostream> sfStorage;\n  llvm::raw_ostream* sf = nullptr;\n  if (StatsFilename != \"\") {\n    // Open stats file early so we fail early if it can't be opened\n    std::error_code ec;\n    if (StatsFilename == \"-\") {\n      // We have to handle stdout specially. We use `outs()` which means\n      // we can't also create a separate llvm::raw_fd_ostream() otherwise\n      // we'll close the file twice.\n      sf = &(llvm::outs());\n    } else {\n      sfStorage.reset(\n          new llvm::raw_fd_ostream(StatsFilename, ec, llvm::sys::fs::F_Excl));\n      if (ec) {\n        ctx.getErrorStream()\n            << jfs::support::getMessageForFailedOpenFileForWriting(\n                   StatsFilename, ec);\n        return 1;\n      }\n      sf = sfStorage.get();\n    }\n  }\n\n  // Create parser\n  SMTLIB2Parser parser(ctx);\n\n  // Create pass manager\n  QueryPassManager pm;\n\n  // Create working directory and solver\n  std::string pathToExecutable = llvm::sys::fs::getMainExecutable(\n      argv[0], reinterpret_cast<void*>(reinterpret_cast<intptr_t>(main)));\n  std::unique_ptr<Solver> solver(\n      makeSolver(ctx, makeWorkingDirectory(ctx), pathToExecutable));\n\n  // Now set up cancel/interrupt handlers. We do this now so that all the\n  // objects we need to interact with at cancellation time can be captured in\n  // lambda.\n  std::atomic<bool> parsingDone(false);\n  cancelFn = [&parsingDone, &solver, &pm, &ctx]() {\n    // Actions to perform if cancellation is requested\n    IF_VERB(ctx, ctx.getDebugStream() << \"(cancelling)\\n\");\n    if (!parsingDone) {\n      // HACK: We can't interrupt parsing so we have to just\n      // do a best effort here and try to exit cleanly.\n      // FIXME: We need to clean up the empty working directory.\n      llvm::outs() << \"unknown\\n\";\n      exit(0);\n    }\n    pm.cancel();\n    solver->cancel();\n  };\n\n  // Setup interrupt handler. This basically just calls\n  // cancelFn.\n  llvm::sys::SetInterruptFunction(handleInterrupt);\n\n  // Apply timeout\n  jfs::support::ScopedTimer timer(MaxTime, [&ctx]() {\n    IF_VERB(ctx, ctx.getDebugStream() << \"(timeout)\\n\");\n    cancelFn();\n  });\n\n  // Parse query\n  std::shared_ptr<Query> query;\n  IF_VERB(ctx, ctx.getDebugStream() << \"(Parser starting)\\n\");\n  {\n    JFS_SM_TIMER(parse_query, ctx);\n    auto bufferOrError = llvm::MemoryBuffer::getFileOrSTDIN(InputFilename);\n    if (auto error = bufferOrError.getError()) {\n      ctx.getErrorStream() << jfs::support::getMessageForFailedOpenFileOrSTDIN(\n          InputFilename, error);\n      return 1;\n    }\n    auto buffer(std::move(bufferOrError.get()));\n    // NOTE: the ToolErrorHandler will deal with parsing errors.\n    query = parser.parseMemoryBuffer(std::move(buffer));\n  }\n  parsingDone = true;\n  IF_VERB(ctx, ctx.getDebugStream() << \"(Parser finished)\\n\");\n  std::unique_ptr<Query> originalQuery;\n  if (ValidateModel) {\n    // When we perform model validation we should do so with respect\n    // to the original query. The query gets modified in place by the\n    // passes so we have to make a copy.\n    originalQuery.reset(new Query(*query));\n  }\n  if (Verbosity > 10)\n    ctx.getDebugStream() << *query;\n\n  // FIXME: We need a better way to control this on the command line, like\n  // we can do with `jfs-opt`.\n  // Run standard transformations\n  if (!DisableStandardPasses) {\n    AddStandardPasses(pm);\n    pm.run(*query);\n    if (Verbosity > 10)\n      ctx.getDebugStream() << *query;\n  }\n\n  if (Verbosity > 0)\n    ctx.getDebugStream() << \"(using solver \\\"\" << solver->getName() << \"\\\")\\n\";\n\n  int toolExitCode = 0;\n  auto response = solver->solve(*query, /*produceModel=*/shouldRequestModel());\n  llvm::outs() << SolverResponse::getSatString(response->sat) << \"\\n\";\n  if (Verbosity > 0) {\n    ctx.getDebugStream() << \"(\" << solver->getName() << \" responded with \"\n                         << SolverResponse::getSatString(response->sat)\n                         << \")\\n\";\n  }\n\n  if (response->sat == SolverResponse::SAT && shouldRequestModel()) {\n    // Print the found model\n    auto model = response->getModel();\n    if (model) {\n      // Convert the model if necessary so it satifies the constraints\n      // originally given.\n      bool convertModelSuccess = pm.convertModel(model);\n      if (!convertModelSuccess) {\n        ctx.raiseFatalError(\"Failed to convert model\");\n      }\n      ModelPrintOptions mpo;\n      // Sort the declarations so they are listed in a deterministic order.\n      mpo.sortDecls = true;\n      llvm::outs() << model->getSMTLIBString(&mpo) << \"\\n\";\n\n      // Validate model if requested\n      if (ValidateModel) {\n        assert(originalQuery.get() != nullptr);\n        ModelValidator validator;\n        ModelValidationOptions mvo;\n        mvo.warnOnVariablesMissingAssignment = true;\n        validator.validate(*originalQuery, model, &mvo);\n        if (validator.getNumberOfFailures() > 0) {\n          ctx.getErrorStream() << \"(error model validation failed:\\n\"\n                               << validator.toStr() << \"\\n)\";\n          toolExitCode = 1;\n        } else {\n          IF_VERB(ctx, ctx.getDebugStream()\n                           << \"(model validation succeeded)\\n\");\n        }\n      }\n    } else {\n      // Don't bail out here because we may want to still record stats.\n      ctx.getErrorStream() << \"(error Failed to get model)\\n\";\n      toolExitCode = 1;\n    }\n  }\n\n  // Write statistics out\n  if (StatsFilename != \"\") {\n    assert(sf != nullptr);\n    if (Verbosity > 0) {\n      ctx.getDebugStream() << \"(writing stats to \\\"\" << StatsFilename\n                           << \"\\\")\\n\";\n    }\n    ctx.getStats()->printYAML(*sf);\n    sf->flush();\n  }\n  return toolExitCode;\n}\n"
  },
  {
    "path": "tools/jfs-opt/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\nadd_executable(jfs-opt\n  main.cpp\n)\n\n# Needed for command line support\njfs_get_llvm_components(llvm_components support)\n\ntarget_link_libraries(\n  jfs-opt\n  PRIVATE\n  ${llvm_components}\n  JFSSupport\n  JFSCore\n  JFSTransform\n)\n\n"
  },
  {
    "path": "tools/jfs-opt/main.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Core/SMTLIB2Parser.h\"\n#include \"jfs/Core/ScopedJFSContextErrorHandler.h\"\n#include \"jfs/Core/ToolErrorHandler.h\"\n#include \"jfs/Support/ErrorMessages.h\"\n#include \"jfs/Support/version.h\"\n#include \"jfs/Transform/Passes.h\"\n#include \"jfs/Transform/QueryPassManager.h\"\n#include \"jfs/Transform/StandardPasses.h\"\n#include \"llvm/Support/CommandLine.h\"\n#include \"llvm/Support/FileSystem.h\"\n#include \"llvm/Support/MemoryBuffer.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <string>\n\nusing namespace jfs;\nusing namespace jfs::core;\nusing namespace jfs::transform;\n\nnamespace {\nllvm::cl::opt<std::string> InputFilename(llvm::cl::Positional,\n                                         llvm::cl::desc(\"<input file>\"),\n                                         llvm::cl::init(\"-\"));\nllvm::cl::opt<unsigned> Verbosity(\"v\", llvm::cl::desc(\"Verbosity level\"),\n                                  llvm::cl::init(0));\n\nllvm::cl::opt<bool>\n    PrintBefore(\"print-before\",\n                llvm::cl::desc(\"Print query before running passes\"),\n                llvm::cl::init(0));\n\nllvm::cl::opt<std::string>\n    OutputFile(\"o\", llvm::cl::desc(\"Output file (default stdout)\"),\n               llvm::cl::init(\"-\"));\n\n// FIXME: Implement a PassRegistry like LLVM does so we don't\n// have to manually list these\nenum QueryPassTy {\n  and_hoist,\n  simplify,\n  duplicate_constraint_elimination,\n  true_constraint_elimination,\n  simple_contradictions_to_false,\n  constant_propagation,\n  bv_bound_propagation,\n  standard_passes,\n};\nllvm::cl::list<QueryPassTy> PassList(\n    llvm::cl::desc(\"Available passes:\"),\n    llvm::cl::values(clEnumValN(and_hoist, \"and-hoist\", \"And hoisting\"),\n                     clEnumVal(simplify, \"Simplify\"),\n                     clEnumValN(duplicate_constraint_elimination, \"dce\",\n                                \"duplicate constraint elimination\"),\n                     clEnumValN(true_constraint_elimination, \"tce\",\n                                \"true constraint elimination\"),\n                     clEnumValN(simple_contradictions_to_false, \"sctf\",\n                                \"simple contradictions to false\"),\n                     clEnumValN(constant_propagation, \"constant-propagation\",\n                                \"constant propagation\"),\n                     clEnumValN(bv_bound_propagation, \"bv-bound-propagation\",\n                                \"Bitvector bound propagation\"),\n                     clEnumValN(standard_passes, \"standard-passes\",\n                                \"Run all standard passes\")));\n\n// FIXME: Don't do this manually\nunsigned AddPasses(QueryPassManager &pm) {\n  unsigned count = 0;\n  for (unsigned index = 0; index < PassList.size(); ++index) {\n    QueryPassTy passTy = PassList[index];\n    ++count;\n    switch (passTy) {\n    case and_hoist:\n      pm.add(std::make_shared<AndHoistingPass>());\n      break;\n    case simplify:\n      pm.add(std::make_shared<SimplificationPass>());\n      break;\n    case duplicate_constraint_elimination:\n      pm.add(std::make_shared<DuplicateConstraintEliminationPass>());\n      break;\n    case true_constraint_elimination:\n      pm.add(std::make_shared<TrueConstraintEliminationPass>());\n      break;\n    case simple_contradictions_to_false:\n      pm.add(std::make_shared<SimpleContradictionsToFalsePass>());\n      break;\n    case constant_propagation:\n      pm.add(std::make_shared<ConstantPropagationPass>());\n      break;\n    case bv_bound_propagation:\n      pm.add(std::make_shared<BvBoundPropagationPass>());\n      break;\n    case standard_passes:\n      // This isn't really a single pass\n      jfs::transform::AddStandardPasses(pm);\n      break;\n    default:\n      llvm_unreachable(\"Unknown pass\");\n    }\n  }\n  return count;\n}\n\nvoid printVersion(llvm::raw_ostream& os) {\n  os << support::getVersionString() << \"\\n\";\n  os << \"\\n\";\n  llvm::cl::PrintVersionMessage();\n  return;\n}\n\n}\n\nint main(int argc, char **argv) {\n  llvm::cl::SetVersionPrinter(printVersion);\n  llvm::cl::ParseCommandLineOptions(argc, argv);\n\n  JFSContextConfig ctxCfg;\n  ctxCfg.verbosity = Verbosity;\n  JFSContext ctx(ctxCfg);\n  auto bufferOrError = llvm::MemoryBuffer::getFileOrSTDIN(InputFilename);\n  if (auto error = bufferOrError.getError()) {\n    ctx.getErrorStream() << jfs::support::getMessageForFailedOpenFileOrSTDIN(\n        InputFilename, error);\n    return 1;\n  }\n  auto buffer(std::move(bufferOrError.get()));\n\n  ToolErrorHandler toolHandler(/*ignoredCanceled=*/false);\n  ScopedJFSContextErrorHandler errorHandler(ctx, &toolHandler);\n  SMTLIB2Parser parser(ctx);\n  auto query = parser.parseMemoryBuffer(std::move(buffer));\n\n  std::error_code ec;\n  llvm::raw_fd_ostream output(OutputFile, ec, llvm::sys::fs::F_Excl);\n  if (ec) {\n    ctx.getErrorStream() << jfs::support::getMessageForFailedOpenFileForWriting(\n        OutputFile, ec);\n    return 1;\n  }\n\n  // Run standard transformations\n  QueryPassManager pm;\n\n  unsigned count = AddPasses(pm);\n  if (Verbosity > 0)\n    ctx.getDebugStream() << \"; Added \" << count << \" passes\\n\";\n  if (PrintBefore)\n    output << *query;\n  pm.run(*query);\n  output << *query;\n  output.close();\n  return 0;\n}\n"
  },
  {
    "path": "tools/jfs-smt2cnf/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2018 J. Ryan Stinnett\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\nadd_executable(jfs-smt2cnf\n  main.cpp\n)\n\n# Needed for command line support\njfs_get_llvm_components(llvm_components support)\n\ntarget_link_libraries(\n  jfs-smt2cnf\n  PRIVATE\n  ${llvm_components}\n  JFSSupport\n  JFSCXXFuzzingBackendCmdLine\n  JFSCXXFuzzingBackend\n  JFSFuzzingCommonCmdLine\n)\n"
  },
  {
    "path": "tools/jfs-smt2cnf/main.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2018 J. Ryan Stinnett\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#include \"jfs/Core/IfVerbose.h\"\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Core/SMTLIB2Parser.h\"\n#include \"jfs/Core/ScopedJFSContextErrorHandler.h\"\n#include \"jfs/Core/ToolErrorHandler.h\"\n#include \"jfs/Core/Z3NodeSet.h\"\n#include \"jfs/FuzzingCommon/FuzzingAnalysisInfo.h\"\n#include \"jfs/Support/ErrorMessages.h\"\n#include \"jfs/Support/version.h\"\n#include \"jfs/Transform/BitBlastPass.h\"\n#include \"jfs/Transform/DIMACSOutputPass.h\"\n#include \"jfs/Transform/FpToBvPass.h\"\n#include \"jfs/Transform/SimplificationPass.h\"\n#include \"jfs/Transform/StandardPasses.h\"\n#include \"jfs/Transform/QueryPassManager.h\"\n#include \"llvm/Support/CommandLine.h\"\n#include \"llvm/Support/MemoryBuffer.h\"\n#include <string>\n\nusing namespace jfs::core;\nusing namespace jfs::fuzzingCommon;\nusing namespace jfs::transform;\n\nnamespace {\nllvm::cl::opt<std::string> InputFilename(llvm::cl::Positional,\n                                         llvm::cl::desc(\"<input file>\"),\n                                         llvm::cl::init(\"-\"));\nllvm::cl::opt<unsigned> Verbosity(\"v\", llvm::cl::desc(\"Verbosity level\"),\n                                  llvm::cl::init(0));\n\nvoid printVersion(llvm::raw_ostream& os) {\n  os << jfs::support::getVersionString() << \"\\n\";\n  os << \"\\n\";\n  llvm::cl::PrintVersionMessage();\n  return;\n}\n}\n\nint main(int argc, char** argv) {\n  llvm::cl::SetVersionPrinter(printVersion);\n  llvm::cl::ParseCommandLineOptions(argc, argv);\n\n  JFSContextConfig ctxCfg;\n  ctxCfg.verbosity = Verbosity;\n  JFSContext ctx(ctxCfg);\n  auto bufferOrError = llvm::MemoryBuffer::getFileOrSTDIN(InputFilename);\n  if (auto error = bufferOrError.getError()) {\n    ctx.getErrorStream() << jfs::support::getMessageForFailedOpenFileOrSTDIN(\n        InputFilename, error);\n    return 1;\n  }\n  auto buffer(std::move(bufferOrError.get()));\n\n  ToolErrorHandler toolHandler(/*ignoredCanceled=*/false);\n  ScopedJFSContextErrorHandler errorHandler(ctx, &toolHandler);\n  SMTLIB2Parser parser(ctx);\n  auto query = parser.parseMemoryBuffer(std::move(buffer));\n\n  QueryPassManager pm;\n\n  // Add passes that JFS would normally apply before handing off to the fuzzer\n  AddStandardPasses(pm);\n  auto fai = std::make_shared<FuzzingAnalysisInfo>(nullptr);\n  // NOTE: One of the passes added in this step is\n  // FreeVariableToBufferAssignmentPass which isn't actually required here, but\n  // it does allow us to sanity check the count of booleans with the size of the\n  // buffer JFS would create.\n  fai->addTo(pm);\n\n  // Convert to bit vectors, then to booleans, and output in DIMACS CNF format\n  pm.add(std::make_shared<FpToBvPass>());\n  pm.add(std::make_shared<SimplificationPass>());\n  pm.add(std::make_shared<BitBlastPass>());\n  pm.add(std::make_shared<SimplificationPass>());\n  // FIXME: Run this logic internally so we can control output rather than\n  // relying on Z3's behavior.\n  pm.add(std::make_shared<DIMACSOutputPass>());\n  pm.run(*query);\n\n  // Number of boolean variables should match JFS buffer size in bits\n  jfs::core::Z3FuncDeclSet variables;\n  query->collectFuncDecls(variables);\n  auto variablesSize = variables.size();\n  auto bits = fai->freeVariableAssignment->bufferAssignment->getTypeBitWidth();\n  // NOTE: We can't check for a simple equality here because JFS might represent\n  // an FP variable by its full bit width in the fuzzing buffer, while the\n  // bit-blasted version may be able to simplify away some bits leaving less\n  // variables.\n  if (variablesSize > bits) {\n    ctx.getWarningStream()\n        << \"(warning \" << variablesSize << \" SAT variables larger than \" << bits\n        << \" bits in fuzzing buffer)\\n\";\n  }\n\n  IF_VERB(ctx, ctx.getDebugStream()\n      << \"(\" << bits << \" fuzzing bits, \" << variablesSize << \" variables, 2^\"\n      << variablesSize << \" possible assignments)\");\n\n  return 0;\n}\n"
  },
  {
    "path": "tools/jfs-smt2cxx/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\nadd_executable(jfs-smt2cxx\n  main.cpp\n)\n\n# Needed for command line support\njfs_get_llvm_components(llvm_components support)\n\ntarget_link_libraries(\n  jfs-smt2cxx\n  PRIVATE\n  ${llvm_components}\n  JFSSupport\n  JFSCXXFuzzingBackendCmdLine\n  JFSCXXFuzzingBackend\n  JFSFuzzingCommonCmdLine\n)\n"
  },
  {
    "path": "tools/jfs-smt2cxx/main.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n\n#include \"jfs/CXXFuzzingBackend/CXXProgram.h\"\n#include \"jfs/CXXFuzzingBackend/CXXProgramBuilderPass.h\"\n#include \"jfs/CXXFuzzingBackend/CmdLine/CXXProgramBuilderOptionsBuilder.h\"\n#include \"jfs/Core/JFSContext.h\"\n#include \"jfs/Core/SMTLIB2Parser.h\"\n#include \"jfs/Core/ScopedJFSContextErrorHandler.h\"\n#include \"jfs/Core/ToolErrorHandler.h\"\n#include \"jfs/FuzzingCommon/CmdLine/FreeVariableToBufferAssignmentPassOptionsBuilder.h\"\n#include \"jfs/FuzzingCommon/FuzzingAnalysisInfo.h\"\n#include \"jfs/Support/ErrorMessages.h\"\n#include \"jfs/Support/version.h\"\n#include \"jfs/Transform/QueryPassManager.h\"\n#include \"llvm/Support/CommandLine.h\"\n#include \"llvm/Support/FileSystem.h\"\n#include \"llvm/Support/MemoryBuffer.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <string>\n\nusing namespace jfs::core;\nusing namespace jfs::transform;\nusing namespace jfs::cxxfb;\nusing namespace jfs::fuzzingCommon;\n\nnamespace {\nllvm::cl::opt<std::string> InputFilename(llvm::cl::Positional,\n                                         llvm::cl::desc(\"<input file>\"),\n                                         llvm::cl::init(\"-\"));\nllvm::cl::opt<unsigned> Verbosity(\"v\", llvm::cl::desc(\"Verbosity level\"),\n                                  llvm::cl::init(0));\n\nllvm::cl::opt<std::string>\n    OutputFile(\"o\", llvm::cl::desc(\"Output file (default stdout)\"),\n               llvm::cl::init(\"-\"));\n\nvoid printVersion(llvm::raw_ostream& os) {\n  os << jfs::support::getVersionString() << \"\\n\";\n  os << \"\\n\";\n  llvm::cl::PrintVersionMessage();\n  return;\n}\n}\n\nint main(int argc, char** argv) {\n  llvm::cl::SetVersionPrinter(printVersion);\n  llvm::cl::ParseCommandLineOptions(argc, argv);\n\n  JFSContextConfig ctxCfg;\n  ctxCfg.verbosity = Verbosity;\n  JFSContext ctx(ctxCfg);\n  auto bufferOrError = llvm::MemoryBuffer::getFileOrSTDIN(InputFilename);\n  if (auto error = bufferOrError.getError()) {\n    ctx.getErrorStream() << jfs::support::getMessageForFailedOpenFileOrSTDIN(\n        InputFilename, error);\n    return 1;\n  }\n  auto buffer(std::move(bufferOrError.get()));\n\n  ToolErrorHandler toolHandler(/*ignoredCanceled=*/false);\n  ScopedJFSContextErrorHandler errorHandler(ctx, &toolHandler);\n  SMTLIB2Parser parser(ctx);\n  auto query = parser.parseMemoryBuffer(std::move(buffer));\n\n  std::error_code ec;\n  llvm::raw_fd_ostream output(OutputFile, ec, llvm::sys::fs::F_Excl);\n  if (ec) {\n    ctx.getErrorStream() << jfs::support::getMessageForFailedOpenFileForWriting(\n        OutputFile, ec);\n    return 1;\n  }\n\n  QueryPassManager pm;\n  auto fvtbap = jfs::fuzzingCommon::cl::buildFVTBAPOptionsFromCmdLine();\n  auto info = std::make_shared<FuzzingAnalysisInfo>(fvtbap.get());\n  info->addTo(pm);\n  auto cxxProgramBuilderOptions =\n      jfs::cxxfb::cl::buildCXXProgramBuilderOptionsFromCmdLine();\n  auto programBuilder = std::make_shared<CXXProgramBuilderPass>(\n      info, cxxProgramBuilderOptions.get(), ctx);\n  pm.add(programBuilder);\n  pm.run(*query);\n\n  // Print the CXX program\n  programBuilder->getProgram()->print(output);\n  return 0;\n}\n"
  },
  {
    "path": "tools/yaml-syntax-check/CMakeLists.txt",
    "content": "\n#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\nadd_executable(yaml-syntax-check\n  main.cpp\n)\n\n# Needed for command line support\njfs_get_llvm_components(llvm_components support)\ntarget_link_libraries(yaml-syntax-check\n  PRIVATE\n  ${llvm_components}\n  JFSSupport # HACK: Not really needed but this will give us the compiler flags\n)\n"
  },
  {
    "path": "tools/yaml-syntax-check/main.cpp",
    "content": "//===----------------------------------------------------------------------===//\n//\n//                                     JFS\n//\n// Copyright 2017-2018 Daniel Liew\n//\n// This file is distributed under the MIT license.\n// See LICENSE.txt for details.\n//\n//===----------------------------------------------------------------------===//\n#include \"jfs/Support/ErrorMessages.h\"\n#include \"llvm/Support/CommandLine.h\"\n#include \"llvm/Support/FileSystem.h\"\n#include \"llvm/Support/MemoryBuffer.h\"\n#include \"llvm/Support/SourceMgr.h\"\n#include \"llvm/Support/YAMLParser.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <string>\n\nnamespace {\nllvm::cl::opt<std::string> InputFilename(llvm::cl::Positional,\n                                         llvm::cl::desc(\"<input file>\"),\n                                         llvm::cl::init(\"-\"));\n}\n\nint main(int argc, char** argv) {\n  llvm::cl::ParseCommandLineOptions(argc, argv,\n                                    \"Check file has valid YAML syntax\");\n  auto bufferOrError = llvm::MemoryBuffer::getFileOrSTDIN(InputFilename);\n  if (auto error = bufferOrError.getError()) {\n    llvm::errs() << jfs::support::getMessageForFailedOpenFileOrSTDIN(\n        InputFilename, error);\n    return 1;\n  }\n  auto buffer(std::move(bufferOrError.get()));\n  auto mbr = buffer->getMemBufferRef();\n  llvm::SourceMgr sm;\n  std::error_code ec;\n  llvm::yaml::Stream yamlStream(mbr, sm);\n  if (ec) {\n    llvm::errs() << \"Failed to open stream because \" << ec.message() << \"\\n\";\n    return 1;\n  }\n  return yamlStream.validate() ? 0 : 1;\n}\n"
  },
  {
    "path": "utils/CMakeLists.txt",
    "content": "#===------------------------------------------------------------------------===#\n#\n#                                      JFS\n#\n# Copyright 2017-2018 Daniel Liew\n#\n# This file is distributed under the MIT license.\n# See LICENSE.txt for details.\n#\n#===------------------------------------------------------------------------===#\n\n###############################################################################\n# Build LLVM testing tools\n###############################################################################\nadd_subdirectory(FileCheck)\nadd_subdirectory(not)\n\n###############################################################################\n# Build GTest\n###############################################################################\nadd_subdirectory(\n  \"${GTEST_SRC_DIR}\"\n  \"${CMAKE_BINARY_DIR}/utils/googletest\"\n)\n"
  },
  {
    "path": "utils/FileCheck/CMakeLists.txt",
    "content": "add_executable(FileCheck\n  FileCheck.cpp\n)\njfs_get_llvm_components(FILECHECK_NEEDED_LIBS Support)\ntarget_include_directories(FileCheck PRIVATE ${JFS_COMPONENT_EXTRA_INCLUDE_DIRS})\ntarget_compile_options(FileCheck PRIVATE ${JFS_COMPONENT_CXX_FLAGS})\ntarget_compile_definitions(FileCheck PRIVATE ${JFS_COMPONENT_CXX_DEFINES})\ntarget_link_libraries(FileCheck PRIVATE ${FILECHECK_NEEDED_LIBS})\n"
  },
  {
    "path": "utils/FileCheck/FileCheck.cpp",
    "content": "//===- FileCheck.cpp - Check that File's Contents match what is expected --===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n//\n// FileCheck does a line-by line check of a file that validates whether it\n// contains the expected content.  This is useful for regression tests etc.\n//\n// This program exits with an error status of 2 on error, exit status of 0 if\n// the file matched the expected contents, and exit status of 1 if it did not\n// contain the expected contents.\n//\n//===----------------------------------------------------------------------===//\n\n#include \"llvm/ADT/SmallString.h\"\n#include \"llvm/ADT/StringExtras.h\"\n#include \"llvm/ADT/StringMap.h\"\n#include \"llvm/ADT/StringSet.h\"\n#include \"llvm/Support/CommandLine.h\"\n#include \"llvm/Support/MemoryBuffer.h\"\n#include \"llvm/Support/PrettyStackTrace.h\"\n#include \"llvm/Support/Regex.h\"\n#include \"llvm/Support/Signals.h\"\n#include \"llvm/Support/SourceMgr.h\"\n#include \"llvm/Support/raw_ostream.h\"\n#include <algorithm>\n#include <cctype>\n#include <map>\n#include <string>\n#include <system_error>\n#include <vector>\nusing namespace llvm;\n\nstatic cl::opt<std::string>\n    CheckFilename(cl::Positional, cl::desc(\"<check-file>\"), cl::Required);\n\nstatic cl::opt<std::string>\n    InputFilename(\"input-file\", cl::desc(\"File to check (defaults to stdin)\"),\n                  cl::init(\"-\"), cl::value_desc(\"filename\"));\n\nstatic cl::list<std::string> CheckPrefixes(\n    \"check-prefix\",\n    cl::desc(\"Prefix to use from check file (defaults to 'CHECK')\"));\nstatic cl::alias CheckPrefixesAlias(\n    \"check-prefixes\", cl::aliasopt(CheckPrefixes), cl::CommaSeparated,\n    cl::NotHidden,\n    cl::desc(\n        \"Alias for -check-prefix permitting multiple comma separated values\"));\n\nstatic cl::opt<bool> NoCanonicalizeWhiteSpace(\n    \"strict-whitespace\",\n    cl::desc(\"Do not treat all horizontal whitespace as equivalent\"));\n\nstatic cl::list<std::string> ImplicitCheckNot(\n    \"implicit-check-not\",\n    cl::desc(\"Add an implicit negative check with this pattern to every\\n\"\n             \"positive check. This can be used to ensure that no instances of\\n\"\n             \"this pattern occur which are not matched by a positive pattern\"),\n    cl::value_desc(\"pattern\"));\n\nstatic cl::opt<bool> AllowEmptyInput(\n    \"allow-empty\", cl::init(false),\n    cl::desc(\"Allow the input file to be empty. This is useful when making\\n\"\n             \"checks that some error message does not occur, for example.\"));\n\nstatic cl::opt<bool> MatchFullLines(\n    \"match-full-lines\", cl::init(false),\n    cl::desc(\"Require all positive matches to cover an entire input line.\\n\"\n             \"Allows leading and trailing whitespace if --strict-whitespace\\n\"\n             \"is not also passed.\"));\n\ntypedef cl::list<std::string>::const_iterator prefix_iterator;\n\n//===----------------------------------------------------------------------===//\n// Pattern Handling Code.\n//===----------------------------------------------------------------------===//\n\nnamespace Check {\nenum CheckType {\n  CheckNone = 0,\n  CheckPlain,\n  CheckNext,\n  CheckSame,\n  CheckNot,\n  CheckDAG,\n  CheckLabel,\n\n  /// Indicates the pattern only matches the end of file. This is used for\n  /// trailing CHECK-NOTs.\n  CheckEOF,\n\n  /// Marks when parsing found a -NOT check combined with another CHECK suffix.\n  CheckBadNot\n};\n}\n\nclass Pattern {\n  SMLoc PatternLoc;\n\n  /// A fixed string to match as the pattern or empty if this pattern requires\n  /// a regex match.\n  StringRef FixedStr;\n\n  /// A regex string to match as the pattern or empty if this pattern requires\n  /// a fixed string to match.\n  std::string RegExStr;\n\n  /// Entries in this vector map to uses of a variable in the pattern, e.g.\n  /// \"foo[[bar]]baz\".  In this case, the RegExStr will contain \"foobaz\" and\n  /// we'll get an entry in this vector that tells us to insert the value of\n  /// bar at offset 3.\n  std::vector<std::pair<StringRef, unsigned>> VariableUses;\n\n  /// Maps definitions of variables to their parenthesized capture numbers.\n  /// \n  /// E.g. for the pattern \"foo[[bar:.*]]baz\", VariableDefs will map \"bar\" to\n  /// 1.\n  std::map<StringRef, unsigned> VariableDefs;\n\n  Check::CheckType CheckTy;\n\n  /// Contains the number of line this pattern is in.\n  unsigned LineNumber;\n\npublic:\n  explicit Pattern(Check::CheckType Ty) : CheckTy(Ty) {}\n\n  /// Returns the location in source code.\n  SMLoc getLoc() const { return PatternLoc; }\n\n  bool ParsePattern(StringRef PatternStr, StringRef Prefix, SourceMgr &SM,\n                    unsigned LineNumber);\n  size_t Match(StringRef Buffer, size_t &MatchLen,\n               StringMap<StringRef> &VariableTable) const;\n  void PrintFailureInfo(const SourceMgr &SM, StringRef Buffer,\n                        const StringMap<StringRef> &VariableTable) const;\n\n  bool hasVariable() const {\n    return !(VariableUses.empty() && VariableDefs.empty());\n  }\n\n  Check::CheckType getCheckTy() const { return CheckTy; }\n\nprivate:\n  bool AddRegExToRegEx(StringRef RS, unsigned &CurParen, SourceMgr &SM);\n  void AddBackrefToRegEx(unsigned BackrefNum);\n  unsigned\n  ComputeMatchDistance(StringRef Buffer,\n                       const StringMap<StringRef> &VariableTable) const;\n  bool EvaluateExpression(StringRef Expr, std::string &Value) const;\n  size_t FindRegexVarEnd(StringRef Str, SourceMgr &SM);\n};\n\n/// Parses the given string into the Pattern.\n///\n/// \\p Prefix provides which prefix is being matched, \\p SM provides the\n/// SourceMgr used for error reports, and \\p LineNumber is the line number in\n/// the input file from which the pattern string was read. Returns true in\n/// case of an error, false otherwise.\nbool Pattern::ParsePattern(StringRef PatternStr, StringRef Prefix,\n                           SourceMgr &SM, unsigned LineNumber) {\n  bool MatchFullLinesHere = MatchFullLines && CheckTy != Check::CheckNot;\n\n  this->LineNumber = LineNumber;\n  PatternLoc = SMLoc::getFromPointer(PatternStr.data());\n\n  if (!(NoCanonicalizeWhiteSpace && MatchFullLines))\n    // Ignore trailing whitespace.\n    while (!PatternStr.empty() &&\n           (PatternStr.back() == ' ' || PatternStr.back() == '\\t'))\n      PatternStr = PatternStr.substr(0, PatternStr.size() - 1);\n\n  // Check that there is something on the line.\n  if (PatternStr.empty()) {\n    SM.PrintMessage(PatternLoc, SourceMgr::DK_Error,\n                    \"found empty check string with prefix '\" + Prefix + \":'\");\n    return true;\n  }\n\n  // Check to see if this is a fixed string, or if it has regex pieces.\n  if (!MatchFullLinesHere &&\n      (PatternStr.size() < 2 || (PatternStr.find(\"{{\") == StringRef::npos &&\n                                 PatternStr.find(\"[[\") == StringRef::npos))) {\n    FixedStr = PatternStr;\n    return false;\n  }\n\n  if (MatchFullLinesHere) {\n    RegExStr += '^';\n    if (!NoCanonicalizeWhiteSpace)\n      RegExStr += \" *\";\n  }\n\n  // Paren value #0 is for the fully matched string.  Any new parenthesized\n  // values add from there.\n  unsigned CurParen = 1;\n\n  // Otherwise, there is at least one regex piece.  Build up the regex pattern\n  // by escaping scary characters in fixed strings, building up one big regex.\n  while (!PatternStr.empty()) {\n    // RegEx matches.\n    if (PatternStr.startswith(\"{{\")) {\n      // This is the start of a regex match.  Scan for the }}.\n      size_t End = PatternStr.find(\"}}\");\n      if (End == StringRef::npos) {\n        SM.PrintMessage(SMLoc::getFromPointer(PatternStr.data()),\n                        SourceMgr::DK_Error,\n                        \"found start of regex string with no end '}}'\");\n        return true;\n      }\n\n      // Enclose {{}} patterns in parens just like [[]] even though we're not\n      // capturing the result for any purpose.  This is required in case the\n      // expression contains an alternation like: CHECK:  abc{{x|z}}def.  We\n      // want this to turn into: \"abc(x|z)def\" not \"abcx|zdef\".\n      RegExStr += '(';\n      ++CurParen;\n\n      if (AddRegExToRegEx(PatternStr.substr(2, End - 2), CurParen, SM))\n        return true;\n      RegExStr += ')';\n\n      PatternStr = PatternStr.substr(End + 2);\n      continue;\n    }\n\n    // Named RegEx matches.  These are of two forms: [[foo:.*]] which matches .*\n    // (or some other regex) and assigns it to the FileCheck variable 'foo'. The\n    // second form is [[foo]] which is a reference to foo.  The variable name\n    // itself must be of the form \"[a-zA-Z_][0-9a-zA-Z_]*\", otherwise we reject\n    // it.  This is to catch some common errors.\n    if (PatternStr.startswith(\"[[\")) {\n      // Find the closing bracket pair ending the match.  End is going to be an\n      // offset relative to the beginning of the match string.\n      size_t End = FindRegexVarEnd(PatternStr.substr(2), SM);\n\n      if (End == StringRef::npos) {\n        SM.PrintMessage(SMLoc::getFromPointer(PatternStr.data()),\n                        SourceMgr::DK_Error,\n                        \"invalid named regex reference, no ]] found\");\n        return true;\n      }\n\n      StringRef MatchStr = PatternStr.substr(2, End);\n      PatternStr = PatternStr.substr(End + 4);\n\n      // Get the regex name (e.g. \"foo\").\n      size_t NameEnd = MatchStr.find(':');\n      StringRef Name = MatchStr.substr(0, NameEnd);\n\n      if (Name.empty()) {\n        SM.PrintMessage(SMLoc::getFromPointer(Name.data()), SourceMgr::DK_Error,\n                        \"invalid name in named regex: empty name\");\n        return true;\n      }\n\n      // Verify that the name/expression is well formed. FileCheck currently\n      // supports @LINE, @LINE+number, @LINE-number expressions. The check here\n      // is relaxed, more strict check is performed in \\c EvaluateExpression.\n      bool IsExpression = false;\n      for (unsigned i = 0, e = Name.size(); i != e; ++i) {\n        if (i == 0 && Name[i] == '@') {\n          if (NameEnd != StringRef::npos) {\n            SM.PrintMessage(SMLoc::getFromPointer(Name.data()),\n                            SourceMgr::DK_Error,\n                            \"invalid name in named regex definition\");\n            return true;\n          }\n          IsExpression = true;\n          continue;\n        }\n        if (Name[i] != '_' && !isalnum(Name[i]) &&\n            (!IsExpression || (Name[i] != '+' && Name[i] != '-'))) {\n          SM.PrintMessage(SMLoc::getFromPointer(Name.data() + i),\n                          SourceMgr::DK_Error, \"invalid name in named regex\");\n          return true;\n        }\n      }\n\n      // Name can't start with a digit.\n      if (isdigit(static_cast<unsigned char>(Name[0]))) {\n        SM.PrintMessage(SMLoc::getFromPointer(Name.data()), SourceMgr::DK_Error,\n                        \"invalid name in named regex\");\n        return true;\n      }\n\n      // Handle [[foo]].\n      if (NameEnd == StringRef::npos) {\n        // Handle variables that were defined earlier on the same line by\n        // emitting a backreference.\n        if (VariableDefs.find(Name) != VariableDefs.end()) {\n          unsigned VarParenNum = VariableDefs[Name];\n          if (VarParenNum < 1 || VarParenNum > 9) {\n            SM.PrintMessage(SMLoc::getFromPointer(Name.data()),\n                            SourceMgr::DK_Error,\n                            \"Can't back-reference more than 9 variables\");\n            return true;\n          }\n          AddBackrefToRegEx(VarParenNum);\n        } else {\n          VariableUses.push_back(std::make_pair(Name, RegExStr.size()));\n        }\n        continue;\n      }\n\n      // Handle [[foo:.*]].\n      VariableDefs[Name] = CurParen;\n      RegExStr += '(';\n      ++CurParen;\n\n      if (AddRegExToRegEx(MatchStr.substr(NameEnd + 1), CurParen, SM))\n        return true;\n\n      RegExStr += ')';\n    }\n\n    // Handle fixed string matches.\n    // Find the end, which is the start of the next regex.\n    size_t FixedMatchEnd = PatternStr.find(\"{{\");\n    FixedMatchEnd = std::min(FixedMatchEnd, PatternStr.find(\"[[\"));\n    RegExStr += Regex::escape(PatternStr.substr(0, FixedMatchEnd));\n    PatternStr = PatternStr.substr(FixedMatchEnd);\n  }\n\n  if (MatchFullLinesHere) {\n    if (!NoCanonicalizeWhiteSpace)\n      RegExStr += \" *\";\n    RegExStr += '$';\n  }\n\n  return false;\n}\n\nbool Pattern::AddRegExToRegEx(StringRef RS, unsigned &CurParen, SourceMgr &SM) {\n  Regex R(RS);\n  std::string Error;\n  if (!R.isValid(Error)) {\n    SM.PrintMessage(SMLoc::getFromPointer(RS.data()), SourceMgr::DK_Error,\n                    \"invalid regex: \" + Error);\n    return true;\n  }\n\n  RegExStr += RS.str();\n  CurParen += R.getNumMatches();\n  return false;\n}\n\nvoid Pattern::AddBackrefToRegEx(unsigned BackrefNum) {\n  assert(BackrefNum >= 1 && BackrefNum <= 9 && \"Invalid backref number\");\n  std::string Backref = std::string(\"\\\\\") + std::string(1, '0' + BackrefNum);\n  RegExStr += Backref;\n}\n\n/// Evaluates expression and stores the result to \\p Value.\n///\n/// Returns true on success and false when the expression has invalid syntax.\nbool Pattern::EvaluateExpression(StringRef Expr, std::string &Value) const {\n  // The only supported expression is @LINE([\\+-]\\d+)?\n  if (!Expr.startswith(\"@LINE\"))\n    return false;\n  Expr = Expr.substr(StringRef(\"@LINE\").size());\n  int Offset = 0;\n  if (!Expr.empty()) {\n    if (Expr[0] == '+')\n      Expr = Expr.substr(1);\n    else if (Expr[0] != '-')\n      return false;\n    if (Expr.getAsInteger(10, Offset))\n      return false;\n  }\n  Value = llvm::itostr(LineNumber + Offset);\n  return true;\n}\n\n/// Matches the pattern string against the input buffer \\p Buffer\n///\n/// This returns the position that is matched or npos if there is no match. If\n/// there is a match, the size of the matched string is returned in \\p\n/// MatchLen.\n///\n/// The \\p VariableTable StringMap provides the current values of filecheck\n/// variables and is updated if this match defines new values.\nsize_t Pattern::Match(StringRef Buffer, size_t &MatchLen,\n                      StringMap<StringRef> &VariableTable) const {\n  // If this is the EOF pattern, match it immediately.\n  if (CheckTy == Check::CheckEOF) {\n    MatchLen = 0;\n    return Buffer.size();\n  }\n\n  // If this is a fixed string pattern, just match it now.\n  if (!FixedStr.empty()) {\n    MatchLen = FixedStr.size();\n    return Buffer.find(FixedStr);\n  }\n\n  // Regex match.\n\n  // If there are variable uses, we need to create a temporary string with the\n  // actual value.\n  StringRef RegExToMatch = RegExStr;\n  std::string TmpStr;\n  if (!VariableUses.empty()) {\n    TmpStr = RegExStr;\n\n    unsigned InsertOffset = 0;\n    for (const auto &VariableUse : VariableUses) {\n      std::string Value;\n\n      if (VariableUse.first[0] == '@') {\n        if (!EvaluateExpression(VariableUse.first, Value))\n          return StringRef::npos;\n      } else {\n        StringMap<StringRef>::iterator it =\n            VariableTable.find(VariableUse.first);\n        // If the variable is undefined, return an error.\n        if (it == VariableTable.end())\n          return StringRef::npos;\n\n        // Look up the value and escape it so that we can put it into the regex.\n        Value += Regex::escape(it->second);\n      }\n\n      // Plop it into the regex at the adjusted offset.\n      TmpStr.insert(TmpStr.begin() + VariableUse.second + InsertOffset,\n                    Value.begin(), Value.end());\n      InsertOffset += Value.size();\n    }\n\n    // Match the newly constructed regex.\n    RegExToMatch = TmpStr;\n  }\n\n  SmallVector<StringRef, 4> MatchInfo;\n  if (!Regex(RegExToMatch, Regex::Newline).match(Buffer, &MatchInfo))\n    return StringRef::npos;\n\n  // Successful regex match.\n  assert(!MatchInfo.empty() && \"Didn't get any match\");\n  StringRef FullMatch = MatchInfo[0];\n\n  // If this defines any variables, remember their values.\n  for (const auto &VariableDef : VariableDefs) {\n    assert(VariableDef.second < MatchInfo.size() && \"Internal paren error\");\n    VariableTable[VariableDef.first] = MatchInfo[VariableDef.second];\n  }\n\n  MatchLen = FullMatch.size();\n  return FullMatch.data() - Buffer.data();\n}\n\n\n/// Computes an arbitrary estimate for the quality of matching this pattern at\n/// the start of \\p Buffer; a distance of zero should correspond to a perfect\n/// match.\nunsigned\nPattern::ComputeMatchDistance(StringRef Buffer,\n                              const StringMap<StringRef> &VariableTable) const {\n  // Just compute the number of matching characters. For regular expressions, we\n  // just compare against the regex itself and hope for the best.\n  //\n  // FIXME: One easy improvement here is have the regex lib generate a single\n  // example regular expression which matches, and use that as the example\n  // string.\n  StringRef ExampleString(FixedStr);\n  if (ExampleString.empty())\n    ExampleString = RegExStr;\n\n  // Only compare up to the first line in the buffer, or the string size.\n  StringRef BufferPrefix = Buffer.substr(0, ExampleString.size());\n  BufferPrefix = BufferPrefix.split('\\n').first;\n  return BufferPrefix.edit_distance(ExampleString);\n}\n\n/// Prints additional information about a failure to match involving this\n/// pattern.\nvoid Pattern::PrintFailureInfo(\n    const SourceMgr &SM, StringRef Buffer,\n    const StringMap<StringRef> &VariableTable) const {\n  // If this was a regular expression using variables, print the current\n  // variable values.\n  if (!VariableUses.empty()) {\n    for (const auto &VariableUse : VariableUses) {\n      SmallString<256> Msg;\n      raw_svector_ostream OS(Msg);\n      StringRef Var = VariableUse.first;\n      if (Var[0] == '@') {\n        std::string Value;\n        if (EvaluateExpression(Var, Value)) {\n          OS << \"with expression \\\"\";\n          OS.write_escaped(Var) << \"\\\" equal to \\\"\";\n          OS.write_escaped(Value) << \"\\\"\";\n        } else {\n          OS << \"uses incorrect expression \\\"\";\n          OS.write_escaped(Var) << \"\\\"\";\n        }\n      } else {\n        StringMap<StringRef>::const_iterator it = VariableTable.find(Var);\n\n        // Check for undefined variable references.\n        if (it == VariableTable.end()) {\n          OS << \"uses undefined variable \\\"\";\n          OS.write_escaped(Var) << \"\\\"\";\n        } else {\n          OS << \"with variable \\\"\";\n          OS.write_escaped(Var) << \"\\\" equal to \\\"\";\n          OS.write_escaped(it->second) << \"\\\"\";\n        }\n      }\n\n      SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), SourceMgr::DK_Note,\n                      OS.str());\n    }\n  }\n\n  // Attempt to find the closest/best fuzzy match.  Usually an error happens\n  // because some string in the output didn't exactly match. In these cases, we\n  // would like to show the user a best guess at what \"should have\" matched, to\n  // save them having to actually check the input manually.\n  size_t NumLinesForward = 0;\n  size_t Best = StringRef::npos;\n  double BestQuality = 0;\n\n  // Use an arbitrary 4k limit on how far we will search.\n  for (size_t i = 0, e = std::min(size_t(4096), Buffer.size()); i != e; ++i) {\n    if (Buffer[i] == '\\n')\n      ++NumLinesForward;\n\n    // Patterns have leading whitespace stripped, so skip whitespace when\n    // looking for something which looks like a pattern.\n    if (Buffer[i] == ' ' || Buffer[i] == '\\t')\n      continue;\n\n    // Compute the \"quality\" of this match as an arbitrary combination of the\n    // match distance and the number of lines skipped to get to this match.\n    unsigned Distance = ComputeMatchDistance(Buffer.substr(i), VariableTable);\n    double Quality = Distance + (NumLinesForward / 100.);\n\n    if (Quality < BestQuality || Best == StringRef::npos) {\n      Best = i;\n      BestQuality = Quality;\n    }\n  }\n\n  // Print the \"possible intended match here\" line if we found something\n  // reasonable and not equal to what we showed in the \"scanning from here\"\n  // line.\n  if (Best && Best != StringRef::npos && BestQuality < 50) {\n    SM.PrintMessage(SMLoc::getFromPointer(Buffer.data() + Best),\n                    SourceMgr::DK_Note, \"possible intended match here\");\n\n    // FIXME: If we wanted to be really friendly we would show why the match\n    // failed, as it can be hard to spot simple one character differences.\n  }\n}\n\n/// Finds the closing sequence of a regex variable usage or definition.\n///\n/// \\p Str has to point in the beginning of the definition (right after the\n/// opening sequence). Returns the offset of the closing sequence within Str,\n/// or npos if it was not found.\nsize_t Pattern::FindRegexVarEnd(StringRef Str, SourceMgr &SM) {\n  // Offset keeps track of the current offset within the input Str\n  size_t Offset = 0;\n  // [...] Nesting depth\n  size_t BracketDepth = 0;\n\n  while (!Str.empty()) {\n    if (Str.startswith(\"]]\") && BracketDepth == 0)\n      return Offset;\n    if (Str[0] == '\\\\') {\n      // Backslash escapes the next char within regexes, so skip them both.\n      Str = Str.substr(2);\n      Offset += 2;\n    } else {\n      switch (Str[0]) {\n      default:\n        break;\n      case '[':\n        BracketDepth++;\n        break;\n      case ']':\n        if (BracketDepth == 0) {\n          SM.PrintMessage(SMLoc::getFromPointer(Str.data()),\n                          SourceMgr::DK_Error,\n                          \"missing closing \\\"]\\\" for regex variable\");\n          exit(1);\n        }\n        BracketDepth--;\n        break;\n      }\n      Str = Str.substr(1);\n      Offset++;\n    }\n  }\n\n  return StringRef::npos;\n}\n\n//===----------------------------------------------------------------------===//\n// Check Strings.\n//===----------------------------------------------------------------------===//\n\n/// A check that we found in the input file.\nstruct CheckString {\n  /// The pattern to match.\n  Pattern Pat;\n\n  /// Which prefix name this check matched.\n  StringRef Prefix;\n\n  /// The location in the match file that the check string was specified.\n  SMLoc Loc;\n\n  /// All of the strings that are disallowed from occurring between this match\n  /// string and the previous one (or start of file).\n  std::vector<Pattern> DagNotStrings;\n\n  CheckString(const Pattern &P, StringRef S, SMLoc L)\n      : Pat(P), Prefix(S), Loc(L) {}\n\n  size_t Check(const SourceMgr &SM, StringRef Buffer, bool IsLabelScanMode,\n               size_t &MatchLen, StringMap<StringRef> &VariableTable) const;\n\n  bool CheckNext(const SourceMgr &SM, StringRef Buffer) const;\n  bool CheckSame(const SourceMgr &SM, StringRef Buffer) const;\n  bool CheckNot(const SourceMgr &SM, StringRef Buffer,\n                const std::vector<const Pattern *> &NotStrings,\n                StringMap<StringRef> &VariableTable) const;\n  size_t CheckDag(const SourceMgr &SM, StringRef Buffer,\n                  std::vector<const Pattern *> &NotStrings,\n                  StringMap<StringRef> &VariableTable) const;\n};\n\n/// Canonicalize whitespaces in the file. Line endings are replaced with\n/// UNIX-style '\\n'.\nstatic StringRef CanonicalizeFile(MemoryBuffer &MB,\n                                  SmallVectorImpl<char> &OutputBuffer) {\n  OutputBuffer.reserve(MB.getBufferSize());\n\n  for (const char *Ptr = MB.getBufferStart(), *End = MB.getBufferEnd();\n       Ptr != End; ++Ptr) {\n    // Eliminate trailing dosish \\r.\n    if (Ptr <= End - 2 && Ptr[0] == '\\r' && Ptr[1] == '\\n') {\n      continue;\n    }\n\n    // If current char is not a horizontal whitespace or if horizontal\n    // whitespace canonicalization is disabled, dump it to output as is.\n    if (NoCanonicalizeWhiteSpace || (*Ptr != ' ' && *Ptr != '\\t')) {\n      OutputBuffer.push_back(*Ptr);\n      continue;\n    }\n\n    // Otherwise, add one space and advance over neighboring space.\n    OutputBuffer.push_back(' ');\n    while (Ptr + 1 != End && (Ptr[1] == ' ' || Ptr[1] == '\\t'))\n      ++Ptr;\n  }\n\n  // Add a null byte and then return all but that byte.\n  OutputBuffer.push_back('\\0');\n  return StringRef(OutputBuffer.data(), OutputBuffer.size() - 1);\n}\n\nstatic bool IsPartOfWord(char c) {\n  return (isalnum(c) || c == '-' || c == '_');\n}\n\n// Get the size of the prefix extension.\nstatic size_t CheckTypeSize(Check::CheckType Ty) {\n  switch (Ty) {\n  case Check::CheckNone:\n  case Check::CheckBadNot:\n    return 0;\n\n  case Check::CheckPlain:\n    return sizeof(\":\") - 1;\n\n  case Check::CheckNext:\n    return sizeof(\"-NEXT:\") - 1;\n\n  case Check::CheckSame:\n    return sizeof(\"-SAME:\") - 1;\n\n  case Check::CheckNot:\n    return sizeof(\"-NOT:\") - 1;\n\n  case Check::CheckDAG:\n    return sizeof(\"-DAG:\") - 1;\n\n  case Check::CheckLabel:\n    return sizeof(\"-LABEL:\") - 1;\n\n  case Check::CheckEOF:\n    llvm_unreachable(\"Should not be using EOF size\");\n  }\n\n  llvm_unreachable(\"Bad check type\");\n}\n\nstatic Check::CheckType FindCheckType(StringRef Buffer, StringRef Prefix) {\n  char NextChar = Buffer[Prefix.size()];\n\n  // Verify that the : is present after the prefix.\n  if (NextChar == ':')\n    return Check::CheckPlain;\n\n  if (NextChar != '-')\n    return Check::CheckNone;\n\n  StringRef Rest = Buffer.drop_front(Prefix.size() + 1);\n  if (Rest.startswith(\"NEXT:\"))\n    return Check::CheckNext;\n\n  if (Rest.startswith(\"SAME:\"))\n    return Check::CheckSame;\n\n  if (Rest.startswith(\"NOT:\"))\n    return Check::CheckNot;\n\n  if (Rest.startswith(\"DAG:\"))\n    return Check::CheckDAG;\n\n  if (Rest.startswith(\"LABEL:\"))\n    return Check::CheckLabel;\n\n  // You can't combine -NOT with another suffix.\n  if (Rest.startswith(\"DAG-NOT:\") || Rest.startswith(\"NOT-DAG:\") ||\n      Rest.startswith(\"NEXT-NOT:\") || Rest.startswith(\"NOT-NEXT:\") ||\n      Rest.startswith(\"SAME-NOT:\") || Rest.startswith(\"NOT-SAME:\"))\n    return Check::CheckBadNot;\n\n  return Check::CheckNone;\n}\n\n// From the given position, find the next character after the word.\nstatic size_t SkipWord(StringRef Str, size_t Loc) {\n  while (Loc < Str.size() && IsPartOfWord(Str[Loc]))\n    ++Loc;\n  return Loc;\n}\n\n/// Search the buffer for the first prefix in the prefix regular expression.\n///\n/// This searches the buffer using the provided regular expression, however it\n/// enforces constraints beyond that:\n/// 1) The found prefix must not be a suffix of something that looks like\n///    a valid prefix.\n/// 2) The found prefix must be followed by a valid check type suffix using \\c\n///    FindCheckType above.\n///\n/// The first match of the regular expression to satisfy these two is returned,\n/// otherwise an empty StringRef is returned to indicate failure.\n///\n/// If this routine returns a valid prefix, it will also shrink \\p Buffer to\n/// start at the beginning of the returned prefix, increment \\p LineNumber for\n/// each new line consumed from \\p Buffer, and set \\p CheckTy to the type of\n/// check found by examining the suffix.\n///\n/// If no valid prefix is found, the state of Buffer, LineNumber, and CheckTy\n/// is unspecified.\nstatic StringRef FindFirstMatchingPrefix(Regex &PrefixRE, StringRef &Buffer,\n                                         unsigned &LineNumber,\n                                         Check::CheckType &CheckTy) {\n  SmallVector<StringRef, 2> Matches;\n\n  while (!Buffer.empty()) {\n    // Find the first (longest) match using the RE.\n    if (!PrefixRE.match(Buffer, &Matches))\n      // No match at all, bail.\n      return StringRef();\n\n    StringRef Prefix = Matches[0];\n    Matches.clear();\n\n    assert(Prefix.data() >= Buffer.data() &&\n           Prefix.data() < Buffer.data() + Buffer.size() &&\n           \"Prefix doesn't start inside of buffer!\");\n    size_t Loc = Prefix.data() - Buffer.data();\n    StringRef Skipped = Buffer.substr(0, Loc);\n    Buffer = Buffer.drop_front(Loc);\n    LineNumber += Skipped.count('\\n');\n\n    // Check that the matched prefix isn't a suffix of some other check-like\n    // word.\n    // FIXME: This is a very ad-hoc check. it would be better handled in some\n    // other way. Among other things it seems hard to distinguish between\n    // intentional and unintentional uses of this feature.\n    if (Skipped.empty() || !IsPartOfWord(Skipped.back())) {\n      // Now extract the type.\n      CheckTy = FindCheckType(Buffer, Prefix);\n\n      // If we've found a valid check type for this prefix, we're done.\n      if (CheckTy != Check::CheckNone)\n        return Prefix;\n    }\n\n    // If we didn't successfully find a prefix, we need to skip this invalid\n    // prefix and continue scanning. We directly skip the prefix that was\n    // matched and any additional parts of that check-like word.\n    Buffer = Buffer.drop_front(SkipWord(Buffer, Prefix.size()));\n  }\n\n  // We ran out of buffer while skipping partial matches so give up.\n  return StringRef();\n}\n\n/// Read the check file, which specifies the sequence of expected strings.\n///\n/// The strings are added to the CheckStrings vector. Returns true in case of\n/// an error, false otherwise.\nstatic bool ReadCheckFile(SourceMgr &SM, StringRef Buffer, Regex &PrefixRE,\n                          std::vector<CheckString> &CheckStrings) {\n  std::vector<Pattern> ImplicitNegativeChecks;\n  for (const auto &PatternString : ImplicitCheckNot) {\n    // Create a buffer with fake command line content in order to display the\n    // command line option responsible for the specific implicit CHECK-NOT.\n    std::string Prefix = (Twine(\"-\") + ImplicitCheckNot.ArgStr + \"='\").str();\n    std::string Suffix = \"'\";\n    std::unique_ptr<MemoryBuffer> CmdLine = MemoryBuffer::getMemBufferCopy(\n        Prefix + PatternString + Suffix, \"command line\");\n\n    StringRef PatternInBuffer =\n        CmdLine->getBuffer().substr(Prefix.size(), PatternString.size());\n    SM.AddNewSourceBuffer(std::move(CmdLine), SMLoc());\n\n    ImplicitNegativeChecks.push_back(Pattern(Check::CheckNot));\n    ImplicitNegativeChecks.back().ParsePattern(PatternInBuffer,\n                                               \"IMPLICIT-CHECK\", SM, 0);\n  }\n\n  std::vector<Pattern> DagNotMatches = ImplicitNegativeChecks;\n\n  // LineNumber keeps track of the line on which CheckPrefix instances are\n  // found.\n  unsigned LineNumber = 1;\n\n  while (1) {\n    Check::CheckType CheckTy;\n\n    // See if a prefix occurs in the memory buffer.\n    StringRef UsedPrefix = FindFirstMatchingPrefix(PrefixRE, Buffer, LineNumber,\n                                                   CheckTy);\n    if (UsedPrefix.empty())\n      break;\n    assert(UsedPrefix.data() == Buffer.data() &&\n           \"Failed to move Buffer's start forward, or pointed prefix outside \"\n           \"of the buffer!\");\n\n    // Location to use for error messages.\n    const char *UsedPrefixStart = UsedPrefix.data();\n\n    // Skip the buffer to the end.\n    Buffer = Buffer.drop_front(UsedPrefix.size() + CheckTypeSize(CheckTy));\n\n    // Complain about useful-looking but unsupported suffixes.\n    if (CheckTy == Check::CheckBadNot) {\n      SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), SourceMgr::DK_Error,\n                      \"unsupported -NOT combo on prefix '\" + UsedPrefix + \"'\");\n      return true;\n    }\n\n    // Okay, we found the prefix, yay. Remember the rest of the line, but ignore\n    // leading whitespace.\n    if (!(NoCanonicalizeWhiteSpace && MatchFullLines))\n      Buffer = Buffer.substr(Buffer.find_first_not_of(\" \\t\"));\n\n    // Scan ahead to the end of line.\n    size_t EOL = Buffer.find_first_of(\"\\n\\r\");\n\n    // Remember the location of the start of the pattern, for diagnostics.\n    SMLoc PatternLoc = SMLoc::getFromPointer(Buffer.data());\n\n    // Parse the pattern.\n    Pattern P(CheckTy);\n    if (P.ParsePattern(Buffer.substr(0, EOL), UsedPrefix, SM, LineNumber))\n      return true;\n\n    // Verify that CHECK-LABEL lines do not define or use variables\n    if ((CheckTy == Check::CheckLabel) && P.hasVariable()) {\n      SM.PrintMessage(\n          SMLoc::getFromPointer(UsedPrefixStart), SourceMgr::DK_Error,\n          \"found '\" + UsedPrefix + \"-LABEL:'\"\n                                   \" with variable definition or use\");\n      return true;\n    }\n\n    Buffer = Buffer.substr(EOL);\n\n    // Verify that CHECK-NEXT lines have at least one CHECK line before them.\n    if ((CheckTy == Check::CheckNext || CheckTy == Check::CheckSame) &&\n        CheckStrings.empty()) {\n      StringRef Type = CheckTy == Check::CheckNext ? \"NEXT\" : \"SAME\";\n      SM.PrintMessage(SMLoc::getFromPointer(UsedPrefixStart),\n                      SourceMgr::DK_Error,\n                      \"found '\" + UsedPrefix + \"-\" + Type +\n                          \"' without previous '\" + UsedPrefix + \": line\");\n      return true;\n    }\n\n    // Handle CHECK-DAG/-NOT.\n    if (CheckTy == Check::CheckDAG || CheckTy == Check::CheckNot) {\n      DagNotMatches.push_back(P);\n      continue;\n    }\n\n    // Okay, add the string we captured to the output vector and move on.\n    CheckStrings.emplace_back(P, UsedPrefix, PatternLoc);\n    std::swap(DagNotMatches, CheckStrings.back().DagNotStrings);\n    DagNotMatches = ImplicitNegativeChecks;\n  }\n\n  // Add an EOF pattern for any trailing CHECK-DAG/-NOTs, and use the first\n  // prefix as a filler for the error message.\n  if (!DagNotMatches.empty()) {\n    CheckStrings.emplace_back(Pattern(Check::CheckEOF), *CheckPrefixes.begin(),\n                              SMLoc::getFromPointer(Buffer.data()));\n    std::swap(DagNotMatches, CheckStrings.back().DagNotStrings);\n  }\n\n  if (CheckStrings.empty()) {\n    errs() << \"error: no check strings found with prefix\"\n           << (CheckPrefixes.size() > 1 ? \"es \" : \" \");\n    prefix_iterator I = CheckPrefixes.begin();\n    prefix_iterator E = CheckPrefixes.end();\n    if (I != E) {\n      errs() << \"\\'\" << *I << \":'\";\n      ++I;\n    }\n    for (; I != E; ++I)\n      errs() << \", \\'\" << *I << \":'\";\n\n    errs() << '\\n';\n    return true;\n  }\n\n  return false;\n}\n\nstatic void PrintCheckFailed(const SourceMgr &SM, SMLoc Loc, const Pattern &Pat,\n                             StringRef Buffer,\n                             StringMap<StringRef> &VariableTable) {\n  // Otherwise, we have an error, emit an error message.\n  SM.PrintMessage(Loc, SourceMgr::DK_Error,\n                  \"expected string not found in input\");\n\n  // Print the \"scanning from here\" line.  If the current position is at the\n  // end of a line, advance to the start of the next line.\n  Buffer = Buffer.substr(Buffer.find_first_not_of(\" \\t\\n\\r\"));\n\n  SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), SourceMgr::DK_Note,\n                  \"scanning from here\");\n\n  // Allow the pattern to print additional information if desired.\n  Pat.PrintFailureInfo(SM, Buffer, VariableTable);\n}\n\nstatic void PrintCheckFailed(const SourceMgr &SM, const CheckString &CheckStr,\n                             StringRef Buffer,\n                             StringMap<StringRef> &VariableTable) {\n  PrintCheckFailed(SM, CheckStr.Loc, CheckStr.Pat, Buffer, VariableTable);\n}\n\n/// Count the number of newlines in the specified range.\nstatic unsigned CountNumNewlinesBetween(StringRef Range,\n                                        const char *&FirstNewLine) {\n  unsigned NumNewLines = 0;\n  while (1) {\n    // Scan for newline.\n    Range = Range.substr(Range.find_first_of(\"\\n\\r\"));\n    if (Range.empty())\n      return NumNewLines;\n\n    ++NumNewLines;\n\n    // Handle \\n\\r and \\r\\n as a single newline.\n    if (Range.size() > 1 && (Range[1] == '\\n' || Range[1] == '\\r') &&\n        (Range[0] != Range[1]))\n      Range = Range.substr(1);\n    Range = Range.substr(1);\n\n    if (NumNewLines == 1)\n      FirstNewLine = Range.begin();\n  }\n}\n\n/// Match check string and its \"not strings\" and/or \"dag strings\".\nsize_t CheckString::Check(const SourceMgr &SM, StringRef Buffer,\n                          bool IsLabelScanMode, size_t &MatchLen,\n                          StringMap<StringRef> &VariableTable) const {\n  size_t LastPos = 0;\n  std::vector<const Pattern *> NotStrings;\n\n  // IsLabelScanMode is true when we are scanning forward to find CHECK-LABEL\n  // bounds; we have not processed variable definitions within the bounded block\n  // yet so cannot handle any final CHECK-DAG yet; this is handled when going\n  // over the block again (including the last CHECK-LABEL) in normal mode.\n  if (!IsLabelScanMode) {\n    // Match \"dag strings\" (with mixed \"not strings\" if any).\n    LastPos = CheckDag(SM, Buffer, NotStrings, VariableTable);\n    if (LastPos == StringRef::npos)\n      return StringRef::npos;\n  }\n\n  // Match itself from the last position after matching CHECK-DAG.\n  StringRef MatchBuffer = Buffer.substr(LastPos);\n  size_t MatchPos = Pat.Match(MatchBuffer, MatchLen, VariableTable);\n  if (MatchPos == StringRef::npos) {\n    PrintCheckFailed(SM, *this, MatchBuffer, VariableTable);\n    return StringRef::npos;\n  }\n\n  // Similar to the above, in \"label-scan mode\" we can't yet handle CHECK-NEXT\n  // or CHECK-NOT\n  if (!IsLabelScanMode) {\n    StringRef SkippedRegion = Buffer.substr(LastPos, MatchPos);\n\n    // If this check is a \"CHECK-NEXT\", verify that the previous match was on\n    // the previous line (i.e. that there is one newline between them).\n    if (CheckNext(SM, SkippedRegion))\n      return StringRef::npos;\n\n    // If this check is a \"CHECK-SAME\", verify that the previous match was on\n    // the same line (i.e. that there is no newline between them).\n    if (CheckSame(SM, SkippedRegion))\n      return StringRef::npos;\n\n    // If this match had \"not strings\", verify that they don't exist in the\n    // skipped region.\n    if (CheckNot(SM, SkippedRegion, NotStrings, VariableTable))\n      return StringRef::npos;\n  }\n\n  return LastPos + MatchPos;\n}\n\n/// Verify there is a single line in the given buffer.\nbool CheckString::CheckNext(const SourceMgr &SM, StringRef Buffer) const {\n  if (Pat.getCheckTy() != Check::CheckNext)\n    return false;\n\n  // Count the number of newlines between the previous match and this one.\n  assert(Buffer.data() !=\n             SM.getMemoryBuffer(SM.FindBufferContainingLoc(\n                                    SMLoc::getFromPointer(Buffer.data())))\n                 ->getBufferStart() &&\n         \"CHECK-NEXT can't be the first check in a file\");\n\n  const char *FirstNewLine = nullptr;\n  unsigned NumNewLines = CountNumNewlinesBetween(Buffer, FirstNewLine);\n\n  if (NumNewLines == 0) {\n    SM.PrintMessage(Loc, SourceMgr::DK_Error,\n                    Prefix + \"-NEXT: is on the same line as previous match\");\n    SM.PrintMessage(SMLoc::getFromPointer(Buffer.end()), SourceMgr::DK_Note,\n                    \"'next' match was here\");\n    SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), SourceMgr::DK_Note,\n                    \"previous match ended here\");\n    return true;\n  }\n\n  if (NumNewLines != 1) {\n    SM.PrintMessage(Loc, SourceMgr::DK_Error,\n                    Prefix +\n                        \"-NEXT: is not on the line after the previous match\");\n    SM.PrintMessage(SMLoc::getFromPointer(Buffer.end()), SourceMgr::DK_Note,\n                    \"'next' match was here\");\n    SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), SourceMgr::DK_Note,\n                    \"previous match ended here\");\n    SM.PrintMessage(SMLoc::getFromPointer(FirstNewLine), SourceMgr::DK_Note,\n                    \"non-matching line after previous match is here\");\n    return true;\n  }\n\n  return false;\n}\n\n/// Verify there is no newline in the given buffer.\nbool CheckString::CheckSame(const SourceMgr &SM, StringRef Buffer) const {\n  if (Pat.getCheckTy() != Check::CheckSame)\n    return false;\n\n  // Count the number of newlines between the previous match and this one.\n  assert(Buffer.data() !=\n             SM.getMemoryBuffer(SM.FindBufferContainingLoc(\n                                    SMLoc::getFromPointer(Buffer.data())))\n                 ->getBufferStart() &&\n         \"CHECK-SAME can't be the first check in a file\");\n\n  const char *FirstNewLine = nullptr;\n  unsigned NumNewLines = CountNumNewlinesBetween(Buffer, FirstNewLine);\n\n  if (NumNewLines != 0) {\n    SM.PrintMessage(Loc, SourceMgr::DK_Error,\n                    Prefix +\n                        \"-SAME: is not on the same line as the previous match\");\n    SM.PrintMessage(SMLoc::getFromPointer(Buffer.end()), SourceMgr::DK_Note,\n                    \"'next' match was here\");\n    SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), SourceMgr::DK_Note,\n                    \"previous match ended here\");\n    return true;\n  }\n\n  return false;\n}\n\n/// Verify there's no \"not strings\" in the given buffer.\nbool CheckString::CheckNot(const SourceMgr &SM, StringRef Buffer,\n                           const std::vector<const Pattern *> &NotStrings,\n                           StringMap<StringRef> &VariableTable) const {\n  for (const Pattern *Pat : NotStrings) {\n    assert((Pat->getCheckTy() == Check::CheckNot) && \"Expect CHECK-NOT!\");\n\n    size_t MatchLen = 0;\n    size_t Pos = Pat->Match(Buffer, MatchLen, VariableTable);\n\n    if (Pos == StringRef::npos)\n      continue;\n\n    SM.PrintMessage(SMLoc::getFromPointer(Buffer.data() + Pos),\n                    SourceMgr::DK_Error, Prefix + \"-NOT: string occurred!\");\n    SM.PrintMessage(Pat->getLoc(), SourceMgr::DK_Note,\n                    Prefix + \"-NOT: pattern specified here\");\n    return true;\n  }\n\n  return false;\n}\n\n/// Match \"dag strings\" and their mixed \"not strings\".\nsize_t CheckString::CheckDag(const SourceMgr &SM, StringRef Buffer,\n                             std::vector<const Pattern *> &NotStrings,\n                             StringMap<StringRef> &VariableTable) const {\n  if (DagNotStrings.empty())\n    return 0;\n\n  size_t LastPos = 0;\n  size_t StartPos = LastPos;\n\n  for (const Pattern &Pat : DagNotStrings) {\n    assert((Pat.getCheckTy() == Check::CheckDAG ||\n            Pat.getCheckTy() == Check::CheckNot) &&\n           \"Invalid CHECK-DAG or CHECK-NOT!\");\n\n    if (Pat.getCheckTy() == Check::CheckNot) {\n      NotStrings.push_back(&Pat);\n      continue;\n    }\n\n    assert((Pat.getCheckTy() == Check::CheckDAG) && \"Expect CHECK-DAG!\");\n\n    size_t MatchLen = 0, MatchPos;\n\n    // CHECK-DAG always matches from the start.\n    StringRef MatchBuffer = Buffer.substr(StartPos);\n    MatchPos = Pat.Match(MatchBuffer, MatchLen, VariableTable);\n    // With a group of CHECK-DAGs, a single mismatching means the match on\n    // that group of CHECK-DAGs fails immediately.\n    if (MatchPos == StringRef::npos) {\n      PrintCheckFailed(SM, Pat.getLoc(), Pat, MatchBuffer, VariableTable);\n      return StringRef::npos;\n    }\n    // Re-calc it as the offset relative to the start of the original string.\n    MatchPos += StartPos;\n\n    if (!NotStrings.empty()) {\n      if (MatchPos < LastPos) {\n        // Reordered?\n        SM.PrintMessage(SMLoc::getFromPointer(Buffer.data() + MatchPos),\n                        SourceMgr::DK_Error,\n                        Prefix + \"-DAG: found a match of CHECK-DAG\"\n                                 \" reordering across a CHECK-NOT\");\n        SM.PrintMessage(SMLoc::getFromPointer(Buffer.data() + LastPos),\n                        SourceMgr::DK_Note,\n                        Prefix + \"-DAG: the farthest match of CHECK-DAG\"\n                                 \" is found here\");\n        SM.PrintMessage(NotStrings[0]->getLoc(), SourceMgr::DK_Note,\n                        Prefix + \"-NOT: the crossed pattern specified\"\n                                 \" here\");\n        SM.PrintMessage(Pat.getLoc(), SourceMgr::DK_Note,\n                        Prefix + \"-DAG: the reordered pattern specified\"\n                                 \" here\");\n        return StringRef::npos;\n      }\n      // All subsequent CHECK-DAGs should be matched from the farthest\n      // position of all precedent CHECK-DAGs (including this one.)\n      StartPos = LastPos;\n      // If there's CHECK-NOTs between two CHECK-DAGs or from CHECK to\n      // CHECK-DAG, verify that there's no 'not' strings occurred in that\n      // region.\n      StringRef SkippedRegion = Buffer.substr(LastPos, MatchPos);\n      if (CheckNot(SM, SkippedRegion, NotStrings, VariableTable))\n        return StringRef::npos;\n      // Clear \"not strings\".\n      NotStrings.clear();\n    }\n\n    // Update the last position with CHECK-DAG matches.\n    LastPos = std::max(MatchPos + MatchLen, LastPos);\n  }\n\n  return LastPos;\n}\n\n// A check prefix must contain only alphanumeric, hyphens and underscores.\nstatic bool ValidateCheckPrefix(StringRef CheckPrefix) {\n  Regex Validator(\"^[a-zA-Z0-9_-]*$\");\n  return Validator.match(CheckPrefix);\n}\n\nstatic bool ValidateCheckPrefixes() {\n  StringSet<> PrefixSet;\n\n  for (StringRef Prefix : CheckPrefixes) {\n    // Reject empty prefixes.\n    if (Prefix == \"\")\n      return false;\n\n    if (!PrefixSet.insert(Prefix).second)\n      return false;\n\n    if (!ValidateCheckPrefix(Prefix))\n      return false;\n  }\n\n  return true;\n}\n\n// Combines the check prefixes into a single regex so that we can efficiently\n// scan for any of the set.\n//\n// The semantics are that the longest-match wins which matches our regex\n// library.\nstatic Regex buildCheckPrefixRegex() {\n  // I don't think there's a way to specify an initial value for cl::list,\n  // so if nothing was specified, add the default\n  if (CheckPrefixes.empty())\n    CheckPrefixes.push_back(\"CHECK\");\n\n  // We already validated the contents of CheckPrefixes so just concatenate\n  // them as alternatives.\n  SmallString<32> PrefixRegexStr;\n  for (StringRef Prefix : CheckPrefixes) {\n    if (Prefix != CheckPrefixes.front())\n      PrefixRegexStr.push_back('|');\n\n    PrefixRegexStr.append(Prefix);\n  }\n\n  return Regex(PrefixRegexStr);\n}\n\nstatic void DumpCommandLine(int argc, char **argv) {\n  errs() << \"FileCheck command line: \";\n  for (int I = 0; I < argc; I++)\n    errs() << \" \" << argv[I];\n  errs() << \"\\n\";\n}\n\n/// Check the input to FileCheck provided in the \\p Buffer against the \\p\n/// CheckStrings read from the check file.\n///\n/// Returns false if the input fails to satisfy the checks.\nbool CheckInput(SourceMgr &SM, StringRef Buffer,\n                ArrayRef<CheckString> CheckStrings) {\n  bool ChecksFailed = false;\n\n  /// VariableTable - This holds all the current filecheck variables.\n  StringMap<StringRef> VariableTable;\n\n  unsigned i = 0, j = 0, e = CheckStrings.size();\n  while (true) {\n    StringRef CheckRegion;\n    if (j == e) {\n      CheckRegion = Buffer;\n    } else {\n      const CheckString &CheckLabelStr = CheckStrings[j];\n      if (CheckLabelStr.Pat.getCheckTy() != Check::CheckLabel) {\n        ++j;\n        continue;\n      }\n\n      // Scan to next CHECK-LABEL match, ignoring CHECK-NOT and CHECK-DAG\n      size_t MatchLabelLen = 0;\n      size_t MatchLabelPos =\n          CheckLabelStr.Check(SM, Buffer, true, MatchLabelLen, VariableTable);\n      if (MatchLabelPos == StringRef::npos)\n        // Immediately bail of CHECK-LABEL fails, nothing else we can do.\n        return false;\n\n      CheckRegion = Buffer.substr(0, MatchLabelPos + MatchLabelLen);\n      Buffer = Buffer.substr(MatchLabelPos + MatchLabelLen);\n      ++j;\n    }\n\n    for (; i != j; ++i) {\n      const CheckString &CheckStr = CheckStrings[i];\n\n      // Check each string within the scanned region, including a second check\n      // of any final CHECK-LABEL (to verify CHECK-NOT and CHECK-DAG)\n      size_t MatchLen = 0;\n      size_t MatchPos =\n          CheckStr.Check(SM, CheckRegion, false, MatchLen, VariableTable);\n\n      if (MatchPos == StringRef::npos) {\n        ChecksFailed = true;\n        i = j;\n        break;\n      }\n\n      CheckRegion = CheckRegion.substr(MatchPos + MatchLen);\n    }\n\n    if (j == e)\n      break;\n  }\n\n  // Success if no checks failed.\n  return !ChecksFailed;\n}\n\nint main(int argc, char **argv) {\n  sys::PrintStackTraceOnErrorSignal(argv[0]);\n  PrettyStackTraceProgram X(argc, argv);\n  cl::ParseCommandLineOptions(argc, argv);\n\n  if (!ValidateCheckPrefixes()) {\n    errs() << \"Supplied check-prefix is invalid! Prefixes must be unique and \"\n              \"start with a letter and contain only alphanumeric characters, \"\n              \"hyphens and underscores\\n\";\n    return 2;\n  }\n\n  Regex PrefixRE = buildCheckPrefixRegex();\n  std::string REError;\n  if (!PrefixRE.isValid(REError)) {\n    errs() << \"Unable to combine check-prefix strings into a prefix regular \"\n              \"expression! This is likely a bug in FileCheck's verification of \"\n              \"the check-prefix strings. Regular expression parsing failed \"\n              \"with the following error: \"\n           << REError << \"\\n\";\n    return 2;\n  }\n\n  SourceMgr SM;\n\n  // Read the expected strings from the check file.\n  ErrorOr<std::unique_ptr<MemoryBuffer>> CheckFileOrErr =\n      MemoryBuffer::getFileOrSTDIN(CheckFilename);\n  if (std::error_code EC = CheckFileOrErr.getError()) {\n    errs() << \"Could not open check file '\" << CheckFilename\n           << \"': \" << EC.message() << '\\n';\n    return 2;\n  }\n  MemoryBuffer &CheckFile = *CheckFileOrErr.get();\n\n  SmallString<4096> CheckFileBuffer;\n  StringRef CheckFileText = CanonicalizeFile(CheckFile, CheckFileBuffer);\n\n  SM.AddNewSourceBuffer(MemoryBuffer::getMemBuffer(\n                            CheckFileText, CheckFile.getBufferIdentifier()),\n                        SMLoc());\n\n  std::vector<CheckString> CheckStrings;\n  if (ReadCheckFile(SM, CheckFileText, PrefixRE, CheckStrings))\n    return 2;\n\n  // Open the file to check and add it to SourceMgr.\n  ErrorOr<std::unique_ptr<MemoryBuffer>> InputFileOrErr =\n      MemoryBuffer::getFileOrSTDIN(InputFilename);\n  if (std::error_code EC = InputFileOrErr.getError()) {\n    errs() << \"Could not open input file '\" << InputFilename\n           << \"': \" << EC.message() << '\\n';\n    return 2;\n  }\n  MemoryBuffer &InputFile = *InputFileOrErr.get();\n\n  if (InputFile.getBufferSize() == 0 && !AllowEmptyInput) {\n    errs() << \"FileCheck error: '\" << InputFilename << \"' is empty.\\n\";\n    DumpCommandLine(argc, argv);\n    return 2;\n  }\n\n  SmallString<4096> InputFileBuffer;\n  StringRef InputFileText = CanonicalizeFile(InputFile, InputFileBuffer);\n\n  SM.AddNewSourceBuffer(MemoryBuffer::getMemBuffer(\n                            InputFileText, InputFile.getBufferIdentifier()),\n                        SMLoc());\n\n  return CheckInput(SM, InputFileText, CheckStrings) ? EXIT_SUCCESS : 1;\n}\n"
  },
  {
    "path": "utils/FileCheck/LICENSE.TXT",
    "content": "==============================================================================\nLLVM Release License\n==============================================================================\nUniversity of Illinois/NCSA\nOpen Source License\n\nCopyright (c) 2003-2017 University of Illinois at Urbana-Champaign.\nAll rights reserved.\n\nDeveloped by:\n\n    LLVM Team\n\n    University of Illinois at Urbana-Champaign\n\n    http://llvm.org\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal with\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\n    * Redistributions of source code must retain the above copyright notice,\n      this list of conditions and the following disclaimers.\n\n    * Redistributions in binary form must reproduce the above copyright notice,\n      this list of conditions and the following disclaimers in the\n      documentation and/or other materials provided with the distribution.\n\n    * Neither the names of the LLVM Team, University of Illinois at\n      Urbana-Champaign, nor the names of its contributors may be used to\n      endorse or promote products derived from this Software without specific\n      prior written permission.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nCONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\nSOFTWARE.\n\n==============================================================================\nCopyrights and Licenses for Third Party Software Distributed with LLVM:\n==============================================================================\nThe LLVM software contains code written by third parties.  Such software will\nhave its own individual LICENSE.TXT file in the directory in which it appears.\nThis file will describe the copyrights, license, and restrictions which apply\nto that code.\n\nThe disclaimer of warranty in the University of Illinois Open Source License\napplies to all code in the LLVM Distribution, and nothing in any of the\nother licenses gives permission to use the names of the LLVM Team or the\nUniversity of Illinois to endorse or promote products derived from this\nSoftware.\n\nThe following pieces of software have additional or alternate copyrights,\nlicenses, and/or restrictions:\n\nProgram             Directory\n-------             ---------\nGoogle Test         llvm/utils/unittest/googletest\nOpenBSD regex       llvm/lib/Support/{reg*, COPYRIGHT.regex}\npyyaml tests        llvm/test/YAMLParser/{*.data, LICENSE.TXT}\nARM contributions   llvm/lib/Target/ARM/LICENSE.TXT\nmd5 contributions   llvm/lib/Support/MD5.cpp llvm/include/llvm/Support/MD5.h\n"
  },
  {
    "path": "utils/SMT-COMP/StarExec-SMTCOMP2017.Dockerfile",
    "content": "# FIXME: This isn't quite the version that's used on StarExec but\n# it's damn close. Hopefully this will be ABI compatible\nFROM centos:centos7.2.1511\nLABEL maintainer \"dan@su-root.co.uk\"\n\n\n# Woraround stupid issue\n# https://github.com/CentOS/sig-cloud-instance-images/issues/15\nRUN yum install -y yum-plugin-ovl && yum clean all\n\n# Make the user and install sudo\nRUN yum install -y sudo && \\\n  useradd -m user && \\\n  echo user:user | chpasswd && \\\n  echo 'user ALL=(root) NOPASSWD: ALL' >> /etc/sudoers\n\nUSER user\nWORKDIR /home/user\n\n# In container development packages (not essential and can be commented out)\nRUN sudo yum install -y vim less\n\n# Install the dependencies for CentOS repos that we can use\nRUN sudo yum install -y \\\n  coreutils \\\n  gcc \\\n  gcc-c++ \\\n  git \\\n  make \\\n  && sudo yum clean all\n\n# Install lit\nRUN curl \"https://bootstrap.pypa.io/get-pip.py\" -o \"get-pip.py\" && \\\n  sudo python get-pip.py && \\\n  sudo pip install lit==0.5.0\n\n# NOTE: We stagger copying across files (i.e. don't do `ADD / ${JFS_SRC_DIR}`\n# first) to avoid triggering a rebuild of CMake/Z3/LLVM unnecessarily.\n\n# This is unlikely to change (i.e. doing so would trigger rebuilds)\n# so its okay to have this declared early.\nENV \\\n  JFS_SRC_DIR=/home/user/jfs/src\n\n# Make directory for JFS source tree\nRUN mkdir -p \"${JFS_SRC_DIR}\"\n\n# Build and install Ninja\nENV \\\n  NINJA_SRC_DIR=/home/user/ninja/src_build \\\n  NINJA_INSTALL=1\nADD /scripts/dist/build_and_install_ninja.sh ${JFS_SRC_DIR}/scripts/dist/\nRUN ${JFS_SRC_DIR}/scripts/dist/build_and_install_ninja.sh\n\n# Build and install CMake\nENV \\\n  CMAKE_SRC_DIR=/home/user/cmake/src_build \\\n  CMAKE_INSTALL=1\nADD /scripts/dist/build_and_install_cmake.sh ${JFS_SRC_DIR}/scripts/dist/\nRUN ${JFS_SRC_DIR}/scripts/dist/build_and_install_cmake.sh\n\n# Build Z3\nENV \\\n  Z3_SRC_DIR=/home/user/z3/src \\\n  Z3_BUILD_DIR=/home/user/z3/build \\\n  Z3_BUILD_TYPE=Release \\\n  Z3_STATIC_BUILD=1 \\\n  Z3_CMAKE_GENERATOR=\"Ninja\"\nADD /scripts/dist/build_z3.sh ${JFS_SRC_DIR}/scripts/dist/\nRUN ${JFS_SRC_DIR}/scripts/dist/build_z3.sh\n\n# Build LLVM\nENV \\\n  LLVM_SRC_DIR=/home/user/llvm/src \\\n  LLVM_BUILD_DIR=/home/user/llvm/build \\\n  LLVM_BUILD_TYPE=Release \\\n  LLVM_CMAKE_GENERATOR=\"Ninja\"\nADD /scripts/dist/build_llvm.sh ${JFS_SRC_DIR}/scripts/dist/\nRUN ${JFS_SRC_DIR}/scripts/dist/build_llvm.sh\n\n# Build JFS\n# Now finally copy across all the other sources\n# FIXME: For final solver build we should disable assertions\nADD / ${JFS_SRC_DIR}\nENV \\\n  JFS_BUILD_DIR=/home/user/jfs/build \\\n  JFS_BUILD_TYPE=Release \\\n  JFS_CMAKE_GENERATOR=\"Ninja\" \\\n  JFS_ENABLE_ASSERTIONS=ON\nRUN ${JFS_SRC_DIR}/scripts/dist/build_jfs.sh\n"
  },
  {
    "path": "utils/SMT-COMP/configs/starexec_run_default",
    "content": "#!/bin/sh\n\n# FIXME: Shouldn't be using dummy backend\n./jfs -dummy -max-time=900 $1\n"
  },
  {
    "path": "utils/SMT-COMP/mk_starexec_binary_dist.sh",
    "content": "#!/bin/bash\n\n# This script builds JFS and its dependencies using Docker and then\n# extracts the necessary files and packs them into a tarball suitable\n# for Solver submission on StarExec (https://www.starexec.org/)\n\nTEMP_DOCKER_IMAGE_NAME=\"jfs_starexec_temp\"\nTEMP_DOCKER_CONTAINER_NAME=\"jfs_starexec_temp_container\"\nRM_TEMP_DOCKER_IMAGE=\"0\"\nTEMP_DIR=\"/tmp/jfs-$$\"\nOUTPUT_FILE_NAME=\"\"\nSCRIPT_ROOT=$(cd ${BASH_SOURCE[0]%/*} ; echo $PWD)\nREPO_ROOT=$(cd \"${SCRIPT_ROOT}/../../\" ; echo $PWD)\n\nfunction usage() {\n  echo \"$(basename $0) [options] <output_file>\"\n  echo \"\"\n  echo \"<output_file> - The destination path for tarball\"\n  echo \"\"\n  echo \"OPTIONS\"\n  echo \"\"\n  echo \"--help\"\n  echo \"Show help\"\n  echo \"\"\n  echo \"--rm-temp-docker-image\"\n  echo \"Remove temporary docker image when done. Default is to keep it for cache reasons\"\n  echo \"\"\n  echo \"--temp-docker-image-name <name>\"\n  echo \"Specify name for temporary docker image (default \\\"${TEMP_DOCKER_IMAGE_NAME}\\\")\"\n  echo \"\"\n  echo \"--temp-docker-container-name <name>\"\n  echo \"Specify name for temporary docker container (default \\\"${TEMP_DOCKER_CONTAINER_NAME}\\\")\"\n  echo \"\"\n  echo \"--temp-dir <path>\"\n  echo \"Directory to write temporary files for tarball preparation\"\n  echo \"\"\n}\n\nif [ \"$#\" -lt 1 ]; then\n  echo \"Insufficent number of arguments. See --help\"\n  exit 1\nfi\n\n# Parse args\nwhile [ -n \"$1\" ]; do\n  if [ $# -gt 1 ] || [ $(echo \"$1\" | grep -Ec '^--help') -eq 1 ] ; then\n    # Parse optional args\n    case \"$1\" in\n      --help)\n        usage\n        exit 0\n      ;;\n      --rm-temp-docker-image)\n        RM_TEMP_DOCKER_IMAGE=1\n        ;;\n      --temp-docker-image-name)\n        shift\n        TEMP_DOCKER_IMAGE_NAME=\"$1\"\n        ;;\n      --temp-docker-container-name)\n        shift\n        TEMP_DOCKER_CONTAINER_NAME=\"$1\"\n        ;;\n      --temp-dir)\n        shift\n        TEMP_DIR=\"$1\"\n        ;;\n      *)\n        echo \"\\\"$1\\\" is not a recognised argument\"\n        exit 1\n    esac\n  else\n    # Get mandatory arg\n    OUTPUT_FILE_NAME=\"$1\"\n  fi\n  shift\ndone\n\nPATH_TO_DOCKER_FILE=\"${SCRIPT_ROOT}/StarExec-SMTCOMP2017.Dockerfile\"\n\n# Show settings\necho \"OUTPUT_FILE_NAME: ${OUTPUT_FILE_NAME}\"\necho \"REPO_ROOT: \\\"${REPO_ROOT}\\\"\"\necho \"RM_TEMP_DOCKER_IMAGE: ${RM_TEMP_DOCKER_IMAGE}\"\necho \"SCRIPT_ROOT: \\\"${SCRIPT_ROOT}\\\"\"\necho \"TEMP_DIR: ${TEMP_DIR}\"\necho \"TEMP_DOCKER_CONTAINER_NAME: ${TEMP_DOCKER_CONTAINER_NAME}\"\necho \"TEMP_DOCKER_IMAGE_NAME: ${TEMP_DOCKER_IMAGE_NAME}\"\n\n# Sanity checks\nif [ ! -d \"${REPO_ROOT}\" ]; then\n  echo \"REPO_ROOT (${REPO_ROOT}) is not a directory\"\n  exit 1\nfi\nif [ ! -d \"${SCRIPT_ROOT}\" ]; then\n  echo \"SCRIPT_ROOT (${SCRIPT_ROOT}) is not a directory\"\n  exit 1\nfi\nif [ ! -e \"${PATH_TO_DOCKER_FILE}\" ]; then\n  echo \"PATH_TO_DOCKER_FILE (${PATH_TO_DOCKER_FILE}) does not exist\"\n  exit 1\nfi\n\nfunction docker_container_exists() {\n  if [ -n \"$(docker ps --all --filter=\"name=^/${1}\\$\" --format='{{.Names}}')\" ]; then\n    echo 1\n  else\n    echo 0\n  fi\n}\n\nset -e\nset -x\nset -o pipefail\n\nif [ \"$(docker_container_exists \"${TEMP_DOCKER_CONTAINER_NAME}\")\" -ne 0 ]; then\n  echo \"Error: container ${TEMP_DOCKER_CONTAINER_NAME} already exists\"\n  exit 1\nfi\n\n# Build JFS and its dependencies in Docker\ndocker build \\\n  -t \"${TEMP_DOCKER_IMAGE_NAME}\" \\\n  -f \"${PATH_TO_DOCKER_FILE}\" \\\n  \"${REPO_ROOT}\"\n\n# Run tests\ndocker run \\\n  --rm \\\n  --cap-add SYS_PTRACE \\\n  \"${TEMP_DOCKER_IMAGE_NAME}\"\n  \"/bin/bash\"\n  \"/home/user/jfs/src/scripts/dist/test_jfs.sh\"\n\n# Create temporary container than we can extract build artifacts from\ndocker create --name \"${TEMP_DOCKER_CONTAINER_NAME}\" \"${TEMP_DOCKER_IMAGE_NAME}\" /bin/true\n\n# Mkdir temp dir\nmkdir -p \"${TEMP_DIR}\"\nmkdir -p \"${TEMP_DIR}/bin\"\n\n# Copy build artifacts across\nartifacts=(\"bin/jfs\")\nfor a in \"${artifacts[*]}\" ; do\n  docker cp \"${TEMP_DOCKER_CONTAINER_NAME}:/home/user/jfs/build/${a}\" \"${TEMP_DIR}/${a}\"\ndone\n\n# Remove container\ndocker rm \"${TEMP_DOCKER_CONTAINER_NAME}\"\n\nif [ \"${RM_TEMP_DOCKER_IMAGE}\" -eq 1 ]; then\n  docker rmi \"${TEMP_DOCKER_IMAGE_NAME}\"\nfi\n\n# Copy across StarExec configurations\ncp \"${SCRIPT_ROOT}/configs/\"* \"${TEMP_DIR}/bin\"\n\n# Copy across StarExec description\ncp \"${SCRIPT_ROOT}/starexec_description.txt\" \"${TEMP_DIR}/\"\n\n# Now tarball up\ntar -C \"${TEMP_DIR}\" -cvzf \"${OUTPUT_FILE_NAME}\" $(cd \"${TEMP_DIR}\"; echo *)\n\n# Remove temp dir\nrm -rf \"${TEMP_DIR}\"\n\n# Done\n"
  },
  {
    "path": "utils/SMT-COMP/starexec_description.txt",
    "content": "# JFS\n\nJFS is a proto type JIT Fuzzing Solver. It designed to operate on\nthe QF_BV, QF_FP, and QF_FPBV theories.\n\nJFS takes as input an SMT query, from which it generates a C program\nwith a sequence of `if` branches, each corresponding to an\nassert from the query.  The program is constructed such that finding\nan input to the program that traverses all the `true` edges of the\nbranches is equivalent to finding a satisfying assignment to all the\nfree variables of the SMT query. To find such an input, a\nhigh performance coverage guided fuzzer is used.\n\n**NOTE**:\nCurrently the fuzzing implementation in JFS is not finished so the `dummy`\nsolver is being used which means satisfiability/unsatisfiability can only be\nshown for trivial benchmarks.\n"
  },
  {
    "path": "utils/googletest/CMakeLists.txt",
    "content": "# HACK: Make sure gtest is built with our flags\nadd_definitions(${JFS_COMPONENT_CXX_DEFINES})\nadd_compile_options(${JFS_COMPONENT_CXX_FLAGS})\nadd_subdirectory(googletest)\n"
  },
  {
    "path": "utils/googletest/README.md",
    "content": "This is googletest 1.8.0\n"
  },
  {
    "path": "utils/googletest/googletest/.gitignore",
    "content": "# python\n*.pyc\n"
  },
  {
    "path": "utils/googletest/googletest/CHANGES",
    "content": "Changes for 1.7.0:\n\n* New feature: death tests are supported on OpenBSD and in iOS\n  simulator now.\n* New feature: Google Test now implements a protocol to allow\n  a test runner to detect that a test program has exited\n  prematurely and report it as a failure (before it would be\n  falsely reported as a success if the exit code is 0).\n* New feature: Test::RecordProperty() can now be used outside of the\n  lifespan of a test method, in which case it will be attributed to\n  the current test case or the test program in the XML report.\n* New feature (potentially breaking): --gtest_list_tests now prints\n  the type parameters and value parameters for each test.\n* Improvement: char pointers and char arrays are now escaped properly\n  in failure messages.\n* Improvement: failure summary in XML reports now includes file and\n  line information.\n* Improvement: the <testsuites> XML element now has a timestamp attribute.\n* Improvement: When --gtest_filter is specified, XML report now doesn't\n  contain information about tests that are filtered out.\n* Fixed the bug where long --gtest_filter flag values are truncated in\n  death tests.\n* Potentially breaking change: RUN_ALL_TESTS() is now implemented as a\n  function instead of a macro in order to work better with Clang.\n* Compatibility fixes with C++ 11 and various platforms.\n* Bug/warning fixes.\n\nChanges for 1.6.0:\n\n* New feature: ADD_FAILURE_AT() for reporting a test failure at the\n  given source location -- useful for writing testing utilities.\n* New feature: the universal value printer is moved from Google Mock\n  to Google Test.\n* New feature: type parameters and value parameters are reported in\n  the XML report now.\n* A gtest_disable_pthreads CMake option.\n* Colored output works in GNU Screen sessions now.\n* Parameters of value-parameterized tests are now printed in the\n  textual output.\n* Failures from ad hoc test assertions run before RUN_ALL_TESTS() are\n  now correctly reported.\n* Arguments of ASSERT_XY and EXPECT_XY no longer need to support << to\n  ostream.\n* More complete handling of exceptions.\n* GTEST_ASSERT_XY can be used instead of ASSERT_XY in case the latter\n  name is already used by another library.\n* --gtest_catch_exceptions is now true by default, allowing a test\n  program to continue after an exception is thrown.\n* Value-parameterized test fixtures can now derive from Test and\n  WithParamInterface<T> separately, easing conversion of legacy tests.\n* Death test messages are clearly marked to make them more\n  distinguishable from other messages.\n* Compatibility fixes for Android, Google Native Client, MinGW, HP UX,\n  PowerPC, Lucid autotools, libCStd, Sun C++, Borland C++ Builder (Code Gear),\n  IBM XL C++ (Visual Age C++), and C++0x.\n* Bug fixes and implementation clean-ups.\n* Potentially incompatible changes: disables the harmful 'make install'\n  command in autotools.\n\nChanges for 1.5.0:\n\n * New feature: assertions can be safely called in multiple threads\n   where the pthreads library is available.\n * New feature: predicates used inside EXPECT_TRUE() and friends\n   can now generate custom failure messages.\n * New feature: Google Test can now be compiled as a DLL.\n * New feature: fused source files are included.\n * New feature: prints help when encountering unrecognized Google Test flags.\n * Experimental feature: CMake build script (requires CMake 2.6.4+).\n * Experimental feature: the Pump script for meta programming.\n * double values streamed to an assertion are printed with enough precision\n   to differentiate any two different values.\n * Google Test now works on Solaris and AIX.\n * Build and test script improvements.\n * Bug fixes and implementation clean-ups.\n\n Potentially breaking changes:\n\n * Stopped supporting VC++ 7.1 with exceptions disabled.\n * Dropped support for 'make install'.\n\nChanges for 1.4.0:\n\n * New feature: the event listener API\n * New feature: test shuffling\n * New feature: the XML report format is closer to junitreport and can\n   be parsed by Hudson now.\n * New feature: when a test runs under Visual Studio, its failures are\n   integrated in the IDE.\n * New feature: /MD(d) versions of VC++ projects.\n * New feature: elapsed time for the tests is printed by default.\n * New feature: comes with a TR1 tuple implementation such that Boost\n   is no longer needed for Combine().\n * New feature: EXPECT_DEATH_IF_SUPPORTED macro and friends.\n * New feature: the Xcode project can now produce static gtest\n   libraries in addition to a framework.\n * Compatibility fixes for Solaris, Cygwin, minGW, Windows Mobile,\n   Symbian, gcc, and C++Builder.\n * Bug fixes and implementation clean-ups.\n\nChanges for 1.3.0:\n\n * New feature: death tests on Windows, Cygwin, and Mac.\n * New feature: ability to use Google Test assertions in other testing\n   frameworks.\n * New feature: ability to run disabled test via\n   --gtest_also_run_disabled_tests.\n * New feature: the --help flag for printing the usage.\n * New feature: access to Google Test flag values in user code.\n * New feature: a script that packs Google Test into one .h and one\n   .cc file for easy deployment.\n * New feature: support for distributing test functions to multiple\n   machines (requires support from the test runner).\n * Bug fixes and implementation clean-ups.\n\nChanges for 1.2.1:\n\n * Compatibility fixes for Linux IA-64 and IBM z/OS.\n * Added support for using Boost and other TR1 implementations.\n * Changes to the build scripts to support upcoming release of Google C++\n   Mocking Framework.\n * Added Makefile to the distribution package.\n * Improved build instructions in README.\n\nChanges for 1.2.0:\n\n * New feature: value-parameterized tests.\n * New feature: the ASSERT/EXPECT_(NON)FATAL_FAILURE(_ON_ALL_THREADS)\n   macros.\n * Changed the XML report format to match JUnit/Ant's.\n * Added tests to the Xcode project.\n * Added scons/SConscript for building with SCons.\n * Added src/gtest-all.cc for building Google Test from a single file.\n * Fixed compatibility with Solaris and z/OS.\n * Enabled running Python tests on systems with python 2.3 installed,\n   e.g. Mac OS X 10.4.\n * Bug fixes.\n\nChanges for 1.1.0:\n\n * New feature: type-parameterized tests.\n * New feature: exception assertions.\n * New feature: printing elapsed time of tests.\n * Improved the robustness of death tests.\n * Added an Xcode project and samples.\n * Adjusted the output format on Windows to be understandable by Visual Studio.\n * Minor bug fixes.\n\nChanges for 1.0.1:\n\n * Added project files for Visual Studio 7.1.\n * Fixed issues with compiling on Mac OS X.\n * Fixed issues with compiling on Cygwin.\n\nChanges for 1.0.0:\n\n * Initial Open Source release of Google Test\n"
  },
  {
    "path": "utils/googletest/googletest/CMakeLists.txt",
    "content": "########################################################################\n# CMake build script for Google Test.\n#\n# To run the tests for Google Test itself on Linux, use 'make test' or\n# ctest.  You can select which tests to run using 'ctest -R regex'.\n# For more options, run 'ctest --help'.\n\n# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to\n# make it prominent in the GUI.\noption(BUILD_SHARED_LIBS \"Build shared libraries (DLLs).\" OFF)\n\n# When other libraries are using a shared version of runtime libraries,\n# Google Test also has to use one.\noption(\n  gtest_force_shared_crt\n  \"Use shared (DLL) run-time lib even when Google Test is built as static lib.\"\n  OFF)\n\noption(gtest_build_tests \"Build all of gtest's own tests.\" OFF)\n\noption(gtest_build_samples \"Build gtest's sample programs.\" OFF)\n\noption(gtest_disable_pthreads \"Disable uses of pthreads in gtest.\" OFF)\n\noption(\n  gtest_hide_internal_symbols\n  \"Build gtest with internal symbols hidden in shared libraries.\"\n  OFF)\n\n# Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build().\ninclude(cmake/hermetic_build.cmake OPTIONAL)\n\nif (COMMAND pre_project_set_up_hermetic_build)\n  pre_project_set_up_hermetic_build()\nendif()\n\n########################################################################\n#\n# Project-wide settings\n\n# Name of the project.\n#\n# CMake files in this project can refer to the root source directory\n# as ${gtest_SOURCE_DIR} and to the root binary directory as\n# ${gtest_BINARY_DIR}.\n# Language \"C\" is required for find_package(Threads).\nproject(gtest CXX C)\nset(GTEST_TARGET_PREFIX \"jfs_\") # HACK\ncmake_minimum_required(VERSION 2.6.2)\n\nif (COMMAND set_up_hermetic_build)\n  set_up_hermetic_build()\nendif()\n\nif (gtest_hide_internal_symbols)\n  set(CMAKE_CXX_VISIBILITY_PRESET hidden)\n  set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)\nendif()\n\n# Define helper functions and macros used by Google Test.\ninclude(cmake/internal_utils.cmake)\n\nconfig_compiler_and_linker()  # Defined in internal_utils.cmake.\n\n# Where Google Test's .h files can be found.\ninclude_directories(\n  ${gtest_SOURCE_DIR}/include\n  ${gtest_SOURCE_DIR})\n\n# Where Google Test's libraries can be found.\nlink_directories(${gtest_BINARY_DIR}/src)\n\n# Summary of tuple support for Microsoft Visual Studio:\n# Compiler    version(MS)  version(cmake)  Support\n# ----------  -----------  --------------  -----------------------------\n# <= VS 2010  <= 10        <= 1600         Use Google Tests's own tuple.\n# VS 2012     11           1700            std::tr1::tuple + _VARIADIC_MAX=10\n# VS 2013     12           1800            std::tr1::tuple\nif (MSVC AND MSVC_VERSION EQUAL 1700)\n  add_definitions(/D _VARIADIC_MAX=10)\nendif()\n\n########################################################################\n#\n# Defines the gtest & gtest_main libraries.  User tests should link\n# with one of them.\n\n# Google Test libraries.  We build them using more strict warnings than what\n# are used for other targets, to ensure that gtest can be compiled by a user\n# aggressive about warnings.\ncxx_library(${GTEST_TARGET_PREFIX}gtest \"${cxx_strict}\" src/gtest-all.cc)\ncxx_library(${GTEST_TARGET_PREFIX}gtest_main \"${cxx_strict}\" src/gtest_main.cc)\ntarget_link_libraries(${GTEST_TARGET_PREFIX}gtest_main ${GTEST_TARGET_PREFIX}gtest)\n\n# If the CMake version supports it, attach header directory information\n# to the targets for when we are part of a parent build (ie being pulled\n# in via add_subdirectory() rather than being a standalone build).\nif (DEFINED CMAKE_VERSION AND NOT \"${CMAKE_VERSION}\" VERSION_LESS \"2.8.11\")\n  target_include_directories(${GTEST_TARGET_PREFIX}gtest      INTERFACE \"${gtest_SOURCE_DIR}/include\")\n  target_include_directories(${GTEST_TARGET_PREFIX}gtest_main INTERFACE \"${gtest_SOURCE_DIR}/include\")\nendif()\n\n########################################################################\n#\n# Install rules\nif (FALSE)\ninstall(TARGETS gtest gtest_main\n  DESTINATION lib)\ninstall(DIRECTORY ${gtest_SOURCE_DIR}/include/gtest\n  DESTINATION include)\nendif()\n\n########################################################################\n#\n# Samples on how to link user tests with gtest or gtest_main.\n#\n# They are not built by default.  To build them, set the\n# gtest_build_samples option to ON.  You can do it by running ccmake\n# or specifying the -Dgtest_build_samples=ON flag when running cmake.\n\nif (gtest_build_samples)\n  cxx_executable(sample1_unittest samples gtest_main samples/sample1.cc)\n  cxx_executable(sample2_unittest samples gtest_main samples/sample2.cc)\n  cxx_executable(sample3_unittest samples gtest_main)\n  cxx_executable(sample4_unittest samples gtest_main samples/sample4.cc)\n  cxx_executable(sample5_unittest samples gtest_main samples/sample1.cc)\n  cxx_executable(sample6_unittest samples gtest_main)\n  cxx_executable(sample7_unittest samples gtest_main)\n  cxx_executable(sample8_unittest samples gtest_main)\n  cxx_executable(sample9_unittest samples gtest)\n  cxx_executable(sample10_unittest samples gtest)\nendif()\n\n########################################################################\n#\n# Google Test's own tests.\n#\n# You can skip this section if you aren't interested in testing\n# Google Test itself.\n#\n# The tests are not built by default.  To build them, set the\n# gtest_build_tests option to ON.  You can do it by running ccmake\n# or specifying the -Dgtest_build_tests=ON flag when running cmake.\n\nif (gtest_build_tests)\n  # This must be set in the root directory for the tests to be run by\n  # 'make test' or ctest.\n  enable_testing()\n\n  ############################################################\n  # C++ tests built with standard compiler flags.\n\n  cxx_test(gtest-death-test_test gtest_main)\n  cxx_test(gtest_environment_test gtest)\n  cxx_test(gtest-filepath_test gtest_main)\n  cxx_test(gtest-linked_ptr_test gtest_main)\n  cxx_test(gtest-listener_test gtest_main)\n  cxx_test(gtest_main_unittest gtest_main)\n  cxx_test(gtest-message_test gtest_main)\n  cxx_test(gtest_no_test_unittest gtest)\n  cxx_test(gtest-options_test gtest_main)\n  cxx_test(gtest-param-test_test gtest\n    test/gtest-param-test2_test.cc)\n  cxx_test(gtest-port_test gtest_main)\n  cxx_test(gtest_pred_impl_unittest gtest_main)\n  cxx_test(gtest_premature_exit_test gtest\n    test/gtest_premature_exit_test.cc)\n  cxx_test(gtest-printers_test gtest_main)\n  cxx_test(gtest_prod_test gtest_main\n    test/production.cc)\n  cxx_test(gtest_repeat_test gtest)\n  cxx_test(gtest_sole_header_test gtest_main)\n  cxx_test(gtest_stress_test gtest)\n  cxx_test(gtest-test-part_test gtest_main)\n  cxx_test(gtest_throw_on_failure_ex_test gtest)\n  cxx_test(gtest-typed-test_test gtest_main\n    test/gtest-typed-test2_test.cc)\n  cxx_test(gtest_unittest gtest_main)\n  cxx_test(gtest-unittest-api_test gtest)\n\n  ############################################################\n  # C++ tests built with non-standard compiler flags.\n\n  # MSVC 7.1 does not support STL with exceptions disabled.\n  if (NOT MSVC OR MSVC_VERSION GREATER 1310)\n    cxx_library(gtest_no_exception \"${cxx_no_exception}\"\n      src/gtest-all.cc)\n    cxx_library(gtest_main_no_exception \"${cxx_no_exception}\"\n      src/gtest-all.cc src/gtest_main.cc)\n  endif()\n  cxx_library(gtest_main_no_rtti \"${cxx_no_rtti}\"\n    src/gtest-all.cc src/gtest_main.cc)\n\n  cxx_test_with_flags(gtest-death-test_ex_nocatch_test\n    \"${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=0\"\n    gtest test/gtest-death-test_ex_test.cc)\n  cxx_test_with_flags(gtest-death-test_ex_catch_test\n    \"${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=1\"\n    gtest test/gtest-death-test_ex_test.cc)\n\n  cxx_test_with_flags(gtest_no_rtti_unittest \"${cxx_no_rtti}\"\n    gtest_main_no_rtti test/gtest_unittest.cc)\n\n  cxx_shared_library(gtest_dll \"${cxx_default}\"\n    src/gtest-all.cc src/gtest_main.cc)\n\n  cxx_executable_with_flags(gtest_dll_test_ \"${cxx_default}\"\n    gtest_dll test/gtest_all_test.cc)\n  set_target_properties(gtest_dll_test_\n                        PROPERTIES\n                        COMPILE_DEFINITIONS \"GTEST_LINKED_AS_SHARED_LIBRARY=1\")\n\n  if (NOT MSVC OR MSVC_VERSION LESS 1600)  # 1600 is Visual Studio 2010.\n    # Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that\n    # conflict with our own definitions. Therefore using our own tuple does not\n    # work on those compilers.\n    cxx_library(gtest_main_use_own_tuple \"${cxx_use_own_tuple}\"\n      src/gtest-all.cc src/gtest_main.cc)\n\n    cxx_test_with_flags(gtest-tuple_test \"${cxx_use_own_tuple}\"\n      gtest_main_use_own_tuple test/gtest-tuple_test.cc)\n\n    cxx_test_with_flags(gtest_use_own_tuple_test \"${cxx_use_own_tuple}\"\n      gtest_main_use_own_tuple\n      test/gtest-param-test_test.cc test/gtest-param-test2_test.cc)\n  endif()\n\n  ############################################################\n  # Python tests.\n\n  cxx_executable(gtest_break_on_failure_unittest_ test gtest)\n  py_test(gtest_break_on_failure_unittest)\n\n  # Visual Studio .NET 2003 does not support STL with exceptions disabled.\n  if (NOT MSVC OR MSVC_VERSION GREATER 1310)  # 1310 is Visual Studio .NET 2003\n    cxx_executable_with_flags(\n      gtest_catch_exceptions_no_ex_test_\n      \"${cxx_no_exception}\"\n      gtest_main_no_exception\n      test/gtest_catch_exceptions_test_.cc)\n  endif()\n\n  cxx_executable_with_flags(\n    gtest_catch_exceptions_ex_test_\n    \"${cxx_exception}\"\n    gtest_main\n    test/gtest_catch_exceptions_test_.cc)\n  py_test(gtest_catch_exceptions_test)\n\n  cxx_executable(gtest_color_test_ test gtest)\n  py_test(gtest_color_test)\n\n  cxx_executable(gtest_env_var_test_ test gtest)\n  py_test(gtest_env_var_test)\n\n  cxx_executable(gtest_filter_unittest_ test gtest)\n  py_test(gtest_filter_unittest)\n\n  cxx_executable(gtest_help_test_ test gtest_main)\n  py_test(gtest_help_test)\n\n  cxx_executable(gtest_list_tests_unittest_ test gtest)\n  py_test(gtest_list_tests_unittest)\n\n  cxx_executable(gtest_output_test_ test gtest)\n  py_test(gtest_output_test)\n\n  cxx_executable(gtest_shuffle_test_ test gtest)\n  py_test(gtest_shuffle_test)\n\n  # MSVC 7.1 does not support STL with exceptions disabled.\n  if (NOT MSVC OR MSVC_VERSION GREATER 1310)\n    cxx_executable(gtest_throw_on_failure_test_ test gtest_no_exception)\n    set_target_properties(gtest_throw_on_failure_test_\n      PROPERTIES\n      COMPILE_FLAGS \"${cxx_no_exception}\")\n    py_test(gtest_throw_on_failure_test)\n  endif()\n\n  cxx_executable(gtest_uninitialized_test_ test gtest)\n  py_test(gtest_uninitialized_test)\n\n  cxx_executable(gtest_xml_outfile1_test_ test gtest_main)\n  cxx_executable(gtest_xml_outfile2_test_ test gtest_main)\n  py_test(gtest_xml_outfiles_test)\n\n  cxx_executable(gtest_xml_output_unittest_ test gtest)\n  py_test(gtest_xml_output_unittest)\nendif()\n"
  },
  {
    "path": "utils/googletest/googletest/CONTRIBUTORS",
    "content": "# This file contains a list of people who've made non-trivial\n# contribution to the Google C++ Testing Framework project.  People\n# who commit code to the project are encouraged to add their names\n# here.  Please keep the list sorted by first names.\n\nAjay Joshi <jaj@google.com>\nBalázs Dán <balazs.dan@gmail.com>\nBharat Mediratta <bharat@menalto.com>\nChandler Carruth <chandlerc@google.com>\nChris Prince <cprince@google.com>\nChris Taylor <taylorc@google.com>\nDan Egnor <egnor@google.com>\nEric Roman <eroman@chromium.org>\nHady Zalek <hady.zalek@gmail.com>\nJeffrey Yasskin <jyasskin@google.com>\nJói Sigurðsson <joi@google.com>\nKeir Mierle <mierle@gmail.com>\nKeith Ray <keith.ray@gmail.com>\nKenton Varda <kenton@google.com>\nManuel Klimek <klimek@google.com>\nMarkus Heule <markus.heule@gmail.com>\nMika Raento <mikie@iki.fi>\nMiklós Fazekas <mfazekas@szemafor.com>\nPasi Valminen <pasi.valminen@gmail.com>\nPatrick Hanna <phanna@google.com>\nPatrick Riley <pfr@google.com>\nPeter Kaminski <piotrk@google.com>\nPreston Jackson <preston.a.jackson@gmail.com>\nRainer Klaffenboeck <rainer.klaffenboeck@dynatrace.com>\nRuss Cox <rsc@google.com>\nRuss Rufer <russ@pentad.com>\nSean Mcafee <eefacm@gmail.com>\nSigurður Ásgeirsson <siggi@google.com>\nTracy Bialik <tracy@pentad.com>\nVadim Berman <vadimb@google.com>\nVlad Losev <vladl@google.com>\nZhanyong Wan <wan@google.com>\n"
  },
  {
    "path": "utils/googletest/googletest/LICENSE",
    "content": "Copyright 2008, Google Inc.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n    * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n    * Neither the name of Google Inc. nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "utils/googletest/googletest/Makefile.am",
    "content": "# Automake file\n\nACLOCAL_AMFLAGS = -I m4\n\n# Nonstandard package files for distribution\nEXTRA_DIST = \\\n  CHANGES \\\n  CONTRIBUTORS \\\n  LICENSE \\\n  include/gtest/gtest-param-test.h.pump \\\n  include/gtest/internal/gtest-param-util-generated.h.pump \\\n  include/gtest/internal/gtest-tuple.h.pump \\\n  include/gtest/internal/gtest-type-util.h.pump \\\n  make/Makefile \\\n  scripts/fuse_gtest_files.py \\\n  scripts/gen_gtest_pred_impl.py \\\n  scripts/pump.py \\\n  scripts/test/Makefile\n\n# gtest source files that we don't compile directly.  They are\n# #included by gtest-all.cc.\nGTEST_SRC = \\\n  src/gtest-death-test.cc \\\n  src/gtest-filepath.cc \\\n  src/gtest-internal-inl.h \\\n  src/gtest-port.cc \\\n  src/gtest-printers.cc \\\n  src/gtest-test-part.cc \\\n  src/gtest-typed-test.cc \\\n  src/gtest.cc\n\nEXTRA_DIST += $(GTEST_SRC)\n\n# Sample files that we don't compile.\nEXTRA_DIST += \\\n  samples/prime_tables.h \\\n  samples/sample2_unittest.cc \\\n  samples/sample3_unittest.cc \\\n  samples/sample4_unittest.cc \\\n  samples/sample5_unittest.cc \\\n  samples/sample6_unittest.cc \\\n  samples/sample7_unittest.cc \\\n  samples/sample8_unittest.cc \\\n  samples/sample9_unittest.cc\n\n# C++ test files that we don't compile directly.\nEXTRA_DIST += \\\n  test/gtest-death-test_ex_test.cc \\\n  test/gtest-death-test_test.cc \\\n  test/gtest-filepath_test.cc \\\n  test/gtest-linked_ptr_test.cc \\\n  test/gtest-listener_test.cc \\\n  test/gtest-message_test.cc \\\n  test/gtest-options_test.cc \\\n  test/gtest-param-test2_test.cc \\\n  test/gtest-param-test2_test.cc \\\n  test/gtest-param-test_test.cc \\\n  test/gtest-param-test_test.cc \\\n  test/gtest-param-test_test.h \\\n  test/gtest-port_test.cc \\\n  test/gtest_premature_exit_test.cc \\\n  test/gtest-printers_test.cc \\\n  test/gtest-test-part_test.cc \\\n  test/gtest-tuple_test.cc \\\n  test/gtest-typed-test2_test.cc \\\n  test/gtest-typed-test_test.cc \\\n  test/gtest-typed-test_test.h \\\n  test/gtest-unittest-api_test.cc \\\n  test/gtest_break_on_failure_unittest_.cc \\\n  test/gtest_catch_exceptions_test_.cc \\\n  test/gtest_color_test_.cc \\\n  test/gtest_env_var_test_.cc \\\n  test/gtest_environment_test.cc \\\n  test/gtest_filter_unittest_.cc \\\n  test/gtest_help_test_.cc \\\n  test/gtest_list_tests_unittest_.cc \\\n  test/gtest_main_unittest.cc \\\n  test/gtest_no_test_unittest.cc \\\n  test/gtest_output_test_.cc \\\n  test/gtest_pred_impl_unittest.cc \\\n  test/gtest_prod_test.cc \\\n  test/gtest_repeat_test.cc \\\n  test/gtest_shuffle_test_.cc \\\n  test/gtest_sole_header_test.cc \\\n  test/gtest_stress_test.cc \\\n  test/gtest_throw_on_failure_ex_test.cc \\\n  test/gtest_throw_on_failure_test_.cc \\\n  test/gtest_uninitialized_test_.cc \\\n  test/gtest_unittest.cc \\\n  test/gtest_unittest.cc \\\n  test/gtest_xml_outfile1_test_.cc \\\n  test/gtest_xml_outfile2_test_.cc \\\n  test/gtest_xml_output_unittest_.cc \\\n  test/production.cc \\\n  test/production.h\n\n# Python tests that we don't run.\nEXTRA_DIST += \\\n  test/gtest_break_on_failure_unittest.py \\\n  test/gtest_catch_exceptions_test.py \\\n  test/gtest_color_test.py \\\n  test/gtest_env_var_test.py \\\n  test/gtest_filter_unittest.py \\\n  test/gtest_help_test.py \\\n  test/gtest_list_tests_unittest.py \\\n  test/gtest_output_test.py \\\n  test/gtest_output_test_golden_lin.txt \\\n  test/gtest_shuffle_test.py \\\n  test/gtest_test_utils.py \\\n  test/gtest_throw_on_failure_test.py \\\n  test/gtest_uninitialized_test.py \\\n  test/gtest_xml_outfiles_test.py \\\n  test/gtest_xml_output_unittest.py \\\n  test/gtest_xml_test_utils.py\n\n# CMake script\nEXTRA_DIST += \\\n  CMakeLists.txt \\\n  cmake/internal_utils.cmake\n\n# MSVC project files\nEXTRA_DIST += \\\n  msvc/gtest-md.sln \\\n  msvc/gtest-md.vcproj \\\n  msvc/gtest.sln \\\n  msvc/gtest.vcproj \\\n  msvc/gtest_main-md.vcproj \\\n  msvc/gtest_main.vcproj \\\n  msvc/gtest_prod_test-md.vcproj \\\n  msvc/gtest_prod_test.vcproj \\\n  msvc/gtest_unittest-md.vcproj \\\n  msvc/gtest_unittest.vcproj\n\n# xcode project files\nEXTRA_DIST += \\\n  xcode/Config/DebugProject.xcconfig \\\n  xcode/Config/FrameworkTarget.xcconfig \\\n  xcode/Config/General.xcconfig \\\n  xcode/Config/ReleaseProject.xcconfig \\\n  xcode/Config/StaticLibraryTarget.xcconfig \\\n  xcode/Config/TestTarget.xcconfig \\\n  xcode/Resources/Info.plist \\\n  xcode/Scripts/runtests.sh \\\n  xcode/Scripts/versiongenerate.py \\\n  xcode/gtest.xcodeproj/project.pbxproj\n\n# xcode sample files\nEXTRA_DIST += \\\n  xcode/Samples/FrameworkSample/Info.plist \\\n  xcode/Samples/FrameworkSample/WidgetFramework.xcodeproj/project.pbxproj \\\n  xcode/Samples/FrameworkSample/runtests.sh \\\n  xcode/Samples/FrameworkSample/widget.cc \\\n  xcode/Samples/FrameworkSample/widget.h \\\n  xcode/Samples/FrameworkSample/widget_test.cc\n\n# C++Builder project files\nEXTRA_DIST += \\\n  codegear/gtest.cbproj \\\n  codegear/gtest.groupproj \\\n  codegear/gtest_all.cc \\\n  codegear/gtest_link.cc \\\n  codegear/gtest_main.cbproj \\\n  codegear/gtest_unittest.cbproj\n\n# Distribute and install M4 macro\nm4datadir = $(datadir)/aclocal\nm4data_DATA = m4/gtest.m4\nEXTRA_DIST += $(m4data_DATA)\n\n# We define the global AM_CPPFLAGS as everything we compile includes from these\n# directories.\nAM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/include\n\n# Modifies compiler and linker flags for pthreads compatibility.\nif HAVE_PTHREADS\n  AM_CXXFLAGS = @PTHREAD_CFLAGS@ -DGTEST_HAS_PTHREAD=1\n  AM_LIBS = @PTHREAD_LIBS@\nelse\n  AM_CXXFLAGS = -DGTEST_HAS_PTHREAD=0\nendif\n\n# Build rules for libraries.\nlib_LTLIBRARIES = lib/libgtest.la lib/libgtest_main.la\n\nlib_libgtest_la_SOURCES = src/gtest-all.cc\n\npkginclude_HEADERS = \\\n  include/gtest/gtest-death-test.h \\\n  include/gtest/gtest-message.h \\\n  include/gtest/gtest-param-test.h \\\n  include/gtest/gtest-printers.h \\\n  include/gtest/gtest-spi.h \\\n  include/gtest/gtest-test-part.h \\\n  include/gtest/gtest-typed-test.h \\\n  include/gtest/gtest.h \\\n  include/gtest/gtest_pred_impl.h \\\n  include/gtest/gtest_prod.h\n\npkginclude_internaldir = $(pkgincludedir)/internal\npkginclude_internal_HEADERS = \\\n  include/gtest/internal/gtest-death-test-internal.h \\\n  include/gtest/internal/gtest-filepath.h \\\n  include/gtest/internal/gtest-internal.h \\\n  include/gtest/internal/gtest-linked_ptr.h \\\n  include/gtest/internal/gtest-param-util-generated.h \\\n  include/gtest/internal/gtest-param-util.h \\\n  include/gtest/internal/gtest-port.h \\\n  include/gtest/internal/gtest-port-arch.h \\\n  include/gtest/internal/gtest-string.h \\\n  include/gtest/internal/gtest-tuple.h \\\n  include/gtest/internal/gtest-type-util.h \\\n  include/gtest/internal/custom/gtest.h \\\n  include/gtest/internal/custom/gtest-port.h \\\n  include/gtest/internal/custom/gtest-printers.h\n\nlib_libgtest_main_la_SOURCES = src/gtest_main.cc\nlib_libgtest_main_la_LIBADD = lib/libgtest.la\n\n# Bulid rules for samples and tests. Automake's naming for some of\n# these variables isn't terribly obvious, so this is a brief\n# reference:\n#\n# TESTS -- Programs run automatically by \"make check\"\n# check_PROGRAMS -- Programs built by \"make check\" but not necessarily run\n\nnoinst_LTLIBRARIES = samples/libsamples.la\n\nsamples_libsamples_la_SOURCES = \\\n  samples/sample1.cc \\\n  samples/sample1.h \\\n  samples/sample2.cc \\\n  samples/sample2.h \\\n  samples/sample3-inl.h \\\n  samples/sample4.cc \\\n  samples/sample4.h\n\nTESTS=\nTESTS_ENVIRONMENT = GTEST_SOURCE_DIR=\"$(srcdir)/test\" \\\n                    GTEST_BUILD_DIR=\"$(top_builddir)/test\"\ncheck_PROGRAMS=\n\n# A simple sample on using gtest.\nTESTS += samples/sample1_unittest\ncheck_PROGRAMS += samples/sample1_unittest\nsamples_sample1_unittest_SOURCES = samples/sample1_unittest.cc\nsamples_sample1_unittest_LDADD = lib/libgtest_main.la \\\n                                 lib/libgtest.la \\\n                                 samples/libsamples.la\n\n# Another sample.  It also verifies that libgtest works.\nTESTS += samples/sample10_unittest\ncheck_PROGRAMS += samples/sample10_unittest\nsamples_sample10_unittest_SOURCES = samples/sample10_unittest.cc\nsamples_sample10_unittest_LDADD = lib/libgtest.la\n\n# This tests most constructs of gtest and verifies that libgtest_main\n# and libgtest work.\nTESTS += test/gtest_all_test\ncheck_PROGRAMS += test/gtest_all_test\ntest_gtest_all_test_SOURCES = test/gtest_all_test.cc\ntest_gtest_all_test_LDADD = lib/libgtest_main.la \\\n                            lib/libgtest.la\n\n# Tests that fused gtest files compile and work.\nFUSED_GTEST_SRC = \\\n  fused-src/gtest/gtest-all.cc \\\n  fused-src/gtest/gtest.h \\\n  fused-src/gtest/gtest_main.cc\n\nif HAVE_PYTHON\nTESTS += test/fused_gtest_test\ncheck_PROGRAMS += test/fused_gtest_test\ntest_fused_gtest_test_SOURCES = $(FUSED_GTEST_SRC) \\\n                                samples/sample1.cc samples/sample1_unittest.cc\ntest_fused_gtest_test_CPPFLAGS = -I\"$(srcdir)/fused-src\"\n\n# Build rules for putting fused Google Test files into the distribution\n# package. The user can also create those files by manually running\n# scripts/fuse_gtest_files.py.\n$(test_fused_gtest_test_SOURCES): fused-gtest\n\nfused-gtest: $(pkginclude_HEADERS) $(pkginclude_internal_HEADERS) \\\n             $(GTEST_SRC) src/gtest-all.cc src/gtest_main.cc \\\n             scripts/fuse_gtest_files.py\n\tmkdir -p \"$(srcdir)/fused-src\"\n\tchmod -R u+w \"$(srcdir)/fused-src\"\n\trm -f \"$(srcdir)/fused-src/gtest/gtest-all.cc\"\n\trm -f \"$(srcdir)/fused-src/gtest/gtest.h\"\n\t\"$(srcdir)/scripts/fuse_gtest_files.py\" \"$(srcdir)/fused-src\"\n\tcp -f \"$(srcdir)/src/gtest_main.cc\" \"$(srcdir)/fused-src/gtest/\"\n\nmaintainer-clean-local:\n\trm -rf \"$(srcdir)/fused-src\"\nendif\n\n# Death tests may produce core dumps in the build directory. In case\n# this happens, clean them to keep distcleancheck happy.\nCLEANFILES = core\n\n# Disables 'make install' as installing a compiled version of Google\n# Test can lead to undefined behavior due to violation of the\n# One-Definition Rule.\n\ninstall-exec-local:\n\techo \"'make install' is dangerous and not supported. Instead, see README for how to integrate Google Test into your build system.\"\n\tfalse\n\ninstall-data-local:\n\techo \"'make install' is dangerous and not supported. Instead, see README for how to integrate Google Test into your build system.\"\n\tfalse\n"
  },
  {
    "path": "utils/googletest/googletest/README.md",
    "content": "\n### Generic Build Instructions ###\n\n#### Setup ####\n\nTo build Google Test and your tests that use it, you need to tell your\nbuild system where to find its headers and source files.  The exact\nway to do it depends on which build system you use, and is usually\nstraightforward.\n\n#### Build ####\n\nSuppose you put Google Test in directory `${GTEST_DIR}`.  To build it,\ncreate a library build target (or a project as called by Visual Studio\nand Xcode) to compile\n\n    ${GTEST_DIR}/src/gtest-all.cc\n\nwith `${GTEST_DIR}/include` in the system header search path and `${GTEST_DIR}`\nin the normal header search path.  Assuming a Linux-like system and gcc,\nsomething like the following will do:\n\n    g++ -isystem ${GTEST_DIR}/include -I${GTEST_DIR} \\\n        -pthread -c ${GTEST_DIR}/src/gtest-all.cc\n    ar -rv libgtest.a gtest-all.o\n\n(We need `-pthread` as Google Test uses threads.)\n\nNext, you should compile your test source file with\n`${GTEST_DIR}/include` in the system header search path, and link it\nwith gtest and any other necessary libraries:\n\n    g++ -isystem ${GTEST_DIR}/include -pthread path/to/your_test.cc libgtest.a \\\n        -o your_test\n\nAs an example, the make/ directory contains a Makefile that you can\nuse to build Google Test on systems where GNU make is available\n(e.g. Linux, Mac OS X, and Cygwin).  It doesn't try to build Google\nTest's own tests.  Instead, it just builds the Google Test library and\na sample test.  You can use it as a starting point for your own build\nscript.\n\nIf the default settings are correct for your environment, the\nfollowing commands should succeed:\n\n    cd ${GTEST_DIR}/make\n    make\n    ./sample1_unittest\n\nIf you see errors, try to tweak the contents of `make/Makefile` to make\nthem go away.  There are instructions in `make/Makefile` on how to do\nit.\n\n### Using CMake ###\n\nGoogle Test comes with a CMake build script (\n[CMakeLists.txt](CMakeLists.txt)) that can be used on a wide range of platforms (\"C\" stands for\ncross-platform.). If you don't have CMake installed already, you can\ndownload it for free from <http://www.cmake.org/>.\n\nCMake works by generating native makefiles or build projects that can\nbe used in the compiler environment of your choice.  The typical\nworkflow starts with:\n\n    mkdir mybuild       # Create a directory to hold the build output.\n    cd mybuild\n    cmake ${GTEST_DIR}  # Generate native build scripts.\n\nIf you want to build Google Test's samples, you should replace the\nlast command with\n\n    cmake -Dgtest_build_samples=ON ${GTEST_DIR}\n\nIf you are on a \\*nix system, you should now see a Makefile in the\ncurrent directory.  Just type 'make' to build gtest.\n\nIf you use Windows and have Visual Studio installed, a `gtest.sln` file\nand several `.vcproj` files will be created.  You can then build them\nusing Visual Studio.\n\nOn Mac OS X with Xcode installed, a `.xcodeproj` file will be generated.\n\n### Legacy Build Scripts ###\n\nBefore settling on CMake, we have been providing hand-maintained build\nprojects/scripts for Visual Studio, Xcode, and Autotools.  While we\ncontinue to provide them for convenience, they are not actively\nmaintained any more.  We highly recommend that you follow the\ninstructions in the previous two sections to integrate Google Test\nwith your existing build system.\n\nIf you still need to use the legacy build scripts, here's how:\n\nThe msvc\\ folder contains two solutions with Visual C++ projects.\nOpen the `gtest.sln` or `gtest-md.sln` file using Visual Studio, and you\nare ready to build Google Test the same way you build any Visual\nStudio project.  Files that have names ending with -md use DLL\nversions of Microsoft runtime libraries (the /MD or the /MDd compiler\noption).  Files without that suffix use static versions of the runtime\nlibraries (the /MT or the /MTd option).  Please note that one must use\nthe same option to compile both gtest and the test code.  If you use\nVisual Studio 2005 or above, we recommend the -md version as /MD is\nthe default for new projects in these versions of Visual Studio.\n\nOn Mac OS X, open the `gtest.xcodeproj` in the `xcode/` folder using\nXcode.  Build the \"gtest\" target.  The universal binary framework will\nend up in your selected build directory (selected in the Xcode\n\"Preferences...\" -> \"Building\" pane and defaults to xcode/build).\nAlternatively, at the command line, enter:\n\n    xcodebuild\n\nThis will build the \"Release\" configuration of gtest.framework in your\ndefault build location.  See the \"xcodebuild\" man page for more\ninformation about building different configurations and building in\ndifferent locations.\n\nIf you wish to use the Google Test Xcode project with Xcode 4.x and\nabove, you need to either:\n\n * update the SDK configuration options in xcode/Config/General.xconfig.\n   Comment options `SDKROOT`, `MACOS_DEPLOYMENT_TARGET`, and `GCC_VERSION`. If\n   you choose this route you lose the ability to target earlier versions\n   of MacOS X.\n * Install an SDK for an earlier version. This doesn't appear to be\n   supported by Apple, but has been reported to work\n   (http://stackoverflow.com/questions/5378518).\n\n### Tweaking Google Test ###\n\nGoogle Test can be used in diverse environments.  The default\nconfiguration may not work (or may not work well) out of the box in\nsome environments.  However, you can easily tweak Google Test by\ndefining control macros on the compiler command line.  Generally,\nthese macros are named like `GTEST_XYZ` and you define them to either 1\nor 0 to enable or disable a certain feature.\n\nWe list the most frequently used macros below.  For a complete list,\nsee file [include/gtest/internal/gtest-port.h](include/gtest/internal/gtest-port.h).\n\n### Choosing a TR1 Tuple Library ###\n\nSome Google Test features require the C++ Technical Report 1 (TR1)\ntuple library, which is not yet available with all compilers.  The\ngood news is that Google Test implements a subset of TR1 tuple that's\nenough for its own need, and will automatically use this when the\ncompiler doesn't provide TR1 tuple.\n\nUsually you don't need to care about which tuple library Google Test\nuses.  However, if your project already uses TR1 tuple, you need to\ntell Google Test to use the same TR1 tuple library the rest of your\nproject uses, or the two tuple implementations will clash.  To do\nthat, add\n\n    -DGTEST_USE_OWN_TR1_TUPLE=0\n\nto the compiler flags while compiling Google Test and your tests.  If\nyou want to force Google Test to use its own tuple library, just add\n\n    -DGTEST_USE_OWN_TR1_TUPLE=1\n\nto the compiler flags instead.\n\nIf you don't want Google Test to use tuple at all, add\n\n    -DGTEST_HAS_TR1_TUPLE=0\n\nand all features using tuple will be disabled.\n\n### Multi-threaded Tests ###\n\nGoogle Test is thread-safe where the pthread library is available.\nAfter `#include \"gtest/gtest.h\"`, you can check the `GTEST_IS_THREADSAFE`\nmacro to see whether this is the case (yes if the macro is `#defined` to\n1, no if it's undefined.).\n\nIf Google Test doesn't correctly detect whether pthread is available\nin your environment, you can force it with\n\n    -DGTEST_HAS_PTHREAD=1\n\nor\n\n    -DGTEST_HAS_PTHREAD=0\n\nWhen Google Test uses pthread, you may need to add flags to your\ncompiler and/or linker to select the pthread library, or you'll get\nlink errors.  If you use the CMake script or the deprecated Autotools\nscript, this is taken care of for you.  If you use your own build\nscript, you'll need to read your compiler and linker's manual to\nfigure out what flags to add.\n\n### As a Shared Library (DLL) ###\n\nGoogle Test is compact, so most users can build and link it as a\nstatic library for the simplicity.  You can choose to use Google Test\nas a shared library (known as a DLL on Windows) if you prefer.\n\nTo compile *gtest* as a shared library, add\n\n    -DGTEST_CREATE_SHARED_LIBRARY=1\n\nto the compiler flags.  You'll also need to tell the linker to produce\na shared library instead - consult your linker's manual for how to do\nit.\n\nTo compile your *tests* that use the gtest shared library, add\n\n    -DGTEST_LINKED_AS_SHARED_LIBRARY=1\n\nto the compiler flags.\n\nNote: while the above steps aren't technically necessary today when\nusing some compilers (e.g. GCC), they may become necessary in the\nfuture, if we decide to improve the speed of loading the library (see\n<http://gcc.gnu.org/wiki/Visibility> for details).  Therefore you are\nrecommended to always add the above flags when using Google Test as a\nshared library.  Otherwise a future release of Google Test may break\nyour build script.\n\n### Avoiding Macro Name Clashes ###\n\nIn C++, macros don't obey namespaces.  Therefore two libraries that\nboth define a macro of the same name will clash if you `#include` both\ndefinitions.  In case a Google Test macro clashes with another\nlibrary, you can force Google Test to rename its macro to avoid the\nconflict.\n\nSpecifically, if both Google Test and some other code define macro\nFOO, you can add\n\n    -DGTEST_DONT_DEFINE_FOO=1\n\nto the compiler flags to tell Google Test to change the macro's name\nfrom `FOO` to `GTEST_FOO`.  Currently `FOO` can be `FAIL`, `SUCCEED`,\nor `TEST`.  For example, with `-DGTEST_DONT_DEFINE_TEST=1`, you'll\nneed to write\n\n    GTEST_TEST(SomeTest, DoesThis) { ... }\n\ninstead of\n\n    TEST(SomeTest, DoesThis) { ... }\n\nin order to define a test.\n\n## Developing Google Test ##\n\nThis section discusses how to make your own changes to Google Test.\n\n### Testing Google Test Itself ###\n\nTo make sure your changes work as intended and don't break existing\nfunctionality, you'll want to compile and run Google Test's own tests.\nFor that you can use CMake:\n\n    mkdir mybuild\n    cd mybuild\n    cmake -Dgtest_build_tests=ON ${GTEST_DIR}\n\nMake sure you have Python installed, as some of Google Test's tests\nare written in Python.  If the cmake command complains about not being\nable to find Python (`Could NOT find PythonInterp (missing:\nPYTHON_EXECUTABLE)`), try telling it explicitly where your Python\nexecutable can be found:\n\n    cmake -DPYTHON_EXECUTABLE=path/to/python -Dgtest_build_tests=ON ${GTEST_DIR}\n\nNext, you can build Google Test and all of its own tests.  On \\*nix,\nthis is usually done by 'make'.  To run the tests, do\n\n    make test\n\nAll tests should pass.\n\nNormally you don't need to worry about regenerating the source files,\nunless you need to modify them.  In that case, you should modify the\ncorresponding .pump files instead and run the pump.py Python script to\nregenerate them.  You can find pump.py in the [scripts/](scripts/) directory.\nRead the [Pump manual](docs/PumpManual.md) for how to use it.\n"
  },
  {
    "path": "utils/googletest/googletest/build-aux/.keep",
    "content": ""
  },
  {
    "path": "utils/googletest/googletest/cmake/internal_utils.cmake",
    "content": "# Defines functions and macros useful for building Google Test and\n# Google Mock.\n#\n# Note:\n#\n# - This file will be run twice when building Google Mock (once via\n#   Google Test's CMakeLists.txt, and once via Google Mock's).\n#   Therefore it shouldn't have any side effects other than defining\n#   the functions and macros.\n#\n# - The functions/macros defined in this file may depend on Google\n#   Test and Google Mock's option() definitions, and thus must be\n#   called *after* the options have been defined.\n\n# Tweaks CMake's default compiler/linker settings to suit Google Test's needs.\n#\n# This must be a macro(), as inside a function string() can only\n# update variables in the function scope.\nmacro(fix_default_compiler_settings_)\n  if (MSVC)\n    # For MSVC, CMake sets certain flags to defaults we want to override.\n    # This replacement code is taken from sample in the CMake Wiki at\n    # http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace.\n    foreach (flag_var\n             CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE\n             CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)\n      if (NOT BUILD_SHARED_LIBS AND NOT gtest_force_shared_crt)\n        # When Google Test is built as a shared library, it should also use\n        # shared runtime libraries.  Otherwise, it may end up with multiple\n        # copies of runtime library data in different modules, resulting in\n        # hard-to-find crashes. When it is built as a static library, it is\n        # preferable to use CRT as static libraries, as we don't have to rely\n        # on CRT DLLs being available. CMake always defaults to using shared\n        # CRT libraries, so we override that default here.\n        string(REPLACE \"/MD\" \"-MT\" ${flag_var} \"${${flag_var}}\")\n      endif()\n\n      # We prefer more strict warning checking for building Google Test.\n      # Replaces /W3 with /W4 in defaults.\n      string(REPLACE \"/W3\" \"/W4\" ${flag_var} \"${${flag_var}}\")\n    endforeach()\n  endif()\nendmacro()\n\n# Defines the compiler/linker flags used to build Google Test and\n# Google Mock.  You can tweak these definitions to suit your need.  A\n# variable's value is empty before it's explicitly assigned to.\nmacro(config_compiler_and_linker)\n  if (NOT gtest_disable_pthreads)\n    # Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT.\n    find_package(Threads)\n  endif()\n\n  fix_default_compiler_settings_()\n  if (MSVC)\n    # Newlines inside flags variables break CMake's NMake generator.\n    # TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.\n    set(cxx_base_flags \"-GS -W4 -WX -wd4251 -wd4275 -nologo -J -Zi\")\n    if (MSVC_VERSION LESS 1400)  # 1400 is Visual Studio 2005\n      # Suppress spurious warnings MSVC 7.1 sometimes issues.\n      # Forcing value to bool.\n      set(cxx_base_flags \"${cxx_base_flags} -wd4800\")\n      # Copy constructor and assignment operator could not be generated.\n      set(cxx_base_flags \"${cxx_base_flags} -wd4511 -wd4512\")\n      # Compatibility warnings not applicable to Google Test.\n      # Resolved overload was found by argument-dependent lookup.\n      set(cxx_base_flags \"${cxx_base_flags} -wd4675\")\n    endif()\n    if (MSVC_VERSION LESS 1500)  # 1500 is Visual Studio 2008\n      # Conditional expression is constant.\n      # When compiling with /W4, we get several instances of C4127\n      # (Conditional expression is constant). In our code, we disable that\n      # warning on a case-by-case basis. However, on Visual Studio 2005,\n      # the warning fires on std::list. Therefore on that compiler and earlier,\n      # we disable the warning project-wide.\n      set(cxx_base_flags \"${cxx_base_flags} -wd4127\")\n    endif()\n    if (NOT (MSVC_VERSION LESS 1700))  # 1700 is Visual Studio 2012.\n      # Suppress \"unreachable code\" warning on VS 2012 and later.\n      # http://stackoverflow.com/questions/3232669 explains the issue.\n      set(cxx_base_flags \"${cxx_base_flags} -wd4702\")\n    endif()\n    if (NOT (MSVC_VERSION GREATER 1900))  # 1900 is Visual Studio 2015\n      # BigObj required for tests.\n      set(cxx_base_flags \"${cxx_base_flags} -bigobj\")\n    endif()\n\n    set(cxx_base_flags \"${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32\")\n    set(cxx_base_flags \"${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN\")\n    set(cxx_exception_flags \"-EHsc -D_HAS_EXCEPTIONS=1\")\n    set(cxx_no_exception_flags \"-D_HAS_EXCEPTIONS=0\")\n    set(cxx_no_rtti_flags \"-GR-\")\n  elseif (CMAKE_COMPILER_IS_GNUCXX)\n    set(cxx_base_flags \"-Wall -Wshadow\")\n    set(cxx_exception_flags \"-fexceptions\")\n    set(cxx_no_exception_flags \"-fno-exceptions\")\n    # Until version 4.3.2, GCC doesn't define a macro to indicate\n    # whether RTTI is enabled.  Therefore we define GTEST_HAS_RTTI\n    # explicitly.\n    set(cxx_no_rtti_flags \"-fno-rtti -DGTEST_HAS_RTTI=0\")\n    set(cxx_strict_flags\n      \"-Wextra -Wno-unused-parameter -Wno-missing-field-initializers\")\n  elseif (CMAKE_CXX_COMPILER_ID STREQUAL \"SunPro\")\n    set(cxx_exception_flags \"-features=except\")\n    # Sun Pro doesn't provide macros to indicate whether exceptions and\n    # RTTI are enabled, so we define GTEST_HAS_* explicitly.\n    set(cxx_no_exception_flags \"-features=no%except -DGTEST_HAS_EXCEPTIONS=0\")\n    set(cxx_no_rtti_flags \"-features=no%rtti -DGTEST_HAS_RTTI=0\")\n  elseif (CMAKE_CXX_COMPILER_ID STREQUAL \"VisualAge\" OR\n      CMAKE_CXX_COMPILER_ID STREQUAL \"XL\")\n    # CMake 2.8 changes Visual Age's compiler ID to \"XL\".\n    set(cxx_exception_flags \"-qeh\")\n    set(cxx_no_exception_flags \"-qnoeh\")\n    # Until version 9.0, Visual Age doesn't define a macro to indicate\n    # whether RTTI is enabled.  Therefore we define GTEST_HAS_RTTI\n    # explicitly.\n    set(cxx_no_rtti_flags \"-qnortti -DGTEST_HAS_RTTI=0\")\n  elseif (CMAKE_CXX_COMPILER_ID STREQUAL \"HP\")\n    set(cxx_base_flags \"-AA -mt\")\n    set(cxx_exception_flags \"-DGTEST_HAS_EXCEPTIONS=1\")\n    set(cxx_no_exception_flags \"+noeh -DGTEST_HAS_EXCEPTIONS=0\")\n    # RTTI can not be disabled in HP aCC compiler.\n    set(cxx_no_rtti_flags \"\")\n  endif()\n\n  if (CMAKE_USE_PTHREADS_INIT)  # The pthreads library is available and allowed.\n    set(cxx_base_flags \"${cxx_base_flags} -DGTEST_HAS_PTHREAD=1\")\n  else()\n    set(cxx_base_flags \"${cxx_base_flags} -DGTEST_HAS_PTHREAD=0\")\n  endif()\n\n  # For building gtest's own tests and samples.\n  set(cxx_exception \"${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_exception_flags}\")\n  set(cxx_no_exception\n    \"${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_no_exception_flags}\")\n  set(cxx_default \"${cxx_exception}\")\n  set(cxx_no_rtti \"${cxx_default} ${cxx_no_rtti_flags}\")\n  set(cxx_use_own_tuple \"${cxx_default} -DGTEST_USE_OWN_TR1_TUPLE=1\")\n\n  # For building the gtest libraries.\n  set(cxx_strict \"${cxx_default} ${cxx_strict_flags}\")\nendmacro()\n\n# Defines the gtest & gtest_main libraries.  User tests should link\n# with one of them.\nfunction(cxx_library_with_type name type cxx_flags)\n  # type can be either STATIC or SHARED to denote a static or shared library.\n  # ARGN refers to additional arguments after 'cxx_flags'.\n  add_library(${name} ${type} ${ARGN})\n  set_target_properties(${name}\n    PROPERTIES\n    COMPILE_FLAGS \"${cxx_flags}\")\n  if (BUILD_SHARED_LIBS OR type STREQUAL \"SHARED\")\n    set_target_properties(${name}\n      PROPERTIES\n      COMPILE_DEFINITIONS \"GTEST_CREATE_SHARED_LIBRARY=1\")\n  endif()\n  if (CMAKE_USE_PTHREADS_INIT)\n    target_link_libraries(${name} ${CMAKE_THREAD_LIBS_INIT})\n  endif()\nendfunction()\n\n########################################################################\n#\n# Helper functions for creating build targets.\n\nfunction(cxx_shared_library name cxx_flags)\n  cxx_library_with_type(${name} SHARED \"${cxx_flags}\" ${ARGN})\nendfunction()\n\nfunction(cxx_library name cxx_flags)\n  cxx_library_with_type(${name} \"\" \"${cxx_flags}\" ${ARGN})\nendfunction()\n\n# cxx_executable_with_flags(name cxx_flags libs srcs...)\n#\n# creates a named C++ executable that depends on the given libraries and\n# is built from the given source files with the given compiler flags.\nfunction(cxx_executable_with_flags name cxx_flags libs)\n  add_executable(${name} ${ARGN})\n  if (cxx_flags)\n    set_target_properties(${name}\n      PROPERTIES\n      COMPILE_FLAGS \"${cxx_flags}\")\n  endif()\n  if (BUILD_SHARED_LIBS)\n    set_target_properties(${name}\n      PROPERTIES\n      COMPILE_DEFINITIONS \"GTEST_LINKED_AS_SHARED_LIBRARY=1\")\n  endif()\n  # To support mixing linking in static and dynamic libraries, link each\n  # library in with an extra call to target_link_libraries.\n  foreach (lib \"${libs}\")\n    target_link_libraries(${name} ${lib})\n  endforeach()\nendfunction()\n\n# cxx_executable(name dir lib srcs...)\n#\n# creates a named target that depends on the given libs and is built\n# from the given source files.  dir/name.cc is implicitly included in\n# the source file list.\nfunction(cxx_executable name dir libs)\n  cxx_executable_with_flags(\n    ${name} \"${cxx_default}\" \"${libs}\" \"${dir}/${name}.cc\" ${ARGN})\nendfunction()\n\n# Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE.\nfind_package(PythonInterp)\n\n# cxx_test_with_flags(name cxx_flags libs srcs...)\n#\n# creates a named C++ test that depends on the given libs and is built\n# from the given source files with the given compiler flags.\nfunction(cxx_test_with_flags name cxx_flags libs)\n  cxx_executable_with_flags(${name} \"${cxx_flags}\" \"${libs}\" ${ARGN})\n  add_test(${name} ${name})\nendfunction()\n\n# cxx_test(name libs srcs...)\n#\n# creates a named test target that depends on the given libs and is\n# built from the given source files.  Unlike cxx_test_with_flags,\n# test/name.cc is already implicitly included in the source file list.\nfunction(cxx_test name libs)\n  cxx_test_with_flags(\"${name}\" \"${cxx_default}\" \"${libs}\"\n    \"test/${name}.cc\" ${ARGN})\nendfunction()\n\n# py_test(name)\n#\n# creates a Python test with the given name whose main module is in\n# test/name.py.  It does nothing if Python is not installed.\nfunction(py_test name)\n  # We are not supporting Python tests on Linux yet as they consider\n  # all Linux environments to be google3 and try to use google3 features.\n  if (PYTHONINTERP_FOUND)\n    # ${CMAKE_BINARY_DIR} is known at configuration time, so we can\n    # directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known\n    # only at ctest runtime (by calling ctest -c <Configuration>), so\n    # we have to escape $ to delay variable substitution here.\n    if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)\n      add_test(\n        NAME ${name}\n        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py\n            --build_dir=${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)\n    else (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)\n      add_test(\n        ${name}\n        ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py\n          --build_dir=${CMAKE_CURRENT_BINARY_DIR}/\\${CTEST_CONFIGURATION_TYPE})\n    endif (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)\n  endif()\nendfunction()\n"
  },
  {
    "path": "utils/googletest/googletest/codegear/gtest.cbproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <PropertyGroup>\r\n    <ProjectGuid>{bca37a72-5b07-46cf-b44e-89f8e06451a2}</ProjectGuid>\r\n    <Config Condition=\"'$(Config)'==''\">Release</Config>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Base' or '$(Base)'!=''\">\r\n    <Base>true</Base>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Debug' or '$(Cfg_1)'!=''\">\r\n    <Base>true</Base>\r\n    <Cfg_1>true</Cfg_1>\r\n    <CfgParent>Base</CfgParent>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Release' or '$(Cfg_2)'!=''\">\r\n    <Base>true</Base>\r\n    <Cfg_2>true</Cfg_2>\r\n    <CfgParent>Base</CfgParent>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Base)'!=''\">\r\n    <BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>\r\n    <OutputExt>lib</OutputExt>\r\n    <DCC_CBuilderOutput>JPHNE</DCC_CBuilderOutput>\r\n    <Defines>NO_STRICT</Defines>\r\n    <DynamicRTL>true</DynamicRTL>\r\n    <UsePackages>true</UsePackages>\r\n    <ProjectType>CppStaticLibrary</ProjectType>\r\n    <BCC_CPPCompileAlways>true</BCC_CPPCompileAlways>\r\n    <PackageImports>rtl.bpi;vcl.bpi;bcbie.bpi;vclx.bpi;vclactnband.bpi;xmlrtl.bpi;bcbsmp.bpi;dbrtl.bpi;vcldb.bpi;bdertl.bpi;vcldbx.bpi;dsnap.bpi;dsnapcon.bpi;vclib.bpi;ibxpress.bpi;adortl.bpi;dbxcds.bpi;dbexpress.bpi;DbxCommonDriver.bpi;websnap.bpi;vclie.bpi;webdsnap.bpi;inet.bpi;inetdbbde.bpi;inetdbxpress.bpi;soaprtl.bpi;Rave75VCL.bpi;teeUI.bpi;tee.bpi;teedb.bpi;IndyCore.bpi;IndySystem.bpi;IndyProtocols.bpi;IntrawebDB_90_100.bpi;Intraweb_90_100.bpi;dclZipForged11.bpi;vclZipForged11.bpi;GR32_BDS2006.bpi;GR32_DSGN_BDS2006.bpi;Jcl.bpi;JclVcl.bpi;JvCoreD11R.bpi;JvSystemD11R.bpi;JvStdCtrlsD11R.bpi;JvAppFrmD11R.bpi;JvBandsD11R.bpi;JvDBD11R.bpi;JvDlgsD11R.bpi;JvBDED11R.bpi;JvCmpD11R.bpi;JvCryptD11R.bpi;JvCtrlsD11R.bpi;JvCustomD11R.bpi;JvDockingD11R.bpi;JvDotNetCtrlsD11R.bpi;JvEDID11R.bpi;JvGlobusD11R.bpi;JvHMID11R.bpi;JvInterpreterD11R.bpi;JvJansD11R.bpi;JvManagedThreadsD11R.bpi;JvMMD11R.bpi;JvNetD11R.bpi;JvPageCompsD11R.bpi;JvPluginD11R.bpi;JvPrintPreviewD11R.bpi;JvRuntimeDesignD11R.bpi;JvTimeFrameworkD11R.bpi;JvValidatorsD11R.bpi;JvWizardD11R.bpi;JvXPCtrlsD11R.bpi;VclSmp.bpi;CExceptionExpert11.bpi</PackageImports>\r\n    <BCC_wpar>false</BCC_wpar>\r\n    <IncludePath>$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\include;..</IncludePath>\r\n    <AllPackageLibs>rtl.lib;vcl.lib</AllPackageLibs>\r\n    <TLIB_PageSize>32</TLIB_PageSize>\r\n    <ILINK_LibraryPath>$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk</ILINK_LibraryPath>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Cfg_1)'!=''\">\r\n    <BCC_OptimizeForSpeed>false</BCC_OptimizeForSpeed>\r\n    <DCC_Optimize>false</DCC_Optimize>\r\n    <DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>\r\n    <Defines>_DEBUG;$(Defines)</Defines>\r\n    <ILINK_FullDebugInfo>true</ILINK_FullDebugInfo>\r\n    <BCC_InlineFunctionExpansion>false</BCC_InlineFunctionExpansion>\r\n    <ILINK_DisableIncrementalLinking>true</ILINK_DisableIncrementalLinking>\r\n    <BCC_UseRegisterVariables>None</BCC_UseRegisterVariables>\r\n    <DCC_Define>DEBUG</DCC_Define>\r\n    <BCC_DebugLineNumbers>true</BCC_DebugLineNumbers>\r\n    <IntermediateOutputDir>Debug</IntermediateOutputDir>\r\n    <TASM_DisplaySourceLines>true</TASM_DisplaySourceLines>\r\n    <BCC_StackFrames>true</BCC_StackFrames>\r\n    <BCC_DisableOptimizations>true</BCC_DisableOptimizations>\r\n    <ILINK_LibraryPath>$(BDS)\\lib\\debug;$(ILINK_LibraryPath)</ILINK_LibraryPath>\r\n    <TASM_Debugging>Full</TASM_Debugging>\r\n    <BCC_SourceDebuggingOn>true</BCC_SourceDebuggingOn>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Cfg_2)'!=''\">\r\n    <Defines>NDEBUG;$(Defines)</Defines>\r\n    <IntermediateOutputDir>Release</IntermediateOutputDir>\r\n    <ILINK_LibraryPath>$(BDS)\\lib\\release;$(ILINK_LibraryPath)</ILINK_LibraryPath>\r\n    <TASM_Debugging>None</TASM_Debugging>\r\n  </PropertyGroup>\r\n  <ProjectExtensions>\r\n    <Borland.Personality>CPlusPlusBuilder.Personality</Borland.Personality>\r\n    <Borland.ProjectType>CppStaticLibrary</Borland.ProjectType>\r\n    <BorlandProject>\r\n<BorlandProject><CPlusPlusBuilder.Personality><VersionInfo><VersionInfo Name=\"IncludeVerInfo\">False</VersionInfo><VersionInfo Name=\"AutoIncBuild\">False</VersionInfo><VersionInfo Name=\"MajorVer\">1</VersionInfo><VersionInfo Name=\"MinorVer\">0</VersionInfo><VersionInfo Name=\"Release\">0</VersionInfo><VersionInfo Name=\"Build\">0</VersionInfo><VersionInfo Name=\"Debug\">False</VersionInfo><VersionInfo Name=\"PreRelease\">False</VersionInfo><VersionInfo Name=\"Special\">False</VersionInfo><VersionInfo Name=\"Private\">False</VersionInfo><VersionInfo Name=\"DLL\">False</VersionInfo><VersionInfo Name=\"Locale\">1033</VersionInfo><VersionInfo Name=\"CodePage\">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name=\"CompanyName\"></VersionInfoKeys><VersionInfoKeys Name=\"FileDescription\"></VersionInfoKeys><VersionInfoKeys Name=\"FileVersion\">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name=\"InternalName\"></VersionInfoKeys><VersionInfoKeys Name=\"LegalCopyright\"></VersionInfoKeys><VersionInfoKeys Name=\"LegalTrademarks\"></VersionInfoKeys><VersionInfoKeys Name=\"OriginalFilename\"></VersionInfoKeys><VersionInfoKeys Name=\"ProductName\"></VersionInfoKeys><VersionInfoKeys Name=\"ProductVersion\">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name=\"Comments\"></VersionInfoKeys></VersionInfoKeys><Debugging><Debugging Name=\"DebugSourceDirs\"></Debugging></Debugging><Parameters><Parameters Name=\"RunParams\"></Parameters><Parameters Name=\"Launcher\"></Parameters><Parameters Name=\"UseLauncher\">False</Parameters><Parameters Name=\"DebugCWD\"></Parameters><Parameters Name=\"HostApplication\"></Parameters><Parameters Name=\"RemoteHost\"></Parameters><Parameters Name=\"RemotePath\"></Parameters><Parameters Name=\"RemoteParams\"></Parameters><Parameters Name=\"RemoteLauncher\"></Parameters><Parameters Name=\"UseRemoteLauncher\">False</Parameters><Parameters Name=\"RemoteCWD\"></Parameters><Parameters Name=\"RemoteDebug\">False</Parameters><Parameters Name=\"Debug Symbols Search Path\"></Parameters><Parameters Name=\"LoadAllSymbols\">True</Parameters><Parameters Name=\"LoadUnspecifiedSymbols\">False</Parameters></Parameters><Excluded_Packages>\r\n      \r\n      \r\n      <Excluded_Packages Name=\"$(BDS)\\bin\\bcboffice2k100.bpl\">CodeGear C++Builder Office 2000 Servers Package</Excluded_Packages>\r\n      <Excluded_Packages Name=\"$(BDS)\\bin\\bcbofficexp100.bpl\">CodeGear C++Builder Office XP Servers Package</Excluded_Packages>\r\n    </Excluded_Packages><Linker><Linker Name=\"LibPrefix\"></Linker><Linker Name=\"LibSuffix\"></Linker><Linker Name=\"LibVersion\"></Linker></Linker><ProjectProperties><ProjectProperties Name=\"AutoShowDeps\">False</ProjectProperties><ProjectProperties Name=\"ManagePaths\">True</ProjectProperties><ProjectProperties Name=\"VerifyPackages\">True</ProjectProperties></ProjectProperties><HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Count\">3</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item0\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\include;..</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item1\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\include;..</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item2\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\src;..\\include</HistoryLists_hlIncludePath></HistoryLists_hlIncludePath><HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Count\">1</HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Item0\">$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk</HistoryLists_hlILINK_LibraryPath></HistoryLists_hlILINK_LibraryPath><HistoryLists_hlDefines><HistoryLists_hlDefines Name=\"Count\">1</HistoryLists_hlDefines><HistoryLists_hlDefines Name=\"Item0\">NO_STRICT</HistoryLists_hlDefines></HistoryLists_hlDefines><HistoryLists_hlTLIB_PageSize><HistoryLists_hlTLIB_PageSize Name=\"Count\">1</HistoryLists_hlTLIB_PageSize><HistoryLists_hlTLIB_PageSize Name=\"Item0\">32</HistoryLists_hlTLIB_PageSize><HistoryLists_hlTLIB_PageSize Name=\"Item1\">16</HistoryLists_hlTLIB_PageSize></HistoryLists_hlTLIB_PageSize></CPlusPlusBuilder.Personality></BorlandProject></BorlandProject>\r\n  </ProjectExtensions>\r\n  <Import Project=\"$(MSBuildBinPath)\\Borland.Cpp.Targets\" />\r\n  <ItemGroup>\r\n    <None Include=\"..\\include\\gtest\\gtest-death-test.h\">\r\n      <BuildOrder>3</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest-message.h\">\r\n      <BuildOrder>4</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest-param-test.h\">\r\n      <BuildOrder>5</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest-spi.h\">\r\n      <BuildOrder>6</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest-test-part.h\">\r\n      <BuildOrder>7</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest-typed-test.h\">\r\n      <BuildOrder>8</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest.h\">\r\n      <BuildOrder>0</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest_pred_impl.h\">\r\n      <BuildOrder>1</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest_prod.h\">\r\n      <BuildOrder>2</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-death-test-internal.h\">\r\n      <BuildOrder>9</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-filepath.h\">\r\n      <BuildOrder>10</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-internal.h\">\r\n      <BuildOrder>11</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-linked_ptr.h\">\r\n      <BuildOrder>12</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-param-util-generated.h\">\r\n      <BuildOrder>14</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-param-util.h\">\r\n      <BuildOrder>13</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-port.h\">\r\n      <BuildOrder>15</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-string.h\">\r\n      <BuildOrder>16</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-type-util.h\">\r\n      <BuildOrder>17</BuildOrder>\r\n    </None>\r\n    <CppCompile Include=\"gtest_all.cc\">\r\n      <BuildOrder>18</BuildOrder>\r\n    </CppCompile>\r\n    <BuildConfiguration Include=\"Debug\">\r\n      <Key>Cfg_1</Key>\r\n    </BuildConfiguration>\r\n    <BuildConfiguration Include=\"Release\">\r\n      <Key>Cfg_2</Key>\r\n    </BuildConfiguration>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "utils/googletest/googletest/codegear/gtest.groupproj",
    "content": "﻿<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <PropertyGroup>\r\n    <ProjectGuid>{c1d923e0-6cba-4332-9b6f-3420acbf5091}</ProjectGuid>\r\n  </PropertyGroup>\r\n  <ItemGroup />\r\n  <ItemGroup>\r\n    <Projects Include=\"gtest.cbproj\" />\r\n    <Projects Include=\"gtest_main.cbproj\" />\r\n    <Projects Include=\"gtest_unittest.cbproj\" />\r\n  </ItemGroup>\r\n  <ProjectExtensions>\r\n    <Borland.Personality>Default.Personality</Borland.Personality>\r\n    <Borland.ProjectType />\r\n    <BorlandProject>\r\n<BorlandProject xmlns=\"\"><Default.Personality></Default.Personality></BorlandProject></BorlandProject>\r\n  </ProjectExtensions>\r\n  <Target Name=\"gtest\">\r\n    <MSBuild Projects=\"gtest.cbproj\" Targets=\"\" />\r\n  </Target>\r\n  <Target Name=\"gtest:Clean\">\r\n    <MSBuild Projects=\"gtest.cbproj\" Targets=\"Clean\" />\r\n  </Target>\r\n  <Target Name=\"gtest:Make\">\r\n    <MSBuild Projects=\"gtest.cbproj\" Targets=\"Make\" />\r\n  </Target>\r\n  <Target Name=\"gtest_main\">\r\n    <MSBuild Projects=\"gtest_main.cbproj\" Targets=\"\" />\r\n  </Target>\r\n  <Target Name=\"gtest_main:Clean\">\r\n    <MSBuild Projects=\"gtest_main.cbproj\" Targets=\"Clean\" />\r\n  </Target>\r\n  <Target Name=\"gtest_main:Make\">\r\n    <MSBuild Projects=\"gtest_main.cbproj\" Targets=\"Make\" />\r\n  </Target>\r\n  <Target Name=\"gtest_unittest\">\r\n    <MSBuild Projects=\"gtest_unittest.cbproj\" Targets=\"\" />\r\n  </Target>\r\n  <Target Name=\"gtest_unittest:Clean\">\r\n    <MSBuild Projects=\"gtest_unittest.cbproj\" Targets=\"Clean\" />\r\n  </Target>\r\n  <Target Name=\"gtest_unittest:Make\">\r\n    <MSBuild Projects=\"gtest_unittest.cbproj\" Targets=\"Make\" />\r\n  </Target>\r\n  <Target Name=\"Build\">\r\n    <CallTarget Targets=\"gtest;gtest_main;gtest_unittest\" />\r\n  </Target>\r\n  <Target Name=\"Clean\">\r\n    <CallTarget Targets=\"gtest:Clean;gtest_main:Clean;gtest_unittest:Clean\" />\r\n  </Target>\r\n  <Target Name=\"Make\">\r\n    <CallTarget Targets=\"gtest:Make;gtest_main:Make;gtest_unittest:Make\" />\r\n  </Target>\r\n  <Import Condition=\"Exists('$(MSBuildBinPath)\\Borland.Group.Targets')\" Project=\"$(MSBuildBinPath)\\Borland.Group.Targets\" />\r\n</Project>"
  },
  {
    "path": "utils/googletest/googletest/codegear/gtest_all.cc",
    "content": "// Copyright 2009, Google Inc.\r\n// All rights reserved.\r\n//\r\n// Redistribution and use in source and binary forms, with or without\r\n// modification, are permitted provided that the following conditions are\r\n// met:\r\n//\r\n//     * Redistributions of source code must retain the above copyright\r\n// notice, this list of conditions and the following disclaimer.\r\n//     * Redistributions in binary form must reproduce the above\r\n// copyright notice, this list of conditions and the following disclaimer\r\n// in the documentation and/or other materials provided with the\r\n// distribution.\r\n//     * Neither the name of Google Inc. nor the names of its\r\n// contributors may be used to endorse or promote products derived from\r\n// this software without specific prior written permission.\r\n//\r\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n//\r\n// Author: Josh Kelley (joshkel@gmail.com)\r\n//\r\n// Google C++ Testing Framework (Google Test)\r\n//\r\n// C++Builder's IDE cannot build a static library from files with hyphens\r\n// in their name.  See http://qc.codegear.com/wc/qcmain.aspx?d=70977 .\r\n// This file serves as a workaround.\r\n\r\n#include \"src/gtest-all.cc\"\r\n"
  },
  {
    "path": "utils/googletest/googletest/codegear/gtest_link.cc",
    "content": "// Copyright 2009, Google Inc.\r\n// All rights reserved.\r\n//\r\n// Redistribution and use in source and binary forms, with or without\r\n// modification, are permitted provided that the following conditions are\r\n// met:\r\n//\r\n//     * Redistributions of source code must retain the above copyright\r\n// notice, this list of conditions and the following disclaimer.\r\n//     * Redistributions in binary form must reproduce the above\r\n// copyright notice, this list of conditions and the following disclaimer\r\n// in the documentation and/or other materials provided with the\r\n// distribution.\r\n//     * Neither the name of Google Inc. nor the names of its\r\n// contributors may be used to endorse or promote products derived from\r\n// this software without specific prior written permission.\r\n//\r\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n//\r\n// Author: Josh Kelley (joshkel@gmail.com)\r\n//\r\n// Google C++ Testing Framework (Google Test)\r\n//\r\n// Links gtest.lib and gtest_main.lib into the current project in C++Builder.\r\n// This means that these libraries can't be renamed, but it's the only way to\r\n// ensure that Debug versus Release test builds are linked against the\r\n// appropriate Debug or Release build of the libraries.\r\n\r\n#pragma link \"gtest.lib\"\r\n#pragma link \"gtest_main.lib\"\r\n"
  },
  {
    "path": "utils/googletest/googletest/codegear/gtest_main.cbproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <PropertyGroup>\r\n    <ProjectGuid>{bca37a72-5b07-46cf-b44e-89f8e06451a2}</ProjectGuid>\r\n    <Config Condition=\"'$(Config)'==''\">Release</Config>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Base' or '$(Base)'!=''\">\r\n    <Base>true</Base>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Debug' or '$(Cfg_1)'!=''\">\r\n    <Base>true</Base>\r\n    <Cfg_1>true</Cfg_1>\r\n    <CfgParent>Base</CfgParent>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Release' or '$(Cfg_2)'!=''\">\r\n    <Base>true</Base>\r\n    <Cfg_2>true</Cfg_2>\r\n    <CfgParent>Base</CfgParent>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Base)'!=''\">\r\n    <BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>\r\n    <OutputExt>lib</OutputExt>\r\n    <DCC_CBuilderOutput>JPHNE</DCC_CBuilderOutput>\r\n    <Defines>NO_STRICT</Defines>\r\n    <DynamicRTL>true</DynamicRTL>\r\n    <UsePackages>true</UsePackages>\r\n    <ProjectType>CppStaticLibrary</ProjectType>\r\n    <BCC_CPPCompileAlways>true</BCC_CPPCompileAlways>\r\n    <PackageImports>rtl.bpi;vcl.bpi;bcbie.bpi;vclx.bpi;vclactnband.bpi;xmlrtl.bpi;bcbsmp.bpi;dbrtl.bpi;vcldb.bpi;bdertl.bpi;vcldbx.bpi;dsnap.bpi;dsnapcon.bpi;vclib.bpi;ibxpress.bpi;adortl.bpi;dbxcds.bpi;dbexpress.bpi;DbxCommonDriver.bpi;websnap.bpi;vclie.bpi;webdsnap.bpi;inet.bpi;inetdbbde.bpi;inetdbxpress.bpi;soaprtl.bpi;Rave75VCL.bpi;teeUI.bpi;tee.bpi;teedb.bpi;IndyCore.bpi;IndySystem.bpi;IndyProtocols.bpi;IntrawebDB_90_100.bpi;Intraweb_90_100.bpi;dclZipForged11.bpi;vclZipForged11.bpi;GR32_BDS2006.bpi;GR32_DSGN_BDS2006.bpi;Jcl.bpi;JclVcl.bpi;JvCoreD11R.bpi;JvSystemD11R.bpi;JvStdCtrlsD11R.bpi;JvAppFrmD11R.bpi;JvBandsD11R.bpi;JvDBD11R.bpi;JvDlgsD11R.bpi;JvBDED11R.bpi;JvCmpD11R.bpi;JvCryptD11R.bpi;JvCtrlsD11R.bpi;JvCustomD11R.bpi;JvDockingD11R.bpi;JvDotNetCtrlsD11R.bpi;JvEDID11R.bpi;JvGlobusD11R.bpi;JvHMID11R.bpi;JvInterpreterD11R.bpi;JvJansD11R.bpi;JvManagedThreadsD11R.bpi;JvMMD11R.bpi;JvNetD11R.bpi;JvPageCompsD11R.bpi;JvPluginD11R.bpi;JvPrintPreviewD11R.bpi;JvRuntimeDesignD11R.bpi;JvTimeFrameworkD11R.bpi;JvValidatorsD11R.bpi;JvWizardD11R.bpi;JvXPCtrlsD11R.bpi;VclSmp.bpi;CExceptionExpert11.bpi</PackageImports>\r\n    <BCC_wpar>false</BCC_wpar>\r\n    <IncludePath>$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\include;..</IncludePath>\r\n    <AllPackageLibs>rtl.lib;vcl.lib</AllPackageLibs>\r\n    <TLIB_PageSize>32</TLIB_PageSize>\r\n    <ILINK_LibraryPath>$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk</ILINK_LibraryPath>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Cfg_1)'!=''\">\r\n    <BCC_OptimizeForSpeed>false</BCC_OptimizeForSpeed>\r\n    <DCC_Optimize>false</DCC_Optimize>\r\n    <DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>\r\n    <Defines>_DEBUG;$(Defines)</Defines>\r\n    <ILINK_FullDebugInfo>true</ILINK_FullDebugInfo>\r\n    <BCC_InlineFunctionExpansion>false</BCC_InlineFunctionExpansion>\r\n    <ILINK_DisableIncrementalLinking>true</ILINK_DisableIncrementalLinking>\r\n    <BCC_UseRegisterVariables>None</BCC_UseRegisterVariables>\r\n    <DCC_Define>DEBUG</DCC_Define>\r\n    <BCC_DebugLineNumbers>true</BCC_DebugLineNumbers>\r\n    <IntermediateOutputDir>Debug</IntermediateOutputDir>\r\n    <TASM_DisplaySourceLines>true</TASM_DisplaySourceLines>\r\n    <BCC_StackFrames>true</BCC_StackFrames>\r\n    <BCC_DisableOptimizations>true</BCC_DisableOptimizations>\r\n    <ILINK_LibraryPath>$(BDS)\\lib\\debug;$(ILINK_LibraryPath)</ILINK_LibraryPath>\r\n    <TASM_Debugging>Full</TASM_Debugging>\r\n    <BCC_SourceDebuggingOn>true</BCC_SourceDebuggingOn>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Cfg_2)'!=''\">\r\n    <Defines>NDEBUG;$(Defines)</Defines>\r\n    <IntermediateOutputDir>Release</IntermediateOutputDir>\r\n    <ILINK_LibraryPath>$(BDS)\\lib\\release;$(ILINK_LibraryPath)</ILINK_LibraryPath>\r\n    <TASM_Debugging>None</TASM_Debugging>\r\n  </PropertyGroup>\r\n  <ProjectExtensions>\r\n    <Borland.Personality>CPlusPlusBuilder.Personality</Borland.Personality>\r\n    <Borland.ProjectType>CppStaticLibrary</Borland.ProjectType>\r\n    <BorlandProject>\r\n<BorlandProject><CPlusPlusBuilder.Personality><VersionInfo><VersionInfo Name=\"IncludeVerInfo\">False</VersionInfo><VersionInfo Name=\"AutoIncBuild\">False</VersionInfo><VersionInfo Name=\"MajorVer\">1</VersionInfo><VersionInfo Name=\"MinorVer\">0</VersionInfo><VersionInfo Name=\"Release\">0</VersionInfo><VersionInfo Name=\"Build\">0</VersionInfo><VersionInfo Name=\"Debug\">False</VersionInfo><VersionInfo Name=\"PreRelease\">False</VersionInfo><VersionInfo Name=\"Special\">False</VersionInfo><VersionInfo Name=\"Private\">False</VersionInfo><VersionInfo Name=\"DLL\">False</VersionInfo><VersionInfo Name=\"Locale\">1033</VersionInfo><VersionInfo Name=\"CodePage\">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name=\"CompanyName\"></VersionInfoKeys><VersionInfoKeys Name=\"FileDescription\"></VersionInfoKeys><VersionInfoKeys Name=\"FileVersion\">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name=\"InternalName\"></VersionInfoKeys><VersionInfoKeys Name=\"LegalCopyright\"></VersionInfoKeys><VersionInfoKeys Name=\"LegalTrademarks\"></VersionInfoKeys><VersionInfoKeys Name=\"OriginalFilename\"></VersionInfoKeys><VersionInfoKeys Name=\"ProductName\"></VersionInfoKeys><VersionInfoKeys Name=\"ProductVersion\">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name=\"Comments\"></VersionInfoKeys></VersionInfoKeys><Debugging><Debugging Name=\"DebugSourceDirs\"></Debugging></Debugging><Parameters><Parameters Name=\"RunParams\"></Parameters><Parameters Name=\"Launcher\"></Parameters><Parameters Name=\"UseLauncher\">False</Parameters><Parameters Name=\"DebugCWD\"></Parameters><Parameters Name=\"HostApplication\"></Parameters><Parameters Name=\"RemoteHost\"></Parameters><Parameters Name=\"RemotePath\"></Parameters><Parameters Name=\"RemoteParams\"></Parameters><Parameters Name=\"RemoteLauncher\"></Parameters><Parameters Name=\"UseRemoteLauncher\">False</Parameters><Parameters Name=\"RemoteCWD\"></Parameters><Parameters Name=\"RemoteDebug\">False</Parameters><Parameters Name=\"Debug Symbols Search Path\"></Parameters><Parameters Name=\"LoadAllSymbols\">True</Parameters><Parameters Name=\"LoadUnspecifiedSymbols\">False</Parameters></Parameters><Excluded_Packages>\r\n      <Excluded_Packages Name=\"$(BDS)\\bin\\bcboffice2k100.bpl\">CodeGear C++Builder Office 2000 Servers Package</Excluded_Packages>\r\n      <Excluded_Packages Name=\"$(BDS)\\bin\\bcbofficexp100.bpl\">CodeGear C++Builder Office XP Servers Package</Excluded_Packages>\r\n    </Excluded_Packages><Linker><Linker Name=\"LibPrefix\"></Linker><Linker Name=\"LibSuffix\"></Linker><Linker Name=\"LibVersion\"></Linker></Linker><ProjectProperties><ProjectProperties Name=\"AutoShowDeps\">False</ProjectProperties><ProjectProperties Name=\"ManagePaths\">True</ProjectProperties><ProjectProperties Name=\"VerifyPackages\">True</ProjectProperties></ProjectProperties><HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Count\">3</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item0\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\include;..</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item1\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\include;..</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item2\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\src;..\\include</HistoryLists_hlIncludePath></HistoryLists_hlIncludePath><HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Count\">1</HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Item0\">$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk</HistoryLists_hlILINK_LibraryPath></HistoryLists_hlILINK_LibraryPath><HistoryLists_hlDefines><HistoryLists_hlDefines Name=\"Count\">1</HistoryLists_hlDefines><HistoryLists_hlDefines Name=\"Item0\">NO_STRICT</HistoryLists_hlDefines></HistoryLists_hlDefines><HistoryLists_hlTLIB_PageSize><HistoryLists_hlTLIB_PageSize Name=\"Count\">1</HistoryLists_hlTLIB_PageSize><HistoryLists_hlTLIB_PageSize Name=\"Item0\">32</HistoryLists_hlTLIB_PageSize><HistoryLists_hlTLIB_PageSize Name=\"Item1\">16</HistoryLists_hlTLIB_PageSize></HistoryLists_hlTLIB_PageSize></CPlusPlusBuilder.Personality></BorlandProject></BorlandProject>\r\n  </ProjectExtensions>\r\n  <Import Project=\"$(MSBuildBinPath)\\Borland.Cpp.Targets\" />\r\n  <ItemGroup>\r\n    <CppCompile Include=\"..\\src\\gtest_main.cc\">\r\n      <BuildOrder>0</BuildOrder>\r\n    </CppCompile>\r\n    <BuildConfiguration Include=\"Debug\">\r\n      <Key>Cfg_1</Key>\r\n    </BuildConfiguration>\r\n    <BuildConfiguration Include=\"Release\">\r\n      <Key>Cfg_2</Key>\r\n    </BuildConfiguration>\r\n  </ItemGroup>\r\n</Project>\r\n"
  },
  {
    "path": "utils/googletest/googletest/codegear/gtest_unittest.cbproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <PropertyGroup>\r\n    <ProjectGuid>{eea63393-5ac5-4b9c-8909-d75fef2daa41}</ProjectGuid>\r\n    <Config Condition=\"'$(Config)'==''\">Release</Config>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Base' or '$(Base)'!=''\">\r\n    <Base>true</Base>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Debug' or '$(Cfg_1)'!=''\">\r\n    <Base>true</Base>\r\n    <Cfg_1>true</Cfg_1>\r\n    <CfgParent>Base</CfgParent>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Release' or '$(Cfg_2)'!=''\">\r\n    <Base>true</Base>\r\n    <Cfg_2>true</Cfg_2>\r\n    <CfgParent>Base</CfgParent>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Base)'!=''\">\r\n    <OutputExt>exe</OutputExt>\r\n    <BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>\r\n    <Defines>NO_STRICT</Defines>\r\n    <DCC_CBuilderOutput>JPHNE</DCC_CBuilderOutput>\r\n    <DynamicRTL>true</DynamicRTL>\r\n    <ILINK_ObjectSearchPath>..\\test</ILINK_ObjectSearchPath>\r\n    <UsePackages>true</UsePackages>\r\n    <ProjectType>CppConsoleApplication</ProjectType>\r\n    <NoVCL>true</NoVCL>\r\n    <BCC_CPPCompileAlways>true</BCC_CPPCompileAlways>\r\n    <PackageImports>rtl.bpi;vcl.bpi;bcbie.bpi;vclx.bpi;vclactnband.bpi;xmlrtl.bpi;bcbsmp.bpi;dbrtl.bpi;vcldb.bpi;bdertl.bpi;vcldbx.bpi;dsnap.bpi;dsnapcon.bpi;vclib.bpi;ibxpress.bpi;adortl.bpi;dbxcds.bpi;dbexpress.bpi;DbxCommonDriver.bpi;websnap.bpi;vclie.bpi;webdsnap.bpi;inet.bpi;inetdbbde.bpi;inetdbxpress.bpi;soaprtl.bpi;Rave75VCL.bpi;teeUI.bpi;tee.bpi;teedb.bpi;IndyCore.bpi;IndySystem.bpi;IndyProtocols.bpi;IntrawebDB_90_100.bpi;Intraweb_90_100.bpi;Jcl.bpi;JclVcl.bpi;JvCoreD11R.bpi;JvSystemD11R.bpi;JvStdCtrlsD11R.bpi;JvAppFrmD11R.bpi;JvBandsD11R.bpi;JvDBD11R.bpi;JvDlgsD11R.bpi;JvBDED11R.bpi;JvCmpD11R.bpi;JvCryptD11R.bpi;JvCtrlsD11R.bpi;JvCustomD11R.bpi;JvDockingD11R.bpi;JvDotNetCtrlsD11R.bpi;JvEDID11R.bpi;JvGlobusD11R.bpi;JvHMID11R.bpi;JvInterpreterD11R.bpi;JvJansD11R.bpi;JvManagedThreadsD11R.bpi;JvMMD11R.bpi;JvNetD11R.bpi;JvPageCompsD11R.bpi;JvPluginD11R.bpi;JvPrintPreviewD11R.bpi;JvRuntimeDesignD11R.bpi;JvTimeFrameworkD11R.bpi;JvValidatorsD11R.bpi;JvWizardD11R.bpi;JvXPCtrlsD11R.bpi;VclSmp.bpi</PackageImports>\r\n    <BCC_wpar>false</BCC_wpar>\r\n    <IncludePath>$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\include;..\\test;..</IncludePath>\r\n    <ILINK_LibraryPath>$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk;..\\test</ILINK_LibraryPath>\r\n    <Multithreaded>true</Multithreaded>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Cfg_1)'!=''\">\r\n    <BCC_OptimizeForSpeed>false</BCC_OptimizeForSpeed>\r\n    <DCC_Optimize>false</DCC_Optimize>\r\n    <DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>\r\n    <Defines>_DEBUG;$(Defines)</Defines>\r\n    <ILINK_FullDebugInfo>true</ILINK_FullDebugInfo>\r\n    <BCC_InlineFunctionExpansion>false</BCC_InlineFunctionExpansion>\r\n    <ILINK_DisableIncrementalLinking>true</ILINK_DisableIncrementalLinking>\r\n    <BCC_UseRegisterVariables>None</BCC_UseRegisterVariables>\r\n    <DCC_Define>DEBUG</DCC_Define>\r\n    <BCC_DebugLineNumbers>true</BCC_DebugLineNumbers>\r\n    <IntermediateOutputDir>Debug</IntermediateOutputDir>\r\n    <TASM_DisplaySourceLines>true</TASM_DisplaySourceLines>\r\n    <BCC_StackFrames>true</BCC_StackFrames>\r\n    <BCC_DisableOptimizations>true</BCC_DisableOptimizations>\r\n    <ILINK_LibraryPath>$(BDS)\\lib\\debug;$(ILINK_LibraryPath)</ILINK_LibraryPath>\r\n    <TASM_Debugging>Full</TASM_Debugging>\r\n    <BCC_SourceDebuggingOn>true</BCC_SourceDebuggingOn>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Cfg_2)'!=''\">\r\n    <Defines>NDEBUG;$(Defines)</Defines>\r\n    <IntermediateOutputDir>Release</IntermediateOutputDir>\r\n    <ILINK_LibraryPath>$(BDS)\\lib\\release;$(ILINK_LibraryPath)</ILINK_LibraryPath>\r\n    <TASM_Debugging>None</TASM_Debugging>\r\n  </PropertyGroup>\r\n  <ProjectExtensions>\r\n    <Borland.Personality>CPlusPlusBuilder.Personality</Borland.Personality>\r\n    <Borland.ProjectType>CppConsoleApplication</Borland.ProjectType>\r\n    <BorlandProject>\r\n<BorlandProject><CPlusPlusBuilder.Personality><VersionInfo><VersionInfo Name=\"IncludeVerInfo\">False</VersionInfo><VersionInfo Name=\"AutoIncBuild\">False</VersionInfo><VersionInfo Name=\"MajorVer\">1</VersionInfo><VersionInfo Name=\"MinorVer\">0</VersionInfo><VersionInfo Name=\"Release\">0</VersionInfo><VersionInfo Name=\"Build\">0</VersionInfo><VersionInfo Name=\"Debug\">False</VersionInfo><VersionInfo Name=\"PreRelease\">False</VersionInfo><VersionInfo Name=\"Special\">False</VersionInfo><VersionInfo Name=\"Private\">False</VersionInfo><VersionInfo Name=\"DLL\">False</VersionInfo><VersionInfo Name=\"Locale\">1033</VersionInfo><VersionInfo Name=\"CodePage\">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name=\"CompanyName\"></VersionInfoKeys><VersionInfoKeys Name=\"FileDescription\"></VersionInfoKeys><VersionInfoKeys Name=\"FileVersion\">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name=\"InternalName\"></VersionInfoKeys><VersionInfoKeys Name=\"LegalCopyright\"></VersionInfoKeys><VersionInfoKeys Name=\"LegalTrademarks\"></VersionInfoKeys><VersionInfoKeys Name=\"OriginalFilename\"></VersionInfoKeys><VersionInfoKeys Name=\"ProductName\"></VersionInfoKeys><VersionInfoKeys Name=\"ProductVersion\">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name=\"Comments\"></VersionInfoKeys></VersionInfoKeys><Debugging><Debugging Name=\"DebugSourceDirs\"></Debugging></Debugging><Parameters><Parameters Name=\"RunParams\"></Parameters><Parameters Name=\"Launcher\"></Parameters><Parameters Name=\"UseLauncher\">False</Parameters><Parameters Name=\"DebugCWD\"></Parameters><Parameters Name=\"HostApplication\"></Parameters><Parameters Name=\"RemoteHost\"></Parameters><Parameters Name=\"RemotePath\"></Parameters><Parameters Name=\"RemoteParams\"></Parameters><Parameters Name=\"RemoteLauncher\"></Parameters><Parameters Name=\"UseRemoteLauncher\">False</Parameters><Parameters Name=\"RemoteCWD\"></Parameters><Parameters Name=\"RemoteDebug\">False</Parameters><Parameters Name=\"Debug Symbols Search Path\"></Parameters><Parameters Name=\"LoadAllSymbols\">True</Parameters><Parameters Name=\"LoadUnspecifiedSymbols\">False</Parameters></Parameters><Excluded_Packages>\r\n      \r\n      \r\n      <Excluded_Packages Name=\"$(BDS)\\bin\\bcboffice2k100.bpl\">CodeGear C++Builder Office 2000 Servers Package</Excluded_Packages>\r\n      <Excluded_Packages Name=\"$(BDS)\\bin\\bcbofficexp100.bpl\">CodeGear C++Builder Office XP Servers Package</Excluded_Packages>\r\n    </Excluded_Packages><Linker><Linker Name=\"LibPrefix\"></Linker><Linker Name=\"LibSuffix\"></Linker><Linker Name=\"LibVersion\"></Linker></Linker><ProjectProperties><ProjectProperties Name=\"AutoShowDeps\">False</ProjectProperties><ProjectProperties Name=\"ManagePaths\">True</ProjectProperties><ProjectProperties Name=\"VerifyPackages\">True</ProjectProperties></ProjectProperties><HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Count\">3</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item0\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\include;..\\test;..</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item1\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\include;..\\test</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item2\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\include</HistoryLists_hlIncludePath></HistoryLists_hlIncludePath><HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Count\">1</HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Item0\">$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk;..\\test</HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Item1\">$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk;..\\test</HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Item2\">$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk;$(OUTPUTDIR);..\\test</HistoryLists_hlILINK_LibraryPath></HistoryLists_hlILINK_LibraryPath><HistoryLists_hlDefines><HistoryLists_hlDefines Name=\"Count\">2</HistoryLists_hlDefines><HistoryLists_hlDefines Name=\"Item0\">NO_STRICT</HistoryLists_hlDefines><HistoryLists_hlDefines Name=\"Item1\">STRICT</HistoryLists_hlDefines></HistoryLists_hlDefines></CPlusPlusBuilder.Personality></BorlandProject></BorlandProject>\r\n  </ProjectExtensions>\r\n  <Import Project=\"$(MSBuildBinPath)\\Borland.Cpp.Targets\" />\r\n  <ItemGroup>\r\n    <CppCompile Include=\"..\\test\\gtest_unittest.cc\">\r\n      <BuildOrder>0</BuildOrder>\r\n    </CppCompile>\r\n    <CppCompile Include=\"gtest_link.cc\">\r\n      <BuildOrder>1</BuildOrder>\r\n    </CppCompile>\r\n    <BuildConfiguration Include=\"Debug\">\r\n      <Key>Cfg_1</Key>\r\n    </BuildConfiguration>\r\n    <BuildConfiguration Include=\"Release\">\r\n      <Key>Cfg_2</Key>\r\n    </BuildConfiguration>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "utils/googletest/googletest/configure.ac",
    "content": "m4_include(m4/acx_pthread.m4)\n\n# At this point, the Xcode project assumes the version string will be three\n# integers separated by periods and surrounded by square brackets (e.g.\n# \"[1.0.1]\"). It also asumes that there won't be any closing parenthesis\n# between \"AC_INIT(\" and the closing \")\" including comments and strings.\nAC_INIT([Google C++ Testing Framework],\n        [1.7.0],\n        [googletestframework@googlegroups.com],\n        [gtest])\n\n# Provide various options to initialize the Autoconf and configure processes.\nAC_PREREQ([2.59])\nAC_CONFIG_SRCDIR([./LICENSE])\nAC_CONFIG_MACRO_DIR([m4])\nAC_CONFIG_AUX_DIR([build-aux])\nAC_CONFIG_HEADERS([build-aux/config.h])\nAC_CONFIG_FILES([Makefile])\nAC_CONFIG_FILES([scripts/gtest-config], [chmod +x scripts/gtest-config])\n\n# Initialize Automake with various options. We require at least v1.9, prevent\n# pedantic complaints about package files, and enable various distribution\n# targets.\nAM_INIT_AUTOMAKE([1.9 dist-bzip2 dist-zip foreign subdir-objects])\n\n# Check for programs used in building Google Test.\nAC_PROG_CC\nAC_PROG_CXX\nAC_LANG([C++])\nAC_PROG_LIBTOOL\n\n# TODO(chandlerc@google.com): Currently we aren't running the Python tests\n# against the interpreter detected by AM_PATH_PYTHON, and so we condition\n# HAVE_PYTHON by requiring \"python\" to be in the PATH, and that interpreter's\n# version to be >= 2.3. This will allow the scripts to use a \"/usr/bin/env\"\n# hashbang.\nPYTHON=  # We *do not* allow the user to specify a python interpreter\nAC_PATH_PROG([PYTHON],[python],[:])\nAS_IF([test \"$PYTHON\" != \":\"],\n      [AM_PYTHON_CHECK_VERSION([$PYTHON],[2.3],[:],[PYTHON=\":\"])])\nAM_CONDITIONAL([HAVE_PYTHON],[test \"$PYTHON\" != \":\"])\n\n# Configure pthreads.\nAC_ARG_WITH([pthreads],\n            [AS_HELP_STRING([--with-pthreads],\n               [use pthreads (default is yes)])],\n            [with_pthreads=$withval],\n            [with_pthreads=check])\n\nhave_pthreads=no\nAS_IF([test \"x$with_pthreads\" != \"xno\"],\n      [ACX_PTHREAD(\n        [],\n        [AS_IF([test \"x$with_pthreads\" != \"xcheck\"],\n               [AC_MSG_FAILURE(\n                 [--with-pthreads was specified, but unable to be used])])])\n       have_pthreads=\"$acx_pthread_ok\"])\nAM_CONDITIONAL([HAVE_PTHREADS],[test \"x$have_pthreads\" = \"xyes\"])\nAC_SUBST(PTHREAD_CFLAGS)\nAC_SUBST(PTHREAD_LIBS)\n\n# TODO(chandlerc@google.com) Check for the necessary system headers.\n\n# TODO(chandlerc@google.com) Check the types, structures, and other compiler\n# and architecture characteristics.\n\n# Output the generated files. No further autoconf macros may be used.\nAC_OUTPUT\n"
  },
  {
    "path": "utils/googletest/googletest/docs/AdvancedGuide.md",
    "content": "\n\nNow that you have read [Primer](Primer.md) and learned how to write tests\nusing Google Test, it's time to learn some new tricks. This document\nwill show you more assertions as well as how to construct complex\nfailure messages, propagate fatal failures, reuse and speed up your\ntest fixtures, and use various flags with your tests.\n\n# More Assertions #\n\nThis section covers some less frequently used, but still significant,\nassertions.\n\n## Explicit Success and Failure ##\n\nThese three assertions do not actually test a value or expression. Instead,\nthey generate a success or failure directly. Like the macros that actually\nperform a test, you may stream a custom failure message into the them.\n\n| `SUCCEED();` |\n|:-------------|\n\nGenerates a success. This does NOT make the overall test succeed. A test is\nconsidered successful only if none of its assertions fail during its execution.\n\nNote: `SUCCEED()` is purely documentary and currently doesn't generate any\nuser-visible output. However, we may add `SUCCEED()` messages to Google Test's\noutput in the future.\n\n| `FAIL();`  | `ADD_FAILURE();` | `ADD_FAILURE_AT(\"`_file\\_path_`\", `_line\\_number_`);` |\n|:-----------|:-----------------|:------------------------------------------------------|\n\n`FAIL()` generates a fatal failure, while `ADD_FAILURE()` and `ADD_FAILURE_AT()` generate a nonfatal\nfailure. These are useful when control flow, rather than a Boolean expression,\ndeteremines the test's success or failure. For example, you might want to write\nsomething like:\n\n```\nswitch(expression) {\n  case 1: ... some checks ...\n  case 2: ... some other checks\n  ...\n  default: FAIL() << \"We shouldn't get here.\";\n}\n```\n\nNote: you can only use `FAIL()` in functions that return `void`. See the [Assertion Placement section](#assertion-placement) for more information.\n\n_Availability_: Linux, Windows, Mac.\n\n## Exception Assertions ##\n\nThese are for verifying that a piece of code throws (or does not\nthrow) an exception of the given type:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_THROW(`_statement_, _exception\\_type_`);`  | `EXPECT_THROW(`_statement_, _exception\\_type_`);`  | _statement_ throws an exception of the given type  |\n| `ASSERT_ANY_THROW(`_statement_`);`                | `EXPECT_ANY_THROW(`_statement_`);`                | _statement_ throws an exception of any type        |\n| `ASSERT_NO_THROW(`_statement_`);`                 | `EXPECT_NO_THROW(`_statement_`);`                 | _statement_ doesn't throw any exception            |\n\nExamples:\n\n```\nASSERT_THROW(Foo(5), bar_exception);\n\nEXPECT_NO_THROW({\n  int n = 5;\n  Bar(&n);\n});\n```\n\n_Availability_: Linux, Windows, Mac; since version 1.1.0.\n\n## Predicate Assertions for Better Error Messages ##\n\nEven though Google Test has a rich set of assertions, they can never be\ncomplete, as it's impossible (nor a good idea) to anticipate all the scenarios\na user might run into. Therefore, sometimes a user has to use `EXPECT_TRUE()`\nto check a complex expression, for lack of a better macro. This has the problem\nof not showing you the values of the parts of the expression, making it hard to\nunderstand what went wrong. As a workaround, some users choose to construct the\nfailure message by themselves, streaming it into `EXPECT_TRUE()`. However, this\nis awkward especially when the expression has side-effects or is expensive to\nevaluate.\n\nGoogle Test gives you three different options to solve this problem:\n\n### Using an Existing Boolean Function ###\n\nIf you already have a function or a functor that returns `bool` (or a type\nthat can be implicitly converted to `bool`), you can use it in a _predicate\nassertion_ to get the function arguments printed for free:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_PRED1(`_pred1, val1_`);`       | `EXPECT_PRED1(`_pred1, val1_`);` | _pred1(val1)_ returns true |\n| `ASSERT_PRED2(`_pred2, val1, val2_`);` | `EXPECT_PRED2(`_pred2, val1, val2_`);` |  _pred2(val1, val2)_ returns true |\n|  ...                | ...                    | ...          |\n\nIn the above, _predn_ is an _n_-ary predicate function or functor, where\n_val1_, _val2_, ..., and _valn_ are its arguments. The assertion succeeds\nif the predicate returns `true` when applied to the given arguments, and fails\notherwise. When the assertion fails, it prints the value of each argument. In\neither case, the arguments are evaluated exactly once.\n\nHere's an example. Given\n\n```\n// Returns true iff m and n have no common divisors except 1.\nbool MutuallyPrime(int m, int n) { ... }\nconst int a = 3;\nconst int b = 4;\nconst int c = 10;\n```\n\nthe assertion `EXPECT_PRED2(MutuallyPrime, a, b);` will succeed, while the\nassertion `EXPECT_PRED2(MutuallyPrime, b, c);` will fail with the message\n\n<pre>\n!MutuallyPrime(b, c) is false, where<br>\nb is 4<br>\nc is 10<br>\n</pre>\n\n**Notes:**\n\n  1. If you see a compiler error \"no matching function to call\" when using `ASSERT_PRED*` or `EXPECT_PRED*`, please see [this FAQ](FAQ.md#the-compiler-complains-no-matching-function-to-call-when-i-use-assert_predn-how-do-i-fix-it) for how to resolve it.\n  1. Currently we only provide predicate assertions of arity <= 5. If you need a higher-arity assertion, let us know.\n\n_Availability_: Linux, Windows, Mac\n\n### Using a Function That Returns an AssertionResult ###\n\nWhile `EXPECT_PRED*()` and friends are handy for a quick job, the\nsyntax is not satisfactory: you have to use different macros for\ndifferent arities, and it feels more like Lisp than C++.  The\n`::testing::AssertionResult` class solves this problem.\n\nAn `AssertionResult` object represents the result of an assertion\n(whether it's a success or a failure, and an associated message).  You\ncan create an `AssertionResult` using one of these factory\nfunctions:\n\n```\nnamespace testing {\n\n// Returns an AssertionResult object to indicate that an assertion has\n// succeeded.\nAssertionResult AssertionSuccess();\n\n// Returns an AssertionResult object to indicate that an assertion has\n// failed.\nAssertionResult AssertionFailure();\n\n}\n```\n\nYou can then use the `<<` operator to stream messages to the\n`AssertionResult` object.\n\nTo provide more readable messages in Boolean assertions\n(e.g. `EXPECT_TRUE()`), write a predicate function that returns\n`AssertionResult` instead of `bool`. For example, if you define\n`IsEven()` as:\n\n```\n::testing::AssertionResult IsEven(int n) {\n  if ((n % 2) == 0)\n    return ::testing::AssertionSuccess();\n  else\n    return ::testing::AssertionFailure() << n << \" is odd\";\n}\n```\n\ninstead of:\n\n```\nbool IsEven(int n) {\n  return (n % 2) == 0;\n}\n```\n\nthe failed assertion `EXPECT_TRUE(IsEven(Fib(4)))` will print:\n\n<pre>\nValue of: IsEven(Fib(4))<br>\nActual: false (*3 is odd*)<br>\nExpected: true<br>\n</pre>\n\ninstead of a more opaque\n\n<pre>\nValue of: IsEven(Fib(4))<br>\nActual: false<br>\nExpected: true<br>\n</pre>\n\nIf you want informative messages in `EXPECT_FALSE` and `ASSERT_FALSE`\nas well, and are fine with making the predicate slower in the success\ncase, you can supply a success message:\n\n```\n::testing::AssertionResult IsEven(int n) {\n  if ((n % 2) == 0)\n    return ::testing::AssertionSuccess() << n << \" is even\";\n  else\n    return ::testing::AssertionFailure() << n << \" is odd\";\n}\n```\n\nThen the statement `EXPECT_FALSE(IsEven(Fib(6)))` will print\n\n<pre>\nValue of: IsEven(Fib(6))<br>\nActual: true (8 is even)<br>\nExpected: false<br>\n</pre>\n\n_Availability_: Linux, Windows, Mac; since version 1.4.1.\n\n### Using a Predicate-Formatter ###\n\nIf you find the default message generated by `(ASSERT|EXPECT)_PRED*` and\n`(ASSERT|EXPECT)_(TRUE|FALSE)` unsatisfactory, or some arguments to your\npredicate do not support streaming to `ostream`, you can instead use the\nfollowing _predicate-formatter assertions_ to _fully_ customize how the\nmessage is formatted:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_PRED_FORMAT1(`_pred\\_format1, val1_`);`        | `EXPECT_PRED_FORMAT1(`_pred\\_format1, val1_`);` | _pred\\_format1(val1)_ is successful |\n| `ASSERT_PRED_FORMAT2(`_pred\\_format2, val1, val2_`);` | `EXPECT_PRED_FORMAT2(`_pred\\_format2, val1, val2_`);` | _pred\\_format2(val1, val2)_ is successful |\n| `...`               | `...`                  | `...`        |\n\nThe difference between this and the previous two groups of macros is that instead of\na predicate, `(ASSERT|EXPECT)_PRED_FORMAT*` take a _predicate-formatter_\n(_pred\\_formatn_), which is a function or functor with the signature:\n\n`::testing::AssertionResult PredicateFormattern(const char* `_expr1_`, const char* `_expr2_`, ... const char* `_exprn_`, T1 `_val1_`, T2 `_val2_`, ... Tn `_valn_`);`\n\nwhere _val1_, _val2_, ..., and _valn_ are the values of the predicate\narguments, and _expr1_, _expr2_, ..., and _exprn_ are the corresponding\nexpressions as they appear in the source code. The types `T1`, `T2`, ..., and\n`Tn` can be either value types or reference types. For example, if an\nargument has type `Foo`, you can declare it as either `Foo` or `const Foo&`,\nwhichever is appropriate.\n\nA predicate-formatter returns a `::testing::AssertionResult` object to indicate\nwhether the assertion has succeeded or not. The only way to create such an\nobject is to call one of these factory functions:\n\nAs an example, let's improve the failure message in the previous example, which uses `EXPECT_PRED2()`:\n\n```\n// Returns the smallest prime common divisor of m and n,\n// or 1 when m and n are mutually prime.\nint SmallestPrimeCommonDivisor(int m, int n) { ... }\n\n// A predicate-formatter for asserting that two integers are mutually prime.\n::testing::AssertionResult AssertMutuallyPrime(const char* m_expr,\n                                               const char* n_expr,\n                                               int m,\n                                               int n) {\n  if (MutuallyPrime(m, n))\n    return ::testing::AssertionSuccess();\n\n  return ::testing::AssertionFailure()\n      << m_expr << \" and \" << n_expr << \" (\" << m << \" and \" << n\n      << \") are not mutually prime, \" << \"as they have a common divisor \"\n      << SmallestPrimeCommonDivisor(m, n);\n}\n```\n\nWith this predicate-formatter, we can use\n\n```\nEXPECT_PRED_FORMAT2(AssertMutuallyPrime, b, c);\n```\n\nto generate the message\n\n<pre>\nb and c (4 and 10) are not mutually prime, as they have a common divisor 2.<br>\n</pre>\n\nAs you may have realized, many of the assertions we introduced earlier are\nspecial cases of `(EXPECT|ASSERT)_PRED_FORMAT*`. In fact, most of them are\nindeed defined using `(EXPECT|ASSERT)_PRED_FORMAT*`.\n\n_Availability_: Linux, Windows, Mac.\n\n\n## Floating-Point Comparison ##\n\nComparing floating-point numbers is tricky. Due to round-off errors, it is\nvery unlikely that two floating-points will match exactly. Therefore,\n`ASSERT_EQ` 's naive comparison usually doesn't work. And since floating-points\ncan have a wide value range, no single fixed error bound works. It's better to\ncompare by a fixed relative error bound, except for values close to 0 due to\nthe loss of precision there.\n\nIn general, for floating-point comparison to make sense, the user needs to\ncarefully choose the error bound. If they don't want or care to, comparing in\nterms of Units in the Last Place (ULPs) is a good default, and Google Test\nprovides assertions to do this. Full details about ULPs are quite long; if you\nwant to learn more, see\n[this article on float comparison](http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm).\n\n### Floating-Point Macros ###\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_FLOAT_EQ(`_val1, val2_`);`  | `EXPECT_FLOAT_EQ(`_val1, val2_`);` | the two `float` values are almost equal |\n| `ASSERT_DOUBLE_EQ(`_val1, val2_`);` | `EXPECT_DOUBLE_EQ(`_val1, val2_`);` | the two `double` values are almost equal |\n\nBy \"almost equal\", we mean the two values are within 4 ULP's from each\nother.\n\nThe following assertions allow you to choose the acceptable error bound:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_NEAR(`_val1, val2, abs\\_error_`);` | `EXPECT_NEAR`_(val1, val2, abs\\_error_`);` | the difference between _val1_ and _val2_ doesn't exceed the given absolute error |\n\n_Availability_: Linux, Windows, Mac.\n\n### Floating-Point Predicate-Format Functions ###\n\nSome floating-point operations are useful, but not that often used. In order\nto avoid an explosion of new macros, we provide them as predicate-format\nfunctions that can be used in predicate assertion macros (e.g.\n`EXPECT_PRED_FORMAT2`, etc).\n\n```\nEXPECT_PRED_FORMAT2(::testing::FloatLE, val1, val2);\nEXPECT_PRED_FORMAT2(::testing::DoubleLE, val1, val2);\n```\n\nVerifies that _val1_ is less than, or almost equal to, _val2_. You can\nreplace `EXPECT_PRED_FORMAT2` in the above table with `ASSERT_PRED_FORMAT2`.\n\n_Availability_: Linux, Windows, Mac.\n\n## Windows HRESULT assertions ##\n\nThese assertions test for `HRESULT` success or failure.\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_HRESULT_SUCCEEDED(`_expression_`);` | `EXPECT_HRESULT_SUCCEEDED(`_expression_`);` | _expression_ is a success `HRESULT` |\n| `ASSERT_HRESULT_FAILED(`_expression_`);`    | `EXPECT_HRESULT_FAILED(`_expression_`);`    | _expression_ is a failure `HRESULT` |\n\nThe generated output contains the human-readable error message\nassociated with the `HRESULT` code returned by _expression_.\n\nYou might use them like this:\n\n```\nCComPtr shell;\nASSERT_HRESULT_SUCCEEDED(shell.CoCreateInstance(L\"Shell.Application\"));\nCComVariant empty;\nASSERT_HRESULT_SUCCEEDED(shell->ShellExecute(CComBSTR(url), empty, empty, empty, empty));\n```\n\n_Availability_: Windows.\n\n## Type Assertions ##\n\nYou can call the function\n```\n::testing::StaticAssertTypeEq<T1, T2>();\n```\nto assert that types `T1` and `T2` are the same.  The function does\nnothing if the assertion is satisfied.  If the types are different,\nthe function call will fail to compile, and the compiler error message\nwill likely (depending on the compiler) show you the actual values of\n`T1` and `T2`.  This is mainly useful inside template code.\n\n_Caveat:_ When used inside a member function of a class template or a\nfunction template, `StaticAssertTypeEq<T1, T2>()` is effective _only if_\nthe function is instantiated.  For example, given:\n```\ntemplate <typename T> class Foo {\n public:\n  void Bar() { ::testing::StaticAssertTypeEq<int, T>(); }\n};\n```\nthe code:\n```\nvoid Test1() { Foo<bool> foo; }\n```\nwill _not_ generate a compiler error, as `Foo<bool>::Bar()` is never\nactually instantiated.  Instead, you need:\n```\nvoid Test2() { Foo<bool> foo; foo.Bar(); }\n```\nto cause a compiler error.\n\n_Availability:_ Linux, Windows, Mac; since version 1.3.0.\n\n## Assertion Placement ##\n\nYou can use assertions in any C++ function. In particular, it doesn't\nhave to be a method of the test fixture class. The one constraint is\nthat assertions that generate a fatal failure (`FAIL*` and `ASSERT_*`)\ncan only be used in void-returning functions. This is a consequence of\nGoogle Test not using exceptions. By placing it in a non-void function\nyou'll get a confusing compile error like\n`\"error: void value not ignored as it ought to be\"`.\n\nIf you need to use assertions in a function that returns non-void, one option\nis to make the function return the value in an out parameter instead. For\nexample, you can rewrite `T2 Foo(T1 x)` to `void Foo(T1 x, T2* result)`. You\nneed to make sure that `*result` contains some sensible value even when the\nfunction returns prematurely. As the function now returns `void`, you can use\nany assertion inside of it.\n\nIf changing the function's type is not an option, you should just use\nassertions that generate non-fatal failures, such as `ADD_FAILURE*` and\n`EXPECT_*`.\n\n_Note_: Constructors and destructors are not considered void-returning\nfunctions, according to the C++ language specification, and so you may not use\nfatal assertions in them. You'll get a compilation error if you try. A simple\nworkaround is to transfer the entire body of the constructor or destructor to a\nprivate void-returning method. However, you should be aware that a fatal\nassertion failure in a constructor does not terminate the current test, as your\nintuition might suggest; it merely returns from the constructor early, possibly\nleaving your object in a partially-constructed state. Likewise, a fatal\nassertion failure in a destructor may leave your object in a\npartially-destructed state. Use assertions carefully in these situations!\n\n# Teaching Google Test How to Print Your Values #\n\nWhen a test assertion such as `EXPECT_EQ` fails, Google Test prints the\nargument values to help you debug.  It does this using a\nuser-extensible value printer.\n\nThis printer knows how to print built-in C++ types, native arrays, STL\ncontainers, and any type that supports the `<<` operator.  For other\ntypes, it prints the raw bytes in the value and hopes that you the\nuser can figure it out.\n\nAs mentioned earlier, the printer is _extensible_.  That means\nyou can teach it to do a better job at printing your particular type\nthan to dump the bytes.  To do that, define `<<` for your type:\n\n```\n#include <iostream>\n\nnamespace foo {\n\nclass Bar { ... };  // We want Google Test to be able to print instances of this.\n\n// It's important that the << operator is defined in the SAME\n// namespace that defines Bar.  C++'s look-up rules rely on that.\n::std::ostream& operator<<(::std::ostream& os, const Bar& bar) {\n  return os << bar.DebugString();  // whatever needed to print bar to os\n}\n\n}  // namespace foo\n```\n\nSometimes, this might not be an option: your team may consider it bad\nstyle to have a `<<` operator for `Bar`, or `Bar` may already have a\n`<<` operator that doesn't do what you want (and you cannot change\nit).  If so, you can instead define a `PrintTo()` function like this:\n\n```\n#include <iostream>\n\nnamespace foo {\n\nclass Bar { ... };\n\n// It's important that PrintTo() is defined in the SAME\n// namespace that defines Bar.  C++'s look-up rules rely on that.\nvoid PrintTo(const Bar& bar, ::std::ostream* os) {\n  *os << bar.DebugString();  // whatever needed to print bar to os\n}\n\n}  // namespace foo\n```\n\nIf you have defined both `<<` and `PrintTo()`, the latter will be used\nwhen Google Test is concerned.  This allows you to customize how the value\nappears in Google Test's output without affecting code that relies on the\nbehavior of its `<<` operator.\n\nIf you want to print a value `x` using Google Test's value printer\nyourself, just call `::testing::PrintToString(`_x_`)`, which\nreturns an `std::string`:\n\n```\nvector<pair<Bar, int> > bar_ints = GetBarIntVector();\n\nEXPECT_TRUE(IsCorrectBarIntVector(bar_ints))\n    << \"bar_ints = \" << ::testing::PrintToString(bar_ints);\n```\n\n# Death Tests #\n\nIn many applications, there are assertions that can cause application failure\nif a condition is not met. These sanity checks, which ensure that the program\nis in a known good state, are there to fail at the earliest possible time after\nsome program state is corrupted. If the assertion checks the wrong condition,\nthen the program may proceed in an erroneous state, which could lead to memory\ncorruption, security holes, or worse. Hence it is vitally important to test\nthat such assertion statements work as expected.\n\nSince these precondition checks cause the processes to die, we call such tests\n_death tests_. More generally, any test that checks that a program terminates\n(except by throwing an exception) in an expected fashion is also a death test.\n\nNote that if a piece of code throws an exception, we don't consider it \"death\"\nfor the purpose of death tests, as the caller of the code could catch the exception\nand avoid the crash. If you want to verify exceptions thrown by your code,\nsee [Exception Assertions](#exception-assertions).\n\nIf you want to test `EXPECT_*()/ASSERT_*()` failures in your test code, see [Catching Failures](#catching-failures).\n\n## How to Write a Death Test ##\n\nGoogle Test has the following macros to support death tests:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_DEATH(`_statement, regex_`);` | `EXPECT_DEATH(`_statement, regex_`);` | _statement_ crashes with the given error |\n| `ASSERT_DEATH_IF_SUPPORTED(`_statement, regex_`);` | `EXPECT_DEATH_IF_SUPPORTED(`_statement, regex_`);` | if death tests are supported, verifies that _statement_ crashes with the given error; otherwise verifies nothing |\n| `ASSERT_EXIT(`_statement, predicate, regex_`);` | `EXPECT_EXIT(`_statement, predicate, regex_`);` |_statement_ exits with the given error and its exit code matches _predicate_ |\n\nwhere _statement_ is a statement that is expected to cause the process to\ndie, _predicate_ is a function or function object that evaluates an integer\nexit status, and _regex_ is a regular expression that the stderr output of\n_statement_ is expected to match. Note that _statement_ can be _any valid\nstatement_ (including _compound statement_) and doesn't have to be an\nexpression.\n\nAs usual, the `ASSERT` variants abort the current test function, while the\n`EXPECT` variants do not.\n\n**Note:** We use the word \"crash\" here to mean that the process\nterminates with a _non-zero_ exit status code.  There are two\npossibilities: either the process has called `exit()` or `_exit()`\nwith a non-zero value, or it may be killed by a signal.\n\nThis means that if _statement_ terminates the process with a 0 exit\ncode, it is _not_ considered a crash by `EXPECT_DEATH`.  Use\n`EXPECT_EXIT` instead if this is the case, or if you want to restrict\nthe exit code more precisely.\n\nA predicate here must accept an `int` and return a `bool`. The death test\nsucceeds only if the predicate returns `true`. Google Test defines a few\npredicates that handle the most common cases:\n\n```\n::testing::ExitedWithCode(exit_code)\n```\n\nThis expression is `true` if the program exited normally with the given exit\ncode.\n\n```\n::testing::KilledBySignal(signal_number)  // Not available on Windows.\n```\n\nThis expression is `true` if the program was killed by the given signal.\n\nThe `*_DEATH` macros are convenient wrappers for `*_EXIT` that use a predicate\nthat verifies the process' exit code is non-zero.\n\nNote that a death test only cares about three things:\n\n  1. does _statement_ abort or exit the process?\n  1. (in the case of `ASSERT_EXIT` and `EXPECT_EXIT`) does the exit status satisfy _predicate_?  Or (in the case of `ASSERT_DEATH` and `EXPECT_DEATH`) is the exit status non-zero?  And\n  1. does the stderr output match _regex_?\n\nIn particular, if _statement_ generates an `ASSERT_*` or `EXPECT_*` failure, it will **not** cause the death test to fail, as Google Test assertions don't abort the process.\n\nTo write a death test, simply use one of the above macros inside your test\nfunction. For example,\n\n```\nTEST(MyDeathTest, Foo) {\n  // This death test uses a compound statement.\n  ASSERT_DEATH({ int n = 5; Foo(&n); }, \"Error on line .* of Foo()\");\n}\nTEST(MyDeathTest, NormalExit) {\n  EXPECT_EXIT(NormalExit(), ::testing::ExitedWithCode(0), \"Success\");\n}\nTEST(MyDeathTest, KillMyself) {\n  EXPECT_EXIT(KillMyself(), ::testing::KilledBySignal(SIGKILL), \"Sending myself unblockable signal\");\n}\n```\n\nverifies that:\n\n  * calling `Foo(5)` causes the process to die with the given error message,\n  * calling `NormalExit()` causes the process to print `\"Success\"` to stderr and exit with exit code 0, and\n  * calling `KillMyself()` kills the process with signal `SIGKILL`.\n\nThe test function body may contain other assertions and statements as well, if\nnecessary.\n\n_Important:_ We strongly recommend you to follow the convention of naming your\ntest case (not test) `*DeathTest` when it contains a death test, as\ndemonstrated in the above example. The `Death Tests And Threads` section below\nexplains why.\n\nIf a test fixture class is shared by normal tests and death tests, you\ncan use typedef to introduce an alias for the fixture class and avoid\nduplicating its code:\n```\nclass FooTest : public ::testing::Test { ... };\n\ntypedef FooTest FooDeathTest;\n\nTEST_F(FooTest, DoesThis) {\n  // normal test\n}\n\nTEST_F(FooDeathTest, DoesThat) {\n  // death test\n}\n```\n\n_Availability:_ Linux, Windows (requires MSVC 8.0 or above), Cygwin, and Mac (the latter three are supported since v1.3.0).  `(ASSERT|EXPECT)_DEATH_IF_SUPPORTED` are new in v1.4.0.\n\n## Regular Expression Syntax ##\n\nOn POSIX systems (e.g. Linux, Cygwin, and Mac), Google Test uses the\n[POSIX extended regular expression](http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_04)\nsyntax in death tests. To learn about this syntax, you may want to read this [Wikipedia entry](http://en.wikipedia.org/wiki/Regular_expression#POSIX_Extended_Regular_Expressions).\n\nOn Windows, Google Test uses its own simple regular expression\nimplementation. It lacks many features you can find in POSIX extended\nregular expressions.  For example, we don't support union (`\"x|y\"`),\ngrouping (`\"(xy)\"`), brackets (`\"[xy]\"`), and repetition count\n(`\"x{5,7}\"`), among others. Below is what we do support (Letter `A` denotes a\nliteral character, period (`.`), or a single `\\\\` escape sequence; `x`\nand `y` denote regular expressions.):\n\n| `c` | matches any literal character `c` |\n|:----|:----------------------------------|\n| `\\\\d` | matches any decimal digit         |\n| `\\\\D` | matches any character that's not a decimal digit |\n| `\\\\f` | matches `\\f`                      |\n| `\\\\n` | matches `\\n`                      |\n| `\\\\r` | matches `\\r`                      |\n| `\\\\s` | matches any ASCII whitespace, including `\\n` |\n| `\\\\S` | matches any character that's not a whitespace |\n| `\\\\t` | matches `\\t`                      |\n| `\\\\v` | matches `\\v`                      |\n| `\\\\w` | matches any letter, `_`, or decimal digit |\n| `\\\\W` | matches any character that `\\\\w` doesn't match |\n| `\\\\c` | matches any literal character `c`, which must be a punctuation |\n| `\\\\.` | matches the `.` character         |\n| `.` | matches any single character except `\\n` |\n| `A?` | matches 0 or 1 occurrences of `A` |\n| `A*` | matches 0 or many occurrences of `A` |\n| `A+` | matches 1 or many occurrences of `A` |\n| `^` | matches the beginning of a string (not that of each line) |\n| `$` | matches the end of a string (not that of each line) |\n| `xy` | matches `x` followed by `y`       |\n\nTo help you determine which capability is available on your system,\nGoogle Test defines macro `GTEST_USES_POSIX_RE=1` when it uses POSIX\nextended regular expressions, or `GTEST_USES_SIMPLE_RE=1` when it uses\nthe simple version.  If you want your death tests to work in both\ncases, you can either `#if` on these macros or use the more limited\nsyntax only.\n\n## How It Works ##\n\nUnder the hood, `ASSERT_EXIT()` spawns a new process and executes the\ndeath test statement in that process. The details of of how precisely\nthat happens depend on the platform and the variable\n`::testing::GTEST_FLAG(death_test_style)` (which is initialized from the\ncommand-line flag `--gtest_death_test_style`).\n\n  * On POSIX systems, `fork()` (or `clone()` on Linux) is used to spawn the child, after which:\n    * If the variable's value is `\"fast\"`, the death test statement is immediately executed.\n    * If the variable's value is `\"threadsafe\"`, the child process re-executes the unit test binary just as it was originally invoked, but with some extra flags to cause just the single death test under consideration to be run.\n  * On Windows, the child is spawned using the `CreateProcess()` API, and re-executes the binary to cause just the single death test under consideration to be run - much like the `threadsafe` mode on POSIX.\n\nOther values for the variable are illegal and will cause the death test to\nfail. Currently, the flag's default value is `\"fast\"`. However, we reserve the\nright to change it in the future. Therefore, your tests should not depend on\nthis.\n\nIn either case, the parent process waits for the child process to complete, and checks that\n\n  1. the child's exit status satisfies the predicate, and\n  1. the child's stderr matches the regular expression.\n\nIf the death test statement runs to completion without dying, the child\nprocess will nonetheless terminate, and the assertion fails.\n\n## Death Tests And Threads ##\n\nThe reason for the two death test styles has to do with thread safety. Due to\nwell-known problems with forking in the presence of threads, death tests should\nbe run in a single-threaded context. Sometimes, however, it isn't feasible to\narrange that kind of environment. For example, statically-initialized modules\nmay start threads before main is ever reached. Once threads have been created,\nit may be difficult or impossible to clean them up.\n\nGoogle Test has three features intended to raise awareness of threading issues.\n\n  1. A warning is emitted if multiple threads are running when a death test is encountered.\n  1. Test cases with a name ending in \"DeathTest\" are run before all other tests.\n  1. It uses `clone()` instead of `fork()` to spawn the child process on Linux (`clone()` is not available on Cygwin and Mac), as `fork()` is more likely to cause the child to hang when the parent process has multiple threads.\n\nIt's perfectly fine to create threads inside a death test statement; they are\nexecuted in a separate process and cannot affect the parent.\n\n## Death Test Styles ##\n\nThe \"threadsafe\" death test style was introduced in order to help mitigate the\nrisks of testing in a possibly multithreaded environment. It trades increased\ntest execution time (potentially dramatically so) for improved thread safety.\nWe suggest using the faster, default \"fast\" style unless your test has specific\nproblems with it.\n\nYou can choose a particular style of death tests by setting the flag\nprogrammatically:\n\n```\n::testing::FLAGS_gtest_death_test_style = \"threadsafe\";\n```\n\nYou can do this in `main()` to set the style for all death tests in the\nbinary, or in individual tests. Recall that flags are saved before running each\ntest and restored afterwards, so you need not do that yourself. For example:\n\n```\nTEST(MyDeathTest, TestOne) {\n  ::testing::FLAGS_gtest_death_test_style = \"threadsafe\";\n  // This test is run in the \"threadsafe\" style:\n  ASSERT_DEATH(ThisShouldDie(), \"\");\n}\n\nTEST(MyDeathTest, TestTwo) {\n  // This test is run in the \"fast\" style:\n  ASSERT_DEATH(ThisShouldDie(), \"\");\n}\n\nint main(int argc, char** argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n  ::testing::FLAGS_gtest_death_test_style = \"fast\";\n  return RUN_ALL_TESTS();\n}\n```\n\n## Caveats ##\n\nThe _statement_ argument of `ASSERT_EXIT()` can be any valid C++ statement.\nIf it leaves the current function via a `return` statement or by throwing an exception,\nthe death test is considered to have failed.  Some Google Test macros may return\nfrom the current function (e.g. `ASSERT_TRUE()`), so be sure to avoid them in _statement_.\n\nSince _statement_ runs in the child process, any in-memory side effect (e.g.\nmodifying a variable, releasing memory, etc) it causes will _not_ be observable\nin the parent process. In particular, if you release memory in a death test,\nyour program will fail the heap check as the parent process will never see the\nmemory reclaimed. To solve this problem, you can\n\n  1. try not to free memory in a death test;\n  1. free the memory again in the parent process; or\n  1. do not use the heap checker in your program.\n\nDue to an implementation detail, you cannot place multiple death test\nassertions on the same line; otherwise, compilation will fail with an unobvious\nerror message.\n\nDespite the improved thread safety afforded by the \"threadsafe\" style of death\ntest, thread problems such as deadlock are still possible in the presence of\nhandlers registered with `pthread_atfork(3)`.\n\n# Using Assertions in Sub-routines #\n\n## Adding Traces to Assertions ##\n\nIf a test sub-routine is called from several places, when an assertion\ninside it fails, it can be hard to tell which invocation of the\nsub-routine the failure is from.  You can alleviate this problem using\nextra logging or custom failure messages, but that usually clutters up\nyour tests. A better solution is to use the `SCOPED_TRACE` macro:\n\n| `SCOPED_TRACE(`_message_`);` |\n|:-----------------------------|\n\nwhere _message_ can be anything streamable to `std::ostream`. This\nmacro will cause the current file name, line number, and the given\nmessage to be added in every failure message. The effect will be\nundone when the control leaves the current lexical scope.\n\nFor example,\n\n```\n10: void Sub1(int n) {\n11:   EXPECT_EQ(1, Bar(n));\n12:   EXPECT_EQ(2, Bar(n + 1));\n13: }\n14:\n15: TEST(FooTest, Bar) {\n16:   {\n17:     SCOPED_TRACE(\"A\");  // This trace point will be included in\n18:                         // every failure in this scope.\n19:     Sub1(1);\n20:   }\n21:   // Now it won't.\n22:   Sub1(9);\n23: }\n```\n\ncould result in messages like these:\n\n```\npath/to/foo_test.cc:11: Failure\nValue of: Bar(n)\nExpected: 1\n  Actual: 2\n   Trace:\npath/to/foo_test.cc:17: A\n\npath/to/foo_test.cc:12: Failure\nValue of: Bar(n + 1)\nExpected: 2\n  Actual: 3\n```\n\nWithout the trace, it would've been difficult to know which invocation\nof `Sub1()` the two failures come from respectively. (You could add an\nextra message to each assertion in `Sub1()` to indicate the value of\n`n`, but that's tedious.)\n\nSome tips on using `SCOPED_TRACE`:\n\n  1. With a suitable message, it's often enough to use `SCOPED_TRACE` at the beginning of a sub-routine, instead of at each call site.\n  1. When calling sub-routines inside a loop, make the loop iterator part of the message in `SCOPED_TRACE` such that you can know which iteration the failure is from.\n  1. Sometimes the line number of the trace point is enough for identifying the particular invocation of a sub-routine. In this case, you don't have to choose a unique message for `SCOPED_TRACE`. You can simply use `\"\"`.\n  1. You can use `SCOPED_TRACE` in an inner scope when there is one in the outer scope. In this case, all active trace points will be included in the failure messages, in reverse order they are encountered.\n  1. The trace dump is clickable in Emacs' compilation buffer - hit return on a line number and you'll be taken to that line in the source file!\n\n_Availability:_ Linux, Windows, Mac.\n\n## Propagating Fatal Failures ##\n\nA common pitfall when using `ASSERT_*` and `FAIL*` is not understanding that\nwhen they fail they only abort the _current function_, not the entire test. For\nexample, the following test will segfault:\n```\nvoid Subroutine() {\n  // Generates a fatal failure and aborts the current function.\n  ASSERT_EQ(1, 2);\n  // The following won't be executed.\n  ...\n}\n\nTEST(FooTest, Bar) {\n  Subroutine();\n  // The intended behavior is for the fatal failure\n  // in Subroutine() to abort the entire test.\n  // The actual behavior: the function goes on after Subroutine() returns.\n  int* p = NULL;\n  *p = 3; // Segfault!\n}\n```\n\nSince we don't use exceptions, it is technically impossible to\nimplement the intended behavior here.  To alleviate this, Google Test\nprovides two solutions.  You could use either the\n`(ASSERT|EXPECT)_NO_FATAL_FAILURE` assertions or the\n`HasFatalFailure()` function.  They are described in the following two\nsubsections.\n\n### Asserting on Subroutines ###\n\nAs shown above, if your test calls a subroutine that has an `ASSERT_*`\nfailure in it, the test will continue after the subroutine\nreturns. This may not be what you want.\n\nOften people want fatal failures to propagate like exceptions.  For\nthat Google Test offers the following macros:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_NO_FATAL_FAILURE(`_statement_`);` | `EXPECT_NO_FATAL_FAILURE(`_statement_`);` | _statement_ doesn't generate any new fatal failures in the current thread. |\n\nOnly failures in the thread that executes the assertion are checked to\ndetermine the result of this type of assertions.  If _statement_\ncreates new threads, failures in these threads are ignored.\n\nExamples:\n\n```\nASSERT_NO_FATAL_FAILURE(Foo());\n\nint i;\nEXPECT_NO_FATAL_FAILURE({\n  i = Bar();\n});\n```\n\n_Availability:_ Linux, Windows, Mac. Assertions from multiple threads\nare currently not supported.\n\n### Checking for Failures in the Current Test ###\n\n`HasFatalFailure()` in the `::testing::Test` class returns `true` if an\nassertion in the current test has suffered a fatal failure. This\nallows functions to catch fatal failures in a sub-routine and return\nearly.\n\n```\nclass Test {\n public:\n  ...\n  static bool HasFatalFailure();\n};\n```\n\nThe typical usage, which basically simulates the behavior of a thrown\nexception, is:\n\n```\nTEST(FooTest, Bar) {\n  Subroutine();\n  // Aborts if Subroutine() had a fatal failure.\n  if (HasFatalFailure())\n    return;\n  // The following won't be executed.\n  ...\n}\n```\n\nIf `HasFatalFailure()` is used outside of `TEST()` , `TEST_F()` , or a test\nfixture, you must add the `::testing::Test::` prefix, as in:\n\n```\nif (::testing::Test::HasFatalFailure())\n  return;\n```\n\nSimilarly, `HasNonfatalFailure()` returns `true` if the current test\nhas at least one non-fatal failure, and `HasFailure()` returns `true`\nif the current test has at least one failure of either kind.\n\n_Availability:_ Linux, Windows, Mac.  `HasNonfatalFailure()` and\n`HasFailure()` are available since version 1.4.0.\n\n# Logging Additional Information #\n\nIn your test code, you can call `RecordProperty(\"key\", value)` to log\nadditional information, where `value` can be either a string or an `int`. The _last_ value recorded for a key will be emitted to the XML output\nif you specify one. For example, the test\n\n```\nTEST_F(WidgetUsageTest, MinAndMaxWidgets) {\n  RecordProperty(\"MaximumWidgets\", ComputeMaxUsage());\n  RecordProperty(\"MinimumWidgets\", ComputeMinUsage());\n}\n```\n\nwill output XML like this:\n\n```\n...\n  <testcase name=\"MinAndMaxWidgets\" status=\"run\" time=\"6\" classname=\"WidgetUsageTest\"\n            MaximumWidgets=\"12\"\n            MinimumWidgets=\"9\" />\n...\n```\n\n_Note_:\n  * `RecordProperty()` is a static member of the `Test` class. Therefore it needs to be prefixed with `::testing::Test::` if used outside of the `TEST` body and the test fixture class.\n  * `key` must be a valid XML attribute name, and cannot conflict with the ones already used by Google Test (`name`, `status`, `time`, `classname`, `type_param`, and `value_param`).\n  * Calling `RecordProperty()` outside of the lifespan of a test is allowed. If it's called outside of a test but between a test case's `SetUpTestCase()` and `TearDownTestCase()` methods, it will be attributed to the XML element for the test case. If it's called outside of all test cases (e.g. in a test environment), it will be attributed to the top-level XML element.\n\n_Availability_: Linux, Windows, Mac.\n\n# Sharing Resources Between Tests in the Same Test Case #\n\n\n\nGoogle Test creates a new test fixture object for each test in order to make\ntests independent and easier to debug. However, sometimes tests use resources\nthat are expensive to set up, making the one-copy-per-test model prohibitively\nexpensive.\n\nIf the tests don't change the resource, there's no harm in them sharing a\nsingle resource copy. So, in addition to per-test set-up/tear-down, Google Test\nalso supports per-test-case set-up/tear-down. To use it:\n\n  1. In your test fixture class (say `FooTest` ), define as `static` some member variables to hold the shared resources.\n  1. In the same test fixture class, define a `static void SetUpTestCase()` function (remember not to spell it as **`SetupTestCase`** with a small `u`!) to set up the shared resources and a `static void TearDownTestCase()` function to tear them down.\n\nThat's it! Google Test automatically calls `SetUpTestCase()` before running the\n_first test_ in the `FooTest` test case (i.e. before creating the first\n`FooTest` object), and calls `TearDownTestCase()` after running the _last test_\nin it (i.e. after deleting the last `FooTest` object). In between, the tests\ncan use the shared resources.\n\nRemember that the test order is undefined, so your code can't depend on a test\npreceding or following another. Also, the tests must either not modify the\nstate of any shared resource, or, if they do modify the state, they must\nrestore the state to its original value before passing control to the next\ntest.\n\nHere's an example of per-test-case set-up and tear-down:\n```\nclass FooTest : public ::testing::Test {\n protected:\n  // Per-test-case set-up.\n  // Called before the first test in this test case.\n  // Can be omitted if not needed.\n  static void SetUpTestCase() {\n    shared_resource_ = new ...;\n  }\n\n  // Per-test-case tear-down.\n  // Called after the last test in this test case.\n  // Can be omitted if not needed.\n  static void TearDownTestCase() {\n    delete shared_resource_;\n    shared_resource_ = NULL;\n  }\n\n  // You can define per-test set-up and tear-down logic as usual.\n  virtual void SetUp() { ... }\n  virtual void TearDown() { ... }\n\n  // Some expensive resource shared by all tests.\n  static T* shared_resource_;\n};\n\nT* FooTest::shared_resource_ = NULL;\n\nTEST_F(FooTest, Test1) {\n  ... you can refer to shared_resource here ...\n}\nTEST_F(FooTest, Test2) {\n  ... you can refer to shared_resource here ...\n}\n```\n\n_Availability:_ Linux, Windows, Mac.\n\n# Global Set-Up and Tear-Down #\n\nJust as you can do set-up and tear-down at the test level and the test case\nlevel, you can also do it at the test program level. Here's how.\n\nFirst, you subclass the `::testing::Environment` class to define a test\nenvironment, which knows how to set-up and tear-down:\n\n```\nclass Environment {\n public:\n  virtual ~Environment() {}\n  // Override this to define how to set up the environment.\n  virtual void SetUp() {}\n  // Override this to define how to tear down the environment.\n  virtual void TearDown() {}\n};\n```\n\nThen, you register an instance of your environment class with Google Test by\ncalling the `::testing::AddGlobalTestEnvironment()` function:\n\n```\nEnvironment* AddGlobalTestEnvironment(Environment* env);\n```\n\nNow, when `RUN_ALL_TESTS()` is called, it first calls the `SetUp()` method of\nthe environment object, then runs the tests if there was no fatal failures, and\nfinally calls `TearDown()` of the environment object.\n\nIt's OK to register multiple environment objects. In this case, their `SetUp()`\nwill be called in the order they are registered, and their `TearDown()` will be\ncalled in the reverse order.\n\nNote that Google Test takes ownership of the registered environment objects.\nTherefore **do not delete them** by yourself.\n\nYou should call `AddGlobalTestEnvironment()` before `RUN_ALL_TESTS()` is\ncalled, probably in `main()`. If you use `gtest_main`, you need to      call\nthis before `main()` starts for it to take effect. One way to do this is to\ndefine a global variable like this:\n\n```\n::testing::Environment* const foo_env = ::testing::AddGlobalTestEnvironment(new FooEnvironment);\n```\n\nHowever, we strongly recommend you to write your own `main()` and call\n`AddGlobalTestEnvironment()` there, as relying on initialization of global\nvariables makes the code harder to read and may cause problems when you\nregister multiple environments from different translation units and the\nenvironments have dependencies among them (remember that the compiler doesn't\nguarantee the order in which global variables from different translation units\nare initialized).\n\n_Availability:_ Linux, Windows, Mac.\n\n\n# Value Parameterized Tests #\n\n_Value-parameterized tests_ allow you to test your code with different\nparameters without writing multiple copies of the same test.\n\nSuppose you write a test for your code and then realize that your code is affected by a presence of a Boolean command line flag.\n\n```\nTEST(MyCodeTest, TestFoo) {\n  // A code to test foo().\n}\n```\n\nUsually people factor their test code into a function with a Boolean parameter in such situations. The function sets the flag, then executes the testing code.\n\n```\nvoid TestFooHelper(bool flag_value) {\n  flag = flag_value;\n  // A code to test foo().\n}\n\nTEST(MyCodeTest, TestFoo) {\n  TestFooHelper(false);\n  TestFooHelper(true);\n}\n```\n\nBut this setup has serious drawbacks. First, when a test assertion fails in your tests, it becomes unclear what value of the parameter caused it to fail. You can stream a clarifying message into your `EXPECT`/`ASSERT` statements, but it you'll have to do it with all of them. Second, you have to add one such helper function per test. What if you have ten tests? Twenty? A hundred?\n\nValue-parameterized tests will let you write your test only once and then easily instantiate and run it with an arbitrary number of parameter values.\n\nHere are some other situations when value-parameterized tests come handy:\n\n  * You want to test different implementations of an OO interface.\n  * You want to test your code over various inputs (a.k.a. data-driven testing). This feature is easy to abuse, so please exercise your good sense when doing it!\n\n## How to Write Value-Parameterized Tests ##\n\nTo write value-parameterized tests, first you should define a fixture\nclass.  It must be derived from both `::testing::Test` and\n`::testing::WithParamInterface<T>` (the latter is a pure interface),\nwhere `T` is the type of your parameter values.  For convenience, you\ncan just derive the fixture class from `::testing::TestWithParam<T>`,\nwhich itself is derived from both `::testing::Test` and\n`::testing::WithParamInterface<T>`. `T` can be any copyable type. If\nit's a raw pointer, you are responsible for managing the lifespan of\nthe pointed values.\n\n```\nclass FooTest : public ::testing::TestWithParam<const char*> {\n  // You can implement all the usual fixture class members here.\n  // To access the test parameter, call GetParam() from class\n  // TestWithParam<T>.\n};\n\n// Or, when you want to add parameters to a pre-existing fixture class:\nclass BaseTest : public ::testing::Test {\n  ...\n};\nclass BarTest : public BaseTest,\n                public ::testing::WithParamInterface<const char*> {\n  ...\n};\n```\n\nThen, use the `TEST_P` macro to define as many test patterns using\nthis fixture as you want.  The `_P` suffix is for \"parameterized\" or\n\"pattern\", whichever you prefer to think.\n\n```\nTEST_P(FooTest, DoesBlah) {\n  // Inside a test, access the test parameter with the GetParam() method\n  // of the TestWithParam<T> class:\n  EXPECT_TRUE(foo.Blah(GetParam()));\n  ...\n}\n\nTEST_P(FooTest, HasBlahBlah) {\n  ...\n}\n```\n\nFinally, you can use `INSTANTIATE_TEST_CASE_P` to instantiate the test\ncase with any set of parameters you want. Google Test defines a number of\nfunctions for generating test parameters. They return what we call\n(surprise!) _parameter generators_. Here is a summary of them,\nwhich are all in the `testing` namespace:\n\n| `Range(begin, end[, step])` | Yields values `{begin, begin+step, begin+step+step, ...}`. The values do not include `end`. `step` defaults to 1. |\n|:----------------------------|:------------------------------------------------------------------------------------------------------------------|\n| `Values(v1, v2, ..., vN)`   | Yields values `{v1, v2, ..., vN}`.                                                                                |\n| `ValuesIn(container)` and `ValuesIn(begin, end)` | Yields values from a C-style array, an STL-style container, or an iterator range `[begin, end)`. `container`, `begin`, and `end` can be expressions whose values are determined at run time.  |\n| `Bool()`                    | Yields sequence `{false, true}`.                                                                                  |\n| `Combine(g1, g2, ..., gN)`  | Yields all combinations (the Cartesian product for the math savvy) of the values generated by the `N` generators. This is only available if your system provides the `<tr1/tuple>` header. If you are sure your system does, and Google Test disagrees, you can override it by defining `GTEST_HAS_TR1_TUPLE=1`. See comments in [include/gtest/internal/gtest-port.h](../include/gtest/internal/gtest-port.h) for more information. |\n\nFor more details, see the comments at the definitions of these functions in the [source code](../include/gtest/gtest-param-test.h).\n\nThe following statement will instantiate tests from the `FooTest` test case\neach with parameter values `\"meeny\"`, `\"miny\"`, and `\"moe\"`.\n\n```\nINSTANTIATE_TEST_CASE_P(InstantiationName,\n                        FooTest,\n                        ::testing::Values(\"meeny\", \"miny\", \"moe\"));\n```\n\nTo distinguish different instances of the pattern (yes, you can\ninstantiate it more than once), the first argument to\n`INSTANTIATE_TEST_CASE_P` is a prefix that will be added to the actual\ntest case name. Remember to pick unique prefixes for different\ninstantiations. The tests from the instantiation above will have these\nnames:\n\n  * `InstantiationName/FooTest.DoesBlah/0` for `\"meeny\"`\n  * `InstantiationName/FooTest.DoesBlah/1` for `\"miny\"`\n  * `InstantiationName/FooTest.DoesBlah/2` for `\"moe\"`\n  * `InstantiationName/FooTest.HasBlahBlah/0` for `\"meeny\"`\n  * `InstantiationName/FooTest.HasBlahBlah/1` for `\"miny\"`\n  * `InstantiationName/FooTest.HasBlahBlah/2` for `\"moe\"`\n\nYou can use these names in [--gtest\\_filter](#running-a-subset-of-the-tests).\n\nThis statement will instantiate all tests from `FooTest` again, each\nwith parameter values `\"cat\"` and `\"dog\"`:\n\n```\nconst char* pets[] = {\"cat\", \"dog\"};\nINSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest,\n                        ::testing::ValuesIn(pets));\n```\n\nThe tests from the instantiation above will have these names:\n\n  * `AnotherInstantiationName/FooTest.DoesBlah/0` for `\"cat\"`\n  * `AnotherInstantiationName/FooTest.DoesBlah/1` for `\"dog\"`\n  * `AnotherInstantiationName/FooTest.HasBlahBlah/0` for `\"cat\"`\n  * `AnotherInstantiationName/FooTest.HasBlahBlah/1` for `\"dog\"`\n\nPlease note that `INSTANTIATE_TEST_CASE_P` will instantiate _all_\ntests in the given test case, whether their definitions come before or\n_after_ the `INSTANTIATE_TEST_CASE_P` statement.\n\nYou can see\n[these](../samples/sample7_unittest.cc)\n[files](../samples/sample8_unittest.cc) for more examples.\n\n_Availability_: Linux, Windows (requires MSVC 8.0 or above), Mac; since version 1.2.0.\n\n## Creating Value-Parameterized Abstract Tests ##\n\nIn the above, we define and instantiate `FooTest` in the same source\nfile. Sometimes you may want to define value-parameterized tests in a\nlibrary and let other people instantiate them later. This pattern is\nknown as <i>abstract tests</i>. As an example of its application, when you\nare designing an interface you can write a standard suite of abstract\ntests (perhaps using a factory function as the test parameter) that\nall implementations of the interface are expected to pass. When\nsomeone implements the interface, he can instantiate your suite to get\nall the interface-conformance tests for free.\n\nTo define abstract tests, you should organize your code like this:\n\n  1. Put the definition of the parameterized test fixture class (e.g. `FooTest`) in a header file, say `foo_param_test.h`. Think of this as _declaring_ your abstract tests.\n  1. Put the `TEST_P` definitions in `foo_param_test.cc`, which includes `foo_param_test.h`. Think of this as _implementing_ your abstract tests.\n\nOnce they are defined, you can instantiate them by including\n`foo_param_test.h`, invoking `INSTANTIATE_TEST_CASE_P()`, and linking\nwith `foo_param_test.cc`. You can instantiate the same abstract test\ncase multiple times, possibly in different source files.\n\n# Typed Tests #\n\nSuppose you have multiple implementations of the same interface and\nwant to make sure that all of them satisfy some common requirements.\nOr, you may have defined several types that are supposed to conform to\nthe same \"concept\" and you want to verify it.  In both cases, you want\nthe same test logic repeated for different types.\n\nWhile you can write one `TEST` or `TEST_F` for each type you want to\ntest (and you may even factor the test logic into a function template\nthat you invoke from the `TEST`), it's tedious and doesn't scale:\nif you want _m_ tests over _n_ types, you'll end up writing _m\\*n_\n`TEST`s.\n\n_Typed tests_ allow you to repeat the same test logic over a list of\ntypes.  You only need to write the test logic once, although you must\nknow the type list when writing typed tests.  Here's how you do it:\n\nFirst, define a fixture class template.  It should be parameterized\nby a type.  Remember to derive it from `::testing::Test`:\n\n```\ntemplate <typename T>\nclass FooTest : public ::testing::Test {\n public:\n  ...\n  typedef std::list<T> List;\n  static T shared_;\n  T value_;\n};\n```\n\nNext, associate a list of types with the test case, which will be\nrepeated for each type in the list:\n\n```\ntypedef ::testing::Types<char, int, unsigned int> MyTypes;\nTYPED_TEST_CASE(FooTest, MyTypes);\n```\n\nThe `typedef` is necessary for the `TYPED_TEST_CASE` macro to parse\ncorrectly.  Otherwise the compiler will think that each comma in the\ntype list introduces a new macro argument.\n\nThen, use `TYPED_TEST()` instead of `TEST_F()` to define a typed test\nfor this test case.  You can repeat this as many times as you want:\n\n```\nTYPED_TEST(FooTest, DoesBlah) {\n  // Inside a test, refer to the special name TypeParam to get the type\n  // parameter.  Since we are inside a derived class template, C++ requires\n  // us to visit the members of FooTest via 'this'.\n  TypeParam n = this->value_;\n\n  // To visit static members of the fixture, add the 'TestFixture::'\n  // prefix.\n  n += TestFixture::shared_;\n\n  // To refer to typedefs in the fixture, add the 'typename TestFixture::'\n  // prefix.  The 'typename' is required to satisfy the compiler.\n  typename TestFixture::List values;\n  values.push_back(n);\n  ...\n}\n\nTYPED_TEST(FooTest, HasPropertyA) { ... }\n```\n\nYou can see `samples/sample6_unittest.cc` for a complete example.\n\n_Availability:_ Linux, Windows (requires MSVC 8.0 or above), Mac;\nsince version 1.1.0.\n\n# Type-Parameterized Tests #\n\n_Type-parameterized tests_ are like typed tests, except that they\ndon't require you to know the list of types ahead of time.  Instead,\nyou can define the test logic first and instantiate it with different\ntype lists later.  You can even instantiate it more than once in the\nsame program.\n\nIf you are designing an interface or concept, you can define a suite\nof type-parameterized tests to verify properties that any valid\nimplementation of the interface/concept should have.  Then, the author\nof each implementation can just instantiate the test suite with his\ntype to verify that it conforms to the requirements, without having to\nwrite similar tests repeatedly.  Here's an example:\n\nFirst, define a fixture class template, as we did with typed tests:\n\n```\ntemplate <typename T>\nclass FooTest : public ::testing::Test {\n  ...\n};\n```\n\nNext, declare that you will define a type-parameterized test case:\n\n```\nTYPED_TEST_CASE_P(FooTest);\n```\n\nThe `_P` suffix is for \"parameterized\" or \"pattern\", whichever you\nprefer to think.\n\nThen, use `TYPED_TEST_P()` to define a type-parameterized test.  You\ncan repeat this as many times as you want:\n\n```\nTYPED_TEST_P(FooTest, DoesBlah) {\n  // Inside a test, refer to TypeParam to get the type parameter.\n  TypeParam n = 0;\n  ...\n}\n\nTYPED_TEST_P(FooTest, HasPropertyA) { ... }\n```\n\nNow the tricky part: you need to register all test patterns using the\n`REGISTER_TYPED_TEST_CASE_P` macro before you can instantiate them.\nThe first argument of the macro is the test case name; the rest are\nthe names of the tests in this test case:\n\n```\nREGISTER_TYPED_TEST_CASE_P(FooTest,\n                           DoesBlah, HasPropertyA);\n```\n\nFinally, you are free to instantiate the pattern with the types you\nwant.  If you put the above code in a header file, you can `#include`\nit in multiple C++ source files and instantiate it multiple times.\n\n```\ntypedef ::testing::Types<char, int, unsigned int> MyTypes;\nINSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);\n```\n\nTo distinguish different instances of the pattern, the first argument\nto the `INSTANTIATE_TYPED_TEST_CASE_P` macro is a prefix that will be\nadded to the actual test case name.  Remember to pick unique prefixes\nfor different instances.\n\nIn the special case where the type list contains only one type, you\ncan write that type directly without `::testing::Types<...>`, like this:\n\n```\nINSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int);\n```\n\nYou can see `samples/sample6_unittest.cc` for a complete example.\n\n_Availability:_ Linux, Windows (requires MSVC 8.0 or above), Mac;\nsince version 1.1.0.\n\n# Testing Private Code #\n\nIf you change your software's internal implementation, your tests should not\nbreak as long as the change is not observable by users. Therefore, per the\n_black-box testing principle_, most of the time you should test your code\nthrough its public interfaces.\n\nIf you still find yourself needing to test internal implementation code,\nconsider if there's a better design that wouldn't require you to do so. If you\nabsolutely have to test non-public interface code though, you can. There are\ntwo cases to consider:\n\n  * Static functions (_not_ the same as static member functions!) or unnamed namespaces, and\n  * Private or protected class members\n\n## Static Functions ##\n\nBoth static functions and definitions/declarations in an unnamed namespace are\nonly visible within the same translation unit. To test them, you can `#include`\nthe entire `.cc` file being tested in your `*_test.cc` file. (`#include`ing `.cc`\nfiles is not a good way to reuse code - you should not do this in production\ncode!)\n\nHowever, a better approach is to move the private code into the\n`foo::internal` namespace, where `foo` is the namespace your project normally\nuses, and put the private declarations in a `*-internal.h` file. Your\nproduction `.cc` files and your tests are allowed to include this internal\nheader, but your clients are not. This way, you can fully test your internal\nimplementation without leaking it to your clients.\n\n## Private Class Members ##\n\nPrivate class members are only accessible from within the class or by friends.\nTo access a class' private members, you can declare your test fixture as a\nfriend to the class and define accessors in your fixture. Tests using the\nfixture can then access the private members of your production class via the\naccessors in the fixture. Note that even though your fixture is a friend to\nyour production class, your tests are not automatically friends to it, as they\nare technically defined in sub-classes of the fixture.\n\nAnother way to test private members is to refactor them into an implementation\nclass, which is then declared in a `*-internal.h` file. Your clients aren't\nallowed to include this header but your tests can. Such is called the Pimpl\n(Private Implementation) idiom.\n\nOr, you can declare an individual test as a friend of your class by adding this\nline in the class body:\n\n```\nFRIEND_TEST(TestCaseName, TestName);\n```\n\nFor example,\n```\n// foo.h\n#include \"gtest/gtest_prod.h\"\n\n// Defines FRIEND_TEST.\nclass Foo {\n  ...\n private:\n  FRIEND_TEST(FooTest, BarReturnsZeroOnNull);\n  int Bar(void* x);\n};\n\n// foo_test.cc\n...\nTEST(FooTest, BarReturnsZeroOnNull) {\n  Foo foo;\n  EXPECT_EQ(0, foo.Bar(NULL));\n  // Uses Foo's private member Bar().\n}\n```\n\nPay special attention when your class is defined in a namespace, as you should\ndefine your test fixtures and tests in the same namespace if you want them to\nbe friends of your class. For example, if the code to be tested looks like:\n\n```\nnamespace my_namespace {\n\nclass Foo {\n  friend class FooTest;\n  FRIEND_TEST(FooTest, Bar);\n  FRIEND_TEST(FooTest, Baz);\n  ...\n  definition of the class Foo\n  ...\n};\n\n}  // namespace my_namespace\n```\n\nYour test code should be something like:\n\n```\nnamespace my_namespace {\nclass FooTest : public ::testing::Test {\n protected:\n  ...\n};\n\nTEST_F(FooTest, Bar) { ... }\nTEST_F(FooTest, Baz) { ... }\n\n}  // namespace my_namespace\n```\n\n# Catching Failures #\n\nIf you are building a testing utility on top of Google Test, you'll\nwant to test your utility.  What framework would you use to test it?\nGoogle Test, of course.\n\nThe challenge is to verify that your testing utility reports failures\ncorrectly.  In frameworks that report a failure by throwing an\nexception, you could catch the exception and assert on it.  But Google\nTest doesn't use exceptions, so how do we test that a piece of code\ngenerates an expected failure?\n\n`\"gtest/gtest-spi.h\"` contains some constructs to do this.  After \n`#include`ing this header, you can use\n\n| `EXPECT_FATAL_FAILURE(`_statement, substring_`);` |\n|:--------------------------------------------------|\n\nto assert that _statement_ generates a fatal (e.g. `ASSERT_*`) failure\nwhose message contains the given _substring_, or use\n\n| `EXPECT_NONFATAL_FAILURE(`_statement, substring_`);` |\n|:-----------------------------------------------------|\n\nif you are expecting a non-fatal (e.g. `EXPECT_*`) failure.\n\nFor technical reasons, there are some caveats:\n\n  1. You cannot stream a failure message to either macro.\n  1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot reference local non-static variables or non-static members of `this` object.\n  1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot return a value.\n\n_Note:_ Google Test is designed with threads in mind. Once the\nsynchronization primitives in `\"gtest/internal/gtest-port.h\"` have\nbeen implemented, Google Test will become thread-safe, meaning that\nyou can then use assertions in multiple threads concurrently. Before\nthat, however, Google Test only supports single-threaded usage. Once\nthread-safe, `EXPECT_FATAL_FAILURE()` and `EXPECT_NONFATAL_FAILURE()`\nwill capture failures in the current thread only. If _statement_\ncreates new threads, failures in these threads will be ignored. If\nyou want to capture failures from all threads instead, you should use\nthe following macros:\n\n| `EXPECT_FATAL_FAILURE_ON_ALL_THREADS(`_statement, substring_`);` |\n|:-----------------------------------------------------------------|\n| `EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(`_statement, substring_`);` |\n\n# Getting the Current Test's Name #\n\nSometimes a function may need to know the name of the currently running test.\nFor example, you may be using the `SetUp()` method of your test fixture to set\nthe golden file name based on which test is running. The `::testing::TestInfo`\nclass has this information:\n\n```\nnamespace testing {\n\nclass TestInfo {\n public:\n  // Returns the test case name and the test name, respectively.\n  //\n  // Do NOT delete or free the return value - it's managed by the\n  // TestInfo class.\n  const char* test_case_name() const;\n  const char* name() const;\n};\n\n}  // namespace testing\n```\n\n\n> To obtain a `TestInfo` object for the currently running test, call\n`current_test_info()` on the `UnitTest` singleton object:\n\n```\n// Gets information about the currently running test.\n// Do NOT delete the returned object - it's managed by the UnitTest class.\nconst ::testing::TestInfo* const test_info =\n  ::testing::UnitTest::GetInstance()->current_test_info();\nprintf(\"We are in test %s of test case %s.\\n\",\n       test_info->name(), test_info->test_case_name());\n```\n\n`current_test_info()` returns a null pointer if no test is running. In\nparticular, you cannot find the test case name in `TestCaseSetUp()`,\n`TestCaseTearDown()` (where you know the test case name implicitly), or\nfunctions called from them.\n\n_Availability:_ Linux, Windows, Mac.\n\n# Extending Google Test by Handling Test Events #\n\nGoogle Test provides an <b>event listener API</b> to let you receive\nnotifications about the progress of a test program and test\nfailures. The events you can listen to include the start and end of\nthe test program, a test case, or a test method, among others. You may\nuse this API to augment or replace the standard console output,\nreplace the XML output, or provide a completely different form of\noutput, such as a GUI or a database. You can also use test events as\ncheckpoints to implement a resource leak checker, for example.\n\n_Availability:_ Linux, Windows, Mac; since v1.4.0.\n\n## Defining Event Listeners ##\n\nTo define a event listener, you subclass either\n[testing::TestEventListener](../include/gtest/gtest.h#L991)\nor [testing::EmptyTestEventListener](../include/gtest/gtest.h#L1044).\nThe former is an (abstract) interface, where <i>each pure virtual method<br>\ncan be overridden to handle a test event</i> (For example, when a test\nstarts, the `OnTestStart()` method will be called.). The latter provides\nan empty implementation of all methods in the interface, such that a\nsubclass only needs to override the methods it cares about.\n\nWhen an event is fired, its context is passed to the handler function\nas an argument. The following argument types are used:\n  * [UnitTest](../include/gtest/gtest.h#L1151) reflects the state of the entire test program,\n  * [TestCase](../include/gtest/gtest.h#L778) has information about a test case, which can contain one or more tests,\n  * [TestInfo](../include/gtest/gtest.h#L644) contains the state of a test, and\n  * [TestPartResult](../include/gtest/gtest-test-part.h#L47) represents the result of a test assertion.\n\nAn event handler function can examine the argument it receives to find\nout interesting information about the event and the test program's\nstate.  Here's an example:\n\n```\n  class MinimalistPrinter : public ::testing::EmptyTestEventListener {\n    // Called before a test starts.\n    virtual void OnTestStart(const ::testing::TestInfo& test_info) {\n      printf(\"*** Test %s.%s starting.\\n\",\n             test_info.test_case_name(), test_info.name());\n    }\n\n    // Called after a failed assertion or a SUCCEED() invocation.\n    virtual void OnTestPartResult(\n        const ::testing::TestPartResult& test_part_result) {\n      printf(\"%s in %s:%d\\n%s\\n\",\n             test_part_result.failed() ? \"*** Failure\" : \"Success\",\n             test_part_result.file_name(),\n             test_part_result.line_number(),\n             test_part_result.summary());\n    }\n\n    // Called after a test ends.\n    virtual void OnTestEnd(const ::testing::TestInfo& test_info) {\n      printf(\"*** Test %s.%s ending.\\n\",\n             test_info.test_case_name(), test_info.name());\n    }\n  };\n```\n\n## Using Event Listeners ##\n\nTo use the event listener you have defined, add an instance of it to\nthe Google Test event listener list (represented by class\n[TestEventListeners](../include/gtest/gtest.h#L1064)\n- note the \"s\" at the end of the name) in your\n`main()` function, before calling `RUN_ALL_TESTS()`:\n```\nint main(int argc, char** argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n  // Gets hold of the event listener list.\n  ::testing::TestEventListeners& listeners =\n      ::testing::UnitTest::GetInstance()->listeners();\n  // Adds a listener to the end.  Google Test takes the ownership.\n  listeners.Append(new MinimalistPrinter);\n  return RUN_ALL_TESTS();\n}\n```\n\nThere's only one problem: the default test result printer is still in\neffect, so its output will mingle with the output from your minimalist\nprinter. To suppress the default printer, just release it from the\nevent listener list and delete it. You can do so by adding one line:\n```\n  ...\n  delete listeners.Release(listeners.default_result_printer());\n  listeners.Append(new MinimalistPrinter);\n  return RUN_ALL_TESTS();\n```\n\nNow, sit back and enjoy a completely different output from your\ntests. For more details, you can read this\n[sample](../samples/sample9_unittest.cc).\n\nYou may append more than one listener to the list. When an `On*Start()`\nor `OnTestPartResult()` event is fired, the listeners will receive it in\nthe order they appear in the list (since new listeners are added to\nthe end of the list, the default text printer and the default XML\ngenerator will receive the event first). An `On*End()` event will be\nreceived by the listeners in the _reverse_ order. This allows output by\nlisteners added later to be framed by output from listeners added\nearlier.\n\n## Generating Failures in Listeners ##\n\nYou may use failure-raising macros (`EXPECT_*()`, `ASSERT_*()`,\n`FAIL()`, etc) when processing an event. There are some restrictions:\n\n  1. You cannot generate any failure in `OnTestPartResult()` (otherwise it will cause `OnTestPartResult()` to be called recursively).\n  1. A listener that handles `OnTestPartResult()` is not allowed to generate any failure.\n\nWhen you add listeners to the listener list, you should put listeners\nthat handle `OnTestPartResult()` _before_ listeners that can generate\nfailures. This ensures that failures generated by the latter are\nattributed to the right test by the former.\n\nWe have a sample of failure-raising listener\n[here](../samples/sample10_unittest.cc).\n\n# Running Test Programs: Advanced Options #\n\nGoogle Test test programs are ordinary executables. Once built, you can run\nthem directly and affect their behavior via the following environment variables\nand/or command line flags. For the flags to work, your programs must call\n`::testing::InitGoogleTest()` before calling `RUN_ALL_TESTS()`.\n\nTo see a list of supported flags and their usage, please run your test\nprogram with the `--help` flag.  You can also use `-h`, `-?`, or `/?`\nfor short.  This feature is added in version 1.3.0.\n\nIf an option is specified both by an environment variable and by a\nflag, the latter takes precedence.  Most of the options can also be\nset/read in code: to access the value of command line flag\n`--gtest_foo`, write `::testing::GTEST_FLAG(foo)`.  A common pattern is\nto set the value of a flag before calling `::testing::InitGoogleTest()`\nto change the default value of the flag:\n```\nint main(int argc, char** argv) {\n  // Disables elapsed time by default.\n  ::testing::GTEST_FLAG(print_time) = false;\n\n  // This allows the user to override the flag on the command line.\n  ::testing::InitGoogleTest(&argc, argv);\n\n  return RUN_ALL_TESTS();\n}\n```\n\n## Selecting Tests ##\n\nThis section shows various options for choosing which tests to run.\n\n### Listing Test Names ###\n\nSometimes it is necessary to list the available tests in a program before\nrunning them so that a filter may be applied if needed. Including the flag\n`--gtest_list_tests` overrides all other flags and lists tests in the following\nformat:\n```\nTestCase1.\n  TestName1\n  TestName2\nTestCase2.\n  TestName\n```\n\nNone of the tests listed are actually run if the flag is provided. There is no\ncorresponding environment variable for this flag.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Running a Subset of the Tests ###\n\nBy default, a Google Test program runs all tests the user has defined.\nSometimes, you want to run only a subset of the tests (e.g. for debugging or\nquickly verifying a change). If you set the `GTEST_FILTER` environment variable\nor the `--gtest_filter` flag to a filter string, Google Test will only run the\ntests whose full names (in the form of `TestCaseName.TestName`) match the\nfilter.\n\nThe format of a filter is a '`:`'-separated list of wildcard patterns (called\nthe positive patterns) optionally followed by a '`-`' and another\n'`:`'-separated pattern list (called the negative patterns). A test matches the\nfilter if and only if it matches any of the positive patterns but does not\nmatch any of the negative patterns.\n\nA pattern may contain `'*'` (matches any string) or `'?'` (matches any single\ncharacter). For convenience, the filter `'*-NegativePatterns'` can be also\nwritten as `'-NegativePatterns'`.\n\nFor example:\n\n  * `./foo_test` Has no flag, and thus runs all its tests.\n  * `./foo_test --gtest_filter=*` Also runs everything, due to the single match-everything `*` value.\n  * `./foo_test --gtest_filter=FooTest.*` Runs everything in test case `FooTest`.\n  * `./foo_test --gtest_filter=*Null*:*Constructor*` Runs any test whose full name contains either `\"Null\"` or `\"Constructor\"`.\n  * `./foo_test --gtest_filter=-*DeathTest.*` Runs all non-death tests.\n  * `./foo_test --gtest_filter=FooTest.*-FooTest.Bar` Runs everything in test case `FooTest` except `FooTest.Bar`.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Temporarily Disabling Tests ###\n\nIf you have a broken test that you cannot fix right away, you can add the\n`DISABLED_` prefix to its name. This will exclude it from execution. This is\nbetter than commenting out the code or using `#if 0`, as disabled tests are\nstill compiled (and thus won't rot).\n\nIf you need to disable all tests in a test case, you can either add `DISABLED_`\nto the front of the name of each test, or alternatively add it to the front of\nthe test case name.\n\nFor example, the following tests won't be run by Google Test, even though they\nwill still be compiled:\n\n```\n// Tests that Foo does Abc.\nTEST(FooTest, DISABLED_DoesAbc) { ... }\n\nclass DISABLED_BarTest : public ::testing::Test { ... };\n\n// Tests that Bar does Xyz.\nTEST_F(DISABLED_BarTest, DoesXyz) { ... }\n```\n\n_Note:_ This feature should only be used for temporary pain-relief. You still\nhave to fix the disabled tests at a later date. As a reminder, Google Test will\nprint a banner warning you if a test program contains any disabled tests.\n\n_Tip:_ You can easily count the number of disabled tests you have\nusing `grep`. This number can be used as a metric for improving your\ntest quality.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Temporarily Enabling Disabled Tests ###\n\nTo include [disabled tests](#temporarily-disabling-tests) in test\nexecution, just invoke the test program with the\n`--gtest_also_run_disabled_tests` flag or set the\n`GTEST_ALSO_RUN_DISABLED_TESTS` environment variable to a value other\nthan `0`.  You can combine this with the\n[--gtest\\_filter](#running-a-subset-of-the-tests) flag to further select\nwhich disabled tests to run.\n\n_Availability:_ Linux, Windows, Mac; since version 1.3.0.\n\n## Repeating the Tests ##\n\nOnce in a while you'll run into a test whose result is hit-or-miss. Perhaps it\nwill fail only 1% of the time, making it rather hard to reproduce the bug under\na debugger. This can be a major source of frustration.\n\nThe `--gtest_repeat` flag allows you to repeat all (or selected) test methods\nin a program many times. Hopefully, a flaky test will eventually fail and give\nyou a chance to debug. Here's how to use it:\n\n| `$ foo_test --gtest_repeat=1000` | Repeat foo\\_test 1000 times and don't stop at failures. |\n|:---------------------------------|:--------------------------------------------------------|\n| `$ foo_test --gtest_repeat=-1`   | A negative count means repeating forever.               |\n| `$ foo_test --gtest_repeat=1000 --gtest_break_on_failure` | Repeat foo\\_test 1000 times, stopping at the first failure. This is especially useful when running under a debugger: when the testfails, it will drop into the debugger and you can then inspect variables and stacks. |\n| `$ foo_test --gtest_repeat=1000 --gtest_filter=FooBar` | Repeat the tests whose name matches the filter 1000 times. |\n\nIf your test program contains global set-up/tear-down code registered\nusing `AddGlobalTestEnvironment()`, it will be repeated in each\niteration as well, as the flakiness may be in it. You can also specify\nthe repeat count by setting the `GTEST_REPEAT` environment variable.\n\n_Availability:_ Linux, Windows, Mac.\n\n## Shuffling the Tests ##\n\nYou can specify the `--gtest_shuffle` flag (or set the `GTEST_SHUFFLE`\nenvironment variable to `1`) to run the tests in a program in a random\norder. This helps to reveal bad dependencies between tests.\n\nBy default, Google Test uses a random seed calculated from the current\ntime. Therefore you'll get a different order every time. The console\noutput includes the random seed value, such that you can reproduce an\norder-related test failure later. To specify the random seed\nexplicitly, use the `--gtest_random_seed=SEED` flag (or set the\n`GTEST_RANDOM_SEED` environment variable), where `SEED` is an integer\nbetween 0 and 99999. The seed value 0 is special: it tells Google Test\nto do the default behavior of calculating the seed from the current\ntime.\n\nIf you combine this with `--gtest_repeat=N`, Google Test will pick a\ndifferent random seed and re-shuffle the tests in each iteration.\n\n_Availability:_ Linux, Windows, Mac; since v1.4.0.\n\n## Controlling Test Output ##\n\nThis section teaches how to tweak the way test results are reported.\n\n### Colored Terminal Output ###\n\nGoogle Test can use colors in its terminal output to make it easier to spot\nthe separation between tests, and whether tests passed.\n\nYou can set the GTEST\\_COLOR environment variable or set the `--gtest_color`\ncommand line flag to `yes`, `no`, or `auto` (the default) to enable colors,\ndisable colors, or let Google Test decide. When the value is `auto`, Google\nTest will use colors if and only if the output goes to a terminal and (on\nnon-Windows platforms) the `TERM` environment variable is set to `xterm` or\n`xterm-color`.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Suppressing the Elapsed Time ###\n\nBy default, Google Test prints the time it takes to run each test.  To\nsuppress that, run the test program with the `--gtest_print_time=0`\ncommand line flag.  Setting the `GTEST_PRINT_TIME` environment\nvariable to `0` has the same effect.\n\n_Availability:_ Linux, Windows, Mac.  (In Google Test 1.3.0 and lower,\nthe default behavior is that the elapsed time is **not** printed.)\n\n### Generating an XML Report ###\n\nGoogle Test can emit a detailed XML report to a file in addition to its normal\ntextual output. The report contains the duration of each test, and thus can\nhelp you identify slow tests.\n\nTo generate the XML report, set the `GTEST_OUTPUT` environment variable or the\n`--gtest_output` flag to the string `\"xml:_path_to_output_file_\"`, which will\ncreate the file at the given location. You can also just use the string\n`\"xml\"`, in which case the output can be found in the `test_detail.xml` file in\nthe current directory.\n\nIf you specify a directory (for example, `\"xml:output/directory/\"` on Linux or\n`\"xml:output\\directory\\\"` on Windows), Google Test will create the XML file in\nthat directory, named after the test executable (e.g. `foo_test.xml` for test\nprogram `foo_test` or `foo_test.exe`). If the file already exists (perhaps left\nover from a previous run), Google Test will pick a different name (e.g.\n`foo_test_1.xml`) to avoid overwriting it.\n\nThe report uses the format described here.  It is based on the\n`junitreport` Ant task and can be parsed by popular continuous build\nsystems like [Hudson](https://hudson.dev.java.net/). Since that format\nwas originally intended for Java, a little interpretation is required\nto make it apply to Google Test tests, as shown here:\n\n```\n<testsuites name=\"AllTests\" ...>\n  <testsuite name=\"test_case_name\" ...>\n    <testcase name=\"test_name\" ...>\n      <failure message=\"...\"/>\n      <failure message=\"...\"/>\n      <failure message=\"...\"/>\n    </testcase>\n  </testsuite>\n</testsuites>\n```\n\n  * The root `<testsuites>` element corresponds to the entire test program.\n  * `<testsuite>` elements correspond to Google Test test cases.\n  * `<testcase>` elements correspond to Google Test test functions.\n\nFor instance, the following program\n\n```\nTEST(MathTest, Addition) { ... }\nTEST(MathTest, Subtraction) { ... }\nTEST(LogicTest, NonContradiction) { ... }\n```\n\ncould generate this report:\n\n```\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites tests=\"3\" failures=\"1\" errors=\"0\" time=\"35\" name=\"AllTests\">\n  <testsuite name=\"MathTest\" tests=\"2\" failures=\"1\" errors=\"0\" time=\"15\">\n    <testcase name=\"Addition\" status=\"run\" time=\"7\" classname=\"\">\n      <failure message=\"Value of: add(1, 1)&#x0A; Actual: 3&#x0A;Expected: 2\" type=\"\"/>\n      <failure message=\"Value of: add(1, -1)&#x0A; Actual: 1&#x0A;Expected: 0\" type=\"\"/>\n    </testcase>\n    <testcase name=\"Subtraction\" status=\"run\" time=\"5\" classname=\"\">\n    </testcase>\n  </testsuite>\n  <testsuite name=\"LogicTest\" tests=\"1\" failures=\"0\" errors=\"0\" time=\"5\">\n    <testcase name=\"NonContradiction\" status=\"run\" time=\"5\" classname=\"\">\n    </testcase>\n  </testsuite>\n</testsuites>\n```\n\nThings to note:\n\n  * The `tests` attribute of a `<testsuites>` or `<testsuite>` element tells how many test functions the Google Test program or test case contains, while the `failures` attribute tells how many of them failed.\n  * The `time` attribute expresses the duration of the test, test case, or entire test program in milliseconds.\n  * Each `<failure>` element corresponds to a single failed Google Test assertion.\n  * Some JUnit concepts don't apply to Google Test, yet we have to conform to the DTD. Therefore you'll see some dummy elements and attributes in the report. You can safely ignore these parts.\n\n_Availability:_ Linux, Windows, Mac.\n\n## Controlling How Failures Are Reported ##\n\n### Turning Assertion Failures into Break-Points ###\n\nWhen running test programs under a debugger, it's very convenient if the\ndebugger can catch an assertion failure and automatically drop into interactive\nmode. Google Test's _break-on-failure_ mode supports this behavior.\n\nTo enable it, set the `GTEST_BREAK_ON_FAILURE` environment variable to a value\nother than `0` . Alternatively, you can use the `--gtest_break_on_failure`\ncommand line flag.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Disabling Catching Test-Thrown Exceptions ###\n\nGoogle Test can be used either with or without exceptions enabled.  If\na test throws a C++ exception or (on Windows) a structured exception\n(SEH), by default Google Test catches it, reports it as a test\nfailure, and continues with the next test method.  This maximizes the\ncoverage of a test run.  Also, on Windows an uncaught exception will\ncause a pop-up window, so catching the exceptions allows you to run\nthe tests automatically.\n\nWhen debugging the test failures, however, you may instead want the\nexceptions to be handled by the debugger, such that you can examine\nthe call stack when an exception is thrown.  To achieve that, set the\n`GTEST_CATCH_EXCEPTIONS` environment variable to `0`, or use the\n`--gtest_catch_exceptions=0` flag when running the tests.\n\n**Availability**: Linux, Windows, Mac.\n\n### Letting Another Testing Framework Drive ###\n\nIf you work on a project that has already been using another testing\nframework and is not ready to completely switch to Google Test yet,\nyou can get much of Google Test's benefit by using its assertions in\nyour existing tests.  Just change your `main()` function to look\nlike:\n\n```\n#include \"gtest/gtest.h\"\n\nint main(int argc, char** argv) {\n  ::testing::GTEST_FLAG(throw_on_failure) = true;\n  // Important: Google Test must be initialized.\n  ::testing::InitGoogleTest(&argc, argv);\n\n  ... whatever your existing testing framework requires ...\n}\n```\n\nWith that, you can use Google Test assertions in addition to the\nnative assertions your testing framework provides, for example:\n\n```\nvoid TestFooDoesBar() {\n  Foo foo;\n  EXPECT_LE(foo.Bar(1), 100);     // A Google Test assertion.\n  CPPUNIT_ASSERT(foo.IsEmpty());  // A native assertion.\n}\n```\n\nIf a Google Test assertion fails, it will print an error message and\nthrow an exception, which will be treated as a failure by your host\ntesting framework.  If you compile your code with exceptions disabled,\na failed Google Test assertion will instead exit your program with a\nnon-zero code, which will also signal a test failure to your test\nrunner.\n\nIf you don't write `::testing::GTEST_FLAG(throw_on_failure) = true;` in\nyour `main()`, you can alternatively enable this feature by specifying\nthe `--gtest_throw_on_failure` flag on the command-line or setting the\n`GTEST_THROW_ON_FAILURE` environment variable to a non-zero value.\n\nDeath tests are _not_ supported when other test framework is used to organize tests.\n\n_Availability:_ Linux, Windows, Mac; since v1.3.0.\n\n## Distributing Test Functions to Multiple Machines ##\n\nIf you have more than one machine you can use to run a test program,\nyou might want to run the test functions in parallel and get the\nresult faster.  We call this technique _sharding_, where each machine\nis called a _shard_.\n\nGoogle Test is compatible with test sharding.  To take advantage of\nthis feature, your test runner (not part of Google Test) needs to do\nthe following:\n\n  1. Allocate a number of machines (shards) to run the tests.\n  1. On each shard, set the `GTEST_TOTAL_SHARDS` environment variable to the total number of shards.  It must be the same for all shards.\n  1. On each shard, set the `GTEST_SHARD_INDEX` environment variable to the index of the shard.  Different shards must be assigned different indices, which must be in the range `[0, GTEST_TOTAL_SHARDS - 1]`.\n  1. Run the same test program on all shards.  When Google Test sees the above two environment variables, it will select a subset of the test functions to run.  Across all shards, each test function in the program will be run exactly once.\n  1. Wait for all shards to finish, then collect and report the results.\n\nYour project may have tests that were written without Google Test and\nthus don't understand this protocol.  In order for your test runner to\nfigure out which test supports sharding, it can set the environment\nvariable `GTEST_SHARD_STATUS_FILE` to a non-existent file path.  If a\ntest program supports sharding, it will create this file to\nacknowledge the fact (the actual contents of the file are not\nimportant at this time; although we may stick some useful information\nin it in the future.); otherwise it will not create it.\n\nHere's an example to make it clear.  Suppose you have a test program\n`foo_test` that contains the following 5 test functions:\n```\nTEST(A, V)\nTEST(A, W)\nTEST(B, X)\nTEST(B, Y)\nTEST(B, Z)\n```\nand you have 3 machines at your disposal.  To run the test functions in\nparallel, you would set `GTEST_TOTAL_SHARDS` to 3 on all machines, and\nset `GTEST_SHARD_INDEX` to 0, 1, and 2 on the machines respectively.\nThen you would run the same `foo_test` on each machine.\n\nGoogle Test reserves the right to change how the work is distributed\nacross the shards, but here's one possible scenario:\n\n  * Machine #0 runs `A.V` and `B.X`.\n  * Machine #1 runs `A.W` and `B.Y`.\n  * Machine #2 runs `B.Z`.\n\n_Availability:_ Linux, Windows, Mac; since version 1.3.0.\n\n# Fusing Google Test Source Files #\n\nGoogle Test's implementation consists of ~30 files (excluding its own\ntests).  Sometimes you may want them to be packaged up in two files (a\n`.h` and a `.cc`) instead, such that you can easily copy them to a new\nmachine and start hacking there.  For this we provide an experimental\nPython script `fuse_gtest_files.py` in the `scripts/` directory (since release 1.3.0).\nAssuming you have Python 2.4 or above installed on your machine, just\ngo to that directory and run\n```\npython fuse_gtest_files.py OUTPUT_DIR\n```\n\nand you should see an `OUTPUT_DIR` directory being created with files\n`gtest/gtest.h` and `gtest/gtest-all.cc` in it.  These files contain\neverything you need to use Google Test.  Just copy them to anywhere\nyou want and you are ready to write tests.  You can use the\n[scripts/test/Makefile](../scripts/test/Makefile)\nfile as an example on how to compile your tests against them.\n\n# Where to Go from Here #\n\nCongratulations! You've now learned more advanced Google Test tools and are\nready to tackle more complex testing tasks. If you want to dive even deeper, you\ncan read the [Frequently-Asked Questions](FAQ.md).\n"
  },
  {
    "path": "utils/googletest/googletest/docs/DevGuide.md",
    "content": "\n\nIf you are interested in understanding the internals of Google Test,\nbuilding from source, or contributing ideas or modifications to the\nproject, then this document is for you.\n\n# Introduction #\n\nFirst, let's give you some background of the project.\n\n## Licensing ##\n\nAll Google Test source and pre-built packages are provided under the [New BSD License](http://www.opensource.org/licenses/bsd-license.php).\n\n## The Google Test Community ##\n\nThe Google Test community exists primarily through the [discussion group](http://groups.google.com/group/googletestframework) and the GitHub repository.\nYou are definitely encouraged to contribute to the\ndiscussion and you can also help us to keep the effectiveness of the\ngroup high by following and promoting the guidelines listed here.\n\n### Please Be Friendly ###\n\nShowing courtesy and respect to others is a vital part of the Google\nculture, and we strongly encourage everyone participating in Google\nTest development to join us in accepting nothing less. Of course,\nbeing courteous is not the same as failing to constructively disagree\nwith each other, but it does mean that we should be respectful of each\nother when enumerating the 42 technical reasons that a particular\nproposal may not be the best choice. There's never a reason to be\nantagonistic or dismissive toward anyone who is sincerely trying to\ncontribute to a discussion.\n\nSure, C++ testing is serious business and all that, but it's also\na lot of fun. Let's keep it that way. Let's strive to be one of the\nfriendliest communities in all of open source.\n\nAs always, discuss Google Test in the official GoogleTest discussion group.\nYou don't have to actually submit code in order to sign up. Your participation\nitself is a valuable contribution.\n\n# Working with the Code #\n\nIf you want to get your hands dirty with the code inside Google Test,\nthis is the section for you.\n\n## Compiling from Source ##\n\nOnce you check out the code, you can find instructions on how to\ncompile it in the [README](../README.md) file.\n\n## Testing ##\n\nA testing framework is of no good if itself is not thoroughly tested.\nTests should be written for any new code, and changes should be\nverified to not break existing tests before they are submitted for\nreview. To perform the tests, follow the instructions in\n[README](../README.md) and verify that there are no failures.\n\n# Contributing Code #\n\nWe are excited that Google Test is now open source, and hope to get\ngreat patches from the community. Before you fire up your favorite IDE\nand begin hammering away at that new feature, though, please take the\ntime to read this section and understand the process. While it seems\nrigorous, we want to keep a high standard of quality in the code\nbase.\n\n## Contributor License Agreements ##\n\nYou must sign a Contributor License Agreement (CLA) before we can\naccept any code.  The CLA protects you and us.\n\n  * If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an [individual CLA](http://code.google.com/legal/individual-cla-v1.0.html).\n  * If you work for a company that wants to allow you to contribute your work to Google Test, then you'll need to sign a [corporate CLA](http://code.google.com/legal/corporate-cla-v1.0.html).\n\nFollow either of the two links above to access the appropriate CLA and\ninstructions for how to sign and return it.\n\n## Coding Style ##\n\nTo keep the source consistent, readable, diffable and easy to merge,\nwe use a fairly rigid coding style, as defined by the [google-styleguide](http://code.google.com/p/google-styleguide/) project.  All patches will be expected\nto conform to the style outlined [here](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml).\n\n## Updating Generated Code ##\n\nSome of Google Test's source files are generated by the Pump tool (a\nPython script).  If you need to update such files, please modify the\nsource (`foo.h.pump`) and re-generate the C++ file using Pump.  You\ncan read the PumpManual for details.\n\n## Submitting Patches ##\n\nPlease do submit code. Here's what you need to do:\n\n  1. A submission should be a set of changes that addresses one issue in the [issue tracker](https://github.com/google/googletest/issues). Please don't mix more than one logical change per submittal, because it makes the history hard to follow. If you want to make a change that doesn't have a corresponding issue in the issue tracker, please create one.\n  1. Also, coordinate with team members that are listed on the issue in question. This ensures that work isn't being duplicated and communicating your plan early also generally leads to better patches.\n  1. Ensure that your code adheres to the [Google Test source code style](#Coding_Style.md).\n  1. Ensure that there are unit tests for your code.\n  1. Sign a Contributor License Agreement.\n  1. Create a Pull Request in the usual way.\n\n## Google Test Committers ##\n\nThe current members of the Google Test engineering team are the only\ncommitters at present. In the great tradition of eating one's own\ndogfood, we will be requiring each new Google Test engineering team\nmember to earn the right to become a committer by following the\nprocedures in this document, writing consistently great code, and\ndemonstrating repeatedly that he or she truly gets the zen of Google\nTest.\n\n# Release Process #\n\nWe follow a typical release process:\n\n  1. A release branch named `release-X.Y` is created.\n  1. Bugs are fixed and features are added in trunk; those individual patches are merged into the release branch until it's stable.\n  1. An individual point release (the `Z` in `X.Y.Z`) is made by creating a tag from the branch.\n  1. Repeat steps 2 and 3 throughout one release cycle (as determined by features or time).\n  1. Go back to step 1 to create another release branch and so on.\n\n---\n\nThis page is based on the [Making GWT Better](http://code.google.com/webtoolkit/makinggwtbetter.html) guide from the [Google Web Toolkit](http://code.google.com/webtoolkit/) project.  Except as otherwise [noted](http://code.google.com/policies.html#restrictions), the content of this page is licensed under the [Creative Commons Attribution 2.5 License](http://creativecommons.org/licenses/by/2.5/).\n"
  },
  {
    "path": "utils/googletest/googletest/docs/Documentation.md",
    "content": "This page lists all documentation wiki pages for Google Test **(the SVN trunk version)**\n-- **if you use a released version of Google Test, please read the\ndocumentation for that specific version instead.**\n\n  * [Primer](Primer.md) -- start here if you are new to Google Test.\n  * [Samples](Samples.md) -- learn from examples.\n  * [AdvancedGuide](AdvancedGuide.md) -- learn more about Google Test.\n  * [XcodeGuide](XcodeGuide.md) -- how to use Google Test in Xcode on Mac.\n  * [Frequently-Asked Questions](FAQ.md) -- check here before asking a question on the mailing list.\n\nTo contribute code to Google Test, read:\n\n  * [DevGuide](DevGuide.md) -- read this _before_ writing your first patch.\n  * [PumpManual](PumpManual.md) -- how we generate some of Google Test's source files."
  },
  {
    "path": "utils/googletest/googletest/docs/FAQ.md",
    "content": "\n\nIf you cannot find the answer to your question here, and you have read\n[Primer](Primer.md) and [AdvancedGuide](AdvancedGuide.md), send it to\ngoogletestframework@googlegroups.com.\n\n## Why should I use Google Test instead of my favorite C++ testing framework? ##\n\nFirst, let us say clearly that we don't want to get into the debate of\nwhich C++ testing framework is **the best**.  There exist many fine\nframeworks for writing C++ tests, and we have tremendous respect for\nthe developers and users of them.  We don't think there is (or will\nbe) a single best framework - you have to pick the right tool for the\nparticular task you are tackling.\n\nWe created Google Test because we couldn't find the right combination\nof features and conveniences in an existing framework to satisfy _our_\nneeds.  The following is a list of things that _we_ like about Google\nTest.  We don't claim them to be unique to Google Test - rather, the\ncombination of them makes Google Test the choice for us.  We hope this\nlist can help you decide whether it is for you too.\n\n  * Google Test is designed to be portable: it doesn't require exceptions or RTTI; it works around various bugs in various compilers and environments; etc.  As a result, it works on Linux, Mac OS X, Windows and several embedded operating systems.\n  * Nonfatal assertions (`EXPECT_*`) have proven to be great time savers, as they allow a test to report multiple failures in a single edit-compile-test cycle.\n  * It's easy to write assertions that generate informative messages: you just use the stream syntax to append any additional information, e.g. `ASSERT_EQ(5, Foo(i)) << \" where i = \" << i;`.  It doesn't require a new set of macros or special functions.\n  * Google Test automatically detects your tests and doesn't require you to enumerate them in order to run them.\n  * Death tests are pretty handy for ensuring that your asserts in production code are triggered by the right conditions.\n  * `SCOPED_TRACE` helps you understand the context of an assertion failure when it comes from inside a sub-routine or loop.\n  * You can decide which tests to run using name patterns.  This saves time when you want to quickly reproduce a test failure.\n  * Google Test can generate XML test result reports that can be parsed by popular continuous build system like Hudson.\n  * Simple things are easy in Google Test, while hard things are possible: in addition to advanced features like [global test environments](AdvancedGuide.md#global-set-up-and-tear-down) and tests parameterized by [values](AdvancedGuide.md#value-parameterized-tests) or [types](docs/AdvancedGuide.md#typed-tests), Google Test supports various ways for the user to extend the framework -- if Google Test doesn't do something out of the box, chances are that a user can implement the feature using Google Test's public API, without changing Google Test itself.  In particular, you can:\n    * expand your testing vocabulary by defining [custom predicates](AdvancedGuide.md#predicate-assertions-for-better-error-messages),\n    * teach Google Test how to [print your types](AdvancedGuide.md#teaching-google-test-how-to-print-your-values),\n    * define your own testing macros or utilities and verify them using Google Test's [Service Provider Interface](AdvancedGuide.md#catching-failures), and\n    * reflect on the test cases or change the test output format by intercepting the [test events](AdvancedGuide.md#extending-google-test-by-handling-test-events).\n\n## I'm getting warnings when compiling Google Test.  Would you fix them? ##\n\nWe strive to minimize compiler warnings Google Test generates.  Before releasing a new version, we test to make sure that it doesn't generate warnings when compiled using its CMake script on Windows, Linux, and Mac OS.\n\nUnfortunately, this doesn't mean you are guaranteed to see no warnings when compiling Google Test in your environment:\n\n  * You may be using a different compiler as we use, or a different version of the same compiler.  We cannot possibly test for all compilers.\n  * You may be compiling on a different platform as we do.\n  * Your project may be using different compiler flags as we do.\n\nIt is not always possible to make Google Test warning-free for everyone.  Or, it may not be desirable if the warning is rarely enabled and fixing the violations makes the code more complex.\n\nIf you see warnings when compiling Google Test, we suggest that you use the `-isystem` flag (assuming your are using GCC) to mark Google Test headers as system headers.  That'll suppress warnings from Google Test headers.\n\n## Why should not test case names and test names contain underscore? ##\n\nUnderscore (`_`) is special, as C++ reserves the following to be used by\nthe compiler and the standard library:\n\n  1. any identifier that starts with an `_` followed by an upper-case letter, and\n  1. any identifier that containers two consecutive underscores (i.e. `__`) _anywhere_ in its name.\n\nUser code is _prohibited_ from using such identifiers.\n\nNow let's look at what this means for `TEST` and `TEST_F`.\n\nCurrently `TEST(TestCaseName, TestName)` generates a class named\n`TestCaseName_TestName_Test`.  What happens if `TestCaseName` or `TestName`\ncontains `_`?\n\n  1. If `TestCaseName` starts with an `_` followed by an upper-case letter (say, `_Foo`), we end up with `_Foo_TestName_Test`, which is reserved and thus invalid.\n  1. If `TestCaseName` ends with an `_` (say, `Foo_`), we get `Foo__TestName_Test`, which is invalid.\n  1. If `TestName` starts with an `_` (say, `_Bar`), we get `TestCaseName__Bar_Test`, which is invalid.\n  1. If `TestName` ends with an `_` (say, `Bar_`), we get `TestCaseName_Bar__Test`, which is invalid.\n\nSo clearly `TestCaseName` and `TestName` cannot start or end with `_`\n(Actually, `TestCaseName` can start with `_` -- as long as the `_` isn't\nfollowed by an upper-case letter.  But that's getting complicated.  So\nfor simplicity we just say that it cannot start with `_`.).\n\nIt may seem fine for `TestCaseName` and `TestName` to contain `_` in the\nmiddle.  However, consider this:\n``` cpp\nTEST(Time, Flies_Like_An_Arrow) { ... }\nTEST(Time_Flies, Like_An_Arrow) { ... }\n```\n\nNow, the two `TEST`s will both generate the same class\n(`Time_Files_Like_An_Arrow_Test`).  That's not good.\n\nSo for simplicity, we just ask the users to avoid `_` in `TestCaseName`\nand `TestName`.  The rule is more constraining than necessary, but it's\nsimple and easy to remember.  It also gives Google Test some wiggle\nroom in case its implementation needs to change in the future.\n\nIf you violate the rule, there may not be immediately consequences,\nbut your test may (just may) break with a new compiler (or a new\nversion of the compiler you are using) or with a new version of Google\nTest.  Therefore it's best to follow the rule.\n\n## Why is it not recommended to install a pre-compiled copy of Google Test (for example, into /usr/local)? ##\n\nIn the early days, we said that you could install\ncompiled Google Test libraries on `*`nix systems using `make install`.\nThen every user of your machine can write tests without\nrecompiling Google Test.\n\nThis seemed like a good idea, but it has a\ngot-cha: every user needs to compile his tests using the _same_ compiler\nflags used to compile the installed Google Test libraries; otherwise\nhe may run into undefined behaviors (i.e. the tests can behave\nstrangely and may even crash for no obvious reasons).\n\nWhy?  Because C++ has this thing called the One-Definition Rule: if\ntwo C++ source files contain different definitions of the same\nclass/function/variable, and you link them together, you violate the\nrule.  The linker may or may not catch the error (in many cases it's\nnot required by the C++ standard to catch the violation).  If it\ndoesn't, you get strange run-time behaviors that are unexpected and\nhard to debug.\n\nIf you compile Google Test and your test code using different compiler\nflags, they may see different definitions of the same\nclass/function/variable (e.g. due to the use of `#if` in Google Test).\nTherefore, for your sanity, we recommend to avoid installing pre-compiled\nGoogle Test libraries.  Instead, each project should compile\nGoogle Test itself such that it can be sure that the same flags are\nused for both Google Test and the tests.\n\n## How do I generate 64-bit binaries on Windows (using Visual Studio 2008)? ##\n\n(Answered by Trevor Robinson)\n\nLoad the supplied Visual Studio solution file, either `msvc\\gtest-md.sln` or\n`msvc\\gtest.sln`. Go through the migration wizard to migrate the\nsolution and project files to Visual Studio 2008. Select\n`Configuration Manager...` from the `Build` menu. Select `<New...>` from\nthe `Active solution platform` dropdown.  Select `x64` from the new\nplatform dropdown, leave `Copy settings from` set to `Win32` and\n`Create new project platforms` checked, then click `OK`. You now have\n`Win32` and `x64` platform configurations, selectable from the\n`Standard` toolbar, which allow you to toggle between building 32-bit or\n64-bit binaries (or both at once using Batch Build).\n\nIn order to prevent build output files from overwriting one another,\nyou'll need to change the `Intermediate Directory` settings for the\nnewly created platform configuration across all the projects. To do\nthis, multi-select (e.g. using shift-click) all projects (but not the\nsolution) in the `Solution Explorer`. Right-click one of them and\nselect `Properties`. In the left pane, select `Configuration Properties`,\nand from the `Configuration` dropdown, select `All Configurations`.\nMake sure the selected platform is `x64`. For the\n`Intermediate Directory` setting, change the value from\n`$(PlatformName)\\$(ConfigurationName)` to\n`$(OutDir)\\$(ProjectName)`. Click `OK` and then build the\nsolution. When the build is complete, the 64-bit binaries will be in\nthe `msvc\\x64\\Debug` directory.\n\n## Can I use Google Test on MinGW? ##\n\nWe haven't tested this ourselves, but Per Abrahamsen reported that he\nwas able to compile and install Google Test successfully when using\nMinGW from Cygwin.  You'll need to configure it with:\n\n`PATH/TO/configure CC=\"gcc -mno-cygwin\" CXX=\"g++ -mno-cygwin\"`\n\nYou should be able to replace the `-mno-cygwin` option with direct links\nto the real MinGW binaries, but we haven't tried that.\n\nCaveats:\n\n  * There are many warnings when compiling.\n  * `make check` will produce some errors as not all tests for Google Test itself are compatible with MinGW.\n\nWe also have reports on successful cross compilation of Google Test\nMinGW binaries on Linux using\n[these instructions](http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux#Cross-compiling_under_Linux_for_MS_Windows)\non the WxWidgets site.\n\nPlease contact `googletestframework@googlegroups.com` if you are\ninterested in improving the support for MinGW.\n\n## Why does Google Test support EXPECT\\_EQ(NULL, ptr) and ASSERT\\_EQ(NULL, ptr) but not EXPECT\\_NE(NULL, ptr) and ASSERT\\_NE(NULL, ptr)? ##\n\nDue to some peculiarity of C++, it requires some non-trivial template\nmeta programming tricks to support using `NULL` as an argument of the\n`EXPECT_XX()` and `ASSERT_XX()` macros. Therefore we only do it where\nit's most needed (otherwise we make the implementation of Google Test\nharder to maintain and more error-prone than necessary).\n\nThe `EXPECT_EQ()` macro takes the _expected_ value as its first\nargument and the _actual_ value as the second. It's reasonable that\nsomeone wants to write `EXPECT_EQ(NULL, some_expression)`, and this\nindeed was requested several times. Therefore we implemented it.\n\nThe need for `EXPECT_NE(NULL, ptr)` isn't nearly as strong. When the\nassertion fails, you already know that `ptr` must be `NULL`, so it\ndoesn't add any information to print ptr in this case. That means\n`EXPECT_TRUE(ptr != NULL)` works just as well.\n\nIf we were to support `EXPECT_NE(NULL, ptr)`, for consistency we'll\nhave to support `EXPECT_NE(ptr, NULL)` as well, as unlike `EXPECT_EQ`,\nwe don't have a convention on the order of the two arguments for\n`EXPECT_NE`. This means using the template meta programming tricks\ntwice in the implementation, making it even harder to understand and\nmaintain. We believe the benefit doesn't justify the cost.\n\nFinally, with the growth of Google Mock's [matcher](../../googlemock/docs/CookBook.md#using-matchers-in-google-test-assertions) library, we are\nencouraging people to use the unified `EXPECT_THAT(value, matcher)`\nsyntax more often in tests. One significant advantage of the matcher\napproach is that matchers can be easily combined to form new matchers,\nwhile the `EXPECT_NE`, etc, macros cannot be easily\ncombined. Therefore we want to invest more in the matchers than in the\n`EXPECT_XX()` macros.\n\n## Does Google Test support running tests in parallel? ##\n\nTest runners tend to be tightly coupled with the build/test\nenvironment, and Google Test doesn't try to solve the problem of\nrunning tests in parallel.  Instead, we tried to make Google Test work\nnicely with test runners.  For example, Google Test's XML report\ncontains the time spent on each test, and its `gtest_list_tests` and\n`gtest_filter` flags can be used for splitting the execution of test\nmethods into multiple processes.  These functionalities can help the\ntest runner run the tests in parallel.\n\n## Why don't Google Test run the tests in different threads to speed things up? ##\n\nIt's difficult to write thread-safe code.  Most tests are not written\nwith thread-safety in mind, and thus may not work correctly in a\nmulti-threaded setting.\n\nIf you think about it, it's already hard to make your code work when\nyou know what other threads are doing.  It's much harder, and\nsometimes even impossible, to make your code work when you don't know\nwhat other threads are doing (remember that test methods can be added,\ndeleted, or modified after your test was written).  If you want to run\nthe tests in parallel, you'd better run them in different processes.\n\n## Why aren't Google Test assertions implemented using exceptions? ##\n\nOur original motivation was to be able to use Google Test in projects\nthat disable exceptions.  Later we realized some additional benefits\nof this approach:\n\n  1. Throwing in a destructor is undefined behavior in C++.  Not using exceptions means Google Test's assertions are safe to use in destructors.\n  1. The `EXPECT_*` family of macros will continue even after a failure, allowing multiple failures in a `TEST` to be reported in a single run. This is a popular feature, as in C++ the edit-compile-test cycle is usually quite long and being able to fixing more than one thing at a time is a blessing.\n  1. If assertions are implemented using exceptions, a test may falsely ignore a failure if it's caught by user code:\n``` cpp\ntry { ... ASSERT_TRUE(...) ... }\ncatch (...) { ... }\n```\nThe above code will pass even if the `ASSERT_TRUE` throws.  While it's unlikely for someone to write this in a test, it's possible to run into this pattern when you write assertions in callbacks that are called by the code under test.\n\nThe downside of not using exceptions is that `ASSERT_*` (implemented\nusing `return`) will only abort the current function, not the current\n`TEST`.\n\n## Why do we use two different macros for tests with and without fixtures? ##\n\nUnfortunately, C++'s macro system doesn't allow us to use the same\nmacro for both cases.  One possibility is to provide only one macro\nfor tests with fixtures, and require the user to define an empty\nfixture sometimes:\n\n``` cpp\nclass FooTest : public ::testing::Test {};\n\nTEST_F(FooTest, DoesThis) { ... }\n```\nor\n``` cpp\ntypedef ::testing::Test FooTest;\n\nTEST_F(FooTest, DoesThat) { ... }\n```\n\nYet, many people think this is one line too many. :-) Our goal was to\nmake it really easy to write tests, so we tried to make simple tests\ntrivial to create.  That means using a separate macro for such tests.\n\nWe think neither approach is ideal, yet either of them is reasonable.\nIn the end, it probably doesn't matter much either way.\n\n## Why don't we use structs as test fixtures? ##\n\nWe like to use structs only when representing passive data.  This\ndistinction between structs and classes is good for documenting the\nintent of the code's author.  Since test fixtures have logic like\n`SetUp()` and `TearDown()`, they are better defined as classes.\n\n## Why are death tests implemented as assertions instead of using a test runner? ##\n\nOur goal was to make death tests as convenient for a user as C++\npossibly allows.  In particular:\n\n  * The runner-style requires to split the information into two pieces: the definition of the death test itself, and the specification for the runner on how to run the death test and what to expect.  The death test would be written in C++, while the runner spec may or may not be.  A user needs to carefully keep the two in sync. `ASSERT_DEATH(statement, expected_message)` specifies all necessary information in one place, in one language, without boilerplate code. It is very declarative.\n  * `ASSERT_DEATH` has a similar syntax and error-reporting semantics as other Google Test assertions, and thus is easy to learn.\n  * `ASSERT_DEATH` can be mixed with other assertions and other logic at your will.  You are not limited to one death test per test method. For example, you can write something like:\n``` cpp\n    if (FooCondition()) {\n      ASSERT_DEATH(Bar(), \"blah\");\n    } else {\n      ASSERT_EQ(5, Bar());\n    }\n```\nIf you prefer one death test per test method, you can write your tests in that style too, but we don't want to impose that on the users.  The fewer artificial limitations the better.\n  * `ASSERT_DEATH` can reference local variables in the current function, and you can decide how many death tests you want based on run-time information.  For example,\n``` cpp\n    const int count = GetCount();  // Only known at run time.\n    for (int i = 1; i <= count; i++) {\n      ASSERT_DEATH({\n        double* buffer = new double[i];\n        ... initializes buffer ...\n        Foo(buffer, i)\n      }, \"blah blah\");\n    }\n```\nThe runner-based approach tends to be more static and less flexible, or requires more user effort to get this kind of flexibility.\n\nAnother interesting thing about `ASSERT_DEATH` is that it calls `fork()`\nto create a child process to run the death test.  This is lightening\nfast, as `fork()` uses copy-on-write pages and incurs almost zero\noverhead, and the child process starts from the user-supplied\nstatement directly, skipping all global and local initialization and\nany code leading to the given statement.  If you launch the child\nprocess from scratch, it can take seconds just to load everything and\nstart running if the test links to many libraries dynamically.\n\n## My death test modifies some state, but the change seems lost after the death test finishes. Why? ##\n\nDeath tests (`EXPECT_DEATH`, etc) are executed in a sub-process s.t. the\nexpected crash won't kill the test program (i.e. the parent process). As a\nresult, any in-memory side effects they incur are observable in their\nrespective sub-processes, but not in the parent process. You can think of them\nas running in a parallel universe, more or less.\n\n## The compiler complains about \"undefined references\" to some static const member variables, but I did define them in the class body. What's wrong? ##\n\nIf your class has a static data member:\n\n``` cpp\n// foo.h\nclass Foo {\n  ...\n  static const int kBar = 100;\n};\n```\n\nYou also need to define it _outside_ of the class body in `foo.cc`:\n\n``` cpp\nconst int Foo::kBar;  // No initializer here.\n```\n\nOtherwise your code is **invalid C++**, and may break in unexpected ways. In\nparticular, using it in Google Test comparison assertions (`EXPECT_EQ`, etc)\nwill generate an \"undefined reference\" linker error.\n\n## I have an interface that has several implementations. Can I write a set of tests once and repeat them over all the implementations? ##\n\nGoogle Test doesn't yet have good support for this kind of tests, or\ndata-driven tests in general. We hope to be able to make improvements in this\narea soon.\n\n## Can I derive a test fixture from another? ##\n\nYes.\n\nEach test fixture has a corresponding and same named test case. This means only\none test case can use a particular fixture. Sometimes, however, multiple test\ncases may want to use the same or slightly different fixtures. For example, you\nmay want to make sure that all of a GUI library's test cases don't leak\nimportant system resources like fonts and brushes.\n\nIn Google Test, you share a fixture among test cases by putting the shared\nlogic in a base test fixture, then deriving from that base a separate fixture\nfor each test case that wants to use this common logic. You then use `TEST_F()`\nto write tests using each derived fixture.\n\nTypically, your code looks like this:\n\n``` cpp\n// Defines a base test fixture.\nclass BaseTest : public ::testing::Test {\n  protected:\n   ...\n};\n\n// Derives a fixture FooTest from BaseTest.\nclass FooTest : public BaseTest {\n  protected:\n    virtual void SetUp() {\n      BaseTest::SetUp();  // Sets up the base fixture first.\n      ... additional set-up work ...\n    }\n    virtual void TearDown() {\n      ... clean-up work for FooTest ...\n      BaseTest::TearDown();  // Remember to tear down the base fixture\n                             // after cleaning up FooTest!\n    }\n    ... functions and variables for FooTest ...\n};\n\n// Tests that use the fixture FooTest.\nTEST_F(FooTest, Bar) { ... }\nTEST_F(FooTest, Baz) { ... }\n\n... additional fixtures derived from BaseTest ...\n```\n\nIf necessary, you can continue to derive test fixtures from a derived fixture.\nGoogle Test has no limit on how deep the hierarchy can be.\n\nFor a complete example using derived test fixtures, see\n[sample5](../samples/sample5_unittest.cc).\n\n## My compiler complains \"void value not ignored as it ought to be.\" What does this mean? ##\n\nYou're probably using an `ASSERT_*()` in a function that doesn't return `void`.\n`ASSERT_*()` can only be used in `void` functions.\n\n## My death test hangs (or seg-faults). How do I fix it? ##\n\nIn Google Test, death tests are run in a child process and the way they work is\ndelicate. To write death tests you really need to understand how they work.\nPlease make sure you have read this.\n\nIn particular, death tests don't like having multiple threads in the parent\nprocess. So the first thing you can try is to eliminate creating threads\noutside of `EXPECT_DEATH()`.\n\nSometimes this is impossible as some library you must use may be creating\nthreads before `main()` is even reached. In this case, you can try to minimize\nthe chance of conflicts by either moving as many activities as possible inside\n`EXPECT_DEATH()` (in the extreme case, you want to move everything inside), or\nleaving as few things as possible in it. Also, you can try to set the death\ntest style to `\"threadsafe\"`, which is safer but slower, and see if it helps.\n\nIf you go with thread-safe death tests, remember that they rerun the test\nprogram from the beginning in the child process. Therefore make sure your\nprogram can run side-by-side with itself and is deterministic.\n\nIn the end, this boils down to good concurrent programming. You have to make\nsure that there is no race conditions or dead locks in your program. No silver\nbullet - sorry!\n\n## Should I use the constructor/destructor of the test fixture or the set-up/tear-down function? ##\n\nThe first thing to remember is that Google Test does not reuse the\nsame test fixture object across multiple tests. For each `TEST_F`,\nGoogle Test will create a fresh test fixture object, _immediately_\ncall `SetUp()`, run the test body, call `TearDown()`, and then\n_immediately_ delete the test fixture object.\n\nWhen you need to write per-test set-up and tear-down logic, you have\nthe choice between using the test fixture constructor/destructor or\n`SetUp()/TearDown()`. The former is usually preferred, as it has the\nfollowing benefits:\n\n  * By initializing a member variable in the constructor, we have the option to make it `const`, which helps prevent accidental changes to its value and makes the tests more obviously correct.\n  * In case we need to subclass the test fixture class, the subclass' constructor is guaranteed to call the base class' constructor first, and the subclass' destructor is guaranteed to call the base class' destructor afterward. With `SetUp()/TearDown()`, a subclass may make the mistake of forgetting to call the base class' `SetUp()/TearDown()` or call them at the wrong moment.\n\nYou may still want to use `SetUp()/TearDown()` in the following rare cases:\n  * If the tear-down operation could throw an exception, you must use `TearDown()` as opposed to the destructor, as throwing in a destructor leads to undefined behavior and usually will kill your program right away. Note that many standard libraries (like STL) may throw when exceptions are enabled in the compiler. Therefore you should prefer `TearDown()` if you want to write portable tests that work with or without exceptions.\n  * The assertion macros throw an exception when flag `--gtest_throw_on_failure` is specified. Therefore, you shouldn't use Google Test assertions in a destructor if you plan to run your tests with this flag.\n  * In a constructor or destructor, you cannot make a virtual function call on this object. (You can call a method declared as virtual, but it will be statically bound.) Therefore, if you need to call a method that will be overriden in a derived class, you have to use `SetUp()/TearDown()`.\n\n## The compiler complains \"no matching function to call\" when I use ASSERT\\_PREDn. How do I fix it? ##\n\nIf the predicate function you use in `ASSERT_PRED*` or `EXPECT_PRED*` is\noverloaded or a template, the compiler will have trouble figuring out which\noverloaded version it should use. `ASSERT_PRED_FORMAT*` and\n`EXPECT_PRED_FORMAT*` don't have this problem.\n\nIf you see this error, you might want to switch to\n`(ASSERT|EXPECT)_PRED_FORMAT*`, which will also give you a better failure\nmessage. If, however, that is not an option, you can resolve the problem by\nexplicitly telling the compiler which version to pick.\n\nFor example, suppose you have\n\n``` cpp\nbool IsPositive(int n) {\n  return n > 0;\n}\nbool IsPositive(double x) {\n  return x > 0;\n}\n```\n\nyou will get a compiler error if you write\n\n``` cpp\nEXPECT_PRED1(IsPositive, 5);\n```\n\nHowever, this will work:\n\n``` cpp\nEXPECT_PRED1(*static_cast<bool (*)(int)>*(IsPositive), 5);\n```\n\n(The stuff inside the angled brackets for the `static_cast` operator is the\ntype of the function pointer for the `int`-version of `IsPositive()`.)\n\nAs another example, when you have a template function\n\n``` cpp\ntemplate <typename T>\nbool IsNegative(T x) {\n  return x < 0;\n}\n```\n\nyou can use it in a predicate assertion like this:\n\n``` cpp\nASSERT_PRED1(IsNegative*<int>*, -5);\n```\n\nThings are more interesting if your template has more than one parameters. The\nfollowing won't compile:\n\n``` cpp\nASSERT_PRED2(*GreaterThan<int, int>*, 5, 0);\n```\n\n\nas the C++ pre-processor thinks you are giving `ASSERT_PRED2` 4 arguments,\nwhich is one more than expected. The workaround is to wrap the predicate\nfunction in parentheses:\n\n``` cpp\nASSERT_PRED2(*(GreaterThan<int, int>)*, 5, 0);\n```\n\n\n## My compiler complains about \"ignoring return value\" when I call RUN\\_ALL\\_TESTS(). Why? ##\n\nSome people had been ignoring the return value of `RUN_ALL_TESTS()`. That is,\ninstead of\n\n``` cpp\nreturn RUN_ALL_TESTS();\n```\n\nthey write\n\n``` cpp\nRUN_ALL_TESTS();\n```\n\nThis is wrong and dangerous. A test runner needs to see the return value of\n`RUN_ALL_TESTS()` in order to determine if a test has passed. If your `main()`\nfunction ignores it, your test will be considered successful even if it has a\nGoogle Test assertion failure. Very bad.\n\nTo help the users avoid this dangerous bug, the implementation of\n`RUN_ALL_TESTS()` causes gcc to raise this warning, when the return value is\nignored. If you see this warning, the fix is simple: just make sure its value\nis used as the return value of `main()`.\n\n## My compiler complains that a constructor (or destructor) cannot return a value. What's going on? ##\n\nDue to a peculiarity of C++, in order to support the syntax for streaming\nmessages to an `ASSERT_*`, e.g.\n\n``` cpp\nASSERT_EQ(1, Foo()) << \"blah blah\" << foo;\n```\n\nwe had to give up using `ASSERT*` and `FAIL*` (but not `EXPECT*` and\n`ADD_FAILURE*`) in constructors and destructors. The workaround is to move the\ncontent of your constructor/destructor to a private void member function, or\nswitch to `EXPECT_*()` if that works. This section in the user's guide explains\nit.\n\n## My set-up function is not called. Why? ##\n\nC++ is case-sensitive. It should be spelled as `SetUp()`.  Did you\nspell it as `Setup()`?\n\nSimilarly, sometimes people spell `SetUpTestCase()` as `SetupTestCase()` and\nwonder why it's never called.\n\n## How do I jump to the line of a failure in Emacs directly? ##\n\nGoogle Test's failure message format is understood by Emacs and many other\nIDEs, like acme and XCode. If a Google Test message is in a compilation buffer\nin Emacs, then it's clickable. You can now hit `enter` on a message to jump to\nthe corresponding source code, or use `C-x `` to jump to the next failure.\n\n## I have several test cases which share the same test fixture logic, do I have to define a new test fixture class for each of them? This seems pretty tedious. ##\n\nYou don't have to. Instead of\n\n``` cpp\nclass FooTest : public BaseTest {};\n\nTEST_F(FooTest, Abc) { ... }\nTEST_F(FooTest, Def) { ... }\n\nclass BarTest : public BaseTest {};\n\nTEST_F(BarTest, Abc) { ... }\nTEST_F(BarTest, Def) { ... }\n```\n\nyou can simply `typedef` the test fixtures:\n``` cpp\ntypedef BaseTest FooTest;\n\nTEST_F(FooTest, Abc) { ... }\nTEST_F(FooTest, Def) { ... }\n\ntypedef BaseTest BarTest;\n\nTEST_F(BarTest, Abc) { ... }\nTEST_F(BarTest, Def) { ... }\n```\n\n## The Google Test output is buried in a whole bunch of log messages. What do I do? ##\n\nThe Google Test output is meant to be a concise and human-friendly report. If\nyour test generates textual output itself, it will mix with the Google Test\noutput, making it hard to read. However, there is an easy solution to this\nproblem.\n\nSince most log messages go to stderr, we decided to let Google Test output go\nto stdout. This way, you can easily separate the two using redirection. For\nexample:\n```\n./my_test > googletest_output.txt\n```\n\n## Why should I prefer test fixtures over global variables? ##\n\nThere are several good reasons:\n  1. It's likely your test needs to change the states of its global variables. This makes it difficult to keep side effects from escaping one test and contaminating others, making debugging difficult. By using fixtures, each test has a fresh set of variables that's different (but with the same names). Thus, tests are kept independent of each other.\n  1. Global variables pollute the global namespace.\n  1. Test fixtures can be reused via subclassing, which cannot be done easily with global variables. This is useful if many test cases have something in common.\n\n## How do I test private class members without writing FRIEND\\_TEST()s? ##\n\nYou should try to write testable code, which means classes should be easily\ntested from their public interface. One way to achieve this is the Pimpl idiom:\nyou move all private members of a class into a helper class, and make all\nmembers of the helper class public.\n\nYou have several other options that don't require using `FRIEND_TEST`:\n  * Write the tests as members of the fixture class:\n``` cpp\nclass Foo {\n  friend class FooTest;\n  ...\n};\n\nclass FooTest : public ::testing::Test {\n protected:\n  ...\n  void Test1() {...} // This accesses private members of class Foo.\n  void Test2() {...} // So does this one.\n};\n\nTEST_F(FooTest, Test1) {\n  Test1();\n}\n\nTEST_F(FooTest, Test2) {\n  Test2();\n}\n```\n  * In the fixture class, write accessors for the tested class' private members, then use the accessors in your tests:\n``` cpp\nclass Foo {\n  friend class FooTest;\n  ...\n};\n\nclass FooTest : public ::testing::Test {\n protected:\n  ...\n  T1 get_private_member1(Foo* obj) {\n    return obj->private_member1_;\n  }\n};\n\nTEST_F(FooTest, Test1) {\n  ...\n  get_private_member1(x)\n  ...\n}\n```\n  * If the methods are declared **protected**, you can change their access level in a test-only subclass:\n``` cpp\nclass YourClass {\n  ...\n protected: // protected access for testability.\n  int DoSomethingReturningInt();\n  ...\n};\n\n// in the your_class_test.cc file:\nclass TestableYourClass : public YourClass {\n  ...\n public: using YourClass::DoSomethingReturningInt; // changes access rights\n  ...\n};\n\nTEST_F(YourClassTest, DoSomethingTest) {\n  TestableYourClass obj;\n  assertEquals(expected_value, obj.DoSomethingReturningInt());\n}\n```\n\n## How do I test private class static members without writing FRIEND\\_TEST()s? ##\n\nWe find private static methods clutter the header file.  They are\nimplementation details and ideally should be kept out of a .h. So often I make\nthem free functions instead.\n\nInstead of:\n``` cpp\n// foo.h\nclass Foo {\n  ...\n private:\n  static bool Func(int n);\n};\n\n// foo.cc\nbool Foo::Func(int n) { ... }\n\n// foo_test.cc\nEXPECT_TRUE(Foo::Func(12345));\n```\n\nYou probably should better write:\n``` cpp\n// foo.h\nclass Foo {\n  ...\n};\n\n// foo.cc\nnamespace internal {\n  bool Func(int n) { ... }\n}\n\n// foo_test.cc\nnamespace internal {\n  bool Func(int n);\n}\n\nEXPECT_TRUE(internal::Func(12345));\n```\n\n## I would like to run a test several times with different parameters. Do I need to write several similar copies of it? ##\n\nNo. You can use a feature called [value-parameterized tests](AdvancedGuide.md#Value_Parameterized_Tests) which\nlets you repeat your tests with different parameters, without defining it more than once.\n\n## How do I test a file that defines main()? ##\n\nTo test a `foo.cc` file, you need to compile and link it into your unit test\nprogram. However, when the file contains a definition for the `main()`\nfunction, it will clash with the `main()` of your unit test, and will result in\na build error.\n\nThe right solution is to split it into three files:\n  1. `foo.h` which contains the declarations,\n  1. `foo.cc` which contains the definitions except `main()`, and\n  1. `foo_main.cc` which contains nothing but the definition of `main()`.\n\nThen `foo.cc` can be easily tested.\n\nIf you are adding tests to an existing file and don't want an intrusive change\nlike this, there is a hack: just include the entire `foo.cc` file in your unit\ntest. For example:\n``` cpp\n// File foo_unittest.cc\n\n// The headers section\n...\n\n// Renames main() in foo.cc to make room for the unit test main()\n#define main FooMain\n\n#include \"a/b/foo.cc\"\n\n// The tests start here.\n...\n```\n\n\nHowever, please remember this is a hack and should only be used as the last\nresort.\n\n## What can the statement argument in ASSERT\\_DEATH() be? ##\n\n`ASSERT_DEATH(_statement_, _regex_)` (or any death assertion macro) can be used\nwherever `_statement_` is valid. So basically `_statement_` can be any C++\nstatement that makes sense in the current context. In particular, it can\nreference global and/or local variables, and can be:\n  * a simple function call (often the case),\n  * a complex expression, or\n  * a compound statement.\n\nSome examples are shown here:\n\n``` cpp\n// A death test can be a simple function call.\nTEST(MyDeathTest, FunctionCall) {\n  ASSERT_DEATH(Xyz(5), \"Xyz failed\");\n}\n\n// Or a complex expression that references variables and functions.\nTEST(MyDeathTest, ComplexExpression) {\n  const bool c = Condition();\n  ASSERT_DEATH((c ? Func1(0) : object2.Method(\"test\")),\n               \"(Func1|Method) failed\");\n}\n\n// Death assertions can be used any where in a function. In\n// particular, they can be inside a loop.\nTEST(MyDeathTest, InsideLoop) {\n  // Verifies that Foo(0), Foo(1), ..., and Foo(4) all die.\n  for (int i = 0; i < 5; i++) {\n    EXPECT_DEATH_M(Foo(i), \"Foo has \\\\d+ errors\",\n                   ::testing::Message() << \"where i is \" << i);\n  }\n}\n\n// A death assertion can contain a compound statement.\nTEST(MyDeathTest, CompoundStatement) {\n  // Verifies that at lease one of Bar(0), Bar(1), ..., and\n  // Bar(4) dies.\n  ASSERT_DEATH({\n    for (int i = 0; i < 5; i++) {\n      Bar(i);\n    }\n  },\n  \"Bar has \\\\d+ errors\");}\n```\n\n`googletest_unittest.cc` contains more examples if you are interested.\n\n## What syntax does the regular expression in ASSERT\\_DEATH use? ##\n\nOn POSIX systems, Google Test uses the POSIX Extended regular\nexpression syntax\n(http://en.wikipedia.org/wiki/Regular_expression#POSIX_Extended_Regular_Expressions).\nOn Windows, it uses a limited variant of regular expression\nsyntax. For more details, see the\n[regular expression syntax](AdvancedGuide.md#Regular_Expression_Syntax).\n\n## I have a fixture class Foo, but TEST\\_F(Foo, Bar) gives me error \"no matching function for call to Foo::Foo()\". Why? ##\n\nGoogle Test needs to be able to create objects of your test fixture class, so\nit must have a default constructor. Normally the compiler will define one for\nyou. However, there are cases where you have to define your own:\n  * If you explicitly declare a non-default constructor for class `Foo`, then you need to define a default constructor, even if it would be empty.\n  * If `Foo` has a const non-static data member, then you have to define the default constructor _and_ initialize the const member in the initializer list of the constructor. (Early versions of `gcc` doesn't force you to initialize the const member. It's a bug that has been fixed in `gcc 4`.)\n\n## Why does ASSERT\\_DEATH complain about previous threads that were already joined? ##\n\nWith the Linux pthread library, there is no turning back once you cross the\nline from single thread to multiple threads. The first time you create a\nthread, a manager thread is created in addition, so you get 3, not 2, threads.\nLater when the thread you create joins the main thread, the thread count\ndecrements by 1, but the manager thread will never be killed, so you still have\n2 threads, which means you cannot safely run a death test.\n\nThe new NPTL thread library doesn't suffer from this problem, as it doesn't\ncreate a manager thread. However, if you don't control which machine your test\nruns on, you shouldn't depend on this.\n\n## Why does Google Test require the entire test case, instead of individual tests, to be named FOODeathTest when it uses ASSERT\\_DEATH? ##\n\nGoogle Test does not interleave tests from different test cases. That is, it\nruns all tests in one test case first, and then runs all tests in the next test\ncase, and so on. Google Test does this because it needs to set up a test case\nbefore the first test in it is run, and tear it down afterwords. Splitting up\nthe test case would require multiple set-up and tear-down processes, which is\ninefficient and makes the semantics unclean.\n\nIf we were to determine the order of tests based on test name instead of test\ncase name, then we would have a problem with the following situation:\n\n``` cpp\nTEST_F(FooTest, AbcDeathTest) { ... }\nTEST_F(FooTest, Uvw) { ... }\n\nTEST_F(BarTest, DefDeathTest) { ... }\nTEST_F(BarTest, Xyz) { ... }\n```\n\nSince `FooTest.AbcDeathTest` needs to run before `BarTest.Xyz`, and we don't\ninterleave tests from different test cases, we need to run all tests in the\n`FooTest` case before running any test in the `BarTest` case. This contradicts\nwith the requirement to run `BarTest.DefDeathTest` before `FooTest.Uvw`.\n\n## But I don't like calling my entire test case FOODeathTest when it contains both death tests and non-death tests. What do I do? ##\n\nYou don't have to, but if you like, you may split up the test case into\n`FooTest` and `FooDeathTest`, where the names make it clear that they are\nrelated:\n\n``` cpp\nclass FooTest : public ::testing::Test { ... };\n\nTEST_F(FooTest, Abc) { ... }\nTEST_F(FooTest, Def) { ... }\n\ntypedef FooTest FooDeathTest;\n\nTEST_F(FooDeathTest, Uvw) { ... EXPECT_DEATH(...) ... }\nTEST_F(FooDeathTest, Xyz) { ... ASSERT_DEATH(...) ... }\n```\n\n## The compiler complains about \"no match for 'operator<<'\" when I use an assertion. What gives? ##\n\nIf you use a user-defined type `FooType` in an assertion, you must make sure\nthere is an `std::ostream& operator<<(std::ostream&, const FooType&)` function\ndefined such that we can print a value of `FooType`.\n\nIn addition, if `FooType` is declared in a name space, the `<<` operator also\nneeds to be defined in the _same_ name space.\n\n## How do I suppress the memory leak messages on Windows? ##\n\nSince the statically initialized Google Test singleton requires allocations on\nthe heap, the Visual C++ memory leak detector will report memory leaks at the\nend of the program run. The easiest way to avoid this is to use the\n`_CrtMemCheckpoint` and `_CrtMemDumpAllObjectsSince` calls to not report any\nstatically initialized heap objects. See MSDN for more details and additional\nheap check/debug routines.\n\n## I am building my project with Google Test in Visual Studio and all I'm getting is a bunch of linker errors (or warnings). Help! ##\n\nYou may get a number of the following linker error or warnings if you\nattempt to link your test project with the Google Test library when\nyour project and the are not built using the same compiler settings.\n\n  * LNK2005: symbol already defined in object\n  * LNK4217: locally defined symbol 'symbol' imported in function 'function'\n  * LNK4049: locally defined symbol 'symbol' imported\n\nThe Google Test project (gtest.vcproj) has the Runtime Library option\nset to /MT (use multi-threaded static libraries, /MTd for debug). If\nyour project uses something else, for example /MD (use multi-threaded\nDLLs, /MDd for debug), you need to change the setting in the Google\nTest project to match your project's.\n\nTo update this setting open the project properties in the Visual\nStudio IDE then select the branch Configuration Properties | C/C++ |\nCode Generation and change the option \"Runtime Library\".  You may also try\nusing gtest-md.vcproj instead of gtest.vcproj.\n\n## I put my tests in a library and Google Test doesn't run them. What's happening? ##\nHave you read a\n[warning](Primer.md#important-note-for-visual-c-users) on\nthe Google Test Primer page?\n\n## I want to use Google Test with Visual Studio but don't know where to start. ##\nMany people are in your position and one of the posted his solution to\nour mailing list.\n\n## I am seeing compile errors mentioning std::type\\_traits when I try to use Google Test on Solaris. ##\nGoogle Test uses parts of the standard C++ library that SunStudio does not support.\nOur users reported success using alternative implementations. Try running the build after runing this commad:\n\n`export CC=cc CXX=CC CXXFLAGS='-library=stlport4'`\n\n## How can my code detect if it is running in a test? ##\n\nIf you write code that sniffs whether it's running in a test and does\ndifferent things accordingly, you are leaking test-only logic into\nproduction code and there is no easy way to ensure that the test-only\ncode paths aren't run by mistake in production.  Such cleverness also\nleads to\n[Heisenbugs](http://en.wikipedia.org/wiki/Unusual_software_bug#Heisenbug).\nTherefore we strongly advise against the practice, and Google Test doesn't\nprovide a way to do it.\n\nIn general, the recommended way to cause the code to behave\ndifferently under test is [dependency injection](http://jamesshore.com/Blog/Dependency-Injection-Demystified.html).\nYou can inject different functionality from the test and from the\nproduction code.  Since your production code doesn't link in the\nfor-test logic at all, there is no danger in accidentally running it.\n\nHowever, if you _really_, _really_, _really_ have no choice, and if\nyou follow the rule of ending your test program names with `_test`,\nyou can use the _horrible_ hack of sniffing your executable name\n(`argv[0]` in `main()`) to know whether the code is under test.\n\n## Google Test defines a macro that clashes with one defined by another library. How do I deal with that? ##\n\nIn C++, macros don't obey namespaces.  Therefore two libraries that\nboth define a macro of the same name will clash if you `#include` both\ndefinitions.  In case a Google Test macro clashes with another\nlibrary, you can force Google Test to rename its macro to avoid the\nconflict.\n\nSpecifically, if both Google Test and some other code define macro\n`FOO`, you can add\n```\n  -DGTEST_DONT_DEFINE_FOO=1\n```\nto the compiler flags to tell Google Test to change the macro's name\nfrom `FOO` to `GTEST_FOO`. For example, with `-DGTEST_DONT_DEFINE_TEST=1`, you'll need to write\n``` cpp\n  GTEST_TEST(SomeTest, DoesThis) { ... }\n```\ninstead of\n``` cpp\n  TEST(SomeTest, DoesThis) { ... }\n```\nin order to define a test.\n\nCurrently, the following `TEST`, `FAIL`, `SUCCEED`, and the basic comparison assertion macros can have alternative names. You can see the full list of covered macros [here](http://www.google.com/codesearch?q=if+!GTEST_DONT_DEFINE_\\w%2B+package:http://googletest\\.googlecode\\.com+file:/include/gtest/gtest.h). More information can be found in the \"Avoiding Macro Name Clashes\" section of the README file.\n\n\n## Is it OK if I have two separate `TEST(Foo, Bar)` test methods defined in different namespaces? ##\n\nYes.\n\nThe rule is **all test methods in the same test case must use the same fixture class**. This means that the following is **allowed** because both tests use the same fixture class (`::testing::Test`).\n\n``` cpp\nnamespace foo {\nTEST(CoolTest, DoSomething) {\n  SUCCEED();\n}\n}  // namespace foo\n\nnamespace bar {\nTEST(CoolTest, DoSomething) {\n  SUCCEED();\n}\n}  // namespace foo\n```\n\nHowever, the following code is **not allowed** and will produce a runtime error from Google Test because the test methods are using different test fixture classes with the same test case name.\n\n``` cpp\nnamespace foo {\nclass CoolTest : public ::testing::Test {};  // Fixture foo::CoolTest\nTEST_F(CoolTest, DoSomething) {\n  SUCCEED();\n}\n}  // namespace foo\n\nnamespace bar {\nclass CoolTest : public ::testing::Test {};  // Fixture: bar::CoolTest\nTEST_F(CoolTest, DoSomething) {\n  SUCCEED();\n}\n}  // namespace foo\n```\n\n## How do I build Google Testing Framework with Xcode 4? ##\n\nIf you try to build Google Test's Xcode project with Xcode 4.0 or later, you may encounter an error message that looks like\n\"Missing SDK in target gtest\\_framework: /Developer/SDKs/MacOSX10.4u.sdk\". That means that Xcode does not support the SDK the project is targeting. See the Xcode section in the [README](../README.md) file on how to resolve this.\n\n## My question is not covered in your FAQ! ##\n\nIf you cannot find the answer to your question in this FAQ, there are\nsome other resources you can use:\n\n  1. read other [wiki pages](../docs),\n  1. search the mailing list [archive](https://groups.google.com/forum/#!forum/googletestframework),\n  1. ask it on [googletestframework@googlegroups.com](mailto:googletestframework@googlegroups.com) and someone will answer it (to prevent spam, we require you to join the [discussion group](http://groups.google.com/group/googletestframework) before you can post.).\n\nPlease note that creating an issue in the\n[issue tracker](https://github.com/google/googletest/issues) is _not_\na good way to get your answer, as it is monitored infrequently by a\nvery small number of people.\n\nWhen asking a question, it's helpful to provide as much of the\nfollowing information as possible (people cannot help you if there's\nnot enough information in your question):\n\n  * the version (or the commit hash if you check out from Git directly) of Google Test you use (Google Test is under active development, so it's possible that your problem has been solved in a later version),\n  * your operating system,\n  * the name and version of your compiler,\n  * the complete command line flags you give to your compiler,\n  * the complete compiler error messages (if the question is about compilation),\n  * the _actual_ code (ideally, a minimal but complete program) that has the problem you encounter.\n"
  },
  {
    "path": "utils/googletest/googletest/docs/Primer.md",
    "content": "\n\n# Introduction: Why Google C++ Testing Framework? #\n\n_Google C++ Testing Framework_ helps you write better C++ tests.\n\nNo matter whether you work on Linux, Windows, or a Mac, if you write C++ code,\nGoogle Test can help you.\n\nSo what makes a good test, and how does Google C++ Testing Framework fit in? We believe:\n  1. Tests should be _independent_ and _repeatable_. It's a pain to debug a test that succeeds or fails as a result of other tests.  Google C++ Testing Framework isolates the tests by running each of them on a different object. When a test fails, Google C++ Testing Framework allows you to run it in isolation for quick debugging.\n  1. Tests should be well _organized_ and reflect the structure of the tested code.  Google C++ Testing Framework groups related tests into test cases that can share data and subroutines. This common pattern is easy to recognize and makes tests easy to maintain. Such consistency is especially helpful when people switch projects and start to work on a new code base.\n  1. Tests should be _portable_ and _reusable_. The open-source community has a lot of code that is platform-neutral, its tests should also be platform-neutral.  Google C++ Testing Framework works on different OSes, with different compilers (gcc, MSVC, and others), with or without exceptions, so Google C++ Testing Framework tests can easily work with a variety of configurations.  (Note that the current release only contains build scripts for Linux - we are actively working on scripts for other platforms.)\n  1. When tests fail, they should provide as much _information_ about the problem as possible. Google C++ Testing Framework doesn't stop at the first test failure. Instead, it only stops the current test and continues with the next. You can also set up tests that report non-fatal failures after which the current test continues. Thus, you can detect and fix multiple bugs in a single run-edit-compile cycle.\n  1. The testing framework should liberate test writers from housekeeping chores and let them focus on the test _content_.  Google C++ Testing Framework automatically keeps track of all tests defined, and doesn't require the user to enumerate them in order to run them.\n  1. Tests should be _fast_. With Google C++ Testing Framework, you can reuse shared resources across tests and pay for the set-up/tear-down only once, without making tests depend on each other.\n\nSince Google C++ Testing Framework is based on the popular xUnit\narchitecture, you'll feel right at home if you've used JUnit or PyUnit before.\nIf not, it will take you about 10 minutes to learn the basics and get started.\nSo let's go!\n\n_Note:_ We sometimes refer to Google C++ Testing Framework informally\nas _Google Test_.\n\n# Setting up a New Test Project #\n\nTo write a test program using Google Test, you need to compile Google\nTest into a library and link your test with it.  We provide build\nfiles for some popular build systems: `msvc/` for Visual Studio,\n`xcode/` for Mac Xcode, `make/` for GNU make, `codegear/` for Borland\nC++ Builder, and the autotools script (deprecated) and\n`CMakeLists.txt` for CMake (recommended) in the Google Test root\ndirectory.  If your build system is not on this list, you can take a\nlook at `make/Makefile` to learn how Google Test should be compiled\n(basically you want to compile `src/gtest-all.cc` with `GTEST_ROOT`\nand `GTEST_ROOT/include` in the header search path, where `GTEST_ROOT`\nis the Google Test root directory).\n\nOnce you are able to compile the Google Test library, you should\ncreate a project or build target for your test program.  Make sure you\nhave `GTEST_ROOT/include` in the header search path so that the\ncompiler can find `\"gtest/gtest.h\"` when compiling your test.  Set up\nyour test project to link with the Google Test library (for example,\nin Visual Studio, this is done by adding a dependency on\n`gtest.vcproj`).\n\nIf you still have questions, take a look at how Google Test's own\ntests are built and use them as examples.\n\n# Basic Concepts #\n\nWhen using Google Test, you start by writing _assertions_, which are statements\nthat check whether a condition is true. An assertion's result can be _success_,\n_nonfatal failure_, or _fatal failure_. If a fatal failure occurs, it aborts\nthe current function; otherwise the program continues normally.\n\n_Tests_ use assertions to verify the tested code's behavior. If a test crashes\nor has a failed assertion, then it _fails_; otherwise it _succeeds_.\n\nA _test case_ contains one or many tests. You should group your tests into test\ncases that reflect the structure of the tested code. When multiple tests in a\ntest case need to share common objects and subroutines, you can put them into a\n_test fixture_ class.\n\nA _test program_ can contain multiple test cases.\n\nWe'll now explain how to write a test program, starting at the individual\nassertion level and building up to tests and test cases.\n\n# Assertions #\n\nGoogle Test assertions are macros that resemble function calls. You test a\nclass or function by making assertions about its behavior. When an assertion\nfails, Google Test prints the assertion's source file and line number location,\nalong with a failure message. You may also supply a custom failure message\nwhich will be appended to Google Test's message.\n\nThe assertions come in pairs that test the same thing but have different\neffects on the current function. `ASSERT_*` versions generate fatal failures\nwhen they fail, and **abort the current function**. `EXPECT_*` versions generate\nnonfatal failures, which don't abort the current function. Usually `EXPECT_*`\nare preferred, as they allow more than one failures to be reported in a test.\nHowever, you should use `ASSERT_*` if it doesn't make sense to continue when\nthe assertion in question fails.\n\nSince a failed `ASSERT_*` returns from the current function immediately,\npossibly skipping clean-up code that comes after it, it may cause a space leak.\nDepending on the nature of the leak, it may or may not be worth fixing - so\nkeep this in mind if you get a heap checker error in addition to assertion\nerrors.\n\nTo provide a custom failure message, simply stream it into the macro using the\n`<<` operator, or a sequence of such operators. An example:\n```\nASSERT_EQ(x.size(), y.size()) << \"Vectors x and y are of unequal length\";\n\nfor (int i = 0; i < x.size(); ++i) {\n  EXPECT_EQ(x[i], y[i]) << \"Vectors x and y differ at index \" << i;\n}\n```\n\nAnything that can be streamed to an `ostream` can be streamed to an assertion\nmacro--in particular, C strings and `string` objects. If a wide string\n(`wchar_t*`, `TCHAR*` in `UNICODE` mode on Windows, or `std::wstring`) is\nstreamed to an assertion, it will be translated to UTF-8 when printed.\n\n## Basic Assertions ##\n\nThese assertions do basic true/false condition testing.\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_TRUE(`_condition_`)`;  | `EXPECT_TRUE(`_condition_`)`;   | _condition_ is true |\n| `ASSERT_FALSE(`_condition_`)`; | `EXPECT_FALSE(`_condition_`)`;  | _condition_ is false |\n\nRemember, when they fail, `ASSERT_*` yields a fatal failure and\nreturns from the current function, while `EXPECT_*` yields a nonfatal\nfailure, allowing the function to continue running. In either case, an\nassertion failure means its containing test fails.\n\n_Availability_: Linux, Windows, Mac.\n\n## Binary Comparison ##\n\nThis section describes assertions that compare two values.\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n|`ASSERT_EQ(`_val1_`, `_val2_`);`|`EXPECT_EQ(`_val1_`, `_val2_`);`| _val1_ `==` _val2_ |\n|`ASSERT_NE(`_val1_`, `_val2_`);`|`EXPECT_NE(`_val1_`, `_val2_`);`| _val1_ `!=` _val2_ |\n|`ASSERT_LT(`_val1_`, `_val2_`);`|`EXPECT_LT(`_val1_`, `_val2_`);`| _val1_ `<` _val2_ |\n|`ASSERT_LE(`_val1_`, `_val2_`);`|`EXPECT_LE(`_val1_`, `_val2_`);`| _val1_ `<=` _val2_ |\n|`ASSERT_GT(`_val1_`, `_val2_`);`|`EXPECT_GT(`_val1_`, `_val2_`);`| _val1_ `>` _val2_ |\n|`ASSERT_GE(`_val1_`, `_val2_`);`|`EXPECT_GE(`_val1_`, `_val2_`);`| _val1_ `>=` _val2_ |\n\nIn the event of a failure, Google Test prints both _val1_ and _val2_.\n\nValue arguments must be comparable by the assertion's comparison\noperator or you'll get a compiler error.  We used to require the\narguments to support the `<<` operator for streaming to an `ostream`,\nbut it's no longer necessary since v1.6.0 (if `<<` is supported, it\nwill be called to print the arguments when the assertion fails;\notherwise Google Test will attempt to print them in the best way it\ncan. For more details and how to customize the printing of the\narguments, see this Google Mock [recipe](../../googlemock/docs/CookBook.md#teaching-google-mock-how-to-print-your-values).).\n\nThese assertions can work with a user-defined type, but only if you define the\ncorresponding comparison operator (e.g. `==`, `<`, etc).  If the corresponding\noperator is defined, prefer using the `ASSERT_*()` macros because they will\nprint out not only the result of the comparison, but the two operands as well.\n\nArguments are always evaluated exactly once. Therefore, it's OK for the\narguments to have side effects. However, as with any ordinary C/C++ function,\nthe arguments' evaluation order is undefined (i.e. the compiler is free to\nchoose any order) and your code should not depend on any particular argument\nevaluation order.\n\n`ASSERT_EQ()` does pointer equality on pointers. If used on two C strings, it\ntests if they are in the same memory location, not if they have the same value.\nTherefore, if you want to compare C strings (e.g. `const char*`) by value, use\n`ASSERT_STREQ()` , which will be described later on. In particular, to assert\nthat a C string is `NULL`, use `ASSERT_STREQ(NULL, c_string)` . However, to\ncompare two `string` objects, you should use `ASSERT_EQ`.\n\nMacros in this section work with both narrow and wide string objects (`string`\nand `wstring`).\n\n_Availability_: Linux, Windows, Mac.\n\n_Historical note_: Before February 2016 `*_EQ` had a convention of calling it as\n`ASSERT_EQ(expected, actual)`, so lots of existing code uses this order.\nNow `*_EQ` treats both parameters in the same way.\n\n## String Comparison ##\n\nThe assertions in this group compare two **C strings**. If you want to compare\ntwo `string` objects, use `EXPECT_EQ`, `EXPECT_NE`, and etc instead.\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_STREQ(`_str1_`, `_str2_`);`    | `EXPECT_STREQ(`_str1_`, `_str_2`);`     | the two C strings have the same content |\n| `ASSERT_STRNE(`_str1_`, `_str2_`);`    | `EXPECT_STRNE(`_str1_`, `_str2_`);`     | the two C strings have different content |\n| `ASSERT_STRCASEEQ(`_str1_`, `_str2_`);`| `EXPECT_STRCASEEQ(`_str1_`, `_str2_`);` | the two C strings have the same content, ignoring case |\n| `ASSERT_STRCASENE(`_str1_`, `_str2_`);`| `EXPECT_STRCASENE(`_str1_`, `_str2_`);` | the two C strings have different content, ignoring case |\n\nNote that \"CASE\" in an assertion name means that case is ignored.\n\n`*STREQ*` and `*STRNE*` also accept wide C strings (`wchar_t*`). If a\ncomparison of two wide strings fails, their values will be printed as UTF-8\nnarrow strings.\n\nA `NULL` pointer and an empty string are considered _different_.\n\n_Availability_: Linux, Windows, Mac.\n\nSee also: For more string comparison tricks (substring, prefix, suffix, and\nregular expression matching, for example), see the [Advanced Google Test Guide](AdvancedGuide.md).\n\n# Simple Tests #\n\nTo create a test:\n  1. Use the `TEST()` macro to define and name a test function, These are ordinary C++ functions that don't return a value.\n  1. In this function, along with any valid C++ statements you want to include, use the various Google Test assertions to check values.\n  1. The test's result is determined by the assertions; if any assertion in the test fails (either fatally or non-fatally), or if the test crashes, the entire test fails. Otherwise, it succeeds.\n\n```\nTEST(test_case_name, test_name) {\n ... test body ...\n}\n```\n\n\n`TEST()` arguments go from general to specific. The _first_ argument is the\nname of the test case, and the _second_ argument is the test's name within the\ntest case. Both names must be valid C++ identifiers, and they should not contain underscore (`_`). A test's _full name_ consists of its containing test case and its\nindividual name. Tests from different test cases can have the same individual\nname.\n\nFor example, let's take a simple integer function:\n```\nint Factorial(int n); // Returns the factorial of n\n```\n\nA test case for this function might look like:\n```\n// Tests factorial of 0.\nTEST(FactorialTest, HandlesZeroInput) {\n  EXPECT_EQ(1, Factorial(0));\n}\n\n// Tests factorial of positive numbers.\nTEST(FactorialTest, HandlesPositiveInput) {\n  EXPECT_EQ(1, Factorial(1));\n  EXPECT_EQ(2, Factorial(2));\n  EXPECT_EQ(6, Factorial(3));\n  EXPECT_EQ(40320, Factorial(8));\n}\n```\n\nGoogle Test groups the test results by test cases, so logically-related tests\nshould be in the same test case; in other words, the first argument to their\n`TEST()` should be the same. In the above example, we have two tests,\n`HandlesZeroInput` and `HandlesPositiveInput`, that belong to the same test\ncase `FactorialTest`.\n\n_Availability_: Linux, Windows, Mac.\n\n# Test Fixtures: Using the Same Data Configuration for Multiple Tests #\n\nIf you find yourself writing two or more tests that operate on similar data,\nyou can use a _test fixture_. It allows you to reuse the same configuration of\nobjects for several different tests.\n\nTo create a fixture, just:\n  1. Derive a class from `::testing::Test` . Start its body with `protected:` or `public:` as we'll want to access fixture members from sub-classes.\n  1. Inside the class, declare any objects you plan to use.\n  1. If necessary, write a default constructor or `SetUp()` function to prepare the objects for each test. A common mistake is to spell `SetUp()` as `Setup()` with a small `u` - don't let that happen to you.\n  1. If necessary, write a destructor or `TearDown()` function to release any resources you allocated in `SetUp()` . To learn when you should use the constructor/destructor and when you should use `SetUp()/TearDown()`, read this [FAQ entry](FAQ.md#should-i-use-the-constructordestructor-of-the-test-fixture-or-the-set-uptear-down-function).\n  1. If needed, define subroutines for your tests to share.\n\nWhen using a fixture, use `TEST_F()` instead of `TEST()` as it allows you to\naccess objects and subroutines in the test fixture:\n```\nTEST_F(test_case_name, test_name) {\n ... test body ...\n}\n```\n\nLike `TEST()`, the first argument is the test case name, but for `TEST_F()`\nthis must be the name of the test fixture class. You've probably guessed: `_F`\nis for fixture.\n\nUnfortunately, the C++ macro system does not allow us to create a single macro\nthat can handle both types of tests. Using the wrong macro causes a compiler\nerror.\n\nAlso, you must first define a test fixture class before using it in a\n`TEST_F()`, or you'll get the compiler error \"`virtual outside class\ndeclaration`\".\n\nFor each test defined with `TEST_F()`, Google Test will:\n  1. Create a _fresh_ test fixture at runtime\n  1. Immediately initialize it via `SetUp()` ,\n  1. Run the test\n  1. Clean up by calling `TearDown()`\n  1. Delete the test fixture.  Note that different tests in the same test case have different test fixture objects, and Google Test always deletes a test fixture before it creates the next one. Google Test does not reuse the same test fixture for multiple tests. Any changes one test makes to the fixture do not affect other tests.\n\nAs an example, let's write tests for a FIFO queue class named `Queue`, which\nhas the following interface:\n```\ntemplate <typename E> // E is the element type.\nclass Queue {\n public:\n  Queue();\n  void Enqueue(const E& element);\n  E* Dequeue(); // Returns NULL if the queue is empty.\n  size_t size() const;\n  ...\n};\n```\n\nFirst, define a fixture class. By convention, you should give it the name\n`FooTest` where `Foo` is the class being tested.\n```\nclass QueueTest : public ::testing::Test {\n protected:\n  virtual void SetUp() {\n    q1_.Enqueue(1);\n    q2_.Enqueue(2);\n    q2_.Enqueue(3);\n  }\n\n  // virtual void TearDown() {}\n\n  Queue<int> q0_;\n  Queue<int> q1_;\n  Queue<int> q2_;\n};\n```\n\nIn this case, `TearDown()` is not needed since we don't have to clean up after\neach test, other than what's already done by the destructor.\n\nNow we'll write tests using `TEST_F()` and this fixture.\n```\nTEST_F(QueueTest, IsEmptyInitially) {\n  EXPECT_EQ(0, q0_.size());\n}\n\nTEST_F(QueueTest, DequeueWorks) {\n  int* n = q0_.Dequeue();\n  EXPECT_EQ(NULL, n);\n\n  n = q1_.Dequeue();\n  ASSERT_TRUE(n != NULL);\n  EXPECT_EQ(1, *n);\n  EXPECT_EQ(0, q1_.size());\n  delete n;\n\n  n = q2_.Dequeue();\n  ASSERT_TRUE(n != NULL);\n  EXPECT_EQ(2, *n);\n  EXPECT_EQ(1, q2_.size());\n  delete n;\n}\n```\n\nThe above uses both `ASSERT_*` and `EXPECT_*` assertions. The rule of thumb is\nto use `EXPECT_*` when you want the test to continue to reveal more errors\nafter the assertion failure, and use `ASSERT_*` when continuing after failure\ndoesn't make sense. For example, the second assertion in the `Dequeue` test is\n`ASSERT_TRUE(n != NULL)`, as we need to dereference the pointer `n` later,\nwhich would lead to a segfault when `n` is `NULL`.\n\nWhen these tests run, the following happens:\n  1. Google Test constructs a `QueueTest` object (let's call it `t1` ).\n  1. `t1.SetUp()` initializes `t1` .\n  1. The first test ( `IsEmptyInitially` ) runs on `t1` .\n  1. `t1.TearDown()` cleans up after the test finishes.\n  1. `t1` is destructed.\n  1. The above steps are repeated on another `QueueTest` object, this time running the `DequeueWorks` test.\n\n_Availability_: Linux, Windows, Mac.\n\n_Note_: Google Test automatically saves all _Google Test_ flags when a test\nobject is constructed, and restores them when it is destructed.\n\n# Invoking the Tests #\n\n`TEST()` and `TEST_F()` implicitly register their tests with Google Test. So, unlike with many other C++ testing frameworks, you don't have to re-list all your defined tests in order to run them.\n\nAfter defining your tests, you can run them with `RUN_ALL_TESTS()` , which returns `0` if all the tests are successful, or `1` otherwise. Note that `RUN_ALL_TESTS()` runs _all tests_ in your link unit -- they can be from different test cases, or even different source files.\n\nWhen invoked, the `RUN_ALL_TESTS()` macro:\n  1. Saves the state of all  Google Test flags.\n  1. Creates a test fixture object for the first test.\n  1. Initializes it via `SetUp()`.\n  1. Runs the test on the fixture object.\n  1. Cleans up the fixture via `TearDown()`.\n  1. Deletes the fixture.\n  1. Restores the state of all Google Test flags.\n  1. Repeats the above steps for the next test, until all tests have run.\n\nIn addition, if the text fixture's constructor generates a fatal failure in\nstep 2, there is no point for step 3 - 5 and they are thus skipped. Similarly,\nif step 3 generates a fatal failure, step 4 will be skipped.\n\n_Important_: You must not ignore the return value of `RUN_ALL_TESTS()`, or `gcc`\nwill give you a compiler error. The rationale for this design is that the\nautomated testing service determines whether a test has passed based on its\nexit code, not on its stdout/stderr output; thus your `main()` function must\nreturn the value of `RUN_ALL_TESTS()`.\n\nAlso, you should call `RUN_ALL_TESTS()` only **once**. Calling it more than once\nconflicts with some advanced Google Test features (e.g. thread-safe death\ntests) and thus is not supported.\n\n_Availability_: Linux, Windows, Mac.\n\n# Writing the main() Function #\n\nYou can start from this boilerplate:\n```\n#include \"this/package/foo.h\"\n#include \"gtest/gtest.h\"\n\nnamespace {\n\n// The fixture for testing class Foo.\nclass FooTest : public ::testing::Test {\n protected:\n  // You can remove any or all of the following functions if its body\n  // is empty.\n\n  FooTest() {\n    // You can do set-up work for each test here.\n  }\n\n  virtual ~FooTest() {\n    // You can do clean-up work that doesn't throw exceptions here.\n  }\n\n  // If the constructor and destructor are not enough for setting up\n  // and cleaning up each test, you can define the following methods:\n\n  virtual void SetUp() {\n    // Code here will be called immediately after the constructor (right\n    // before each test).\n  }\n\n  virtual void TearDown() {\n    // Code here will be called immediately after each test (right\n    // before the destructor).\n  }\n\n  // Objects declared here can be used by all tests in the test case for Foo.\n};\n\n// Tests that the Foo::Bar() method does Abc.\nTEST_F(FooTest, MethodBarDoesAbc) {\n  const string input_filepath = \"this/package/testdata/myinputfile.dat\";\n  const string output_filepath = \"this/package/testdata/myoutputfile.dat\";\n  Foo f;\n  EXPECT_EQ(0, f.Bar(input_filepath, output_filepath));\n}\n\n// Tests that Foo does Xyz.\nTEST_F(FooTest, DoesXyz) {\n  // Exercises the Xyz feature of Foo.\n}\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n```\n\nThe `::testing::InitGoogleTest()` function parses the command line for Google\nTest flags, and removes all recognized flags. This allows the user to control a\ntest program's behavior via various flags, which we'll cover in [AdvancedGuide](AdvancedGuide.md).\nYou must call this function before calling `RUN_ALL_TESTS()`, or the flags\nwon't be properly initialized.\n\nOn Windows, `InitGoogleTest()` also works with wide strings, so it can be used\nin programs compiled in `UNICODE` mode as well.\n\nBut maybe you think that writing all those main() functions is too much work? We agree with you completely and that's why Google Test provides a basic implementation of main(). If it fits your needs, then just link your test with gtest\\_main library and you are good to go.\n\n## Important note for Visual C++ users ##\nIf you put your tests into a library and your `main()` function is in a different library or in your .exe file, those tests will not run. The reason is a [bug](https://connect.microsoft.com/feedback/viewfeedback.aspx?FeedbackID=244410&siteid=210) in Visual C++. When you define your tests, Google Test creates certain static objects to register them. These objects are not referenced from elsewhere but their constructors are still supposed to run. When Visual C++ linker sees that nothing in the library is referenced from other places it throws the library out. You have to reference your library with tests from your main program to keep the linker from discarding it. Here is how to do it. Somewhere in your library code declare a function:\n```\n__declspec(dllexport) int PullInMyLibrary() { return 0; }\n```\nIf you put your tests in a static library (not DLL) then `__declspec(dllexport)` is not required. Now, in your main program, write a code that invokes that function:\n```\nint PullInMyLibrary();\nstatic int dummy = PullInMyLibrary();\n```\nThis will keep your tests referenced and will make them register themselves at startup.\n\nIn addition, if you define your tests in a static library, add `/OPT:NOREF` to your main program linker options. If you use MSVC++ IDE, go to your .exe project properties/Configuration Properties/Linker/Optimization and set References setting to `Keep Unreferenced Data (/OPT:NOREF)`. This will keep Visual C++ linker from discarding individual symbols generated by your tests from the final executable.\n\nThere is one more pitfall, though. If you use Google Test as a static library (that's how it is defined in gtest.vcproj) your tests must also reside in a static library. If you have to have them in a DLL, you _must_ change Google Test to build into a DLL as well. Otherwise your tests will not run correctly or will not run at all. The general conclusion here is: make your life easier - do not write your tests in libraries!\n\n# Where to Go from Here #\n\nCongratulations! You've learned the Google Test basics. You can start writing\nand running Google Test tests, read some [samples](Samples.md), or continue with\n[AdvancedGuide](AdvancedGuide.md), which describes many more useful Google Test features.\n\n# Known Limitations #\n\nGoogle Test is designed to be thread-safe.  The implementation is\nthread-safe on systems where the `pthreads` library is available.  It\nis currently _unsafe_ to use Google Test assertions from two threads\nconcurrently on other systems (e.g. Windows).  In most tests this is\nnot an issue as usually the assertions are done in the main thread. If\nyou want to help, you can volunteer to implement the necessary\nsynchronization primitives in `gtest-port.h` for your platform.\n"
  },
  {
    "path": "utils/googletest/googletest/docs/PumpManual.md",
    "content": "\n\n<b>P</b>ump is <b>U</b>seful for <b>M</b>eta <b>P</b>rogramming.\n\n# The Problem #\n\nTemplate and macro libraries often need to define many classes,\nfunctions, or macros that vary only (or almost only) in the number of\narguments they take. It's a lot of repetitive, mechanical, and\nerror-prone work.\n\nVariadic templates and variadic macros can alleviate the problem.\nHowever, while both are being considered by the C++ committee, neither\nis in the standard yet or widely supported by compilers.  Thus they\nare often not a good choice, especially when your code needs to be\nportable. And their capabilities are still limited.\n\nAs a result, authors of such libraries often have to write scripts to\ngenerate their implementation. However, our experience is that it's\ntedious to write such scripts, which tend to reflect the structure of\nthe generated code poorly and are often hard to read and edit. For\nexample, a small change needed in the generated code may require some\nnon-intuitive, non-trivial changes in the script. This is especially\npainful when experimenting with the code.\n\n# Our Solution #\n\nPump (for Pump is Useful for Meta Programming, Pretty Useful for Meta\nProgramming, or Practical Utility for Meta Programming, whichever you\nprefer) is a simple meta-programming tool for C++. The idea is that a\nprogrammer writes a `foo.pump` file which contains C++ code plus meta\ncode that manipulates the C++ code. The meta code can handle\niterations over a range, nested iterations, local meta variable\ndefinitions, simple arithmetic, and conditional expressions. You can\nview it as a small Domain-Specific Language. The meta language is\ndesigned to be non-intrusive (s.t. it won't confuse Emacs' C++ mode,\nfor example) and concise, making Pump code intuitive and easy to\nmaintain.\n\n## Highlights ##\n\n  * The implementation is in a single Python script and thus ultra portable: no build or installation is needed and it works cross platforms.\n  * Pump tries to be smart with respect to [Google's style guide](http://code.google.com/p/google-styleguide/): it breaks long lines (easy to have when they are generated) at acceptable places to fit within 80 columns and indent the continuation lines correctly.\n  * The format is human-readable and more concise than XML.\n  * The format works relatively well with Emacs' C++ mode.\n\n## Examples ##\n\nThe following Pump code (where meta keywords start with `$`, `[[` and `]]` are meta brackets, and `$$` starts a meta comment that ends with the line):\n\n```\n$var n = 3     $$ Defines a meta variable n.\n$range i 0..n  $$ Declares the range of meta iterator i (inclusive).\n$for i [[\n               $$ Meta loop.\n// Foo$i does blah for $i-ary predicates.\n$range j 1..i\ntemplate <size_t N $for j [[, typename A$j]]>\nclass Foo$i {\n$if i == 0 [[\n  blah a;\n]] $elif i <= 2 [[\n  blah b;\n]] $else [[\n  blah c;\n]]\n};\n\n]]\n```\n\nwill be translated by the Pump compiler to:\n\n```\n// Foo0 does blah for 0-ary predicates.\ntemplate <size_t N>\nclass Foo0 {\n  blah a;\n};\n\n// Foo1 does blah for 1-ary predicates.\ntemplate <size_t N, typename A1>\nclass Foo1 {\n  blah b;\n};\n\n// Foo2 does blah for 2-ary predicates.\ntemplate <size_t N, typename A1, typename A2>\nclass Foo2 {\n  blah b;\n};\n\n// Foo3 does blah for 3-ary predicates.\ntemplate <size_t N, typename A1, typename A2, typename A3>\nclass Foo3 {\n  blah c;\n};\n```\n\nIn another example,\n\n```\n$range i 1..n\nFunc($for i + [[a$i]]);\n$$ The text between i and [[ is the separator between iterations.\n```\n\nwill generate one of the following lines (without the comments), depending on the value of `n`:\n\n```\nFunc();              // If n is 0.\nFunc(a1);            // If n is 1.\nFunc(a1 + a2);       // If n is 2.\nFunc(a1 + a2 + a3);  // If n is 3.\n// And so on...\n```\n\n## Constructs ##\n\nWe support the following meta programming constructs:\n\n| `$var id = exp` | Defines a named constant value. `$id` is valid util the end of the current meta lexical block. |\n|:----------------|:-----------------------------------------------------------------------------------------------|\n| `$range id exp..exp` | Sets the range of an iteration variable, which can be reused in multiple loops later.          |\n| `$for id sep [[ code ]]` | Iteration. The range of `id` must have been defined earlier. `$id` is valid in `code`.         |\n| `$($)`          | Generates a single `$` character.                                                              |\n| `$id`           | Value of the named constant or iteration variable.                                             |\n| `$(exp)`        | Value of the expression.                                                                       |\n| `$if exp [[ code ]] else_branch` | Conditional.                                                                                   |\n| `[[ code ]]`    | Meta lexical block.                                                                            |\n| `cpp_code`      | Raw C++ code.                                                                                  |\n| `$$ comment`    | Meta comment.                                                                                  |\n\n**Note:** To give the user some freedom in formatting the Pump source\ncode, Pump ignores a new-line character if it's right after `$for foo`\nor next to `[[` or `]]`. Without this rule you'll often be forced to write\nvery long lines to get the desired output. Therefore sometimes you may\nneed to insert an extra new-line in such places for a new-line to show\nup in your output.\n\n## Grammar ##\n\n```\ncode ::= atomic_code*\natomic_code ::= $var id = exp\n    | $var id = [[ code ]]\n    | $range id exp..exp\n    | $for id sep [[ code ]]\n    | $($)\n    | $id\n    | $(exp)\n    | $if exp [[ code ]] else_branch\n    | [[ code ]]\n    | cpp_code\nsep ::= cpp_code | empty_string\nelse_branch ::= $else [[ code ]]\n    | $elif exp [[ code ]] else_branch\n    | empty_string\nexp ::= simple_expression_in_Python_syntax\n```\n\n## Code ##\n\nYou can find the source code of Pump in [scripts/pump.py](../scripts/pump.py). It is still\nvery unpolished and lacks automated tests, although it has been\nsuccessfully used many times. If you find a chance to use it in your\nproject, please let us know what you think!  We also welcome help on\nimproving Pump.\n\n## Real Examples ##\n\nYou can find real-world applications of Pump in [Google Test](http://www.google.com/codesearch?q=file%3A\\.pump%24+package%3Ahttp%3A%2F%2Fgoogletest\\.googlecode\\.com) and [Google Mock](http://www.google.com/codesearch?q=file%3A\\.pump%24+package%3Ahttp%3A%2F%2Fgooglemock\\.googlecode\\.com).  The source file `foo.h.pump` generates `foo.h`.\n\n## Tips ##\n\n  * If a meta variable is followed by a letter or digit, you can separate them using `[[]]`, which inserts an empty string. For example `Foo$j[[]]Helper` generate `Foo1Helper` when `j` is 1.\n  * To avoid extra-long Pump source lines, you can break a line anywhere you want by inserting `[[]]` followed by a new line. Since any new-line character next to `[[` or `]]` is ignored, the generated code won't contain this new line.\n"
  },
  {
    "path": "utils/googletest/googletest/docs/Samples.md",
    "content": "If you're like us, you'd like to look at some Google Test sample code.  The\n[samples folder](../samples) has a number of well-commented samples showing how to use a\nvariety of Google Test features.\n\n  * [Sample #1](../samples/sample1_unittest.cc) shows the basic steps of using Google Test to test C++ functions.\n  * [Sample #2](../samples/sample2_unittest.cc) shows a more complex unit test for a class with multiple member functions.\n  * [Sample #3](../samples/sample3_unittest.cc) uses a test fixture.\n  * [Sample #4](../samples/sample4_unittest.cc) is another basic example of using Google Test.\n  * [Sample #5](../samples/sample5_unittest.cc) teaches how to reuse a test fixture in multiple test cases by deriving sub-fixtures from it.\n  * [Sample #6](../samples/sample6_unittest.cc) demonstrates type-parameterized tests.\n  * [Sample #7](../samples/sample7_unittest.cc) teaches the basics of value-parameterized tests.\n  * [Sample #8](../samples/sample8_unittest.cc) shows using `Combine()` in value-parameterized tests.\n  * [Sample #9](../samples/sample9_unittest.cc) shows use of the listener API to modify Google Test's console output and the use of its reflection API to inspect test results.\n  * [Sample #10](../samples/sample10_unittest.cc) shows use of the listener API to implement a primitive memory leak checker.\n"
  },
  {
    "path": "utils/googletest/googletest/docs/V1_5_AdvancedGuide.md",
    "content": "\n\nNow that you have read [Primer](V1_5_Primer.md) and learned how to write tests\nusing Google Test, it's time to learn some new tricks. This document\nwill show you more assertions as well as how to construct complex\nfailure messages, propagate fatal failures, reuse and speed up your\ntest fixtures, and use various flags with your tests.\n\n# More Assertions #\n\nThis section covers some less frequently used, but still significant,\nassertions.\n\n## Explicit Success and Failure ##\n\nThese three assertions do not actually test a value or expression. Instead,\nthey generate a success or failure directly. Like the macros that actually\nperform a test, you may stream a custom failure message into the them.\n\n| `SUCCEED();` |\n|:-------------|\n\nGenerates a success. This does NOT make the overall test succeed. A test is\nconsidered successful only if none of its assertions fail during its execution.\n\nNote: `SUCCEED()` is purely documentary and currently doesn't generate any\nuser-visible output. However, we may add `SUCCEED()` messages to Google Test's\noutput in the future.\n\n| `FAIL();`  | `ADD_FAILURE();` |\n|:-----------|:-----------------|\n\n`FAIL*` generates a fatal failure while `ADD_FAILURE*` generates a nonfatal\nfailure. These are useful when control flow, rather than a Boolean expression,\ndeteremines the test's success or failure. For example, you might want to write\nsomething like:\n\n```\nswitch(expression) {\n  case 1: ... some checks ...\n  case 2: ... some other checks\n  ...\n  default: FAIL() << \"We shouldn't get here.\";\n}\n```\n\n_Availability_: Linux, Windows, Mac.\n\n## Exception Assertions ##\n\nThese are for verifying that a piece of code throws (or does not\nthrow) an exception of the given type:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_THROW(`_statement_, _exception\\_type_`);`  | `EXPECT_THROW(`_statement_, _exception\\_type_`);`  | _statement_ throws an exception of the given type  |\n| `ASSERT_ANY_THROW(`_statement_`);`                | `EXPECT_ANY_THROW(`_statement_`);`                | _statement_ throws an exception of any type        |\n| `ASSERT_NO_THROW(`_statement_`);`                 | `EXPECT_NO_THROW(`_statement_`);`                 | _statement_ doesn't throw any exception            |\n\nExamples:\n\n```\nASSERT_THROW(Foo(5), bar_exception);\n\nEXPECT_NO_THROW({\n  int n = 5;\n  Bar(&n);\n});\n```\n\n_Availability_: Linux, Windows, Mac; since version 1.1.0.\n\n## Predicate Assertions for Better Error Messages ##\n\nEven though Google Test has a rich set of assertions, they can never be\ncomplete, as it's impossible (nor a good idea) to anticipate all the scenarios\na user might run into. Therefore, sometimes a user has to use `EXPECT_TRUE()`\nto check a complex expression, for lack of a better macro. This has the problem\nof not showing you the values of the parts of the expression, making it hard to\nunderstand what went wrong. As a workaround, some users choose to construct the\nfailure message by themselves, streaming it into `EXPECT_TRUE()`. However, this\nis awkward especially when the expression has side-effects or is expensive to\nevaluate.\n\nGoogle Test gives you three different options to solve this problem:\n\n### Using an Existing Boolean Function ###\n\nIf you already have a function or a functor that returns `bool` (or a type\nthat can be implicitly converted to `bool`), you can use it in a _predicate\nassertion_ to get the function arguments printed for free:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_PRED1(`_pred1, val1_`);`       | `EXPECT_PRED1(`_pred1, val1_`);` | _pred1(val1)_ returns true |\n| `ASSERT_PRED2(`_pred2, val1, val2_`);` | `EXPECT_PRED2(`_pred2, val1, val2_`);` |  _pred2(val1, val2)_ returns true |\n|  ...                | ...                    | ...          |\n\nIn the above, _predn_ is an _n_-ary predicate function or functor, where\n_val1_, _val2_, ..., and _valn_ are its arguments. The assertion succeeds\nif the predicate returns `true` when applied to the given arguments, and fails\notherwise. When the assertion fails, it prints the value of each argument. In\neither case, the arguments are evaluated exactly once.\n\nHere's an example. Given\n\n```\n// Returns true iff m and n have no common divisors except 1.\nbool MutuallyPrime(int m, int n) { ... }\nconst int a = 3;\nconst int b = 4;\nconst int c = 10;\n```\n\nthe assertion `EXPECT_PRED2(MutuallyPrime, a, b);` will succeed, while the\nassertion `EXPECT_PRED2(MutuallyPrime, b, c);` will fail with the message\n\n<pre>\n!MutuallyPrime(b, c) is false, where<br>\nb is 4<br>\nc is 10<br>\n</pre>\n\n**Notes:**\n\n  1. If you see a compiler error \"no matching function to call\" when using `ASSERT_PRED*` or `EXPECT_PRED*`, please see [this](V1_5_FAQ.md#the-compiler-complains-about-undefined-references-to-some-static-const-member-variables-but-i-did-define-them-in-the-class-body-whats-wrong) for how to resolve it.\n  1. Currently we only provide predicate assertions of arity <= 5. If you need a higher-arity assertion, let us know.\n\n_Availability_: Linux, Windows, Mac\n\n### Using a Function That Returns an AssertionResult ###\n\nWhile `EXPECT_PRED*()` and friends are handy for a quick job, the\nsyntax is not satisfactory: you have to use different macros for\ndifferent arities, and it feels more like Lisp than C++.  The\n`::testing::AssertionResult` class solves this problem.\n\nAn `AssertionResult` object represents the result of an assertion\n(whether it's a success or a failure, and an associated message).  You\ncan create an `AssertionResult` using one of these factory\nfunctions:\n\n```\nnamespace testing {\n\n// Returns an AssertionResult object to indicate that an assertion has\n// succeeded.\nAssertionResult AssertionSuccess();\n\n// Returns an AssertionResult object to indicate that an assertion has\n// failed.\nAssertionResult AssertionFailure();\n\n}\n```\n\nYou can then use the `<<` operator to stream messages to the\n`AssertionResult` object.\n\nTo provide more readable messages in Boolean assertions\n(e.g. `EXPECT_TRUE()`), write a predicate function that returns\n`AssertionResult` instead of `bool`. For example, if you define\n`IsEven()` as:\n\n```\n::testing::AssertionResult IsEven(int n) {\n  if ((n % 2) == 0)\n    return ::testing::AssertionSuccess();\n  else\n    return ::testing::AssertionFailure() << n << \" is odd\";\n}\n```\n\ninstead of:\n\n```\nbool IsEven(int n) {\n  return (n % 2) == 0;\n}\n```\n\nthe failed assertion `EXPECT_TRUE(IsEven(Fib(4)))` will print:\n\n<pre>\nValue of: !IsEven(Fib(4))<br>\nActual: false (*3 is odd*)<br>\nExpected: true<br>\n</pre>\n\ninstead of a more opaque\n\n<pre>\nValue of: !IsEven(Fib(4))<br>\nActual: false<br>\nExpected: true<br>\n</pre>\n\nIf you want informative messages in `EXPECT_FALSE` and `ASSERT_FALSE`\nas well, and are fine with making the predicate slower in the success\ncase, you can supply a success message:\n\n```\n::testing::AssertionResult IsEven(int n) {\n  if ((n % 2) == 0)\n    return ::testing::AssertionSuccess() << n << \" is even\";\n  else\n    return ::testing::AssertionFailure() << n << \" is odd\";\n}\n```\n\nThen the statement `EXPECT_FALSE(IsEven(Fib(6)))` will print\n\n<pre>\nValue of: !IsEven(Fib(6))<br>\nActual: true (8 is even)<br>\nExpected: false<br>\n</pre>\n\n_Availability_: Linux, Windows, Mac; since version 1.4.1.\n\n### Using a Predicate-Formatter ###\n\nIf you find the default message generated by `(ASSERT|EXPECT)_PRED*` and\n`(ASSERT|EXPECT)_(TRUE|FALSE)` unsatisfactory, or some arguments to your\npredicate do not support streaming to `ostream`, you can instead use the\nfollowing _predicate-formatter assertions_ to _fully_ customize how the\nmessage is formatted:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_PRED_FORMAT1(`_pred\\_format1, val1_`);`        | `EXPECT_PRED_FORMAT1(`_pred\\_format1, val1_`); | _pred\\_format1(val1)_ is successful |\n| `ASSERT_PRED_FORMAT2(`_pred\\_format2, val1, val2_`);` | `EXPECT_PRED_FORMAT2(`_pred\\_format2, val1, val2_`);` | _pred\\_format2(val1, val2)_ is successful |\n| `...`               | `...`                  | `...`        |\n\nThe difference between this and the previous two groups of macros is that instead of\na predicate, `(ASSERT|EXPECT)_PRED_FORMAT*` take a _predicate-formatter_\n(_pred\\_formatn_), which is a function or functor with the signature:\n\n`::testing::AssertionResult PredicateFormattern(const char* `_expr1_`, const char* `_expr2_`, ... const char* `_exprn_`, T1 `_val1_`, T2 `_val2_`, ... Tn `_valn_`);`\n\nwhere _val1_, _val2_, ..., and _valn_ are the values of the predicate\narguments, and _expr1_, _expr2_, ..., and _exprn_ are the corresponding\nexpressions as they appear in the source code. The types `T1`, `T2`, ..., and\n`Tn` can be either value types or reference types. For example, if an\nargument has type `Foo`, you can declare it as either `Foo` or `const Foo&`,\nwhichever is appropriate.\n\nA predicate-formatter returns a `::testing::AssertionResult` object to indicate\nwhether the assertion has succeeded or not. The only way to create such an\nobject is to call one of these factory functions:\n\nAs an example, let's improve the failure message in the previous example, which uses `EXPECT_PRED2()`:\n\n```\n// Returns the smallest prime common divisor of m and n,\n// or 1 when m and n are mutually prime.\nint SmallestPrimeCommonDivisor(int m, int n) { ... }\n\n// A predicate-formatter for asserting that two integers are mutually prime.\n::testing::AssertionResult AssertMutuallyPrime(const char* m_expr,\n                                               const char* n_expr,\n                                               int m,\n                                               int n) {\n  if (MutuallyPrime(m, n))\n    return ::testing::AssertionSuccess();\n\n  return ::testing::AssertionFailure()\n      << m_expr << \" and \" << n_expr << \" (\" << m << \" and \" << n\n      << \") are not mutually prime, \" << \"as they have a common divisor \"\n      << SmallestPrimeCommonDivisor(m, n);\n}\n```\n\nWith this predicate-formatter, we can use\n\n```\nEXPECT_PRED_FORMAT2(AssertMutuallyPrime, b, c);\n```\n\nto generate the message\n\n<pre>\nb and c (4 and 10) are not mutually prime, as they have a common divisor 2.<br>\n</pre>\n\nAs you may have realized, many of the assertions we introduced earlier are\nspecial cases of `(EXPECT|ASSERT)_PRED_FORMAT*`. In fact, most of them are\nindeed defined using `(EXPECT|ASSERT)_PRED_FORMAT*`.\n\n_Availability_: Linux, Windows, Mac.\n\n\n## Floating-Point Comparison ##\n\nComparing floating-point numbers is tricky. Due to round-off errors, it is\nvery unlikely that two floating-points will match exactly. Therefore,\n`ASSERT_EQ` 's naive comparison usually doesn't work. And since floating-points\ncan have a wide value range, no single fixed error bound works. It's better to\ncompare by a fixed relative error bound, except for values close to 0 due to\nthe loss of precision there.\n\nIn general, for floating-point comparison to make sense, the user needs to\ncarefully choose the error bound. If they don't want or care to, comparing in\nterms of Units in the Last Place (ULPs) is a good default, and Google Test\nprovides assertions to do this. Full details about ULPs are quite long; if you\nwant to learn more, see\n[this article on float comparison](http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm).\n\n### Floating-Point Macros ###\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_FLOAT_EQ(`_expected, actual_`);`  | `EXPECT_FLOAT_EQ(`_expected, actual_`);` | the two `float` values are almost equal |\n| `ASSERT_DOUBLE_EQ(`_expected, actual_`);` | `EXPECT_DOUBLE_EQ(`_expected, actual_`);` | the two `double` values are almost equal |\n\nBy \"almost equal\", we mean the two values are within 4 ULP's from each\nother.\n\nThe following assertions allow you to choose the acceptable error bound:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_NEAR(`_val1, val2, abs\\_error_`);` | `EXPECT_NEAR`_(val1, val2, abs\\_error_`);` | the difference between _val1_ and _val2_ doesn't exceed the given absolute error |\n\n_Availability_: Linux, Windows, Mac.\n\n### Floating-Point Predicate-Format Functions ###\n\nSome floating-point operations are useful, but not that often used. In order\nto avoid an explosion of new macros, we provide them as predicate-format\nfunctions that can be used in predicate assertion macros (e.g.\n`EXPECT_PRED_FORMAT2`, etc).\n\n```\nEXPECT_PRED_FORMAT2(::testing::FloatLE, val1, val2);\nEXPECT_PRED_FORMAT2(::testing::DoubleLE, val1, val2);\n```\n\nVerifies that _val1_ is less than, or almost equal to, _val2_. You can\nreplace `EXPECT_PRED_FORMAT2` in the above table with `ASSERT_PRED_FORMAT2`.\n\n_Availability_: Linux, Windows, Mac.\n\n## Windows HRESULT assertions ##\n\nThese assertions test for `HRESULT` success or failure.\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_HRESULT_SUCCEEDED(`_expression_`);` | `EXPECT_HRESULT_SUCCEEDED(`_expression_`);` | _expression_ is a success `HRESULT` |\n| `ASSERT_HRESULT_FAILED(`_expression_`);`    | `EXPECT_HRESULT_FAILED(`_expression_`);`    | _expression_ is a failure `HRESULT` |\n\nThe generated output contains the human-readable error message\nassociated with the `HRESULT` code returned by _expression_.\n\nYou might use them like this:\n\n```\nCComPtr shell;\nASSERT_HRESULT_SUCCEEDED(shell.CoCreateInstance(L\"Shell.Application\"));\nCComVariant empty;\nASSERT_HRESULT_SUCCEEDED(shell->ShellExecute(CComBSTR(url), empty, empty, empty, empty));\n```\n\n_Availability_: Windows.\n\n## Type Assertions ##\n\nYou can call the function\n```\n::testing::StaticAssertTypeEq<T1, T2>();\n```\nto assert that types `T1` and `T2` are the same.  The function does\nnothing if the assertion is satisfied.  If the types are different,\nthe function call will fail to compile, and the compiler error message\nwill likely (depending on the compiler) show you the actual values of\n`T1` and `T2`.  This is mainly useful inside template code.\n\n_Caveat:_ When used inside a member function of a class template or a\nfunction template, `StaticAssertTypeEq<T1, T2>()` is effective _only if_\nthe function is instantiated.  For example, given:\n```\ntemplate <typename T> class Foo {\n public:\n  void Bar() { ::testing::StaticAssertTypeEq<int, T>(); }\n};\n```\nthe code:\n```\nvoid Test1() { Foo<bool> foo; }\n```\nwill _not_ generate a compiler error, as `Foo<bool>::Bar()` is never\nactually instantiated.  Instead, you need:\n```\nvoid Test2() { Foo<bool> foo; foo.Bar(); }\n```\nto cause a compiler error.\n\n_Availability:_ Linux, Windows, Mac; since version 1.3.0.\n\n## Assertion Placement ##\n\nYou can use assertions in any C++ function. In particular, it doesn't\nhave to be a method of the test fixture class. The one constraint is\nthat assertions that generate a fatal failure (`FAIL*` and `ASSERT_*`)\ncan only be used in void-returning functions. This is a consequence of\nGoogle Test not using exceptions. By placing it in a non-void function\nyou'll get a confusing compile error like\n`\"error: void value not ignored as it ought to be\"`.\n\nIf you need to use assertions in a function that returns non-void, one option\nis to make the function return the value in an out parameter instead. For\nexample, you can rewrite `T2 Foo(T1 x)` to `void Foo(T1 x, T2* result)`. You\nneed to make sure that `*result` contains some sensible value even when the\nfunction returns prematurely. As the function now returns `void`, you can use\nany assertion inside of it.\n\nIf changing the function's type is not an option, you should just use\nassertions that generate non-fatal failures, such as `ADD_FAILURE*` and\n`EXPECT_*`.\n\n_Note_: Constructors and destructors are not considered void-returning\nfunctions, according to the C++ language specification, and so you may not use\nfatal assertions in them. You'll get a compilation error if you try. A simple\nworkaround is to transfer the entire body of the constructor or destructor to a\nprivate void-returning method. However, you should be aware that a fatal\nassertion failure in a constructor does not terminate the current test, as your\nintuition might suggest; it merely returns from the constructor early, possibly\nleaving your object in a partially-constructed state. Likewise, a fatal\nassertion failure in a destructor may leave your object in a\npartially-destructed state. Use assertions carefully in these situations!\n\n# Death Tests #\n\nIn many applications, there are assertions that can cause application failure\nif a condition is not met. These sanity checks, which ensure that the program\nis in a known good state, are there to fail at the earliest possible time after\nsome program state is corrupted. If the assertion checks the wrong condition,\nthen the program may proceed in an erroneous state, which could lead to memory\ncorruption, security holes, or worse. Hence it is vitally important to test\nthat such assertion statements work as expected.\n\nSince these precondition checks cause the processes to die, we call such tests\n_death tests_. More generally, any test that checks that a program terminates\nin an expected fashion is also a death test.\n\nIf you want to test `EXPECT_*()/ASSERT_*()` failures in your test code, see [Catching Failures](#catching-failures).\n\n## How to Write a Death Test ##\n\nGoogle Test has the following macros to support death tests:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_DEATH(`_statement, regex_`); | `EXPECT_DEATH(`_statement, regex_`); | _statement_ crashes with the given error |\n| `ASSERT_DEATH_IF_SUPPORTED(`_statement, regex_`); | `EXPECT_DEATH_IF_SUPPORTED(`_statement, regex_`); | if death tests are supported, verifies that _statement_ crashes with the given error; otherwise verifies nothing |\n| `ASSERT_EXIT(`_statement, predicate, regex_`); | `EXPECT_EXIT(`_statement, predicate, regex_`); |_statement_ exits with the given error and its exit code matches _predicate_ |\n\nwhere _statement_ is a statement that is expected to cause the process to\ndie, _predicate_ is a function or function object that evaluates an integer\nexit status, and _regex_ is a regular expression that the stderr output of\n_statement_ is expected to match. Note that _statement_ can be _any valid\nstatement_ (including _compound statement_) and doesn't have to be an\nexpression.\n\nAs usual, the `ASSERT` variants abort the current test function, while the\n`EXPECT` variants do not.\n\n**Note:** We use the word \"crash\" here to mean that the process\nterminates with a _non-zero_ exit status code.  There are two\npossibilities: either the process has called `exit()` or `_exit()`\nwith a non-zero value, or it may be killed by a signal.\n\nThis means that if _statement_ terminates the process with a 0 exit\ncode, it is _not_ considered a crash by `EXPECT_DEATH`.  Use\n`EXPECT_EXIT` instead if this is the case, or if you want to restrict\nthe exit code more precisely.\n\nA predicate here must accept an `int` and return a `bool`. The death test\nsucceeds only if the predicate returns `true`. Google Test defines a few\npredicates that handle the most common cases:\n\n```\n::testing::ExitedWithCode(exit_code)\n```\n\nThis expression is `true` if the program exited normally with the given exit\ncode.\n\n```\n::testing::KilledBySignal(signal_number)  // Not available on Windows.\n```\n\nThis expression is `true` if the program was killed by the given signal.\n\nThe `*_DEATH` macros are convenient wrappers for `*_EXIT` that use a predicate\nthat verifies the process' exit code is non-zero.\n\nNote that a death test only cares about three things:\n\n  1. does _statement_ abort or exit the process?\n  1. (in the case of `ASSERT_EXIT` and `EXPECT_EXIT`) does the exit status satisfy _predicate_?  Or (in the case of `ASSERT_DEATH` and `EXPECT_DEATH`) is the exit status non-zero?  And\n  1. does the stderr output match _regex_?\n\nIn particular, if _statement_ generates an `ASSERT_*` or `EXPECT_*` failure, it will **not** cause the death test to fail, as Google Test assertions don't abort the process.\n\nTo write a death test, simply use one of the above macros inside your test\nfunction. For example,\n\n```\nTEST(My*DeathTest*, Foo) {\n  // This death test uses a compound statement.\n  ASSERT_DEATH({ int n = 5; Foo(&n); }, \"Error on line .* of Foo()\");\n}\nTEST(MyDeathTest, NormalExit) {\n  EXPECT_EXIT(NormalExit(), ::testing::ExitedWithCode(0), \"Success\");\n}\nTEST(MyDeathTest, KillMyself) {\n  EXPECT_EXIT(KillMyself(), ::testing::KilledBySignal(SIGKILL), \"Sending myself unblockable signal\");\n}\n```\n\nverifies that:\n\n  * calling `Foo(5)` causes the process to die with the given error message,\n  * calling `NormalExit()` causes the process to print `\"Success\"` to stderr and exit with exit code 0, and\n  * calling `KillMyself()` kills the process with signal `SIGKILL`.\n\nThe test function body may contain other assertions and statements as well, if\nnecessary.\n\n_Important:_ We strongly recommend you to follow the convention of naming your\ntest case (not test) `*DeathTest` when it contains a death test, as\ndemonstrated in the above example. The `Death Tests And Threads` section below\nexplains why.\n\nIf a test fixture class is shared by normal tests and death tests, you\ncan use typedef to introduce an alias for the fixture class and avoid\nduplicating its code:\n```\nclass FooTest : public ::testing::Test { ... };\n\ntypedef FooTest FooDeathTest;\n\nTEST_F(FooTest, DoesThis) {\n  // normal test\n}\n\nTEST_F(FooDeathTest, DoesThat) {\n  // death test\n}\n```\n\n_Availability:_ Linux, Windows (requires MSVC 8.0 or above), Cygwin, and Mac (the latter three are supported since v1.3.0).  `(ASSERT|EXPECT)_DEATH_IF_SUPPORTED` are new in v1.4.0.\n\n## Regular Expression Syntax ##\n\nOn POSIX systems (e.g. Linux, Cygwin, and Mac), Google Test uses the\n[POSIX extended regular expression](http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_04)\nsyntax in death tests. To learn about this syntax, you may want to read this [Wikipedia entry](http://en.wikipedia.org/wiki/Regular_expression#POSIX_Extended_Regular_Expressions).\n\nOn Windows, Google Test uses its own simple regular expression\nimplementation. It lacks many features you can find in POSIX extended\nregular expressions.  For example, we don't support union (`\"x|y\"`),\ngrouping (`\"(xy)\"`), brackets (`\"[xy]\"`), and repetition count\n(`\"x{5,7}\"`), among others. Below is what we do support (`A` denotes a\nliteral character, period (`.`), or a single `\\\\` escape sequence; `x`\nand `y` denote regular expressions.):\n\n| `c` | matches any literal character `c` |\n|:----|:----------------------------------|\n| `\\\\d` | matches any decimal digit         |\n| `\\\\D` | matches any character that's not a decimal digit |\n| `\\\\f` | matches `\\f`                      |\n| `\\\\n` | matches `\\n`                      |\n| `\\\\r` | matches `\\r`                      |\n| `\\\\s` | matches any ASCII whitespace, including `\\n` |\n| `\\\\S` | matches any character that's not a whitespace |\n| `\\\\t` | matches `\\t`                      |\n| `\\\\v` | matches `\\v`                      |\n| `\\\\w` | matches any letter, `_`, or decimal digit |\n| `\\\\W` | matches any character that `\\\\w` doesn't match |\n| `\\\\c` | matches any literal character `c`, which must be a punctuation |\n| `.` | matches any single character except `\\n` |\n| `A?` | matches 0 or 1 occurrences of `A` |\n| `A*` | matches 0 or many occurrences of `A` |\n| `A+` | matches 1 or many occurrences of `A` |\n| `^` | matches the beginning of a string (not that of each line) |\n| `$` | matches the end of a string (not that of each line) |\n| `xy` | matches `x` followed by `y`       |\n\nTo help you determine which capability is available on your system,\nGoogle Test defines macro `GTEST_USES_POSIX_RE=1` when it uses POSIX\nextended regular expressions, or `GTEST_USES_SIMPLE_RE=1` when it uses\nthe simple version.  If you want your death tests to work in both\ncases, you can either `#if` on these macros or use the more limited\nsyntax only.\n\n## How It Works ##\n\nUnder the hood, `ASSERT_EXIT()` spawns a new process and executes the\ndeath test statement in that process. The details of of how precisely\nthat happens depend on the platform and the variable\n`::testing::GTEST_FLAG(death_test_style)` (which is initialized from the\ncommand-line flag `--gtest_death_test_style`).\n\n  * On POSIX systems, `fork()` (or `clone()` on Linux) is used to spawn the child, after which:\n    * If the variable's value is `\"fast\"`, the death test statement is immediately executed.\n    * If the variable's value is `\"threadsafe\"`, the child process re-executes the unit test binary just as it was originally invoked, but with some extra flags to cause just the single death test under consideration to be run.\n  * On Windows, the child is spawned using the `CreateProcess()` API, and re-executes the binary to cause just the single death test under consideration to be run - much like the `threadsafe` mode on POSIX.\n\nOther values for the variable are illegal and will cause the death test to\nfail. Currently, the flag's default value is `\"fast\"`. However, we reserve the\nright to change it in the future. Therefore, your tests should not depend on\nthis.\n\nIn either case, the parent process waits for the child process to complete, and checks that\n\n  1. the child's exit status satisfies the predicate, and\n  1. the child's stderr matches the regular expression.\n\nIf the death test statement runs to completion without dying, the child\nprocess will nonetheless terminate, and the assertion fails.\n\n## Death Tests And Threads ##\n\nThe reason for the two death test styles has to do with thread safety. Due to\nwell-known problems with forking in the presence of threads, death tests should\nbe run in a single-threaded context. Sometimes, however, it isn't feasible to\narrange that kind of environment. For example, statically-initialized modules\nmay start threads before main is ever reached. Once threads have been created,\nit may be difficult or impossible to clean them up.\n\nGoogle Test has three features intended to raise awareness of threading issues.\n\n  1. A warning is emitted if multiple threads are running when a death test is encountered.\n  1. Test cases with a name ending in \"DeathTest\" are run before all other tests.\n  1. It uses `clone()` instead of `fork()` to spawn the child process on Linux (`clone()` is not available on Cygwin and Mac), as `fork()` is more likely to cause the child to hang when the parent process has multiple threads.\n\nIt's perfectly fine to create threads inside a death test statement; they are\nexecuted in a separate process and cannot affect the parent.\n\n## Death Test Styles ##\n\nThe \"threadsafe\" death test style was introduced in order to help mitigate the\nrisks of testing in a possibly multithreaded environment. It trades increased\ntest execution time (potentially dramatically so) for improved thread safety.\nWe suggest using the faster, default \"fast\" style unless your test has specific\nproblems with it.\n\nYou can choose a particular style of death tests by setting the flag\nprogrammatically:\n\n```\n::testing::FLAGS_gtest_death_test_style = \"threadsafe\";\n```\n\nYou can do this in `main()` to set the style for all death tests in the\nbinary, or in individual tests. Recall that flags are saved before running each\ntest and restored afterwards, so you need not do that yourself. For example:\n\n```\nTEST(MyDeathTest, TestOne) {\n  ::testing::FLAGS_gtest_death_test_style = \"threadsafe\";\n  // This test is run in the \"threadsafe\" style:\n  ASSERT_DEATH(ThisShouldDie(), \"\");\n}\n\nTEST(MyDeathTest, TestTwo) {\n  // This test is run in the \"fast\" style:\n  ASSERT_DEATH(ThisShouldDie(), \"\");\n}\n\nint main(int argc, char** argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n  ::testing::FLAGS_gtest_death_test_style = \"fast\";\n  return RUN_ALL_TESTS();\n}\n```\n\n## Caveats ##\n\nThe _statement_ argument of `ASSERT_EXIT()` can be any valid C++ statement\nexcept that it can not return from the current function. This means\n_statement_ should not contain `return` or a macro that might return (e.g.\n`ASSERT_TRUE()` ). If _statement_ returns before it crashes, Google Test will\nprint an error message, and the test will fail.\n\nSince _statement_ runs in the child process, any in-memory side effect (e.g.\nmodifying a variable, releasing memory, etc) it causes will _not_ be observable\nin the parent process. In particular, if you release memory in a death test,\nyour program will fail the heap check as the parent process will never see the\nmemory reclaimed. To solve this problem, you can\n\n  1. try not to free memory in a death test;\n  1. free the memory again in the parent process; or\n  1. do not use the heap checker in your program.\n\nDue to an implementation detail, you cannot place multiple death test\nassertions on the same line; otherwise, compilation will fail with an unobvious\nerror message.\n\nDespite the improved thread safety afforded by the \"threadsafe\" style of death\ntest, thread problems such as deadlock are still possible in the presence of\nhandlers registered with `pthread_atfork(3)`.\n\n# Using Assertions in Sub-routines #\n\n## Adding Traces to Assertions ##\n\nIf a test sub-routine is called from several places, when an assertion\ninside it fails, it can be hard to tell which invocation of the\nsub-routine the failure is from.  You can alleviate this problem using\nextra logging or custom failure messages, but that usually clutters up\nyour tests. A better solution is to use the `SCOPED_TRACE` macro:\n\n| `SCOPED_TRACE(`_message_`);` |\n|:-----------------------------|\n\nwhere _message_ can be anything streamable to `std::ostream`. This\nmacro will cause the current file name, line number, and the given\nmessage to be added in every failure message. The effect will be\nundone when the control leaves the current lexical scope.\n\nFor example,\n\n```\n10: void Sub1(int n) {\n11:   EXPECT_EQ(1, Bar(n));\n12:   EXPECT_EQ(2, Bar(n + 1));\n13: }\n14:\n15: TEST(FooTest, Bar) {\n16:   {\n17:     SCOPED_TRACE(\"A\");  // This trace point will be included in\n18:                         // every failure in this scope.\n19:     Sub1(1);\n20:   }\n21:   // Now it won't.\n22:   Sub1(9);\n23: }\n```\n\ncould result in messages like these:\n\n```\npath/to/foo_test.cc:11: Failure\nValue of: Bar(n)\nExpected: 1\n  Actual: 2\n   Trace:\npath/to/foo_test.cc:17: A\n\npath/to/foo_test.cc:12: Failure\nValue of: Bar(n + 1)\nExpected: 2\n  Actual: 3\n```\n\nWithout the trace, it would've been difficult to know which invocation\nof `Sub1()` the two failures come from respectively. (You could add an\nextra message to each assertion in `Sub1()` to indicate the value of\n`n`, but that's tedious.)\n\nSome tips on using `SCOPED_TRACE`:\n\n  1. With a suitable message, it's often enough to use `SCOPED_TRACE` at the beginning of a sub-routine, instead of at each call site.\n  1. When calling sub-routines inside a loop, make the loop iterator part of the message in `SCOPED_TRACE` such that you can know which iteration the failure is from.\n  1. Sometimes the line number of the trace point is enough for identifying the particular invocation of a sub-routine. In this case, you don't have to choose a unique message for `SCOPED_TRACE`. You can simply use `\"\"`.\n  1. You can use `SCOPED_TRACE` in an inner scope when there is one in the outer scope. In this case, all active trace points will be included in the failure messages, in reverse order they are encountered.\n  1. The trace dump is clickable in Emacs' compilation buffer - hit return on a line number and you'll be taken to that line in the source file!\n\n_Availability:_ Linux, Windows, Mac.\n\n## Propagating Fatal Failures ##\n\nA common pitfall when using `ASSERT_*` and `FAIL*` is not understanding that\nwhen they fail they only abort the _current function_, not the entire test. For\nexample, the following test will segfault:\n```\nvoid Subroutine() {\n  // Generates a fatal failure and aborts the current function.\n  ASSERT_EQ(1, 2);\n  // The following won't be executed.\n  ...\n}\n\nTEST(FooTest, Bar) {\n  Subroutine();\n  // The intended behavior is for the fatal failure\n  // in Subroutine() to abort the entire test.\n  // The actual behavior: the function goes on after Subroutine() returns.\n  int* p = NULL;\n  *p = 3; // Segfault!\n}\n```\n\nSince we don't use exceptions, it is technically impossible to\nimplement the intended behavior here.  To alleviate this, Google Test\nprovides two solutions.  You could use either the\n`(ASSERT|EXPECT)_NO_FATAL_FAILURE` assertions or the\n`HasFatalFailure()` function.  They are described in the following two\nsubsections.\n\n\n\n### Asserting on Subroutines ###\n\nAs shown above, if your test calls a subroutine that has an `ASSERT_*`\nfailure in it, the test will continue after the subroutine\nreturns. This may not be what you want.\n\nOften people want fatal failures to propagate like exceptions.  For\nthat Google Test offers the following macros:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_NO_FATAL_FAILURE(`_statement_`);` | `EXPECT_NO_FATAL_FAILURE(`_statement_`);` | _statement_ doesn't generate any new fatal failures in the current thread. |\n\nOnly failures in the thread that executes the assertion are checked to\ndetermine the result of this type of assertions.  If _statement_\ncreates new threads, failures in these threads are ignored.\n\nExamples:\n\n```\nASSERT_NO_FATAL_FAILURE(Foo());\n\nint i;\nEXPECT_NO_FATAL_FAILURE({\n  i = Bar();\n});\n```\n\n_Availability:_ Linux, Windows, Mac. Assertions from multiple threads\nare currently not supported.\n\n### Checking for Failures in the Current Test ###\n\n`HasFatalFailure()` in the `::testing::Test` class returns `true` if an\nassertion in the current test has suffered a fatal failure. This\nallows functions to catch fatal failures in a sub-routine and return\nearly.\n\n```\nclass Test {\n public:\n  ...\n  static bool HasFatalFailure();\n};\n```\n\nThe typical usage, which basically simulates the behavior of a thrown\nexception, is:\n\n```\nTEST(FooTest, Bar) {\n  Subroutine();\n  // Aborts if Subroutine() had a fatal failure.\n  if (HasFatalFailure())\n    return;\n  // The following won't be executed.\n  ...\n}\n```\n\nIf `HasFatalFailure()` is used outside of `TEST()` , `TEST_F()` , or a test\nfixture, you must add the `::testing::Test::` prefix, as in:\n\n```\nif (::testing::Test::HasFatalFailure())\n  return;\n```\n\nSimilarly, `HasNonfatalFailure()` returns `true` if the current test\nhas at least one non-fatal failure, and `HasFailure()` returns `true`\nif the current test has at least one failure of either kind.\n\n_Availability:_ Linux, Windows, Mac.  `HasNonfatalFailure()` and\n`HasFailure()` are available since version 1.4.0.\n\n# Logging Additional Information #\n\nIn your test code, you can call `RecordProperty(\"key\", value)` to log\nadditional information, where `value` can be either a C string or a 32-bit\ninteger. The _last_ value recorded for a key will be emitted to the XML output\nif you specify one. For example, the test\n\n```\nTEST_F(WidgetUsageTest, MinAndMaxWidgets) {\n  RecordProperty(\"MaximumWidgets\", ComputeMaxUsage());\n  RecordProperty(\"MinimumWidgets\", ComputeMinUsage());\n}\n```\n\nwill output XML like this:\n\n```\n...\n  <testcase name=\"MinAndMaxWidgets\" status=\"run\" time=\"6\" classname=\"WidgetUsageTest\"\n            MaximumWidgets=\"12\"\n            MinimumWidgets=\"9\" />\n...\n```\n\n_Note_:\n  * `RecordProperty()` is a static member of the `Test` class. Therefore it needs to be prefixed with `::testing::Test::` if used outside of the `TEST` body and the test fixture class.\n  * `key` must be a valid XML attribute name, and cannot conflict with the ones already used by Google Test (`name`, `status`,     `time`, and `classname`).\n\n_Availability_: Linux, Windows, Mac.\n\n# Sharing Resources Between Tests in the Same Test Case #\n\n\n\nGoogle Test creates a new test fixture object for each test in order to make\ntests independent and easier to debug. However, sometimes tests use resources\nthat are expensive to set up, making the one-copy-per-test model prohibitively\nexpensive.\n\nIf the tests don't change the resource, there's no harm in them sharing a\nsingle resource copy. So, in addition to per-test set-up/tear-down, Google Test\nalso supports per-test-case set-up/tear-down. To use it:\n\n  1. In your test fixture class (say `FooTest` ), define as `static` some member variables to hold the shared resources.\n  1. In the same test fixture class, define a `static void SetUpTestCase()` function (remember not to spell it as **`SetupTestCase`** with a small `u`!) to set up the shared resources and a `static void TearDownTestCase()` function to tear them down.\n\nThat's it! Google Test automatically calls `SetUpTestCase()` before running the\n_first test_ in the `FooTest` test case (i.e. before creating the first\n`FooTest` object), and calls `TearDownTestCase()` after running the _last test_\nin it (i.e. after deleting the last `FooTest` object). In between, the tests\ncan use the shared resources.\n\nRemember that the test order is undefined, so your code can't depend on a test\npreceding or following another. Also, the tests must either not modify the\nstate of any shared resource, or, if they do modify the state, they must\nrestore the state to its original value before passing control to the next\ntest.\n\nHere's an example of per-test-case set-up and tear-down:\n```\nclass FooTest : public ::testing::Test {\n protected:\n  // Per-test-case set-up.\n  // Called before the first test in this test case.\n  // Can be omitted if not needed.\n  static void SetUpTestCase() {\n    shared_resource_ = new ...;\n  }\n\n  // Per-test-case tear-down.\n  // Called after the last test in this test case.\n  // Can be omitted if not needed.\n  static void TearDownTestCase() {\n    delete shared_resource_;\n    shared_resource_ = NULL;\n  }\n\n  // You can define per-test set-up and tear-down logic as usual.\n  virtual void SetUp() { ... }\n  virtual void TearDown() { ... }\n\n  // Some expensive resource shared by all tests.\n  static T* shared_resource_;\n};\n\nT* FooTest::shared_resource_ = NULL;\n\nTEST_F(FooTest, Test1) {\n  ... you can refer to shared_resource here ...\n}\nTEST_F(FooTest, Test2) {\n  ... you can refer to shared_resource here ...\n}\n```\n\n_Availability:_ Linux, Windows, Mac.\n\n# Global Set-Up and Tear-Down #\n\nJust as you can do set-up and tear-down at the test level and the test case\nlevel, you can also do it at the test program level. Here's how.\n\nFirst, you subclass the `::testing::Environment` class to define a test\nenvironment, which knows how to set-up and tear-down:\n\n```\nclass Environment {\n public:\n  virtual ~Environment() {}\n  // Override this to define how to set up the environment.\n  virtual void SetUp() {}\n  // Override this to define how to tear down the environment.\n  virtual void TearDown() {}\n};\n```\n\nThen, you register an instance of your environment class with Google Test by\ncalling the `::testing::AddGlobalTestEnvironment()` function:\n\n```\nEnvironment* AddGlobalTestEnvironment(Environment* env);\n```\n\nNow, when `RUN_ALL_TESTS()` is called, it first calls the `SetUp()` method of\nthe environment object, then runs the tests if there was no fatal failures, and\nfinally calls `TearDown()` of the environment object.\n\nIt's OK to register multiple environment objects. In this case, their `SetUp()`\nwill be called in the order they are registered, and their `TearDown()` will be\ncalled in the reverse order.\n\nNote that Google Test takes ownership of the registered environment objects.\nTherefore **do not delete them** by yourself.\n\nYou should call `AddGlobalTestEnvironment()` before `RUN_ALL_TESTS()` is\ncalled, probably in `main()`. If you use `gtest_main`, you need to      call\nthis before `main()` starts for it to take effect. One way to do this is to\ndefine a global variable like this:\n\n```\n::testing::Environment* const foo_env = ::testing::AddGlobalTestEnvironment(new FooEnvironment);\n```\n\nHowever, we strongly recommend you to write your own `main()` and call\n`AddGlobalTestEnvironment()` there, as relying on initialization of global\nvariables makes the code harder to read and may cause problems when you\nregister multiple environments from different translation units and the\nenvironments have dependencies among them (remember that the compiler doesn't\nguarantee the order in which global variables from different translation units\nare initialized).\n\n_Availability:_ Linux, Windows, Mac.\n\n\n# Value Parameterized Tests #\n\n_Value-parameterized tests_ allow you to test your code with different\nparameters without writing multiple copies of the same test.\n\nSuppose you write a test for your code and then realize that your code is affected by a presence of a Boolean command line flag.\n\n```\nTEST(MyCodeTest, TestFoo) {\n  // A code to test foo().\n}\n```\n\nUsually people factor their test code into a function with a Boolean parameter in such situations. The function sets the flag, then executes the testing code.\n\n```\nvoid TestFooHelper(bool flag_value) {\n  flag = flag_value;\n  // A code to test foo().\n}\n\nTEST(MyCodeTest, TestFooo) {\n  TestFooHelper(false);\n  TestFooHelper(true);\n}\n```\n\nBut this setup has serious drawbacks. First, when a test assertion fails in your tests, it becomes unclear what value of the parameter caused it to fail. You can stream a clarifying message into your `EXPECT`/`ASSERT` statements, but it you'll have to do it with all of them. Second, you have to add one such helper function per test. What if you have ten tests? Twenty? A hundred?\n\nValue-parameterized tests will let you write your test only once and then easily instantiate and run it with an arbitrary number of parameter values.\n\nHere are some other situations when value-parameterized tests come handy:\n\n  * You wan to test different implementations of an OO interface.\n  * You want to test your code over various inputs (a.k.a. data-driven testing). This feature is easy to abuse, so please exercise your good sense when doing it!\n\n## How to Write Value-Parameterized Tests ##\n\nTo write value-parameterized tests, first you should define a fixture\nclass. It must be derived from `::testing::TestWithParam<T>`, where `T`\nis the type of your parameter values. `TestWithParam<T>` is itself\nderived from `::testing::Test`. `T` can be any copyable type. If it's\na raw pointer, you are responsible for managing the lifespan of the\npointed values.\n\n```\nclass FooTest : public ::testing::TestWithParam<const char*> {\n  // You can implement all the usual fixture class members here.\n  // To access the test parameter, call GetParam() from class\n  // TestWithParam<T>.\n};\n```\n\nThen, use the `TEST_P` macro to define as many test patterns using\nthis fixture as you want.  The `_P` suffix is for \"parameterized\" or\n\"pattern\", whichever you prefer to think.\n\n```\nTEST_P(FooTest, DoesBlah) {\n  // Inside a test, access the test parameter with the GetParam() method\n  // of the TestWithParam<T> class:\n  EXPECT_TRUE(foo.Blah(GetParam()));\n  ...\n}\n\nTEST_P(FooTest, HasBlahBlah) {\n  ...\n}\n```\n\nFinally, you can use `INSTANTIATE_TEST_CASE_P` to instantiate the test\ncase with any set of parameters you want. Google Test defines a number of\nfunctions for generating test parameters. They return what we call\n(surprise!) _parameter generators_. Here is a summary of them,\nwhich are all in the `testing` namespace:\n\n| `Range(begin, end[, step])` | Yields values `{begin, begin+step, begin+step+step, ...}`. The values do not include `end`. `step` defaults to 1. |\n|:----------------------------|:------------------------------------------------------------------------------------------------------------------|\n| `Values(v1, v2, ..., vN)`   | Yields values `{v1, v2, ..., vN}`.                                                                                |\n| `ValuesIn(container)` and `ValuesIn(begin, end)` | Yields values from a C-style array, an STL-style container, or an iterator range `[begin, end)`.                  |\n| `Bool()`                    | Yields sequence `{false, true}`.                                                                                  |\n| `Combine(g1, g2, ..., gN)`  | Yields all combinations (the Cartesian product for the math savvy) of the values generated by the `N` generators. This is only available if your system provides the `<tr1/tuple>` header. If you are sure your system does, and Google Test disagrees, you can override it by defining `GTEST_HAS_TR1_TUPLE=1`. See comments in [include/gtest/internal/gtest-port.h](../include/gtest/internal/gtest-port.h) for more information. |\n\nFor more details, see the comments at the definitions of these functions in the [source code](../include/gtest/gtest-param-test.h).\n\nThe following statement will instantiate tests from the `FooTest` test case\neach with parameter values `\"meeny\"`, `\"miny\"`, and `\"moe\"`.\n\n```\nINSTANTIATE_TEST_CASE_P(InstantiationName,\n                        FooTest,\n                        ::testing::Values(\"meeny\", \"miny\", \"moe\"));\n```\n\nTo distinguish different instances of the pattern (yes, you can\ninstantiate it more than once), the first argument to\n`INSTANTIATE_TEST_CASE_P` is a prefix that will be added to the actual\ntest case name. Remember to pick unique prefixes for different\ninstantiations. The tests from the instantiation above will have these\nnames:\n\n  * `InstantiationName/FooTest.DoesBlah/0` for `\"meeny\"`\n  * `InstantiationName/FooTest.DoesBlah/1` for `\"miny\"`\n  * `InstantiationName/FooTest.DoesBlah/2` for `\"moe\"`\n  * `InstantiationName/FooTest.HasBlahBlah/0` for `\"meeny\"`\n  * `InstantiationName/FooTest.HasBlahBlah/1` for `\"miny\"`\n  * `InstantiationName/FooTest.HasBlahBlah/2` for `\"moe\"`\n\nYou can use these names in [--gtest\\-filter](#running-a-subset-of-the-tests).\n\nThis statement will instantiate all tests from `FooTest` again, each\nwith parameter values `\"cat\"` and `\"dog\"`:\n\n```\nconst char* pets[] = {\"cat\", \"dog\"};\nINSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest,\n                        ::testing::ValuesIn(pets));\n```\n\nThe tests from the instantiation above will have these names:\n\n  * `AnotherInstantiationName/FooTest.DoesBlah/0` for `\"cat\"`\n  * `AnotherInstantiationName/FooTest.DoesBlah/1` for `\"dog\"`\n  * `AnotherInstantiationName/FooTest.HasBlahBlah/0` for `\"cat\"`\n  * `AnotherInstantiationName/FooTest.HasBlahBlah/1` for `\"dog\"`\n\nPlease note that `INSTANTIATE_TEST_CASE_P` will instantiate _all_\ntests in the given test case, whether their definitions come before or\n_after_ the `INSTANTIATE_TEST_CASE_P` statement.\n\nYou can see\n[these](../samples/sample7_unittest.cc)\n[files](../samples/sample8_unittest.cc) for more examples.\n\n_Availability_: Linux, Windows (requires MSVC 8.0 or above), Mac; since version 1.2.0.\n\n## Creating Value-Parameterized Abstract Tests ##\n\nIn the above, we define and instantiate `FooTest` in the same source\nfile. Sometimes you may want to define value-parameterized tests in a\nlibrary and let other people instantiate them later. This pattern is\nknown as <i>abstract tests</i>. As an example of its application, when you\nare designing an interface you can write a standard suite of abstract\ntests (perhaps using a factory function as the test parameter) that\nall implementations of the interface are expected to pass. When\nsomeone implements the interface, he can instantiate your suite to get\nall the interface-conformance tests for free.\n\nTo define abstract tests, you should organize your code like this:\n\n  1. Put the definition of the parameterized test fixture class (e.g. `FooTest`) in a header file, say `foo_param_test.h`. Think of this as _declaring_ your abstract tests.\n  1. Put the `TEST_P` definitions in `foo_param_test.cc`, which includes `foo_param_test.h`. Think of this as _implementing_ your abstract tests.\n\nOnce they are defined, you can instantiate them by including\n`foo_param_test.h`, invoking `INSTANTIATE_TEST_CASE_P()`, and linking\nwith `foo_param_test.cc`. You can instantiate the same abstract test\ncase multiple times, possibly in different source files.\n\n# Typed Tests #\n\nSuppose you have multiple implementations of the same interface and\nwant to make sure that all of them satisfy some common requirements.\nOr, you may have defined several types that are supposed to conform to\nthe same \"concept\" and you want to verify it.  In both cases, you want\nthe same test logic repeated for different types.\n\nWhile you can write one `TEST` or `TEST_F` for each type you want to\ntest (and you may even factor the test logic into a function template\nthat you invoke from the `TEST`), it's tedious and doesn't scale:\nif you want _m_ tests over _n_ types, you'll end up writing _m\\*n_\n`TEST`s.\n\n_Typed tests_ allow you to repeat the same test logic over a list of\ntypes.  You only need to write the test logic once, although you must\nknow the type list when writing typed tests.  Here's how you do it:\n\nFirst, define a fixture class template.  It should be parameterized\nby a type.  Remember to derive it from `::testing::Test`:\n\n```\ntemplate <typename T>\nclass FooTest : public ::testing::Test {\n public:\n  ...\n  typedef std::list<T> List;\n  static T shared_;\n  T value_;\n};\n```\n\nNext, associate a list of types with the test case, which will be\nrepeated for each type in the list:\n\n```\ntypedef ::testing::Types<char, int, unsigned int> MyTypes;\nTYPED_TEST_CASE(FooTest, MyTypes);\n```\n\nThe `typedef` is necessary for the `TYPED_TEST_CASE` macro to parse\ncorrectly.  Otherwise the compiler will think that each comma in the\ntype list introduces a new macro argument.\n\nThen, use `TYPED_TEST()` instead of `TEST_F()` to define a typed test\nfor this test case.  You can repeat this as many times as you want:\n\n```\nTYPED_TEST(FooTest, DoesBlah) {\n  // Inside a test, refer to the special name TypeParam to get the type\n  // parameter.  Since we are inside a derived class template, C++ requires\n  // us to visit the members of FooTest via 'this'.\n  TypeParam n = this->value_;\n\n  // To visit static members of the fixture, add the 'TestFixture::'\n  // prefix.\n  n += TestFixture::shared_;\n\n  // To refer to typedefs in the fixture, add the 'typename TestFixture::'\n  // prefix.  The 'typename' is required to satisfy the compiler.\n  typename TestFixture::List values;\n  values.push_back(n);\n  ...\n}\n\nTYPED_TEST(FooTest, HasPropertyA) { ... }\n```\n\nYou can see `samples/sample6_unittest.cc` for a complete example.\n\n_Availability:_ Linux, Windows (requires MSVC 8.0 or above), Mac;\nsince version 1.1.0.\n\n# Type-Parameterized Tests #\n\n_Type-parameterized tests_ are like typed tests, except that they\ndon't require you to know the list of types ahead of time.  Instead,\nyou can define the test logic first and instantiate it with different\ntype lists later.  You can even instantiate it more than once in the\nsame program.\n\nIf you are designing an interface or concept, you can define a suite\nof type-parameterized tests to verify properties that any valid\nimplementation of the interface/concept should have.  Then, the author\nof each implementation can just instantiate the test suite with his\ntype to verify that it conforms to the requirements, without having to\nwrite similar tests repeatedly.  Here's an example:\n\nFirst, define a fixture class template, as we did with typed tests:\n\n```\ntemplate <typename T>\nclass FooTest : public ::testing::Test {\n  ...\n};\n```\n\nNext, declare that you will define a type-parameterized test case:\n\n```\nTYPED_TEST_CASE_P(FooTest);\n```\n\nThe `_P` suffix is for \"parameterized\" or \"pattern\", whichever you\nprefer to think.\n\nThen, use `TYPED_TEST_P()` to define a type-parameterized test.  You\ncan repeat this as many times as you want:\n\n```\nTYPED_TEST_P(FooTest, DoesBlah) {\n  // Inside a test, refer to TypeParam to get the type parameter.\n  TypeParam n = 0;\n  ...\n}\n\nTYPED_TEST_P(FooTest, HasPropertyA) { ... }\n```\n\nNow the tricky part: you need to register all test patterns using the\n`REGISTER_TYPED_TEST_CASE_P` macro before you can instantiate them.\nThe first argument of the macro is the test case name; the rest are\nthe names of the tests in this test case:\n\n```\nREGISTER_TYPED_TEST_CASE_P(FooTest,\n                           DoesBlah, HasPropertyA);\n```\n\nFinally, you are free to instantiate the pattern with the types you\nwant.  If you put the above code in a header file, you can `#include`\nit in multiple C++ source files and instantiate it multiple times.\n\n```\ntypedef ::testing::Types<char, int, unsigned int> MyTypes;\nINSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);\n```\n\nTo distinguish different instances of the pattern, the first argument\nto the `INSTANTIATE_TYPED_TEST_CASE_P` macro is a prefix that will be\nadded to the actual test case name.  Remember to pick unique prefixes\nfor different instances.\n\nIn the special case where the type list contains only one type, you\ncan write that type directly without `::testing::Types<...>`, like this:\n\n```\nINSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int);\n```\n\nYou can see `samples/sample6_unittest.cc` for a complete example.\n\n_Availability:_ Linux, Windows (requires MSVC 8.0 or above), Mac;\nsince version 1.1.0.\n\n# Testing Private Code #\n\nIf you change your software's internal implementation, your tests should not\nbreak as long as the change is not observable by users. Therefore, per the\n_black-box testing principle_, most of the time you should test your code\nthrough its public interfaces.\n\nIf you still find yourself needing to test internal implementation code,\nconsider if there's a better design that wouldn't require you to do so. If you\nabsolutely have to test non-public interface code though, you can. There are\ntwo cases to consider:\n\n  * Static functions (_not_ the same as static member functions!) or unnamed namespaces, and\n  * Private or protected class members\n\n## Static Functions ##\n\nBoth static functions and definitions/declarations in an unnamed namespace are\nonly visible within the same translation unit. To test them, you can `#include`\nthe entire `.cc` file being tested in your `*_test.cc` file. (`#include`ing `.cc`\nfiles is not a good way to reuse code - you should not do this in production\ncode!)\n\nHowever, a better approach is to move the private code into the\n`foo::internal` namespace, where `foo` is the namespace your project normally\nuses, and put the private declarations in a `*-internal.h` file. Your\nproduction `.cc` files and your tests are allowed to include this internal\nheader, but your clients are not. This way, you can fully test your internal\nimplementation without leaking it to your clients.\n\n## Private Class Members ##\n\nPrivate class members are only accessible from within the class or by friends.\nTo access a class' private members, you can declare your test fixture as a\nfriend to the class and define accessors in your fixture. Tests using the\nfixture can then access the private members of your production class via the\naccessors in the fixture. Note that even though your fixture is a friend to\nyour production class, your tests are not automatically friends to it, as they\nare technically defined in sub-classes of the fixture.\n\nAnother way to test private members is to refactor them into an implementation\nclass, which is then declared in a `*-internal.h` file. Your clients aren't\nallowed to include this header but your tests can. Such is called the Pimpl\n(Private Implementation) idiom.\n\nOr, you can declare an individual test as a friend of your class by adding this\nline in the class body:\n\n```\nFRIEND_TEST(TestCaseName, TestName);\n```\n\nFor example,\n```\n// foo.h\n#include <gtest/gtest_prod.h>\n\n// Defines FRIEND_TEST.\nclass Foo {\n  ...\n private:\n  FRIEND_TEST(FooTest, BarReturnsZeroOnNull);\n  int Bar(void* x);\n};\n\n// foo_test.cc\n...\nTEST(FooTest, BarReturnsZeroOnNull) {\n  Foo foo;\n  EXPECT_EQ(0, foo.Bar(NULL));\n  // Uses Foo's private member Bar().\n}\n```\n\nPay special attention when your class is defined in a namespace, as you should\ndefine your test fixtures and tests in the same namespace if you want them to\nbe friends of your class. For example, if the code to be tested looks like:\n\n```\nnamespace my_namespace {\n\nclass Foo {\n  friend class FooTest;\n  FRIEND_TEST(FooTest, Bar);\n  FRIEND_TEST(FooTest, Baz);\n  ...\n  definition of the class Foo\n  ...\n};\n\n}  // namespace my_namespace\n```\n\nYour test code should be something like:\n\n```\nnamespace my_namespace {\nclass FooTest : public ::testing::Test {\n protected:\n  ...\n};\n\nTEST_F(FooTest, Bar) { ... }\nTEST_F(FooTest, Baz) { ... }\n\n}  // namespace my_namespace\n```\n\n# Catching Failures #\n\nIf you are building a testing utility on top of Google Test, you'll\nwant to test your utility.  What framework would you use to test it?\nGoogle Test, of course.\n\nThe challenge is to verify that your testing utility reports failures\ncorrectly.  In frameworks that report a failure by throwing an\nexception, you could catch the exception and assert on it.  But Google\nTest doesn't use exceptions, so how do we test that a piece of code\ngenerates an expected failure?\n\n`<gtest/gtest-spi.h>` contains some constructs to do this.  After\n`#include`ing this header, you can use\n\n| `EXPECT_FATAL_FAILURE(`_statement, substring_`);` |\n|:--------------------------------------------------|\n\nto assert that _statement_ generates a fatal (e.g. `ASSERT_*`) failure\nwhose message contains the given _substring_, or use\n\n| `EXPECT_NONFATAL_FAILURE(`_statement, substring_`);` |\n|:-----------------------------------------------------|\n\nif you are expecting a non-fatal (e.g. `EXPECT_*`) failure.\n\nFor technical reasons, there are some caveats:\n\n  1. You cannot stream a failure message to either macro.\n  1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot reference local non-static variables or non-static members of `this` object.\n  1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot return a value.\n\n_Note:_ Google Test is designed with threads in mind.  Once the\nsynchronization primitives in `<gtest/internal/gtest-port.h>` have\nbeen implemented, Google Test will become thread-safe, meaning that\nyou can then use assertions in multiple threads concurrently.  Before\n\nthat, however, Google Test only supports single-threaded usage.  Once\nthread-safe, `EXPECT_FATAL_FAILURE()` and `EXPECT_NONFATAL_FAILURE()`\nwill capture failures in the current thread only. If _statement_\ncreates new threads, failures in these threads will be ignored.  If\nyou want to capture failures from all threads instead, you should use\nthe following macros:\n\n| `EXPECT_FATAL_FAILURE_ON_ALL_THREADS(`_statement, substring_`);` |\n|:-----------------------------------------------------------------|\n| `EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(`_statement, substring_`);` |\n\n# Getting the Current Test's Name #\n\nSometimes a function may need to know the name of the currently running test.\nFor example, you may be using the `SetUp()` method of your test fixture to set\nthe golden file name based on which test is running. The `::testing::TestInfo`\nclass has this information:\n\n```\nnamespace testing {\n\nclass TestInfo {\n public:\n  // Returns the test case name and the test name, respectively.\n  //\n  // Do NOT delete or free the return value - it's managed by the\n  // TestInfo class.\n  const char* test_case_name() const;\n  const char* name() const;\n};\n\n}  // namespace testing\n```\n\n\n> To obtain a `TestInfo` object for the currently running test, call\n`current_test_info()` on the `UnitTest` singleton object:\n\n```\n// Gets information about the currently running test.\n// Do NOT delete the returned object - it's managed by the UnitTest class.\nconst ::testing::TestInfo* const test_info =\n  ::testing::UnitTest::GetInstance()->current_test_info();\nprintf(\"We are in test %s of test case %s.\\n\",\n       test_info->name(), test_info->test_case_name());\n```\n\n`current_test_info()` returns a null pointer if no test is running. In\nparticular, you cannot find the test case name in `TestCaseSetUp()`,\n`TestCaseTearDown()` (where you know the test case name implicitly), or\nfunctions called from them.\n\n_Availability:_ Linux, Windows, Mac.\n\n# Extending Google Test by Handling Test Events #\n\nGoogle Test provides an <b>event listener API</b> to let you receive\nnotifications about the progress of a test program and test\nfailures. The events you can listen to include the start and end of\nthe test program, a test case, or a test method, among others. You may\nuse this API to augment or replace the standard console output,\nreplace the XML output, or provide a completely different form of\noutput, such as a GUI or a database. You can also use test events as\ncheckpoints to implement a resource leak checker, for example.\n\n_Availability:_ Linux, Windows, Mac; since v1.4.0.\n\n## Defining Event Listeners ##\n\nTo define a event listener, you subclass either\n[testing::TestEventListener](../include/gtest/gtest.h#L855)\nor [testing::EmptyTestEventListener](../include/gtest/gtest.h#L905).\nThe former is an (abstract) interface, where <i>each pure virtual method<br>\ncan be overridden to handle a test event</i> (For example, when a test\nstarts, the `OnTestStart()` method will be called.). The latter provides\nan empty implementation of all methods in the interface, such that a\nsubclass only needs to override the methods it cares about.\n\nWhen an event is fired, its context is passed to the handler function\nas an argument. The following argument types are used:\n  * [UnitTest](../include/gtest/gtest.h#L1007) reflects the state of the entire test program,\n  * [TestCase](../include/gtest/gtest.h#L689) has information about a test case, which can contain one or more tests,\n  * [TestInfo](../include/gtest/gtest.h#L599) contains the state of a test, and\n  * [TestPartResult](../include/gtest/gtest-test-part.h#L42) represents the result of a test assertion.\n\nAn event handler function can examine the argument it receives to find\nout interesting information about the event and the test program's\nstate.  Here's an example:\n\n```\n  class MinimalistPrinter : public ::testing::EmptyTestEventListener {\n    // Called before a test starts.\n    virtual void OnTestStart(const ::testing::TestInfo& test_info) {\n      printf(\"*** Test %s.%s starting.\\n\",\n             test_info.test_case_name(), test_info.name());\n    }\n\n    // Called after a failed assertion or a SUCCESS().\n    virtual void OnTestPartResult(\n        const ::testing::TestPartResult& test_part_result) {\n      printf(\"%s in %s:%d\\n%s\\n\",\n             test_part_result.failed() ? \"*** Failure\" : \"Success\",\n             test_part_result.file_name(),\n             test_part_result.line_number(),\n             test_part_result.summary());\n    }\n\n    // Called after a test ends.\n    virtual void OnTestEnd(const ::testing::TestInfo& test_info) {\n      printf(\"*** Test %s.%s ending.\\n\",\n             test_info.test_case_name(), test_info.name());\n    }\n  };\n```\n\n## Using Event Listeners ##\n\nTo use the event listener you have defined, add an instance of it to\nthe Google Test event listener list (represented by class\n[TestEventListeners](../include/gtest/gtest.h#L929)\n- note the \"s\" at the end of the name) in your\n`main()` function, before calling `RUN_ALL_TESTS()`:\n```\nint main(int argc, char** argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n  // Gets hold of the event listener list.\n  ::testing::TestEventListeners& listeners =\n      ::testing::UnitTest::GetInstance()->listeners();\n  // Adds a listener to the end.  Google Test takes the ownership.\n  listeners.Append(new MinimalistPrinter);\n  return RUN_ALL_TESTS();\n}\n```\n\nThere's only one problem: the default test result printer is still in\neffect, so its output will mingle with the output from your minimalist\nprinter. To suppress the default printer, just release it from the\nevent listener list and delete it. You can do so by adding one line:\n```\n  ...\n  delete listeners.Release(listeners.default_result_printer());\n  listeners.Append(new MinimalistPrinter);\n  return RUN_ALL_TESTS();\n```\n\nNow, sit back and enjoy a completely different output from your\ntests. For more details, you can read this\n[sample](../samples/sample9_unittest.cc).\n\nYou may append more than one listener to the list. When an `On*Start()`\nor `OnTestPartResult()` event is fired, the listeners will receive it in\nthe order they appear in the list (since new listeners are added to\nthe end of the list, the default text printer and the default XML\ngenerator will receive the event first). An `On*End()` event will be\nreceived by the listeners in the _reverse_ order. This allows output by\nlisteners added later to be framed by output from listeners added\nearlier.\n\n## Generating Failures in Listeners ##\n\nYou may use failure-raising macros (`EXPECT_*()`, `ASSERT_*()`,\n`FAIL()`, etc) when processing an event. There are some restrictions:\n\n  1. You cannot generate any failure in `OnTestPartResult()` (otherwise it will cause `OnTestPartResult()` to be called recursively).\n  1. A listener that handles `OnTestPartResult()` is not allowed to generate any failure.\n\nWhen you add listeners to the listener list, you should put listeners\nthat handle `OnTestPartResult()` _before_ listeners that can generate\nfailures. This ensures that failures generated by the latter are\nattributed to the right test by the former.\n\nWe have a sample of failure-raising listener\n[here](../samples/sample10_unittest.cc).\n\n# Running Test Programs: Advanced Options #\n\nGoogle Test test programs are ordinary executables. Once built, you can run\nthem directly and affect their behavior via the following environment variables\nand/or command line flags. For the flags to work, your programs must call\n`::testing::InitGoogleTest()` before calling `RUN_ALL_TESTS()`.\n\nTo see a list of supported flags and their usage, please run your test\nprogram with the `--help` flag.  You can also use `-h`, `-?`, or `/?`\nfor short.  This feature is added in version 1.3.0.\n\nIf an option is specified both by an environment variable and by a\nflag, the latter takes precedence.  Most of the options can also be\nset/read in code: to access the value of command line flag\n`--gtest_foo`, write `::testing::GTEST_FLAG(foo)`.  A common pattern is\nto set the value of a flag before calling `::testing::InitGoogleTest()`\nto change the default value of the flag:\n```\nint main(int argc, char** argv) {\n  // Disables elapsed time by default.\n  ::testing::GTEST_FLAG(print_time) = false;\n\n  // This allows the user to override the flag on the command line.\n  ::testing::InitGoogleTest(&argc, argv);\n\n  return RUN_ALL_TESTS();\n}\n```\n\n## Selecting Tests ##\n\nThis section shows various options for choosing which tests to run.\n\n### Listing Test Names ###\n\nSometimes it is necessary to list the available tests in a program before\nrunning them so that a filter may be applied if needed. Including the flag\n`--gtest_list_tests` overrides all other flags and lists tests in the following\nformat:\n```\nTestCase1.\n  TestName1\n  TestName2\nTestCase2.\n  TestName\n```\n\nNone of the tests listed are actually run if the flag is provided. There is no\ncorresponding environment variable for this flag.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Running a Subset of the Tests ###\n\nBy default, a Google Test program runs all tests the user has defined.\nSometimes, you want to run only a subset of the tests (e.g. for debugging or\nquickly verifying a change). If you set the `GTEST_FILTER` environment variable\nor the `--gtest_filter` flag to a filter string, Google Test will only run the\ntests whose full names (in the form of `TestCaseName.TestName`) match the\nfilter.\n\nThe format of a filter is a '`:`'-separated list of wildcard patterns (called\nthe positive patterns) optionally followed by a '`-`' and another\n'`:`'-separated pattern list (called the negative patterns). A test matches the\nfilter if and only if it matches any of the positive patterns but does not\nmatch any of the negative patterns.\n\nA pattern may contain `'*'` (matches any string) or `'?'` (matches any single\ncharacter). For convenience, the filter `'*-NegativePatterns'` can be also\nwritten as `'-NegativePatterns'`.\n\nFor example:\n\n  * `./foo_test` Has no flag, and thus runs all its tests.\n  * `./foo_test --gtest_filter=*` Also runs everything, due to the single match-everything `*` value.\n  * `./foo_test --gtest_filter=FooTest.*` Runs everything in test case `FooTest`.\n  * `./foo_test --gtest_filter=*Null*:*Constructor*` Runs any test whose full name contains either `\"Null\"` or `\"Constructor\"`.\n  * `./foo_test --gtest_filter=-*DeathTest.*` Runs all non-death tests.\n  * `./foo_test --gtest_filter=FooTest.*-FooTest.Bar` Runs everything in test case `FooTest` except `FooTest.Bar`.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Temporarily Disabling Tests ###\n\nIf you have a broken test that you cannot fix right away, you can add the\n`DISABLED_` prefix to its name. This will exclude it from execution. This is\nbetter than commenting out the code or using `#if 0`, as disabled tests are\nstill compiled (and thus won't rot).\n\nIf you need to disable all tests in a test case, you can either add `DISABLED_`\nto the front of the name of each test, or alternatively add it to the front of\nthe test case name.\n\nFor example, the following tests won't be run by Google Test, even though they\nwill still be compiled:\n\n```\n// Tests that Foo does Abc.\nTEST(FooTest, DISABLED_DoesAbc) { ... }\n\nclass DISABLED_BarTest : public ::testing::Test { ... };\n\n// Tests that Bar does Xyz.\nTEST_F(DISABLED_BarTest, DoesXyz) { ... }\n```\n\n_Note:_ This feature should only be used for temporary pain-relief. You still\nhave to fix the disabled tests at a later date. As a reminder, Google Test will\nprint a banner warning you if a test program contains any disabled tests.\n\n_Tip:_ You can easily count the number of disabled tests you have\nusing `grep`. This number can be used as a metric for improving your\ntest quality.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Temporarily Enabling Disabled Tests ###\n\nTo include [disabled tests](#temporarily-disabling-tests) in test\nexecution, just invoke the test program with the\n`--gtest_also_run_disabled_tests` flag or set the\n`GTEST_ALSO_RUN_DISABLED_TESTS` environment variable to a value other\nthan `0`.  You can combine this with the\n[--gtest\\_filter](#running-a-subset-of-the-tests) flag to further select\nwhich disabled tests to run.\n\n_Availability:_ Linux, Windows, Mac; since version 1.3.0.\n\n## Repeating the Tests ##\n\nOnce in a while you'll run into a test whose result is hit-or-miss. Perhaps it\nwill fail only 1% of the time, making it rather hard to reproduce the bug under\na debugger. This can be a major source of frustration.\n\nThe `--gtest_repeat` flag allows you to repeat all (or selected) test methods\nin a program many times. Hopefully, a flaky test will eventually fail and give\nyou a chance to debug. Here's how to use it:\n\n| `$ foo_test --gtest_repeat=1000` | Repeat foo\\_test 1000 times and don't stop at failures. |\n|:---------------------------------|:--------------------------------------------------------|\n| `$ foo_test --gtest_repeat=-1`   | A negative count means repeating forever.               |\n| `$ foo_test --gtest_repeat=1000 --gtest_break_on_failure` | Repeat foo\\_test 1000 times, stopping at the first failure. This is especially useful when running under a debugger: when the testfails, it will drop into the debugger and you can then inspect variables and stacks. |\n| `$ foo_test --gtest_repeat=1000 --gtest_filter=FooBar` | Repeat the tests whose name matches the filter 1000 times. |\n\nIf your test program contains global set-up/tear-down code registered\nusing `AddGlobalTestEnvironment()`, it will be repeated in each\niteration as well, as the flakiness may be in it. You can also specify\nthe repeat count by setting the `GTEST_REPEAT` environment variable.\n\n_Availability:_ Linux, Windows, Mac.\n\n## Shuffling the Tests ##\n\nYou can specify the `--gtest_shuffle` flag (or set the `GTEST_SHUFFLE`\nenvironment variable to `1`) to run the tests in a program in a random\norder. This helps to reveal bad dependencies between tests.\n\nBy default, Google Test uses a random seed calculated from the current\ntime. Therefore you'll get a different order every time. The console\noutput includes the random seed value, such that you can reproduce an\norder-related test failure later. To specify the random seed\nexplicitly, use the `--gtest_random_seed=SEED` flag (or set the\n`GTEST_RANDOM_SEED` environment variable), where `SEED` is an integer\nbetween 0 and 99999. The seed value 0 is special: it tells Google Test\nto do the default behavior of calculating the seed from the current\ntime.\n\nIf you combine this with `--gtest_repeat=N`, Google Test will pick a\ndifferent random seed and re-shuffle the tests in each iteration.\n\n_Availability:_ Linux, Windows, Mac; since v1.4.0.\n\n## Controlling Test Output ##\n\nThis section teaches how to tweak the way test results are reported.\n\n### Colored Terminal Output ###\n\nGoogle Test can use colors in its terminal output to make it easier to spot\nthe separation between tests, and whether tests passed.\n\nYou can set the GTEST\\_COLOR environment variable or set the `--gtest_color`\ncommand line flag to `yes`, `no`, or `auto` (the default) to enable colors,\ndisable colors, or let Google Test decide. When the value is `auto`, Google\nTest will use colors if and only if the output goes to a terminal and (on\nnon-Windows platforms) the `TERM` environment variable is set to `xterm` or\n`xterm-color`.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Suppressing the Elapsed Time ###\n\nBy default, Google Test prints the time it takes to run each test.  To\nsuppress that, run the test program with the `--gtest_print_time=0`\ncommand line flag.  Setting the `GTEST_PRINT_TIME` environment\nvariable to `0` has the same effect.\n\n_Availability:_ Linux, Windows, Mac.  (In Google Test 1.3.0 and lower,\nthe default behavior is that the elapsed time is **not** printed.)\n\n### Generating an XML Report ###\n\nGoogle Test can emit a detailed XML report to a file in addition to its normal\ntextual output. The report contains the duration of each test, and thus can\nhelp you identify slow tests.\n\nTo generate the XML report, set the `GTEST_OUTPUT` environment variable or the\n`--gtest_output` flag to the string `\"xml:_path_to_output_file_\"`, which will\ncreate the file at the given location. You can also just use the string\n`\"xml\"`, in which case the output can be found in the `test_detail.xml` file in\nthe current directory.\n\nIf you specify a directory (for example, `\"xml:output/directory/\"` on Linux or\n`\"xml:output\\directory\\\"` on Windows), Google Test will create the XML file in\nthat directory, named after the test executable (e.g. `foo_test.xml` for test\nprogram `foo_test` or `foo_test.exe`). If the file already exists (perhaps left\nover from a previous run), Google Test will pick a different name (e.g.\n`foo_test_1.xml`) to avoid overwriting it.\n\nThe report uses the format described here.  It is based on the\n`junitreport` Ant task and can be parsed by popular continuous build\nsystems like [Hudson](https://hudson.dev.java.net/). Since that format\nwas originally intended for Java, a little interpretation is required\nto make it apply to Google Test tests, as shown here:\n\n```\n<testsuites name=\"AllTests\" ...>\n  <testsuite name=\"test_case_name\" ...>\n    <testcase name=\"test_name\" ...>\n      <failure message=\"...\"/>\n      <failure message=\"...\"/>\n      <failure message=\"...\"/>\n    </testcase>\n  </testsuite>\n</testsuites>\n```\n\n  * The root `<testsuites>` element corresponds to the entire test program.\n  * `<testsuite>` elements correspond to Google Test test cases.\n  * `<testcase>` elements correspond to Google Test test functions.\n\nFor instance, the following program\n\n```\nTEST(MathTest, Addition) { ... }\nTEST(MathTest, Subtraction) { ... }\nTEST(LogicTest, NonContradiction) { ... }\n```\n\ncould generate this report:\n\n```\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites tests=\"3\" failures=\"1\" errors=\"0\" time=\"35\" name=\"AllTests\">\n  <testsuite name=\"MathTest\" tests=\"2\" failures=\"1\"* errors=\"0\" time=\"15\">\n    <testcase name=\"Addition\" status=\"run\" time=\"7\" classname=\"\">\n      <failure message=\"Value of: add(1, 1)&#x0A; Actual: 3&#x0A;Expected: 2\" type=\"\"/>\n      <failure message=\"Value of: add(1, -1)&#x0A; Actual: 1&#x0A;Expected: 0\" type=\"\"/>\n    </testcase>\n    <testcase name=\"Subtraction\" status=\"run\" time=\"5\" classname=\"\">\n    </testcase>\n  </testsuite>\n  <testsuite name=\"LogicTest\" tests=\"1\" failures=\"0\" errors=\"0\" time=\"5\">\n    <testcase name=\"NonContradiction\" status=\"run\" time=\"5\" classname=\"\">\n    </testcase>\n  </testsuite>\n</testsuites>\n```\n\nThings to note:\n\n  * The `tests` attribute of a `<testsuites>` or `<testsuite>` element tells how many test functions the Google Test program or test case contains, while the `failures` attribute tells how many of them failed.\n  * The `time` attribute expresses the duration of the test, test case, or entire test program in milliseconds.\n  * Each `<failure>` element corresponds to a single failed Google Test assertion.\n  * Some JUnit concepts don't apply to Google Test, yet we have to conform to the DTD. Therefore you'll see some dummy elements and attributes in the report. You can safely ignore these parts.\n\n_Availability:_ Linux, Windows, Mac.\n\n## Controlling How Failures Are Reported ##\n\n### Turning Assertion Failures into Break-Points ###\n\nWhen running test programs under a debugger, it's very convenient if the\ndebugger can catch an assertion failure and automatically drop into interactive\nmode. Google Test's _break-on-failure_ mode supports this behavior.\n\nTo enable it, set the `GTEST_BREAK_ON_FAILURE` environment variable to a value\nother than `0` . Alternatively, you can use the `--gtest_break_on_failure`\ncommand line flag.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Suppressing Pop-ups Caused by Exceptions ###\n\nOn Windows, Google Test may be used with exceptions enabled. Even when\nexceptions are disabled, an application can still throw structured exceptions\n(SEH's). If a test throws an exception, by default Google Test doesn't try to\ncatch it. Instead, you'll see a pop-up dialog, at which point you can attach\nthe process to a debugger and easily find out what went wrong.\n\nHowever, if you don't want to see the pop-ups (for example, if you run the\ntests in a batch job), set the `GTEST_CATCH_EXCEPTIONS` environment variable to\na non- `0` value, or use the `--gtest_catch_exceptions` flag. Google Test now\ncatches all test-thrown exceptions and logs them as failures.\n\n_Availability:_ Windows. `GTEST_CATCH_EXCEPTIONS` and\n`--gtest_catch_exceptions` have no effect on Google Test's behavior on Linux or\nMac, even if exceptions are enabled. It is possible to add support for catching\nexceptions on these platforms, but it is not implemented yet.\n\n### Letting Another Testing Framework Drive ###\n\nIf you work on a project that has already been using another testing\nframework and is not ready to completely switch to Google Test yet,\nyou can get much of Google Test's benefit by using its assertions in\nyour existing tests.  Just change your `main()` function to look\nlike:\n\n```\n#include <gtest/gtest.h>\n\nint main(int argc, char** argv) {\n  ::testing::GTEST_FLAG(throw_on_failure) = true;\n  // Important: Google Test must be initialized.\n  ::testing::InitGoogleTest(&argc, argv);\n\n  ... whatever your existing testing framework requires ...\n}\n```\n\nWith that, you can use Google Test assertions in addition to the\nnative assertions your testing framework provides, for example:\n\n```\nvoid TestFooDoesBar() {\n  Foo foo;\n  EXPECT_LE(foo.Bar(1), 100);     // A Google Test assertion.\n  CPPUNIT_ASSERT(foo.IsEmpty());  // A native assertion.\n}\n```\n\nIf a Google Test assertion fails, it will print an error message and\nthrow an exception, which will be treated as a failure by your host\ntesting framework.  If you compile your code with exceptions disabled,\na failed Google Test assertion will instead exit your program with a\nnon-zero code, which will also signal a test failure to your test\nrunner.\n\nIf you don't write `::testing::GTEST_FLAG(throw_on_failure) = true;` in\nyour `main()`, you can alternatively enable this feature by specifying\nthe `--gtest_throw_on_failure` flag on the command-line or setting the\n`GTEST_THROW_ON_FAILURE` environment variable to a non-zero value.\n\n_Availability:_ Linux, Windows, Mac; since v1.3.0.\n\n## Distributing Test Functions to Multiple Machines ##\n\nIf you have more than one machine you can use to run a test program,\nyou might want to run the test functions in parallel and get the\nresult faster.  We call this technique _sharding_, where each machine\nis called a _shard_.\n\nGoogle Test is compatible with test sharding.  To take advantage of\nthis feature, your test runner (not part of Google Test) needs to do\nthe following:\n\n  1. Allocate a number of machines (shards) to run the tests.\n  1. On each shard, set the `GTEST_TOTAL_SHARDS` environment variable to the total number of shards.  It must be the same for all shards.\n  1. On each shard, set the `GTEST_SHARD_INDEX` environment variable to the index of the shard.  Different shards must be assigned different indices, which must be in the range `[0, GTEST_TOTAL_SHARDS - 1]`.\n  1. Run the same test program on all shards.  When Google Test sees the above two environment variables, it will select a subset of the test functions to run.  Across all shards, each test function in the program will be run exactly once.\n  1. Wait for all shards to finish, then collect and report the results.\n\nYour project may have tests that were written without Google Test and\nthus don't understand this protocol.  In order for your test runner to\nfigure out which test supports sharding, it can set the environment\nvariable `GTEST_SHARD_STATUS_FILE` to a non-existent file path.  If a\ntest program supports sharding, it will create this file to\nacknowledge the fact (the actual contents of the file are not\nimportant at this time; although we may stick some useful information\nin it in the future.); otherwise it will not create it.\n\nHere's an example to make it clear.  Suppose you have a test program\n`foo_test` that contains the following 5 test functions:\n```\nTEST(A, V)\nTEST(A, W)\nTEST(B, X)\nTEST(B, Y)\nTEST(B, Z)\n```\nand you have 3 machines at your disposal.  To run the test functions in\nparallel, you would set `GTEST_TOTAL_SHARDS` to 3 on all machines, and\nset `GTEST_SHARD_INDEX` to 0, 1, and 2 on the machines respectively.\nThen you would run the same `foo_test` on each machine.\n\nGoogle Test reserves the right to change how the work is distributed\nacross the shards, but here's one possible scenario:\n\n  * Machine #0 runs `A.V` and `B.X`.\n  * Machine #1 runs `A.W` and `B.Y`.\n  * Machine #2 runs `B.Z`.\n\n_Availability:_ Linux, Windows, Mac; since version 1.3.0.\n\n# Fusing Google Test Source Files #\n\nGoogle Test's implementation consists of ~30 files (excluding its own\ntests).  Sometimes you may want them to be packaged up in two files (a\n`.h` and a `.cc`) instead, such that you can easily copy them to a new\nmachine and start hacking there.  For this we provide an experimental\nPython script `fuse_gtest_files.py` in the `scripts/` directory (since release 1.3.0).\nAssuming you have Python 2.4 or above installed on your machine, just\ngo to that directory and run\n```\npython fuse_gtest_files.py OUTPUT_DIR\n```\n\nand you should see an `OUTPUT_DIR` directory being created with files\n`gtest/gtest.h` and `gtest/gtest-all.cc` in it.  These files contain\neverything you need to use Google Test.  Just copy them to anywhere\nyou want and you are ready to write tests.  You can use the\n[scrpts/test/Makefile](../scripts/test/Makefile)\nfile as an example on how to compile your tests against them.\n\n# Where to Go from Here #\n\nCongratulations! You've now learned more advanced Google Test tools and are\nready to tackle more complex testing tasks. If you want to dive even deeper, you\ncan read the [FAQ](V1_5_FAQ.md).\n"
  },
  {
    "path": "utils/googletest/googletest/docs/V1_5_Documentation.md",
    "content": "This page lists all official documentation wiki pages for Google Test **1.5.0** -- **if you use a different version of Google Test, make sure to read the documentation for that version instead.**\n\n  * [Primer](V1_5_Primer.md) -- start here if you are new to Google Test.\n  * [Samples](Samples.md) -- learn from examples.\n  * [AdvancedGuide](V1_5_AdvancedGuide.md) -- learn more about Google Test.\n  * [XcodeGuide](V1_5_XcodeGuide.md) -- how to use Google Test in Xcode on Mac.\n  * [Frequently-Asked Questions](V1_5_FAQ.md) -- check here before asking a question on the mailing list.\n\nTo contribute code to Google Test, read:\n\n  * DevGuide -- read this _before_ writing your first patch.\n  * [PumpManual](V1_5_PumpManual.md) -- how we generate some of Google Test's source files."
  },
  {
    "path": "utils/googletest/googletest/docs/V1_5_FAQ.md",
    "content": "\n\nIf you cannot find the answer to your question here, and you have read\n[Primer](V1_5_Primer.md) and [AdvancedGuide](V1_5_AdvancedGuide.md), send it to\ngoogletestframework@googlegroups.com.\n\n## Why should I use Google Test instead of my favorite C++ testing framework? ##\n\nFirst, let's say clearly that we don't want to get into the debate of\nwhich C++ testing framework is **the best**.  There exist many fine\nframeworks for writing C++ tests, and we have tremendous respect for\nthe developers and users of them.  We don't think there is (or will\nbe) a single best framework - you have to pick the right tool for the\nparticular task you are tackling.\n\nWe created Google Test because we couldn't find the right combination\nof features and conveniences in an existing framework to satisfy _our_\nneeds.  The following is a list of things that _we_ like about Google\nTest.  We don't claim them to be unique to Google Test - rather, the\ncombination of them makes Google Test the choice for us.  We hope this\nlist can help you decide whether it is for you too.\n\n  * Google Test is designed to be portable.  It works where many STL types (e.g. `std::string` and `std::vector`) don't compile.  It doesn't require exceptions or RTTI.  As a result, it runs on Linux, Mac OS X, Windows and several embedded operating systems.\n  * Nonfatal assertions (`EXPECT_*`) have proven to be great time savers, as they allow a test to report multiple failures in a single edit-compile-test cycle.\n  * It's easy to write assertions that generate informative messages: you just use the stream syntax to append any additional information, e.g. `ASSERT_EQ(5, Foo(i)) << \" where i = \" << i;`.  It doesn't require a new set of macros or special functions.\n  * Google Test automatically detects your tests and doesn't require you to enumerate them in order to run them.\n  * No framework can anticipate all your needs, so Google Test provides `EXPECT_PRED*` to make it easy to extend your assertion vocabulary.  For a nicer syntax, you can define your own assertion macros trivially in terms of `EXPECT_PRED*`.\n  * Death tests are pretty handy for ensuring that your asserts in production code are triggered by the right conditions.\n  * `SCOPED_TRACE` helps you understand the context of an assertion failure when it comes from inside a sub-routine or loop.\n  * You can decide which tests to run using name patterns.  This saves time when you want to quickly reproduce a test failure.\n\n## How do I generate 64-bit binaries on Windows (using Visual Studio 2008)? ##\n\n(Answered by Trevor Robinson)\n\nLoad the supplied Visual Studio solution file, either `msvc\\gtest-md.sln` or\n`msvc\\gtest.sln`. Go through the migration wizard to migrate the\nsolution and project files to Visual Studio 2008. Select\n`Configuration Manager...` from the `Build` menu. Select `<New...>` from\nthe `Active solution platform` dropdown.  Select `x64` from the new\nplatform dropdown, leave `Copy settings from` set to `Win32` and\n`Create new project platforms` checked, then click `OK`. You now have\n`Win32` and `x64` platform configurations, selectable from the\n`Standard` toolbar, which allow you to toggle between building 32-bit or\n64-bit binaries (or both at once using Batch Build).\n\nIn order to prevent build output files from overwriting one another,\nyou'll need to change the `Intermediate Directory` settings for the\nnewly created platform configuration across all the projects. To do\nthis, multi-select (e.g. using shift-click) all projects (but not the\nsolution) in the `Solution Explorer`. Right-click one of them and\nselect `Properties`. In the left pane, select `Configuration Properties`,\nand from the `Configuration` dropdown, select `All Configurations`.\nMake sure the selected platform is `x64`. For the\n`Intermediate Directory` setting, change the value from\n`$(PlatformName)\\$(ConfigurationName)` to\n`$(OutDir)\\$(ProjectName)`. Click `OK` and then build the\nsolution. When the build is complete, the 64-bit binaries will be in\nthe `msvc\\x64\\Debug` directory.\n\n## Can I use Google Test on MinGW? ##\n\nWe haven't tested this ourselves, but Per Abrahamsen reported that he\nwas able to compile and install Google Test successfully when using\nMinGW from Cygwin.  You'll need to configure it with:\n\n`PATH/TO/configure CC=\"gcc -mno-cygwin\" CXX=\"g++ -mno-cygwin\"`\n\nYou should be able to replace the `-mno-cygwin` option with direct links\nto the real MinGW binaries, but we haven't tried that.\n\nCaveats:\n\n  * There are many warnings when compiling.\n  * `make check` will produce some errors as not all tests for Google Test itself are compatible with MinGW.\n\nWe also have reports on successful cross compilation of Google Test MinGW binaries on Linux using [these instructions](http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux#Cross-compiling_under_Linux_for_MS_Windows) on the WxWidgets site.\n\nPlease contact `googletestframework@googlegroups.com` if you are\ninterested in improving the support for MinGW.\n\n## Why does Google Test support EXPECT\\_EQ(NULL, ptr) and ASSERT\\_EQ(NULL, ptr) but not EXPECT\\_NE(NULL, ptr) and ASSERT\\_NE(NULL, ptr)? ##\n\nDue to some peculiarity of C++, it requires some non-trivial template\nmeta programming tricks to support using `NULL` as an argument of the\n`EXPECT_XX()` and `ASSERT_XX()` macros. Therefore we only do it where\nit's most needed (otherwise we make the implementation of Google Test\nharder to maintain and more error-prone than necessary).\n\nThe `EXPECT_EQ()` macro takes the _expected_ value as its first\nargument and the _actual_ value as the second. It's reasonable that\nsomeone wants to write `EXPECT_EQ(NULL, some_expression)`, and this\nindeed was requested several times. Therefore we implemented it.\n\nThe need for `EXPECT_NE(NULL, ptr)` isn't nearly as strong. When the\nassertion fails, you already know that `ptr` must be `NULL`, so it\ndoesn't add any information to print ptr in this case. That means\n`EXPECT_TRUE(ptr ! NULL)` works just as well.\n\nIf we were to support `EXPECT_NE(NULL, ptr)`, for consistency we'll\nhave to support `EXPECT_NE(ptr, NULL)` as well, as unlike `EXPECT_EQ`,\nwe don't have a convention on the order of the two arguments for\n`EXPECT_NE`. This means using the template meta programming tricks\ntwice in the implementation, making it even harder to understand and\nmaintain. We believe the benefit doesn't justify the cost.\n\nFinally, with the growth of Google Mock's [matcher](../../CookBook.md#using-matchers-in-google-test-assertions) library, we are\nencouraging people to use the unified `EXPECT_THAT(value, matcher)`\nsyntax more often in tests. One significant advantage of the matcher\napproach is that matchers can be easily combined to form new matchers,\nwhile the `EXPECT_NE`, etc, macros cannot be easily\ncombined. Therefore we want to invest more in the matchers than in the\n`EXPECT_XX()` macros.\n\n## Does Google Test support running tests in parallel? ##\n\nTest runners tend to be tightly coupled with the build/test\nenvironment, and Google Test doesn't try to solve the problem of\nrunning tests in parallel.  Instead, we tried to make Google Test work\nnicely with test runners.  For example, Google Test's XML report\ncontains the time spent on each test, and its `gtest_list_tests` and\n`gtest_filter` flags can be used for splitting the execution of test\nmethods into multiple processes.  These functionalities can help the\ntest runner run the tests in parallel.\n\n## Why don't Google Test run the tests in different threads to speed things up? ##\n\nIt's difficult to write thread-safe code.  Most tests are not written\nwith thread-safety in mind, and thus may not work correctly in a\nmulti-threaded setting.\n\nIf you think about it, it's already hard to make your code work when\nyou know what other threads are doing.  It's much harder, and\nsometimes even impossible, to make your code work when you don't know\nwhat other threads are doing (remember that test methods can be added,\ndeleted, or modified after your test was written).  If you want to run\nthe tests in parallel, you'd better run them in different processes.\n\n## Why aren't Google Test assertions implemented using exceptions? ##\n\nOur original motivation was to be able to use Google Test in projects\nthat disable exceptions.  Later we realized some additional benefits\nof this approach:\n\n  1. Throwing in a destructor is undefined behavior in C++.  Not using exceptions means Google Test's assertions are safe to use in destructors.\n  1. The `EXPECT_*` family of macros will continue even after a failure, allowing multiple failures in a `TEST` to be reported in a single run. This is a popular feature, as in C++ the edit-compile-test cycle is usually quite long and being able to fixing more than one thing at a time is a blessing.\n  1. If assertions are implemented using exceptions, a test may falsely ignore a failure if it's caught by user code:\n```\ntry { ... ASSERT_TRUE(...) ... }\ncatch (...) { ... }\n```\nThe above code will pass even if the `ASSERT_TRUE` throws.  While it's unlikely for someone to write this in a test, it's possible to run into this pattern when you write assertions in callbacks that are called by the code under test.\n\nThe downside of not using exceptions is that `ASSERT_*` (implemented\nusing `return`) will only abort the current function, not the current\n`TEST`.\n\n## Why do we use two different macros for tests with and without fixtures? ##\n\nUnfortunately, C++'s macro system doesn't allow us to use the same\nmacro for both cases.  One possibility is to provide only one macro\nfor tests with fixtures, and require the user to define an empty\nfixture sometimes:\n\n```\nclass FooTest : public ::testing::Test {};\n\nTEST_F(FooTest, DoesThis) { ... }\n```\nor\n```\ntypedef ::testing::Test FooTest;\n\nTEST_F(FooTest, DoesThat) { ... }\n```\n\nYet, many people think this is one line too many. :-) Our goal was to\nmake it really easy to write tests, so we tried to make simple tests\ntrivial to create.  That means using a separate macro for such tests.\n\nWe think neither approach is ideal, yet either of them is reasonable.\nIn the end, it probably doesn't matter much either way.\n\n## Why don't we use structs as test fixtures? ##\n\nWe like to use structs only when representing passive data.  This\ndistinction between structs and classes is good for documenting the\nintent of the code's author.  Since test fixtures have logic like\n`SetUp()` and `TearDown()`, they are better defined as classes.\n\n## Why are death tests implemented as assertions instead of using a test runner? ##\n\nOur goal was to make death tests as convenient for a user as C++\npossibly allows.  In particular:\n\n  * The runner-style requires to split the information into two pieces: the definition of the death test itself, and the specification for the runner on how to run the death test and what to expect.  The death test would be written in C++, while the runner spec may or may not be.  A user needs to carefully keep the two in sync. `ASSERT_DEATH(statement, expected_message)` specifies all necessary information in one place, in one language, without boilerplate code. It is very declarative.\n  * `ASSERT_DEATH` has a similar syntax and error-reporting semantics as other Google Test assertions, and thus is easy to learn.\n  * `ASSERT_DEATH` can be mixed with other assertions and other logic at your will.  You are not limited to one death test per test method. For example, you can write something like:\n```\n    if (FooCondition()) {\n      ASSERT_DEATH(Bar(), \"blah\");\n    } else {\n      ASSERT_EQ(5, Bar());\n    }\n```\nIf you prefer one death test per test method, you can write your tests in that style too, but we don't want to impose that on the users.  The fewer artificial limitations the better.\n  * `ASSERT_DEATH` can reference local variables in the current function, and you can decide how many death tests you want based on run-time information.  For example,\n```\n    const int count = GetCount();  // Only known at run time.\n    for (int i = 1; i <= count; i++) {\n      ASSERT_DEATH({\n        double* buffer = new double[i];\n        ... initializes buffer ...\n        Foo(buffer, i)\n      }, \"blah blah\");\n    }\n```\nThe runner-based approach tends to be more static and less flexible, or requires more user effort to get this kind of flexibility.\n\nAnother interesting thing about `ASSERT_DEATH` is that it calls `fork()`\nto create a child process to run the death test.  This is lightening\nfast, as `fork()` uses copy-on-write pages and incurs almost zero\noverhead, and the child process starts from the user-supplied\nstatement directly, skipping all global and local initialization and\nany code leading to the given statement.  If you launch the child\nprocess from scratch, it can take seconds just to load everything and\nstart running if the test links to many libraries dynamically.\n\n## My death test modifies some state, but the change seems lost after the death test finishes. Why? ##\n\nDeath tests (`EXPECT_DEATH`, etc) are executed in a sub-process s.t. the\nexpected crash won't kill the test program (i.e. the parent process). As a\nresult, any in-memory side effects they incur are observable in their\nrespective sub-processes, but not in the parent process. You can think of them\nas running in a parallel universe, more or less.\n\n## The compiler complains about \"undefined references\" to some static const member variables, but I did define them in the class body. What's wrong? ##\n\nIf your class has a static data member:\n\n```\n// foo.h\nclass Foo {\n  ...\n  static const int kBar = 100;\n};\n```\n\nYou also need to define it _outside_ of the class body in `foo.cc`:\n\n```\nconst int Foo::kBar;  // No initializer here.\n```\n\nOtherwise your code is **invalid C++**, and may break in unexpected ways. In\nparticular, using it in Google Test comparison assertions (`EXPECT_EQ`, etc)\nwill generate an \"undefined reference\" linker error.\n\n## I have an interface that has several implementations. Can I write a set of tests once and repeat them over all the implementations? ##\n\nGoogle Test doesn't yet have good support for this kind of tests, or\ndata-driven tests in general. We hope to be able to make improvements in this\narea soon.\n\n## Can I derive a test fixture from another? ##\n\nYes.\n\nEach test fixture has a corresponding and same named test case. This means only\none test case can use a particular fixture. Sometimes, however, multiple test\ncases may want to use the same or slightly different fixtures. For example, you\nmay want to make sure that all of a GUI library's test cases don't leak\nimportant system resources like fonts and brushes.\n\nIn Google Test, you share a fixture among test cases by putting the shared\nlogic in a base test fixture, then deriving from that base a separate fixture\nfor each test case that wants to use this common logic. You then use `TEST_F()`\nto write tests using each derived fixture.\n\nTypically, your code looks like this:\n\n```\n// Defines a base test fixture.\nclass BaseTest : public ::testing::Test {\n  protected:\n   ...\n};\n\n// Derives a fixture FooTest from BaseTest.\nclass FooTest : public BaseTest {\n  protected:\n    virtual void SetUp() {\n      BaseTest::SetUp();  // Sets up the base fixture first.\n      ... additional set-up work ...\n    }\n    virtual void TearDown() {\n      ... clean-up work for FooTest ...\n      BaseTest::TearDown();  // Remember to tear down the base fixture\n                             // after cleaning up FooTest!\n    }\n    ... functions and variables for FooTest ...\n};\n\n// Tests that use the fixture FooTest.\nTEST_F(FooTest, Bar) { ... }\nTEST_F(FooTest, Baz) { ... }\n\n... additional fixtures derived from BaseTest ...\n```\n\nIf necessary, you can continue to derive test fixtures from a derived fixture.\nGoogle Test has no limit on how deep the hierarchy can be.\n\nFor a complete example using derived test fixtures, see\n`samples/sample5_unittest.cc`.\n\n## My compiler complains \"void value not ignored as it ought to be.\" What does this mean? ##\n\nYou're probably using an `ASSERT_*()` in a function that doesn't return `void`.\n`ASSERT_*()` can only be used in `void` functions.\n\n## My death test hangs (or seg-faults). How do I fix it? ##\n\nIn Google Test, death tests are run in a child process and the way they work is\ndelicate. To write death tests you really need to understand how they work.\nPlease make sure you have read this.\n\nIn particular, death tests don't like having multiple threads in the parent\nprocess. So the first thing you can try is to eliminate creating threads\noutside of `EXPECT_DEATH()`.\n\nSometimes this is impossible as some library you must use may be creating\nthreads before `main()` is even reached. In this case, you can try to minimize\nthe chance of conflicts by either moving as many activities as possible inside\n`EXPECT_DEATH()` (in the extreme case, you want to move everything inside), or\nleaving as few things as possible in it. Also, you can try to set the death\ntest style to `\"threadsafe\"`, which is safer but slower, and see if it helps.\n\nIf you go with thread-safe death tests, remember that they rerun the test\nprogram from the beginning in the child process. Therefore make sure your\nprogram can run side-by-side with itself and is deterministic.\n\nIn the end, this boils down to good concurrent programming. You have to make\nsure that there is no race conditions or dead locks in your program. No silver\nbullet - sorry!\n\n## Should I use the constructor/destructor of the test fixture or the set-up/tear-down function? ##\n\nThe first thing to remember is that Google Test does not reuse the\nsame test fixture object across multiple tests. For each `TEST_F`,\nGoogle Test will create a fresh test fixture object, _immediately_\ncall `SetUp()`, run the test, call `TearDown()`, and then\n_immediately_ delete the test fixture object. Therefore, there is no\nneed to write a `SetUp()` or `TearDown()` function if the constructor\nor destructor already does the job.\n\nYou may still want to use `SetUp()/TearDown()` in the following cases:\n  * If the tear-down operation could throw an exception, you must use `TearDown()` as opposed to the destructor, as throwing in a destructor leads to undefined behavior and usually will kill your program right away. Note that many standard libraries (like STL) may throw when exceptions are enabled in the compiler. Therefore you should prefer `TearDown()` if you want to write portable tests that work with or without exceptions.\n  * The Google Test team is considering making the assertion macros throw on platforms where exceptions are enabled (e.g. Windows, Mac OS, and Linux client-side), which will eliminate the need for the user to propagate failures from a subroutine to its caller. Therefore, you shouldn't use Google Test assertions in a destructor if your code could run on such a platform.\n  * In a constructor or destructor, you cannot make a virtual function call on this object. (You can call a method declared as virtual, but it will be statically bound.) Therefore, if you need to call a method that will be overriden in a derived class, you have to use `SetUp()/TearDown()`.\n\n## The compiler complains \"no matching function to call\" when I use ASSERT\\_PREDn. How do I fix it? ##\n\nIf the predicate function you use in `ASSERT_PRED*` or `EXPECT_PRED*` is\noverloaded or a template, the compiler will have trouble figuring out which\noverloaded version it should use. `ASSERT_PRED_FORMAT*` and\n`EXPECT_PRED_FORMAT*` don't have this problem.\n\nIf you see this error, you might want to switch to\n`(ASSERT|EXPECT)_PRED_FORMAT*`, which will also give you a better failure\nmessage. If, however, that is not an option, you can resolve the problem by\nexplicitly telling the compiler which version to pick.\n\nFor example, suppose you have\n\n```\nbool IsPositive(int n) {\n  return n > 0;\n}\nbool IsPositive(double x) {\n  return x > 0;\n}\n```\n\nyou will get a compiler error if you write\n\n```\nEXPECT_PRED1(IsPositive, 5);\n```\n\nHowever, this will work:\n\n```\nEXPECT_PRED1(*static_cast<bool (*)(int)>*(IsPositive), 5);\n```\n\n(The stuff inside the angled brackets for the `static_cast` operator is the\ntype of the function pointer for the `int`-version of `IsPositive()`.)\n\nAs another example, when you have a template function\n\n```\ntemplate <typename T>\nbool IsNegative(T x) {\n  return x < 0;\n}\n```\n\nyou can use it in a predicate assertion like this:\n\n```\nASSERT_PRED1(IsNegative*<int>*, -5);\n```\n\nThings are more interesting if your template has more than one parameters. The\nfollowing won't compile:\n\n```\nASSERT_PRED2(*GreaterThan<int, int>*, 5, 0);\n```\n\n\nas the C++ pre-processor thinks you are giving `ASSERT_PRED2` 4 arguments,\nwhich is one more than expected. The workaround is to wrap the predicate\nfunction in parentheses:\n\n```\nASSERT_PRED2(*(GreaterThan<int, int>)*, 5, 0);\n```\n\n\n## My compiler complains about \"ignoring return value\" when I call RUN\\_ALL\\_TESTS(). Why? ##\n\nSome people had been ignoring the return value of `RUN_ALL_TESTS()`. That is,\ninstead of\n\n```\nreturn RUN_ALL_TESTS();\n```\n\nthey write\n\n```\nRUN_ALL_TESTS();\n```\n\nThis is wrong and dangerous. A test runner needs to see the return value of\n`RUN_ALL_TESTS()` in order to determine if a test has passed. If your `main()`\nfunction ignores it, your test will be considered successful even if it has a\nGoogle Test assertion failure. Very bad.\n\nTo help the users avoid this dangerous bug, the implementation of\n`RUN_ALL_TESTS()` causes gcc to raise this warning, when the return value is\nignored. If you see this warning, the fix is simple: just make sure its value\nis used as the return value of `main()`.\n\n## My compiler complains that a constructor (or destructor) cannot return a value. What's going on? ##\n\nDue to a peculiarity of C++, in order to support the syntax for streaming\nmessages to an `ASSERT_*`, e.g.\n\n```\nASSERT_EQ(1, Foo()) << \"blah blah\" << foo;\n```\n\nwe had to give up using `ASSERT*` and `FAIL*` (but not `EXPECT*` and\n`ADD_FAILURE*`) in constructors and destructors. The workaround is to move the\ncontent of your constructor/destructor to a private void member function, or\nswitch to `EXPECT_*()` if that works. This section in the user's guide explains\nit.\n\n## My set-up function is not called. Why? ##\n\nC++ is case-sensitive. It should be spelled as `SetUp()`.  Did you\nspell it as `Setup()`?\n\nSimilarly, sometimes people spell `SetUpTestCase()` as `SetupTestCase()` and\nwonder why it's never called.\n\n## How do I jump to the line of a failure in Emacs directly? ##\n\nGoogle Test's failure message format is understood by Emacs and many other\nIDEs, like acme and XCode. If a Google Test message is in a compilation buffer\nin Emacs, then it's clickable. You can now hit `enter` on a message to jump to\nthe corresponding source code, or use `C-x `` to jump to the next failure.\n\n## I have several test cases which share the same test fixture logic, do I have to define a new test fixture class for each of them? This seems pretty tedious. ##\n\nYou don't have to. Instead of\n\n```\nclass FooTest : public BaseTest {};\n\nTEST_F(FooTest, Abc) { ... }\nTEST_F(FooTest, Def) { ... }\n\nclass BarTest : public BaseTest {};\n\nTEST_F(BarTest, Abc) { ... }\nTEST_F(BarTest, Def) { ... }\n```\n\nyou can simply `typedef` the test fixtures:\n```\ntypedef BaseTest FooTest;\n\nTEST_F(FooTest, Abc) { ... }\nTEST_F(FooTest, Def) { ... }\n\ntypedef BaseTest BarTest;\n\nTEST_F(BarTest, Abc) { ... }\nTEST_F(BarTest, Def) { ... }\n```\n\n## The Google Test output is buried in a whole bunch of log messages. What do I do? ##\n\nThe Google Test output is meant to be a concise and human-friendly report. If\nyour test generates textual output itself, it will mix with the Google Test\noutput, making it hard to read. However, there is an easy solution to this\nproblem.\n\nSince most log messages go to stderr, we decided to let Google Test output go\nto stdout. This way, you can easily separate the two using redirection. For\nexample:\n```\n./my_test > googletest_output.txt\n```\n\n## Why should I prefer test fixtures over global variables? ##\n\nThere are several good reasons:\n  1. It's likely your test needs to change the states of its global variables. This makes it difficult to keep side effects from escaping one test and contaminating others, making debugging difficult. By using fixtures, each test has a fresh set of variables that's different (but with the same names). Thus, tests are kept independent of each other.\n  1. Global variables pollute the global namespace.\n  1. Test fixtures can be reused via subclassing, which cannot be done easily with global variables. This is useful if many test cases have something in common.\n\n## How do I test private class members without writing FRIEND\\_TEST()s? ##\n\nYou should try to write testable code, which means classes should be easily\ntested from their public interface. One way to achieve this is the Pimpl idiom:\nyou move all private members of a class into a helper class, and make all\nmembers of the helper class public.\n\nYou have several other options that don't require using `FRIEND_TEST`:\n  * Write the tests as members of the fixture class:\n```\nclass Foo {\n  friend class FooTest;\n  ...\n};\n\nclass FooTest : public ::testing::Test {\n protected:\n  ...\n  void Test1() {...} // This accesses private members of class Foo.\n  void Test2() {...} // So does this one.\n};\n\nTEST_F(FooTest, Test1) {\n  Test1();\n}\n\nTEST_F(FooTest, Test2) {\n  Test2();\n}\n```\n  * In the fixture class, write accessors for the tested class' private members, then use the accessors in your tests:\n```\nclass Foo {\n  friend class FooTest;\n  ...\n};\n\nclass FooTest : public ::testing::Test {\n protected:\n  ...\n  T1 get_private_member1(Foo* obj) {\n    return obj->private_member1_;\n  }\n};\n\nTEST_F(FooTest, Test1) {\n  ...\n  get_private_member1(x)\n  ...\n}\n```\n  * If the methods are declared **protected**, you can change their access level in a test-only subclass:\n```\nclass YourClass {\n  ...\n protected: // protected access for testability.\n  int DoSomethingReturningInt();\n  ...\n};\n\n// in the your_class_test.cc file:\nclass TestableYourClass : public YourClass {\n  ...\n public: using YourClass::DoSomethingReturningInt; // changes access rights\n  ...\n};\n\nTEST_F(YourClassTest, DoSomethingTest) {\n  TestableYourClass obj;\n  assertEquals(expected_value, obj.DoSomethingReturningInt());\n}\n```\n\n## How do I test private class static members without writing FRIEND\\_TEST()s? ##\n\nWe find private static methods clutter the header file.  They are\nimplementation details and ideally should be kept out of a .h. So often I make\nthem free functions instead.\n\nInstead of:\n```\n// foo.h\nclass Foo {\n  ...\n private:\n  static bool Func(int n);\n};\n\n// foo.cc\nbool Foo::Func(int n) { ... }\n\n// foo_test.cc\nEXPECT_TRUE(Foo::Func(12345));\n```\n\nYou probably should better write:\n```\n// foo.h\nclass Foo {\n  ...\n};\n\n// foo.cc\nnamespace internal {\n  bool Func(int n) { ... }\n}\n\n// foo_test.cc\nnamespace internal {\n  bool Func(int n);\n}\n\nEXPECT_TRUE(internal::Func(12345));\n```\n\n## I would like to run a test several times with different parameters. Do I need to write several similar copies of it? ##\n\nNo. You can use a feature called [value-parameterized tests](V1_5_AdvancedGuide.md#Value_Parameterized_Tests) which\nlets you repeat your tests with different parameters, without defining it more than once.\n\n## How do I test a file that defines main()? ##\n\nTo test a `foo.cc` file, you need to compile and link it into your unit test\nprogram. However, when the file contains a definition for the `main()`\nfunction, it will clash with the `main()` of your unit test, and will result in\na build error.\n\nThe right solution is to split it into three files:\n  1. `foo.h` which contains the declarations,\n  1. `foo.cc` which contains the definitions except `main()`, and\n  1. `foo_main.cc` which contains nothing but the definition of `main()`.\n\nThen `foo.cc` can be easily tested.\n\nIf you are adding tests to an existing file and don't want an intrusive change\nlike this, there is a hack: just include the entire `foo.cc` file in your unit\ntest. For example:\n```\n// File foo_unittest.cc\n\n// The headers section\n...\n\n// Renames main() in foo.cc to make room for the unit test main()\n#define main FooMain\n\n#include \"a/b/foo.cc\"\n\n// The tests start here.\n...\n```\n\n\nHowever, please remember this is a hack and should only be used as the last\nresort.\n\n## What can the statement argument in ASSERT\\_DEATH() be? ##\n\n`ASSERT_DEATH(_statement_, _regex_)` (or any death assertion macro) can be used\nwherever `_statement_` is valid. So basically `_statement_` can be any C++\nstatement that makes sense in the current context. In particular, it can\nreference global and/or local variables, and can be:\n  * a simple function call (often the case),\n  * a complex expression, or\n  * a compound statement.\n\n> Some examples are shown here:\n\n```\n// A death test can be a simple function call.\nTEST(MyDeathTest, FunctionCall) {\n  ASSERT_DEATH(Xyz(5), \"Xyz failed\");\n}\n\n// Or a complex expression that references variables and functions.\nTEST(MyDeathTest, ComplexExpression) {\n  const bool c = Condition();\n  ASSERT_DEATH((c ? Func1(0) : object2.Method(\"test\")),\n               \"(Func1|Method) failed\");\n}\n\n// Death assertions can be used any where in a function. In\n// particular, they can be inside a loop.\nTEST(MyDeathTest, InsideLoop) {\n  // Verifies that Foo(0), Foo(1), ..., and Foo(4) all die.\n  for (int i = 0; i < 5; i++) {\n    EXPECT_DEATH_M(Foo(i), \"Foo has \\\\d+ errors\",\n                   ::testing::Message() << \"where i is \" << i);\n  }\n}\n\n// A death assertion can contain a compound statement.\nTEST(MyDeathTest, CompoundStatement) {\n  // Verifies that at lease one of Bar(0), Bar(1), ..., and\n  // Bar(4) dies.\n  ASSERT_DEATH({\n    for (int i = 0; i < 5; i++) {\n      Bar(i);\n    }\n  },\n  \"Bar has \\\\d+ errors\");}\n```\n\n`googletest_unittest.cc` contains more examples if you are interested.\n\n## What syntax does the regular expression in ASSERT\\_DEATH use? ##\n\nOn POSIX systems, Google Test uses the POSIX Extended regular\nexpression syntax\n(http://en.wikipedia.org/wiki/Regular_expression#POSIX_Extended_Regular_Expressions). On\nWindows, it uses a limited variant of regular expression syntax. For\nmore details, see the [regular expression syntax](V1_5_AdvancedGuide.md#Regular_Expression_Syntax).\n\n## I have a fixture class Foo, but TEST\\_F(Foo, Bar) gives me error \"no matching function for call to Foo::Foo()\". Why? ##\n\nGoogle Test needs to be able to create objects of your test fixture class, so\nit must have a default constructor. Normally the compiler will define one for\nyou. However, there are cases where you have to define your own:\n  * If you explicitly declare a non-default constructor for class `Foo`, then you need to define a default constructor, even if it would be empty.\n  * If `Foo` has a const non-static data member, then you have to define the default constructor _and_ initialize the const member in the initializer list of the constructor. (Early versions of `gcc` doesn't force you to initialize the const member. It's a bug that has been fixed in `gcc 4`.)\n\n## Why does ASSERT\\_DEATH complain about previous threads that were already joined? ##\n\nWith the Linux pthread library, there is no turning back once you cross the\nline from single thread to multiple threads. The first time you create a\nthread, a manager thread is created in addition, so you get 3, not 2, threads.\nLater when the thread you create joins the main thread, the thread count\ndecrements by 1, but the manager thread will never be killed, so you still have\n2 threads, which means you cannot safely run a death test.\n\nThe new NPTL thread library doesn't suffer from this problem, as it doesn't\ncreate a manager thread. However, if you don't control which machine your test\nruns on, you shouldn't depend on this.\n\n## Why does Google Test require the entire test case, instead of individual tests, to be named FOODeathTest when it uses ASSERT\\_DEATH? ##\n\nGoogle Test does not interleave tests from different test cases. That is, it\nruns all tests in one test case first, and then runs all tests in the next test\ncase, and so on. Google Test does this because it needs to set up a test case\nbefore the first test in it is run, and tear it down afterwords. Splitting up\nthe test case would require multiple set-up and tear-down processes, which is\ninefficient and makes the semantics unclean.\n\nIf we were to determine the order of tests based on test name instead of test\ncase name, then we would have a problem with the following situation:\n\n```\nTEST_F(FooTest, AbcDeathTest) { ... }\nTEST_F(FooTest, Uvw) { ... }\n\nTEST_F(BarTest, DefDeathTest) { ... }\nTEST_F(BarTest, Xyz) { ... }\n```\n\nSince `FooTest.AbcDeathTest` needs to run before `BarTest.Xyz`, and we don't\ninterleave tests from different test cases, we need to run all tests in the\n`FooTest` case before running any test in the `BarTest` case. This contradicts\nwith the requirement to run `BarTest.DefDeathTest` before `FooTest.Uvw`.\n\n## But I don't like calling my entire test case FOODeathTest when it contains both death tests and non-death tests. What do I do? ##\n\nYou don't have to, but if you like, you may split up the test case into\n`FooTest` and `FooDeathTest`, where the names make it clear that they are\nrelated:\n\n```\nclass FooTest : public ::testing::Test { ... };\n\nTEST_F(FooTest, Abc) { ... }\nTEST_F(FooTest, Def) { ... }\n\ntypedef FooTest FooDeathTest;\n\nTEST_F(FooDeathTest, Uvw) { ... EXPECT_DEATH(...) ... }\nTEST_F(FooDeathTest, Xyz) { ... ASSERT_DEATH(...) ... }\n```\n\n## The compiler complains about \"no match for 'operator<<'\" when I use an assertion. What gives? ##\n\nIf you use a user-defined type `FooType` in an assertion, you must make sure\nthere is an `std::ostream& operator<<(std::ostream&, const FooType&)` function\ndefined such that we can print a value of `FooType`.\n\nIn addition, if `FooType` is declared in a name space, the `<<` operator also\nneeds to be defined in the _same_ name space.\n\n## How do I suppress the memory leak messages on Windows? ##\n\nSince the statically initialized Google Test singleton requires allocations on\nthe heap, the Visual C++ memory leak detector will report memory leaks at the\nend of the program run. The easiest way to avoid this is to use the\n`_CrtMemCheckpoint` and `_CrtMemDumpAllObjectsSince` calls to not report any\nstatically initialized heap objects. See MSDN for more details and additional\nheap check/debug routines.\n\n## I am building my project with Google Test in Visual Studio and all I'm getting is a bunch of linker errors (or warnings). Help! ##\n\nYou may get a number of the following linker error or warnings if you\nattempt to link your test project with the Google Test library when\nyour project and the are not built using the same compiler settings.\n\n  * LNK2005: symbol already defined in object\n  * LNK4217: locally defined symbol 'symbol' imported in function 'function'\n  * LNK4049: locally defined symbol 'symbol' imported\n\nThe Google Test project (gtest.vcproj) has the Runtime Library option\nset to /MT (use multi-threaded static libraries, /MTd for debug). If\nyour project uses something else, for example /MD (use multi-threaded\nDLLs, /MDd for debug), you need to change the setting in the Google\nTest project to match your project's.\n\nTo update this setting open the project properties in the Visual\nStudio IDE then select the branch Configuration Properties | C/C++ |\nCode Generation and change the option \"Runtime Library\".  You may also try\nusing gtest-md.vcproj instead of gtest.vcproj.\n\n## I put my tests in a library and Google Test doesn't run them. What's happening? ##\nHave you read a\n[warning](V1_5_Primer.md#important-note-for-visual-c-users) on\nthe Google Test Primer page?\n\n## I want to use Google Test with Visual Studio but don't know where to start. ##\nMany people are in your position and one of the posted his solution to\nour mailing list. Here is his link:\nhttp://hassanjamilahmad.blogspot.com/2009/07/gtest-starters-help.html.\n\n## My question is not covered in your FAQ! ##\n\nIf you cannot find the answer to your question in this FAQ, there are\nsome other resources you can use:\n\n  1. read other [wiki pages](http://code.google.com/p/googletest/w/list),\n  1. search the mailing list [archive](http://groups.google.com/group/googletestframework/topics),\n  1. ask it on [googletestframework@googlegroups.com](mailto:googletestframework@googlegroups.com) and someone will answer it (to prevent spam, we require you to join the [discussion group](http://groups.google.com/group/googletestframework) before you can post.).\n\nPlease note that creating an issue in the\n[issue tracker](http://code.google.com/p/googletest/issues/list) is _not_\na good way to get your answer, as it is monitored infrequently by a\nvery small number of people.\n\nWhen asking a question, it's helpful to provide as much of the\nfollowing information as possible (people cannot help you if there's\nnot enough information in your question):\n\n  * the version (or the revision number if you check out from SVN directly) of Google Test you use (Google Test is under active development, so it's possible that your problem has been solved in a later version),\n  * your operating system,\n  * the name and version of your compiler,\n  * the complete command line flags you give to your compiler,\n  * the complete compiler error messages (if the question is about compilation),\n  * the _actual_ code (ideally, a minimal but complete program) that has the problem you encounter.\n"
  },
  {
    "path": "utils/googletest/googletest/docs/V1_5_Primer.md",
    "content": "\n\n# Introduction: Why Google C++ Testing Framework? #\n\n_Google C++ Testing Framework_ helps you write better C++ tests.\n\nNo matter whether you work on Linux, Windows, or a Mac, if you write C++ code,\nGoogle Test can help you.\n\nSo what makes a good test, and how does Google C++ Testing Framework fit in? We believe:\n  1. Tests should be _independent_ and _repeatable_. It's a pain to debug a test that succeeds or fails as a result of other tests.  Google C++ Testing Framework isolates the tests by running each of them on a different object. When a test fails, Google C++ Testing Framework allows you to run it in isolation for quick debugging.\n  1. Tests should be well _organized_ and reflect the structure of the tested code.  Google C++ Testing Framework groups related tests into test cases that can share data and subroutines. This common pattern is easy to recognize and makes tests easy to maintain. Such consistency is especially helpful when people switch projects and start to work on a new code base.\n  1. Tests should be _portable_ and _reusable_. The open-source community has a lot of code that is platform-neutral, its tests should also be platform-neutral.  Google C++ Testing Framework works on different OSes, with different compilers (gcc, MSVC, and others), with or without exceptions, so Google C++ Testing Framework tests can easily work with a variety of configurations.  (Note that the current release only contains build scripts for Linux - we are actively working on scripts for other platforms.)\n  1. When tests fail, they should provide as much _information_ about the problem as possible. Google C++ Testing Framework doesn't stop at the first test failure. Instead, it only stops the current test and continues with the next. You can also set up tests that report non-fatal failures after which the current test continues. Thus, you can detect and fix multiple bugs in a single run-edit-compile cycle.\n  1. The testing framework should liberate test writers from housekeeping chores and let them focus on the test _content_.  Google C++ Testing Framework automatically keeps track of all tests defined, and doesn't require the user to enumerate them in order to run them.\n  1. Tests should be _fast_. With Google C++ Testing Framework, you can reuse shared resources across tests and pay for the set-up/tear-down only once, without making tests depend on each other.\n\nSince Google C++ Testing Framework is based on the popular xUnit\narchitecture, you'll feel right at home if you've used JUnit or PyUnit before.\nIf not, it will take you about 10 minutes to learn the basics and get started.\nSo let's go!\n\n_Note:_ We sometimes refer to Google C++ Testing Framework informally\nas _Google Test_.\n\n# Setting up a New Test Project #\n\nTo write a test program using Google Test, you need to compile Google\nTest into a library and link your test with it.  We provide build\nfiles for some popular build systems (`msvc/` for Visual Studio,\n`xcode/` for Mac Xcode, `make/` for GNU make, `codegear/` for Borland\nC++ Builder, and the autotools script in the\nGoogle Test root directory).  If your build system is not on this\nlist, you can take a look at `make/Makefile` to learn how Google Test\nshould be compiled (basically you want to compile `src/gtest-all.cc`\nwith `GTEST_ROOT` and `GTEST_ROOT/include` in the header search path,\nwhere `GTEST_ROOT` is the Google Test root directory).\n\nOnce you are able to compile the Google Test library, you should\ncreate a project or build target for your test program.  Make sure you\nhave `GTEST_ROOT/include` in the header search path so that the\ncompiler can find `<gtest/gtest.h>` when compiling your test.  Set up\nyour test project to link with the Google Test library (for example,\nin Visual Studio, this is done by adding a dependency on\n`gtest.vcproj`).\n\nIf you still have questions, take a look at how Google Test's own\ntests are built and use them as examples.\n\n# Basic Concepts #\n\nWhen using Google Test, you start by writing _assertions_, which are statements\nthat check whether a condition is true. An assertion's result can be _success_,\n_nonfatal failure_, or _fatal failure_. If a fatal failure occurs, it aborts\nthe current function; otherwise the program continues normally.\n\n_Tests_ use assertions to verify the tested code's behavior. If a test crashes\nor has a failed assertion, then it _fails_; otherwise it _succeeds_.\n\nA _test case_ contains one or many tests. You should group your tests into test\ncases that reflect the structure of the tested code. When multiple tests in a\ntest case need to share common objects and subroutines, you can put them into a\n_test fixture_ class.\n\nA _test program_ can contain multiple test cases.\n\nWe'll now explain how to write a test program, starting at the individual\nassertion level and building up to tests and test cases.\n\n# Assertions #\n\nGoogle Test assertions are macros that resemble function calls. You test a\nclass or function by making assertions about its behavior. When an assertion\nfails, Google Test prints the assertion's source file and line number location,\nalong with a failure message. You may also supply a custom failure message\nwhich will be appended to Google Test's message.\n\nThe assertions come in pairs that test the same thing but have different\neffects on the current function. `ASSERT_*` versions generate fatal failures\nwhen they fail, and **abort the current function**. `EXPECT_*` versions generate\nnonfatal failures, which don't abort the current function. Usually `EXPECT_*`\nare preferred, as they allow more than one failures to be reported in a test.\nHowever, you should use `ASSERT_*` if it doesn't make sense to continue when\nthe assertion in question fails.\n\nSince a failed `ASSERT_*` returns from the current function immediately,\npossibly skipping clean-up code that comes after it, it may cause a space leak.\nDepending on the nature of the leak, it may or may not be worth fixing - so\nkeep this in mind if you get a heap checker error in addition to assertion\nerrors.\n\nTo provide a custom failure message, simply stream it into the macro using the\n`<<` operator, or a sequence of such operators. An example:\n```\nASSERT_EQ(x.size(), y.size()) << \"Vectors x and y are of unequal length\";\n\nfor (int i = 0; i < x.size(); ++i) {\n  EXPECT_EQ(x[i], y[i]) << \"Vectors x and y differ at index \" << i;\n}\n```\n\nAnything that can be streamed to an `ostream` can be streamed to an assertion\nmacro--in particular, C strings and `string` objects. If a wide string\n(`wchar_t*`, `TCHAR*` in `UNICODE` mode on Windows, or `std::wstring`) is\nstreamed to an assertion, it will be translated to UTF-8 when printed.\n\n## Basic Assertions ##\n\nThese assertions do basic true/false condition testing.\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_TRUE(`_condition_`)`;  | `EXPECT_TRUE(`_condition_`)`;   | _condition_ is true |\n| `ASSERT_FALSE(`_condition_`)`; | `EXPECT_FALSE(`_condition_`)`;  | _condition_ is false |\n\nRemember, when they fail, `ASSERT_*` yields a fatal failure and\nreturns from the current function, while `EXPECT_*` yields a nonfatal\nfailure, allowing the function to continue running. In either case, an\nassertion failure means its containing test fails.\n\n_Availability_: Linux, Windows, Mac.\n\n## Binary Comparison ##\n\nThis section describes assertions that compare two values.\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n|`ASSERT_EQ(`_expected_`, `_actual_`);`|`EXPECT_EQ(`_expected_`, `_actual_`);`| _expected_ `==` _actual_ |\n|`ASSERT_NE(`_val1_`, `_val2_`);`      |`EXPECT_NE(`_val1_`, `_val2_`);`      | _val1_ `!=` _val2_ |\n|`ASSERT_LT(`_val1_`, `_val2_`);`      |`EXPECT_LT(`_val1_`, `_val2_`);`      | _val1_ `<` _val2_ |\n|`ASSERT_LE(`_val1_`, `_val2_`);`      |`EXPECT_LE(`_val1_`, `_val2_`);`      | _val1_ `<=` _val2_ |\n|`ASSERT_GT(`_val1_`, `_val2_`);`      |`EXPECT_GT(`_val1_`, `_val2_`);`      | _val1_ `>` _val2_ |\n|`ASSERT_GE(`_val1_`, `_val2_`);`      |`EXPECT_GE(`_val1_`, `_val2_`);`      | _val1_ `>=` _val2_ |\n\nIn the event of a failure, Google Test prints both _val1_ and _val2_\n. In `ASSERT_EQ*` and `EXPECT_EQ*` (and all other equality assertions\nwe'll introduce later), you should put the expression you want to test\nin the position of _actual_, and put its expected value in _expected_,\nas Google Test's failure messages are optimized for this convention.\n\nValue arguments must be comparable by the assertion's comparison operator or\nyou'll get a compiler error. Values must also support the `<<` operator for\nstreaming to an `ostream`. All built-in types support this.\n\nThese assertions can work with a user-defined type, but only if you define the\ncorresponding comparison operator (e.g. `==`, `<`, etc).  If the corresponding\noperator is defined, prefer using the `ASSERT_*()` macros because they will\nprint out not only the result of the comparison, but the two operands as well.\n\nArguments are always evaluated exactly once. Therefore, it's OK for the\narguments to have side effects. However, as with any ordinary C/C++ function,\nthe arguments' evaluation order is undefined (i.e. the compiler is free to\nchoose any order) and your code should not depend on any particular argument\nevaluation order.\n\n`ASSERT_EQ()` does pointer equality on pointers. If used on two C strings, it\ntests if they are in the same memory location, not if they have the same value.\nTherefore, if you want to compare C strings (e.g. `const char*`) by value, use\n`ASSERT_STREQ()` , which will be described later on. In particular, to assert\nthat a C string is `NULL`, use `ASSERT_STREQ(NULL, c_string)` . However, to\ncompare two `string` objects, you should use `ASSERT_EQ`.\n\nMacros in this section work with both narrow and wide string objects (`string`\nand `wstring`).\n\n_Availability_: Linux, Windows, Mac.\n\n## String Comparison ##\n\nThe assertions in this group compare two **C strings**. If you want to compare\ntwo `string` objects, use `EXPECT_EQ`, `EXPECT_NE`, and etc instead.\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_STREQ(`_expected\\_str_`, `_actual\\_str_`);`    | `EXPECT_STREQ(`_expected\\_str_`, `_actual\\_str_`);`     | the two C strings have the same content |\n| `ASSERT_STRNE(`_str1_`, `_str2_`);`    | `EXPECT_STRNE(`_str1_`, `_str2_`);`     | the two C strings have different content |\n| `ASSERT_STRCASEEQ(`_expected\\_str_`, `_actual\\_str_`);`| `EXPECT_STRCASEEQ(`_expected\\_str_`, `_actual\\_str_`);` | the two C strings have the same content, ignoring case |\n| `ASSERT_STRCASENE(`_str1_`, `_str2_`);`| `EXPECT_STRCASENE(`_str1_`, `_str2_`);` | the two C strings have different content, ignoring case |\n\nNote that \"CASE\" in an assertion name means that case is ignored.\n\n`*STREQ*` and `*STRNE*` also accept wide C strings (`wchar_t*`). If a\ncomparison of two wide strings fails, their values will be printed as UTF-8\nnarrow strings.\n\nA `NULL` pointer and an empty string are considered _different_.\n\n_Availability_: Linux, Windows, Mac.\n\nSee also: For more string comparison tricks (substring, prefix, suffix, and\nregular expression matching, for example), see the [AdvancedGuide Advanced\nGoogle Test Guide].\n\n# Simple Tests #\n\nTo create a test:\n  1. Use the `TEST()` macro to define and name a test function, These are ordinary C++ functions that don't return a value.\n  1. In this function, along with any valid C++ statements you want to include, use the various Google Test assertions to check values.\n  1. The test's result is determined by the assertions; if any assertion in the test fails (either fatally or non-fatally), or if the test crashes, the entire test fails. Otherwise, it succeeds.\n\n```\nTEST(test_case_name, test_name) {\n ... test body ...\n}\n```\n\n\n`TEST()` arguments go from general to specific. The _first_ argument is the\nname of the test case, and the _second_ argument is the test's name within the\ntest case. Remember that a test case can contain any number of individual\ntests. A test's _full name_ consists of its containing test case and its\nindividual name. Tests from different test cases can have the same individual\nname.\n\nFor example, let's take a simple integer function:\n```\nint Factorial(int n); // Returns the factorial of n\n```\n\nA test case for this function might look like:\n```\n// Tests factorial of 0.\nTEST(FactorialTest, HandlesZeroInput) {\n  EXPECT_EQ(1, Factorial(0));\n}\n\n// Tests factorial of positive numbers.\nTEST(FactorialTest, HandlesPositiveInput) {\n  EXPECT_EQ(1, Factorial(1));\n  EXPECT_EQ(2, Factorial(2));\n  EXPECT_EQ(6, Factorial(3));\n  EXPECT_EQ(40320, Factorial(8));\n}\n```\n\nGoogle Test groups the test results by test cases, so logically-related tests\nshould be in the same test case; in other words, the first argument to their\n`TEST()` should be the same. In the above example, we have two tests,\n`HandlesZeroInput` and `HandlesPositiveInput`, that belong to the same test\ncase `FactorialTest`.\n\n_Availability_: Linux, Windows, Mac.\n\n# Test Fixtures: Using the Same Data Configuration for Multiple Tests #\n\nIf you find yourself writing two or more tests that operate on similar data,\nyou can use a _test fixture_. It allows you to reuse the same configuration of\nobjects for several different tests.\n\nTo create a fixture, just:\n  1. Derive a class from `::testing::Test` . Start its body with `protected:` or `public:` as we'll want to access fixture members from sub-classes.\n  1. Inside the class, declare any objects you plan to use.\n  1. If necessary, write a default constructor or `SetUp()` function to prepare the objects for each test. A common mistake is to spell `SetUp()` as `Setup()` with a small `u` - don't let that happen to you.\n  1. If necessary, write a destructor or `TearDown()` function to release any resources you allocated in `SetUp()` . To learn when you should use the constructor/destructor and when you should use `SetUp()/TearDown()`, read this [FAQ entry](V1_5_FAQ.md#should-i-use-the-constructordestructor-of-the-test-fixture-or-the-set-uptear-down-function).\n  1. If needed, define subroutines for your tests to share.\n\nWhen using a fixture, use `TEST_F()` instead of `TEST()` as it allows you to\naccess objects and subroutines in the test fixture:\n```\nTEST_F(test_case_name, test_name) {\n ... test body ...\n}\n```\n\nLike `TEST()`, the first argument is the test case name, but for `TEST_F()`\nthis must be the name of the test fixture class. You've probably guessed: `_F`\nis for fixture.\n\nUnfortunately, the C++ macro system does not allow us to create a single macro\nthat can handle both types of tests. Using the wrong macro causes a compiler\nerror.\n\nAlso, you must first define a test fixture class before using it in a\n`TEST_F()`, or you'll get the compiler error \"`virtual outside class\ndeclaration`\".\n\nFor each test defined with `TEST_F()`, Google Test will:\n  1. Create a _fresh_ test fixture at runtime\n  1. Immediately initialize it via `SetUp()` ,\n  1. Run the test\n  1. Clean up by calling `TearDown()`\n  1. Delete the test fixture.  Note that different tests in the same test case have different test fixture objects, and Google Test always deletes a test fixture before it creates the next one. Google Test does not reuse the same test fixture for multiple tests. Any changes one test makes to the fixture do not affect other tests.\n\nAs an example, let's write tests for a FIFO queue class named `Queue`, which\nhas the following interface:\n```\ntemplate <typename E> // E is the element type.\nclass Queue {\n public:\n  Queue();\n  void Enqueue(const E& element);\n  E* Dequeue(); // Returns NULL if the queue is empty.\n  size_t size() const;\n  ...\n};\n```\n\nFirst, define a fixture class. By convention, you should give it the name\n`FooTest` where `Foo` is the class being tested.\n```\nclass QueueTest : public ::testing::Test {\n protected:\n  virtual void SetUp() {\n    q1_.Enqueue(1);\n    q2_.Enqueue(2);\n    q2_.Enqueue(3);\n  }\n\n  // virtual void TearDown() {}\n\n  Queue<int> q0_;\n  Queue<int> q1_;\n  Queue<int> q2_;\n};\n```\n\nIn this case, `TearDown()` is not needed since we don't have to clean up after\neach test, other than what's already done by the destructor.\n\nNow we'll write tests using `TEST_F()` and this fixture.\n```\nTEST_F(QueueTest, IsEmptyInitially) {\n  EXPECT_EQ(0, q0_.size());\n}\n\nTEST_F(QueueTest, DequeueWorks) {\n  int* n = q0_.Dequeue();\n  EXPECT_EQ(NULL, n);\n\n  n = q1_.Dequeue();\n  ASSERT_TRUE(n != NULL);\n  EXPECT_EQ(1, *n);\n  EXPECT_EQ(0, q1_.size());\n  delete n;\n\n  n = q2_.Dequeue();\n  ASSERT_TRUE(n != NULL);\n  EXPECT_EQ(2, *n);\n  EXPECT_EQ(1, q2_.size());\n  delete n;\n}\n```\n\nThe above uses both `ASSERT_*` and `EXPECT_*` assertions. The rule of thumb is\nto use `EXPECT_*` when you want the test to continue to reveal more errors\nafter the assertion failure, and use `ASSERT_*` when continuing after failure\ndoesn't make sense. For example, the second assertion in the `Dequeue` test is\n`ASSERT_TRUE(n != NULL)`, as we need to dereference the pointer `n` later,\nwhich would lead to a segfault when `n` is `NULL`.\n\nWhen these tests run, the following happens:\n  1. Google Test constructs a `QueueTest` object (let's call it `t1` ).\n  1. `t1.SetUp()` initializes `t1` .\n  1. The first test ( `IsEmptyInitially` ) runs on `t1` .\n  1. `t1.TearDown()` cleans up after the test finishes.\n  1. `t1` is destructed.\n  1. The above steps are repeated on another `QueueTest` object, this time running the `DequeueWorks` test.\n\n_Availability_: Linux, Windows, Mac.\n\n_Note_: Google Test automatically saves all _Google Test_ flags when a test\nobject is constructed, and restores them when it is destructed.\n\n# Invoking the Tests #\n\n`TEST()` and `TEST_F()` implicitly register their tests with Google Test. So, unlike with many other C++ testing frameworks, you don't have to re-list all your defined tests in order to run them.\n\nAfter defining your tests, you can run them with `RUN_ALL_TESTS()` , which returns `0` if all the tests are successful, or `1` otherwise. Note that `RUN_ALL_TESTS()` runs _all tests_ in your link unit -- they can be from different test cases, or even different source files.\n\nWhen invoked, the `RUN_ALL_TESTS()` macro:\n  1. Saves the state of all  Google Test flags.\n  1. Creates a test fixture object for the first test.\n  1. Initializes it via `SetUp()`.\n  1. Runs the test on the fixture object.\n  1. Cleans up the fixture via `TearDown()`.\n  1. Deletes the fixture.\n  1. Restores the state of all Google Test flags.\n  1. Repeats the above steps for the next test, until all tests have run.\n\nIn addition, if the text fixture's constructor generates a fatal failure in\nstep 2, there is no point for step 3 - 5 and they are thus skipped. Similarly,\nif step 3 generates a fatal failure, step 4 will be skipped.\n\n_Important_: You must not ignore the return value of `RUN_ALL_TESTS()`, or `gcc`\nwill give you a compiler error. The rationale for this design is that the\nautomated testing service determines whether a test has passed based on its\nexit code, not on its stdout/stderr output; thus your `main()` function must\nreturn the value of `RUN_ALL_TESTS()`.\n\nAlso, you should call `RUN_ALL_TESTS()` only **once**. Calling it more than once\nconflicts with some advanced Google Test features (e.g. thread-safe death\ntests) and thus is not supported.\n\n_Availability_: Linux, Windows, Mac.\n\n# Writing the main() Function #\n\nYou can start from this boilerplate:\n```\n#include \"this/package/foo.h\"\n#include <gtest/gtest.h>\n\nnamespace {\n\n// The fixture for testing class Foo.\nclass FooTest : public ::testing::Test {\n protected:\n  // You can remove any or all of the following functions if its body\n  // is empty.\n\n  FooTest() {\n    // You can do set-up work for each test here.\n  }\n\n  virtual ~FooTest() {\n    // You can do clean-up work that doesn't throw exceptions here.\n  }\n\n  // If the constructor and destructor are not enough for setting up\n  // and cleaning up each test, you can define the following methods:\n\n  virtual void SetUp() {\n    // Code here will be called immediately after the constructor (right\n    // before each test).\n  }\n\n  virtual void TearDown() {\n    // Code here will be called immediately after each test (right\n    // before the destructor).\n  }\n\n  // Objects declared here can be used by all tests in the test case for Foo.\n};\n\n// Tests that the Foo::Bar() method does Abc.\nTEST_F(FooTest, MethodBarDoesAbc) {\n  const string input_filepath = \"this/package/testdata/myinputfile.dat\";\n  const string output_filepath = \"this/package/testdata/myoutputfile.dat\";\n  Foo f;\n  EXPECT_EQ(0, f.Bar(input_filepath, output_filepath));\n}\n\n// Tests that Foo does Xyz.\nTEST_F(FooTest, DoesXyz) {\n  // Exercises the Xyz feature of Foo.\n}\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n```\n\nThe `::testing::InitGoogleTest()` function parses the command line for Google\nTest flags, and removes all recognized flags. This allows the user to control a\ntest program's behavior via various flags, which we'll cover in [AdvancedGuide](V1_5_AdvancedGuide.md).\nYou must call this function before calling `RUN_ALL_TESTS()`, or the flags\nwon't be properly initialized.\n\nOn Windows, `InitGoogleTest()` also works with wide strings, so it can be used\nin programs compiled in `UNICODE` mode as well.\n\nBut maybe you think that writing all those main() functions is too much work? We agree with you completely and that's why Google Test provides a basic implementation of main(). If it fits your needs, then just link your test with gtest\\_main library and you are good to go.\n\n## Important note for Visual C++ users ##\nIf you put your tests into a library and your `main()` function is in a different library or in your .exe file, those tests will not run. The reason is a [bug](https://connect.microsoft.com/feedback/viewfeedback.aspx?FeedbackID=244410&siteid=210) in Visual C++. When you define your tests, Google Test creates certain static objects to register them. These objects are not referenced from elsewhere but their constructors are still supposed to run. When Visual C++ linker sees that nothing in the library is referenced from other places it throws the library out. You have to reference your library with tests from your main program to keep the linker from discarding it. Here is how to do it. Somewhere in your library code declare a function:\n```\n__declspec(dllexport) int PullInMyLibrary() { return 0; }\n```\nIf you put your tests in a static library (not DLL) then `__declspec(dllexport)` is not required. Now, in your main program, write a code that invokes that function:\n```\nint PullInMyLibrary();\nstatic int dummy = PullInMyLibrary();\n```\nThis will keep your tests referenced and will make them register themselves at startup.\n\nIn addition, if you define your tests in a static library, add `/OPT:NOREF` to your main program linker options. If you use MSVC++ IDE, go to your .exe project properties/Configuration Properties/Linker/Optimization and set References setting to `Keep Unreferenced Data (/OPT:NOREF)`. This will keep Visual C++ linker from discarding individual symbols generated by your tests from the final executable.\n\nThere is one more pitfall, though. If you use Google Test as a static library (that's how it is defined in gtest.vcproj) your tests must also reside in a static library. If you have to have them in a DLL, you _must_ change Google Test to build into a DLL as well. Otherwise your tests will not run correctly or will not run at all. The general conclusion here is: make your life easier - do not write your tests in libraries!\n\n# Where to Go from Here #\n\nCongratulations! You've learned the Google Test basics. You can start writing\nand running Google Test tests, read some [samples](Samples.md), or continue with\n[AdvancedGuide](V1_5_AdvancedGuide.md), which describes many more useful Google Test features.\n\n# Known Limitations #\n\nGoogle Test is designed to be thread-safe.  The implementation is\nthread-safe on systems where the `pthreads` library is available.  It\nis currently _unsafe_ to use Google Test assertions from two threads\nconcurrently on other systems (e.g. Windows).  In most tests this is\nnot an issue as usually the assertions are done in the main thread. If\nyou want to help, you can volunteer to implement the necessary\nsynchronization primitives in `gtest-port.h` for your platform.\n"
  },
  {
    "path": "utils/googletest/googletest/docs/V1_5_PumpManual.md",
    "content": "\n\n<b>P</b>ump is <b>U</b>seful for <b>M</b>eta <b>P</b>rogramming.\n\n# The Problem #\n\nTemplate and macro libraries often need to define many classes,\nfunctions, or macros that vary only (or almost only) in the number of\narguments they take. It's a lot of repetitive, mechanical, and\nerror-prone work.\n\nVariadic templates and variadic macros can alleviate the problem.\nHowever, while both are being considered by the C++ committee, neither\nis in the standard yet or widely supported by compilers.  Thus they\nare often not a good choice, especially when your code needs to be\nportable. And their capabilities are still limited.\n\nAs a result, authors of such libraries often have to write scripts to\ngenerate their implementation. However, our experience is that it's\ntedious to write such scripts, which tend to reflect the structure of\nthe generated code poorly and are often hard to read and edit. For\nexample, a small change needed in the generated code may require some\nnon-intuitive, non-trivial changes in the script. This is especially\npainful when experimenting with the code.\n\n# Our Solution #\n\nPump (for Pump is Useful for Meta Programming, Pretty Useful for Meta\nProgramming, or Practical Utility for Meta Programming, whichever you\nprefer) is a simple meta-programming tool for C++. The idea is that a\nprogrammer writes a `foo.pump` file which contains C++ code plus meta\ncode that manipulates the C++ code. The meta code can handle\niterations over a range, nested iterations, local meta variable\ndefinitions, simple arithmetic, and conditional expressions. You can\nview it as a small Domain-Specific Language. The meta language is\ndesigned to be non-intrusive (s.t. it won't confuse Emacs' C++ mode,\nfor example) and concise, making Pump code intuitive and easy to\nmaintain.\n\n## Highlights ##\n\n  * The implementation is in a single Python script and thus ultra portable: no build or installation is needed and it works cross platforms.\n  * Pump tries to be smart with respect to [Google's style guide](http://code.google.com/p/google-styleguide/): it breaks long lines (easy to have when they are generated) at acceptable places to fit within 80 columns and indent the continuation lines correctly.\n  * The format is human-readable and more concise than XML.\n  * The format works relatively well with Emacs' C++ mode.\n\n## Examples ##\n\nThe following Pump code (where meta keywords start with `$`, `[[` and `]]` are meta brackets, and `$$` starts a meta comment that ends with the line):\n\n```\n$var n = 3     $$ Defines a meta variable n.\n$range i 0..n  $$ Declares the range of meta iterator i (inclusive).\n$for i [[\n               $$ Meta loop.\n// Foo$i does blah for $i-ary predicates.\n$range j 1..i\ntemplate <size_t N $for j [[, typename A$j]]>\nclass Foo$i {\n$if i == 0 [[\n  blah a;\n]] $elif i <= 2 [[\n  blah b;\n]] $else [[\n  blah c;\n]]\n};\n\n]]\n```\n\nwill be translated by the Pump compiler to:\n\n```\n// Foo0 does blah for 0-ary predicates.\ntemplate <size_t N>\nclass Foo0 {\n  blah a;\n};\n\n// Foo1 does blah for 1-ary predicates.\ntemplate <size_t N, typename A1>\nclass Foo1 {\n  blah b;\n};\n\n// Foo2 does blah for 2-ary predicates.\ntemplate <size_t N, typename A1, typename A2>\nclass Foo2 {\n  blah b;\n};\n\n// Foo3 does blah for 3-ary predicates.\ntemplate <size_t N, typename A1, typename A2, typename A3>\nclass Foo3 {\n  blah c;\n};\n```\n\nIn another example,\n\n```\n$range i 1..n\nFunc($for i + [[a$i]]);\n$$ The text between i and [[ is the separator between iterations.\n```\n\nwill generate one of the following lines (without the comments), depending on the value of `n`:\n\n```\nFunc();              // If n is 0.\nFunc(a1);            // If n is 1.\nFunc(a1 + a2);       // If n is 2.\nFunc(a1 + a2 + a3);  // If n is 3.\n// And so on...\n```\n\n## Constructs ##\n\nWe support the following meta programming constructs:\n\n| `$var id = exp` | Defines a named constant value. `$id` is valid util the end of the current meta lexical block. |\n|:----------------|:-----------------------------------------------------------------------------------------------|\n| $range id exp..exp | Sets the range of an iteration variable, which can be reused in multiple loops later.          |\n| $for id sep [[code ](.md)] | Iteration. The range of `id` must have been defined earlier. `$id` is valid in `code`.         |\n| `$($)`          | Generates a single `$` character.                                                              |\n| `$id`           | Value of the named constant or iteration variable.                                             |\n| `$(exp)`        | Value of the expression.                                                                       |\n| `$if exp [[ code ]] else_branch` | Conditional.                                                                                   |\n| `[[ code ]]`    | Meta lexical block.                                                                            |\n| `cpp_code`      | Raw C++ code.                                                                                  |\n| `$$ comment`    | Meta comment.                                                                                  |\n\n**Note:** To give the user some freedom in formatting the Pump source\ncode, Pump ignores a new-line character if it's right after `$for foo`\nor next to `[[` or `]]`. Without this rule you'll often be forced to write\nvery long lines to get the desired output. Therefore sometimes you may\nneed to insert an extra new-line in such places for a new-line to show\nup in your output.\n\n## Grammar ##\n\n```\ncode ::= atomic_code*\natomic_code ::= $var id = exp\n    | $var id = [[ code ]]\n    | $range id exp..exp\n    | $for id sep [[ code ]]\n    | $($)\n    | $id\n    | $(exp)\n    | $if exp [[ code ]] else_branch\n    | [[ code ]]\n    | cpp_code\nsep ::= cpp_code | empty_string\nelse_branch ::= $else [[ code ]]\n    | $elif exp [[ code ]] else_branch\n    | empty_string\nexp ::= simple_expression_in_Python_syntax\n```\n\n## Code ##\n\nYou can find the source code of Pump in [scripts/pump.py](http://code.google.com/p/googletest/source/browse/trunk/scripts/pump.py). It is still\nvery unpolished and lacks automated tests, although it has been\nsuccessfully used many times. If you find a chance to use it in your\nproject, please let us know what you think!  We also welcome help on\nimproving Pump.\n\n## Real Examples ##\n\nYou can find real-world applications of Pump in [Google Test](http://www.google.com/codesearch?q=file%3A\\.pump%24+package%3Ahttp%3A%2F%2Fgoogletest\\.googlecode\\.com) and [Google Mock](http://www.google.com/codesearch?q=file%3A\\.pump%24+package%3Ahttp%3A%2F%2Fgooglemock\\.googlecode\\.com).  The source file `foo.h.pump` generates `foo.h`.\n\n## Tips ##\n\n  * If a meta variable is followed by a letter or digit, you can separate them using `[[]]`, which inserts an empty string. For example `Foo$j[[]]Helper` generate `Foo1Helper` when `j` is 1.\n  * To avoid extra-long Pump source lines, you can break a line anywhere you want by inserting `[[]]` followed by a new line. Since any new-line character next to `[[` or `]]` is ignored, the generated code won't contain this new line."
  },
  {
    "path": "utils/googletest/googletest/docs/V1_5_XcodeGuide.md",
    "content": "\n\nThis guide will explain how to use the Google Testing Framework in your Xcode projects on Mac OS X. This tutorial begins by quickly explaining what to do for experienced users. After the quick start, the guide goes provides additional explanation about each step.\n\n# Quick Start #\n\nHere is the quick guide for using Google Test in your Xcode project.\n\n  1. Download the source from the [website](http://code.google.com/p/googletest) using this command: `svn checkout http://googletest.googlecode.com/svn/trunk/ googletest-read-only`\n  1. Open up the `gtest.xcodeproj` in the `googletest-read-only/xcode/` directory and build the gtest.framework.\n  1. Create a new \"Shell Tool\" target in your Xcode project called something like \"UnitTests\"\n  1. Add the gtest.framework to your project and add it to the \"Link Binary with Libraries\" build phase of \"UnitTests\"\n  1. Add your unit test source code to the \"Compile Sources\" build phase of \"UnitTests\"\n  1. Edit the \"UnitTests\" executable and add an environment variable named \"DYLD\\_FRAMEWORK\\_PATH\" with a value equal to the path to the framework containing the gtest.framework relative to the compiled executable.\n  1. Build and Go\n\nThe following sections further explain each of the steps listed above in depth, describing in more detail how to complete it including some variations.\n\n# Get the Source #\n\nCurrently, the gtest.framework discussed here isn't available in a tagged release of Google Test, it is only available in the trunk. As explained at the Google Test [site](http://code.google.com/p/googletest/source/checkout\">svn), you can get the code from anonymous SVN with this command:\n\n```\nsvn checkout http://googletest.googlecode.com/svn/trunk/ googletest-read-only\n```\n\nAlternatively, if you are working with Subversion in your own code base, you can add Google Test as an external dependency to your own Subversion repository. By following this approach, everyone that checks out your svn repository will also receive a copy of Google Test (a specific version, if you wish) without having to check it out explicitly. This makes the set up of your project simpler and reduces the copied code in the repository.\n\nTo use `svn:externals`, decide where you would like to have the external source reside. You might choose to put the external source inside the trunk, because you want it to be part of the branch when you make a release. However, keeping it outside the trunk in a version-tagged directory called something like `third-party/googletest/1.0.1`, is another option. Once the location is established, use `svn propedit svn:externals _directory_` to set the svn:externals property on a directory in your repository. This directory won't contain the code, but be its versioned parent directory.\n\nThe command `svn propedit` will bring up your Subversion editor, making editing the long, (potentially multi-line) property simpler. This same method can be used to check out a tagged branch, by using the appropriate URL (e.g. `http://googletest.googlecode.com/svn/tags/release-1.0.1`). Additionally, the svn:externals property allows the specification of a particular revision of the trunk with the `-r_##_` option (e.g. `externals/src/googletest -r60 http://googletest.googlecode.com/svn/trunk`).\n\nHere is an example of using the svn:externals properties on a trunk (read via `svn propget`) of a project. This value checks out a copy of Google Test into the `trunk/externals/src/googletest/` directory.\n\n```\n[Computer:svn] user$ svn propget svn:externals trunk\nexternals/src/googletest http://googletest.googlecode.com/svn/trunk\n```\n\n# Add the Framework to Your Project #\n\nThe next step is to build and add the gtest.framework to your own project. This guide describes two common ways below.\n\n  * **Option 1** --- The simplest way to add Google Test to your own project, is to open gtest.xcodeproj (found in the xcode/ directory of the Google Test trunk) and build the framework manually. Then, add the built framework into your project using the \"Add->Existing Framework...\" from the context menu or \"Project->Add...\" from the main menu. The gtest.framework is relocatable and contains the headers and object code that you'll need to make tests. This method requires rebuilding every time you upgrade Google Test in your project.\n  * **Option 2** --- If you are going to be living off the trunk of Google Test, incorporating its latest features into your unit tests (or are a Google Test developer yourself). You'll want to rebuild the framework every time the source updates. to do this, you'll need to add the gtest.xcodeproj file, not the framework itself, to your own Xcode project. Then, from the build products that are revealed by the project's disclosure triangle, you can find the gtest.framework, which can be added to your targets (discussed below).\n\n# Make a Test Target #\n\nTo start writing tests, make a new \"Shell Tool\" target. This target template is available under BSD, Cocoa, or Carbon. Add your unit test source code to the \"Compile Sources\" build phase of the target.\n\nNext, you'll want to add gtest.framework in two different ways, depending upon which option you chose above.\n\n  * **Option 1** --- During compilation, Xcode will need to know that you are linking against the gtest.framework. Add the gtest.framework to the \"Link Binary with Libraries\" build phase of your test target. This will include the Google Test headers in your header search path, and will tell the linker where to find the library.\n  * **Option 2** --- If your working out of the trunk, you'll also want to add gtest.framework to your \"Link Binary with Libraries\" build phase of your test target. In addition, you'll  want to add the gtest.framework as a dependency to your unit test target. This way, Xcode will make sure that gtest.framework is up to date, every time your build your target. Finally, if you don't share build directories with Google Test, you'll have to copy the gtest.framework into your own build products directory using a \"Run Script\" build phase.\n\n# Set Up the Executable Run Environment #\n\nSince the unit test executable is a shell tool, it doesn't have a bundle with a `Contents/Frameworks` directory, in which to place gtest.framework. Instead, the dynamic linker must be told at runtime to search for the framework in another location. This can be accomplished by setting the \"DYLD\\_FRAMEWORK\\_PATH\" environment variable in the \"Edit Active Executable ...\" Arguments tab, under \"Variables to be set in the environment:\". The path for this value is the path (relative or absolute) of the directory containing the gtest.framework.\n\nIf you haven't set up the DYLD\\_FRAMEWORK\\_PATH, correctly, you might get a message like this:\n\n```\n[Session started at 2008-08-15 06:23:57 -0600.]\n  dyld: Library not loaded: @loader_path/../Frameworks/gtest.framework/Versions/A/gtest\n    Referenced from: /Users/username/Documents/Sandbox/gtestSample/build/Debug/WidgetFrameworkTest\n    Reason: image not found\n```\n\nTo correct this problem, got to the directory containing the executable named in \"Referenced from:\" value in the error message above. Then, with the terminal in this location, find the relative path to the directory containing the gtest.framework. That is the value you'll need to set as the DYLD\\_FRAMEWORK\\_PATH.\n\n# Build and Go #\n\nNow, when you click \"Build and Go\", the test will be executed. Dumping out something like this:\n\n```\n[Session started at 2008-08-06 06:36:13 -0600.]\n[==========] Running 2 tests from 1 test case.\n[----------] Global test environment set-up.\n[----------] 2 tests from WidgetInitializerTest\n[ RUN      ] WidgetInitializerTest.TestConstructor\n[       OK ] WidgetInitializerTest.TestConstructor\n[ RUN      ] WidgetInitializerTest.TestConversion\n[       OK ] WidgetInitializerTest.TestConversion\n[----------] Global test environment tear-down\n[==========] 2 tests from 1 test case ran.\n[  PASSED  ] 2 tests.\n\nThe Debugger has exited with status 0.  \n```\n\n# Summary #\n\nUnit testing is a valuable way to ensure your data model stays valid even during rapid development or refactoring. The Google Testing Framework is a great unit testing framework for C and C++ which integrates well with an Xcode development environment."
  },
  {
    "path": "utils/googletest/googletest/docs/V1_6_AdvancedGuide.md",
    "content": "\n\nNow that you have read [Primer](V1_6_Primer.md) and learned how to write tests\nusing Google Test, it's time to learn some new tricks. This document\nwill show you more assertions as well as how to construct complex\nfailure messages, propagate fatal failures, reuse and speed up your\ntest fixtures, and use various flags with your tests.\n\n# More Assertions #\n\nThis section covers some less frequently used, but still significant,\nassertions.\n\n## Explicit Success and Failure ##\n\nThese three assertions do not actually test a value or expression. Instead,\nthey generate a success or failure directly. Like the macros that actually\nperform a test, you may stream a custom failure message into the them.\n\n| `SUCCEED();` |\n|:-------------|\n\nGenerates a success. This does NOT make the overall test succeed. A test is\nconsidered successful only if none of its assertions fail during its execution.\n\nNote: `SUCCEED()` is purely documentary and currently doesn't generate any\nuser-visible output. However, we may add `SUCCEED()` messages to Google Test's\noutput in the future.\n\n| `FAIL();`  | `ADD_FAILURE();` | `ADD_FAILURE_AT(\"`_file\\_path_`\", `_line\\_number_`);` |\n|:-----------|:-----------------|:------------------------------------------------------|\n\n`FAIL()` generates a fatal failure, while `ADD_FAILURE()` and `ADD_FAILURE_AT()` generate a nonfatal\nfailure. These are useful when control flow, rather than a Boolean expression,\ndeteremines the test's success or failure. For example, you might want to write\nsomething like:\n\n```\nswitch(expression) {\n  case 1: ... some checks ...\n  case 2: ... some other checks\n  ...\n  default: FAIL() << \"We shouldn't get here.\";\n}\n```\n\n_Availability_: Linux, Windows, Mac.\n\n## Exception Assertions ##\n\nThese are for verifying that a piece of code throws (or does not\nthrow) an exception of the given type:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_THROW(`_statement_, _exception\\_type_`);`  | `EXPECT_THROW(`_statement_, _exception\\_type_`);`  | _statement_ throws an exception of the given type  |\n| `ASSERT_ANY_THROW(`_statement_`);`                | `EXPECT_ANY_THROW(`_statement_`);`                | _statement_ throws an exception of any type        |\n| `ASSERT_NO_THROW(`_statement_`);`                 | `EXPECT_NO_THROW(`_statement_`);`                 | _statement_ doesn't throw any exception            |\n\nExamples:\n\n```\nASSERT_THROW(Foo(5), bar_exception);\n\nEXPECT_NO_THROW({\n  int n = 5;\n  Bar(&n);\n});\n```\n\n_Availability_: Linux, Windows, Mac; since version 1.1.0.\n\n## Predicate Assertions for Better Error Messages ##\n\nEven though Google Test has a rich set of assertions, they can never be\ncomplete, as it's impossible (nor a good idea) to anticipate all the scenarios\na user might run into. Therefore, sometimes a user has to use `EXPECT_TRUE()`\nto check a complex expression, for lack of a better macro. This has the problem\nof not showing you the values of the parts of the expression, making it hard to\nunderstand what went wrong. As a workaround, some users choose to construct the\nfailure message by themselves, streaming it into `EXPECT_TRUE()`. However, this\nis awkward especially when the expression has side-effects or is expensive to\nevaluate.\n\nGoogle Test gives you three different options to solve this problem:\n\n### Using an Existing Boolean Function ###\n\nIf you already have a function or a functor that returns `bool` (or a type\nthat can be implicitly converted to `bool`), you can use it in a _predicate\nassertion_ to get the function arguments printed for free:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_PRED1(`_pred1, val1_`);`       | `EXPECT_PRED1(`_pred1, val1_`);` | _pred1(val1)_ returns true |\n| `ASSERT_PRED2(`_pred2, val1, val2_`);` | `EXPECT_PRED2(`_pred2, val1, val2_`);` |  _pred2(val1, val2)_ returns true |\n|  ...                | ...                    | ...          |\n\nIn the above, _predn_ is an _n_-ary predicate function or functor, where\n_val1_, _val2_, ..., and _valn_ are its arguments. The assertion succeeds\nif the predicate returns `true` when applied to the given arguments, and fails\notherwise. When the assertion fails, it prints the value of each argument. In\neither case, the arguments are evaluated exactly once.\n\nHere's an example. Given\n\n```\n// Returns true iff m and n have no common divisors except 1.\nbool MutuallyPrime(int m, int n) { ... }\nconst int a = 3;\nconst int b = 4;\nconst int c = 10;\n```\n\nthe assertion `EXPECT_PRED2(MutuallyPrime, a, b);` will succeed, while the\nassertion `EXPECT_PRED2(MutuallyPrime, b, c);` will fail with the message\n\n<pre>\n!MutuallyPrime(b, c) is false, where<br>\nb is 4<br>\nc is 10<br>\n</pre>\n\n**Notes:**\n\n  1. If you see a compiler error \"no matching function to call\" when using `ASSERT_PRED*` or `EXPECT_PRED*`, please see [this](v1_6_FAQ.md#ithe-compiler-complains-about-undefined-references-to-some-static-const-member-variables-but-i-did-define-them-in-the-class-body-whats-wrong) for how to resolve it.\n  1. Currently we only provide predicate assertions of arity <= 5. If you need a higher-arity assertion, let us know.\n\n_Availability_: Linux, Windows, Mac\n\n### Using a Function That Returns an AssertionResult ###\n\nWhile `EXPECT_PRED*()` and friends are handy for a quick job, the\nsyntax is not satisfactory: you have to use different macros for\ndifferent arities, and it feels more like Lisp than C++.  The\n`::testing::AssertionResult` class solves this problem.\n\nAn `AssertionResult` object represents the result of an assertion\n(whether it's a success or a failure, and an associated message).  You\ncan create an `AssertionResult` using one of these factory\nfunctions:\n\n```\nnamespace testing {\n\n// Returns an AssertionResult object to indicate that an assertion has\n// succeeded.\nAssertionResult AssertionSuccess();\n\n// Returns an AssertionResult object to indicate that an assertion has\n// failed.\nAssertionResult AssertionFailure();\n\n}\n```\n\nYou can then use the `<<` operator to stream messages to the\n`AssertionResult` object.\n\nTo provide more readable messages in Boolean assertions\n(e.g. `EXPECT_TRUE()`), write a predicate function that returns\n`AssertionResult` instead of `bool`. For example, if you define\n`IsEven()` as:\n\n```\n::testing::AssertionResult IsEven(int n) {\n  if ((n % 2) == 0)\n    return ::testing::AssertionSuccess();\n  else\n    return ::testing::AssertionFailure() << n << \" is odd\";\n}\n```\n\ninstead of:\n\n```\nbool IsEven(int n) {\n  return (n % 2) == 0;\n}\n```\n\nthe failed assertion `EXPECT_TRUE(IsEven(Fib(4)))` will print:\n\n<pre>\nValue of: !IsEven(Fib(4))<br>\nActual: false (*3 is odd*)<br>\nExpected: true<br>\n</pre>\n\ninstead of a more opaque\n\n<pre>\nValue of: !IsEven(Fib(4))<br>\nActual: false<br>\nExpected: true<br>\n</pre>\n\nIf you want informative messages in `EXPECT_FALSE` and `ASSERT_FALSE`\nas well, and are fine with making the predicate slower in the success\ncase, you can supply a success message:\n\n```\n::testing::AssertionResult IsEven(int n) {\n  if ((n % 2) == 0)\n    return ::testing::AssertionSuccess() << n << \" is even\";\n  else\n    return ::testing::AssertionFailure() << n << \" is odd\";\n}\n```\n\nThen the statement `EXPECT_FALSE(IsEven(Fib(6)))` will print\n\n<pre>\nValue of: !IsEven(Fib(6))<br>\nActual: true (8 is even)<br>\nExpected: false<br>\n</pre>\n\n_Availability_: Linux, Windows, Mac; since version 1.4.1.\n\n### Using a Predicate-Formatter ###\n\nIf you find the default message generated by `(ASSERT|EXPECT)_PRED*` and\n`(ASSERT|EXPECT)_(TRUE|FALSE)` unsatisfactory, or some arguments to your\npredicate do not support streaming to `ostream`, you can instead use the\nfollowing _predicate-formatter assertions_ to _fully_ customize how the\nmessage is formatted:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_PRED_FORMAT1(`_pred\\_format1, val1_`);`        | `EXPECT_PRED_FORMAT1(`_pred\\_format1, val1_`); | _pred\\_format1(val1)_ is successful |\n| `ASSERT_PRED_FORMAT2(`_pred\\_format2, val1, val2_`);` | `EXPECT_PRED_FORMAT2(`_pred\\_format2, val1, val2_`);` | _pred\\_format2(val1, val2)_ is successful |\n| `...`               | `...`                  | `...`        |\n\nThe difference between this and the previous two groups of macros is that instead of\na predicate, `(ASSERT|EXPECT)_PRED_FORMAT*` take a _predicate-formatter_\n(_pred\\_formatn_), which is a function or functor with the signature:\n\n`::testing::AssertionResult PredicateFormattern(const char* `_expr1_`, const char* `_expr2_`, ... const char* `_exprn_`, T1 `_val1_`, T2 `_val2_`, ... Tn `_valn_`);`\n\nwhere _val1_, _val2_, ..., and _valn_ are the values of the predicate\narguments, and _expr1_, _expr2_, ..., and _exprn_ are the corresponding\nexpressions as they appear in the source code. The types `T1`, `T2`, ..., and\n`Tn` can be either value types or reference types. For example, if an\nargument has type `Foo`, you can declare it as either `Foo` or `const Foo&`,\nwhichever is appropriate.\n\nA predicate-formatter returns a `::testing::AssertionResult` object to indicate\nwhether the assertion has succeeded or not. The only way to create such an\nobject is to call one of these factory functions:\n\nAs an example, let's improve the failure message in the previous example, which uses `EXPECT_PRED2()`:\n\n```\n// Returns the smallest prime common divisor of m and n,\n// or 1 when m and n are mutually prime.\nint SmallestPrimeCommonDivisor(int m, int n) { ... }\n\n// A predicate-formatter for asserting that two integers are mutually prime.\n::testing::AssertionResult AssertMutuallyPrime(const char* m_expr,\n                                               const char* n_expr,\n                                               int m,\n                                               int n) {\n  if (MutuallyPrime(m, n))\n    return ::testing::AssertionSuccess();\n\n  return ::testing::AssertionFailure()\n      << m_expr << \" and \" << n_expr << \" (\" << m << \" and \" << n\n      << \") are not mutually prime, \" << \"as they have a common divisor \"\n      << SmallestPrimeCommonDivisor(m, n);\n}\n```\n\nWith this predicate-formatter, we can use\n\n```\nEXPECT_PRED_FORMAT2(AssertMutuallyPrime, b, c);\n```\n\nto generate the message\n\n<pre>\nb and c (4 and 10) are not mutually prime, as they have a common divisor 2.<br>\n</pre>\n\nAs you may have realized, many of the assertions we introduced earlier are\nspecial cases of `(EXPECT|ASSERT)_PRED_FORMAT*`. In fact, most of them are\nindeed defined using `(EXPECT|ASSERT)_PRED_FORMAT*`.\n\n_Availability_: Linux, Windows, Mac.\n\n\n## Floating-Point Comparison ##\n\nComparing floating-point numbers is tricky. Due to round-off errors, it is\nvery unlikely that two floating-points will match exactly. Therefore,\n`ASSERT_EQ` 's naive comparison usually doesn't work. And since floating-points\ncan have a wide value range, no single fixed error bound works. It's better to\ncompare by a fixed relative error bound, except for values close to 0 due to\nthe loss of precision there.\n\nIn general, for floating-point comparison to make sense, the user needs to\ncarefully choose the error bound. If they don't want or care to, comparing in\nterms of Units in the Last Place (ULPs) is a good default, and Google Test\nprovides assertions to do this. Full details about ULPs are quite long; if you\nwant to learn more, see\n[this article on float comparison](http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm).\n\n### Floating-Point Macros ###\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_FLOAT_EQ(`_expected, actual_`);`  | `EXPECT_FLOAT_EQ(`_expected, actual_`);` | the two `float` values are almost equal |\n| `ASSERT_DOUBLE_EQ(`_expected, actual_`);` | `EXPECT_DOUBLE_EQ(`_expected, actual_`);` | the two `double` values are almost equal |\n\nBy \"almost equal\", we mean the two values are within 4 ULP's from each\nother.\n\nThe following assertions allow you to choose the acceptable error bound:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_NEAR(`_val1, val2, abs\\_error_`);` | `EXPECT_NEAR`_(val1, val2, abs\\_error_`);` | the difference between _val1_ and _val2_ doesn't exceed the given absolute error |\n\n_Availability_: Linux, Windows, Mac.\n\n### Floating-Point Predicate-Format Functions ###\n\nSome floating-point operations are useful, but not that often used. In order\nto avoid an explosion of new macros, we provide them as predicate-format\nfunctions that can be used in predicate assertion macros (e.g.\n`EXPECT_PRED_FORMAT2`, etc).\n\n```\nEXPECT_PRED_FORMAT2(::testing::FloatLE, val1, val2);\nEXPECT_PRED_FORMAT2(::testing::DoubleLE, val1, val2);\n```\n\nVerifies that _val1_ is less than, or almost equal to, _val2_. You can\nreplace `EXPECT_PRED_FORMAT2` in the above table with `ASSERT_PRED_FORMAT2`.\n\n_Availability_: Linux, Windows, Mac.\n\n## Windows HRESULT assertions ##\n\nThese assertions test for `HRESULT` success or failure.\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_HRESULT_SUCCEEDED(`_expression_`);` | `EXPECT_HRESULT_SUCCEEDED(`_expression_`);` | _expression_ is a success `HRESULT` |\n| `ASSERT_HRESULT_FAILED(`_expression_`);`    | `EXPECT_HRESULT_FAILED(`_expression_`);`    | _expression_ is a failure `HRESULT` |\n\nThe generated output contains the human-readable error message\nassociated with the `HRESULT` code returned by _expression_.\n\nYou might use them like this:\n\n```\nCComPtr shell;\nASSERT_HRESULT_SUCCEEDED(shell.CoCreateInstance(L\"Shell.Application\"));\nCComVariant empty;\nASSERT_HRESULT_SUCCEEDED(shell->ShellExecute(CComBSTR(url), empty, empty, empty, empty));\n```\n\n_Availability_: Windows.\n\n## Type Assertions ##\n\nYou can call the function\n```\n::testing::StaticAssertTypeEq<T1, T2>();\n```\nto assert that types `T1` and `T2` are the same.  The function does\nnothing if the assertion is satisfied.  If the types are different,\nthe function call will fail to compile, and the compiler error message\nwill likely (depending on the compiler) show you the actual values of\n`T1` and `T2`.  This is mainly useful inside template code.\n\n_Caveat:_ When used inside a member function of a class template or a\nfunction template, `StaticAssertTypeEq<T1, T2>()` is effective _only if_\nthe function is instantiated.  For example, given:\n```\ntemplate <typename T> class Foo {\n public:\n  void Bar() { ::testing::StaticAssertTypeEq<int, T>(); }\n};\n```\nthe code:\n```\nvoid Test1() { Foo<bool> foo; }\n```\nwill _not_ generate a compiler error, as `Foo<bool>::Bar()` is never\nactually instantiated.  Instead, you need:\n```\nvoid Test2() { Foo<bool> foo; foo.Bar(); }\n```\nto cause a compiler error.\n\n_Availability:_ Linux, Windows, Mac; since version 1.3.0.\n\n## Assertion Placement ##\n\nYou can use assertions in any C++ function. In particular, it doesn't\nhave to be a method of the test fixture class. The one constraint is\nthat assertions that generate a fatal failure (`FAIL*` and `ASSERT_*`)\ncan only be used in void-returning functions. This is a consequence of\nGoogle Test not using exceptions. By placing it in a non-void function\nyou'll get a confusing compile error like\n`\"error: void value not ignored as it ought to be\"`.\n\nIf you need to use assertions in a function that returns non-void, one option\nis to make the function return the value in an out parameter instead. For\nexample, you can rewrite `T2 Foo(T1 x)` to `void Foo(T1 x, T2* result)`. You\nneed to make sure that `*result` contains some sensible value even when the\nfunction returns prematurely. As the function now returns `void`, you can use\nany assertion inside of it.\n\nIf changing the function's type is not an option, you should just use\nassertions that generate non-fatal failures, such as `ADD_FAILURE*` and\n`EXPECT_*`.\n\n_Note_: Constructors and destructors are not considered void-returning\nfunctions, according to the C++ language specification, and so you may not use\nfatal assertions in them. You'll get a compilation error if you try. A simple\nworkaround is to transfer the entire body of the constructor or destructor to a\nprivate void-returning method. However, you should be aware that a fatal\nassertion failure in a constructor does not terminate the current test, as your\nintuition might suggest; it merely returns from the constructor early, possibly\nleaving your object in a partially-constructed state. Likewise, a fatal\nassertion failure in a destructor may leave your object in a\npartially-destructed state. Use assertions carefully in these situations!\n\n# Teaching Google Test How to Print Your Values #\n\nWhen a test assertion such as `EXPECT_EQ` fails, Google Test prints the\nargument values to help you debug.  It does this using a\nuser-extensible value printer.\n\nThis printer knows how to print built-in C++ types, native arrays, STL\ncontainers, and any type that supports the `<<` operator.  For other\ntypes, it prints the raw bytes in the value and hopes that you the\nuser can figure it out.\n\nAs mentioned earlier, the printer is _extensible_.  That means\nyou can teach it to do a better job at printing your particular type\nthan to dump the bytes.  To do that, define `<<` for your type:\n\n```\n#include <iostream>\n\nnamespace foo {\n\nclass Bar { ... };  // We want Google Test to be able to print instances of this.\n\n// It's important that the << operator is defined in the SAME\n// namespace that defines Bar.  C++'s look-up rules rely on that.\n::std::ostream& operator<<(::std::ostream& os, const Bar& bar) {\n  return os << bar.DebugString();  // whatever needed to print bar to os\n}\n\n}  // namespace foo\n```\n\nSometimes, this might not be an option: your team may consider it bad\nstyle to have a `<<` operator for `Bar`, or `Bar` may already have a\n`<<` operator that doesn't do what you want (and you cannot change\nit).  If so, you can instead define a `PrintTo()` function like this:\n\n```\n#include <iostream>\n\nnamespace foo {\n\nclass Bar { ... };\n\n// It's important that PrintTo() is defined in the SAME\n// namespace that defines Bar.  C++'s look-up rules rely on that.\nvoid PrintTo(const Bar& bar, ::std::ostream* os) {\n  *os << bar.DebugString();  // whatever needed to print bar to os\n}\n\n}  // namespace foo\n```\n\nIf you have defined both `<<` and `PrintTo()`, the latter will be used\nwhen Google Test is concerned.  This allows you to customize how the value\nappears in Google Test's output without affecting code that relies on the\nbehavior of its `<<` operator.\n\nIf you want to print a value `x` using Google Test's value printer\nyourself, just call `::testing::PrintToString(`_x_`)`, which\nreturns an `std::string`:\n\n```\nvector<pair<Bar, int> > bar_ints = GetBarIntVector();\n\nEXPECT_TRUE(IsCorrectBarIntVector(bar_ints))\n    << \"bar_ints = \" << ::testing::PrintToString(bar_ints);\n```\n\n# Death Tests #\n\nIn many applications, there are assertions that can cause application failure\nif a condition is not met. These sanity checks, which ensure that the program\nis in a known good state, are there to fail at the earliest possible time after\nsome program state is corrupted. If the assertion checks the wrong condition,\nthen the program may proceed in an erroneous state, which could lead to memory\ncorruption, security holes, or worse. Hence it is vitally important to test\nthat such assertion statements work as expected.\n\nSince these precondition checks cause the processes to die, we call such tests\n_death tests_. More generally, any test that checks that a program terminates\n(except by throwing an exception) in an expected fashion is also a death test.\n\nNote that if a piece of code throws an exception, we don't consider it \"death\"\nfor the purpose of death tests, as the caller of the code could catch the exception\nand avoid the crash. If you want to verify exceptions thrown by your code,\nsee [Exception Assertions](#exception-assertions).\n\nIf you want to test `EXPECT_*()/ASSERT_*()` failures in your test code, see [Catching Failures](#catching-failures).\n\n## How to Write a Death Test ##\n\nGoogle Test has the following macros to support death tests:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_DEATH(`_statement, regex_`); | `EXPECT_DEATH(`_statement, regex_`); | _statement_ crashes with the given error |\n| `ASSERT_DEATH_IF_SUPPORTED(`_statement, regex_`); | `EXPECT_DEATH_IF_SUPPORTED(`_statement, regex_`); | if death tests are supported, verifies that _statement_ crashes with the given error; otherwise verifies nothing |\n| `ASSERT_EXIT(`_statement, predicate, regex_`); | `EXPECT_EXIT(`_statement, predicate, regex_`); |_statement_ exits with the given error and its exit code matches _predicate_ |\n\nwhere _statement_ is a statement that is expected to cause the process to\ndie, _predicate_ is a function or function object that evaluates an integer\nexit status, and _regex_ is a regular expression that the stderr output of\n_statement_ is expected to match. Note that _statement_ can be _any valid\nstatement_ (including _compound statement_) and doesn't have to be an\nexpression.\n\nAs usual, the `ASSERT` variants abort the current test function, while the\n`EXPECT` variants do not.\n\n**Note:** We use the word \"crash\" here to mean that the process\nterminates with a _non-zero_ exit status code.  There are two\npossibilities: either the process has called `exit()` or `_exit()`\nwith a non-zero value, or it may be killed by a signal.\n\nThis means that if _statement_ terminates the process with a 0 exit\ncode, it is _not_ considered a crash by `EXPECT_DEATH`.  Use\n`EXPECT_EXIT` instead if this is the case, or if you want to restrict\nthe exit code more precisely.\n\nA predicate here must accept an `int` and return a `bool`. The death test\nsucceeds only if the predicate returns `true`. Google Test defines a few\npredicates that handle the most common cases:\n\n```\n::testing::ExitedWithCode(exit_code)\n```\n\nThis expression is `true` if the program exited normally with the given exit\ncode.\n\n```\n::testing::KilledBySignal(signal_number)  // Not available on Windows.\n```\n\nThis expression is `true` if the program was killed by the given signal.\n\nThe `*_DEATH` macros are convenient wrappers for `*_EXIT` that use a predicate\nthat verifies the process' exit code is non-zero.\n\nNote that a death test only cares about three things:\n\n  1. does _statement_ abort or exit the process?\n  1. (in the case of `ASSERT_EXIT` and `EXPECT_EXIT`) does the exit status satisfy _predicate_?  Or (in the case of `ASSERT_DEATH` and `EXPECT_DEATH`) is the exit status non-zero?  And\n  1. does the stderr output match _regex_?\n\nIn particular, if _statement_ generates an `ASSERT_*` or `EXPECT_*` failure, it will **not** cause the death test to fail, as Google Test assertions don't abort the process.\n\nTo write a death test, simply use one of the above macros inside your test\nfunction. For example,\n\n```\nTEST(My*DeathTest*, Foo) {\n  // This death test uses a compound statement.\n  ASSERT_DEATH({ int n = 5; Foo(&n); }, \"Error on line .* of Foo()\");\n}\nTEST(MyDeathTest, NormalExit) {\n  EXPECT_EXIT(NormalExit(), ::testing::ExitedWithCode(0), \"Success\");\n}\nTEST(MyDeathTest, KillMyself) {\n  EXPECT_EXIT(KillMyself(), ::testing::KilledBySignal(SIGKILL), \"Sending myself unblockable signal\");\n}\n```\n\nverifies that:\n\n  * calling `Foo(5)` causes the process to die with the given error message,\n  * calling `NormalExit()` causes the process to print `\"Success\"` to stderr and exit with exit code 0, and\n  * calling `KillMyself()` kills the process with signal `SIGKILL`.\n\nThe test function body may contain other assertions and statements as well, if\nnecessary.\n\n_Important:_ We strongly recommend you to follow the convention of naming your\ntest case (not test) `*DeathTest` when it contains a death test, as\ndemonstrated in the above example. The `Death Tests And Threads` section below\nexplains why.\n\nIf a test fixture class is shared by normal tests and death tests, you\ncan use typedef to introduce an alias for the fixture class and avoid\nduplicating its code:\n```\nclass FooTest : public ::testing::Test { ... };\n\ntypedef FooTest FooDeathTest;\n\nTEST_F(FooTest, DoesThis) {\n  // normal test\n}\n\nTEST_F(FooDeathTest, DoesThat) {\n  // death test\n}\n```\n\n_Availability:_ Linux, Windows (requires MSVC 8.0 or above), Cygwin, and Mac (the latter three are supported since v1.3.0).  `(ASSERT|EXPECT)_DEATH_IF_SUPPORTED` are new in v1.4.0.\n\n## Regular Expression Syntax ##\n\nOn POSIX systems (e.g. Linux, Cygwin, and Mac), Google Test uses the\n[POSIX extended regular expression](http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_04)\nsyntax in death tests. To learn about this syntax, you may want to read this [Wikipedia entry](http://en.wikipedia.org/wiki/Regular_expression#POSIX_Extended_Regular_Expressions).\n\nOn Windows, Google Test uses its own simple regular expression\nimplementation. It lacks many features you can find in POSIX extended\nregular expressions.  For example, we don't support union (`\"x|y\"`),\ngrouping (`\"(xy)\"`), brackets (`\"[xy]\"`), and repetition count\n(`\"x{5,7}\"`), among others. Below is what we do support (`A` denotes a\nliteral character, period (`.`), or a single `\\\\` escape sequence; `x`\nand `y` denote regular expressions.):\n\n| `c` | matches any literal character `c` |\n|:----|:----------------------------------|\n| `\\\\d` | matches any decimal digit         |\n| `\\\\D` | matches any character that's not a decimal digit |\n| `\\\\f` | matches `\\f`                      |\n| `\\\\n` | matches `\\n`                      |\n| `\\\\r` | matches `\\r`                      |\n| `\\\\s` | matches any ASCII whitespace, including `\\n` |\n| `\\\\S` | matches any character that's not a whitespace |\n| `\\\\t` | matches `\\t`                      |\n| `\\\\v` | matches `\\v`                      |\n| `\\\\w` | matches any letter, `_`, or decimal digit |\n| `\\\\W` | matches any character that `\\\\w` doesn't match |\n| `\\\\c` | matches any literal character `c`, which must be a punctuation |\n| `.` | matches any single character except `\\n` |\n| `A?` | matches 0 or 1 occurrences of `A` |\n| `A*` | matches 0 or many occurrences of `A` |\n| `A+` | matches 1 or many occurrences of `A` |\n| `^` | matches the beginning of a string (not that of each line) |\n| `$` | matches the end of a string (not that of each line) |\n| `xy` | matches `x` followed by `y`       |\n\nTo help you determine which capability is available on your system,\nGoogle Test defines macro `GTEST_USES_POSIX_RE=1` when it uses POSIX\nextended regular expressions, or `GTEST_USES_SIMPLE_RE=1` when it uses\nthe simple version.  If you want your death tests to work in both\ncases, you can either `#if` on these macros or use the more limited\nsyntax only.\n\n## How It Works ##\n\nUnder the hood, `ASSERT_EXIT()` spawns a new process and executes the\ndeath test statement in that process. The details of of how precisely\nthat happens depend on the platform and the variable\n`::testing::GTEST_FLAG(death_test_style)` (which is initialized from the\ncommand-line flag `--gtest_death_test_style`).\n\n  * On POSIX systems, `fork()` (or `clone()` on Linux) is used to spawn the child, after which:\n    * If the variable's value is `\"fast\"`, the death test statement is immediately executed.\n    * If the variable's value is `\"threadsafe\"`, the child process re-executes the unit test binary just as it was originally invoked, but with some extra flags to cause just the single death test under consideration to be run.\n  * On Windows, the child is spawned using the `CreateProcess()` API, and re-executes the binary to cause just the single death test under consideration to be run - much like the `threadsafe` mode on POSIX.\n\nOther values for the variable are illegal and will cause the death test to\nfail. Currently, the flag's default value is `\"fast\"`. However, we reserve the\nright to change it in the future. Therefore, your tests should not depend on\nthis.\n\nIn either case, the parent process waits for the child process to complete, and checks that\n\n  1. the child's exit status satisfies the predicate, and\n  1. the child's stderr matches the regular expression.\n\nIf the death test statement runs to completion without dying, the child\nprocess will nonetheless terminate, and the assertion fails.\n\n## Death Tests And Threads ##\n\nThe reason for the two death test styles has to do with thread safety. Due to\nwell-known problems with forking in the presence of threads, death tests should\nbe run in a single-threaded context. Sometimes, however, it isn't feasible to\narrange that kind of environment. For example, statically-initialized modules\nmay start threads before main is ever reached. Once threads have been created,\nit may be difficult or impossible to clean them up.\n\nGoogle Test has three features intended to raise awareness of threading issues.\n\n  1. A warning is emitted if multiple threads are running when a death test is encountered.\n  1. Test cases with a name ending in \"DeathTest\" are run before all other tests.\n  1. It uses `clone()` instead of `fork()` to spawn the child process on Linux (`clone()` is not available on Cygwin and Mac), as `fork()` is more likely to cause the child to hang when the parent process has multiple threads.\n\nIt's perfectly fine to create threads inside a death test statement; they are\nexecuted in a separate process and cannot affect the parent.\n\n## Death Test Styles ##\n\nThe \"threadsafe\" death test style was introduced in order to help mitigate the\nrisks of testing in a possibly multithreaded environment. It trades increased\ntest execution time (potentially dramatically so) for improved thread safety.\nWe suggest using the faster, default \"fast\" style unless your test has specific\nproblems with it.\n\nYou can choose a particular style of death tests by setting the flag\nprogrammatically:\n\n```\n::testing::FLAGS_gtest_death_test_style = \"threadsafe\";\n```\n\nYou can do this in `main()` to set the style for all death tests in the\nbinary, or in individual tests. Recall that flags are saved before running each\ntest and restored afterwards, so you need not do that yourself. For example:\n\n```\nTEST(MyDeathTest, TestOne) {\n  ::testing::FLAGS_gtest_death_test_style = \"threadsafe\";\n  // This test is run in the \"threadsafe\" style:\n  ASSERT_DEATH(ThisShouldDie(), \"\");\n}\n\nTEST(MyDeathTest, TestTwo) {\n  // This test is run in the \"fast\" style:\n  ASSERT_DEATH(ThisShouldDie(), \"\");\n}\n\nint main(int argc, char** argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n  ::testing::FLAGS_gtest_death_test_style = \"fast\";\n  return RUN_ALL_TESTS();\n}\n```\n\n## Caveats ##\n\nThe _statement_ argument of `ASSERT_EXIT()` can be any valid C++ statement.\nIf it leaves the current function via a `return` statement or by throwing an exception,\nthe death test is considered to have failed.  Some Google Test macros may return\nfrom the current function (e.g. `ASSERT_TRUE()`), so be sure to avoid them in _statement_.\n\nSince _statement_ runs in the child process, any in-memory side effect (e.g.\nmodifying a variable, releasing memory, etc) it causes will _not_ be observable\nin the parent process. In particular, if you release memory in a death test,\nyour program will fail the heap check as the parent process will never see the\nmemory reclaimed. To solve this problem, you can\n\n  1. try not to free memory in a death test;\n  1. free the memory again in the parent process; or\n  1. do not use the heap checker in your program.\n\nDue to an implementation detail, you cannot place multiple death test\nassertions on the same line; otherwise, compilation will fail with an unobvious\nerror message.\n\nDespite the improved thread safety afforded by the \"threadsafe\" style of death\ntest, thread problems such as deadlock are still possible in the presence of\nhandlers registered with `pthread_atfork(3)`.\n\n# Using Assertions in Sub-routines #\n\n## Adding Traces to Assertions ##\n\nIf a test sub-routine is called from several places, when an assertion\ninside it fails, it can be hard to tell which invocation of the\nsub-routine the failure is from.  You can alleviate this problem using\nextra logging or custom failure messages, but that usually clutters up\nyour tests. A better solution is to use the `SCOPED_TRACE` macro:\n\n| `SCOPED_TRACE(`_message_`);` |\n|:-----------------------------|\n\nwhere _message_ can be anything streamable to `std::ostream`. This\nmacro will cause the current file name, line number, and the given\nmessage to be added in every failure message. The effect will be\nundone when the control leaves the current lexical scope.\n\nFor example,\n\n```\n10: void Sub1(int n) {\n11:   EXPECT_EQ(1, Bar(n));\n12:   EXPECT_EQ(2, Bar(n + 1));\n13: }\n14:\n15: TEST(FooTest, Bar) {\n16:   {\n17:     SCOPED_TRACE(\"A\");  // This trace point will be included in\n18:                         // every failure in this scope.\n19:     Sub1(1);\n20:   }\n21:   // Now it won't.\n22:   Sub1(9);\n23: }\n```\n\ncould result in messages like these:\n\n```\npath/to/foo_test.cc:11: Failure\nValue of: Bar(n)\nExpected: 1\n  Actual: 2\n   Trace:\npath/to/foo_test.cc:17: A\n\npath/to/foo_test.cc:12: Failure\nValue of: Bar(n + 1)\nExpected: 2\n  Actual: 3\n```\n\nWithout the trace, it would've been difficult to know which invocation\nof `Sub1()` the two failures come from respectively. (You could add an\nextra message to each assertion in `Sub1()` to indicate the value of\n`n`, but that's tedious.)\n\nSome tips on using `SCOPED_TRACE`:\n\n  1. With a suitable message, it's often enough to use `SCOPED_TRACE` at the beginning of a sub-routine, instead of at each call site.\n  1. When calling sub-routines inside a loop, make the loop iterator part of the message in `SCOPED_TRACE` such that you can know which iteration the failure is from.\n  1. Sometimes the line number of the trace point is enough for identifying the particular invocation of a sub-routine. In this case, you don't have to choose a unique message for `SCOPED_TRACE`. You can simply use `\"\"`.\n  1. You can use `SCOPED_TRACE` in an inner scope when there is one in the outer scope. In this case, all active trace points will be included in the failure messages, in reverse order they are encountered.\n  1. The trace dump is clickable in Emacs' compilation buffer - hit return on a line number and you'll be taken to that line in the source file!\n\n_Availability:_ Linux, Windows, Mac.\n\n## Propagating Fatal Failures ##\n\nA common pitfall when using `ASSERT_*` and `FAIL*` is not understanding that\nwhen they fail they only abort the _current function_, not the entire test. For\nexample, the following test will segfault:\n```\nvoid Subroutine() {\n  // Generates a fatal failure and aborts the current function.\n  ASSERT_EQ(1, 2);\n  // The following won't be executed.\n  ...\n}\n\nTEST(FooTest, Bar) {\n  Subroutine();\n  // The intended behavior is for the fatal failure\n  // in Subroutine() to abort the entire test.\n  // The actual behavior: the function goes on after Subroutine() returns.\n  int* p = NULL;\n  *p = 3; // Segfault!\n}\n```\n\nSince we don't use exceptions, it is technically impossible to\nimplement the intended behavior here.  To alleviate this, Google Test\nprovides two solutions.  You could use either the\n`(ASSERT|EXPECT)_NO_FATAL_FAILURE` assertions or the\n`HasFatalFailure()` function.  They are described in the following two\nsubsections.\n\n### Asserting on Subroutines ###\n\nAs shown above, if your test calls a subroutine that has an `ASSERT_*`\nfailure in it, the test will continue after the subroutine\nreturns. This may not be what you want.\n\nOften people want fatal failures to propagate like exceptions.  For\nthat Google Test offers the following macros:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_NO_FATAL_FAILURE(`_statement_`);` | `EXPECT_NO_FATAL_FAILURE(`_statement_`);` | _statement_ doesn't generate any new fatal failures in the current thread. |\n\nOnly failures in the thread that executes the assertion are checked to\ndetermine the result of this type of assertions.  If _statement_\ncreates new threads, failures in these threads are ignored.\n\nExamples:\n\n```\nASSERT_NO_FATAL_FAILURE(Foo());\n\nint i;\nEXPECT_NO_FATAL_FAILURE({\n  i = Bar();\n});\n```\n\n_Availability:_ Linux, Windows, Mac. Assertions from multiple threads\nare currently not supported.\n\n### Checking for Failures in the Current Test ###\n\n`HasFatalFailure()` in the `::testing::Test` class returns `true` if an\nassertion in the current test has suffered a fatal failure. This\nallows functions to catch fatal failures in a sub-routine and return\nearly.\n\n```\nclass Test {\n public:\n  ...\n  static bool HasFatalFailure();\n};\n```\n\nThe typical usage, which basically simulates the behavior of a thrown\nexception, is:\n\n```\nTEST(FooTest, Bar) {\n  Subroutine();\n  // Aborts if Subroutine() had a fatal failure.\n  if (HasFatalFailure())\n    return;\n  // The following won't be executed.\n  ...\n}\n```\n\nIf `HasFatalFailure()` is used outside of `TEST()` , `TEST_F()` , or a test\nfixture, you must add the `::testing::Test::` prefix, as in:\n\n```\nif (::testing::Test::HasFatalFailure())\n  return;\n```\n\nSimilarly, `HasNonfatalFailure()` returns `true` if the current test\nhas at least one non-fatal failure, and `HasFailure()` returns `true`\nif the current test has at least one failure of either kind.\n\n_Availability:_ Linux, Windows, Mac.  `HasNonfatalFailure()` and\n`HasFailure()` are available since version 1.4.0.\n\n# Logging Additional Information #\n\nIn your test code, you can call `RecordProperty(\"key\", value)` to log\nadditional information, where `value` can be either a C string or a 32-bit\ninteger. The _last_ value recorded for a key will be emitted to the XML output\nif you specify one. For example, the test\n\n```\nTEST_F(WidgetUsageTest, MinAndMaxWidgets) {\n  RecordProperty(\"MaximumWidgets\", ComputeMaxUsage());\n  RecordProperty(\"MinimumWidgets\", ComputeMinUsage());\n}\n```\n\nwill output XML like this:\n\n```\n...\n  <testcase name=\"MinAndMaxWidgets\" status=\"run\" time=\"6\" classname=\"WidgetUsageTest\"\n            MaximumWidgets=\"12\"\n            MinimumWidgets=\"9\" />\n...\n```\n\n_Note_:\n  * `RecordProperty()` is a static member of the `Test` class. Therefore it needs to be prefixed with `::testing::Test::` if used outside of the `TEST` body and the test fixture class.\n  * `key` must be a valid XML attribute name, and cannot conflict with the ones already used by Google Test (`name`, `status`,     `time`, and `classname`).\n\n_Availability_: Linux, Windows, Mac.\n\n# Sharing Resources Between Tests in the Same Test Case #\n\n\n\nGoogle Test creates a new test fixture object for each test in order to make\ntests independent and easier to debug. However, sometimes tests use resources\nthat are expensive to set up, making the one-copy-per-test model prohibitively\nexpensive.\n\nIf the tests don't change the resource, there's no harm in them sharing a\nsingle resource copy. So, in addition to per-test set-up/tear-down, Google Test\nalso supports per-test-case set-up/tear-down. To use it:\n\n  1. In your test fixture class (say `FooTest` ), define as `static` some member variables to hold the shared resources.\n  1. In the same test fixture class, define a `static void SetUpTestCase()` function (remember not to spell it as **`SetupTestCase`** with a small `u`!) to set up the shared resources and a `static void TearDownTestCase()` function to tear them down.\n\nThat's it! Google Test automatically calls `SetUpTestCase()` before running the\n_first test_ in the `FooTest` test case (i.e. before creating the first\n`FooTest` object), and calls `TearDownTestCase()` after running the _last test_\nin it (i.e. after deleting the last `FooTest` object). In between, the tests\ncan use the shared resources.\n\nRemember that the test order is undefined, so your code can't depend on a test\npreceding or following another. Also, the tests must either not modify the\nstate of any shared resource, or, if they do modify the state, they must\nrestore the state to its original value before passing control to the next\ntest.\n\nHere's an example of per-test-case set-up and tear-down:\n```\nclass FooTest : public ::testing::Test {\n protected:\n  // Per-test-case set-up.\n  // Called before the first test in this test case.\n  // Can be omitted if not needed.\n  static void SetUpTestCase() {\n    shared_resource_ = new ...;\n  }\n\n  // Per-test-case tear-down.\n  // Called after the last test in this test case.\n  // Can be omitted if not needed.\n  static void TearDownTestCase() {\n    delete shared_resource_;\n    shared_resource_ = NULL;\n  }\n\n  // You can define per-test set-up and tear-down logic as usual.\n  virtual void SetUp() { ... }\n  virtual void TearDown() { ... }\n\n  // Some expensive resource shared by all tests.\n  static T* shared_resource_;\n};\n\nT* FooTest::shared_resource_ = NULL;\n\nTEST_F(FooTest, Test1) {\n  ... you can refer to shared_resource here ...\n}\nTEST_F(FooTest, Test2) {\n  ... you can refer to shared_resource here ...\n}\n```\n\n_Availability:_ Linux, Windows, Mac.\n\n# Global Set-Up and Tear-Down #\n\nJust as you can do set-up and tear-down at the test level and the test case\nlevel, you can also do it at the test program level. Here's how.\n\nFirst, you subclass the `::testing::Environment` class to define a test\nenvironment, which knows how to set-up and tear-down:\n\n```\nclass Environment {\n public:\n  virtual ~Environment() {}\n  // Override this to define how to set up the environment.\n  virtual void SetUp() {}\n  // Override this to define how to tear down the environment.\n  virtual void TearDown() {}\n};\n```\n\nThen, you register an instance of your environment class with Google Test by\ncalling the `::testing::AddGlobalTestEnvironment()` function:\n\n```\nEnvironment* AddGlobalTestEnvironment(Environment* env);\n```\n\nNow, when `RUN_ALL_TESTS()` is called, it first calls the `SetUp()` method of\nthe environment object, then runs the tests if there was no fatal failures, and\nfinally calls `TearDown()` of the environment object.\n\nIt's OK to register multiple environment objects. In this case, their `SetUp()`\nwill be called in the order they are registered, and their `TearDown()` will be\ncalled in the reverse order.\n\nNote that Google Test takes ownership of the registered environment objects.\nTherefore **do not delete them** by yourself.\n\nYou should call `AddGlobalTestEnvironment()` before `RUN_ALL_TESTS()` is\ncalled, probably in `main()`. If you use `gtest_main`, you need to      call\nthis before `main()` starts for it to take effect. One way to do this is to\ndefine a global variable like this:\n\n```\n::testing::Environment* const foo_env = ::testing::AddGlobalTestEnvironment(new FooEnvironment);\n```\n\nHowever, we strongly recommend you to write your own `main()` and call\n`AddGlobalTestEnvironment()` there, as relying on initialization of global\nvariables makes the code harder to read and may cause problems when you\nregister multiple environments from different translation units and the\nenvironments have dependencies among them (remember that the compiler doesn't\nguarantee the order in which global variables from different translation units\nare initialized).\n\n_Availability:_ Linux, Windows, Mac.\n\n\n# Value Parameterized Tests #\n\n_Value-parameterized tests_ allow you to test your code with different\nparameters without writing multiple copies of the same test.\n\nSuppose you write a test for your code and then realize that your code is affected by a presence of a Boolean command line flag.\n\n```\nTEST(MyCodeTest, TestFoo) {\n  // A code to test foo().\n}\n```\n\nUsually people factor their test code into a function with a Boolean parameter in such situations. The function sets the flag, then executes the testing code.\n\n```\nvoid TestFooHelper(bool flag_value) {\n  flag = flag_value;\n  // A code to test foo().\n}\n\nTEST(MyCodeTest, TestFooo) {\n  TestFooHelper(false);\n  TestFooHelper(true);\n}\n```\n\nBut this setup has serious drawbacks. First, when a test assertion fails in your tests, it becomes unclear what value of the parameter caused it to fail. You can stream a clarifying message into your `EXPECT`/`ASSERT` statements, but it you'll have to do it with all of them. Second, you have to add one such helper function per test. What if you have ten tests? Twenty? A hundred?\n\nValue-parameterized tests will let you write your test only once and then easily instantiate and run it with an arbitrary number of parameter values.\n\nHere are some other situations when value-parameterized tests come handy:\n\n  * You want to test different implementations of an OO interface.\n  * You want to test your code over various inputs (a.k.a. data-driven testing). This feature is easy to abuse, so please exercise your good sense when doing it!\n\n## How to Write Value-Parameterized Tests ##\n\nTo write value-parameterized tests, first you should define a fixture\nclass.  It must be derived from both `::testing::Test` and\n`::testing::WithParamInterface<T>` (the latter is a pure interface),\nwhere `T` is the type of your parameter values.  For convenience, you\ncan just derive the fixture class from `::testing::TestWithParam<T>`,\nwhich itself is derived from both `::testing::Test` and\n`::testing::WithParamInterface<T>`. `T` can be any copyable type. If\nit's a raw pointer, you are responsible for managing the lifespan of\nthe pointed values.\n\n```\nclass FooTest : public ::testing::TestWithParam<const char*> {\n  // You can implement all the usual fixture class members here.\n  // To access the test parameter, call GetParam() from class\n  // TestWithParam<T>.\n};\n\n// Or, when you want to add parameters to a pre-existing fixture class:\nclass BaseTest : public ::testing::Test {\n  ...\n};\nclass BarTest : public BaseTest,\n                public ::testing::WithParamInterface<const char*> {\n  ...\n};\n```\n\nThen, use the `TEST_P` macro to define as many test patterns using\nthis fixture as you want.  The `_P` suffix is for \"parameterized\" or\n\"pattern\", whichever you prefer to think.\n\n```\nTEST_P(FooTest, DoesBlah) {\n  // Inside a test, access the test parameter with the GetParam() method\n  // of the TestWithParam<T> class:\n  EXPECT_TRUE(foo.Blah(GetParam()));\n  ...\n}\n\nTEST_P(FooTest, HasBlahBlah) {\n  ...\n}\n```\n\nFinally, you can use `INSTANTIATE_TEST_CASE_P` to instantiate the test\ncase with any set of parameters you want. Google Test defines a number of\nfunctions for generating test parameters. They return what we call\n(surprise!) _parameter generators_. Here is a summary of them,\nwhich are all in the `testing` namespace:\n\n| `Range(begin, end[, step])` | Yields values `{begin, begin+step, begin+step+step, ...}`. The values do not include `end`. `step` defaults to 1. |\n|:----------------------------|:------------------------------------------------------------------------------------------------------------------|\n| `Values(v1, v2, ..., vN)`   | Yields values `{v1, v2, ..., vN}`.                                                                                |\n| `ValuesIn(container)` and `ValuesIn(begin, end)` | Yields values from a C-style array, an STL-style container, or an iterator range `[begin, end)`. `container`, `begin`, and `end` can be expressions whose values are determined at run time.  |\n| `Bool()`                    | Yields sequence `{false, true}`.                                                                                  |\n| `Combine(g1, g2, ..., gN)`  | Yields all combinations (the Cartesian product for the math savvy) of the values generated by the `N` generators. This is only available if your system provides the `<tr1/tuple>` header. If you are sure your system does, and Google Test disagrees, you can override it by defining `GTEST_HAS_TR1_TUPLE=1`. See comments in [include/gtest/internal/gtest-port.h](../include/gtest/internal/gtest-port.h) for more information. |\n\nFor more details, see the comments at the definitions of these functions in the [source code](../include/gtest/gtest-param-test.h).\n\nThe following statement will instantiate tests from the `FooTest` test case\neach with parameter values `\"meeny\"`, `\"miny\"`, and `\"moe\"`.\n\n```\nINSTANTIATE_TEST_CASE_P(InstantiationName,\n                        FooTest,\n                        ::testing::Values(\"meeny\", \"miny\", \"moe\"));\n```\n\nTo distinguish different instances of the pattern (yes, you can\ninstantiate it more than once), the first argument to\n`INSTANTIATE_TEST_CASE_P` is a prefix that will be added to the actual\ntest case name. Remember to pick unique prefixes for different\ninstantiations. The tests from the instantiation above will have these\nnames:\n\n  * `InstantiationName/FooTest.DoesBlah/0` for `\"meeny\"`\n  * `InstantiationName/FooTest.DoesBlah/1` for `\"miny\"`\n  * `InstantiationName/FooTest.DoesBlah/2` for `\"moe\"`\n  * `InstantiationName/FooTest.HasBlahBlah/0` for `\"meeny\"`\n  * `InstantiationName/FooTest.HasBlahBlah/1` for `\"miny\"`\n  * `InstantiationName/FooTest.HasBlahBlah/2` for `\"moe\"`\n\nYou can use these names in [--gtest\\-filter](#running-a-subset-of-the-tests).\n\nThis statement will instantiate all tests from `FooTest` again, each\nwith parameter values `\"cat\"` and `\"dog\"`:\n\n```\nconst char* pets[] = {\"cat\", \"dog\"};\nINSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest,\n                        ::testing::ValuesIn(pets));\n```\n\nThe tests from the instantiation above will have these names:\n\n  * `AnotherInstantiationName/FooTest.DoesBlah/0` for `\"cat\"`\n  * `AnotherInstantiationName/FooTest.DoesBlah/1` for `\"dog\"`\n  * `AnotherInstantiationName/FooTest.HasBlahBlah/0` for `\"cat\"`\n  * `AnotherInstantiationName/FooTest.HasBlahBlah/1` for `\"dog\"`\n\nPlease note that `INSTANTIATE_TEST_CASE_P` will instantiate _all_\ntests in the given test case, whether their definitions come before or\n_after_ the `INSTANTIATE_TEST_CASE_P` statement.\n\nYou can see\n[these](../samples/sample7_unittest.cc)\n[files](../samples/sample8_unittest.cc) for more examples.\n\n_Availability_: Linux, Windows (requires MSVC 8.0 or above), Mac; since version 1.2.0.\n\n## Creating Value-Parameterized Abstract Tests ##\n\nIn the above, we define and instantiate `FooTest` in the same source\nfile. Sometimes you may want to define value-parameterized tests in a\nlibrary and let other people instantiate them later. This pattern is\nknown as <i>abstract tests</i>. As an example of its application, when you\nare designing an interface you can write a standard suite of abstract\ntests (perhaps using a factory function as the test parameter) that\nall implementations of the interface are expected to pass. When\nsomeone implements the interface, he can instantiate your suite to get\nall the interface-conformance tests for free.\n\nTo define abstract tests, you should organize your code like this:\n\n  1. Put the definition of the parameterized test fixture class (e.g. `FooTest`) in a header file, say `foo_param_test.h`. Think of this as _declaring_ your abstract tests.\n  1. Put the `TEST_P` definitions in `foo_param_test.cc`, which includes `foo_param_test.h`. Think of this as _implementing_ your abstract tests.\n\nOnce they are defined, you can instantiate them by including\n`foo_param_test.h`, invoking `INSTANTIATE_TEST_CASE_P()`, and linking\nwith `foo_param_test.cc`. You can instantiate the same abstract test\ncase multiple times, possibly in different source files.\n\n# Typed Tests #\n\nSuppose you have multiple implementations of the same interface and\nwant to make sure that all of them satisfy some common requirements.\nOr, you may have defined several types that are supposed to conform to\nthe same \"concept\" and you want to verify it.  In both cases, you want\nthe same test logic repeated for different types.\n\nWhile you can write one `TEST` or `TEST_F` for each type you want to\ntest (and you may even factor the test logic into a function template\nthat you invoke from the `TEST`), it's tedious and doesn't scale:\nif you want _m_ tests over _n_ types, you'll end up writing _m\\*n_\n`TEST`s.\n\n_Typed tests_ allow you to repeat the same test logic over a list of\ntypes.  You only need to write the test logic once, although you must\nknow the type list when writing typed tests.  Here's how you do it:\n\nFirst, define a fixture class template.  It should be parameterized\nby a type.  Remember to derive it from `::testing::Test`:\n\n```\ntemplate <typename T>\nclass FooTest : public ::testing::Test {\n public:\n  ...\n  typedef std::list<T> List;\n  static T shared_;\n  T value_;\n};\n```\n\nNext, associate a list of types with the test case, which will be\nrepeated for each type in the list:\n\n```\ntypedef ::testing::Types<char, int, unsigned int> MyTypes;\nTYPED_TEST_CASE(FooTest, MyTypes);\n```\n\nThe `typedef` is necessary for the `TYPED_TEST_CASE` macro to parse\ncorrectly.  Otherwise the compiler will think that each comma in the\ntype list introduces a new macro argument.\n\nThen, use `TYPED_TEST()` instead of `TEST_F()` to define a typed test\nfor this test case.  You can repeat this as many times as you want:\n\n```\nTYPED_TEST(FooTest, DoesBlah) {\n  // Inside a test, refer to the special name TypeParam to get the type\n  // parameter.  Since we are inside a derived class template, C++ requires\n  // us to visit the members of FooTest via 'this'.\n  TypeParam n = this->value_;\n\n  // To visit static members of the fixture, add the 'TestFixture::'\n  // prefix.\n  n += TestFixture::shared_;\n\n  // To refer to typedefs in the fixture, add the 'typename TestFixture::'\n  // prefix.  The 'typename' is required to satisfy the compiler.\n  typename TestFixture::List values;\n  values.push_back(n);\n  ...\n}\n\nTYPED_TEST(FooTest, HasPropertyA) { ... }\n```\n\nYou can see `samples/sample6_unittest.cc` for a complete example.\n\n_Availability:_ Linux, Windows (requires MSVC 8.0 or above), Mac;\nsince version 1.1.0.\n\n# Type-Parameterized Tests #\n\n_Type-parameterized tests_ are like typed tests, except that they\ndon't require you to know the list of types ahead of time.  Instead,\nyou can define the test logic first and instantiate it with different\ntype lists later.  You can even instantiate it more than once in the\nsame program.\n\nIf you are designing an interface or concept, you can define a suite\nof type-parameterized tests to verify properties that any valid\nimplementation of the interface/concept should have.  Then, the author\nof each implementation can just instantiate the test suite with his\ntype to verify that it conforms to the requirements, without having to\nwrite similar tests repeatedly.  Here's an example:\n\nFirst, define a fixture class template, as we did with typed tests:\n\n```\ntemplate <typename T>\nclass FooTest : public ::testing::Test {\n  ...\n};\n```\n\nNext, declare that you will define a type-parameterized test case:\n\n```\nTYPED_TEST_CASE_P(FooTest);\n```\n\nThe `_P` suffix is for \"parameterized\" or \"pattern\", whichever you\nprefer to think.\n\nThen, use `TYPED_TEST_P()` to define a type-parameterized test.  You\ncan repeat this as many times as you want:\n\n```\nTYPED_TEST_P(FooTest, DoesBlah) {\n  // Inside a test, refer to TypeParam to get the type parameter.\n  TypeParam n = 0;\n  ...\n}\n\nTYPED_TEST_P(FooTest, HasPropertyA) { ... }\n```\n\nNow the tricky part: you need to register all test patterns using the\n`REGISTER_TYPED_TEST_CASE_P` macro before you can instantiate them.\nThe first argument of the macro is the test case name; the rest are\nthe names of the tests in this test case:\n\n```\nREGISTER_TYPED_TEST_CASE_P(FooTest,\n                           DoesBlah, HasPropertyA);\n```\n\nFinally, you are free to instantiate the pattern with the types you\nwant.  If you put the above code in a header file, you can `#include`\nit in multiple C++ source files and instantiate it multiple times.\n\n```\ntypedef ::testing::Types<char, int, unsigned int> MyTypes;\nINSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);\n```\n\nTo distinguish different instances of the pattern, the first argument\nto the `INSTANTIATE_TYPED_TEST_CASE_P` macro is a prefix that will be\nadded to the actual test case name.  Remember to pick unique prefixes\nfor different instances.\n\nIn the special case where the type list contains only one type, you\ncan write that type directly without `::testing::Types<...>`, like this:\n\n```\nINSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int);\n```\n\nYou can see `samples/sample6_unittest.cc` for a complete example.\n\n_Availability:_ Linux, Windows (requires MSVC 8.0 or above), Mac;\nsince version 1.1.0.\n\n# Testing Private Code #\n\nIf you change your software's internal implementation, your tests should not\nbreak as long as the change is not observable by users. Therefore, per the\n_black-box testing principle_, most of the time you should test your code\nthrough its public interfaces.\n\nIf you still find yourself needing to test internal implementation code,\nconsider if there's a better design that wouldn't require you to do so. If you\nabsolutely have to test non-public interface code though, you can. There are\ntwo cases to consider:\n\n  * Static functions (_not_ the same as static member functions!) or unnamed namespaces, and\n  * Private or protected class members\n\n## Static Functions ##\n\nBoth static functions and definitions/declarations in an unnamed namespace are\nonly visible within the same translation unit. To test them, you can `#include`\nthe entire `.cc` file being tested in your `*_test.cc` file. (`#include`ing `.cc`\nfiles is not a good way to reuse code - you should not do this in production\ncode!)\n\nHowever, a better approach is to move the private code into the\n`foo::internal` namespace, where `foo` is the namespace your project normally\nuses, and put the private declarations in a `*-internal.h` file. Your\nproduction `.cc` files and your tests are allowed to include this internal\nheader, but your clients are not. This way, you can fully test your internal\nimplementation without leaking it to your clients.\n\n## Private Class Members ##\n\nPrivate class members are only accessible from within the class or by friends.\nTo access a class' private members, you can declare your test fixture as a\nfriend to the class and define accessors in your fixture. Tests using the\nfixture can then access the private members of your production class via the\naccessors in the fixture. Note that even though your fixture is a friend to\nyour production class, your tests are not automatically friends to it, as they\nare technically defined in sub-classes of the fixture.\n\nAnother way to test private members is to refactor them into an implementation\nclass, which is then declared in a `*-internal.h` file. Your clients aren't\nallowed to include this header but your tests can. Such is called the Pimpl\n(Private Implementation) idiom.\n\nOr, you can declare an individual test as a friend of your class by adding this\nline in the class body:\n\n```\nFRIEND_TEST(TestCaseName, TestName);\n```\n\nFor example,\n```\n// foo.h\n#include \"gtest/gtest_prod.h\"\n\n// Defines FRIEND_TEST.\nclass Foo {\n  ...\n private:\n  FRIEND_TEST(FooTest, BarReturnsZeroOnNull);\n  int Bar(void* x);\n};\n\n// foo_test.cc\n...\nTEST(FooTest, BarReturnsZeroOnNull) {\n  Foo foo;\n  EXPECT_EQ(0, foo.Bar(NULL));\n  // Uses Foo's private member Bar().\n}\n```\n\nPay special attention when your class is defined in a namespace, as you should\ndefine your test fixtures and tests in the same namespace if you want them to\nbe friends of your class. For example, if the code to be tested looks like:\n\n```\nnamespace my_namespace {\n\nclass Foo {\n  friend class FooTest;\n  FRIEND_TEST(FooTest, Bar);\n  FRIEND_TEST(FooTest, Baz);\n  ...\n  definition of the class Foo\n  ...\n};\n\n}  // namespace my_namespace\n```\n\nYour test code should be something like:\n\n```\nnamespace my_namespace {\nclass FooTest : public ::testing::Test {\n protected:\n  ...\n};\n\nTEST_F(FooTest, Bar) { ... }\nTEST_F(FooTest, Baz) { ... }\n\n}  // namespace my_namespace\n```\n\n# Catching Failures #\n\nIf you are building a testing utility on top of Google Test, you'll\nwant to test your utility.  What framework would you use to test it?\nGoogle Test, of course.\n\nThe challenge is to verify that your testing utility reports failures\ncorrectly.  In frameworks that report a failure by throwing an\nexception, you could catch the exception and assert on it.  But Google\nTest doesn't use exceptions, so how do we test that a piece of code\ngenerates an expected failure?\n\n`\"gtest/gtest-spi.h\"` contains some constructs to do this.  After\n`#include`ing this header, you can use\n\n| `EXPECT_FATAL_FAILURE(`_statement, substring_`);` |\n|:--------------------------------------------------|\n\nto assert that _statement_ generates a fatal (e.g. `ASSERT_*`) failure\nwhose message contains the given _substring_, or use\n\n| `EXPECT_NONFATAL_FAILURE(`_statement, substring_`);` |\n|:-----------------------------------------------------|\n\nif you are expecting a non-fatal (e.g. `EXPECT_*`) failure.\n\nFor technical reasons, there are some caveats:\n\n  1. You cannot stream a failure message to either macro.\n  1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot reference local non-static variables or non-static members of `this` object.\n  1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot return a value.\n\n_Note:_ Google Test is designed with threads in mind.  Once the\nsynchronization primitives in `\"gtest/internal/gtest-port.h\"` have\nbeen implemented, Google Test will become thread-safe, meaning that\nyou can then use assertions in multiple threads concurrently.  Before\n\nthat, however, Google Test only supports single-threaded usage.  Once\nthread-safe, `EXPECT_FATAL_FAILURE()` and `EXPECT_NONFATAL_FAILURE()`\nwill capture failures in the current thread only. If _statement_\ncreates new threads, failures in these threads will be ignored.  If\nyou want to capture failures from all threads instead, you should use\nthe following macros:\n\n| `EXPECT_FATAL_FAILURE_ON_ALL_THREADS(`_statement, substring_`);` |\n|:-----------------------------------------------------------------|\n| `EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(`_statement, substring_`);` |\n\n# Getting the Current Test's Name #\n\nSometimes a function may need to know the name of the currently running test.\nFor example, you may be using the `SetUp()` method of your test fixture to set\nthe golden file name based on which test is running. The `::testing::TestInfo`\nclass has this information:\n\n```\nnamespace testing {\n\nclass TestInfo {\n public:\n  // Returns the test case name and the test name, respectively.\n  //\n  // Do NOT delete or free the return value - it's managed by the\n  // TestInfo class.\n  const char* test_case_name() const;\n  const char* name() const;\n};\n\n}  // namespace testing\n```\n\n\n> To obtain a `TestInfo` object for the currently running test, call\n`current_test_info()` on the `UnitTest` singleton object:\n\n```\n// Gets information about the currently running test.\n// Do NOT delete the returned object - it's managed by the UnitTest class.\nconst ::testing::TestInfo* const test_info =\n  ::testing::UnitTest::GetInstance()->current_test_info();\nprintf(\"We are in test %s of test case %s.\\n\",\n       test_info->name(), test_info->test_case_name());\n```\n\n`current_test_info()` returns a null pointer if no test is running. In\nparticular, you cannot find the test case name in `TestCaseSetUp()`,\n`TestCaseTearDown()` (where you know the test case name implicitly), or\nfunctions called from them.\n\n_Availability:_ Linux, Windows, Mac.\n\n# Extending Google Test by Handling Test Events #\n\nGoogle Test provides an <b>event listener API</b> to let you receive\nnotifications about the progress of a test program and test\nfailures. The events you can listen to include the start and end of\nthe test program, a test case, or a test method, among others. You may\nuse this API to augment or replace the standard console output,\nreplace the XML output, or provide a completely different form of\noutput, such as a GUI or a database. You can also use test events as\ncheckpoints to implement a resource leak checker, for example.\n\n_Availability:_ Linux, Windows, Mac; since v1.4.0.\n\n## Defining Event Listeners ##\n\nTo define a event listener, you subclass either\n[testing::TestEventListener](../include/gtest/gtest.h#L855)\nor [testing::EmptyTestEventListener](../include/gtest/gtest.h#L905).\nThe former is an (abstract) interface, where <i>each pure virtual method<br>\ncan be overridden to handle a test event</i> (For example, when a test\nstarts, the `OnTestStart()` method will be called.). The latter provides\nan empty implementation of all methods in the interface, such that a\nsubclass only needs to override the methods it cares about.\n\nWhen an event is fired, its context is passed to the handler function\nas an argument. The following argument types are used:\n  * [UnitTest](../include/gtest/gtest.h#L1007) reflects the state of the entire test program,\n  * [TestCase](../include/gtest/gtest.h#L689) has information about a test case, which can contain one or more tests,\n  * [TestInfo](../include/gtest/gtest.h#L599) contains the state of a test, and\n  * [TestPartResult](../include/gtest/gtest-test-part.h#L42) represents the result of a test assertion.\n\nAn event handler function can examine the argument it receives to find\nout interesting information about the event and the test program's\nstate.  Here's an example:\n\n```\n  class MinimalistPrinter : public ::testing::EmptyTestEventListener {\n    // Called before a test starts.\n    virtual void OnTestStart(const ::testing::TestInfo& test_info) {\n      printf(\"*** Test %s.%s starting.\\n\",\n             test_info.test_case_name(), test_info.name());\n    }\n\n    // Called after a failed assertion or a SUCCEED() invocation.\n    virtual void OnTestPartResult(\n        const ::testing::TestPartResult& test_part_result) {\n      printf(\"%s in %s:%d\\n%s\\n\",\n             test_part_result.failed() ? \"*** Failure\" : \"Success\",\n             test_part_result.file_name(),\n             test_part_result.line_number(),\n             test_part_result.summary());\n    }\n\n    // Called after a test ends.\n    virtual void OnTestEnd(const ::testing::TestInfo& test_info) {\n      printf(\"*** Test %s.%s ending.\\n\",\n             test_info.test_case_name(), test_info.name());\n    }\n  };\n```\n\n## Using Event Listeners ##\n\nTo use the event listener you have defined, add an instance of it to\nthe Google Test event listener list (represented by class\n[TestEventListeners](../include/gtest/gtest.h#L929)\n- note the \"s\" at the end of the name) in your\n`main()` function, before calling `RUN_ALL_TESTS()`:\n```\nint main(int argc, char** argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n  // Gets hold of the event listener list.\n  ::testing::TestEventListeners& listeners =\n      ::testing::UnitTest::GetInstance()->listeners();\n  // Adds a listener to the end.  Google Test takes the ownership.\n  listeners.Append(new MinimalistPrinter);\n  return RUN_ALL_TESTS();\n}\n```\n\nThere's only one problem: the default test result printer is still in\neffect, so its output will mingle with the output from your minimalist\nprinter. To suppress the default printer, just release it from the\nevent listener list and delete it. You can do so by adding one line:\n```\n  ...\n  delete listeners.Release(listeners.default_result_printer());\n  listeners.Append(new MinimalistPrinter);\n  return RUN_ALL_TESTS();\n```\n\nNow, sit back and enjoy a completely different output from your\ntests. For more details, you can read this\n[sample](../samples/sample9_unittest.cc).\n\nYou may append more than one listener to the list. When an `On*Start()`\nor `OnTestPartResult()` event is fired, the listeners will receive it in\nthe order they appear in the list (since new listeners are added to\nthe end of the list, the default text printer and the default XML\ngenerator will receive the event first). An `On*End()` event will be\nreceived by the listeners in the _reverse_ order. This allows output by\nlisteners added later to be framed by output from listeners added\nearlier.\n\n## Generating Failures in Listeners ##\n\nYou may use failure-raising macros (`EXPECT_*()`, `ASSERT_*()`,\n`FAIL()`, etc) when processing an event. There are some restrictions:\n\n  1. You cannot generate any failure in `OnTestPartResult()` (otherwise it will cause `OnTestPartResult()` to be called recursively).\n  1. A listener that handles `OnTestPartResult()` is not allowed to generate any failure.\n\nWhen you add listeners to the listener list, you should put listeners\nthat handle `OnTestPartResult()` _before_ listeners that can generate\nfailures. This ensures that failures generated by the latter are\nattributed to the right test by the former.\n\nWe have a sample of failure-raising listener\n[here](../samples/sample10_unittest.cc).\n\n# Running Test Programs: Advanced Options #\n\nGoogle Test test programs are ordinary executables. Once built, you can run\nthem directly and affect their behavior via the following environment variables\nand/or command line flags. For the flags to work, your programs must call\n`::testing::InitGoogleTest()` before calling `RUN_ALL_TESTS()`.\n\nTo see a list of supported flags and their usage, please run your test\nprogram with the `--help` flag.  You can also use `-h`, `-?`, or `/?`\nfor short.  This feature is added in version 1.3.0.\n\nIf an option is specified both by an environment variable and by a\nflag, the latter takes precedence.  Most of the options can also be\nset/read in code: to access the value of command line flag\n`--gtest_foo`, write `::testing::GTEST_FLAG(foo)`.  A common pattern is\nto set the value of a flag before calling `::testing::InitGoogleTest()`\nto change the default value of the flag:\n```\nint main(int argc, char** argv) {\n  // Disables elapsed time by default.\n  ::testing::GTEST_FLAG(print_time) = false;\n\n  // This allows the user to override the flag on the command line.\n  ::testing::InitGoogleTest(&argc, argv);\n\n  return RUN_ALL_TESTS();\n}\n```\n\n## Selecting Tests ##\n\nThis section shows various options for choosing which tests to run.\n\n### Listing Test Names ###\n\nSometimes it is necessary to list the available tests in a program before\nrunning them so that a filter may be applied if needed. Including the flag\n`--gtest_list_tests` overrides all other flags and lists tests in the following\nformat:\n```\nTestCase1.\n  TestName1\n  TestName2\nTestCase2.\n  TestName\n```\n\nNone of the tests listed are actually run if the flag is provided. There is no\ncorresponding environment variable for this flag.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Running a Subset of the Tests ###\n\nBy default, a Google Test program runs all tests the user has defined.\nSometimes, you want to run only a subset of the tests (e.g. for debugging or\nquickly verifying a change). If you set the `GTEST_FILTER` environment variable\nor the `--gtest_filter` flag to a filter string, Google Test will only run the\ntests whose full names (in the form of `TestCaseName.TestName`) match the\nfilter.\n\nThe format of a filter is a '`:`'-separated list of wildcard patterns (called\nthe positive patterns) optionally followed by a '`-`' and another\n'`:`'-separated pattern list (called the negative patterns). A test matches the\nfilter if and only if it matches any of the positive patterns but does not\nmatch any of the negative patterns.\n\nA pattern may contain `'*'` (matches any string) or `'?'` (matches any single\ncharacter). For convenience, the filter `'*-NegativePatterns'` can be also\nwritten as `'-NegativePatterns'`.\n\nFor example:\n\n  * `./foo_test` Has no flag, and thus runs all its tests.\n  * `./foo_test --gtest_filter=*` Also runs everything, due to the single match-everything `*` value.\n  * `./foo_test --gtest_filter=FooTest.*` Runs everything in test case `FooTest`.\n  * `./foo_test --gtest_filter=*Null*:*Constructor*` Runs any test whose full name contains either `\"Null\"` or `\"Constructor\"`.\n  * `./foo_test --gtest_filter=-*DeathTest.*` Runs all non-death tests.\n  * `./foo_test --gtest_filter=FooTest.*-FooTest.Bar` Runs everything in test case `FooTest` except `FooTest.Bar`.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Temporarily Disabling Tests ###\n\nIf you have a broken test that you cannot fix right away, you can add the\n`DISABLED_` prefix to its name. This will exclude it from execution. This is\nbetter than commenting out the code or using `#if 0`, as disabled tests are\nstill compiled (and thus won't rot).\n\nIf you need to disable all tests in a test case, you can either add `DISABLED_`\nto the front of the name of each test, or alternatively add it to the front of\nthe test case name.\n\nFor example, the following tests won't be run by Google Test, even though they\nwill still be compiled:\n\n```\n// Tests that Foo does Abc.\nTEST(FooTest, DISABLED_DoesAbc) { ... }\n\nclass DISABLED_BarTest : public ::testing::Test { ... };\n\n// Tests that Bar does Xyz.\nTEST_F(DISABLED_BarTest, DoesXyz) { ... }\n```\n\n_Note:_ This feature should only be used for temporary pain-relief. You still\nhave to fix the disabled tests at a later date. As a reminder, Google Test will\nprint a banner warning you if a test program contains any disabled tests.\n\n_Tip:_ You can easily count the number of disabled tests you have\nusing `grep`. This number can be used as a metric for improving your\ntest quality.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Temporarily Enabling Disabled Tests ###\n\nTo include [disabled tests](#temporarily-disabling-tests) in test\nexecution, just invoke the test program with the\n`--gtest_also_run_disabled_tests` flag or set the\n`GTEST_ALSO_RUN_DISABLED_TESTS` environment variable to a value other\nthan `0`.  You can combine this with the\n[--gtest\\-filter](#running-a-subset-of-the_tests) flag to further select\nwhich disabled tests to run.\n\n_Availability:_ Linux, Windows, Mac; since version 1.3.0.\n\n## Repeating the Tests ##\n\nOnce in a while you'll run into a test whose result is hit-or-miss. Perhaps it\nwill fail only 1% of the time, making it rather hard to reproduce the bug under\na debugger. This can be a major source of frustration.\n\nThe `--gtest_repeat` flag allows you to repeat all (or selected) test methods\nin a program many times. Hopefully, a flaky test will eventually fail and give\nyou a chance to debug. Here's how to use it:\n\n| `$ foo_test --gtest_repeat=1000` | Repeat foo\\_test 1000 times and don't stop at failures. |\n|:---------------------------------|:--------------------------------------------------------|\n| `$ foo_test --gtest_repeat=-1`   | A negative count means repeating forever.               |\n| `$ foo_test --gtest_repeat=1000 --gtest_break_on_failure` | Repeat foo\\_test 1000 times, stopping at the first failure. This is especially useful when running under a debugger: when the testfails, it will drop into the debugger and you can then inspect variables and stacks. |\n| `$ foo_test --gtest_repeat=1000 --gtest_filter=FooBar` | Repeat the tests whose name matches the filter 1000 times. |\n\nIf your test program contains global set-up/tear-down code registered\nusing `AddGlobalTestEnvironment()`, it will be repeated in each\niteration as well, as the flakiness may be in it. You can also specify\nthe repeat count by setting the `GTEST_REPEAT` environment variable.\n\n_Availability:_ Linux, Windows, Mac.\n\n## Shuffling the Tests ##\n\nYou can specify the `--gtest_shuffle` flag (or set the `GTEST_SHUFFLE`\nenvironment variable to `1`) to run the tests in a program in a random\norder. This helps to reveal bad dependencies between tests.\n\nBy default, Google Test uses a random seed calculated from the current\ntime. Therefore you'll get a different order every time. The console\noutput includes the random seed value, such that you can reproduce an\norder-related test failure later. To specify the random seed\nexplicitly, use the `--gtest_random_seed=SEED` flag (or set the\n`GTEST_RANDOM_SEED` environment variable), where `SEED` is an integer\nbetween 0 and 99999. The seed value 0 is special: it tells Google Test\nto do the default behavior of calculating the seed from the current\ntime.\n\nIf you combine this with `--gtest_repeat=N`, Google Test will pick a\ndifferent random seed and re-shuffle the tests in each iteration.\n\n_Availability:_ Linux, Windows, Mac; since v1.4.0.\n\n## Controlling Test Output ##\n\nThis section teaches how to tweak the way test results are reported.\n\n### Colored Terminal Output ###\n\nGoogle Test can use colors in its terminal output to make it easier to spot\nthe separation between tests, and whether tests passed.\n\nYou can set the GTEST\\_COLOR environment variable or set the `--gtest_color`\ncommand line flag to `yes`, `no`, or `auto` (the default) to enable colors,\ndisable colors, or let Google Test decide. When the value is `auto`, Google\nTest will use colors if and only if the output goes to a terminal and (on\nnon-Windows platforms) the `TERM` environment variable is set to `xterm` or\n`xterm-color`.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Suppressing the Elapsed Time ###\n\nBy default, Google Test prints the time it takes to run each test.  To\nsuppress that, run the test program with the `--gtest_print_time=0`\ncommand line flag.  Setting the `GTEST_PRINT_TIME` environment\nvariable to `0` has the same effect.\n\n_Availability:_ Linux, Windows, Mac.  (In Google Test 1.3.0 and lower,\nthe default behavior is that the elapsed time is **not** printed.)\n\n### Generating an XML Report ###\n\nGoogle Test can emit a detailed XML report to a file in addition to its normal\ntextual output. The report contains the duration of each test, and thus can\nhelp you identify slow tests.\n\nTo generate the XML report, set the `GTEST_OUTPUT` environment variable or the\n`--gtest_output` flag to the string `\"xml:_path_to_output_file_\"`, which will\ncreate the file at the given location. You can also just use the string\n`\"xml\"`, in which case the output can be found in the `test_detail.xml` file in\nthe current directory.\n\nIf you specify a directory (for example, `\"xml:output/directory/\"` on Linux or\n`\"xml:output\\directory\\\"` on Windows), Google Test will create the XML file in\nthat directory, named after the test executable (e.g. `foo_test.xml` for test\nprogram `foo_test` or `foo_test.exe`). If the file already exists (perhaps left\nover from a previous run), Google Test will pick a different name (e.g.\n`foo_test_1.xml`) to avoid overwriting it.\n\nThe report uses the format described here.  It is based on the\n`junitreport` Ant task and can be parsed by popular continuous build\nsystems like [Hudson](https://hudson.dev.java.net/). Since that format\nwas originally intended for Java, a little interpretation is required\nto make it apply to Google Test tests, as shown here:\n\n```\n<testsuites name=\"AllTests\" ...>\n  <testsuite name=\"test_case_name\" ...>\n    <testcase name=\"test_name\" ...>\n      <failure message=\"...\"/>\n      <failure message=\"...\"/>\n      <failure message=\"...\"/>\n    </testcase>\n  </testsuite>\n</testsuites>\n```\n\n  * The root `<testsuites>` element corresponds to the entire test program.\n  * `<testsuite>` elements correspond to Google Test test cases.\n  * `<testcase>` elements correspond to Google Test test functions.\n\nFor instance, the following program\n\n```\nTEST(MathTest, Addition) { ... }\nTEST(MathTest, Subtraction) { ... }\nTEST(LogicTest, NonContradiction) { ... }\n```\n\ncould generate this report:\n\n```\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites tests=\"3\" failures=\"1\" errors=\"0\" time=\"35\" name=\"AllTests\">\n  <testsuite name=\"MathTest\" tests=\"2\" failures=\"1\" errors=\"0\" time=\"15\">\n    <testcase name=\"Addition\" status=\"run\" time=\"7\" classname=\"\">\n      <failure message=\"Value of: add(1, 1)&#x0A; Actual: 3&#x0A;Expected: 2\" type=\"\"/>\n      <failure message=\"Value of: add(1, -1)&#x0A; Actual: 1&#x0A;Expected: 0\" type=\"\"/>\n    </testcase>\n    <testcase name=\"Subtraction\" status=\"run\" time=\"5\" classname=\"\">\n    </testcase>\n  </testsuite>\n  <testsuite name=\"LogicTest\" tests=\"1\" failures=\"0\" errors=\"0\" time=\"5\">\n    <testcase name=\"NonContradiction\" status=\"run\" time=\"5\" classname=\"\">\n    </testcase>\n  </testsuite>\n</testsuites>\n```\n\nThings to note:\n\n  * The `tests` attribute of a `<testsuites>` or `<testsuite>` element tells how many test functions the Google Test program or test case contains, while the `failures` attribute tells how many of them failed.\n  * The `time` attribute expresses the duration of the test, test case, or entire test program in milliseconds.\n  * Each `<failure>` element corresponds to a single failed Google Test assertion.\n  * Some JUnit concepts don't apply to Google Test, yet we have to conform to the DTD. Therefore you'll see some dummy elements and attributes in the report. You can safely ignore these parts.\n\n_Availability:_ Linux, Windows, Mac.\n\n## Controlling How Failures Are Reported ##\n\n### Turning Assertion Failures into Break-Points ###\n\nWhen running test programs under a debugger, it's very convenient if the\ndebugger can catch an assertion failure and automatically drop into interactive\nmode. Google Test's _break-on-failure_ mode supports this behavior.\n\nTo enable it, set the `GTEST_BREAK_ON_FAILURE` environment variable to a value\nother than `0` . Alternatively, you can use the `--gtest_break_on_failure`\ncommand line flag.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Disabling Catching Test-Thrown Exceptions ###\n\nGoogle Test can be used either with or without exceptions enabled.  If\na test throws a C++ exception or (on Windows) a structured exception\n(SEH), by default Google Test catches it, reports it as a test\nfailure, and continues with the next test method.  This maximizes the\ncoverage of a test run.  Also, on Windows an uncaught exception will\ncause a pop-up window, so catching the exceptions allows you to run\nthe tests automatically.\n\nWhen debugging the test failures, however, you may instead want the\nexceptions to be handled by the debugger, such that you can examine\nthe call stack when an exception is thrown.  To achieve that, set the\n`GTEST_CATCH_EXCEPTIONS` environment variable to `0`, or use the\n`--gtest_catch_exceptions=0` flag when running the tests.\n\n**Availability**: Linux, Windows, Mac.\n\n### Letting Another Testing Framework Drive ###\n\nIf you work on a project that has already been using another testing\nframework and is not ready to completely switch to Google Test yet,\nyou can get much of Google Test's benefit by using its assertions in\nyour existing tests.  Just change your `main()` function to look\nlike:\n\n```\n#include \"gtest/gtest.h\"\n\nint main(int argc, char** argv) {\n  ::testing::GTEST_FLAG(throw_on_failure) = true;\n  // Important: Google Test must be initialized.\n  ::testing::InitGoogleTest(&argc, argv);\n\n  ... whatever your existing testing framework requires ...\n}\n```\n\nWith that, you can use Google Test assertions in addition to the\nnative assertions your testing framework provides, for example:\n\n```\nvoid TestFooDoesBar() {\n  Foo foo;\n  EXPECT_LE(foo.Bar(1), 100);     // A Google Test assertion.\n  CPPUNIT_ASSERT(foo.IsEmpty());  // A native assertion.\n}\n```\n\nIf a Google Test assertion fails, it will print an error message and\nthrow an exception, which will be treated as a failure by your host\ntesting framework.  If you compile your code with exceptions disabled,\na failed Google Test assertion will instead exit your program with a\nnon-zero code, which will also signal a test failure to your test\nrunner.\n\nIf you don't write `::testing::GTEST_FLAG(throw_on_failure) = true;` in\nyour `main()`, you can alternatively enable this feature by specifying\nthe `--gtest_throw_on_failure` flag on the command-line or setting the\n`GTEST_THROW_ON_FAILURE` environment variable to a non-zero value.\n\n_Availability:_ Linux, Windows, Mac; since v1.3.0.\n\n## Distributing Test Functions to Multiple Machines ##\n\nIf you have more than one machine you can use to run a test program,\nyou might want to run the test functions in parallel and get the\nresult faster.  We call this technique _sharding_, where each machine\nis called a _shard_.\n\nGoogle Test is compatible with test sharding.  To take advantage of\nthis feature, your test runner (not part of Google Test) needs to do\nthe following:\n\n  1. Allocate a number of machines (shards) to run the tests.\n  1. On each shard, set the `GTEST_TOTAL_SHARDS` environment variable to the total number of shards.  It must be the same for all shards.\n  1. On each shard, set the `GTEST_SHARD_INDEX` environment variable to the index of the shard.  Different shards must be assigned different indices, which must be in the range `[0, GTEST_TOTAL_SHARDS - 1]`.\n  1. Run the same test program on all shards.  When Google Test sees the above two environment variables, it will select a subset of the test functions to run.  Across all shards, each test function in the program will be run exactly once.\n  1. Wait for all shards to finish, then collect and report the results.\n\nYour project may have tests that were written without Google Test and\nthus don't understand this protocol.  In order for your test runner to\nfigure out which test supports sharding, it can set the environment\nvariable `GTEST_SHARD_STATUS_FILE` to a non-existent file path.  If a\ntest program supports sharding, it will create this file to\nacknowledge the fact (the actual contents of the file are not\nimportant at this time; although we may stick some useful information\nin it in the future.); otherwise it will not create it.\n\nHere's an example to make it clear.  Suppose you have a test program\n`foo_test` that contains the following 5 test functions:\n```\nTEST(A, V)\nTEST(A, W)\nTEST(B, X)\nTEST(B, Y)\nTEST(B, Z)\n```\nand you have 3 machines at your disposal.  To run the test functions in\nparallel, you would set `GTEST_TOTAL_SHARDS` to 3 on all machines, and\nset `GTEST_SHARD_INDEX` to 0, 1, and 2 on the machines respectively.\nThen you would run the same `foo_test` on each machine.\n\nGoogle Test reserves the right to change how the work is distributed\nacross the shards, but here's one possible scenario:\n\n  * Machine #0 runs `A.V` and `B.X`.\n  * Machine #1 runs `A.W` and `B.Y`.\n  * Machine #2 runs `B.Z`.\n\n_Availability:_ Linux, Windows, Mac; since version 1.3.0.\n\n# Fusing Google Test Source Files #\n\nGoogle Test's implementation consists of ~30 files (excluding its own\ntests).  Sometimes you may want them to be packaged up in two files (a\n`.h` and a `.cc`) instead, such that you can easily copy them to a new\nmachine and start hacking there.  For this we provide an experimental\nPython script `fuse_gtest_files.py` in the `scripts/` directory (since release 1.3.0).\nAssuming you have Python 2.4 or above installed on your machine, just\ngo to that directory and run\n```\npython fuse_gtest_files.py OUTPUT_DIR\n```\n\nand you should see an `OUTPUT_DIR` directory being created with files\n`gtest/gtest.h` and `gtest/gtest-all.cc` in it.  These files contain\neverything you need to use Google Test.  Just copy them to anywhere\nyou want and you are ready to write tests.  You can use the\n[scripts/test/Makefile](../scripts/test/Makefile)\nfile as an example on how to compile your tests against them.\n\n# Where to Go from Here #\n\nCongratulations! You've now learned more advanced Google Test tools and are\nready to tackle more complex testing tasks. If you want to dive even deeper, you\ncan read the [Frequently-Asked Questions](V1_6_FAQ.md).\n"
  },
  {
    "path": "utils/googletest/googletest/docs/V1_6_Documentation.md",
    "content": "This page lists all documentation wiki pages for Google Test **1.6**\n-- **if you use a released version of Google Test, please read the\ndocumentation for that specific version instead.**\n\n  * [Primer](V1_6_Primer.md) -- start here if you are new to Google Test.\n  * [Samples](V1_6_Samples.md) -- learn from examples.\n  * [AdvancedGuide](V1_6_AdvancedGuide.md) -- learn more about Google Test.\n  * [XcodeGuide](V1_6_XcodeGuide.md) -- how to use Google Test in Xcode on Mac.\n  * [Frequently-Asked Questions](V1_6_FAQ.md) -- check here before asking a question on the mailing list.\n\nTo contribute code to Google Test, read:\n\n  * [DevGuide](DevGuide.md) -- read this _before_ writing your first patch.\n  * [PumpManual](V1_6_PumpManual.md) -- how we generate some of Google Test's source files."
  },
  {
    "path": "utils/googletest/googletest/docs/V1_6_FAQ.md",
    "content": "\n\nIf you cannot find the answer to your question here, and you have read\n[Primer](V1_6_Primer.md) and [AdvancedGuide](V1_6_AdvancedGuide.md), send it to\ngoogletestframework@googlegroups.com.\n\n## Why should I use Google Test instead of my favorite C++ testing framework? ##\n\nFirst, let us say clearly that we don't want to get into the debate of\nwhich C++ testing framework is **the best**.  There exist many fine\nframeworks for writing C++ tests, and we have tremendous respect for\nthe developers and users of them.  We don't think there is (or will\nbe) a single best framework - you have to pick the right tool for the\nparticular task you are tackling.\n\nWe created Google Test because we couldn't find the right combination\nof features and conveniences in an existing framework to satisfy _our_\nneeds.  The following is a list of things that _we_ like about Google\nTest.  We don't claim them to be unique to Google Test - rather, the\ncombination of them makes Google Test the choice for us.  We hope this\nlist can help you decide whether it is for you too.\n\n  * Google Test is designed to be portable: it doesn't require exceptions or RTTI; it works around various bugs in various compilers and environments; etc.  As a result, it works on Linux, Mac OS X, Windows and several embedded operating systems.\n  * Nonfatal assertions (`EXPECT_*`) have proven to be great time savers, as they allow a test to report multiple failures in a single edit-compile-test cycle.\n  * It's easy to write assertions that generate informative messages: you just use the stream syntax to append any additional information, e.g. `ASSERT_EQ(5, Foo(i)) << \" where i = \" << i;`.  It doesn't require a new set of macros or special functions.\n  * Google Test automatically detects your tests and doesn't require you to enumerate them in order to run them.\n  * Death tests are pretty handy for ensuring that your asserts in production code are triggered by the right conditions.\n  * `SCOPED_TRACE` helps you understand the context of an assertion failure when it comes from inside a sub-routine or loop.\n  * You can decide which tests to run using name patterns.  This saves time when you want to quickly reproduce a test failure.\n  * Google Test can generate XML test result reports that can be parsed by popular continuous build system like Hudson.\n  * Simple things are easy in Google Test, while hard things are possible: in addition to advanced features like [global test environments](V1_6_AdvancedGuide.md#Global_Set-Up_and_Tear-Down) and tests parameterized by [values](V1_6_AdvancedGuide.md#value-parameterized-tests) or [types](V1_6_AdvancedGuide.md#typed-tests), Google Test supports various ways for the user to extend the framework -- if Google Test doesn't do something out of the box, chances are that a user can implement the feature using Google Test's public API, without changing Google Test itself.  In particular, you can:\n    * expand your testing vocabulary by defining [custom predicates](V1_6_AdvancedGuide.md#predicate-assertions-for-better-error-messages),\n    * teach Google Test how to [print your types](V1_6_AdvancedGuide.md#teaching-google-test-how-to-print-your-values),\n    * define your own testing macros or utilities and verify them using Google Test's [Service Provider Interface](V1_6_AdvancedGuide.md#catching-failures), and\n    * reflect on the test cases or change the test output format by intercepting the [test events](V1_6_AdvancedGuide.md#extending-google-test-by-handling-test-events).\n\n## I'm getting warnings when compiling Google Test.  Would you fix them? ##\n\nWe strive to minimize compiler warnings Google Test generates.  Before releasing a new version, we test to make sure that it doesn't generate warnings when compiled using its CMake script on Windows, Linux, and Mac OS.\n\nUnfortunately, this doesn't mean you are guaranteed to see no warnings when compiling Google Test in your environment:\n\n  * You may be using a different compiler as we use, or a different version of the same compiler.  We cannot possibly test for all compilers.\n  * You may be compiling on a different platform as we do.\n  * Your project may be using different compiler flags as we do.\n\nIt is not always possible to make Google Test warning-free for everyone.  Or, it may not be desirable if the warning is rarely enabled and fixing the violations makes the code more complex.\n\nIf you see warnings when compiling Google Test, we suggest that you use the `-isystem` flag (assuming your are using GCC) to mark Google Test headers as system headers.  That'll suppress warnings from Google Test headers.\n\n## Why should not test case names and test names contain underscore? ##\n\nUnderscore (`_`) is special, as C++ reserves the following to be used by\nthe compiler and the standard library:\n\n  1. any identifier that starts with an `_` followed by an upper-case letter, and\n  1. any identifier that containers two consecutive underscores (i.e. `__`) _anywhere_ in its name.\n\nUser code is _prohibited_ from using such identifiers.\n\nNow let's look at what this means for `TEST` and `TEST_F`.\n\nCurrently `TEST(TestCaseName, TestName)` generates a class named\n`TestCaseName_TestName_Test`.  What happens if `TestCaseName` or `TestName`\ncontains `_`?\n\n  1. If `TestCaseName` starts with an `_` followed by an upper-case letter (say, `_Foo`), we end up with `_Foo_TestName_Test`, which is reserved and thus invalid.\n  1. If `TestCaseName` ends with an `_` (say, `Foo_`), we get `Foo__TestName_Test`, which is invalid.\n  1. If `TestName` starts with an `_` (say, `_Bar`), we get `TestCaseName__Bar_Test`, which is invalid.\n  1. If `TestName` ends with an `_` (say, `Bar_`), we get `TestCaseName_Bar__Test`, which is invalid.\n\nSo clearly `TestCaseName` and `TestName` cannot start or end with `_`\n(Actually, `TestCaseName` can start with `_` -- as long as the `_` isn't\nfollowed by an upper-case letter.  But that's getting complicated.  So\nfor simplicity we just say that it cannot start with `_`.).\n\nIt may seem fine for `TestCaseName` and `TestName` to contain `_` in the\nmiddle.  However, consider this:\n```\nTEST(Time, Flies_Like_An_Arrow) { ... }\nTEST(Time_Flies, Like_An_Arrow) { ... }\n```\n\nNow, the two `TEST`s will both generate the same class\n(`Time_Files_Like_An_Arrow_Test`).  That's not good.\n\nSo for simplicity, we just ask the users to avoid `_` in `TestCaseName`\nand `TestName`.  The rule is more constraining than necessary, but it's\nsimple and easy to remember.  It also gives Google Test some wiggle\nroom in case its implementation needs to change in the future.\n\nIf you violate the rule, there may not be immediately consequences,\nbut your test may (just may) break with a new compiler (or a new\nversion of the compiler you are using) or with a new version of Google\nTest.  Therefore it's best to follow the rule.\n\n## Why is it not recommended to install a pre-compiled copy of Google Test (for example, into /usr/local)? ##\n\nIn the early days, we said that you could install\ncompiled Google Test libraries on `*`nix systems using `make install`.\nThen every user of your machine can write tests without\nrecompiling Google Test.\n\nThis seemed like a good idea, but it has a\ngot-cha: every user needs to compile his tests using the _same_ compiler\nflags used to compile the installed Google Test libraries; otherwise\nhe may run into undefined behaviors (i.e. the tests can behave\nstrangely and may even crash for no obvious reasons).\n\nWhy?  Because C++ has this thing called the One-Definition Rule: if\ntwo C++ source files contain different definitions of the same\nclass/function/variable, and you link them together, you violate the\nrule.  The linker may or may not catch the error (in many cases it's\nnot required by the C++ standard to catch the violation).  If it\ndoesn't, you get strange run-time behaviors that are unexpected and\nhard to debug.\n\nIf you compile Google Test and your test code using different compiler\nflags, they may see different definitions of the same\nclass/function/variable (e.g. due to the use of `#if` in Google Test).\nTherefore, for your sanity, we recommend to avoid installing pre-compiled\nGoogle Test libraries.  Instead, each project should compile\nGoogle Test itself such that it can be sure that the same flags are\nused for both Google Test and the tests.\n\n## How do I generate 64-bit binaries on Windows (using Visual Studio 2008)? ##\n\n(Answered by Trevor Robinson)\n\nLoad the supplied Visual Studio solution file, either `msvc\\gtest-md.sln` or\n`msvc\\gtest.sln`. Go through the migration wizard to migrate the\nsolution and project files to Visual Studio 2008. Select\n`Configuration Manager...` from the `Build` menu. Select `<New...>` from\nthe `Active solution platform` dropdown.  Select `x64` from the new\nplatform dropdown, leave `Copy settings from` set to `Win32` and\n`Create new project platforms` checked, then click `OK`. You now have\n`Win32` and `x64` platform configurations, selectable from the\n`Standard` toolbar, which allow you to toggle between building 32-bit or\n64-bit binaries (or both at once using Batch Build).\n\nIn order to prevent build output files from overwriting one another,\nyou'll need to change the `Intermediate Directory` settings for the\nnewly created platform configuration across all the projects. To do\nthis, multi-select (e.g. using shift-click) all projects (but not the\nsolution) in the `Solution Explorer`. Right-click one of them and\nselect `Properties`. In the left pane, select `Configuration Properties`,\nand from the `Configuration` dropdown, select `All Configurations`.\nMake sure the selected platform is `x64`. For the\n`Intermediate Directory` setting, change the value from\n`$(PlatformName)\\$(ConfigurationName)` to\n`$(OutDir)\\$(ProjectName)`. Click `OK` and then build the\nsolution. When the build is complete, the 64-bit binaries will be in\nthe `msvc\\x64\\Debug` directory.\n\n## Can I use Google Test on MinGW? ##\n\nWe haven't tested this ourselves, but Per Abrahamsen reported that he\nwas able to compile and install Google Test successfully when using\nMinGW from Cygwin.  You'll need to configure it with:\n\n`PATH/TO/configure CC=\"gcc -mno-cygwin\" CXX=\"g++ -mno-cygwin\"`\n\nYou should be able to replace the `-mno-cygwin` option with direct links\nto the real MinGW binaries, but we haven't tried that.\n\nCaveats:\n\n  * There are many warnings when compiling.\n  * `make check` will produce some errors as not all tests for Google Test itself are compatible with MinGW.\n\nWe also have reports on successful cross compilation of Google Test\nMinGW binaries on Linux using\n[these instructions](http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux#Cross-compiling_under_Linux_for_MS_Windows)\non the WxWidgets site.\n\nPlease contact `googletestframework@googlegroups.com` if you are\ninterested in improving the support for MinGW.\n\n## Why does Google Test support EXPECT\\_EQ(NULL, ptr) and ASSERT\\_EQ(NULL, ptr) but not EXPECT\\_NE(NULL, ptr) and ASSERT\\_NE(NULL, ptr)? ##\n\nDue to some peculiarity of C++, it requires some non-trivial template\nmeta programming tricks to support using `NULL` as an argument of the\n`EXPECT_XX()` and `ASSERT_XX()` macros. Therefore we only do it where\nit's most needed (otherwise we make the implementation of Google Test\nharder to maintain and more error-prone than necessary).\n\nThe `EXPECT_EQ()` macro takes the _expected_ value as its first\nargument and the _actual_ value as the second. It's reasonable that\nsomeone wants to write `EXPECT_EQ(NULL, some_expression)`, and this\nindeed was requested several times. Therefore we implemented it.\n\nThe need for `EXPECT_NE(NULL, ptr)` isn't nearly as strong. When the\nassertion fails, you already know that `ptr` must be `NULL`, so it\ndoesn't add any information to print ptr in this case. That means\n`EXPECT_TRUE(ptr ! NULL)` works just as well.\n\nIf we were to support `EXPECT_NE(NULL, ptr)`, for consistency we'll\nhave to support `EXPECT_NE(ptr, NULL)` as well, as unlike `EXPECT_EQ`,\nwe don't have a convention on the order of the two arguments for\n`EXPECT_NE`. This means using the template meta programming tricks\ntwice in the implementation, making it even harder to understand and\nmaintain. We believe the benefit doesn't justify the cost.\n\nFinally, with the growth of Google Mock's [matcher](../../CookBook.md#using-matchers-in-google-test-assertions) library, we are\nencouraging people to use the unified `EXPECT_THAT(value, matcher)`\nsyntax more often in tests. One significant advantage of the matcher\napproach is that matchers can be easily combined to form new matchers,\nwhile the `EXPECT_NE`, etc, macros cannot be easily\ncombined. Therefore we want to invest more in the matchers than in the\n`EXPECT_XX()` macros.\n\n## Does Google Test support running tests in parallel? ##\n\nTest runners tend to be tightly coupled with the build/test\nenvironment, and Google Test doesn't try to solve the problem of\nrunning tests in parallel.  Instead, we tried to make Google Test work\nnicely with test runners.  For example, Google Test's XML report\ncontains the time spent on each test, and its `gtest_list_tests` and\n`gtest_filter` flags can be used for splitting the execution of test\nmethods into multiple processes.  These functionalities can help the\ntest runner run the tests in parallel.\n\n## Why don't Google Test run the tests in different threads to speed things up? ##\n\nIt's difficult to write thread-safe code.  Most tests are not written\nwith thread-safety in mind, and thus may not work correctly in a\nmulti-threaded setting.\n\nIf you think about it, it's already hard to make your code work when\nyou know what other threads are doing.  It's much harder, and\nsometimes even impossible, to make your code work when you don't know\nwhat other threads are doing (remember that test methods can be added,\ndeleted, or modified after your test was written).  If you want to run\nthe tests in parallel, you'd better run them in different processes.\n\n## Why aren't Google Test assertions implemented using exceptions? ##\n\nOur original motivation was to be able to use Google Test in projects\nthat disable exceptions.  Later we realized some additional benefits\nof this approach:\n\n  1. Throwing in a destructor is undefined behavior in C++.  Not using exceptions means Google Test's assertions are safe to use in destructors.\n  1. The `EXPECT_*` family of macros will continue even after a failure, allowing multiple failures in a `TEST` to be reported in a single run. This is a popular feature, as in C++ the edit-compile-test cycle is usually quite long and being able to fixing more than one thing at a time is a blessing.\n  1. If assertions are implemented using exceptions, a test may falsely ignore a failure if it's caught by user code:\n```\ntry { ... ASSERT_TRUE(...) ... }\ncatch (...) { ... }\n```\nThe above code will pass even if the `ASSERT_TRUE` throws.  While it's unlikely for someone to write this in a test, it's possible to run into this pattern when you write assertions in callbacks that are called by the code under test.\n\nThe downside of not using exceptions is that `ASSERT_*` (implemented\nusing `return`) will only abort the current function, not the current\n`TEST`.\n\n## Why do we use two different macros for tests with and without fixtures? ##\n\nUnfortunately, C++'s macro system doesn't allow us to use the same\nmacro for both cases.  One possibility is to provide only one macro\nfor tests with fixtures, and require the user to define an empty\nfixture sometimes:\n\n```\nclass FooTest : public ::testing::Test {};\n\nTEST_F(FooTest, DoesThis) { ... }\n```\nor\n```\ntypedef ::testing::Test FooTest;\n\nTEST_F(FooTest, DoesThat) { ... }\n```\n\nYet, many people think this is one line too many. :-) Our goal was to\nmake it really easy to write tests, so we tried to make simple tests\ntrivial to create.  That means using a separate macro for such tests.\n\nWe think neither approach is ideal, yet either of them is reasonable.\nIn the end, it probably doesn't matter much either way.\n\n## Why don't we use structs as test fixtures? ##\n\nWe like to use structs only when representing passive data.  This\ndistinction between structs and classes is good for documenting the\nintent of the code's author.  Since test fixtures have logic like\n`SetUp()` and `TearDown()`, they are better defined as classes.\n\n## Why are death tests implemented as assertions instead of using a test runner? ##\n\nOur goal was to make death tests as convenient for a user as C++\npossibly allows.  In particular:\n\n  * The runner-style requires to split the information into two pieces: the definition of the death test itself, and the specification for the runner on how to run the death test and what to expect.  The death test would be written in C++, while the runner spec may or may not be.  A user needs to carefully keep the two in sync. `ASSERT_DEATH(statement, expected_message)` specifies all necessary information in one place, in one language, without boilerplate code. It is very declarative.\n  * `ASSERT_DEATH` has a similar syntax and error-reporting semantics as other Google Test assertions, and thus is easy to learn.\n  * `ASSERT_DEATH` can be mixed with other assertions and other logic at your will.  You are not limited to one death test per test method. For example, you can write something like:\n```\n    if (FooCondition()) {\n      ASSERT_DEATH(Bar(), \"blah\");\n    } else {\n      ASSERT_EQ(5, Bar());\n    }\n```\nIf you prefer one death test per test method, you can write your tests in that style too, but we don't want to impose that on the users.  The fewer artificial limitations the better.\n  * `ASSERT_DEATH` can reference local variables in the current function, and you can decide how many death tests you want based on run-time information.  For example,\n```\n    const int count = GetCount();  // Only known at run time.\n    for (int i = 1; i <= count; i++) {\n      ASSERT_DEATH({\n        double* buffer = new double[i];\n        ... initializes buffer ...\n        Foo(buffer, i)\n      }, \"blah blah\");\n    }\n```\nThe runner-based approach tends to be more static and less flexible, or requires more user effort to get this kind of flexibility.\n\nAnother interesting thing about `ASSERT_DEATH` is that it calls `fork()`\nto create a child process to run the death test.  This is lightening\nfast, as `fork()` uses copy-on-write pages and incurs almost zero\noverhead, and the child process starts from the user-supplied\nstatement directly, skipping all global and local initialization and\nany code leading to the given statement.  If you launch the child\nprocess from scratch, it can take seconds just to load everything and\nstart running if the test links to many libraries dynamically.\n\n## My death test modifies some state, but the change seems lost after the death test finishes. Why? ##\n\nDeath tests (`EXPECT_DEATH`, etc) are executed in a sub-process s.t. the\nexpected crash won't kill the test program (i.e. the parent process). As a\nresult, any in-memory side effects they incur are observable in their\nrespective sub-processes, but not in the parent process. You can think of them\nas running in a parallel universe, more or less.\n\n## The compiler complains about \"undefined references\" to some static const member variables, but I did define them in the class body. What's wrong? ##\n\nIf your class has a static data member:\n\n```\n// foo.h\nclass Foo {\n  ...\n  static const int kBar = 100;\n};\n```\n\nYou also need to define it _outside_ of the class body in `foo.cc`:\n\n```\nconst int Foo::kBar;  // No initializer here.\n```\n\nOtherwise your code is **invalid C++**, and may break in unexpected ways. In\nparticular, using it in Google Test comparison assertions (`EXPECT_EQ`, etc)\nwill generate an \"undefined reference\" linker error.\n\n## I have an interface that has several implementations. Can I write a set of tests once and repeat them over all the implementations? ##\n\nGoogle Test doesn't yet have good support for this kind of tests, or\ndata-driven tests in general. We hope to be able to make improvements in this\narea soon.\n\n## Can I derive a test fixture from another? ##\n\nYes.\n\nEach test fixture has a corresponding and same named test case. This means only\none test case can use a particular fixture. Sometimes, however, multiple test\ncases may want to use the same or slightly different fixtures. For example, you\nmay want to make sure that all of a GUI library's test cases don't leak\nimportant system resources like fonts and brushes.\n\nIn Google Test, you share a fixture among test cases by putting the shared\nlogic in a base test fixture, then deriving from that base a separate fixture\nfor each test case that wants to use this common logic. You then use `TEST_F()`\nto write tests using each derived fixture.\n\nTypically, your code looks like this:\n\n```\n// Defines a base test fixture.\nclass BaseTest : public ::testing::Test {\n  protected:\n   ...\n};\n\n// Derives a fixture FooTest from BaseTest.\nclass FooTest : public BaseTest {\n  protected:\n    virtual void SetUp() {\n      BaseTest::SetUp();  // Sets up the base fixture first.\n      ... additional set-up work ...\n    }\n    virtual void TearDown() {\n      ... clean-up work for FooTest ...\n      BaseTest::TearDown();  // Remember to tear down the base fixture\n                             // after cleaning up FooTest!\n    }\n    ... functions and variables for FooTest ...\n};\n\n// Tests that use the fixture FooTest.\nTEST_F(FooTest, Bar) { ... }\nTEST_F(FooTest, Baz) { ... }\n\n... additional fixtures derived from BaseTest ...\n```\n\nIf necessary, you can continue to derive test fixtures from a derived fixture.\nGoogle Test has no limit on how deep the hierarchy can be.\n\nFor a complete example using derived test fixtures, see\n[sample5](../samples/sample5_unittest.cc).\n\n## My compiler complains \"void value not ignored as it ought to be.\" What does this mean? ##\n\nYou're probably using an `ASSERT_*()` in a function that doesn't return `void`.\n`ASSERT_*()` can only be used in `void` functions.\n\n## My death test hangs (or seg-faults). How do I fix it? ##\n\nIn Google Test, death tests are run in a child process and the way they work is\ndelicate. To write death tests you really need to understand how they work.\nPlease make sure you have read this.\n\nIn particular, death tests don't like having multiple threads in the parent\nprocess. So the first thing you can try is to eliminate creating threads\noutside of `EXPECT_DEATH()`.\n\nSometimes this is impossible as some library you must use may be creating\nthreads before `main()` is even reached. In this case, you can try to minimize\nthe chance of conflicts by either moving as many activities as possible inside\n`EXPECT_DEATH()` (in the extreme case, you want to move everything inside), or\nleaving as few things as possible in it. Also, you can try to set the death\ntest style to `\"threadsafe\"`, which is safer but slower, and see if it helps.\n\nIf you go with thread-safe death tests, remember that they rerun the test\nprogram from the beginning in the child process. Therefore make sure your\nprogram can run side-by-side with itself and is deterministic.\n\nIn the end, this boils down to good concurrent programming. You have to make\nsure that there is no race conditions or dead locks in your program. No silver\nbullet - sorry!\n\n## Should I use the constructor/destructor of the test fixture or the set-up/tear-down function? ##\n\nThe first thing to remember is that Google Test does not reuse the\nsame test fixture object across multiple tests. For each `TEST_F`,\nGoogle Test will create a fresh test fixture object, _immediately_\ncall `SetUp()`, run the test, call `TearDown()`, and then\n_immediately_ delete the test fixture object. Therefore, there is no\nneed to write a `SetUp()` or `TearDown()` function if the constructor\nor destructor already does the job.\n\nYou may still want to use `SetUp()/TearDown()` in the following cases:\n  * If the tear-down operation could throw an exception, you must use `TearDown()` as opposed to the destructor, as throwing in a destructor leads to undefined behavior and usually will kill your program right away. Note that many standard libraries (like STL) may throw when exceptions are enabled in the compiler. Therefore you should prefer `TearDown()` if you want to write portable tests that work with or without exceptions.\n  * The Google Test team is considering making the assertion macros throw on platforms where exceptions are enabled (e.g. Windows, Mac OS, and Linux client-side), which will eliminate the need for the user to propagate failures from a subroutine to its caller. Therefore, you shouldn't use Google Test assertions in a destructor if your code could run on such a platform.\n  * In a constructor or destructor, you cannot make a virtual function call on this object. (You can call a method declared as virtual, but it will be statically bound.) Therefore, if you need to call a method that will be overriden in a derived class, you have to use `SetUp()/TearDown()`.\n\n## The compiler complains \"no matching function to call\" when I use ASSERT\\_PREDn. How do I fix it? ##\n\nIf the predicate function you use in `ASSERT_PRED*` or `EXPECT_PRED*` is\noverloaded or a template, the compiler will have trouble figuring out which\noverloaded version it should use. `ASSERT_PRED_FORMAT*` and\n`EXPECT_PRED_FORMAT*` don't have this problem.\n\nIf you see this error, you might want to switch to\n`(ASSERT|EXPECT)_PRED_FORMAT*`, which will also give you a better failure\nmessage. If, however, that is not an option, you can resolve the problem by\nexplicitly telling the compiler which version to pick.\n\nFor example, suppose you have\n\n```\nbool IsPositive(int n) {\n  return n > 0;\n}\nbool IsPositive(double x) {\n  return x > 0;\n}\n```\n\nyou will get a compiler error if you write\n\n```\nEXPECT_PRED1(IsPositive, 5);\n```\n\nHowever, this will work:\n\n```\nEXPECT_PRED1(*static_cast<bool (*)(int)>*(IsPositive), 5);\n```\n\n(The stuff inside the angled brackets for the `static_cast` operator is the\ntype of the function pointer for the `int`-version of `IsPositive()`.)\n\nAs another example, when you have a template function\n\n```\ntemplate <typename T>\nbool IsNegative(T x) {\n  return x < 0;\n}\n```\n\nyou can use it in a predicate assertion like this:\n\n```\nASSERT_PRED1(IsNegative*<int>*, -5);\n```\n\nThings are more interesting if your template has more than one parameters. The\nfollowing won't compile:\n\n```\nASSERT_PRED2(*GreaterThan<int, int>*, 5, 0);\n```\n\n\nas the C++ pre-processor thinks you are giving `ASSERT_PRED2` 4 arguments,\nwhich is one more than expected. The workaround is to wrap the predicate\nfunction in parentheses:\n\n```\nASSERT_PRED2(*(GreaterThan<int, int>)*, 5, 0);\n```\n\n\n## My compiler complains about \"ignoring return value\" when I call RUN\\_ALL\\_TESTS(). Why? ##\n\nSome people had been ignoring the return value of `RUN_ALL_TESTS()`. That is,\ninstead of\n\n```\nreturn RUN_ALL_TESTS();\n```\n\nthey write\n\n```\nRUN_ALL_TESTS();\n```\n\nThis is wrong and dangerous. A test runner needs to see the return value of\n`RUN_ALL_TESTS()` in order to determine if a test has passed. If your `main()`\nfunction ignores it, your test will be considered successful even if it has a\nGoogle Test assertion failure. Very bad.\n\nTo help the users avoid this dangerous bug, the implementation of\n`RUN_ALL_TESTS()` causes gcc to raise this warning, when the return value is\nignored. If you see this warning, the fix is simple: just make sure its value\nis used as the return value of `main()`.\n\n## My compiler complains that a constructor (or destructor) cannot return a value. What's going on? ##\n\nDue to a peculiarity of C++, in order to support the syntax for streaming\nmessages to an `ASSERT_*`, e.g.\n\n```\nASSERT_EQ(1, Foo()) << \"blah blah\" << foo;\n```\n\nwe had to give up using `ASSERT*` and `FAIL*` (but not `EXPECT*` and\n`ADD_FAILURE*`) in constructors and destructors. The workaround is to move the\ncontent of your constructor/destructor to a private void member function, or\nswitch to `EXPECT_*()` if that works. This section in the user's guide explains\nit.\n\n## My set-up function is not called. Why? ##\n\nC++ is case-sensitive. It should be spelled as `SetUp()`.  Did you\nspell it as `Setup()`?\n\nSimilarly, sometimes people spell `SetUpTestCase()` as `SetupTestCase()` and\nwonder why it's never called.\n\n## How do I jump to the line of a failure in Emacs directly? ##\n\nGoogle Test's failure message format is understood by Emacs and many other\nIDEs, like acme and XCode. If a Google Test message is in a compilation buffer\nin Emacs, then it's clickable. You can now hit `enter` on a message to jump to\nthe corresponding source code, or use `C-x `` to jump to the next failure.\n\n## I have several test cases which share the same test fixture logic, do I have to define a new test fixture class for each of them? This seems pretty tedious. ##\n\nYou don't have to. Instead of\n\n```\nclass FooTest : public BaseTest {};\n\nTEST_F(FooTest, Abc) { ... }\nTEST_F(FooTest, Def) { ... }\n\nclass BarTest : public BaseTest {};\n\nTEST_F(BarTest, Abc) { ... }\nTEST_F(BarTest, Def) { ... }\n```\n\nyou can simply `typedef` the test fixtures:\n```\ntypedef BaseTest FooTest;\n\nTEST_F(FooTest, Abc) { ... }\nTEST_F(FooTest, Def) { ... }\n\ntypedef BaseTest BarTest;\n\nTEST_F(BarTest, Abc) { ... }\nTEST_F(BarTest, Def) { ... }\n```\n\n## The Google Test output is buried in a whole bunch of log messages. What do I do? ##\n\nThe Google Test output is meant to be a concise and human-friendly report. If\nyour test generates textual output itself, it will mix with the Google Test\noutput, making it hard to read. However, there is an easy solution to this\nproblem.\n\nSince most log messages go to stderr, we decided to let Google Test output go\nto stdout. This way, you can easily separate the two using redirection. For\nexample:\n```\n./my_test > googletest_output.txt\n```\n\n## Why should I prefer test fixtures over global variables? ##\n\nThere are several good reasons:\n  1. It's likely your test needs to change the states of its global variables. This makes it difficult to keep side effects from escaping one test and contaminating others, making debugging difficult. By using fixtures, each test has a fresh set of variables that's different (but with the same names). Thus, tests are kept independent of each other.\n  1. Global variables pollute the global namespace.\n  1. Test fixtures can be reused via subclassing, which cannot be done easily with global variables. This is useful if many test cases have something in common.\n\n## How do I test private class members without writing FRIEND\\_TEST()s? ##\n\nYou should try to write testable code, which means classes should be easily\ntested from their public interface. One way to achieve this is the Pimpl idiom:\nyou move all private members of a class into a helper class, and make all\nmembers of the helper class public.\n\nYou have several other options that don't require using `FRIEND_TEST`:\n  * Write the tests as members of the fixture class:\n```\nclass Foo {\n  friend class FooTest;\n  ...\n};\n\nclass FooTest : public ::testing::Test {\n protected:\n  ...\n  void Test1() {...} // This accesses private members of class Foo.\n  void Test2() {...} // So does this one.\n};\n\nTEST_F(FooTest, Test1) {\n  Test1();\n}\n\nTEST_F(FooTest, Test2) {\n  Test2();\n}\n```\n  * In the fixture class, write accessors for the tested class' private members, then use the accessors in your tests:\n```\nclass Foo {\n  friend class FooTest;\n  ...\n};\n\nclass FooTest : public ::testing::Test {\n protected:\n  ...\n  T1 get_private_member1(Foo* obj) {\n    return obj->private_member1_;\n  }\n};\n\nTEST_F(FooTest, Test1) {\n  ...\n  get_private_member1(x)\n  ...\n}\n```\n  * If the methods are declared **protected**, you can change their access level in a test-only subclass:\n```\nclass YourClass {\n  ...\n protected: // protected access for testability.\n  int DoSomethingReturningInt();\n  ...\n};\n\n// in the your_class_test.cc file:\nclass TestableYourClass : public YourClass {\n  ...\n public: using YourClass::DoSomethingReturningInt; // changes access rights\n  ...\n};\n\nTEST_F(YourClassTest, DoSomethingTest) {\n  TestableYourClass obj;\n  assertEquals(expected_value, obj.DoSomethingReturningInt());\n}\n```\n\n## How do I test private class static members without writing FRIEND\\_TEST()s? ##\n\nWe find private static methods clutter the header file.  They are\nimplementation details and ideally should be kept out of a .h. So often I make\nthem free functions instead.\n\nInstead of:\n```\n// foo.h\nclass Foo {\n  ...\n private:\n  static bool Func(int n);\n};\n\n// foo.cc\nbool Foo::Func(int n) { ... }\n\n// foo_test.cc\nEXPECT_TRUE(Foo::Func(12345));\n```\n\nYou probably should better write:\n```\n// foo.h\nclass Foo {\n  ...\n};\n\n// foo.cc\nnamespace internal {\n  bool Func(int n) { ... }\n}\n\n// foo_test.cc\nnamespace internal {\n  bool Func(int n);\n}\n\nEXPECT_TRUE(internal::Func(12345));\n```\n\n## I would like to run a test several times with different parameters. Do I need to write several similar copies of it? ##\n\nNo. You can use a feature called [value-parameterized tests](V1_6_AdvancedGuide.md#Value_Parameterized_Tests) which\nlets you repeat your tests with different parameters, without defining it more than once.\n\n## How do I test a file that defines main()? ##\n\nTo test a `foo.cc` file, you need to compile and link it into your unit test\nprogram. However, when the file contains a definition for the `main()`\nfunction, it will clash with the `main()` of your unit test, and will result in\na build error.\n\nThe right solution is to split it into three files:\n  1. `foo.h` which contains the declarations,\n  1. `foo.cc` which contains the definitions except `main()`, and\n  1. `foo_main.cc` which contains nothing but the definition of `main()`.\n\nThen `foo.cc` can be easily tested.\n\nIf you are adding tests to an existing file and don't want an intrusive change\nlike this, there is a hack: just include the entire `foo.cc` file in your unit\ntest. For example:\n```\n// File foo_unittest.cc\n\n// The headers section\n...\n\n// Renames main() in foo.cc to make room for the unit test main()\n#define main FooMain\n\n#include \"a/b/foo.cc\"\n\n// The tests start here.\n...\n```\n\n\nHowever, please remember this is a hack and should only be used as the last\nresort.\n\n## What can the statement argument in ASSERT\\_DEATH() be? ##\n\n`ASSERT_DEATH(_statement_, _regex_)` (or any death assertion macro) can be used\nwherever `_statement_` is valid. So basically `_statement_` can be any C++\nstatement that makes sense in the current context. In particular, it can\nreference global and/or local variables, and can be:\n  * a simple function call (often the case),\n  * a complex expression, or\n  * a compound statement.\n\n> Some examples are shown here:\n\n```\n// A death test can be a simple function call.\nTEST(MyDeathTest, FunctionCall) {\n  ASSERT_DEATH(Xyz(5), \"Xyz failed\");\n}\n\n// Or a complex expression that references variables and functions.\nTEST(MyDeathTest, ComplexExpression) {\n  const bool c = Condition();\n  ASSERT_DEATH((c ? Func1(0) : object2.Method(\"test\")),\n               \"(Func1|Method) failed\");\n}\n\n// Death assertions can be used any where in a function. In\n// particular, they can be inside a loop.\nTEST(MyDeathTest, InsideLoop) {\n  // Verifies that Foo(0), Foo(1), ..., and Foo(4) all die.\n  for (int i = 0; i < 5; i++) {\n    EXPECT_DEATH_M(Foo(i), \"Foo has \\\\d+ errors\",\n                   ::testing::Message() << \"where i is \" << i);\n  }\n}\n\n// A death assertion can contain a compound statement.\nTEST(MyDeathTest, CompoundStatement) {\n  // Verifies that at lease one of Bar(0), Bar(1), ..., and\n  // Bar(4) dies.\n  ASSERT_DEATH({\n    for (int i = 0; i < 5; i++) {\n      Bar(i);\n    }\n  },\n  \"Bar has \\\\d+ errors\");}\n```\n\n`googletest_unittest.cc` contains more examples if you are interested.\n\n## What syntax does the regular expression in ASSERT\\_DEATH use? ##\n\nOn POSIX systems, Google Test uses the POSIX Extended regular\nexpression syntax\n(http://en.wikipedia.org/wiki/Regular_expression#POSIX_Extended_Regular_Expressions).\nOn Windows, it uses a limited variant of regular expression\nsyntax. For more details, see the\n[regular expression syntax](V1_6_AdvancedGuide.md#Regular_Expression_Syntax).\n\n## I have a fixture class Foo, but TEST\\_F(Foo, Bar) gives me error \"no matching function for call to Foo::Foo()\". Why? ##\n\nGoogle Test needs to be able to create objects of your test fixture class, so\nit must have a default constructor. Normally the compiler will define one for\nyou. However, there are cases where you have to define your own:\n  * If you explicitly declare a non-default constructor for class `Foo`, then you need to define a default constructor, even if it would be empty.\n  * If `Foo` has a const non-static data member, then you have to define the default constructor _and_ initialize the const member in the initializer list of the constructor. (Early versions of `gcc` doesn't force you to initialize the const member. It's a bug that has been fixed in `gcc 4`.)\n\n## Why does ASSERT\\_DEATH complain about previous threads that were already joined? ##\n\nWith the Linux pthread library, there is no turning back once you cross the\nline from single thread to multiple threads. The first time you create a\nthread, a manager thread is created in addition, so you get 3, not 2, threads.\nLater when the thread you create joins the main thread, the thread count\ndecrements by 1, but the manager thread will never be killed, so you still have\n2 threads, which means you cannot safely run a death test.\n\nThe new NPTL thread library doesn't suffer from this problem, as it doesn't\ncreate a manager thread. However, if you don't control which machine your test\nruns on, you shouldn't depend on this.\n\n## Why does Google Test require the entire test case, instead of individual tests, to be named FOODeathTest when it uses ASSERT\\_DEATH? ##\n\nGoogle Test does not interleave tests from different test cases. That is, it\nruns all tests in one test case first, and then runs all tests in the next test\ncase, and so on. Google Test does this because it needs to set up a test case\nbefore the first test in it is run, and tear it down afterwords. Splitting up\nthe test case would require multiple set-up and tear-down processes, which is\ninefficient and makes the semantics unclean.\n\nIf we were to determine the order of tests based on test name instead of test\ncase name, then we would have a problem with the following situation:\n\n```\nTEST_F(FooTest, AbcDeathTest) { ... }\nTEST_F(FooTest, Uvw) { ... }\n\nTEST_F(BarTest, DefDeathTest) { ... }\nTEST_F(BarTest, Xyz) { ... }\n```\n\nSince `FooTest.AbcDeathTest` needs to run before `BarTest.Xyz`, and we don't\ninterleave tests from different test cases, we need to run all tests in the\n`FooTest` case before running any test in the `BarTest` case. This contradicts\nwith the requirement to run `BarTest.DefDeathTest` before `FooTest.Uvw`.\n\n## But I don't like calling my entire test case FOODeathTest when it contains both death tests and non-death tests. What do I do? ##\n\nYou don't have to, but if you like, you may split up the test case into\n`FooTest` and `FooDeathTest`, where the names make it clear that they are\nrelated:\n\n```\nclass FooTest : public ::testing::Test { ... };\n\nTEST_F(FooTest, Abc) { ... }\nTEST_F(FooTest, Def) { ... }\n\ntypedef FooTest FooDeathTest;\n\nTEST_F(FooDeathTest, Uvw) { ... EXPECT_DEATH(...) ... }\nTEST_F(FooDeathTest, Xyz) { ... ASSERT_DEATH(...) ... }\n```\n\n## The compiler complains about \"no match for 'operator<<'\" when I use an assertion. What gives? ##\n\nIf you use a user-defined type `FooType` in an assertion, you must make sure\nthere is an `std::ostream& operator<<(std::ostream&, const FooType&)` function\ndefined such that we can print a value of `FooType`.\n\nIn addition, if `FooType` is declared in a name space, the `<<` operator also\nneeds to be defined in the _same_ name space.\n\n## How do I suppress the memory leak messages on Windows? ##\n\nSince the statically initialized Google Test singleton requires allocations on\nthe heap, the Visual C++ memory leak detector will report memory leaks at the\nend of the program run. The easiest way to avoid this is to use the\n`_CrtMemCheckpoint` and `_CrtMemDumpAllObjectsSince` calls to not report any\nstatically initialized heap objects. See MSDN for more details and additional\nheap check/debug routines.\n\n## I am building my project with Google Test in Visual Studio and all I'm getting is a bunch of linker errors (or warnings). Help! ##\n\nYou may get a number of the following linker error or warnings if you\nattempt to link your test project with the Google Test library when\nyour project and the are not built using the same compiler settings.\n\n  * LNK2005: symbol already defined in object\n  * LNK4217: locally defined symbol 'symbol' imported in function 'function'\n  * LNK4049: locally defined symbol 'symbol' imported\n\nThe Google Test project (gtest.vcproj) has the Runtime Library option\nset to /MT (use multi-threaded static libraries, /MTd for debug). If\nyour project uses something else, for example /MD (use multi-threaded\nDLLs, /MDd for debug), you need to change the setting in the Google\nTest project to match your project's.\n\nTo update this setting open the project properties in the Visual\nStudio IDE then select the branch Configuration Properties | C/C++ |\nCode Generation and change the option \"Runtime Library\".  You may also try\nusing gtest-md.vcproj instead of gtest.vcproj.\n\n## I put my tests in a library and Google Test doesn't run them. What's happening? ##\nHave you read a\n[warning](V1_6_Primer.md#important-note-for-visual-c-users) on\nthe Google Test Primer page?\n\n## I want to use Google Test with Visual Studio but don't know where to start. ##\nMany people are in your position and one of the posted his solution to\nour mailing list. Here is his link:\nhttp://hassanjamilahmad.blogspot.com/2009/07/gtest-starters-help.html.\n\n## I am seeing compile errors mentioning std::type\\_traits when I try to use Google Test on Solaris. ##\nGoogle Test uses parts of the standard C++ library that SunStudio does not support.\nOur users reported success using alternative implementations. Try running the build after runing this commad:\n\n`export CC=cc CXX=CC CXXFLAGS='-library=stlport4'`\n\n## How can my code detect if it is running in a test? ##\n\nIf you write code that sniffs whether it's running in a test and does\ndifferent things accordingly, you are leaking test-only logic into\nproduction code and there is no easy way to ensure that the test-only\ncode paths aren't run by mistake in production.  Such cleverness also\nleads to\n[Heisenbugs](http://en.wikipedia.org/wiki/Unusual_software_bug#Heisenbug).\nTherefore we strongly advise against the practice, and Google Test doesn't\nprovide a way to do it.\n\nIn general, the recommended way to cause the code to behave\ndifferently under test is [dependency injection](http://jamesshore.com/Blog/Dependency-Injection-Demystified.html).\nYou can inject different functionality from the test and from the\nproduction code.  Since your production code doesn't link in the\nfor-test logic at all, there is no danger in accidentally running it.\n\nHowever, if you _really_, _really_, _really_ have no choice, and if\nyou follow the rule of ending your test program names with `_test`,\nyou can use the _horrible_ hack of sniffing your executable name\n(`argv[0]` in `main()`) to know whether the code is under test.\n\n## Google Test defines a macro that clashes with one defined by another library. How do I deal with that? ##\n\nIn C++, macros don't obey namespaces.  Therefore two libraries that\nboth define a macro of the same name will clash if you `#include` both\ndefinitions.  In case a Google Test macro clashes with another\nlibrary, you can force Google Test to rename its macro to avoid the\nconflict.\n\nSpecifically, if both Google Test and some other code define macro\n`FOO`, you can add\n```\n  -DGTEST_DONT_DEFINE_FOO=1\n```\nto the compiler flags to tell Google Test to change the macro's name\nfrom `FOO` to `GTEST_FOO`. For example, with `-DGTEST_DONT_DEFINE_TEST=1`, you'll need to write\n```\n  GTEST_TEST(SomeTest, DoesThis) { ... }\n```\ninstead of\n```\n  TEST(SomeTest, DoesThis) { ... }\n```\nin order to define a test.\n\nCurrently, the following `TEST`, `FAIL`, `SUCCEED`, and the basic comparison assertion macros can have alternative names. You can see the full list of covered macros [here](http://www.google.com/codesearch?q=if+!GTEST_DONT_DEFINE_\\w%2B+package:http://googletest\\.googlecode\\.com+file:/include/gtest/gtest.h). More information can be found in the \"Avoiding Macro Name Clashes\" section of the README file.\n\n## My question is not covered in your FAQ! ##\n\nIf you cannot find the answer to your question in this FAQ, there are\nsome other resources you can use:\n\n  1. read other [wiki pages](http://code.google.com/p/googletest/w/list),\n  1. search the mailing list [archive](http://groups.google.com/group/googletestframework/topics),\n  1. ask it on [googletestframework@googlegroups.com](mailto:googletestframework@googlegroups.com) and someone will answer it (to prevent spam, we require you to join the [discussion group](http://groups.google.com/group/googletestframework) before you can post.).\n\nPlease note that creating an issue in the\n[issue tracker](http://code.google.com/p/googletest/issues/list) is _not_\na good way to get your answer, as it is monitored infrequently by a\nvery small number of people.\n\nWhen asking a question, it's helpful to provide as much of the\nfollowing information as possible (people cannot help you if there's\nnot enough information in your question):\n\n  * the version (or the revision number if you check out from SVN directly) of Google Test you use (Google Test is under active development, so it's possible that your problem has been solved in a later version),\n  * your operating system,\n  * the name and version of your compiler,\n  * the complete command line flags you give to your compiler,\n  * the complete compiler error messages (if the question is about compilation),\n  * the _actual_ code (ideally, a minimal but complete program) that has the problem you encounter.\n"
  },
  {
    "path": "utils/googletest/googletest/docs/V1_6_Primer.md",
    "content": "\n\n# Introduction: Why Google C++ Testing Framework? #\n\n_Google C++ Testing Framework_ helps you write better C++ tests.\n\nNo matter whether you work on Linux, Windows, or a Mac, if you write C++ code,\nGoogle Test can help you.\n\nSo what makes a good test, and how does Google C++ Testing Framework fit in? We believe:\n  1. Tests should be _independent_ and _repeatable_. It's a pain to debug a test that succeeds or fails as a result of other tests.  Google C++ Testing Framework isolates the tests by running each of them on a different object. When a test fails, Google C++ Testing Framework allows you to run it in isolation for quick debugging.\n  1. Tests should be well _organized_ and reflect the structure of the tested code.  Google C++ Testing Framework groups related tests into test cases that can share data and subroutines. This common pattern is easy to recognize and makes tests easy to maintain. Such consistency is especially helpful when people switch projects and start to work on a new code base.\n  1. Tests should be _portable_ and _reusable_. The open-source community has a lot of code that is platform-neutral, its tests should also be platform-neutral.  Google C++ Testing Framework works on different OSes, with different compilers (gcc, MSVC, and others), with or without exceptions, so Google C++ Testing Framework tests can easily work with a variety of configurations.  (Note that the current release only contains build scripts for Linux - we are actively working on scripts for other platforms.)\n  1. When tests fail, they should provide as much _information_ about the problem as possible. Google C++ Testing Framework doesn't stop at the first test failure. Instead, it only stops the current test and continues with the next. You can also set up tests that report non-fatal failures after which the current test continues. Thus, you can detect and fix multiple bugs in a single run-edit-compile cycle.\n  1. The testing framework should liberate test writers from housekeeping chores and let them focus on the test _content_.  Google C++ Testing Framework automatically keeps track of all tests defined, and doesn't require the user to enumerate them in order to run them.\n  1. Tests should be _fast_. With Google C++ Testing Framework, you can reuse shared resources across tests and pay for the set-up/tear-down only once, without making tests depend on each other.\n\nSince Google C++ Testing Framework is based on the popular xUnit\narchitecture, you'll feel right at home if you've used JUnit or PyUnit before.\nIf not, it will take you about 10 minutes to learn the basics and get started.\nSo let's go!\n\n_Note:_ We sometimes refer to Google C++ Testing Framework informally\nas _Google Test_.\n\n# Setting up a New Test Project #\n\nTo write a test program using Google Test, you need to compile Google\nTest into a library and link your test with it.  We provide build\nfiles for some popular build systems: `msvc/` for Visual Studio,\n`xcode/` for Mac Xcode, `make/` for GNU make, `codegear/` for Borland\nC++ Builder, and the autotools script (deprecated) and\n`CMakeLists.txt` for CMake (recommended) in the Google Test root\ndirectory.  If your build system is not on this list, you can take a\nlook at `make/Makefile` to learn how Google Test should be compiled\n(basically you want to compile `src/gtest-all.cc` with `GTEST_ROOT`\nand `GTEST_ROOT/include` in the header search path, where `GTEST_ROOT`\nis the Google Test root directory).\n\nOnce you are able to compile the Google Test library, you should\ncreate a project or build target for your test program.  Make sure you\nhave `GTEST_ROOT/include` in the header search path so that the\ncompiler can find `\"gtest/gtest.h\"` when compiling your test.  Set up\nyour test project to link with the Google Test library (for example,\nin Visual Studio, this is done by adding a dependency on\n`gtest.vcproj`).\n\nIf you still have questions, take a look at how Google Test's own\ntests are built and use them as examples.\n\n# Basic Concepts #\n\nWhen using Google Test, you start by writing _assertions_, which are statements\nthat check whether a condition is true. An assertion's result can be _success_,\n_nonfatal failure_, or _fatal failure_. If a fatal failure occurs, it aborts\nthe current function; otherwise the program continues normally.\n\n_Tests_ use assertions to verify the tested code's behavior. If a test crashes\nor has a failed assertion, then it _fails_; otherwise it _succeeds_.\n\nA _test case_ contains one or many tests. You should group your tests into test\ncases that reflect the structure of the tested code. When multiple tests in a\ntest case need to share common objects and subroutines, you can put them into a\n_test fixture_ class.\n\nA _test program_ can contain multiple test cases.\n\nWe'll now explain how to write a test program, starting at the individual\nassertion level and building up to tests and test cases.\n\n# Assertions #\n\nGoogle Test assertions are macros that resemble function calls. You test a\nclass or function by making assertions about its behavior. When an assertion\nfails, Google Test prints the assertion's source file and line number location,\nalong with a failure message. You may also supply a custom failure message\nwhich will be appended to Google Test's message.\n\nThe assertions come in pairs that test the same thing but have different\neffects on the current function. `ASSERT_*` versions generate fatal failures\nwhen they fail, and **abort the current function**. `EXPECT_*` versions generate\nnonfatal failures, which don't abort the current function. Usually `EXPECT_*`\nare preferred, as they allow more than one failures to be reported in a test.\nHowever, you should use `ASSERT_*` if it doesn't make sense to continue when\nthe assertion in question fails.\n\nSince a failed `ASSERT_*` returns from the current function immediately,\npossibly skipping clean-up code that comes after it, it may cause a space leak.\nDepending on the nature of the leak, it may or may not be worth fixing - so\nkeep this in mind if you get a heap checker error in addition to assertion\nerrors.\n\nTo provide a custom failure message, simply stream it into the macro using the\n`<<` operator, or a sequence of such operators. An example:\n```\nASSERT_EQ(x.size(), y.size()) << \"Vectors x and y are of unequal length\";\n\nfor (int i = 0; i < x.size(); ++i) {\n  EXPECT_EQ(x[i], y[i]) << \"Vectors x and y differ at index \" << i;\n}\n```\n\nAnything that can be streamed to an `ostream` can be streamed to an assertion\nmacro--in particular, C strings and `string` objects. If a wide string\n(`wchar_t*`, `TCHAR*` in `UNICODE` mode on Windows, or `std::wstring`) is\nstreamed to an assertion, it will be translated to UTF-8 when printed.\n\n## Basic Assertions ##\n\nThese assertions do basic true/false condition testing.\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_TRUE(`_condition_`)`;  | `EXPECT_TRUE(`_condition_`)`;   | _condition_ is true |\n| `ASSERT_FALSE(`_condition_`)`; | `EXPECT_FALSE(`_condition_`)`;  | _condition_ is false |\n\nRemember, when they fail, `ASSERT_*` yields a fatal failure and\nreturns from the current function, while `EXPECT_*` yields a nonfatal\nfailure, allowing the function to continue running. In either case, an\nassertion failure means its containing test fails.\n\n_Availability_: Linux, Windows, Mac.\n\n## Binary Comparison ##\n\nThis section describes assertions that compare two values.\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n|`ASSERT_EQ(`_expected_`, `_actual_`);`|`EXPECT_EQ(`_expected_`, `_actual_`);`| _expected_ `==` _actual_ |\n|`ASSERT_NE(`_val1_`, `_val2_`);`      |`EXPECT_NE(`_val1_`, `_val2_`);`      | _val1_ `!=` _val2_ |\n|`ASSERT_LT(`_val1_`, `_val2_`);`      |`EXPECT_LT(`_val1_`, `_val2_`);`      | _val1_ `<` _val2_ |\n|`ASSERT_LE(`_val1_`, `_val2_`);`      |`EXPECT_LE(`_val1_`, `_val2_`);`      | _val1_ `<=` _val2_ |\n|`ASSERT_GT(`_val1_`, `_val2_`);`      |`EXPECT_GT(`_val1_`, `_val2_`);`      | _val1_ `>` _val2_ |\n|`ASSERT_GE(`_val1_`, `_val2_`);`      |`EXPECT_GE(`_val1_`, `_val2_`);`      | _val1_ `>=` _val2_ |\n\nIn the event of a failure, Google Test prints both _val1_ and _val2_\n. In `ASSERT_EQ*` and `EXPECT_EQ*` (and all other equality assertions\nwe'll introduce later), you should put the expression you want to test\nin the position of _actual_, and put its expected value in _expected_,\nas Google Test's failure messages are optimized for this convention.\n\nValue arguments must be comparable by the assertion's comparison\noperator or you'll get a compiler error.  We used to require the\narguments to support the `<<` operator for streaming to an `ostream`,\nbut it's no longer necessary since v1.6.0 (if `<<` is supported, it\nwill be called to print the arguments when the assertion fails;\notherwise Google Test will attempt to print them in the best way it\ncan. For more details and how to customize the printing of the\narguments, see this Google Mock [recipe](../../googlemock/docs/CookBook.md#teaching-google-mock-how-to-print-your-values).).\n\nThese assertions can work with a user-defined type, but only if you define the\ncorresponding comparison operator (e.g. `==`, `<`, etc).  If the corresponding\noperator is defined, prefer using the `ASSERT_*()` macros because they will\nprint out not only the result of the comparison, but the two operands as well.\n\nArguments are always evaluated exactly once. Therefore, it's OK for the\narguments to have side effects. However, as with any ordinary C/C++ function,\nthe arguments' evaluation order is undefined (i.e. the compiler is free to\nchoose any order) and your code should not depend on any particular argument\nevaluation order.\n\n`ASSERT_EQ()` does pointer equality on pointers. If used on two C strings, it\ntests if they are in the same memory location, not if they have the same value.\nTherefore, if you want to compare C strings (e.g. `const char*`) by value, use\n`ASSERT_STREQ()` , which will be described later on. In particular, to assert\nthat a C string is `NULL`, use `ASSERT_STREQ(NULL, c_string)` . However, to\ncompare two `string` objects, you should use `ASSERT_EQ`.\n\nMacros in this section work with both narrow and wide string objects (`string`\nand `wstring`).\n\n_Availability_: Linux, Windows, Mac.\n\n## String Comparison ##\n\nThe assertions in this group compare two **C strings**. If you want to compare\ntwo `string` objects, use `EXPECT_EQ`, `EXPECT_NE`, and etc instead.\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_STREQ(`_expected\\_str_`, `_actual\\_str_`);`    | `EXPECT_STREQ(`_expected\\_str_`, `_actual\\_str_`);`     | the two C strings have the same content |\n| `ASSERT_STRNE(`_str1_`, `_str2_`);`    | `EXPECT_STRNE(`_str1_`, `_str2_`);`     | the two C strings have different content |\n| `ASSERT_STRCASEEQ(`_expected\\_str_`, `_actual\\_str_`);`| `EXPECT_STRCASEEQ(`_expected\\_str_`, `_actual\\_str_`);` | the two C strings have the same content, ignoring case |\n| `ASSERT_STRCASENE(`_str1_`, `_str2_`);`| `EXPECT_STRCASENE(`_str1_`, `_str2_`);` | the two C strings have different content, ignoring case |\n\nNote that \"CASE\" in an assertion name means that case is ignored.\n\n`*STREQ*` and `*STRNE*` also accept wide C strings (`wchar_t*`). If a\ncomparison of two wide strings fails, their values will be printed as UTF-8\nnarrow strings.\n\nA `NULL` pointer and an empty string are considered _different_.\n\n_Availability_: Linux, Windows, Mac.\n\nSee also: For more string comparison tricks (substring, prefix, suffix, and\nregular expression matching, for example), see the [Advanced Google Test Guide](V1_6_AdvancedGuide.md).\n\n# Simple Tests #\n\nTo create a test:\n  1. Use the `TEST()` macro to define and name a test function, These are ordinary C++ functions that don't return a value.\n  1. In this function, along with any valid C++ statements you want to include, use the various Google Test assertions to check values.\n  1. The test's result is determined by the assertions; if any assertion in the test fails (either fatally or non-fatally), or if the test crashes, the entire test fails. Otherwise, it succeeds.\n\n```\nTEST(test_case_name, test_name) {\n ... test body ...\n}\n```\n\n\n`TEST()` arguments go from general to specific. The _first_ argument is the\nname of the test case, and the _second_ argument is the test's name within the\ntest case. Both names must be valid C++ identifiers, and they should not contain underscore (`_`). A test's _full name_ consists of its containing test case and its\nindividual name. Tests from different test cases can have the same individual\nname.\n\nFor example, let's take a simple integer function:\n```\nint Factorial(int n); // Returns the factorial of n\n```\n\nA test case for this function might look like:\n```\n// Tests factorial of 0.\nTEST(FactorialTest, HandlesZeroInput) {\n  EXPECT_EQ(1, Factorial(0));\n}\n\n// Tests factorial of positive numbers.\nTEST(FactorialTest, HandlesPositiveInput) {\n  EXPECT_EQ(1, Factorial(1));\n  EXPECT_EQ(2, Factorial(2));\n  EXPECT_EQ(6, Factorial(3));\n  EXPECT_EQ(40320, Factorial(8));\n}\n```\n\nGoogle Test groups the test results by test cases, so logically-related tests\nshould be in the same test case; in other words, the first argument to their\n`TEST()` should be the same. In the above example, we have two tests,\n`HandlesZeroInput` and `HandlesPositiveInput`, that belong to the same test\ncase `FactorialTest`.\n\n_Availability_: Linux, Windows, Mac.\n\n# Test Fixtures: Using the Same Data Configuration for Multiple Tests #\n\nIf you find yourself writing two or more tests that operate on similar data,\nyou can use a _test fixture_. It allows you to reuse the same configuration of\nobjects for several different tests.\n\nTo create a fixture, just:\n  1. Derive a class from `::testing::Test` . Start its body with `protected:` or `public:` as we'll want to access fixture members from sub-classes.\n  1. Inside the class, declare any objects you plan to use.\n  1. If necessary, write a default constructor or `SetUp()` function to prepare the objects for each test. A common mistake is to spell `SetUp()` as `Setup()` with a small `u` - don't let that happen to you.\n  1. If necessary, write a destructor or `TearDown()` function to release any resources you allocated in `SetUp()` . To learn when you should use the constructor/destructor and when you should use `SetUp()/TearDown()`, read this [FAQ entry](V1_6_FAQ.md#should-i-use-the-constructordestructor-of-the-test-fixture-or-the-set-uptear-down-function).\n  1. If needed, define subroutines for your tests to share.\n\nWhen using a fixture, use `TEST_F()` instead of `TEST()` as it allows you to\naccess objects and subroutines in the test fixture:\n```\nTEST_F(test_case_name, test_name) {\n ... test body ...\n}\n```\n\nLike `TEST()`, the first argument is the test case name, but for `TEST_F()`\nthis must be the name of the test fixture class. You've probably guessed: `_F`\nis for fixture.\n\nUnfortunately, the C++ macro system does not allow us to create a single macro\nthat can handle both types of tests. Using the wrong macro causes a compiler\nerror.\n\nAlso, you must first define a test fixture class before using it in a\n`TEST_F()`, or you'll get the compiler error \"`virtual outside class\ndeclaration`\".\n\nFor each test defined with `TEST_F()`, Google Test will:\n  1. Create a _fresh_ test fixture at runtime\n  1. Immediately initialize it via `SetUp()` ,\n  1. Run the test\n  1. Clean up by calling `TearDown()`\n  1. Delete the test fixture.  Note that different tests in the same test case have different test fixture objects, and Google Test always deletes a test fixture before it creates the next one. Google Test does not reuse the same test fixture for multiple tests. Any changes one test makes to the fixture do not affect other tests.\n\nAs an example, let's write tests for a FIFO queue class named `Queue`, which\nhas the following interface:\n```\ntemplate <typename E> // E is the element type.\nclass Queue {\n public:\n  Queue();\n  void Enqueue(const E& element);\n  E* Dequeue(); // Returns NULL if the queue is empty.\n  size_t size() const;\n  ...\n};\n```\n\nFirst, define a fixture class. By convention, you should give it the name\n`FooTest` where `Foo` is the class being tested.\n```\nclass QueueTest : public ::testing::Test {\n protected:\n  virtual void SetUp() {\n    q1_.Enqueue(1);\n    q2_.Enqueue(2);\n    q2_.Enqueue(3);\n  }\n\n  // virtual void TearDown() {}\n\n  Queue<int> q0_;\n  Queue<int> q1_;\n  Queue<int> q2_;\n};\n```\n\nIn this case, `TearDown()` is not needed since we don't have to clean up after\neach test, other than what's already done by the destructor.\n\nNow we'll write tests using `TEST_F()` and this fixture.\n```\nTEST_F(QueueTest, IsEmptyInitially) {\n  EXPECT_EQ(0, q0_.size());\n}\n\nTEST_F(QueueTest, DequeueWorks) {\n  int* n = q0_.Dequeue();\n  EXPECT_EQ(NULL, n);\n\n  n = q1_.Dequeue();\n  ASSERT_TRUE(n != NULL);\n  EXPECT_EQ(1, *n);\n  EXPECT_EQ(0, q1_.size());\n  delete n;\n\n  n = q2_.Dequeue();\n  ASSERT_TRUE(n != NULL);\n  EXPECT_EQ(2, *n);\n  EXPECT_EQ(1, q2_.size());\n  delete n;\n}\n```\n\nThe above uses both `ASSERT_*` and `EXPECT_*` assertions. The rule of thumb is\nto use `EXPECT_*` when you want the test to continue to reveal more errors\nafter the assertion failure, and use `ASSERT_*` when continuing after failure\ndoesn't make sense. For example, the second assertion in the `Dequeue` test is\n`ASSERT_TRUE(n != NULL)`, as we need to dereference the pointer `n` later,\nwhich would lead to a segfault when `n` is `NULL`.\n\nWhen these tests run, the following happens:\n  1. Google Test constructs a `QueueTest` object (let's call it `t1` ).\n  1. `t1.SetUp()` initializes `t1` .\n  1. The first test ( `IsEmptyInitially` ) runs on `t1` .\n  1. `t1.TearDown()` cleans up after the test finishes.\n  1. `t1` is destructed.\n  1. The above steps are repeated on another `QueueTest` object, this time running the `DequeueWorks` test.\n\n_Availability_: Linux, Windows, Mac.\n\n_Note_: Google Test automatically saves all _Google Test_ flags when a test\nobject is constructed, and restores them when it is destructed.\n\n# Invoking the Tests #\n\n`TEST()` and `TEST_F()` implicitly register their tests with Google Test. So, unlike with many other C++ testing frameworks, you don't have to re-list all your defined tests in order to run them.\n\nAfter defining your tests, you can run them with `RUN_ALL_TESTS()` , which returns `0` if all the tests are successful, or `1` otherwise. Note that `RUN_ALL_TESTS()` runs _all tests_ in your link unit -- they can be from different test cases, or even different source files.\n\nWhen invoked, the `RUN_ALL_TESTS()` macro:\n  1. Saves the state of all  Google Test flags.\n  1. Creates a test fixture object for the first test.\n  1. Initializes it via `SetUp()`.\n  1. Runs the test on the fixture object.\n  1. Cleans up the fixture via `TearDown()`.\n  1. Deletes the fixture.\n  1. Restores the state of all Google Test flags.\n  1. Repeats the above steps for the next test, until all tests have run.\n\nIn addition, if the text fixture's constructor generates a fatal failure in\nstep 2, there is no point for step 3 - 5 and they are thus skipped. Similarly,\nif step 3 generates a fatal failure, step 4 will be skipped.\n\n_Important_: You must not ignore the return value of `RUN_ALL_TESTS()`, or `gcc`\nwill give you a compiler error. The rationale for this design is that the\nautomated testing service determines whether a test has passed based on its\nexit code, not on its stdout/stderr output; thus your `main()` function must\nreturn the value of `RUN_ALL_TESTS()`.\n\nAlso, you should call `RUN_ALL_TESTS()` only **once**. Calling it more than once\nconflicts with some advanced Google Test features (e.g. thread-safe death\ntests) and thus is not supported.\n\n_Availability_: Linux, Windows, Mac.\n\n# Writing the main() Function #\n\nYou can start from this boilerplate:\n```\n#include \"this/package/foo.h\"\n#include \"gtest/gtest.h\"\n\nnamespace {\n\n// The fixture for testing class Foo.\nclass FooTest : public ::testing::Test {\n protected:\n  // You can remove any or all of the following functions if its body\n  // is empty.\n\n  FooTest() {\n    // You can do set-up work for each test here.\n  }\n\n  virtual ~FooTest() {\n    // You can do clean-up work that doesn't throw exceptions here.\n  }\n\n  // If the constructor and destructor are not enough for setting up\n  // and cleaning up each test, you can define the following methods:\n\n  virtual void SetUp() {\n    // Code here will be called immediately after the constructor (right\n    // before each test).\n  }\n\n  virtual void TearDown() {\n    // Code here will be called immediately after each test (right\n    // before the destructor).\n  }\n\n  // Objects declared here can be used by all tests in the test case for Foo.\n};\n\n// Tests that the Foo::Bar() method does Abc.\nTEST_F(FooTest, MethodBarDoesAbc) {\n  const string input_filepath = \"this/package/testdata/myinputfile.dat\";\n  const string output_filepath = \"this/package/testdata/myoutputfile.dat\";\n  Foo f;\n  EXPECT_EQ(0, f.Bar(input_filepath, output_filepath));\n}\n\n// Tests that Foo does Xyz.\nTEST_F(FooTest, DoesXyz) {\n  // Exercises the Xyz feature of Foo.\n}\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n```\n\nThe `::testing::InitGoogleTest()` function parses the command line for Google\nTest flags, and removes all recognized flags. This allows the user to control a\ntest program's behavior via various flags, which we'll cover in [AdvancedGuide](V1_6_AdvancedGuide.md).\nYou must call this function before calling `RUN_ALL_TESTS()`, or the flags\nwon't be properly initialized.\n\nOn Windows, `InitGoogleTest()` also works with wide strings, so it can be used\nin programs compiled in `UNICODE` mode as well.\n\nBut maybe you think that writing all those main() functions is too much work? We agree with you completely and that's why Google Test provides a basic implementation of main(). If it fits your needs, then just link your test with gtest\\_main library and you are good to go.\n\n## Important note for Visual C++ users ##\nIf you put your tests into a library and your `main()` function is in a different library or in your .exe file, those tests will not run. The reason is a [bug](https://connect.microsoft.com/feedback/viewfeedback.aspx?FeedbackID=244410&siteid=210) in Visual C++. When you define your tests, Google Test creates certain static objects to register them. These objects are not referenced from elsewhere but their constructors are still supposed to run. When Visual C++ linker sees that nothing in the library is referenced from other places it throws the library out. You have to reference your library with tests from your main program to keep the linker from discarding it. Here is how to do it. Somewhere in your library code declare a function:\n```\n__declspec(dllexport) int PullInMyLibrary() { return 0; }\n```\nIf you put your tests in a static library (not DLL) then `__declspec(dllexport)` is not required. Now, in your main program, write a code that invokes that function:\n```\nint PullInMyLibrary();\nstatic int dummy = PullInMyLibrary();\n```\nThis will keep your tests referenced and will make them register themselves at startup.\n\nIn addition, if you define your tests in a static library, add `/OPT:NOREF` to your main program linker options. If you use MSVC++ IDE, go to your .exe project properties/Configuration Properties/Linker/Optimization and set References setting to `Keep Unreferenced Data (/OPT:NOREF)`. This will keep Visual C++ linker from discarding individual symbols generated by your tests from the final executable.\n\nThere is one more pitfall, though. If you use Google Test as a static library (that's how it is defined in gtest.vcproj) your tests must also reside in a static library. If you have to have them in a DLL, you _must_ change Google Test to build into a DLL as well. Otherwise your tests will not run correctly or will not run at all. The general conclusion here is: make your life easier - do not write your tests in libraries!\n\n# Where to Go from Here #\n\nCongratulations! You've learned the Google Test basics. You can start writing\nand running Google Test tests, read some [samples](V1_6_Samples.md), or continue with\n[AdvancedGuide](V1_6_AdvancedGuide.md), which describes many more useful Google Test features.\n\n# Known Limitations #\n\nGoogle Test is designed to be thread-safe.  The implementation is\nthread-safe on systems where the `pthreads` library is available.  It\nis currently _unsafe_ to use Google Test assertions from two threads\nconcurrently on other systems (e.g. Windows).  In most tests this is\nnot an issue as usually the assertions are done in the main thread. If\nyou want to help, you can volunteer to implement the necessary\nsynchronization primitives in `gtest-port.h` for your platform.\n"
  },
  {
    "path": "utils/googletest/googletest/docs/V1_6_PumpManual.md",
    "content": "\n\n<b>P</b>ump is <b>U</b>seful for <b>M</b>eta <b>P</b>rogramming.\n\n# The Problem #\n\nTemplate and macro libraries often need to define many classes,\nfunctions, or macros that vary only (or almost only) in the number of\narguments they take. It's a lot of repetitive, mechanical, and\nerror-prone work.\n\nVariadic templates and variadic macros can alleviate the problem.\nHowever, while both are being considered by the C++ committee, neither\nis in the standard yet or widely supported by compilers.  Thus they\nare often not a good choice, especially when your code needs to be\nportable. And their capabilities are still limited.\n\nAs a result, authors of such libraries often have to write scripts to\ngenerate their implementation. However, our experience is that it's\ntedious to write such scripts, which tend to reflect the structure of\nthe generated code poorly and are often hard to read and edit. For\nexample, a small change needed in the generated code may require some\nnon-intuitive, non-trivial changes in the script. This is especially\npainful when experimenting with the code.\n\n# Our Solution #\n\nPump (for Pump is Useful for Meta Programming, Pretty Useful for Meta\nProgramming, or Practical Utility for Meta Programming, whichever you\nprefer) is a simple meta-programming tool for C++. The idea is that a\nprogrammer writes a `foo.pump` file which contains C++ code plus meta\ncode that manipulates the C++ code. The meta code can handle\niterations over a range, nested iterations, local meta variable\ndefinitions, simple arithmetic, and conditional expressions. You can\nview it as a small Domain-Specific Language. The meta language is\ndesigned to be non-intrusive (s.t. it won't confuse Emacs' C++ mode,\nfor example) and concise, making Pump code intuitive and easy to\nmaintain.\n\n## Highlights ##\n\n  * The implementation is in a single Python script and thus ultra portable: no build or installation is needed and it works cross platforms.\n  * Pump tries to be smart with respect to [Google's style guide](http://code.google.com/p/google-styleguide/): it breaks long lines (easy to have when they are generated) at acceptable places to fit within 80 columns and indent the continuation lines correctly.\n  * The format is human-readable and more concise than XML.\n  * The format works relatively well with Emacs' C++ mode.\n\n## Examples ##\n\nThe following Pump code (where meta keywords start with `$`, `[[` and `]]` are meta brackets, and `$$` starts a meta comment that ends with the line):\n\n```\n$var n = 3     $$ Defines a meta variable n.\n$range i 0..n  $$ Declares the range of meta iterator i (inclusive).\n$for i [[\n               $$ Meta loop.\n// Foo$i does blah for $i-ary predicates.\n$range j 1..i\ntemplate <size_t N $for j [[, typename A$j]]>\nclass Foo$i {\n$if i == 0 [[\n  blah a;\n]] $elif i <= 2 [[\n  blah b;\n]] $else [[\n  blah c;\n]]\n};\n\n]]\n```\n\nwill be translated by the Pump compiler to:\n\n```\n// Foo0 does blah for 0-ary predicates.\ntemplate <size_t N>\nclass Foo0 {\n  blah a;\n};\n\n// Foo1 does blah for 1-ary predicates.\ntemplate <size_t N, typename A1>\nclass Foo1 {\n  blah b;\n};\n\n// Foo2 does blah for 2-ary predicates.\ntemplate <size_t N, typename A1, typename A2>\nclass Foo2 {\n  blah b;\n};\n\n// Foo3 does blah for 3-ary predicates.\ntemplate <size_t N, typename A1, typename A2, typename A3>\nclass Foo3 {\n  blah c;\n};\n```\n\nIn another example,\n\n```\n$range i 1..n\nFunc($for i + [[a$i]]);\n$$ The text between i and [[ is the separator between iterations.\n```\n\nwill generate one of the following lines (without the comments), depending on the value of `n`:\n\n```\nFunc();              // If n is 0.\nFunc(a1);            // If n is 1.\nFunc(a1 + a2);       // If n is 2.\nFunc(a1 + a2 + a3);  // If n is 3.\n// And so on...\n```\n\n## Constructs ##\n\nWe support the following meta programming constructs:\n\n| `$var id = exp` | Defines a named constant value. `$id` is valid util the end of the current meta lexical block. |\n|:----------------|:-----------------------------------------------------------------------------------------------|\n| `$range id exp..exp` | Sets the range of an iteration variable, which can be reused in multiple loops later.          |\n| `$for id sep [[ code ]]` | Iteration. The range of `id` must have been defined earlier. `$id` is valid in `code`.         |\n| `$($)`          | Generates a single `$` character.                                                              |\n| `$id`           | Value of the named constant or iteration variable.                                             |\n| `$(exp)`        | Value of the expression.                                                                       |\n| `$if exp [[ code ]] else_branch` | Conditional.                                                                                   |\n| `[[ code ]]`    | Meta lexical block.                                                                            |\n| `cpp_code`      | Raw C++ code.                                                                                  |\n| `$$ comment`    | Meta comment.                                                                                  |\n\n**Note:** To give the user some freedom in formatting the Pump source\ncode, Pump ignores a new-line character if it's right after `$for foo`\nor next to `[[` or `]]`. Without this rule you'll often be forced to write\nvery long lines to get the desired output. Therefore sometimes you may\nneed to insert an extra new-line in such places for a new-line to show\nup in your output.\n\n## Grammar ##\n\n```\ncode ::= atomic_code*\natomic_code ::= $var id = exp\n    | $var id = [[ code ]]\n    | $range id exp..exp\n    | $for id sep [[ code ]]\n    | $($)\n    | $id\n    | $(exp)\n    | $if exp [[ code ]] else_branch\n    | [[ code ]]\n    | cpp_code\nsep ::= cpp_code | empty_string\nelse_branch ::= $else [[ code ]]\n    | $elif exp [[ code ]] else_branch\n    | empty_string\nexp ::= simple_expression_in_Python_syntax\n```\n\n## Code ##\n\nYou can find the source code of Pump in [scripts/pump.py](../scripts/pump.py). It is still\nvery unpolished and lacks automated tests, although it has been\nsuccessfully used many times. If you find a chance to use it in your\nproject, please let us know what you think!  We also welcome help on\nimproving Pump.\n\n## Real Examples ##\n\nYou can find real-world applications of Pump in [Google Test](http://www.google.com/codesearch?q=file%3A\\.pump%24+package%3Ahttp%3A%2F%2Fgoogletest\\.googlecode\\.com) and [Google Mock](http://www.google.com/codesearch?q=file%3A\\.pump%24+package%3Ahttp%3A%2F%2Fgooglemock\\.googlecode\\.com).  The source file `foo.h.pump` generates `foo.h`.\n\n## Tips ##\n\n  * If a meta variable is followed by a letter or digit, you can separate them using `[[]]`, which inserts an empty string. For example `Foo$j[[]]Helper` generate `Foo1Helper` when `j` is 1.\n  * To avoid extra-long Pump source lines, you can break a line anywhere you want by inserting `[[]]` followed by a new line. Since any new-line character next to `[[` or `]]` is ignored, the generated code won't contain this new line.\n"
  },
  {
    "path": "utils/googletest/googletest/docs/V1_6_Samples.md",
    "content": "If you're like us, you'd like to look at some Google Test sample code.  The\n[samples folder](../samples) has a number of well-commented samples showing how to use a\nvariety of Google Test features.\n\n  * [Sample #1](../samples/sample1_unittest.cc) shows the basic steps of using Google Test to test C++ functions.\n  * [Sample #2](../samples/sample2_unittest.cc) shows a more complex unit test for a class with multiple member functions.\n  * [Sample #3](../samples/sample3_unittest.cc) uses a test fixture.\n  * [Sample #4](../samples/sample4_unittest.cc) is another basic example of using Google Test.\n  * [Sample #5](../samples/sample5_unittest.cc) teaches how to reuse a test fixture in multiple test cases by deriving sub-fixtures from it.\n  * [Sample #6](../samples/sample6_unittest.cc) demonstrates type-parameterized tests.\n  * [Sample #7](../samples/sample7_unittest.cc) teaches the basics of value-parameterized tests.\n  * [Sample #8](../samples/sample8_unittest.cc) shows using `Combine()` in value-parameterized tests.\n  * [Sample #9](../samples/sample9_unittest.cc) shows use of the listener API to modify Google Test's console output and the use of its reflection API to inspect test results.\n  * [Sample #10](../samples/sample10_unittest.cc) shows use of the listener API to implement a primitive memory leak checker.\n"
  },
  {
    "path": "utils/googletest/googletest/docs/V1_6_XcodeGuide.md",
    "content": "\n\nThis guide will explain how to use the Google Testing Framework in your Xcode projects on Mac OS X. This tutorial begins by quickly explaining what to do for experienced users. After the quick start, the guide goes provides additional explanation about each step.\n\n# Quick Start #\n\nHere is the quick guide for using Google Test in your Xcode project.\n\n  1. Download the source from the [website](http://code.google.com/p/googletest) using this command: `svn checkout http://googletest.googlecode.com/svn/trunk/ googletest-read-only`\n  1. Open up the `gtest.xcodeproj` in the `googletest-read-only/xcode/` directory and build the gtest.framework.\n  1. Create a new \"Shell Tool\" target in your Xcode project called something like \"UnitTests\"\n  1. Add the gtest.framework to your project and add it to the \"Link Binary with Libraries\" build phase of \"UnitTests\"\n  1. Add your unit test source code to the \"Compile Sources\" build phase of \"UnitTests\"\n  1. Edit the \"UnitTests\" executable and add an environment variable named \"DYLD\\_FRAMEWORK\\_PATH\" with a value equal to the path to the framework containing the gtest.framework relative to the compiled executable.\n  1. Build and Go\n\nThe following sections further explain each of the steps listed above in depth, describing in more detail how to complete it including some variations.\n\n# Get the Source #\n\nCurrently, the gtest.framework discussed here isn't available in a tagged release of Google Test, it is only available in the trunk. As explained at the Google Test [site](http://code.google.com/p/googletest/source/checkout\">svn), you can get the code from anonymous SVN with this command:\n\n```\nsvn checkout http://googletest.googlecode.com/svn/trunk/ googletest-read-only\n```\n\nAlternatively, if you are working with Subversion in your own code base, you can add Google Test as an external dependency to your own Subversion repository. By following this approach, everyone that checks out your svn repository will also receive a copy of Google Test (a specific version, if you wish) without having to check it out explicitly. This makes the set up of your project simpler and reduces the copied code in the repository.\n\nTo use `svn:externals`, decide where you would like to have the external source reside. You might choose to put the external source inside the trunk, because you want it to be part of the branch when you make a release. However, keeping it outside the trunk in a version-tagged directory called something like `third-party/googletest/1.0.1`, is another option. Once the location is established, use `svn propedit svn:externals _directory_` to set the svn:externals property on a directory in your repository. This directory won't contain the code, but be its versioned parent directory.\n\nThe command `svn propedit` will bring up your Subversion editor, making editing the long, (potentially multi-line) property simpler. This same method can be used to check out a tagged branch, by using the appropriate URL (e.g. `http://googletest.googlecode.com/svn/tags/release-1.0.1`). Additionally, the svn:externals property allows the specification of a particular revision of the trunk with the `-r_##_` option (e.g. `externals/src/googletest -r60 http://googletest.googlecode.com/svn/trunk`).\n\nHere is an example of using the svn:externals properties on a trunk (read via `svn propget`) of a project. This value checks out a copy of Google Test into the `trunk/externals/src/googletest/` directory.\n\n```\n[Computer:svn] user$ svn propget svn:externals trunk\nexternals/src/googletest http://googletest.googlecode.com/svn/trunk\n```\n\n# Add the Framework to Your Project #\n\nThe next step is to build and add the gtest.framework to your own project. This guide describes two common ways below.\n\n  * **Option 1** --- The simplest way to add Google Test to your own project, is to open gtest.xcodeproj (found in the xcode/ directory of the Google Test trunk) and build the framework manually. Then, add the built framework into your project using the \"Add->Existing Framework...\" from the context menu or \"Project->Add...\" from the main menu. The gtest.framework is relocatable and contains the headers and object code that you'll need to make tests. This method requires rebuilding every time you upgrade Google Test in your project.\n  * **Option 2** --- If you are going to be living off the trunk of Google Test, incorporating its latest features into your unit tests (or are a Google Test developer yourself). You'll want to rebuild the framework every time the source updates. to do this, you'll need to add the gtest.xcodeproj file, not the framework itself, to your own Xcode project. Then, from the build products that are revealed by the project's disclosure triangle, you can find the gtest.framework, which can be added to your targets (discussed below).\n\n# Make a Test Target #\n\nTo start writing tests, make a new \"Shell Tool\" target. This target template is available under BSD, Cocoa, or Carbon. Add your unit test source code to the \"Compile Sources\" build phase of the target.\n\nNext, you'll want to add gtest.framework in two different ways, depending upon which option you chose above.\n\n  * **Option 1** --- During compilation, Xcode will need to know that you are linking against the gtest.framework. Add the gtest.framework to the \"Link Binary with Libraries\" build phase of your test target. This will include the Google Test headers in your header search path, and will tell the linker where to find the library.\n  * **Option 2** --- If your working out of the trunk, you'll also want to add gtest.framework to your \"Link Binary with Libraries\" build phase of your test target. In addition, you'll  want to add the gtest.framework as a dependency to your unit test target. This way, Xcode will make sure that gtest.framework is up to date, every time your build your target. Finally, if you don't share build directories with Google Test, you'll have to copy the gtest.framework into your own build products directory using a \"Run Script\" build phase.\n\n# Set Up the Executable Run Environment #\n\nSince the unit test executable is a shell tool, it doesn't have a bundle with a `Contents/Frameworks` directory, in which to place gtest.framework. Instead, the dynamic linker must be told at runtime to search for the framework in another location. This can be accomplished by setting the \"DYLD\\_FRAMEWORK\\_PATH\" environment variable in the \"Edit Active Executable ...\" Arguments tab, under \"Variables to be set in the environment:\". The path for this value is the path (relative or absolute) of the directory containing the gtest.framework.\n\nIf you haven't set up the DYLD\\_FRAMEWORK\\_PATH, correctly, you might get a message like this:\n\n```\n[Session started at 2008-08-15 06:23:57 -0600.]\n  dyld: Library not loaded: @loader_path/../Frameworks/gtest.framework/Versions/A/gtest\n    Referenced from: /Users/username/Documents/Sandbox/gtestSample/build/Debug/WidgetFrameworkTest\n    Reason: image not found\n```\n\nTo correct this problem, got to the directory containing the executable named in \"Referenced from:\" value in the error message above. Then, with the terminal in this location, find the relative path to the directory containing the gtest.framework. That is the value you'll need to set as the DYLD\\_FRAMEWORK\\_PATH.\n\n# Build and Go #\n\nNow, when you click \"Build and Go\", the test will be executed. Dumping out something like this:\n\n```\n[Session started at 2008-08-06 06:36:13 -0600.]\n[==========] Running 2 tests from 1 test case.\n[----------] Global test environment set-up.\n[----------] 2 tests from WidgetInitializerTest\n[ RUN      ] WidgetInitializerTest.TestConstructor\n[       OK ] WidgetInitializerTest.TestConstructor\n[ RUN      ] WidgetInitializerTest.TestConversion\n[       OK ] WidgetInitializerTest.TestConversion\n[----------] Global test environment tear-down\n[==========] 2 tests from 1 test case ran.\n[  PASSED  ] 2 tests.\n\nThe Debugger has exited with status 0.  \n```\n\n# Summary #\n\nUnit testing is a valuable way to ensure your data model stays valid even during rapid development or refactoring. The Google Testing Framework is a great unit testing framework for C and C++ which integrates well with an Xcode development environment."
  },
  {
    "path": "utils/googletest/googletest/docs/V1_7_AdvancedGuide.md",
    "content": "\n\nNow that you have read [Primer](V1_7_Primer.md) and learned how to write tests\nusing Google Test, it's time to learn some new tricks. This document\nwill show you more assertions as well as how to construct complex\nfailure messages, propagate fatal failures, reuse and speed up your\ntest fixtures, and use various flags with your tests.\n\n# More Assertions #\n\nThis section covers some less frequently used, but still significant,\nassertions.\n\n## Explicit Success and Failure ##\n\nThese three assertions do not actually test a value or expression. Instead,\nthey generate a success or failure directly. Like the macros that actually\nperform a test, you may stream a custom failure message into the them.\n\n| `SUCCEED();` |\n|:-------------|\n\nGenerates a success. This does NOT make the overall test succeed. A test is\nconsidered successful only if none of its assertions fail during its execution.\n\nNote: `SUCCEED()` is purely documentary and currently doesn't generate any\nuser-visible output. However, we may add `SUCCEED()` messages to Google Test's\noutput in the future.\n\n| `FAIL();`  | `ADD_FAILURE();` | `ADD_FAILURE_AT(\"`_file\\_path_`\", `_line\\_number_`);` |\n|:-----------|:-----------------|:------------------------------------------------------|\n\n`FAIL()` generates a fatal failure, while `ADD_FAILURE()` and `ADD_FAILURE_AT()` generate a nonfatal\nfailure. These are useful when control flow, rather than a Boolean expression,\ndeteremines the test's success or failure. For example, you might want to write\nsomething like:\n\n```\nswitch(expression) {\n  case 1: ... some checks ...\n  case 2: ... some other checks\n  ...\n  default: FAIL() << \"We shouldn't get here.\";\n}\n```\n\n_Availability_: Linux, Windows, Mac.\n\n## Exception Assertions ##\n\nThese are for verifying that a piece of code throws (or does not\nthrow) an exception of the given type:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_THROW(`_statement_, _exception\\_type_`);`  | `EXPECT_THROW(`_statement_, _exception\\_type_`);`  | _statement_ throws an exception of the given type  |\n| `ASSERT_ANY_THROW(`_statement_`);`                | `EXPECT_ANY_THROW(`_statement_`);`                | _statement_ throws an exception of any type        |\n| `ASSERT_NO_THROW(`_statement_`);`                 | `EXPECT_NO_THROW(`_statement_`);`                 | _statement_ doesn't throw any exception            |\n\nExamples:\n\n```\nASSERT_THROW(Foo(5), bar_exception);\n\nEXPECT_NO_THROW({\n  int n = 5;\n  Bar(&n);\n});\n```\n\n_Availability_: Linux, Windows, Mac; since version 1.1.0.\n\n## Predicate Assertions for Better Error Messages ##\n\nEven though Google Test has a rich set of assertions, they can never be\ncomplete, as it's impossible (nor a good idea) to anticipate all the scenarios\na user might run into. Therefore, sometimes a user has to use `EXPECT_TRUE()`\nto check a complex expression, for lack of a better macro. This has the problem\nof not showing you the values of the parts of the expression, making it hard to\nunderstand what went wrong. As a workaround, some users choose to construct the\nfailure message by themselves, streaming it into `EXPECT_TRUE()`. However, this\nis awkward especially when the expression has side-effects or is expensive to\nevaluate.\n\nGoogle Test gives you three different options to solve this problem:\n\n### Using an Existing Boolean Function ###\n\nIf you already have a function or a functor that returns `bool` (or a type\nthat can be implicitly converted to `bool`), you can use it in a _predicate\nassertion_ to get the function arguments printed for free:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_PRED1(`_pred1, val1_`);`       | `EXPECT_PRED1(`_pred1, val1_`);` | _pred1(val1)_ returns true |\n| `ASSERT_PRED2(`_pred2, val1, val2_`);` | `EXPECT_PRED2(`_pred2, val1, val2_`);` |  _pred2(val1, val2)_ returns true |\n|  ...                | ...                    | ...          |\n\nIn the above, _predn_ is an _n_-ary predicate function or functor, where\n_val1_, _val2_, ..., and _valn_ are its arguments. The assertion succeeds\nif the predicate returns `true` when applied to the given arguments, and fails\notherwise. When the assertion fails, it prints the value of each argument. In\neither case, the arguments are evaluated exactly once.\n\nHere's an example. Given\n\n```\n// Returns true iff m and n have no common divisors except 1.\nbool MutuallyPrime(int m, int n) { ... }\nconst int a = 3;\nconst int b = 4;\nconst int c = 10;\n```\n\nthe assertion `EXPECT_PRED2(MutuallyPrime, a, b);` will succeed, while the\nassertion `EXPECT_PRED2(MutuallyPrime, b, c);` will fail with the message\n\n<pre>\n!MutuallyPrime(b, c) is false, where<br>\nb is 4<br>\nc is 10<br>\n</pre>\n\n**Notes:**\n\n  1. If you see a compiler error \"no matching function to call\" when using `ASSERT_PRED*` or `EXPECT_PRED*`, please see [this](V1_7_FAQ.md#the-compiler-complains-about-undefined-references-to-some-static-const-member-variables-but-i-did-define-them-in-the-class-body-whats-wrong) for how to resolve it.\n  1. Currently we only provide predicate assertions of arity <= 5. If you need a higher-arity assertion, let us know.\n\n_Availability_: Linux, Windows, Mac\n\n### Using a Function That Returns an AssertionResult ###\n\nWhile `EXPECT_PRED*()` and friends are handy for a quick job, the\nsyntax is not satisfactory: you have to use different macros for\ndifferent arities, and it feels more like Lisp than C++.  The\n`::testing::AssertionResult` class solves this problem.\n\nAn `AssertionResult` object represents the result of an assertion\n(whether it's a success or a failure, and an associated message).  You\ncan create an `AssertionResult` using one of these factory\nfunctions:\n\n```\nnamespace testing {\n\n// Returns an AssertionResult object to indicate that an assertion has\n// succeeded.\nAssertionResult AssertionSuccess();\n\n// Returns an AssertionResult object to indicate that an assertion has\n// failed.\nAssertionResult AssertionFailure();\n\n}\n```\n\nYou can then use the `<<` operator to stream messages to the\n`AssertionResult` object.\n\nTo provide more readable messages in Boolean assertions\n(e.g. `EXPECT_TRUE()`), write a predicate function that returns\n`AssertionResult` instead of `bool`. For example, if you define\n`IsEven()` as:\n\n```\n::testing::AssertionResult IsEven(int n) {\n  if ((n % 2) == 0)\n    return ::testing::AssertionSuccess();\n  else\n    return ::testing::AssertionFailure() << n << \" is odd\";\n}\n```\n\ninstead of:\n\n```\nbool IsEven(int n) {\n  return (n % 2) == 0;\n}\n```\n\nthe failed assertion `EXPECT_TRUE(IsEven(Fib(4)))` will print:\n\n<pre>\nValue of: IsEven(Fib(4))<br>\nActual: false (*3 is odd*)<br>\nExpected: true<br>\n</pre>\n\ninstead of a more opaque\n\n<pre>\nValue of: IsEven(Fib(4))<br>\nActual: false<br>\nExpected: true<br>\n</pre>\n\nIf you want informative messages in `EXPECT_FALSE` and `ASSERT_FALSE`\nas well, and are fine with making the predicate slower in the success\ncase, you can supply a success message:\n\n```\n::testing::AssertionResult IsEven(int n) {\n  if ((n % 2) == 0)\n    return ::testing::AssertionSuccess() << n << \" is even\";\n  else\n    return ::testing::AssertionFailure() << n << \" is odd\";\n}\n```\n\nThen the statement `EXPECT_FALSE(IsEven(Fib(6)))` will print\n\n<pre>\nValue of: IsEven(Fib(6))<br>\nActual: true (8 is even)<br>\nExpected: false<br>\n</pre>\n\n_Availability_: Linux, Windows, Mac; since version 1.4.1.\n\n### Using a Predicate-Formatter ###\n\nIf you find the default message generated by `(ASSERT|EXPECT)_PRED*` and\n`(ASSERT|EXPECT)_(TRUE|FALSE)` unsatisfactory, or some arguments to your\npredicate do not support streaming to `ostream`, you can instead use the\nfollowing _predicate-formatter assertions_ to _fully_ customize how the\nmessage is formatted:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_PRED_FORMAT1(`_pred\\_format1, val1_`);`        | `EXPECT_PRED_FORMAT1(`_pred\\_format1, val1_`); | _pred\\_format1(val1)_ is successful |\n| `ASSERT_PRED_FORMAT2(`_pred\\_format2, val1, val2_`);` | `EXPECT_PRED_FORMAT2(`_pred\\_format2, val1, val2_`);` | _pred\\_format2(val1, val2)_ is successful |\n| `...`               | `...`                  | `...`        |\n\nThe difference between this and the previous two groups of macros is that instead of\na predicate, `(ASSERT|EXPECT)_PRED_FORMAT*` take a _predicate-formatter_\n(_pred\\_formatn_), which is a function or functor with the signature:\n\n`::testing::AssertionResult PredicateFormattern(const char* `_expr1_`, const char* `_expr2_`, ... const char* `_exprn_`, T1 `_val1_`, T2 `_val2_`, ... Tn `_valn_`);`\n\nwhere _val1_, _val2_, ..., and _valn_ are the values of the predicate\narguments, and _expr1_, _expr2_, ..., and _exprn_ are the corresponding\nexpressions as they appear in the source code. The types `T1`, `T2`, ..., and\n`Tn` can be either value types or reference types. For example, if an\nargument has type `Foo`, you can declare it as either `Foo` or `const Foo&`,\nwhichever is appropriate.\n\nA predicate-formatter returns a `::testing::AssertionResult` object to indicate\nwhether the assertion has succeeded or not. The only way to create such an\nobject is to call one of these factory functions:\n\nAs an example, let's improve the failure message in the previous example, which uses `EXPECT_PRED2()`:\n\n```\n// Returns the smallest prime common divisor of m and n,\n// or 1 when m and n are mutually prime.\nint SmallestPrimeCommonDivisor(int m, int n) { ... }\n\n// A predicate-formatter for asserting that two integers are mutually prime.\n::testing::AssertionResult AssertMutuallyPrime(const char* m_expr,\n                                               const char* n_expr,\n                                               int m,\n                                               int n) {\n  if (MutuallyPrime(m, n))\n    return ::testing::AssertionSuccess();\n\n  return ::testing::AssertionFailure()\n      << m_expr << \" and \" << n_expr << \" (\" << m << \" and \" << n\n      << \") are not mutually prime, \" << \"as they have a common divisor \"\n      << SmallestPrimeCommonDivisor(m, n);\n}\n```\n\nWith this predicate-formatter, we can use\n\n```\nEXPECT_PRED_FORMAT2(AssertMutuallyPrime, b, c);\n```\n\nto generate the message\n\n<pre>\nb and c (4 and 10) are not mutually prime, as they have a common divisor 2.<br>\n</pre>\n\nAs you may have realized, many of the assertions we introduced earlier are\nspecial cases of `(EXPECT|ASSERT)_PRED_FORMAT*`. In fact, most of them are\nindeed defined using `(EXPECT|ASSERT)_PRED_FORMAT*`.\n\n_Availability_: Linux, Windows, Mac.\n\n\n## Floating-Point Comparison ##\n\nComparing floating-point numbers is tricky. Due to round-off errors, it is\nvery unlikely that two floating-points will match exactly. Therefore,\n`ASSERT_EQ` 's naive comparison usually doesn't work. And since floating-points\ncan have a wide value range, no single fixed error bound works. It's better to\ncompare by a fixed relative error bound, except for values close to 0 due to\nthe loss of precision there.\n\nIn general, for floating-point comparison to make sense, the user needs to\ncarefully choose the error bound. If they don't want or care to, comparing in\nterms of Units in the Last Place (ULPs) is a good default, and Google Test\nprovides assertions to do this. Full details about ULPs are quite long; if you\nwant to learn more, see\n[this article on float comparison](http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm).\n\n### Floating-Point Macros ###\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_FLOAT_EQ(`_expected, actual_`);`  | `EXPECT_FLOAT_EQ(`_expected, actual_`);` | the two `float` values are almost equal |\n| `ASSERT_DOUBLE_EQ(`_expected, actual_`);` | `EXPECT_DOUBLE_EQ(`_expected, actual_`);` | the two `double` values are almost equal |\n\nBy \"almost equal\", we mean the two values are within 4 ULP's from each\nother.\n\nThe following assertions allow you to choose the acceptable error bound:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_NEAR(`_val1, val2, abs\\_error_`);` | `EXPECT_NEAR`_(val1, val2, abs\\_error_`);` | the difference between _val1_ and _val2_ doesn't exceed the given absolute error |\n\n_Availability_: Linux, Windows, Mac.\n\n### Floating-Point Predicate-Format Functions ###\n\nSome floating-point operations are useful, but not that often used. In order\nto avoid an explosion of new macros, we provide them as predicate-format\nfunctions that can be used in predicate assertion macros (e.g.\n`EXPECT_PRED_FORMAT2`, etc).\n\n```\nEXPECT_PRED_FORMAT2(::testing::FloatLE, val1, val2);\nEXPECT_PRED_FORMAT2(::testing::DoubleLE, val1, val2);\n```\n\nVerifies that _val1_ is less than, or almost equal to, _val2_. You can\nreplace `EXPECT_PRED_FORMAT2` in the above table with `ASSERT_PRED_FORMAT2`.\n\n_Availability_: Linux, Windows, Mac.\n\n## Windows HRESULT assertions ##\n\nThese assertions test for `HRESULT` success or failure.\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_HRESULT_SUCCEEDED(`_expression_`);` | `EXPECT_HRESULT_SUCCEEDED(`_expression_`);` | _expression_ is a success `HRESULT` |\n| `ASSERT_HRESULT_FAILED(`_expression_`);`    | `EXPECT_HRESULT_FAILED(`_expression_`);`    | _expression_ is a failure `HRESULT` |\n\nThe generated output contains the human-readable error message\nassociated with the `HRESULT` code returned by _expression_.\n\nYou might use them like this:\n\n```\nCComPtr shell;\nASSERT_HRESULT_SUCCEEDED(shell.CoCreateInstance(L\"Shell.Application\"));\nCComVariant empty;\nASSERT_HRESULT_SUCCEEDED(shell->ShellExecute(CComBSTR(url), empty, empty, empty, empty));\n```\n\n_Availability_: Windows.\n\n## Type Assertions ##\n\nYou can call the function\n```\n::testing::StaticAssertTypeEq<T1, T2>();\n```\nto assert that types `T1` and `T2` are the same.  The function does\nnothing if the assertion is satisfied.  If the types are different,\nthe function call will fail to compile, and the compiler error message\nwill likely (depending on the compiler) show you the actual values of\n`T1` and `T2`.  This is mainly useful inside template code.\n\n_Caveat:_ When used inside a member function of a class template or a\nfunction template, `StaticAssertTypeEq<T1, T2>()` is effective _only if_\nthe function is instantiated.  For example, given:\n```\ntemplate <typename T> class Foo {\n public:\n  void Bar() { ::testing::StaticAssertTypeEq<int, T>(); }\n};\n```\nthe code:\n```\nvoid Test1() { Foo<bool> foo; }\n```\nwill _not_ generate a compiler error, as `Foo<bool>::Bar()` is never\nactually instantiated.  Instead, you need:\n```\nvoid Test2() { Foo<bool> foo; foo.Bar(); }\n```\nto cause a compiler error.\n\n_Availability:_ Linux, Windows, Mac; since version 1.3.0.\n\n## Assertion Placement ##\n\nYou can use assertions in any C++ function. In particular, it doesn't\nhave to be a method of the test fixture class. The one constraint is\nthat assertions that generate a fatal failure (`FAIL*` and `ASSERT_*`)\ncan only be used in void-returning functions. This is a consequence of\nGoogle Test not using exceptions. By placing it in a non-void function\nyou'll get a confusing compile error like\n`\"error: void value not ignored as it ought to be\"`.\n\nIf you need to use assertions in a function that returns non-void, one option\nis to make the function return the value in an out parameter instead. For\nexample, you can rewrite `T2 Foo(T1 x)` to `void Foo(T1 x, T2* result)`. You\nneed to make sure that `*result` contains some sensible value even when the\nfunction returns prematurely. As the function now returns `void`, you can use\nany assertion inside of it.\n\nIf changing the function's type is not an option, you should just use\nassertions that generate non-fatal failures, such as `ADD_FAILURE*` and\n`EXPECT_*`.\n\n_Note_: Constructors and destructors are not considered void-returning\nfunctions, according to the C++ language specification, and so you may not use\nfatal assertions in them. You'll get a compilation error if you try. A simple\nworkaround is to transfer the entire body of the constructor or destructor to a\nprivate void-returning method. However, you should be aware that a fatal\nassertion failure in a constructor does not terminate the current test, as your\nintuition might suggest; it merely returns from the constructor early, possibly\nleaving your object in a partially-constructed state. Likewise, a fatal\nassertion failure in a destructor may leave your object in a\npartially-destructed state. Use assertions carefully in these situations!\n\n# Teaching Google Test How to Print Your Values #\n\nWhen a test assertion such as `EXPECT_EQ` fails, Google Test prints the\nargument values to help you debug.  It does this using a\nuser-extensible value printer.\n\nThis printer knows how to print built-in C++ types, native arrays, STL\ncontainers, and any type that supports the `<<` operator.  For other\ntypes, it prints the raw bytes in the value and hopes that you the\nuser can figure it out.\n\nAs mentioned earlier, the printer is _extensible_.  That means\nyou can teach it to do a better job at printing your particular type\nthan to dump the bytes.  To do that, define `<<` for your type:\n\n```\n#include <iostream>\n\nnamespace foo {\n\nclass Bar { ... };  // We want Google Test to be able to print instances of this.\n\n// It's important that the << operator is defined in the SAME\n// namespace that defines Bar.  C++'s look-up rules rely on that.\n::std::ostream& operator<<(::std::ostream& os, const Bar& bar) {\n  return os << bar.DebugString();  // whatever needed to print bar to os\n}\n\n}  // namespace foo\n```\n\nSometimes, this might not be an option: your team may consider it bad\nstyle to have a `<<` operator for `Bar`, or `Bar` may already have a\n`<<` operator that doesn't do what you want (and you cannot change\nit).  If so, you can instead define a `PrintTo()` function like this:\n\n```\n#include <iostream>\n\nnamespace foo {\n\nclass Bar { ... };\n\n// It's important that PrintTo() is defined in the SAME\n// namespace that defines Bar.  C++'s look-up rules rely on that.\nvoid PrintTo(const Bar& bar, ::std::ostream* os) {\n  *os << bar.DebugString();  // whatever needed to print bar to os\n}\n\n}  // namespace foo\n```\n\nIf you have defined both `<<` and `PrintTo()`, the latter will be used\nwhen Google Test is concerned.  This allows you to customize how the value\nappears in Google Test's output without affecting code that relies on the\nbehavior of its `<<` operator.\n\nIf you want to print a value `x` using Google Test's value printer\nyourself, just call `::testing::PrintToString(`_x_`)`, which\nreturns an `std::string`:\n\n```\nvector<pair<Bar, int> > bar_ints = GetBarIntVector();\n\nEXPECT_TRUE(IsCorrectBarIntVector(bar_ints))\n    << \"bar_ints = \" << ::testing::PrintToString(bar_ints);\n```\n\n# Death Tests #\n\nIn many applications, there are assertions that can cause application failure\nif a condition is not met. These sanity checks, which ensure that the program\nis in a known good state, are there to fail at the earliest possible time after\nsome program state is corrupted. If the assertion checks the wrong condition,\nthen the program may proceed in an erroneous state, which could lead to memory\ncorruption, security holes, or worse. Hence it is vitally important to test\nthat such assertion statements work as expected.\n\nSince these precondition checks cause the processes to die, we call such tests\n_death tests_. More generally, any test that checks that a program terminates\n(except by throwing an exception) in an expected fashion is also a death test.\n\nNote that if a piece of code throws an exception, we don't consider it \"death\"\nfor the purpose of death tests, as the caller of the code could catch the exception\nand avoid the crash. If you want to verify exceptions thrown by your code,\nsee [Exception Assertions](#exception-assertions).\n\nIf you want to test `EXPECT_*()/ASSERT_*()` failures in your test code, see [Catching Failures](#catching-failures).\n\n## How to Write a Death Test ##\n\nGoogle Test has the following macros to support death tests:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_DEATH(`_statement, regex_`); | `EXPECT_DEATH(`_statement, regex_`); | _statement_ crashes with the given error |\n| `ASSERT_DEATH_IF_SUPPORTED(`_statement, regex_`); | `EXPECT_DEATH_IF_SUPPORTED(`_statement, regex_`); | if death tests are supported, verifies that _statement_ crashes with the given error; otherwise verifies nothing |\n| `ASSERT_EXIT(`_statement, predicate, regex_`); | `EXPECT_EXIT(`_statement, predicate, regex_`); |_statement_ exits with the given error and its exit code matches _predicate_ |\n\nwhere _statement_ is a statement that is expected to cause the process to\ndie, _predicate_ is a function or function object that evaluates an integer\nexit status, and _regex_ is a regular expression that the stderr output of\n_statement_ is expected to match. Note that _statement_ can be _any valid\nstatement_ (including _compound statement_) and doesn't have to be an\nexpression.\n\nAs usual, the `ASSERT` variants abort the current test function, while the\n`EXPECT` variants do not.\n\n**Note:** We use the word \"crash\" here to mean that the process\nterminates with a _non-zero_ exit status code.  There are two\npossibilities: either the process has called `exit()` or `_exit()`\nwith a non-zero value, or it may be killed by a signal.\n\nThis means that if _statement_ terminates the process with a 0 exit\ncode, it is _not_ considered a crash by `EXPECT_DEATH`.  Use\n`EXPECT_EXIT` instead if this is the case, or if you want to restrict\nthe exit code more precisely.\n\nA predicate here must accept an `int` and return a `bool`. The death test\nsucceeds only if the predicate returns `true`. Google Test defines a few\npredicates that handle the most common cases:\n\n```\n::testing::ExitedWithCode(exit_code)\n```\n\nThis expression is `true` if the program exited normally with the given exit\ncode.\n\n```\n::testing::KilledBySignal(signal_number)  // Not available on Windows.\n```\n\nThis expression is `true` if the program was killed by the given signal.\n\nThe `*_DEATH` macros are convenient wrappers for `*_EXIT` that use a predicate\nthat verifies the process' exit code is non-zero.\n\nNote that a death test only cares about three things:\n\n  1. does _statement_ abort or exit the process?\n  1. (in the case of `ASSERT_EXIT` and `EXPECT_EXIT`) does the exit status satisfy _predicate_?  Or (in the case of `ASSERT_DEATH` and `EXPECT_DEATH`) is the exit status non-zero?  And\n  1. does the stderr output match _regex_?\n\nIn particular, if _statement_ generates an `ASSERT_*` or `EXPECT_*` failure, it will **not** cause the death test to fail, as Google Test assertions don't abort the process.\n\nTo write a death test, simply use one of the above macros inside your test\nfunction. For example,\n\n```\nTEST(MyDeathTest, Foo) {\n  // This death test uses a compound statement.\n  ASSERT_DEATH({ int n = 5; Foo(&n); }, \"Error on line .* of Foo()\");\n}\nTEST(MyDeathTest, NormalExit) {\n  EXPECT_EXIT(NormalExit(), ::testing::ExitedWithCode(0), \"Success\");\n}\nTEST(MyDeathTest, KillMyself) {\n  EXPECT_EXIT(KillMyself(), ::testing::KilledBySignal(SIGKILL), \"Sending myself unblockable signal\");\n}\n```\n\nverifies that:\n\n  * calling `Foo(5)` causes the process to die with the given error message,\n  * calling `NormalExit()` causes the process to print `\"Success\"` to stderr and exit with exit code 0, and\n  * calling `KillMyself()` kills the process with signal `SIGKILL`.\n\nThe test function body may contain other assertions and statements as well, if\nnecessary.\n\n_Important:_ We strongly recommend you to follow the convention of naming your\ntest case (not test) `*DeathTest` when it contains a death test, as\ndemonstrated in the above example. The `Death Tests And Threads` section below\nexplains why.\n\nIf a test fixture class is shared by normal tests and death tests, you\ncan use typedef to introduce an alias for the fixture class and avoid\nduplicating its code:\n```\nclass FooTest : public ::testing::Test { ... };\n\ntypedef FooTest FooDeathTest;\n\nTEST_F(FooTest, DoesThis) {\n  // normal test\n}\n\nTEST_F(FooDeathTest, DoesThat) {\n  // death test\n}\n```\n\n_Availability:_ Linux, Windows (requires MSVC 8.0 or above), Cygwin, and Mac (the latter three are supported since v1.3.0).  `(ASSERT|EXPECT)_DEATH_IF_SUPPORTED` are new in v1.4.0.\n\n## Regular Expression Syntax ##\n\nOn POSIX systems (e.g. Linux, Cygwin, and Mac), Google Test uses the\n[POSIX extended regular expression](http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_04)\nsyntax in death tests. To learn about this syntax, you may want to read this [Wikipedia entry](http://en.wikipedia.org/wiki/Regular_expression#POSIX_Extended_Regular_Expressions).\n\nOn Windows, Google Test uses its own simple regular expression\nimplementation. It lacks many features you can find in POSIX extended\nregular expressions.  For example, we don't support union (`\"x|y\"`),\ngrouping (`\"(xy)\"`), brackets (`\"[xy]\"`), and repetition count\n(`\"x{5,7}\"`), among others. Below is what we do support (Letter `A` denotes a\nliteral character, period (`.`), or a single `\\\\` escape sequence; `x`\nand `y` denote regular expressions.):\n\n| `c` | matches any literal character `c` |\n|:----|:----------------------------------|\n| `\\\\d` | matches any decimal digit         |\n| `\\\\D` | matches any character that's not a decimal digit |\n| `\\\\f` | matches `\\f`                      |\n| `\\\\n` | matches `\\n`                      |\n| `\\\\r` | matches `\\r`                      |\n| `\\\\s` | matches any ASCII whitespace, including `\\n` |\n| `\\\\S` | matches any character that's not a whitespace |\n| `\\\\t` | matches `\\t`                      |\n| `\\\\v` | matches `\\v`                      |\n| `\\\\w` | matches any letter, `_`, or decimal digit |\n| `\\\\W` | matches any character that `\\\\w` doesn't match |\n| `\\\\c` | matches any literal character `c`, which must be a punctuation |\n| `\\\\.` | matches the `.` character         |\n| `.` | matches any single character except `\\n` |\n| `A?` | matches 0 or 1 occurrences of `A` |\n| `A*` | matches 0 or many occurrences of `A` |\n| `A+` | matches 1 or many occurrences of `A` |\n| `^` | matches the beginning of a string (not that of each line) |\n| `$` | matches the end of a string (not that of each line) |\n| `xy` | matches `x` followed by `y`       |\n\nTo help you determine which capability is available on your system,\nGoogle Test defines macro `GTEST_USES_POSIX_RE=1` when it uses POSIX\nextended regular expressions, or `GTEST_USES_SIMPLE_RE=1` when it uses\nthe simple version.  If you want your death tests to work in both\ncases, you can either `#if` on these macros or use the more limited\nsyntax only.\n\n## How It Works ##\n\nUnder the hood, `ASSERT_EXIT()` spawns a new process and executes the\ndeath test statement in that process. The details of of how precisely\nthat happens depend on the platform and the variable\n`::testing::GTEST_FLAG(death_test_style)` (which is initialized from the\ncommand-line flag `--gtest_death_test_style`).\n\n  * On POSIX systems, `fork()` (or `clone()` on Linux) is used to spawn the child, after which:\n    * If the variable's value is `\"fast\"`, the death test statement is immediately executed.\n    * If the variable's value is `\"threadsafe\"`, the child process re-executes the unit test binary just as it was originally invoked, but with some extra flags to cause just the single death test under consideration to be run.\n  * On Windows, the child is spawned using the `CreateProcess()` API, and re-executes the binary to cause just the single death test under consideration to be run - much like the `threadsafe` mode on POSIX.\n\nOther values for the variable are illegal and will cause the death test to\nfail. Currently, the flag's default value is `\"fast\"`. However, we reserve the\nright to change it in the future. Therefore, your tests should not depend on\nthis.\n\nIn either case, the parent process waits for the child process to complete, and checks that\n\n  1. the child's exit status satisfies the predicate, and\n  1. the child's stderr matches the regular expression.\n\nIf the death test statement runs to completion without dying, the child\nprocess will nonetheless terminate, and the assertion fails.\n\n## Death Tests And Threads ##\n\nThe reason for the two death test styles has to do with thread safety. Due to\nwell-known problems with forking in the presence of threads, death tests should\nbe run in a single-threaded context. Sometimes, however, it isn't feasible to\narrange that kind of environment. For example, statically-initialized modules\nmay start threads before main is ever reached. Once threads have been created,\nit may be difficult or impossible to clean them up.\n\nGoogle Test has three features intended to raise awareness of threading issues.\n\n  1. A warning is emitted if multiple threads are running when a death test is encountered.\n  1. Test cases with a name ending in \"DeathTest\" are run before all other tests.\n  1. It uses `clone()` instead of `fork()` to spawn the child process on Linux (`clone()` is not available on Cygwin and Mac), as `fork()` is more likely to cause the child to hang when the parent process has multiple threads.\n\nIt's perfectly fine to create threads inside a death test statement; they are\nexecuted in a separate process and cannot affect the parent.\n\n## Death Test Styles ##\n\nThe \"threadsafe\" death test style was introduced in order to help mitigate the\nrisks of testing in a possibly multithreaded environment. It trades increased\ntest execution time (potentially dramatically so) for improved thread safety.\nWe suggest using the faster, default \"fast\" style unless your test has specific\nproblems with it.\n\nYou can choose a particular style of death tests by setting the flag\nprogrammatically:\n\n```\n::testing::FLAGS_gtest_death_test_style = \"threadsafe\";\n```\n\nYou can do this in `main()` to set the style for all death tests in the\nbinary, or in individual tests. Recall that flags are saved before running each\ntest and restored afterwards, so you need not do that yourself. For example:\n\n```\nTEST(MyDeathTest, TestOne) {\n  ::testing::FLAGS_gtest_death_test_style = \"threadsafe\";\n  // This test is run in the \"threadsafe\" style:\n  ASSERT_DEATH(ThisShouldDie(), \"\");\n}\n\nTEST(MyDeathTest, TestTwo) {\n  // This test is run in the \"fast\" style:\n  ASSERT_DEATH(ThisShouldDie(), \"\");\n}\n\nint main(int argc, char** argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n  ::testing::FLAGS_gtest_death_test_style = \"fast\";\n  return RUN_ALL_TESTS();\n}\n```\n\n## Caveats ##\n\nThe _statement_ argument of `ASSERT_EXIT()` can be any valid C++ statement.\nIf it leaves the current function via a `return` statement or by throwing an exception,\nthe death test is considered to have failed.  Some Google Test macros may return\nfrom the current function (e.g. `ASSERT_TRUE()`), so be sure to avoid them in _statement_.\n\nSince _statement_ runs in the child process, any in-memory side effect (e.g.\nmodifying a variable, releasing memory, etc) it causes will _not_ be observable\nin the parent process. In particular, if you release memory in a death test,\nyour program will fail the heap check as the parent process will never see the\nmemory reclaimed. To solve this problem, you can\n\n  1. try not to free memory in a death test;\n  1. free the memory again in the parent process; or\n  1. do not use the heap checker in your program.\n\nDue to an implementation detail, you cannot place multiple death test\nassertions on the same line; otherwise, compilation will fail with an unobvious\nerror message.\n\nDespite the improved thread safety afforded by the \"threadsafe\" style of death\ntest, thread problems such as deadlock are still possible in the presence of\nhandlers registered with `pthread_atfork(3)`.\n\n# Using Assertions in Sub-routines #\n\n## Adding Traces to Assertions ##\n\nIf a test sub-routine is called from several places, when an assertion\ninside it fails, it can be hard to tell which invocation of the\nsub-routine the failure is from.  You can alleviate this problem using\nextra logging or custom failure messages, but that usually clutters up\nyour tests. A better solution is to use the `SCOPED_TRACE` macro:\n\n| `SCOPED_TRACE(`_message_`);` |\n|:-----------------------------|\n\nwhere _message_ can be anything streamable to `std::ostream`. This\nmacro will cause the current file name, line number, and the given\nmessage to be added in every failure message. The effect will be\nundone when the control leaves the current lexical scope.\n\nFor example,\n\n```\n10: void Sub1(int n) {\n11:   EXPECT_EQ(1, Bar(n));\n12:   EXPECT_EQ(2, Bar(n + 1));\n13: }\n14:\n15: TEST(FooTest, Bar) {\n16:   {\n17:     SCOPED_TRACE(\"A\");  // This trace point will be included in\n18:                         // every failure in this scope.\n19:     Sub1(1);\n20:   }\n21:   // Now it won't.\n22:   Sub1(9);\n23: }\n```\n\ncould result in messages like these:\n\n```\npath/to/foo_test.cc:11: Failure\nValue of: Bar(n)\nExpected: 1\n  Actual: 2\n   Trace:\npath/to/foo_test.cc:17: A\n\npath/to/foo_test.cc:12: Failure\nValue of: Bar(n + 1)\nExpected: 2\n  Actual: 3\n```\n\nWithout the trace, it would've been difficult to know which invocation\nof `Sub1()` the two failures come from respectively. (You could add an\nextra message to each assertion in `Sub1()` to indicate the value of\n`n`, but that's tedious.)\n\nSome tips on using `SCOPED_TRACE`:\n\n  1. With a suitable message, it's often enough to use `SCOPED_TRACE` at the beginning of a sub-routine, instead of at each call site.\n  1. When calling sub-routines inside a loop, make the loop iterator part of the message in `SCOPED_TRACE` such that you can know which iteration the failure is from.\n  1. Sometimes the line number of the trace point is enough for identifying the particular invocation of a sub-routine. In this case, you don't have to choose a unique message for `SCOPED_TRACE`. You can simply use `\"\"`.\n  1. You can use `SCOPED_TRACE` in an inner scope when there is one in the outer scope. In this case, all active trace points will be included in the failure messages, in reverse order they are encountered.\n  1. The trace dump is clickable in Emacs' compilation buffer - hit return on a line number and you'll be taken to that line in the source file!\n\n_Availability:_ Linux, Windows, Mac.\n\n## Propagating Fatal Failures ##\n\nA common pitfall when using `ASSERT_*` and `FAIL*` is not understanding that\nwhen they fail they only abort the _current function_, not the entire test. For\nexample, the following test will segfault:\n```\nvoid Subroutine() {\n  // Generates a fatal failure and aborts the current function.\n  ASSERT_EQ(1, 2);\n  // The following won't be executed.\n  ...\n}\n\nTEST(FooTest, Bar) {\n  Subroutine();\n  // The intended behavior is for the fatal failure\n  // in Subroutine() to abort the entire test.\n  // The actual behavior: the function goes on after Subroutine() returns.\n  int* p = NULL;\n  *p = 3; // Segfault!\n}\n```\n\nSince we don't use exceptions, it is technically impossible to\nimplement the intended behavior here.  To alleviate this, Google Test\nprovides two solutions.  You could use either the\n`(ASSERT|EXPECT)_NO_FATAL_FAILURE` assertions or the\n`HasFatalFailure()` function.  They are described in the following two\nsubsections.\n\n### Asserting on Subroutines ###\n\nAs shown above, if your test calls a subroutine that has an `ASSERT_*`\nfailure in it, the test will continue after the subroutine\nreturns. This may not be what you want.\n\nOften people want fatal failures to propagate like exceptions.  For\nthat Google Test offers the following macros:\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_NO_FATAL_FAILURE(`_statement_`);` | `EXPECT_NO_FATAL_FAILURE(`_statement_`);` | _statement_ doesn't generate any new fatal failures in the current thread. |\n\nOnly failures in the thread that executes the assertion are checked to\ndetermine the result of this type of assertions.  If _statement_\ncreates new threads, failures in these threads are ignored.\n\nExamples:\n\n```\nASSERT_NO_FATAL_FAILURE(Foo());\n\nint i;\nEXPECT_NO_FATAL_FAILURE({\n  i = Bar();\n});\n```\n\n_Availability:_ Linux, Windows, Mac. Assertions from multiple threads\nare currently not supported.\n\n### Checking for Failures in the Current Test ###\n\n`HasFatalFailure()` in the `::testing::Test` class returns `true` if an\nassertion in the current test has suffered a fatal failure. This\nallows functions to catch fatal failures in a sub-routine and return\nearly.\n\n```\nclass Test {\n public:\n  ...\n  static bool HasFatalFailure();\n};\n```\n\nThe typical usage, which basically simulates the behavior of a thrown\nexception, is:\n\n```\nTEST(FooTest, Bar) {\n  Subroutine();\n  // Aborts if Subroutine() had a fatal failure.\n  if (HasFatalFailure())\n    return;\n  // The following won't be executed.\n  ...\n}\n```\n\nIf `HasFatalFailure()` is used outside of `TEST()` , `TEST_F()` , or a test\nfixture, you must add the `::testing::Test::` prefix, as in:\n\n```\nif (::testing::Test::HasFatalFailure())\n  return;\n```\n\nSimilarly, `HasNonfatalFailure()` returns `true` if the current test\nhas at least one non-fatal failure, and `HasFailure()` returns `true`\nif the current test has at least one failure of either kind.\n\n_Availability:_ Linux, Windows, Mac.  `HasNonfatalFailure()` and\n`HasFailure()` are available since version 1.4.0.\n\n# Logging Additional Information #\n\nIn your test code, you can call `RecordProperty(\"key\", value)` to log\nadditional information, where `value` can be either a string or an `int`. The _last_ value recorded for a key will be emitted to the XML output\nif you specify one. For example, the test\n\n```\nTEST_F(WidgetUsageTest, MinAndMaxWidgets) {\n  RecordProperty(\"MaximumWidgets\", ComputeMaxUsage());\n  RecordProperty(\"MinimumWidgets\", ComputeMinUsage());\n}\n```\n\nwill output XML like this:\n\n```\n...\n  <testcase name=\"MinAndMaxWidgets\" status=\"run\" time=\"6\" classname=\"WidgetUsageTest\"\n            MaximumWidgets=\"12\"\n            MinimumWidgets=\"9\" />\n...\n```\n\n_Note_:\n  * `RecordProperty()` is a static member of the `Test` class. Therefore it needs to be prefixed with `::testing::Test::` if used outside of the `TEST` body and the test fixture class.\n  * `key` must be a valid XML attribute name, and cannot conflict with the ones already used by Google Test (`name`, `status`, `time`, `classname`, `type_param`, and `value_param`).\n  * Calling `RecordProperty()` outside of the lifespan of a test is allowed. If it's called outside of a test but between a test case's `SetUpTestCase()` and `TearDownTestCase()` methods, it will be attributed to the XML element for the test case. If it's called outside of all test cases (e.g. in a test environment), it will be attributed to the top-level XML element.\n\n_Availability_: Linux, Windows, Mac.\n\n# Sharing Resources Between Tests in the Same Test Case #\n\n\n\nGoogle Test creates a new test fixture object for each test in order to make\ntests independent and easier to debug. However, sometimes tests use resources\nthat are expensive to set up, making the one-copy-per-test model prohibitively\nexpensive.\n\nIf the tests don't change the resource, there's no harm in them sharing a\nsingle resource copy. So, in addition to per-test set-up/tear-down, Google Test\nalso supports per-test-case set-up/tear-down. To use it:\n\n  1. In your test fixture class (say `FooTest` ), define as `static` some member variables to hold the shared resources.\n  1. In the same test fixture class, define a `static void SetUpTestCase()` function (remember not to spell it as **`SetupTestCase`** with a small `u`!) to set up the shared resources and a `static void TearDownTestCase()` function to tear them down.\n\nThat's it! Google Test automatically calls `SetUpTestCase()` before running the\n_first test_ in the `FooTest` test case (i.e. before creating the first\n`FooTest` object), and calls `TearDownTestCase()` after running the _last test_\nin it (i.e. after deleting the last `FooTest` object). In between, the tests\ncan use the shared resources.\n\nRemember that the test order is undefined, so your code can't depend on a test\npreceding or following another. Also, the tests must either not modify the\nstate of any shared resource, or, if they do modify the state, they must\nrestore the state to its original value before passing control to the next\ntest.\n\nHere's an example of per-test-case set-up and tear-down:\n```\nclass FooTest : public ::testing::Test {\n protected:\n  // Per-test-case set-up.\n  // Called before the first test in this test case.\n  // Can be omitted if not needed.\n  static void SetUpTestCase() {\n    shared_resource_ = new ...;\n  }\n\n  // Per-test-case tear-down.\n  // Called after the last test in this test case.\n  // Can be omitted if not needed.\n  static void TearDownTestCase() {\n    delete shared_resource_;\n    shared_resource_ = NULL;\n  }\n\n  // You can define per-test set-up and tear-down logic as usual.\n  virtual void SetUp() { ... }\n  virtual void TearDown() { ... }\n\n  // Some expensive resource shared by all tests.\n  static T* shared_resource_;\n};\n\nT* FooTest::shared_resource_ = NULL;\n\nTEST_F(FooTest, Test1) {\n  ... you can refer to shared_resource here ...\n}\nTEST_F(FooTest, Test2) {\n  ... you can refer to shared_resource here ...\n}\n```\n\n_Availability:_ Linux, Windows, Mac.\n\n# Global Set-Up and Tear-Down #\n\nJust as you can do set-up and tear-down at the test level and the test case\nlevel, you can also do it at the test program level. Here's how.\n\nFirst, you subclass the `::testing::Environment` class to define a test\nenvironment, which knows how to set-up and tear-down:\n\n```\nclass Environment {\n public:\n  virtual ~Environment() {}\n  // Override this to define how to set up the environment.\n  virtual void SetUp() {}\n  // Override this to define how to tear down the environment.\n  virtual void TearDown() {}\n};\n```\n\nThen, you register an instance of your environment class with Google Test by\ncalling the `::testing::AddGlobalTestEnvironment()` function:\n\n```\nEnvironment* AddGlobalTestEnvironment(Environment* env);\n```\n\nNow, when `RUN_ALL_TESTS()` is called, it first calls the `SetUp()` method of\nthe environment object, then runs the tests if there was no fatal failures, and\nfinally calls `TearDown()` of the environment object.\n\nIt's OK to register multiple environment objects. In this case, their `SetUp()`\nwill be called in the order they are registered, and their `TearDown()` will be\ncalled in the reverse order.\n\nNote that Google Test takes ownership of the registered environment objects.\nTherefore **do not delete them** by yourself.\n\nYou should call `AddGlobalTestEnvironment()` before `RUN_ALL_TESTS()` is\ncalled, probably in `main()`. If you use `gtest_main`, you need to      call\nthis before `main()` starts for it to take effect. One way to do this is to\ndefine a global variable like this:\n\n```\n::testing::Environment* const foo_env = ::testing::AddGlobalTestEnvironment(new FooEnvironment);\n```\n\nHowever, we strongly recommend you to write your own `main()` and call\n`AddGlobalTestEnvironment()` there, as relying on initialization of global\nvariables makes the code harder to read and may cause problems when you\nregister multiple environments from different translation units and the\nenvironments have dependencies among them (remember that the compiler doesn't\nguarantee the order in which global variables from different translation units\nare initialized).\n\n_Availability:_ Linux, Windows, Mac.\n\n\n# Value Parameterized Tests #\n\n_Value-parameterized tests_ allow you to test your code with different\nparameters without writing multiple copies of the same test.\n\nSuppose you write a test for your code and then realize that your code is affected by a presence of a Boolean command line flag.\n\n```\nTEST(MyCodeTest, TestFoo) {\n  // A code to test foo().\n}\n```\n\nUsually people factor their test code into a function with a Boolean parameter in such situations. The function sets the flag, then executes the testing code.\n\n```\nvoid TestFooHelper(bool flag_value) {\n  flag = flag_value;\n  // A code to test foo().\n}\n\nTEST(MyCodeTest, TestFoo) {\n  TestFooHelper(false);\n  TestFooHelper(true);\n}\n```\n\nBut this setup has serious drawbacks. First, when a test assertion fails in your tests, it becomes unclear what value of the parameter caused it to fail. You can stream a clarifying message into your `EXPECT`/`ASSERT` statements, but it you'll have to do it with all of them. Second, you have to add one such helper function per test. What if you have ten tests? Twenty? A hundred?\n\nValue-parameterized tests will let you write your test only once and then easily instantiate and run it with an arbitrary number of parameter values.\n\nHere are some other situations when value-parameterized tests come handy:\n\n  * You want to test different implementations of an OO interface.\n  * You want to test your code over various inputs (a.k.a. data-driven testing). This feature is easy to abuse, so please exercise your good sense when doing it!\n\n## How to Write Value-Parameterized Tests ##\n\nTo write value-parameterized tests, first you should define a fixture\nclass.  It must be derived from both `::testing::Test` and\n`::testing::WithParamInterface<T>` (the latter is a pure interface),\nwhere `T` is the type of your parameter values.  For convenience, you\ncan just derive the fixture class from `::testing::TestWithParam<T>`,\nwhich itself is derived from both `::testing::Test` and\n`::testing::WithParamInterface<T>`. `T` can be any copyable type. If\nit's a raw pointer, you are responsible for managing the lifespan of\nthe pointed values.\n\n```\nclass FooTest : public ::testing::TestWithParam<const char*> {\n  // You can implement all the usual fixture class members here.\n  // To access the test parameter, call GetParam() from class\n  // TestWithParam<T>.\n};\n\n// Or, when you want to add parameters to a pre-existing fixture class:\nclass BaseTest : public ::testing::Test {\n  ...\n};\nclass BarTest : public BaseTest,\n                public ::testing::WithParamInterface<const char*> {\n  ...\n};\n```\n\nThen, use the `TEST_P` macro to define as many test patterns using\nthis fixture as you want.  The `_P` suffix is for \"parameterized\" or\n\"pattern\", whichever you prefer to think.\n\n```\nTEST_P(FooTest, DoesBlah) {\n  // Inside a test, access the test parameter with the GetParam() method\n  // of the TestWithParam<T> class:\n  EXPECT_TRUE(foo.Blah(GetParam()));\n  ...\n}\n\nTEST_P(FooTest, HasBlahBlah) {\n  ...\n}\n```\n\nFinally, you can use `INSTANTIATE_TEST_CASE_P` to instantiate the test\ncase with any set of parameters you want. Google Test defines a number of\nfunctions for generating test parameters. They return what we call\n(surprise!) _parameter generators_. Here is a summary of them,\nwhich are all in the `testing` namespace:\n\n| `Range(begin, end[, step])` | Yields values `{begin, begin+step, begin+step+step, ...}`. The values do not include `end`. `step` defaults to 1. |\n|:----------------------------|:------------------------------------------------------------------------------------------------------------------|\n| `Values(v1, v2, ..., vN)`   | Yields values `{v1, v2, ..., vN}`.                                                                                |\n| `ValuesIn(container)` and `ValuesIn(begin, end)` | Yields values from a C-style array, an STL-style container, or an iterator range `[begin, end)`. `container`, `begin`, and `end` can be expressions whose values are determined at run time.  |\n| `Bool()`                    | Yields sequence `{false, true}`.                                                                                  |\n| `Combine(g1, g2, ..., gN)`  | Yields all combinations (the Cartesian product for the math savvy) of the values generated by the `N` generators. This is only available if your system provides the `<tr1/tuple>` header. If you are sure your system does, and Google Test disagrees, you can override it by defining `GTEST_HAS_TR1_TUPLE=1`. See comments in [include/gtest/internal/gtest-port.h](../include/gtest/internal/gtest-port.h) for more information. |\n\nFor more details, see the comments at the definitions of these functions in the [source code](../include/gtest/gtest-param-test.h).\n\nThe following statement will instantiate tests from the `FooTest` test case\neach with parameter values `\"meeny\"`, `\"miny\"`, and `\"moe\"`.\n\n```\nINSTANTIATE_TEST_CASE_P(InstantiationName,\n                        FooTest,\n                        ::testing::Values(\"meeny\", \"miny\", \"moe\"));\n```\n\nTo distinguish different instances of the pattern (yes, you can\ninstantiate it more than once), the first argument to\n`INSTANTIATE_TEST_CASE_P` is a prefix that will be added to the actual\ntest case name. Remember to pick unique prefixes for different\ninstantiations. The tests from the instantiation above will have these\nnames:\n\n  * `InstantiationName/FooTest.DoesBlah/0` for `\"meeny\"`\n  * `InstantiationName/FooTest.DoesBlah/1` for `\"miny\"`\n  * `InstantiationName/FooTest.DoesBlah/2` for `\"moe\"`\n  * `InstantiationName/FooTest.HasBlahBlah/0` for `\"meeny\"`\n  * `InstantiationName/FooTest.HasBlahBlah/1` for `\"miny\"`\n  * `InstantiationName/FooTest.HasBlahBlah/2` for `\"moe\"`\n\nYou can use these names in [--gtest\\_filter](#running-a-subset-of-the-tests).\n\nThis statement will instantiate all tests from `FooTest` again, each\nwith parameter values `\"cat\"` and `\"dog\"`:\n\n```\nconst char* pets[] = {\"cat\", \"dog\"};\nINSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest,\n                        ::testing::ValuesIn(pets));\n```\n\nThe tests from the instantiation above will have these names:\n\n  * `AnotherInstantiationName/FooTest.DoesBlah/0` for `\"cat\"`\n  * `AnotherInstantiationName/FooTest.DoesBlah/1` for `\"dog\"`\n  * `AnotherInstantiationName/FooTest.HasBlahBlah/0` for `\"cat\"`\n  * `AnotherInstantiationName/FooTest.HasBlahBlah/1` for `\"dog\"`\n\nPlease note that `INSTANTIATE_TEST_CASE_P` will instantiate _all_\ntests in the given test case, whether their definitions come before or\n_after_ the `INSTANTIATE_TEST_CASE_P` statement.\n\nYou can see\n[these](../samples/sample7_unittest.cc)\n[files](../samples/sample8_unittest.cc) for more examples.\n\n_Availability_: Linux, Windows (requires MSVC 8.0 or above), Mac; since version 1.2.0.\n\n## Creating Value-Parameterized Abstract Tests ##\n\nIn the above, we define and instantiate `FooTest` in the same source\nfile. Sometimes you may want to define value-parameterized tests in a\nlibrary and let other people instantiate them later. This pattern is\nknown as <i>abstract tests</i>. As an example of its application, when you\nare designing an interface you can write a standard suite of abstract\ntests (perhaps using a factory function as the test parameter) that\nall implementations of the interface are expected to pass. When\nsomeone implements the interface, he can instantiate your suite to get\nall the interface-conformance tests for free.\n\nTo define abstract tests, you should organize your code like this:\n\n  1. Put the definition of the parameterized test fixture class (e.g. `FooTest`) in a header file, say `foo_param_test.h`. Think of this as _declaring_ your abstract tests.\n  1. Put the `TEST_P` definitions in `foo_param_test.cc`, which includes `foo_param_test.h`. Think of this as _implementing_ your abstract tests.\n\nOnce they are defined, you can instantiate them by including\n`foo_param_test.h`, invoking `INSTANTIATE_TEST_CASE_P()`, and linking\nwith `foo_param_test.cc`. You can instantiate the same abstract test\ncase multiple times, possibly in different source files.\n\n# Typed Tests #\n\nSuppose you have multiple implementations of the same interface and\nwant to make sure that all of them satisfy some common requirements.\nOr, you may have defined several types that are supposed to conform to\nthe same \"concept\" and you want to verify it.  In both cases, you want\nthe same test logic repeated for different types.\n\nWhile you can write one `TEST` or `TEST_F` for each type you want to\ntest (and you may even factor the test logic into a function template\nthat you invoke from the `TEST`), it's tedious and doesn't scale:\nif you want _m_ tests over _n_ types, you'll end up writing _m\\*n_\n`TEST`s.\n\n_Typed tests_ allow you to repeat the same test logic over a list of\ntypes.  You only need to write the test logic once, although you must\nknow the type list when writing typed tests.  Here's how you do it:\n\nFirst, define a fixture class template.  It should be parameterized\nby a type.  Remember to derive it from `::testing::Test`:\n\n```\ntemplate <typename T>\nclass FooTest : public ::testing::Test {\n public:\n  ...\n  typedef std::list<T> List;\n  static T shared_;\n  T value_;\n};\n```\n\nNext, associate a list of types with the test case, which will be\nrepeated for each type in the list:\n\n```\ntypedef ::testing::Types<char, int, unsigned int> MyTypes;\nTYPED_TEST_CASE(FooTest, MyTypes);\n```\n\nThe `typedef` is necessary for the `TYPED_TEST_CASE` macro to parse\ncorrectly.  Otherwise the compiler will think that each comma in the\ntype list introduces a new macro argument.\n\nThen, use `TYPED_TEST()` instead of `TEST_F()` to define a typed test\nfor this test case.  You can repeat this as many times as you want:\n\n```\nTYPED_TEST(FooTest, DoesBlah) {\n  // Inside a test, refer to the special name TypeParam to get the type\n  // parameter.  Since we are inside a derived class template, C++ requires\n  // us to visit the members of FooTest via 'this'.\n  TypeParam n = this->value_;\n\n  // To visit static members of the fixture, add the 'TestFixture::'\n  // prefix.\n  n += TestFixture::shared_;\n\n  // To refer to typedefs in the fixture, add the 'typename TestFixture::'\n  // prefix.  The 'typename' is required to satisfy the compiler.\n  typename TestFixture::List values;\n  values.push_back(n);\n  ...\n}\n\nTYPED_TEST(FooTest, HasPropertyA) { ... }\n```\n\nYou can see `samples/sample6_unittest.cc` for a complete example.\n\n_Availability:_ Linux, Windows (requires MSVC 8.0 or above), Mac;\nsince version 1.1.0.\n\n# Type-Parameterized Tests #\n\n_Type-parameterized tests_ are like typed tests, except that they\ndon't require you to know the list of types ahead of time.  Instead,\nyou can define the test logic first and instantiate it with different\ntype lists later.  You can even instantiate it more than once in the\nsame program.\n\nIf you are designing an interface or concept, you can define a suite\nof type-parameterized tests to verify properties that any valid\nimplementation of the interface/concept should have.  Then, the author\nof each implementation can just instantiate the test suite with his\ntype to verify that it conforms to the requirements, without having to\nwrite similar tests repeatedly.  Here's an example:\n\nFirst, define a fixture class template, as we did with typed tests:\n\n```\ntemplate <typename T>\nclass FooTest : public ::testing::Test {\n  ...\n};\n```\n\nNext, declare that you will define a type-parameterized test case:\n\n```\nTYPED_TEST_CASE_P(FooTest);\n```\n\nThe `_P` suffix is for \"parameterized\" or \"pattern\", whichever you\nprefer to think.\n\nThen, use `TYPED_TEST_P()` to define a type-parameterized test.  You\ncan repeat this as many times as you want:\n\n```\nTYPED_TEST_P(FooTest, DoesBlah) {\n  // Inside a test, refer to TypeParam to get the type parameter.\n  TypeParam n = 0;\n  ...\n}\n\nTYPED_TEST_P(FooTest, HasPropertyA) { ... }\n```\n\nNow the tricky part: you need to register all test patterns using the\n`REGISTER_TYPED_TEST_CASE_P` macro before you can instantiate them.\nThe first argument of the macro is the test case name; the rest are\nthe names of the tests in this test case:\n\n```\nREGISTER_TYPED_TEST_CASE_P(FooTest,\n                           DoesBlah, HasPropertyA);\n```\n\nFinally, you are free to instantiate the pattern with the types you\nwant.  If you put the above code in a header file, you can `#include`\nit in multiple C++ source files and instantiate it multiple times.\n\n```\ntypedef ::testing::Types<char, int, unsigned int> MyTypes;\nINSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);\n```\n\nTo distinguish different instances of the pattern, the first argument\nto the `INSTANTIATE_TYPED_TEST_CASE_P` macro is a prefix that will be\nadded to the actual test case name.  Remember to pick unique prefixes\nfor different instances.\n\nIn the special case where the type list contains only one type, you\ncan write that type directly without `::testing::Types<...>`, like this:\n\n```\nINSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int);\n```\n\nYou can see `samples/sample6_unittest.cc` for a complete example.\n\n_Availability:_ Linux, Windows (requires MSVC 8.0 or above), Mac;\nsince version 1.1.0.\n\n# Testing Private Code #\n\nIf you change your software's internal implementation, your tests should not\nbreak as long as the change is not observable by users. Therefore, per the\n_black-box testing principle_, most of the time you should test your code\nthrough its public interfaces.\n\nIf you still find yourself needing to test internal implementation code,\nconsider if there's a better design that wouldn't require you to do so. If you\nabsolutely have to test non-public interface code though, you can. There are\ntwo cases to consider:\n\n  * Static functions (_not_ the same as static member functions!) or unnamed namespaces, and\n  * Private or protected class members\n\n## Static Functions ##\n\nBoth static functions and definitions/declarations in an unnamed namespace are\nonly visible within the same translation unit. To test them, you can `#include`\nthe entire `.cc` file being tested in your `*_test.cc` file. (`#include`ing `.cc`\nfiles is not a good way to reuse code - you should not do this in production\ncode!)\n\nHowever, a better approach is to move the private code into the\n`foo::internal` namespace, where `foo` is the namespace your project normally\nuses, and put the private declarations in a `*-internal.h` file. Your\nproduction `.cc` files and your tests are allowed to include this internal\nheader, but your clients are not. This way, you can fully test your internal\nimplementation without leaking it to your clients.\n\n## Private Class Members ##\n\nPrivate class members are only accessible from within the class or by friends.\nTo access a class' private members, you can declare your test fixture as a\nfriend to the class and define accessors in your fixture. Tests using the\nfixture can then access the private members of your production class via the\naccessors in the fixture. Note that even though your fixture is a friend to\nyour production class, your tests are not automatically friends to it, as they\nare technically defined in sub-classes of the fixture.\n\nAnother way to test private members is to refactor them into an implementation\nclass, which is then declared in a `*-internal.h` file. Your clients aren't\nallowed to include this header but your tests can. Such is called the Pimpl\n(Private Implementation) idiom.\n\nOr, you can declare an individual test as a friend of your class by adding this\nline in the class body:\n\n```\nFRIEND_TEST(TestCaseName, TestName);\n```\n\nFor example,\n```\n// foo.h\n#include \"gtest/gtest_prod.h\"\n\n// Defines FRIEND_TEST.\nclass Foo {\n  ...\n private:\n  FRIEND_TEST(FooTest, BarReturnsZeroOnNull);\n  int Bar(void* x);\n};\n\n// foo_test.cc\n...\nTEST(FooTest, BarReturnsZeroOnNull) {\n  Foo foo;\n  EXPECT_EQ(0, foo.Bar(NULL));\n  // Uses Foo's private member Bar().\n}\n```\n\nPay special attention when your class is defined in a namespace, as you should\ndefine your test fixtures and tests in the same namespace if you want them to\nbe friends of your class. For example, if the code to be tested looks like:\n\n```\nnamespace my_namespace {\n\nclass Foo {\n  friend class FooTest;\n  FRIEND_TEST(FooTest, Bar);\n  FRIEND_TEST(FooTest, Baz);\n  ...\n  definition of the class Foo\n  ...\n};\n\n}  // namespace my_namespace\n```\n\nYour test code should be something like:\n\n```\nnamespace my_namespace {\nclass FooTest : public ::testing::Test {\n protected:\n  ...\n};\n\nTEST_F(FooTest, Bar) { ... }\nTEST_F(FooTest, Baz) { ... }\n\n}  // namespace my_namespace\n```\n\n# Catching Failures #\n\nIf you are building a testing utility on top of Google Test, you'll\nwant to test your utility.  What framework would you use to test it?\nGoogle Test, of course.\n\nThe challenge is to verify that your testing utility reports failures\ncorrectly.  In frameworks that report a failure by throwing an\nexception, you could catch the exception and assert on it.  But Google\nTest doesn't use exceptions, so how do we test that a piece of code\ngenerates an expected failure?\n\n`\"gtest/gtest-spi.h\"` contains some constructs to do this.  After\n`#include`ing this header, you can use\n\n| `EXPECT_FATAL_FAILURE(`_statement, substring_`);` |\n|:--------------------------------------------------|\n\nto assert that _statement_ generates a fatal (e.g. `ASSERT_*`) failure\nwhose message contains the given _substring_, or use\n\n| `EXPECT_NONFATAL_FAILURE(`_statement, substring_`);` |\n|:-----------------------------------------------------|\n\nif you are expecting a non-fatal (e.g. `EXPECT_*`) failure.\n\nFor technical reasons, there are some caveats:\n\n  1. You cannot stream a failure message to either macro.\n  1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot reference local non-static variables or non-static members of `this` object.\n  1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot return a value.\n\n_Note:_ Google Test is designed with threads in mind.  Once the\nsynchronization primitives in `\"gtest/internal/gtest-port.h\"` have\nbeen implemented, Google Test will become thread-safe, meaning that\nyou can then use assertions in multiple threads concurrently.  Before\n\nthat, however, Google Test only supports single-threaded usage.  Once\nthread-safe, `EXPECT_FATAL_FAILURE()` and `EXPECT_NONFATAL_FAILURE()`\nwill capture failures in the current thread only. If _statement_\ncreates new threads, failures in these threads will be ignored.  If\nyou want to capture failures from all threads instead, you should use\nthe following macros:\n\n| `EXPECT_FATAL_FAILURE_ON_ALL_THREADS(`_statement, substring_`);` |\n|:-----------------------------------------------------------------|\n| `EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(`_statement, substring_`);` |\n\n# Getting the Current Test's Name #\n\nSometimes a function may need to know the name of the currently running test.\nFor example, you may be using the `SetUp()` method of your test fixture to set\nthe golden file name based on which test is running. The `::testing::TestInfo`\nclass has this information:\n\n```\nnamespace testing {\n\nclass TestInfo {\n public:\n  // Returns the test case name and the test name, respectively.\n  //\n  // Do NOT delete or free the return value - it's managed by the\n  // TestInfo class.\n  const char* test_case_name() const;\n  const char* name() const;\n};\n\n}  // namespace testing\n```\n\n\n> To obtain a `TestInfo` object for the currently running test, call\n`current_test_info()` on the `UnitTest` singleton object:\n\n```\n// Gets information about the currently running test.\n// Do NOT delete the returned object - it's managed by the UnitTest class.\nconst ::testing::TestInfo* const test_info =\n  ::testing::UnitTest::GetInstance()->current_test_info();\nprintf(\"We are in test %s of test case %s.\\n\",\n       test_info->name(), test_info->test_case_name());\n```\n\n`current_test_info()` returns a null pointer if no test is running. In\nparticular, you cannot find the test case name in `TestCaseSetUp()`,\n`TestCaseTearDown()` (where you know the test case name implicitly), or\nfunctions called from them.\n\n_Availability:_ Linux, Windows, Mac.\n\n# Extending Google Test by Handling Test Events #\n\nGoogle Test provides an <b>event listener API</b> to let you receive\nnotifications about the progress of a test program and test\nfailures. The events you can listen to include the start and end of\nthe test program, a test case, or a test method, among others. You may\nuse this API to augment or replace the standard console output,\nreplace the XML output, or provide a completely different form of\noutput, such as a GUI or a database. You can also use test events as\ncheckpoints to implement a resource leak checker, for example.\n\n_Availability:_ Linux, Windows, Mac; since v1.4.0.\n\n## Defining Event Listeners ##\n\nTo define a event listener, you subclass either\n[testing::TestEventListener](../include/gtest/gtest.h#L855)\nor [testing::EmptyTestEventListener](../include/gtest/gtest.h#L905).\nThe former is an (abstract) interface, where <i>each pure virtual method<br>\ncan be overridden to handle a test event</i> (For example, when a test\nstarts, the `OnTestStart()` method will be called.). The latter provides\nan empty implementation of all methods in the interface, such that a\nsubclass only needs to override the methods it cares about.\n\nWhen an event is fired, its context is passed to the handler function\nas an argument. The following argument types are used:\n  * [UnitTest](../include/gtest/gtest.h#L1007) reflects the state of the entire test program,\n  * [TestCase](../include/gtest/gtest.h#L689) has information about a test case, which can contain one or more tests,\n  * [TestInfo](../include/gtest/gtest.h#L599) contains the state of a test, and\n  * [TestPartResult](../include/gtest/gtest-test-part.h#L42) represents the result of a test assertion.\n\nAn event handler function can examine the argument it receives to find\nout interesting information about the event and the test program's\nstate.  Here's an example:\n\n```\n  class MinimalistPrinter : public ::testing::EmptyTestEventListener {\n    // Called before a test starts.\n    virtual void OnTestStart(const ::testing::TestInfo& test_info) {\n      printf(\"*** Test %s.%s starting.\\n\",\n             test_info.test_case_name(), test_info.name());\n    }\n\n    // Called after a failed assertion or a SUCCEED() invocation.\n    virtual void OnTestPartResult(\n        const ::testing::TestPartResult& test_part_result) {\n      printf(\"%s in %s:%d\\n%s\\n\",\n             test_part_result.failed() ? \"*** Failure\" : \"Success\",\n             test_part_result.file_name(),\n             test_part_result.line_number(),\n             test_part_result.summary());\n    }\n\n    // Called after a test ends.\n    virtual void OnTestEnd(const ::testing::TestInfo& test_info) {\n      printf(\"*** Test %s.%s ending.\\n\",\n             test_info.test_case_name(), test_info.name());\n    }\n  };\n```\n\n## Using Event Listeners ##\n\nTo use the event listener you have defined, add an instance of it to\nthe Google Test event listener list (represented by class\n[TestEventListeners](../include/gtest/gtest.h#L929)\n- note the \"s\" at the end of the name) in your\n`main()` function, before calling `RUN_ALL_TESTS()`:\n```\nint main(int argc, char** argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n  // Gets hold of the event listener list.\n  ::testing::TestEventListeners& listeners =\n      ::testing::UnitTest::GetInstance()->listeners();\n  // Adds a listener to the end.  Google Test takes the ownership.\n  listeners.Append(new MinimalistPrinter);\n  return RUN_ALL_TESTS();\n}\n```\n\nThere's only one problem: the default test result printer is still in\neffect, so its output will mingle with the output from your minimalist\nprinter. To suppress the default printer, just release it from the\nevent listener list and delete it. You can do so by adding one line:\n```\n  ...\n  delete listeners.Release(listeners.default_result_printer());\n  listeners.Append(new MinimalistPrinter);\n  return RUN_ALL_TESTS();\n```\n\nNow, sit back and enjoy a completely different output from your\ntests. For more details, you can read this\n[sample](../samples/sample9_unittest.cc).\n\nYou may append more than one listener to the list. When an `On*Start()`\nor `OnTestPartResult()` event is fired, the listeners will receive it in\nthe order they appear in the list (since new listeners are added to\nthe end of the list, the default text printer and the default XML\ngenerator will receive the event first). An `On*End()` event will be\nreceived by the listeners in the _reverse_ order. This allows output by\nlisteners added later to be framed by output from listeners added\nearlier.\n\n## Generating Failures in Listeners ##\n\nYou may use failure-raising macros (`EXPECT_*()`, `ASSERT_*()`,\n`FAIL()`, etc) when processing an event. There are some restrictions:\n\n  1. You cannot generate any failure in `OnTestPartResult()` (otherwise it will cause `OnTestPartResult()` to be called recursively).\n  1. A listener that handles `OnTestPartResult()` is not allowed to generate any failure.\n\nWhen you add listeners to the listener list, you should put listeners\nthat handle `OnTestPartResult()` _before_ listeners that can generate\nfailures. This ensures that failures generated by the latter are\nattributed to the right test by the former.\n\nWe have a sample of failure-raising listener\n[here](../samples/sample10_unittest.cc).\n\n# Running Test Programs: Advanced Options #\n\nGoogle Test test programs are ordinary executables. Once built, you can run\nthem directly and affect their behavior via the following environment variables\nand/or command line flags. For the flags to work, your programs must call\n`::testing::InitGoogleTest()` before calling `RUN_ALL_TESTS()`.\n\nTo see a list of supported flags and their usage, please run your test\nprogram with the `--help` flag.  You can also use `-h`, `-?`, or `/?`\nfor short.  This feature is added in version 1.3.0.\n\nIf an option is specified both by an environment variable and by a\nflag, the latter takes precedence.  Most of the options can also be\nset/read in code: to access the value of command line flag\n`--gtest_foo`, write `::testing::GTEST_FLAG(foo)`.  A common pattern is\nto set the value of a flag before calling `::testing::InitGoogleTest()`\nto change the default value of the flag:\n```\nint main(int argc, char** argv) {\n  // Disables elapsed time by default.\n  ::testing::GTEST_FLAG(print_time) = false;\n\n  // This allows the user to override the flag on the command line.\n  ::testing::InitGoogleTest(&argc, argv);\n\n  return RUN_ALL_TESTS();\n}\n```\n\n## Selecting Tests ##\n\nThis section shows various options for choosing which tests to run.\n\n### Listing Test Names ###\n\nSometimes it is necessary to list the available tests in a program before\nrunning them so that a filter may be applied if needed. Including the flag\n`--gtest_list_tests` overrides all other flags and lists tests in the following\nformat:\n```\nTestCase1.\n  TestName1\n  TestName2\nTestCase2.\n  TestName\n```\n\nNone of the tests listed are actually run if the flag is provided. There is no\ncorresponding environment variable for this flag.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Running a Subset of the Tests ###\n\nBy default, a Google Test program runs all tests the user has defined.\nSometimes, you want to run only a subset of the tests (e.g. for debugging or\nquickly verifying a change). If you set the `GTEST_FILTER` environment variable\nor the `--gtest_filter` flag to a filter string, Google Test will only run the\ntests whose full names (in the form of `TestCaseName.TestName`) match the\nfilter.\n\nThe format of a filter is a '`:`'-separated list of wildcard patterns (called\nthe positive patterns) optionally followed by a '`-`' and another\n'`:`'-separated pattern list (called the negative patterns). A test matches the\nfilter if and only if it matches any of the positive patterns but does not\nmatch any of the negative patterns.\n\nA pattern may contain `'*'` (matches any string) or `'?'` (matches any single\ncharacter). For convenience, the filter `'*-NegativePatterns'` can be also\nwritten as `'-NegativePatterns'`.\n\nFor example:\n\n  * `./foo_test` Has no flag, and thus runs all its tests.\n  * `./foo_test --gtest_filter=*` Also runs everything, due to the single match-everything `*` value.\n  * `./foo_test --gtest_filter=FooTest.*` Runs everything in test case `FooTest`.\n  * `./foo_test --gtest_filter=*Null*:*Constructor*` Runs any test whose full name contains either `\"Null\"` or `\"Constructor\"`.\n  * `./foo_test --gtest_filter=-*DeathTest.*` Runs all non-death tests.\n  * `./foo_test --gtest_filter=FooTest.*-FooTest.Bar` Runs everything in test case `FooTest` except `FooTest.Bar`.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Temporarily Disabling Tests ###\n\nIf you have a broken test that you cannot fix right away, you can add the\n`DISABLED_` prefix to its name. This will exclude it from execution. This is\nbetter than commenting out the code or using `#if 0`, as disabled tests are\nstill compiled (and thus won't rot).\n\nIf you need to disable all tests in a test case, you can either add `DISABLED_`\nto the front of the name of each test, or alternatively add it to the front of\nthe test case name.\n\nFor example, the following tests won't be run by Google Test, even though they\nwill still be compiled:\n\n```\n// Tests that Foo does Abc.\nTEST(FooTest, DISABLED_DoesAbc) { ... }\n\nclass DISABLED_BarTest : public ::testing::Test { ... };\n\n// Tests that Bar does Xyz.\nTEST_F(DISABLED_BarTest, DoesXyz) { ... }\n```\n\n_Note:_ This feature should only be used for temporary pain-relief. You still\nhave to fix the disabled tests at a later date. As a reminder, Google Test will\nprint a banner warning you if a test program contains any disabled tests.\n\n_Tip:_ You can easily count the number of disabled tests you have\nusing `grep`. This number can be used as a metric for improving your\ntest quality.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Temporarily Enabling Disabled Tests ###\n\nTo include [disabled tests](#temporarily-disabling-tests) in test\nexecution, just invoke the test program with the\n`--gtest_also_run_disabled_tests` flag or set the\n`GTEST_ALSO_RUN_DISABLED_TESTS` environment variable to a value other\nthan `0`.  You can combine this with the\n[--gtest\\_filter](#running-a-subset-of-the-tests) flag to further select\nwhich disabled tests to run.\n\n_Availability:_ Linux, Windows, Mac; since version 1.3.0.\n\n## Repeating the Tests ##\n\nOnce in a while you'll run into a test whose result is hit-or-miss. Perhaps it\nwill fail only 1% of the time, making it rather hard to reproduce the bug under\na debugger. This can be a major source of frustration.\n\nThe `--gtest_repeat` flag allows you to repeat all (or selected) test methods\nin a program many times. Hopefully, a flaky test will eventually fail and give\nyou a chance to debug. Here's how to use it:\n\n| `$ foo_test --gtest_repeat=1000` | Repeat foo\\_test 1000 times and don't stop at failures. |\n|:---------------------------------|:--------------------------------------------------------|\n| `$ foo_test --gtest_repeat=-1`   | A negative count means repeating forever.               |\n| `$ foo_test --gtest_repeat=1000 --gtest_break_on_failure` | Repeat foo\\_test 1000 times, stopping at the first failure. This is especially useful when running under a debugger: when the testfails, it will drop into the debugger and you can then inspect variables and stacks. |\n| `$ foo_test --gtest_repeat=1000 --gtest_filter=FooBar` | Repeat the tests whose name matches the filter 1000 times. |\n\nIf your test program contains global set-up/tear-down code registered\nusing `AddGlobalTestEnvironment()`, it will be repeated in each\niteration as well, as the flakiness may be in it. You can also specify\nthe repeat count by setting the `GTEST_REPEAT` environment variable.\n\n_Availability:_ Linux, Windows, Mac.\n\n## Shuffling the Tests ##\n\nYou can specify the `--gtest_shuffle` flag (or set the `GTEST_SHUFFLE`\nenvironment variable to `1`) to run the tests in a program in a random\norder. This helps to reveal bad dependencies between tests.\n\nBy default, Google Test uses a random seed calculated from the current\ntime. Therefore you'll get a different order every time. The console\noutput includes the random seed value, such that you can reproduce an\norder-related test failure later. To specify the random seed\nexplicitly, use the `--gtest_random_seed=SEED` flag (or set the\n`GTEST_RANDOM_SEED` environment variable), where `SEED` is an integer\nbetween 0 and 99999. The seed value 0 is special: it tells Google Test\nto do the default behavior of calculating the seed from the current\ntime.\n\nIf you combine this with `--gtest_repeat=N`, Google Test will pick a\ndifferent random seed and re-shuffle the tests in each iteration.\n\n_Availability:_ Linux, Windows, Mac; since v1.4.0.\n\n## Controlling Test Output ##\n\nThis section teaches how to tweak the way test results are reported.\n\n### Colored Terminal Output ###\n\nGoogle Test can use colors in its terminal output to make it easier to spot\nthe separation between tests, and whether tests passed.\n\nYou can set the GTEST\\_COLOR environment variable or set the `--gtest_color`\ncommand line flag to `yes`, `no`, or `auto` (the default) to enable colors,\ndisable colors, or let Google Test decide. When the value is `auto`, Google\nTest will use colors if and only if the output goes to a terminal and (on\nnon-Windows platforms) the `TERM` environment variable is set to `xterm` or\n`xterm-color`.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Suppressing the Elapsed Time ###\n\nBy default, Google Test prints the time it takes to run each test.  To\nsuppress that, run the test program with the `--gtest_print_time=0`\ncommand line flag.  Setting the `GTEST_PRINT_TIME` environment\nvariable to `0` has the same effect.\n\n_Availability:_ Linux, Windows, Mac.  (In Google Test 1.3.0 and lower,\nthe default behavior is that the elapsed time is **not** printed.)\n\n### Generating an XML Report ###\n\nGoogle Test can emit a detailed XML report to a file in addition to its normal\ntextual output. The report contains the duration of each test, and thus can\nhelp you identify slow tests.\n\nTo generate the XML report, set the `GTEST_OUTPUT` environment variable or the\n`--gtest_output` flag to the string `\"xml:_path_to_output_file_\"`, which will\ncreate the file at the given location. You can also just use the string\n`\"xml\"`, in which case the output can be found in the `test_detail.xml` file in\nthe current directory.\n\nIf you specify a directory (for example, `\"xml:output/directory/\"` on Linux or\n`\"xml:output\\directory\\\"` on Windows), Google Test will create the XML file in\nthat directory, named after the test executable (e.g. `foo_test.xml` for test\nprogram `foo_test` or `foo_test.exe`). If the file already exists (perhaps left\nover from a previous run), Google Test will pick a different name (e.g.\n`foo_test_1.xml`) to avoid overwriting it.\n\nThe report uses the format described here.  It is based on the\n`junitreport` Ant task and can be parsed by popular continuous build\nsystems like [Jenkins](http://jenkins-ci.org/). Since that format\nwas originally intended for Java, a little interpretation is required\nto make it apply to Google Test tests, as shown here:\n\n```\n<testsuites name=\"AllTests\" ...>\n  <testsuite name=\"test_case_name\" ...>\n    <testcase name=\"test_name\" ...>\n      <failure message=\"...\"/>\n      <failure message=\"...\"/>\n      <failure message=\"...\"/>\n    </testcase>\n  </testsuite>\n</testsuites>\n```\n\n  * The root `<testsuites>` element corresponds to the entire test program.\n  * `<testsuite>` elements correspond to Google Test test cases.\n  * `<testcase>` elements correspond to Google Test test functions.\n\nFor instance, the following program\n\n```\nTEST(MathTest, Addition) { ... }\nTEST(MathTest, Subtraction) { ... }\nTEST(LogicTest, NonContradiction) { ... }\n```\n\ncould generate this report:\n\n```\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites tests=\"3\" failures=\"1\" errors=\"0\" time=\"35\" name=\"AllTests\">\n  <testsuite name=\"MathTest\" tests=\"2\" failures=\"1\" errors=\"0\" time=\"15\">\n    <testcase name=\"Addition\" status=\"run\" time=\"7\" classname=\"\">\n      <failure message=\"Value of: add(1, 1)&#x0A; Actual: 3&#x0A;Expected: 2\" type=\"\"/>\n      <failure message=\"Value of: add(1, -1)&#x0A; Actual: 1&#x0A;Expected: 0\" type=\"\"/>\n    </testcase>\n    <testcase name=\"Subtraction\" status=\"run\" time=\"5\" classname=\"\">\n    </testcase>\n  </testsuite>\n  <testsuite name=\"LogicTest\" tests=\"1\" failures=\"0\" errors=\"0\" time=\"5\">\n    <testcase name=\"NonContradiction\" status=\"run\" time=\"5\" classname=\"\">\n    </testcase>\n  </testsuite>\n</testsuites>\n```\n\nThings to note:\n\n  * The `tests` attribute of a `<testsuites>` or `<testsuite>` element tells how many test functions the Google Test program or test case contains, while the `failures` attribute tells how many of them failed.\n  * The `time` attribute expresses the duration of the test, test case, or entire test program in milliseconds.\n  * Each `<failure>` element corresponds to a single failed Google Test assertion.\n  * Some JUnit concepts don't apply to Google Test, yet we have to conform to the DTD. Therefore you'll see some dummy elements and attributes in the report. You can safely ignore these parts.\n\n_Availability:_ Linux, Windows, Mac.\n\n## Controlling How Failures Are Reported ##\n\n### Turning Assertion Failures into Break-Points ###\n\nWhen running test programs under a debugger, it's very convenient if the\ndebugger can catch an assertion failure and automatically drop into interactive\nmode. Google Test's _break-on-failure_ mode supports this behavior.\n\nTo enable it, set the `GTEST_BREAK_ON_FAILURE` environment variable to a value\nother than `0` . Alternatively, you can use the `--gtest_break_on_failure`\ncommand line flag.\n\n_Availability:_ Linux, Windows, Mac.\n\n### Disabling Catching Test-Thrown Exceptions ###\n\nGoogle Test can be used either with or without exceptions enabled.  If\na test throws a C++ exception or (on Windows) a structured exception\n(SEH), by default Google Test catches it, reports it as a test\nfailure, and continues with the next test method.  This maximizes the\ncoverage of a test run.  Also, on Windows an uncaught exception will\ncause a pop-up window, so catching the exceptions allows you to run\nthe tests automatically.\n\nWhen debugging the test failures, however, you may instead want the\nexceptions to be handled by the debugger, such that you can examine\nthe call stack when an exception is thrown.  To achieve that, set the\n`GTEST_CATCH_EXCEPTIONS` environment variable to `0`, or use the\n`--gtest_catch_exceptions=0` flag when running the tests.\n\n**Availability**: Linux, Windows, Mac.\n\n### Letting Another Testing Framework Drive ###\n\nIf you work on a project that has already been using another testing\nframework and is not ready to completely switch to Google Test yet,\nyou can get much of Google Test's benefit by using its assertions in\nyour existing tests.  Just change your `main()` function to look\nlike:\n\n```\n#include \"gtest/gtest.h\"\n\nint main(int argc, char** argv) {\n  ::testing::GTEST_FLAG(throw_on_failure) = true;\n  // Important: Google Test must be initialized.\n  ::testing::InitGoogleTest(&argc, argv);\n\n  ... whatever your existing testing framework requires ...\n}\n```\n\nWith that, you can use Google Test assertions in addition to the\nnative assertions your testing framework provides, for example:\n\n```\nvoid TestFooDoesBar() {\n  Foo foo;\n  EXPECT_LE(foo.Bar(1), 100);     // A Google Test assertion.\n  CPPUNIT_ASSERT(foo.IsEmpty());  // A native assertion.\n}\n```\n\nIf a Google Test assertion fails, it will print an error message and\nthrow an exception, which will be treated as a failure by your host\ntesting framework.  If you compile your code with exceptions disabled,\na failed Google Test assertion will instead exit your program with a\nnon-zero code, which will also signal a test failure to your test\nrunner.\n\nIf you don't write `::testing::GTEST_FLAG(throw_on_failure) = true;` in\nyour `main()`, you can alternatively enable this feature by specifying\nthe `--gtest_throw_on_failure` flag on the command-line or setting the\n`GTEST_THROW_ON_FAILURE` environment variable to a non-zero value.\n\nDeath tests are _not_ supported when other test framework is used to organize tests.\n\n_Availability:_ Linux, Windows, Mac; since v1.3.0.\n\n## Distributing Test Functions to Multiple Machines ##\n\nIf you have more than one machine you can use to run a test program,\nyou might want to run the test functions in parallel and get the\nresult faster.  We call this technique _sharding_, where each machine\nis called a _shard_.\n\nGoogle Test is compatible with test sharding.  To take advantage of\nthis feature, your test runner (not part of Google Test) needs to do\nthe following:\n\n  1. Allocate a number of machines (shards) to run the tests.\n  1. On each shard, set the `GTEST_TOTAL_SHARDS` environment variable to the total number of shards.  It must be the same for all shards.\n  1. On each shard, set the `GTEST_SHARD_INDEX` environment variable to the index of the shard.  Different shards must be assigned different indices, which must be in the range `[0, GTEST_TOTAL_SHARDS - 1]`.\n  1. Run the same test program on all shards.  When Google Test sees the above two environment variables, it will select a subset of the test functions to run.  Across all shards, each test function in the program will be run exactly once.\n  1. Wait for all shards to finish, then collect and report the results.\n\nYour project may have tests that were written without Google Test and\nthus don't understand this protocol.  In order for your test runner to\nfigure out which test supports sharding, it can set the environment\nvariable `GTEST_SHARD_STATUS_FILE` to a non-existent file path.  If a\ntest program supports sharding, it will create this file to\nacknowledge the fact (the actual contents of the file are not\nimportant at this time; although we may stick some useful information\nin it in the future.); otherwise it will not create it.\n\nHere's an example to make it clear.  Suppose you have a test program\n`foo_test` that contains the following 5 test functions:\n```\nTEST(A, V)\nTEST(A, W)\nTEST(B, X)\nTEST(B, Y)\nTEST(B, Z)\n```\nand you have 3 machines at your disposal.  To run the test functions in\nparallel, you would set `GTEST_TOTAL_SHARDS` to 3 on all machines, and\nset `GTEST_SHARD_INDEX` to 0, 1, and 2 on the machines respectively.\nThen you would run the same `foo_test` on each machine.\n\nGoogle Test reserves the right to change how the work is distributed\nacross the shards, but here's one possible scenario:\n\n  * Machine #0 runs `A.V` and `B.X`.\n  * Machine #1 runs `A.W` and `B.Y`.\n  * Machine #2 runs `B.Z`.\n\n_Availability:_ Linux, Windows, Mac; since version 1.3.0.\n\n# Fusing Google Test Source Files #\n\nGoogle Test's implementation consists of ~30 files (excluding its own\ntests).  Sometimes you may want them to be packaged up in two files (a\n`.h` and a `.cc`) instead, such that you can easily copy them to a new\nmachine and start hacking there.  For this we provide an experimental\nPython script `fuse_gtest_files.py` in the `scripts/` directory (since release 1.3.0).\nAssuming you have Python 2.4 or above installed on your machine, just\ngo to that directory and run\n```\npython fuse_gtest_files.py OUTPUT_DIR\n```\n\nand you should see an `OUTPUT_DIR` directory being created with files\n`gtest/gtest.h` and `gtest/gtest-all.cc` in it.  These files contain\neverything you need to use Google Test.  Just copy them to anywhere\nyou want and you are ready to write tests.  You can use the\n[scripts/test/Makefile](../scripts/test/Makefile)\nfile as an example on how to compile your tests against them.\n\n# Where to Go from Here #\n\nCongratulations! You've now learned more advanced Google Test tools and are\nready to tackle more complex testing tasks. If you want to dive even deeper, you\ncan read the [Frequently-Asked Questions](V1_7_FAQ.md).\n"
  },
  {
    "path": "utils/googletest/googletest/docs/V1_7_Documentation.md",
    "content": "This page lists all documentation wiki pages for Google Test **(the SVN trunk version)**\n-- **if you use a released version of Google Test, please read the\ndocumentation for that specific version instead.**\n\n  * [Primer](V1_7_Primer.md) -- start here if you are new to Google Test.\n  * [Samples](V1_7_Samples.md) -- learn from examples.\n  * [AdvancedGuide](V1_7_AdvancedGuide.md) -- learn more about Google Test.\n  * [XcodeGuide](V1_7_XcodeGuide.md) -- how to use Google Test in Xcode on Mac.\n  * [Frequently-Asked Questions](V1_7_FAQ.md) -- check here before asking a question on the mailing list.\n\nTo contribute code to Google Test, read:\n\n  * [DevGuide](DevGuide.md) -- read this _before_ writing your first patch.\n  * [PumpManual](V1_7_PumpManual.md) -- how we generate some of Google Test's source files."
  },
  {
    "path": "utils/googletest/googletest/docs/V1_7_FAQ.md",
    "content": "\n\nIf you cannot find the answer to your question here, and you have read\n[Primer](V1_7_Primer.md) and [AdvancedGuide](V1_7_AdvancedGuide.md), send it to\ngoogletestframework@googlegroups.com.\n\n## Why should I use Google Test instead of my favorite C++ testing framework? ##\n\nFirst, let us say clearly that we don't want to get into the debate of\nwhich C++ testing framework is **the best**.  There exist many fine\nframeworks for writing C++ tests, and we have tremendous respect for\nthe developers and users of them.  We don't think there is (or will\nbe) a single best framework - you have to pick the right tool for the\nparticular task you are tackling.\n\nWe created Google Test because we couldn't find the right combination\nof features and conveniences in an existing framework to satisfy _our_\nneeds.  The following is a list of things that _we_ like about Google\nTest.  We don't claim them to be unique to Google Test - rather, the\ncombination of them makes Google Test the choice for us.  We hope this\nlist can help you decide whether it is for you too.\n\n  * Google Test is designed to be portable: it doesn't require exceptions or RTTI; it works around various bugs in various compilers and environments; etc.  As a result, it works on Linux, Mac OS X, Windows and several embedded operating systems.\n  * Nonfatal assertions (`EXPECT_*`) have proven to be great time savers, as they allow a test to report multiple failures in a single edit-compile-test cycle.\n  * It's easy to write assertions that generate informative messages: you just use the stream syntax to append any additional information, e.g. `ASSERT_EQ(5, Foo(i)) << \" where i = \" << i;`.  It doesn't require a new set of macros or special functions.\n  * Google Test automatically detects your tests and doesn't require you to enumerate them in order to run them.\n  * Death tests are pretty handy for ensuring that your asserts in production code are triggered by the right conditions.\n  * `SCOPED_TRACE` helps you understand the context of an assertion failure when it comes from inside a sub-routine or loop.\n  * You can decide which tests to run using name patterns.  This saves time when you want to quickly reproduce a test failure.\n  * Google Test can generate XML test result reports that can be parsed by popular continuous build system like Hudson.\n  * Simple things are easy in Google Test, while hard things are possible: in addition to advanced features like [global test environments](V1_7_AdvancedGuide.md#global-set-up-and-tear-down) and tests parameterized by [values](V1_7_AdvancedGuide.md#value-parameterized-tests) or [types](V1_7_AdvancedGuide.md#typed-tests), Google Test supports various ways for the user to extend the framework -- if Google Test doesn't do something out of the box, chances are that a user can implement the feature using Google Test's public API, without changing Google Test itself.  In particular, you can:\n    * expand your testing vocabulary by defining [custom predicates](V1_7_AdvancedGuide.md#predicate-assertions-for-better-error-messages),\n    * teach Google Test how to [print your types](V1_7_AdvancedGuide.md#teaching-google-test-how-to-print-your-values),\n    * define your own testing macros or utilities and verify them using Google Test's [Service Provider Interface](V1_7_AdvancedGuide.md#catching-failures), and\n    * reflect on the test cases or change the test output format by intercepting the [test events](V1_7_AdvancedGuide.md#extending-google-test-by-handling-test-events).\n\n## I'm getting warnings when compiling Google Test.  Would you fix them? ##\n\nWe strive to minimize compiler warnings Google Test generates.  Before releasing a new version, we test to make sure that it doesn't generate warnings when compiled using its CMake script on Windows, Linux, and Mac OS.\n\nUnfortunately, this doesn't mean you are guaranteed to see no warnings when compiling Google Test in your environment:\n\n  * You may be using a different compiler as we use, or a different version of the same compiler.  We cannot possibly test for all compilers.\n  * You may be compiling on a different platform as we do.\n  * Your project may be using different compiler flags as we do.\n\nIt is not always possible to make Google Test warning-free for everyone.  Or, it may not be desirable if the warning is rarely enabled and fixing the violations makes the code more complex.\n\nIf you see warnings when compiling Google Test, we suggest that you use the `-isystem` flag (assuming your are using GCC) to mark Google Test headers as system headers.  That'll suppress warnings from Google Test headers.\n\n## Why should not test case names and test names contain underscore? ##\n\nUnderscore (`_`) is special, as C++ reserves the following to be used by\nthe compiler and the standard library:\n\n  1. any identifier that starts with an `_` followed by an upper-case letter, and\n  1. any identifier that containers two consecutive underscores (i.e. `__`) _anywhere_ in its name.\n\nUser code is _prohibited_ from using such identifiers.\n\nNow let's look at what this means for `TEST` and `TEST_F`.\n\nCurrently `TEST(TestCaseName, TestName)` generates a class named\n`TestCaseName_TestName_Test`.  What happens if `TestCaseName` or `TestName`\ncontains `_`?\n\n  1. If `TestCaseName` starts with an `_` followed by an upper-case letter (say, `_Foo`), we end up with `_Foo_TestName_Test`, which is reserved and thus invalid.\n  1. If `TestCaseName` ends with an `_` (say, `Foo_`), we get `Foo__TestName_Test`, which is invalid.\n  1. If `TestName` starts with an `_` (say, `_Bar`), we get `TestCaseName__Bar_Test`, which is invalid.\n  1. If `TestName` ends with an `_` (say, `Bar_`), we get `TestCaseName_Bar__Test`, which is invalid.\n\nSo clearly `TestCaseName` and `TestName` cannot start or end with `_`\n(Actually, `TestCaseName` can start with `_` -- as long as the `_` isn't\nfollowed by an upper-case letter.  But that's getting complicated.  So\nfor simplicity we just say that it cannot start with `_`.).\n\nIt may seem fine for `TestCaseName` and `TestName` to contain `_` in the\nmiddle.  However, consider this:\n```\nTEST(Time, Flies_Like_An_Arrow) { ... }\nTEST(Time_Flies, Like_An_Arrow) { ... }\n```\n\nNow, the two `TEST`s will both generate the same class\n(`Time_Files_Like_An_Arrow_Test`).  That's not good.\n\nSo for simplicity, we just ask the users to avoid `_` in `TestCaseName`\nand `TestName`.  The rule is more constraining than necessary, but it's\nsimple and easy to remember.  It also gives Google Test some wiggle\nroom in case its implementation needs to change in the future.\n\nIf you violate the rule, there may not be immediately consequences,\nbut your test may (just may) break with a new compiler (or a new\nversion of the compiler you are using) or with a new version of Google\nTest.  Therefore it's best to follow the rule.\n\n## Why is it not recommended to install a pre-compiled copy of Google Test (for example, into /usr/local)? ##\n\nIn the early days, we said that you could install\ncompiled Google Test libraries on `*`nix systems using `make install`.\nThen every user of your machine can write tests without\nrecompiling Google Test.\n\nThis seemed like a good idea, but it has a\ngot-cha: every user needs to compile his tests using the _same_ compiler\nflags used to compile the installed Google Test libraries; otherwise\nhe may run into undefined behaviors (i.e. the tests can behave\nstrangely and may even crash for no obvious reasons).\n\nWhy?  Because C++ has this thing called the One-Definition Rule: if\ntwo C++ source files contain different definitions of the same\nclass/function/variable, and you link them together, you violate the\nrule.  The linker may or may not catch the error (in many cases it's\nnot required by the C++ standard to catch the violation).  If it\ndoesn't, you get strange run-time behaviors that are unexpected and\nhard to debug.\n\nIf you compile Google Test and your test code using different compiler\nflags, they may see different definitions of the same\nclass/function/variable (e.g. due to the use of `#if` in Google Test).\nTherefore, for your sanity, we recommend to avoid installing pre-compiled\nGoogle Test libraries.  Instead, each project should compile\nGoogle Test itself such that it can be sure that the same flags are\nused for both Google Test and the tests.\n\n## How do I generate 64-bit binaries on Windows (using Visual Studio 2008)? ##\n\n(Answered by Trevor Robinson)\n\nLoad the supplied Visual Studio solution file, either `msvc\\gtest-md.sln` or\n`msvc\\gtest.sln`. Go through the migration wizard to migrate the\nsolution and project files to Visual Studio 2008. Select\n`Configuration Manager...` from the `Build` menu. Select `<New...>` from\nthe `Active solution platform` dropdown.  Select `x64` from the new\nplatform dropdown, leave `Copy settings from` set to `Win32` and\n`Create new project platforms` checked, then click `OK`. You now have\n`Win32` and `x64` platform configurations, selectable from the\n`Standard` toolbar, which allow you to toggle between building 32-bit or\n64-bit binaries (or both at once using Batch Build).\n\nIn order to prevent build output files from overwriting one another,\nyou'll need to change the `Intermediate Directory` settings for the\nnewly created platform configuration across all the projects. To do\nthis, multi-select (e.g. using shift-click) all projects (but not the\nsolution) in the `Solution Explorer`. Right-click one of them and\nselect `Properties`. In the left pane, select `Configuration Properties`,\nand from the `Configuration` dropdown, select `All Configurations`.\nMake sure the selected platform is `x64`. For the\n`Intermediate Directory` setting, change the value from\n`$(PlatformName)\\$(ConfigurationName)` to\n`$(OutDir)\\$(ProjectName)`. Click `OK` and then build the\nsolution. When the build is complete, the 64-bit binaries will be in\nthe `msvc\\x64\\Debug` directory.\n\n## Can I use Google Test on MinGW? ##\n\nWe haven't tested this ourselves, but Per Abrahamsen reported that he\nwas able to compile and install Google Test successfully when using\nMinGW from Cygwin.  You'll need to configure it with:\n\n`PATH/TO/configure CC=\"gcc -mno-cygwin\" CXX=\"g++ -mno-cygwin\"`\n\nYou should be able to replace the `-mno-cygwin` option with direct links\nto the real MinGW binaries, but we haven't tried that.\n\nCaveats:\n\n  * There are many warnings when compiling.\n  * `make check` will produce some errors as not all tests for Google Test itself are compatible with MinGW.\n\nWe also have reports on successful cross compilation of Google Test\nMinGW binaries on Linux using\n[these instructions](http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux#Cross-compiling_under_Linux_for_MS_Windows)\non the WxWidgets site.\n\nPlease contact `googletestframework@googlegroups.com` if you are\ninterested in improving the support for MinGW.\n\n## Why does Google Test support EXPECT\\_EQ(NULL, ptr) and ASSERT\\_EQ(NULL, ptr) but not EXPECT\\_NE(NULL, ptr) and ASSERT\\_NE(NULL, ptr)? ##\n\nDue to some peculiarity of C++, it requires some non-trivial template\nmeta programming tricks to support using `NULL` as an argument of the\n`EXPECT_XX()` and `ASSERT_XX()` macros. Therefore we only do it where\nit's most needed (otherwise we make the implementation of Google Test\nharder to maintain and more error-prone than necessary).\n\nThe `EXPECT_EQ()` macro takes the _expected_ value as its first\nargument and the _actual_ value as the second. It's reasonable that\nsomeone wants to write `EXPECT_EQ(NULL, some_expression)`, and this\nindeed was requested several times. Therefore we implemented it.\n\nThe need for `EXPECT_NE(NULL, ptr)` isn't nearly as strong. When the\nassertion fails, you already know that `ptr` must be `NULL`, so it\ndoesn't add any information to print ptr in this case. That means\n`EXPECT_TRUE(ptr != NULL)` works just as well.\n\nIf we were to support `EXPECT_NE(NULL, ptr)`, for consistency we'll\nhave to support `EXPECT_NE(ptr, NULL)` as well, as unlike `EXPECT_EQ`,\nwe don't have a convention on the order of the two arguments for\n`EXPECT_NE`. This means using the template meta programming tricks\ntwice in the implementation, making it even harder to understand and\nmaintain. We believe the benefit doesn't justify the cost.\n\nFinally, with the growth of Google Mock's [matcher](../../CookBook.md#using-matchers-in-google-test-assertions) library, we are\nencouraging people to use the unified `EXPECT_THAT(value, matcher)`\nsyntax more often in tests. One significant advantage of the matcher\napproach is that matchers can be easily combined to form new matchers,\nwhile the `EXPECT_NE`, etc, macros cannot be easily\ncombined. Therefore we want to invest more in the matchers than in the\n`EXPECT_XX()` macros.\n\n## Does Google Test support running tests in parallel? ##\n\nTest runners tend to be tightly coupled with the build/test\nenvironment, and Google Test doesn't try to solve the problem of\nrunning tests in parallel.  Instead, we tried to make Google Test work\nnicely with test runners.  For example, Google Test's XML report\ncontains the time spent on each test, and its `gtest_list_tests` and\n`gtest_filter` flags can be used for splitting the execution of test\nmethods into multiple processes.  These functionalities can help the\ntest runner run the tests in parallel.\n\n## Why don't Google Test run the tests in different threads to speed things up? ##\n\nIt's difficult to write thread-safe code.  Most tests are not written\nwith thread-safety in mind, and thus may not work correctly in a\nmulti-threaded setting.\n\nIf you think about it, it's already hard to make your code work when\nyou know what other threads are doing.  It's much harder, and\nsometimes even impossible, to make your code work when you don't know\nwhat other threads are doing (remember that test methods can be added,\ndeleted, or modified after your test was written).  If you want to run\nthe tests in parallel, you'd better run them in different processes.\n\n## Why aren't Google Test assertions implemented using exceptions? ##\n\nOur original motivation was to be able to use Google Test in projects\nthat disable exceptions.  Later we realized some additional benefits\nof this approach:\n\n  1. Throwing in a destructor is undefined behavior in C++.  Not using exceptions means Google Test's assertions are safe to use in destructors.\n  1. The `EXPECT_*` family of macros will continue even after a failure, allowing multiple failures in a `TEST` to be reported in a single run. This is a popular feature, as in C++ the edit-compile-test cycle is usually quite long and being able to fixing more than one thing at a time is a blessing.\n  1. If assertions are implemented using exceptions, a test may falsely ignore a failure if it's caught by user code:\n```\ntry { ... ASSERT_TRUE(...) ... }\ncatch (...) { ... }\n```\nThe above code will pass even if the `ASSERT_TRUE` throws.  While it's unlikely for someone to write this in a test, it's possible to run into this pattern when you write assertions in callbacks that are called by the code under test.\n\nThe downside of not using exceptions is that `ASSERT_*` (implemented\nusing `return`) will only abort the current function, not the current\n`TEST`.\n\n## Why do we use two different macros for tests with and without fixtures? ##\n\nUnfortunately, C++'s macro system doesn't allow us to use the same\nmacro for both cases.  One possibility is to provide only one macro\nfor tests with fixtures, and require the user to define an empty\nfixture sometimes:\n\n```\nclass FooTest : public ::testing::Test {};\n\nTEST_F(FooTest, DoesThis) { ... }\n```\nor\n```\ntypedef ::testing::Test FooTest;\n\nTEST_F(FooTest, DoesThat) { ... }\n```\n\nYet, many people think this is one line too many. :-) Our goal was to\nmake it really easy to write tests, so we tried to make simple tests\ntrivial to create.  That means using a separate macro for such tests.\n\nWe think neither approach is ideal, yet either of them is reasonable.\nIn the end, it probably doesn't matter much either way.\n\n## Why don't we use structs as test fixtures? ##\n\nWe like to use structs only when representing passive data.  This\ndistinction between structs and classes is good for documenting the\nintent of the code's author.  Since test fixtures have logic like\n`SetUp()` and `TearDown()`, they are better defined as classes.\n\n## Why are death tests implemented as assertions instead of using a test runner? ##\n\nOur goal was to make death tests as convenient for a user as C++\npossibly allows.  In particular:\n\n  * The runner-style requires to split the information into two pieces: the definition of the death test itself, and the specification for the runner on how to run the death test and what to expect.  The death test would be written in C++, while the runner spec may or may not be.  A user needs to carefully keep the two in sync. `ASSERT_DEATH(statement, expected_message)` specifies all necessary information in one place, in one language, without boilerplate code. It is very declarative.\n  * `ASSERT_DEATH` has a similar syntax and error-reporting semantics as other Google Test assertions, and thus is easy to learn.\n  * `ASSERT_DEATH` can be mixed with other assertions and other logic at your will.  You are not limited to one death test per test method. For example, you can write something like:\n```\n    if (FooCondition()) {\n      ASSERT_DEATH(Bar(), \"blah\");\n    } else {\n      ASSERT_EQ(5, Bar());\n    }\n```\nIf you prefer one death test per test method, you can write your tests in that style too, but we don't want to impose that on the users.  The fewer artificial limitations the better.\n  * `ASSERT_DEATH` can reference local variables in the current function, and you can decide how many death tests you want based on run-time information.  For example,\n```\n    const int count = GetCount();  // Only known at run time.\n    for (int i = 1; i <= count; i++) {\n      ASSERT_DEATH({\n        double* buffer = new double[i];\n        ... initializes buffer ...\n        Foo(buffer, i)\n      }, \"blah blah\");\n    }\n```\nThe runner-based approach tends to be more static and less flexible, or requires more user effort to get this kind of flexibility.\n\nAnother interesting thing about `ASSERT_DEATH` is that it calls `fork()`\nto create a child process to run the death test.  This is lightening\nfast, as `fork()` uses copy-on-write pages and incurs almost zero\noverhead, and the child process starts from the user-supplied\nstatement directly, skipping all global and local initialization and\nany code leading to the given statement.  If you launch the child\nprocess from scratch, it can take seconds just to load everything and\nstart running if the test links to many libraries dynamically.\n\n## My death test modifies some state, but the change seems lost after the death test finishes. Why? ##\n\nDeath tests (`EXPECT_DEATH`, etc) are executed in a sub-process s.t. the\nexpected crash won't kill the test program (i.e. the parent process). As a\nresult, any in-memory side effects they incur are observable in their\nrespective sub-processes, but not in the parent process. You can think of them\nas running in a parallel universe, more or less.\n\n## The compiler complains about \"undefined references\" to some static const member variables, but I did define them in the class body. What's wrong? ##\n\nIf your class has a static data member:\n\n```\n// foo.h\nclass Foo {\n  ...\n  static const int kBar = 100;\n};\n```\n\nYou also need to define it _outside_ of the class body in `foo.cc`:\n\n```\nconst int Foo::kBar;  // No initializer here.\n```\n\nOtherwise your code is **invalid C++**, and may break in unexpected ways. In\nparticular, using it in Google Test comparison assertions (`EXPECT_EQ`, etc)\nwill generate an \"undefined reference\" linker error.\n\n## I have an interface that has several implementations. Can I write a set of tests once and repeat them over all the implementations? ##\n\nGoogle Test doesn't yet have good support for this kind of tests, or\ndata-driven tests in general. We hope to be able to make improvements in this\narea soon.\n\n## Can I derive a test fixture from another? ##\n\nYes.\n\nEach test fixture has a corresponding and same named test case. This means only\none test case can use a particular fixture. Sometimes, however, multiple test\ncases may want to use the same or slightly different fixtures. For example, you\nmay want to make sure that all of a GUI library's test cases don't leak\nimportant system resources like fonts and brushes.\n\nIn Google Test, you share a fixture among test cases by putting the shared\nlogic in a base test fixture, then deriving from that base a separate fixture\nfor each test case that wants to use this common logic. You then use `TEST_F()`\nto write tests using each derived fixture.\n\nTypically, your code looks like this:\n\n```\n// Defines a base test fixture.\nclass BaseTest : public ::testing::Test {\n  protected:\n   ...\n};\n\n// Derives a fixture FooTest from BaseTest.\nclass FooTest : public BaseTest {\n  protected:\n    virtual void SetUp() {\n      BaseTest::SetUp();  // Sets up the base fixture first.\n      ... additional set-up work ...\n    }\n    virtual void TearDown() {\n      ... clean-up work for FooTest ...\n      BaseTest::TearDown();  // Remember to tear down the base fixture\n                             // after cleaning up FooTest!\n    }\n    ... functions and variables for FooTest ...\n};\n\n// Tests that use the fixture FooTest.\nTEST_F(FooTest, Bar) { ... }\nTEST_F(FooTest, Baz) { ... }\n\n... additional fixtures derived from BaseTest ...\n```\n\nIf necessary, you can continue to derive test fixtures from a derived fixture.\nGoogle Test has no limit on how deep the hierarchy can be.\n\nFor a complete example using derived test fixtures, see\n[sample5](../samples/sample5_unittest.cc).\n\n## My compiler complains \"void value not ignored as it ought to be.\" What does this mean? ##\n\nYou're probably using an `ASSERT_*()` in a function that doesn't return `void`.\n`ASSERT_*()` can only be used in `void` functions.\n\n## My death test hangs (or seg-faults). How do I fix it? ##\n\nIn Google Test, death tests are run in a child process and the way they work is\ndelicate. To write death tests you really need to understand how they work.\nPlease make sure you have read this.\n\nIn particular, death tests don't like having multiple threads in the parent\nprocess. So the first thing you can try is to eliminate creating threads\noutside of `EXPECT_DEATH()`.\n\nSometimes this is impossible as some library you must use may be creating\nthreads before `main()` is even reached. In this case, you can try to minimize\nthe chance of conflicts by either moving as many activities as possible inside\n`EXPECT_DEATH()` (in the extreme case, you want to move everything inside), or\nleaving as few things as possible in it. Also, you can try to set the death\ntest style to `\"threadsafe\"`, which is safer but slower, and see if it helps.\n\nIf you go with thread-safe death tests, remember that they rerun the test\nprogram from the beginning in the child process. Therefore make sure your\nprogram can run side-by-side with itself and is deterministic.\n\nIn the end, this boils down to good concurrent programming. You have to make\nsure that there is no race conditions or dead locks in your program. No silver\nbullet - sorry!\n\n## Should I use the constructor/destructor of the test fixture or the set-up/tear-down function? ##\n\nThe first thing to remember is that Google Test does not reuse the\nsame test fixture object across multiple tests. For each `TEST_F`,\nGoogle Test will create a fresh test fixture object, _immediately_\ncall `SetUp()`, run the test, call `TearDown()`, and then\n_immediately_ delete the test fixture object. Therefore, there is no\nneed to write a `SetUp()` or `TearDown()` function if the constructor\nor destructor already does the job.\n\nYou may still want to use `SetUp()/TearDown()` in the following cases:\n  * If the tear-down operation could throw an exception, you must use `TearDown()` as opposed to the destructor, as throwing in a destructor leads to undefined behavior and usually will kill your program right away. Note that many standard libraries (like STL) may throw when exceptions are enabled in the compiler. Therefore you should prefer `TearDown()` if you want to write portable tests that work with or without exceptions.\n  * The assertion macros throw an exception when flag `--gtest_throw_on_failure` is specified. Therefore, you shouldn't use Google Test assertions in a destructor if you plan to run your tests with this flag.\n  * In a constructor or destructor, you cannot make a virtual function call on this object. (You can call a method declared as virtual, but it will be statically bound.) Therefore, if you need to call a method that will be overriden in a derived class, you have to use `SetUp()/TearDown()`.\n\n## The compiler complains \"no matching function to call\" when I use ASSERT\\_PREDn. How do I fix it? ##\n\nIf the predicate function you use in `ASSERT_PRED*` or `EXPECT_PRED*` is\noverloaded or a template, the compiler will have trouble figuring out which\noverloaded version it should use. `ASSERT_PRED_FORMAT*` and\n`EXPECT_PRED_FORMAT*` don't have this problem.\n\nIf you see this error, you might want to switch to\n`(ASSERT|EXPECT)_PRED_FORMAT*`, which will also give you a better failure\nmessage. If, however, that is not an option, you can resolve the problem by\nexplicitly telling the compiler which version to pick.\n\nFor example, suppose you have\n\n```\nbool IsPositive(int n) {\n  return n > 0;\n}\nbool IsPositive(double x) {\n  return x > 0;\n}\n```\n\nyou will get a compiler error if you write\n\n```\nEXPECT_PRED1(IsPositive, 5);\n```\n\nHowever, this will work:\n\n```\nEXPECT_PRED1(*static_cast<bool (*)(int)>*(IsPositive), 5);\n```\n\n(The stuff inside the angled brackets for the `static_cast` operator is the\ntype of the function pointer for the `int`-version of `IsPositive()`.)\n\nAs another example, when you have a template function\n\n```\ntemplate <typename T>\nbool IsNegative(T x) {\n  return x < 0;\n}\n```\n\nyou can use it in a predicate assertion like this:\n\n```\nASSERT_PRED1(IsNegative*<int>*, -5);\n```\n\nThings are more interesting if your template has more than one parameters. The\nfollowing won't compile:\n\n```\nASSERT_PRED2(*GreaterThan<int, int>*, 5, 0);\n```\n\n\nas the C++ pre-processor thinks you are giving `ASSERT_PRED2` 4 arguments,\nwhich is one more than expected. The workaround is to wrap the predicate\nfunction in parentheses:\n\n```\nASSERT_PRED2(*(GreaterThan<int, int>)*, 5, 0);\n```\n\n\n## My compiler complains about \"ignoring return value\" when I call RUN\\_ALL\\_TESTS(). Why? ##\n\nSome people had been ignoring the return value of `RUN_ALL_TESTS()`. That is,\ninstead of\n\n```\nreturn RUN_ALL_TESTS();\n```\n\nthey write\n\n```\nRUN_ALL_TESTS();\n```\n\nThis is wrong and dangerous. A test runner needs to see the return value of\n`RUN_ALL_TESTS()` in order to determine if a test has passed. If your `main()`\nfunction ignores it, your test will be considered successful even if it has a\nGoogle Test assertion failure. Very bad.\n\nTo help the users avoid this dangerous bug, the implementation of\n`RUN_ALL_TESTS()` causes gcc to raise this warning, when the return value is\nignored. If you see this warning, the fix is simple: just make sure its value\nis used as the return value of `main()`.\n\n## My compiler complains that a constructor (or destructor) cannot return a value. What's going on? ##\n\nDue to a peculiarity of C++, in order to support the syntax for streaming\nmessages to an `ASSERT_*`, e.g.\n\n```\nASSERT_EQ(1, Foo()) << \"blah blah\" << foo;\n```\n\nwe had to give up using `ASSERT*` and `FAIL*` (but not `EXPECT*` and\n`ADD_FAILURE*`) in constructors and destructors. The workaround is to move the\ncontent of your constructor/destructor to a private void member function, or\nswitch to `EXPECT_*()` if that works. This section in the user's guide explains\nit.\n\n## My set-up function is not called. Why? ##\n\nC++ is case-sensitive. It should be spelled as `SetUp()`.  Did you\nspell it as `Setup()`?\n\nSimilarly, sometimes people spell `SetUpTestCase()` as `SetupTestCase()` and\nwonder why it's never called.\n\n## How do I jump to the line of a failure in Emacs directly? ##\n\nGoogle Test's failure message format is understood by Emacs and many other\nIDEs, like acme and XCode. If a Google Test message is in a compilation buffer\nin Emacs, then it's clickable. You can now hit `enter` on a message to jump to\nthe corresponding source code, or use `C-x `` to jump to the next failure.\n\n## I have several test cases which share the same test fixture logic, do I have to define a new test fixture class for each of them? This seems pretty tedious. ##\n\nYou don't have to. Instead of\n\n```\nclass FooTest : public BaseTest {};\n\nTEST_F(FooTest, Abc) { ... }\nTEST_F(FooTest, Def) { ... }\n\nclass BarTest : public BaseTest {};\n\nTEST_F(BarTest, Abc) { ... }\nTEST_F(BarTest, Def) { ... }\n```\n\nyou can simply `typedef` the test fixtures:\n```\ntypedef BaseTest FooTest;\n\nTEST_F(FooTest, Abc) { ... }\nTEST_F(FooTest, Def) { ... }\n\ntypedef BaseTest BarTest;\n\nTEST_F(BarTest, Abc) { ... }\nTEST_F(BarTest, Def) { ... }\n```\n\n## The Google Test output is buried in a whole bunch of log messages. What do I do? ##\n\nThe Google Test output is meant to be a concise and human-friendly report. If\nyour test generates textual output itself, it will mix with the Google Test\noutput, making it hard to read. However, there is an easy solution to this\nproblem.\n\nSince most log messages go to stderr, we decided to let Google Test output go\nto stdout. This way, you can easily separate the two using redirection. For\nexample:\n```\n./my_test > googletest_output.txt\n```\n\n## Why should I prefer test fixtures over global variables? ##\n\nThere are several good reasons:\n  1. It's likely your test needs to change the states of its global variables. This makes it difficult to keep side effects from escaping one test and contaminating others, making debugging difficult. By using fixtures, each test has a fresh set of variables that's different (but with the same names). Thus, tests are kept independent of each other.\n  1. Global variables pollute the global namespace.\n  1. Test fixtures can be reused via subclassing, which cannot be done easily with global variables. This is useful if many test cases have something in common.\n\n## How do I test private class members without writing FRIEND\\_TEST()s? ##\n\nYou should try to write testable code, which means classes should be easily\ntested from their public interface. One way to achieve this is the Pimpl idiom:\nyou move all private members of a class into a helper class, and make all\nmembers of the helper class public.\n\nYou have several other options that don't require using `FRIEND_TEST`:\n  * Write the tests as members of the fixture class:\n```\nclass Foo {\n  friend class FooTest;\n  ...\n};\n\nclass FooTest : public ::testing::Test {\n protected:\n  ...\n  void Test1() {...} // This accesses private members of class Foo.\n  void Test2() {...} // So does this one.\n};\n\nTEST_F(FooTest, Test1) {\n  Test1();\n}\n\nTEST_F(FooTest, Test2) {\n  Test2();\n}\n```\n  * In the fixture class, write accessors for the tested class' private members, then use the accessors in your tests:\n```\nclass Foo {\n  friend class FooTest;\n  ...\n};\n\nclass FooTest : public ::testing::Test {\n protected:\n  ...\n  T1 get_private_member1(Foo* obj) {\n    return obj->private_member1_;\n  }\n};\n\nTEST_F(FooTest, Test1) {\n  ...\n  get_private_member1(x)\n  ...\n}\n```\n  * If the methods are declared **protected**, you can change their access level in a test-only subclass:\n```\nclass YourClass {\n  ...\n protected: // protected access for testability.\n  int DoSomethingReturningInt();\n  ...\n};\n\n// in the your_class_test.cc file:\nclass TestableYourClass : public YourClass {\n  ...\n public: using YourClass::DoSomethingReturningInt; // changes access rights\n  ...\n};\n\nTEST_F(YourClassTest, DoSomethingTest) {\n  TestableYourClass obj;\n  assertEquals(expected_value, obj.DoSomethingReturningInt());\n}\n```\n\n## How do I test private class static members without writing FRIEND\\_TEST()s? ##\n\nWe find private static methods clutter the header file.  They are\nimplementation details and ideally should be kept out of a .h. So often I make\nthem free functions instead.\n\nInstead of:\n```\n// foo.h\nclass Foo {\n  ...\n private:\n  static bool Func(int n);\n};\n\n// foo.cc\nbool Foo::Func(int n) { ... }\n\n// foo_test.cc\nEXPECT_TRUE(Foo::Func(12345));\n```\n\nYou probably should better write:\n```\n// foo.h\nclass Foo {\n  ...\n};\n\n// foo.cc\nnamespace internal {\n  bool Func(int n) { ... }\n}\n\n// foo_test.cc\nnamespace internal {\n  bool Func(int n);\n}\n\nEXPECT_TRUE(internal::Func(12345));\n```\n\n## I would like to run a test several times with different parameters. Do I need to write several similar copies of it? ##\n\nNo. You can use a feature called [value-parameterized tests](V1_7_AdvancedGuide.md#Value_Parameterized_Tests) which\nlets you repeat your tests with different parameters, without defining it more than once.\n\n## How do I test a file that defines main()? ##\n\nTo test a `foo.cc` file, you need to compile and link it into your unit test\nprogram. However, when the file contains a definition for the `main()`\nfunction, it will clash with the `main()` of your unit test, and will result in\na build error.\n\nThe right solution is to split it into three files:\n  1. `foo.h` which contains the declarations,\n  1. `foo.cc` which contains the definitions except `main()`, and\n  1. `foo_main.cc` which contains nothing but the definition of `main()`.\n\nThen `foo.cc` can be easily tested.\n\nIf you are adding tests to an existing file and don't want an intrusive change\nlike this, there is a hack: just include the entire `foo.cc` file in your unit\ntest. For example:\n```\n// File foo_unittest.cc\n\n// The headers section\n...\n\n// Renames main() in foo.cc to make room for the unit test main()\n#define main FooMain\n\n#include \"a/b/foo.cc\"\n\n// The tests start here.\n...\n```\n\n\nHowever, please remember this is a hack and should only be used as the last\nresort.\n\n## What can the statement argument in ASSERT\\_DEATH() be? ##\n\n`ASSERT_DEATH(_statement_, _regex_)` (or any death assertion macro) can be used\nwherever `_statement_` is valid. So basically `_statement_` can be any C++\nstatement that makes sense in the current context. In particular, it can\nreference global and/or local variables, and can be:\n  * a simple function call (often the case),\n  * a complex expression, or\n  * a compound statement.\n\n> Some examples are shown here:\n\n```\n// A death test can be a simple function call.\nTEST(MyDeathTest, FunctionCall) {\n  ASSERT_DEATH(Xyz(5), \"Xyz failed\");\n}\n\n// Or a complex expression that references variables and functions.\nTEST(MyDeathTest, ComplexExpression) {\n  const bool c = Condition();\n  ASSERT_DEATH((c ? Func1(0) : object2.Method(\"test\")),\n               \"(Func1|Method) failed\");\n}\n\n// Death assertions can be used any where in a function. In\n// particular, they can be inside a loop.\nTEST(MyDeathTest, InsideLoop) {\n  // Verifies that Foo(0), Foo(1), ..., and Foo(4) all die.\n  for (int i = 0; i < 5; i++) {\n    EXPECT_DEATH_M(Foo(i), \"Foo has \\\\d+ errors\",\n                   ::testing::Message() << \"where i is \" << i);\n  }\n}\n\n// A death assertion can contain a compound statement.\nTEST(MyDeathTest, CompoundStatement) {\n  // Verifies that at lease one of Bar(0), Bar(1), ..., and\n  // Bar(4) dies.\n  ASSERT_DEATH({\n    for (int i = 0; i < 5; i++) {\n      Bar(i);\n    }\n  },\n  \"Bar has \\\\d+ errors\");}\n```\n\n`googletest_unittest.cc` contains more examples if you are interested.\n\n## What syntax does the regular expression in ASSERT\\_DEATH use? ##\n\nOn POSIX systems, Google Test uses the POSIX Extended regular\nexpression syntax\n(http://en.wikipedia.org/wiki/Regular_expression#POSIX_Extended_Regular_Expressions).\nOn Windows, it uses a limited variant of regular expression\nsyntax. For more details, see the\n[regular expression syntax](V1_7_AdvancedGuide.md#Regular_Expression_Syntax).\n\n## I have a fixture class Foo, but TEST\\_F(Foo, Bar) gives me error \"no matching function for call to Foo::Foo()\". Why? ##\n\nGoogle Test needs to be able to create objects of your test fixture class, so\nit must have a default constructor. Normally the compiler will define one for\nyou. However, there are cases where you have to define your own:\n  * If you explicitly declare a non-default constructor for class `Foo`, then you need to define a default constructor, even if it would be empty.\n  * If `Foo` has a const non-static data member, then you have to define the default constructor _and_ initialize the const member in the initializer list of the constructor. (Early versions of `gcc` doesn't force you to initialize the const member. It's a bug that has been fixed in `gcc 4`.)\n\n## Why does ASSERT\\_DEATH complain about previous threads that were already joined? ##\n\nWith the Linux pthread library, there is no turning back once you cross the\nline from single thread to multiple threads. The first time you create a\nthread, a manager thread is created in addition, so you get 3, not 2, threads.\nLater when the thread you create joins the main thread, the thread count\ndecrements by 1, but the manager thread will never be killed, so you still have\n2 threads, which means you cannot safely run a death test.\n\nThe new NPTL thread library doesn't suffer from this problem, as it doesn't\ncreate a manager thread. However, if you don't control which machine your test\nruns on, you shouldn't depend on this.\n\n## Why does Google Test require the entire test case, instead of individual tests, to be named FOODeathTest when it uses ASSERT\\_DEATH? ##\n\nGoogle Test does not interleave tests from different test cases. That is, it\nruns all tests in one test case first, and then runs all tests in the next test\ncase, and so on. Google Test does this because it needs to set up a test case\nbefore the first test in it is run, and tear it down afterwords. Splitting up\nthe test case would require multiple set-up and tear-down processes, which is\ninefficient and makes the semantics unclean.\n\nIf we were to determine the order of tests based on test name instead of test\ncase name, then we would have a problem with the following situation:\n\n```\nTEST_F(FooTest, AbcDeathTest) { ... }\nTEST_F(FooTest, Uvw) { ... }\n\nTEST_F(BarTest, DefDeathTest) { ... }\nTEST_F(BarTest, Xyz) { ... }\n```\n\nSince `FooTest.AbcDeathTest` needs to run before `BarTest.Xyz`, and we don't\ninterleave tests from different test cases, we need to run all tests in the\n`FooTest` case before running any test in the `BarTest` case. This contradicts\nwith the requirement to run `BarTest.DefDeathTest` before `FooTest.Uvw`.\n\n## But I don't like calling my entire test case FOODeathTest when it contains both death tests and non-death tests. What do I do? ##\n\nYou don't have to, but if you like, you may split up the test case into\n`FooTest` and `FooDeathTest`, where the names make it clear that they are\nrelated:\n\n```\nclass FooTest : public ::testing::Test { ... };\n\nTEST_F(FooTest, Abc) { ... }\nTEST_F(FooTest, Def) { ... }\n\ntypedef FooTest FooDeathTest;\n\nTEST_F(FooDeathTest, Uvw) { ... EXPECT_DEATH(...) ... }\nTEST_F(FooDeathTest, Xyz) { ... ASSERT_DEATH(...) ... }\n```\n\n## The compiler complains about \"no match for 'operator<<'\" when I use an assertion. What gives? ##\n\nIf you use a user-defined type `FooType` in an assertion, you must make sure\nthere is an `std::ostream& operator<<(std::ostream&, const FooType&)` function\ndefined such that we can print a value of `FooType`.\n\nIn addition, if `FooType` is declared in a name space, the `<<` operator also\nneeds to be defined in the _same_ name space.\n\n## How do I suppress the memory leak messages on Windows? ##\n\nSince the statically initialized Google Test singleton requires allocations on\nthe heap, the Visual C++ memory leak detector will report memory leaks at the\nend of the program run. The easiest way to avoid this is to use the\n`_CrtMemCheckpoint` and `_CrtMemDumpAllObjectsSince` calls to not report any\nstatically initialized heap objects. See MSDN for more details and additional\nheap check/debug routines.\n\n## I am building my project with Google Test in Visual Studio and all I'm getting is a bunch of linker errors (or warnings). Help! ##\n\nYou may get a number of the following linker error or warnings if you\nattempt to link your test project with the Google Test library when\nyour project and the are not built using the same compiler settings.\n\n  * LNK2005: symbol already defined in object\n  * LNK4217: locally defined symbol 'symbol' imported in function 'function'\n  * LNK4049: locally defined symbol 'symbol' imported\n\nThe Google Test project (gtest.vcproj) has the Runtime Library option\nset to /MT (use multi-threaded static libraries, /MTd for debug). If\nyour project uses something else, for example /MD (use multi-threaded\nDLLs, /MDd for debug), you need to change the setting in the Google\nTest project to match your project's.\n\nTo update this setting open the project properties in the Visual\nStudio IDE then select the branch Configuration Properties | C/C++ |\nCode Generation and change the option \"Runtime Library\".  You may also try\nusing gtest-md.vcproj instead of gtest.vcproj.\n\n## I put my tests in a library and Google Test doesn't run them. What's happening? ##\nHave you read a\n[warning](V1_7_Primer.md#important-note-for-visual-c-users) on\nthe Google Test Primer page?\n\n## I want to use Google Test with Visual Studio but don't know where to start. ##\nMany people are in your position and one of the posted his solution to\nour mailing list. Here is his link:\nhttp://hassanjamilahmad.blogspot.com/2009/07/gtest-starters-help.html.\n\n## I am seeing compile errors mentioning std::type\\_traits when I try to use Google Test on Solaris. ##\nGoogle Test uses parts of the standard C++ library that SunStudio does not support.\nOur users reported success using alternative implementations. Try running the build after runing this commad:\n\n`export CC=cc CXX=CC CXXFLAGS='-library=stlport4'`\n\n## How can my code detect if it is running in a test? ##\n\nIf you write code that sniffs whether it's running in a test and does\ndifferent things accordingly, you are leaking test-only logic into\nproduction code and there is no easy way to ensure that the test-only\ncode paths aren't run by mistake in production.  Such cleverness also\nleads to\n[Heisenbugs](http://en.wikipedia.org/wiki/Unusual_software_bug#Heisenbug).\nTherefore we strongly advise against the practice, and Google Test doesn't\nprovide a way to do it.\n\nIn general, the recommended way to cause the code to behave\ndifferently under test is [dependency injection](http://jamesshore.com/Blog/Dependency-Injection-Demystified.html).\nYou can inject different functionality from the test and from the\nproduction code.  Since your production code doesn't link in the\nfor-test logic at all, there is no danger in accidentally running it.\n\nHowever, if you _really_, _really_, _really_ have no choice, and if\nyou follow the rule of ending your test program names with `_test`,\nyou can use the _horrible_ hack of sniffing your executable name\n(`argv[0]` in `main()`) to know whether the code is under test.\n\n## Google Test defines a macro that clashes with one defined by another library. How do I deal with that? ##\n\nIn C++, macros don't obey namespaces.  Therefore two libraries that\nboth define a macro of the same name will clash if you `#include` both\ndefinitions.  In case a Google Test macro clashes with another\nlibrary, you can force Google Test to rename its macro to avoid the\nconflict.\n\nSpecifically, if both Google Test and some other code define macro\n`FOO`, you can add\n```\n  -DGTEST_DONT_DEFINE_FOO=1\n```\nto the compiler flags to tell Google Test to change the macro's name\nfrom `FOO` to `GTEST_FOO`. For example, with `-DGTEST_DONT_DEFINE_TEST=1`, you'll need to write\n```\n  GTEST_TEST(SomeTest, DoesThis) { ... }\n```\ninstead of\n```\n  TEST(SomeTest, DoesThis) { ... }\n```\nin order to define a test.\n\nCurrently, the following `TEST`, `FAIL`, `SUCCEED`, and the basic comparison assertion macros can have alternative names. You can see the full list of covered macros [here](http://www.google.com/codesearch?q=if+!GTEST_DONT_DEFINE_\\w%2B+package:http://googletest\\.googlecode\\.com+file:/include/gtest/gtest.h). More information can be found in the \"Avoiding Macro Name Clashes\" section of the README file.\n\n\n## Is it OK if I have two separate `TEST(Foo, Bar)` test methods defined in different namespaces? ##\n\nYes.\n\nThe rule is **all test methods in the same test case must use the same fixture class**. This means that the following is **allowed** because both tests use the same fixture class (`::testing::Test`).\n\n```\nnamespace foo {\nTEST(CoolTest, DoSomething) {\n  SUCCEED();\n}\n}  // namespace foo\n\nnamespace bar {\nTEST(CoolTest, DoSomething) {\n  SUCCEED();\n}\n}  // namespace foo\n```\n\nHowever, the following code is **not allowed** and will produce a runtime error from Google Test because the test methods are using different test fixture classes with the same test case name.\n\n```\nnamespace foo {\nclass CoolTest : public ::testing::Test {};  // Fixture foo::CoolTest\nTEST_F(CoolTest, DoSomething) {\n  SUCCEED();\n}\n}  // namespace foo\n\nnamespace bar {\nclass CoolTest : public ::testing::Test {};  // Fixture: bar::CoolTest\nTEST_F(CoolTest, DoSomething) {\n  SUCCEED();\n}\n}  // namespace foo\n```\n\n## How do I build Google Testing Framework with Xcode 4? ##\n\nIf you try to build Google Test's Xcode project with Xcode 4.0 or later, you may encounter an error message that looks like\n\"Missing SDK in target gtest\\_framework: /Developer/SDKs/MacOSX10.4u.sdk\". That means that Xcode does not support the SDK the project is targeting. See the Xcode section in the [README](../../README.MD) file on how to resolve this.\n\n## My question is not covered in your FAQ! ##\n\nIf you cannot find the answer to your question in this FAQ, there are\nsome other resources you can use:\n\n  1. read other [wiki pages](http://code.google.com/p/googletest/w/list),\n  1. search the mailing list [archive](http://groups.google.com/group/googletestframework/topics),\n  1. ask it on [googletestframework@googlegroups.com](mailto:googletestframework@googlegroups.com) and someone will answer it (to prevent spam, we require you to join the [discussion group](http://groups.google.com/group/googletestframework) before you can post.).\n\nPlease note that creating an issue in the\n[issue tracker](http://code.google.com/p/googletest/issues/list) is _not_\na good way to get your answer, as it is monitored infrequently by a\nvery small number of people.\n\nWhen asking a question, it's helpful to provide as much of the\nfollowing information as possible (people cannot help you if there's\nnot enough information in your question):\n\n  * the version (or the revision number if you check out from SVN directly) of Google Test you use (Google Test is under active development, so it's possible that your problem has been solved in a later version),\n  * your operating system,\n  * the name and version of your compiler,\n  * the complete command line flags you give to your compiler,\n  * the complete compiler error messages (if the question is about compilation),\n  * the _actual_ code (ideally, a minimal but complete program) that has the problem you encounter.\n"
  },
  {
    "path": "utils/googletest/googletest/docs/V1_7_Primer.md",
    "content": "\n\n# Introduction: Why Google C++ Testing Framework? #\n\n_Google C++ Testing Framework_ helps you write better C++ tests.\n\nNo matter whether you work on Linux, Windows, or a Mac, if you write C++ code,\nGoogle Test can help you.\n\nSo what makes a good test, and how does Google C++ Testing Framework fit in? We believe:\n  1. Tests should be _independent_ and _repeatable_. It's a pain to debug a test that succeeds or fails as a result of other tests.  Google C++ Testing Framework isolates the tests by running each of them on a different object. When a test fails, Google C++ Testing Framework allows you to run it in isolation for quick debugging.\n  1. Tests should be well _organized_ and reflect the structure of the tested code.  Google C++ Testing Framework groups related tests into test cases that can share data and subroutines. This common pattern is easy to recognize and makes tests easy to maintain. Such consistency is especially helpful when people switch projects and start to work on a new code base.\n  1. Tests should be _portable_ and _reusable_. The open-source community has a lot of code that is platform-neutral, its tests should also be platform-neutral.  Google C++ Testing Framework works on different OSes, with different compilers (gcc, MSVC, and others), with or without exceptions, so Google C++ Testing Framework tests can easily work with a variety of configurations.  (Note that the current release only contains build scripts for Linux - we are actively working on scripts for other platforms.)\n  1. When tests fail, they should provide as much _information_ about the problem as possible. Google C++ Testing Framework doesn't stop at the first test failure. Instead, it only stops the current test and continues with the next. You can also set up tests that report non-fatal failures after which the current test continues. Thus, you can detect and fix multiple bugs in a single run-edit-compile cycle.\n  1. The testing framework should liberate test writers from housekeeping chores and let them focus on the test _content_.  Google C++ Testing Framework automatically keeps track of all tests defined, and doesn't require the user to enumerate them in order to run them.\n  1. Tests should be _fast_. With Google C++ Testing Framework, you can reuse shared resources across tests and pay for the set-up/tear-down only once, without making tests depend on each other.\n\nSince Google C++ Testing Framework is based on the popular xUnit\narchitecture, you'll feel right at home if you've used JUnit or PyUnit before.\nIf not, it will take you about 10 minutes to learn the basics and get started.\nSo let's go!\n\n_Note:_ We sometimes refer to Google C++ Testing Framework informally\nas _Google Test_.\n\n# Setting up a New Test Project #\n\nTo write a test program using Google Test, you need to compile Google\nTest into a library and link your test with it.  We provide build\nfiles for some popular build systems: `msvc/` for Visual Studio,\n`xcode/` for Mac Xcode, `make/` for GNU make, `codegear/` for Borland\nC++ Builder, and the autotools script (deprecated) and\n`CMakeLists.txt` for CMake (recommended) in the Google Test root\ndirectory.  If your build system is not on this list, you can take a\nlook at `make/Makefile` to learn how Google Test should be compiled\n(basically you want to compile `src/gtest-all.cc` with `GTEST_ROOT`\nand `GTEST_ROOT/include` in the header search path, where `GTEST_ROOT`\nis the Google Test root directory).\n\nOnce you are able to compile the Google Test library, you should\ncreate a project or build target for your test program.  Make sure you\nhave `GTEST_ROOT/include` in the header search path so that the\ncompiler can find `\"gtest/gtest.h\"` when compiling your test.  Set up\nyour test project to link with the Google Test library (for example,\nin Visual Studio, this is done by adding a dependency on\n`gtest.vcproj`).\n\nIf you still have questions, take a look at how Google Test's own\ntests are built and use them as examples.\n\n# Basic Concepts #\n\nWhen using Google Test, you start by writing _assertions_, which are statements\nthat check whether a condition is true. An assertion's result can be _success_,\n_nonfatal failure_, or _fatal failure_. If a fatal failure occurs, it aborts\nthe current function; otherwise the program continues normally.\n\n_Tests_ use assertions to verify the tested code's behavior. If a test crashes\nor has a failed assertion, then it _fails_; otherwise it _succeeds_.\n\nA _test case_ contains one or many tests. You should group your tests into test\ncases that reflect the structure of the tested code. When multiple tests in a\ntest case need to share common objects and subroutines, you can put them into a\n_test fixture_ class.\n\nA _test program_ can contain multiple test cases.\n\nWe'll now explain how to write a test program, starting at the individual\nassertion level and building up to tests and test cases.\n\n# Assertions #\n\nGoogle Test assertions are macros that resemble function calls. You test a\nclass or function by making assertions about its behavior. When an assertion\nfails, Google Test prints the assertion's source file and line number location,\nalong with a failure message. You may also supply a custom failure message\nwhich will be appended to Google Test's message.\n\nThe assertions come in pairs that test the same thing but have different\neffects on the current function. `ASSERT_*` versions generate fatal failures\nwhen they fail, and **abort the current function**. `EXPECT_*` versions generate\nnonfatal failures, which don't abort the current function. Usually `EXPECT_*`\nare preferred, as they allow more than one failures to be reported in a test.\nHowever, you should use `ASSERT_*` if it doesn't make sense to continue when\nthe assertion in question fails.\n\nSince a failed `ASSERT_*` returns from the current function immediately,\npossibly skipping clean-up code that comes after it, it may cause a space leak.\nDepending on the nature of the leak, it may or may not be worth fixing - so\nkeep this in mind if you get a heap checker error in addition to assertion\nerrors.\n\nTo provide a custom failure message, simply stream it into the macro using the\n`<<` operator, or a sequence of such operators. An example:\n```\nASSERT_EQ(x.size(), y.size()) << \"Vectors x and y are of unequal length\";\n\nfor (int i = 0; i < x.size(); ++i) {\n  EXPECT_EQ(x[i], y[i]) << \"Vectors x and y differ at index \" << i;\n}\n```\n\nAnything that can be streamed to an `ostream` can be streamed to an assertion\nmacro--in particular, C strings and `string` objects. If a wide string\n(`wchar_t*`, `TCHAR*` in `UNICODE` mode on Windows, or `std::wstring`) is\nstreamed to an assertion, it will be translated to UTF-8 when printed.\n\n## Basic Assertions ##\n\nThese assertions do basic true/false condition testing.\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_TRUE(`_condition_`)`;  | `EXPECT_TRUE(`_condition_`)`;   | _condition_ is true |\n| `ASSERT_FALSE(`_condition_`)`; | `EXPECT_FALSE(`_condition_`)`;  | _condition_ is false |\n\nRemember, when they fail, `ASSERT_*` yields a fatal failure and\nreturns from the current function, while `EXPECT_*` yields a nonfatal\nfailure, allowing the function to continue running. In either case, an\nassertion failure means its containing test fails.\n\n_Availability_: Linux, Windows, Mac.\n\n## Binary Comparison ##\n\nThis section describes assertions that compare two values.\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n|`ASSERT_EQ(`_expected_`, `_actual_`);`|`EXPECT_EQ(`_expected_`, `_actual_`);`| _expected_ `==` _actual_ |\n|`ASSERT_NE(`_val1_`, `_val2_`);`      |`EXPECT_NE(`_val1_`, `_val2_`);`      | _val1_ `!=` _val2_ |\n|`ASSERT_LT(`_val1_`, `_val2_`);`      |`EXPECT_LT(`_val1_`, `_val2_`);`      | _val1_ `<` _val2_ |\n|`ASSERT_LE(`_val1_`, `_val2_`);`      |`EXPECT_LE(`_val1_`, `_val2_`);`      | _val1_ `<=` _val2_ |\n|`ASSERT_GT(`_val1_`, `_val2_`);`      |`EXPECT_GT(`_val1_`, `_val2_`);`      | _val1_ `>` _val2_ |\n|`ASSERT_GE(`_val1_`, `_val2_`);`      |`EXPECT_GE(`_val1_`, `_val2_`);`      | _val1_ `>=` _val2_ |\n\nIn the event of a failure, Google Test prints both _val1_ and _val2_\n. In `ASSERT_EQ*` and `EXPECT_EQ*` (and all other equality assertions\nwe'll introduce later), you should put the expression you want to test\nin the position of _actual_, and put its expected value in _expected_,\nas Google Test's failure messages are optimized for this convention.\n\nValue arguments must be comparable by the assertion's comparison\noperator or you'll get a compiler error.  We used to require the\narguments to support the `<<` operator for streaming to an `ostream`,\nbut it's no longer necessary since v1.6.0 (if `<<` is supported, it\nwill be called to print the arguments when the assertion fails;\notherwise Google Test will attempt to print them in the best way it\ncan. For more details and how to customize the printing of the\narguments, see this Google Mock [recipe](../../googlemock/docs/CookBook.md#teaching-google-mock-how-to-print-your-values).).\n\nThese assertions can work with a user-defined type, but only if you define the\ncorresponding comparison operator (e.g. `==`, `<`, etc).  If the corresponding\noperator is defined, prefer using the `ASSERT_*()` macros because they will\nprint out not only the result of the comparison, but the two operands as well.\n\nArguments are always evaluated exactly once. Therefore, it's OK for the\narguments to have side effects. However, as with any ordinary C/C++ function,\nthe arguments' evaluation order is undefined (i.e. the compiler is free to\nchoose any order) and your code should not depend on any particular argument\nevaluation order.\n\n`ASSERT_EQ()` does pointer equality on pointers. If used on two C strings, it\ntests if they are in the same memory location, not if they have the same value.\nTherefore, if you want to compare C strings (e.g. `const char*`) by value, use\n`ASSERT_STREQ()` , which will be described later on. In particular, to assert\nthat a C string is `NULL`, use `ASSERT_STREQ(NULL, c_string)` . However, to\ncompare two `string` objects, you should use `ASSERT_EQ`.\n\nMacros in this section work with both narrow and wide string objects (`string`\nand `wstring`).\n\n_Availability_: Linux, Windows, Mac.\n\n## String Comparison ##\n\nThe assertions in this group compare two **C strings**. If you want to compare\ntwo `string` objects, use `EXPECT_EQ`, `EXPECT_NE`, and etc instead.\n\n| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |\n|:--------------------|:-----------------------|:-------------|\n| `ASSERT_STREQ(`_expected\\_str_`, `_actual\\_str_`);`    | `EXPECT_STREQ(`_expected\\_str_`, `_actual\\_str_`);`     | the two C strings have the same content |\n| `ASSERT_STRNE(`_str1_`, `_str2_`);`    | `EXPECT_STRNE(`_str1_`, `_str2_`);`     | the two C strings have different content |\n| `ASSERT_STRCASEEQ(`_expected\\_str_`, `_actual\\_str_`);`| `EXPECT_STRCASEEQ(`_expected\\_str_`, `_actual\\_str_`);` | the two C strings have the same content, ignoring case |\n| `ASSERT_STRCASENE(`_str1_`, `_str2_`);`| `EXPECT_STRCASENE(`_str1_`, `_str2_`);` | the two C strings have different content, ignoring case |\n\nNote that \"CASE\" in an assertion name means that case is ignored.\n\n`*STREQ*` and `*STRNE*` also accept wide C strings (`wchar_t*`). If a\ncomparison of two wide strings fails, their values will be printed as UTF-8\nnarrow strings.\n\nA `NULL` pointer and an empty string are considered _different_.\n\n_Availability_: Linux, Windows, Mac.\n\nSee also: For more string comparison tricks (substring, prefix, suffix, and\nregular expression matching, for example), see the [Advanced Google Test Guide](V1_7_AdvancedGuide.md).\n\n# Simple Tests #\n\nTo create a test:\n  1. Use the `TEST()` macro to define and name a test function, These are ordinary C++ functions that don't return a value.\n  1. In this function, along with any valid C++ statements you want to include, use the various Google Test assertions to check values.\n  1. The test's result is determined by the assertions; if any assertion in the test fails (either fatally or non-fatally), or if the test crashes, the entire test fails. Otherwise, it succeeds.\n\n```\nTEST(test_case_name, test_name) {\n ... test body ...\n}\n```\n\n\n`TEST()` arguments go from general to specific. The _first_ argument is the\nname of the test case, and the _second_ argument is the test's name within the\ntest case. Both names must be valid C++ identifiers, and they should not contain underscore (`_`). A test's _full name_ consists of its containing test case and its\nindividual name. Tests from different test cases can have the same individual\nname.\n\nFor example, let's take a simple integer function:\n```\nint Factorial(int n); // Returns the factorial of n\n```\n\nA test case for this function might look like:\n```\n// Tests factorial of 0.\nTEST(FactorialTest, HandlesZeroInput) {\n  EXPECT_EQ(1, Factorial(0));\n}\n\n// Tests factorial of positive numbers.\nTEST(FactorialTest, HandlesPositiveInput) {\n  EXPECT_EQ(1, Factorial(1));\n  EXPECT_EQ(2, Factorial(2));\n  EXPECT_EQ(6, Factorial(3));\n  EXPECT_EQ(40320, Factorial(8));\n}\n```\n\nGoogle Test groups the test results by test cases, so logically-related tests\nshould be in the same test case; in other words, the first argument to their\n`TEST()` should be the same. In the above example, we have two tests,\n`HandlesZeroInput` and `HandlesPositiveInput`, that belong to the same test\ncase `FactorialTest`.\n\n_Availability_: Linux, Windows, Mac.\n\n# Test Fixtures: Using the Same Data Configuration for Multiple Tests #\n\nIf you find yourself writing two or more tests that operate on similar data,\nyou can use a _test fixture_. It allows you to reuse the same configuration of\nobjects for several different tests.\n\nTo create a fixture, just:\n  1. Derive a class from `::testing::Test` . Start its body with `protected:` or `public:` as we'll want to access fixture members from sub-classes.\n  1. Inside the class, declare any objects you plan to use.\n  1. If necessary, write a default constructor or `SetUp()` function to prepare the objects for each test. A common mistake is to spell `SetUp()` as `Setup()` with a small `u` - don't let that happen to you.\n  1. If necessary, write a destructor or `TearDown()` function to release any resources you allocated in `SetUp()` . To learn when you should use the constructor/destructor and when you should use `SetUp()/TearDown()`, read this [FAQ entry](V1_7_FAQ.md#should-i-use-the-constructordestructor-of-the-test-fixture-or-the-set-uptear-down-function).\n  1. If needed, define subroutines for your tests to share.\n\nWhen using a fixture, use `TEST_F()` instead of `TEST()` as it allows you to\naccess objects and subroutines in the test fixture:\n```\nTEST_F(test_case_name, test_name) {\n ... test body ...\n}\n```\n\nLike `TEST()`, the first argument is the test case name, but for `TEST_F()`\nthis must be the name of the test fixture class. You've probably guessed: `_F`\nis for fixture.\n\nUnfortunately, the C++ macro system does not allow us to create a single macro\nthat can handle both types of tests. Using the wrong macro causes a compiler\nerror.\n\nAlso, you must first define a test fixture class before using it in a\n`TEST_F()`, or you'll get the compiler error \"`virtual outside class\ndeclaration`\".\n\nFor each test defined with `TEST_F()`, Google Test will:\n  1. Create a _fresh_ test fixture at runtime\n  1. Immediately initialize it via `SetUp()` ,\n  1. Run the test\n  1. Clean up by calling `TearDown()`\n  1. Delete the test fixture.  Note that different tests in the same test case have different test fixture objects, and Google Test always deletes a test fixture before it creates the next one. Google Test does not reuse the same test fixture for multiple tests. Any changes one test makes to the fixture do not affect other tests.\n\nAs an example, let's write tests for a FIFO queue class named `Queue`, which\nhas the following interface:\n```\ntemplate <typename E> // E is the element type.\nclass Queue {\n public:\n  Queue();\n  void Enqueue(const E& element);\n  E* Dequeue(); // Returns NULL if the queue is empty.\n  size_t size() const;\n  ...\n};\n```\n\nFirst, define a fixture class. By convention, you should give it the name\n`FooTest` where `Foo` is the class being tested.\n```\nclass QueueTest : public ::testing::Test {\n protected:\n  virtual void SetUp() {\n    q1_.Enqueue(1);\n    q2_.Enqueue(2);\n    q2_.Enqueue(3);\n  }\n\n  // virtual void TearDown() {}\n\n  Queue<int> q0_;\n  Queue<int> q1_;\n  Queue<int> q2_;\n};\n```\n\nIn this case, `TearDown()` is not needed since we don't have to clean up after\neach test, other than what's already done by the destructor.\n\nNow we'll write tests using `TEST_F()` and this fixture.\n```\nTEST_F(QueueTest, IsEmptyInitially) {\n  EXPECT_EQ(0, q0_.size());\n}\n\nTEST_F(QueueTest, DequeueWorks) {\n  int* n = q0_.Dequeue();\n  EXPECT_EQ(NULL, n);\n\n  n = q1_.Dequeue();\n  ASSERT_TRUE(n != NULL);\n  EXPECT_EQ(1, *n);\n  EXPECT_EQ(0, q1_.size());\n  delete n;\n\n  n = q2_.Dequeue();\n  ASSERT_TRUE(n != NULL);\n  EXPECT_EQ(2, *n);\n  EXPECT_EQ(1, q2_.size());\n  delete n;\n}\n```\n\nThe above uses both `ASSERT_*` and `EXPECT_*` assertions. The rule of thumb is\nto use `EXPECT_*` when you want the test to continue to reveal more errors\nafter the assertion failure, and use `ASSERT_*` when continuing after failure\ndoesn't make sense. For example, the second assertion in the `Dequeue` test is\n`ASSERT_TRUE(n != NULL)`, as we need to dereference the pointer `n` later,\nwhich would lead to a segfault when `n` is `NULL`.\n\nWhen these tests run, the following happens:\n  1. Google Test constructs a `QueueTest` object (let's call it `t1` ).\n  1. `t1.SetUp()` initializes `t1` .\n  1. The first test ( `IsEmptyInitially` ) runs on `t1` .\n  1. `t1.TearDown()` cleans up after the test finishes.\n  1. `t1` is destructed.\n  1. The above steps are repeated on another `QueueTest` object, this time running the `DequeueWorks` test.\n\n_Availability_: Linux, Windows, Mac.\n\n_Note_: Google Test automatically saves all _Google Test_ flags when a test\nobject is constructed, and restores them when it is destructed.\n\n# Invoking the Tests #\n\n`TEST()` and `TEST_F()` implicitly register their tests with Google Test. So, unlike with many other C++ testing frameworks, you don't have to re-list all your defined tests in order to run them.\n\nAfter defining your tests, you can run them with `RUN_ALL_TESTS()` , which returns `0` if all the tests are successful, or `1` otherwise. Note that `RUN_ALL_TESTS()` runs _all tests_ in your link unit -- they can be from different test cases, or even different source files.\n\nWhen invoked, the `RUN_ALL_TESTS()` macro:\n  1. Saves the state of all  Google Test flags.\n  1. Creates a test fixture object for the first test.\n  1. Initializes it via `SetUp()`.\n  1. Runs the test on the fixture object.\n  1. Cleans up the fixture via `TearDown()`.\n  1. Deletes the fixture.\n  1. Restores the state of all Google Test flags.\n  1. Repeats the above steps for the next test, until all tests have run.\n\nIn addition, if the text fixture's constructor generates a fatal failure in\nstep 2, there is no point for step 3 - 5 and they are thus skipped. Similarly,\nif step 3 generates a fatal failure, step 4 will be skipped.\n\n_Important_: You must not ignore the return value of `RUN_ALL_TESTS()`, or `gcc`\nwill give you a compiler error. The rationale for this design is that the\nautomated testing service determines whether a test has passed based on its\nexit code, not on its stdout/stderr output; thus your `main()` function must\nreturn the value of `RUN_ALL_TESTS()`.\n\nAlso, you should call `RUN_ALL_TESTS()` only **once**. Calling it more than once\nconflicts with some advanced Google Test features (e.g. thread-safe death\ntests) and thus is not supported.\n\n_Availability_: Linux, Windows, Mac.\n\n# Writing the main() Function #\n\nYou can start from this boilerplate:\n```\n#include \"this/package/foo.h\"\n#include \"gtest/gtest.h\"\n\nnamespace {\n\n// The fixture for testing class Foo.\nclass FooTest : public ::testing::Test {\n protected:\n  // You can remove any or all of the following functions if its body\n  // is empty.\n\n  FooTest() {\n    // You can do set-up work for each test here.\n  }\n\n  virtual ~FooTest() {\n    // You can do clean-up work that doesn't throw exceptions here.\n  }\n\n  // If the constructor and destructor are not enough for setting up\n  // and cleaning up each test, you can define the following methods:\n\n  virtual void SetUp() {\n    // Code here will be called immediately after the constructor (right\n    // before each test).\n  }\n\n  virtual void TearDown() {\n    // Code here will be called immediately after each test (right\n    // before the destructor).\n  }\n\n  // Objects declared here can be used by all tests in the test case for Foo.\n};\n\n// Tests that the Foo::Bar() method does Abc.\nTEST_F(FooTest, MethodBarDoesAbc) {\n  const string input_filepath = \"this/package/testdata/myinputfile.dat\";\n  const string output_filepath = \"this/package/testdata/myoutputfile.dat\";\n  Foo f;\n  EXPECT_EQ(0, f.Bar(input_filepath, output_filepath));\n}\n\n// Tests that Foo does Xyz.\nTEST_F(FooTest, DoesXyz) {\n  // Exercises the Xyz feature of Foo.\n}\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n```\n\nThe `::testing::InitGoogleTest()` function parses the command line for Google\nTest flags, and removes all recognized flags. This allows the user to control a\ntest program's behavior via various flags, which we'll cover in [AdvancedGuide](V1_7_AdvancedGuide.md).\nYou must call this function before calling `RUN_ALL_TESTS()`, or the flags\nwon't be properly initialized.\n\nOn Windows, `InitGoogleTest()` also works with wide strings, so it can be used\nin programs compiled in `UNICODE` mode as well.\n\nBut maybe you think that writing all those main() functions is too much work? We agree with you completely and that's why Google Test provides a basic implementation of main(). If it fits your needs, then just link your test with gtest\\_main library and you are good to go.\n\n## Important note for Visual C++ users ##\nIf you put your tests into a library and your `main()` function is in a different library or in your .exe file, those tests will not run. The reason is a [bug](https://connect.microsoft.com/feedback/viewfeedback.aspx?FeedbackID=244410&siteid=210) in Visual C++. When you define your tests, Google Test creates certain static objects to register them. These objects are not referenced from elsewhere but their constructors are still supposed to run. When Visual C++ linker sees that nothing in the library is referenced from other places it throws the library out. You have to reference your library with tests from your main program to keep the linker from discarding it. Here is how to do it. Somewhere in your library code declare a function:\n```\n__declspec(dllexport) int PullInMyLibrary() { return 0; }\n```\nIf you put your tests in a static library (not DLL) then `__declspec(dllexport)` is not required. Now, in your main program, write a code that invokes that function:\n```\nint PullInMyLibrary();\nstatic int dummy = PullInMyLibrary();\n```\nThis will keep your tests referenced and will make them register themselves at startup.\n\nIn addition, if you define your tests in a static library, add `/OPT:NOREF` to your main program linker options. If you use MSVC++ IDE, go to your .exe project properties/Configuration Properties/Linker/Optimization and set References setting to `Keep Unreferenced Data (/OPT:NOREF)`. This will keep Visual C++ linker from discarding individual symbols generated by your tests from the final executable.\n\nThere is one more pitfall, though. If you use Google Test as a static library (that's how it is defined in gtest.vcproj) your tests must also reside in a static library. If you have to have them in a DLL, you _must_ change Google Test to build into a DLL as well. Otherwise your tests will not run correctly or will not run at all. The general conclusion here is: make your life easier - do not write your tests in libraries!\n\n# Where to Go from Here #\n\nCongratulations! You've learned the Google Test basics. You can start writing\nand running Google Test tests, read some [samples](V1_7_Samples.md), or continue with\n[AdvancedGuide](V1_7_AdvancedGuide.md), which describes many more useful Google Test features.\n\n# Known Limitations #\n\nGoogle Test is designed to be thread-safe.  The implementation is\nthread-safe on systems where the `pthreads` library is available.  It\nis currently _unsafe_ to use Google Test assertions from two threads\nconcurrently on other systems (e.g. Windows).  In most tests this is\nnot an issue as usually the assertions are done in the main thread. If\nyou want to help, you can volunteer to implement the necessary\nsynchronization primitives in `gtest-port.h` for your platform.\n"
  },
  {
    "path": "utils/googletest/googletest/docs/V1_7_PumpManual.md",
    "content": "\n\n<b>P</b>ump is <b>U</b>seful for <b>M</b>eta <b>P</b>rogramming.\n\n# The Problem #\n\nTemplate and macro libraries often need to define many classes,\nfunctions, or macros that vary only (or almost only) in the number of\narguments they take. It's a lot of repetitive, mechanical, and\nerror-prone work.\n\nVariadic templates and variadic macros can alleviate the problem.\nHowever, while both are being considered by the C++ committee, neither\nis in the standard yet or widely supported by compilers.  Thus they\nare often not a good choice, especially when your code needs to be\nportable. And their capabilities are still limited.\n\nAs a result, authors of such libraries often have to write scripts to\ngenerate their implementation. However, our experience is that it's\ntedious to write such scripts, which tend to reflect the structure of\nthe generated code poorly and are often hard to read and edit. For\nexample, a small change needed in the generated code may require some\nnon-intuitive, non-trivial changes in the script. This is especially\npainful when experimenting with the code.\n\n# Our Solution #\n\nPump (for Pump is Useful for Meta Programming, Pretty Useful for Meta\nProgramming, or Practical Utility for Meta Programming, whichever you\nprefer) is a simple meta-programming tool for C++. The idea is that a\nprogrammer writes a `foo.pump` file which contains C++ code plus meta\ncode that manipulates the C++ code. The meta code can handle\niterations over a range, nested iterations, local meta variable\ndefinitions, simple arithmetic, and conditional expressions. You can\nview it as a small Domain-Specific Language. The meta language is\ndesigned to be non-intrusive (s.t. it won't confuse Emacs' C++ mode,\nfor example) and concise, making Pump code intuitive and easy to\nmaintain.\n\n## Highlights ##\n\n  * The implementation is in a single Python script and thus ultra portable: no build or installation is needed and it works cross platforms.\n  * Pump tries to be smart with respect to [Google's style guide](http://code.google.com/p/google-styleguide/): it breaks long lines (easy to have when they are generated) at acceptable places to fit within 80 columns and indent the continuation lines correctly.\n  * The format is human-readable and more concise than XML.\n  * The format works relatively well with Emacs' C++ mode.\n\n## Examples ##\n\nThe following Pump code (where meta keywords start with `$`, `[[` and `]]` are meta brackets, and `$$` starts a meta comment that ends with the line):\n\n```\n$var n = 3     $$ Defines a meta variable n.\n$range i 0..n  $$ Declares the range of meta iterator i (inclusive).\n$for i [[\n               $$ Meta loop.\n// Foo$i does blah for $i-ary predicates.\n$range j 1..i\ntemplate <size_t N $for j [[, typename A$j]]>\nclass Foo$i {\n$if i == 0 [[\n  blah a;\n]] $elif i <= 2 [[\n  blah b;\n]] $else [[\n  blah c;\n]]\n};\n\n]]\n```\n\nwill be translated by the Pump compiler to:\n\n```\n// Foo0 does blah for 0-ary predicates.\ntemplate <size_t N>\nclass Foo0 {\n  blah a;\n};\n\n// Foo1 does blah for 1-ary predicates.\ntemplate <size_t N, typename A1>\nclass Foo1 {\n  blah b;\n};\n\n// Foo2 does blah for 2-ary predicates.\ntemplate <size_t N, typename A1, typename A2>\nclass Foo2 {\n  blah b;\n};\n\n// Foo3 does blah for 3-ary predicates.\ntemplate <size_t N, typename A1, typename A2, typename A3>\nclass Foo3 {\n  blah c;\n};\n```\n\nIn another example,\n\n```\n$range i 1..n\nFunc($for i + [[a$i]]);\n$$ The text between i and [[ is the separator between iterations.\n```\n\nwill generate one of the following lines (without the comments), depending on the value of `n`:\n\n```\nFunc();              // If n is 0.\nFunc(a1);            // If n is 1.\nFunc(a1 + a2);       // If n is 2.\nFunc(a1 + a2 + a3);  // If n is 3.\n// And so on...\n```\n\n## Constructs ##\n\nWe support the following meta programming constructs:\n\n| `$var id = exp` | Defines a named constant value. `$id` is valid util the end of the current meta lexical block. |\n|:----------------|:-----------------------------------------------------------------------------------------------|\n| `$range id exp..exp` | Sets the range of an iteration variable, which can be reused in multiple loops later.          |\n| `$for id sep [[ code ]]` | Iteration. The range of `id` must have been defined earlier. `$id` is valid in `code`.         |\n| `$($)`          | Generates a single `$` character.                                                              |\n| `$id`           | Value of the named constant or iteration variable.                                             |\n| `$(exp)`        | Value of the expression.                                                                       |\n| `$if exp [[ code ]] else_branch` | Conditional.                                                                                   |\n| `[[ code ]]`    | Meta lexical block.                                                                            |\n| `cpp_code`      | Raw C++ code.                                                                                  |\n| `$$ comment`    | Meta comment.                                                                                  |\n\n**Note:** To give the user some freedom in formatting the Pump source\ncode, Pump ignores a new-line character if it's right after `$for foo`\nor next to `[[` or `]]`. Without this rule you'll often be forced to write\nvery long lines to get the desired output. Therefore sometimes you may\nneed to insert an extra new-line in such places for a new-line to show\nup in your output.\n\n## Grammar ##\n\n```\ncode ::= atomic_code*\natomic_code ::= $var id = exp\n    | $var id = [[ code ]]\n    | $range id exp..exp\n    | $for id sep [[ code ]]\n    | $($)\n    | $id\n    | $(exp)\n    | $if exp [[ code ]] else_branch\n    | [[ code ]]\n    | cpp_code\nsep ::= cpp_code | empty_string\nelse_branch ::= $else [[ code ]]\n    | $elif exp [[ code ]] else_branch\n    | empty_string\nexp ::= simple_expression_in_Python_syntax\n```\n\n## Code ##\n\nYou can find the source code of Pump in [scripts/pump.py](../scripts/pump.py). It is still\nvery unpolished and lacks automated tests, although it has been\nsuccessfully used many times. If you find a chance to use it in your\nproject, please let us know what you think!  We also welcome help on\nimproving Pump.\n\n## Real Examples ##\n\nYou can find real-world applications of Pump in [Google Test](http://www.google.com/codesearch?q=file%3A\\.pump%24+package%3Ahttp%3A%2F%2Fgoogletest\\.googlecode\\.com) and [Google Mock](http://www.google.com/codesearch?q=file%3A\\.pump%24+package%3Ahttp%3A%2F%2Fgooglemock\\.googlecode\\.com).  The source file `foo.h.pump` generates `foo.h`.\n\n## Tips ##\n\n  * If a meta variable is followed by a letter or digit, you can separate them using `[[]]`, which inserts an empty string. For example `Foo$j[[]]Helper` generate `Foo1Helper` when `j` is 1.\n  * To avoid extra-long Pump source lines, you can break a line anywhere you want by inserting `[[]]` followed by a new line. Since any new-line character next to `[[` or `]]` is ignored, the generated code won't contain this new line.\n"
  },
  {
    "path": "utils/googletest/googletest/docs/V1_7_Samples.md",
    "content": "If you're like us, you'd like to look at some Google Test sample code.  The\n[samples folder](../samples) has a number of well-commented samples showing how to use a\nvariety of Google Test features.\n\n  * [Sample #1](../samples/sample1_unittest.cc) shows the basic steps of using Google Test to test C++ functions.\n  * [Sample #2](../samples/sample2_unittest.cc) shows a more complex unit test for a class with multiple member functions.\n  * [Sample #3](../samples/sample3_unittest.cc) uses a test fixture.\n  * [Sample #4](../samples/sample4_unittest.cc) is another basic example of using Google Test.\n  * [Sample #5](../samples/sample5_unittest.cc) teaches how to reuse a test fixture in multiple test cases by deriving sub-fixtures from it.\n  * [Sample #6](../samples/sample6_unittest.cc) demonstrates type-parameterized tests.\n  * [Sample #7](../samples/sample7_unittest.cc) teaches the basics of value-parameterized tests.\n  * [Sample #8](../samples/sample8_unittest.cc) shows using `Combine()` in value-parameterized tests.\n  * [Sample #9](../samples/sample9_unittest.cc) shows use of the listener API to modify Google Test's console output and the use of its reflection API to inspect test results.\n  * [Sample #10](../samples/sample10_unittest.cc) shows use of the listener API to implement a primitive memory leak checker.\n"
  },
  {
    "path": "utils/googletest/googletest/docs/V1_7_XcodeGuide.md",
    "content": "\n\nThis guide will explain how to use the Google Testing Framework in your Xcode projects on Mac OS X. This tutorial begins by quickly explaining what to do for experienced users. After the quick start, the guide goes provides additional explanation about each step.\n\n# Quick Start #\n\nHere is the quick guide for using Google Test in your Xcode project.\n\n  1. Download the source from the [website](http://code.google.com/p/googletest) using this command: `svn checkout http://googletest.googlecode.com/svn/trunk/ googletest-read-only`\n  1. Open up the `gtest.xcodeproj` in the `googletest-read-only/xcode/` directory and build the gtest.framework.\n  1. Create a new \"Shell Tool\" target in your Xcode project called something like \"UnitTests\"\n  1. Add the gtest.framework to your project and add it to the \"Link Binary with Libraries\" build phase of \"UnitTests\"\n  1. Add your unit test source code to the \"Compile Sources\" build phase of \"UnitTests\"\n  1. Edit the \"UnitTests\" executable and add an environment variable named \"DYLD\\_FRAMEWORK\\_PATH\" with a value equal to the path to the framework containing the gtest.framework relative to the compiled executable.\n  1. Build and Go\n\nThe following sections further explain each of the steps listed above in depth, describing in more detail how to complete it including some variations.\n\n# Get the Source #\n\nCurrently, the gtest.framework discussed here isn't available in a tagged release of Google Test, it is only available in the trunk. As explained at the Google Test [site](http://code.google.com/p/googletest/source/checkout\">svn), you can get the code from anonymous SVN with this command:\n\n```\nsvn checkout http://googletest.googlecode.com/svn/trunk/ googletest-read-only\n```\n\nAlternatively, if you are working with Subversion in your own code base, you can add Google Test as an external dependency to your own Subversion repository. By following this approach, everyone that checks out your svn repository will also receive a copy of Google Test (a specific version, if you wish) without having to check it out explicitly. This makes the set up of your project simpler and reduces the copied code in the repository.\n\nTo use `svn:externals`, decide where you would like to have the external source reside. You might choose to put the external source inside the trunk, because you want it to be part of the branch when you make a release. However, keeping it outside the trunk in a version-tagged directory called something like `third-party/googletest/1.0.1`, is another option. Once the location is established, use `svn propedit svn:externals _directory_` to set the svn:externals property on a directory in your repository. This directory won't contain the code, but be its versioned parent directory.\n\nThe command `svn propedit` will bring up your Subversion editor, making editing the long, (potentially multi-line) property simpler. This same method can be used to check out a tagged branch, by using the appropriate URL (e.g. `http://googletest.googlecode.com/svn/tags/release-1.0.1`). Additionally, the svn:externals property allows the specification of a particular revision of the trunk with the `-r_##_` option (e.g. `externals/src/googletest -r60 http://googletest.googlecode.com/svn/trunk`).\n\nHere is an example of using the svn:externals properties on a trunk (read via `svn propget`) of a project. This value checks out a copy of Google Test into the `trunk/externals/src/googletest/` directory.\n\n```\n[Computer:svn] user$ svn propget svn:externals trunk\nexternals/src/googletest http://googletest.googlecode.com/svn/trunk\n```\n\n# Add the Framework to Your Project #\n\nThe next step is to build and add the gtest.framework to your own project. This guide describes two common ways below.\n\n  * **Option 1** --- The simplest way to add Google Test to your own project, is to open gtest.xcodeproj (found in the xcode/ directory of the Google Test trunk) and build the framework manually. Then, add the built framework into your project using the \"Add->Existing Framework...\" from the context menu or \"Project->Add...\" from the main menu. The gtest.framework is relocatable and contains the headers and object code that you'll need to make tests. This method requires rebuilding every time you upgrade Google Test in your project.\n  * **Option 2** --- If you are going to be living off the trunk of Google Test, incorporating its latest features into your unit tests (or are a Google Test developer yourself). You'll want to rebuild the framework every time the source updates. to do this, you'll need to add the gtest.xcodeproj file, not the framework itself, to your own Xcode project. Then, from the build products that are revealed by the project's disclosure triangle, you can find the gtest.framework, which can be added to your targets (discussed below).\n\n# Make a Test Target #\n\nTo start writing tests, make a new \"Shell Tool\" target. This target template is available under BSD, Cocoa, or Carbon. Add your unit test source code to the \"Compile Sources\" build phase of the target.\n\nNext, you'll want to add gtest.framework in two different ways, depending upon which option you chose above.\n\n  * **Option 1** --- During compilation, Xcode will need to know that you are linking against the gtest.framework. Add the gtest.framework to the \"Link Binary with Libraries\" build phase of your test target. This will include the Google Test headers in your header search path, and will tell the linker where to find the library.\n  * **Option 2** --- If your working out of the trunk, you'll also want to add gtest.framework to your \"Link Binary with Libraries\" build phase of your test target. In addition, you'll  want to add the gtest.framework as a dependency to your unit test target. This way, Xcode will make sure that gtest.framework is up to date, every time your build your target. Finally, if you don't share build directories with Google Test, you'll have to copy the gtest.framework into your own build products directory using a \"Run Script\" build phase.\n\n# Set Up the Executable Run Environment #\n\nSince the unit test executable is a shell tool, it doesn't have a bundle with a `Contents/Frameworks` directory, in which to place gtest.framework. Instead, the dynamic linker must be told at runtime to search for the framework in another location. This can be accomplished by setting the \"DYLD\\_FRAMEWORK\\_PATH\" environment variable in the \"Edit Active Executable ...\" Arguments tab, under \"Variables to be set in the environment:\". The path for this value is the path (relative or absolute) of the directory containing the gtest.framework.\n\nIf you haven't set up the DYLD\\_FRAMEWORK\\_PATH, correctly, you might get a message like this:\n\n```\n[Session started at 2008-08-15 06:23:57 -0600.]\n  dyld: Library not loaded: @loader_path/../Frameworks/gtest.framework/Versions/A/gtest\n    Referenced from: /Users/username/Documents/Sandbox/gtestSample/build/Debug/WidgetFrameworkTest\n    Reason: image not found\n```\n\nTo correct this problem, got to the directory containing the executable named in \"Referenced from:\" value in the error message above. Then, with the terminal in this location, find the relative path to the directory containing the gtest.framework. That is the value you'll need to set as the DYLD\\_FRAMEWORK\\_PATH.\n\n# Build and Go #\n\nNow, when you click \"Build and Go\", the test will be executed. Dumping out something like this:\n\n```\n[Session started at 2008-08-06 06:36:13 -0600.]\n[==========] Running 2 tests from 1 test case.\n[----------] Global test environment set-up.\n[----------] 2 tests from WidgetInitializerTest\n[ RUN      ] WidgetInitializerTest.TestConstructor\n[       OK ] WidgetInitializerTest.TestConstructor\n[ RUN      ] WidgetInitializerTest.TestConversion\n[       OK ] WidgetInitializerTest.TestConversion\n[----------] Global test environment tear-down\n[==========] 2 tests from 1 test case ran.\n[  PASSED  ] 2 tests.\n\nThe Debugger has exited with status 0.  \n```\n\n# Summary #\n\nUnit testing is a valuable way to ensure your data model stays valid even during rapid development or refactoring. The Google Testing Framework is a great unit testing framework for C and C++ which integrates well with an Xcode development environment."
  },
  {
    "path": "utils/googletest/googletest/docs/XcodeGuide.md",
    "content": "\n\nThis guide will explain how to use the Google Testing Framework in your Xcode projects on Mac OS X. This tutorial begins by quickly explaining what to do for experienced users. After the quick start, the guide goes provides additional explanation about each step.\n\n# Quick Start #\n\nHere is the quick guide for using Google Test in your Xcode project.\n\n  1. Download the source from the [website](http://code.google.com/p/googletest) using this command: `svn checkout http://googletest.googlecode.com/svn/trunk/ googletest-read-only`\n  1. Open up the `gtest.xcodeproj` in the `googletest-read-only/xcode/` directory and build the gtest.framework.\n  1. Create a new \"Shell Tool\" target in your Xcode project called something like \"UnitTests\"\n  1. Add the gtest.framework to your project and add it to the \"Link Binary with Libraries\" build phase of \"UnitTests\"\n  1. Add your unit test source code to the \"Compile Sources\" build phase of \"UnitTests\"\n  1. Edit the \"UnitTests\" executable and add an environment variable named \"DYLD\\_FRAMEWORK\\_PATH\" with a value equal to the path to the framework containing the gtest.framework relative to the compiled executable.\n  1. Build and Go\n\nThe following sections further explain each of the steps listed above in depth, describing in more detail how to complete it including some variations.\n\n# Get the Source #\n\nCurrently, the gtest.framework discussed here isn't available in a tagged release of Google Test, it is only available in the trunk. As explained at the Google Test [site](http://code.google.com/p/googletest/source/checkout\">svn), you can get the code from anonymous SVN with this command:\n\n```\nsvn checkout http://googletest.googlecode.com/svn/trunk/ googletest-read-only\n```\n\nAlternatively, if you are working with Subversion in your own code base, you can add Google Test as an external dependency to your own Subversion repository. By following this approach, everyone that checks out your svn repository will also receive a copy of Google Test (a specific version, if you wish) without having to check it out explicitly. This makes the set up of your project simpler and reduces the copied code in the repository.\n\nTo use `svn:externals`, decide where you would like to have the external source reside. You might choose to put the external source inside the trunk, because you want it to be part of the branch when you make a release. However, keeping it outside the trunk in a version-tagged directory called something like `third-party/googletest/1.0.1`, is another option. Once the location is established, use `svn propedit svn:externals _directory_` to set the svn:externals property on a directory in your repository. This directory won't contain the code, but be its versioned parent directory.\n\nThe command `svn propedit` will bring up your Subversion editor, making editing the long, (potentially multi-line) property simpler. This same method can be used to check out a tagged branch, by using the appropriate URL (e.g. `http://googletest.googlecode.com/svn/tags/release-1.0.1`). Additionally, the svn:externals property allows the specification of a particular revision of the trunk with the `-r_##_` option (e.g. `externals/src/googletest -r60 http://googletest.googlecode.com/svn/trunk`).\n\nHere is an example of using the svn:externals properties on a trunk (read via `svn propget`) of a project. This value checks out a copy of Google Test into the `trunk/externals/src/googletest/` directory.\n\n```\n[Computer:svn] user$ svn propget svn:externals trunk\nexternals/src/googletest http://googletest.googlecode.com/svn/trunk\n```\n\n# Add the Framework to Your Project #\n\nThe next step is to build and add the gtest.framework to your own project. This guide describes two common ways below.\n\n  * **Option 1** --- The simplest way to add Google Test to your own project, is to open gtest.xcodeproj (found in the xcode/ directory of the Google Test trunk) and build the framework manually. Then, add the built framework into your project using the \"Add->Existing Framework...\" from the context menu or \"Project->Add...\" from the main menu. The gtest.framework is relocatable and contains the headers and object code that you'll need to make tests. This method requires rebuilding every time you upgrade Google Test in your project.\n  * **Option 2** --- If you are going to be living off the trunk of Google Test, incorporating its latest features into your unit tests (or are a Google Test developer yourself). You'll want to rebuild the framework every time the source updates. to do this, you'll need to add the gtest.xcodeproj file, not the framework itself, to your own Xcode project. Then, from the build products that are revealed by the project's disclosure triangle, you can find the gtest.framework, which can be added to your targets (discussed below).\n\n# Make a Test Target #\n\nTo start writing tests, make a new \"Shell Tool\" target. This target template is available under BSD, Cocoa, or Carbon. Add your unit test source code to the \"Compile Sources\" build phase of the target.\n\nNext, you'll want to add gtest.framework in two different ways, depending upon which option you chose above.\n\n  * **Option 1** --- During compilation, Xcode will need to know that you are linking against the gtest.framework. Add the gtest.framework to the \"Link Binary with Libraries\" build phase of your test target. This will include the Google Test headers in your header search path, and will tell the linker where to find the library.\n  * **Option 2** --- If your working out of the trunk, you'll also want to add gtest.framework to your \"Link Binary with Libraries\" build phase of your test target. In addition, you'll  want to add the gtest.framework as a dependency to your unit test target. This way, Xcode will make sure that gtest.framework is up to date, every time your build your target. Finally, if you don't share build directories with Google Test, you'll have to copy the gtest.framework into your own build products directory using a \"Run Script\" build phase.\n\n# Set Up the Executable Run Environment #\n\nSince the unit test executable is a shell tool, it doesn't have a bundle with a `Contents/Frameworks` directory, in which to place gtest.framework. Instead, the dynamic linker must be told at runtime to search for the framework in another location. This can be accomplished by setting the \"DYLD\\_FRAMEWORK\\_PATH\" environment variable in the \"Edit Active Executable ...\" Arguments tab, under \"Variables to be set in the environment:\". The path for this value is the path (relative or absolute) of the directory containing the gtest.framework.\n\nIf you haven't set up the DYLD\\_FRAMEWORK\\_PATH, correctly, you might get a message like this:\n\n```\n[Session started at 2008-08-15 06:23:57 -0600.]\n  dyld: Library not loaded: @loader_path/../Frameworks/gtest.framework/Versions/A/gtest\n    Referenced from: /Users/username/Documents/Sandbox/gtestSample/build/Debug/WidgetFrameworkTest\n    Reason: image not found\n```\n\nTo correct this problem, got to the directory containing the executable named in \"Referenced from:\" value in the error message above. Then, with the terminal in this location, find the relative path to the directory containing the gtest.framework. That is the value you'll need to set as the DYLD\\_FRAMEWORK\\_PATH.\n\n# Build and Go #\n\nNow, when you click \"Build and Go\", the test will be executed. Dumping out something like this:\n\n```\n[Session started at 2008-08-06 06:36:13 -0600.]\n[==========] Running 2 tests from 1 test case.\n[----------] Global test environment set-up.\n[----------] 2 tests from WidgetInitializerTest\n[ RUN      ] WidgetInitializerTest.TestConstructor\n[       OK ] WidgetInitializerTest.TestConstructor\n[ RUN      ] WidgetInitializerTest.TestConversion\n[       OK ] WidgetInitializerTest.TestConversion\n[----------] Global test environment tear-down\n[==========] 2 tests from 1 test case ran.\n[  PASSED  ] 2 tests.\n\nThe Debugger has exited with status 0.  \n```\n\n# Summary #\n\nUnit testing is a valuable way to ensure your data model stays valid even during rapid development or refactoring. The Google Testing Framework is a great unit testing framework for C and C++ which integrates well with an Xcode development environment."
  },
  {
    "path": "utils/googletest/googletest/include/gtest/gtest-death-test.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This header file defines the public API for death tests.  It is\n// #included by gtest.h so a user doesn't need to include this\n// directly.\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_\n#define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_\n\n#include \"gtest/internal/gtest-death-test-internal.h\"\n\nnamespace testing {\n\n// This flag controls the style of death tests.  Valid values are \"threadsafe\",\n// meaning that the death test child process will re-execute the test binary\n// from the start, running only a single death test, or \"fast\",\n// meaning that the child process will execute the test logic immediately\n// after forking.\nGTEST_DECLARE_string_(death_test_style);\n\n#if GTEST_HAS_DEATH_TEST\n\nnamespace internal {\n\n// Returns a Boolean value indicating whether the caller is currently\n// executing in the context of the death test child process.  Tools such as\n// Valgrind heap checkers may need this to modify their behavior in death\n// tests.  IMPORTANT: This is an internal utility.  Using it may break the\n// implementation of death tests.  User code MUST NOT use it.\nGTEST_API_ bool InDeathTestChild();\n\n}  // namespace internal\n\n// The following macros are useful for writing death tests.\n\n// Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is\n// executed:\n//\n//   1. It generates a warning if there is more than one active\n//   thread.  This is because it's safe to fork() or clone() only\n//   when there is a single thread.\n//\n//   2. The parent process clone()s a sub-process and runs the death\n//   test in it; the sub-process exits with code 0 at the end of the\n//   death test, if it hasn't exited already.\n//\n//   3. The parent process waits for the sub-process to terminate.\n//\n//   4. The parent process checks the exit code and error message of\n//   the sub-process.\n//\n// Examples:\n//\n//   ASSERT_DEATH(server.SendMessage(56, \"Hello\"), \"Invalid port number\");\n//   for (int i = 0; i < 5; i++) {\n//     EXPECT_DEATH(server.ProcessRequest(i),\n//                  \"Invalid request .* in ProcessRequest()\")\n//                  << \"Failed to die on request \" << i;\n//   }\n//\n//   ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), \"Exiting\");\n//\n//   bool KilledBySIGHUP(int exit_code) {\n//     return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP;\n//   }\n//\n//   ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, \"Hanging up!\");\n//\n// On the regular expressions used in death tests:\n//\n//   On POSIX-compliant systems (*nix), we use the <regex.h> library,\n//   which uses the POSIX extended regex syntax.\n//\n//   On other platforms (e.g. Windows), we only support a simple regex\n//   syntax implemented as part of Google Test.  This limited\n//   implementation should be enough most of the time when writing\n//   death tests; though it lacks many features you can find in PCRE\n//   or POSIX extended regex syntax.  For example, we don't support\n//   union (\"x|y\"), grouping (\"(xy)\"), brackets (\"[xy]\"), and\n//   repetition count (\"x{5,7}\"), among others.\n//\n//   Below is the syntax that we do support.  We chose it to be a\n//   subset of both PCRE and POSIX extended regex, so it's easy to\n//   learn wherever you come from.  In the following: 'A' denotes a\n//   literal character, period (.), or a single \\\\ escape sequence;\n//   'x' and 'y' denote regular expressions; 'm' and 'n' are for\n//   natural numbers.\n//\n//     c     matches any literal character c\n//     \\\\d   matches any decimal digit\n//     \\\\D   matches any character that's not a decimal digit\n//     \\\\f   matches \\f\n//     \\\\n   matches \\n\n//     \\\\r   matches \\r\n//     \\\\s   matches any ASCII whitespace, including \\n\n//     \\\\S   matches any character that's not a whitespace\n//     \\\\t   matches \\t\n//     \\\\v   matches \\v\n//     \\\\w   matches any letter, _, or decimal digit\n//     \\\\W   matches any character that \\\\w doesn't match\n//     \\\\c   matches any literal character c, which must be a punctuation\n//     .     matches any single character except \\n\n//     A?    matches 0 or 1 occurrences of A\n//     A*    matches 0 or many occurrences of A\n//     A+    matches 1 or many occurrences of A\n//     ^     matches the beginning of a string (not that of each line)\n//     $     matches the end of a string (not that of each line)\n//     xy    matches x followed by y\n//\n//   If you accidentally use PCRE or POSIX extended regex features\n//   not implemented by us, you will get a run-time failure.  In that\n//   case, please try to rewrite your regular expression within the\n//   above syntax.\n//\n//   This implementation is *not* meant to be as highly tuned or robust\n//   as a compiled regex library, but should perform well enough for a\n//   death test, which already incurs significant overhead by launching\n//   a child process.\n//\n// Known caveats:\n//\n//   A \"threadsafe\" style death test obtains the path to the test\n//   program from argv[0] and re-executes it in the sub-process.  For\n//   simplicity, the current implementation doesn't search the PATH\n//   when launching the sub-process.  This means that the user must\n//   invoke the test program via a path that contains at least one\n//   path separator (e.g. path/to/foo_test and\n//   /absolute/path/to/bar_test are fine, but foo_test is not).  This\n//   is rarely a problem as people usually don't put the test binary\n//   directory in PATH.\n//\n// TODO(wan@google.com): make thread-safe death tests search the PATH.\n\n// Asserts that a given statement causes the program to exit, with an\n// integer exit status that satisfies predicate, and emitting error output\n// that matches regex.\n# define ASSERT_EXIT(statement, predicate, regex) \\\n    GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)\n\n// Like ASSERT_EXIT, but continues on to successive tests in the\n// test case, if any:\n# define EXPECT_EXIT(statement, predicate, regex) \\\n    GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)\n\n// Asserts that a given statement causes the program to exit, either by\n// explicitly exiting with a nonzero exit code or being killed by a\n// signal, and emitting error output that matches regex.\n# define ASSERT_DEATH(statement, regex) \\\n    ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)\n\n// Like ASSERT_DEATH, but continues on to successive tests in the\n// test case, if any:\n# define EXPECT_DEATH(statement, regex) \\\n    EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)\n\n// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:\n\n// Tests that an exit code describes a normal exit with a given exit code.\nclass GTEST_API_ ExitedWithCode {\n public:\n  explicit ExitedWithCode(int exit_code);\n  bool operator()(int exit_status) const;\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ExitedWithCode& other);\n\n  const int exit_code_;\n};\n\n# if !GTEST_OS_WINDOWS\n// Tests that an exit code describes an exit due to termination by a\n// given signal.\nclass GTEST_API_ KilledBySignal {\n public:\n  explicit KilledBySignal(int signum);\n  bool operator()(int exit_status) const;\n private:\n  const int signum_;\n};\n# endif  // !GTEST_OS_WINDOWS\n\n// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.\n// The death testing framework causes this to have interesting semantics,\n// since the sideeffects of the call are only visible in opt mode, and not\n// in debug mode.\n//\n// In practice, this can be used to test functions that utilize the\n// LOG(DFATAL) macro using the following style:\n//\n// int DieInDebugOr12(int* sideeffect) {\n//   if (sideeffect) {\n//     *sideeffect = 12;\n//   }\n//   LOG(DFATAL) << \"death\";\n//   return 12;\n// }\n//\n// TEST(TestCase, TestDieOr12WorksInDgbAndOpt) {\n//   int sideeffect = 0;\n//   // Only asserts in dbg.\n//   EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), \"death\");\n//\n// #ifdef NDEBUG\n//   // opt-mode has sideeffect visible.\n//   EXPECT_EQ(12, sideeffect);\n// #else\n//   // dbg-mode no visible sideeffect.\n//   EXPECT_EQ(0, sideeffect);\n// #endif\n// }\n//\n// This will assert that DieInDebugReturn12InOpt() crashes in debug\n// mode, usually due to a DCHECK or LOG(DFATAL), but returns the\n// appropriate fallback value (12 in this case) in opt mode. If you\n// need to test that a function has appropriate side-effects in opt\n// mode, include assertions against the side-effects.  A general\n// pattern for this is:\n//\n// EXPECT_DEBUG_DEATH({\n//   // Side-effects here will have an effect after this statement in\n//   // opt mode, but none in debug mode.\n//   EXPECT_EQ(12, DieInDebugOr12(&sideeffect));\n// }, \"death\");\n//\n# ifdef NDEBUG\n\n#  define EXPECT_DEBUG_DEATH(statement, regex) \\\n  GTEST_EXECUTE_STATEMENT_(statement, regex)\n\n#  define ASSERT_DEBUG_DEATH(statement, regex) \\\n  GTEST_EXECUTE_STATEMENT_(statement, regex)\n\n# else\n\n#  define EXPECT_DEBUG_DEATH(statement, regex) \\\n  EXPECT_DEATH(statement, regex)\n\n#  define ASSERT_DEBUG_DEATH(statement, regex) \\\n  ASSERT_DEATH(statement, regex)\n\n# endif  // NDEBUG for EXPECT_DEBUG_DEATH\n#endif  // GTEST_HAS_DEATH_TEST\n\n// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and\n// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if\n// death tests are supported; otherwise they just issue a warning.  This is\n// useful when you are combining death test assertions with normal test\n// assertions in one test.\n#if GTEST_HAS_DEATH_TEST\n# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \\\n    EXPECT_DEATH(statement, regex)\n# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \\\n    ASSERT_DEATH(statement, regex)\n#else\n# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \\\n    GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, )\n# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \\\n    GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return)\n#endif\n\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/gtest-message.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This header file defines the Message class.\n//\n// IMPORTANT NOTE: Due to limitation of the C++ language, we have to\n// leave some internal implementation details in this header file.\n// They are clearly marked by comments like this:\n//\n//   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n//\n// Such code is NOT meant to be used by a user directly, and is subject\n// to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user\n// program!\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_\n#define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_\n\n#include <limits>\n\n#include \"gtest/internal/gtest-port.h\"\n\n// Ensures that there is at least one operator<< in the global namespace.\n// See Message& operator<<(...) below for why.\nvoid operator<<(const testing::internal::Secret&, int);\n\nnamespace testing {\n\n// The Message class works like an ostream repeater.\n//\n// Typical usage:\n//\n//   1. You stream a bunch of values to a Message object.\n//      It will remember the text in a stringstream.\n//   2. Then you stream the Message object to an ostream.\n//      This causes the text in the Message to be streamed\n//      to the ostream.\n//\n// For example;\n//\n//   testing::Message foo;\n//   foo << 1 << \" != \" << 2;\n//   std::cout << foo;\n//\n// will print \"1 != 2\".\n//\n// Message is not intended to be inherited from.  In particular, its\n// destructor is not virtual.\n//\n// Note that stringstream behaves differently in gcc and in MSVC.  You\n// can stream a NULL char pointer to it in the former, but not in the\n// latter (it causes an access violation if you do).  The Message\n// class hides this difference by treating a NULL char pointer as\n// \"(null)\".\nclass GTEST_API_ Message {\n private:\n  // The type of basic IO manipulators (endl, ends, and flush) for\n  // narrow streams.\n  typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);\n\n public:\n  // Constructs an empty Message.\n  Message();\n\n  // Copy constructor.\n  Message(const Message& msg) : ss_(new ::std::stringstream) {  // NOLINT\n    *ss_ << msg.GetString();\n  }\n\n  // Constructs a Message from a C-string.\n  explicit Message(const char* str) : ss_(new ::std::stringstream) {\n    *ss_ << str;\n  }\n\n#if GTEST_OS_SYMBIAN\n  // Streams a value (either a pointer or not) to this object.\n  template <typename T>\n  inline Message& operator <<(const T& value) {\n    StreamHelper(typename internal::is_pointer<T>::type(), value);\n    return *this;\n  }\n#else\n  // Streams a non-pointer value to this object.\n  template <typename T>\n  inline Message& operator <<(const T& val) {\n    // Some libraries overload << for STL containers.  These\n    // overloads are defined in the global namespace instead of ::std.\n    //\n    // C++'s symbol lookup rule (i.e. Koenig lookup) says that these\n    // overloads are visible in either the std namespace or the global\n    // namespace, but not other namespaces, including the testing\n    // namespace which Google Test's Message class is in.\n    //\n    // To allow STL containers (and other types that has a << operator\n    // defined in the global namespace) to be used in Google Test\n    // assertions, testing::Message must access the custom << operator\n    // from the global namespace.  With this using declaration,\n    // overloads of << defined in the global namespace and those\n    // visible via Koenig lookup are both exposed in this function.\n    using ::operator <<;\n    *ss_ << val;\n    return *this;\n  }\n\n  // Streams a pointer value to this object.\n  //\n  // This function is an overload of the previous one.  When you\n  // stream a pointer to a Message, this definition will be used as it\n  // is more specialized.  (The C++ Standard, section\n  // [temp.func.order].)  If you stream a non-pointer, then the\n  // previous definition will be used.\n  //\n  // The reason for this overload is that streaming a NULL pointer to\n  // ostream is undefined behavior.  Depending on the compiler, you\n  // may get \"0\", \"(nil)\", \"(null)\", or an access violation.  To\n  // ensure consistent result across compilers, we always treat NULL\n  // as \"(null)\".\n  template <typename T>\n  inline Message& operator <<(T* const& pointer) {  // NOLINT\n    if (pointer == NULL) {\n      *ss_ << \"(null)\";\n    } else {\n      *ss_ << pointer;\n    }\n    return *this;\n  }\n#endif  // GTEST_OS_SYMBIAN\n\n  // Since the basic IO manipulators are overloaded for both narrow\n  // and wide streams, we have to provide this specialized definition\n  // of operator <<, even though its body is the same as the\n  // templatized version above.  Without this definition, streaming\n  // endl or other basic IO manipulators to Message will confuse the\n  // compiler.\n  Message& operator <<(BasicNarrowIoManip val) {\n    *ss_ << val;\n    return *this;\n  }\n\n  // Instead of 1/0, we want to see true/false for bool values.\n  Message& operator <<(bool b) {\n    return *this << (b ? \"true\" : \"false\");\n  }\n\n  // These two overloads allow streaming a wide C string to a Message\n  // using the UTF-8 encoding.\n  Message& operator <<(const wchar_t* wide_c_str);\n  Message& operator <<(wchar_t* wide_c_str);\n\n#if GTEST_HAS_STD_WSTRING\n  // Converts the given wide string to a narrow string using the UTF-8\n  // encoding, and streams the result to this Message object.\n  Message& operator <<(const ::std::wstring& wstr);\n#endif  // GTEST_HAS_STD_WSTRING\n\n#if GTEST_HAS_GLOBAL_WSTRING\n  // Converts the given wide string to a narrow string using the UTF-8\n  // encoding, and streams the result to this Message object.\n  Message& operator <<(const ::wstring& wstr);\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n  // Gets the text streamed to this object so far as an std::string.\n  // Each '\\0' character in the buffer is replaced with \"\\\\0\".\n  //\n  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n  std::string GetString() const;\n\n private:\n\n#if GTEST_OS_SYMBIAN\n  // These are needed as the Nokia Symbian Compiler cannot decide between\n  // const T& and const T* in a function template. The Nokia compiler _can_\n  // decide between class template specializations for T and T*, so a\n  // tr1::type_traits-like is_pointer works, and we can overload on that.\n  template <typename T>\n  inline void StreamHelper(internal::true_type /*is_pointer*/, T* pointer) {\n    if (pointer == NULL) {\n      *ss_ << \"(null)\";\n    } else {\n      *ss_ << pointer;\n    }\n  }\n  template <typename T>\n  inline void StreamHelper(internal::false_type /*is_pointer*/,\n                           const T& value) {\n    // See the comments in Message& operator <<(const T&) above for why\n    // we need this using statement.\n    using ::operator <<;\n    *ss_ << value;\n  }\n#endif  // GTEST_OS_SYMBIAN\n\n  // We'll hold the text streamed to this object here.\n  const internal::scoped_ptr< ::std::stringstream> ss_;\n\n  // We declare (but don't implement) this to prevent the compiler\n  // from implementing the assignment operator.\n  void operator=(const Message&);\n};\n\n// Streams a Message to an ostream.\ninline std::ostream& operator <<(std::ostream& os, const Message& sb) {\n  return os << sb.GetString();\n}\n\nnamespace internal {\n\n// Converts a streamable value to an std::string.  A NULL pointer is\n// converted to \"(null)\".  When the input value is a ::string,\n// ::std::string, ::wstring, or ::std::wstring object, each NUL\n// character in it is replaced with \"\\\\0\".\ntemplate <typename T>\nstd::string StreamableToString(const T& streamable) {\n  return (Message() << streamable).GetString();\n}\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/gtest-param-test.h",
    "content": "// This file was GENERATED by command:\n//     pump.py gtest-param-test.h.pump\n// DO NOT EDIT BY HAND!!!\n\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: vladl@google.com (Vlad Losev)\n//\n// Macros and functions for implementing parameterized tests\n// in Google C++ Testing Framework (Google Test)\n//\n// This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!\n//\n#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_\n#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_\n\n\n// Value-parameterized tests allow you to test your code with different\n// parameters without writing multiple copies of the same test.\n//\n// Here is how you use value-parameterized tests:\n\n#if 0\n\n// To write value-parameterized tests, first you should define a fixture\n// class. It is usually derived from testing::TestWithParam<T> (see below for\n// another inheritance scheme that's sometimes useful in more complicated\n// class hierarchies), where the type of your parameter values.\n// TestWithParam<T> is itself derived from testing::Test. T can be any\n// copyable type. If it's a raw pointer, you are responsible for managing the\n// lifespan of the pointed values.\n\nclass FooTest : public ::testing::TestWithParam<const char*> {\n  // You can implement all the usual class fixture members here.\n};\n\n// Then, use the TEST_P macro to define as many parameterized tests\n// for this fixture as you want. The _P suffix is for \"parameterized\"\n// or \"pattern\", whichever you prefer to think.\n\nTEST_P(FooTest, DoesBlah) {\n  // Inside a test, access the test parameter with the GetParam() method\n  // of the TestWithParam<T> class:\n  EXPECT_TRUE(foo.Blah(GetParam()));\n  ...\n}\n\nTEST_P(FooTest, HasBlahBlah) {\n  ...\n}\n\n// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test\n// case with any set of parameters you want. Google Test defines a number\n// of functions for generating test parameters. They return what we call\n// (surprise!) parameter generators. Here is a  summary of them, which\n// are all in the testing namespace:\n//\n//\n//  Range(begin, end [, step]) - Yields values {begin, begin+step,\n//                               begin+step+step, ...}. The values do not\n//                               include end. step defaults to 1.\n//  Values(v1, v2, ..., vN)    - Yields values {v1, v2, ..., vN}.\n//  ValuesIn(container)        - Yields values from a C-style array, an STL\n//  ValuesIn(begin,end)          container, or an iterator range [begin, end).\n//  Bool()                     - Yields sequence {false, true}.\n//  Combine(g1, g2, ..., gN)   - Yields all combinations (the Cartesian product\n//                               for the math savvy) of the values generated\n//                               by the N generators.\n//\n// For more details, see comments at the definitions of these functions below\n// in this file.\n//\n// The following statement will instantiate tests from the FooTest test case\n// each with parameter values \"meeny\", \"miny\", and \"moe\".\n\nINSTANTIATE_TEST_CASE_P(InstantiationName,\n                        FooTest,\n                        Values(\"meeny\", \"miny\", \"moe\"));\n\n// To distinguish different instances of the pattern, (yes, you\n// can instantiate it more then once) the first argument to the\n// INSTANTIATE_TEST_CASE_P macro is a prefix that will be added to the\n// actual test case name. Remember to pick unique prefixes for different\n// instantiations. The tests from the instantiation above will have\n// these names:\n//\n//    * InstantiationName/FooTest.DoesBlah/0 for \"meeny\"\n//    * InstantiationName/FooTest.DoesBlah/1 for \"miny\"\n//    * InstantiationName/FooTest.DoesBlah/2 for \"moe\"\n//    * InstantiationName/FooTest.HasBlahBlah/0 for \"meeny\"\n//    * InstantiationName/FooTest.HasBlahBlah/1 for \"miny\"\n//    * InstantiationName/FooTest.HasBlahBlah/2 for \"moe\"\n//\n// You can use these names in --gtest_filter.\n//\n// This statement will instantiate all tests from FooTest again, each\n// with parameter values \"cat\" and \"dog\":\n\nconst char* pets[] = {\"cat\", \"dog\"};\nINSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));\n\n// The tests from the instantiation above will have these names:\n//\n//    * AnotherInstantiationName/FooTest.DoesBlah/0 for \"cat\"\n//    * AnotherInstantiationName/FooTest.DoesBlah/1 for \"dog\"\n//    * AnotherInstantiationName/FooTest.HasBlahBlah/0 for \"cat\"\n//    * AnotherInstantiationName/FooTest.HasBlahBlah/1 for \"dog\"\n//\n// Please note that INSTANTIATE_TEST_CASE_P will instantiate all tests\n// in the given test case, whether their definitions come before or\n// AFTER the INSTANTIATE_TEST_CASE_P statement.\n//\n// Please also note that generator expressions (including parameters to the\n// generators) are evaluated in InitGoogleTest(), after main() has started.\n// This allows the user on one hand, to adjust generator parameters in order\n// to dynamically determine a set of tests to run and on the other hand,\n// give the user a chance to inspect the generated tests with Google Test\n// reflection API before RUN_ALL_TESTS() is executed.\n//\n// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc\n// for more examples.\n//\n// In the future, we plan to publish the API for defining new parameter\n// generators. But for now this interface remains part of the internal\n// implementation and is subject to change.\n//\n//\n// A parameterized test fixture must be derived from testing::Test and from\n// testing::WithParamInterface<T>, where T is the type of the parameter\n// values. Inheriting from TestWithParam<T> satisfies that requirement because\n// TestWithParam<T> inherits from both Test and WithParamInterface. In more\n// complicated hierarchies, however, it is occasionally useful to inherit\n// separately from Test and WithParamInterface. For example:\n\nclass BaseTest : public ::testing::Test {\n  // You can inherit all the usual members for a non-parameterized test\n  // fixture here.\n};\n\nclass DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {\n  // The usual test fixture members go here too.\n};\n\nTEST_F(BaseTest, HasFoo) {\n  // This is an ordinary non-parameterized test.\n}\n\nTEST_P(DerivedTest, DoesBlah) {\n  // GetParam works just the same here as if you inherit from TestWithParam.\n  EXPECT_TRUE(foo.Blah(GetParam()));\n}\n\n#endif  // 0\n\n#include \"gtest/internal/gtest-port.h\"\n\n#if !GTEST_OS_SYMBIAN\n# include <utility>\n#endif\n\n// scripts/fuse_gtest.py depends on gtest's own header being #included\n// *unconditionally*.  Therefore these #includes cannot be moved\n// inside #if GTEST_HAS_PARAM_TEST.\n#include \"gtest/internal/gtest-internal.h\"\n#include \"gtest/internal/gtest-param-util.h\"\n#include \"gtest/internal/gtest-param-util-generated.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\nnamespace testing {\n\n// Functions producing parameter generators.\n//\n// Google Test uses these generators to produce parameters for value-\n// parameterized tests. When a parameterized test case is instantiated\n// with a particular generator, Google Test creates and runs tests\n// for each element in the sequence produced by the generator.\n//\n// In the following sample, tests from test case FooTest are instantiated\n// each three times with parameter values 3, 5, and 8:\n//\n// class FooTest : public TestWithParam<int> { ... };\n//\n// TEST_P(FooTest, TestThis) {\n// }\n// TEST_P(FooTest, TestThat) {\n// }\n// INSTANTIATE_TEST_CASE_P(TestSequence, FooTest, Values(3, 5, 8));\n//\n\n// Range() returns generators providing sequences of values in a range.\n//\n// Synopsis:\n// Range(start, end)\n//   - returns a generator producing a sequence of values {start, start+1,\n//     start+2, ..., }.\n// Range(start, end, step)\n//   - returns a generator producing a sequence of values {start, start+step,\n//     start+step+step, ..., }.\n// Notes:\n//   * The generated sequences never include end. For example, Range(1, 5)\n//     returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)\n//     returns a generator producing {1, 3, 5, 7}.\n//   * start and end must have the same type. That type may be any integral or\n//     floating-point type or a user defined type satisfying these conditions:\n//     * It must be assignable (have operator=() defined).\n//     * It must have operator+() (operator+(int-compatible type) for\n//       two-operand version).\n//     * It must have operator<() defined.\n//     Elements in the resulting sequences will also have that type.\n//   * Condition start < end must be satisfied in order for resulting sequences\n//     to contain any elements.\n//\ntemplate <typename T, typename IncrementT>\ninternal::ParamGenerator<T> Range(T start, T end, IncrementT step) {\n  return internal::ParamGenerator<T>(\n      new internal::RangeGenerator<T, IncrementT>(start, end, step));\n}\n\ntemplate <typename T>\ninternal::ParamGenerator<T> Range(T start, T end) {\n  return Range(start, end, 1);\n}\n\n// ValuesIn() function allows generation of tests with parameters coming from\n// a container.\n//\n// Synopsis:\n// ValuesIn(const T (&array)[N])\n//   - returns a generator producing sequences with elements from\n//     a C-style array.\n// ValuesIn(const Container& container)\n//   - returns a generator producing sequences with elements from\n//     an STL-style container.\n// ValuesIn(Iterator begin, Iterator end)\n//   - returns a generator producing sequences with elements from\n//     a range [begin, end) defined by a pair of STL-style iterators. These\n//     iterators can also be plain C pointers.\n//\n// Please note that ValuesIn copies the values from the containers\n// passed in and keeps them to generate tests in RUN_ALL_TESTS().\n//\n// Examples:\n//\n// This instantiates tests from test case StringTest\n// each with C-string values of \"foo\", \"bar\", and \"baz\":\n//\n// const char* strings[] = {\"foo\", \"bar\", \"baz\"};\n// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings));\n//\n// This instantiates tests from test case StlStringTest\n// each with STL strings with values \"a\" and \"b\":\n//\n// ::std::vector< ::std::string> GetParameterStrings() {\n//   ::std::vector< ::std::string> v;\n//   v.push_back(\"a\");\n//   v.push_back(\"b\");\n//   return v;\n// }\n//\n// INSTANTIATE_TEST_CASE_P(CharSequence,\n//                         StlStringTest,\n//                         ValuesIn(GetParameterStrings()));\n//\n//\n// This will also instantiate tests from CharTest\n// each with parameter values 'a' and 'b':\n//\n// ::std::list<char> GetParameterChars() {\n//   ::std::list<char> list;\n//   list.push_back('a');\n//   list.push_back('b');\n//   return list;\n// }\n// ::std::list<char> l = GetParameterChars();\n// INSTANTIATE_TEST_CASE_P(CharSequence2,\n//                         CharTest,\n//                         ValuesIn(l.begin(), l.end()));\n//\ntemplate <typename ForwardIterator>\ninternal::ParamGenerator<\n  typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>\nValuesIn(ForwardIterator begin, ForwardIterator end) {\n  typedef typename ::testing::internal::IteratorTraits<ForwardIterator>\n      ::value_type ParamType;\n  return internal::ParamGenerator<ParamType>(\n      new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));\n}\n\ntemplate <typename T, size_t N>\ninternal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {\n  return ValuesIn(array, array + N);\n}\n\ntemplate <class Container>\ninternal::ParamGenerator<typename Container::value_type> ValuesIn(\n    const Container& container) {\n  return ValuesIn(container.begin(), container.end());\n}\n\n// Values() allows generating tests from explicitly specified list of\n// parameters.\n//\n// Synopsis:\n// Values(T v1, T v2, ..., T vN)\n//   - returns a generator producing sequences with elements v1, v2, ..., vN.\n//\n// For example, this instantiates tests from test case BarTest each\n// with values \"one\", \"two\", and \"three\":\n//\n// INSTANTIATE_TEST_CASE_P(NumSequence, BarTest, Values(\"one\", \"two\", \"three\"));\n//\n// This instantiates tests from test case BazTest each with values 1, 2, 3.5.\n// The exact type of values will depend on the type of parameter in BazTest.\n//\n// INSTANTIATE_TEST_CASE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));\n//\n// Currently, Values() supports from 1 to 50 parameters.\n//\ntemplate <typename T1>\ninternal::ValueArray1<T1> Values(T1 v1) {\n  return internal::ValueArray1<T1>(v1);\n}\n\ntemplate <typename T1, typename T2>\ninternal::ValueArray2<T1, T2> Values(T1 v1, T2 v2) {\n  return internal::ValueArray2<T1, T2>(v1, v2);\n}\n\ntemplate <typename T1, typename T2, typename T3>\ninternal::ValueArray3<T1, T2, T3> Values(T1 v1, T2 v2, T3 v3) {\n  return internal::ValueArray3<T1, T2, T3>(v1, v2, v3);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4>\ninternal::ValueArray4<T1, T2, T3, T4> Values(T1 v1, T2 v2, T3 v3, T4 v4) {\n  return internal::ValueArray4<T1, T2, T3, T4>(v1, v2, v3, v4);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\ninternal::ValueArray5<T1, T2, T3, T4, T5> Values(T1 v1, T2 v2, T3 v3, T4 v4,\n    T5 v5) {\n  return internal::ValueArray5<T1, T2, T3, T4, T5>(v1, v2, v3, v4, v5);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6>\ninternal::ValueArray6<T1, T2, T3, T4, T5, T6> Values(T1 v1, T2 v2, T3 v3,\n    T4 v4, T5 v5, T6 v6) {\n  return internal::ValueArray6<T1, T2, T3, T4, T5, T6>(v1, v2, v3, v4, v5, v6);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7>\ninternal::ValueArray7<T1, T2, T3, T4, T5, T6, T7> Values(T1 v1, T2 v2, T3 v3,\n    T4 v4, T5 v5, T6 v6, T7 v7) {\n  return internal::ValueArray7<T1, T2, T3, T4, T5, T6, T7>(v1, v2, v3, v4, v5,\n      v6, v7);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8>\ninternal::ValueArray8<T1, T2, T3, T4, T5, T6, T7, T8> Values(T1 v1, T2 v2,\n    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) {\n  return internal::ValueArray8<T1, T2, T3, T4, T5, T6, T7, T8>(v1, v2, v3, v4,\n      v5, v6, v7, v8);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9>\ninternal::ValueArray9<T1, T2, T3, T4, T5, T6, T7, T8, T9> Values(T1 v1, T2 v2,\n    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) {\n  return internal::ValueArray9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(v1, v2, v3,\n      v4, v5, v6, v7, v8, v9);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10>\ninternal::ValueArray10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Values(T1 v1,\n    T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10) {\n  return internal::ValueArray10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(v1,\n      v2, v3, v4, v5, v6, v7, v8, v9, v10);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11>\ninternal::ValueArray11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,\n    T11> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11) {\n  return internal::ValueArray11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,\n      T11>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12>\ninternal::ValueArray12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n    T12> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12) {\n  return internal::ValueArray12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13>\ninternal::ValueArray13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n    T13> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13) {\n  return internal::ValueArray13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14>\ninternal::ValueArray14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) {\n  return internal::ValueArray14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,\n      v14);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15>\ninternal::ValueArray15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,\n    T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) {\n  return internal::ValueArray15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,\n      v13, v14, v15);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16>\ninternal::ValueArray16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,\n    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16) {\n  return internal::ValueArray16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,\n      v12, v13, v14, v15, v16);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17>\ninternal::ValueArray17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,\n    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17) {\n  return internal::ValueArray17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,\n      v11, v12, v13, v14, v15, v16, v17);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18>\ninternal::ValueArray18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,\n    T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17, T18 v18) {\n  return internal::ValueArray18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18>(v1, v2, v3, v4, v5, v6, v7, v8, v9,\n      v10, v11, v12, v13, v14, v15, v16, v17, v18);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19>\ninternal::ValueArray19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,\n    T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,\n    T15 v15, T16 v16, T17 v17, T18 v18, T19 v19) {\n  return internal::ValueArray19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19>(v1, v2, v3, v4, v5, v6, v7, v8,\n      v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20>\ninternal::ValueArray20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20> Values(T1 v1, T2 v2, T3 v3, T4 v4,\n    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,\n    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20) {\n  return internal::ValueArray20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20>(v1, v2, v3, v4, v5, v6, v7,\n      v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21>\ninternal::ValueArray21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21> Values(T1 v1, T2 v2, T3 v3, T4 v4,\n    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,\n    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21) {\n  return internal::ValueArray21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>(v1, v2, v3, v4, v5, v6,\n      v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22>\ninternal::ValueArray22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22> Values(T1 v1, T2 v2, T3 v3,\n    T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,\n    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,\n    T21 v21, T22 v22) {\n  return internal::ValueArray22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>(v1, v2, v3, v4,\n      v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,\n      v20, v21, v22);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23>\ninternal::ValueArray23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> Values(T1 v1, T2 v2,\n    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,\n    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,\n    T21 v21, T22 v22, T23 v23) {\n  return internal::ValueArray23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23>(v1, v2, v3,\n      v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,\n      v20, v21, v22, v23);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24>\ninternal::ValueArray24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> Values(T1 v1, T2 v2,\n    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,\n    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,\n    T21 v21, T22 v22, T23 v23, T24 v24) {\n  return internal::ValueArray24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24>(v1, v2,\n      v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18,\n      v19, v20, v21, v22, v23, v24);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25>\ninternal::ValueArray25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Values(T1 v1,\n    T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11,\n    T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19,\n    T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25) {\n  return internal::ValueArray25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25>(v1,\n      v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17,\n      v18, v19, v20, v21, v22, v23, v24, v25);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26>\ninternal::ValueArray26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n    T26> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26) {\n  return internal::ValueArray26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,\n      v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27>\ninternal::ValueArray27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n    T27> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26, T27 v27) {\n  return internal::ValueArray27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14,\n      v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28>\ninternal::ValueArray28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n    T28> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26, T27 v27, T28 v28) {\n  return internal::ValueArray28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,\n      v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27,\n      v28);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29>\ninternal::ValueArray29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26, T27 v27, T28 v28, T29 v29) {\n  return internal::ValueArray29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,\n      v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26,\n      v27, v28, v29);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30>\ninternal::ValueArray30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,\n    T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,\n    T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,\n    T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30) {\n  return internal::ValueArray30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,\n      v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25,\n      v26, v27, v28, v29, v30);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31>\ninternal::ValueArray31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,\n    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,\n    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31) {\n  return internal::ValueArray31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,\n      v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24,\n      v25, v26, v27, v28, v29, v30, v31);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32>\ninternal::ValueArray32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,\n    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,\n    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,\n    T32 v32) {\n  return internal::ValueArray32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32>(v1, v2, v3, v4, v5, v6, v7, v8, v9,\n      v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,\n      v24, v25, v26, v27, v28, v29, v30, v31, v32);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33>\ninternal::ValueArray33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,\n    T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,\n    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,\n    T32 v32, T33 v33) {\n  return internal::ValueArray33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33>(v1, v2, v3, v4, v5, v6, v7, v8,\n      v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,\n      v24, v25, v26, v27, v28, v29, v30, v31, v32, v33);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34>\ninternal::ValueArray34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,\n    T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,\n    T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22,\n    T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30,\n    T31 v31, T32 v32, T33 v33, T34 v34) {\n  return internal::ValueArray34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34>(v1, v2, v3, v4, v5, v6, v7,\n      v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22,\n      v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35>\ninternal::ValueArray35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35> Values(T1 v1, T2 v2, T3 v3, T4 v4,\n    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,\n    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,\n    T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,\n    T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35) {\n  return internal::ValueArray35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35>(v1, v2, v3, v4, v5, v6,\n      v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,\n      v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36>\ninternal::ValueArray36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36> Values(T1 v1, T2 v2, T3 v3, T4 v4,\n    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,\n    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,\n    T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,\n    T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36) {\n  return internal::ValueArray36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36>(v1, v2, v3, v4,\n      v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,\n      v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,\n      v34, v35, v36);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37>\ninternal::ValueArray37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37> Values(T1 v1, T2 v2, T3 v3,\n    T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,\n    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,\n    T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,\n    T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,\n    T37 v37) {\n  return internal::ValueArray37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37>(v1, v2, v3,\n      v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,\n      v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,\n      v34, v35, v36, v37);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38>\ninternal::ValueArray38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> Values(T1 v1, T2 v2,\n    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,\n    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,\n    T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,\n    T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,\n    T37 v37, T38 v38) {\n  return internal::ValueArray38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38>(v1, v2,\n      v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18,\n      v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32,\n      v33, v34, v35, v36, v37, v38);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39>\ninternal::ValueArray39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Values(T1 v1, T2 v2,\n    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,\n    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,\n    T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,\n    T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,\n    T37 v37, T38 v38, T39 v39) {\n  return internal::ValueArray39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39>(v1,\n      v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17,\n      v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,\n      v32, v33, v34, v35, v36, v37, v38, v39);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40>\ninternal::ValueArray40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Values(T1 v1,\n    T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11,\n    T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19,\n    T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27,\n    T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35,\n    T36 v36, T37 v37, T38 v38, T39 v39, T40 v40) {\n  return internal::ValueArray40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,\n      v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29,\n      v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41>\ninternal::ValueArray41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n    T41> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41) {\n  return internal::ValueArray41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14,\n      v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28,\n      v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42>\ninternal::ValueArray42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n    T42> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n    T42 v42) {\n  return internal::ValueArray42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,\n      v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27,\n      v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41,\n      v42);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43>\ninternal::ValueArray43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n    T43> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n    T42 v42, T43 v43) {\n  return internal::ValueArray43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,\n      v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26,\n      v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40,\n      v41, v42, v43);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44>\ninternal::ValueArray44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n    T42 v42, T43 v43, T44 v44) {\n  return internal::ValueArray44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43, T44>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,\n      v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25,\n      v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39,\n      v40, v41, v42, v43, v44);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45>\ninternal::ValueArray45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44, T45> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,\n    T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,\n    T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,\n    T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32,\n    T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40,\n    T41 v41, T42 v42, T43 v43, T44 v44, T45 v45) {\n  return internal::ValueArray45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43, T44, T45>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,\n      v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24,\n      v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38,\n      v39, v40, v41, v42, v43, v44, v45);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46>\ninternal::ValueArray46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44, T45, T46> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,\n    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,\n    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,\n    T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,\n    T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46) {\n  return internal::ValueArray46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43, T44, T45, T46>(v1, v2, v3, v4, v5, v6, v7, v8, v9,\n      v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,\n      v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37,\n      v38, v39, v40, v41, v42, v43, v44, v45, v46);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47>\ninternal::ValueArray47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44, T45, T46, T47> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,\n    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,\n    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,\n    T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,\n    T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47) {\n  return internal::ValueArray47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43, T44, T45, T46, T47>(v1, v2, v3, v4, v5, v6, v7, v8,\n      v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,\n      v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37,\n      v38, v39, v40, v41, v42, v43, v44, v45, v46, v47);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48>\ninternal::ValueArray48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44, T45, T46, T47, T48> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,\n    T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,\n    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,\n    T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,\n    T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47,\n    T48 v48) {\n  return internal::ValueArray48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43, T44, T45, T46, T47, T48>(v1, v2, v3, v4, v5, v6, v7,\n      v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22,\n      v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36,\n      v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49>\ninternal::ValueArray49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44, T45, T46, T47, T48, T49> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,\n    T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,\n    T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22,\n    T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30,\n    T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38,\n    T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46,\n    T47 v47, T48 v48, T49 v49) {\n  return internal::ValueArray49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43, T44, T45, T46, T47, T48, T49>(v1, v2, v3, v4, v5, v6,\n      v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,\n      v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35,\n      v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49, typename T50>\ninternal::ValueArray50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44, T45, T46, T47, T48, T49, T50> Values(T1 v1, T2 v2, T3 v3, T4 v4,\n    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,\n    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,\n    T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,\n    T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37,\n    T38 v38, T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45,\n    T46 v46, T47 v47, T48 v48, T49 v49, T50 v50) {\n  return internal::ValueArray50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43, T44, T45, T46, T47, T48, T49, T50>(v1, v2, v3, v4,\n      v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,\n      v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,\n      v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47,\n      v48, v49, v50);\n}\n\n// Bool() allows generating tests with parameters in a set of (false, true).\n//\n// Synopsis:\n// Bool()\n//   - returns a generator producing sequences with elements {false, true}.\n//\n// It is useful when testing code that depends on Boolean flags. Combinations\n// of multiple flags can be tested when several Bool()'s are combined using\n// Combine() function.\n//\n// In the following example all tests in the test case FlagDependentTest\n// will be instantiated twice with parameters false and true.\n//\n// class FlagDependentTest : public testing::TestWithParam<bool> {\n//   virtual void SetUp() {\n//     external_flag = GetParam();\n//   }\n// }\n// INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool());\n//\ninline internal::ParamGenerator<bool> Bool() {\n  return Values(false, true);\n}\n\n# if GTEST_HAS_COMBINE\n// Combine() allows the user to combine two or more sequences to produce\n// values of a Cartesian product of those sequences' elements.\n//\n// Synopsis:\n// Combine(gen1, gen2, ..., genN)\n//   - returns a generator producing sequences with elements coming from\n//     the Cartesian product of elements from the sequences generated by\n//     gen1, gen2, ..., genN. The sequence elements will have a type of\n//     tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types\n//     of elements from sequences produces by gen1, gen2, ..., genN.\n//\n// Combine can have up to 10 arguments. This number is currently limited\n// by the maximum number of elements in the tuple implementation used by Google\n// Test.\n//\n// Example:\n//\n// This will instantiate tests in test case AnimalTest each one with\n// the parameter values tuple(\"cat\", BLACK), tuple(\"cat\", WHITE),\n// tuple(\"dog\", BLACK), and tuple(\"dog\", WHITE):\n//\n// enum Color { BLACK, GRAY, WHITE };\n// class AnimalTest\n//     : public testing::TestWithParam<tuple<const char*, Color> > {...};\n//\n// TEST_P(AnimalTest, AnimalLooksNice) {...}\n//\n// INSTANTIATE_TEST_CASE_P(AnimalVariations, AnimalTest,\n//                         Combine(Values(\"cat\", \"dog\"),\n//                                 Values(BLACK, WHITE)));\n//\n// This will instantiate tests in FlagDependentTest with all variations of two\n// Boolean flags:\n//\n// class FlagDependentTest\n//     : public testing::TestWithParam<tuple<bool, bool> > {\n//   virtual void SetUp() {\n//     // Assigns external_flag_1 and external_flag_2 values from the tuple.\n//     tie(external_flag_1, external_flag_2) = GetParam();\n//   }\n// };\n//\n// TEST_P(FlagDependentTest, TestFeature1) {\n//   // Test your code using external_flag_1 and external_flag_2 here.\n// }\n// INSTANTIATE_TEST_CASE_P(TwoBoolSequence, FlagDependentTest,\n//                         Combine(Bool(), Bool()));\n//\ntemplate <typename Generator1, typename Generator2>\ninternal::CartesianProductHolder2<Generator1, Generator2> Combine(\n    const Generator1& g1, const Generator2& g2) {\n  return internal::CartesianProductHolder2<Generator1, Generator2>(\n      g1, g2);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3>\ninternal::CartesianProductHolder3<Generator1, Generator2, Generator3> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3) {\n  return internal::CartesianProductHolder3<Generator1, Generator2, Generator3>(\n      g1, g2, g3);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3,\n    typename Generator4>\ninternal::CartesianProductHolder4<Generator1, Generator2, Generator3,\n    Generator4> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3,\n        const Generator4& g4) {\n  return internal::CartesianProductHolder4<Generator1, Generator2, Generator3,\n      Generator4>(\n      g1, g2, g3, g4);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3,\n    typename Generator4, typename Generator5>\ninternal::CartesianProductHolder5<Generator1, Generator2, Generator3,\n    Generator4, Generator5> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3,\n        const Generator4& g4, const Generator5& g5) {\n  return internal::CartesianProductHolder5<Generator1, Generator2, Generator3,\n      Generator4, Generator5>(\n      g1, g2, g3, g4, g5);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3,\n    typename Generator4, typename Generator5, typename Generator6>\ninternal::CartesianProductHolder6<Generator1, Generator2, Generator3,\n    Generator4, Generator5, Generator6> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3,\n        const Generator4& g4, const Generator5& g5, const Generator6& g6) {\n  return internal::CartesianProductHolder6<Generator1, Generator2, Generator3,\n      Generator4, Generator5, Generator6>(\n      g1, g2, g3, g4, g5, g6);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3,\n    typename Generator4, typename Generator5, typename Generator6,\n    typename Generator7>\ninternal::CartesianProductHolder7<Generator1, Generator2, Generator3,\n    Generator4, Generator5, Generator6, Generator7> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3,\n        const Generator4& g4, const Generator5& g5, const Generator6& g6,\n        const Generator7& g7) {\n  return internal::CartesianProductHolder7<Generator1, Generator2, Generator3,\n      Generator4, Generator5, Generator6, Generator7>(\n      g1, g2, g3, g4, g5, g6, g7);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3,\n    typename Generator4, typename Generator5, typename Generator6,\n    typename Generator7, typename Generator8>\ninternal::CartesianProductHolder8<Generator1, Generator2, Generator3,\n    Generator4, Generator5, Generator6, Generator7, Generator8> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3,\n        const Generator4& g4, const Generator5& g5, const Generator6& g6,\n        const Generator7& g7, const Generator8& g8) {\n  return internal::CartesianProductHolder8<Generator1, Generator2, Generator3,\n      Generator4, Generator5, Generator6, Generator7, Generator8>(\n      g1, g2, g3, g4, g5, g6, g7, g8);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3,\n    typename Generator4, typename Generator5, typename Generator6,\n    typename Generator7, typename Generator8, typename Generator9>\ninternal::CartesianProductHolder9<Generator1, Generator2, Generator3,\n    Generator4, Generator5, Generator6, Generator7, Generator8,\n    Generator9> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3,\n        const Generator4& g4, const Generator5& g5, const Generator6& g6,\n        const Generator7& g7, const Generator8& g8, const Generator9& g9) {\n  return internal::CartesianProductHolder9<Generator1, Generator2, Generator3,\n      Generator4, Generator5, Generator6, Generator7, Generator8, Generator9>(\n      g1, g2, g3, g4, g5, g6, g7, g8, g9);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3,\n    typename Generator4, typename Generator5, typename Generator6,\n    typename Generator7, typename Generator8, typename Generator9,\n    typename Generator10>\ninternal::CartesianProductHolder10<Generator1, Generator2, Generator3,\n    Generator4, Generator5, Generator6, Generator7, Generator8, Generator9,\n    Generator10> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3,\n        const Generator4& g4, const Generator5& g5, const Generator6& g6,\n        const Generator7& g7, const Generator8& g8, const Generator9& g9,\n        const Generator10& g10) {\n  return internal::CartesianProductHolder10<Generator1, Generator2, Generator3,\n      Generator4, Generator5, Generator6, Generator7, Generator8, Generator9,\n      Generator10>(\n      g1, g2, g3, g4, g5, g6, g7, g8, g9, g10);\n}\n# endif  // GTEST_HAS_COMBINE\n\n\n\n# define TEST_P(test_case_name, test_name) \\\n  class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \\\n      : public test_case_name { \\\n   public: \\\n    GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \\\n    virtual void TestBody(); \\\n   private: \\\n    static int AddToRegistry() { \\\n      ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \\\n          GetTestCasePatternHolder<test_case_name>(\\\n              #test_case_name, \\\n              ::testing::internal::CodeLocation(\\\n                  __FILE__, __LINE__))->AddTestPattern(\\\n                      #test_case_name, \\\n                      #test_name, \\\n                      new ::testing::internal::TestMetaFactory< \\\n                          GTEST_TEST_CLASS_NAME_(\\\n                              test_case_name, test_name)>()); \\\n      return 0; \\\n    } \\\n    static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \\\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(\\\n        GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \\\n  }; \\\n  int GTEST_TEST_CLASS_NAME_(test_case_name, \\\n                             test_name)::gtest_registering_dummy_ = \\\n      GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \\\n  void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()\n\n// The optional last argument to INSTANTIATE_TEST_CASE_P allows the user\n// to specify a function or functor that generates custom test name suffixes\n// based on the test parameters. The function should accept one argument of\n// type testing::TestParamInfo<class ParamType>, and return std::string.\n//\n// testing::PrintToStringParamName is a builtin test suffix generator that\n// returns the value of testing::PrintToString(GetParam()). It does not work\n// for std::string or C strings.\n//\n// Note: test names must be non-empty, unique, and may only contain ASCII\n// alphanumeric characters or underscore.\n\n# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \\\n  ::testing::internal::ParamGenerator<test_case_name::ParamType> \\\n      gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \\\n  ::std::string gtest_##prefix##test_case_name##_EvalGenerateName_( \\\n      const ::testing::TestParamInfo<test_case_name::ParamType>& info) { \\\n    return ::testing::internal::GetParamNameGen<test_case_name::ParamType> \\\n        (__VA_ARGS__)(info); \\\n  } \\\n  int gtest_##prefix##test_case_name##_dummy_ GTEST_ATTRIBUTE_UNUSED_ = \\\n      ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \\\n          GetTestCasePatternHolder<test_case_name>(\\\n              #test_case_name, \\\n              ::testing::internal::CodeLocation(\\\n                  __FILE__, __LINE__))->AddTestCaseInstantiation(\\\n                      #prefix, \\\n                      &gtest_##prefix##test_case_name##_EvalGenerator_, \\\n                      &gtest_##prefix##test_case_name##_EvalGenerateName_, \\\n                      __FILE__, __LINE__)\n\n}  // namespace testing\n\n#endif  // GTEST_HAS_PARAM_TEST\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/gtest-param-test.h.pump",
    "content": "$$ -*- mode: c++; -*-\n$var n = 50  $$ Maximum length of Values arguments we want to support.\n$var maxtuple = 10  $$ Maximum number of Combine arguments we want to support.\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: vladl@google.com (Vlad Losev)\n//\n// Macros and functions for implementing parameterized tests\n// in Google C++ Testing Framework (Google Test)\n//\n// This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!\n//\n#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_\n#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_\n\n\n// Value-parameterized tests allow you to test your code with different\n// parameters without writing multiple copies of the same test.\n//\n// Here is how you use value-parameterized tests:\n\n#if 0\n\n// To write value-parameterized tests, first you should define a fixture\n// class. It is usually derived from testing::TestWithParam<T> (see below for\n// another inheritance scheme that's sometimes useful in more complicated\n// class hierarchies), where the type of your parameter values.\n// TestWithParam<T> is itself derived from testing::Test. T can be any\n// copyable type. If it's a raw pointer, you are responsible for managing the\n// lifespan of the pointed values.\n\nclass FooTest : public ::testing::TestWithParam<const char*> {\n  // You can implement all the usual class fixture members here.\n};\n\n// Then, use the TEST_P macro to define as many parameterized tests\n// for this fixture as you want. The _P suffix is for \"parameterized\"\n// or \"pattern\", whichever you prefer to think.\n\nTEST_P(FooTest, DoesBlah) {\n  // Inside a test, access the test parameter with the GetParam() method\n  // of the TestWithParam<T> class:\n  EXPECT_TRUE(foo.Blah(GetParam()));\n  ...\n}\n\nTEST_P(FooTest, HasBlahBlah) {\n  ...\n}\n\n// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test\n// case with any set of parameters you want. Google Test defines a number\n// of functions for generating test parameters. They return what we call\n// (surprise!) parameter generators. Here is a  summary of them, which\n// are all in the testing namespace:\n//\n//\n//  Range(begin, end [, step]) - Yields values {begin, begin+step,\n//                               begin+step+step, ...}. The values do not\n//                               include end. step defaults to 1.\n//  Values(v1, v2, ..., vN)    - Yields values {v1, v2, ..., vN}.\n//  ValuesIn(container)        - Yields values from a C-style array, an STL\n//  ValuesIn(begin,end)          container, or an iterator range [begin, end).\n//  Bool()                     - Yields sequence {false, true}.\n//  Combine(g1, g2, ..., gN)   - Yields all combinations (the Cartesian product\n//                               for the math savvy) of the values generated\n//                               by the N generators.\n//\n// For more details, see comments at the definitions of these functions below\n// in this file.\n//\n// The following statement will instantiate tests from the FooTest test case\n// each with parameter values \"meeny\", \"miny\", and \"moe\".\n\nINSTANTIATE_TEST_CASE_P(InstantiationName,\n                        FooTest,\n                        Values(\"meeny\", \"miny\", \"moe\"));\n\n// To distinguish different instances of the pattern, (yes, you\n// can instantiate it more then once) the first argument to the\n// INSTANTIATE_TEST_CASE_P macro is a prefix that will be added to the\n// actual test case name. Remember to pick unique prefixes for different\n// instantiations. The tests from the instantiation above will have\n// these names:\n//\n//    * InstantiationName/FooTest.DoesBlah/0 for \"meeny\"\n//    * InstantiationName/FooTest.DoesBlah/1 for \"miny\"\n//    * InstantiationName/FooTest.DoesBlah/2 for \"moe\"\n//    * InstantiationName/FooTest.HasBlahBlah/0 for \"meeny\"\n//    * InstantiationName/FooTest.HasBlahBlah/1 for \"miny\"\n//    * InstantiationName/FooTest.HasBlahBlah/2 for \"moe\"\n//\n// You can use these names in --gtest_filter.\n//\n// This statement will instantiate all tests from FooTest again, each\n// with parameter values \"cat\" and \"dog\":\n\nconst char* pets[] = {\"cat\", \"dog\"};\nINSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));\n\n// The tests from the instantiation above will have these names:\n//\n//    * AnotherInstantiationName/FooTest.DoesBlah/0 for \"cat\"\n//    * AnotherInstantiationName/FooTest.DoesBlah/1 for \"dog\"\n//    * AnotherInstantiationName/FooTest.HasBlahBlah/0 for \"cat\"\n//    * AnotherInstantiationName/FooTest.HasBlahBlah/1 for \"dog\"\n//\n// Please note that INSTANTIATE_TEST_CASE_P will instantiate all tests\n// in the given test case, whether their definitions come before or\n// AFTER the INSTANTIATE_TEST_CASE_P statement.\n//\n// Please also note that generator expressions (including parameters to the\n// generators) are evaluated in InitGoogleTest(), after main() has started.\n// This allows the user on one hand, to adjust generator parameters in order\n// to dynamically determine a set of tests to run and on the other hand,\n// give the user a chance to inspect the generated tests with Google Test\n// reflection API before RUN_ALL_TESTS() is executed.\n//\n// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc\n// for more examples.\n//\n// In the future, we plan to publish the API for defining new parameter\n// generators. But for now this interface remains part of the internal\n// implementation and is subject to change.\n//\n//\n// A parameterized test fixture must be derived from testing::Test and from\n// testing::WithParamInterface<T>, where T is the type of the parameter\n// values. Inheriting from TestWithParam<T> satisfies that requirement because\n// TestWithParam<T> inherits from both Test and WithParamInterface. In more\n// complicated hierarchies, however, it is occasionally useful to inherit\n// separately from Test and WithParamInterface. For example:\n\nclass BaseTest : public ::testing::Test {\n  // You can inherit all the usual members for a non-parameterized test\n  // fixture here.\n};\n\nclass DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {\n  // The usual test fixture members go here too.\n};\n\nTEST_F(BaseTest, HasFoo) {\n  // This is an ordinary non-parameterized test.\n}\n\nTEST_P(DerivedTest, DoesBlah) {\n  // GetParam works just the same here as if you inherit from TestWithParam.\n  EXPECT_TRUE(foo.Blah(GetParam()));\n}\n\n#endif  // 0\n\n#include \"gtest/internal/gtest-port.h\"\n\n#if !GTEST_OS_SYMBIAN\n# include <utility>\n#endif\n\n// scripts/fuse_gtest.py depends on gtest's own header being #included\n// *unconditionally*.  Therefore these #includes cannot be moved\n// inside #if GTEST_HAS_PARAM_TEST.\n#include \"gtest/internal/gtest-internal.h\"\n#include \"gtest/internal/gtest-param-util.h\"\n#include \"gtest/internal/gtest-param-util-generated.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\nnamespace testing {\n\n// Functions producing parameter generators.\n//\n// Google Test uses these generators to produce parameters for value-\n// parameterized tests. When a parameterized test case is instantiated\n// with a particular generator, Google Test creates and runs tests\n// for each element in the sequence produced by the generator.\n//\n// In the following sample, tests from test case FooTest are instantiated\n// each three times with parameter values 3, 5, and 8:\n//\n// class FooTest : public TestWithParam<int> { ... };\n//\n// TEST_P(FooTest, TestThis) {\n// }\n// TEST_P(FooTest, TestThat) {\n// }\n// INSTANTIATE_TEST_CASE_P(TestSequence, FooTest, Values(3, 5, 8));\n//\n\n// Range() returns generators providing sequences of values in a range.\n//\n// Synopsis:\n// Range(start, end)\n//   - returns a generator producing a sequence of values {start, start+1,\n//     start+2, ..., }.\n// Range(start, end, step)\n//   - returns a generator producing a sequence of values {start, start+step,\n//     start+step+step, ..., }.\n// Notes:\n//   * The generated sequences never include end. For example, Range(1, 5)\n//     returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)\n//     returns a generator producing {1, 3, 5, 7}.\n//   * start and end must have the same type. That type may be any integral or\n//     floating-point type or a user defined type satisfying these conditions:\n//     * It must be assignable (have operator=() defined).\n//     * It must have operator+() (operator+(int-compatible type) for\n//       two-operand version).\n//     * It must have operator<() defined.\n//     Elements in the resulting sequences will also have that type.\n//   * Condition start < end must be satisfied in order for resulting sequences\n//     to contain any elements.\n//\ntemplate <typename T, typename IncrementT>\ninternal::ParamGenerator<T> Range(T start, T end, IncrementT step) {\n  return internal::ParamGenerator<T>(\n      new internal::RangeGenerator<T, IncrementT>(start, end, step));\n}\n\ntemplate <typename T>\ninternal::ParamGenerator<T> Range(T start, T end) {\n  return Range(start, end, 1);\n}\n\n// ValuesIn() function allows generation of tests with parameters coming from\n// a container.\n//\n// Synopsis:\n// ValuesIn(const T (&array)[N])\n//   - returns a generator producing sequences with elements from\n//     a C-style array.\n// ValuesIn(const Container& container)\n//   - returns a generator producing sequences with elements from\n//     an STL-style container.\n// ValuesIn(Iterator begin, Iterator end)\n//   - returns a generator producing sequences with elements from\n//     a range [begin, end) defined by a pair of STL-style iterators. These\n//     iterators can also be plain C pointers.\n//\n// Please note that ValuesIn copies the values from the containers\n// passed in and keeps them to generate tests in RUN_ALL_TESTS().\n//\n// Examples:\n//\n// This instantiates tests from test case StringTest\n// each with C-string values of \"foo\", \"bar\", and \"baz\":\n//\n// const char* strings[] = {\"foo\", \"bar\", \"baz\"};\n// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings));\n//\n// This instantiates tests from test case StlStringTest\n// each with STL strings with values \"a\" and \"b\":\n//\n// ::std::vector< ::std::string> GetParameterStrings() {\n//   ::std::vector< ::std::string> v;\n//   v.push_back(\"a\");\n//   v.push_back(\"b\");\n//   return v;\n// }\n//\n// INSTANTIATE_TEST_CASE_P(CharSequence,\n//                         StlStringTest,\n//                         ValuesIn(GetParameterStrings()));\n//\n//\n// This will also instantiate tests from CharTest\n// each with parameter values 'a' and 'b':\n//\n// ::std::list<char> GetParameterChars() {\n//   ::std::list<char> list;\n//   list.push_back('a');\n//   list.push_back('b');\n//   return list;\n// }\n// ::std::list<char> l = GetParameterChars();\n// INSTANTIATE_TEST_CASE_P(CharSequence2,\n//                         CharTest,\n//                         ValuesIn(l.begin(), l.end()));\n//\ntemplate <typename ForwardIterator>\ninternal::ParamGenerator<\n  typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>\nValuesIn(ForwardIterator begin, ForwardIterator end) {\n  typedef typename ::testing::internal::IteratorTraits<ForwardIterator>\n      ::value_type ParamType;\n  return internal::ParamGenerator<ParamType>(\n      new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));\n}\n\ntemplate <typename T, size_t N>\ninternal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {\n  return ValuesIn(array, array + N);\n}\n\ntemplate <class Container>\ninternal::ParamGenerator<typename Container::value_type> ValuesIn(\n    const Container& container) {\n  return ValuesIn(container.begin(), container.end());\n}\n\n// Values() allows generating tests from explicitly specified list of\n// parameters.\n//\n// Synopsis:\n// Values(T v1, T v2, ..., T vN)\n//   - returns a generator producing sequences with elements v1, v2, ..., vN.\n//\n// For example, this instantiates tests from test case BarTest each\n// with values \"one\", \"two\", and \"three\":\n//\n// INSTANTIATE_TEST_CASE_P(NumSequence, BarTest, Values(\"one\", \"two\", \"three\"));\n//\n// This instantiates tests from test case BazTest each with values 1, 2, 3.5.\n// The exact type of values will depend on the type of parameter in BazTest.\n//\n// INSTANTIATE_TEST_CASE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));\n//\n// Currently, Values() supports from 1 to $n parameters.\n//\n$range i 1..n\n$for i [[\n$range j 1..i\n\ntemplate <$for j, [[typename T$j]]>\ninternal::ValueArray$i<$for j, [[T$j]]> Values($for j, [[T$j v$j]]) {\n  return internal::ValueArray$i<$for j, [[T$j]]>($for j, [[v$j]]);\n}\n\n]]\n\n// Bool() allows generating tests with parameters in a set of (false, true).\n//\n// Synopsis:\n// Bool()\n//   - returns a generator producing sequences with elements {false, true}.\n//\n// It is useful when testing code that depends on Boolean flags. Combinations\n// of multiple flags can be tested when several Bool()'s are combined using\n// Combine() function.\n//\n// In the following example all tests in the test case FlagDependentTest\n// will be instantiated twice with parameters false and true.\n//\n// class FlagDependentTest : public testing::TestWithParam<bool> {\n//   virtual void SetUp() {\n//     external_flag = GetParam();\n//   }\n// }\n// INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool());\n//\ninline internal::ParamGenerator<bool> Bool() {\n  return Values(false, true);\n}\n\n# if GTEST_HAS_COMBINE\n// Combine() allows the user to combine two or more sequences to produce\n// values of a Cartesian product of those sequences' elements.\n//\n// Synopsis:\n// Combine(gen1, gen2, ..., genN)\n//   - returns a generator producing sequences with elements coming from\n//     the Cartesian product of elements from the sequences generated by\n//     gen1, gen2, ..., genN. The sequence elements will have a type of\n//     tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types\n//     of elements from sequences produces by gen1, gen2, ..., genN.\n//\n// Combine can have up to $maxtuple arguments. This number is currently limited\n// by the maximum number of elements in the tuple implementation used by Google\n// Test.\n//\n// Example:\n//\n// This will instantiate tests in test case AnimalTest each one with\n// the parameter values tuple(\"cat\", BLACK), tuple(\"cat\", WHITE),\n// tuple(\"dog\", BLACK), and tuple(\"dog\", WHITE):\n//\n// enum Color { BLACK, GRAY, WHITE };\n// class AnimalTest\n//     : public testing::TestWithParam<tuple<const char*, Color> > {...};\n//\n// TEST_P(AnimalTest, AnimalLooksNice) {...}\n//\n// INSTANTIATE_TEST_CASE_P(AnimalVariations, AnimalTest,\n//                         Combine(Values(\"cat\", \"dog\"),\n//                                 Values(BLACK, WHITE)));\n//\n// This will instantiate tests in FlagDependentTest with all variations of two\n// Boolean flags:\n//\n// class FlagDependentTest\n//     : public testing::TestWithParam<tuple<bool, bool> > {\n//   virtual void SetUp() {\n//     // Assigns external_flag_1 and external_flag_2 values from the tuple.\n//     tie(external_flag_1, external_flag_2) = GetParam();\n//   }\n// };\n//\n// TEST_P(FlagDependentTest, TestFeature1) {\n//   // Test your code using external_flag_1 and external_flag_2 here.\n// }\n// INSTANTIATE_TEST_CASE_P(TwoBoolSequence, FlagDependentTest,\n//                         Combine(Bool(), Bool()));\n//\n$range i 2..maxtuple\n$for i [[\n$range j 1..i\n\ntemplate <$for j, [[typename Generator$j]]>\ninternal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine(\n    $for j, [[const Generator$j& g$j]]) {\n  return internal::CartesianProductHolder$i<$for j, [[Generator$j]]>(\n      $for j, [[g$j]]);\n}\n\n]]\n# endif  // GTEST_HAS_COMBINE\n\n\n\n# define TEST_P(test_case_name, test_name) \\\n  class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \\\n      : public test_case_name { \\\n   public: \\\n    GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \\\n    virtual void TestBody(); \\\n   private: \\\n    static int AddToRegistry() { \\\n      ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \\\n          GetTestCasePatternHolder<test_case_name>(\\\n              #test_case_name, \\\n              ::testing::internal::CodeLocation(\\\n                  __FILE__, __LINE__))->AddTestPattern(\\\n                      #test_case_name, \\\n                      #test_name, \\\n                      new ::testing::internal::TestMetaFactory< \\\n                          GTEST_TEST_CLASS_NAME_(\\\n                              test_case_name, test_name)>()); \\\n      return 0; \\\n    } \\\n    static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \\\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(\\\n        GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \\\n  }; \\\n  int GTEST_TEST_CLASS_NAME_(test_case_name, \\\n                             test_name)::gtest_registering_dummy_ = \\\n      GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \\\n  void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()\n\n// The optional last argument to INSTANTIATE_TEST_CASE_P allows the user\n// to specify a function or functor that generates custom test name suffixes\n// based on the test parameters. The function should accept one argument of\n// type testing::TestParamInfo<class ParamType>, and return std::string.\n//\n// testing::PrintToStringParamName is a builtin test suffix generator that\n// returns the value of testing::PrintToString(GetParam()).\n//\n// Note: test names must be non-empty, unique, and may only contain ASCII\n// alphanumeric characters or underscore. Because PrintToString adds quotes\n// to std::string and C strings, it won't work for these types.\n\n# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \\\n  ::testing::internal::ParamGenerator<test_case_name::ParamType> \\\n      gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \\\n  ::std::string gtest_##prefix##test_case_name##_EvalGenerateName_( \\\n      const ::testing::TestParamInfo<test_case_name::ParamType>& info) { \\\n    return ::testing::internal::GetParamNameGen<test_case_name::ParamType> \\\n        (__VA_ARGS__)(info); \\\n  } \\\n  int gtest_##prefix##test_case_name##_dummy_ GTEST_ATTRIBUTE_UNUSED_ = \\\n      ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \\\n          GetTestCasePatternHolder<test_case_name>(\\\n              #test_case_name, \\\n              ::testing::internal::CodeLocation(\\\n                  __FILE__, __LINE__))->AddTestCaseInstantiation(\\\n                      #prefix, \\\n                      &gtest_##prefix##test_case_name##_EvalGenerator_, \\\n                      &gtest_##prefix##test_case_name##_EvalGenerateName_, \\\n                      __FILE__, __LINE__)\n\n}  // namespace testing\n\n#endif  // GTEST_HAS_PARAM_TEST\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/gtest-printers.h",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Test - The Google C++ Testing Framework\n//\n// This file implements a universal value printer that can print a\n// value of any type T:\n//\n//   void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);\n//\n// A user can teach this function how to print a class type T by\n// defining either operator<<() or PrintTo() in the namespace that\n// defines T.  More specifically, the FIRST defined function in the\n// following list will be used (assuming T is defined in namespace\n// foo):\n//\n//   1. foo::PrintTo(const T&, ostream*)\n//   2. operator<<(ostream&, const T&) defined in either foo or the\n//      global namespace.\n//\n// If none of the above is defined, it will print the debug string of\n// the value if it is a protocol buffer, or print the raw bytes in the\n// value otherwise.\n//\n// To aid debugging: when T is a reference type, the address of the\n// value is also printed; when T is a (const) char pointer, both the\n// pointer value and the NUL-terminated string it points to are\n// printed.\n//\n// We also provide some convenient wrappers:\n//\n//   // Prints a value to a string.  For a (const or not) char\n//   // pointer, the NUL-terminated string (but not the pointer) is\n//   // printed.\n//   std::string ::testing::PrintToString(const T& value);\n//\n//   // Prints a value tersely: for a reference type, the referenced\n//   // value (but not the address) is printed; for a (const or not) char\n//   // pointer, the NUL-terminated string (but not the pointer) is\n//   // printed.\n//   void ::testing::internal::UniversalTersePrint(const T& value, ostream*);\n//\n//   // Prints value using the type inferred by the compiler.  The difference\n//   // from UniversalTersePrint() is that this function prints both the\n//   // pointer and the NUL-terminated string for a (const or not) char pointer.\n//   void ::testing::internal::UniversalPrint(const T& value, ostream*);\n//\n//   // Prints the fields of a tuple tersely to a string vector, one\n//   // element for each field. Tuple support must be enabled in\n//   // gtest-port.h.\n//   std::vector<string> UniversalTersePrintTupleFieldsToStrings(\n//       const Tuple& value);\n//\n// Known limitation:\n//\n// The print primitives print the elements of an STL-style container\n// using the compiler-inferred type of *iter where iter is a\n// const_iterator of the container.  When const_iterator is an input\n// iterator but not a forward iterator, this inferred type may not\n// match value_type, and the print output may be incorrect.  In\n// practice, this is rarely a problem as for most containers\n// const_iterator is a forward iterator.  We'll fix this if there's an\n// actual need for it.  Note that this fix cannot rely on value_type\n// being defined as many user-defined container types don't have\n// value_type.\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_\n#define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_\n\n#include <ostream>  // NOLINT\n#include <sstream>\n#include <string>\n#include <utility>\n#include <vector>\n#include \"gtest/internal/gtest-port.h\"\n#include \"gtest/internal/gtest-internal.h\"\n\n#if GTEST_HAS_STD_TUPLE_\n# include <tuple>\n#endif\n\nnamespace testing {\n\n// Definitions in the 'internal' and 'internal2' name spaces are\n// subject to change without notice.  DO NOT USE THEM IN USER CODE!\nnamespace internal2 {\n\n// Prints the given number of bytes in the given object to the given\n// ostream.\nGTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,\n                                     size_t count,\n                                     ::std::ostream* os);\n\n// For selecting which printer to use when a given type has neither <<\n// nor PrintTo().\nenum TypeKind {\n  kProtobuf,              // a protobuf type\n  kConvertibleToInteger,  // a type implicitly convertible to BiggestInt\n                          // (e.g. a named or unnamed enum type)\n  kOtherType              // anything else\n};\n\n// TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called\n// by the universal printer to print a value of type T when neither\n// operator<< nor PrintTo() is defined for T, where kTypeKind is the\n// \"kind\" of T as defined by enum TypeKind.\ntemplate <typename T, TypeKind kTypeKind>\nclass TypeWithoutFormatter {\n public:\n  // This default version is called when kTypeKind is kOtherType.\n  static void PrintValue(const T& value, ::std::ostream* os) {\n    PrintBytesInObjectTo(reinterpret_cast<const unsigned char*>(&value),\n                         sizeof(value), os);\n  }\n};\n\n// We print a protobuf using its ShortDebugString() when the string\n// doesn't exceed this many characters; otherwise we print it using\n// DebugString() for better readability.\nconst size_t kProtobufOneLinerMaxLength = 50;\n\ntemplate <typename T>\nclass TypeWithoutFormatter<T, kProtobuf> {\n public:\n  static void PrintValue(const T& value, ::std::ostream* os) {\n    const ::testing::internal::string short_str = value.ShortDebugString();\n    const ::testing::internal::string pretty_str =\n        short_str.length() <= kProtobufOneLinerMaxLength ?\n        short_str : (\"\\n\" + value.DebugString());\n    *os << (\"<\" + pretty_str + \">\");\n  }\n};\n\ntemplate <typename T>\nclass TypeWithoutFormatter<T, kConvertibleToInteger> {\n public:\n  // Since T has no << operator or PrintTo() but can be implicitly\n  // converted to BiggestInt, we print it as a BiggestInt.\n  //\n  // Most likely T is an enum type (either named or unnamed), in which\n  // case printing it as an integer is the desired behavior.  In case\n  // T is not an enum, printing it as an integer is the best we can do\n  // given that it has no user-defined printer.\n  static void PrintValue(const T& value, ::std::ostream* os) {\n    const internal::BiggestInt kBigInt = value;\n    *os << kBigInt;\n  }\n};\n\n// Prints the given value to the given ostream.  If the value is a\n// protocol message, its debug string is printed; if it's an enum or\n// of a type implicitly convertible to BiggestInt, it's printed as an\n// integer; otherwise the bytes in the value are printed.  This is\n// what UniversalPrinter<T>::Print() does when it knows nothing about\n// type T and T has neither << operator nor PrintTo().\n//\n// A user can override this behavior for a class type Foo by defining\n// a << operator in the namespace where Foo is defined.\n//\n// We put this operator in namespace 'internal2' instead of 'internal'\n// to simplify the implementation, as much code in 'internal' needs to\n// use << in STL, which would conflict with our own << were it defined\n// in 'internal'.\n//\n// Note that this operator<< takes a generic std::basic_ostream<Char,\n// CharTraits> type instead of the more restricted std::ostream.  If\n// we define it to take an std::ostream instead, we'll get an\n// \"ambiguous overloads\" compiler error when trying to print a type\n// Foo that supports streaming to std::basic_ostream<Char,\n// CharTraits>, as the compiler cannot tell whether\n// operator<<(std::ostream&, const T&) or\n// operator<<(std::basic_stream<Char, CharTraits>, const Foo&) is more\n// specific.\ntemplate <typename Char, typename CharTraits, typename T>\n::std::basic_ostream<Char, CharTraits>& operator<<(\n    ::std::basic_ostream<Char, CharTraits>& os, const T& x) {\n  TypeWithoutFormatter<T,\n      (internal::IsAProtocolMessage<T>::value ? kProtobuf :\n       internal::ImplicitlyConvertible<const T&, internal::BiggestInt>::value ?\n       kConvertibleToInteger : kOtherType)>::PrintValue(x, &os);\n  return os;\n}\n\n}  // namespace internal2\n}  // namespace testing\n\n// This namespace MUST NOT BE NESTED IN ::testing, or the name look-up\n// magic needed for implementing UniversalPrinter won't work.\nnamespace testing_internal {\n\n// Used to print a value that is not an STL-style container when the\n// user doesn't define PrintTo() for it.\ntemplate <typename T>\nvoid DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) {\n  // With the following statement, during unqualified name lookup,\n  // testing::internal2::operator<< appears as if it was declared in\n  // the nearest enclosing namespace that contains both\n  // ::testing_internal and ::testing::internal2, i.e. the global\n  // namespace.  For more details, refer to the C++ Standard section\n  // 7.3.4-1 [namespace.udir].  This allows us to fall back onto\n  // testing::internal2::operator<< in case T doesn't come with a <<\n  // operator.\n  //\n  // We cannot write 'using ::testing::internal2::operator<<;', which\n  // gcc 3.3 fails to compile due to a compiler bug.\n  using namespace ::testing::internal2;  // NOLINT\n\n  // Assuming T is defined in namespace foo, in the next statement,\n  // the compiler will consider all of:\n  //\n  //   1. foo::operator<< (thanks to Koenig look-up),\n  //   2. ::operator<< (as the current namespace is enclosed in ::),\n  //   3. testing::internal2::operator<< (thanks to the using statement above).\n  //\n  // The operator<< whose type matches T best will be picked.\n  //\n  // We deliberately allow #2 to be a candidate, as sometimes it's\n  // impossible to define #1 (e.g. when foo is ::std, defining\n  // anything in it is undefined behavior unless you are a compiler\n  // vendor.).\n  *os << value;\n}\n\n}  // namespace testing_internal\n\nnamespace testing {\nnamespace internal {\n\n// FormatForComparison<ToPrint, OtherOperand>::Format(value) formats a\n// value of type ToPrint that is an operand of a comparison assertion\n// (e.g. ASSERT_EQ).  OtherOperand is the type of the other operand in\n// the comparison, and is used to help determine the best way to\n// format the value.  In particular, when the value is a C string\n// (char pointer) and the other operand is an STL string object, we\n// want to format the C string as a string, since we know it is\n// compared by value with the string object.  If the value is a char\n// pointer but the other operand is not an STL string object, we don't\n// know whether the pointer is supposed to point to a NUL-terminated\n// string, and thus want to print it as a pointer to be safe.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n\n// The default case.\ntemplate <typename ToPrint, typename OtherOperand>\nclass FormatForComparison {\n public:\n  static ::std::string Format(const ToPrint& value) {\n    return ::testing::PrintToString(value);\n  }\n};\n\n// Array.\ntemplate <typename ToPrint, size_t N, typename OtherOperand>\nclass FormatForComparison<ToPrint[N], OtherOperand> {\n public:\n  static ::std::string Format(const ToPrint* value) {\n    return FormatForComparison<const ToPrint*, OtherOperand>::Format(value);\n  }\n};\n\n// By default, print C string as pointers to be safe, as we don't know\n// whether they actually point to a NUL-terminated string.\n\n#define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType)                \\\n  template <typename OtherOperand>                                      \\\n  class FormatForComparison<CharType*, OtherOperand> {                  \\\n   public:                                                              \\\n    static ::std::string Format(CharType* value) {                      \\\n      return ::testing::PrintToString(static_cast<const void*>(value)); \\\n    }                                                                   \\\n  }\n\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char);\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char);\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t);\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t);\n\n#undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_\n\n// If a C string is compared with an STL string object, we know it's meant\n// to point to a NUL-terminated string, and thus can print it as a string.\n\n#define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \\\n  template <>                                                           \\\n  class FormatForComparison<CharType*, OtherStringType> {               \\\n   public:                                                              \\\n    static ::std::string Format(CharType* value) {                      \\\n      return ::testing::PrintToString(value);                           \\\n    }                                                                   \\\n  }\n\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string);\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string);\n\n#if GTEST_HAS_GLOBAL_STRING\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::string);\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::string);\n#endif\n\n#if GTEST_HAS_GLOBAL_WSTRING\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::wstring);\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::wstring);\n#endif\n\n#if GTEST_HAS_STD_WSTRING\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring);\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring);\n#endif\n\n#undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_\n\n// Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc)\n// operand to be used in a failure message.  The type (but not value)\n// of the other operand may affect the format.  This allows us to\n// print a char* as a raw pointer when it is compared against another\n// char* or void*, and print it as a C string when it is compared\n// against an std::string object, for example.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\ntemplate <typename T1, typename T2>\nstd::string FormatForComparisonFailureMessage(\n    const T1& value, const T2& /* other_operand */) {\n  return FormatForComparison<T1, T2>::Format(value);\n}\n\n// UniversalPrinter<T>::Print(value, ostream_ptr) prints the given\n// value to the given ostream.  The caller must ensure that\n// 'ostream_ptr' is not NULL, or the behavior is undefined.\n//\n// We define UniversalPrinter as a class template (as opposed to a\n// function template), as we need to partially specialize it for\n// reference types, which cannot be done with function templates.\ntemplate <typename T>\nclass UniversalPrinter;\n\ntemplate <typename T>\nvoid UniversalPrint(const T& value, ::std::ostream* os);\n\n// Used to print an STL-style container when the user doesn't define\n// a PrintTo() for it.\ntemplate <typename C>\nvoid DefaultPrintTo(IsContainer /* dummy */,\n                    false_type /* is not a pointer */,\n                    const C& container, ::std::ostream* os) {\n  const size_t kMaxCount = 32;  // The maximum number of elements to print.\n  *os << '{';\n  size_t count = 0;\n  for (typename C::const_iterator it = container.begin();\n       it != container.end(); ++it, ++count) {\n    if (count > 0) {\n      *os << ',';\n      if (count == kMaxCount) {  // Enough has been printed.\n        *os << \" ...\";\n        break;\n      }\n    }\n    *os << ' ';\n    // We cannot call PrintTo(*it, os) here as PrintTo() doesn't\n    // handle *it being a native array.\n    internal::UniversalPrint(*it, os);\n  }\n\n  if (count > 0) {\n    *os << ' ';\n  }\n  *os << '}';\n}\n\n// Used to print a pointer that is neither a char pointer nor a member\n// pointer, when the user doesn't define PrintTo() for it.  (A member\n// variable pointer or member function pointer doesn't really point to\n// a location in the address space.  Their representation is\n// implementation-defined.  Therefore they will be printed as raw\n// bytes.)\ntemplate <typename T>\nvoid DefaultPrintTo(IsNotContainer /* dummy */,\n                    true_type /* is a pointer */,\n                    T* p, ::std::ostream* os) {\n  if (p == NULL) {\n    *os << \"NULL\";\n  } else {\n    // C++ doesn't allow casting from a function pointer to any object\n    // pointer.\n    //\n    // IsTrue() silences warnings: \"Condition is always true\",\n    // \"unreachable code\".\n    if (IsTrue(ImplicitlyConvertible<T*, const void*>::value)) {\n      // T is not a function type.  We just call << to print p,\n      // relying on ADL to pick up user-defined << for their pointer\n      // types, if any.\n      *os << p;\n    } else {\n      // T is a function type, so '*os << p' doesn't do what we want\n      // (it just prints p as bool).  We want to print p as a const\n      // void*.  However, we cannot cast it to const void* directly,\n      // even using reinterpret_cast, as earlier versions of gcc\n      // (e.g. 3.4.5) cannot compile the cast when p is a function\n      // pointer.  Casting to UInt64 first solves the problem.\n      *os << reinterpret_cast<const void*>(\n          reinterpret_cast<internal::UInt64>(p));\n    }\n  }\n}\n\n// Used to print a non-container, non-pointer value when the user\n// doesn't define PrintTo() for it.\ntemplate <typename T>\nvoid DefaultPrintTo(IsNotContainer /* dummy */,\n                    false_type /* is not a pointer */,\n                    const T& value, ::std::ostream* os) {\n  ::testing_internal::DefaultPrintNonContainerTo(value, os);\n}\n\n// Prints the given value using the << operator if it has one;\n// otherwise prints the bytes in it.  This is what\n// UniversalPrinter<T>::Print() does when PrintTo() is not specialized\n// or overloaded for type T.\n//\n// A user can override this behavior for a class type Foo by defining\n// an overload of PrintTo() in the namespace where Foo is defined.  We\n// give the user this option as sometimes defining a << operator for\n// Foo is not desirable (e.g. the coding style may prevent doing it,\n// or there is already a << operator but it doesn't do what the user\n// wants).\ntemplate <typename T>\nvoid PrintTo(const T& value, ::std::ostream* os) {\n  // DefaultPrintTo() is overloaded.  The type of its first two\n  // arguments determine which version will be picked.  If T is an\n  // STL-style container, the version for container will be called; if\n  // T is a pointer, the pointer version will be called; otherwise the\n  // generic version will be called.\n  //\n  // Note that we check for container types here, prior to we check\n  // for protocol message types in our operator<<.  The rationale is:\n  //\n  // For protocol messages, we want to give people a chance to\n  // override Google Mock's format by defining a PrintTo() or\n  // operator<<.  For STL containers, other formats can be\n  // incompatible with Google Mock's format for the container\n  // elements; therefore we check for container types here to ensure\n  // that our format is used.\n  //\n  // The second argument of DefaultPrintTo() is needed to bypass a bug\n  // in Symbian's C++ compiler that prevents it from picking the right\n  // overload between:\n  //\n  //   PrintTo(const T& x, ...);\n  //   PrintTo(T* x, ...);\n  DefaultPrintTo(IsContainerTest<T>(0), is_pointer<T>(), value, os);\n}\n\n// The following list of PrintTo() overloads tells\n// UniversalPrinter<T>::Print() how to print standard types (built-in\n// types, strings, plain arrays, and pointers).\n\n// Overloads for various char types.\nGTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os);\nGTEST_API_ void PrintTo(signed char c, ::std::ostream* os);\ninline void PrintTo(char c, ::std::ostream* os) {\n  // When printing a plain char, we always treat it as unsigned.  This\n  // way, the output won't be affected by whether the compiler thinks\n  // char is signed or not.\n  PrintTo(static_cast<unsigned char>(c), os);\n}\n\n// Overloads for other simple built-in types.\ninline void PrintTo(bool x, ::std::ostream* os) {\n  *os << (x ? \"true\" : \"false\");\n}\n\n// Overload for wchar_t type.\n// Prints a wchar_t as a symbol if it is printable or as its internal\n// code otherwise and also as its decimal code (except for L'\\0').\n// The L'\\0' char is printed as \"L'\\\\0'\". The decimal code is printed\n// as signed integer when wchar_t is implemented by the compiler\n// as a signed type and is printed as an unsigned integer when wchar_t\n// is implemented as an unsigned type.\nGTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);\n\n// Overloads for C strings.\nGTEST_API_ void PrintTo(const char* s, ::std::ostream* os);\ninline void PrintTo(char* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const char*>(s), os);\n}\n\n// signed/unsigned char is often used for representing binary data, so\n// we print pointers to it as void* to be safe.\ninline void PrintTo(const signed char* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const void*>(s), os);\n}\ninline void PrintTo(signed char* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const void*>(s), os);\n}\ninline void PrintTo(const unsigned char* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const void*>(s), os);\n}\ninline void PrintTo(unsigned char* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const void*>(s), os);\n}\n\n// MSVC can be configured to define wchar_t as a typedef of unsigned\n// short.  It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native\n// type.  When wchar_t is a typedef, defining an overload for const\n// wchar_t* would cause unsigned short* be printed as a wide string,\n// possibly causing invalid memory accesses.\n#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)\n// Overloads for wide C strings\nGTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os);\ninline void PrintTo(wchar_t* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const wchar_t*>(s), os);\n}\n#endif\n\n// Overload for C arrays.  Multi-dimensional arrays are printed\n// properly.\n\n// Prints the given number of elements in an array, without printing\n// the curly braces.\ntemplate <typename T>\nvoid PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {\n  UniversalPrint(a[0], os);\n  for (size_t i = 1; i != count; i++) {\n    *os << \", \";\n    UniversalPrint(a[i], os);\n  }\n}\n\n// Overloads for ::string and ::std::string.\n#if GTEST_HAS_GLOBAL_STRING\nGTEST_API_ void PrintStringTo(const ::string&s, ::std::ostream* os);\ninline void PrintTo(const ::string& s, ::std::ostream* os) {\n  PrintStringTo(s, os);\n}\n#endif  // GTEST_HAS_GLOBAL_STRING\n\nGTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os);\ninline void PrintTo(const ::std::string& s, ::std::ostream* os) {\n  PrintStringTo(s, os);\n}\n\n// Overloads for ::wstring and ::std::wstring.\n#if GTEST_HAS_GLOBAL_WSTRING\nGTEST_API_ void PrintWideStringTo(const ::wstring&s, ::std::ostream* os);\ninline void PrintTo(const ::wstring& s, ::std::ostream* os) {\n  PrintWideStringTo(s, os);\n}\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n#if GTEST_HAS_STD_WSTRING\nGTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);\ninline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {\n  PrintWideStringTo(s, os);\n}\n#endif  // GTEST_HAS_STD_WSTRING\n\n#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_\n// Helper function for printing a tuple.  T must be instantiated with\n// a tuple type.\ntemplate <typename T>\nvoid PrintTupleTo(const T& t, ::std::ostream* os);\n#endif  // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_\n\n#if GTEST_HAS_TR1_TUPLE\n// Overload for ::std::tr1::tuple.  Needed for printing function arguments,\n// which are packed as tuples.\n\n// Overloaded PrintTo() for tuples of various arities.  We support\n// tuples of up-to 10 fields.  The following implementation works\n// regardless of whether tr1::tuple is implemented using the\n// non-standard variadic template feature or not.\n\ninline void PrintTo(const ::std::tr1::tuple<>& t, ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1>\nvoid PrintTo(const ::std::tr1::tuple<T1>& t, ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2>& t, ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2, T3>& t, ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4>& t, ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5>& t,\n             ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n          typename T6>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6>& t,\n             ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n          typename T6, typename T7>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7>& t,\n             ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n          typename T6, typename T7, typename T8>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8>& t,\n             ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n          typename T6, typename T7, typename T8, typename T9>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t,\n             ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n          typename T6, typename T7, typename T8, typename T9, typename T10>\nvoid PrintTo(\n    const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& t,\n    ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n#endif  // GTEST_HAS_TR1_TUPLE\n\n#if GTEST_HAS_STD_TUPLE_\ntemplate <typename... Types>\nvoid PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n#endif  // GTEST_HAS_STD_TUPLE_\n\n// Overload for std::pair.\ntemplate <typename T1, typename T2>\nvoid PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {\n  *os << '(';\n  // We cannot use UniversalPrint(value.first, os) here, as T1 may be\n  // a reference type.  The same for printing value.second.\n  UniversalPrinter<T1>::Print(value.first, os);\n  *os << \", \";\n  UniversalPrinter<T2>::Print(value.second, os);\n  *os << ')';\n}\n\n// Implements printing a non-reference type T by letting the compiler\n// pick the right overload of PrintTo() for T.\ntemplate <typename T>\nclass UniversalPrinter {\n public:\n  // MSVC warns about adding const to a function type, so we want to\n  // disable the warning.\n  GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)\n\n  // Note: we deliberately don't call this PrintTo(), as that name\n  // conflicts with ::testing::internal::PrintTo in the body of the\n  // function.\n  static void Print(const T& value, ::std::ostream* os) {\n    // By default, ::testing::internal::PrintTo() is used for printing\n    // the value.\n    //\n    // Thanks to Koenig look-up, if T is a class and has its own\n    // PrintTo() function defined in its namespace, that function will\n    // be visible here.  Since it is more specific than the generic ones\n    // in ::testing::internal, it will be picked by the compiler in the\n    // following statement - exactly what we want.\n    PrintTo(value, os);\n  }\n\n  GTEST_DISABLE_MSC_WARNINGS_POP_()\n};\n\n// UniversalPrintArray(begin, len, os) prints an array of 'len'\n// elements, starting at address 'begin'.\ntemplate <typename T>\nvoid UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {\n  if (len == 0) {\n    *os << \"{}\";\n  } else {\n    *os << \"{ \";\n    const size_t kThreshold = 18;\n    const size_t kChunkSize = 8;\n    // If the array has more than kThreshold elements, we'll have to\n    // omit some details by printing only the first and the last\n    // kChunkSize elements.\n    // TODO(wan@google.com): let the user control the threshold using a flag.\n    if (len <= kThreshold) {\n      PrintRawArrayTo(begin, len, os);\n    } else {\n      PrintRawArrayTo(begin, kChunkSize, os);\n      *os << \", ..., \";\n      PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os);\n    }\n    *os << \" }\";\n  }\n}\n// This overload prints a (const) char array compactly.\nGTEST_API_ void UniversalPrintArray(\n    const char* begin, size_t len, ::std::ostream* os);\n\n// This overload prints a (const) wchar_t array compactly.\nGTEST_API_ void UniversalPrintArray(\n    const wchar_t* begin, size_t len, ::std::ostream* os);\n\n// Implements printing an array type T[N].\ntemplate <typename T, size_t N>\nclass UniversalPrinter<T[N]> {\n public:\n  // Prints the given array, omitting some elements when there are too\n  // many.\n  static void Print(const T (&a)[N], ::std::ostream* os) {\n    UniversalPrintArray(a, N, os);\n  }\n};\n\n// Implements printing a reference type T&.\ntemplate <typename T>\nclass UniversalPrinter<T&> {\n public:\n  // MSVC warns about adding const to a function type, so we want to\n  // disable the warning.\n  GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)\n\n  static void Print(const T& value, ::std::ostream* os) {\n    // Prints the address of the value.  We use reinterpret_cast here\n    // as static_cast doesn't compile when T is a function type.\n    *os << \"@\" << reinterpret_cast<const void*>(&value) << \" \";\n\n    // Then prints the value itself.\n    UniversalPrint(value, os);\n  }\n\n  GTEST_DISABLE_MSC_WARNINGS_POP_()\n};\n\n// Prints a value tersely: for a reference type, the referenced value\n// (but not the address) is printed; for a (const) char pointer, the\n// NUL-terminated string (but not the pointer) is printed.\n\ntemplate <typename T>\nclass UniversalTersePrinter {\n public:\n  static void Print(const T& value, ::std::ostream* os) {\n    UniversalPrint(value, os);\n  }\n};\ntemplate <typename T>\nclass UniversalTersePrinter<T&> {\n public:\n  static void Print(const T& value, ::std::ostream* os) {\n    UniversalPrint(value, os);\n  }\n};\ntemplate <typename T, size_t N>\nclass UniversalTersePrinter<T[N]> {\n public:\n  static void Print(const T (&value)[N], ::std::ostream* os) {\n    UniversalPrinter<T[N]>::Print(value, os);\n  }\n};\ntemplate <>\nclass UniversalTersePrinter<const char*> {\n public:\n  static void Print(const char* str, ::std::ostream* os) {\n    if (str == NULL) {\n      *os << \"NULL\";\n    } else {\n      UniversalPrint(string(str), os);\n    }\n  }\n};\ntemplate <>\nclass UniversalTersePrinter<char*> {\n public:\n  static void Print(char* str, ::std::ostream* os) {\n    UniversalTersePrinter<const char*>::Print(str, os);\n  }\n};\n\n#if GTEST_HAS_STD_WSTRING\ntemplate <>\nclass UniversalTersePrinter<const wchar_t*> {\n public:\n  static void Print(const wchar_t* str, ::std::ostream* os) {\n    if (str == NULL) {\n      *os << \"NULL\";\n    } else {\n      UniversalPrint(::std::wstring(str), os);\n    }\n  }\n};\n#endif\n\ntemplate <>\nclass UniversalTersePrinter<wchar_t*> {\n public:\n  static void Print(wchar_t* str, ::std::ostream* os) {\n    UniversalTersePrinter<const wchar_t*>::Print(str, os);\n  }\n};\n\ntemplate <typename T>\nvoid UniversalTersePrint(const T& value, ::std::ostream* os) {\n  UniversalTersePrinter<T>::Print(value, os);\n}\n\n// Prints a value using the type inferred by the compiler.  The\n// difference between this and UniversalTersePrint() is that for a\n// (const) char pointer, this prints both the pointer and the\n// NUL-terminated string.\ntemplate <typename T>\nvoid UniversalPrint(const T& value, ::std::ostream* os) {\n  // A workarond for the bug in VC++ 7.1 that prevents us from instantiating\n  // UniversalPrinter with T directly.\n  typedef T T1;\n  UniversalPrinter<T1>::Print(value, os);\n}\n\ntypedef ::std::vector<string> Strings;\n\n// TuplePolicy<TupleT> must provide:\n// - tuple_size\n//     size of tuple TupleT.\n// - get<size_t I>(const TupleT& t)\n//     static function extracting element I of tuple TupleT.\n// - tuple_element<size_t I>::type\n//     type of element I of tuple TupleT.\ntemplate <typename TupleT>\nstruct TuplePolicy;\n\n#if GTEST_HAS_TR1_TUPLE\ntemplate <typename TupleT>\nstruct TuplePolicy {\n  typedef TupleT Tuple;\n  static const size_t tuple_size = ::std::tr1::tuple_size<Tuple>::value;\n\n  template <size_t I>\n  struct tuple_element : ::std::tr1::tuple_element<I, Tuple> {};\n\n  template <size_t I>\n  static typename AddReference<\n      const typename ::std::tr1::tuple_element<I, Tuple>::type>::type get(\n      const Tuple& tuple) {\n    return ::std::tr1::get<I>(tuple);\n  }\n};\ntemplate <typename TupleT>\nconst size_t TuplePolicy<TupleT>::tuple_size;\n#endif  // GTEST_HAS_TR1_TUPLE\n\n#if GTEST_HAS_STD_TUPLE_\ntemplate <typename... Types>\nstruct TuplePolicy< ::std::tuple<Types...> > {\n  typedef ::std::tuple<Types...> Tuple;\n  static const size_t tuple_size = ::std::tuple_size<Tuple>::value;\n\n  template <size_t I>\n  struct tuple_element : ::std::tuple_element<I, Tuple> {};\n\n  template <size_t I>\n  static const typename ::std::tuple_element<I, Tuple>::type& get(\n      const Tuple& tuple) {\n    return ::std::get<I>(tuple);\n  }\n};\ntemplate <typename... Types>\nconst size_t TuplePolicy< ::std::tuple<Types...> >::tuple_size;\n#endif  // GTEST_HAS_STD_TUPLE_\n\n#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_\n// This helper template allows PrintTo() for tuples and\n// UniversalTersePrintTupleFieldsToStrings() to be defined by\n// induction on the number of tuple fields.  The idea is that\n// TuplePrefixPrinter<N>::PrintPrefixTo(t, os) prints the first N\n// fields in tuple t, and can be defined in terms of\n// TuplePrefixPrinter<N - 1>.\n//\n// The inductive case.\ntemplate <size_t N>\nstruct TuplePrefixPrinter {\n  // Prints the first N fields of a tuple.\n  template <typename Tuple>\n  static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {\n    TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);\n    GTEST_INTENTIONAL_CONST_COND_PUSH_()\n    if (N > 1) {\n    GTEST_INTENTIONAL_CONST_COND_POP_()\n      *os << \", \";\n    }\n    UniversalPrinter<\n        typename TuplePolicy<Tuple>::template tuple_element<N - 1>::type>\n        ::Print(TuplePolicy<Tuple>::template get<N - 1>(t), os);\n  }\n\n  // Tersely prints the first N fields of a tuple to a string vector,\n  // one element for each field.\n  template <typename Tuple>\n  static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {\n    TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);\n    ::std::stringstream ss;\n    UniversalTersePrint(TuplePolicy<Tuple>::template get<N - 1>(t), &ss);\n    strings->push_back(ss.str());\n  }\n};\n\n// Base case.\ntemplate <>\nstruct TuplePrefixPrinter<0> {\n  template <typename Tuple>\n  static void PrintPrefixTo(const Tuple&, ::std::ostream*) {}\n\n  template <typename Tuple>\n  static void TersePrintPrefixToStrings(const Tuple&, Strings*) {}\n};\n\n// Helper function for printing a tuple.\n// Tuple must be either std::tr1::tuple or std::tuple type.\ntemplate <typename Tuple>\nvoid PrintTupleTo(const Tuple& t, ::std::ostream* os) {\n  *os << \"(\";\n  TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>::PrintPrefixTo(t, os);\n  *os << \")\";\n}\n\n// Prints the fields of a tuple tersely to a string vector, one\n// element for each field.  See the comment before\n// UniversalTersePrint() for how we define \"tersely\".\ntemplate <typename Tuple>\nStrings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {\n  Strings result;\n  TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>::\n      TersePrintPrefixToStrings(value, &result);\n  return result;\n}\n#endif  // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_\n\n}  // namespace internal\n\ntemplate <typename T>\n::std::string PrintToString(const T& value) {\n  ::std::stringstream ss;\n  internal::UniversalTersePrinter<T>::Print(value, &ss);\n  return ss.str();\n}\n\n}  // namespace testing\n\n// Include any custom printer added by the local installation.\n// We must include this header at the end to make sure it can use the\n// declarations from this file.\n#include \"gtest/internal/custom/gtest-printers.h\"\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/gtest-spi.h",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Utilities for testing Google Test itself and code that uses Google Test\n// (e.g. frameworks built on top of Google Test).\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_SPI_H_\n#define GTEST_INCLUDE_GTEST_GTEST_SPI_H_\n\n#include \"gtest/gtest.h\"\n\nnamespace testing {\n\n// This helper class can be used to mock out Google Test failure reporting\n// so that we can test Google Test or code that builds on Google Test.\n//\n// An object of this class appends a TestPartResult object to the\n// TestPartResultArray object given in the constructor whenever a Google Test\n// failure is reported. It can either intercept only failures that are\n// generated in the same thread that created this object or it can intercept\n// all generated failures. The scope of this mock object can be controlled with\n// the second argument to the two arguments constructor.\nclass GTEST_API_ ScopedFakeTestPartResultReporter\n    : public TestPartResultReporterInterface {\n public:\n  // The two possible mocking modes of this object.\n  enum InterceptMode {\n    INTERCEPT_ONLY_CURRENT_THREAD,  // Intercepts only thread local failures.\n    INTERCEPT_ALL_THREADS           // Intercepts all failures.\n  };\n\n  // The c'tor sets this object as the test part result reporter used\n  // by Google Test.  The 'result' parameter specifies where to report the\n  // results. This reporter will only catch failures generated in the current\n  // thread. DEPRECATED\n  explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result);\n\n  // Same as above, but you can choose the interception scope of this object.\n  ScopedFakeTestPartResultReporter(InterceptMode intercept_mode,\n                                   TestPartResultArray* result);\n\n  // The d'tor restores the previous test part result reporter.\n  virtual ~ScopedFakeTestPartResultReporter();\n\n  // Appends the TestPartResult object to the TestPartResultArray\n  // received in the constructor.\n  //\n  // This method is from the TestPartResultReporterInterface\n  // interface.\n  virtual void ReportTestPartResult(const TestPartResult& result);\n private:\n  void Init();\n\n  const InterceptMode intercept_mode_;\n  TestPartResultReporterInterface* old_reporter_;\n  TestPartResultArray* const result_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter);\n};\n\nnamespace internal {\n\n// A helper class for implementing EXPECT_FATAL_FAILURE() and\n// EXPECT_NONFATAL_FAILURE().  Its destructor verifies that the given\n// TestPartResultArray contains exactly one failure that has the given\n// type and contains the given substring.  If that's not the case, a\n// non-fatal failure will be generated.\nclass GTEST_API_ SingleFailureChecker {\n public:\n  // The constructor remembers the arguments.\n  SingleFailureChecker(const TestPartResultArray* results,\n                       TestPartResult::Type type,\n                       const string& substr);\n  ~SingleFailureChecker();\n private:\n  const TestPartResultArray* const results_;\n  const TestPartResult::Type type_;\n  const string substr_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);\n};\n\n}  // namespace internal\n\n}  // namespace testing\n\n// A set of macros for testing Google Test assertions or code that's expected\n// to generate Google Test fatal failures.  It verifies that the given\n// statement will cause exactly one fatal Google Test failure with 'substr'\n// being part of the failure message.\n//\n// There are two different versions of this macro. EXPECT_FATAL_FAILURE only\n// affects and considers failures generated in the current thread and\n// EXPECT_FATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.\n//\n// The verification of the assertion is done correctly even when the statement\n// throws an exception or aborts the current function.\n//\n// Known restrictions:\n//   - 'statement' cannot reference local non-static variables or\n//     non-static members of the current object.\n//   - 'statement' cannot return a value.\n//   - You cannot stream a failure message to this macro.\n//\n// Note that even though the implementations of the following two\n// macros are much alike, we cannot refactor them to use a common\n// helper macro, due to some peculiarity in how the preprocessor\n// works.  The AcceptsMacroThatExpandsToUnprotectedComma test in\n// gtest_unittest.cc will fail to compile if we do that.\n#define EXPECT_FATAL_FAILURE(statement, substr) \\\n  do { \\\n    class GTestExpectFatalFailureHelper {\\\n     public:\\\n      static void Execute() { statement; }\\\n    };\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter:: \\\n          INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\\\n      GTestExpectFatalFailureHelper::Execute();\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \\\n  do { \\\n    class GTestExpectFatalFailureHelper {\\\n     public:\\\n      static void Execute() { statement; }\\\n    };\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter:: \\\n          INTERCEPT_ALL_THREADS, &gtest_failures);\\\n      GTestExpectFatalFailureHelper::Execute();\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n// A macro for testing Google Test assertions or code that's expected to\n// generate Google Test non-fatal failures.  It asserts that the given\n// statement will cause exactly one non-fatal Google Test failure with 'substr'\n// being part of the failure message.\n//\n// There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only\n// affects and considers failures generated in the current thread and\n// EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.\n//\n// 'statement' is allowed to reference local variables and members of\n// the current object.\n//\n// The verification of the assertion is done correctly even when the statement\n// throws an exception or aborts the current function.\n//\n// Known restrictions:\n//   - You cannot stream a failure message to this macro.\n//\n// Note that even though the implementations of the following two\n// macros are much alike, we cannot refactor them to use a common\n// helper macro, due to some peculiarity in how the preprocessor\n// works.  If we do that, the code won't compile when the user gives\n// EXPECT_NONFATAL_FAILURE() a statement that contains a macro that\n// expands to code containing an unprotected comma.  The\n// AcceptsMacroThatExpandsToUnprotectedComma test in gtest_unittest.cc\n// catches that.\n//\n// For the same reason, we have to write\n//   if (::testing::internal::AlwaysTrue()) { statement; }\n// instead of\n//   GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)\n// to avoid an MSVC warning on unreachable code.\n#define EXPECT_NONFATAL_FAILURE(statement, substr) \\\n  do {\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \\\n        (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter:: \\\n          INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\\\n      if (::testing::internal::AlwaysTrue()) { statement; }\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \\\n  do {\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \\\n        (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \\\n          &gtest_failures);\\\n      if (::testing::internal::AlwaysTrue()) { statement; }\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_SPI_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/gtest-test-part.h",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: mheule@google.com (Markus Heule)\n//\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_\n#define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_\n\n#include <iosfwd>\n#include <vector>\n#include \"gtest/internal/gtest-internal.h\"\n#include \"gtest/internal/gtest-string.h\"\n\nnamespace testing {\n\n// A copyable object representing the result of a test part (i.e. an\n// assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).\n//\n// Don't inherit from TestPartResult as its destructor is not virtual.\nclass GTEST_API_ TestPartResult {\n public:\n  // The possible outcomes of a test part (i.e. an assertion or an\n  // explicit SUCCEED(), FAIL(), or ADD_FAILURE()).\n  enum Type {\n    kSuccess,          // Succeeded.\n    kNonFatalFailure,  // Failed but the test can continue.\n    kFatalFailure      // Failed and the test should be terminated.\n  };\n\n  // C'tor.  TestPartResult does NOT have a default constructor.\n  // Always use this constructor (with parameters) to create a\n  // TestPartResult object.\n  TestPartResult(Type a_type,\n                 const char* a_file_name,\n                 int a_line_number,\n                 const char* a_message)\n      : type_(a_type),\n        file_name_(a_file_name == NULL ? \"\" : a_file_name),\n        line_number_(a_line_number),\n        summary_(ExtractSummary(a_message)),\n        message_(a_message) {\n  }\n\n  // Gets the outcome of the test part.\n  Type type() const { return type_; }\n\n  // Gets the name of the source file where the test part took place, or\n  // NULL if it's unknown.\n  const char* file_name() const {\n    return file_name_.empty() ? NULL : file_name_.c_str();\n  }\n\n  // Gets the line in the source file where the test part took place,\n  // or -1 if it's unknown.\n  int line_number() const { return line_number_; }\n\n  // Gets the summary of the failure message.\n  const char* summary() const { return summary_.c_str(); }\n\n  // Gets the message associated with the test part.\n  const char* message() const { return message_.c_str(); }\n\n  // Returns true iff the test part passed.\n  bool passed() const { return type_ == kSuccess; }\n\n  // Returns true iff the test part failed.\n  bool failed() const { return type_ != kSuccess; }\n\n  // Returns true iff the test part non-fatally failed.\n  bool nonfatally_failed() const { return type_ == kNonFatalFailure; }\n\n  // Returns true iff the test part fatally failed.\n  bool fatally_failed() const { return type_ == kFatalFailure; }\n\n private:\n  Type type_;\n\n  // Gets the summary of the failure message by omitting the stack\n  // trace in it.\n  static std::string ExtractSummary(const char* message);\n\n  // The name of the source file where the test part took place, or\n  // \"\" if the source file is unknown.\n  std::string file_name_;\n  // The line in the source file where the test part took place, or -1\n  // if the line number is unknown.\n  int line_number_;\n  std::string summary_;  // The test failure summary.\n  std::string message_;  // The test failure message.\n};\n\n// Prints a TestPartResult object.\nstd::ostream& operator<<(std::ostream& os, const TestPartResult& result);\n\n// An array of TestPartResult objects.\n//\n// Don't inherit from TestPartResultArray as its destructor is not\n// virtual.\nclass GTEST_API_ TestPartResultArray {\n public:\n  TestPartResultArray() {}\n\n  // Appends the given TestPartResult to the array.\n  void Append(const TestPartResult& result);\n\n  // Returns the TestPartResult at the given index (0-based).\n  const TestPartResult& GetTestPartResult(int index) const;\n\n  // Returns the number of TestPartResult objects in the array.\n  int size() const;\n\n private:\n  std::vector<TestPartResult> array_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);\n};\n\n// This interface knows how to report a test part result.\nclass TestPartResultReporterInterface {\n public:\n  virtual ~TestPartResultReporterInterface() {}\n\n  virtual void ReportTestPartResult(const TestPartResult& result) = 0;\n};\n\nnamespace internal {\n\n// This helper class is used by {ASSERT|EXPECT}_NO_FATAL_FAILURE to check if a\n// statement generates new fatal failures. To do so it registers itself as the\n// current test part result reporter. Besides checking if fatal failures were\n// reported, it only delegates the reporting to the former result reporter.\n// The original result reporter is restored in the destructor.\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nclass GTEST_API_ HasNewFatalFailureHelper\n    : public TestPartResultReporterInterface {\n public:\n  HasNewFatalFailureHelper();\n  virtual ~HasNewFatalFailureHelper();\n  virtual void ReportTestPartResult(const TestPartResult& result);\n  bool has_new_fatal_failure() const { return has_new_fatal_failure_; }\n private:\n  bool has_new_fatal_failure_;\n  TestPartResultReporterInterface* original_reporter_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper);\n};\n\n}  // namespace internal\n\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/gtest-typed-test.h",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_\n#define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_\n\n// This header implements typed tests and type-parameterized tests.\n\n// Typed (aka type-driven) tests repeat the same test for types in a\n// list.  You must know which types you want to test with when writing\n// typed tests. Here's how you do it:\n\n#if 0\n\n// First, define a fixture class template.  It should be parameterized\n// by a type.  Remember to derive it from testing::Test.\ntemplate <typename T>\nclass FooTest : public testing::Test {\n public:\n  ...\n  typedef std::list<T> List;\n  static T shared_;\n  T value_;\n};\n\n// Next, associate a list of types with the test case, which will be\n// repeated for each type in the list.  The typedef is necessary for\n// the macro to parse correctly.\ntypedef testing::Types<char, int, unsigned int> MyTypes;\nTYPED_TEST_CASE(FooTest, MyTypes);\n\n// If the type list contains only one type, you can write that type\n// directly without Types<...>:\n//   TYPED_TEST_CASE(FooTest, int);\n\n// Then, use TYPED_TEST() instead of TEST_F() to define as many typed\n// tests for this test case as you want.\nTYPED_TEST(FooTest, DoesBlah) {\n  // Inside a test, refer to TypeParam to get the type parameter.\n  // Since we are inside a derived class template, C++ requires use to\n  // visit the members of FooTest via 'this'.\n  TypeParam n = this->value_;\n\n  // To visit static members of the fixture, add the TestFixture::\n  // prefix.\n  n += TestFixture::shared_;\n\n  // To refer to typedefs in the fixture, add the \"typename\n  // TestFixture::\" prefix.\n  typename TestFixture::List values;\n  values.push_back(n);\n  ...\n}\n\nTYPED_TEST(FooTest, HasPropertyA) { ... }\n\n#endif  // 0\n\n// Type-parameterized tests are abstract test patterns parameterized\n// by a type.  Compared with typed tests, type-parameterized tests\n// allow you to define the test pattern without knowing what the type\n// parameters are.  The defined pattern can be instantiated with\n// different types any number of times, in any number of translation\n// units.\n//\n// If you are designing an interface or concept, you can define a\n// suite of type-parameterized tests to verify properties that any\n// valid implementation of the interface/concept should have.  Then,\n// each implementation can easily instantiate the test suite to verify\n// that it conforms to the requirements, without having to write\n// similar tests repeatedly.  Here's an example:\n\n#if 0\n\n// First, define a fixture class template.  It should be parameterized\n// by a type.  Remember to derive it from testing::Test.\ntemplate <typename T>\nclass FooTest : public testing::Test {\n  ...\n};\n\n// Next, declare that you will define a type-parameterized test case\n// (the _P suffix is for \"parameterized\" or \"pattern\", whichever you\n// prefer):\nTYPED_TEST_CASE_P(FooTest);\n\n// Then, use TYPED_TEST_P() to define as many type-parameterized tests\n// for this type-parameterized test case as you want.\nTYPED_TEST_P(FooTest, DoesBlah) {\n  // Inside a test, refer to TypeParam to get the type parameter.\n  TypeParam n = 0;\n  ...\n}\n\nTYPED_TEST_P(FooTest, HasPropertyA) { ... }\n\n// Now the tricky part: you need to register all test patterns before\n// you can instantiate them.  The first argument of the macro is the\n// test case name; the rest are the names of the tests in this test\n// case.\nREGISTER_TYPED_TEST_CASE_P(FooTest,\n                           DoesBlah, HasPropertyA);\n\n// Finally, you are free to instantiate the pattern with the types you\n// want.  If you put the above code in a header file, you can #include\n// it in multiple C++ source files and instantiate it multiple times.\n//\n// To distinguish different instances of the pattern, the first\n// argument to the INSTANTIATE_* macro is a prefix that will be added\n// to the actual test case name.  Remember to pick unique prefixes for\n// different instances.\ntypedef testing::Types<char, int, unsigned int> MyTypes;\nINSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);\n\n// If the type list contains only one type, you can write that type\n// directly without Types<...>:\n//   INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int);\n\n#endif  // 0\n\n#include \"gtest/internal/gtest-port.h\"\n#include \"gtest/internal/gtest-type-util.h\"\n\n// Implements typed tests.\n\n#if GTEST_HAS_TYPED_TEST\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Expands to the name of the typedef for the type parameters of the\n// given test case.\n# define GTEST_TYPE_PARAMS_(TestCaseName) gtest_type_params_##TestCaseName##_\n\n// The 'Types' template argument below must have spaces around it\n// since some compilers may choke on '>>' when passing a template\n// instance (e.g. Types<int>)\n# define TYPED_TEST_CASE(CaseName, Types) \\\n  typedef ::testing::internal::TypeList< Types >::type \\\n      GTEST_TYPE_PARAMS_(CaseName)\n\n# define TYPED_TEST(CaseName, TestName) \\\n  template <typename gtest_TypeParam_> \\\n  class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \\\n      : public CaseName<gtest_TypeParam_> { \\\n   private: \\\n    typedef CaseName<gtest_TypeParam_> TestFixture; \\\n    typedef gtest_TypeParam_ TypeParam; \\\n    virtual void TestBody(); \\\n  }; \\\n  bool gtest_##CaseName##_##TestName##_registered_ GTEST_ATTRIBUTE_UNUSED_ = \\\n      ::testing::internal::TypeParameterizedTest< \\\n          CaseName, \\\n          ::testing::internal::TemplateSel< \\\n              GTEST_TEST_CLASS_NAME_(CaseName, TestName)>, \\\n          GTEST_TYPE_PARAMS_(CaseName)>::Register(\\\n              \"\", ::testing::internal::CodeLocation(__FILE__, __LINE__), \\\n              #CaseName, #TestName, 0); \\\n  template <typename gtest_TypeParam_> \\\n  void GTEST_TEST_CLASS_NAME_(CaseName, TestName)<gtest_TypeParam_>::TestBody()\n\n#endif  // GTEST_HAS_TYPED_TEST\n\n// Implements type-parameterized tests.\n\n#if GTEST_HAS_TYPED_TEST_P\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Expands to the namespace name that the type-parameterized tests for\n// the given type-parameterized test case are defined in.  The exact\n// name of the namespace is subject to change without notice.\n# define GTEST_CASE_NAMESPACE_(TestCaseName) \\\n  gtest_case_##TestCaseName##_\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Expands to the name of the variable used to remember the names of\n// the defined tests in the given test case.\n# define GTEST_TYPED_TEST_CASE_P_STATE_(TestCaseName) \\\n  gtest_typed_test_case_p_state_##TestCaseName##_\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE DIRECTLY.\n//\n// Expands to the name of the variable used to remember the names of\n// the registered tests in the given test case.\n# define GTEST_REGISTERED_TEST_NAMES_(TestCaseName) \\\n  gtest_registered_test_names_##TestCaseName##_\n\n// The variables defined in the type-parameterized test macros are\n// static as typically these macros are used in a .h file that can be\n// #included in multiple translation units linked together.\n# define TYPED_TEST_CASE_P(CaseName) \\\n  static ::testing::internal::TypedTestCasePState \\\n      GTEST_TYPED_TEST_CASE_P_STATE_(CaseName)\n\n# define TYPED_TEST_P(CaseName, TestName) \\\n  namespace GTEST_CASE_NAMESPACE_(CaseName) { \\\n  template <typename gtest_TypeParam_> \\\n  class TestName : public CaseName<gtest_TypeParam_> { \\\n   private: \\\n    typedef CaseName<gtest_TypeParam_> TestFixture; \\\n    typedef gtest_TypeParam_ TypeParam; \\\n    virtual void TestBody(); \\\n  }; \\\n  static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \\\n      GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\\\n          __FILE__, __LINE__, #CaseName, #TestName); \\\n  } \\\n  template <typename gtest_TypeParam_> \\\n  void GTEST_CASE_NAMESPACE_(CaseName)::TestName<gtest_TypeParam_>::TestBody()\n\n# define REGISTER_TYPED_TEST_CASE_P(CaseName, ...) \\\n  namespace GTEST_CASE_NAMESPACE_(CaseName) { \\\n  typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \\\n  } \\\n  static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) = \\\n      GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\\\n          __FILE__, __LINE__, #__VA_ARGS__)\n\n// The 'Types' template argument below must have spaces around it\n// since some compilers may choke on '>>' when passing a template\n// instance (e.g. Types<int>)\n# define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types) \\\n  bool gtest_##Prefix##_##CaseName GTEST_ATTRIBUTE_UNUSED_ = \\\n      ::testing::internal::TypeParameterizedTestCase<CaseName, \\\n          GTEST_CASE_NAMESPACE_(CaseName)::gtest_AllTests_, \\\n          ::testing::internal::TypeList< Types >::type>::Register(\\\n              #Prefix, \\\n              ::testing::internal::CodeLocation(__FILE__, __LINE__), \\\n              &GTEST_TYPED_TEST_CASE_P_STATE_(CaseName), \\\n              #CaseName, GTEST_REGISTERED_TEST_NAMES_(CaseName))\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/gtest.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This header file defines the public API for Google Test.  It should be\n// included by any test program that uses Google Test.\n//\n// IMPORTANT NOTE: Due to limitation of the C++ language, we have to\n// leave some internal implementation details in this header file.\n// They are clearly marked by comments like this:\n//\n//   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n//\n// Such code is NOT meant to be used by a user directly, and is subject\n// to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user\n// program!\n//\n// Acknowledgment: Google Test borrowed the idea of automatic test\n// registration from Barthelemy Dagenais' (barthelemy@prologique.com)\n// easyUnit framework.\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_H_\n#define GTEST_INCLUDE_GTEST_GTEST_H_\n\n#include <limits>\n#include <ostream>\n#include <vector>\n\n#include \"gtest/internal/gtest-internal.h\"\n#include \"gtest/internal/gtest-string.h\"\n#include \"gtest/gtest-death-test.h\"\n#include \"gtest/gtest-message.h\"\n#include \"gtest/gtest-param-test.h\"\n#include \"gtest/gtest-printers.h\"\n#include \"gtest/gtest_prod.h\"\n#include \"gtest/gtest-test-part.h\"\n#include \"gtest/gtest-typed-test.h\"\n\n// Depending on the platform, different string classes are available.\n// On Linux, in addition to ::std::string, Google also makes use of\n// class ::string, which has the same interface as ::std::string, but\n// has a different implementation.\n//\n// You can define GTEST_HAS_GLOBAL_STRING to 1 to indicate that\n// ::string is available AND is a distinct type to ::std::string, or\n// define it to 0 to indicate otherwise.\n//\n// If ::std::string and ::string are the same class on your platform\n// due to aliasing, you should define GTEST_HAS_GLOBAL_STRING to 0.\n//\n// If you do not define GTEST_HAS_GLOBAL_STRING, it is defined\n// heuristically.\n\nnamespace testing {\n\n// Declares the flags.\n\n// This flag temporary enables the disabled tests.\nGTEST_DECLARE_bool_(also_run_disabled_tests);\n\n// This flag brings the debugger on an assertion failure.\nGTEST_DECLARE_bool_(break_on_failure);\n\n// This flag controls whether Google Test catches all test-thrown exceptions\n// and logs them as failures.\nGTEST_DECLARE_bool_(catch_exceptions);\n\n// This flag enables using colors in terminal output. Available values are\n// \"yes\" to enable colors, \"no\" (disable colors), or \"auto\" (the default)\n// to let Google Test decide.\nGTEST_DECLARE_string_(color);\n\n// This flag sets up the filter to select by name using a glob pattern\n// the tests to run. If the filter is not given all tests are executed.\nGTEST_DECLARE_string_(filter);\n\n// This flag causes the Google Test to list tests. None of the tests listed\n// are actually run if the flag is provided.\nGTEST_DECLARE_bool_(list_tests);\n\n// This flag controls whether Google Test emits a detailed XML report to a file\n// in addition to its normal textual output.\nGTEST_DECLARE_string_(output);\n\n// This flags control whether Google Test prints the elapsed time for each\n// test.\nGTEST_DECLARE_bool_(print_time);\n\n// This flag specifies the random number seed.\nGTEST_DECLARE_int32_(random_seed);\n\n// This flag sets how many times the tests are repeated. The default value\n// is 1. If the value is -1 the tests are repeating forever.\nGTEST_DECLARE_int32_(repeat);\n\n// This flag controls whether Google Test includes Google Test internal\n// stack frames in failure stack traces.\nGTEST_DECLARE_bool_(show_internal_stack_frames);\n\n// When this flag is specified, tests' order is randomized on every iteration.\nGTEST_DECLARE_bool_(shuffle);\n\n// This flag specifies the maximum number of stack frames to be\n// printed in a failure message.\nGTEST_DECLARE_int32_(stack_trace_depth);\n\n// When this flag is specified, a failed assertion will throw an\n// exception if exceptions are enabled, or exit the program with a\n// non-zero code otherwise.\nGTEST_DECLARE_bool_(throw_on_failure);\n\n// When this flag is set with a \"host:port\" string, on supported\n// platforms test results are streamed to the specified port on\n// the specified host machine.\nGTEST_DECLARE_string_(stream_result_to);\n\n// The upper limit for valid stack trace depths.\nconst int kMaxStackTraceDepth = 100;\n\nnamespace internal {\n\nclass AssertHelper;\nclass DefaultGlobalTestPartResultReporter;\nclass ExecDeathTest;\nclass NoExecDeathTest;\nclass FinalSuccessChecker;\nclass GTestFlagSaver;\nclass StreamingListenerTest;\nclass TestResultAccessor;\nclass TestEventListenersAccessor;\nclass TestEventRepeater;\nclass UnitTestRecordPropertyTestHelper;\nclass WindowsDeathTest;\nclass UnitTestImpl* GetUnitTestImpl();\nvoid ReportFailureInUnknownLocation(TestPartResult::Type result_type,\n                                    const std::string& message);\n\n}  // namespace internal\n\n// The friend relationship of some of these classes is cyclic.\n// If we don't forward declare them the compiler might confuse the classes\n// in friendship clauses with same named classes on the scope.\nclass Test;\nclass TestCase;\nclass TestInfo;\nclass UnitTest;\n\n// A class for indicating whether an assertion was successful.  When\n// the assertion wasn't successful, the AssertionResult object\n// remembers a non-empty message that describes how it failed.\n//\n// To create an instance of this class, use one of the factory functions\n// (AssertionSuccess() and AssertionFailure()).\n//\n// This class is useful for two purposes:\n//   1. Defining predicate functions to be used with Boolean test assertions\n//      EXPECT_TRUE/EXPECT_FALSE and their ASSERT_ counterparts\n//   2. Defining predicate-format functions to be\n//      used with predicate assertions (ASSERT_PRED_FORMAT*, etc).\n//\n// For example, if you define IsEven predicate:\n//\n//   testing::AssertionResult IsEven(int n) {\n//     if ((n % 2) == 0)\n//       return testing::AssertionSuccess();\n//     else\n//       return testing::AssertionFailure() << n << \" is odd\";\n//   }\n//\n// Then the failed expectation EXPECT_TRUE(IsEven(Fib(5)))\n// will print the message\n//\n//   Value of: IsEven(Fib(5))\n//     Actual: false (5 is odd)\n//   Expected: true\n//\n// instead of a more opaque\n//\n//   Value of: IsEven(Fib(5))\n//     Actual: false\n//   Expected: true\n//\n// in case IsEven is a simple Boolean predicate.\n//\n// If you expect your predicate to be reused and want to support informative\n// messages in EXPECT_FALSE and ASSERT_FALSE (negative assertions show up\n// about half as often as positive ones in our tests), supply messages for\n// both success and failure cases:\n//\n//   testing::AssertionResult IsEven(int n) {\n//     if ((n % 2) == 0)\n//       return testing::AssertionSuccess() << n << \" is even\";\n//     else\n//       return testing::AssertionFailure() << n << \" is odd\";\n//   }\n//\n// Then a statement EXPECT_FALSE(IsEven(Fib(6))) will print\n//\n//   Value of: IsEven(Fib(6))\n//     Actual: true (8 is even)\n//   Expected: false\n//\n// NB: Predicates that support negative Boolean assertions have reduced\n// performance in positive ones so be careful not to use them in tests\n// that have lots (tens of thousands) of positive Boolean assertions.\n//\n// To use this class with EXPECT_PRED_FORMAT assertions such as:\n//\n//   // Verifies that Foo() returns an even number.\n//   EXPECT_PRED_FORMAT1(IsEven, Foo());\n//\n// you need to define:\n//\n//   testing::AssertionResult IsEven(const char* expr, int n) {\n//     if ((n % 2) == 0)\n//       return testing::AssertionSuccess();\n//     else\n//       return testing::AssertionFailure()\n//         << \"Expected: \" << expr << \" is even\\n  Actual: it's \" << n;\n//   }\n//\n// If Foo() returns 5, you will see the following message:\n//\n//   Expected: Foo() is even\n//     Actual: it's 5\n//\nclass GTEST_API_ AssertionResult {\n public:\n  // Copy constructor.\n  // Used in EXPECT_TRUE/FALSE(assertion_result).\n  AssertionResult(const AssertionResult& other);\n\n  GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 /* forcing value to bool */)\n\n  // Used in the EXPECT_TRUE/FALSE(bool_expression).\n  //\n  // T must be contextually convertible to bool.\n  //\n  // The second parameter prevents this overload from being considered if\n  // the argument is implicitly convertible to AssertionResult. In that case\n  // we want AssertionResult's copy constructor to be used.\n  template <typename T>\n  explicit AssertionResult(\n      const T& success,\n      typename internal::EnableIf<\n          !internal::ImplicitlyConvertible<T, AssertionResult>::value>::type*\n          /*enabler*/ = NULL)\n      : success_(success) {}\n\n  GTEST_DISABLE_MSC_WARNINGS_POP_()\n\n  // Assignment operator.\n  AssertionResult& operator=(AssertionResult other) {\n    swap(other);\n    return *this;\n  }\n\n  // Returns true iff the assertion succeeded.\n  operator bool() const { return success_; }  // NOLINT\n\n  // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.\n  AssertionResult operator!() const;\n\n  // Returns the text streamed into this AssertionResult. Test assertions\n  // use it when they fail (i.e., the predicate's outcome doesn't match the\n  // assertion's expectation). When nothing has been streamed into the\n  // object, returns an empty string.\n  const char* message() const {\n    return message_.get() != NULL ?  message_->c_str() : \"\";\n  }\n  // TODO(vladl@google.com): Remove this after making sure no clients use it.\n  // Deprecated; please use message() instead.\n  const char* failure_message() const { return message(); }\n\n  // Streams a custom failure message into this object.\n  template <typename T> AssertionResult& operator<<(const T& value) {\n    AppendMessage(Message() << value);\n    return *this;\n  }\n\n  // Allows streaming basic output manipulators such as endl or flush into\n  // this object.\n  AssertionResult& operator<<(\n      ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) {\n    AppendMessage(Message() << basic_manipulator);\n    return *this;\n  }\n\n private:\n  // Appends the contents of message to message_.\n  void AppendMessage(const Message& a_message) {\n    if (message_.get() == NULL)\n      message_.reset(new ::std::string);\n    message_->append(a_message.GetString().c_str());\n  }\n\n  // Swap the contents of this AssertionResult with other.\n  void swap(AssertionResult& other);\n\n  // Stores result of the assertion predicate.\n  bool success_;\n  // Stores the message describing the condition in case the expectation\n  // construct is not satisfied with the predicate's outcome.\n  // Referenced via a pointer to avoid taking too much stack frame space\n  // with test assertions.\n  internal::scoped_ptr< ::std::string> message_;\n};\n\n// Makes a successful assertion result.\nGTEST_API_ AssertionResult AssertionSuccess();\n\n// Makes a failed assertion result.\nGTEST_API_ AssertionResult AssertionFailure();\n\n// Makes a failed assertion result with the given failure message.\n// Deprecated; use AssertionFailure() << msg.\nGTEST_API_ AssertionResult AssertionFailure(const Message& msg);\n\n// The abstract class that all tests inherit from.\n//\n// In Google Test, a unit test program contains one or many TestCases, and\n// each TestCase contains one or many Tests.\n//\n// When you define a test using the TEST macro, you don't need to\n// explicitly derive from Test - the TEST macro automatically does\n// this for you.\n//\n// The only time you derive from Test is when defining a test fixture\n// to be used a TEST_F.  For example:\n//\n//   class FooTest : public testing::Test {\n//    protected:\n//     void SetUp() override { ... }\n//     void TearDown() override { ... }\n//     ...\n//   };\n//\n//   TEST_F(FooTest, Bar) { ... }\n//   TEST_F(FooTest, Baz) { ... }\n//\n// Test is not copyable.\nclass GTEST_API_ Test {\n public:\n  friend class TestInfo;\n\n  // Defines types for pointers to functions that set up and tear down\n  // a test case.\n  typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc;\n  typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc;\n\n  // The d'tor is virtual as we intend to inherit from Test.\n  virtual ~Test();\n\n  // Sets up the stuff shared by all tests in this test case.\n  //\n  // Google Test will call Foo::SetUpTestCase() before running the first\n  // test in test case Foo.  Hence a sub-class can define its own\n  // SetUpTestCase() method to shadow the one defined in the super\n  // class.\n  static void SetUpTestCase() {}\n\n  // Tears down the stuff shared by all tests in this test case.\n  //\n  // Google Test will call Foo::TearDownTestCase() after running the last\n  // test in test case Foo.  Hence a sub-class can define its own\n  // TearDownTestCase() method to shadow the one defined in the super\n  // class.\n  static void TearDownTestCase() {}\n\n  // Returns true iff the current test has a fatal failure.\n  static bool HasFatalFailure();\n\n  // Returns true iff the current test has a non-fatal failure.\n  static bool HasNonfatalFailure();\n\n  // Returns true iff the current test has a (either fatal or\n  // non-fatal) failure.\n  static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }\n\n  // Logs a property for the current test, test case, or for the entire\n  // invocation of the test program when used outside of the context of a\n  // test case.  Only the last value for a given key is remembered.  These\n  // are public static so they can be called from utility functions that are\n  // not members of the test fixture.  Calls to RecordProperty made during\n  // lifespan of the test (from the moment its constructor starts to the\n  // moment its destructor finishes) will be output in XML as attributes of\n  // the <testcase> element.  Properties recorded from fixture's\n  // SetUpTestCase or TearDownTestCase are logged as attributes of the\n  // corresponding <testsuite> element.  Calls to RecordProperty made in the\n  // global context (before or after invocation of RUN_ALL_TESTS and from\n  // SetUp/TearDown method of Environment objects registered with Google\n  // Test) will be output as attributes of the <testsuites> element.\n  static void RecordProperty(const std::string& key, const std::string& value);\n  static void RecordProperty(const std::string& key, int value);\n\n protected:\n  // Creates a Test object.\n  Test();\n\n  // Sets up the test fixture.\n  virtual void SetUp();\n\n  // Tears down the test fixture.\n  virtual void TearDown();\n\n private:\n  // Returns true iff the current test has the same fixture class as\n  // the first test in the current test case.\n  static bool HasSameFixtureClass();\n\n  // Runs the test after the test fixture has been set up.\n  //\n  // A sub-class must implement this to define the test logic.\n  //\n  // DO NOT OVERRIDE THIS FUNCTION DIRECTLY IN A USER PROGRAM.\n  // Instead, use the TEST or TEST_F macro.\n  virtual void TestBody() = 0;\n\n  // Sets up, executes, and tears down the test.\n  void Run();\n\n  // Deletes self.  We deliberately pick an unusual name for this\n  // internal method to avoid clashing with names used in user TESTs.\n  void DeleteSelf_() { delete this; }\n\n  const internal::scoped_ptr< GTEST_FLAG_SAVER_ > gtest_flag_saver_;\n\n  // Often a user misspells SetUp() as Setup() and spends a long time\n  // wondering why it is never called by Google Test.  The declaration of\n  // the following method is solely for catching such an error at\n  // compile time:\n  //\n  //   - The return type is deliberately chosen to be not void, so it\n  //   will be a conflict if void Setup() is declared in the user's\n  //   test fixture.\n  //\n  //   - This method is private, so it will be another compiler error\n  //   if the method is called from the user's test fixture.\n  //\n  // DO NOT OVERRIDE THIS FUNCTION.\n  //\n  // If you see an error about overriding the following function or\n  // about it being private, you have mis-spelled SetUp() as Setup().\n  struct Setup_should_be_spelled_SetUp {};\n  virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }\n\n  // We disallow copying Tests.\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);\n};\n\ntypedef internal::TimeInMillis TimeInMillis;\n\n// A copyable object representing a user specified test property which can be\n// output as a key/value string pair.\n//\n// Don't inherit from TestProperty as its destructor is not virtual.\nclass TestProperty {\n public:\n  // C'tor.  TestProperty does NOT have a default constructor.\n  // Always use this constructor (with parameters) to create a\n  // TestProperty object.\n  TestProperty(const std::string& a_key, const std::string& a_value) :\n    key_(a_key), value_(a_value) {\n  }\n\n  // Gets the user supplied key.\n  const char* key() const {\n    return key_.c_str();\n  }\n\n  // Gets the user supplied value.\n  const char* value() const {\n    return value_.c_str();\n  }\n\n  // Sets a new value, overriding the one supplied in the constructor.\n  void SetValue(const std::string& new_value) {\n    value_ = new_value;\n  }\n\n private:\n  // The key supplied by the user.\n  std::string key_;\n  // The value supplied by the user.\n  std::string value_;\n};\n\n// The result of a single Test.  This includes a list of\n// TestPartResults, a list of TestProperties, a count of how many\n// death tests there are in the Test, and how much time it took to run\n// the Test.\n//\n// TestResult is not copyable.\nclass GTEST_API_ TestResult {\n public:\n  // Creates an empty TestResult.\n  TestResult();\n\n  // D'tor.  Do not inherit from TestResult.\n  ~TestResult();\n\n  // Gets the number of all test parts.  This is the sum of the number\n  // of successful test parts and the number of failed test parts.\n  int total_part_count() const;\n\n  // Returns the number of the test properties.\n  int test_property_count() const;\n\n  // Returns true iff the test passed (i.e. no test part failed).\n  bool Passed() const { return !Failed(); }\n\n  // Returns true iff the test failed.\n  bool Failed() const;\n\n  // Returns true iff the test fatally failed.\n  bool HasFatalFailure() const;\n\n  // Returns true iff the test has a non-fatal failure.\n  bool HasNonfatalFailure() const;\n\n  // Returns the elapsed time, in milliseconds.\n  TimeInMillis elapsed_time() const { return elapsed_time_; }\n\n  // Returns the i-th test part result among all the results. i can range\n  // from 0 to test_property_count() - 1. If i is not in that range, aborts\n  // the program.\n  const TestPartResult& GetTestPartResult(int i) const;\n\n  // Returns the i-th test property. i can range from 0 to\n  // test_property_count() - 1. If i is not in that range, aborts the\n  // program.\n  const TestProperty& GetTestProperty(int i) const;\n\n private:\n  friend class TestInfo;\n  friend class TestCase;\n  friend class UnitTest;\n  friend class internal::DefaultGlobalTestPartResultReporter;\n  friend class internal::ExecDeathTest;\n  friend class internal::TestResultAccessor;\n  friend class internal::UnitTestImpl;\n  friend class internal::WindowsDeathTest;\n\n  // Gets the vector of TestPartResults.\n  const std::vector<TestPartResult>& test_part_results() const {\n    return test_part_results_;\n  }\n\n  // Gets the vector of TestProperties.\n  const std::vector<TestProperty>& test_properties() const {\n    return test_properties_;\n  }\n\n  // Sets the elapsed time.\n  void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; }\n\n  // Adds a test property to the list. The property is validated and may add\n  // a non-fatal failure if invalid (e.g., if it conflicts with reserved\n  // key names). If a property is already recorded for the same key, the\n  // value will be updated, rather than storing multiple values for the same\n  // key.  xml_element specifies the element for which the property is being\n  // recorded and is used for validation.\n  void RecordProperty(const std::string& xml_element,\n                      const TestProperty& test_property);\n\n  // Adds a failure if the key is a reserved attribute of Google Test\n  // testcase tags.  Returns true if the property is valid.\n  // TODO(russr): Validate attribute names are legal and human readable.\n  static bool ValidateTestProperty(const std::string& xml_element,\n                                   const TestProperty& test_property);\n\n  // Adds a test part result to the list.\n  void AddTestPartResult(const TestPartResult& test_part_result);\n\n  // Returns the death test count.\n  int death_test_count() const { return death_test_count_; }\n\n  // Increments the death test count, returning the new count.\n  int increment_death_test_count() { return ++death_test_count_; }\n\n  // Clears the test part results.\n  void ClearTestPartResults();\n\n  // Clears the object.\n  void Clear();\n\n  // Protects mutable state of the property vector and of owned\n  // properties, whose values may be updated.\n  internal::Mutex test_properites_mutex_;\n\n  // The vector of TestPartResults\n  std::vector<TestPartResult> test_part_results_;\n  // The vector of TestProperties\n  std::vector<TestProperty> test_properties_;\n  // Running count of death tests.\n  int death_test_count_;\n  // The elapsed time, in milliseconds.\n  TimeInMillis elapsed_time_;\n\n  // We disallow copying TestResult.\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult);\n};  // class TestResult\n\n// A TestInfo object stores the following information about a test:\n//\n//   Test case name\n//   Test name\n//   Whether the test should be run\n//   A function pointer that creates the test object when invoked\n//   Test result\n//\n// The constructor of TestInfo registers itself with the UnitTest\n// singleton such that the RUN_ALL_TESTS() macro knows which tests to\n// run.\nclass GTEST_API_ TestInfo {\n public:\n  // Destructs a TestInfo object.  This function is not virtual, so\n  // don't inherit from TestInfo.\n  ~TestInfo();\n\n  // Returns the test case name.\n  const char* test_case_name() const { return test_case_name_.c_str(); }\n\n  // Returns the test name.\n  const char* name() const { return name_.c_str(); }\n\n  // Returns the name of the parameter type, or NULL if this is not a typed\n  // or a type-parameterized test.\n  const char* type_param() const {\n    if (type_param_.get() != NULL)\n      return type_param_->c_str();\n    return NULL;\n  }\n\n  // Returns the text representation of the value parameter, or NULL if this\n  // is not a value-parameterized test.\n  const char* value_param() const {\n    if (value_param_.get() != NULL)\n      return value_param_->c_str();\n    return NULL;\n  }\n\n  // Returns the file name where this test is defined.\n  const char* file() const { return location_.file.c_str(); }\n\n  // Returns the line where this test is defined.\n  int line() const { return location_.line; }\n\n  // Returns true if this test should run, that is if the test is not\n  // disabled (or it is disabled but the also_run_disabled_tests flag has\n  // been specified) and its full name matches the user-specified filter.\n  //\n  // Google Test allows the user to filter the tests by their full names.\n  // The full name of a test Bar in test case Foo is defined as\n  // \"Foo.Bar\".  Only the tests that match the filter will run.\n  //\n  // A filter is a colon-separated list of glob (not regex) patterns,\n  // optionally followed by a '-' and a colon-separated list of\n  // negative patterns (tests to exclude).  A test is run if it\n  // matches one of the positive patterns and does not match any of\n  // the negative patterns.\n  //\n  // For example, *A*:Foo.* is a filter that matches any string that\n  // contains the character 'A' or starts with \"Foo.\".\n  bool should_run() const { return should_run_; }\n\n  // Returns true iff this test will appear in the XML report.\n  bool is_reportable() const {\n    // For now, the XML report includes all tests matching the filter.\n    // In the future, we may trim tests that are excluded because of\n    // sharding.\n    return matches_filter_;\n  }\n\n  // Returns the result of the test.\n  const TestResult* result() const { return &result_; }\n\n private:\n#if GTEST_HAS_DEATH_TEST\n  friend class internal::DefaultDeathTestFactory;\n#endif  // GTEST_HAS_DEATH_TEST\n  friend class Test;\n  friend class TestCase;\n  friend class internal::UnitTestImpl;\n  friend class internal::StreamingListenerTest;\n  friend TestInfo* internal::MakeAndRegisterTestInfo(\n      const char* test_case_name,\n      const char* name,\n      const char* type_param,\n      const char* value_param,\n      internal::CodeLocation code_location,\n      internal::TypeId fixture_class_id,\n      Test::SetUpTestCaseFunc set_up_tc,\n      Test::TearDownTestCaseFunc tear_down_tc,\n      internal::TestFactoryBase* factory);\n\n  // Constructs a TestInfo object. The newly constructed instance assumes\n  // ownership of the factory object.\n  TestInfo(const std::string& test_case_name,\n           const std::string& name,\n           const char* a_type_param,   // NULL if not a type-parameterized test\n           const char* a_value_param,  // NULL if not a value-parameterized test\n           internal::CodeLocation a_code_location,\n           internal::TypeId fixture_class_id,\n           internal::TestFactoryBase* factory);\n\n  // Increments the number of death tests encountered in this test so\n  // far.\n  int increment_death_test_count() {\n    return result_.increment_death_test_count();\n  }\n\n  // Creates the test object, runs it, records its result, and then\n  // deletes it.\n  void Run();\n\n  static void ClearTestResult(TestInfo* test_info) {\n    test_info->result_.Clear();\n  }\n\n  // These fields are immutable properties of the test.\n  const std::string test_case_name_;     // Test case name\n  const std::string name_;               // Test name\n  // Name of the parameter type, or NULL if this is not a typed or a\n  // type-parameterized test.\n  const internal::scoped_ptr<const ::std::string> type_param_;\n  // Text representation of the value parameter, or NULL if this is not a\n  // value-parameterized test.\n  const internal::scoped_ptr<const ::std::string> value_param_;\n  internal::CodeLocation location_;\n  const internal::TypeId fixture_class_id_;   // ID of the test fixture class\n  bool should_run_;                 // True iff this test should run\n  bool is_disabled_;                // True iff this test is disabled\n  bool matches_filter_;             // True if this test matches the\n                                    // user-specified filter.\n  internal::TestFactoryBase* const factory_;  // The factory that creates\n                                              // the test object\n\n  // This field is mutable and needs to be reset before running the\n  // test for the second time.\n  TestResult result_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);\n};\n\n// A test case, which consists of a vector of TestInfos.\n//\n// TestCase is not copyable.\nclass GTEST_API_ TestCase {\n public:\n  // Creates a TestCase with the given name.\n  //\n  // TestCase does NOT have a default constructor.  Always use this\n  // constructor to create a TestCase object.\n  //\n  // Arguments:\n  //\n  //   name:         name of the test case\n  //   a_type_param: the name of the test's type parameter, or NULL if\n  //                 this is not a type-parameterized test.\n  //   set_up_tc:    pointer to the function that sets up the test case\n  //   tear_down_tc: pointer to the function that tears down the test case\n  TestCase(const char* name, const char* a_type_param,\n           Test::SetUpTestCaseFunc set_up_tc,\n           Test::TearDownTestCaseFunc tear_down_tc);\n\n  // Destructor of TestCase.\n  virtual ~TestCase();\n\n  // Gets the name of the TestCase.\n  const char* name() const { return name_.c_str(); }\n\n  // Returns the name of the parameter type, or NULL if this is not a\n  // type-parameterized test case.\n  const char* type_param() const {\n    if (type_param_.get() != NULL)\n      return type_param_->c_str();\n    return NULL;\n  }\n\n  // Returns true if any test in this test case should run.\n  bool should_run() const { return should_run_; }\n\n  // Gets the number of successful tests in this test case.\n  int successful_test_count() const;\n\n  // Gets the number of failed tests in this test case.\n  int failed_test_count() const;\n\n  // Gets the number of disabled tests that will be reported in the XML report.\n  int reportable_disabled_test_count() const;\n\n  // Gets the number of disabled tests in this test case.\n  int disabled_test_count() const;\n\n  // Gets the number of tests to be printed in the XML report.\n  int reportable_test_count() const;\n\n  // Get the number of tests in this test case that should run.\n  int test_to_run_count() const;\n\n  // Gets the number of all tests in this test case.\n  int total_test_count() const;\n\n  // Returns true iff the test case passed.\n  bool Passed() const { return !Failed(); }\n\n  // Returns true iff the test case failed.\n  bool Failed() const { return failed_test_count() > 0; }\n\n  // Returns the elapsed time, in milliseconds.\n  TimeInMillis elapsed_time() const { return elapsed_time_; }\n\n  // Returns the i-th test among all the tests. i can range from 0 to\n  // total_test_count() - 1. If i is not in that range, returns NULL.\n  const TestInfo* GetTestInfo(int i) const;\n\n  // Returns the TestResult that holds test properties recorded during\n  // execution of SetUpTestCase and TearDownTestCase.\n  const TestResult& ad_hoc_test_result() const { return ad_hoc_test_result_; }\n\n private:\n  friend class Test;\n  friend class internal::UnitTestImpl;\n\n  // Gets the (mutable) vector of TestInfos in this TestCase.\n  std::vector<TestInfo*>& test_info_list() { return test_info_list_; }\n\n  // Gets the (immutable) vector of TestInfos in this TestCase.\n  const std::vector<TestInfo*>& test_info_list() const {\n    return test_info_list_;\n  }\n\n  // Returns the i-th test among all the tests. i can range from 0 to\n  // total_test_count() - 1. If i is not in that range, returns NULL.\n  TestInfo* GetMutableTestInfo(int i);\n\n  // Sets the should_run member.\n  void set_should_run(bool should) { should_run_ = should; }\n\n  // Adds a TestInfo to this test case.  Will delete the TestInfo upon\n  // destruction of the TestCase object.\n  void AddTestInfo(TestInfo * test_info);\n\n  // Clears the results of all tests in this test case.\n  void ClearResult();\n\n  // Clears the results of all tests in the given test case.\n  static void ClearTestCaseResult(TestCase* test_case) {\n    test_case->ClearResult();\n  }\n\n  // Runs every test in this TestCase.\n  void Run();\n\n  // Runs SetUpTestCase() for this TestCase.  This wrapper is needed\n  // for catching exceptions thrown from SetUpTestCase().\n  void RunSetUpTestCase() { (*set_up_tc_)(); }\n\n  // Runs TearDownTestCase() for this TestCase.  This wrapper is\n  // needed for catching exceptions thrown from TearDownTestCase().\n  void RunTearDownTestCase() { (*tear_down_tc_)(); }\n\n  // Returns true iff test passed.\n  static bool TestPassed(const TestInfo* test_info) {\n    return test_info->should_run() && test_info->result()->Passed();\n  }\n\n  // Returns true iff test failed.\n  static bool TestFailed(const TestInfo* test_info) {\n    return test_info->should_run() && test_info->result()->Failed();\n  }\n\n  // Returns true iff the test is disabled and will be reported in the XML\n  // report.\n  static bool TestReportableDisabled(const TestInfo* test_info) {\n    return test_info->is_reportable() && test_info->is_disabled_;\n  }\n\n  // Returns true iff test is disabled.\n  static bool TestDisabled(const TestInfo* test_info) {\n    return test_info->is_disabled_;\n  }\n\n  // Returns true iff this test will appear in the XML report.\n  static bool TestReportable(const TestInfo* test_info) {\n    return test_info->is_reportable();\n  }\n\n  // Returns true if the given test should run.\n  static bool ShouldRunTest(const TestInfo* test_info) {\n    return test_info->should_run();\n  }\n\n  // Shuffles the tests in this test case.\n  void ShuffleTests(internal::Random* random);\n\n  // Restores the test order to before the first shuffle.\n  void UnshuffleTests();\n\n  // Name of the test case.\n  std::string name_;\n  // Name of the parameter type, or NULL if this is not a typed or a\n  // type-parameterized test.\n  const internal::scoped_ptr<const ::std::string> type_param_;\n  // The vector of TestInfos in their original order.  It owns the\n  // elements in the vector.\n  std::vector<TestInfo*> test_info_list_;\n  // Provides a level of indirection for the test list to allow easy\n  // shuffling and restoring the test order.  The i-th element in this\n  // vector is the index of the i-th test in the shuffled test list.\n  std::vector<int> test_indices_;\n  // Pointer to the function that sets up the test case.\n  Test::SetUpTestCaseFunc set_up_tc_;\n  // Pointer to the function that tears down the test case.\n  Test::TearDownTestCaseFunc tear_down_tc_;\n  // True iff any test in this test case should run.\n  bool should_run_;\n  // Elapsed time, in milliseconds.\n  TimeInMillis elapsed_time_;\n  // Holds test properties recorded during execution of SetUpTestCase and\n  // TearDownTestCase.\n  TestResult ad_hoc_test_result_;\n\n  // We disallow copying TestCases.\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestCase);\n};\n\n// An Environment object is capable of setting up and tearing down an\n// environment.  You should subclass this to define your own\n// environment(s).\n//\n// An Environment object does the set-up and tear-down in virtual\n// methods SetUp() and TearDown() instead of the constructor and the\n// destructor, as:\n//\n//   1. You cannot safely throw from a destructor.  This is a problem\n//      as in some cases Google Test is used where exceptions are enabled, and\n//      we may want to implement ASSERT_* using exceptions where they are\n//      available.\n//   2. You cannot use ASSERT_* directly in a constructor or\n//      destructor.\nclass Environment {\n public:\n  // The d'tor is virtual as we need to subclass Environment.\n  virtual ~Environment() {}\n\n  // Override this to define how to set up the environment.\n  virtual void SetUp() {}\n\n  // Override this to define how to tear down the environment.\n  virtual void TearDown() {}\n private:\n  // If you see an error about overriding the following function or\n  // about it being private, you have mis-spelled SetUp() as Setup().\n  struct Setup_should_be_spelled_SetUp {};\n  virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }\n};\n\n// The interface for tracing execution of tests. The methods are organized in\n// the order the corresponding events are fired.\nclass TestEventListener {\n public:\n  virtual ~TestEventListener() {}\n\n  // Fired before any test activity starts.\n  virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;\n\n  // Fired before each iteration of tests starts.  There may be more than\n  // one iteration if GTEST_FLAG(repeat) is set. iteration is the iteration\n  // index, starting from 0.\n  virtual void OnTestIterationStart(const UnitTest& unit_test,\n                                    int iteration) = 0;\n\n  // Fired before environment set-up for each iteration of tests starts.\n  virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0;\n\n  // Fired after environment set-up for each iteration of tests ends.\n  virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0;\n\n  // Fired before the test case starts.\n  virtual void OnTestCaseStart(const TestCase& test_case) = 0;\n\n  // Fired before the test starts.\n  virtual void OnTestStart(const TestInfo& test_info) = 0;\n\n  // Fired after a failed assertion or a SUCCEED() invocation.\n  virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;\n\n  // Fired after the test ends.\n  virtual void OnTestEnd(const TestInfo& test_info) = 0;\n\n  // Fired after the test case ends.\n  virtual void OnTestCaseEnd(const TestCase& test_case) = 0;\n\n  // Fired before environment tear-down for each iteration of tests starts.\n  virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0;\n\n  // Fired after environment tear-down for each iteration of tests ends.\n  virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0;\n\n  // Fired after each iteration of tests finishes.\n  virtual void OnTestIterationEnd(const UnitTest& unit_test,\n                                  int iteration) = 0;\n\n  // Fired after all test activities have ended.\n  virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0;\n};\n\n// The convenience class for users who need to override just one or two\n// methods and are not concerned that a possible change to a signature of\n// the methods they override will not be caught during the build.  For\n// comments about each method please see the definition of TestEventListener\n// above.\nclass EmptyTestEventListener : public TestEventListener {\n public:\n  virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}\n  virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,\n                                    int /*iteration*/) {}\n  virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) {}\n  virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}\n  virtual void OnTestCaseStart(const TestCase& /*test_case*/) {}\n  virtual void OnTestStart(const TestInfo& /*test_info*/) {}\n  virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) {}\n  virtual void OnTestEnd(const TestInfo& /*test_info*/) {}\n  virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {}\n  virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {}\n  virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}\n  virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,\n                                  int /*iteration*/) {}\n  virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}\n};\n\n// TestEventListeners lets users add listeners to track events in Google Test.\nclass GTEST_API_ TestEventListeners {\n public:\n  TestEventListeners();\n  ~TestEventListeners();\n\n  // Appends an event listener to the end of the list. Google Test assumes\n  // the ownership of the listener (i.e. it will delete the listener when\n  // the test program finishes).\n  void Append(TestEventListener* listener);\n\n  // Removes the given event listener from the list and returns it.  It then\n  // becomes the caller's responsibility to delete the listener. Returns\n  // NULL if the listener is not found in the list.\n  TestEventListener* Release(TestEventListener* listener);\n\n  // Returns the standard listener responsible for the default console\n  // output.  Can be removed from the listeners list to shut down default\n  // console output.  Note that removing this object from the listener list\n  // with Release transfers its ownership to the caller and makes this\n  // function return NULL the next time.\n  TestEventListener* default_result_printer() const {\n    return default_result_printer_;\n  }\n\n  // Returns the standard listener responsible for the default XML output\n  // controlled by the --gtest_output=xml flag.  Can be removed from the\n  // listeners list by users who want to shut down the default XML output\n  // controlled by this flag and substitute it with custom one.  Note that\n  // removing this object from the listener list with Release transfers its\n  // ownership to the caller and makes this function return NULL the next\n  // time.\n  TestEventListener* default_xml_generator() const {\n    return default_xml_generator_;\n  }\n\n private:\n  friend class TestCase;\n  friend class TestInfo;\n  friend class internal::DefaultGlobalTestPartResultReporter;\n  friend class internal::NoExecDeathTest;\n  friend class internal::TestEventListenersAccessor;\n  friend class internal::UnitTestImpl;\n\n  // Returns repeater that broadcasts the TestEventListener events to all\n  // subscribers.\n  TestEventListener* repeater();\n\n  // Sets the default_result_printer attribute to the provided listener.\n  // The listener is also added to the listener list and previous\n  // default_result_printer is removed from it and deleted. The listener can\n  // also be NULL in which case it will not be added to the list. Does\n  // nothing if the previous and the current listener objects are the same.\n  void SetDefaultResultPrinter(TestEventListener* listener);\n\n  // Sets the default_xml_generator attribute to the provided listener.  The\n  // listener is also added to the listener list and previous\n  // default_xml_generator is removed from it and deleted. The listener can\n  // also be NULL in which case it will not be added to the list. Does\n  // nothing if the previous and the current listener objects are the same.\n  void SetDefaultXmlGenerator(TestEventListener* listener);\n\n  // Controls whether events will be forwarded by the repeater to the\n  // listeners in the list.\n  bool EventForwardingEnabled() const;\n  void SuppressEventForwarding();\n\n  // The actual list of listeners.\n  internal::TestEventRepeater* repeater_;\n  // Listener responsible for the standard result output.\n  TestEventListener* default_result_printer_;\n  // Listener responsible for the creation of the XML output file.\n  TestEventListener* default_xml_generator_;\n\n  // We disallow copying TestEventListeners.\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners);\n};\n\n// A UnitTest consists of a vector of TestCases.\n//\n// This is a singleton class.  The only instance of UnitTest is\n// created when UnitTest::GetInstance() is first called.  This\n// instance is never deleted.\n//\n// UnitTest is not copyable.\n//\n// This class is thread-safe as long as the methods are called\n// according to their specification.\nclass GTEST_API_ UnitTest {\n public:\n  // Gets the singleton UnitTest object.  The first time this method\n  // is called, a UnitTest object is constructed and returned.\n  // Consecutive calls will return the same object.\n  static UnitTest* GetInstance();\n\n  // Runs all tests in this UnitTest object and prints the result.\n  // Returns 0 if successful, or 1 otherwise.\n  //\n  // This method can only be called from the main thread.\n  //\n  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n  int Run() GTEST_MUST_USE_RESULT_;\n\n  // Returns the working directory when the first TEST() or TEST_F()\n  // was executed.  The UnitTest object owns the string.\n  const char* original_working_dir() const;\n\n  // Returns the TestCase object for the test that's currently running,\n  // or NULL if no test is running.\n  const TestCase* current_test_case() const\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // Returns the TestInfo object for the test that's currently running,\n  // or NULL if no test is running.\n  const TestInfo* current_test_info() const\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // Returns the random seed used at the start of the current test run.\n  int random_seed() const;\n\n#if GTEST_HAS_PARAM_TEST\n  // Returns the ParameterizedTestCaseRegistry object used to keep track of\n  // value-parameterized tests and instantiate and register them.\n  //\n  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n  internal::ParameterizedTestCaseRegistry& parameterized_test_registry()\n      GTEST_LOCK_EXCLUDED_(mutex_);\n#endif  // GTEST_HAS_PARAM_TEST\n\n  // Gets the number of successful test cases.\n  int successful_test_case_count() const;\n\n  // Gets the number of failed test cases.\n  int failed_test_case_count() const;\n\n  // Gets the number of all test cases.\n  int total_test_case_count() const;\n\n  // Gets the number of all test cases that contain at least one test\n  // that should run.\n  int test_case_to_run_count() const;\n\n  // Gets the number of successful tests.\n  int successful_test_count() const;\n\n  // Gets the number of failed tests.\n  int failed_test_count() const;\n\n  // Gets the number of disabled tests that will be reported in the XML report.\n  int reportable_disabled_test_count() const;\n\n  // Gets the number of disabled tests.\n  int disabled_test_count() const;\n\n  // Gets the number of tests to be printed in the XML report.\n  int reportable_test_count() const;\n\n  // Gets the number of all tests.\n  int total_test_count() const;\n\n  // Gets the number of tests that should run.\n  int test_to_run_count() const;\n\n  // Gets the time of the test program start, in ms from the start of the\n  // UNIX epoch.\n  TimeInMillis start_timestamp() const;\n\n  // Gets the elapsed time, in milliseconds.\n  TimeInMillis elapsed_time() const;\n\n  // Returns true iff the unit test passed (i.e. all test cases passed).\n  bool Passed() const;\n\n  // Returns true iff the unit test failed (i.e. some test case failed\n  // or something outside of all tests failed).\n  bool Failed() const;\n\n  // Gets the i-th test case among all the test cases. i can range from 0 to\n  // total_test_case_count() - 1. If i is not in that range, returns NULL.\n  const TestCase* GetTestCase(int i) const;\n\n  // Returns the TestResult containing information on test failures and\n  // properties logged outside of individual test cases.\n  const TestResult& ad_hoc_test_result() const;\n\n  // Returns the list of event listeners that can be used to track events\n  // inside Google Test.\n  TestEventListeners& listeners();\n\n private:\n  // Registers and returns a global test environment.  When a test\n  // program is run, all global test environments will be set-up in\n  // the order they were registered.  After all tests in the program\n  // have finished, all global test environments will be torn-down in\n  // the *reverse* order they were registered.\n  //\n  // The UnitTest object takes ownership of the given environment.\n  //\n  // This method can only be called from the main thread.\n  Environment* AddEnvironment(Environment* env);\n\n  // Adds a TestPartResult to the current TestResult object.  All\n  // Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc)\n  // eventually call this to report their results.  The user code\n  // should use the assertion macros instead of calling this directly.\n  void AddTestPartResult(TestPartResult::Type result_type,\n                         const char* file_name,\n                         int line_number,\n                         const std::string& message,\n                         const std::string& os_stack_trace)\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // Adds a TestProperty to the current TestResult object when invoked from\n  // inside a test, to current TestCase's ad_hoc_test_result_ when invoked\n  // from SetUpTestCase or TearDownTestCase, or to the global property set\n  // when invoked elsewhere.  If the result already contains a property with\n  // the same key, the value will be updated.\n  void RecordProperty(const std::string& key, const std::string& value);\n\n  // Gets the i-th test case among all the test cases. i can range from 0 to\n  // total_test_case_count() - 1. If i is not in that range, returns NULL.\n  TestCase* GetMutableTestCase(int i);\n\n  // Accessors for the implementation object.\n  internal::UnitTestImpl* impl() { return impl_; }\n  const internal::UnitTestImpl* impl() const { return impl_; }\n\n  // These classes and funcions are friends as they need to access private\n  // members of UnitTest.\n  friend class Test;\n  friend class internal::AssertHelper;\n  friend class internal::ScopedTrace;\n  friend class internal::StreamingListenerTest;\n  friend class internal::UnitTestRecordPropertyTestHelper;\n  friend Environment* AddGlobalTestEnvironment(Environment* env);\n  friend internal::UnitTestImpl* internal::GetUnitTestImpl();\n  friend void internal::ReportFailureInUnknownLocation(\n      TestPartResult::Type result_type,\n      const std::string& message);\n\n  // Creates an empty UnitTest.\n  UnitTest();\n\n  // D'tor\n  virtual ~UnitTest();\n\n  // Pushes a trace defined by SCOPED_TRACE() on to the per-thread\n  // Google Test trace stack.\n  void PushGTestTrace(const internal::TraceInfo& trace)\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // Pops a trace from the per-thread Google Test trace stack.\n  void PopGTestTrace()\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // Protects mutable state in *impl_.  This is mutable as some const\n  // methods need to lock it too.\n  mutable internal::Mutex mutex_;\n\n  // Opaque implementation object.  This field is never changed once\n  // the object is constructed.  We don't mark it as const here, as\n  // doing so will cause a warning in the constructor of UnitTest.\n  // Mutable state in *impl_ is protected by mutex_.\n  internal::UnitTestImpl* impl_;\n\n  // We disallow copying UnitTest.\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest);\n};\n\n// A convenient wrapper for adding an environment for the test\n// program.\n//\n// You should call this before RUN_ALL_TESTS() is called, probably in\n// main().  If you use gtest_main, you need to call this before main()\n// starts for it to take effect.  For example, you can define a global\n// variable like this:\n//\n//   testing::Environment* const foo_env =\n//       testing::AddGlobalTestEnvironment(new FooEnvironment);\n//\n// However, we strongly recommend you to write your own main() and\n// call AddGlobalTestEnvironment() there, as relying on initialization\n// of global variables makes the code harder to read and may cause\n// problems when you register multiple environments from different\n// translation units and the environments have dependencies among them\n// (remember that the compiler doesn't guarantee the order in which\n// global variables from different translation units are initialized).\ninline Environment* AddGlobalTestEnvironment(Environment* env) {\n  return UnitTest::GetInstance()->AddEnvironment(env);\n}\n\n// Initializes Google Test.  This must be called before calling\n// RUN_ALL_TESTS().  In particular, it parses a command line for the\n// flags that Google Test recognizes.  Whenever a Google Test flag is\n// seen, it is removed from argv, and *argc is decremented.\n//\n// No value is returned.  Instead, the Google Test flag variables are\n// updated.\n//\n// Calling the function for the second time has no user-visible effect.\nGTEST_API_ void InitGoogleTest(int* argc, char** argv);\n\n// This overloaded version can be used in Windows programs compiled in\n// UNICODE mode.\nGTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv);\n\nnamespace internal {\n\n// Separate the error generating code from the code path to reduce the stack\n// frame size of CmpHelperEQ. This helps reduce the overhead of some sanitizers\n// when calling EXPECT_* in a tight loop.\ntemplate <typename T1, typename T2>\nAssertionResult CmpHelperEQFailure(const char* lhs_expression,\n                                   const char* rhs_expression,\n                                   const T1& lhs, const T2& rhs) {\n  return EqFailure(lhs_expression,\n                   rhs_expression,\n                   FormatForComparisonFailureMessage(lhs, rhs),\n                   FormatForComparisonFailureMessage(rhs, lhs),\n                   false);\n}\n\n// The helper function for {ASSERT|EXPECT}_EQ.\ntemplate <typename T1, typename T2>\nAssertionResult CmpHelperEQ(const char* lhs_expression,\n                            const char* rhs_expression,\n                            const T1& lhs,\n                            const T2& rhs) {\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(4389 /* signed/unsigned mismatch */)\n  if (lhs == rhs) {\n    return AssertionSuccess();\n  }\nGTEST_DISABLE_MSC_WARNINGS_POP_()\n\n  return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);\n}\n\n// With this overloaded version, we allow anonymous enums to be used\n// in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums\n// can be implicitly cast to BiggestInt.\nGTEST_API_ AssertionResult CmpHelperEQ(const char* lhs_expression,\n                                       const char* rhs_expression,\n                                       BiggestInt lhs,\n                                       BiggestInt rhs);\n\n// The helper class for {ASSERT|EXPECT}_EQ.  The template argument\n// lhs_is_null_literal is true iff the first argument to ASSERT_EQ()\n// is a null pointer literal.  The following default implementation is\n// for lhs_is_null_literal being false.\ntemplate <bool lhs_is_null_literal>\nclass EqHelper {\n public:\n  // This templatized version is for the general case.\n  template <typename T1, typename T2>\n  static AssertionResult Compare(const char* lhs_expression,\n                                 const char* rhs_expression,\n                                 const T1& lhs,\n                                 const T2& rhs) {\n    return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);\n  }\n\n  // With this overloaded version, we allow anonymous enums to be used\n  // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous\n  // enums can be implicitly cast to BiggestInt.\n  //\n  // Even though its body looks the same as the above version, we\n  // cannot merge the two, as it will make anonymous enums unhappy.\n  static AssertionResult Compare(const char* lhs_expression,\n                                 const char* rhs_expression,\n                                 BiggestInt lhs,\n                                 BiggestInt rhs) {\n    return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);\n  }\n};\n\n// This specialization is used when the first argument to ASSERT_EQ()\n// is a null pointer literal, like NULL, false, or 0.\ntemplate <>\nclass EqHelper<true> {\n public:\n  // We define two overloaded versions of Compare().  The first\n  // version will be picked when the second argument to ASSERT_EQ() is\n  // NOT a pointer, e.g. ASSERT_EQ(0, AnIntFunction()) or\n  // EXPECT_EQ(false, a_bool).\n  template <typename T1, typename T2>\n  static AssertionResult Compare(\n      const char* lhs_expression,\n      const char* rhs_expression,\n      const T1& lhs,\n      const T2& rhs,\n      // The following line prevents this overload from being considered if T2\n      // is not a pointer type.  We need this because ASSERT_EQ(NULL, my_ptr)\n      // expands to Compare(\"\", \"\", NULL, my_ptr), which requires a conversion\n      // to match the Secret* in the other overload, which would otherwise make\n      // this template match better.\n      typename EnableIf<!is_pointer<T2>::value>::type* = 0) {\n    return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);\n  }\n\n  // This version will be picked when the second argument to ASSERT_EQ() is a\n  // pointer, e.g. ASSERT_EQ(NULL, a_pointer).\n  template <typename T>\n  static AssertionResult Compare(\n      const char* lhs_expression,\n      const char* rhs_expression,\n      // We used to have a second template parameter instead of Secret*.  That\n      // template parameter would deduce to 'long', making this a better match\n      // than the first overload even without the first overload's EnableIf.\n      // Unfortunately, gcc with -Wconversion-null warns when \"passing NULL to\n      // non-pointer argument\" (even a deduced integral argument), so the old\n      // implementation caused warnings in user code.\n      Secret* /* lhs (NULL) */,\n      T* rhs) {\n    // We already know that 'lhs' is a null pointer.\n    return CmpHelperEQ(lhs_expression, rhs_expression,\n                       static_cast<T*>(NULL), rhs);\n  }\n};\n\n// Separate the error generating code from the code path to reduce the stack\n// frame size of CmpHelperOP. This helps reduce the overhead of some sanitizers\n// when calling EXPECT_OP in a tight loop.\ntemplate <typename T1, typename T2>\nAssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2,\n                                   const T1& val1, const T2& val2,\n                                   const char* op) {\n  return AssertionFailure()\n         << \"Expected: (\" << expr1 << \") \" << op << \" (\" << expr2\n         << \"), actual: \" << FormatForComparisonFailureMessage(val1, val2)\n         << \" vs \" << FormatForComparisonFailureMessage(val2, val1);\n}\n\n// A macro for implementing the helper functions needed to implement\n// ASSERT_?? and EXPECT_??.  It is here just to avoid copy-and-paste\n// of similar code.\n//\n// For each templatized helper function, we also define an overloaded\n// version for BiggestInt in order to reduce code bloat and allow\n// anonymous enums to be used with {ASSERT|EXPECT}_?? when compiled\n// with gcc 4.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n\n#define GTEST_IMPL_CMP_HELPER_(op_name, op)\\\ntemplate <typename T1, typename T2>\\\nAssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \\\n                                   const T1& val1, const T2& val2) {\\\n  if (val1 op val2) {\\\n    return AssertionSuccess();\\\n  } else {\\\n    return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\\\n  }\\\n}\\\nGTEST_API_ AssertionResult CmpHelper##op_name(\\\n    const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2)\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n\n// Implements the helper function for {ASSERT|EXPECT}_NE\nGTEST_IMPL_CMP_HELPER_(NE, !=);\n// Implements the helper function for {ASSERT|EXPECT}_LE\nGTEST_IMPL_CMP_HELPER_(LE, <=);\n// Implements the helper function for {ASSERT|EXPECT}_LT\nGTEST_IMPL_CMP_HELPER_(LT, <);\n// Implements the helper function for {ASSERT|EXPECT}_GE\nGTEST_IMPL_CMP_HELPER_(GE, >=);\n// Implements the helper function for {ASSERT|EXPECT}_GT\nGTEST_IMPL_CMP_HELPER_(GT, >);\n\n#undef GTEST_IMPL_CMP_HELPER_\n\n// The helper function for {ASSERT|EXPECT}_STREQ.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,\n                                          const char* s2_expression,\n                                          const char* s1,\n                                          const char* s2);\n\n// The helper function for {ASSERT|EXPECT}_STRCASEEQ.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* s1_expression,\n                                              const char* s2_expression,\n                                              const char* s1,\n                                              const char* s2);\n\n// The helper function for {ASSERT|EXPECT}_STRNE.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,\n                                          const char* s2_expression,\n                                          const char* s1,\n                                          const char* s2);\n\n// The helper function for {ASSERT|EXPECT}_STRCASENE.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression,\n                                              const char* s2_expression,\n                                              const char* s1,\n                                              const char* s2);\n\n\n// Helper function for *_STREQ on wide strings.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,\n                                          const char* s2_expression,\n                                          const wchar_t* s1,\n                                          const wchar_t* s2);\n\n// Helper function for *_STRNE on wide strings.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,\n                                          const char* s2_expression,\n                                          const wchar_t* s1,\n                                          const wchar_t* s2);\n\n}  // namespace internal\n\n// IsSubstring() and IsNotSubstring() are intended to be used as the\n// first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by\n// themselves.  They check whether needle is a substring of haystack\n// (NULL is considered a substring of itself only), and return an\n// appropriate error message when they fail.\n//\n// The {needle,haystack}_expr arguments are the stringified\n// expressions that generated the two real arguments.\nGTEST_API_ AssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const char* needle, const char* haystack);\nGTEST_API_ AssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const wchar_t* needle, const wchar_t* haystack);\nGTEST_API_ AssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const char* needle, const char* haystack);\nGTEST_API_ AssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const wchar_t* needle, const wchar_t* haystack);\nGTEST_API_ AssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::string& needle, const ::std::string& haystack);\nGTEST_API_ AssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::string& needle, const ::std::string& haystack);\n\n#if GTEST_HAS_STD_WSTRING\nGTEST_API_ AssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::wstring& needle, const ::std::wstring& haystack);\nGTEST_API_ AssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::wstring& needle, const ::std::wstring& haystack);\n#endif  // GTEST_HAS_STD_WSTRING\n\nnamespace internal {\n\n// Helper template function for comparing floating-points.\n//\n// Template parameter:\n//\n//   RawType: the raw floating-point type (either float or double)\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\ntemplate <typename RawType>\nAssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,\n                                         const char* rhs_expression,\n                                         RawType lhs_value,\n                                         RawType rhs_value) {\n  const FloatingPoint<RawType> lhs(lhs_value), rhs(rhs_value);\n\n  if (lhs.AlmostEquals(rhs)) {\n    return AssertionSuccess();\n  }\n\n  ::std::stringstream lhs_ss;\n  lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)\n         << lhs_value;\n\n  ::std::stringstream rhs_ss;\n  rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)\n         << rhs_value;\n\n  return EqFailure(lhs_expression,\n                   rhs_expression,\n                   StringStreamToString(&lhs_ss),\n                   StringStreamToString(&rhs_ss),\n                   false);\n}\n\n// Helper function for implementing ASSERT_NEAR.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1,\n                                                const char* expr2,\n                                                const char* abs_error_expr,\n                                                double val1,\n                                                double val2,\n                                                double abs_error);\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n// A class that enables one to stream messages to assertion macros\nclass GTEST_API_ AssertHelper {\n public:\n  // Constructor.\n  AssertHelper(TestPartResult::Type type,\n               const char* file,\n               int line,\n               const char* message);\n  ~AssertHelper();\n\n  // Message assignment is a semantic trick to enable assertion\n  // streaming; see the GTEST_MESSAGE_ macro below.\n  void operator=(const Message& message) const;\n\n private:\n  // We put our data in a struct so that the size of the AssertHelper class can\n  // be as small as possible.  This is important because gcc is incapable of\n  // re-using stack space even for temporary variables, so every EXPECT_EQ\n  // reserves stack space for another AssertHelper.\n  struct AssertHelperData {\n    AssertHelperData(TestPartResult::Type t,\n                     const char* srcfile,\n                     int line_num,\n                     const char* msg)\n        : type(t), file(srcfile), line(line_num), message(msg) { }\n\n    TestPartResult::Type const type;\n    const char* const file;\n    int const line;\n    std::string const message;\n\n   private:\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData);\n  };\n\n  AssertHelperData* const data_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);\n};\n\n}  // namespace internal\n\n#if GTEST_HAS_PARAM_TEST\n// The pure interface class that all value-parameterized tests inherit from.\n// A value-parameterized class must inherit from both ::testing::Test and\n// ::testing::WithParamInterface. In most cases that just means inheriting\n// from ::testing::TestWithParam, but more complicated test hierarchies\n// may need to inherit from Test and WithParamInterface at different levels.\n//\n// This interface has support for accessing the test parameter value via\n// the GetParam() method.\n//\n// Use it with one of the parameter generator defining functions, like Range(),\n// Values(), ValuesIn(), Bool(), and Combine().\n//\n// class FooTest : public ::testing::TestWithParam<int> {\n//  protected:\n//   FooTest() {\n//     // Can use GetParam() here.\n//   }\n//   virtual ~FooTest() {\n//     // Can use GetParam() here.\n//   }\n//   virtual void SetUp() {\n//     // Can use GetParam() here.\n//   }\n//   virtual void TearDown {\n//     // Can use GetParam() here.\n//   }\n// };\n// TEST_P(FooTest, DoesBar) {\n//   // Can use GetParam() method here.\n//   Foo foo;\n//   ASSERT_TRUE(foo.DoesBar(GetParam()));\n// }\n// INSTANTIATE_TEST_CASE_P(OneToTenRange, FooTest, ::testing::Range(1, 10));\n\ntemplate <typename T>\nclass WithParamInterface {\n public:\n  typedef T ParamType;\n  virtual ~WithParamInterface() {}\n\n  // The current parameter value. Is also available in the test fixture's\n  // constructor. This member function is non-static, even though it only\n  // references static data, to reduce the opportunity for incorrect uses\n  // like writing 'WithParamInterface<bool>::GetParam()' for a test that\n  // uses a fixture whose parameter type is int.\n  const ParamType& GetParam() const {\n    GTEST_CHECK_(parameter_ != NULL)\n        << \"GetParam() can only be called inside a value-parameterized test \"\n        << \"-- did you intend to write TEST_P instead of TEST_F?\";\n    return *parameter_;\n  }\n\n private:\n  // Sets parameter value. The caller is responsible for making sure the value\n  // remains alive and unchanged throughout the current test.\n  static void SetParam(const ParamType* parameter) {\n    parameter_ = parameter;\n  }\n\n  // Static value used for accessing parameter during a test lifetime.\n  static const ParamType* parameter_;\n\n  // TestClass must be a subclass of WithParamInterface<T> and Test.\n  template <class TestClass> friend class internal::ParameterizedTestFactory;\n};\n\ntemplate <typename T>\nconst T* WithParamInterface<T>::parameter_ = NULL;\n\n// Most value-parameterized classes can ignore the existence of\n// WithParamInterface, and can just inherit from ::testing::TestWithParam.\n\ntemplate <typename T>\nclass TestWithParam : public Test, public WithParamInterface<T> {\n};\n\n#endif  // GTEST_HAS_PARAM_TEST\n\n// Macros for indicating success/failure in test code.\n\n// ADD_FAILURE unconditionally adds a failure to the current test.\n// SUCCEED generates a success - it doesn't automatically make the\n// current test successful, as a test is only successful when it has\n// no failure.\n//\n// EXPECT_* verifies that a certain condition is satisfied.  If not,\n// it behaves like ADD_FAILURE.  In particular:\n//\n//   EXPECT_TRUE  verifies that a Boolean condition is true.\n//   EXPECT_FALSE verifies that a Boolean condition is false.\n//\n// FAIL and ASSERT_* are similar to ADD_FAILURE and EXPECT_*, except\n// that they will also abort the current function on failure.  People\n// usually want the fail-fast behavior of FAIL and ASSERT_*, but those\n// writing data-driven tests often find themselves using ADD_FAILURE\n// and EXPECT_* more.\n\n// Generates a nonfatal failure with a generic message.\n#define ADD_FAILURE() GTEST_NONFATAL_FAILURE_(\"Failed\")\n\n// Generates a nonfatal failure at the given source file location with\n// a generic message.\n#define ADD_FAILURE_AT(file, line) \\\n  GTEST_MESSAGE_AT_(file, line, \"Failed\", \\\n                    ::testing::TestPartResult::kNonFatalFailure)\n\n// Generates a fatal failure with a generic message.\n#define GTEST_FAIL() GTEST_FATAL_FAILURE_(\"Failed\")\n\n// Define this macro to 1 to omit the definition of FAIL(), which is a\n// generic name and clashes with some other libraries.\n#if !GTEST_DONT_DEFINE_FAIL\n# define FAIL() GTEST_FAIL()\n#endif\n\n// Generates a success with a generic message.\n#define GTEST_SUCCEED() GTEST_SUCCESS_(\"Succeeded\")\n\n// Define this macro to 1 to omit the definition of SUCCEED(), which\n// is a generic name and clashes with some other libraries.\n#if !GTEST_DONT_DEFINE_SUCCEED\n# define SUCCEED() GTEST_SUCCEED()\n#endif\n\n// Macros for testing exceptions.\n//\n//    * {ASSERT|EXPECT}_THROW(statement, expected_exception):\n//         Tests that the statement throws the expected exception.\n//    * {ASSERT|EXPECT}_NO_THROW(statement):\n//         Tests that the statement doesn't throw any exception.\n//    * {ASSERT|EXPECT}_ANY_THROW(statement):\n//         Tests that the statement throws an exception.\n\n#define EXPECT_THROW(statement, expected_exception) \\\n  GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_NO_THROW(statement) \\\n  GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_ANY_THROW(statement) \\\n  GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_THROW(statement, expected_exception) \\\n  GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)\n#define ASSERT_NO_THROW(statement) \\\n  GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_)\n#define ASSERT_ANY_THROW(statement) \\\n  GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_)\n\n// Boolean assertions. Condition can be either a Boolean expression or an\n// AssertionResult. For more information on how to use AssertionResult with\n// these macros see comments on that class.\n#define EXPECT_TRUE(condition) \\\n  GTEST_TEST_BOOLEAN_((condition), #condition, false, true, \\\n                      GTEST_NONFATAL_FAILURE_)\n#define EXPECT_FALSE(condition) \\\n  GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \\\n                      GTEST_NONFATAL_FAILURE_)\n#define ASSERT_TRUE(condition) \\\n  GTEST_TEST_BOOLEAN_((condition), #condition, false, true, \\\n                      GTEST_FATAL_FAILURE_)\n#define ASSERT_FALSE(condition) \\\n  GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \\\n                      GTEST_FATAL_FAILURE_)\n\n// Includes the auto-generated header that implements a family of\n// generic predicate assertion macros.\n#include \"gtest/gtest_pred_impl.h\"\n\n// Macros for testing equalities and inequalities.\n//\n//    * {ASSERT|EXPECT}_EQ(v1, v2): Tests that v1 == v2\n//    * {ASSERT|EXPECT}_NE(v1, v2): Tests that v1 != v2\n//    * {ASSERT|EXPECT}_LT(v1, v2): Tests that v1 < v2\n//    * {ASSERT|EXPECT}_LE(v1, v2): Tests that v1 <= v2\n//    * {ASSERT|EXPECT}_GT(v1, v2): Tests that v1 > v2\n//    * {ASSERT|EXPECT}_GE(v1, v2): Tests that v1 >= v2\n//\n// When they are not, Google Test prints both the tested expressions and\n// their actual values.  The values must be compatible built-in types,\n// or you will get a compiler error.  By \"compatible\" we mean that the\n// values can be compared by the respective operator.\n//\n// Note:\n//\n//   1. It is possible to make a user-defined type work with\n//   {ASSERT|EXPECT}_??(), but that requires overloading the\n//   comparison operators and is thus discouraged by the Google C++\n//   Usage Guide.  Therefore, you are advised to use the\n//   {ASSERT|EXPECT}_TRUE() macro to assert that two objects are\n//   equal.\n//\n//   2. The {ASSERT|EXPECT}_??() macros do pointer comparisons on\n//   pointers (in particular, C strings).  Therefore, if you use it\n//   with two C strings, you are testing how their locations in memory\n//   are related, not how their content is related.  To compare two C\n//   strings by content, use {ASSERT|EXPECT}_STR*().\n//\n//   3. {ASSERT|EXPECT}_EQ(v1, v2) is preferred to\n//   {ASSERT|EXPECT}_TRUE(v1 == v2), as the former tells you\n//   what the actual value is when it fails, and similarly for the\n//   other comparisons.\n//\n//   4. Do not depend on the order in which {ASSERT|EXPECT}_??()\n//   evaluate their arguments, which is undefined.\n//\n//   5. These macros evaluate their arguments exactly once.\n//\n// Examples:\n//\n//   EXPECT_NE(5, Foo());\n//   EXPECT_EQ(NULL, a_pointer);\n//   ASSERT_LT(i, array_size);\n//   ASSERT_GT(records.size(), 0) << \"There is no record left.\";\n\n#define EXPECT_EQ(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal:: \\\n                      EqHelper<GTEST_IS_NULL_LITERAL_(val1)>::Compare, \\\n                      val1, val2)\n#define EXPECT_NE(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)\n#define EXPECT_LE(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)\n#define EXPECT_LT(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)\n#define EXPECT_GE(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)\n#define EXPECT_GT(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)\n\n#define GTEST_ASSERT_EQ(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal:: \\\n                      EqHelper<GTEST_IS_NULL_LITERAL_(val1)>::Compare, \\\n                      val1, val2)\n#define GTEST_ASSERT_NE(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)\n#define GTEST_ASSERT_LE(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)\n#define GTEST_ASSERT_LT(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)\n#define GTEST_ASSERT_GE(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)\n#define GTEST_ASSERT_GT(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)\n\n// Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of\n// ASSERT_XY(), which clashes with some users' own code.\n\n#if !GTEST_DONT_DEFINE_ASSERT_EQ\n# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_NE\n# define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_LE\n# define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_LT\n# define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_GE\n# define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_GT\n# define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)\n#endif\n\n// C-string Comparisons.  All tests treat NULL and any non-NULL string\n// as different.  Two NULLs are equal.\n//\n//    * {ASSERT|EXPECT}_STREQ(s1, s2):     Tests that s1 == s2\n//    * {ASSERT|EXPECT}_STRNE(s1, s2):     Tests that s1 != s2\n//    * {ASSERT|EXPECT}_STRCASEEQ(s1, s2): Tests that s1 == s2, ignoring case\n//    * {ASSERT|EXPECT}_STRCASENE(s1, s2): Tests that s1 != s2, ignoring case\n//\n// For wide or narrow string objects, you can use the\n// {ASSERT|EXPECT}_??() macros.\n//\n// Don't depend on the order in which the arguments are evaluated,\n// which is undefined.\n//\n// These macros evaluate their arguments exactly once.\n\n#define EXPECT_STREQ(s1, s2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)\n#define EXPECT_STRNE(s1, s2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)\n#define EXPECT_STRCASEEQ(s1, s2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)\n#define EXPECT_STRCASENE(s1, s2)\\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)\n\n#define ASSERT_STREQ(s1, s2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)\n#define ASSERT_STRNE(s1, s2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)\n#define ASSERT_STRCASEEQ(s1, s2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)\n#define ASSERT_STRCASENE(s1, s2)\\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)\n\n// Macros for comparing floating-point numbers.\n//\n//    * {ASSERT|EXPECT}_FLOAT_EQ(val1, val2):\n//         Tests that two float values are almost equal.\n//    * {ASSERT|EXPECT}_DOUBLE_EQ(val1, val2):\n//         Tests that two double values are almost equal.\n//    * {ASSERT|EXPECT}_NEAR(v1, v2, abs_error):\n//         Tests that v1 and v2 are within the given distance to each other.\n//\n// Google Test uses ULP-based comparison to automatically pick a default\n// error bound that is appropriate for the operands.  See the\n// FloatingPoint template class in gtest-internal.h if you are\n// interested in the implementation details.\n\n#define EXPECT_FLOAT_EQ(val1, val2)\\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \\\n                      val1, val2)\n\n#define EXPECT_DOUBLE_EQ(val1, val2)\\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \\\n                      val1, val2)\n\n#define ASSERT_FLOAT_EQ(val1, val2)\\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \\\n                      val1, val2)\n\n#define ASSERT_DOUBLE_EQ(val1, val2)\\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \\\n                      val1, val2)\n\n#define EXPECT_NEAR(val1, val2, abs_error)\\\n  EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \\\n                      val1, val2, abs_error)\n\n#define ASSERT_NEAR(val1, val2, abs_error)\\\n  ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \\\n                      val1, val2, abs_error)\n\n// These predicate format functions work on floating-point values, and\n// can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g.\n//\n//   EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0);\n\n// Asserts that val1 is less than, or almost equal to, val2.  Fails\n// otherwise.  In particular, it fails if either val1 or val2 is NaN.\nGTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2,\n                                   float val1, float val2);\nGTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,\n                                    double val1, double val2);\n\n\n#if GTEST_OS_WINDOWS\n\n// Macros that test for HRESULT failure and success, these are only useful\n// on Windows, and rely on Windows SDK macros and APIs to compile.\n//\n//    * {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}(expr)\n//\n// When expr unexpectedly fails or succeeds, Google Test prints the\n// expected result and the actual result with both a human-readable\n// string representation of the error, if available, as well as the\n// hex result code.\n# define EXPECT_HRESULT_SUCCEEDED(expr) \\\n    EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))\n\n# define ASSERT_HRESULT_SUCCEEDED(expr) \\\n    ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))\n\n# define EXPECT_HRESULT_FAILED(expr) \\\n    EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))\n\n# define ASSERT_HRESULT_FAILED(expr) \\\n    ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))\n\n#endif  // GTEST_OS_WINDOWS\n\n// Macros that execute statement and check that it doesn't generate new fatal\n// failures in the current thread.\n//\n//   * {ASSERT|EXPECT}_NO_FATAL_FAILURE(statement);\n//\n// Examples:\n//\n//   EXPECT_NO_FATAL_FAILURE(Process());\n//   ASSERT_NO_FATAL_FAILURE(Process()) << \"Process() failed\";\n//\n#define ASSERT_NO_FATAL_FAILURE(statement) \\\n    GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_)\n#define EXPECT_NO_FATAL_FAILURE(statement) \\\n    GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)\n\n// Causes a trace (including the source file path, the current line\n// number, and the given message) to be included in every test failure\n// message generated by code in the current scope.  The effect is\n// undone when the control leaves the current scope.\n//\n// The message argument can be anything streamable to std::ostream.\n//\n// In the implementation, we include the current line number as part\n// of the dummy variable name, thus allowing multiple SCOPED_TRACE()s\n// to appear in the same block - as long as they are on different\n// lines.\n#define SCOPED_TRACE(message) \\\n  ::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\\\n    __FILE__, __LINE__, ::testing::Message() << (message))\n\n// Compile-time assertion for type equality.\n// StaticAssertTypeEq<type1, type2>() compiles iff type1 and type2 are\n// the same type.  The value it returns is not interesting.\n//\n// Instead of making StaticAssertTypeEq a class template, we make it a\n// function template that invokes a helper class template.  This\n// prevents a user from misusing StaticAssertTypeEq<T1, T2> by\n// defining objects of that type.\n//\n// CAVEAT:\n//\n// When used inside a method of a class template,\n// StaticAssertTypeEq<T1, T2>() is effective ONLY IF the method is\n// instantiated.  For example, given:\n//\n//   template <typename T> class Foo {\n//    public:\n//     void Bar() { testing::StaticAssertTypeEq<int, T>(); }\n//   };\n//\n// the code:\n//\n//   void Test1() { Foo<bool> foo; }\n//\n// will NOT generate a compiler error, as Foo<bool>::Bar() is never\n// actually instantiated.  Instead, you need:\n//\n//   void Test2() { Foo<bool> foo; foo.Bar(); }\n//\n// to cause a compiler error.\ntemplate <typename T1, typename T2>\nbool StaticAssertTypeEq() {\n  (void)internal::StaticAssertTypeEqHelper<T1, T2>();\n  return true;\n}\n\n// Defines a test.\n//\n// The first parameter is the name of the test case, and the second\n// parameter is the name of the test within the test case.\n//\n// The convention is to end the test case name with \"Test\".  For\n// example, a test case for the Foo class can be named FooTest.\n//\n// Test code should appear between braces after an invocation of\n// this macro.  Example:\n//\n//   TEST(FooTest, InitializesCorrectly) {\n//     Foo foo;\n//     EXPECT_TRUE(foo.StatusIsOK());\n//   }\n\n// Note that we call GetTestTypeId() instead of GetTypeId<\n// ::testing::Test>() here to get the type ID of testing::Test.  This\n// is to work around a suspected linker bug when using Google Test as\n// a framework on Mac OS X.  The bug causes GetTypeId<\n// ::testing::Test>() to return different values depending on whether\n// the call is from the Google Test framework itself or from user test\n// code.  GetTestTypeId() is guaranteed to always return the same\n// value, as it always calls GetTypeId<>() from the Google Test\n// framework.\n#define GTEST_TEST(test_case_name, test_name)\\\n  GTEST_TEST_(test_case_name, test_name, \\\n              ::testing::Test, ::testing::internal::GetTestTypeId())\n\n// Define this macro to 1 to omit the definition of TEST(), which\n// is a generic name and clashes with some other libraries.\n#if !GTEST_DONT_DEFINE_TEST\n# define TEST(test_case_name, test_name) GTEST_TEST(test_case_name, test_name)\n#endif\n\n// Defines a test that uses a test fixture.\n//\n// The first parameter is the name of the test fixture class, which\n// also doubles as the test case name.  The second parameter is the\n// name of the test within the test case.\n//\n// A test fixture class must be declared earlier.  The user should put\n// his test code between braces after using this macro.  Example:\n//\n//   class FooTest : public testing::Test {\n//    protected:\n//     virtual void SetUp() { b_.AddElement(3); }\n//\n//     Foo a_;\n//     Foo b_;\n//   };\n//\n//   TEST_F(FooTest, InitializesCorrectly) {\n//     EXPECT_TRUE(a_.StatusIsOK());\n//   }\n//\n//   TEST_F(FooTest, ReturnsElementCountCorrectly) {\n//     EXPECT_EQ(0, a_.size());\n//     EXPECT_EQ(1, b_.size());\n//   }\n\n#define TEST_F(test_fixture, test_name)\\\n  GTEST_TEST_(test_fixture, test_name, test_fixture, \\\n              ::testing::internal::GetTypeId<test_fixture>())\n\n}  // namespace testing\n\n// Use this function in main() to run all tests.  It returns 0 if all\n// tests are successful, or 1 otherwise.\n//\n// RUN_ALL_TESTS() should be invoked after the command line has been\n// parsed by InitGoogleTest().\n//\n// This function was formerly a macro; thus, it is in the global\n// namespace and has an all-caps name.\nint RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_;\n\ninline int RUN_ALL_TESTS() {\n  return ::testing::UnitTest::GetInstance()->Run();\n}\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/gtest_pred_impl.h",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is AUTOMATICALLY GENERATED on 10/31/2011 by command\n// 'gen_gtest_pred_impl.py 5'.  DO NOT EDIT BY HAND!\n//\n// Implements a family of generic predicate assertion macros.\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n#define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n\n// Makes sure this header is not included before gtest.h.\n#ifndef GTEST_INCLUDE_GTEST_GTEST_H_\n# error Do not include gtest_pred_impl.h directly.  Include gtest.h instead.\n#endif  // GTEST_INCLUDE_GTEST_GTEST_H_\n\n// This header implements a family of generic predicate assertion\n// macros:\n//\n//   ASSERT_PRED_FORMAT1(pred_format, v1)\n//   ASSERT_PRED_FORMAT2(pred_format, v1, v2)\n//   ...\n//\n// where pred_format is a function or functor that takes n (in the\n// case of ASSERT_PRED_FORMATn) values and their source expression\n// text, and returns a testing::AssertionResult.  See the definition\n// of ASSERT_EQ in gtest.h for an example.\n//\n// If you don't care about formatting, you can use the more\n// restrictive version:\n//\n//   ASSERT_PRED1(pred, v1)\n//   ASSERT_PRED2(pred, v1, v2)\n//   ...\n//\n// where pred is an n-ary function or functor that returns bool,\n// and the values v1, v2, ..., must support the << operator for\n// streaming to std::ostream.\n//\n// We also define the EXPECT_* variations.\n//\n// For now we only support predicates whose arity is at most 5.\n// Please email googletestframework@googlegroups.com if you need\n// support for higher arities.\n\n// GTEST_ASSERT_ is the basic statement to which all of the assertions\n// in this file reduce.  Don't use this in your code.\n\n#define GTEST_ASSERT_(expression, on_failure) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (const ::testing::AssertionResult gtest_ar = (expression)) \\\n    ; \\\n  else \\\n    on_failure(gtest_ar.failure_message())\n\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED1.  Don't use\n// this in your code.\ntemplate <typename Pred,\n          typename T1>\nAssertionResult AssertPred1Helper(const char* pred_text,\n                                  const char* e1,\n                                  Pred pred,\n                                  const T1& v1) {\n  if (pred(v1)) return AssertionSuccess();\n\n  return AssertionFailure() << pred_text << \"(\"\n                            << e1 << \") evaluates to false, where\"\n                            << \"\\n\" << e1 << \" evaluates to \" << v1;\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\\\n  GTEST_ASSERT_(pred_format(#v1, v1), \\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED1.  Don't use\n// this in your code.\n#define GTEST_PRED1_(pred, v1, on_failure)\\\n  GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \\\n                                             #v1, \\\n                                             pred, \\\n                                             v1), on_failure)\n\n// Unary predicate assertion macros.\n#define EXPECT_PRED_FORMAT1(pred_format, v1) \\\n  GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED1(pred, v1) \\\n  GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT1(pred_format, v1) \\\n  GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED1(pred, v1) \\\n  GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)\n\n\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED2.  Don't use\n// this in your code.\ntemplate <typename Pred,\n          typename T1,\n          typename T2>\nAssertionResult AssertPred2Helper(const char* pred_text,\n                                  const char* e1,\n                                  const char* e2,\n                                  Pred pred,\n                                  const T1& v1,\n                                  const T2& v2) {\n  if (pred(v1, v2)) return AssertionSuccess();\n\n  return AssertionFailure() << pred_text << \"(\"\n                            << e1 << \", \"\n                            << e2 << \") evaluates to false, where\"\n                            << \"\\n\" << e1 << \" evaluates to \" << v1\n                            << \"\\n\" << e2 << \" evaluates to \" << v2;\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\\\n  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED2.  Don't use\n// this in your code.\n#define GTEST_PRED2_(pred, v1, v2, on_failure)\\\n  GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \\\n                                             #v1, \\\n                                             #v2, \\\n                                             pred, \\\n                                             v1, \\\n                                             v2), on_failure)\n\n// Binary predicate assertion macros.\n#define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \\\n  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED2(pred, v1, v2) \\\n  GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \\\n  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED2(pred, v1, v2) \\\n  GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)\n\n\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED3.  Don't use\n// this in your code.\ntemplate <typename Pred,\n          typename T1,\n          typename T2,\n          typename T3>\nAssertionResult AssertPred3Helper(const char* pred_text,\n                                  const char* e1,\n                                  const char* e2,\n                                  const char* e3,\n                                  Pred pred,\n                                  const T1& v1,\n                                  const T2& v2,\n                                  const T3& v3) {\n  if (pred(v1, v2, v3)) return AssertionSuccess();\n\n  return AssertionFailure() << pred_text << \"(\"\n                            << e1 << \", \"\n                            << e2 << \", \"\n                            << e3 << \") evaluates to false, where\"\n                            << \"\\n\" << e1 << \" evaluates to \" << v1\n                            << \"\\n\" << e2 << \" evaluates to \" << v2\n                            << \"\\n\" << e3 << \" evaluates to \" << v3;\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\\\n  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED3.  Don't use\n// this in your code.\n#define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\\\n  GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \\\n                                             #v1, \\\n                                             #v2, \\\n                                             #v3, \\\n                                             pred, \\\n                                             v1, \\\n                                             v2, \\\n                                             v3), on_failure)\n\n// Ternary predicate assertion macros.\n#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \\\n  GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED3(pred, v1, v2, v3) \\\n  GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \\\n  GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED3(pred, v1, v2, v3) \\\n  GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)\n\n\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED4.  Don't use\n// this in your code.\ntemplate <typename Pred,\n          typename T1,\n          typename T2,\n          typename T3,\n          typename T4>\nAssertionResult AssertPred4Helper(const char* pred_text,\n                                  const char* e1,\n                                  const char* e2,\n                                  const char* e3,\n                                  const char* e4,\n                                  Pred pred,\n                                  const T1& v1,\n                                  const T2& v2,\n                                  const T3& v3,\n                                  const T4& v4) {\n  if (pred(v1, v2, v3, v4)) return AssertionSuccess();\n\n  return AssertionFailure() << pred_text << \"(\"\n                            << e1 << \", \"\n                            << e2 << \", \"\n                            << e3 << \", \"\n                            << e4 << \") evaluates to false, where\"\n                            << \"\\n\" << e1 << \" evaluates to \" << v1\n                            << \"\\n\" << e2 << \" evaluates to \" << v2\n                            << \"\\n\" << e3 << \" evaluates to \" << v3\n                            << \"\\n\" << e4 << \" evaluates to \" << v4;\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\\\n  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED4.  Don't use\n// this in your code.\n#define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\\\n  GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \\\n                                             #v1, \\\n                                             #v2, \\\n                                             #v3, \\\n                                             #v4, \\\n                                             pred, \\\n                                             v1, \\\n                                             v2, \\\n                                             v3, \\\n                                             v4), on_failure)\n\n// 4-ary predicate assertion macros.\n#define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \\\n  GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED4(pred, v1, v2, v3, v4) \\\n  GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \\\n  GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED4(pred, v1, v2, v3, v4) \\\n  GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)\n\n\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED5.  Don't use\n// this in your code.\ntemplate <typename Pred,\n          typename T1,\n          typename T2,\n          typename T3,\n          typename T4,\n          typename T5>\nAssertionResult AssertPred5Helper(const char* pred_text,\n                                  const char* e1,\n                                  const char* e2,\n                                  const char* e3,\n                                  const char* e4,\n                                  const char* e5,\n                                  Pred pred,\n                                  const T1& v1,\n                                  const T2& v2,\n                                  const T3& v3,\n                                  const T4& v4,\n                                  const T5& v5) {\n  if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess();\n\n  return AssertionFailure() << pred_text << \"(\"\n                            << e1 << \", \"\n                            << e2 << \", \"\n                            << e3 << \", \"\n                            << e4 << \", \"\n                            << e5 << \") evaluates to false, where\"\n                            << \"\\n\" << e1 << \" evaluates to \" << v1\n                            << \"\\n\" << e2 << \" evaluates to \" << v2\n                            << \"\\n\" << e3 << \" evaluates to \" << v3\n                            << \"\\n\" << e4 << \" evaluates to \" << v4\n                            << \"\\n\" << e5 << \" evaluates to \" << v5;\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\\\n  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED5.  Don't use\n// this in your code.\n#define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\\\n  GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \\\n                                             #v1, \\\n                                             #v2, \\\n                                             #v3, \\\n                                             #v4, \\\n                                             #v5, \\\n                                             pred, \\\n                                             v1, \\\n                                             v2, \\\n                                             v3, \\\n                                             v4, \\\n                                             v5), on_failure)\n\n// 5-ary predicate assertion macros.\n#define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \\\n  GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \\\n  GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \\\n  GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \\\n  GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)\n\n\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/gtest_prod.h",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Google C++ Testing Framework definitions useful in production code.\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_\n#define GTEST_INCLUDE_GTEST_GTEST_PROD_H_\n\n// When you need to test the private or protected members of a class,\n// use the FRIEND_TEST macro to declare your tests as friends of the\n// class.  For example:\n//\n// class MyClass {\n//  private:\n//   void MyMethod();\n//   FRIEND_TEST(MyClassTest, MyMethod);\n// };\n//\n// class MyClassTest : public testing::Test {\n//   // ...\n// };\n//\n// TEST_F(MyClassTest, MyMethod) {\n//   // Can call MyClass::MyMethod() here.\n// }\n\n#define FRIEND_TEST(test_case_name, test_name)\\\nfriend class test_case_name##_##test_name##_Test\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_PROD_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/custom/gtest-port.h",
    "content": "// Copyright 2015, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Injection point for custom user configurations.\n// The following macros can be defined:\n//\n//   Flag related macros:\n//     GTEST_FLAG(flag_name)\n//     GTEST_USE_OWN_FLAGFILE_FLAG_  - Define to 0 when the system provides its\n//                                     own flagfile flag parsing.\n//     GTEST_DECLARE_bool_(name)\n//     GTEST_DECLARE_int32_(name)\n//     GTEST_DECLARE_string_(name)\n//     GTEST_DEFINE_bool_(name, default_val, doc)\n//     GTEST_DEFINE_int32_(name, default_val, doc)\n//     GTEST_DEFINE_string_(name, default_val, doc)\n//\n//   Test filtering:\n//     GTEST_TEST_FILTER_ENV_VAR_ - The name of an environment variable that\n//                                  will be used if --GTEST_FLAG(test_filter)\n//                                  is not provided.\n//\n//   Logging:\n//     GTEST_LOG_(severity)\n//     GTEST_CHECK_(condition)\n//     Functions LogToStderr() and FlushInfoLog() have to be provided too.\n//\n//   Threading:\n//     GTEST_HAS_NOTIFICATION_ - Enabled if Notification is already provided.\n//     GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ - Enabled if Mutex and ThreadLocal are\n//                                         already provided.\n//     Must also provide GTEST_DECLARE_STATIC_MUTEX_(mutex) and\n//     GTEST_DEFINE_STATIC_MUTEX_(mutex)\n//\n//     GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)\n//     GTEST_LOCK_EXCLUDED_(locks)\n//\n// ** Custom implementation starts here **\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/custom/gtest-printers.h",
    "content": "// Copyright 2015, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// This file provides an injection point for custom printers in a local\n// installation of gTest.\n// It will be included from gtest-printers.h and the overrides in this file\n// will be visible to everyone.\n// See documentation at gtest/gtest-printers.h for details on how to define a\n// custom printer.\n//\n// ** Custom implementation starts here **\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/custom/gtest.h",
    "content": "// Copyright 2015, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Injection point for custom user configurations.\n// The following macros can be defined:\n//\n// GTEST_OS_STACK_TRACE_GETTER_  - The name of an implementation of\n//                                 OsStackTraceGetterInterface.\n//\n// ** Custom implementation starts here **\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/gtest-death-test-internal.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This header file defines internal utilities needed for implementing\n// death tests.  They are subject to change without notice.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_\n\n#include \"gtest/internal/gtest-internal.h\"\n\n#include <stdio.h>\n\nnamespace testing {\nnamespace internal {\n\nGTEST_DECLARE_string_(internal_run_death_test);\n\n// Names of the flags (needed for parsing Google Test flags).\nconst char kDeathTestStyleFlag[] = \"death_test_style\";\nconst char kDeathTestUseFork[] = \"death_test_use_fork\";\nconst char kInternalRunDeathTestFlag[] = \"internal_run_death_test\";\n\n#if GTEST_HAS_DEATH_TEST\n\n// DeathTest is a class that hides much of the complexity of the\n// GTEST_DEATH_TEST_ macro.  It is abstract; its static Create method\n// returns a concrete class that depends on the prevailing death test\n// style, as defined by the --gtest_death_test_style and/or\n// --gtest_internal_run_death_test flags.\n\n// In describing the results of death tests, these terms are used with\n// the corresponding definitions:\n//\n// exit status:  The integer exit information in the format specified\n//               by wait(2)\n// exit code:    The integer code passed to exit(3), _exit(2), or\n//               returned from main()\nclass GTEST_API_ DeathTest {\n public:\n  // Create returns false if there was an error determining the\n  // appropriate action to take for the current death test; for example,\n  // if the gtest_death_test_style flag is set to an invalid value.\n  // The LastMessage method will return a more detailed message in that\n  // case.  Otherwise, the DeathTest pointer pointed to by the \"test\"\n  // argument is set.  If the death test should be skipped, the pointer\n  // is set to NULL; otherwise, it is set to the address of a new concrete\n  // DeathTest object that controls the execution of the current test.\n  static bool Create(const char* statement, const RE* regex,\n                     const char* file, int line, DeathTest** test);\n  DeathTest();\n  virtual ~DeathTest() { }\n\n  // A helper class that aborts a death test when it's deleted.\n  class ReturnSentinel {\n   public:\n    explicit ReturnSentinel(DeathTest* test) : test_(test) { }\n    ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }\n   private:\n    DeathTest* const test_;\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);\n  } GTEST_ATTRIBUTE_UNUSED_;\n\n  // An enumeration of possible roles that may be taken when a death\n  // test is encountered.  EXECUTE means that the death test logic should\n  // be executed immediately.  OVERSEE means that the program should prepare\n  // the appropriate environment for a child process to execute the death\n  // test, then wait for it to complete.\n  enum TestRole { OVERSEE_TEST, EXECUTE_TEST };\n\n  // An enumeration of the three reasons that a test might be aborted.\n  enum AbortReason {\n    TEST_ENCOUNTERED_RETURN_STATEMENT,\n    TEST_THREW_EXCEPTION,\n    TEST_DID_NOT_DIE\n  };\n\n  // Assumes one of the above roles.\n  virtual TestRole AssumeRole() = 0;\n\n  // Waits for the death test to finish and returns its status.\n  virtual int Wait() = 0;\n\n  // Returns true if the death test passed; that is, the test process\n  // exited during the test, its exit status matches a user-supplied\n  // predicate, and its stderr output matches a user-supplied regular\n  // expression.\n  // The user-supplied predicate may be a macro expression rather\n  // than a function pointer or functor, or else Wait and Passed could\n  // be combined.\n  virtual bool Passed(bool exit_status_ok) = 0;\n\n  // Signals that the death test did not die as expected.\n  virtual void Abort(AbortReason reason) = 0;\n\n  // Returns a human-readable outcome message regarding the outcome of\n  // the last death test.\n  static const char* LastMessage();\n\n  static void set_last_death_test_message(const std::string& message);\n\n private:\n  // A string containing a description of the outcome of the last death test.\n  static std::string last_death_test_message_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);\n};\n\n// Factory interface for death tests.  May be mocked out for testing.\nclass DeathTestFactory {\n public:\n  virtual ~DeathTestFactory() { }\n  virtual bool Create(const char* statement, const RE* regex,\n                      const char* file, int line, DeathTest** test) = 0;\n};\n\n// A concrete DeathTestFactory implementation for normal use.\nclass DefaultDeathTestFactory : public DeathTestFactory {\n public:\n  virtual bool Create(const char* statement, const RE* regex,\n                      const char* file, int line, DeathTest** test);\n};\n\n// Returns true if exit_status describes a process that was terminated\n// by a signal, or exited normally with a nonzero exit code.\nGTEST_API_ bool ExitedUnsuccessfully(int exit_status);\n\n// Traps C++ exceptions escaping statement and reports them as test\n// failures. Note that trapping SEH exceptions is not implemented here.\n# if GTEST_HAS_EXCEPTIONS\n#  define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \\\n  try { \\\n    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n  } catch (const ::std::exception& gtest_exception) { \\\n    fprintf(\\\n        stderr, \\\n        \"\\n%s: Caught std::exception-derived exception escaping the \" \\\n        \"death test statement. Exception message: %s\\n\", \\\n        ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \\\n        gtest_exception.what()); \\\n    fflush(stderr); \\\n    death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \\\n  } catch (...) { \\\n    death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \\\n  }\n\n# else\n#  define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \\\n  GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)\n\n# endif\n\n// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,\n// ASSERT_EXIT*, and EXPECT_EXIT*.\n# define GTEST_DEATH_TEST_(statement, predicate, regex, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (::testing::internal::AlwaysTrue()) { \\\n    const ::testing::internal::RE& gtest_regex = (regex); \\\n    ::testing::internal::DeathTest* gtest_dt; \\\n    if (!::testing::internal::DeathTest::Create(#statement, &gtest_regex, \\\n        __FILE__, __LINE__, &gtest_dt)) { \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \\\n    } \\\n    if (gtest_dt != NULL) { \\\n      ::testing::internal::scoped_ptr< ::testing::internal::DeathTest> \\\n          gtest_dt_ptr(gtest_dt); \\\n      switch (gtest_dt->AssumeRole()) { \\\n        case ::testing::internal::DeathTest::OVERSEE_TEST: \\\n          if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \\\n            goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \\\n          } \\\n          break; \\\n        case ::testing::internal::DeathTest::EXECUTE_TEST: { \\\n          ::testing::internal::DeathTest::ReturnSentinel \\\n              gtest_sentinel(gtest_dt); \\\n          GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \\\n          gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \\\n          break; \\\n        } \\\n        default: \\\n          break; \\\n      } \\\n    } \\\n  } else \\\n    GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__): \\\n      fail(::testing::internal::DeathTest::LastMessage())\n// The symbol \"fail\" here expands to something into which a message\n// can be streamed.\n\n// This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in\n// NDEBUG mode. In this case we need the statements to be executed, the regex is\n// ignored, and the macro must accept a streamed message even though the message\n// is never printed.\n# define GTEST_EXECUTE_STATEMENT_(statement, regex) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (::testing::internal::AlwaysTrue()) { \\\n     GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n  } else \\\n    ::testing::Message()\n\n// A class representing the parsed contents of the\n// --gtest_internal_run_death_test flag, as it existed when\n// RUN_ALL_TESTS was called.\nclass InternalRunDeathTestFlag {\n public:\n  InternalRunDeathTestFlag(const std::string& a_file,\n                           int a_line,\n                           int an_index,\n                           int a_write_fd)\n      : file_(a_file), line_(a_line), index_(an_index),\n        write_fd_(a_write_fd) {}\n\n  ~InternalRunDeathTestFlag() {\n    if (write_fd_ >= 0)\n      posix::Close(write_fd_);\n  }\n\n  const std::string& file() const { return file_; }\n  int line() const { return line_; }\n  int index() const { return index_; }\n  int write_fd() const { return write_fd_; }\n\n private:\n  std::string file_;\n  int line_;\n  int index_;\n  int write_fd_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);\n};\n\n// Returns a newly created InternalRunDeathTestFlag object with fields\n// initialized from the GTEST_FLAG(internal_run_death_test) flag if\n// the flag is specified; otherwise returns NULL.\nInternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();\n\n#else  // GTEST_HAS_DEATH_TEST\n\n// This macro is used for implementing macros such as\n// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where\n// death tests are not supported. Those macros must compile on such systems\n// iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on\n// systems that support death tests. This allows one to write such a macro\n// on a system that does not support death tests and be sure that it will\n// compile on a death-test supporting system.\n//\n// Parameters:\n//   statement -  A statement that a macro such as EXPECT_DEATH would test\n//                for program termination. This macro has to make sure this\n//                statement is compiled but not executed, to ensure that\n//                EXPECT_DEATH_IF_SUPPORTED compiles with a certain\n//                parameter iff EXPECT_DEATH compiles with it.\n//   regex     -  A regex that a macro such as EXPECT_DEATH would use to test\n//                the output of statement.  This parameter has to be\n//                compiled but not evaluated by this macro, to ensure that\n//                this macro only accepts expressions that a macro such as\n//                EXPECT_DEATH would accept.\n//   terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED\n//                and a return statement for ASSERT_DEATH_IF_SUPPORTED.\n//                This ensures that ASSERT_DEATH_IF_SUPPORTED will not\n//                compile inside functions where ASSERT_DEATH doesn't\n//                compile.\n//\n//  The branch that has an always false condition is used to ensure that\n//  statement and regex are compiled (and thus syntactically correct) but\n//  never executed. The unreachable code macro protects the terminator\n//  statement from generating an 'unreachable code' warning in case\n//  statement unconditionally returns or throws. The Message constructor at\n//  the end allows the syntax of streaming additional messages into the\n//  macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.\n# define GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, terminator) \\\n    GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n    if (::testing::internal::AlwaysTrue()) { \\\n      GTEST_LOG_(WARNING) \\\n          << \"Death tests are not supported on this platform.\\n\" \\\n          << \"Statement '\" #statement \"' cannot be verified.\"; \\\n    } else if (::testing::internal::AlwaysFalse()) { \\\n      ::testing::internal::RE::PartialMatch(\".*\", (regex)); \\\n      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n      terminator; \\\n    } else \\\n      ::testing::Message()\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/gtest-filepath.h",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: keith.ray@gmail.com (Keith Ray)\n//\n// Google Test filepath utilities\n//\n// This header file declares classes and functions used internally by\n// Google Test.  They are subject to change without notice.\n//\n// This file is #included in <gtest/internal/gtest-internal.h>.\n// Do not include this header file separately!\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_\n\n#include \"gtest/internal/gtest-string.h\"\n\nnamespace testing {\nnamespace internal {\n\n// FilePath - a class for file and directory pathname manipulation which\n// handles platform-specific conventions (like the pathname separator).\n// Used for helper functions for naming files in a directory for xml output.\n// Except for Set methods, all methods are const or static, which provides an\n// \"immutable value object\" -- useful for peace of mind.\n// A FilePath with a value ending in a path separator (\"like/this/\") represents\n// a directory, otherwise it is assumed to represent a file. In either case,\n// it may or may not represent an actual file or directory in the file system.\n// Names are NOT checked for syntax correctness -- no checking for illegal\n// characters, malformed paths, etc.\n\nclass GTEST_API_ FilePath {\n public:\n  FilePath() : pathname_(\"\") { }\n  FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }\n\n  explicit FilePath(const std::string& pathname) : pathname_(pathname) {\n    Normalize();\n  }\n\n  FilePath& operator=(const FilePath& rhs) {\n    Set(rhs);\n    return *this;\n  }\n\n  void Set(const FilePath& rhs) {\n    pathname_ = rhs.pathname_;\n  }\n\n  const std::string& string() const { return pathname_; }\n  const char* c_str() const { return pathname_.c_str(); }\n\n  // Returns the current working directory, or \"\" if unsuccessful.\n  static FilePath GetCurrentDir();\n\n  // Given directory = \"dir\", base_name = \"test\", number = 0,\n  // extension = \"xml\", returns \"dir/test.xml\". If number is greater\n  // than zero (e.g., 12), returns \"dir/test_12.xml\".\n  // On Windows platform, uses \\ as the separator rather than /.\n  static FilePath MakeFileName(const FilePath& directory,\n                               const FilePath& base_name,\n                               int number,\n                               const char* extension);\n\n  // Given directory = \"dir\", relative_path = \"test.xml\",\n  // returns \"dir/test.xml\".\n  // On Windows, uses \\ as the separator rather than /.\n  static FilePath ConcatPaths(const FilePath& directory,\n                              const FilePath& relative_path);\n\n  // Returns a pathname for a file that does not currently exist. The pathname\n  // will be directory/base_name.extension or\n  // directory/base_name_<number>.extension if directory/base_name.extension\n  // already exists. The number will be incremented until a pathname is found\n  // that does not already exist.\n  // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.\n  // There could be a race condition if two or more processes are calling this\n  // function at the same time -- they could both pick the same filename.\n  static FilePath GenerateUniqueFileName(const FilePath& directory,\n                                         const FilePath& base_name,\n                                         const char* extension);\n\n  // Returns true iff the path is \"\".\n  bool IsEmpty() const { return pathname_.empty(); }\n\n  // If input name has a trailing separator character, removes it and returns\n  // the name, otherwise return the name string unmodified.\n  // On Windows platform, uses \\ as the separator, other platforms use /.\n  FilePath RemoveTrailingPathSeparator() const;\n\n  // Returns a copy of the FilePath with the directory part removed.\n  // Example: FilePath(\"path/to/file\").RemoveDirectoryName() returns\n  // FilePath(\"file\"). If there is no directory part (\"just_a_file\"), it returns\n  // the FilePath unmodified. If there is no file part (\"just_a_dir/\") it\n  // returns an empty FilePath (\"\").\n  // On Windows platform, '\\' is the path separator, otherwise it is '/'.\n  FilePath RemoveDirectoryName() const;\n\n  // RemoveFileName returns the directory path with the filename removed.\n  // Example: FilePath(\"path/to/file\").RemoveFileName() returns \"path/to/\".\n  // If the FilePath is \"a_file\" or \"/a_file\", RemoveFileName returns\n  // FilePath(\"./\") or, on Windows, FilePath(\".\\\\\"). If the filepath does\n  // not have a file, like \"just/a/dir/\", it returns the FilePath unmodified.\n  // On Windows platform, '\\' is the path separator, otherwise it is '/'.\n  FilePath RemoveFileName() const;\n\n  // Returns a copy of the FilePath with the case-insensitive extension removed.\n  // Example: FilePath(\"dir/file.exe\").RemoveExtension(\"EXE\") returns\n  // FilePath(\"dir/file\"). If a case-insensitive extension is not\n  // found, returns a copy of the original FilePath.\n  FilePath RemoveExtension(const char* extension) const;\n\n  // Creates directories so that path exists. Returns true if successful or if\n  // the directories already exist; returns false if unable to create\n  // directories for any reason. Will also return false if the FilePath does\n  // not represent a directory (that is, it doesn't end with a path separator).\n  bool CreateDirectoriesRecursively() const;\n\n  // Create the directory so that path exists. Returns true if successful or\n  // if the directory already exists; returns false if unable to create the\n  // directory for any reason, including if the parent directory does not\n  // exist. Not named \"CreateDirectory\" because that's a macro on Windows.\n  bool CreateFolder() const;\n\n  // Returns true if FilePath describes something in the file-system,\n  // either a file, directory, or whatever, and that something exists.\n  bool FileOrDirectoryExists() const;\n\n  // Returns true if pathname describes a directory in the file-system\n  // that exists.\n  bool DirectoryExists() const;\n\n  // Returns true if FilePath ends with a path separator, which indicates that\n  // it is intended to represent a directory. Returns false otherwise.\n  // This does NOT check that a directory (or file) actually exists.\n  bool IsDirectory() const;\n\n  // Returns true if pathname describes a root directory. (Windows has one\n  // root directory per disk drive.)\n  bool IsRootDirectory() const;\n\n  // Returns true if pathname describes an absolute path.\n  bool IsAbsolutePath() const;\n\n private:\n  // Replaces multiple consecutive separators with a single separator.\n  // For example, \"bar///foo\" becomes \"bar/foo\". Does not eliminate other\n  // redundancies that might be in a pathname involving \".\" or \"..\".\n  //\n  // A pathname with multiple consecutive separators may occur either through\n  // user error or as a result of some scripts or APIs that generate a pathname\n  // with a trailing separator. On other platforms the same API or script\n  // may NOT generate a pathname with a trailing \"/\". Then elsewhere that\n  // pathname may have another \"/\" and pathname components added to it,\n  // without checking for the separator already being there.\n  // The script language and operating system may allow paths like \"foo//bar\"\n  // but some of the functions in FilePath will not handle that correctly. In\n  // particular, RemoveTrailingPathSeparator() only removes one separator, and\n  // it is called in CreateDirectoriesRecursively() assuming that it will change\n  // a pathname from directory syntax (trailing separator) to filename syntax.\n  //\n  // On Windows this method also replaces the alternate path separator '/' with\n  // the primary path separator '\\\\', so that for example \"bar\\\\/\\\\foo\" becomes\n  // \"bar\\\\foo\".\n\n  void Normalize();\n\n  // Returns a pointer to the last occurence of a valid path separator in\n  // the FilePath. On Windows, for example, both '/' and '\\' are valid path\n  // separators. Returns NULL if no path separator was found.\n  const char* FindLastPathSeparator() const;\n\n  std::string pathname_;\n};  // class FilePath\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/gtest-internal.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This header file declares functions and macros used internally by\n// Google Test.  They are subject to change without notice.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_\n\n#include \"gtest/internal/gtest-port.h\"\n\n#if GTEST_OS_LINUX\n# include <stdlib.h>\n# include <sys/types.h>\n# include <sys/wait.h>\n# include <unistd.h>\n#endif  // GTEST_OS_LINUX\n\n#if GTEST_HAS_EXCEPTIONS\n# include <stdexcept>\n#endif\n\n#include <ctype.h>\n#include <float.h>\n#include <string.h>\n#include <iomanip>\n#include <limits>\n#include <map>\n#include <set>\n#include <string>\n#include <vector>\n\n#include \"gtest/gtest-message.h\"\n#include \"gtest/internal/gtest-string.h\"\n#include \"gtest/internal/gtest-filepath.h\"\n#include \"gtest/internal/gtest-type-util.h\"\n\n// Due to C++ preprocessor weirdness, we need double indirection to\n// concatenate two tokens when one of them is __LINE__.  Writing\n//\n//   foo ## __LINE__\n//\n// will result in the token foo__LINE__, instead of foo followed by\n// the current line number.  For more details, see\n// http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6\n#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)\n#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar\n\nclass ProtocolMessage;\nnamespace proto2 { class Message; }\n\nnamespace testing {\n\n// Forward declarations.\n\nclass AssertionResult;                 // Result of an assertion.\nclass Message;                         // Represents a failure message.\nclass Test;                            // Represents a test.\nclass TestInfo;                        // Information about a test.\nclass TestPartResult;                  // Result of a test part.\nclass UnitTest;                        // A collection of test cases.\n\ntemplate <typename T>\n::std::string PrintToString(const T& value);\n\nnamespace internal {\n\nstruct TraceInfo;                      // Information about a trace point.\nclass ScopedTrace;                     // Implements scoped trace.\nclass TestInfoImpl;                    // Opaque implementation of TestInfo\nclass UnitTestImpl;                    // Opaque implementation of UnitTest\n\n// The text used in failure messages to indicate the start of the\n// stack trace.\nGTEST_API_ extern const char kStackTraceMarker[];\n\n// Two overloaded helpers for checking at compile time whether an\n// expression is a null pointer literal (i.e. NULL or any 0-valued\n// compile-time integral constant).  Their return values have\n// different sizes, so we can use sizeof() to test which version is\n// picked by the compiler.  These helpers have no implementations, as\n// we only need their signatures.\n//\n// Given IsNullLiteralHelper(x), the compiler will pick the first\n// version if x can be implicitly converted to Secret*, and pick the\n// second version otherwise.  Since Secret is a secret and incomplete\n// type, the only expression a user can write that has type Secret* is\n// a null pointer literal.  Therefore, we know that x is a null\n// pointer literal if and only if the first version is picked by the\n// compiler.\nchar IsNullLiteralHelper(Secret* p);\nchar (&IsNullLiteralHelper(...))[2];  // NOLINT\n\n// A compile-time bool constant that is true if and only if x is a\n// null pointer literal (i.e. NULL or any 0-valued compile-time\n// integral constant).\n#ifdef GTEST_ELLIPSIS_NEEDS_POD_\n// We lose support for NULL detection where the compiler doesn't like\n// passing non-POD classes through ellipsis (...).\n# define GTEST_IS_NULL_LITERAL_(x) false\n#else\n# define GTEST_IS_NULL_LITERAL_(x) \\\n    (sizeof(::testing::internal::IsNullLiteralHelper(x)) == 1)\n#endif  // GTEST_ELLIPSIS_NEEDS_POD_\n\n// Appends the user-supplied message to the Google-Test-generated message.\nGTEST_API_ std::string AppendUserMessage(\n    const std::string& gtest_msg, const Message& user_msg);\n\n#if GTEST_HAS_EXCEPTIONS\n\n// This exception is thrown by (and only by) a failed Google Test\n// assertion when GTEST_FLAG(throw_on_failure) is true (if exceptions\n// are enabled).  We derive it from std::runtime_error, which is for\n// errors presumably detectable only at run time.  Since\n// std::runtime_error inherits from std::exception, many testing\n// frameworks know how to extract and print the message inside it.\nclass GTEST_API_ GoogleTestFailureException : public ::std::runtime_error {\n public:\n  explicit GoogleTestFailureException(const TestPartResult& failure);\n};\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// A helper class for creating scoped traces in user programs.\nclass GTEST_API_ ScopedTrace {\n public:\n  // The c'tor pushes the given source file location and message onto\n  // a trace stack maintained by Google Test.\n  ScopedTrace(const char* file, int line, const Message& message);\n\n  // The d'tor pops the info pushed by the c'tor.\n  //\n  // Note that the d'tor is not virtual in order to be efficient.\n  // Don't inherit from ScopedTrace!\n  ~ScopedTrace();\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);\n} GTEST_ATTRIBUTE_UNUSED_;  // A ScopedTrace object does its job in its\n                            // c'tor and d'tor.  Therefore it doesn't\n                            // need to be used otherwise.\n\nnamespace edit_distance {\n// Returns the optimal edits to go from 'left' to 'right'.\n// All edits cost the same, with replace having lower priority than\n// add/remove.\n// Simple implementation of the Wagner–Fischer algorithm.\n// See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm\nenum EditType { kMatch, kAdd, kRemove, kReplace };\nGTEST_API_ std::vector<EditType> CalculateOptimalEdits(\n    const std::vector<size_t>& left, const std::vector<size_t>& right);\n\n// Same as above, but the input is represented as strings.\nGTEST_API_ std::vector<EditType> CalculateOptimalEdits(\n    const std::vector<std::string>& left,\n    const std::vector<std::string>& right);\n\n// Create a diff of the input strings in Unified diff format.\nGTEST_API_ std::string CreateUnifiedDiff(const std::vector<std::string>& left,\n                                         const std::vector<std::string>& right,\n                                         size_t context = 2);\n\n}  // namespace edit_distance\n\n// Calculate the diff between 'left' and 'right' and return it in unified diff\n// format.\n// If not null, stores in 'total_line_count' the total number of lines found\n// in left + right.\nGTEST_API_ std::string DiffStrings(const std::string& left,\n                                   const std::string& right,\n                                   size_t* total_line_count);\n\n// Constructs and returns the message for an equality assertion\n// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.\n//\n// The first four parameters are the expressions used in the assertion\n// and their values, as strings.  For example, for ASSERT_EQ(foo, bar)\n// where foo is 5 and bar is 6, we have:\n//\n//   expected_expression: \"foo\"\n//   actual_expression:   \"bar\"\n//   expected_value:      \"5\"\n//   actual_value:        \"6\"\n//\n// The ignoring_case parameter is true iff the assertion is a\n// *_STRCASEEQ*.  When it's true, the string \" (ignoring case)\" will\n// be inserted into the message.\nGTEST_API_ AssertionResult EqFailure(const char* expected_expression,\n                                     const char* actual_expression,\n                                     const std::string& expected_value,\n                                     const std::string& actual_value,\n                                     bool ignoring_case);\n\n// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.\nGTEST_API_ std::string GetBoolAssertionFailureMessage(\n    const AssertionResult& assertion_result,\n    const char* expression_text,\n    const char* actual_predicate_value,\n    const char* expected_predicate_value);\n\n// This template class represents an IEEE floating-point number\n// (either single-precision or double-precision, depending on the\n// template parameters).\n//\n// The purpose of this class is to do more sophisticated number\n// comparison.  (Due to round-off error, etc, it's very unlikely that\n// two floating-points will be equal exactly.  Hence a naive\n// comparison by the == operation often doesn't work.)\n//\n// Format of IEEE floating-point:\n//\n//   The most-significant bit being the leftmost, an IEEE\n//   floating-point looks like\n//\n//     sign_bit exponent_bits fraction_bits\n//\n//   Here, sign_bit is a single bit that designates the sign of the\n//   number.\n//\n//   For float, there are 8 exponent bits and 23 fraction bits.\n//\n//   For double, there are 11 exponent bits and 52 fraction bits.\n//\n//   More details can be found at\n//   http://en.wikipedia.org/wiki/IEEE_floating-point_standard.\n//\n// Template parameter:\n//\n//   RawType: the raw floating-point type (either float or double)\ntemplate <typename RawType>\nclass FloatingPoint {\n public:\n  // Defines the unsigned integer type that has the same size as the\n  // floating point number.\n  typedef typename TypeWithSize<sizeof(RawType)>::UInt Bits;\n\n  // Constants.\n\n  // # of bits in a number.\n  static const size_t kBitCount = 8*sizeof(RawType);\n\n  // # of fraction bits in a number.\n  static const size_t kFractionBitCount =\n    std::numeric_limits<RawType>::digits - 1;\n\n  // # of exponent bits in a number.\n  static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount;\n\n  // The mask for the sign bit.\n  static const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1);\n\n  // The mask for the fraction bits.\n  static const Bits kFractionBitMask =\n    ~static_cast<Bits>(0) >> (kExponentBitCount + 1);\n\n  // The mask for the exponent bits.\n  static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask);\n\n  // How many ULP's (Units in the Last Place) we want to tolerate when\n  // comparing two numbers.  The larger the value, the more error we\n  // allow.  A 0 value means that two numbers must be exactly the same\n  // to be considered equal.\n  //\n  // The maximum error of a single floating-point operation is 0.5\n  // units in the last place.  On Intel CPU's, all floating-point\n  // calculations are done with 80-bit precision, while double has 64\n  // bits.  Therefore, 4 should be enough for ordinary use.\n  //\n  // See the following article for more details on ULP:\n  // http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/\n  static const size_t kMaxUlps = 4;\n\n  // Constructs a FloatingPoint from a raw floating-point number.\n  //\n  // On an Intel CPU, passing a non-normalized NAN (Not a Number)\n  // around may change its bits, although the new value is guaranteed\n  // to be also a NAN.  Therefore, don't expect this constructor to\n  // preserve the bits in x when x is a NAN.\n  explicit FloatingPoint(const RawType& x) { u_.value_ = x; }\n\n  // Static methods\n\n  // Reinterprets a bit pattern as a floating-point number.\n  //\n  // This function is needed to test the AlmostEquals() method.\n  static RawType ReinterpretBits(const Bits bits) {\n    FloatingPoint fp(0);\n    fp.u_.bits_ = bits;\n    return fp.u_.value_;\n  }\n\n  // Returns the floating-point number that represent positive infinity.\n  static RawType Infinity() {\n    return ReinterpretBits(kExponentBitMask);\n  }\n\n  // Returns the maximum representable finite floating-point number.\n  static RawType Max();\n\n  // Non-static methods\n\n  // Returns the bits that represents this number.\n  const Bits &bits() const { return u_.bits_; }\n\n  // Returns the exponent bits of this number.\n  Bits exponent_bits() const { return kExponentBitMask & u_.bits_; }\n\n  // Returns the fraction bits of this number.\n  Bits fraction_bits() const { return kFractionBitMask & u_.bits_; }\n\n  // Returns the sign bit of this number.\n  Bits sign_bit() const { return kSignBitMask & u_.bits_; }\n\n  // Returns true iff this is NAN (not a number).\n  bool is_nan() const {\n    // It's a NAN if the exponent bits are all ones and the fraction\n    // bits are not entirely zeros.\n    return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);\n  }\n\n  // Returns true iff this number is at most kMaxUlps ULP's away from\n  // rhs.  In particular, this function:\n  //\n  //   - returns false if either number is (or both are) NAN.\n  //   - treats really large numbers as almost equal to infinity.\n  //   - thinks +0.0 and -0.0 are 0 DLP's apart.\n  bool AlmostEquals(const FloatingPoint& rhs) const {\n    // The IEEE standard says that any comparison operation involving\n    // a NAN must return false.\n    if (is_nan() || rhs.is_nan()) return false;\n\n    return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)\n        <= kMaxUlps;\n  }\n\n private:\n  // The data type used to store the actual floating-point number.\n  union FloatingPointUnion {\n    RawType value_;  // The raw floating-point number.\n    Bits bits_;      // The bits that represent the number.\n  };\n\n  // Converts an integer from the sign-and-magnitude representation to\n  // the biased representation.  More precisely, let N be 2 to the\n  // power of (kBitCount - 1), an integer x is represented by the\n  // unsigned number x + N.\n  //\n  // For instance,\n  //\n  //   -N + 1 (the most negative number representable using\n  //          sign-and-magnitude) is represented by 1;\n  //   0      is represented by N; and\n  //   N - 1  (the biggest number representable using\n  //          sign-and-magnitude) is represented by 2N - 1.\n  //\n  // Read http://en.wikipedia.org/wiki/Signed_number_representations\n  // for more details on signed number representations.\n  static Bits SignAndMagnitudeToBiased(const Bits &sam) {\n    if (kSignBitMask & sam) {\n      // sam represents a negative number.\n      return ~sam + 1;\n    } else {\n      // sam represents a positive number.\n      return kSignBitMask | sam;\n    }\n  }\n\n  // Given two numbers in the sign-and-magnitude representation,\n  // returns the distance between them as an unsigned number.\n  static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1,\n                                                     const Bits &sam2) {\n    const Bits biased1 = SignAndMagnitudeToBiased(sam1);\n    const Bits biased2 = SignAndMagnitudeToBiased(sam2);\n    return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);\n  }\n\n  FloatingPointUnion u_;\n};\n\n// We cannot use std::numeric_limits<T>::max() as it clashes with the max()\n// macro defined by <windows.h>.\ntemplate <>\ninline float FloatingPoint<float>::Max() { return FLT_MAX; }\ntemplate <>\ninline double FloatingPoint<double>::Max() { return DBL_MAX; }\n\n// Typedefs the instances of the FloatingPoint template class that we\n// care to use.\ntypedef FloatingPoint<float> Float;\ntypedef FloatingPoint<double> Double;\n\n// In order to catch the mistake of putting tests that use different\n// test fixture classes in the same test case, we need to assign\n// unique IDs to fixture classes and compare them.  The TypeId type is\n// used to hold such IDs.  The user should treat TypeId as an opaque\n// type: the only operation allowed on TypeId values is to compare\n// them for equality using the == operator.\ntypedef const void* TypeId;\n\ntemplate <typename T>\nclass TypeIdHelper {\n public:\n  // dummy_ must not have a const type.  Otherwise an overly eager\n  // compiler (e.g. MSVC 7.1 & 8.0) may try to merge\n  // TypeIdHelper<T>::dummy_ for different Ts as an \"optimization\".\n  static bool dummy_;\n};\n\ntemplate <typename T>\nbool TypeIdHelper<T>::dummy_ = false;\n\n// GetTypeId<T>() returns the ID of type T.  Different values will be\n// returned for different types.  Calling the function twice with the\n// same type argument is guaranteed to return the same ID.\ntemplate <typename T>\nTypeId GetTypeId() {\n  // The compiler is required to allocate a different\n  // TypeIdHelper<T>::dummy_ variable for each T used to instantiate\n  // the template.  Therefore, the address of dummy_ is guaranteed to\n  // be unique.\n  return &(TypeIdHelper<T>::dummy_);\n}\n\n// Returns the type ID of ::testing::Test.  Always call this instead\n// of GetTypeId< ::testing::Test>() to get the type ID of\n// ::testing::Test, as the latter may give the wrong result due to a\n// suspected linker bug when compiling Google Test as a Mac OS X\n// framework.\nGTEST_API_ TypeId GetTestTypeId();\n\n// Defines the abstract factory interface that creates instances\n// of a Test object.\nclass TestFactoryBase {\n public:\n  virtual ~TestFactoryBase() {}\n\n  // Creates a test instance to run. The instance is both created and destroyed\n  // within TestInfoImpl::Run()\n  virtual Test* CreateTest() = 0;\n\n protected:\n  TestFactoryBase() {}\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestFactoryBase);\n};\n\n// This class provides implementation of TeastFactoryBase interface.\n// It is used in TEST and TEST_F macros.\ntemplate <class TestClass>\nclass TestFactoryImpl : public TestFactoryBase {\n public:\n  virtual Test* CreateTest() { return new TestClass; }\n};\n\n#if GTEST_OS_WINDOWS\n\n// Predicate-formatters for implementing the HRESULT checking macros\n// {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}\n// We pass a long instead of HRESULT to avoid causing an\n// include dependency for the HRESULT type.\nGTEST_API_ AssertionResult IsHRESULTSuccess(const char* expr,\n                                            long hr);  // NOLINT\nGTEST_API_ AssertionResult IsHRESULTFailure(const char* expr,\n                                            long hr);  // NOLINT\n\n#endif  // GTEST_OS_WINDOWS\n\n// Types of SetUpTestCase() and TearDownTestCase() functions.\ntypedef void (*SetUpTestCaseFunc)();\ntypedef void (*TearDownTestCaseFunc)();\n\nstruct CodeLocation {\n  CodeLocation(const string& a_file, int a_line) : file(a_file), line(a_line) {}\n\n  string file;\n  int line;\n};\n\n// Creates a new TestInfo object and registers it with Google Test;\n// returns the created object.\n//\n// Arguments:\n//\n//   test_case_name:   name of the test case\n//   name:             name of the test\n//   type_param        the name of the test's type parameter, or NULL if\n//                     this is not a typed or a type-parameterized test.\n//   value_param       text representation of the test's value parameter,\n//                     or NULL if this is not a type-parameterized test.\n//   code_location:    code location where the test is defined\n//   fixture_class_id: ID of the test fixture class\n//   set_up_tc:        pointer to the function that sets up the test case\n//   tear_down_tc:     pointer to the function that tears down the test case\n//   factory:          pointer to the factory that creates a test object.\n//                     The newly created TestInfo instance will assume\n//                     ownership of the factory object.\nGTEST_API_ TestInfo* MakeAndRegisterTestInfo(\n    const char* test_case_name,\n    const char* name,\n    const char* type_param,\n    const char* value_param,\n    CodeLocation code_location,\n    TypeId fixture_class_id,\n    SetUpTestCaseFunc set_up_tc,\n    TearDownTestCaseFunc tear_down_tc,\n    TestFactoryBase* factory);\n\n// If *pstr starts with the given prefix, modifies *pstr to be right\n// past the prefix and returns true; otherwise leaves *pstr unchanged\n// and returns false.  None of pstr, *pstr, and prefix can be NULL.\nGTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr);\n\n#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P\n\n// State of the definition of a type-parameterized test case.\nclass GTEST_API_ TypedTestCasePState {\n public:\n  TypedTestCasePState() : registered_(false) {}\n\n  // Adds the given test name to defined_test_names_ and return true\n  // if the test case hasn't been registered; otherwise aborts the\n  // program.\n  bool AddTestName(const char* file, int line, const char* case_name,\n                   const char* test_name) {\n    if (registered_) {\n      fprintf(stderr, \"%s Test %s must be defined before \"\n              \"REGISTER_TYPED_TEST_CASE_P(%s, ...).\\n\",\n              FormatFileLocation(file, line).c_str(), test_name, case_name);\n      fflush(stderr);\n      posix::Abort();\n    }\n    registered_tests_.insert(\n        ::std::make_pair(test_name, CodeLocation(file, line)));\n    return true;\n  }\n\n  bool TestExists(const std::string& test_name) const {\n    return registered_tests_.count(test_name) > 0;\n  }\n\n  const CodeLocation& GetCodeLocation(const std::string& test_name) const {\n    RegisteredTestsMap::const_iterator it = registered_tests_.find(test_name);\n    GTEST_CHECK_(it != registered_tests_.end());\n    return it->second;\n  }\n\n  // Verifies that registered_tests match the test names in\n  // defined_test_names_; returns registered_tests if successful, or\n  // aborts the program otherwise.\n  const char* VerifyRegisteredTestNames(\n      const char* file, int line, const char* registered_tests);\n\n private:\n  typedef ::std::map<std::string, CodeLocation> RegisteredTestsMap;\n\n  bool registered_;\n  RegisteredTestsMap registered_tests_;\n};\n\n// Skips to the first non-space char after the first comma in 'str';\n// returns NULL if no comma is found in 'str'.\ninline const char* SkipComma(const char* str) {\n  const char* comma = strchr(str, ',');\n  if (comma == NULL) {\n    return NULL;\n  }\n  while (IsSpace(*(++comma))) {}\n  return comma;\n}\n\n// Returns the prefix of 'str' before the first comma in it; returns\n// the entire string if it contains no comma.\ninline std::string GetPrefixUntilComma(const char* str) {\n  const char* comma = strchr(str, ',');\n  return comma == NULL ? str : std::string(str, comma);\n}\n\n// Splits a given string on a given delimiter, populating a given\n// vector with the fields.\nvoid SplitString(const ::std::string& str, char delimiter,\n                 ::std::vector< ::std::string>* dest);\n\n// TypeParameterizedTest<Fixture, TestSel, Types>::Register()\n// registers a list of type-parameterized tests with Google Test.  The\n// return value is insignificant - we just need to return something\n// such that we can call this function in a namespace scope.\n//\n// Implementation note: The GTEST_TEMPLATE_ macro declares a template\n// template parameter.  It's defined in gtest-type-util.h.\ntemplate <GTEST_TEMPLATE_ Fixture, class TestSel, typename Types>\nclass TypeParameterizedTest {\n public:\n  // 'index' is the index of the test in the type list 'Types'\n  // specified in INSTANTIATE_TYPED_TEST_CASE_P(Prefix, TestCase,\n  // Types).  Valid values for 'index' are [0, N - 1] where N is the\n  // length of Types.\n  static bool Register(const char* prefix,\n                       CodeLocation code_location,\n                       const char* case_name, const char* test_names,\n                       int index) {\n    typedef typename Types::Head Type;\n    typedef Fixture<Type> FixtureClass;\n    typedef typename GTEST_BIND_(TestSel, Type) TestClass;\n\n    // First, registers the first type-parameterized test in the type\n    // list.\n    MakeAndRegisterTestInfo(\n        (std::string(prefix) + (prefix[0] == '\\0' ? \"\" : \"/\") + case_name + \"/\"\n         + StreamableToString(index)).c_str(),\n        StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(),\n        GetTypeName<Type>().c_str(),\n        NULL,  // No value parameter.\n        code_location,\n        GetTypeId<FixtureClass>(),\n        TestClass::SetUpTestCase,\n        TestClass::TearDownTestCase,\n        new TestFactoryImpl<TestClass>);\n\n    // Next, recurses (at compile time) with the tail of the type list.\n    return TypeParameterizedTest<Fixture, TestSel, typename Types::Tail>\n        ::Register(prefix, code_location, case_name, test_names, index + 1);\n  }\n};\n\n// The base case for the compile time recursion.\ntemplate <GTEST_TEMPLATE_ Fixture, class TestSel>\nclass TypeParameterizedTest<Fixture, TestSel, Types0> {\n public:\n  static bool Register(const char* /*prefix*/, CodeLocation,\n                       const char* /*case_name*/, const char* /*test_names*/,\n                       int /*index*/) {\n    return true;\n  }\n};\n\n// TypeParameterizedTestCase<Fixture, Tests, Types>::Register()\n// registers *all combinations* of 'Tests' and 'Types' with Google\n// Test.  The return value is insignificant - we just need to return\n// something such that we can call this function in a namespace scope.\ntemplate <GTEST_TEMPLATE_ Fixture, typename Tests, typename Types>\nclass TypeParameterizedTestCase {\n public:\n  static bool Register(const char* prefix, CodeLocation code_location,\n                       const TypedTestCasePState* state,\n                       const char* case_name, const char* test_names) {\n    std::string test_name = StripTrailingSpaces(\n        GetPrefixUntilComma(test_names));\n    if (!state->TestExists(test_name)) {\n      fprintf(stderr, \"Failed to get code location for test %s.%s at %s.\",\n              case_name, test_name.c_str(),\n              FormatFileLocation(code_location.file.c_str(),\n                                 code_location.line).c_str());\n      fflush(stderr);\n      posix::Abort();\n    }\n    const CodeLocation& test_location = state->GetCodeLocation(test_name);\n\n    typedef typename Tests::Head Head;\n\n    // First, register the first test in 'Test' for each type in 'Types'.\n    TypeParameterizedTest<Fixture, Head, Types>::Register(\n        prefix, test_location, case_name, test_names, 0);\n\n    // Next, recurses (at compile time) with the tail of the test list.\n    return TypeParameterizedTestCase<Fixture, typename Tests::Tail, Types>\n        ::Register(prefix, code_location, state,\n                   case_name, SkipComma(test_names));\n  }\n};\n\n// The base case for the compile time recursion.\ntemplate <GTEST_TEMPLATE_ Fixture, typename Types>\nclass TypeParameterizedTestCase<Fixture, Templates0, Types> {\n public:\n  static bool Register(const char* /*prefix*/, CodeLocation,\n                       const TypedTestCasePState* /*state*/,\n                       const char* /*case_name*/, const char* /*test_names*/) {\n    return true;\n  }\n};\n\n#endif  // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P\n\n// Returns the current OS stack trace as an std::string.\n//\n// The maximum number of stack frames to be included is specified by\n// the gtest_stack_trace_depth flag.  The skip_count parameter\n// specifies the number of top frames to be skipped, which doesn't\n// count against the number of frames to be included.\n//\n// For example, if Foo() calls Bar(), which in turn calls\n// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in\n// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.\nGTEST_API_ std::string GetCurrentOsStackTraceExceptTop(\n    UnitTest* unit_test, int skip_count);\n\n// Helpers for suppressing warnings on unreachable code or constant\n// condition.\n\n// Always returns true.\nGTEST_API_ bool AlwaysTrue();\n\n// Always returns false.\ninline bool AlwaysFalse() { return !AlwaysTrue(); }\n\n// Helper for suppressing false warning from Clang on a const char*\n// variable declared in a conditional expression always being NULL in\n// the else branch.\nstruct GTEST_API_ ConstCharPtr {\n  ConstCharPtr(const char* str) : value(str) {}\n  operator bool() const { return true; }\n  const char* value;\n};\n\n// A simple Linear Congruential Generator for generating random\n// numbers with a uniform distribution.  Unlike rand() and srand(), it\n// doesn't use global state (and therefore can't interfere with user\n// code).  Unlike rand_r(), it's portable.  An LCG isn't very random,\n// but it's good enough for our purposes.\nclass GTEST_API_ Random {\n public:\n  static const UInt32 kMaxRange = 1u << 31;\n\n  explicit Random(UInt32 seed) : state_(seed) {}\n\n  void Reseed(UInt32 seed) { state_ = seed; }\n\n  // Generates a random number from [0, range).  Crashes if 'range' is\n  // 0 or greater than kMaxRange.\n  UInt32 Generate(UInt32 range);\n\n private:\n  UInt32 state_;\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Random);\n};\n\n// Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a\n// compiler error iff T1 and T2 are different types.\ntemplate <typename T1, typename T2>\nstruct CompileAssertTypesEqual;\n\ntemplate <typename T>\nstruct CompileAssertTypesEqual<T, T> {\n};\n\n// Removes the reference from a type if it is a reference type,\n// otherwise leaves it unchanged.  This is the same as\n// tr1::remove_reference, which is not widely available yet.\ntemplate <typename T>\nstruct RemoveReference { typedef T type; };  // NOLINT\ntemplate <typename T>\nstruct RemoveReference<T&> { typedef T type; };  // NOLINT\n\n// A handy wrapper around RemoveReference that works when the argument\n// T depends on template parameters.\n#define GTEST_REMOVE_REFERENCE_(T) \\\n    typename ::testing::internal::RemoveReference<T>::type\n\n// Removes const from a type if it is a const type, otherwise leaves\n// it unchanged.  This is the same as tr1::remove_const, which is not\n// widely available yet.\ntemplate <typename T>\nstruct RemoveConst { typedef T type; };  // NOLINT\ntemplate <typename T>\nstruct RemoveConst<const T> { typedef T type; };  // NOLINT\n\n// MSVC 8.0, Sun C++, and IBM XL C++ have a bug which causes the above\n// definition to fail to remove the const in 'const int[3]' and 'const\n// char[3][4]'.  The following specialization works around the bug.\ntemplate <typename T, size_t N>\nstruct RemoveConst<const T[N]> {\n  typedef typename RemoveConst<T>::type type[N];\n};\n\n#if defined(_MSC_VER) && _MSC_VER < 1400\n// This is the only specialization that allows VC++ 7.1 to remove const in\n// 'const int[3] and 'const int[3][4]'.  However, it causes trouble with GCC\n// and thus needs to be conditionally compiled.\ntemplate <typename T, size_t N>\nstruct RemoveConst<T[N]> {\n  typedef typename RemoveConst<T>::type type[N];\n};\n#endif\n\n// A handy wrapper around RemoveConst that works when the argument\n// T depends on template parameters.\n#define GTEST_REMOVE_CONST_(T) \\\n    typename ::testing::internal::RemoveConst<T>::type\n\n// Turns const U&, U&, const U, and U all into U.\n#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \\\n    GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))\n\n// Adds reference to a type if it is not a reference type,\n// otherwise leaves it unchanged.  This is the same as\n// tr1::add_reference, which is not widely available yet.\ntemplate <typename T>\nstruct AddReference { typedef T& type; };  // NOLINT\ntemplate <typename T>\nstruct AddReference<T&> { typedef T& type; };  // NOLINT\n\n// A handy wrapper around AddReference that works when the argument T\n// depends on template parameters.\n#define GTEST_ADD_REFERENCE_(T) \\\n    typename ::testing::internal::AddReference<T>::type\n\n// Adds a reference to const on top of T as necessary.  For example,\n// it transforms\n//\n//   char         ==> const char&\n//   const char   ==> const char&\n//   char&        ==> const char&\n//   const char&  ==> const char&\n//\n// The argument T must depend on some template parameters.\n#define GTEST_REFERENCE_TO_CONST_(T) \\\n    GTEST_ADD_REFERENCE_(const GTEST_REMOVE_REFERENCE_(T))\n\n// ImplicitlyConvertible<From, To>::value is a compile-time bool\n// constant that's true iff type From can be implicitly converted to\n// type To.\ntemplate <typename From, typename To>\nclass ImplicitlyConvertible {\n private:\n  // We need the following helper functions only for their types.\n  // They have no implementations.\n\n  // MakeFrom() is an expression whose type is From.  We cannot simply\n  // use From(), as the type From may not have a public default\n  // constructor.\n  static typename AddReference<From>::type MakeFrom();\n\n  // These two functions are overloaded.  Given an expression\n  // Helper(x), the compiler will pick the first version if x can be\n  // implicitly converted to type To; otherwise it will pick the\n  // second version.\n  //\n  // The first version returns a value of size 1, and the second\n  // version returns a value of size 2.  Therefore, by checking the\n  // size of Helper(x), which can be done at compile time, we can tell\n  // which version of Helper() is used, and hence whether x can be\n  // implicitly converted to type To.\n  static char Helper(To);\n  static char (&Helper(...))[2];  // NOLINT\n\n  // We have to put the 'public' section after the 'private' section,\n  // or MSVC refuses to compile the code.\n public:\n#if defined(__BORLANDC__)\n  // C++Builder cannot use member overload resolution during template\n  // instantiation.  The simplest workaround is to use its C++0x type traits\n  // functions (C++Builder 2009 and above only).\n  static const bool value = __is_convertible(From, To);\n#else\n  // MSVC warns about implicitly converting from double to int for\n  // possible loss of data, so we need to temporarily disable the\n  // warning.\n  GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244)\n  static const bool value =\n      sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1;\n  GTEST_DISABLE_MSC_WARNINGS_POP_()\n#endif  // __BORLANDC__\n};\ntemplate <typename From, typename To>\nconst bool ImplicitlyConvertible<From, To>::value;\n\n// IsAProtocolMessage<T>::value is a compile-time bool constant that's\n// true iff T is type ProtocolMessage, proto2::Message, or a subclass\n// of those.\ntemplate <typename T>\nstruct IsAProtocolMessage\n    : public bool_constant<\n  ImplicitlyConvertible<const T*, const ::ProtocolMessage*>::value ||\n  ImplicitlyConvertible<const T*, const ::proto2::Message*>::value> {\n};\n\n// When the compiler sees expression IsContainerTest<C>(0), if C is an\n// STL-style container class, the first overload of IsContainerTest\n// will be viable (since both C::iterator* and C::const_iterator* are\n// valid types and NULL can be implicitly converted to them).  It will\n// be picked over the second overload as 'int' is a perfect match for\n// the type of argument 0.  If C::iterator or C::const_iterator is not\n// a valid type, the first overload is not viable, and the second\n// overload will be picked.  Therefore, we can determine whether C is\n// a container class by checking the type of IsContainerTest<C>(0).\n// The value of the expression is insignificant.\n//\n// Note that we look for both C::iterator and C::const_iterator.  The\n// reason is that C++ injects the name of a class as a member of the\n// class itself (e.g. you can refer to class iterator as either\n// 'iterator' or 'iterator::iterator').  If we look for C::iterator\n// only, for example, we would mistakenly think that a class named\n// iterator is an STL container.\n//\n// Also note that the simpler approach of overloading\n// IsContainerTest(typename C::const_iterator*) and\n// IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++.\ntypedef int IsContainer;\ntemplate <class C>\nIsContainer IsContainerTest(int /* dummy */,\n                            typename C::iterator* /* it */ = NULL,\n                            typename C::const_iterator* /* const_it */ = NULL) {\n  return 0;\n}\n\ntypedef char IsNotContainer;\ntemplate <class C>\nIsNotContainer IsContainerTest(long /* dummy */) { return '\\0'; }\n\n// EnableIf<condition>::type is void when 'Cond' is true, and\n// undefined when 'Cond' is false.  To use SFINAE to make a function\n// overload only apply when a particular expression is true, add\n// \"typename EnableIf<expression>::type* = 0\" as the last parameter.\ntemplate<bool> struct EnableIf;\ntemplate<> struct EnableIf<true> { typedef void type; };  // NOLINT\n\n// Utilities for native arrays.\n\n// ArrayEq() compares two k-dimensional native arrays using the\n// elements' operator==, where k can be any integer >= 0.  When k is\n// 0, ArrayEq() degenerates into comparing a single pair of values.\n\ntemplate <typename T, typename U>\nbool ArrayEq(const T* lhs, size_t size, const U* rhs);\n\n// This generic version is used when k is 0.\ntemplate <typename T, typename U>\ninline bool ArrayEq(const T& lhs, const U& rhs) { return lhs == rhs; }\n\n// This overload is used when k >= 1.\ntemplate <typename T, typename U, size_t N>\ninline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) {\n  return internal::ArrayEq(lhs, N, rhs);\n}\n\n// This helper reduces code bloat.  If we instead put its logic inside\n// the previous ArrayEq() function, arrays with different sizes would\n// lead to different copies of the template code.\ntemplate <typename T, typename U>\nbool ArrayEq(const T* lhs, size_t size, const U* rhs) {\n  for (size_t i = 0; i != size; i++) {\n    if (!internal::ArrayEq(lhs[i], rhs[i]))\n      return false;\n  }\n  return true;\n}\n\n// Finds the first element in the iterator range [begin, end) that\n// equals elem.  Element may be a native array type itself.\ntemplate <typename Iter, typename Element>\nIter ArrayAwareFind(Iter begin, Iter end, const Element& elem) {\n  for (Iter it = begin; it != end; ++it) {\n    if (internal::ArrayEq(*it, elem))\n      return it;\n  }\n  return end;\n}\n\n// CopyArray() copies a k-dimensional native array using the elements'\n// operator=, where k can be any integer >= 0.  When k is 0,\n// CopyArray() degenerates into copying a single value.\n\ntemplate <typename T, typename U>\nvoid CopyArray(const T* from, size_t size, U* to);\n\n// This generic version is used when k is 0.\ntemplate <typename T, typename U>\ninline void CopyArray(const T& from, U* to) { *to = from; }\n\n// This overload is used when k >= 1.\ntemplate <typename T, typename U, size_t N>\ninline void CopyArray(const T(&from)[N], U(*to)[N]) {\n  internal::CopyArray(from, N, *to);\n}\n\n// This helper reduces code bloat.  If we instead put its logic inside\n// the previous CopyArray() function, arrays with different sizes\n// would lead to different copies of the template code.\ntemplate <typename T, typename U>\nvoid CopyArray(const T* from, size_t size, U* to) {\n  for (size_t i = 0; i != size; i++) {\n    internal::CopyArray(from[i], to + i);\n  }\n}\n\n// The relation between an NativeArray object (see below) and the\n// native array it represents.\n// We use 2 different structs to allow non-copyable types to be used, as long\n// as RelationToSourceReference() is passed.\nstruct RelationToSourceReference {};\nstruct RelationToSourceCopy {};\n\n// Adapts a native array to a read-only STL-style container.  Instead\n// of the complete STL container concept, this adaptor only implements\n// members useful for Google Mock's container matchers.  New members\n// should be added as needed.  To simplify the implementation, we only\n// support Element being a raw type (i.e. having no top-level const or\n// reference modifier).  It's the client's responsibility to satisfy\n// this requirement.  Element can be an array type itself (hence\n// multi-dimensional arrays are supported).\ntemplate <typename Element>\nclass NativeArray {\n public:\n  // STL-style container typedefs.\n  typedef Element value_type;\n  typedef Element* iterator;\n  typedef const Element* const_iterator;\n\n  // Constructs from a native array. References the source.\n  NativeArray(const Element* array, size_t count, RelationToSourceReference) {\n    InitRef(array, count);\n  }\n\n  // Constructs from a native array. Copies the source.\n  NativeArray(const Element* array, size_t count, RelationToSourceCopy) {\n    InitCopy(array, count);\n  }\n\n  // Copy constructor.\n  NativeArray(const NativeArray& rhs) {\n    (this->*rhs.clone_)(rhs.array_, rhs.size_);\n  }\n\n  ~NativeArray() {\n    if (clone_ != &NativeArray::InitRef)\n      delete[] array_;\n  }\n\n  // STL-style container methods.\n  size_t size() const { return size_; }\n  const_iterator begin() const { return array_; }\n  const_iterator end() const { return array_ + size_; }\n  bool operator==(const NativeArray& rhs) const {\n    return size() == rhs.size() &&\n        ArrayEq(begin(), size(), rhs.begin());\n  }\n\n private:\n  enum {\n    kCheckTypeIsNotConstOrAReference = StaticAssertTypeEqHelper<\n        Element, GTEST_REMOVE_REFERENCE_AND_CONST_(Element)>::value,\n  };\n\n  // Initializes this object with a copy of the input.\n  void InitCopy(const Element* array, size_t a_size) {\n    Element* const copy = new Element[a_size];\n    CopyArray(array, a_size, copy);\n    array_ = copy;\n    size_ = a_size;\n    clone_ = &NativeArray::InitCopy;\n  }\n\n  // Initializes this object with a reference of the input.\n  void InitRef(const Element* array, size_t a_size) {\n    array_ = array;\n    size_ = a_size;\n    clone_ = &NativeArray::InitRef;\n  }\n\n  const Element* array_;\n  size_t size_;\n  void (NativeArray::*clone_)(const Element*, size_t);\n\n  GTEST_DISALLOW_ASSIGN_(NativeArray);\n};\n\n}  // namespace internal\n}  // namespace testing\n\n#define GTEST_MESSAGE_AT_(file, line, message, result_type) \\\n  ::testing::internal::AssertHelper(result_type, file, line, message) \\\n    = ::testing::Message()\n\n#define GTEST_MESSAGE_(message, result_type) \\\n  GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type)\n\n#define GTEST_FATAL_FAILURE_(message) \\\n  return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure)\n\n#define GTEST_NONFATAL_FAILURE_(message) \\\n  GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure)\n\n#define GTEST_SUCCESS_(message) \\\n  GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)\n\n// Suppresses MSVC warnings 4072 (unreachable code) for the code following\n// statement if it returns or throws (or doesn't return or throw in some\n// situations).\n#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \\\n  if (::testing::internal::AlwaysTrue()) { statement; }\n\n#define GTEST_TEST_THROW_(statement, expected_exception, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (::testing::internal::ConstCharPtr gtest_msg = \"\") { \\\n    bool gtest_caught_expected = false; \\\n    try { \\\n      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n    } \\\n    catch (expected_exception const&) { \\\n      gtest_caught_expected = true; \\\n    } \\\n    catch (...) { \\\n      gtest_msg.value = \\\n          \"Expected: \" #statement \" throws an exception of type \" \\\n          #expected_exception \".\\n  Actual: it throws a different type.\"; \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \\\n    } \\\n    if (!gtest_caught_expected) { \\\n      gtest_msg.value = \\\n          \"Expected: \" #statement \" throws an exception of type \" \\\n          #expected_exception \".\\n  Actual: it throws nothing.\"; \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \\\n    } \\\n  } else \\\n    GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \\\n      fail(gtest_msg.value)\n\n#define GTEST_TEST_NO_THROW_(statement, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (::testing::internal::AlwaysTrue()) { \\\n    try { \\\n      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n    } \\\n    catch (...) { \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \\\n    } \\\n  } else \\\n    GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \\\n      fail(\"Expected: \" #statement \" doesn't throw an exception.\\n\" \\\n           \"  Actual: it throws.\")\n\n#define GTEST_TEST_ANY_THROW_(statement, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (::testing::internal::AlwaysTrue()) { \\\n    bool gtest_caught_any = false; \\\n    try { \\\n      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n    } \\\n    catch (...) { \\\n      gtest_caught_any = true; \\\n    } \\\n    if (!gtest_caught_any) { \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \\\n    } \\\n  } else \\\n    GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \\\n      fail(\"Expected: \" #statement \" throws an exception.\\n\" \\\n           \"  Actual: it doesn't.\")\n\n\n// Implements Boolean test assertions such as EXPECT_TRUE. expression can be\n// either a boolean expression or an AssertionResult. text is a textual\n// represenation of expression as it was passed into the EXPECT_TRUE.\n#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (const ::testing::AssertionResult gtest_ar_ = \\\n      ::testing::AssertionResult(expression)) \\\n    ; \\\n  else \\\n    fail(::testing::internal::GetBoolAssertionFailureMessage(\\\n        gtest_ar_, text, #actual, #expected).c_str())\n\n#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (::testing::internal::AlwaysTrue()) { \\\n    ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \\\n    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n    if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \\\n    } \\\n  } else \\\n    GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \\\n      fail(\"Expected: \" #statement \" doesn't generate new fatal \" \\\n           \"failures in the current thread.\\n\" \\\n           \"  Actual: it does.\")\n\n// Expands to the name of the class that implements the given test.\n#define GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \\\n  test_case_name##_##test_name##_Test\n\n// Helper macro for defining tests.\n#define GTEST_TEST_(test_case_name, test_name, parent_class, parent_id)\\\nclass GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\\\n public:\\\n  GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\\\n private:\\\n  virtual void TestBody();\\\n  static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\\\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(\\\n      GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\\\n};\\\n\\\n::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\\\n  ::test_info_ =\\\n    ::testing::internal::MakeAndRegisterTestInfo(\\\n        #test_case_name, #test_name, NULL, NULL, \\\n        ::testing::internal::CodeLocation(__FILE__, __LINE__), \\\n        (parent_id), \\\n        parent_class::SetUpTestCase, \\\n        parent_class::TearDownTestCase, \\\n        new ::testing::internal::TestFactoryImpl<\\\n            GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\\\nvoid GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_\n\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/gtest-linked_ptr.h",
    "content": "// Copyright 2003 Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: Dan Egnor (egnor@google.com)\n//\n// A \"smart\" pointer type with reference tracking.  Every pointer to a\n// particular object is kept on a circular linked list.  When the last pointer\n// to an object is destroyed or reassigned, the object is deleted.\n//\n// Used properly, this deletes the object when the last reference goes away.\n// There are several caveats:\n// - Like all reference counting schemes, cycles lead to leaks.\n// - Each smart pointer is actually two pointers (8 bytes instead of 4).\n// - Every time a pointer is assigned, the entire list of pointers to that\n//   object is traversed.  This class is therefore NOT SUITABLE when there\n//   will often be more than two or three pointers to a particular object.\n// - References are only tracked as long as linked_ptr<> objects are copied.\n//   If a linked_ptr<> is converted to a raw pointer and back, BAD THINGS\n//   will happen (double deletion).\n//\n// A good use of this class is storing object references in STL containers.\n// You can safely put linked_ptr<> in a vector<>.\n// Other uses may not be as good.\n//\n// Note: If you use an incomplete type with linked_ptr<>, the class\n// *containing* linked_ptr<> must have a constructor and destructor (even\n// if they do nothing!).\n//\n// Bill Gibbons suggested we use something like this.\n//\n// Thread Safety:\n//   Unlike other linked_ptr implementations, in this implementation\n//   a linked_ptr object is thread-safe in the sense that:\n//     - it's safe to copy linked_ptr objects concurrently,\n//     - it's safe to copy *from* a linked_ptr and read its underlying\n//       raw pointer (e.g. via get()) concurrently, and\n//     - it's safe to write to two linked_ptrs that point to the same\n//       shared object concurrently.\n// TODO(wan@google.com): rename this to safe_linked_ptr to avoid\n// confusion with normal linked_ptr.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_\n\n#include <stdlib.h>\n#include <assert.h>\n\n#include \"gtest/internal/gtest-port.h\"\n\nnamespace testing {\nnamespace internal {\n\n// Protects copying of all linked_ptr objects.\nGTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_linked_ptr_mutex);\n\n// This is used internally by all instances of linked_ptr<>.  It needs to be\n// a non-template class because different types of linked_ptr<> can refer to\n// the same object (linked_ptr<Superclass>(obj) vs linked_ptr<Subclass>(obj)).\n// So, it needs to be possible for different types of linked_ptr to participate\n// in the same circular linked list, so we need a single class type here.\n//\n// DO NOT USE THIS CLASS DIRECTLY YOURSELF.  Use linked_ptr<T>.\nclass linked_ptr_internal {\n public:\n  // Create a new circle that includes only this instance.\n  void join_new() {\n    next_ = this;\n  }\n\n  // Many linked_ptr operations may change p.link_ for some linked_ptr\n  // variable p in the same circle as this object.  Therefore we need\n  // to prevent two such operations from occurring concurrently.\n  //\n  // Note that different types of linked_ptr objects can coexist in a\n  // circle (e.g. linked_ptr<Base>, linked_ptr<Derived1>, and\n  // linked_ptr<Derived2>).  Therefore we must use a single mutex to\n  // protect all linked_ptr objects.  This can create serious\n  // contention in production code, but is acceptable in a testing\n  // framework.\n\n  // Join an existing circle.\n  void join(linked_ptr_internal const* ptr)\n      GTEST_LOCK_EXCLUDED_(g_linked_ptr_mutex) {\n    MutexLock lock(&g_linked_ptr_mutex);\n\n    linked_ptr_internal const* p = ptr;\n    while (p->next_ != ptr) {\n      assert(p->next_ != this &&\n             \"Trying to join() a linked ring we are already in. \"\n             \"Is GMock thread safety enabled?\");\n      p = p->next_;\n    }\n    p->next_ = this;\n    next_ = ptr;\n  }\n\n  // Leave whatever circle we're part of.  Returns true if we were the\n  // last member of the circle.  Once this is done, you can join() another.\n  bool depart()\n      GTEST_LOCK_EXCLUDED_(g_linked_ptr_mutex) {\n    MutexLock lock(&g_linked_ptr_mutex);\n\n    if (next_ == this) return true;\n    linked_ptr_internal const* p = next_;\n    while (p->next_ != this) {\n      assert(p->next_ != next_ &&\n             \"Trying to depart() a linked ring we are not in. \"\n             \"Is GMock thread safety enabled?\");\n      p = p->next_;\n    }\n    p->next_ = next_;\n    return false;\n  }\n\n private:\n  mutable linked_ptr_internal const* next_;\n};\n\ntemplate <typename T>\nclass linked_ptr {\n public:\n  typedef T element_type;\n\n  // Take over ownership of a raw pointer.  This should happen as soon as\n  // possible after the object is created.\n  explicit linked_ptr(T* ptr = NULL) { capture(ptr); }\n  ~linked_ptr() { depart(); }\n\n  // Copy an existing linked_ptr<>, adding ourselves to the list of references.\n  template <typename U> linked_ptr(linked_ptr<U> const& ptr) { copy(&ptr); }\n  linked_ptr(linked_ptr const& ptr) {  // NOLINT\n    assert(&ptr != this);\n    copy(&ptr);\n  }\n\n  // Assignment releases the old value and acquires the new.\n  template <typename U> linked_ptr& operator=(linked_ptr<U> const& ptr) {\n    depart();\n    copy(&ptr);\n    return *this;\n  }\n\n  linked_ptr& operator=(linked_ptr const& ptr) {\n    if (&ptr != this) {\n      depart();\n      copy(&ptr);\n    }\n    return *this;\n  }\n\n  // Smart pointer members.\n  void reset(T* ptr = NULL) {\n    depart();\n    capture(ptr);\n  }\n  T* get() const { return value_; }\n  T* operator->() const { return value_; }\n  T& operator*() const { return *value_; }\n\n  bool operator==(T* p) const { return value_ == p; }\n  bool operator!=(T* p) const { return value_ != p; }\n  template <typename U>\n  bool operator==(linked_ptr<U> const& ptr) const {\n    return value_ == ptr.get();\n  }\n  template <typename U>\n  bool operator!=(linked_ptr<U> const& ptr) const {\n    return value_ != ptr.get();\n  }\n\n private:\n  template <typename U>\n  friend class linked_ptr;\n\n  T* value_;\n  linked_ptr_internal link_;\n\n  void depart() {\n    if (link_.depart()) delete value_;\n  }\n\n  void capture(T* ptr) {\n    value_ = ptr;\n    link_.join_new();\n  }\n\n  template <typename U> void copy(linked_ptr<U> const* ptr) {\n    value_ = ptr->get();\n    if (value_)\n      link_.join(&ptr->link_);\n    else\n      link_.join_new();\n  }\n};\n\ntemplate<typename T> inline\nbool operator==(T* ptr, const linked_ptr<T>& x) {\n  return ptr == x.get();\n}\n\ntemplate<typename T> inline\nbool operator!=(T* ptr, const linked_ptr<T>& x) {\n  return ptr != x.get();\n}\n\n// A function to convert T* into linked_ptr<T>\n// Doing e.g. make_linked_ptr(new FooBarBaz<type>(arg)) is a shorter notation\n// for linked_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))\ntemplate <typename T>\nlinked_ptr<T> make_linked_ptr(T* ptr) {\n  return linked_ptr<T>(ptr);\n}\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/gtest-param-util-generated.h",
    "content": "// This file was GENERATED by command:\n//     pump.py gtest-param-util-generated.h.pump\n// DO NOT EDIT BY HAND!!!\n\n// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// Type and function utilities for implementing parameterized tests.\n// This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!\n//\n// Currently Google Test supports at most 50 arguments in Values,\n// and at most 10 arguments in Combine. Please contact\n// googletestframework@googlegroups.com if you need more.\n// Please note that the number of arguments to Combine is limited\n// by the maximum arity of the implementation of tuple which is\n// currently set at 10.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_\n\n// scripts/fuse_gtest.py depends on gtest's own header being #included\n// *unconditionally*.  Therefore these #includes cannot be moved\n// inside #if GTEST_HAS_PARAM_TEST.\n#include \"gtest/internal/gtest-param-util.h\"\n#include \"gtest/internal/gtest-port.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\nnamespace testing {\n\n// Forward declarations of ValuesIn(), which is implemented in\n// include/gtest/gtest-param-test.h.\ntemplate <typename ForwardIterator>\ninternal::ParamGenerator<\n  typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>\nValuesIn(ForwardIterator begin, ForwardIterator end);\n\ntemplate <typename T, size_t N>\ninternal::ParamGenerator<T> ValuesIn(const T (&array)[N]);\n\ntemplate <class Container>\ninternal::ParamGenerator<typename Container::value_type> ValuesIn(\n    const Container& container);\n\nnamespace internal {\n\n// Used in the Values() function to provide polymorphic capabilities.\ntemplate <typename T1>\nclass ValueArray1 {\n public:\n  explicit ValueArray1(T1 v1) : v1_(v1) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray1& other);\n\n  const T1 v1_;\n};\n\ntemplate <typename T1, typename T2>\nclass ValueArray2 {\n public:\n  ValueArray2(T1 v1, T2 v2) : v1_(v1), v2_(v2) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray2& other);\n\n  const T1 v1_;\n  const T2 v2_;\n};\n\ntemplate <typename T1, typename T2, typename T3>\nclass ValueArray3 {\n public:\n  ValueArray3(T1 v1, T2 v2, T3 v3) : v1_(v1), v2_(v2), v3_(v3) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray3& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4>\nclass ValueArray4 {\n public:\n  ValueArray4(T1 v1, T2 v2, T3 v3, T4 v4) : v1_(v1), v2_(v2), v3_(v3),\n      v4_(v4) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray4& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\nclass ValueArray5 {\n public:\n  ValueArray5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) : v1_(v1), v2_(v2), v3_(v3),\n      v4_(v4), v5_(v5) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray5& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6>\nclass ValueArray6 {\n public:\n  ValueArray6(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) : v1_(v1), v2_(v2),\n      v3_(v3), v4_(v4), v5_(v5), v6_(v6) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray6& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7>\nclass ValueArray7 {\n public:\n  ValueArray7(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) : v1_(v1),\n      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray7& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8>\nclass ValueArray8 {\n public:\n  ValueArray8(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,\n      T8 v8) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray8& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9>\nclass ValueArray9 {\n public:\n  ValueArray9(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,\n      T9 v9) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray9& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10>\nclass ValueArray10 {\n public:\n  ValueArray10(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray10& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11>\nclass ValueArray11 {\n public:\n  ValueArray11(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),\n      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray11& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12>\nclass ValueArray12 {\n public:\n  ValueArray12(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),\n      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray12& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13>\nclass ValueArray13 {\n public:\n  ValueArray13(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),\n      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),\n      v12_(v12), v13_(v13) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray13& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14>\nclass ValueArray14 {\n public:\n  ValueArray14(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) : v1_(v1), v2_(v2), v3_(v3),\n      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray14& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15>\nclass ValueArray15 {\n public:\n  ValueArray15(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) : v1_(v1), v2_(v2),\n      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray15& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16>\nclass ValueArray16 {\n public:\n  ValueArray16(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16) : v1_(v1),\n      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),\n      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),\n      v16_(v16) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray16& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17>\nclass ValueArray17 {\n public:\n  ValueArray17(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,\n      T17 v17) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray17& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18>\nclass ValueArray18 {\n public:\n  ValueArray18(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray18& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19>\nclass ValueArray19 {\n public:\n  ValueArray19(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),\n      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),\n      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray19& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20>\nclass ValueArray20 {\n public:\n  ValueArray20(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),\n      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),\n      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),\n      v19_(v19), v20_(v20) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray20& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21>\nclass ValueArray21 {\n public:\n  ValueArray21(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),\n      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),\n      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),\n      v18_(v18), v19_(v19), v20_(v20), v21_(v21) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray21& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22>\nclass ValueArray22 {\n public:\n  ValueArray22(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22) : v1_(v1), v2_(v2), v3_(v3),\n      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray22& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23>\nclass ValueArray23 {\n public:\n  ValueArray23(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23) : v1_(v1), v2_(v2),\n      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),\n      v23_(v23) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray23& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24>\nclass ValueArray24 {\n public:\n  ValueArray24(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24) : v1_(v1),\n      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),\n      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),\n      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),\n      v22_(v22), v23_(v23), v24_(v24) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray24& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25>\nclass ValueArray25 {\n public:\n  ValueArray25(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,\n      T25 v25) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray25& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26>\nclass ValueArray26 {\n public:\n  ValueArray26(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray26& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27>\nclass ValueArray27 {\n public:\n  ValueArray27(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),\n      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),\n      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19),\n      v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25),\n      v26_(v26), v27_(v27) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray27& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28>\nclass ValueArray28 {\n public:\n  ValueArray28(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),\n      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),\n      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),\n      v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24),\n      v25_(v25), v26_(v26), v27_(v27), v28_(v28) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray28& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29>\nclass ValueArray29 {\n public:\n  ValueArray29(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),\n      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),\n      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),\n      v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23),\n      v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray29& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30>\nclass ValueArray30 {\n public:\n  ValueArray30(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30) : v1_(v1), v2_(v2), v3_(v3),\n      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),\n      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),\n      v29_(v29), v30_(v30) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray30& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31>\nclass ValueArray31 {\n public:\n  ValueArray31(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31) : v1_(v1), v2_(v2),\n      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),\n      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),\n      v29_(v29), v30_(v30), v31_(v31) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray31& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32>\nclass ValueArray32 {\n public:\n  ValueArray32(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32) : v1_(v1),\n      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),\n      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),\n      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),\n      v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27),\n      v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray32& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33>\nclass ValueArray33 {\n public:\n  ValueArray33(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32,\n      T33 v33) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),\n      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),\n      v33_(v33) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray33& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34>\nclass ValueArray34 {\n public:\n  ValueArray34(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),\n      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),\n      v33_(v33), v34_(v34) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray34& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35>\nclass ValueArray35 {\n public:\n  ValueArray35(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),\n      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),\n      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19),\n      v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25),\n      v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31),\n      v32_(v32), v33_(v33), v34_(v34), v35_(v35) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray35& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36>\nclass ValueArray36 {\n public:\n  ValueArray36(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),\n      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),\n      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),\n      v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24),\n      v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30),\n      v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray36& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37>\nclass ValueArray37 {\n public:\n  ValueArray37(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),\n      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),\n      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),\n      v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23),\n      v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29),\n      v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35),\n      v36_(v36), v37_(v37) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray37& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38>\nclass ValueArray38 {\n public:\n  ValueArray38(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38) : v1_(v1), v2_(v2), v3_(v3),\n      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),\n      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),\n      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),\n      v35_(v35), v36_(v36), v37_(v37), v38_(v38) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray38& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39>\nclass ValueArray39 {\n public:\n  ValueArray39(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39) : v1_(v1), v2_(v2),\n      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),\n      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),\n      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),\n      v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray39& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40>\nclass ValueArray40 {\n public:\n  ValueArray40(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40) : v1_(v1),\n      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),\n      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),\n      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),\n      v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27),\n      v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33),\n      v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39),\n      v40_(v40) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray40& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41>\nclass ValueArray41 {\n public:\n  ValueArray41(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40,\n      T41 v41) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),\n      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),\n      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),\n      v39_(v39), v40_(v40), v41_(v41) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray41& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42>\nclass ValueArray42 {\n public:\n  ValueArray42(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),\n      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),\n      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),\n      v39_(v39), v40_(v40), v41_(v41), v42_(v42) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray42& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43>\nclass ValueArray43 {\n public:\n  ValueArray43(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),\n      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),\n      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19),\n      v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25),\n      v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31),\n      v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37),\n      v38_(v38), v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray43& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44>\nclass ValueArray44 {\n public:\n  ValueArray44(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43, T44 v44) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),\n      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),\n      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),\n      v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24),\n      v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30),\n      v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36),\n      v37_(v37), v38_(v38), v39_(v39), v40_(v40), v41_(v41), v42_(v42),\n      v43_(v43), v44_(v44) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray44& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n  const T44 v44_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45>\nclass ValueArray45 {\n public:\n  ValueArray45(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43, T44 v44, T45 v45) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),\n      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),\n      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),\n      v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23),\n      v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29),\n      v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35),\n      v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40), v41_(v41),\n      v42_(v42), v43_(v43), v44_(v44), v45_(v45) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),\n        static_cast<T>(v45_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray45& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n  const T44 v44_;\n  const T45 v45_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46>\nclass ValueArray46 {\n public:\n  ValueArray46(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46) : v1_(v1), v2_(v2), v3_(v3),\n      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),\n      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),\n      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),\n      v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40),\n      v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45), v46_(v46) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),\n        static_cast<T>(v45_), static_cast<T>(v46_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray46& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n  const T44 v44_;\n  const T45 v45_;\n  const T46 v46_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47>\nclass ValueArray47 {\n public:\n  ValueArray47(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47) : v1_(v1), v2_(v2),\n      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),\n      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),\n      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),\n      v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40),\n      v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45), v46_(v46),\n      v47_(v47) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),\n        static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray47& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n  const T44 v44_;\n  const T45 v45_;\n  const T46 v46_;\n  const T47 v47_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48>\nclass ValueArray48 {\n public:\n  ValueArray48(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48) : v1_(v1),\n      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),\n      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),\n      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),\n      v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27),\n      v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33),\n      v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39),\n      v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45),\n      v46_(v46), v47_(v47), v48_(v48) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),\n        static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_),\n        static_cast<T>(v48_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray48& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n  const T44 v44_;\n  const T45 v45_;\n  const T46 v46_;\n  const T47 v47_;\n  const T48 v48_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49>\nclass ValueArray49 {\n public:\n  ValueArray49(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48,\n      T49 v49) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),\n      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),\n      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),\n      v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44),\n      v45_(v45), v46_(v46), v47_(v47), v48_(v48), v49_(v49) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),\n        static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_),\n        static_cast<T>(v48_), static_cast<T>(v49_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray49& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n  const T44 v44_;\n  const T45 v45_;\n  const T46 v46_;\n  const T47 v47_;\n  const T48 v48_;\n  const T49 v49_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49, typename T50>\nclass ValueArray50 {\n public:\n  ValueArray50(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48, T49 v49,\n      T50 v50) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),\n      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),\n      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),\n      v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44),\n      v45_(v45), v46_(v46), v47_(v47), v48_(v48), v49_(v49), v50_(v50) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),\n        static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_),\n        static_cast<T>(v48_), static_cast<T>(v49_), static_cast<T>(v50_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray50& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n  const T44 v44_;\n  const T45 v45_;\n  const T46 v46_;\n  const T47 v47_;\n  const T48 v48_;\n  const T49 v49_;\n  const T50 v50_;\n};\n\n# if GTEST_HAS_COMBINE\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Generates values from the Cartesian product of values produced\n// by the argument generators.\n//\ntemplate <typename T1, typename T2>\nclass CartesianProductGenerator2\n    : public ParamGeneratorInterface< ::testing::tuple<T1, T2> > {\n public:\n  typedef ::testing::tuple<T1, T2> ParamType;\n\n  CartesianProductGenerator2(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2)\n      : g1_(g1), g2_(g2) {}\n  virtual ~CartesianProductGenerator2() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current2_;\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator2::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator2& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n};  // class CartesianProductGenerator2\n\n\ntemplate <typename T1, typename T2, typename T3>\nclass CartesianProductGenerator3\n    : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3> > {\n public:\n  typedef ::testing::tuple<T1, T2, T3> ParamType;\n\n  CartesianProductGenerator3(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3)\n      : g1_(g1), g2_(g2), g3_(g3) {}\n  virtual ~CartesianProductGenerator3() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current3_;\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator3::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator3& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n};  // class CartesianProductGenerator3\n\n\ntemplate <typename T1, typename T2, typename T3, typename T4>\nclass CartesianProductGenerator4\n    : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4> > {\n public:\n  typedef ::testing::tuple<T1, T2, T3, T4> ParamType;\n\n  CartesianProductGenerator4(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,\n      const ParamGenerator<T4>& g4)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {}\n  virtual ~CartesianProductGenerator4() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin(), g4_, g4_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),\n        g4_, g4_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3,\n      const ParamGenerator<T4>& g4,\n      const typename ParamGenerator<T4>::iterator& current4)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),\n          begin4_(g4.begin()), end4_(g4.end()), current4_(current4)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current4_;\n      if (current4_ == end4_) {\n        current4_ = begin4_;\n        ++current3_;\n      }\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_ &&\n          current4_ == typed_other->current4_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_),\n        begin4_(other.begin4_),\n        end4_(other.end4_),\n        current4_(other.current4_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_,\n            *current4_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_ ||\n          current4_ == end4_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    const typename ParamGenerator<T4>::iterator begin4_;\n    const typename ParamGenerator<T4>::iterator end4_;\n    typename ParamGenerator<T4>::iterator current4_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator4::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator4& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n  const ParamGenerator<T4> g4_;\n};  // class CartesianProductGenerator4\n\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\nclass CartesianProductGenerator5\n    : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5> > {\n public:\n  typedef ::testing::tuple<T1, T2, T3, T4, T5> ParamType;\n\n  CartesianProductGenerator5(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,\n      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {}\n  virtual ~CartesianProductGenerator5() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),\n        g4_, g4_.end(), g5_, g5_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3,\n      const ParamGenerator<T4>& g4,\n      const typename ParamGenerator<T4>::iterator& current4,\n      const ParamGenerator<T5>& g5,\n      const typename ParamGenerator<T5>::iterator& current5)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),\n          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),\n          begin5_(g5.begin()), end5_(g5.end()), current5_(current5)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current5_;\n      if (current5_ == end5_) {\n        current5_ = begin5_;\n        ++current4_;\n      }\n      if (current4_ == end4_) {\n        current4_ = begin4_;\n        ++current3_;\n      }\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_ &&\n          current4_ == typed_other->current4_ &&\n          current5_ == typed_other->current5_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_),\n        begin4_(other.begin4_),\n        end4_(other.end4_),\n        current4_(other.current4_),\n        begin5_(other.begin5_),\n        end5_(other.end5_),\n        current5_(other.current5_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_,\n            *current4_, *current5_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_ ||\n          current4_ == end4_ ||\n          current5_ == end5_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    const typename ParamGenerator<T4>::iterator begin4_;\n    const typename ParamGenerator<T4>::iterator end4_;\n    typename ParamGenerator<T4>::iterator current4_;\n    const typename ParamGenerator<T5>::iterator begin5_;\n    const typename ParamGenerator<T5>::iterator end5_;\n    typename ParamGenerator<T5>::iterator current5_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator5::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator5& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n  const ParamGenerator<T4> g4_;\n  const ParamGenerator<T5> g5_;\n};  // class CartesianProductGenerator5\n\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6>\nclass CartesianProductGenerator6\n    : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5,\n        T6> > {\n public:\n  typedef ::testing::tuple<T1, T2, T3, T4, T5, T6> ParamType;\n\n  CartesianProductGenerator6(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,\n      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,\n      const ParamGenerator<T6>& g6)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {}\n  virtual ~CartesianProductGenerator6() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),\n        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3,\n      const ParamGenerator<T4>& g4,\n      const typename ParamGenerator<T4>::iterator& current4,\n      const ParamGenerator<T5>& g5,\n      const typename ParamGenerator<T5>::iterator& current5,\n      const ParamGenerator<T6>& g6,\n      const typename ParamGenerator<T6>::iterator& current6)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),\n          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),\n          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),\n          begin6_(g6.begin()), end6_(g6.end()), current6_(current6)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current6_;\n      if (current6_ == end6_) {\n        current6_ = begin6_;\n        ++current5_;\n      }\n      if (current5_ == end5_) {\n        current5_ = begin5_;\n        ++current4_;\n      }\n      if (current4_ == end4_) {\n        current4_ = begin4_;\n        ++current3_;\n      }\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_ &&\n          current4_ == typed_other->current4_ &&\n          current5_ == typed_other->current5_ &&\n          current6_ == typed_other->current6_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_),\n        begin4_(other.begin4_),\n        end4_(other.end4_),\n        current4_(other.current4_),\n        begin5_(other.begin5_),\n        end5_(other.end5_),\n        current5_(other.current5_),\n        begin6_(other.begin6_),\n        end6_(other.end6_),\n        current6_(other.current6_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_,\n            *current4_, *current5_, *current6_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_ ||\n          current4_ == end4_ ||\n          current5_ == end5_ ||\n          current6_ == end6_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    const typename ParamGenerator<T4>::iterator begin4_;\n    const typename ParamGenerator<T4>::iterator end4_;\n    typename ParamGenerator<T4>::iterator current4_;\n    const typename ParamGenerator<T5>::iterator begin5_;\n    const typename ParamGenerator<T5>::iterator end5_;\n    typename ParamGenerator<T5>::iterator current5_;\n    const typename ParamGenerator<T6>::iterator begin6_;\n    const typename ParamGenerator<T6>::iterator end6_;\n    typename ParamGenerator<T6>::iterator current6_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator6::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator6& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n  const ParamGenerator<T4> g4_;\n  const ParamGenerator<T5> g5_;\n  const ParamGenerator<T6> g6_;\n};  // class CartesianProductGenerator6\n\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7>\nclass CartesianProductGenerator7\n    : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6,\n        T7> > {\n public:\n  typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7> ParamType;\n\n  CartesianProductGenerator7(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,\n      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,\n      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {}\n  virtual ~CartesianProductGenerator7() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,\n        g7_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),\n        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3,\n      const ParamGenerator<T4>& g4,\n      const typename ParamGenerator<T4>::iterator& current4,\n      const ParamGenerator<T5>& g5,\n      const typename ParamGenerator<T5>::iterator& current5,\n      const ParamGenerator<T6>& g6,\n      const typename ParamGenerator<T6>::iterator& current6,\n      const ParamGenerator<T7>& g7,\n      const typename ParamGenerator<T7>::iterator& current7)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),\n          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),\n          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),\n          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),\n          begin7_(g7.begin()), end7_(g7.end()), current7_(current7)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current7_;\n      if (current7_ == end7_) {\n        current7_ = begin7_;\n        ++current6_;\n      }\n      if (current6_ == end6_) {\n        current6_ = begin6_;\n        ++current5_;\n      }\n      if (current5_ == end5_) {\n        current5_ = begin5_;\n        ++current4_;\n      }\n      if (current4_ == end4_) {\n        current4_ = begin4_;\n        ++current3_;\n      }\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_ &&\n          current4_ == typed_other->current4_ &&\n          current5_ == typed_other->current5_ &&\n          current6_ == typed_other->current6_ &&\n          current7_ == typed_other->current7_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_),\n        begin4_(other.begin4_),\n        end4_(other.end4_),\n        current4_(other.current4_),\n        begin5_(other.begin5_),\n        end5_(other.end5_),\n        current5_(other.current5_),\n        begin6_(other.begin6_),\n        end6_(other.end6_),\n        current6_(other.current6_),\n        begin7_(other.begin7_),\n        end7_(other.end7_),\n        current7_(other.current7_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_,\n            *current4_, *current5_, *current6_, *current7_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_ ||\n          current4_ == end4_ ||\n          current5_ == end5_ ||\n          current6_ == end6_ ||\n          current7_ == end7_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    const typename ParamGenerator<T4>::iterator begin4_;\n    const typename ParamGenerator<T4>::iterator end4_;\n    typename ParamGenerator<T4>::iterator current4_;\n    const typename ParamGenerator<T5>::iterator begin5_;\n    const typename ParamGenerator<T5>::iterator end5_;\n    typename ParamGenerator<T5>::iterator current5_;\n    const typename ParamGenerator<T6>::iterator begin6_;\n    const typename ParamGenerator<T6>::iterator end6_;\n    typename ParamGenerator<T6>::iterator current6_;\n    const typename ParamGenerator<T7>::iterator begin7_;\n    const typename ParamGenerator<T7>::iterator end7_;\n    typename ParamGenerator<T7>::iterator current7_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator7::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator7& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n  const ParamGenerator<T4> g4_;\n  const ParamGenerator<T5> g5_;\n  const ParamGenerator<T6> g6_;\n  const ParamGenerator<T7> g7_;\n};  // class CartesianProductGenerator7\n\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8>\nclass CartesianProductGenerator8\n    : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6,\n        T7, T8> > {\n public:\n  typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8> ParamType;\n\n  CartesianProductGenerator8(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,\n      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,\n      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,\n      const ParamGenerator<T8>& g8)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7),\n          g8_(g8) {}\n  virtual ~CartesianProductGenerator8() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,\n        g7_.begin(), g8_, g8_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),\n        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,\n        g8_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3,\n      const ParamGenerator<T4>& g4,\n      const typename ParamGenerator<T4>::iterator& current4,\n      const ParamGenerator<T5>& g5,\n      const typename ParamGenerator<T5>::iterator& current5,\n      const ParamGenerator<T6>& g6,\n      const typename ParamGenerator<T6>::iterator& current6,\n      const ParamGenerator<T7>& g7,\n      const typename ParamGenerator<T7>::iterator& current7,\n      const ParamGenerator<T8>& g8,\n      const typename ParamGenerator<T8>::iterator& current8)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),\n          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),\n          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),\n          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),\n          begin7_(g7.begin()), end7_(g7.end()), current7_(current7),\n          begin8_(g8.begin()), end8_(g8.end()), current8_(current8)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current8_;\n      if (current8_ == end8_) {\n        current8_ = begin8_;\n        ++current7_;\n      }\n      if (current7_ == end7_) {\n        current7_ = begin7_;\n        ++current6_;\n      }\n      if (current6_ == end6_) {\n        current6_ = begin6_;\n        ++current5_;\n      }\n      if (current5_ == end5_) {\n        current5_ = begin5_;\n        ++current4_;\n      }\n      if (current4_ == end4_) {\n        current4_ = begin4_;\n        ++current3_;\n      }\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_ &&\n          current4_ == typed_other->current4_ &&\n          current5_ == typed_other->current5_ &&\n          current6_ == typed_other->current6_ &&\n          current7_ == typed_other->current7_ &&\n          current8_ == typed_other->current8_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_),\n        begin4_(other.begin4_),\n        end4_(other.end4_),\n        current4_(other.current4_),\n        begin5_(other.begin5_),\n        end5_(other.end5_),\n        current5_(other.current5_),\n        begin6_(other.begin6_),\n        end6_(other.end6_),\n        current6_(other.current6_),\n        begin7_(other.begin7_),\n        end7_(other.end7_),\n        current7_(other.current7_),\n        begin8_(other.begin8_),\n        end8_(other.end8_),\n        current8_(other.current8_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_,\n            *current4_, *current5_, *current6_, *current7_, *current8_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_ ||\n          current4_ == end4_ ||\n          current5_ == end5_ ||\n          current6_ == end6_ ||\n          current7_ == end7_ ||\n          current8_ == end8_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    const typename ParamGenerator<T4>::iterator begin4_;\n    const typename ParamGenerator<T4>::iterator end4_;\n    typename ParamGenerator<T4>::iterator current4_;\n    const typename ParamGenerator<T5>::iterator begin5_;\n    const typename ParamGenerator<T5>::iterator end5_;\n    typename ParamGenerator<T5>::iterator current5_;\n    const typename ParamGenerator<T6>::iterator begin6_;\n    const typename ParamGenerator<T6>::iterator end6_;\n    typename ParamGenerator<T6>::iterator current6_;\n    const typename ParamGenerator<T7>::iterator begin7_;\n    const typename ParamGenerator<T7>::iterator end7_;\n    typename ParamGenerator<T7>::iterator current7_;\n    const typename ParamGenerator<T8>::iterator begin8_;\n    const typename ParamGenerator<T8>::iterator end8_;\n    typename ParamGenerator<T8>::iterator current8_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator8::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator8& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n  const ParamGenerator<T4> g4_;\n  const ParamGenerator<T5> g5_;\n  const ParamGenerator<T6> g6_;\n  const ParamGenerator<T7> g7_;\n  const ParamGenerator<T8> g8_;\n};  // class CartesianProductGenerator8\n\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9>\nclass CartesianProductGenerator9\n    : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6,\n        T7, T8, T9> > {\n public:\n  typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> ParamType;\n\n  CartesianProductGenerator9(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,\n      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,\n      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,\n      const ParamGenerator<T8>& g8, const ParamGenerator<T9>& g9)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),\n          g9_(g9) {}\n  virtual ~CartesianProductGenerator9() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,\n        g7_.begin(), g8_, g8_.begin(), g9_, g9_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),\n        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,\n        g8_.end(), g9_, g9_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3,\n      const ParamGenerator<T4>& g4,\n      const typename ParamGenerator<T4>::iterator& current4,\n      const ParamGenerator<T5>& g5,\n      const typename ParamGenerator<T5>::iterator& current5,\n      const ParamGenerator<T6>& g6,\n      const typename ParamGenerator<T6>::iterator& current6,\n      const ParamGenerator<T7>& g7,\n      const typename ParamGenerator<T7>::iterator& current7,\n      const ParamGenerator<T8>& g8,\n      const typename ParamGenerator<T8>::iterator& current8,\n      const ParamGenerator<T9>& g9,\n      const typename ParamGenerator<T9>::iterator& current9)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),\n          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),\n          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),\n          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),\n          begin7_(g7.begin()), end7_(g7.end()), current7_(current7),\n          begin8_(g8.begin()), end8_(g8.end()), current8_(current8),\n          begin9_(g9.begin()), end9_(g9.end()), current9_(current9)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current9_;\n      if (current9_ == end9_) {\n        current9_ = begin9_;\n        ++current8_;\n      }\n      if (current8_ == end8_) {\n        current8_ = begin8_;\n        ++current7_;\n      }\n      if (current7_ == end7_) {\n        current7_ = begin7_;\n        ++current6_;\n      }\n      if (current6_ == end6_) {\n        current6_ = begin6_;\n        ++current5_;\n      }\n      if (current5_ == end5_) {\n        current5_ = begin5_;\n        ++current4_;\n      }\n      if (current4_ == end4_) {\n        current4_ = begin4_;\n        ++current3_;\n      }\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_ &&\n          current4_ == typed_other->current4_ &&\n          current5_ == typed_other->current5_ &&\n          current6_ == typed_other->current6_ &&\n          current7_ == typed_other->current7_ &&\n          current8_ == typed_other->current8_ &&\n          current9_ == typed_other->current9_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_),\n        begin4_(other.begin4_),\n        end4_(other.end4_),\n        current4_(other.current4_),\n        begin5_(other.begin5_),\n        end5_(other.end5_),\n        current5_(other.current5_),\n        begin6_(other.begin6_),\n        end6_(other.end6_),\n        current6_(other.current6_),\n        begin7_(other.begin7_),\n        end7_(other.end7_),\n        current7_(other.current7_),\n        begin8_(other.begin8_),\n        end8_(other.end8_),\n        current8_(other.current8_),\n        begin9_(other.begin9_),\n        end9_(other.end9_),\n        current9_(other.current9_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_,\n            *current4_, *current5_, *current6_, *current7_, *current8_,\n            *current9_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_ ||\n          current4_ == end4_ ||\n          current5_ == end5_ ||\n          current6_ == end6_ ||\n          current7_ == end7_ ||\n          current8_ == end8_ ||\n          current9_ == end9_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    const typename ParamGenerator<T4>::iterator begin4_;\n    const typename ParamGenerator<T4>::iterator end4_;\n    typename ParamGenerator<T4>::iterator current4_;\n    const typename ParamGenerator<T5>::iterator begin5_;\n    const typename ParamGenerator<T5>::iterator end5_;\n    typename ParamGenerator<T5>::iterator current5_;\n    const typename ParamGenerator<T6>::iterator begin6_;\n    const typename ParamGenerator<T6>::iterator end6_;\n    typename ParamGenerator<T6>::iterator current6_;\n    const typename ParamGenerator<T7>::iterator begin7_;\n    const typename ParamGenerator<T7>::iterator end7_;\n    typename ParamGenerator<T7>::iterator current7_;\n    const typename ParamGenerator<T8>::iterator begin8_;\n    const typename ParamGenerator<T8>::iterator end8_;\n    typename ParamGenerator<T8>::iterator current8_;\n    const typename ParamGenerator<T9>::iterator begin9_;\n    const typename ParamGenerator<T9>::iterator end9_;\n    typename ParamGenerator<T9>::iterator current9_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator9::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator9& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n  const ParamGenerator<T4> g4_;\n  const ParamGenerator<T5> g5_;\n  const ParamGenerator<T6> g6_;\n  const ParamGenerator<T7> g7_;\n  const ParamGenerator<T8> g8_;\n  const ParamGenerator<T9> g9_;\n};  // class CartesianProductGenerator9\n\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10>\nclass CartesianProductGenerator10\n    : public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6,\n        T7, T8, T9, T10> > {\n public:\n  typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ParamType;\n\n  CartesianProductGenerator10(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,\n      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,\n      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,\n      const ParamGenerator<T8>& g8, const ParamGenerator<T9>& g9,\n      const ParamGenerator<T10>& g10)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),\n          g9_(g9), g10_(g10) {}\n  virtual ~CartesianProductGenerator10() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,\n        g7_.begin(), g8_, g8_.begin(), g9_, g9_.begin(), g10_, g10_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),\n        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,\n        g8_.end(), g9_, g9_.end(), g10_, g10_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3,\n      const ParamGenerator<T4>& g4,\n      const typename ParamGenerator<T4>::iterator& current4,\n      const ParamGenerator<T5>& g5,\n      const typename ParamGenerator<T5>::iterator& current5,\n      const ParamGenerator<T6>& g6,\n      const typename ParamGenerator<T6>::iterator& current6,\n      const ParamGenerator<T7>& g7,\n      const typename ParamGenerator<T7>::iterator& current7,\n      const ParamGenerator<T8>& g8,\n      const typename ParamGenerator<T8>::iterator& current8,\n      const ParamGenerator<T9>& g9,\n      const typename ParamGenerator<T9>::iterator& current9,\n      const ParamGenerator<T10>& g10,\n      const typename ParamGenerator<T10>::iterator& current10)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),\n          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),\n          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),\n          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),\n          begin7_(g7.begin()), end7_(g7.end()), current7_(current7),\n          begin8_(g8.begin()), end8_(g8.end()), current8_(current8),\n          begin9_(g9.begin()), end9_(g9.end()), current9_(current9),\n          begin10_(g10.begin()), end10_(g10.end()), current10_(current10)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current10_;\n      if (current10_ == end10_) {\n        current10_ = begin10_;\n        ++current9_;\n      }\n      if (current9_ == end9_) {\n        current9_ = begin9_;\n        ++current8_;\n      }\n      if (current8_ == end8_) {\n        current8_ = begin8_;\n        ++current7_;\n      }\n      if (current7_ == end7_) {\n        current7_ = begin7_;\n        ++current6_;\n      }\n      if (current6_ == end6_) {\n        current6_ = begin6_;\n        ++current5_;\n      }\n      if (current5_ == end5_) {\n        current5_ = begin5_;\n        ++current4_;\n      }\n      if (current4_ == end4_) {\n        current4_ = begin4_;\n        ++current3_;\n      }\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_ &&\n          current4_ == typed_other->current4_ &&\n          current5_ == typed_other->current5_ &&\n          current6_ == typed_other->current6_ &&\n          current7_ == typed_other->current7_ &&\n          current8_ == typed_other->current8_ &&\n          current9_ == typed_other->current9_ &&\n          current10_ == typed_other->current10_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_),\n        begin4_(other.begin4_),\n        end4_(other.end4_),\n        current4_(other.current4_),\n        begin5_(other.begin5_),\n        end5_(other.end5_),\n        current5_(other.current5_),\n        begin6_(other.begin6_),\n        end6_(other.end6_),\n        current6_(other.current6_),\n        begin7_(other.begin7_),\n        end7_(other.end7_),\n        current7_(other.current7_),\n        begin8_(other.begin8_),\n        end8_(other.end8_),\n        current8_(other.current8_),\n        begin9_(other.begin9_),\n        end9_(other.end9_),\n        current9_(other.current9_),\n        begin10_(other.begin10_),\n        end10_(other.end10_),\n        current10_(other.current10_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_,\n            *current4_, *current5_, *current6_, *current7_, *current8_,\n            *current9_, *current10_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_ ||\n          current4_ == end4_ ||\n          current5_ == end5_ ||\n          current6_ == end6_ ||\n          current7_ == end7_ ||\n          current8_ == end8_ ||\n          current9_ == end9_ ||\n          current10_ == end10_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    const typename ParamGenerator<T4>::iterator begin4_;\n    const typename ParamGenerator<T4>::iterator end4_;\n    typename ParamGenerator<T4>::iterator current4_;\n    const typename ParamGenerator<T5>::iterator begin5_;\n    const typename ParamGenerator<T5>::iterator end5_;\n    typename ParamGenerator<T5>::iterator current5_;\n    const typename ParamGenerator<T6>::iterator begin6_;\n    const typename ParamGenerator<T6>::iterator end6_;\n    typename ParamGenerator<T6>::iterator current6_;\n    const typename ParamGenerator<T7>::iterator begin7_;\n    const typename ParamGenerator<T7>::iterator end7_;\n    typename ParamGenerator<T7>::iterator current7_;\n    const typename ParamGenerator<T8>::iterator begin8_;\n    const typename ParamGenerator<T8>::iterator end8_;\n    typename ParamGenerator<T8>::iterator current8_;\n    const typename ParamGenerator<T9>::iterator begin9_;\n    const typename ParamGenerator<T9>::iterator end9_;\n    typename ParamGenerator<T9>::iterator current9_;\n    const typename ParamGenerator<T10>::iterator begin10_;\n    const typename ParamGenerator<T10>::iterator end10_;\n    typename ParamGenerator<T10>::iterator current10_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator10::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator10& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n  const ParamGenerator<T4> g4_;\n  const ParamGenerator<T5> g5_;\n  const ParamGenerator<T6> g6_;\n  const ParamGenerator<T7> g7_;\n  const ParamGenerator<T8> g8_;\n  const ParamGenerator<T9> g9_;\n  const ParamGenerator<T10> g10_;\n};  // class CartesianProductGenerator10\n\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Helper classes providing Combine() with polymorphic features. They allow\n// casting CartesianProductGeneratorN<T> to ParamGenerator<U> if T is\n// convertible to U.\n//\ntemplate <class Generator1, class Generator2>\nclass CartesianProductHolder2 {\n public:\nCartesianProductHolder2(const Generator1& g1, const Generator2& g2)\n      : g1_(g1), g2_(g2) {}\n  template <typename T1, typename T2>\n  operator ParamGenerator< ::testing::tuple<T1, T2> >() const {\n    return ParamGenerator< ::testing::tuple<T1, T2> >(\n        new CartesianProductGenerator2<T1, T2>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder2& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n};  // class CartesianProductHolder2\n\ntemplate <class Generator1, class Generator2, class Generator3>\nclass CartesianProductHolder3 {\n public:\nCartesianProductHolder3(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3)\n      : g1_(g1), g2_(g2), g3_(g3) {}\n  template <typename T1, typename T2, typename T3>\n  operator ParamGenerator< ::testing::tuple<T1, T2, T3> >() const {\n    return ParamGenerator< ::testing::tuple<T1, T2, T3> >(\n        new CartesianProductGenerator3<T1, T2, T3>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder3& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n};  // class CartesianProductHolder3\n\ntemplate <class Generator1, class Generator2, class Generator3,\n    class Generator4>\nclass CartesianProductHolder4 {\n public:\nCartesianProductHolder4(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3, const Generator4& g4)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {}\n  template <typename T1, typename T2, typename T3, typename T4>\n  operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4> >() const {\n    return ParamGenerator< ::testing::tuple<T1, T2, T3, T4> >(\n        new CartesianProductGenerator4<T1, T2, T3, T4>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_),\n        static_cast<ParamGenerator<T4> >(g4_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder4& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n  const Generator4 g4_;\n};  // class CartesianProductHolder4\n\ntemplate <class Generator1, class Generator2, class Generator3,\n    class Generator4, class Generator5>\nclass CartesianProductHolder5 {\n public:\nCartesianProductHolder5(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3, const Generator4& g4, const Generator5& g5)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {}\n  template <typename T1, typename T2, typename T3, typename T4, typename T5>\n  operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5> >() const {\n    return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5> >(\n        new CartesianProductGenerator5<T1, T2, T3, T4, T5>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_),\n        static_cast<ParamGenerator<T4> >(g4_),\n        static_cast<ParamGenerator<T5> >(g5_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder5& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n  const Generator4 g4_;\n  const Generator5 g5_;\n};  // class CartesianProductHolder5\n\ntemplate <class Generator1, class Generator2, class Generator3,\n    class Generator4, class Generator5, class Generator6>\nclass CartesianProductHolder6 {\n public:\nCartesianProductHolder6(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3, const Generator4& g4, const Generator5& g5,\n    const Generator6& g6)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {}\n  template <typename T1, typename T2, typename T3, typename T4, typename T5,\n      typename T6>\n  operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6> >() const {\n    return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6> >(\n        new CartesianProductGenerator6<T1, T2, T3, T4, T5, T6>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_),\n        static_cast<ParamGenerator<T4> >(g4_),\n        static_cast<ParamGenerator<T5> >(g5_),\n        static_cast<ParamGenerator<T6> >(g6_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder6& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n  const Generator4 g4_;\n  const Generator5 g5_;\n  const Generator6 g6_;\n};  // class CartesianProductHolder6\n\ntemplate <class Generator1, class Generator2, class Generator3,\n    class Generator4, class Generator5, class Generator6, class Generator7>\nclass CartesianProductHolder7 {\n public:\nCartesianProductHolder7(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3, const Generator4& g4, const Generator5& g5,\n    const Generator6& g6, const Generator7& g7)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {}\n  template <typename T1, typename T2, typename T3, typename T4, typename T5,\n      typename T6, typename T7>\n  operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6,\n      T7> >() const {\n    return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7> >(\n        new CartesianProductGenerator7<T1, T2, T3, T4, T5, T6, T7>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_),\n        static_cast<ParamGenerator<T4> >(g4_),\n        static_cast<ParamGenerator<T5> >(g5_),\n        static_cast<ParamGenerator<T6> >(g6_),\n        static_cast<ParamGenerator<T7> >(g7_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder7& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n  const Generator4 g4_;\n  const Generator5 g5_;\n  const Generator6 g6_;\n  const Generator7 g7_;\n};  // class CartesianProductHolder7\n\ntemplate <class Generator1, class Generator2, class Generator3,\n    class Generator4, class Generator5, class Generator6, class Generator7,\n    class Generator8>\nclass CartesianProductHolder8 {\n public:\nCartesianProductHolder8(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3, const Generator4& g4, const Generator5& g5,\n    const Generator6& g6, const Generator7& g7, const Generator8& g8)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7),\n          g8_(g8) {}\n  template <typename T1, typename T2, typename T3, typename T4, typename T5,\n      typename T6, typename T7, typename T8>\n  operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7,\n      T8> >() const {\n    return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8> >(\n        new CartesianProductGenerator8<T1, T2, T3, T4, T5, T6, T7, T8>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_),\n        static_cast<ParamGenerator<T4> >(g4_),\n        static_cast<ParamGenerator<T5> >(g5_),\n        static_cast<ParamGenerator<T6> >(g6_),\n        static_cast<ParamGenerator<T7> >(g7_),\n        static_cast<ParamGenerator<T8> >(g8_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder8& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n  const Generator4 g4_;\n  const Generator5 g5_;\n  const Generator6 g6_;\n  const Generator7 g7_;\n  const Generator8 g8_;\n};  // class CartesianProductHolder8\n\ntemplate <class Generator1, class Generator2, class Generator3,\n    class Generator4, class Generator5, class Generator6, class Generator7,\n    class Generator8, class Generator9>\nclass CartesianProductHolder9 {\n public:\nCartesianProductHolder9(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3, const Generator4& g4, const Generator5& g5,\n    const Generator6& g6, const Generator7& g7, const Generator8& g8,\n    const Generator9& g9)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),\n          g9_(g9) {}\n  template <typename T1, typename T2, typename T3, typename T4, typename T5,\n      typename T6, typename T7, typename T8, typename T9>\n  operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8,\n      T9> >() const {\n    return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8,\n        T9> >(\n        new CartesianProductGenerator9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_),\n        static_cast<ParamGenerator<T4> >(g4_),\n        static_cast<ParamGenerator<T5> >(g5_),\n        static_cast<ParamGenerator<T6> >(g6_),\n        static_cast<ParamGenerator<T7> >(g7_),\n        static_cast<ParamGenerator<T8> >(g8_),\n        static_cast<ParamGenerator<T9> >(g9_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder9& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n  const Generator4 g4_;\n  const Generator5 g5_;\n  const Generator6 g6_;\n  const Generator7 g7_;\n  const Generator8 g8_;\n  const Generator9 g9_;\n};  // class CartesianProductHolder9\n\ntemplate <class Generator1, class Generator2, class Generator3,\n    class Generator4, class Generator5, class Generator6, class Generator7,\n    class Generator8, class Generator9, class Generator10>\nclass CartesianProductHolder10 {\n public:\nCartesianProductHolder10(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3, const Generator4& g4, const Generator5& g5,\n    const Generator6& g6, const Generator7& g7, const Generator8& g8,\n    const Generator9& g9, const Generator10& g10)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),\n          g9_(g9), g10_(g10) {}\n  template <typename T1, typename T2, typename T3, typename T4, typename T5,\n      typename T6, typename T7, typename T8, typename T9, typename T10>\n  operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9,\n      T10> >() const {\n    return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9,\n        T10> >(\n        new CartesianProductGenerator10<T1, T2, T3, T4, T5, T6, T7, T8, T9,\n            T10>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_),\n        static_cast<ParamGenerator<T4> >(g4_),\n        static_cast<ParamGenerator<T5> >(g5_),\n        static_cast<ParamGenerator<T6> >(g6_),\n        static_cast<ParamGenerator<T7> >(g7_),\n        static_cast<ParamGenerator<T8> >(g8_),\n        static_cast<ParamGenerator<T9> >(g9_),\n        static_cast<ParamGenerator<T10> >(g10_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder10& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n  const Generator4 g4_;\n  const Generator5 g5_;\n  const Generator6 g6_;\n  const Generator7 g7_;\n  const Generator8 g8_;\n  const Generator9 g9_;\n  const Generator10 g10_;\n};  // class CartesianProductHolder10\n\n# endif  // GTEST_HAS_COMBINE\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  //  GTEST_HAS_PARAM_TEST\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/gtest-param-util-generated.h.pump",
    "content": "$$ -*- mode: c++; -*-\n$var n = 50  $$ Maximum length of Values arguments we want to support.\n$var maxtuple = 10  $$ Maximum number of Combine arguments we want to support.\n// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// Type and function utilities for implementing parameterized tests.\n// This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!\n//\n// Currently Google Test supports at most $n arguments in Values,\n// and at most $maxtuple arguments in Combine. Please contact\n// googletestframework@googlegroups.com if you need more.\n// Please note that the number of arguments to Combine is limited\n// by the maximum arity of the implementation of tuple which is\n// currently set at $maxtuple.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_\n\n// scripts/fuse_gtest.py depends on gtest's own header being #included\n// *unconditionally*.  Therefore these #includes cannot be moved\n// inside #if GTEST_HAS_PARAM_TEST.\n#include \"gtest/internal/gtest-param-util.h\"\n#include \"gtest/internal/gtest-port.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\nnamespace testing {\n\n// Forward declarations of ValuesIn(), which is implemented in\n// include/gtest/gtest-param-test.h.\ntemplate <typename ForwardIterator>\ninternal::ParamGenerator<\n  typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>\nValuesIn(ForwardIterator begin, ForwardIterator end);\n\ntemplate <typename T, size_t N>\ninternal::ParamGenerator<T> ValuesIn(const T (&array)[N]);\n\ntemplate <class Container>\ninternal::ParamGenerator<typename Container::value_type> ValuesIn(\n    const Container& container);\n\nnamespace internal {\n\n// Used in the Values() function to provide polymorphic capabilities.\n$range i 1..n\n$for i [[\n$range j 1..i\n\ntemplate <$for j, [[typename T$j]]>\nclass ValueArray$i {\n public:\n  $if i==1 [[explicit ]]ValueArray$i($for j, [[T$j v$j]]) : $for j, [[v$(j)_(v$j)]] {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {$for j, [[static_cast<T>(v$(j)_)]]};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray$i& other);\n\n$for j [[\n\n  const T$j v$(j)_;\n]]\n\n};\n\n]]\n\n# if GTEST_HAS_COMBINE\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Generates values from the Cartesian product of values produced\n// by the argument generators.\n//\n$range i 2..maxtuple\n$for i [[\n$range j 1..i\n$range k 2..i\n\ntemplate <$for j, [[typename T$j]]>\nclass CartesianProductGenerator$i\n    : public ParamGeneratorInterface< ::testing::tuple<$for j, [[T$j]]> > {\n public:\n  typedef ::testing::tuple<$for j, [[T$j]]> ParamType;\n\n  CartesianProductGenerator$i($for j, [[const ParamGenerator<T$j>& g$j]])\n      : $for j, [[g$(j)_(g$j)]] {}\n  virtual ~CartesianProductGenerator$i() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, $for j, [[g$(j)_, g$(j)_.begin()]]);\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, $for j, [[g$(j)_, g$(j)_.end()]]);\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base, $for j, [[\n\n      const ParamGenerator<T$j>& g$j,\n      const typename ParamGenerator<T$j>::iterator& current$(j)]])\n        : base_(base),\n$for j, [[\n\n          begin$(j)_(g$j.begin()), end$(j)_(g$j.end()), current$(j)_(current$j)\n]]    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current$(i)_;\n\n$for k [[\n      if (current$(i+2-k)_ == end$(i+2-k)_) {\n        current$(i+2-k)_ = begin$(i+2-k)_;\n        ++current$(i+2-k-1)_;\n      }\n\n]]\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         ($for j  && [[\n\n          current$(j)_ == typed_other->current$(j)_\n]]);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_), $for j, [[\n\n        begin$(j)_(other.begin$(j)_),\n        end$(j)_(other.end$(j)_),\n        current$(j)_(other.current$(j)_)\n]] {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType($for j, [[*current$(j)_]]);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n$for j  || [[\n\n          current$(j)_ == end$(j)_\n]];\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n$for j [[\n\n    const typename ParamGenerator<T$j>::iterator begin$(j)_;\n    const typename ParamGenerator<T$j>::iterator end$(j)_;\n    typename ParamGenerator<T$j>::iterator current$(j)_;\n]]\n\n    ParamType current_value_;\n  };  // class CartesianProductGenerator$i::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator$i& other);\n\n\n$for j [[\n  const ParamGenerator<T$j> g$(j)_;\n\n]]\n};  // class CartesianProductGenerator$i\n\n\n]]\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Helper classes providing Combine() with polymorphic features. They allow\n// casting CartesianProductGeneratorN<T> to ParamGenerator<U> if T is\n// convertible to U.\n//\n$range i 2..maxtuple\n$for i [[\n$range j 1..i\n\ntemplate <$for j, [[class Generator$j]]>\nclass CartesianProductHolder$i {\n public:\nCartesianProductHolder$i($for j, [[const Generator$j& g$j]])\n      : $for j, [[g$(j)_(g$j)]] {}\n  template <$for j, [[typename T$j]]>\n  operator ParamGenerator< ::testing::tuple<$for j, [[T$j]]> >() const {\n    return ParamGenerator< ::testing::tuple<$for j, [[T$j]]> >(\n        new CartesianProductGenerator$i<$for j, [[T$j]]>(\n$for j,[[\n\n        static_cast<ParamGenerator<T$j> >(g$(j)_)\n]]));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder$i& other);\n\n\n$for j [[\n  const Generator$j g$(j)_;\n\n]]\n};  // class CartesianProductHolder$i\n\n]]\n\n# endif  // GTEST_HAS_COMBINE\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  //  GTEST_HAS_PARAM_TEST\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/gtest-param-util.h",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// Type and function utilities for implementing parameterized tests.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_\n\n#include <ctype.h>\n\n#include <iterator>\n#include <set>\n#include <utility>\n#include <vector>\n\n// scripts/fuse_gtest.py depends on gtest's own header being #included\n// *unconditionally*.  Therefore these #includes cannot be moved\n// inside #if GTEST_HAS_PARAM_TEST.\n#include \"gtest/internal/gtest-internal.h\"\n#include \"gtest/internal/gtest-linked_ptr.h\"\n#include \"gtest/internal/gtest-port.h\"\n#include \"gtest/gtest-printers.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\nnamespace testing {\n\n// Input to a parameterized test name generator, describing a test parameter.\n// Consists of the parameter value and the integer parameter index.\ntemplate <class ParamType>\nstruct TestParamInfo {\n  TestParamInfo(const ParamType& a_param, size_t an_index) :\n    param(a_param),\n    index(an_index) {}\n  ParamType param;\n  size_t index;\n};\n\n// A builtin parameterized test name generator which returns the result of\n// testing::PrintToString.\nstruct PrintToStringParamName {\n  template <class ParamType>\n  std::string operator()(const TestParamInfo<ParamType>& info) const {\n    return PrintToString(info.param);\n  }\n};\n\nnamespace internal {\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Outputs a message explaining invalid registration of different\n// fixture class for the same test case. This may happen when\n// TEST_P macro is used to define two tests with the same name\n// but in different namespaces.\nGTEST_API_ void ReportInvalidTestCaseType(const char* test_case_name,\n                                          CodeLocation code_location);\n\ntemplate <typename> class ParamGeneratorInterface;\ntemplate <typename> class ParamGenerator;\n\n// Interface for iterating over elements provided by an implementation\n// of ParamGeneratorInterface<T>.\ntemplate <typename T>\nclass ParamIteratorInterface {\n public:\n  virtual ~ParamIteratorInterface() {}\n  // A pointer to the base generator instance.\n  // Used only for the purposes of iterator comparison\n  // to make sure that two iterators belong to the same generator.\n  virtual const ParamGeneratorInterface<T>* BaseGenerator() const = 0;\n  // Advances iterator to point to the next element\n  // provided by the generator. The caller is responsible\n  // for not calling Advance() on an iterator equal to\n  // BaseGenerator()->End().\n  virtual void Advance() = 0;\n  // Clones the iterator object. Used for implementing copy semantics\n  // of ParamIterator<T>.\n  virtual ParamIteratorInterface* Clone() const = 0;\n  // Dereferences the current iterator and provides (read-only) access\n  // to the pointed value. It is the caller's responsibility not to call\n  // Current() on an iterator equal to BaseGenerator()->End().\n  // Used for implementing ParamGenerator<T>::operator*().\n  virtual const T* Current() const = 0;\n  // Determines whether the given iterator and other point to the same\n  // element in the sequence generated by the generator.\n  // Used for implementing ParamGenerator<T>::operator==().\n  virtual bool Equals(const ParamIteratorInterface& other) const = 0;\n};\n\n// Class iterating over elements provided by an implementation of\n// ParamGeneratorInterface<T>. It wraps ParamIteratorInterface<T>\n// and implements the const forward iterator concept.\ntemplate <typename T>\nclass ParamIterator {\n public:\n  typedef T value_type;\n  typedef const T& reference;\n  typedef ptrdiff_t difference_type;\n\n  // ParamIterator assumes ownership of the impl_ pointer.\n  ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {}\n  ParamIterator& operator=(const ParamIterator& other) {\n    if (this != &other)\n      impl_.reset(other.impl_->Clone());\n    return *this;\n  }\n\n  const T& operator*() const { return *impl_->Current(); }\n  const T* operator->() const { return impl_->Current(); }\n  // Prefix version of operator++.\n  ParamIterator& operator++() {\n    impl_->Advance();\n    return *this;\n  }\n  // Postfix version of operator++.\n  ParamIterator operator++(int /*unused*/) {\n    ParamIteratorInterface<T>* clone = impl_->Clone();\n    impl_->Advance();\n    return ParamIterator(clone);\n  }\n  bool operator==(const ParamIterator& other) const {\n    return impl_.get() == other.impl_.get() || impl_->Equals(*other.impl_);\n  }\n  bool operator!=(const ParamIterator& other) const {\n    return !(*this == other);\n  }\n\n private:\n  friend class ParamGenerator<T>;\n  explicit ParamIterator(ParamIteratorInterface<T>* impl) : impl_(impl) {}\n  scoped_ptr<ParamIteratorInterface<T> > impl_;\n};\n\n// ParamGeneratorInterface<T> is the binary interface to access generators\n// defined in other translation units.\ntemplate <typename T>\nclass ParamGeneratorInterface {\n public:\n  typedef T ParamType;\n\n  virtual ~ParamGeneratorInterface() {}\n\n  // Generator interface definition\n  virtual ParamIteratorInterface<T>* Begin() const = 0;\n  virtual ParamIteratorInterface<T>* End() const = 0;\n};\n\n// Wraps ParamGeneratorInterface<T> and provides general generator syntax\n// compatible with the STL Container concept.\n// This class implements copy initialization semantics and the contained\n// ParamGeneratorInterface<T> instance is shared among all copies\n// of the original object. This is possible because that instance is immutable.\ntemplate<typename T>\nclass ParamGenerator {\n public:\n  typedef ParamIterator<T> iterator;\n\n  explicit ParamGenerator(ParamGeneratorInterface<T>* impl) : impl_(impl) {}\n  ParamGenerator(const ParamGenerator& other) : impl_(other.impl_) {}\n\n  ParamGenerator& operator=(const ParamGenerator& other) {\n    impl_ = other.impl_;\n    return *this;\n  }\n\n  iterator begin() const { return iterator(impl_->Begin()); }\n  iterator end() const { return iterator(impl_->End()); }\n\n private:\n  linked_ptr<const ParamGeneratorInterface<T> > impl_;\n};\n\n// Generates values from a range of two comparable values. Can be used to\n// generate sequences of user-defined types that implement operator+() and\n// operator<().\n// This class is used in the Range() function.\ntemplate <typename T, typename IncrementT>\nclass RangeGenerator : public ParamGeneratorInterface<T> {\n public:\n  RangeGenerator(T begin, T end, IncrementT step)\n      : begin_(begin), end_(end),\n        step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}\n  virtual ~RangeGenerator() {}\n\n  virtual ParamIteratorInterface<T>* Begin() const {\n    return new Iterator(this, begin_, 0, step_);\n  }\n  virtual ParamIteratorInterface<T>* End() const {\n    return new Iterator(this, end_, end_index_, step_);\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<T> {\n   public:\n    Iterator(const ParamGeneratorInterface<T>* base, T value, int index,\n             IncrementT step)\n        : base_(base), value_(value), index_(index), step_(step) {}\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<T>* BaseGenerator() const {\n      return base_;\n    }\n    virtual void Advance() {\n      value_ = static_cast<T>(value_ + step_);\n      index_++;\n    }\n    virtual ParamIteratorInterface<T>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const T* Current() const { return &value_; }\n    virtual bool Equals(const ParamIteratorInterface<T>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const int other_index =\n          CheckedDowncastToActualType<const Iterator>(&other)->index_;\n      return index_ == other_index;\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : ParamIteratorInterface<T>(),\n          base_(other.base_), value_(other.value_), index_(other.index_),\n          step_(other.step_) {}\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<T>* const base_;\n    T value_;\n    int index_;\n    const IncrementT step_;\n  };  // class RangeGenerator::Iterator\n\n  static int CalculateEndIndex(const T& begin,\n                               const T& end,\n                               const IncrementT& step) {\n    int end_index = 0;\n    for (T i = begin; i < end; i = static_cast<T>(i + step))\n      end_index++;\n    return end_index;\n  }\n\n  // No implementation - assignment is unsupported.\n  void operator=(const RangeGenerator& other);\n\n  const T begin_;\n  const T end_;\n  const IncrementT step_;\n  // The index for the end() iterator. All the elements in the generated\n  // sequence are indexed (0-based) to aid iterator comparison.\n  const int end_index_;\n};  // class RangeGenerator\n\n\n// Generates values from a pair of STL-style iterators. Used in the\n// ValuesIn() function. The elements are copied from the source range\n// since the source can be located on the stack, and the generator\n// is likely to persist beyond that stack frame.\ntemplate <typename T>\nclass ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {\n public:\n  template <typename ForwardIterator>\n  ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)\n      : container_(begin, end) {}\n  virtual ~ValuesInIteratorRangeGenerator() {}\n\n  virtual ParamIteratorInterface<T>* Begin() const {\n    return new Iterator(this, container_.begin());\n  }\n  virtual ParamIteratorInterface<T>* End() const {\n    return new Iterator(this, container_.end());\n  }\n\n private:\n  typedef typename ::std::vector<T> ContainerType;\n\n  class Iterator : public ParamIteratorInterface<T> {\n   public:\n    Iterator(const ParamGeneratorInterface<T>* base,\n             typename ContainerType::const_iterator iterator)\n        : base_(base), iterator_(iterator) {}\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<T>* BaseGenerator() const {\n      return base_;\n    }\n    virtual void Advance() {\n      ++iterator_;\n      value_.reset();\n    }\n    virtual ParamIteratorInterface<T>* Clone() const {\n      return new Iterator(*this);\n    }\n    // We need to use cached value referenced by iterator_ because *iterator_\n    // can return a temporary object (and of type other then T), so just\n    // having \"return &*iterator_;\" doesn't work.\n    // value_ is updated here and not in Advance() because Advance()\n    // can advance iterator_ beyond the end of the range, and we cannot\n    // detect that fact. The client code, on the other hand, is\n    // responsible for not calling Current() on an out-of-range iterator.\n    virtual const T* Current() const {\n      if (value_.get() == NULL)\n        value_.reset(new T(*iterator_));\n      return value_.get();\n    }\n    virtual bool Equals(const ParamIteratorInterface<T>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      return iterator_ ==\n          CheckedDowncastToActualType<const Iterator>(&other)->iterator_;\n    }\n\n   private:\n    Iterator(const Iterator& other)\n          // The explicit constructor call suppresses a false warning\n          // emitted by gcc when supplied with the -Wextra option.\n        : ParamIteratorInterface<T>(),\n          base_(other.base_),\n          iterator_(other.iterator_) {}\n\n    const ParamGeneratorInterface<T>* const base_;\n    typename ContainerType::const_iterator iterator_;\n    // A cached value of *iterator_. We keep it here to allow access by\n    // pointer in the wrapping iterator's operator->().\n    // value_ needs to be mutable to be accessed in Current().\n    // Use of scoped_ptr helps manage cached value's lifetime,\n    // which is bound by the lifespan of the iterator itself.\n    mutable scoped_ptr<const T> value_;\n  };  // class ValuesInIteratorRangeGenerator::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const ValuesInIteratorRangeGenerator& other);\n\n  const ContainerType container_;\n};  // class ValuesInIteratorRangeGenerator\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Default parameterized test name generator, returns a string containing the\n// integer test parameter index.\ntemplate <class ParamType>\nstd::string DefaultParamName(const TestParamInfo<ParamType>& info) {\n  Message name_stream;\n  name_stream << info.index;\n  return name_stream.GetString();\n}\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Parameterized test name overload helpers, which help the\n// INSTANTIATE_TEST_CASE_P macro choose between the default parameterized\n// test name generator and user param name generator.\ntemplate <class ParamType, class ParamNameGenFunctor>\nParamNameGenFunctor GetParamNameGen(ParamNameGenFunctor func) {\n  return func;\n}\n\ntemplate <class ParamType>\nstruct ParamNameGenFunc {\n  typedef std::string Type(const TestParamInfo<ParamType>&);\n};\n\ntemplate <class ParamType>\ntypename ParamNameGenFunc<ParamType>::Type *GetParamNameGen() {\n  return DefaultParamName;\n}\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Stores a parameter value and later creates tests parameterized with that\n// value.\ntemplate <class TestClass>\nclass ParameterizedTestFactory : public TestFactoryBase {\n public:\n  typedef typename TestClass::ParamType ParamType;\n  explicit ParameterizedTestFactory(ParamType parameter) :\n      parameter_(parameter) {}\n  virtual Test* CreateTest() {\n    TestClass::SetParam(&parameter_);\n    return new TestClass();\n  }\n\n private:\n  const ParamType parameter_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);\n};\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// TestMetaFactoryBase is a base class for meta-factories that create\n// test factories for passing into MakeAndRegisterTestInfo function.\ntemplate <class ParamType>\nclass TestMetaFactoryBase {\n public:\n  virtual ~TestMetaFactoryBase() {}\n\n  virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;\n};\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// TestMetaFactory creates test factories for passing into\n// MakeAndRegisterTestInfo function. Since MakeAndRegisterTestInfo receives\n// ownership of test factory pointer, same factory object cannot be passed\n// into that method twice. But ParameterizedTestCaseInfo is going to call\n// it for each Test/Parameter value combination. Thus it needs meta factory\n// creator class.\ntemplate <class TestCase>\nclass TestMetaFactory\n    : public TestMetaFactoryBase<typename TestCase::ParamType> {\n public:\n  typedef typename TestCase::ParamType ParamType;\n\n  TestMetaFactory() {}\n\n  virtual TestFactoryBase* CreateTestFactory(ParamType parameter) {\n    return new ParameterizedTestFactory<TestCase>(parameter);\n  }\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory);\n};\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// ParameterizedTestCaseInfoBase is a generic interface\n// to ParameterizedTestCaseInfo classes. ParameterizedTestCaseInfoBase\n// accumulates test information provided by TEST_P macro invocations\n// and generators provided by INSTANTIATE_TEST_CASE_P macro invocations\n// and uses that information to register all resulting test instances\n// in RegisterTests method. The ParameterizeTestCaseRegistry class holds\n// a collection of pointers to the ParameterizedTestCaseInfo objects\n// and calls RegisterTests() on each of them when asked.\nclass ParameterizedTestCaseInfoBase {\n public:\n  virtual ~ParameterizedTestCaseInfoBase() {}\n\n  // Base part of test case name for display purposes.\n  virtual const string& GetTestCaseName() const = 0;\n  // Test case id to verify identity.\n  virtual TypeId GetTestCaseTypeId() const = 0;\n  // UnitTest class invokes this method to register tests in this\n  // test case right before running them in RUN_ALL_TESTS macro.\n  // This method should not be called more then once on any single\n  // instance of a ParameterizedTestCaseInfoBase derived class.\n  virtual void RegisterTests() = 0;\n\n protected:\n  ParameterizedTestCaseInfoBase() {}\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfoBase);\n};\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// ParameterizedTestCaseInfo accumulates tests obtained from TEST_P\n// macro invocations for a particular test case and generators\n// obtained from INSTANTIATE_TEST_CASE_P macro invocations for that\n// test case. It registers tests with all values generated by all\n// generators when asked.\ntemplate <class TestCase>\nclass ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {\n public:\n  // ParamType and GeneratorCreationFunc are private types but are required\n  // for declarations of public methods AddTestPattern() and\n  // AddTestCaseInstantiation().\n  typedef typename TestCase::ParamType ParamType;\n  // A function that returns an instance of appropriate generator type.\n  typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();\n  typedef typename ParamNameGenFunc<ParamType>::Type ParamNameGeneratorFunc;\n\n  explicit ParameterizedTestCaseInfo(\n      const char* name, CodeLocation code_location)\n      : test_case_name_(name), code_location_(code_location) {}\n\n  // Test case base name for display purposes.\n  virtual const string& GetTestCaseName() const { return test_case_name_; }\n  // Test case id to verify identity.\n  virtual TypeId GetTestCaseTypeId() const { return GetTypeId<TestCase>(); }\n  // TEST_P macro uses AddTestPattern() to record information\n  // about a single test in a LocalTestInfo structure.\n  // test_case_name is the base name of the test case (without invocation\n  // prefix). test_base_name is the name of an individual test without\n  // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is\n  // test case base name and DoBar is test base name.\n  void AddTestPattern(const char* test_case_name,\n                      const char* test_base_name,\n                      TestMetaFactoryBase<ParamType>* meta_factory) {\n    tests_.push_back(linked_ptr<TestInfo>(new TestInfo(test_case_name,\n                                                       test_base_name,\n                                                       meta_factory)));\n  }\n  // INSTANTIATE_TEST_CASE_P macro uses AddGenerator() to record information\n  // about a generator.\n  int AddTestCaseInstantiation(const string& instantiation_name,\n                               GeneratorCreationFunc* func,\n                               ParamNameGeneratorFunc* name_func,\n                               const char* file,\n                               int line) {\n    instantiations_.push_back(\n        InstantiationInfo(instantiation_name, func, name_func, file, line));\n    return 0;  // Return value used only to run this method in namespace scope.\n  }\n  // UnitTest class invokes this method to register tests in this test case\n  // test cases right before running tests in RUN_ALL_TESTS macro.\n  // This method should not be called more then once on any single\n  // instance of a ParameterizedTestCaseInfoBase derived class.\n  // UnitTest has a guard to prevent from calling this method more then once.\n  virtual void RegisterTests() {\n    for (typename TestInfoContainer::iterator test_it = tests_.begin();\n         test_it != tests_.end(); ++test_it) {\n      linked_ptr<TestInfo> test_info = *test_it;\n      for (typename InstantiationContainer::iterator gen_it =\n               instantiations_.begin(); gen_it != instantiations_.end();\n               ++gen_it) {\n        const string& instantiation_name = gen_it->name;\n        ParamGenerator<ParamType> generator((*gen_it->generator)());\n        ParamNameGeneratorFunc* name_func = gen_it->name_func;\n        const char* file = gen_it->file;\n        int line = gen_it->line;\n\n        string test_case_name;\n        if ( !instantiation_name.empty() )\n          test_case_name = instantiation_name + \"/\";\n        test_case_name += test_info->test_case_base_name;\n\n        size_t i = 0;\n        std::set<std::string> test_param_names;\n        for (typename ParamGenerator<ParamType>::iterator param_it =\n                 generator.begin();\n             param_it != generator.end(); ++param_it, ++i) {\n          Message test_name_stream;\n\n          std::string param_name = name_func(\n              TestParamInfo<ParamType>(*param_it, i));\n\n          GTEST_CHECK_(IsValidParamName(param_name))\n              << \"Parameterized test name '\" << param_name\n              << \"' is invalid, in \" << file\n              << \" line \" << line << std::endl;\n\n          GTEST_CHECK_(test_param_names.count(param_name) == 0)\n              << \"Duplicate parameterized test name '\" << param_name\n              << \"', in \" << file << \" line \" << line << std::endl;\n\n          test_param_names.insert(param_name);\n\n          test_name_stream << test_info->test_base_name << \"/\" << param_name;\n          MakeAndRegisterTestInfo(\n              test_case_name.c_str(),\n              test_name_stream.GetString().c_str(),\n              NULL,  // No type parameter.\n              PrintToString(*param_it).c_str(),\n              code_location_,\n              GetTestCaseTypeId(),\n              TestCase::SetUpTestCase,\n              TestCase::TearDownTestCase,\n              test_info->test_meta_factory->CreateTestFactory(*param_it));\n        }  // for param_it\n      }  // for gen_it\n    }  // for test_it\n  }  // RegisterTests\n\n private:\n  // LocalTestInfo structure keeps information about a single test registered\n  // with TEST_P macro.\n  struct TestInfo {\n    TestInfo(const char* a_test_case_base_name,\n             const char* a_test_base_name,\n             TestMetaFactoryBase<ParamType>* a_test_meta_factory) :\n        test_case_base_name(a_test_case_base_name),\n        test_base_name(a_test_base_name),\n        test_meta_factory(a_test_meta_factory) {}\n\n    const string test_case_base_name;\n    const string test_base_name;\n    const scoped_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory;\n  };\n  typedef ::std::vector<linked_ptr<TestInfo> > TestInfoContainer;\n  // Records data received from INSTANTIATE_TEST_CASE_P macros:\n  //  <Instantiation name, Sequence generator creation function,\n  //     Name generator function, Source file, Source line>\n  struct InstantiationInfo {\n      InstantiationInfo(const std::string &name_in,\n                        GeneratorCreationFunc* generator_in,\n                        ParamNameGeneratorFunc* name_func_in,\n                        const char* file_in,\n                        int line_in)\n          : name(name_in),\n            generator(generator_in),\n            name_func(name_func_in),\n            file(file_in),\n            line(line_in) {}\n\n      std::string name;\n      GeneratorCreationFunc* generator;\n      ParamNameGeneratorFunc* name_func;\n      const char* file;\n      int line;\n  };\n  typedef ::std::vector<InstantiationInfo> InstantiationContainer;\n\n  static bool IsValidParamName(const std::string& name) {\n    // Check for empty string\n    if (name.empty())\n      return false;\n\n    // Check for invalid characters\n    for (std::string::size_type index = 0; index < name.size(); ++index) {\n      if (!isalnum(name[index]) && name[index] != '_')\n        return false;\n    }\n\n    return true;\n  }\n\n  const string test_case_name_;\n  CodeLocation code_location_;\n  TestInfoContainer tests_;\n  InstantiationContainer instantiations_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfo);\n};  // class ParameterizedTestCaseInfo\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// ParameterizedTestCaseRegistry contains a map of ParameterizedTestCaseInfoBase\n// classes accessed by test case names. TEST_P and INSTANTIATE_TEST_CASE_P\n// macros use it to locate their corresponding ParameterizedTestCaseInfo\n// descriptors.\nclass ParameterizedTestCaseRegistry {\n public:\n  ParameterizedTestCaseRegistry() {}\n  ~ParameterizedTestCaseRegistry() {\n    for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();\n         it != test_case_infos_.end(); ++it) {\n      delete *it;\n    }\n  }\n\n  // Looks up or creates and returns a structure containing information about\n  // tests and instantiations of a particular test case.\n  template <class TestCase>\n  ParameterizedTestCaseInfo<TestCase>* GetTestCasePatternHolder(\n      const char* test_case_name,\n      CodeLocation code_location) {\n    ParameterizedTestCaseInfo<TestCase>* typed_test_info = NULL;\n    for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();\n         it != test_case_infos_.end(); ++it) {\n      if ((*it)->GetTestCaseName() == test_case_name) {\n        if ((*it)->GetTestCaseTypeId() != GetTypeId<TestCase>()) {\n          // Complain about incorrect usage of Google Test facilities\n          // and terminate the program since we cannot guaranty correct\n          // test case setup and tear-down in this case.\n          ReportInvalidTestCaseType(test_case_name, code_location);\n          posix::Abort();\n        } else {\n          // At this point we are sure that the object we found is of the same\n          // type we are looking for, so we downcast it to that type\n          // without further checks.\n          typed_test_info = CheckedDowncastToActualType<\n              ParameterizedTestCaseInfo<TestCase> >(*it);\n        }\n        break;\n      }\n    }\n    if (typed_test_info == NULL) {\n      typed_test_info = new ParameterizedTestCaseInfo<TestCase>(\n          test_case_name, code_location);\n      test_case_infos_.push_back(typed_test_info);\n    }\n    return typed_test_info;\n  }\n  void RegisterTests() {\n    for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();\n         it != test_case_infos_.end(); ++it) {\n      (*it)->RegisterTests();\n    }\n  }\n\n private:\n  typedef ::std::vector<ParameterizedTestCaseInfoBase*> TestCaseInfoContainer;\n\n  TestCaseInfoContainer test_case_infos_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseRegistry);\n};\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  //  GTEST_HAS_PARAM_TEST\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/gtest-port-arch.h",
    "content": "// Copyright 2015, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This header file defines the GTEST_OS_* macro.\n// It is separate from gtest-port.h so that custom/gtest-port.h can include it.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_\n\n// Determines the platform on which Google Test is compiled.\n#ifdef __CYGWIN__\n# define GTEST_OS_CYGWIN 1\n#elif defined __SYMBIAN32__\n# define GTEST_OS_SYMBIAN 1\n#elif defined _WIN32\n# define GTEST_OS_WINDOWS 1\n# ifdef _WIN32_WCE\n#  define GTEST_OS_WINDOWS_MOBILE 1\n# elif defined(__MINGW__) || defined(__MINGW32__)\n#  define GTEST_OS_WINDOWS_MINGW 1\n# elif defined(WINAPI_FAMILY)\n#  include <winapifamily.h>\n#  if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)\n#   define GTEST_OS_WINDOWS_DESKTOP 1\n#  elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)\n#   define GTEST_OS_WINDOWS_PHONE 1\n#  elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)\n#   define GTEST_OS_WINDOWS_RT 1\n#  else\n    // WINAPI_FAMILY defined but no known partition matched.\n    // Default to desktop.\n#   define GTEST_OS_WINDOWS_DESKTOP 1\n#  endif\n# else\n#  define GTEST_OS_WINDOWS_DESKTOP 1\n# endif  // _WIN32_WCE\n#elif defined __APPLE__\n# define GTEST_OS_MAC 1\n# if TARGET_OS_IPHONE\n#  define GTEST_OS_IOS 1\n# endif\n#elif defined __FreeBSD__\n# define GTEST_OS_FREEBSD 1\n#elif defined __linux__\n# define GTEST_OS_LINUX 1\n# if defined __ANDROID__\n#  define GTEST_OS_LINUX_ANDROID 1\n# endif\n#elif defined __MVS__\n# define GTEST_OS_ZOS 1\n#elif defined(__sun) && defined(__SVR4)\n# define GTEST_OS_SOLARIS 1\n#elif defined(_AIX)\n# define GTEST_OS_AIX 1\n#elif defined(__hpux)\n# define GTEST_OS_HPUX 1\n#elif defined __native_client__\n# define GTEST_OS_NACL 1\n#elif defined __OpenBSD__\n# define GTEST_OS_OPENBSD 1\n#elif defined __QNX__\n# define GTEST_OS_QNX 1\n#endif  // __CYGWIN__\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/gtest-port.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: wan@google.com (Zhanyong Wan)\n//\n// Low-level types and utilities for porting Google Test to various\n// platforms.  All macros ending with _ and symbols defined in an\n// internal namespace are subject to change without notice.  Code\n// outside Google Test MUST NOT USE THEM DIRECTLY.  Macros that don't\n// end with _ are part of Google Test's public API and can be used by\n// code outside Google Test.\n//\n// This file is fundamental to Google Test.  All other Google Test source\n// files are expected to #include this.  Therefore, it cannot #include\n// any other Google Test header.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_\n\n// Environment-describing macros\n// -----------------------------\n//\n// Google Test can be used in many different environments.  Macros in\n// this section tell Google Test what kind of environment it is being\n// used in, such that Google Test can provide environment-specific\n// features and implementations.\n//\n// Google Test tries to automatically detect the properties of its\n// environment, so users usually don't need to worry about these\n// macros.  However, the automatic detection is not perfect.\n// Sometimes it's necessary for a user to define some of the following\n// macros in the build script to override Google Test's decisions.\n//\n// If the user doesn't define a macro in the list, Google Test will\n// provide a default definition.  After this header is #included, all\n// macros in this list will be defined to either 1 or 0.\n//\n// Notes to maintainers:\n//   - Each macro here is a user-tweakable knob; do not grow the list\n//     lightly.\n//   - Use #if to key off these macros.  Don't use #ifdef or \"#if\n//     defined(...)\", which will not work as these macros are ALWAYS\n//     defined.\n//\n//   GTEST_HAS_CLONE          - Define it to 1/0 to indicate that clone(2)\n//                              is/isn't available.\n//   GTEST_HAS_EXCEPTIONS     - Define it to 1/0 to indicate that exceptions\n//                              are enabled.\n//   GTEST_HAS_GLOBAL_STRING  - Define it to 1/0 to indicate that ::string\n//                              is/isn't available (some systems define\n//                              ::string, which is different to std::string).\n//   GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::string\n//                              is/isn't available (some systems define\n//                              ::wstring, which is different to std::wstring).\n//   GTEST_HAS_POSIX_RE       - Define it to 1/0 to indicate that POSIX regular\n//                              expressions are/aren't available.\n//   GTEST_HAS_PTHREAD        - Define it to 1/0 to indicate that <pthread.h>\n//                              is/isn't available.\n//   GTEST_HAS_RTTI           - Define it to 1/0 to indicate that RTTI is/isn't\n//                              enabled.\n//   GTEST_HAS_STD_WSTRING    - Define it to 1/0 to indicate that\n//                              std::wstring does/doesn't work (Google Test can\n//                              be used where std::wstring is unavailable).\n//   GTEST_HAS_TR1_TUPLE      - Define it to 1/0 to indicate tr1::tuple\n//                              is/isn't available.\n//   GTEST_HAS_SEH            - Define it to 1/0 to indicate whether the\n//                              compiler supports Microsoft's \"Structured\n//                              Exception Handling\".\n//   GTEST_HAS_STREAM_REDIRECTION\n//                            - Define it to 1/0 to indicate whether the\n//                              platform supports I/O stream redirection using\n//                              dup() and dup2().\n//   GTEST_USE_OWN_TR1_TUPLE  - Define it to 1/0 to indicate whether Google\n//                              Test's own tr1 tuple implementation should be\n//                              used.  Unused when the user sets\n//                              GTEST_HAS_TR1_TUPLE to 0.\n//   GTEST_LANG_CXX11         - Define it to 1/0 to indicate that Google Test\n//                              is building in C++11/C++98 mode.\n//   GTEST_LINKED_AS_SHARED_LIBRARY\n//                            - Define to 1 when compiling tests that use\n//                              Google Test as a shared library (known as\n//                              DLL on Windows).\n//   GTEST_CREATE_SHARED_LIBRARY\n//                            - Define to 1 when compiling Google Test itself\n//                              as a shared library.\n\n// Platform-indicating macros\n// --------------------------\n//\n// Macros indicating the platform on which Google Test is being used\n// (a macro is defined to 1 if compiled on the given platform;\n// otherwise UNDEFINED -- it's never defined to 0.).  Google Test\n// defines these macros automatically.  Code outside Google Test MUST\n// NOT define them.\n//\n//   GTEST_OS_AIX      - IBM AIX\n//   GTEST_OS_CYGWIN   - Cygwin\n//   GTEST_OS_FREEBSD  - FreeBSD\n//   GTEST_OS_HPUX     - HP-UX\n//   GTEST_OS_LINUX    - Linux\n//     GTEST_OS_LINUX_ANDROID - Google Android\n//   GTEST_OS_MAC      - Mac OS X\n//     GTEST_OS_IOS    - iOS\n//   GTEST_OS_NACL     - Google Native Client (NaCl)\n//   GTEST_OS_OPENBSD  - OpenBSD\n//   GTEST_OS_QNX      - QNX\n//   GTEST_OS_SOLARIS  - Sun Solaris\n//   GTEST_OS_SYMBIAN  - Symbian\n//   GTEST_OS_WINDOWS  - Windows (Desktop, MinGW, or Mobile)\n//     GTEST_OS_WINDOWS_DESKTOP  - Windows Desktop\n//     GTEST_OS_WINDOWS_MINGW    - MinGW\n//     GTEST_OS_WINDOWS_MOBILE   - Windows Mobile\n//     GTEST_OS_WINDOWS_PHONE    - Windows Phone\n//     GTEST_OS_WINDOWS_RT       - Windows Store App/WinRT\n//   GTEST_OS_ZOS      - z/OS\n//\n// Among the platforms, Cygwin, Linux, Max OS X, and Windows have the\n// most stable support.  Since core members of the Google Test project\n// don't have access to other platforms, support for them may be less\n// stable.  If you notice any problems on your platform, please notify\n// googletestframework@googlegroups.com (patches for fixing them are\n// even more welcome!).\n//\n// It is possible that none of the GTEST_OS_* macros are defined.\n\n// Feature-indicating macros\n// -------------------------\n//\n// Macros indicating which Google Test features are available (a macro\n// is defined to 1 if the corresponding feature is supported;\n// otherwise UNDEFINED -- it's never defined to 0.).  Google Test\n// defines these macros automatically.  Code outside Google Test MUST\n// NOT define them.\n//\n// These macros are public so that portable tests can be written.\n// Such tests typically surround code using a feature with an #if\n// which controls that code.  For example:\n//\n// #if GTEST_HAS_DEATH_TEST\n//   EXPECT_DEATH(DoSomethingDeadly());\n// #endif\n//\n//   GTEST_HAS_COMBINE      - the Combine() function (for value-parameterized\n//                            tests)\n//   GTEST_HAS_DEATH_TEST   - death tests\n//   GTEST_HAS_PARAM_TEST   - value-parameterized tests\n//   GTEST_HAS_TYPED_TEST   - typed tests\n//   GTEST_HAS_TYPED_TEST_P - type-parameterized tests\n//   GTEST_IS_THREADSAFE    - Google Test is thread-safe.\n//   GTEST_USES_POSIX_RE    - enhanced POSIX regex is used. Do not confuse with\n//                            GTEST_HAS_POSIX_RE (see above) which users can\n//                            define themselves.\n//   GTEST_USES_SIMPLE_RE   - our own simple regex is used;\n//                            the above two are mutually exclusive.\n//   GTEST_CAN_COMPARE_NULL - accepts untyped NULL in EXPECT_EQ().\n\n// Misc public macros\n// ------------------\n//\n//   GTEST_FLAG(flag_name)  - references the variable corresponding to\n//                            the given Google Test flag.\n\n// Internal utilities\n// ------------------\n//\n// The following macros and utilities are for Google Test's INTERNAL\n// use only.  Code outside Google Test MUST NOT USE THEM DIRECTLY.\n//\n// Macros for basic C++ coding:\n//   GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.\n//   GTEST_ATTRIBUTE_UNUSED_  - declares that a class' instances or a\n//                              variable don't have to be used.\n//   GTEST_DISALLOW_ASSIGN_   - disables operator=.\n//   GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.\n//   GTEST_MUST_USE_RESULT_   - declares that a function's result must be used.\n//   GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is\n//                                        suppressed (constant conditional).\n//   GTEST_INTENTIONAL_CONST_COND_POP_  - finish code section where MSVC C4127\n//                                        is suppressed.\n//\n// C++11 feature wrappers:\n//\n//   testing::internal::move  - portability wrapper for std::move.\n//\n// Synchronization:\n//   Mutex, MutexLock, ThreadLocal, GetThreadCount()\n//                            - synchronization primitives.\n//\n// Template meta programming:\n//   is_pointer     - as in TR1; needed on Symbian and IBM XL C/C++ only.\n//   IteratorTraits - partial implementation of std::iterator_traits, which\n//                    is not available in libCstd when compiled with Sun C++.\n//\n// Smart pointers:\n//   scoped_ptr     - as in TR2.\n//\n// Regular expressions:\n//   RE             - a simple regular expression class using the POSIX\n//                    Extended Regular Expression syntax on UNIX-like\n//                    platforms, or a reduced regular exception syntax on\n//                    other platforms, including Windows.\n//\n// Logging:\n//   GTEST_LOG_()   - logs messages at the specified severity level.\n//   LogToStderr()  - directs all log messages to stderr.\n//   FlushInfoLog() - flushes informational log messages.\n//\n// Stdout and stderr capturing:\n//   CaptureStdout()     - starts capturing stdout.\n//   GetCapturedStdout() - stops capturing stdout and returns the captured\n//                         string.\n//   CaptureStderr()     - starts capturing stderr.\n//   GetCapturedStderr() - stops capturing stderr and returns the captured\n//                         string.\n//\n// Integer types:\n//   TypeWithSize   - maps an integer to a int type.\n//   Int32, UInt32, Int64, UInt64, TimeInMillis\n//                  - integers of known sizes.\n//   BiggestInt     - the biggest signed integer type.\n//\n// Command-line utilities:\n//   GTEST_DECLARE_*()  - declares a flag.\n//   GTEST_DEFINE_*()   - defines a flag.\n//   GetInjectableArgvs() - returns the command line as a vector of strings.\n//\n// Environment variable utilities:\n//   GetEnv()             - gets the value of an environment variable.\n//   BoolFromGTestEnv()   - parses a bool environment variable.\n//   Int32FromGTestEnv()  - parses an Int32 environment variable.\n//   StringFromGTestEnv() - parses a string environment variable.\n\n#include <ctype.h>   // for isspace, etc\n#include <stddef.h>  // for ptrdiff_t\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#ifndef _WIN32_WCE\n# include <sys/types.h>\n# include <sys/stat.h>\n#endif  // !_WIN32_WCE\n\n#if defined __APPLE__\n# include <AvailabilityMacros.h>\n# include <TargetConditionals.h>\n#endif\n\n#include <algorithm>  // NOLINT\n#include <iostream>  // NOLINT\n#include <sstream>  // NOLINT\n#include <string>  // NOLINT\n#include <utility>\n#include <vector>  // NOLINT\n\n#include \"gtest/internal/gtest-port-arch.h\"\n#include \"gtest/internal/custom/gtest-port.h\"\n\n#if !defined(GTEST_DEV_EMAIL_)\n# define GTEST_DEV_EMAIL_ \"googletestframework@@googlegroups.com\"\n# define GTEST_FLAG_PREFIX_ \"gtest_\"\n# define GTEST_FLAG_PREFIX_DASH_ \"gtest-\"\n# define GTEST_FLAG_PREFIX_UPPER_ \"GTEST_\"\n# define GTEST_NAME_ \"Google Test\"\n# define GTEST_PROJECT_URL_ \"https://github.com/google/googletest/\"\n#endif  // !defined(GTEST_DEV_EMAIL_)\n\n#if !defined(GTEST_INIT_GOOGLE_TEST_NAME_)\n# define GTEST_INIT_GOOGLE_TEST_NAME_ \"testing::InitGoogleTest\"\n#endif  // !defined(GTEST_INIT_GOOGLE_TEST_NAME_)\n\n// Determines the version of gcc that is used to compile this.\n#ifdef __GNUC__\n// 40302 means version 4.3.2.\n# define GTEST_GCC_VER_ \\\n    (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)\n#endif  // __GNUC__\n\n// Macros for disabling Microsoft Visual C++ warnings.\n//\n//   GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385)\n//   /* code that triggers warnings C4800 and C4385 */\n//   GTEST_DISABLE_MSC_WARNINGS_POP_()\n#if _MSC_VER >= 1500\n# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \\\n    __pragma(warning(push))                        \\\n    __pragma(warning(disable: warnings))\n# define GTEST_DISABLE_MSC_WARNINGS_POP_()          \\\n    __pragma(warning(pop))\n#else\n// Older versions of MSVC don't have __pragma.\n# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)\n# define GTEST_DISABLE_MSC_WARNINGS_POP_()\n#endif\n\n#ifndef GTEST_LANG_CXX11\n// gcc and clang define __GXX_EXPERIMENTAL_CXX0X__ when\n// -std={c,gnu}++{0x,11} is passed.  The C++11 standard specifies a\n// value for __cplusplus, and recent versions of clang, gcc, and\n// probably other compilers set that too in C++11 mode.\n# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L\n// Compiling in at least C++11 mode.\n#  define GTEST_LANG_CXX11 1\n# else\n#  define GTEST_LANG_CXX11 0\n# endif\n#endif\n\n// Distinct from C++11 language support, some environments don't provide\n// proper C++11 library support. Notably, it's possible to build in\n// C++11 mode when targeting Mac OS X 10.6, which has an old libstdc++\n// with no C++11 support.\n//\n// libstdc++ has sufficient C++11 support as of GCC 4.6.0, __GLIBCXX__\n// 20110325, but maintenance releases in the 4.4 and 4.5 series followed\n// this date, so check for those versions by their date stamps.\n// https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning\n#if GTEST_LANG_CXX11 && \\\n    (!defined(__GLIBCXX__) || ( \\\n        __GLIBCXX__ >= 20110325ul &&  /* GCC >= 4.6.0 */ \\\n        /* Blacklist of patch releases of older branches: */ \\\n        __GLIBCXX__ != 20110416ul &&  /* GCC 4.4.6 */ \\\n        __GLIBCXX__ != 20120313ul &&  /* GCC 4.4.7 */ \\\n        __GLIBCXX__ != 20110428ul &&  /* GCC 4.5.3 */ \\\n        __GLIBCXX__ != 20120702ul))   /* GCC 4.5.4 */\n# define GTEST_STDLIB_CXX11 1\n#endif\n\n// Only use C++11 library features if the library provides them.\n#if GTEST_STDLIB_CXX11\n# define GTEST_HAS_STD_BEGIN_AND_END_ 1\n# define GTEST_HAS_STD_FORWARD_LIST_ 1\n# define GTEST_HAS_STD_FUNCTION_ 1\n# define GTEST_HAS_STD_INITIALIZER_LIST_ 1\n# define GTEST_HAS_STD_MOVE_ 1\n# define GTEST_HAS_STD_SHARED_PTR_ 1\n# define GTEST_HAS_STD_TYPE_TRAITS_ 1\n# define GTEST_HAS_STD_UNIQUE_PTR_ 1\n#endif\n\n// C++11 specifies that <tuple> provides std::tuple.\n// Some platforms still might not have it, however.\n#if GTEST_LANG_CXX11\n# define GTEST_HAS_STD_TUPLE_ 1\n# if defined(__clang__)\n// Inspired by http://clang.llvm.org/docs/LanguageExtensions.html#__has_include\n#  if defined(__has_include) && !__has_include(<tuple>)\n#   undef GTEST_HAS_STD_TUPLE_\n#  endif\n# elif defined(_MSC_VER)\n// Inspired by boost/config/stdlib/dinkumware.hpp\n#  if defined(_CPPLIB_VER) && _CPPLIB_VER < 520\n#   undef GTEST_HAS_STD_TUPLE_\n#  endif\n# elif defined(__GLIBCXX__)\n// Inspired by boost/config/stdlib/libstdcpp3.hpp,\n// http://gcc.gnu.org/gcc-4.2/changes.html and\n// http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt01ch01.html#manual.intro.status.standard.200x\n#  if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)\n#   undef GTEST_HAS_STD_TUPLE_\n#  endif\n# endif\n#endif\n\n// Brings in definitions for functions used in the testing::internal::posix\n// namespace (read, write, close, chdir, isatty, stat). We do not currently\n// use them on Windows Mobile.\n#if GTEST_OS_WINDOWS\n# if !GTEST_OS_WINDOWS_MOBILE\n#  include <direct.h>\n#  include <io.h>\n# endif\n// In order to avoid having to include <windows.h>, use forward declaration\n// assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.\n// This assumption is verified by\n// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.\nstruct _RTL_CRITICAL_SECTION;\n#else\n// This assumes that non-Windows OSes provide unistd.h. For OSes where this\n// is not the case, we need to include headers that provide the functions\n// mentioned above.\n# include <unistd.h>\n# include <strings.h>\n#endif  // GTEST_OS_WINDOWS\n\n#if GTEST_OS_LINUX_ANDROID\n// Used to define __ANDROID_API__ matching the target NDK API level.\n#  include <android/api-level.h>  // NOLINT\n#endif\n\n// Defines this to true iff Google Test can use POSIX regular expressions.\n#ifndef GTEST_HAS_POSIX_RE\n# if GTEST_OS_LINUX_ANDROID\n// On Android, <regex.h> is only available starting with Gingerbread.\n#  define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9)\n# else\n#  define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS)\n# endif\n#endif\n\n#if GTEST_USES_PCRE\n// The appropriate headers have already been included.\n\n#elif GTEST_HAS_POSIX_RE\n\n// On some platforms, <regex.h> needs someone to define size_t, and\n// won't compile otherwise.  We can #include it here as we already\n// included <stdlib.h>, which is guaranteed to define size_t through\n// <stddef.h>.\n# include <regex.h>  // NOLINT\n\n# define GTEST_USES_POSIX_RE 1\n\n#elif GTEST_OS_WINDOWS\n\n// <regex.h> is not available on Windows.  Use our own simple regex\n// implementation instead.\n# define GTEST_USES_SIMPLE_RE 1\n\n#else\n\n// <regex.h> may not be available on this platform.  Use our own\n// simple regex implementation instead.\n# define GTEST_USES_SIMPLE_RE 1\n\n#endif  // GTEST_USES_PCRE\n\n#ifndef GTEST_HAS_EXCEPTIONS\n// The user didn't tell us whether exceptions are enabled, so we need\n// to figure it out.\n# if defined(_MSC_VER) || defined(__BORLANDC__)\n// MSVC's and C++Builder's implementations of the STL use the _HAS_EXCEPTIONS\n// macro to enable exceptions, so we'll do the same.\n// Assumes that exceptions are enabled by default.\n#  ifndef _HAS_EXCEPTIONS\n#   define _HAS_EXCEPTIONS 1\n#  endif  // _HAS_EXCEPTIONS\n#  define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS\n# elif defined(__clang__)\n// clang defines __EXCEPTIONS iff exceptions are enabled before clang 220714,\n// but iff cleanups are enabled after that. In Obj-C++ files, there can be\n// cleanups for ObjC exceptions which also need cleanups, even if C++ exceptions\n// are disabled. clang has __has_feature(cxx_exceptions) which checks for C++\n// exceptions starting at clang r206352, but which checked for cleanups prior to\n// that. To reliably check for C++ exception availability with clang, check for\n// __EXCEPTIONS && __has_feature(cxx_exceptions).\n#  define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions))\n# elif defined(__GNUC__) && __EXCEPTIONS\n// gcc defines __EXCEPTIONS to 1 iff exceptions are enabled.\n#  define GTEST_HAS_EXCEPTIONS 1\n# elif defined(__SUNPRO_CC)\n// Sun Pro CC supports exceptions.  However, there is no compile-time way of\n// detecting whether they are enabled or not.  Therefore, we assume that\n// they are enabled unless the user tells us otherwise.\n#  define GTEST_HAS_EXCEPTIONS 1\n# elif defined(__IBMCPP__) && __EXCEPTIONS\n// xlC defines __EXCEPTIONS to 1 iff exceptions are enabled.\n#  define GTEST_HAS_EXCEPTIONS 1\n# elif defined(__HP_aCC)\n// Exception handling is in effect by default in HP aCC compiler. It has to\n// be turned of by +noeh compiler option if desired.\n#  define GTEST_HAS_EXCEPTIONS 1\n# else\n// For other compilers, we assume exceptions are disabled to be\n// conservative.\n#  define GTEST_HAS_EXCEPTIONS 0\n# endif  // defined(_MSC_VER) || defined(__BORLANDC__)\n#endif  // GTEST_HAS_EXCEPTIONS\n\n#if !defined(GTEST_HAS_STD_STRING)\n// Even though we don't use this macro any longer, we keep it in case\n// some clients still depend on it.\n# define GTEST_HAS_STD_STRING 1\n#elif !GTEST_HAS_STD_STRING\n// The user told us that ::std::string isn't available.\n# error \"Google Test cannot be used where ::std::string isn't available.\"\n#endif  // !defined(GTEST_HAS_STD_STRING)\n\n#ifndef GTEST_HAS_GLOBAL_STRING\n// The user didn't tell us whether ::string is available, so we need\n// to figure it out.\n\n# define GTEST_HAS_GLOBAL_STRING 0\n\n#endif  // GTEST_HAS_GLOBAL_STRING\n\n#ifndef GTEST_HAS_STD_WSTRING\n// The user didn't tell us whether ::std::wstring is available, so we need\n// to figure it out.\n// TODO(wan@google.com): uses autoconf to detect whether ::std::wstring\n//   is available.\n\n// Cygwin 1.7 and below doesn't support ::std::wstring.\n// Solaris' libc++ doesn't support it either.  Android has\n// no support for it at least as recent as Froyo (2.2).\n# define GTEST_HAS_STD_WSTRING \\\n    (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS))\n\n#endif  // GTEST_HAS_STD_WSTRING\n\n#ifndef GTEST_HAS_GLOBAL_WSTRING\n// The user didn't tell us whether ::wstring is available, so we need\n// to figure it out.\n# define GTEST_HAS_GLOBAL_WSTRING \\\n    (GTEST_HAS_STD_WSTRING && GTEST_HAS_GLOBAL_STRING)\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n// Determines whether RTTI is available.\n#ifndef GTEST_HAS_RTTI\n// The user didn't tell us whether RTTI is enabled, so we need to\n// figure it out.\n\n# ifdef _MSC_VER\n\n#  ifdef _CPPRTTI  // MSVC defines this macro iff RTTI is enabled.\n#   define GTEST_HAS_RTTI 1\n#  else\n#   define GTEST_HAS_RTTI 0\n#  endif\n\n// Starting with version 4.3.2, gcc defines __GXX_RTTI iff RTTI is enabled.\n# elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40302)\n\n#  ifdef __GXX_RTTI\n// When building against STLport with the Android NDK and with\n// -frtti -fno-exceptions, the build fails at link time with undefined\n// references to __cxa_bad_typeid. Note sure if STL or toolchain bug,\n// so disable RTTI when detected.\n#   if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) && \\\n       !defined(__EXCEPTIONS)\n#    define GTEST_HAS_RTTI 0\n#   else\n#    define GTEST_HAS_RTTI 1\n#   endif  // GTEST_OS_LINUX_ANDROID && __STLPORT_MAJOR && !__EXCEPTIONS\n#  else\n#   define GTEST_HAS_RTTI 0\n#  endif  // __GXX_RTTI\n\n// Clang defines __GXX_RTTI starting with version 3.0, but its manual recommends\n// using has_feature instead. has_feature(cxx_rtti) is supported since 2.7, the\n// first version with C++ support.\n# elif defined(__clang__)\n\n#  define GTEST_HAS_RTTI __has_feature(cxx_rtti)\n\n// Starting with version 9.0 IBM Visual Age defines __RTTI_ALL__ to 1 if\n// both the typeid and dynamic_cast features are present.\n# elif defined(__IBMCPP__) && (__IBMCPP__ >= 900)\n\n#  ifdef __RTTI_ALL__\n#   define GTEST_HAS_RTTI 1\n#  else\n#   define GTEST_HAS_RTTI 0\n#  endif\n\n# else\n\n// For all other compilers, we assume RTTI is enabled.\n#  define GTEST_HAS_RTTI 1\n\n# endif  // _MSC_VER\n\n#endif  // GTEST_HAS_RTTI\n\n// It's this header's responsibility to #include <typeinfo> when RTTI\n// is enabled.\n#if GTEST_HAS_RTTI\n# include <typeinfo>\n#endif\n\n// Determines whether Google Test can use the pthreads library.\n#ifndef GTEST_HAS_PTHREAD\n// The user didn't tell us explicitly, so we make reasonable assumptions about\n// which platforms have pthreads support.\n//\n// To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0\n// to your compiler flags.\n# define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX \\\n    || GTEST_OS_QNX || GTEST_OS_FREEBSD || GTEST_OS_NACL)\n#endif  // GTEST_HAS_PTHREAD\n\n#if GTEST_HAS_PTHREAD\n// gtest-port.h guarantees to #include <pthread.h> when GTEST_HAS_PTHREAD is\n// true.\n# include <pthread.h>  // NOLINT\n\n// For timespec and nanosleep, used below.\n# include <time.h>  // NOLINT\n#endif\n\n// Determines if hash_map/hash_set are available.\n// Only used for testing against those containers.\n#if !defined(GTEST_HAS_HASH_MAP_)\n# if _MSC_VER\n#  define GTEST_HAS_HASH_MAP_ 1  // Indicates that hash_map is available.\n#  define GTEST_HAS_HASH_SET_ 1  // Indicates that hash_set is available.\n# endif  // _MSC_VER\n#endif  // !defined(GTEST_HAS_HASH_MAP_)\n\n// Determines whether Google Test can use tr1/tuple.  You can define\n// this macro to 0 to prevent Google Test from using tuple (any\n// feature depending on tuple with be disabled in this mode).\n#ifndef GTEST_HAS_TR1_TUPLE\n# if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR)\n// STLport, provided with the Android NDK, has neither <tr1/tuple> or <tuple>.\n#  define GTEST_HAS_TR1_TUPLE 0\n# else\n// The user didn't tell us not to do it, so we assume it's OK.\n#  define GTEST_HAS_TR1_TUPLE 1\n# endif\n#endif  // GTEST_HAS_TR1_TUPLE\n\n// Determines whether Google Test's own tr1 tuple implementation\n// should be used.\n#ifndef GTEST_USE_OWN_TR1_TUPLE\n// The user didn't tell us, so we need to figure it out.\n\n// We use our own TR1 tuple if we aren't sure the user has an\n// implementation of it already.  At this time, libstdc++ 4.0.0+ and\n// MSVC 2010 are the only mainstream standard libraries that come\n// with a TR1 tuple implementation.  NVIDIA's CUDA NVCC compiler\n// pretends to be GCC by defining __GNUC__ and friends, but cannot\n// compile GCC's tuple implementation.  MSVC 2008 (9.0) provides TR1\n// tuple in a 323 MB Feature Pack download, which we cannot assume the\n// user has.  QNX's QCC compiler is a modified GCC but it doesn't\n// support TR1 tuple.  libc++ only provides std::tuple, in C++11 mode,\n// and it can be used with some compilers that define __GNUC__.\n# if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \\\n      && !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) || _MSC_VER >= 1600\n#  define GTEST_ENV_HAS_TR1_TUPLE_ 1\n# endif\n\n// C++11 specifies that <tuple> provides std::tuple. Use that if gtest is used\n// in C++11 mode and libstdc++ isn't very old (binaries targeting OS X 10.6\n// can build with clang but need to use gcc4.2's libstdc++).\n# if GTEST_LANG_CXX11 && (!defined(__GLIBCXX__) || __GLIBCXX__ > 20110325)\n#  define GTEST_ENV_HAS_STD_TUPLE_ 1\n# endif\n\n# if GTEST_ENV_HAS_TR1_TUPLE_ || GTEST_ENV_HAS_STD_TUPLE_\n#  define GTEST_USE_OWN_TR1_TUPLE 0\n# else\n#  define GTEST_USE_OWN_TR1_TUPLE 1\n# endif\n\n#endif  // GTEST_USE_OWN_TR1_TUPLE\n\n// To avoid conditional compilation everywhere, we make it\n// gtest-port.h's responsibility to #include the header implementing\n// tuple.\n#if GTEST_HAS_STD_TUPLE_\n# include <tuple>  // IWYU pragma: export\n# define GTEST_TUPLE_NAMESPACE_ ::std\n#endif  // GTEST_HAS_STD_TUPLE_\n\n// We include tr1::tuple even if std::tuple is available to define printers for\n// them.\n#if GTEST_HAS_TR1_TUPLE\n# ifndef GTEST_TUPLE_NAMESPACE_\n#  define GTEST_TUPLE_NAMESPACE_ ::std::tr1\n# endif  // GTEST_TUPLE_NAMESPACE_\n\n# if GTEST_USE_OWN_TR1_TUPLE\n#  include \"gtest/internal/gtest-tuple.h\"  // IWYU pragma: export  // NOLINT\n# elif GTEST_ENV_HAS_STD_TUPLE_\n#  include <tuple>\n// C++11 puts its tuple into the ::std namespace rather than\n// ::std::tr1.  gtest expects tuple to live in ::std::tr1, so put it there.\n// This causes undefined behavior, but supported compilers react in\n// the way we intend.\nnamespace std {\nnamespace tr1 {\nusing ::std::get;\nusing ::std::make_tuple;\nusing ::std::tuple;\nusing ::std::tuple_element;\nusing ::std::tuple_size;\n}\n}\n\n# elif GTEST_OS_SYMBIAN\n\n// On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to\n// use STLport's tuple implementation, which unfortunately doesn't\n// work as the copy of STLport distributed with Symbian is incomplete.\n// By making sure BOOST_HAS_TR1_TUPLE is undefined, we force Boost to\n// use its own tuple implementation.\n#  ifdef BOOST_HAS_TR1_TUPLE\n#   undef BOOST_HAS_TR1_TUPLE\n#  endif  // BOOST_HAS_TR1_TUPLE\n\n// This prevents <boost/tr1/detail/config.hpp>, which defines\n// BOOST_HAS_TR1_TUPLE, from being #included by Boost's <tuple>.\n#  define BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED\n#  include <tuple>  // IWYU pragma: export  // NOLINT\n\n# elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40000)\n// GCC 4.0+ implements tr1/tuple in the <tr1/tuple> header.  This does\n// not conform to the TR1 spec, which requires the header to be <tuple>.\n\n#  if !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302\n// Until version 4.3.2, gcc has a bug that causes <tr1/functional>,\n// which is #included by <tr1/tuple>, to not compile when RTTI is\n// disabled.  _TR1_FUNCTIONAL is the header guard for\n// <tr1/functional>.  Hence the following #define is a hack to prevent\n// <tr1/functional> from being included.\n#   define _TR1_FUNCTIONAL 1\n#   include <tr1/tuple>\n#   undef _TR1_FUNCTIONAL  // Allows the user to #include\n                        // <tr1/functional> if he chooses to.\n#  else\n#   include <tr1/tuple>  // NOLINT\n#  endif  // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302\n\n# else\n// If the compiler is not GCC 4.0+, we assume the user is using a\n// spec-conforming TR1 implementation.\n#  include <tuple>  // IWYU pragma: export  // NOLINT\n# endif  // GTEST_USE_OWN_TR1_TUPLE\n\n#endif  // GTEST_HAS_TR1_TUPLE\n\n// Determines whether clone(2) is supported.\n// Usually it will only be available on Linux, excluding\n// Linux on the Itanium architecture.\n// Also see http://linux.die.net/man/2/clone.\n#ifndef GTEST_HAS_CLONE\n// The user didn't tell us, so we need to figure it out.\n\n# if GTEST_OS_LINUX && !defined(__ia64__)\n#  if GTEST_OS_LINUX_ANDROID\n// On Android, clone() is only available on ARM starting with Gingerbread.\n#    if defined(__arm__) && __ANDROID_API__ >= 9\n#     define GTEST_HAS_CLONE 1\n#    else\n#     define GTEST_HAS_CLONE 0\n#    endif\n#  else\n#   define GTEST_HAS_CLONE 1\n#  endif\n# else\n#  define GTEST_HAS_CLONE 0\n# endif  // GTEST_OS_LINUX && !defined(__ia64__)\n\n#endif  // GTEST_HAS_CLONE\n\n// Determines whether to support stream redirection. This is used to test\n// output correctness and to implement death tests.\n#ifndef GTEST_HAS_STREAM_REDIRECTION\n// By default, we assume that stream redirection is supported on all\n// platforms except known mobile ones.\n# if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || \\\n    GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT\n#  define GTEST_HAS_STREAM_REDIRECTION 0\n# else\n#  define GTEST_HAS_STREAM_REDIRECTION 1\n# endif  // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_SYMBIAN\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\n// Determines whether to support death tests.\n// Google Test does not support death tests for VC 7.1 and earlier as\n// abort() in a VC 7.1 application compiled as GUI in debug config\n// pops up a dialog window that cannot be suppressed programmatically.\n#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \\\n     (GTEST_OS_MAC && !GTEST_OS_IOS) || \\\n     (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \\\n     GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \\\n     GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD)\n# define GTEST_HAS_DEATH_TEST 1\n#endif\n\n// We don't support MSVC 7.1 with exceptions disabled now.  Therefore\n// all the compilers we care about are adequate for supporting\n// value-parameterized tests.\n#define GTEST_HAS_PARAM_TEST 1\n\n// Determines whether to support type-driven tests.\n\n// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,\n// Sun Pro CC, IBM Visual Age, and HP aCC support.\n#if defined(__GNUC__) || (_MSC_VER >= 1400) || defined(__SUNPRO_CC) || \\\n    defined(__IBMCPP__) || defined(__HP_aCC)\n# define GTEST_HAS_TYPED_TEST 1\n# define GTEST_HAS_TYPED_TEST_P 1\n#endif\n\n// Determines whether to support Combine(). This only makes sense when\n// value-parameterized tests are enabled.  The implementation doesn't\n// work on Sun Studio since it doesn't understand templated conversion\n// operators.\n#if GTEST_HAS_PARAM_TEST && GTEST_HAS_TR1_TUPLE && !defined(__SUNPRO_CC)\n# define GTEST_HAS_COMBINE 1\n#endif\n\n// Determines whether the system compiler uses UTF-16 for encoding wide strings.\n#define GTEST_WIDE_STRING_USES_UTF16_ \\\n    (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_SYMBIAN || GTEST_OS_AIX)\n\n// Determines whether test results can be streamed to a socket.\n#if GTEST_OS_LINUX\n# define GTEST_CAN_STREAM_RESULTS_ 1\n#endif\n\n// Defines some utility macros.\n\n// The GNU compiler emits a warning if nested \"if\" statements are followed by\n// an \"else\" statement and braces are not used to explicitly disambiguate the\n// \"else\" binding.  This leads to problems with code like:\n//\n//   if (gate)\n//     ASSERT_*(condition) << \"Some message\";\n//\n// The \"switch (0) case 0:\" idiom is used to suppress this.\n#ifdef __INTEL_COMPILER\n# define GTEST_AMBIGUOUS_ELSE_BLOCKER_\n#else\n# define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default:  // NOLINT\n#endif\n\n// Use this annotation at the end of a struct/class definition to\n// prevent the compiler from optimizing away instances that are never\n// used.  This is useful when all interesting logic happens inside the\n// c'tor and / or d'tor.  Example:\n//\n//   struct Foo {\n//     Foo() { ... }\n//   } GTEST_ATTRIBUTE_UNUSED_;\n//\n// Also use it after a variable or parameter declaration to tell the\n// compiler the variable/parameter does not have to be used.\n#if defined(__GNUC__) && !defined(COMPILER_ICC)\n# define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))\n#elif defined(__clang__)\n# if __has_attribute(unused)\n#  define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))\n# endif\n#endif\n#ifndef GTEST_ATTRIBUTE_UNUSED_\n# define GTEST_ATTRIBUTE_UNUSED_\n#endif\n\n// A macro to disallow operator=\n// This should be used in the private: declarations for a class.\n#define GTEST_DISALLOW_ASSIGN_(type)\\\n  void operator=(type const &)\n\n// A macro to disallow copy constructor and operator=\n// This should be used in the private: declarations for a class.\n#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\\\n  type(type const &);\\\n  GTEST_DISALLOW_ASSIGN_(type)\n\n// Tell the compiler to warn about unused return values for functions declared\n// with this macro.  The macro should be used on function declarations\n// following the argument list:\n//\n//   Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_;\n#if defined(__GNUC__) && (GTEST_GCC_VER_ >= 30400) && !defined(COMPILER_ICC)\n# define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result))\n#else\n# define GTEST_MUST_USE_RESULT_\n#endif  // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC\n\n// MS C++ compiler emits warning when a conditional expression is compile time\n// constant. In some contexts this warning is false positive and needs to be\n// suppressed. Use the following two macros in such cases:\n//\n// GTEST_INTENTIONAL_CONST_COND_PUSH_()\n// while (true) {\n// GTEST_INTENTIONAL_CONST_COND_POP_()\n// }\n# define GTEST_INTENTIONAL_CONST_COND_PUSH_() \\\n    GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127)\n# define GTEST_INTENTIONAL_CONST_COND_POP_() \\\n    GTEST_DISABLE_MSC_WARNINGS_POP_()\n\n// Determine whether the compiler supports Microsoft's Structured Exception\n// Handling.  This is supported by several Windows compilers but generally\n// does not exist on any other system.\n#ifndef GTEST_HAS_SEH\n// The user didn't tell us, so we need to figure it out.\n\n# if defined(_MSC_VER) || defined(__BORLANDC__)\n// These two compilers are known to support SEH.\n#  define GTEST_HAS_SEH 1\n# else\n// Assume no SEH.\n#  define GTEST_HAS_SEH 0\n# endif\n\n#define GTEST_IS_THREADSAFE \\\n    (GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ \\\n     || (GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) \\\n     || GTEST_HAS_PTHREAD)\n\n#endif  // GTEST_HAS_SEH\n\n#ifdef _MSC_VER\n# if GTEST_LINKED_AS_SHARED_LIBRARY\n#  define GTEST_API_ __declspec(dllimport)\n# elif GTEST_CREATE_SHARED_LIBRARY\n#  define GTEST_API_ __declspec(dllexport)\n# endif\n#elif __GNUC__ >= 4 || defined(__clang__)\n# define GTEST_API_ __attribute__((visibility (\"default\")))\n#endif // _MSC_VER\n\n#ifndef GTEST_API_\n# define GTEST_API_\n#endif\n\n#ifdef __GNUC__\n// Ask the compiler to never inline a given function.\n# define GTEST_NO_INLINE_ __attribute__((noinline))\n#else\n# define GTEST_NO_INLINE_\n#endif\n\n// _LIBCPP_VERSION is defined by the libc++ library from the LLVM project.\n#if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION)\n# define GTEST_HAS_CXXABI_H_ 1\n#else\n# define GTEST_HAS_CXXABI_H_ 0\n#endif\n\n// A function level attribute to disable checking for use of uninitialized\n// memory when built with MemorySanitizer.\n#if defined(__clang__)\n# if __has_feature(memory_sanitizer)\n#  define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ \\\n       __attribute__((no_sanitize_memory))\n# else\n#  define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_\n# endif  // __has_feature(memory_sanitizer)\n#else\n# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_\n#endif  // __clang__\n\n// A function level attribute to disable AddressSanitizer instrumentation.\n#if defined(__clang__)\n# if __has_feature(address_sanitizer)\n#  define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ \\\n       __attribute__((no_sanitize_address))\n# else\n#  define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_\n# endif  // __has_feature(address_sanitizer)\n#else\n# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_\n#endif  // __clang__\n\n// A function level attribute to disable ThreadSanitizer instrumentation.\n#if defined(__clang__)\n# if __has_feature(thread_sanitizer)\n#  define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ \\\n       __attribute__((no_sanitize_thread))\n# else\n#  define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_\n# endif  // __has_feature(thread_sanitizer)\n#else\n# define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_\n#endif  // __clang__\n\nnamespace testing {\n\nclass Message;\n\n#if defined(GTEST_TUPLE_NAMESPACE_)\n// Import tuple and friends into the ::testing namespace.\n// It is part of our interface, having them in ::testing allows us to change\n// their types as needed.\nusing GTEST_TUPLE_NAMESPACE_::get;\nusing GTEST_TUPLE_NAMESPACE_::make_tuple;\nusing GTEST_TUPLE_NAMESPACE_::tuple;\nusing GTEST_TUPLE_NAMESPACE_::tuple_size;\nusing GTEST_TUPLE_NAMESPACE_::tuple_element;\n#endif  // defined(GTEST_TUPLE_NAMESPACE_)\n\nnamespace internal {\n\n// A secret type that Google Test users don't know about.  It has no\n// definition on purpose.  Therefore it's impossible to create a\n// Secret object, which is what we want.\nclass Secret;\n\n// The GTEST_COMPILE_ASSERT_ macro can be used to verify that a compile time\n// expression is true. For example, you could use it to verify the\n// size of a static array:\n//\n//   GTEST_COMPILE_ASSERT_(GTEST_ARRAY_SIZE_(names) == NUM_NAMES,\n//                         names_incorrect_size);\n//\n// or to make sure a struct is smaller than a certain size:\n//\n//   GTEST_COMPILE_ASSERT_(sizeof(foo) < 128, foo_too_large);\n//\n// The second argument to the macro is the name of the variable. If\n// the expression is false, most compilers will issue a warning/error\n// containing the name of the variable.\n\n#if GTEST_LANG_CXX11\n# define GTEST_COMPILE_ASSERT_(expr, msg) static_assert(expr, #msg)\n#else  // !GTEST_LANG_CXX11\ntemplate <bool>\n  struct CompileAssert {\n};\n\n# define GTEST_COMPILE_ASSERT_(expr, msg) \\\n  typedef ::testing::internal::CompileAssert<(static_cast<bool>(expr))> \\\n      msg[static_cast<bool>(expr) ? 1 : -1] GTEST_ATTRIBUTE_UNUSED_\n#endif  // !GTEST_LANG_CXX11\n\n// Implementation details of GTEST_COMPILE_ASSERT_:\n//\n// (In C++11, we simply use static_assert instead of the following)\n//\n// - GTEST_COMPILE_ASSERT_ works by defining an array type that has -1\n//   elements (and thus is invalid) when the expression is false.\n//\n// - The simpler definition\n//\n//    #define GTEST_COMPILE_ASSERT_(expr, msg) typedef char msg[(expr) ? 1 : -1]\n//\n//   does not work, as gcc supports variable-length arrays whose sizes\n//   are determined at run-time (this is gcc's extension and not part\n//   of the C++ standard).  As a result, gcc fails to reject the\n//   following code with the simple definition:\n//\n//     int foo;\n//     GTEST_COMPILE_ASSERT_(foo, msg); // not supposed to compile as foo is\n//                                      // not a compile-time constant.\n//\n// - By using the type CompileAssert<(bool(expr))>, we ensures that\n//   expr is a compile-time constant.  (Template arguments must be\n//   determined at compile-time.)\n//\n// - The outter parentheses in CompileAssert<(bool(expr))> are necessary\n//   to work around a bug in gcc 3.4.4 and 4.0.1.  If we had written\n//\n//     CompileAssert<bool(expr)>\n//\n//   instead, these compilers will refuse to compile\n//\n//     GTEST_COMPILE_ASSERT_(5 > 0, some_message);\n//\n//   (They seem to think the \">\" in \"5 > 0\" marks the end of the\n//   template argument list.)\n//\n// - The array size is (bool(expr) ? 1 : -1), instead of simply\n//\n//     ((expr) ? 1 : -1).\n//\n//   This is to avoid running into a bug in MS VC 7.1, which\n//   causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.\n\n// StaticAssertTypeEqHelper is used by StaticAssertTypeEq defined in gtest.h.\n//\n// This template is declared, but intentionally undefined.\ntemplate <typename T1, typename T2>\nstruct StaticAssertTypeEqHelper;\n\ntemplate <typename T>\nstruct StaticAssertTypeEqHelper<T, T> {\n  enum { value = true };\n};\n\n// Evaluates to the number of elements in 'array'.\n#define GTEST_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0]))\n\n#if GTEST_HAS_GLOBAL_STRING\ntypedef ::string string;\n#else\ntypedef ::std::string string;\n#endif  // GTEST_HAS_GLOBAL_STRING\n\n#if GTEST_HAS_GLOBAL_WSTRING\ntypedef ::wstring wstring;\n#elif GTEST_HAS_STD_WSTRING\ntypedef ::std::wstring wstring;\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n// A helper for suppressing warnings on constant condition.  It just\n// returns 'condition'.\nGTEST_API_ bool IsTrue(bool condition);\n\n// Defines scoped_ptr.\n\n// This implementation of scoped_ptr is PARTIAL - it only contains\n// enough stuff to satisfy Google Test's need.\ntemplate <typename T>\nclass scoped_ptr {\n public:\n  typedef T element_type;\n\n  explicit scoped_ptr(T* p = NULL) : ptr_(p) {}\n  ~scoped_ptr() { reset(); }\n\n  T& operator*() const { return *ptr_; }\n  T* operator->() const { return ptr_; }\n  T* get() const { return ptr_; }\n\n  T* release() {\n    T* const ptr = ptr_;\n    ptr_ = NULL;\n    return ptr;\n  }\n\n  void reset(T* p = NULL) {\n    if (p != ptr_) {\n      if (IsTrue(sizeof(T) > 0)) {  // Makes sure T is a complete type.\n        delete ptr_;\n      }\n      ptr_ = p;\n    }\n  }\n\n  friend void swap(scoped_ptr& a, scoped_ptr& b) {\n    using std::swap;\n    swap(a.ptr_, b.ptr_);\n  }\n\n private:\n  T* ptr_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr);\n};\n\n// Defines RE.\n\n// A simple C++ wrapper for <regex.h>.  It uses the POSIX Extended\n// Regular Expression syntax.\nclass GTEST_API_ RE {\n public:\n  // A copy constructor is required by the Standard to initialize object\n  // references from r-values.\n  RE(const RE& other) { Init(other.pattern()); }\n\n  // Constructs an RE from a string.\n  RE(const ::std::string& regex) { Init(regex.c_str()); }  // NOLINT\n\n#if GTEST_HAS_GLOBAL_STRING\n\n  RE(const ::string& regex) { Init(regex.c_str()); }  // NOLINT\n\n#endif  // GTEST_HAS_GLOBAL_STRING\n\n  RE(const char* regex) { Init(regex); }  // NOLINT\n  ~RE();\n\n  // Returns the string representation of the regex.\n  const char* pattern() const { return pattern_; }\n\n  // FullMatch(str, re) returns true iff regular expression re matches\n  // the entire str.\n  // PartialMatch(str, re) returns true iff regular expression re\n  // matches a substring of str (including str itself).\n  //\n  // TODO(wan@google.com): make FullMatch() and PartialMatch() work\n  // when str contains NUL characters.\n  static bool FullMatch(const ::std::string& str, const RE& re) {\n    return FullMatch(str.c_str(), re);\n  }\n  static bool PartialMatch(const ::std::string& str, const RE& re) {\n    return PartialMatch(str.c_str(), re);\n  }\n\n#if GTEST_HAS_GLOBAL_STRING\n\n  static bool FullMatch(const ::string& str, const RE& re) {\n    return FullMatch(str.c_str(), re);\n  }\n  static bool PartialMatch(const ::string& str, const RE& re) {\n    return PartialMatch(str.c_str(), re);\n  }\n\n#endif  // GTEST_HAS_GLOBAL_STRING\n\n  static bool FullMatch(const char* str, const RE& re);\n  static bool PartialMatch(const char* str, const RE& re);\n\n private:\n  void Init(const char* regex);\n\n  // We use a const char* instead of an std::string, as Google Test used to be\n  // used where std::string is not available.  TODO(wan@google.com): change to\n  // std::string.\n  const char* pattern_;\n  bool is_valid_;\n\n#if GTEST_USES_POSIX_RE\n\n  regex_t full_regex_;     // For FullMatch().\n  regex_t partial_regex_;  // For PartialMatch().\n\n#else  // GTEST_USES_SIMPLE_RE\n\n  const char* full_pattern_;  // For FullMatch();\n\n#endif\n\n  GTEST_DISALLOW_ASSIGN_(RE);\n};\n\n// Formats a source file path and a line number as they would appear\n// in an error message from the compiler used to compile this code.\nGTEST_API_ ::std::string FormatFileLocation(const char* file, int line);\n\n// Formats a file location for compiler-independent XML output.\n// Although this function is not platform dependent, we put it next to\n// FormatFileLocation in order to contrast the two functions.\nGTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char* file,\n                                                               int line);\n\n// Defines logging utilities:\n//   GTEST_LOG_(severity) - logs messages at the specified severity level. The\n//                          message itself is streamed into the macro.\n//   LogToStderr()  - directs all log messages to stderr.\n//   FlushInfoLog() - flushes informational log messages.\n\nenum GTestLogSeverity {\n  GTEST_INFO,\n  GTEST_WARNING,\n  GTEST_ERROR,\n  GTEST_FATAL\n};\n\n// Formats log entry severity, provides a stream object for streaming the\n// log message, and terminates the message with a newline when going out of\n// scope.\nclass GTEST_API_ GTestLog {\n public:\n  GTestLog(GTestLogSeverity severity, const char* file, int line);\n\n  // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.\n  ~GTestLog();\n\n  ::std::ostream& GetStream() { return ::std::cerr; }\n\n private:\n  const GTestLogSeverity severity_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog);\n};\n\n#if !defined(GTEST_LOG_)\n\n# define GTEST_LOG_(severity) \\\n    ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \\\n                                  __FILE__, __LINE__).GetStream()\n\ninline void LogToStderr() {}\ninline void FlushInfoLog() { fflush(NULL); }\n\n#endif  // !defined(GTEST_LOG_)\n\n#if !defined(GTEST_CHECK_)\n// INTERNAL IMPLEMENTATION - DO NOT USE.\n//\n// GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition\n// is not satisfied.\n//  Synopsys:\n//    GTEST_CHECK_(boolean_condition);\n//     or\n//    GTEST_CHECK_(boolean_condition) << \"Additional message\";\n//\n//    This checks the condition and if the condition is not satisfied\n//    it prints message about the condition violation, including the\n//    condition itself, plus additional message streamed into it, if any,\n//    and then it aborts the program. It aborts the program irrespective of\n//    whether it is built in the debug mode or not.\n# define GTEST_CHECK_(condition) \\\n    GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n    if (::testing::internal::IsTrue(condition)) \\\n      ; \\\n    else \\\n      GTEST_LOG_(FATAL) << \"Condition \" #condition \" failed. \"\n#endif  // !defined(GTEST_CHECK_)\n\n// An all-mode assert to verify that the given POSIX-style function\n// call returns 0 (indicating success).  Known limitation: this\n// doesn't expand to a balanced 'if' statement, so enclose the macro\n// in {} if you need to use it as the only statement in an 'if'\n// branch.\n#define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \\\n  if (const int gtest_error = (posix_call)) \\\n    GTEST_LOG_(FATAL) << #posix_call << \"failed with error \" \\\n                      << gtest_error\n\n#if GTEST_HAS_STD_MOVE_\nusing std::move;\n#else  // GTEST_HAS_STD_MOVE_\ntemplate <typename T>\nconst T& move(const T& t) {\n  return t;\n}\n#endif  // GTEST_HAS_STD_MOVE_\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Use ImplicitCast_ as a safe version of static_cast for upcasting in\n// the type hierarchy (e.g. casting a Foo* to a SuperclassOfFoo* or a\n// const Foo*).  When you use ImplicitCast_, the compiler checks that\n// the cast is safe.  Such explicit ImplicitCast_s are necessary in\n// surprisingly many situations where C++ demands an exact type match\n// instead of an argument type convertable to a target type.\n//\n// The syntax for using ImplicitCast_ is the same as for static_cast:\n//\n//   ImplicitCast_<ToType>(expr)\n//\n// ImplicitCast_ would have been part of the C++ standard library,\n// but the proposal was submitted too late.  It will probably make\n// its way into the language in the future.\n//\n// This relatively ugly name is intentional. It prevents clashes with\n// similar functions users may have (e.g., implicit_cast). The internal\n// namespace alone is not enough because the function can be found by ADL.\ntemplate<typename To>\ninline To ImplicitCast_(To x) { return x; }\n\n// When you upcast (that is, cast a pointer from type Foo to type\n// SuperclassOfFoo), it's fine to use ImplicitCast_<>, since upcasts\n// always succeed.  When you downcast (that is, cast a pointer from\n// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because\n// how do you know the pointer is really of type SubclassOfFoo?  It\n// could be a bare Foo, or of type DifferentSubclassOfFoo.  Thus,\n// when you downcast, you should use this macro.  In debug mode, we\n// use dynamic_cast<> to double-check the downcast is legal (we die\n// if it's not).  In normal mode, we do the efficient static_cast<>\n// instead.  Thus, it's important to test in debug mode to make sure\n// the cast is legal!\n//    This is the only place in the code we should use dynamic_cast<>.\n// In particular, you SHOULDN'T be using dynamic_cast<> in order to\n// do RTTI (eg code like this:\n//    if (dynamic_cast<Subclass1>(foo)) HandleASubclass1Object(foo);\n//    if (dynamic_cast<Subclass2>(foo)) HandleASubclass2Object(foo);\n// You should design the code some other way not to need this.\n//\n// This relatively ugly name is intentional. It prevents clashes with\n// similar functions users may have (e.g., down_cast). The internal\n// namespace alone is not enough because the function can be found by ADL.\ntemplate<typename To, typename From>  // use like this: DownCast_<T*>(foo);\ninline To DownCast_(From* f) {  // so we only accept pointers\n  // Ensures that To is a sub-type of From *.  This test is here only\n  // for compile-time type checking, and has no overhead in an\n  // optimized build at run-time, as it will be optimized away\n  // completely.\n  GTEST_INTENTIONAL_CONST_COND_PUSH_()\n  if (false) {\n  GTEST_INTENTIONAL_CONST_COND_POP_()\n    const To to = NULL;\n    ::testing::internal::ImplicitCast_<From*>(to);\n  }\n\n#if GTEST_HAS_RTTI\n  // RTTI: debug mode only!\n  GTEST_CHECK_(f == NULL || dynamic_cast<To>(f) != NULL);\n#endif\n  return static_cast<To>(f);\n}\n\n// Downcasts the pointer of type Base to Derived.\n// Derived must be a subclass of Base. The parameter MUST\n// point to a class of type Derived, not any subclass of it.\n// When RTTI is available, the function performs a runtime\n// check to enforce this.\ntemplate <class Derived, class Base>\nDerived* CheckedDowncastToActualType(Base* base) {\n#if GTEST_HAS_RTTI\n  GTEST_CHECK_(typeid(*base) == typeid(Derived));\n#endif\n\n#if GTEST_HAS_DOWNCAST_\n  return ::down_cast<Derived*>(base);\n#elif GTEST_HAS_RTTI\n  return dynamic_cast<Derived*>(base);  // NOLINT\n#else\n  return static_cast<Derived*>(base);  // Poor man's downcast.\n#endif\n}\n\n#if GTEST_HAS_STREAM_REDIRECTION\n\n// Defines the stderr capturer:\n//   CaptureStdout     - starts capturing stdout.\n//   GetCapturedStdout - stops capturing stdout and returns the captured string.\n//   CaptureStderr     - starts capturing stderr.\n//   GetCapturedStderr - stops capturing stderr and returns the captured string.\n//\nGTEST_API_ void CaptureStdout();\nGTEST_API_ std::string GetCapturedStdout();\nGTEST_API_ void CaptureStderr();\nGTEST_API_ std::string GetCapturedStderr();\n\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\n// Returns a path to temporary directory.\nGTEST_API_ std::string TempDir();\n\n// Returns the size (in bytes) of a file.\nGTEST_API_ size_t GetFileSize(FILE* file);\n\n// Reads the entire content of a file as a string.\nGTEST_API_ std::string ReadEntireFile(FILE* file);\n\n// All command line arguments.\nGTEST_API_ const ::std::vector<testing::internal::string>& GetArgvs();\n\n#if GTEST_HAS_DEATH_TEST\n\nconst ::std::vector<testing::internal::string>& GetInjectableArgvs();\nvoid SetInjectableArgvs(const ::std::vector<testing::internal::string>*\n                             new_argvs);\n\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n// Defines synchronization primitives.\n#if GTEST_IS_THREADSAFE\n# if GTEST_HAS_PTHREAD\n// Sleeps for (roughly) n milliseconds.  This function is only for testing\n// Google Test's own constructs.  Don't use it in user tests, either\n// directly or indirectly.\ninline void SleepMilliseconds(int n) {\n  const timespec time = {\n    0,                  // 0 seconds.\n    n * 1000L * 1000L,  // And n ms.\n  };\n  nanosleep(&time, NULL);\n}\n# endif  // GTEST_HAS_PTHREAD\n\n# if GTEST_HAS_NOTIFICATION_\n// Notification has already been imported into the namespace.\n// Nothing to do here.\n\n# elif GTEST_HAS_PTHREAD\n// Allows a controller thread to pause execution of newly created\n// threads until notified.  Instances of this class must be created\n// and destroyed in the controller thread.\n//\n// This class is only for testing Google Test's own constructs. Do not\n// use it in user tests, either directly or indirectly.\nclass Notification {\n public:\n  Notification() : notified_(false) {\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, NULL));\n  }\n  ~Notification() {\n    pthread_mutex_destroy(&mutex_);\n  }\n\n  // Notifies all threads created with this notification to start. Must\n  // be called from the controller thread.\n  void Notify() {\n    pthread_mutex_lock(&mutex_);\n    notified_ = true;\n    pthread_mutex_unlock(&mutex_);\n  }\n\n  // Blocks until the controller thread notifies. Must be called from a test\n  // thread.\n  void WaitForNotification() {\n    for (;;) {\n      pthread_mutex_lock(&mutex_);\n      const bool notified = notified_;\n      pthread_mutex_unlock(&mutex_);\n      if (notified)\n        break;\n      SleepMilliseconds(10);\n    }\n  }\n\n private:\n  pthread_mutex_t mutex_;\n  bool notified_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);\n};\n\n# elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT\n\nGTEST_API_ void SleepMilliseconds(int n);\n\n// Provides leak-safe Windows kernel handle ownership.\n// Used in death tests and in threading support.\nclass GTEST_API_ AutoHandle {\n public:\n  // Assume that Win32 HANDLE type is equivalent to void*. Doing so allows us to\n  // avoid including <windows.h> in this header file. Including <windows.h> is\n  // undesirable because it defines a lot of symbols and macros that tend to\n  // conflict with client code. This assumption is verified by\n  // WindowsTypesTest.HANDLEIsVoidStar.\n  typedef void* Handle;\n  AutoHandle();\n  explicit AutoHandle(Handle handle);\n\n  ~AutoHandle();\n\n  Handle Get() const;\n  void Reset();\n  void Reset(Handle handle);\n\n private:\n  // Returns true iff the handle is a valid handle object that can be closed.\n  bool IsCloseable() const;\n\n  Handle handle_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle);\n};\n\n// Allows a controller thread to pause execution of newly created\n// threads until notified.  Instances of this class must be created\n// and destroyed in the controller thread.\n//\n// This class is only for testing Google Test's own constructs. Do not\n// use it in user tests, either directly or indirectly.\nclass GTEST_API_ Notification {\n public:\n  Notification();\n  void Notify();\n  void WaitForNotification();\n\n private:\n  AutoHandle event_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);\n};\n# endif  // GTEST_HAS_NOTIFICATION_\n\n// On MinGW, we can have both GTEST_OS_WINDOWS and GTEST_HAS_PTHREAD\n// defined, but we don't want to use MinGW's pthreads implementation, which\n// has conformance problems with some versions of the POSIX standard.\n# if GTEST_HAS_PTHREAD && !GTEST_OS_WINDOWS_MINGW\n\n// As a C-function, ThreadFuncWithCLinkage cannot be templated itself.\n// Consequently, it cannot select a correct instantiation of ThreadWithParam\n// in order to call its Run(). Introducing ThreadWithParamBase as a\n// non-templated base class for ThreadWithParam allows us to bypass this\n// problem.\nclass ThreadWithParamBase {\n public:\n  virtual ~ThreadWithParamBase() {}\n  virtual void Run() = 0;\n};\n\n// pthread_create() accepts a pointer to a function type with the C linkage.\n// According to the Standard (7.5/1), function types with different linkages\n// are different even if they are otherwise identical.  Some compilers (for\n// example, SunStudio) treat them as different types.  Since class methods\n// cannot be defined with C-linkage we need to define a free C-function to\n// pass into pthread_create().\nextern \"C\" inline void* ThreadFuncWithCLinkage(void* thread) {\n  static_cast<ThreadWithParamBase*>(thread)->Run();\n  return NULL;\n}\n\n// Helper class for testing Google Test's multi-threading constructs.\n// To use it, write:\n//\n//   void ThreadFunc(int param) { /* Do things with param */ }\n//   Notification thread_can_start;\n//   ...\n//   // The thread_can_start parameter is optional; you can supply NULL.\n//   ThreadWithParam<int> thread(&ThreadFunc, 5, &thread_can_start);\n//   thread_can_start.Notify();\n//\n// These classes are only for testing Google Test's own constructs. Do\n// not use them in user tests, either directly or indirectly.\ntemplate <typename T>\nclass ThreadWithParam : public ThreadWithParamBase {\n public:\n  typedef void UserThreadFunc(T);\n\n  ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start)\n      : func_(func),\n        param_(param),\n        thread_can_start_(thread_can_start),\n        finished_(false) {\n    ThreadWithParamBase* const base = this;\n    // The thread can be created only after all fields except thread_\n    // have been initialized.\n    GTEST_CHECK_POSIX_SUCCESS_(\n        pthread_create(&thread_, 0, &ThreadFuncWithCLinkage, base));\n  }\n  ~ThreadWithParam() { Join(); }\n\n  void Join() {\n    if (!finished_) {\n      GTEST_CHECK_POSIX_SUCCESS_(pthread_join(thread_, 0));\n      finished_ = true;\n    }\n  }\n\n  virtual void Run() {\n    if (thread_can_start_ != NULL)\n      thread_can_start_->WaitForNotification();\n    func_(param_);\n  }\n\n private:\n  UserThreadFunc* const func_;  // User-supplied thread function.\n  const T param_;  // User-supplied parameter to the thread function.\n  // When non-NULL, used to block execution until the controller thread\n  // notifies.\n  Notification* const thread_can_start_;\n  bool finished_;  // true iff we know that the thread function has finished.\n  pthread_t thread_;  // The native thread object.\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);\n};\n# endif  // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD ||\n         // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_\n\n# if GTEST_HAS_MUTEX_AND_THREAD_LOCAL_\n// Mutex and ThreadLocal have already been imported into the namespace.\n// Nothing to do here.\n\n# elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT\n\n// Mutex implements mutex on Windows platforms.  It is used in conjunction\n// with class MutexLock:\n//\n//   Mutex mutex;\n//   ...\n//   MutexLock lock(&mutex);  // Acquires the mutex and releases it at the\n//                            // end of the current scope.\n//\n// A static Mutex *must* be defined or declared using one of the following\n// macros:\n//   GTEST_DEFINE_STATIC_MUTEX_(g_some_mutex);\n//   GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex);\n//\n// (A non-static Mutex is defined/declared in the usual way).\nclass GTEST_API_ Mutex {\n public:\n  enum MutexType { kStatic = 0, kDynamic = 1 };\n  // We rely on kStaticMutex being 0 as it is to what the linker initializes\n  // type_ in static mutexes.  critical_section_ will be initialized lazily\n  // in ThreadSafeLazyInit().\n  enum StaticConstructorSelector { kStaticMutex = 0 };\n\n  // This constructor intentionally does nothing.  It relies on type_ being\n  // statically initialized to 0 (effectively setting it to kStatic) and on\n  // ThreadSafeLazyInit() to lazily initialize the rest of the members.\n  explicit Mutex(StaticConstructorSelector /*dummy*/) {}\n\n  Mutex();\n  ~Mutex();\n\n  void Lock();\n\n  void Unlock();\n\n  // Does nothing if the current thread holds the mutex. Otherwise, crashes\n  // with high probability.\n  void AssertHeld();\n\n private:\n  // Initializes owner_thread_id_ and critical_section_ in static mutexes.\n  void ThreadSafeLazyInit();\n\n  // Per http://blogs.msdn.com/b/oldnewthing/archive/2004/02/23/78395.aspx,\n  // we assume that 0 is an invalid value for thread IDs.\n  unsigned int owner_thread_id_;\n\n  // For static mutexes, we rely on these members being initialized to zeros\n  // by the linker.\n  MutexType type_;\n  long critical_section_init_phase_;  // NOLINT\n  _RTL_CRITICAL_SECTION* critical_section_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);\n};\n\n# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \\\n    extern ::testing::internal::Mutex mutex\n\n# define GTEST_DEFINE_STATIC_MUTEX_(mutex) \\\n    ::testing::internal::Mutex mutex(::testing::internal::Mutex::kStaticMutex)\n\n// We cannot name this class MutexLock because the ctor declaration would\n// conflict with a macro named MutexLock, which is defined on some\n// platforms. That macro is used as a defensive measure to prevent against\n// inadvertent misuses of MutexLock like \"MutexLock(&mu)\" rather than\n// \"MutexLock l(&mu)\".  Hence the typedef trick below.\nclass GTestMutexLock {\n public:\n  explicit GTestMutexLock(Mutex* mutex)\n      : mutex_(mutex) { mutex_->Lock(); }\n\n  ~GTestMutexLock() { mutex_->Unlock(); }\n\n private:\n  Mutex* const mutex_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);\n};\n\ntypedef GTestMutexLock MutexLock;\n\n// Base class for ValueHolder<T>.  Allows a caller to hold and delete a value\n// without knowing its type.\nclass ThreadLocalValueHolderBase {\n public:\n  virtual ~ThreadLocalValueHolderBase() {}\n};\n\n// Provides a way for a thread to send notifications to a ThreadLocal\n// regardless of its parameter type.\nclass ThreadLocalBase {\n public:\n  // Creates a new ValueHolder<T> object holding a default value passed to\n  // this ThreadLocal<T>'s constructor and returns it.  It is the caller's\n  // responsibility not to call this when the ThreadLocal<T> instance already\n  // has a value on the current thread.\n  virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const = 0;\n\n protected:\n  ThreadLocalBase() {}\n  virtual ~ThreadLocalBase() {}\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocalBase);\n};\n\n// Maps a thread to a set of ThreadLocals that have values instantiated on that\n// thread and notifies them when the thread exits.  A ThreadLocal instance is\n// expected to persist until all threads it has values on have terminated.\nclass GTEST_API_ ThreadLocalRegistry {\n public:\n  // Registers thread_local_instance as having value on the current thread.\n  // Returns a value that can be used to identify the thread from other threads.\n  static ThreadLocalValueHolderBase* GetValueOnCurrentThread(\n      const ThreadLocalBase* thread_local_instance);\n\n  // Invoked when a ThreadLocal instance is destroyed.\n  static void OnThreadLocalDestroyed(\n      const ThreadLocalBase* thread_local_instance);\n};\n\nclass GTEST_API_ ThreadWithParamBase {\n public:\n  void Join();\n\n protected:\n  class Runnable {\n   public:\n    virtual ~Runnable() {}\n    virtual void Run() = 0;\n  };\n\n  ThreadWithParamBase(Runnable *runnable, Notification* thread_can_start);\n  virtual ~ThreadWithParamBase();\n\n private:\n  AutoHandle thread_;\n};\n\n// Helper class for testing Google Test's multi-threading constructs.\ntemplate <typename T>\nclass ThreadWithParam : public ThreadWithParamBase {\n public:\n  typedef void UserThreadFunc(T);\n\n  ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start)\n      : ThreadWithParamBase(new RunnableImpl(func, param), thread_can_start) {\n  }\n  virtual ~ThreadWithParam() {}\n\n private:\n  class RunnableImpl : public Runnable {\n   public:\n    RunnableImpl(UserThreadFunc* func, T param)\n        : func_(func),\n          param_(param) {\n    }\n    virtual ~RunnableImpl() {}\n    virtual void Run() {\n      func_(param_);\n    }\n\n   private:\n    UserThreadFunc* const func_;\n    const T param_;\n\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(RunnableImpl);\n  };\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);\n};\n\n// Implements thread-local storage on Windows systems.\n//\n//   // Thread 1\n//   ThreadLocal<int> tl(100);  // 100 is the default value for each thread.\n//\n//   // Thread 2\n//   tl.set(150);  // Changes the value for thread 2 only.\n//   EXPECT_EQ(150, tl.get());\n//\n//   // Thread 1\n//   EXPECT_EQ(100, tl.get());  // In thread 1, tl has the original value.\n//   tl.set(200);\n//   EXPECT_EQ(200, tl.get());\n//\n// The template type argument T must have a public copy constructor.\n// In addition, the default ThreadLocal constructor requires T to have\n// a public default constructor.\n//\n// The users of a TheadLocal instance have to make sure that all but one\n// threads (including the main one) using that instance have exited before\n// destroying it. Otherwise, the per-thread objects managed for them by the\n// ThreadLocal instance are not guaranteed to be destroyed on all platforms.\n//\n// Google Test only uses global ThreadLocal objects.  That means they\n// will die after main() has returned.  Therefore, no per-thread\n// object managed by Google Test will be leaked as long as all threads\n// using Google Test have exited when main() returns.\ntemplate <typename T>\nclass ThreadLocal : public ThreadLocalBase {\n public:\n  ThreadLocal() : default_factory_(new DefaultValueHolderFactory()) {}\n  explicit ThreadLocal(const T& value)\n      : default_factory_(new InstanceValueHolderFactory(value)) {}\n\n  ~ThreadLocal() { ThreadLocalRegistry::OnThreadLocalDestroyed(this); }\n\n  T* pointer() { return GetOrCreateValue(); }\n  const T* pointer() const { return GetOrCreateValue(); }\n  const T& get() const { return *pointer(); }\n  void set(const T& value) { *pointer() = value; }\n\n private:\n  // Holds a value of T.  Can be deleted via its base class without the caller\n  // knowing the type of T.\n  class ValueHolder : public ThreadLocalValueHolderBase {\n   public:\n    ValueHolder() : value_() {}\n    explicit ValueHolder(const T& value) : value_(value) {}\n\n    T* pointer() { return &value_; }\n\n   private:\n    T value_;\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);\n  };\n\n\n  T* GetOrCreateValue() const {\n    return static_cast<ValueHolder*>(\n        ThreadLocalRegistry::GetValueOnCurrentThread(this))->pointer();\n  }\n\n  virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const {\n    return default_factory_->MakeNewHolder();\n  }\n\n  class ValueHolderFactory {\n   public:\n    ValueHolderFactory() {}\n    virtual ~ValueHolderFactory() {}\n    virtual ValueHolder* MakeNewHolder() const = 0;\n\n   private:\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory);\n  };\n\n  class DefaultValueHolderFactory : public ValueHolderFactory {\n   public:\n    DefaultValueHolderFactory() {}\n    virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); }\n\n   private:\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);\n  };\n\n  class InstanceValueHolderFactory : public ValueHolderFactory {\n   public:\n    explicit InstanceValueHolderFactory(const T& value) : value_(value) {}\n    virtual ValueHolder* MakeNewHolder() const {\n      return new ValueHolder(value_);\n    }\n\n   private:\n    const T value_;  // The value for each thread.\n\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory);\n  };\n\n  scoped_ptr<ValueHolderFactory> default_factory_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);\n};\n\n# elif GTEST_HAS_PTHREAD\n\n// MutexBase and Mutex implement mutex on pthreads-based platforms.\nclass MutexBase {\n public:\n  // Acquires this mutex.\n  void Lock() {\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_));\n    owner_ = pthread_self();\n    has_owner_ = true;\n  }\n\n  // Releases this mutex.\n  void Unlock() {\n    // Since the lock is being released the owner_ field should no longer be\n    // considered valid. We don't protect writing to has_owner_ here, as it's\n    // the caller's responsibility to ensure that the current thread holds the\n    // mutex when this is called.\n    has_owner_ = false;\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&mutex_));\n  }\n\n  // Does nothing if the current thread holds the mutex. Otherwise, crashes\n  // with high probability.\n  void AssertHeld() const {\n    GTEST_CHECK_(has_owner_ && pthread_equal(owner_, pthread_self()))\n        << \"The current thread is not holding the mutex @\" << this;\n  }\n\n  // A static mutex may be used before main() is entered.  It may even\n  // be used before the dynamic initialization stage.  Therefore we\n  // must be able to initialize a static mutex object at link time.\n  // This means MutexBase has to be a POD and its member variables\n  // have to be public.\n public:\n  pthread_mutex_t mutex_;  // The underlying pthread mutex.\n  // has_owner_ indicates whether the owner_ field below contains a valid thread\n  // ID and is therefore safe to inspect (e.g., to use in pthread_equal()). All\n  // accesses to the owner_ field should be protected by a check of this field.\n  // An alternative might be to memset() owner_ to all zeros, but there's no\n  // guarantee that a zero'd pthread_t is necessarily invalid or even different\n  // from pthread_self().\n  bool has_owner_;\n  pthread_t owner_;  // The thread holding the mutex.\n};\n\n// Forward-declares a static mutex.\n#  define GTEST_DECLARE_STATIC_MUTEX_(mutex) \\\n     extern ::testing::internal::MutexBase mutex\n\n// Defines and statically (i.e. at link time) initializes a static mutex.\n#  define GTEST_DEFINE_STATIC_MUTEX_(mutex) \\\n     ::testing::internal::MutexBase mutex = { PTHREAD_MUTEX_INITIALIZER, false, pthread_t() }\n\n// The Mutex class can only be used for mutexes created at runtime. It\n// shares its API with MutexBase otherwise.\nclass Mutex : public MutexBase {\n public:\n  Mutex() {\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, NULL));\n    has_owner_ = false;\n  }\n  ~Mutex() {\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_));\n  }\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);\n};\n\n// We cannot name this class MutexLock because the ctor declaration would\n// conflict with a macro named MutexLock, which is defined on some\n// platforms. That macro is used as a defensive measure to prevent against\n// inadvertent misuses of MutexLock like \"MutexLock(&mu)\" rather than\n// \"MutexLock l(&mu)\".  Hence the typedef trick below.\nclass GTestMutexLock {\n public:\n  explicit GTestMutexLock(MutexBase* mutex)\n      : mutex_(mutex) { mutex_->Lock(); }\n\n  ~GTestMutexLock() { mutex_->Unlock(); }\n\n private:\n  MutexBase* const mutex_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);\n};\n\ntypedef GTestMutexLock MutexLock;\n\n// Helpers for ThreadLocal.\n\n// pthread_key_create() requires DeleteThreadLocalValue() to have\n// C-linkage.  Therefore it cannot be templatized to access\n// ThreadLocal<T>.  Hence the need for class\n// ThreadLocalValueHolderBase.\nclass ThreadLocalValueHolderBase {\n public:\n  virtual ~ThreadLocalValueHolderBase() {}\n};\n\n// Called by pthread to delete thread-local data stored by\n// pthread_setspecific().\nextern \"C\" inline void DeleteThreadLocalValue(void* value_holder) {\n  delete static_cast<ThreadLocalValueHolderBase*>(value_holder);\n}\n\n// Implements thread-local storage on pthreads-based systems.\ntemplate <typename T>\nclass ThreadLocal {\n public:\n  ThreadLocal()\n      : key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {}\n  explicit ThreadLocal(const T& value)\n      : key_(CreateKey()),\n        default_factory_(new InstanceValueHolderFactory(value)) {}\n\n  ~ThreadLocal() {\n    // Destroys the managed object for the current thread, if any.\n    DeleteThreadLocalValue(pthread_getspecific(key_));\n\n    // Releases resources associated with the key.  This will *not*\n    // delete managed objects for other threads.\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_key_delete(key_));\n  }\n\n  T* pointer() { return GetOrCreateValue(); }\n  const T* pointer() const { return GetOrCreateValue(); }\n  const T& get() const { return *pointer(); }\n  void set(const T& value) { *pointer() = value; }\n\n private:\n  // Holds a value of type T.\n  class ValueHolder : public ThreadLocalValueHolderBase {\n   public:\n    ValueHolder() : value_() {}\n    explicit ValueHolder(const T& value) : value_(value) {}\n\n    T* pointer() { return &value_; }\n\n   private:\n    T value_;\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);\n  };\n\n  static pthread_key_t CreateKey() {\n    pthread_key_t key;\n    // When a thread exits, DeleteThreadLocalValue() will be called on\n    // the object managed for that thread.\n    GTEST_CHECK_POSIX_SUCCESS_(\n        pthread_key_create(&key, &DeleteThreadLocalValue));\n    return key;\n  }\n\n  T* GetOrCreateValue() const {\n    ThreadLocalValueHolderBase* const holder =\n        static_cast<ThreadLocalValueHolderBase*>(pthread_getspecific(key_));\n    if (holder != NULL) {\n      return CheckedDowncastToActualType<ValueHolder>(holder)->pointer();\n    }\n\n    ValueHolder* const new_holder = default_factory_->MakeNewHolder();\n    ThreadLocalValueHolderBase* const holder_base = new_holder;\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_setspecific(key_, holder_base));\n    return new_holder->pointer();\n  }\n\n  class ValueHolderFactory {\n   public:\n    ValueHolderFactory() {}\n    virtual ~ValueHolderFactory() {}\n    virtual ValueHolder* MakeNewHolder() const = 0;\n\n   private:\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory);\n  };\n\n  class DefaultValueHolderFactory : public ValueHolderFactory {\n   public:\n    DefaultValueHolderFactory() {}\n    virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); }\n\n   private:\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);\n  };\n\n  class InstanceValueHolderFactory : public ValueHolderFactory {\n   public:\n    explicit InstanceValueHolderFactory(const T& value) : value_(value) {}\n    virtual ValueHolder* MakeNewHolder() const {\n      return new ValueHolder(value_);\n    }\n\n   private:\n    const T value_;  // The value for each thread.\n\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory);\n  };\n\n  // A key pthreads uses for looking up per-thread values.\n  const pthread_key_t key_;\n  scoped_ptr<ValueHolderFactory> default_factory_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);\n};\n\n# endif  // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_\n\n#else  // GTEST_IS_THREADSAFE\n\n// A dummy implementation of synchronization primitives (mutex, lock,\n// and thread-local variable).  Necessary for compiling Google Test where\n// mutex is not supported - using Google Test in multiple threads is not\n// supported on such platforms.\n\nclass Mutex {\n public:\n  Mutex() {}\n  void Lock() {}\n  void Unlock() {}\n  void AssertHeld() const {}\n};\n\n# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \\\n  extern ::testing::internal::Mutex mutex\n\n# define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex\n\n// We cannot name this class MutexLock because the ctor declaration would\n// conflict with a macro named MutexLock, which is defined on some\n// platforms. That macro is used as a defensive measure to prevent against\n// inadvertent misuses of MutexLock like \"MutexLock(&mu)\" rather than\n// \"MutexLock l(&mu)\".  Hence the typedef trick below.\nclass GTestMutexLock {\n public:\n  explicit GTestMutexLock(Mutex*) {}  // NOLINT\n};\n\ntypedef GTestMutexLock MutexLock;\n\ntemplate <typename T>\nclass ThreadLocal {\n public:\n  ThreadLocal() : value_() {}\n  explicit ThreadLocal(const T& value) : value_(value) {}\n  T* pointer() { return &value_; }\n  const T* pointer() const { return &value_; }\n  const T& get() const { return value_; }\n  void set(const T& value) { value_ = value; }\n private:\n  T value_;\n};\n\n#endif  // GTEST_IS_THREADSAFE\n\n// Returns the number of threads running in the process, or 0 to indicate that\n// we cannot detect it.\nGTEST_API_ size_t GetThreadCount();\n\n// Passing non-POD classes through ellipsis (...) crashes the ARM\n// compiler and generates a warning in Sun Studio.  The Nokia Symbian\n// and the IBM XL C/C++ compiler try to instantiate a copy constructor\n// for objects passed through ellipsis (...), failing for uncopyable\n// objects.  We define this to ensure that only POD is passed through\n// ellipsis on these systems.\n#if defined(__SYMBIAN32__) || defined(__IBMCPP__) || defined(__SUNPRO_CC)\n// We lose support for NULL detection where the compiler doesn't like\n// passing non-POD classes through ellipsis (...).\n# define GTEST_ELLIPSIS_NEEDS_POD_ 1\n#else\n# define GTEST_CAN_COMPARE_NULL 1\n#endif\n\n// The Nokia Symbian and IBM XL C/C++ compilers cannot decide between\n// const T& and const T* in a function template.  These compilers\n// _can_ decide between class template specializations for T and T*,\n// so a tr1::type_traits-like is_pointer works.\n#if defined(__SYMBIAN32__) || defined(__IBMCPP__)\n# define GTEST_NEEDS_IS_POINTER_ 1\n#endif\n\ntemplate <bool bool_value>\nstruct bool_constant {\n  typedef bool_constant<bool_value> type;\n  static const bool value = bool_value;\n};\ntemplate <bool bool_value> const bool bool_constant<bool_value>::value;\n\ntypedef bool_constant<false> false_type;\ntypedef bool_constant<true> true_type;\n\ntemplate <typename T>\nstruct is_pointer : public false_type {};\n\ntemplate <typename T>\nstruct is_pointer<T*> : public true_type {};\n\ntemplate <typename Iterator>\nstruct IteratorTraits {\n  typedef typename Iterator::value_type value_type;\n};\n\ntemplate <typename T>\nstruct IteratorTraits<T*> {\n  typedef T value_type;\n};\n\ntemplate <typename T>\nstruct IteratorTraits<const T*> {\n  typedef T value_type;\n};\n\n#if GTEST_OS_WINDOWS\n# define GTEST_PATH_SEP_ \"\\\\\"\n# define GTEST_HAS_ALT_PATH_SEP_ 1\n// The biggest signed integer type the compiler supports.\ntypedef __int64 BiggestInt;\n#else\n# define GTEST_PATH_SEP_ \"/\"\n# define GTEST_HAS_ALT_PATH_SEP_ 0\ntypedef long long BiggestInt;  // NOLINT\n#endif  // GTEST_OS_WINDOWS\n\n// Utilities for char.\n\n// isspace(int ch) and friends accept an unsigned char or EOF.  char\n// may be signed, depending on the compiler (or compiler flags).\n// Therefore we need to cast a char to unsigned char before calling\n// isspace(), etc.\n\ninline bool IsAlpha(char ch) {\n  return isalpha(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsAlNum(char ch) {\n  return isalnum(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsDigit(char ch) {\n  return isdigit(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsLower(char ch) {\n  return islower(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsSpace(char ch) {\n  return isspace(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsUpper(char ch) {\n  return isupper(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsXDigit(char ch) {\n  return isxdigit(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsXDigit(wchar_t ch) {\n  const unsigned char low_byte = static_cast<unsigned char>(ch);\n  return ch == low_byte && isxdigit(low_byte) != 0;\n}\n\ninline char ToLower(char ch) {\n  return static_cast<char>(tolower(static_cast<unsigned char>(ch)));\n}\ninline char ToUpper(char ch) {\n  return static_cast<char>(toupper(static_cast<unsigned char>(ch)));\n}\n\ninline std::string StripTrailingSpaces(std::string str) {\n  std::string::iterator it = str.end();\n  while (it != str.begin() && IsSpace(*--it))\n    it = str.erase(it);\n  return str;\n}\n\n// The testing::internal::posix namespace holds wrappers for common\n// POSIX functions.  These wrappers hide the differences between\n// Windows/MSVC and POSIX systems.  Since some compilers define these\n// standard functions as macros, the wrapper cannot have the same name\n// as the wrapped function.\n\nnamespace posix {\n\n// Functions with a different name on Windows.\n\n#if GTEST_OS_WINDOWS\n\ntypedef struct _stat StatStruct;\n\n# ifdef __BORLANDC__\ninline int IsATTY(int fd) { return isatty(fd); }\ninline int StrCaseCmp(const char* s1, const char* s2) {\n  return stricmp(s1, s2);\n}\ninline char* StrDup(const char* src) { return strdup(src); }\n# else  // !__BORLANDC__\n#  if GTEST_OS_WINDOWS_MOBILE\ninline int IsATTY(int /* fd */) { return 0; }\n#  else\ninline int IsATTY(int fd) { return _isatty(fd); }\n#  endif  // GTEST_OS_WINDOWS_MOBILE\ninline int StrCaseCmp(const char* s1, const char* s2) {\n  return _stricmp(s1, s2);\n}\ninline char* StrDup(const char* src) { return _strdup(src); }\n# endif  // __BORLANDC__\n\n# if GTEST_OS_WINDOWS_MOBILE\ninline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); }\n// Stat(), RmDir(), and IsDir() are not needed on Windows CE at this\n// time and thus not defined there.\n# else\ninline int FileNo(FILE* file) { return _fileno(file); }\ninline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }\ninline int RmDir(const char* dir) { return _rmdir(dir); }\ninline bool IsDir(const StatStruct& st) {\n  return (_S_IFDIR & st.st_mode) != 0;\n}\n# endif  // GTEST_OS_WINDOWS_MOBILE\n\n#else\n\ntypedef struct stat StatStruct;\n\ninline int FileNo(FILE* file) { return fileno(file); }\ninline int IsATTY(int fd) { return isatty(fd); }\ninline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }\ninline int StrCaseCmp(const char* s1, const char* s2) {\n  return strcasecmp(s1, s2);\n}\ninline char* StrDup(const char* src) { return strdup(src); }\ninline int RmDir(const char* dir) { return rmdir(dir); }\ninline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }\n\n#endif  // GTEST_OS_WINDOWS\n\n// Functions deprecated by MSVC 8.0.\n\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(4996 /* deprecated function */)\n\ninline const char* StrNCpy(char* dest, const char* src, size_t n) {\n  return strncpy(dest, src, n);\n}\n\n// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and\n// StrError() aren't needed on Windows CE at this time and thus not\n// defined there.\n\n#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT\ninline int ChDir(const char* dir) { return chdir(dir); }\n#endif\ninline FILE* FOpen(const char* path, const char* mode) {\n  return fopen(path, mode);\n}\n#if !GTEST_OS_WINDOWS_MOBILE\ninline FILE *FReopen(const char* path, const char* mode, FILE* stream) {\n  return freopen(path, mode, stream);\n}\ninline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }\n#endif\ninline int FClose(FILE* fp) { return fclose(fp); }\n#if !GTEST_OS_WINDOWS_MOBILE\ninline int Read(int fd, void* buf, unsigned int count) {\n  return static_cast<int>(read(fd, buf, count));\n}\ninline int Write(int fd, const void* buf, unsigned int count) {\n  return static_cast<int>(write(fd, buf, count));\n}\ninline int Close(int fd) { return close(fd); }\ninline const char* StrError(int errnum) { return strerror(errnum); }\n#endif\ninline const char* GetEnv(const char* name) {\n#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE | GTEST_OS_WINDOWS_RT\n  // We are on Windows CE, which has no environment variables.\n  static_cast<void>(name);  // To prevent 'unused argument' warning.\n  return NULL;\n#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)\n  // Environment variables which we programmatically clear will be set to the\n  // empty string rather than unset (NULL).  Handle that case.\n  const char* const env = getenv(name);\n  return (env != NULL && env[0] != '\\0') ? env : NULL;\n#else\n  return getenv(name);\n#endif\n}\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()\n\n#if GTEST_OS_WINDOWS_MOBILE\n// Windows CE has no C library. The abort() function is used in\n// several places in Google Test. This implementation provides a reasonable\n// imitation of standard behaviour.\nvoid Abort();\n#else\ninline void Abort() { abort(); }\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n}  // namespace posix\n\n// MSVC \"deprecates\" snprintf and issues warnings wherever it is used.  In\n// order to avoid these warnings, we need to use _snprintf or _snprintf_s on\n// MSVC-based platforms.  We map the GTEST_SNPRINTF_ macro to the appropriate\n// function in order to achieve that.  We use macro definition here because\n// snprintf is a variadic function.\n#if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE\n// MSVC 2005 and above support variadic macros.\n# define GTEST_SNPRINTF_(buffer, size, format, ...) \\\n     _snprintf_s(buffer, size, size, format, __VA_ARGS__)\n#elif defined(_MSC_VER)\n// Windows CE does not define _snprintf_s and MSVC prior to 2005 doesn't\n// complain about _snprintf.\n# define GTEST_SNPRINTF_ _snprintf\n#else\n# define GTEST_SNPRINTF_ snprintf\n#endif\n\n// The maximum number a BiggestInt can represent.  This definition\n// works no matter BiggestInt is represented in one's complement or\n// two's complement.\n//\n// We cannot rely on numeric_limits in STL, as __int64 and long long\n// are not part of standard C++ and numeric_limits doesn't need to be\n// defined for them.\nconst BiggestInt kMaxBiggestInt =\n    ~(static_cast<BiggestInt>(1) << (8*sizeof(BiggestInt) - 1));\n\n// This template class serves as a compile-time function from size to\n// type.  It maps a size in bytes to a primitive type with that\n// size. e.g.\n//\n//   TypeWithSize<4>::UInt\n//\n// is typedef-ed to be unsigned int (unsigned integer made up of 4\n// bytes).\n//\n// Such functionality should belong to STL, but I cannot find it\n// there.\n//\n// Google Test uses this class in the implementation of floating-point\n// comparison.\n//\n// For now it only handles UInt (unsigned int) as that's all Google Test\n// needs.  Other types can be easily added in the future if need\n// arises.\ntemplate <size_t size>\nclass TypeWithSize {\n public:\n  // This prevents the user from using TypeWithSize<N> with incorrect\n  // values of N.\n  typedef void UInt;\n};\n\n// The specialization for size 4.\ntemplate <>\nclass TypeWithSize<4> {\n public:\n  // unsigned int has size 4 in both gcc and MSVC.\n  //\n  // As base/basictypes.h doesn't compile on Windows, we cannot use\n  // uint32, uint64, and etc here.\n  typedef int Int;\n  typedef unsigned int UInt;\n};\n\n// The specialization for size 8.\ntemplate <>\nclass TypeWithSize<8> {\n public:\n#if GTEST_OS_WINDOWS\n  typedef __int64 Int;\n  typedef unsigned __int64 UInt;\n#else\n  typedef long long Int;  // NOLINT\n  typedef unsigned long long UInt;  // NOLINT\n#endif  // GTEST_OS_WINDOWS\n};\n\n// Integer types of known sizes.\ntypedef TypeWithSize<4>::Int Int32;\ntypedef TypeWithSize<4>::UInt UInt32;\ntypedef TypeWithSize<8>::Int Int64;\ntypedef TypeWithSize<8>::UInt UInt64;\ntypedef TypeWithSize<8>::Int TimeInMillis;  // Represents time in milliseconds.\n\n// Utilities for command line flags and environment variables.\n\n// Macro for referencing flags.\n#if !defined(GTEST_FLAG)\n# define GTEST_FLAG(name) FLAGS_gtest_##name\n#endif  // !defined(GTEST_FLAG)\n\n#if !defined(GTEST_USE_OWN_FLAGFILE_FLAG_)\n# define GTEST_USE_OWN_FLAGFILE_FLAG_ 1\n#endif  // !defined(GTEST_USE_OWN_FLAGFILE_FLAG_)\n\n#if !defined(GTEST_DECLARE_bool_)\n# define GTEST_FLAG_SAVER_ ::testing::internal::GTestFlagSaver\n\n// Macros for declaring flags.\n# define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)\n# define GTEST_DECLARE_int32_(name) \\\n    GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)\n#define GTEST_DECLARE_string_(name) \\\n    GTEST_API_ extern ::std::string GTEST_FLAG(name)\n\n// Macros for defining flags.\n#define GTEST_DEFINE_bool_(name, default_val, doc) \\\n    GTEST_API_ bool GTEST_FLAG(name) = (default_val)\n#define GTEST_DEFINE_int32_(name, default_val, doc) \\\n    GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)\n#define GTEST_DEFINE_string_(name, default_val, doc) \\\n    GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)\n\n#endif  // !defined(GTEST_DECLARE_bool_)\n\n// Thread annotations\n#if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)\n# define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)\n# define GTEST_LOCK_EXCLUDED_(locks)\n#endif  // !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)\n\n// Parses 'str' for a 32-bit signed integer.  If successful, writes the result\n// to *value and returns true; otherwise leaves *value unchanged and returns\n// false.\n// TODO(chandlerc): Find a better way to refactor flag and environment parsing\n// out of both gtest-port.cc and gtest.cc to avoid exporting this utility\n// function.\nbool ParseInt32(const Message& src_text, const char* str, Int32* value);\n\n// Parses a bool/Int32/string from the environment variable\n// corresponding to the given Google Test flag.\nbool BoolFromGTestEnv(const char* flag, bool default_val);\nGTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);\nstd::string StringFromGTestEnv(const char* flag, const char* default_val);\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/gtest-string.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This header file declares the String class and functions used internally by\n// Google Test.  They are subject to change without notice. They should not used\n// by code external to Google Test.\n//\n// This header file is #included by <gtest/internal/gtest-internal.h>.\n// It should not be #included by other files.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_\n\n#ifdef __BORLANDC__\n// string.h is not guaranteed to provide strcpy on C++ Builder.\n# include <mem.h>\n#endif\n\n#include <string.h>\n#include <string>\n\n#include \"gtest/internal/gtest-port.h\"\n\nnamespace testing {\nnamespace internal {\n\n// String - an abstract class holding static string utilities.\nclass GTEST_API_ String {\n public:\n  // Static utility methods\n\n  // Clones a 0-terminated C string, allocating memory using new.  The\n  // caller is responsible for deleting the return value using\n  // delete[].  Returns the cloned string, or NULL if the input is\n  // NULL.\n  //\n  // This is different from strdup() in string.h, which allocates\n  // memory using malloc().\n  static const char* CloneCString(const char* c_str);\n\n#if GTEST_OS_WINDOWS_MOBILE\n  // Windows CE does not have the 'ANSI' versions of Win32 APIs. To be\n  // able to pass strings to Win32 APIs on CE we need to convert them\n  // to 'Unicode', UTF-16.\n\n  // Creates a UTF-16 wide string from the given ANSI string, allocating\n  // memory using new. The caller is responsible for deleting the return\n  // value using delete[]. Returns the wide string, or NULL if the\n  // input is NULL.\n  //\n  // The wide string is created using the ANSI codepage (CP_ACP) to\n  // match the behaviour of the ANSI versions of Win32 calls and the\n  // C runtime.\n  static LPCWSTR AnsiToUtf16(const char* c_str);\n\n  // Creates an ANSI string from the given wide string, allocating\n  // memory using new. The caller is responsible for deleting the return\n  // value using delete[]. Returns the ANSI string, or NULL if the\n  // input is NULL.\n  //\n  // The returned string is created using the ANSI codepage (CP_ACP) to\n  // match the behaviour of the ANSI versions of Win32 calls and the\n  // C runtime.\n  static const char* Utf16ToAnsi(LPCWSTR utf16_str);\n#endif\n\n  // Compares two C strings.  Returns true iff they have the same content.\n  //\n  // Unlike strcmp(), this function can handle NULL argument(s).  A\n  // NULL C string is considered different to any non-NULL C string,\n  // including the empty string.\n  static bool CStringEquals(const char* lhs, const char* rhs);\n\n  // Converts a wide C string to a String using the UTF-8 encoding.\n  // NULL will be converted to \"(null)\".  If an error occurred during\n  // the conversion, \"(failed to convert from wide string)\" is\n  // returned.\n  static std::string ShowWideCString(const wchar_t* wide_c_str);\n\n  // Compares two wide C strings.  Returns true iff they have the same\n  // content.\n  //\n  // Unlike wcscmp(), this function can handle NULL argument(s).  A\n  // NULL C string is considered different to any non-NULL C string,\n  // including the empty string.\n  static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs);\n\n  // Compares two C strings, ignoring case.  Returns true iff they\n  // have the same content.\n  //\n  // Unlike strcasecmp(), this function can handle NULL argument(s).\n  // A NULL C string is considered different to any non-NULL C string,\n  // including the empty string.\n  static bool CaseInsensitiveCStringEquals(const char* lhs,\n                                           const char* rhs);\n\n  // Compares two wide C strings, ignoring case.  Returns true iff they\n  // have the same content.\n  //\n  // Unlike wcscasecmp(), this function can handle NULL argument(s).\n  // A NULL C string is considered different to any non-NULL wide C string,\n  // including the empty string.\n  // NB: The implementations on different platforms slightly differ.\n  // On windows, this method uses _wcsicmp which compares according to LC_CTYPE\n  // environment variable. On GNU platform this method uses wcscasecmp\n  // which compares according to LC_CTYPE category of the current locale.\n  // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the\n  // current locale.\n  static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs,\n                                               const wchar_t* rhs);\n\n  // Returns true iff the given string ends with the given suffix, ignoring\n  // case. Any string is considered to end with an empty suffix.\n  static bool EndsWithCaseInsensitive(\n      const std::string& str, const std::string& suffix);\n\n  // Formats an int value as \"%02d\".\n  static std::string FormatIntWidth2(int value);  // \"%02d\" for width == 2\n\n  // Formats an int value as \"%X\".\n  static std::string FormatHexInt(int value);\n\n  // Formats a byte as \"%02X\".\n  static std::string FormatByte(unsigned char value);\n\n private:\n  String();  // Not meant to be instantiated.\n};  // class String\n\n// Gets the content of the stringstream's buffer as an std::string.  Each '\\0'\n// character in the buffer is replaced with \"\\\\0\".\nGTEST_API_ std::string StringStreamToString(::std::stringstream* stream);\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/gtest-tuple.h",
    "content": "// This file was GENERATED by command:\n//     pump.py gtest-tuple.h.pump\n// DO NOT EDIT BY HAND!!!\n\n// Copyright 2009 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Implements a subset of TR1 tuple needed by Google Test and Google Mock.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_\n\n#include <utility>  // For ::std::pair.\n\n// The compiler used in Symbian has a bug that prevents us from declaring the\n// tuple template as a friend (it complains that tuple is redefined).  This\n// hack bypasses the bug by declaring the members that should otherwise be\n// private as public.\n// Sun Studio versions < 12 also have the above bug.\n#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)\n# define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:\n#else\n# define GTEST_DECLARE_TUPLE_AS_FRIEND_ \\\n    template <GTEST_10_TYPENAMES_(U)> friend class tuple; \\\n   private:\n#endif\n\n// Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that conflict\n// with our own definitions. Therefore using our own tuple does not work on\n// those compilers.\n#if defined(_MSC_VER) && _MSC_VER >= 1600  /* 1600 is Visual Studio 2010 */\n# error \"gtest's tuple doesn't compile on Visual Studio 2010 or later. \\\nGTEST_USE_OWN_TR1_TUPLE must be set to 0 on those compilers.\"\n#endif\n\n// GTEST_n_TUPLE_(T) is the type of an n-tuple.\n#define GTEST_0_TUPLE_(T) tuple<>\n#define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \\\n    void, void, void>\n#define GTEST_2_TUPLE_(T) tuple<T##0, T##1, void, void, void, void, void, \\\n    void, void, void>\n#define GTEST_3_TUPLE_(T) tuple<T##0, T##1, T##2, void, void, void, void, \\\n    void, void, void>\n#define GTEST_4_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, void, void, void, \\\n    void, void, void>\n#define GTEST_5_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, void, void, \\\n    void, void, void>\n#define GTEST_6_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, void, \\\n    void, void, void>\n#define GTEST_7_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \\\n    void, void, void>\n#define GTEST_8_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \\\n    T##7, void, void>\n#define GTEST_9_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \\\n    T##7, T##8, void>\n#define GTEST_10_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \\\n    T##7, T##8, T##9>\n\n// GTEST_n_TYPENAMES_(T) declares a list of n typenames.\n#define GTEST_0_TYPENAMES_(T)\n#define GTEST_1_TYPENAMES_(T) typename T##0\n#define GTEST_2_TYPENAMES_(T) typename T##0, typename T##1\n#define GTEST_3_TYPENAMES_(T) typename T##0, typename T##1, typename T##2\n#define GTEST_4_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \\\n    typename T##3\n#define GTEST_5_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \\\n    typename T##3, typename T##4\n#define GTEST_6_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \\\n    typename T##3, typename T##4, typename T##5\n#define GTEST_7_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \\\n    typename T##3, typename T##4, typename T##5, typename T##6\n#define GTEST_8_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \\\n    typename T##3, typename T##4, typename T##5, typename T##6, typename T##7\n#define GTEST_9_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \\\n    typename T##3, typename T##4, typename T##5, typename T##6, \\\n    typename T##7, typename T##8\n#define GTEST_10_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \\\n    typename T##3, typename T##4, typename T##5, typename T##6, \\\n    typename T##7, typename T##8, typename T##9\n\n// In theory, defining stuff in the ::std namespace is undefined\n// behavior.  We can do this as we are playing the role of a standard\n// library vendor.\nnamespace std {\nnamespace tr1 {\n\ntemplate <typename T0 = void, typename T1 = void, typename T2 = void,\n    typename T3 = void, typename T4 = void, typename T5 = void,\n    typename T6 = void, typename T7 = void, typename T8 = void,\n    typename T9 = void>\nclass tuple;\n\n// Anything in namespace gtest_internal is Google Test's INTERNAL\n// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.\nnamespace gtest_internal {\n\n// ByRef<T>::type is T if T is a reference; otherwise it's const T&.\ntemplate <typename T>\nstruct ByRef { typedef const T& type; };  // NOLINT\ntemplate <typename T>\nstruct ByRef<T&> { typedef T& type; };  // NOLINT\n\n// A handy wrapper for ByRef.\n#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type\n\n// AddRef<T>::type is T if T is a reference; otherwise it's T&.  This\n// is the same as tr1::add_reference<T>::type.\ntemplate <typename T>\nstruct AddRef { typedef T& type; };  // NOLINT\ntemplate <typename T>\nstruct AddRef<T&> { typedef T& type; };  // NOLINT\n\n// A handy wrapper for AddRef.\n#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type\n\n// A helper for implementing get<k>().\ntemplate <int k> class Get;\n\n// A helper for implementing tuple_element<k, T>.  kIndexValid is true\n// iff k < the number of fields in tuple type T.\ntemplate <bool kIndexValid, int kIndex, class Tuple>\nstruct TupleElement;\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 0, GTEST_10_TUPLE_(T) > {\n  typedef T0 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 1, GTEST_10_TUPLE_(T) > {\n  typedef T1 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 2, GTEST_10_TUPLE_(T) > {\n  typedef T2 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 3, GTEST_10_TUPLE_(T) > {\n  typedef T3 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 4, GTEST_10_TUPLE_(T) > {\n  typedef T4 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 5, GTEST_10_TUPLE_(T) > {\n  typedef T5 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 6, GTEST_10_TUPLE_(T) > {\n  typedef T6 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 7, GTEST_10_TUPLE_(T) > {\n  typedef T7 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 8, GTEST_10_TUPLE_(T) > {\n  typedef T8 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 9, GTEST_10_TUPLE_(T) > {\n  typedef T9 type;\n};\n\n}  // namespace gtest_internal\n\ntemplate <>\nclass tuple<> {\n public:\n  tuple() {}\n  tuple(const tuple& /* t */)  {}\n  tuple& operator=(const tuple& /* t */) { return *this; }\n};\n\ntemplate <GTEST_1_TYPENAMES_(T)>\nclass GTEST_1_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0) : f0_(f0) {}\n\n  tuple(const tuple& t) : f0_(t.f0_) {}\n\n  template <GTEST_1_TYPENAMES_(U)>\n  tuple(const GTEST_1_TUPLE_(U)& t) : f0_(t.f0_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_1_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_1_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_1_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_1_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    return *this;\n  }\n\n  T0 f0_;\n};\n\ntemplate <GTEST_2_TYPENAMES_(T)>\nclass GTEST_2_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1) : f0_(f0),\n      f1_(f1) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_) {}\n\n  template <GTEST_2_TYPENAMES_(U)>\n  tuple(const GTEST_2_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_) {}\n  template <typename U0, typename U1>\n  tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_2_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_2_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n  template <typename U0, typename U1>\n  tuple& operator=(const ::std::pair<U0, U1>& p) {\n    f0_ = p.first;\n    f1_ = p.second;\n    return *this;\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_2_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_2_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n};\n\ntemplate <GTEST_3_TYPENAMES_(T)>\nclass GTEST_3_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2) : f0_(f0), f1_(f1), f2_(f2) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}\n\n  template <GTEST_3_TYPENAMES_(U)>\n  tuple(const GTEST_3_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_3_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_3_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_3_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_3_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n};\n\ntemplate <GTEST_4_TYPENAMES_(T)>\nclass GTEST_4_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_(), f3_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3) : f0_(f0), f1_(f1), f2_(f2),\n      f3_(f3) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_) {}\n\n  template <GTEST_4_TYPENAMES_(U)>\n  tuple(const GTEST_4_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),\n      f3_(t.f3_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_4_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_4_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_4_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_4_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    f3_ = t.f3_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n  T3 f3_;\n};\n\ntemplate <GTEST_5_TYPENAMES_(T)>\nclass GTEST_5_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_(), f3_(), f4_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3,\n      GTEST_BY_REF_(T4) f4) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),\n      f4_(t.f4_) {}\n\n  template <GTEST_5_TYPENAMES_(U)>\n  tuple(const GTEST_5_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),\n      f3_(t.f3_), f4_(t.f4_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_5_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_5_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_5_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_5_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    f3_ = t.f3_;\n    f4_ = t.f4_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n  T3 f3_;\n  T4 f4_;\n};\n\ntemplate <GTEST_6_TYPENAMES_(T)>\nclass GTEST_6_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,\n      GTEST_BY_REF_(T5) f5) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),\n      f5_(f5) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),\n      f4_(t.f4_), f5_(t.f5_) {}\n\n  template <GTEST_6_TYPENAMES_(U)>\n  tuple(const GTEST_6_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),\n      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_6_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_6_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_6_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_6_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    f3_ = t.f3_;\n    f4_ = t.f4_;\n    f5_ = t.f5_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n  T3 f3_;\n  T4 f4_;\n  T5 f5_;\n};\n\ntemplate <GTEST_7_TYPENAMES_(T)>\nclass GTEST_7_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,\n      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6) : f0_(f0), f1_(f1), f2_(f2),\n      f3_(f3), f4_(f4), f5_(f5), f6_(f6) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),\n      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}\n\n  template <GTEST_7_TYPENAMES_(U)>\n  tuple(const GTEST_7_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),\n      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_7_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_7_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_7_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_7_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    f3_ = t.f3_;\n    f4_ = t.f4_;\n    f5_ = t.f5_;\n    f6_ = t.f6_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n  T3 f3_;\n  T4 f4_;\n  T5 f5_;\n  T6 f6_;\n};\n\ntemplate <GTEST_8_TYPENAMES_(T)>\nclass GTEST_8_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,\n      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6,\n      GTEST_BY_REF_(T7) f7) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),\n      f5_(f5), f6_(f6), f7_(f7) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),\n      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}\n\n  template <GTEST_8_TYPENAMES_(U)>\n  tuple(const GTEST_8_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),\n      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_8_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_8_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_8_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_8_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    f3_ = t.f3_;\n    f4_ = t.f4_;\n    f5_ = t.f5_;\n    f6_ = t.f6_;\n    f7_ = t.f7_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n  T3 f3_;\n  T4 f4_;\n  T5 f5_;\n  T6 f6_;\n  T7 f7_;\n};\n\ntemplate <GTEST_9_TYPENAMES_(T)>\nclass GTEST_9_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,\n      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,\n      GTEST_BY_REF_(T8) f8) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),\n      f5_(f5), f6_(f6), f7_(f7), f8_(f8) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),\n      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}\n\n  template <GTEST_9_TYPENAMES_(U)>\n  tuple(const GTEST_9_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),\n      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_9_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_9_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_9_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_9_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    f3_ = t.f3_;\n    f4_ = t.f4_;\n    f5_ = t.f5_;\n    f6_ = t.f6_;\n    f7_ = t.f7_;\n    f8_ = t.f8_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n  T3 f3_;\n  T4 f4_;\n  T5 f5_;\n  T6 f6_;\n  T7 f7_;\n  T8 f8_;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nclass tuple {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_(),\n      f9_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,\n      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,\n      GTEST_BY_REF_(T8) f8, GTEST_BY_REF_(T9) f9) : f0_(f0), f1_(f1), f2_(f2),\n      f3_(f3), f4_(f4), f5_(f5), f6_(f6), f7_(f7), f8_(f8), f9_(f9) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),\n      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_), f9_(t.f9_) {}\n\n  template <GTEST_10_TYPENAMES_(U)>\n  tuple(const GTEST_10_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),\n      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_),\n      f9_(t.f9_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_10_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_10_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_10_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_10_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    f3_ = t.f3_;\n    f4_ = t.f4_;\n    f5_ = t.f5_;\n    f6_ = t.f6_;\n    f7_ = t.f7_;\n    f8_ = t.f8_;\n    f9_ = t.f9_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n  T3 f3_;\n  T4 f4_;\n  T5 f5_;\n  T6 f6_;\n  T7 f7_;\n  T8 f8_;\n  T9 f9_;\n};\n\n// 6.1.3.2 Tuple creation functions.\n\n// Known limitations: we don't support passing an\n// std::tr1::reference_wrapper<T> to make_tuple().  And we don't\n// implement tie().\n\ninline tuple<> make_tuple() { return tuple<>(); }\n\ntemplate <GTEST_1_TYPENAMES_(T)>\ninline GTEST_1_TUPLE_(T) make_tuple(const T0& f0) {\n  return GTEST_1_TUPLE_(T)(f0);\n}\n\ntemplate <GTEST_2_TYPENAMES_(T)>\ninline GTEST_2_TUPLE_(T) make_tuple(const T0& f0, const T1& f1) {\n  return GTEST_2_TUPLE_(T)(f0, f1);\n}\n\ntemplate <GTEST_3_TYPENAMES_(T)>\ninline GTEST_3_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2) {\n  return GTEST_3_TUPLE_(T)(f0, f1, f2);\n}\n\ntemplate <GTEST_4_TYPENAMES_(T)>\ninline GTEST_4_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,\n    const T3& f3) {\n  return GTEST_4_TUPLE_(T)(f0, f1, f2, f3);\n}\n\ntemplate <GTEST_5_TYPENAMES_(T)>\ninline GTEST_5_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,\n    const T3& f3, const T4& f4) {\n  return GTEST_5_TUPLE_(T)(f0, f1, f2, f3, f4);\n}\n\ntemplate <GTEST_6_TYPENAMES_(T)>\ninline GTEST_6_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,\n    const T3& f3, const T4& f4, const T5& f5) {\n  return GTEST_6_TUPLE_(T)(f0, f1, f2, f3, f4, f5);\n}\n\ntemplate <GTEST_7_TYPENAMES_(T)>\ninline GTEST_7_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,\n    const T3& f3, const T4& f4, const T5& f5, const T6& f6) {\n  return GTEST_7_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6);\n}\n\ntemplate <GTEST_8_TYPENAMES_(T)>\ninline GTEST_8_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,\n    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7) {\n  return GTEST_8_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7);\n}\n\ntemplate <GTEST_9_TYPENAMES_(T)>\ninline GTEST_9_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,\n    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,\n    const T8& f8) {\n  return GTEST_9_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8);\n}\n\ntemplate <GTEST_10_TYPENAMES_(T)>\ninline GTEST_10_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,\n    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,\n    const T8& f8, const T9& f9) {\n  return GTEST_10_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9);\n}\n\n// 6.1.3.3 Tuple helper classes.\n\ntemplate <typename Tuple> struct tuple_size;\n\ntemplate <GTEST_0_TYPENAMES_(T)>\nstruct tuple_size<GTEST_0_TUPLE_(T) > {\n  static const int value = 0;\n};\n\ntemplate <GTEST_1_TYPENAMES_(T)>\nstruct tuple_size<GTEST_1_TUPLE_(T) > {\n  static const int value = 1;\n};\n\ntemplate <GTEST_2_TYPENAMES_(T)>\nstruct tuple_size<GTEST_2_TUPLE_(T) > {\n  static const int value = 2;\n};\n\ntemplate <GTEST_3_TYPENAMES_(T)>\nstruct tuple_size<GTEST_3_TUPLE_(T) > {\n  static const int value = 3;\n};\n\ntemplate <GTEST_4_TYPENAMES_(T)>\nstruct tuple_size<GTEST_4_TUPLE_(T) > {\n  static const int value = 4;\n};\n\ntemplate <GTEST_5_TYPENAMES_(T)>\nstruct tuple_size<GTEST_5_TUPLE_(T) > {\n  static const int value = 5;\n};\n\ntemplate <GTEST_6_TYPENAMES_(T)>\nstruct tuple_size<GTEST_6_TUPLE_(T) > {\n  static const int value = 6;\n};\n\ntemplate <GTEST_7_TYPENAMES_(T)>\nstruct tuple_size<GTEST_7_TUPLE_(T) > {\n  static const int value = 7;\n};\n\ntemplate <GTEST_8_TYPENAMES_(T)>\nstruct tuple_size<GTEST_8_TUPLE_(T) > {\n  static const int value = 8;\n};\n\ntemplate <GTEST_9_TYPENAMES_(T)>\nstruct tuple_size<GTEST_9_TUPLE_(T) > {\n  static const int value = 9;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct tuple_size<GTEST_10_TUPLE_(T) > {\n  static const int value = 10;\n};\n\ntemplate <int k, class Tuple>\nstruct tuple_element {\n  typedef typename gtest_internal::TupleElement<\n      k < (tuple_size<Tuple>::value), k, Tuple>::type type;\n};\n\n#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type\n\n// 6.1.3.4 Element access.\n\nnamespace gtest_internal {\n\ntemplate <>\nclass Get<0> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))\n  Field(Tuple& t) { return t.f0_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))\n  ConstField(const Tuple& t) { return t.f0_; }\n};\n\ntemplate <>\nclass Get<1> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))\n  Field(Tuple& t) { return t.f1_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))\n  ConstField(const Tuple& t) { return t.f1_; }\n};\n\ntemplate <>\nclass Get<2> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))\n  Field(Tuple& t) { return t.f2_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))\n  ConstField(const Tuple& t) { return t.f2_; }\n};\n\ntemplate <>\nclass Get<3> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))\n  Field(Tuple& t) { return t.f3_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))\n  ConstField(const Tuple& t) { return t.f3_; }\n};\n\ntemplate <>\nclass Get<4> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))\n  Field(Tuple& t) { return t.f4_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))\n  ConstField(const Tuple& t) { return t.f4_; }\n};\n\ntemplate <>\nclass Get<5> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))\n  Field(Tuple& t) { return t.f5_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))\n  ConstField(const Tuple& t) { return t.f5_; }\n};\n\ntemplate <>\nclass Get<6> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))\n  Field(Tuple& t) { return t.f6_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))\n  ConstField(const Tuple& t) { return t.f6_; }\n};\n\ntemplate <>\nclass Get<7> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))\n  Field(Tuple& t) { return t.f7_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))\n  ConstField(const Tuple& t) { return t.f7_; }\n};\n\ntemplate <>\nclass Get<8> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))\n  Field(Tuple& t) { return t.f8_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))\n  ConstField(const Tuple& t) { return t.f8_; }\n};\n\ntemplate <>\nclass Get<9> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))\n  Field(Tuple& t) { return t.f9_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))\n  ConstField(const Tuple& t) { return t.f9_; }\n};\n\n}  // namespace gtest_internal\n\ntemplate <int k, GTEST_10_TYPENAMES_(T)>\nGTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_10_TUPLE_(T)))\nget(GTEST_10_TUPLE_(T)& t) {\n  return gtest_internal::Get<k>::Field(t);\n}\n\ntemplate <int k, GTEST_10_TYPENAMES_(T)>\nGTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k,  GTEST_10_TUPLE_(T)))\nget(const GTEST_10_TUPLE_(T)& t) {\n  return gtest_internal::Get<k>::ConstField(t);\n}\n\n// 6.1.3.5 Relational operators\n\n// We only implement == and !=, as we don't have a need for the rest yet.\n\nnamespace gtest_internal {\n\n// SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the\n// first k fields of t1 equals the first k fields of t2.\n// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if\n// k1 != k2.\ntemplate <int kSize1, int kSize2>\nstruct SameSizeTuplePrefixComparator;\n\ntemplate <>\nstruct SameSizeTuplePrefixComparator<0, 0> {\n  template <class Tuple1, class Tuple2>\n  static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {\n    return true;\n  }\n};\n\ntemplate <int k>\nstruct SameSizeTuplePrefixComparator<k, k> {\n  template <class Tuple1, class Tuple2>\n  static bool Eq(const Tuple1& t1, const Tuple2& t2) {\n    return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) &&\n        ::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2);\n  }\n};\n\n}  // namespace gtest_internal\n\ntemplate <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>\ninline bool operator==(const GTEST_10_TUPLE_(T)& t,\n                       const GTEST_10_TUPLE_(U)& u) {\n  return gtest_internal::SameSizeTuplePrefixComparator<\n      tuple_size<GTEST_10_TUPLE_(T) >::value,\n      tuple_size<GTEST_10_TUPLE_(U) >::value>::Eq(t, u);\n}\n\ntemplate <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>\ninline bool operator!=(const GTEST_10_TUPLE_(T)& t,\n                       const GTEST_10_TUPLE_(U)& u) { return !(t == u); }\n\n// 6.1.4 Pairs.\n// Unimplemented.\n\n}  // namespace tr1\n}  // namespace std\n\n#undef GTEST_0_TUPLE_\n#undef GTEST_1_TUPLE_\n#undef GTEST_2_TUPLE_\n#undef GTEST_3_TUPLE_\n#undef GTEST_4_TUPLE_\n#undef GTEST_5_TUPLE_\n#undef GTEST_6_TUPLE_\n#undef GTEST_7_TUPLE_\n#undef GTEST_8_TUPLE_\n#undef GTEST_9_TUPLE_\n#undef GTEST_10_TUPLE_\n\n#undef GTEST_0_TYPENAMES_\n#undef GTEST_1_TYPENAMES_\n#undef GTEST_2_TYPENAMES_\n#undef GTEST_3_TYPENAMES_\n#undef GTEST_4_TYPENAMES_\n#undef GTEST_5_TYPENAMES_\n#undef GTEST_6_TYPENAMES_\n#undef GTEST_7_TYPENAMES_\n#undef GTEST_8_TYPENAMES_\n#undef GTEST_9_TYPENAMES_\n#undef GTEST_10_TYPENAMES_\n\n#undef GTEST_DECLARE_TUPLE_AS_FRIEND_\n#undef GTEST_BY_REF_\n#undef GTEST_ADD_REF_\n#undef GTEST_TUPLE_ELEMENT_\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/gtest-tuple.h.pump",
    "content": "$$ -*- mode: c++; -*-\n$var n = 10  $$ Maximum number of tuple fields we want to support.\n$$ This meta comment fixes auto-indentation in Emacs. }}\n// Copyright 2009 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Implements a subset of TR1 tuple needed by Google Test and Google Mock.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_\n\n#include <utility>  // For ::std::pair.\n\n// The compiler used in Symbian has a bug that prevents us from declaring the\n// tuple template as a friend (it complains that tuple is redefined).  This\n// hack bypasses the bug by declaring the members that should otherwise be\n// private as public.\n// Sun Studio versions < 12 also have the above bug.\n#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)\n# define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:\n#else\n# define GTEST_DECLARE_TUPLE_AS_FRIEND_ \\\n    template <GTEST_$(n)_TYPENAMES_(U)> friend class tuple; \\\n   private:\n#endif\n\n// Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that conflict\n// with our own definitions. Therefore using our own tuple does not work on\n// those compilers.\n#if defined(_MSC_VER) && _MSC_VER >= 1600  /* 1600 is Visual Studio 2010 */\n# error \"gtest's tuple doesn't compile on Visual Studio 2010 or later. \\\nGTEST_USE_OWN_TR1_TUPLE must be set to 0 on those compilers.\"\n#endif\n\n\n$range i 0..n-1\n$range j 0..n\n$range k 1..n\n// GTEST_n_TUPLE_(T) is the type of an n-tuple.\n#define GTEST_0_TUPLE_(T) tuple<>\n\n$for k [[\n$range m 0..k-1\n$range m2 k..n-1\n#define GTEST_$(k)_TUPLE_(T) tuple<$for m, [[T##$m]]$for m2 [[, void]]>\n\n]]\n\n// GTEST_n_TYPENAMES_(T) declares a list of n typenames.\n\n$for j [[\n$range m 0..j-1\n#define GTEST_$(j)_TYPENAMES_(T) $for m, [[typename T##$m]]\n\n\n]]\n\n// In theory, defining stuff in the ::std namespace is undefined\n// behavior.  We can do this as we are playing the role of a standard\n// library vendor.\nnamespace std {\nnamespace tr1 {\n\ntemplate <$for i, [[typename T$i = void]]>\nclass tuple;\n\n// Anything in namespace gtest_internal is Google Test's INTERNAL\n// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.\nnamespace gtest_internal {\n\n// ByRef<T>::type is T if T is a reference; otherwise it's const T&.\ntemplate <typename T>\nstruct ByRef { typedef const T& type; };  // NOLINT\ntemplate <typename T>\nstruct ByRef<T&> { typedef T& type; };  // NOLINT\n\n// A handy wrapper for ByRef.\n#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type\n\n// AddRef<T>::type is T if T is a reference; otherwise it's T&.  This\n// is the same as tr1::add_reference<T>::type.\ntemplate <typename T>\nstruct AddRef { typedef T& type; };  // NOLINT\ntemplate <typename T>\nstruct AddRef<T&> { typedef T& type; };  // NOLINT\n\n// A handy wrapper for AddRef.\n#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type\n\n// A helper for implementing get<k>().\ntemplate <int k> class Get;\n\n// A helper for implementing tuple_element<k, T>.  kIndexValid is true\n// iff k < the number of fields in tuple type T.\ntemplate <bool kIndexValid, int kIndex, class Tuple>\nstruct TupleElement;\n\n\n$for i [[\ntemplate <GTEST_$(n)_TYPENAMES_(T)>\nstruct TupleElement<true, $i, GTEST_$(n)_TUPLE_(T) > {\n  typedef T$i type;\n};\n\n\n]]\n}  // namespace gtest_internal\n\ntemplate <>\nclass tuple<> {\n public:\n  tuple() {}\n  tuple(const tuple& /* t */)  {}\n  tuple& operator=(const tuple& /* t */) { return *this; }\n};\n\n\n$for k [[\n$range m 0..k-1\ntemplate <GTEST_$(k)_TYPENAMES_(T)>\nclass $if k < n [[GTEST_$(k)_TUPLE_(T)]] $else [[tuple]] {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : $for m, [[f$(m)_()]] {}\n\n  explicit tuple($for m, [[GTEST_BY_REF_(T$m) f$m]]) : [[]]\n$for m, [[f$(m)_(f$m)]] {}\n\n  tuple(const tuple& t) : $for m, [[f$(m)_(t.f$(m)_)]] {}\n\n  template <GTEST_$(k)_TYPENAMES_(U)>\n  tuple(const GTEST_$(k)_TUPLE_(U)& t) : $for m, [[f$(m)_(t.f$(m)_)]] {}\n\n$if k == 2 [[\n  template <typename U0, typename U1>\n  tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {}\n\n]]\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_$(k)_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_$(k)_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n$if k == 2 [[\n  template <typename U0, typename U1>\n  tuple& operator=(const ::std::pair<U0, U1>& p) {\n    f0_ = p.first;\n    f1_ = p.second;\n    return *this;\n  }\n\n]]\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_$(k)_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_$(k)_TUPLE_(U)& t) {\n\n$for m [[\n    f$(m)_ = t.f$(m)_;\n\n]]\n    return *this;\n  }\n\n\n$for m [[\n  T$m f$(m)_;\n\n]]\n};\n\n\n]]\n// 6.1.3.2 Tuple creation functions.\n\n// Known limitations: we don't support passing an\n// std::tr1::reference_wrapper<T> to make_tuple().  And we don't\n// implement tie().\n\ninline tuple<> make_tuple() { return tuple<>(); }\n\n$for k [[\n$range m 0..k-1\n\ntemplate <GTEST_$(k)_TYPENAMES_(T)>\ninline GTEST_$(k)_TUPLE_(T) make_tuple($for m, [[const T$m& f$m]]) {\n  return GTEST_$(k)_TUPLE_(T)($for m, [[f$m]]);\n}\n\n]]\n\n// 6.1.3.3 Tuple helper classes.\n\ntemplate <typename Tuple> struct tuple_size;\n\n\n$for j [[\ntemplate <GTEST_$(j)_TYPENAMES_(T)>\nstruct tuple_size<GTEST_$(j)_TUPLE_(T) > {\n  static const int value = $j;\n};\n\n\n]]\ntemplate <int k, class Tuple>\nstruct tuple_element {\n  typedef typename gtest_internal::TupleElement<\n      k < (tuple_size<Tuple>::value), k, Tuple>::type type;\n};\n\n#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type\n\n// 6.1.3.4 Element access.\n\nnamespace gtest_internal {\n\n\n$for i [[\ntemplate <>\nclass Get<$i> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple))\n  Field(Tuple& t) { return t.f$(i)_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple))\n  ConstField(const Tuple& t) { return t.f$(i)_; }\n};\n\n\n]]\n}  // namespace gtest_internal\n\ntemplate <int k, GTEST_$(n)_TYPENAMES_(T)>\nGTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_$(n)_TUPLE_(T)))\nget(GTEST_$(n)_TUPLE_(T)& t) {\n  return gtest_internal::Get<k>::Field(t);\n}\n\ntemplate <int k, GTEST_$(n)_TYPENAMES_(T)>\nGTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k,  GTEST_$(n)_TUPLE_(T)))\nget(const GTEST_$(n)_TUPLE_(T)& t) {\n  return gtest_internal::Get<k>::ConstField(t);\n}\n\n// 6.1.3.5 Relational operators\n\n// We only implement == and !=, as we don't have a need for the rest yet.\n\nnamespace gtest_internal {\n\n// SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the\n// first k fields of t1 equals the first k fields of t2.\n// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if\n// k1 != k2.\ntemplate <int kSize1, int kSize2>\nstruct SameSizeTuplePrefixComparator;\n\ntemplate <>\nstruct SameSizeTuplePrefixComparator<0, 0> {\n  template <class Tuple1, class Tuple2>\n  static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {\n    return true;\n  }\n};\n\ntemplate <int k>\nstruct SameSizeTuplePrefixComparator<k, k> {\n  template <class Tuple1, class Tuple2>\n  static bool Eq(const Tuple1& t1, const Tuple2& t2) {\n    return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) &&\n        ::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2);\n  }\n};\n\n}  // namespace gtest_internal\n\ntemplate <GTEST_$(n)_TYPENAMES_(T), GTEST_$(n)_TYPENAMES_(U)>\ninline bool operator==(const GTEST_$(n)_TUPLE_(T)& t,\n                       const GTEST_$(n)_TUPLE_(U)& u) {\n  return gtest_internal::SameSizeTuplePrefixComparator<\n      tuple_size<GTEST_$(n)_TUPLE_(T) >::value,\n      tuple_size<GTEST_$(n)_TUPLE_(U) >::value>::Eq(t, u);\n}\n\ntemplate <GTEST_$(n)_TYPENAMES_(T), GTEST_$(n)_TYPENAMES_(U)>\ninline bool operator!=(const GTEST_$(n)_TUPLE_(T)& t,\n                       const GTEST_$(n)_TUPLE_(U)& u) { return !(t == u); }\n\n// 6.1.4 Pairs.\n// Unimplemented.\n\n}  // namespace tr1\n}  // namespace std\n\n\n$for j [[\n#undef GTEST_$(j)_TUPLE_\n\n]]\n\n\n$for j [[\n#undef GTEST_$(j)_TYPENAMES_\n\n]]\n\n#undef GTEST_DECLARE_TUPLE_AS_FRIEND_\n#undef GTEST_BY_REF_\n#undef GTEST_ADD_REF_\n#undef GTEST_TUPLE_ELEMENT_\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/gtest-type-util.h",
    "content": "// This file was GENERATED by command:\n//     pump.py gtest-type-util.h.pump\n// DO NOT EDIT BY HAND!!!\n\n// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Type utilities needed for implementing typed and type-parameterized\n// tests.  This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!\n//\n// Currently we support at most 50 types in a list, and at most 50\n// type-parameterized tests in one type-parameterized test case.\n// Please contact googletestframework@googlegroups.com if you need\n// more.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_\n\n#include \"gtest/internal/gtest-port.h\"\n\n// #ifdef __GNUC__ is too general here.  It is possible to use gcc without using\n// libstdc++ (which is where cxxabi.h comes from).\n# if GTEST_HAS_CXXABI_H_\n#  include <cxxabi.h>\n# elif defined(__HP_aCC)\n#  include <acxx_demangle.h>\n# endif  // GTEST_HASH_CXXABI_H_\n\nnamespace testing {\nnamespace internal {\n\n// GetTypeName<T>() returns a human-readable name of type T.\n// NB: This function is also used in Google Mock, so don't move it inside of\n// the typed-test-only section below.\ntemplate <typename T>\nstd::string GetTypeName() {\n# if GTEST_HAS_RTTI\n\n  const char* const name = typeid(T).name();\n#  if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC)\n  int status = 0;\n  // gcc's implementation of typeid(T).name() mangles the type name,\n  // so we have to demangle it.\n#   if GTEST_HAS_CXXABI_H_\n  using abi::__cxa_demangle;\n#   endif  // GTEST_HAS_CXXABI_H_\n  char* const readable_name = __cxa_demangle(name, 0, 0, &status);\n  const std::string name_str(status == 0 ? readable_name : name);\n  free(readable_name);\n  return name_str;\n#  else\n  return name;\n#  endif  // GTEST_HAS_CXXABI_H_ || __HP_aCC\n\n# else\n\n  return \"<type>\";\n\n# endif  // GTEST_HAS_RTTI\n}\n\n#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P\n\n// AssertyTypeEq<T1, T2>::type is defined iff T1 and T2 are the same\n// type.  This can be used as a compile-time assertion to ensure that\n// two types are equal.\n\ntemplate <typename T1, typename T2>\nstruct AssertTypeEq;\n\ntemplate <typename T>\nstruct AssertTypeEq<T, T> {\n  typedef bool type;\n};\n\n// A unique type used as the default value for the arguments of class\n// template Types.  This allows us to simulate variadic templates\n// (e.g. Types<int>, Type<int, double>, and etc), which C++ doesn't\n// support directly.\nstruct None {};\n\n// The following family of struct and struct templates are used to\n// represent type lists.  In particular, TypesN<T1, T2, ..., TN>\n// represents a type list with N types (T1, T2, ..., and TN) in it.\n// Except for Types0, every struct in the family has two member types:\n// Head for the first type in the list, and Tail for the rest of the\n// list.\n\n// The empty type list.\nstruct Types0 {};\n\n// Type lists of length 1, 2, 3, and so on.\n\ntemplate <typename T1>\nstruct Types1 {\n  typedef T1 Head;\n  typedef Types0 Tail;\n};\ntemplate <typename T1, typename T2>\nstruct Types2 {\n  typedef T1 Head;\n  typedef Types1<T2> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3>\nstruct Types3 {\n  typedef T1 Head;\n  typedef Types2<T2, T3> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4>\nstruct Types4 {\n  typedef T1 Head;\n  typedef Types3<T2, T3, T4> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\nstruct Types5 {\n  typedef T1 Head;\n  typedef Types4<T2, T3, T4, T5> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6>\nstruct Types6 {\n  typedef T1 Head;\n  typedef Types5<T2, T3, T4, T5, T6> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7>\nstruct Types7 {\n  typedef T1 Head;\n  typedef Types6<T2, T3, T4, T5, T6, T7> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8>\nstruct Types8 {\n  typedef T1 Head;\n  typedef Types7<T2, T3, T4, T5, T6, T7, T8> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9>\nstruct Types9 {\n  typedef T1 Head;\n  typedef Types8<T2, T3, T4, T5, T6, T7, T8, T9> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10>\nstruct Types10 {\n  typedef T1 Head;\n  typedef Types9<T2, T3, T4, T5, T6, T7, T8, T9, T10> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11>\nstruct Types11 {\n  typedef T1 Head;\n  typedef Types10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12>\nstruct Types12 {\n  typedef T1 Head;\n  typedef Types11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13>\nstruct Types13 {\n  typedef T1 Head;\n  typedef Types12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14>\nstruct Types14 {\n  typedef T1 Head;\n  typedef Types13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15>\nstruct Types15 {\n  typedef T1 Head;\n  typedef Types14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16>\nstruct Types16 {\n  typedef T1 Head;\n  typedef Types15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17>\nstruct Types17 {\n  typedef T1 Head;\n  typedef Types16<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18>\nstruct Types18 {\n  typedef T1 Head;\n  typedef Types17<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19>\nstruct Types19 {\n  typedef T1 Head;\n  typedef Types18<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20>\nstruct Types20 {\n  typedef T1 Head;\n  typedef Types19<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21>\nstruct Types21 {\n  typedef T1 Head;\n  typedef Types20<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22>\nstruct Types22 {\n  typedef T1 Head;\n  typedef Types21<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23>\nstruct Types23 {\n  typedef T1 Head;\n  typedef Types22<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24>\nstruct Types24 {\n  typedef T1 Head;\n  typedef Types23<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25>\nstruct Types25 {\n  typedef T1 Head;\n  typedef Types24<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26>\nstruct Types26 {\n  typedef T1 Head;\n  typedef Types25<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27>\nstruct Types27 {\n  typedef T1 Head;\n  typedef Types26<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28>\nstruct Types28 {\n  typedef T1 Head;\n  typedef Types27<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29>\nstruct Types29 {\n  typedef T1 Head;\n  typedef Types28<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30>\nstruct Types30 {\n  typedef T1 Head;\n  typedef Types29<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31>\nstruct Types31 {\n  typedef T1 Head;\n  typedef Types30<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32>\nstruct Types32 {\n  typedef T1 Head;\n  typedef Types31<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33>\nstruct Types33 {\n  typedef T1 Head;\n  typedef Types32<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34>\nstruct Types34 {\n  typedef T1 Head;\n  typedef Types33<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35>\nstruct Types35 {\n  typedef T1 Head;\n  typedef Types34<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36>\nstruct Types36 {\n  typedef T1 Head;\n  typedef Types35<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37>\nstruct Types37 {\n  typedef T1 Head;\n  typedef Types36<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38>\nstruct Types38 {\n  typedef T1 Head;\n  typedef Types37<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39>\nstruct Types39 {\n  typedef T1 Head;\n  typedef Types38<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40>\nstruct Types40 {\n  typedef T1 Head;\n  typedef Types39<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41>\nstruct Types41 {\n  typedef T1 Head;\n  typedef Types40<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42>\nstruct Types42 {\n  typedef T1 Head;\n  typedef Types41<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43>\nstruct Types43 {\n  typedef T1 Head;\n  typedef Types42<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44>\nstruct Types44 {\n  typedef T1 Head;\n  typedef Types43<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n      T44> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45>\nstruct Types45 {\n  typedef T1 Head;\n  typedef Types44<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n      T44, T45> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46>\nstruct Types46 {\n  typedef T1 Head;\n  typedef Types45<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n      T44, T45, T46> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47>\nstruct Types47 {\n  typedef T1 Head;\n  typedef Types46<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n      T44, T45, T46, T47> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48>\nstruct Types48 {\n  typedef T1 Head;\n  typedef Types47<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n      T44, T45, T46, T47, T48> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49>\nstruct Types49 {\n  typedef T1 Head;\n  typedef Types48<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n      T44, T45, T46, T47, T48, T49> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49, typename T50>\nstruct Types50 {\n  typedef T1 Head;\n  typedef Types49<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n      T44, T45, T46, T47, T48, T49, T50> Tail;\n};\n\n\n}  // namespace internal\n\n// We don't want to require the users to write TypesN<...> directly,\n// as that would require them to count the length.  Types<...> is much\n// easier to write, but generates horrible messages when there is a\n// compiler error, as gcc insists on printing out each template\n// argument, even if it has the default value (this means Types<int>\n// will appear as Types<int, None, None, ..., None> in the compiler\n// errors).\n//\n// Our solution is to combine the best part of the two approaches: a\n// user would write Types<T1, ..., TN>, and Google Test will translate\n// that to TypesN<T1, ..., TN> internally to make error messages\n// readable.  The translation is done by the 'type' member of the\n// Types template.\ntemplate <typename T1 = internal::None, typename T2 = internal::None,\n    typename T3 = internal::None, typename T4 = internal::None,\n    typename T5 = internal::None, typename T6 = internal::None,\n    typename T7 = internal::None, typename T8 = internal::None,\n    typename T9 = internal::None, typename T10 = internal::None,\n    typename T11 = internal::None, typename T12 = internal::None,\n    typename T13 = internal::None, typename T14 = internal::None,\n    typename T15 = internal::None, typename T16 = internal::None,\n    typename T17 = internal::None, typename T18 = internal::None,\n    typename T19 = internal::None, typename T20 = internal::None,\n    typename T21 = internal::None, typename T22 = internal::None,\n    typename T23 = internal::None, typename T24 = internal::None,\n    typename T25 = internal::None, typename T26 = internal::None,\n    typename T27 = internal::None, typename T28 = internal::None,\n    typename T29 = internal::None, typename T30 = internal::None,\n    typename T31 = internal::None, typename T32 = internal::None,\n    typename T33 = internal::None, typename T34 = internal::None,\n    typename T35 = internal::None, typename T36 = internal::None,\n    typename T37 = internal::None, typename T38 = internal::None,\n    typename T39 = internal::None, typename T40 = internal::None,\n    typename T41 = internal::None, typename T42 = internal::None,\n    typename T43 = internal::None, typename T44 = internal::None,\n    typename T45 = internal::None, typename T46 = internal::None,\n    typename T47 = internal::None, typename T48 = internal::None,\n    typename T49 = internal::None, typename T50 = internal::None>\nstruct Types {\n  typedef internal::Types50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44, T45, T46, T47, T48, T49, T50> type;\n};\n\ntemplate <>\nstruct Types<internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types0 type;\n};\ntemplate <typename T1>\nstruct Types<T1, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types1<T1> type;\n};\ntemplate <typename T1, typename T2>\nstruct Types<T1, T2, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types2<T1, T2> type;\n};\ntemplate <typename T1, typename T2, typename T3>\nstruct Types<T1, T2, T3, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types3<T1, T2, T3> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4>\nstruct Types<T1, T2, T3, T4, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types4<T1, T2, T3, T4> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\nstruct Types<T1, T2, T3, T4, T5, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types5<T1, T2, T3, T4, T5> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6>\nstruct Types<T1, T2, T3, T4, T5, T6, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types6<T1, T2, T3, T4, T5, T6> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types7<T1, T2, T3, T4, T5, T6, T7> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types8<T1, T2, T3, T4, T5, T6, T7, T8> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types9<T1, T2, T3, T4, T5, T6, T7, T8, T9> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44, T45> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,\n    T46, internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44, T45, T46> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,\n    T46, T47, internal::None, internal::None, internal::None> {\n  typedef internal::Types47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44, T45, T46, T47> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,\n    T46, T47, T48, internal::None, internal::None> {\n  typedef internal::Types48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44, T45, T46, T47, T48> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,\n    T46, T47, T48, T49, internal::None> {\n  typedef internal::Types49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44, T45, T46, T47, T48, T49> type;\n};\n\nnamespace internal {\n\n# define GTEST_TEMPLATE_ template <typename T> class\n\n// The template \"selector\" struct TemplateSel<Tmpl> is used to\n// represent Tmpl, which must be a class template with one type\n// parameter, as a type.  TemplateSel<Tmpl>::Bind<T>::type is defined\n// as the type Tmpl<T>.  This allows us to actually instantiate the\n// template \"selected\" by TemplateSel<Tmpl>.\n//\n// This trick is necessary for simulating typedef for class templates,\n// which C++ doesn't support directly.\ntemplate <GTEST_TEMPLATE_ Tmpl>\nstruct TemplateSel {\n  template <typename T>\n  struct Bind {\n    typedef Tmpl<T> type;\n  };\n};\n\n# define GTEST_BIND_(TmplSel, T) \\\n  TmplSel::template Bind<T>::type\n\n// A unique struct template used as the default value for the\n// arguments of class template Templates.  This allows us to simulate\n// variadic templates (e.g. Templates<int>, Templates<int, double>,\n// and etc), which C++ doesn't support directly.\ntemplate <typename T>\nstruct NoneT {};\n\n// The following family of struct and struct templates are used to\n// represent template lists.  In particular, TemplatesN<T1, T2, ...,\n// TN> represents a list of N templates (T1, T2, ..., and TN).  Except\n// for Templates0, every struct in the family has two member types:\n// Head for the selector of the first template in the list, and Tail\n// for the rest of the list.\n\n// The empty template list.\nstruct Templates0 {};\n\n// Template lists of length 1, 2, 3, and so on.\n\ntemplate <GTEST_TEMPLATE_ T1>\nstruct Templates1 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates0 Tail;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2>\nstruct Templates2 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates1<T2> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3>\nstruct Templates3 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates2<T2, T3> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4>\nstruct Templates4 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates3<T2, T3, T4> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5>\nstruct Templates5 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates4<T2, T3, T4, T5> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6>\nstruct Templates6 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates5<T2, T3, T4, T5, T6> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7>\nstruct Templates7 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates6<T2, T3, T4, T5, T6, T7> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8>\nstruct Templates8 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates7<T2, T3, T4, T5, T6, T7, T8> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9>\nstruct Templates9 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates8<T2, T3, T4, T5, T6, T7, T8, T9> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10>\nstruct Templates10 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates9<T2, T3, T4, T5, T6, T7, T8, T9, T10> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11>\nstruct Templates11 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12>\nstruct Templates12 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13>\nstruct Templates13 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14>\nstruct Templates14 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15>\nstruct Templates15 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16>\nstruct Templates16 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17>\nstruct Templates17 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates16<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18>\nstruct Templates18 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates17<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19>\nstruct Templates19 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates18<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20>\nstruct Templates20 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates19<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21>\nstruct Templates21 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates20<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22>\nstruct Templates22 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates21<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23>\nstruct Templates23 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates22<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24>\nstruct Templates24 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates23<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25>\nstruct Templates25 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates24<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26>\nstruct Templates26 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates25<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27>\nstruct Templates27 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates26<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28>\nstruct Templates28 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates27<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29>\nstruct Templates29 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates28<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30>\nstruct Templates30 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates29<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31>\nstruct Templates31 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates30<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32>\nstruct Templates32 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates31<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33>\nstruct Templates33 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates32<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34>\nstruct Templates34 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates33<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35>\nstruct Templates35 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates34<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36>\nstruct Templates36 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates35<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37>\nstruct Templates37 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates36<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38>\nstruct Templates38 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates37<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39>\nstruct Templates39 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates38<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40>\nstruct Templates40 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates39<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41>\nstruct Templates41 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates40<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42>\nstruct Templates42 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates41<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43>\nstruct Templates43 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates42<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44>\nstruct Templates44 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates43<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43, T44> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45>\nstruct Templates45 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates44<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43, T44, T45> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46>\nstruct Templates46 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates45<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43, T44, T45, T46> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47>\nstruct Templates47 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates46<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43, T44, T45, T46, T47> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48>\nstruct Templates48 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates47<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43, T44, T45, T46, T47, T48> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,\n    GTEST_TEMPLATE_ T49>\nstruct Templates49 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates48<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43, T44, T45, T46, T47, T48, T49> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,\n    GTEST_TEMPLATE_ T49, GTEST_TEMPLATE_ T50>\nstruct Templates50 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates49<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43, T44, T45, T46, T47, T48, T49, T50> Tail;\n};\n\n\n// We don't want to require the users to write TemplatesN<...> directly,\n// as that would require them to count the length.  Templates<...> is much\n// easier to write, but generates horrible messages when there is a\n// compiler error, as gcc insists on printing out each template\n// argument, even if it has the default value (this means Templates<list>\n// will appear as Templates<list, NoneT, NoneT, ..., NoneT> in the compiler\n// errors).\n//\n// Our solution is to combine the best part of the two approaches: a\n// user would write Templates<T1, ..., TN>, and Google Test will translate\n// that to TemplatesN<T1, ..., TN> internally to make error messages\n// readable.  The translation is done by the 'type' member of the\n// Templates template.\ntemplate <GTEST_TEMPLATE_ T1 = NoneT, GTEST_TEMPLATE_ T2 = NoneT,\n    GTEST_TEMPLATE_ T3 = NoneT, GTEST_TEMPLATE_ T4 = NoneT,\n    GTEST_TEMPLATE_ T5 = NoneT, GTEST_TEMPLATE_ T6 = NoneT,\n    GTEST_TEMPLATE_ T7 = NoneT, GTEST_TEMPLATE_ T8 = NoneT,\n    GTEST_TEMPLATE_ T9 = NoneT, GTEST_TEMPLATE_ T10 = NoneT,\n    GTEST_TEMPLATE_ T11 = NoneT, GTEST_TEMPLATE_ T12 = NoneT,\n    GTEST_TEMPLATE_ T13 = NoneT, GTEST_TEMPLATE_ T14 = NoneT,\n    GTEST_TEMPLATE_ T15 = NoneT, GTEST_TEMPLATE_ T16 = NoneT,\n    GTEST_TEMPLATE_ T17 = NoneT, GTEST_TEMPLATE_ T18 = NoneT,\n    GTEST_TEMPLATE_ T19 = NoneT, GTEST_TEMPLATE_ T20 = NoneT,\n    GTEST_TEMPLATE_ T21 = NoneT, GTEST_TEMPLATE_ T22 = NoneT,\n    GTEST_TEMPLATE_ T23 = NoneT, GTEST_TEMPLATE_ T24 = NoneT,\n    GTEST_TEMPLATE_ T25 = NoneT, GTEST_TEMPLATE_ T26 = NoneT,\n    GTEST_TEMPLATE_ T27 = NoneT, GTEST_TEMPLATE_ T28 = NoneT,\n    GTEST_TEMPLATE_ T29 = NoneT, GTEST_TEMPLATE_ T30 = NoneT,\n    GTEST_TEMPLATE_ T31 = NoneT, GTEST_TEMPLATE_ T32 = NoneT,\n    GTEST_TEMPLATE_ T33 = NoneT, GTEST_TEMPLATE_ T34 = NoneT,\n    GTEST_TEMPLATE_ T35 = NoneT, GTEST_TEMPLATE_ T36 = NoneT,\n    GTEST_TEMPLATE_ T37 = NoneT, GTEST_TEMPLATE_ T38 = NoneT,\n    GTEST_TEMPLATE_ T39 = NoneT, GTEST_TEMPLATE_ T40 = NoneT,\n    GTEST_TEMPLATE_ T41 = NoneT, GTEST_TEMPLATE_ T42 = NoneT,\n    GTEST_TEMPLATE_ T43 = NoneT, GTEST_TEMPLATE_ T44 = NoneT,\n    GTEST_TEMPLATE_ T45 = NoneT, GTEST_TEMPLATE_ T46 = NoneT,\n    GTEST_TEMPLATE_ T47 = NoneT, GTEST_TEMPLATE_ T48 = NoneT,\n    GTEST_TEMPLATE_ T49 = NoneT, GTEST_TEMPLATE_ T50 = NoneT>\nstruct Templates {\n  typedef Templates50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43, T44, T45, T46, T47, T48, T49, T50> type;\n};\n\ntemplate <>\nstruct Templates<NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT> {\n  typedef Templates0 type;\n};\ntemplate <GTEST_TEMPLATE_ T1>\nstruct Templates<T1, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT> {\n  typedef Templates1<T1> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2>\nstruct Templates<T1, T2, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT> {\n  typedef Templates2<T1, T2> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3>\nstruct Templates<T1, T2, T3, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates3<T1, T2, T3> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4>\nstruct Templates<T1, T2, T3, T4, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates4<T1, T2, T3, T4> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5>\nstruct Templates<T1, T2, T3, T4, T5, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates5<T1, T2, T3, T4, T5> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6>\nstruct Templates<T1, T2, T3, T4, T5, T6, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates6<T1, T2, T3, T4, T5, T6> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates7<T1, T2, T3, T4, T5, T6, T7> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates8<T1, T2, T3, T4, T5, T6, T7, T8> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates9<T1, T2, T3, T4, T5, T6, T7, T8, T9> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT> {\n  typedef Templates22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT> {\n  typedef Templates23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT> {\n  typedef Templates24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT> {\n  typedef Templates25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT> {\n  typedef Templates26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT> {\n  typedef Templates27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT> {\n  typedef Templates28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT> {\n  typedef Templates29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43, T44> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,\n    T45, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43, T44, T45> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,\n    T45, T46, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43, T44, T45, T46> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,\n    T45, T46, T47, NoneT, NoneT, NoneT> {\n  typedef Templates47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43, T44, T45, T46, T47> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,\n    T45, T46, T47, T48, NoneT, NoneT> {\n  typedef Templates48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43, T44, T45, T46, T47, T48> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,\n    GTEST_TEMPLATE_ T49>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,\n    T45, T46, T47, T48, T49, NoneT> {\n  typedef Templates49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43, T44, T45, T46, T47, T48, T49> type;\n};\n\n// The TypeList template makes it possible to use either a single type\n// or a Types<...> list in TYPED_TEST_CASE() and\n// INSTANTIATE_TYPED_TEST_CASE_P().\n\ntemplate <typename T>\nstruct TypeList {\n  typedef Types1<T> type;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49, typename T50>\nstruct TypeList<Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44, T45, T46, T47, T48, T49, T50> > {\n  typedef typename Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44, T45, T46, T47, T48, T49, T50>::type type;\n};\n\n#endif  // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_\n"
  },
  {
    "path": "utils/googletest/googletest/include/gtest/internal/gtest-type-util.h.pump",
    "content": "$$ -*- mode: c++; -*-\n$var n = 50  $$ Maximum length of type lists we want to support.\n// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Type utilities needed for implementing typed and type-parameterized\n// tests.  This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!\n//\n// Currently we support at most $n types in a list, and at most $n\n// type-parameterized tests in one type-parameterized test case.\n// Please contact googletestframework@googlegroups.com if you need\n// more.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_\n\n#include \"gtest/internal/gtest-port.h\"\n\n// #ifdef __GNUC__ is too general here.  It is possible to use gcc without using\n// libstdc++ (which is where cxxabi.h comes from).\n# if GTEST_HAS_CXXABI_H_\n#  include <cxxabi.h>\n# elif defined(__HP_aCC)\n#  include <acxx_demangle.h>\n# endif  // GTEST_HASH_CXXABI_H_\n\nnamespace testing {\nnamespace internal {\n\n// GetTypeName<T>() returns a human-readable name of type T.\n// NB: This function is also used in Google Mock, so don't move it inside of\n// the typed-test-only section below.\ntemplate <typename T>\nstd::string GetTypeName() {\n# if GTEST_HAS_RTTI\n\n  const char* const name = typeid(T).name();\n#  if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC)\n  int status = 0;\n  // gcc's implementation of typeid(T).name() mangles the type name,\n  // so we have to demangle it.\n#   if GTEST_HAS_CXXABI_H_\n  using abi::__cxa_demangle;\n#   endif  // GTEST_HAS_CXXABI_H_\n  char* const readable_name = __cxa_demangle(name, 0, 0, &status);\n  const std::string name_str(status == 0 ? readable_name : name);\n  free(readable_name);\n  return name_str;\n#  else\n  return name;\n#  endif  // GTEST_HAS_CXXABI_H_ || __HP_aCC\n\n# else\n\n  return \"<type>\";\n\n# endif  // GTEST_HAS_RTTI\n}\n\n#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P\n\n// AssertyTypeEq<T1, T2>::type is defined iff T1 and T2 are the same\n// type.  This can be used as a compile-time assertion to ensure that\n// two types are equal.\n\ntemplate <typename T1, typename T2>\nstruct AssertTypeEq;\n\ntemplate <typename T>\nstruct AssertTypeEq<T, T> {\n  typedef bool type;\n};\n\n// A unique type used as the default value for the arguments of class\n// template Types.  This allows us to simulate variadic templates\n// (e.g. Types<int>, Type<int, double>, and etc), which C++ doesn't\n// support directly.\nstruct None {};\n\n// The following family of struct and struct templates are used to\n// represent type lists.  In particular, TypesN<T1, T2, ..., TN>\n// represents a type list with N types (T1, T2, ..., and TN) in it.\n// Except for Types0, every struct in the family has two member types:\n// Head for the first type in the list, and Tail for the rest of the\n// list.\n\n// The empty type list.\nstruct Types0 {};\n\n// Type lists of length 1, 2, 3, and so on.\n\ntemplate <typename T1>\nstruct Types1 {\n  typedef T1 Head;\n  typedef Types0 Tail;\n};\n\n$range i 2..n\n\n$for i [[\n$range j 1..i\n$range k 2..i\ntemplate <$for j, [[typename T$j]]>\nstruct Types$i {\n  typedef T1 Head;\n  typedef Types$(i-1)<$for k, [[T$k]]> Tail;\n};\n\n\n]]\n\n}  // namespace internal\n\n// We don't want to require the users to write TypesN<...> directly,\n// as that would require them to count the length.  Types<...> is much\n// easier to write, but generates horrible messages when there is a\n// compiler error, as gcc insists on printing out each template\n// argument, even if it has the default value (this means Types<int>\n// will appear as Types<int, None, None, ..., None> in the compiler\n// errors).\n//\n// Our solution is to combine the best part of the two approaches: a\n// user would write Types<T1, ..., TN>, and Google Test will translate\n// that to TypesN<T1, ..., TN> internally to make error messages\n// readable.  The translation is done by the 'type' member of the\n// Types template.\n\n$range i 1..n\ntemplate <$for i, [[typename T$i = internal::None]]>\nstruct Types {\n  typedef internal::Types$n<$for i, [[T$i]]> type;\n};\n\ntemplate <>\nstruct Types<$for i, [[internal::None]]> {\n  typedef internal::Types0 type;\n};\n\n$range i 1..n-1\n$for i [[\n$range j 1..i\n$range k i+1..n\ntemplate <$for j, [[typename T$j]]>\nstruct Types<$for j, [[T$j]]$for k[[, internal::None]]> {\n  typedef internal::Types$i<$for j, [[T$j]]> type;\n};\n\n]]\n\nnamespace internal {\n\n# define GTEST_TEMPLATE_ template <typename T> class\n\n// The template \"selector\" struct TemplateSel<Tmpl> is used to\n// represent Tmpl, which must be a class template with one type\n// parameter, as a type.  TemplateSel<Tmpl>::Bind<T>::type is defined\n// as the type Tmpl<T>.  This allows us to actually instantiate the\n// template \"selected\" by TemplateSel<Tmpl>.\n//\n// This trick is necessary for simulating typedef for class templates,\n// which C++ doesn't support directly.\ntemplate <GTEST_TEMPLATE_ Tmpl>\nstruct TemplateSel {\n  template <typename T>\n  struct Bind {\n    typedef Tmpl<T> type;\n  };\n};\n\n# define GTEST_BIND_(TmplSel, T) \\\n  TmplSel::template Bind<T>::type\n\n// A unique struct template used as the default value for the\n// arguments of class template Templates.  This allows us to simulate\n// variadic templates (e.g. Templates<int>, Templates<int, double>,\n// and etc), which C++ doesn't support directly.\ntemplate <typename T>\nstruct NoneT {};\n\n// The following family of struct and struct templates are used to\n// represent template lists.  In particular, TemplatesN<T1, T2, ...,\n// TN> represents a list of N templates (T1, T2, ..., and TN).  Except\n// for Templates0, every struct in the family has two member types:\n// Head for the selector of the first template in the list, and Tail\n// for the rest of the list.\n\n// The empty template list.\nstruct Templates0 {};\n\n// Template lists of length 1, 2, 3, and so on.\n\ntemplate <GTEST_TEMPLATE_ T1>\nstruct Templates1 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates0 Tail;\n};\n\n$range i 2..n\n\n$for i [[\n$range j 1..i\n$range k 2..i\ntemplate <$for j, [[GTEST_TEMPLATE_ T$j]]>\nstruct Templates$i {\n  typedef TemplateSel<T1> Head;\n  typedef Templates$(i-1)<$for k, [[T$k]]> Tail;\n};\n\n\n]]\n\n// We don't want to require the users to write TemplatesN<...> directly,\n// as that would require them to count the length.  Templates<...> is much\n// easier to write, but generates horrible messages when there is a\n// compiler error, as gcc insists on printing out each template\n// argument, even if it has the default value (this means Templates<list>\n// will appear as Templates<list, NoneT, NoneT, ..., NoneT> in the compiler\n// errors).\n//\n// Our solution is to combine the best part of the two approaches: a\n// user would write Templates<T1, ..., TN>, and Google Test will translate\n// that to TemplatesN<T1, ..., TN> internally to make error messages\n// readable.  The translation is done by the 'type' member of the\n// Templates template.\n\n$range i 1..n\ntemplate <$for i, [[GTEST_TEMPLATE_ T$i = NoneT]]>\nstruct Templates {\n  typedef Templates$n<$for i, [[T$i]]> type;\n};\n\ntemplate <>\nstruct Templates<$for i, [[NoneT]]> {\n  typedef Templates0 type;\n};\n\n$range i 1..n-1\n$for i [[\n$range j 1..i\n$range k i+1..n\ntemplate <$for j, [[GTEST_TEMPLATE_ T$j]]>\nstruct Templates<$for j, [[T$j]]$for k[[, NoneT]]> {\n  typedef Templates$i<$for j, [[T$j]]> type;\n};\n\n]]\n\n// The TypeList template makes it possible to use either a single type\n// or a Types<...> list in TYPED_TEST_CASE() and\n// INSTANTIATE_TYPED_TEST_CASE_P().\n\ntemplate <typename T>\nstruct TypeList {\n  typedef Types1<T> type;\n};\n\n\n$range i 1..n\ntemplate <$for i, [[typename T$i]]>\nstruct TypeList<Types<$for i, [[T$i]]> > {\n  typedef typename Types<$for i, [[T$i]]>::type type;\n};\n\n#endif  // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_\n"
  },
  {
    "path": "utils/googletest/googletest/m4/acx_pthread.m4",
    "content": "# This was retrieved from\n#    http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?revision=1277&root=avahi\n# See also (perhaps for new versions?)\n#    http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?root=avahi\n#\n# We've rewritten the inconsistency check code (from avahi), to work\n# more broadly.  In particular, it no longer assumes ld accepts -zdefs.\n# This caused a restructing of the code, but the functionality has only\n# changed a little.\n\ndnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])\ndnl\ndnl @summary figure out how to build C programs using POSIX threads\ndnl\ndnl This macro figures out how to build C programs using POSIX threads.\ndnl It sets the PTHREAD_LIBS output variable to the threads library and\ndnl linker flags, and the PTHREAD_CFLAGS output variable to any special\ndnl C compiler flags that are needed. (The user can also force certain\ndnl compiler flags/libs to be tested by setting these environment\ndnl variables.)\ndnl\ndnl Also sets PTHREAD_CC to any special C compiler that is needed for\ndnl multi-threaded programs (defaults to the value of CC otherwise).\ndnl (This is necessary on AIX to use the special cc_r compiler alias.)\ndnl\ndnl NOTE: You are assumed to not only compile your program with these\ndnl flags, but also link it with them as well. e.g. you should link\ndnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS\ndnl $LIBS\ndnl\ndnl If you are only building threads programs, you may wish to use\ndnl these variables in your default LIBS, CFLAGS, and CC:\ndnl\ndnl        LIBS=\"$PTHREAD_LIBS $LIBS\"\ndnl        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\ndnl        CC=\"$PTHREAD_CC\"\ndnl\ndnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute\ndnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to\ndnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).\ndnl\ndnl ACTION-IF-FOUND is a list of shell commands to run if a threads\ndnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to\ndnl run it if it is not found. If ACTION-IF-FOUND is not specified, the\ndnl default action will define HAVE_PTHREAD.\ndnl\ndnl Please let the authors know if this macro fails on any platform, or\ndnl if you have any other suggestions or comments. This macro was based\ndnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with\ndnl help from M. Frigo), as well as ac_pthread and hb_pthread macros\ndnl posted by Alejandro Forero Cuervo to the autoconf macro repository.\ndnl We are also grateful for the helpful feedback of numerous users.\ndnl\ndnl @category InstalledPackages\ndnl @author Steven G. Johnson <stevenj@alum.mit.edu>\ndnl @version 2006-05-29\ndnl @license GPLWithACException\ndnl \ndnl Checks for GCC shared/pthread inconsistency based on work by\ndnl Marcin Owsiany <marcin@owsiany.pl>\n\n\nAC_DEFUN([ACX_PTHREAD], [\nAC_REQUIRE([AC_CANONICAL_HOST])\nAC_LANG_SAVE\nAC_LANG_C\nacx_pthread_ok=no\n\n# We used to check for pthread.h first, but this fails if pthread.h\n# requires special compiler flags (e.g. on True64 or Sequent).\n# It gets checked for in the link test anyway.\n\n# First of all, check if the user has set any of the PTHREAD_LIBS,\n# etcetera environment variables, and if threads linking works using\n# them:\nif test x\"$PTHREAD_LIBS$PTHREAD_CFLAGS\" != x; then\n        save_CFLAGS=\"$CFLAGS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n        save_LIBS=\"$LIBS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])\n        AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)\n        AC_MSG_RESULT($acx_pthread_ok)\n        if test x\"$acx_pthread_ok\" = xno; then\n                PTHREAD_LIBS=\"\"\n                PTHREAD_CFLAGS=\"\"\n        fi\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\nfi\n\n# We must check for the threads library under a number of different\n# names; the ordering is very important because some systems\n# (e.g. DEC) have both -lpthread and -lpthreads, where one of the\n# libraries is broken (non-POSIX).\n\n# Create a list of thread flags to try.  Items starting with a \"-\" are\n# C compiler flags, and other items are library names, except for \"none\"\n# which indicates that we try without any flags at all, and \"pthread-config\"\n# which is a program returning the flags for the Pth emulation library.\n\nacx_pthread_flags=\"pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config\"\n\n# The ordering *is* (sometimes) important.  Some notes on the\n# individual items follow:\n\n# pthreads: AIX (must check this before -lpthread)\n# none: in case threads are in libc; should be tried before -Kthread and\n#       other compiler flags to prevent continual compiler warnings\n# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)\n# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)\n# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)\n# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)\n# -pthreads: Solaris/gcc\n# -mthreads: Mingw32/gcc, Lynx/gcc\n# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it\n#      doesn't hurt to check since this sometimes defines pthreads too;\n#      also defines -D_REENTRANT)\n#      ... -mt is also the pthreads flag for HP/aCC\n# pthread: Linux, etcetera\n# --thread-safe: KAI C++\n# pthread-config: use pthread-config program (for GNU Pth library)\n\ncase \"${host_cpu}-${host_os}\" in\n        *solaris*)\n\n        # On Solaris (at least, for some versions), libc contains stubbed\n        # (non-functional) versions of the pthreads routines, so link-based\n        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/\n        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather\n        # a function called by this macro, so we could check for that, but\n        # who knows whether they'll stub that too in a future libc.)  So,\n        # we'll just look for -pthreads and -lpthread first:\n\n        acx_pthread_flags=\"-pthreads pthread -mt -pthread $acx_pthread_flags\"\n        ;;\nesac\n\nif test x\"$acx_pthread_ok\" = xno; then\nfor flag in $acx_pthread_flags; do\n\n        case $flag in\n                none)\n                AC_MSG_CHECKING([whether pthreads work without any flags])\n                ;;\n\n                -*)\n                AC_MSG_CHECKING([whether pthreads work with $flag])\n                PTHREAD_CFLAGS=\"$flag\"\n                ;;\n\n\t\tpthread-config)\n\t\tAC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)\n\t\tif test x\"$acx_pthread_config\" = xno; then continue; fi\n\t\tPTHREAD_CFLAGS=\"`pthread-config --cflags`\"\n\t\tPTHREAD_LIBS=\"`pthread-config --ldflags` `pthread-config --libs`\"\n\t\t;;\n\n                *)\n                AC_MSG_CHECKING([for the pthreads library -l$flag])\n                PTHREAD_LIBS=\"-l$flag\"\n                ;;\n        esac\n\n        save_LIBS=\"$LIBS\"\n        save_CFLAGS=\"$CFLAGS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n\n        # Check for various functions.  We must include pthread.h,\n        # since some functions may be macros.  (On the Sequent, we\n        # need a special flag -Kthread to make this header compile.)\n        # We check for pthread_join because it is in -lpthread on IRIX\n        # while pthread_create is in libc.  We check for pthread_attr_init\n        # due to DEC craziness with -lpthreads.  We check for\n        # pthread_cleanup_push because it is one of the few pthread\n        # functions on Solaris that doesn't have a non-functional libc stub.\n        # We try pthread_create on general principles.\n        AC_TRY_LINK([#include <pthread.h>],\n                    [pthread_t th; pthread_join(th, 0);\n                     pthread_attr_init(0); pthread_cleanup_push(0, 0);\n                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n                    [acx_pthread_ok=yes])\n\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\n\n        AC_MSG_RESULT($acx_pthread_ok)\n        if test \"x$acx_pthread_ok\" = xyes; then\n                break;\n        fi\n\n        PTHREAD_LIBS=\"\"\n        PTHREAD_CFLAGS=\"\"\ndone\nfi\n\n# Various other checks:\nif test \"x$acx_pthread_ok\" = xyes; then\n        save_LIBS=\"$LIBS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        save_CFLAGS=\"$CFLAGS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n\n        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.\n\tAC_MSG_CHECKING([for joinable pthread attribute])\n\tattr_name=unknown\n\tfor attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do\n\t    AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],\n                        [attr_name=$attr; break])\n\tdone\n        AC_MSG_RESULT($attr_name)\n        if test \"$attr_name\" != PTHREAD_CREATE_JOINABLE; then\n            AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,\n                               [Define to necessary symbol if this constant\n                                uses a non-standard name on your system.])\n        fi\n\n        AC_MSG_CHECKING([if more special flags are required for pthreads])\n        flag=no\n        case \"${host_cpu}-${host_os}\" in\n            *-aix* | *-freebsd* | *-darwin*) flag=\"-D_THREAD_SAFE\";;\n            *solaris* | *-osf* | *-hpux*) flag=\"-D_REENTRANT\";;\n        esac\n        AC_MSG_RESULT(${flag})\n        if test \"x$flag\" != xno; then\n            PTHREAD_CFLAGS=\"$flag $PTHREAD_CFLAGS\"\n        fi\n\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\n        # More AIX lossage: must compile with xlc_r or cc_r\n\tif test x\"$GCC\" != xyes; then\n          AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})\n        else\n          PTHREAD_CC=$CC\n\tfi\n\n\t# The next part tries to detect GCC inconsistency with -shared on some\n\t# architectures and systems. The problem is that in certain\n\t# configurations, when -shared is specified, GCC \"forgets\" to\n\t# internally use various flags which are still necessary.\n\t\n\t#\n\t# Prepare the flags\n\t#\n\tsave_CFLAGS=\"$CFLAGS\"\n\tsave_LIBS=\"$LIBS\"\n\tsave_CC=\"$CC\"\n\t\n\t# Try with the flags determined by the earlier checks.\n\t#\n\t# -Wl,-z,defs forces link-time symbol resolution, so that the\n\t# linking checks with -shared actually have any value\n\t#\n\t# FIXME: -fPIC is required for -shared on many architectures,\n\t# so we specify it here, but the right way would probably be to\n\t# properly detect whether it is actually required.\n\tCFLAGS=\"-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS\"\n\tLIBS=\"$PTHREAD_LIBS $LIBS\"\n\tCC=\"$PTHREAD_CC\"\n\t\n\t# In order not to create several levels of indentation, we test\n\t# the value of \"$done\" until we find the cure or run out of ideas.\n\tdone=\"no\"\n\t\n\t# First, make sure the CFLAGS we added are actually accepted by our\n\t# compiler.  If not (and OS X's ld, for instance, does not accept -z),\n\t# then we can't do this test.\n\tif test x\"$done\" = xno; then\n\t   AC_MSG_CHECKING([whether to check for GCC pthread/shared inconsistencies])\n\t   AC_TRY_LINK(,, , [done=yes])\n\t\n\t   if test \"x$done\" = xyes ; then\n\t      AC_MSG_RESULT([no])\n\t   else\n\t      AC_MSG_RESULT([yes])\n\t   fi\n\tfi\n\t\n\tif test x\"$done\" = xno; then\n\t   AC_MSG_CHECKING([whether -pthread is sufficient with -shared])\n\t   AC_TRY_LINK([#include <pthread.h>],\n\t      [pthread_t th; pthread_join(th, 0);\n\t      pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t      pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n\t      [done=yes])\n\t   \n\t   if test \"x$done\" = xyes; then\n\t      AC_MSG_RESULT([yes])\n\t   else\n\t      AC_MSG_RESULT([no])\n\t   fi\n\tfi\n\t\n\t#\n\t# Linux gcc on some architectures such as mips/mipsel forgets\n\t# about -lpthread\n\t#\n\tif test x\"$done\" = xno; then\n\t   AC_MSG_CHECKING([whether -lpthread fixes that])\n\t   LIBS=\"-lpthread $PTHREAD_LIBS $save_LIBS\"\n\t   AC_TRY_LINK([#include <pthread.h>],\n\t      [pthread_t th; pthread_join(th, 0);\n\t      pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t      pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n\t      [done=yes])\n\t\n\t   if test \"x$done\" = xyes; then\n\t      AC_MSG_RESULT([yes])\n\t      PTHREAD_LIBS=\"-lpthread $PTHREAD_LIBS\"\n\t   else\n\t      AC_MSG_RESULT([no])\n\t   fi\n\tfi\n\t#\n\t# FreeBSD 4.10 gcc forgets to use -lc_r instead of -lc\n\t#\n\tif test x\"$done\" = xno; then\n\t   AC_MSG_CHECKING([whether -lc_r fixes that])\n\t   LIBS=\"-lc_r $PTHREAD_LIBS $save_LIBS\"\n\t   AC_TRY_LINK([#include <pthread.h>],\n\t       [pthread_t th; pthread_join(th, 0);\n\t        pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t        pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n\t       [done=yes])\n\t\n\t   if test \"x$done\" = xyes; then\n\t      AC_MSG_RESULT([yes])\n\t      PTHREAD_LIBS=\"-lc_r $PTHREAD_LIBS\"\n\t   else\n\t      AC_MSG_RESULT([no])\n\t   fi\n\tfi\n\tif test x\"$done\" = xno; then\n\t   # OK, we have run out of ideas\n\t   AC_MSG_WARN([Impossible to determine how to use pthreads with shared libraries])\n\t\n\t   # so it's not safe to assume that we may use pthreads\n\t   acx_pthread_ok=no\n\tfi\n\t\n\tCFLAGS=\"$save_CFLAGS\"\n\tLIBS=\"$save_LIBS\"\n\tCC=\"$save_CC\"\nelse\n        PTHREAD_CC=\"$CC\"\nfi\n\nAC_SUBST(PTHREAD_LIBS)\nAC_SUBST(PTHREAD_CFLAGS)\nAC_SUBST(PTHREAD_CC)\n\n# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:\nif test x\"$acx_pthread_ok\" = xyes; then\n        ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])\n        :\nelse\n        acx_pthread_ok=no\n        $2\nfi\nAC_LANG_RESTORE\n])dnl ACX_PTHREAD\n"
  },
  {
    "path": "utils/googletest/googletest/m4/gtest.m4",
    "content": "dnl GTEST_LIB_CHECK([minimum version [,\ndnl                  action if found [,action if not found]]])\ndnl\ndnl Check for the presence of the Google Test library, optionally at a minimum\ndnl version, and indicate a viable version with the HAVE_GTEST flag. It defines\ndnl standard variables for substitution including GTEST_CPPFLAGS,\ndnl GTEST_CXXFLAGS, GTEST_LDFLAGS, and GTEST_LIBS. It also defines\ndnl GTEST_VERSION as the version of Google Test found. Finally, it provides\ndnl optional custom action slots in the event GTEST is found or not.\nAC_DEFUN([GTEST_LIB_CHECK],\n[\ndnl Provide a flag to enable or disable Google Test usage.\nAC_ARG_ENABLE([gtest],\n  [AS_HELP_STRING([--enable-gtest],\n                  [Enable tests using the Google C++ Testing Framework.\n                  (Default is enabled.)])],\n  [],\n  [enable_gtest=])\nAC_ARG_VAR([GTEST_CONFIG],\n           [The exact path of Google Test's 'gtest-config' script.])\nAC_ARG_VAR([GTEST_CPPFLAGS],\n           [C-like preprocessor flags for Google Test.])\nAC_ARG_VAR([GTEST_CXXFLAGS],\n           [C++ compile flags for Google Test.])\nAC_ARG_VAR([GTEST_LDFLAGS],\n           [Linker path and option flags for Google Test.])\nAC_ARG_VAR([GTEST_LIBS],\n           [Library linking flags for Google Test.])\nAC_ARG_VAR([GTEST_VERSION],\n           [The version of Google Test available.])\nHAVE_GTEST=\"no\"\nAS_IF([test \"x${enable_gtest}\" != \"xno\"],\n  [AC_MSG_CHECKING([for 'gtest-config'])\n   AS_IF([test \"x${enable_gtest}\" != \"xyes\"],\n     [AS_IF([test -x \"${enable_gtest}/scripts/gtest-config\"],\n        [GTEST_CONFIG=\"${enable_gtest}/scripts/gtest-config\"],\n        [GTEST_CONFIG=\"${enable_gtest}/bin/gtest-config\"])\n      AS_IF([test -x \"${GTEST_CONFIG}\"], [],\n        [AC_MSG_RESULT([no])\n         AC_MSG_ERROR([dnl\nUnable to locate either a built or installed Google Test.\nThe specific location '${enable_gtest}' was provided for a built or installed\nGoogle Test, but no 'gtest-config' script could be found at this location.])\n         ])],\n     [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])])\n   AS_IF([test -x \"${GTEST_CONFIG}\"],\n     [AC_MSG_RESULT([${GTEST_CONFIG}])\n      m4_ifval([$1],\n        [_gtest_min_version=\"--min-version=$1\"\n         AC_MSG_CHECKING([for Google Test at least version >= $1])],\n        [_gtest_min_version=\"--min-version=0\"\n         AC_MSG_CHECKING([for Google Test])])\n      AS_IF([${GTEST_CONFIG} ${_gtest_min_version}],\n        [AC_MSG_RESULT([yes])\n         HAVE_GTEST='yes'],\n        [AC_MSG_RESULT([no])])],\n     [AC_MSG_RESULT([no])])\n   AS_IF([test \"x${HAVE_GTEST}\" = \"xyes\"],\n     [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`\n      GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`\n      GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`\n      GTEST_LIBS=`${GTEST_CONFIG} --libs`\n      GTEST_VERSION=`${GTEST_CONFIG} --version`\n      AC_DEFINE([HAVE_GTEST],[1],[Defined when Google Test is available.])],\n     [AS_IF([test \"x${enable_gtest}\" = \"xyes\"],\n        [AC_MSG_ERROR([dnl\nGoogle Test was enabled, but no viable version could be found.])\n         ])])])\nAC_SUBST([HAVE_GTEST])\nAM_CONDITIONAL([HAVE_GTEST],[test \"x$HAVE_GTEST\" = \"xyes\"])\nAS_IF([test \"x$HAVE_GTEST\" = \"xyes\"],\n  [m4_ifval([$2], [$2])],\n  [m4_ifval([$3], [$3])])\n])\n"
  },
  {
    "path": "utils/googletest/googletest/make/Makefile",
    "content": "# A sample Makefile for building Google Test and using it in user\n# tests.  Please tweak it to suit your environment and project.  You\n# may want to move it to your project's root directory.\n#\n# SYNOPSIS:\n#\n#   make [all]  - makes everything.\n#   make TARGET - makes the given target.\n#   make clean  - removes all files generated by make.\n\n# Please tweak the following variable definitions as needed by your\n# project, except GTEST_HEADERS, which you can use in your own targets\n# but shouldn't modify.\n\n# Points to the root of Google Test, relative to where this file is.\n# Remember to tweak this if you move this file.\nGTEST_DIR = ..\n\n# Where to find user code.\nUSER_DIR = ../samples\n\n# Flags passed to the preprocessor.\n# Set Google Test's header directory as a system directory, such that\n# the compiler doesn't generate warnings in Google Test headers.\nCPPFLAGS += -isystem $(GTEST_DIR)/include\n\n# Flags passed to the C++ compiler.\nCXXFLAGS += -g -Wall -Wextra -pthread\n\n# All tests produced by this Makefile.  Remember to add new tests you\n# created to the list.\nTESTS = sample1_unittest\n\n# All Google Test headers.  Usually you shouldn't change this\n# definition.\nGTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \\\n                $(GTEST_DIR)/include/gtest/internal/*.h\n\n# House-keeping build targets.\n\nall : $(TESTS)\n\nclean :\n\trm -f $(TESTS) gtest.a gtest_main.a *.o\n\n# Builds gtest.a and gtest_main.a.\n\n# Usually you shouldn't tweak such internal variables, indicated by a\n# trailing _.\nGTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)\n\n# For simplicity and to avoid depending on Google Test's\n# implementation details, the dependencies specified below are\n# conservative and not optimized.  This is fine as Google Test\n# compiles fast and for ordinary users its source rarely changes.\ngtest-all.o : $(GTEST_SRCS_)\n\t$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \\\n            $(GTEST_DIR)/src/gtest-all.cc\n\ngtest_main.o : $(GTEST_SRCS_)\n\t$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \\\n            $(GTEST_DIR)/src/gtest_main.cc\n\ngtest.a : gtest-all.o\n\t$(AR) $(ARFLAGS) $@ $^\n\ngtest_main.a : gtest-all.o gtest_main.o\n\t$(AR) $(ARFLAGS) $@ $^\n\n# Builds a sample test.  A test should link with either gtest.a or\n# gtest_main.a, depending on whether it defines its own main()\n# function.\n\nsample1.o : $(USER_DIR)/sample1.cc $(USER_DIR)/sample1.h $(GTEST_HEADERS)\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/sample1.cc\n\nsample1_unittest.o : $(USER_DIR)/sample1_unittest.cc \\\n                     $(USER_DIR)/sample1.h $(GTEST_HEADERS)\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/sample1_unittest.cc\n\nsample1_unittest : sample1.o sample1_unittest.o gtest_main.a\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@\n"
  },
  {
    "path": "utils/googletest/googletest/msvc/gtest-md.sln",
    "content": "Microsoft Visual Studio Solution File, Format Version 8.00\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest-md\", \"gtest-md.vcproj\", \"{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest_main-md\", \"gtest_main-md.vcproj\", \"{3AF54C8A-10BF-4332-9147-F68ED9862033}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest_prod_test-md\", \"gtest_prod_test-md.vcproj\", \"{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest_unittest-md\", \"gtest_unittest-md.vcproj\", \"{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nGlobal\r\n\tGlobalSection(SolutionConfiguration) = preSolution\r\n\t\tDebug = Debug\r\n\t\tRelease = Release\r\n\tEndGlobalSection\r\n\tGlobalSection(ProjectConfiguration) = postSolution\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.Build.0 = Debug|Win32\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.ActiveCfg = Release|Win32\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.Build.0 = Release|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.Build.0 = Debug|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.ActiveCfg = Release|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.Build.0 = Release|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.Build.0 = Debug|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.ActiveCfg = Release|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.Build.0 = Release|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.Build.0 = Debug|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.ActiveCfg = Release|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.Build.0 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(ExtensibilityGlobals) = postSolution\r\n\tEndGlobalSection\r\n\tGlobalSection(ExtensibilityAddIns) = postSolution\r\n\tEndGlobalSection\r\nEndGlobal\r\n"
  },
  {
    "path": "utils/googletest/googletest/msvc/gtest-md.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest-md\"\r\n\tProjectGUID=\"{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtestd.lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"&quot;..\\include&quot;;&quot;..&quot;\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest.lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\src\\gtest-all.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "utils/googletest/googletest/msvc/gtest.sln",
    "content": "Microsoft Visual Studio Solution File, Format Version 8.00\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest\", \"gtest.vcproj\", \"{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest_main\", \"gtest_main.vcproj\", \"{3AF54C8A-10BF-4332-9147-F68ED9862032}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest_unittest\", \"gtest_unittest.vcproj\", \"{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest_prod_test\", \"gtest_prod_test.vcproj\", \"{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nGlobal\r\n\tGlobalSection(SolutionConfiguration) = preSolution\r\n\t\tDebug = Debug\r\n\t\tRelease = Release\r\n\tEndGlobalSection\r\n\tGlobalSection(ProjectConfiguration) = postSolution\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.Build.0 = Debug|Win32\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.ActiveCfg = Release|Win32\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.Build.0 = Release|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.Build.0 = Debug|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.ActiveCfg = Release|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.Build.0 = Release|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.Build.0 = Debug|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.ActiveCfg = Release|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.Build.0 = Release|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.Build.0 = Debug|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.ActiveCfg = Release|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.Build.0 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(ExtensibilityGlobals) = postSolution\r\n\tEndGlobalSection\r\n\tGlobalSection(ExtensibilityAddIns) = postSolution\r\n\tEndGlobalSection\r\nEndGlobal\r\n"
  },
  {
    "path": "utils/googletest/googletest/msvc/gtest.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest\"\r\n\tProjectGUID=\"{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"5\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtestd.lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"&quot;..\\include&quot;;&quot;..&quot;\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\r\n\t\t\t\tRuntimeLibrary=\"4\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest.lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\src\\gtest-all.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "utils/googletest/googletest/msvc/gtest_main-md.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest_main-md\"\r\n\tProjectGUID=\"{3AF54C8A-10BF-4332-9147-F68ED9862033}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/$(ProjectName)d.lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"&quot;..\\include&quot;;&quot;..&quot;\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/$(ProjectName).lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t\t<ProjectReference\r\n\t\t\tReferencedProjectIdentifier=\"{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}\"\r\n\t\t\tName=\"gtest-md\"/>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\src\\gtest_main.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "utils/googletest/googletest/msvc/gtest_main.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest_main\"\r\n\tProjectGUID=\"{3AF54C8A-10BF-4332-9147-F68ED9862032}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"5\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/$(ProjectName)d.lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"&quot;..\\include&quot;;&quot;..&quot;\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\r\n\t\t\t\tRuntimeLibrary=\"4\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/$(ProjectName).lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t\t<ProjectReference\r\n\t\t\tReferencedProjectIdentifier=\"{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}\"\r\n\t\t\tName=\"gtest\"/>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\src\\gtest_main.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "utils/googletest/googletest/msvc/gtest_prod_test-md.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest_prod_test-md\"\r\n\tProjectGUID=\"{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_prod_test.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tProgramDatabaseFile=\"$(OutDir)/gtest_prod_test.pdb\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_prod_test.exe\"\r\n\t\t\t\tLinkIncremental=\"1\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t\t<ProjectReference\r\n\t\t\tReferencedProjectIdentifier=\"{3AF54C8A-10BF-4332-9147-F68ED9862033}\"\r\n\t\t\tName=\"gtest_main-md\"/>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\gtest_prod_test.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\production.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\production.h\">\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "utils/googletest/googletest/msvc/gtest_prod_test.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest_prod_test\"\r\n\tProjectGUID=\"{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"5\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_prod_test.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tProgramDatabaseFile=\"$(OutDir)/gtest_prod_test.pdb\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE\"\r\n\t\t\t\tRuntimeLibrary=\"4\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_prod_test.exe\"\r\n\t\t\t\tLinkIncremental=\"1\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t\t<ProjectReference\r\n\t\t\tReferencedProjectIdentifier=\"{3AF54C8A-10BF-4332-9147-F68ED9862032}\"\r\n\t\t\tName=\"gtest_main\"/>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\gtest_prod_test.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\production.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\production.h\">\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "utils/googletest/googletest/msvc/gtest_unittest-md.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest_unittest-md\"\r\n\tProjectGUID=\"{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_unittest.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tProgramDatabaseFile=\"$(OutDir)/gtest_unittest.pdb\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_unittest.exe\"\r\n\t\t\t\tLinkIncremental=\"1\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t\t<ProjectReference\r\n\t\t\tReferencedProjectIdentifier=\"{3AF54C8A-10BF-4332-9147-F68ED9862033}\"\r\n\t\t\tName=\"gtest_main-md\"/>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\gtest_unittest.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tOptimization=\"1\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tBasicRuntimeChecks=\"0\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "utils/googletest/googletest/msvc/gtest_unittest.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest_unittest\"\r\n\tProjectGUID=\"{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"5\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_unittest.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tProgramDatabaseFile=\"$(OutDir)/gtest_unittest.pdb\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE\"\r\n\t\t\t\tRuntimeLibrary=\"4\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_unittest.exe\"\r\n\t\t\t\tLinkIncremental=\"1\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t\t<ProjectReference\r\n\t\t\tReferencedProjectIdentifier=\"{3AF54C8A-10BF-4332-9147-F68ED9862032}\"\r\n\t\t\tName=\"gtest_main\"/>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\gtest_unittest.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tOptimization=\"1\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tBasicRuntimeChecks=\"0\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "utils/googletest/googletest/samples/prime_tables.h",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n// Author: vladl@google.com (Vlad Losev)\n\n// This provides interface PrimeTable that determines whether a number is a\n// prime and determines a next prime number. This interface is used\n// in Google Test samples demonstrating use of parameterized tests.\n\n#ifndef GTEST_SAMPLES_PRIME_TABLES_H_\n#define GTEST_SAMPLES_PRIME_TABLES_H_\n\n#include <algorithm>\n\n// The prime table interface.\nclass PrimeTable {\n public:\n  virtual ~PrimeTable() {}\n\n  // Returns true iff n is a prime number.\n  virtual bool IsPrime(int n) const = 0;\n\n  // Returns the smallest prime number greater than p; or returns -1\n  // if the next prime is beyond the capacity of the table.\n  virtual int GetNextPrime(int p) const = 0;\n};\n\n// Implementation #1 calculates the primes on-the-fly.\nclass OnTheFlyPrimeTable : public PrimeTable {\n public:\n  virtual bool IsPrime(int n) const {\n    if (n <= 1) return false;\n\n    for (int i = 2; i*i <= n; i++) {\n      // n is divisible by an integer other than 1 and itself.\n      if ((n % i) == 0) return false;\n    }\n\n    return true;\n  }\n\n  virtual int GetNextPrime(int p) const {\n    for (int n = p + 1; n > 0; n++) {\n      if (IsPrime(n)) return n;\n    }\n\n    return -1;\n  }\n};\n\n// Implementation #2 pre-calculates the primes and stores the result\n// in an array.\nclass PreCalculatedPrimeTable : public PrimeTable {\n public:\n  // 'max' specifies the maximum number the prime table holds.\n  explicit PreCalculatedPrimeTable(int max)\n      : is_prime_size_(max + 1), is_prime_(new bool[max + 1]) {\n    CalculatePrimesUpTo(max);\n  }\n  virtual ~PreCalculatedPrimeTable() { delete[] is_prime_; }\n\n  virtual bool IsPrime(int n) const {\n    return 0 <= n && n < is_prime_size_ && is_prime_[n];\n  }\n\n  virtual int GetNextPrime(int p) const {\n    for (int n = p + 1; n < is_prime_size_; n++) {\n      if (is_prime_[n]) return n;\n    }\n\n    return -1;\n  }\n\n private:\n  void CalculatePrimesUpTo(int max) {\n    ::std::fill(is_prime_, is_prime_ + is_prime_size_, true);\n    is_prime_[0] = is_prime_[1] = false;\n\n    for (int i = 2; i <= max; i++) {\n      if (!is_prime_[i]) continue;\n\n      // Marks all multiples of i (except i itself) as non-prime.\n      for (int j = 2*i; j <= max; j += i) {\n        is_prime_[j] = false;\n      }\n    }\n  }\n\n  const int is_prime_size_;\n  bool* const is_prime_;\n\n  // Disables compiler warning \"assignment operator could not be generated.\"\n  void operator=(const PreCalculatedPrimeTable& rhs);\n};\n\n#endif  // GTEST_SAMPLES_PRIME_TABLES_H_\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample1.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"sample1.h\"\n\n// Returns n! (the factorial of n).  For negative n, n! is defined to be 1.\nint Factorial(int n) {\n  int result = 1;\n  for (int i = 1; i <= n; i++) {\n    result *= i;\n  }\n\n  return result;\n}\n\n// Returns true iff n is a prime number.\nbool IsPrime(int n) {\n  // Trivial case 1: small numbers\n  if (n <= 1) return false;\n\n  // Trivial case 2: even numbers\n  if (n % 2 == 0) return n == 2;\n\n  // Now, we have that n is odd and n >= 3.\n\n  // Try to divide n by every odd number i, starting from 3\n  for (int i = 3; ; i += 2) {\n    // We only have to try i up to the squre root of n\n    if (i > n/i) break;\n\n    // Now, we have i <= n/i < n.\n    // If n is divisible by i, n is not prime.\n    if (n % i == 0) return false;\n  }\n\n  // n has no integer factor in the range (1, n), and thus is prime.\n  return true;\n}\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample1.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#ifndef GTEST_SAMPLES_SAMPLE1_H_\n#define GTEST_SAMPLES_SAMPLE1_H_\n\n// Returns n! (the factorial of n).  For negative n, n! is defined to be 1.\nint Factorial(int n);\n\n// Returns true iff n is a prime number.\nbool IsPrime(int n);\n\n#endif  // GTEST_SAMPLES_SAMPLE1_H_\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample10_unittest.cc",
    "content": "// Copyright 2009 Google Inc. All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// This sample shows how to use Google Test listener API to implement\n// a primitive leak checker.\n\n#include <stdio.h>\n#include <stdlib.h>\n\n#include \"gtest/gtest.h\"\n\nusing ::testing::EmptyTestEventListener;\nusing ::testing::InitGoogleTest;\nusing ::testing::Test;\nusing ::testing::TestCase;\nusing ::testing::TestEventListeners;\nusing ::testing::TestInfo;\nusing ::testing::TestPartResult;\nusing ::testing::UnitTest;\n\nnamespace {\n\n// We will track memory used by this class.\nclass Water {\n public:\n  // Normal Water declarations go here.\n\n  // operator new and operator delete help us control water allocation.\n  void* operator new(size_t allocation_size) {\n    allocated_++;\n    return malloc(allocation_size);\n  }\n\n  void operator delete(void* block, size_t /* allocation_size */) {\n    allocated_--;\n    free(block);\n  }\n\n  static int allocated() { return allocated_; }\n\n private:\n  static int allocated_;\n};\n\nint Water::allocated_ = 0;\n\n// This event listener monitors how many Water objects are created and\n// destroyed by each test, and reports a failure if a test leaks some Water\n// objects. It does this by comparing the number of live Water objects at\n// the beginning of a test and at the end of a test.\nclass LeakChecker : public EmptyTestEventListener {\n private:\n  // Called before a test starts.\n  virtual void OnTestStart(const TestInfo& /* test_info */) {\n    initially_allocated_ = Water::allocated();\n  }\n\n  // Called after a test ends.\n  virtual void OnTestEnd(const TestInfo& /* test_info */) {\n    int difference = Water::allocated() - initially_allocated_;\n\n    // You can generate a failure in any event handler except\n    // OnTestPartResult. Just use an appropriate Google Test assertion to do\n    // it.\n    EXPECT_LE(difference, 0) << \"Leaked \" << difference << \" unit(s) of Water!\";\n  }\n\n  int initially_allocated_;\n};\n\nTEST(ListenersTest, DoesNotLeak) {\n  Water* water = new Water;\n  delete water;\n}\n\n// This should fail when the --check_for_leaks command line flag is\n// specified.\nTEST(ListenersTest, LeaksWater) {\n  Water* water = new Water;\n  EXPECT_TRUE(water != NULL);\n}\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  InitGoogleTest(&argc, argv);\n\n  bool check_for_leaks = false;\n  if (argc > 1 && strcmp(argv[1], \"--check_for_leaks\") == 0 )\n    check_for_leaks = true;\n  else\n    printf(\"%s\\n\", \"Run this program with --check_for_leaks to enable \"\n           \"custom leak checking in the tests.\");\n\n  // If we are given the --check_for_leaks command line flag, installs the\n  // leak checker.\n  if (check_for_leaks) {\n    TestEventListeners& listeners = UnitTest::GetInstance()->listeners();\n\n    // Adds the leak checker to the end of the test event listener list,\n    // after the default text output printer and the default XML report\n    // generator.\n    //\n    // The order is important - it ensures that failures generated in the\n    // leak checker's OnTestEnd() method are processed by the text and XML\n    // printers *before* their OnTestEnd() methods are called, such that\n    // they are attributed to the right test. Remember that a listener\n    // receives an OnXyzStart event *after* listeners preceding it in the\n    // list received that event, and receives an OnXyzEnd event *before*\n    // listeners preceding it.\n    //\n    // We don't need to worry about deleting the new listener later, as\n    // Google Test will do it.\n    listeners.Append(new LeakChecker);\n  }\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample1_unittest.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n\n// This sample shows how to write a simple unit test for a function,\n// using Google C++ testing framework.\n//\n// Writing a unit test using Google C++ testing framework is easy as 1-2-3:\n\n\n// Step 1. Include necessary header files such that the stuff your\n// test logic needs is declared.\n//\n// Don't forget gtest.h, which declares the testing framework.\n\n#include <limits.h>\n#include \"sample1.h\"\n#include \"gtest/gtest.h\"\n\n\n// Step 2. Use the TEST macro to define your tests.\n//\n// TEST has two parameters: the test case name and the test name.\n// After using the macro, you should define your test logic between a\n// pair of braces.  You can use a bunch of macros to indicate the\n// success or failure of a test.  EXPECT_TRUE and EXPECT_EQ are\n// examples of such macros.  For a complete list, see gtest.h.\n//\n// <TechnicalDetails>\n//\n// In Google Test, tests are grouped into test cases.  This is how we\n// keep test code organized.  You should put logically related tests\n// into the same test case.\n//\n// The test case name and the test name should both be valid C++\n// identifiers.  And you should not use underscore (_) in the names.\n//\n// Google Test guarantees that each test you define is run exactly\n// once, but it makes no guarantee on the order the tests are\n// executed.  Therefore, you should write your tests in such a way\n// that their results don't depend on their order.\n//\n// </TechnicalDetails>\n\n\n// Tests Factorial().\n\n// Tests factorial of negative numbers.\nTEST(FactorialTest, Negative) {\n  // This test is named \"Negative\", and belongs to the \"FactorialTest\"\n  // test case.\n  EXPECT_EQ(1, Factorial(-5));\n  EXPECT_EQ(1, Factorial(-1));\n  EXPECT_GT(Factorial(-10), 0);\n\n  // <TechnicalDetails>\n  //\n  // EXPECT_EQ(expected, actual) is the same as\n  //\n  //   EXPECT_TRUE((expected) == (actual))\n  //\n  // except that it will print both the expected value and the actual\n  // value when the assertion fails.  This is very helpful for\n  // debugging.  Therefore in this case EXPECT_EQ is preferred.\n  //\n  // On the other hand, EXPECT_TRUE accepts any Boolean expression,\n  // and is thus more general.\n  //\n  // </TechnicalDetails>\n}\n\n// Tests factorial of 0.\nTEST(FactorialTest, Zero) {\n  EXPECT_EQ(1, Factorial(0));\n}\n\n// Tests factorial of positive numbers.\nTEST(FactorialTest, Positive) {\n  EXPECT_EQ(1, Factorial(1));\n  EXPECT_EQ(2, Factorial(2));\n  EXPECT_EQ(6, Factorial(3));\n  EXPECT_EQ(40320, Factorial(8));\n}\n\n\n// Tests IsPrime()\n\n// Tests negative input.\nTEST(IsPrimeTest, Negative) {\n  // This test belongs to the IsPrimeTest test case.\n\n  EXPECT_FALSE(IsPrime(-1));\n  EXPECT_FALSE(IsPrime(-2));\n  EXPECT_FALSE(IsPrime(INT_MIN));\n}\n\n// Tests some trivial cases.\nTEST(IsPrimeTest, Trivial) {\n  EXPECT_FALSE(IsPrime(0));\n  EXPECT_FALSE(IsPrime(1));\n  EXPECT_TRUE(IsPrime(2));\n  EXPECT_TRUE(IsPrime(3));\n}\n\n// Tests positive input.\nTEST(IsPrimeTest, Positive) {\n  EXPECT_FALSE(IsPrime(4));\n  EXPECT_TRUE(IsPrime(5));\n  EXPECT_FALSE(IsPrime(6));\n  EXPECT_TRUE(IsPrime(23));\n}\n\n// Step 3. Call RUN_ALL_TESTS() in main().\n//\n// We do this by linking in src/gtest_main.cc file, which consists of\n// a main() function which calls RUN_ALL_TESTS() for us.\n//\n// This runs all the tests you've defined, prints the result, and\n// returns 0 if successful, or 1 otherwise.\n//\n// Did you notice that we didn't register the tests?  The\n// RUN_ALL_TESTS() macro magically knows about all the tests we\n// defined.  Isn't this convenient?\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample2.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"sample2.h\"\n\n#include <string.h>\n\n// Clones a 0-terminated C string, allocating memory using new.\nconst char* MyString::CloneCString(const char* a_c_string) {\n  if (a_c_string == NULL) return NULL;\n\n  const size_t len = strlen(a_c_string);\n  char* const clone = new char[ len + 1 ];\n  memcpy(clone, a_c_string, len + 1);\n\n  return clone;\n}\n\n// Sets the 0-terminated C string this MyString object\n// represents.\nvoid MyString::Set(const char* a_c_string) {\n  // Makes sure this works when c_string == c_string_\n  const char* const temp = MyString::CloneCString(a_c_string);\n  delete[] c_string_;\n  c_string_ = temp;\n}\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample2.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#ifndef GTEST_SAMPLES_SAMPLE2_H_\n#define GTEST_SAMPLES_SAMPLE2_H_\n\n#include <string.h>\n\n\n// A simple string class.\nclass MyString {\n private:\n  const char* c_string_;\n  const MyString& operator=(const MyString& rhs);\n\n public:\n  // Clones a 0-terminated C string, allocating memory using new.\n  static const char* CloneCString(const char* a_c_string);\n\n  ////////////////////////////////////////////////////////////\n  //\n  // C'tors\n\n  // The default c'tor constructs a NULL string.\n  MyString() : c_string_(NULL) {}\n\n  // Constructs a MyString by cloning a 0-terminated C string.\n  explicit MyString(const char* a_c_string) : c_string_(NULL) {\n    Set(a_c_string);\n  }\n\n  // Copy c'tor\n  MyString(const MyString& string) : c_string_(NULL) {\n    Set(string.c_string_);\n  }\n\n  ////////////////////////////////////////////////////////////\n  //\n  // D'tor.  MyString is intended to be a final class, so the d'tor\n  // doesn't need to be virtual.\n  ~MyString() { delete[] c_string_; }\n\n  // Gets the 0-terminated C string this MyString object represents.\n  const char* c_string() const { return c_string_; }\n\n  size_t Length() const {\n    return c_string_ == NULL ? 0 : strlen(c_string_);\n  }\n\n  // Sets the 0-terminated C string this MyString object represents.\n  void Set(const char* c_string);\n};\n\n\n#endif  // GTEST_SAMPLES_SAMPLE2_H_\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample2_unittest.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n\n// This sample shows how to write a more complex unit test for a class\n// that has multiple member functions.\n//\n// Usually, it's a good idea to have one test for each method in your\n// class.  You don't have to do that exactly, but it helps to keep\n// your tests organized.  You may also throw in additional tests as\n// needed.\n\n#include \"sample2.h\"\n#include \"gtest/gtest.h\"\n\n// In this example, we test the MyString class (a simple string).\n\n// Tests the default c'tor.\nTEST(MyString, DefaultConstructor) {\n  const MyString s;\n\n  // Asserts that s.c_string() returns NULL.\n  //\n  // <TechnicalDetails>\n  //\n  // If we write NULL instead of\n  //\n  //   static_cast<const char *>(NULL)\n  //\n  // in this assertion, it will generate a warning on gcc 3.4.  The\n  // reason is that EXPECT_EQ needs to know the types of its\n  // arguments in order to print them when it fails.  Since NULL is\n  // #defined as 0, the compiler will use the formatter function for\n  // int to print it.  However, gcc thinks that NULL should be used as\n  // a pointer, not an int, and therefore complains.\n  //\n  // The root of the problem is C++'s lack of distinction between the\n  // integer number 0 and the null pointer constant.  Unfortunately,\n  // we have to live with this fact.\n  //\n  // </TechnicalDetails>\n  EXPECT_STREQ(NULL, s.c_string());\n\n  EXPECT_EQ(0u, s.Length());\n}\n\nconst char kHelloString[] = \"Hello, world!\";\n\n// Tests the c'tor that accepts a C string.\nTEST(MyString, ConstructorFromCString) {\n  const MyString s(kHelloString);\n  EXPECT_EQ(0, strcmp(s.c_string(), kHelloString));\n  EXPECT_EQ(sizeof(kHelloString)/sizeof(kHelloString[0]) - 1,\n            s.Length());\n}\n\n// Tests the copy c'tor.\nTEST(MyString, CopyConstructor) {\n  const MyString s1(kHelloString);\n  const MyString s2 = s1;\n  EXPECT_EQ(0, strcmp(s2.c_string(), kHelloString));\n}\n\n// Tests the Set method.\nTEST(MyString, Set) {\n  MyString s;\n\n  s.Set(kHelloString);\n  EXPECT_EQ(0, strcmp(s.c_string(), kHelloString));\n\n  // Set should work when the input pointer is the same as the one\n  // already in the MyString object.\n  s.Set(s.c_string());\n  EXPECT_EQ(0, strcmp(s.c_string(), kHelloString));\n\n  // Can we set the MyString to NULL?\n  s.Set(NULL);\n  EXPECT_STREQ(NULL, s.c_string());\n}\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample3-inl.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#ifndef GTEST_SAMPLES_SAMPLE3_INL_H_\n#define GTEST_SAMPLES_SAMPLE3_INL_H_\n\n#include <stddef.h>\n\n\n// Queue is a simple queue implemented as a singled-linked list.\n//\n// The element type must support copy constructor.\ntemplate <typename E>  // E is the element type\nclass Queue;\n\n// QueueNode is a node in a Queue, which consists of an element of\n// type E and a pointer to the next node.\ntemplate <typename E>  // E is the element type\nclass QueueNode {\n  friend class Queue<E>;\n\n public:\n  // Gets the element in this node.\n  const E& element() const { return element_; }\n\n  // Gets the next node in the queue.\n  QueueNode* next() { return next_; }\n  const QueueNode* next() const { return next_; }\n\n private:\n  // Creates a node with a given element value.  The next pointer is\n  // set to NULL.\n  explicit QueueNode(const E& an_element) : element_(an_element), next_(NULL) {}\n\n  // We disable the default assignment operator and copy c'tor.\n  const QueueNode& operator = (const QueueNode&);\n  QueueNode(const QueueNode&);\n\n  E element_;\n  QueueNode* next_;\n};\n\ntemplate <typename E>  // E is the element type.\nclass Queue {\n public:\n  // Creates an empty queue.\n  Queue() : head_(NULL), last_(NULL), size_(0) {}\n\n  // D'tor.  Clears the queue.\n  ~Queue() { Clear(); }\n\n  // Clears the queue.\n  void Clear() {\n    if (size_ > 0) {\n      // 1. Deletes every node.\n      QueueNode<E>* node = head_;\n      QueueNode<E>* next = node->next();\n      for (; ;) {\n        delete node;\n        node = next;\n        if (node == NULL) break;\n        next = node->next();\n      }\n\n      // 2. Resets the member variables.\n      head_ = last_ = NULL;\n      size_ = 0;\n    }\n  }\n\n  // Gets the number of elements.\n  size_t Size() const { return size_; }\n\n  // Gets the first element of the queue, or NULL if the queue is empty.\n  QueueNode<E>* Head() { return head_; }\n  const QueueNode<E>* Head() const { return head_; }\n\n  // Gets the last element of the queue, or NULL if the queue is empty.\n  QueueNode<E>* Last() { return last_; }\n  const QueueNode<E>* Last() const { return last_; }\n\n  // Adds an element to the end of the queue.  A copy of the element is\n  // created using the copy constructor, and then stored in the queue.\n  // Changes made to the element in the queue doesn't affect the source\n  // object, and vice versa.\n  void Enqueue(const E& element) {\n    QueueNode<E>* new_node = new QueueNode<E>(element);\n\n    if (size_ == 0) {\n      head_ = last_ = new_node;\n      size_ = 1;\n    } else {\n      last_->next_ = new_node;\n      last_ = new_node;\n      size_++;\n    }\n  }\n\n  // Removes the head of the queue and returns it.  Returns NULL if\n  // the queue is empty.\n  E* Dequeue() {\n    if (size_ == 0) {\n      return NULL;\n    }\n\n    const QueueNode<E>* const old_head = head_;\n    head_ = head_->next_;\n    size_--;\n    if (size_ == 0) {\n      last_ = NULL;\n    }\n\n    E* element = new E(old_head->element());\n    delete old_head;\n\n    return element;\n  }\n\n  // Applies a function/functor on each element of the queue, and\n  // returns the result in a new queue.  The original queue is not\n  // affected.\n  template <typename F>\n  Queue* Map(F function) const {\n    Queue* new_queue = new Queue();\n    for (const QueueNode<E>* node = head_; node != NULL; node = node->next_) {\n      new_queue->Enqueue(function(node->element()));\n    }\n\n    return new_queue;\n  }\n\n private:\n  QueueNode<E>* head_;  // The first node of the queue.\n  QueueNode<E>* last_;  // The last node of the queue.\n  size_t size_;  // The number of elements in the queue.\n\n  // We disallow copying a queue.\n  Queue(const Queue&);\n  const Queue& operator = (const Queue&);\n};\n\n#endif  // GTEST_SAMPLES_SAMPLE3_INL_H_\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample3_unittest.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n\n// In this example, we use a more advanced feature of Google Test called\n// test fixture.\n//\n// A test fixture is a place to hold objects and functions shared by\n// all tests in a test case.  Using a test fixture avoids duplicating\n// the test code necessary to initialize and cleanup those common\n// objects for each test.  It is also useful for defining sub-routines\n// that your tests need to invoke a lot.\n//\n// <TechnicalDetails>\n//\n// The tests share the test fixture in the sense of code sharing, not\n// data sharing.  Each test is given its own fresh copy of the\n// fixture.  You cannot expect the data modified by one test to be\n// passed on to another test, which is a bad idea.\n//\n// The reason for this design is that tests should be independent and\n// repeatable.  In particular, a test should not fail as the result of\n// another test's failure.  If one test depends on info produced by\n// another test, then the two tests should really be one big test.\n//\n// The macros for indicating the success/failure of a test\n// (EXPECT_TRUE, FAIL, etc) need to know what the current test is\n// (when Google Test prints the test result, it tells you which test\n// each failure belongs to).  Technically, these macros invoke a\n// member function of the Test class.  Therefore, you cannot use them\n// in a global function.  That's why you should put test sub-routines\n// in a test fixture.\n//\n// </TechnicalDetails>\n\n#include \"sample3-inl.h\"\n#include \"gtest/gtest.h\"\n\n// To use a test fixture, derive a class from testing::Test.\nclass QueueTest : public testing::Test {\n protected:  // You should make the members protected s.t. they can be\n             // accessed from sub-classes.\n\n  // virtual void SetUp() will be called before each test is run.  You\n  // should define it if you need to initialize the varaibles.\n  // Otherwise, this can be skipped.\n  virtual void SetUp() {\n    q1_.Enqueue(1);\n    q2_.Enqueue(2);\n    q2_.Enqueue(3);\n  }\n\n  // virtual void TearDown() will be called after each test is run.\n  // You should define it if there is cleanup work to do.  Otherwise,\n  // you don't have to provide it.\n  //\n  // virtual void TearDown() {\n  // }\n\n  // A helper function that some test uses.\n  static int Double(int n) {\n    return 2*n;\n  }\n\n  // A helper function for testing Queue::Map().\n  void MapTester(const Queue<int> * q) {\n    // Creates a new queue, where each element is twice as big as the\n    // corresponding one in q.\n    const Queue<int> * const new_q = q->Map(Double);\n\n    // Verifies that the new queue has the same size as q.\n    ASSERT_EQ(q->Size(), new_q->Size());\n\n    // Verifies the relationship between the elements of the two queues.\n    for ( const QueueNode<int> * n1 = q->Head(), * n2 = new_q->Head();\n          n1 != NULL; n1 = n1->next(), n2 = n2->next() ) {\n      EXPECT_EQ(2 * n1->element(), n2->element());\n    }\n\n    delete new_q;\n  }\n\n  // Declares the variables your tests want to use.\n  Queue<int> q0_;\n  Queue<int> q1_;\n  Queue<int> q2_;\n};\n\n// When you have a test fixture, you define a test using TEST_F\n// instead of TEST.\n\n// Tests the default c'tor.\nTEST_F(QueueTest, DefaultConstructor) {\n  // You can access data in the test fixture here.\n  EXPECT_EQ(0u, q0_.Size());\n}\n\n// Tests Dequeue().\nTEST_F(QueueTest, Dequeue) {\n  int * n = q0_.Dequeue();\n  EXPECT_TRUE(n == NULL);\n\n  n = q1_.Dequeue();\n  ASSERT_TRUE(n != NULL);\n  EXPECT_EQ(1, *n);\n  EXPECT_EQ(0u, q1_.Size());\n  delete n;\n\n  n = q2_.Dequeue();\n  ASSERT_TRUE(n != NULL);\n  EXPECT_EQ(2, *n);\n  EXPECT_EQ(1u, q2_.Size());\n  delete n;\n}\n\n// Tests the Queue::Map() function.\nTEST_F(QueueTest, Map) {\n  MapTester(&q0_);\n  MapTester(&q1_);\n  MapTester(&q2_);\n}\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample4.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include <stdio.h>\n\n#include \"sample4.h\"\n\n// Returns the current counter value, and increments it.\nint Counter::Increment() {\n  return counter_++;\n}\n\n// Prints the current counter value to STDOUT.\nvoid Counter::Print() const {\n  printf(\"%d\", counter_);\n}\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample4.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#ifndef GTEST_SAMPLES_SAMPLE4_H_\n#define GTEST_SAMPLES_SAMPLE4_H_\n\n// A simple monotonic counter.\nclass Counter {\n private:\n  int counter_;\n\n public:\n  // Creates a counter that starts at 0.\n  Counter() : counter_(0) {}\n\n  // Returns the current counter value, and increments it.\n  int Increment();\n\n  // Prints the current counter value to STDOUT.\n  void Print() const;\n};\n\n#endif  // GTEST_SAMPLES_SAMPLE4_H_\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample4_unittest.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/gtest.h\"\n#include \"sample4.h\"\n\n// Tests the Increment() method.\nTEST(Counter, Increment) {\n  Counter c;\n\n  // EXPECT_EQ() evaluates its arguments exactly once, so they\n  // can have side effects.\n\n  EXPECT_EQ(0, c.Increment());\n  EXPECT_EQ(1, c.Increment());\n  EXPECT_EQ(2, c.Increment());\n}\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample5_unittest.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// This sample teaches how to reuse a test fixture in multiple test\n// cases by deriving sub-fixtures from it.\n//\n// When you define a test fixture, you specify the name of the test\n// case that will use this fixture.  Therefore, a test fixture can\n// be used by only one test case.\n//\n// Sometimes, more than one test cases may want to use the same or\n// slightly different test fixtures.  For example, you may want to\n// make sure that all tests for a GUI library don't leak important\n// system resources like fonts and brushes.  In Google Test, you do\n// this by putting the shared logic in a super (as in \"super class\")\n// test fixture, and then have each test case use a fixture derived\n// from this super fixture.\n\n#include <limits.h>\n#include <time.h>\n#include \"sample3-inl.h\"\n#include \"gtest/gtest.h\"\n#include \"sample1.h\"\n\n// In this sample, we want to ensure that every test finishes within\n// ~5 seconds.  If a test takes longer to run, we consider it a\n// failure.\n//\n// We put the code for timing a test in a test fixture called\n// \"QuickTest\".  QuickTest is intended to be the super fixture that\n// other fixtures derive from, therefore there is no test case with\n// the name \"QuickTest\".  This is OK.\n//\n// Later, we will derive multiple test fixtures from QuickTest.\nclass QuickTest : public testing::Test {\n protected:\n  // Remember that SetUp() is run immediately before a test starts.\n  // This is a good place to record the start time.\n  virtual void SetUp() {\n    start_time_ = time(NULL);\n  }\n\n  // TearDown() is invoked immediately after a test finishes.  Here we\n  // check if the test was too slow.\n  virtual void TearDown() {\n    // Gets the time when the test finishes\n    const time_t end_time = time(NULL);\n\n    // Asserts that the test took no more than ~5 seconds.  Did you\n    // know that you can use assertions in SetUp() and TearDown() as\n    // well?\n    EXPECT_TRUE(end_time - start_time_ <= 5) << \"The test took too long.\";\n  }\n\n  // The UTC time (in seconds) when the test starts\n  time_t start_time_;\n};\n\n\n// We derive a fixture named IntegerFunctionTest from the QuickTest\n// fixture.  All tests using this fixture will be automatically\n// required to be quick.\nclass IntegerFunctionTest : public QuickTest {\n  // We don't need any more logic than already in the QuickTest fixture.\n  // Therefore the body is empty.\n};\n\n\n// Now we can write tests in the IntegerFunctionTest test case.\n\n// Tests Factorial()\nTEST_F(IntegerFunctionTest, Factorial) {\n  // Tests factorial of negative numbers.\n  EXPECT_EQ(1, Factorial(-5));\n  EXPECT_EQ(1, Factorial(-1));\n  EXPECT_GT(Factorial(-10), 0);\n\n  // Tests factorial of 0.\n  EXPECT_EQ(1, Factorial(0));\n\n  // Tests factorial of positive numbers.\n  EXPECT_EQ(1, Factorial(1));\n  EXPECT_EQ(2, Factorial(2));\n  EXPECT_EQ(6, Factorial(3));\n  EXPECT_EQ(40320, Factorial(8));\n}\n\n\n// Tests IsPrime()\nTEST_F(IntegerFunctionTest, IsPrime) {\n  // Tests negative input.\n  EXPECT_FALSE(IsPrime(-1));\n  EXPECT_FALSE(IsPrime(-2));\n  EXPECT_FALSE(IsPrime(INT_MIN));\n\n  // Tests some trivial cases.\n  EXPECT_FALSE(IsPrime(0));\n  EXPECT_FALSE(IsPrime(1));\n  EXPECT_TRUE(IsPrime(2));\n  EXPECT_TRUE(IsPrime(3));\n\n  // Tests positive input.\n  EXPECT_FALSE(IsPrime(4));\n  EXPECT_TRUE(IsPrime(5));\n  EXPECT_FALSE(IsPrime(6));\n  EXPECT_TRUE(IsPrime(23));\n}\n\n\n// The next test case (named \"QueueTest\") also needs to be quick, so\n// we derive another fixture from QuickTest.\n//\n// The QueueTest test fixture has some logic and shared objects in\n// addition to what's in QuickTest already.  We define the additional\n// stuff inside the body of the test fixture, as usual.\nclass QueueTest : public QuickTest {\n protected:\n  virtual void SetUp() {\n    // First, we need to set up the super fixture (QuickTest).\n    QuickTest::SetUp();\n\n    // Second, some additional setup for this fixture.\n    q1_.Enqueue(1);\n    q2_.Enqueue(2);\n    q2_.Enqueue(3);\n  }\n\n  // By default, TearDown() inherits the behavior of\n  // QuickTest::TearDown().  As we have no additional cleaning work\n  // for QueueTest, we omit it here.\n  //\n  // virtual void TearDown() {\n  //   QuickTest::TearDown();\n  // }\n\n  Queue<int> q0_;\n  Queue<int> q1_;\n  Queue<int> q2_;\n};\n\n\n// Now, let's write tests using the QueueTest fixture.\n\n// Tests the default constructor.\nTEST_F(QueueTest, DefaultConstructor) {\n  EXPECT_EQ(0u, q0_.Size());\n}\n\n// Tests Dequeue().\nTEST_F(QueueTest, Dequeue) {\n  int* n = q0_.Dequeue();\n  EXPECT_TRUE(n == NULL);\n\n  n = q1_.Dequeue();\n  EXPECT_TRUE(n != NULL);\n  EXPECT_EQ(1, *n);\n  EXPECT_EQ(0u, q1_.Size());\n  delete n;\n\n  n = q2_.Dequeue();\n  EXPECT_TRUE(n != NULL);\n  EXPECT_EQ(2, *n);\n  EXPECT_EQ(1u, q2_.Size());\n  delete n;\n}\n\n// If necessary, you can derive further test fixtures from a derived\n// fixture itself.  For example, you can derive another fixture from\n// QueueTest.  Google Test imposes no limit on how deep the hierarchy\n// can be.  In practice, however, you probably don't want it to be too\n// deep as to be confusing.\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample6_unittest.cc",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// This sample shows how to test common properties of multiple\n// implementations of the same interface (aka interface tests).\n\n// The interface and its implementations are in this header.\n#include \"prime_tables.h\"\n\n#include \"gtest/gtest.h\"\n\n// First, we define some factory functions for creating instances of\n// the implementations.  You may be able to skip this step if all your\n// implementations can be constructed the same way.\n\ntemplate <class T>\nPrimeTable* CreatePrimeTable();\n\ntemplate <>\nPrimeTable* CreatePrimeTable<OnTheFlyPrimeTable>() {\n  return new OnTheFlyPrimeTable;\n}\n\ntemplate <>\nPrimeTable* CreatePrimeTable<PreCalculatedPrimeTable>() {\n  return new PreCalculatedPrimeTable(10000);\n}\n\n// Then we define a test fixture class template.\ntemplate <class T>\nclass PrimeTableTest : public testing::Test {\n protected:\n  // The ctor calls the factory function to create a prime table\n  // implemented by T.\n  PrimeTableTest() : table_(CreatePrimeTable<T>()) {}\n\n  virtual ~PrimeTableTest() { delete table_; }\n\n  // Note that we test an implementation via the base interface\n  // instead of the actual implementation class.  This is important\n  // for keeping the tests close to the real world scenario, where the\n  // implementation is invoked via the base interface.  It avoids\n  // got-yas where the implementation class has a method that shadows\n  // a method with the same name (but slightly different argument\n  // types) in the base interface, for example.\n  PrimeTable* const table_;\n};\n\n#if GTEST_HAS_TYPED_TEST\n\nusing testing::Types;\n\n// Google Test offers two ways for reusing tests for different types.\n// The first is called \"typed tests\".  You should use it if you\n// already know *all* the types you are gonna exercise when you write\n// the tests.\n\n// To write a typed test case, first use\n//\n//   TYPED_TEST_CASE(TestCaseName, TypeList);\n//\n// to declare it and specify the type parameters.  As with TEST_F,\n// TestCaseName must match the test fixture name.\n\n// The list of types we want to test.\ntypedef Types<OnTheFlyPrimeTable, PreCalculatedPrimeTable> Implementations;\n\nTYPED_TEST_CASE(PrimeTableTest, Implementations);\n\n// Then use TYPED_TEST(TestCaseName, TestName) to define a typed test,\n// similar to TEST_F.\nTYPED_TEST(PrimeTableTest, ReturnsFalseForNonPrimes) {\n  // Inside the test body, you can refer to the type parameter by\n  // TypeParam, and refer to the fixture class by TestFixture.  We\n  // don't need them in this example.\n\n  // Since we are in the template world, C++ requires explicitly\n  // writing 'this->' when referring to members of the fixture class.\n  // This is something you have to learn to live with.\n  EXPECT_FALSE(this->table_->IsPrime(-5));\n  EXPECT_FALSE(this->table_->IsPrime(0));\n  EXPECT_FALSE(this->table_->IsPrime(1));\n  EXPECT_FALSE(this->table_->IsPrime(4));\n  EXPECT_FALSE(this->table_->IsPrime(6));\n  EXPECT_FALSE(this->table_->IsPrime(100));\n}\n\nTYPED_TEST(PrimeTableTest, ReturnsTrueForPrimes) {\n  EXPECT_TRUE(this->table_->IsPrime(2));\n  EXPECT_TRUE(this->table_->IsPrime(3));\n  EXPECT_TRUE(this->table_->IsPrime(5));\n  EXPECT_TRUE(this->table_->IsPrime(7));\n  EXPECT_TRUE(this->table_->IsPrime(11));\n  EXPECT_TRUE(this->table_->IsPrime(131));\n}\n\nTYPED_TEST(PrimeTableTest, CanGetNextPrime) {\n  EXPECT_EQ(2, this->table_->GetNextPrime(0));\n  EXPECT_EQ(3, this->table_->GetNextPrime(2));\n  EXPECT_EQ(5, this->table_->GetNextPrime(3));\n  EXPECT_EQ(7, this->table_->GetNextPrime(5));\n  EXPECT_EQ(11, this->table_->GetNextPrime(7));\n  EXPECT_EQ(131, this->table_->GetNextPrime(128));\n}\n\n// That's it!  Google Test will repeat each TYPED_TEST for each type\n// in the type list specified in TYPED_TEST_CASE.  Sit back and be\n// happy that you don't have to define them multiple times.\n\n#endif  // GTEST_HAS_TYPED_TEST\n\n#if GTEST_HAS_TYPED_TEST_P\n\nusing testing::Types;\n\n// Sometimes, however, you don't yet know all the types that you want\n// to test when you write the tests.  For example, if you are the\n// author of an interface and expect other people to implement it, you\n// might want to write a set of tests to make sure each implementation\n// conforms to some basic requirements, but you don't know what\n// implementations will be written in the future.\n//\n// How can you write the tests without committing to the type\n// parameters?  That's what \"type-parameterized tests\" can do for you.\n// It is a bit more involved than typed tests, but in return you get a\n// test pattern that can be reused in many contexts, which is a big\n// win.  Here's how you do it:\n\n// First, define a test fixture class template.  Here we just reuse\n// the PrimeTableTest fixture defined earlier:\n\ntemplate <class T>\nclass PrimeTableTest2 : public PrimeTableTest<T> {\n};\n\n// Then, declare the test case.  The argument is the name of the test\n// fixture, and also the name of the test case (as usual).  The _P\n// suffix is for \"parameterized\" or \"pattern\".\nTYPED_TEST_CASE_P(PrimeTableTest2);\n\n// Next, use TYPED_TEST_P(TestCaseName, TestName) to define a test,\n// similar to what you do with TEST_F.\nTYPED_TEST_P(PrimeTableTest2, ReturnsFalseForNonPrimes) {\n  EXPECT_FALSE(this->table_->IsPrime(-5));\n  EXPECT_FALSE(this->table_->IsPrime(0));\n  EXPECT_FALSE(this->table_->IsPrime(1));\n  EXPECT_FALSE(this->table_->IsPrime(4));\n  EXPECT_FALSE(this->table_->IsPrime(6));\n  EXPECT_FALSE(this->table_->IsPrime(100));\n}\n\nTYPED_TEST_P(PrimeTableTest2, ReturnsTrueForPrimes) {\n  EXPECT_TRUE(this->table_->IsPrime(2));\n  EXPECT_TRUE(this->table_->IsPrime(3));\n  EXPECT_TRUE(this->table_->IsPrime(5));\n  EXPECT_TRUE(this->table_->IsPrime(7));\n  EXPECT_TRUE(this->table_->IsPrime(11));\n  EXPECT_TRUE(this->table_->IsPrime(131));\n}\n\nTYPED_TEST_P(PrimeTableTest2, CanGetNextPrime) {\n  EXPECT_EQ(2, this->table_->GetNextPrime(0));\n  EXPECT_EQ(3, this->table_->GetNextPrime(2));\n  EXPECT_EQ(5, this->table_->GetNextPrime(3));\n  EXPECT_EQ(7, this->table_->GetNextPrime(5));\n  EXPECT_EQ(11, this->table_->GetNextPrime(7));\n  EXPECT_EQ(131, this->table_->GetNextPrime(128));\n}\n\n// Type-parameterized tests involve one extra step: you have to\n// enumerate the tests you defined:\nREGISTER_TYPED_TEST_CASE_P(\n    PrimeTableTest2,  // The first argument is the test case name.\n    // The rest of the arguments are the test names.\n    ReturnsFalseForNonPrimes, ReturnsTrueForPrimes, CanGetNextPrime);\n\n// At this point the test pattern is done.  However, you don't have\n// any real test yet as you haven't said which types you want to run\n// the tests with.\n\n// To turn the abstract test pattern into real tests, you instantiate\n// it with a list of types.  Usually the test pattern will be defined\n// in a .h file, and anyone can #include and instantiate it.  You can\n// even instantiate it more than once in the same program.  To tell\n// different instances apart, you give each of them a name, which will\n// become part of the test case name and can be used in test filters.\n\n// The list of types we want to test.  Note that it doesn't have to be\n// defined at the time we write the TYPED_TEST_P()s.\ntypedef Types<OnTheFlyPrimeTable, PreCalculatedPrimeTable>\n    PrimeTableImplementations;\nINSTANTIATE_TYPED_TEST_CASE_P(OnTheFlyAndPreCalculated,    // Instance name\n                              PrimeTableTest2,             // Test case name\n                              PrimeTableImplementations);  // Type list\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample7_unittest.cc",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// This sample shows how to test common properties of multiple\n// implementations of an interface (aka interface tests) using\n// value-parameterized tests. Each test in the test case has\n// a parameter that is an interface pointer to an implementation\n// tested.\n\n// The interface and its implementations are in this header.\n#include \"prime_tables.h\"\n\n#include \"gtest/gtest.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\nusing ::testing::TestWithParam;\nusing ::testing::Values;\n\n// As a general rule, to prevent a test from affecting the tests that come\n// after it, you should create and destroy the tested objects for each test\n// instead of reusing them.  In this sample we will define a simple factory\n// function for PrimeTable objects.  We will instantiate objects in test's\n// SetUp() method and delete them in TearDown() method.\ntypedef PrimeTable* CreatePrimeTableFunc();\n\nPrimeTable* CreateOnTheFlyPrimeTable() {\n  return new OnTheFlyPrimeTable();\n}\n\ntemplate <size_t max_precalculated>\nPrimeTable* CreatePreCalculatedPrimeTable() {\n  return new PreCalculatedPrimeTable(max_precalculated);\n}\n\n// Inside the test body, fixture constructor, SetUp(), and TearDown() you\n// can refer to the test parameter by GetParam().  In this case, the test\n// parameter is a factory function which we call in fixture's SetUp() to\n// create and store an instance of PrimeTable.\nclass PrimeTableTest : public TestWithParam<CreatePrimeTableFunc*> {\n public:\n  virtual ~PrimeTableTest() { delete table_; }\n  virtual void SetUp() { table_ = (*GetParam())(); }\n  virtual void TearDown() {\n    delete table_;\n    table_ = NULL;\n  }\n\n protected:\n  PrimeTable* table_;\n};\n\nTEST_P(PrimeTableTest, ReturnsFalseForNonPrimes) {\n  EXPECT_FALSE(table_->IsPrime(-5));\n  EXPECT_FALSE(table_->IsPrime(0));\n  EXPECT_FALSE(table_->IsPrime(1));\n  EXPECT_FALSE(table_->IsPrime(4));\n  EXPECT_FALSE(table_->IsPrime(6));\n  EXPECT_FALSE(table_->IsPrime(100));\n}\n\nTEST_P(PrimeTableTest, ReturnsTrueForPrimes) {\n  EXPECT_TRUE(table_->IsPrime(2));\n  EXPECT_TRUE(table_->IsPrime(3));\n  EXPECT_TRUE(table_->IsPrime(5));\n  EXPECT_TRUE(table_->IsPrime(7));\n  EXPECT_TRUE(table_->IsPrime(11));\n  EXPECT_TRUE(table_->IsPrime(131));\n}\n\nTEST_P(PrimeTableTest, CanGetNextPrime) {\n  EXPECT_EQ(2, table_->GetNextPrime(0));\n  EXPECT_EQ(3, table_->GetNextPrime(2));\n  EXPECT_EQ(5, table_->GetNextPrime(3));\n  EXPECT_EQ(7, table_->GetNextPrime(5));\n  EXPECT_EQ(11, table_->GetNextPrime(7));\n  EXPECT_EQ(131, table_->GetNextPrime(128));\n}\n\n// In order to run value-parameterized tests, you need to instantiate them,\n// or bind them to a list of values which will be used as test parameters.\n// You can instantiate them in a different translation module, or even\n// instantiate them several times.\n//\n// Here, we instantiate our tests with a list of two PrimeTable object\n// factory functions:\nINSTANTIATE_TEST_CASE_P(\n    OnTheFlyAndPreCalculated,\n    PrimeTableTest,\n    Values(&CreateOnTheFlyPrimeTable, &CreatePreCalculatedPrimeTable<1000>));\n\n#else\n\n// Google Test may not support value-parameterized tests with some\n// compilers. If we use conditional compilation to compile out all\n// code referring to the gtest_main library, MSVC linker will not link\n// that library at all and consequently complain about missing entry\n// point defined in that library (fatal error LNK1561: entry point\n// must be defined). This dummy test keeps gtest_main linked in.\nTEST(DummyTest, ValueParameterizedTestsAreNotSupportedOnThisPlatform) {}\n\n#endif  // GTEST_HAS_PARAM_TEST\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample8_unittest.cc",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// This sample shows how to test code relying on some global flag variables.\n// Combine() helps with generating all possible combinations of such flags,\n// and each test is given one combination as a parameter.\n\n// Use class definitions to test from this header.\n#include \"prime_tables.h\"\n\n#include \"gtest/gtest.h\"\n\n#if GTEST_HAS_COMBINE\n\n// Suppose we want to introduce a new, improved implementation of PrimeTable\n// which combines speed of PrecalcPrimeTable and versatility of\n// OnTheFlyPrimeTable (see prime_tables.h). Inside it instantiates both\n// PrecalcPrimeTable and OnTheFlyPrimeTable and uses the one that is more\n// appropriate under the circumstances. But in low memory conditions, it can be\n// told to instantiate without PrecalcPrimeTable instance at all and use only\n// OnTheFlyPrimeTable.\nclass HybridPrimeTable : public PrimeTable {\n public:\n  HybridPrimeTable(bool force_on_the_fly, int max_precalculated)\n      : on_the_fly_impl_(new OnTheFlyPrimeTable),\n        precalc_impl_(force_on_the_fly ? NULL :\n                          new PreCalculatedPrimeTable(max_precalculated)),\n        max_precalculated_(max_precalculated) {}\n  virtual ~HybridPrimeTable() {\n    delete on_the_fly_impl_;\n    delete precalc_impl_;\n  }\n\n  virtual bool IsPrime(int n) const {\n    if (precalc_impl_ != NULL && n < max_precalculated_)\n      return precalc_impl_->IsPrime(n);\n    else\n      return on_the_fly_impl_->IsPrime(n);\n  }\n\n  virtual int GetNextPrime(int p) const {\n    int next_prime = -1;\n    if (precalc_impl_ != NULL && p < max_precalculated_)\n      next_prime = precalc_impl_->GetNextPrime(p);\n\n    return next_prime != -1 ? next_prime : on_the_fly_impl_->GetNextPrime(p);\n  }\n\n private:\n  OnTheFlyPrimeTable* on_the_fly_impl_;\n  PreCalculatedPrimeTable* precalc_impl_;\n  int max_precalculated_;\n};\n\nusing ::testing::TestWithParam;\nusing ::testing::Bool;\nusing ::testing::Values;\nusing ::testing::Combine;\n\n// To test all code paths for HybridPrimeTable we must test it with numbers\n// both within and outside PreCalculatedPrimeTable's capacity and also with\n// PreCalculatedPrimeTable disabled. We do this by defining fixture which will\n// accept different combinations of parameters for instantiating a\n// HybridPrimeTable instance.\nclass PrimeTableTest : public TestWithParam< ::testing::tuple<bool, int> > {\n protected:\n  virtual void SetUp() {\n    // This can be written as\n    //\n    // bool force_on_the_fly;\n    // int max_precalculated;\n    // tie(force_on_the_fly, max_precalculated) = GetParam();\n    //\n    // once the Google C++ Style Guide allows use of ::std::tr1::tie.\n    //\n    bool force_on_the_fly = ::testing::get<0>(GetParam());\n    int max_precalculated = ::testing::get<1>(GetParam());\n    table_ = new HybridPrimeTable(force_on_the_fly, max_precalculated);\n  }\n  virtual void TearDown() {\n    delete table_;\n    table_ = NULL;\n  }\n  HybridPrimeTable* table_;\n};\n\nTEST_P(PrimeTableTest, ReturnsFalseForNonPrimes) {\n  // Inside the test body, you can refer to the test parameter by GetParam().\n  // In this case, the test parameter is a PrimeTable interface pointer which\n  // we can use directly.\n  // Please note that you can also save it in the fixture's SetUp() method\n  // or constructor and use saved copy in the tests.\n\n  EXPECT_FALSE(table_->IsPrime(-5));\n  EXPECT_FALSE(table_->IsPrime(0));\n  EXPECT_FALSE(table_->IsPrime(1));\n  EXPECT_FALSE(table_->IsPrime(4));\n  EXPECT_FALSE(table_->IsPrime(6));\n  EXPECT_FALSE(table_->IsPrime(100));\n}\n\nTEST_P(PrimeTableTest, ReturnsTrueForPrimes) {\n  EXPECT_TRUE(table_->IsPrime(2));\n  EXPECT_TRUE(table_->IsPrime(3));\n  EXPECT_TRUE(table_->IsPrime(5));\n  EXPECT_TRUE(table_->IsPrime(7));\n  EXPECT_TRUE(table_->IsPrime(11));\n  EXPECT_TRUE(table_->IsPrime(131));\n}\n\nTEST_P(PrimeTableTest, CanGetNextPrime) {\n  EXPECT_EQ(2, table_->GetNextPrime(0));\n  EXPECT_EQ(3, table_->GetNextPrime(2));\n  EXPECT_EQ(5, table_->GetNextPrime(3));\n  EXPECT_EQ(7, table_->GetNextPrime(5));\n  EXPECT_EQ(11, table_->GetNextPrime(7));\n  EXPECT_EQ(131, table_->GetNextPrime(128));\n}\n\n// In order to run value-parameterized tests, you need to instantiate them,\n// or bind them to a list of values which will be used as test parameters.\n// You can instantiate them in a different translation module, or even\n// instantiate them several times.\n//\n// Here, we instantiate our tests with a list of parameters. We must combine\n// all variations of the boolean flag suppressing PrecalcPrimeTable and some\n// meaningful values for tests. We choose a small value (1), and a value that\n// will put some of the tested numbers beyond the capability of the\n// PrecalcPrimeTable instance and some inside it (10). Combine will produce all\n// possible combinations.\nINSTANTIATE_TEST_CASE_P(MeaningfulTestParameters,\n                        PrimeTableTest,\n                        Combine(Bool(), Values(1, 10)));\n\n#else\n\n// Google Test may not support Combine() with some compilers. If we\n// use conditional compilation to compile out all code referring to\n// the gtest_main library, MSVC linker will not link that library at\n// all and consequently complain about missing entry point defined in\n// that library (fatal error LNK1561: entry point must be\n// defined). This dummy test keeps gtest_main linked in.\nTEST(DummyTest, CombineIsNotSupportedOnThisPlatform) {}\n\n#endif  // GTEST_HAS_COMBINE\n"
  },
  {
    "path": "utils/googletest/googletest/samples/sample9_unittest.cc",
    "content": "// Copyright 2009 Google Inc. All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// This sample shows how to use Google Test listener API to implement\n// an alternative console output and how to use the UnitTest reflection API\n// to enumerate test cases and tests and to inspect their results.\n\n#include <stdio.h>\n\n#include \"gtest/gtest.h\"\n\nusing ::testing::EmptyTestEventListener;\nusing ::testing::InitGoogleTest;\nusing ::testing::Test;\nusing ::testing::TestCase;\nusing ::testing::TestEventListeners;\nusing ::testing::TestInfo;\nusing ::testing::TestPartResult;\nusing ::testing::UnitTest;\n\nnamespace {\n\n// Provides alternative output mode which produces minimal amount of\n// information about tests.\nclass TersePrinter : public EmptyTestEventListener {\n private:\n  // Called before any test activity starts.\n  virtual void OnTestProgramStart(const UnitTest& /* unit_test */) {}\n\n  // Called after all test activities have ended.\n  virtual void OnTestProgramEnd(const UnitTest& unit_test) {\n    fprintf(stdout, \"TEST %s\\n\", unit_test.Passed() ? \"PASSED\" : \"FAILED\");\n    fflush(stdout);\n  }\n\n  // Called before a test starts.\n  virtual void OnTestStart(const TestInfo& test_info) {\n    fprintf(stdout,\n            \"*** Test %s.%s starting.\\n\",\n            test_info.test_case_name(),\n            test_info.name());\n    fflush(stdout);\n  }\n\n  // Called after a failed assertion or a SUCCEED() invocation.\n  virtual void OnTestPartResult(const TestPartResult& test_part_result) {\n    fprintf(stdout,\n            \"%s in %s:%d\\n%s\\n\",\n            test_part_result.failed() ? \"*** Failure\" : \"Success\",\n            test_part_result.file_name(),\n            test_part_result.line_number(),\n            test_part_result.summary());\n    fflush(stdout);\n  }\n\n  // Called after a test ends.\n  virtual void OnTestEnd(const TestInfo& test_info) {\n    fprintf(stdout,\n            \"*** Test %s.%s ending.\\n\",\n            test_info.test_case_name(),\n            test_info.name());\n    fflush(stdout);\n  }\n};  // class TersePrinter\n\nTEST(CustomOutputTest, PrintsMessage) {\n  printf(\"Printing something from the test body...\\n\");\n}\n\nTEST(CustomOutputTest, Succeeds) {\n  SUCCEED() << \"SUCCEED() has been invoked from here\";\n}\n\nTEST(CustomOutputTest, Fails) {\n  EXPECT_EQ(1, 2)\n      << \"This test fails in order to demonstrate alternative failure messages\";\n}\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  InitGoogleTest(&argc, argv);\n\n  bool terse_output = false;\n  if (argc > 1 && strcmp(argv[1], \"--terse_output\") == 0 )\n    terse_output = true;\n  else\n    printf(\"%s\\n\", \"Run this program with --terse_output to change the way \"\n           \"it prints its output.\");\n\n  UnitTest& unit_test = *UnitTest::GetInstance();\n\n  // If we are given the --terse_output command line flag, suppresses the\n  // standard output and attaches own result printer.\n  if (terse_output) {\n    TestEventListeners& listeners = unit_test.listeners();\n\n    // Removes the default console output listener from the list so it will\n    // not receive events from Google Test and won't print any output. Since\n    // this operation transfers ownership of the listener to the caller we\n    // have to delete it as well.\n    delete listeners.Release(listeners.default_result_printer());\n\n    // Adds the custom output listener to the list. It will now receive\n    // events from Google Test and print the alternative output. We don't\n    // have to worry about deleting it since Google Test assumes ownership\n    // over it after adding it to the list.\n    listeners.Append(new TersePrinter);\n  }\n  int ret_val = RUN_ALL_TESTS();\n\n  // This is an example of using the UnitTest reflection API to inspect test\n  // results. Here we discount failures from the tests we expected to fail.\n  int unexpectedly_failed_tests = 0;\n  for (int i = 0; i < unit_test.total_test_case_count(); ++i) {\n    const TestCase& test_case = *unit_test.GetTestCase(i);\n    for (int j = 0; j < test_case.total_test_count(); ++j) {\n      const TestInfo& test_info = *test_case.GetTestInfo(j);\n      // Counts failed tests that were not meant to fail (those without\n      // 'Fails' in the name).\n      if (test_info.result()->Failed() &&\n          strcmp(test_info.name(), \"Fails\") != 0) {\n        unexpectedly_failed_tests++;\n      }\n    }\n  }\n\n  // Test that were meant to fail should not affect the test program outcome.\n  if (unexpectedly_failed_tests == 0)\n    ret_val = 0;\n\n  return ret_val;\n}\n"
  },
  {
    "path": "utils/googletest/googletest/scripts/common.py",
    "content": "# Copyright 2013 Google Inc. All Rights Reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Shared utilities for writing scripts for Google Test/Mock.\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\n\nimport os\nimport re\n\n\n# Matches the line from 'svn info .' output that describes what SVN\n# path the current local directory corresponds to.  For example, in\n# a googletest SVN workspace's trunk/test directory, the output will be:\n#\n# URL: https://googletest.googlecode.com/svn/trunk/test\n_SVN_INFO_URL_RE = re.compile(r'^URL: https://(\\w+)\\.googlecode\\.com/svn(.*)')\n\n\ndef GetCommandOutput(command):\n  \"\"\"Runs the shell command and returns its stdout as a list of lines.\"\"\"\n\n  f = os.popen(command, 'r')\n  lines = [line.strip() for line in f.readlines()]\n  f.close()\n  return lines\n\n\ndef GetSvnInfo():\n  \"\"\"Returns the project name and the current SVN workspace's root path.\"\"\"\n\n  for line in GetCommandOutput('svn info .'):\n    m = _SVN_INFO_URL_RE.match(line)\n    if m:\n      project = m.group(1)  # googletest or googlemock\n      rel_path = m.group(2)\n      root = os.path.realpath(rel_path.count('/') * '../')\n      return project, root\n\n  return None, None\n\n\ndef GetSvnTrunk():\n  \"\"\"Returns the current SVN workspace's trunk root path.\"\"\"\n\n  _, root = GetSvnInfo()\n  return root + '/trunk' if root else None\n\n\ndef IsInGTestSvn():\n  project, _ = GetSvnInfo()\n  return project == 'googletest'\n\n\ndef IsInGMockSvn():\n  project, _ = GetSvnInfo()\n  return project == 'googlemock'\n"
  },
  {
    "path": "utils/googletest/googletest/scripts/fuse_gtest_files.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2009, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"fuse_gtest_files.py v0.2.0\nFuses Google Test source code into a .h file and a .cc file.\n\nSYNOPSIS\n       fuse_gtest_files.py [GTEST_ROOT_DIR] OUTPUT_DIR\n\n       Scans GTEST_ROOT_DIR for Google Test source code, and generates\n       two files: OUTPUT_DIR/gtest/gtest.h and OUTPUT_DIR/gtest/gtest-all.cc.\n       Then you can build your tests by adding OUTPUT_DIR to the include\n       search path and linking with OUTPUT_DIR/gtest/gtest-all.cc.  These\n       two files contain everything you need to use Google Test.  Hence\n       you can \"install\" Google Test by copying them to wherever you want.\n\n       GTEST_ROOT_DIR can be omitted and defaults to the parent\n       directory of the directory holding this script.\n\nEXAMPLES\n       ./fuse_gtest_files.py fused_gtest\n       ./fuse_gtest_files.py path/to/unpacked/gtest fused_gtest\n\nThis tool is experimental.  In particular, it assumes that there is no\nconditional inclusion of Google Test headers.  Please report any\nproblems to googletestframework@googlegroups.com.  You can read\nhttp://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide for\nmore information.\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport re\ntry:\n  from sets import Set as set  # For Python 2.3 compatibility\nexcept ImportError:\n  pass\nimport sys\n\n# We assume that this file is in the scripts/ directory in the Google\n# Test root directory.\nDEFAULT_GTEST_ROOT_DIR = os.path.join(os.path.dirname(__file__), '..')\n\n# Regex for matching '#include \"gtest/...\"'.\nINCLUDE_GTEST_FILE_REGEX = re.compile(r'^\\s*#\\s*include\\s*\"(gtest/.+)\"')\n\n# Regex for matching '#include \"src/...\"'.\nINCLUDE_SRC_FILE_REGEX = re.compile(r'^\\s*#\\s*include\\s*\"(src/.+)\"')\n\n# Where to find the source seed files.\nGTEST_H_SEED = 'include/gtest/gtest.h'\nGTEST_SPI_H_SEED = 'include/gtest/gtest-spi.h'\nGTEST_ALL_CC_SEED = 'src/gtest-all.cc'\n\n# Where to put the generated files.\nGTEST_H_OUTPUT = 'gtest/gtest.h'\nGTEST_ALL_CC_OUTPUT = 'gtest/gtest-all.cc'\n\n\ndef VerifyFileExists(directory, relative_path):\n  \"\"\"Verifies that the given file exists; aborts on failure.\n\n  relative_path is the file path relative to the given directory.\n  \"\"\"\n\n  if not os.path.isfile(os.path.join(directory, relative_path)):\n    print('ERROR: Cannot find %s in directory %s.' % (relative_path,\n                                                      directory))\n    print('Please either specify a valid project root directory '\n          'or omit it on the command line.')\n    sys.exit(1)\n\n\ndef ValidateGTestRootDir(gtest_root):\n  \"\"\"Makes sure gtest_root points to a valid gtest root directory.\n\n  The function aborts the program on failure.\n  \"\"\"\n\n  VerifyFileExists(gtest_root, GTEST_H_SEED)\n  VerifyFileExists(gtest_root, GTEST_ALL_CC_SEED)\n\n\ndef VerifyOutputFile(output_dir, relative_path):\n  \"\"\"Verifies that the given output file path is valid.\n\n  relative_path is relative to the output_dir directory.\n  \"\"\"\n\n  # Makes sure the output file either doesn't exist or can be overwritten.\n  output_file = os.path.join(output_dir, relative_path)\n  if os.path.exists(output_file):\n    # TODO(wan@google.com): The following user-interaction doesn't\n    # work with automated processes.  We should provide a way for the\n    # Makefile to force overwriting the files.\n    print('%s already exists in directory %s - overwrite it? (y/N) ' %\n          (relative_path, output_dir))\n    answer = sys.stdin.readline().strip()\n    if answer not in ['y', 'Y']:\n      print('ABORTED.')\n      sys.exit(1)\n\n  # Makes sure the directory holding the output file exists; creates\n  # it and all its ancestors if necessary.\n  parent_directory = os.path.dirname(output_file)\n  if not os.path.isdir(parent_directory):\n    os.makedirs(parent_directory)\n\n\ndef ValidateOutputDir(output_dir):\n  \"\"\"Makes sure output_dir points to a valid output directory.\n\n  The function aborts the program on failure.\n  \"\"\"\n\n  VerifyOutputFile(output_dir, GTEST_H_OUTPUT)\n  VerifyOutputFile(output_dir, GTEST_ALL_CC_OUTPUT)\n\n\ndef FuseGTestH(gtest_root, output_dir):\n  \"\"\"Scans folder gtest_root to generate gtest/gtest.h in output_dir.\"\"\"\n\n  output_file = open(os.path.join(output_dir, GTEST_H_OUTPUT), 'w')\n  processed_files = set()  # Holds all gtest headers we've processed.\n\n  def ProcessFile(gtest_header_path):\n    \"\"\"Processes the given gtest header file.\"\"\"\n\n    # We don't process the same header twice.\n    if gtest_header_path in processed_files:\n      return\n\n    processed_files.add(gtest_header_path)\n\n    # Reads each line in the given gtest header.\n    for line in open(os.path.join(gtest_root, gtest_header_path), 'r'):\n      m = INCLUDE_GTEST_FILE_REGEX.match(line)\n      if m:\n        # It's '#include \"gtest/...\"' - let's process it recursively.\n        ProcessFile('include/' + m.group(1))\n      else:\n        # Otherwise we copy the line unchanged to the output file.\n        output_file.write(line)\n\n  ProcessFile(GTEST_H_SEED)\n  output_file.close()\n\n\ndef FuseGTestAllCcToFile(gtest_root, output_file):\n  \"\"\"Scans folder gtest_root to generate gtest/gtest-all.cc in output_file.\"\"\"\n\n  processed_files = set()\n\n  def ProcessFile(gtest_source_file):\n    \"\"\"Processes the given gtest source file.\"\"\"\n\n    # We don't process the same #included file twice.\n    if gtest_source_file in processed_files:\n      return\n\n    processed_files.add(gtest_source_file)\n\n    # Reads each line in the given gtest source file.\n    for line in open(os.path.join(gtest_root, gtest_source_file), 'r'):\n      m = INCLUDE_GTEST_FILE_REGEX.match(line)\n      if m:\n        if 'include/' + m.group(1) == GTEST_SPI_H_SEED:\n          # It's '#include \"gtest/gtest-spi.h\"'.  This file is not\n          # #included by \"gtest/gtest.h\", so we need to process it.\n          ProcessFile(GTEST_SPI_H_SEED)\n        else:\n          # It's '#include \"gtest/foo.h\"' where foo is not gtest-spi.\n          # We treat it as '#include \"gtest/gtest.h\"', as all other\n          # gtest headers are being fused into gtest.h and cannot be\n          # #included directly.\n\n          # There is no need to #include \"gtest/gtest.h\" more than once.\n          if not GTEST_H_SEED in processed_files:\n            processed_files.add(GTEST_H_SEED)\n            output_file.write('#include \"%s\"\\n' % (GTEST_H_OUTPUT,))\n      else:\n        m = INCLUDE_SRC_FILE_REGEX.match(line)\n        if m:\n          # It's '#include \"src/foo\"' - let's process it recursively.\n          ProcessFile(m.group(1))\n        else:\n          output_file.write(line)\n\n  ProcessFile(GTEST_ALL_CC_SEED)\n\n\ndef FuseGTestAllCc(gtest_root, output_dir):\n  \"\"\"Scans folder gtest_root to generate gtest/gtest-all.cc in output_dir.\"\"\"\n\n  output_file = open(os.path.join(output_dir, GTEST_ALL_CC_OUTPUT), 'w')\n  FuseGTestAllCcToFile(gtest_root, output_file)\n  output_file.close()\n\n\ndef FuseGTest(gtest_root, output_dir):\n  \"\"\"Fuses gtest.h and gtest-all.cc.\"\"\"\n\n  ValidateGTestRootDir(gtest_root)\n  ValidateOutputDir(output_dir)\n\n  FuseGTestH(gtest_root, output_dir)\n  FuseGTestAllCc(gtest_root, output_dir)\n\n\ndef main():\n  argc = len(sys.argv)\n  if argc == 2:\n    # fuse_gtest_files.py OUTPUT_DIR\n    FuseGTest(DEFAULT_GTEST_ROOT_DIR, sys.argv[1])\n  elif argc == 3:\n    # fuse_gtest_files.py GTEST_ROOT_DIR OUTPUT_DIR\n    FuseGTest(sys.argv[1], sys.argv[2])\n  else:\n    print(__doc__)\n    sys.exit(1)\n\n\nif __name__ == '__main__':\n  main()\n"
  },
  {
    "path": "utils/googletest/googletest/scripts/gen_gtest_pred_impl.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2006, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"gen_gtest_pred_impl.py v0.1\n\nGenerates the implementation of Google Test predicate assertions and\naccompanying tests.\n\nUsage:\n\n  gen_gtest_pred_impl.py MAX_ARITY\n\nwhere MAX_ARITY is a positive integer.\n\nThe command generates the implementation of up-to MAX_ARITY-ary\npredicate assertions, and writes it to file gtest_pred_impl.h in the\ndirectory where the script is.  It also generates the accompanying\nunit test in file gtest_pred_impl_unittest.cc.\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport sys\nimport time\n\n# Where this script is.\nSCRIPT_DIR = os.path.dirname(sys.argv[0])\n\n# Where to store the generated header.\nHEADER = os.path.join(SCRIPT_DIR, '../include/gtest/gtest_pred_impl.h')\n\n# Where to store the generated unit test.\nUNIT_TEST = os.path.join(SCRIPT_DIR, '../test/gtest_pred_impl_unittest.cc')\n\n\ndef HeaderPreamble(n):\n  \"\"\"Returns the preamble for the header file.\n\n  Args:\n    n:  the maximum arity of the predicate macros to be generated.\n  \"\"\"\n\n  # A map that defines the values used in the preamble template.\n  DEFS = {\n    'today' : time.strftime('%m/%d/%Y'),\n    'year' : time.strftime('%Y'),\n    'command' : '%s %s' % (os.path.basename(sys.argv[0]), n),\n    'n' : n\n    }\n\n  return (\n\"\"\"// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is AUTOMATICALLY GENERATED on %(today)s by command\n// '%(command)s'.  DO NOT EDIT BY HAND!\n//\n// Implements a family of generic predicate assertion macros.\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n#define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n\n// Makes sure this header is not included before gtest.h.\n#ifndef GTEST_INCLUDE_GTEST_GTEST_H_\n# error Do not include gtest_pred_impl.h directly.  Include gtest.h instead.\n#endif  // GTEST_INCLUDE_GTEST_GTEST_H_\n\n// This header implements a family of generic predicate assertion\n// macros:\n//\n//   ASSERT_PRED_FORMAT1(pred_format, v1)\n//   ASSERT_PRED_FORMAT2(pred_format, v1, v2)\n//   ...\n//\n// where pred_format is a function or functor that takes n (in the\n// case of ASSERT_PRED_FORMATn) values and their source expression\n// text, and returns a testing::AssertionResult.  See the definition\n// of ASSERT_EQ in gtest.h for an example.\n//\n// If you don't care about formatting, you can use the more\n// restrictive version:\n//\n//   ASSERT_PRED1(pred, v1)\n//   ASSERT_PRED2(pred, v1, v2)\n//   ...\n//\n// where pred is an n-ary function or functor that returns bool,\n// and the values v1, v2, ..., must support the << operator for\n// streaming to std::ostream.\n//\n// We also define the EXPECT_* variations.\n//\n// For now we only support predicates whose arity is at most %(n)s.\n// Please email googletestframework@googlegroups.com if you need\n// support for higher arities.\n\n// GTEST_ASSERT_ is the basic statement to which all of the assertions\n// in this file reduce.  Don't use this in your code.\n\n#define GTEST_ASSERT_(expression, on_failure) \\\\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\\\n  if (const ::testing::AssertionResult gtest_ar = (expression)) \\\\\n    ; \\\\\n  else \\\\\n    on_failure(gtest_ar.failure_message())\n\"\"\" % DEFS)\n\n\ndef Arity(n):\n  \"\"\"Returns the English name of the given arity.\"\"\"\n\n  if n < 0:\n    return None\n  elif n <= 3:\n    return ['nullary', 'unary', 'binary', 'ternary'][n]\n  else:\n    return '%s-ary' % n\n\n\ndef Title(word):\n  \"\"\"Returns the given word in title case.  The difference between\n  this and string's title() method is that Title('4-ary') is '4-ary'\n  while '4-ary'.title() is '4-Ary'.\"\"\"\n\n  return word[0].upper() + word[1:]\n\n\ndef OneTo(n):\n  \"\"\"Returns the list [1, 2, 3, ..., n].\"\"\"\n\n  return range(1, n + 1)\n\n\ndef Iter(n, format, sep=''):\n  \"\"\"Given a positive integer n, a format string that contains 0 or\n  more '%s' format specs, and optionally a separator string, returns\n  the join of n strings, each formatted with the format string on an\n  iterator ranged from 1 to n.\n\n  Example:\n\n  Iter(3, 'v%s', sep=', ') returns 'v1, v2, v3'.\n  \"\"\"\n\n  # How many '%s' specs are in format?\n  spec_count = len(format.split('%s')) - 1\n  return sep.join([format % (spec_count * (i,)) for i in OneTo(n)])\n\n\ndef ImplementationForArity(n):\n  \"\"\"Returns the implementation of n-ary predicate assertions.\"\"\"\n\n  # A map the defines the values used in the implementation template.\n  DEFS = {\n    'n' : str(n),\n    'vs' : Iter(n, 'v%s', sep=', '),\n    'vts' : Iter(n, '#v%s', sep=', '),\n    'arity' : Arity(n),\n    'Arity' : Title(Arity(n))\n    }\n\n  impl = \"\"\"\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED%(n)s.  Don't use\n// this in your code.\ntemplate <typename Pred\"\"\" % DEFS\n\n  impl += Iter(n, \"\"\",\n          typename T%s\"\"\")\n\n  impl += \"\"\">\nAssertionResult AssertPred%(n)sHelper(const char* pred_text\"\"\" % DEFS\n\n  impl += Iter(n, \"\"\",\n                                  const char* e%s\"\"\")\n\n  impl += \"\"\",\n                                  Pred pred\"\"\"\n\n  impl += Iter(n, \"\"\",\n                                  const T%s& v%s\"\"\")\n\n  impl += \"\"\") {\n  if (pred(%(vs)s)) return AssertionSuccess();\n\n\"\"\" % DEFS\n\n  impl += '  return AssertionFailure() << pred_text << \"(\"'\n\n  impl += Iter(n, \"\"\"\n                            << e%s\"\"\", sep=' << \", \"')\n\n  impl += ' << \") evaluates to false, where\"'\n\n  impl += Iter(n, \"\"\"\n                            << \"\\\\n\" << e%s << \" evaluates to \" << v%s\"\"\")\n\n  impl += \"\"\";\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT%(n)s.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT%(n)s_(pred_format, %(vs)s, on_failure)\\\\\n  GTEST_ASSERT_(pred_format(%(vts)s, %(vs)s), \\\\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED%(n)s.  Don't use\n// this in your code.\n#define GTEST_PRED%(n)s_(pred, %(vs)s, on_failure)\\\\\n  GTEST_ASSERT_(::testing::AssertPred%(n)sHelper(#pred\"\"\" % DEFS\n\n  impl += Iter(n, \"\"\", \\\\\n                                             #v%s\"\"\")\n\n  impl += \"\"\", \\\\\n                                             pred\"\"\"\n\n  impl += Iter(n, \"\"\", \\\\\n                                             v%s\"\"\")\n\n  impl += \"\"\"), on_failure)\n\n// %(Arity)s predicate assertion macros.\n#define EXPECT_PRED_FORMAT%(n)s(pred_format, %(vs)s) \\\\\n  GTEST_PRED_FORMAT%(n)s_(pred_format, %(vs)s, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED%(n)s(pred, %(vs)s) \\\\\n  GTEST_PRED%(n)s_(pred, %(vs)s, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT%(n)s(pred_format, %(vs)s) \\\\\n  GTEST_PRED_FORMAT%(n)s_(pred_format, %(vs)s, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED%(n)s(pred, %(vs)s) \\\\\n  GTEST_PRED%(n)s_(pred, %(vs)s, GTEST_FATAL_FAILURE_)\n\n\"\"\" % DEFS\n\n  return impl\n\n\ndef HeaderPostamble():\n  \"\"\"Returns the postamble for the header file.\"\"\"\n\n  return \"\"\"\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n\"\"\"\n\n\ndef GenerateFile(path, content):\n  \"\"\"Given a file path and a content string, overwrites it with the\n  given content.\"\"\"\n\n  print 'Updating file %s . . .' % path\n\n  f = file(path, 'w+')\n  print >>f, content,\n  f.close()\n\n  print 'File %s has been updated.' % path\n\n\ndef GenerateHeader(n):\n  \"\"\"Given the maximum arity n, updates the header file that implements\n  the predicate assertions.\"\"\"\n\n  GenerateFile(HEADER,\n               HeaderPreamble(n)\n               + ''.join([ImplementationForArity(i) for i in OneTo(n)])\n               + HeaderPostamble())\n\n\ndef UnitTestPreamble():\n  \"\"\"Returns the preamble for the unit test file.\"\"\"\n\n  # A map that defines the values used in the preamble template.\n  DEFS = {\n    'today' : time.strftime('%m/%d/%Y'),\n    'year' : time.strftime('%Y'),\n    'command' : '%s %s' % (os.path.basename(sys.argv[0]), sys.argv[1]),\n    }\n\n  return (\n\"\"\"// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is AUTOMATICALLY GENERATED on %(today)s by command\n// '%(command)s'.  DO NOT EDIT BY HAND!\n\n// Regression test for gtest_pred_impl.h\n//\n// This file is generated by a script and quite long.  If you intend to\n// learn how Google Test works by reading its unit tests, read\n// gtest_unittest.cc instead.\n//\n// This is intended as a regression test for the Google Test predicate\n// assertions.  We compile it as part of the gtest_unittest target\n// only to keep the implementation tidy and compact, as it is quite\n// involved to set up the stage for testing Google Test using Google\n// Test itself.\n//\n// Currently, gtest_unittest takes ~11 seconds to run in the testing\n// daemon.  In the future, if it grows too large and needs much more\n// time to finish, we should consider separating this file into a\n// stand-alone regression test.\n\n#include <iostream>\n\n#include \"gtest/gtest.h\"\n#include \"gtest/gtest-spi.h\"\n\n// A user-defined data type.\nstruct Bool {\n  explicit Bool(int val) : value(val != 0) {}\n\n  bool operator>(int n) const { return value > Bool(n).value; }\n\n  Bool operator+(const Bool& rhs) const { return Bool(value + rhs.value); }\n\n  bool operator==(const Bool& rhs) const { return value == rhs.value; }\n\n  bool value;\n};\n\n// Enables Bool to be used in assertions.\nstd::ostream& operator<<(std::ostream& os, const Bool& x) {\n  return os << (x.value ? \"true\" : \"false\");\n}\n\n\"\"\" % DEFS)\n\n\ndef TestsForArity(n):\n  \"\"\"Returns the tests for n-ary predicate assertions.\"\"\"\n\n  # A map that defines the values used in the template for the tests.\n  DEFS = {\n    'n' : n,\n    'es' : Iter(n, 'e%s', sep=', '),\n    'vs' : Iter(n, 'v%s', sep=', '),\n    'vts' : Iter(n, '#v%s', sep=', '),\n    'tvs' : Iter(n, 'T%s v%s', sep=', '),\n    'int_vs' : Iter(n, 'int v%s', sep=', '),\n    'Bool_vs' : Iter(n, 'Bool v%s', sep=', '),\n    'types' : Iter(n, 'typename T%s', sep=', '),\n    'v_sum' : Iter(n, 'v%s', sep=' + '),\n    'arity' : Arity(n),\n    'Arity' : Title(Arity(n)),\n    }\n\n  tests = (\n\"\"\"// Sample functions/functors for testing %(arity)s predicate assertions.\n\n// A %(arity)s predicate function.\ntemplate <%(types)s>\nbool PredFunction%(n)s(%(tvs)s) {\n  return %(v_sum)s > 0;\n}\n\n// The following two functions are needed to circumvent a bug in\n// gcc 2.95.3, which sometimes has problem with the above template\n// function.\nbool PredFunction%(n)sInt(%(int_vs)s) {\n  return %(v_sum)s > 0;\n}\nbool PredFunction%(n)sBool(%(Bool_vs)s) {\n  return %(v_sum)s > 0;\n}\n\"\"\" % DEFS)\n\n  tests += \"\"\"\n// A %(arity)s predicate functor.\nstruct PredFunctor%(n)s {\n  template <%(types)s>\n  bool operator()(\"\"\" % DEFS\n\n  tests += Iter(n, 'const T%s& v%s', sep=\"\"\",\n                  \"\"\")\n\n  tests += \"\"\") {\n    return %(v_sum)s > 0;\n  }\n};\n\"\"\" % DEFS\n\n  tests += \"\"\"\n// A %(arity)s predicate-formatter function.\ntemplate <%(types)s>\ntesting::AssertionResult PredFormatFunction%(n)s(\"\"\" % DEFS\n\n  tests += Iter(n, 'const char* e%s', sep=\"\"\",\n                                             \"\"\")\n\n  tests += Iter(n, \"\"\",\n                                             const T%s& v%s\"\"\")\n\n  tests += \"\"\") {\n  if (PredFunction%(n)s(%(vs)s))\n    return testing::AssertionSuccess();\n\n  return testing::AssertionFailure()\n      << \"\"\" % DEFS\n\n  tests += Iter(n, 'e%s', sep=' << \" + \" << ')\n\n  tests += \"\"\"\n      << \" is expected to be positive, but evaluates to \"\n      << %(v_sum)s << \".\";\n}\n\"\"\" % DEFS\n\n  tests += \"\"\"\n// A %(arity)s predicate-formatter functor.\nstruct PredFormatFunctor%(n)s {\n  template <%(types)s>\n  testing::AssertionResult operator()(\"\"\" % DEFS\n\n  tests += Iter(n, 'const char* e%s', sep=\"\"\",\n                                      \"\"\")\n\n  tests += Iter(n, \"\"\",\n                                      const T%s& v%s\"\"\")\n\n  tests += \"\"\") const {\n    return PredFormatFunction%(n)s(%(es)s, %(vs)s);\n  }\n};\n\"\"\" % DEFS\n\n  tests += \"\"\"\n// Tests for {EXPECT|ASSERT}_PRED_FORMAT%(n)s.\n\nclass Predicate%(n)sTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    expected_to_finish_ = true;\n    finished_ = false;\"\"\" % DEFS\n\n  tests += \"\"\"\n    \"\"\" + Iter(n, 'n%s_ = ') + \"\"\"0;\n  }\n\"\"\"\n\n  tests += \"\"\"\n  virtual void TearDown() {\n    // Verifies that each of the predicate's arguments was evaluated\n    // exactly once.\"\"\"\n\n  tests += ''.join([\"\"\"\n    EXPECT_EQ(1, n%s_) <<\n        \"The predicate assertion didn't evaluate argument %s \"\n        \"exactly once.\";\"\"\" % (i, i + 1) for i in OneTo(n)])\n\n  tests += \"\"\"\n\n    // Verifies that the control flow in the test function is expected.\n    if (expected_to_finish_ && !finished_) {\n      FAIL() << \"The predicate assertion unexpactedly aborted the test.\";\n    } else if (!expected_to_finish_ && finished_) {\n      FAIL() << \"The failed predicate assertion didn't abort the test \"\n                \"as expected.\";\n    }\n  }\n\n  // true iff the test function is expected to run to finish.\n  static bool expected_to_finish_;\n\n  // true iff the test function did run to finish.\n  static bool finished_;\n\"\"\" % DEFS\n\n  tests += Iter(n, \"\"\"\n  static int n%s_;\"\"\")\n\n  tests += \"\"\"\n};\n\nbool Predicate%(n)sTest::expected_to_finish_;\nbool Predicate%(n)sTest::finished_;\n\"\"\" % DEFS\n\n  tests += Iter(n, \"\"\"int Predicate%%(n)sTest::n%s_;\n\"\"\") % DEFS\n\n  tests += \"\"\"\ntypedef Predicate%(n)sTest EXPECT_PRED_FORMAT%(n)sTest;\ntypedef Predicate%(n)sTest ASSERT_PRED_FORMAT%(n)sTest;\ntypedef Predicate%(n)sTest EXPECT_PRED%(n)sTest;\ntypedef Predicate%(n)sTest ASSERT_PRED%(n)sTest;\n\"\"\" % DEFS\n\n  def GenTest(use_format, use_assert, expect_failure,\n              use_functor, use_user_type):\n    \"\"\"Returns the test for a predicate assertion macro.\n\n    Args:\n      use_format:     true iff the assertion is a *_PRED_FORMAT*.\n      use_assert:     true iff the assertion is a ASSERT_*.\n      expect_failure: true iff the assertion is expected to fail.\n      use_functor:    true iff the first argument of the assertion is\n                      a functor (as opposed to a function)\n      use_user_type:  true iff the predicate functor/function takes\n                      argument(s) of a user-defined type.\n\n    Example:\n\n      GenTest(1, 0, 0, 1, 0) returns a test that tests the behavior\n      of a successful EXPECT_PRED_FORMATn() that takes a functor\n      whose arguments have built-in types.\"\"\"\n\n    if use_assert:\n      assrt = 'ASSERT'  # 'assert' is reserved, so we cannot use\n                        # that identifier here.\n    else:\n      assrt = 'EXPECT'\n\n    assertion = assrt + '_PRED'\n\n    if use_format:\n      pred_format = 'PredFormat'\n      assertion += '_FORMAT'\n    else:\n      pred_format = 'Pred'\n\n    assertion += '%(n)s' % DEFS\n\n    if use_functor:\n      pred_format_type = 'functor'\n      pred_format += 'Functor%(n)s()'\n    else:\n      pred_format_type = 'function'\n      pred_format += 'Function%(n)s'\n      if not use_format:\n        if use_user_type:\n          pred_format += 'Bool'\n        else:\n          pred_format += 'Int'\n\n    test_name = pred_format_type.title()\n\n    if use_user_type:\n      arg_type = 'user-defined type (Bool)'\n      test_name += 'OnUserType'\n      if expect_failure:\n        arg = 'Bool(n%s_++)'\n      else:\n        arg = 'Bool(++n%s_)'\n    else:\n      arg_type = 'built-in type (int)'\n      test_name += 'OnBuiltInType'\n      if expect_failure:\n        arg = 'n%s_++'\n      else:\n        arg = '++n%s_'\n\n    if expect_failure:\n      successful_or_failed = 'failed'\n      expected_or_not = 'expected.'\n      test_name +=  'Failure'\n    else:\n      successful_or_failed = 'successful'\n      expected_or_not = 'UNEXPECTED!'\n      test_name +=  'Success'\n\n    # A map that defines the values used in the test template.\n    defs = DEFS.copy()\n    defs.update({\n      'assert' : assrt,\n      'assertion' : assertion,\n      'test_name' : test_name,\n      'pf_type' : pred_format_type,\n      'pf' : pred_format,\n      'arg_type' : arg_type,\n      'arg' : arg,\n      'successful' : successful_or_failed,\n      'expected' : expected_or_not,\n      })\n\n    test = \"\"\"\n// Tests a %(successful)s %(assertion)s where the\n// predicate-formatter is a %(pf_type)s on a %(arg_type)s.\nTEST_F(%(assertion)sTest, %(test_name)s) {\"\"\" % defs\n\n    indent = (len(assertion) + 3)*' '\n    extra_indent = ''\n\n    if expect_failure:\n      extra_indent = '  '\n      if use_assert:\n        test += \"\"\"\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\"\"\"\n      else:\n        test += \"\"\"\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\"\"\"\n\n    test += '\\n' + extra_indent + \"\"\"  %(assertion)s(%(pf)s\"\"\" % defs\n\n    test = test % defs\n    test += Iter(n, ',\\n' + indent + extra_indent + '%(arg)s' % defs)\n    test += ');\\n' + extra_indent + '  finished_ = true;\\n'\n\n    if expect_failure:\n      test += '  }, \"\");\\n'\n\n    test += '}\\n'\n    return test\n\n  # Generates tests for all 2**6 = 64 combinations.\n  tests += ''.join([GenTest(use_format, use_assert, expect_failure,\n                            use_functor, use_user_type)\n                    for use_format in [0, 1]\n                    for use_assert in [0, 1]\n                    for expect_failure in [0, 1]\n                    for use_functor in [0, 1]\n                    for use_user_type in [0, 1]\n                    ])\n\n  return tests\n\n\ndef UnitTestPostamble():\n  \"\"\"Returns the postamble for the tests.\"\"\"\n\n  return ''\n\n\ndef GenerateUnitTest(n):\n  \"\"\"Returns the tests for up-to n-ary predicate assertions.\"\"\"\n\n  GenerateFile(UNIT_TEST,\n               UnitTestPreamble()\n               + ''.join([TestsForArity(i) for i in OneTo(n)])\n               + UnitTestPostamble())\n\n\ndef _Main():\n  \"\"\"The entry point of the script.  Generates the header file and its\n  unit test.\"\"\"\n\n  if len(sys.argv) != 2:\n    print __doc__\n    print 'Author: ' + __author__\n    sys.exit(1)\n\n  n = int(sys.argv[1])\n  GenerateHeader(n)\n  GenerateUnitTest(n)\n\n\nif __name__ == '__main__':\n  _Main()\n"
  },
  {
    "path": "utils/googletest/googletest/scripts/gtest-config.in",
    "content": "#!/bin/sh\n\n# These variables are automatically filled in by the configure script.\nname=\"@PACKAGE_TARNAME@\"\nversion=\"@PACKAGE_VERSION@\"\n\nshow_usage()\n{\n  echo \"Usage: gtest-config [OPTIONS...]\"\n}\n\nshow_help()\n{\n  show_usage\n  cat <<\\EOF\n\nThe `gtest-config' script provides access to the necessary compile and linking\nflags to connect with Google C++ Testing Framework, both in a build prior to\ninstallation, and on the system proper after installation. The installation\noverrides may be issued in combination with any other queries, but will only\naffect installation queries if called on a built but not installed gtest. The\ninstallation queries may not be issued with any other types of queries, and\nonly one installation query may be made at a time. The version queries and\ncompiler flag queries may be combined as desired but not mixed. Different\nversion queries are always combined with logical \"and\" semantics, and only the\nlast of any particular query is used while all previous ones ignored. All\nversions must be specified as a sequence of numbers separated by periods.\nCompiler flag queries output the union of the sets of flags when combined.\n\n Examples:\n  gtest-config --min-version=1.0 || echo \"Insufficient Google Test version.\"\n\n  g++ $(gtest-config --cppflags --cxxflags) -o foo.o -c foo.cpp\n  g++ $(gtest-config --ldflags --libs) -o foo foo.o\n\n  # When using a built but not installed Google Test:\n  g++ $(../../my_gtest_build/scripts/gtest-config ...) ...\n\n  # When using an installed Google Test, but with installation overrides:\n  export GTEST_PREFIX=\"/opt\"\n  g++ $(gtest-config --libdir=\"/opt/lib64\" ...) ...\n\n Help:\n  --usage                    brief usage information\n  --help                     display this help message\n\n Installation Overrides:\n  --prefix=<dir>             overrides the installation prefix\n  --exec-prefix=<dir>        overrides the executable installation prefix\n  --libdir=<dir>             overrides the library installation prefix\n  --includedir=<dir>         overrides the header file installation prefix\n\n Installation Queries:\n  --prefix                   installation prefix\n  --exec-prefix              executable installation prefix\n  --libdir                   library installation directory\n  --includedir               header file installation directory\n  --version                  the version of the Google Test installation\n\n Version Queries:\n  --min-version=VERSION      return 0 if the version is at least VERSION\n  --exact-version=VERSION    return 0 if the version is exactly VERSION\n  --max-version=VERSION      return 0 if the version is at most VERSION\n\n Compilation Flag Queries:\n  --cppflags                 compile flags specific to the C-like preprocessors\n  --cxxflags                 compile flags appropriate for C++ programs\n  --ldflags                  linker flags\n  --libs                     libraries for linking\n\nEOF\n}\n\n# This function bounds our version with a min and a max. It uses some clever\n# POSIX-compliant variable expansion to portably do all the work in the shell\n# and avoid any dependency on a particular \"sed\" or \"awk\" implementation.\n# Notable is that it will only ever compare the first 3 components of versions.\n# Further components will be cleanly stripped off. All versions must be\n# unadorned, so \"v1.0\" will *not* work. The minimum version must be in $1, and\n# the max in $2. TODO(chandlerc@google.com): If this ever breaks, we should\n# investigate expanding this via autom4te from AS_VERSION_COMPARE rather than\n# continuing to maintain our own shell version.\ncheck_versions()\n{\n  major_version=${version%%.*}\n  minor_version=\"0\"\n  point_version=\"0\"\n  if test \"${version#*.}\" != \"${version}\"; then\n    minor_version=${version#*.}\n    minor_version=${minor_version%%.*}\n  fi\n  if test \"${version#*.*.}\" != \"${version}\"; then\n    point_version=${version#*.*.}\n    point_version=${point_version%%.*}\n  fi\n\n  min_version=\"$1\"\n  min_major_version=${min_version%%.*}\n  min_minor_version=\"0\"\n  min_point_version=\"0\"\n  if test \"${min_version#*.}\" != \"${min_version}\"; then\n    min_minor_version=${min_version#*.}\n    min_minor_version=${min_minor_version%%.*}\n  fi\n  if test \"${min_version#*.*.}\" != \"${min_version}\"; then\n    min_point_version=${min_version#*.*.}\n    min_point_version=${min_point_version%%.*}\n  fi\n\n  max_version=\"$2\"\n  max_major_version=${max_version%%.*}\n  max_minor_version=\"0\"\n  max_point_version=\"0\"\n  if test \"${max_version#*.}\" != \"${max_version}\"; then\n    max_minor_version=${max_version#*.}\n    max_minor_version=${max_minor_version%%.*}\n  fi\n  if test \"${max_version#*.*.}\" != \"${max_version}\"; then\n    max_point_version=${max_version#*.*.}\n    max_point_version=${max_point_version%%.*}\n  fi\n\n  test $(($major_version)) -lt $(($min_major_version)) && exit 1\n  if test $(($major_version)) -eq $(($min_major_version)); then\n    test $(($minor_version)) -lt $(($min_minor_version)) && exit 1\n    if test $(($minor_version)) -eq $(($min_minor_version)); then\n      test $(($point_version)) -lt $(($min_point_version)) && exit 1\n    fi\n  fi\n\n  test $(($major_version)) -gt $(($max_major_version)) && exit 1\n  if test $(($major_version)) -eq $(($max_major_version)); then\n    test $(($minor_version)) -gt $(($max_minor_version)) && exit 1\n    if test $(($minor_version)) -eq $(($max_minor_version)); then\n      test $(($point_version)) -gt $(($max_point_version)) && exit 1\n    fi\n  fi\n\n  exit 0\n}\n\n# Show the usage line when no arguments are specified.\nif test $# -eq 0; then\n  show_usage\n  exit 1\nfi\n\nwhile test $# -gt 0; do\n  case $1 in\n    --usage)          show_usage;         exit 0;;\n    --help)           show_help;          exit 0;;\n\n    # Installation overrides\n    --prefix=*)       GTEST_PREFIX=${1#--prefix=};;\n    --exec-prefix=*)  GTEST_EXEC_PREFIX=${1#--exec-prefix=};;\n    --libdir=*)       GTEST_LIBDIR=${1#--libdir=};;\n    --includedir=*)   GTEST_INCLUDEDIR=${1#--includedir=};;\n\n    # Installation queries\n    --prefix|--exec-prefix|--libdir|--includedir|--version)\n      if test -n \"${do_query}\"; then\n        show_usage\n        exit 1\n      fi\n      do_query=${1#--}\n      ;;\n\n    # Version checking\n    --min-version=*)\n      do_check_versions=yes\n      min_version=${1#--min-version=}\n      ;;\n    --max-version=*)\n      do_check_versions=yes\n      max_version=${1#--max-version=}\n      ;;\n    --exact-version=*)\n      do_check_versions=yes\n      exact_version=${1#--exact-version=}\n      ;;\n\n    # Compiler flag output\n    --cppflags)       echo_cppflags=yes;;\n    --cxxflags)       echo_cxxflags=yes;;\n    --ldflags)        echo_ldflags=yes;;\n    --libs)           echo_libs=yes;;\n\n    # Everything else is an error\n    *)                show_usage;         exit 1;;\n  esac\n  shift\ndone\n\n# These have defaults filled in by the configure script but can also be\n# overridden by environment variables or command line parameters.\nprefix=\"${GTEST_PREFIX:-@prefix@}\"\nexec_prefix=\"${GTEST_EXEC_PREFIX:-@exec_prefix@}\"\nlibdir=\"${GTEST_LIBDIR:-@libdir@}\"\nincludedir=\"${GTEST_INCLUDEDIR:-@includedir@}\"\n\n# We try and detect if our binary is not located at its installed location. If\n# it's not, we provide variables pointing to the source and build tree rather\n# than to the install tree. This allows building against a just-built gtest\n# rather than an installed gtest.\nbindir=\"@bindir@\"\nthis_relative_bindir=`dirname $0`\nthis_bindir=`cd ${this_relative_bindir}; pwd -P`\nif test \"${this_bindir}\" = \"${this_bindir%${bindir}}\"; then\n  # The path to the script doesn't end in the bindir sequence from Autoconf,\n  # assume that we are in a build tree.\n  build_dir=`dirname ${this_bindir}`\n  src_dir=`cd ${this_bindir}; cd @top_srcdir@; pwd -P`\n\n  # TODO(chandlerc@google.com): This is a dangerous dependency on libtool, we\n  # should work to remove it, and/or remove libtool altogether, replacing it\n  # with direct references to the library and a link path.\n  gtest_libs=\"${build_dir}/lib/libgtest.la @PTHREAD_CFLAGS@ @PTHREAD_LIBS@\"\n  gtest_ldflags=\"\"\n\n  # We provide hooks to include from either the source or build dir, where the\n  # build dir is always preferred. This will potentially allow us to write\n  # build rules for generated headers and have them automatically be preferred\n  # over provided versions.\n  gtest_cppflags=\"-I${build_dir}/include -I${src_dir}/include\"\n  gtest_cxxflags=\"@PTHREAD_CFLAGS@\"\nelse\n  # We're using an installed gtest, although it may be staged under some\n  # prefix. Assume (as our own libraries do) that we can resolve the prefix,\n  # and are present in the dynamic link paths.\n  gtest_ldflags=\"-L${libdir}\"\n  gtest_libs=\"-l${name} @PTHREAD_CFLAGS@ @PTHREAD_LIBS@\"\n  gtest_cppflags=\"-I${includedir}\"\n  gtest_cxxflags=\"@PTHREAD_CFLAGS@\"\nfi\n\n# Do an installation query if requested.\nif test -n \"$do_query\"; then\n  case $do_query in\n    prefix)           echo $prefix;       exit 0;;\n    exec-prefix)      echo $exec_prefix;  exit 0;;\n    libdir)           echo $libdir;       exit 0;;\n    includedir)       echo $includedir;   exit 0;;\n    version)          echo $version;      exit 0;;\n    *)                show_usage;         exit 1;;\n  esac\nfi\n\n# Do a version check if requested.\nif test \"$do_check_versions\" = \"yes\"; then\n  # Make sure we didn't receive a bad combination of parameters.\n  test \"$echo_cppflags\" = \"yes\" && show_usage && exit 1\n  test \"$echo_cxxflags\" = \"yes\" && show_usage && exit 1\n  test \"$echo_ldflags\" = \"yes\"  && show_usage && exit 1\n  test \"$echo_libs\" = \"yes\"     && show_usage && exit 1\n\n  if test \"$exact_version\" != \"\"; then\n    check_versions $exact_version $exact_version\n    # unreachable\n  else\n    check_versions ${min_version:-0.0.0} ${max_version:-9999.9999.9999}\n    # unreachable\n  fi\nfi\n\n# Do the output in the correct order so that these can be used in-line of\n# a compiler invocation.\noutput=\"\"\ntest \"$echo_cppflags\" = \"yes\" && output=\"$output $gtest_cppflags\"\ntest \"$echo_cxxflags\" = \"yes\" && output=\"$output $gtest_cxxflags\"\ntest \"$echo_ldflags\" = \"yes\"  && output=\"$output $gtest_ldflags\"\ntest \"$echo_libs\" = \"yes\"     && output=\"$output $gtest_libs\"\necho $output\n\nexit 0\n"
  },
  {
    "path": "utils/googletest/googletest/scripts/pump.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"pump v0.2.0 - Pretty Useful for Meta Programming.\n\nA tool for preprocessor meta programming.  Useful for generating\nrepetitive boilerplate code.  Especially useful for writing C++\nclasses, functions, macros, and templates that need to work with\nvarious number of arguments.\n\nUSAGE:\n       pump.py SOURCE_FILE\n\nEXAMPLES:\n       pump.py foo.cc.pump\n         Converts foo.cc.pump to foo.cc.\n\nGRAMMAR:\n       CODE ::= ATOMIC_CODE*\n       ATOMIC_CODE ::= $var ID = EXPRESSION\n           | $var ID = [[ CODE ]]\n           | $range ID EXPRESSION..EXPRESSION\n           | $for ID SEPARATOR [[ CODE ]]\n           | $($)\n           | $ID\n           | $(EXPRESSION)\n           | $if EXPRESSION [[ CODE ]] ELSE_BRANCH\n           | [[ CODE ]]\n           | RAW_CODE\n       SEPARATOR ::= RAW_CODE | EMPTY\n       ELSE_BRANCH ::= $else [[ CODE ]]\n           | $elif EXPRESSION [[ CODE ]] ELSE_BRANCH\n           | EMPTY\n       EXPRESSION has Python syntax.\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport re\nimport sys\n\n\nTOKEN_TABLE = [\n    (re.compile(r'\\$var\\s+'), '$var'),\n    (re.compile(r'\\$elif\\s+'), '$elif'),\n    (re.compile(r'\\$else\\s+'), '$else'),\n    (re.compile(r'\\$for\\s+'), '$for'),\n    (re.compile(r'\\$if\\s+'), '$if'),\n    (re.compile(r'\\$range\\s+'), '$range'),\n    (re.compile(r'\\$[_A-Za-z]\\w*'), '$id'),\n    (re.compile(r'\\$\\(\\$\\)'), '$($)'),\n    (re.compile(r'\\$'), '$'),\n    (re.compile(r'\\[\\[\\n?'), '[['),\n    (re.compile(r'\\]\\]\\n?'), ']]'),\n    ]\n\n\nclass Cursor:\n  \"\"\"Represents a position (line and column) in a text file.\"\"\"\n\n  def __init__(self, line=-1, column=-1):\n    self.line = line\n    self.column = column\n\n  def __eq__(self, rhs):\n    return self.line == rhs.line and self.column == rhs.column\n\n  def __ne__(self, rhs):\n    return not self == rhs\n\n  def __lt__(self, rhs):\n    return self.line < rhs.line or (\n        self.line == rhs.line and self.column < rhs.column)\n\n  def __le__(self, rhs):\n    return self < rhs or self == rhs\n\n  def __gt__(self, rhs):\n    return rhs < self\n\n  def __ge__(self, rhs):\n    return rhs <= self\n\n  def __str__(self):\n    if self == Eof():\n      return 'EOF'\n    else:\n      return '%s(%s)' % (self.line + 1, self.column)\n\n  def __add__(self, offset):\n    return Cursor(self.line, self.column + offset)\n\n  def __sub__(self, offset):\n    return Cursor(self.line, self.column - offset)\n\n  def Clone(self):\n    \"\"\"Returns a copy of self.\"\"\"\n\n    return Cursor(self.line, self.column)\n\n\n# Special cursor to indicate the end-of-file.\ndef Eof():\n  \"\"\"Returns the special cursor to denote the end-of-file.\"\"\"\n  return Cursor(-1, -1)\n\n\nclass Token:\n  \"\"\"Represents a token in a Pump source file.\"\"\"\n\n  def __init__(self, start=None, end=None, value=None, token_type=None):\n    if start is None:\n      self.start = Eof()\n    else:\n      self.start = start\n    if end is None:\n      self.end = Eof()\n    else:\n      self.end = end\n    self.value = value\n    self.token_type = token_type\n\n  def __str__(self):\n    return 'Token @%s: \\'%s\\' type=%s' % (\n        self.start, self.value, self.token_type)\n\n  def Clone(self):\n    \"\"\"Returns a copy of self.\"\"\"\n\n    return Token(self.start.Clone(), self.end.Clone(), self.value,\n                 self.token_type)\n\n\ndef StartsWith(lines, pos, string):\n  \"\"\"Returns True iff the given position in lines starts with 'string'.\"\"\"\n\n  return lines[pos.line][pos.column:].startswith(string)\n\n\ndef FindFirstInLine(line, token_table):\n  best_match_start = -1\n  for (regex, token_type) in token_table:\n    m = regex.search(line)\n    if m:\n      # We found regex in lines\n      if best_match_start < 0 or m.start() < best_match_start:\n        best_match_start = m.start()\n        best_match_length = m.end() - m.start()\n        best_match_token_type = token_type\n\n  if best_match_start < 0:\n    return None\n\n  return (best_match_start, best_match_length, best_match_token_type)\n\n\ndef FindFirst(lines, token_table, cursor):\n  \"\"\"Finds the first occurrence of any string in strings in lines.\"\"\"\n\n  start = cursor.Clone()\n  cur_line_number = cursor.line\n  for line in lines[start.line:]:\n    if cur_line_number == start.line:\n      line = line[start.column:]\n    m = FindFirstInLine(line, token_table)\n    if m:\n      # We found a regex in line.\n      (start_column, length, token_type) = m\n      if cur_line_number == start.line:\n        start_column += start.column\n      found_start = Cursor(cur_line_number, start_column)\n      found_end = found_start + length\n      return MakeToken(lines, found_start, found_end, token_type)\n    cur_line_number += 1\n  # We failed to find str in lines\n  return None\n\n\ndef SubString(lines, start, end):\n  \"\"\"Returns a substring in lines.\"\"\"\n\n  if end == Eof():\n    end = Cursor(len(lines) - 1, len(lines[-1]))\n\n  if start >= end:\n    return ''\n\n  if start.line == end.line:\n    return lines[start.line][start.column:end.column]\n\n  result_lines = ([lines[start.line][start.column:]] +\n                  lines[start.line + 1:end.line] +\n                  [lines[end.line][:end.column]])\n  return ''.join(result_lines)\n\n\ndef StripMetaComments(str):\n  \"\"\"Strip meta comments from each line in the given string.\"\"\"\n\n  # First, completely remove lines containing nothing but a meta\n  # comment, including the trailing \\n.\n  str = re.sub(r'^\\s*\\$\\$.*\\n', '', str)\n\n  # Then, remove meta comments from contentful lines.\n  return re.sub(r'\\s*\\$\\$.*', '', str)\n\n\ndef MakeToken(lines, start, end, token_type):\n  \"\"\"Creates a new instance of Token.\"\"\"\n\n  return Token(start, end, SubString(lines, start, end), token_type)\n\n\ndef ParseToken(lines, pos, regex, token_type):\n  line = lines[pos.line][pos.column:]\n  m = regex.search(line)\n  if m and not m.start():\n    return MakeToken(lines, pos, pos + m.end(), token_type)\n  else:\n    print 'ERROR: %s expected at %s.' % (token_type, pos)\n    sys.exit(1)\n\n\nID_REGEX = re.compile(r'[_A-Za-z]\\w*')\nEQ_REGEX = re.compile(r'=')\nREST_OF_LINE_REGEX = re.compile(r'.*?(?=$|\\$\\$)')\nOPTIONAL_WHITE_SPACES_REGEX = re.compile(r'\\s*')\nWHITE_SPACE_REGEX = re.compile(r'\\s')\nDOT_DOT_REGEX = re.compile(r'\\.\\.')\n\n\ndef Skip(lines, pos, regex):\n  line = lines[pos.line][pos.column:]\n  m = re.search(regex, line)\n  if m and not m.start():\n    return pos + m.end()\n  else:\n    return pos\n\n\ndef SkipUntil(lines, pos, regex, token_type):\n  line = lines[pos.line][pos.column:]\n  m = re.search(regex, line)\n  if m:\n    return pos + m.start()\n  else:\n    print ('ERROR: %s expected on line %s after column %s.' %\n           (token_type, pos.line + 1, pos.column))\n    sys.exit(1)\n\n\ndef ParseExpTokenInParens(lines, pos):\n  def ParseInParens(pos):\n    pos = Skip(lines, pos, OPTIONAL_WHITE_SPACES_REGEX)\n    pos = Skip(lines, pos, r'\\(')\n    pos = Parse(pos)\n    pos = Skip(lines, pos, r'\\)')\n    return pos\n\n  def Parse(pos):\n    pos = SkipUntil(lines, pos, r'\\(|\\)', ')')\n    if SubString(lines, pos, pos + 1) == '(':\n      pos = Parse(pos + 1)\n      pos = Skip(lines, pos, r'\\)')\n      return Parse(pos)\n    else:\n      return pos\n\n  start = pos.Clone()\n  pos = ParseInParens(pos)\n  return MakeToken(lines, start, pos, 'exp')\n\n\ndef RStripNewLineFromToken(token):\n  if token.value.endswith('\\n'):\n    return Token(token.start, token.end, token.value[:-1], token.token_type)\n  else:\n    return token\n\n\ndef TokenizeLines(lines, pos):\n  while True:\n    found = FindFirst(lines, TOKEN_TABLE, pos)\n    if not found:\n      yield MakeToken(lines, pos, Eof(), 'code')\n      return\n\n    if found.start == pos:\n      prev_token = None\n      prev_token_rstripped = None\n    else:\n      prev_token = MakeToken(lines, pos, found.start, 'code')\n      prev_token_rstripped = RStripNewLineFromToken(prev_token)\n\n    if found.token_type == '$var':\n      if prev_token_rstripped:\n        yield prev_token_rstripped\n      yield found\n      id_token = ParseToken(lines, found.end, ID_REGEX, 'id')\n      yield id_token\n      pos = Skip(lines, id_token.end, OPTIONAL_WHITE_SPACES_REGEX)\n\n      eq_token = ParseToken(lines, pos, EQ_REGEX, '=')\n      yield eq_token\n      pos = Skip(lines, eq_token.end, r'\\s*')\n\n      if SubString(lines, pos, pos + 2) != '[[':\n        exp_token = ParseToken(lines, pos, REST_OF_LINE_REGEX, 'exp')\n        yield exp_token\n        pos = Cursor(exp_token.end.line + 1, 0)\n    elif found.token_type == '$for':\n      if prev_token_rstripped:\n        yield prev_token_rstripped\n      yield found\n      id_token = ParseToken(lines, found.end, ID_REGEX, 'id')\n      yield id_token\n      pos = Skip(lines, id_token.end, WHITE_SPACE_REGEX)\n    elif found.token_type == '$range':\n      if prev_token_rstripped:\n        yield prev_token_rstripped\n      yield found\n      id_token = ParseToken(lines, found.end, ID_REGEX, 'id')\n      yield id_token\n      pos = Skip(lines, id_token.end, OPTIONAL_WHITE_SPACES_REGEX)\n\n      dots_pos = SkipUntil(lines, pos, DOT_DOT_REGEX, '..')\n      yield MakeToken(lines, pos, dots_pos, 'exp')\n      yield MakeToken(lines, dots_pos, dots_pos + 2, '..')\n      pos = dots_pos + 2\n      new_pos = Cursor(pos.line + 1, 0)\n      yield MakeToken(lines, pos, new_pos, 'exp')\n      pos = new_pos\n    elif found.token_type == '$':\n      if prev_token:\n        yield prev_token\n      yield found\n      exp_token = ParseExpTokenInParens(lines, found.end)\n      yield exp_token\n      pos = exp_token.end\n    elif (found.token_type == ']]' or found.token_type == '$if' or\n          found.token_type == '$elif' or found.token_type == '$else'):\n      if prev_token_rstripped:\n        yield prev_token_rstripped\n      yield found\n      pos = found.end\n    else:\n      if prev_token:\n        yield prev_token\n      yield found\n      pos = found.end\n\n\ndef Tokenize(s):\n  \"\"\"A generator that yields the tokens in the given string.\"\"\"\n  if s != '':\n    lines = s.splitlines(True)\n    for token in TokenizeLines(lines, Cursor(0, 0)):\n      yield token\n\n\nclass CodeNode:\n  def __init__(self, atomic_code_list=None):\n    self.atomic_code = atomic_code_list\n\n\nclass VarNode:\n  def __init__(self, identifier=None, atomic_code=None):\n    self.identifier = identifier\n    self.atomic_code = atomic_code\n\n\nclass RangeNode:\n  def __init__(self, identifier=None, exp1=None, exp2=None):\n    self.identifier = identifier\n    self.exp1 = exp1\n    self.exp2 = exp2\n\n\nclass ForNode:\n  def __init__(self, identifier=None, sep=None, code=None):\n    self.identifier = identifier\n    self.sep = sep\n    self.code = code\n\n\nclass ElseNode:\n  def __init__(self, else_branch=None):\n    self.else_branch = else_branch\n\n\nclass IfNode:\n  def __init__(self, exp=None, then_branch=None, else_branch=None):\n    self.exp = exp\n    self.then_branch = then_branch\n    self.else_branch = else_branch\n\n\nclass RawCodeNode:\n  def __init__(self, token=None):\n    self.raw_code = token\n\n\nclass LiteralDollarNode:\n  def __init__(self, token):\n    self.token = token\n\n\nclass ExpNode:\n  def __init__(self, token, python_exp):\n    self.token = token\n    self.python_exp = python_exp\n\n\ndef PopFront(a_list):\n  head = a_list[0]\n  a_list[:1] = []\n  return head\n\n\ndef PushFront(a_list, elem):\n  a_list[:0] = [elem]\n\n\ndef PopToken(a_list, token_type=None):\n  token = PopFront(a_list)\n  if token_type is not None and token.token_type != token_type:\n    print 'ERROR: %s expected at %s' % (token_type, token.start)\n    print 'ERROR: %s found instead' % (token,)\n    sys.exit(1)\n\n  return token\n\n\ndef PeekToken(a_list):\n  if not a_list:\n    return None\n\n  return a_list[0]\n\n\ndef ParseExpNode(token):\n  python_exp = re.sub(r'([_A-Za-z]\\w*)', r'self.GetValue(\"\\1\")', token.value)\n  return ExpNode(token, python_exp)\n\n\ndef ParseElseNode(tokens):\n  def Pop(token_type=None):\n    return PopToken(tokens, token_type)\n\n  next = PeekToken(tokens)\n  if not next:\n    return None\n  if next.token_type == '$else':\n    Pop('$else')\n    Pop('[[')\n    code_node = ParseCodeNode(tokens)\n    Pop(']]')\n    return code_node\n  elif next.token_type == '$elif':\n    Pop('$elif')\n    exp = Pop('code')\n    Pop('[[')\n    code_node = ParseCodeNode(tokens)\n    Pop(']]')\n    inner_else_node = ParseElseNode(tokens)\n    return CodeNode([IfNode(ParseExpNode(exp), code_node, inner_else_node)])\n  elif not next.value.strip():\n    Pop('code')\n    return ParseElseNode(tokens)\n  else:\n    return None\n\n\ndef ParseAtomicCodeNode(tokens):\n  def Pop(token_type=None):\n    return PopToken(tokens, token_type)\n\n  head = PopFront(tokens)\n  t = head.token_type\n  if t == 'code':\n    return RawCodeNode(head)\n  elif t == '$var':\n    id_token = Pop('id')\n    Pop('=')\n    next = PeekToken(tokens)\n    if next.token_type == 'exp':\n      exp_token = Pop()\n      return VarNode(id_token, ParseExpNode(exp_token))\n    Pop('[[')\n    code_node = ParseCodeNode(tokens)\n    Pop(']]')\n    return VarNode(id_token, code_node)\n  elif t == '$for':\n    id_token = Pop('id')\n    next_token = PeekToken(tokens)\n    if next_token.token_type == 'code':\n      sep_token = next_token\n      Pop('code')\n    else:\n      sep_token = None\n    Pop('[[')\n    code_node = ParseCodeNode(tokens)\n    Pop(']]')\n    return ForNode(id_token, sep_token, code_node)\n  elif t == '$if':\n    exp_token = Pop('code')\n    Pop('[[')\n    code_node = ParseCodeNode(tokens)\n    Pop(']]')\n    else_node = ParseElseNode(tokens)\n    return IfNode(ParseExpNode(exp_token), code_node, else_node)\n  elif t == '$range':\n    id_token = Pop('id')\n    exp1_token = Pop('exp')\n    Pop('..')\n    exp2_token = Pop('exp')\n    return RangeNode(id_token, ParseExpNode(exp1_token),\n                     ParseExpNode(exp2_token))\n  elif t == '$id':\n    return ParseExpNode(Token(head.start + 1, head.end, head.value[1:], 'id'))\n  elif t == '$($)':\n    return LiteralDollarNode(head)\n  elif t == '$':\n    exp_token = Pop('exp')\n    return ParseExpNode(exp_token)\n  elif t == '[[':\n    code_node = ParseCodeNode(tokens)\n    Pop(']]')\n    return code_node\n  else:\n    PushFront(tokens, head)\n    return None\n\n\ndef ParseCodeNode(tokens):\n  atomic_code_list = []\n  while True:\n    if not tokens:\n      break\n    atomic_code_node = ParseAtomicCodeNode(tokens)\n    if atomic_code_node:\n      atomic_code_list.append(atomic_code_node)\n    else:\n      break\n  return CodeNode(atomic_code_list)\n\n\ndef ParseToAST(pump_src_text):\n  \"\"\"Convert the given Pump source text into an AST.\"\"\"\n  tokens = list(Tokenize(pump_src_text))\n  code_node = ParseCodeNode(tokens)\n  return code_node\n\n\nclass Env:\n  def __init__(self):\n    self.variables = []\n    self.ranges = []\n\n  def Clone(self):\n    clone = Env()\n    clone.variables = self.variables[:]\n    clone.ranges = self.ranges[:]\n    return clone\n\n  def PushVariable(self, var, value):\n    # If value looks like an int, store it as an int.\n    try:\n      int_value = int(value)\n      if ('%s' % int_value) == value:\n        value = int_value\n    except Exception:\n      pass\n    self.variables[:0] = [(var, value)]\n\n  def PopVariable(self):\n    self.variables[:1] = []\n\n  def PushRange(self, var, lower, upper):\n    self.ranges[:0] = [(var, lower, upper)]\n\n  def PopRange(self):\n    self.ranges[:1] = []\n\n  def GetValue(self, identifier):\n    for (var, value) in self.variables:\n      if identifier == var:\n        return value\n\n    print 'ERROR: meta variable %s is undefined.' % (identifier,)\n    sys.exit(1)\n\n  def EvalExp(self, exp):\n    try:\n      result = eval(exp.python_exp)\n    except Exception, e:\n      print 'ERROR: caught exception %s: %s' % (e.__class__.__name__, e)\n      print ('ERROR: failed to evaluate meta expression %s at %s' %\n             (exp.python_exp, exp.token.start))\n      sys.exit(1)\n    return result\n\n  def GetRange(self, identifier):\n    for (var, lower, upper) in self.ranges:\n      if identifier == var:\n        return (lower, upper)\n\n    print 'ERROR: range %s is undefined.' % (identifier,)\n    sys.exit(1)\n\n\nclass Output:\n  def __init__(self):\n    self.string = ''\n\n  def GetLastLine(self):\n    index = self.string.rfind('\\n')\n    if index < 0:\n      return ''\n\n    return self.string[index + 1:]\n\n  def Append(self, s):\n    self.string += s\n\n\ndef RunAtomicCode(env, node, output):\n  if isinstance(node, VarNode):\n    identifier = node.identifier.value.strip()\n    result = Output()\n    RunAtomicCode(env.Clone(), node.atomic_code, result)\n    value = result.string\n    env.PushVariable(identifier, value)\n  elif isinstance(node, RangeNode):\n    identifier = node.identifier.value.strip()\n    lower = int(env.EvalExp(node.exp1))\n    upper = int(env.EvalExp(node.exp2))\n    env.PushRange(identifier, lower, upper)\n  elif isinstance(node, ForNode):\n    identifier = node.identifier.value.strip()\n    if node.sep is None:\n      sep = ''\n    else:\n      sep = node.sep.value\n    (lower, upper) = env.GetRange(identifier)\n    for i in range(lower, upper + 1):\n      new_env = env.Clone()\n      new_env.PushVariable(identifier, i)\n      RunCode(new_env, node.code, output)\n      if i != upper:\n        output.Append(sep)\n  elif isinstance(node, RawCodeNode):\n    output.Append(node.raw_code.value)\n  elif isinstance(node, IfNode):\n    cond = env.EvalExp(node.exp)\n    if cond:\n      RunCode(env.Clone(), node.then_branch, output)\n    elif node.else_branch is not None:\n      RunCode(env.Clone(), node.else_branch, output)\n  elif isinstance(node, ExpNode):\n    value = env.EvalExp(node)\n    output.Append('%s' % (value,))\n  elif isinstance(node, LiteralDollarNode):\n    output.Append('$')\n  elif isinstance(node, CodeNode):\n    RunCode(env.Clone(), node, output)\n  else:\n    print 'BAD'\n    print node\n    sys.exit(1)\n\n\ndef RunCode(env, code_node, output):\n  for atomic_code in code_node.atomic_code:\n    RunAtomicCode(env, atomic_code, output)\n\n\ndef IsSingleLineComment(cur_line):\n  return '//' in cur_line\n\n\ndef IsInPreprocessorDirective(prev_lines, cur_line):\n  if cur_line.lstrip().startswith('#'):\n    return True\n  return prev_lines and prev_lines[-1].endswith('\\\\')\n\n\ndef WrapComment(line, output):\n  loc = line.find('//')\n  before_comment = line[:loc].rstrip()\n  if before_comment == '':\n    indent = loc\n  else:\n    output.append(before_comment)\n    indent = len(before_comment) - len(before_comment.lstrip())\n  prefix = indent*' ' + '// '\n  max_len = 80 - len(prefix)\n  comment = line[loc + 2:].strip()\n  segs = [seg for seg in re.split(r'(\\w+\\W*)', comment) if seg != '']\n  cur_line = ''\n  for seg in segs:\n    if len((cur_line + seg).rstrip()) < max_len:\n      cur_line += seg\n    else:\n      if cur_line.strip() != '':\n        output.append(prefix + cur_line.rstrip())\n      cur_line = seg.lstrip()\n  if cur_line.strip() != '':\n    output.append(prefix + cur_line.strip())\n\n\ndef WrapCode(line, line_concat, output):\n  indent = len(line) - len(line.lstrip())\n  prefix = indent*' '  # Prefix of the current line\n  max_len = 80 - indent - len(line_concat)  # Maximum length of the current line\n  new_prefix = prefix + 4*' '  # Prefix of a continuation line\n  new_max_len = max_len - 4  # Maximum length of a continuation line\n  # Prefers to wrap a line after a ',' or ';'.\n  segs = [seg for seg in re.split(r'([^,;]+[,;]?)', line.strip()) if seg != '']\n  cur_line = ''  # The current line without leading spaces.\n  for seg in segs:\n    # If the line is still too long, wrap at a space.\n    while cur_line == '' and len(seg.strip()) > max_len:\n      seg = seg.lstrip()\n      split_at = seg.rfind(' ', 0, max_len)\n      output.append(prefix + seg[:split_at].strip() + line_concat)\n      seg = seg[split_at + 1:]\n      prefix = new_prefix\n      max_len = new_max_len\n\n    if len((cur_line + seg).rstrip()) < max_len:\n      cur_line = (cur_line + seg).lstrip()\n    else:\n      output.append(prefix + cur_line.rstrip() + line_concat)\n      prefix = new_prefix\n      max_len = new_max_len\n      cur_line = seg.lstrip()\n  if cur_line.strip() != '':\n    output.append(prefix + cur_line.strip())\n\n\ndef WrapPreprocessorDirective(line, output):\n  WrapCode(line, ' \\\\', output)\n\n\ndef WrapPlainCode(line, output):\n  WrapCode(line, '', output)\n\n\ndef IsMultiLineIWYUPragma(line):\n  return re.search(r'/\\* IWYU pragma: ', line)\n\n\ndef IsHeaderGuardIncludeOrOneLineIWYUPragma(line):\n  return (re.match(r'^#(ifndef|define|endif\\s*//)\\s*[\\w_]+\\s*$', line) or\n          re.match(r'^#include\\s', line) or\n          # Don't break IWYU pragmas, either; that causes iwyu.py problems.\n          re.search(r'// IWYU pragma: ', line))\n\n\ndef WrapLongLine(line, output):\n  line = line.rstrip()\n  if len(line) <= 80:\n    output.append(line)\n  elif IsSingleLineComment(line):\n    if IsHeaderGuardIncludeOrOneLineIWYUPragma(line):\n      # The style guide made an exception to allow long header guard lines,\n      # includes and IWYU pragmas.\n      output.append(line)\n    else:\n      WrapComment(line, output)\n  elif IsInPreprocessorDirective(output, line):\n    if IsHeaderGuardIncludeOrOneLineIWYUPragma(line):\n      # The style guide made an exception to allow long header guard lines,\n      # includes and IWYU pragmas.\n      output.append(line)\n    else:\n      WrapPreprocessorDirective(line, output)\n  elif IsMultiLineIWYUPragma(line):\n    output.append(line)\n  else:\n    WrapPlainCode(line, output)\n\n\ndef BeautifyCode(string):\n  lines = string.splitlines()\n  output = []\n  for line in lines:\n    WrapLongLine(line, output)\n  output2 = [line.rstrip() for line in output]\n  return '\\n'.join(output2) + '\\n'\n\n\ndef ConvertFromPumpSource(src_text):\n  \"\"\"Return the text generated from the given Pump source text.\"\"\"\n  ast = ParseToAST(StripMetaComments(src_text))\n  output = Output()\n  RunCode(Env(), ast, output)\n  return BeautifyCode(output.string)\n\n\ndef main(argv):\n  if len(argv) == 1:\n    print __doc__\n    sys.exit(1)\n\n  file_path = argv[-1]\n  output_str = ConvertFromPumpSource(file(file_path, 'r').read())\n  if file_path.endswith('.pump'):\n    output_file_path = file_path[:-5]\n  else:\n    output_file_path = '-'\n  if output_file_path == '-':\n    print output_str,\n  else:\n    output_file = file(output_file_path, 'w')\n    output_file.write('// This file was GENERATED by command:\\n')\n    output_file.write('//     %s %s\\n' %\n                      (os.path.basename(__file__), os.path.basename(file_path)))\n    output_file.write('// DO NOT EDIT BY HAND!!!\\n\\n')\n    output_file.write(output_str)\n    output_file.close()\n\n\nif __name__ == '__main__':\n  main(sys.argv)\n"
  },
  {
    "path": "utils/googletest/googletest/scripts/release_docs.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2013 Google Inc. All Rights Reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Script for branching Google Test/Mock wiki pages for a new version.\n\nSYNOPSIS\n       release_docs.py NEW_RELEASE_VERSION\n\n       Google Test and Google Mock's external user documentation is in\n       interlinked wiki files.  When we release a new version of\n       Google Test or Google Mock, we need to branch the wiki files\n       such that users of a specific version of Google Test/Mock can\n       look up documenation relevant for that version.  This script\n       automates that process by:\n\n         - branching the current wiki pages (which document the\n           behavior of the SVN trunk head) to pages for the specified\n           version (e.g. branching FAQ.wiki to V2_6_FAQ.wiki when\n           NEW_RELEASE_VERSION is 2.6);\n         - updating the links in the branched files to point to the branched\n           version (e.g. a link in V2_6_FAQ.wiki that pointed to\n           Primer.wiki#Anchor will now point to V2_6_Primer.wiki#Anchor).\n\n       NOTE: NEW_RELEASE_VERSION must be a NEW version number for\n       which the wiki pages don't yet exist; otherwise you'll get SVN\n       errors like \"svn: Path 'V1_7_PumpManual.wiki' is not a\n       directory\" when running the script.\n\nEXAMPLE\n       $ cd PATH/TO/GTEST_SVN_WORKSPACE/trunk\n       $ scripts/release_docs.py 2.6  # create wiki pages for v2.6\n       $ svn status                   # verify the file list\n       $ svn diff                     # verify the file contents\n       $ svn commit -m \"release wiki pages for v2.6\"\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport re\nimport sys\n\nimport common\n\n\n# Wiki pages that shouldn't be branched for every gtest/gmock release.\nGTEST_UNVERSIONED_WIKIS = ['DevGuide.wiki']\nGMOCK_UNVERSIONED_WIKIS = [\n    'DesignDoc.wiki',\n    'DevGuide.wiki',\n    'KnownIssues.wiki'\n    ]\n\n\ndef DropWikiSuffix(wiki_filename):\n  \"\"\"Removes the .wiki suffix (if any) from the given filename.\"\"\"\n\n  return (wiki_filename[:-len('.wiki')] if wiki_filename.endswith('.wiki')\n          else wiki_filename)\n\n\nclass WikiBrancher(object):\n  \"\"\"Branches ...\"\"\"\n\n  def __init__(self, dot_version):\n    self.project, svn_root_path = common.GetSvnInfo()\n    if self.project not in ('googletest', 'googlemock'):\n      sys.exit('This script must be run in a gtest or gmock SVN workspace.')\n    self.wiki_dir = svn_root_path + '/wiki'\n    # Turn '2.6' to 'V2_6_'.\n    self.version_prefix = 'V' + dot_version.replace('.', '_') + '_'\n    self.files_to_branch = self.GetFilesToBranch()\n    page_names = [DropWikiSuffix(f) for f in self.files_to_branch]\n    # A link to Foo.wiki is in one of the following forms:\n    #   [Foo words]\n    #   [Foo#Anchor words]\n    #   [http://code.google.com/.../wiki/Foo words]\n    #   [http://code.google.com/.../wiki/Foo#Anchor words]\n    # We want to replace 'Foo' with 'V2_6_Foo' in the above cases.\n    self.search_for_re = re.compile(\n        # This regex matches either\n        #   [Foo\n        # or\n        #   /wiki/Foo\n        # followed by a space or a #, where Foo is the name of an\n        # unversioned wiki page.\n        r'(\\[|/wiki/)(%s)([ #])' % '|'.join(page_names))\n    self.replace_with = r'\\1%s\\2\\3' % (self.version_prefix,)\n\n  def GetFilesToBranch(self):\n    \"\"\"Returns a list of .wiki file names that need to be branched.\"\"\"\n\n    unversioned_wikis = (GTEST_UNVERSIONED_WIKIS if self.project == 'googletest'\n                         else GMOCK_UNVERSIONED_WIKIS)\n    return [f for f in os.listdir(self.wiki_dir)\n            if (f.endswith('.wiki') and\n                not re.match(r'^V\\d', f) and  # Excluded versioned .wiki files.\n                f not in unversioned_wikis)]\n\n  def BranchFiles(self):\n    \"\"\"Branches the .wiki files needed to be branched.\"\"\"\n\n    print 'Branching %d .wiki files:' % (len(self.files_to_branch),)\n    os.chdir(self.wiki_dir)\n    for f in self.files_to_branch:\n      command = 'svn cp %s %s%s' % (f, self.version_prefix, f)\n      print command\n      os.system(command)\n\n  def UpdateLinksInBranchedFiles(self):\n\n    for f in self.files_to_branch:\n      source_file = os.path.join(self.wiki_dir, f)\n      versioned_file = os.path.join(self.wiki_dir, self.version_prefix + f)\n      print 'Updating links in %s.' % (versioned_file,)\n      text = file(source_file, 'r').read()\n      new_text = self.search_for_re.sub(self.replace_with, text)\n      file(versioned_file, 'w').write(new_text)\n\n\ndef main():\n  if len(sys.argv) != 2:\n    sys.exit(__doc__)\n\n  brancher = WikiBrancher(sys.argv[1])\n  brancher.BranchFiles()\n  brancher.UpdateLinksInBranchedFiles()\n\n\nif __name__ == '__main__':\n  main()\n"
  },
  {
    "path": "utils/googletest/googletest/scripts/test/Makefile",
    "content": "# A Makefile for fusing Google Test and building a sample test against it.\n#\n# SYNOPSIS:\n#\n#   make [all]  - makes everything.\n#   make TARGET - makes the given target.\n#   make check  - makes everything and runs the built sample test.\n#   make clean  - removes all files generated by make.\n\n# Points to the root of fused Google Test, relative to where this file is.\nFUSED_GTEST_DIR = output\n\n# Paths to the fused gtest files.\nFUSED_GTEST_H = $(FUSED_GTEST_DIR)/gtest/gtest.h\nFUSED_GTEST_ALL_CC = $(FUSED_GTEST_DIR)/gtest/gtest-all.cc\n\n# Where to find the sample test.\nSAMPLE_DIR = ../../samples\n\n# Where to find gtest_main.cc.\nGTEST_MAIN_CC = ../../src/gtest_main.cc\n\n# Flags passed to the preprocessor.\n# We have no idea here whether pthreads is available in the system, so\n# disable its use.\nCPPFLAGS += -I$(FUSED_GTEST_DIR) -DGTEST_HAS_PTHREAD=0\n\n# Flags passed to the C++ compiler.\nCXXFLAGS += -g\n\nall : sample1_unittest\n\ncheck : all\n\t./sample1_unittest\n\nclean :\n\trm -rf $(FUSED_GTEST_DIR) sample1_unittest *.o\n\n$(FUSED_GTEST_H) :\n\t../fuse_gtest_files.py $(FUSED_GTEST_DIR)\n\n$(FUSED_GTEST_ALL_CC) :\n\t../fuse_gtest_files.py $(FUSED_GTEST_DIR)\n\ngtest-all.o : $(FUSED_GTEST_H) $(FUSED_GTEST_ALL_CC)\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(FUSED_GTEST_DIR)/gtest/gtest-all.cc\n\ngtest_main.o : $(FUSED_GTEST_H) $(GTEST_MAIN_CC)\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_MAIN_CC)\n\nsample1.o : $(SAMPLE_DIR)/sample1.cc $(SAMPLE_DIR)/sample1.h\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1.cc\n\nsample1_unittest.o : $(SAMPLE_DIR)/sample1_unittest.cc \\\n                     $(SAMPLE_DIR)/sample1.h $(FUSED_GTEST_H)\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1_unittest.cc\n\nsample1_unittest : sample1.o sample1_unittest.o gtest-all.o gtest_main.o\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@\n"
  },
  {
    "path": "utils/googletest/googletest/scripts/upload.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2007 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Tool for uploading diffs from a version control system to the codereview app.\n\nUsage summary: upload.py [options] [-- diff_options]\n\nDiff options are passed to the diff command of the underlying system.\n\nSupported version control systems:\n  Git\n  Mercurial\n  Subversion\n\nIt is important for Git/Mercurial users to specify a tree/node/branch to diff\nagainst by using the '--rev' option.\n\"\"\"\n# This code is derived from appcfg.py in the App Engine SDK (open source),\n# and from ASPN recipe #146306.\n\nimport cookielib\nimport getpass\nimport logging\nimport md5\nimport mimetypes\nimport optparse\nimport os\nimport re\nimport socket\nimport subprocess\nimport sys\nimport urllib\nimport urllib2\nimport urlparse\n\ntry:\n  import readline\nexcept ImportError:\n  pass\n\n# The logging verbosity:\n#  0: Errors only.\n#  1: Status messages.\n#  2: Info logs.\n#  3: Debug logs.\nverbosity = 1\n\n# Max size of patch or base file.\nMAX_UPLOAD_SIZE = 900 * 1024\n\n\ndef GetEmail(prompt):\n  \"\"\"Prompts the user for their email address and returns it.\n\n  The last used email address is saved to a file and offered up as a suggestion\n  to the user. If the user presses enter without typing in anything the last\n  used email address is used. If the user enters a new address, it is saved\n  for next time we prompt.\n\n  \"\"\"\n  last_email_file_name = os.path.expanduser(\"~/.last_codereview_email_address\")\n  last_email = \"\"\n  if os.path.exists(last_email_file_name):\n    try:\n      last_email_file = open(last_email_file_name, \"r\")\n      last_email = last_email_file.readline().strip(\"\\n\")\n      last_email_file.close()\n      prompt += \" [%s]\" % last_email\n    except IOError, e:\n      pass\n  email = raw_input(prompt + \": \").strip()\n  if email:\n    try:\n      last_email_file = open(last_email_file_name, \"w\")\n      last_email_file.write(email)\n      last_email_file.close()\n    except IOError, e:\n      pass\n  else:\n    email = last_email\n  return email\n\n\ndef StatusUpdate(msg):\n  \"\"\"Print a status message to stdout.\n\n  If 'verbosity' is greater than 0, print the message.\n\n  Args:\n    msg: The string to print.\n  \"\"\"\n  if verbosity > 0:\n    print msg\n\n\ndef ErrorExit(msg):\n  \"\"\"Print an error message to stderr and exit.\"\"\"\n  print >>sys.stderr, msg\n  sys.exit(1)\n\n\nclass ClientLoginError(urllib2.HTTPError):\n  \"\"\"Raised to indicate there was an error authenticating with ClientLogin.\"\"\"\n\n  def __init__(self, url, code, msg, headers, args):\n    urllib2.HTTPError.__init__(self, url, code, msg, headers, None)\n    self.args = args\n    self.reason = args[\"Error\"]\n\n\nclass AbstractRpcServer(object):\n  \"\"\"Provides a common interface for a simple RPC server.\"\"\"\n\n  def __init__(self, host, auth_function, host_override=None, extra_headers={},\n               save_cookies=False):\n    \"\"\"Creates a new HttpRpcServer.\n\n    Args:\n      host: The host to send requests to.\n      auth_function: A function that takes no arguments and returns an\n        (email, password) tuple when called. Will be called if authentication\n        is required.\n      host_override: The host header to send to the server (defaults to host).\n      extra_headers: A dict of extra headers to append to every request.\n      save_cookies: If True, save the authentication cookies to local disk.\n        If False, use an in-memory cookiejar instead.  Subclasses must\n        implement this functionality.  Defaults to False.\n    \"\"\"\n    self.host = host\n    self.host_override = host_override\n    self.auth_function = auth_function\n    self.authenticated = False\n    self.extra_headers = extra_headers\n    self.save_cookies = save_cookies\n    self.opener = self._GetOpener()\n    if self.host_override:\n      logging.info(\"Server: %s; Host: %s\", self.host, self.host_override)\n    else:\n      logging.info(\"Server: %s\", self.host)\n\n  def _GetOpener(self):\n    \"\"\"Returns an OpenerDirector for making HTTP requests.\n\n    Returns:\n      A urllib2.OpenerDirector object.\n    \"\"\"\n    raise NotImplementedError()\n\n  def _CreateRequest(self, url, data=None):\n    \"\"\"Creates a new urllib request.\"\"\"\n    logging.debug(\"Creating request for: '%s' with payload:\\n%s\", url, data)\n    req = urllib2.Request(url, data=data)\n    if self.host_override:\n      req.add_header(\"Host\", self.host_override)\n    for key, value in self.extra_headers.iteritems():\n      req.add_header(key, value)\n    return req\n\n  def _GetAuthToken(self, email, password):\n    \"\"\"Uses ClientLogin to authenticate the user, returning an auth token.\n\n    Args:\n      email:    The user's email address\n      password: The user's password\n\n    Raises:\n      ClientLoginError: If there was an error authenticating with ClientLogin.\n      HTTPError: If there was some other form of HTTP error.\n\n    Returns:\n      The authentication token returned by ClientLogin.\n    \"\"\"\n    account_type = \"GOOGLE\"\n    if self.host.endswith(\".google.com\"):\n      # Needed for use inside Google.\n      account_type = \"HOSTED\"\n    req = self._CreateRequest(\n        url=\"https://www.google.com/accounts/ClientLogin\",\n        data=urllib.urlencode({\n            \"Email\": email,\n            \"Passwd\": password,\n            \"service\": \"ah\",\n            \"source\": \"rietveld-codereview-upload\",\n            \"accountType\": account_type,\n        }),\n    )\n    try:\n      response = self.opener.open(req)\n      response_body = response.read()\n      response_dict = dict(x.split(\"=\")\n                           for x in response_body.split(\"\\n\") if x)\n      return response_dict[\"Auth\"]\n    except urllib2.HTTPError, e:\n      if e.code == 403:\n        body = e.read()\n        response_dict = dict(x.split(\"=\", 1) for x in body.split(\"\\n\") if x)\n        raise ClientLoginError(req.get_full_url(), e.code, e.msg,\n                               e.headers, response_dict)\n      else:\n        raise\n\n  def _GetAuthCookie(self, auth_token):\n    \"\"\"Fetches authentication cookies for an authentication token.\n\n    Args:\n      auth_token: The authentication token returned by ClientLogin.\n\n    Raises:\n      HTTPError: If there was an error fetching the authentication cookies.\n    \"\"\"\n    # This is a dummy value to allow us to identify when we're successful.\n    continue_location = \"http://localhost/\"\n    args = {\"continue\": continue_location, \"auth\": auth_token}\n    req = self._CreateRequest(\"http://%s/_ah/login?%s\" %\n                              (self.host, urllib.urlencode(args)))\n    try:\n      response = self.opener.open(req)\n    except urllib2.HTTPError, e:\n      response = e\n    if (response.code != 302 or\n        response.info()[\"location\"] != continue_location):\n      raise urllib2.HTTPError(req.get_full_url(), response.code, response.msg,\n                              response.headers, response.fp)\n    self.authenticated = True\n\n  def _Authenticate(self):\n    \"\"\"Authenticates the user.\n\n    The authentication process works as follows:\n     1) We get a username and password from the user\n     2) We use ClientLogin to obtain an AUTH token for the user\n        (see http://code.google.com/apis/accounts/AuthForInstalledApps.html).\n     3) We pass the auth token to /_ah/login on the server to obtain an\n        authentication cookie. If login was successful, it tries to redirect\n        us to the URL we provided.\n\n    If we attempt to access the upload API without first obtaining an\n    authentication cookie, it returns a 401 response and directs us to\n    authenticate ourselves with ClientLogin.\n    \"\"\"\n    for i in range(3):\n      credentials = self.auth_function()\n      try:\n        auth_token = self._GetAuthToken(credentials[0], credentials[1])\n      except ClientLoginError, e:\n        if e.reason == \"BadAuthentication\":\n          print >>sys.stderr, \"Invalid username or password.\"\n          continue\n        if e.reason == \"CaptchaRequired\":\n          print >>sys.stderr, (\n              \"Please go to\\n\"\n              \"https://www.google.com/accounts/DisplayUnlockCaptcha\\n\"\n              \"and verify you are a human.  Then try again.\")\n          break\n        if e.reason == \"NotVerified\":\n          print >>sys.stderr, \"Account not verified.\"\n          break\n        if e.reason == \"TermsNotAgreed\":\n          print >>sys.stderr, \"User has not agreed to TOS.\"\n          break\n        if e.reason == \"AccountDeleted\":\n          print >>sys.stderr, \"The user account has been deleted.\"\n          break\n        if e.reason == \"AccountDisabled\":\n          print >>sys.stderr, \"The user account has been disabled.\"\n          break\n        if e.reason == \"ServiceDisabled\":\n          print >>sys.stderr, (\"The user's access to the service has been \"\n                               \"disabled.\")\n          break\n        if e.reason == \"ServiceUnavailable\":\n          print >>sys.stderr, \"The service is not available; try again later.\"\n          break\n        raise\n      self._GetAuthCookie(auth_token)\n      return\n\n  def Send(self, request_path, payload=None,\n           content_type=\"application/octet-stream\",\n           timeout=None,\n           **kwargs):\n    \"\"\"Sends an RPC and returns the response.\n\n    Args:\n      request_path: The path to send the request to, eg /api/appversion/create.\n      payload: The body of the request, or None to send an empty request.\n      content_type: The Content-Type header to use.\n      timeout: timeout in seconds; default None i.e. no timeout.\n        (Note: for large requests on OS X, the timeout doesn't work right.)\n      kwargs: Any keyword arguments are converted into query string parameters.\n\n    Returns:\n      The response body, as a string.\n    \"\"\"\n    # TODO: Don't require authentication.  Let the server say\n    # whether it is necessary.\n    if not self.authenticated:\n      self._Authenticate()\n\n    old_timeout = socket.getdefaulttimeout()\n    socket.setdefaulttimeout(timeout)\n    try:\n      tries = 0\n      while True:\n        tries += 1\n        args = dict(kwargs)\n        url = \"http://%s%s\" % (self.host, request_path)\n        if args:\n          url += \"?\" + urllib.urlencode(args)\n        req = self._CreateRequest(url=url, data=payload)\n        req.add_header(\"Content-Type\", content_type)\n        try:\n          f = self.opener.open(req)\n          response = f.read()\n          f.close()\n          return response\n        except urllib2.HTTPError, e:\n          if tries > 3:\n            raise\n          elif e.code == 401:\n            self._Authenticate()\n##           elif e.code >= 500 and e.code < 600:\n##             # Server Error - try again.\n##             continue\n          else:\n            raise\n    finally:\n      socket.setdefaulttimeout(old_timeout)\n\n\nclass HttpRpcServer(AbstractRpcServer):\n  \"\"\"Provides a simplified RPC-style interface for HTTP requests.\"\"\"\n\n  def _Authenticate(self):\n    \"\"\"Save the cookie jar after authentication.\"\"\"\n    super(HttpRpcServer, self)._Authenticate()\n    if self.save_cookies:\n      StatusUpdate(\"Saving authentication cookies to %s\" % self.cookie_file)\n      self.cookie_jar.save()\n\n  def _GetOpener(self):\n    \"\"\"Returns an OpenerDirector that supports cookies and ignores redirects.\n\n    Returns:\n      A urllib2.OpenerDirector object.\n    \"\"\"\n    opener = urllib2.OpenerDirector()\n    opener.add_handler(urllib2.ProxyHandler())\n    opener.add_handler(urllib2.UnknownHandler())\n    opener.add_handler(urllib2.HTTPHandler())\n    opener.add_handler(urllib2.HTTPDefaultErrorHandler())\n    opener.add_handler(urllib2.HTTPSHandler())\n    opener.add_handler(urllib2.HTTPErrorProcessor())\n    if self.save_cookies:\n      self.cookie_file = os.path.expanduser(\"~/.codereview_upload_cookies\")\n      self.cookie_jar = cookielib.MozillaCookieJar(self.cookie_file)\n      if os.path.exists(self.cookie_file):\n        try:\n          self.cookie_jar.load()\n          self.authenticated = True\n          StatusUpdate(\"Loaded authentication cookies from %s\" %\n                       self.cookie_file)\n        except (cookielib.LoadError, IOError):\n          # Failed to load cookies - just ignore them.\n          pass\n      else:\n        # Create an empty cookie file with mode 600\n        fd = os.open(self.cookie_file, os.O_CREAT, 0600)\n        os.close(fd)\n      # Always chmod the cookie file\n      os.chmod(self.cookie_file, 0600)\n    else:\n      # Don't save cookies across runs of update.py.\n      self.cookie_jar = cookielib.CookieJar()\n    opener.add_handler(urllib2.HTTPCookieProcessor(self.cookie_jar))\n    return opener\n\n\nparser = optparse.OptionParser(usage=\"%prog [options] [-- diff_options]\")\nparser.add_option(\"-y\", \"--assume_yes\", action=\"store_true\",\n                  dest=\"assume_yes\", default=False,\n                  help=\"Assume that the answer to yes/no questions is 'yes'.\")\n# Logging\ngroup = parser.add_option_group(\"Logging options\")\ngroup.add_option(\"-q\", \"--quiet\", action=\"store_const\", const=0,\n                 dest=\"verbose\", help=\"Print errors only.\")\ngroup.add_option(\"-v\", \"--verbose\", action=\"store_const\", const=2,\n                 dest=\"verbose\", default=1,\n                 help=\"Print info level logs (default).\")\ngroup.add_option(\"--noisy\", action=\"store_const\", const=3,\n                 dest=\"verbose\", help=\"Print all logs.\")\n# Review server\ngroup = parser.add_option_group(\"Review server options\")\ngroup.add_option(\"-s\", \"--server\", action=\"store\", dest=\"server\",\n                 default=\"codereview.appspot.com\",\n                 metavar=\"SERVER\",\n                 help=(\"The server to upload to. The format is host[:port]. \"\n                       \"Defaults to 'codereview.appspot.com'.\"))\ngroup.add_option(\"-e\", \"--email\", action=\"store\", dest=\"email\",\n                 metavar=\"EMAIL\", default=None,\n                 help=\"The username to use. Will prompt if omitted.\")\ngroup.add_option(\"-H\", \"--host\", action=\"store\", dest=\"host\",\n                 metavar=\"HOST\", default=None,\n                 help=\"Overrides the Host header sent with all RPCs.\")\ngroup.add_option(\"--no_cookies\", action=\"store_false\",\n                 dest=\"save_cookies\", default=True,\n                 help=\"Do not save authentication cookies to local disk.\")\n# Issue\ngroup = parser.add_option_group(\"Issue options\")\ngroup.add_option(\"-d\", \"--description\", action=\"store\", dest=\"description\",\n                 metavar=\"DESCRIPTION\", default=None,\n                 help=\"Optional description when creating an issue.\")\ngroup.add_option(\"-f\", \"--description_file\", action=\"store\",\n                 dest=\"description_file\", metavar=\"DESCRIPTION_FILE\",\n                 default=None,\n                 help=\"Optional path of a file that contains \"\n                      \"the description when creating an issue.\")\ngroup.add_option(\"-r\", \"--reviewers\", action=\"store\", dest=\"reviewers\",\n                 metavar=\"REVIEWERS\", default=None,\n                 help=\"Add reviewers (comma separated email addresses).\")\ngroup.add_option(\"--cc\", action=\"store\", dest=\"cc\",\n                 metavar=\"CC\", default=None,\n                 help=\"Add CC (comma separated email addresses).\")\n# Upload options\ngroup = parser.add_option_group(\"Patch options\")\ngroup.add_option(\"-m\", \"--message\", action=\"store\", dest=\"message\",\n                 metavar=\"MESSAGE\", default=None,\n                 help=\"A message to identify the patch. \"\n                      \"Will prompt if omitted.\")\ngroup.add_option(\"-i\", \"--issue\", type=\"int\", action=\"store\",\n                 metavar=\"ISSUE\", default=None,\n                 help=\"Issue number to which to add. Defaults to new issue.\")\ngroup.add_option(\"--download_base\", action=\"store_true\",\n                 dest=\"download_base\", default=False,\n                 help=\"Base files will be downloaded by the server \"\n                 \"(side-by-side diffs may not work on files with CRs).\")\ngroup.add_option(\"--rev\", action=\"store\", dest=\"revision\",\n                 metavar=\"REV\", default=None,\n                 help=\"Branch/tree/revision to diff against (used by DVCS).\")\ngroup.add_option(\"--send_mail\", action=\"store_true\",\n                 dest=\"send_mail\", default=False,\n                 help=\"Send notification email to reviewers.\")\n\n\ndef GetRpcServer(options):\n  \"\"\"Returns an instance of an AbstractRpcServer.\n\n  Returns:\n    A new AbstractRpcServer, on which RPC calls can be made.\n  \"\"\"\n\n  rpc_server_class = HttpRpcServer\n\n  def GetUserCredentials():\n    \"\"\"Prompts the user for a username and password.\"\"\"\n    email = options.email\n    if email is None:\n      email = GetEmail(\"Email (login for uploading to %s)\" % options.server)\n    password = getpass.getpass(\"Password for %s: \" % email)\n    return (email, password)\n\n  # If this is the dev_appserver, use fake authentication.\n  host = (options.host or options.server).lower()\n  if host == \"localhost\" or host.startswith(\"localhost:\"):\n    email = options.email\n    if email is None:\n      email = \"test@example.com\"\n      logging.info(\"Using debug user %s.  Override with --email\" % email)\n    server = rpc_server_class(\n        options.server,\n        lambda: (email, \"password\"),\n        host_override=options.host,\n        extra_headers={\"Cookie\":\n                       'dev_appserver_login=\"%s:False\"' % email},\n        save_cookies=options.save_cookies)\n    # Don't try to talk to ClientLogin.\n    server.authenticated = True\n    return server\n\n  return rpc_server_class(options.server, GetUserCredentials,\n                          host_override=options.host,\n                          save_cookies=options.save_cookies)\n\n\ndef EncodeMultipartFormData(fields, files):\n  \"\"\"Encode form fields for multipart/form-data.\n\n  Args:\n    fields: A sequence of (name, value) elements for regular form fields.\n    files: A sequence of (name, filename, value) elements for data to be\n           uploaded as files.\n  Returns:\n    (content_type, body) ready for httplib.HTTP instance.\n\n  Source:\n    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306\n  \"\"\"\n  BOUNDARY = '-M-A-G-I-C---B-O-U-N-D-A-R-Y-'\n  CRLF = '\\r\\n'\n  lines = []\n  for (key, value) in fields:\n    lines.append('--' + BOUNDARY)\n    lines.append('Content-Disposition: form-data; name=\"%s\"' % key)\n    lines.append('')\n    lines.append(value)\n  for (key, filename, value) in files:\n    lines.append('--' + BOUNDARY)\n    lines.append('Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"' %\n             (key, filename))\n    lines.append('Content-Type: %s' % GetContentType(filename))\n    lines.append('')\n    lines.append(value)\n  lines.append('--' + BOUNDARY + '--')\n  lines.append('')\n  body = CRLF.join(lines)\n  content_type = 'multipart/form-data; boundary=%s' % BOUNDARY\n  return content_type, body\n\n\ndef GetContentType(filename):\n  \"\"\"Helper to guess the content-type from the filename.\"\"\"\n  return mimetypes.guess_type(filename)[0] or 'application/octet-stream'\n\n\n# Use a shell for subcommands on Windows to get a PATH search.\nuse_shell = sys.platform.startswith(\"win\")\n\ndef RunShellWithReturnCode(command, print_output=False,\n                           universal_newlines=True):\n  \"\"\"Executes a command and returns the output from stdout and the return code.\n\n  Args:\n    command: Command to execute.\n    print_output: If True, the output is printed to stdout.\n                  If False, both stdout and stderr are ignored.\n    universal_newlines: Use universal_newlines flag (default: True).\n\n  Returns:\n    Tuple (output, return code)\n  \"\"\"\n  logging.info(\"Running %s\", command)\n  p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,\n                       shell=use_shell, universal_newlines=universal_newlines)\n  if print_output:\n    output_array = []\n    while True:\n      line = p.stdout.readline()\n      if not line:\n        break\n      print line.strip(\"\\n\")\n      output_array.append(line)\n    output = \"\".join(output_array)\n  else:\n    output = p.stdout.read()\n  p.wait()\n  errout = p.stderr.read()\n  if print_output and errout:\n    print >>sys.stderr, errout\n  p.stdout.close()\n  p.stderr.close()\n  return output, p.returncode\n\n\ndef RunShell(command, silent_ok=False, universal_newlines=True,\n             print_output=False):\n  data, retcode = RunShellWithReturnCode(command, print_output,\n                                         universal_newlines)\n  if retcode:\n    ErrorExit(\"Got error status from %s:\\n%s\" % (command, data))\n  if not silent_ok and not data:\n    ErrorExit(\"No output from %s\" % command)\n  return data\n\n\nclass VersionControlSystem(object):\n  \"\"\"Abstract base class providing an interface to the VCS.\"\"\"\n\n  def __init__(self, options):\n    \"\"\"Constructor.\n\n    Args:\n      options: Command line options.\n    \"\"\"\n    self.options = options\n\n  def GenerateDiff(self, args):\n    \"\"\"Return the current diff as a string.\n\n    Args:\n      args: Extra arguments to pass to the diff command.\n    \"\"\"\n    raise NotImplementedError(\n        \"abstract method -- subclass %s must override\" % self.__class__)\n\n  def GetUnknownFiles(self):\n    \"\"\"Return a list of files unknown to the VCS.\"\"\"\n    raise NotImplementedError(\n        \"abstract method -- subclass %s must override\" % self.__class__)\n\n  def CheckForUnknownFiles(self):\n    \"\"\"Show an \"are you sure?\" prompt if there are unknown files.\"\"\"\n    unknown_files = self.GetUnknownFiles()\n    if unknown_files:\n      print \"The following files are not added to version control:\"\n      for line in unknown_files:\n        print line\n      prompt = \"Are you sure to continue?(y/N) \"\n      answer = raw_input(prompt).strip()\n      if answer != \"y\":\n        ErrorExit(\"User aborted\")\n\n  def GetBaseFile(self, filename):\n    \"\"\"Get the content of the upstream version of a file.\n\n    Returns:\n      A tuple (base_content, new_content, is_binary, status)\n        base_content: The contents of the base file.\n        new_content: For text files, this is empty.  For binary files, this is\n          the contents of the new file, since the diff output won't contain\n          information to reconstruct the current file.\n        is_binary: True iff the file is binary.\n        status: The status of the file.\n    \"\"\"\n\n    raise NotImplementedError(\n        \"abstract method -- subclass %s must override\" % self.__class__)\n\n\n  def GetBaseFiles(self, diff):\n    \"\"\"Helper that calls GetBase file for each file in the patch.\n\n    Returns:\n      A dictionary that maps from filename to GetBaseFile's tuple.  Filenames\n      are retrieved based on lines that start with \"Index:\" or\n      \"Property changes on:\".\n    \"\"\"\n    files = {}\n    for line in diff.splitlines(True):\n      if line.startswith('Index:') or line.startswith('Property changes on:'):\n        unused, filename = line.split(':', 1)\n        # On Windows if a file has property changes its filename uses '\\'\n        # instead of '/'.\n        filename = filename.strip().replace('\\\\', '/')\n        files[filename] = self.GetBaseFile(filename)\n    return files\n\n\n  def UploadBaseFiles(self, issue, rpc_server, patch_list, patchset, options,\n                      files):\n    \"\"\"Uploads the base files (and if necessary, the current ones as well).\"\"\"\n\n    def UploadFile(filename, file_id, content, is_binary, status, is_base):\n      \"\"\"Uploads a file to the server.\"\"\"\n      file_too_large = False\n      if is_base:\n        type = \"base\"\n      else:\n        type = \"current\"\n      if len(content) > MAX_UPLOAD_SIZE:\n        print (\"Not uploading the %s file for %s because it's too large.\" %\n               (type, filename))\n        file_too_large = True\n        content = \"\"\n      checksum = md5.new(content).hexdigest()\n      if options.verbose > 0 and not file_too_large:\n        print \"Uploading %s file for %s\" % (type, filename)\n      url = \"/%d/upload_content/%d/%d\" % (int(issue), int(patchset), file_id)\n      form_fields = [(\"filename\", filename),\n                     (\"status\", status),\n                     (\"checksum\", checksum),\n                     (\"is_binary\", str(is_binary)),\n                     (\"is_current\", str(not is_base)),\n                    ]\n      if file_too_large:\n        form_fields.append((\"file_too_large\", \"1\"))\n      if options.email:\n        form_fields.append((\"user\", options.email))\n      ctype, body = EncodeMultipartFormData(form_fields,\n                                            [(\"data\", filename, content)])\n      response_body = rpc_server.Send(url, body,\n                                      content_type=ctype)\n      if not response_body.startswith(\"OK\"):\n        StatusUpdate(\"  --> %s\" % response_body)\n        sys.exit(1)\n\n    patches = dict()\n    [patches.setdefault(v, k) for k, v in patch_list]\n    for filename in patches.keys():\n      base_content, new_content, is_binary, status = files[filename]\n      file_id_str = patches.get(filename)\n      if file_id_str.find(\"nobase\") != -1:\n        base_content = None\n        file_id_str = file_id_str[file_id_str.rfind(\"_\") + 1:]\n      file_id = int(file_id_str)\n      if base_content != None:\n        UploadFile(filename, file_id, base_content, is_binary, status, True)\n      if new_content != None:\n        UploadFile(filename, file_id, new_content, is_binary, status, False)\n\n  def IsImage(self, filename):\n    \"\"\"Returns true if the filename has an image extension.\"\"\"\n    mimetype =  mimetypes.guess_type(filename)[0]\n    if not mimetype:\n      return False\n    return mimetype.startswith(\"image/\")\n\n\nclass SubversionVCS(VersionControlSystem):\n  \"\"\"Implementation of the VersionControlSystem interface for Subversion.\"\"\"\n\n  def __init__(self, options):\n    super(SubversionVCS, self).__init__(options)\n    if self.options.revision:\n      match = re.match(r\"(\\d+)(:(\\d+))?\", self.options.revision)\n      if not match:\n        ErrorExit(\"Invalid Subversion revision %s.\" % self.options.revision)\n      self.rev_start = match.group(1)\n      self.rev_end = match.group(3)\n    else:\n      self.rev_start = self.rev_end = None\n    # Cache output from \"svn list -r REVNO dirname\".\n    # Keys: dirname, Values: 2-tuple (ouput for start rev and end rev).\n    self.svnls_cache = {}\n    # SVN base URL is required to fetch files deleted in an older revision.\n    # Result is cached to not guess it over and over again in GetBaseFile().\n    required = self.options.download_base or self.options.revision is not None\n    self.svn_base = self._GuessBase(required)\n\n  def GuessBase(self, required):\n    \"\"\"Wrapper for _GuessBase.\"\"\"\n    return self.svn_base\n\n  def _GuessBase(self, required):\n    \"\"\"Returns the SVN base URL.\n\n    Args:\n      required: If true, exits if the url can't be guessed, otherwise None is\n        returned.\n    \"\"\"\n    info = RunShell([\"svn\", \"info\"])\n    for line in info.splitlines():\n      words = line.split()\n      if len(words) == 2 and words[0] == \"URL:\":\n        url = words[1]\n        scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)\n        username, netloc = urllib.splituser(netloc)\n        if username:\n          logging.info(\"Removed username from base URL\")\n        if netloc.endswith(\"svn.python.org\"):\n          if netloc == \"svn.python.org\":\n            if path.startswith(\"/projects/\"):\n              path = path[9:]\n          elif netloc != \"pythondev@svn.python.org\":\n            ErrorExit(\"Unrecognized Python URL: %s\" % url)\n          base = \"http://svn.python.org/view/*checkout*%s/\" % path\n          logging.info(\"Guessed Python base = %s\", base)\n        elif netloc.endswith(\"svn.collab.net\"):\n          if path.startswith(\"/repos/\"):\n            path = path[6:]\n          base = \"http://svn.collab.net/viewvc/*checkout*%s/\" % path\n          logging.info(\"Guessed CollabNet base = %s\", base)\n        elif netloc.endswith(\".googlecode.com\"):\n          path = path + \"/\"\n          base = urlparse.urlunparse((\"http\", netloc, path, params,\n                                      query, fragment))\n          logging.info(\"Guessed Google Code base = %s\", base)\n        else:\n          path = path + \"/\"\n          base = urlparse.urlunparse((scheme, netloc, path, params,\n                                      query, fragment))\n          logging.info(\"Guessed base = %s\", base)\n        return base\n    if required:\n      ErrorExit(\"Can't find URL in output from svn info\")\n    return None\n\n  def GenerateDiff(self, args):\n    cmd = [\"svn\", \"diff\"]\n    if self.options.revision:\n      cmd += [\"-r\", self.options.revision]\n    cmd.extend(args)\n    data = RunShell(cmd)\n    count = 0\n    for line in data.splitlines():\n      if line.startswith(\"Index:\") or line.startswith(\"Property changes on:\"):\n        count += 1\n        logging.info(line)\n    if not count:\n      ErrorExit(\"No valid patches found in output from svn diff\")\n    return data\n\n  def _CollapseKeywords(self, content, keyword_str):\n    \"\"\"Collapses SVN keywords.\"\"\"\n    # svn cat translates keywords but svn diff doesn't. As a result of this\n    # behavior patching.PatchChunks() fails with a chunk mismatch error.\n    # This part was originally written by the Review Board development team\n    # who had the same problem (http://reviews.review-board.org/r/276/).\n    # Mapping of keywords to known aliases\n    svn_keywords = {\n      # Standard keywords\n      'Date':                ['Date', 'LastChangedDate'],\n      'Revision':            ['Revision', 'LastChangedRevision', 'Rev'],\n      'Author':              ['Author', 'LastChangedBy'],\n      'HeadURL':             ['HeadURL', 'URL'],\n      'Id':                  ['Id'],\n\n      # Aliases\n      'LastChangedDate':     ['LastChangedDate', 'Date'],\n      'LastChangedRevision': ['LastChangedRevision', 'Rev', 'Revision'],\n      'LastChangedBy':       ['LastChangedBy', 'Author'],\n      'URL':                 ['URL', 'HeadURL'],\n    }\n\n    def repl(m):\n       if m.group(2):\n         return \"$%s::%s$\" % (m.group(1), \" \" * len(m.group(3)))\n       return \"$%s$\" % m.group(1)\n    keywords = [keyword\n                for name in keyword_str.split(\" \")\n                for keyword in svn_keywords.get(name, [])]\n    return re.sub(r\"\\$(%s):(:?)([^\\$]+)\\$\" % '|'.join(keywords), repl, content)\n\n  def GetUnknownFiles(self):\n    status = RunShell([\"svn\", \"status\", \"--ignore-externals\"], silent_ok=True)\n    unknown_files = []\n    for line in status.split(\"\\n\"):\n      if line and line[0] == \"?\":\n        unknown_files.append(line)\n    return unknown_files\n\n  def ReadFile(self, filename):\n    \"\"\"Returns the contents of a file.\"\"\"\n    file = open(filename, 'rb')\n    result = \"\"\n    try:\n      result = file.read()\n    finally:\n      file.close()\n    return result\n\n  def GetStatus(self, filename):\n    \"\"\"Returns the status of a file.\"\"\"\n    if not self.options.revision:\n      status = RunShell([\"svn\", \"status\", \"--ignore-externals\", filename])\n      if not status:\n        ErrorExit(\"svn status returned no output for %s\" % filename)\n      status_lines = status.splitlines()\n      # If file is in a cl, the output will begin with\n      # \"\\n--- Changelist 'cl_name':\\n\".  See\n      # http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt\n      if (len(status_lines) == 3 and\n          not status_lines[0] and\n          status_lines[1].startswith(\"--- Changelist\")):\n        status = status_lines[2]\n      else:\n        status = status_lines[0]\n    # If we have a revision to diff against we need to run \"svn list\"\n    # for the old and the new revision and compare the results to get\n    # the correct status for a file.\n    else:\n      dirname, relfilename = os.path.split(filename)\n      if dirname not in self.svnls_cache:\n        cmd = [\"svn\", \"list\", \"-r\", self.rev_start, dirname or \".\"]\n        out, returncode = RunShellWithReturnCode(cmd)\n        if returncode:\n          ErrorExit(\"Failed to get status for %s.\" % filename)\n        old_files = out.splitlines()\n        args = [\"svn\", \"list\"]\n        if self.rev_end:\n          args += [\"-r\", self.rev_end]\n        cmd = args + [dirname or \".\"]\n        out, returncode = RunShellWithReturnCode(cmd)\n        if returncode:\n          ErrorExit(\"Failed to run command %s\" % cmd)\n        self.svnls_cache[dirname] = (old_files, out.splitlines())\n      old_files, new_files = self.svnls_cache[dirname]\n      if relfilename in old_files and relfilename not in new_files:\n        status = \"D   \"\n      elif relfilename in old_files and relfilename in new_files:\n        status = \"M   \"\n      else:\n        status = \"A   \"\n    return status\n\n  def GetBaseFile(self, filename):\n    status = self.GetStatus(filename)\n    base_content = None\n    new_content = None\n\n    # If a file is copied its status will be \"A  +\", which signifies\n    # \"addition-with-history\".  See \"svn st\" for more information.  We need to\n    # upload the original file or else diff parsing will fail if the file was\n    # edited.\n    if status[0] == \"A\" and status[3] != \"+\":\n      # We'll need to upload the new content if we're adding a binary file\n      # since diff's output won't contain it.\n      mimetype = RunShell([\"svn\", \"propget\", \"svn:mime-type\", filename],\n                          silent_ok=True)\n      base_content = \"\"\n      is_binary = mimetype and not mimetype.startswith(\"text/\")\n      if is_binary and self.IsImage(filename):\n        new_content = self.ReadFile(filename)\n    elif (status[0] in (\"M\", \"D\", \"R\") or\n          (status[0] == \"A\" and status[3] == \"+\") or  # Copied file.\n          (status[0] == \" \" and status[1] == \"M\")):  # Property change.\n      args = []\n      if self.options.revision:\n        url = \"%s/%s@%s\" % (self.svn_base, filename, self.rev_start)\n      else:\n        # Don't change filename, it's needed later.\n        url = filename\n        args += [\"-r\", \"BASE\"]\n      cmd = [\"svn\"] + args + [\"propget\", \"svn:mime-type\", url]\n      mimetype, returncode = RunShellWithReturnCode(cmd)\n      if returncode:\n        # File does not exist in the requested revision.\n        # Reset mimetype, it contains an error message.\n        mimetype = \"\"\n      get_base = False\n      is_binary = mimetype and not mimetype.startswith(\"text/\")\n      if status[0] == \" \":\n        # Empty base content just to force an upload.\n        base_content = \"\"\n      elif is_binary:\n        if self.IsImage(filename):\n          get_base = True\n          if status[0] == \"M\":\n            if not self.rev_end:\n              new_content = self.ReadFile(filename)\n            else:\n              url = \"%s/%s@%s\" % (self.svn_base, filename, self.rev_end)\n              new_content = RunShell([\"svn\", \"cat\", url],\n                                     universal_newlines=True, silent_ok=True)\n        else:\n          base_content = \"\"\n      else:\n        get_base = True\n\n      if get_base:\n        if is_binary:\n          universal_newlines = False\n        else:\n          universal_newlines = True\n        if self.rev_start:\n          # \"svn cat -r REV delete_file.txt\" doesn't work. cat requires\n          # the full URL with \"@REV\" appended instead of using \"-r\" option.\n          url = \"%s/%s@%s\" % (self.svn_base, filename, self.rev_start)\n          base_content = RunShell([\"svn\", \"cat\", url],\n                                  universal_newlines=universal_newlines,\n                                  silent_ok=True)\n        else:\n          base_content = RunShell([\"svn\", \"cat\", filename],\n                                  universal_newlines=universal_newlines,\n                                  silent_ok=True)\n        if not is_binary:\n          args = []\n          if self.rev_start:\n            url = \"%s/%s@%s\" % (self.svn_base, filename, self.rev_start)\n          else:\n            url = filename\n            args += [\"-r\", \"BASE\"]\n          cmd = [\"svn\"] + args + [\"propget\", \"svn:keywords\", url]\n          keywords, returncode = RunShellWithReturnCode(cmd)\n          if keywords and not returncode:\n            base_content = self._CollapseKeywords(base_content, keywords)\n    else:\n      StatusUpdate(\"svn status returned unexpected output: %s\" % status)\n      sys.exit(1)\n    return base_content, new_content, is_binary, status[0:5]\n\n\nclass GitVCS(VersionControlSystem):\n  \"\"\"Implementation of the VersionControlSystem interface for Git.\"\"\"\n\n  def __init__(self, options):\n    super(GitVCS, self).__init__(options)\n    # Map of filename -> hash of base file.\n    self.base_hashes = {}\n\n  def GenerateDiff(self, extra_args):\n    # This is more complicated than svn's GenerateDiff because we must convert\n    # the diff output to include an svn-style \"Index:\" line as well as record\n    # the hashes of the base files, so we can upload them along with our diff.\n    if self.options.revision:\n      extra_args = [self.options.revision] + extra_args\n    gitdiff = RunShell([\"git\", \"diff\", \"--full-index\"] + extra_args)\n    svndiff = []\n    filecount = 0\n    filename = None\n    for line in gitdiff.splitlines():\n      match = re.match(r\"diff --git a/(.*) b/.*$\", line)\n      if match:\n        filecount += 1\n        filename = match.group(1)\n        svndiff.append(\"Index: %s\\n\" % filename)\n      else:\n        # The \"index\" line in a git diff looks like this (long hashes elided):\n        #   index 82c0d44..b2cee3f 100755\n        # We want to save the left hash, as that identifies the base file.\n        match = re.match(r\"index (\\w+)\\.\\.\", line)\n        if match:\n          self.base_hashes[filename] = match.group(1)\n      svndiff.append(line + \"\\n\")\n    if not filecount:\n      ErrorExit(\"No valid patches found in output from git diff\")\n    return \"\".join(svndiff)\n\n  def GetUnknownFiles(self):\n    status = RunShell([\"git\", \"ls-files\", \"--exclude-standard\", \"--others\"],\n                      silent_ok=True)\n    return status.splitlines()\n\n  def GetBaseFile(self, filename):\n    hash = self.base_hashes[filename]\n    base_content = None\n    new_content = None\n    is_binary = False\n    if hash == \"0\" * 40:  # All-zero hash indicates no base file.\n      status = \"A\"\n      base_content = \"\"\n    else:\n      status = \"M\"\n      base_content, returncode = RunShellWithReturnCode([\"git\", \"show\", hash])\n      if returncode:\n        ErrorExit(\"Got error status from 'git show %s'\" % hash)\n    return (base_content, new_content, is_binary, status)\n\n\nclass MercurialVCS(VersionControlSystem):\n  \"\"\"Implementation of the VersionControlSystem interface for Mercurial.\"\"\"\n\n  def __init__(self, options, repo_dir):\n    super(MercurialVCS, self).__init__(options)\n    # Absolute path to repository (we can be in a subdir)\n    self.repo_dir = os.path.normpath(repo_dir)\n    # Compute the subdir\n    cwd = os.path.normpath(os.getcwd())\n    assert cwd.startswith(self.repo_dir)\n    self.subdir = cwd[len(self.repo_dir):].lstrip(r\"\\/\")\n    if self.options.revision:\n      self.base_rev = self.options.revision\n    else:\n      self.base_rev = RunShell([\"hg\", \"parent\", \"-q\"]).split(':')[1].strip()\n\n  def _GetRelPath(self, filename):\n    \"\"\"Get relative path of a file according to the current directory,\n    given its logical path in the repo.\"\"\"\n    assert filename.startswith(self.subdir), filename\n    return filename[len(self.subdir):].lstrip(r\"\\/\")\n\n  def GenerateDiff(self, extra_args):\n    # If no file specified, restrict to the current subdir\n    extra_args = extra_args or [\".\"]\n    cmd = [\"hg\", \"diff\", \"--git\", \"-r\", self.base_rev] + extra_args\n    data = RunShell(cmd, silent_ok=True)\n    svndiff = []\n    filecount = 0\n    for line in data.splitlines():\n      m = re.match(\"diff --git a/(\\S+) b/(\\S+)\", line)\n      if m:\n        # Modify line to make it look like as it comes from svn diff.\n        # With this modification no changes on the server side are required\n        # to make upload.py work with Mercurial repos.\n        # NOTE: for proper handling of moved/copied files, we have to use\n        # the second filename.\n        filename = m.group(2)\n        svndiff.append(\"Index: %s\" % filename)\n        svndiff.append(\"=\" * 67)\n        filecount += 1\n        logging.info(line)\n      else:\n        svndiff.append(line)\n    if not filecount:\n      ErrorExit(\"No valid patches found in output from hg diff\")\n    return \"\\n\".join(svndiff) + \"\\n\"\n\n  def GetUnknownFiles(self):\n    \"\"\"Return a list of files unknown to the VCS.\"\"\"\n    args = []\n    status = RunShell([\"hg\", \"status\", \"--rev\", self.base_rev, \"-u\", \".\"],\n        silent_ok=True)\n    unknown_files = []\n    for line in status.splitlines():\n      st, fn = line.split(\" \", 1)\n      if st == \"?\":\n        unknown_files.append(fn)\n    return unknown_files\n\n  def GetBaseFile(self, filename):\n    # \"hg status\" and \"hg cat\" both take a path relative to the current subdir\n    # rather than to the repo root, but \"hg diff\" has given us the full path\n    # to the repo root.\n    base_content = \"\"\n    new_content = None\n    is_binary = False\n    oldrelpath = relpath = self._GetRelPath(filename)\n    # \"hg status -C\" returns two lines for moved/copied files, one otherwise\n    out = RunShell([\"hg\", \"status\", \"-C\", \"--rev\", self.base_rev, relpath])\n    out = out.splitlines()\n    # HACK: strip error message about missing file/directory if it isn't in\n    # the working copy\n    if out[0].startswith('%s: ' % relpath):\n      out = out[1:]\n    if len(out) > 1:\n      # Moved/copied => considered as modified, use old filename to\n      # retrieve base contents\n      oldrelpath = out[1].strip()\n      status = \"M\"\n    else:\n      status, _ = out[0].split(' ', 1)\n    if status != \"A\":\n      base_content = RunShell([\"hg\", \"cat\", \"-r\", self.base_rev, oldrelpath],\n        silent_ok=True)\n      is_binary = \"\\0\" in base_content  # Mercurial's heuristic\n    if status != \"R\":\n      new_content = open(relpath, \"rb\").read()\n      is_binary = is_binary or \"\\0\" in new_content\n    if is_binary and base_content:\n      # Fetch again without converting newlines\n      base_content = RunShell([\"hg\", \"cat\", \"-r\", self.base_rev, oldrelpath],\n        silent_ok=True, universal_newlines=False)\n    if not is_binary or not self.IsImage(relpath):\n      new_content = None\n    return base_content, new_content, is_binary, status\n\n\n# NOTE: The SplitPatch function is duplicated in engine.py, keep them in sync.\ndef SplitPatch(data):\n  \"\"\"Splits a patch into separate pieces for each file.\n\n  Args:\n    data: A string containing the output of svn diff.\n\n  Returns:\n    A list of 2-tuple (filename, text) where text is the svn diff output\n      pertaining to filename.\n  \"\"\"\n  patches = []\n  filename = None\n  diff = []\n  for line in data.splitlines(True):\n    new_filename = None\n    if line.startswith('Index:'):\n      unused, new_filename = line.split(':', 1)\n      new_filename = new_filename.strip()\n    elif line.startswith('Property changes on:'):\n      unused, temp_filename = line.split(':', 1)\n      # When a file is modified, paths use '/' between directories, however\n      # when a property is modified '\\' is used on Windows.  Make them the same\n      # otherwise the file shows up twice.\n      temp_filename = temp_filename.strip().replace('\\\\', '/')\n      if temp_filename != filename:\n        # File has property changes but no modifications, create a new diff.\n        new_filename = temp_filename\n    if new_filename:\n      if filename and diff:\n        patches.append((filename, ''.join(diff)))\n      filename = new_filename\n      diff = [line]\n      continue\n    if diff is not None:\n      diff.append(line)\n  if filename and diff:\n    patches.append((filename, ''.join(diff)))\n  return patches\n\n\ndef UploadSeparatePatches(issue, rpc_server, patchset, data, options):\n  \"\"\"Uploads a separate patch for each file in the diff output.\n\n  Returns a list of [patch_key, filename] for each file.\n  \"\"\"\n  patches = SplitPatch(data)\n  rv = []\n  for patch in patches:\n    if len(patch[1]) > MAX_UPLOAD_SIZE:\n      print (\"Not uploading the patch for \" + patch[0] +\n             \" because the file is too large.\")\n      continue\n    form_fields = [(\"filename\", patch[0])]\n    if not options.download_base:\n      form_fields.append((\"content_upload\", \"1\"))\n    files = [(\"data\", \"data.diff\", patch[1])]\n    ctype, body = EncodeMultipartFormData(form_fields, files)\n    url = \"/%d/upload_patch/%d\" % (int(issue), int(patchset))\n    print \"Uploading patch for \" + patch[0]\n    response_body = rpc_server.Send(url, body, content_type=ctype)\n    lines = response_body.splitlines()\n    if not lines or lines[0] != \"OK\":\n      StatusUpdate(\"  --> %s\" % response_body)\n      sys.exit(1)\n    rv.append([lines[1], patch[0]])\n  return rv\n\n\ndef GuessVCS(options):\n  \"\"\"Helper to guess the version control system.\n\n  This examines the current directory, guesses which VersionControlSystem\n  we're using, and returns an instance of the appropriate class.  Exit with an\n  error if we can't figure it out.\n\n  Returns:\n    A VersionControlSystem instance. Exits if the VCS can't be guessed.\n  \"\"\"\n  # Mercurial has a command to get the base directory of a repository\n  # Try running it, but don't die if we don't have hg installed.\n  # NOTE: we try Mercurial first as it can sit on top of an SVN working copy.\n  try:\n    out, returncode = RunShellWithReturnCode([\"hg\", \"root\"])\n    if returncode == 0:\n      return MercurialVCS(options, out.strip())\n  except OSError, (errno, message):\n    if errno != 2:  # ENOENT -- they don't have hg installed.\n      raise\n\n  # Subversion has a .svn in all working directories.\n  if os.path.isdir('.svn'):\n    logging.info(\"Guessed VCS = Subversion\")\n    return SubversionVCS(options)\n\n  # Git has a command to test if you're in a git tree.\n  # Try running it, but don't die if we don't have git installed.\n  try:\n    out, returncode = RunShellWithReturnCode([\"git\", \"rev-parse\",\n                                              \"--is-inside-work-tree\"])\n    if returncode == 0:\n      return GitVCS(options)\n  except OSError, (errno, message):\n    if errno != 2:  # ENOENT -- they don't have git installed.\n      raise\n\n  ErrorExit((\"Could not guess version control system. \"\n             \"Are you in a working copy directory?\"))\n\n\ndef RealMain(argv, data=None):\n  \"\"\"The real main function.\n\n  Args:\n    argv: Command line arguments.\n    data: Diff contents. If None (default) the diff is generated by\n      the VersionControlSystem implementation returned by GuessVCS().\n\n  Returns:\n    A 2-tuple (issue id, patchset id).\n    The patchset id is None if the base files are not uploaded by this\n    script (applies only to SVN checkouts).\n  \"\"\"\n  logging.basicConfig(format=(\"%(asctime).19s %(levelname)s %(filename)s:\"\n                              \"%(lineno)s %(message)s \"))\n  os.environ['LC_ALL'] = 'C'\n  options, args = parser.parse_args(argv[1:])\n  global verbosity\n  verbosity = options.verbose\n  if verbosity >= 3:\n    logging.getLogger().setLevel(logging.DEBUG)\n  elif verbosity >= 2:\n    logging.getLogger().setLevel(logging.INFO)\n  vcs = GuessVCS(options)\n  if isinstance(vcs, SubversionVCS):\n    # base field is only allowed for Subversion.\n    # Note: Fetching base files may become deprecated in future releases.\n    base = vcs.GuessBase(options.download_base)\n  else:\n    base = None\n  if not base and options.download_base:\n    options.download_base = True\n    logging.info(\"Enabled upload of base file\")\n  if not options.assume_yes:\n    vcs.CheckForUnknownFiles()\n  if data is None:\n    data = vcs.GenerateDiff(args)\n  files = vcs.GetBaseFiles(data)\n  if verbosity >= 1:\n    print \"Upload server:\", options.server, \"(change with -s/--server)\"\n  if options.issue:\n    prompt = \"Message describing this patch set: \"\n  else:\n    prompt = \"New issue subject: \"\n  message = options.message or raw_input(prompt).strip()\n  if not message:\n    ErrorExit(\"A non-empty message is required\")\n  rpc_server = GetRpcServer(options)\n  form_fields = [(\"subject\", message)]\n  if base:\n    form_fields.append((\"base\", base))\n  if options.issue:\n    form_fields.append((\"issue\", str(options.issue)))\n  if options.email:\n    form_fields.append((\"user\", options.email))\n  if options.reviewers:\n    for reviewer in options.reviewers.split(','):\n      if \"@\" in reviewer and not reviewer.split(\"@\")[1].count(\".\") == 1:\n        ErrorExit(\"Invalid email address: %s\" % reviewer)\n    form_fields.append((\"reviewers\", options.reviewers))\n  if options.cc:\n    for cc in options.cc.split(','):\n      if \"@\" in cc and not cc.split(\"@\")[1].count(\".\") == 1:\n        ErrorExit(\"Invalid email address: %s\" % cc)\n    form_fields.append((\"cc\", options.cc))\n  description = options.description\n  if options.description_file:\n    if options.description:\n      ErrorExit(\"Can't specify description and description_file\")\n    file = open(options.description_file, 'r')\n    description = file.read()\n    file.close()\n  if description:\n    form_fields.append((\"description\", description))\n  # Send a hash of all the base file so the server can determine if a copy\n  # already exists in an earlier patchset.\n  base_hashes = \"\"\n  for file, info in files.iteritems():\n    if not info[0] is None:\n      checksum = md5.new(info[0]).hexdigest()\n      if base_hashes:\n        base_hashes += \"|\"\n      base_hashes += checksum + \":\" + file\n  form_fields.append((\"base_hashes\", base_hashes))\n  # If we're uploading base files, don't send the email before the uploads, so\n  # that it contains the file status.\n  if options.send_mail and options.download_base:\n    form_fields.append((\"send_mail\", \"1\"))\n  if not options.download_base:\n    form_fields.append((\"content_upload\", \"1\"))\n  if len(data) > MAX_UPLOAD_SIZE:\n    print \"Patch is large, so uploading file patches separately.\"\n    uploaded_diff_file = []\n    form_fields.append((\"separate_patches\", \"1\"))\n  else:\n    uploaded_diff_file = [(\"data\", \"data.diff\", data)]\n  ctype, body = EncodeMultipartFormData(form_fields, uploaded_diff_file)\n  response_body = rpc_server.Send(\"/upload\", body, content_type=ctype)\n  patchset = None\n  if not options.download_base or not uploaded_diff_file:\n    lines = response_body.splitlines()\n    if len(lines) >= 2:\n      msg = lines[0]\n      patchset = lines[1].strip()\n      patches = [x.split(\" \", 1) for x in lines[2:]]\n    else:\n      msg = response_body\n  else:\n    msg = response_body\n  StatusUpdate(msg)\n  if not response_body.startswith(\"Issue created.\") and \\\n  not response_body.startswith(\"Issue updated.\"):\n    sys.exit(0)\n  issue = msg[msg.rfind(\"/\")+1:]\n\n  if not uploaded_diff_file:\n    result = UploadSeparatePatches(issue, rpc_server, patchset, data, options)\n    if not options.download_base:\n      patches = result\n\n  if not options.download_base:\n    vcs.UploadBaseFiles(issue, rpc_server, patches, patchset, options, files)\n    if options.send_mail:\n      rpc_server.Send(\"/\" + issue + \"/mail\", payload=\"\")\n  return issue, patchset\n\n\ndef main():\n  try:\n    RealMain(sys.argv)\n  except KeyboardInterrupt:\n    print\n    StatusUpdate(\"Interrupted.\")\n    sys.exit(1)\n\n\nif __name__ == \"__main__\":\n  main()\n"
  },
  {
    "path": "utils/googletest/googletest/scripts/upload_gtest.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2009, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"upload_gtest.py v0.1.0 -- uploads a Google Test patch for review.\n\nThis simple wrapper passes all command line flags and\n--cc=googletestframework@googlegroups.com to upload.py.\n\nUSAGE: upload_gtest.py [options for upload.py]\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport sys\n\nCC_FLAG = '--cc='\nGTEST_GROUP = 'googletestframework@googlegroups.com'\n\n\ndef main():\n  # Finds the path to upload.py, assuming it is in the same directory\n  # as this file.\n  my_dir = os.path.dirname(os.path.abspath(__file__))\n  upload_py_path = os.path.join(my_dir, 'upload.py')\n\n  # Adds Google Test discussion group to the cc line if it's not there\n  # already.\n  upload_py_argv = [upload_py_path]\n  found_cc_flag = False\n  for arg in sys.argv[1:]:\n    if arg.startswith(CC_FLAG):\n      found_cc_flag = True\n      cc_line = arg[len(CC_FLAG):]\n      cc_list = [addr for addr in cc_line.split(',') if addr]\n      if GTEST_GROUP not in cc_list:\n        cc_list.append(GTEST_GROUP)\n      upload_py_argv.append(CC_FLAG + ','.join(cc_list))\n    else:\n      upload_py_argv.append(arg)\n\n  if not found_cc_flag:\n    upload_py_argv.append(CC_FLAG + GTEST_GROUP)\n\n  # Invokes upload.py with the modified command line flags.\n  os.execv(upload_py_path, upload_py_argv)\n\n\nif __name__ == '__main__':\n  main()\n"
  },
  {
    "path": "utils/googletest/googletest/src/gtest-all.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: mheule@google.com (Markus Heule)\n//\n// Google C++ Testing Framework (Google Test)\n//\n// Sometimes it's desirable to build Google Test by compiling a single file.\n// This file serves this purpose.\n\n// This line ensures that gtest.h can be compiled on its own, even\n// when it's fused.\n#include \"gtest/gtest.h\"\n\n// The following lines pull in the real gtest *.cc files.\n#include \"src/gtest.cc\"\n#include \"src/gtest-death-test.cc\"\n#include \"src/gtest-filepath.cc\"\n#include \"src/gtest-port.cc\"\n#include \"src/gtest-printers.cc\"\n#include \"src/gtest-test-part.cc\"\n#include \"src/gtest-typed-test.cc\"\n"
  },
  {
    "path": "utils/googletest/googletest/src/gtest-death-test.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev)\n//\n// This file implements death tests.\n\n#include \"gtest/gtest-death-test.h\"\n#include \"gtest/internal/gtest-port.h\"\n#include \"gtest/internal/custom/gtest.h\"\n\n#if GTEST_HAS_DEATH_TEST\n\n# if GTEST_OS_MAC\n#  include <crt_externs.h>\n# endif  // GTEST_OS_MAC\n\n# include <errno.h>\n# include <fcntl.h>\n# include <limits.h>\n\n# if GTEST_OS_LINUX\n#  include <signal.h>\n# endif  // GTEST_OS_LINUX\n\n# include <stdarg.h>\n\n# if GTEST_OS_WINDOWS\n#  include <windows.h>\n# else\n#  include <sys/mman.h>\n#  include <sys/wait.h>\n# endif  // GTEST_OS_WINDOWS\n\n# if GTEST_OS_QNX\n#  include <spawn.h>\n# endif  // GTEST_OS_QNX\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n#include \"gtest/gtest-message.h\"\n#include \"gtest/internal/gtest-string.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick exists to\n// prevent the accidental inclusion of gtest-internal-inl.h in the\n// user's code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nnamespace testing {\n\n// Constants.\n\n// The default death test style.\nstatic const char kDefaultDeathTestStyle[] = \"fast\";\n\nGTEST_DEFINE_string_(\n    death_test_style,\n    internal::StringFromGTestEnv(\"death_test_style\", kDefaultDeathTestStyle),\n    \"Indicates how to run a death test in a forked child process: \"\n    \"\\\"threadsafe\\\" (child process re-executes the test binary \"\n    \"from the beginning, running only the specific death test) or \"\n    \"\\\"fast\\\" (child process runs the death test immediately \"\n    \"after forking).\");\n\nGTEST_DEFINE_bool_(\n    death_test_use_fork,\n    internal::BoolFromGTestEnv(\"death_test_use_fork\", false),\n    \"Instructs to use fork()/_exit() instead of clone() in death tests. \"\n    \"Ignored and always uses fork() on POSIX systems where clone() is not \"\n    \"implemented. Useful when running under valgrind or similar tools if \"\n    \"those do not support clone(). Valgrind 3.3.1 will just fail if \"\n    \"it sees an unsupported combination of clone() flags. \"\n    \"It is not recommended to use this flag w/o valgrind though it will \"\n    \"work in 99% of the cases. Once valgrind is fixed, this flag will \"\n    \"most likely be removed.\");\n\nnamespace internal {\nGTEST_DEFINE_string_(\n    internal_run_death_test, \"\",\n    \"Indicates the file, line number, temporal index of \"\n    \"the single death test to run, and a file descriptor to \"\n    \"which a success code may be sent, all separated by \"\n    \"the '|' characters.  This flag is specified if and only if the current \"\n    \"process is a sub-process launched for running a thread-safe \"\n    \"death test.  FOR INTERNAL USE ONLY.\");\n}  // namespace internal\n\n#if GTEST_HAS_DEATH_TEST\n\nnamespace internal {\n\n// Valid only for fast death tests. Indicates the code is running in the\n// child process of a fast style death test.\n# if !GTEST_OS_WINDOWS\nstatic bool g_in_fast_death_test_child = false;\n# endif\n\n// Returns a Boolean value indicating whether the caller is currently\n// executing in the context of the death test child process.  Tools such as\n// Valgrind heap checkers may need this to modify their behavior in death\n// tests.  IMPORTANT: This is an internal utility.  Using it may break the\n// implementation of death tests.  User code MUST NOT use it.\nbool InDeathTestChild() {\n# if GTEST_OS_WINDOWS\n\n  // On Windows, death tests are thread-safe regardless of the value of the\n  // death_test_style flag.\n  return !GTEST_FLAG(internal_run_death_test).empty();\n\n# else\n\n  if (GTEST_FLAG(death_test_style) == \"threadsafe\")\n    return !GTEST_FLAG(internal_run_death_test).empty();\n  else\n    return g_in_fast_death_test_child;\n#endif\n}\n\n}  // namespace internal\n\n// ExitedWithCode constructor.\nExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) {\n}\n\n// ExitedWithCode function-call operator.\nbool ExitedWithCode::operator()(int exit_status) const {\n# if GTEST_OS_WINDOWS\n\n  return exit_status == exit_code_;\n\n# else\n\n  return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_;\n\n# endif  // GTEST_OS_WINDOWS\n}\n\n# if !GTEST_OS_WINDOWS\n// KilledBySignal constructor.\nKilledBySignal::KilledBySignal(int signum) : signum_(signum) {\n}\n\n// KilledBySignal function-call operator.\nbool KilledBySignal::operator()(int exit_status) const {\n#  if defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_)\n  {\n    bool result;\n    if (GTEST_KILLED_BY_SIGNAL_OVERRIDE_(signum_, exit_status, &result)) {\n      return result;\n    }\n  }\n#  endif  // defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_)\n  return WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_;\n}\n# endif  // !GTEST_OS_WINDOWS\n\nnamespace internal {\n\n// Utilities needed for death tests.\n\n// Generates a textual description of a given exit code, in the format\n// specified by wait(2).\nstatic std::string ExitSummary(int exit_code) {\n  Message m;\n\n# if GTEST_OS_WINDOWS\n\n  m << \"Exited with exit status \" << exit_code;\n\n# else\n\n  if (WIFEXITED(exit_code)) {\n    m << \"Exited with exit status \" << WEXITSTATUS(exit_code);\n  } else if (WIFSIGNALED(exit_code)) {\n    m << \"Terminated by signal \" << WTERMSIG(exit_code);\n  }\n#  ifdef WCOREDUMP\n  if (WCOREDUMP(exit_code)) {\n    m << \" (core dumped)\";\n  }\n#  endif\n# endif  // GTEST_OS_WINDOWS\n\n  return m.GetString();\n}\n\n// Returns true if exit_status describes a process that was terminated\n// by a signal, or exited normally with a nonzero exit code.\nbool ExitedUnsuccessfully(int exit_status) {\n  return !ExitedWithCode(0)(exit_status);\n}\n\n# if !GTEST_OS_WINDOWS\n// Generates a textual failure message when a death test finds more than\n// one thread running, or cannot determine the number of threads, prior\n// to executing the given statement.  It is the responsibility of the\n// caller not to pass a thread_count of 1.\nstatic std::string DeathTestThreadWarning(size_t thread_count) {\n  Message msg;\n  msg << \"Death tests use fork(), which is unsafe particularly\"\n      << \" in a threaded context. For this test, \" << GTEST_NAME_ << \" \";\n  if (thread_count == 0)\n    msg << \"couldn't detect the number of threads.\";\n  else\n    msg << \"detected \" << thread_count << \" threads.\";\n  return msg.GetString();\n}\n# endif  // !GTEST_OS_WINDOWS\n\n// Flag characters for reporting a death test that did not die.\nstatic const char kDeathTestLived = 'L';\nstatic const char kDeathTestReturned = 'R';\nstatic const char kDeathTestThrew = 'T';\nstatic const char kDeathTestInternalError = 'I';\n\n// An enumeration describing all of the possible ways that a death test can\n// conclude.  DIED means that the process died while executing the test\n// code; LIVED means that process lived beyond the end of the test code;\n// RETURNED means that the test statement attempted to execute a return\n// statement, which is not allowed; THREW means that the test statement\n// returned control by throwing an exception.  IN_PROGRESS means the test\n// has not yet concluded.\n// TODO(vladl@google.com): Unify names and possibly values for\n// AbortReason, DeathTestOutcome, and flag characters above.\nenum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW };\n\n// Routine for aborting the program which is safe to call from an\n// exec-style death test child process, in which case the error\n// message is propagated back to the parent process.  Otherwise, the\n// message is simply printed to stderr.  In either case, the program\n// then exits with status 1.\nvoid DeathTestAbort(const std::string& message) {\n  // On a POSIX system, this function may be called from a threadsafe-style\n  // death test child process, which operates on a very small stack.  Use\n  // the heap for any additional non-minuscule memory requirements.\n  const InternalRunDeathTestFlag* const flag =\n      GetUnitTestImpl()->internal_run_death_test_flag();\n  if (flag != NULL) {\n    FILE* parent = posix::FDOpen(flag->write_fd(), \"w\");\n    fputc(kDeathTestInternalError, parent);\n    fprintf(parent, \"%s\", message.c_str());\n    fflush(parent);\n    _exit(1);\n  } else {\n    fprintf(stderr, \"%s\", message.c_str());\n    fflush(stderr);\n    posix::Abort();\n  }\n}\n\n// A replacement for CHECK that calls DeathTestAbort if the assertion\n// fails.\n# define GTEST_DEATH_TEST_CHECK_(expression) \\\n  do { \\\n    if (!::testing::internal::IsTrue(expression)) { \\\n      DeathTestAbort( \\\n          ::std::string(\"CHECK failed: File \") + __FILE__ +  \", line \" \\\n          + ::testing::internal::StreamableToString(__LINE__) + \": \" \\\n          + #expression); \\\n    } \\\n  } while (::testing::internal::AlwaysFalse())\n\n// This macro is similar to GTEST_DEATH_TEST_CHECK_, but it is meant for\n// evaluating any system call that fulfills two conditions: it must return\n// -1 on failure, and set errno to EINTR when it is interrupted and\n// should be tried again.  The macro expands to a loop that repeatedly\n// evaluates the expression as long as it evaluates to -1 and sets\n// errno to EINTR.  If the expression evaluates to -1 but errno is\n// something other than EINTR, DeathTestAbort is called.\n# define GTEST_DEATH_TEST_CHECK_SYSCALL_(expression) \\\n  do { \\\n    int gtest_retval; \\\n    do { \\\n      gtest_retval = (expression); \\\n    } while (gtest_retval == -1 && errno == EINTR); \\\n    if (gtest_retval == -1) { \\\n      DeathTestAbort( \\\n          ::std::string(\"CHECK failed: File \") + __FILE__ + \", line \" \\\n          + ::testing::internal::StreamableToString(__LINE__) + \": \" \\\n          + #expression + \" != -1\"); \\\n    } \\\n  } while (::testing::internal::AlwaysFalse())\n\n// Returns the message describing the last system error in errno.\nstd::string GetLastErrnoDescription() {\n    return errno == 0 ? \"\" : posix::StrError(errno);\n}\n\n// This is called from a death test parent process to read a failure\n// message from the death test child process and log it with the FATAL\n// severity. On Windows, the message is read from a pipe handle. On other\n// platforms, it is read from a file descriptor.\nstatic void FailFromInternalError(int fd) {\n  Message error;\n  char buffer[256];\n  int num_read;\n\n  do {\n    while ((num_read = posix::Read(fd, buffer, 255)) > 0) {\n      buffer[num_read] = '\\0';\n      error << buffer;\n    }\n  } while (num_read == -1 && errno == EINTR);\n\n  if (num_read == 0) {\n    GTEST_LOG_(FATAL) << error.GetString();\n  } else {\n    const int last_error = errno;\n    GTEST_LOG_(FATAL) << \"Error while reading death test internal: \"\n                      << GetLastErrnoDescription() << \" [\" << last_error << \"]\";\n  }\n}\n\n// Death test constructor.  Increments the running death test count\n// for the current test.\nDeathTest::DeathTest() {\n  TestInfo* const info = GetUnitTestImpl()->current_test_info();\n  if (info == NULL) {\n    DeathTestAbort(\"Cannot run a death test outside of a TEST or \"\n                   \"TEST_F construct\");\n  }\n}\n\n// Creates and returns a death test by dispatching to the current\n// death test factory.\nbool DeathTest::Create(const char* statement, const RE* regex,\n                       const char* file, int line, DeathTest** test) {\n  return GetUnitTestImpl()->death_test_factory()->Create(\n      statement, regex, file, line, test);\n}\n\nconst char* DeathTest::LastMessage() {\n  return last_death_test_message_.c_str();\n}\n\nvoid DeathTest::set_last_death_test_message(const std::string& message) {\n  last_death_test_message_ = message;\n}\n\nstd::string DeathTest::last_death_test_message_;\n\n// Provides cross platform implementation for some death functionality.\nclass DeathTestImpl : public DeathTest {\n protected:\n  DeathTestImpl(const char* a_statement, const RE* a_regex)\n      : statement_(a_statement),\n        regex_(a_regex),\n        spawned_(false),\n        status_(-1),\n        outcome_(IN_PROGRESS),\n        read_fd_(-1),\n        write_fd_(-1) {}\n\n  // read_fd_ is expected to be closed and cleared by a derived class.\n  ~DeathTestImpl() { GTEST_DEATH_TEST_CHECK_(read_fd_ == -1); }\n\n  void Abort(AbortReason reason);\n  virtual bool Passed(bool status_ok);\n\n  const char* statement() const { return statement_; }\n  const RE* regex() const { return regex_; }\n  bool spawned() const { return spawned_; }\n  void set_spawned(bool is_spawned) { spawned_ = is_spawned; }\n  int status() const { return status_; }\n  void set_status(int a_status) { status_ = a_status; }\n  DeathTestOutcome outcome() const { return outcome_; }\n  void set_outcome(DeathTestOutcome an_outcome) { outcome_ = an_outcome; }\n  int read_fd() const { return read_fd_; }\n  void set_read_fd(int fd) { read_fd_ = fd; }\n  int write_fd() const { return write_fd_; }\n  void set_write_fd(int fd) { write_fd_ = fd; }\n\n  // Called in the parent process only. Reads the result code of the death\n  // test child process via a pipe, interprets it to set the outcome_\n  // member, and closes read_fd_.  Outputs diagnostics and terminates in\n  // case of unexpected codes.\n  void ReadAndInterpretStatusByte();\n\n private:\n  // The textual content of the code this object is testing.  This class\n  // doesn't own this string and should not attempt to delete it.\n  const char* const statement_;\n  // The regular expression which test output must match.  DeathTestImpl\n  // doesn't own this object and should not attempt to delete it.\n  const RE* const regex_;\n  // True if the death test child process has been successfully spawned.\n  bool spawned_;\n  // The exit status of the child process.\n  int status_;\n  // How the death test concluded.\n  DeathTestOutcome outcome_;\n  // Descriptor to the read end of the pipe to the child process.  It is\n  // always -1 in the child process.  The child keeps its write end of the\n  // pipe in write_fd_.\n  int read_fd_;\n  // Descriptor to the child's write end of the pipe to the parent process.\n  // It is always -1 in the parent process.  The parent keeps its end of the\n  // pipe in read_fd_.\n  int write_fd_;\n};\n\n// Called in the parent process only. Reads the result code of the death\n// test child process via a pipe, interprets it to set the outcome_\n// member, and closes read_fd_.  Outputs diagnostics and terminates in\n// case of unexpected codes.\nvoid DeathTestImpl::ReadAndInterpretStatusByte() {\n  char flag;\n  int bytes_read;\n\n  // The read() here blocks until data is available (signifying the\n  // failure of the death test) or until the pipe is closed (signifying\n  // its success), so it's okay to call this in the parent before\n  // the child process has exited.\n  do {\n    bytes_read = posix::Read(read_fd(), &flag, 1);\n  } while (bytes_read == -1 && errno == EINTR);\n\n  if (bytes_read == 0) {\n    set_outcome(DIED);\n  } else if (bytes_read == 1) {\n    switch (flag) {\n      case kDeathTestReturned:\n        set_outcome(RETURNED);\n        break;\n      case kDeathTestThrew:\n        set_outcome(THREW);\n        break;\n      case kDeathTestLived:\n        set_outcome(LIVED);\n        break;\n      case kDeathTestInternalError:\n        FailFromInternalError(read_fd());  // Does not return.\n        break;\n      default:\n        GTEST_LOG_(FATAL) << \"Death test child process reported \"\n                          << \"unexpected status byte (\"\n                          << static_cast<unsigned int>(flag) << \")\";\n    }\n  } else {\n    GTEST_LOG_(FATAL) << \"Read from death test child process failed: \"\n                      << GetLastErrnoDescription();\n  }\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(read_fd()));\n  set_read_fd(-1);\n}\n\n// Signals that the death test code which should have exited, didn't.\n// Should be called only in a death test child process.\n// Writes a status byte to the child's status file descriptor, then\n// calls _exit(1).\nvoid DeathTestImpl::Abort(AbortReason reason) {\n  // The parent process considers the death test to be a failure if\n  // it finds any data in our pipe.  So, here we write a single flag byte\n  // to the pipe, then exit.\n  const char status_ch =\n      reason == TEST_DID_NOT_DIE ? kDeathTestLived :\n      reason == TEST_THREW_EXCEPTION ? kDeathTestThrew : kDeathTestReturned;\n\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1));\n  // We are leaking the descriptor here because on some platforms (i.e.,\n  // when built as Windows DLL), destructors of global objects will still\n  // run after calling _exit(). On such systems, write_fd_ will be\n  // indirectly closed from the destructor of UnitTestImpl, causing double\n  // close if it is also closed here. On debug configurations, double close\n  // may assert. As there are no in-process buffers to flush here, we are\n  // relying on the OS to close the descriptor after the process terminates\n  // when the destructors are not run.\n  _exit(1);  // Exits w/o any normal exit hooks (we were supposed to crash)\n}\n\n// Returns an indented copy of stderr output for a death test.\n// This makes distinguishing death test output lines from regular log lines\n// much easier.\nstatic ::std::string FormatDeathTestOutput(const ::std::string& output) {\n  ::std::string ret;\n  for (size_t at = 0; ; ) {\n    const size_t line_end = output.find('\\n', at);\n    ret += \"[  DEATH   ] \";\n    if (line_end == ::std::string::npos) {\n      ret += output.substr(at);\n      break;\n    }\n    ret += output.substr(at, line_end + 1 - at);\n    at = line_end + 1;\n  }\n  return ret;\n}\n\n// Assesses the success or failure of a death test, using both private\n// members which have previously been set, and one argument:\n//\n// Private data members:\n//   outcome:  An enumeration describing how the death test\n//             concluded: DIED, LIVED, THREW, or RETURNED.  The death test\n//             fails in the latter three cases.\n//   status:   The exit status of the child process. On *nix, it is in the\n//             in the format specified by wait(2). On Windows, this is the\n//             value supplied to the ExitProcess() API or a numeric code\n//             of the exception that terminated the program.\n//   regex:    A regular expression object to be applied to\n//             the test's captured standard error output; the death test\n//             fails if it does not match.\n//\n// Argument:\n//   status_ok: true if exit_status is acceptable in the context of\n//              this particular death test, which fails if it is false\n//\n// Returns true iff all of the above conditions are met.  Otherwise, the\n// first failing condition, in the order given above, is the one that is\n// reported. Also sets the last death test message string.\nbool DeathTestImpl::Passed(bool status_ok) {\n  if (!spawned())\n    return false;\n\n  const std::string error_message = GetCapturedStderr();\n\n  bool success = false;\n  Message buffer;\n\n  buffer << \"Death test: \" << statement() << \"\\n\";\n  switch (outcome()) {\n    case LIVED:\n      buffer << \"    Result: failed to die.\\n\"\n             << \" Error msg:\\n\" << FormatDeathTestOutput(error_message);\n      break;\n    case THREW:\n      buffer << \"    Result: threw an exception.\\n\"\n             << \" Error msg:\\n\" << FormatDeathTestOutput(error_message);\n      break;\n    case RETURNED:\n      buffer << \"    Result: illegal return in test statement.\\n\"\n             << \" Error msg:\\n\" << FormatDeathTestOutput(error_message);\n      break;\n    case DIED:\n      if (status_ok) {\n        const bool matched = RE::PartialMatch(error_message.c_str(), *regex());\n        if (matched) {\n          success = true;\n        } else {\n          buffer << \"    Result: died but not with expected error.\\n\"\n                 << \"  Expected: \" << regex()->pattern() << \"\\n\"\n                 << \"Actual msg:\\n\" << FormatDeathTestOutput(error_message);\n        }\n      } else {\n        buffer << \"    Result: died but not with expected exit code:\\n\"\n               << \"            \" << ExitSummary(status()) << \"\\n\"\n               << \"Actual msg:\\n\" << FormatDeathTestOutput(error_message);\n      }\n      break;\n    case IN_PROGRESS:\n    default:\n      GTEST_LOG_(FATAL)\n          << \"DeathTest::Passed somehow called before conclusion of test\";\n  }\n\n  DeathTest::set_last_death_test_message(buffer.GetString());\n  return success;\n}\n\n# if GTEST_OS_WINDOWS\n// WindowsDeathTest implements death tests on Windows. Due to the\n// specifics of starting new processes on Windows, death tests there are\n// always threadsafe, and Google Test considers the\n// --gtest_death_test_style=fast setting to be equivalent to\n// --gtest_death_test_style=threadsafe there.\n//\n// A few implementation notes:  Like the Linux version, the Windows\n// implementation uses pipes for child-to-parent communication. But due to\n// the specifics of pipes on Windows, some extra steps are required:\n//\n// 1. The parent creates a communication pipe and stores handles to both\n//    ends of it.\n// 2. The parent starts the child and provides it with the information\n//    necessary to acquire the handle to the write end of the pipe.\n// 3. The child acquires the write end of the pipe and signals the parent\n//    using a Windows event.\n// 4. Now the parent can release the write end of the pipe on its side. If\n//    this is done before step 3, the object's reference count goes down to\n//    0 and it is destroyed, preventing the child from acquiring it. The\n//    parent now has to release it, or read operations on the read end of\n//    the pipe will not return when the child terminates.\n// 5. The parent reads child's output through the pipe (outcome code and\n//    any possible error messages) from the pipe, and its stderr and then\n//    determines whether to fail the test.\n//\n// Note: to distinguish Win32 API calls from the local method and function\n// calls, the former are explicitly resolved in the global namespace.\n//\nclass WindowsDeathTest : public DeathTestImpl {\n public:\n  WindowsDeathTest(const char* a_statement,\n                   const RE* a_regex,\n                   const char* file,\n                   int line)\n      : DeathTestImpl(a_statement, a_regex), file_(file), line_(line) {}\n\n  // All of these virtual functions are inherited from DeathTest.\n  virtual int Wait();\n  virtual TestRole AssumeRole();\n\n private:\n  // The name of the file in which the death test is located.\n  const char* const file_;\n  // The line number on which the death test is located.\n  const int line_;\n  // Handle to the write end of the pipe to the child process.\n  AutoHandle write_handle_;\n  // Child process handle.\n  AutoHandle child_handle_;\n  // Event the child process uses to signal the parent that it has\n  // acquired the handle to the write end of the pipe. After seeing this\n  // event the parent can release its own handles to make sure its\n  // ReadFile() calls return when the child terminates.\n  AutoHandle event_handle_;\n};\n\n// Waits for the child in a death test to exit, returning its exit\n// status, or 0 if no child process exists.  As a side effect, sets the\n// outcome data member.\nint WindowsDeathTest::Wait() {\n  if (!spawned())\n    return 0;\n\n  // Wait until the child either signals that it has acquired the write end\n  // of the pipe or it dies.\n  const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() };\n  switch (::WaitForMultipleObjects(2,\n                                   wait_handles,\n                                   FALSE,  // Waits for any of the handles.\n                                   INFINITE)) {\n    case WAIT_OBJECT_0:\n    case WAIT_OBJECT_0 + 1:\n      break;\n    default:\n      GTEST_DEATH_TEST_CHECK_(false);  // Should not get here.\n  }\n\n  // The child has acquired the write end of the pipe or exited.\n  // We release the handle on our side and continue.\n  write_handle_.Reset();\n  event_handle_.Reset();\n\n  ReadAndInterpretStatusByte();\n\n  // Waits for the child process to exit if it haven't already. This\n  // returns immediately if the child has already exited, regardless of\n  // whether previous calls to WaitForMultipleObjects synchronized on this\n  // handle or not.\n  GTEST_DEATH_TEST_CHECK_(\n      WAIT_OBJECT_0 == ::WaitForSingleObject(child_handle_.Get(),\n                                             INFINITE));\n  DWORD status_code;\n  GTEST_DEATH_TEST_CHECK_(\n      ::GetExitCodeProcess(child_handle_.Get(), &status_code) != FALSE);\n  child_handle_.Reset();\n  set_status(static_cast<int>(status_code));\n  return status();\n}\n\n// The AssumeRole process for a Windows death test.  It creates a child\n// process with the same executable as the current process to run the\n// death test.  The child process is given the --gtest_filter and\n// --gtest_internal_run_death_test flags such that it knows to run the\n// current death test only.\nDeathTest::TestRole WindowsDeathTest::AssumeRole() {\n  const UnitTestImpl* const impl = GetUnitTestImpl();\n  const InternalRunDeathTestFlag* const flag =\n      impl->internal_run_death_test_flag();\n  const TestInfo* const info = impl->current_test_info();\n  const int death_test_index = info->result()->death_test_count();\n\n  if (flag != NULL) {\n    // ParseInternalRunDeathTestFlag() has performed all the necessary\n    // processing.\n    set_write_fd(flag->write_fd());\n    return EXECUTE_TEST;\n  }\n\n  // WindowsDeathTest uses an anonymous pipe to communicate results of\n  // a death test.\n  SECURITY_ATTRIBUTES handles_are_inheritable = {\n    sizeof(SECURITY_ATTRIBUTES), NULL, TRUE };\n  HANDLE read_handle, write_handle;\n  GTEST_DEATH_TEST_CHECK_(\n      ::CreatePipe(&read_handle, &write_handle, &handles_are_inheritable,\n                   0)  // Default buffer size.\n      != FALSE);\n  set_read_fd(::_open_osfhandle(reinterpret_cast<intptr_t>(read_handle),\n                                O_RDONLY));\n  write_handle_.Reset(write_handle);\n  event_handle_.Reset(::CreateEvent(\n      &handles_are_inheritable,\n      TRUE,    // The event will automatically reset to non-signaled state.\n      FALSE,   // The initial state is non-signalled.\n      NULL));  // The even is unnamed.\n  GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != NULL);\n  const std::string filter_flag =\n      std::string(\"--\") + GTEST_FLAG_PREFIX_ + kFilterFlag + \"=\" +\n      info->test_case_name() + \".\" + info->name();\n  const std::string internal_flag =\n      std::string(\"--\") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag +\n      \"=\" + file_ + \"|\" + StreamableToString(line_) + \"|\" +\n      StreamableToString(death_test_index) + \"|\" +\n      StreamableToString(static_cast<unsigned int>(::GetCurrentProcessId())) +\n      // size_t has the same width as pointers on both 32-bit and 64-bit\n      // Windows platforms.\n      // See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx.\n      \"|\" + StreamableToString(reinterpret_cast<size_t>(write_handle)) +\n      \"|\" + StreamableToString(reinterpret_cast<size_t>(event_handle_.Get()));\n\n  char executable_path[_MAX_PATH + 1];  // NOLINT\n  GTEST_DEATH_TEST_CHECK_(\n      _MAX_PATH + 1 != ::GetModuleFileNameA(NULL,\n                                            executable_path,\n                                            _MAX_PATH));\n\n  std::string command_line =\n      std::string(::GetCommandLineA()) + \" \" + filter_flag + \" \\\"\" +\n      internal_flag + \"\\\"\";\n\n  DeathTest::set_last_death_test_message(\"\");\n\n  CaptureStderr();\n  // Flush the log buffers since the log streams are shared with the child.\n  FlushInfoLog();\n\n  // The child process will share the standard handles with the parent.\n  STARTUPINFOA startup_info;\n  memset(&startup_info, 0, sizeof(STARTUPINFO));\n  startup_info.dwFlags = STARTF_USESTDHANDLES;\n  startup_info.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE);\n  startup_info.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE);\n  startup_info.hStdError = ::GetStdHandle(STD_ERROR_HANDLE);\n\n  PROCESS_INFORMATION process_info;\n  GTEST_DEATH_TEST_CHECK_(::CreateProcessA(\n      executable_path,\n      const_cast<char*>(command_line.c_str()),\n      NULL,   // Retuned process handle is not inheritable.\n      NULL,   // Retuned thread handle is not inheritable.\n      TRUE,   // Child inherits all inheritable handles (for write_handle_).\n      0x0,    // Default creation flags.\n      NULL,   // Inherit the parent's environment.\n      UnitTest::GetInstance()->original_working_dir(),\n      &startup_info,\n      &process_info) != FALSE);\n  child_handle_.Reset(process_info.hProcess);\n  ::CloseHandle(process_info.hThread);\n  set_spawned(true);\n  return OVERSEE_TEST;\n}\n# else  // We are not on Windows.\n\n// ForkingDeathTest provides implementations for most of the abstract\n// methods of the DeathTest interface.  Only the AssumeRole method is\n// left undefined.\nclass ForkingDeathTest : public DeathTestImpl {\n public:\n  ForkingDeathTest(const char* statement, const RE* regex);\n\n  // All of these virtual functions are inherited from DeathTest.\n  virtual int Wait();\n\n protected:\n  void set_child_pid(pid_t child_pid) { child_pid_ = child_pid; }\n\n private:\n  // PID of child process during death test; 0 in the child process itself.\n  pid_t child_pid_;\n};\n\n// Constructs a ForkingDeathTest.\nForkingDeathTest::ForkingDeathTest(const char* a_statement, const RE* a_regex)\n    : DeathTestImpl(a_statement, a_regex),\n      child_pid_(-1) {}\n\n// Waits for the child in a death test to exit, returning its exit\n// status, or 0 if no child process exists.  As a side effect, sets the\n// outcome data member.\nint ForkingDeathTest::Wait() {\n  if (!spawned())\n    return 0;\n\n  ReadAndInterpretStatusByte();\n\n  int status_value;\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(waitpid(child_pid_, &status_value, 0));\n  set_status(status_value);\n  return status_value;\n}\n\n// A concrete death test class that forks, then immediately runs the test\n// in the child process.\nclass NoExecDeathTest : public ForkingDeathTest {\n public:\n  NoExecDeathTest(const char* a_statement, const RE* a_regex) :\n      ForkingDeathTest(a_statement, a_regex) { }\n  virtual TestRole AssumeRole();\n};\n\n// The AssumeRole process for a fork-and-run death test.  It implements a\n// straightforward fork, with a simple pipe to transmit the status byte.\nDeathTest::TestRole NoExecDeathTest::AssumeRole() {\n  const size_t thread_count = GetThreadCount();\n  if (thread_count != 1) {\n    GTEST_LOG_(WARNING) << DeathTestThreadWarning(thread_count);\n  }\n\n  int pipe_fd[2];\n  GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1);\n\n  DeathTest::set_last_death_test_message(\"\");\n  CaptureStderr();\n  // When we fork the process below, the log file buffers are copied, but the\n  // file descriptors are shared.  We flush all log files here so that closing\n  // the file descriptors in the child process doesn't throw off the\n  // synchronization between descriptors and buffers in the parent process.\n  // This is as close to the fork as possible to avoid a race condition in case\n  // there are multiple threads running before the death test, and another\n  // thread writes to the log file.\n  FlushInfoLog();\n\n  const pid_t child_pid = fork();\n  GTEST_DEATH_TEST_CHECK_(child_pid != -1);\n  set_child_pid(child_pid);\n  if (child_pid == 0) {\n    GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[0]));\n    set_write_fd(pipe_fd[1]);\n    // Redirects all logging to stderr in the child process to prevent\n    // concurrent writes to the log files.  We capture stderr in the parent\n    // process and append the child process' output to a log.\n    LogToStderr();\n    // Event forwarding to the listeners of event listener API mush be shut\n    // down in death test subprocesses.\n    GetUnitTestImpl()->listeners()->SuppressEventForwarding();\n    g_in_fast_death_test_child = true;\n    return EXECUTE_TEST;\n  } else {\n    GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));\n    set_read_fd(pipe_fd[0]);\n    set_spawned(true);\n    return OVERSEE_TEST;\n  }\n}\n\n// A concrete death test class that forks and re-executes the main\n// program from the beginning, with command-line flags set that cause\n// only this specific death test to be run.\nclass ExecDeathTest : public ForkingDeathTest {\n public:\n  ExecDeathTest(const char* a_statement, const RE* a_regex,\n                const char* file, int line) :\n      ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { }\n  virtual TestRole AssumeRole();\n private:\n  static ::std::vector<testing::internal::string>\n  GetArgvsForDeathTestChildProcess() {\n    ::std::vector<testing::internal::string> args = GetInjectableArgvs();\n#  if defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_)\n    ::std::vector<testing::internal::string> extra_args =\n        GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_();\n    args.insert(args.end(), extra_args.begin(), extra_args.end());\n#  endif  // defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_)\n    return args;\n  }\n  // The name of the file in which the death test is located.\n  const char* const file_;\n  // The line number on which the death test is located.\n  const int line_;\n};\n\n// Utility class for accumulating command-line arguments.\nclass Arguments {\n public:\n  Arguments() {\n    args_.push_back(NULL);\n  }\n\n  ~Arguments() {\n    for (std::vector<char*>::iterator i = args_.begin(); i != args_.end();\n         ++i) {\n      free(*i);\n    }\n  }\n  void AddArgument(const char* argument) {\n    args_.insert(args_.end() - 1, posix::StrDup(argument));\n  }\n\n  template <typename Str>\n  void AddArguments(const ::std::vector<Str>& arguments) {\n    for (typename ::std::vector<Str>::const_iterator i = arguments.begin();\n         i != arguments.end();\n         ++i) {\n      args_.insert(args_.end() - 1, posix::StrDup(i->c_str()));\n    }\n  }\n  char* const* Argv() {\n    return &args_[0];\n  }\n\n private:\n  std::vector<char*> args_;\n};\n\n// A struct that encompasses the arguments to the child process of a\n// threadsafe-style death test process.\nstruct ExecDeathTestArgs {\n  char* const* argv;  // Command-line arguments for the child's call to exec\n  int close_fd;       // File descriptor to close; the read end of a pipe\n};\n\n#  if GTEST_OS_MAC\ninline char** GetEnviron() {\n  // When Google Test is built as a framework on MacOS X, the environ variable\n  // is unavailable. Apple's documentation (man environ) recommends using\n  // _NSGetEnviron() instead.\n  return *_NSGetEnviron();\n}\n#  else\n// Some POSIX platforms expect you to declare environ. extern \"C\" makes\n// it reside in the global namespace.\nextern \"C\" char** environ;\ninline char** GetEnviron() { return environ; }\n#  endif  // GTEST_OS_MAC\n\n#  if !GTEST_OS_QNX\n// The main function for a threadsafe-style death test child process.\n// This function is called in a clone()-ed process and thus must avoid\n// any potentially unsafe operations like malloc or libc functions.\nstatic int ExecDeathTestChildMain(void* child_arg) {\n  ExecDeathTestArgs* const args = static_cast<ExecDeathTestArgs*>(child_arg);\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(args->close_fd));\n\n  // We need to execute the test program in the same environment where\n  // it was originally invoked.  Therefore we change to the original\n  // working directory first.\n  const char* const original_dir =\n      UnitTest::GetInstance()->original_working_dir();\n  // We can safely call chdir() as it's a direct system call.\n  if (chdir(original_dir) != 0) {\n    DeathTestAbort(std::string(\"chdir(\\\"\") + original_dir + \"\\\") failed: \" +\n                   GetLastErrnoDescription());\n    return EXIT_FAILURE;\n  }\n\n  // We can safely call execve() as it's a direct system call.  We\n  // cannot use execvp() as it's a libc function and thus potentially\n  // unsafe.  Since execve() doesn't search the PATH, the user must\n  // invoke the test program via a valid path that contains at least\n  // one path separator.\n  execve(args->argv[0], args->argv, GetEnviron());\n  DeathTestAbort(std::string(\"execve(\") + args->argv[0] + \", ...) in \" +\n                 original_dir + \" failed: \" +\n                 GetLastErrnoDescription());\n  return EXIT_FAILURE;\n}\n#  endif  // !GTEST_OS_QNX\n\n// Two utility routines that together determine the direction the stack\n// grows.\n// This could be accomplished more elegantly by a single recursive\n// function, but we want to guard against the unlikely possibility of\n// a smart compiler optimizing the recursion away.\n//\n// GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining\n// StackLowerThanAddress into StackGrowsDown, which then doesn't give\n// correct answer.\nvoid StackLowerThanAddress(const void* ptr, bool* result) GTEST_NO_INLINE_;\nvoid StackLowerThanAddress(const void* ptr, bool* result) {\n  int dummy;\n  *result = (&dummy < ptr);\n}\n\n// Make sure AddressSanitizer does not tamper with the stack here.\nGTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_\nbool StackGrowsDown() {\n  int dummy;\n  bool result;\n  StackLowerThanAddress(&dummy, &result);\n  return result;\n}\n\n// Spawns a child process with the same executable as the current process in\n// a thread-safe manner and instructs it to run the death test.  The\n// implementation uses fork(2) + exec.  On systems where clone(2) is\n// available, it is used instead, being slightly more thread-safe.  On QNX,\n// fork supports only single-threaded environments, so this function uses\n// spawn(2) there instead.  The function dies with an error message if\n// anything goes wrong.\nstatic pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {\n  ExecDeathTestArgs args = { argv, close_fd };\n  pid_t child_pid = -1;\n\n#  if GTEST_OS_QNX\n  // Obtains the current directory and sets it to be closed in the child\n  // process.\n  const int cwd_fd = open(\".\", O_RDONLY);\n  GTEST_DEATH_TEST_CHECK_(cwd_fd != -1);\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(cwd_fd, F_SETFD, FD_CLOEXEC));\n  // We need to execute the test program in the same environment where\n  // it was originally invoked.  Therefore we change to the original\n  // working directory first.\n  const char* const original_dir =\n      UnitTest::GetInstance()->original_working_dir();\n  // We can safely call chdir() as it's a direct system call.\n  if (chdir(original_dir) != 0) {\n    DeathTestAbort(std::string(\"chdir(\\\"\") + original_dir + \"\\\") failed: \" +\n                   GetLastErrnoDescription());\n    return EXIT_FAILURE;\n  }\n\n  int fd_flags;\n  // Set close_fd to be closed after spawn.\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(fd_flags = fcntl(close_fd, F_GETFD));\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(close_fd, F_SETFD,\n                                        fd_flags | FD_CLOEXEC));\n  struct inheritance inherit = {0};\n  // spawn is a system call.\n  child_pid = spawn(args.argv[0], 0, NULL, &inherit, args.argv, GetEnviron());\n  // Restores the current working directory.\n  GTEST_DEATH_TEST_CHECK_(fchdir(cwd_fd) != -1);\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(cwd_fd));\n\n#  else   // GTEST_OS_QNX\n#   if GTEST_OS_LINUX\n  // When a SIGPROF signal is received while fork() or clone() are executing,\n  // the process may hang. To avoid this, we ignore SIGPROF here and re-enable\n  // it after the call to fork()/clone() is complete.\n  struct sigaction saved_sigprof_action;\n  struct sigaction ignore_sigprof_action;\n  memset(&ignore_sigprof_action, 0, sizeof(ignore_sigprof_action));\n  sigemptyset(&ignore_sigprof_action.sa_mask);\n  ignore_sigprof_action.sa_handler = SIG_IGN;\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(sigaction(\n      SIGPROF, &ignore_sigprof_action, &saved_sigprof_action));\n#   endif  // GTEST_OS_LINUX\n\n#   if GTEST_HAS_CLONE\n  const bool use_fork = GTEST_FLAG(death_test_use_fork);\n\n  if (!use_fork) {\n    static const bool stack_grows_down = StackGrowsDown();\n    const size_t stack_size = getpagesize();\n    // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead.\n    void* const stack = mmap(NULL, stack_size, PROT_READ | PROT_WRITE,\n                             MAP_ANON | MAP_PRIVATE, -1, 0);\n    GTEST_DEATH_TEST_CHECK_(stack != MAP_FAILED);\n\n    // Maximum stack alignment in bytes:  For a downward-growing stack, this\n    // amount is subtracted from size of the stack space to get an address\n    // that is within the stack space and is aligned on all systems we care\n    // about.  As far as I know there is no ABI with stack alignment greater\n    // than 64.  We assume stack and stack_size already have alignment of\n    // kMaxStackAlignment.\n    const size_t kMaxStackAlignment = 64;\n    void* const stack_top =\n        static_cast<char*>(stack) +\n            (stack_grows_down ? stack_size - kMaxStackAlignment : 0);\n    GTEST_DEATH_TEST_CHECK_(stack_size > kMaxStackAlignment &&\n        reinterpret_cast<intptr_t>(stack_top) % kMaxStackAlignment == 0);\n\n    child_pid = clone(&ExecDeathTestChildMain, stack_top, SIGCHLD, &args);\n\n    GTEST_DEATH_TEST_CHECK_(munmap(stack, stack_size) != -1);\n  }\n#   else\n  const bool use_fork = true;\n#   endif  // GTEST_HAS_CLONE\n\n  if (use_fork && (child_pid = fork()) == 0) {\n      ExecDeathTestChildMain(&args);\n      _exit(0);\n  }\n#  endif  // GTEST_OS_QNX\n#  if GTEST_OS_LINUX\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(\n      sigaction(SIGPROF, &saved_sigprof_action, NULL));\n#  endif  // GTEST_OS_LINUX\n\n  GTEST_DEATH_TEST_CHECK_(child_pid != -1);\n  return child_pid;\n}\n\n// The AssumeRole process for a fork-and-exec death test.  It re-executes the\n// main program from the beginning, setting the --gtest_filter\n// and --gtest_internal_run_death_test flags to cause only the current\n// death test to be re-run.\nDeathTest::TestRole ExecDeathTest::AssumeRole() {\n  const UnitTestImpl* const impl = GetUnitTestImpl();\n  const InternalRunDeathTestFlag* const flag =\n      impl->internal_run_death_test_flag();\n  const TestInfo* const info = impl->current_test_info();\n  const int death_test_index = info->result()->death_test_count();\n\n  if (flag != NULL) {\n    set_write_fd(flag->write_fd());\n    return EXECUTE_TEST;\n  }\n\n  int pipe_fd[2];\n  GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1);\n  // Clear the close-on-exec flag on the write end of the pipe, lest\n  // it be closed when the child process does an exec:\n  GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1);\n\n  const std::string filter_flag =\n      std::string(\"--\") + GTEST_FLAG_PREFIX_ + kFilterFlag + \"=\"\n      + info->test_case_name() + \".\" + info->name();\n  const std::string internal_flag =\n      std::string(\"--\") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + \"=\"\n      + file_ + \"|\" + StreamableToString(line_) + \"|\"\n      + StreamableToString(death_test_index) + \"|\"\n      + StreamableToString(pipe_fd[1]);\n  Arguments args;\n  args.AddArguments(GetArgvsForDeathTestChildProcess());\n  args.AddArgument(filter_flag.c_str());\n  args.AddArgument(internal_flag.c_str());\n\n  DeathTest::set_last_death_test_message(\"\");\n\n  CaptureStderr();\n  // See the comment in NoExecDeathTest::AssumeRole for why the next line\n  // is necessary.\n  FlushInfoLog();\n\n  const pid_t child_pid = ExecDeathTestSpawnChild(args.Argv(), pipe_fd[0]);\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));\n  set_child_pid(child_pid);\n  set_read_fd(pipe_fd[0]);\n  set_spawned(true);\n  return OVERSEE_TEST;\n}\n\n# endif  // !GTEST_OS_WINDOWS\n\n// Creates a concrete DeathTest-derived class that depends on the\n// --gtest_death_test_style flag, and sets the pointer pointed to\n// by the \"test\" argument to its address.  If the test should be\n// skipped, sets that pointer to NULL.  Returns true, unless the\n// flag is set to an invalid value.\nbool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,\n                                     const char* file, int line,\n                                     DeathTest** test) {\n  UnitTestImpl* const impl = GetUnitTestImpl();\n  const InternalRunDeathTestFlag* const flag =\n      impl->internal_run_death_test_flag();\n  const int death_test_index = impl->current_test_info()\n      ->increment_death_test_count();\n\n  if (flag != NULL) {\n    if (death_test_index > flag->index()) {\n      DeathTest::set_last_death_test_message(\n          \"Death test count (\" + StreamableToString(death_test_index)\n          + \") somehow exceeded expected maximum (\"\n          + StreamableToString(flag->index()) + \")\");\n      return false;\n    }\n\n    if (!(flag->file() == file && flag->line() == line &&\n          flag->index() == death_test_index)) {\n      *test = NULL;\n      return true;\n    }\n  }\n\n# if GTEST_OS_WINDOWS\n\n  if (GTEST_FLAG(death_test_style) == \"threadsafe\" ||\n      GTEST_FLAG(death_test_style) == \"fast\") {\n    *test = new WindowsDeathTest(statement, regex, file, line);\n  }\n\n# else\n\n  if (GTEST_FLAG(death_test_style) == \"threadsafe\") {\n    *test = new ExecDeathTest(statement, regex, file, line);\n  } else if (GTEST_FLAG(death_test_style) == \"fast\") {\n    *test = new NoExecDeathTest(statement, regex);\n  }\n\n# endif  // GTEST_OS_WINDOWS\n\n  else {  // NOLINT - this is more readable than unbalanced brackets inside #if.\n    DeathTest::set_last_death_test_message(\n        \"Unknown death test style \\\"\" + GTEST_FLAG(death_test_style)\n        + \"\\\" encountered\");\n    return false;\n  }\n\n  return true;\n}\n\n# if GTEST_OS_WINDOWS\n// Recreates the pipe and event handles from the provided parameters,\n// signals the event, and returns a file descriptor wrapped around the pipe\n// handle. This function is called in the child process only.\nint GetStatusFileDescriptor(unsigned int parent_process_id,\n                            size_t write_handle_as_size_t,\n                            size_t event_handle_as_size_t) {\n  AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE,\n                                                   FALSE,  // Non-inheritable.\n                                                   parent_process_id));\n  if (parent_process_handle.Get() == INVALID_HANDLE_VALUE) {\n    DeathTestAbort(\"Unable to open parent process \" +\n                   StreamableToString(parent_process_id));\n  }\n\n  // TODO(vladl@google.com): Replace the following check with a\n  // compile-time assertion when available.\n  GTEST_CHECK_(sizeof(HANDLE) <= sizeof(size_t));\n\n  const HANDLE write_handle =\n      reinterpret_cast<HANDLE>(write_handle_as_size_t);\n  HANDLE dup_write_handle;\n\n  // The newly initialized handle is accessible only in in the parent\n  // process. To obtain one accessible within the child, we need to use\n  // DuplicateHandle.\n  if (!::DuplicateHandle(parent_process_handle.Get(), write_handle,\n                         ::GetCurrentProcess(), &dup_write_handle,\n                         0x0,    // Requested privileges ignored since\n                                 // DUPLICATE_SAME_ACCESS is used.\n                         FALSE,  // Request non-inheritable handler.\n                         DUPLICATE_SAME_ACCESS)) {\n    DeathTestAbort(\"Unable to duplicate the pipe handle \" +\n                   StreamableToString(write_handle_as_size_t) +\n                   \" from the parent process \" +\n                   StreamableToString(parent_process_id));\n  }\n\n  const HANDLE event_handle = reinterpret_cast<HANDLE>(event_handle_as_size_t);\n  HANDLE dup_event_handle;\n\n  if (!::DuplicateHandle(parent_process_handle.Get(), event_handle,\n                         ::GetCurrentProcess(), &dup_event_handle,\n                         0x0,\n                         FALSE,\n                         DUPLICATE_SAME_ACCESS)) {\n    DeathTestAbort(\"Unable to duplicate the event handle \" +\n                   StreamableToString(event_handle_as_size_t) +\n                   \" from the parent process \" +\n                   StreamableToString(parent_process_id));\n  }\n\n  const int write_fd =\n      ::_open_osfhandle(reinterpret_cast<intptr_t>(dup_write_handle), O_APPEND);\n  if (write_fd == -1) {\n    DeathTestAbort(\"Unable to convert pipe handle \" +\n                   StreamableToString(write_handle_as_size_t) +\n                   \" to a file descriptor\");\n  }\n\n  // Signals the parent that the write end of the pipe has been acquired\n  // so the parent can release its own write end.\n  ::SetEvent(dup_event_handle);\n\n  return write_fd;\n}\n# endif  // GTEST_OS_WINDOWS\n\n// Returns a newly created InternalRunDeathTestFlag object with fields\n// initialized from the GTEST_FLAG(internal_run_death_test) flag if\n// the flag is specified; otherwise returns NULL.\nInternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {\n  if (GTEST_FLAG(internal_run_death_test) == \"\") return NULL;\n\n  // GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we\n  // can use it here.\n  int line = -1;\n  int index = -1;\n  ::std::vector< ::std::string> fields;\n  SplitString(GTEST_FLAG(internal_run_death_test).c_str(), '|', &fields);\n  int write_fd = -1;\n\n# if GTEST_OS_WINDOWS\n\n  unsigned int parent_process_id = 0;\n  size_t write_handle_as_size_t = 0;\n  size_t event_handle_as_size_t = 0;\n\n  if (fields.size() != 6\n      || !ParseNaturalNumber(fields[1], &line)\n      || !ParseNaturalNumber(fields[2], &index)\n      || !ParseNaturalNumber(fields[3], &parent_process_id)\n      || !ParseNaturalNumber(fields[4], &write_handle_as_size_t)\n      || !ParseNaturalNumber(fields[5], &event_handle_as_size_t)) {\n    DeathTestAbort(\"Bad --gtest_internal_run_death_test flag: \" +\n                   GTEST_FLAG(internal_run_death_test));\n  }\n  write_fd = GetStatusFileDescriptor(parent_process_id,\n                                     write_handle_as_size_t,\n                                     event_handle_as_size_t);\n# else\n\n  if (fields.size() != 4\n      || !ParseNaturalNumber(fields[1], &line)\n      || !ParseNaturalNumber(fields[2], &index)\n      || !ParseNaturalNumber(fields[3], &write_fd)) {\n    DeathTestAbort(\"Bad --gtest_internal_run_death_test flag: \"\n        + GTEST_FLAG(internal_run_death_test));\n  }\n\n# endif  // GTEST_OS_WINDOWS\n\n  return new InternalRunDeathTestFlag(fields[0], line, index, write_fd);\n}\n\n}  // namespace internal\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n}  // namespace testing\n"
  },
  {
    "path": "utils/googletest/googletest/src/gtest-filepath.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: keith.ray@gmail.com (Keith Ray)\n\n#include \"gtest/gtest-message.h\"\n#include \"gtest/internal/gtest-filepath.h\"\n#include \"gtest/internal/gtest-port.h\"\n\n#include <stdlib.h>\n\n#if GTEST_OS_WINDOWS_MOBILE\n# include <windows.h>\n#elif GTEST_OS_WINDOWS\n# include <direct.h>\n# include <io.h>\n#elif GTEST_OS_SYMBIAN\n// Symbian OpenC has PATH_MAX in sys/syslimits.h\n# include <sys/syslimits.h>\n#else\n# include <limits.h>\n# include <climits>  // Some Linux distributions define PATH_MAX here.\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n#if GTEST_OS_WINDOWS\n# define GTEST_PATH_MAX_ _MAX_PATH\n#elif defined(PATH_MAX)\n# define GTEST_PATH_MAX_ PATH_MAX\n#elif defined(_XOPEN_PATH_MAX)\n# define GTEST_PATH_MAX_ _XOPEN_PATH_MAX\n#else\n# define GTEST_PATH_MAX_ _POSIX_PATH_MAX\n#endif  // GTEST_OS_WINDOWS\n\n#include \"gtest/internal/gtest-string.h\"\n\nnamespace testing {\nnamespace internal {\n\n#if GTEST_OS_WINDOWS\n// On Windows, '\\\\' is the standard path separator, but many tools and the\n// Windows API also accept '/' as an alternate path separator. Unless otherwise\n// noted, a file path can contain either kind of path separators, or a mixture\n// of them.\nconst char kPathSeparator = '\\\\';\nconst char kAlternatePathSeparator = '/';\nconst char kAlternatePathSeparatorString[] = \"/\";\n# if GTEST_OS_WINDOWS_MOBILE\n// Windows CE doesn't have a current directory. You should not use\n// the current directory in tests on Windows CE, but this at least\n// provides a reasonable fallback.\nconst char kCurrentDirectoryString[] = \"\\\\\";\n// Windows CE doesn't define INVALID_FILE_ATTRIBUTES\nconst DWORD kInvalidFileAttributes = 0xffffffff;\n# else\nconst char kCurrentDirectoryString[] = \".\\\\\";\n# endif  // GTEST_OS_WINDOWS_MOBILE\n#else\nconst char kPathSeparator = '/';\nconst char kCurrentDirectoryString[] = \"./\";\n#endif  // GTEST_OS_WINDOWS\n\n// Returns whether the given character is a valid path separator.\nstatic bool IsPathSeparator(char c) {\n#if GTEST_HAS_ALT_PATH_SEP_\n  return (c == kPathSeparator) || (c == kAlternatePathSeparator);\n#else\n  return c == kPathSeparator;\n#endif\n}\n\n// Returns the current working directory, or \"\" if unsuccessful.\nFilePath FilePath::GetCurrentDir() {\n#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT\n  // Windows CE doesn't have a current directory, so we just return\n  // something reasonable.\n  return FilePath(kCurrentDirectoryString);\n#elif GTEST_OS_WINDOWS\n  char cwd[GTEST_PATH_MAX_ + 1] = { '\\0' };\n  return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? \"\" : cwd);\n#else\n  char cwd[GTEST_PATH_MAX_ + 1] = { '\\0' };\n  char* result = getcwd(cwd, sizeof(cwd));\n# if GTEST_OS_NACL\n  // getcwd will likely fail in NaCl due to the sandbox, so return something\n  // reasonable. The user may have provided a shim implementation for getcwd,\n  // however, so fallback only when failure is detected.\n  return FilePath(result == NULL ? kCurrentDirectoryString : cwd);\n# endif  // GTEST_OS_NACL\n  return FilePath(result == NULL ? \"\" : cwd);\n#endif  // GTEST_OS_WINDOWS_MOBILE\n}\n\n// Returns a copy of the FilePath with the case-insensitive extension removed.\n// Example: FilePath(\"dir/file.exe\").RemoveExtension(\"EXE\") returns\n// FilePath(\"dir/file\"). If a case-insensitive extension is not\n// found, returns a copy of the original FilePath.\nFilePath FilePath::RemoveExtension(const char* extension) const {\n  const std::string dot_extension = std::string(\".\") + extension;\n  if (String::EndsWithCaseInsensitive(pathname_, dot_extension)) {\n    return FilePath(pathname_.substr(\n        0, pathname_.length() - dot_extension.length()));\n  }\n  return *this;\n}\n\n// Returns a pointer to the last occurence of a valid path separator in\n// the FilePath. On Windows, for example, both '/' and '\\' are valid path\n// separators. Returns NULL if no path separator was found.\nconst char* FilePath::FindLastPathSeparator() const {\n  const char* const last_sep = strrchr(c_str(), kPathSeparator);\n#if GTEST_HAS_ALT_PATH_SEP_\n  const char* const last_alt_sep = strrchr(c_str(), kAlternatePathSeparator);\n  // Comparing two pointers of which only one is NULL is undefined.\n  if (last_alt_sep != NULL &&\n      (last_sep == NULL || last_alt_sep > last_sep)) {\n    return last_alt_sep;\n  }\n#endif\n  return last_sep;\n}\n\n// Returns a copy of the FilePath with the directory part removed.\n// Example: FilePath(\"path/to/file\").RemoveDirectoryName() returns\n// FilePath(\"file\"). If there is no directory part (\"just_a_file\"), it returns\n// the FilePath unmodified. If there is no file part (\"just_a_dir/\") it\n// returns an empty FilePath (\"\").\n// On Windows platform, '\\' is the path separator, otherwise it is '/'.\nFilePath FilePath::RemoveDirectoryName() const {\n  const char* const last_sep = FindLastPathSeparator();\n  return last_sep ? FilePath(last_sep + 1) : *this;\n}\n\n// RemoveFileName returns the directory path with the filename removed.\n// Example: FilePath(\"path/to/file\").RemoveFileName() returns \"path/to/\".\n// If the FilePath is \"a_file\" or \"/a_file\", RemoveFileName returns\n// FilePath(\"./\") or, on Windows, FilePath(\".\\\\\"). If the filepath does\n// not have a file, like \"just/a/dir/\", it returns the FilePath unmodified.\n// On Windows platform, '\\' is the path separator, otherwise it is '/'.\nFilePath FilePath::RemoveFileName() const {\n  const char* const last_sep = FindLastPathSeparator();\n  std::string dir;\n  if (last_sep) {\n    dir = std::string(c_str(), last_sep + 1 - c_str());\n  } else {\n    dir = kCurrentDirectoryString;\n  }\n  return FilePath(dir);\n}\n\n// Helper functions for naming files in a directory for xml output.\n\n// Given directory = \"dir\", base_name = \"test\", number = 0,\n// extension = \"xml\", returns \"dir/test.xml\". If number is greater\n// than zero (e.g., 12), returns \"dir/test_12.xml\".\n// On Windows platform, uses \\ as the separator rather than /.\nFilePath FilePath::MakeFileName(const FilePath& directory,\n                                const FilePath& base_name,\n                                int number,\n                                const char* extension) {\n  std::string file;\n  if (number == 0) {\n    file = base_name.string() + \".\" + extension;\n  } else {\n    file = base_name.string() + \"_\" + StreamableToString(number)\n        + \".\" + extension;\n  }\n  return ConcatPaths(directory, FilePath(file));\n}\n\n// Given directory = \"dir\", relative_path = \"test.xml\", returns \"dir/test.xml\".\n// On Windows, uses \\ as the separator rather than /.\nFilePath FilePath::ConcatPaths(const FilePath& directory,\n                               const FilePath& relative_path) {\n  if (directory.IsEmpty())\n    return relative_path;\n  const FilePath dir(directory.RemoveTrailingPathSeparator());\n  return FilePath(dir.string() + kPathSeparator + relative_path.string());\n}\n\n// Returns true if pathname describes something findable in the file-system,\n// either a file, directory, or whatever.\nbool FilePath::FileOrDirectoryExists() const {\n#if GTEST_OS_WINDOWS_MOBILE\n  LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str());\n  const DWORD attributes = GetFileAttributes(unicode);\n  delete [] unicode;\n  return attributes != kInvalidFileAttributes;\n#else\n  posix::StatStruct file_stat;\n  return posix::Stat(pathname_.c_str(), &file_stat) == 0;\n#endif  // GTEST_OS_WINDOWS_MOBILE\n}\n\n// Returns true if pathname describes a directory in the file-system\n// that exists.\nbool FilePath::DirectoryExists() const {\n  bool result = false;\n#if GTEST_OS_WINDOWS\n  // Don't strip off trailing separator if path is a root directory on\n  // Windows (like \"C:\\\\\").\n  const FilePath& path(IsRootDirectory() ? *this :\n                                           RemoveTrailingPathSeparator());\n#else\n  const FilePath& path(*this);\n#endif\n\n#if GTEST_OS_WINDOWS_MOBILE\n  LPCWSTR unicode = String::AnsiToUtf16(path.c_str());\n  const DWORD attributes = GetFileAttributes(unicode);\n  delete [] unicode;\n  if ((attributes != kInvalidFileAttributes) &&\n      (attributes & FILE_ATTRIBUTE_DIRECTORY)) {\n    result = true;\n  }\n#else\n  posix::StatStruct file_stat;\n  result = posix::Stat(path.c_str(), &file_stat) == 0 &&\n      posix::IsDir(file_stat);\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n  return result;\n}\n\n// Returns true if pathname describes a root directory. (Windows has one\n// root directory per disk drive.)\nbool FilePath::IsRootDirectory() const {\n#if GTEST_OS_WINDOWS\n  // TODO(wan@google.com): on Windows a network share like\n  // \\\\server\\share can be a root directory, although it cannot be the\n  // current directory.  Handle this properly.\n  return pathname_.length() == 3 && IsAbsolutePath();\n#else\n  return pathname_.length() == 1 && IsPathSeparator(pathname_.c_str()[0]);\n#endif\n}\n\n// Returns true if pathname describes an absolute path.\nbool FilePath::IsAbsolutePath() const {\n  const char* const name = pathname_.c_str();\n#if GTEST_OS_WINDOWS\n  return pathname_.length() >= 3 &&\n     ((name[0] >= 'a' && name[0] <= 'z') ||\n      (name[0] >= 'A' && name[0] <= 'Z')) &&\n     name[1] == ':' &&\n     IsPathSeparator(name[2]);\n#else\n  return IsPathSeparator(name[0]);\n#endif\n}\n\n// Returns a pathname for a file that does not currently exist. The pathname\n// will be directory/base_name.extension or\n// directory/base_name_<number>.extension if directory/base_name.extension\n// already exists. The number will be incremented until a pathname is found\n// that does not already exist.\n// Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.\n// There could be a race condition if two or more processes are calling this\n// function at the same time -- they could both pick the same filename.\nFilePath FilePath::GenerateUniqueFileName(const FilePath& directory,\n                                          const FilePath& base_name,\n                                          const char* extension) {\n  FilePath full_pathname;\n  int number = 0;\n  do {\n    full_pathname.Set(MakeFileName(directory, base_name, number++, extension));\n  } while (full_pathname.FileOrDirectoryExists());\n  return full_pathname;\n}\n\n// Returns true if FilePath ends with a path separator, which indicates that\n// it is intended to represent a directory. Returns false otherwise.\n// This does NOT check that a directory (or file) actually exists.\nbool FilePath::IsDirectory() const {\n  return !pathname_.empty() &&\n         IsPathSeparator(pathname_.c_str()[pathname_.length() - 1]);\n}\n\n// Create directories so that path exists. Returns true if successful or if\n// the directories already exist; returns false if unable to create directories\n// for any reason.\nbool FilePath::CreateDirectoriesRecursively() const {\n  if (!this->IsDirectory()) {\n    return false;\n  }\n\n  if (pathname_.length() == 0 || this->DirectoryExists()) {\n    return true;\n  }\n\n  const FilePath parent(this->RemoveTrailingPathSeparator().RemoveFileName());\n  return parent.CreateDirectoriesRecursively() && this->CreateFolder();\n}\n\n// Create the directory so that path exists. Returns true if successful or\n// if the directory already exists; returns false if unable to create the\n// directory for any reason, including if the parent directory does not\n// exist. Not named \"CreateDirectory\" because that's a macro on Windows.\nbool FilePath::CreateFolder() const {\n#if GTEST_OS_WINDOWS_MOBILE\n  FilePath removed_sep(this->RemoveTrailingPathSeparator());\n  LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str());\n  int result = CreateDirectory(unicode, NULL) ? 0 : -1;\n  delete [] unicode;\n#elif GTEST_OS_WINDOWS\n  int result = _mkdir(pathname_.c_str());\n#else\n  int result = mkdir(pathname_.c_str(), 0777);\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n  if (result == -1) {\n    return this->DirectoryExists();  // An error is OK if the directory exists.\n  }\n  return true;  // No error.\n}\n\n// If input name has a trailing separator character, remove it and return the\n// name, otherwise return the name string unmodified.\n// On Windows platform, uses \\ as the separator, other platforms use /.\nFilePath FilePath::RemoveTrailingPathSeparator() const {\n  return IsDirectory()\n      ? FilePath(pathname_.substr(0, pathname_.length() - 1))\n      : *this;\n}\n\n// Removes any redundant separators that might be in the pathname.\n// For example, \"bar///foo\" becomes \"bar/foo\". Does not eliminate other\n// redundancies that might be in a pathname involving \".\" or \"..\".\n// TODO(wan@google.com): handle Windows network shares (e.g. \\\\server\\share).\nvoid FilePath::Normalize() {\n  if (pathname_.c_str() == NULL) {\n    pathname_ = \"\";\n    return;\n  }\n  const char* src = pathname_.c_str();\n  char* const dest = new char[pathname_.length() + 1];\n  char* dest_ptr = dest;\n  memset(dest_ptr, 0, pathname_.length() + 1);\n\n  while (*src != '\\0') {\n    *dest_ptr = *src;\n    if (!IsPathSeparator(*src)) {\n      src++;\n    } else {\n#if GTEST_HAS_ALT_PATH_SEP_\n      if (*dest_ptr == kAlternatePathSeparator) {\n        *dest_ptr = kPathSeparator;\n      }\n#endif\n      while (IsPathSeparator(*src))\n        src++;\n    }\n    dest_ptr++;\n  }\n  *dest_ptr = '\\0';\n  pathname_ = dest;\n  delete[] dest;\n}\n\n}  // namespace internal\n}  // namespace testing\n"
  },
  {
    "path": "utils/googletest/googletest/src/gtest-internal-inl.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Utility functions and classes used by the Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// This file contains purely Google Test's internal implementation.  Please\n// DO NOT #INCLUDE IT IN A USER PROGRAM.\n\n#ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_\n#define GTEST_SRC_GTEST_INTERNAL_INL_H_\n\n// GTEST_IMPLEMENTATION_ is defined to 1 iff the current translation unit is\n// part of Google Test's implementation; otherwise it's undefined.\n#if !GTEST_IMPLEMENTATION_\n// If this file is included from the user's code, just say no.\n# error \"gtest-internal-inl.h is part of Google Test's internal implementation.\"\n# error \"It must not be included except by Google Test itself.\"\n#endif  // GTEST_IMPLEMENTATION_\n\n#ifndef _WIN32_WCE\n# include <errno.h>\n#endif  // !_WIN32_WCE\n#include <stddef.h>\n#include <stdlib.h>  // For strtoll/_strtoul64/malloc/free.\n#include <string.h>  // For memmove.\n\n#include <algorithm>\n#include <string>\n#include <vector>\n\n#include \"gtest/internal/gtest-port.h\"\n\n#if GTEST_CAN_STREAM_RESULTS_\n# include <arpa/inet.h>  // NOLINT\n# include <netdb.h>  // NOLINT\n#endif\n\n#if GTEST_OS_WINDOWS\n# include <windows.h>  // NOLINT\n#endif  // GTEST_OS_WINDOWS\n\n#include \"gtest/gtest.h\"  // NOLINT\n#include \"gtest/gtest-spi.h\"\n\nnamespace testing {\n\n// Declares the flags.\n//\n// We don't want the users to modify this flag in the code, but want\n// Google Test's own unit tests to be able to access it. Therefore we\n// declare it here as opposed to in gtest.h.\nGTEST_DECLARE_bool_(death_test_use_fork);\n\nnamespace internal {\n\n// The value of GetTestTypeId() as seen from within the Google Test\n// library.  This is solely for testing GetTestTypeId().\nGTEST_API_ extern const TypeId kTestTypeIdInGoogleTest;\n\n// Names of the flags (needed for parsing Google Test flags).\nconst char kAlsoRunDisabledTestsFlag[] = \"also_run_disabled_tests\";\nconst char kBreakOnFailureFlag[] = \"break_on_failure\";\nconst char kCatchExceptionsFlag[] = \"catch_exceptions\";\nconst char kColorFlag[] = \"color\";\nconst char kFilterFlag[] = \"filter\";\nconst char kListTestsFlag[] = \"list_tests\";\nconst char kOutputFlag[] = \"output\";\nconst char kPrintTimeFlag[] = \"print_time\";\nconst char kRandomSeedFlag[] = \"random_seed\";\nconst char kRepeatFlag[] = \"repeat\";\nconst char kShuffleFlag[] = \"shuffle\";\nconst char kStackTraceDepthFlag[] = \"stack_trace_depth\";\nconst char kStreamResultToFlag[] = \"stream_result_to\";\nconst char kThrowOnFailureFlag[] = \"throw_on_failure\";\nconst char kFlagfileFlag[] = \"flagfile\";\n\n// A valid random seed must be in [1, kMaxRandomSeed].\nconst int kMaxRandomSeed = 99999;\n\n// g_help_flag is true iff the --help flag or an equivalent form is\n// specified on the command line.\nGTEST_API_ extern bool g_help_flag;\n\n// Returns the current time in milliseconds.\nGTEST_API_ TimeInMillis GetTimeInMillis();\n\n// Returns true iff Google Test should use colors in the output.\nGTEST_API_ bool ShouldUseColor(bool stdout_is_tty);\n\n// Formats the given time in milliseconds as seconds.\nGTEST_API_ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms);\n\n// Converts the given time in milliseconds to a date string in the ISO 8601\n// format, without the timezone information.  N.B.: due to the use the\n// non-reentrant localtime() function, this function is not thread safe.  Do\n// not use it in any code that can be called from multiple threads.\nGTEST_API_ std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms);\n\n// Parses a string for an Int32 flag, in the form of \"--flag=value\".\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\nGTEST_API_ bool ParseInt32Flag(\n    const char* str, const char* flag, Int32* value);\n\n// Returns a random seed in range [1, kMaxRandomSeed] based on the\n// given --gtest_random_seed flag value.\ninline int GetRandomSeedFromFlag(Int32 random_seed_flag) {\n  const unsigned int raw_seed = (random_seed_flag == 0) ?\n      static_cast<unsigned int>(GetTimeInMillis()) :\n      static_cast<unsigned int>(random_seed_flag);\n\n  // Normalizes the actual seed to range [1, kMaxRandomSeed] such that\n  // it's easy to type.\n  const int normalized_seed =\n      static_cast<int>((raw_seed - 1U) %\n                       static_cast<unsigned int>(kMaxRandomSeed)) + 1;\n  return normalized_seed;\n}\n\n// Returns the first valid random seed after 'seed'.  The behavior is\n// undefined if 'seed' is invalid.  The seed after kMaxRandomSeed is\n// considered to be 1.\ninline int GetNextRandomSeed(int seed) {\n  GTEST_CHECK_(1 <= seed && seed <= kMaxRandomSeed)\n      << \"Invalid random seed \" << seed << \" - must be in [1, \"\n      << kMaxRandomSeed << \"].\";\n  const int next_seed = seed + 1;\n  return (next_seed > kMaxRandomSeed) ? 1 : next_seed;\n}\n\n// This class saves the values of all Google Test flags in its c'tor, and\n// restores them in its d'tor.\nclass GTestFlagSaver {\n public:\n  // The c'tor.\n  GTestFlagSaver() {\n    also_run_disabled_tests_ = GTEST_FLAG(also_run_disabled_tests);\n    break_on_failure_ = GTEST_FLAG(break_on_failure);\n    catch_exceptions_ = GTEST_FLAG(catch_exceptions);\n    color_ = GTEST_FLAG(color);\n    death_test_style_ = GTEST_FLAG(death_test_style);\n    death_test_use_fork_ = GTEST_FLAG(death_test_use_fork);\n    filter_ = GTEST_FLAG(filter);\n    internal_run_death_test_ = GTEST_FLAG(internal_run_death_test);\n    list_tests_ = GTEST_FLAG(list_tests);\n    output_ = GTEST_FLAG(output);\n    print_time_ = GTEST_FLAG(print_time);\n    random_seed_ = GTEST_FLAG(random_seed);\n    repeat_ = GTEST_FLAG(repeat);\n    shuffle_ = GTEST_FLAG(shuffle);\n    stack_trace_depth_ = GTEST_FLAG(stack_trace_depth);\n    stream_result_to_ = GTEST_FLAG(stream_result_to);\n    throw_on_failure_ = GTEST_FLAG(throw_on_failure);\n  }\n\n  // The d'tor is not virtual.  DO NOT INHERIT FROM THIS CLASS.\n  ~GTestFlagSaver() {\n    GTEST_FLAG(also_run_disabled_tests) = also_run_disabled_tests_;\n    GTEST_FLAG(break_on_failure) = break_on_failure_;\n    GTEST_FLAG(catch_exceptions) = catch_exceptions_;\n    GTEST_FLAG(color) = color_;\n    GTEST_FLAG(death_test_style) = death_test_style_;\n    GTEST_FLAG(death_test_use_fork) = death_test_use_fork_;\n    GTEST_FLAG(filter) = filter_;\n    GTEST_FLAG(internal_run_death_test) = internal_run_death_test_;\n    GTEST_FLAG(list_tests) = list_tests_;\n    GTEST_FLAG(output) = output_;\n    GTEST_FLAG(print_time) = print_time_;\n    GTEST_FLAG(random_seed) = random_seed_;\n    GTEST_FLAG(repeat) = repeat_;\n    GTEST_FLAG(shuffle) = shuffle_;\n    GTEST_FLAG(stack_trace_depth) = stack_trace_depth_;\n    GTEST_FLAG(stream_result_to) = stream_result_to_;\n    GTEST_FLAG(throw_on_failure) = throw_on_failure_;\n  }\n\n private:\n  // Fields for saving the original values of flags.\n  bool also_run_disabled_tests_;\n  bool break_on_failure_;\n  bool catch_exceptions_;\n  std::string color_;\n  std::string death_test_style_;\n  bool death_test_use_fork_;\n  std::string filter_;\n  std::string internal_run_death_test_;\n  bool list_tests_;\n  std::string output_;\n  bool print_time_;\n  internal::Int32 random_seed_;\n  internal::Int32 repeat_;\n  bool shuffle_;\n  internal::Int32 stack_trace_depth_;\n  std::string stream_result_to_;\n  bool throw_on_failure_;\n} GTEST_ATTRIBUTE_UNUSED_;\n\n// Converts a Unicode code point to a narrow string in UTF-8 encoding.\n// code_point parameter is of type UInt32 because wchar_t may not be\n// wide enough to contain a code point.\n// If the code_point is not a valid Unicode code point\n// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted\n// to \"(Invalid Unicode 0xXXXXXXXX)\".\nGTEST_API_ std::string CodePointToUtf8(UInt32 code_point);\n\n// Converts a wide string to a narrow string in UTF-8 encoding.\n// The wide string is assumed to have the following encoding:\n//   UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS)\n//   UTF-32 if sizeof(wchar_t) == 4 (on Linux)\n// Parameter str points to a null-terminated wide string.\n// Parameter num_chars may additionally limit the number\n// of wchar_t characters processed. -1 is used when the entire string\n// should be processed.\n// If the string contains code points that are not valid Unicode code points\n// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output\n// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding\n// and contains invalid UTF-16 surrogate pairs, values in those pairs\n// will be encoded as individual Unicode characters from Basic Normal Plane.\nGTEST_API_ std::string WideStringToUtf8(const wchar_t* str, int num_chars);\n\n// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file\n// if the variable is present. If a file already exists at this location, this\n// function will write over it. If the variable is present, but the file cannot\n// be created, prints an error and exits.\nvoid WriteToShardStatusFileIfNeeded();\n\n// Checks whether sharding is enabled by examining the relevant\n// environment variable values. If the variables are present,\n// but inconsistent (e.g., shard_index >= total_shards), prints\n// an error and exits. If in_subprocess_for_death_test, sharding is\n// disabled because it must only be applied to the original test\n// process. Otherwise, we could filter out death tests we intended to execute.\nGTEST_API_ bool ShouldShard(const char* total_shards_str,\n                            const char* shard_index_str,\n                            bool in_subprocess_for_death_test);\n\n// Parses the environment variable var as an Int32. If it is unset,\n// returns default_val. If it is not an Int32, prints an error and\n// and aborts.\nGTEST_API_ Int32 Int32FromEnvOrDie(const char* env_var, Int32 default_val);\n\n// Given the total number of shards, the shard index, and the test id,\n// returns true iff the test should be run on this shard. The test id is\n// some arbitrary but unique non-negative integer assigned to each test\n// method. Assumes that 0 <= shard_index < total_shards.\nGTEST_API_ bool ShouldRunTestOnShard(\n    int total_shards, int shard_index, int test_id);\n\n// STL container utilities.\n\n// Returns the number of elements in the given container that satisfy\n// the given predicate.\ntemplate <class Container, typename Predicate>\ninline int CountIf(const Container& c, Predicate predicate) {\n  // Implemented as an explicit loop since std::count_if() in libCstd on\n  // Solaris has a non-standard signature.\n  int count = 0;\n  for (typename Container::const_iterator it = c.begin(); it != c.end(); ++it) {\n    if (predicate(*it))\n      ++count;\n  }\n  return count;\n}\n\n// Applies a function/functor to each element in the container.\ntemplate <class Container, typename Functor>\nvoid ForEach(const Container& c, Functor functor) {\n  std::for_each(c.begin(), c.end(), functor);\n}\n\n// Returns the i-th element of the vector, or default_value if i is not\n// in range [0, v.size()).\ntemplate <typename E>\ninline E GetElementOr(const std::vector<E>& v, int i, E default_value) {\n  return (i < 0 || i >= static_cast<int>(v.size())) ? default_value : v[i];\n}\n\n// Performs an in-place shuffle of a range of the vector's elements.\n// 'begin' and 'end' are element indices as an STL-style range;\n// i.e. [begin, end) are shuffled, where 'end' == size() means to\n// shuffle to the end of the vector.\ntemplate <typename E>\nvoid ShuffleRange(internal::Random* random, int begin, int end,\n                  std::vector<E>* v) {\n  const int size = static_cast<int>(v->size());\n  GTEST_CHECK_(0 <= begin && begin <= size)\n      << \"Invalid shuffle range start \" << begin << \": must be in range [0, \"\n      << size << \"].\";\n  GTEST_CHECK_(begin <= end && end <= size)\n      << \"Invalid shuffle range finish \" << end << \": must be in range [\"\n      << begin << \", \" << size << \"].\";\n\n  // Fisher-Yates shuffle, from\n  // http://en.wikipedia.org/wiki/Fisher-Yates_shuffle\n  for (int range_width = end - begin; range_width >= 2; range_width--) {\n    const int last_in_range = begin + range_width - 1;\n    const int selected = begin + random->Generate(range_width);\n    std::swap((*v)[selected], (*v)[last_in_range]);\n  }\n}\n\n// Performs an in-place shuffle of the vector's elements.\ntemplate <typename E>\ninline void Shuffle(internal::Random* random, std::vector<E>* v) {\n  ShuffleRange(random, 0, static_cast<int>(v->size()), v);\n}\n\n// A function for deleting an object.  Handy for being used as a\n// functor.\ntemplate <typename T>\nstatic void Delete(T* x) {\n  delete x;\n}\n\n// A predicate that checks the key of a TestProperty against a known key.\n//\n// TestPropertyKeyIs is copyable.\nclass TestPropertyKeyIs {\n public:\n  // Constructor.\n  //\n  // TestPropertyKeyIs has NO default constructor.\n  explicit TestPropertyKeyIs(const std::string& key) : key_(key) {}\n\n  // Returns true iff the test name of test property matches on key_.\n  bool operator()(const TestProperty& test_property) const {\n    return test_property.key() == key_;\n  }\n\n private:\n  std::string key_;\n};\n\n// Class UnitTestOptions.\n//\n// This class contains functions for processing options the user\n// specifies when running the tests.  It has only static members.\n//\n// In most cases, the user can specify an option using either an\n// environment variable or a command line flag.  E.g. you can set the\n// test filter using either GTEST_FILTER or --gtest_filter.  If both\n// the variable and the flag are present, the latter overrides the\n// former.\nclass GTEST_API_ UnitTestOptions {\n public:\n  // Functions for processing the gtest_output flag.\n\n  // Returns the output format, or \"\" for normal printed output.\n  static std::string GetOutputFormat();\n\n  // Returns the absolute path of the requested output file, or the\n  // default (test_detail.xml in the original working directory) if\n  // none was explicitly specified.\n  static std::string GetAbsolutePathToOutputFile();\n\n  // Functions for processing the gtest_filter flag.\n\n  // Returns true iff the wildcard pattern matches the string.  The\n  // first ':' or '\\0' character in pattern marks the end of it.\n  //\n  // This recursive algorithm isn't very efficient, but is clear and\n  // works well enough for matching test names, which are short.\n  static bool PatternMatchesString(const char *pattern, const char *str);\n\n  // Returns true iff the user-specified filter matches the test case\n  // name and the test name.\n  static bool FilterMatchesTest(const std::string &test_case_name,\n                                const std::string &test_name);\n\n#if GTEST_OS_WINDOWS\n  // Function for supporting the gtest_catch_exception flag.\n\n  // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the\n  // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.\n  // This function is useful as an __except condition.\n  static int GTestShouldProcessSEH(DWORD exception_code);\n#endif  // GTEST_OS_WINDOWS\n\n  // Returns true if \"name\" matches the ':' separated list of glob-style\n  // filters in \"filter\".\n  static bool MatchesFilter(const std::string& name, const char* filter);\n};\n\n// Returns the current application's name, removing directory path if that\n// is present.  Used by UnitTestOptions::GetOutputFile.\nGTEST_API_ FilePath GetCurrentExecutableName();\n\n// The role interface for getting the OS stack trace as a string.\nclass OsStackTraceGetterInterface {\n public:\n  OsStackTraceGetterInterface() {}\n  virtual ~OsStackTraceGetterInterface() {}\n\n  // Returns the current OS stack trace as an std::string.  Parameters:\n  //\n  //   max_depth  - the maximum number of stack frames to be included\n  //                in the trace.\n  //   skip_count - the number of top frames to be skipped; doesn't count\n  //                against max_depth.\n  virtual string CurrentStackTrace(int max_depth, int skip_count) = 0;\n\n  // UponLeavingGTest() should be called immediately before Google Test calls\n  // user code. It saves some information about the current stack that\n  // CurrentStackTrace() will use to find and hide Google Test stack frames.\n  virtual void UponLeavingGTest() = 0;\n\n  // This string is inserted in place of stack frames that are part of\n  // Google Test's implementation.\n  static const char* const kElidedFramesMarker;\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetterInterface);\n};\n\n// A working implementation of the OsStackTraceGetterInterface interface.\nclass OsStackTraceGetter : public OsStackTraceGetterInterface {\n public:\n  OsStackTraceGetter() {}\n\n  virtual string CurrentStackTrace(int max_depth, int skip_count);\n  virtual void UponLeavingGTest();\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter);\n};\n\n// Information about a Google Test trace point.\nstruct TraceInfo {\n  const char* file;\n  int line;\n  std::string message;\n};\n\n// This is the default global test part result reporter used in UnitTestImpl.\n// This class should only be used by UnitTestImpl.\nclass DefaultGlobalTestPartResultReporter\n  : public TestPartResultReporterInterface {\n public:\n  explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test);\n  // Implements the TestPartResultReporterInterface. Reports the test part\n  // result in the current test.\n  virtual void ReportTestPartResult(const TestPartResult& result);\n\n private:\n  UnitTestImpl* const unit_test_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultGlobalTestPartResultReporter);\n};\n\n// This is the default per thread test part result reporter used in\n// UnitTestImpl. This class should only be used by UnitTestImpl.\nclass DefaultPerThreadTestPartResultReporter\n    : public TestPartResultReporterInterface {\n public:\n  explicit DefaultPerThreadTestPartResultReporter(UnitTestImpl* unit_test);\n  // Implements the TestPartResultReporterInterface. The implementation just\n  // delegates to the current global test part result reporter of *unit_test_.\n  virtual void ReportTestPartResult(const TestPartResult& result);\n\n private:\n  UnitTestImpl* const unit_test_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultPerThreadTestPartResultReporter);\n};\n\n// The private implementation of the UnitTest class.  We don't protect\n// the methods under a mutex, as this class is not accessible by a\n// user and the UnitTest class that delegates work to this class does\n// proper locking.\nclass GTEST_API_ UnitTestImpl {\n public:\n  explicit UnitTestImpl(UnitTest* parent);\n  virtual ~UnitTestImpl();\n\n  // There are two different ways to register your own TestPartResultReporter.\n  // You can register your own repoter to listen either only for test results\n  // from the current thread or for results from all threads.\n  // By default, each per-thread test result repoter just passes a new\n  // TestPartResult to the global test result reporter, which registers the\n  // test part result for the currently running test.\n\n  // Returns the global test part result reporter.\n  TestPartResultReporterInterface* GetGlobalTestPartResultReporter();\n\n  // Sets the global test part result reporter.\n  void SetGlobalTestPartResultReporter(\n      TestPartResultReporterInterface* reporter);\n\n  // Returns the test part result reporter for the current thread.\n  TestPartResultReporterInterface* GetTestPartResultReporterForCurrentThread();\n\n  // Sets the test part result reporter for the current thread.\n  void SetTestPartResultReporterForCurrentThread(\n      TestPartResultReporterInterface* reporter);\n\n  // Gets the number of successful test cases.\n  int successful_test_case_count() const;\n\n  // Gets the number of failed test cases.\n  int failed_test_case_count() const;\n\n  // Gets the number of all test cases.\n  int total_test_case_count() const;\n\n  // Gets the number of all test cases that contain at least one test\n  // that should run.\n  int test_case_to_run_count() const;\n\n  // Gets the number of successful tests.\n  int successful_test_count() const;\n\n  // Gets the number of failed tests.\n  int failed_test_count() const;\n\n  // Gets the number of disabled tests that will be reported in the XML report.\n  int reportable_disabled_test_count() const;\n\n  // Gets the number of disabled tests.\n  int disabled_test_count() const;\n\n  // Gets the number of tests to be printed in the XML report.\n  int reportable_test_count() const;\n\n  // Gets the number of all tests.\n  int total_test_count() const;\n\n  // Gets the number of tests that should run.\n  int test_to_run_count() const;\n\n  // Gets the time of the test program start, in ms from the start of the\n  // UNIX epoch.\n  TimeInMillis start_timestamp() const { return start_timestamp_; }\n\n  // Gets the elapsed time, in milliseconds.\n  TimeInMillis elapsed_time() const { return elapsed_time_; }\n\n  // Returns true iff the unit test passed (i.e. all test cases passed).\n  bool Passed() const { return !Failed(); }\n\n  // Returns true iff the unit test failed (i.e. some test case failed\n  // or something outside of all tests failed).\n  bool Failed() const {\n    return failed_test_case_count() > 0 || ad_hoc_test_result()->Failed();\n  }\n\n  // Gets the i-th test case among all the test cases. i can range from 0 to\n  // total_test_case_count() - 1. If i is not in that range, returns NULL.\n  const TestCase* GetTestCase(int i) const {\n    const int index = GetElementOr(test_case_indices_, i, -1);\n    return index < 0 ? NULL : test_cases_[i];\n  }\n\n  // Gets the i-th test case among all the test cases. i can range from 0 to\n  // total_test_case_count() - 1. If i is not in that range, returns NULL.\n  TestCase* GetMutableTestCase(int i) {\n    const int index = GetElementOr(test_case_indices_, i, -1);\n    return index < 0 ? NULL : test_cases_[index];\n  }\n\n  // Provides access to the event listener list.\n  TestEventListeners* listeners() { return &listeners_; }\n\n  // Returns the TestResult for the test that's currently running, or\n  // the TestResult for the ad hoc test if no test is running.\n  TestResult* current_test_result();\n\n  // Returns the TestResult for the ad hoc test.\n  const TestResult* ad_hoc_test_result() const { return &ad_hoc_test_result_; }\n\n  // Sets the OS stack trace getter.\n  //\n  // Does nothing if the input and the current OS stack trace getter\n  // are the same; otherwise, deletes the old getter and makes the\n  // input the current getter.\n  void set_os_stack_trace_getter(OsStackTraceGetterInterface* getter);\n\n  // Returns the current OS stack trace getter if it is not NULL;\n  // otherwise, creates an OsStackTraceGetter, makes it the current\n  // getter, and returns it.\n  OsStackTraceGetterInterface* os_stack_trace_getter();\n\n  // Returns the current OS stack trace as an std::string.\n  //\n  // The maximum number of stack frames to be included is specified by\n  // the gtest_stack_trace_depth flag.  The skip_count parameter\n  // specifies the number of top frames to be skipped, which doesn't\n  // count against the number of frames to be included.\n  //\n  // For example, if Foo() calls Bar(), which in turn calls\n  // CurrentOsStackTraceExceptTop(1), Foo() will be included in the\n  // trace but Bar() and CurrentOsStackTraceExceptTop() won't.\n  std::string CurrentOsStackTraceExceptTop(int skip_count) GTEST_NO_INLINE_;\n\n  // Finds and returns a TestCase with the given name.  If one doesn't\n  // exist, creates one and returns it.\n  //\n  // Arguments:\n  //\n  //   test_case_name: name of the test case\n  //   type_param:     the name of the test's type parameter, or NULL if\n  //                   this is not a typed or a type-parameterized test.\n  //   set_up_tc:      pointer to the function that sets up the test case\n  //   tear_down_tc:   pointer to the function that tears down the test case\n  TestCase* GetTestCase(const char* test_case_name,\n                        const char* type_param,\n                        Test::SetUpTestCaseFunc set_up_tc,\n                        Test::TearDownTestCaseFunc tear_down_tc);\n\n  // Adds a TestInfo to the unit test.\n  //\n  // Arguments:\n  //\n  //   set_up_tc:    pointer to the function that sets up the test case\n  //   tear_down_tc: pointer to the function that tears down the test case\n  //   test_info:    the TestInfo object\n  void AddTestInfo(Test::SetUpTestCaseFunc set_up_tc,\n                   Test::TearDownTestCaseFunc tear_down_tc,\n                   TestInfo* test_info) {\n    // In order to support thread-safe death tests, we need to\n    // remember the original working directory when the test program\n    // was first invoked.  We cannot do this in RUN_ALL_TESTS(), as\n    // the user may have changed the current directory before calling\n    // RUN_ALL_TESTS().  Therefore we capture the current directory in\n    // AddTestInfo(), which is called to register a TEST or TEST_F\n    // before main() is reached.\n    if (original_working_dir_.IsEmpty()) {\n      original_working_dir_.Set(FilePath::GetCurrentDir());\n      GTEST_CHECK_(!original_working_dir_.IsEmpty())\n          << \"Failed to get the current working directory.\";\n    }\n\n    GetTestCase(test_info->test_case_name(),\n                test_info->type_param(),\n                set_up_tc,\n                tear_down_tc)->AddTestInfo(test_info);\n  }\n\n#if GTEST_HAS_PARAM_TEST\n  // Returns ParameterizedTestCaseRegistry object used to keep track of\n  // value-parameterized tests and instantiate and register them.\n  internal::ParameterizedTestCaseRegistry& parameterized_test_registry() {\n    return parameterized_test_registry_;\n  }\n#endif  // GTEST_HAS_PARAM_TEST\n\n  // Sets the TestCase object for the test that's currently running.\n  void set_current_test_case(TestCase* a_current_test_case) {\n    current_test_case_ = a_current_test_case;\n  }\n\n  // Sets the TestInfo object for the test that's currently running.  If\n  // current_test_info is NULL, the assertion results will be stored in\n  // ad_hoc_test_result_.\n  void set_current_test_info(TestInfo* a_current_test_info) {\n    current_test_info_ = a_current_test_info;\n  }\n\n  // Registers all parameterized tests defined using TEST_P and\n  // INSTANTIATE_TEST_CASE_P, creating regular tests for each test/parameter\n  // combination. This method can be called more then once; it has guards\n  // protecting from registering the tests more then once.  If\n  // value-parameterized tests are disabled, RegisterParameterizedTests is\n  // present but does nothing.\n  void RegisterParameterizedTests();\n\n  // Runs all tests in this UnitTest object, prints the result, and\n  // returns true if all tests are successful.  If any exception is\n  // thrown during a test, this test is considered to be failed, but\n  // the rest of the tests will still be run.\n  bool RunAllTests();\n\n  // Clears the results of all tests, except the ad hoc tests.\n  void ClearNonAdHocTestResult() {\n    ForEach(test_cases_, TestCase::ClearTestCaseResult);\n  }\n\n  // Clears the results of ad-hoc test assertions.\n  void ClearAdHocTestResult() {\n    ad_hoc_test_result_.Clear();\n  }\n\n  // Adds a TestProperty to the current TestResult object when invoked in a\n  // context of a test or a test case, or to the global property set. If the\n  // result already contains a property with the same key, the value will be\n  // updated.\n  void RecordProperty(const TestProperty& test_property);\n\n  enum ReactionToSharding {\n    HONOR_SHARDING_PROTOCOL,\n    IGNORE_SHARDING_PROTOCOL\n  };\n\n  // Matches the full name of each test against the user-specified\n  // filter to decide whether the test should run, then records the\n  // result in each TestCase and TestInfo object.\n  // If shard_tests == HONOR_SHARDING_PROTOCOL, further filters tests\n  // based on sharding variables in the environment.\n  // Returns the number of tests that should run.\n  int FilterTests(ReactionToSharding shard_tests);\n\n  // Prints the names of the tests matching the user-specified filter flag.\n  void ListTestsMatchingFilter();\n\n  const TestCase* current_test_case() const { return current_test_case_; }\n  TestInfo* current_test_info() { return current_test_info_; }\n  const TestInfo* current_test_info() const { return current_test_info_; }\n\n  // Returns the vector of environments that need to be set-up/torn-down\n  // before/after the tests are run.\n  std::vector<Environment*>& environments() { return environments_; }\n\n  // Getters for the per-thread Google Test trace stack.\n  std::vector<TraceInfo>& gtest_trace_stack() {\n    return *(gtest_trace_stack_.pointer());\n  }\n  const std::vector<TraceInfo>& gtest_trace_stack() const {\n    return gtest_trace_stack_.get();\n  }\n\n#if GTEST_HAS_DEATH_TEST\n  void InitDeathTestSubprocessControlInfo() {\n    internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag());\n  }\n  // Returns a pointer to the parsed --gtest_internal_run_death_test\n  // flag, or NULL if that flag was not specified.\n  // This information is useful only in a death test child process.\n  // Must not be called before a call to InitGoogleTest.\n  const InternalRunDeathTestFlag* internal_run_death_test_flag() const {\n    return internal_run_death_test_flag_.get();\n  }\n\n  // Returns a pointer to the current death test factory.\n  internal::DeathTestFactory* death_test_factory() {\n    return death_test_factory_.get();\n  }\n\n  void SuppressTestEventsIfInSubprocess();\n\n  friend class ReplaceDeathTestFactory;\n#endif  // GTEST_HAS_DEATH_TEST\n\n  // Initializes the event listener performing XML output as specified by\n  // UnitTestOptions. Must not be called before InitGoogleTest.\n  void ConfigureXmlOutput();\n\n#if GTEST_CAN_STREAM_RESULTS_\n  // Initializes the event listener for streaming test results to a socket.\n  // Must not be called before InitGoogleTest.\n  void ConfigureStreamingOutput();\n#endif\n\n  // Performs initialization dependent upon flag values obtained in\n  // ParseGoogleTestFlagsOnly.  Is called from InitGoogleTest after the call to\n  // ParseGoogleTestFlagsOnly.  In case a user neglects to call InitGoogleTest\n  // this function is also called from RunAllTests.  Since this function can be\n  // called more than once, it has to be idempotent.\n  void PostFlagParsingInit();\n\n  // Gets the random seed used at the start of the current test iteration.\n  int random_seed() const { return random_seed_; }\n\n  // Gets the random number generator.\n  internal::Random* random() { return &random_; }\n\n  // Shuffles all test cases, and the tests within each test case,\n  // making sure that death tests are still run first.\n  void ShuffleTests();\n\n  // Restores the test cases and tests to their order before the first shuffle.\n  void UnshuffleTests();\n\n  // Returns the value of GTEST_FLAG(catch_exceptions) at the moment\n  // UnitTest::Run() starts.\n  bool catch_exceptions() const { return catch_exceptions_; }\n\n private:\n  friend class ::testing::UnitTest;\n\n  // Used by UnitTest::Run() to capture the state of\n  // GTEST_FLAG(catch_exceptions) at the moment it starts.\n  void set_catch_exceptions(bool value) { catch_exceptions_ = value; }\n\n  // The UnitTest object that owns this implementation object.\n  UnitTest* const parent_;\n\n  // The working directory when the first TEST() or TEST_F() was\n  // executed.\n  internal::FilePath original_working_dir_;\n\n  // The default test part result reporters.\n  DefaultGlobalTestPartResultReporter default_global_test_part_result_reporter_;\n  DefaultPerThreadTestPartResultReporter\n      default_per_thread_test_part_result_reporter_;\n\n  // Points to (but doesn't own) the global test part result reporter.\n  TestPartResultReporterInterface* global_test_part_result_repoter_;\n\n  // Protects read and write access to global_test_part_result_reporter_.\n  internal::Mutex global_test_part_result_reporter_mutex_;\n\n  // Points to (but doesn't own) the per-thread test part result reporter.\n  internal::ThreadLocal<TestPartResultReporterInterface*>\n      per_thread_test_part_result_reporter_;\n\n  // The vector of environments that need to be set-up/torn-down\n  // before/after the tests are run.\n  std::vector<Environment*> environments_;\n\n  // The vector of TestCases in their original order.  It owns the\n  // elements in the vector.\n  std::vector<TestCase*> test_cases_;\n\n  // Provides a level of indirection for the test case list to allow\n  // easy shuffling and restoring the test case order.  The i-th\n  // element of this vector is the index of the i-th test case in the\n  // shuffled order.\n  std::vector<int> test_case_indices_;\n\n#if GTEST_HAS_PARAM_TEST\n  // ParameterizedTestRegistry object used to register value-parameterized\n  // tests.\n  internal::ParameterizedTestCaseRegistry parameterized_test_registry_;\n\n  // Indicates whether RegisterParameterizedTests() has been called already.\n  bool parameterized_tests_registered_;\n#endif  // GTEST_HAS_PARAM_TEST\n\n  // Index of the last death test case registered.  Initially -1.\n  int last_death_test_case_;\n\n  // This points to the TestCase for the currently running test.  It\n  // changes as Google Test goes through one test case after another.\n  // When no test is running, this is set to NULL and Google Test\n  // stores assertion results in ad_hoc_test_result_.  Initially NULL.\n  TestCase* current_test_case_;\n\n  // This points to the TestInfo for the currently running test.  It\n  // changes as Google Test goes through one test after another.  When\n  // no test is running, this is set to NULL and Google Test stores\n  // assertion results in ad_hoc_test_result_.  Initially NULL.\n  TestInfo* current_test_info_;\n\n  // Normally, a user only writes assertions inside a TEST or TEST_F,\n  // or inside a function called by a TEST or TEST_F.  Since Google\n  // Test keeps track of which test is current running, it can\n  // associate such an assertion with the test it belongs to.\n  //\n  // If an assertion is encountered when no TEST or TEST_F is running,\n  // Google Test attributes the assertion result to an imaginary \"ad hoc\"\n  // test, and records the result in ad_hoc_test_result_.\n  TestResult ad_hoc_test_result_;\n\n  // The list of event listeners that can be used to track events inside\n  // Google Test.\n  TestEventListeners listeners_;\n\n  // The OS stack trace getter.  Will be deleted when the UnitTest\n  // object is destructed.  By default, an OsStackTraceGetter is used,\n  // but the user can set this field to use a custom getter if that is\n  // desired.\n  OsStackTraceGetterInterface* os_stack_trace_getter_;\n\n  // True iff PostFlagParsingInit() has been called.\n  bool post_flag_parse_init_performed_;\n\n  // The random number seed used at the beginning of the test run.\n  int random_seed_;\n\n  // Our random number generator.\n  internal::Random random_;\n\n  // The time of the test program start, in ms from the start of the\n  // UNIX epoch.\n  TimeInMillis start_timestamp_;\n\n  // How long the test took to run, in milliseconds.\n  TimeInMillis elapsed_time_;\n\n#if GTEST_HAS_DEATH_TEST\n  // The decomposed components of the gtest_internal_run_death_test flag,\n  // parsed when RUN_ALL_TESTS is called.\n  internal::scoped_ptr<InternalRunDeathTestFlag> internal_run_death_test_flag_;\n  internal::scoped_ptr<internal::DeathTestFactory> death_test_factory_;\n#endif  // GTEST_HAS_DEATH_TEST\n\n  // A per-thread stack of traces created by the SCOPED_TRACE() macro.\n  internal::ThreadLocal<std::vector<TraceInfo> > gtest_trace_stack_;\n\n  // The value of GTEST_FLAG(catch_exceptions) at the moment RunAllTests()\n  // starts.\n  bool catch_exceptions_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTestImpl);\n};  // class UnitTestImpl\n\n// Convenience function for accessing the global UnitTest\n// implementation object.\ninline UnitTestImpl* GetUnitTestImpl() {\n  return UnitTest::GetInstance()->impl();\n}\n\n#if GTEST_USES_SIMPLE_RE\n\n// Internal helper functions for implementing the simple regular\n// expression matcher.\nGTEST_API_ bool IsInSet(char ch, const char* str);\nGTEST_API_ bool IsAsciiDigit(char ch);\nGTEST_API_ bool IsAsciiPunct(char ch);\nGTEST_API_ bool IsRepeat(char ch);\nGTEST_API_ bool IsAsciiWhiteSpace(char ch);\nGTEST_API_ bool IsAsciiWordChar(char ch);\nGTEST_API_ bool IsValidEscape(char ch);\nGTEST_API_ bool AtomMatchesChar(bool escaped, char pattern, char ch);\nGTEST_API_ bool ValidateRegex(const char* regex);\nGTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str);\nGTEST_API_ bool MatchRepetitionAndRegexAtHead(\n    bool escaped, char ch, char repeat, const char* regex, const char* str);\nGTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str);\n\n#endif  // GTEST_USES_SIMPLE_RE\n\n// Parses the command line for Google Test flags, without initializing\n// other parts of Google Test.\nGTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, char** argv);\nGTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv);\n\n#if GTEST_HAS_DEATH_TEST\n\n// Returns the message describing the last system error, regardless of the\n// platform.\nGTEST_API_ std::string GetLastErrnoDescription();\n\n// Attempts to parse a string into a positive integer pointed to by the\n// number parameter.  Returns true if that is possible.\n// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we can use\n// it here.\ntemplate <typename Integer>\nbool ParseNaturalNumber(const ::std::string& str, Integer* number) {\n  // Fail fast if the given string does not begin with a digit;\n  // this bypasses strtoXXX's \"optional leading whitespace and plus\n  // or minus sign\" semantics, which are undesirable here.\n  if (str.empty() || !IsDigit(str[0])) {\n    return false;\n  }\n  errno = 0;\n\n  char* end;\n  // BiggestConvertible is the largest integer type that system-provided\n  // string-to-number conversion routines can return.\n\n# if GTEST_OS_WINDOWS && !defined(__GNUC__)\n\n  // MSVC and C++ Builder define __int64 instead of the standard long long.\n  typedef unsigned __int64 BiggestConvertible;\n  const BiggestConvertible parsed = _strtoui64(str.c_str(), &end, 10);\n\n# else\n\n  typedef unsigned long long BiggestConvertible;  // NOLINT\n  const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10);\n\n# endif  // GTEST_OS_WINDOWS && !defined(__GNUC__)\n\n  const bool parse_success = *end == '\\0' && errno == 0;\n\n  // TODO(vladl@google.com): Convert this to compile time assertion when it is\n  // available.\n  GTEST_CHECK_(sizeof(Integer) <= sizeof(parsed));\n\n  const Integer result = static_cast<Integer>(parsed);\n  if (parse_success && static_cast<BiggestConvertible>(result) == parsed) {\n    *number = result;\n    return true;\n  }\n  return false;\n}\n#endif  // GTEST_HAS_DEATH_TEST\n\n// TestResult contains some private methods that should be hidden from\n// Google Test user but are required for testing. This class allow our tests\n// to access them.\n//\n// This class is supplied only for the purpose of testing Google Test's own\n// constructs. Do not use it in user tests, either directly or indirectly.\nclass TestResultAccessor {\n public:\n  static void RecordProperty(TestResult* test_result,\n                             const std::string& xml_element,\n                             const TestProperty& property) {\n    test_result->RecordProperty(xml_element, property);\n  }\n\n  static void ClearTestPartResults(TestResult* test_result) {\n    test_result->ClearTestPartResults();\n  }\n\n  static const std::vector<testing::TestPartResult>& test_part_results(\n      const TestResult& test_result) {\n    return test_result.test_part_results();\n  }\n};\n\n#if GTEST_CAN_STREAM_RESULTS_\n\n// Streams test results to the given port on the given host machine.\nclass GTEST_API_ StreamingListener : public EmptyTestEventListener {\n public:\n  // Abstract base class for writing strings to a socket.\n  class AbstractSocketWriter {\n   public:\n    virtual ~AbstractSocketWriter() {}\n\n    // Sends a string to the socket.\n    virtual void Send(const string& message) = 0;\n\n    // Closes the socket.\n    virtual void CloseConnection() {}\n\n    // Sends a string and a newline to the socket.\n    void SendLn(const string& message) {\n      Send(message + \"\\n\");\n    }\n  };\n\n  // Concrete class for actually writing strings to a socket.\n  class SocketWriter : public AbstractSocketWriter {\n   public:\n    SocketWriter(const string& host, const string& port)\n        : sockfd_(-1), host_name_(host), port_num_(port) {\n      MakeConnection();\n    }\n\n    virtual ~SocketWriter() {\n      if (sockfd_ != -1)\n        CloseConnection();\n    }\n\n    // Sends a string to the socket.\n    virtual void Send(const string& message) {\n      GTEST_CHECK_(sockfd_ != -1)\n          << \"Send() can be called only when there is a connection.\";\n\n      const int len = static_cast<int>(message.length());\n      if (write(sockfd_, message.c_str(), len) != len) {\n        GTEST_LOG_(WARNING)\n            << \"stream_result_to: failed to stream to \"\n            << host_name_ << \":\" << port_num_;\n      }\n    }\n\n   private:\n    // Creates a client socket and connects to the server.\n    void MakeConnection();\n\n    // Closes the socket.\n    void CloseConnection() {\n      GTEST_CHECK_(sockfd_ != -1)\n          << \"CloseConnection() can be called only when there is a connection.\";\n\n      close(sockfd_);\n      sockfd_ = -1;\n    }\n\n    int sockfd_;  // socket file descriptor\n    const string host_name_;\n    const string port_num_;\n\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter);\n  };  // class SocketWriter\n\n  // Escapes '=', '&', '%', and '\\n' characters in str as \"%xx\".\n  static string UrlEncode(const char* str);\n\n  StreamingListener(const string& host, const string& port)\n      : socket_writer_(new SocketWriter(host, port)) { Start(); }\n\n  explicit StreamingListener(AbstractSocketWriter* socket_writer)\n      : socket_writer_(socket_writer) { Start(); }\n\n  void OnTestProgramStart(const UnitTest& /* unit_test */) {\n    SendLn(\"event=TestProgramStart\");\n  }\n\n  void OnTestProgramEnd(const UnitTest& unit_test) {\n    // Note that Google Test current only report elapsed time for each\n    // test iteration, not for the entire test program.\n    SendLn(\"event=TestProgramEnd&passed=\" + FormatBool(unit_test.Passed()));\n\n    // Notify the streaming server to stop.\n    socket_writer_->CloseConnection();\n  }\n\n  void OnTestIterationStart(const UnitTest& /* unit_test */, int iteration) {\n    SendLn(\"event=TestIterationStart&iteration=\" +\n           StreamableToString(iteration));\n  }\n\n  void OnTestIterationEnd(const UnitTest& unit_test, int /* iteration */) {\n    SendLn(\"event=TestIterationEnd&passed=\" +\n           FormatBool(unit_test.Passed()) + \"&elapsed_time=\" +\n           StreamableToString(unit_test.elapsed_time()) + \"ms\");\n  }\n\n  void OnTestCaseStart(const TestCase& test_case) {\n    SendLn(std::string(\"event=TestCaseStart&name=\") + test_case.name());\n  }\n\n  void OnTestCaseEnd(const TestCase& test_case) {\n    SendLn(\"event=TestCaseEnd&passed=\" + FormatBool(test_case.Passed())\n           + \"&elapsed_time=\" + StreamableToString(test_case.elapsed_time())\n           + \"ms\");\n  }\n\n  void OnTestStart(const TestInfo& test_info) {\n    SendLn(std::string(\"event=TestStart&name=\") + test_info.name());\n  }\n\n  void OnTestEnd(const TestInfo& test_info) {\n    SendLn(\"event=TestEnd&passed=\" +\n           FormatBool((test_info.result())->Passed()) +\n           \"&elapsed_time=\" +\n           StreamableToString((test_info.result())->elapsed_time()) + \"ms\");\n  }\n\n  void OnTestPartResult(const TestPartResult& test_part_result) {\n    const char* file_name = test_part_result.file_name();\n    if (file_name == NULL)\n      file_name = \"\";\n    SendLn(\"event=TestPartResult&file=\" + UrlEncode(file_name) +\n           \"&line=\" + StreamableToString(test_part_result.line_number()) +\n           \"&message=\" + UrlEncode(test_part_result.message()));\n  }\n\n private:\n  // Sends the given message and a newline to the socket.\n  void SendLn(const string& message) { socket_writer_->SendLn(message); }\n\n  // Called at the start of streaming to notify the receiver what\n  // protocol we are using.\n  void Start() { SendLn(\"gtest_streaming_protocol_version=1.0\"); }\n\n  string FormatBool(bool value) { return value ? \"1\" : \"0\"; }\n\n  const scoped_ptr<AbstractSocketWriter> socket_writer_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamingListener);\n};  // class StreamingListener\n\n#endif  // GTEST_CAN_STREAM_RESULTS_\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_SRC_GTEST_INTERNAL_INL_H_\n"
  },
  {
    "path": "utils/googletest/googletest/src/gtest-port.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/internal/gtest-port.h\"\n\n#include <limits.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <fstream>\n\n#if GTEST_OS_WINDOWS\n# include <windows.h>\n# include <io.h>\n# include <sys/stat.h>\n# include <map>  // Used in ThreadLocal.\n#else\n# include <unistd.h>\n#endif  // GTEST_OS_WINDOWS\n\n#if GTEST_OS_MAC\n# include <mach/mach_init.h>\n# include <mach/task.h>\n# include <mach/vm_map.h>\n#endif  // GTEST_OS_MAC\n\n#if GTEST_OS_QNX\n# include <devctl.h>\n# include <fcntl.h>\n# include <sys/procfs.h>\n#endif  // GTEST_OS_QNX\n\n#if GTEST_OS_AIX\n# include <procinfo.h>\n# include <sys/types.h>\n#endif  // GTEST_OS_AIX\n\n#include \"gtest/gtest-spi.h\"\n#include \"gtest/gtest-message.h\"\n#include \"gtest/internal/gtest-internal.h\"\n#include \"gtest/internal/gtest-string.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick exists to\n// prevent the accidental inclusion of gtest-internal-inl.h in the\n// user's code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nnamespace testing {\nnamespace internal {\n\n#if defined(_MSC_VER) || defined(__BORLANDC__)\n// MSVC and C++Builder do not provide a definition of STDERR_FILENO.\nconst int kStdOutFileno = 1;\nconst int kStdErrFileno = 2;\n#else\nconst int kStdOutFileno = STDOUT_FILENO;\nconst int kStdErrFileno = STDERR_FILENO;\n#endif  // _MSC_VER\n\n#if GTEST_OS_LINUX\n\nnamespace {\ntemplate <typename T>\nT ReadProcFileField(const string& filename, int field) {\n  std::string dummy;\n  std::ifstream file(filename.c_str());\n  while (field-- > 0) {\n    file >> dummy;\n  }\n  T output = 0;\n  file >> output;\n  return output;\n}\n}  // namespace\n\n// Returns the number of active threads, or 0 when there is an error.\nsize_t GetThreadCount() {\n  const string filename =\n      (Message() << \"/proc/\" << getpid() << \"/stat\").GetString();\n  return ReadProcFileField<int>(filename, 19);\n}\n\n#elif GTEST_OS_MAC\n\nsize_t GetThreadCount() {\n  const task_t task = mach_task_self();\n  mach_msg_type_number_t thread_count;\n  thread_act_array_t thread_list;\n  const kern_return_t status = task_threads(task, &thread_list, &thread_count);\n  if (status == KERN_SUCCESS) {\n    // task_threads allocates resources in thread_list and we need to free them\n    // to avoid leaks.\n    vm_deallocate(task,\n                  reinterpret_cast<vm_address_t>(thread_list),\n                  sizeof(thread_t) * thread_count);\n    return static_cast<size_t>(thread_count);\n  } else {\n    return 0;\n  }\n}\n\n#elif GTEST_OS_QNX\n\n// Returns the number of threads running in the process, or 0 to indicate that\n// we cannot detect it.\nsize_t GetThreadCount() {\n  const int fd = open(\"/proc/self/as\", O_RDONLY);\n  if (fd < 0) {\n    return 0;\n  }\n  procfs_info process_info;\n  const int status =\n      devctl(fd, DCMD_PROC_INFO, &process_info, sizeof(process_info), NULL);\n  close(fd);\n  if (status == EOK) {\n    return static_cast<size_t>(process_info.num_threads);\n  } else {\n    return 0;\n  }\n}\n\n#elif GTEST_OS_AIX\n\nsize_t GetThreadCount() {\n  struct procentry64 entry;\n  pid_t pid = getpid();\n  int status = getprocs64(&entry, sizeof(entry), NULL, 0, &pid, 1);\n  if (status == 1) {\n    return entry.pi_thcount;\n  } else {\n    return 0;\n  }\n}\n\n#else\n\nsize_t GetThreadCount() {\n  // There's no portable way to detect the number of threads, so we just\n  // return 0 to indicate that we cannot detect it.\n  return 0;\n}\n\n#endif  // GTEST_OS_LINUX\n\n#if GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS\n\nvoid SleepMilliseconds(int n) {\n  ::Sleep(n);\n}\n\nAutoHandle::AutoHandle()\n    : handle_(INVALID_HANDLE_VALUE) {}\n\nAutoHandle::AutoHandle(Handle handle)\n    : handle_(handle) {}\n\nAutoHandle::~AutoHandle() {\n  Reset();\n}\n\nAutoHandle::Handle AutoHandle::Get() const {\n  return handle_;\n}\n\nvoid AutoHandle::Reset() {\n  Reset(INVALID_HANDLE_VALUE);\n}\n\nvoid AutoHandle::Reset(HANDLE handle) {\n  // Resetting with the same handle we already own is invalid.\n  if (handle_ != handle) {\n    if (IsCloseable()) {\n      ::CloseHandle(handle_);\n    }\n    handle_ = handle;\n  } else {\n    GTEST_CHECK_(!IsCloseable())\n        << \"Resetting a valid handle to itself is likely a programmer error \"\n            \"and thus not allowed.\";\n  }\n}\n\nbool AutoHandle::IsCloseable() const {\n  // Different Windows APIs may use either of these values to represent an\n  // invalid handle.\n  return handle_ != NULL && handle_ != INVALID_HANDLE_VALUE;\n}\n\nNotification::Notification()\n    : event_(::CreateEvent(NULL,   // Default security attributes.\n                           TRUE,   // Do not reset automatically.\n                           FALSE,  // Initially unset.\n                           NULL)) {  // Anonymous event.\n  GTEST_CHECK_(event_.Get() != NULL);\n}\n\nvoid Notification::Notify() {\n  GTEST_CHECK_(::SetEvent(event_.Get()) != FALSE);\n}\n\nvoid Notification::WaitForNotification() {\n  GTEST_CHECK_(\n      ::WaitForSingleObject(event_.Get(), INFINITE) == WAIT_OBJECT_0);\n}\n\nMutex::Mutex()\n    : owner_thread_id_(0),\n      type_(kDynamic),\n      critical_section_init_phase_(0),\n      critical_section_(new CRITICAL_SECTION) {\n  ::InitializeCriticalSection(critical_section_);\n}\n\nMutex::~Mutex() {\n  // Static mutexes are leaked intentionally. It is not thread-safe to try\n  // to clean them up.\n  // TODO(yukawa): Switch to Slim Reader/Writer (SRW) Locks, which requires\n  // nothing to clean it up but is available only on Vista and later.\n  // http://msdn.microsoft.com/en-us/library/windows/desktop/aa904937.aspx\n  if (type_ == kDynamic) {\n    ::DeleteCriticalSection(critical_section_);\n    delete critical_section_;\n    critical_section_ = NULL;\n  }\n}\n\nvoid Mutex::Lock() {\n  ThreadSafeLazyInit();\n  ::EnterCriticalSection(critical_section_);\n  owner_thread_id_ = ::GetCurrentThreadId();\n}\n\nvoid Mutex::Unlock() {\n  ThreadSafeLazyInit();\n  // We don't protect writing to owner_thread_id_ here, as it's the\n  // caller's responsibility to ensure that the current thread holds the\n  // mutex when this is called.\n  owner_thread_id_ = 0;\n  ::LeaveCriticalSection(critical_section_);\n}\n\n// Does nothing if the current thread holds the mutex. Otherwise, crashes\n// with high probability.\nvoid Mutex::AssertHeld() {\n  ThreadSafeLazyInit();\n  GTEST_CHECK_(owner_thread_id_ == ::GetCurrentThreadId())\n      << \"The current thread is not holding the mutex @\" << this;\n}\n\n// Initializes owner_thread_id_ and critical_section_ in static mutexes.\nvoid Mutex::ThreadSafeLazyInit() {\n  // Dynamic mutexes are initialized in the constructor.\n  if (type_ == kStatic) {\n    switch (\n        ::InterlockedCompareExchange(&critical_section_init_phase_, 1L, 0L)) {\n      case 0:\n        // If critical_section_init_phase_ was 0 before the exchange, we\n        // are the first to test it and need to perform the initialization.\n        owner_thread_id_ = 0;\n        critical_section_ = new CRITICAL_SECTION;\n        ::InitializeCriticalSection(critical_section_);\n        // Updates the critical_section_init_phase_ to 2 to signal\n        // initialization complete.\n        GTEST_CHECK_(::InterlockedCompareExchange(\n                          &critical_section_init_phase_, 2L, 1L) ==\n                      1L);\n        break;\n      case 1:\n        // Somebody else is already initializing the mutex; spin until they\n        // are done.\n        while (::InterlockedCompareExchange(&critical_section_init_phase_,\n                                            2L,\n                                            2L) != 2L) {\n          // Possibly yields the rest of the thread's time slice to other\n          // threads.\n          ::Sleep(0);\n        }\n        break;\n\n      case 2:\n        break;  // The mutex is already initialized and ready for use.\n\n      default:\n        GTEST_CHECK_(false)\n            << \"Unexpected value of critical_section_init_phase_ \"\n            << \"while initializing a static mutex.\";\n    }\n  }\n}\n\nnamespace {\n\nclass ThreadWithParamSupport : public ThreadWithParamBase {\n public:\n  static HANDLE CreateThread(Runnable* runnable,\n                             Notification* thread_can_start) {\n    ThreadMainParam* param = new ThreadMainParam(runnable, thread_can_start);\n    DWORD thread_id;\n    // TODO(yukawa): Consider to use _beginthreadex instead.\n    HANDLE thread_handle = ::CreateThread(\n        NULL,    // Default security.\n        0,       // Default stack size.\n        &ThreadWithParamSupport::ThreadMain,\n        param,   // Parameter to ThreadMainStatic\n        0x0,     // Default creation flags.\n        &thread_id);  // Need a valid pointer for the call to work under Win98.\n    GTEST_CHECK_(thread_handle != NULL) << \"CreateThread failed with error \"\n                                        << ::GetLastError() << \".\";\n    if (thread_handle == NULL) {\n      delete param;\n    }\n    return thread_handle;\n  }\n\n private:\n  struct ThreadMainParam {\n    ThreadMainParam(Runnable* runnable, Notification* thread_can_start)\n        : runnable_(runnable),\n          thread_can_start_(thread_can_start) {\n    }\n    scoped_ptr<Runnable> runnable_;\n    // Does not own.\n    Notification* thread_can_start_;\n  };\n\n  static DWORD WINAPI ThreadMain(void* ptr) {\n    // Transfers ownership.\n    scoped_ptr<ThreadMainParam> param(static_cast<ThreadMainParam*>(ptr));\n    if (param->thread_can_start_ != NULL)\n      param->thread_can_start_->WaitForNotification();\n    param->runnable_->Run();\n    return 0;\n  }\n\n  // Prohibit instantiation.\n  ThreadWithParamSupport();\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParamSupport);\n};\n\n}  // namespace\n\nThreadWithParamBase::ThreadWithParamBase(Runnable *runnable,\n                                         Notification* thread_can_start)\n      : thread_(ThreadWithParamSupport::CreateThread(runnable,\n                                                     thread_can_start)) {\n}\n\nThreadWithParamBase::~ThreadWithParamBase() {\n  Join();\n}\n\nvoid ThreadWithParamBase::Join() {\n  GTEST_CHECK_(::WaitForSingleObject(thread_.Get(), INFINITE) == WAIT_OBJECT_0)\n      << \"Failed to join the thread with error \" << ::GetLastError() << \".\";\n}\n\n// Maps a thread to a set of ThreadIdToThreadLocals that have values\n// instantiated on that thread and notifies them when the thread exits.  A\n// ThreadLocal instance is expected to persist until all threads it has\n// values on have terminated.\nclass ThreadLocalRegistryImpl {\n public:\n  // Registers thread_local_instance as having value on the current thread.\n  // Returns a value that can be used to identify the thread from other threads.\n  static ThreadLocalValueHolderBase* GetValueOnCurrentThread(\n      const ThreadLocalBase* thread_local_instance) {\n    DWORD current_thread = ::GetCurrentThreadId();\n    MutexLock lock(&mutex_);\n    ThreadIdToThreadLocals* const thread_to_thread_locals =\n        GetThreadLocalsMapLocked();\n    ThreadIdToThreadLocals::iterator thread_local_pos =\n        thread_to_thread_locals->find(current_thread);\n    if (thread_local_pos == thread_to_thread_locals->end()) {\n      thread_local_pos = thread_to_thread_locals->insert(\n          std::make_pair(current_thread, ThreadLocalValues())).first;\n      StartWatcherThreadFor(current_thread);\n    }\n    ThreadLocalValues& thread_local_values = thread_local_pos->second;\n    ThreadLocalValues::iterator value_pos =\n        thread_local_values.find(thread_local_instance);\n    if (value_pos == thread_local_values.end()) {\n      value_pos =\n          thread_local_values\n              .insert(std::make_pair(\n                  thread_local_instance,\n                  linked_ptr<ThreadLocalValueHolderBase>(\n                      thread_local_instance->NewValueForCurrentThread())))\n              .first;\n    }\n    return value_pos->second.get();\n  }\n\n  static void OnThreadLocalDestroyed(\n      const ThreadLocalBase* thread_local_instance) {\n    std::vector<linked_ptr<ThreadLocalValueHolderBase> > value_holders;\n    // Clean up the ThreadLocalValues data structure while holding the lock, but\n    // defer the destruction of the ThreadLocalValueHolderBases.\n    {\n      MutexLock lock(&mutex_);\n      ThreadIdToThreadLocals* const thread_to_thread_locals =\n          GetThreadLocalsMapLocked();\n      for (ThreadIdToThreadLocals::iterator it =\n          thread_to_thread_locals->begin();\n          it != thread_to_thread_locals->end();\n          ++it) {\n        ThreadLocalValues& thread_local_values = it->second;\n        ThreadLocalValues::iterator value_pos =\n            thread_local_values.find(thread_local_instance);\n        if (value_pos != thread_local_values.end()) {\n          value_holders.push_back(value_pos->second);\n          thread_local_values.erase(value_pos);\n          // This 'if' can only be successful at most once, so theoretically we\n          // could break out of the loop here, but we don't bother doing so.\n        }\n      }\n    }\n    // Outside the lock, let the destructor for 'value_holders' deallocate the\n    // ThreadLocalValueHolderBases.\n  }\n\n  static void OnThreadExit(DWORD thread_id) {\n    GTEST_CHECK_(thread_id != 0) << ::GetLastError();\n    std::vector<linked_ptr<ThreadLocalValueHolderBase> > value_holders;\n    // Clean up the ThreadIdToThreadLocals data structure while holding the\n    // lock, but defer the destruction of the ThreadLocalValueHolderBases.\n    {\n      MutexLock lock(&mutex_);\n      ThreadIdToThreadLocals* const thread_to_thread_locals =\n          GetThreadLocalsMapLocked();\n      ThreadIdToThreadLocals::iterator thread_local_pos =\n          thread_to_thread_locals->find(thread_id);\n      if (thread_local_pos != thread_to_thread_locals->end()) {\n        ThreadLocalValues& thread_local_values = thread_local_pos->second;\n        for (ThreadLocalValues::iterator value_pos =\n            thread_local_values.begin();\n            value_pos != thread_local_values.end();\n            ++value_pos) {\n          value_holders.push_back(value_pos->second);\n        }\n        thread_to_thread_locals->erase(thread_local_pos);\n      }\n    }\n    // Outside the lock, let the destructor for 'value_holders' deallocate the\n    // ThreadLocalValueHolderBases.\n  }\n\n private:\n  // In a particular thread, maps a ThreadLocal object to its value.\n  typedef std::map<const ThreadLocalBase*,\n                   linked_ptr<ThreadLocalValueHolderBase> > ThreadLocalValues;\n  // Stores all ThreadIdToThreadLocals having values in a thread, indexed by\n  // thread's ID.\n  typedef std::map<DWORD, ThreadLocalValues> ThreadIdToThreadLocals;\n\n  // Holds the thread id and thread handle that we pass from\n  // StartWatcherThreadFor to WatcherThreadFunc.\n  typedef std::pair<DWORD, HANDLE> ThreadIdAndHandle;\n\n  static void StartWatcherThreadFor(DWORD thread_id) {\n    // The returned handle will be kept in thread_map and closed by\n    // watcher_thread in WatcherThreadFunc.\n    HANDLE thread = ::OpenThread(SYNCHRONIZE | THREAD_QUERY_INFORMATION,\n                                 FALSE,\n                                 thread_id);\n    GTEST_CHECK_(thread != NULL);\n    // We need to to pass a valid thread ID pointer into CreateThread for it\n    // to work correctly under Win98.\n    DWORD watcher_thread_id;\n    HANDLE watcher_thread = ::CreateThread(\n        NULL,   // Default security.\n        0,      // Default stack size\n        &ThreadLocalRegistryImpl::WatcherThreadFunc,\n        reinterpret_cast<LPVOID>(new ThreadIdAndHandle(thread_id, thread)),\n        CREATE_SUSPENDED,\n        &watcher_thread_id);\n    GTEST_CHECK_(watcher_thread != NULL);\n    // Give the watcher thread the same priority as ours to avoid being\n    // blocked by it.\n    ::SetThreadPriority(watcher_thread,\n                        ::GetThreadPriority(::GetCurrentThread()));\n    ::ResumeThread(watcher_thread);\n    ::CloseHandle(watcher_thread);\n  }\n\n  // Monitors exit from a given thread and notifies those\n  // ThreadIdToThreadLocals about thread termination.\n  static DWORD WINAPI WatcherThreadFunc(LPVOID param) {\n    const ThreadIdAndHandle* tah =\n        reinterpret_cast<const ThreadIdAndHandle*>(param);\n    GTEST_CHECK_(\n        ::WaitForSingleObject(tah->second, INFINITE) == WAIT_OBJECT_0);\n    OnThreadExit(tah->first);\n    ::CloseHandle(tah->second);\n    delete tah;\n    return 0;\n  }\n\n  // Returns map of thread local instances.\n  static ThreadIdToThreadLocals* GetThreadLocalsMapLocked() {\n    mutex_.AssertHeld();\n    static ThreadIdToThreadLocals* map = new ThreadIdToThreadLocals;\n    return map;\n  }\n\n  // Protects access to GetThreadLocalsMapLocked() and its return value.\n  static Mutex mutex_;\n  // Protects access to GetThreadMapLocked() and its return value.\n  static Mutex thread_map_mutex_;\n};\n\nMutex ThreadLocalRegistryImpl::mutex_(Mutex::kStaticMutex);\nMutex ThreadLocalRegistryImpl::thread_map_mutex_(Mutex::kStaticMutex);\n\nThreadLocalValueHolderBase* ThreadLocalRegistry::GetValueOnCurrentThread(\n      const ThreadLocalBase* thread_local_instance) {\n  return ThreadLocalRegistryImpl::GetValueOnCurrentThread(\n      thread_local_instance);\n}\n\nvoid ThreadLocalRegistry::OnThreadLocalDestroyed(\n      const ThreadLocalBase* thread_local_instance) {\n  ThreadLocalRegistryImpl::OnThreadLocalDestroyed(thread_local_instance);\n}\n\n#endif  // GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS\n\n#if GTEST_USES_POSIX_RE\n\n// Implements RE.  Currently only needed for death tests.\n\nRE::~RE() {\n  if (is_valid_) {\n    // regfree'ing an invalid regex might crash because the content\n    // of the regex is undefined. Since the regex's are essentially\n    // the same, one cannot be valid (or invalid) without the other\n    // being so too.\n    regfree(&partial_regex_);\n    regfree(&full_regex_);\n  }\n  free(const_cast<char*>(pattern_));\n}\n\n// Returns true iff regular expression re matches the entire str.\nbool RE::FullMatch(const char* str, const RE& re) {\n  if (!re.is_valid_) return false;\n\n  regmatch_t match;\n  return regexec(&re.full_regex_, str, 1, &match, 0) == 0;\n}\n\n// Returns true iff regular expression re matches a substring of str\n// (including str itself).\nbool RE::PartialMatch(const char* str, const RE& re) {\n  if (!re.is_valid_) return false;\n\n  regmatch_t match;\n  return regexec(&re.partial_regex_, str, 1, &match, 0) == 0;\n}\n\n// Initializes an RE from its string representation.\nvoid RE::Init(const char* regex) {\n  pattern_ = posix::StrDup(regex);\n\n  // Reserves enough bytes to hold the regular expression used for a\n  // full match.\n  const size_t full_regex_len = strlen(regex) + 10;\n  char* const full_pattern = new char[full_regex_len];\n\n  snprintf(full_pattern, full_regex_len, \"^(%s)$\", regex);\n  is_valid_ = regcomp(&full_regex_, full_pattern, REG_EXTENDED) == 0;\n  // We want to call regcomp(&partial_regex_, ...) even if the\n  // previous expression returns false.  Otherwise partial_regex_ may\n  // not be properly initialized can may cause trouble when it's\n  // freed.\n  //\n  // Some implementation of POSIX regex (e.g. on at least some\n  // versions of Cygwin) doesn't accept the empty string as a valid\n  // regex.  We change it to an equivalent form \"()\" to be safe.\n  if (is_valid_) {\n    const char* const partial_regex = (*regex == '\\0') ? \"()\" : regex;\n    is_valid_ = regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0;\n  }\n  EXPECT_TRUE(is_valid_)\n      << \"Regular expression \\\"\" << regex\n      << \"\\\" is not a valid POSIX Extended regular expression.\";\n\n  delete[] full_pattern;\n}\n\n#elif GTEST_USES_SIMPLE_RE\n\n// Returns true iff ch appears anywhere in str (excluding the\n// terminating '\\0' character).\nbool IsInSet(char ch, const char* str) {\n  return ch != '\\0' && strchr(str, ch) != NULL;\n}\n\n// Returns true iff ch belongs to the given classification.  Unlike\n// similar functions in <ctype.h>, these aren't affected by the\n// current locale.\nbool IsAsciiDigit(char ch) { return '0' <= ch && ch <= '9'; }\nbool IsAsciiPunct(char ch) {\n  return IsInSet(ch, \"^-!\\\"#$%&'()*+,./:;<=>?@[\\\\]_`{|}~\");\n}\nbool IsRepeat(char ch) { return IsInSet(ch, \"?*+\"); }\nbool IsAsciiWhiteSpace(char ch) { return IsInSet(ch, \" \\f\\n\\r\\t\\v\"); }\nbool IsAsciiWordChar(char ch) {\n  return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') ||\n      ('0' <= ch && ch <= '9') || ch == '_';\n}\n\n// Returns true iff \"\\\\c\" is a supported escape sequence.\nbool IsValidEscape(char c) {\n  return (IsAsciiPunct(c) || IsInSet(c, \"dDfnrsStvwW\"));\n}\n\n// Returns true iff the given atom (specified by escaped and pattern)\n// matches ch.  The result is undefined if the atom is invalid.\nbool AtomMatchesChar(bool escaped, char pattern_char, char ch) {\n  if (escaped) {  // \"\\\\p\" where p is pattern_char.\n    switch (pattern_char) {\n      case 'd': return IsAsciiDigit(ch);\n      case 'D': return !IsAsciiDigit(ch);\n      case 'f': return ch == '\\f';\n      case 'n': return ch == '\\n';\n      case 'r': return ch == '\\r';\n      case 's': return IsAsciiWhiteSpace(ch);\n      case 'S': return !IsAsciiWhiteSpace(ch);\n      case 't': return ch == '\\t';\n      case 'v': return ch == '\\v';\n      case 'w': return IsAsciiWordChar(ch);\n      case 'W': return !IsAsciiWordChar(ch);\n    }\n    return IsAsciiPunct(pattern_char) && pattern_char == ch;\n  }\n\n  return (pattern_char == '.' && ch != '\\n') || pattern_char == ch;\n}\n\n// Helper function used by ValidateRegex() to format error messages.\nstd::string FormatRegexSyntaxError(const char* regex, int index) {\n  return (Message() << \"Syntax error at index \" << index\n          << \" in simple regular expression \\\"\" << regex << \"\\\": \").GetString();\n}\n\n// Generates non-fatal failures and returns false if regex is invalid;\n// otherwise returns true.\nbool ValidateRegex(const char* regex) {\n  if (regex == NULL) {\n    // TODO(wan@google.com): fix the source file location in the\n    // assertion failures to match where the regex is used in user\n    // code.\n    ADD_FAILURE() << \"NULL is not a valid simple regular expression.\";\n    return false;\n  }\n\n  bool is_valid = true;\n\n  // True iff ?, *, or + can follow the previous atom.\n  bool prev_repeatable = false;\n  for (int i = 0; regex[i]; i++) {\n    if (regex[i] == '\\\\') {  // An escape sequence\n      i++;\n      if (regex[i] == '\\0') {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)\n                      << \"'\\\\' cannot appear at the end.\";\n        return false;\n      }\n\n      if (!IsValidEscape(regex[i])) {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)\n                      << \"invalid escape sequence \\\"\\\\\" << regex[i] << \"\\\".\";\n        is_valid = false;\n      }\n      prev_repeatable = true;\n    } else {  // Not an escape sequence.\n      const char ch = regex[i];\n\n      if (ch == '^' && i > 0) {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)\n                      << \"'^' can only appear at the beginning.\";\n        is_valid = false;\n      } else if (ch == '$' && regex[i + 1] != '\\0') {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)\n                      << \"'$' can only appear at the end.\";\n        is_valid = false;\n      } else if (IsInSet(ch, \"()[]{}|\")) {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)\n                      << \"'\" << ch << \"' is unsupported.\";\n        is_valid = false;\n      } else if (IsRepeat(ch) && !prev_repeatable) {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)\n                      << \"'\" << ch << \"' can only follow a repeatable token.\";\n        is_valid = false;\n      }\n\n      prev_repeatable = !IsInSet(ch, \"^$?*+\");\n    }\n  }\n\n  return is_valid;\n}\n\n// Matches a repeated regex atom followed by a valid simple regular\n// expression.  The regex atom is defined as c if escaped is false,\n// or \\c otherwise.  repeat is the repetition meta character (?, *,\n// or +).  The behavior is undefined if str contains too many\n// characters to be indexable by size_t, in which case the test will\n// probably time out anyway.  We are fine with this limitation as\n// std::string has it too.\nbool MatchRepetitionAndRegexAtHead(\n    bool escaped, char c, char repeat, const char* regex,\n    const char* str) {\n  const size_t min_count = (repeat == '+') ? 1 : 0;\n  const size_t max_count = (repeat == '?') ? 1 :\n      static_cast<size_t>(-1) - 1;\n  // We cannot call numeric_limits::max() as it conflicts with the\n  // max() macro on Windows.\n\n  for (size_t i = 0; i <= max_count; ++i) {\n    // We know that the atom matches each of the first i characters in str.\n    if (i >= min_count && MatchRegexAtHead(regex, str + i)) {\n      // We have enough matches at the head, and the tail matches too.\n      // Since we only care about *whether* the pattern matches str\n      // (as opposed to *how* it matches), there is no need to find a\n      // greedy match.\n      return true;\n    }\n    if (str[i] == '\\0' || !AtomMatchesChar(escaped, c, str[i]))\n      return false;\n  }\n  return false;\n}\n\n// Returns true iff regex matches a prefix of str.  regex must be a\n// valid simple regular expression and not start with \"^\", or the\n// result is undefined.\nbool MatchRegexAtHead(const char* regex, const char* str) {\n  if (*regex == '\\0')  // An empty regex matches a prefix of anything.\n    return true;\n\n  // \"$\" only matches the end of a string.  Note that regex being\n  // valid guarantees that there's nothing after \"$\" in it.\n  if (*regex == '$')\n    return *str == '\\0';\n\n  // Is the first thing in regex an escape sequence?\n  const bool escaped = *regex == '\\\\';\n  if (escaped)\n    ++regex;\n  if (IsRepeat(regex[1])) {\n    // MatchRepetitionAndRegexAtHead() calls MatchRegexAtHead(), so\n    // here's an indirect recursion.  It terminates as the regex gets\n    // shorter in each recursion.\n    return MatchRepetitionAndRegexAtHead(\n        escaped, regex[0], regex[1], regex + 2, str);\n  } else {\n    // regex isn't empty, isn't \"$\", and doesn't start with a\n    // repetition.  We match the first atom of regex with the first\n    // character of str and recurse.\n    return (*str != '\\0') && AtomMatchesChar(escaped, *regex, *str) &&\n        MatchRegexAtHead(regex + 1, str + 1);\n  }\n}\n\n// Returns true iff regex matches any substring of str.  regex must be\n// a valid simple regular expression, or the result is undefined.\n//\n// The algorithm is recursive, but the recursion depth doesn't exceed\n// the regex length, so we won't need to worry about running out of\n// stack space normally.  In rare cases the time complexity can be\n// exponential with respect to the regex length + the string length,\n// but usually it's must faster (often close to linear).\nbool MatchRegexAnywhere(const char* regex, const char* str) {\n  if (regex == NULL || str == NULL)\n    return false;\n\n  if (*regex == '^')\n    return MatchRegexAtHead(regex + 1, str);\n\n  // A successful match can be anywhere in str.\n  do {\n    if (MatchRegexAtHead(regex, str))\n      return true;\n  } while (*str++ != '\\0');\n  return false;\n}\n\n// Implements the RE class.\n\nRE::~RE() {\n  free(const_cast<char*>(pattern_));\n  free(const_cast<char*>(full_pattern_));\n}\n\n// Returns true iff regular expression re matches the entire str.\nbool RE::FullMatch(const char* str, const RE& re) {\n  return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str);\n}\n\n// Returns true iff regular expression re matches a substring of str\n// (including str itself).\nbool RE::PartialMatch(const char* str, const RE& re) {\n  return re.is_valid_ && MatchRegexAnywhere(re.pattern_, str);\n}\n\n// Initializes an RE from its string representation.\nvoid RE::Init(const char* regex) {\n  pattern_ = full_pattern_ = NULL;\n  if (regex != NULL) {\n    pattern_ = posix::StrDup(regex);\n  }\n\n  is_valid_ = ValidateRegex(regex);\n  if (!is_valid_) {\n    // No need to calculate the full pattern when the regex is invalid.\n    return;\n  }\n\n  const size_t len = strlen(regex);\n  // Reserves enough bytes to hold the regular expression used for a\n  // full match: we need space to prepend a '^', append a '$', and\n  // terminate the string with '\\0'.\n  char* buffer = static_cast<char*>(malloc(len + 3));\n  full_pattern_ = buffer;\n\n  if (*regex != '^')\n    *buffer++ = '^';  // Makes sure full_pattern_ starts with '^'.\n\n  // We don't use snprintf or strncpy, as they trigger a warning when\n  // compiled with VC++ 8.0.\n  memcpy(buffer, regex, len);\n  buffer += len;\n\n  if (len == 0 || regex[len - 1] != '$')\n    *buffer++ = '$';  // Makes sure full_pattern_ ends with '$'.\n\n  *buffer = '\\0';\n}\n\n#endif  // GTEST_USES_POSIX_RE\n\nconst char kUnknownFile[] = \"unknown file\";\n\n// Formats a source file path and a line number as they would appear\n// in an error message from the compiler used to compile this code.\nGTEST_API_ ::std::string FormatFileLocation(const char* file, int line) {\n  const std::string file_name(file == NULL ? kUnknownFile : file);\n\n  if (line < 0) {\n    return file_name + \":\";\n  }\n#ifdef _MSC_VER\n  return file_name + \"(\" + StreamableToString(line) + \"):\";\n#else\n  return file_name + \":\" + StreamableToString(line) + \":\";\n#endif  // _MSC_VER\n}\n\n// Formats a file location for compiler-independent XML output.\n// Although this function is not platform dependent, we put it next to\n// FormatFileLocation in order to contrast the two functions.\n// Note that FormatCompilerIndependentFileLocation() does NOT append colon\n// to the file location it produces, unlike FormatFileLocation().\nGTEST_API_ ::std::string FormatCompilerIndependentFileLocation(\n    const char* file, int line) {\n  const std::string file_name(file == NULL ? kUnknownFile : file);\n\n  if (line < 0)\n    return file_name;\n  else\n    return file_name + \":\" + StreamableToString(line);\n}\n\nGTestLog::GTestLog(GTestLogSeverity severity, const char* file, int line)\n    : severity_(severity) {\n  const char* const marker =\n      severity == GTEST_INFO ?    \"[  INFO ]\" :\n      severity == GTEST_WARNING ? \"[WARNING]\" :\n      severity == GTEST_ERROR ?   \"[ ERROR ]\" : \"[ FATAL ]\";\n  GetStream() << ::std::endl << marker << \" \"\n              << FormatFileLocation(file, line).c_str() << \": \";\n}\n\n// Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.\nGTestLog::~GTestLog() {\n  GetStream() << ::std::endl;\n  if (severity_ == GTEST_FATAL) {\n    fflush(stderr);\n    posix::Abort();\n  }\n}\n// Disable Microsoft deprecation warnings for POSIX functions called from\n// this class (creat, dup, dup2, and close)\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)\n\n#if GTEST_HAS_STREAM_REDIRECTION\n\n// Object that captures an output stream (stdout/stderr).\nclass CapturedStream {\n public:\n  // The ctor redirects the stream to a temporary file.\n  explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) {\n# if GTEST_OS_WINDOWS\n    char temp_dir_path[MAX_PATH + 1] = { '\\0' };  // NOLINT\n    char temp_file_path[MAX_PATH + 1] = { '\\0' };  // NOLINT\n\n    ::GetTempPathA(sizeof(temp_dir_path), temp_dir_path);\n    const UINT success = ::GetTempFileNameA(temp_dir_path,\n                                            \"gtest_redir\",\n                                            0,  // Generate unique file name.\n                                            temp_file_path);\n    GTEST_CHECK_(success != 0)\n        << \"Unable to create a temporary file in \" << temp_dir_path;\n    const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE);\n    GTEST_CHECK_(captured_fd != -1) << \"Unable to open temporary file \"\n                                    << temp_file_path;\n    filename_ = temp_file_path;\n# else\n    // There's no guarantee that a test has write access to the current\n    // directory, so we create the temporary file in the /tmp directory\n    // instead. We use /tmp on most systems, and /sdcard on Android.\n    // That's because Android doesn't have /tmp.\n#  if GTEST_OS_LINUX_ANDROID\n    // Note: Android applications are expected to call the framework's\n    // Context.getExternalStorageDirectory() method through JNI to get\n    // the location of the world-writable SD Card directory. However,\n    // this requires a Context handle, which cannot be retrieved\n    // globally from native code. Doing so also precludes running the\n    // code as part of a regular standalone executable, which doesn't\n    // run in a Dalvik process (e.g. when running it through 'adb shell').\n    //\n    // The location /sdcard is directly accessible from native code\n    // and is the only location (unofficially) supported by the Android\n    // team. It's generally a symlink to the real SD Card mount point\n    // which can be /mnt/sdcard, /mnt/sdcard0, /system/media/sdcard, or\n    // other OEM-customized locations. Never rely on these, and always\n    // use /sdcard.\n    char name_template[] = \"/sdcard/gtest_captured_stream.XXXXXX\";\n#  else\n    char name_template[] = \"/tmp/captured_stream.XXXXXX\";\n#  endif  // GTEST_OS_LINUX_ANDROID\n    const int captured_fd = mkstemp(name_template);\n    filename_ = name_template;\n# endif  // GTEST_OS_WINDOWS\n    fflush(NULL);\n    dup2(captured_fd, fd_);\n    close(captured_fd);\n  }\n\n  ~CapturedStream() {\n    remove(filename_.c_str());\n  }\n\n  std::string GetCapturedString() {\n    if (uncaptured_fd_ != -1) {\n      // Restores the original stream.\n      fflush(NULL);\n      dup2(uncaptured_fd_, fd_);\n      close(uncaptured_fd_);\n      uncaptured_fd_ = -1;\n    }\n\n    FILE* const file = posix::FOpen(filename_.c_str(), \"r\");\n    const std::string content = ReadEntireFile(file);\n    posix::FClose(file);\n    return content;\n  }\n\n private:\n  const int fd_;  // A stream to capture.\n  int uncaptured_fd_;\n  // Name of the temporary file holding the stderr output.\n  ::std::string filename_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(CapturedStream);\n};\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()\n\nstatic CapturedStream* g_captured_stderr = NULL;\nstatic CapturedStream* g_captured_stdout = NULL;\n\n// Starts capturing an output stream (stdout/stderr).\nvoid CaptureStream(int fd, const char* stream_name, CapturedStream** stream) {\n  if (*stream != NULL) {\n    GTEST_LOG_(FATAL) << \"Only one \" << stream_name\n                      << \" capturer can exist at a time.\";\n  }\n  *stream = new CapturedStream(fd);\n}\n\n// Stops capturing the output stream and returns the captured string.\nstd::string GetCapturedStream(CapturedStream** captured_stream) {\n  const std::string content = (*captured_stream)->GetCapturedString();\n\n  delete *captured_stream;\n  *captured_stream = NULL;\n\n  return content;\n}\n\n// Starts capturing stdout.\nvoid CaptureStdout() {\n  CaptureStream(kStdOutFileno, \"stdout\", &g_captured_stdout);\n}\n\n// Starts capturing stderr.\nvoid CaptureStderr() {\n  CaptureStream(kStdErrFileno, \"stderr\", &g_captured_stderr);\n}\n\n// Stops capturing stdout and returns the captured string.\nstd::string GetCapturedStdout() {\n  return GetCapturedStream(&g_captured_stdout);\n}\n\n// Stops capturing stderr and returns the captured string.\nstd::string GetCapturedStderr() {\n  return GetCapturedStream(&g_captured_stderr);\n}\n\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\nstd::string TempDir() {\n#if GTEST_OS_WINDOWS_MOBILE\n  return \"\\\\temp\\\\\";\n#elif GTEST_OS_WINDOWS\n  const char* temp_dir = posix::GetEnv(\"TEMP\");\n  if (temp_dir == NULL || temp_dir[0] == '\\0')\n    return \"\\\\temp\\\\\";\n  else if (temp_dir[strlen(temp_dir) - 1] == '\\\\')\n    return temp_dir;\n  else\n    return std::string(temp_dir) + \"\\\\\";\n#elif GTEST_OS_LINUX_ANDROID\n  return \"/sdcard/\";\n#else\n  return \"/tmp/\";\n#endif  // GTEST_OS_WINDOWS_MOBILE\n}\n\nsize_t GetFileSize(FILE* file) {\n  fseek(file, 0, SEEK_END);\n  return static_cast<size_t>(ftell(file));\n}\n\nstd::string ReadEntireFile(FILE* file) {\n  const size_t file_size = GetFileSize(file);\n  char* const buffer = new char[file_size];\n\n  size_t bytes_last_read = 0;  // # of bytes read in the last fread()\n  size_t bytes_read = 0;       // # of bytes read so far\n\n  fseek(file, 0, SEEK_SET);\n\n  // Keeps reading the file until we cannot read further or the\n  // pre-determined file size is reached.\n  do {\n    bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file);\n    bytes_read += bytes_last_read;\n  } while (bytes_last_read > 0 && bytes_read < file_size);\n\n  const std::string content(buffer, bytes_read);\n  delete[] buffer;\n\n  return content;\n}\n\n#if GTEST_HAS_DEATH_TEST\n\nstatic const ::std::vector<testing::internal::string>* g_injected_test_argvs =\n                                        NULL;  // Owned.\n\nvoid SetInjectableArgvs(const ::std::vector<testing::internal::string>* argvs) {\n  if (g_injected_test_argvs != argvs)\n    delete g_injected_test_argvs;\n  g_injected_test_argvs = argvs;\n}\n\nconst ::std::vector<testing::internal::string>& GetInjectableArgvs() {\n  if (g_injected_test_argvs != NULL) {\n    return *g_injected_test_argvs;\n  }\n  return GetArgvs();\n}\n#endif  // GTEST_HAS_DEATH_TEST\n\n#if GTEST_OS_WINDOWS_MOBILE\nnamespace posix {\nvoid Abort() {\n  DebugBreak();\n  TerminateProcess(GetCurrentProcess(), 1);\n}\n}  // namespace posix\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n// Returns the name of the environment variable corresponding to the\n// given flag.  For example, FlagToEnvVar(\"foo\") will return\n// \"GTEST_FOO\" in the open-source version.\nstatic std::string FlagToEnvVar(const char* flag) {\n  const std::string full_flag =\n      (Message() << GTEST_FLAG_PREFIX_ << flag).GetString();\n\n  Message env_var;\n  for (size_t i = 0; i != full_flag.length(); i++) {\n    env_var << ToUpper(full_flag.c_str()[i]);\n  }\n\n  return env_var.GetString();\n}\n\n// Parses 'str' for a 32-bit signed integer.  If successful, writes\n// the result to *value and returns true; otherwise leaves *value\n// unchanged and returns false.\nbool ParseInt32(const Message& src_text, const char* str, Int32* value) {\n  // Parses the environment variable as a decimal integer.\n  char* end = NULL;\n  const long long_value = strtol(str, &end, 10);  // NOLINT\n\n  // Has strtol() consumed all characters in the string?\n  if (*end != '\\0') {\n    // No - an invalid character was encountered.\n    Message msg;\n    msg << \"WARNING: \" << src_text\n        << \" is expected to be a 32-bit integer, but actually\"\n        << \" has value \\\"\" << str << \"\\\".\\n\";\n    printf(\"%s\", msg.GetString().c_str());\n    fflush(stdout);\n    return false;\n  }\n\n  // Is the parsed value in the range of an Int32?\n  const Int32 result = static_cast<Int32>(long_value);\n  if (long_value == LONG_MAX || long_value == LONG_MIN ||\n      // The parsed value overflows as a long.  (strtol() returns\n      // LONG_MAX or LONG_MIN when the input overflows.)\n      result != long_value\n      // The parsed value overflows as an Int32.\n      ) {\n    Message msg;\n    msg << \"WARNING: \" << src_text\n        << \" is expected to be a 32-bit integer, but actually\"\n        << \" has value \" << str << \", which overflows.\\n\";\n    printf(\"%s\", msg.GetString().c_str());\n    fflush(stdout);\n    return false;\n  }\n\n  *value = result;\n  return true;\n}\n\n// Reads and returns the Boolean environment variable corresponding to\n// the given flag; if it's not set, returns default_value.\n//\n// The value is considered true iff it's not \"0\".\nbool BoolFromGTestEnv(const char* flag, bool default_value) {\n#if defined(GTEST_GET_BOOL_FROM_ENV_)\n  return GTEST_GET_BOOL_FROM_ENV_(flag, default_value);\n#endif  // defined(GTEST_GET_BOOL_FROM_ENV_)\n  const std::string env_var = FlagToEnvVar(flag);\n  const char* const string_value = posix::GetEnv(env_var.c_str());\n  return string_value == NULL ?\n      default_value : strcmp(string_value, \"0\") != 0;\n}\n\n// Reads and returns a 32-bit integer stored in the environment\n// variable corresponding to the given flag; if it isn't set or\n// doesn't represent a valid 32-bit integer, returns default_value.\nInt32 Int32FromGTestEnv(const char* flag, Int32 default_value) {\n#if defined(GTEST_GET_INT32_FROM_ENV_)\n  return GTEST_GET_INT32_FROM_ENV_(flag, default_value);\n#endif  // defined(GTEST_GET_INT32_FROM_ENV_)\n  const std::string env_var = FlagToEnvVar(flag);\n  const char* const string_value = posix::GetEnv(env_var.c_str());\n  if (string_value == NULL) {\n    // The environment variable is not set.\n    return default_value;\n  }\n\n  Int32 result = default_value;\n  if (!ParseInt32(Message() << \"Environment variable \" << env_var,\n                  string_value, &result)) {\n    printf(\"The default value %s is used.\\n\",\n           (Message() << default_value).GetString().c_str());\n    fflush(stdout);\n    return default_value;\n  }\n\n  return result;\n}\n\n// Reads and returns the string environment variable corresponding to\n// the given flag; if it's not set, returns default_value.\nstd::string StringFromGTestEnv(const char* flag, const char* default_value) {\n#if defined(GTEST_GET_STRING_FROM_ENV_)\n  return GTEST_GET_STRING_FROM_ENV_(flag, default_value);\n#endif  // defined(GTEST_GET_STRING_FROM_ENV_)\n  const std::string env_var = FlagToEnvVar(flag);\n  const char* value = posix::GetEnv(env_var.c_str());\n  if (value != NULL) {\n    return value;\n  }\n\n  // As a special case for the 'output' flag, if GTEST_OUTPUT is not\n  // set, we look for XML_OUTPUT_FILE, which is set by the Bazel build\n  // system.  The value of XML_OUTPUT_FILE is a filename without the\n  // \"xml:\" prefix of GTEST_OUTPUT.\n  //\n  // The net priority order after flag processing is thus:\n  //   --gtest_output command line flag\n  //   GTEST_OUTPUT environment variable\n  //   XML_OUTPUT_FILE environment variable\n  //   'default_value'\n  if (strcmp(flag, \"output\") == 0) {\n    value = posix::GetEnv(\"XML_OUTPUT_FILE\");\n    if (value != NULL) {\n      return std::string(\"xml:\") + value;\n    }\n  }\n  return default_value;\n}\n\n}  // namespace internal\n}  // namespace testing\n"
  },
  {
    "path": "utils/googletest/googletest/src/gtest-printers.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Test - The Google C++ Testing Framework\n//\n// This file implements a universal value printer that can print a\n// value of any type T:\n//\n//   void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);\n//\n// It uses the << operator when possible, and prints the bytes in the\n// object otherwise.  A user can override its behavior for a class\n// type Foo by defining either operator<<(::std::ostream&, const Foo&)\n// or void PrintTo(const Foo&, ::std::ostream*) in the namespace that\n// defines Foo.\n\n#include \"gtest/gtest-printers.h\"\n#include <ctype.h>\n#include <stdio.h>\n#include <cwchar>\n#include <ostream>  // NOLINT\n#include <string>\n#include \"gtest/internal/gtest-port.h\"\n\nnamespace testing {\n\nnamespace {\n\nusing ::std::ostream;\n\n// Prints a segment of bytes in the given object.\nGTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_\nGTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_\nGTEST_ATTRIBUTE_NO_SANITIZE_THREAD_\nvoid PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start,\n                                size_t count, ostream* os) {\n  char text[5] = \"\";\n  for (size_t i = 0; i != count; i++) {\n    const size_t j = start + i;\n    if (i != 0) {\n      // Organizes the bytes into groups of 2 for easy parsing by\n      // human.\n      if ((j % 2) == 0)\n        *os << ' ';\n      else\n        *os << '-';\n    }\n    GTEST_SNPRINTF_(text, sizeof(text), \"%02X\", obj_bytes[j]);\n    *os << text;\n  }\n}\n\n// Prints the bytes in the given value to the given ostream.\nvoid PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count,\n                              ostream* os) {\n  // Tells the user how big the object is.\n  *os << count << \"-byte object <\";\n\n  const size_t kThreshold = 132;\n  const size_t kChunkSize = 64;\n  // If the object size is bigger than kThreshold, we'll have to omit\n  // some details by printing only the first and the last kChunkSize\n  // bytes.\n  // TODO(wan): let the user control the threshold using a flag.\n  if (count < kThreshold) {\n    PrintByteSegmentInObjectTo(obj_bytes, 0, count, os);\n  } else {\n    PrintByteSegmentInObjectTo(obj_bytes, 0, kChunkSize, os);\n    *os << \" ... \";\n    // Rounds up to 2-byte boundary.\n    const size_t resume_pos = (count - kChunkSize + 1)/2*2;\n    PrintByteSegmentInObjectTo(obj_bytes, resume_pos, count - resume_pos, os);\n  }\n  *os << \">\";\n}\n\n}  // namespace\n\nnamespace internal2 {\n\n// Delegates to PrintBytesInObjectToImpl() to print the bytes in the\n// given object.  The delegation simplifies the implementation, which\n// uses the << operator and thus is easier done outside of the\n// ::testing::internal namespace, which contains a << operator that\n// sometimes conflicts with the one in STL.\nvoid PrintBytesInObjectTo(const unsigned char* obj_bytes, size_t count,\n                          ostream* os) {\n  PrintBytesInObjectToImpl(obj_bytes, count, os);\n}\n\n}  // namespace internal2\n\nnamespace internal {\n\n// Depending on the value of a char (or wchar_t), we print it in one\n// of three formats:\n//   - as is if it's a printable ASCII (e.g. 'a', '2', ' '),\n//   - as a hexidecimal escape sequence (e.g. '\\x7F'), or\n//   - as a special escape sequence (e.g. '\\r', '\\n').\nenum CharFormat {\n  kAsIs,\n  kHexEscape,\n  kSpecialEscape\n};\n\n// Returns true if c is a printable ASCII character.  We test the\n// value of c directly instead of calling isprint(), which is buggy on\n// Windows Mobile.\ninline bool IsPrintableAscii(wchar_t c) {\n  return 0x20 <= c && c <= 0x7E;\n}\n\n// Prints a wide or narrow char c as a character literal without the\n// quotes, escaping it when necessary; returns how c was formatted.\n// The template argument UnsignedChar is the unsigned version of Char,\n// which is the type of c.\ntemplate <typename UnsignedChar, typename Char>\nstatic CharFormat PrintAsCharLiteralTo(Char c, ostream* os) {\n  switch (static_cast<wchar_t>(c)) {\n    case L'\\0':\n      *os << \"\\\\0\";\n      break;\n    case L'\\'':\n      *os << \"\\\\'\";\n      break;\n    case L'\\\\':\n      *os << \"\\\\\\\\\";\n      break;\n    case L'\\a':\n      *os << \"\\\\a\";\n      break;\n    case L'\\b':\n      *os << \"\\\\b\";\n      break;\n    case L'\\f':\n      *os << \"\\\\f\";\n      break;\n    case L'\\n':\n      *os << \"\\\\n\";\n      break;\n    case L'\\r':\n      *os << \"\\\\r\";\n      break;\n    case L'\\t':\n      *os << \"\\\\t\";\n      break;\n    case L'\\v':\n      *os << \"\\\\v\";\n      break;\n    default:\n      if (IsPrintableAscii(c)) {\n        *os << static_cast<char>(c);\n        return kAsIs;\n      } else {\n        *os << \"\\\\x\" + String::FormatHexInt(static_cast<UnsignedChar>(c));\n        return kHexEscape;\n      }\n  }\n  return kSpecialEscape;\n}\n\n// Prints a wchar_t c as if it's part of a string literal, escaping it when\n// necessary; returns how c was formatted.\nstatic CharFormat PrintAsStringLiteralTo(wchar_t c, ostream* os) {\n  switch (c) {\n    case L'\\'':\n      *os << \"'\";\n      return kAsIs;\n    case L'\"':\n      *os << \"\\\\\\\"\";\n      return kSpecialEscape;\n    default:\n      return PrintAsCharLiteralTo<wchar_t>(c, os);\n  }\n}\n\n// Prints a char c as if it's part of a string literal, escaping it when\n// necessary; returns how c was formatted.\nstatic CharFormat PrintAsStringLiteralTo(char c, ostream* os) {\n  return PrintAsStringLiteralTo(\n      static_cast<wchar_t>(static_cast<unsigned char>(c)), os);\n}\n\n// Prints a wide or narrow character c and its code.  '\\0' is printed\n// as \"'\\\\0'\", other unprintable characters are also properly escaped\n// using the standard C++ escape sequence.  The template argument\n// UnsignedChar is the unsigned version of Char, which is the type of c.\ntemplate <typename UnsignedChar, typename Char>\nvoid PrintCharAndCodeTo(Char c, ostream* os) {\n  // First, print c as a literal in the most readable form we can find.\n  *os << ((sizeof(c) > 1) ? \"L'\" : \"'\");\n  const CharFormat format = PrintAsCharLiteralTo<UnsignedChar>(c, os);\n  *os << \"'\";\n\n  // To aid user debugging, we also print c's code in decimal, unless\n  // it's 0 (in which case c was printed as '\\\\0', making the code\n  // obvious).\n  if (c == 0)\n    return;\n  *os << \" (\" << static_cast<int>(c);\n\n  // For more convenience, we print c's code again in hexidecimal,\n  // unless c was already printed in the form '\\x##' or the code is in\n  // [1, 9].\n  if (format == kHexEscape || (1 <= c && c <= 9)) {\n    // Do nothing.\n  } else {\n    *os << \", 0x\" << String::FormatHexInt(static_cast<UnsignedChar>(c));\n  }\n  *os << \")\";\n}\n\nvoid PrintTo(unsigned char c, ::std::ostream* os) {\n  PrintCharAndCodeTo<unsigned char>(c, os);\n}\nvoid PrintTo(signed char c, ::std::ostream* os) {\n  PrintCharAndCodeTo<unsigned char>(c, os);\n}\n\n// Prints a wchar_t as a symbol if it is printable or as its internal\n// code otherwise and also as its code.  L'\\0' is printed as \"L'\\\\0'\".\nvoid PrintTo(wchar_t wc, ostream* os) {\n  PrintCharAndCodeTo<wchar_t>(wc, os);\n}\n\n// Prints the given array of characters to the ostream.  CharType must be either\n// char or wchar_t.\n// The array starts at begin, the length is len, it may include '\\0' characters\n// and may not be NUL-terminated.\ntemplate <typename CharType>\nGTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_\nGTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_\nGTEST_ATTRIBUTE_NO_SANITIZE_THREAD_\nstatic void PrintCharsAsStringTo(\n    const CharType* begin, size_t len, ostream* os) {\n  const char* const kQuoteBegin = sizeof(CharType) == 1 ? \"\\\"\" : \"L\\\"\";\n  *os << kQuoteBegin;\n  bool is_previous_hex = false;\n  for (size_t index = 0; index < len; ++index) {\n    const CharType cur = begin[index];\n    if (is_previous_hex && IsXDigit(cur)) {\n      // Previous character is of '\\x..' form and this character can be\n      // interpreted as another hexadecimal digit in its number. Break string to\n      // disambiguate.\n      *os << \"\\\" \" << kQuoteBegin;\n    }\n    is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape;\n  }\n  *os << \"\\\"\";\n}\n\n// Prints a (const) char/wchar_t array of 'len' elements, starting at address\n// 'begin'.  CharType must be either char or wchar_t.\ntemplate <typename CharType>\nGTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_\nGTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_\nGTEST_ATTRIBUTE_NO_SANITIZE_THREAD_\nstatic void UniversalPrintCharArray(\n    const CharType* begin, size_t len, ostream* os) {\n  // The code\n  //   const char kFoo[] = \"foo\";\n  // generates an array of 4, not 3, elements, with the last one being '\\0'.\n  //\n  // Therefore when printing a char array, we don't print the last element if\n  // it's '\\0', such that the output matches the string literal as it's\n  // written in the source code.\n  if (len > 0 && begin[len - 1] == '\\0') {\n    PrintCharsAsStringTo(begin, len - 1, os);\n    return;\n  }\n\n  // If, however, the last element in the array is not '\\0', e.g.\n  //    const char kFoo[] = { 'f', 'o', 'o' };\n  // we must print the entire array.  We also print a message to indicate\n  // that the array is not NUL-terminated.\n  PrintCharsAsStringTo(begin, len, os);\n  *os << \" (no terminating NUL)\";\n}\n\n// Prints a (const) char array of 'len' elements, starting at address 'begin'.\nvoid UniversalPrintArray(const char* begin, size_t len, ostream* os) {\n  UniversalPrintCharArray(begin, len, os);\n}\n\n// Prints a (const) wchar_t array of 'len' elements, starting at address\n// 'begin'.\nvoid UniversalPrintArray(const wchar_t* begin, size_t len, ostream* os) {\n  UniversalPrintCharArray(begin, len, os);\n}\n\n// Prints the given C string to the ostream.\nvoid PrintTo(const char* s, ostream* os) {\n  if (s == NULL) {\n    *os << \"NULL\";\n  } else {\n    *os << ImplicitCast_<const void*>(s) << \" pointing to \";\n    PrintCharsAsStringTo(s, strlen(s), os);\n  }\n}\n\n// MSVC compiler can be configured to define whar_t as a typedef\n// of unsigned short. Defining an overload for const wchar_t* in that case\n// would cause pointers to unsigned shorts be printed as wide strings,\n// possibly accessing more memory than intended and causing invalid\n// memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when\n// wchar_t is implemented as a native type.\n#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)\n// Prints the given wide C string to the ostream.\nvoid PrintTo(const wchar_t* s, ostream* os) {\n  if (s == NULL) {\n    *os << \"NULL\";\n  } else {\n    *os << ImplicitCast_<const void*>(s) << \" pointing to \";\n    PrintCharsAsStringTo(s, std::wcslen(s), os);\n  }\n}\n#endif  // wchar_t is native\n\n// Prints a ::string object.\n#if GTEST_HAS_GLOBAL_STRING\nvoid PrintStringTo(const ::string& s, ostream* os) {\n  PrintCharsAsStringTo(s.data(), s.size(), os);\n}\n#endif  // GTEST_HAS_GLOBAL_STRING\n\nvoid PrintStringTo(const ::std::string& s, ostream* os) {\n  PrintCharsAsStringTo(s.data(), s.size(), os);\n}\n\n// Prints a ::wstring object.\n#if GTEST_HAS_GLOBAL_WSTRING\nvoid PrintWideStringTo(const ::wstring& s, ostream* os) {\n  PrintCharsAsStringTo(s.data(), s.size(), os);\n}\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n#if GTEST_HAS_STD_WSTRING\nvoid PrintWideStringTo(const ::std::wstring& s, ostream* os) {\n  PrintCharsAsStringTo(s.data(), s.size(), os);\n}\n#endif  // GTEST_HAS_STD_WSTRING\n\n}  // namespace internal\n\n}  // namespace testing\n"
  },
  {
    "path": "utils/googletest/googletest/src/gtest-test-part.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: mheule@google.com (Markus Heule)\n//\n// The Google C++ Testing Framework (Google Test)\n\n#include \"gtest/gtest-test-part.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick exists to\n// prevent the accidental inclusion of gtest-internal-inl.h in the\n// user's code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nnamespace testing {\n\nusing internal::GetUnitTestImpl;\n\n// Gets the summary of the failure message by omitting the stack trace\n// in it.\nstd::string TestPartResult::ExtractSummary(const char* message) {\n  const char* const stack_trace = strstr(message, internal::kStackTraceMarker);\n  return stack_trace == NULL ? message :\n      std::string(message, stack_trace);\n}\n\n// Prints a TestPartResult object.\nstd::ostream& operator<<(std::ostream& os, const TestPartResult& result) {\n  return os\n      << result.file_name() << \":\" << result.line_number() << \": \"\n      << (result.type() == TestPartResult::kSuccess ? \"Success\" :\n          result.type() == TestPartResult::kFatalFailure ? \"Fatal failure\" :\n          \"Non-fatal failure\") << \":\\n\"\n      << result.message() << std::endl;\n}\n\n// Appends a TestPartResult to the array.\nvoid TestPartResultArray::Append(const TestPartResult& result) {\n  array_.push_back(result);\n}\n\n// Returns the TestPartResult at the given index (0-based).\nconst TestPartResult& TestPartResultArray::GetTestPartResult(int index) const {\n  if (index < 0 || index >= size()) {\n    printf(\"\\nInvalid index (%d) into TestPartResultArray.\\n\", index);\n    internal::posix::Abort();\n  }\n\n  return array_[index];\n}\n\n// Returns the number of TestPartResult objects in the array.\nint TestPartResultArray::size() const {\n  return static_cast<int>(array_.size());\n}\n\nnamespace internal {\n\nHasNewFatalFailureHelper::HasNewFatalFailureHelper()\n    : has_new_fatal_failure_(false),\n      original_reporter_(GetUnitTestImpl()->\n                         GetTestPartResultReporterForCurrentThread()) {\n  GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(this);\n}\n\nHasNewFatalFailureHelper::~HasNewFatalFailureHelper() {\n  GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(\n      original_reporter_);\n}\n\nvoid HasNewFatalFailureHelper::ReportTestPartResult(\n    const TestPartResult& result) {\n  if (result.fatally_failed())\n    has_new_fatal_failure_ = true;\n  original_reporter_->ReportTestPartResult(result);\n}\n\n}  // namespace internal\n\n}  // namespace testing\n"
  },
  {
    "path": "utils/googletest/googletest/src/gtest-typed-test.cc",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/gtest-typed-test.h\"\n#include \"gtest/gtest.h\"\n\nnamespace testing {\nnamespace internal {\n\n#if GTEST_HAS_TYPED_TEST_P\n\n// Skips to the first non-space char in str. Returns an empty string if str\n// contains only whitespace characters.\nstatic const char* SkipSpaces(const char* str) {\n  while (IsSpace(*str))\n    str++;\n  return str;\n}\n\nstatic std::vector<std::string> SplitIntoTestNames(const char* src) {\n  std::vector<std::string> name_vec;\n  src = SkipSpaces(src);\n  for (; src != NULL; src = SkipComma(src)) {\n    name_vec.push_back(StripTrailingSpaces(GetPrefixUntilComma(src)));\n  }\n  return name_vec;\n}\n\n// Verifies that registered_tests match the test names in\n// registered_tests_; returns registered_tests if successful, or\n// aborts the program otherwise.\nconst char* TypedTestCasePState::VerifyRegisteredTestNames(\n    const char* file, int line, const char* registered_tests) {\n  typedef RegisteredTestsMap::const_iterator RegisteredTestIter;\n  registered_ = true;\n\n  std::vector<std::string> name_vec = SplitIntoTestNames(registered_tests);\n\n  Message errors;\n\n  std::set<std::string> tests;\n  for (std::vector<std::string>::const_iterator name_it = name_vec.begin();\n       name_it != name_vec.end(); ++name_it) {\n    const std::string& name = *name_it;\n    if (tests.count(name) != 0) {\n      errors << \"Test \" << name << \" is listed more than once.\\n\";\n      continue;\n    }\n\n    bool found = false;\n    for (RegisteredTestIter it = registered_tests_.begin();\n         it != registered_tests_.end();\n         ++it) {\n      if (name == it->first) {\n        found = true;\n        break;\n      }\n    }\n\n    if (found) {\n      tests.insert(name);\n    } else {\n      errors << \"No test named \" << name\n             << \" can be found in this test case.\\n\";\n    }\n  }\n\n  for (RegisteredTestIter it = registered_tests_.begin();\n       it != registered_tests_.end();\n       ++it) {\n    if (tests.count(it->first) == 0) {\n      errors << \"You forgot to list test \" << it->first << \".\\n\";\n    }\n  }\n\n  const std::string& errors_str = errors.GetString();\n  if (errors_str != \"\") {\n    fprintf(stderr, \"%s %s\", FormatFileLocation(file, line).c_str(),\n            errors_str.c_str());\n    fflush(stderr);\n    posix::Abort();\n  }\n\n  return registered_tests;\n}\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n\n}  // namespace internal\n}  // namespace testing\n"
  },
  {
    "path": "utils/googletest/googletest/src/gtest.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// The Google C++ Testing Framework (Google Test)\n\n#include \"gtest/gtest.h\"\n#include \"gtest/internal/custom/gtest.h\"\n#include \"gtest/gtest-spi.h\"\n\n#include <ctype.h>\n#include <math.h>\n#include <stdarg.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <time.h>\n#include <wchar.h>\n#include <wctype.h>\n\n#include <algorithm>\n#include <iomanip>\n#include <limits>\n#include <list>\n#include <map>\n#include <ostream>  // NOLINT\n#include <sstream>\n#include <vector>\n\n#if GTEST_OS_LINUX\n\n// TODO(kenton@google.com): Use autoconf to detect availability of\n// gettimeofday().\n# define GTEST_HAS_GETTIMEOFDAY_ 1\n\n# include <fcntl.h>  // NOLINT\n# include <limits.h>  // NOLINT\n# include <sched.h>  // NOLINT\n// Declares vsnprintf().  This header is not available on Windows.\n# include <strings.h>  // NOLINT\n# include <sys/mman.h>  // NOLINT\n# include <sys/time.h>  // NOLINT\n# include <unistd.h>  // NOLINT\n# include <string>\n\n#elif GTEST_OS_SYMBIAN\n# define GTEST_HAS_GETTIMEOFDAY_ 1\n# include <sys/time.h>  // NOLINT\n\n#elif GTEST_OS_ZOS\n# define GTEST_HAS_GETTIMEOFDAY_ 1\n# include <sys/time.h>  // NOLINT\n\n// On z/OS we additionally need strings.h for strcasecmp.\n# include <strings.h>  // NOLINT\n\n#elif GTEST_OS_WINDOWS_MOBILE  // We are on Windows CE.\n\n# include <windows.h>  // NOLINT\n# undef min\n\n#elif GTEST_OS_WINDOWS  // We are on Windows proper.\n\n# include <io.h>  // NOLINT\n# include <sys/timeb.h>  // NOLINT\n# include <sys/types.h>  // NOLINT\n# include <sys/stat.h>  // NOLINT\n\n# if GTEST_OS_WINDOWS_MINGW\n// MinGW has gettimeofday() but not _ftime64().\n// TODO(kenton@google.com): Use autoconf to detect availability of\n//   gettimeofday().\n// TODO(kenton@google.com): There are other ways to get the time on\n//   Windows, like GetTickCount() or GetSystemTimeAsFileTime().  MinGW\n//   supports these.  consider using them instead.\n#  define GTEST_HAS_GETTIMEOFDAY_ 1\n#  include <sys/time.h>  // NOLINT\n# endif  // GTEST_OS_WINDOWS_MINGW\n\n// cpplint thinks that the header is already included, so we want to\n// silence it.\n# include <windows.h>  // NOLINT\n# undef min\n\n#else\n\n// Assume other platforms have gettimeofday().\n// TODO(kenton@google.com): Use autoconf to detect availability of\n//   gettimeofday().\n# define GTEST_HAS_GETTIMEOFDAY_ 1\n\n// cpplint thinks that the header is already included, so we want to\n// silence it.\n# include <sys/time.h>  // NOLINT\n# include <unistd.h>  // NOLINT\n\n#endif  // GTEST_OS_LINUX\n\n#if GTEST_HAS_EXCEPTIONS\n# include <stdexcept>\n#endif\n\n#if GTEST_CAN_STREAM_RESULTS_\n# include <arpa/inet.h>  // NOLINT\n# include <netdb.h>  // NOLINT\n# include <sys/socket.h>  // NOLINT\n# include <sys/types.h>  // NOLINT\n#endif\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\n#if GTEST_OS_WINDOWS\n# define vsnprintf _vsnprintf\n#endif  // GTEST_OS_WINDOWS\n\nnamespace testing {\n\nusing internal::CountIf;\nusing internal::ForEach;\nusing internal::GetElementOr;\nusing internal::Shuffle;\n\n// Constants.\n\n// A test whose test case name or test name matches this filter is\n// disabled and not run.\nstatic const char kDisableTestFilter[] = \"DISABLED_*:*/DISABLED_*\";\n\n// A test case whose name matches this filter is considered a death\n// test case and will be run before test cases whose name doesn't\n// match this filter.\nstatic const char kDeathTestCaseFilter[] = \"*DeathTest:*DeathTest/*\";\n\n// A test filter that matches everything.\nstatic const char kUniversalFilter[] = \"*\";\n\n// The default output file for XML output.\nstatic const char kDefaultOutputFile[] = \"test_detail.xml\";\n\n// The environment variable name for the test shard index.\nstatic const char kTestShardIndex[] = \"GTEST_SHARD_INDEX\";\n// The environment variable name for the total number of test shards.\nstatic const char kTestTotalShards[] = \"GTEST_TOTAL_SHARDS\";\n// The environment variable name for the test shard status file.\nstatic const char kTestShardStatusFile[] = \"GTEST_SHARD_STATUS_FILE\";\n\nnamespace internal {\n\n// The text used in failure messages to indicate the start of the\n// stack trace.\nconst char kStackTraceMarker[] = \"\\nStack trace:\\n\";\n\n// g_help_flag is true iff the --help flag or an equivalent form is\n// specified on the command line.\nbool g_help_flag = false;\n\n}  // namespace internal\n\nstatic const char* GetDefaultFilter() {\n#ifdef GTEST_TEST_FILTER_ENV_VAR_\n  const char* const testbridge_test_only = getenv(GTEST_TEST_FILTER_ENV_VAR_);\n  if (testbridge_test_only != NULL) {\n    return testbridge_test_only;\n  }\n#endif  // GTEST_TEST_FILTER_ENV_VAR_\n  return kUniversalFilter;\n}\n\nGTEST_DEFINE_bool_(\n    also_run_disabled_tests,\n    internal::BoolFromGTestEnv(\"also_run_disabled_tests\", false),\n    \"Run disabled tests too, in addition to the tests normally being run.\");\n\nGTEST_DEFINE_bool_(\n    break_on_failure,\n    internal::BoolFromGTestEnv(\"break_on_failure\", false),\n    \"True iff a failed assertion should be a debugger break-point.\");\n\nGTEST_DEFINE_bool_(\n    catch_exceptions,\n    internal::BoolFromGTestEnv(\"catch_exceptions\", true),\n    \"True iff \" GTEST_NAME_\n    \" should catch exceptions and treat them as test failures.\");\n\nGTEST_DEFINE_string_(\n    color,\n    internal::StringFromGTestEnv(\"color\", \"auto\"),\n    \"Whether to use colors in the output.  Valid values: yes, no, \"\n    \"and auto.  'auto' means to use colors if the output is \"\n    \"being sent to a terminal and the TERM environment variable \"\n    \"is set to a terminal type that supports colors.\");\n\nGTEST_DEFINE_string_(\n    filter,\n    internal::StringFromGTestEnv(\"filter\", GetDefaultFilter()),\n    \"A colon-separated list of glob (not regex) patterns \"\n    \"for filtering the tests to run, optionally followed by a \"\n    \"'-' and a : separated list of negative patterns (tests to \"\n    \"exclude).  A test is run if it matches one of the positive \"\n    \"patterns and does not match any of the negative patterns.\");\n\nGTEST_DEFINE_bool_(list_tests, false,\n                   \"List all tests without running them.\");\n\nGTEST_DEFINE_string_(\n    output,\n    internal::StringFromGTestEnv(\"output\", \"\"),\n    \"A format (currently must be \\\"xml\\\"), optionally followed \"\n    \"by a colon and an output file name or directory. A directory \"\n    \"is indicated by a trailing pathname separator. \"\n    \"Examples: \\\"xml:filename.xml\\\", \\\"xml::directoryname/\\\". \"\n    \"If a directory is specified, output files will be created \"\n    \"within that directory, with file-names based on the test \"\n    \"executable's name and, if necessary, made unique by adding \"\n    \"digits.\");\n\nGTEST_DEFINE_bool_(\n    print_time,\n    internal::BoolFromGTestEnv(\"print_time\", true),\n    \"True iff \" GTEST_NAME_\n    \" should display elapsed time in text output.\");\n\nGTEST_DEFINE_int32_(\n    random_seed,\n    internal::Int32FromGTestEnv(\"random_seed\", 0),\n    \"Random number seed to use when shuffling test orders.  Must be in range \"\n    \"[1, 99999], or 0 to use a seed based on the current time.\");\n\nGTEST_DEFINE_int32_(\n    repeat,\n    internal::Int32FromGTestEnv(\"repeat\", 1),\n    \"How many times to repeat each test.  Specify a negative number \"\n    \"for repeating forever.  Useful for shaking out flaky tests.\");\n\nGTEST_DEFINE_bool_(\n    show_internal_stack_frames, false,\n    \"True iff \" GTEST_NAME_ \" should include internal stack frames when \"\n    \"printing test failure stack traces.\");\n\nGTEST_DEFINE_bool_(\n    shuffle,\n    internal::BoolFromGTestEnv(\"shuffle\", false),\n    \"True iff \" GTEST_NAME_\n    \" should randomize tests' order on every run.\");\n\nGTEST_DEFINE_int32_(\n    stack_trace_depth,\n    internal::Int32FromGTestEnv(\"stack_trace_depth\", kMaxStackTraceDepth),\n    \"The maximum number of stack frames to print when an \"\n    \"assertion fails.  The valid range is 0 through 100, inclusive.\");\n\nGTEST_DEFINE_string_(\n    stream_result_to,\n    internal::StringFromGTestEnv(\"stream_result_to\", \"\"),\n    \"This flag specifies the host name and the port number on which to stream \"\n    \"test results. Example: \\\"localhost:555\\\". The flag is effective only on \"\n    \"Linux.\");\n\nGTEST_DEFINE_bool_(\n    throw_on_failure,\n    internal::BoolFromGTestEnv(\"throw_on_failure\", false),\n    \"When this flag is specified, a failed assertion will throw an exception \"\n    \"if exceptions are enabled or exit the program with a non-zero code \"\n    \"otherwise.\");\n\n#if GTEST_USE_OWN_FLAGFILE_FLAG_\nGTEST_DEFINE_string_(\n    flagfile,\n    internal::StringFromGTestEnv(\"flagfile\", \"\"),\n    \"This flag specifies the flagfile to read command-line flags from.\");\n#endif  // GTEST_USE_OWN_FLAGFILE_FLAG_\n\nnamespace internal {\n\n// Generates a random number from [0, range), using a Linear\n// Congruential Generator (LCG).  Crashes if 'range' is 0 or greater\n// than kMaxRange.\nUInt32 Random::Generate(UInt32 range) {\n  // These constants are the same as are used in glibc's rand(3).\n  state_ = (1103515245U*state_ + 12345U) % kMaxRange;\n\n  GTEST_CHECK_(range > 0)\n      << \"Cannot generate a number in the range [0, 0).\";\n  GTEST_CHECK_(range <= kMaxRange)\n      << \"Generation of a number in [0, \" << range << \") was requested, \"\n      << \"but this can only generate numbers in [0, \" << kMaxRange << \").\";\n\n  // Converting via modulus introduces a bit of downward bias, but\n  // it's simple, and a linear congruential generator isn't too good\n  // to begin with.\n  return state_ % range;\n}\n\n// GTestIsInitialized() returns true iff the user has initialized\n// Google Test.  Useful for catching the user mistake of not initializing\n// Google Test before calling RUN_ALL_TESTS().\nstatic bool GTestIsInitialized() { return GetArgvs().size() > 0; }\n\n// Iterates over a vector of TestCases, keeping a running sum of the\n// results of calling a given int-returning method on each.\n// Returns the sum.\nstatic int SumOverTestCaseList(const std::vector<TestCase*>& case_list,\n                               int (TestCase::*method)() const) {\n  int sum = 0;\n  for (size_t i = 0; i < case_list.size(); i++) {\n    sum += (case_list[i]->*method)();\n  }\n  return sum;\n}\n\n// Returns true iff the test case passed.\nstatic bool TestCasePassed(const TestCase* test_case) {\n  return test_case->should_run() && test_case->Passed();\n}\n\n// Returns true iff the test case failed.\nstatic bool TestCaseFailed(const TestCase* test_case) {\n  return test_case->should_run() && test_case->Failed();\n}\n\n// Returns true iff test_case contains at least one test that should\n// run.\nstatic bool ShouldRunTestCase(const TestCase* test_case) {\n  return test_case->should_run();\n}\n\n// AssertHelper constructor.\nAssertHelper::AssertHelper(TestPartResult::Type type,\n                           const char* file,\n                           int line,\n                           const char* message)\n    : data_(new AssertHelperData(type, file, line, message)) {\n}\n\nAssertHelper::~AssertHelper() {\n  delete data_;\n}\n\n// Message assignment, for assertion streaming support.\nvoid AssertHelper::operator=(const Message& message) const {\n  UnitTest::GetInstance()->\n    AddTestPartResult(data_->type, data_->file, data_->line,\n                      AppendUserMessage(data_->message, message),\n                      UnitTest::GetInstance()->impl()\n                      ->CurrentOsStackTraceExceptTop(1)\n                      // Skips the stack frame for this function itself.\n                      );  // NOLINT\n}\n\n// Mutex for linked pointers.\nGTEST_API_ GTEST_DEFINE_STATIC_MUTEX_(g_linked_ptr_mutex);\n\n// A copy of all command line arguments.  Set by InitGoogleTest().\n::std::vector<testing::internal::string> g_argvs;\n\nconst ::std::vector<testing::internal::string>& GetArgvs() {\n#if defined(GTEST_CUSTOM_GET_ARGVS_)\n  return GTEST_CUSTOM_GET_ARGVS_();\n#else  // defined(GTEST_CUSTOM_GET_ARGVS_)\n  return g_argvs;\n#endif  // defined(GTEST_CUSTOM_GET_ARGVS_)\n}\n\n// Returns the current application's name, removing directory path if that\n// is present.\nFilePath GetCurrentExecutableName() {\n  FilePath result;\n\n#if GTEST_OS_WINDOWS\n  result.Set(FilePath(GetArgvs()[0]).RemoveExtension(\"exe\"));\n#else\n  result.Set(FilePath(GetArgvs()[0]));\n#endif  // GTEST_OS_WINDOWS\n\n  return result.RemoveDirectoryName();\n}\n\n// Functions for processing the gtest_output flag.\n\n// Returns the output format, or \"\" for normal printed output.\nstd::string UnitTestOptions::GetOutputFormat() {\n  const char* const gtest_output_flag = GTEST_FLAG(output).c_str();\n  if (gtest_output_flag == NULL) return std::string(\"\");\n\n  const char* const colon = strchr(gtest_output_flag, ':');\n  return (colon == NULL) ?\n      std::string(gtest_output_flag) :\n      std::string(gtest_output_flag, colon - gtest_output_flag);\n}\n\n// Returns the name of the requested output file, or the default if none\n// was explicitly specified.\nstd::string UnitTestOptions::GetAbsolutePathToOutputFile() {\n  const char* const gtest_output_flag = GTEST_FLAG(output).c_str();\n  if (gtest_output_flag == NULL)\n    return \"\";\n\n  const char* const colon = strchr(gtest_output_flag, ':');\n  if (colon == NULL)\n    return internal::FilePath::ConcatPaths(\n        internal::FilePath(\n            UnitTest::GetInstance()->original_working_dir()),\n        internal::FilePath(kDefaultOutputFile)).string();\n\n  internal::FilePath output_name(colon + 1);\n  if (!output_name.IsAbsolutePath())\n    // TODO(wan@google.com): on Windows \\some\\path is not an absolute\n    // path (as its meaning depends on the current drive), yet the\n    // following logic for turning it into an absolute path is wrong.\n    // Fix it.\n    output_name = internal::FilePath::ConcatPaths(\n        internal::FilePath(UnitTest::GetInstance()->original_working_dir()),\n        internal::FilePath(colon + 1));\n\n  if (!output_name.IsDirectory())\n    return output_name.string();\n\n  internal::FilePath result(internal::FilePath::GenerateUniqueFileName(\n      output_name, internal::GetCurrentExecutableName(),\n      GetOutputFormat().c_str()));\n  return result.string();\n}\n\n// Returns true iff the wildcard pattern matches the string.  The\n// first ':' or '\\0' character in pattern marks the end of it.\n//\n// This recursive algorithm isn't very efficient, but is clear and\n// works well enough for matching test names, which are short.\nbool UnitTestOptions::PatternMatchesString(const char *pattern,\n                                           const char *str) {\n  switch (*pattern) {\n    case '\\0':\n    case ':':  // Either ':' or '\\0' marks the end of the pattern.\n      return *str == '\\0';\n    case '?':  // Matches any single character.\n      return *str != '\\0' && PatternMatchesString(pattern + 1, str + 1);\n    case '*':  // Matches any string (possibly empty) of characters.\n      return (*str != '\\0' && PatternMatchesString(pattern, str + 1)) ||\n          PatternMatchesString(pattern + 1, str);\n    default:  // Non-special character.  Matches itself.\n      return *pattern == *str &&\n          PatternMatchesString(pattern + 1, str + 1);\n  }\n}\n\nbool UnitTestOptions::MatchesFilter(\n    const std::string& name, const char* filter) {\n  const char *cur_pattern = filter;\n  for (;;) {\n    if (PatternMatchesString(cur_pattern, name.c_str())) {\n      return true;\n    }\n\n    // Finds the next pattern in the filter.\n    cur_pattern = strchr(cur_pattern, ':');\n\n    // Returns if no more pattern can be found.\n    if (cur_pattern == NULL) {\n      return false;\n    }\n\n    // Skips the pattern separater (the ':' character).\n    cur_pattern++;\n  }\n}\n\n// Returns true iff the user-specified filter matches the test case\n// name and the test name.\nbool UnitTestOptions::FilterMatchesTest(const std::string &test_case_name,\n                                        const std::string &test_name) {\n  const std::string& full_name = test_case_name + \".\" + test_name.c_str();\n\n  // Split --gtest_filter at '-', if there is one, to separate into\n  // positive filter and negative filter portions\n  const char* const p = GTEST_FLAG(filter).c_str();\n  const char* const dash = strchr(p, '-');\n  std::string positive;\n  std::string negative;\n  if (dash == NULL) {\n    positive = GTEST_FLAG(filter).c_str();  // Whole string is a positive filter\n    negative = \"\";\n  } else {\n    positive = std::string(p, dash);   // Everything up to the dash\n    negative = std::string(dash + 1);  // Everything after the dash\n    if (positive.empty()) {\n      // Treat '-test1' as the same as '*-test1'\n      positive = kUniversalFilter;\n    }\n  }\n\n  // A filter is a colon-separated list of patterns.  It matches a\n  // test if any pattern in it matches the test.\n  return (MatchesFilter(full_name, positive.c_str()) &&\n          !MatchesFilter(full_name, negative.c_str()));\n}\n\n#if GTEST_HAS_SEH\n// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the\n// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.\n// This function is useful as an __except condition.\nint UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) {\n  // Google Test should handle a SEH exception if:\n  //   1. the user wants it to, AND\n  //   2. this is not a breakpoint exception, AND\n  //   3. this is not a C++ exception (VC++ implements them via SEH,\n  //      apparently).\n  //\n  // SEH exception code for C++ exceptions.\n  // (see http://support.microsoft.com/kb/185294 for more information).\n  const DWORD kCxxExceptionCode = 0xe06d7363;\n\n  bool should_handle = true;\n\n  if (!GTEST_FLAG(catch_exceptions))\n    should_handle = false;\n  else if (exception_code == EXCEPTION_BREAKPOINT)\n    should_handle = false;\n  else if (exception_code == kCxxExceptionCode)\n    should_handle = false;\n\n  return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;\n}\n#endif  // GTEST_HAS_SEH\n\n}  // namespace internal\n\n// The c'tor sets this object as the test part result reporter used by\n// Google Test.  The 'result' parameter specifies where to report the\n// results. Intercepts only failures from the current thread.\nScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(\n    TestPartResultArray* result)\n    : intercept_mode_(INTERCEPT_ONLY_CURRENT_THREAD),\n      result_(result) {\n  Init();\n}\n\n// The c'tor sets this object as the test part result reporter used by\n// Google Test.  The 'result' parameter specifies where to report the\n// results.\nScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(\n    InterceptMode intercept_mode, TestPartResultArray* result)\n    : intercept_mode_(intercept_mode),\n      result_(result) {\n  Init();\n}\n\nvoid ScopedFakeTestPartResultReporter::Init() {\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  if (intercept_mode_ == INTERCEPT_ALL_THREADS) {\n    old_reporter_ = impl->GetGlobalTestPartResultReporter();\n    impl->SetGlobalTestPartResultReporter(this);\n  } else {\n    old_reporter_ = impl->GetTestPartResultReporterForCurrentThread();\n    impl->SetTestPartResultReporterForCurrentThread(this);\n  }\n}\n\n// The d'tor restores the test part result reporter used by Google Test\n// before.\nScopedFakeTestPartResultReporter::~ScopedFakeTestPartResultReporter() {\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  if (intercept_mode_ == INTERCEPT_ALL_THREADS) {\n    impl->SetGlobalTestPartResultReporter(old_reporter_);\n  } else {\n    impl->SetTestPartResultReporterForCurrentThread(old_reporter_);\n  }\n}\n\n// Increments the test part result count and remembers the result.\n// This method is from the TestPartResultReporterInterface interface.\nvoid ScopedFakeTestPartResultReporter::ReportTestPartResult(\n    const TestPartResult& result) {\n  result_->Append(result);\n}\n\nnamespace internal {\n\n// Returns the type ID of ::testing::Test.  We should always call this\n// instead of GetTypeId< ::testing::Test>() to get the type ID of\n// testing::Test.  This is to work around a suspected linker bug when\n// using Google Test as a framework on Mac OS X.  The bug causes\n// GetTypeId< ::testing::Test>() to return different values depending\n// on whether the call is from the Google Test framework itself or\n// from user test code.  GetTestTypeId() is guaranteed to always\n// return the same value, as it always calls GetTypeId<>() from the\n// gtest.cc, which is within the Google Test framework.\nTypeId GetTestTypeId() {\n  return GetTypeId<Test>();\n}\n\n// The value of GetTestTypeId() as seen from within the Google Test\n// library.  This is solely for testing GetTestTypeId().\nextern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId();\n\n// This predicate-formatter checks that 'results' contains a test part\n// failure of the given type and that the failure message contains the\n// given substring.\nAssertionResult HasOneFailure(const char* /* results_expr */,\n                              const char* /* type_expr */,\n                              const char* /* substr_expr */,\n                              const TestPartResultArray& results,\n                              TestPartResult::Type type,\n                              const string& substr) {\n  const std::string expected(type == TestPartResult::kFatalFailure ?\n                        \"1 fatal failure\" :\n                        \"1 non-fatal failure\");\n  Message msg;\n  if (results.size() != 1) {\n    msg << \"Expected: \" << expected << \"\\n\"\n        << \"  Actual: \" << results.size() << \" failures\";\n    for (int i = 0; i < results.size(); i++) {\n      msg << \"\\n\" << results.GetTestPartResult(i);\n    }\n    return AssertionFailure() << msg;\n  }\n\n  const TestPartResult& r = results.GetTestPartResult(0);\n  if (r.type() != type) {\n    return AssertionFailure() << \"Expected: \" << expected << \"\\n\"\n                              << \"  Actual:\\n\"\n                              << r;\n  }\n\n  if (strstr(r.message(), substr.c_str()) == NULL) {\n    return AssertionFailure() << \"Expected: \" << expected << \" containing \\\"\"\n                              << substr << \"\\\"\\n\"\n                              << \"  Actual:\\n\"\n                              << r;\n  }\n\n  return AssertionSuccess();\n}\n\n// The constructor of SingleFailureChecker remembers where to look up\n// test part results, what type of failure we expect, and what\n// substring the failure message should contain.\nSingleFailureChecker:: SingleFailureChecker(\n    const TestPartResultArray* results,\n    TestPartResult::Type type,\n    const string& substr)\n    : results_(results),\n      type_(type),\n      substr_(substr) {}\n\n// The destructor of SingleFailureChecker verifies that the given\n// TestPartResultArray contains exactly one failure that has the given\n// type and contains the given substring.  If that's not the case, a\n// non-fatal failure will be generated.\nSingleFailureChecker::~SingleFailureChecker() {\n  EXPECT_PRED_FORMAT3(HasOneFailure, *results_, type_, substr_);\n}\n\nDefaultGlobalTestPartResultReporter::DefaultGlobalTestPartResultReporter(\n    UnitTestImpl* unit_test) : unit_test_(unit_test) {}\n\nvoid DefaultGlobalTestPartResultReporter::ReportTestPartResult(\n    const TestPartResult& result) {\n  unit_test_->current_test_result()->AddTestPartResult(result);\n  unit_test_->listeners()->repeater()->OnTestPartResult(result);\n}\n\nDefaultPerThreadTestPartResultReporter::DefaultPerThreadTestPartResultReporter(\n    UnitTestImpl* unit_test) : unit_test_(unit_test) {}\n\nvoid DefaultPerThreadTestPartResultReporter::ReportTestPartResult(\n    const TestPartResult& result) {\n  unit_test_->GetGlobalTestPartResultReporter()->ReportTestPartResult(result);\n}\n\n// Returns the global test part result reporter.\nTestPartResultReporterInterface*\nUnitTestImpl::GetGlobalTestPartResultReporter() {\n  internal::MutexLock lock(&global_test_part_result_reporter_mutex_);\n  return global_test_part_result_repoter_;\n}\n\n// Sets the global test part result reporter.\nvoid UnitTestImpl::SetGlobalTestPartResultReporter(\n    TestPartResultReporterInterface* reporter) {\n  internal::MutexLock lock(&global_test_part_result_reporter_mutex_);\n  global_test_part_result_repoter_ = reporter;\n}\n\n// Returns the test part result reporter for the current thread.\nTestPartResultReporterInterface*\nUnitTestImpl::GetTestPartResultReporterForCurrentThread() {\n  return per_thread_test_part_result_reporter_.get();\n}\n\n// Sets the test part result reporter for the current thread.\nvoid UnitTestImpl::SetTestPartResultReporterForCurrentThread(\n    TestPartResultReporterInterface* reporter) {\n  per_thread_test_part_result_reporter_.set(reporter);\n}\n\n// Gets the number of successful test cases.\nint UnitTestImpl::successful_test_case_count() const {\n  return CountIf(test_cases_, TestCasePassed);\n}\n\n// Gets the number of failed test cases.\nint UnitTestImpl::failed_test_case_count() const {\n  return CountIf(test_cases_, TestCaseFailed);\n}\n\n// Gets the number of all test cases.\nint UnitTestImpl::total_test_case_count() const {\n  return static_cast<int>(test_cases_.size());\n}\n\n// Gets the number of all test cases that contain at least one test\n// that should run.\nint UnitTestImpl::test_case_to_run_count() const {\n  return CountIf(test_cases_, ShouldRunTestCase);\n}\n\n// Gets the number of successful tests.\nint UnitTestImpl::successful_test_count() const {\n  return SumOverTestCaseList(test_cases_, &TestCase::successful_test_count);\n}\n\n// Gets the number of failed tests.\nint UnitTestImpl::failed_test_count() const {\n  return SumOverTestCaseList(test_cases_, &TestCase::failed_test_count);\n}\n\n// Gets the number of disabled tests that will be reported in the XML report.\nint UnitTestImpl::reportable_disabled_test_count() const {\n  return SumOverTestCaseList(test_cases_,\n                             &TestCase::reportable_disabled_test_count);\n}\n\n// Gets the number of disabled tests.\nint UnitTestImpl::disabled_test_count() const {\n  return SumOverTestCaseList(test_cases_, &TestCase::disabled_test_count);\n}\n\n// Gets the number of tests to be printed in the XML report.\nint UnitTestImpl::reportable_test_count() const {\n  return SumOverTestCaseList(test_cases_, &TestCase::reportable_test_count);\n}\n\n// Gets the number of all tests.\nint UnitTestImpl::total_test_count() const {\n  return SumOverTestCaseList(test_cases_, &TestCase::total_test_count);\n}\n\n// Gets the number of tests that should run.\nint UnitTestImpl::test_to_run_count() const {\n  return SumOverTestCaseList(test_cases_, &TestCase::test_to_run_count);\n}\n\n// Returns the current OS stack trace as an std::string.\n//\n// The maximum number of stack frames to be included is specified by\n// the gtest_stack_trace_depth flag.  The skip_count parameter\n// specifies the number of top frames to be skipped, which doesn't\n// count against the number of frames to be included.\n//\n// For example, if Foo() calls Bar(), which in turn calls\n// CurrentOsStackTraceExceptTop(1), Foo() will be included in the\n// trace but Bar() and CurrentOsStackTraceExceptTop() won't.\nstd::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {\n  return os_stack_trace_getter()->CurrentStackTrace(\n      static_cast<int>(GTEST_FLAG(stack_trace_depth)),\n      skip_count + 1\n      // Skips the user-specified number of frames plus this function\n      // itself.\n      );  // NOLINT\n}\n\n// Returns the current time in milliseconds.\nTimeInMillis GetTimeInMillis() {\n#if GTEST_OS_WINDOWS_MOBILE || defined(__BORLANDC__)\n  // Difference between 1970-01-01 and 1601-01-01 in milliseconds.\n  // http://analogous.blogspot.com/2005/04/epoch.html\n  const TimeInMillis kJavaEpochToWinFileTimeDelta =\n    static_cast<TimeInMillis>(116444736UL) * 100000UL;\n  const DWORD kTenthMicrosInMilliSecond = 10000;\n\n  SYSTEMTIME now_systime;\n  FILETIME now_filetime;\n  ULARGE_INTEGER now_int64;\n  // TODO(kenton@google.com): Shouldn't this just use\n  //   GetSystemTimeAsFileTime()?\n  GetSystemTime(&now_systime);\n  if (SystemTimeToFileTime(&now_systime, &now_filetime)) {\n    now_int64.LowPart = now_filetime.dwLowDateTime;\n    now_int64.HighPart = now_filetime.dwHighDateTime;\n    now_int64.QuadPart = (now_int64.QuadPart / kTenthMicrosInMilliSecond) -\n      kJavaEpochToWinFileTimeDelta;\n    return now_int64.QuadPart;\n  }\n  return 0;\n#elif GTEST_OS_WINDOWS && !GTEST_HAS_GETTIMEOFDAY_\n  __timeb64 now;\n\n  // MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996\n  // (deprecated function) there.\n  // TODO(kenton@google.com): Use GetTickCount()?  Or use\n  //   SystemTimeToFileTime()\n  GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)\n  _ftime64(&now);\n  GTEST_DISABLE_MSC_WARNINGS_POP_()\n\n  return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm;\n#elif GTEST_HAS_GETTIMEOFDAY_\n  struct timeval now;\n  gettimeofday(&now, NULL);\n  return static_cast<TimeInMillis>(now.tv_sec) * 1000 + now.tv_usec / 1000;\n#else\n# error \"Don't know how to get the current time on your system.\"\n#endif\n}\n\n// Utilities\n\n// class String.\n\n#if GTEST_OS_WINDOWS_MOBILE\n// Creates a UTF-16 wide string from the given ANSI string, allocating\n// memory using new. The caller is responsible for deleting the return\n// value using delete[]. Returns the wide string, or NULL if the\n// input is NULL.\nLPCWSTR String::AnsiToUtf16(const char* ansi) {\n  if (!ansi) return NULL;\n  const int length = strlen(ansi);\n  const int unicode_length =\n      MultiByteToWideChar(CP_ACP, 0, ansi, length,\n                          NULL, 0);\n  WCHAR* unicode = new WCHAR[unicode_length + 1];\n  MultiByteToWideChar(CP_ACP, 0, ansi, length,\n                      unicode, unicode_length);\n  unicode[unicode_length] = 0;\n  return unicode;\n}\n\n// Creates an ANSI string from the given wide string, allocating\n// memory using new. The caller is responsible for deleting the return\n// value using delete[]. Returns the ANSI string, or NULL if the\n// input is NULL.\nconst char* String::Utf16ToAnsi(LPCWSTR utf16_str)  {\n  if (!utf16_str) return NULL;\n  const int ansi_length =\n      WideCharToMultiByte(CP_ACP, 0, utf16_str, -1,\n                          NULL, 0, NULL, NULL);\n  char* ansi = new char[ansi_length + 1];\n  WideCharToMultiByte(CP_ACP, 0, utf16_str, -1,\n                      ansi, ansi_length, NULL, NULL);\n  ansi[ansi_length] = 0;\n  return ansi;\n}\n\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n// Compares two C strings.  Returns true iff they have the same content.\n//\n// Unlike strcmp(), this function can handle NULL argument(s).  A NULL\n// C string is considered different to any non-NULL C string,\n// including the empty string.\nbool String::CStringEquals(const char * lhs, const char * rhs) {\n  if ( lhs == NULL ) return rhs == NULL;\n\n  if ( rhs == NULL ) return false;\n\n  return strcmp(lhs, rhs) == 0;\n}\n\n#if GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING\n\n// Converts an array of wide chars to a narrow string using the UTF-8\n// encoding, and streams the result to the given Message object.\nstatic void StreamWideCharsToMessage(const wchar_t* wstr, size_t length,\n                                     Message* msg) {\n  for (size_t i = 0; i != length; ) {  // NOLINT\n    if (wstr[i] != L'\\0') {\n      *msg << WideStringToUtf8(wstr + i, static_cast<int>(length - i));\n      while (i != length && wstr[i] != L'\\0')\n        i++;\n    } else {\n      *msg << '\\0';\n      i++;\n    }\n  }\n}\n\n#endif  // GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING\n\nvoid SplitString(const ::std::string& str, char delimiter,\n                 ::std::vector< ::std::string>* dest) {\n  ::std::vector< ::std::string> parsed;\n  ::std::string::size_type pos = 0;\n  while (::testing::internal::AlwaysTrue()) {\n    const ::std::string::size_type colon = str.find(delimiter, pos);\n    if (colon == ::std::string::npos) {\n      parsed.push_back(str.substr(pos));\n      break;\n    } else {\n      parsed.push_back(str.substr(pos, colon - pos));\n      pos = colon + 1;\n    }\n  }\n  dest->swap(parsed);\n}\n\n}  // namespace internal\n\n// Constructs an empty Message.\n// We allocate the stringstream separately because otherwise each use of\n// ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's\n// stack frame leading to huge stack frames in some cases; gcc does not reuse\n// the stack space.\nMessage::Message() : ss_(new ::std::stringstream) {\n  // By default, we want there to be enough precision when printing\n  // a double to a Message.\n  *ss_ << std::setprecision(std::numeric_limits<double>::digits10 + 2);\n}\n\n// These two overloads allow streaming a wide C string to a Message\n// using the UTF-8 encoding.\nMessage& Message::operator <<(const wchar_t* wide_c_str) {\n  return *this << internal::String::ShowWideCString(wide_c_str);\n}\nMessage& Message::operator <<(wchar_t* wide_c_str) {\n  return *this << internal::String::ShowWideCString(wide_c_str);\n}\n\n#if GTEST_HAS_STD_WSTRING\n// Converts the given wide string to a narrow string using the UTF-8\n// encoding, and streams the result to this Message object.\nMessage& Message::operator <<(const ::std::wstring& wstr) {\n  internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);\n  return *this;\n}\n#endif  // GTEST_HAS_STD_WSTRING\n\n#if GTEST_HAS_GLOBAL_WSTRING\n// Converts the given wide string to a narrow string using the UTF-8\n// encoding, and streams the result to this Message object.\nMessage& Message::operator <<(const ::wstring& wstr) {\n  internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);\n  return *this;\n}\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n// Gets the text streamed to this object so far as an std::string.\n// Each '\\0' character in the buffer is replaced with \"\\\\0\".\nstd::string Message::GetString() const {\n  return internal::StringStreamToString(ss_.get());\n}\n\n// AssertionResult constructors.\n// Used in EXPECT_TRUE/FALSE(assertion_result).\nAssertionResult::AssertionResult(const AssertionResult& other)\n    : success_(other.success_),\n      message_(other.message_.get() != NULL ?\n               new ::std::string(*other.message_) :\n               static_cast< ::std::string*>(NULL)) {\n}\n\n// Swaps two AssertionResults.\nvoid AssertionResult::swap(AssertionResult& other) {\n  using std::swap;\n  swap(success_, other.success_);\n  swap(message_, other.message_);\n}\n\n// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.\nAssertionResult AssertionResult::operator!() const {\n  AssertionResult negation(!success_);\n  if (message_.get() != NULL)\n    negation << *message_;\n  return negation;\n}\n\n// Makes a successful assertion result.\nAssertionResult AssertionSuccess() {\n  return AssertionResult(true);\n}\n\n// Makes a failed assertion result.\nAssertionResult AssertionFailure() {\n  return AssertionResult(false);\n}\n\n// Makes a failed assertion result with the given failure message.\n// Deprecated; use AssertionFailure() << message.\nAssertionResult AssertionFailure(const Message& message) {\n  return AssertionFailure() << message;\n}\n\nnamespace internal {\n\nnamespace edit_distance {\nstd::vector<EditType> CalculateOptimalEdits(const std::vector<size_t>& left,\n                                            const std::vector<size_t>& right) {\n  std::vector<std::vector<double> > costs(\n      left.size() + 1, std::vector<double>(right.size() + 1));\n  std::vector<std::vector<EditType> > best_move(\n      left.size() + 1, std::vector<EditType>(right.size() + 1));\n\n  // Populate for empty right.\n  for (size_t l_i = 0; l_i < costs.size(); ++l_i) {\n    costs[l_i][0] = static_cast<double>(l_i);\n    best_move[l_i][0] = kRemove;\n  }\n  // Populate for empty left.\n  for (size_t r_i = 1; r_i < costs[0].size(); ++r_i) {\n    costs[0][r_i] = static_cast<double>(r_i);\n    best_move[0][r_i] = kAdd;\n  }\n\n  for (size_t l_i = 0; l_i < left.size(); ++l_i) {\n    for (size_t r_i = 0; r_i < right.size(); ++r_i) {\n      if (left[l_i] == right[r_i]) {\n        // Found a match. Consume it.\n        costs[l_i + 1][r_i + 1] = costs[l_i][r_i];\n        best_move[l_i + 1][r_i + 1] = kMatch;\n        continue;\n      }\n\n      const double add = costs[l_i + 1][r_i];\n      const double remove = costs[l_i][r_i + 1];\n      const double replace = costs[l_i][r_i];\n      if (add < remove && add < replace) {\n        costs[l_i + 1][r_i + 1] = add + 1;\n        best_move[l_i + 1][r_i + 1] = kAdd;\n      } else if (remove < add && remove < replace) {\n        costs[l_i + 1][r_i + 1] = remove + 1;\n        best_move[l_i + 1][r_i + 1] = kRemove;\n      } else {\n        // We make replace a little more expensive than add/remove to lower\n        // their priority.\n        costs[l_i + 1][r_i + 1] = replace + 1.00001;\n        best_move[l_i + 1][r_i + 1] = kReplace;\n      }\n    }\n  }\n\n  // Reconstruct the best path. We do it in reverse order.\n  std::vector<EditType> best_path;\n  for (size_t l_i = left.size(), r_i = right.size(); l_i > 0 || r_i > 0;) {\n    EditType move = best_move[l_i][r_i];\n    best_path.push_back(move);\n    l_i -= move != kAdd;\n    r_i -= move != kRemove;\n  }\n  std::reverse(best_path.begin(), best_path.end());\n  return best_path;\n}\n\nnamespace {\n\n// Helper class to convert string into ids with deduplication.\nclass InternalStrings {\n public:\n  size_t GetId(const std::string& str) {\n    IdMap::iterator it = ids_.find(str);\n    if (it != ids_.end()) return it->second;\n    size_t id = ids_.size();\n    return ids_[str] = id;\n  }\n\n private:\n  typedef std::map<std::string, size_t> IdMap;\n  IdMap ids_;\n};\n\n}  // namespace\n\nstd::vector<EditType> CalculateOptimalEdits(\n    const std::vector<std::string>& left,\n    const std::vector<std::string>& right) {\n  std::vector<size_t> left_ids, right_ids;\n  {\n    InternalStrings intern_table;\n    for (size_t i = 0; i < left.size(); ++i) {\n      left_ids.push_back(intern_table.GetId(left[i]));\n    }\n    for (size_t i = 0; i < right.size(); ++i) {\n      right_ids.push_back(intern_table.GetId(right[i]));\n    }\n  }\n  return CalculateOptimalEdits(left_ids, right_ids);\n}\n\nnamespace {\n\n// Helper class that holds the state for one hunk and prints it out to the\n// stream.\n// It reorders adds/removes when possible to group all removes before all\n// adds. It also adds the hunk header before printint into the stream.\nclass Hunk {\n public:\n  Hunk(size_t left_start, size_t right_start)\n      : left_start_(left_start),\n        right_start_(right_start),\n        adds_(),\n        removes_(),\n        common_() {}\n\n  void PushLine(char edit, const char* line) {\n    switch (edit) {\n      case ' ':\n        ++common_;\n        FlushEdits();\n        hunk_.push_back(std::make_pair(' ', line));\n        break;\n      case '-':\n        ++removes_;\n        hunk_removes_.push_back(std::make_pair('-', line));\n        break;\n      case '+':\n        ++adds_;\n        hunk_adds_.push_back(std::make_pair('+', line));\n        break;\n    }\n  }\n\n  void PrintTo(std::ostream* os) {\n    PrintHeader(os);\n    FlushEdits();\n    for (std::list<std::pair<char, const char*> >::const_iterator it =\n             hunk_.begin();\n         it != hunk_.end(); ++it) {\n      *os << it->first << it->second << \"\\n\";\n    }\n  }\n\n  bool has_edits() const { return adds_ || removes_; }\n\n private:\n  void FlushEdits() {\n    hunk_.splice(hunk_.end(), hunk_removes_);\n    hunk_.splice(hunk_.end(), hunk_adds_);\n  }\n\n  // Print a unified diff header for one hunk.\n  // The format is\n  //   \"@@ -<left_start>,<left_length> +<right_start>,<right_length> @@\"\n  // where the left/right parts are ommitted if unnecessary.\n  void PrintHeader(std::ostream* ss) const {\n    *ss << \"@@ \";\n    if (removes_) {\n      *ss << \"-\" << left_start_ << \",\" << (removes_ + common_);\n    }\n    if (removes_ && adds_) {\n      *ss << \" \";\n    }\n    if (adds_) {\n      *ss << \"+\" << right_start_ << \",\" << (adds_ + common_);\n    }\n    *ss << \" @@\\n\";\n  }\n\n  size_t left_start_, right_start_;\n  size_t adds_, removes_, common_;\n  std::list<std::pair<char, const char*> > hunk_, hunk_adds_, hunk_removes_;\n};\n\n}  // namespace\n\n// Create a list of diff hunks in Unified diff format.\n// Each hunk has a header generated by PrintHeader above plus a body with\n// lines prefixed with ' ' for no change, '-' for deletion and '+' for\n// addition.\n// 'context' represents the desired unchanged prefix/suffix around the diff.\n// If two hunks are close enough that their contexts overlap, then they are\n// joined into one hunk.\nstd::string CreateUnifiedDiff(const std::vector<std::string>& left,\n                              const std::vector<std::string>& right,\n                              size_t context) {\n  const std::vector<EditType> edits = CalculateOptimalEdits(left, right);\n\n  size_t l_i = 0, r_i = 0, edit_i = 0;\n  std::stringstream ss;\n  while (edit_i < edits.size()) {\n    // Find first edit.\n    while (edit_i < edits.size() && edits[edit_i] == kMatch) {\n      ++l_i;\n      ++r_i;\n      ++edit_i;\n    }\n\n    // Find the first line to include in the hunk.\n    const size_t prefix_context = std::min(l_i, context);\n    Hunk hunk(l_i - prefix_context + 1, r_i - prefix_context + 1);\n    for (size_t i = prefix_context; i > 0; --i) {\n      hunk.PushLine(' ', left[l_i - i].c_str());\n    }\n\n    // Iterate the edits until we found enough suffix for the hunk or the input\n    // is over.\n    size_t n_suffix = 0;\n    for (; edit_i < edits.size(); ++edit_i) {\n      if (n_suffix >= context) {\n        // Continue only if the next hunk is very close.\n        std::vector<EditType>::const_iterator it = edits.begin() + edit_i;\n        while (it != edits.end() && *it == kMatch) ++it;\n        if (it == edits.end() || (it - edits.begin()) - edit_i >= context) {\n          // There is no next edit or it is too far away.\n          break;\n        }\n      }\n\n      EditType edit = edits[edit_i];\n      // Reset count when a non match is found.\n      n_suffix = edit == kMatch ? n_suffix + 1 : 0;\n\n      if (edit == kMatch || edit == kRemove || edit == kReplace) {\n        hunk.PushLine(edit == kMatch ? ' ' : '-', left[l_i].c_str());\n      }\n      if (edit == kAdd || edit == kReplace) {\n        hunk.PushLine('+', right[r_i].c_str());\n      }\n\n      // Advance indices, depending on edit type.\n      l_i += edit != kAdd;\n      r_i += edit != kRemove;\n    }\n\n    if (!hunk.has_edits()) {\n      // We are done. We don't want this hunk.\n      break;\n    }\n\n    hunk.PrintTo(&ss);\n  }\n  return ss.str();\n}\n\n}  // namespace edit_distance\n\nnamespace {\n\n// The string representation of the values received in EqFailure() are already\n// escaped. Split them on escaped '\\n' boundaries. Leave all other escaped\n// characters the same.\nstd::vector<std::string> SplitEscapedString(const std::string& str) {\n  std::vector<std::string> lines;\n  size_t start = 0, end = str.size();\n  if (end > 2 && str[0] == '\"' && str[end - 1] == '\"') {\n    ++start;\n    --end;\n  }\n  bool escaped = false;\n  for (size_t i = start; i + 1 < end; ++i) {\n    if (escaped) {\n      escaped = false;\n      if (str[i] == 'n') {\n        lines.push_back(str.substr(start, i - start - 1));\n        start = i + 1;\n      }\n    } else {\n      escaped = str[i] == '\\\\';\n    }\n  }\n  lines.push_back(str.substr(start, end - start));\n  return lines;\n}\n\n}  // namespace\n\n// Constructs and returns the message for an equality assertion\n// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.\n//\n// The first four parameters are the expressions used in the assertion\n// and their values, as strings.  For example, for ASSERT_EQ(foo, bar)\n// where foo is 5 and bar is 6, we have:\n//\n//   lhs_expression: \"foo\"\n//   rhs_expression: \"bar\"\n//   lhs_value:      \"5\"\n//   rhs_value:      \"6\"\n//\n// The ignoring_case parameter is true iff the assertion is a\n// *_STRCASEEQ*.  When it's true, the string \"Ignoring case\" will\n// be inserted into the message.\nAssertionResult EqFailure(const char* lhs_expression,\n                          const char* rhs_expression,\n                          const std::string& lhs_value,\n                          const std::string& rhs_value,\n                          bool ignoring_case) {\n  Message msg;\n  msg << \"      Expected: \" << lhs_expression;\n  if (lhs_value != lhs_expression) {\n    msg << \"\\n      Which is: \" << lhs_value;\n  }\n  msg << \"\\nTo be equal to: \" << rhs_expression;\n  if (rhs_value != rhs_expression) {\n    msg << \"\\n      Which is: \" << rhs_value;\n  }\n\n  if (ignoring_case) {\n    msg << \"\\nIgnoring case\";\n  }\n\n  if (!lhs_value.empty() && !rhs_value.empty()) {\n    const std::vector<std::string> lhs_lines =\n        SplitEscapedString(lhs_value);\n    const std::vector<std::string> rhs_lines =\n        SplitEscapedString(rhs_value);\n    if (lhs_lines.size() > 1 || rhs_lines.size() > 1) {\n      msg << \"\\nWith diff:\\n\"\n          << edit_distance::CreateUnifiedDiff(lhs_lines, rhs_lines);\n    }\n  }\n\n  return AssertionFailure() << msg;\n}\n\n// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.\nstd::string GetBoolAssertionFailureMessage(\n    const AssertionResult& assertion_result,\n    const char* expression_text,\n    const char* actual_predicate_value,\n    const char* expected_predicate_value) {\n  const char* actual_message = assertion_result.message();\n  Message msg;\n  msg << \"Value of: \" << expression_text\n      << \"\\n  Actual: \" << actual_predicate_value;\n  if (actual_message[0] != '\\0')\n    msg << \" (\" << actual_message << \")\";\n  msg << \"\\nExpected: \" << expected_predicate_value;\n  return msg.GetString();\n}\n\n// Helper function for implementing ASSERT_NEAR.\nAssertionResult DoubleNearPredFormat(const char* expr1,\n                                     const char* expr2,\n                                     const char* abs_error_expr,\n                                     double val1,\n                                     double val2,\n                                     double abs_error) {\n  const double diff = fabs(val1 - val2);\n  if (diff <= abs_error) return AssertionSuccess();\n\n  // TODO(wan): do not print the value of an expression if it's\n  // already a literal.\n  return AssertionFailure()\n      << \"The difference between \" << expr1 << \" and \" << expr2\n      << \" is \" << diff << \", which exceeds \" << abs_error_expr << \", where\\n\"\n      << expr1 << \" evaluates to \" << val1 << \",\\n\"\n      << expr2 << \" evaluates to \" << val2 << \", and\\n\"\n      << abs_error_expr << \" evaluates to \" << abs_error << \".\";\n}\n\n\n// Helper template for implementing FloatLE() and DoubleLE().\ntemplate <typename RawType>\nAssertionResult FloatingPointLE(const char* expr1,\n                                const char* expr2,\n                                RawType val1,\n                                RawType val2) {\n  // Returns success if val1 is less than val2,\n  if (val1 < val2) {\n    return AssertionSuccess();\n  }\n\n  // or if val1 is almost equal to val2.\n  const FloatingPoint<RawType> lhs(val1), rhs(val2);\n  if (lhs.AlmostEquals(rhs)) {\n    return AssertionSuccess();\n  }\n\n  // Note that the above two checks will both fail if either val1 or\n  // val2 is NaN, as the IEEE floating-point standard requires that\n  // any predicate involving a NaN must return false.\n\n  ::std::stringstream val1_ss;\n  val1_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)\n          << val1;\n\n  ::std::stringstream val2_ss;\n  val2_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)\n          << val2;\n\n  return AssertionFailure()\n      << \"Expected: (\" << expr1 << \") <= (\" << expr2 << \")\\n\"\n      << \"  Actual: \" << StringStreamToString(&val1_ss) << \" vs \"\n      << StringStreamToString(&val2_ss);\n}\n\n}  // namespace internal\n\n// Asserts that val1 is less than, or almost equal to, val2.  Fails\n// otherwise.  In particular, it fails if either val1 or val2 is NaN.\nAssertionResult FloatLE(const char* expr1, const char* expr2,\n                        float val1, float val2) {\n  return internal::FloatingPointLE<float>(expr1, expr2, val1, val2);\n}\n\n// Asserts that val1 is less than, or almost equal to, val2.  Fails\n// otherwise.  In particular, it fails if either val1 or val2 is NaN.\nAssertionResult DoubleLE(const char* expr1, const char* expr2,\n                         double val1, double val2) {\n  return internal::FloatingPointLE<double>(expr1, expr2, val1, val2);\n}\n\nnamespace internal {\n\n// The helper function for {ASSERT|EXPECT}_EQ with int or enum\n// arguments.\nAssertionResult CmpHelperEQ(const char* lhs_expression,\n                            const char* rhs_expression,\n                            BiggestInt lhs,\n                            BiggestInt rhs) {\n  if (lhs == rhs) {\n    return AssertionSuccess();\n  }\n\n  return EqFailure(lhs_expression,\n                   rhs_expression,\n                   FormatForComparisonFailureMessage(lhs, rhs),\n                   FormatForComparisonFailureMessage(rhs, lhs),\n                   false);\n}\n\n// A macro for implementing the helper functions needed to implement\n// ASSERT_?? and EXPECT_?? with integer or enum arguments.  It is here\n// just to avoid copy-and-paste of similar code.\n#define GTEST_IMPL_CMP_HELPER_(op_name, op)\\\nAssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \\\n                                   BiggestInt val1, BiggestInt val2) {\\\n  if (val1 op val2) {\\\n    return AssertionSuccess();\\\n  } else {\\\n    return AssertionFailure() \\\n        << \"Expected: (\" << expr1 << \") \" #op \" (\" << expr2\\\n        << \"), actual: \" << FormatForComparisonFailureMessage(val1, val2)\\\n        << \" vs \" << FormatForComparisonFailureMessage(val2, val1);\\\n  }\\\n}\n\n// Implements the helper function for {ASSERT|EXPECT}_NE with int or\n// enum arguments.\nGTEST_IMPL_CMP_HELPER_(NE, !=)\n// Implements the helper function for {ASSERT|EXPECT}_LE with int or\n// enum arguments.\nGTEST_IMPL_CMP_HELPER_(LE, <=)\n// Implements the helper function for {ASSERT|EXPECT}_LT with int or\n// enum arguments.\nGTEST_IMPL_CMP_HELPER_(LT, < )\n// Implements the helper function for {ASSERT|EXPECT}_GE with int or\n// enum arguments.\nGTEST_IMPL_CMP_HELPER_(GE, >=)\n// Implements the helper function for {ASSERT|EXPECT}_GT with int or\n// enum arguments.\nGTEST_IMPL_CMP_HELPER_(GT, > )\n\n#undef GTEST_IMPL_CMP_HELPER_\n\n// The helper function for {ASSERT|EXPECT}_STREQ.\nAssertionResult CmpHelperSTREQ(const char* lhs_expression,\n                               const char* rhs_expression,\n                               const char* lhs,\n                               const char* rhs) {\n  if (String::CStringEquals(lhs, rhs)) {\n    return AssertionSuccess();\n  }\n\n  return EqFailure(lhs_expression,\n                   rhs_expression,\n                   PrintToString(lhs),\n                   PrintToString(rhs),\n                   false);\n}\n\n// The helper function for {ASSERT|EXPECT}_STRCASEEQ.\nAssertionResult CmpHelperSTRCASEEQ(const char* lhs_expression,\n                                   const char* rhs_expression,\n                                   const char* lhs,\n                                   const char* rhs) {\n  if (String::CaseInsensitiveCStringEquals(lhs, rhs)) {\n    return AssertionSuccess();\n  }\n\n  return EqFailure(lhs_expression,\n                   rhs_expression,\n                   PrintToString(lhs),\n                   PrintToString(rhs),\n                   true);\n}\n\n// The helper function for {ASSERT|EXPECT}_STRNE.\nAssertionResult CmpHelperSTRNE(const char* s1_expression,\n                               const char* s2_expression,\n                               const char* s1,\n                               const char* s2) {\n  if (!String::CStringEquals(s1, s2)) {\n    return AssertionSuccess();\n  } else {\n    return AssertionFailure() << \"Expected: (\" << s1_expression << \") != (\"\n                              << s2_expression << \"), actual: \\\"\"\n                              << s1 << \"\\\" vs \\\"\" << s2 << \"\\\"\";\n  }\n}\n\n// The helper function for {ASSERT|EXPECT}_STRCASENE.\nAssertionResult CmpHelperSTRCASENE(const char* s1_expression,\n                                   const char* s2_expression,\n                                   const char* s1,\n                                   const char* s2) {\n  if (!String::CaseInsensitiveCStringEquals(s1, s2)) {\n    return AssertionSuccess();\n  } else {\n    return AssertionFailure()\n        << \"Expected: (\" << s1_expression << \") != (\"\n        << s2_expression << \") (ignoring case), actual: \\\"\"\n        << s1 << \"\\\" vs \\\"\" << s2 << \"\\\"\";\n  }\n}\n\n}  // namespace internal\n\nnamespace {\n\n// Helper functions for implementing IsSubString() and IsNotSubstring().\n\n// This group of overloaded functions return true iff needle is a\n// substring of haystack.  NULL is considered a substring of itself\n// only.\n\nbool IsSubstringPred(const char* needle, const char* haystack) {\n  if (needle == NULL || haystack == NULL)\n    return needle == haystack;\n\n  return strstr(haystack, needle) != NULL;\n}\n\nbool IsSubstringPred(const wchar_t* needle, const wchar_t* haystack) {\n  if (needle == NULL || haystack == NULL)\n    return needle == haystack;\n\n  return wcsstr(haystack, needle) != NULL;\n}\n\n// StringType here can be either ::std::string or ::std::wstring.\ntemplate <typename StringType>\nbool IsSubstringPred(const StringType& needle,\n                     const StringType& haystack) {\n  return haystack.find(needle) != StringType::npos;\n}\n\n// This function implements either IsSubstring() or IsNotSubstring(),\n// depending on the value of the expected_to_be_substring parameter.\n// StringType here can be const char*, const wchar_t*, ::std::string,\n// or ::std::wstring.\ntemplate <typename StringType>\nAssertionResult IsSubstringImpl(\n    bool expected_to_be_substring,\n    const char* needle_expr, const char* haystack_expr,\n    const StringType& needle, const StringType& haystack) {\n  if (IsSubstringPred(needle, haystack) == expected_to_be_substring)\n    return AssertionSuccess();\n\n  const bool is_wide_string = sizeof(needle[0]) > 1;\n  const char* const begin_string_quote = is_wide_string ? \"L\\\"\" : \"\\\"\";\n  return AssertionFailure()\n      << \"Value of: \" << needle_expr << \"\\n\"\n      << \"  Actual: \" << begin_string_quote << needle << \"\\\"\\n\"\n      << \"Expected: \" << (expected_to_be_substring ? \"\" : \"not \")\n      << \"a substring of \" << haystack_expr << \"\\n\"\n      << \"Which is: \" << begin_string_quote << haystack << \"\\\"\";\n}\n\n}  // namespace\n\n// IsSubstring() and IsNotSubstring() check whether needle is a\n// substring of haystack (NULL is considered a substring of itself\n// only), and return an appropriate error message when they fail.\n\nAssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const char* needle, const char* haystack) {\n  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const wchar_t* needle, const wchar_t* haystack) {\n  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const char* needle, const char* haystack) {\n  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const wchar_t* needle, const wchar_t* haystack) {\n  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::string& needle, const ::std::string& haystack) {\n  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::string& needle, const ::std::string& haystack) {\n  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);\n}\n\n#if GTEST_HAS_STD_WSTRING\nAssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::wstring& needle, const ::std::wstring& haystack) {\n  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::wstring& needle, const ::std::wstring& haystack) {\n  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);\n}\n#endif  // GTEST_HAS_STD_WSTRING\n\nnamespace internal {\n\n#if GTEST_OS_WINDOWS\n\nnamespace {\n\n// Helper function for IsHRESULT{SuccessFailure} predicates\nAssertionResult HRESULTFailureHelper(const char* expr,\n                                     const char* expected,\n                                     long hr) {  // NOLINT\n# if GTEST_OS_WINDOWS_MOBILE\n\n  // Windows CE doesn't support FormatMessage.\n  const char error_text[] = \"\";\n\n# else\n\n  // Looks up the human-readable system message for the HRESULT code\n  // and since we're not passing any params to FormatMessage, we don't\n  // want inserts expanded.\n  const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM |\n                       FORMAT_MESSAGE_IGNORE_INSERTS;\n  const DWORD kBufSize = 4096;\n  // Gets the system's human readable message string for this HRESULT.\n  char error_text[kBufSize] = { '\\0' };\n  DWORD message_length = ::FormatMessageA(kFlags,\n                                          0,  // no source, we're asking system\n                                          hr,  // the error\n                                          0,  // no line width restrictions\n                                          error_text,  // output buffer\n                                          kBufSize,  // buf size\n                                          NULL);  // no arguments for inserts\n  // Trims tailing white space (FormatMessage leaves a trailing CR-LF)\n  for (; message_length && IsSpace(error_text[message_length - 1]);\n          --message_length) {\n    error_text[message_length - 1] = '\\0';\n  }\n\n# endif  // GTEST_OS_WINDOWS_MOBILE\n\n  const std::string error_hex(\"0x\" + String::FormatHexInt(hr));\n  return ::testing::AssertionFailure()\n      << \"Expected: \" << expr << \" \" << expected << \".\\n\"\n      << \"  Actual: \" << error_hex << \" \" << error_text << \"\\n\";\n}\n\n}  // namespace\n\nAssertionResult IsHRESULTSuccess(const char* expr, long hr) {  // NOLINT\n  if (SUCCEEDED(hr)) {\n    return AssertionSuccess();\n  }\n  return HRESULTFailureHelper(expr, \"succeeds\", hr);\n}\n\nAssertionResult IsHRESULTFailure(const char* expr, long hr) {  // NOLINT\n  if (FAILED(hr)) {\n    return AssertionSuccess();\n  }\n  return HRESULTFailureHelper(expr, \"fails\", hr);\n}\n\n#endif  // GTEST_OS_WINDOWS\n\n// Utility functions for encoding Unicode text (wide strings) in\n// UTF-8.\n\n// A Unicode code-point can have upto 21 bits, and is encoded in UTF-8\n// like this:\n//\n// Code-point length   Encoding\n//   0 -  7 bits       0xxxxxxx\n//   8 - 11 bits       110xxxxx 10xxxxxx\n//  12 - 16 bits       1110xxxx 10xxxxxx 10xxxxxx\n//  17 - 21 bits       11110xxx 10xxxxxx 10xxxxxx 10xxxxxx\n\n// The maximum code-point a one-byte UTF-8 sequence can represent.\nconst UInt32 kMaxCodePoint1 = (static_cast<UInt32>(1) <<  7) - 1;\n\n// The maximum code-point a two-byte UTF-8 sequence can represent.\nconst UInt32 kMaxCodePoint2 = (static_cast<UInt32>(1) << (5 + 6)) - 1;\n\n// The maximum code-point a three-byte UTF-8 sequence can represent.\nconst UInt32 kMaxCodePoint3 = (static_cast<UInt32>(1) << (4 + 2*6)) - 1;\n\n// The maximum code-point a four-byte UTF-8 sequence can represent.\nconst UInt32 kMaxCodePoint4 = (static_cast<UInt32>(1) << (3 + 3*6)) - 1;\n\n// Chops off the n lowest bits from a bit pattern.  Returns the n\n// lowest bits.  As a side effect, the original bit pattern will be\n// shifted to the right by n bits.\ninline UInt32 ChopLowBits(UInt32* bits, int n) {\n  const UInt32 low_bits = *bits & ((static_cast<UInt32>(1) << n) - 1);\n  *bits >>= n;\n  return low_bits;\n}\n\n// Converts a Unicode code point to a narrow string in UTF-8 encoding.\n// code_point parameter is of type UInt32 because wchar_t may not be\n// wide enough to contain a code point.\n// If the code_point is not a valid Unicode code point\n// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted\n// to \"(Invalid Unicode 0xXXXXXXXX)\".\nstd::string CodePointToUtf8(UInt32 code_point) {\n  if (code_point > kMaxCodePoint4) {\n    return \"(Invalid Unicode 0x\" + String::FormatHexInt(code_point) + \")\";\n  }\n\n  char str[5];  // Big enough for the largest valid code point.\n  if (code_point <= kMaxCodePoint1) {\n    str[1] = '\\0';\n    str[0] = static_cast<char>(code_point);                          // 0xxxxxxx\n  } else if (code_point <= kMaxCodePoint2) {\n    str[2] = '\\0';\n    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[0] = static_cast<char>(0xC0 | code_point);                   // 110xxxxx\n  } else if (code_point <= kMaxCodePoint3) {\n    str[3] = '\\0';\n    str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[0] = static_cast<char>(0xE0 | code_point);                   // 1110xxxx\n  } else {  // code_point <= kMaxCodePoint4\n    str[4] = '\\0';\n    str[3] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[0] = static_cast<char>(0xF0 | code_point);                   // 11110xxx\n  }\n  return str;\n}\n\n// The following two functions only make sense if the the system\n// uses UTF-16 for wide string encoding. All supported systems\n// with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16.\n\n// Determines if the arguments constitute UTF-16 surrogate pair\n// and thus should be combined into a single Unicode code point\n// using CreateCodePointFromUtf16SurrogatePair.\ninline bool IsUtf16SurrogatePair(wchar_t first, wchar_t second) {\n  return sizeof(wchar_t) == 2 &&\n      (first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00;\n}\n\n// Creates a Unicode code point from UTF16 surrogate pair.\ninline UInt32 CreateCodePointFromUtf16SurrogatePair(wchar_t first,\n                                                    wchar_t second) {\n  const UInt32 mask = (1 << 10) - 1;\n  return (sizeof(wchar_t) == 2) ?\n      (((first & mask) << 10) | (second & mask)) + 0x10000 :\n      // This function should not be called when the condition is\n      // false, but we provide a sensible default in case it is.\n      static_cast<UInt32>(first);\n}\n\n// Converts a wide string to a narrow string in UTF-8 encoding.\n// The wide string is assumed to have the following encoding:\n//   UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS)\n//   UTF-32 if sizeof(wchar_t) == 4 (on Linux)\n// Parameter str points to a null-terminated wide string.\n// Parameter num_chars may additionally limit the number\n// of wchar_t characters processed. -1 is used when the entire string\n// should be processed.\n// If the string contains code points that are not valid Unicode code points\n// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output\n// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding\n// and contains invalid UTF-16 surrogate pairs, values in those pairs\n// will be encoded as individual Unicode characters from Basic Normal Plane.\nstd::string WideStringToUtf8(const wchar_t* str, int num_chars) {\n  if (num_chars == -1)\n    num_chars = static_cast<int>(wcslen(str));\n\n  ::std::stringstream stream;\n  for (int i = 0; i < num_chars; ++i) {\n    UInt32 unicode_code_point;\n\n    if (str[i] == L'\\0') {\n      break;\n    } else if (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) {\n      unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],\n                                                                 str[i + 1]);\n      i++;\n    } else {\n      unicode_code_point = static_cast<UInt32>(str[i]);\n    }\n\n    stream << CodePointToUtf8(unicode_code_point);\n  }\n  return StringStreamToString(&stream);\n}\n\n// Converts a wide C string to an std::string using the UTF-8 encoding.\n// NULL will be converted to \"(null)\".\nstd::string String::ShowWideCString(const wchar_t * wide_c_str) {\n  if (wide_c_str == NULL)  return \"(null)\";\n\n  return internal::WideStringToUtf8(wide_c_str, -1);\n}\n\n// Compares two wide C strings.  Returns true iff they have the same\n// content.\n//\n// Unlike wcscmp(), this function can handle NULL argument(s).  A NULL\n// C string is considered different to any non-NULL C string,\n// including the empty string.\nbool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) {\n  if (lhs == NULL) return rhs == NULL;\n\n  if (rhs == NULL) return false;\n\n  return wcscmp(lhs, rhs) == 0;\n}\n\n// Helper function for *_STREQ on wide strings.\nAssertionResult CmpHelperSTREQ(const char* lhs_expression,\n                               const char* rhs_expression,\n                               const wchar_t* lhs,\n                               const wchar_t* rhs) {\n  if (String::WideCStringEquals(lhs, rhs)) {\n    return AssertionSuccess();\n  }\n\n  return EqFailure(lhs_expression,\n                   rhs_expression,\n                   PrintToString(lhs),\n                   PrintToString(rhs),\n                   false);\n}\n\n// Helper function for *_STRNE on wide strings.\nAssertionResult CmpHelperSTRNE(const char* s1_expression,\n                               const char* s2_expression,\n                               const wchar_t* s1,\n                               const wchar_t* s2) {\n  if (!String::WideCStringEquals(s1, s2)) {\n    return AssertionSuccess();\n  }\n\n  return AssertionFailure() << \"Expected: (\" << s1_expression << \") != (\"\n                            << s2_expression << \"), actual: \"\n                            << PrintToString(s1)\n                            << \" vs \" << PrintToString(s2);\n}\n\n// Compares two C strings, ignoring case.  Returns true iff they have\n// the same content.\n//\n// Unlike strcasecmp(), this function can handle NULL argument(s).  A\n// NULL C string is considered different to any non-NULL C string,\n// including the empty string.\nbool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {\n  if (lhs == NULL)\n    return rhs == NULL;\n  if (rhs == NULL)\n    return false;\n  return posix::StrCaseCmp(lhs, rhs) == 0;\n}\n\n  // Compares two wide C strings, ignoring case.  Returns true iff they\n  // have the same content.\n  //\n  // Unlike wcscasecmp(), this function can handle NULL argument(s).\n  // A NULL C string is considered different to any non-NULL wide C string,\n  // including the empty string.\n  // NB: The implementations on different platforms slightly differ.\n  // On windows, this method uses _wcsicmp which compares according to LC_CTYPE\n  // environment variable. On GNU platform this method uses wcscasecmp\n  // which compares according to LC_CTYPE category of the current locale.\n  // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the\n  // current locale.\nbool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,\n                                              const wchar_t* rhs) {\n  if (lhs == NULL) return rhs == NULL;\n\n  if (rhs == NULL) return false;\n\n#if GTEST_OS_WINDOWS\n  return _wcsicmp(lhs, rhs) == 0;\n#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID\n  return wcscasecmp(lhs, rhs) == 0;\n#else\n  // Android, Mac OS X and Cygwin don't define wcscasecmp.\n  // Other unknown OSes may not define it either.\n  wint_t left, right;\n  do {\n    left = towlower(*lhs++);\n    right = towlower(*rhs++);\n  } while (left && left == right);\n  return left == right;\n#endif  // OS selector\n}\n\n// Returns true iff str ends with the given suffix, ignoring case.\n// Any string is considered to end with an empty suffix.\nbool String::EndsWithCaseInsensitive(\n    const std::string& str, const std::string& suffix) {\n  const size_t str_len = str.length();\n  const size_t suffix_len = suffix.length();\n  return (str_len >= suffix_len) &&\n         CaseInsensitiveCStringEquals(str.c_str() + str_len - suffix_len,\n                                      suffix.c_str());\n}\n\n// Formats an int value as \"%02d\".\nstd::string String::FormatIntWidth2(int value) {\n  std::stringstream ss;\n  ss << std::setfill('0') << std::setw(2) << value;\n  return ss.str();\n}\n\n// Formats an int value as \"%X\".\nstd::string String::FormatHexInt(int value) {\n  std::stringstream ss;\n  ss << std::hex << std::uppercase << value;\n  return ss.str();\n}\n\n// Formats a byte as \"%02X\".\nstd::string String::FormatByte(unsigned char value) {\n  std::stringstream ss;\n  ss << std::setfill('0') << std::setw(2) << std::hex << std::uppercase\n     << static_cast<unsigned int>(value);\n  return ss.str();\n}\n\n// Converts the buffer in a stringstream to an std::string, converting NUL\n// bytes to \"\\\\0\" along the way.\nstd::string StringStreamToString(::std::stringstream* ss) {\n  const ::std::string& str = ss->str();\n  const char* const start = str.c_str();\n  const char* const end = start + str.length();\n\n  std::string result;\n  result.reserve(2 * (end - start));\n  for (const char* ch = start; ch != end; ++ch) {\n    if (*ch == '\\0') {\n      result += \"\\\\0\";  // Replaces NUL with \"\\\\0\";\n    } else {\n      result += *ch;\n    }\n  }\n\n  return result;\n}\n\n// Appends the user-supplied message to the Google-Test-generated message.\nstd::string AppendUserMessage(const std::string& gtest_msg,\n                              const Message& user_msg) {\n  // Appends the user message if it's non-empty.\n  const std::string user_msg_string = user_msg.GetString();\n  if (user_msg_string.empty()) {\n    return gtest_msg;\n  }\n\n  return gtest_msg + \"\\n\" + user_msg_string;\n}\n\n}  // namespace internal\n\n// class TestResult\n\n// Creates an empty TestResult.\nTestResult::TestResult()\n    : death_test_count_(0),\n      elapsed_time_(0) {\n}\n\n// D'tor.\nTestResult::~TestResult() {\n}\n\n// Returns the i-th test part result among all the results. i can\n// range from 0 to total_part_count() - 1. If i is not in that range,\n// aborts the program.\nconst TestPartResult& TestResult::GetTestPartResult(int i) const {\n  if (i < 0 || i >= total_part_count())\n    internal::posix::Abort();\n  return test_part_results_.at(i);\n}\n\n// Returns the i-th test property. i can range from 0 to\n// test_property_count() - 1. If i is not in that range, aborts the\n// program.\nconst TestProperty& TestResult::GetTestProperty(int i) const {\n  if (i < 0 || i >= test_property_count())\n    internal::posix::Abort();\n  return test_properties_.at(i);\n}\n\n// Clears the test part results.\nvoid TestResult::ClearTestPartResults() {\n  test_part_results_.clear();\n}\n\n// Adds a test part result to the list.\nvoid TestResult::AddTestPartResult(const TestPartResult& test_part_result) {\n  test_part_results_.push_back(test_part_result);\n}\n\n// Adds a test property to the list. If a property with the same key as the\n// supplied property is already represented, the value of this test_property\n// replaces the old value for that key.\nvoid TestResult::RecordProperty(const std::string& xml_element,\n                                const TestProperty& test_property) {\n  if (!ValidateTestProperty(xml_element, test_property)) {\n    return;\n  }\n  internal::MutexLock lock(&test_properites_mutex_);\n  const std::vector<TestProperty>::iterator property_with_matching_key =\n      std::find_if(test_properties_.begin(), test_properties_.end(),\n                   internal::TestPropertyKeyIs(test_property.key()));\n  if (property_with_matching_key == test_properties_.end()) {\n    test_properties_.push_back(test_property);\n    return;\n  }\n  property_with_matching_key->SetValue(test_property.value());\n}\n\n// The list of reserved attributes used in the <testsuites> element of XML\n// output.\nstatic const char* const kReservedTestSuitesAttributes[] = {\n  \"disabled\",\n  \"errors\",\n  \"failures\",\n  \"name\",\n  \"random_seed\",\n  \"tests\",\n  \"time\",\n  \"timestamp\"\n};\n\n// The list of reserved attributes used in the <testsuite> element of XML\n// output.\nstatic const char* const kReservedTestSuiteAttributes[] = {\n  \"disabled\",\n  \"errors\",\n  \"failures\",\n  \"name\",\n  \"tests\",\n  \"time\"\n};\n\n// The list of reserved attributes used in the <testcase> element of XML output.\nstatic const char* const kReservedTestCaseAttributes[] = {\n  \"classname\",\n  \"name\",\n  \"status\",\n  \"time\",\n  \"type_param\",\n  \"value_param\"\n};\n\ntemplate <int kSize>\nstd::vector<std::string> ArrayAsVector(const char* const (&array)[kSize]) {\n  return std::vector<std::string>(array, array + kSize);\n}\n\nstatic std::vector<std::string> GetReservedAttributesForElement(\n    const std::string& xml_element) {\n  if (xml_element == \"testsuites\") {\n    return ArrayAsVector(kReservedTestSuitesAttributes);\n  } else if (xml_element == \"testsuite\") {\n    return ArrayAsVector(kReservedTestSuiteAttributes);\n  } else if (xml_element == \"testcase\") {\n    return ArrayAsVector(kReservedTestCaseAttributes);\n  } else {\n    GTEST_CHECK_(false) << \"Unrecognized xml_element provided: \" << xml_element;\n  }\n  // This code is unreachable but some compilers may not realizes that.\n  return std::vector<std::string>();\n}\n\nstatic std::string FormatWordList(const std::vector<std::string>& words) {\n  Message word_list;\n  for (size_t i = 0; i < words.size(); ++i) {\n    if (i > 0 && words.size() > 2) {\n      word_list << \", \";\n    }\n    if (i == words.size() - 1) {\n      word_list << \"and \";\n    }\n    word_list << \"'\" << words[i] << \"'\";\n  }\n  return word_list.GetString();\n}\n\nbool ValidateTestPropertyName(const std::string& property_name,\n                              const std::vector<std::string>& reserved_names) {\n  if (std::find(reserved_names.begin(), reserved_names.end(), property_name) !=\n          reserved_names.end()) {\n    ADD_FAILURE() << \"Reserved key used in RecordProperty(): \" << property_name\n                  << \" (\" << FormatWordList(reserved_names)\n                  << \" are reserved by \" << GTEST_NAME_ << \")\";\n    return false;\n  }\n  return true;\n}\n\n// Adds a failure if the key is a reserved attribute of the element named\n// xml_element.  Returns true if the property is valid.\nbool TestResult::ValidateTestProperty(const std::string& xml_element,\n                                      const TestProperty& test_property) {\n  return ValidateTestPropertyName(test_property.key(),\n                                  GetReservedAttributesForElement(xml_element));\n}\n\n// Clears the object.\nvoid TestResult::Clear() {\n  test_part_results_.clear();\n  test_properties_.clear();\n  death_test_count_ = 0;\n  elapsed_time_ = 0;\n}\n\n// Returns true iff the test failed.\nbool TestResult::Failed() const {\n  for (int i = 0; i < total_part_count(); ++i) {\n    if (GetTestPartResult(i).failed())\n      return true;\n  }\n  return false;\n}\n\n// Returns true iff the test part fatally failed.\nstatic bool TestPartFatallyFailed(const TestPartResult& result) {\n  return result.fatally_failed();\n}\n\n// Returns true iff the test fatally failed.\nbool TestResult::HasFatalFailure() const {\n  return CountIf(test_part_results_, TestPartFatallyFailed) > 0;\n}\n\n// Returns true iff the test part non-fatally failed.\nstatic bool TestPartNonfatallyFailed(const TestPartResult& result) {\n  return result.nonfatally_failed();\n}\n\n// Returns true iff the test has a non-fatal failure.\nbool TestResult::HasNonfatalFailure() const {\n  return CountIf(test_part_results_, TestPartNonfatallyFailed) > 0;\n}\n\n// Gets the number of all test parts.  This is the sum of the number\n// of successful test parts and the number of failed test parts.\nint TestResult::total_part_count() const {\n  return static_cast<int>(test_part_results_.size());\n}\n\n// Returns the number of the test properties.\nint TestResult::test_property_count() const {\n  return static_cast<int>(test_properties_.size());\n}\n\n// class Test\n\n// Creates a Test object.\n\n// The c'tor saves the states of all flags.\nTest::Test()\n    : gtest_flag_saver_(new GTEST_FLAG_SAVER_) {\n}\n\n// The d'tor restores the states of all flags.  The actual work is\n// done by the d'tor of the gtest_flag_saver_ field, and thus not\n// visible here.\nTest::~Test() {\n}\n\n// Sets up the test fixture.\n//\n// A sub-class may override this.\nvoid Test::SetUp() {\n}\n\n// Tears down the test fixture.\n//\n// A sub-class may override this.\nvoid Test::TearDown() {\n}\n\n// Allows user supplied key value pairs to be recorded for later output.\nvoid Test::RecordProperty(const std::string& key, const std::string& value) {\n  UnitTest::GetInstance()->RecordProperty(key, value);\n}\n\n// Allows user supplied key value pairs to be recorded for later output.\nvoid Test::RecordProperty(const std::string& key, int value) {\n  Message value_message;\n  value_message << value;\n  RecordProperty(key, value_message.GetString().c_str());\n}\n\nnamespace internal {\n\nvoid ReportFailureInUnknownLocation(TestPartResult::Type result_type,\n                                    const std::string& message) {\n  // This function is a friend of UnitTest and as such has access to\n  // AddTestPartResult.\n  UnitTest::GetInstance()->AddTestPartResult(\n      result_type,\n      NULL,  // No info about the source file where the exception occurred.\n      -1,    // We have no info on which line caused the exception.\n      message,\n      \"\");   // No stack trace, either.\n}\n\n}  // namespace internal\n\n// Google Test requires all tests in the same test case to use the same test\n// fixture class.  This function checks if the current test has the\n// same fixture class as the first test in the current test case.  If\n// yes, it returns true; otherwise it generates a Google Test failure and\n// returns false.\nbool Test::HasSameFixtureClass() {\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  const TestCase* const test_case = impl->current_test_case();\n\n  // Info about the first test in the current test case.\n  const TestInfo* const first_test_info = test_case->test_info_list()[0];\n  const internal::TypeId first_fixture_id = first_test_info->fixture_class_id_;\n  const char* const first_test_name = first_test_info->name();\n\n  // Info about the current test.\n  const TestInfo* const this_test_info = impl->current_test_info();\n  const internal::TypeId this_fixture_id = this_test_info->fixture_class_id_;\n  const char* const this_test_name = this_test_info->name();\n\n  if (this_fixture_id != first_fixture_id) {\n    // Is the first test defined using TEST?\n    const bool first_is_TEST = first_fixture_id == internal::GetTestTypeId();\n    // Is this test defined using TEST?\n    const bool this_is_TEST = this_fixture_id == internal::GetTestTypeId();\n\n    if (first_is_TEST || this_is_TEST) {\n      // Both TEST and TEST_F appear in same test case, which is incorrect.\n      // Tell the user how to fix this.\n\n      // Gets the name of the TEST and the name of the TEST_F.  Note\n      // that first_is_TEST and this_is_TEST cannot both be true, as\n      // the fixture IDs are different for the two tests.\n      const char* const TEST_name =\n          first_is_TEST ? first_test_name : this_test_name;\n      const char* const TEST_F_name =\n          first_is_TEST ? this_test_name : first_test_name;\n\n      ADD_FAILURE()\n          << \"All tests in the same test case must use the same test fixture\\n\"\n          << \"class, so mixing TEST_F and TEST in the same test case is\\n\"\n          << \"illegal.  In test case \" << this_test_info->test_case_name()\n          << \",\\n\"\n          << \"test \" << TEST_F_name << \" is defined using TEST_F but\\n\"\n          << \"test \" << TEST_name << \" is defined using TEST.  You probably\\n\"\n          << \"want to change the TEST to TEST_F or move it to another test\\n\"\n          << \"case.\";\n    } else {\n      // Two fixture classes with the same name appear in two different\n      // namespaces, which is not allowed. Tell the user how to fix this.\n      ADD_FAILURE()\n          << \"All tests in the same test case must use the same test fixture\\n\"\n          << \"class.  However, in test case \"\n          << this_test_info->test_case_name() << \",\\n\"\n          << \"you defined test \" << first_test_name\n          << \" and test \" << this_test_name << \"\\n\"\n          << \"using two different test fixture classes.  This can happen if\\n\"\n          << \"the two classes are from different namespaces or translation\\n\"\n          << \"units and have the same name.  You should probably rename one\\n\"\n          << \"of the classes to put the tests into different test cases.\";\n    }\n    return false;\n  }\n\n  return true;\n}\n\n#if GTEST_HAS_SEH\n\n// Adds an \"exception thrown\" fatal failure to the current test.  This\n// function returns its result via an output parameter pointer because VC++\n// prohibits creation of objects with destructors on stack in functions\n// using __try (see error C2712).\nstatic std::string* FormatSehExceptionMessage(DWORD exception_code,\n                                              const char* location) {\n  Message message;\n  message << \"SEH exception with code 0x\" << std::setbase(16) <<\n    exception_code << std::setbase(10) << \" thrown in \" << location << \".\";\n\n  return new std::string(message.GetString());\n}\n\n#endif  // GTEST_HAS_SEH\n\nnamespace internal {\n\n#if GTEST_HAS_EXCEPTIONS\n\n// Adds an \"exception thrown\" fatal failure to the current test.\nstatic std::string FormatCxxExceptionMessage(const char* description,\n                                             const char* location) {\n  Message message;\n  if (description != NULL) {\n    message << \"C++ exception with description \\\"\" << description << \"\\\"\";\n  } else {\n    message << \"Unknown C++ exception\";\n  }\n  message << \" thrown in \" << location << \".\";\n\n  return message.GetString();\n}\n\nstatic std::string PrintTestPartResultToString(\n    const TestPartResult& test_part_result);\n\nGoogleTestFailureException::GoogleTestFailureException(\n    const TestPartResult& failure)\n    : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// We put these helper functions in the internal namespace as IBM's xlC\n// compiler rejects the code if they were declared static.\n\n// Runs the given method and handles SEH exceptions it throws, when\n// SEH is supported; returns the 0-value for type Result in case of an\n// SEH exception.  (Microsoft compilers cannot handle SEH and C++\n// exceptions in the same function.  Therefore, we provide a separate\n// wrapper function for handling SEH exceptions.)\ntemplate <class T, typename Result>\nResult HandleSehExceptionsInMethodIfSupported(\n    T* object, Result (T::*method)(), const char* location) {\n#if GTEST_HAS_SEH\n  __try {\n    return (object->*method)();\n  } __except (internal::UnitTestOptions::GTestShouldProcessSEH(  // NOLINT\n      GetExceptionCode())) {\n    // We create the exception message on the heap because VC++ prohibits\n    // creation of objects with destructors on stack in functions using __try\n    // (see error C2712).\n    std::string* exception_message = FormatSehExceptionMessage(\n        GetExceptionCode(), location);\n    internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure,\n                                             *exception_message);\n    delete exception_message;\n    return static_cast<Result>(0);\n  }\n#else\n  (void)location;\n  return (object->*method)();\n#endif  // GTEST_HAS_SEH\n}\n\n// Runs the given method and catches and reports C++ and/or SEH-style\n// exceptions, if they are supported; returns the 0-value for type\n// Result in case of an SEH exception.\ntemplate <class T, typename Result>\nResult HandleExceptionsInMethodIfSupported(\n    T* object, Result (T::*method)(), const char* location) {\n  // NOTE: The user code can affect the way in which Google Test handles\n  // exceptions by setting GTEST_FLAG(catch_exceptions), but only before\n  // RUN_ALL_TESTS() starts. It is technically possible to check the flag\n  // after the exception is caught and either report or re-throw the\n  // exception based on the flag's value:\n  //\n  // try {\n  //   // Perform the test method.\n  // } catch (...) {\n  //   if (GTEST_FLAG(catch_exceptions))\n  //     // Report the exception as failure.\n  //   else\n  //     throw;  // Re-throws the original exception.\n  // }\n  //\n  // However, the purpose of this flag is to allow the program to drop into\n  // the debugger when the exception is thrown. On most platforms, once the\n  // control enters the catch block, the exception origin information is\n  // lost and the debugger will stop the program at the point of the\n  // re-throw in this function -- instead of at the point of the original\n  // throw statement in the code under test.  For this reason, we perform\n  // the check early, sacrificing the ability to affect Google Test's\n  // exception handling in the method where the exception is thrown.\n  if (internal::GetUnitTestImpl()->catch_exceptions()) {\n#if GTEST_HAS_EXCEPTIONS\n    try {\n      return HandleSehExceptionsInMethodIfSupported(object, method, location);\n    } catch (const internal::GoogleTestFailureException&) {  // NOLINT\n      // This exception type can only be thrown by a failed Google\n      // Test assertion with the intention of letting another testing\n      // framework catch it.  Therefore we just re-throw it.\n      throw;\n    } catch (const std::exception& e) {  // NOLINT\n      internal::ReportFailureInUnknownLocation(\n          TestPartResult::kFatalFailure,\n          FormatCxxExceptionMessage(e.what(), location));\n    } catch (...) {  // NOLINT\n      internal::ReportFailureInUnknownLocation(\n          TestPartResult::kFatalFailure,\n          FormatCxxExceptionMessage(NULL, location));\n    }\n    return static_cast<Result>(0);\n#else\n    return HandleSehExceptionsInMethodIfSupported(object, method, location);\n#endif  // GTEST_HAS_EXCEPTIONS\n  } else {\n    return (object->*method)();\n  }\n}\n\n}  // namespace internal\n\n// Runs the test and updates the test result.\nvoid Test::Run() {\n  if (!HasSameFixtureClass()) return;\n\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n  internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, \"SetUp()\");\n  // We will run the test only if SetUp() was successful.\n  if (!HasFatalFailure()) {\n    impl->os_stack_trace_getter()->UponLeavingGTest();\n    internal::HandleExceptionsInMethodIfSupported(\n        this, &Test::TestBody, \"the test body\");\n  }\n\n  // However, we want to clean up as much as possible.  Hence we will\n  // always call TearDown(), even if SetUp() or the test body has\n  // failed.\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n  internal::HandleExceptionsInMethodIfSupported(\n      this, &Test::TearDown, \"TearDown()\");\n}\n\n// Returns true iff the current test has a fatal failure.\nbool Test::HasFatalFailure() {\n  return internal::GetUnitTestImpl()->current_test_result()->HasFatalFailure();\n}\n\n// Returns true iff the current test has a non-fatal failure.\nbool Test::HasNonfatalFailure() {\n  return internal::GetUnitTestImpl()->current_test_result()->\n      HasNonfatalFailure();\n}\n\n// class TestInfo\n\n// Constructs a TestInfo object. It assumes ownership of the test factory\n// object.\nTestInfo::TestInfo(const std::string& a_test_case_name,\n                   const std::string& a_name,\n                   const char* a_type_param,\n                   const char* a_value_param,\n                   internal::CodeLocation a_code_location,\n                   internal::TypeId fixture_class_id,\n                   internal::TestFactoryBase* factory)\n    : test_case_name_(a_test_case_name),\n      name_(a_name),\n      type_param_(a_type_param ? new std::string(a_type_param) : NULL),\n      value_param_(a_value_param ? new std::string(a_value_param) : NULL),\n      location_(a_code_location),\n      fixture_class_id_(fixture_class_id),\n      should_run_(false),\n      is_disabled_(false),\n      matches_filter_(false),\n      factory_(factory),\n      result_() {}\n\n// Destructs a TestInfo object.\nTestInfo::~TestInfo() { delete factory_; }\n\nnamespace internal {\n\n// Creates a new TestInfo object and registers it with Google Test;\n// returns the created object.\n//\n// Arguments:\n//\n//   test_case_name:   name of the test case\n//   name:             name of the test\n//   type_param:       the name of the test's type parameter, or NULL if\n//                     this is not a typed or a type-parameterized test.\n//   value_param:      text representation of the test's value parameter,\n//                     or NULL if this is not a value-parameterized test.\n//   code_location:    code location where the test is defined\n//   fixture_class_id: ID of the test fixture class\n//   set_up_tc:        pointer to the function that sets up the test case\n//   tear_down_tc:     pointer to the function that tears down the test case\n//   factory:          pointer to the factory that creates a test object.\n//                     The newly created TestInfo instance will assume\n//                     ownership of the factory object.\nTestInfo* MakeAndRegisterTestInfo(\n    const char* test_case_name,\n    const char* name,\n    const char* type_param,\n    const char* value_param,\n    CodeLocation code_location,\n    TypeId fixture_class_id,\n    SetUpTestCaseFunc set_up_tc,\n    TearDownTestCaseFunc tear_down_tc,\n    TestFactoryBase* factory) {\n  TestInfo* const test_info =\n      new TestInfo(test_case_name, name, type_param, value_param,\n                   code_location, fixture_class_id, factory);\n  GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info);\n  return test_info;\n}\n\n#if GTEST_HAS_PARAM_TEST\nvoid ReportInvalidTestCaseType(const char* test_case_name,\n                               CodeLocation code_location) {\n  Message errors;\n  errors\n      << \"Attempted redefinition of test case \" << test_case_name << \".\\n\"\n      << \"All tests in the same test case must use the same test fixture\\n\"\n      << \"class.  However, in test case \" << test_case_name << \", you tried\\n\"\n      << \"to define a test using a fixture class different from the one\\n\"\n      << \"used earlier. This can happen if the two fixture classes are\\n\"\n      << \"from different namespaces and have the same name. You should\\n\"\n      << \"probably rename one of the classes to put the tests into different\\n\"\n      << \"test cases.\";\n\n  fprintf(stderr, \"%s %s\",\n          FormatFileLocation(code_location.file.c_str(),\n                             code_location.line).c_str(),\n          errors.GetString().c_str());\n}\n#endif  // GTEST_HAS_PARAM_TEST\n\n}  // namespace internal\n\nnamespace {\n\n// A predicate that checks the test name of a TestInfo against a known\n// value.\n//\n// This is used for implementation of the TestCase class only.  We put\n// it in the anonymous namespace to prevent polluting the outer\n// namespace.\n//\n// TestNameIs is copyable.\nclass TestNameIs {\n public:\n  // Constructor.\n  //\n  // TestNameIs has NO default constructor.\n  explicit TestNameIs(const char* name)\n      : name_(name) {}\n\n  // Returns true iff the test name of test_info matches name_.\n  bool operator()(const TestInfo * test_info) const {\n    return test_info && test_info->name() == name_;\n  }\n\n private:\n  std::string name_;\n};\n\n}  // namespace\n\nnamespace internal {\n\n// This method expands all parameterized tests registered with macros TEST_P\n// and INSTANTIATE_TEST_CASE_P into regular tests and registers those.\n// This will be done just once during the program runtime.\nvoid UnitTestImpl::RegisterParameterizedTests() {\n#if GTEST_HAS_PARAM_TEST\n  if (!parameterized_tests_registered_) {\n    parameterized_test_registry_.RegisterTests();\n    parameterized_tests_registered_ = true;\n  }\n#endif\n}\n\n}  // namespace internal\n\n// Creates the test object, runs it, records its result, and then\n// deletes it.\nvoid TestInfo::Run() {\n  if (!should_run_) return;\n\n  // Tells UnitTest where to store test result.\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  impl->set_current_test_info(this);\n\n  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();\n\n  // Notifies the unit test event listeners that a test is about to start.\n  repeater->OnTestStart(*this);\n\n  const TimeInMillis start = internal::GetTimeInMillis();\n\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n\n  // Creates the test object.\n  Test* const test = internal::HandleExceptionsInMethodIfSupported(\n      factory_, &internal::TestFactoryBase::CreateTest,\n      \"the test fixture's constructor\");\n\n  // Runs the test only if the test object was created and its\n  // constructor didn't generate a fatal failure.\n  if ((test != NULL) && !Test::HasFatalFailure()) {\n    // This doesn't throw as all user code that can throw are wrapped into\n    // exception handling code.\n    test->Run();\n  }\n\n  // Deletes the test object.\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n  internal::HandleExceptionsInMethodIfSupported(\n      test, &Test::DeleteSelf_, \"the test fixture's destructor\");\n\n  result_.set_elapsed_time(internal::GetTimeInMillis() - start);\n\n  // Notifies the unit test event listener that a test has just finished.\n  repeater->OnTestEnd(*this);\n\n  // Tells UnitTest to stop associating assertion results to this\n  // test.\n  impl->set_current_test_info(NULL);\n}\n\n// class TestCase\n\n// Gets the number of successful tests in this test case.\nint TestCase::successful_test_count() const {\n  return CountIf(test_info_list_, TestPassed);\n}\n\n// Gets the number of failed tests in this test case.\nint TestCase::failed_test_count() const {\n  return CountIf(test_info_list_, TestFailed);\n}\n\n// Gets the number of disabled tests that will be reported in the XML report.\nint TestCase::reportable_disabled_test_count() const {\n  return CountIf(test_info_list_, TestReportableDisabled);\n}\n\n// Gets the number of disabled tests in this test case.\nint TestCase::disabled_test_count() const {\n  return CountIf(test_info_list_, TestDisabled);\n}\n\n// Gets the number of tests to be printed in the XML report.\nint TestCase::reportable_test_count() const {\n  return CountIf(test_info_list_, TestReportable);\n}\n\n// Get the number of tests in this test case that should run.\nint TestCase::test_to_run_count() const {\n  return CountIf(test_info_list_, ShouldRunTest);\n}\n\n// Gets the number of all tests.\nint TestCase::total_test_count() const {\n  return static_cast<int>(test_info_list_.size());\n}\n\n// Creates a TestCase with the given name.\n//\n// Arguments:\n//\n//   name:         name of the test case\n//   a_type_param: the name of the test case's type parameter, or NULL if\n//                 this is not a typed or a type-parameterized test case.\n//   set_up_tc:    pointer to the function that sets up the test case\n//   tear_down_tc: pointer to the function that tears down the test case\nTestCase::TestCase(const char* a_name, const char* a_type_param,\n                   Test::SetUpTestCaseFunc set_up_tc,\n                   Test::TearDownTestCaseFunc tear_down_tc)\n    : name_(a_name),\n      type_param_(a_type_param ? new std::string(a_type_param) : NULL),\n      set_up_tc_(set_up_tc),\n      tear_down_tc_(tear_down_tc),\n      should_run_(false),\n      elapsed_time_(0) {\n}\n\n// Destructor of TestCase.\nTestCase::~TestCase() {\n  // Deletes every Test in the collection.\n  ForEach(test_info_list_, internal::Delete<TestInfo>);\n}\n\n// Returns the i-th test among all the tests. i can range from 0 to\n// total_test_count() - 1. If i is not in that range, returns NULL.\nconst TestInfo* TestCase::GetTestInfo(int i) const {\n  const int index = GetElementOr(test_indices_, i, -1);\n  return index < 0 ? NULL : test_info_list_[index];\n}\n\n// Returns the i-th test among all the tests. i can range from 0 to\n// total_test_count() - 1. If i is not in that range, returns NULL.\nTestInfo* TestCase::GetMutableTestInfo(int i) {\n  const int index = GetElementOr(test_indices_, i, -1);\n  return index < 0 ? NULL : test_info_list_[index];\n}\n\n// Adds a test to this test case.  Will delete the test upon\n// destruction of the TestCase object.\nvoid TestCase::AddTestInfo(TestInfo * test_info) {\n  test_info_list_.push_back(test_info);\n  test_indices_.push_back(static_cast<int>(test_indices_.size()));\n}\n\n// Runs every test in this TestCase.\nvoid TestCase::Run() {\n  if (!should_run_) return;\n\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  impl->set_current_test_case(this);\n\n  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();\n\n  repeater->OnTestCaseStart(*this);\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n  internal::HandleExceptionsInMethodIfSupported(\n      this, &TestCase::RunSetUpTestCase, \"SetUpTestCase()\");\n\n  const internal::TimeInMillis start = internal::GetTimeInMillis();\n  for (int i = 0; i < total_test_count(); i++) {\n    GetMutableTestInfo(i)->Run();\n  }\n  elapsed_time_ = internal::GetTimeInMillis() - start;\n\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n  internal::HandleExceptionsInMethodIfSupported(\n      this, &TestCase::RunTearDownTestCase, \"TearDownTestCase()\");\n\n  repeater->OnTestCaseEnd(*this);\n  impl->set_current_test_case(NULL);\n}\n\n// Clears the results of all tests in this test case.\nvoid TestCase::ClearResult() {\n  ad_hoc_test_result_.Clear();\n  ForEach(test_info_list_, TestInfo::ClearTestResult);\n}\n\n// Shuffles the tests in this test case.\nvoid TestCase::ShuffleTests(internal::Random* random) {\n  Shuffle(random, &test_indices_);\n}\n\n// Restores the test order to before the first shuffle.\nvoid TestCase::UnshuffleTests() {\n  for (size_t i = 0; i < test_indices_.size(); i++) {\n    test_indices_[i] = static_cast<int>(i);\n  }\n}\n\n// Formats a countable noun.  Depending on its quantity, either the\n// singular form or the plural form is used. e.g.\n//\n// FormatCountableNoun(1, \"formula\", \"formuli\") returns \"1 formula\".\n// FormatCountableNoun(5, \"book\", \"books\") returns \"5 books\".\nstatic std::string FormatCountableNoun(int count,\n                                       const char * singular_form,\n                                       const char * plural_form) {\n  return internal::StreamableToString(count) + \" \" +\n      (count == 1 ? singular_form : plural_form);\n}\n\n// Formats the count of tests.\nstatic std::string FormatTestCount(int test_count) {\n  return FormatCountableNoun(test_count, \"test\", \"tests\");\n}\n\n// Formats the count of test cases.\nstatic std::string FormatTestCaseCount(int test_case_count) {\n  return FormatCountableNoun(test_case_count, \"test case\", \"test cases\");\n}\n\n// Converts a TestPartResult::Type enum to human-friendly string\n// representation.  Both kNonFatalFailure and kFatalFailure are translated\n// to \"Failure\", as the user usually doesn't care about the difference\n// between the two when viewing the test result.\nstatic const char * TestPartResultTypeToString(TestPartResult::Type type) {\n  switch (type) {\n    case TestPartResult::kSuccess:\n      return \"Success\";\n\n    case TestPartResult::kNonFatalFailure:\n    case TestPartResult::kFatalFailure:\n#ifdef _MSC_VER\n      return \"error: \";\n#else\n      return \"Failure\\n\";\n#endif\n    default:\n      return \"Unknown result type\";\n  }\n}\n\nnamespace internal {\n\n// Prints a TestPartResult to an std::string.\nstatic std::string PrintTestPartResultToString(\n    const TestPartResult& test_part_result) {\n  return (Message()\n          << internal::FormatFileLocation(test_part_result.file_name(),\n                                          test_part_result.line_number())\n          << \" \" << TestPartResultTypeToString(test_part_result.type())\n          << test_part_result.message()).GetString();\n}\n\n// Prints a TestPartResult.\nstatic void PrintTestPartResult(const TestPartResult& test_part_result) {\n  const std::string& result =\n      PrintTestPartResultToString(test_part_result);\n  printf(\"%s\\n\", result.c_str());\n  fflush(stdout);\n  // If the test program runs in Visual Studio or a debugger, the\n  // following statements add the test part result message to the Output\n  // window such that the user can double-click on it to jump to the\n  // corresponding source code location; otherwise they do nothing.\n#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE\n  // We don't call OutputDebugString*() on Windows Mobile, as printing\n  // to stdout is done by OutputDebugString() there already - we don't\n  // want the same message printed twice.\n  ::OutputDebugStringA(result.c_str());\n  ::OutputDebugStringA(\"\\n\");\n#endif\n}\n\n// class PrettyUnitTestResultPrinter\n\nenum GTestColor {\n  COLOR_DEFAULT,\n  COLOR_RED,\n  COLOR_GREEN,\n  COLOR_YELLOW\n};\n\n#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \\\n    !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT\n\n// Returns the character attribute for the given color.\nWORD GetColorAttribute(GTestColor color) {\n  switch (color) {\n    case COLOR_RED:    return FOREGROUND_RED;\n    case COLOR_GREEN:  return FOREGROUND_GREEN;\n    case COLOR_YELLOW: return FOREGROUND_RED | FOREGROUND_GREEN;\n    default:           return 0;\n  }\n}\n\n#else\n\n// Returns the ANSI color code for the given color.  COLOR_DEFAULT is\n// an invalid input.\nconst char* GetAnsiColorCode(GTestColor color) {\n  switch (color) {\n    case COLOR_RED:     return \"1\";\n    case COLOR_GREEN:   return \"2\";\n    case COLOR_YELLOW:  return \"3\";\n    default:            return NULL;\n  };\n}\n\n#endif  // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE\n\n// Returns true iff Google Test should use colors in the output.\nbool ShouldUseColor(bool stdout_is_tty) {\n  const char* const gtest_color = GTEST_FLAG(color).c_str();\n\n  if (String::CaseInsensitiveCStringEquals(gtest_color, \"auto\")) {\n#if GTEST_OS_WINDOWS\n    // On Windows the TERM variable is usually not set, but the\n    // console there does support colors.\n    return stdout_is_tty;\n#else\n    // On non-Windows platforms, we rely on the TERM variable.\n    const char* const term = posix::GetEnv(\"TERM\");\n    const bool term_supports_color =\n        String::CStringEquals(term, \"xterm\") ||\n        String::CStringEquals(term, \"xterm-color\") ||\n        String::CStringEquals(term, \"xterm-256color\") ||\n        String::CStringEquals(term, \"screen\") ||\n        String::CStringEquals(term, \"screen-256color\") ||\n        String::CStringEquals(term, \"tmux\") ||\n        String::CStringEquals(term, \"tmux-256color\") ||\n        String::CStringEquals(term, \"rxvt-unicode\") ||\n        String::CStringEquals(term, \"rxvt-unicode-256color\") ||\n        String::CStringEquals(term, \"linux\") ||\n        String::CStringEquals(term, \"cygwin\");\n    return stdout_is_tty && term_supports_color;\n#endif  // GTEST_OS_WINDOWS\n  }\n\n  return String::CaseInsensitiveCStringEquals(gtest_color, \"yes\") ||\n      String::CaseInsensitiveCStringEquals(gtest_color, \"true\") ||\n      String::CaseInsensitiveCStringEquals(gtest_color, \"t\") ||\n      String::CStringEquals(gtest_color, \"1\");\n  // We take \"yes\", \"true\", \"t\", and \"1\" as meaning \"yes\".  If the\n  // value is neither one of these nor \"auto\", we treat it as \"no\" to\n  // be conservative.\n}\n\n// Helpers for printing colored strings to stdout. Note that on Windows, we\n// cannot simply emit special characters and have the terminal change colors.\n// This routine must actually emit the characters rather than return a string\n// that would be colored when printed, as can be done on Linux.\nvoid ColoredPrintf(GTestColor color, const char* fmt, ...) {\n  va_list args;\n  va_start(args, fmt);\n\n#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS || \\\n    GTEST_OS_IOS || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT\n  const bool use_color = AlwaysFalse();\n#else\n  static const bool in_color_mode =\n      ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0);\n  const bool use_color = in_color_mode && (color != COLOR_DEFAULT);\n#endif  // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS\n  // The '!= 0' comparison is necessary to satisfy MSVC 7.1.\n\n  if (!use_color) {\n    vprintf(fmt, args);\n    va_end(args);\n    return;\n  }\n\n#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \\\n    !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT\n  const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);\n\n  // Gets the current text color.\n  CONSOLE_SCREEN_BUFFER_INFO buffer_info;\n  GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);\n  const WORD old_color_attrs = buffer_info.wAttributes;\n\n  // We need to flush the stream buffers into the console before each\n  // SetConsoleTextAttribute call lest it affect the text that is already\n  // printed but has not yet reached the console.\n  fflush(stdout);\n  SetConsoleTextAttribute(stdout_handle,\n                          GetColorAttribute(color) | FOREGROUND_INTENSITY);\n  vprintf(fmt, args);\n\n  fflush(stdout);\n  // Restores the text color.\n  SetConsoleTextAttribute(stdout_handle, old_color_attrs);\n#else\n  printf(\"\\033[0;3%sm\", GetAnsiColorCode(color));\n  vprintf(fmt, args);\n  printf(\"\\033[m\");  // Resets the terminal to default.\n#endif  // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE\n  va_end(args);\n}\n\n// Text printed in Google Test's text output and --gunit_list_tests\n// output to label the type parameter and value parameter for a test.\nstatic const char kTypeParamLabel[] = \"TypeParam\";\nstatic const char kValueParamLabel[] = \"GetParam()\";\n\nvoid PrintFullTestCommentIfPresent(const TestInfo& test_info) {\n  const char* const type_param = test_info.type_param();\n  const char* const value_param = test_info.value_param();\n\n  if (type_param != NULL || value_param != NULL) {\n    printf(\", where \");\n    if (type_param != NULL) {\n      printf(\"%s = %s\", kTypeParamLabel, type_param);\n      if (value_param != NULL)\n        printf(\" and \");\n    }\n    if (value_param != NULL) {\n      printf(\"%s = %s\", kValueParamLabel, value_param);\n    }\n  }\n}\n\n// This class implements the TestEventListener interface.\n//\n// Class PrettyUnitTestResultPrinter is copyable.\nclass PrettyUnitTestResultPrinter : public TestEventListener {\n public:\n  PrettyUnitTestResultPrinter() {}\n  static void PrintTestName(const char * test_case, const char * test) {\n    printf(\"%s.%s\", test_case, test);\n  }\n\n  // The following methods override what's in the TestEventListener class.\n  virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}\n  virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration);\n  virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test);\n  virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}\n  virtual void OnTestCaseStart(const TestCase& test_case);\n  virtual void OnTestStart(const TestInfo& test_info);\n  virtual void OnTestPartResult(const TestPartResult& result);\n  virtual void OnTestEnd(const TestInfo& test_info);\n  virtual void OnTestCaseEnd(const TestCase& test_case);\n  virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test);\n  virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}\n  virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);\n  virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}\n\n private:\n  static void PrintFailedTests(const UnitTest& unit_test);\n};\n\n  // Fired before each iteration of tests starts.\nvoid PrettyUnitTestResultPrinter::OnTestIterationStart(\n    const UnitTest& unit_test, int iteration) {\n  if (GTEST_FLAG(repeat) != 1)\n    printf(\"\\nRepeating all tests (iteration %d) . . .\\n\\n\", iteration + 1);\n\n  const char* const filter = GTEST_FLAG(filter).c_str();\n\n  // Prints the filter if it's not *.  This reminds the user that some\n  // tests may be skipped.\n  if (!String::CStringEquals(filter, kUniversalFilter)) {\n    ColoredPrintf(COLOR_YELLOW,\n                  \"Note: %s filter = %s\\n\", GTEST_NAME_, filter);\n  }\n\n  if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {\n    const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);\n    ColoredPrintf(COLOR_YELLOW,\n                  \"Note: This is test shard %d of %s.\\n\",\n                  static_cast<int>(shard_index) + 1,\n                  internal::posix::GetEnv(kTestTotalShards));\n  }\n\n  if (GTEST_FLAG(shuffle)) {\n    ColoredPrintf(COLOR_YELLOW,\n                  \"Note: Randomizing tests' orders with a seed of %d .\\n\",\n                  unit_test.random_seed());\n  }\n\n  ColoredPrintf(COLOR_GREEN,  \"[==========] \");\n  printf(\"Running %s from %s.\\n\",\n         FormatTestCount(unit_test.test_to_run_count()).c_str(),\n         FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str());\n  fflush(stdout);\n}\n\nvoid PrettyUnitTestResultPrinter::OnEnvironmentsSetUpStart(\n    const UnitTest& /*unit_test*/) {\n  ColoredPrintf(COLOR_GREEN,  \"[----------] \");\n  printf(\"Global test environment set-up.\\n\");\n  fflush(stdout);\n}\n\nvoid PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) {\n  const std::string counts =\n      FormatCountableNoun(test_case.test_to_run_count(), \"test\", \"tests\");\n  ColoredPrintf(COLOR_GREEN, \"[----------] \");\n  printf(\"%s from %s\", counts.c_str(), test_case.name());\n  if (test_case.type_param() == NULL) {\n    printf(\"\\n\");\n  } else {\n    printf(\", where %s = %s\\n\", kTypeParamLabel, test_case.type_param());\n  }\n  fflush(stdout);\n}\n\nvoid PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) {\n  ColoredPrintf(COLOR_GREEN,  \"[ RUN      ] \");\n  PrintTestName(test_info.test_case_name(), test_info.name());\n  printf(\"\\n\");\n  fflush(stdout);\n}\n\n// Called after an assertion failure.\nvoid PrettyUnitTestResultPrinter::OnTestPartResult(\n    const TestPartResult& result) {\n  // If the test part succeeded, we don't need to do anything.\n  if (result.type() == TestPartResult::kSuccess)\n    return;\n\n  // Print failure message from the assertion (e.g. expected this and got that).\n  PrintTestPartResult(result);\n  fflush(stdout);\n}\n\nvoid PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) {\n  if (test_info.result()->Passed()) {\n    ColoredPrintf(COLOR_GREEN, \"[       OK ] \");\n  } else {\n    ColoredPrintf(COLOR_RED, \"[  FAILED  ] \");\n  }\n  PrintTestName(test_info.test_case_name(), test_info.name());\n  if (test_info.result()->Failed())\n    PrintFullTestCommentIfPresent(test_info);\n\n  if (GTEST_FLAG(print_time)) {\n    printf(\" (%s ms)\\n\", internal::StreamableToString(\n           test_info.result()->elapsed_time()).c_str());\n  } else {\n    printf(\"\\n\");\n  }\n  fflush(stdout);\n}\n\nvoid PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestCase& test_case) {\n  if (!GTEST_FLAG(print_time)) return;\n\n  const std::string counts =\n      FormatCountableNoun(test_case.test_to_run_count(), \"test\", \"tests\");\n  ColoredPrintf(COLOR_GREEN, \"[----------] \");\n  printf(\"%s from %s (%s ms total)\\n\\n\",\n         counts.c_str(), test_case.name(),\n         internal::StreamableToString(test_case.elapsed_time()).c_str());\n  fflush(stdout);\n}\n\nvoid PrettyUnitTestResultPrinter::OnEnvironmentsTearDownStart(\n    const UnitTest& /*unit_test*/) {\n  ColoredPrintf(COLOR_GREEN,  \"[----------] \");\n  printf(\"Global test environment tear-down\\n\");\n  fflush(stdout);\n}\n\n// Internal helper for printing the list of failed tests.\nvoid PrettyUnitTestResultPrinter::PrintFailedTests(const UnitTest& unit_test) {\n  const int failed_test_count = unit_test.failed_test_count();\n  if (failed_test_count == 0) {\n    return;\n  }\n\n  for (int i = 0; i < unit_test.total_test_case_count(); ++i) {\n    const TestCase& test_case = *unit_test.GetTestCase(i);\n    if (!test_case.should_run() || (test_case.failed_test_count() == 0)) {\n      continue;\n    }\n    for (int j = 0; j < test_case.total_test_count(); ++j) {\n      const TestInfo& test_info = *test_case.GetTestInfo(j);\n      if (!test_info.should_run() || test_info.result()->Passed()) {\n        continue;\n      }\n      ColoredPrintf(COLOR_RED, \"[  FAILED  ] \");\n      printf(\"%s.%s\", test_case.name(), test_info.name());\n      PrintFullTestCommentIfPresent(test_info);\n      printf(\"\\n\");\n    }\n  }\n}\n\nvoid PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,\n                                                     int /*iteration*/) {\n  ColoredPrintf(COLOR_GREEN,  \"[==========] \");\n  printf(\"%s from %s ran.\",\n         FormatTestCount(unit_test.test_to_run_count()).c_str(),\n         FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str());\n  if (GTEST_FLAG(print_time)) {\n    printf(\" (%s ms total)\",\n           internal::StreamableToString(unit_test.elapsed_time()).c_str());\n  }\n  printf(\"\\n\");\n  ColoredPrintf(COLOR_GREEN,  \"[  PASSED  ] \");\n  printf(\"%s.\\n\", FormatTestCount(unit_test.successful_test_count()).c_str());\n\n  int num_failures = unit_test.failed_test_count();\n  if (!unit_test.Passed()) {\n    const int failed_test_count = unit_test.failed_test_count();\n    ColoredPrintf(COLOR_RED,  \"[  FAILED  ] \");\n    printf(\"%s, listed below:\\n\", FormatTestCount(failed_test_count).c_str());\n    PrintFailedTests(unit_test);\n    printf(\"\\n%2d FAILED %s\\n\", num_failures,\n                        num_failures == 1 ? \"TEST\" : \"TESTS\");\n  }\n\n  int num_disabled = unit_test.reportable_disabled_test_count();\n  if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {\n    if (!num_failures) {\n      printf(\"\\n\");  // Add a spacer if no FAILURE banner is displayed.\n    }\n    ColoredPrintf(COLOR_YELLOW,\n                  \"  YOU HAVE %d DISABLED %s\\n\\n\",\n                  num_disabled,\n                  num_disabled == 1 ? \"TEST\" : \"TESTS\");\n  }\n  // Ensure that Google Test output is printed before, e.g., heapchecker output.\n  fflush(stdout);\n}\n\n// End PrettyUnitTestResultPrinter\n\n// class TestEventRepeater\n//\n// This class forwards events to other event listeners.\nclass TestEventRepeater : public TestEventListener {\n public:\n  TestEventRepeater() : forwarding_enabled_(true) {}\n  virtual ~TestEventRepeater();\n  void Append(TestEventListener *listener);\n  TestEventListener* Release(TestEventListener* listener);\n\n  // Controls whether events will be forwarded to listeners_. Set to false\n  // in death test child processes.\n  bool forwarding_enabled() const { return forwarding_enabled_; }\n  void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; }\n\n  virtual void OnTestProgramStart(const UnitTest& unit_test);\n  virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration);\n  virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test);\n  virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test);\n  virtual void OnTestCaseStart(const TestCase& test_case);\n  virtual void OnTestStart(const TestInfo& test_info);\n  virtual void OnTestPartResult(const TestPartResult& result);\n  virtual void OnTestEnd(const TestInfo& test_info);\n  virtual void OnTestCaseEnd(const TestCase& test_case);\n  virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test);\n  virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test);\n  virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);\n  virtual void OnTestProgramEnd(const UnitTest& unit_test);\n\n private:\n  // Controls whether events will be forwarded to listeners_. Set to false\n  // in death test child processes.\n  bool forwarding_enabled_;\n  // The list of listeners that receive events.\n  std::vector<TestEventListener*> listeners_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventRepeater);\n};\n\nTestEventRepeater::~TestEventRepeater() {\n  ForEach(listeners_, Delete<TestEventListener>);\n}\n\nvoid TestEventRepeater::Append(TestEventListener *listener) {\n  listeners_.push_back(listener);\n}\n\n// TODO(vladl@google.com): Factor the search functionality into Vector::Find.\nTestEventListener* TestEventRepeater::Release(TestEventListener *listener) {\n  for (size_t i = 0; i < listeners_.size(); ++i) {\n    if (listeners_[i] == listener) {\n      listeners_.erase(listeners_.begin() + i);\n      return listener;\n    }\n  }\n\n  return NULL;\n}\n\n// Since most methods are very similar, use macros to reduce boilerplate.\n// This defines a member that forwards the call to all listeners.\n#define GTEST_REPEATER_METHOD_(Name, Type) \\\nvoid TestEventRepeater::Name(const Type& parameter) { \\\n  if (forwarding_enabled_) { \\\n    for (size_t i = 0; i < listeners_.size(); i++) { \\\n      listeners_[i]->Name(parameter); \\\n    } \\\n  } \\\n}\n// This defines a member that forwards the call to all listeners in reverse\n// order.\n#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type) \\\nvoid TestEventRepeater::Name(const Type& parameter) { \\\n  if (forwarding_enabled_) { \\\n    for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) { \\\n      listeners_[i]->Name(parameter); \\\n    } \\\n  } \\\n}\n\nGTEST_REPEATER_METHOD_(OnTestProgramStart, UnitTest)\nGTEST_REPEATER_METHOD_(OnEnvironmentsSetUpStart, UnitTest)\nGTEST_REPEATER_METHOD_(OnTestCaseStart, TestCase)\nGTEST_REPEATER_METHOD_(OnTestStart, TestInfo)\nGTEST_REPEATER_METHOD_(OnTestPartResult, TestPartResult)\nGTEST_REPEATER_METHOD_(OnEnvironmentsTearDownStart, UnitTest)\nGTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsSetUpEnd, UnitTest)\nGTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsTearDownEnd, UnitTest)\nGTEST_REVERSE_REPEATER_METHOD_(OnTestEnd, TestInfo)\nGTEST_REVERSE_REPEATER_METHOD_(OnTestCaseEnd, TestCase)\nGTEST_REVERSE_REPEATER_METHOD_(OnTestProgramEnd, UnitTest)\n\n#undef GTEST_REPEATER_METHOD_\n#undef GTEST_REVERSE_REPEATER_METHOD_\n\nvoid TestEventRepeater::OnTestIterationStart(const UnitTest& unit_test,\n                                             int iteration) {\n  if (forwarding_enabled_) {\n    for (size_t i = 0; i < listeners_.size(); i++) {\n      listeners_[i]->OnTestIterationStart(unit_test, iteration);\n    }\n  }\n}\n\nvoid TestEventRepeater::OnTestIterationEnd(const UnitTest& unit_test,\n                                           int iteration) {\n  if (forwarding_enabled_) {\n    for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) {\n      listeners_[i]->OnTestIterationEnd(unit_test, iteration);\n    }\n  }\n}\n\n// End TestEventRepeater\n\n// This class generates an XML output file.\nclass XmlUnitTestResultPrinter : public EmptyTestEventListener {\n public:\n  explicit XmlUnitTestResultPrinter(const char* output_file);\n\n  virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);\n\n private:\n  // Is c a whitespace character that is normalized to a space character\n  // when it appears in an XML attribute value?\n  static bool IsNormalizableWhitespace(char c) {\n    return c == 0x9 || c == 0xA || c == 0xD;\n  }\n\n  // May c appear in a well-formed XML document?\n  static bool IsValidXmlCharacter(char c) {\n    return IsNormalizableWhitespace(c) || c >= 0x20;\n  }\n\n  // Returns an XML-escaped copy of the input string str.  If\n  // is_attribute is true, the text is meant to appear as an attribute\n  // value, and normalizable whitespace is preserved by replacing it\n  // with character references.\n  static std::string EscapeXml(const std::string& str, bool is_attribute);\n\n  // Returns the given string with all characters invalid in XML removed.\n  static std::string RemoveInvalidXmlCharacters(const std::string& str);\n\n  // Convenience wrapper around EscapeXml when str is an attribute value.\n  static std::string EscapeXmlAttribute(const std::string& str) {\n    return EscapeXml(str, true);\n  }\n\n  // Convenience wrapper around EscapeXml when str is not an attribute value.\n  static std::string EscapeXmlText(const char* str) {\n    return EscapeXml(str, false);\n  }\n\n  // Verifies that the given attribute belongs to the given element and\n  // streams the attribute as XML.\n  static void OutputXmlAttribute(std::ostream* stream,\n                                 const std::string& element_name,\n                                 const std::string& name,\n                                 const std::string& value);\n\n  // Streams an XML CDATA section, escaping invalid CDATA sequences as needed.\n  static void OutputXmlCDataSection(::std::ostream* stream, const char* data);\n\n  // Streams an XML representation of a TestInfo object.\n  static void OutputXmlTestInfo(::std::ostream* stream,\n                                const char* test_case_name,\n                                const TestInfo& test_info);\n\n  // Prints an XML representation of a TestCase object\n  static void PrintXmlTestCase(::std::ostream* stream,\n                               const TestCase& test_case);\n\n  // Prints an XML summary of unit_test to output stream out.\n  static void PrintXmlUnitTest(::std::ostream* stream,\n                               const UnitTest& unit_test);\n\n  // Produces a string representing the test properties in a result as space\n  // delimited XML attributes based on the property key=\"value\" pairs.\n  // When the std::string is not empty, it includes a space at the beginning,\n  // to delimit this attribute from prior attributes.\n  static std::string TestPropertiesAsXmlAttributes(const TestResult& result);\n\n  // The output file.\n  const std::string output_file_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(XmlUnitTestResultPrinter);\n};\n\n// Creates a new XmlUnitTestResultPrinter.\nXmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file)\n    : output_file_(output_file) {\n  if (output_file_.c_str() == NULL || output_file_.empty()) {\n    fprintf(stderr, \"XML output file may not be null\\n\");\n    fflush(stderr);\n    exit(EXIT_FAILURE);\n  }\n}\n\n// Called after the unit test ends.\nvoid XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,\n                                                  int /*iteration*/) {\n  FILE* xmlout = NULL;\n  FilePath output_file(output_file_);\n  FilePath output_dir(output_file.RemoveFileName());\n\n  if (output_dir.CreateDirectoriesRecursively()) {\n    xmlout = posix::FOpen(output_file_.c_str(), \"w\");\n  }\n  if (xmlout == NULL) {\n    // TODO(wan): report the reason of the failure.\n    //\n    // We don't do it for now as:\n    //\n    //   1. There is no urgent need for it.\n    //   2. It's a bit involved to make the errno variable thread-safe on\n    //      all three operating systems (Linux, Windows, and Mac OS).\n    //   3. To interpret the meaning of errno in a thread-safe way,\n    //      we need the strerror_r() function, which is not available on\n    //      Windows.\n    fprintf(stderr,\n            \"Unable to open file \\\"%s\\\"\\n\",\n            output_file_.c_str());\n    fflush(stderr);\n    exit(EXIT_FAILURE);\n  }\n  std::stringstream stream;\n  PrintXmlUnitTest(&stream, unit_test);\n  fprintf(xmlout, \"%s\", StringStreamToString(&stream).c_str());\n  fclose(xmlout);\n}\n\n// Returns an XML-escaped copy of the input string str.  If is_attribute\n// is true, the text is meant to appear as an attribute value, and\n// normalizable whitespace is preserved by replacing it with character\n// references.\n//\n// Invalid XML characters in str, if any, are stripped from the output.\n// It is expected that most, if not all, of the text processed by this\n// module will consist of ordinary English text.\n// If this module is ever modified to produce version 1.1 XML output,\n// most invalid characters can be retained using character references.\n// TODO(wan): It might be nice to have a minimally invasive, human-readable\n// escaping scheme for invalid characters, rather than dropping them.\nstd::string XmlUnitTestResultPrinter::EscapeXml(\n    const std::string& str, bool is_attribute) {\n  Message m;\n\n  for (size_t i = 0; i < str.size(); ++i) {\n    const char ch = str[i];\n    switch (ch) {\n      case '<':\n        m << \"&lt;\";\n        break;\n      case '>':\n        m << \"&gt;\";\n        break;\n      case '&':\n        m << \"&amp;\";\n        break;\n      case '\\'':\n        if (is_attribute)\n          m << \"&apos;\";\n        else\n          m << '\\'';\n        break;\n      case '\"':\n        if (is_attribute)\n          m << \"&quot;\";\n        else\n          m << '\"';\n        break;\n      default:\n        if (IsValidXmlCharacter(ch)) {\n          if (is_attribute && IsNormalizableWhitespace(ch))\n            m << \"&#x\" << String::FormatByte(static_cast<unsigned char>(ch))\n              << \";\";\n          else\n            m << ch;\n        }\n        break;\n    }\n  }\n\n  return m.GetString();\n}\n\n// Returns the given string with all characters invalid in XML removed.\n// Currently invalid characters are dropped from the string. An\n// alternative is to replace them with certain characters such as . or ?.\nstd::string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters(\n    const std::string& str) {\n  std::string output;\n  output.reserve(str.size());\n  for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)\n    if (IsValidXmlCharacter(*it))\n      output.push_back(*it);\n\n  return output;\n}\n\n// The following routines generate an XML representation of a UnitTest\n// object.\n//\n// This is how Google Test concepts map to the DTD:\n//\n// <testsuites name=\"AllTests\">        <-- corresponds to a UnitTest object\n//   <testsuite name=\"testcase-name\">  <-- corresponds to a TestCase object\n//     <testcase name=\"test-name\">     <-- corresponds to a TestInfo object\n//       <failure message=\"...\">...</failure>\n//       <failure message=\"...\">...</failure>\n//       <failure message=\"...\">...</failure>\n//                                     <-- individual assertion failures\n//     </testcase>\n//   </testsuite>\n// </testsuites>\n\n// Formats the given time in milliseconds as seconds.\nstd::string FormatTimeInMillisAsSeconds(TimeInMillis ms) {\n  ::std::stringstream ss;\n  ss << (static_cast<double>(ms) * 1e-3);\n  return ss.str();\n}\n\nstatic bool PortableLocaltime(time_t seconds, struct tm* out) {\n#if defined(_MSC_VER)\n  return localtime_s(out, &seconds) == 0;\n#elif defined(__MINGW32__) || defined(__MINGW64__)\n  // MINGW <time.h> provides neither localtime_r nor localtime_s, but uses\n  // Windows' localtime(), which has a thread-local tm buffer.\n  struct tm* tm_ptr = localtime(&seconds);  // NOLINT\n  if (tm_ptr == NULL)\n    return false;\n  *out = *tm_ptr;\n  return true;\n#else\n  return localtime_r(&seconds, out) != NULL;\n#endif\n}\n\n// Converts the given epoch time in milliseconds to a date string in the ISO\n// 8601 format, without the timezone information.\nstd::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms) {\n  struct tm time_struct;\n  if (!PortableLocaltime(static_cast<time_t>(ms / 1000), &time_struct))\n    return \"\";\n  // YYYY-MM-DDThh:mm:ss\n  return StreamableToString(time_struct.tm_year + 1900) + \"-\" +\n      String::FormatIntWidth2(time_struct.tm_mon + 1) + \"-\" +\n      String::FormatIntWidth2(time_struct.tm_mday) + \"T\" +\n      String::FormatIntWidth2(time_struct.tm_hour) + \":\" +\n      String::FormatIntWidth2(time_struct.tm_min) + \":\" +\n      String::FormatIntWidth2(time_struct.tm_sec);\n}\n\n// Streams an XML CDATA section, escaping invalid CDATA sequences as needed.\nvoid XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,\n                                                     const char* data) {\n  const char* segment = data;\n  *stream << \"<![CDATA[\";\n  for (;;) {\n    const char* const next_segment = strstr(segment, \"]]>\");\n    if (next_segment != NULL) {\n      stream->write(\n          segment, static_cast<std::streamsize>(next_segment - segment));\n      *stream << \"]]>]]&gt;<![CDATA[\";\n      segment = next_segment + strlen(\"]]>\");\n    } else {\n      *stream << segment;\n      break;\n    }\n  }\n  *stream << \"]]>\";\n}\n\nvoid XmlUnitTestResultPrinter::OutputXmlAttribute(\n    std::ostream* stream,\n    const std::string& element_name,\n    const std::string& name,\n    const std::string& value) {\n  const std::vector<std::string>& allowed_names =\n      GetReservedAttributesForElement(element_name);\n\n  GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=\n                   allowed_names.end())\n      << \"Attribute \" << name << \" is not allowed for element <\" << element_name\n      << \">.\";\n\n  *stream << \" \" << name << \"=\\\"\" << EscapeXmlAttribute(value) << \"\\\"\";\n}\n\n// Prints an XML representation of a TestInfo object.\n// TODO(wan): There is also value in printing properties with the plain printer.\nvoid XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,\n                                                 const char* test_case_name,\n                                                 const TestInfo& test_info) {\n  const TestResult& result = *test_info.result();\n  const std::string kTestcase = \"testcase\";\n\n  *stream << \"    <testcase\";\n  OutputXmlAttribute(stream, kTestcase, \"name\", test_info.name());\n\n  if (test_info.value_param() != NULL) {\n    OutputXmlAttribute(stream, kTestcase, \"value_param\",\n                       test_info.value_param());\n  }\n  if (test_info.type_param() != NULL) {\n    OutputXmlAttribute(stream, kTestcase, \"type_param\", test_info.type_param());\n  }\n\n  OutputXmlAttribute(stream, kTestcase, \"status\",\n                     test_info.should_run() ? \"run\" : \"notrun\");\n  OutputXmlAttribute(stream, kTestcase, \"time\",\n                     FormatTimeInMillisAsSeconds(result.elapsed_time()));\n  OutputXmlAttribute(stream, kTestcase, \"classname\", test_case_name);\n  *stream << TestPropertiesAsXmlAttributes(result);\n\n  int failures = 0;\n  for (int i = 0; i < result.total_part_count(); ++i) {\n    const TestPartResult& part = result.GetTestPartResult(i);\n    if (part.failed()) {\n      if (++failures == 1) {\n        *stream << \">\\n\";\n      }\n      const string location = internal::FormatCompilerIndependentFileLocation(\n          part.file_name(), part.line_number());\n      const string summary = location + \"\\n\" + part.summary();\n      *stream << \"      <failure message=\\\"\"\n              << EscapeXmlAttribute(summary.c_str())\n              << \"\\\" type=\\\"\\\">\";\n      const string detail = location + \"\\n\" + part.message();\n      OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());\n      *stream << \"</failure>\\n\";\n    }\n  }\n\n  if (failures == 0)\n    *stream << \" />\\n\";\n  else\n    *stream << \"    </testcase>\\n\";\n}\n\n// Prints an XML representation of a TestCase object\nvoid XmlUnitTestResultPrinter::PrintXmlTestCase(std::ostream* stream,\n                                                const TestCase& test_case) {\n  const std::string kTestsuite = \"testsuite\";\n  *stream << \"  <\" << kTestsuite;\n  OutputXmlAttribute(stream, kTestsuite, \"name\", test_case.name());\n  OutputXmlAttribute(stream, kTestsuite, \"tests\",\n                     StreamableToString(test_case.reportable_test_count()));\n  OutputXmlAttribute(stream, kTestsuite, \"failures\",\n                     StreamableToString(test_case.failed_test_count()));\n  OutputXmlAttribute(\n      stream, kTestsuite, \"disabled\",\n      StreamableToString(test_case.reportable_disabled_test_count()));\n  OutputXmlAttribute(stream, kTestsuite, \"errors\", \"0\");\n  OutputXmlAttribute(stream, kTestsuite, \"time\",\n                     FormatTimeInMillisAsSeconds(test_case.elapsed_time()));\n  *stream << TestPropertiesAsXmlAttributes(test_case.ad_hoc_test_result())\n          << \">\\n\";\n\n  for (int i = 0; i < test_case.total_test_count(); ++i) {\n    if (test_case.GetTestInfo(i)->is_reportable())\n      OutputXmlTestInfo(stream, test_case.name(), *test_case.GetTestInfo(i));\n  }\n  *stream << \"  </\" << kTestsuite << \">\\n\";\n}\n\n// Prints an XML summary of unit_test to output stream out.\nvoid XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream,\n                                                const UnitTest& unit_test) {\n  const std::string kTestsuites = \"testsuites\";\n\n  *stream << \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\";\n  *stream << \"<\" << kTestsuites;\n\n  OutputXmlAttribute(stream, kTestsuites, \"tests\",\n                     StreamableToString(unit_test.reportable_test_count()));\n  OutputXmlAttribute(stream, kTestsuites, \"failures\",\n                     StreamableToString(unit_test.failed_test_count()));\n  OutputXmlAttribute(\n      stream, kTestsuites, \"disabled\",\n      StreamableToString(unit_test.reportable_disabled_test_count()));\n  OutputXmlAttribute(stream, kTestsuites, \"errors\", \"0\");\n  OutputXmlAttribute(\n      stream, kTestsuites, \"timestamp\",\n      FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp()));\n  OutputXmlAttribute(stream, kTestsuites, \"time\",\n                     FormatTimeInMillisAsSeconds(unit_test.elapsed_time()));\n\n  if (GTEST_FLAG(shuffle)) {\n    OutputXmlAttribute(stream, kTestsuites, \"random_seed\",\n                       StreamableToString(unit_test.random_seed()));\n  }\n\n  *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result());\n\n  OutputXmlAttribute(stream, kTestsuites, \"name\", \"AllTests\");\n  *stream << \">\\n\";\n\n  for (int i = 0; i < unit_test.total_test_case_count(); ++i) {\n    if (unit_test.GetTestCase(i)->reportable_test_count() > 0)\n      PrintXmlTestCase(stream, *unit_test.GetTestCase(i));\n  }\n  *stream << \"</\" << kTestsuites << \">\\n\";\n}\n\n// Produces a string representing the test properties in a result as space\n// delimited XML attributes based on the property key=\"value\" pairs.\nstd::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(\n    const TestResult& result) {\n  Message attributes;\n  for (int i = 0; i < result.test_property_count(); ++i) {\n    const TestProperty& property = result.GetTestProperty(i);\n    attributes << \" \" << property.key() << \"=\"\n        << \"\\\"\" << EscapeXmlAttribute(property.value()) << \"\\\"\";\n  }\n  return attributes.GetString();\n}\n\n// End XmlUnitTestResultPrinter\n\n#if GTEST_CAN_STREAM_RESULTS_\n\n// Checks if str contains '=', '&', '%' or '\\n' characters. If yes,\n// replaces them by \"%xx\" where xx is their hexadecimal value. For\n// example, replaces \"=\" with \"%3D\".  This algorithm is O(strlen(str))\n// in both time and space -- important as the input str may contain an\n// arbitrarily long test failure message and stack trace.\nstring StreamingListener::UrlEncode(const char* str) {\n  string result;\n  result.reserve(strlen(str) + 1);\n  for (char ch = *str; ch != '\\0'; ch = *++str) {\n    switch (ch) {\n      case '%':\n      case '=':\n      case '&':\n      case '\\n':\n        result.append(\"%\" + String::FormatByte(static_cast<unsigned char>(ch)));\n        break;\n      default:\n        result.push_back(ch);\n        break;\n    }\n  }\n  return result;\n}\n\nvoid StreamingListener::SocketWriter::MakeConnection() {\n  GTEST_CHECK_(sockfd_ == -1)\n      << \"MakeConnection() can't be called when there is already a connection.\";\n\n  addrinfo hints;\n  memset(&hints, 0, sizeof(hints));\n  hints.ai_family = AF_UNSPEC;    // To allow both IPv4 and IPv6 addresses.\n  hints.ai_socktype = SOCK_STREAM;\n  addrinfo* servinfo = NULL;\n\n  // Use the getaddrinfo() to get a linked list of IP addresses for\n  // the given host name.\n  const int error_num = getaddrinfo(\n      host_name_.c_str(), port_num_.c_str(), &hints, &servinfo);\n  if (error_num != 0) {\n    GTEST_LOG_(WARNING) << \"stream_result_to: getaddrinfo() failed: \"\n                        << gai_strerror(error_num);\n  }\n\n  // Loop through all the results and connect to the first we can.\n  for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != NULL;\n       cur_addr = cur_addr->ai_next) {\n    sockfd_ = socket(\n        cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol);\n    if (sockfd_ != -1) {\n      // Connect the client socket to the server socket.\n      if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {\n        close(sockfd_);\n        sockfd_ = -1;\n      }\n    }\n  }\n\n  freeaddrinfo(servinfo);  // all done with this structure\n\n  if (sockfd_ == -1) {\n    GTEST_LOG_(WARNING) << \"stream_result_to: failed to connect to \"\n                        << host_name_ << \":\" << port_num_;\n  }\n}\n\n// End of class Streaming Listener\n#endif  // GTEST_CAN_STREAM_RESULTS__\n\n// Class ScopedTrace\n\n// Pushes the given source file location and message onto a per-thread\n// trace stack maintained by Google Test.\nScopedTrace::ScopedTrace(const char* file, int line, const Message& message)\n    GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {\n  TraceInfo trace;\n  trace.file = file;\n  trace.line = line;\n  trace.message = message.GetString();\n\n  UnitTest::GetInstance()->PushGTestTrace(trace);\n}\n\n// Pops the info pushed by the c'tor.\nScopedTrace::~ScopedTrace()\n    GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {\n  UnitTest::GetInstance()->PopGTestTrace();\n}\n\n\n// class OsStackTraceGetter\n\nconst char* const OsStackTraceGetterInterface::kElidedFramesMarker =\n    \"... \" GTEST_NAME_ \" internal frames ...\";\n\nstring OsStackTraceGetter::CurrentStackTrace(int /*max_depth*/,\n                                             int /*skip_count*/) {\n  return \"\";\n}\n\nvoid OsStackTraceGetter::UponLeavingGTest() {}\n\n// A helper class that creates the premature-exit file in its\n// constructor and deletes the file in its destructor.\nclass ScopedPrematureExitFile {\n public:\n  explicit ScopedPrematureExitFile(const char* premature_exit_filepath)\n      : premature_exit_filepath_(premature_exit_filepath) {\n    // If a path to the premature-exit file is specified...\n    if (premature_exit_filepath != NULL && *premature_exit_filepath != '\\0') {\n      // create the file with a single \"0\" character in it.  I/O\n      // errors are ignored as there's nothing better we can do and we\n      // don't want to fail the test because of this.\n      FILE* pfile = posix::FOpen(premature_exit_filepath, \"w\");\n      fwrite(\"0\", 1, 1, pfile);\n      fclose(pfile);\n    }\n  }\n\n  ~ScopedPrematureExitFile() {\n    if (premature_exit_filepath_ != NULL && *premature_exit_filepath_ != '\\0') {\n      remove(premature_exit_filepath_);\n    }\n  }\n\n private:\n  const char* const premature_exit_filepath_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedPrematureExitFile);\n};\n\n}  // namespace internal\n\n// class TestEventListeners\n\nTestEventListeners::TestEventListeners()\n    : repeater_(new internal::TestEventRepeater()),\n      default_result_printer_(NULL),\n      default_xml_generator_(NULL) {\n}\n\nTestEventListeners::~TestEventListeners() { delete repeater_; }\n\n// Returns the standard listener responsible for the default console\n// output.  Can be removed from the listeners list to shut down default\n// console output.  Note that removing this object from the listener list\n// with Release transfers its ownership to the user.\nvoid TestEventListeners::Append(TestEventListener* listener) {\n  repeater_->Append(listener);\n}\n\n// Removes the given event listener from the list and returns it.  It then\n// becomes the caller's responsibility to delete the listener. Returns\n// NULL if the listener is not found in the list.\nTestEventListener* TestEventListeners::Release(TestEventListener* listener) {\n  if (listener == default_result_printer_)\n    default_result_printer_ = NULL;\n  else if (listener == default_xml_generator_)\n    default_xml_generator_ = NULL;\n  return repeater_->Release(listener);\n}\n\n// Returns repeater that broadcasts the TestEventListener events to all\n// subscribers.\nTestEventListener* TestEventListeners::repeater() { return repeater_; }\n\n// Sets the default_result_printer attribute to the provided listener.\n// The listener is also added to the listener list and previous\n// default_result_printer is removed from it and deleted. The listener can\n// also be NULL in which case it will not be added to the list. Does\n// nothing if the previous and the current listener objects are the same.\nvoid TestEventListeners::SetDefaultResultPrinter(TestEventListener* listener) {\n  if (default_result_printer_ != listener) {\n    // It is an error to pass this method a listener that is already in the\n    // list.\n    delete Release(default_result_printer_);\n    default_result_printer_ = listener;\n    if (listener != NULL)\n      Append(listener);\n  }\n}\n\n// Sets the default_xml_generator attribute to the provided listener.  The\n// listener is also added to the listener list and previous\n// default_xml_generator is removed from it and deleted. The listener can\n// also be NULL in which case it will not be added to the list. Does\n// nothing if the previous and the current listener objects are the same.\nvoid TestEventListeners::SetDefaultXmlGenerator(TestEventListener* listener) {\n  if (default_xml_generator_ != listener) {\n    // It is an error to pass this method a listener that is already in the\n    // list.\n    delete Release(default_xml_generator_);\n    default_xml_generator_ = listener;\n    if (listener != NULL)\n      Append(listener);\n  }\n}\n\n// Controls whether events will be forwarded by the repeater to the\n// listeners in the list.\nbool TestEventListeners::EventForwardingEnabled() const {\n  return repeater_->forwarding_enabled();\n}\n\nvoid TestEventListeners::SuppressEventForwarding() {\n  repeater_->set_forwarding_enabled(false);\n}\n\n// class UnitTest\n\n// Gets the singleton UnitTest object.  The first time this method is\n// called, a UnitTest object is constructed and returned.  Consecutive\n// calls will return the same object.\n//\n// We don't protect this under mutex_ as a user is not supposed to\n// call this before main() starts, from which point on the return\n// value will never change.\nUnitTest* UnitTest::GetInstance() {\n  // When compiled with MSVC 7.1 in optimized mode, destroying the\n  // UnitTest object upon exiting the program messes up the exit code,\n  // causing successful tests to appear failed.  We have to use a\n  // different implementation in this case to bypass the compiler bug.\n  // This implementation makes the compiler happy, at the cost of\n  // leaking the UnitTest object.\n\n  // CodeGear C++Builder insists on a public destructor for the\n  // default implementation.  Use this implementation to keep good OO\n  // design with private destructor.\n\n#if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)\n  static UnitTest* const instance = new UnitTest;\n  return instance;\n#else\n  static UnitTest instance;\n  return &instance;\n#endif  // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)\n}\n\n// Gets the number of successful test cases.\nint UnitTest::successful_test_case_count() const {\n  return impl()->successful_test_case_count();\n}\n\n// Gets the number of failed test cases.\nint UnitTest::failed_test_case_count() const {\n  return impl()->failed_test_case_count();\n}\n\n// Gets the number of all test cases.\nint UnitTest::total_test_case_count() const {\n  return impl()->total_test_case_count();\n}\n\n// Gets the number of all test cases that contain at least one test\n// that should run.\nint UnitTest::test_case_to_run_count() const {\n  return impl()->test_case_to_run_count();\n}\n\n// Gets the number of successful tests.\nint UnitTest::successful_test_count() const {\n  return impl()->successful_test_count();\n}\n\n// Gets the number of failed tests.\nint UnitTest::failed_test_count() const { return impl()->failed_test_count(); }\n\n// Gets the number of disabled tests that will be reported in the XML report.\nint UnitTest::reportable_disabled_test_count() const {\n  return impl()->reportable_disabled_test_count();\n}\n\n// Gets the number of disabled tests.\nint UnitTest::disabled_test_count() const {\n  return impl()->disabled_test_count();\n}\n\n// Gets the number of tests to be printed in the XML report.\nint UnitTest::reportable_test_count() const {\n  return impl()->reportable_test_count();\n}\n\n// Gets the number of all tests.\nint UnitTest::total_test_count() const { return impl()->total_test_count(); }\n\n// Gets the number of tests that should run.\nint UnitTest::test_to_run_count() const { return impl()->test_to_run_count(); }\n\n// Gets the time of the test program start, in ms from the start of the\n// UNIX epoch.\ninternal::TimeInMillis UnitTest::start_timestamp() const {\n    return impl()->start_timestamp();\n}\n\n// Gets the elapsed time, in milliseconds.\ninternal::TimeInMillis UnitTest::elapsed_time() const {\n  return impl()->elapsed_time();\n}\n\n// Returns true iff the unit test passed (i.e. all test cases passed).\nbool UnitTest::Passed() const { return impl()->Passed(); }\n\n// Returns true iff the unit test failed (i.e. some test case failed\n// or something outside of all tests failed).\nbool UnitTest::Failed() const { return impl()->Failed(); }\n\n// Gets the i-th test case among all the test cases. i can range from 0 to\n// total_test_case_count() - 1. If i is not in that range, returns NULL.\nconst TestCase* UnitTest::GetTestCase(int i) const {\n  return impl()->GetTestCase(i);\n}\n\n// Returns the TestResult containing information on test failures and\n// properties logged outside of individual test cases.\nconst TestResult& UnitTest::ad_hoc_test_result() const {\n  return *impl()->ad_hoc_test_result();\n}\n\n// Gets the i-th test case among all the test cases. i can range from 0 to\n// total_test_case_count() - 1. If i is not in that range, returns NULL.\nTestCase* UnitTest::GetMutableTestCase(int i) {\n  return impl()->GetMutableTestCase(i);\n}\n\n// Returns the list of event listeners that can be used to track events\n// inside Google Test.\nTestEventListeners& UnitTest::listeners() {\n  return *impl()->listeners();\n}\n\n// Registers and returns a global test environment.  When a test\n// program is run, all global test environments will be set-up in the\n// order they were registered.  After all tests in the program have\n// finished, all global test environments will be torn-down in the\n// *reverse* order they were registered.\n//\n// The UnitTest object takes ownership of the given environment.\n//\n// We don't protect this under mutex_, as we only support calling it\n// from the main thread.\nEnvironment* UnitTest::AddEnvironment(Environment* env) {\n  if (env == NULL) {\n    return NULL;\n  }\n\n  impl_->environments().push_back(env);\n  return env;\n}\n\n// Adds a TestPartResult to the current TestResult object.  All Google Test\n// assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) eventually call\n// this to report their results.  The user code should use the\n// assertion macros instead of calling this directly.\nvoid UnitTest::AddTestPartResult(\n    TestPartResult::Type result_type,\n    const char* file_name,\n    int line_number,\n    const std::string& message,\n    const std::string& os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_) {\n  Message msg;\n  msg << message;\n\n  internal::MutexLock lock(&mutex_);\n  if (impl_->gtest_trace_stack().size() > 0) {\n    msg << \"\\n\" << GTEST_NAME_ << \" trace:\";\n\n    for (int i = static_cast<int>(impl_->gtest_trace_stack().size());\n         i > 0; --i) {\n      const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1];\n      msg << \"\\n\" << internal::FormatFileLocation(trace.file, trace.line)\n          << \" \" << trace.message;\n    }\n  }\n\n  if (os_stack_trace.c_str() != NULL && !os_stack_trace.empty()) {\n    msg << internal::kStackTraceMarker << os_stack_trace;\n  }\n\n  const TestPartResult result =\n    TestPartResult(result_type, file_name, line_number,\n                   msg.GetString().c_str());\n  impl_->GetTestPartResultReporterForCurrentThread()->\n      ReportTestPartResult(result);\n\n  if (result_type != TestPartResult::kSuccess) {\n    // gtest_break_on_failure takes precedence over\n    // gtest_throw_on_failure.  This allows a user to set the latter\n    // in the code (perhaps in order to use Google Test assertions\n    // with another testing framework) and specify the former on the\n    // command line for debugging.\n    if (GTEST_FLAG(break_on_failure)) {\n#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT\n      // Using DebugBreak on Windows allows gtest to still break into a debugger\n      // when a failure happens and both the --gtest_break_on_failure and\n      // the --gtest_catch_exceptions flags are specified.\n      DebugBreak();\n#else\n      // Dereference NULL through a volatile pointer to prevent the compiler\n      // from removing. We use this rather than abort() or __builtin_trap() for\n      // portability: Symbian doesn't implement abort() well, and some debuggers\n      // don't correctly trap abort().\n      *static_cast<volatile int*>(NULL) = 1;\n#endif  // GTEST_OS_WINDOWS\n    } else if (GTEST_FLAG(throw_on_failure)) {\n#if GTEST_HAS_EXCEPTIONS\n      throw internal::GoogleTestFailureException(result);\n#else\n      // We cannot call abort() as it generates a pop-up in debug mode\n      // that cannot be suppressed in VC 7.1 or below.\n      exit(1);\n#endif\n    }\n  }\n}\n\n// Adds a TestProperty to the current TestResult object when invoked from\n// inside a test, to current TestCase's ad_hoc_test_result_ when invoked\n// from SetUpTestCase or TearDownTestCase, or to the global property set\n// when invoked elsewhere.  If the result already contains a property with\n// the same key, the value will be updated.\nvoid UnitTest::RecordProperty(const std::string& key,\n                              const std::string& value) {\n  impl_->RecordProperty(TestProperty(key, value));\n}\n\n// Runs all tests in this UnitTest object and prints the result.\n// Returns 0 if successful, or 1 otherwise.\n//\n// We don't protect this under mutex_, as we only support calling it\n// from the main thread.\nint UnitTest::Run() {\n  const bool in_death_test_child_process =\n      internal::GTEST_FLAG(internal_run_death_test).length() > 0;\n\n  // Google Test implements this protocol for catching that a test\n  // program exits before returning control to Google Test:\n  //\n  //   1. Upon start, Google Test creates a file whose absolute path\n  //      is specified by the environment variable\n  //      TEST_PREMATURE_EXIT_FILE.\n  //   2. When Google Test has finished its work, it deletes the file.\n  //\n  // This allows a test runner to set TEST_PREMATURE_EXIT_FILE before\n  // running a Google-Test-based test program and check the existence\n  // of the file at the end of the test execution to see if it has\n  // exited prematurely.\n\n  // If we are in the child process of a death test, don't\n  // create/delete the premature exit file, as doing so is unnecessary\n  // and will confuse the parent process.  Otherwise, create/delete\n  // the file upon entering/leaving this function.  If the program\n  // somehow exits before this function has a chance to return, the\n  // premature-exit file will be left undeleted, causing a test runner\n  // that understands the premature-exit-file protocol to report the\n  // test as having failed.\n  const internal::ScopedPrematureExitFile premature_exit_file(\n      in_death_test_child_process ?\n      NULL : internal::posix::GetEnv(\"TEST_PREMATURE_EXIT_FILE\"));\n\n  // Captures the value of GTEST_FLAG(catch_exceptions).  This value will be\n  // used for the duration of the program.\n  impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions));\n\n#if GTEST_HAS_SEH\n  // Either the user wants Google Test to catch exceptions thrown by the\n  // tests or this is executing in the context of death test child\n  // process. In either case the user does not want to see pop-up dialogs\n  // about crashes - they are expected.\n  if (impl()->catch_exceptions() || in_death_test_child_process) {\n# if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT\n    // SetErrorMode doesn't exist on CE.\n    SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |\n                 SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);\n# endif  // !GTEST_OS_WINDOWS_MOBILE\n\n# if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE\n    // Death test children can be terminated with _abort().  On Windows,\n    // _abort() can show a dialog with a warning message.  This forces the\n    // abort message to go to stderr instead.\n    _set_error_mode(_OUT_TO_STDERR);\n# endif\n\n# if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE\n    // In the debug version, Visual Studio pops up a separate dialog\n    // offering a choice to debug the aborted program. We need to suppress\n    // this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement\n    // executed. Google Test will notify the user of any unexpected\n    // failure via stderr.\n    //\n    // VC++ doesn't define _set_abort_behavior() prior to the version 8.0.\n    // Users of prior VC versions shall suffer the agony and pain of\n    // clicking through the countless debug dialogs.\n    // TODO(vladl@google.com): find a way to suppress the abort dialog() in the\n    // debug mode when compiled with VC 7.1 or lower.\n    if (!GTEST_FLAG(break_on_failure))\n      _set_abort_behavior(\n          0x0,                                    // Clear the following flags:\n          _WRITE_ABORT_MSG | _CALL_REPORTFAULT);  // pop-up window, core dump.\n# endif\n  }\n#endif  // GTEST_HAS_SEH\n\n  return internal::HandleExceptionsInMethodIfSupported(\n      impl(),\n      &internal::UnitTestImpl::RunAllTests,\n      \"auxiliary test code (environments or event listeners)\") ? 0 : 1;\n}\n\n// Returns the working directory when the first TEST() or TEST_F() was\n// executed.\nconst char* UnitTest::original_working_dir() const {\n  return impl_->original_working_dir_.c_str();\n}\n\n// Returns the TestCase object for the test that's currently running,\n// or NULL if no test is running.\nconst TestCase* UnitTest::current_test_case() const\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  internal::MutexLock lock(&mutex_);\n  return impl_->current_test_case();\n}\n\n// Returns the TestInfo object for the test that's currently running,\n// or NULL if no test is running.\nconst TestInfo* UnitTest::current_test_info() const\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  internal::MutexLock lock(&mutex_);\n  return impl_->current_test_info();\n}\n\n// Returns the random seed used at the start of the current test run.\nint UnitTest::random_seed() const { return impl_->random_seed(); }\n\n#if GTEST_HAS_PARAM_TEST\n// Returns ParameterizedTestCaseRegistry object used to keep track of\n// value-parameterized tests and instantiate and register them.\ninternal::ParameterizedTestCaseRegistry&\n    UnitTest::parameterized_test_registry()\n        GTEST_LOCK_EXCLUDED_(mutex_) {\n  return impl_->parameterized_test_registry();\n}\n#endif  // GTEST_HAS_PARAM_TEST\n\n// Creates an empty UnitTest.\nUnitTest::UnitTest() {\n  impl_ = new internal::UnitTestImpl(this);\n}\n\n// Destructor of UnitTest.\nUnitTest::~UnitTest() {\n  delete impl_;\n}\n\n// Pushes a trace defined by SCOPED_TRACE() on to the per-thread\n// Google Test trace stack.\nvoid UnitTest::PushGTestTrace(const internal::TraceInfo& trace)\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  internal::MutexLock lock(&mutex_);\n  impl_->gtest_trace_stack().push_back(trace);\n}\n\n// Pops a trace from the per-thread Google Test trace stack.\nvoid UnitTest::PopGTestTrace()\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  internal::MutexLock lock(&mutex_);\n  impl_->gtest_trace_stack().pop_back();\n}\n\nnamespace internal {\n\nUnitTestImpl::UnitTestImpl(UnitTest* parent)\n    : parent_(parent),\n      GTEST_DISABLE_MSC_WARNINGS_PUSH_(4355 /* using this in initializer */)\n      default_global_test_part_result_reporter_(this),\n      default_per_thread_test_part_result_reporter_(this),\n      GTEST_DISABLE_MSC_WARNINGS_POP_()\n      global_test_part_result_repoter_(\n          &default_global_test_part_result_reporter_),\n      per_thread_test_part_result_reporter_(\n          &default_per_thread_test_part_result_reporter_),\n#if GTEST_HAS_PARAM_TEST\n      parameterized_test_registry_(),\n      parameterized_tests_registered_(false),\n#endif  // GTEST_HAS_PARAM_TEST\n      last_death_test_case_(-1),\n      current_test_case_(NULL),\n      current_test_info_(NULL),\n      ad_hoc_test_result_(),\n      os_stack_trace_getter_(NULL),\n      post_flag_parse_init_performed_(false),\n      random_seed_(0),  // Will be overridden by the flag before first use.\n      random_(0),  // Will be reseeded before first use.\n      start_timestamp_(0),\n      elapsed_time_(0),\n#if GTEST_HAS_DEATH_TEST\n      death_test_factory_(new DefaultDeathTestFactory),\n#endif\n      // Will be overridden by the flag before first use.\n      catch_exceptions_(false) {\n  listeners()->SetDefaultResultPrinter(new PrettyUnitTestResultPrinter);\n}\n\nUnitTestImpl::~UnitTestImpl() {\n  // Deletes every TestCase.\n  ForEach(test_cases_, internal::Delete<TestCase>);\n\n  // Deletes every Environment.\n  ForEach(environments_, internal::Delete<Environment>);\n\n  delete os_stack_trace_getter_;\n}\n\n// Adds a TestProperty to the current TestResult object when invoked in a\n// context of a test, to current test case's ad_hoc_test_result when invoke\n// from SetUpTestCase/TearDownTestCase, or to the global property set\n// otherwise.  If the result already contains a property with the same key,\n// the value will be updated.\nvoid UnitTestImpl::RecordProperty(const TestProperty& test_property) {\n  std::string xml_element;\n  TestResult* test_result;  // TestResult appropriate for property recording.\n\n  if (current_test_info_ != NULL) {\n    xml_element = \"testcase\";\n    test_result = &(current_test_info_->result_);\n  } else if (current_test_case_ != NULL) {\n    xml_element = \"testsuite\";\n    test_result = &(current_test_case_->ad_hoc_test_result_);\n  } else {\n    xml_element = \"testsuites\";\n    test_result = &ad_hoc_test_result_;\n  }\n  test_result->RecordProperty(xml_element, test_property);\n}\n\n#if GTEST_HAS_DEATH_TEST\n// Disables event forwarding if the control is currently in a death test\n// subprocess. Must not be called before InitGoogleTest.\nvoid UnitTestImpl::SuppressTestEventsIfInSubprocess() {\n  if (internal_run_death_test_flag_.get() != NULL)\n    listeners()->SuppressEventForwarding();\n}\n#endif  // GTEST_HAS_DEATH_TEST\n\n// Initializes event listeners performing XML output as specified by\n// UnitTestOptions. Must not be called before InitGoogleTest.\nvoid UnitTestImpl::ConfigureXmlOutput() {\n  const std::string& output_format = UnitTestOptions::GetOutputFormat();\n  if (output_format == \"xml\") {\n    listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(\n        UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));\n  } else if (output_format != \"\") {\n    printf(\"WARNING: unrecognized output format \\\"%s\\\" ignored.\\n\",\n           output_format.c_str());\n    fflush(stdout);\n  }\n}\n\n#if GTEST_CAN_STREAM_RESULTS_\n// Initializes event listeners for streaming test results in string form.\n// Must not be called before InitGoogleTest.\nvoid UnitTestImpl::ConfigureStreamingOutput() {\n  const std::string& target = GTEST_FLAG(stream_result_to);\n  if (!target.empty()) {\n    const size_t pos = target.find(':');\n    if (pos != std::string::npos) {\n      listeners()->Append(new StreamingListener(target.substr(0, pos),\n                                                target.substr(pos+1)));\n    } else {\n      printf(\"WARNING: unrecognized streaming target \\\"%s\\\" ignored.\\n\",\n             target.c_str());\n      fflush(stdout);\n    }\n  }\n}\n#endif  // GTEST_CAN_STREAM_RESULTS_\n\n// Performs initialization dependent upon flag values obtained in\n// ParseGoogleTestFlagsOnly.  Is called from InitGoogleTest after the call to\n// ParseGoogleTestFlagsOnly.  In case a user neglects to call InitGoogleTest\n// this function is also called from RunAllTests.  Since this function can be\n// called more than once, it has to be idempotent.\nvoid UnitTestImpl::PostFlagParsingInit() {\n  // Ensures that this function does not execute more than once.\n  if (!post_flag_parse_init_performed_) {\n    post_flag_parse_init_performed_ = true;\n\n#if defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)\n    // Register to send notifications about key process state changes.\n    listeners()->Append(new GTEST_CUSTOM_TEST_EVENT_LISTENER_());\n#endif  // defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)\n\n#if GTEST_HAS_DEATH_TEST\n    InitDeathTestSubprocessControlInfo();\n    SuppressTestEventsIfInSubprocess();\n#endif  // GTEST_HAS_DEATH_TEST\n\n    // Registers parameterized tests. This makes parameterized tests\n    // available to the UnitTest reflection API without running\n    // RUN_ALL_TESTS.\n    RegisterParameterizedTests();\n\n    // Configures listeners for XML output. This makes it possible for users\n    // to shut down the default XML output before invoking RUN_ALL_TESTS.\n    ConfigureXmlOutput();\n\n#if GTEST_CAN_STREAM_RESULTS_\n    // Configures listeners for streaming test results to the specified server.\n    ConfigureStreamingOutput();\n#endif  // GTEST_CAN_STREAM_RESULTS_\n  }\n}\n\n// A predicate that checks the name of a TestCase against a known\n// value.\n//\n// This is used for implementation of the UnitTest class only.  We put\n// it in the anonymous namespace to prevent polluting the outer\n// namespace.\n//\n// TestCaseNameIs is copyable.\nclass TestCaseNameIs {\n public:\n  // Constructor.\n  explicit TestCaseNameIs(const std::string& name)\n      : name_(name) {}\n\n  // Returns true iff the name of test_case matches name_.\n  bool operator()(const TestCase* test_case) const {\n    return test_case != NULL && strcmp(test_case->name(), name_.c_str()) == 0;\n  }\n\n private:\n  std::string name_;\n};\n\n// Finds and returns a TestCase with the given name.  If one doesn't\n// exist, creates one and returns it.  It's the CALLER'S\n// RESPONSIBILITY to ensure that this function is only called WHEN THE\n// TESTS ARE NOT SHUFFLED.\n//\n// Arguments:\n//\n//   test_case_name: name of the test case\n//   type_param:     the name of the test case's type parameter, or NULL if\n//                   this is not a typed or a type-parameterized test case.\n//   set_up_tc:      pointer to the function that sets up the test case\n//   tear_down_tc:   pointer to the function that tears down the test case\nTestCase* UnitTestImpl::GetTestCase(const char* test_case_name,\n                                    const char* type_param,\n                                    Test::SetUpTestCaseFunc set_up_tc,\n                                    Test::TearDownTestCaseFunc tear_down_tc) {\n  // Can we find a TestCase with the given name?\n  const std::vector<TestCase*>::const_iterator test_case =\n      std::find_if(test_cases_.begin(), test_cases_.end(),\n                   TestCaseNameIs(test_case_name));\n\n  if (test_case != test_cases_.end())\n    return *test_case;\n\n  // No.  Let's create one.\n  TestCase* const new_test_case =\n      new TestCase(test_case_name, type_param, set_up_tc, tear_down_tc);\n\n  // Is this a death test case?\n  if (internal::UnitTestOptions::MatchesFilter(test_case_name,\n                                               kDeathTestCaseFilter)) {\n    // Yes.  Inserts the test case after the last death test case\n    // defined so far.  This only works when the test cases haven't\n    // been shuffled.  Otherwise we may end up running a death test\n    // after a non-death test.\n    ++last_death_test_case_;\n    test_cases_.insert(test_cases_.begin() + last_death_test_case_,\n                       new_test_case);\n  } else {\n    // No.  Appends to the end of the list.\n    test_cases_.push_back(new_test_case);\n  }\n\n  test_case_indices_.push_back(static_cast<int>(test_case_indices_.size()));\n  return new_test_case;\n}\n\n// Helpers for setting up / tearing down the given environment.  They\n// are for use in the ForEach() function.\nstatic void SetUpEnvironment(Environment* env) { env->SetUp(); }\nstatic void TearDownEnvironment(Environment* env) { env->TearDown(); }\n\n// Runs all tests in this UnitTest object, prints the result, and\n// returns true if all tests are successful.  If any exception is\n// thrown during a test, the test is considered to be failed, but the\n// rest of the tests will still be run.\n//\n// When parameterized tests are enabled, it expands and registers\n// parameterized tests first in RegisterParameterizedTests().\n// All other functions called from RunAllTests() may safely assume that\n// parameterized tests are ready to be counted and run.\nbool UnitTestImpl::RunAllTests() {\n  // Makes sure InitGoogleTest() was called.\n  if (!GTestIsInitialized()) {\n    printf(\"%s\",\n           \"\\nThis test program did NOT call ::testing::InitGoogleTest \"\n           \"before calling RUN_ALL_TESTS().  Please fix it.\\n\");\n    return false;\n  }\n\n  // Do not run any test if the --help flag was specified.\n  if (g_help_flag)\n    return true;\n\n  // Repeats the call to the post-flag parsing initialization in case the\n  // user didn't call InitGoogleTest.\n  PostFlagParsingInit();\n\n  // Even if sharding is not on, test runners may want to use the\n  // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding\n  // protocol.\n  internal::WriteToShardStatusFileIfNeeded();\n\n  // True iff we are in a subprocess for running a thread-safe-style\n  // death test.\n  bool in_subprocess_for_death_test = false;\n\n#if GTEST_HAS_DEATH_TEST\n  in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL);\n# if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)\n  if (in_subprocess_for_death_test) {\n    GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_();\n  }\n# endif  // defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)\n#endif  // GTEST_HAS_DEATH_TEST\n\n  const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex,\n                                        in_subprocess_for_death_test);\n\n  // Compares the full test names with the filter to decide which\n  // tests to run.\n  const bool has_tests_to_run = FilterTests(should_shard\n                                              ? HONOR_SHARDING_PROTOCOL\n                                              : IGNORE_SHARDING_PROTOCOL) > 0;\n\n  // Lists the tests and exits if the --gtest_list_tests flag was specified.\n  if (GTEST_FLAG(list_tests)) {\n    // This must be called *after* FilterTests() has been called.\n    ListTestsMatchingFilter();\n    return true;\n  }\n\n  random_seed_ = GTEST_FLAG(shuffle) ?\n      GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0;\n\n  // True iff at least one test has failed.\n  bool failed = false;\n\n  TestEventListener* repeater = listeners()->repeater();\n\n  start_timestamp_ = GetTimeInMillis();\n  repeater->OnTestProgramStart(*parent_);\n\n  // How many times to repeat the tests?  We don't want to repeat them\n  // when we are inside the subprocess of a death test.\n  const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat);\n  // Repeats forever if the repeat count is negative.\n  const bool forever = repeat < 0;\n  for (int i = 0; forever || i != repeat; i++) {\n    // We want to preserve failures generated by ad-hoc test\n    // assertions executed before RUN_ALL_TESTS().\n    ClearNonAdHocTestResult();\n\n    const TimeInMillis start = GetTimeInMillis();\n\n    // Shuffles test cases and tests if requested.\n    if (has_tests_to_run && GTEST_FLAG(shuffle)) {\n      random()->Reseed(random_seed_);\n      // This should be done before calling OnTestIterationStart(),\n      // such that a test event listener can see the actual test order\n      // in the event.\n      ShuffleTests();\n    }\n\n    // Tells the unit test event listeners that the tests are about to start.\n    repeater->OnTestIterationStart(*parent_, i);\n\n    // Runs each test case if there is at least one test to run.\n    if (has_tests_to_run) {\n      // Sets up all environments beforehand.\n      repeater->OnEnvironmentsSetUpStart(*parent_);\n      ForEach(environments_, SetUpEnvironment);\n      repeater->OnEnvironmentsSetUpEnd(*parent_);\n\n      // Runs the tests only if there was no fatal failure during global\n      // set-up.\n      if (!Test::HasFatalFailure()) {\n        for (int test_index = 0; test_index < total_test_case_count();\n             test_index++) {\n          GetMutableTestCase(test_index)->Run();\n        }\n      }\n\n      // Tears down all environments in reverse order afterwards.\n      repeater->OnEnvironmentsTearDownStart(*parent_);\n      std::for_each(environments_.rbegin(), environments_.rend(),\n                    TearDownEnvironment);\n      repeater->OnEnvironmentsTearDownEnd(*parent_);\n    }\n\n    elapsed_time_ = GetTimeInMillis() - start;\n\n    // Tells the unit test event listener that the tests have just finished.\n    repeater->OnTestIterationEnd(*parent_, i);\n\n    // Gets the result and clears it.\n    if (!Passed()) {\n      failed = true;\n    }\n\n    // Restores the original test order after the iteration.  This\n    // allows the user to quickly repro a failure that happens in the\n    // N-th iteration without repeating the first (N - 1) iterations.\n    // This is not enclosed in \"if (GTEST_FLAG(shuffle)) { ... }\", in\n    // case the user somehow changes the value of the flag somewhere\n    // (it's always safe to unshuffle the tests).\n    UnshuffleTests();\n\n    if (GTEST_FLAG(shuffle)) {\n      // Picks a new random seed for each iteration.\n      random_seed_ = GetNextRandomSeed(random_seed_);\n    }\n  }\n\n  repeater->OnTestProgramEnd(*parent_);\n\n  return !failed;\n}\n\n// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file\n// if the variable is present. If a file already exists at this location, this\n// function will write over it. If the variable is present, but the file cannot\n// be created, prints an error and exits.\nvoid WriteToShardStatusFileIfNeeded() {\n  const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile);\n  if (test_shard_file != NULL) {\n    FILE* const file = posix::FOpen(test_shard_file, \"w\");\n    if (file == NULL) {\n      ColoredPrintf(COLOR_RED,\n                    \"Could not write to the test shard status file \\\"%s\\\" \"\n                    \"specified by the %s environment variable.\\n\",\n                    test_shard_file, kTestShardStatusFile);\n      fflush(stdout);\n      exit(EXIT_FAILURE);\n    }\n    fclose(file);\n  }\n}\n\n// Checks whether sharding is enabled by examining the relevant\n// environment variable values. If the variables are present,\n// but inconsistent (i.e., shard_index >= total_shards), prints\n// an error and exits. If in_subprocess_for_death_test, sharding is\n// disabled because it must only be applied to the original test\n// process. Otherwise, we could filter out death tests we intended to execute.\nbool ShouldShard(const char* total_shards_env,\n                 const char* shard_index_env,\n                 bool in_subprocess_for_death_test) {\n  if (in_subprocess_for_death_test) {\n    return false;\n  }\n\n  const Int32 total_shards = Int32FromEnvOrDie(total_shards_env, -1);\n  const Int32 shard_index = Int32FromEnvOrDie(shard_index_env, -1);\n\n  if (total_shards == -1 && shard_index == -1) {\n    return false;\n  } else if (total_shards == -1 && shard_index != -1) {\n    const Message msg = Message()\n      << \"Invalid environment variables: you have \"\n      << kTestShardIndex << \" = \" << shard_index\n      << \", but have left \" << kTestTotalShards << \" unset.\\n\";\n    ColoredPrintf(COLOR_RED, msg.GetString().c_str());\n    fflush(stdout);\n    exit(EXIT_FAILURE);\n  } else if (total_shards != -1 && shard_index == -1) {\n    const Message msg = Message()\n      << \"Invalid environment variables: you have \"\n      << kTestTotalShards << \" = \" << total_shards\n      << \", but have left \" << kTestShardIndex << \" unset.\\n\";\n    ColoredPrintf(COLOR_RED, msg.GetString().c_str());\n    fflush(stdout);\n    exit(EXIT_FAILURE);\n  } else if (shard_index < 0 || shard_index >= total_shards) {\n    const Message msg = Message()\n      << \"Invalid environment variables: we require 0 <= \"\n      << kTestShardIndex << \" < \" << kTestTotalShards\n      << \", but you have \" << kTestShardIndex << \"=\" << shard_index\n      << \", \" << kTestTotalShards << \"=\" << total_shards << \".\\n\";\n    ColoredPrintf(COLOR_RED, msg.GetString().c_str());\n    fflush(stdout);\n    exit(EXIT_FAILURE);\n  }\n\n  return total_shards > 1;\n}\n\n// Parses the environment variable var as an Int32. If it is unset,\n// returns default_val. If it is not an Int32, prints an error\n// and aborts.\nInt32 Int32FromEnvOrDie(const char* var, Int32 default_val) {\n  const char* str_val = posix::GetEnv(var);\n  if (str_val == NULL) {\n    return default_val;\n  }\n\n  Int32 result;\n  if (!ParseInt32(Message() << \"The value of environment variable \" << var,\n                  str_val, &result)) {\n    exit(EXIT_FAILURE);\n  }\n  return result;\n}\n\n// Given the total number of shards, the shard index, and the test id,\n// returns true iff the test should be run on this shard. The test id is\n// some arbitrary but unique non-negative integer assigned to each test\n// method. Assumes that 0 <= shard_index < total_shards.\nbool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) {\n  return (test_id % total_shards) == shard_index;\n}\n\n// Compares the name of each test with the user-specified filter to\n// decide whether the test should be run, then records the result in\n// each TestCase and TestInfo object.\n// If shard_tests == true, further filters tests based on sharding\n// variables in the environment - see\n// http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide.\n// Returns the number of tests that should run.\nint UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {\n  const Int32 total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ?\n      Int32FromEnvOrDie(kTestTotalShards, -1) : -1;\n  const Int32 shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ?\n      Int32FromEnvOrDie(kTestShardIndex, -1) : -1;\n\n  // num_runnable_tests are the number of tests that will\n  // run across all shards (i.e., match filter and are not disabled).\n  // num_selected_tests are the number of tests to be run on\n  // this shard.\n  int num_runnable_tests = 0;\n  int num_selected_tests = 0;\n  for (size_t i = 0; i < test_cases_.size(); i++) {\n    TestCase* const test_case = test_cases_[i];\n    const std::string &test_case_name = test_case->name();\n    test_case->set_should_run(false);\n\n    for (size_t j = 0; j < test_case->test_info_list().size(); j++) {\n      TestInfo* const test_info = test_case->test_info_list()[j];\n      const std::string test_name(test_info->name());\n      // A test is disabled if test case name or test name matches\n      // kDisableTestFilter.\n      const bool is_disabled =\n          internal::UnitTestOptions::MatchesFilter(test_case_name,\n                                                   kDisableTestFilter) ||\n          internal::UnitTestOptions::MatchesFilter(test_name,\n                                                   kDisableTestFilter);\n      test_info->is_disabled_ = is_disabled;\n\n      const bool matches_filter =\n          internal::UnitTestOptions::FilterMatchesTest(test_case_name,\n                                                       test_name);\n      test_info->matches_filter_ = matches_filter;\n\n      const bool is_runnable =\n          (GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&\n          matches_filter;\n\n      const bool is_selected = is_runnable &&\n          (shard_tests == IGNORE_SHARDING_PROTOCOL ||\n           ShouldRunTestOnShard(total_shards, shard_index,\n                                num_runnable_tests));\n\n      num_runnable_tests += is_runnable;\n      num_selected_tests += is_selected;\n\n      test_info->should_run_ = is_selected;\n      test_case->set_should_run(test_case->should_run() || is_selected);\n    }\n  }\n  return num_selected_tests;\n}\n\n// Prints the given C-string on a single line by replacing all '\\n'\n// characters with string \"\\\\n\".  If the output takes more than\n// max_length characters, only prints the first max_length characters\n// and \"...\".\nstatic void PrintOnOneLine(const char* str, int max_length) {\n  if (str != NULL) {\n    for (int i = 0; *str != '\\0'; ++str) {\n      if (i >= max_length) {\n        printf(\"...\");\n        break;\n      }\n      if (*str == '\\n') {\n        printf(\"\\\\n\");\n        i += 2;\n      } else {\n        printf(\"%c\", *str);\n        ++i;\n      }\n    }\n  }\n}\n\n// Prints the names of the tests matching the user-specified filter flag.\nvoid UnitTestImpl::ListTestsMatchingFilter() {\n  // Print at most this many characters for each type/value parameter.\n  const int kMaxParamLength = 250;\n\n  for (size_t i = 0; i < test_cases_.size(); i++) {\n    const TestCase* const test_case = test_cases_[i];\n    bool printed_test_case_name = false;\n\n    for (size_t j = 0; j < test_case->test_info_list().size(); j++) {\n      const TestInfo* const test_info =\n          test_case->test_info_list()[j];\n      if (test_info->matches_filter_) {\n        if (!printed_test_case_name) {\n          printed_test_case_name = true;\n          printf(\"%s.\", test_case->name());\n          if (test_case->type_param() != NULL) {\n            printf(\"  # %s = \", kTypeParamLabel);\n            // We print the type parameter on a single line to make\n            // the output easy to parse by a program.\n            PrintOnOneLine(test_case->type_param(), kMaxParamLength);\n          }\n          printf(\"\\n\");\n        }\n        printf(\"  %s\", test_info->name());\n        if (test_info->value_param() != NULL) {\n          printf(\"  # %s = \", kValueParamLabel);\n          // We print the value parameter on a single line to make the\n          // output easy to parse by a program.\n          PrintOnOneLine(test_info->value_param(), kMaxParamLength);\n        }\n        printf(\"\\n\");\n      }\n    }\n  }\n  fflush(stdout);\n}\n\n// Sets the OS stack trace getter.\n//\n// Does nothing if the input and the current OS stack trace getter are\n// the same; otherwise, deletes the old getter and makes the input the\n// current getter.\nvoid UnitTestImpl::set_os_stack_trace_getter(\n    OsStackTraceGetterInterface* getter) {\n  if (os_stack_trace_getter_ != getter) {\n    delete os_stack_trace_getter_;\n    os_stack_trace_getter_ = getter;\n  }\n}\n\n// Returns the current OS stack trace getter if it is not NULL;\n// otherwise, creates an OsStackTraceGetter, makes it the current\n// getter, and returns it.\nOsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() {\n  if (os_stack_trace_getter_ == NULL) {\n#ifdef GTEST_OS_STACK_TRACE_GETTER_\n    os_stack_trace_getter_ = new GTEST_OS_STACK_TRACE_GETTER_;\n#else\n    os_stack_trace_getter_ = new OsStackTraceGetter;\n#endif  // GTEST_OS_STACK_TRACE_GETTER_\n  }\n\n  return os_stack_trace_getter_;\n}\n\n// Returns the TestResult for the test that's currently running, or\n// the TestResult for the ad hoc test if no test is running.\nTestResult* UnitTestImpl::current_test_result() {\n  return current_test_info_ ?\n      &(current_test_info_->result_) : &ad_hoc_test_result_;\n}\n\n// Shuffles all test cases, and the tests within each test case,\n// making sure that death tests are still run first.\nvoid UnitTestImpl::ShuffleTests() {\n  // Shuffles the death test cases.\n  ShuffleRange(random(), 0, last_death_test_case_ + 1, &test_case_indices_);\n\n  // Shuffles the non-death test cases.\n  ShuffleRange(random(), last_death_test_case_ + 1,\n               static_cast<int>(test_cases_.size()), &test_case_indices_);\n\n  // Shuffles the tests inside each test case.\n  for (size_t i = 0; i < test_cases_.size(); i++) {\n    test_cases_[i]->ShuffleTests(random());\n  }\n}\n\n// Restores the test cases and tests to their order before the first shuffle.\nvoid UnitTestImpl::UnshuffleTests() {\n  for (size_t i = 0; i < test_cases_.size(); i++) {\n    // Unshuffles the tests in each test case.\n    test_cases_[i]->UnshuffleTests();\n    // Resets the index of each test case.\n    test_case_indices_[i] = static_cast<int>(i);\n  }\n}\n\n// Returns the current OS stack trace as an std::string.\n//\n// The maximum number of stack frames to be included is specified by\n// the gtest_stack_trace_depth flag.  The skip_count parameter\n// specifies the number of top frames to be skipped, which doesn't\n// count against the number of frames to be included.\n//\n// For example, if Foo() calls Bar(), which in turn calls\n// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in\n// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.\nstd::string GetCurrentOsStackTraceExceptTop(UnitTest* /*unit_test*/,\n                                            int skip_count) {\n  // We pass skip_count + 1 to skip this wrapper function in addition\n  // to what the user really wants to skip.\n  return GetUnitTestImpl()->CurrentOsStackTraceExceptTop(skip_count + 1);\n}\n\n// Used by the GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_ macro to\n// suppress unreachable code warnings.\nnamespace {\nclass ClassUniqueToAlwaysTrue {};\n}\n\nbool IsTrue(bool condition) { return condition; }\n\nbool AlwaysTrue() {\n#if GTEST_HAS_EXCEPTIONS\n  // This condition is always false so AlwaysTrue() never actually throws,\n  // but it makes the compiler think that it may throw.\n  if (IsTrue(false))\n    throw ClassUniqueToAlwaysTrue();\n#endif  // GTEST_HAS_EXCEPTIONS\n  return true;\n}\n\n// If *pstr starts with the given prefix, modifies *pstr to be right\n// past the prefix and returns true; otherwise leaves *pstr unchanged\n// and returns false.  None of pstr, *pstr, and prefix can be NULL.\nbool SkipPrefix(const char* prefix, const char** pstr) {\n  const size_t prefix_len = strlen(prefix);\n  if (strncmp(*pstr, prefix, prefix_len) == 0) {\n    *pstr += prefix_len;\n    return true;\n  }\n  return false;\n}\n\n// Parses a string as a command line flag.  The string should have\n// the format \"--flag=value\".  When def_optional is true, the \"=value\"\n// part can be omitted.\n//\n// Returns the value of the flag, or NULL if the parsing failed.\nconst char* ParseFlagValue(const char* str,\n                           const char* flag,\n                           bool def_optional) {\n  // str and flag must not be NULL.\n  if (str == NULL || flag == NULL) return NULL;\n\n  // The flag must start with \"--\" followed by GTEST_FLAG_PREFIX_.\n  const std::string flag_str = std::string(\"--\") + GTEST_FLAG_PREFIX_ + flag;\n  const size_t flag_len = flag_str.length();\n  if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL;\n\n  // Skips the flag name.\n  const char* flag_end = str + flag_len;\n\n  // When def_optional is true, it's OK to not have a \"=value\" part.\n  if (def_optional && (flag_end[0] == '\\0')) {\n    return flag_end;\n  }\n\n  // If def_optional is true and there are more characters after the\n  // flag name, or if def_optional is false, there must be a '=' after\n  // the flag name.\n  if (flag_end[0] != '=') return NULL;\n\n  // Returns the string after \"=\".\n  return flag_end + 1;\n}\n\n// Parses a string for a bool flag, in the form of either\n// \"--flag=value\" or \"--flag\".\n//\n// In the former case, the value is taken as true as long as it does\n// not start with '0', 'f', or 'F'.\n//\n// In the latter case, the value is taken as true.\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\nbool ParseBoolFlag(const char* str, const char* flag, bool* value) {\n  // Gets the value of the flag as a string.\n  const char* const value_str = ParseFlagValue(str, flag, true);\n\n  // Aborts if the parsing failed.\n  if (value_str == NULL) return false;\n\n  // Converts the string value to a bool.\n  *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');\n  return true;\n}\n\n// Parses a string for an Int32 flag, in the form of\n// \"--flag=value\".\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\nbool ParseInt32Flag(const char* str, const char* flag, Int32* value) {\n  // Gets the value of the flag as a string.\n  const char* const value_str = ParseFlagValue(str, flag, false);\n\n  // Aborts if the parsing failed.\n  if (value_str == NULL) return false;\n\n  // Sets *value to the value of the flag.\n  return ParseInt32(Message() << \"The value of flag --\" << flag,\n                    value_str, value);\n}\n\n// Parses a string for a string flag, in the form of\n// \"--flag=value\".\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\nbool ParseStringFlag(const char* str, const char* flag, std::string* value) {\n  // Gets the value of the flag as a string.\n  const char* const value_str = ParseFlagValue(str, flag, false);\n\n  // Aborts if the parsing failed.\n  if (value_str == NULL) return false;\n\n  // Sets *value to the value of the flag.\n  *value = value_str;\n  return true;\n}\n\n// Determines whether a string has a prefix that Google Test uses for its\n// flags, i.e., starts with GTEST_FLAG_PREFIX_ or GTEST_FLAG_PREFIX_DASH_.\n// If Google Test detects that a command line flag has its prefix but is not\n// recognized, it will print its help message. Flags starting with\n// GTEST_INTERNAL_PREFIX_ followed by \"internal_\" are considered Google Test\n// internal flags and do not trigger the help message.\nstatic bool HasGoogleTestFlagPrefix(const char* str) {\n  return (SkipPrefix(\"--\", &str) ||\n          SkipPrefix(\"-\", &str) ||\n          SkipPrefix(\"/\", &str)) &&\n         !SkipPrefix(GTEST_FLAG_PREFIX_ \"internal_\", &str) &&\n         (SkipPrefix(GTEST_FLAG_PREFIX_, &str) ||\n          SkipPrefix(GTEST_FLAG_PREFIX_DASH_, &str));\n}\n\n// Prints a string containing code-encoded text.  The following escape\n// sequences can be used in the string to control the text color:\n//\n//   @@    prints a single '@' character.\n//   @R    changes the color to red.\n//   @G    changes the color to green.\n//   @Y    changes the color to yellow.\n//   @D    changes to the default terminal text color.\n//\n// TODO(wan@google.com): Write tests for this once we add stdout\n// capturing to Google Test.\nstatic void PrintColorEncoded(const char* str) {\n  GTestColor color = COLOR_DEFAULT;  // The current color.\n\n  // Conceptually, we split the string into segments divided by escape\n  // sequences.  Then we print one segment at a time.  At the end of\n  // each iteration, the str pointer advances to the beginning of the\n  // next segment.\n  for (;;) {\n    const char* p = strchr(str, '@');\n    if (p == NULL) {\n      ColoredPrintf(color, \"%s\", str);\n      return;\n    }\n\n    ColoredPrintf(color, \"%s\", std::string(str, p).c_str());\n\n    const char ch = p[1];\n    str = p + 2;\n    if (ch == '@') {\n      ColoredPrintf(color, \"@\");\n    } else if (ch == 'D') {\n      color = COLOR_DEFAULT;\n    } else if (ch == 'R') {\n      color = COLOR_RED;\n    } else if (ch == 'G') {\n      color = COLOR_GREEN;\n    } else if (ch == 'Y') {\n      color = COLOR_YELLOW;\n    } else {\n      --str;\n    }\n  }\n}\n\nstatic const char kColorEncodedHelpMessage[] =\n\"This program contains tests written using \" GTEST_NAME_ \". You can use the\\n\"\n\"following command line flags to control its behavior:\\n\"\n\"\\n\"\n\"Test Selection:\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"list_tests@D\\n\"\n\"      List the names of all tests instead of running them. The name of\\n\"\n\"      TEST(Foo, Bar) is \\\"Foo.Bar\\\".\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"filter=@YPOSTIVE_PATTERNS\"\n    \"[@G-@YNEGATIVE_PATTERNS]@D\\n\"\n\"      Run only the tests whose name matches one of the positive patterns but\\n\"\n\"      none of the negative patterns. '?' matches any single character; '*'\\n\"\n\"      matches any substring; ':' separates two patterns.\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"also_run_disabled_tests@D\\n\"\n\"      Run all disabled tests too.\\n\"\n\"\\n\"\n\"Test Execution:\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"repeat=@Y[COUNT]@D\\n\"\n\"      Run the tests repeatedly; use a negative count to repeat forever.\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"shuffle@D\\n\"\n\"      Randomize tests' orders on every iteration.\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"random_seed=@Y[NUMBER]@D\\n\"\n\"      Random number seed to use for shuffling test orders (between 1 and\\n\"\n\"      99999, or 0 to use a seed based on the current time).\\n\"\n\"\\n\"\n\"Test Output:\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"color=@Y(@Gyes@Y|@Gno@Y|@Gauto@Y)@D\\n\"\n\"      Enable/disable colored output. The default is @Gauto@D.\\n\"\n\"  -@G-\" GTEST_FLAG_PREFIX_ \"print_time=0@D\\n\"\n\"      Don't print the elapsed time of each test.\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"output=xml@Y[@G:@YDIRECTORY_PATH@G\"\n    GTEST_PATH_SEP_ \"@Y|@G:@YFILE_PATH]@D\\n\"\n\"      Generate an XML report in the given directory or with the given file\\n\"\n\"      name. @YFILE_PATH@D defaults to @Gtest_details.xml@D.\\n\"\n#if GTEST_CAN_STREAM_RESULTS_\n\"  @G--\" GTEST_FLAG_PREFIX_ \"stream_result_to=@YHOST@G:@YPORT@D\\n\"\n\"      Stream test results to the given server.\\n\"\n#endif  // GTEST_CAN_STREAM_RESULTS_\n\"\\n\"\n\"Assertion Behavior:\\n\"\n#if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS\n\"  @G--\" GTEST_FLAG_PREFIX_ \"death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D\\n\"\n\"      Set the default death test style.\\n\"\n#endif  // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS\n\"  @G--\" GTEST_FLAG_PREFIX_ \"break_on_failure@D\\n\"\n\"      Turn assertion failures into debugger break-points.\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"throw_on_failure@D\\n\"\n\"      Turn assertion failures into C++ exceptions.\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"catch_exceptions=0@D\\n\"\n\"      Do not report exceptions as test failures. Instead, allow them\\n\"\n\"      to crash the program or throw a pop-up (on Windows).\\n\"\n\"\\n\"\n\"Except for @G--\" GTEST_FLAG_PREFIX_ \"list_tests@D, you can alternatively set \"\n    \"the corresponding\\n\"\n\"environment variable of a flag (all letters in upper-case). For example, to\\n\"\n\"disable colored text output, you can either specify @G--\" GTEST_FLAG_PREFIX_\n    \"color=no@D or set\\n\"\n\"the @G\" GTEST_FLAG_PREFIX_UPPER_ \"COLOR@D environment variable to @Gno@D.\\n\"\n\"\\n\"\n\"For more information, please read the \" GTEST_NAME_ \" documentation at\\n\"\n\"@G\" GTEST_PROJECT_URL_ \"@D. If you find a bug in \" GTEST_NAME_ \"\\n\"\n\"(not one in your own code or tests), please report it to\\n\"\n\"@G<\" GTEST_DEV_EMAIL_ \">@D.\\n\";\n\nbool ParseGoogleTestFlag(const char* const arg) {\n  return ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag,\n                       &GTEST_FLAG(also_run_disabled_tests)) ||\n      ParseBoolFlag(arg, kBreakOnFailureFlag,\n                    &GTEST_FLAG(break_on_failure)) ||\n      ParseBoolFlag(arg, kCatchExceptionsFlag,\n                    &GTEST_FLAG(catch_exceptions)) ||\n      ParseStringFlag(arg, kColorFlag, &GTEST_FLAG(color)) ||\n      ParseStringFlag(arg, kDeathTestStyleFlag,\n                      &GTEST_FLAG(death_test_style)) ||\n      ParseBoolFlag(arg, kDeathTestUseFork,\n                    &GTEST_FLAG(death_test_use_fork)) ||\n      ParseStringFlag(arg, kFilterFlag, &GTEST_FLAG(filter)) ||\n      ParseStringFlag(arg, kInternalRunDeathTestFlag,\n                      &GTEST_FLAG(internal_run_death_test)) ||\n      ParseBoolFlag(arg, kListTestsFlag, &GTEST_FLAG(list_tests)) ||\n      ParseStringFlag(arg, kOutputFlag, &GTEST_FLAG(output)) ||\n      ParseBoolFlag(arg, kPrintTimeFlag, &GTEST_FLAG(print_time)) ||\n      ParseInt32Flag(arg, kRandomSeedFlag, &GTEST_FLAG(random_seed)) ||\n      ParseInt32Flag(arg, kRepeatFlag, &GTEST_FLAG(repeat)) ||\n      ParseBoolFlag(arg, kShuffleFlag, &GTEST_FLAG(shuffle)) ||\n      ParseInt32Flag(arg, kStackTraceDepthFlag,\n                     &GTEST_FLAG(stack_trace_depth)) ||\n      ParseStringFlag(arg, kStreamResultToFlag,\n                      &GTEST_FLAG(stream_result_to)) ||\n      ParseBoolFlag(arg, kThrowOnFailureFlag,\n                    &GTEST_FLAG(throw_on_failure));\n}\n\n#if GTEST_USE_OWN_FLAGFILE_FLAG_\nvoid LoadFlagsFromFile(const std::string& path) {\n  FILE* flagfile = posix::FOpen(path.c_str(), \"r\");\n  if (!flagfile) {\n    fprintf(stderr,\n            \"Unable to open file \\\"%s\\\"\\n\",\n            GTEST_FLAG(flagfile).c_str());\n    fflush(stderr);\n    exit(EXIT_FAILURE);\n  }\n  std::string contents(ReadEntireFile(flagfile));\n  posix::FClose(flagfile);\n  std::vector<std::string> lines;\n  SplitString(contents, '\\n', &lines);\n  for (size_t i = 0; i < lines.size(); ++i) {\n    if (lines[i].empty())\n      continue;\n    if (!ParseGoogleTestFlag(lines[i].c_str()))\n      g_help_flag = true;\n  }\n}\n#endif  // GTEST_USE_OWN_FLAGFILE_FLAG_\n\n// Parses the command line for Google Test flags, without initializing\n// other parts of Google Test.  The type parameter CharType can be\n// instantiated to either char or wchar_t.\ntemplate <typename CharType>\nvoid ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {\n  for (int i = 1; i < *argc; i++) {\n    const std::string arg_string = StreamableToString(argv[i]);\n    const char* const arg = arg_string.c_str();\n\n    using internal::ParseBoolFlag;\n    using internal::ParseInt32Flag;\n    using internal::ParseStringFlag;\n\n    bool remove_flag = false;\n    if (ParseGoogleTestFlag(arg)) {\n      remove_flag = true;\n#if GTEST_USE_OWN_FLAGFILE_FLAG_\n    } else if (ParseStringFlag(arg, kFlagfileFlag, &GTEST_FLAG(flagfile))) {\n      LoadFlagsFromFile(GTEST_FLAG(flagfile));\n      remove_flag = true;\n#endif  // GTEST_USE_OWN_FLAGFILE_FLAG_\n    } else if (arg_string == \"--help\" || arg_string == \"-h\" ||\n               arg_string == \"-?\" || arg_string == \"/?\" ||\n               HasGoogleTestFlagPrefix(arg)) {\n      // Both help flag and unrecognized Google Test flags (excluding\n      // internal ones) trigger help display.\n      g_help_flag = true;\n    }\n\n    if (remove_flag) {\n      // Shift the remainder of the argv list left by one.  Note\n      // that argv has (*argc + 1) elements, the last one always being\n      // NULL.  The following loop moves the trailing NULL element as\n      // well.\n      for (int j = i; j != *argc; j++) {\n        argv[j] = argv[j + 1];\n      }\n\n      // Decrements the argument count.\n      (*argc)--;\n\n      // We also need to decrement the iterator as we just removed\n      // an element.\n      i--;\n    }\n  }\n\n  if (g_help_flag) {\n    // We print the help here instead of in RUN_ALL_TESTS(), as the\n    // latter may not be called at all if the user is using Google\n    // Test with another testing framework.\n    PrintColorEncoded(kColorEncodedHelpMessage);\n  }\n}\n\n// Parses the command line for Google Test flags, without initializing\n// other parts of Google Test.\nvoid ParseGoogleTestFlagsOnly(int* argc, char** argv) {\n  ParseGoogleTestFlagsOnlyImpl(argc, argv);\n}\nvoid ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) {\n  ParseGoogleTestFlagsOnlyImpl(argc, argv);\n}\n\n// The internal implementation of InitGoogleTest().\n//\n// The type parameter CharType can be instantiated to either char or\n// wchar_t.\ntemplate <typename CharType>\nvoid InitGoogleTestImpl(int* argc, CharType** argv) {\n  // We don't want to run the initialization code twice.\n  if (GTestIsInitialized()) return;\n\n  if (*argc <= 0) return;\n\n  g_argvs.clear();\n  for (int i = 0; i != *argc; i++) {\n    g_argvs.push_back(StreamableToString(argv[i]));\n  }\n\n  ParseGoogleTestFlagsOnly(argc, argv);\n  GetUnitTestImpl()->PostFlagParsingInit();\n}\n\n}  // namespace internal\n\n// Initializes Google Test.  This must be called before calling\n// RUN_ALL_TESTS().  In particular, it parses a command line for the\n// flags that Google Test recognizes.  Whenever a Google Test flag is\n// seen, it is removed from argv, and *argc is decremented.\n//\n// No value is returned.  Instead, the Google Test flag variables are\n// updated.\n//\n// Calling the function for the second time has no user-visible effect.\nvoid InitGoogleTest(int* argc, char** argv) {\n#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)\n  GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv);\n#else  // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)\n  internal::InitGoogleTestImpl(argc, argv);\n#endif  // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)\n}\n\n// This overloaded version can be used in Windows programs compiled in\n// UNICODE mode.\nvoid InitGoogleTest(int* argc, wchar_t** argv) {\n#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)\n  GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv);\n#else  // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)\n  internal::InitGoogleTestImpl(argc, argv);\n#endif  // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)\n}\n\n}  // namespace testing\n"
  },
  {
    "path": "utils/googletest/googletest/src/gtest_main.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <stdio.h>\n\n#include \"gtest/gtest.h\"\n\nGTEST_API_ int main(int argc, char **argv) {\n  printf(\"Running main() from gtest_main.cc\\n\");\n  testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-death-test_ex_test.cc",
    "content": "// Copyright 2010, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n//\n// Tests that verify interaction of exceptions and death tests.\n\n#include \"gtest/gtest-death-test.h\"\n#include \"gtest/gtest.h\"\n\n#if GTEST_HAS_DEATH_TEST\n\n# if GTEST_HAS_SEH\n#  include <windows.h>          // For RaiseException().\n# endif\n\n# include \"gtest/gtest-spi.h\"\n\n# if GTEST_HAS_EXCEPTIONS\n\n#  include <exception>  // For std::exception.\n\n// Tests that death tests report thrown exceptions as failures and that the\n// exceptions do not escape death test macros.\nTEST(CxxExceptionDeathTest, ExceptionIsFailure) {\n  try {\n    EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw 1, \"\"), \"threw an exception\");\n  } catch (...) {  // NOLINT\n    FAIL() << \"An exception escaped a death test macro invocation \"\n           << \"with catch_exceptions \"\n           << (testing::GTEST_FLAG(catch_exceptions) ? \"enabled\" : \"disabled\");\n  }\n}\n\nclass TestException : public std::exception {\n public:\n  virtual const char* what() const throw() { return \"exceptional message\"; }\n};\n\nTEST(CxxExceptionDeathTest, PrintsMessageForStdExceptions) {\n  // Verifies that the exception message is quoted in the failure text.\n  EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw TestException(), \"\"),\n                          \"exceptional message\");\n  // Verifies that the location is mentioned in the failure text.\n  EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw TestException(), \"\"),\n                          \"gtest-death-test_ex_test.cc\");\n}\n# endif  // GTEST_HAS_EXCEPTIONS\n\n# if GTEST_HAS_SEH\n// Tests that enabling interception of SEH exceptions with the\n// catch_exceptions flag does not interfere with SEH exceptions being\n// treated as death by death tests.\nTEST(SehExceptionDeasTest, CatchExceptionsDoesNotInterfere) {\n  EXPECT_DEATH(RaiseException(42, 0x0, 0, NULL), \"\")\n      << \"with catch_exceptions \"\n      << (testing::GTEST_FLAG(catch_exceptions) ? \"enabled\" : \"disabled\");\n}\n# endif\n\n#endif  // GTEST_HAS_DEATH_TEST\n\nint main(int argc, char** argv) {\n  testing::InitGoogleTest(&argc, argv);\n  testing::GTEST_FLAG(catch_exceptions) = GTEST_ENABLE_CATCH_EXCEPTIONS_ != 0;\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-death-test_test.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Tests for death tests.\n\n#include \"gtest/gtest-death-test.h\"\n#include \"gtest/gtest.h\"\n#include \"gtest/internal/gtest-filepath.h\"\n\nusing testing::internal::AlwaysFalse;\nusing testing::internal::AlwaysTrue;\n\n#if GTEST_HAS_DEATH_TEST\n\n# if GTEST_OS_WINDOWS\n#  include <direct.h>          // For chdir().\n# else\n#  include <unistd.h>\n#  include <sys/wait.h>        // For waitpid.\n# endif  // GTEST_OS_WINDOWS\n\n# include <limits.h>\n# include <signal.h>\n# include <stdio.h>\n\n# if GTEST_OS_LINUX\n#  include <sys/time.h>\n# endif  // GTEST_OS_LINUX\n\n# include \"gtest/gtest-spi.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n# define GTEST_IMPLEMENTATION_ 1\n# include \"src/gtest-internal-inl.h\"\n# undef GTEST_IMPLEMENTATION_\n\nnamespace posix = ::testing::internal::posix;\n\nusing testing::Message;\nusing testing::internal::DeathTest;\nusing testing::internal::DeathTestFactory;\nusing testing::internal::FilePath;\nusing testing::internal::GetLastErrnoDescription;\nusing testing::internal::GetUnitTestImpl;\nusing testing::internal::InDeathTestChild;\nusing testing::internal::ParseNaturalNumber;\n\nnamespace testing {\nnamespace internal {\n\n// A helper class whose objects replace the death test factory for a\n// single UnitTest object during their lifetimes.\nclass ReplaceDeathTestFactory {\n public:\n  explicit ReplaceDeathTestFactory(DeathTestFactory* new_factory)\n      : unit_test_impl_(GetUnitTestImpl()) {\n    old_factory_ = unit_test_impl_->death_test_factory_.release();\n    unit_test_impl_->death_test_factory_.reset(new_factory);\n  }\n\n  ~ReplaceDeathTestFactory() {\n    unit_test_impl_->death_test_factory_.release();\n    unit_test_impl_->death_test_factory_.reset(old_factory_);\n  }\n private:\n  // Prevents copying ReplaceDeathTestFactory objects.\n  ReplaceDeathTestFactory(const ReplaceDeathTestFactory&);\n  void operator=(const ReplaceDeathTestFactory&);\n\n  UnitTestImpl* unit_test_impl_;\n  DeathTestFactory* old_factory_;\n};\n\n}  // namespace internal\n}  // namespace testing\n\nvoid DieWithMessage(const ::std::string& message) {\n  fprintf(stderr, \"%s\", message.c_str());\n  fflush(stderr);  // Make sure the text is printed before the process exits.\n\n  // We call _exit() instead of exit(), as the former is a direct\n  // system call and thus safer in the presence of threads.  exit()\n  // will invoke user-defined exit-hooks, which may do dangerous\n  // things that conflict with death tests.\n  //\n  // Some compilers can recognize that _exit() never returns and issue the\n  // 'unreachable code' warning for code following this function, unless\n  // fooled by a fake condition.\n  if (AlwaysTrue())\n    _exit(1);\n}\n\nvoid DieInside(const ::std::string& function) {\n  DieWithMessage(\"death inside \" + function + \"().\");\n}\n\n// Tests that death tests work.\n\nclass TestForDeathTest : public testing::Test {\n protected:\n  TestForDeathTest() : original_dir_(FilePath::GetCurrentDir()) {}\n\n  virtual ~TestForDeathTest() {\n    posix::ChDir(original_dir_.c_str());\n  }\n\n  // A static member function that's expected to die.\n  static void StaticMemberFunction() { DieInside(\"StaticMemberFunction\"); }\n\n  // A method of the test fixture that may die.\n  void MemberFunction() {\n    if (should_die_)\n      DieInside(\"MemberFunction\");\n  }\n\n  // True iff MemberFunction() should die.\n  bool should_die_;\n  const FilePath original_dir_;\n};\n\n// A class with a member function that may die.\nclass MayDie {\n public:\n  explicit MayDie(bool should_die) : should_die_(should_die) {}\n\n  // A member function that may die.\n  void MemberFunction() const {\n    if (should_die_)\n      DieInside(\"MayDie::MemberFunction\");\n  }\n\n private:\n  // True iff MemberFunction() should die.\n  bool should_die_;\n};\n\n// A global function that's expected to die.\nvoid GlobalFunction() { DieInside(\"GlobalFunction\"); }\n\n// A non-void function that's expected to die.\nint NonVoidFunction() {\n  DieInside(\"NonVoidFunction\");\n  return 1;\n}\n\n// A unary function that may die.\nvoid DieIf(bool should_die) {\n  if (should_die)\n    DieInside(\"DieIf\");\n}\n\n// A binary function that may die.\nbool DieIfLessThan(int x, int y) {\n  if (x < y) {\n    DieInside(\"DieIfLessThan\");\n  }\n  return true;\n}\n\n// Tests that ASSERT_DEATH can be used outside a TEST, TEST_F, or test fixture.\nvoid DeathTestSubroutine() {\n  EXPECT_DEATH(GlobalFunction(), \"death.*GlobalFunction\");\n  ASSERT_DEATH(GlobalFunction(), \"death.*GlobalFunction\");\n}\n\n// Death in dbg, not opt.\nint DieInDebugElse12(int* sideeffect) {\n  if (sideeffect) *sideeffect = 12;\n\n# ifndef NDEBUG\n\n  DieInside(\"DieInDebugElse12\");\n\n# endif  // NDEBUG\n\n  return 12;\n}\n\n# if GTEST_OS_WINDOWS\n\n// Tests the ExitedWithCode predicate.\nTEST(ExitStatusPredicateTest, ExitedWithCode) {\n  // On Windows, the process's exit code is the same as its exit status,\n  // so the predicate just compares the its input with its parameter.\n  EXPECT_TRUE(testing::ExitedWithCode(0)(0));\n  EXPECT_TRUE(testing::ExitedWithCode(1)(1));\n  EXPECT_TRUE(testing::ExitedWithCode(42)(42));\n  EXPECT_FALSE(testing::ExitedWithCode(0)(1));\n  EXPECT_FALSE(testing::ExitedWithCode(1)(0));\n}\n\n# else\n\n// Returns the exit status of a process that calls _exit(2) with a\n// given exit code.  This is a helper function for the\n// ExitStatusPredicateTest test suite.\nstatic int NormalExitStatus(int exit_code) {\n  pid_t child_pid = fork();\n  if (child_pid == 0) {\n    _exit(exit_code);\n  }\n  int status;\n  waitpid(child_pid, &status, 0);\n  return status;\n}\n\n// Returns the exit status of a process that raises a given signal.\n// If the signal does not cause the process to die, then it returns\n// instead the exit status of a process that exits normally with exit\n// code 1.  This is a helper function for the ExitStatusPredicateTest\n// test suite.\nstatic int KilledExitStatus(int signum) {\n  pid_t child_pid = fork();\n  if (child_pid == 0) {\n    raise(signum);\n    _exit(1);\n  }\n  int status;\n  waitpid(child_pid, &status, 0);\n  return status;\n}\n\n// Tests the ExitedWithCode predicate.\nTEST(ExitStatusPredicateTest, ExitedWithCode) {\n  const int status0  = NormalExitStatus(0);\n  const int status1  = NormalExitStatus(1);\n  const int status42 = NormalExitStatus(42);\n  const testing::ExitedWithCode pred0(0);\n  const testing::ExitedWithCode pred1(1);\n  const testing::ExitedWithCode pred42(42);\n  EXPECT_PRED1(pred0,  status0);\n  EXPECT_PRED1(pred1,  status1);\n  EXPECT_PRED1(pred42, status42);\n  EXPECT_FALSE(pred0(status1));\n  EXPECT_FALSE(pred42(status0));\n  EXPECT_FALSE(pred1(status42));\n}\n\n// Tests the KilledBySignal predicate.\nTEST(ExitStatusPredicateTest, KilledBySignal) {\n  const int status_segv = KilledExitStatus(SIGSEGV);\n  const int status_kill = KilledExitStatus(SIGKILL);\n  const testing::KilledBySignal pred_segv(SIGSEGV);\n  const testing::KilledBySignal pred_kill(SIGKILL);\n  EXPECT_PRED1(pred_segv, status_segv);\n  EXPECT_PRED1(pred_kill, status_kill);\n  EXPECT_FALSE(pred_segv(status_kill));\n  EXPECT_FALSE(pred_kill(status_segv));\n}\n\n# endif  // GTEST_OS_WINDOWS\n\n// Tests that the death test macros expand to code which may or may not\n// be followed by operator<<, and that in either case the complete text\n// comprises only a single C++ statement.\nTEST_F(TestForDeathTest, SingleStatement) {\n  if (AlwaysFalse())\n    // This would fail if executed; this is a compilation test only\n    ASSERT_DEATH(return, \"\");\n\n  if (AlwaysTrue())\n    EXPECT_DEATH(_exit(1), \"\");\n  else\n    // This empty \"else\" branch is meant to ensure that EXPECT_DEATH\n    // doesn't expand into an \"if\" statement without an \"else\"\n    ;\n\n  if (AlwaysFalse())\n    ASSERT_DEATH(return, \"\") << \"did not die\";\n\n  if (AlwaysFalse())\n    ;\n  else\n    EXPECT_DEATH(_exit(1), \"\") << 1 << 2 << 3;\n}\n\nvoid DieWithEmbeddedNul() {\n  fprintf(stderr, \"Hello%cmy null world.\\n\", '\\0');\n  fflush(stderr);\n  _exit(1);\n}\n\n# if GTEST_USES_PCRE\n// Tests that EXPECT_DEATH and ASSERT_DEATH work when the error\n// message has a NUL character in it.\nTEST_F(TestForDeathTest, EmbeddedNulInMessage) {\n  // TODO(wan@google.com): <regex.h> doesn't support matching strings\n  // with embedded NUL characters - find a way to workaround it.\n  EXPECT_DEATH(DieWithEmbeddedNul(), \"my null world\");\n  ASSERT_DEATH(DieWithEmbeddedNul(), \"my null world\");\n}\n# endif  // GTEST_USES_PCRE\n\n// Tests that death test macros expand to code which interacts well with switch\n// statements.\nTEST_F(TestForDeathTest, SwitchStatement) {\n  // Microsoft compiler usually complains about switch statements without\n  // case labels. We suppress that warning for this test.\n  GTEST_DISABLE_MSC_WARNINGS_PUSH_(4065)\n\n  switch (0)\n    default:\n      ASSERT_DEATH(_exit(1), \"\") << \"exit in default switch handler\";\n\n  switch (0)\n    case 0:\n      EXPECT_DEATH(_exit(1), \"\") << \"exit in switch case\";\n\n  GTEST_DISABLE_MSC_WARNINGS_POP_()\n}\n\n// Tests that a static member function can be used in a \"fast\" style\n// death test.\nTEST_F(TestForDeathTest, StaticMemberFunctionFastStyle) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  ASSERT_DEATH(StaticMemberFunction(), \"death.*StaticMember\");\n}\n\n// Tests that a method of the test fixture can be used in a \"fast\"\n// style death test.\nTEST_F(TestForDeathTest, MemberFunctionFastStyle) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  should_die_ = true;\n  EXPECT_DEATH(MemberFunction(), \"inside.*MemberFunction\");\n}\n\nvoid ChangeToRootDir() { posix::ChDir(GTEST_PATH_SEP_); }\n\n// Tests that death tests work even if the current directory has been\n// changed.\nTEST_F(TestForDeathTest, FastDeathTestInChangedDir) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n\n  ChangeToRootDir();\n  EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), \"\");\n\n  ChangeToRootDir();\n  ASSERT_DEATH(_exit(1), \"\");\n}\n\n# if GTEST_OS_LINUX\nvoid SigprofAction(int, siginfo_t*, void*) { /* no op */ }\n\n// Sets SIGPROF action and ITIMER_PROF timer (interval: 1ms).\nvoid SetSigprofActionAndTimer() {\n  struct itimerval timer;\n  timer.it_interval.tv_sec = 0;\n  timer.it_interval.tv_usec = 1;\n  timer.it_value = timer.it_interval;\n  ASSERT_EQ(0, setitimer(ITIMER_PROF, &timer, NULL));\n  struct sigaction signal_action;\n  memset(&signal_action, 0, sizeof(signal_action));\n  sigemptyset(&signal_action.sa_mask);\n  signal_action.sa_sigaction = SigprofAction;\n  signal_action.sa_flags = SA_RESTART | SA_SIGINFO;\n  ASSERT_EQ(0, sigaction(SIGPROF, &signal_action, NULL));\n}\n\n// Disables ITIMER_PROF timer and ignores SIGPROF signal.\nvoid DisableSigprofActionAndTimer(struct sigaction* old_signal_action) {\n  struct itimerval timer;\n  timer.it_interval.tv_sec = 0;\n  timer.it_interval.tv_usec = 0;\n  timer.it_value = timer.it_interval;\n  ASSERT_EQ(0, setitimer(ITIMER_PROF, &timer, NULL));\n  struct sigaction signal_action;\n  memset(&signal_action, 0, sizeof(signal_action));\n  sigemptyset(&signal_action.sa_mask);\n  signal_action.sa_handler = SIG_IGN;\n  ASSERT_EQ(0, sigaction(SIGPROF, &signal_action, old_signal_action));\n}\n\n// Tests that death tests work when SIGPROF handler and timer are set.\nTEST_F(TestForDeathTest, FastSigprofActionSet) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  SetSigprofActionAndTimer();\n  EXPECT_DEATH(_exit(1), \"\");\n  struct sigaction old_signal_action;\n  DisableSigprofActionAndTimer(&old_signal_action);\n  EXPECT_TRUE(old_signal_action.sa_sigaction == SigprofAction);\n}\n\nTEST_F(TestForDeathTest, ThreadSafeSigprofActionSet) {\n  testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n  SetSigprofActionAndTimer();\n  EXPECT_DEATH(_exit(1), \"\");\n  struct sigaction old_signal_action;\n  DisableSigprofActionAndTimer(&old_signal_action);\n  EXPECT_TRUE(old_signal_action.sa_sigaction == SigprofAction);\n}\n# endif  // GTEST_OS_LINUX\n\n// Repeats a representative sample of death tests in the \"threadsafe\" style:\n\nTEST_F(TestForDeathTest, StaticMemberFunctionThreadsafeStyle) {\n  testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n  ASSERT_DEATH(StaticMemberFunction(), \"death.*StaticMember\");\n}\n\nTEST_F(TestForDeathTest, MemberFunctionThreadsafeStyle) {\n  testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n  should_die_ = true;\n  EXPECT_DEATH(MemberFunction(), \"inside.*MemberFunction\");\n}\n\nTEST_F(TestForDeathTest, ThreadsafeDeathTestInLoop) {\n  testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n\n  for (int i = 0; i < 3; ++i)\n    EXPECT_EXIT(_exit(i), testing::ExitedWithCode(i), \"\") << \": i = \" << i;\n}\n\nTEST_F(TestForDeathTest, ThreadsafeDeathTestInChangedDir) {\n  testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n\n  ChangeToRootDir();\n  EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), \"\");\n\n  ChangeToRootDir();\n  ASSERT_DEATH(_exit(1), \"\");\n}\n\nTEST_F(TestForDeathTest, MixedStyles) {\n  testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n  EXPECT_DEATH(_exit(1), \"\");\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_DEATH(_exit(1), \"\");\n}\n\n# if GTEST_HAS_CLONE && GTEST_HAS_PTHREAD\n\nnamespace {\n\nbool pthread_flag;\n\nvoid SetPthreadFlag() {\n  pthread_flag = true;\n}\n\n}  // namespace\n\nTEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) {\n  if (!testing::GTEST_FLAG(death_test_use_fork)) {\n    testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n    pthread_flag = false;\n    ASSERT_EQ(0, pthread_atfork(&SetPthreadFlag, NULL, NULL));\n    ASSERT_DEATH(_exit(1), \"\");\n    ASSERT_FALSE(pthread_flag);\n  }\n}\n\n# endif  // GTEST_HAS_CLONE && GTEST_HAS_PTHREAD\n\n// Tests that a method of another class can be used in a death test.\nTEST_F(TestForDeathTest, MethodOfAnotherClass) {\n  const MayDie x(true);\n  ASSERT_DEATH(x.MemberFunction(), \"MayDie\\\\:\\\\:MemberFunction\");\n}\n\n// Tests that a global function can be used in a death test.\nTEST_F(TestForDeathTest, GlobalFunction) {\n  EXPECT_DEATH(GlobalFunction(), \"GlobalFunction\");\n}\n\n// Tests that any value convertible to an RE works as a second\n// argument to EXPECT_DEATH.\nTEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) {\n  static const char regex_c_str[] = \"GlobalFunction\";\n  EXPECT_DEATH(GlobalFunction(), regex_c_str);\n\n  const testing::internal::RE regex(regex_c_str);\n  EXPECT_DEATH(GlobalFunction(), regex);\n\n# if GTEST_HAS_GLOBAL_STRING\n\n  const string regex_str(regex_c_str);\n  EXPECT_DEATH(GlobalFunction(), regex_str);\n\n# endif  // GTEST_HAS_GLOBAL_STRING\n\n# if !GTEST_USES_PCRE\n\n  const ::std::string regex_std_str(regex_c_str);\n  EXPECT_DEATH(GlobalFunction(), regex_std_str);\n\n# endif  // !GTEST_USES_PCRE\n}\n\n// Tests that a non-void function can be used in a death test.\nTEST_F(TestForDeathTest, NonVoidFunction) {\n  ASSERT_DEATH(NonVoidFunction(), \"NonVoidFunction\");\n}\n\n// Tests that functions that take parameter(s) can be used in a death test.\nTEST_F(TestForDeathTest, FunctionWithParameter) {\n  EXPECT_DEATH(DieIf(true), \"DieIf\\\\(\\\\)\");\n  EXPECT_DEATH(DieIfLessThan(2, 3), \"DieIfLessThan\");\n}\n\n// Tests that ASSERT_DEATH can be used outside a TEST, TEST_F, or test fixture.\nTEST_F(TestForDeathTest, OutsideFixture) {\n  DeathTestSubroutine();\n}\n\n// Tests that death tests can be done inside a loop.\nTEST_F(TestForDeathTest, InsideLoop) {\n  for (int i = 0; i < 5; i++) {\n    EXPECT_DEATH(DieIfLessThan(-1, i), \"DieIfLessThan\") << \"where i == \" << i;\n  }\n}\n\n// Tests that a compound statement can be used in a death test.\nTEST_F(TestForDeathTest, CompoundStatement) {\n  EXPECT_DEATH({  // NOLINT\n    const int x = 2;\n    const int y = x + 1;\n    DieIfLessThan(x, y);\n  },\n  \"DieIfLessThan\");\n}\n\n// Tests that code that doesn't die causes a death test to fail.\nTEST_F(TestForDeathTest, DoesNotDie) {\n  EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(DieIf(false), \"DieIf\"),\n                          \"failed to die\");\n}\n\n// Tests that a death test fails when the error message isn't expected.\nTEST_F(TestForDeathTest, ErrorMessageMismatch) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_DEATH(DieIf(true), \"DieIfLessThan\") << \"End of death test message.\";\n  }, \"died but not with expected error\");\n}\n\n// On exit, *aborted will be true iff the EXPECT_DEATH() statement\n// aborted the function.\nvoid ExpectDeathTestHelper(bool* aborted) {\n  *aborted = true;\n  EXPECT_DEATH(DieIf(false), \"DieIf\");  // This assertion should fail.\n  *aborted = false;\n}\n\n// Tests that EXPECT_DEATH doesn't abort the test on failure.\nTEST_F(TestForDeathTest, EXPECT_DEATH) {\n  bool aborted = true;\n  EXPECT_NONFATAL_FAILURE(ExpectDeathTestHelper(&aborted),\n                          \"failed to die\");\n  EXPECT_FALSE(aborted);\n}\n\n// Tests that ASSERT_DEATH does abort the test on failure.\nTEST_F(TestForDeathTest, ASSERT_DEATH) {\n  static bool aborted;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    aborted = true;\n    ASSERT_DEATH(DieIf(false), \"DieIf\");  // This assertion should fail.\n    aborted = false;\n  }, \"failed to die\");\n  EXPECT_TRUE(aborted);\n}\n\n// Tests that EXPECT_DEATH evaluates the arguments exactly once.\nTEST_F(TestForDeathTest, SingleEvaluation) {\n  int x = 3;\n  EXPECT_DEATH(DieIf((++x) == 4), \"DieIf\");\n\n  const char* regex = \"DieIf\";\n  const char* regex_save = regex;\n  EXPECT_DEATH(DieIfLessThan(3, 4), regex++);\n  EXPECT_EQ(regex_save + 1, regex);\n}\n\n// Tests that run-away death tests are reported as failures.\nTEST_F(TestForDeathTest, RunawayIsFailure) {\n  EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(static_cast<void>(0), \"Foo\"),\n                          \"failed to die.\");\n}\n\n// Tests that death tests report executing 'return' in the statement as\n// failure.\nTEST_F(TestForDeathTest, ReturnIsFailure) {\n  EXPECT_FATAL_FAILURE(ASSERT_DEATH(return, \"Bar\"),\n                       \"illegal return in test statement.\");\n}\n\n// Tests that EXPECT_DEBUG_DEATH works as expected, that is, you can stream a\n// message to it, and in debug mode it:\n// 1. Asserts on death.\n// 2. Has no side effect.\n//\n// And in opt mode, it:\n// 1.  Has side effects but does not assert.\nTEST_F(TestForDeathTest, TestExpectDebugDeath) {\n  int sideeffect = 0;\n\n  EXPECT_DEBUG_DEATH(DieInDebugElse12(&sideeffect), \"death.*DieInDebugElse12\")\n      << \"Must accept a streamed message\";\n\n# ifdef NDEBUG\n\n  // Checks that the assignment occurs in opt mode (sideeffect).\n  EXPECT_EQ(12, sideeffect);\n\n# else\n\n  // Checks that the assignment does not occur in dbg mode (no sideeffect).\n  EXPECT_EQ(0, sideeffect);\n\n# endif\n}\n\n// Tests that ASSERT_DEBUG_DEATH works as expected, that is, you can stream a\n// message to it, and in debug mode it:\n// 1. Asserts on death.\n// 2. Has no side effect.\n//\n// And in opt mode, it:\n// 1.  Has side effects but does not assert.\nTEST_F(TestForDeathTest, TestAssertDebugDeath) {\n  int sideeffect = 0;\n\n  ASSERT_DEBUG_DEATH(DieInDebugElse12(&sideeffect), \"death.*DieInDebugElse12\")\n      << \"Must accept a streamed message\";\n\n# ifdef NDEBUG\n\n  // Checks that the assignment occurs in opt mode (sideeffect).\n  EXPECT_EQ(12, sideeffect);\n\n# else\n\n  // Checks that the assignment does not occur in dbg mode (no sideeffect).\n  EXPECT_EQ(0, sideeffect);\n\n# endif\n}\n\n# ifndef NDEBUG\n\nvoid ExpectDebugDeathHelper(bool* aborted) {\n  *aborted = true;\n  EXPECT_DEBUG_DEATH(return, \"\") << \"This is expected to fail.\";\n  *aborted = false;\n}\n\n#  if GTEST_OS_WINDOWS\nTEST(PopUpDeathTest, DoesNotShowPopUpOnAbort) {\n  printf(\"This test should be considered failing if it shows \"\n         \"any pop-up dialogs.\\n\");\n  fflush(stdout);\n\n  EXPECT_DEATH({\n    testing::GTEST_FLAG(catch_exceptions) = false;\n    abort();\n  }, \"\");\n}\n#  endif  // GTEST_OS_WINDOWS\n\n// Tests that EXPECT_DEBUG_DEATH in debug mode does not abort\n// the function.\nTEST_F(TestForDeathTest, ExpectDebugDeathDoesNotAbort) {\n  bool aborted = true;\n  EXPECT_NONFATAL_FAILURE(ExpectDebugDeathHelper(&aborted), \"\");\n  EXPECT_FALSE(aborted);\n}\n\nvoid AssertDebugDeathHelper(bool* aborted) {\n  *aborted = true;\n  GTEST_LOG_(INFO) << \"Before ASSERT_DEBUG_DEATH\";\n  ASSERT_DEBUG_DEATH(GTEST_LOG_(INFO) << \"In ASSERT_DEBUG_DEATH\"; return, \"\")\n      << \"This is expected to fail.\";\n  GTEST_LOG_(INFO) << \"After ASSERT_DEBUG_DEATH\";\n  *aborted = false;\n}\n\n// Tests that ASSERT_DEBUG_DEATH in debug mode aborts the function on\n// failure.\nTEST_F(TestForDeathTest, AssertDebugDeathAborts) {\n  static bool aborted;\n  aborted = false;\n  EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), \"\");\n  EXPECT_TRUE(aborted);\n}\n\nTEST_F(TestForDeathTest, AssertDebugDeathAborts2) {\n  static bool aborted;\n  aborted = false;\n  EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), \"\");\n  EXPECT_TRUE(aborted);\n}\n\nTEST_F(TestForDeathTest, AssertDebugDeathAborts3) {\n  static bool aborted;\n  aborted = false;\n  EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), \"\");\n  EXPECT_TRUE(aborted);\n}\n\nTEST_F(TestForDeathTest, AssertDebugDeathAborts4) {\n  static bool aborted;\n  aborted = false;\n  EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), \"\");\n  EXPECT_TRUE(aborted);\n}\n\nTEST_F(TestForDeathTest, AssertDebugDeathAborts5) {\n  static bool aborted;\n  aborted = false;\n  EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), \"\");\n  EXPECT_TRUE(aborted);\n}\n\nTEST_F(TestForDeathTest, AssertDebugDeathAborts6) {\n  static bool aborted;\n  aborted = false;\n  EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), \"\");\n  EXPECT_TRUE(aborted);\n}\n\nTEST_F(TestForDeathTest, AssertDebugDeathAborts7) {\n  static bool aborted;\n  aborted = false;\n  EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), \"\");\n  EXPECT_TRUE(aborted);\n}\n\nTEST_F(TestForDeathTest, AssertDebugDeathAborts8) {\n  static bool aborted;\n  aborted = false;\n  EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), \"\");\n  EXPECT_TRUE(aborted);\n}\n\nTEST_F(TestForDeathTest, AssertDebugDeathAborts9) {\n  static bool aborted;\n  aborted = false;\n  EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), \"\");\n  EXPECT_TRUE(aborted);\n}\n\nTEST_F(TestForDeathTest, AssertDebugDeathAborts10) {\n  static bool aborted;\n  aborted = false;\n  EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), \"\");\n  EXPECT_TRUE(aborted);\n}\n\n# endif  // _NDEBUG\n\n// Tests the *_EXIT family of macros, using a variety of predicates.\nstatic void TestExitMacros() {\n  EXPECT_EXIT(_exit(1),  testing::ExitedWithCode(1),  \"\");\n  ASSERT_EXIT(_exit(42), testing::ExitedWithCode(42), \"\");\n\n# if GTEST_OS_WINDOWS\n\n  // Of all signals effects on the process exit code, only those of SIGABRT\n  // are documented on Windows.\n  // See http://msdn.microsoft.com/en-us/library/dwwzkt4c(VS.71).aspx.\n  EXPECT_EXIT(raise(SIGABRT), testing::ExitedWithCode(3), \"\") << \"b_ar\";\n\n# else\n\n  EXPECT_EXIT(raise(SIGKILL), testing::KilledBySignal(SIGKILL), \"\") << \"foo\";\n  ASSERT_EXIT(raise(SIGUSR2), testing::KilledBySignal(SIGUSR2), \"\") << \"bar\";\n\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_EXIT(_exit(0), testing::KilledBySignal(SIGSEGV), \"\")\n      << \"This failure is expected, too.\";\n  }, \"This failure is expected, too.\");\n\n# endif  // GTEST_OS_WINDOWS\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_EXIT(raise(SIGSEGV), testing::ExitedWithCode(0), \"\")\n      << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n}\n\nTEST_F(TestForDeathTest, ExitMacros) {\n  TestExitMacros();\n}\n\nTEST_F(TestForDeathTest, ExitMacrosUsingFork) {\n  testing::GTEST_FLAG(death_test_use_fork) = true;\n  TestExitMacros();\n}\n\nTEST_F(TestForDeathTest, InvalidStyle) {\n  testing::GTEST_FLAG(death_test_style) = \"rococo\";\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_DEATH(_exit(0), \"\") << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n}\n\nTEST_F(TestForDeathTest, DeathTestFailedOutput) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_DEATH(DieWithMessage(\"death\\n\"),\n                   \"expected message\"),\n      \"Actual msg:\\n\"\n      \"[  DEATH   ] death\\n\");\n}\n\nTEST_F(TestForDeathTest, DeathTestUnexpectedReturnOutput) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_DEATH({\n          fprintf(stderr, \"returning\\n\");\n          fflush(stderr);\n          return;\n        }, \"\"),\n      \"    Result: illegal return in test statement.\\n\"\n      \" Error msg:\\n\"\n      \"[  DEATH   ] returning\\n\");\n}\n\nTEST_F(TestForDeathTest, DeathTestBadExitCodeOutput) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_EXIT(DieWithMessage(\"exiting with rc 1\\n\"),\n                  testing::ExitedWithCode(3),\n                  \"expected message\"),\n      \"    Result: died but not with expected exit code:\\n\"\n      \"            Exited with exit status 1\\n\"\n      \"Actual msg:\\n\"\n      \"[  DEATH   ] exiting with rc 1\\n\");\n}\n\nTEST_F(TestForDeathTest, DeathTestMultiLineMatchFail) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_DEATH(DieWithMessage(\"line 1\\nline 2\\nline 3\\n\"),\n                   \"line 1\\nxyz\\nline 3\\n\"),\n      \"Actual msg:\\n\"\n      \"[  DEATH   ] line 1\\n\"\n      \"[  DEATH   ] line 2\\n\"\n      \"[  DEATH   ] line 3\\n\");\n}\n\nTEST_F(TestForDeathTest, DeathTestMultiLineMatchPass) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_DEATH(DieWithMessage(\"line 1\\nline 2\\nline 3\\n\"),\n               \"line 1\\nline 2\\nline 3\\n\");\n}\n\n// A DeathTestFactory that returns MockDeathTests.\nclass MockDeathTestFactory : public DeathTestFactory {\n public:\n  MockDeathTestFactory();\n  virtual bool Create(const char* statement,\n                      const ::testing::internal::RE* regex,\n                      const char* file, int line, DeathTest** test);\n\n  // Sets the parameters for subsequent calls to Create.\n  void SetParameters(bool create, DeathTest::TestRole role,\n                     int status, bool passed);\n\n  // Accessors.\n  int AssumeRoleCalls() const { return assume_role_calls_; }\n  int WaitCalls() const { return wait_calls_; }\n  size_t PassedCalls() const { return passed_args_.size(); }\n  bool PassedArgument(int n) const { return passed_args_[n]; }\n  size_t AbortCalls() const { return abort_args_.size(); }\n  DeathTest::AbortReason AbortArgument(int n) const {\n    return abort_args_[n];\n  }\n  bool TestDeleted() const { return test_deleted_; }\n\n private:\n  friend class MockDeathTest;\n  // If true, Create will return a MockDeathTest; otherwise it returns\n  // NULL.\n  bool create_;\n  // The value a MockDeathTest will return from its AssumeRole method.\n  DeathTest::TestRole role_;\n  // The value a MockDeathTest will return from its Wait method.\n  int status_;\n  // The value a MockDeathTest will return from its Passed method.\n  bool passed_;\n\n  // Number of times AssumeRole was called.\n  int assume_role_calls_;\n  // Number of times Wait was called.\n  int wait_calls_;\n  // The arguments to the calls to Passed since the last call to\n  // SetParameters.\n  std::vector<bool> passed_args_;\n  // The arguments to the calls to Abort since the last call to\n  // SetParameters.\n  std::vector<DeathTest::AbortReason> abort_args_;\n  // True if the last MockDeathTest returned by Create has been\n  // deleted.\n  bool test_deleted_;\n};\n\n\n// A DeathTest implementation useful in testing.  It returns values set\n// at its creation from its various inherited DeathTest methods, and\n// reports calls to those methods to its parent MockDeathTestFactory\n// object.\nclass MockDeathTest : public DeathTest {\n public:\n  MockDeathTest(MockDeathTestFactory *parent,\n                TestRole role, int status, bool passed) :\n      parent_(parent), role_(role), status_(status), passed_(passed) {\n  }\n  virtual ~MockDeathTest() {\n    parent_->test_deleted_ = true;\n  }\n  virtual TestRole AssumeRole() {\n    ++parent_->assume_role_calls_;\n    return role_;\n  }\n  virtual int Wait() {\n    ++parent_->wait_calls_;\n    return status_;\n  }\n  virtual bool Passed(bool exit_status_ok) {\n    parent_->passed_args_.push_back(exit_status_ok);\n    return passed_;\n  }\n  virtual void Abort(AbortReason reason) {\n    parent_->abort_args_.push_back(reason);\n  }\n\n private:\n  MockDeathTestFactory* const parent_;\n  const TestRole role_;\n  const int status_;\n  const bool passed_;\n};\n\n\n// MockDeathTestFactory constructor.\nMockDeathTestFactory::MockDeathTestFactory()\n    : create_(true),\n      role_(DeathTest::OVERSEE_TEST),\n      status_(0),\n      passed_(true),\n      assume_role_calls_(0),\n      wait_calls_(0),\n      passed_args_(),\n      abort_args_() {\n}\n\n\n// Sets the parameters for subsequent calls to Create.\nvoid MockDeathTestFactory::SetParameters(bool create,\n                                         DeathTest::TestRole role,\n                                         int status, bool passed) {\n  create_ = create;\n  role_ = role;\n  status_ = status;\n  passed_ = passed;\n\n  assume_role_calls_ = 0;\n  wait_calls_ = 0;\n  passed_args_.clear();\n  abort_args_.clear();\n}\n\n\n// Sets test to NULL (if create_ is false) or to the address of a new\n// MockDeathTest object with parameters taken from the last call\n// to SetParameters (if create_ is true).  Always returns true.\nbool MockDeathTestFactory::Create(const char* /*statement*/,\n                                  const ::testing::internal::RE* /*regex*/,\n                                  const char* /*file*/,\n                                  int /*line*/,\n                                  DeathTest** test) {\n  test_deleted_ = false;\n  if (create_) {\n    *test = new MockDeathTest(this, role_, status_, passed_);\n  } else {\n    *test = NULL;\n  }\n  return true;\n}\n\n// A test fixture for testing the logic of the GTEST_DEATH_TEST_ macro.\n// It installs a MockDeathTestFactory that is used for the duration\n// of the test case.\nclass MacroLogicDeathTest : public testing::Test {\n protected:\n  static testing::internal::ReplaceDeathTestFactory* replacer_;\n  static MockDeathTestFactory* factory_;\n\n  static void SetUpTestCase() {\n    factory_ = new MockDeathTestFactory;\n    replacer_ = new testing::internal::ReplaceDeathTestFactory(factory_);\n  }\n\n  static void TearDownTestCase() {\n    delete replacer_;\n    replacer_ = NULL;\n    delete factory_;\n    factory_ = NULL;\n  }\n\n  // Runs a death test that breaks the rules by returning.  Such a death\n  // test cannot be run directly from a test routine that uses a\n  // MockDeathTest, or the remainder of the routine will not be executed.\n  static void RunReturningDeathTest(bool* flag) {\n    ASSERT_DEATH({  // NOLINT\n      *flag = true;\n      return;\n    }, \"\");\n  }\n};\n\ntesting::internal::ReplaceDeathTestFactory* MacroLogicDeathTest::replacer_\n    = NULL;\nMockDeathTestFactory* MacroLogicDeathTest::factory_ = NULL;\n\n\n// Test that nothing happens when the factory doesn't return a DeathTest:\nTEST_F(MacroLogicDeathTest, NothingHappens) {\n  bool flag = false;\n  factory_->SetParameters(false, DeathTest::OVERSEE_TEST, 0, true);\n  EXPECT_DEATH(flag = true, \"\");\n  EXPECT_FALSE(flag);\n  EXPECT_EQ(0, factory_->AssumeRoleCalls());\n  EXPECT_EQ(0, factory_->WaitCalls());\n  EXPECT_EQ(0U, factory_->PassedCalls());\n  EXPECT_EQ(0U, factory_->AbortCalls());\n  EXPECT_FALSE(factory_->TestDeleted());\n}\n\n// Test that the parent process doesn't run the death test code,\n// and that the Passed method returns false when the (simulated)\n// child process exits with status 0:\nTEST_F(MacroLogicDeathTest, ChildExitsSuccessfully) {\n  bool flag = false;\n  factory_->SetParameters(true, DeathTest::OVERSEE_TEST, 0, true);\n  EXPECT_DEATH(flag = true, \"\");\n  EXPECT_FALSE(flag);\n  EXPECT_EQ(1, factory_->AssumeRoleCalls());\n  EXPECT_EQ(1, factory_->WaitCalls());\n  ASSERT_EQ(1U, factory_->PassedCalls());\n  EXPECT_FALSE(factory_->PassedArgument(0));\n  EXPECT_EQ(0U, factory_->AbortCalls());\n  EXPECT_TRUE(factory_->TestDeleted());\n}\n\n// Tests that the Passed method was given the argument \"true\" when\n// the (simulated) child process exits with status 1:\nTEST_F(MacroLogicDeathTest, ChildExitsUnsuccessfully) {\n  bool flag = false;\n  factory_->SetParameters(true, DeathTest::OVERSEE_TEST, 1, true);\n  EXPECT_DEATH(flag = true, \"\");\n  EXPECT_FALSE(flag);\n  EXPECT_EQ(1, factory_->AssumeRoleCalls());\n  EXPECT_EQ(1, factory_->WaitCalls());\n  ASSERT_EQ(1U, factory_->PassedCalls());\n  EXPECT_TRUE(factory_->PassedArgument(0));\n  EXPECT_EQ(0U, factory_->AbortCalls());\n  EXPECT_TRUE(factory_->TestDeleted());\n}\n\n// Tests that the (simulated) child process executes the death test\n// code, and is aborted with the correct AbortReason if it\n// executes a return statement.\nTEST_F(MacroLogicDeathTest, ChildPerformsReturn) {\n  bool flag = false;\n  factory_->SetParameters(true, DeathTest::EXECUTE_TEST, 0, true);\n  RunReturningDeathTest(&flag);\n  EXPECT_TRUE(flag);\n  EXPECT_EQ(1, factory_->AssumeRoleCalls());\n  EXPECT_EQ(0, factory_->WaitCalls());\n  EXPECT_EQ(0U, factory_->PassedCalls());\n  EXPECT_EQ(1U, factory_->AbortCalls());\n  EXPECT_EQ(DeathTest::TEST_ENCOUNTERED_RETURN_STATEMENT,\n            factory_->AbortArgument(0));\n  EXPECT_TRUE(factory_->TestDeleted());\n}\n\n// Tests that the (simulated) child process is aborted with the\n// correct AbortReason if it does not die.\nTEST_F(MacroLogicDeathTest, ChildDoesNotDie) {\n  bool flag = false;\n  factory_->SetParameters(true, DeathTest::EXECUTE_TEST, 0, true);\n  EXPECT_DEATH(flag = true, \"\");\n  EXPECT_TRUE(flag);\n  EXPECT_EQ(1, factory_->AssumeRoleCalls());\n  EXPECT_EQ(0, factory_->WaitCalls());\n  EXPECT_EQ(0U, factory_->PassedCalls());\n  // This time there are two calls to Abort: one since the test didn't\n  // die, and another from the ReturnSentinel when it's destroyed.  The\n  // sentinel normally isn't destroyed if a test doesn't die, since\n  // _exit(2) is called in that case by ForkingDeathTest, but not by\n  // our MockDeathTest.\n  ASSERT_EQ(2U, factory_->AbortCalls());\n  EXPECT_EQ(DeathTest::TEST_DID_NOT_DIE,\n            factory_->AbortArgument(0));\n  EXPECT_EQ(DeathTest::TEST_ENCOUNTERED_RETURN_STATEMENT,\n            factory_->AbortArgument(1));\n  EXPECT_TRUE(factory_->TestDeleted());\n}\n\n// Tests that a successful death test does not register a successful\n// test part.\nTEST(SuccessRegistrationDeathTest, NoSuccessPart) {\n  EXPECT_DEATH(_exit(1), \"\");\n  EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count());\n}\n\nTEST(StreamingAssertionsDeathTest, DeathTest) {\n  EXPECT_DEATH(_exit(1), \"\") << \"unexpected failure\";\n  ASSERT_DEATH(_exit(1), \"\") << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_DEATH(_exit(0), \"\") << \"expected failure\";\n  }, \"expected failure\");\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_DEATH(_exit(0), \"\") << \"expected failure\";\n  }, \"expected failure\");\n}\n\n// Tests that GetLastErrnoDescription returns an empty string when the\n// last error is 0 and non-empty string when it is non-zero.\nTEST(GetLastErrnoDescription, GetLastErrnoDescriptionWorks) {\n  errno = ENOENT;\n  EXPECT_STRNE(\"\", GetLastErrnoDescription().c_str());\n  errno = 0;\n  EXPECT_STREQ(\"\", GetLastErrnoDescription().c_str());\n}\n\n# if GTEST_OS_WINDOWS\nTEST(AutoHandleTest, AutoHandleWorks) {\n  HANDLE handle = ::CreateEvent(NULL, FALSE, FALSE, NULL);\n  ASSERT_NE(INVALID_HANDLE_VALUE, handle);\n\n  // Tests that the AutoHandle is correctly initialized with a handle.\n  testing::internal::AutoHandle auto_handle(handle);\n  EXPECT_EQ(handle, auto_handle.Get());\n\n  // Tests that Reset assigns INVALID_HANDLE_VALUE.\n  // Note that this cannot verify whether the original handle is closed.\n  auto_handle.Reset();\n  EXPECT_EQ(INVALID_HANDLE_VALUE, auto_handle.Get());\n\n  // Tests that Reset assigns the new handle.\n  // Note that this cannot verify whether the original handle is closed.\n  handle = ::CreateEvent(NULL, FALSE, FALSE, NULL);\n  ASSERT_NE(INVALID_HANDLE_VALUE, handle);\n  auto_handle.Reset(handle);\n  EXPECT_EQ(handle, auto_handle.Get());\n\n  // Tests that AutoHandle contains INVALID_HANDLE_VALUE by default.\n  testing::internal::AutoHandle auto_handle2;\n  EXPECT_EQ(INVALID_HANDLE_VALUE, auto_handle2.Get());\n}\n# endif  // GTEST_OS_WINDOWS\n\n# if GTEST_OS_WINDOWS\ntypedef unsigned __int64 BiggestParsable;\ntypedef signed __int64 BiggestSignedParsable;\n# else\ntypedef unsigned long long BiggestParsable;\ntypedef signed long long BiggestSignedParsable;\n# endif  // GTEST_OS_WINDOWS\n\n// We cannot use std::numeric_limits<T>::max() as it clashes with the\n// max() macro defined by <windows.h>.\nconst BiggestParsable kBiggestParsableMax = ULLONG_MAX;\nconst BiggestSignedParsable kBiggestSignedParsableMax = LLONG_MAX;\n\nTEST(ParseNaturalNumberTest, RejectsInvalidFormat) {\n  BiggestParsable result = 0;\n\n  // Rejects non-numbers.\n  EXPECT_FALSE(ParseNaturalNumber(\"non-number string\", &result));\n\n  // Rejects numbers with whitespace prefix.\n  EXPECT_FALSE(ParseNaturalNumber(\" 123\", &result));\n\n  // Rejects negative numbers.\n  EXPECT_FALSE(ParseNaturalNumber(\"-123\", &result));\n\n  // Rejects numbers starting with a plus sign.\n  EXPECT_FALSE(ParseNaturalNumber(\"+123\", &result));\n  errno = 0;\n}\n\nTEST(ParseNaturalNumberTest, RejectsOverflownNumbers) {\n  BiggestParsable result = 0;\n\n  EXPECT_FALSE(ParseNaturalNumber(\"99999999999999999999999\", &result));\n\n  signed char char_result = 0;\n  EXPECT_FALSE(ParseNaturalNumber(\"200\", &char_result));\n  errno = 0;\n}\n\nTEST(ParseNaturalNumberTest, AcceptsValidNumbers) {\n  BiggestParsable result = 0;\n\n  result = 0;\n  ASSERT_TRUE(ParseNaturalNumber(\"123\", &result));\n  EXPECT_EQ(123U, result);\n\n  // Check 0 as an edge case.\n  result = 1;\n  ASSERT_TRUE(ParseNaturalNumber(\"0\", &result));\n  EXPECT_EQ(0U, result);\n\n  result = 1;\n  ASSERT_TRUE(ParseNaturalNumber(\"00000\", &result));\n  EXPECT_EQ(0U, result);\n}\n\nTEST(ParseNaturalNumberTest, AcceptsTypeLimits) {\n  Message msg;\n  msg << kBiggestParsableMax;\n\n  BiggestParsable result = 0;\n  EXPECT_TRUE(ParseNaturalNumber(msg.GetString(), &result));\n  EXPECT_EQ(kBiggestParsableMax, result);\n\n  Message msg2;\n  msg2 << kBiggestSignedParsableMax;\n\n  BiggestSignedParsable signed_result = 0;\n  EXPECT_TRUE(ParseNaturalNumber(msg2.GetString(), &signed_result));\n  EXPECT_EQ(kBiggestSignedParsableMax, signed_result);\n\n  Message msg3;\n  msg3 << INT_MAX;\n\n  int int_result = 0;\n  EXPECT_TRUE(ParseNaturalNumber(msg3.GetString(), &int_result));\n  EXPECT_EQ(INT_MAX, int_result);\n\n  Message msg4;\n  msg4 << UINT_MAX;\n\n  unsigned int uint_result = 0;\n  EXPECT_TRUE(ParseNaturalNumber(msg4.GetString(), &uint_result));\n  EXPECT_EQ(UINT_MAX, uint_result);\n}\n\nTEST(ParseNaturalNumberTest, WorksForShorterIntegers) {\n  short short_result = 0;\n  ASSERT_TRUE(ParseNaturalNumber(\"123\", &short_result));\n  EXPECT_EQ(123, short_result);\n\n  signed char char_result = 0;\n  ASSERT_TRUE(ParseNaturalNumber(\"123\", &char_result));\n  EXPECT_EQ(123, char_result);\n}\n\n# if GTEST_OS_WINDOWS\nTEST(EnvironmentTest, HandleFitsIntoSizeT) {\n  // TODO(vladl@google.com): Remove this test after this condition is verified\n  // in a static assertion in gtest-death-test.cc in the function\n  // GetStatusFileDescriptor.\n  ASSERT_TRUE(sizeof(HANDLE) <= sizeof(size_t));\n}\n# endif  // GTEST_OS_WINDOWS\n\n// Tests that EXPECT_DEATH_IF_SUPPORTED/ASSERT_DEATH_IF_SUPPORTED trigger\n// failures when death tests are available on the system.\nTEST(ConditionalDeathMacrosDeathTest, ExpectsDeathWhenDeathTestsAvailable) {\n  EXPECT_DEATH_IF_SUPPORTED(DieInside(\"CondDeathTestExpectMacro\"),\n                            \"death inside CondDeathTestExpectMacro\");\n  ASSERT_DEATH_IF_SUPPORTED(DieInside(\"CondDeathTestAssertMacro\"),\n                            \"death inside CondDeathTestAssertMacro\");\n\n  // Empty statement will not crash, which must trigger a failure.\n  EXPECT_NONFATAL_FAILURE(EXPECT_DEATH_IF_SUPPORTED(;, \"\"), \"\");\n  EXPECT_FATAL_FAILURE(ASSERT_DEATH_IF_SUPPORTED(;, \"\"), \"\");\n}\n\nTEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInFastStyle) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_FALSE(InDeathTestChild());\n  EXPECT_DEATH({\n    fprintf(stderr, InDeathTestChild() ? \"Inside\" : \"Outside\");\n    fflush(stderr);\n    _exit(1);\n  }, \"Inside\");\n}\n\nTEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInThreadSafeStyle) {\n  testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n  EXPECT_FALSE(InDeathTestChild());\n  EXPECT_DEATH({\n    fprintf(stderr, InDeathTestChild() ? \"Inside\" : \"Outside\");\n    fflush(stderr);\n    _exit(1);\n  }, \"Inside\");\n}\n\n#else  // !GTEST_HAS_DEATH_TEST follows\n\nusing testing::internal::CaptureStderr;\nusing testing::internal::GetCapturedStderr;\n\n// Tests that EXPECT_DEATH_IF_SUPPORTED/ASSERT_DEATH_IF_SUPPORTED are still\n// defined but do not trigger failures when death tests are not available on\n// the system.\nTEST(ConditionalDeathMacrosTest, WarnsWhenDeathTestsNotAvailable) {\n  // Empty statement will not crash, but that should not trigger a failure\n  // when death tests are not supported.\n  CaptureStderr();\n  EXPECT_DEATH_IF_SUPPORTED(;, \"\");\n  std::string output = GetCapturedStderr();\n  ASSERT_TRUE(NULL != strstr(output.c_str(),\n                             \"Death tests are not supported on this platform\"));\n  ASSERT_TRUE(NULL != strstr(output.c_str(), \";\"));\n\n  // The streamed message should not be printed as there is no test failure.\n  CaptureStderr();\n  EXPECT_DEATH_IF_SUPPORTED(;, \"\") << \"streamed message\";\n  output = GetCapturedStderr();\n  ASSERT_TRUE(NULL == strstr(output.c_str(), \"streamed message\"));\n\n  CaptureStderr();\n  ASSERT_DEATH_IF_SUPPORTED(;, \"\");  // NOLINT\n  output = GetCapturedStderr();\n  ASSERT_TRUE(NULL != strstr(output.c_str(),\n                             \"Death tests are not supported on this platform\"));\n  ASSERT_TRUE(NULL != strstr(output.c_str(), \";\"));\n\n  CaptureStderr();\n  ASSERT_DEATH_IF_SUPPORTED(;, \"\") << \"streamed message\";  // NOLINT\n  output = GetCapturedStderr();\n  ASSERT_TRUE(NULL == strstr(output.c_str(), \"streamed message\"));\n}\n\nvoid FuncWithAssert(int* n) {\n  ASSERT_DEATH_IF_SUPPORTED(return;, \"\");\n  (*n)++;\n}\n\n// Tests that ASSERT_DEATH_IF_SUPPORTED does not return from the current\n// function (as ASSERT_DEATH does) if death tests are not supported.\nTEST(ConditionalDeathMacrosTest, AssertDeatDoesNotReturnhIfUnsupported) {\n  int n = 0;\n  FuncWithAssert(&n);\n  EXPECT_EQ(1, n);\n}\n\n#endif  // !GTEST_HAS_DEATH_TEST\n\n// Tests that the death test macros expand to code which may or may not\n// be followed by operator<<, and that in either case the complete text\n// comprises only a single C++ statement.\n//\n// The syntax should work whether death tests are available or not.\nTEST(ConditionalDeathMacrosSyntaxDeathTest, SingleStatement) {\n  if (AlwaysFalse())\n    // This would fail if executed; this is a compilation test only\n    ASSERT_DEATH_IF_SUPPORTED(return, \"\");\n\n  if (AlwaysTrue())\n    EXPECT_DEATH_IF_SUPPORTED(_exit(1), \"\");\n  else\n    // This empty \"else\" branch is meant to ensure that EXPECT_DEATH\n    // doesn't expand into an \"if\" statement without an \"else\"\n    ;  // NOLINT\n\n  if (AlwaysFalse())\n    ASSERT_DEATH_IF_SUPPORTED(return, \"\") << \"did not die\";\n\n  if (AlwaysFalse())\n    ;  // NOLINT\n  else\n    EXPECT_DEATH_IF_SUPPORTED(_exit(1), \"\") << 1 << 2 << 3;\n}\n\n// Tests that conditional death test macros expand to code which interacts\n// well with switch statements.\nTEST(ConditionalDeathMacrosSyntaxDeathTest, SwitchStatement) {\n  // Microsoft compiler usually complains about switch statements without\n  // case labels. We suppress that warning for this test.\n  GTEST_DISABLE_MSC_WARNINGS_PUSH_(4065)\n\n  switch (0)\n    default:\n      ASSERT_DEATH_IF_SUPPORTED(_exit(1), \"\")\n          << \"exit in default switch handler\";\n\n  switch (0)\n    case 0:\n      EXPECT_DEATH_IF_SUPPORTED(_exit(1), \"\") << \"exit in switch case\";\n\n  GTEST_DISABLE_MSC_WARNINGS_POP_()\n}\n\n// Tests that a test case whose name ends with \"DeathTest\" works fine\n// on Windows.\nTEST(NotADeathTest, Test) {\n  SUCCEED();\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-filepath_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: keith.ray@gmail.com (Keith Ray)\n//\n// Google Test filepath utilities\n//\n// This file tests classes and functions used internally by\n// Google Test.  They are subject to change without notice.\n//\n// This file is #included from gtest_unittest.cc, to avoid changing\n// build or make-files for some existing Google Test clients. Do not\n// #include this file anywhere else!\n\n#include \"gtest/internal/gtest-filepath.h\"\n#include \"gtest/gtest.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\n#if GTEST_OS_WINDOWS_MOBILE\n# include <windows.h>  // NOLINT\n#elif GTEST_OS_WINDOWS\n# include <direct.h>  // NOLINT\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\nnamespace testing {\nnamespace internal {\nnamespace {\n\n#if GTEST_OS_WINDOWS_MOBILE\n// TODO(wan@google.com): Move these to the POSIX adapter section in\n// gtest-port.h.\n\n// Windows CE doesn't have the remove C function.\nint remove(const char* path) {\n  LPCWSTR wpath = String::AnsiToUtf16(path);\n  int ret = DeleteFile(wpath) ? 0 : -1;\n  delete [] wpath;\n  return ret;\n}\n// Windows CE doesn't have the _rmdir C function.\nint _rmdir(const char* path) {\n  FilePath filepath(path);\n  LPCWSTR wpath = String::AnsiToUtf16(\n      filepath.RemoveTrailingPathSeparator().c_str());\n  int ret = RemoveDirectory(wpath) ? 0 : -1;\n  delete [] wpath;\n  return ret;\n}\n\n#else\n\nTEST(GetCurrentDirTest, ReturnsCurrentDir) {\n  const FilePath original_dir = FilePath::GetCurrentDir();\n  EXPECT_FALSE(original_dir.IsEmpty());\n\n  posix::ChDir(GTEST_PATH_SEP_);\n  const FilePath cwd = FilePath::GetCurrentDir();\n  posix::ChDir(original_dir.c_str());\n\n# if GTEST_OS_WINDOWS\n\n  // Skips the \":\".\n  const char* const cwd_without_drive = strchr(cwd.c_str(), ':');\n  ASSERT_TRUE(cwd_without_drive != NULL);\n  EXPECT_STREQ(GTEST_PATH_SEP_, cwd_without_drive + 1);\n\n# else\n\n  EXPECT_EQ(GTEST_PATH_SEP_, cwd.string());\n\n# endif\n}\n\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\nTEST(IsEmptyTest, ReturnsTrueForEmptyPath) {\n  EXPECT_TRUE(FilePath(\"\").IsEmpty());\n}\n\nTEST(IsEmptyTest, ReturnsFalseForNonEmptyPath) {\n  EXPECT_FALSE(FilePath(\"a\").IsEmpty());\n  EXPECT_FALSE(FilePath(\".\").IsEmpty());\n  EXPECT_FALSE(FilePath(\"a/b\").IsEmpty());\n  EXPECT_FALSE(FilePath(\"a\\\\b\\\\\").IsEmpty());\n}\n\n// RemoveDirectoryName \"\" -> \"\"\nTEST(RemoveDirectoryNameTest, WhenEmptyName) {\n  EXPECT_EQ(\"\", FilePath(\"\").RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName \"afile\" -> \"afile\"\nTEST(RemoveDirectoryNameTest, ButNoDirectory) {\n  EXPECT_EQ(\"afile\",\n      FilePath(\"afile\").RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName \"/afile\" -> \"afile\"\nTEST(RemoveDirectoryNameTest, RootFileShouldGiveFileName) {\n  EXPECT_EQ(\"afile\",\n      FilePath(GTEST_PATH_SEP_ \"afile\").RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName \"adir/\" -> \"\"\nTEST(RemoveDirectoryNameTest, WhereThereIsNoFileName) {\n  EXPECT_EQ(\"\",\n      FilePath(\"adir\" GTEST_PATH_SEP_).RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName \"adir/afile\" -> \"afile\"\nTEST(RemoveDirectoryNameTest, ShouldGiveFileName) {\n  EXPECT_EQ(\"afile\",\n      FilePath(\"adir\" GTEST_PATH_SEP_ \"afile\").RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName \"adir/subdir/afile\" -> \"afile\"\nTEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileName) {\n  EXPECT_EQ(\"afile\",\n      FilePath(\"adir\" GTEST_PATH_SEP_ \"subdir\" GTEST_PATH_SEP_ \"afile\")\n      .RemoveDirectoryName().string());\n}\n\n#if GTEST_HAS_ALT_PATH_SEP_\n\n// Tests that RemoveDirectoryName() works with the alternate separator\n// on Windows.\n\n// RemoveDirectoryName(\"/afile\") -> \"afile\"\nTEST(RemoveDirectoryNameTest, RootFileShouldGiveFileNameForAlternateSeparator) {\n  EXPECT_EQ(\"afile\", FilePath(\"/afile\").RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName(\"adir/\") -> \"\"\nTEST(RemoveDirectoryNameTest, WhereThereIsNoFileNameForAlternateSeparator) {\n  EXPECT_EQ(\"\", FilePath(\"adir/\").RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName(\"adir/afile\") -> \"afile\"\nTEST(RemoveDirectoryNameTest, ShouldGiveFileNameForAlternateSeparator) {\n  EXPECT_EQ(\"afile\", FilePath(\"adir/afile\").RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName(\"adir/subdir/afile\") -> \"afile\"\nTEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileNameForAlternateSeparator) {\n  EXPECT_EQ(\"afile\",\n            FilePath(\"adir/subdir/afile\").RemoveDirectoryName().string());\n}\n\n#endif\n\n// RemoveFileName \"\" -> \"./\"\nTEST(RemoveFileNameTest, EmptyName) {\n#if GTEST_OS_WINDOWS_MOBILE\n  // On Windows CE, we use the root as the current directory.\n  EXPECT_EQ(GTEST_PATH_SEP_, FilePath(\"\").RemoveFileName().string());\n#else\n  EXPECT_EQ(\".\" GTEST_PATH_SEP_, FilePath(\"\").RemoveFileName().string());\n#endif\n}\n\n// RemoveFileName \"adir/\" -> \"adir/\"\nTEST(RemoveFileNameTest, ButNoFile) {\n  EXPECT_EQ(\"adir\" GTEST_PATH_SEP_,\n      FilePath(\"adir\" GTEST_PATH_SEP_).RemoveFileName().string());\n}\n\n// RemoveFileName \"adir/afile\" -> \"adir/\"\nTEST(RemoveFileNameTest, GivesDirName) {\n  EXPECT_EQ(\"adir\" GTEST_PATH_SEP_,\n            FilePath(\"adir\" GTEST_PATH_SEP_ \"afile\").RemoveFileName().string());\n}\n\n// RemoveFileName \"adir/subdir/afile\" -> \"adir/subdir/\"\nTEST(RemoveFileNameTest, GivesDirAndSubDirName) {\n  EXPECT_EQ(\"adir\" GTEST_PATH_SEP_ \"subdir\" GTEST_PATH_SEP_,\n      FilePath(\"adir\" GTEST_PATH_SEP_ \"subdir\" GTEST_PATH_SEP_ \"afile\")\n      .RemoveFileName().string());\n}\n\n// RemoveFileName \"/afile\" -> \"/\"\nTEST(RemoveFileNameTest, GivesRootDir) {\n  EXPECT_EQ(GTEST_PATH_SEP_,\n      FilePath(GTEST_PATH_SEP_ \"afile\").RemoveFileName().string());\n}\n\n#if GTEST_HAS_ALT_PATH_SEP_\n\n// Tests that RemoveFileName() works with the alternate separator on\n// Windows.\n\n// RemoveFileName(\"adir/\") -> \"adir/\"\nTEST(RemoveFileNameTest, ButNoFileForAlternateSeparator) {\n  EXPECT_EQ(\"adir\" GTEST_PATH_SEP_,\n            FilePath(\"adir/\").RemoveFileName().string());\n}\n\n// RemoveFileName(\"adir/afile\") -> \"adir/\"\nTEST(RemoveFileNameTest, GivesDirNameForAlternateSeparator) {\n  EXPECT_EQ(\"adir\" GTEST_PATH_SEP_,\n            FilePath(\"adir/afile\").RemoveFileName().string());\n}\n\n// RemoveFileName(\"adir/subdir/afile\") -> \"adir/subdir/\"\nTEST(RemoveFileNameTest, GivesDirAndSubDirNameForAlternateSeparator) {\n  EXPECT_EQ(\"adir\" GTEST_PATH_SEP_ \"subdir\" GTEST_PATH_SEP_,\n            FilePath(\"adir/subdir/afile\").RemoveFileName().string());\n}\n\n// RemoveFileName(\"/afile\") -> \"\\\"\nTEST(RemoveFileNameTest, GivesRootDirForAlternateSeparator) {\n  EXPECT_EQ(GTEST_PATH_SEP_, FilePath(\"/afile\").RemoveFileName().string());\n}\n\n#endif\n\nTEST(MakeFileNameTest, GenerateWhenNumberIsZero) {\n  FilePath actual = FilePath::MakeFileName(FilePath(\"foo\"), FilePath(\"bar\"),\n      0, \"xml\");\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar.xml\", actual.string());\n}\n\nTEST(MakeFileNameTest, GenerateFileNameNumberGtZero) {\n  FilePath actual = FilePath::MakeFileName(FilePath(\"foo\"), FilePath(\"bar\"),\n      12, \"xml\");\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar_12.xml\", actual.string());\n}\n\nTEST(MakeFileNameTest, GenerateFileNameWithSlashNumberIsZero) {\n  FilePath actual = FilePath::MakeFileName(FilePath(\"foo\" GTEST_PATH_SEP_),\n      FilePath(\"bar\"), 0, \"xml\");\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar.xml\", actual.string());\n}\n\nTEST(MakeFileNameTest, GenerateFileNameWithSlashNumberGtZero) {\n  FilePath actual = FilePath::MakeFileName(FilePath(\"foo\" GTEST_PATH_SEP_),\n      FilePath(\"bar\"), 12, \"xml\");\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar_12.xml\", actual.string());\n}\n\nTEST(MakeFileNameTest, GenerateWhenNumberIsZeroAndDirIsEmpty) {\n  FilePath actual = FilePath::MakeFileName(FilePath(\"\"), FilePath(\"bar\"),\n      0, \"xml\");\n  EXPECT_EQ(\"bar.xml\", actual.string());\n}\n\nTEST(MakeFileNameTest, GenerateWhenNumberIsNotZeroAndDirIsEmpty) {\n  FilePath actual = FilePath::MakeFileName(FilePath(\"\"), FilePath(\"bar\"),\n      14, \"xml\");\n  EXPECT_EQ(\"bar_14.xml\", actual.string());\n}\n\nTEST(ConcatPathsTest, WorksWhenDirDoesNotEndWithPathSep) {\n  FilePath actual = FilePath::ConcatPaths(FilePath(\"foo\"),\n                                          FilePath(\"bar.xml\"));\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar.xml\", actual.string());\n}\n\nTEST(ConcatPathsTest, WorksWhenPath1EndsWithPathSep) {\n  FilePath actual = FilePath::ConcatPaths(FilePath(\"foo\" GTEST_PATH_SEP_),\n                                          FilePath(\"bar.xml\"));\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar.xml\", actual.string());\n}\n\nTEST(ConcatPathsTest, Path1BeingEmpty) {\n  FilePath actual = FilePath::ConcatPaths(FilePath(\"\"),\n                                          FilePath(\"bar.xml\"));\n  EXPECT_EQ(\"bar.xml\", actual.string());\n}\n\nTEST(ConcatPathsTest, Path2BeingEmpty) {\n  FilePath actual = FilePath::ConcatPaths(FilePath(\"foo\"), FilePath(\"\"));\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_, actual.string());\n}\n\nTEST(ConcatPathsTest, BothPathBeingEmpty) {\n  FilePath actual = FilePath::ConcatPaths(FilePath(\"\"),\n                                          FilePath(\"\"));\n  EXPECT_EQ(\"\", actual.string());\n}\n\nTEST(ConcatPathsTest, Path1ContainsPathSep) {\n  FilePath actual = FilePath::ConcatPaths(FilePath(\"foo\" GTEST_PATH_SEP_ \"bar\"),\n                                          FilePath(\"foobar.xml\"));\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\" GTEST_PATH_SEP_ \"foobar.xml\",\n            actual.string());\n}\n\nTEST(ConcatPathsTest, Path2ContainsPathSep) {\n  FilePath actual = FilePath::ConcatPaths(\n      FilePath(\"foo\" GTEST_PATH_SEP_),\n      FilePath(\"bar\" GTEST_PATH_SEP_ \"bar.xml\"));\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\" GTEST_PATH_SEP_ \"bar.xml\",\n            actual.string());\n}\n\nTEST(ConcatPathsTest, Path2EndsWithPathSep) {\n  FilePath actual = FilePath::ConcatPaths(FilePath(\"foo\"),\n                                          FilePath(\"bar\" GTEST_PATH_SEP_));\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\" GTEST_PATH_SEP_, actual.string());\n}\n\n// RemoveTrailingPathSeparator \"\" -> \"\"\nTEST(RemoveTrailingPathSeparatorTest, EmptyString) {\n  EXPECT_EQ(\"\", FilePath(\"\").RemoveTrailingPathSeparator().string());\n}\n\n// RemoveTrailingPathSeparator \"foo\" -> \"foo\"\nTEST(RemoveTrailingPathSeparatorTest, FileNoSlashString) {\n  EXPECT_EQ(\"foo\", FilePath(\"foo\").RemoveTrailingPathSeparator().string());\n}\n\n// RemoveTrailingPathSeparator \"foo/\" -> \"foo\"\nTEST(RemoveTrailingPathSeparatorTest, ShouldRemoveTrailingSeparator) {\n  EXPECT_EQ(\"foo\",\n      FilePath(\"foo\" GTEST_PATH_SEP_).RemoveTrailingPathSeparator().string());\n#if GTEST_HAS_ALT_PATH_SEP_\n  EXPECT_EQ(\"foo\", FilePath(\"foo/\").RemoveTrailingPathSeparator().string());\n#endif\n}\n\n// RemoveTrailingPathSeparator \"foo/bar/\" -> \"foo/bar/\"\nTEST(RemoveTrailingPathSeparatorTest, ShouldRemoveLastSeparator) {\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\",\n            FilePath(\"foo\" GTEST_PATH_SEP_ \"bar\" GTEST_PATH_SEP_)\n                .RemoveTrailingPathSeparator().string());\n}\n\n// RemoveTrailingPathSeparator \"foo/bar\" -> \"foo/bar\"\nTEST(RemoveTrailingPathSeparatorTest, ShouldReturnUnmodified) {\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\",\n            FilePath(\"foo\" GTEST_PATH_SEP_ \"bar\")\n                .RemoveTrailingPathSeparator().string());\n}\n\nTEST(DirectoryTest, RootDirectoryExists) {\n#if GTEST_OS_WINDOWS  // We are on Windows.\n  char current_drive[_MAX_PATH];  // NOLINT\n  current_drive[0] = static_cast<char>(_getdrive() + 'A' - 1);\n  current_drive[1] = ':';\n  current_drive[2] = '\\\\';\n  current_drive[3] = '\\0';\n  EXPECT_TRUE(FilePath(current_drive).DirectoryExists());\n#else\n  EXPECT_TRUE(FilePath(\"/\").DirectoryExists());\n#endif  // GTEST_OS_WINDOWS\n}\n\n#if GTEST_OS_WINDOWS\nTEST(DirectoryTest, RootOfWrongDriveDoesNotExists) {\n  const int saved_drive_ = _getdrive();\n  // Find a drive that doesn't exist. Start with 'Z' to avoid common ones.\n  for (char drive = 'Z'; drive >= 'A'; drive--)\n    if (_chdrive(drive - 'A' + 1) == -1) {\n      char non_drive[_MAX_PATH];  // NOLINT\n      non_drive[0] = drive;\n      non_drive[1] = ':';\n      non_drive[2] = '\\\\';\n      non_drive[3] = '\\0';\n      EXPECT_FALSE(FilePath(non_drive).DirectoryExists());\n      break;\n    }\n  _chdrive(saved_drive_);\n}\n#endif  // GTEST_OS_WINDOWS\n\n#if !GTEST_OS_WINDOWS_MOBILE\n// Windows CE _does_ consider an empty directory to exist.\nTEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) {\n  EXPECT_FALSE(FilePath(\"\").DirectoryExists());\n}\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\nTEST(DirectoryTest, CurrentDirectoryExists) {\n#if GTEST_OS_WINDOWS  // We are on Windows.\n# ifndef _WIN32_CE  // Windows CE doesn't have a current directory.\n\n  EXPECT_TRUE(FilePath(\".\").DirectoryExists());\n  EXPECT_TRUE(FilePath(\".\\\\\").DirectoryExists());\n\n# endif  // _WIN32_CE\n#else\n  EXPECT_TRUE(FilePath(\".\").DirectoryExists());\n  EXPECT_TRUE(FilePath(\"./\").DirectoryExists());\n#endif  // GTEST_OS_WINDOWS\n}\n\n// \"foo/bar\" == foo//bar\" == \"foo///bar\"\nTEST(NormalizeTest, MultipleConsecutiveSepaparatorsInMidstring) {\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\",\n            FilePath(\"foo\" GTEST_PATH_SEP_ \"bar\").string());\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\",\n            FilePath(\"foo\" GTEST_PATH_SEP_ GTEST_PATH_SEP_ \"bar\").string());\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\",\n            FilePath(\"foo\" GTEST_PATH_SEP_ GTEST_PATH_SEP_\n                     GTEST_PATH_SEP_ \"bar\").string());\n}\n\n// \"/bar\" == //bar\" == \"///bar\"\nTEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringStart) {\n  EXPECT_EQ(GTEST_PATH_SEP_ \"bar\",\n    FilePath(GTEST_PATH_SEP_ \"bar\").string());\n  EXPECT_EQ(GTEST_PATH_SEP_ \"bar\",\n    FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ \"bar\").string());\n  EXPECT_EQ(GTEST_PATH_SEP_ \"bar\",\n    FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_ \"bar\").string());\n}\n\n// \"foo/\" == foo//\" == \"foo///\"\nTEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringEnd) {\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_,\n    FilePath(\"foo\" GTEST_PATH_SEP_).string());\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_,\n    FilePath(\"foo\" GTEST_PATH_SEP_ GTEST_PATH_SEP_).string());\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_,\n    FilePath(\"foo\" GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_).string());\n}\n\n#if GTEST_HAS_ALT_PATH_SEP_\n\n// Tests that separators at the end of the string are normalized\n// regardless of their combination (e.g. \"foo\\\" ==\"foo/\\\" ==\n// \"foo\\\\/\").\nTEST(NormalizeTest, MixAlternateSeparatorAtStringEnd) {\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_,\n            FilePath(\"foo/\").string());\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_,\n            FilePath(\"foo\" GTEST_PATH_SEP_ \"/\").string());\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_,\n            FilePath(\"foo//\" GTEST_PATH_SEP_).string());\n}\n\n#endif\n\nTEST(AssignmentOperatorTest, DefaultAssignedToNonDefault) {\n  FilePath default_path;\n  FilePath non_default_path(\"path\");\n  non_default_path = default_path;\n  EXPECT_EQ(\"\", non_default_path.string());\n  EXPECT_EQ(\"\", default_path.string());  // RHS var is unchanged.\n}\n\nTEST(AssignmentOperatorTest, NonDefaultAssignedToDefault) {\n  FilePath non_default_path(\"path\");\n  FilePath default_path;\n  default_path = non_default_path;\n  EXPECT_EQ(\"path\", default_path.string());\n  EXPECT_EQ(\"path\", non_default_path.string());  // RHS var is unchanged.\n}\n\nTEST(AssignmentOperatorTest, ConstAssignedToNonConst) {\n  const FilePath const_default_path(\"const_path\");\n  FilePath non_default_path(\"path\");\n  non_default_path = const_default_path;\n  EXPECT_EQ(\"const_path\", non_default_path.string());\n}\n\nclass DirectoryCreationTest : public Test {\n protected:\n  virtual void SetUp() {\n    testdata_path_.Set(FilePath(\n        TempDir() + GetCurrentExecutableName().string() +\n        \"_directory_creation\" GTEST_PATH_SEP_ \"test\" GTEST_PATH_SEP_));\n    testdata_file_.Set(testdata_path_.RemoveTrailingPathSeparator());\n\n    unique_file0_.Set(FilePath::MakeFileName(testdata_path_, FilePath(\"unique\"),\n        0, \"txt\"));\n    unique_file1_.Set(FilePath::MakeFileName(testdata_path_, FilePath(\"unique\"),\n        1, \"txt\"));\n\n    remove(testdata_file_.c_str());\n    remove(unique_file0_.c_str());\n    remove(unique_file1_.c_str());\n    posix::RmDir(testdata_path_.c_str());\n  }\n\n  virtual void TearDown() {\n    remove(testdata_file_.c_str());\n    remove(unique_file0_.c_str());\n    remove(unique_file1_.c_str());\n    posix::RmDir(testdata_path_.c_str());\n  }\n\n  void CreateTextFile(const char* filename) {\n    FILE* f = posix::FOpen(filename, \"w\");\n    fprintf(f, \"text\\n\");\n    fclose(f);\n  }\n\n  // Strings representing a directory and a file, with identical paths\n  // except for the trailing separator character that distinquishes\n  // a directory named 'test' from a file named 'test'. Example names:\n  FilePath testdata_path_;  // \"/tmp/directory_creation/test/\"\n  FilePath testdata_file_;  // \"/tmp/directory_creation/test\"\n  FilePath unique_file0_;  // \"/tmp/directory_creation/test/unique.txt\"\n  FilePath unique_file1_;  // \"/tmp/directory_creation/test/unique_1.txt\"\n};\n\nTEST_F(DirectoryCreationTest, CreateDirectoriesRecursively) {\n  EXPECT_FALSE(testdata_path_.DirectoryExists()) << testdata_path_.string();\n  EXPECT_TRUE(testdata_path_.CreateDirectoriesRecursively());\n  EXPECT_TRUE(testdata_path_.DirectoryExists());\n}\n\nTEST_F(DirectoryCreationTest, CreateDirectoriesForAlreadyExistingPath) {\n  EXPECT_FALSE(testdata_path_.DirectoryExists()) << testdata_path_.string();\n  EXPECT_TRUE(testdata_path_.CreateDirectoriesRecursively());\n  // Call 'create' again... should still succeed.\n  EXPECT_TRUE(testdata_path_.CreateDirectoriesRecursively());\n}\n\nTEST_F(DirectoryCreationTest, CreateDirectoriesAndUniqueFilename) {\n  FilePath file_path(FilePath::GenerateUniqueFileName(testdata_path_,\n      FilePath(\"unique\"), \"txt\"));\n  EXPECT_EQ(unique_file0_.string(), file_path.string());\n  EXPECT_FALSE(file_path.FileOrDirectoryExists());  // file not there\n\n  testdata_path_.CreateDirectoriesRecursively();\n  EXPECT_FALSE(file_path.FileOrDirectoryExists());  // file still not there\n  CreateTextFile(file_path.c_str());\n  EXPECT_TRUE(file_path.FileOrDirectoryExists());\n\n  FilePath file_path2(FilePath::GenerateUniqueFileName(testdata_path_,\n      FilePath(\"unique\"), \"txt\"));\n  EXPECT_EQ(unique_file1_.string(), file_path2.string());\n  EXPECT_FALSE(file_path2.FileOrDirectoryExists());  // file not there\n  CreateTextFile(file_path2.c_str());\n  EXPECT_TRUE(file_path2.FileOrDirectoryExists());\n}\n\nTEST_F(DirectoryCreationTest, CreateDirectoriesFail) {\n  // force a failure by putting a file where we will try to create a directory.\n  CreateTextFile(testdata_file_.c_str());\n  EXPECT_TRUE(testdata_file_.FileOrDirectoryExists());\n  EXPECT_FALSE(testdata_file_.DirectoryExists());\n  EXPECT_FALSE(testdata_file_.CreateDirectoriesRecursively());\n}\n\nTEST(NoDirectoryCreationTest, CreateNoDirectoriesForDefaultXmlFile) {\n  const FilePath test_detail_xml(\"test_detail.xml\");\n  EXPECT_FALSE(test_detail_xml.CreateDirectoriesRecursively());\n}\n\nTEST(FilePathTest, DefaultConstructor) {\n  FilePath fp;\n  EXPECT_EQ(\"\", fp.string());\n}\n\nTEST(FilePathTest, CharAndCopyConstructors) {\n  const FilePath fp(\"spicy\");\n  EXPECT_EQ(\"spicy\", fp.string());\n\n  const FilePath fp_copy(fp);\n  EXPECT_EQ(\"spicy\", fp_copy.string());\n}\n\nTEST(FilePathTest, StringConstructor) {\n  const FilePath fp(std::string(\"cider\"));\n  EXPECT_EQ(\"cider\", fp.string());\n}\n\nTEST(FilePathTest, Set) {\n  const FilePath apple(\"apple\");\n  FilePath mac(\"mac\");\n  mac.Set(apple);  // Implement Set() since overloading operator= is forbidden.\n  EXPECT_EQ(\"apple\", mac.string());\n  EXPECT_EQ(\"apple\", apple.string());\n}\n\nTEST(FilePathTest, ToString) {\n  const FilePath file(\"drink\");\n  EXPECT_EQ(\"drink\", file.string());\n}\n\nTEST(FilePathTest, RemoveExtension) {\n  EXPECT_EQ(\"app\", FilePath(\"app.cc\").RemoveExtension(\"cc\").string());\n  EXPECT_EQ(\"app\", FilePath(\"app.exe\").RemoveExtension(\"exe\").string());\n  EXPECT_EQ(\"APP\", FilePath(\"APP.EXE\").RemoveExtension(\"exe\").string());\n}\n\nTEST(FilePathTest, RemoveExtensionWhenThereIsNoExtension) {\n  EXPECT_EQ(\"app\", FilePath(\"app\").RemoveExtension(\"exe\").string());\n}\n\nTEST(FilePathTest, IsDirectory) {\n  EXPECT_FALSE(FilePath(\"cola\").IsDirectory());\n  EXPECT_TRUE(FilePath(\"koala\" GTEST_PATH_SEP_).IsDirectory());\n#if GTEST_HAS_ALT_PATH_SEP_\n  EXPECT_TRUE(FilePath(\"koala/\").IsDirectory());\n#endif\n}\n\nTEST(FilePathTest, IsAbsolutePath) {\n  EXPECT_FALSE(FilePath(\"is\" GTEST_PATH_SEP_ \"relative\").IsAbsolutePath());\n  EXPECT_FALSE(FilePath(\"\").IsAbsolutePath());\n#if GTEST_OS_WINDOWS\n  EXPECT_TRUE(FilePath(\"c:\\\\\" GTEST_PATH_SEP_ \"is_not\"\n                       GTEST_PATH_SEP_ \"relative\").IsAbsolutePath());\n  EXPECT_FALSE(FilePath(\"c:foo\" GTEST_PATH_SEP_ \"bar\").IsAbsolutePath());\n  EXPECT_TRUE(FilePath(\"c:/\" GTEST_PATH_SEP_ \"is_not\"\n                       GTEST_PATH_SEP_ \"relative\").IsAbsolutePath());\n#else\n  EXPECT_TRUE(FilePath(GTEST_PATH_SEP_ \"is_not\" GTEST_PATH_SEP_ \"relative\")\n              .IsAbsolutePath());\n#endif  // GTEST_OS_WINDOWS\n}\n\nTEST(FilePathTest, IsRootDirectory) {\n#if GTEST_OS_WINDOWS\n  EXPECT_TRUE(FilePath(\"a:\\\\\").IsRootDirectory());\n  EXPECT_TRUE(FilePath(\"Z:/\").IsRootDirectory());\n  EXPECT_TRUE(FilePath(\"e://\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"b:\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"b:a\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"8:/\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"c|/\").IsRootDirectory());\n#else\n  EXPECT_TRUE(FilePath(\"/\").IsRootDirectory());\n  EXPECT_TRUE(FilePath(\"//\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"\\\\\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"/x\").IsRootDirectory());\n#endif\n}\n\n}  // namespace\n}  // namespace internal\n}  // namespace testing\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-linked_ptr_test.cc",
    "content": "// Copyright 2003, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: Dan Egnor (egnor@google.com)\n// Ported to Windows: Vadim Berman (vadimb@google.com)\n\n#include \"gtest/internal/gtest-linked_ptr.h\"\n\n#include <stdlib.h>\n#include \"gtest/gtest.h\"\n\nnamespace {\n\nusing testing::Message;\nusing testing::internal::linked_ptr;\n\nint num;\nMessage* history = NULL;\n\n// Class which tracks allocation/deallocation\nclass A {\n public:\n  A(): mynum(num++) { *history << \"A\" << mynum << \" ctor\\n\"; }\n  virtual ~A() { *history << \"A\" << mynum << \" dtor\\n\"; }\n  virtual void Use() { *history << \"A\" << mynum << \" use\\n\"; }\n protected:\n  int mynum;\n};\n\n// Subclass\nclass B : public A {\n public:\n  B() { *history << \"B\" << mynum << \" ctor\\n\"; }\n  ~B() { *history << \"B\" << mynum << \" dtor\\n\"; }\n  virtual void Use() { *history << \"B\" << mynum << \" use\\n\"; }\n};\n\nclass LinkedPtrTest : public testing::Test {\n public:\n  LinkedPtrTest() {\n    num = 0;\n    history = new Message;\n  }\n\n  virtual ~LinkedPtrTest() {\n    delete history;\n    history = NULL;\n  }\n};\n\nTEST_F(LinkedPtrTest, GeneralTest) {\n  {\n    linked_ptr<A> a0, a1, a2;\n    // Use explicit function call notation here to suppress self-assign warning.\n    a0.operator=(a0);\n    a1 = a2;\n    ASSERT_EQ(a0.get(), static_cast<A*>(NULL));\n    ASSERT_EQ(a1.get(), static_cast<A*>(NULL));\n    ASSERT_EQ(a2.get(), static_cast<A*>(NULL));\n    ASSERT_TRUE(a0 == NULL);\n    ASSERT_TRUE(a1 == NULL);\n    ASSERT_TRUE(a2 == NULL);\n\n    {\n      linked_ptr<A> a3(new A);\n      a0 = a3;\n      ASSERT_TRUE(a0 == a3);\n      ASSERT_TRUE(a0 != NULL);\n      ASSERT_TRUE(a0.get() == a3);\n      ASSERT_TRUE(a0 == a3.get());\n      linked_ptr<A> a4(a0);\n      a1 = a4;\n      linked_ptr<A> a5(new A);\n      ASSERT_TRUE(a5.get() != a3);\n      ASSERT_TRUE(a5 != a3.get());\n      a2 = a5;\n      linked_ptr<B> b0(new B);\n      linked_ptr<A> a6(b0);\n      ASSERT_TRUE(b0 == a6);\n      ASSERT_TRUE(a6 == b0);\n      ASSERT_TRUE(b0 != NULL);\n      a5 = b0;\n      a5 = b0;\n      a3->Use();\n      a4->Use();\n      a5->Use();\n      a6->Use();\n      b0->Use();\n      (*b0).Use();\n      b0.get()->Use();\n    }\n\n    a0->Use();\n    a1->Use();\n    a2->Use();\n\n    a1 = a2;\n    a2.reset(new A);\n    a0.reset();\n\n    linked_ptr<A> a7;\n  }\n\n  ASSERT_STREQ(\n    \"A0 ctor\\n\"\n    \"A1 ctor\\n\"\n    \"A2 ctor\\n\"\n    \"B2 ctor\\n\"\n    \"A0 use\\n\"\n    \"A0 use\\n\"\n    \"B2 use\\n\"\n    \"B2 use\\n\"\n    \"B2 use\\n\"\n    \"B2 use\\n\"\n    \"B2 use\\n\"\n    \"B2 dtor\\n\"\n    \"A2 dtor\\n\"\n    \"A0 use\\n\"\n    \"A0 use\\n\"\n    \"A1 use\\n\"\n    \"A3 ctor\\n\"\n    \"A0 dtor\\n\"\n    \"A3 dtor\\n\"\n    \"A1 dtor\\n\",\n    history->GetString().c_str());\n}\n\n}  // Unnamed namespace\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-listener_test.cc",
    "content": "// Copyright 2009 Google Inc. All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This file verifies Google Test event listeners receive events at the\n// right times.\n\n#include \"gtest/gtest.h\"\n#include <vector>\n\nusing ::testing::AddGlobalTestEnvironment;\nusing ::testing::Environment;\nusing ::testing::InitGoogleTest;\nusing ::testing::Test;\nusing ::testing::TestCase;\nusing ::testing::TestEventListener;\nusing ::testing::TestInfo;\nusing ::testing::TestPartResult;\nusing ::testing::UnitTest;\n\n// Used by tests to register their events.\nstd::vector<std::string>* g_events = NULL;\n\nnamespace testing {\nnamespace internal {\n\nclass EventRecordingListener : public TestEventListener {\n public:\n  explicit EventRecordingListener(const char* name) : name_(name) {}\n\n protected:\n  virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {\n    g_events->push_back(GetFullMethodName(\"OnTestProgramStart\"));\n  }\n\n  virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,\n                                    int iteration) {\n    Message message;\n    message << GetFullMethodName(\"OnTestIterationStart\")\n            << \"(\" << iteration << \")\";\n    g_events->push_back(message.GetString());\n  }\n\n  virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) {\n    g_events->push_back(GetFullMethodName(\"OnEnvironmentsSetUpStart\"));\n  }\n\n  virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {\n    g_events->push_back(GetFullMethodName(\"OnEnvironmentsSetUpEnd\"));\n  }\n\n  virtual void OnTestCaseStart(const TestCase& /*test_case*/) {\n    g_events->push_back(GetFullMethodName(\"OnTestCaseStart\"));\n  }\n\n  virtual void OnTestStart(const TestInfo& /*test_info*/) {\n    g_events->push_back(GetFullMethodName(\"OnTestStart\"));\n  }\n\n  virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) {\n    g_events->push_back(GetFullMethodName(\"OnTestPartResult\"));\n  }\n\n  virtual void OnTestEnd(const TestInfo& /*test_info*/) {\n    g_events->push_back(GetFullMethodName(\"OnTestEnd\"));\n  }\n\n  virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {\n    g_events->push_back(GetFullMethodName(\"OnTestCaseEnd\"));\n  }\n\n  virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {\n    g_events->push_back(GetFullMethodName(\"OnEnvironmentsTearDownStart\"));\n  }\n\n  virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {\n    g_events->push_back(GetFullMethodName(\"OnEnvironmentsTearDownEnd\"));\n  }\n\n  virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,\n                                  int iteration) {\n    Message message;\n    message << GetFullMethodName(\"OnTestIterationEnd\")\n            << \"(\"  << iteration << \")\";\n    g_events->push_back(message.GetString());\n  }\n\n  virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {\n    g_events->push_back(GetFullMethodName(\"OnTestProgramEnd\"));\n  }\n\n private:\n  std::string GetFullMethodName(const char* name) {\n    return name_ + \".\" + name;\n  }\n\n  std::string name_;\n};\n\nclass EnvironmentInvocationCatcher : public Environment {\n protected:\n  virtual void SetUp() {\n    g_events->push_back(\"Environment::SetUp\");\n  }\n\n  virtual void TearDown() {\n    g_events->push_back(\"Environment::TearDown\");\n  }\n};\n\nclass ListenerTest : public Test {\n protected:\n  static void SetUpTestCase() {\n    g_events->push_back(\"ListenerTest::SetUpTestCase\");\n  }\n\n  static void TearDownTestCase() {\n    g_events->push_back(\"ListenerTest::TearDownTestCase\");\n  }\n\n  virtual void SetUp() {\n    g_events->push_back(\"ListenerTest::SetUp\");\n  }\n\n  virtual void TearDown() {\n    g_events->push_back(\"ListenerTest::TearDown\");\n  }\n};\n\nTEST_F(ListenerTest, DoesFoo) {\n  // Test execution order within a test case is not guaranteed so we are not\n  // recording the test name.\n  g_events->push_back(\"ListenerTest::* Test Body\");\n  SUCCEED();  // Triggers OnTestPartResult.\n}\n\nTEST_F(ListenerTest, DoesBar) {\n  g_events->push_back(\"ListenerTest::* Test Body\");\n  SUCCEED();  // Triggers OnTestPartResult.\n}\n\n}  // namespace internal\n\n}  // namespace testing\n\nusing ::testing::internal::EnvironmentInvocationCatcher;\nusing ::testing::internal::EventRecordingListener;\n\nvoid VerifyResults(const std::vector<std::string>& data,\n                   const char* const* expected_data,\n                   size_t expected_data_size) {\n  const size_t actual_size = data.size();\n  // If the following assertion fails, a new entry will be appended to\n  // data.  Hence we save data.size() first.\n  EXPECT_EQ(expected_data_size, actual_size);\n\n  // Compares the common prefix.\n  const size_t shorter_size = expected_data_size <= actual_size ?\n      expected_data_size : actual_size;\n  size_t i = 0;\n  for (; i < shorter_size; ++i) {\n    ASSERT_STREQ(expected_data[i], data[i].c_str())\n        << \"at position \" << i;\n  }\n\n  // Prints extra elements in the actual data.\n  for (; i < actual_size; ++i) {\n    printf(\"  Actual event #%lu: %s\\n\",\n        static_cast<unsigned long>(i), data[i].c_str());\n  }\n}\n\nint main(int argc, char **argv) {\n  std::vector<std::string> events;\n  g_events = &events;\n  InitGoogleTest(&argc, argv);\n\n  UnitTest::GetInstance()->listeners().Append(\n      new EventRecordingListener(\"1st\"));\n  UnitTest::GetInstance()->listeners().Append(\n      new EventRecordingListener(\"2nd\"));\n\n  AddGlobalTestEnvironment(new EnvironmentInvocationCatcher);\n\n  GTEST_CHECK_(events.size() == 0)\n      << \"AddGlobalTestEnvironment should not generate any events itself.\";\n\n  ::testing::GTEST_FLAG(repeat) = 2;\n  int ret_val = RUN_ALL_TESTS();\n\n  const char* const expected_events[] = {\n    \"1st.OnTestProgramStart\",\n    \"2nd.OnTestProgramStart\",\n    \"1st.OnTestIterationStart(0)\",\n    \"2nd.OnTestIterationStart(0)\",\n    \"1st.OnEnvironmentsSetUpStart\",\n    \"2nd.OnEnvironmentsSetUpStart\",\n    \"Environment::SetUp\",\n    \"2nd.OnEnvironmentsSetUpEnd\",\n    \"1st.OnEnvironmentsSetUpEnd\",\n    \"1st.OnTestCaseStart\",\n    \"2nd.OnTestCaseStart\",\n    \"ListenerTest::SetUpTestCase\",\n    \"1st.OnTestStart\",\n    \"2nd.OnTestStart\",\n    \"ListenerTest::SetUp\",\n    \"ListenerTest::* Test Body\",\n    \"1st.OnTestPartResult\",\n    \"2nd.OnTestPartResult\",\n    \"ListenerTest::TearDown\",\n    \"2nd.OnTestEnd\",\n    \"1st.OnTestEnd\",\n    \"1st.OnTestStart\",\n    \"2nd.OnTestStart\",\n    \"ListenerTest::SetUp\",\n    \"ListenerTest::* Test Body\",\n    \"1st.OnTestPartResult\",\n    \"2nd.OnTestPartResult\",\n    \"ListenerTest::TearDown\",\n    \"2nd.OnTestEnd\",\n    \"1st.OnTestEnd\",\n    \"ListenerTest::TearDownTestCase\",\n    \"2nd.OnTestCaseEnd\",\n    \"1st.OnTestCaseEnd\",\n    \"1st.OnEnvironmentsTearDownStart\",\n    \"2nd.OnEnvironmentsTearDownStart\",\n    \"Environment::TearDown\",\n    \"2nd.OnEnvironmentsTearDownEnd\",\n    \"1st.OnEnvironmentsTearDownEnd\",\n    \"2nd.OnTestIterationEnd(0)\",\n    \"1st.OnTestIterationEnd(0)\",\n    \"1st.OnTestIterationStart(1)\",\n    \"2nd.OnTestIterationStart(1)\",\n    \"1st.OnEnvironmentsSetUpStart\",\n    \"2nd.OnEnvironmentsSetUpStart\",\n    \"Environment::SetUp\",\n    \"2nd.OnEnvironmentsSetUpEnd\",\n    \"1st.OnEnvironmentsSetUpEnd\",\n    \"1st.OnTestCaseStart\",\n    \"2nd.OnTestCaseStart\",\n    \"ListenerTest::SetUpTestCase\",\n    \"1st.OnTestStart\",\n    \"2nd.OnTestStart\",\n    \"ListenerTest::SetUp\",\n    \"ListenerTest::* Test Body\",\n    \"1st.OnTestPartResult\",\n    \"2nd.OnTestPartResult\",\n    \"ListenerTest::TearDown\",\n    \"2nd.OnTestEnd\",\n    \"1st.OnTestEnd\",\n    \"1st.OnTestStart\",\n    \"2nd.OnTestStart\",\n    \"ListenerTest::SetUp\",\n    \"ListenerTest::* Test Body\",\n    \"1st.OnTestPartResult\",\n    \"2nd.OnTestPartResult\",\n    \"ListenerTest::TearDown\",\n    \"2nd.OnTestEnd\",\n    \"1st.OnTestEnd\",\n    \"ListenerTest::TearDownTestCase\",\n    \"2nd.OnTestCaseEnd\",\n    \"1st.OnTestCaseEnd\",\n    \"1st.OnEnvironmentsTearDownStart\",\n    \"2nd.OnEnvironmentsTearDownStart\",\n    \"Environment::TearDown\",\n    \"2nd.OnEnvironmentsTearDownEnd\",\n    \"1st.OnEnvironmentsTearDownEnd\",\n    \"2nd.OnTestIterationEnd(1)\",\n    \"1st.OnTestIterationEnd(1)\",\n    \"2nd.OnTestProgramEnd\",\n    \"1st.OnTestProgramEnd\"\n  };\n  VerifyResults(events,\n                expected_events,\n                sizeof(expected_events)/sizeof(expected_events[0]));\n\n  // We need to check manually for ad hoc test failures that happen after\n  // RUN_ALL_TESTS finishes.\n  if (UnitTest::GetInstance()->Failed())\n    ret_val = 1;\n\n  return ret_val;\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-message_test.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Tests for the Message class.\n\n#include \"gtest/gtest-message.h\"\n\n#include \"gtest/gtest.h\"\n\nnamespace {\n\nusing ::testing::Message;\n\n// Tests the testing::Message class\n\n// Tests the default constructor.\nTEST(MessageTest, DefaultConstructor) {\n  const Message msg;\n  EXPECT_EQ(\"\", msg.GetString());\n}\n\n// Tests the copy constructor.\nTEST(MessageTest, CopyConstructor) {\n  const Message msg1(\"Hello\");\n  const Message msg2(msg1);\n  EXPECT_EQ(\"Hello\", msg2.GetString());\n}\n\n// Tests constructing a Message from a C-string.\nTEST(MessageTest, ConstructsFromCString) {\n  Message msg(\"Hello\");\n  EXPECT_EQ(\"Hello\", msg.GetString());\n}\n\n// Tests streaming a float.\nTEST(MessageTest, StreamsFloat) {\n  const std::string s = (Message() << 1.23456F << \" \" << 2.34567F).GetString();\n  // Both numbers should be printed with enough precision.\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"1.234560\", s.c_str());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \" 2.345669\", s.c_str());\n}\n\n// Tests streaming a double.\nTEST(MessageTest, StreamsDouble) {\n  const std::string s = (Message() << 1260570880.4555497 << \" \"\n                                  << 1260572265.1954534).GetString();\n  // Both numbers should be printed with enough precision.\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"1260570880.45\", s.c_str());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \" 1260572265.19\", s.c_str());\n}\n\n// Tests streaming a non-char pointer.\nTEST(MessageTest, StreamsPointer) {\n  int n = 0;\n  int* p = &n;\n  EXPECT_NE(\"(null)\", (Message() << p).GetString());\n}\n\n// Tests streaming a NULL non-char pointer.\nTEST(MessageTest, StreamsNullPointer) {\n  int* p = NULL;\n  EXPECT_EQ(\"(null)\", (Message() << p).GetString());\n}\n\n// Tests streaming a C string.\nTEST(MessageTest, StreamsCString) {\n  EXPECT_EQ(\"Foo\", (Message() << \"Foo\").GetString());\n}\n\n// Tests streaming a NULL C string.\nTEST(MessageTest, StreamsNullCString) {\n  char* p = NULL;\n  EXPECT_EQ(\"(null)\", (Message() << p).GetString());\n}\n\n// Tests streaming std::string.\nTEST(MessageTest, StreamsString) {\n  const ::std::string str(\"Hello\");\n  EXPECT_EQ(\"Hello\", (Message() << str).GetString());\n}\n\n// Tests that we can output strings containing embedded NULs.\nTEST(MessageTest, StreamsStringWithEmbeddedNUL) {\n  const char char_array_with_nul[] =\n      \"Here's a NUL\\0 and some more string\";\n  const ::std::string string_with_nul(char_array_with_nul,\n                                      sizeof(char_array_with_nul) - 1);\n  EXPECT_EQ(\"Here's a NUL\\\\0 and some more string\",\n            (Message() << string_with_nul).GetString());\n}\n\n// Tests streaming a NUL char.\nTEST(MessageTest, StreamsNULChar) {\n  EXPECT_EQ(\"\\\\0\", (Message() << '\\0').GetString());\n}\n\n// Tests streaming int.\nTEST(MessageTest, StreamsInt) {\n  EXPECT_EQ(\"123\", (Message() << 123).GetString());\n}\n\n// Tests that basic IO manipulators (endl, ends, and flush) can be\n// streamed to Message.\nTEST(MessageTest, StreamsBasicIoManip) {\n  EXPECT_EQ(\"Line 1.\\nA NUL char \\\\0 in line 2.\",\n               (Message() << \"Line 1.\" << std::endl\n                         << \"A NUL char \" << std::ends << std::flush\n                         << \" in line 2.\").GetString());\n}\n\n// Tests Message::GetString()\nTEST(MessageTest, GetString) {\n  Message msg;\n  msg << 1 << \" lamb\";\n  EXPECT_EQ(\"1 lamb\", msg.GetString());\n}\n\n// Tests streaming a Message object to an ostream.\nTEST(MessageTest, StreamsToOStream) {\n  Message msg(\"Hello\");\n  ::std::stringstream ss;\n  ss << msg;\n  EXPECT_EQ(\"Hello\", testing::internal::StringStreamToString(&ss));\n}\n\n// Tests that a Message object doesn't take up too much stack space.\nTEST(MessageTest, DoesNotTakeUpMuchStackSpace) {\n  EXPECT_LE(sizeof(Message), 16U);\n}\n\n}  // namespace\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-options_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: keith.ray@gmail.com (Keith Ray)\n//\n// Google Test UnitTestOptions tests\n//\n// This file tests classes and functions used internally by\n// Google Test.  They are subject to change without notice.\n//\n// This file is #included from gtest.cc, to avoid changing build or\n// make-files on Windows and other platforms. Do not #include this file\n// anywhere else!\n\n#include \"gtest/gtest.h\"\n\n#if GTEST_OS_WINDOWS_MOBILE\n# include <windows.h>\n#elif GTEST_OS_WINDOWS\n# include <direct.h>\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nnamespace testing {\nnamespace internal {\nnamespace {\n\n// Turns the given relative path into an absolute path.\nFilePath GetAbsolutePathOf(const FilePath& relative_path) {\n  return FilePath::ConcatPaths(FilePath::GetCurrentDir(), relative_path);\n}\n\n// Testing UnitTestOptions::GetOutputFormat/GetOutputFile.\n\nTEST(XmlOutputTest, GetOutputFormatDefault) {\n  GTEST_FLAG(output) = \"\";\n  EXPECT_STREQ(\"\", UnitTestOptions::GetOutputFormat().c_str());\n}\n\nTEST(XmlOutputTest, GetOutputFormat) {\n  GTEST_FLAG(output) = \"xml:filename\";\n  EXPECT_STREQ(\"xml\", UnitTestOptions::GetOutputFormat().c_str());\n}\n\nTEST(XmlOutputTest, GetOutputFileDefault) {\n  GTEST_FLAG(output) = \"\";\n  EXPECT_EQ(GetAbsolutePathOf(FilePath(\"test_detail.xml\")).string(),\n            UnitTestOptions::GetAbsolutePathToOutputFile());\n}\n\nTEST(XmlOutputTest, GetOutputFileSingleFile) {\n  GTEST_FLAG(output) = \"xml:filename.abc\";\n  EXPECT_EQ(GetAbsolutePathOf(FilePath(\"filename.abc\")).string(),\n            UnitTestOptions::GetAbsolutePathToOutputFile());\n}\n\nTEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {\n  GTEST_FLAG(output) = \"xml:path\" GTEST_PATH_SEP_;\n  const std::string expected_output_file =\n      GetAbsolutePathOf(\n          FilePath(std::string(\"path\") + GTEST_PATH_SEP_ +\n                   GetCurrentExecutableName().string() + \".xml\")).string();\n  const std::string& output_file =\n      UnitTestOptions::GetAbsolutePathToOutputFile();\n#if GTEST_OS_WINDOWS\n  EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());\n#else\n  EXPECT_EQ(expected_output_file, output_file.c_str());\n#endif\n}\n\nTEST(OutputFileHelpersTest, GetCurrentExecutableName) {\n  const std::string exe_str = GetCurrentExecutableName().string();\n#if GTEST_OS_WINDOWS\n  const bool success =\n      _strcmpi(\"gtest-options_test\", exe_str.c_str()) == 0 ||\n      _strcmpi(\"gtest-options-ex_test\", exe_str.c_str()) == 0 ||\n      _strcmpi(\"gtest_all_test\", exe_str.c_str()) == 0 ||\n      _strcmpi(\"gtest_dll_test\", exe_str.c_str()) == 0;\n#else\n  // TODO(wan@google.com): remove the hard-coded \"lt-\" prefix when\n  //   Chandler Carruth's libtool replacement is ready.\n  const bool success =\n      exe_str == \"gtest-options_test\" ||\n      exe_str == \"gtest_all_test\" ||\n      exe_str == \"lt-gtest_all_test\" ||\n      exe_str == \"gtest_dll_test\";\n#endif  // GTEST_OS_WINDOWS\n  if (!success)\n    FAIL() << \"GetCurrentExecutableName() returns \" << exe_str;\n}\n\nclass XmlOutputChangeDirTest : public Test {\n protected:\n  virtual void SetUp() {\n    original_working_dir_ = FilePath::GetCurrentDir();\n    posix::ChDir(\"..\");\n    // This will make the test fail if run from the root directory.\n    EXPECT_NE(original_working_dir_.string(),\n              FilePath::GetCurrentDir().string());\n  }\n\n  virtual void TearDown() {\n    posix::ChDir(original_working_dir_.string().c_str());\n  }\n\n  FilePath original_working_dir_;\n};\n\nTEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefault) {\n  GTEST_FLAG(output) = \"\";\n  EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_,\n                                  FilePath(\"test_detail.xml\")).string(),\n            UnitTestOptions::GetAbsolutePathToOutputFile());\n}\n\nTEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefaultXML) {\n  GTEST_FLAG(output) = \"xml\";\n  EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_,\n                                  FilePath(\"test_detail.xml\")).string(),\n            UnitTestOptions::GetAbsolutePathToOutputFile());\n}\n\nTEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativeFile) {\n  GTEST_FLAG(output) = \"xml:filename.abc\";\n  EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_,\n                                  FilePath(\"filename.abc\")).string(),\n            UnitTestOptions::GetAbsolutePathToOutputFile());\n}\n\nTEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {\n  GTEST_FLAG(output) = \"xml:path\" GTEST_PATH_SEP_;\n  const std::string expected_output_file =\n      FilePath::ConcatPaths(\n          original_working_dir_,\n          FilePath(std::string(\"path\") + GTEST_PATH_SEP_ +\n                   GetCurrentExecutableName().string() + \".xml\")).string();\n  const std::string& output_file =\n      UnitTestOptions::GetAbsolutePathToOutputFile();\n#if GTEST_OS_WINDOWS\n  EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());\n#else\n  EXPECT_EQ(expected_output_file, output_file.c_str());\n#endif\n}\n\nTEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) {\n#if GTEST_OS_WINDOWS\n  GTEST_FLAG(output) = \"xml:c:\\\\tmp\\\\filename.abc\";\n  EXPECT_EQ(FilePath(\"c:\\\\tmp\\\\filename.abc\").string(),\n            UnitTestOptions::GetAbsolutePathToOutputFile());\n#else\n  GTEST_FLAG(output) =\"xml:/tmp/filename.abc\";\n  EXPECT_EQ(FilePath(\"/tmp/filename.abc\").string(),\n            UnitTestOptions::GetAbsolutePathToOutputFile());\n#endif\n}\n\nTEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) {\n#if GTEST_OS_WINDOWS\n  const std::string path = \"c:\\\\tmp\\\\\";\n#else\n  const std::string path = \"/tmp/\";\n#endif\n\n  GTEST_FLAG(output) = \"xml:\" + path;\n  const std::string expected_output_file =\n      path + GetCurrentExecutableName().string() + \".xml\";\n  const std::string& output_file =\n      UnitTestOptions::GetAbsolutePathToOutputFile();\n\n#if GTEST_OS_WINDOWS\n  EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());\n#else\n  EXPECT_EQ(expected_output_file, output_file.c_str());\n#endif\n}\n\n}  // namespace\n}  // namespace internal\n}  // namespace testing\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-param-test2_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n//\n// Tests for Google Test itself.  This verifies that the basic constructs of\n// Google Test work.\n\n#include \"gtest/gtest.h\"\n\n#include \"test/gtest-param-test_test.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\nusing ::testing::Values;\nusing ::testing::internal::ParamGenerator;\n\n// Tests that generators defined in a different translation unit\n// are functional. The test using extern_gen is defined\n// in gtest-param-test_test.cc.\nParamGenerator<int> extern_gen = Values(33);\n\n// Tests that a parameterized test case can be defined in one translation unit\n// and instantiated in another. The test is defined in gtest-param-test_test.cc\n// and ExternalInstantiationTest fixture class is defined in\n// gtest-param-test_test.h.\nINSTANTIATE_TEST_CASE_P(MultiplesOf33,\n                        ExternalInstantiationTest,\n                        Values(33, 66));\n\n// Tests that a parameterized test case can be instantiated\n// in multiple translation units. Another instantiation is defined\n// in gtest-param-test_test.cc and InstantiationInMultipleTranslaionUnitsTest\n// fixture is defined in gtest-param-test_test.h\nINSTANTIATE_TEST_CASE_P(Sequence2,\n                        InstantiationInMultipleTranslaionUnitsTest,\n                        Values(42*3, 42*4, 42*5));\n\n#endif  // GTEST_HAS_PARAM_TEST\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-param-test_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n//\n// Tests for Google Test itself. This file verifies that the parameter\n// generators objects produce correct parameter sequences and that\n// Google Test runtime instantiates correct tests from those sequences.\n\n#include \"gtest/gtest.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\n# include <algorithm>\n# include <iostream>\n# include <list>\n# include <sstream>\n# include <string>\n# include <vector>\n\n// To include gtest-internal-inl.h.\n# define GTEST_IMPLEMENTATION_ 1\n# include \"src/gtest-internal-inl.h\"  // for UnitTestOptions\n# undef GTEST_IMPLEMENTATION_\n\n# include \"test/gtest-param-test_test.h\"\n\nusing ::std::vector;\nusing ::std::sort;\n\nusing ::testing::AddGlobalTestEnvironment;\nusing ::testing::Bool;\nusing ::testing::Message;\nusing ::testing::Range;\nusing ::testing::TestWithParam;\nusing ::testing::Values;\nusing ::testing::ValuesIn;\n\n# if GTEST_HAS_COMBINE\nusing ::testing::Combine;\nusing ::testing::get;\nusing ::testing::make_tuple;\nusing ::testing::tuple;\n# endif  // GTEST_HAS_COMBINE\n\nusing ::testing::internal::ParamGenerator;\nusing ::testing::internal::UnitTestOptions;\n\n// Prints a value to a string.\n//\n// TODO(wan@google.com): remove PrintValue() when we move matchers and\n// EXPECT_THAT() from Google Mock to Google Test.  At that time, we\n// can write EXPECT_THAT(x, Eq(y)) to compare two tuples x and y, as\n// EXPECT_THAT() and the matchers know how to print tuples.\ntemplate <typename T>\n::std::string PrintValue(const T& value) {\n  ::std::stringstream stream;\n  stream << value;\n  return stream.str();\n}\n\n# if GTEST_HAS_COMBINE\n\n// These overloads allow printing tuples in our tests.  We cannot\n// define an operator<< for tuples, as that definition needs to be in\n// the std namespace in order to be picked up by Google Test via\n// Argument-Dependent Lookup, yet defining anything in the std\n// namespace in non-STL code is undefined behavior.\n\ntemplate <typename T1, typename T2>\n::std::string PrintValue(const tuple<T1, T2>& value) {\n  ::std::stringstream stream;\n  stream << \"(\" << get<0>(value) << \", \" << get<1>(value) << \")\";\n  return stream.str();\n}\n\ntemplate <typename T1, typename T2, typename T3>\n::std::string PrintValue(const tuple<T1, T2, T3>& value) {\n  ::std::stringstream stream;\n  stream << \"(\" << get<0>(value) << \", \" << get<1>(value)\n         << \", \"<< get<2>(value) << \")\";\n  return stream.str();\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n          typename T6, typename T7, typename T8, typename T9, typename T10>\n::std::string PrintValue(\n    const tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& value) {\n  ::std::stringstream stream;\n  stream << \"(\" << get<0>(value) << \", \" << get<1>(value)\n         << \", \"<< get<2>(value) << \", \" << get<3>(value)\n         << \", \"<< get<4>(value) << \", \" << get<5>(value)\n         << \", \"<< get<6>(value) << \", \" << get<7>(value)\n         << \", \"<< get<8>(value) << \", \" << get<9>(value) << \")\";\n  return stream.str();\n}\n\n# endif  // GTEST_HAS_COMBINE\n\n// Verifies that a sequence generated by the generator and accessed\n// via the iterator object matches the expected one using Google Test\n// assertions.\ntemplate <typename T, size_t N>\nvoid VerifyGenerator(const ParamGenerator<T>& generator,\n                     const T (&expected_values)[N]) {\n  typename ParamGenerator<T>::iterator it = generator.begin();\n  for (size_t i = 0; i < N; ++i) {\n    ASSERT_FALSE(it == generator.end())\n        << \"At element \" << i << \" when accessing via an iterator \"\n        << \"created with the copy constructor.\\n\";\n    // We cannot use EXPECT_EQ() here as the values may be tuples,\n    // which don't support <<.\n    EXPECT_TRUE(expected_values[i] == *it)\n        << \"where i is \" << i\n        << \", expected_values[i] is \" << PrintValue(expected_values[i])\n        << \", *it is \" << PrintValue(*it)\n        << \", and 'it' is an iterator created with the copy constructor.\\n\";\n    it++;\n  }\n  EXPECT_TRUE(it == generator.end())\n        << \"At the presumed end of sequence when accessing via an iterator \"\n        << \"created with the copy constructor.\\n\";\n\n  // Test the iterator assignment. The following lines verify that\n  // the sequence accessed via an iterator initialized via the\n  // assignment operator (as opposed to a copy constructor) matches\n  // just the same.\n  it = generator.begin();\n  for (size_t i = 0; i < N; ++i) {\n    ASSERT_FALSE(it == generator.end())\n        << \"At element \" << i << \" when accessing via an iterator \"\n        << \"created with the assignment operator.\\n\";\n    EXPECT_TRUE(expected_values[i] == *it)\n        << \"where i is \" << i\n        << \", expected_values[i] is \" << PrintValue(expected_values[i])\n        << \", *it is \" << PrintValue(*it)\n        << \", and 'it' is an iterator created with the copy constructor.\\n\";\n    it++;\n  }\n  EXPECT_TRUE(it == generator.end())\n        << \"At the presumed end of sequence when accessing via an iterator \"\n        << \"created with the assignment operator.\\n\";\n}\n\ntemplate <typename T>\nvoid VerifyGeneratorIsEmpty(const ParamGenerator<T>& generator) {\n  typename ParamGenerator<T>::iterator it = generator.begin();\n  EXPECT_TRUE(it == generator.end());\n\n  it = generator.begin();\n  EXPECT_TRUE(it == generator.end());\n}\n\n// Generator tests. They test that each of the provided generator functions\n// generates an expected sequence of values. The general test pattern\n// instantiates a generator using one of the generator functions,\n// checks the sequence produced by the generator using its iterator API,\n// and then resets the iterator back to the beginning of the sequence\n// and checks the sequence again.\n\n// Tests that iterators produced by generator functions conform to the\n// ForwardIterator concept.\nTEST(IteratorTest, ParamIteratorConformsToForwardIteratorConcept) {\n  const ParamGenerator<int> gen = Range(0, 10);\n  ParamGenerator<int>::iterator it = gen.begin();\n\n  // Verifies that iterator initialization works as expected.\n  ParamGenerator<int>::iterator it2 = it;\n  EXPECT_TRUE(*it == *it2) << \"Initialized iterators must point to the \"\n                           << \"element same as its source points to\";\n\n  // Verifies that iterator assignment works as expected.\n  it++;\n  EXPECT_FALSE(*it == *it2);\n  it2 = it;\n  EXPECT_TRUE(*it == *it2) << \"Assigned iterators must point to the \"\n                           << \"element same as its source points to\";\n\n  // Verifies that prefix operator++() returns *this.\n  EXPECT_EQ(&it, &(++it)) << \"Result of the prefix operator++ must be \"\n                          << \"refer to the original object\";\n\n  // Verifies that the result of the postfix operator++ points to the value\n  // pointed to by the original iterator.\n  int original_value = *it;  // Have to compute it outside of macro call to be\n                             // unaffected by the parameter evaluation order.\n  EXPECT_EQ(original_value, *(it++));\n\n  // Verifies that prefix and postfix operator++() advance an iterator\n  // all the same.\n  it2 = it;\n  it++;\n  ++it2;\n  EXPECT_TRUE(*it == *it2);\n}\n\n// Tests that Range() generates the expected sequence.\nTEST(RangeTest, IntRangeWithDefaultStep) {\n  const ParamGenerator<int> gen = Range(0, 3);\n  const int expected_values[] = {0, 1, 2};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Edge case. Tests that Range() generates the single element sequence\n// as expected when provided with range limits that are equal.\nTEST(RangeTest, IntRangeSingleValue) {\n  const ParamGenerator<int> gen = Range(0, 1);\n  const int expected_values[] = {0};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Edge case. Tests that Range() with generates empty sequence when\n// supplied with an empty range.\nTEST(RangeTest, IntRangeEmpty) {\n  const ParamGenerator<int> gen = Range(0, 0);\n  VerifyGeneratorIsEmpty(gen);\n}\n\n// Tests that Range() with custom step (greater then one) generates\n// the expected sequence.\nTEST(RangeTest, IntRangeWithCustomStep) {\n  const ParamGenerator<int> gen = Range(0, 9, 3);\n  const int expected_values[] = {0, 3, 6};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that Range() with custom step (greater then one) generates\n// the expected sequence when the last element does not fall on the\n// upper range limit. Sequences generated by Range() must not have\n// elements beyond the range limits.\nTEST(RangeTest, IntRangeWithCustomStepOverUpperBound) {\n  const ParamGenerator<int> gen = Range(0, 4, 3);\n  const int expected_values[] = {0, 3};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Verifies that Range works with user-defined types that define\n// copy constructor, operator=(), operator+(), and operator<().\nclass DogAdder {\n public:\n  explicit DogAdder(const char* a_value) : value_(a_value) {}\n  DogAdder(const DogAdder& other) : value_(other.value_.c_str()) {}\n\n  DogAdder operator=(const DogAdder& other) {\n    if (this != &other)\n      value_ = other.value_;\n    return *this;\n  }\n  DogAdder operator+(const DogAdder& other) const {\n    Message msg;\n    msg << value_.c_str() << other.value_.c_str();\n    return DogAdder(msg.GetString().c_str());\n  }\n  bool operator<(const DogAdder& other) const {\n    return value_ < other.value_;\n  }\n  const std::string& value() const { return value_; }\n\n private:\n  std::string value_;\n};\n\nTEST(RangeTest, WorksWithACustomType) {\n  const ParamGenerator<DogAdder> gen =\n      Range(DogAdder(\"cat\"), DogAdder(\"catdogdog\"), DogAdder(\"dog\"));\n  ParamGenerator<DogAdder>::iterator it = gen.begin();\n\n  ASSERT_FALSE(it == gen.end());\n  EXPECT_STREQ(\"cat\", it->value().c_str());\n\n  ASSERT_FALSE(++it == gen.end());\n  EXPECT_STREQ(\"catdog\", it->value().c_str());\n\n  EXPECT_TRUE(++it == gen.end());\n}\n\nclass IntWrapper {\n public:\n  explicit IntWrapper(int a_value) : value_(a_value) {}\n  IntWrapper(const IntWrapper& other) : value_(other.value_) {}\n\n  IntWrapper operator=(const IntWrapper& other) {\n    value_ = other.value_;\n    return *this;\n  }\n  // operator+() adds a different type.\n  IntWrapper operator+(int other) const { return IntWrapper(value_ + other); }\n  bool operator<(const IntWrapper& other) const {\n    return value_ < other.value_;\n  }\n  int value() const { return value_; }\n\n private:\n  int value_;\n};\n\nTEST(RangeTest, WorksWithACustomTypeWithDifferentIncrementType) {\n  const ParamGenerator<IntWrapper> gen = Range(IntWrapper(0), IntWrapper(2));\n  ParamGenerator<IntWrapper>::iterator it = gen.begin();\n\n  ASSERT_FALSE(it == gen.end());\n  EXPECT_EQ(0, it->value());\n\n  ASSERT_FALSE(++it == gen.end());\n  EXPECT_EQ(1, it->value());\n\n  EXPECT_TRUE(++it == gen.end());\n}\n\n// Tests that ValuesIn() with an array parameter generates\n// the expected sequence.\nTEST(ValuesInTest, ValuesInArray) {\n  int array[] = {3, 5, 8};\n  const ParamGenerator<int> gen = ValuesIn(array);\n  VerifyGenerator(gen, array);\n}\n\n// Tests that ValuesIn() with a const array parameter generates\n// the expected sequence.\nTEST(ValuesInTest, ValuesInConstArray) {\n  const int array[] = {3, 5, 8};\n  const ParamGenerator<int> gen = ValuesIn(array);\n  VerifyGenerator(gen, array);\n}\n\n// Edge case. Tests that ValuesIn() with an array parameter containing a\n// single element generates the single element sequence.\nTEST(ValuesInTest, ValuesInSingleElementArray) {\n  int array[] = {42};\n  const ParamGenerator<int> gen = ValuesIn(array);\n  VerifyGenerator(gen, array);\n}\n\n// Tests that ValuesIn() generates the expected sequence for an STL\n// container (vector).\nTEST(ValuesInTest, ValuesInVector) {\n  typedef ::std::vector<int> ContainerType;\n  ContainerType values;\n  values.push_back(3);\n  values.push_back(5);\n  values.push_back(8);\n  const ParamGenerator<int> gen = ValuesIn(values);\n\n  const int expected_values[] = {3, 5, 8};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that ValuesIn() generates the expected sequence.\nTEST(ValuesInTest, ValuesInIteratorRange) {\n  typedef ::std::vector<int> ContainerType;\n  ContainerType values;\n  values.push_back(3);\n  values.push_back(5);\n  values.push_back(8);\n  const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());\n\n  const int expected_values[] = {3, 5, 8};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Edge case. Tests that ValuesIn() provided with an iterator range specifying a\n// single value generates a single-element sequence.\nTEST(ValuesInTest, ValuesInSingleElementIteratorRange) {\n  typedef ::std::vector<int> ContainerType;\n  ContainerType values;\n  values.push_back(42);\n  const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());\n\n  const int expected_values[] = {42};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Edge case. Tests that ValuesIn() provided with an empty iterator range\n// generates an empty sequence.\nTEST(ValuesInTest, ValuesInEmptyIteratorRange) {\n  typedef ::std::vector<int> ContainerType;\n  ContainerType values;\n  const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());\n\n  VerifyGeneratorIsEmpty(gen);\n}\n\n// Tests that the Values() generates the expected sequence.\nTEST(ValuesTest, ValuesWorks) {\n  const ParamGenerator<int> gen = Values(3, 5, 8);\n\n  const int expected_values[] = {3, 5, 8};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that Values() generates the expected sequences from elements of\n// different types convertible to ParamGenerator's parameter type.\nTEST(ValuesTest, ValuesWorksForValuesOfCompatibleTypes) {\n  const ParamGenerator<double> gen = Values(3, 5.0f, 8.0);\n\n  const double expected_values[] = {3.0, 5.0, 8.0};\n  VerifyGenerator(gen, expected_values);\n}\n\nTEST(ValuesTest, ValuesWorksForMaxLengthList) {\n  const ParamGenerator<int> gen = Values(\n      10, 20, 30, 40, 50, 60, 70, 80, 90, 100,\n      110, 120, 130, 140, 150, 160, 170, 180, 190, 200,\n      210, 220, 230, 240, 250, 260, 270, 280, 290, 300,\n      310, 320, 330, 340, 350, 360, 370, 380, 390, 400,\n      410, 420, 430, 440, 450, 460, 470, 480, 490, 500);\n\n  const int expected_values[] = {\n      10, 20, 30, 40, 50, 60, 70, 80, 90, 100,\n      110, 120, 130, 140, 150, 160, 170, 180, 190, 200,\n      210, 220, 230, 240, 250, 260, 270, 280, 290, 300,\n      310, 320, 330, 340, 350, 360, 370, 380, 390, 400,\n      410, 420, 430, 440, 450, 460, 470, 480, 490, 500};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Edge case test. Tests that single-parameter Values() generates the sequence\n// with the single value.\nTEST(ValuesTest, ValuesWithSingleParameter) {\n  const ParamGenerator<int> gen = Values(42);\n\n  const int expected_values[] = {42};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that Bool() generates sequence (false, true).\nTEST(BoolTest, BoolWorks) {\n  const ParamGenerator<bool> gen = Bool();\n\n  const bool expected_values[] = {false, true};\n  VerifyGenerator(gen, expected_values);\n}\n\n# if GTEST_HAS_COMBINE\n\n// Tests that Combine() with two parameters generates the expected sequence.\nTEST(CombineTest, CombineWithTwoParameters) {\n  const char* foo = \"foo\";\n  const char* bar = \"bar\";\n  const ParamGenerator<tuple<const char*, int> > gen =\n      Combine(Values(foo, bar), Values(3, 4));\n\n  tuple<const char*, int> expected_values[] = {\n    make_tuple(foo, 3), make_tuple(foo, 4),\n    make_tuple(bar, 3), make_tuple(bar, 4)};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that Combine() with three parameters generates the expected sequence.\nTEST(CombineTest, CombineWithThreeParameters) {\n  const ParamGenerator<tuple<int, int, int> > gen = Combine(Values(0, 1),\n                                                            Values(3, 4),\n                                                            Values(5, 6));\n  tuple<int, int, int> expected_values[] = {\n    make_tuple(0, 3, 5), make_tuple(0, 3, 6),\n    make_tuple(0, 4, 5), make_tuple(0, 4, 6),\n    make_tuple(1, 3, 5), make_tuple(1, 3, 6),\n    make_tuple(1, 4, 5), make_tuple(1, 4, 6)};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that the Combine() with the first parameter generating a single value\n// sequence generates a sequence with the number of elements equal to the\n// number of elements in the sequence generated by the second parameter.\nTEST(CombineTest, CombineWithFirstParameterSingleValue) {\n  const ParamGenerator<tuple<int, int> > gen = Combine(Values(42),\n                                                       Values(0, 1));\n\n  tuple<int, int> expected_values[] = {make_tuple(42, 0), make_tuple(42, 1)};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that the Combine() with the second parameter generating a single value\n// sequence generates a sequence with the number of elements equal to the\n// number of elements in the sequence generated by the first parameter.\nTEST(CombineTest, CombineWithSecondParameterSingleValue) {\n  const ParamGenerator<tuple<int, int> > gen = Combine(Values(0, 1),\n                                                       Values(42));\n\n  tuple<int, int> expected_values[] = {make_tuple(0, 42), make_tuple(1, 42)};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that when the first parameter produces an empty sequence,\n// Combine() produces an empty sequence, too.\nTEST(CombineTest, CombineWithFirstParameterEmptyRange) {\n  const ParamGenerator<tuple<int, int> > gen = Combine(Range(0, 0),\n                                                       Values(0, 1));\n  VerifyGeneratorIsEmpty(gen);\n}\n\n// Tests that when the second parameter produces an empty sequence,\n// Combine() produces an empty sequence, too.\nTEST(CombineTest, CombineWithSecondParameterEmptyRange) {\n  const ParamGenerator<tuple<int, int> > gen = Combine(Values(0, 1),\n                                                       Range(1, 1));\n  VerifyGeneratorIsEmpty(gen);\n}\n\n// Edge case. Tests that combine works with the maximum number\n// of parameters supported by Google Test (currently 10).\nTEST(CombineTest, CombineWithMaxNumberOfParameters) {\n  const char* foo = \"foo\";\n  const char* bar = \"bar\";\n  const ParamGenerator<tuple<const char*, int, int, int, int, int, int, int,\n                             int, int> > gen = Combine(Values(foo, bar),\n                                                       Values(1), Values(2),\n                                                       Values(3), Values(4),\n                                                       Values(5), Values(6),\n                                                       Values(7), Values(8),\n                                                       Values(9));\n\n  tuple<const char*, int, int, int, int, int, int, int, int, int>\n      expected_values[] = {make_tuple(foo, 1, 2, 3, 4, 5, 6, 7, 8, 9),\n                           make_tuple(bar, 1, 2, 3, 4, 5, 6, 7, 8, 9)};\n  VerifyGenerator(gen, expected_values);\n}\n\n# endif  // GTEST_HAS_COMBINE\n\n// Tests that an generator produces correct sequence after being\n// assigned from another generator.\nTEST(ParamGeneratorTest, AssignmentWorks) {\n  ParamGenerator<int> gen = Values(1, 2);\n  const ParamGenerator<int> gen2 = Values(3, 4);\n  gen = gen2;\n\n  const int expected_values[] = {3, 4};\n  VerifyGenerator(gen, expected_values);\n}\n\n// This test verifies that the tests are expanded and run as specified:\n// one test per element from the sequence produced by the generator\n// specified in INSTANTIATE_TEST_CASE_P. It also verifies that the test's\n// fixture constructor, SetUp(), and TearDown() have run and have been\n// supplied with the correct parameters.\n\n// The use of environment object allows detection of the case where no test\n// case functionality is run at all. In this case TestCaseTearDown will not\n// be able to detect missing tests, naturally.\ntemplate <int kExpectedCalls>\nclass TestGenerationEnvironment : public ::testing::Environment {\n public:\n  static TestGenerationEnvironment* Instance() {\n    static TestGenerationEnvironment* instance = new TestGenerationEnvironment;\n    return instance;\n  }\n\n  void FixtureConstructorExecuted() { fixture_constructor_count_++; }\n  void SetUpExecuted() { set_up_count_++; }\n  void TearDownExecuted() { tear_down_count_++; }\n  void TestBodyExecuted() { test_body_count_++; }\n\n  virtual void TearDown() {\n    // If all MultipleTestGenerationTest tests have been de-selected\n    // by the filter flag, the following checks make no sense.\n    bool perform_check = false;\n\n    for (int i = 0; i < kExpectedCalls; ++i) {\n      Message msg;\n      msg << \"TestsExpandedAndRun/\" << i;\n      if (UnitTestOptions::FilterMatchesTest(\n             \"TestExpansionModule/MultipleTestGenerationTest\",\n              msg.GetString().c_str())) {\n        perform_check = true;\n      }\n    }\n    if (perform_check) {\n      EXPECT_EQ(kExpectedCalls, fixture_constructor_count_)\n          << \"Fixture constructor of ParamTestGenerationTest test case \"\n          << \"has not been run as expected.\";\n      EXPECT_EQ(kExpectedCalls, set_up_count_)\n          << \"Fixture SetUp method of ParamTestGenerationTest test case \"\n          << \"has not been run as expected.\";\n      EXPECT_EQ(kExpectedCalls, tear_down_count_)\n          << \"Fixture TearDown method of ParamTestGenerationTest test case \"\n          << \"has not been run as expected.\";\n      EXPECT_EQ(kExpectedCalls, test_body_count_)\n          << \"Test in ParamTestGenerationTest test case \"\n          << \"has not been run as expected.\";\n    }\n  }\n\n private:\n  TestGenerationEnvironment() : fixture_constructor_count_(0), set_up_count_(0),\n                                tear_down_count_(0), test_body_count_(0) {}\n\n  int fixture_constructor_count_;\n  int set_up_count_;\n  int tear_down_count_;\n  int test_body_count_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestGenerationEnvironment);\n};\n\nconst int test_generation_params[] = {36, 42, 72};\n\nclass TestGenerationTest : public TestWithParam<int> {\n public:\n  enum {\n    PARAMETER_COUNT =\n        sizeof(test_generation_params)/sizeof(test_generation_params[0])\n  };\n\n  typedef TestGenerationEnvironment<PARAMETER_COUNT> Environment;\n\n  TestGenerationTest() {\n    Environment::Instance()->FixtureConstructorExecuted();\n    current_parameter_ = GetParam();\n  }\n  virtual void SetUp() {\n    Environment::Instance()->SetUpExecuted();\n    EXPECT_EQ(current_parameter_, GetParam());\n  }\n  virtual void TearDown() {\n    Environment::Instance()->TearDownExecuted();\n    EXPECT_EQ(current_parameter_, GetParam());\n  }\n\n  static void SetUpTestCase() {\n    bool all_tests_in_test_case_selected = true;\n\n    for (int i = 0; i < PARAMETER_COUNT; ++i) {\n      Message test_name;\n      test_name << \"TestsExpandedAndRun/\" << i;\n      if ( !UnitTestOptions::FilterMatchesTest(\n                \"TestExpansionModule/MultipleTestGenerationTest\",\n                test_name.GetString())) {\n        all_tests_in_test_case_selected = false;\n      }\n    }\n    EXPECT_TRUE(all_tests_in_test_case_selected)\n        << \"When running the TestGenerationTest test case all of its tests\\n\"\n        << \"must be selected by the filter flag for the test case to pass.\\n\"\n        << \"If not all of them are enabled, we can't reliably conclude\\n\"\n        << \"that the correct number of tests have been generated.\";\n\n    collected_parameters_.clear();\n  }\n\n  static void TearDownTestCase() {\n    vector<int> expected_values(test_generation_params,\n                                test_generation_params + PARAMETER_COUNT);\n    // Test execution order is not guaranteed by Google Test,\n    // so the order of values in collected_parameters_ can be\n    // different and we have to sort to compare.\n    sort(expected_values.begin(), expected_values.end());\n    sort(collected_parameters_.begin(), collected_parameters_.end());\n\n    EXPECT_TRUE(collected_parameters_ == expected_values);\n  }\n\n protected:\n  int current_parameter_;\n  static vector<int> collected_parameters_;\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestGenerationTest);\n};\nvector<int> TestGenerationTest::collected_parameters_;\n\nTEST_P(TestGenerationTest, TestsExpandedAndRun) {\n  Environment::Instance()->TestBodyExecuted();\n  EXPECT_EQ(current_parameter_, GetParam());\n  collected_parameters_.push_back(GetParam());\n}\nINSTANTIATE_TEST_CASE_P(TestExpansionModule, TestGenerationTest,\n                        ValuesIn(test_generation_params));\n\n// This test verifies that the element sequence (third parameter of\n// INSTANTIATE_TEST_CASE_P) is evaluated in InitGoogleTest() and neither at\n// the call site of INSTANTIATE_TEST_CASE_P nor in RUN_ALL_TESTS().  For\n// that, we declare param_value_ to be a static member of\n// GeneratorEvaluationTest and initialize it to 0.  We set it to 1 in\n// main(), just before invocation of InitGoogleTest().  After calling\n// InitGoogleTest(), we set the value to 2.  If the sequence is evaluated\n// before or after InitGoogleTest, INSTANTIATE_TEST_CASE_P will create a\n// test with parameter other than 1, and the test body will fail the\n// assertion.\nclass GeneratorEvaluationTest : public TestWithParam<int> {\n public:\n  static int param_value() { return param_value_; }\n  static void set_param_value(int param_value) { param_value_ = param_value; }\n\n private:\n  static int param_value_;\n};\nint GeneratorEvaluationTest::param_value_ = 0;\n\nTEST_P(GeneratorEvaluationTest, GeneratorsEvaluatedInMain) {\n  EXPECT_EQ(1, GetParam());\n}\nINSTANTIATE_TEST_CASE_P(GenEvalModule,\n                        GeneratorEvaluationTest,\n                        Values(GeneratorEvaluationTest::param_value()));\n\n// Tests that generators defined in a different translation unit are\n// functional. Generator extern_gen is defined in gtest-param-test_test2.cc.\nextern ParamGenerator<int> extern_gen;\nclass ExternalGeneratorTest : public TestWithParam<int> {};\nTEST_P(ExternalGeneratorTest, ExternalGenerator) {\n  // Sequence produced by extern_gen contains only a single value\n  // which we verify here.\n  EXPECT_EQ(GetParam(), 33);\n}\nINSTANTIATE_TEST_CASE_P(ExternalGeneratorModule,\n                        ExternalGeneratorTest,\n                        extern_gen);\n\n// Tests that a parameterized test case can be defined in one translation\n// unit and instantiated in another. This test will be instantiated in\n// gtest-param-test_test2.cc. ExternalInstantiationTest fixture class is\n// defined in gtest-param-test_test.h.\nTEST_P(ExternalInstantiationTest, IsMultipleOf33) {\n  EXPECT_EQ(0, GetParam() % 33);\n}\n\n// Tests that a parameterized test case can be instantiated with multiple\n// generators.\nclass MultipleInstantiationTest : public TestWithParam<int> {};\nTEST_P(MultipleInstantiationTest, AllowsMultipleInstances) {\n}\nINSTANTIATE_TEST_CASE_P(Sequence1, MultipleInstantiationTest, Values(1, 2));\nINSTANTIATE_TEST_CASE_P(Sequence2, MultipleInstantiationTest, Range(3, 5));\n\n// Tests that a parameterized test case can be instantiated\n// in multiple translation units. This test will be instantiated\n// here and in gtest-param-test_test2.cc.\n// InstantiationInMultipleTranslationUnitsTest fixture class\n// is defined in gtest-param-test_test.h.\nTEST_P(InstantiationInMultipleTranslaionUnitsTest, IsMultipleOf42) {\n  EXPECT_EQ(0, GetParam() % 42);\n}\nINSTANTIATE_TEST_CASE_P(Sequence1,\n                        InstantiationInMultipleTranslaionUnitsTest,\n                        Values(42, 42*2));\n\n// Tests that each iteration of parameterized test runs in a separate test\n// object.\nclass SeparateInstanceTest : public TestWithParam<int> {\n public:\n  SeparateInstanceTest() : count_(0) {}\n\n  static void TearDownTestCase() {\n    EXPECT_GE(global_count_, 2)\n        << \"If some (but not all) SeparateInstanceTest tests have been \"\n        << \"filtered out this test will fail. Make sure that all \"\n        << \"GeneratorEvaluationTest are selected or de-selected together \"\n        << \"by the test filter.\";\n  }\n\n protected:\n  int count_;\n  static int global_count_;\n};\nint SeparateInstanceTest::global_count_ = 0;\n\nTEST_P(SeparateInstanceTest, TestsRunInSeparateInstances) {\n  EXPECT_EQ(0, count_++);\n  global_count_++;\n}\nINSTANTIATE_TEST_CASE_P(FourElemSequence, SeparateInstanceTest, Range(1, 4));\n\n// Tests that all instantiations of a test have named appropriately. Test\n// defined with TEST_P(TestCaseName, TestName) and instantiated with\n// INSTANTIATE_TEST_CASE_P(SequenceName, TestCaseName, generator) must be named\n// SequenceName/TestCaseName.TestName/i, where i is the 0-based index of the\n// sequence element used to instantiate the test.\nclass NamingTest : public TestWithParam<int> {};\n\nTEST_P(NamingTest, TestsReportCorrectNamesAndParameters) {\n  const ::testing::TestInfo* const test_info =\n     ::testing::UnitTest::GetInstance()->current_test_info();\n\n  EXPECT_STREQ(\"ZeroToFiveSequence/NamingTest\", test_info->test_case_name());\n\n  Message index_stream;\n  index_stream << \"TestsReportCorrectNamesAndParameters/\" << GetParam();\n  EXPECT_STREQ(index_stream.GetString().c_str(), test_info->name());\n\n  EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());\n}\n\nINSTANTIATE_TEST_CASE_P(ZeroToFiveSequence, NamingTest, Range(0, 5));\n\n// Tests that user supplied custom parameter names are working correctly.\n// Runs the test with a builtin helper method which uses PrintToString,\n// as well as a custom function and custom functor to ensure all possible\n// uses work correctly.\nclass CustomFunctorNamingTest : public TestWithParam<std::string> {};\nTEST_P(CustomFunctorNamingTest, CustomTestNames) {}\n\nstruct CustomParamNameFunctor {\n  std::string operator()(const ::testing::TestParamInfo<std::string>& info) {\n    return info.param;\n  }\n};\n\nINSTANTIATE_TEST_CASE_P(CustomParamNameFunctor,\n                        CustomFunctorNamingTest,\n                        Values(std::string(\"FunctorName\")),\n                        CustomParamNameFunctor());\n\nINSTANTIATE_TEST_CASE_P(AllAllowedCharacters,\n                        CustomFunctorNamingTest,\n                        Values(\"abcdefghijklmnopqrstuvwxyz\",\n                               \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",\n                               \"01234567890_\"),\n                        CustomParamNameFunctor());\n\ninline std::string CustomParamNameFunction(\n    const ::testing::TestParamInfo<std::string>& info) {\n  return info.param;\n}\n\nclass CustomFunctionNamingTest : public TestWithParam<std::string> {};\nTEST_P(CustomFunctionNamingTest, CustomTestNames) {}\n\nINSTANTIATE_TEST_CASE_P(CustomParamNameFunction,\n                        CustomFunctionNamingTest,\n                        Values(std::string(\"FunctionName\")),\n                        CustomParamNameFunction);\n\n#if GTEST_LANG_CXX11\n\n// Test custom naming with a lambda\n\nclass CustomLambdaNamingTest : public TestWithParam<std::string> {};\nTEST_P(CustomLambdaNamingTest, CustomTestNames) {}\n\nINSTANTIATE_TEST_CASE_P(CustomParamNameLambda,\n                        CustomLambdaNamingTest,\n                        Values(std::string(\"LambdaName\")),\n                        [](const ::testing::TestParamInfo<std::string>& info) {\n                          return info.param;\n                        });\n\n#endif  // GTEST_LANG_CXX11\n\nTEST(CustomNamingTest, CheckNameRegistry) {\n  ::testing::UnitTest* unit_test = ::testing::UnitTest::GetInstance();\n  std::set<std::string> test_names;\n  for (int case_num = 0;\n       case_num < unit_test->total_test_case_count();\n       ++case_num) {\n    const ::testing::TestCase* test_case = unit_test->GetTestCase(case_num);\n    for (int test_num = 0;\n         test_num < test_case->total_test_count();\n         ++test_num) {\n      const ::testing::TestInfo* test_info = test_case->GetTestInfo(test_num);\n      test_names.insert(std::string(test_info->name()));\n    }\n  }\n  EXPECT_EQ(1u, test_names.count(\"CustomTestNames/FunctorName\"));\n  EXPECT_EQ(1u, test_names.count(\"CustomTestNames/FunctionName\"));\n#if GTEST_LANG_CXX11\n  EXPECT_EQ(1u, test_names.count(\"CustomTestNames/LambdaName\"));\n#endif  // GTEST_LANG_CXX11\n}\n\n// Test a numeric name to ensure PrintToStringParamName works correctly.\n\nclass CustomIntegerNamingTest : public TestWithParam<int> {};\n\nTEST_P(CustomIntegerNamingTest, TestsReportCorrectNames) {\n  const ::testing::TestInfo* const test_info =\n     ::testing::UnitTest::GetInstance()->current_test_info();\n  Message test_name_stream;\n  test_name_stream << \"TestsReportCorrectNames/\" << GetParam();\n  EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());\n}\n\nINSTANTIATE_TEST_CASE_P(PrintToString,\n                        CustomIntegerNamingTest,\n                        Range(0, 5),\n                        ::testing::PrintToStringParamName());\n\n// Test a custom struct with PrintToString.\n\nstruct CustomStruct {\n  explicit CustomStruct(int value) : x(value) {}\n  int x;\n};\n\nstd::ostream& operator<<(std::ostream& stream, const CustomStruct& val) {\n  stream << val.x;\n  return stream;\n}\n\nclass CustomStructNamingTest : public TestWithParam<CustomStruct> {};\n\nTEST_P(CustomStructNamingTest, TestsReportCorrectNames) {\n  const ::testing::TestInfo* const test_info =\n     ::testing::UnitTest::GetInstance()->current_test_info();\n  Message test_name_stream;\n  test_name_stream << \"TestsReportCorrectNames/\" << GetParam();\n  EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());\n}\n\nINSTANTIATE_TEST_CASE_P(PrintToString,\n                        CustomStructNamingTest,\n                        Values(CustomStruct(0), CustomStruct(1)),\n                        ::testing::PrintToStringParamName());\n\n// Test that using a stateful parameter naming function works as expected.\n\nstruct StatefulNamingFunctor {\n  StatefulNamingFunctor() : sum(0) {}\n  std::string operator()(const ::testing::TestParamInfo<int>& info) {\n    int value = info.param + sum;\n    sum += info.param;\n    return ::testing::PrintToString(value);\n  }\n  int sum;\n};\n\nclass StatefulNamingTest : public ::testing::TestWithParam<int> {\n protected:\n  StatefulNamingTest() : sum_(0) {}\n  int sum_;\n};\n\nTEST_P(StatefulNamingTest, TestsReportCorrectNames) {\n  const ::testing::TestInfo* const test_info =\n     ::testing::UnitTest::GetInstance()->current_test_info();\n  sum_ += GetParam();\n  Message test_name_stream;\n  test_name_stream << \"TestsReportCorrectNames/\" << sum_;\n  EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());\n}\n\nINSTANTIATE_TEST_CASE_P(StatefulNamingFunctor,\n                        StatefulNamingTest,\n                        Range(0, 5),\n                        StatefulNamingFunctor());\n\n// Class that cannot be streamed into an ostream.  It needs to be copyable\n// (and, in case of MSVC, also assignable) in order to be a test parameter\n// type.  Its default copy constructor and assignment operator do exactly\n// what we need.\nclass Unstreamable {\n public:\n  explicit Unstreamable(int value) : value_(value) {}\n\n private:\n  int value_;\n};\n\nclass CommentTest : public TestWithParam<Unstreamable> {};\n\nTEST_P(CommentTest, TestsCorrectlyReportUnstreamableParams) {\n  const ::testing::TestInfo* const test_info =\n     ::testing::UnitTest::GetInstance()->current_test_info();\n\n  EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());\n}\n\nINSTANTIATE_TEST_CASE_P(InstantiationWithComments,\n                        CommentTest,\n                        Values(Unstreamable(1)));\n\n// Verify that we can create a hierarchy of test fixtures, where the base\n// class fixture is not parameterized and the derived class is. In this case\n// ParameterizedDerivedTest inherits from NonParameterizedBaseTest.  We\n// perform simple tests on both.\nclass NonParameterizedBaseTest : public ::testing::Test {\n public:\n  NonParameterizedBaseTest() : n_(17) { }\n protected:\n  int n_;\n};\n\nclass ParameterizedDerivedTest : public NonParameterizedBaseTest,\n                                 public ::testing::WithParamInterface<int> {\n protected:\n  ParameterizedDerivedTest() : count_(0) { }\n  int count_;\n  static int global_count_;\n};\n\nint ParameterizedDerivedTest::global_count_ = 0;\n\nTEST_F(NonParameterizedBaseTest, FixtureIsInitialized) {\n  EXPECT_EQ(17, n_);\n}\n\nTEST_P(ParameterizedDerivedTest, SeesSequence) {\n  EXPECT_EQ(17, n_);\n  EXPECT_EQ(0, count_++);\n  EXPECT_EQ(GetParam(), global_count_++);\n}\n\nclass ParameterizedDeathTest : public ::testing::TestWithParam<int> { };\n\nTEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {\n  EXPECT_DEATH_IF_SUPPORTED(GetParam(),\n                            \".* value-parameterized test .*\");\n}\n\nINSTANTIATE_TEST_CASE_P(RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5));\n\n#endif  // GTEST_HAS_PARAM_TEST\n\nTEST(CompileTest, CombineIsDefinedOnlyWhenGtestHasParamTestIsDefined) {\n#if GTEST_HAS_COMBINE && !GTEST_HAS_PARAM_TEST\n  FAIL() << \"GTEST_HAS_COMBINE is defined while GTEST_HAS_PARAM_TEST is not\\n\"\n#endif\n}\n\nint main(int argc, char **argv) {\n#if GTEST_HAS_PARAM_TEST\n  // Used in TestGenerationTest test case.\n  AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance());\n  // Used in GeneratorEvaluationTest test case. Tests that the updated value\n  // will be picked up for instantiating tests in GeneratorEvaluationTest.\n  GeneratorEvaluationTest::set_param_value(1);\n#endif  // GTEST_HAS_PARAM_TEST\n\n  ::testing::InitGoogleTest(&argc, argv);\n\n#if GTEST_HAS_PARAM_TEST\n  // Used in GeneratorEvaluationTest test case. Tests that value updated\n  // here will NOT be used for instantiating tests in\n  // GeneratorEvaluationTest.\n  GeneratorEvaluationTest::set_param_value(2);\n#endif  // GTEST_HAS_PARAM_TEST\n\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-param-test_test.h",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: vladl@google.com (Vlad Losev)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This header file provides classes and functions used internally\n// for testing Google Test itself.\n\n#ifndef GTEST_TEST_GTEST_PARAM_TEST_TEST_H_\n#define GTEST_TEST_GTEST_PARAM_TEST_TEST_H_\n\n#include \"gtest/gtest.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\n// Test fixture for testing definition and instantiation of a test\n// in separate translation units.\nclass ExternalInstantiationTest : public ::testing::TestWithParam<int> {\n};\n\n// Test fixture for testing instantiation of a test in multiple\n// translation units.\nclass InstantiationInMultipleTranslaionUnitsTest\n    : public ::testing::TestWithParam<int> {\n};\n\n#endif  // GTEST_HAS_PARAM_TEST\n\n#endif  // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-port_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: vladl@google.com (Vlad Losev), wan@google.com (Zhanyong Wan)\n//\n// This file tests the internal cross-platform support utilities.\n\n#include \"gtest/internal/gtest-port.h\"\n\n#include <stdio.h>\n\n#if GTEST_OS_MAC\n# include <time.h>\n#endif  // GTEST_OS_MAC\n\n#include <list>\n#include <utility>  // For std::pair and std::make_pair.\n#include <vector>\n\n#include \"gtest/gtest.h\"\n#include \"gtest/gtest-spi.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nusing std::make_pair;\nusing std::pair;\n\nnamespace testing {\nnamespace internal {\n\nTEST(IsXDigitTest, WorksForNarrowAscii) {\n  EXPECT_TRUE(IsXDigit('0'));\n  EXPECT_TRUE(IsXDigit('9'));\n  EXPECT_TRUE(IsXDigit('A'));\n  EXPECT_TRUE(IsXDigit('F'));\n  EXPECT_TRUE(IsXDigit('a'));\n  EXPECT_TRUE(IsXDigit('f'));\n\n  EXPECT_FALSE(IsXDigit('-'));\n  EXPECT_FALSE(IsXDigit('g'));\n  EXPECT_FALSE(IsXDigit('G'));\n}\n\nTEST(IsXDigitTest, ReturnsFalseForNarrowNonAscii) {\n  EXPECT_FALSE(IsXDigit('\\x80'));\n  EXPECT_FALSE(IsXDigit(static_cast<char>('0' | '\\x80')));\n}\n\nTEST(IsXDigitTest, WorksForWideAscii) {\n  EXPECT_TRUE(IsXDigit(L'0'));\n  EXPECT_TRUE(IsXDigit(L'9'));\n  EXPECT_TRUE(IsXDigit(L'A'));\n  EXPECT_TRUE(IsXDigit(L'F'));\n  EXPECT_TRUE(IsXDigit(L'a'));\n  EXPECT_TRUE(IsXDigit(L'f'));\n\n  EXPECT_FALSE(IsXDigit(L'-'));\n  EXPECT_FALSE(IsXDigit(L'g'));\n  EXPECT_FALSE(IsXDigit(L'G'));\n}\n\nTEST(IsXDigitTest, ReturnsFalseForWideNonAscii) {\n  EXPECT_FALSE(IsXDigit(static_cast<wchar_t>(0x80)));\n  EXPECT_FALSE(IsXDigit(static_cast<wchar_t>(L'0' | 0x80)));\n  EXPECT_FALSE(IsXDigit(static_cast<wchar_t>(L'0' | 0x100)));\n}\n\nclass Base {\n public:\n  // Copy constructor and assignment operator do exactly what we need, so we\n  // use them.\n  Base() : member_(0) {}\n  explicit Base(int n) : member_(n) {}\n  virtual ~Base() {}\n  int member() { return member_; }\n\n private:\n  int member_;\n};\n\nclass Derived : public Base {\n public:\n  explicit Derived(int n) : Base(n) {}\n};\n\nTEST(ImplicitCastTest, ConvertsPointers) {\n  Derived derived(0);\n  EXPECT_TRUE(&derived == ::testing::internal::ImplicitCast_<Base*>(&derived));\n}\n\nTEST(ImplicitCastTest, CanUseInheritance) {\n  Derived derived(1);\n  Base base = ::testing::internal::ImplicitCast_<Base>(derived);\n  EXPECT_EQ(derived.member(), base.member());\n}\n\nclass Castable {\n public:\n  explicit Castable(bool* converted) : converted_(converted) {}\n  operator Base() {\n    *converted_ = true;\n    return Base();\n  }\n\n private:\n  bool* converted_;\n};\n\nTEST(ImplicitCastTest, CanUseNonConstCastOperator) {\n  bool converted = false;\n  Castable castable(&converted);\n  Base base = ::testing::internal::ImplicitCast_<Base>(castable);\n  EXPECT_TRUE(converted);\n}\n\nclass ConstCastable {\n public:\n  explicit ConstCastable(bool* converted) : converted_(converted) {}\n  operator Base() const {\n    *converted_ = true;\n    return Base();\n  }\n\n private:\n  bool* converted_;\n};\n\nTEST(ImplicitCastTest, CanUseConstCastOperatorOnConstValues) {\n  bool converted = false;\n  const ConstCastable const_castable(&converted);\n  Base base = ::testing::internal::ImplicitCast_<Base>(const_castable);\n  EXPECT_TRUE(converted);\n}\n\nclass ConstAndNonConstCastable {\n public:\n  ConstAndNonConstCastable(bool* converted, bool* const_converted)\n      : converted_(converted), const_converted_(const_converted) {}\n  operator Base() {\n    *converted_ = true;\n    return Base();\n  }\n  operator Base() const {\n    *const_converted_ = true;\n    return Base();\n  }\n\n private:\n  bool* converted_;\n  bool* const_converted_;\n};\n\nTEST(ImplicitCastTest, CanSelectBetweenConstAndNonConstCasrAppropriately) {\n  bool converted = false;\n  bool const_converted = false;\n  ConstAndNonConstCastable castable(&converted, &const_converted);\n  Base base = ::testing::internal::ImplicitCast_<Base>(castable);\n  EXPECT_TRUE(converted);\n  EXPECT_FALSE(const_converted);\n\n  converted = false;\n  const_converted = false;\n  const ConstAndNonConstCastable const_castable(&converted, &const_converted);\n  base = ::testing::internal::ImplicitCast_<Base>(const_castable);\n  EXPECT_FALSE(converted);\n  EXPECT_TRUE(const_converted);\n}\n\nclass To {\n public:\n  To(bool* converted) { *converted = true; }  // NOLINT\n};\n\nTEST(ImplicitCastTest, CanUseImplicitConstructor) {\n  bool converted = false;\n  To to = ::testing::internal::ImplicitCast_<To>(&converted);\n  (void)to;\n  EXPECT_TRUE(converted);\n}\n\nTEST(IteratorTraitsTest, WorksForSTLContainerIterators) {\n  StaticAssertTypeEq<int,\n      IteratorTraits< ::std::vector<int>::const_iterator>::value_type>();\n  StaticAssertTypeEq<bool,\n      IteratorTraits< ::std::list<bool>::iterator>::value_type>();\n}\n\nTEST(IteratorTraitsTest, WorksForPointerToNonConst) {\n  StaticAssertTypeEq<char, IteratorTraits<char*>::value_type>();\n  StaticAssertTypeEq<const void*, IteratorTraits<const void**>::value_type>();\n}\n\nTEST(IteratorTraitsTest, WorksForPointerToConst) {\n  StaticAssertTypeEq<char, IteratorTraits<const char*>::value_type>();\n  StaticAssertTypeEq<const void*,\n      IteratorTraits<const void* const*>::value_type>();\n}\n\n// Tests that the element_type typedef is available in scoped_ptr and refers\n// to the parameter type.\nTEST(ScopedPtrTest, DefinesElementType) {\n  StaticAssertTypeEq<int, ::testing::internal::scoped_ptr<int>::element_type>();\n}\n\n// TODO(vladl@google.com): Implement THE REST of scoped_ptr tests.\n\nTEST(GtestCheckSyntaxTest, BehavesLikeASingleStatement) {\n  if (AlwaysFalse())\n    GTEST_CHECK_(false) << \"This should never be executed; \"\n                           \"It's a compilation test only.\";\n\n  if (AlwaysTrue())\n    GTEST_CHECK_(true);\n  else\n    ;  // NOLINT\n\n  if (AlwaysFalse())\n    ;  // NOLINT\n  else\n    GTEST_CHECK_(true) << \"\";\n}\n\nTEST(GtestCheckSyntaxTest, WorksWithSwitch) {\n  switch (0) {\n    case 1:\n      break;\n    default:\n      GTEST_CHECK_(true);\n  }\n\n  switch (0)\n    case 0:\n      GTEST_CHECK_(true) << \"Check failed in switch case\";\n}\n\n// Verifies behavior of FormatFileLocation.\nTEST(FormatFileLocationTest, FormatsFileLocation) {\n  EXPECT_PRED_FORMAT2(IsSubstring, \"foo.cc\", FormatFileLocation(\"foo.cc\", 42));\n  EXPECT_PRED_FORMAT2(IsSubstring, \"42\", FormatFileLocation(\"foo.cc\", 42));\n}\n\nTEST(FormatFileLocationTest, FormatsUnknownFile) {\n  EXPECT_PRED_FORMAT2(\n      IsSubstring, \"unknown file\", FormatFileLocation(NULL, 42));\n  EXPECT_PRED_FORMAT2(IsSubstring, \"42\", FormatFileLocation(NULL, 42));\n}\n\nTEST(FormatFileLocationTest, FormatsUknownLine) {\n  EXPECT_EQ(\"foo.cc:\", FormatFileLocation(\"foo.cc\", -1));\n}\n\nTEST(FormatFileLocationTest, FormatsUknownFileAndLine) {\n  EXPECT_EQ(\"unknown file:\", FormatFileLocation(NULL, -1));\n}\n\n// Verifies behavior of FormatCompilerIndependentFileLocation.\nTEST(FormatCompilerIndependentFileLocationTest, FormatsFileLocation) {\n  EXPECT_EQ(\"foo.cc:42\", FormatCompilerIndependentFileLocation(\"foo.cc\", 42));\n}\n\nTEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFile) {\n  EXPECT_EQ(\"unknown file:42\",\n            FormatCompilerIndependentFileLocation(NULL, 42));\n}\n\nTEST(FormatCompilerIndependentFileLocationTest, FormatsUknownLine) {\n  EXPECT_EQ(\"foo.cc\", FormatCompilerIndependentFileLocation(\"foo.cc\", -1));\n}\n\nTEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFileAndLine) {\n  EXPECT_EQ(\"unknown file\", FormatCompilerIndependentFileLocation(NULL, -1));\n}\n\n#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX\nvoid* ThreadFunc(void* data) {\n  internal::Mutex* mutex = static_cast<internal::Mutex*>(data);\n  mutex->Lock();\n  mutex->Unlock();\n  return NULL;\n}\n\nTEST(GetThreadCountTest, ReturnsCorrectValue) {\n  const size_t starting_count = GetThreadCount();\n  pthread_t       thread_id;\n\n  internal::Mutex mutex;\n  {\n    internal::MutexLock lock(&mutex);\n    pthread_attr_t  attr;\n    ASSERT_EQ(0, pthread_attr_init(&attr));\n    ASSERT_EQ(0, pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE));\n\n    const int status = pthread_create(&thread_id, &attr, &ThreadFunc, &mutex);\n    ASSERT_EQ(0, pthread_attr_destroy(&attr));\n    ASSERT_EQ(0, status);\n    EXPECT_EQ(starting_count + 1, GetThreadCount());\n  }\n\n  void* dummy;\n  ASSERT_EQ(0, pthread_join(thread_id, &dummy));\n\n  // The OS may not immediately report the updated thread count after\n  // joining a thread, causing flakiness in this test. To counter that, we\n  // wait for up to .5 seconds for the OS to report the correct value.\n  for (int i = 0; i < 5; ++i) {\n    if (GetThreadCount() == starting_count)\n      break;\n\n    SleepMilliseconds(100);\n  }\n\n  EXPECT_EQ(starting_count, GetThreadCount());\n}\n#else\nTEST(GetThreadCountTest, ReturnsZeroWhenUnableToCountThreads) {\n  EXPECT_EQ(0U, GetThreadCount());\n}\n#endif  // GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX\n\nTEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) {\n  const bool a_false_condition = false;\n  const char regex[] =\n#ifdef _MSC_VER\n     \"gtest-port_test\\\\.cc\\\\(\\\\d+\\\\):\"\n#elif GTEST_USES_POSIX_RE\n     \"gtest-port_test\\\\.cc:[0-9]+\"\n#else\n     \"gtest-port_test\\\\.cc:\\\\d+\"\n#endif  // _MSC_VER\n     \".*a_false_condition.*Extra info.*\";\n\n  EXPECT_DEATH_IF_SUPPORTED(GTEST_CHECK_(a_false_condition) << \"Extra info\",\n                            regex);\n}\n\n#if GTEST_HAS_DEATH_TEST\n\nTEST(GtestCheckDeathTest, LivesSilentlyOnSuccess) {\n  EXPECT_EXIT({\n      GTEST_CHECK_(true) << \"Extra info\";\n      ::std::cerr << \"Success\\n\";\n      exit(0); },\n      ::testing::ExitedWithCode(0), \"Success\");\n}\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n// Verifies that Google Test choose regular expression engine appropriate to\n// the platform. The test will produce compiler errors in case of failure.\n// For simplicity, we only cover the most important platforms here.\nTEST(RegexEngineSelectionTest, SelectsCorrectRegexEngine) {\n#if !GTEST_USES_PCRE\n# if GTEST_HAS_POSIX_RE\n\n  EXPECT_TRUE(GTEST_USES_POSIX_RE);\n\n# else\n\n  EXPECT_TRUE(GTEST_USES_SIMPLE_RE);\n\n# endif\n#endif  // !GTEST_USES_PCRE\n}\n\n#if GTEST_USES_POSIX_RE\n\n# if GTEST_HAS_TYPED_TEST\n\ntemplate <typename Str>\nclass RETest : public ::testing::Test {};\n\n// Defines StringTypes as the list of all string types that class RE\n// supports.\ntypedef testing::Types<\n    ::std::string,\n#  if GTEST_HAS_GLOBAL_STRING\n    ::string,\n#  endif  // GTEST_HAS_GLOBAL_STRING\n    const char*> StringTypes;\n\nTYPED_TEST_CASE(RETest, StringTypes);\n\n// Tests RE's implicit constructors.\nTYPED_TEST(RETest, ImplicitConstructorWorks) {\n  const RE empty(TypeParam(\"\"));\n  EXPECT_STREQ(\"\", empty.pattern());\n\n  const RE simple(TypeParam(\"hello\"));\n  EXPECT_STREQ(\"hello\", simple.pattern());\n\n  const RE normal(TypeParam(\".*(\\\\w+)\"));\n  EXPECT_STREQ(\".*(\\\\w+)\", normal.pattern());\n}\n\n// Tests that RE's constructors reject invalid regular expressions.\nTYPED_TEST(RETest, RejectsInvalidRegex) {\n  EXPECT_NONFATAL_FAILURE({\n    const RE invalid(TypeParam(\"?\"));\n  }, \"\\\"?\\\" is not a valid POSIX Extended regular expression.\");\n}\n\n// Tests RE::FullMatch().\nTYPED_TEST(RETest, FullMatchWorks) {\n  const RE empty(TypeParam(\"\"));\n  EXPECT_TRUE(RE::FullMatch(TypeParam(\"\"), empty));\n  EXPECT_FALSE(RE::FullMatch(TypeParam(\"a\"), empty));\n\n  const RE re(TypeParam(\"a.*z\"));\n  EXPECT_TRUE(RE::FullMatch(TypeParam(\"az\"), re));\n  EXPECT_TRUE(RE::FullMatch(TypeParam(\"axyz\"), re));\n  EXPECT_FALSE(RE::FullMatch(TypeParam(\"baz\"), re));\n  EXPECT_FALSE(RE::FullMatch(TypeParam(\"azy\"), re));\n}\n\n// Tests RE::PartialMatch().\nTYPED_TEST(RETest, PartialMatchWorks) {\n  const RE empty(TypeParam(\"\"));\n  EXPECT_TRUE(RE::PartialMatch(TypeParam(\"\"), empty));\n  EXPECT_TRUE(RE::PartialMatch(TypeParam(\"a\"), empty));\n\n  const RE re(TypeParam(\"a.*z\"));\n  EXPECT_TRUE(RE::PartialMatch(TypeParam(\"az\"), re));\n  EXPECT_TRUE(RE::PartialMatch(TypeParam(\"axyz\"), re));\n  EXPECT_TRUE(RE::PartialMatch(TypeParam(\"baz\"), re));\n  EXPECT_TRUE(RE::PartialMatch(TypeParam(\"azy\"), re));\n  EXPECT_FALSE(RE::PartialMatch(TypeParam(\"zza\"), re));\n}\n\n# endif  // GTEST_HAS_TYPED_TEST\n\n#elif GTEST_USES_SIMPLE_RE\n\nTEST(IsInSetTest, NulCharIsNotInAnySet) {\n  EXPECT_FALSE(IsInSet('\\0', \"\"));\n  EXPECT_FALSE(IsInSet('\\0', \"\\0\"));\n  EXPECT_FALSE(IsInSet('\\0', \"a\"));\n}\n\nTEST(IsInSetTest, WorksForNonNulChars) {\n  EXPECT_FALSE(IsInSet('a', \"Ab\"));\n  EXPECT_FALSE(IsInSet('c', \"\"));\n\n  EXPECT_TRUE(IsInSet('b', \"bcd\"));\n  EXPECT_TRUE(IsInSet('b', \"ab\"));\n}\n\nTEST(IsAsciiDigitTest, IsFalseForNonDigit) {\n  EXPECT_FALSE(IsAsciiDigit('\\0'));\n  EXPECT_FALSE(IsAsciiDigit(' '));\n  EXPECT_FALSE(IsAsciiDigit('+'));\n  EXPECT_FALSE(IsAsciiDigit('-'));\n  EXPECT_FALSE(IsAsciiDigit('.'));\n  EXPECT_FALSE(IsAsciiDigit('a'));\n}\n\nTEST(IsAsciiDigitTest, IsTrueForDigit) {\n  EXPECT_TRUE(IsAsciiDigit('0'));\n  EXPECT_TRUE(IsAsciiDigit('1'));\n  EXPECT_TRUE(IsAsciiDigit('5'));\n  EXPECT_TRUE(IsAsciiDigit('9'));\n}\n\nTEST(IsAsciiPunctTest, IsFalseForNonPunct) {\n  EXPECT_FALSE(IsAsciiPunct('\\0'));\n  EXPECT_FALSE(IsAsciiPunct(' '));\n  EXPECT_FALSE(IsAsciiPunct('\\n'));\n  EXPECT_FALSE(IsAsciiPunct('a'));\n  EXPECT_FALSE(IsAsciiPunct('0'));\n}\n\nTEST(IsAsciiPunctTest, IsTrueForPunct) {\n  for (const char* p = \"^-!\\\"#$%&'()*+,./:;<=>?@[\\\\]_`{|}~\"; *p; p++) {\n    EXPECT_PRED1(IsAsciiPunct, *p);\n  }\n}\n\nTEST(IsRepeatTest, IsFalseForNonRepeatChar) {\n  EXPECT_FALSE(IsRepeat('\\0'));\n  EXPECT_FALSE(IsRepeat(' '));\n  EXPECT_FALSE(IsRepeat('a'));\n  EXPECT_FALSE(IsRepeat('1'));\n  EXPECT_FALSE(IsRepeat('-'));\n}\n\nTEST(IsRepeatTest, IsTrueForRepeatChar) {\n  EXPECT_TRUE(IsRepeat('?'));\n  EXPECT_TRUE(IsRepeat('*'));\n  EXPECT_TRUE(IsRepeat('+'));\n}\n\nTEST(IsAsciiWhiteSpaceTest, IsFalseForNonWhiteSpace) {\n  EXPECT_FALSE(IsAsciiWhiteSpace('\\0'));\n  EXPECT_FALSE(IsAsciiWhiteSpace('a'));\n  EXPECT_FALSE(IsAsciiWhiteSpace('1'));\n  EXPECT_FALSE(IsAsciiWhiteSpace('+'));\n  EXPECT_FALSE(IsAsciiWhiteSpace('_'));\n}\n\nTEST(IsAsciiWhiteSpaceTest, IsTrueForWhiteSpace) {\n  EXPECT_TRUE(IsAsciiWhiteSpace(' '));\n  EXPECT_TRUE(IsAsciiWhiteSpace('\\n'));\n  EXPECT_TRUE(IsAsciiWhiteSpace('\\r'));\n  EXPECT_TRUE(IsAsciiWhiteSpace('\\t'));\n  EXPECT_TRUE(IsAsciiWhiteSpace('\\v'));\n  EXPECT_TRUE(IsAsciiWhiteSpace('\\f'));\n}\n\nTEST(IsAsciiWordCharTest, IsFalseForNonWordChar) {\n  EXPECT_FALSE(IsAsciiWordChar('\\0'));\n  EXPECT_FALSE(IsAsciiWordChar('+'));\n  EXPECT_FALSE(IsAsciiWordChar('.'));\n  EXPECT_FALSE(IsAsciiWordChar(' '));\n  EXPECT_FALSE(IsAsciiWordChar('\\n'));\n}\n\nTEST(IsAsciiWordCharTest, IsTrueForLetter) {\n  EXPECT_TRUE(IsAsciiWordChar('a'));\n  EXPECT_TRUE(IsAsciiWordChar('b'));\n  EXPECT_TRUE(IsAsciiWordChar('A'));\n  EXPECT_TRUE(IsAsciiWordChar('Z'));\n}\n\nTEST(IsAsciiWordCharTest, IsTrueForDigit) {\n  EXPECT_TRUE(IsAsciiWordChar('0'));\n  EXPECT_TRUE(IsAsciiWordChar('1'));\n  EXPECT_TRUE(IsAsciiWordChar('7'));\n  EXPECT_TRUE(IsAsciiWordChar('9'));\n}\n\nTEST(IsAsciiWordCharTest, IsTrueForUnderscore) {\n  EXPECT_TRUE(IsAsciiWordChar('_'));\n}\n\nTEST(IsValidEscapeTest, IsFalseForNonPrintable) {\n  EXPECT_FALSE(IsValidEscape('\\0'));\n  EXPECT_FALSE(IsValidEscape('\\007'));\n}\n\nTEST(IsValidEscapeTest, IsFalseForDigit) {\n  EXPECT_FALSE(IsValidEscape('0'));\n  EXPECT_FALSE(IsValidEscape('9'));\n}\n\nTEST(IsValidEscapeTest, IsFalseForWhiteSpace) {\n  EXPECT_FALSE(IsValidEscape(' '));\n  EXPECT_FALSE(IsValidEscape('\\n'));\n}\n\nTEST(IsValidEscapeTest, IsFalseForSomeLetter) {\n  EXPECT_FALSE(IsValidEscape('a'));\n  EXPECT_FALSE(IsValidEscape('Z'));\n}\n\nTEST(IsValidEscapeTest, IsTrueForPunct) {\n  EXPECT_TRUE(IsValidEscape('.'));\n  EXPECT_TRUE(IsValidEscape('-'));\n  EXPECT_TRUE(IsValidEscape('^'));\n  EXPECT_TRUE(IsValidEscape('$'));\n  EXPECT_TRUE(IsValidEscape('('));\n  EXPECT_TRUE(IsValidEscape(']'));\n  EXPECT_TRUE(IsValidEscape('{'));\n  EXPECT_TRUE(IsValidEscape('|'));\n}\n\nTEST(IsValidEscapeTest, IsTrueForSomeLetter) {\n  EXPECT_TRUE(IsValidEscape('d'));\n  EXPECT_TRUE(IsValidEscape('D'));\n  EXPECT_TRUE(IsValidEscape('s'));\n  EXPECT_TRUE(IsValidEscape('S'));\n  EXPECT_TRUE(IsValidEscape('w'));\n  EXPECT_TRUE(IsValidEscape('W'));\n}\n\nTEST(AtomMatchesCharTest, EscapedPunct) {\n  EXPECT_FALSE(AtomMatchesChar(true, '\\\\', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, '\\\\', ' '));\n  EXPECT_FALSE(AtomMatchesChar(true, '_', '.'));\n  EXPECT_FALSE(AtomMatchesChar(true, '.', 'a'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, '\\\\', '\\\\'));\n  EXPECT_TRUE(AtomMatchesChar(true, '_', '_'));\n  EXPECT_TRUE(AtomMatchesChar(true, '+', '+'));\n  EXPECT_TRUE(AtomMatchesChar(true, '.', '.'));\n}\n\nTEST(AtomMatchesCharTest, Escaped_d) {\n  EXPECT_FALSE(AtomMatchesChar(true, 'd', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'd', 'a'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'd', '.'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, 'd', '0'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'd', '9'));\n}\n\nTEST(AtomMatchesCharTest, Escaped_D) {\n  EXPECT_FALSE(AtomMatchesChar(true, 'D', '0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'D', '9'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, 'D', '\\0'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'D', 'a'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'D', '-'));\n}\n\nTEST(AtomMatchesCharTest, Escaped_s) {\n  EXPECT_FALSE(AtomMatchesChar(true, 's', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 's', 'a'));\n  EXPECT_FALSE(AtomMatchesChar(true, 's', '.'));\n  EXPECT_FALSE(AtomMatchesChar(true, 's', '9'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, 's', ' '));\n  EXPECT_TRUE(AtomMatchesChar(true, 's', '\\n'));\n  EXPECT_TRUE(AtomMatchesChar(true, 's', '\\t'));\n}\n\nTEST(AtomMatchesCharTest, Escaped_S) {\n  EXPECT_FALSE(AtomMatchesChar(true, 'S', ' '));\n  EXPECT_FALSE(AtomMatchesChar(true, 'S', '\\r'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, 'S', '\\0'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'S', 'a'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'S', '9'));\n}\n\nTEST(AtomMatchesCharTest, Escaped_w) {\n  EXPECT_FALSE(AtomMatchesChar(true, 'w', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'w', '+'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'w', ' '));\n  EXPECT_FALSE(AtomMatchesChar(true, 'w', '\\n'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, 'w', '0'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'w', 'b'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'w', 'C'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'w', '_'));\n}\n\nTEST(AtomMatchesCharTest, Escaped_W) {\n  EXPECT_FALSE(AtomMatchesChar(true, 'W', 'A'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'W', 'b'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'W', '9'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'W', '_'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, 'W', '\\0'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'W', '*'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'W', '\\n'));\n}\n\nTEST(AtomMatchesCharTest, EscapedWhiteSpace) {\n  EXPECT_FALSE(AtomMatchesChar(true, 'f', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'f', '\\n'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'n', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'n', '\\r'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'r', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'r', 'a'));\n  EXPECT_FALSE(AtomMatchesChar(true, 't', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 't', 't'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'v', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'v', '\\f'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, 'f', '\\f'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'n', '\\n'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'r', '\\r'));\n  EXPECT_TRUE(AtomMatchesChar(true, 't', '\\t'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'v', '\\v'));\n}\n\nTEST(AtomMatchesCharTest, UnescapedDot) {\n  EXPECT_FALSE(AtomMatchesChar(false, '.', '\\n'));\n\n  EXPECT_TRUE(AtomMatchesChar(false, '.', '\\0'));\n  EXPECT_TRUE(AtomMatchesChar(false, '.', '.'));\n  EXPECT_TRUE(AtomMatchesChar(false, '.', 'a'));\n  EXPECT_TRUE(AtomMatchesChar(false, '.', ' '));\n}\n\nTEST(AtomMatchesCharTest, UnescapedChar) {\n  EXPECT_FALSE(AtomMatchesChar(false, 'a', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(false, 'a', 'b'));\n  EXPECT_FALSE(AtomMatchesChar(false, '$', 'a'));\n\n  EXPECT_TRUE(AtomMatchesChar(false, '$', '$'));\n  EXPECT_TRUE(AtomMatchesChar(false, '5', '5'));\n  EXPECT_TRUE(AtomMatchesChar(false, 'Z', 'Z'));\n}\n\nTEST(ValidateRegexTest, GeneratesFailureAndReturnsFalseForInvalid) {\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(NULL)),\n                          \"NULL is not a valid simple regular expression\");\n  EXPECT_NONFATAL_FAILURE(\n      ASSERT_FALSE(ValidateRegex(\"a\\\\\")),\n      \"Syntax error at index 1 in simple regular expression \\\"a\\\\\\\": \");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"a\\\\\")),\n                          \"'\\\\' cannot appear at the end\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"\\\\n\\\\\")),\n                          \"'\\\\' cannot appear at the end\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"\\\\s\\\\hb\")),\n                          \"invalid escape sequence \\\"\\\\h\\\"\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"^^\")),\n                          \"'^' can only appear at the beginning\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\".*^b\")),\n                          \"'^' can only appear at the beginning\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"$$\")),\n                          \"'$' can only appear at the end\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"^$a\")),\n                          \"'$' can only appear at the end\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"a(b\")),\n                          \"'(' is unsupported\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"ab)\")),\n                          \"')' is unsupported\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"[ab\")),\n                          \"'[' is unsupported\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"a{2\")),\n                          \"'{' is unsupported\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"?\")),\n                          \"'?' can only follow a repeatable token\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"^*\")),\n                          \"'*' can only follow a repeatable token\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"5*+\")),\n                          \"'+' can only follow a repeatable token\");\n}\n\nTEST(ValidateRegexTest, ReturnsTrueForValid) {\n  EXPECT_TRUE(ValidateRegex(\"\"));\n  EXPECT_TRUE(ValidateRegex(\"a\"));\n  EXPECT_TRUE(ValidateRegex(\".*\"));\n  EXPECT_TRUE(ValidateRegex(\"^a_+\"));\n  EXPECT_TRUE(ValidateRegex(\"^a\\\\t\\\\&?\"));\n  EXPECT_TRUE(ValidateRegex(\"09*$\"));\n  EXPECT_TRUE(ValidateRegex(\"^Z$\"));\n  EXPECT_TRUE(ValidateRegex(\"a\\\\^Z\\\\$\\\\(\\\\)\\\\|\\\\[\\\\]\\\\{\\\\}\"));\n}\n\nTEST(MatchRepetitionAndRegexAtHeadTest, WorksForZeroOrOne) {\n  EXPECT_FALSE(MatchRepetitionAndRegexAtHead(false, 'a', '?', \"a\", \"ba\"));\n  // Repeating more than once.\n  EXPECT_FALSE(MatchRepetitionAndRegexAtHead(false, 'a', '?', \"b\", \"aab\"));\n\n  // Repeating zero times.\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(false, 'a', '?', \"b\", \"ba\"));\n  // Repeating once.\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(false, 'a', '?', \"b\", \"ab\"));\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(false, '#', '?', \".\", \"##\"));\n}\n\nTEST(MatchRepetitionAndRegexAtHeadTest, WorksForZeroOrMany) {\n  EXPECT_FALSE(MatchRepetitionAndRegexAtHead(false, '.', '*', \"a$\", \"baab\"));\n\n  // Repeating zero times.\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(false, '.', '*', \"b\", \"bc\"));\n  // Repeating once.\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(false, '.', '*', \"b\", \"abc\"));\n  // Repeating more than once.\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(true, 'w', '*', \"-\", \"ab_1-g\"));\n}\n\nTEST(MatchRepetitionAndRegexAtHeadTest, WorksForOneOrMany) {\n  EXPECT_FALSE(MatchRepetitionAndRegexAtHead(false, '.', '+', \"a$\", \"baab\"));\n  // Repeating zero times.\n  EXPECT_FALSE(MatchRepetitionAndRegexAtHead(false, '.', '+', \"b\", \"bc\"));\n\n  // Repeating once.\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(false, '.', '+', \"b\", \"abc\"));\n  // Repeating more than once.\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(true, 'w', '+', \"-\", \"ab_1-g\"));\n}\n\nTEST(MatchRegexAtHeadTest, ReturnsTrueForEmptyRegex) {\n  EXPECT_TRUE(MatchRegexAtHead(\"\", \"\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"\", \"ab\"));\n}\n\nTEST(MatchRegexAtHeadTest, WorksWhenDollarIsInRegex) {\n  EXPECT_FALSE(MatchRegexAtHead(\"$\", \"a\"));\n\n  EXPECT_TRUE(MatchRegexAtHead(\"$\", \"\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"a$\", \"a\"));\n}\n\nTEST(MatchRegexAtHeadTest, WorksWhenRegexStartsWithEscapeSequence) {\n  EXPECT_FALSE(MatchRegexAtHead(\"\\\\w\", \"+\"));\n  EXPECT_FALSE(MatchRegexAtHead(\"\\\\W\", \"ab\"));\n\n  EXPECT_TRUE(MatchRegexAtHead(\"\\\\sa\", \"\\nab\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"\\\\d\", \"1a\"));\n}\n\nTEST(MatchRegexAtHeadTest, WorksWhenRegexStartsWithRepetition) {\n  EXPECT_FALSE(MatchRegexAtHead(\".+a\", \"abc\"));\n  EXPECT_FALSE(MatchRegexAtHead(\"a?b\", \"aab\"));\n\n  EXPECT_TRUE(MatchRegexAtHead(\".*a\", \"bc12-ab\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"a?b\", \"b\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"a?b\", \"ab\"));\n}\n\nTEST(MatchRegexAtHeadTest,\n     WorksWhenRegexStartsWithRepetionOfEscapeSequence) {\n  EXPECT_FALSE(MatchRegexAtHead(\"\\\\.+a\", \"abc\"));\n  EXPECT_FALSE(MatchRegexAtHead(\"\\\\s?b\", \"  b\"));\n\n  EXPECT_TRUE(MatchRegexAtHead(\"\\\\(*a\", \"((((ab\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"\\\\^?b\", \"^b\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"\\\\\\\\?b\", \"b\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"\\\\\\\\?b\", \"\\\\b\"));\n}\n\nTEST(MatchRegexAtHeadTest, MatchesSequentially) {\n  EXPECT_FALSE(MatchRegexAtHead(\"ab.*c\", \"acabc\"));\n\n  EXPECT_TRUE(MatchRegexAtHead(\"ab.*c\", \"ab-fsc\"));\n}\n\nTEST(MatchRegexAnywhereTest, ReturnsFalseWhenStringIsNull) {\n  EXPECT_FALSE(MatchRegexAnywhere(\"\", NULL));\n}\n\nTEST(MatchRegexAnywhereTest, WorksWhenRegexStartsWithCaret) {\n  EXPECT_FALSE(MatchRegexAnywhere(\"^a\", \"ba\"));\n  EXPECT_FALSE(MatchRegexAnywhere(\"^$\", \"a\"));\n\n  EXPECT_TRUE(MatchRegexAnywhere(\"^a\", \"ab\"));\n  EXPECT_TRUE(MatchRegexAnywhere(\"^\", \"ab\"));\n  EXPECT_TRUE(MatchRegexAnywhere(\"^$\", \"\"));\n}\n\nTEST(MatchRegexAnywhereTest, ReturnsFalseWhenNoMatch) {\n  EXPECT_FALSE(MatchRegexAnywhere(\"a\", \"bcde123\"));\n  EXPECT_FALSE(MatchRegexAnywhere(\"a.+a\", \"--aa88888888\"));\n}\n\nTEST(MatchRegexAnywhereTest, ReturnsTrueWhenMatchingPrefix) {\n  EXPECT_TRUE(MatchRegexAnywhere(\"\\\\w+\", \"ab1_ - 5\"));\n  EXPECT_TRUE(MatchRegexAnywhere(\".*=\", \"=\"));\n  EXPECT_TRUE(MatchRegexAnywhere(\"x.*ab?.*bc\", \"xaaabc\"));\n}\n\nTEST(MatchRegexAnywhereTest, ReturnsTrueWhenMatchingNonPrefix) {\n  EXPECT_TRUE(MatchRegexAnywhere(\"\\\\w+\", \"$$$ ab1_ - 5\"));\n  EXPECT_TRUE(MatchRegexAnywhere(\"\\\\.+=\", \"=  ...=\"));\n}\n\n// Tests RE's implicit constructors.\nTEST(RETest, ImplicitConstructorWorks) {\n  const RE empty(\"\");\n  EXPECT_STREQ(\"\", empty.pattern());\n\n  const RE simple(\"hello\");\n  EXPECT_STREQ(\"hello\", simple.pattern());\n}\n\n// Tests that RE's constructors reject invalid regular expressions.\nTEST(RETest, RejectsInvalidRegex) {\n  EXPECT_NONFATAL_FAILURE({\n    const RE normal(NULL);\n  }, \"NULL is not a valid simple regular expression\");\n\n  EXPECT_NONFATAL_FAILURE({\n    const RE normal(\".*(\\\\w+\");\n  }, \"'(' is unsupported\");\n\n  EXPECT_NONFATAL_FAILURE({\n    const RE invalid(\"^?\");\n  }, \"'?' can only follow a repeatable token\");\n}\n\n// Tests RE::FullMatch().\nTEST(RETest, FullMatchWorks) {\n  const RE empty(\"\");\n  EXPECT_TRUE(RE::FullMatch(\"\", empty));\n  EXPECT_FALSE(RE::FullMatch(\"a\", empty));\n\n  const RE re1(\"a\");\n  EXPECT_TRUE(RE::FullMatch(\"a\", re1));\n\n  const RE re(\"a.*z\");\n  EXPECT_TRUE(RE::FullMatch(\"az\", re));\n  EXPECT_TRUE(RE::FullMatch(\"axyz\", re));\n  EXPECT_FALSE(RE::FullMatch(\"baz\", re));\n  EXPECT_FALSE(RE::FullMatch(\"azy\", re));\n}\n\n// Tests RE::PartialMatch().\nTEST(RETest, PartialMatchWorks) {\n  const RE empty(\"\");\n  EXPECT_TRUE(RE::PartialMatch(\"\", empty));\n  EXPECT_TRUE(RE::PartialMatch(\"a\", empty));\n\n  const RE re(\"a.*z\");\n  EXPECT_TRUE(RE::PartialMatch(\"az\", re));\n  EXPECT_TRUE(RE::PartialMatch(\"axyz\", re));\n  EXPECT_TRUE(RE::PartialMatch(\"baz\", re));\n  EXPECT_TRUE(RE::PartialMatch(\"azy\", re));\n  EXPECT_FALSE(RE::PartialMatch(\"zza\", re));\n}\n\n#endif  // GTEST_USES_POSIX_RE\n\n#if !GTEST_OS_WINDOWS_MOBILE\n\nTEST(CaptureTest, CapturesStdout) {\n  CaptureStdout();\n  fprintf(stdout, \"abc\");\n  EXPECT_STREQ(\"abc\", GetCapturedStdout().c_str());\n\n  CaptureStdout();\n  fprintf(stdout, \"def%cghi\", '\\0');\n  EXPECT_EQ(::std::string(\"def\\0ghi\", 7), ::std::string(GetCapturedStdout()));\n}\n\nTEST(CaptureTest, CapturesStderr) {\n  CaptureStderr();\n  fprintf(stderr, \"jkl\");\n  EXPECT_STREQ(\"jkl\", GetCapturedStderr().c_str());\n\n  CaptureStderr();\n  fprintf(stderr, \"jkl%cmno\", '\\0');\n  EXPECT_EQ(::std::string(\"jkl\\0mno\", 7), ::std::string(GetCapturedStderr()));\n}\n\n// Tests that stdout and stderr capture don't interfere with each other.\nTEST(CaptureTest, CapturesStdoutAndStderr) {\n  CaptureStdout();\n  CaptureStderr();\n  fprintf(stdout, \"pqr\");\n  fprintf(stderr, \"stu\");\n  EXPECT_STREQ(\"pqr\", GetCapturedStdout().c_str());\n  EXPECT_STREQ(\"stu\", GetCapturedStderr().c_str());\n}\n\nTEST(CaptureDeathTest, CannotReenterStdoutCapture) {\n  CaptureStdout();\n  EXPECT_DEATH_IF_SUPPORTED(CaptureStdout(),\n                            \"Only one stdout capturer can exist at a time\");\n  GetCapturedStdout();\n\n  // We cannot test stderr capturing using death tests as they use it\n  // themselves.\n}\n\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\nTEST(ThreadLocalTest, DefaultConstructorInitializesToDefaultValues) {\n  ThreadLocal<int> t1;\n  EXPECT_EQ(0, t1.get());\n\n  ThreadLocal<void*> t2;\n  EXPECT_TRUE(t2.get() == NULL);\n}\n\nTEST(ThreadLocalTest, SingleParamConstructorInitializesToParam) {\n  ThreadLocal<int> t1(123);\n  EXPECT_EQ(123, t1.get());\n\n  int i = 0;\n  ThreadLocal<int*> t2(&i);\n  EXPECT_EQ(&i, t2.get());\n}\n\nclass NoDefaultContructor {\n public:\n  explicit NoDefaultContructor(const char*) {}\n  NoDefaultContructor(const NoDefaultContructor&) {}\n};\n\nTEST(ThreadLocalTest, ValueDefaultContructorIsNotRequiredForParamVersion) {\n  ThreadLocal<NoDefaultContructor> bar(NoDefaultContructor(\"foo\"));\n  bar.pointer();\n}\n\nTEST(ThreadLocalTest, GetAndPointerReturnSameValue) {\n  ThreadLocal<std::string> thread_local_string;\n\n  EXPECT_EQ(thread_local_string.pointer(), &(thread_local_string.get()));\n\n  // Verifies the condition still holds after calling set.\n  thread_local_string.set(\"foo\");\n  EXPECT_EQ(thread_local_string.pointer(), &(thread_local_string.get()));\n}\n\nTEST(ThreadLocalTest, PointerAndConstPointerReturnSameValue) {\n  ThreadLocal<std::string> thread_local_string;\n  const ThreadLocal<std::string>& const_thread_local_string =\n      thread_local_string;\n\n  EXPECT_EQ(thread_local_string.pointer(), const_thread_local_string.pointer());\n\n  thread_local_string.set(\"foo\");\n  EXPECT_EQ(thread_local_string.pointer(), const_thread_local_string.pointer());\n}\n\n#if GTEST_IS_THREADSAFE\n\nvoid AddTwo(int* param) { *param += 2; }\n\nTEST(ThreadWithParamTest, ConstructorExecutesThreadFunc) {\n  int i = 40;\n  ThreadWithParam<int*> thread(&AddTwo, &i, NULL);\n  thread.Join();\n  EXPECT_EQ(42, i);\n}\n\nTEST(MutexDeathTest, AssertHeldShouldAssertWhenNotLocked) {\n  // AssertHeld() is flaky only in the presence of multiple threads accessing\n  // the lock. In this case, the test is robust.\n  EXPECT_DEATH_IF_SUPPORTED({\n    Mutex m;\n    { MutexLock lock(&m); }\n    m.AssertHeld();\n  },\n  \"thread .*hold\");\n}\n\nTEST(MutexTest, AssertHeldShouldNotAssertWhenLocked) {\n  Mutex m;\n  MutexLock lock(&m);\n  m.AssertHeld();\n}\n\nclass AtomicCounterWithMutex {\n public:\n  explicit AtomicCounterWithMutex(Mutex* mutex) :\n    value_(0), mutex_(mutex), random_(42) {}\n\n  void Increment() {\n    MutexLock lock(mutex_);\n    int temp = value_;\n    {\n      // We need to put up a memory barrier to prevent reads and writes to\n      // value_ rearranged with the call to SleepMilliseconds when observed\n      // from other threads.\n#if GTEST_HAS_PTHREAD\n      // On POSIX, locking a mutex puts up a memory barrier.  We cannot use\n      // Mutex and MutexLock here or rely on their memory barrier\n      // functionality as we are testing them here.\n      pthread_mutex_t memory_barrier_mutex;\n      GTEST_CHECK_POSIX_SUCCESS_(\n          pthread_mutex_init(&memory_barrier_mutex, NULL));\n      GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&memory_barrier_mutex));\n\n      SleepMilliseconds(random_.Generate(30));\n\n      GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&memory_barrier_mutex));\n      GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&memory_barrier_mutex));\n#elif GTEST_OS_WINDOWS\n      // On Windows, performing an interlocked access puts up a memory barrier.\n      volatile LONG dummy = 0;\n      ::InterlockedIncrement(&dummy);\n      SleepMilliseconds(random_.Generate(30));\n      ::InterlockedIncrement(&dummy);\n#else\n# error \"Memory barrier not implemented on this platform.\"\n#endif  // GTEST_HAS_PTHREAD\n    }\n    value_ = temp + 1;\n  }\n  int value() const { return value_; }\n\n private:\n  volatile int value_;\n  Mutex* const mutex_;  // Protects value_.\n  Random       random_;\n};\n\nvoid CountingThreadFunc(pair<AtomicCounterWithMutex*, int> param) {\n  for (int i = 0; i < param.second; ++i)\n      param.first->Increment();\n}\n\n// Tests that the mutex only lets one thread at a time to lock it.\nTEST(MutexTest, OnlyOneThreadCanLockAtATime) {\n  Mutex mutex;\n  AtomicCounterWithMutex locked_counter(&mutex);\n\n  typedef ThreadWithParam<pair<AtomicCounterWithMutex*, int> > ThreadType;\n  const int kCycleCount = 20;\n  const int kThreadCount = 7;\n  scoped_ptr<ThreadType> counting_threads[kThreadCount];\n  Notification threads_can_start;\n  // Creates and runs kThreadCount threads that increment locked_counter\n  // kCycleCount times each.\n  for (int i = 0; i < kThreadCount; ++i) {\n    counting_threads[i].reset(new ThreadType(&CountingThreadFunc,\n                                             make_pair(&locked_counter,\n                                                       kCycleCount),\n                                             &threads_can_start));\n  }\n  threads_can_start.Notify();\n  for (int i = 0; i < kThreadCount; ++i)\n    counting_threads[i]->Join();\n\n  // If the mutex lets more than one thread to increment the counter at a\n  // time, they are likely to encounter a race condition and have some\n  // increments overwritten, resulting in the lower then expected counter\n  // value.\n  EXPECT_EQ(kCycleCount * kThreadCount, locked_counter.value());\n}\n\ntemplate <typename T>\nvoid RunFromThread(void (func)(T), T param) {\n  ThreadWithParam<T> thread(func, param, NULL);\n  thread.Join();\n}\n\nvoid RetrieveThreadLocalValue(\n    pair<ThreadLocal<std::string>*, std::string*> param) {\n  *param.second = param.first->get();\n}\n\nTEST(ThreadLocalTest, ParameterizedConstructorSetsDefault) {\n  ThreadLocal<std::string> thread_local_string(\"foo\");\n  EXPECT_STREQ(\"foo\", thread_local_string.get().c_str());\n\n  thread_local_string.set(\"bar\");\n  EXPECT_STREQ(\"bar\", thread_local_string.get().c_str());\n\n  std::string result;\n  RunFromThread(&RetrieveThreadLocalValue,\n                make_pair(&thread_local_string, &result));\n  EXPECT_STREQ(\"foo\", result.c_str());\n}\n\n// Keeps track of whether of destructors being called on instances of\n// DestructorTracker.  On Windows, waits for the destructor call reports.\nclass DestructorCall {\n public:\n  DestructorCall() {\n    invoked_ = false;\n#if GTEST_OS_WINDOWS\n    wait_event_.Reset(::CreateEvent(NULL, TRUE, FALSE, NULL));\n    GTEST_CHECK_(wait_event_.Get() != NULL);\n#endif\n  }\n\n  bool CheckDestroyed() const {\n#if GTEST_OS_WINDOWS\n    if (::WaitForSingleObject(wait_event_.Get(), 1000) != WAIT_OBJECT_0)\n      return false;\n#endif\n    return invoked_;\n  }\n\n  void ReportDestroyed() {\n    invoked_ = true;\n#if GTEST_OS_WINDOWS\n    ::SetEvent(wait_event_.Get());\n#endif\n  }\n\n  static std::vector<DestructorCall*>& List() { return *list_; }\n\n  static void ResetList() {\n    for (size_t i = 0; i < list_->size(); ++i) {\n      delete list_->at(i);\n    }\n    list_->clear();\n  }\n\n private:\n  bool invoked_;\n#if GTEST_OS_WINDOWS\n  AutoHandle wait_event_;\n#endif\n  static std::vector<DestructorCall*>* const list_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(DestructorCall);\n};\n\nstd::vector<DestructorCall*>* const DestructorCall::list_ =\n    new std::vector<DestructorCall*>;\n\n// DestructorTracker keeps track of whether its instances have been\n// destroyed.\nclass DestructorTracker {\n public:\n  DestructorTracker() : index_(GetNewIndex()) {}\n  DestructorTracker(const DestructorTracker& /* rhs */)\n      : index_(GetNewIndex()) {}\n  ~DestructorTracker() {\n    // We never access DestructorCall::List() concurrently, so we don't need\n    // to protect this acccess with a mutex.\n    DestructorCall::List()[index_]->ReportDestroyed();\n  }\n\n private:\n  static size_t GetNewIndex() {\n    DestructorCall::List().push_back(new DestructorCall);\n    return DestructorCall::List().size() - 1;\n  }\n  const size_t index_;\n\n  GTEST_DISALLOW_ASSIGN_(DestructorTracker);\n};\n\ntypedef ThreadLocal<DestructorTracker>* ThreadParam;\n\nvoid CallThreadLocalGet(ThreadParam thread_local_param) {\n  thread_local_param->get();\n}\n\n// Tests that when a ThreadLocal object dies in a thread, it destroys\n// the managed object for that thread.\nTEST(ThreadLocalTest, DestroysManagedObjectForOwnThreadWhenDying) {\n  DestructorCall::ResetList();\n\n  {\n    ThreadLocal<DestructorTracker> thread_local_tracker;\n    ASSERT_EQ(0U, DestructorCall::List().size());\n\n    // This creates another DestructorTracker object for the main thread.\n    thread_local_tracker.get();\n    ASSERT_EQ(1U, DestructorCall::List().size());\n    ASSERT_FALSE(DestructorCall::List()[0]->CheckDestroyed());\n  }\n\n  // Now thread_local_tracker has died.\n  ASSERT_EQ(1U, DestructorCall::List().size());\n  EXPECT_TRUE(DestructorCall::List()[0]->CheckDestroyed());\n\n  DestructorCall::ResetList();\n}\n\n// Tests that when a thread exits, the thread-local object for that\n// thread is destroyed.\nTEST(ThreadLocalTest, DestroysManagedObjectAtThreadExit) {\n  DestructorCall::ResetList();\n\n  {\n    ThreadLocal<DestructorTracker> thread_local_tracker;\n    ASSERT_EQ(0U, DestructorCall::List().size());\n\n    // This creates another DestructorTracker object in the new thread.\n    ThreadWithParam<ThreadParam> thread(\n        &CallThreadLocalGet, &thread_local_tracker, NULL);\n    thread.Join();\n\n    // The thread has exited, and we should have a DestroyedTracker\n    // instance created for it. But it may not have been destroyed yet.\n    ASSERT_EQ(1U, DestructorCall::List().size());\n  }\n\n  // The thread has exited and thread_local_tracker has died.\n  ASSERT_EQ(1U, DestructorCall::List().size());\n  EXPECT_TRUE(DestructorCall::List()[0]->CheckDestroyed());\n\n  DestructorCall::ResetList();\n}\n\nTEST(ThreadLocalTest, ThreadLocalMutationsAffectOnlyCurrentThread) {\n  ThreadLocal<std::string> thread_local_string;\n  thread_local_string.set(\"Foo\");\n  EXPECT_STREQ(\"Foo\", thread_local_string.get().c_str());\n\n  std::string result;\n  RunFromThread(&RetrieveThreadLocalValue,\n                make_pair(&thread_local_string, &result));\n  EXPECT_TRUE(result.empty());\n}\n\n#endif  // GTEST_IS_THREADSAFE\n\n#if GTEST_OS_WINDOWS\nTEST(WindowsTypesTest, HANDLEIsVoidStar) {\n  StaticAssertTypeEq<HANDLE, void*>();\n}\n\nTEST(WindowsTypesTest, CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION) {\n  StaticAssertTypeEq<CRITICAL_SECTION, _RTL_CRITICAL_SECTION>();\n}\n#endif  // GTEST_OS_WINDOWS\n\n}  // namespace internal\n}  // namespace testing\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-printers_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Test - The Google C++ Testing Framework\n//\n// This file tests the universal value printer.\n\n#include \"gtest/gtest-printers.h\"\n\n#include <ctype.h>\n#include <limits.h>\n#include <string.h>\n#include <algorithm>\n#include <deque>\n#include <list>\n#include <map>\n#include <set>\n#include <sstream>\n#include <string>\n#include <utility>\n#include <vector>\n\n#include \"gtest/gtest.h\"\n\n// hash_map and hash_set are available under Visual C++, or on Linux.\n#if GTEST_HAS_HASH_MAP_\n# include <hash_map>            // NOLINT\n#endif  // GTEST_HAS_HASH_MAP_\n#if GTEST_HAS_HASH_SET_\n# include <hash_set>            // NOLINT\n#endif  // GTEST_HAS_HASH_SET_\n\n#if GTEST_HAS_STD_FORWARD_LIST_\n# include <forward_list> // NOLINT\n#endif  // GTEST_HAS_STD_FORWARD_LIST_\n\n// Some user-defined types for testing the universal value printer.\n\n// An anonymous enum type.\nenum AnonymousEnum {\n  kAE1 = -1,\n  kAE2 = 1\n};\n\n// An enum without a user-defined printer.\nenum EnumWithoutPrinter {\n  kEWP1 = -2,\n  kEWP2 = 42\n};\n\n// An enum with a << operator.\nenum EnumWithStreaming {\n  kEWS1 = 10\n};\n\nstd::ostream& operator<<(std::ostream& os, EnumWithStreaming e) {\n  return os << (e == kEWS1 ? \"kEWS1\" : \"invalid\");\n}\n\n// An enum with a PrintTo() function.\nenum EnumWithPrintTo {\n  kEWPT1 = 1\n};\n\nvoid PrintTo(EnumWithPrintTo e, std::ostream* os) {\n  *os << (e == kEWPT1 ? \"kEWPT1\" : \"invalid\");\n}\n\n// A class implicitly convertible to BiggestInt.\nclass BiggestIntConvertible {\n public:\n  operator ::testing::internal::BiggestInt() const { return 42; }\n};\n\n// A user-defined unprintable class template in the global namespace.\ntemplate <typename T>\nclass UnprintableTemplateInGlobal {\n public:\n  UnprintableTemplateInGlobal() : value_() {}\n private:\n  T value_;\n};\n\n// A user-defined streamable type in the global namespace.\nclass StreamableInGlobal {\n public:\n  virtual ~StreamableInGlobal() {}\n};\n\ninline void operator<<(::std::ostream& os, const StreamableInGlobal& /* x */) {\n  os << \"StreamableInGlobal\";\n}\n\nvoid operator<<(::std::ostream& os, const StreamableInGlobal* /* x */) {\n  os << \"StreamableInGlobal*\";\n}\n\nnamespace foo {\n\n// A user-defined unprintable type in a user namespace.\nclass UnprintableInFoo {\n public:\n  UnprintableInFoo() : z_(0) { memcpy(xy_, \"\\xEF\\x12\\x0\\x0\\x34\\xAB\\x0\\x0\", 8); }\n  double z() const { return z_; }\n private:\n  char xy_[8];\n  double z_;\n};\n\n// A user-defined printable type in a user-chosen namespace.\nstruct PrintableViaPrintTo {\n  PrintableViaPrintTo() : value() {}\n  int value;\n};\n\nvoid PrintTo(const PrintableViaPrintTo& x, ::std::ostream* os) {\n  *os << \"PrintableViaPrintTo: \" << x.value;\n}\n\n// A type with a user-defined << for printing its pointer.\nstruct PointerPrintable {\n};\n\n::std::ostream& operator<<(::std::ostream& os,\n                           const PointerPrintable* /* x */) {\n  return os << \"PointerPrintable*\";\n}\n\n// A user-defined printable class template in a user-chosen namespace.\ntemplate <typename T>\nclass PrintableViaPrintToTemplate {\n public:\n  explicit PrintableViaPrintToTemplate(const T& a_value) : value_(a_value) {}\n\n  const T& value() const { return value_; }\n private:\n  T value_;\n};\n\ntemplate <typename T>\nvoid PrintTo(const PrintableViaPrintToTemplate<T>& x, ::std::ostream* os) {\n  *os << \"PrintableViaPrintToTemplate: \" << x.value();\n}\n\n// A user-defined streamable class template in a user namespace.\ntemplate <typename T>\nclass StreamableTemplateInFoo {\n public:\n  StreamableTemplateInFoo() : value_() {}\n\n  const T& value() const { return value_; }\n private:\n  T value_;\n};\n\ntemplate <typename T>\ninline ::std::ostream& operator<<(::std::ostream& os,\n                                  const StreamableTemplateInFoo<T>& x) {\n  return os << \"StreamableTemplateInFoo: \" << x.value();\n}\n\n}  // namespace foo\n\nnamespace testing {\nnamespace gtest_printers_test {\n\nusing ::std::deque;\nusing ::std::list;\nusing ::std::make_pair;\nusing ::std::map;\nusing ::std::multimap;\nusing ::std::multiset;\nusing ::std::pair;\nusing ::std::set;\nusing ::std::vector;\nusing ::testing::PrintToString;\nusing ::testing::internal::FormatForComparisonFailureMessage;\nusing ::testing::internal::ImplicitCast_;\nusing ::testing::internal::NativeArray;\nusing ::testing::internal::RE;\nusing ::testing::internal::RelationToSourceReference;\nusing ::testing::internal::Strings;\nusing ::testing::internal::UniversalPrint;\nusing ::testing::internal::UniversalPrinter;\nusing ::testing::internal::UniversalTersePrint;\nusing ::testing::internal::UniversalTersePrintTupleFieldsToStrings;\nusing ::testing::internal::string;\n\n// The hash_* classes are not part of the C++ standard.  STLport\n// defines them in namespace std.  MSVC defines them in ::stdext.  GCC\n// defines them in ::.\n#ifdef _STLP_HASH_MAP  // We got <hash_map> from STLport.\nusing ::std::hash_map;\nusing ::std::hash_set;\nusing ::std::hash_multimap;\nusing ::std::hash_multiset;\n#elif _MSC_VER\nusing ::stdext::hash_map;\nusing ::stdext::hash_set;\nusing ::stdext::hash_multimap;\nusing ::stdext::hash_multiset;\n#endif\n\n// Prints a value to a string using the universal value printer.  This\n// is a helper for testing UniversalPrinter<T>::Print() for various types.\ntemplate <typename T>\nstring Print(const T& value) {\n  ::std::stringstream ss;\n  UniversalPrinter<T>::Print(value, &ss);\n  return ss.str();\n}\n\n// Prints a value passed by reference to a string, using the universal\n// value printer.  This is a helper for testing\n// UniversalPrinter<T&>::Print() for various types.\ntemplate <typename T>\nstring PrintByRef(const T& value) {\n  ::std::stringstream ss;\n  UniversalPrinter<T&>::Print(value, &ss);\n  return ss.str();\n}\n\n// Tests printing various enum types.\n\nTEST(PrintEnumTest, AnonymousEnum) {\n  EXPECT_EQ(\"-1\", Print(kAE1));\n  EXPECT_EQ(\"1\", Print(kAE2));\n}\n\nTEST(PrintEnumTest, EnumWithoutPrinter) {\n  EXPECT_EQ(\"-2\", Print(kEWP1));\n  EXPECT_EQ(\"42\", Print(kEWP2));\n}\n\nTEST(PrintEnumTest, EnumWithStreaming) {\n  EXPECT_EQ(\"kEWS1\", Print(kEWS1));\n  EXPECT_EQ(\"invalid\", Print(static_cast<EnumWithStreaming>(0)));\n}\n\nTEST(PrintEnumTest, EnumWithPrintTo) {\n  EXPECT_EQ(\"kEWPT1\", Print(kEWPT1));\n  EXPECT_EQ(\"invalid\", Print(static_cast<EnumWithPrintTo>(0)));\n}\n\n// Tests printing a class implicitly convertible to BiggestInt.\n\nTEST(PrintClassTest, BiggestIntConvertible) {\n  EXPECT_EQ(\"42\", Print(BiggestIntConvertible()));\n}\n\n// Tests printing various char types.\n\n// char.\nTEST(PrintCharTest, PlainChar) {\n  EXPECT_EQ(\"'\\\\0'\", Print('\\0'));\n  EXPECT_EQ(\"'\\\\'' (39, 0x27)\", Print('\\''));\n  EXPECT_EQ(\"'\\\"' (34, 0x22)\", Print('\"'));\n  EXPECT_EQ(\"'?' (63, 0x3F)\", Print('?'));\n  EXPECT_EQ(\"'\\\\\\\\' (92, 0x5C)\", Print('\\\\'));\n  EXPECT_EQ(\"'\\\\a' (7)\", Print('\\a'));\n  EXPECT_EQ(\"'\\\\b' (8)\", Print('\\b'));\n  EXPECT_EQ(\"'\\\\f' (12, 0xC)\", Print('\\f'));\n  EXPECT_EQ(\"'\\\\n' (10, 0xA)\", Print('\\n'));\n  EXPECT_EQ(\"'\\\\r' (13, 0xD)\", Print('\\r'));\n  EXPECT_EQ(\"'\\\\t' (9)\", Print('\\t'));\n  EXPECT_EQ(\"'\\\\v' (11, 0xB)\", Print('\\v'));\n  EXPECT_EQ(\"'\\\\x7F' (127)\", Print('\\x7F'));\n  EXPECT_EQ(\"'\\\\xFF' (255)\", Print('\\xFF'));\n  EXPECT_EQ(\"' ' (32, 0x20)\", Print(' '));\n  EXPECT_EQ(\"'a' (97, 0x61)\", Print('a'));\n}\n\n// signed char.\nTEST(PrintCharTest, SignedChar) {\n  EXPECT_EQ(\"'\\\\0'\", Print(static_cast<signed char>('\\0')));\n  EXPECT_EQ(\"'\\\\xCE' (-50)\",\n            Print(static_cast<signed char>(-50)));\n}\n\n// unsigned char.\nTEST(PrintCharTest, UnsignedChar) {\n  EXPECT_EQ(\"'\\\\0'\", Print(static_cast<unsigned char>('\\0')));\n  EXPECT_EQ(\"'b' (98, 0x62)\",\n            Print(static_cast<unsigned char>('b')));\n}\n\n// Tests printing other simple, built-in types.\n\n// bool.\nTEST(PrintBuiltInTypeTest, Bool) {\n  EXPECT_EQ(\"false\", Print(false));\n  EXPECT_EQ(\"true\", Print(true));\n}\n\n// wchar_t.\nTEST(PrintBuiltInTypeTest, Wchar_t) {\n  EXPECT_EQ(\"L'\\\\0'\", Print(L'\\0'));\n  EXPECT_EQ(\"L'\\\\'' (39, 0x27)\", Print(L'\\''));\n  EXPECT_EQ(\"L'\\\"' (34, 0x22)\", Print(L'\"'));\n  EXPECT_EQ(\"L'?' (63, 0x3F)\", Print(L'?'));\n  EXPECT_EQ(\"L'\\\\\\\\' (92, 0x5C)\", Print(L'\\\\'));\n  EXPECT_EQ(\"L'\\\\a' (7)\", Print(L'\\a'));\n  EXPECT_EQ(\"L'\\\\b' (8)\", Print(L'\\b'));\n  EXPECT_EQ(\"L'\\\\f' (12, 0xC)\", Print(L'\\f'));\n  EXPECT_EQ(\"L'\\\\n' (10, 0xA)\", Print(L'\\n'));\n  EXPECT_EQ(\"L'\\\\r' (13, 0xD)\", Print(L'\\r'));\n  EXPECT_EQ(\"L'\\\\t' (9)\", Print(L'\\t'));\n  EXPECT_EQ(\"L'\\\\v' (11, 0xB)\", Print(L'\\v'));\n  EXPECT_EQ(\"L'\\\\x7F' (127)\", Print(L'\\x7F'));\n  EXPECT_EQ(\"L'\\\\xFF' (255)\", Print(L'\\xFF'));\n  EXPECT_EQ(\"L' ' (32, 0x20)\", Print(L' '));\n  EXPECT_EQ(\"L'a' (97, 0x61)\", Print(L'a'));\n  EXPECT_EQ(\"L'\\\\x576' (1398)\", Print(static_cast<wchar_t>(0x576)));\n  EXPECT_EQ(\"L'\\\\xC74D' (51021)\", Print(static_cast<wchar_t>(0xC74D)));\n}\n\n// Test that Int64 provides more storage than wchar_t.\nTEST(PrintTypeSizeTest, Wchar_t) {\n  EXPECT_LT(sizeof(wchar_t), sizeof(testing::internal::Int64));\n}\n\n// Various integer types.\nTEST(PrintBuiltInTypeTest, Integer) {\n  EXPECT_EQ(\"'\\\\xFF' (255)\", Print(static_cast<unsigned char>(255)));  // uint8\n  EXPECT_EQ(\"'\\\\x80' (-128)\", Print(static_cast<signed char>(-128)));  // int8\n  EXPECT_EQ(\"65535\", Print(USHRT_MAX));  // uint16\n  EXPECT_EQ(\"-32768\", Print(SHRT_MIN));  // int16\n  EXPECT_EQ(\"4294967295\", Print(UINT_MAX));  // uint32\n  EXPECT_EQ(\"-2147483648\", Print(INT_MIN));  // int32\n  EXPECT_EQ(\"18446744073709551615\",\n            Print(static_cast<testing::internal::UInt64>(-1)));  // uint64\n  EXPECT_EQ(\"-9223372036854775808\",\n            Print(static_cast<testing::internal::Int64>(1) << 63));  // int64\n}\n\n// Size types.\nTEST(PrintBuiltInTypeTest, Size_t) {\n  EXPECT_EQ(\"1\", Print(sizeof('a')));  // size_t.\n#if !GTEST_OS_WINDOWS\n  // Windows has no ssize_t type.\n  EXPECT_EQ(\"-2\", Print(static_cast<ssize_t>(-2)));  // ssize_t.\n#endif  // !GTEST_OS_WINDOWS\n}\n\n// Floating-points.\nTEST(PrintBuiltInTypeTest, FloatingPoints) {\n  EXPECT_EQ(\"1.5\", Print(1.5f));   // float\n  EXPECT_EQ(\"-2.5\", Print(-2.5));  // double\n}\n\n// Since ::std::stringstream::operator<<(const void *) formats the pointer\n// output differently with different compilers, we have to create the expected\n// output first and use it as our expectation.\nstatic string PrintPointer(const void *p) {\n  ::std::stringstream expected_result_stream;\n  expected_result_stream << p;\n  return expected_result_stream.str();\n}\n\n// Tests printing C strings.\n\n// const char*.\nTEST(PrintCStringTest, Const) {\n  const char* p = \"World\";\n  EXPECT_EQ(PrintPointer(p) + \" pointing to \\\"World\\\"\", Print(p));\n}\n\n// char*.\nTEST(PrintCStringTest, NonConst) {\n  char p[] = \"Hi\";\n  EXPECT_EQ(PrintPointer(p) + \" pointing to \\\"Hi\\\"\",\n            Print(static_cast<char*>(p)));\n}\n\n// NULL C string.\nTEST(PrintCStringTest, Null) {\n  const char* p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// Tests that C strings are escaped properly.\nTEST(PrintCStringTest, EscapesProperly) {\n  const char* p = \"'\\\"?\\\\\\a\\b\\f\\n\\r\\t\\v\\x7F\\xFF a\";\n  EXPECT_EQ(PrintPointer(p) + \" pointing to \\\"'\\\\\\\"?\\\\\\\\\\\\a\\\\b\\\\f\"\n            \"\\\\n\\\\r\\\\t\\\\v\\\\x7F\\\\xFF a\\\"\",\n            Print(p));\n}\n\n// MSVC compiler can be configured to define whar_t as a typedef\n// of unsigned short. Defining an overload for const wchar_t* in that case\n// would cause pointers to unsigned shorts be printed as wide strings,\n// possibly accessing more memory than intended and causing invalid\n// memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when\n// wchar_t is implemented as a native type.\n#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)\n\n// const wchar_t*.\nTEST(PrintWideCStringTest, Const) {\n  const wchar_t* p = L\"World\";\n  EXPECT_EQ(PrintPointer(p) + \" pointing to L\\\"World\\\"\", Print(p));\n}\n\n// wchar_t*.\nTEST(PrintWideCStringTest, NonConst) {\n  wchar_t p[] = L\"Hi\";\n  EXPECT_EQ(PrintPointer(p) + \" pointing to L\\\"Hi\\\"\",\n            Print(static_cast<wchar_t*>(p)));\n}\n\n// NULL wide C string.\nTEST(PrintWideCStringTest, Null) {\n  const wchar_t* p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// Tests that wide C strings are escaped properly.\nTEST(PrintWideCStringTest, EscapesProperly) {\n  const wchar_t s[] = {'\\'', '\"', '?', '\\\\', '\\a', '\\b', '\\f', '\\n', '\\r',\n                       '\\t', '\\v', 0xD3, 0x576, 0x8D3, 0xC74D, ' ', 'a', '\\0'};\n  EXPECT_EQ(PrintPointer(s) + \" pointing to L\\\"'\\\\\\\"?\\\\\\\\\\\\a\\\\b\\\\f\"\n            \"\\\\n\\\\r\\\\t\\\\v\\\\xD3\\\\x576\\\\x8D3\\\\xC74D a\\\"\",\n            Print(static_cast<const wchar_t*>(s)));\n}\n#endif  // native wchar_t\n\n// Tests printing pointers to other char types.\n\n// signed char*.\nTEST(PrintCharPointerTest, SignedChar) {\n  signed char* p = reinterpret_cast<signed char*>(0x1234);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// const signed char*.\nTEST(PrintCharPointerTest, ConstSignedChar) {\n  signed char* p = reinterpret_cast<signed char*>(0x1234);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// unsigned char*.\nTEST(PrintCharPointerTest, UnsignedChar) {\n  unsigned char* p = reinterpret_cast<unsigned char*>(0x1234);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// const unsigned char*.\nTEST(PrintCharPointerTest, ConstUnsignedChar) {\n  const unsigned char* p = reinterpret_cast<const unsigned char*>(0x1234);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// Tests printing pointers to simple, built-in types.\n\n// bool*.\nTEST(PrintPointerToBuiltInTypeTest, Bool) {\n  bool* p = reinterpret_cast<bool*>(0xABCD);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// void*.\nTEST(PrintPointerToBuiltInTypeTest, Void) {\n  void* p = reinterpret_cast<void*>(0xABCD);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// const void*.\nTEST(PrintPointerToBuiltInTypeTest, ConstVoid) {\n  const void* p = reinterpret_cast<const void*>(0xABCD);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// Tests printing pointers to pointers.\nTEST(PrintPointerToPointerTest, IntPointerPointer) {\n  int** p = reinterpret_cast<int**>(0xABCD);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// Tests printing (non-member) function pointers.\n\nvoid MyFunction(int /* n */) {}\n\nTEST(PrintPointerTest, NonMemberFunctionPointer) {\n  // We cannot directly cast &MyFunction to const void* because the\n  // standard disallows casting between pointers to functions and\n  // pointers to objects, and some compilers (e.g. GCC 3.4) enforce\n  // this limitation.\n  EXPECT_EQ(\n      PrintPointer(reinterpret_cast<const void*>(\n          reinterpret_cast<internal::BiggestInt>(&MyFunction))),\n      Print(&MyFunction));\n  int (*p)(bool) = NULL;  // NOLINT\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// An assertion predicate determining whether a one string is a prefix for\n// another.\ntemplate <typename StringType>\nAssertionResult HasPrefix(const StringType& str, const StringType& prefix) {\n  if (str.find(prefix, 0) == 0)\n    return AssertionSuccess();\n\n  const bool is_wide_string = sizeof(prefix[0]) > 1;\n  const char* const begin_string_quote = is_wide_string ? \"L\\\"\" : \"\\\"\";\n  return AssertionFailure()\n      << begin_string_quote << prefix << \"\\\" is not a prefix of \"\n      << begin_string_quote << str << \"\\\"\\n\";\n}\n\n// Tests printing member variable pointers.  Although they are called\n// pointers, they don't point to a location in the address space.\n// Their representation is implementation-defined.  Thus they will be\n// printed as raw bytes.\n\nstruct Foo {\n public:\n  virtual ~Foo() {}\n  int MyMethod(char x) { return x + 1; }\n  virtual char MyVirtualMethod(int /* n */) { return 'a'; }\n\n  int value;\n};\n\nTEST(PrintPointerTest, MemberVariablePointer) {\n  EXPECT_TRUE(HasPrefix(Print(&Foo::value),\n                        Print(sizeof(&Foo::value)) + \"-byte object \"));\n  int (Foo::*p) = NULL;  // NOLINT\n  EXPECT_TRUE(HasPrefix(Print(p),\n                        Print(sizeof(p)) + \"-byte object \"));\n}\n\n// Tests printing member function pointers.  Although they are called\n// pointers, they don't point to a location in the address space.\n// Their representation is implementation-defined.  Thus they will be\n// printed as raw bytes.\nTEST(PrintPointerTest, MemberFunctionPointer) {\n  EXPECT_TRUE(HasPrefix(Print(&Foo::MyMethod),\n                        Print(sizeof(&Foo::MyMethod)) + \"-byte object \"));\n  EXPECT_TRUE(\n      HasPrefix(Print(&Foo::MyVirtualMethod),\n                Print(sizeof((&Foo::MyVirtualMethod))) + \"-byte object \"));\n  int (Foo::*p)(char) = NULL;  // NOLINT\n  EXPECT_TRUE(HasPrefix(Print(p),\n                        Print(sizeof(p)) + \"-byte object \"));\n}\n\n// Tests printing C arrays.\n\n// The difference between this and Print() is that it ensures that the\n// argument is a reference to an array.\ntemplate <typename T, size_t N>\nstring PrintArrayHelper(T (&a)[N]) {\n  return Print(a);\n}\n\n// One-dimensional array.\nTEST(PrintArrayTest, OneDimensionalArray) {\n  int a[5] = { 1, 2, 3, 4, 5 };\n  EXPECT_EQ(\"{ 1, 2, 3, 4, 5 }\", PrintArrayHelper(a));\n}\n\n// Two-dimensional array.\nTEST(PrintArrayTest, TwoDimensionalArray) {\n  int a[2][5] = {\n    { 1, 2, 3, 4, 5 },\n    { 6, 7, 8, 9, 0 }\n  };\n  EXPECT_EQ(\"{ { 1, 2, 3, 4, 5 }, { 6, 7, 8, 9, 0 } }\", PrintArrayHelper(a));\n}\n\n// Array of const elements.\nTEST(PrintArrayTest, ConstArray) {\n  const bool a[1] = { false };\n  EXPECT_EQ(\"{ false }\", PrintArrayHelper(a));\n}\n\n// char array without terminating NUL.\nTEST(PrintArrayTest, CharArrayWithNoTerminatingNul) {\n  // Array a contains '\\0' in the middle and doesn't end with '\\0'.\n  char a[] = { 'H', '\\0', 'i' };\n  EXPECT_EQ(\"\\\"H\\\\0i\\\" (no terminating NUL)\", PrintArrayHelper(a));\n}\n\n// const char array with terminating NUL.\nTEST(PrintArrayTest, ConstCharArrayWithTerminatingNul) {\n  const char a[] = \"\\0Hi\";\n  EXPECT_EQ(\"\\\"\\\\0Hi\\\"\", PrintArrayHelper(a));\n}\n\n// const wchar_t array without terminating NUL.\nTEST(PrintArrayTest, WCharArrayWithNoTerminatingNul) {\n  // Array a contains '\\0' in the middle and doesn't end with '\\0'.\n  const wchar_t a[] = { L'H', L'\\0', L'i' };\n  EXPECT_EQ(\"L\\\"H\\\\0i\\\" (no terminating NUL)\", PrintArrayHelper(a));\n}\n\n// wchar_t array with terminating NUL.\nTEST(PrintArrayTest, WConstCharArrayWithTerminatingNul) {\n  const wchar_t a[] = L\"\\0Hi\";\n  EXPECT_EQ(\"L\\\"\\\\0Hi\\\"\", PrintArrayHelper(a));\n}\n\n// Array of objects.\nTEST(PrintArrayTest, ObjectArray) {\n  string a[3] = { \"Hi\", \"Hello\", \"Ni hao\" };\n  EXPECT_EQ(\"{ \\\"Hi\\\", \\\"Hello\\\", \\\"Ni hao\\\" }\", PrintArrayHelper(a));\n}\n\n// Array with many elements.\nTEST(PrintArrayTest, BigArray) {\n  int a[100] = { 1, 2, 3 };\n  EXPECT_EQ(\"{ 1, 2, 3, 0, 0, 0, 0, 0, ..., 0, 0, 0, 0, 0, 0, 0, 0 }\",\n            PrintArrayHelper(a));\n}\n\n// Tests printing ::string and ::std::string.\n\n#if GTEST_HAS_GLOBAL_STRING\n// ::string.\nTEST(PrintStringTest, StringInGlobalNamespace) {\n  const char s[] = \"'\\\"?\\\\\\a\\b\\f\\n\\0\\r\\t\\v\\x7F\\xFF a\";\n  const ::string str(s, sizeof(s));\n  EXPECT_EQ(\"\\\"'\\\\\\\"?\\\\\\\\\\\\a\\\\b\\\\f\\\\n\\\\0\\\\r\\\\t\\\\v\\\\x7F\\\\xFF a\\\\0\\\"\",\n            Print(str));\n}\n#endif  // GTEST_HAS_GLOBAL_STRING\n\n// ::std::string.\nTEST(PrintStringTest, StringInStdNamespace) {\n  const char s[] = \"'\\\"?\\\\\\a\\b\\f\\n\\0\\r\\t\\v\\x7F\\xFF a\";\n  const ::std::string str(s, sizeof(s));\n  EXPECT_EQ(\"\\\"'\\\\\\\"?\\\\\\\\\\\\a\\\\b\\\\f\\\\n\\\\0\\\\r\\\\t\\\\v\\\\x7F\\\\xFF a\\\\0\\\"\",\n            Print(str));\n}\n\nTEST(PrintStringTest, StringAmbiguousHex) {\n  // \"\\x6BANANA\" is ambiguous, it can be interpreted as starting with either of:\n  // '\\x6', '\\x6B', or '\\x6BA'.\n\n  // a hex escaping sequence following by a decimal digit\n  EXPECT_EQ(\"\\\"0\\\\x12\\\" \\\"3\\\"\", Print(::std::string(\"0\\x12\" \"3\")));\n  // a hex escaping sequence following by a hex digit (lower-case)\n  EXPECT_EQ(\"\\\"mm\\\\x6\\\" \\\"bananas\\\"\", Print(::std::string(\"mm\\x6\" \"bananas\")));\n  // a hex escaping sequence following by a hex digit (upper-case)\n  EXPECT_EQ(\"\\\"NOM\\\\x6\\\" \\\"BANANA\\\"\", Print(::std::string(\"NOM\\x6\" \"BANANA\")));\n  // a hex escaping sequence following by a non-xdigit\n  EXPECT_EQ(\"\\\"!\\\\x5-!\\\"\", Print(::std::string(\"!\\x5-!\")));\n}\n\n// Tests printing ::wstring and ::std::wstring.\n\n#if GTEST_HAS_GLOBAL_WSTRING\n// ::wstring.\nTEST(PrintWideStringTest, StringInGlobalNamespace) {\n  const wchar_t s[] = L\"'\\\"?\\\\\\a\\b\\f\\n\\0\\r\\t\\v\\xD3\\x576\\x8D3\\xC74D a\";\n  const ::wstring str(s, sizeof(s)/sizeof(wchar_t));\n  EXPECT_EQ(\"L\\\"'\\\\\\\"?\\\\\\\\\\\\a\\\\b\\\\f\\\\n\\\\0\\\\r\\\\t\\\\v\"\n            \"\\\\xD3\\\\x576\\\\x8D3\\\\xC74D a\\\\0\\\"\",\n            Print(str));\n}\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n#if GTEST_HAS_STD_WSTRING\n// ::std::wstring.\nTEST(PrintWideStringTest, StringInStdNamespace) {\n  const wchar_t s[] = L\"'\\\"?\\\\\\a\\b\\f\\n\\0\\r\\t\\v\\xD3\\x576\\x8D3\\xC74D a\";\n  const ::std::wstring str(s, sizeof(s)/sizeof(wchar_t));\n  EXPECT_EQ(\"L\\\"'\\\\\\\"?\\\\\\\\\\\\a\\\\b\\\\f\\\\n\\\\0\\\\r\\\\t\\\\v\"\n            \"\\\\xD3\\\\x576\\\\x8D3\\\\xC74D a\\\\0\\\"\",\n            Print(str));\n}\n\nTEST(PrintWideStringTest, StringAmbiguousHex) {\n  // same for wide strings.\n  EXPECT_EQ(\"L\\\"0\\\\x12\\\" L\\\"3\\\"\", Print(::std::wstring(L\"0\\x12\" L\"3\")));\n  EXPECT_EQ(\"L\\\"mm\\\\x6\\\" L\\\"bananas\\\"\",\n            Print(::std::wstring(L\"mm\\x6\" L\"bananas\")));\n  EXPECT_EQ(\"L\\\"NOM\\\\x6\\\" L\\\"BANANA\\\"\",\n            Print(::std::wstring(L\"NOM\\x6\" L\"BANANA\")));\n  EXPECT_EQ(\"L\\\"!\\\\x5-!\\\"\", Print(::std::wstring(L\"!\\x5-!\")));\n}\n#endif  // GTEST_HAS_STD_WSTRING\n\n// Tests printing types that support generic streaming (i.e. streaming\n// to std::basic_ostream<Char, CharTraits> for any valid Char and\n// CharTraits types).\n\n// Tests printing a non-template type that supports generic streaming.\n\nclass AllowsGenericStreaming {};\n\ntemplate <typename Char, typename CharTraits>\nstd::basic_ostream<Char, CharTraits>& operator<<(\n    std::basic_ostream<Char, CharTraits>& os,\n    const AllowsGenericStreaming& /* a */) {\n  return os << \"AllowsGenericStreaming\";\n}\n\nTEST(PrintTypeWithGenericStreamingTest, NonTemplateType) {\n  AllowsGenericStreaming a;\n  EXPECT_EQ(\"AllowsGenericStreaming\", Print(a));\n}\n\n// Tests printing a template type that supports generic streaming.\n\ntemplate <typename T>\nclass AllowsGenericStreamingTemplate {};\n\ntemplate <typename Char, typename CharTraits, typename T>\nstd::basic_ostream<Char, CharTraits>& operator<<(\n    std::basic_ostream<Char, CharTraits>& os,\n    const AllowsGenericStreamingTemplate<T>& /* a */) {\n  return os << \"AllowsGenericStreamingTemplate\";\n}\n\nTEST(PrintTypeWithGenericStreamingTest, TemplateType) {\n  AllowsGenericStreamingTemplate<int> a;\n  EXPECT_EQ(\"AllowsGenericStreamingTemplate\", Print(a));\n}\n\n// Tests printing a type that supports generic streaming and can be\n// implicitly converted to another printable type.\n\ntemplate <typename T>\nclass AllowsGenericStreamingAndImplicitConversionTemplate {\n public:\n  operator bool() const { return false; }\n};\n\ntemplate <typename Char, typename CharTraits, typename T>\nstd::basic_ostream<Char, CharTraits>& operator<<(\n    std::basic_ostream<Char, CharTraits>& os,\n    const AllowsGenericStreamingAndImplicitConversionTemplate<T>& /* a */) {\n  return os << \"AllowsGenericStreamingAndImplicitConversionTemplate\";\n}\n\nTEST(PrintTypeWithGenericStreamingTest, TypeImplicitlyConvertible) {\n  AllowsGenericStreamingAndImplicitConversionTemplate<int> a;\n  EXPECT_EQ(\"AllowsGenericStreamingAndImplicitConversionTemplate\", Print(a));\n}\n\n#if GTEST_HAS_STRING_PIECE_\n\n// Tests printing StringPiece.\n\nTEST(PrintStringPieceTest, SimpleStringPiece) {\n  const StringPiece sp = \"Hello\";\n  EXPECT_EQ(\"\\\"Hello\\\"\", Print(sp));\n}\n\nTEST(PrintStringPieceTest, UnprintableCharacters) {\n  const char str[] = \"NUL (\\0) and \\r\\t\";\n  const StringPiece sp(str, sizeof(str) - 1);\n  EXPECT_EQ(\"\\\"NUL (\\\\0) and \\\\r\\\\t\\\"\", Print(sp));\n}\n\n#endif  // GTEST_HAS_STRING_PIECE_\n\n// Tests printing STL containers.\n\nTEST(PrintStlContainerTest, EmptyDeque) {\n  deque<char> empty;\n  EXPECT_EQ(\"{}\", Print(empty));\n}\n\nTEST(PrintStlContainerTest, NonEmptyDeque) {\n  deque<int> non_empty;\n  non_empty.push_back(1);\n  non_empty.push_back(3);\n  EXPECT_EQ(\"{ 1, 3 }\", Print(non_empty));\n}\n\n#if GTEST_HAS_HASH_MAP_\n\nTEST(PrintStlContainerTest, OneElementHashMap) {\n  hash_map<int, char> map1;\n  map1[1] = 'a';\n  EXPECT_EQ(\"{ (1, 'a' (97, 0x61)) }\", Print(map1));\n}\n\nTEST(PrintStlContainerTest, HashMultiMap) {\n  hash_multimap<int, bool> map1;\n  map1.insert(make_pair(5, true));\n  map1.insert(make_pair(5, false));\n\n  // Elements of hash_multimap can be printed in any order.\n  const string result = Print(map1);\n  EXPECT_TRUE(result == \"{ (5, true), (5, false) }\" ||\n              result == \"{ (5, false), (5, true) }\")\n                  << \" where Print(map1) returns \\\"\" << result << \"\\\".\";\n}\n\n#endif  // GTEST_HAS_HASH_MAP_\n\n#if GTEST_HAS_HASH_SET_\n\nTEST(PrintStlContainerTest, HashSet) {\n  hash_set<string> set1;\n  set1.insert(\"hello\");\n  EXPECT_EQ(\"{ \\\"hello\\\" }\", Print(set1));\n}\n\nTEST(PrintStlContainerTest, HashMultiSet) {\n  const int kSize = 5;\n  int a[kSize] = { 1, 1, 2, 5, 1 };\n  hash_multiset<int> set1(a, a + kSize);\n\n  // Elements of hash_multiset can be printed in any order.\n  const string result = Print(set1);\n  const string expected_pattern = \"{ d, d, d, d, d }\";  // d means a digit.\n\n  // Verifies the result matches the expected pattern; also extracts\n  // the numbers in the result.\n  ASSERT_EQ(expected_pattern.length(), result.length());\n  std::vector<int> numbers;\n  for (size_t i = 0; i != result.length(); i++) {\n    if (expected_pattern[i] == 'd') {\n      ASSERT_NE(isdigit(static_cast<unsigned char>(result[i])), 0);\n      numbers.push_back(result[i] - '0');\n    } else {\n      EXPECT_EQ(expected_pattern[i], result[i]) << \" where result is \"\n                                                << result;\n    }\n  }\n\n  // Makes sure the result contains the right numbers.\n  std::sort(numbers.begin(), numbers.end());\n  std::sort(a, a + kSize);\n  EXPECT_TRUE(std::equal(a, a + kSize, numbers.begin()));\n}\n\n#endif  // GTEST_HAS_HASH_SET_\n\nTEST(PrintStlContainerTest, List) {\n  const string a[] = {\n    \"hello\",\n    \"world\"\n  };\n  const list<string> strings(a, a + 2);\n  EXPECT_EQ(\"{ \\\"hello\\\", \\\"world\\\" }\", Print(strings));\n}\n\nTEST(PrintStlContainerTest, Map) {\n  map<int, bool> map1;\n  map1[1] = true;\n  map1[5] = false;\n  map1[3] = true;\n  EXPECT_EQ(\"{ (1, true), (3, true), (5, false) }\", Print(map1));\n}\n\nTEST(PrintStlContainerTest, MultiMap) {\n  multimap<bool, int> map1;\n  // The make_pair template function would deduce the type as\n  // pair<bool, int> here, and since the key part in a multimap has to\n  // be constant, without a templated ctor in the pair class (as in\n  // libCstd on Solaris), make_pair call would fail to compile as no\n  // implicit conversion is found.  Thus explicit typename is used\n  // here instead.\n  map1.insert(pair<const bool, int>(true, 0));\n  map1.insert(pair<const bool, int>(true, 1));\n  map1.insert(pair<const bool, int>(false, 2));\n  EXPECT_EQ(\"{ (false, 2), (true, 0), (true, 1) }\", Print(map1));\n}\n\nTEST(PrintStlContainerTest, Set) {\n  const unsigned int a[] = { 3, 0, 5 };\n  set<unsigned int> set1(a, a + 3);\n  EXPECT_EQ(\"{ 0, 3, 5 }\", Print(set1));\n}\n\nTEST(PrintStlContainerTest, MultiSet) {\n  const int a[] = { 1, 1, 2, 5, 1 };\n  multiset<int> set1(a, a + 5);\n  EXPECT_EQ(\"{ 1, 1, 1, 2, 5 }\", Print(set1));\n}\n\n#if GTEST_HAS_STD_FORWARD_LIST_\n// <slist> is available on Linux in the google3 mode, but not on\n// Windows or Mac OS X.\n\nTEST(PrintStlContainerTest, SinglyLinkedList) {\n  int a[] = { 9, 2, 8 };\n  const std::forward_list<int> ints(a, a + 3);\n  EXPECT_EQ(\"{ 9, 2, 8 }\", Print(ints));\n}\n#endif  // GTEST_HAS_STD_FORWARD_LIST_\n\nTEST(PrintStlContainerTest, Pair) {\n  pair<const bool, int> p(true, 5);\n  EXPECT_EQ(\"(true, 5)\", Print(p));\n}\n\nTEST(PrintStlContainerTest, Vector) {\n  vector<int> v;\n  v.push_back(1);\n  v.push_back(2);\n  EXPECT_EQ(\"{ 1, 2 }\", Print(v));\n}\n\nTEST(PrintStlContainerTest, LongSequence) {\n  const int a[100] = { 1, 2, 3 };\n  const vector<int> v(a, a + 100);\n  EXPECT_EQ(\"{ 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \"\n            \"0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... }\", Print(v));\n}\n\nTEST(PrintStlContainerTest, NestedContainer) {\n  const int a1[] = { 1, 2 };\n  const int a2[] = { 3, 4, 5 };\n  const list<int> l1(a1, a1 + 2);\n  const list<int> l2(a2, a2 + 3);\n\n  vector<list<int> > v;\n  v.push_back(l1);\n  v.push_back(l2);\n  EXPECT_EQ(\"{ { 1, 2 }, { 3, 4, 5 } }\", Print(v));\n}\n\nTEST(PrintStlContainerTest, OneDimensionalNativeArray) {\n  const int a[3] = { 1, 2, 3 };\n  NativeArray<int> b(a, 3, RelationToSourceReference());\n  EXPECT_EQ(\"{ 1, 2, 3 }\", Print(b));\n}\n\nTEST(PrintStlContainerTest, TwoDimensionalNativeArray) {\n  const int a[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } };\n  NativeArray<int[3]> b(a, 2, RelationToSourceReference());\n  EXPECT_EQ(\"{ { 1, 2, 3 }, { 4, 5, 6 } }\", Print(b));\n}\n\n// Tests that a class named iterator isn't treated as a container.\n\nstruct iterator {\n  char x;\n};\n\nTEST(PrintStlContainerTest, Iterator) {\n  iterator it = {};\n  EXPECT_EQ(\"1-byte object <00>\", Print(it));\n}\n\n// Tests that a class named const_iterator isn't treated as a container.\n\nstruct const_iterator {\n  char x;\n};\n\nTEST(PrintStlContainerTest, ConstIterator) {\n  const_iterator it = {};\n  EXPECT_EQ(\"1-byte object <00>\", Print(it));\n}\n\n#if GTEST_HAS_TR1_TUPLE\n// Tests printing ::std::tr1::tuples.\n\n// Tuples of various arities.\nTEST(PrintTr1TupleTest, VariousSizes) {\n  ::std::tr1::tuple<> t0;\n  EXPECT_EQ(\"()\", Print(t0));\n\n  ::std::tr1::tuple<int> t1(5);\n  EXPECT_EQ(\"(5)\", Print(t1));\n\n  ::std::tr1::tuple<char, bool> t2('a', true);\n  EXPECT_EQ(\"('a' (97, 0x61), true)\", Print(t2));\n\n  ::std::tr1::tuple<bool, int, int> t3(false, 2, 3);\n  EXPECT_EQ(\"(false, 2, 3)\", Print(t3));\n\n  ::std::tr1::tuple<bool, int, int, int> t4(false, 2, 3, 4);\n  EXPECT_EQ(\"(false, 2, 3, 4)\", Print(t4));\n\n  ::std::tr1::tuple<bool, int, int, int, bool> t5(false, 2, 3, 4, true);\n  EXPECT_EQ(\"(false, 2, 3, 4, true)\", Print(t5));\n\n  ::std::tr1::tuple<bool, int, int, int, bool, int> t6(false, 2, 3, 4, true, 6);\n  EXPECT_EQ(\"(false, 2, 3, 4, true, 6)\", Print(t6));\n\n  ::std::tr1::tuple<bool, int, int, int, bool, int, int> t7(\n      false, 2, 3, 4, true, 6, 7);\n  EXPECT_EQ(\"(false, 2, 3, 4, true, 6, 7)\", Print(t7));\n\n  ::std::tr1::tuple<bool, int, int, int, bool, int, int, bool> t8(\n      false, 2, 3, 4, true, 6, 7, true);\n  EXPECT_EQ(\"(false, 2, 3, 4, true, 6, 7, true)\", Print(t8));\n\n  ::std::tr1::tuple<bool, int, int, int, bool, int, int, bool, int> t9(\n      false, 2, 3, 4, true, 6, 7, true, 9);\n  EXPECT_EQ(\"(false, 2, 3, 4, true, 6, 7, true, 9)\", Print(t9));\n\n  const char* const str = \"8\";\n  // VC++ 2010's implementation of tuple of C++0x is deficient, requiring\n  // an explicit type cast of NULL to be used.\n  ::std::tr1::tuple<bool, char, short, testing::internal::Int32,  // NOLINT\n      testing::internal::Int64, float, double, const char*, void*, string>\n      t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str,\n          ImplicitCast_<void*>(NULL), \"10\");\n  EXPECT_EQ(\"(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, \" + PrintPointer(str) +\n            \" pointing to \\\"8\\\", NULL, \\\"10\\\")\",\n            Print(t10));\n}\n\n// Nested tuples.\nTEST(PrintTr1TupleTest, NestedTuple) {\n  ::std::tr1::tuple< ::std::tr1::tuple<int, bool>, char> nested(\n      ::std::tr1::make_tuple(5, true), 'a');\n  EXPECT_EQ(\"((5, true), 'a' (97, 0x61))\", Print(nested));\n}\n\n#endif  // GTEST_HAS_TR1_TUPLE\n\n#if GTEST_HAS_STD_TUPLE_\n// Tests printing ::std::tuples.\n\n// Tuples of various arities.\nTEST(PrintStdTupleTest, VariousSizes) {\n  ::std::tuple<> t0;\n  EXPECT_EQ(\"()\", Print(t0));\n\n  ::std::tuple<int> t1(5);\n  EXPECT_EQ(\"(5)\", Print(t1));\n\n  ::std::tuple<char, bool> t2('a', true);\n  EXPECT_EQ(\"('a' (97, 0x61), true)\", Print(t2));\n\n  ::std::tuple<bool, int, int> t3(false, 2, 3);\n  EXPECT_EQ(\"(false, 2, 3)\", Print(t3));\n\n  ::std::tuple<bool, int, int, int> t4(false, 2, 3, 4);\n  EXPECT_EQ(\"(false, 2, 3, 4)\", Print(t4));\n\n  ::std::tuple<bool, int, int, int, bool> t5(false, 2, 3, 4, true);\n  EXPECT_EQ(\"(false, 2, 3, 4, true)\", Print(t5));\n\n  ::std::tuple<bool, int, int, int, bool, int> t6(false, 2, 3, 4, true, 6);\n  EXPECT_EQ(\"(false, 2, 3, 4, true, 6)\", Print(t6));\n\n  ::std::tuple<bool, int, int, int, bool, int, int> t7(\n      false, 2, 3, 4, true, 6, 7);\n  EXPECT_EQ(\"(false, 2, 3, 4, true, 6, 7)\", Print(t7));\n\n  ::std::tuple<bool, int, int, int, bool, int, int, bool> t8(\n      false, 2, 3, 4, true, 6, 7, true);\n  EXPECT_EQ(\"(false, 2, 3, 4, true, 6, 7, true)\", Print(t8));\n\n  ::std::tuple<bool, int, int, int, bool, int, int, bool, int> t9(\n      false, 2, 3, 4, true, 6, 7, true, 9);\n  EXPECT_EQ(\"(false, 2, 3, 4, true, 6, 7, true, 9)\", Print(t9));\n\n  const char* const str = \"8\";\n  // VC++ 2010's implementation of tuple of C++0x is deficient, requiring\n  // an explicit type cast of NULL to be used.\n  ::std::tuple<bool, char, short, testing::internal::Int32,  // NOLINT\n      testing::internal::Int64, float, double, const char*, void*, string>\n      t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str,\n          ImplicitCast_<void*>(NULL), \"10\");\n  EXPECT_EQ(\"(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, \" + PrintPointer(str) +\n            \" pointing to \\\"8\\\", NULL, \\\"10\\\")\",\n            Print(t10));\n}\n\n// Nested tuples.\nTEST(PrintStdTupleTest, NestedTuple) {\n  ::std::tuple< ::std::tuple<int, bool>, char> nested(\n      ::std::make_tuple(5, true), 'a');\n  EXPECT_EQ(\"((5, true), 'a' (97, 0x61))\", Print(nested));\n}\n\n#endif  // GTEST_LANG_CXX11\n\n// Tests printing user-defined unprintable types.\n\n// Unprintable types in the global namespace.\nTEST(PrintUnprintableTypeTest, InGlobalNamespace) {\n  EXPECT_EQ(\"1-byte object <00>\",\n            Print(UnprintableTemplateInGlobal<char>()));\n}\n\n// Unprintable types in a user namespace.\nTEST(PrintUnprintableTypeTest, InUserNamespace) {\n  EXPECT_EQ(\"16-byte object <EF-12 00-00 34-AB 00-00 00-00 00-00 00-00 00-00>\",\n            Print(::foo::UnprintableInFoo()));\n}\n\n// Unprintable types are that too big to be printed completely.\n\nstruct Big {\n  Big() { memset(array, 0, sizeof(array)); }\n  char array[257];\n};\n\nTEST(PrintUnpritableTypeTest, BigObject) {\n  EXPECT_EQ(\"257-byte object <00-00 00-00 00-00 00-00 00-00 00-00 \"\n            \"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 \"\n            \"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 \"\n            \"00-00 00-00 00-00 00-00 00-00 00-00 ... 00-00 00-00 00-00 \"\n            \"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 \"\n            \"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 \"\n            \"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00>\",\n            Print(Big()));\n}\n\n// Tests printing user-defined streamable types.\n\n// Streamable types in the global namespace.\nTEST(PrintStreamableTypeTest, InGlobalNamespace) {\n  StreamableInGlobal x;\n  EXPECT_EQ(\"StreamableInGlobal\", Print(x));\n  EXPECT_EQ(\"StreamableInGlobal*\", Print(&x));\n}\n\n// Printable template types in a user namespace.\nTEST(PrintStreamableTypeTest, TemplateTypeInUserNamespace) {\n  EXPECT_EQ(\"StreamableTemplateInFoo: 0\",\n            Print(::foo::StreamableTemplateInFoo<int>()));\n}\n\n// Tests printing user-defined types that have a PrintTo() function.\nTEST(PrintPrintableTypeTest, InUserNamespace) {\n  EXPECT_EQ(\"PrintableViaPrintTo: 0\",\n            Print(::foo::PrintableViaPrintTo()));\n}\n\n// Tests printing a pointer to a user-defined type that has a <<\n// operator for its pointer.\nTEST(PrintPrintableTypeTest, PointerInUserNamespace) {\n  ::foo::PointerPrintable x;\n  EXPECT_EQ(\"PointerPrintable*\", Print(&x));\n}\n\n// Tests printing user-defined class template that have a PrintTo() function.\nTEST(PrintPrintableTypeTest, TemplateInUserNamespace) {\n  EXPECT_EQ(\"PrintableViaPrintToTemplate: 5\",\n            Print(::foo::PrintableViaPrintToTemplate<int>(5)));\n}\n\n// Tests that the universal printer prints both the address and the\n// value of a reference.\nTEST(PrintReferenceTest, PrintsAddressAndValue) {\n  int n = 5;\n  EXPECT_EQ(\"@\" + PrintPointer(&n) + \" 5\", PrintByRef(n));\n\n  int a[2][3] = {\n    { 0, 1, 2 },\n    { 3, 4, 5 }\n  };\n  EXPECT_EQ(\"@\" + PrintPointer(a) + \" { { 0, 1, 2 }, { 3, 4, 5 } }\",\n            PrintByRef(a));\n\n  const ::foo::UnprintableInFoo x;\n  EXPECT_EQ(\"@\" + PrintPointer(&x) + \" 16-byte object \"\n            \"<EF-12 00-00 34-AB 00-00 00-00 00-00 00-00 00-00>\",\n            PrintByRef(x));\n}\n\n// Tests that the universal printer prints a function pointer passed by\n// reference.\nTEST(PrintReferenceTest, HandlesFunctionPointer) {\n  void (*fp)(int n) = &MyFunction;\n  const string fp_pointer_string =\n      PrintPointer(reinterpret_cast<const void*>(&fp));\n  // We cannot directly cast &MyFunction to const void* because the\n  // standard disallows casting between pointers to functions and\n  // pointers to objects, and some compilers (e.g. GCC 3.4) enforce\n  // this limitation.\n  const string fp_string = PrintPointer(reinterpret_cast<const void*>(\n      reinterpret_cast<internal::BiggestInt>(fp)));\n  EXPECT_EQ(\"@\" + fp_pointer_string + \" \" + fp_string,\n            PrintByRef(fp));\n}\n\n// Tests that the universal printer prints a member function pointer\n// passed by reference.\nTEST(PrintReferenceTest, HandlesMemberFunctionPointer) {\n  int (Foo::*p)(char ch) = &Foo::MyMethod;\n  EXPECT_TRUE(HasPrefix(\n      PrintByRef(p),\n      \"@\" + PrintPointer(reinterpret_cast<const void*>(&p)) + \" \" +\n          Print(sizeof(p)) + \"-byte object \"));\n\n  char (Foo::*p2)(int n) = &Foo::MyVirtualMethod;\n  EXPECT_TRUE(HasPrefix(\n      PrintByRef(p2),\n      \"@\" + PrintPointer(reinterpret_cast<const void*>(&p2)) + \" \" +\n          Print(sizeof(p2)) + \"-byte object \"));\n}\n\n// Tests that the universal printer prints a member variable pointer\n// passed by reference.\nTEST(PrintReferenceTest, HandlesMemberVariablePointer) {\n  int (Foo::*p) = &Foo::value;  // NOLINT\n  EXPECT_TRUE(HasPrefix(\n      PrintByRef(p),\n      \"@\" + PrintPointer(&p) + \" \" + Print(sizeof(p)) + \"-byte object \"));\n}\n\n// Tests that FormatForComparisonFailureMessage(), which is used to print\n// an operand in a comparison assertion (e.g. ASSERT_EQ) when the assertion\n// fails, formats the operand in the desired way.\n\n// scalar\nTEST(FormatForComparisonFailureMessageTest, WorksForScalar) {\n  EXPECT_STREQ(\"123\",\n               FormatForComparisonFailureMessage(123, 124).c_str());\n}\n\n// non-char pointer\nTEST(FormatForComparisonFailureMessageTest, WorksForNonCharPointer) {\n  int n = 0;\n  EXPECT_EQ(PrintPointer(&n),\n            FormatForComparisonFailureMessage(&n, &n).c_str());\n}\n\n// non-char array\nTEST(FormatForComparisonFailureMessageTest, FormatsNonCharArrayAsPointer) {\n  // In expression 'array == x', 'array' is compared by pointer.\n  // Therefore we want to print an array operand as a pointer.\n  int n[] = { 1, 2, 3 };\n  EXPECT_EQ(PrintPointer(n),\n            FormatForComparisonFailureMessage(n, n).c_str());\n}\n\n// Tests formatting a char pointer when it's compared with another pointer.\n// In this case we want to print it as a raw pointer, as the comparision is by\n// pointer.\n\n// char pointer vs pointer\nTEST(FormatForComparisonFailureMessageTest, WorksForCharPointerVsPointer) {\n  // In expression 'p == x', where 'p' and 'x' are (const or not) char\n  // pointers, the operands are compared by pointer.  Therefore we\n  // want to print 'p' as a pointer instead of a C string (we don't\n  // even know if it's supposed to point to a valid C string).\n\n  // const char*\n  const char* s = \"hello\";\n  EXPECT_EQ(PrintPointer(s),\n            FormatForComparisonFailureMessage(s, s).c_str());\n\n  // char*\n  char ch = 'a';\n  EXPECT_EQ(PrintPointer(&ch),\n            FormatForComparisonFailureMessage(&ch, &ch).c_str());\n}\n\n// wchar_t pointer vs pointer\nTEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsPointer) {\n  // In expression 'p == x', where 'p' and 'x' are (const or not) char\n  // pointers, the operands are compared by pointer.  Therefore we\n  // want to print 'p' as a pointer instead of a wide C string (we don't\n  // even know if it's supposed to point to a valid wide C string).\n\n  // const wchar_t*\n  const wchar_t* s = L\"hello\";\n  EXPECT_EQ(PrintPointer(s),\n            FormatForComparisonFailureMessage(s, s).c_str());\n\n  // wchar_t*\n  wchar_t ch = L'a';\n  EXPECT_EQ(PrintPointer(&ch),\n            FormatForComparisonFailureMessage(&ch, &ch).c_str());\n}\n\n// Tests formatting a char pointer when it's compared to a string object.\n// In this case we want to print the char pointer as a C string.\n\n#if GTEST_HAS_GLOBAL_STRING\n// char pointer vs ::string\nTEST(FormatForComparisonFailureMessageTest, WorksForCharPointerVsString) {\n  const char* s = \"hello \\\"world\";\n  EXPECT_STREQ(\"\\\"hello \\\\\\\"world\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(s, ::string()).c_str());\n\n  // char*\n  char str[] = \"hi\\1\";\n  char* p = str;\n  EXPECT_STREQ(\"\\\"hi\\\\x1\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(p, ::string()).c_str());\n}\n#endif\n\n// char pointer vs std::string\nTEST(FormatForComparisonFailureMessageTest, WorksForCharPointerVsStdString) {\n  const char* s = \"hello \\\"world\";\n  EXPECT_STREQ(\"\\\"hello \\\\\\\"world\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(s, ::std::string()).c_str());\n\n  // char*\n  char str[] = \"hi\\1\";\n  char* p = str;\n  EXPECT_STREQ(\"\\\"hi\\\\x1\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(p, ::std::string()).c_str());\n}\n\n#if GTEST_HAS_GLOBAL_WSTRING\n// wchar_t pointer vs ::wstring\nTEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsWString) {\n  const wchar_t* s = L\"hi \\\"world\";\n  EXPECT_STREQ(\"L\\\"hi \\\\\\\"world\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(s, ::wstring()).c_str());\n\n  // wchar_t*\n  wchar_t str[] = L\"hi\\1\";\n  wchar_t* p = str;\n  EXPECT_STREQ(\"L\\\"hi\\\\x1\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(p, ::wstring()).c_str());\n}\n#endif\n\n#if GTEST_HAS_STD_WSTRING\n// wchar_t pointer vs std::wstring\nTEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsStdWString) {\n  const wchar_t* s = L\"hi \\\"world\";\n  EXPECT_STREQ(\"L\\\"hi \\\\\\\"world\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(s, ::std::wstring()).c_str());\n\n  // wchar_t*\n  wchar_t str[] = L\"hi\\1\";\n  wchar_t* p = str;\n  EXPECT_STREQ(\"L\\\"hi\\\\x1\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(p, ::std::wstring()).c_str());\n}\n#endif\n\n// Tests formatting a char array when it's compared with a pointer or array.\n// In this case we want to print the array as a row pointer, as the comparison\n// is by pointer.\n\n// char array vs pointer\nTEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsPointer) {\n  char str[] = \"hi \\\"world\\\"\";\n  char* p = NULL;\n  EXPECT_EQ(PrintPointer(str),\n            FormatForComparisonFailureMessage(str, p).c_str());\n}\n\n// char array vs char array\nTEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsCharArray) {\n  const char str[] = \"hi \\\"world\\\"\";\n  EXPECT_EQ(PrintPointer(str),\n            FormatForComparisonFailureMessage(str, str).c_str());\n}\n\n// wchar_t array vs pointer\nTEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsPointer) {\n  wchar_t str[] = L\"hi \\\"world\\\"\";\n  wchar_t* p = NULL;\n  EXPECT_EQ(PrintPointer(str),\n            FormatForComparisonFailureMessage(str, p).c_str());\n}\n\n// wchar_t array vs wchar_t array\nTEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsWCharArray) {\n  const wchar_t str[] = L\"hi \\\"world\\\"\";\n  EXPECT_EQ(PrintPointer(str),\n            FormatForComparisonFailureMessage(str, str).c_str());\n}\n\n// Tests formatting a char array when it's compared with a string object.\n// In this case we want to print the array as a C string.\n\n#if GTEST_HAS_GLOBAL_STRING\n// char array vs string\nTEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsString) {\n  const char str[] = \"hi \\\"w\\0rld\\\"\";\n  EXPECT_STREQ(\"\\\"hi \\\\\\\"w\\\"\",  // The content should be escaped.\n                                // Embedded NUL terminates the string.\n               FormatForComparisonFailureMessage(str, ::string()).c_str());\n}\n#endif\n\n// char array vs std::string\nTEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsStdString) {\n  const char str[] = \"hi \\\"world\\\"\";\n  EXPECT_STREQ(\"\\\"hi \\\\\\\"world\\\\\\\"\\\"\",  // The content should be escaped.\n               FormatForComparisonFailureMessage(str, ::std::string()).c_str());\n}\n\n#if GTEST_HAS_GLOBAL_WSTRING\n// wchar_t array vs wstring\nTEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsWString) {\n  const wchar_t str[] = L\"hi \\\"world\\\"\";\n  EXPECT_STREQ(\"L\\\"hi \\\\\\\"world\\\\\\\"\\\"\",  // The content should be escaped.\n               FormatForComparisonFailureMessage(str, ::wstring()).c_str());\n}\n#endif\n\n#if GTEST_HAS_STD_WSTRING\n// wchar_t array vs std::wstring\nTEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsStdWString) {\n  const wchar_t str[] = L\"hi \\\"w\\0rld\\\"\";\n  EXPECT_STREQ(\n      \"L\\\"hi \\\\\\\"w\\\"\",  // The content should be escaped.\n                        // Embedded NUL terminates the string.\n      FormatForComparisonFailureMessage(str, ::std::wstring()).c_str());\n}\n#endif\n\n// Useful for testing PrintToString().  We cannot use EXPECT_EQ()\n// there as its implementation uses PrintToString().  The caller must\n// ensure that 'value' has no side effect.\n#define EXPECT_PRINT_TO_STRING_(value, expected_string)         \\\n  EXPECT_TRUE(PrintToString(value) == (expected_string))        \\\n      << \" where \" #value \" prints as \" << (PrintToString(value))\n\nTEST(PrintToStringTest, WorksForScalar) {\n  EXPECT_PRINT_TO_STRING_(123, \"123\");\n}\n\nTEST(PrintToStringTest, WorksForPointerToConstChar) {\n  const char* p = \"hello\";\n  EXPECT_PRINT_TO_STRING_(p, \"\\\"hello\\\"\");\n}\n\nTEST(PrintToStringTest, WorksForPointerToNonConstChar) {\n  char s[] = \"hello\";\n  char* p = s;\n  EXPECT_PRINT_TO_STRING_(p, \"\\\"hello\\\"\");\n}\n\nTEST(PrintToStringTest, EscapesForPointerToConstChar) {\n  const char* p = \"hello\\n\";\n  EXPECT_PRINT_TO_STRING_(p, \"\\\"hello\\\\n\\\"\");\n}\n\nTEST(PrintToStringTest, EscapesForPointerToNonConstChar) {\n  char s[] = \"hello\\1\";\n  char* p = s;\n  EXPECT_PRINT_TO_STRING_(p, \"\\\"hello\\\\x1\\\"\");\n}\n\nTEST(PrintToStringTest, WorksForArray) {\n  int n[3] = { 1, 2, 3 };\n  EXPECT_PRINT_TO_STRING_(n, \"{ 1, 2, 3 }\");\n}\n\nTEST(PrintToStringTest, WorksForCharArray) {\n  char s[] = \"hello\";\n  EXPECT_PRINT_TO_STRING_(s, \"\\\"hello\\\"\");\n}\n\nTEST(PrintToStringTest, WorksForCharArrayWithEmbeddedNul) {\n  const char str_with_nul[] = \"hello\\0 world\";\n  EXPECT_PRINT_TO_STRING_(str_with_nul, \"\\\"hello\\\\0 world\\\"\");\n\n  char mutable_str_with_nul[] = \"hello\\0 world\";\n  EXPECT_PRINT_TO_STRING_(mutable_str_with_nul, \"\\\"hello\\\\0 world\\\"\");\n}\n\n#undef EXPECT_PRINT_TO_STRING_\n\nTEST(UniversalTersePrintTest, WorksForNonReference) {\n  ::std::stringstream ss;\n  UniversalTersePrint(123, &ss);\n  EXPECT_EQ(\"123\", ss.str());\n}\n\nTEST(UniversalTersePrintTest, WorksForReference) {\n  const int& n = 123;\n  ::std::stringstream ss;\n  UniversalTersePrint(n, &ss);\n  EXPECT_EQ(\"123\", ss.str());\n}\n\nTEST(UniversalTersePrintTest, WorksForCString) {\n  const char* s1 = \"abc\";\n  ::std::stringstream ss1;\n  UniversalTersePrint(s1, &ss1);\n  EXPECT_EQ(\"\\\"abc\\\"\", ss1.str());\n\n  char* s2 = const_cast<char*>(s1);\n  ::std::stringstream ss2;\n  UniversalTersePrint(s2, &ss2);\n  EXPECT_EQ(\"\\\"abc\\\"\", ss2.str());\n\n  const char* s3 = NULL;\n  ::std::stringstream ss3;\n  UniversalTersePrint(s3, &ss3);\n  EXPECT_EQ(\"NULL\", ss3.str());\n}\n\nTEST(UniversalPrintTest, WorksForNonReference) {\n  ::std::stringstream ss;\n  UniversalPrint(123, &ss);\n  EXPECT_EQ(\"123\", ss.str());\n}\n\nTEST(UniversalPrintTest, WorksForReference) {\n  const int& n = 123;\n  ::std::stringstream ss;\n  UniversalPrint(n, &ss);\n  EXPECT_EQ(\"123\", ss.str());\n}\n\nTEST(UniversalPrintTest, WorksForCString) {\n  const char* s1 = \"abc\";\n  ::std::stringstream ss1;\n  UniversalPrint(s1, &ss1);\n  EXPECT_EQ(PrintPointer(s1) + \" pointing to \\\"abc\\\"\", string(ss1.str()));\n\n  char* s2 = const_cast<char*>(s1);\n  ::std::stringstream ss2;\n  UniversalPrint(s2, &ss2);\n  EXPECT_EQ(PrintPointer(s2) + \" pointing to \\\"abc\\\"\", string(ss2.str()));\n\n  const char* s3 = NULL;\n  ::std::stringstream ss3;\n  UniversalPrint(s3, &ss3);\n  EXPECT_EQ(\"NULL\", ss3.str());\n}\n\nTEST(UniversalPrintTest, WorksForCharArray) {\n  const char str[] = \"\\\"Line\\0 1\\\"\\nLine 2\";\n  ::std::stringstream ss1;\n  UniversalPrint(str, &ss1);\n  EXPECT_EQ(\"\\\"\\\\\\\"Line\\\\0 1\\\\\\\"\\\\nLine 2\\\"\", ss1.str());\n\n  const char mutable_str[] = \"\\\"Line\\0 1\\\"\\nLine 2\";\n  ::std::stringstream ss2;\n  UniversalPrint(mutable_str, &ss2);\n  EXPECT_EQ(\"\\\"\\\\\\\"Line\\\\0 1\\\\\\\"\\\\nLine 2\\\"\", ss2.str());\n}\n\n#if GTEST_HAS_TR1_TUPLE\n\nTEST(UniversalTersePrintTupleFieldsToStringsTestWithTr1, PrintsEmptyTuple) {\n  Strings result = UniversalTersePrintTupleFieldsToStrings(\n      ::std::tr1::make_tuple());\n  EXPECT_EQ(0u, result.size());\n}\n\nTEST(UniversalTersePrintTupleFieldsToStringsTestWithTr1, PrintsOneTuple) {\n  Strings result = UniversalTersePrintTupleFieldsToStrings(\n      ::std::tr1::make_tuple(1));\n  ASSERT_EQ(1u, result.size());\n  EXPECT_EQ(\"1\", result[0]);\n}\n\nTEST(UniversalTersePrintTupleFieldsToStringsTestWithTr1, PrintsTwoTuple) {\n  Strings result = UniversalTersePrintTupleFieldsToStrings(\n      ::std::tr1::make_tuple(1, 'a'));\n  ASSERT_EQ(2u, result.size());\n  EXPECT_EQ(\"1\", result[0]);\n  EXPECT_EQ(\"'a' (97, 0x61)\", result[1]);\n}\n\nTEST(UniversalTersePrintTupleFieldsToStringsTestWithTr1, PrintsTersely) {\n  const int n = 1;\n  Strings result = UniversalTersePrintTupleFieldsToStrings(\n      ::std::tr1::tuple<const int&, const char*>(n, \"a\"));\n  ASSERT_EQ(2u, result.size());\n  EXPECT_EQ(\"1\", result[0]);\n  EXPECT_EQ(\"\\\"a\\\"\", result[1]);\n}\n\n#endif  // GTEST_HAS_TR1_TUPLE\n\n#if GTEST_HAS_STD_TUPLE_\n\nTEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsEmptyTuple) {\n  Strings result = UniversalTersePrintTupleFieldsToStrings(::std::make_tuple());\n  EXPECT_EQ(0u, result.size());\n}\n\nTEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsOneTuple) {\n  Strings result = UniversalTersePrintTupleFieldsToStrings(\n      ::std::make_tuple(1));\n  ASSERT_EQ(1u, result.size());\n  EXPECT_EQ(\"1\", result[0]);\n}\n\nTEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTwoTuple) {\n  Strings result = UniversalTersePrintTupleFieldsToStrings(\n      ::std::make_tuple(1, 'a'));\n  ASSERT_EQ(2u, result.size());\n  EXPECT_EQ(\"1\", result[0]);\n  EXPECT_EQ(\"'a' (97, 0x61)\", result[1]);\n}\n\nTEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTersely) {\n  const int n = 1;\n  Strings result = UniversalTersePrintTupleFieldsToStrings(\n      ::std::tuple<const int&, const char*>(n, \"a\"));\n  ASSERT_EQ(2u, result.size());\n  EXPECT_EQ(\"1\", result[0]);\n  EXPECT_EQ(\"\\\"a\\\"\", result[1]);\n}\n\n#endif  // GTEST_HAS_STD_TUPLE_\n\n}  // namespace gtest_printers_test\n}  // namespace testing\n\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-test-part_test.cc",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: mheule@google.com (Markus Heule)\n//\n\n#include \"gtest/gtest-test-part.h\"\n\n#include \"gtest/gtest.h\"\n\nusing testing::Message;\nusing testing::Test;\nusing testing::TestPartResult;\nusing testing::TestPartResultArray;\n\nnamespace {\n\n// Tests the TestPartResult class.\n\n// The test fixture for testing TestPartResult.\nclass TestPartResultTest : public Test {\n protected:\n  TestPartResultTest()\n      : r1_(TestPartResult::kSuccess, \"foo/bar.cc\", 10, \"Success!\"),\n        r2_(TestPartResult::kNonFatalFailure, \"foo/bar.cc\", -1, \"Failure!\"),\n        r3_(TestPartResult::kFatalFailure, NULL, -1, \"Failure!\") {}\n\n  TestPartResult r1_, r2_, r3_;\n};\n\n\nTEST_F(TestPartResultTest, ConstructorWorks) {\n  Message message;\n  message << \"something is terribly wrong\";\n  message << static_cast<const char*>(testing::internal::kStackTraceMarker);\n  message << \"some unimportant stack trace\";\n\n  const TestPartResult result(TestPartResult::kNonFatalFailure,\n                              \"some_file.cc\",\n                              42,\n                              message.GetString().c_str());\n\n  EXPECT_EQ(TestPartResult::kNonFatalFailure, result.type());\n  EXPECT_STREQ(\"some_file.cc\", result.file_name());\n  EXPECT_EQ(42, result.line_number());\n  EXPECT_STREQ(message.GetString().c_str(), result.message());\n  EXPECT_STREQ(\"something is terribly wrong\", result.summary());\n}\n\nTEST_F(TestPartResultTest, ResultAccessorsWork) {\n  const TestPartResult success(TestPartResult::kSuccess,\n                               \"file.cc\",\n                               42,\n                               \"message\");\n  EXPECT_TRUE(success.passed());\n  EXPECT_FALSE(success.failed());\n  EXPECT_FALSE(success.nonfatally_failed());\n  EXPECT_FALSE(success.fatally_failed());\n\n  const TestPartResult nonfatal_failure(TestPartResult::kNonFatalFailure,\n                                        \"file.cc\",\n                                        42,\n                                        \"message\");\n  EXPECT_FALSE(nonfatal_failure.passed());\n  EXPECT_TRUE(nonfatal_failure.failed());\n  EXPECT_TRUE(nonfatal_failure.nonfatally_failed());\n  EXPECT_FALSE(nonfatal_failure.fatally_failed());\n\n  const TestPartResult fatal_failure(TestPartResult::kFatalFailure,\n                                     \"file.cc\",\n                                     42,\n                                     \"message\");\n  EXPECT_FALSE(fatal_failure.passed());\n  EXPECT_TRUE(fatal_failure.failed());\n  EXPECT_FALSE(fatal_failure.nonfatally_failed());\n  EXPECT_TRUE(fatal_failure.fatally_failed());\n}\n\n// Tests TestPartResult::type().\nTEST_F(TestPartResultTest, type) {\n  EXPECT_EQ(TestPartResult::kSuccess, r1_.type());\n  EXPECT_EQ(TestPartResult::kNonFatalFailure, r2_.type());\n  EXPECT_EQ(TestPartResult::kFatalFailure, r3_.type());\n}\n\n// Tests TestPartResult::file_name().\nTEST_F(TestPartResultTest, file_name) {\n  EXPECT_STREQ(\"foo/bar.cc\", r1_.file_name());\n  EXPECT_STREQ(NULL, r3_.file_name());\n}\n\n// Tests TestPartResult::line_number().\nTEST_F(TestPartResultTest, line_number) {\n  EXPECT_EQ(10, r1_.line_number());\n  EXPECT_EQ(-1, r2_.line_number());\n}\n\n// Tests TestPartResult::message().\nTEST_F(TestPartResultTest, message) {\n  EXPECT_STREQ(\"Success!\", r1_.message());\n}\n\n// Tests TestPartResult::passed().\nTEST_F(TestPartResultTest, Passed) {\n  EXPECT_TRUE(r1_.passed());\n  EXPECT_FALSE(r2_.passed());\n  EXPECT_FALSE(r3_.passed());\n}\n\n// Tests TestPartResult::failed().\nTEST_F(TestPartResultTest, Failed) {\n  EXPECT_FALSE(r1_.failed());\n  EXPECT_TRUE(r2_.failed());\n  EXPECT_TRUE(r3_.failed());\n}\n\n// Tests TestPartResult::fatally_failed().\nTEST_F(TestPartResultTest, FatallyFailed) {\n  EXPECT_FALSE(r1_.fatally_failed());\n  EXPECT_FALSE(r2_.fatally_failed());\n  EXPECT_TRUE(r3_.fatally_failed());\n}\n\n// Tests TestPartResult::nonfatally_failed().\nTEST_F(TestPartResultTest, NonfatallyFailed) {\n  EXPECT_FALSE(r1_.nonfatally_failed());\n  EXPECT_TRUE(r2_.nonfatally_failed());\n  EXPECT_FALSE(r3_.nonfatally_failed());\n}\n\n// Tests the TestPartResultArray class.\n\nclass TestPartResultArrayTest : public Test {\n protected:\n  TestPartResultArrayTest()\n      : r1_(TestPartResult::kNonFatalFailure, \"foo/bar.cc\", -1, \"Failure 1\"),\n        r2_(TestPartResult::kFatalFailure, \"foo/bar.cc\", -1, \"Failure 2\") {}\n\n  const TestPartResult r1_, r2_;\n};\n\n// Tests that TestPartResultArray initially has size 0.\nTEST_F(TestPartResultArrayTest, InitialSizeIsZero) {\n  TestPartResultArray results;\n  EXPECT_EQ(0, results.size());\n}\n\n// Tests that TestPartResultArray contains the given TestPartResult\n// after one Append() operation.\nTEST_F(TestPartResultArrayTest, ContainsGivenResultAfterAppend) {\n  TestPartResultArray results;\n  results.Append(r1_);\n  EXPECT_EQ(1, results.size());\n  EXPECT_STREQ(\"Failure 1\", results.GetTestPartResult(0).message());\n}\n\n// Tests that TestPartResultArray contains the given TestPartResults\n// after two Append() operations.\nTEST_F(TestPartResultArrayTest, ContainsGivenResultsAfterTwoAppends) {\n  TestPartResultArray results;\n  results.Append(r1_);\n  results.Append(r2_);\n  EXPECT_EQ(2, results.size());\n  EXPECT_STREQ(\"Failure 1\", results.GetTestPartResult(0).message());\n  EXPECT_STREQ(\"Failure 2\", results.GetTestPartResult(1).message());\n}\n\ntypedef TestPartResultArrayTest TestPartResultArrayDeathTest;\n\n// Tests that the program dies when GetTestPartResult() is called with\n// an invalid index.\nTEST_F(TestPartResultArrayDeathTest, DiesWhenIndexIsOutOfBound) {\n  TestPartResultArray results;\n  results.Append(r1_);\n\n  EXPECT_DEATH_IF_SUPPORTED(results.GetTestPartResult(-1), \"\");\n  EXPECT_DEATH_IF_SUPPORTED(results.GetTestPartResult(1), \"\");\n}\n\n// TODO(mheule@google.com): Add a test for the class HasNewFatalFailureHelper.\n\n}  // namespace\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-tuple_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/internal/gtest-tuple.h\"\n#include <utility>\n#include \"gtest/gtest.h\"\n\nnamespace {\n\nusing ::std::tr1::get;\nusing ::std::tr1::make_tuple;\nusing ::std::tr1::tuple;\nusing ::std::tr1::tuple_element;\nusing ::std::tr1::tuple_size;\nusing ::testing::StaticAssertTypeEq;\n\n// Tests that tuple_element<K, tuple<T0, T1, ..., TN> >::type returns TK.\nTEST(tuple_element_Test, ReturnsElementType) {\n  StaticAssertTypeEq<int, tuple_element<0, tuple<int, char> >::type>();\n  StaticAssertTypeEq<int&, tuple_element<1, tuple<double, int&> >::type>();\n  StaticAssertTypeEq<bool, tuple_element<2, tuple<double, int, bool> >::type>();\n}\n\n// Tests that tuple_size<T>::value gives the number of fields in tuple\n// type T.\nTEST(tuple_size_Test, ReturnsNumberOfFields) {\n  EXPECT_EQ(0, +tuple_size<tuple<> >::value);\n  EXPECT_EQ(1, +tuple_size<tuple<void*> >::value);\n  EXPECT_EQ(1, +tuple_size<tuple<char> >::value);\n  EXPECT_EQ(1, +(tuple_size<tuple<tuple<int, double> > >::value));\n  EXPECT_EQ(2, +(tuple_size<tuple<int&, const char> >::value));\n  EXPECT_EQ(3, +(tuple_size<tuple<char*, void, const bool&> >::value));\n}\n\n// Tests comparing a tuple with itself.\nTEST(ComparisonTest, ComparesWithSelf) {\n  const tuple<int, char, bool> a(5, 'a', false);\n\n  EXPECT_TRUE(a == a);\n  EXPECT_FALSE(a != a);\n}\n\n// Tests comparing two tuples with the same value.\nTEST(ComparisonTest, ComparesEqualTuples) {\n  const tuple<int, bool> a(5, true), b(5, true);\n\n  EXPECT_TRUE(a == b);\n  EXPECT_FALSE(a != b);\n}\n\n// Tests comparing two different tuples that have no reference fields.\nTEST(ComparisonTest, ComparesUnequalTuplesWithoutReferenceFields) {\n  typedef tuple<const int, char> FooTuple;\n\n  const FooTuple a(0, 'x');\n  const FooTuple b(1, 'a');\n\n  EXPECT_TRUE(a != b);\n  EXPECT_FALSE(a == b);\n\n  const FooTuple c(1, 'b');\n\n  EXPECT_TRUE(b != c);\n  EXPECT_FALSE(b == c);\n}\n\n// Tests comparing two different tuples that have reference fields.\nTEST(ComparisonTest, ComparesUnequalTuplesWithReferenceFields) {\n  typedef tuple<int&, const char&> FooTuple;\n\n  int i = 5;\n  const char ch = 'a';\n  const FooTuple a(i, ch);\n\n  int j = 6;\n  const FooTuple b(j, ch);\n\n  EXPECT_TRUE(a != b);\n  EXPECT_FALSE(a == b);\n\n  j = 5;\n  const char ch2 = 'b';\n  const FooTuple c(j, ch2);\n\n  EXPECT_TRUE(b != c);\n  EXPECT_FALSE(b == c);\n}\n\n// Tests that a tuple field with a reference type is an alias of the\n// variable it's supposed to reference.\nTEST(ReferenceFieldTest, IsAliasOfReferencedVariable) {\n  int n = 0;\n  tuple<bool, int&> t(true, n);\n\n  n = 1;\n  EXPECT_EQ(n, get<1>(t))\n      << \"Changing a underlying variable should update the reference field.\";\n\n  // Makes sure that the implementation doesn't do anything funny with\n  // the & operator for the return type of get<>().\n  EXPECT_EQ(&n, &(get<1>(t)))\n      << \"The address of a reference field should equal the address of \"\n      << \"the underlying variable.\";\n\n  get<1>(t) = 2;\n  EXPECT_EQ(2, n)\n      << \"Changing a reference field should update the underlying variable.\";\n}\n\n// Tests that tuple's default constructor default initializes each field.\n// This test needs to compile without generating warnings.\nTEST(TupleConstructorTest, DefaultConstructorDefaultInitializesEachField) {\n  // The TR1 report requires that tuple's default constructor default\n  // initializes each field, even if it's a primitive type.  If the\n  // implementation forgets to do this, this test will catch it by\n  // generating warnings about using uninitialized variables (assuming\n  // a decent compiler).\n\n  tuple<> empty;\n\n  tuple<int> a1, b1;\n  b1 = a1;\n  EXPECT_EQ(0, get<0>(b1));\n\n  tuple<int, double> a2, b2;\n  b2 = a2;\n  EXPECT_EQ(0, get<0>(b2));\n  EXPECT_EQ(0.0, get<1>(b2));\n\n  tuple<double, char, bool*> a3, b3;\n  b3 = a3;\n  EXPECT_EQ(0.0, get<0>(b3));\n  EXPECT_EQ('\\0', get<1>(b3));\n  EXPECT_TRUE(get<2>(b3) == NULL);\n\n  tuple<int, int, int, int, int, int, int, int, int, int> a10, b10;\n  b10 = a10;\n  EXPECT_EQ(0, get<0>(b10));\n  EXPECT_EQ(0, get<1>(b10));\n  EXPECT_EQ(0, get<2>(b10));\n  EXPECT_EQ(0, get<3>(b10));\n  EXPECT_EQ(0, get<4>(b10));\n  EXPECT_EQ(0, get<5>(b10));\n  EXPECT_EQ(0, get<6>(b10));\n  EXPECT_EQ(0, get<7>(b10));\n  EXPECT_EQ(0, get<8>(b10));\n  EXPECT_EQ(0, get<9>(b10));\n}\n\n// Tests constructing a tuple from its fields.\nTEST(TupleConstructorTest, ConstructsFromFields) {\n  int n = 1;\n  // Reference field.\n  tuple<int&> a(n);\n  EXPECT_EQ(&n, &(get<0>(a)));\n\n  // Non-reference fields.\n  tuple<int, char> b(5, 'a');\n  EXPECT_EQ(5, get<0>(b));\n  EXPECT_EQ('a', get<1>(b));\n\n  // Const reference field.\n  const int m = 2;\n  tuple<bool, const int&> c(true, m);\n  EXPECT_TRUE(get<0>(c));\n  EXPECT_EQ(&m, &(get<1>(c)));\n}\n\n// Tests tuple's copy constructor.\nTEST(TupleConstructorTest, CopyConstructor) {\n  tuple<double, bool> a(0.0, true);\n  tuple<double, bool> b(a);\n\n  EXPECT_DOUBLE_EQ(0.0, get<0>(b));\n  EXPECT_TRUE(get<1>(b));\n}\n\n// Tests constructing a tuple from another tuple that has a compatible\n// but different type.\nTEST(TupleConstructorTest, ConstructsFromDifferentTupleType) {\n  tuple<int, int, char> a(0, 1, 'a');\n  tuple<double, long, int> b(a);\n\n  EXPECT_DOUBLE_EQ(0.0, get<0>(b));\n  EXPECT_EQ(1, get<1>(b));\n  EXPECT_EQ('a', get<2>(b));\n}\n\n// Tests constructing a 2-tuple from an std::pair.\nTEST(TupleConstructorTest, ConstructsFromPair) {\n  ::std::pair<int, char> a(1, 'a');\n  tuple<int, char> b(a);\n  tuple<int, const char&> c(a);\n}\n\n// Tests assigning a tuple to another tuple with the same type.\nTEST(TupleAssignmentTest, AssignsToSameTupleType) {\n  const tuple<int, long> a(5, 7L);\n  tuple<int, long> b;\n  b = a;\n  EXPECT_EQ(5, get<0>(b));\n  EXPECT_EQ(7L, get<1>(b));\n}\n\n// Tests assigning a tuple to another tuple with a different but\n// compatible type.\nTEST(TupleAssignmentTest, AssignsToDifferentTupleType) {\n  const tuple<int, long, bool> a(1, 7L, true);\n  tuple<long, int, bool> b;\n  b = a;\n  EXPECT_EQ(1L, get<0>(b));\n  EXPECT_EQ(7, get<1>(b));\n  EXPECT_TRUE(get<2>(b));\n}\n\n// Tests assigning an std::pair to a 2-tuple.\nTEST(TupleAssignmentTest, AssignsFromPair) {\n  const ::std::pair<int, bool> a(5, true);\n  tuple<int, bool> b;\n  b = a;\n  EXPECT_EQ(5, get<0>(b));\n  EXPECT_TRUE(get<1>(b));\n\n  tuple<long, bool> c;\n  c = a;\n  EXPECT_EQ(5L, get<0>(c));\n  EXPECT_TRUE(get<1>(c));\n}\n\n// A fixture for testing big tuples.\nclass BigTupleTest : public testing::Test {\n protected:\n  typedef tuple<int, int, int, int, int, int, int, int, int, int> BigTuple;\n\n  BigTupleTest() :\n      a_(1, 0, 0, 0, 0, 0, 0, 0, 0, 2),\n      b_(1, 0, 0, 0, 0, 0, 0, 0, 0, 3) {}\n\n  BigTuple a_, b_;\n};\n\n// Tests constructing big tuples.\nTEST_F(BigTupleTest, Construction) {\n  BigTuple a;\n  BigTuple b(b_);\n}\n\n// Tests that get<N>(t) returns the N-th (0-based) field of tuple t.\nTEST_F(BigTupleTest, get) {\n  EXPECT_EQ(1, get<0>(a_));\n  EXPECT_EQ(2, get<9>(a_));\n\n  // Tests that get() works on a const tuple too.\n  const BigTuple a(a_);\n  EXPECT_EQ(1, get<0>(a));\n  EXPECT_EQ(2, get<9>(a));\n}\n\n// Tests comparing big tuples.\nTEST_F(BigTupleTest, Comparisons) {\n  EXPECT_TRUE(a_ == a_);\n  EXPECT_FALSE(a_ != a_);\n\n  EXPECT_TRUE(a_ != b_);\n  EXPECT_FALSE(a_ == b_);\n}\n\nTEST(MakeTupleTest, WorksForScalarTypes) {\n  tuple<bool, int> a;\n  a = make_tuple(true, 5);\n  EXPECT_TRUE(get<0>(a));\n  EXPECT_EQ(5, get<1>(a));\n\n  tuple<char, int, long> b;\n  b = make_tuple('a', 'b', 5);\n  EXPECT_EQ('a', get<0>(b));\n  EXPECT_EQ('b', get<1>(b));\n  EXPECT_EQ(5, get<2>(b));\n}\n\nTEST(MakeTupleTest, WorksForPointers) {\n  int a[] = { 1, 2, 3, 4 };\n  const char* const str = \"hi\";\n  int* const p = a;\n\n  tuple<const char*, int*> t;\n  t = make_tuple(str, p);\n  EXPECT_EQ(str, get<0>(t));\n  EXPECT_EQ(p, get<1>(t));\n}\n\n}  // namespace\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-typed-test2_test.cc",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include <vector>\n\n#include \"test/gtest-typed-test_test.h\"\n#include \"gtest/gtest.h\"\n\n#if GTEST_HAS_TYPED_TEST_P\n\n// Tests that the same type-parameterized test case can be\n// instantiated in different translation units linked together.\n// (ContainerTest is also instantiated in gtest-typed-test_test.cc.)\nINSTANTIATE_TYPED_TEST_CASE_P(Vector, ContainerTest,\n                              testing::Types<std::vector<int> >);\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-typed-test_test.cc",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"test/gtest-typed-test_test.h\"\n\n#include <set>\n#include <vector>\n\n#include \"gtest/gtest.h\"\n\nusing testing::Test;\n\n// Used for testing that SetUpTestCase()/TearDownTestCase(), fixture\n// ctor/dtor, and SetUp()/TearDown() work correctly in typed tests and\n// type-parameterized test.\ntemplate <typename T>\nclass CommonTest : public Test {\n  // For some technical reason, SetUpTestCase() and TearDownTestCase()\n  // must be public.\n public:\n  static void SetUpTestCase() {\n    shared_ = new T(5);\n  }\n\n  static void TearDownTestCase() {\n    delete shared_;\n    shared_ = NULL;\n  }\n\n  // This 'protected:' is optional.  There's no harm in making all\n  // members of this fixture class template public.\n protected:\n  // We used to use std::list here, but switched to std::vector since\n  // MSVC's <list> doesn't compile cleanly with /W4.\n  typedef std::vector<T> Vector;\n  typedef std::set<int> IntSet;\n\n  CommonTest() : value_(1) {}\n\n  virtual ~CommonTest() { EXPECT_EQ(3, value_); }\n\n  virtual void SetUp() {\n    EXPECT_EQ(1, value_);\n    value_++;\n  }\n\n  virtual void TearDown() {\n    EXPECT_EQ(2, value_);\n    value_++;\n  }\n\n  T value_;\n  static T* shared_;\n};\n\ntemplate <typename T>\nT* CommonTest<T>::shared_ = NULL;\n\n// This #ifdef block tests typed tests.\n#if GTEST_HAS_TYPED_TEST\n\nusing testing::Types;\n\n// Tests that SetUpTestCase()/TearDownTestCase(), fixture ctor/dtor,\n// and SetUp()/TearDown() work correctly in typed tests\n\ntypedef Types<char, int> TwoTypes;\nTYPED_TEST_CASE(CommonTest, TwoTypes);\n\nTYPED_TEST(CommonTest, ValuesAreCorrect) {\n  // Static members of the fixture class template can be visited via\n  // the TestFixture:: prefix.\n  EXPECT_EQ(5, *TestFixture::shared_);\n\n  // Typedefs in the fixture class template can be visited via the\n  // \"typename TestFixture::\" prefix.\n  typename TestFixture::Vector empty;\n  EXPECT_EQ(0U, empty.size());\n\n  typename TestFixture::IntSet empty2;\n  EXPECT_EQ(0U, empty2.size());\n\n  // Non-static members of the fixture class must be visited via\n  // 'this', as required by C++ for class templates.\n  EXPECT_EQ(2, this->value_);\n}\n\n// The second test makes sure shared_ is not deleted after the first\n// test.\nTYPED_TEST(CommonTest, ValuesAreStillCorrect) {\n  // Static members of the fixture class template can also be visited\n  // via 'this'.\n  ASSERT_TRUE(this->shared_ != NULL);\n  EXPECT_EQ(5, *this->shared_);\n\n  // TypeParam can be used to refer to the type parameter.\n  EXPECT_EQ(static_cast<TypeParam>(2), this->value_);\n}\n\n// Tests that multiple TYPED_TEST_CASE's can be defined in the same\n// translation unit.\n\ntemplate <typename T>\nclass TypedTest1 : public Test {\n};\n\n// Verifies that the second argument of TYPED_TEST_CASE can be a\n// single type.\nTYPED_TEST_CASE(TypedTest1, int);\nTYPED_TEST(TypedTest1, A) {}\n\ntemplate <typename T>\nclass TypedTest2 : public Test {\n};\n\n// Verifies that the second argument of TYPED_TEST_CASE can be a\n// Types<...> type list.\nTYPED_TEST_CASE(TypedTest2, Types<int>);\n\n// This also verifies that tests from different typed test cases can\n// share the same name.\nTYPED_TEST(TypedTest2, A) {}\n\n// Tests that a typed test case can be defined in a namespace.\n\nnamespace library1 {\n\ntemplate <typename T>\nclass NumericTest : public Test {\n};\n\ntypedef Types<int, long> NumericTypes;\nTYPED_TEST_CASE(NumericTest, NumericTypes);\n\nTYPED_TEST(NumericTest, DefaultIsZero) {\n  EXPECT_EQ(0, TypeParam());\n}\n\n}  // namespace library1\n\n#endif  // GTEST_HAS_TYPED_TEST\n\n// This #ifdef block tests type-parameterized tests.\n#if GTEST_HAS_TYPED_TEST_P\n\nusing testing::Types;\nusing testing::internal::TypedTestCasePState;\n\n// Tests TypedTestCasePState.\n\nclass TypedTestCasePStateTest : public Test {\n protected:\n  virtual void SetUp() {\n    state_.AddTestName(\"foo.cc\", 0, \"FooTest\", \"A\");\n    state_.AddTestName(\"foo.cc\", 0, \"FooTest\", \"B\");\n    state_.AddTestName(\"foo.cc\", 0, \"FooTest\", \"C\");\n  }\n\n  TypedTestCasePState state_;\n};\n\nTEST_F(TypedTestCasePStateTest, SucceedsForMatchingList) {\n  const char* tests = \"A, B, C\";\n  EXPECT_EQ(tests,\n            state_.VerifyRegisteredTestNames(\"foo.cc\", 1, tests));\n}\n\n// Makes sure that the order of the tests and spaces around the names\n// don't matter.\nTEST_F(TypedTestCasePStateTest, IgnoresOrderAndSpaces) {\n  const char* tests = \"A,C,   B\";\n  EXPECT_EQ(tests,\n            state_.VerifyRegisteredTestNames(\"foo.cc\", 1, tests));\n}\n\ntypedef TypedTestCasePStateTest TypedTestCasePStateDeathTest;\n\nTEST_F(TypedTestCasePStateDeathTest, DetectsDuplicates) {\n  EXPECT_DEATH_IF_SUPPORTED(\n      state_.VerifyRegisteredTestNames(\"foo.cc\", 1, \"A, B, A, C\"),\n      \"foo\\\\.cc.1.?: Test A is listed more than once\\\\.\");\n}\n\nTEST_F(TypedTestCasePStateDeathTest, DetectsExtraTest) {\n  EXPECT_DEATH_IF_SUPPORTED(\n      state_.VerifyRegisteredTestNames(\"foo.cc\", 1, \"A, B, C, D\"),\n      \"foo\\\\.cc.1.?: No test named D can be found in this test case\\\\.\");\n}\n\nTEST_F(TypedTestCasePStateDeathTest, DetectsMissedTest) {\n  EXPECT_DEATH_IF_SUPPORTED(\n      state_.VerifyRegisteredTestNames(\"foo.cc\", 1, \"A, C\"),\n      \"foo\\\\.cc.1.?: You forgot to list test B\\\\.\");\n}\n\n// Tests that defining a test for a parameterized test case generates\n// a run-time error if the test case has been registered.\nTEST_F(TypedTestCasePStateDeathTest, DetectsTestAfterRegistration) {\n  state_.VerifyRegisteredTestNames(\"foo.cc\", 1, \"A, B, C\");\n  EXPECT_DEATH_IF_SUPPORTED(\n      state_.AddTestName(\"foo.cc\", 2, \"FooTest\", \"D\"),\n      \"foo\\\\.cc.2.?: Test D must be defined before REGISTER_TYPED_TEST_CASE_P\"\n      \"\\\\(FooTest, \\\\.\\\\.\\\\.\\\\)\\\\.\");\n}\n\n// Tests that SetUpTestCase()/TearDownTestCase(), fixture ctor/dtor,\n// and SetUp()/TearDown() work correctly in type-parameterized tests.\n\ntemplate <typename T>\nclass DerivedTest : public CommonTest<T> {\n};\n\nTYPED_TEST_CASE_P(DerivedTest);\n\nTYPED_TEST_P(DerivedTest, ValuesAreCorrect) {\n  // Static members of the fixture class template can be visited via\n  // the TestFixture:: prefix.\n  EXPECT_EQ(5, *TestFixture::shared_);\n\n  // Non-static members of the fixture class must be visited via\n  // 'this', as required by C++ for class templates.\n  EXPECT_EQ(2, this->value_);\n}\n\n// The second test makes sure shared_ is not deleted after the first\n// test.\nTYPED_TEST_P(DerivedTest, ValuesAreStillCorrect) {\n  // Static members of the fixture class template can also be visited\n  // via 'this'.\n  ASSERT_TRUE(this->shared_ != NULL);\n  EXPECT_EQ(5, *this->shared_);\n  EXPECT_EQ(2, this->value_);\n}\n\nREGISTER_TYPED_TEST_CASE_P(DerivedTest,\n                           ValuesAreCorrect, ValuesAreStillCorrect);\n\ntypedef Types<short, long> MyTwoTypes;\nINSTANTIATE_TYPED_TEST_CASE_P(My, DerivedTest, MyTwoTypes);\n\n// Tests that multiple TYPED_TEST_CASE_P's can be defined in the same\n// translation unit.\n\ntemplate <typename T>\nclass TypedTestP1 : public Test {\n};\n\nTYPED_TEST_CASE_P(TypedTestP1);\n\n// For testing that the code between TYPED_TEST_CASE_P() and\n// TYPED_TEST_P() is not enclosed in a namespace.\ntypedef int IntAfterTypedTestCaseP;\n\nTYPED_TEST_P(TypedTestP1, A) {}\nTYPED_TEST_P(TypedTestP1, B) {}\n\n// For testing that the code between TYPED_TEST_P() and\n// REGISTER_TYPED_TEST_CASE_P() is not enclosed in a namespace.\ntypedef int IntBeforeRegisterTypedTestCaseP;\n\nREGISTER_TYPED_TEST_CASE_P(TypedTestP1, A, B);\n\ntemplate <typename T>\nclass TypedTestP2 : public Test {\n};\n\nTYPED_TEST_CASE_P(TypedTestP2);\n\n// This also verifies that tests from different type-parameterized\n// test cases can share the same name.\nTYPED_TEST_P(TypedTestP2, A) {}\n\nREGISTER_TYPED_TEST_CASE_P(TypedTestP2, A);\n\n// Verifies that the code between TYPED_TEST_CASE_P() and\n// REGISTER_TYPED_TEST_CASE_P() is not enclosed in a namespace.\nIntAfterTypedTestCaseP after = 0;\nIntBeforeRegisterTypedTestCaseP before = 0;\n\n// Verifies that the last argument of INSTANTIATE_TYPED_TEST_CASE_P()\n// can be either a single type or a Types<...> type list.\nINSTANTIATE_TYPED_TEST_CASE_P(Int, TypedTestP1, int);\nINSTANTIATE_TYPED_TEST_CASE_P(Int, TypedTestP2, Types<int>);\n\n// Tests that the same type-parameterized test case can be\n// instantiated more than once in the same translation unit.\nINSTANTIATE_TYPED_TEST_CASE_P(Double, TypedTestP2, Types<double>);\n\n// Tests that the same type-parameterized test case can be\n// instantiated in different translation units linked together.\n// (ContainerTest is also instantiated in gtest-typed-test_test.cc.)\ntypedef Types<std::vector<double>, std::set<char> > MyContainers;\nINSTANTIATE_TYPED_TEST_CASE_P(My, ContainerTest, MyContainers);\n\n// Tests that a type-parameterized test case can be defined and\n// instantiated in a namespace.\n\nnamespace library2 {\n\ntemplate <typename T>\nclass NumericTest : public Test {\n};\n\nTYPED_TEST_CASE_P(NumericTest);\n\nTYPED_TEST_P(NumericTest, DefaultIsZero) {\n  EXPECT_EQ(0, TypeParam());\n}\n\nTYPED_TEST_P(NumericTest, ZeroIsLessThanOne) {\n  EXPECT_LT(TypeParam(0), TypeParam(1));\n}\n\nREGISTER_TYPED_TEST_CASE_P(NumericTest,\n                           DefaultIsZero, ZeroIsLessThanOne);\ntypedef Types<int, double> NumericTypes;\nINSTANTIATE_TYPED_TEST_CASE_P(My, NumericTest, NumericTypes);\n\nstatic const char* GetTestName() {\n  return testing::UnitTest::GetInstance()->current_test_info()->name();\n}\n// Test the stripping of space from test names\ntemplate <typename T> class TrimmedTest : public Test { };\nTYPED_TEST_CASE_P(TrimmedTest);\nTYPED_TEST_P(TrimmedTest, Test1) { EXPECT_STREQ(\"Test1\", GetTestName()); }\nTYPED_TEST_P(TrimmedTest, Test2) { EXPECT_STREQ(\"Test2\", GetTestName()); }\nTYPED_TEST_P(TrimmedTest, Test3) { EXPECT_STREQ(\"Test3\", GetTestName()); }\nTYPED_TEST_P(TrimmedTest, Test4) { EXPECT_STREQ(\"Test4\", GetTestName()); }\nTYPED_TEST_P(TrimmedTest, Test5) { EXPECT_STREQ(\"Test5\", GetTestName()); }\nREGISTER_TYPED_TEST_CASE_P(\n    TrimmedTest,\n    Test1, Test2,Test3 , Test4 ,Test5 );  // NOLINT\ntemplate <typename T1, typename T2> struct MyPair {};\n// Be sure to try a type with a comma in its name just in case it matters.\ntypedef Types<int, double, MyPair<int, int> > TrimTypes;\nINSTANTIATE_TYPED_TEST_CASE_P(My, TrimmedTest, TrimTypes);\n\n}  // namespace library2\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n\n#if !defined(GTEST_HAS_TYPED_TEST) && !defined(GTEST_HAS_TYPED_TEST_P)\n\n// Google Test may not support type-parameterized tests with some\n// compilers. If we use conditional compilation to compile out all\n// code referring to the gtest_main library, MSVC linker will not link\n// that library at all and consequently complain about missing entry\n// point defined in that library (fatal error LNK1561: entry point\n// must be defined). This dummy test keeps gtest_main linked in.\nTEST(DummyTest, TypedTestsAreNotSupportedOnThisPlatform) {}\n\n#endif  // #if !defined(GTEST_HAS_TYPED_TEST) && !defined(GTEST_HAS_TYPED_TEST_P)\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-typed-test_test.h",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#ifndef GTEST_TEST_GTEST_TYPED_TEST_TEST_H_\n#define GTEST_TEST_GTEST_TYPED_TEST_TEST_H_\n\n#include \"gtest/gtest.h\"\n\n#if GTEST_HAS_TYPED_TEST_P\n\nusing testing::Test;\n\n// For testing that the same type-parameterized test case can be\n// instantiated in different translation units linked together.\n// ContainerTest will be instantiated in both gtest-typed-test_test.cc\n// and gtest-typed-test2_test.cc.\n\ntemplate <typename T>\nclass ContainerTest : public Test {\n};\n\nTYPED_TEST_CASE_P(ContainerTest);\n\nTYPED_TEST_P(ContainerTest, CanBeDefaultConstructed) {\n  TypeParam container;\n}\n\nTYPED_TEST_P(ContainerTest, InitialSizeIsZero) {\n  TypeParam container;\n  EXPECT_EQ(0U, container.size());\n}\n\nREGISTER_TYPED_TEST_CASE_P(ContainerTest,\n                           CanBeDefaultConstructed, InitialSizeIsZero);\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n\n#endif  // GTEST_TEST_GTEST_TYPED_TEST_TEST_H_\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest-unittest-api_test.cc",
    "content": "// Copyright 2009 Google Inc.  All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This file contains tests verifying correctness of data provided via\n// UnitTest's public methods.\n\n#include \"gtest/gtest.h\"\n\n#include <string.h>  // For strcmp.\n#include <algorithm>\n\nusing ::testing::InitGoogleTest;\n\nnamespace testing {\nnamespace internal {\n\ntemplate <typename T>\nstruct LessByName {\n  bool operator()(const T* a, const T* b) {\n    return strcmp(a->name(), b->name()) < 0;\n  }\n};\n\nclass UnitTestHelper {\n public:\n  // Returns the array of pointers to all test cases sorted by the test case\n  // name.  The caller is responsible for deleting the array.\n  static TestCase const** GetSortedTestCases() {\n    UnitTest& unit_test = *UnitTest::GetInstance();\n    TestCase const** const test_cases =\n        new const TestCase*[unit_test.total_test_case_count()];\n\n    for (int i = 0; i < unit_test.total_test_case_count(); ++i)\n      test_cases[i] = unit_test.GetTestCase(i);\n\n    std::sort(test_cases,\n              test_cases + unit_test.total_test_case_count(),\n              LessByName<TestCase>());\n    return test_cases;\n  }\n\n  // Returns the test case by its name.  The caller doesn't own the returned\n  // pointer.\n  static const TestCase* FindTestCase(const char* name) {\n    UnitTest& unit_test = *UnitTest::GetInstance();\n    for (int i = 0; i < unit_test.total_test_case_count(); ++i) {\n      const TestCase* test_case = unit_test.GetTestCase(i);\n      if (0 == strcmp(test_case->name(), name))\n        return test_case;\n    }\n    return NULL;\n  }\n\n  // Returns the array of pointers to all tests in a particular test case\n  // sorted by the test name.  The caller is responsible for deleting the\n  // array.\n  static TestInfo const** GetSortedTests(const TestCase* test_case) {\n    TestInfo const** const tests =\n        new const TestInfo*[test_case->total_test_count()];\n\n    for (int i = 0; i < test_case->total_test_count(); ++i)\n      tests[i] = test_case->GetTestInfo(i);\n\n    std::sort(tests, tests + test_case->total_test_count(),\n              LessByName<TestInfo>());\n    return tests;\n  }\n};\n\n#if GTEST_HAS_TYPED_TEST\ntemplate <typename T> class TestCaseWithCommentTest : public Test {};\nTYPED_TEST_CASE(TestCaseWithCommentTest, Types<int>);\nTYPED_TEST(TestCaseWithCommentTest, Dummy) {}\n\nconst int kTypedTestCases = 1;\nconst int kTypedTests = 1;\n#else\nconst int kTypedTestCases = 0;\nconst int kTypedTests = 0;\n#endif  // GTEST_HAS_TYPED_TEST\n\n// We can only test the accessors that do not change value while tests run.\n// Since tests can be run in any order, the values the accessors that track\n// test execution (such as failed_test_count) can not be predicted.\nTEST(ApiTest, UnitTestImmutableAccessorsWork) {\n  UnitTest* unit_test = UnitTest::GetInstance();\n\n  ASSERT_EQ(2 + kTypedTestCases, unit_test->total_test_case_count());\n  EXPECT_EQ(1 + kTypedTestCases, unit_test->test_case_to_run_count());\n  EXPECT_EQ(2, unit_test->disabled_test_count());\n  EXPECT_EQ(5 + kTypedTests, unit_test->total_test_count());\n  EXPECT_EQ(3 + kTypedTests, unit_test->test_to_run_count());\n\n  const TestCase** const test_cases = UnitTestHelper::GetSortedTestCases();\n\n  EXPECT_STREQ(\"ApiTest\", test_cases[0]->name());\n  EXPECT_STREQ(\"DISABLED_Test\", test_cases[1]->name());\n#if GTEST_HAS_TYPED_TEST\n  EXPECT_STREQ(\"TestCaseWithCommentTest/0\", test_cases[2]->name());\n#endif  // GTEST_HAS_TYPED_TEST\n\n  delete[] test_cases;\n\n  // The following lines initiate actions to verify certain methods in\n  // FinalSuccessChecker::TearDown.\n\n  // Records a test property to verify TestResult::GetTestProperty().\n  RecordProperty(\"key\", \"value\");\n}\n\nAssertionResult IsNull(const char* str) {\n  if (str != NULL) {\n    return testing::AssertionFailure() << \"argument is \" << str;\n  }\n  return AssertionSuccess();\n}\n\nTEST(ApiTest, TestCaseImmutableAccessorsWork) {\n  const TestCase* test_case = UnitTestHelper::FindTestCase(\"ApiTest\");\n  ASSERT_TRUE(test_case != NULL);\n\n  EXPECT_STREQ(\"ApiTest\", test_case->name());\n  EXPECT_TRUE(IsNull(test_case->type_param()));\n  EXPECT_TRUE(test_case->should_run());\n  EXPECT_EQ(1, test_case->disabled_test_count());\n  EXPECT_EQ(3, test_case->test_to_run_count());\n  ASSERT_EQ(4, test_case->total_test_count());\n\n  const TestInfo** tests = UnitTestHelper::GetSortedTests(test_case);\n\n  EXPECT_STREQ(\"DISABLED_Dummy1\", tests[0]->name());\n  EXPECT_STREQ(\"ApiTest\", tests[0]->test_case_name());\n  EXPECT_TRUE(IsNull(tests[0]->value_param()));\n  EXPECT_TRUE(IsNull(tests[0]->type_param()));\n  EXPECT_FALSE(tests[0]->should_run());\n\n  EXPECT_STREQ(\"TestCaseDisabledAccessorsWork\", tests[1]->name());\n  EXPECT_STREQ(\"ApiTest\", tests[1]->test_case_name());\n  EXPECT_TRUE(IsNull(tests[1]->value_param()));\n  EXPECT_TRUE(IsNull(tests[1]->type_param()));\n  EXPECT_TRUE(tests[1]->should_run());\n\n  EXPECT_STREQ(\"TestCaseImmutableAccessorsWork\", tests[2]->name());\n  EXPECT_STREQ(\"ApiTest\", tests[2]->test_case_name());\n  EXPECT_TRUE(IsNull(tests[2]->value_param()));\n  EXPECT_TRUE(IsNull(tests[2]->type_param()));\n  EXPECT_TRUE(tests[2]->should_run());\n\n  EXPECT_STREQ(\"UnitTestImmutableAccessorsWork\", tests[3]->name());\n  EXPECT_STREQ(\"ApiTest\", tests[3]->test_case_name());\n  EXPECT_TRUE(IsNull(tests[3]->value_param()));\n  EXPECT_TRUE(IsNull(tests[3]->type_param()));\n  EXPECT_TRUE(tests[3]->should_run());\n\n  delete[] tests;\n  tests = NULL;\n\n#if GTEST_HAS_TYPED_TEST\n  test_case = UnitTestHelper::FindTestCase(\"TestCaseWithCommentTest/0\");\n  ASSERT_TRUE(test_case != NULL);\n\n  EXPECT_STREQ(\"TestCaseWithCommentTest/0\", test_case->name());\n  EXPECT_STREQ(GetTypeName<int>().c_str(), test_case->type_param());\n  EXPECT_TRUE(test_case->should_run());\n  EXPECT_EQ(0, test_case->disabled_test_count());\n  EXPECT_EQ(1, test_case->test_to_run_count());\n  ASSERT_EQ(1, test_case->total_test_count());\n\n  tests = UnitTestHelper::GetSortedTests(test_case);\n\n  EXPECT_STREQ(\"Dummy\", tests[0]->name());\n  EXPECT_STREQ(\"TestCaseWithCommentTest/0\", tests[0]->test_case_name());\n  EXPECT_TRUE(IsNull(tests[0]->value_param()));\n  EXPECT_STREQ(GetTypeName<int>().c_str(), tests[0]->type_param());\n  EXPECT_TRUE(tests[0]->should_run());\n\n  delete[] tests;\n#endif  // GTEST_HAS_TYPED_TEST\n}\n\nTEST(ApiTest, TestCaseDisabledAccessorsWork) {\n  const TestCase* test_case = UnitTestHelper::FindTestCase(\"DISABLED_Test\");\n  ASSERT_TRUE(test_case != NULL);\n\n  EXPECT_STREQ(\"DISABLED_Test\", test_case->name());\n  EXPECT_TRUE(IsNull(test_case->type_param()));\n  EXPECT_FALSE(test_case->should_run());\n  EXPECT_EQ(1, test_case->disabled_test_count());\n  EXPECT_EQ(0, test_case->test_to_run_count());\n  ASSERT_EQ(1, test_case->total_test_count());\n\n  const TestInfo* const test_info = test_case->GetTestInfo(0);\n  EXPECT_STREQ(\"Dummy2\", test_info->name());\n  EXPECT_STREQ(\"DISABLED_Test\", test_info->test_case_name());\n  EXPECT_TRUE(IsNull(test_info->value_param()));\n  EXPECT_TRUE(IsNull(test_info->type_param()));\n  EXPECT_FALSE(test_info->should_run());\n}\n\n// These two tests are here to provide support for testing\n// test_case_to_run_count, disabled_test_count, and test_to_run_count.\nTEST(ApiTest, DISABLED_Dummy1) {}\nTEST(DISABLED_Test, Dummy2) {}\n\nclass FinalSuccessChecker : public Environment {\n protected:\n  virtual void TearDown() {\n    UnitTest* unit_test = UnitTest::GetInstance();\n\n    EXPECT_EQ(1 + kTypedTestCases, unit_test->successful_test_case_count());\n    EXPECT_EQ(3 + kTypedTests, unit_test->successful_test_count());\n    EXPECT_EQ(0, unit_test->failed_test_case_count());\n    EXPECT_EQ(0, unit_test->failed_test_count());\n    EXPECT_TRUE(unit_test->Passed());\n    EXPECT_FALSE(unit_test->Failed());\n    ASSERT_EQ(2 + kTypedTestCases, unit_test->total_test_case_count());\n\n    const TestCase** const test_cases = UnitTestHelper::GetSortedTestCases();\n\n    EXPECT_STREQ(\"ApiTest\", test_cases[0]->name());\n    EXPECT_TRUE(IsNull(test_cases[0]->type_param()));\n    EXPECT_TRUE(test_cases[0]->should_run());\n    EXPECT_EQ(1, test_cases[0]->disabled_test_count());\n    ASSERT_EQ(4, test_cases[0]->total_test_count());\n    EXPECT_EQ(3, test_cases[0]->successful_test_count());\n    EXPECT_EQ(0, test_cases[0]->failed_test_count());\n    EXPECT_TRUE(test_cases[0]->Passed());\n    EXPECT_FALSE(test_cases[0]->Failed());\n\n    EXPECT_STREQ(\"DISABLED_Test\", test_cases[1]->name());\n    EXPECT_TRUE(IsNull(test_cases[1]->type_param()));\n    EXPECT_FALSE(test_cases[1]->should_run());\n    EXPECT_EQ(1, test_cases[1]->disabled_test_count());\n    ASSERT_EQ(1, test_cases[1]->total_test_count());\n    EXPECT_EQ(0, test_cases[1]->successful_test_count());\n    EXPECT_EQ(0, test_cases[1]->failed_test_count());\n\n#if GTEST_HAS_TYPED_TEST\n    EXPECT_STREQ(\"TestCaseWithCommentTest/0\", test_cases[2]->name());\n    EXPECT_STREQ(GetTypeName<int>().c_str(), test_cases[2]->type_param());\n    EXPECT_TRUE(test_cases[2]->should_run());\n    EXPECT_EQ(0, test_cases[2]->disabled_test_count());\n    ASSERT_EQ(1, test_cases[2]->total_test_count());\n    EXPECT_EQ(1, test_cases[2]->successful_test_count());\n    EXPECT_EQ(0, test_cases[2]->failed_test_count());\n    EXPECT_TRUE(test_cases[2]->Passed());\n    EXPECT_FALSE(test_cases[2]->Failed());\n#endif  // GTEST_HAS_TYPED_TEST\n\n    const TestCase* test_case = UnitTestHelper::FindTestCase(\"ApiTest\");\n    const TestInfo** tests = UnitTestHelper::GetSortedTests(test_case);\n    EXPECT_STREQ(\"DISABLED_Dummy1\", tests[0]->name());\n    EXPECT_STREQ(\"ApiTest\", tests[0]->test_case_name());\n    EXPECT_FALSE(tests[0]->should_run());\n\n    EXPECT_STREQ(\"TestCaseDisabledAccessorsWork\", tests[1]->name());\n    EXPECT_STREQ(\"ApiTest\", tests[1]->test_case_name());\n    EXPECT_TRUE(IsNull(tests[1]->value_param()));\n    EXPECT_TRUE(IsNull(tests[1]->type_param()));\n    EXPECT_TRUE(tests[1]->should_run());\n    EXPECT_TRUE(tests[1]->result()->Passed());\n    EXPECT_EQ(0, tests[1]->result()->test_property_count());\n\n    EXPECT_STREQ(\"TestCaseImmutableAccessorsWork\", tests[2]->name());\n    EXPECT_STREQ(\"ApiTest\", tests[2]->test_case_name());\n    EXPECT_TRUE(IsNull(tests[2]->value_param()));\n    EXPECT_TRUE(IsNull(tests[2]->type_param()));\n    EXPECT_TRUE(tests[2]->should_run());\n    EXPECT_TRUE(tests[2]->result()->Passed());\n    EXPECT_EQ(0, tests[2]->result()->test_property_count());\n\n    EXPECT_STREQ(\"UnitTestImmutableAccessorsWork\", tests[3]->name());\n    EXPECT_STREQ(\"ApiTest\", tests[3]->test_case_name());\n    EXPECT_TRUE(IsNull(tests[3]->value_param()));\n    EXPECT_TRUE(IsNull(tests[3]->type_param()));\n    EXPECT_TRUE(tests[3]->should_run());\n    EXPECT_TRUE(tests[3]->result()->Passed());\n    EXPECT_EQ(1, tests[3]->result()->test_property_count());\n    const TestProperty& property = tests[3]->result()->GetTestProperty(0);\n    EXPECT_STREQ(\"key\", property.key());\n    EXPECT_STREQ(\"value\", property.value());\n\n    delete[] tests;\n\n#if GTEST_HAS_TYPED_TEST\n    test_case = UnitTestHelper::FindTestCase(\"TestCaseWithCommentTest/0\");\n    tests = UnitTestHelper::GetSortedTests(test_case);\n\n    EXPECT_STREQ(\"Dummy\", tests[0]->name());\n    EXPECT_STREQ(\"TestCaseWithCommentTest/0\", tests[0]->test_case_name());\n    EXPECT_TRUE(IsNull(tests[0]->value_param()));\n    EXPECT_STREQ(GetTypeName<int>().c_str(), tests[0]->type_param());\n    EXPECT_TRUE(tests[0]->should_run());\n    EXPECT_TRUE(tests[0]->result()->Passed());\n    EXPECT_EQ(0, tests[0]->result()->test_property_count());\n\n    delete[] tests;\n#endif  // GTEST_HAS_TYPED_TEST\n    delete[] test_cases;\n  }\n};\n\n}  // namespace internal\n}  // namespace testing\n\nint main(int argc, char **argv) {\n  InitGoogleTest(&argc, argv);\n\n  AddGlobalTestEnvironment(new testing::internal::FinalSuccessChecker());\n\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_all_test.cc",
    "content": "// Copyright 2009, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Tests for Google C++ Testing Framework (Google Test)\n//\n// Sometimes it's desirable to build most of Google Test's own tests\n// by compiling a single file.  This file serves this purpose.\n#include \"test/gtest-filepath_test.cc\"\n#include \"test/gtest-linked_ptr_test.cc\"\n#include \"test/gtest-message_test.cc\"\n#include \"test/gtest-options_test.cc\"\n#include \"test/gtest-port_test.cc\"\n#include \"test/gtest_pred_impl_unittest.cc\"\n#include \"test/gtest_prod_test.cc\"\n#include \"test/gtest-test-part_test.cc\"\n#include \"test/gtest-typed-test_test.cc\"\n#include \"test/gtest-typed-test2_test.cc\"\n#include \"test/gtest_unittest.cc\"\n#include \"test/production.cc\"\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_break_on_failure_unittest.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2006, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Unit test for Google Test's break-on-failure mode.\n\nA user can ask Google Test to seg-fault when an assertion fails, using\neither the GTEST_BREAK_ON_FAILURE environment variable or the\n--gtest_break_on_failure flag.  This script tests such functionality\nby invoking gtest_break_on_failure_unittest_ (a program written with\nGoogle Test) with different environments and command line flags.\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport gtest_test_utils\nimport os\nimport sys\n\n\n# Constants.\n\nIS_WINDOWS = os.name == 'nt'\n\n# The environment variable for enabling/disabling the break-on-failure mode.\nBREAK_ON_FAILURE_ENV_VAR = 'GTEST_BREAK_ON_FAILURE'\n\n# The command line flag for enabling/disabling the break-on-failure mode.\nBREAK_ON_FAILURE_FLAG = 'gtest_break_on_failure'\n\n# The environment variable for enabling/disabling the throw-on-failure mode.\nTHROW_ON_FAILURE_ENV_VAR = 'GTEST_THROW_ON_FAILURE'\n\n# The environment variable for enabling/disabling the catch-exceptions mode.\nCATCH_EXCEPTIONS_ENV_VAR = 'GTEST_CATCH_EXCEPTIONS'\n\n# Path to the gtest_break_on_failure_unittest_ program.\nEXE_PATH = gtest_test_utils.GetTestExecutablePath(\n    'gtest_break_on_failure_unittest_')\n\n\nenviron = gtest_test_utils.environ\nSetEnvVar = gtest_test_utils.SetEnvVar\n\n# Tests in this file run a Google-Test-based test program and expect it\n# to terminate prematurely.  Therefore they are incompatible with\n# the premature-exit-file protocol by design.  Unset the\n# premature-exit filepath to prevent Google Test from creating\n# the file.\nSetEnvVar(gtest_test_utils.PREMATURE_EXIT_FILE_ENV_VAR, None)\n\n\ndef Run(command):\n  \"\"\"Runs a command; returns 1 if it was killed by a signal, or 0 otherwise.\"\"\"\n\n  p = gtest_test_utils.Subprocess(command, env=environ)\n  if p.terminated_by_signal:\n    return 1\n  else:\n    return 0\n\n\n# The tests.\n\n\nclass GTestBreakOnFailureUnitTest(gtest_test_utils.TestCase):\n  \"\"\"Tests using the GTEST_BREAK_ON_FAILURE environment variable or\n  the --gtest_break_on_failure flag to turn assertion failures into\n  segmentation faults.\n  \"\"\"\n\n  def RunAndVerify(self, env_var_value, flag_value, expect_seg_fault):\n    \"\"\"Runs gtest_break_on_failure_unittest_ and verifies that it does\n    (or does not) have a seg-fault.\n\n    Args:\n      env_var_value:    value of the GTEST_BREAK_ON_FAILURE environment\n                        variable; None if the variable should be unset.\n      flag_value:       value of the --gtest_break_on_failure flag;\n                        None if the flag should not be present.\n      expect_seg_fault: 1 if the program is expected to generate a seg-fault;\n                        0 otherwise.\n    \"\"\"\n\n    SetEnvVar(BREAK_ON_FAILURE_ENV_VAR, env_var_value)\n\n    if env_var_value is None:\n      env_var_value_msg = ' is not set'\n    else:\n      env_var_value_msg = '=' + env_var_value\n\n    if flag_value is None:\n      flag = ''\n    elif flag_value == '0':\n      flag = '--%s=0' % BREAK_ON_FAILURE_FLAG\n    else:\n      flag = '--%s' % BREAK_ON_FAILURE_FLAG\n\n    command = [EXE_PATH]\n    if flag:\n      command.append(flag)\n\n    if expect_seg_fault:\n      should_or_not = 'should'\n    else:\n      should_or_not = 'should not'\n\n    has_seg_fault = Run(command)\n\n    SetEnvVar(BREAK_ON_FAILURE_ENV_VAR, None)\n\n    msg = ('when %s%s, an assertion failure in \"%s\" %s cause a seg-fault.' %\n           (BREAK_ON_FAILURE_ENV_VAR, env_var_value_msg, ' '.join(command),\n            should_or_not))\n    self.assert_(has_seg_fault == expect_seg_fault, msg)\n\n  def testDefaultBehavior(self):\n    \"\"\"Tests the behavior of the default mode.\"\"\"\n\n    self.RunAndVerify(env_var_value=None,\n                      flag_value=None,\n                      expect_seg_fault=0)\n\n  def testEnvVar(self):\n    \"\"\"Tests using the GTEST_BREAK_ON_FAILURE environment variable.\"\"\"\n\n    self.RunAndVerify(env_var_value='0',\n                      flag_value=None,\n                      expect_seg_fault=0)\n    self.RunAndVerify(env_var_value='1',\n                      flag_value=None,\n                      expect_seg_fault=1)\n\n  def testFlag(self):\n    \"\"\"Tests using the --gtest_break_on_failure flag.\"\"\"\n\n    self.RunAndVerify(env_var_value=None,\n                      flag_value='0',\n                      expect_seg_fault=0)\n    self.RunAndVerify(env_var_value=None,\n                      flag_value='1',\n                      expect_seg_fault=1)\n\n  def testFlagOverridesEnvVar(self):\n    \"\"\"Tests that the flag overrides the environment variable.\"\"\"\n\n    self.RunAndVerify(env_var_value='0',\n                      flag_value='0',\n                      expect_seg_fault=0)\n    self.RunAndVerify(env_var_value='0',\n                      flag_value='1',\n                      expect_seg_fault=1)\n    self.RunAndVerify(env_var_value='1',\n                      flag_value='0',\n                      expect_seg_fault=0)\n    self.RunAndVerify(env_var_value='1',\n                      flag_value='1',\n                      expect_seg_fault=1)\n\n  def testBreakOnFailureOverridesThrowOnFailure(self):\n    \"\"\"Tests that gtest_break_on_failure overrides gtest_throw_on_failure.\"\"\"\n\n    SetEnvVar(THROW_ON_FAILURE_ENV_VAR, '1')\n    try:\n      self.RunAndVerify(env_var_value=None,\n                        flag_value='1',\n                        expect_seg_fault=1)\n    finally:\n      SetEnvVar(THROW_ON_FAILURE_ENV_VAR, None)\n\n  if IS_WINDOWS:\n    def testCatchExceptionsDoesNotInterfere(self):\n      \"\"\"Tests that gtest_catch_exceptions doesn't interfere.\"\"\"\n\n      SetEnvVar(CATCH_EXCEPTIONS_ENV_VAR, '1')\n      try:\n        self.RunAndVerify(env_var_value='1',\n                          flag_value='1',\n                          expect_seg_fault=1)\n      finally:\n        SetEnvVar(CATCH_EXCEPTIONS_ENV_VAR, None)\n\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_break_on_failure_unittest_.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Unit test for Google Test's break-on-failure mode.\n//\n// A user can ask Google Test to seg-fault when an assertion fails, using\n// either the GTEST_BREAK_ON_FAILURE environment variable or the\n// --gtest_break_on_failure flag.  This file is used for testing such\n// functionality.\n//\n// This program will be invoked from a Python unit test.  It is\n// expected to fail.  Don't run it directly.\n\n#include \"gtest/gtest.h\"\n\n#if GTEST_OS_WINDOWS\n# include <windows.h>\n# include <stdlib.h>\n#endif\n\nnamespace {\n\n// A test that's expected to fail.\nTEST(Foo, Bar) {\n  EXPECT_EQ(2, 3);\n}\n\n#if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE\n// On Windows Mobile global exception handlers are not supported.\nLONG WINAPI ExitWithExceptionCode(\n    struct _EXCEPTION_POINTERS* exception_pointers) {\n  exit(exception_pointers->ExceptionRecord->ExceptionCode);\n}\n#endif\n\n}  // namespace\n\nint main(int argc, char **argv) {\n#if GTEST_OS_WINDOWS\n  // Suppresses display of the Windows error dialog upon encountering\n  // a general protection fault (segment violation).\n  SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS);\n\n# if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE\n\n  // The default unhandled exception filter does not always exit\n  // with the exception code as exit code - for example it exits with\n  // 0 for EXCEPTION_ACCESS_VIOLATION and 1 for EXCEPTION_BREAKPOINT\n  // if the application is compiled in debug mode. Thus we use our own\n  // filter which always exits with the exception code for unhandled\n  // exceptions.\n  SetUnhandledExceptionFilter(ExitWithExceptionCode);\n\n# endif\n#endif\n\n  testing::InitGoogleTest(&argc, argv);\n\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_catch_exceptions_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2010 Google Inc.  All Rights Reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Tests Google Test's exception catching behavior.\n\nThis script invokes gtest_catch_exceptions_test_ and\ngtest_catch_exceptions_ex_test_ (programs written with\nGoogle Test) and verifies their output.\n\"\"\"\n\n__author__ = 'vladl@google.com (Vlad Losev)'\n\nimport os\n\nimport gtest_test_utils\n\n# Constants.\nFLAG_PREFIX = '--gtest_'\nLIST_TESTS_FLAG = FLAG_PREFIX + 'list_tests'\nNO_CATCH_EXCEPTIONS_FLAG = FLAG_PREFIX + 'catch_exceptions=0'\nFILTER_FLAG = FLAG_PREFIX + 'filter'\n\n# Path to the gtest_catch_exceptions_ex_test_ binary, compiled with\n# exceptions enabled.\nEX_EXE_PATH = gtest_test_utils.GetTestExecutablePath(\n    'gtest_catch_exceptions_ex_test_')\n\n# Path to the gtest_catch_exceptions_test_ binary, compiled with\n# exceptions disabled.\nEXE_PATH = gtest_test_utils.GetTestExecutablePath(\n    'gtest_catch_exceptions_no_ex_test_')\n\nenviron = gtest_test_utils.environ\nSetEnvVar = gtest_test_utils.SetEnvVar\n\n# Tests in this file run a Google-Test-based test program and expect it\n# to terminate prematurely.  Therefore they are incompatible with\n# the premature-exit-file protocol by design.  Unset the\n# premature-exit filepath to prevent Google Test from creating\n# the file.\nSetEnvVar(gtest_test_utils.PREMATURE_EXIT_FILE_ENV_VAR, None)\n\nTEST_LIST = gtest_test_utils.Subprocess(\n    [EXE_PATH, LIST_TESTS_FLAG], env=environ).output\n\nSUPPORTS_SEH_EXCEPTIONS = 'ThrowsSehException' in TEST_LIST\n\nif SUPPORTS_SEH_EXCEPTIONS:\n  BINARY_OUTPUT = gtest_test_utils.Subprocess([EXE_PATH], env=environ).output\n\nEX_BINARY_OUTPUT = gtest_test_utils.Subprocess(\n    [EX_EXE_PATH], env=environ).output\n\n\n# The tests.\nif SUPPORTS_SEH_EXCEPTIONS:\n  # pylint:disable-msg=C6302\n  class CatchSehExceptionsTest(gtest_test_utils.TestCase):\n    \"\"\"Tests exception-catching behavior.\"\"\"\n\n\n    def TestSehExceptions(self, test_output):\n      self.assert_('SEH exception with code 0x2a thrown '\n                   'in the test fixture\\'s constructor'\n                   in test_output)\n      self.assert_('SEH exception with code 0x2a thrown '\n                   'in the test fixture\\'s destructor'\n                   in test_output)\n      self.assert_('SEH exception with code 0x2a thrown in SetUpTestCase()'\n                   in test_output)\n      self.assert_('SEH exception with code 0x2a thrown in TearDownTestCase()'\n                   in test_output)\n      self.assert_('SEH exception with code 0x2a thrown in SetUp()'\n                   in test_output)\n      self.assert_('SEH exception with code 0x2a thrown in TearDown()'\n                   in test_output)\n      self.assert_('SEH exception with code 0x2a thrown in the test body'\n                   in test_output)\n\n    def testCatchesSehExceptionsWithCxxExceptionsEnabled(self):\n      self.TestSehExceptions(EX_BINARY_OUTPUT)\n\n    def testCatchesSehExceptionsWithCxxExceptionsDisabled(self):\n      self.TestSehExceptions(BINARY_OUTPUT)\n\n\nclass CatchCxxExceptionsTest(gtest_test_utils.TestCase):\n  \"\"\"Tests C++ exception-catching behavior.\n\n     Tests in this test case verify that:\n     * C++ exceptions are caught and logged as C++ (not SEH) exceptions\n     * Exception thrown affect the remainder of the test work flow in the\n       expected manner.\n  \"\"\"\n\n  def testCatchesCxxExceptionsInFixtureConstructor(self):\n    self.assert_('C++ exception with description '\n                 '\"Standard C++ exception\" thrown '\n                 'in the test fixture\\'s constructor'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('unexpected' not in EX_BINARY_OUTPUT,\n                 'This failure belongs in this test only if '\n                 '\"CxxExceptionInConstructorTest\" (no quotes) '\n                 'appears on the same line as words \"called unexpectedly\"')\n\n  if ('CxxExceptionInDestructorTest.ThrowsExceptionInDestructor' in\n      EX_BINARY_OUTPUT):\n\n    def testCatchesCxxExceptionsInFixtureDestructor(self):\n      self.assert_('C++ exception with description '\n                   '\"Standard C++ exception\" thrown '\n                   'in the test fixture\\'s destructor'\n                   in EX_BINARY_OUTPUT)\n      self.assert_('CxxExceptionInDestructorTest::TearDownTestCase() '\n                   'called as expected.'\n                   in EX_BINARY_OUTPUT)\n\n  def testCatchesCxxExceptionsInSetUpTestCase(self):\n    self.assert_('C++ exception with description \"Standard C++ exception\"'\n                 ' thrown in SetUpTestCase()'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInConstructorTest::TearDownTestCase() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTestCaseTest constructor '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTestCaseTest destructor '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTestCaseTest::SetUp() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTestCaseTest::TearDown() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTestCaseTest test body '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n\n  def testCatchesCxxExceptionsInTearDownTestCase(self):\n    self.assert_('C++ exception with description \"Standard C++ exception\"'\n                 ' thrown in TearDownTestCase()'\n                 in EX_BINARY_OUTPUT)\n\n  def testCatchesCxxExceptionsInSetUp(self):\n    self.assert_('C++ exception with description \"Standard C++ exception\"'\n                 ' thrown in SetUp()'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTest::TearDownTestCase() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTest destructor '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTest::TearDown() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('unexpected' not in EX_BINARY_OUTPUT,\n                 'This failure belongs in this test only if '\n                 '\"CxxExceptionInSetUpTest\" (no quotes) '\n                 'appears on the same line as words \"called unexpectedly\"')\n\n  def testCatchesCxxExceptionsInTearDown(self):\n    self.assert_('C++ exception with description \"Standard C++ exception\"'\n                 ' thrown in TearDown()'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInTearDownTest::TearDownTestCase() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInTearDownTest destructor '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n\n  def testCatchesCxxExceptionsInTestBody(self):\n    self.assert_('C++ exception with description \"Standard C++ exception\"'\n                 ' thrown in the test body'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInTestBodyTest::TearDownTestCase() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInTestBodyTest destructor '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInTestBodyTest::TearDown() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n\n  def testCatchesNonStdCxxExceptions(self):\n    self.assert_('Unknown C++ exception thrown in the test body'\n                 in EX_BINARY_OUTPUT)\n\n  def testUnhandledCxxExceptionsAbortTheProgram(self):\n    # Filters out SEH exception tests on Windows. Unhandled SEH exceptions\n    # cause tests to show pop-up windows there.\n    FITLER_OUT_SEH_TESTS_FLAG = FILTER_FLAG + '=-*Seh*'\n    # By default, Google Test doesn't catch the exceptions.\n    uncaught_exceptions_ex_binary_output = gtest_test_utils.Subprocess(\n        [EX_EXE_PATH,\n         NO_CATCH_EXCEPTIONS_FLAG,\n         FITLER_OUT_SEH_TESTS_FLAG],\n        env=environ).output\n\n    self.assert_('Unhandled C++ exception terminating the program'\n                 in uncaught_exceptions_ex_binary_output)\n    self.assert_('unexpected' not in uncaught_exceptions_ex_binary_output)\n\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_catch_exceptions_test_.cc",
    "content": "// Copyright 2010, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n//\n// Tests for Google Test itself. Tests in this file throw C++ or SEH\n// exceptions, and the output is verified by gtest_catch_exceptions_test.py.\n\n#include \"gtest/gtest.h\"\n\n#include <stdio.h>  // NOLINT\n#include <stdlib.h>  // For exit().\n\n#if GTEST_HAS_SEH\n# include <windows.h>\n#endif\n\n#if GTEST_HAS_EXCEPTIONS\n# include <exception>  // For set_terminate().\n# include <stdexcept>\n#endif\n\nusing testing::Test;\n\n#if GTEST_HAS_SEH\n\nclass SehExceptionInConstructorTest : public Test {\n public:\n  SehExceptionInConstructorTest() { RaiseException(42, 0, 0, NULL); }\n};\n\nTEST_F(SehExceptionInConstructorTest, ThrowsExceptionInConstructor) {}\n\nclass SehExceptionInDestructorTest : public Test {\n public:\n  ~SehExceptionInDestructorTest() { RaiseException(42, 0, 0, NULL); }\n};\n\nTEST_F(SehExceptionInDestructorTest, ThrowsExceptionInDestructor) {}\n\nclass SehExceptionInSetUpTestCaseTest : public Test {\n public:\n  static void SetUpTestCase() { RaiseException(42, 0, 0, NULL); }\n};\n\nTEST_F(SehExceptionInSetUpTestCaseTest, ThrowsExceptionInSetUpTestCase) {}\n\nclass SehExceptionInTearDownTestCaseTest : public Test {\n public:\n  static void TearDownTestCase() { RaiseException(42, 0, 0, NULL); }\n};\n\nTEST_F(SehExceptionInTearDownTestCaseTest, ThrowsExceptionInTearDownTestCase) {}\n\nclass SehExceptionInSetUpTest : public Test {\n protected:\n  virtual void SetUp() { RaiseException(42, 0, 0, NULL); }\n};\n\nTEST_F(SehExceptionInSetUpTest, ThrowsExceptionInSetUp) {}\n\nclass SehExceptionInTearDownTest : public Test {\n protected:\n  virtual void TearDown() { RaiseException(42, 0, 0, NULL); }\n};\n\nTEST_F(SehExceptionInTearDownTest, ThrowsExceptionInTearDown) {}\n\nTEST(SehExceptionTest, ThrowsSehException) {\n  RaiseException(42, 0, 0, NULL);\n}\n\n#endif  // GTEST_HAS_SEH\n\n#if GTEST_HAS_EXCEPTIONS\n\nclass CxxExceptionInConstructorTest : public Test {\n public:\n  CxxExceptionInConstructorTest() {\n    // Without this macro VC++ complains about unreachable code at the end of\n    // the constructor.\n    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(\n        throw std::runtime_error(\"Standard C++ exception\"));\n  }\n\n  static void TearDownTestCase() {\n    printf(\"%s\",\n           \"CxxExceptionInConstructorTest::TearDownTestCase() \"\n           \"called as expected.\\n\");\n  }\n\n protected:\n  ~CxxExceptionInConstructorTest() {\n    ADD_FAILURE() << \"CxxExceptionInConstructorTest destructor \"\n                  << \"called unexpectedly.\";\n  }\n\n  virtual void SetUp() {\n    ADD_FAILURE() << \"CxxExceptionInConstructorTest::SetUp() \"\n                  << \"called unexpectedly.\";\n  }\n\n  virtual void TearDown() {\n    ADD_FAILURE() << \"CxxExceptionInConstructorTest::TearDown() \"\n                  << \"called unexpectedly.\";\n  }\n};\n\nTEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {\n  ADD_FAILURE() << \"CxxExceptionInConstructorTest test body \"\n                << \"called unexpectedly.\";\n}\n\n// Exceptions in destructors are not supported in C++11.\n#if !defined(__GXX_EXPERIMENTAL_CXX0X__) &&  __cplusplus < 201103L\nclass CxxExceptionInDestructorTest : public Test {\n public:\n  static void TearDownTestCase() {\n    printf(\"%s\",\n           \"CxxExceptionInDestructorTest::TearDownTestCase() \"\n           \"called as expected.\\n\");\n  }\n\n protected:\n  ~CxxExceptionInDestructorTest() {\n    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(\n        throw std::runtime_error(\"Standard C++ exception\"));\n  }\n};\n\nTEST_F(CxxExceptionInDestructorTest, ThrowsExceptionInDestructor) {}\n#endif  // C++11 mode\n\nclass CxxExceptionInSetUpTestCaseTest : public Test {\n public:\n  CxxExceptionInSetUpTestCaseTest() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTestCaseTest constructor \"\n           \"called as expected.\\n\");\n  }\n\n  static void SetUpTestCase() {\n    throw std::runtime_error(\"Standard C++ exception\");\n  }\n\n  static void TearDownTestCase() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTestCaseTest::TearDownTestCase() \"\n           \"called as expected.\\n\");\n  }\n\n protected:\n  ~CxxExceptionInSetUpTestCaseTest() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTestCaseTest destructor \"\n           \"called as expected.\\n\");\n  }\n\n  virtual void SetUp() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTestCaseTest::SetUp() \"\n           \"called as expected.\\n\");\n  }\n\n  virtual void TearDown() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTestCaseTest::TearDown() \"\n           \"called as expected.\\n\");\n  }\n};\n\nTEST_F(CxxExceptionInSetUpTestCaseTest, ThrowsExceptionInSetUpTestCase) {\n  printf(\"%s\",\n         \"CxxExceptionInSetUpTestCaseTest test body \"\n         \"called as expected.\\n\");\n}\n\nclass CxxExceptionInTearDownTestCaseTest : public Test {\n public:\n  static void TearDownTestCase() {\n    throw std::runtime_error(\"Standard C++ exception\");\n  }\n};\n\nTEST_F(CxxExceptionInTearDownTestCaseTest, ThrowsExceptionInTearDownTestCase) {}\n\nclass CxxExceptionInSetUpTest : public Test {\n public:\n  static void TearDownTestCase() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTest::TearDownTestCase() \"\n           \"called as expected.\\n\");\n  }\n\n protected:\n  ~CxxExceptionInSetUpTest() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTest destructor \"\n           \"called as expected.\\n\");\n  }\n\n  virtual void SetUp() { throw std::runtime_error(\"Standard C++ exception\"); }\n\n  virtual void TearDown() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTest::TearDown() \"\n           \"called as expected.\\n\");\n  }\n};\n\nTEST_F(CxxExceptionInSetUpTest, ThrowsExceptionInSetUp) {\n  ADD_FAILURE() << \"CxxExceptionInSetUpTest test body \"\n                << \"called unexpectedly.\";\n}\n\nclass CxxExceptionInTearDownTest : public Test {\n public:\n  static void TearDownTestCase() {\n    printf(\"%s\",\n           \"CxxExceptionInTearDownTest::TearDownTestCase() \"\n           \"called as expected.\\n\");\n  }\n\n protected:\n  ~CxxExceptionInTearDownTest() {\n    printf(\"%s\",\n           \"CxxExceptionInTearDownTest destructor \"\n           \"called as expected.\\n\");\n  }\n\n  virtual void TearDown() {\n    throw std::runtime_error(\"Standard C++ exception\");\n  }\n};\n\nTEST_F(CxxExceptionInTearDownTest, ThrowsExceptionInTearDown) {}\n\nclass CxxExceptionInTestBodyTest : public Test {\n public:\n  static void TearDownTestCase() {\n    printf(\"%s\",\n           \"CxxExceptionInTestBodyTest::TearDownTestCase() \"\n           \"called as expected.\\n\");\n  }\n\n protected:\n  ~CxxExceptionInTestBodyTest() {\n    printf(\"%s\",\n           \"CxxExceptionInTestBodyTest destructor \"\n           \"called as expected.\\n\");\n  }\n\n  virtual void TearDown() {\n    printf(\"%s\",\n           \"CxxExceptionInTestBodyTest::TearDown() \"\n           \"called as expected.\\n\");\n  }\n};\n\nTEST_F(CxxExceptionInTestBodyTest, ThrowsStdCxxException) {\n  throw std::runtime_error(\"Standard C++ exception\");\n}\n\nTEST(CxxExceptionTest, ThrowsNonStdCxxException) {\n  throw \"C-string\";\n}\n\n// This terminate handler aborts the program using exit() rather than abort().\n// This avoids showing pop-ups on Windows systems and core dumps on Unix-like\n// ones.\nvoid TerminateHandler() {\n  fprintf(stderr, \"%s\\n\", \"Unhandled C++ exception terminating the program.\");\n  fflush(NULL);\n  exit(3);\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\nint main(int argc, char** argv) {\n#if GTEST_HAS_EXCEPTIONS\n  std::set_terminate(&TerminateHandler);\n#endif\n  testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_color_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Verifies that Google Test correctly determines whether to use colors.\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport gtest_test_utils\n\n\nIS_WINDOWS = os.name = 'nt'\n\nCOLOR_ENV_VAR = 'GTEST_COLOR'\nCOLOR_FLAG = 'gtest_color'\nCOMMAND = gtest_test_utils.GetTestExecutablePath('gtest_color_test_')\n\n\ndef SetEnvVar(env_var, value):\n  \"\"\"Sets the env variable to 'value'; unsets it when 'value' is None.\"\"\"\n\n  if value is not None:\n    os.environ[env_var] = value\n  elif env_var in os.environ:\n    del os.environ[env_var]\n\n\ndef UsesColor(term, color_env_var, color_flag):\n  \"\"\"Runs gtest_color_test_ and returns its exit code.\"\"\"\n\n  SetEnvVar('TERM', term)\n  SetEnvVar(COLOR_ENV_VAR, color_env_var)\n\n  if color_flag is None:\n    args = []\n  else:\n    args = ['--%s=%s' % (COLOR_FLAG, color_flag)]\n  p = gtest_test_utils.Subprocess([COMMAND] + args)\n  return not p.exited or p.exit_code\n\n\nclass GTestColorTest(gtest_test_utils.TestCase):\n  def testNoEnvVarNoFlag(self):\n    \"\"\"Tests the case when there's neither GTEST_COLOR nor --gtest_color.\"\"\"\n\n    if not IS_WINDOWS:\n      self.assert_(not UsesColor('dumb', None, None))\n      self.assert_(not UsesColor('emacs', None, None))\n      self.assert_(not UsesColor('xterm-mono', None, None))\n      self.assert_(not UsesColor('unknown', None, None))\n      self.assert_(not UsesColor(None, None, None))\n    self.assert_(UsesColor('linux', None, None))\n    self.assert_(UsesColor('cygwin', None, None))\n    self.assert_(UsesColor('xterm', None, None))\n    self.assert_(UsesColor('xterm-color', None, None))\n    self.assert_(UsesColor('xterm-256color', None, None))\n\n  def testFlagOnly(self):\n    \"\"\"Tests the case when there's --gtest_color but not GTEST_COLOR.\"\"\"\n\n    self.assert_(not UsesColor('dumb', None, 'no'))\n    self.assert_(not UsesColor('xterm-color', None, 'no'))\n    if not IS_WINDOWS:\n      self.assert_(not UsesColor('emacs', None, 'auto'))\n    self.assert_(UsesColor('xterm', None, 'auto'))\n    self.assert_(UsesColor('dumb', None, 'yes'))\n    self.assert_(UsesColor('xterm', None, 'yes'))\n\n  def testEnvVarOnly(self):\n    \"\"\"Tests the case when there's GTEST_COLOR but not --gtest_color.\"\"\"\n\n    self.assert_(not UsesColor('dumb', 'no', None))\n    self.assert_(not UsesColor('xterm-color', 'no', None))\n    if not IS_WINDOWS:\n      self.assert_(not UsesColor('dumb', 'auto', None))\n    self.assert_(UsesColor('xterm-color', 'auto', None))\n    self.assert_(UsesColor('dumb', 'yes', None))\n    self.assert_(UsesColor('xterm-color', 'yes', None))\n\n  def testEnvVarAndFlag(self):\n    \"\"\"Tests the case when there are both GTEST_COLOR and --gtest_color.\"\"\"\n\n    self.assert_(not UsesColor('xterm-color', 'no', 'no'))\n    self.assert_(UsesColor('dumb', 'no', 'yes'))\n    self.assert_(UsesColor('xterm-color', 'no', 'auto'))\n\n  def testAliasesOfYesAndNo(self):\n    \"\"\"Tests using aliases in specifying --gtest_color.\"\"\"\n\n    self.assert_(UsesColor('dumb', None, 'true'))\n    self.assert_(UsesColor('dumb', None, 'YES'))\n    self.assert_(UsesColor('dumb', None, 'T'))\n    self.assert_(UsesColor('dumb', None, '1'))\n\n    self.assert_(not UsesColor('xterm', None, 'f'))\n    self.assert_(not UsesColor('xterm', None, 'false'))\n    self.assert_(not UsesColor('xterm', None, '0'))\n    self.assert_(not UsesColor('xterm', None, 'unknown'))\n\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_color_test_.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// A helper program for testing how Google Test determines whether to use\n// colors in the output.  It prints \"YES\" and returns 1 if Google Test\n// decides to use colors, and prints \"NO\" and returns 0 otherwise.\n\n#include <stdio.h>\n\n#include \"gtest/gtest.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nusing testing::internal::ShouldUseColor;\n\n// The purpose of this is to ensure that the UnitTest singleton is\n// created before main() is entered, and thus that ShouldUseColor()\n// works the same way as in a real Google-Test-based test.  We don't actual\n// run the TEST itself.\nTEST(GTestColorTest, Dummy) {\n}\n\nint main(int argc, char** argv) {\n  testing::InitGoogleTest(&argc, argv);\n\n  if (ShouldUseColor(true)) {\n    // Google Test decides to use colors in the output (assuming it\n    // goes to a TTY).\n    printf(\"YES\\n\");\n    return 1;\n  } else {\n    // Google Test decides not to use colors in the output.\n    printf(\"NO\\n\");\n    return 0;\n  }\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_env_var_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Verifies that Google Test correctly parses environment variables.\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport gtest_test_utils\n\n\nIS_WINDOWS = os.name == 'nt'\nIS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'\n\nCOMMAND = gtest_test_utils.GetTestExecutablePath('gtest_env_var_test_')\n\nenviron = os.environ.copy()\n\n\ndef AssertEq(expected, actual):\n  if expected != actual:\n    print('Expected: %s' % (expected,))\n    print('  Actual: %s' % (actual,))\n    raise AssertionError\n\n\ndef SetEnvVar(env_var, value):\n  \"\"\"Sets the env variable to 'value'; unsets it when 'value' is None.\"\"\"\n\n  if value is not None:\n    environ[env_var] = value\n  elif env_var in environ:\n    del environ[env_var]\n\n\ndef GetFlag(flag):\n  \"\"\"Runs gtest_env_var_test_ and returns its output.\"\"\"\n\n  args = [COMMAND]\n  if flag is not None:\n    args += [flag]\n  return gtest_test_utils.Subprocess(args, env=environ).output\n\n\ndef TestFlag(flag, test_val, default_val):\n  \"\"\"Verifies that the given flag is affected by the corresponding env var.\"\"\"\n\n  env_var = 'GTEST_' + flag.upper()\n  SetEnvVar(env_var, test_val)\n  AssertEq(test_val, GetFlag(flag))\n  SetEnvVar(env_var, None)\n  AssertEq(default_val, GetFlag(flag))\n\n\nclass GTestEnvVarTest(gtest_test_utils.TestCase):\n  def testEnvVarAffectsFlag(self):\n    \"\"\"Tests that environment variable should affect the corresponding flag.\"\"\"\n\n    TestFlag('break_on_failure', '1', '0')\n    TestFlag('color', 'yes', 'auto')\n    TestFlag('filter', 'FooTest.Bar', '*')\n    SetEnvVar('XML_OUTPUT_FILE', None) # For 'output' test\n    TestFlag('output', 'xml:tmp/foo.xml', '')\n    TestFlag('print_time', '0', '1')\n    TestFlag('repeat', '999', '1')\n    TestFlag('throw_on_failure', '1', '0')\n    TestFlag('death_test_style', 'threadsafe', 'fast')\n    TestFlag('catch_exceptions', '0', '1')\n\n    if IS_LINUX:\n      TestFlag('death_test_use_fork', '1', '0')\n      TestFlag('stack_trace_depth', '0', '100')\n\n  def testXmlOutputFile(self):\n    \"\"\"Tests that $XML_OUTPUT_FILE affects the output flag.\"\"\"\n\n    SetEnvVar('GTEST_OUTPUT', None)\n    SetEnvVar('XML_OUTPUT_FILE', 'tmp/bar.xml')\n    AssertEq('xml:tmp/bar.xml', GetFlag('output'))\n\n  def testXmlOutputFileOverride(self):\n    \"\"\"Tests that $XML_OUTPUT_FILE is overridden by $GTEST_OUTPUT\"\"\"\n\n    SetEnvVar('GTEST_OUTPUT', 'xml:tmp/foo.xml')\n    SetEnvVar('XML_OUTPUT_FILE', 'tmp/bar.xml')\n    AssertEq('xml:tmp/foo.xml', GetFlag('output'))\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_env_var_test_.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// A helper program for testing that Google Test parses the environment\n// variables correctly.\n\n#include \"gtest/gtest.h\"\n\n#include <iostream>\n\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nusing ::std::cout;\n\nnamespace testing {\n\n// The purpose of this is to make the test more realistic by ensuring\n// that the UnitTest singleton is created before main() is entered.\n// We don't actual run the TEST itself.\nTEST(GTestEnvVarTest, Dummy) {\n}\n\nvoid PrintFlag(const char* flag) {\n  if (strcmp(flag, \"break_on_failure\") == 0) {\n    cout << GTEST_FLAG(break_on_failure);\n    return;\n  }\n\n  if (strcmp(flag, \"catch_exceptions\") == 0) {\n    cout << GTEST_FLAG(catch_exceptions);\n    return;\n  }\n\n  if (strcmp(flag, \"color\") == 0) {\n    cout << GTEST_FLAG(color);\n    return;\n  }\n\n  if (strcmp(flag, \"death_test_style\") == 0) {\n    cout << GTEST_FLAG(death_test_style);\n    return;\n  }\n\n  if (strcmp(flag, \"death_test_use_fork\") == 0) {\n    cout << GTEST_FLAG(death_test_use_fork);\n    return;\n  }\n\n  if (strcmp(flag, \"filter\") == 0) {\n    cout << GTEST_FLAG(filter);\n    return;\n  }\n\n  if (strcmp(flag, \"output\") == 0) {\n    cout << GTEST_FLAG(output);\n    return;\n  }\n\n  if (strcmp(flag, \"print_time\") == 0) {\n    cout << GTEST_FLAG(print_time);\n    return;\n  }\n\n  if (strcmp(flag, \"repeat\") == 0) {\n    cout << GTEST_FLAG(repeat);\n    return;\n  }\n\n  if (strcmp(flag, \"stack_trace_depth\") == 0) {\n    cout << GTEST_FLAG(stack_trace_depth);\n    return;\n  }\n\n  if (strcmp(flag, \"throw_on_failure\") == 0) {\n    cout << GTEST_FLAG(throw_on_failure);\n    return;\n  }\n\n  cout << \"Invalid flag name \" << flag\n       << \".  Valid names are break_on_failure, color, filter, etc.\\n\";\n  exit(1);\n}\n\n}  // namespace testing\n\nint main(int argc, char** argv) {\n  testing::InitGoogleTest(&argc, argv);\n\n  if (argc != 2) {\n    cout << \"Usage: gtest_env_var_test_ NAME_OF_FLAG\\n\";\n    return 1;\n  }\n\n  testing::PrintFlag(argv[1]);\n  return 0;\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_environment_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Tests using global test environments.\n\n#include <stdlib.h>\n#include <stdio.h>\n#include \"gtest/gtest.h\"\n\n#define GTEST_IMPLEMENTATION_ 1  // Required for the next #include.\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nnamespace testing {\nGTEST_DECLARE_string_(filter);\n}\n\nnamespace {\n\nenum FailureType {\n  NO_FAILURE, NON_FATAL_FAILURE, FATAL_FAILURE\n};\n\n// For testing using global test environments.\nclass MyEnvironment : public testing::Environment {\n public:\n  MyEnvironment() { Reset(); }\n\n  // Depending on the value of failure_in_set_up_, SetUp() will\n  // generate a non-fatal failure, generate a fatal failure, or\n  // succeed.\n  virtual void SetUp() {\n    set_up_was_run_ = true;\n\n    switch (failure_in_set_up_) {\n      case NON_FATAL_FAILURE:\n        ADD_FAILURE() << \"Expected non-fatal failure in global set-up.\";\n        break;\n      case FATAL_FAILURE:\n        FAIL() << \"Expected fatal failure in global set-up.\";\n        break;\n      default:\n        break;\n    }\n  }\n\n  // Generates a non-fatal failure.\n  virtual void TearDown() {\n    tear_down_was_run_ = true;\n    ADD_FAILURE() << \"Expected non-fatal failure in global tear-down.\";\n  }\n\n  // Resets the state of the environment s.t. it can be reused.\n  void Reset() {\n    failure_in_set_up_ = NO_FAILURE;\n    set_up_was_run_ = false;\n    tear_down_was_run_ = false;\n  }\n\n  // We call this function to set the type of failure SetUp() should\n  // generate.\n  void set_failure_in_set_up(FailureType type) {\n    failure_in_set_up_ = type;\n  }\n\n  // Was SetUp() run?\n  bool set_up_was_run() const { return set_up_was_run_; }\n\n  // Was TearDown() run?\n  bool tear_down_was_run() const { return tear_down_was_run_; }\n\n private:\n  FailureType failure_in_set_up_;\n  bool set_up_was_run_;\n  bool tear_down_was_run_;\n};\n\n// Was the TEST run?\nbool test_was_run;\n\n// The sole purpose of this TEST is to enable us to check whether it\n// was run.\nTEST(FooTest, Bar) {\n  test_was_run = true;\n}\n\n// Prints the message and aborts the program if condition is false.\nvoid Check(bool condition, const char* msg) {\n  if (!condition) {\n    printf(\"FAILED: %s\\n\", msg);\n    testing::internal::posix::Abort();\n  }\n}\n\n// Runs the tests.  Return true iff successful.\n//\n// The 'failure' parameter specifies the type of failure that should\n// be generated by the global set-up.\nint RunAllTests(MyEnvironment* env, FailureType failure) {\n  env->Reset();\n  env->set_failure_in_set_up(failure);\n  test_was_run = false;\n  testing::internal::GetUnitTestImpl()->ClearAdHocTestResult();\n  return RUN_ALL_TESTS();\n}\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  testing::InitGoogleTest(&argc, argv);\n\n  // Registers a global test environment, and verifies that the\n  // registration function returns its argument.\n  MyEnvironment* const env = new MyEnvironment;\n  Check(testing::AddGlobalTestEnvironment(env) == env,\n        \"AddGlobalTestEnvironment() should return its argument.\");\n\n  // Verifies that RUN_ALL_TESTS() runs the tests when the global\n  // set-up is successful.\n  Check(RunAllTests(env, NO_FAILURE) != 0,\n        \"RUN_ALL_TESTS() should return non-zero, as the global tear-down \"\n        \"should generate a failure.\");\n  Check(test_was_run,\n        \"The tests should run, as the global set-up should generate no \"\n        \"failure\");\n  Check(env->tear_down_was_run(),\n        \"The global tear-down should run, as the global set-up was run.\");\n\n  // Verifies that RUN_ALL_TESTS() runs the tests when the global\n  // set-up generates no fatal failure.\n  Check(RunAllTests(env, NON_FATAL_FAILURE) != 0,\n        \"RUN_ALL_TESTS() should return non-zero, as both the global set-up \"\n        \"and the global tear-down should generate a non-fatal failure.\");\n  Check(test_was_run,\n        \"The tests should run, as the global set-up should generate no \"\n        \"fatal failure.\");\n  Check(env->tear_down_was_run(),\n        \"The global tear-down should run, as the global set-up was run.\");\n\n  // Verifies that RUN_ALL_TESTS() runs no test when the global set-up\n  // generates a fatal failure.\n  Check(RunAllTests(env, FATAL_FAILURE) != 0,\n        \"RUN_ALL_TESTS() should return non-zero, as the global set-up \"\n        \"should generate a fatal failure.\");\n  Check(!test_was_run,\n        \"The tests should not run, as the global set-up should generate \"\n        \"a fatal failure.\");\n  Check(env->tear_down_was_run(),\n        \"The global tear-down should run, as the global set-up was run.\");\n\n  // Verifies that RUN_ALL_TESTS() doesn't do global set-up or\n  // tear-down when there is no test to run.\n  testing::GTEST_FLAG(filter) = \"-*\";\n  Check(RunAllTests(env, NO_FAILURE) == 0,\n        \"RUN_ALL_TESTS() should return zero, as there is no test to run.\");\n  Check(!env->set_up_was_run(),\n        \"The global set-up should not run, as there is no test to run.\");\n  Check(!env->tear_down_was_run(),\n        \"The global tear-down should not run, \"\n        \"as the global set-up was not run.\");\n\n  printf(\"PASS\\n\");\n  return 0;\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_filter_unittest.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2005 Google Inc. All Rights Reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Unit test for Google Test test filters.\n\nA user can specify which test(s) in a Google Test program to run via either\nthe GTEST_FILTER environment variable or the --gtest_filter flag.\nThis script tests such functionality by invoking\ngtest_filter_unittest_ (a program written with Google Test) with different\nenvironments and command line flags.\n\nNote that test sharding may also influence which tests are filtered. Therefore,\nwe test that here also.\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport re\ntry:\n  from sets import Set as set  # For Python 2.3 compatibility\nexcept ImportError:\n  pass\nimport sys\n\nimport gtest_test_utils\n\n# Constants.\n\n# Checks if this platform can pass empty environment variables to child\n# processes.  We set an env variable to an empty string and invoke a python\n# script in a subprocess to print whether the variable is STILL in\n# os.environ.  We then use 'eval' to parse the child's output so that an\n# exception is thrown if the input is anything other than 'True' nor 'False'.\nos.environ['EMPTY_VAR'] = ''\nchild = gtest_test_utils.Subprocess(\n    [sys.executable, '-c', 'import os; print(\\'EMPTY_VAR\\' in os.environ)'])\nCAN_PASS_EMPTY_ENV = eval(child.output)\n\n\n# Check if this platform can unset environment variables in child processes.\n# We set an env variable to a non-empty string, unset it, and invoke\n# a python script in a subprocess to print whether the variable\n# is NO LONGER in os.environ.\n# We use 'eval' to parse the child's output so that an exception\n# is thrown if the input is neither 'True' nor 'False'.\nos.environ['UNSET_VAR'] = 'X'\ndel os.environ['UNSET_VAR']\nchild = gtest_test_utils.Subprocess(\n    [sys.executable, '-c', 'import os; print(\\'UNSET_VAR\\' not in os.environ)'])\nCAN_UNSET_ENV = eval(child.output)\n\n\n# Checks if we should test with an empty filter. This doesn't\n# make sense on platforms that cannot pass empty env variables (Win32)\n# and on platforms that cannot unset variables (since we cannot tell\n# the difference between \"\" and NULL -- Borland and Solaris < 5.10)\nCAN_TEST_EMPTY_FILTER = (CAN_PASS_EMPTY_ENV and CAN_UNSET_ENV)\n\n\n# The environment variable for specifying the test filters.\nFILTER_ENV_VAR = 'GTEST_FILTER'\n\n# The environment variables for test sharding.\nTOTAL_SHARDS_ENV_VAR = 'GTEST_TOTAL_SHARDS'\nSHARD_INDEX_ENV_VAR = 'GTEST_SHARD_INDEX'\nSHARD_STATUS_FILE_ENV_VAR = 'GTEST_SHARD_STATUS_FILE'\n\n# The command line flag for specifying the test filters.\nFILTER_FLAG = 'gtest_filter'\n\n# The command line flag for including disabled tests.\nALSO_RUN_DISABED_TESTS_FLAG = 'gtest_also_run_disabled_tests'\n\n# Command to run the gtest_filter_unittest_ program.\nCOMMAND = gtest_test_utils.GetTestExecutablePath('gtest_filter_unittest_')\n\n# Regex for determining whether parameterized tests are enabled in the binary.\nPARAM_TEST_REGEX = re.compile(r'/ParamTest')\n\n# Regex for parsing test case names from Google Test's output.\nTEST_CASE_REGEX = re.compile(r'^\\[\\-+\\] \\d+ tests? from (\\w+(/\\w+)?)')\n\n# Regex for parsing test names from Google Test's output.\nTEST_REGEX = re.compile(r'^\\[\\s*RUN\\s*\\].*\\.(\\w+(/\\w+)?)')\n\n# The command line flag to tell Google Test to output the list of tests it\n# will run.\nLIST_TESTS_FLAG = '--gtest_list_tests'\n\n# Indicates whether Google Test supports death tests.\nSUPPORTS_DEATH_TESTS = 'HasDeathTest' in gtest_test_utils.Subprocess(\n    [COMMAND, LIST_TESTS_FLAG]).output\n\n# Full names of all tests in gtest_filter_unittests_.\nPARAM_TESTS = [\n    'SeqP/ParamTest.TestX/0',\n    'SeqP/ParamTest.TestX/1',\n    'SeqP/ParamTest.TestY/0',\n    'SeqP/ParamTest.TestY/1',\n    'SeqQ/ParamTest.TestX/0',\n    'SeqQ/ParamTest.TestX/1',\n    'SeqQ/ParamTest.TestY/0',\n    'SeqQ/ParamTest.TestY/1',\n    ]\n\nDISABLED_TESTS = [\n    'BarTest.DISABLED_TestFour',\n    'BarTest.DISABLED_TestFive',\n    'BazTest.DISABLED_TestC',\n    'DISABLED_FoobarTest.Test1',\n    'DISABLED_FoobarTest.DISABLED_Test2',\n    'DISABLED_FoobarbazTest.TestA',\n    ]\n\nif SUPPORTS_DEATH_TESTS:\n  DEATH_TESTS = [\n    'HasDeathTest.Test1',\n    'HasDeathTest.Test2',\n    ]\nelse:\n  DEATH_TESTS = []\n\n# All the non-disabled tests.\nACTIVE_TESTS = [\n    'FooTest.Abc',\n    'FooTest.Xyz',\n\n    'BarTest.TestOne',\n    'BarTest.TestTwo',\n    'BarTest.TestThree',\n\n    'BazTest.TestOne',\n    'BazTest.TestA',\n    'BazTest.TestB',\n    ] + DEATH_TESTS + PARAM_TESTS\n\nparam_tests_present = None\n\n# Utilities.\n\nenviron = os.environ.copy()\n\n\ndef SetEnvVar(env_var, value):\n  \"\"\"Sets the env variable to 'value'; unsets it when 'value' is None.\"\"\"\n\n  if value is not None:\n    environ[env_var] = value\n  elif env_var in environ:\n    del environ[env_var]\n\n\ndef RunAndReturnOutput(args = None):\n  \"\"\"Runs the test program and returns its output.\"\"\"\n\n  return gtest_test_utils.Subprocess([COMMAND] + (args or []),\n                                     env=environ).output\n\n\ndef RunAndExtractTestList(args = None):\n  \"\"\"Runs the test program and returns its exit code and a list of tests run.\"\"\"\n\n  p = gtest_test_utils.Subprocess([COMMAND] + (args or []), env=environ)\n  tests_run = []\n  test_case = ''\n  test = ''\n  for line in p.output.split('\\n'):\n    match = TEST_CASE_REGEX.match(line)\n    if match is not None:\n      test_case = match.group(1)\n    else:\n      match = TEST_REGEX.match(line)\n      if match is not None:\n        test = match.group(1)\n        tests_run.append(test_case + '.' + test)\n  return (tests_run, p.exit_code)\n\n\ndef InvokeWithModifiedEnv(extra_env, function, *args, **kwargs):\n  \"\"\"Runs the given function and arguments in a modified environment.\"\"\"\n  try:\n    original_env = environ.copy()\n    environ.update(extra_env)\n    return function(*args, **kwargs)\n  finally:\n    environ.clear()\n    environ.update(original_env)\n\n\ndef RunWithSharding(total_shards, shard_index, command):\n  \"\"\"Runs a test program shard and returns exit code and a list of tests run.\"\"\"\n\n  extra_env = {SHARD_INDEX_ENV_VAR: str(shard_index),\n               TOTAL_SHARDS_ENV_VAR: str(total_shards)}\n  return InvokeWithModifiedEnv(extra_env, RunAndExtractTestList, command)\n\n# The unit test.\n\n\nclass GTestFilterUnitTest(gtest_test_utils.TestCase):\n  \"\"\"Tests the env variable or the command line flag to filter tests.\"\"\"\n\n  # Utilities.\n\n  def AssertSetEqual(self, lhs, rhs):\n    \"\"\"Asserts that two sets are equal.\"\"\"\n\n    for elem in lhs:\n      self.assert_(elem in rhs, '%s in %s' % (elem, rhs))\n\n    for elem in rhs:\n      self.assert_(elem in lhs, '%s in %s' % (elem, lhs))\n\n  def AssertPartitionIsValid(self, set_var, list_of_sets):\n    \"\"\"Asserts that list_of_sets is a valid partition of set_var.\"\"\"\n\n    full_partition = []\n    for slice_var in list_of_sets:\n      full_partition.extend(slice_var)\n    self.assertEqual(len(set_var), len(full_partition))\n    self.assertEqual(set(set_var), set(full_partition))\n\n  def AdjustForParameterizedTests(self, tests_to_run):\n    \"\"\"Adjust tests_to_run in case value parameterized tests are disabled.\"\"\"\n\n    global param_tests_present\n    if not param_tests_present:\n      return list(set(tests_to_run) - set(PARAM_TESTS))\n    else:\n      return tests_to_run\n\n  def RunAndVerify(self, gtest_filter, tests_to_run):\n    \"\"\"Checks that the binary runs correct set of tests for a given filter.\"\"\"\n\n    tests_to_run = self.AdjustForParameterizedTests(tests_to_run)\n\n    # First, tests using the environment variable.\n\n    # Windows removes empty variables from the environment when passing it\n    # to a new process.  This means it is impossible to pass an empty filter\n    # into a process using the environment variable.  However, we can still\n    # test the case when the variable is not supplied (i.e., gtest_filter is\n    # None).\n    # pylint: disable-msg=C6403\n    if CAN_TEST_EMPTY_FILTER or gtest_filter != '':\n      SetEnvVar(FILTER_ENV_VAR, gtest_filter)\n      tests_run = RunAndExtractTestList()[0]\n      SetEnvVar(FILTER_ENV_VAR, None)\n      self.AssertSetEqual(tests_run, tests_to_run)\n    # pylint: enable-msg=C6403\n\n    # Next, tests using the command line flag.\n\n    if gtest_filter is None:\n      args = []\n    else:\n      args = ['--%s=%s' % (FILTER_FLAG, gtest_filter)]\n\n    tests_run = RunAndExtractTestList(args)[0]\n    self.AssertSetEqual(tests_run, tests_to_run)\n\n  def RunAndVerifyWithSharding(self, gtest_filter, total_shards, tests_to_run,\n                               args=None, check_exit_0=False):\n    \"\"\"Checks that binary runs correct tests for the given filter and shard.\n\n    Runs all shards of gtest_filter_unittest_ with the given filter, and\n    verifies that the right set of tests were run. The union of tests run\n    on each shard should be identical to tests_to_run, without duplicates.\n\n    Args:\n      gtest_filter: A filter to apply to the tests.\n      total_shards: A total number of shards to split test run into.\n      tests_to_run: A set of tests expected to run.\n      args   :      Arguments to pass to the to the test binary.\n      check_exit_0: When set to a true value, make sure that all shards\n                    return 0.\n    \"\"\"\n\n    tests_to_run = self.AdjustForParameterizedTests(tests_to_run)\n\n    # Windows removes empty variables from the environment when passing it\n    # to a new process.  This means it is impossible to pass an empty filter\n    # into a process using the environment variable.  However, we can still\n    # test the case when the variable is not supplied (i.e., gtest_filter is\n    # None).\n    # pylint: disable-msg=C6403\n    if CAN_TEST_EMPTY_FILTER or gtest_filter != '':\n      SetEnvVar(FILTER_ENV_VAR, gtest_filter)\n      partition = []\n      for i in range(0, total_shards):\n        (tests_run, exit_code) = RunWithSharding(total_shards, i, args)\n        if check_exit_0:\n          self.assertEqual(0, exit_code)\n        partition.append(tests_run)\n\n      self.AssertPartitionIsValid(tests_to_run, partition)\n      SetEnvVar(FILTER_ENV_VAR, None)\n    # pylint: enable-msg=C6403\n\n  def RunAndVerifyAllowingDisabled(self, gtest_filter, tests_to_run):\n    \"\"\"Checks that the binary runs correct set of tests for the given filter.\n\n    Runs gtest_filter_unittest_ with the given filter, and enables\n    disabled tests. Verifies that the right set of tests were run.\n\n    Args:\n      gtest_filter: A filter to apply to the tests.\n      tests_to_run: A set of tests expected to run.\n    \"\"\"\n\n    tests_to_run = self.AdjustForParameterizedTests(tests_to_run)\n\n    # Construct the command line.\n    args = ['--%s' % ALSO_RUN_DISABED_TESTS_FLAG]\n    if gtest_filter is not None:\n      args.append('--%s=%s' % (FILTER_FLAG, gtest_filter))\n\n    tests_run = RunAndExtractTestList(args)[0]\n    self.AssertSetEqual(tests_run, tests_to_run)\n\n  def setUp(self):\n    \"\"\"Sets up test case.\n\n    Determines whether value-parameterized tests are enabled in the binary and\n    sets the flags accordingly.\n    \"\"\"\n\n    global param_tests_present\n    if param_tests_present is None:\n      param_tests_present = PARAM_TEST_REGEX.search(\n          RunAndReturnOutput()) is not None\n\n  def testDefaultBehavior(self):\n    \"\"\"Tests the behavior of not specifying the filter.\"\"\"\n\n    self.RunAndVerify(None, ACTIVE_TESTS)\n\n  def testDefaultBehaviorWithShards(self):\n    \"\"\"Tests the behavior without the filter, with sharding enabled.\"\"\"\n\n    self.RunAndVerifyWithSharding(None, 1, ACTIVE_TESTS)\n    self.RunAndVerifyWithSharding(None, 2, ACTIVE_TESTS)\n    self.RunAndVerifyWithSharding(None, len(ACTIVE_TESTS) - 1, ACTIVE_TESTS)\n    self.RunAndVerifyWithSharding(None, len(ACTIVE_TESTS), ACTIVE_TESTS)\n    self.RunAndVerifyWithSharding(None, len(ACTIVE_TESTS) + 1, ACTIVE_TESTS)\n\n  def testEmptyFilter(self):\n    \"\"\"Tests an empty filter.\"\"\"\n\n    self.RunAndVerify('', [])\n    self.RunAndVerifyWithSharding('', 1, [])\n    self.RunAndVerifyWithSharding('', 2, [])\n\n  def testBadFilter(self):\n    \"\"\"Tests a filter that matches nothing.\"\"\"\n\n    self.RunAndVerify('BadFilter', [])\n    self.RunAndVerifyAllowingDisabled('BadFilter', [])\n\n  def testFullName(self):\n    \"\"\"Tests filtering by full name.\"\"\"\n\n    self.RunAndVerify('FooTest.Xyz', ['FooTest.Xyz'])\n    self.RunAndVerifyAllowingDisabled('FooTest.Xyz', ['FooTest.Xyz'])\n    self.RunAndVerifyWithSharding('FooTest.Xyz', 5, ['FooTest.Xyz'])\n\n  def testUniversalFilters(self):\n    \"\"\"Tests filters that match everything.\"\"\"\n\n    self.RunAndVerify('*', ACTIVE_TESTS)\n    self.RunAndVerify('*.*', ACTIVE_TESTS)\n    self.RunAndVerifyWithSharding('*.*', len(ACTIVE_TESTS) - 3, ACTIVE_TESTS)\n    self.RunAndVerifyAllowingDisabled('*', ACTIVE_TESTS + DISABLED_TESTS)\n    self.RunAndVerifyAllowingDisabled('*.*', ACTIVE_TESTS + DISABLED_TESTS)\n\n  def testFilterByTestCase(self):\n    \"\"\"Tests filtering by test case name.\"\"\"\n\n    self.RunAndVerify('FooTest.*', ['FooTest.Abc', 'FooTest.Xyz'])\n\n    BAZ_TESTS = ['BazTest.TestOne', 'BazTest.TestA', 'BazTest.TestB']\n    self.RunAndVerify('BazTest.*', BAZ_TESTS)\n    self.RunAndVerifyAllowingDisabled('BazTest.*',\n                                      BAZ_TESTS + ['BazTest.DISABLED_TestC'])\n\n  def testFilterByTest(self):\n    \"\"\"Tests filtering by test name.\"\"\"\n\n    self.RunAndVerify('*.TestOne', ['BarTest.TestOne', 'BazTest.TestOne'])\n\n  def testFilterDisabledTests(self):\n    \"\"\"Select only the disabled tests to run.\"\"\"\n\n    self.RunAndVerify('DISABLED_FoobarTest.Test1', [])\n    self.RunAndVerifyAllowingDisabled('DISABLED_FoobarTest.Test1',\n                                      ['DISABLED_FoobarTest.Test1'])\n\n    self.RunAndVerify('*DISABLED_*', [])\n    self.RunAndVerifyAllowingDisabled('*DISABLED_*', DISABLED_TESTS)\n\n    self.RunAndVerify('*.DISABLED_*', [])\n    self.RunAndVerifyAllowingDisabled('*.DISABLED_*', [\n        'BarTest.DISABLED_TestFour',\n        'BarTest.DISABLED_TestFive',\n        'BazTest.DISABLED_TestC',\n        'DISABLED_FoobarTest.DISABLED_Test2',\n        ])\n\n    self.RunAndVerify('DISABLED_*', [])\n    self.RunAndVerifyAllowingDisabled('DISABLED_*', [\n        'DISABLED_FoobarTest.Test1',\n        'DISABLED_FoobarTest.DISABLED_Test2',\n        'DISABLED_FoobarbazTest.TestA',\n        ])\n\n  def testWildcardInTestCaseName(self):\n    \"\"\"Tests using wildcard in the test case name.\"\"\"\n\n    self.RunAndVerify('*a*.*', [\n        'BarTest.TestOne',\n        'BarTest.TestTwo',\n        'BarTest.TestThree',\n\n        'BazTest.TestOne',\n        'BazTest.TestA',\n        'BazTest.TestB', ] + DEATH_TESTS + PARAM_TESTS)\n\n  def testWildcardInTestName(self):\n    \"\"\"Tests using wildcard in the test name.\"\"\"\n\n    self.RunAndVerify('*.*A*', ['FooTest.Abc', 'BazTest.TestA'])\n\n  def testFilterWithoutDot(self):\n    \"\"\"Tests a filter that has no '.' in it.\"\"\"\n\n    self.RunAndVerify('*z*', [\n        'FooTest.Xyz',\n\n        'BazTest.TestOne',\n        'BazTest.TestA',\n        'BazTest.TestB',\n        ])\n\n  def testTwoPatterns(self):\n    \"\"\"Tests filters that consist of two patterns.\"\"\"\n\n    self.RunAndVerify('Foo*.*:*A*', [\n        'FooTest.Abc',\n        'FooTest.Xyz',\n\n        'BazTest.TestA',\n        ])\n\n    # An empty pattern + a non-empty one\n    self.RunAndVerify(':*A*', ['FooTest.Abc', 'BazTest.TestA'])\n\n  def testThreePatterns(self):\n    \"\"\"Tests filters that consist of three patterns.\"\"\"\n\n    self.RunAndVerify('*oo*:*A*:*One', [\n        'FooTest.Abc',\n        'FooTest.Xyz',\n\n        'BarTest.TestOne',\n\n        'BazTest.TestOne',\n        'BazTest.TestA',\n        ])\n\n    # The 2nd pattern is empty.\n    self.RunAndVerify('*oo*::*One', [\n        'FooTest.Abc',\n        'FooTest.Xyz',\n\n        'BarTest.TestOne',\n\n        'BazTest.TestOne',\n        ])\n\n    # The last 2 patterns are empty.\n    self.RunAndVerify('*oo*::', [\n        'FooTest.Abc',\n        'FooTest.Xyz',\n        ])\n\n  def testNegativeFilters(self):\n    self.RunAndVerify('*-BazTest.TestOne', [\n        'FooTest.Abc',\n        'FooTest.Xyz',\n\n        'BarTest.TestOne',\n        'BarTest.TestTwo',\n        'BarTest.TestThree',\n\n        'BazTest.TestA',\n        'BazTest.TestB',\n        ] + DEATH_TESTS + PARAM_TESTS)\n\n    self.RunAndVerify('*-FooTest.Abc:BazTest.*', [\n        'FooTest.Xyz',\n\n        'BarTest.TestOne',\n        'BarTest.TestTwo',\n        'BarTest.TestThree',\n        ] + DEATH_TESTS + PARAM_TESTS)\n\n    self.RunAndVerify('BarTest.*-BarTest.TestOne', [\n        'BarTest.TestTwo',\n        'BarTest.TestThree',\n        ])\n\n    # Tests without leading '*'.\n    self.RunAndVerify('-FooTest.Abc:FooTest.Xyz:BazTest.*', [\n        'BarTest.TestOne',\n        'BarTest.TestTwo',\n        'BarTest.TestThree',\n        ] + DEATH_TESTS + PARAM_TESTS)\n\n    # Value parameterized tests.\n    self.RunAndVerify('*/*', PARAM_TESTS)\n\n    # Value parameterized tests filtering by the sequence name.\n    self.RunAndVerify('SeqP/*', [\n        'SeqP/ParamTest.TestX/0',\n        'SeqP/ParamTest.TestX/1',\n        'SeqP/ParamTest.TestY/0',\n        'SeqP/ParamTest.TestY/1',\n        ])\n\n    # Value parameterized tests filtering by the test name.\n    self.RunAndVerify('*/0', [\n        'SeqP/ParamTest.TestX/0',\n        'SeqP/ParamTest.TestY/0',\n        'SeqQ/ParamTest.TestX/0',\n        'SeqQ/ParamTest.TestY/0',\n        ])\n\n  def testFlagOverridesEnvVar(self):\n    \"\"\"Tests that the filter flag overrides the filtering env. variable.\"\"\"\n\n    SetEnvVar(FILTER_ENV_VAR, 'Foo*')\n    args = ['--%s=%s' % (FILTER_FLAG, '*One')]\n    tests_run = RunAndExtractTestList(args)[0]\n    SetEnvVar(FILTER_ENV_VAR, None)\n\n    self.AssertSetEqual(tests_run, ['BarTest.TestOne', 'BazTest.TestOne'])\n\n  def testShardStatusFileIsCreated(self):\n    \"\"\"Tests that the shard file is created if specified in the environment.\"\"\"\n\n    shard_status_file = os.path.join(gtest_test_utils.GetTempDir(),\n                                     'shard_status_file')\n    self.assert_(not os.path.exists(shard_status_file))\n\n    extra_env = {SHARD_STATUS_FILE_ENV_VAR: shard_status_file}\n    try:\n      InvokeWithModifiedEnv(extra_env, RunAndReturnOutput)\n    finally:\n      self.assert_(os.path.exists(shard_status_file))\n      os.remove(shard_status_file)\n\n  def testShardStatusFileIsCreatedWithListTests(self):\n    \"\"\"Tests that the shard file is created with the \"list_tests\" flag.\"\"\"\n\n    shard_status_file = os.path.join(gtest_test_utils.GetTempDir(),\n                                     'shard_status_file2')\n    self.assert_(not os.path.exists(shard_status_file))\n\n    extra_env = {SHARD_STATUS_FILE_ENV_VAR: shard_status_file}\n    try:\n      output = InvokeWithModifiedEnv(extra_env,\n                                     RunAndReturnOutput,\n                                     [LIST_TESTS_FLAG])\n    finally:\n      # This assertion ensures that Google Test enumerated the tests as\n      # opposed to running them.\n      self.assert_('[==========]' not in output,\n                   'Unexpected output during test enumeration.\\n'\n                   'Please ensure that LIST_TESTS_FLAG is assigned the\\n'\n                   'correct flag value for listing Google Test tests.')\n\n      self.assert_(os.path.exists(shard_status_file))\n      os.remove(shard_status_file)\n\n  if SUPPORTS_DEATH_TESTS:\n    def testShardingWorksWithDeathTests(self):\n      \"\"\"Tests integration with death tests and sharding.\"\"\"\n\n      gtest_filter = 'HasDeathTest.*:SeqP/*'\n      expected_tests = [\n          'HasDeathTest.Test1',\n          'HasDeathTest.Test2',\n\n          'SeqP/ParamTest.TestX/0',\n          'SeqP/ParamTest.TestX/1',\n          'SeqP/ParamTest.TestY/0',\n          'SeqP/ParamTest.TestY/1',\n          ]\n\n      for flag in ['--gtest_death_test_style=threadsafe',\n                   '--gtest_death_test_style=fast']:\n        self.RunAndVerifyWithSharding(gtest_filter, 3, expected_tests,\n                                      check_exit_0=True, args=[flag])\n        self.RunAndVerifyWithSharding(gtest_filter, 5, expected_tests,\n                                      check_exit_0=True, args=[flag])\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_filter_unittest_.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Unit test for Google Test test filters.\n//\n// A user can specify which test(s) in a Google Test program to run via\n// either the GTEST_FILTER environment variable or the --gtest_filter\n// flag.  This is used for testing such functionality.\n//\n// The program will be invoked from a Python unit test.  Don't run it\n// directly.\n\n#include \"gtest/gtest.h\"\n\nnamespace {\n\n// Test case FooTest.\n\nclass FooTest : public testing::Test {\n};\n\nTEST_F(FooTest, Abc) {\n}\n\nTEST_F(FooTest, Xyz) {\n  FAIL() << \"Expected failure.\";\n}\n\n// Test case BarTest.\n\nTEST(BarTest, TestOne) {\n}\n\nTEST(BarTest, TestTwo) {\n}\n\nTEST(BarTest, TestThree) {\n}\n\nTEST(BarTest, DISABLED_TestFour) {\n  FAIL() << \"Expected failure.\";\n}\n\nTEST(BarTest, DISABLED_TestFive) {\n  FAIL() << \"Expected failure.\";\n}\n\n// Test case BazTest.\n\nTEST(BazTest, TestOne) {\n  FAIL() << \"Expected failure.\";\n}\n\nTEST(BazTest, TestA) {\n}\n\nTEST(BazTest, TestB) {\n}\n\nTEST(BazTest, DISABLED_TestC) {\n  FAIL() << \"Expected failure.\";\n}\n\n// Test case HasDeathTest\n\nTEST(HasDeathTest, Test1) {\n  EXPECT_DEATH_IF_SUPPORTED(exit(1), \".*\");\n}\n\n// We need at least two death tests to make sure that the all death tests\n// aren't on the first shard.\nTEST(HasDeathTest, Test2) {\n  EXPECT_DEATH_IF_SUPPORTED(exit(1), \".*\");\n}\n\n// Test case FoobarTest\n\nTEST(DISABLED_FoobarTest, Test1) {\n  FAIL() << \"Expected failure.\";\n}\n\nTEST(DISABLED_FoobarTest, DISABLED_Test2) {\n  FAIL() << \"Expected failure.\";\n}\n\n// Test case FoobarbazTest\n\nTEST(DISABLED_FoobarbazTest, TestA) {\n  FAIL() << \"Expected failure.\";\n}\n\n#if GTEST_HAS_PARAM_TEST\nclass ParamTest : public testing::TestWithParam<int> {\n};\n\nTEST_P(ParamTest, TestX) {\n}\n\nTEST_P(ParamTest, TestY) {\n}\n\nINSTANTIATE_TEST_CASE_P(SeqP, ParamTest, testing::Values(1, 2));\nINSTANTIATE_TEST_CASE_P(SeqQ, ParamTest, testing::Values(5, 6));\n#endif  // GTEST_HAS_PARAM_TEST\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_help_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2009, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Tests the --help flag of Google C++ Testing Framework.\n\nSYNOPSIS\n       gtest_help_test.py --build_dir=BUILD/DIR\n         # where BUILD/DIR contains the built gtest_help_test_ file.\n       gtest_help_test.py\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport re\nimport gtest_test_utils\n\n\nIS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'\nIS_WINDOWS = os.name == 'nt'\n\nPROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_help_test_')\nFLAG_PREFIX = '--gtest_'\nDEATH_TEST_STYLE_FLAG = FLAG_PREFIX + 'death_test_style'\nSTREAM_RESULT_TO_FLAG = FLAG_PREFIX + 'stream_result_to'\nUNKNOWN_FLAG = FLAG_PREFIX + 'unknown_flag_for_testing'\nLIST_TESTS_FLAG = FLAG_PREFIX + 'list_tests'\nINCORRECT_FLAG_VARIANTS = [re.sub('^--', '-', LIST_TESTS_FLAG),\n                           re.sub('^--', '/', LIST_TESTS_FLAG),\n                           re.sub('_', '-', LIST_TESTS_FLAG)]\nINTERNAL_FLAG_FOR_TESTING = FLAG_PREFIX + 'internal_flag_for_testing'\n\nSUPPORTS_DEATH_TESTS = \"DeathTest\" in gtest_test_utils.Subprocess(\n    [PROGRAM_PATH, LIST_TESTS_FLAG]).output\n\n# The help message must match this regex.\nHELP_REGEX = re.compile(\n    FLAG_PREFIX + r'list_tests.*' +\n    FLAG_PREFIX + r'filter=.*' +\n    FLAG_PREFIX + r'also_run_disabled_tests.*' +\n    FLAG_PREFIX + r'repeat=.*' +\n    FLAG_PREFIX + r'shuffle.*' +\n    FLAG_PREFIX + r'random_seed=.*' +\n    FLAG_PREFIX + r'color=.*' +\n    FLAG_PREFIX + r'print_time.*' +\n    FLAG_PREFIX + r'output=.*' +\n    FLAG_PREFIX + r'break_on_failure.*' +\n    FLAG_PREFIX + r'throw_on_failure.*' +\n    FLAG_PREFIX + r'catch_exceptions=0.*',\n    re.DOTALL)\n\n\ndef RunWithFlag(flag):\n  \"\"\"Runs gtest_help_test_ with the given flag.\n\n  Returns:\n    the exit code and the text output as a tuple.\n  Args:\n    flag: the command-line flag to pass to gtest_help_test_, or None.\n  \"\"\"\n\n  if flag is None:\n    command = [PROGRAM_PATH]\n  else:\n    command = [PROGRAM_PATH, flag]\n  child = gtest_test_utils.Subprocess(command)\n  return child.exit_code, child.output\n\n\nclass GTestHelpTest(gtest_test_utils.TestCase):\n  \"\"\"Tests the --help flag and its equivalent forms.\"\"\"\n\n  def TestHelpFlag(self, flag):\n    \"\"\"Verifies correct behavior when help flag is specified.\n\n    The right message must be printed and the tests must\n    skipped when the given flag is specified.\n\n    Args:\n      flag:  A flag to pass to the binary or None.\n    \"\"\"\n\n    exit_code, output = RunWithFlag(flag)\n    self.assertEquals(0, exit_code)\n    self.assert_(HELP_REGEX.search(output), output)\n\n    if IS_LINUX:\n      self.assert_(STREAM_RESULT_TO_FLAG in output, output)\n    else:\n      self.assert_(STREAM_RESULT_TO_FLAG not in output, output)\n\n    if SUPPORTS_DEATH_TESTS and not IS_WINDOWS:\n      self.assert_(DEATH_TEST_STYLE_FLAG in output, output)\n    else:\n      self.assert_(DEATH_TEST_STYLE_FLAG not in output, output)\n\n  def TestNonHelpFlag(self, flag):\n    \"\"\"Verifies correct behavior when no help flag is specified.\n\n    Verifies that when no help flag is specified, the tests are run\n    and the help message is not printed.\n\n    Args:\n      flag:  A flag to pass to the binary or None.\n    \"\"\"\n\n    exit_code, output = RunWithFlag(flag)\n    self.assert_(exit_code != 0)\n    self.assert_(not HELP_REGEX.search(output), output)\n\n  def testPrintsHelpWithFullFlag(self):\n    self.TestHelpFlag('--help')\n\n  def testPrintsHelpWithShortFlag(self):\n    self.TestHelpFlag('-h')\n\n  def testPrintsHelpWithQuestionFlag(self):\n    self.TestHelpFlag('-?')\n\n  def testPrintsHelpWithWindowsStyleQuestionFlag(self):\n    self.TestHelpFlag('/?')\n\n  def testPrintsHelpWithUnrecognizedGoogleTestFlag(self):\n    self.TestHelpFlag(UNKNOWN_FLAG)\n\n  def testPrintsHelpWithIncorrectFlagStyle(self):\n    for incorrect_flag in INCORRECT_FLAG_VARIANTS:\n      self.TestHelpFlag(incorrect_flag)\n\n  def testRunsTestsWithoutHelpFlag(self):\n    \"\"\"Verifies that when no help flag is specified, the tests are run\n    and the help message is not printed.\"\"\"\n\n    self.TestNonHelpFlag(None)\n\n  def testRunsTestsWithGtestInternalFlag(self):\n    \"\"\"Verifies that the tests are run and no help message is printed when\n    a flag starting with Google Test prefix and 'internal_' is supplied.\"\"\"\n\n    self.TestNonHelpFlag(INTERNAL_FLAG_FOR_TESTING)\n\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_help_test_.cc",
    "content": "// Copyright 2009, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// This program is meant to be run by gtest_help_test.py.  Do not run\n// it directly.\n\n#include \"gtest/gtest.h\"\n\n// When a help flag is specified, this program should skip the tests\n// and exit with 0; otherwise the following test will be executed,\n// causing this program to exit with a non-zero code.\nTEST(HelpFlagTest, ShouldNotBeRun) {\n  ASSERT_TRUE(false) << \"Tests shouldn't be run when --help is specified.\";\n}\n\n#if GTEST_HAS_DEATH_TEST\nTEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {}\n#endif\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_list_tests_unittest.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2006, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Unit test for Google Test's --gtest_list_tests flag.\n\nA user can ask Google Test to list all tests by specifying the\n--gtest_list_tests flag.  This script tests such functionality\nby invoking gtest_list_tests_unittest_ (a program written with\nGoogle Test) the command line flags.\n\"\"\"\n\n__author__ = 'phanna@google.com (Patrick Hanna)'\n\nimport gtest_test_utils\nimport re\n\n\n# Constants.\n\n# The command line flag for enabling/disabling listing all tests.\nLIST_TESTS_FLAG = 'gtest_list_tests'\n\n# Path to the gtest_list_tests_unittest_ program.\nEXE_PATH = gtest_test_utils.GetTestExecutablePath('gtest_list_tests_unittest_')\n\n# The expected output when running gtest_list_tests_unittest_ with\n# --gtest_list_tests\nEXPECTED_OUTPUT_NO_FILTER_RE = re.compile(r\"\"\"FooDeathTest\\.\n  Test1\nFoo\\.\n  Bar1\n  Bar2\n  DISABLED_Bar3\nAbc\\.\n  Xyz\n  Def\nFooBar\\.\n  Baz\nFooTest\\.\n  Test1\n  DISABLED_Test2\n  Test3\nTypedTest/0\\.  # TypeParam = (VeryLo{245}|class VeryLo{239})\\.\\.\\.\n  TestA\n  TestB\nTypedTest/1\\.  # TypeParam = int\\s*\\*( __ptr64)?\n  TestA\n  TestB\nTypedTest/2\\.  # TypeParam = .*MyArray<bool,\\s*42>\n  TestA\n  TestB\nMy/TypeParamTest/0\\.  # TypeParam = (VeryLo{245}|class VeryLo{239})\\.\\.\\.\n  TestA\n  TestB\nMy/TypeParamTest/1\\.  # TypeParam = int\\s*\\*( __ptr64)?\n  TestA\n  TestB\nMy/TypeParamTest/2\\.  # TypeParam = .*MyArray<bool,\\s*42>\n  TestA\n  TestB\nMyInstantiation/ValueParamTest\\.\n  TestA/0  # GetParam\\(\\) = one line\n  TestA/1  # GetParam\\(\\) = two\\\\nlines\n  TestA/2  # GetParam\\(\\) = a very\\\\nlo{241}\\.\\.\\.\n  TestB/0  # GetParam\\(\\) = one line\n  TestB/1  # GetParam\\(\\) = two\\\\nlines\n  TestB/2  # GetParam\\(\\) = a very\\\\nlo{241}\\.\\.\\.\n\"\"\")\n\n# The expected output when running gtest_list_tests_unittest_ with\n# --gtest_list_tests and --gtest_filter=Foo*.\nEXPECTED_OUTPUT_FILTER_FOO_RE = re.compile(r\"\"\"FooDeathTest\\.\n  Test1\nFoo\\.\n  Bar1\n  Bar2\n  DISABLED_Bar3\nFooBar\\.\n  Baz\nFooTest\\.\n  Test1\n  DISABLED_Test2\n  Test3\n\"\"\")\n\n# Utilities.\n\n\ndef Run(args):\n  \"\"\"Runs gtest_list_tests_unittest_ and returns the list of tests printed.\"\"\"\n\n  return gtest_test_utils.Subprocess([EXE_PATH] + args,\n                                     capture_stderr=False).output\n\n\n# The unit test.\n\nclass GTestListTestsUnitTest(gtest_test_utils.TestCase):\n  \"\"\"Tests using the --gtest_list_tests flag to list all tests.\"\"\"\n\n  def RunAndVerify(self, flag_value, expected_output_re, other_flag):\n    \"\"\"Runs gtest_list_tests_unittest_ and verifies that it prints\n    the correct tests.\n\n    Args:\n      flag_value:         value of the --gtest_list_tests flag;\n                          None if the flag should not be present.\n      expected_output_re: regular expression that matches the expected\n                          output after running command;\n      other_flag:         a different flag to be passed to command\n                          along with gtest_list_tests;\n                          None if the flag should not be present.\n    \"\"\"\n\n    if flag_value is None:\n      flag = ''\n      flag_expression = 'not set'\n    elif flag_value == '0':\n      flag = '--%s=0' % LIST_TESTS_FLAG\n      flag_expression = '0'\n    else:\n      flag = '--%s' % LIST_TESTS_FLAG\n      flag_expression = '1'\n\n    args = [flag]\n\n    if other_flag is not None:\n      args += [other_flag]\n\n    output = Run(args)\n\n    if expected_output_re:\n      self.assert_(\n          expected_output_re.match(output),\n          ('when %s is %s, the output of \"%s\" is \"%s\",\\n'\n           'which does not match regex \"%s\"' %\n           (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output,\n            expected_output_re.pattern)))\n    else:\n      self.assert_(\n          not EXPECTED_OUTPUT_NO_FILTER_RE.match(output),\n          ('when %s is %s, the output of \"%s\" is \"%s\"'%\n           (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output)))\n\n  def testDefaultBehavior(self):\n    \"\"\"Tests the behavior of the default mode.\"\"\"\n\n    self.RunAndVerify(flag_value=None,\n                      expected_output_re=None,\n                      other_flag=None)\n\n  def testFlag(self):\n    \"\"\"Tests using the --gtest_list_tests flag.\"\"\"\n\n    self.RunAndVerify(flag_value='0',\n                      expected_output_re=None,\n                      other_flag=None)\n    self.RunAndVerify(flag_value='1',\n                      expected_output_re=EXPECTED_OUTPUT_NO_FILTER_RE,\n                      other_flag=None)\n\n  def testOverrideNonFilterFlags(self):\n    \"\"\"Tests that --gtest_list_tests overrides the non-filter flags.\"\"\"\n\n    self.RunAndVerify(flag_value='1',\n                      expected_output_re=EXPECTED_OUTPUT_NO_FILTER_RE,\n                      other_flag='--gtest_break_on_failure')\n\n  def testWithFilterFlags(self):\n    \"\"\"Tests that --gtest_list_tests takes into account the\n    --gtest_filter flag.\"\"\"\n\n    self.RunAndVerify(flag_value='1',\n                      expected_output_re=EXPECTED_OUTPUT_FILTER_FOO_RE,\n                      other_flag='--gtest_filter=Foo*')\n\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_list_tests_unittest_.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: phanna@google.com (Patrick Hanna)\n\n// Unit test for Google Test's --gtest_list_tests flag.\n//\n// A user can ask Google Test to list all tests that will run\n// so that when using a filter, a user will know what\n// tests to look for. The tests will not be run after listing.\n//\n// This program will be invoked from a Python unit test.\n// Don't run it directly.\n\n#include \"gtest/gtest.h\"\n\n// Several different test cases and tests that will be listed.\nTEST(Foo, Bar1) {\n}\n\nTEST(Foo, Bar2) {\n}\n\nTEST(Foo, DISABLED_Bar3) {\n}\n\nTEST(Abc, Xyz) {\n}\n\nTEST(Abc, Def) {\n}\n\nTEST(FooBar, Baz) {\n}\n\nclass FooTest : public testing::Test {\n};\n\nTEST_F(FooTest, Test1) {\n}\n\nTEST_F(FooTest, DISABLED_Test2) {\n}\n\nTEST_F(FooTest, Test3) {\n}\n\nTEST(FooDeathTest, Test1) {\n}\n\n// A group of value-parameterized tests.\n\nclass MyType {\n public:\n  explicit MyType(const std::string& a_value) : value_(a_value) {}\n\n  const std::string& value() const { return value_; }\n\n private:\n  std::string value_;\n};\n\n// Teaches Google Test how to print a MyType.\nvoid PrintTo(const MyType& x, std::ostream* os) {\n  *os << x.value();\n}\n\nclass ValueParamTest : public testing::TestWithParam<MyType> {\n};\n\nTEST_P(ValueParamTest, TestA) {\n}\n\nTEST_P(ValueParamTest, TestB) {\n}\n\nINSTANTIATE_TEST_CASE_P(\n    MyInstantiation, ValueParamTest,\n    testing::Values(MyType(\"one line\"),\n                    MyType(\"two\\nlines\"),\n                    MyType(\"a very\\nloooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong line\")));  // NOLINT\n\n// A group of typed tests.\n\n// A deliberately long type name for testing the line-truncating\n// behavior when printing a type parameter.\nclass VeryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName {  // NOLINT\n};\n\ntemplate <typename T>\nclass TypedTest : public testing::Test {\n};\n\ntemplate <typename T, int kSize>\nclass MyArray {\n};\n\ntypedef testing::Types<VeryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName,  // NOLINT\n                       int*, MyArray<bool, 42> > MyTypes;\n\nTYPED_TEST_CASE(TypedTest, MyTypes);\n\nTYPED_TEST(TypedTest, TestA) {\n}\n\nTYPED_TEST(TypedTest, TestB) {\n}\n\n// A group of type-parameterized tests.\n\ntemplate <typename T>\nclass TypeParamTest : public testing::Test {\n};\n\nTYPED_TEST_CASE_P(TypeParamTest);\n\nTYPED_TEST_P(TypeParamTest, TestA) {\n}\n\nTYPED_TEST_P(TypeParamTest, TestB) {\n}\n\nREGISTER_TYPED_TEST_CASE_P(TypeParamTest, TestA, TestB);\n\nINSTANTIATE_TYPED_TEST_CASE_P(My, TypeParamTest, MyTypes);\n\nint main(int argc, char **argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_main_unittest.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/gtest.h\"\n\n// Tests that we don't have to define main() when we link to\n// gtest_main instead of gtest.\n\nnamespace {\n\nTEST(GTestMainTest, ShouldSucceed) {\n}\n\n}  // namespace\n\n// We are using the main() function defined in src/gtest_main.cc, so\n// we don't define it here.\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_no_test_unittest.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Tests that a Google Test program that has no test defined can run\n// successfully.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/gtest.h\"\n\nint main(int argc, char **argv) {\n  testing::InitGoogleTest(&argc, argv);\n\n  // An ad-hoc assertion outside of all tests.\n  //\n  // This serves three purposes:\n  //\n  // 1. It verifies that an ad-hoc assertion can be executed even if\n  //    no test is defined.\n  // 2. It verifies that a failed ad-hoc assertion causes the test\n  //    program to fail.\n  // 3. We had a bug where the XML output won't be generated if an\n  //    assertion is executed before RUN_ALL_TESTS() is called, even\n  //    though --gtest_output=xml is specified.  This makes sure the\n  //    bug is fixed and doesn't regress.\n  EXPECT_EQ(1, 2);\n\n  // The above EXPECT_EQ() should cause RUN_ALL_TESTS() to return non-zero.\n  return RUN_ALL_TESTS() ? 0 : 1;\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_output_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Tests the text output of Google C++ Testing Framework.\n\nSYNOPSIS\n       gtest_output_test.py --build_dir=BUILD/DIR --gengolden\n         # where BUILD/DIR contains the built gtest_output_test_ file.\n       gtest_output_test.py --gengolden\n       gtest_output_test.py\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport difflib\nimport os\nimport re\nimport sys\nimport gtest_test_utils\n\n\n# The flag for generating the golden file\nGENGOLDEN_FLAG = '--gengolden'\nCATCH_EXCEPTIONS_ENV_VAR_NAME = 'GTEST_CATCH_EXCEPTIONS'\n\nIS_WINDOWS = os.name == 'nt'\n\n# TODO(vladl@google.com): remove the _lin suffix.\nGOLDEN_NAME = 'gtest_output_test_golden_lin.txt'\n\nPROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_output_test_')\n\n# At least one command we exercise must not have the\n# 'internal_skip_environment_and_ad_hoc_tests' argument.\nCOMMAND_LIST_TESTS = ({}, [PROGRAM_PATH, '--gtest_list_tests'])\nCOMMAND_WITH_COLOR = ({}, [PROGRAM_PATH, '--gtest_color=yes'])\nCOMMAND_WITH_TIME = ({}, [PROGRAM_PATH,\n                          '--gtest_print_time',\n                          'internal_skip_environment_and_ad_hoc_tests',\n                          '--gtest_filter=FatalFailureTest.*:LoggingTest.*'])\nCOMMAND_WITH_DISABLED = (\n    {}, [PROGRAM_PATH,\n         '--gtest_also_run_disabled_tests',\n         'internal_skip_environment_and_ad_hoc_tests',\n         '--gtest_filter=*DISABLED_*'])\nCOMMAND_WITH_SHARDING = (\n    {'GTEST_SHARD_INDEX': '1', 'GTEST_TOTAL_SHARDS': '2'},\n    [PROGRAM_PATH,\n     'internal_skip_environment_and_ad_hoc_tests',\n     '--gtest_filter=PassingTest.*'])\n\nGOLDEN_PATH = os.path.join(gtest_test_utils.GetSourceDir(), GOLDEN_NAME)\n\n\ndef ToUnixLineEnding(s):\n  \"\"\"Changes all Windows/Mac line endings in s to UNIX line endings.\"\"\"\n\n  return s.replace('\\r\\n', '\\n').replace('\\r', '\\n')\n\n\ndef RemoveLocations(test_output):\n  \"\"\"Removes all file location info from a Google Test program's output.\n\n  Args:\n       test_output:  the output of a Google Test program.\n\n  Returns:\n       output with all file location info (in the form of\n       'DIRECTORY/FILE_NAME:LINE_NUMBER: 'or\n       'DIRECTORY\\\\FILE_NAME(LINE_NUMBER): ') replaced by\n       'FILE_NAME:#: '.\n  \"\"\"\n\n  return re.sub(r'.*[/\\\\](.+)(\\:\\d+|\\(\\d+\\))\\: ', r'\\1:#: ', test_output)\n\n\ndef RemoveStackTraceDetails(output):\n  \"\"\"Removes all stack traces from a Google Test program's output.\"\"\"\n\n  # *? means \"find the shortest string that matches\".\n  return re.sub(r'Stack trace:(.|\\n)*?\\n\\n',\n                'Stack trace: (omitted)\\n\\n', output)\n\n\ndef RemoveStackTraces(output):\n  \"\"\"Removes all traces of stack traces from a Google Test program's output.\"\"\"\n\n  # *? means \"find the shortest string that matches\".\n  return re.sub(r'Stack trace:(.|\\n)*?\\n\\n', '', output)\n\n\ndef RemoveTime(output):\n  \"\"\"Removes all time information from a Google Test program's output.\"\"\"\n\n  return re.sub(r'\\(\\d+ ms', '(? ms', output)\n\n\ndef RemoveTypeInfoDetails(test_output):\n  \"\"\"Removes compiler-specific type info from Google Test program's output.\n\n  Args:\n       test_output:  the output of a Google Test program.\n\n  Returns:\n       output with type information normalized to canonical form.\n  \"\"\"\n\n  # some compilers output the name of type 'unsigned int' as 'unsigned'\n  return re.sub(r'unsigned int', 'unsigned', test_output)\n\n\ndef NormalizeToCurrentPlatform(test_output):\n  \"\"\"Normalizes platform specific output details for easier comparison.\"\"\"\n\n  if IS_WINDOWS:\n    # Removes the color information that is not present on Windows.\n    test_output = re.sub('\\x1b\\\\[(0;3\\d)?m', '', test_output)\n    # Changes failure message headers into the Windows format.\n    test_output = re.sub(r': Failure\\n', r': error: ', test_output)\n    # Changes file(line_number) to file:line_number.\n    test_output = re.sub(r'((\\w|\\.)+)\\((\\d+)\\):', r'\\1:\\3:', test_output)\n\n  return test_output\n\n\ndef RemoveTestCounts(output):\n  \"\"\"Removes test counts from a Google Test program's output.\"\"\"\n\n  output = re.sub(r'\\d+ tests?, listed below',\n                  '? tests, listed below', output)\n  output = re.sub(r'\\d+ FAILED TESTS',\n                  '? FAILED TESTS', output)\n  output = re.sub(r'\\d+ tests? from \\d+ test cases?',\n                  '? tests from ? test cases', output)\n  output = re.sub(r'\\d+ tests? from ([a-zA-Z_])',\n                  r'? tests from \\1', output)\n  return re.sub(r'\\d+ tests?\\.', '? tests.', output)\n\n\ndef RemoveMatchingTests(test_output, pattern):\n  \"\"\"Removes output of specified tests from a Google Test program's output.\n\n  This function strips not only the beginning and the end of a test but also\n  all output in between.\n\n  Args:\n    test_output:       A string containing the test output.\n    pattern:           A regex string that matches names of test cases or\n                       tests to remove.\n\n  Returns:\n    Contents of test_output with tests whose names match pattern removed.\n  \"\"\"\n\n  test_output = re.sub(\n      r'.*\\[ RUN      \\] .*%s(.|\\n)*?\\[(  FAILED  |       OK )\\] .*%s.*\\n' % (\n          pattern, pattern),\n      '',\n      test_output)\n  return re.sub(r'.*%s.*\\n' % pattern, '', test_output)\n\n\ndef NormalizeOutput(output):\n  \"\"\"Normalizes output (the output of gtest_output_test_.exe).\"\"\"\n\n  output = ToUnixLineEnding(output)\n  output = RemoveLocations(output)\n  output = RemoveStackTraceDetails(output)\n  output = RemoveTime(output)\n  return output\n\n\ndef GetShellCommandOutput(env_cmd):\n  \"\"\"Runs a command in a sub-process, and returns its output in a string.\n\n  Args:\n    env_cmd: The shell command. A 2-tuple where element 0 is a dict of extra\n             environment variables to set, and element 1 is a string with\n             the command and any flags.\n\n  Returns:\n    A string with the command's combined standard and diagnostic output.\n  \"\"\"\n\n  # Spawns cmd in a sub-process, and gets its standard I/O file objects.\n  # Set and save the environment properly.\n  environ = os.environ.copy()\n  environ.update(env_cmd[0])\n  p = gtest_test_utils.Subprocess(env_cmd[1], env=environ)\n\n  return p.output\n\n\ndef GetCommandOutput(env_cmd):\n  \"\"\"Runs a command and returns its output with all file location\n  info stripped off.\n\n  Args:\n    env_cmd:  The shell command. A 2-tuple where element 0 is a dict of extra\n              environment variables to set, and element 1 is a string with\n              the command and any flags.\n  \"\"\"\n\n  # Disables exception pop-ups on Windows.\n  environ, cmdline = env_cmd\n  environ = dict(environ)  # Ensures we are modifying a copy.\n  environ[CATCH_EXCEPTIONS_ENV_VAR_NAME] = '1'\n  return NormalizeOutput(GetShellCommandOutput((environ, cmdline)))\n\n\ndef GetOutputOfAllCommands():\n  \"\"\"Returns concatenated output from several representative commands.\"\"\"\n\n  return (GetCommandOutput(COMMAND_WITH_COLOR) +\n          GetCommandOutput(COMMAND_WITH_TIME) +\n          GetCommandOutput(COMMAND_WITH_DISABLED) +\n          GetCommandOutput(COMMAND_WITH_SHARDING))\n\n\ntest_list = GetShellCommandOutput(COMMAND_LIST_TESTS)\nSUPPORTS_DEATH_TESTS = 'DeathTest' in test_list\nSUPPORTS_TYPED_TESTS = 'TypedTest' in test_list\nSUPPORTS_THREADS = 'ExpectFailureWithThreadsTest' in test_list\nSUPPORTS_STACK_TRACES = False\n\nCAN_GENERATE_GOLDEN_FILE = (SUPPORTS_DEATH_TESTS and\n                            SUPPORTS_TYPED_TESTS and\n                            SUPPORTS_THREADS and\n                            not IS_WINDOWS)\n\nclass GTestOutputTest(gtest_test_utils.TestCase):\n  def RemoveUnsupportedTests(self, test_output):\n    if not SUPPORTS_DEATH_TESTS:\n      test_output = RemoveMatchingTests(test_output, 'DeathTest')\n    if not SUPPORTS_TYPED_TESTS:\n      test_output = RemoveMatchingTests(test_output, 'TypedTest')\n      test_output = RemoveMatchingTests(test_output, 'TypedDeathTest')\n      test_output = RemoveMatchingTests(test_output, 'TypeParamDeathTest')\n    if not SUPPORTS_THREADS:\n      test_output = RemoveMatchingTests(test_output,\n                                        'ExpectFailureWithThreadsTest')\n      test_output = RemoveMatchingTests(test_output,\n                                        'ScopedFakeTestPartResultReporterTest')\n      test_output = RemoveMatchingTests(test_output,\n                                        'WorksConcurrently')\n    if not SUPPORTS_STACK_TRACES:\n      test_output = RemoveStackTraces(test_output)\n\n    return test_output\n\n  def testOutput(self):\n    output = GetOutputOfAllCommands()\n\n    golden_file = open(GOLDEN_PATH, 'r')\n    # A mis-configured source control system can cause \\r appear in EOL\n    # sequences when we read the golden file irrespective of an operating\n    # system used. Therefore, we need to strip those \\r's from newlines\n    # unconditionally.\n    golden = ToUnixLineEnding(golden_file.read())\n    golden_file.close()\n\n    # We want the test to pass regardless of certain features being\n    # supported or not.\n\n    # We still have to remove type name specifics in all cases.\n    normalized_actual = RemoveTypeInfoDetails(output)\n    normalized_golden = RemoveTypeInfoDetails(golden)\n\n    if CAN_GENERATE_GOLDEN_FILE:\n      self.assertEqual(normalized_golden, normalized_actual,\n                       '\\n'.join(difflib.unified_diff(\n                           normalized_golden.split('\\n'),\n                           normalized_actual.split('\\n'),\n                           'golden', 'actual')))\n    else:\n      normalized_actual = NormalizeToCurrentPlatform(\n          RemoveTestCounts(normalized_actual))\n      normalized_golden = NormalizeToCurrentPlatform(\n          RemoveTestCounts(self.RemoveUnsupportedTests(normalized_golden)))\n\n      # This code is very handy when debugging golden file differences:\n      if os.getenv('DEBUG_GTEST_OUTPUT_TEST'):\n        open(os.path.join(\n            gtest_test_utils.GetSourceDir(),\n            '_gtest_output_test_normalized_actual.txt'), 'wb').write(\n                normalized_actual)\n        open(os.path.join(\n            gtest_test_utils.GetSourceDir(),\n            '_gtest_output_test_normalized_golden.txt'), 'wb').write(\n                normalized_golden)\n\n      self.assertEqual(normalized_golden, normalized_actual)\n\n\nif __name__ == '__main__':\n  if sys.argv[1:] == [GENGOLDEN_FLAG]:\n    if CAN_GENERATE_GOLDEN_FILE:\n      output = GetOutputOfAllCommands()\n      golden_file = open(GOLDEN_PATH, 'wb')\n      golden_file.write(output)\n      golden_file.close()\n    else:\n      message = (\n          \"\"\"Unable to write a golden file when compiled in an environment\nthat does not support all the required features (death tests, typed tests,\nand multiple threads).  Please generate the golden file using a binary built\nwith those features enabled.\"\"\")\n\n      sys.stderr.write(message)\n      sys.exit(1)\n  else:\n    gtest_test_utils.Main()\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_output_test_.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// The purpose of this file is to generate Google Test output under\n// various conditions.  The output will then be verified by\n// gtest_output_test.py to ensure that Google Test generates the\n// desired messages.  Therefore, most tests in this file are MEANT TO\n// FAIL.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/gtest-spi.h\"\n#include \"gtest/gtest.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\n#include <stdlib.h>\n\n#if GTEST_IS_THREADSAFE\nusing testing::ScopedFakeTestPartResultReporter;\nusing testing::TestPartResultArray;\n\nusing testing::internal::Notification;\nusing testing::internal::ThreadWithParam;\n#endif\n\nnamespace posix = ::testing::internal::posix;\n\n// Tests catching fatal failures.\n\n// A subroutine used by the following test.\nvoid TestEq1(int x) {\n  ASSERT_EQ(1, x);\n}\n\n// This function calls a test subroutine, catches the fatal failure it\n// generates, and then returns early.\nvoid TryTestSubroutine() {\n  // Calls a subrountine that yields a fatal failure.\n  TestEq1(2);\n\n  // Catches the fatal failure and aborts the test.\n  //\n  // The testing::Test:: prefix is necessary when calling\n  // HasFatalFailure() outside of a TEST, TEST_F, or test fixture.\n  if (testing::Test::HasFatalFailure()) return;\n\n  // If we get here, something is wrong.\n  FAIL() << \"This should never be reached.\";\n}\n\nTEST(PassingTest, PassingTest1) {\n}\n\nTEST(PassingTest, PassingTest2) {\n}\n\n// Tests that parameters of failing parameterized tests are printed in the\n// failing test summary.\nclass FailingParamTest : public testing::TestWithParam<int> {};\n\nTEST_P(FailingParamTest, Fails) {\n  EXPECT_EQ(1, GetParam());\n}\n\n// This generates a test which will fail. Google Test is expected to print\n// its parameter when it outputs the list of all failed tests.\nINSTANTIATE_TEST_CASE_P(PrintingFailingParams,\n                        FailingParamTest,\n                        testing::Values(2));\n\nstatic const char kGoldenString[] = \"\\\"Line\\0 1\\\"\\nLine 2\";\n\nTEST(NonfatalFailureTest, EscapesStringOperands) {\n  std::string actual = \"actual \\\"string\\\"\";\n  EXPECT_EQ(kGoldenString, actual);\n\n  const char* golden = kGoldenString;\n  EXPECT_EQ(golden, actual);\n}\n\nTEST(NonfatalFailureTest, DiffForLongStrings) {\n  std::string golden_str(kGoldenString, sizeof(kGoldenString) - 1);\n  EXPECT_EQ(golden_str, \"Line 2\");\n}\n\n// Tests catching a fatal failure in a subroutine.\nTEST(FatalFailureTest, FatalFailureInSubroutine) {\n  printf(\"(expecting a failure that x should be 1)\\n\");\n\n  TryTestSubroutine();\n}\n\n// Tests catching a fatal failure in a nested subroutine.\nTEST(FatalFailureTest, FatalFailureInNestedSubroutine) {\n  printf(\"(expecting a failure that x should be 1)\\n\");\n\n  // Calls a subrountine that yields a fatal failure.\n  TryTestSubroutine();\n\n  // Catches the fatal failure and aborts the test.\n  //\n  // When calling HasFatalFailure() inside a TEST, TEST_F, or test\n  // fixture, the testing::Test:: prefix is not needed.\n  if (HasFatalFailure()) return;\n\n  // If we get here, something is wrong.\n  FAIL() << \"This should never be reached.\";\n}\n\n// Tests HasFatalFailure() after a failed EXPECT check.\nTEST(FatalFailureTest, NonfatalFailureInSubroutine) {\n  printf(\"(expecting a failure on false)\\n\");\n  EXPECT_TRUE(false);  // Generates a nonfatal failure\n  ASSERT_FALSE(HasFatalFailure());  // This should succeed.\n}\n\n// Tests interleaving user logging and Google Test assertions.\nTEST(LoggingTest, InterleavingLoggingAndAssertions) {\n  static const int a[4] = {\n    3, 9, 2, 6\n  };\n\n  printf(\"(expecting 2 failures on (3) >= (a[i]))\\n\");\n  for (int i = 0; i < static_cast<int>(sizeof(a)/sizeof(*a)); i++) {\n    printf(\"i == %d\\n\", i);\n    EXPECT_GE(3, a[i]);\n  }\n}\n\n// Tests the SCOPED_TRACE macro.\n\n// A helper function for testing SCOPED_TRACE.\nvoid SubWithoutTrace(int n) {\n  EXPECT_EQ(1, n);\n  ASSERT_EQ(2, n);\n}\n\n// Another helper function for testing SCOPED_TRACE.\nvoid SubWithTrace(int n) {\n  SCOPED_TRACE(testing::Message() << \"n = \" << n);\n\n  SubWithoutTrace(n);\n}\n\n// Tests that SCOPED_TRACE() obeys lexical scopes.\nTEST(SCOPED_TRACETest, ObeysScopes) {\n  printf(\"(expected to fail)\\n\");\n\n  // There should be no trace before SCOPED_TRACE() is invoked.\n  ADD_FAILURE() << \"This failure is expected, and shouldn't have a trace.\";\n\n  {\n    SCOPED_TRACE(\"Expected trace\");\n    // After SCOPED_TRACE(), a failure in the current scope should contain\n    // the trace.\n    ADD_FAILURE() << \"This failure is expected, and should have a trace.\";\n  }\n\n  // Once the control leaves the scope of the SCOPED_TRACE(), there\n  // should be no trace again.\n  ADD_FAILURE() << \"This failure is expected, and shouldn't have a trace.\";\n}\n\n// Tests that SCOPED_TRACE works inside a loop.\nTEST(SCOPED_TRACETest, WorksInLoop) {\n  printf(\"(expected to fail)\\n\");\n\n  for (int i = 1; i <= 2; i++) {\n    SCOPED_TRACE(testing::Message() << \"i = \" << i);\n\n    SubWithoutTrace(i);\n  }\n}\n\n// Tests that SCOPED_TRACE works in a subroutine.\nTEST(SCOPED_TRACETest, WorksInSubroutine) {\n  printf(\"(expected to fail)\\n\");\n\n  SubWithTrace(1);\n  SubWithTrace(2);\n}\n\n// Tests that SCOPED_TRACE can be nested.\nTEST(SCOPED_TRACETest, CanBeNested) {\n  printf(\"(expected to fail)\\n\");\n\n  SCOPED_TRACE(\"\");  // A trace without a message.\n\n  SubWithTrace(2);\n}\n\n// Tests that multiple SCOPED_TRACEs can be used in the same scope.\nTEST(SCOPED_TRACETest, CanBeRepeated) {\n  printf(\"(expected to fail)\\n\");\n\n  SCOPED_TRACE(\"A\");\n  ADD_FAILURE()\n      << \"This failure is expected, and should contain trace point A.\";\n\n  SCOPED_TRACE(\"B\");\n  ADD_FAILURE()\n      << \"This failure is expected, and should contain trace point A and B.\";\n\n  {\n    SCOPED_TRACE(\"C\");\n    ADD_FAILURE() << \"This failure is expected, and should \"\n                  << \"contain trace point A, B, and C.\";\n  }\n\n  SCOPED_TRACE(\"D\");\n  ADD_FAILURE() << \"This failure is expected, and should \"\n                << \"contain trace point A, B, and D.\";\n}\n\n#if GTEST_IS_THREADSAFE\n// Tests that SCOPED_TRACE()s can be used concurrently from multiple\n// threads.  Namely, an assertion should be affected by\n// SCOPED_TRACE()s in its own thread only.\n\n// Here's the sequence of actions that happen in the test:\n//\n//   Thread A (main)                | Thread B (spawned)\n//   ===============================|================================\n//   spawns thread B                |\n//   -------------------------------+--------------------------------\n//   waits for n1                   | SCOPED_TRACE(\"Trace B\");\n//                                  | generates failure #1\n//                                  | notifies n1\n//   -------------------------------+--------------------------------\n//   SCOPED_TRACE(\"Trace A\");       | waits for n2\n//   generates failure #2           |\n//   notifies n2                    |\n//   -------------------------------|--------------------------------\n//   waits for n3                   | generates failure #3\n//                                  | trace B dies\n//                                  | generates failure #4\n//                                  | notifies n3\n//   -------------------------------|--------------------------------\n//   generates failure #5           | finishes\n//   trace A dies                   |\n//   generates failure #6           |\n//   -------------------------------|--------------------------------\n//   waits for thread B to finish   |\n\nstruct CheckPoints {\n  Notification n1;\n  Notification n2;\n  Notification n3;\n};\n\nstatic void ThreadWithScopedTrace(CheckPoints* check_points) {\n  {\n    SCOPED_TRACE(\"Trace B\");\n    ADD_FAILURE()\n        << \"Expected failure #1 (in thread B, only trace B alive).\";\n    check_points->n1.Notify();\n    check_points->n2.WaitForNotification();\n\n    ADD_FAILURE()\n        << \"Expected failure #3 (in thread B, trace A & B both alive).\";\n  }  // Trace B dies here.\n  ADD_FAILURE()\n      << \"Expected failure #4 (in thread B, only trace A alive).\";\n  check_points->n3.Notify();\n}\n\nTEST(SCOPED_TRACETest, WorksConcurrently) {\n  printf(\"(expecting 6 failures)\\n\");\n\n  CheckPoints check_points;\n  ThreadWithParam<CheckPoints*> thread(&ThreadWithScopedTrace,\n                                       &check_points,\n                                       NULL);\n  check_points.n1.WaitForNotification();\n\n  {\n    SCOPED_TRACE(\"Trace A\");\n    ADD_FAILURE()\n        << \"Expected failure #2 (in thread A, trace A & B both alive).\";\n    check_points.n2.Notify();\n    check_points.n3.WaitForNotification();\n\n    ADD_FAILURE()\n        << \"Expected failure #5 (in thread A, only trace A alive).\";\n  }  // Trace A dies here.\n  ADD_FAILURE()\n      << \"Expected failure #6 (in thread A, no trace alive).\";\n  thread.Join();\n}\n#endif  // GTEST_IS_THREADSAFE\n\nTEST(DisabledTestsWarningTest,\n     DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning) {\n  // This test body is intentionally empty.  Its sole purpose is for\n  // verifying that the --gtest_also_run_disabled_tests flag\n  // suppresses the \"YOU HAVE 12 DISABLED TESTS\" warning at the end of\n  // the test output.\n}\n\n// Tests using assertions outside of TEST and TEST_F.\n//\n// This function creates two failures intentionally.\nvoid AdHocTest() {\n  printf(\"The non-test part of the code is expected to have 2 failures.\\n\\n\");\n  EXPECT_TRUE(false);\n  EXPECT_EQ(2, 3);\n}\n\n// Runs all TESTs, all TEST_Fs, and the ad hoc test.\nint RunAllTests() {\n  AdHocTest();\n  return RUN_ALL_TESTS();\n}\n\n// Tests non-fatal failures in the fixture constructor.\nclass NonFatalFailureInFixtureConstructorTest : public testing::Test {\n protected:\n  NonFatalFailureInFixtureConstructorTest() {\n    printf(\"(expecting 5 failures)\\n\");\n    ADD_FAILURE() << \"Expected failure #1, in the test fixture c'tor.\";\n  }\n\n  ~NonFatalFailureInFixtureConstructorTest() {\n    ADD_FAILURE() << \"Expected failure #5, in the test fixture d'tor.\";\n  }\n\n  virtual void SetUp() {\n    ADD_FAILURE() << \"Expected failure #2, in SetUp().\";\n  }\n\n  virtual void TearDown() {\n    ADD_FAILURE() << \"Expected failure #4, in TearDown.\";\n  }\n};\n\nTEST_F(NonFatalFailureInFixtureConstructorTest, FailureInConstructor) {\n  ADD_FAILURE() << \"Expected failure #3, in the test body.\";\n}\n\n// Tests fatal failures in the fixture constructor.\nclass FatalFailureInFixtureConstructorTest : public testing::Test {\n protected:\n  FatalFailureInFixtureConstructorTest() {\n    printf(\"(expecting 2 failures)\\n\");\n    Init();\n  }\n\n  ~FatalFailureInFixtureConstructorTest() {\n    ADD_FAILURE() << \"Expected failure #2, in the test fixture d'tor.\";\n  }\n\n  virtual void SetUp() {\n    ADD_FAILURE() << \"UNEXPECTED failure in SetUp().  \"\n                  << \"We should never get here, as the test fixture c'tor \"\n                  << \"had a fatal failure.\";\n  }\n\n  virtual void TearDown() {\n    ADD_FAILURE() << \"UNEXPECTED failure in TearDown().  \"\n                  << \"We should never get here, as the test fixture c'tor \"\n                  << \"had a fatal failure.\";\n  }\n\n private:\n  void Init() {\n    FAIL() << \"Expected failure #1, in the test fixture c'tor.\";\n  }\n};\n\nTEST_F(FatalFailureInFixtureConstructorTest, FailureInConstructor) {\n  ADD_FAILURE() << \"UNEXPECTED failure in the test body.  \"\n                << \"We should never get here, as the test fixture c'tor \"\n                << \"had a fatal failure.\";\n}\n\n// Tests non-fatal failures in SetUp().\nclass NonFatalFailureInSetUpTest : public testing::Test {\n protected:\n  virtual ~NonFatalFailureInSetUpTest() {\n    Deinit();\n  }\n\n  virtual void SetUp() {\n    printf(\"(expecting 4 failures)\\n\");\n    ADD_FAILURE() << \"Expected failure #1, in SetUp().\";\n  }\n\n  virtual void TearDown() {\n    FAIL() << \"Expected failure #3, in TearDown().\";\n  }\n private:\n  void Deinit() {\n    FAIL() << \"Expected failure #4, in the test fixture d'tor.\";\n  }\n};\n\nTEST_F(NonFatalFailureInSetUpTest, FailureInSetUp) {\n  FAIL() << \"Expected failure #2, in the test function.\";\n}\n\n// Tests fatal failures in SetUp().\nclass FatalFailureInSetUpTest : public testing::Test {\n protected:\n  virtual ~FatalFailureInSetUpTest() {\n    Deinit();\n  }\n\n  virtual void SetUp() {\n    printf(\"(expecting 3 failures)\\n\");\n    FAIL() << \"Expected failure #1, in SetUp().\";\n  }\n\n  virtual void TearDown() {\n    FAIL() << \"Expected failure #2, in TearDown().\";\n  }\n private:\n  void Deinit() {\n    FAIL() << \"Expected failure #3, in the test fixture d'tor.\";\n  }\n};\n\nTEST_F(FatalFailureInSetUpTest, FailureInSetUp) {\n  FAIL() << \"UNEXPECTED failure in the test function.  \"\n         << \"We should never get here, as SetUp() failed.\";\n}\n\nTEST(AddFailureAtTest, MessageContainsSpecifiedFileAndLineNumber) {\n  ADD_FAILURE_AT(\"foo.cc\", 42) << \"Expected failure in foo.cc\";\n}\n\n#if GTEST_IS_THREADSAFE\n\n// A unary function that may die.\nvoid DieIf(bool should_die) {\n  GTEST_CHECK_(!should_die) << \" - death inside DieIf().\";\n}\n\n// Tests running death tests in a multi-threaded context.\n\n// Used for coordination between the main and the spawn thread.\nstruct SpawnThreadNotifications {\n  SpawnThreadNotifications() {}\n\n  Notification spawn_thread_started;\n  Notification spawn_thread_ok_to_terminate;\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(SpawnThreadNotifications);\n};\n\n// The function to be executed in the thread spawn by the\n// MultipleThreads test (below).\nstatic void ThreadRoutine(SpawnThreadNotifications* notifications) {\n  // Signals the main thread that this thread has started.\n  notifications->spawn_thread_started.Notify();\n\n  // Waits for permission to finish from the main thread.\n  notifications->spawn_thread_ok_to_terminate.WaitForNotification();\n}\n\n// This is a death-test test, but it's not named with a DeathTest\n// suffix.  It starts threads which might interfere with later\n// death tests, so it must run after all other death tests.\nclass DeathTestAndMultiThreadsTest : public testing::Test {\n protected:\n  // Starts a thread and waits for it to begin.\n  virtual void SetUp() {\n    thread_.reset(new ThreadWithParam<SpawnThreadNotifications*>(\n        &ThreadRoutine, &notifications_, NULL));\n    notifications_.spawn_thread_started.WaitForNotification();\n  }\n  // Tells the thread to finish, and reaps it.\n  // Depending on the version of the thread library in use,\n  // a manager thread might still be left running that will interfere\n  // with later death tests.  This is unfortunate, but this class\n  // cleans up after itself as best it can.\n  virtual void TearDown() {\n    notifications_.spawn_thread_ok_to_terminate.Notify();\n  }\n\n private:\n  SpawnThreadNotifications notifications_;\n  testing::internal::scoped_ptr<ThreadWithParam<SpawnThreadNotifications*> >\n      thread_;\n};\n\n#endif  // GTEST_IS_THREADSAFE\n\n// The MixedUpTestCaseTest test case verifies that Google Test will fail a\n// test if it uses a different fixture class than what other tests in\n// the same test case use.  It deliberately contains two fixture\n// classes with the same name but defined in different namespaces.\n\n// The MixedUpTestCaseWithSameTestNameTest test case verifies that\n// when the user defines two tests with the same test case name AND\n// same test name (but in different namespaces), the second test will\n// fail.\n\nnamespace foo {\n\nclass MixedUpTestCaseTest : public testing::Test {\n};\n\nTEST_F(MixedUpTestCaseTest, FirstTestFromNamespaceFoo) {}\nTEST_F(MixedUpTestCaseTest, SecondTestFromNamespaceFoo) {}\n\nclass MixedUpTestCaseWithSameTestNameTest : public testing::Test {\n};\n\nTEST_F(MixedUpTestCaseWithSameTestNameTest,\n       TheSecondTestWithThisNameShouldFail) {}\n\n}  // namespace foo\n\nnamespace bar {\n\nclass MixedUpTestCaseTest : public testing::Test {\n};\n\n// The following two tests are expected to fail.  We rely on the\n// golden file to check that Google Test generates the right error message.\nTEST_F(MixedUpTestCaseTest, ThisShouldFail) {}\nTEST_F(MixedUpTestCaseTest, ThisShouldFailToo) {}\n\nclass MixedUpTestCaseWithSameTestNameTest : public testing::Test {\n};\n\n// Expected to fail.  We rely on the golden file to check that Google Test\n// generates the right error message.\nTEST_F(MixedUpTestCaseWithSameTestNameTest,\n       TheSecondTestWithThisNameShouldFail) {}\n\n}  // namespace bar\n\n// The following two test cases verify that Google Test catches the user\n// error of mixing TEST and TEST_F in the same test case.  The first\n// test case checks the scenario where TEST_F appears before TEST, and\n// the second one checks where TEST appears before TEST_F.\n\nclass TEST_F_before_TEST_in_same_test_case : public testing::Test {\n};\n\nTEST_F(TEST_F_before_TEST_in_same_test_case, DefinedUsingTEST_F) {}\n\n// Expected to fail.  We rely on the golden file to check that Google Test\n// generates the right error message.\nTEST(TEST_F_before_TEST_in_same_test_case, DefinedUsingTESTAndShouldFail) {}\n\nclass TEST_before_TEST_F_in_same_test_case : public testing::Test {\n};\n\nTEST(TEST_before_TEST_F_in_same_test_case, DefinedUsingTEST) {}\n\n// Expected to fail.  We rely on the golden file to check that Google Test\n// generates the right error message.\nTEST_F(TEST_before_TEST_F_in_same_test_case, DefinedUsingTEST_FAndShouldFail) {\n}\n\n// Used for testing EXPECT_NONFATAL_FAILURE() and EXPECT_FATAL_FAILURE().\nint global_integer = 0;\n\n// Tests that EXPECT_NONFATAL_FAILURE() can reference global variables.\nTEST(ExpectNonfatalFailureTest, CanReferenceGlobalVariables) {\n  global_integer = 0;\n  EXPECT_NONFATAL_FAILURE({\n    EXPECT_EQ(1, global_integer) << \"Expected non-fatal failure.\";\n  }, \"Expected non-fatal failure.\");\n}\n\n// Tests that EXPECT_NONFATAL_FAILURE() can reference local variables\n// (static or not).\nTEST(ExpectNonfatalFailureTest, CanReferenceLocalVariables) {\n  int m = 0;\n  static int n;\n  n = 1;\n  EXPECT_NONFATAL_FAILURE({\n    EXPECT_EQ(m, n) << \"Expected non-fatal failure.\";\n  }, \"Expected non-fatal failure.\");\n}\n\n// Tests that EXPECT_NONFATAL_FAILURE() succeeds when there is exactly\n// one non-fatal failure and no fatal failure.\nTEST(ExpectNonfatalFailureTest, SucceedsWhenThereIsOneNonfatalFailure) {\n  EXPECT_NONFATAL_FAILURE({\n    ADD_FAILURE() << \"Expected non-fatal failure.\";\n  }, \"Expected non-fatal failure.\");\n}\n\n// Tests that EXPECT_NONFATAL_FAILURE() fails when there is no\n// non-fatal failure.\nTEST(ExpectNonfatalFailureTest, FailsWhenThereIsNoNonfatalFailure) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_NONFATAL_FAILURE({\n  }, \"\");\n}\n\n// Tests that EXPECT_NONFATAL_FAILURE() fails when there are two\n// non-fatal failures.\nTEST(ExpectNonfatalFailureTest, FailsWhenThereAreTwoNonfatalFailures) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_NONFATAL_FAILURE({\n    ADD_FAILURE() << \"Expected non-fatal failure 1.\";\n    ADD_FAILURE() << \"Expected non-fatal failure 2.\";\n  }, \"\");\n}\n\n// Tests that EXPECT_NONFATAL_FAILURE() fails when there is one fatal\n// failure.\nTEST(ExpectNonfatalFailureTest, FailsWhenThereIsOneFatalFailure) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_NONFATAL_FAILURE({\n    FAIL() << \"Expected fatal failure.\";\n  }, \"\");\n}\n\n// Tests that EXPECT_NONFATAL_FAILURE() fails when the statement being\n// tested returns.\nTEST(ExpectNonfatalFailureTest, FailsWhenStatementReturns) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_NONFATAL_FAILURE({\n    return;\n  }, \"\");\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\n// Tests that EXPECT_NONFATAL_FAILURE() fails when the statement being\n// tested throws.\nTEST(ExpectNonfatalFailureTest, FailsWhenStatementThrows) {\n  printf(\"(expecting a failure)\\n\");\n  try {\n    EXPECT_NONFATAL_FAILURE({\n      throw 0;\n    }, \"\");\n  } catch(int) {  // NOLINT\n  }\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// Tests that EXPECT_FATAL_FAILURE() can reference global variables.\nTEST(ExpectFatalFailureTest, CanReferenceGlobalVariables) {\n  global_integer = 0;\n  EXPECT_FATAL_FAILURE({\n    ASSERT_EQ(1, global_integer) << \"Expected fatal failure.\";\n  }, \"Expected fatal failure.\");\n}\n\n// Tests that EXPECT_FATAL_FAILURE() can reference local static\n// variables.\nTEST(ExpectFatalFailureTest, CanReferenceLocalStaticVariables) {\n  static int n;\n  n = 1;\n  EXPECT_FATAL_FAILURE({\n    ASSERT_EQ(0, n) << \"Expected fatal failure.\";\n  }, \"Expected fatal failure.\");\n}\n\n// Tests that EXPECT_FATAL_FAILURE() succeeds when there is exactly\n// one fatal failure and no non-fatal failure.\nTEST(ExpectFatalFailureTest, SucceedsWhenThereIsOneFatalFailure) {\n  EXPECT_FATAL_FAILURE({\n    FAIL() << \"Expected fatal failure.\";\n  }, \"Expected fatal failure.\");\n}\n\n// Tests that EXPECT_FATAL_FAILURE() fails when there is no fatal\n// failure.\nTEST(ExpectFatalFailureTest, FailsWhenThereIsNoFatalFailure) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_FATAL_FAILURE({\n  }, \"\");\n}\n\n// A helper for generating a fatal failure.\nvoid FatalFailure() {\n  FAIL() << \"Expected fatal failure.\";\n}\n\n// Tests that EXPECT_FATAL_FAILURE() fails when there are two\n// fatal failures.\nTEST(ExpectFatalFailureTest, FailsWhenThereAreTwoFatalFailures) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_FATAL_FAILURE({\n    FatalFailure();\n    FatalFailure();\n  }, \"\");\n}\n\n// Tests that EXPECT_FATAL_FAILURE() fails when there is one non-fatal\n// failure.\nTEST(ExpectFatalFailureTest, FailsWhenThereIsOneNonfatalFailure) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_FATAL_FAILURE({\n    ADD_FAILURE() << \"Expected non-fatal failure.\";\n  }, \"\");\n}\n\n// Tests that EXPECT_FATAL_FAILURE() fails when the statement being\n// tested returns.\nTEST(ExpectFatalFailureTest, FailsWhenStatementReturns) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_FATAL_FAILURE({\n    return;\n  }, \"\");\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\n// Tests that EXPECT_FATAL_FAILURE() fails when the statement being\n// tested throws.\nTEST(ExpectFatalFailureTest, FailsWhenStatementThrows) {\n  printf(\"(expecting a failure)\\n\");\n  try {\n    EXPECT_FATAL_FAILURE({\n      throw 0;\n    }, \"\");\n  } catch(int) {  // NOLINT\n  }\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// This #ifdef block tests the output of value-parameterized tests.\n\n#if GTEST_HAS_PARAM_TEST\n\nstd::string ParamNameFunc(const testing::TestParamInfo<std::string>& info) {\n  return info.param;\n}\n\nclass ParamTest : public testing::TestWithParam<std::string> {\n};\n\nTEST_P(ParamTest, Success) {\n  EXPECT_EQ(\"a\", GetParam());\n}\n\nTEST_P(ParamTest, Failure) {\n  EXPECT_EQ(\"b\", GetParam()) << \"Expected failure\";\n}\n\nINSTANTIATE_TEST_CASE_P(PrintingStrings,\n                        ParamTest,\n                        testing::Values(std::string(\"a\")),\n                        ParamNameFunc);\n\n#endif  // GTEST_HAS_PARAM_TEST\n\n// This #ifdef block tests the output of typed tests.\n#if GTEST_HAS_TYPED_TEST\n\ntemplate <typename T>\nclass TypedTest : public testing::Test {\n};\n\nTYPED_TEST_CASE(TypedTest, testing::Types<int>);\n\nTYPED_TEST(TypedTest, Success) {\n  EXPECT_EQ(0, TypeParam());\n}\n\nTYPED_TEST(TypedTest, Failure) {\n  EXPECT_EQ(1, TypeParam()) << \"Expected failure\";\n}\n\n#endif  // GTEST_HAS_TYPED_TEST\n\n// This #ifdef block tests the output of type-parameterized tests.\n#if GTEST_HAS_TYPED_TEST_P\n\ntemplate <typename T>\nclass TypedTestP : public testing::Test {\n};\n\nTYPED_TEST_CASE_P(TypedTestP);\n\nTYPED_TEST_P(TypedTestP, Success) {\n  EXPECT_EQ(0U, TypeParam());\n}\n\nTYPED_TEST_P(TypedTestP, Failure) {\n  EXPECT_EQ(1U, TypeParam()) << \"Expected failure\";\n}\n\nREGISTER_TYPED_TEST_CASE_P(TypedTestP, Success, Failure);\n\ntypedef testing::Types<unsigned char, unsigned int> UnsignedTypes;\nINSTANTIATE_TYPED_TEST_CASE_P(Unsigned, TypedTestP, UnsignedTypes);\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n\n#if GTEST_HAS_DEATH_TEST\n\n// We rely on the golden file to verify that tests whose test case\n// name ends with DeathTest are run first.\n\nTEST(ADeathTest, ShouldRunFirst) {\n}\n\n# if GTEST_HAS_TYPED_TEST\n\n// We rely on the golden file to verify that typed tests whose test\n// case name ends with DeathTest are run first.\n\ntemplate <typename T>\nclass ATypedDeathTest : public testing::Test {\n};\n\ntypedef testing::Types<int, double> NumericTypes;\nTYPED_TEST_CASE(ATypedDeathTest, NumericTypes);\n\nTYPED_TEST(ATypedDeathTest, ShouldRunFirst) {\n}\n\n# endif  // GTEST_HAS_TYPED_TEST\n\n# if GTEST_HAS_TYPED_TEST_P\n\n\n// We rely on the golden file to verify that type-parameterized tests\n// whose test case name ends with DeathTest are run first.\n\ntemplate <typename T>\nclass ATypeParamDeathTest : public testing::Test {\n};\n\nTYPED_TEST_CASE_P(ATypeParamDeathTest);\n\nTYPED_TEST_P(ATypeParamDeathTest, ShouldRunFirst) {\n}\n\nREGISTER_TYPED_TEST_CASE_P(ATypeParamDeathTest, ShouldRunFirst);\n\nINSTANTIATE_TYPED_TEST_CASE_P(My, ATypeParamDeathTest, NumericTypes);\n\n# endif  // GTEST_HAS_TYPED_TEST_P\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n// Tests various failure conditions of\n// EXPECT_{,NON}FATAL_FAILURE{,_ON_ALL_THREADS}.\nclass ExpectFailureTest : public testing::Test {\n public:  // Must be public and not protected due to a bug in g++ 3.4.2.\n  enum FailureMode {\n    FATAL_FAILURE,\n    NONFATAL_FAILURE\n  };\n  static void AddFailure(FailureMode failure) {\n    if (failure == FATAL_FAILURE) {\n      FAIL() << \"Expected fatal failure.\";\n    } else {\n      ADD_FAILURE() << \"Expected non-fatal failure.\";\n    }\n  }\n};\n\nTEST_F(ExpectFailureTest, ExpectFatalFailure) {\n  // Expected fatal failure, but succeeds.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_FATAL_FAILURE(SUCCEED(), \"Expected fatal failure.\");\n  // Expected fatal failure, but got a non-fatal failure.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_FATAL_FAILURE(AddFailure(NONFATAL_FAILURE), \"Expected non-fatal \"\n                       \"failure.\");\n  // Wrong message.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_FATAL_FAILURE(AddFailure(FATAL_FAILURE), \"Some other fatal failure \"\n                       \"expected.\");\n}\n\nTEST_F(ExpectFailureTest, ExpectNonFatalFailure) {\n  // Expected non-fatal failure, but succeeds.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_NONFATAL_FAILURE(SUCCEED(), \"Expected non-fatal failure.\");\n  // Expected non-fatal failure, but got a fatal failure.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_NONFATAL_FAILURE(AddFailure(FATAL_FAILURE), \"Expected fatal failure.\");\n  // Wrong message.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_NONFATAL_FAILURE(AddFailure(NONFATAL_FAILURE), \"Some other non-fatal \"\n                          \"failure.\");\n}\n\n#if GTEST_IS_THREADSAFE\n\nclass ExpectFailureWithThreadsTest : public ExpectFailureTest {\n protected:\n  static void AddFailureInOtherThread(FailureMode failure) {\n    ThreadWithParam<FailureMode> thread(&AddFailure, failure, NULL);\n    thread.Join();\n  }\n};\n\nTEST_F(ExpectFailureWithThreadsTest, ExpectFatalFailure) {\n  // We only intercept the current thread.\n  printf(\"(expecting 2 failures)\\n\");\n  EXPECT_FATAL_FAILURE(AddFailureInOtherThread(FATAL_FAILURE),\n                       \"Expected fatal failure.\");\n}\n\nTEST_F(ExpectFailureWithThreadsTest, ExpectNonFatalFailure) {\n  // We only intercept the current thread.\n  printf(\"(expecting 2 failures)\\n\");\n  EXPECT_NONFATAL_FAILURE(AddFailureInOtherThread(NONFATAL_FAILURE),\n                          \"Expected non-fatal failure.\");\n}\n\ntypedef ExpectFailureWithThreadsTest ScopedFakeTestPartResultReporterTest;\n\n// Tests that the ScopedFakeTestPartResultReporter only catches failures from\n// the current thread if it is instantiated with INTERCEPT_ONLY_CURRENT_THREAD.\nTEST_F(ScopedFakeTestPartResultReporterTest, InterceptOnlyCurrentThread) {\n  printf(\"(expecting 2 failures)\\n\");\n  TestPartResultArray results;\n  {\n    ScopedFakeTestPartResultReporter reporter(\n        ScopedFakeTestPartResultReporter::INTERCEPT_ONLY_CURRENT_THREAD,\n        &results);\n    AddFailureInOtherThread(FATAL_FAILURE);\n    AddFailureInOtherThread(NONFATAL_FAILURE);\n  }\n  // The two failures should not have been intercepted.\n  EXPECT_EQ(0, results.size()) << \"This shouldn't fail.\";\n}\n\n#endif  // GTEST_IS_THREADSAFE\n\nTEST_F(ExpectFailureTest, ExpectFatalFailureOnAllThreads) {\n  // Expected fatal failure, but succeeds.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(SUCCEED(), \"Expected fatal failure.\");\n  // Expected fatal failure, but got a non-fatal failure.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(AddFailure(NONFATAL_FAILURE),\n                                      \"Expected non-fatal failure.\");\n  // Wrong message.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(AddFailure(FATAL_FAILURE),\n                                      \"Some other fatal failure expected.\");\n}\n\nTEST_F(ExpectFailureTest, ExpectNonFatalFailureOnAllThreads) {\n  // Expected non-fatal failure, but succeeds.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(SUCCEED(), \"Expected non-fatal \"\n                                         \"failure.\");\n  // Expected non-fatal failure, but got a fatal failure.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(AddFailure(FATAL_FAILURE),\n                                         \"Expected fatal failure.\");\n  // Wrong message.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(AddFailure(NONFATAL_FAILURE),\n                                         \"Some other non-fatal failure.\");\n}\n\n\n// Two test environments for testing testing::AddGlobalTestEnvironment().\n\nclass FooEnvironment : public testing::Environment {\n public:\n  virtual void SetUp() {\n    printf(\"%s\", \"FooEnvironment::SetUp() called.\\n\");\n  }\n\n  virtual void TearDown() {\n    printf(\"%s\", \"FooEnvironment::TearDown() called.\\n\");\n    FAIL() << \"Expected fatal failure.\";\n  }\n};\n\nclass BarEnvironment : public testing::Environment {\n public:\n  virtual void SetUp() {\n    printf(\"%s\", \"BarEnvironment::SetUp() called.\\n\");\n  }\n\n  virtual void TearDown() {\n    printf(\"%s\", \"BarEnvironment::TearDown() called.\\n\");\n    ADD_FAILURE() << \"Expected non-fatal failure.\";\n  }\n};\n\n// The main function.\n//\n// The idea is to use Google Test to run all the tests we have defined (some\n// of them are intended to fail), and then compare the test results\n// with the \"golden\" file.\nint main(int argc, char **argv) {\n  testing::GTEST_FLAG(print_time) = false;\n\n  // We just run the tests, knowing some of them are intended to fail.\n  // We will use a separate Python script to compare the output of\n  // this program with the golden file.\n\n  // It's hard to test InitGoogleTest() directly, as it has many\n  // global side effects.  The following line serves as a sanity test\n  // for it.\n  testing::InitGoogleTest(&argc, argv);\n  bool internal_skip_environment_and_ad_hoc_tests =\n      std::count(argv, argv + argc,\n                 std::string(\"internal_skip_environment_and_ad_hoc_tests\")) > 0;\n\n#if GTEST_HAS_DEATH_TEST\n  if (testing::internal::GTEST_FLAG(internal_run_death_test) != \"\") {\n    // Skip the usual output capturing if we're running as the child\n    // process of an threadsafe-style death test.\n# if GTEST_OS_WINDOWS\n    posix::FReopen(\"nul:\", \"w\", stdout);\n# else\n    posix::FReopen(\"/dev/null\", \"w\", stdout);\n# endif  // GTEST_OS_WINDOWS\n    return RUN_ALL_TESTS();\n  }\n#endif  // GTEST_HAS_DEATH_TEST\n\n  if (internal_skip_environment_and_ad_hoc_tests)\n    return RUN_ALL_TESTS();\n\n  // Registers two global test environments.\n  // The golden file verifies that they are set up in the order they\n  // are registered, and torn down in the reverse order.\n  testing::AddGlobalTestEnvironment(new FooEnvironment);\n  testing::AddGlobalTestEnvironment(new BarEnvironment);\n\n  return RunAllTests();\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_output_test_golden_lin.txt",
    "content": "The non-test part of the code is expected to have 2 failures.\n\ngtest_output_test_.cc:#: Failure\nValue of: false\n  Actual: false\nExpected: true\ngtest_output_test_.cc:#: Failure\n      Expected: 2\nTo be equal to: 3\n\u001b[0;32m[==========] \u001b[mRunning 66 tests from 29 test cases.\n\u001b[0;32m[----------] \u001b[mGlobal test environment set-up.\nFooEnvironment::SetUp() called.\nBarEnvironment::SetUp() called.\n\u001b[0;32m[----------] \u001b[m1 test from ADeathTest\n\u001b[0;32m[ RUN      ] \u001b[mADeathTest.ShouldRunFirst\n\u001b[0;32m[       OK ] \u001b[mADeathTest.ShouldRunFirst\n\u001b[0;32m[----------] \u001b[m1 test from ATypedDeathTest/0, where TypeParam = int\n\u001b[0;32m[ RUN      ] \u001b[mATypedDeathTest/0.ShouldRunFirst\n\u001b[0;32m[       OK ] \u001b[mATypedDeathTest/0.ShouldRunFirst\n\u001b[0;32m[----------] \u001b[m1 test from ATypedDeathTest/1, where TypeParam = double\n\u001b[0;32m[ RUN      ] \u001b[mATypedDeathTest/1.ShouldRunFirst\n\u001b[0;32m[       OK ] \u001b[mATypedDeathTest/1.ShouldRunFirst\n\u001b[0;32m[----------] \u001b[m1 test from My/ATypeParamDeathTest/0, where TypeParam = int\n\u001b[0;32m[ RUN      ] \u001b[mMy/ATypeParamDeathTest/0.ShouldRunFirst\n\u001b[0;32m[       OK ] \u001b[mMy/ATypeParamDeathTest/0.ShouldRunFirst\n\u001b[0;32m[----------] \u001b[m1 test from My/ATypeParamDeathTest/1, where TypeParam = double\n\u001b[0;32m[ RUN      ] \u001b[mMy/ATypeParamDeathTest/1.ShouldRunFirst\n\u001b[0;32m[       OK ] \u001b[mMy/ATypeParamDeathTest/1.ShouldRunFirst\n\u001b[0;32m[----------] \u001b[m2 tests from PassingTest\n\u001b[0;32m[ RUN      ] \u001b[mPassingTest.PassingTest1\n\u001b[0;32m[       OK ] \u001b[mPassingTest.PassingTest1\n\u001b[0;32m[ RUN      ] \u001b[mPassingTest.PassingTest2\n\u001b[0;32m[       OK ] \u001b[mPassingTest.PassingTest2\n\u001b[0;32m[----------] \u001b[m2 tests from NonfatalFailureTest\n\u001b[0;32m[ RUN      ] \u001b[mNonfatalFailureTest.EscapesStringOperands\ngtest_output_test_.cc:#: Failure\n      Expected: kGoldenString\n      Which is: \"\\\"Line\"\nTo be equal to: actual\n      Which is: \"actual \\\"string\\\"\"\ngtest_output_test_.cc:#: Failure\n      Expected: golden\n      Which is: \"\\\"Line\"\nTo be equal to: actual\n      Which is: \"actual \\\"string\\\"\"\n\u001b[0;31m[  FAILED  ] \u001b[mNonfatalFailureTest.EscapesStringOperands\n\u001b[0;32m[ RUN      ] \u001b[mNonfatalFailureTest.DiffForLongStrings\ngtest_output_test_.cc:#: Failure\n      Expected: golden_str\n      Which is: \"\\\"Line\\0 1\\\"\\nLine 2\"\nTo be equal to: \"Line 2\"\nWith diff:\n@@ -1,2 @@\n-\\\"Line\\0 1\\\"\n Line 2\n\n\u001b[0;31m[  FAILED  ] \u001b[mNonfatalFailureTest.DiffForLongStrings\n\u001b[0;32m[----------] \u001b[m3 tests from FatalFailureTest\n\u001b[0;32m[ RUN      ] \u001b[mFatalFailureTest.FatalFailureInSubroutine\n(expecting a failure that x should be 1)\ngtest_output_test_.cc:#: Failure\n      Expected: 1\nTo be equal to: x\n      Which is: 2\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureTest.FatalFailureInSubroutine\n\u001b[0;32m[ RUN      ] \u001b[mFatalFailureTest.FatalFailureInNestedSubroutine\n(expecting a failure that x should be 1)\ngtest_output_test_.cc:#: Failure\n      Expected: 1\nTo be equal to: x\n      Which is: 2\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureTest.FatalFailureInNestedSubroutine\n\u001b[0;32m[ RUN      ] \u001b[mFatalFailureTest.NonfatalFailureInSubroutine\n(expecting a failure on false)\ngtest_output_test_.cc:#: Failure\nValue of: false\n  Actual: false\nExpected: true\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureTest.NonfatalFailureInSubroutine\n\u001b[0;32m[----------] \u001b[m1 test from LoggingTest\n\u001b[0;32m[ RUN      ] \u001b[mLoggingTest.InterleavingLoggingAndAssertions\n(expecting 2 failures on (3) >= (a[i]))\ni == 0\ni == 1\ngtest_output_test_.cc:#: Failure\nExpected: (3) >= (a[i]), actual: 3 vs 9\ni == 2\ni == 3\ngtest_output_test_.cc:#: Failure\nExpected: (3) >= (a[i]), actual: 3 vs 6\n\u001b[0;31m[  FAILED  ] \u001b[mLoggingTest.InterleavingLoggingAndAssertions\n\u001b[0;32m[----------] \u001b[m6 tests from SCOPED_TRACETest\n\u001b[0;32m[ RUN      ] \u001b[mSCOPED_TRACETest.ObeysScopes\n(expected to fail)\ngtest_output_test_.cc:#: Failure\nFailed\nThis failure is expected, and shouldn't have a trace.\ngtest_output_test_.cc:#: Failure\nFailed\nThis failure is expected, and should have a trace.\nGoogle Test trace:\ngtest_output_test_.cc:#: Expected trace\ngtest_output_test_.cc:#: Failure\nFailed\nThis failure is expected, and shouldn't have a trace.\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.ObeysScopes\n\u001b[0;32m[ RUN      ] \u001b[mSCOPED_TRACETest.WorksInLoop\n(expected to fail)\ngtest_output_test_.cc:#: Failure\n      Expected: 2\nTo be equal to: n\n      Which is: 1\nGoogle Test trace:\ngtest_output_test_.cc:#: i = 1\ngtest_output_test_.cc:#: Failure\n      Expected: 1\nTo be equal to: n\n      Which is: 2\nGoogle Test trace:\ngtest_output_test_.cc:#: i = 2\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.WorksInLoop\n\u001b[0;32m[ RUN      ] \u001b[mSCOPED_TRACETest.WorksInSubroutine\n(expected to fail)\ngtest_output_test_.cc:#: Failure\n      Expected: 2\nTo be equal to: n\n      Which is: 1\nGoogle Test trace:\ngtest_output_test_.cc:#: n = 1\ngtest_output_test_.cc:#: Failure\n      Expected: 1\nTo be equal to: n\n      Which is: 2\nGoogle Test trace:\ngtest_output_test_.cc:#: n = 2\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.WorksInSubroutine\n\u001b[0;32m[ RUN      ] \u001b[mSCOPED_TRACETest.CanBeNested\n(expected to fail)\ngtest_output_test_.cc:#: Failure\n      Expected: 1\nTo be equal to: n\n      Which is: 2\nGoogle Test trace:\ngtest_output_test_.cc:#: n = 2\ngtest_output_test_.cc:#: \n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.CanBeNested\n\u001b[0;32m[ RUN      ] \u001b[mSCOPED_TRACETest.CanBeRepeated\n(expected to fail)\ngtest_output_test_.cc:#: Failure\nFailed\nThis failure is expected, and should contain trace point A.\nGoogle Test trace:\ngtest_output_test_.cc:#: A\ngtest_output_test_.cc:#: Failure\nFailed\nThis failure is expected, and should contain trace point A and B.\nGoogle Test trace:\ngtest_output_test_.cc:#: B\ngtest_output_test_.cc:#: A\ngtest_output_test_.cc:#: Failure\nFailed\nThis failure is expected, and should contain trace point A, B, and C.\nGoogle Test trace:\ngtest_output_test_.cc:#: C\ngtest_output_test_.cc:#: B\ngtest_output_test_.cc:#: A\ngtest_output_test_.cc:#: Failure\nFailed\nThis failure is expected, and should contain trace point A, B, and D.\nGoogle Test trace:\ngtest_output_test_.cc:#: D\ngtest_output_test_.cc:#: B\ngtest_output_test_.cc:#: A\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.CanBeRepeated\n\u001b[0;32m[ RUN      ] \u001b[mSCOPED_TRACETest.WorksConcurrently\n(expecting 6 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #1 (in thread B, only trace B alive).\nGoogle Test trace:\ngtest_output_test_.cc:#: Trace B\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #2 (in thread A, trace A & B both alive).\nGoogle Test trace:\ngtest_output_test_.cc:#: Trace A\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #3 (in thread B, trace A & B both alive).\nGoogle Test trace:\ngtest_output_test_.cc:#: Trace B\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #4 (in thread B, only trace A alive).\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #5 (in thread A, only trace A alive).\nGoogle Test trace:\ngtest_output_test_.cc:#: Trace A\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #6 (in thread A, no trace alive).\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.WorksConcurrently\n\u001b[0;32m[----------] \u001b[m1 test from NonFatalFailureInFixtureConstructorTest\n\u001b[0;32m[ RUN      ] \u001b[mNonFatalFailureInFixtureConstructorTest.FailureInConstructor\n(expecting 5 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #1, in the test fixture c'tor.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #2, in SetUp().\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #3, in the test body.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #4, in TearDown.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #5, in the test fixture d'tor.\n\u001b[0;31m[  FAILED  ] \u001b[mNonFatalFailureInFixtureConstructorTest.FailureInConstructor\n\u001b[0;32m[----------] \u001b[m1 test from FatalFailureInFixtureConstructorTest\n\u001b[0;32m[ RUN      ] \u001b[mFatalFailureInFixtureConstructorTest.FailureInConstructor\n(expecting 2 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #1, in the test fixture c'tor.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #2, in the test fixture d'tor.\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureInFixtureConstructorTest.FailureInConstructor\n\u001b[0;32m[----------] \u001b[m1 test from NonFatalFailureInSetUpTest\n\u001b[0;32m[ RUN      ] \u001b[mNonFatalFailureInSetUpTest.FailureInSetUp\n(expecting 4 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #1, in SetUp().\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #2, in the test function.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #3, in TearDown().\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #4, in the test fixture d'tor.\n\u001b[0;31m[  FAILED  ] \u001b[mNonFatalFailureInSetUpTest.FailureInSetUp\n\u001b[0;32m[----------] \u001b[m1 test from FatalFailureInSetUpTest\n\u001b[0;32m[ RUN      ] \u001b[mFatalFailureInSetUpTest.FailureInSetUp\n(expecting 3 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #1, in SetUp().\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #2, in TearDown().\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #3, in the test fixture d'tor.\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureInSetUpTest.FailureInSetUp\n\u001b[0;32m[----------] \u001b[m1 test from AddFailureAtTest\n\u001b[0;32m[ RUN      ] \u001b[mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber\nfoo.cc:42: Failure\nFailed\nExpected failure in foo.cc\n\u001b[0;31m[  FAILED  ] \u001b[mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber\n\u001b[0;32m[----------] \u001b[m4 tests from MixedUpTestCaseTest\n\u001b[0;32m[ RUN      ] \u001b[mMixedUpTestCaseTest.FirstTestFromNamespaceFoo\n\u001b[0;32m[       OK ] \u001b[mMixedUpTestCaseTest.FirstTestFromNamespaceFoo\n\u001b[0;32m[ RUN      ] \u001b[mMixedUpTestCaseTest.SecondTestFromNamespaceFoo\n\u001b[0;32m[       OK ] \u001b[mMixedUpTestCaseTest.SecondTestFromNamespaceFoo\n\u001b[0;32m[ RUN      ] \u001b[mMixedUpTestCaseTest.ThisShouldFail\ngtest.cc:#: Failure\nFailed\nAll tests in the same test case must use the same test fixture\nclass.  However, in test case MixedUpTestCaseTest,\nyou defined test FirstTestFromNamespaceFoo and test ThisShouldFail\nusing two different test fixture classes.  This can happen if\nthe two classes are from different namespaces or translation\nunits and have the same name.  You should probably rename one\nof the classes to put the tests into different test cases.\n\u001b[0;31m[  FAILED  ] \u001b[mMixedUpTestCaseTest.ThisShouldFail\n\u001b[0;32m[ RUN      ] \u001b[mMixedUpTestCaseTest.ThisShouldFailToo\ngtest.cc:#: Failure\nFailed\nAll tests in the same test case must use the same test fixture\nclass.  However, in test case MixedUpTestCaseTest,\nyou defined test FirstTestFromNamespaceFoo and test ThisShouldFailToo\nusing two different test fixture classes.  This can happen if\nthe two classes are from different namespaces or translation\nunits and have the same name.  You should probably rename one\nof the classes to put the tests into different test cases.\n\u001b[0;31m[  FAILED  ] \u001b[mMixedUpTestCaseTest.ThisShouldFailToo\n\u001b[0;32m[----------] \u001b[m2 tests from MixedUpTestCaseWithSameTestNameTest\n\u001b[0;32m[ RUN      ] \u001b[mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail\n\u001b[0;32m[       OK ] \u001b[mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail\n\u001b[0;32m[ RUN      ] \u001b[mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail\ngtest.cc:#: Failure\nFailed\nAll tests in the same test case must use the same test fixture\nclass.  However, in test case MixedUpTestCaseWithSameTestNameTest,\nyou defined test TheSecondTestWithThisNameShouldFail and test TheSecondTestWithThisNameShouldFail\nusing two different test fixture classes.  This can happen if\nthe two classes are from different namespaces or translation\nunits and have the same name.  You should probably rename one\nof the classes to put the tests into different test cases.\n\u001b[0;31m[  FAILED  ] \u001b[mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail\n\u001b[0;32m[----------] \u001b[m2 tests from TEST_F_before_TEST_in_same_test_case\n\u001b[0;32m[ RUN      ] \u001b[mTEST_F_before_TEST_in_same_test_case.DefinedUsingTEST_F\n\u001b[0;32m[       OK ] \u001b[mTEST_F_before_TEST_in_same_test_case.DefinedUsingTEST_F\n\u001b[0;32m[ RUN      ] \u001b[mTEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail\ngtest.cc:#: Failure\nFailed\nAll tests in the same test case must use the same test fixture\nclass, so mixing TEST_F and TEST in the same test case is\nillegal.  In test case TEST_F_before_TEST_in_same_test_case,\ntest DefinedUsingTEST_F is defined using TEST_F but\ntest DefinedUsingTESTAndShouldFail is defined using TEST.  You probably\nwant to change the TEST to TEST_F or move it to another test\ncase.\n\u001b[0;31m[  FAILED  ] \u001b[mTEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail\n\u001b[0;32m[----------] \u001b[m2 tests from TEST_before_TEST_F_in_same_test_case\n\u001b[0;32m[ RUN      ] \u001b[mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST\n\u001b[0;32m[       OK ] \u001b[mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST\n\u001b[0;32m[ RUN      ] \u001b[mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail\ngtest.cc:#: Failure\nFailed\nAll tests in the same test case must use the same test fixture\nclass, so mixing TEST_F and TEST in the same test case is\nillegal.  In test case TEST_before_TEST_F_in_same_test_case,\ntest DefinedUsingTEST_FAndShouldFail is defined using TEST_F but\ntest DefinedUsingTEST is defined using TEST.  You probably\nwant to change the TEST to TEST_F or move it to another test\ncase.\n\u001b[0;31m[  FAILED  ] \u001b[mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail\n\u001b[0;32m[----------] \u001b[m8 tests from ExpectNonfatalFailureTest\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.CanReferenceGlobalVariables\n\u001b[0;32m[       OK ] \u001b[mExpectNonfatalFailureTest.CanReferenceGlobalVariables\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.CanReferenceLocalVariables\n\u001b[0;32m[       OK ] \u001b[mExpectNonfatalFailureTest.CanReferenceLocalVariables\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.SucceedsWhenThereIsOneNonfatalFailure\n\u001b[0;32m[       OK ] \u001b[mExpectNonfatalFailureTest.SucceedsWhenThereIsOneNonfatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereIsNoNonfatalFailure\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereIsNoNonfatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereAreTwoNonfatalFailures\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual: 2 failures\ngtest_output_test_.cc:#: Non-fatal failure:\nFailed\nExpected non-fatal failure 1.\n\ngtest_output_test_.cc:#: Non-fatal failure:\nFailed\nExpected non-fatal failure 2.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereAreTwoNonfatalFailures\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereIsOneFatalFailure\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual:\ngtest_output_test_.cc:#: Fatal failure:\nFailed\nExpected fatal failure.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereIsOneFatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.FailsWhenStatementReturns\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenStatementReturns\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.FailsWhenStatementThrows\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenStatementThrows\n\u001b[0;32m[----------] \u001b[m8 tests from ExpectFatalFailureTest\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.CanReferenceGlobalVariables\n\u001b[0;32m[       OK ] \u001b[mExpectFatalFailureTest.CanReferenceGlobalVariables\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.CanReferenceLocalStaticVariables\n\u001b[0;32m[       OK ] \u001b[mExpectFatalFailureTest.CanReferenceLocalStaticVariables\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.SucceedsWhenThereIsOneFatalFailure\n\u001b[0;32m[       OK ] \u001b[mExpectFatalFailureTest.SucceedsWhenThereIsOneFatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.FailsWhenThereIsNoFatalFailure\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenThereIsNoFatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.FailsWhenThereAreTwoFatalFailures\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual: 2 failures\ngtest_output_test_.cc:#: Fatal failure:\nFailed\nExpected fatal failure.\n\ngtest_output_test_.cc:#: Fatal failure:\nFailed\nExpected fatal failure.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenThereAreTwoFatalFailures\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.FailsWhenThereIsOneNonfatalFailure\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual:\ngtest_output_test_.cc:#: Non-fatal failure:\nFailed\nExpected non-fatal failure.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenThereIsOneNonfatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.FailsWhenStatementReturns\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenStatementReturns\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.FailsWhenStatementThrows\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenStatementThrows\n\u001b[0;32m[----------] \u001b[m2 tests from TypedTest/0, where TypeParam = int\n\u001b[0;32m[ RUN      ] \u001b[mTypedTest/0.Success\n\u001b[0;32m[       OK ] \u001b[mTypedTest/0.Success\n\u001b[0;32m[ RUN      ] \u001b[mTypedTest/0.Failure\ngtest_output_test_.cc:#: Failure\n      Expected: 1\nTo be equal to: TypeParam()\n      Which is: 0\nExpected failure\n\u001b[0;31m[  FAILED  ] \u001b[mTypedTest/0.Failure, where TypeParam = int\n\u001b[0;32m[----------] \u001b[m2 tests from Unsigned/TypedTestP/0, where TypeParam = unsigned char\n\u001b[0;32m[ RUN      ] \u001b[mUnsigned/TypedTestP/0.Success\n\u001b[0;32m[       OK ] \u001b[mUnsigned/TypedTestP/0.Success\n\u001b[0;32m[ RUN      ] \u001b[mUnsigned/TypedTestP/0.Failure\ngtest_output_test_.cc:#: Failure\n      Expected: 1U\n      Which is: 1\nTo be equal to: TypeParam()\n      Which is: '\\0'\nExpected failure\n\u001b[0;31m[  FAILED  ] \u001b[mUnsigned/TypedTestP/0.Failure, where TypeParam = unsigned char\n\u001b[0;32m[----------] \u001b[m2 tests from Unsigned/TypedTestP/1, where TypeParam = unsigned int\n\u001b[0;32m[ RUN      ] \u001b[mUnsigned/TypedTestP/1.Success\n\u001b[0;32m[       OK ] \u001b[mUnsigned/TypedTestP/1.Success\n\u001b[0;32m[ RUN      ] \u001b[mUnsigned/TypedTestP/1.Failure\ngtest_output_test_.cc:#: Failure\n      Expected: 1U\n      Which is: 1\nTo be equal to: TypeParam()\n      Which is: 0\nExpected failure\n\u001b[0;31m[  FAILED  ] \u001b[mUnsigned/TypedTestP/1.Failure, where TypeParam = unsigned int\n\u001b[0;32m[----------] \u001b[m4 tests from ExpectFailureTest\n\u001b[0;32m[ RUN      ] \u001b[mExpectFailureTest.ExpectFatalFailure\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual:\ngtest_output_test_.cc:#: Success:\nSucceeded\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual:\ngtest_output_test_.cc:#: Non-fatal failure:\nFailed\nExpected non-fatal failure.\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure containing \"Some other fatal failure expected.\"\n  Actual:\ngtest_output_test_.cc:#: Fatal failure:\nFailed\nExpected fatal failure.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectFatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectFailureTest.ExpectNonFatalFailure\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual:\ngtest_output_test_.cc:#: Success:\nSucceeded\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual:\ngtest_output_test_.cc:#: Fatal failure:\nFailed\nExpected fatal failure.\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure containing \"Some other non-fatal failure.\"\n  Actual:\ngtest_output_test_.cc:#: Non-fatal failure:\nFailed\nExpected non-fatal failure.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectNonFatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectFailureTest.ExpectFatalFailureOnAllThreads\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual:\ngtest_output_test_.cc:#: Success:\nSucceeded\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual:\ngtest_output_test_.cc:#: Non-fatal failure:\nFailed\nExpected non-fatal failure.\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure containing \"Some other fatal failure expected.\"\n  Actual:\ngtest_output_test_.cc:#: Fatal failure:\nFailed\nExpected fatal failure.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectFatalFailureOnAllThreads\n\u001b[0;32m[ RUN      ] \u001b[mExpectFailureTest.ExpectNonFatalFailureOnAllThreads\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual:\ngtest_output_test_.cc:#: Success:\nSucceeded\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual:\ngtest_output_test_.cc:#: Fatal failure:\nFailed\nExpected fatal failure.\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure containing \"Some other non-fatal failure.\"\n  Actual:\ngtest_output_test_.cc:#: Non-fatal failure:\nFailed\nExpected non-fatal failure.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectNonFatalFailureOnAllThreads\n\u001b[0;32m[----------] \u001b[m2 tests from ExpectFailureWithThreadsTest\n\u001b[0;32m[ RUN      ] \u001b[mExpectFailureWithThreadsTest.ExpectFatalFailure\n(expecting 2 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected fatal failure.\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureWithThreadsTest.ExpectFatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectFailureWithThreadsTest.ExpectNonFatalFailure\n(expecting 2 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected non-fatal failure.\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureWithThreadsTest.ExpectNonFatalFailure\n\u001b[0;32m[----------] \u001b[m1 test from ScopedFakeTestPartResultReporterTest\n\u001b[0;32m[ RUN      ] \u001b[mScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread\n(expecting 2 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected fatal failure.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected non-fatal failure.\n\u001b[0;31m[  FAILED  ] \u001b[mScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread\n\u001b[0;32m[----------] \u001b[m1 test from PrintingFailingParams/FailingParamTest\n\u001b[0;32m[ RUN      ] \u001b[mPrintingFailingParams/FailingParamTest.Fails/0\ngtest_output_test_.cc:#: Failure\n      Expected: 1\nTo be equal to: GetParam()\n      Which is: 2\n\u001b[0;31m[  FAILED  ] \u001b[mPrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2\n\u001b[0;32m[----------] \u001b[m2 tests from PrintingStrings/ParamTest\n\u001b[0;32m[ RUN      ] \u001b[mPrintingStrings/ParamTest.Success/a\n\u001b[0;32m[       OK ] \u001b[mPrintingStrings/ParamTest.Success/a\n\u001b[0;32m[ RUN      ] \u001b[mPrintingStrings/ParamTest.Failure/a\ngtest_output_test_.cc:#: Failure\n      Expected: \"b\"\nTo be equal to: GetParam()\n      Which is: \"a\"\nExpected failure\n\u001b[0;31m[  FAILED  ] \u001b[mPrintingStrings/ParamTest.Failure/a, where GetParam() = \"a\"\n\u001b[0;32m[----------] \u001b[mGlobal test environment tear-down\nBarEnvironment::TearDown() called.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected non-fatal failure.\nFooEnvironment::TearDown() called.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected fatal failure.\n\u001b[0;32m[==========] \u001b[m66 tests from 29 test cases ran.\n\u001b[0;32m[  PASSED  ] \u001b[m22 tests.\n\u001b[0;31m[  FAILED  ] \u001b[m44 tests, listed below:\n\u001b[0;31m[  FAILED  ] \u001b[mNonfatalFailureTest.EscapesStringOperands\n\u001b[0;31m[  FAILED  ] \u001b[mNonfatalFailureTest.DiffForLongStrings\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureTest.FatalFailureInSubroutine\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureTest.FatalFailureInNestedSubroutine\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureTest.NonfatalFailureInSubroutine\n\u001b[0;31m[  FAILED  ] \u001b[mLoggingTest.InterleavingLoggingAndAssertions\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.ObeysScopes\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.WorksInLoop\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.WorksInSubroutine\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.CanBeNested\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.CanBeRepeated\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.WorksConcurrently\n\u001b[0;31m[  FAILED  ] \u001b[mNonFatalFailureInFixtureConstructorTest.FailureInConstructor\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureInFixtureConstructorTest.FailureInConstructor\n\u001b[0;31m[  FAILED  ] \u001b[mNonFatalFailureInSetUpTest.FailureInSetUp\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureInSetUpTest.FailureInSetUp\n\u001b[0;31m[  FAILED  ] \u001b[mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber\n\u001b[0;31m[  FAILED  ] \u001b[mMixedUpTestCaseTest.ThisShouldFail\n\u001b[0;31m[  FAILED  ] \u001b[mMixedUpTestCaseTest.ThisShouldFailToo\n\u001b[0;31m[  FAILED  ] \u001b[mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail\n\u001b[0;31m[  FAILED  ] \u001b[mTEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail\n\u001b[0;31m[  FAILED  ] \u001b[mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereIsNoNonfatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereAreTwoNonfatalFailures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereIsOneFatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenStatementReturns\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenStatementThrows\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenThereIsNoFatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenThereAreTwoFatalFailures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenThereIsOneNonfatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenStatementReturns\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenStatementThrows\n\u001b[0;31m[  FAILED  ] \u001b[mTypedTest/0.Failure, where TypeParam = int\n\u001b[0;31m[  FAILED  ] \u001b[mUnsigned/TypedTestP/0.Failure, where TypeParam = unsigned char\n\u001b[0;31m[  FAILED  ] \u001b[mUnsigned/TypedTestP/1.Failure, where TypeParam = unsigned int\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectFatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectNonFatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectFatalFailureOnAllThreads\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectNonFatalFailureOnAllThreads\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureWithThreadsTest.ExpectFatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureWithThreadsTest.ExpectNonFatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread\n\u001b[0;31m[  FAILED  ] \u001b[mPrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2\n\u001b[0;31m[  FAILED  ] \u001b[mPrintingStrings/ParamTest.Failure/a, where GetParam() = \"a\"\n\n44 FAILED TESTS\n\u001b[0;33m  YOU HAVE 1 DISABLED TEST\n\n\u001b[mNote: Google Test filter = FatalFailureTest.*:LoggingTest.*\n[==========] Running 4 tests from 2 test cases.\n[----------] Global test environment set-up.\n[----------] 3 tests from FatalFailureTest\n[ RUN      ] FatalFailureTest.FatalFailureInSubroutine\n(expecting a failure that x should be 1)\ngtest_output_test_.cc:#: Failure\n      Expected: 1\nTo be equal to: x\n      Which is: 2\n[  FAILED  ] FatalFailureTest.FatalFailureInSubroutine (? ms)\n[ RUN      ] FatalFailureTest.FatalFailureInNestedSubroutine\n(expecting a failure that x should be 1)\ngtest_output_test_.cc:#: Failure\n      Expected: 1\nTo be equal to: x\n      Which is: 2\n[  FAILED  ] FatalFailureTest.FatalFailureInNestedSubroutine (? ms)\n[ RUN      ] FatalFailureTest.NonfatalFailureInSubroutine\n(expecting a failure on false)\ngtest_output_test_.cc:#: Failure\nValue of: false\n  Actual: false\nExpected: true\n[  FAILED  ] FatalFailureTest.NonfatalFailureInSubroutine (? ms)\n[----------] 3 tests from FatalFailureTest (? ms total)\n\n[----------] 1 test from LoggingTest\n[ RUN      ] LoggingTest.InterleavingLoggingAndAssertions\n(expecting 2 failures on (3) >= (a[i]))\ni == 0\ni == 1\ngtest_output_test_.cc:#: Failure\nExpected: (3) >= (a[i]), actual: 3 vs 9\ni == 2\ni == 3\ngtest_output_test_.cc:#: Failure\nExpected: (3) >= (a[i]), actual: 3 vs 6\n[  FAILED  ] LoggingTest.InterleavingLoggingAndAssertions (? ms)\n[----------] 1 test from LoggingTest (? ms total)\n\n[----------] Global test environment tear-down\n[==========] 4 tests from 2 test cases ran. (? ms total)\n[  PASSED  ] 0 tests.\n[  FAILED  ] 4 tests, listed below:\n[  FAILED  ] FatalFailureTest.FatalFailureInSubroutine\n[  FAILED  ] FatalFailureTest.FatalFailureInNestedSubroutine\n[  FAILED  ] FatalFailureTest.NonfatalFailureInSubroutine\n[  FAILED  ] LoggingTest.InterleavingLoggingAndAssertions\n\n 4 FAILED TESTS\nNote: Google Test filter = *DISABLED_*\n[==========] Running 1 test from 1 test case.\n[----------] Global test environment set-up.\n[----------] 1 test from DisabledTestsWarningTest\n[ RUN      ] DisabledTestsWarningTest.DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning\n[       OK ] DisabledTestsWarningTest.DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning\n[----------] Global test environment tear-down\n[==========] 1 test from 1 test case ran.\n[  PASSED  ] 1 test.\nNote: Google Test filter = PassingTest.*\nNote: This is test shard 2 of 2.\n[==========] Running 1 test from 1 test case.\n[----------] Global test environment set-up.\n[----------] 1 test from PassingTest\n[ RUN      ] PassingTest.PassingTest2\n[       OK ] PassingTest.PassingTest2\n[----------] Global test environment tear-down\n[==========] 1 test from 1 test case ran.\n[  PASSED  ] 1 test.\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_pred_impl_unittest.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is AUTOMATICALLY GENERATED on 10/31/2011 by command\n// 'gen_gtest_pred_impl.py 5'.  DO NOT EDIT BY HAND!\n\n// Regression test for gtest_pred_impl.h\n//\n// This file is generated by a script and quite long.  If you intend to\n// learn how Google Test works by reading its unit tests, read\n// gtest_unittest.cc instead.\n//\n// This is intended as a regression test for the Google Test predicate\n// assertions.  We compile it as part of the gtest_unittest target\n// only to keep the implementation tidy and compact, as it is quite\n// involved to set up the stage for testing Google Test using Google\n// Test itself.\n//\n// Currently, gtest_unittest takes ~11 seconds to run in the testing\n// daemon.  In the future, if it grows too large and needs much more\n// time to finish, we should consider separating this file into a\n// stand-alone regression test.\n\n#include <iostream>\n\n#include \"gtest/gtest.h\"\n#include \"gtest/gtest-spi.h\"\n\n// A user-defined data type.\nstruct Bool {\n  explicit Bool(int val) : value(val != 0) {}\n\n  bool operator>(int n) const { return value > Bool(n).value; }\n\n  Bool operator+(const Bool& rhs) const { return Bool(value + rhs.value); }\n\n  bool operator==(const Bool& rhs) const { return value == rhs.value; }\n\n  bool value;\n};\n\n// Enables Bool to be used in assertions.\nstd::ostream& operator<<(std::ostream& os, const Bool& x) {\n  return os << (x.value ? \"true\" : \"false\");\n}\n\n// Sample functions/functors for testing unary predicate assertions.\n\n// A unary predicate function.\ntemplate <typename T1>\nbool PredFunction1(T1 v1) {\n  return v1 > 0;\n}\n\n// The following two functions are needed to circumvent a bug in\n// gcc 2.95.3, which sometimes has problem with the above template\n// function.\nbool PredFunction1Int(int v1) {\n  return v1 > 0;\n}\nbool PredFunction1Bool(Bool v1) {\n  return v1 > 0;\n}\n\n// A unary predicate functor.\nstruct PredFunctor1 {\n  template <typename T1>\n  bool operator()(const T1& v1) {\n    return v1 > 0;\n  }\n};\n\n// A unary predicate-formatter function.\ntemplate <typename T1>\ntesting::AssertionResult PredFormatFunction1(const char* e1,\n                                             const T1& v1) {\n  if (PredFunction1(v1))\n    return testing::AssertionSuccess();\n\n  return testing::AssertionFailure()\n      << e1\n      << \" is expected to be positive, but evaluates to \"\n      << v1 << \".\";\n}\n\n// A unary predicate-formatter functor.\nstruct PredFormatFunctor1 {\n  template <typename T1>\n  testing::AssertionResult operator()(const char* e1,\n                                      const T1& v1) const {\n    return PredFormatFunction1(e1, v1);\n  }\n};\n\n// Tests for {EXPECT|ASSERT}_PRED_FORMAT1.\n\nclass Predicate1Test : public testing::Test {\n protected:\n  virtual void SetUp() {\n    expected_to_finish_ = true;\n    finished_ = false;\n    n1_ = 0;\n  }\n\n  virtual void TearDown() {\n    // Verifies that each of the predicate's arguments was evaluated\n    // exactly once.\n    EXPECT_EQ(1, n1_) <<\n        \"The predicate assertion didn't evaluate argument 2 \"\n        \"exactly once.\";\n\n    // Verifies that the control flow in the test function is expected.\n    if (expected_to_finish_ && !finished_) {\n      FAIL() << \"The predicate assertion unexpactedly aborted the test.\";\n    } else if (!expected_to_finish_ && finished_) {\n      FAIL() << \"The failed predicate assertion didn't abort the test \"\n                \"as expected.\";\n    }\n  }\n\n  // true iff the test function is expected to run to finish.\n  static bool expected_to_finish_;\n\n  // true iff the test function did run to finish.\n  static bool finished_;\n\n  static int n1_;\n};\n\nbool Predicate1Test::expected_to_finish_;\nbool Predicate1Test::finished_;\nint Predicate1Test::n1_;\n\ntypedef Predicate1Test EXPECT_PRED_FORMAT1Test;\ntypedef Predicate1Test ASSERT_PRED_FORMAT1Test;\ntypedef Predicate1Test EXPECT_PRED1Test;\ntypedef Predicate1Test ASSERT_PRED1Test;\n\n// Tests a successful EXPECT_PRED1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED1(PredFunction1Int,\n               ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED1Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED1(PredFunction1Bool,\n               Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED1(PredFunctor1(),\n               ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED1Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED1(PredFunctor1(),\n               Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED1(PredFunction1Int,\n                 n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED1Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED1(PredFunction1Bool,\n                 Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED1(PredFunctor1(),\n                 n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED1Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED1(PredFunctor1(),\n                 Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED1(PredFunction1Int,\n               ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED1Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED1(PredFunction1Bool,\n               Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED1(PredFunctor1(),\n               ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED1Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED1(PredFunctor1(),\n               Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED1(PredFunction1Int,\n                 n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED1Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED1(PredFunction1Bool,\n                 Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED1(PredFunctor1(),\n                 n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED1Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED1(PredFunctor1(),\n                 Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT1(PredFormatFunction1,\n                      ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT1(PredFormatFunction1,\n                      Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT1(PredFormatFunctor1(),\n                      ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT1(PredFormatFunctor1(),\n                      Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT1(PredFormatFunction1,\n                        n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT1(PredFormatFunction1,\n                        Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT1(PredFormatFunctor1(),\n                        n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT1(PredFormatFunctor1(),\n                        Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT1(PredFormatFunction1,\n                      ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT1(PredFormatFunction1,\n                      Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT1(PredFormatFunctor1(),\n                      ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT1(PredFormatFunctor1(),\n                      Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT1(PredFormatFunction1,\n                        n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT1(PredFormatFunction1,\n                        Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT1(PredFormatFunctor1(),\n                        n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT1(PredFormatFunctor1(),\n                        Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n// Sample functions/functors for testing binary predicate assertions.\n\n// A binary predicate function.\ntemplate <typename T1, typename T2>\nbool PredFunction2(T1 v1, T2 v2) {\n  return v1 + v2 > 0;\n}\n\n// The following two functions are needed to circumvent a bug in\n// gcc 2.95.3, which sometimes has problem with the above template\n// function.\nbool PredFunction2Int(int v1, int v2) {\n  return v1 + v2 > 0;\n}\nbool PredFunction2Bool(Bool v1, Bool v2) {\n  return v1 + v2 > 0;\n}\n\n// A binary predicate functor.\nstruct PredFunctor2 {\n  template <typename T1, typename T2>\n  bool operator()(const T1& v1,\n                  const T2& v2) {\n    return v1 + v2 > 0;\n  }\n};\n\n// A binary predicate-formatter function.\ntemplate <typename T1, typename T2>\ntesting::AssertionResult PredFormatFunction2(const char* e1,\n                                             const char* e2,\n                                             const T1& v1,\n                                             const T2& v2) {\n  if (PredFunction2(v1, v2))\n    return testing::AssertionSuccess();\n\n  return testing::AssertionFailure()\n      << e1 << \" + \" << e2\n      << \" is expected to be positive, but evaluates to \"\n      << v1 + v2 << \".\";\n}\n\n// A binary predicate-formatter functor.\nstruct PredFormatFunctor2 {\n  template <typename T1, typename T2>\n  testing::AssertionResult operator()(const char* e1,\n                                      const char* e2,\n                                      const T1& v1,\n                                      const T2& v2) const {\n    return PredFormatFunction2(e1, e2, v1, v2);\n  }\n};\n\n// Tests for {EXPECT|ASSERT}_PRED_FORMAT2.\n\nclass Predicate2Test : public testing::Test {\n protected:\n  virtual void SetUp() {\n    expected_to_finish_ = true;\n    finished_ = false;\n    n1_ = n2_ = 0;\n  }\n\n  virtual void TearDown() {\n    // Verifies that each of the predicate's arguments was evaluated\n    // exactly once.\n    EXPECT_EQ(1, n1_) <<\n        \"The predicate assertion didn't evaluate argument 2 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n2_) <<\n        \"The predicate assertion didn't evaluate argument 3 \"\n        \"exactly once.\";\n\n    // Verifies that the control flow in the test function is expected.\n    if (expected_to_finish_ && !finished_) {\n      FAIL() << \"The predicate assertion unexpactedly aborted the test.\";\n    } else if (!expected_to_finish_ && finished_) {\n      FAIL() << \"The failed predicate assertion didn't abort the test \"\n                \"as expected.\";\n    }\n  }\n\n  // true iff the test function is expected to run to finish.\n  static bool expected_to_finish_;\n\n  // true iff the test function did run to finish.\n  static bool finished_;\n\n  static int n1_;\n  static int n2_;\n};\n\nbool Predicate2Test::expected_to_finish_;\nbool Predicate2Test::finished_;\nint Predicate2Test::n1_;\nint Predicate2Test::n2_;\n\ntypedef Predicate2Test EXPECT_PRED_FORMAT2Test;\ntypedef Predicate2Test ASSERT_PRED_FORMAT2Test;\ntypedef Predicate2Test EXPECT_PRED2Test;\ntypedef Predicate2Test ASSERT_PRED2Test;\n\n// Tests a successful EXPECT_PRED2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED2(PredFunction2Int,\n               ++n1_,\n               ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED2Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED2(PredFunction2Bool,\n               Bool(++n1_),\n               Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED2(PredFunctor2(),\n               ++n1_,\n               ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED2Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED2(PredFunctor2(),\n               Bool(++n1_),\n               Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED2(PredFunction2Int,\n                 n1_++,\n                 n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED2Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED2(PredFunction2Bool,\n                 Bool(n1_++),\n                 Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED2(PredFunctor2(),\n                 n1_++,\n                 n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED2Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED2(PredFunctor2(),\n                 Bool(n1_++),\n                 Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED2(PredFunction2Int,\n               ++n1_,\n               ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED2Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED2(PredFunction2Bool,\n               Bool(++n1_),\n               Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED2(PredFunctor2(),\n               ++n1_,\n               ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED2Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED2(PredFunctor2(),\n               Bool(++n1_),\n               Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED2(PredFunction2Int,\n                 n1_++,\n                 n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED2Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED2(PredFunction2Bool,\n                 Bool(n1_++),\n                 Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED2(PredFunctor2(),\n                 n1_++,\n                 n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED2Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED2(PredFunctor2(),\n                 Bool(n1_++),\n                 Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT2(PredFormatFunction2,\n                      ++n1_,\n                      ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT2(PredFormatFunction2,\n                      Bool(++n1_),\n                      Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT2(PredFormatFunctor2(),\n                      ++n1_,\n                      ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT2(PredFormatFunctor2(),\n                      Bool(++n1_),\n                      Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(PredFormatFunction2,\n                        n1_++,\n                        n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(PredFormatFunction2,\n                        Bool(n1_++),\n                        Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(PredFormatFunctor2(),\n                        n1_++,\n                        n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(PredFormatFunctor2(),\n                        Bool(n1_++),\n                        Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT2(PredFormatFunction2,\n                      ++n1_,\n                      ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT2(PredFormatFunction2,\n                      Bool(++n1_),\n                      Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT2(PredFormatFunctor2(),\n                      ++n1_,\n                      ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT2(PredFormatFunctor2(),\n                      Bool(++n1_),\n                      Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT2(PredFormatFunction2,\n                        n1_++,\n                        n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT2(PredFormatFunction2,\n                        Bool(n1_++),\n                        Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT2(PredFormatFunctor2(),\n                        n1_++,\n                        n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT2(PredFormatFunctor2(),\n                        Bool(n1_++),\n                        Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n// Sample functions/functors for testing ternary predicate assertions.\n\n// A ternary predicate function.\ntemplate <typename T1, typename T2, typename T3>\nbool PredFunction3(T1 v1, T2 v2, T3 v3) {\n  return v1 + v2 + v3 > 0;\n}\n\n// The following two functions are needed to circumvent a bug in\n// gcc 2.95.3, which sometimes has problem with the above template\n// function.\nbool PredFunction3Int(int v1, int v2, int v3) {\n  return v1 + v2 + v3 > 0;\n}\nbool PredFunction3Bool(Bool v1, Bool v2, Bool v3) {\n  return v1 + v2 + v3 > 0;\n}\n\n// A ternary predicate functor.\nstruct PredFunctor3 {\n  template <typename T1, typename T2, typename T3>\n  bool operator()(const T1& v1,\n                  const T2& v2,\n                  const T3& v3) {\n    return v1 + v2 + v3 > 0;\n  }\n};\n\n// A ternary predicate-formatter function.\ntemplate <typename T1, typename T2, typename T3>\ntesting::AssertionResult PredFormatFunction3(const char* e1,\n                                             const char* e2,\n                                             const char* e3,\n                                             const T1& v1,\n                                             const T2& v2,\n                                             const T3& v3) {\n  if (PredFunction3(v1, v2, v3))\n    return testing::AssertionSuccess();\n\n  return testing::AssertionFailure()\n      << e1 << \" + \" << e2 << \" + \" << e3\n      << \" is expected to be positive, but evaluates to \"\n      << v1 + v2 + v3 << \".\";\n}\n\n// A ternary predicate-formatter functor.\nstruct PredFormatFunctor3 {\n  template <typename T1, typename T2, typename T3>\n  testing::AssertionResult operator()(const char* e1,\n                                      const char* e2,\n                                      const char* e3,\n                                      const T1& v1,\n                                      const T2& v2,\n                                      const T3& v3) const {\n    return PredFormatFunction3(e1, e2, e3, v1, v2, v3);\n  }\n};\n\n// Tests for {EXPECT|ASSERT}_PRED_FORMAT3.\n\nclass Predicate3Test : public testing::Test {\n protected:\n  virtual void SetUp() {\n    expected_to_finish_ = true;\n    finished_ = false;\n    n1_ = n2_ = n3_ = 0;\n  }\n\n  virtual void TearDown() {\n    // Verifies that each of the predicate's arguments was evaluated\n    // exactly once.\n    EXPECT_EQ(1, n1_) <<\n        \"The predicate assertion didn't evaluate argument 2 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n2_) <<\n        \"The predicate assertion didn't evaluate argument 3 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n3_) <<\n        \"The predicate assertion didn't evaluate argument 4 \"\n        \"exactly once.\";\n\n    // Verifies that the control flow in the test function is expected.\n    if (expected_to_finish_ && !finished_) {\n      FAIL() << \"The predicate assertion unexpactedly aborted the test.\";\n    } else if (!expected_to_finish_ && finished_) {\n      FAIL() << \"The failed predicate assertion didn't abort the test \"\n                \"as expected.\";\n    }\n  }\n\n  // true iff the test function is expected to run to finish.\n  static bool expected_to_finish_;\n\n  // true iff the test function did run to finish.\n  static bool finished_;\n\n  static int n1_;\n  static int n2_;\n  static int n3_;\n};\n\nbool Predicate3Test::expected_to_finish_;\nbool Predicate3Test::finished_;\nint Predicate3Test::n1_;\nint Predicate3Test::n2_;\nint Predicate3Test::n3_;\n\ntypedef Predicate3Test EXPECT_PRED_FORMAT3Test;\ntypedef Predicate3Test ASSERT_PRED_FORMAT3Test;\ntypedef Predicate3Test EXPECT_PRED3Test;\ntypedef Predicate3Test ASSERT_PRED3Test;\n\n// Tests a successful EXPECT_PRED3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED3(PredFunction3Int,\n               ++n1_,\n               ++n2_,\n               ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED3Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED3(PredFunction3Bool,\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED3(PredFunctor3(),\n               ++n1_,\n               ++n2_,\n               ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED3Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED3(PredFunctor3(),\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED3(PredFunction3Int,\n                 n1_++,\n                 n2_++,\n                 n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED3Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED3(PredFunction3Bool,\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED3(PredFunctor3(),\n                 n1_++,\n                 n2_++,\n                 n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED3Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED3(PredFunctor3(),\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED3(PredFunction3Int,\n               ++n1_,\n               ++n2_,\n               ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED3Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED3(PredFunction3Bool,\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED3(PredFunctor3(),\n               ++n1_,\n               ++n2_,\n               ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED3Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED3(PredFunctor3(),\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED3(PredFunction3Int,\n                 n1_++,\n                 n2_++,\n                 n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED3Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED3(PredFunction3Bool,\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED3(PredFunctor3(),\n                 n1_++,\n                 n2_++,\n                 n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED3Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED3(PredFunctor3(),\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT3(PredFormatFunction3,\n                      ++n1_,\n                      ++n2_,\n                      ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT3(PredFormatFunction3,\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT3(PredFormatFunctor3(),\n                      ++n1_,\n                      ++n2_,\n                      ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT3(PredFormatFunctor3(),\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT3(PredFormatFunction3,\n                        n1_++,\n                        n2_++,\n                        n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT3(PredFormatFunction3,\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT3(PredFormatFunctor3(),\n                        n1_++,\n                        n2_++,\n                        n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT3(PredFormatFunctor3(),\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT3(PredFormatFunction3,\n                      ++n1_,\n                      ++n2_,\n                      ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT3(PredFormatFunction3,\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT3(PredFormatFunctor3(),\n                      ++n1_,\n                      ++n2_,\n                      ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT3(PredFormatFunctor3(),\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT3(PredFormatFunction3,\n                        n1_++,\n                        n2_++,\n                        n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT3(PredFormatFunction3,\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT3(PredFormatFunctor3(),\n                        n1_++,\n                        n2_++,\n                        n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT3(PredFormatFunctor3(),\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n// Sample functions/functors for testing 4-ary predicate assertions.\n\n// A 4-ary predicate function.\ntemplate <typename T1, typename T2, typename T3, typename T4>\nbool PredFunction4(T1 v1, T2 v2, T3 v3, T4 v4) {\n  return v1 + v2 + v3 + v4 > 0;\n}\n\n// The following two functions are needed to circumvent a bug in\n// gcc 2.95.3, which sometimes has problem with the above template\n// function.\nbool PredFunction4Int(int v1, int v2, int v3, int v4) {\n  return v1 + v2 + v3 + v4 > 0;\n}\nbool PredFunction4Bool(Bool v1, Bool v2, Bool v3, Bool v4) {\n  return v1 + v2 + v3 + v4 > 0;\n}\n\n// A 4-ary predicate functor.\nstruct PredFunctor4 {\n  template <typename T1, typename T2, typename T3, typename T4>\n  bool operator()(const T1& v1,\n                  const T2& v2,\n                  const T3& v3,\n                  const T4& v4) {\n    return v1 + v2 + v3 + v4 > 0;\n  }\n};\n\n// A 4-ary predicate-formatter function.\ntemplate <typename T1, typename T2, typename T3, typename T4>\ntesting::AssertionResult PredFormatFunction4(const char* e1,\n                                             const char* e2,\n                                             const char* e3,\n                                             const char* e4,\n                                             const T1& v1,\n                                             const T2& v2,\n                                             const T3& v3,\n                                             const T4& v4) {\n  if (PredFunction4(v1, v2, v3, v4))\n    return testing::AssertionSuccess();\n\n  return testing::AssertionFailure()\n      << e1 << \" + \" << e2 << \" + \" << e3 << \" + \" << e4\n      << \" is expected to be positive, but evaluates to \"\n      << v1 + v2 + v3 + v4 << \".\";\n}\n\n// A 4-ary predicate-formatter functor.\nstruct PredFormatFunctor4 {\n  template <typename T1, typename T2, typename T3, typename T4>\n  testing::AssertionResult operator()(const char* e1,\n                                      const char* e2,\n                                      const char* e3,\n                                      const char* e4,\n                                      const T1& v1,\n                                      const T2& v2,\n                                      const T3& v3,\n                                      const T4& v4) const {\n    return PredFormatFunction4(e1, e2, e3, e4, v1, v2, v3, v4);\n  }\n};\n\n// Tests for {EXPECT|ASSERT}_PRED_FORMAT4.\n\nclass Predicate4Test : public testing::Test {\n protected:\n  virtual void SetUp() {\n    expected_to_finish_ = true;\n    finished_ = false;\n    n1_ = n2_ = n3_ = n4_ = 0;\n  }\n\n  virtual void TearDown() {\n    // Verifies that each of the predicate's arguments was evaluated\n    // exactly once.\n    EXPECT_EQ(1, n1_) <<\n        \"The predicate assertion didn't evaluate argument 2 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n2_) <<\n        \"The predicate assertion didn't evaluate argument 3 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n3_) <<\n        \"The predicate assertion didn't evaluate argument 4 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n4_) <<\n        \"The predicate assertion didn't evaluate argument 5 \"\n        \"exactly once.\";\n\n    // Verifies that the control flow in the test function is expected.\n    if (expected_to_finish_ && !finished_) {\n      FAIL() << \"The predicate assertion unexpactedly aborted the test.\";\n    } else if (!expected_to_finish_ && finished_) {\n      FAIL() << \"The failed predicate assertion didn't abort the test \"\n                \"as expected.\";\n    }\n  }\n\n  // true iff the test function is expected to run to finish.\n  static bool expected_to_finish_;\n\n  // true iff the test function did run to finish.\n  static bool finished_;\n\n  static int n1_;\n  static int n2_;\n  static int n3_;\n  static int n4_;\n};\n\nbool Predicate4Test::expected_to_finish_;\nbool Predicate4Test::finished_;\nint Predicate4Test::n1_;\nint Predicate4Test::n2_;\nint Predicate4Test::n3_;\nint Predicate4Test::n4_;\n\ntypedef Predicate4Test EXPECT_PRED_FORMAT4Test;\ntypedef Predicate4Test ASSERT_PRED_FORMAT4Test;\ntypedef Predicate4Test EXPECT_PRED4Test;\ntypedef Predicate4Test ASSERT_PRED4Test;\n\n// Tests a successful EXPECT_PRED4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED4(PredFunction4Int,\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED4Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED4(PredFunction4Bool,\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED4(PredFunctor4(),\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED4Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED4(PredFunctor4(),\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED4(PredFunction4Int,\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED4Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED4(PredFunction4Bool,\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED4(PredFunctor4(),\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED4Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED4(PredFunctor4(),\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED4(PredFunction4Int,\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED4Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED4(PredFunction4Bool,\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED4(PredFunctor4(),\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED4Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED4(PredFunctor4(),\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED4(PredFunction4Int,\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED4Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED4(PredFunction4Bool,\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED4(PredFunctor4(),\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED4Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED4(PredFunctor4(),\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT4(PredFormatFunction4,\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT4(PredFormatFunction4,\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT4(PredFormatFunctor4(),\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT4(PredFormatFunctor4(),\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT4(PredFormatFunction4,\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT4(PredFormatFunction4,\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT4(PredFormatFunctor4(),\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT4(PredFormatFunctor4(),\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT4(PredFormatFunction4,\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT4(PredFormatFunction4,\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT4(PredFormatFunctor4(),\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT4(PredFormatFunctor4(),\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT4(PredFormatFunction4,\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT4(PredFormatFunction4,\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT4(PredFormatFunctor4(),\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT4(PredFormatFunctor4(),\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n// Sample functions/functors for testing 5-ary predicate assertions.\n\n// A 5-ary predicate function.\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\nbool PredFunction5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) {\n  return v1 + v2 + v3 + v4 + v5 > 0;\n}\n\n// The following two functions are needed to circumvent a bug in\n// gcc 2.95.3, which sometimes has problem with the above template\n// function.\nbool PredFunction5Int(int v1, int v2, int v3, int v4, int v5) {\n  return v1 + v2 + v3 + v4 + v5 > 0;\n}\nbool PredFunction5Bool(Bool v1, Bool v2, Bool v3, Bool v4, Bool v5) {\n  return v1 + v2 + v3 + v4 + v5 > 0;\n}\n\n// A 5-ary predicate functor.\nstruct PredFunctor5 {\n  template <typename T1, typename T2, typename T3, typename T4, typename T5>\n  bool operator()(const T1& v1,\n                  const T2& v2,\n                  const T3& v3,\n                  const T4& v4,\n                  const T5& v5) {\n    return v1 + v2 + v3 + v4 + v5 > 0;\n  }\n};\n\n// A 5-ary predicate-formatter function.\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\ntesting::AssertionResult PredFormatFunction5(const char* e1,\n                                             const char* e2,\n                                             const char* e3,\n                                             const char* e4,\n                                             const char* e5,\n                                             const T1& v1,\n                                             const T2& v2,\n                                             const T3& v3,\n                                             const T4& v4,\n                                             const T5& v5) {\n  if (PredFunction5(v1, v2, v3, v4, v5))\n    return testing::AssertionSuccess();\n\n  return testing::AssertionFailure()\n      << e1 << \" + \" << e2 << \" + \" << e3 << \" + \" << e4 << \" + \" << e5\n      << \" is expected to be positive, but evaluates to \"\n      << v1 + v2 + v3 + v4 + v5 << \".\";\n}\n\n// A 5-ary predicate-formatter functor.\nstruct PredFormatFunctor5 {\n  template <typename T1, typename T2, typename T3, typename T4, typename T5>\n  testing::AssertionResult operator()(const char* e1,\n                                      const char* e2,\n                                      const char* e3,\n                                      const char* e4,\n                                      const char* e5,\n                                      const T1& v1,\n                                      const T2& v2,\n                                      const T3& v3,\n                                      const T4& v4,\n                                      const T5& v5) const {\n    return PredFormatFunction5(e1, e2, e3, e4, e5, v1, v2, v3, v4, v5);\n  }\n};\n\n// Tests for {EXPECT|ASSERT}_PRED_FORMAT5.\n\nclass Predicate5Test : public testing::Test {\n protected:\n  virtual void SetUp() {\n    expected_to_finish_ = true;\n    finished_ = false;\n    n1_ = n2_ = n3_ = n4_ = n5_ = 0;\n  }\n\n  virtual void TearDown() {\n    // Verifies that each of the predicate's arguments was evaluated\n    // exactly once.\n    EXPECT_EQ(1, n1_) <<\n        \"The predicate assertion didn't evaluate argument 2 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n2_) <<\n        \"The predicate assertion didn't evaluate argument 3 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n3_) <<\n        \"The predicate assertion didn't evaluate argument 4 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n4_) <<\n        \"The predicate assertion didn't evaluate argument 5 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n5_) <<\n        \"The predicate assertion didn't evaluate argument 6 \"\n        \"exactly once.\";\n\n    // Verifies that the control flow in the test function is expected.\n    if (expected_to_finish_ && !finished_) {\n      FAIL() << \"The predicate assertion unexpactedly aborted the test.\";\n    } else if (!expected_to_finish_ && finished_) {\n      FAIL() << \"The failed predicate assertion didn't abort the test \"\n                \"as expected.\";\n    }\n  }\n\n  // true iff the test function is expected to run to finish.\n  static bool expected_to_finish_;\n\n  // true iff the test function did run to finish.\n  static bool finished_;\n\n  static int n1_;\n  static int n2_;\n  static int n3_;\n  static int n4_;\n  static int n5_;\n};\n\nbool Predicate5Test::expected_to_finish_;\nbool Predicate5Test::finished_;\nint Predicate5Test::n1_;\nint Predicate5Test::n2_;\nint Predicate5Test::n3_;\nint Predicate5Test::n4_;\nint Predicate5Test::n5_;\n\ntypedef Predicate5Test EXPECT_PRED_FORMAT5Test;\ntypedef Predicate5Test ASSERT_PRED_FORMAT5Test;\ntypedef Predicate5Test EXPECT_PRED5Test;\ntypedef Predicate5Test ASSERT_PRED5Test;\n\n// Tests a successful EXPECT_PRED5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED5(PredFunction5Int,\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_,\n               ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED5Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED5(PredFunction5Bool,\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_),\n               Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED5(PredFunctor5(),\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_,\n               ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED5Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED5(PredFunctor5(),\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_),\n               Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED5(PredFunction5Int,\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++,\n                 n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED5Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED5(PredFunction5Bool,\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++),\n                 Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED5(PredFunctor5(),\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++,\n                 n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED5Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED5(PredFunctor5(),\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++),\n                 Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED5(PredFunction5Int,\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_,\n               ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED5Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED5(PredFunction5Bool,\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_),\n               Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED5(PredFunctor5(),\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_,\n               ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED5Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED5(PredFunctor5(),\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_),\n               Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED5(PredFunction5Int,\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++,\n                 n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED5Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED5(PredFunction5Bool,\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++),\n                 Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED5(PredFunctor5(),\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++,\n                 n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED5Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED5(PredFunctor5(),\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++),\n                 Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT5(PredFormatFunction5,\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_,\n                      ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT5(PredFormatFunction5,\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_),\n                      Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT5(PredFormatFunctor5(),\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_,\n                      ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT5(PredFormatFunctor5(),\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_),\n                      Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT5(PredFormatFunction5,\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++,\n                        n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT5(PredFormatFunction5,\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++),\n                        Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT5(PredFormatFunctor5(),\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++,\n                        n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT5(PredFormatFunctor5(),\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++),\n                        Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT5(PredFormatFunction5,\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_,\n                      ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT5(PredFormatFunction5,\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_),\n                      Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT5(PredFormatFunctor5(),\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_,\n                      ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT5(PredFormatFunctor5(),\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_),\n                      Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT5(PredFormatFunction5,\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++,\n                        n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT5(PredFormatFunction5,\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++),\n                        Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT5(PredFormatFunctor5(),\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++,\n                        n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT5(PredFormatFunctor5(),\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++),\n                        Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_premature_exit_test.cc",
    "content": "// Copyright 2013, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Tests that Google Test manipulates the premature-exit-detection\n// file correctly.\n\n#include <stdio.h>\n\n#include \"gtest/gtest.h\"\n\nusing ::testing::InitGoogleTest;\nusing ::testing::Test;\nusing ::testing::internal::posix::GetEnv;\nusing ::testing::internal::posix::Stat;\nusing ::testing::internal::posix::StatStruct;\n\nnamespace {\n\nclass PrematureExitTest : public Test {\n public:\n  // Returns true iff the given file exists.\n  static bool FileExists(const char* filepath) {\n    StatStruct stat;\n    return Stat(filepath, &stat) == 0;\n  }\n\n protected:\n  PrematureExitTest() {\n    premature_exit_file_path_ = GetEnv(\"TEST_PREMATURE_EXIT_FILE\");\n\n    // Normalize NULL to \"\" for ease of handling.\n    if (premature_exit_file_path_ == NULL) {\n      premature_exit_file_path_ = \"\";\n    }\n  }\n\n  // Returns true iff the premature-exit file exists.\n  bool PrematureExitFileExists() const {\n    return FileExists(premature_exit_file_path_);\n  }\n\n  const char* premature_exit_file_path_;\n};\n\ntypedef PrematureExitTest PrematureExitDeathTest;\n\n// Tests that:\n//   - the premature-exit file exists during the execution of a\n//     death test (EXPECT_DEATH*), and\n//   - a death test doesn't interfere with the main test process's\n//     handling of the premature-exit file.\nTEST_F(PrematureExitDeathTest, FileExistsDuringExecutionOfDeathTest) {\n  if (*premature_exit_file_path_ == '\\0') {\n    return;\n  }\n\n  EXPECT_DEATH_IF_SUPPORTED({\n      // If the file exists, crash the process such that the main test\n      // process will catch the (expected) crash and report a success;\n      // otherwise don't crash, which will cause the main test process\n      // to report that the death test has failed.\n      if (PrematureExitFileExists()) {\n        exit(1);\n      }\n    }, \"\");\n}\n\n// Tests that the premature-exit file exists during the execution of a\n// normal (non-death) test.\nTEST_F(PrematureExitTest, PrematureExitFileExistsDuringTestExecution) {\n  if (*premature_exit_file_path_ == '\\0') {\n    return;\n  }\n\n  EXPECT_TRUE(PrematureExitFileExists())\n      << \" file \" << premature_exit_file_path_\n      << \" should exist during test execution, but doesn't.\";\n}\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  InitGoogleTest(&argc, argv);\n  const int exit_code = RUN_ALL_TESTS();\n\n  // Test that the premature-exit file is deleted upon return from\n  // RUN_ALL_TESTS().\n  const char* const filepath = GetEnv(\"TEST_PREMATURE_EXIT_FILE\");\n  if (filepath != NULL && *filepath != '\\0') {\n    if (PrematureExitTest::FileExists(filepath)) {\n      printf(\n          \"File %s shouldn't exist after the test program finishes, but does.\",\n          filepath);\n      return 1;\n    }\n  }\n\n  return exit_code;\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_prod_test.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Unit test for include/gtest/gtest_prod.h.\n\n#include \"gtest/gtest.h\"\n#include \"test/production.h\"\n\n// Tests that private members can be accessed from a TEST declared as\n// a friend of the class.\nTEST(PrivateCodeTest, CanAccessPrivateMembers) {\n  PrivateCode a;\n  EXPECT_EQ(0, a.x_);\n\n  a.set_x(1);\n  EXPECT_EQ(1, a.x_);\n}\n\ntypedef testing::Test PrivateCodeFixtureTest;\n\n// Tests that private members can be accessed from a TEST_F declared\n// as a friend of the class.\nTEST_F(PrivateCodeFixtureTest, CanAccessPrivateMembers) {\n  PrivateCode a;\n  EXPECT_EQ(0, a.x_);\n\n  a.set_x(2);\n  EXPECT_EQ(2, a.x_);\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_repeat_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Tests the --gtest_repeat=number flag.\n\n#include <stdlib.h>\n#include <iostream>\n#include \"gtest/gtest.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nnamespace testing {\n\nGTEST_DECLARE_string_(death_test_style);\nGTEST_DECLARE_string_(filter);\nGTEST_DECLARE_int32_(repeat);\n\n}  // namespace testing\n\nusing testing::GTEST_FLAG(death_test_style);\nusing testing::GTEST_FLAG(filter);\nusing testing::GTEST_FLAG(repeat);\n\nnamespace {\n\n// We need this when we are testing Google Test itself and therefore\n// cannot use Google Test assertions.\n#define GTEST_CHECK_INT_EQ_(expected, actual) \\\n  do {\\\n    const int expected_val = (expected);\\\n    const int actual_val = (actual);\\\n    if (::testing::internal::IsTrue(expected_val != actual_val)) {\\\n      ::std::cout << \"Value of: \" #actual \"\\n\"\\\n                  << \"  Actual: \" << actual_val << \"\\n\"\\\n                  << \"Expected: \" #expected \"\\n\"\\\n                  << \"Which is: \" << expected_val << \"\\n\";\\\n      ::testing::internal::posix::Abort();\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n\n// Used for verifying that global environment set-up and tear-down are\n// inside the gtest_repeat loop.\n\nint g_environment_set_up_count = 0;\nint g_environment_tear_down_count = 0;\n\nclass MyEnvironment : public testing::Environment {\n public:\n  MyEnvironment() {}\n  virtual void SetUp() { g_environment_set_up_count++; }\n  virtual void TearDown() { g_environment_tear_down_count++; }\n};\n\n// A test that should fail.\n\nint g_should_fail_count = 0;\n\nTEST(FooTest, ShouldFail) {\n  g_should_fail_count++;\n  EXPECT_EQ(0, 1) << \"Expected failure.\";\n}\n\n// A test that should pass.\n\nint g_should_pass_count = 0;\n\nTEST(FooTest, ShouldPass) {\n  g_should_pass_count++;\n}\n\n// A test that contains a thread-safe death test and a fast death\n// test.  It should pass.\n\nint g_death_test_count = 0;\n\nTEST(BarDeathTest, ThreadSafeAndFast) {\n  g_death_test_count++;\n\n  GTEST_FLAG(death_test_style) = \"threadsafe\";\n  EXPECT_DEATH_IF_SUPPORTED(::testing::internal::posix::Abort(), \"\");\n\n  GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_DEATH_IF_SUPPORTED(::testing::internal::posix::Abort(), \"\");\n}\n\n#if GTEST_HAS_PARAM_TEST\nint g_param_test_count = 0;\n\nconst int kNumberOfParamTests = 10;\n\nclass MyParamTest : public testing::TestWithParam<int> {};\n\nTEST_P(MyParamTest, ShouldPass) {\n  // TODO(vladl@google.com): Make parameter value checking robust\n  //                         WRT order of tests.\n  GTEST_CHECK_INT_EQ_(g_param_test_count % kNumberOfParamTests, GetParam());\n  g_param_test_count++;\n}\nINSTANTIATE_TEST_CASE_P(MyParamSequence,\n                        MyParamTest,\n                        testing::Range(0, kNumberOfParamTests));\n#endif  // GTEST_HAS_PARAM_TEST\n\n// Resets the count for each test.\nvoid ResetCounts() {\n  g_environment_set_up_count = 0;\n  g_environment_tear_down_count = 0;\n  g_should_fail_count = 0;\n  g_should_pass_count = 0;\n  g_death_test_count = 0;\n#if GTEST_HAS_PARAM_TEST\n  g_param_test_count = 0;\n#endif  // GTEST_HAS_PARAM_TEST\n}\n\n// Checks that the count for each test is expected.\nvoid CheckCounts(int expected) {\n  GTEST_CHECK_INT_EQ_(expected, g_environment_set_up_count);\n  GTEST_CHECK_INT_EQ_(expected, g_environment_tear_down_count);\n  GTEST_CHECK_INT_EQ_(expected, g_should_fail_count);\n  GTEST_CHECK_INT_EQ_(expected, g_should_pass_count);\n  GTEST_CHECK_INT_EQ_(expected, g_death_test_count);\n#if GTEST_HAS_PARAM_TEST\n  GTEST_CHECK_INT_EQ_(expected * kNumberOfParamTests, g_param_test_count);\n#endif  // GTEST_HAS_PARAM_TEST\n}\n\n// Tests the behavior of Google Test when --gtest_repeat is not specified.\nvoid TestRepeatUnspecified() {\n  ResetCounts();\n  GTEST_CHECK_INT_EQ_(1, RUN_ALL_TESTS());\n  CheckCounts(1);\n}\n\n// Tests the behavior of Google Test when --gtest_repeat has the given value.\nvoid TestRepeat(int repeat) {\n  GTEST_FLAG(repeat) = repeat;\n\n  ResetCounts();\n  GTEST_CHECK_INT_EQ_(repeat > 0 ? 1 : 0, RUN_ALL_TESTS());\n  CheckCounts(repeat);\n}\n\n// Tests using --gtest_repeat when --gtest_filter specifies an empty\n// set of tests.\nvoid TestRepeatWithEmptyFilter(int repeat) {\n  GTEST_FLAG(repeat) = repeat;\n  GTEST_FLAG(filter) = \"None\";\n\n  ResetCounts();\n  GTEST_CHECK_INT_EQ_(0, RUN_ALL_TESTS());\n  CheckCounts(0);\n}\n\n// Tests using --gtest_repeat when --gtest_filter specifies a set of\n// successful tests.\nvoid TestRepeatWithFilterForSuccessfulTests(int repeat) {\n  GTEST_FLAG(repeat) = repeat;\n  GTEST_FLAG(filter) = \"*-*ShouldFail\";\n\n  ResetCounts();\n  GTEST_CHECK_INT_EQ_(0, RUN_ALL_TESTS());\n  GTEST_CHECK_INT_EQ_(repeat, g_environment_set_up_count);\n  GTEST_CHECK_INT_EQ_(repeat, g_environment_tear_down_count);\n  GTEST_CHECK_INT_EQ_(0, g_should_fail_count);\n  GTEST_CHECK_INT_EQ_(repeat, g_should_pass_count);\n  GTEST_CHECK_INT_EQ_(repeat, g_death_test_count);\n#if GTEST_HAS_PARAM_TEST\n  GTEST_CHECK_INT_EQ_(repeat * kNumberOfParamTests, g_param_test_count);\n#endif  // GTEST_HAS_PARAM_TEST\n}\n\n// Tests using --gtest_repeat when --gtest_filter specifies a set of\n// failed tests.\nvoid TestRepeatWithFilterForFailedTests(int repeat) {\n  GTEST_FLAG(repeat) = repeat;\n  GTEST_FLAG(filter) = \"*ShouldFail\";\n\n  ResetCounts();\n  GTEST_CHECK_INT_EQ_(1, RUN_ALL_TESTS());\n  GTEST_CHECK_INT_EQ_(repeat, g_environment_set_up_count);\n  GTEST_CHECK_INT_EQ_(repeat, g_environment_tear_down_count);\n  GTEST_CHECK_INT_EQ_(repeat, g_should_fail_count);\n  GTEST_CHECK_INT_EQ_(0, g_should_pass_count);\n  GTEST_CHECK_INT_EQ_(0, g_death_test_count);\n#if GTEST_HAS_PARAM_TEST\n  GTEST_CHECK_INT_EQ_(0, g_param_test_count);\n#endif  // GTEST_HAS_PARAM_TEST\n}\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  testing::InitGoogleTest(&argc, argv);\n  testing::AddGlobalTestEnvironment(new MyEnvironment);\n\n  TestRepeatUnspecified();\n  TestRepeat(0);\n  TestRepeat(1);\n  TestRepeat(5);\n\n  TestRepeatWithEmptyFilter(2);\n  TestRepeatWithEmptyFilter(3);\n\n  TestRepeatWithFilterForSuccessfulTests(3);\n\n  TestRepeatWithFilterForFailedTests(4);\n\n  // It would be nice to verify that the tests indeed loop forever\n  // when GTEST_FLAG(repeat) is negative, but this test will be quite\n  // complicated to write.  Since this flag is for interactive\n  // debugging only and doesn't affect the normal test result, such a\n  // test would be an overkill.\n\n  printf(\"PASS\\n\");\n  return 0;\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_shuffle_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2009 Google Inc. All Rights Reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Verifies that test shuffling works.\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport gtest_test_utils\n\n# Command to run the gtest_shuffle_test_ program.\nCOMMAND = gtest_test_utils.GetTestExecutablePath('gtest_shuffle_test_')\n\n# The environment variables for test sharding.\nTOTAL_SHARDS_ENV_VAR = 'GTEST_TOTAL_SHARDS'\nSHARD_INDEX_ENV_VAR = 'GTEST_SHARD_INDEX'\n\nTEST_FILTER = 'A*.A:A*.B:C*'\n\nALL_TESTS = []\nACTIVE_TESTS = []\nFILTERED_TESTS = []\nSHARDED_TESTS = []\n\nSHUFFLED_ALL_TESTS = []\nSHUFFLED_ACTIVE_TESTS = []\nSHUFFLED_FILTERED_TESTS = []\nSHUFFLED_SHARDED_TESTS = []\n\n\ndef AlsoRunDisabledTestsFlag():\n  return '--gtest_also_run_disabled_tests'\n\n\ndef FilterFlag(test_filter):\n  return '--gtest_filter=%s' % (test_filter,)\n\n\ndef RepeatFlag(n):\n  return '--gtest_repeat=%s' % (n,)\n\n\ndef ShuffleFlag():\n  return '--gtest_shuffle'\n\n\ndef RandomSeedFlag(n):\n  return '--gtest_random_seed=%s' % (n,)\n\n\ndef RunAndReturnOutput(extra_env, args):\n  \"\"\"Runs the test program and returns its output.\"\"\"\n\n  environ_copy = os.environ.copy()\n  environ_copy.update(extra_env)\n\n  return gtest_test_utils.Subprocess([COMMAND] + args, env=environ_copy).output\n\n\ndef GetTestsForAllIterations(extra_env, args):\n  \"\"\"Runs the test program and returns a list of test lists.\n\n  Args:\n    extra_env: a map from environment variables to their values\n    args: command line flags to pass to gtest_shuffle_test_\n\n  Returns:\n    A list where the i-th element is the list of tests run in the i-th\n    test iteration.\n  \"\"\"\n\n  test_iterations = []\n  for line in RunAndReturnOutput(extra_env, args).split('\\n'):\n    if line.startswith('----'):\n      tests = []\n      test_iterations.append(tests)\n    elif line.strip():\n      tests.append(line.strip())  # 'TestCaseName.TestName'\n\n  return test_iterations\n\n\ndef GetTestCases(tests):\n  \"\"\"Returns a list of test cases in the given full test names.\n\n  Args:\n    tests: a list of full test names\n\n  Returns:\n    A list of test cases from 'tests', in their original order.\n    Consecutive duplicates are removed.\n  \"\"\"\n\n  test_cases = []\n  for test in tests:\n    test_case = test.split('.')[0]\n    if not test_case in test_cases:\n      test_cases.append(test_case)\n\n  return test_cases\n\n\ndef CalculateTestLists():\n  \"\"\"Calculates the list of tests run under different flags.\"\"\"\n\n  if not ALL_TESTS:\n    ALL_TESTS.extend(\n        GetTestsForAllIterations({}, [AlsoRunDisabledTestsFlag()])[0])\n\n  if not ACTIVE_TESTS:\n    ACTIVE_TESTS.extend(GetTestsForAllIterations({}, [])[0])\n\n  if not FILTERED_TESTS:\n    FILTERED_TESTS.extend(\n        GetTestsForAllIterations({}, [FilterFlag(TEST_FILTER)])[0])\n\n  if not SHARDED_TESTS:\n    SHARDED_TESTS.extend(\n        GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3',\n                                  SHARD_INDEX_ENV_VAR: '1'},\n                                 [])[0])\n\n  if not SHUFFLED_ALL_TESTS:\n    SHUFFLED_ALL_TESTS.extend(GetTestsForAllIterations(\n        {}, [AlsoRunDisabledTestsFlag(), ShuffleFlag(), RandomSeedFlag(1)])[0])\n\n  if not SHUFFLED_ACTIVE_TESTS:\n    SHUFFLED_ACTIVE_TESTS.extend(GetTestsForAllIterations(\n        {}, [ShuffleFlag(), RandomSeedFlag(1)])[0])\n\n  if not SHUFFLED_FILTERED_TESTS:\n    SHUFFLED_FILTERED_TESTS.extend(GetTestsForAllIterations(\n        {}, [ShuffleFlag(), RandomSeedFlag(1), FilterFlag(TEST_FILTER)])[0])\n\n  if not SHUFFLED_SHARDED_TESTS:\n    SHUFFLED_SHARDED_TESTS.extend(\n        GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3',\n                                  SHARD_INDEX_ENV_VAR: '1'},\n                                 [ShuffleFlag(), RandomSeedFlag(1)])[0])\n\n\nclass GTestShuffleUnitTest(gtest_test_utils.TestCase):\n  \"\"\"Tests test shuffling.\"\"\"\n\n  def setUp(self):\n    CalculateTestLists()\n\n  def testShufflePreservesNumberOfTests(self):\n    self.assertEqual(len(ALL_TESTS), len(SHUFFLED_ALL_TESTS))\n    self.assertEqual(len(ACTIVE_TESTS), len(SHUFFLED_ACTIVE_TESTS))\n    self.assertEqual(len(FILTERED_TESTS), len(SHUFFLED_FILTERED_TESTS))\n    self.assertEqual(len(SHARDED_TESTS), len(SHUFFLED_SHARDED_TESTS))\n\n  def testShuffleChangesTestOrder(self):\n    self.assert_(SHUFFLED_ALL_TESTS != ALL_TESTS, SHUFFLED_ALL_TESTS)\n    self.assert_(SHUFFLED_ACTIVE_TESTS != ACTIVE_TESTS, SHUFFLED_ACTIVE_TESTS)\n    self.assert_(SHUFFLED_FILTERED_TESTS != FILTERED_TESTS,\n                 SHUFFLED_FILTERED_TESTS)\n    self.assert_(SHUFFLED_SHARDED_TESTS != SHARDED_TESTS,\n                 SHUFFLED_SHARDED_TESTS)\n\n  def testShuffleChangesTestCaseOrder(self):\n    self.assert_(GetTestCases(SHUFFLED_ALL_TESTS) != GetTestCases(ALL_TESTS),\n                 GetTestCases(SHUFFLED_ALL_TESTS))\n    self.assert_(\n        GetTestCases(SHUFFLED_ACTIVE_TESTS) != GetTestCases(ACTIVE_TESTS),\n        GetTestCases(SHUFFLED_ACTIVE_TESTS))\n    self.assert_(\n        GetTestCases(SHUFFLED_FILTERED_TESTS) != GetTestCases(FILTERED_TESTS),\n        GetTestCases(SHUFFLED_FILTERED_TESTS))\n    self.assert_(\n        GetTestCases(SHUFFLED_SHARDED_TESTS) != GetTestCases(SHARDED_TESTS),\n        GetTestCases(SHUFFLED_SHARDED_TESTS))\n\n  def testShuffleDoesNotRepeatTest(self):\n    for test in SHUFFLED_ALL_TESTS:\n      self.assertEqual(1, SHUFFLED_ALL_TESTS.count(test),\n                       '%s appears more than once' % (test,))\n    for test in SHUFFLED_ACTIVE_TESTS:\n      self.assertEqual(1, SHUFFLED_ACTIVE_TESTS.count(test),\n                       '%s appears more than once' % (test,))\n    for test in SHUFFLED_FILTERED_TESTS:\n      self.assertEqual(1, SHUFFLED_FILTERED_TESTS.count(test),\n                       '%s appears more than once' % (test,))\n    for test in SHUFFLED_SHARDED_TESTS:\n      self.assertEqual(1, SHUFFLED_SHARDED_TESTS.count(test),\n                       '%s appears more than once' % (test,))\n\n  def testShuffleDoesNotCreateNewTest(self):\n    for test in SHUFFLED_ALL_TESTS:\n      self.assert_(test in ALL_TESTS, '%s is an invalid test' % (test,))\n    for test in SHUFFLED_ACTIVE_TESTS:\n      self.assert_(test in ACTIVE_TESTS, '%s is an invalid test' % (test,))\n    for test in SHUFFLED_FILTERED_TESTS:\n      self.assert_(test in FILTERED_TESTS, '%s is an invalid test' % (test,))\n    for test in SHUFFLED_SHARDED_TESTS:\n      self.assert_(test in SHARDED_TESTS, '%s is an invalid test' % (test,))\n\n  def testShuffleIncludesAllTests(self):\n    for test in ALL_TESTS:\n      self.assert_(test in SHUFFLED_ALL_TESTS, '%s is missing' % (test,))\n    for test in ACTIVE_TESTS:\n      self.assert_(test in SHUFFLED_ACTIVE_TESTS, '%s is missing' % (test,))\n    for test in FILTERED_TESTS:\n      self.assert_(test in SHUFFLED_FILTERED_TESTS, '%s is missing' % (test,))\n    for test in SHARDED_TESTS:\n      self.assert_(test in SHUFFLED_SHARDED_TESTS, '%s is missing' % (test,))\n\n  def testShuffleLeavesDeathTestsAtFront(self):\n    non_death_test_found = False\n    for test in SHUFFLED_ACTIVE_TESTS:\n      if 'DeathTest.' in test:\n        self.assert_(not non_death_test_found,\n                     '%s appears after a non-death test' % (test,))\n      else:\n        non_death_test_found = True\n\n  def _VerifyTestCasesDoNotInterleave(self, tests):\n    test_cases = []\n    for test in tests:\n      [test_case, _] = test.split('.')\n      if test_cases and test_cases[-1] != test_case:\n        test_cases.append(test_case)\n        self.assertEqual(1, test_cases.count(test_case),\n                         'Test case %s is not grouped together in %s' %\n                         (test_case, tests))\n\n  def testShuffleDoesNotInterleaveTestCases(self):\n    self._VerifyTestCasesDoNotInterleave(SHUFFLED_ALL_TESTS)\n    self._VerifyTestCasesDoNotInterleave(SHUFFLED_ACTIVE_TESTS)\n    self._VerifyTestCasesDoNotInterleave(SHUFFLED_FILTERED_TESTS)\n    self._VerifyTestCasesDoNotInterleave(SHUFFLED_SHARDED_TESTS)\n\n  def testShuffleRestoresOrderAfterEachIteration(self):\n    # Get the test lists in all 3 iterations, using random seed 1, 2,\n    # and 3 respectively.  Google Test picks a different seed in each\n    # iteration, and this test depends on the current implementation\n    # picking successive numbers.  This dependency is not ideal, but\n    # makes the test much easier to write.\n    [tests_in_iteration1, tests_in_iteration2, tests_in_iteration3] = (\n        GetTestsForAllIterations(\n            {}, [ShuffleFlag(), RandomSeedFlag(1), RepeatFlag(3)]))\n\n    # Make sure running the tests with random seed 1 gets the same\n    # order as in iteration 1 above.\n    [tests_with_seed1] = GetTestsForAllIterations(\n        {}, [ShuffleFlag(), RandomSeedFlag(1)])\n    self.assertEqual(tests_in_iteration1, tests_with_seed1)\n\n    # Make sure running the tests with random seed 2 gets the same\n    # order as in iteration 2 above.  Success means that Google Test\n    # correctly restores the test order before re-shuffling at the\n    # beginning of iteration 2.\n    [tests_with_seed2] = GetTestsForAllIterations(\n        {}, [ShuffleFlag(), RandomSeedFlag(2)])\n    self.assertEqual(tests_in_iteration2, tests_with_seed2)\n\n    # Make sure running the tests with random seed 3 gets the same\n    # order as in iteration 3 above.  Success means that Google Test\n    # correctly restores the test order before re-shuffling at the\n    # beginning of iteration 3.\n    [tests_with_seed3] = GetTestsForAllIterations(\n        {}, [ShuffleFlag(), RandomSeedFlag(3)])\n    self.assertEqual(tests_in_iteration3, tests_with_seed3)\n\n  def testShuffleGeneratesNewOrderInEachIteration(self):\n    [tests_in_iteration1, tests_in_iteration2, tests_in_iteration3] = (\n        GetTestsForAllIterations(\n            {}, [ShuffleFlag(), RandomSeedFlag(1), RepeatFlag(3)]))\n\n    self.assert_(tests_in_iteration1 != tests_in_iteration2,\n                 tests_in_iteration1)\n    self.assert_(tests_in_iteration1 != tests_in_iteration3,\n                 tests_in_iteration1)\n    self.assert_(tests_in_iteration2 != tests_in_iteration3,\n                 tests_in_iteration2)\n\n  def testShuffleShardedTestsPreservesPartition(self):\n    # If we run M tests on N shards, the same M tests should be run in\n    # total, regardless of the random seeds used by the shards.\n    [tests1] = GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3',\n                                         SHARD_INDEX_ENV_VAR: '0'},\n                                        [ShuffleFlag(), RandomSeedFlag(1)])\n    [tests2] = GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3',\n                                         SHARD_INDEX_ENV_VAR: '1'},\n                                        [ShuffleFlag(), RandomSeedFlag(20)])\n    [tests3] = GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3',\n                                         SHARD_INDEX_ENV_VAR: '2'},\n                                        [ShuffleFlag(), RandomSeedFlag(25)])\n    sorted_sharded_tests = tests1 + tests2 + tests3\n    sorted_sharded_tests.sort()\n    sorted_active_tests = []\n    sorted_active_tests.extend(ACTIVE_TESTS)\n    sorted_active_tests.sort()\n    self.assertEqual(sorted_active_tests, sorted_sharded_tests)\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_shuffle_test_.cc",
    "content": "// Copyright 2009, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Verifies that test shuffling works.\n\n#include \"gtest/gtest.h\"\n\nnamespace {\n\nusing ::testing::EmptyTestEventListener;\nusing ::testing::InitGoogleTest;\nusing ::testing::Message;\nusing ::testing::Test;\nusing ::testing::TestEventListeners;\nusing ::testing::TestInfo;\nusing ::testing::UnitTest;\nusing ::testing::internal::scoped_ptr;\n\n// The test methods are empty, as the sole purpose of this program is\n// to print the test names before/after shuffling.\n\nclass A : public Test {};\nTEST_F(A, A) {}\nTEST_F(A, B) {}\n\nTEST(ADeathTest, A) {}\nTEST(ADeathTest, B) {}\nTEST(ADeathTest, C) {}\n\nTEST(B, A) {}\nTEST(B, B) {}\nTEST(B, C) {}\nTEST(B, DISABLED_D) {}\nTEST(B, DISABLED_E) {}\n\nTEST(BDeathTest, A) {}\nTEST(BDeathTest, B) {}\n\nTEST(C, A) {}\nTEST(C, B) {}\nTEST(C, C) {}\nTEST(C, DISABLED_D) {}\n\nTEST(CDeathTest, A) {}\n\nTEST(DISABLED_D, A) {}\nTEST(DISABLED_D, DISABLED_B) {}\n\n// This printer prints the full test names only, starting each test\n// iteration with a \"----\" marker.\nclass TestNamePrinter : public EmptyTestEventListener {\n public:\n  virtual void OnTestIterationStart(const UnitTest& /* unit_test */,\n                                    int /* iteration */) {\n    printf(\"----\\n\");\n  }\n\n  virtual void OnTestStart(const TestInfo& test_info) {\n    printf(\"%s.%s\\n\", test_info.test_case_name(), test_info.name());\n  }\n};\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  InitGoogleTest(&argc, argv);\n\n  // Replaces the default printer with TestNamePrinter, which prints\n  // the test name only.\n  TestEventListeners& listeners = UnitTest::GetInstance()->listeners();\n  delete listeners.Release(listeners.default_result_printer());\n  listeners.Append(new TestNamePrinter);\n\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_sole_header_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: mheule@google.com (Markus Heule)\n//\n// This test verifies that it's possible to use Google Test by including\n// the gtest.h header file alone.\n\n#include \"gtest/gtest.h\"\n\nnamespace {\n\nvoid Subroutine() {\n  EXPECT_EQ(42, 42);\n}\n\nTEST(NoFatalFailureTest, ExpectNoFatalFailure) {\n  EXPECT_NO_FATAL_FAILURE(;);\n  EXPECT_NO_FATAL_FAILURE(SUCCEED());\n  EXPECT_NO_FATAL_FAILURE(Subroutine());\n  EXPECT_NO_FATAL_FAILURE({ SUCCEED(); });\n}\n\nTEST(NoFatalFailureTest, AssertNoFatalFailure) {\n  ASSERT_NO_FATAL_FAILURE(;);\n  ASSERT_NO_FATAL_FAILURE(SUCCEED());\n  ASSERT_NO_FATAL_FAILURE(Subroutine());\n  ASSERT_NO_FATAL_FAILURE({ SUCCEED(); });\n}\n\n}  // namespace\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_stress_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Tests that SCOPED_TRACE() and various Google Test assertions can be\n// used in a large number of threads concurrently.\n\n#include \"gtest/gtest.h\"\n\n#include <iostream>\n#include <vector>\n\n// We must define this macro in order to #include\n// gtest-internal-inl.h.  This is how Google Test prevents a user from\n// accidentally depending on its internal implementation.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\n#if GTEST_IS_THREADSAFE\n\nnamespace testing {\nnamespace {\n\nusing internal::Notification;\nusing internal::TestPropertyKeyIs;\nusing internal::ThreadWithParam;\nusing internal::scoped_ptr;\n\n// In order to run tests in this file, for platforms where Google Test is\n// thread safe, implement ThreadWithParam. See the description of its API\n// in gtest-port.h, where it is defined for already supported platforms.\n\n// How many threads to create?\nconst int kThreadCount = 50;\n\nstd::string IdToKey(int id, const char* suffix) {\n  Message key;\n  key << \"key_\" << id << \"_\" << suffix;\n  return key.GetString();\n}\n\nstd::string IdToString(int id) {\n  Message id_message;\n  id_message << id;\n  return id_message.GetString();\n}\n\nvoid ExpectKeyAndValueWereRecordedForId(\n    const std::vector<TestProperty>& properties,\n    int id, const char* suffix) {\n  TestPropertyKeyIs matches_key(IdToKey(id, suffix).c_str());\n  const std::vector<TestProperty>::const_iterator property =\n      std::find_if(properties.begin(), properties.end(), matches_key);\n  ASSERT_TRUE(property != properties.end())\n      << \"expecting \" << suffix << \" value for id \" << id;\n  EXPECT_STREQ(IdToString(id).c_str(), property->value());\n}\n\n// Calls a large number of Google Test assertions, where exactly one of them\n// will fail.\nvoid ManyAsserts(int id) {\n  GTEST_LOG_(INFO) << \"Thread #\" << id << \" running...\";\n\n  SCOPED_TRACE(Message() << \"Thread #\" << id);\n\n  for (int i = 0; i < kThreadCount; i++) {\n    SCOPED_TRACE(Message() << \"Iteration #\" << i);\n\n    // A bunch of assertions that should succeed.\n    EXPECT_TRUE(true);\n    ASSERT_FALSE(false) << \"This shouldn't fail.\";\n    EXPECT_STREQ(\"a\", \"a\");\n    ASSERT_LE(5, 6);\n    EXPECT_EQ(i, i) << \"This shouldn't fail.\";\n\n    // RecordProperty() should interact safely with other threads as well.\n    // The shared_key forces property updates.\n    Test::RecordProperty(IdToKey(id, \"string\").c_str(), IdToString(id).c_str());\n    Test::RecordProperty(IdToKey(id, \"int\").c_str(), id);\n    Test::RecordProperty(\"shared_key\", IdToString(id).c_str());\n\n    // This assertion should fail kThreadCount times per thread.  It\n    // is for testing whether Google Test can handle failed assertions in a\n    // multi-threaded context.\n    EXPECT_LT(i, 0) << \"This should always fail.\";\n  }\n}\n\nvoid CheckTestFailureCount(int expected_failures) {\n  const TestInfo* const info = UnitTest::GetInstance()->current_test_info();\n  const TestResult* const result = info->result();\n  GTEST_CHECK_(expected_failures == result->total_part_count())\n      << \"Logged \" << result->total_part_count() << \" failures \"\n      << \" vs. \" << expected_failures << \" expected\";\n}\n\n// Tests using SCOPED_TRACE() and Google Test assertions in many threads\n// concurrently.\nTEST(StressTest, CanUseScopedTraceAndAssertionsInManyThreads) {\n  {\n    scoped_ptr<ThreadWithParam<int> > threads[kThreadCount];\n    Notification threads_can_start;\n    for (int i = 0; i != kThreadCount; i++)\n      threads[i].reset(new ThreadWithParam<int>(&ManyAsserts,\n                                                i,\n                                                &threads_can_start));\n\n    threads_can_start.Notify();\n\n    // Blocks until all the threads are done.\n    for (int i = 0; i != kThreadCount; i++)\n      threads[i]->Join();\n  }\n\n  // Ensures that kThreadCount*kThreadCount failures have been reported.\n  const TestInfo* const info = UnitTest::GetInstance()->current_test_info();\n  const TestResult* const result = info->result();\n\n  std::vector<TestProperty> properties;\n  // We have no access to the TestResult's list of properties but we can\n  // copy them one by one.\n  for (int i = 0; i < result->test_property_count(); ++i)\n    properties.push_back(result->GetTestProperty(i));\n\n  EXPECT_EQ(kThreadCount * 2 + 1, result->test_property_count())\n      << \"String and int values recorded on each thread, \"\n      << \"as well as one shared_key\";\n  for (int i = 0; i < kThreadCount; ++i) {\n    ExpectKeyAndValueWereRecordedForId(properties, i, \"string\");\n    ExpectKeyAndValueWereRecordedForId(properties, i, \"int\");\n  }\n  CheckTestFailureCount(kThreadCount*kThreadCount);\n}\n\nvoid FailingThread(bool is_fatal) {\n  if (is_fatal)\n    FAIL() << \"Fatal failure in some other thread. \"\n           << \"(This failure is expected.)\";\n  else\n    ADD_FAILURE() << \"Non-fatal failure in some other thread. \"\n                  << \"(This failure is expected.)\";\n}\n\nvoid GenerateFatalFailureInAnotherThread(bool is_fatal) {\n  ThreadWithParam<bool> thread(&FailingThread, is_fatal, NULL);\n  thread.Join();\n}\n\nTEST(NoFatalFailureTest, ExpectNoFatalFailureIgnoresFailuresInOtherThreads) {\n  EXPECT_NO_FATAL_FAILURE(GenerateFatalFailureInAnotherThread(true));\n  // We should only have one failure (the one from\n  // GenerateFatalFailureInAnotherThread()), since the EXPECT_NO_FATAL_FAILURE\n  // should succeed.\n  CheckTestFailureCount(1);\n}\n\nvoid AssertNoFatalFailureIgnoresFailuresInOtherThreads() {\n  ASSERT_NO_FATAL_FAILURE(GenerateFatalFailureInAnotherThread(true));\n}\nTEST(NoFatalFailureTest, AssertNoFatalFailureIgnoresFailuresInOtherThreads) {\n  // Using a subroutine, to make sure, that the test continues.\n  AssertNoFatalFailureIgnoresFailuresInOtherThreads();\n  // We should only have one failure (the one from\n  // GenerateFatalFailureInAnotherThread()), since the EXPECT_NO_FATAL_FAILURE\n  // should succeed.\n  CheckTestFailureCount(1);\n}\n\nTEST(FatalFailureTest, ExpectFatalFailureIgnoresFailuresInOtherThreads) {\n  // This statement should fail, since the current thread doesn't generate a\n  // fatal failure, only another one does.\n  EXPECT_FATAL_FAILURE(GenerateFatalFailureInAnotherThread(true), \"expected\");\n  CheckTestFailureCount(2);\n}\n\nTEST(FatalFailureOnAllThreadsTest, ExpectFatalFailureOnAllThreads) {\n  // This statement should succeed, because failures in all threads are\n  // considered.\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(\n      GenerateFatalFailureInAnotherThread(true), \"expected\");\n  CheckTestFailureCount(0);\n  // We need to add a failure, because main() checks that there are failures.\n  // But when only this test is run, we shouldn't have any failures.\n  ADD_FAILURE() << \"This is an expected non-fatal failure.\";\n}\n\nTEST(NonFatalFailureTest, ExpectNonFatalFailureIgnoresFailuresInOtherThreads) {\n  // This statement should fail, since the current thread doesn't generate a\n  // fatal failure, only another one does.\n  EXPECT_NONFATAL_FAILURE(GenerateFatalFailureInAnotherThread(false),\n                          \"expected\");\n  CheckTestFailureCount(2);\n}\n\nTEST(NonFatalFailureOnAllThreadsTest, ExpectNonFatalFailureOnAllThreads) {\n  // This statement should succeed, because failures in all threads are\n  // considered.\n  EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(\n      GenerateFatalFailureInAnotherThread(false), \"expected\");\n  CheckTestFailureCount(0);\n  // We need to add a failure, because main() checks that there are failures,\n  // But when only this test is run, we shouldn't have any failures.\n  ADD_FAILURE() << \"This is an expected non-fatal failure.\";\n}\n\n}  // namespace\n}  // namespace testing\n\nint main(int argc, char **argv) {\n  testing::InitGoogleTest(&argc, argv);\n\n  const int result = RUN_ALL_TESTS();  // Expected to fail.\n  GTEST_CHECK_(result == 1) << \"RUN_ALL_TESTS() did not fail as expected\";\n\n  printf(\"\\nPASS\\n\");\n  return 0;\n}\n\n#else\nTEST(StressTest,\n     DISABLED_ThreadSafetyTestsAreSkippedWhenGoogleTestIsNotThreadSafe) {\n}\n\nint main(int argc, char **argv) {\n  testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n#endif  // GTEST_IS_THREADSAFE\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_test_utils.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2006, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Unit test utilities for Google C++ Testing Framework.\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport atexit\nimport os\nimport shutil\nimport sys\nimport tempfile\nimport unittest\n_test_module = unittest\n\n# Suppresses the 'Import not at the top of the file' lint complaint.\n# pylint: disable-msg=C6204\ntry:\n  import subprocess\n  _SUBPROCESS_MODULE_AVAILABLE = True\nexcept:\n  import popen2\n  _SUBPROCESS_MODULE_AVAILABLE = False\n# pylint: enable-msg=C6204\n\nGTEST_OUTPUT_VAR_NAME = 'GTEST_OUTPUT'\n\nIS_WINDOWS = os.name == 'nt'\nIS_CYGWIN = os.name == 'posix' and 'CYGWIN' in os.uname()[0]\n\n# The environment variable for specifying the path to the premature-exit file.\nPREMATURE_EXIT_FILE_ENV_VAR = 'TEST_PREMATURE_EXIT_FILE'\n\nenviron = os.environ.copy()\n\n\ndef SetEnvVar(env_var, value):\n  \"\"\"Sets/unsets an environment variable to a given value.\"\"\"\n\n  if value is not None:\n    environ[env_var] = value\n  elif env_var in environ:\n    del environ[env_var]\n\n\n# Here we expose a class from a particular module, depending on the\n# environment. The comment suppresses the 'Invalid variable name' lint\n# complaint.\nTestCase = _test_module.TestCase  # pylint: disable-msg=C6409\n\n# Initially maps a flag to its default value. After\n# _ParseAndStripGTestFlags() is called, maps a flag to its actual value.\n_flag_map = {'source_dir': os.path.dirname(sys.argv[0]),\n             'build_dir': os.path.dirname(sys.argv[0])}\n_gtest_flags_are_parsed = False\n\n\ndef _ParseAndStripGTestFlags(argv):\n  \"\"\"Parses and strips Google Test flags from argv.  This is idempotent.\"\"\"\n\n  # Suppresses the lint complaint about a global variable since we need it\n  # here to maintain module-wide state.\n  global _gtest_flags_are_parsed  # pylint: disable-msg=W0603\n  if _gtest_flags_are_parsed:\n    return\n\n  _gtest_flags_are_parsed = True\n  for flag in _flag_map:\n    # The environment variable overrides the default value.\n    if flag.upper() in os.environ:\n      _flag_map[flag] = os.environ[flag.upper()]\n\n    # The command line flag overrides the environment variable.\n    i = 1  # Skips the program name.\n    while i < len(argv):\n      prefix = '--' + flag + '='\n      if argv[i].startswith(prefix):\n        _flag_map[flag] = argv[i][len(prefix):]\n        del argv[i]\n        break\n      else:\n        # We don't increment i in case we just found a --gtest_* flag\n        # and removed it from argv.\n        i += 1\n\n\ndef GetFlag(flag):\n  \"\"\"Returns the value of the given flag.\"\"\"\n\n  # In case GetFlag() is called before Main(), we always call\n  # _ParseAndStripGTestFlags() here to make sure the --gtest_* flags\n  # are parsed.\n  _ParseAndStripGTestFlags(sys.argv)\n\n  return _flag_map[flag]\n\n\ndef GetSourceDir():\n  \"\"\"Returns the absolute path of the directory where the .py files are.\"\"\"\n\n  return os.path.abspath(GetFlag('source_dir'))\n\n\ndef GetBuildDir():\n  \"\"\"Returns the absolute path of the directory where the test binaries are.\"\"\"\n\n  return os.path.abspath(GetFlag('build_dir'))\n\n\n_temp_dir = None\n\ndef _RemoveTempDir():\n  if _temp_dir:\n    shutil.rmtree(_temp_dir, ignore_errors=True)\n\natexit.register(_RemoveTempDir)\n\n\ndef GetTempDir():\n  \"\"\"Returns a directory for temporary files.\"\"\"\n\n  global _temp_dir\n  if not _temp_dir:\n    _temp_dir = tempfile.mkdtemp()\n  return _temp_dir\n\n\ndef GetTestExecutablePath(executable_name, build_dir=None):\n  \"\"\"Returns the absolute path of the test binary given its name.\n\n  The function will print a message and abort the program if the resulting file\n  doesn't exist.\n\n  Args:\n    executable_name: name of the test binary that the test script runs.\n    build_dir:       directory where to look for executables, by default\n                     the result of GetBuildDir().\n\n  Returns:\n    The absolute path of the test binary.\n  \"\"\"\n\n  path = os.path.abspath(os.path.join(build_dir or GetBuildDir(),\n                                      executable_name))\n  if (IS_WINDOWS or IS_CYGWIN) and not path.endswith('.exe'):\n    path += '.exe'\n\n  if not os.path.exists(path):\n    message = (\n        'Unable to find the test binary \"%s\". Please make sure to provide\\n'\n        'a path to the binary via the --build_dir flag or the BUILD_DIR\\n'\n        'environment variable.' % path)\n    sys.stdout.write(message)\n    sys.exit(1)\n\n  return path\n\n\ndef GetExitStatus(exit_code):\n  \"\"\"Returns the argument to exit(), or -1 if exit() wasn't called.\n\n  Args:\n    exit_code: the result value of os.system(command).\n  \"\"\"\n\n  if os.name == 'nt':\n    # On Windows, os.WEXITSTATUS() doesn't work and os.system() returns\n    # the argument to exit() directly.\n    return exit_code\n  else:\n    # On Unix, os.WEXITSTATUS() must be used to extract the exit status\n    # from the result of os.system().\n    if os.WIFEXITED(exit_code):\n      return os.WEXITSTATUS(exit_code)\n    else:\n      return -1\n\n\nclass Subprocess:\n  def __init__(self, command, working_dir=None, capture_stderr=True, env=None):\n    \"\"\"Changes into a specified directory, if provided, and executes a command.\n\n    Restores the old directory afterwards.\n\n    Args:\n      command:        The command to run, in the form of sys.argv.\n      working_dir:    The directory to change into.\n      capture_stderr: Determines whether to capture stderr in the output member\n                      or to discard it.\n      env:            Dictionary with environment to pass to the subprocess.\n\n    Returns:\n      An object that represents outcome of the executed process. It has the\n      following attributes:\n        terminated_by_signal   True iff the child process has been terminated\n                               by a signal.\n        signal                 Sygnal that terminated the child process.\n        exited                 True iff the child process exited normally.\n        exit_code              The code with which the child process exited.\n        output                 Child process's stdout and stderr output\n                               combined in a string.\n    \"\"\"\n\n    # The subprocess module is the preferrable way of running programs\n    # since it is available and behaves consistently on all platforms,\n    # including Windows. But it is only available starting in python 2.4.\n    # In earlier python versions, we revert to the popen2 module, which is\n    # available in python 2.0 and later but doesn't provide required\n    # functionality (Popen4) under Windows. This allows us to support Mac\n    # OS X 10.4 Tiger, which has python 2.3 installed.\n    if _SUBPROCESS_MODULE_AVAILABLE:\n      if capture_stderr:\n        stderr = subprocess.STDOUT\n      else:\n        stderr = subprocess.PIPE\n\n      p = subprocess.Popen(command,\n                           stdout=subprocess.PIPE, stderr=stderr,\n                           cwd=working_dir, universal_newlines=True, env=env)\n      # communicate returns a tuple with the file obect for the child's\n      # output.\n      self.output = p.communicate()[0]\n      self._return_code = p.returncode\n    else:\n      old_dir = os.getcwd()\n\n      def _ReplaceEnvDict(dest, src):\n        # Changes made by os.environ.clear are not inheritable by child\n        # processes until Python 2.6. To produce inheritable changes we have\n        # to delete environment items with the del statement.\n        for key in dest.keys():\n          del dest[key]\n        dest.update(src)\n\n      # When 'env' is not None, backup the environment variables and replace\n      # them with the passed 'env'. When 'env' is None, we simply use the\n      # current 'os.environ' for compatibility with the subprocess.Popen\n      # semantics used above.\n      if env is not None:\n        old_environ = os.environ.copy()\n        _ReplaceEnvDict(os.environ, env)\n\n      try:\n        if working_dir is not None:\n          os.chdir(working_dir)\n        if capture_stderr:\n          p = popen2.Popen4(command)\n        else:\n          p = popen2.Popen3(command)\n        p.tochild.close()\n        self.output = p.fromchild.read()\n        ret_code = p.wait()\n      finally:\n        os.chdir(old_dir)\n\n        # Restore the old environment variables\n        # if they were replaced.\n        if env is not None:\n          _ReplaceEnvDict(os.environ, old_environ)\n\n      # Converts ret_code to match the semantics of\n      # subprocess.Popen.returncode.\n      if os.WIFSIGNALED(ret_code):\n        self._return_code = -os.WTERMSIG(ret_code)\n      else:  # os.WIFEXITED(ret_code) should return True here.\n        self._return_code = os.WEXITSTATUS(ret_code)\n\n    if self._return_code < 0:\n      self.terminated_by_signal = True\n      self.exited = False\n      self.signal = -self._return_code\n    else:\n      self.terminated_by_signal = False\n      self.exited = True\n      self.exit_code = self._return_code\n\n\ndef Main():\n  \"\"\"Runs the unit test.\"\"\"\n\n  # We must call _ParseAndStripGTestFlags() before calling\n  # unittest.main().  Otherwise the latter will be confused by the\n  # --gtest_* flags.\n  _ParseAndStripGTestFlags(sys.argv)\n  # The tested binaries should not be writing XML output files unless the\n  # script explicitly instructs them to.\n  # TODO(vladl@google.com): Move this into Subprocess when we implement\n  # passing environment into it as a parameter.\n  if GTEST_OUTPUT_VAR_NAME in os.environ:\n    del os.environ[GTEST_OUTPUT_VAR_NAME]\n\n  _test_module.main()\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_throw_on_failure_ex_test.cc",
    "content": "// Copyright 2009, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Tests Google Test's throw-on-failure mode with exceptions enabled.\n\n#include \"gtest/gtest.h\"\n\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <stdexcept>\n\n// Prints the given failure message and exits the program with\n// non-zero.  We use this instead of a Google Test assertion to\n// indicate a failure, as the latter is been tested and cannot be\n// relied on.\nvoid Fail(const char* msg) {\n  printf(\"FAILURE: %s\\n\", msg);\n  fflush(stdout);\n  exit(1);\n}\n\n// Tests that an assertion failure throws a subclass of\n// std::runtime_error.\nvoid TestFailureThrowsRuntimeError() {\n  testing::GTEST_FLAG(throw_on_failure) = true;\n\n  // A successful assertion shouldn't throw.\n  try {\n    EXPECT_EQ(3, 3);\n  } catch(...) {\n    Fail(\"A successful assertion wrongfully threw.\");\n  }\n\n  // A failed assertion should throw a subclass of std::runtime_error.\n  try {\n    EXPECT_EQ(2, 3) << \"Expected failure\";\n  } catch(const std::runtime_error& e) {\n    if (strstr(e.what(), \"Expected failure\") != NULL)\n      return;\n\n    printf(\"%s\",\n           \"A failed assertion did throw an exception of the right type, \"\n           \"but the message is incorrect.  Instead of containing \\\"Expected \"\n           \"failure\\\", it is:\\n\");\n    Fail(e.what());\n  } catch(...) {\n    Fail(\"A failed assertion threw the wrong type of exception.\");\n  }\n  Fail(\"A failed assertion should've thrown but didn't.\");\n}\n\nint main(int argc, char** argv) {\n  testing::InitGoogleTest(&argc, argv);\n\n  // We want to ensure that people can use Google Test assertions in\n  // other testing frameworks, as long as they initialize Google Test\n  // properly and set the thrown-on-failure mode.  Therefore, we don't\n  // use Google Test's constructs for defining and running tests\n  // (e.g. TEST and RUN_ALL_TESTS) here.\n\n  TestFailureThrowsRuntimeError();\n  return 0;\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_throw_on_failure_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2009, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Tests Google Test's throw-on-failure mode with exceptions disabled.\n\nThis script invokes gtest_throw_on_failure_test_ (a program written with\nGoogle Test) with different environments and command line flags.\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport gtest_test_utils\n\n\n# Constants.\n\n# The command line flag for enabling/disabling the throw-on-failure mode.\nTHROW_ON_FAILURE = 'gtest_throw_on_failure'\n\n# Path to the gtest_throw_on_failure_test_ program, compiled with\n# exceptions disabled.\nEXE_PATH = gtest_test_utils.GetTestExecutablePath(\n    'gtest_throw_on_failure_test_')\n\n\n# Utilities.\n\n\ndef SetEnvVar(env_var, value):\n  \"\"\"Sets an environment variable to a given value; unsets it when the\n  given value is None.\n  \"\"\"\n\n  env_var = env_var.upper()\n  if value is not None:\n    os.environ[env_var] = value\n  elif env_var in os.environ:\n    del os.environ[env_var]\n\n\ndef Run(command):\n  \"\"\"Runs a command; returns True/False if its exit code is/isn't 0.\"\"\"\n\n  print('Running \"%s\". . .' % ' '.join(command))\n  p = gtest_test_utils.Subprocess(command)\n  return p.exited and p.exit_code == 0\n\n\n# The tests.  TODO(wan@google.com): refactor the class to share common\n# logic with code in gtest_break_on_failure_unittest.py.\nclass ThrowOnFailureTest(gtest_test_utils.TestCase):\n  \"\"\"Tests the throw-on-failure mode.\"\"\"\n\n  def RunAndVerify(self, env_var_value, flag_value, should_fail):\n    \"\"\"Runs gtest_throw_on_failure_test_ and verifies that it does\n    (or does not) exit with a non-zero code.\n\n    Args:\n      env_var_value:    value of the GTEST_BREAK_ON_FAILURE environment\n                        variable; None if the variable should be unset.\n      flag_value:       value of the --gtest_break_on_failure flag;\n                        None if the flag should not be present.\n      should_fail:      True iff the program is expected to fail.\n    \"\"\"\n\n    SetEnvVar(THROW_ON_FAILURE, env_var_value)\n\n    if env_var_value is None:\n      env_var_value_msg = ' is not set'\n    else:\n      env_var_value_msg = '=' + env_var_value\n\n    if flag_value is None:\n      flag = ''\n    elif flag_value == '0':\n      flag = '--%s=0' % THROW_ON_FAILURE\n    else:\n      flag = '--%s' % THROW_ON_FAILURE\n\n    command = [EXE_PATH]\n    if flag:\n      command.append(flag)\n\n    if should_fail:\n      should_or_not = 'should'\n    else:\n      should_or_not = 'should not'\n\n    failed = not Run(command)\n\n    SetEnvVar(THROW_ON_FAILURE, None)\n\n    msg = ('when %s%s, an assertion failure in \"%s\" %s cause a non-zero '\n           'exit code.' %\n           (THROW_ON_FAILURE, env_var_value_msg, ' '.join(command),\n            should_or_not))\n    self.assert_(failed == should_fail, msg)\n\n  def testDefaultBehavior(self):\n    \"\"\"Tests the behavior of the default mode.\"\"\"\n\n    self.RunAndVerify(env_var_value=None, flag_value=None, should_fail=False)\n\n  def testThrowOnFailureEnvVar(self):\n    \"\"\"Tests using the GTEST_THROW_ON_FAILURE environment variable.\"\"\"\n\n    self.RunAndVerify(env_var_value='0',\n                      flag_value=None,\n                      should_fail=False)\n    self.RunAndVerify(env_var_value='1',\n                      flag_value=None,\n                      should_fail=True)\n\n  def testThrowOnFailureFlag(self):\n    \"\"\"Tests using the --gtest_throw_on_failure flag.\"\"\"\n\n    self.RunAndVerify(env_var_value=None,\n                      flag_value='0',\n                      should_fail=False)\n    self.RunAndVerify(env_var_value=None,\n                      flag_value='1',\n                      should_fail=True)\n\n  def testThrowOnFailureFlagOverridesEnvVar(self):\n    \"\"\"Tests that --gtest_throw_on_failure overrides GTEST_THROW_ON_FAILURE.\"\"\"\n\n    self.RunAndVerify(env_var_value='0',\n                      flag_value='0',\n                      should_fail=False)\n    self.RunAndVerify(env_var_value='0',\n                      flag_value='1',\n                      should_fail=True)\n    self.RunAndVerify(env_var_value='1',\n                      flag_value='0',\n                      should_fail=False)\n    self.RunAndVerify(env_var_value='1',\n                      flag_value='1',\n                      should_fail=True)\n\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_throw_on_failure_test_.cc",
    "content": "// Copyright 2009, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Tests Google Test's throw-on-failure mode with exceptions disabled.\n//\n// This program must be compiled with exceptions disabled.  It will be\n// invoked by gtest_throw_on_failure_test.py, and is expected to exit\n// with non-zero in the throw-on-failure mode or 0 otherwise.\n\n#include \"gtest/gtest.h\"\n\n#include <stdio.h>                      // for fflush, fprintf, NULL, etc.\n#include <stdlib.h>                     // for exit\n#include <exception>                    // for set_terminate\n\n// This terminate handler aborts the program using exit() rather than abort().\n// This avoids showing pop-ups on Windows systems and core dumps on Unix-like\n// ones.\nvoid TerminateHandler() {\n  fprintf(stderr, \"%s\\n\", \"Unhandled C++ exception terminating the program.\");\n  fflush(NULL);\n  exit(1);\n}\n\nint main(int argc, char** argv) {\n#if GTEST_HAS_EXCEPTIONS\n  std::set_terminate(&TerminateHandler);\n#endif\n  testing::InitGoogleTest(&argc, argv);\n\n  // We want to ensure that people can use Google Test assertions in\n  // other testing frameworks, as long as they initialize Google Test\n  // properly and set the throw-on-failure mode.  Therefore, we don't\n  // use Google Test's constructs for defining and running tests\n  // (e.g. TEST and RUN_ALL_TESTS) here.\n\n  // In the throw-on-failure mode with exceptions disabled, this\n  // assertion will cause the program to exit with a non-zero code.\n  EXPECT_EQ(2, 3);\n\n  // When not in the throw-on-failure mode, the control will reach\n  // here.\n  return 0;\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_uninitialized_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Verifies that Google Test warns the user when not initialized properly.\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport gtest_test_utils\n\n\nCOMMAND = gtest_test_utils.GetTestExecutablePath('gtest_uninitialized_test_')\n\n\ndef Assert(condition):\n  if not condition:\n    raise AssertionError\n\n\ndef AssertEq(expected, actual):\n  if expected != actual:\n    print('Expected: %s' % (expected,))\n    print('  Actual: %s' % (actual,))\n    raise AssertionError\n\n\ndef TestExitCodeAndOutput(command):\n  \"\"\"Runs the given command and verifies its exit code and output.\"\"\"\n\n  # Verifies that 'command' exits with code 1.\n  p = gtest_test_utils.Subprocess(command)\n  Assert(p.exited)\n  AssertEq(1, p.exit_code)\n  Assert('InitGoogleTest' in p.output)\n\n\nclass GTestUninitializedTest(gtest_test_utils.TestCase):\n  def testExitCodeAndOutput(self):\n    TestExitCodeAndOutput(COMMAND)\n\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_uninitialized_test_.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/gtest.h\"\n\nTEST(DummyTest, Dummy) {\n  // This test doesn't verify anything.  We just need it to create a\n  // realistic stage for testing the behavior of Google Test when\n  // RUN_ALL_TESTS() is called without testing::InitGoogleTest() being\n  // called first.\n}\n\nint main() {\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_unittest.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Tests for Google Test itself.  This verifies that the basic constructs of\n// Google Test work.\n\n#include \"gtest/gtest.h\"\n\n// Verifies that the command line flag variables can be accessed\n// in code once <gtest/gtest.h> has been #included.\n// Do not move it after other #includes.\nTEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {\n  bool dummy = testing::GTEST_FLAG(also_run_disabled_tests)\n      || testing::GTEST_FLAG(break_on_failure)\n      || testing::GTEST_FLAG(catch_exceptions)\n      || testing::GTEST_FLAG(color) != \"unknown\"\n      || testing::GTEST_FLAG(filter) != \"unknown\"\n      || testing::GTEST_FLAG(list_tests)\n      || testing::GTEST_FLAG(output) != \"unknown\"\n      || testing::GTEST_FLAG(print_time)\n      || testing::GTEST_FLAG(random_seed)\n      || testing::GTEST_FLAG(repeat) > 0\n      || testing::GTEST_FLAG(show_internal_stack_frames)\n      || testing::GTEST_FLAG(shuffle)\n      || testing::GTEST_FLAG(stack_trace_depth) > 0\n      || testing::GTEST_FLAG(stream_result_to) != \"unknown\"\n      || testing::GTEST_FLAG(throw_on_failure);\n  EXPECT_TRUE(dummy || !dummy);  // Suppresses warning that dummy is unused.\n}\n\n#include <limits.h>  // For INT_MAX.\n#include <stdlib.h>\n#include <string.h>\n#include <time.h>\n\n#include <map>\n#include <vector>\n#include <ostream>\n\n#include \"gtest/gtest-spi.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nnamespace testing {\nnamespace internal {\n\n#if GTEST_CAN_STREAM_RESULTS_\n\nclass StreamingListenerTest : public Test {\n public:\n  class FakeSocketWriter : public StreamingListener::AbstractSocketWriter {\n   public:\n    // Sends a string to the socket.\n    virtual void Send(const string& message) { output_ += message; }\n\n    string output_;\n  };\n\n  StreamingListenerTest()\n      : fake_sock_writer_(new FakeSocketWriter),\n        streamer_(fake_sock_writer_),\n        test_info_obj_(\"FooTest\", \"Bar\", NULL, NULL,\n                       CodeLocation(__FILE__, __LINE__), 0, NULL) {}\n\n protected:\n  string* output() { return &(fake_sock_writer_->output_); }\n\n  FakeSocketWriter* const fake_sock_writer_;\n  StreamingListener streamer_;\n  UnitTest unit_test_;\n  TestInfo test_info_obj_;  // The name test_info_ was taken by testing::Test.\n};\n\nTEST_F(StreamingListenerTest, OnTestProgramEnd) {\n  *output() = \"\";\n  streamer_.OnTestProgramEnd(unit_test_);\n  EXPECT_EQ(\"event=TestProgramEnd&passed=1\\n\", *output());\n}\n\nTEST_F(StreamingListenerTest, OnTestIterationEnd) {\n  *output() = \"\";\n  streamer_.OnTestIterationEnd(unit_test_, 42);\n  EXPECT_EQ(\"event=TestIterationEnd&passed=1&elapsed_time=0ms\\n\", *output());\n}\n\nTEST_F(StreamingListenerTest, OnTestCaseStart) {\n  *output() = \"\";\n  streamer_.OnTestCaseStart(TestCase(\"FooTest\", \"Bar\", NULL, NULL));\n  EXPECT_EQ(\"event=TestCaseStart&name=FooTest\\n\", *output());\n}\n\nTEST_F(StreamingListenerTest, OnTestCaseEnd) {\n  *output() = \"\";\n  streamer_.OnTestCaseEnd(TestCase(\"FooTest\", \"Bar\", NULL, NULL));\n  EXPECT_EQ(\"event=TestCaseEnd&passed=1&elapsed_time=0ms\\n\", *output());\n}\n\nTEST_F(StreamingListenerTest, OnTestStart) {\n  *output() = \"\";\n  streamer_.OnTestStart(test_info_obj_);\n  EXPECT_EQ(\"event=TestStart&name=Bar\\n\", *output());\n}\n\nTEST_F(StreamingListenerTest, OnTestEnd) {\n  *output() = \"\";\n  streamer_.OnTestEnd(test_info_obj_);\n  EXPECT_EQ(\"event=TestEnd&passed=1&elapsed_time=0ms\\n\", *output());\n}\n\nTEST_F(StreamingListenerTest, OnTestPartResult) {\n  *output() = \"\";\n  streamer_.OnTestPartResult(TestPartResult(\n      TestPartResult::kFatalFailure, \"foo.cc\", 42, \"failed=\\n&%\"));\n\n  // Meta characters in the failure message should be properly escaped.\n  EXPECT_EQ(\n      \"event=TestPartResult&file=foo.cc&line=42&message=failed%3D%0A%26%25\\n\",\n      *output());\n}\n\n#endif  // GTEST_CAN_STREAM_RESULTS_\n\n// Provides access to otherwise private parts of the TestEventListeners class\n// that are needed to test it.\nclass TestEventListenersAccessor {\n public:\n  static TestEventListener* GetRepeater(TestEventListeners* listeners) {\n    return listeners->repeater();\n  }\n\n  static void SetDefaultResultPrinter(TestEventListeners* listeners,\n                                      TestEventListener* listener) {\n    listeners->SetDefaultResultPrinter(listener);\n  }\n  static void SetDefaultXmlGenerator(TestEventListeners* listeners,\n                                     TestEventListener* listener) {\n    listeners->SetDefaultXmlGenerator(listener);\n  }\n\n  static bool EventForwardingEnabled(const TestEventListeners& listeners) {\n    return listeners.EventForwardingEnabled();\n  }\n\n  static void SuppressEventForwarding(TestEventListeners* listeners) {\n    listeners->SuppressEventForwarding();\n  }\n};\n\nclass UnitTestRecordPropertyTestHelper : public Test {\n protected:\n  UnitTestRecordPropertyTestHelper() {}\n\n  // Forwards to UnitTest::RecordProperty() to bypass access controls.\n  void UnitTestRecordProperty(const char* key, const std::string& value) {\n    unit_test_.RecordProperty(key, value);\n  }\n\n  UnitTest unit_test_;\n};\n\n}  // namespace internal\n}  // namespace testing\n\nusing testing::AssertionFailure;\nusing testing::AssertionResult;\nusing testing::AssertionSuccess;\nusing testing::DoubleLE;\nusing testing::EmptyTestEventListener;\nusing testing::Environment;\nusing testing::FloatLE;\nusing testing::GTEST_FLAG(also_run_disabled_tests);\nusing testing::GTEST_FLAG(break_on_failure);\nusing testing::GTEST_FLAG(catch_exceptions);\nusing testing::GTEST_FLAG(color);\nusing testing::GTEST_FLAG(death_test_use_fork);\nusing testing::GTEST_FLAG(filter);\nusing testing::GTEST_FLAG(list_tests);\nusing testing::GTEST_FLAG(output);\nusing testing::GTEST_FLAG(print_time);\nusing testing::GTEST_FLAG(random_seed);\nusing testing::GTEST_FLAG(repeat);\nusing testing::GTEST_FLAG(show_internal_stack_frames);\nusing testing::GTEST_FLAG(shuffle);\nusing testing::GTEST_FLAG(stack_trace_depth);\nusing testing::GTEST_FLAG(stream_result_to);\nusing testing::GTEST_FLAG(throw_on_failure);\nusing testing::IsNotSubstring;\nusing testing::IsSubstring;\nusing testing::Message;\nusing testing::ScopedFakeTestPartResultReporter;\nusing testing::StaticAssertTypeEq;\nusing testing::Test;\nusing testing::TestCase;\nusing testing::TestEventListeners;\nusing testing::TestInfo;\nusing testing::TestPartResult;\nusing testing::TestPartResultArray;\nusing testing::TestProperty;\nusing testing::TestResult;\nusing testing::TimeInMillis;\nusing testing::UnitTest;\nusing testing::internal::AddReference;\nusing testing::internal::AlwaysFalse;\nusing testing::internal::AlwaysTrue;\nusing testing::internal::AppendUserMessage;\nusing testing::internal::ArrayAwareFind;\nusing testing::internal::ArrayEq;\nusing testing::internal::CodePointToUtf8;\nusing testing::internal::CompileAssertTypesEqual;\nusing testing::internal::CopyArray;\nusing testing::internal::CountIf;\nusing testing::internal::EqFailure;\nusing testing::internal::FloatingPoint;\nusing testing::internal::ForEach;\nusing testing::internal::FormatEpochTimeInMillisAsIso8601;\nusing testing::internal::FormatTimeInMillisAsSeconds;\nusing testing::internal::GTestFlagSaver;\nusing testing::internal::GetCurrentOsStackTraceExceptTop;\nusing testing::internal::GetElementOr;\nusing testing::internal::GetNextRandomSeed;\nusing testing::internal::GetRandomSeedFromFlag;\nusing testing::internal::GetTestTypeId;\nusing testing::internal::GetTimeInMillis;\nusing testing::internal::GetTypeId;\nusing testing::internal::GetUnitTestImpl;\nusing testing::internal::ImplicitlyConvertible;\nusing testing::internal::Int32;\nusing testing::internal::Int32FromEnvOrDie;\nusing testing::internal::IsAProtocolMessage;\nusing testing::internal::IsContainer;\nusing testing::internal::IsContainerTest;\nusing testing::internal::IsNotContainer;\nusing testing::internal::NativeArray;\nusing testing::internal::ParseInt32Flag;\nusing testing::internal::RelationToSourceCopy;\nusing testing::internal::RelationToSourceReference;\nusing testing::internal::RemoveConst;\nusing testing::internal::RemoveReference;\nusing testing::internal::ShouldRunTestOnShard;\nusing testing::internal::ShouldShard;\nusing testing::internal::ShouldUseColor;\nusing testing::internal::Shuffle;\nusing testing::internal::ShuffleRange;\nusing testing::internal::SkipPrefix;\nusing testing::internal::StreamableToString;\nusing testing::internal::String;\nusing testing::internal::TestEventListenersAccessor;\nusing testing::internal::TestResultAccessor;\nusing testing::internal::UInt32;\nusing testing::internal::WideStringToUtf8;\nusing testing::internal::edit_distance::CalculateOptimalEdits;\nusing testing::internal::edit_distance::CreateUnifiedDiff;\nusing testing::internal::edit_distance::EditType;\nusing testing::internal::kMaxRandomSeed;\nusing testing::internal::kTestTypeIdInGoogleTest;\nusing testing::kMaxStackTraceDepth;\n\n#if GTEST_HAS_STREAM_REDIRECTION\nusing testing::internal::CaptureStdout;\nusing testing::internal::GetCapturedStdout;\n#endif\n\n#if GTEST_IS_THREADSAFE\nusing testing::internal::ThreadWithParam;\n#endif\n\nclass TestingVector : public std::vector<int> {\n};\n\n::std::ostream& operator<<(::std::ostream& os,\n                           const TestingVector& vector) {\n  os << \"{ \";\n  for (size_t i = 0; i < vector.size(); i++) {\n    os << vector[i] << \" \";\n  }\n  os << \"}\";\n  return os;\n}\n\n// This line tests that we can define tests in an unnamed namespace.\nnamespace {\n\nTEST(GetRandomSeedFromFlagTest, HandlesZero) {\n  const int seed = GetRandomSeedFromFlag(0);\n  EXPECT_LE(1, seed);\n  EXPECT_LE(seed, static_cast<int>(kMaxRandomSeed));\n}\n\nTEST(GetRandomSeedFromFlagTest, PreservesValidSeed) {\n  EXPECT_EQ(1, GetRandomSeedFromFlag(1));\n  EXPECT_EQ(2, GetRandomSeedFromFlag(2));\n  EXPECT_EQ(kMaxRandomSeed - 1, GetRandomSeedFromFlag(kMaxRandomSeed - 1));\n  EXPECT_EQ(static_cast<int>(kMaxRandomSeed),\n            GetRandomSeedFromFlag(kMaxRandomSeed));\n}\n\nTEST(GetRandomSeedFromFlagTest, NormalizesInvalidSeed) {\n  const int seed1 = GetRandomSeedFromFlag(-1);\n  EXPECT_LE(1, seed1);\n  EXPECT_LE(seed1, static_cast<int>(kMaxRandomSeed));\n\n  const int seed2 = GetRandomSeedFromFlag(kMaxRandomSeed + 1);\n  EXPECT_LE(1, seed2);\n  EXPECT_LE(seed2, static_cast<int>(kMaxRandomSeed));\n}\n\nTEST(GetNextRandomSeedTest, WorksForValidInput) {\n  EXPECT_EQ(2, GetNextRandomSeed(1));\n  EXPECT_EQ(3, GetNextRandomSeed(2));\n  EXPECT_EQ(static_cast<int>(kMaxRandomSeed),\n            GetNextRandomSeed(kMaxRandomSeed - 1));\n  EXPECT_EQ(1, GetNextRandomSeed(kMaxRandomSeed));\n\n  // We deliberately don't test GetNextRandomSeed() with invalid\n  // inputs, as that requires death tests, which are expensive.  This\n  // is fine as GetNextRandomSeed() is internal and has a\n  // straightforward definition.\n}\n\nstatic void ClearCurrentTestPartResults() {\n  TestResultAccessor::ClearTestPartResults(\n      GetUnitTestImpl()->current_test_result());\n}\n\n// Tests GetTypeId.\n\nTEST(GetTypeIdTest, ReturnsSameValueForSameType) {\n  EXPECT_EQ(GetTypeId<int>(), GetTypeId<int>());\n  EXPECT_EQ(GetTypeId<Test>(), GetTypeId<Test>());\n}\n\nclass SubClassOfTest : public Test {};\nclass AnotherSubClassOfTest : public Test {};\n\nTEST(GetTypeIdTest, ReturnsDifferentValuesForDifferentTypes) {\n  EXPECT_NE(GetTypeId<int>(), GetTypeId<const int>());\n  EXPECT_NE(GetTypeId<int>(), GetTypeId<char>());\n  EXPECT_NE(GetTypeId<int>(), GetTestTypeId());\n  EXPECT_NE(GetTypeId<SubClassOfTest>(), GetTestTypeId());\n  EXPECT_NE(GetTypeId<AnotherSubClassOfTest>(), GetTestTypeId());\n  EXPECT_NE(GetTypeId<AnotherSubClassOfTest>(), GetTypeId<SubClassOfTest>());\n}\n\n// Verifies that GetTestTypeId() returns the same value, no matter it\n// is called from inside Google Test or outside of it.\nTEST(GetTestTypeIdTest, ReturnsTheSameValueInsideOrOutsideOfGoogleTest) {\n  EXPECT_EQ(kTestTypeIdInGoogleTest, GetTestTypeId());\n}\n\n// Tests FormatTimeInMillisAsSeconds().\n\nTEST(FormatTimeInMillisAsSecondsTest, FormatsZero) {\n  EXPECT_EQ(\"0\", FormatTimeInMillisAsSeconds(0));\n}\n\nTEST(FormatTimeInMillisAsSecondsTest, FormatsPositiveNumber) {\n  EXPECT_EQ(\"0.003\", FormatTimeInMillisAsSeconds(3));\n  EXPECT_EQ(\"0.01\", FormatTimeInMillisAsSeconds(10));\n  EXPECT_EQ(\"0.2\", FormatTimeInMillisAsSeconds(200));\n  EXPECT_EQ(\"1.2\", FormatTimeInMillisAsSeconds(1200));\n  EXPECT_EQ(\"3\", FormatTimeInMillisAsSeconds(3000));\n}\n\nTEST(FormatTimeInMillisAsSecondsTest, FormatsNegativeNumber) {\n  EXPECT_EQ(\"-0.003\", FormatTimeInMillisAsSeconds(-3));\n  EXPECT_EQ(\"-0.01\", FormatTimeInMillisAsSeconds(-10));\n  EXPECT_EQ(\"-0.2\", FormatTimeInMillisAsSeconds(-200));\n  EXPECT_EQ(\"-1.2\", FormatTimeInMillisAsSeconds(-1200));\n  EXPECT_EQ(\"-3\", FormatTimeInMillisAsSeconds(-3000));\n}\n\n// Tests FormatEpochTimeInMillisAsIso8601().  The correctness of conversion\n// for particular dates below was verified in Python using\n// datetime.datetime.fromutctimestamp(<timetamp>/1000).\n\n// FormatEpochTimeInMillisAsIso8601 depends on the current timezone, so we\n// have to set up a particular timezone to obtain predictable results.\nclass FormatEpochTimeInMillisAsIso8601Test : public Test {\n public:\n  // On Cygwin, GCC doesn't allow unqualified integer literals to exceed\n  // 32 bits, even when 64-bit integer types are available.  We have to\n  // force the constants to have a 64-bit type here.\n  static const TimeInMillis kMillisPerSec = 1000;\n\n private:\n  virtual void SetUp() {\n    saved_tz_ = NULL;\n\n    GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996 /* getenv, strdup: deprecated */)\n    if (getenv(\"TZ\"))\n      saved_tz_ = strdup(getenv(\"TZ\"));\n    GTEST_DISABLE_MSC_WARNINGS_POP_()\n\n    // Set up the time zone for FormatEpochTimeInMillisAsIso8601 to use.  We\n    // cannot use the local time zone because the function's output depends\n    // on the time zone.\n    SetTimeZone(\"UTC+00\");\n  }\n\n  virtual void TearDown() {\n    SetTimeZone(saved_tz_);\n    free(const_cast<char*>(saved_tz_));\n    saved_tz_ = NULL;\n  }\n\n  static void SetTimeZone(const char* time_zone) {\n    // tzset() distinguishes between the TZ variable being present and empty\n    // and not being present, so we have to consider the case of time_zone\n    // being NULL.\n#if _MSC_VER\n    // ...Unless it's MSVC, whose standard library's _putenv doesn't\n    // distinguish between an empty and a missing variable.\n    const std::string env_var =\n        std::string(\"TZ=\") + (time_zone ? time_zone : \"\");\n    _putenv(env_var.c_str());\n    GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996 /* deprecated function */)\n    tzset();\n    GTEST_DISABLE_MSC_WARNINGS_POP_()\n#else\n    if (time_zone) {\n      setenv((\"TZ\"), time_zone, 1);\n    } else {\n      unsetenv(\"TZ\");\n    }\n    tzset();\n#endif\n  }\n\n  const char* saved_tz_;\n};\n\nconst TimeInMillis FormatEpochTimeInMillisAsIso8601Test::kMillisPerSec;\n\nTEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsTwoDigitSegments) {\n  EXPECT_EQ(\"2011-10-31T18:52:42\",\n            FormatEpochTimeInMillisAsIso8601(1320087162 * kMillisPerSec));\n}\n\nTEST_F(FormatEpochTimeInMillisAsIso8601Test, MillisecondsDoNotAffectResult) {\n  EXPECT_EQ(\n      \"2011-10-31T18:52:42\",\n      FormatEpochTimeInMillisAsIso8601(1320087162 * kMillisPerSec + 234));\n}\n\nTEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsLeadingZeroes) {\n  EXPECT_EQ(\"2011-09-03T05:07:02\",\n            FormatEpochTimeInMillisAsIso8601(1315026422 * kMillisPerSec));\n}\n\nTEST_F(FormatEpochTimeInMillisAsIso8601Test, Prints24HourTime) {\n  EXPECT_EQ(\"2011-09-28T17:08:22\",\n            FormatEpochTimeInMillisAsIso8601(1317229702 * kMillisPerSec));\n}\n\nTEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsEpochStart) {\n  EXPECT_EQ(\"1970-01-01T00:00:00\", FormatEpochTimeInMillisAsIso8601(0));\n}\n\n#if GTEST_CAN_COMPARE_NULL\n\n# ifdef __BORLANDC__\n// Silences warnings: \"Condition is always true\", \"Unreachable code\"\n#  pragma option push -w-ccc -w-rch\n# endif\n\n// Tests that GTEST_IS_NULL_LITERAL_(x) is true when x is a null\n// pointer literal.\nTEST(NullLiteralTest, IsTrueForNullLiterals) {\n  EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(NULL));\n  EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0));\n  EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0U));\n  EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0L));\n}\n\n// Tests that GTEST_IS_NULL_LITERAL_(x) is false when x is not a null\n// pointer literal.\nTEST(NullLiteralTest, IsFalseForNonNullLiterals) {\n  EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(1));\n  EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(0.0));\n  EXPECT_FALSE(GTEST_IS_NULL_LITERAL_('a'));\n  EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(static_cast<void*>(NULL)));\n}\n\n# ifdef __BORLANDC__\n// Restores warnings after previous \"#pragma option push\" suppressed them.\n#  pragma option pop\n# endif\n\n#endif  // GTEST_CAN_COMPARE_NULL\n//\n// Tests CodePointToUtf8().\n\n// Tests that the NUL character L'\\0' is encoded correctly.\nTEST(CodePointToUtf8Test, CanEncodeNul) {\n  EXPECT_EQ(\"\", CodePointToUtf8(L'\\0'));\n}\n\n// Tests that ASCII characters are encoded correctly.\nTEST(CodePointToUtf8Test, CanEncodeAscii) {\n  EXPECT_EQ(\"a\", CodePointToUtf8(L'a'));\n  EXPECT_EQ(\"Z\", CodePointToUtf8(L'Z'));\n  EXPECT_EQ(\"&\", CodePointToUtf8(L'&'));\n  EXPECT_EQ(\"\\x7F\", CodePointToUtf8(L'\\x7F'));\n}\n\n// Tests that Unicode code-points that have 8 to 11 bits are encoded\n// as 110xxxxx 10xxxxxx.\nTEST(CodePointToUtf8Test, CanEncode8To11Bits) {\n  // 000 1101 0011 => 110-00011 10-010011\n  EXPECT_EQ(\"\\xC3\\x93\", CodePointToUtf8(L'\\xD3'));\n\n  // 101 0111 0110 => 110-10101 10-110110\n  // Some compilers (e.g., GCC on MinGW) cannot handle non-ASCII codepoints\n  // in wide strings and wide chars. In order to accomodate them, we have to\n  // introduce such character constants as integers.\n  EXPECT_EQ(\"\\xD5\\xB6\",\n            CodePointToUtf8(static_cast<wchar_t>(0x576)));\n}\n\n// Tests that Unicode code-points that have 12 to 16 bits are encoded\n// as 1110xxxx 10xxxxxx 10xxxxxx.\nTEST(CodePointToUtf8Test, CanEncode12To16Bits) {\n  // 0000 1000 1101 0011 => 1110-0000 10-100011 10-010011\n  EXPECT_EQ(\"\\xE0\\xA3\\x93\",\n            CodePointToUtf8(static_cast<wchar_t>(0x8D3)));\n\n  // 1100 0111 0100 1101 => 1110-1100 10-011101 10-001101\n  EXPECT_EQ(\"\\xEC\\x9D\\x8D\",\n            CodePointToUtf8(static_cast<wchar_t>(0xC74D)));\n}\n\n#if !GTEST_WIDE_STRING_USES_UTF16_\n// Tests in this group require a wchar_t to hold > 16 bits, and thus\n// are skipped on Windows, Cygwin, and Symbian, where a wchar_t is\n// 16-bit wide. This code may not compile on those systems.\n\n// Tests that Unicode code-points that have 17 to 21 bits are encoded\n// as 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx.\nTEST(CodePointToUtf8Test, CanEncode17To21Bits) {\n  // 0 0001 0000 1000 1101 0011 => 11110-000 10-010000 10-100011 10-010011\n  EXPECT_EQ(\"\\xF0\\x90\\xA3\\x93\", CodePointToUtf8(L'\\x108D3'));\n\n  // 0 0001 0000 0100 0000 0000 => 11110-000 10-010000 10-010000 10-000000\n  EXPECT_EQ(\"\\xF0\\x90\\x90\\x80\", CodePointToUtf8(L'\\x10400'));\n\n  // 1 0000 1000 0110 0011 0100 => 11110-100 10-001000 10-011000 10-110100\n  EXPECT_EQ(\"\\xF4\\x88\\x98\\xB4\", CodePointToUtf8(L'\\x108634'));\n}\n\n// Tests that encoding an invalid code-point generates the expected result.\nTEST(CodePointToUtf8Test, CanEncodeInvalidCodePoint) {\n  EXPECT_EQ(\"(Invalid Unicode 0x1234ABCD)\", CodePointToUtf8(L'\\x1234ABCD'));\n}\n\n#endif  // !GTEST_WIDE_STRING_USES_UTF16_\n\n// Tests WideStringToUtf8().\n\n// Tests that the NUL character L'\\0' is encoded correctly.\nTEST(WideStringToUtf8Test, CanEncodeNul) {\n  EXPECT_STREQ(\"\", WideStringToUtf8(L\"\", 0).c_str());\n  EXPECT_STREQ(\"\", WideStringToUtf8(L\"\", -1).c_str());\n}\n\n// Tests that ASCII strings are encoded correctly.\nTEST(WideStringToUtf8Test, CanEncodeAscii) {\n  EXPECT_STREQ(\"a\", WideStringToUtf8(L\"a\", 1).c_str());\n  EXPECT_STREQ(\"ab\", WideStringToUtf8(L\"ab\", 2).c_str());\n  EXPECT_STREQ(\"a\", WideStringToUtf8(L\"a\", -1).c_str());\n  EXPECT_STREQ(\"ab\", WideStringToUtf8(L\"ab\", -1).c_str());\n}\n\n// Tests that Unicode code-points that have 8 to 11 bits are encoded\n// as 110xxxxx 10xxxxxx.\nTEST(WideStringToUtf8Test, CanEncode8To11Bits) {\n  // 000 1101 0011 => 110-00011 10-010011\n  EXPECT_STREQ(\"\\xC3\\x93\", WideStringToUtf8(L\"\\xD3\", 1).c_str());\n  EXPECT_STREQ(\"\\xC3\\x93\", WideStringToUtf8(L\"\\xD3\", -1).c_str());\n\n  // 101 0111 0110 => 110-10101 10-110110\n  const wchar_t s[] = { 0x576, '\\0' };\n  EXPECT_STREQ(\"\\xD5\\xB6\", WideStringToUtf8(s, 1).c_str());\n  EXPECT_STREQ(\"\\xD5\\xB6\", WideStringToUtf8(s, -1).c_str());\n}\n\n// Tests that Unicode code-points that have 12 to 16 bits are encoded\n// as 1110xxxx 10xxxxxx 10xxxxxx.\nTEST(WideStringToUtf8Test, CanEncode12To16Bits) {\n  // 0000 1000 1101 0011 => 1110-0000 10-100011 10-010011\n  const wchar_t s1[] = { 0x8D3, '\\0' };\n  EXPECT_STREQ(\"\\xE0\\xA3\\x93\", WideStringToUtf8(s1, 1).c_str());\n  EXPECT_STREQ(\"\\xE0\\xA3\\x93\", WideStringToUtf8(s1, -1).c_str());\n\n  // 1100 0111 0100 1101 => 1110-1100 10-011101 10-001101\n  const wchar_t s2[] = { 0xC74D, '\\0' };\n  EXPECT_STREQ(\"\\xEC\\x9D\\x8D\", WideStringToUtf8(s2, 1).c_str());\n  EXPECT_STREQ(\"\\xEC\\x9D\\x8D\", WideStringToUtf8(s2, -1).c_str());\n}\n\n// Tests that the conversion stops when the function encounters \\0 character.\nTEST(WideStringToUtf8Test, StopsOnNulCharacter) {\n  EXPECT_STREQ(\"ABC\", WideStringToUtf8(L\"ABC\\0XYZ\", 100).c_str());\n}\n\n// Tests that the conversion stops when the function reaches the limit\n// specified by the 'length' parameter.\nTEST(WideStringToUtf8Test, StopsWhenLengthLimitReached) {\n  EXPECT_STREQ(\"ABC\", WideStringToUtf8(L\"ABCDEF\", 3).c_str());\n}\n\n#if !GTEST_WIDE_STRING_USES_UTF16_\n// Tests that Unicode code-points that have 17 to 21 bits are encoded\n// as 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx. This code may not compile\n// on the systems using UTF-16 encoding.\nTEST(WideStringToUtf8Test, CanEncode17To21Bits) {\n  // 0 0001 0000 1000 1101 0011 => 11110-000 10-010000 10-100011 10-010011\n  EXPECT_STREQ(\"\\xF0\\x90\\xA3\\x93\", WideStringToUtf8(L\"\\x108D3\", 1).c_str());\n  EXPECT_STREQ(\"\\xF0\\x90\\xA3\\x93\", WideStringToUtf8(L\"\\x108D3\", -1).c_str());\n\n  // 1 0000 1000 0110 0011 0100 => 11110-100 10-001000 10-011000 10-110100\n  EXPECT_STREQ(\"\\xF4\\x88\\x98\\xB4\", WideStringToUtf8(L\"\\x108634\", 1).c_str());\n  EXPECT_STREQ(\"\\xF4\\x88\\x98\\xB4\", WideStringToUtf8(L\"\\x108634\", -1).c_str());\n}\n\n// Tests that encoding an invalid code-point generates the expected result.\nTEST(WideStringToUtf8Test, CanEncodeInvalidCodePoint) {\n  EXPECT_STREQ(\"(Invalid Unicode 0xABCDFF)\",\n               WideStringToUtf8(L\"\\xABCDFF\", -1).c_str());\n}\n#else  // !GTEST_WIDE_STRING_USES_UTF16_\n// Tests that surrogate pairs are encoded correctly on the systems using\n// UTF-16 encoding in the wide strings.\nTEST(WideStringToUtf8Test, CanEncodeValidUtf16SUrrogatePairs) {\n  const wchar_t s[] = { 0xD801, 0xDC00, '\\0' };\n  EXPECT_STREQ(\"\\xF0\\x90\\x90\\x80\", WideStringToUtf8(s, -1).c_str());\n}\n\n// Tests that encoding an invalid UTF-16 surrogate pair\n// generates the expected result.\nTEST(WideStringToUtf8Test, CanEncodeInvalidUtf16SurrogatePair) {\n  // Leading surrogate is at the end of the string.\n  const wchar_t s1[] = { 0xD800, '\\0' };\n  EXPECT_STREQ(\"\\xED\\xA0\\x80\", WideStringToUtf8(s1, -1).c_str());\n  // Leading surrogate is not followed by the trailing surrogate.\n  const wchar_t s2[] = { 0xD800, 'M', '\\0' };\n  EXPECT_STREQ(\"\\xED\\xA0\\x80M\", WideStringToUtf8(s2, -1).c_str());\n  // Trailing surrogate appearas without a leading surrogate.\n  const wchar_t s3[] = { 0xDC00, 'P', 'Q', 'R', '\\0' };\n  EXPECT_STREQ(\"\\xED\\xB0\\x80PQR\", WideStringToUtf8(s3, -1).c_str());\n}\n#endif  // !GTEST_WIDE_STRING_USES_UTF16_\n\n// Tests that codepoint concatenation works correctly.\n#if !GTEST_WIDE_STRING_USES_UTF16_\nTEST(WideStringToUtf8Test, ConcatenatesCodepointsCorrectly) {\n  const wchar_t s[] = { 0x108634, 0xC74D, '\\n', 0x576, 0x8D3, 0x108634, '\\0'};\n  EXPECT_STREQ(\n      \"\\xF4\\x88\\x98\\xB4\"\n          \"\\xEC\\x9D\\x8D\"\n          \"\\n\"\n          \"\\xD5\\xB6\"\n          \"\\xE0\\xA3\\x93\"\n          \"\\xF4\\x88\\x98\\xB4\",\n      WideStringToUtf8(s, -1).c_str());\n}\n#else\nTEST(WideStringToUtf8Test, ConcatenatesCodepointsCorrectly) {\n  const wchar_t s[] = { 0xC74D, '\\n', 0x576, 0x8D3, '\\0'};\n  EXPECT_STREQ(\n      \"\\xEC\\x9D\\x8D\" \"\\n\" \"\\xD5\\xB6\" \"\\xE0\\xA3\\x93\",\n      WideStringToUtf8(s, -1).c_str());\n}\n#endif  // !GTEST_WIDE_STRING_USES_UTF16_\n\n// Tests the Random class.\n\nTEST(RandomDeathTest, GeneratesCrashesOnInvalidRange) {\n  testing::internal::Random random(42);\n  EXPECT_DEATH_IF_SUPPORTED(\n      random.Generate(0),\n      \"Cannot generate a number in the range \\\\[0, 0\\\\)\");\n  EXPECT_DEATH_IF_SUPPORTED(\n      random.Generate(testing::internal::Random::kMaxRange + 1),\n      \"Generation of a number in \\\\[0, 2147483649\\\\) was requested, \"\n      \"but this can only generate numbers in \\\\[0, 2147483648\\\\)\");\n}\n\nTEST(RandomTest, GeneratesNumbersWithinRange) {\n  const UInt32 kRange = 10000;\n  testing::internal::Random random(12345);\n  for (int i = 0; i < 10; i++) {\n    EXPECT_LT(random.Generate(kRange), kRange) << \" for iteration \" << i;\n  }\n\n  testing::internal::Random random2(testing::internal::Random::kMaxRange);\n  for (int i = 0; i < 10; i++) {\n    EXPECT_LT(random2.Generate(kRange), kRange) << \" for iteration \" << i;\n  }\n}\n\nTEST(RandomTest, RepeatsWhenReseeded) {\n  const int kSeed = 123;\n  const int kArraySize = 10;\n  const UInt32 kRange = 10000;\n  UInt32 values[kArraySize];\n\n  testing::internal::Random random(kSeed);\n  for (int i = 0; i < kArraySize; i++) {\n    values[i] = random.Generate(kRange);\n  }\n\n  random.Reseed(kSeed);\n  for (int i = 0; i < kArraySize; i++) {\n    EXPECT_EQ(values[i], random.Generate(kRange)) << \" for iteration \" << i;\n  }\n}\n\n// Tests STL container utilities.\n\n// Tests CountIf().\n\nstatic bool IsPositive(int n) { return n > 0; }\n\nTEST(ContainerUtilityTest, CountIf) {\n  std::vector<int> v;\n  EXPECT_EQ(0, CountIf(v, IsPositive));  // Works for an empty container.\n\n  v.push_back(-1);\n  v.push_back(0);\n  EXPECT_EQ(0, CountIf(v, IsPositive));  // Works when no value satisfies.\n\n  v.push_back(2);\n  v.push_back(-10);\n  v.push_back(10);\n  EXPECT_EQ(2, CountIf(v, IsPositive));\n}\n\n// Tests ForEach().\n\nstatic int g_sum = 0;\nstatic void Accumulate(int n) { g_sum += n; }\n\nTEST(ContainerUtilityTest, ForEach) {\n  std::vector<int> v;\n  g_sum = 0;\n  ForEach(v, Accumulate);\n  EXPECT_EQ(0, g_sum);  // Works for an empty container;\n\n  g_sum = 0;\n  v.push_back(1);\n  ForEach(v, Accumulate);\n  EXPECT_EQ(1, g_sum);  // Works for a container with one element.\n\n  g_sum = 0;\n  v.push_back(20);\n  v.push_back(300);\n  ForEach(v, Accumulate);\n  EXPECT_EQ(321, g_sum);\n}\n\n// Tests GetElementOr().\nTEST(ContainerUtilityTest, GetElementOr) {\n  std::vector<char> a;\n  EXPECT_EQ('x', GetElementOr(a, 0, 'x'));\n\n  a.push_back('a');\n  a.push_back('b');\n  EXPECT_EQ('a', GetElementOr(a, 0, 'x'));\n  EXPECT_EQ('b', GetElementOr(a, 1, 'x'));\n  EXPECT_EQ('x', GetElementOr(a, -2, 'x'));\n  EXPECT_EQ('x', GetElementOr(a, 2, 'x'));\n}\n\nTEST(ContainerUtilityDeathTest, ShuffleRange) {\n  std::vector<int> a;\n  a.push_back(0);\n  a.push_back(1);\n  a.push_back(2);\n  testing::internal::Random random(1);\n\n  EXPECT_DEATH_IF_SUPPORTED(\n      ShuffleRange(&random, -1, 1, &a),\n      \"Invalid shuffle range start -1: must be in range \\\\[0, 3\\\\]\");\n  EXPECT_DEATH_IF_SUPPORTED(\n      ShuffleRange(&random, 4, 4, &a),\n      \"Invalid shuffle range start 4: must be in range \\\\[0, 3\\\\]\");\n  EXPECT_DEATH_IF_SUPPORTED(\n      ShuffleRange(&random, 3, 2, &a),\n      \"Invalid shuffle range finish 2: must be in range \\\\[3, 3\\\\]\");\n  EXPECT_DEATH_IF_SUPPORTED(\n      ShuffleRange(&random, 3, 4, &a),\n      \"Invalid shuffle range finish 4: must be in range \\\\[3, 3\\\\]\");\n}\n\nclass VectorShuffleTest : public Test {\n protected:\n  static const int kVectorSize = 20;\n\n  VectorShuffleTest() : random_(1) {\n    for (int i = 0; i < kVectorSize; i++) {\n      vector_.push_back(i);\n    }\n  }\n\n  static bool VectorIsCorrupt(const TestingVector& vector) {\n    if (kVectorSize != static_cast<int>(vector.size())) {\n      return true;\n    }\n\n    bool found_in_vector[kVectorSize] = { false };\n    for (size_t i = 0; i < vector.size(); i++) {\n      const int e = vector[i];\n      if (e < 0 || e >= kVectorSize || found_in_vector[e]) {\n        return true;\n      }\n      found_in_vector[e] = true;\n    }\n\n    // Vector size is correct, elements' range is correct, no\n    // duplicate elements.  Therefore no corruption has occurred.\n    return false;\n  }\n\n  static bool VectorIsNotCorrupt(const TestingVector& vector) {\n    return !VectorIsCorrupt(vector);\n  }\n\n  static bool RangeIsShuffled(const TestingVector& vector, int begin, int end) {\n    for (int i = begin; i < end; i++) {\n      if (i != vector[i]) {\n        return true;\n      }\n    }\n    return false;\n  }\n\n  static bool RangeIsUnshuffled(\n      const TestingVector& vector, int begin, int end) {\n    return !RangeIsShuffled(vector, begin, end);\n  }\n\n  static bool VectorIsShuffled(const TestingVector& vector) {\n    return RangeIsShuffled(vector, 0, static_cast<int>(vector.size()));\n  }\n\n  static bool VectorIsUnshuffled(const TestingVector& vector) {\n    return !VectorIsShuffled(vector);\n  }\n\n  testing::internal::Random random_;\n  TestingVector vector_;\n};  // class VectorShuffleTest\n\nconst int VectorShuffleTest::kVectorSize;\n\nTEST_F(VectorShuffleTest, HandlesEmptyRange) {\n  // Tests an empty range at the beginning...\n  ShuffleRange(&random_, 0, 0, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsUnshuffled, vector_);\n\n  // ...in the middle...\n  ShuffleRange(&random_, kVectorSize/2, kVectorSize/2, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsUnshuffled, vector_);\n\n  // ...at the end...\n  ShuffleRange(&random_, kVectorSize - 1, kVectorSize - 1, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsUnshuffled, vector_);\n\n  // ...and past the end.\n  ShuffleRange(&random_, kVectorSize, kVectorSize, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsUnshuffled, vector_);\n}\n\nTEST_F(VectorShuffleTest, HandlesRangeOfSizeOne) {\n  // Tests a size one range at the beginning...\n  ShuffleRange(&random_, 0, 1, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsUnshuffled, vector_);\n\n  // ...in the middle...\n  ShuffleRange(&random_, kVectorSize/2, kVectorSize/2 + 1, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsUnshuffled, vector_);\n\n  // ...and at the end.\n  ShuffleRange(&random_, kVectorSize - 1, kVectorSize, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsUnshuffled, vector_);\n}\n\n// Because we use our own random number generator and a fixed seed,\n// we can guarantee that the following \"random\" tests will succeed.\n\nTEST_F(VectorShuffleTest, ShufflesEntireVector) {\n  Shuffle(&random_, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  EXPECT_FALSE(VectorIsUnshuffled(vector_)) << vector_;\n\n  // Tests the first and last elements in particular to ensure that\n  // there are no off-by-one problems in our shuffle algorithm.\n  EXPECT_NE(0, vector_[0]);\n  EXPECT_NE(kVectorSize - 1, vector_[kVectorSize - 1]);\n}\n\nTEST_F(VectorShuffleTest, ShufflesStartOfVector) {\n  const int kRangeSize = kVectorSize/2;\n\n  ShuffleRange(&random_, 0, kRangeSize, &vector_);\n\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  EXPECT_PRED3(RangeIsShuffled, vector_, 0, kRangeSize);\n  EXPECT_PRED3(RangeIsUnshuffled, vector_, kRangeSize, kVectorSize);\n}\n\nTEST_F(VectorShuffleTest, ShufflesEndOfVector) {\n  const int kRangeSize = kVectorSize / 2;\n  ShuffleRange(&random_, kRangeSize, kVectorSize, &vector_);\n\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  EXPECT_PRED3(RangeIsUnshuffled, vector_, 0, kRangeSize);\n  EXPECT_PRED3(RangeIsShuffled, vector_, kRangeSize, kVectorSize);\n}\n\nTEST_F(VectorShuffleTest, ShufflesMiddleOfVector) {\n  int kRangeSize = kVectorSize/3;\n  ShuffleRange(&random_, kRangeSize, 2*kRangeSize, &vector_);\n\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  EXPECT_PRED3(RangeIsUnshuffled, vector_, 0, kRangeSize);\n  EXPECT_PRED3(RangeIsShuffled, vector_, kRangeSize, 2*kRangeSize);\n  EXPECT_PRED3(RangeIsUnshuffled, vector_, 2*kRangeSize, kVectorSize);\n}\n\nTEST_F(VectorShuffleTest, ShufflesRepeatably) {\n  TestingVector vector2;\n  for (int i = 0; i < kVectorSize; i++) {\n    vector2.push_back(i);\n  }\n\n  random_.Reseed(1234);\n  Shuffle(&random_, &vector_);\n  random_.Reseed(1234);\n  Shuffle(&random_, &vector2);\n\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector2);\n\n  for (int i = 0; i < kVectorSize; i++) {\n    EXPECT_EQ(vector_[i], vector2[i]) << \" where i is \" << i;\n  }\n}\n\n// Tests the size of the AssertHelper class.\n\nTEST(AssertHelperTest, AssertHelperIsSmall) {\n  // To avoid breaking clients that use lots of assertions in one\n  // function, we cannot grow the size of AssertHelper.\n  EXPECT_LE(sizeof(testing::internal::AssertHelper), sizeof(void*));\n}\n\n// Tests String::EndsWithCaseInsensitive().\nTEST(StringTest, EndsWithCaseInsensitive) {\n  EXPECT_TRUE(String::EndsWithCaseInsensitive(\"foobar\", \"BAR\"));\n  EXPECT_TRUE(String::EndsWithCaseInsensitive(\"foobaR\", \"bar\"));\n  EXPECT_TRUE(String::EndsWithCaseInsensitive(\"foobar\", \"\"));\n  EXPECT_TRUE(String::EndsWithCaseInsensitive(\"\", \"\"));\n\n  EXPECT_FALSE(String::EndsWithCaseInsensitive(\"Foobar\", \"foo\"));\n  EXPECT_FALSE(String::EndsWithCaseInsensitive(\"foobar\", \"Foo\"));\n  EXPECT_FALSE(String::EndsWithCaseInsensitive(\"\", \"foo\"));\n}\n\n// C++Builder's preprocessor is buggy; it fails to expand macros that\n// appear in macro parameters after wide char literals.  Provide an alias\n// for NULL as a workaround.\nstatic const wchar_t* const kNull = NULL;\n\n// Tests String::CaseInsensitiveWideCStringEquals\nTEST(StringTest, CaseInsensitiveWideCStringEquals) {\n  EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(NULL, NULL));\n  EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(kNull, L\"\"));\n  EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(L\"\", kNull));\n  EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(kNull, L\"foobar\"));\n  EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(L\"foobar\", kNull));\n  EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(L\"foobar\", L\"foobar\"));\n  EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(L\"foobar\", L\"FOOBAR\"));\n  EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(L\"FOOBAR\", L\"foobar\"));\n}\n\n#if GTEST_OS_WINDOWS\n\n// Tests String::ShowWideCString().\nTEST(StringTest, ShowWideCString) {\n  EXPECT_STREQ(\"(null)\",\n               String::ShowWideCString(NULL).c_str());\n  EXPECT_STREQ(\"\", String::ShowWideCString(L\"\").c_str());\n  EXPECT_STREQ(\"foo\", String::ShowWideCString(L\"foo\").c_str());\n}\n\n# if GTEST_OS_WINDOWS_MOBILE\nTEST(StringTest, AnsiAndUtf16Null) {\n  EXPECT_EQ(NULL, String::AnsiToUtf16(NULL));\n  EXPECT_EQ(NULL, String::Utf16ToAnsi(NULL));\n}\n\nTEST(StringTest, AnsiAndUtf16ConvertBasic) {\n  const char* ansi = String::Utf16ToAnsi(L\"str\");\n  EXPECT_STREQ(\"str\", ansi);\n  delete [] ansi;\n  const WCHAR* utf16 = String::AnsiToUtf16(\"str\");\n  EXPECT_EQ(0, wcsncmp(L\"str\", utf16, 3));\n  delete [] utf16;\n}\n\nTEST(StringTest, AnsiAndUtf16ConvertPathChars) {\n  const char* ansi = String::Utf16ToAnsi(L\".:\\\\ \\\"*?\");\n  EXPECT_STREQ(\".:\\\\ \\\"*?\", ansi);\n  delete [] ansi;\n  const WCHAR* utf16 = String::AnsiToUtf16(\".:\\\\ \\\"*?\");\n  EXPECT_EQ(0, wcsncmp(L\".:\\\\ \\\"*?\", utf16, 3));\n  delete [] utf16;\n}\n# endif  // GTEST_OS_WINDOWS_MOBILE\n\n#endif  // GTEST_OS_WINDOWS\n\n// Tests TestProperty construction.\nTEST(TestPropertyTest, StringValue) {\n  TestProperty property(\"key\", \"1\");\n  EXPECT_STREQ(\"key\", property.key());\n  EXPECT_STREQ(\"1\", property.value());\n}\n\n// Tests TestProperty replacing a value.\nTEST(TestPropertyTest, ReplaceStringValue) {\n  TestProperty property(\"key\", \"1\");\n  EXPECT_STREQ(\"1\", property.value());\n  property.SetValue(\"2\");\n  EXPECT_STREQ(\"2\", property.value());\n}\n\n// AddFatalFailure() and AddNonfatalFailure() must be stand-alone\n// functions (i.e. their definitions cannot be inlined at the call\n// sites), or C++Builder won't compile the code.\nstatic void AddFatalFailure() {\n  FAIL() << \"Expected fatal failure.\";\n}\n\nstatic void AddNonfatalFailure() {\n  ADD_FAILURE() << \"Expected non-fatal failure.\";\n}\n\nclass ScopedFakeTestPartResultReporterTest : public Test {\n public:  // Must be public and not protected due to a bug in g++ 3.4.2.\n  enum FailureMode {\n    FATAL_FAILURE,\n    NONFATAL_FAILURE\n  };\n  static void AddFailure(FailureMode failure) {\n    if (failure == FATAL_FAILURE) {\n      AddFatalFailure();\n    } else {\n      AddNonfatalFailure();\n    }\n  }\n};\n\n// Tests that ScopedFakeTestPartResultReporter intercepts test\n// failures.\nTEST_F(ScopedFakeTestPartResultReporterTest, InterceptsTestFailures) {\n  TestPartResultArray results;\n  {\n    ScopedFakeTestPartResultReporter reporter(\n        ScopedFakeTestPartResultReporter::INTERCEPT_ONLY_CURRENT_THREAD,\n        &results);\n    AddFailure(NONFATAL_FAILURE);\n    AddFailure(FATAL_FAILURE);\n  }\n\n  EXPECT_EQ(2, results.size());\n  EXPECT_TRUE(results.GetTestPartResult(0).nonfatally_failed());\n  EXPECT_TRUE(results.GetTestPartResult(1).fatally_failed());\n}\n\nTEST_F(ScopedFakeTestPartResultReporterTest, DeprecatedConstructor) {\n  TestPartResultArray results;\n  {\n    // Tests, that the deprecated constructor still works.\n    ScopedFakeTestPartResultReporter reporter(&results);\n    AddFailure(NONFATAL_FAILURE);\n  }\n  EXPECT_EQ(1, results.size());\n}\n\n#if GTEST_IS_THREADSAFE\n\nclass ScopedFakeTestPartResultReporterWithThreadsTest\n  : public ScopedFakeTestPartResultReporterTest {\n protected:\n  static void AddFailureInOtherThread(FailureMode failure) {\n    ThreadWithParam<FailureMode> thread(&AddFailure, failure, NULL);\n    thread.Join();\n  }\n};\n\nTEST_F(ScopedFakeTestPartResultReporterWithThreadsTest,\n       InterceptsTestFailuresInAllThreads) {\n  TestPartResultArray results;\n  {\n    ScopedFakeTestPartResultReporter reporter(\n        ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, &results);\n    AddFailure(NONFATAL_FAILURE);\n    AddFailure(FATAL_FAILURE);\n    AddFailureInOtherThread(NONFATAL_FAILURE);\n    AddFailureInOtherThread(FATAL_FAILURE);\n  }\n\n  EXPECT_EQ(4, results.size());\n  EXPECT_TRUE(results.GetTestPartResult(0).nonfatally_failed());\n  EXPECT_TRUE(results.GetTestPartResult(1).fatally_failed());\n  EXPECT_TRUE(results.GetTestPartResult(2).nonfatally_failed());\n  EXPECT_TRUE(results.GetTestPartResult(3).fatally_failed());\n}\n\n#endif  // GTEST_IS_THREADSAFE\n\n// Tests EXPECT_FATAL_FAILURE{,ON_ALL_THREADS}.  Makes sure that they\n// work even if the failure is generated in a called function rather than\n// the current context.\n\ntypedef ScopedFakeTestPartResultReporterTest ExpectFatalFailureTest;\n\nTEST_F(ExpectFatalFailureTest, CatchesFatalFaliure) {\n  EXPECT_FATAL_FAILURE(AddFatalFailure(), \"Expected fatal failure.\");\n}\n\n#if GTEST_HAS_GLOBAL_STRING\nTEST_F(ExpectFatalFailureTest, AcceptsStringObject) {\n  EXPECT_FATAL_FAILURE(AddFatalFailure(), ::string(\"Expected fatal failure.\"));\n}\n#endif\n\nTEST_F(ExpectFatalFailureTest, AcceptsStdStringObject) {\n  EXPECT_FATAL_FAILURE(AddFatalFailure(),\n                       ::std::string(\"Expected fatal failure.\"));\n}\n\nTEST_F(ExpectFatalFailureTest, CatchesFatalFailureOnAllThreads) {\n  // We have another test below to verify that the macro catches fatal\n  // failures generated on another thread.\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(AddFatalFailure(),\n                                      \"Expected fatal failure.\");\n}\n\n#ifdef __BORLANDC__\n// Silences warnings: \"Condition is always true\"\n# pragma option push -w-ccc\n#endif\n\n// Tests that EXPECT_FATAL_FAILURE() can be used in a non-void\n// function even when the statement in it contains ASSERT_*.\n\nint NonVoidFunction() {\n  EXPECT_FATAL_FAILURE(ASSERT_TRUE(false), \"\");\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(FAIL(), \"\");\n  return 0;\n}\n\nTEST_F(ExpectFatalFailureTest, CanBeUsedInNonVoidFunction) {\n  NonVoidFunction();\n}\n\n// Tests that EXPECT_FATAL_FAILURE(statement, ...) doesn't abort the\n// current function even though 'statement' generates a fatal failure.\n\nvoid DoesNotAbortHelper(bool* aborted) {\n  EXPECT_FATAL_FAILURE(ASSERT_TRUE(false), \"\");\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(FAIL(), \"\");\n\n  *aborted = false;\n}\n\n#ifdef __BORLANDC__\n// Restores warnings after previous \"#pragma option push\" suppressed them.\n# pragma option pop\n#endif\n\nTEST_F(ExpectFatalFailureTest, DoesNotAbort) {\n  bool aborted = true;\n  DoesNotAbortHelper(&aborted);\n  EXPECT_FALSE(aborted);\n}\n\n// Tests that the EXPECT_FATAL_FAILURE{,_ON_ALL_THREADS} accepts a\n// statement that contains a macro which expands to code containing an\n// unprotected comma.\n\nstatic int global_var = 0;\n#define GTEST_USE_UNPROTECTED_COMMA_ global_var++, global_var++\n\nTEST_F(ExpectFatalFailureTest, AcceptsMacroThatExpandsToUnprotectedComma) {\n#ifndef __BORLANDC__\n  // ICE's in C++Builder.\n  EXPECT_FATAL_FAILURE({\n    GTEST_USE_UNPROTECTED_COMMA_;\n    AddFatalFailure();\n  }, \"\");\n#endif\n\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS({\n    GTEST_USE_UNPROTECTED_COMMA_;\n    AddFatalFailure();\n  }, \"\");\n}\n\n// Tests EXPECT_NONFATAL_FAILURE{,ON_ALL_THREADS}.\n\ntypedef ScopedFakeTestPartResultReporterTest ExpectNonfatalFailureTest;\n\nTEST_F(ExpectNonfatalFailureTest, CatchesNonfatalFailure) {\n  EXPECT_NONFATAL_FAILURE(AddNonfatalFailure(),\n                          \"Expected non-fatal failure.\");\n}\n\n#if GTEST_HAS_GLOBAL_STRING\nTEST_F(ExpectNonfatalFailureTest, AcceptsStringObject) {\n  EXPECT_NONFATAL_FAILURE(AddNonfatalFailure(),\n                          ::string(\"Expected non-fatal failure.\"));\n}\n#endif\n\nTEST_F(ExpectNonfatalFailureTest, AcceptsStdStringObject) {\n  EXPECT_NONFATAL_FAILURE(AddNonfatalFailure(),\n                          ::std::string(\"Expected non-fatal failure.\"));\n}\n\nTEST_F(ExpectNonfatalFailureTest, CatchesNonfatalFailureOnAllThreads) {\n  // We have another test below to verify that the macro catches\n  // non-fatal failures generated on another thread.\n  EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(AddNonfatalFailure(),\n                                         \"Expected non-fatal failure.\");\n}\n\n// Tests that the EXPECT_NONFATAL_FAILURE{,_ON_ALL_THREADS} accepts a\n// statement that contains a macro which expands to code containing an\n// unprotected comma.\nTEST_F(ExpectNonfatalFailureTest, AcceptsMacroThatExpandsToUnprotectedComma) {\n  EXPECT_NONFATAL_FAILURE({\n    GTEST_USE_UNPROTECTED_COMMA_;\n    AddNonfatalFailure();\n  }, \"\");\n\n  EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS({\n    GTEST_USE_UNPROTECTED_COMMA_;\n    AddNonfatalFailure();\n  }, \"\");\n}\n\n#if GTEST_IS_THREADSAFE\n\ntypedef ScopedFakeTestPartResultReporterWithThreadsTest\n    ExpectFailureWithThreadsTest;\n\nTEST_F(ExpectFailureWithThreadsTest, ExpectFatalFailureOnAllThreads) {\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(AddFailureInOtherThread(FATAL_FAILURE),\n                                      \"Expected fatal failure.\");\n}\n\nTEST_F(ExpectFailureWithThreadsTest, ExpectNonFatalFailureOnAllThreads) {\n  EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(\n      AddFailureInOtherThread(NONFATAL_FAILURE), \"Expected non-fatal failure.\");\n}\n\n#endif  // GTEST_IS_THREADSAFE\n\n// Tests the TestProperty class.\n\nTEST(TestPropertyTest, ConstructorWorks) {\n  const TestProperty property(\"key\", \"value\");\n  EXPECT_STREQ(\"key\", property.key());\n  EXPECT_STREQ(\"value\", property.value());\n}\n\nTEST(TestPropertyTest, SetValue) {\n  TestProperty property(\"key\", \"value_1\");\n  EXPECT_STREQ(\"key\", property.key());\n  property.SetValue(\"value_2\");\n  EXPECT_STREQ(\"key\", property.key());\n  EXPECT_STREQ(\"value_2\", property.value());\n}\n\n// Tests the TestResult class\n\n// The test fixture for testing TestResult.\nclass TestResultTest : public Test {\n protected:\n  typedef std::vector<TestPartResult> TPRVector;\n\n  // We make use of 2 TestPartResult objects,\n  TestPartResult * pr1, * pr2;\n\n  // ... and 3 TestResult objects.\n  TestResult * r0, * r1, * r2;\n\n  virtual void SetUp() {\n    // pr1 is for success.\n    pr1 = new TestPartResult(TestPartResult::kSuccess,\n                             \"foo/bar.cc\",\n                             10,\n                             \"Success!\");\n\n    // pr2 is for fatal failure.\n    pr2 = new TestPartResult(TestPartResult::kFatalFailure,\n                             \"foo/bar.cc\",\n                             -1,  // This line number means \"unknown\"\n                             \"Failure!\");\n\n    // Creates the TestResult objects.\n    r0 = new TestResult();\n    r1 = new TestResult();\n    r2 = new TestResult();\n\n    // In order to test TestResult, we need to modify its internal\n    // state, in particular the TestPartResult vector it holds.\n    // test_part_results() returns a const reference to this vector.\n    // We cast it to a non-const object s.t. it can be modified (yes,\n    // this is a hack).\n    TPRVector* results1 = const_cast<TPRVector*>(\n        &TestResultAccessor::test_part_results(*r1));\n    TPRVector* results2 = const_cast<TPRVector*>(\n        &TestResultAccessor::test_part_results(*r2));\n\n    // r0 is an empty TestResult.\n\n    // r1 contains a single SUCCESS TestPartResult.\n    results1->push_back(*pr1);\n\n    // r2 contains a SUCCESS, and a FAILURE.\n    results2->push_back(*pr1);\n    results2->push_back(*pr2);\n  }\n\n  virtual void TearDown() {\n    delete pr1;\n    delete pr2;\n\n    delete r0;\n    delete r1;\n    delete r2;\n  }\n\n  // Helper that compares two two TestPartResults.\n  static void CompareTestPartResult(const TestPartResult& expected,\n                                    const TestPartResult& actual) {\n    EXPECT_EQ(expected.type(), actual.type());\n    EXPECT_STREQ(expected.file_name(), actual.file_name());\n    EXPECT_EQ(expected.line_number(), actual.line_number());\n    EXPECT_STREQ(expected.summary(), actual.summary());\n    EXPECT_STREQ(expected.message(), actual.message());\n    EXPECT_EQ(expected.passed(), actual.passed());\n    EXPECT_EQ(expected.failed(), actual.failed());\n    EXPECT_EQ(expected.nonfatally_failed(), actual.nonfatally_failed());\n    EXPECT_EQ(expected.fatally_failed(), actual.fatally_failed());\n  }\n};\n\n// Tests TestResult::total_part_count().\nTEST_F(TestResultTest, total_part_count) {\n  ASSERT_EQ(0, r0->total_part_count());\n  ASSERT_EQ(1, r1->total_part_count());\n  ASSERT_EQ(2, r2->total_part_count());\n}\n\n// Tests TestResult::Passed().\nTEST_F(TestResultTest, Passed) {\n  ASSERT_TRUE(r0->Passed());\n  ASSERT_TRUE(r1->Passed());\n  ASSERT_FALSE(r2->Passed());\n}\n\n// Tests TestResult::Failed().\nTEST_F(TestResultTest, Failed) {\n  ASSERT_FALSE(r0->Failed());\n  ASSERT_FALSE(r1->Failed());\n  ASSERT_TRUE(r2->Failed());\n}\n\n// Tests TestResult::GetTestPartResult().\n\ntypedef TestResultTest TestResultDeathTest;\n\nTEST_F(TestResultDeathTest, GetTestPartResult) {\n  CompareTestPartResult(*pr1, r2->GetTestPartResult(0));\n  CompareTestPartResult(*pr2, r2->GetTestPartResult(1));\n  EXPECT_DEATH_IF_SUPPORTED(r2->GetTestPartResult(2), \"\");\n  EXPECT_DEATH_IF_SUPPORTED(r2->GetTestPartResult(-1), \"\");\n}\n\n// Tests TestResult has no properties when none are added.\nTEST(TestResultPropertyTest, NoPropertiesFoundWhenNoneAreAdded) {\n  TestResult test_result;\n  ASSERT_EQ(0, test_result.test_property_count());\n}\n\n// Tests TestResult has the expected property when added.\nTEST(TestResultPropertyTest, OnePropertyFoundWhenAdded) {\n  TestResult test_result;\n  TestProperty property(\"key_1\", \"1\");\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property);\n  ASSERT_EQ(1, test_result.test_property_count());\n  const TestProperty& actual_property = test_result.GetTestProperty(0);\n  EXPECT_STREQ(\"key_1\", actual_property.key());\n  EXPECT_STREQ(\"1\", actual_property.value());\n}\n\n// Tests TestResult has multiple properties when added.\nTEST(TestResultPropertyTest, MultiplePropertiesFoundWhenAdded) {\n  TestResult test_result;\n  TestProperty property_1(\"key_1\", \"1\");\n  TestProperty property_2(\"key_2\", \"2\");\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_1);\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_2);\n  ASSERT_EQ(2, test_result.test_property_count());\n  const TestProperty& actual_property_1 = test_result.GetTestProperty(0);\n  EXPECT_STREQ(\"key_1\", actual_property_1.key());\n  EXPECT_STREQ(\"1\", actual_property_1.value());\n\n  const TestProperty& actual_property_2 = test_result.GetTestProperty(1);\n  EXPECT_STREQ(\"key_2\", actual_property_2.key());\n  EXPECT_STREQ(\"2\", actual_property_2.value());\n}\n\n// Tests TestResult::RecordProperty() overrides values for duplicate keys.\nTEST(TestResultPropertyTest, OverridesValuesForDuplicateKeys) {\n  TestResult test_result;\n  TestProperty property_1_1(\"key_1\", \"1\");\n  TestProperty property_2_1(\"key_2\", \"2\");\n  TestProperty property_1_2(\"key_1\", \"12\");\n  TestProperty property_2_2(\"key_2\", \"22\");\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_1_1);\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_2_1);\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_1_2);\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_2_2);\n\n  ASSERT_EQ(2, test_result.test_property_count());\n  const TestProperty& actual_property_1 = test_result.GetTestProperty(0);\n  EXPECT_STREQ(\"key_1\", actual_property_1.key());\n  EXPECT_STREQ(\"12\", actual_property_1.value());\n\n  const TestProperty& actual_property_2 = test_result.GetTestProperty(1);\n  EXPECT_STREQ(\"key_2\", actual_property_2.key());\n  EXPECT_STREQ(\"22\", actual_property_2.value());\n}\n\n// Tests TestResult::GetTestProperty().\nTEST(TestResultPropertyTest, GetTestProperty) {\n  TestResult test_result;\n  TestProperty property_1(\"key_1\", \"1\");\n  TestProperty property_2(\"key_2\", \"2\");\n  TestProperty property_3(\"key_3\", \"3\");\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_1);\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_2);\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_3);\n\n  const TestProperty& fetched_property_1 = test_result.GetTestProperty(0);\n  const TestProperty& fetched_property_2 = test_result.GetTestProperty(1);\n  const TestProperty& fetched_property_3 = test_result.GetTestProperty(2);\n\n  EXPECT_STREQ(\"key_1\", fetched_property_1.key());\n  EXPECT_STREQ(\"1\", fetched_property_1.value());\n\n  EXPECT_STREQ(\"key_2\", fetched_property_2.key());\n  EXPECT_STREQ(\"2\", fetched_property_2.value());\n\n  EXPECT_STREQ(\"key_3\", fetched_property_3.key());\n  EXPECT_STREQ(\"3\", fetched_property_3.value());\n\n  EXPECT_DEATH_IF_SUPPORTED(test_result.GetTestProperty(3), \"\");\n  EXPECT_DEATH_IF_SUPPORTED(test_result.GetTestProperty(-1), \"\");\n}\n\n// Tests the Test class.\n//\n// It's difficult to test every public method of this class (we are\n// already stretching the limit of Google Test by using it to test itself!).\n// Fortunately, we don't have to do that, as we are already testing\n// the functionalities of the Test class extensively by using Google Test\n// alone.\n//\n// Therefore, this section only contains one test.\n\n// Tests that GTestFlagSaver works on Windows and Mac.\n\nclass GTestFlagSaverTest : public Test {\n protected:\n  // Saves the Google Test flags such that we can restore them later, and\n  // then sets them to their default values.  This will be called\n  // before the first test in this test case is run.\n  static void SetUpTestCase() {\n    saver_ = new GTestFlagSaver;\n\n    GTEST_FLAG(also_run_disabled_tests) = false;\n    GTEST_FLAG(break_on_failure) = false;\n    GTEST_FLAG(catch_exceptions) = false;\n    GTEST_FLAG(death_test_use_fork) = false;\n    GTEST_FLAG(color) = \"auto\";\n    GTEST_FLAG(filter) = \"\";\n    GTEST_FLAG(list_tests) = false;\n    GTEST_FLAG(output) = \"\";\n    GTEST_FLAG(print_time) = true;\n    GTEST_FLAG(random_seed) = 0;\n    GTEST_FLAG(repeat) = 1;\n    GTEST_FLAG(shuffle) = false;\n    GTEST_FLAG(stack_trace_depth) = kMaxStackTraceDepth;\n    GTEST_FLAG(stream_result_to) = \"\";\n    GTEST_FLAG(throw_on_failure) = false;\n  }\n\n  // Restores the Google Test flags that the tests have modified.  This will\n  // be called after the last test in this test case is run.\n  static void TearDownTestCase() {\n    delete saver_;\n    saver_ = NULL;\n  }\n\n  // Verifies that the Google Test flags have their default values, and then\n  // modifies each of them.\n  void VerifyAndModifyFlags() {\n    EXPECT_FALSE(GTEST_FLAG(also_run_disabled_tests));\n    EXPECT_FALSE(GTEST_FLAG(break_on_failure));\n    EXPECT_FALSE(GTEST_FLAG(catch_exceptions));\n    EXPECT_STREQ(\"auto\", GTEST_FLAG(color).c_str());\n    EXPECT_FALSE(GTEST_FLAG(death_test_use_fork));\n    EXPECT_STREQ(\"\", GTEST_FLAG(filter).c_str());\n    EXPECT_FALSE(GTEST_FLAG(list_tests));\n    EXPECT_STREQ(\"\", GTEST_FLAG(output).c_str());\n    EXPECT_TRUE(GTEST_FLAG(print_time));\n    EXPECT_EQ(0, GTEST_FLAG(random_seed));\n    EXPECT_EQ(1, GTEST_FLAG(repeat));\n    EXPECT_FALSE(GTEST_FLAG(shuffle));\n    EXPECT_EQ(kMaxStackTraceDepth, GTEST_FLAG(stack_trace_depth));\n    EXPECT_STREQ(\"\", GTEST_FLAG(stream_result_to).c_str());\n    EXPECT_FALSE(GTEST_FLAG(throw_on_failure));\n\n    GTEST_FLAG(also_run_disabled_tests) = true;\n    GTEST_FLAG(break_on_failure) = true;\n    GTEST_FLAG(catch_exceptions) = true;\n    GTEST_FLAG(color) = \"no\";\n    GTEST_FLAG(death_test_use_fork) = true;\n    GTEST_FLAG(filter) = \"abc\";\n    GTEST_FLAG(list_tests) = true;\n    GTEST_FLAG(output) = \"xml:foo.xml\";\n    GTEST_FLAG(print_time) = false;\n    GTEST_FLAG(random_seed) = 1;\n    GTEST_FLAG(repeat) = 100;\n    GTEST_FLAG(shuffle) = true;\n    GTEST_FLAG(stack_trace_depth) = 1;\n    GTEST_FLAG(stream_result_to) = \"localhost:1234\";\n    GTEST_FLAG(throw_on_failure) = true;\n  }\n\n private:\n  // For saving Google Test flags during this test case.\n  static GTestFlagSaver* saver_;\n};\n\nGTestFlagSaver* GTestFlagSaverTest::saver_ = NULL;\n\n// Google Test doesn't guarantee the order of tests.  The following two\n// tests are designed to work regardless of their order.\n\n// Modifies the Google Test flags in the test body.\nTEST_F(GTestFlagSaverTest, ModifyGTestFlags) {\n  VerifyAndModifyFlags();\n}\n\n// Verifies that the Google Test flags in the body of the previous test were\n// restored to their original values.\nTEST_F(GTestFlagSaverTest, VerifyGTestFlags) {\n  VerifyAndModifyFlags();\n}\n\n// Sets an environment variable with the given name to the given\n// value.  If the value argument is \"\", unsets the environment\n// variable.  The caller must ensure that both arguments are not NULL.\nstatic void SetEnv(const char* name, const char* value) {\n#if GTEST_OS_WINDOWS_MOBILE\n  // Environment variables are not supported on Windows CE.\n  return;\n#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)\n  // C++Builder's putenv only stores a pointer to its parameter; we have to\n  // ensure that the string remains valid as long as it might be needed.\n  // We use an std::map to do so.\n  static std::map<std::string, std::string*> added_env;\n\n  // Because putenv stores a pointer to the string buffer, we can't delete the\n  // previous string (if present) until after it's replaced.\n  std::string *prev_env = NULL;\n  if (added_env.find(name) != added_env.end()) {\n    prev_env = added_env[name];\n  }\n  added_env[name] = new std::string(\n      (Message() << name << \"=\" << value).GetString());\n\n  // The standard signature of putenv accepts a 'char*' argument. Other\n  // implementations, like C++Builder's, accept a 'const char*'.\n  // We cast away the 'const' since that would work for both variants.\n  putenv(const_cast<char*>(added_env[name]->c_str()));\n  delete prev_env;\n#elif GTEST_OS_WINDOWS  // If we are on Windows proper.\n  _putenv((Message() << name << \"=\" << value).GetString().c_str());\n#else\n  if (*value == '\\0') {\n    unsetenv(name);\n  } else {\n    setenv(name, value, 1);\n  }\n#endif  // GTEST_OS_WINDOWS_MOBILE\n}\n\n#if !GTEST_OS_WINDOWS_MOBILE\n// Environment variables are not supported on Windows CE.\n\nusing testing::internal::Int32FromGTestEnv;\n\n// Tests Int32FromGTestEnv().\n\n// Tests that Int32FromGTestEnv() returns the default value when the\n// environment variable is not set.\nTEST(Int32FromGTestEnvTest, ReturnsDefaultWhenVariableIsNotSet) {\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"TEMP\", \"\");\n  EXPECT_EQ(10, Int32FromGTestEnv(\"temp\", 10));\n}\n\n# if !defined(GTEST_GET_INT32_FROM_ENV_)\n\n// Tests that Int32FromGTestEnv() returns the default value when the\n// environment variable overflows as an Int32.\nTEST(Int32FromGTestEnvTest, ReturnsDefaultWhenValueOverflows) {\n  printf(\"(expecting 2 warnings)\\n\");\n\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"TEMP\", \"12345678987654321\");\n  EXPECT_EQ(20, Int32FromGTestEnv(\"temp\", 20));\n\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"TEMP\", \"-12345678987654321\");\n  EXPECT_EQ(30, Int32FromGTestEnv(\"temp\", 30));\n}\n\n// Tests that Int32FromGTestEnv() returns the default value when the\n// environment variable does not represent a valid decimal integer.\nTEST(Int32FromGTestEnvTest, ReturnsDefaultWhenValueIsInvalid) {\n  printf(\"(expecting 2 warnings)\\n\");\n\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"TEMP\", \"A1\");\n  EXPECT_EQ(40, Int32FromGTestEnv(\"temp\", 40));\n\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"TEMP\", \"12X\");\n  EXPECT_EQ(50, Int32FromGTestEnv(\"temp\", 50));\n}\n\n# endif  // !defined(GTEST_GET_INT32_FROM_ENV_)\n\n// Tests that Int32FromGTestEnv() parses and returns the value of the\n// environment variable when it represents a valid decimal integer in\n// the range of an Int32.\nTEST(Int32FromGTestEnvTest, ParsesAndReturnsValidValue) {\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"TEMP\", \"123\");\n  EXPECT_EQ(123, Int32FromGTestEnv(\"temp\", 0));\n\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"TEMP\", \"-321\");\n  EXPECT_EQ(-321, Int32FromGTestEnv(\"temp\", 0));\n}\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\n// Tests ParseInt32Flag().\n\n// Tests that ParseInt32Flag() returns false and doesn't change the\n// output value when the flag has wrong format\nTEST(ParseInt32FlagTest, ReturnsFalseForInvalidFlag) {\n  Int32 value = 123;\n  EXPECT_FALSE(ParseInt32Flag(\"--a=100\", \"b\", &value));\n  EXPECT_EQ(123, value);\n\n  EXPECT_FALSE(ParseInt32Flag(\"a=100\", \"a\", &value));\n  EXPECT_EQ(123, value);\n}\n\n// Tests that ParseInt32Flag() returns false and doesn't change the\n// output value when the flag overflows as an Int32.\nTEST(ParseInt32FlagTest, ReturnsDefaultWhenValueOverflows) {\n  printf(\"(expecting 2 warnings)\\n\");\n\n  Int32 value = 123;\n  EXPECT_FALSE(ParseInt32Flag(\"--abc=12345678987654321\", \"abc\", &value));\n  EXPECT_EQ(123, value);\n\n  EXPECT_FALSE(ParseInt32Flag(\"--abc=-12345678987654321\", \"abc\", &value));\n  EXPECT_EQ(123, value);\n}\n\n// Tests that ParseInt32Flag() returns false and doesn't change the\n// output value when the flag does not represent a valid decimal\n// integer.\nTEST(ParseInt32FlagTest, ReturnsDefaultWhenValueIsInvalid) {\n  printf(\"(expecting 2 warnings)\\n\");\n\n  Int32 value = 123;\n  EXPECT_FALSE(ParseInt32Flag(\"--abc=A1\", \"abc\", &value));\n  EXPECT_EQ(123, value);\n\n  EXPECT_FALSE(ParseInt32Flag(\"--abc=12X\", \"abc\", &value));\n  EXPECT_EQ(123, value);\n}\n\n// Tests that ParseInt32Flag() parses the value of the flag and\n// returns true when the flag represents a valid decimal integer in\n// the range of an Int32.\nTEST(ParseInt32FlagTest, ParsesAndReturnsValidValue) {\n  Int32 value = 123;\n  EXPECT_TRUE(ParseInt32Flag(\"--\" GTEST_FLAG_PREFIX_ \"abc=456\", \"abc\", &value));\n  EXPECT_EQ(456, value);\n\n  EXPECT_TRUE(ParseInt32Flag(\"--\" GTEST_FLAG_PREFIX_ \"abc=-789\",\n                             \"abc\", &value));\n  EXPECT_EQ(-789, value);\n}\n\n// Tests that Int32FromEnvOrDie() parses the value of the var or\n// returns the correct default.\n// Environment variables are not supported on Windows CE.\n#if !GTEST_OS_WINDOWS_MOBILE\nTEST(Int32FromEnvOrDieTest, ParsesAndReturnsValidValue) {\n  EXPECT_EQ(333, Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ \"UnsetVar\", 333));\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"UnsetVar\", \"123\");\n  EXPECT_EQ(123, Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ \"UnsetVar\", 333));\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"UnsetVar\", \"-123\");\n  EXPECT_EQ(-123, Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ \"UnsetVar\", 333));\n}\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\n// Tests that Int32FromEnvOrDie() aborts with an error message\n// if the variable is not an Int32.\nTEST(Int32FromEnvOrDieDeathTest, AbortsOnFailure) {\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"VAR\", \"xxx\");\n  EXPECT_DEATH_IF_SUPPORTED(\n      Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ \"VAR\", 123),\n      \".*\");\n}\n\n// Tests that Int32FromEnvOrDie() aborts with an error message\n// if the variable cannot be represnted by an Int32.\nTEST(Int32FromEnvOrDieDeathTest, AbortsOnInt32Overflow) {\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"VAR\", \"1234567891234567891234\");\n  EXPECT_DEATH_IF_SUPPORTED(\n      Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ \"VAR\", 123),\n      \".*\");\n}\n\n// Tests that ShouldRunTestOnShard() selects all tests\n// where there is 1 shard.\nTEST(ShouldRunTestOnShardTest, IsPartitionWhenThereIsOneShard) {\n  EXPECT_TRUE(ShouldRunTestOnShard(1, 0, 0));\n  EXPECT_TRUE(ShouldRunTestOnShard(1, 0, 1));\n  EXPECT_TRUE(ShouldRunTestOnShard(1, 0, 2));\n  EXPECT_TRUE(ShouldRunTestOnShard(1, 0, 3));\n  EXPECT_TRUE(ShouldRunTestOnShard(1, 0, 4));\n}\n\nclass ShouldShardTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    index_var_ = GTEST_FLAG_PREFIX_UPPER_ \"INDEX\";\n    total_var_ = GTEST_FLAG_PREFIX_UPPER_ \"TOTAL\";\n  }\n\n  virtual void TearDown() {\n    SetEnv(index_var_, \"\");\n    SetEnv(total_var_, \"\");\n  }\n\n  const char* index_var_;\n  const char* total_var_;\n};\n\n// Tests that sharding is disabled if neither of the environment variables\n// are set.\nTEST_F(ShouldShardTest, ReturnsFalseWhenNeitherEnvVarIsSet) {\n  SetEnv(index_var_, \"\");\n  SetEnv(total_var_, \"\");\n\n  EXPECT_FALSE(ShouldShard(total_var_, index_var_, false));\n  EXPECT_FALSE(ShouldShard(total_var_, index_var_, true));\n}\n\n// Tests that sharding is not enabled if total_shards  == 1.\nTEST_F(ShouldShardTest, ReturnsFalseWhenTotalShardIsOne) {\n  SetEnv(index_var_, \"0\");\n  SetEnv(total_var_, \"1\");\n  EXPECT_FALSE(ShouldShard(total_var_, index_var_, false));\n  EXPECT_FALSE(ShouldShard(total_var_, index_var_, true));\n}\n\n// Tests that sharding is enabled if total_shards > 1 and\n// we are not in a death test subprocess.\n// Environment variables are not supported on Windows CE.\n#if !GTEST_OS_WINDOWS_MOBILE\nTEST_F(ShouldShardTest, WorksWhenShardEnvVarsAreValid) {\n  SetEnv(index_var_, \"4\");\n  SetEnv(total_var_, \"22\");\n  EXPECT_TRUE(ShouldShard(total_var_, index_var_, false));\n  EXPECT_FALSE(ShouldShard(total_var_, index_var_, true));\n\n  SetEnv(index_var_, \"8\");\n  SetEnv(total_var_, \"9\");\n  EXPECT_TRUE(ShouldShard(total_var_, index_var_, false));\n  EXPECT_FALSE(ShouldShard(total_var_, index_var_, true));\n\n  SetEnv(index_var_, \"0\");\n  SetEnv(total_var_, \"9\");\n  EXPECT_TRUE(ShouldShard(total_var_, index_var_, false));\n  EXPECT_FALSE(ShouldShard(total_var_, index_var_, true));\n}\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\n// Tests that we exit in error if the sharding values are not valid.\n\ntypedef ShouldShardTest ShouldShardDeathTest;\n\nTEST_F(ShouldShardDeathTest, AbortsWhenShardingEnvVarsAreInvalid) {\n  SetEnv(index_var_, \"4\");\n  SetEnv(total_var_, \"4\");\n  EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), \".*\");\n\n  SetEnv(index_var_, \"4\");\n  SetEnv(total_var_, \"-2\");\n  EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), \".*\");\n\n  SetEnv(index_var_, \"5\");\n  SetEnv(total_var_, \"\");\n  EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), \".*\");\n\n  SetEnv(index_var_, \"\");\n  SetEnv(total_var_, \"5\");\n  EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), \".*\");\n}\n\n// Tests that ShouldRunTestOnShard is a partition when 5\n// shards are used.\nTEST(ShouldRunTestOnShardTest, IsPartitionWhenThereAreFiveShards) {\n  // Choose an arbitrary number of tests and shards.\n  const int num_tests = 17;\n  const int num_shards = 5;\n\n  // Check partitioning: each test should be on exactly 1 shard.\n  for (int test_id = 0; test_id < num_tests; test_id++) {\n    int prev_selected_shard_index = -1;\n    for (int shard_index = 0; shard_index < num_shards; shard_index++) {\n      if (ShouldRunTestOnShard(num_shards, shard_index, test_id)) {\n        if (prev_selected_shard_index < 0) {\n          prev_selected_shard_index = shard_index;\n        } else {\n          ADD_FAILURE() << \"Shard \" << prev_selected_shard_index << \" and \"\n            << shard_index << \" are both selected to run test \" << test_id;\n        }\n      }\n    }\n  }\n\n  // Check balance: This is not required by the sharding protocol, but is a\n  // desirable property for performance.\n  for (int shard_index = 0; shard_index < num_shards; shard_index++) {\n    int num_tests_on_shard = 0;\n    for (int test_id = 0; test_id < num_tests; test_id++) {\n      num_tests_on_shard +=\n        ShouldRunTestOnShard(num_shards, shard_index, test_id);\n    }\n    EXPECT_GE(num_tests_on_shard, num_tests / num_shards);\n  }\n}\n\n// For the same reason we are not explicitly testing everything in the\n// Test class, there are no separate tests for the following classes\n// (except for some trivial cases):\n//\n//   TestCase, UnitTest, UnitTestResultPrinter.\n//\n// Similarly, there are no separate tests for the following macros:\n//\n//   TEST, TEST_F, RUN_ALL_TESTS\n\nTEST(UnitTestTest, CanGetOriginalWorkingDir) {\n  ASSERT_TRUE(UnitTest::GetInstance()->original_working_dir() != NULL);\n  EXPECT_STRNE(UnitTest::GetInstance()->original_working_dir(), \"\");\n}\n\nTEST(UnitTestTest, ReturnsPlausibleTimestamp) {\n  EXPECT_LT(0, UnitTest::GetInstance()->start_timestamp());\n  EXPECT_LE(UnitTest::GetInstance()->start_timestamp(), GetTimeInMillis());\n}\n\n// When a property using a reserved key is supplied to this function, it\n// tests that a non-fatal failure is added, a fatal failure is not added,\n// and that the property is not recorded.\nvoid ExpectNonFatalFailureRecordingPropertyWithReservedKey(\n    const TestResult& test_result, const char* key) {\n  EXPECT_NONFATAL_FAILURE(Test::RecordProperty(key, \"1\"), \"Reserved key\");\n  ASSERT_EQ(0, test_result.test_property_count()) << \"Property for key '\" << key\n                                                  << \"' recorded unexpectedly.\";\n}\n\nvoid ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(\n    const char* key) {\n  const TestInfo* test_info = UnitTest::GetInstance()->current_test_info();\n  ASSERT_TRUE(test_info != NULL);\n  ExpectNonFatalFailureRecordingPropertyWithReservedKey(*test_info->result(),\n                                                        key);\n}\n\nvoid ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(\n    const char* key) {\n  const TestCase* test_case = UnitTest::GetInstance()->current_test_case();\n  ASSERT_TRUE(test_case != NULL);\n  ExpectNonFatalFailureRecordingPropertyWithReservedKey(\n      test_case->ad_hoc_test_result(), key);\n}\n\nvoid ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n    const char* key) {\n  ExpectNonFatalFailureRecordingPropertyWithReservedKey(\n      UnitTest::GetInstance()->ad_hoc_test_result(), key);\n}\n\n// Tests that property recording functions in UnitTest outside of tests\n// functions correcly.  Creating a separate instance of UnitTest ensures it\n// is in a state similar to the UnitTest's singleton's between tests.\nclass UnitTestRecordPropertyTest :\n    public testing::internal::UnitTestRecordPropertyTestHelper {\n public:\n  static void SetUpTestCase() {\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(\n        \"disabled\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(\n        \"errors\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(\n        \"failures\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(\n        \"name\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(\n        \"tests\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(\n        \"time\");\n\n    Test::RecordProperty(\"test_case_key_1\", \"1\");\n    const TestCase* test_case = UnitTest::GetInstance()->current_test_case();\n    ASSERT_TRUE(test_case != NULL);\n\n    ASSERT_EQ(1, test_case->ad_hoc_test_result().test_property_count());\n    EXPECT_STREQ(\"test_case_key_1\",\n                 test_case->ad_hoc_test_result().GetTestProperty(0).key());\n    EXPECT_STREQ(\"1\",\n                 test_case->ad_hoc_test_result().GetTestProperty(0).value());\n  }\n};\n\n// Tests TestResult has the expected property when added.\nTEST_F(UnitTestRecordPropertyTest, OnePropertyFoundWhenAdded) {\n  UnitTestRecordProperty(\"key_1\", \"1\");\n\n  ASSERT_EQ(1, unit_test_.ad_hoc_test_result().test_property_count());\n\n  EXPECT_STREQ(\"key_1\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(0).key());\n  EXPECT_STREQ(\"1\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(0).value());\n}\n\n// Tests TestResult has multiple properties when added.\nTEST_F(UnitTestRecordPropertyTest, MultiplePropertiesFoundWhenAdded) {\n  UnitTestRecordProperty(\"key_1\", \"1\");\n  UnitTestRecordProperty(\"key_2\", \"2\");\n\n  ASSERT_EQ(2, unit_test_.ad_hoc_test_result().test_property_count());\n\n  EXPECT_STREQ(\"key_1\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(0).key());\n  EXPECT_STREQ(\"1\", unit_test_.ad_hoc_test_result().GetTestProperty(0).value());\n\n  EXPECT_STREQ(\"key_2\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(1).key());\n  EXPECT_STREQ(\"2\", unit_test_.ad_hoc_test_result().GetTestProperty(1).value());\n}\n\n// Tests TestResult::RecordProperty() overrides values for duplicate keys.\nTEST_F(UnitTestRecordPropertyTest, OverridesValuesForDuplicateKeys) {\n  UnitTestRecordProperty(\"key_1\", \"1\");\n  UnitTestRecordProperty(\"key_2\", \"2\");\n  UnitTestRecordProperty(\"key_1\", \"12\");\n  UnitTestRecordProperty(\"key_2\", \"22\");\n\n  ASSERT_EQ(2, unit_test_.ad_hoc_test_result().test_property_count());\n\n  EXPECT_STREQ(\"key_1\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(0).key());\n  EXPECT_STREQ(\"12\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(0).value());\n\n  EXPECT_STREQ(\"key_2\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(1).key());\n  EXPECT_STREQ(\"22\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(1).value());\n}\n\nTEST_F(UnitTestRecordPropertyTest,\n       AddFailureInsideTestsWhenUsingTestCaseReservedKeys) {\n  ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(\n      \"name\");\n  ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(\n      \"value_param\");\n  ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(\n      \"type_param\");\n  ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(\n      \"status\");\n  ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(\n      \"time\");\n  ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(\n      \"classname\");\n}\n\nTEST_F(UnitTestRecordPropertyTest,\n       AddRecordWithReservedKeysGeneratesCorrectPropertyList) {\n  EXPECT_NONFATAL_FAILURE(\n      Test::RecordProperty(\"name\", \"1\"),\n      \"'classname', 'name', 'status', 'time', 'type_param', and 'value_param'\"\n      \" are reserved\");\n}\n\nclass UnitTestRecordPropertyTestEnvironment : public Environment {\n public:\n  virtual void TearDown() {\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"tests\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"failures\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"disabled\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"errors\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"name\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"timestamp\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"time\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"random_seed\");\n  }\n};\n\n// This will test property recording outside of any test or test case.\nstatic Environment* record_property_env =\n    AddGlobalTestEnvironment(new UnitTestRecordPropertyTestEnvironment);\n\n// This group of tests is for predicate assertions (ASSERT_PRED*, etc)\n// of various arities.  They do not attempt to be exhaustive.  Rather,\n// view them as smoke tests that can be easily reviewed and verified.\n// A more complete set of tests for predicate assertions can be found\n// in gtest_pred_impl_unittest.cc.\n\n// First, some predicates and predicate-formatters needed by the tests.\n\n// Returns true iff the argument is an even number.\nbool IsEven(int n) {\n  return (n % 2) == 0;\n}\n\n// A functor that returns true iff the argument is an even number.\nstruct IsEvenFunctor {\n  bool operator()(int n) { return IsEven(n); }\n};\n\n// A predicate-formatter function that asserts the argument is an even\n// number.\nAssertionResult AssertIsEven(const char* expr, int n) {\n  if (IsEven(n)) {\n    return AssertionSuccess();\n  }\n\n  Message msg;\n  msg << expr << \" evaluates to \" << n << \", which is not even.\";\n  return AssertionFailure(msg);\n}\n\n// A predicate function that returns AssertionResult for use in\n// EXPECT/ASSERT_TRUE/FALSE.\nAssertionResult ResultIsEven(int n) {\n  if (IsEven(n))\n    return AssertionSuccess() << n << \" is even\";\n  else\n    return AssertionFailure() << n << \" is odd\";\n}\n\n// A predicate function that returns AssertionResult but gives no\n// explanation why it succeeds. Needed for testing that\n// EXPECT/ASSERT_FALSE handles such functions correctly.\nAssertionResult ResultIsEvenNoExplanation(int n) {\n  if (IsEven(n))\n    return AssertionSuccess();\n  else\n    return AssertionFailure() << n << \" is odd\";\n}\n\n// A predicate-formatter functor that asserts the argument is an even\n// number.\nstruct AssertIsEvenFunctor {\n  AssertionResult operator()(const char* expr, int n) {\n    return AssertIsEven(expr, n);\n  }\n};\n\n// Returns true iff the sum of the arguments is an even number.\nbool SumIsEven2(int n1, int n2) {\n  return IsEven(n1 + n2);\n}\n\n// A functor that returns true iff the sum of the arguments is an even\n// number.\nstruct SumIsEven3Functor {\n  bool operator()(int n1, int n2, int n3) {\n    return IsEven(n1 + n2 + n3);\n  }\n};\n\n// A predicate-formatter function that asserts the sum of the\n// arguments is an even number.\nAssertionResult AssertSumIsEven4(\n    const char* e1, const char* e2, const char* e3, const char* e4,\n    int n1, int n2, int n3, int n4) {\n  const int sum = n1 + n2 + n3 + n4;\n  if (IsEven(sum)) {\n    return AssertionSuccess();\n  }\n\n  Message msg;\n  msg << e1 << \" + \" << e2 << \" + \" << e3 << \" + \" << e4\n      << \" (\" << n1 << \" + \" << n2 << \" + \" << n3 << \" + \" << n4\n      << \") evaluates to \" << sum << \", which is not even.\";\n  return AssertionFailure(msg);\n}\n\n// A predicate-formatter functor that asserts the sum of the arguments\n// is an even number.\nstruct AssertSumIsEven5Functor {\n  AssertionResult operator()(\n      const char* e1, const char* e2, const char* e3, const char* e4,\n      const char* e5, int n1, int n2, int n3, int n4, int n5) {\n    const int sum = n1 + n2 + n3 + n4 + n5;\n    if (IsEven(sum)) {\n      return AssertionSuccess();\n    }\n\n    Message msg;\n    msg << e1 << \" + \" << e2 << \" + \" << e3 << \" + \" << e4 << \" + \" << e5\n        << \" (\"\n        << n1 << \" + \" << n2 << \" + \" << n3 << \" + \" << n4 << \" + \" << n5\n        << \") evaluates to \" << sum << \", which is not even.\";\n    return AssertionFailure(msg);\n  }\n};\n\n\n// Tests unary predicate assertions.\n\n// Tests unary predicate assertions that don't use a custom formatter.\nTEST(Pred1Test, WithoutFormat) {\n  // Success cases.\n  EXPECT_PRED1(IsEvenFunctor(), 2) << \"This failure is UNEXPECTED!\";\n  ASSERT_PRED1(IsEven, 4);\n\n  // Failure cases.\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED1(IsEven, 5) << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n  EXPECT_FATAL_FAILURE(ASSERT_PRED1(IsEvenFunctor(), 5),\n                       \"evaluates to false\");\n}\n\n// Tests unary predicate assertions that use a custom formatter.\nTEST(Pred1Test, WithFormat) {\n  // Success cases.\n  EXPECT_PRED_FORMAT1(AssertIsEven, 2);\n  ASSERT_PRED_FORMAT1(AssertIsEvenFunctor(), 4)\n    << \"This failure is UNEXPECTED!\";\n\n  // Failure cases.\n  const int n = 5;\n  EXPECT_NONFATAL_FAILURE(EXPECT_PRED_FORMAT1(AssertIsEvenFunctor(), n),\n                          \"n evaluates to 5, which is not even.\");\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT1(AssertIsEven, 5) << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n}\n\n// Tests that unary predicate assertions evaluates their arguments\n// exactly once.\nTEST(Pred1Test, SingleEvaluationOnFailure) {\n  // A success case.\n  static int n = 0;\n  EXPECT_PRED1(IsEven, n++);\n  EXPECT_EQ(1, n) << \"The argument is not evaluated exactly once.\";\n\n  // A failure case.\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT1(AssertIsEvenFunctor(), n++)\n        << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n  EXPECT_EQ(2, n) << \"The argument is not evaluated exactly once.\";\n}\n\n\n// Tests predicate assertions whose arity is >= 2.\n\n// Tests predicate assertions that don't use a custom formatter.\nTEST(PredTest, WithoutFormat) {\n  // Success cases.\n  ASSERT_PRED2(SumIsEven2, 2, 4) << \"This failure is UNEXPECTED!\";\n  EXPECT_PRED3(SumIsEven3Functor(), 4, 6, 8);\n\n  // Failure cases.\n  const int n1 = 1;\n  const int n2 = 2;\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED2(SumIsEven2, n1, n2) << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED3(SumIsEven3Functor(), 1, 2, 4);\n  }, \"evaluates to false\");\n}\n\n// Tests predicate assertions that use a custom formatter.\nTEST(PredTest, WithFormat) {\n  // Success cases.\n  ASSERT_PRED_FORMAT4(AssertSumIsEven4, 4, 6, 8, 10) <<\n    \"This failure is UNEXPECTED!\";\n  EXPECT_PRED_FORMAT5(AssertSumIsEven5Functor(), 2, 4, 6, 8, 10);\n\n  // Failure cases.\n  const int n1 = 1;\n  const int n2 = 2;\n  const int n3 = 4;\n  const int n4 = 6;\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT4(AssertSumIsEven4, n1, n2, n3, n4);\n  }, \"evaluates to 13, which is not even.\");\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT5(AssertSumIsEven5Functor(), 1, 2, 4, 6, 8)\n        << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n}\n\n// Tests that predicate assertions evaluates their arguments\n// exactly once.\nTEST(PredTest, SingleEvaluationOnFailure) {\n  // A success case.\n  int n1 = 0;\n  int n2 = 0;\n  EXPECT_PRED2(SumIsEven2, n1++, n2++);\n  EXPECT_EQ(1, n1) << \"Argument 1 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n2) << \"Argument 2 is not evaluated exactly once.\";\n\n  // Another success case.\n  n1 = n2 = 0;\n  int n3 = 0;\n  int n4 = 0;\n  int n5 = 0;\n  ASSERT_PRED_FORMAT5(AssertSumIsEven5Functor(),\n                      n1++, n2++, n3++, n4++, n5++)\n                        << \"This failure is UNEXPECTED!\";\n  EXPECT_EQ(1, n1) << \"Argument 1 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n2) << \"Argument 2 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n3) << \"Argument 3 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n4) << \"Argument 4 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n5) << \"Argument 5 is not evaluated exactly once.\";\n\n  // A failure case.\n  n1 = n2 = n3 = 0;\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED3(SumIsEven3Functor(), ++n1, n2++, n3++)\n        << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n  EXPECT_EQ(1, n1) << \"Argument 1 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n2) << \"Argument 2 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n3) << \"Argument 3 is not evaluated exactly once.\";\n\n  // Another failure case.\n  n1 = n2 = n3 = n4 = 0;\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT4(AssertSumIsEven4, ++n1, n2++, n3++, n4++);\n  }, \"evaluates to 1, which is not even.\");\n  EXPECT_EQ(1, n1) << \"Argument 1 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n2) << \"Argument 2 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n3) << \"Argument 3 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n4) << \"Argument 4 is not evaluated exactly once.\";\n}\n\n\n// Some helper functions for testing using overloaded/template\n// functions with ASSERT_PREDn and EXPECT_PREDn.\n\nbool IsPositive(double x) {\n  return x > 0;\n}\n\ntemplate <typename T>\nbool IsNegative(T x) {\n  return x < 0;\n}\n\ntemplate <typename T1, typename T2>\nbool GreaterThan(T1 x1, T2 x2) {\n  return x1 > x2;\n}\n\n// Tests that overloaded functions can be used in *_PRED* as long as\n// their types are explicitly specified.\nTEST(PredicateAssertionTest, AcceptsOverloadedFunction) {\n  // C++Builder requires C-style casts rather than static_cast.\n  EXPECT_PRED1((bool (*)(int))(IsPositive), 5);  // NOLINT\n  ASSERT_PRED1((bool (*)(double))(IsPositive), 6.0);  // NOLINT\n}\n\n// Tests that template functions can be used in *_PRED* as long as\n// their types are explicitly specified.\nTEST(PredicateAssertionTest, AcceptsTemplateFunction) {\n  EXPECT_PRED1(IsNegative<int>, -5);\n  // Makes sure that we can handle templates with more than one\n  // parameter.\n  ASSERT_PRED2((GreaterThan<int, int>), 5, 0);\n}\n\n\n// Some helper functions for testing using overloaded/template\n// functions with ASSERT_PRED_FORMATn and EXPECT_PRED_FORMATn.\n\nAssertionResult IsPositiveFormat(const char* /* expr */, int n) {\n  return n > 0 ? AssertionSuccess() :\n      AssertionFailure(Message() << \"Failure\");\n}\n\nAssertionResult IsPositiveFormat(const char* /* expr */, double x) {\n  return x > 0 ? AssertionSuccess() :\n      AssertionFailure(Message() << \"Failure\");\n}\n\ntemplate <typename T>\nAssertionResult IsNegativeFormat(const char* /* expr */, T x) {\n  return x < 0 ? AssertionSuccess() :\n      AssertionFailure(Message() << \"Failure\");\n}\n\ntemplate <typename T1, typename T2>\nAssertionResult EqualsFormat(const char* /* expr1 */, const char* /* expr2 */,\n                             const T1& x1, const T2& x2) {\n  return x1 == x2 ? AssertionSuccess() :\n      AssertionFailure(Message() << \"Failure\");\n}\n\n// Tests that overloaded functions can be used in *_PRED_FORMAT*\n// without explicitly specifying their types.\nTEST(PredicateFormatAssertionTest, AcceptsOverloadedFunction) {\n  EXPECT_PRED_FORMAT1(IsPositiveFormat, 5);\n  ASSERT_PRED_FORMAT1(IsPositiveFormat, 6.0);\n}\n\n// Tests that template functions can be used in *_PRED_FORMAT* without\n// explicitly specifying their types.\nTEST(PredicateFormatAssertionTest, AcceptsTemplateFunction) {\n  EXPECT_PRED_FORMAT1(IsNegativeFormat, -5);\n  ASSERT_PRED_FORMAT2(EqualsFormat, 3, 3);\n}\n\n\n// Tests string assertions.\n\n// Tests ASSERT_STREQ with non-NULL arguments.\nTEST(StringAssertionTest, ASSERT_STREQ) {\n  const char * const p1 = \"good\";\n  ASSERT_STREQ(p1, p1);\n\n  // Let p2 have the same content as p1, but be at a different address.\n  const char p2[] = \"good\";\n  ASSERT_STREQ(p1, p2);\n\n  EXPECT_FATAL_FAILURE(ASSERT_STREQ(\"bad\", \"good\"),\n                       \"Expected: \\\"bad\\\"\");\n}\n\n// Tests ASSERT_STREQ with NULL arguments.\nTEST(StringAssertionTest, ASSERT_STREQ_Null) {\n  ASSERT_STREQ(static_cast<const char *>(NULL), NULL);\n  EXPECT_FATAL_FAILURE(ASSERT_STREQ(NULL, \"non-null\"),\n                       \"non-null\");\n}\n\n// Tests ASSERT_STREQ with NULL arguments.\nTEST(StringAssertionTest, ASSERT_STREQ_Null2) {\n  EXPECT_FATAL_FAILURE(ASSERT_STREQ(\"non-null\", NULL),\n                       \"non-null\");\n}\n\n// Tests ASSERT_STRNE.\nTEST(StringAssertionTest, ASSERT_STRNE) {\n  ASSERT_STRNE(\"hi\", \"Hi\");\n  ASSERT_STRNE(\"Hi\", NULL);\n  ASSERT_STRNE(NULL, \"Hi\");\n  ASSERT_STRNE(\"\", NULL);\n  ASSERT_STRNE(NULL, \"\");\n  ASSERT_STRNE(\"\", \"Hi\");\n  ASSERT_STRNE(\"Hi\", \"\");\n  EXPECT_FATAL_FAILURE(ASSERT_STRNE(\"Hi\", \"Hi\"),\n                       \"\\\"Hi\\\" vs \\\"Hi\\\"\");\n}\n\n// Tests ASSERT_STRCASEEQ.\nTEST(StringAssertionTest, ASSERT_STRCASEEQ) {\n  ASSERT_STRCASEEQ(\"hi\", \"Hi\");\n  ASSERT_STRCASEEQ(static_cast<const char *>(NULL), NULL);\n\n  ASSERT_STRCASEEQ(\"\", \"\");\n  EXPECT_FATAL_FAILURE(ASSERT_STRCASEEQ(\"Hi\", \"hi2\"),\n                       \"Ignoring case\");\n}\n\n// Tests ASSERT_STRCASENE.\nTEST(StringAssertionTest, ASSERT_STRCASENE) {\n  ASSERT_STRCASENE(\"hi1\", \"Hi2\");\n  ASSERT_STRCASENE(\"Hi\", NULL);\n  ASSERT_STRCASENE(NULL, \"Hi\");\n  ASSERT_STRCASENE(\"\", NULL);\n  ASSERT_STRCASENE(NULL, \"\");\n  ASSERT_STRCASENE(\"\", \"Hi\");\n  ASSERT_STRCASENE(\"Hi\", \"\");\n  EXPECT_FATAL_FAILURE(ASSERT_STRCASENE(\"Hi\", \"hi\"),\n                       \"(ignoring case)\");\n}\n\n// Tests *_STREQ on wide strings.\nTEST(StringAssertionTest, STREQ_Wide) {\n  // NULL strings.\n  ASSERT_STREQ(static_cast<const wchar_t *>(NULL), NULL);\n\n  // Empty strings.\n  ASSERT_STREQ(L\"\", L\"\");\n\n  // Non-null vs NULL.\n  EXPECT_NONFATAL_FAILURE(EXPECT_STREQ(L\"non-null\", NULL),\n                          \"non-null\");\n\n  // Equal strings.\n  EXPECT_STREQ(L\"Hi\", L\"Hi\");\n\n  // Unequal strings.\n  EXPECT_NONFATAL_FAILURE(EXPECT_STREQ(L\"abc\", L\"Abc\"),\n                          \"Abc\");\n\n  // Strings containing wide characters.\n  EXPECT_NONFATAL_FAILURE(EXPECT_STREQ(L\"abc\\x8119\", L\"abc\\x8120\"),\n                          \"abc\");\n\n  // The streaming variation.\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_STREQ(L\"abc\\x8119\", L\"abc\\x8121\") << \"Expected failure\";\n  }, \"Expected failure\");\n}\n\n// Tests *_STRNE on wide strings.\nTEST(StringAssertionTest, STRNE_Wide) {\n  // NULL strings.\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_STRNE(static_cast<const wchar_t *>(NULL), NULL);\n  }, \"\");\n\n  // Empty strings.\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(L\"\", L\"\"),\n                          \"L\\\"\\\"\");\n\n  // Non-null vs NULL.\n  ASSERT_STRNE(L\"non-null\", NULL);\n\n  // Equal strings.\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(L\"Hi\", L\"Hi\"),\n                          \"L\\\"Hi\\\"\");\n\n  // Unequal strings.\n  EXPECT_STRNE(L\"abc\", L\"Abc\");\n\n  // Strings containing wide characters.\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(L\"abc\\x8119\", L\"abc\\x8119\"),\n                          \"abc\");\n\n  // The streaming variation.\n  ASSERT_STRNE(L\"abc\\x8119\", L\"abc\\x8120\") << \"This shouldn't happen\";\n}\n\n// Tests for ::testing::IsSubstring().\n\n// Tests that IsSubstring() returns the correct result when the input\n// argument type is const char*.\nTEST(IsSubstringTest, ReturnsCorrectResultForCString) {\n  EXPECT_FALSE(IsSubstring(\"\", \"\", NULL, \"a\"));\n  EXPECT_FALSE(IsSubstring(\"\", \"\", \"b\", NULL));\n  EXPECT_FALSE(IsSubstring(\"\", \"\", \"needle\", \"haystack\"));\n\n  EXPECT_TRUE(IsSubstring(\"\", \"\", static_cast<const char*>(NULL), NULL));\n  EXPECT_TRUE(IsSubstring(\"\", \"\", \"needle\", \"two needles\"));\n}\n\n// Tests that IsSubstring() returns the correct result when the input\n// argument type is const wchar_t*.\nTEST(IsSubstringTest, ReturnsCorrectResultForWideCString) {\n  EXPECT_FALSE(IsSubstring(\"\", \"\", kNull, L\"a\"));\n  EXPECT_FALSE(IsSubstring(\"\", \"\", L\"b\", kNull));\n  EXPECT_FALSE(IsSubstring(\"\", \"\", L\"needle\", L\"haystack\"));\n\n  EXPECT_TRUE(IsSubstring(\"\", \"\", static_cast<const wchar_t*>(NULL), NULL));\n  EXPECT_TRUE(IsSubstring(\"\", \"\", L\"needle\", L\"two needles\"));\n}\n\n// Tests that IsSubstring() generates the correct message when the input\n// argument type is const char*.\nTEST(IsSubstringTest, GeneratesCorrectMessageForCString) {\n  EXPECT_STREQ(\"Value of: needle_expr\\n\"\n               \"  Actual: \\\"needle\\\"\\n\"\n               \"Expected: a substring of haystack_expr\\n\"\n               \"Which is: \\\"haystack\\\"\",\n               IsSubstring(\"needle_expr\", \"haystack_expr\",\n                           \"needle\", \"haystack\").failure_message());\n}\n\n// Tests that IsSubstring returns the correct result when the input\n// argument type is ::std::string.\nTEST(IsSubstringTest, ReturnsCorrectResultsForStdString) {\n  EXPECT_TRUE(IsSubstring(\"\", \"\", std::string(\"hello\"), \"ahellob\"));\n  EXPECT_FALSE(IsSubstring(\"\", \"\", \"hello\", std::string(\"world\")));\n}\n\n#if GTEST_HAS_STD_WSTRING\n// Tests that IsSubstring returns the correct result when the input\n// argument type is ::std::wstring.\nTEST(IsSubstringTest, ReturnsCorrectResultForStdWstring) {\n  EXPECT_TRUE(IsSubstring(\"\", \"\", ::std::wstring(L\"needle\"), L\"two needles\"));\n  EXPECT_FALSE(IsSubstring(\"\", \"\", L\"needle\", ::std::wstring(L\"haystack\")));\n}\n\n// Tests that IsSubstring() generates the correct message when the input\n// argument type is ::std::wstring.\nTEST(IsSubstringTest, GeneratesCorrectMessageForWstring) {\n  EXPECT_STREQ(\"Value of: needle_expr\\n\"\n               \"  Actual: L\\\"needle\\\"\\n\"\n               \"Expected: a substring of haystack_expr\\n\"\n               \"Which is: L\\\"haystack\\\"\",\n               IsSubstring(\n                   \"needle_expr\", \"haystack_expr\",\n                   ::std::wstring(L\"needle\"), L\"haystack\").failure_message());\n}\n\n#endif  // GTEST_HAS_STD_WSTRING\n\n// Tests for ::testing::IsNotSubstring().\n\n// Tests that IsNotSubstring() returns the correct result when the input\n// argument type is const char*.\nTEST(IsNotSubstringTest, ReturnsCorrectResultForCString) {\n  EXPECT_TRUE(IsNotSubstring(\"\", \"\", \"needle\", \"haystack\"));\n  EXPECT_FALSE(IsNotSubstring(\"\", \"\", \"needle\", \"two needles\"));\n}\n\n// Tests that IsNotSubstring() returns the correct result when the input\n// argument type is const wchar_t*.\nTEST(IsNotSubstringTest, ReturnsCorrectResultForWideCString) {\n  EXPECT_TRUE(IsNotSubstring(\"\", \"\", L\"needle\", L\"haystack\"));\n  EXPECT_FALSE(IsNotSubstring(\"\", \"\", L\"needle\", L\"two needles\"));\n}\n\n// Tests that IsNotSubstring() generates the correct message when the input\n// argument type is const wchar_t*.\nTEST(IsNotSubstringTest, GeneratesCorrectMessageForWideCString) {\n  EXPECT_STREQ(\"Value of: needle_expr\\n\"\n               \"  Actual: L\\\"needle\\\"\\n\"\n               \"Expected: not a substring of haystack_expr\\n\"\n               \"Which is: L\\\"two needles\\\"\",\n               IsNotSubstring(\n                   \"needle_expr\", \"haystack_expr\",\n                   L\"needle\", L\"two needles\").failure_message());\n}\n\n// Tests that IsNotSubstring returns the correct result when the input\n// argument type is ::std::string.\nTEST(IsNotSubstringTest, ReturnsCorrectResultsForStdString) {\n  EXPECT_FALSE(IsNotSubstring(\"\", \"\", std::string(\"hello\"), \"ahellob\"));\n  EXPECT_TRUE(IsNotSubstring(\"\", \"\", \"hello\", std::string(\"world\")));\n}\n\n// Tests that IsNotSubstring() generates the correct message when the input\n// argument type is ::std::string.\nTEST(IsNotSubstringTest, GeneratesCorrectMessageForStdString) {\n  EXPECT_STREQ(\"Value of: needle_expr\\n\"\n               \"  Actual: \\\"needle\\\"\\n\"\n               \"Expected: not a substring of haystack_expr\\n\"\n               \"Which is: \\\"two needles\\\"\",\n               IsNotSubstring(\n                   \"needle_expr\", \"haystack_expr\",\n                   ::std::string(\"needle\"), \"two needles\").failure_message());\n}\n\n#if GTEST_HAS_STD_WSTRING\n\n// Tests that IsNotSubstring returns the correct result when the input\n// argument type is ::std::wstring.\nTEST(IsNotSubstringTest, ReturnsCorrectResultForStdWstring) {\n  EXPECT_FALSE(\n      IsNotSubstring(\"\", \"\", ::std::wstring(L\"needle\"), L\"two needles\"));\n  EXPECT_TRUE(IsNotSubstring(\"\", \"\", L\"needle\", ::std::wstring(L\"haystack\")));\n}\n\n#endif  // GTEST_HAS_STD_WSTRING\n\n// Tests floating-point assertions.\n\ntemplate <typename RawType>\nclass FloatingPointTest : public Test {\n protected:\n  // Pre-calculated numbers to be used by the tests.\n  struct TestValues {\n    RawType close_to_positive_zero;\n    RawType close_to_negative_zero;\n    RawType further_from_negative_zero;\n\n    RawType close_to_one;\n    RawType further_from_one;\n\n    RawType infinity;\n    RawType close_to_infinity;\n    RawType further_from_infinity;\n\n    RawType nan1;\n    RawType nan2;\n  };\n\n  typedef typename testing::internal::FloatingPoint<RawType> Floating;\n  typedef typename Floating::Bits Bits;\n\n  virtual void SetUp() {\n    const size_t max_ulps = Floating::kMaxUlps;\n\n    // The bits that represent 0.0.\n    const Bits zero_bits = Floating(0).bits();\n\n    // Makes some numbers close to 0.0.\n    values_.close_to_positive_zero = Floating::ReinterpretBits(\n        zero_bits + max_ulps/2);\n    values_.close_to_negative_zero = -Floating::ReinterpretBits(\n        zero_bits + max_ulps - max_ulps/2);\n    values_.further_from_negative_zero = -Floating::ReinterpretBits(\n        zero_bits + max_ulps + 1 - max_ulps/2);\n\n    // The bits that represent 1.0.\n    const Bits one_bits = Floating(1).bits();\n\n    // Makes some numbers close to 1.0.\n    values_.close_to_one = Floating::ReinterpretBits(one_bits + max_ulps);\n    values_.further_from_one = Floating::ReinterpretBits(\n        one_bits + max_ulps + 1);\n\n    // +infinity.\n    values_.infinity = Floating::Infinity();\n\n    // The bits that represent +infinity.\n    const Bits infinity_bits = Floating(values_.infinity).bits();\n\n    // Makes some numbers close to infinity.\n    values_.close_to_infinity = Floating::ReinterpretBits(\n        infinity_bits - max_ulps);\n    values_.further_from_infinity = Floating::ReinterpretBits(\n        infinity_bits - max_ulps - 1);\n\n    // Makes some NAN's.  Sets the most significant bit of the fraction so that\n    // our NaN's are quiet; trying to process a signaling NaN would raise an\n    // exception if our environment enables floating point exceptions.\n    values_.nan1 = Floating::ReinterpretBits(Floating::kExponentBitMask\n        | (static_cast<Bits>(1) << (Floating::kFractionBitCount - 1)) | 1);\n    values_.nan2 = Floating::ReinterpretBits(Floating::kExponentBitMask\n        | (static_cast<Bits>(1) << (Floating::kFractionBitCount - 1)) | 200);\n  }\n\n  void TestSize() {\n    EXPECT_EQ(sizeof(RawType), sizeof(Bits));\n  }\n\n  static TestValues values_;\n};\n\ntemplate <typename RawType>\ntypename FloatingPointTest<RawType>::TestValues\n    FloatingPointTest<RawType>::values_;\n\n// Instantiates FloatingPointTest for testing *_FLOAT_EQ.\ntypedef FloatingPointTest<float> FloatTest;\n\n// Tests that the size of Float::Bits matches the size of float.\nTEST_F(FloatTest, Size) {\n  TestSize();\n}\n\n// Tests comparing with +0 and -0.\nTEST_F(FloatTest, Zeros) {\n  EXPECT_FLOAT_EQ(0.0, -0.0);\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(-0.0, 1.0),\n                          \"1.0\");\n  EXPECT_FATAL_FAILURE(ASSERT_FLOAT_EQ(0.0, 1.5),\n                       \"1.5\");\n}\n\n// Tests comparing numbers close to 0.\n//\n// This ensures that *_FLOAT_EQ handles the sign correctly and no\n// overflow occurs when comparing numbers whose absolute value is very\n// small.\nTEST_F(FloatTest, AlmostZeros) {\n  // In C++Builder, names within local classes (such as used by\n  // EXPECT_FATAL_FAILURE) cannot be resolved against static members of the\n  // scoping class.  Use a static local alias as a workaround.\n  // We use the assignment syntax since some compilers, like Sun Studio,\n  // don't allow initializing references using construction syntax\n  // (parentheses).\n  static const FloatTest::TestValues& v = this->values_;\n\n  EXPECT_FLOAT_EQ(0.0, v.close_to_positive_zero);\n  EXPECT_FLOAT_EQ(-0.0, v.close_to_negative_zero);\n  EXPECT_FLOAT_EQ(v.close_to_positive_zero, v.close_to_negative_zero);\n\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_FLOAT_EQ(v.close_to_positive_zero,\n                    v.further_from_negative_zero);\n  }, \"v.further_from_negative_zero\");\n}\n\n// Tests comparing numbers close to each other.\nTEST_F(FloatTest, SmallDiff) {\n  EXPECT_FLOAT_EQ(1.0, values_.close_to_one);\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(1.0, values_.further_from_one),\n                          \"values_.further_from_one\");\n}\n\n// Tests comparing numbers far apart.\nTEST_F(FloatTest, LargeDiff) {\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(2.5, 3.0),\n                          \"3.0\");\n}\n\n// Tests comparing with infinity.\n//\n// This ensures that no overflow occurs when comparing numbers whose\n// absolute value is very large.\nTEST_F(FloatTest, Infinity) {\n  EXPECT_FLOAT_EQ(values_.infinity, values_.close_to_infinity);\n  EXPECT_FLOAT_EQ(-values_.infinity, -values_.close_to_infinity);\n#if !GTEST_OS_SYMBIAN\n  // Nokia's STLport crashes if we try to output infinity or NaN.\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(values_.infinity, -values_.infinity),\n                          \"-values_.infinity\");\n\n  // This is interesting as the representations of infinity and nan1\n  // are only 1 DLP apart.\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(values_.infinity, values_.nan1),\n                          \"values_.nan1\");\n#endif  // !GTEST_OS_SYMBIAN\n}\n\n// Tests that comparing with NAN always returns false.\nTEST_F(FloatTest, NaN) {\n#if !GTEST_OS_SYMBIAN\n// Nokia's STLport crashes if we try to output infinity or NaN.\n\n  // In C++Builder, names within local classes (such as used by\n  // EXPECT_FATAL_FAILURE) cannot be resolved against static members of the\n  // scoping class.  Use a static local alias as a workaround.\n  // We use the assignment syntax since some compilers, like Sun Studio,\n  // don't allow initializing references using construction syntax\n  // (parentheses).\n  static const FloatTest::TestValues& v = this->values_;\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(v.nan1, v.nan1),\n                          \"v.nan1\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(v.nan1, v.nan2),\n                          \"v.nan2\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(1.0, v.nan1),\n                          \"v.nan1\");\n\n  EXPECT_FATAL_FAILURE(ASSERT_FLOAT_EQ(v.nan1, v.infinity),\n                       \"v.infinity\");\n#endif  // !GTEST_OS_SYMBIAN\n}\n\n// Tests that *_FLOAT_EQ are reflexive.\nTEST_F(FloatTest, Reflexive) {\n  EXPECT_FLOAT_EQ(0.0, 0.0);\n  EXPECT_FLOAT_EQ(1.0, 1.0);\n  ASSERT_FLOAT_EQ(values_.infinity, values_.infinity);\n}\n\n// Tests that *_FLOAT_EQ are commutative.\nTEST_F(FloatTest, Commutative) {\n  // We already tested EXPECT_FLOAT_EQ(1.0, values_.close_to_one).\n  EXPECT_FLOAT_EQ(values_.close_to_one, 1.0);\n\n  // We already tested EXPECT_FLOAT_EQ(1.0, values_.further_from_one).\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(values_.further_from_one, 1.0),\n                          \"1.0\");\n}\n\n// Tests EXPECT_NEAR.\nTEST_F(FloatTest, EXPECT_NEAR) {\n  EXPECT_NEAR(-1.0f, -1.1f, 0.2f);\n  EXPECT_NEAR(2.0f, 3.0f, 1.0f);\n  EXPECT_NONFATAL_FAILURE(EXPECT_NEAR(1.0f,1.5f, 0.25f),  // NOLINT\n                          \"The difference between 1.0f and 1.5f is 0.5, \"\n                          \"which exceeds 0.25f\");\n  // To work around a bug in gcc 2.95.0, there is intentionally no\n  // space after the first comma in the previous line.\n}\n\n// Tests ASSERT_NEAR.\nTEST_F(FloatTest, ASSERT_NEAR) {\n  ASSERT_NEAR(-1.0f, -1.1f, 0.2f);\n  ASSERT_NEAR(2.0f, 3.0f, 1.0f);\n  EXPECT_FATAL_FAILURE(ASSERT_NEAR(1.0f,1.5f, 0.25f),  // NOLINT\n                       \"The difference between 1.0f and 1.5f is 0.5, \"\n                       \"which exceeds 0.25f\");\n  // To work around a bug in gcc 2.95.0, there is intentionally no\n  // space after the first comma in the previous line.\n}\n\n// Tests the cases where FloatLE() should succeed.\nTEST_F(FloatTest, FloatLESucceeds) {\n  EXPECT_PRED_FORMAT2(FloatLE, 1.0f, 2.0f);  // When val1 < val2,\n  ASSERT_PRED_FORMAT2(FloatLE, 1.0f, 1.0f);  // val1 == val2,\n\n  // or when val1 is greater than, but almost equals to, val2.\n  EXPECT_PRED_FORMAT2(FloatLE, values_.close_to_positive_zero, 0.0f);\n}\n\n// Tests the cases where FloatLE() should fail.\nTEST_F(FloatTest, FloatLEFails) {\n  // When val1 is greater than val2 by a large margin,\n  EXPECT_NONFATAL_FAILURE(EXPECT_PRED_FORMAT2(FloatLE, 2.0f, 1.0f),\n                          \"(2.0f) <= (1.0f)\");\n\n  // or by a small yet non-negligible margin,\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(FloatLE, values_.further_from_one, 1.0f);\n  }, \"(values_.further_from_one) <= (1.0f)\");\n\n#if !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)\n  // Nokia's STLport crashes if we try to output infinity or NaN.\n  // C++Builder gives bad results for ordered comparisons involving NaNs\n  // due to compiler bugs.\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(FloatLE, values_.nan1, values_.infinity);\n  }, \"(values_.nan1) <= (values_.infinity)\");\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(FloatLE, -values_.infinity, values_.nan1);\n  }, \"(-values_.infinity) <= (values_.nan1)\");\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT2(FloatLE, values_.nan1, values_.nan1);\n  }, \"(values_.nan1) <= (values_.nan1)\");\n#endif  // !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)\n}\n\n// Instantiates FloatingPointTest for testing *_DOUBLE_EQ.\ntypedef FloatingPointTest<double> DoubleTest;\n\n// Tests that the size of Double::Bits matches the size of double.\nTEST_F(DoubleTest, Size) {\n  TestSize();\n}\n\n// Tests comparing with +0 and -0.\nTEST_F(DoubleTest, Zeros) {\n  EXPECT_DOUBLE_EQ(0.0, -0.0);\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(-0.0, 1.0),\n                          \"1.0\");\n  EXPECT_FATAL_FAILURE(ASSERT_DOUBLE_EQ(0.0, 1.0),\n                       \"1.0\");\n}\n\n// Tests comparing numbers close to 0.\n//\n// This ensures that *_DOUBLE_EQ handles the sign correctly and no\n// overflow occurs when comparing numbers whose absolute value is very\n// small.\nTEST_F(DoubleTest, AlmostZeros) {\n  // In C++Builder, names within local classes (such as used by\n  // EXPECT_FATAL_FAILURE) cannot be resolved against static members of the\n  // scoping class.  Use a static local alias as a workaround.\n  // We use the assignment syntax since some compilers, like Sun Studio,\n  // don't allow initializing references using construction syntax\n  // (parentheses).\n  static const DoubleTest::TestValues& v = this->values_;\n\n  EXPECT_DOUBLE_EQ(0.0, v.close_to_positive_zero);\n  EXPECT_DOUBLE_EQ(-0.0, v.close_to_negative_zero);\n  EXPECT_DOUBLE_EQ(v.close_to_positive_zero, v.close_to_negative_zero);\n\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_DOUBLE_EQ(v.close_to_positive_zero,\n                     v.further_from_negative_zero);\n  }, \"v.further_from_negative_zero\");\n}\n\n// Tests comparing numbers close to each other.\nTEST_F(DoubleTest, SmallDiff) {\n  EXPECT_DOUBLE_EQ(1.0, values_.close_to_one);\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(1.0, values_.further_from_one),\n                          \"values_.further_from_one\");\n}\n\n// Tests comparing numbers far apart.\nTEST_F(DoubleTest, LargeDiff) {\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(2.0, 3.0),\n                          \"3.0\");\n}\n\n// Tests comparing with infinity.\n//\n// This ensures that no overflow occurs when comparing numbers whose\n// absolute value is very large.\nTEST_F(DoubleTest, Infinity) {\n  EXPECT_DOUBLE_EQ(values_.infinity, values_.close_to_infinity);\n  EXPECT_DOUBLE_EQ(-values_.infinity, -values_.close_to_infinity);\n#if !GTEST_OS_SYMBIAN\n  // Nokia's STLport crashes if we try to output infinity or NaN.\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(values_.infinity, -values_.infinity),\n                          \"-values_.infinity\");\n\n  // This is interesting as the representations of infinity_ and nan1_\n  // are only 1 DLP apart.\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(values_.infinity, values_.nan1),\n                          \"values_.nan1\");\n#endif  // !GTEST_OS_SYMBIAN\n}\n\n// Tests that comparing with NAN always returns false.\nTEST_F(DoubleTest, NaN) {\n#if !GTEST_OS_SYMBIAN\n  // In C++Builder, names within local classes (such as used by\n  // EXPECT_FATAL_FAILURE) cannot be resolved against static members of the\n  // scoping class.  Use a static local alias as a workaround.\n  // We use the assignment syntax since some compilers, like Sun Studio,\n  // don't allow initializing references using construction syntax\n  // (parentheses).\n  static const DoubleTest::TestValues& v = this->values_;\n\n  // Nokia's STLport crashes if we try to output infinity or NaN.\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(v.nan1, v.nan1),\n                          \"v.nan1\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(v.nan1, v.nan2), \"v.nan2\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(1.0, v.nan1), \"v.nan1\");\n  EXPECT_FATAL_FAILURE(ASSERT_DOUBLE_EQ(v.nan1, v.infinity),\n                       \"v.infinity\");\n#endif  // !GTEST_OS_SYMBIAN\n}\n\n// Tests that *_DOUBLE_EQ are reflexive.\nTEST_F(DoubleTest, Reflexive) {\n  EXPECT_DOUBLE_EQ(0.0, 0.0);\n  EXPECT_DOUBLE_EQ(1.0, 1.0);\n#if !GTEST_OS_SYMBIAN\n  // Nokia's STLport crashes if we try to output infinity or NaN.\n  ASSERT_DOUBLE_EQ(values_.infinity, values_.infinity);\n#endif  // !GTEST_OS_SYMBIAN\n}\n\n// Tests that *_DOUBLE_EQ are commutative.\nTEST_F(DoubleTest, Commutative) {\n  // We already tested EXPECT_DOUBLE_EQ(1.0, values_.close_to_one).\n  EXPECT_DOUBLE_EQ(values_.close_to_one, 1.0);\n\n  // We already tested EXPECT_DOUBLE_EQ(1.0, values_.further_from_one).\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(values_.further_from_one, 1.0),\n                          \"1.0\");\n}\n\n// Tests EXPECT_NEAR.\nTEST_F(DoubleTest, EXPECT_NEAR) {\n  EXPECT_NEAR(-1.0, -1.1, 0.2);\n  EXPECT_NEAR(2.0, 3.0, 1.0);\n  EXPECT_NONFATAL_FAILURE(EXPECT_NEAR(1.0, 1.5, 0.25),  // NOLINT\n                          \"The difference between 1.0 and 1.5 is 0.5, \"\n                          \"which exceeds 0.25\");\n  // To work around a bug in gcc 2.95.0, there is intentionally no\n  // space after the first comma in the previous statement.\n}\n\n// Tests ASSERT_NEAR.\nTEST_F(DoubleTest, ASSERT_NEAR) {\n  ASSERT_NEAR(-1.0, -1.1, 0.2);\n  ASSERT_NEAR(2.0, 3.0, 1.0);\n  EXPECT_FATAL_FAILURE(ASSERT_NEAR(1.0, 1.5, 0.25),  // NOLINT\n                       \"The difference between 1.0 and 1.5 is 0.5, \"\n                       \"which exceeds 0.25\");\n  // To work around a bug in gcc 2.95.0, there is intentionally no\n  // space after the first comma in the previous statement.\n}\n\n// Tests the cases where DoubleLE() should succeed.\nTEST_F(DoubleTest, DoubleLESucceeds) {\n  EXPECT_PRED_FORMAT2(DoubleLE, 1.0, 2.0);  // When val1 < val2,\n  ASSERT_PRED_FORMAT2(DoubleLE, 1.0, 1.0);  // val1 == val2,\n\n  // or when val1 is greater than, but almost equals to, val2.\n  EXPECT_PRED_FORMAT2(DoubleLE, values_.close_to_positive_zero, 0.0);\n}\n\n// Tests the cases where DoubleLE() should fail.\nTEST_F(DoubleTest, DoubleLEFails) {\n  // When val1 is greater than val2 by a large margin,\n  EXPECT_NONFATAL_FAILURE(EXPECT_PRED_FORMAT2(DoubleLE, 2.0, 1.0),\n                          \"(2.0) <= (1.0)\");\n\n  // or by a small yet non-negligible margin,\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(DoubleLE, values_.further_from_one, 1.0);\n  }, \"(values_.further_from_one) <= (1.0)\");\n\n#if !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)\n  // Nokia's STLport crashes if we try to output infinity or NaN.\n  // C++Builder gives bad results for ordered comparisons involving NaNs\n  // due to compiler bugs.\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(DoubleLE, values_.nan1, values_.infinity);\n  }, \"(values_.nan1) <= (values_.infinity)\");\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(DoubleLE, -values_.infinity, values_.nan1);\n  }, \" (-values_.infinity) <= (values_.nan1)\");\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT2(DoubleLE, values_.nan1, values_.nan1);\n  }, \"(values_.nan1) <= (values_.nan1)\");\n#endif  // !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)\n}\n\n\n// Verifies that a test or test case whose name starts with DISABLED_ is\n// not run.\n\n// A test whose name starts with DISABLED_.\n// Should not run.\nTEST(DisabledTest, DISABLED_TestShouldNotRun) {\n  FAIL() << \"Unexpected failure: Disabled test should not be run.\";\n}\n\n// A test whose name does not start with DISABLED_.\n// Should run.\nTEST(DisabledTest, NotDISABLED_TestShouldRun) {\n  EXPECT_EQ(1, 1);\n}\n\n// A test case whose name starts with DISABLED_.\n// Should not run.\nTEST(DISABLED_TestCase, TestShouldNotRun) {\n  FAIL() << \"Unexpected failure: Test in disabled test case should not be run.\";\n}\n\n// A test case and test whose names start with DISABLED_.\n// Should not run.\nTEST(DISABLED_TestCase, DISABLED_TestShouldNotRun) {\n  FAIL() << \"Unexpected failure: Test in disabled test case should not be run.\";\n}\n\n// Check that when all tests in a test case are disabled, SetupTestCase() and\n// TearDownTestCase() are not called.\nclass DisabledTestsTest : public Test {\n protected:\n  static void SetUpTestCase() {\n    FAIL() << \"Unexpected failure: All tests disabled in test case. \"\n              \"SetupTestCase() should not be called.\";\n  }\n\n  static void TearDownTestCase() {\n    FAIL() << \"Unexpected failure: All tests disabled in test case. \"\n              \"TearDownTestCase() should not be called.\";\n  }\n};\n\nTEST_F(DisabledTestsTest, DISABLED_TestShouldNotRun_1) {\n  FAIL() << \"Unexpected failure: Disabled test should not be run.\";\n}\n\nTEST_F(DisabledTestsTest, DISABLED_TestShouldNotRun_2) {\n  FAIL() << \"Unexpected failure: Disabled test should not be run.\";\n}\n\n// Tests that disabled typed tests aren't run.\n\n#if GTEST_HAS_TYPED_TEST\n\ntemplate <typename T>\nclass TypedTest : public Test {\n};\n\ntypedef testing::Types<int, double> NumericTypes;\nTYPED_TEST_CASE(TypedTest, NumericTypes);\n\nTYPED_TEST(TypedTest, DISABLED_ShouldNotRun) {\n  FAIL() << \"Unexpected failure: Disabled typed test should not run.\";\n}\n\ntemplate <typename T>\nclass DISABLED_TypedTest : public Test {\n};\n\nTYPED_TEST_CASE(DISABLED_TypedTest, NumericTypes);\n\nTYPED_TEST(DISABLED_TypedTest, ShouldNotRun) {\n  FAIL() << \"Unexpected failure: Disabled typed test should not run.\";\n}\n\n#endif  // GTEST_HAS_TYPED_TEST\n\n// Tests that disabled type-parameterized tests aren't run.\n\n#if GTEST_HAS_TYPED_TEST_P\n\ntemplate <typename T>\nclass TypedTestP : public Test {\n};\n\nTYPED_TEST_CASE_P(TypedTestP);\n\nTYPED_TEST_P(TypedTestP, DISABLED_ShouldNotRun) {\n  FAIL() << \"Unexpected failure: \"\n         << \"Disabled type-parameterized test should not run.\";\n}\n\nREGISTER_TYPED_TEST_CASE_P(TypedTestP, DISABLED_ShouldNotRun);\n\nINSTANTIATE_TYPED_TEST_CASE_P(My, TypedTestP, NumericTypes);\n\ntemplate <typename T>\nclass DISABLED_TypedTestP : public Test {\n};\n\nTYPED_TEST_CASE_P(DISABLED_TypedTestP);\n\nTYPED_TEST_P(DISABLED_TypedTestP, ShouldNotRun) {\n  FAIL() << \"Unexpected failure: \"\n         << \"Disabled type-parameterized test should not run.\";\n}\n\nREGISTER_TYPED_TEST_CASE_P(DISABLED_TypedTestP, ShouldNotRun);\n\nINSTANTIATE_TYPED_TEST_CASE_P(My, DISABLED_TypedTestP, NumericTypes);\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n\n// Tests that assertion macros evaluate their arguments exactly once.\n\nclass SingleEvaluationTest : public Test {\n public:  // Must be public and not protected due to a bug in g++ 3.4.2.\n  // This helper function is needed by the FailedASSERT_STREQ test\n  // below.  It's public to work around C++Builder's bug with scoping local\n  // classes.\n  static void CompareAndIncrementCharPtrs() {\n    ASSERT_STREQ(p1_++, p2_++);\n  }\n\n  // This helper function is needed by the FailedASSERT_NE test below.  It's\n  // public to work around C++Builder's bug with scoping local classes.\n  static void CompareAndIncrementInts() {\n    ASSERT_NE(a_++, b_++);\n  }\n\n protected:\n  SingleEvaluationTest() {\n    p1_ = s1_;\n    p2_ = s2_;\n    a_ = 0;\n    b_ = 0;\n  }\n\n  static const char* const s1_;\n  static const char* const s2_;\n  static const char* p1_;\n  static const char* p2_;\n\n  static int a_;\n  static int b_;\n};\n\nconst char* const SingleEvaluationTest::s1_ = \"01234\";\nconst char* const SingleEvaluationTest::s2_ = \"abcde\";\nconst char* SingleEvaluationTest::p1_;\nconst char* SingleEvaluationTest::p2_;\nint SingleEvaluationTest::a_;\nint SingleEvaluationTest::b_;\n\n// Tests that when ASSERT_STREQ fails, it evaluates its arguments\n// exactly once.\nTEST_F(SingleEvaluationTest, FailedASSERT_STREQ) {\n  EXPECT_FATAL_FAILURE(SingleEvaluationTest::CompareAndIncrementCharPtrs(),\n                       \"p2_++\");\n  EXPECT_EQ(s1_ + 1, p1_);\n  EXPECT_EQ(s2_ + 1, p2_);\n}\n\n// Tests that string assertion arguments are evaluated exactly once.\nTEST_F(SingleEvaluationTest, ASSERT_STR) {\n  // successful EXPECT_STRNE\n  EXPECT_STRNE(p1_++, p2_++);\n  EXPECT_EQ(s1_ + 1, p1_);\n  EXPECT_EQ(s2_ + 1, p2_);\n\n  // failed EXPECT_STRCASEEQ\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRCASEEQ(p1_++, p2_++),\n                          \"Ignoring case\");\n  EXPECT_EQ(s1_ + 2, p1_);\n  EXPECT_EQ(s2_ + 2, p2_);\n}\n\n// Tests that when ASSERT_NE fails, it evaluates its arguments exactly\n// once.\nTEST_F(SingleEvaluationTest, FailedASSERT_NE) {\n  EXPECT_FATAL_FAILURE(SingleEvaluationTest::CompareAndIncrementInts(),\n                       \"(a_++) != (b_++)\");\n  EXPECT_EQ(1, a_);\n  EXPECT_EQ(1, b_);\n}\n\n// Tests that assertion arguments are evaluated exactly once.\nTEST_F(SingleEvaluationTest, OtherCases) {\n  // successful EXPECT_TRUE\n  EXPECT_TRUE(0 == a_++);  // NOLINT\n  EXPECT_EQ(1, a_);\n\n  // failed EXPECT_TRUE\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(-1 == a_++), \"-1 == a_++\");\n  EXPECT_EQ(2, a_);\n\n  // successful EXPECT_GT\n  EXPECT_GT(a_++, b_++);\n  EXPECT_EQ(3, a_);\n  EXPECT_EQ(1, b_);\n\n  // failed EXPECT_LT\n  EXPECT_NONFATAL_FAILURE(EXPECT_LT(a_++, b_++), \"(a_++) < (b_++)\");\n  EXPECT_EQ(4, a_);\n  EXPECT_EQ(2, b_);\n\n  // successful ASSERT_TRUE\n  ASSERT_TRUE(0 < a_++);  // NOLINT\n  EXPECT_EQ(5, a_);\n\n  // successful ASSERT_GT\n  ASSERT_GT(a_++, b_++);\n  EXPECT_EQ(6, a_);\n  EXPECT_EQ(3, b_);\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\nvoid ThrowAnInteger() {\n  throw 1;\n}\n\n// Tests that assertion arguments are evaluated exactly once.\nTEST_F(SingleEvaluationTest, ExceptionTests) {\n  // successful EXPECT_THROW\n  EXPECT_THROW({  // NOLINT\n    a_++;\n    ThrowAnInteger();\n  }, int);\n  EXPECT_EQ(1, a_);\n\n  // failed EXPECT_THROW, throws different\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW({  // NOLINT\n    a_++;\n    ThrowAnInteger();\n  }, bool), \"throws a different type\");\n  EXPECT_EQ(2, a_);\n\n  // failed EXPECT_THROW, throws nothing\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW(a_++, bool), \"throws nothing\");\n  EXPECT_EQ(3, a_);\n\n  // successful EXPECT_NO_THROW\n  EXPECT_NO_THROW(a_++);\n  EXPECT_EQ(4, a_);\n\n  // failed EXPECT_NO_THROW\n  EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW({  // NOLINT\n    a_++;\n    ThrowAnInteger();\n  }), \"it throws\");\n  EXPECT_EQ(5, a_);\n\n  // successful EXPECT_ANY_THROW\n  EXPECT_ANY_THROW({  // NOLINT\n    a_++;\n    ThrowAnInteger();\n  });\n  EXPECT_EQ(6, a_);\n\n  // failed EXPECT_ANY_THROW\n  EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(a_++), \"it doesn't\");\n  EXPECT_EQ(7, a_);\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// Tests {ASSERT|EXPECT}_NO_FATAL_FAILURE.\nclass NoFatalFailureTest : public Test {\n protected:\n  void Succeeds() {}\n  void FailsNonFatal() {\n    ADD_FAILURE() << \"some non-fatal failure\";\n  }\n  void Fails() {\n    FAIL() << \"some fatal failure\";\n  }\n\n  void DoAssertNoFatalFailureOnFails() {\n    ASSERT_NO_FATAL_FAILURE(Fails());\n    ADD_FAILURE() << \"shold not reach here.\";\n  }\n\n  void DoExpectNoFatalFailureOnFails() {\n    EXPECT_NO_FATAL_FAILURE(Fails());\n    ADD_FAILURE() << \"other failure\";\n  }\n};\n\nTEST_F(NoFatalFailureTest, NoFailure) {\n  EXPECT_NO_FATAL_FAILURE(Succeeds());\n  ASSERT_NO_FATAL_FAILURE(Succeeds());\n}\n\nTEST_F(NoFatalFailureTest, NonFatalIsNoFailure) {\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_NO_FATAL_FAILURE(FailsNonFatal()),\n      \"some non-fatal failure\");\n  EXPECT_NONFATAL_FAILURE(\n      ASSERT_NO_FATAL_FAILURE(FailsNonFatal()),\n      \"some non-fatal failure\");\n}\n\nTEST_F(NoFatalFailureTest, AssertNoFatalFailureOnFatalFailure) {\n  TestPartResultArray gtest_failures;\n  {\n    ScopedFakeTestPartResultReporter gtest_reporter(&gtest_failures);\n    DoAssertNoFatalFailureOnFails();\n  }\n  ASSERT_EQ(2, gtest_failures.size());\n  EXPECT_EQ(TestPartResult::kFatalFailure,\n            gtest_failures.GetTestPartResult(0).type());\n  EXPECT_EQ(TestPartResult::kFatalFailure,\n            gtest_failures.GetTestPartResult(1).type());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"some fatal failure\",\n                      gtest_failures.GetTestPartResult(0).message());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"it does\",\n                      gtest_failures.GetTestPartResult(1).message());\n}\n\nTEST_F(NoFatalFailureTest, ExpectNoFatalFailureOnFatalFailure) {\n  TestPartResultArray gtest_failures;\n  {\n    ScopedFakeTestPartResultReporter gtest_reporter(&gtest_failures);\n    DoExpectNoFatalFailureOnFails();\n  }\n  ASSERT_EQ(3, gtest_failures.size());\n  EXPECT_EQ(TestPartResult::kFatalFailure,\n            gtest_failures.GetTestPartResult(0).type());\n  EXPECT_EQ(TestPartResult::kNonFatalFailure,\n            gtest_failures.GetTestPartResult(1).type());\n  EXPECT_EQ(TestPartResult::kNonFatalFailure,\n            gtest_failures.GetTestPartResult(2).type());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"some fatal failure\",\n                      gtest_failures.GetTestPartResult(0).message());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"it does\",\n                      gtest_failures.GetTestPartResult(1).message());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"other failure\",\n                      gtest_failures.GetTestPartResult(2).message());\n}\n\nTEST_F(NoFatalFailureTest, MessageIsStreamable) {\n  TestPartResultArray gtest_failures;\n  {\n    ScopedFakeTestPartResultReporter gtest_reporter(&gtest_failures);\n    EXPECT_NO_FATAL_FAILURE(FAIL() << \"foo\") << \"my message\";\n  }\n  ASSERT_EQ(2, gtest_failures.size());\n  EXPECT_EQ(TestPartResult::kNonFatalFailure,\n            gtest_failures.GetTestPartResult(0).type());\n  EXPECT_EQ(TestPartResult::kNonFatalFailure,\n            gtest_failures.GetTestPartResult(1).type());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"foo\",\n                      gtest_failures.GetTestPartResult(0).message());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"my message\",\n                      gtest_failures.GetTestPartResult(1).message());\n}\n\n// Tests non-string assertions.\n\nstd::string EditsToString(const std::vector<EditType>& edits) {\n  std::string out;\n  for (size_t i = 0; i < edits.size(); ++i) {\n    static const char kEdits[] = \" +-/\";\n    out.append(1, kEdits[edits[i]]);\n  }\n  return out;\n}\n\nstd::vector<size_t> CharsToIndices(const std::string& str) {\n  std::vector<size_t> out;\n  for (size_t i = 0; i < str.size(); ++i) {\n    out.push_back(str[i]);\n  }\n  return out;\n}\n\nstd::vector<std::string> CharsToLines(const std::string& str) {\n  std::vector<std::string> out;\n  for (size_t i = 0; i < str.size(); ++i) {\n    out.push_back(str.substr(i, 1));\n  }\n  return out;\n}\n\nTEST(EditDistance, TestCases) {\n  struct Case {\n    int line;\n    const char* left;\n    const char* right;\n    const char* expected_edits;\n    const char* expected_diff;\n  };\n  static const Case kCases[] = {\n      // No change.\n      {__LINE__, \"A\", \"A\", \" \", \"\"},\n      {__LINE__, \"ABCDE\", \"ABCDE\", \"     \", \"\"},\n      // Simple adds.\n      {__LINE__, \"X\", \"XA\", \" +\", \"@@ +1,2 @@\\n X\\n+A\\n\"},\n      {__LINE__, \"X\", \"XABCD\", \" ++++\", \"@@ +1,5 @@\\n X\\n+A\\n+B\\n+C\\n+D\\n\"},\n      // Simple removes.\n      {__LINE__, \"XA\", \"X\", \" -\", \"@@ -1,2 @@\\n X\\n-A\\n\"},\n      {__LINE__, \"XABCD\", \"X\", \" ----\", \"@@ -1,5 @@\\n X\\n-A\\n-B\\n-C\\n-D\\n\"},\n      // Simple replaces.\n      {__LINE__, \"A\", \"a\", \"/\", \"@@ -1,1 +1,1 @@\\n-A\\n+a\\n\"},\n      {__LINE__, \"ABCD\", \"abcd\", \"////\",\n       \"@@ -1,4 +1,4 @@\\n-A\\n-B\\n-C\\n-D\\n+a\\n+b\\n+c\\n+d\\n\"},\n      // Path finding.\n      {__LINE__, \"ABCDEFGH\", \"ABXEGH1\", \"  -/ -  +\",\n       \"@@ -1,8 +1,7 @@\\n A\\n B\\n-C\\n-D\\n+X\\n E\\n-F\\n G\\n H\\n+1\\n\"},\n      {__LINE__, \"AAAABCCCC\", \"ABABCDCDC\", \"- /   + / \",\n       \"@@ -1,9 +1,9 @@\\n-A\\n A\\n-A\\n+B\\n A\\n B\\n C\\n+D\\n C\\n-C\\n+D\\n C\\n\"},\n      {__LINE__, \"ABCDE\", \"BCDCD\", \"-   +/\",\n       \"@@ -1,5 +1,5 @@\\n-A\\n B\\n C\\n D\\n-E\\n+C\\n+D\\n\"},\n      {__LINE__, \"ABCDEFGHIJKL\", \"BCDCDEFGJKLJK\", \"- ++     --   ++\",\n       \"@@ -1,4 +1,5 @@\\n-A\\n B\\n+C\\n+D\\n C\\n D\\n\"\n       \"@@ -6,7 +7,7 @@\\n F\\n G\\n-H\\n-I\\n J\\n K\\n L\\n+J\\n+K\\n\"},\n      {}};\n  for (const Case* c = kCases; c->left; ++c) {\n    EXPECT_TRUE(c->expected_edits ==\n                EditsToString(CalculateOptimalEdits(CharsToIndices(c->left),\n                                                    CharsToIndices(c->right))))\n        << \"Left <\" << c->left << \"> Right <\" << c->right << \"> Edits <\"\n        << EditsToString(CalculateOptimalEdits(\n               CharsToIndices(c->left), CharsToIndices(c->right))) << \">\";\n    EXPECT_TRUE(c->expected_diff == CreateUnifiedDiff(CharsToLines(c->left),\n                                                      CharsToLines(c->right)))\n        << \"Left <\" << c->left << \"> Right <\" << c->right << \"> Diff <\"\n        << CreateUnifiedDiff(CharsToLines(c->left), CharsToLines(c->right))\n        << \">\";\n  }\n}\n\n// Tests EqFailure(), used for implementing *EQ* assertions.\nTEST(AssertionTest, EqFailure) {\n  const std::string foo_val(\"5\"), bar_val(\"6\");\n  const std::string msg1(\n      EqFailure(\"foo\", \"bar\", foo_val, bar_val, false)\n      .failure_message());\n  EXPECT_STREQ(\n      \"      Expected: foo\\n\"\n      \"      Which is: 5\\n\"\n      \"To be equal to: bar\\n\"\n      \"      Which is: 6\",\n      msg1.c_str());\n\n  const std::string msg2(\n      EqFailure(\"foo\", \"6\", foo_val, bar_val, false)\n      .failure_message());\n  EXPECT_STREQ(\n      \"      Expected: foo\\n\"\n      \"      Which is: 5\\n\"\n      \"To be equal to: 6\",\n      msg2.c_str());\n\n  const std::string msg3(\n      EqFailure(\"5\", \"bar\", foo_val, bar_val, false)\n      .failure_message());\n  EXPECT_STREQ(\n      \"      Expected: 5\\n\"\n      \"To be equal to: bar\\n\"\n      \"      Which is: 6\",\n      msg3.c_str());\n\n  const std::string msg4(\n      EqFailure(\"5\", \"6\", foo_val, bar_val, false).failure_message());\n  EXPECT_STREQ(\n      \"      Expected: 5\\n\"\n      \"To be equal to: 6\",\n      msg4.c_str());\n\n  const std::string msg5(\n      EqFailure(\"foo\", \"bar\",\n                std::string(\"\\\"x\\\"\"), std::string(\"\\\"y\\\"\"),\n                true).failure_message());\n  EXPECT_STREQ(\n      \"      Expected: foo\\n\"\n      \"      Which is: \\\"x\\\"\\n\"\n      \"To be equal to: bar\\n\"\n      \"      Which is: \\\"y\\\"\\n\"\n      \"Ignoring case\",\n      msg5.c_str());\n}\n\nTEST(AssertionTest, EqFailureWithDiff) {\n  const std::string left(\n      \"1\\\\n2XXX\\\\n3\\\\n5\\\\n6\\\\n7\\\\n8\\\\n9\\\\n10\\\\n11\\\\n12XXX\\\\n13\\\\n14\\\\n15\");\n  const std::string right(\n      \"1\\\\n2\\\\n3\\\\n4\\\\n5\\\\n6\\\\n7\\\\n8\\\\n9\\\\n11\\\\n12\\\\n13\\\\n14\");\n  const std::string msg1(\n      EqFailure(\"left\", \"right\", left, right, false).failure_message());\n  EXPECT_STREQ(\n      \"      Expected: left\\n\"\n      \"      Which is: \"\n      \"1\\\\n2XXX\\\\n3\\\\n5\\\\n6\\\\n7\\\\n8\\\\n9\\\\n10\\\\n11\\\\n12XXX\\\\n13\\\\n14\\\\n15\\n\"\n      \"To be equal to: right\\n\"\n      \"      Which is: 1\\\\n2\\\\n3\\\\n4\\\\n5\\\\n6\\\\n7\\\\n8\\\\n9\\\\n11\\\\n12\\\\n13\\\\n14\\n\"\n      \"With diff:\\n@@ -1,5 +1,6 @@\\n 1\\n-2XXX\\n+2\\n 3\\n+4\\n 5\\n 6\\n\"\n      \"@@ -7,8 +8,6 @@\\n 8\\n 9\\n-10\\n 11\\n-12XXX\\n+12\\n 13\\n 14\\n-15\\n\",\n      msg1.c_str());\n}\n\n// Tests AppendUserMessage(), used for implementing the *EQ* macros.\nTEST(AssertionTest, AppendUserMessage) {\n  const std::string foo(\"foo\");\n\n  Message msg;\n  EXPECT_STREQ(\"foo\",\n               AppendUserMessage(foo, msg).c_str());\n\n  msg << \"bar\";\n  EXPECT_STREQ(\"foo\\nbar\",\n               AppendUserMessage(foo, msg).c_str());\n}\n\n#ifdef __BORLANDC__\n// Silences warnings: \"Condition is always true\", \"Unreachable code\"\n# pragma option push -w-ccc -w-rch\n#endif\n\n// Tests ASSERT_TRUE.\nTEST(AssertionTest, ASSERT_TRUE) {\n  ASSERT_TRUE(2 > 1);  // NOLINT\n  EXPECT_FATAL_FAILURE(ASSERT_TRUE(2 < 1),\n                       \"2 < 1\");\n}\n\n// Tests ASSERT_TRUE(predicate) for predicates returning AssertionResult.\nTEST(AssertionTest, AssertTrueWithAssertionResult) {\n  ASSERT_TRUE(ResultIsEven(2));\n#ifndef __BORLANDC__\n  // ICE's in C++Builder.\n  EXPECT_FATAL_FAILURE(ASSERT_TRUE(ResultIsEven(3)),\n                       \"Value of: ResultIsEven(3)\\n\"\n                       \"  Actual: false (3 is odd)\\n\"\n                       \"Expected: true\");\n#endif\n  ASSERT_TRUE(ResultIsEvenNoExplanation(2));\n  EXPECT_FATAL_FAILURE(ASSERT_TRUE(ResultIsEvenNoExplanation(3)),\n                       \"Value of: ResultIsEvenNoExplanation(3)\\n\"\n                       \"  Actual: false (3 is odd)\\n\"\n                       \"Expected: true\");\n}\n\n// Tests ASSERT_FALSE.\nTEST(AssertionTest, ASSERT_FALSE) {\n  ASSERT_FALSE(2 < 1);  // NOLINT\n  EXPECT_FATAL_FAILURE(ASSERT_FALSE(2 > 1),\n                       \"Value of: 2 > 1\\n\"\n                       \"  Actual: true\\n\"\n                       \"Expected: false\");\n}\n\n// Tests ASSERT_FALSE(predicate) for predicates returning AssertionResult.\nTEST(AssertionTest, AssertFalseWithAssertionResult) {\n  ASSERT_FALSE(ResultIsEven(3));\n#ifndef __BORLANDC__\n  // ICE's in C++Builder.\n  EXPECT_FATAL_FAILURE(ASSERT_FALSE(ResultIsEven(2)),\n                       \"Value of: ResultIsEven(2)\\n\"\n                       \"  Actual: true (2 is even)\\n\"\n                       \"Expected: false\");\n#endif\n  ASSERT_FALSE(ResultIsEvenNoExplanation(3));\n  EXPECT_FATAL_FAILURE(ASSERT_FALSE(ResultIsEvenNoExplanation(2)),\n                       \"Value of: ResultIsEvenNoExplanation(2)\\n\"\n                       \"  Actual: true\\n\"\n                       \"Expected: false\");\n}\n\n#ifdef __BORLANDC__\n// Restores warnings after previous \"#pragma option push\" supressed them\n# pragma option pop\n#endif\n\n// Tests using ASSERT_EQ on double values.  The purpose is to make\n// sure that the specialization we did for integer and anonymous enums\n// isn't used for double arguments.\nTEST(ExpectTest, ASSERT_EQ_Double) {\n  // A success.\n  ASSERT_EQ(5.6, 5.6);\n\n  // A failure.\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(5.1, 5.2),\n                       \"5.1\");\n}\n\n// Tests ASSERT_EQ.\nTEST(AssertionTest, ASSERT_EQ) {\n  ASSERT_EQ(5, 2 + 3);\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(5, 2*3),\n                       \"      Expected: 5\\n\"\n                       \"To be equal to: 2*3\\n\"\n                       \"      Which is: 6\");\n}\n\n// Tests ASSERT_EQ(NULL, pointer).\n#if GTEST_CAN_COMPARE_NULL\nTEST(AssertionTest, ASSERT_EQ_NULL) {\n  // A success.\n  const char* p = NULL;\n  // Some older GCC versions may issue a spurious waring in this or the next\n  // assertion statement. This warning should not be suppressed with\n  // static_cast since the test verifies the ability to use bare NULL as the\n  // expected parameter to the macro.\n  ASSERT_EQ(NULL, p);\n\n  // A failure.\n  static int n = 0;\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(NULL, &n),\n                       \"To be equal to: &n\\n\");\n}\n#endif  // GTEST_CAN_COMPARE_NULL\n\n// Tests ASSERT_EQ(0, non_pointer).  Since the literal 0 can be\n// treated as a null pointer by the compiler, we need to make sure\n// that ASSERT_EQ(0, non_pointer) isn't interpreted by Google Test as\n// ASSERT_EQ(static_cast<void*>(NULL), non_pointer).\nTEST(ExpectTest, ASSERT_EQ_0) {\n  int n = 0;\n\n  // A success.\n  ASSERT_EQ(0, n);\n\n  // A failure.\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(0, 5.6),\n                       \"Expected: 0\");\n}\n\n// Tests ASSERT_NE.\nTEST(AssertionTest, ASSERT_NE) {\n  ASSERT_NE(6, 7);\n  EXPECT_FATAL_FAILURE(ASSERT_NE('a', 'a'),\n                       \"Expected: ('a') != ('a'), \"\n                       \"actual: 'a' (97, 0x61) vs 'a' (97, 0x61)\");\n}\n\n// Tests ASSERT_LE.\nTEST(AssertionTest, ASSERT_LE) {\n  ASSERT_LE(2, 3);\n  ASSERT_LE(2, 2);\n  EXPECT_FATAL_FAILURE(ASSERT_LE(2, 0),\n                       \"Expected: (2) <= (0), actual: 2 vs 0\");\n}\n\n// Tests ASSERT_LT.\nTEST(AssertionTest, ASSERT_LT) {\n  ASSERT_LT(2, 3);\n  EXPECT_FATAL_FAILURE(ASSERT_LT(2, 2),\n                       \"Expected: (2) < (2), actual: 2 vs 2\");\n}\n\n// Tests ASSERT_GE.\nTEST(AssertionTest, ASSERT_GE) {\n  ASSERT_GE(2, 1);\n  ASSERT_GE(2, 2);\n  EXPECT_FATAL_FAILURE(ASSERT_GE(2, 3),\n                       \"Expected: (2) >= (3), actual: 2 vs 3\");\n}\n\n// Tests ASSERT_GT.\nTEST(AssertionTest, ASSERT_GT) {\n  ASSERT_GT(2, 1);\n  EXPECT_FATAL_FAILURE(ASSERT_GT(2, 2),\n                       \"Expected: (2) > (2), actual: 2 vs 2\");\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\nvoid ThrowNothing() {}\n\n// Tests ASSERT_THROW.\nTEST(AssertionTest, ASSERT_THROW) {\n  ASSERT_THROW(ThrowAnInteger(), int);\n\n# ifndef __BORLANDC__\n\n  // ICE's in C++Builder 2007 and 2009.\n  EXPECT_FATAL_FAILURE(\n      ASSERT_THROW(ThrowAnInteger(), bool),\n      \"Expected: ThrowAnInteger() throws an exception of type bool.\\n\"\n      \"  Actual: it throws a different type.\");\n# endif\n\n  EXPECT_FATAL_FAILURE(\n      ASSERT_THROW(ThrowNothing(), bool),\n      \"Expected: ThrowNothing() throws an exception of type bool.\\n\"\n      \"  Actual: it throws nothing.\");\n}\n\n// Tests ASSERT_NO_THROW.\nTEST(AssertionTest, ASSERT_NO_THROW) {\n  ASSERT_NO_THROW(ThrowNothing());\n  EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnInteger()),\n                       \"Expected: ThrowAnInteger() doesn't throw an exception.\"\n                       \"\\n  Actual: it throws.\");\n}\n\n// Tests ASSERT_ANY_THROW.\nTEST(AssertionTest, ASSERT_ANY_THROW) {\n  ASSERT_ANY_THROW(ThrowAnInteger());\n  EXPECT_FATAL_FAILURE(\n      ASSERT_ANY_THROW(ThrowNothing()),\n      \"Expected: ThrowNothing() throws an exception.\\n\"\n      \"  Actual: it doesn't.\");\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// Makes sure we deal with the precedence of <<.  This test should\n// compile.\nTEST(AssertionTest, AssertPrecedence) {\n  ASSERT_EQ(1 < 2, true);\n  bool false_value = false;\n  ASSERT_EQ(true && false_value, false);\n}\n\n// A subroutine used by the following test.\nvoid TestEq1(int x) {\n  ASSERT_EQ(1, x);\n}\n\n// Tests calling a test subroutine that's not part of a fixture.\nTEST(AssertionTest, NonFixtureSubroutine) {\n  EXPECT_FATAL_FAILURE(TestEq1(2),\n                       \"To be equal to: x\");\n}\n\n// An uncopyable class.\nclass Uncopyable {\n public:\n  explicit Uncopyable(int a_value) : value_(a_value) {}\n\n  int value() const { return value_; }\n  bool operator==(const Uncopyable& rhs) const {\n    return value() == rhs.value();\n  }\n private:\n  // This constructor deliberately has no implementation, as we don't\n  // want this class to be copyable.\n  Uncopyable(const Uncopyable&);  // NOLINT\n\n  int value_;\n};\n\n::std::ostream& operator<<(::std::ostream& os, const Uncopyable& value) {\n  return os << value.value();\n}\n\n\nbool IsPositiveUncopyable(const Uncopyable& x) {\n  return x.value() > 0;\n}\n\n// A subroutine used by the following test.\nvoid TestAssertNonPositive() {\n  Uncopyable y(-1);\n  ASSERT_PRED1(IsPositiveUncopyable, y);\n}\n// A subroutine used by the following test.\nvoid TestAssertEqualsUncopyable() {\n  Uncopyable x(5);\n  Uncopyable y(-1);\n  ASSERT_EQ(x, y);\n}\n\n// Tests that uncopyable objects can be used in assertions.\nTEST(AssertionTest, AssertWorksWithUncopyableObject) {\n  Uncopyable x(5);\n  ASSERT_PRED1(IsPositiveUncopyable, x);\n  ASSERT_EQ(x, x);\n  EXPECT_FATAL_FAILURE(TestAssertNonPositive(),\n    \"IsPositiveUncopyable(y) evaluates to false, where\\ny evaluates to -1\");\n  EXPECT_FATAL_FAILURE(TestAssertEqualsUncopyable(),\n    \"Expected: x\\n      Which is: 5\\nTo be equal to: y\\n      Which is: -1\");\n}\n\n// Tests that uncopyable objects can be used in expects.\nTEST(AssertionTest, ExpectWorksWithUncopyableObject) {\n  Uncopyable x(5);\n  EXPECT_PRED1(IsPositiveUncopyable, x);\n  Uncopyable y(-1);\n  EXPECT_NONFATAL_FAILURE(EXPECT_PRED1(IsPositiveUncopyable, y),\n    \"IsPositiveUncopyable(y) evaluates to false, where\\ny evaluates to -1\");\n  EXPECT_EQ(x, x);\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(x, y),\n    \"Expected: x\\n      Which is: 5\\nTo be equal to: y\\n      Which is: -1\");\n}\n\nenum NamedEnum {\n  kE1 = 0,\n  kE2 = 1\n};\n\nTEST(AssertionTest, NamedEnum) {\n  EXPECT_EQ(kE1, kE1);\n  EXPECT_LT(kE1, kE2);\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(kE1, kE2), \"Which is: 0\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(kE1, kE2), \"Which is: 1\");\n}\n\n// The version of gcc used in XCode 2.2 has a bug and doesn't allow\n// anonymous enums in assertions.  Therefore the following test is not\n// done on Mac.\n// Sun Studio and HP aCC also reject this code.\n#if !GTEST_OS_MAC && !defined(__SUNPRO_CC) && !defined(__HP_aCC)\n\n// Tests using assertions with anonymous enums.\nenum {\n  kCaseA = -1,\n\n# if GTEST_OS_LINUX\n\n  // We want to test the case where the size of the anonymous enum is\n  // larger than sizeof(int), to make sure our implementation of the\n  // assertions doesn't truncate the enums.  However, MSVC\n  // (incorrectly) doesn't allow an enum value to exceed the range of\n  // an int, so this has to be conditionally compiled.\n  //\n  // On Linux, kCaseB and kCaseA have the same value when truncated to\n  // int size.  We want to test whether this will confuse the\n  // assertions.\n  kCaseB = testing::internal::kMaxBiggestInt,\n\n# else\n\n  kCaseB = INT_MAX,\n\n# endif  // GTEST_OS_LINUX\n\n  kCaseC = 42\n};\n\nTEST(AssertionTest, AnonymousEnum) {\n# if GTEST_OS_LINUX\n\n  EXPECT_EQ(static_cast<int>(kCaseA), static_cast<int>(kCaseB));\n\n# endif  // GTEST_OS_LINUX\n\n  EXPECT_EQ(kCaseA, kCaseA);\n  EXPECT_NE(kCaseA, kCaseB);\n  EXPECT_LT(kCaseA, kCaseB);\n  EXPECT_LE(kCaseA, kCaseB);\n  EXPECT_GT(kCaseB, kCaseA);\n  EXPECT_GE(kCaseA, kCaseA);\n  EXPECT_NONFATAL_FAILURE(EXPECT_GE(kCaseA, kCaseB),\n                          \"(kCaseA) >= (kCaseB)\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_GE(kCaseA, kCaseC),\n                          \"-1 vs 42\");\n\n  ASSERT_EQ(kCaseA, kCaseA);\n  ASSERT_NE(kCaseA, kCaseB);\n  ASSERT_LT(kCaseA, kCaseB);\n  ASSERT_LE(kCaseA, kCaseB);\n  ASSERT_GT(kCaseB, kCaseA);\n  ASSERT_GE(kCaseA, kCaseA);\n\n# ifndef __BORLANDC__\n\n  // ICE's in C++Builder.\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseB),\n                       \"To be equal to: kCaseB\");\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseC),\n                       \"Which is: 42\");\n# endif\n\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseC),\n                       \"Which is: -1\");\n}\n\n#endif  // !GTEST_OS_MAC && !defined(__SUNPRO_CC)\n\n#if GTEST_OS_WINDOWS\n\nstatic HRESULT UnexpectedHRESULTFailure() {\n  return E_UNEXPECTED;\n}\n\nstatic HRESULT OkHRESULTSuccess() {\n  return S_OK;\n}\n\nstatic HRESULT FalseHRESULTSuccess() {\n  return S_FALSE;\n}\n\n// HRESULT assertion tests test both zero and non-zero\n// success codes as well as failure message for each.\n//\n// Windows CE doesn't support message texts.\nTEST(HRESULTAssertionTest, EXPECT_HRESULT_SUCCEEDED) {\n  EXPECT_HRESULT_SUCCEEDED(S_OK);\n  EXPECT_HRESULT_SUCCEEDED(S_FALSE);\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_HRESULT_SUCCEEDED(UnexpectedHRESULTFailure()),\n    \"Expected: (UnexpectedHRESULTFailure()) succeeds.\\n\"\n    \"  Actual: 0x8000FFFF\");\n}\n\nTEST(HRESULTAssertionTest, ASSERT_HRESULT_SUCCEEDED) {\n  ASSERT_HRESULT_SUCCEEDED(S_OK);\n  ASSERT_HRESULT_SUCCEEDED(S_FALSE);\n\n  EXPECT_FATAL_FAILURE(ASSERT_HRESULT_SUCCEEDED(UnexpectedHRESULTFailure()),\n    \"Expected: (UnexpectedHRESULTFailure()) succeeds.\\n\"\n    \"  Actual: 0x8000FFFF\");\n}\n\nTEST(HRESULTAssertionTest, EXPECT_HRESULT_FAILED) {\n  EXPECT_HRESULT_FAILED(E_UNEXPECTED);\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_HRESULT_FAILED(OkHRESULTSuccess()),\n    \"Expected: (OkHRESULTSuccess()) fails.\\n\"\n    \"  Actual: 0x0\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_HRESULT_FAILED(FalseHRESULTSuccess()),\n    \"Expected: (FalseHRESULTSuccess()) fails.\\n\"\n    \"  Actual: 0x1\");\n}\n\nTEST(HRESULTAssertionTest, ASSERT_HRESULT_FAILED) {\n  ASSERT_HRESULT_FAILED(E_UNEXPECTED);\n\n# ifndef __BORLANDC__\n\n  // ICE's in C++Builder 2007 and 2009.\n  EXPECT_FATAL_FAILURE(ASSERT_HRESULT_FAILED(OkHRESULTSuccess()),\n    \"Expected: (OkHRESULTSuccess()) fails.\\n\"\n    \"  Actual: 0x0\");\n# endif\n\n  EXPECT_FATAL_FAILURE(ASSERT_HRESULT_FAILED(FalseHRESULTSuccess()),\n    \"Expected: (FalseHRESULTSuccess()) fails.\\n\"\n    \"  Actual: 0x1\");\n}\n\n// Tests that streaming to the HRESULT macros works.\nTEST(HRESULTAssertionTest, Streaming) {\n  EXPECT_HRESULT_SUCCEEDED(S_OK) << \"unexpected failure\";\n  ASSERT_HRESULT_SUCCEEDED(S_OK) << \"unexpected failure\";\n  EXPECT_HRESULT_FAILED(E_UNEXPECTED) << \"unexpected failure\";\n  ASSERT_HRESULT_FAILED(E_UNEXPECTED) << \"unexpected failure\";\n\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_HRESULT_SUCCEEDED(E_UNEXPECTED) << \"expected failure\",\n      \"expected failure\");\n\n# ifndef __BORLANDC__\n\n  // ICE's in C++Builder 2007 and 2009.\n  EXPECT_FATAL_FAILURE(\n      ASSERT_HRESULT_SUCCEEDED(E_UNEXPECTED) << \"expected failure\",\n      \"expected failure\");\n# endif\n\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_HRESULT_FAILED(S_OK) << \"expected failure\",\n      \"expected failure\");\n\n  EXPECT_FATAL_FAILURE(\n      ASSERT_HRESULT_FAILED(S_OK) << \"expected failure\",\n      \"expected failure\");\n}\n\n#endif  // GTEST_OS_WINDOWS\n\n#ifdef __BORLANDC__\n// Silences warnings: \"Condition is always true\", \"Unreachable code\"\n# pragma option push -w-ccc -w-rch\n#endif\n\n// Tests that the assertion macros behave like single statements.\nTEST(AssertionSyntaxTest, BasicAssertionsBehavesLikeSingleStatement) {\n  if (AlwaysFalse())\n    ASSERT_TRUE(false) << \"This should never be executed; \"\n                          \"It's a compilation test only.\";\n\n  if (AlwaysTrue())\n    EXPECT_FALSE(false);\n  else\n    ;  // NOLINT\n\n  if (AlwaysFalse())\n    ASSERT_LT(1, 3);\n\n  if (AlwaysFalse())\n    ;  // NOLINT\n  else\n    EXPECT_GT(3, 2) << \"\";\n}\n\n#if GTEST_HAS_EXCEPTIONS\n// Tests that the compiler will not complain about unreachable code in the\n// EXPECT_THROW/EXPECT_ANY_THROW/EXPECT_NO_THROW macros.\nTEST(ExpectThrowTest, DoesNotGenerateUnreachableCodeWarning) {\n  int n = 0;\n\n  EXPECT_THROW(throw 1, int);\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW(n++, int), \"\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW(throw 1, const char*), \"\");\n  EXPECT_NO_THROW(n++);\n  EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(throw 1), \"\");\n  EXPECT_ANY_THROW(throw 1);\n  EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(n++), \"\");\n}\n\nTEST(AssertionSyntaxTest, ExceptionAssertionsBehavesLikeSingleStatement) {\n  if (AlwaysFalse())\n    EXPECT_THROW(ThrowNothing(), bool);\n\n  if (AlwaysTrue())\n    EXPECT_THROW(ThrowAnInteger(), int);\n  else\n    ;  // NOLINT\n\n  if (AlwaysFalse())\n    EXPECT_NO_THROW(ThrowAnInteger());\n\n  if (AlwaysTrue())\n    EXPECT_NO_THROW(ThrowNothing());\n  else\n    ;  // NOLINT\n\n  if (AlwaysFalse())\n    EXPECT_ANY_THROW(ThrowNothing());\n\n  if (AlwaysTrue())\n    EXPECT_ANY_THROW(ThrowAnInteger());\n  else\n    ;  // NOLINT\n}\n#endif  // GTEST_HAS_EXCEPTIONS\n\nTEST(AssertionSyntaxTest, NoFatalFailureAssertionsBehavesLikeSingleStatement) {\n  if (AlwaysFalse())\n    EXPECT_NO_FATAL_FAILURE(FAIL()) << \"This should never be executed. \"\n                                    << \"It's a compilation test only.\";\n  else\n    ;  // NOLINT\n\n  if (AlwaysFalse())\n    ASSERT_NO_FATAL_FAILURE(FAIL()) << \"\";\n  else\n    ;  // NOLINT\n\n  if (AlwaysTrue())\n    EXPECT_NO_FATAL_FAILURE(SUCCEED());\n  else\n    ;  // NOLINT\n\n  if (AlwaysFalse())\n    ;  // NOLINT\n  else\n    ASSERT_NO_FATAL_FAILURE(SUCCEED());\n}\n\n// Tests that the assertion macros work well with switch statements.\nTEST(AssertionSyntaxTest, WorksWithSwitch) {\n  switch (0) {\n    case 1:\n      break;\n    default:\n      ASSERT_TRUE(true);\n  }\n\n  switch (0)\n    case 0:\n      EXPECT_FALSE(false) << \"EXPECT_FALSE failed in switch case\";\n\n  // Binary assertions are implemented using a different code path\n  // than the Boolean assertions.  Hence we test them separately.\n  switch (0) {\n    case 1:\n    default:\n      ASSERT_EQ(1, 1) << \"ASSERT_EQ failed in default switch handler\";\n  }\n\n  switch (0)\n    case 0:\n      EXPECT_NE(1, 2);\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\nvoid ThrowAString() {\n    throw \"std::string\";\n}\n\n// Test that the exception assertion macros compile and work with const\n// type qualifier.\nTEST(AssertionSyntaxTest, WorksWithConst) {\n    ASSERT_THROW(ThrowAString(), const char*);\n\n    EXPECT_THROW(ThrowAString(), const char*);\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n}  // namespace\n\nnamespace testing {\n\n// Tests that Google Test tracks SUCCEED*.\nTEST(SuccessfulAssertionTest, SUCCEED) {\n  SUCCEED();\n  SUCCEED() << \"OK\";\n  EXPECT_EQ(2, GetUnitTestImpl()->current_test_result()->total_part_count());\n}\n\n// Tests that Google Test doesn't track successful EXPECT_*.\nTEST(SuccessfulAssertionTest, EXPECT) {\n  EXPECT_TRUE(true);\n  EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count());\n}\n\n// Tests that Google Test doesn't track successful EXPECT_STR*.\nTEST(SuccessfulAssertionTest, EXPECT_STR) {\n  EXPECT_STREQ(\"\", \"\");\n  EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count());\n}\n\n// Tests that Google Test doesn't track successful ASSERT_*.\nTEST(SuccessfulAssertionTest, ASSERT) {\n  ASSERT_TRUE(true);\n  EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count());\n}\n\n// Tests that Google Test doesn't track successful ASSERT_STR*.\nTEST(SuccessfulAssertionTest, ASSERT_STR) {\n  ASSERT_STREQ(\"\", \"\");\n  EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count());\n}\n\n}  // namespace testing\n\nnamespace {\n\n// Tests the message streaming variation of assertions.\n\nTEST(AssertionWithMessageTest, EXPECT) {\n  EXPECT_EQ(1, 1) << \"This should succeed.\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_NE(1, 1) << \"Expected failure #1.\",\n                          \"Expected failure #1\");\n  EXPECT_LE(1, 2) << \"This should succeed.\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_LT(1, 0) << \"Expected failure #2.\",\n                          \"Expected failure #2.\");\n  EXPECT_GE(1, 0) << \"This should succeed.\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_GT(1, 2) << \"Expected failure #3.\",\n                          \"Expected failure #3.\");\n\n  EXPECT_STREQ(\"1\", \"1\") << \"This should succeed.\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(\"1\", \"1\") << \"Expected failure #4.\",\n                          \"Expected failure #4.\");\n  EXPECT_STRCASEEQ(\"a\", \"A\") << \"This should succeed.\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRCASENE(\"a\", \"A\") << \"Expected failure #5.\",\n                          \"Expected failure #5.\");\n\n  EXPECT_FLOAT_EQ(1, 1) << \"This should succeed.\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(1, 1.2) << \"Expected failure #6.\",\n                          \"Expected failure #6.\");\n  EXPECT_NEAR(1, 1.1, 0.2) << \"This should succeed.\";\n}\n\nTEST(AssertionWithMessageTest, ASSERT) {\n  ASSERT_EQ(1, 1) << \"This should succeed.\";\n  ASSERT_NE(1, 2) << \"This should succeed.\";\n  ASSERT_LE(1, 2) << \"This should succeed.\";\n  ASSERT_LT(1, 2) << \"This should succeed.\";\n  ASSERT_GE(1, 0) << \"This should succeed.\";\n  EXPECT_FATAL_FAILURE(ASSERT_GT(1, 2) << \"Expected failure.\",\n                       \"Expected failure.\");\n}\n\nTEST(AssertionWithMessageTest, ASSERT_STR) {\n  ASSERT_STREQ(\"1\", \"1\") << \"This should succeed.\";\n  ASSERT_STRNE(\"1\", \"2\") << \"This should succeed.\";\n  ASSERT_STRCASEEQ(\"a\", \"A\") << \"This should succeed.\";\n  EXPECT_FATAL_FAILURE(ASSERT_STRCASENE(\"a\", \"A\") << \"Expected failure.\",\n                       \"Expected failure.\");\n}\n\nTEST(AssertionWithMessageTest, ASSERT_FLOATING) {\n  ASSERT_FLOAT_EQ(1, 1) << \"This should succeed.\";\n  ASSERT_DOUBLE_EQ(1, 1) << \"This should succeed.\";\n  EXPECT_FATAL_FAILURE(ASSERT_NEAR(1,1.2, 0.1) << \"Expect failure.\",  // NOLINT\n                       \"Expect failure.\");\n  // To work around a bug in gcc 2.95.0, there is intentionally no\n  // space after the first comma in the previous statement.\n}\n\n// Tests using ASSERT_FALSE with a streamed message.\nTEST(AssertionWithMessageTest, ASSERT_FALSE) {\n  ASSERT_FALSE(false) << \"This shouldn't fail.\";\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_FALSE(true) << \"Expected failure: \" << 2 << \" > \" << 1\n                       << \" evaluates to \" << true;\n  }, \"Expected failure\");\n}\n\n// Tests using FAIL with a streamed message.\nTEST(AssertionWithMessageTest, FAIL) {\n  EXPECT_FATAL_FAILURE(FAIL() << 0,\n                       \"0\");\n}\n\n// Tests using SUCCEED with a streamed message.\nTEST(AssertionWithMessageTest, SUCCEED) {\n  SUCCEED() << \"Success == \" << 1;\n}\n\n// Tests using ASSERT_TRUE with a streamed message.\nTEST(AssertionWithMessageTest, ASSERT_TRUE) {\n  ASSERT_TRUE(true) << \"This should succeed.\";\n  ASSERT_TRUE(true) << true;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_TRUE(false) << static_cast<const char *>(NULL)\n                       << static_cast<char *>(NULL);\n  }, \"(null)(null)\");\n}\n\n#if GTEST_OS_WINDOWS\n// Tests using wide strings in assertion messages.\nTEST(AssertionWithMessageTest, WideStringMessage) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_TRUE(false) << L\"This failure is expected.\\x8119\";\n  }, \"This failure is expected.\");\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_EQ(1, 2) << \"This failure is \"\n                    << L\"expected too.\\x8120\";\n  }, \"This failure is expected too.\");\n}\n#endif  // GTEST_OS_WINDOWS\n\n// Tests EXPECT_TRUE.\nTEST(ExpectTest, EXPECT_TRUE) {\n  EXPECT_TRUE(true) << \"Intentional success\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(false) << \"Intentional failure #1.\",\n                          \"Intentional failure #1.\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(false) << \"Intentional failure #2.\",\n                          \"Intentional failure #2.\");\n  EXPECT_TRUE(2 > 1);  // NOLINT\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(2 < 1),\n                          \"Value of: 2 < 1\\n\"\n                          \"  Actual: false\\n\"\n                          \"Expected: true\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(2 > 3),\n                          \"2 > 3\");\n}\n\n// Tests EXPECT_TRUE(predicate) for predicates returning AssertionResult.\nTEST(ExpectTest, ExpectTrueWithAssertionResult) {\n  EXPECT_TRUE(ResultIsEven(2));\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(ResultIsEven(3)),\n                          \"Value of: ResultIsEven(3)\\n\"\n                          \"  Actual: false (3 is odd)\\n\"\n                          \"Expected: true\");\n  EXPECT_TRUE(ResultIsEvenNoExplanation(2));\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(ResultIsEvenNoExplanation(3)),\n                          \"Value of: ResultIsEvenNoExplanation(3)\\n\"\n                          \"  Actual: false (3 is odd)\\n\"\n                          \"Expected: true\");\n}\n\n// Tests EXPECT_FALSE with a streamed message.\nTEST(ExpectTest, EXPECT_FALSE) {\n  EXPECT_FALSE(2 < 1);  // NOLINT\n  EXPECT_FALSE(false) << \"Intentional success\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(true) << \"Intentional failure #1.\",\n                          \"Intentional failure #1.\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(true) << \"Intentional failure #2.\",\n                          \"Intentional failure #2.\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(2 > 1),\n                          \"Value of: 2 > 1\\n\"\n                          \"  Actual: true\\n\"\n                          \"Expected: false\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(2 < 3),\n                          \"2 < 3\");\n}\n\n// Tests EXPECT_FALSE(predicate) for predicates returning AssertionResult.\nTEST(ExpectTest, ExpectFalseWithAssertionResult) {\n  EXPECT_FALSE(ResultIsEven(3));\n  EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(ResultIsEven(2)),\n                          \"Value of: ResultIsEven(2)\\n\"\n                          \"  Actual: true (2 is even)\\n\"\n                          \"Expected: false\");\n  EXPECT_FALSE(ResultIsEvenNoExplanation(3));\n  EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(ResultIsEvenNoExplanation(2)),\n                          \"Value of: ResultIsEvenNoExplanation(2)\\n\"\n                          \"  Actual: true\\n\"\n                          \"Expected: false\");\n}\n\n#ifdef __BORLANDC__\n// Restores warnings after previous \"#pragma option push\" supressed them\n# pragma option pop\n#endif\n\n// Tests EXPECT_EQ.\nTEST(ExpectTest, EXPECT_EQ) {\n  EXPECT_EQ(5, 2 + 3);\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(5, 2*3),\n                          \"      Expected: 5\\n\"\n                          \"To be equal to: 2*3\\n\"\n                          \"      Which is: 6\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(5, 2 - 3),\n                          \"2 - 3\");\n}\n\n// Tests using EXPECT_EQ on double values.  The purpose is to make\n// sure that the specialization we did for integer and anonymous enums\n// isn't used for double arguments.\nTEST(ExpectTest, EXPECT_EQ_Double) {\n  // A success.\n  EXPECT_EQ(5.6, 5.6);\n\n  // A failure.\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(5.1, 5.2),\n                          \"5.1\");\n}\n\n#if GTEST_CAN_COMPARE_NULL\n// Tests EXPECT_EQ(NULL, pointer).\nTEST(ExpectTest, EXPECT_EQ_NULL) {\n  // A success.\n  const char* p = NULL;\n  // Some older GCC versions may issue a spurious warning in this or the next\n  // assertion statement. This warning should not be suppressed with\n  // static_cast since the test verifies the ability to use bare NULL as the\n  // expected parameter to the macro.\n  EXPECT_EQ(NULL, p);\n\n  // A failure.\n  int n = 0;\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(NULL, &n),\n                          \"To be equal to: &n\\n\");\n}\n#endif  // GTEST_CAN_COMPARE_NULL\n\n// Tests EXPECT_EQ(0, non_pointer).  Since the literal 0 can be\n// treated as a null pointer by the compiler, we need to make sure\n// that EXPECT_EQ(0, non_pointer) isn't interpreted by Google Test as\n// EXPECT_EQ(static_cast<void*>(NULL), non_pointer).\nTEST(ExpectTest, EXPECT_EQ_0) {\n  int n = 0;\n\n  // A success.\n  EXPECT_EQ(0, n);\n\n  // A failure.\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(0, 5.6),\n                          \"Expected: 0\");\n}\n\n// Tests EXPECT_NE.\nTEST(ExpectTest, EXPECT_NE) {\n  EXPECT_NE(6, 7);\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_NE('a', 'a'),\n                          \"Expected: ('a') != ('a'), \"\n                          \"actual: 'a' (97, 0x61) vs 'a' (97, 0x61)\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_NE(2, 2),\n                          \"2\");\n  char* const p0 = NULL;\n  EXPECT_NONFATAL_FAILURE(EXPECT_NE(p0, p0),\n                          \"p0\");\n  // Only way to get the Nokia compiler to compile the cast\n  // is to have a separate void* variable first. Putting\n  // the two casts on the same line doesn't work, neither does\n  // a direct C-style to char*.\n  void* pv1 = (void*)0x1234;  // NOLINT\n  char* const p1 = reinterpret_cast<char*>(pv1);\n  EXPECT_NONFATAL_FAILURE(EXPECT_NE(p1, p1),\n                          \"p1\");\n}\n\n// Tests EXPECT_LE.\nTEST(ExpectTest, EXPECT_LE) {\n  EXPECT_LE(2, 3);\n  EXPECT_LE(2, 2);\n  EXPECT_NONFATAL_FAILURE(EXPECT_LE(2, 0),\n                          \"Expected: (2) <= (0), actual: 2 vs 0\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_LE(1.1, 0.9),\n                          \"(1.1) <= (0.9)\");\n}\n\n// Tests EXPECT_LT.\nTEST(ExpectTest, EXPECT_LT) {\n  EXPECT_LT(2, 3);\n  EXPECT_NONFATAL_FAILURE(EXPECT_LT(2, 2),\n                          \"Expected: (2) < (2), actual: 2 vs 2\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_LT(2, 1),\n                          \"(2) < (1)\");\n}\n\n// Tests EXPECT_GE.\nTEST(ExpectTest, EXPECT_GE) {\n  EXPECT_GE(2, 1);\n  EXPECT_GE(2, 2);\n  EXPECT_NONFATAL_FAILURE(EXPECT_GE(2, 3),\n                          \"Expected: (2) >= (3), actual: 2 vs 3\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_GE(0.9, 1.1),\n                          \"(0.9) >= (1.1)\");\n}\n\n// Tests EXPECT_GT.\nTEST(ExpectTest, EXPECT_GT) {\n  EXPECT_GT(2, 1);\n  EXPECT_NONFATAL_FAILURE(EXPECT_GT(2, 2),\n                          \"Expected: (2) > (2), actual: 2 vs 2\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_GT(2, 3),\n                          \"(2) > (3)\");\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\n// Tests EXPECT_THROW.\nTEST(ExpectTest, EXPECT_THROW) {\n  EXPECT_THROW(ThrowAnInteger(), int);\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW(ThrowAnInteger(), bool),\n                          \"Expected: ThrowAnInteger() throws an exception of \"\n                          \"type bool.\\n  Actual: it throws a different type.\");\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_THROW(ThrowNothing(), bool),\n      \"Expected: ThrowNothing() throws an exception of type bool.\\n\"\n      \"  Actual: it throws nothing.\");\n}\n\n// Tests EXPECT_NO_THROW.\nTEST(ExpectTest, EXPECT_NO_THROW) {\n  EXPECT_NO_THROW(ThrowNothing());\n  EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnInteger()),\n                          \"Expected: ThrowAnInteger() doesn't throw an \"\n                          \"exception.\\n  Actual: it throws.\");\n}\n\n// Tests EXPECT_ANY_THROW.\nTEST(ExpectTest, EXPECT_ANY_THROW) {\n  EXPECT_ANY_THROW(ThrowAnInteger());\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_ANY_THROW(ThrowNothing()),\n      \"Expected: ThrowNothing() throws an exception.\\n\"\n      \"  Actual: it doesn't.\");\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// Make sure we deal with the precedence of <<.\nTEST(ExpectTest, ExpectPrecedence) {\n  EXPECT_EQ(1 < 2, true);\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(true, true && false),\n                          \"To be equal to: true && false\");\n}\n\n\n// Tests the StreamableToString() function.\n\n// Tests using StreamableToString() on a scalar.\nTEST(StreamableToStringTest, Scalar) {\n  EXPECT_STREQ(\"5\", StreamableToString(5).c_str());\n}\n\n// Tests using StreamableToString() on a non-char pointer.\nTEST(StreamableToStringTest, Pointer) {\n  int n = 0;\n  int* p = &n;\n  EXPECT_STRNE(\"(null)\", StreamableToString(p).c_str());\n}\n\n// Tests using StreamableToString() on a NULL non-char pointer.\nTEST(StreamableToStringTest, NullPointer) {\n  int* p = NULL;\n  EXPECT_STREQ(\"(null)\", StreamableToString(p).c_str());\n}\n\n// Tests using StreamableToString() on a C string.\nTEST(StreamableToStringTest, CString) {\n  EXPECT_STREQ(\"Foo\", StreamableToString(\"Foo\").c_str());\n}\n\n// Tests using StreamableToString() on a NULL C string.\nTEST(StreamableToStringTest, NullCString) {\n  char* p = NULL;\n  EXPECT_STREQ(\"(null)\", StreamableToString(p).c_str());\n}\n\n// Tests using streamable values as assertion messages.\n\n// Tests using std::string as an assertion message.\nTEST(StreamableTest, string) {\n  static const std::string str(\n      \"This failure message is a std::string, and is expected.\");\n  EXPECT_FATAL_FAILURE(FAIL() << str,\n                       str.c_str());\n}\n\n// Tests that we can output strings containing embedded NULs.\n// Limited to Linux because we can only do this with std::string's.\nTEST(StreamableTest, stringWithEmbeddedNUL) {\n  static const char char_array_with_nul[] =\n      \"Here's a NUL\\0 and some more string\";\n  static const std::string string_with_nul(char_array_with_nul,\n                                           sizeof(char_array_with_nul)\n                                           - 1);  // drops the trailing NUL\n  EXPECT_FATAL_FAILURE(FAIL() << string_with_nul,\n                       \"Here's a NUL\\\\0 and some more string\");\n}\n\n// Tests that we can output a NUL char.\nTEST(StreamableTest, NULChar) {\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    FAIL() << \"A NUL\" << '\\0' << \" and some more string\";\n  }, \"A NUL\\\\0 and some more string\");\n}\n\n// Tests using int as an assertion message.\nTEST(StreamableTest, int) {\n  EXPECT_FATAL_FAILURE(FAIL() << 900913,\n                       \"900913\");\n}\n\n// Tests using NULL char pointer as an assertion message.\n//\n// In MSVC, streaming a NULL char * causes access violation.  Google Test\n// implemented a workaround (substituting \"(null)\" for NULL).  This\n// tests whether the workaround works.\nTEST(StreamableTest, NullCharPtr) {\n  EXPECT_FATAL_FAILURE(FAIL() << static_cast<const char*>(NULL),\n                       \"(null)\");\n}\n\n// Tests that basic IO manipulators (endl, ends, and flush) can be\n// streamed to testing::Message.\nTEST(StreamableTest, BasicIoManip) {\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    FAIL() << \"Line 1.\" << std::endl\n           << \"A NUL char \" << std::ends << std::flush << \" in line 2.\";\n  }, \"Line 1.\\nA NUL char \\\\0 in line 2.\");\n}\n\n// Tests the macros that haven't been covered so far.\n\nvoid AddFailureHelper(bool* aborted) {\n  *aborted = true;\n  ADD_FAILURE() << \"Intentional failure.\";\n  *aborted = false;\n}\n\n// Tests ADD_FAILURE.\nTEST(MacroTest, ADD_FAILURE) {\n  bool aborted = true;\n  EXPECT_NONFATAL_FAILURE(AddFailureHelper(&aborted),\n                          \"Intentional failure.\");\n  EXPECT_FALSE(aborted);\n}\n\n// Tests ADD_FAILURE_AT.\nTEST(MacroTest, ADD_FAILURE_AT) {\n  // Verifies that ADD_FAILURE_AT does generate a nonfatal failure and\n  // the failure message contains the user-streamed part.\n  EXPECT_NONFATAL_FAILURE(ADD_FAILURE_AT(\"foo.cc\", 42) << \"Wrong!\", \"Wrong!\");\n\n  // Verifies that the user-streamed part is optional.\n  EXPECT_NONFATAL_FAILURE(ADD_FAILURE_AT(\"foo.cc\", 42), \"Failed\");\n\n  // Unfortunately, we cannot verify that the failure message contains\n  // the right file path and line number the same way, as\n  // EXPECT_NONFATAL_FAILURE() doesn't get to see the file path and\n  // line number.  Instead, we do that in gtest_output_test_.cc.\n}\n\n// Tests FAIL.\nTEST(MacroTest, FAIL) {\n  EXPECT_FATAL_FAILURE(FAIL(),\n                       \"Failed\");\n  EXPECT_FATAL_FAILURE(FAIL() << \"Intentional failure.\",\n                       \"Intentional failure.\");\n}\n\n// Tests SUCCEED\nTEST(MacroTest, SUCCEED) {\n  SUCCEED();\n  SUCCEED() << \"Explicit success.\";\n}\n\n// Tests for EXPECT_EQ() and ASSERT_EQ().\n//\n// These tests fail *intentionally*, s.t. the failure messages can be\n// generated and tested.\n//\n// We have different tests for different argument types.\n\n// Tests using bool values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, Bool) {\n  EXPECT_EQ(true,  true);\n  EXPECT_FATAL_FAILURE({\n      bool false_value = false;\n      ASSERT_EQ(false_value, true);\n    }, \"To be equal to: true\");\n}\n\n// Tests using int values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, Int) {\n  ASSERT_EQ(32, 32);\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(32, 33),\n                          \"33\");\n}\n\n// Tests using time_t values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, Time_T) {\n  EXPECT_EQ(static_cast<time_t>(0),\n            static_cast<time_t>(0));\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<time_t>(0),\n                                 static_cast<time_t>(1234)),\n                       \"1234\");\n}\n\n// Tests using char values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, Char) {\n  ASSERT_EQ('z', 'z');\n  const char ch = 'b';\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ('\\0', ch),\n                          \"ch\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ('a', ch),\n                          \"ch\");\n}\n\n// Tests using wchar_t values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, WideChar) {\n  EXPECT_EQ(L'b', L'b');\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(L'\\0', L'x'),\n                          \"      Expected: L'\\0'\\n\"\n                          \"      Which is: L'\\0' (0, 0x0)\\n\"\n                          \"To be equal to: L'x'\\n\"\n                          \"      Which is: L'x' (120, 0x78)\");\n\n  static wchar_t wchar;\n  wchar = L'b';\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(L'a', wchar),\n                          \"wchar\");\n  wchar = 0x8119;\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<wchar_t>(0x8120), wchar),\n                       \"To be equal to: wchar\");\n}\n\n// Tests using ::std::string values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, StdString) {\n  // Compares a const char* to an std::string that has identical\n  // content.\n  ASSERT_EQ(\"Test\", ::std::string(\"Test\"));\n\n  // Compares two identical std::strings.\n  static const ::std::string str1(\"A * in the middle\");\n  static const ::std::string str2(str1);\n  EXPECT_EQ(str1, str2);\n\n  // Compares a const char* to an std::string that has different\n  // content\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(\"Test\", ::std::string(\"test\")),\n                          \"\\\"test\\\"\");\n\n  // Compares an std::string to a char* that has different content.\n  char* const p1 = const_cast<char*>(\"foo\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(::std::string(\"bar\"), p1),\n                          \"p1\");\n\n  // Compares two std::strings that have different contents, one of\n  // which having a NUL character in the middle.  This should fail.\n  static ::std::string str3(str1);\n  str3.at(2) = '\\0';\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(str1, str3),\n                       \"To be equal to: str3\\n\"\n                       \"      Which is: \\\"A \\\\0 in the middle\\\"\");\n}\n\n#if GTEST_HAS_STD_WSTRING\n\n// Tests using ::std::wstring values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, StdWideString) {\n  // Compares two identical std::wstrings.\n  const ::std::wstring wstr1(L\"A * in the middle\");\n  const ::std::wstring wstr2(wstr1);\n  ASSERT_EQ(wstr1, wstr2);\n\n  // Compares an std::wstring to a const wchar_t* that has identical\n  // content.\n  const wchar_t kTestX8119[] = { 'T', 'e', 's', 't', 0x8119, '\\0' };\n  EXPECT_EQ(::std::wstring(kTestX8119), kTestX8119);\n\n  // Compares an std::wstring to a const wchar_t* that has different\n  // content.\n  const wchar_t kTestX8120[] = { 'T', 'e', 's', 't', 0x8120, '\\0' };\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_EQ(::std::wstring(kTestX8119), kTestX8120);\n  }, \"kTestX8120\");\n\n  // Compares two std::wstrings that have different contents, one of\n  // which having a NUL character in the middle.\n  ::std::wstring wstr3(wstr1);\n  wstr3.at(2) = L'\\0';\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(wstr1, wstr3),\n                          \"wstr3\");\n\n  // Compares a wchar_t* to an std::wstring that has different\n  // content.\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_EQ(const_cast<wchar_t*>(L\"foo\"), ::std::wstring(L\"bar\"));\n  }, \"\");\n}\n\n#endif  // GTEST_HAS_STD_WSTRING\n\n#if GTEST_HAS_GLOBAL_STRING\n// Tests using ::string values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, GlobalString) {\n  // Compares a const char* to a ::string that has identical content.\n  EXPECT_EQ(\"Test\", ::string(\"Test\"));\n\n  // Compares two identical ::strings.\n  const ::string str1(\"A * in the middle\");\n  const ::string str2(str1);\n  ASSERT_EQ(str1, str2);\n\n  // Compares a ::string to a const char* that has different content.\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(::string(\"Test\"), \"test\"),\n                          \"test\");\n\n  // Compares two ::strings that have different contents, one of which\n  // having a NUL character in the middle.\n  ::string str3(str1);\n  str3.at(2) = '\\0';\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(str1, str3),\n                          \"str3\");\n\n  // Compares a ::string to a char* that has different content.\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_EQ(::string(\"bar\"), const_cast<char*>(\"foo\"));\n  }, \"\");\n}\n\n#endif  // GTEST_HAS_GLOBAL_STRING\n\n#if GTEST_HAS_GLOBAL_WSTRING\n\n// Tests using ::wstring values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, GlobalWideString) {\n  // Compares two identical ::wstrings.\n  static const ::wstring wstr1(L\"A * in the middle\");\n  static const ::wstring wstr2(wstr1);\n  EXPECT_EQ(wstr1, wstr2);\n\n  // Compares a const wchar_t* to a ::wstring that has identical content.\n  const wchar_t kTestX8119[] = { 'T', 'e', 's', 't', 0x8119, '\\0' };\n  ASSERT_EQ(kTestX8119, ::wstring(kTestX8119));\n\n  // Compares a const wchar_t* to a ::wstring that has different\n  // content.\n  const wchar_t kTestX8120[] = { 'T', 'e', 's', 't', 0x8120, '\\0' };\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_EQ(kTestX8120, ::wstring(kTestX8119));\n  }, \"Test\\\\x8119\");\n\n  // Compares a wchar_t* to a ::wstring that has different content.\n  wchar_t* const p1 = const_cast<wchar_t*>(L\"foo\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, ::wstring(L\"bar\")),\n                          \"bar\");\n\n  // Compares two ::wstrings that have different contents, one of which\n  // having a NUL character in the middle.\n  static ::wstring wstr3;\n  wstr3 = wstr1;\n  wstr3.at(2) = L'\\0';\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(wstr1, wstr3),\n                       \"wstr3\");\n}\n\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n// Tests using char pointers in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, CharPointer) {\n  char* const p0 = NULL;\n  // Only way to get the Nokia compiler to compile the cast\n  // is to have a separate void* variable first. Putting\n  // the two casts on the same line doesn't work, neither does\n  // a direct C-style to char*.\n  void* pv1 = (void*)0x1234;  // NOLINT\n  void* pv2 = (void*)0xABC0;  // NOLINT\n  char* const p1 = reinterpret_cast<char*>(pv1);\n  char* const p2 = reinterpret_cast<char*>(pv2);\n  ASSERT_EQ(p1, p1);\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2),\n                          \"To be equal to: p2\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2),\n                          \"p2\");\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(reinterpret_cast<char*>(0x1234),\n                                 reinterpret_cast<char*>(0xABC0)),\n                       \"ABC0\");\n}\n\n// Tests using wchar_t pointers in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, WideCharPointer) {\n  wchar_t* const p0 = NULL;\n  // Only way to get the Nokia compiler to compile the cast\n  // is to have a separate void* variable first. Putting\n  // the two casts on the same line doesn't work, neither does\n  // a direct C-style to char*.\n  void* pv1 = (void*)0x1234;  // NOLINT\n  void* pv2 = (void*)0xABC0;  // NOLINT\n  wchar_t* const p1 = reinterpret_cast<wchar_t*>(pv1);\n  wchar_t* const p2 = reinterpret_cast<wchar_t*>(pv2);\n  EXPECT_EQ(p0, p0);\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2),\n                          \"To be equal to: p2\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2),\n                          \"p2\");\n  void* pv3 = (void*)0x1234;  // NOLINT\n  void* pv4 = (void*)0xABC0;  // NOLINT\n  const wchar_t* p3 = reinterpret_cast<const wchar_t*>(pv3);\n  const wchar_t* p4 = reinterpret_cast<const wchar_t*>(pv4);\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p3, p4),\n                          \"p4\");\n}\n\n// Tests using other types of pointers in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, OtherPointer) {\n  ASSERT_EQ(static_cast<const int*>(NULL),\n            static_cast<const int*>(NULL));\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<const int*>(NULL),\n                                 reinterpret_cast<const int*>(0x1234)),\n                       \"0x1234\");\n}\n\n// A class that supports binary comparison operators but not streaming.\nclass UnprintableChar {\n public:\n  explicit UnprintableChar(char ch) : char_(ch) {}\n\n  bool operator==(const UnprintableChar& rhs) const {\n    return char_ == rhs.char_;\n  }\n  bool operator!=(const UnprintableChar& rhs) const {\n    return char_ != rhs.char_;\n  }\n  bool operator<(const UnprintableChar& rhs) const {\n    return char_ < rhs.char_;\n  }\n  bool operator<=(const UnprintableChar& rhs) const {\n    return char_ <= rhs.char_;\n  }\n  bool operator>(const UnprintableChar& rhs) const {\n    return char_ > rhs.char_;\n  }\n  bool operator>=(const UnprintableChar& rhs) const {\n    return char_ >= rhs.char_;\n  }\n\n private:\n  char char_;\n};\n\n// Tests that ASSERT_EQ() and friends don't require the arguments to\n// be printable.\nTEST(ComparisonAssertionTest, AcceptsUnprintableArgs) {\n  const UnprintableChar x('x'), y('y');\n  ASSERT_EQ(x, x);\n  EXPECT_NE(x, y);\n  ASSERT_LT(x, y);\n  EXPECT_LE(x, y);\n  ASSERT_GT(y, x);\n  EXPECT_GE(x, x);\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(x, y), \"1-byte object <78>\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(x, y), \"1-byte object <79>\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_LT(y, y), \"1-byte object <79>\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_GT(x, y), \"1-byte object <78>\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_GT(x, y), \"1-byte object <79>\");\n\n  // Code tested by EXPECT_FATAL_FAILURE cannot reference local\n  // variables, so we have to write UnprintableChar('x') instead of x.\n#ifndef __BORLANDC__\n  // ICE's in C++Builder.\n  EXPECT_FATAL_FAILURE(ASSERT_NE(UnprintableChar('x'), UnprintableChar('x')),\n                       \"1-byte object <78>\");\n  EXPECT_FATAL_FAILURE(ASSERT_LE(UnprintableChar('y'), UnprintableChar('x')),\n                       \"1-byte object <78>\");\n#endif\n  EXPECT_FATAL_FAILURE(ASSERT_LE(UnprintableChar('y'), UnprintableChar('x')),\n                       \"1-byte object <79>\");\n  EXPECT_FATAL_FAILURE(ASSERT_GE(UnprintableChar('x'), UnprintableChar('y')),\n                       \"1-byte object <78>\");\n  EXPECT_FATAL_FAILURE(ASSERT_GE(UnprintableChar('x'), UnprintableChar('y')),\n                       \"1-byte object <79>\");\n}\n\n// Tests the FRIEND_TEST macro.\n\n// This class has a private member we want to test.  We will test it\n// both in a TEST and in a TEST_F.\nclass Foo {\n public:\n  Foo() {}\n\n private:\n  int Bar() const { return 1; }\n\n  // Declares the friend tests that can access the private member\n  // Bar().\n  FRIEND_TEST(FRIEND_TEST_Test, TEST);\n  FRIEND_TEST(FRIEND_TEST_Test2, TEST_F);\n};\n\n// Tests that the FRIEND_TEST declaration allows a TEST to access a\n// class's private members.  This should compile.\nTEST(FRIEND_TEST_Test, TEST) {\n  ASSERT_EQ(1, Foo().Bar());\n}\n\n// The fixture needed to test using FRIEND_TEST with TEST_F.\nclass FRIEND_TEST_Test2 : public Test {\n protected:\n  Foo foo;\n};\n\n// Tests that the FRIEND_TEST declaration allows a TEST_F to access a\n// class's private members.  This should compile.\nTEST_F(FRIEND_TEST_Test2, TEST_F) {\n  ASSERT_EQ(1, foo.Bar());\n}\n\n// Tests the life cycle of Test objects.\n\n// The test fixture for testing the life cycle of Test objects.\n//\n// This class counts the number of live test objects that uses this\n// fixture.\nclass TestLifeCycleTest : public Test {\n protected:\n  // Constructor.  Increments the number of test objects that uses\n  // this fixture.\n  TestLifeCycleTest() { count_++; }\n\n  // Destructor.  Decrements the number of test objects that uses this\n  // fixture.\n  ~TestLifeCycleTest() { count_--; }\n\n  // Returns the number of live test objects that uses this fixture.\n  int count() const { return count_; }\n\n private:\n  static int count_;\n};\n\nint TestLifeCycleTest::count_ = 0;\n\n// Tests the life cycle of test objects.\nTEST_F(TestLifeCycleTest, Test1) {\n  // There should be only one test object in this test case that's\n  // currently alive.\n  ASSERT_EQ(1, count());\n}\n\n// Tests the life cycle of test objects.\nTEST_F(TestLifeCycleTest, Test2) {\n  // After Test1 is done and Test2 is started, there should still be\n  // only one live test object, as the object for Test1 should've been\n  // deleted.\n  ASSERT_EQ(1, count());\n}\n\n}  // namespace\n\n// Tests that the copy constructor works when it is NOT optimized away by\n// the compiler.\nTEST(AssertionResultTest, CopyConstructorWorksWhenNotOptimied) {\n  // Checks that the copy constructor doesn't try to dereference NULL pointers\n  // in the source object.\n  AssertionResult r1 = AssertionSuccess();\n  AssertionResult r2 = r1;\n  // The following line is added to prevent the compiler from optimizing\n  // away the constructor call.\n  r1 << \"abc\";\n\n  AssertionResult r3 = r1;\n  EXPECT_EQ(static_cast<bool>(r3), static_cast<bool>(r1));\n  EXPECT_STREQ(\"abc\", r1.message());\n}\n\n// Tests that AssertionSuccess and AssertionFailure construct\n// AssertionResult objects as expected.\nTEST(AssertionResultTest, ConstructionWorks) {\n  AssertionResult r1 = AssertionSuccess();\n  EXPECT_TRUE(r1);\n  EXPECT_STREQ(\"\", r1.message());\n\n  AssertionResult r2 = AssertionSuccess() << \"abc\";\n  EXPECT_TRUE(r2);\n  EXPECT_STREQ(\"abc\", r2.message());\n\n  AssertionResult r3 = AssertionFailure();\n  EXPECT_FALSE(r3);\n  EXPECT_STREQ(\"\", r3.message());\n\n  AssertionResult r4 = AssertionFailure() << \"def\";\n  EXPECT_FALSE(r4);\n  EXPECT_STREQ(\"def\", r4.message());\n\n  AssertionResult r5 = AssertionFailure(Message() << \"ghi\");\n  EXPECT_FALSE(r5);\n  EXPECT_STREQ(\"ghi\", r5.message());\n}\n\n// Tests that the negation flips the predicate result but keeps the message.\nTEST(AssertionResultTest, NegationWorks) {\n  AssertionResult r1 = AssertionSuccess() << \"abc\";\n  EXPECT_FALSE(!r1);\n  EXPECT_STREQ(\"abc\", (!r1).message());\n\n  AssertionResult r2 = AssertionFailure() << \"def\";\n  EXPECT_TRUE(!r2);\n  EXPECT_STREQ(\"def\", (!r2).message());\n}\n\nTEST(AssertionResultTest, StreamingWorks) {\n  AssertionResult r = AssertionSuccess();\n  r << \"abc\" << 'd' << 0 << true;\n  EXPECT_STREQ(\"abcd0true\", r.message());\n}\n\nTEST(AssertionResultTest, CanStreamOstreamManipulators) {\n  AssertionResult r = AssertionSuccess();\n  r << \"Data\" << std::endl << std::flush << std::ends << \"Will be visible\";\n  EXPECT_STREQ(\"Data\\n\\\\0Will be visible\", r.message());\n}\n\n// The next test uses explicit conversion operators -- a C++11 feature.\n#if GTEST_LANG_CXX11\n\nTEST(AssertionResultTest, ConstructibleFromContextuallyConvertibleToBool) {\n  struct ExplicitlyConvertibleToBool {\n    explicit operator bool() const { return value; }\n    bool value;\n  };\n  ExplicitlyConvertibleToBool v1 = {false};\n  ExplicitlyConvertibleToBool v2 = {true};\n  EXPECT_FALSE(v1);\n  EXPECT_TRUE(v2);\n}\n\n#endif  // GTEST_LANG_CXX11\n\nstruct ConvertibleToAssertionResult {\n  operator AssertionResult() const { return AssertionResult(true); }\n};\n\nTEST(AssertionResultTest, ConstructibleFromImplicitlyConvertible) {\n  ConvertibleToAssertionResult obj;\n  EXPECT_TRUE(obj);\n}\n\n// Tests streaming a user type whose definition and operator << are\n// both in the global namespace.\nclass Base {\n public:\n  explicit Base(int an_x) : x_(an_x) {}\n  int x() const { return x_; }\n private:\n  int x_;\n};\nstd::ostream& operator<<(std::ostream& os,\n                         const Base& val) {\n  return os << val.x();\n}\nstd::ostream& operator<<(std::ostream& os,\n                         const Base* pointer) {\n  return os << \"(\" << pointer->x() << \")\";\n}\n\nTEST(MessageTest, CanStreamUserTypeInGlobalNameSpace) {\n  Message msg;\n  Base a(1);\n\n  msg << a << &a;  // Uses ::operator<<.\n  EXPECT_STREQ(\"1(1)\", msg.GetString().c_str());\n}\n\n// Tests streaming a user type whose definition and operator<< are\n// both in an unnamed namespace.\nnamespace {\nclass MyTypeInUnnamedNameSpace : public Base {\n public:\n  explicit MyTypeInUnnamedNameSpace(int an_x): Base(an_x) {}\n};\nstd::ostream& operator<<(std::ostream& os,\n                         const MyTypeInUnnamedNameSpace& val) {\n  return os << val.x();\n}\nstd::ostream& operator<<(std::ostream& os,\n                         const MyTypeInUnnamedNameSpace* pointer) {\n  return os << \"(\" << pointer->x() << \")\";\n}\n}  // namespace\n\nTEST(MessageTest, CanStreamUserTypeInUnnamedNameSpace) {\n  Message msg;\n  MyTypeInUnnamedNameSpace a(1);\n\n  msg << a << &a;  // Uses <unnamed_namespace>::operator<<.\n  EXPECT_STREQ(\"1(1)\", msg.GetString().c_str());\n}\n\n// Tests streaming a user type whose definition and operator<< are\n// both in a user namespace.\nnamespace namespace1 {\nclass MyTypeInNameSpace1 : public Base {\n public:\n  explicit MyTypeInNameSpace1(int an_x): Base(an_x) {}\n};\nstd::ostream& operator<<(std::ostream& os,\n                         const MyTypeInNameSpace1& val) {\n  return os << val.x();\n}\nstd::ostream& operator<<(std::ostream& os,\n                         const MyTypeInNameSpace1* pointer) {\n  return os << \"(\" << pointer->x() << \")\";\n}\n}  // namespace namespace1\n\nTEST(MessageTest, CanStreamUserTypeInUserNameSpace) {\n  Message msg;\n  namespace1::MyTypeInNameSpace1 a(1);\n\n  msg << a << &a;  // Uses namespace1::operator<<.\n  EXPECT_STREQ(\"1(1)\", msg.GetString().c_str());\n}\n\n// Tests streaming a user type whose definition is in a user namespace\n// but whose operator<< is in the global namespace.\nnamespace namespace2 {\nclass MyTypeInNameSpace2 : public ::Base {\n public:\n  explicit MyTypeInNameSpace2(int an_x): Base(an_x) {}\n};\n}  // namespace namespace2\nstd::ostream& operator<<(std::ostream& os,\n                         const namespace2::MyTypeInNameSpace2& val) {\n  return os << val.x();\n}\nstd::ostream& operator<<(std::ostream& os,\n                         const namespace2::MyTypeInNameSpace2* pointer) {\n  return os << \"(\" << pointer->x() << \")\";\n}\n\nTEST(MessageTest, CanStreamUserTypeInUserNameSpaceWithStreamOperatorInGlobal) {\n  Message msg;\n  namespace2::MyTypeInNameSpace2 a(1);\n\n  msg << a << &a;  // Uses ::operator<<.\n  EXPECT_STREQ(\"1(1)\", msg.GetString().c_str());\n}\n\n// Tests streaming NULL pointers to testing::Message.\nTEST(MessageTest, NullPointers) {\n  Message msg;\n  char* const p1 = NULL;\n  unsigned char* const p2 = NULL;\n  int* p3 = NULL;\n  double* p4 = NULL;\n  bool* p5 = NULL;\n  Message* p6 = NULL;\n\n  msg << p1 << p2 << p3 << p4 << p5 << p6;\n  ASSERT_STREQ(\"(null)(null)(null)(null)(null)(null)\",\n               msg.GetString().c_str());\n}\n\n// Tests streaming wide strings to testing::Message.\nTEST(MessageTest, WideStrings) {\n  // Streams a NULL of type const wchar_t*.\n  const wchar_t* const_wstr = NULL;\n  EXPECT_STREQ(\"(null)\",\n               (Message() << const_wstr).GetString().c_str());\n\n  // Streams a NULL of type wchar_t*.\n  wchar_t* wstr = NULL;\n  EXPECT_STREQ(\"(null)\",\n               (Message() << wstr).GetString().c_str());\n\n  // Streams a non-NULL of type const wchar_t*.\n  const_wstr = L\"abc\\x8119\";\n  EXPECT_STREQ(\"abc\\xe8\\x84\\x99\",\n               (Message() << const_wstr).GetString().c_str());\n\n  // Streams a non-NULL of type wchar_t*.\n  wstr = const_cast<wchar_t*>(const_wstr);\n  EXPECT_STREQ(\"abc\\xe8\\x84\\x99\",\n               (Message() << wstr).GetString().c_str());\n}\n\n\n// This line tests that we can define tests in the testing namespace.\nnamespace testing {\n\n// Tests the TestInfo class.\n\nclass TestInfoTest : public Test {\n protected:\n  static const TestInfo* GetTestInfo(const char* test_name) {\n    const TestCase* const test_case = GetUnitTestImpl()->\n        GetTestCase(\"TestInfoTest\", \"\", NULL, NULL);\n\n    for (int i = 0; i < test_case->total_test_count(); ++i) {\n      const TestInfo* const test_info = test_case->GetTestInfo(i);\n      if (strcmp(test_name, test_info->name()) == 0)\n        return test_info;\n    }\n    return NULL;\n  }\n\n  static const TestResult* GetTestResult(\n      const TestInfo* test_info) {\n    return test_info->result();\n  }\n};\n\n// Tests TestInfo::test_case_name() and TestInfo::name().\nTEST_F(TestInfoTest, Names) {\n  const TestInfo* const test_info = GetTestInfo(\"Names\");\n\n  ASSERT_STREQ(\"TestInfoTest\", test_info->test_case_name());\n  ASSERT_STREQ(\"Names\", test_info->name());\n}\n\n// Tests TestInfo::result().\nTEST_F(TestInfoTest, result) {\n  const TestInfo* const test_info = GetTestInfo(\"result\");\n\n  // Initially, there is no TestPartResult for this test.\n  ASSERT_EQ(0, GetTestResult(test_info)->total_part_count());\n\n  // After the previous assertion, there is still none.\n  ASSERT_EQ(0, GetTestResult(test_info)->total_part_count());\n}\n\n#define VERIFY_CODE_LOCATION \\\n  const int expected_line = __LINE__ - 1; \\\n  const TestInfo* const test_info = GetUnitTestImpl()->current_test_info(); \\\n  ASSERT_TRUE(test_info); \\\n  EXPECT_STREQ(__FILE__, test_info->file()); \\\n  EXPECT_EQ(expected_line, test_info->line())\n\nTEST(CodeLocationForTEST, Verify) {\n  VERIFY_CODE_LOCATION;\n}\n\nclass CodeLocationForTESTF : public Test {\n};\n\nTEST_F(CodeLocationForTESTF, Verify) {\n  VERIFY_CODE_LOCATION;\n}\n\nclass CodeLocationForTESTP : public TestWithParam<int> {\n};\n\nTEST_P(CodeLocationForTESTP, Verify) {\n  VERIFY_CODE_LOCATION;\n}\n\nINSTANTIATE_TEST_CASE_P(, CodeLocationForTESTP, Values(0));\n\ntemplate <typename T>\nclass CodeLocationForTYPEDTEST : public Test {\n};\n\nTYPED_TEST_CASE(CodeLocationForTYPEDTEST, int);\n\nTYPED_TEST(CodeLocationForTYPEDTEST, Verify) {\n  VERIFY_CODE_LOCATION;\n}\n\ntemplate <typename T>\nclass CodeLocationForTYPEDTESTP : public Test {\n};\n\nTYPED_TEST_CASE_P(CodeLocationForTYPEDTESTP);\n\nTYPED_TEST_P(CodeLocationForTYPEDTESTP, Verify) {\n  VERIFY_CODE_LOCATION;\n}\n\nREGISTER_TYPED_TEST_CASE_P(CodeLocationForTYPEDTESTP, Verify);\n\nINSTANTIATE_TYPED_TEST_CASE_P(My, CodeLocationForTYPEDTESTP, int);\n\n#undef VERIFY_CODE_LOCATION\n\n// Tests setting up and tearing down a test case.\n\nclass SetUpTestCaseTest : public Test {\n protected:\n  // This will be called once before the first test in this test case\n  // is run.\n  static void SetUpTestCase() {\n    printf(\"Setting up the test case . . .\\n\");\n\n    // Initializes some shared resource.  In this simple example, we\n    // just create a C string.  More complex stuff can be done if\n    // desired.\n    shared_resource_ = \"123\";\n\n    // Increments the number of test cases that have been set up.\n    counter_++;\n\n    // SetUpTestCase() should be called only once.\n    EXPECT_EQ(1, counter_);\n  }\n\n  // This will be called once after the last test in this test case is\n  // run.\n  static void TearDownTestCase() {\n    printf(\"Tearing down the test case . . .\\n\");\n\n    // Decrements the number of test cases that have been set up.\n    counter_--;\n\n    // TearDownTestCase() should be called only once.\n    EXPECT_EQ(0, counter_);\n\n    // Cleans up the shared resource.\n    shared_resource_ = NULL;\n  }\n\n  // This will be called before each test in this test case.\n  virtual void SetUp() {\n    // SetUpTestCase() should be called only once, so counter_ should\n    // always be 1.\n    EXPECT_EQ(1, counter_);\n  }\n\n  // Number of test cases that have been set up.\n  static int counter_;\n\n  // Some resource to be shared by all tests in this test case.\n  static const char* shared_resource_;\n};\n\nint SetUpTestCaseTest::counter_ = 0;\nconst char* SetUpTestCaseTest::shared_resource_ = NULL;\n\n// A test that uses the shared resource.\nTEST_F(SetUpTestCaseTest, Test1) {\n  EXPECT_STRNE(NULL, shared_resource_);\n}\n\n// Another test that uses the shared resource.\nTEST_F(SetUpTestCaseTest, Test2) {\n  EXPECT_STREQ(\"123\", shared_resource_);\n}\n\n// The InitGoogleTestTest test case tests testing::InitGoogleTest().\n\n// The Flags struct stores a copy of all Google Test flags.\nstruct Flags {\n  // Constructs a Flags struct where each flag has its default value.\n  Flags() : also_run_disabled_tests(false),\n            break_on_failure(false),\n            catch_exceptions(false),\n            death_test_use_fork(false),\n            filter(\"\"),\n            list_tests(false),\n            output(\"\"),\n            print_time(true),\n            random_seed(0),\n            repeat(1),\n            shuffle(false),\n            stack_trace_depth(kMaxStackTraceDepth),\n            stream_result_to(\"\"),\n            throw_on_failure(false) {}\n\n  // Factory methods.\n\n  // Creates a Flags struct where the gtest_also_run_disabled_tests flag has\n  // the given value.\n  static Flags AlsoRunDisabledTests(bool also_run_disabled_tests) {\n    Flags flags;\n    flags.also_run_disabled_tests = also_run_disabled_tests;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_break_on_failure flag has\n  // the given value.\n  static Flags BreakOnFailure(bool break_on_failure) {\n    Flags flags;\n    flags.break_on_failure = break_on_failure;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_catch_exceptions flag has\n  // the given value.\n  static Flags CatchExceptions(bool catch_exceptions) {\n    Flags flags;\n    flags.catch_exceptions = catch_exceptions;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_death_test_use_fork flag has\n  // the given value.\n  static Flags DeathTestUseFork(bool death_test_use_fork) {\n    Flags flags;\n    flags.death_test_use_fork = death_test_use_fork;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_filter flag has the given\n  // value.\n  static Flags Filter(const char* filter) {\n    Flags flags;\n    flags.filter = filter;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_list_tests flag has the\n  // given value.\n  static Flags ListTests(bool list_tests) {\n    Flags flags;\n    flags.list_tests = list_tests;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_output flag has the given\n  // value.\n  static Flags Output(const char* output) {\n    Flags flags;\n    flags.output = output;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_print_time flag has the given\n  // value.\n  static Flags PrintTime(bool print_time) {\n    Flags flags;\n    flags.print_time = print_time;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_random_seed flag has\n  // the given value.\n  static Flags RandomSeed(Int32 random_seed) {\n    Flags flags;\n    flags.random_seed = random_seed;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_repeat flag has the given\n  // value.\n  static Flags Repeat(Int32 repeat) {\n    Flags flags;\n    flags.repeat = repeat;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_shuffle flag has\n  // the given value.\n  static Flags Shuffle(bool shuffle) {\n    Flags flags;\n    flags.shuffle = shuffle;\n    return flags;\n  }\n\n  // Creates a Flags struct where the GTEST_FLAG(stack_trace_depth) flag has\n  // the given value.\n  static Flags StackTraceDepth(Int32 stack_trace_depth) {\n    Flags flags;\n    flags.stack_trace_depth = stack_trace_depth;\n    return flags;\n  }\n\n  // Creates a Flags struct where the GTEST_FLAG(stream_result_to) flag has\n  // the given value.\n  static Flags StreamResultTo(const char* stream_result_to) {\n    Flags flags;\n    flags.stream_result_to = stream_result_to;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_throw_on_failure flag has\n  // the given value.\n  static Flags ThrowOnFailure(bool throw_on_failure) {\n    Flags flags;\n    flags.throw_on_failure = throw_on_failure;\n    return flags;\n  }\n\n  // These fields store the flag values.\n  bool also_run_disabled_tests;\n  bool break_on_failure;\n  bool catch_exceptions;\n  bool death_test_use_fork;\n  const char* filter;\n  bool list_tests;\n  const char* output;\n  bool print_time;\n  Int32 random_seed;\n  Int32 repeat;\n  bool shuffle;\n  Int32 stack_trace_depth;\n  const char* stream_result_to;\n  bool throw_on_failure;\n};\n\n// Fixture for testing InitGoogleTest().\nclass InitGoogleTestTest : public Test {\n protected:\n  // Clears the flags before each test.\n  virtual void SetUp() {\n    GTEST_FLAG(also_run_disabled_tests) = false;\n    GTEST_FLAG(break_on_failure) = false;\n    GTEST_FLAG(catch_exceptions) = false;\n    GTEST_FLAG(death_test_use_fork) = false;\n    GTEST_FLAG(filter) = \"\";\n    GTEST_FLAG(list_tests) = false;\n    GTEST_FLAG(output) = \"\";\n    GTEST_FLAG(print_time) = true;\n    GTEST_FLAG(random_seed) = 0;\n    GTEST_FLAG(repeat) = 1;\n    GTEST_FLAG(shuffle) = false;\n    GTEST_FLAG(stack_trace_depth) = kMaxStackTraceDepth;\n    GTEST_FLAG(stream_result_to) = \"\";\n    GTEST_FLAG(throw_on_failure) = false;\n  }\n\n  // Asserts that two narrow or wide string arrays are equal.\n  template <typename CharType>\n  static void AssertStringArrayEq(size_t size1, CharType** array1,\n                                  size_t size2, CharType** array2) {\n    ASSERT_EQ(size1, size2) << \" Array sizes different.\";\n\n    for (size_t i = 0; i != size1; i++) {\n      ASSERT_STREQ(array1[i], array2[i]) << \" where i == \" << i;\n    }\n  }\n\n  // Verifies that the flag values match the expected values.\n  static void CheckFlags(const Flags& expected) {\n    EXPECT_EQ(expected.also_run_disabled_tests,\n              GTEST_FLAG(also_run_disabled_tests));\n    EXPECT_EQ(expected.break_on_failure, GTEST_FLAG(break_on_failure));\n    EXPECT_EQ(expected.catch_exceptions, GTEST_FLAG(catch_exceptions));\n    EXPECT_EQ(expected.death_test_use_fork, GTEST_FLAG(death_test_use_fork));\n    EXPECT_STREQ(expected.filter, GTEST_FLAG(filter).c_str());\n    EXPECT_EQ(expected.list_tests, GTEST_FLAG(list_tests));\n    EXPECT_STREQ(expected.output, GTEST_FLAG(output).c_str());\n    EXPECT_EQ(expected.print_time, GTEST_FLAG(print_time));\n    EXPECT_EQ(expected.random_seed, GTEST_FLAG(random_seed));\n    EXPECT_EQ(expected.repeat, GTEST_FLAG(repeat));\n    EXPECT_EQ(expected.shuffle, GTEST_FLAG(shuffle));\n    EXPECT_EQ(expected.stack_trace_depth, GTEST_FLAG(stack_trace_depth));\n    EXPECT_STREQ(expected.stream_result_to,\n                 GTEST_FLAG(stream_result_to).c_str());\n    EXPECT_EQ(expected.throw_on_failure, GTEST_FLAG(throw_on_failure));\n  }\n\n  // Parses a command line (specified by argc1 and argv1), then\n  // verifies that the flag values are expected and that the\n  // recognized flags are removed from the command line.\n  template <typename CharType>\n  static void TestParsingFlags(int argc1, const CharType** argv1,\n                               int argc2, const CharType** argv2,\n                               const Flags& expected, bool should_print_help) {\n    const bool saved_help_flag = ::testing::internal::g_help_flag;\n    ::testing::internal::g_help_flag = false;\n\n#if GTEST_HAS_STREAM_REDIRECTION\n    CaptureStdout();\n#endif\n\n    // Parses the command line.\n    internal::ParseGoogleTestFlagsOnly(&argc1, const_cast<CharType**>(argv1));\n\n#if GTEST_HAS_STREAM_REDIRECTION\n    const std::string captured_stdout = GetCapturedStdout();\n#endif\n\n    // Verifies the flag values.\n    CheckFlags(expected);\n\n    // Verifies that the recognized flags are removed from the command\n    // line.\n    AssertStringArrayEq(argc1 + 1, argv1, argc2 + 1, argv2);\n\n    // ParseGoogleTestFlagsOnly should neither set g_help_flag nor print the\n    // help message for the flags it recognizes.\n    EXPECT_EQ(should_print_help, ::testing::internal::g_help_flag);\n\n#if GTEST_HAS_STREAM_REDIRECTION\n    const char* const expected_help_fragment =\n        \"This program contains tests written using\";\n    if (should_print_help) {\n      EXPECT_PRED_FORMAT2(IsSubstring, expected_help_fragment, captured_stdout);\n    } else {\n      EXPECT_PRED_FORMAT2(IsNotSubstring,\n                          expected_help_fragment, captured_stdout);\n    }\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\n    ::testing::internal::g_help_flag = saved_help_flag;\n  }\n\n  // This macro wraps TestParsingFlags s.t. the user doesn't need\n  // to specify the array sizes.\n\n#define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \\\n  TestParsingFlags(sizeof(argv1)/sizeof(*argv1) - 1, argv1, \\\n                   sizeof(argv2)/sizeof(*argv2) - 1, argv2, \\\n                   expected, should_print_help)\n};\n\n// Tests parsing an empty command line.\nTEST_F(InitGoogleTestTest, Empty) {\n  const char* argv[] = {\n    NULL\n  };\n\n  const char* argv2[] = {\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false);\n}\n\n// Tests parsing a command line that has no flag.\nTEST_F(InitGoogleTestTest, NoFlag) {\n  const char* argv[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false);\n}\n\n// Tests parsing a bad --gtest_filter flag.\nTEST_F(InitGoogleTestTest, FilterBad) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_filter\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    \"--gtest_filter\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(\"\"), true);\n}\n\n// Tests parsing an empty --gtest_filter flag.\nTEST_F(InitGoogleTestTest, FilterEmpty) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_filter=\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(\"\"), false);\n}\n\n// Tests parsing a non-empty --gtest_filter flag.\nTEST_F(InitGoogleTestTest, FilterNonEmpty) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_filter=abc\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(\"abc\"), false);\n}\n\n// Tests parsing --gtest_break_on_failure.\nTEST_F(InitGoogleTestTest, BreakOnFailureWithoutValue) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_break_on_failure\",\n    NULL\n};\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(true), false);\n}\n\n// Tests parsing --gtest_break_on_failure=0.\nTEST_F(InitGoogleTestTest, BreakOnFailureFalse_0) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_break_on_failure=0\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false);\n}\n\n// Tests parsing --gtest_break_on_failure=f.\nTEST_F(InitGoogleTestTest, BreakOnFailureFalse_f) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_break_on_failure=f\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false);\n}\n\n// Tests parsing --gtest_break_on_failure=F.\nTEST_F(InitGoogleTestTest, BreakOnFailureFalse_F) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_break_on_failure=F\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false);\n}\n\n// Tests parsing a --gtest_break_on_failure flag that has a \"true\"\n// definition.\nTEST_F(InitGoogleTestTest, BreakOnFailureTrue) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_break_on_failure=1\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(true), false);\n}\n\n// Tests parsing --gtest_catch_exceptions.\nTEST_F(InitGoogleTestTest, CatchExceptions) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_catch_exceptions\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::CatchExceptions(true), false);\n}\n\n// Tests parsing --gtest_death_test_use_fork.\nTEST_F(InitGoogleTestTest, DeathTestUseFork) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_death_test_use_fork\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::DeathTestUseFork(true), false);\n}\n\n// Tests having the same flag twice with different values.  The\n// expected behavior is that the one coming last takes precedence.\nTEST_F(InitGoogleTestTest, DuplicatedFlags) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_filter=a\",\n    \"--gtest_filter=b\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(\"b\"), false);\n}\n\n// Tests having an unrecognized flag on the command line.\nTEST_F(InitGoogleTestTest, UnrecognizedFlag) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_break_on_failure\",\n    \"bar\",  // Unrecognized by Google Test.\n    \"--gtest_filter=b\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    \"bar\",\n    NULL\n  };\n\n  Flags flags;\n  flags.break_on_failure = true;\n  flags.filter = \"b\";\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, flags, false);\n}\n\n// Tests having a --gtest_list_tests flag\nTEST_F(InitGoogleTestTest, ListTestsFlag) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_list_tests\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(true), false);\n}\n\n// Tests having a --gtest_list_tests flag with a \"true\" value\nTEST_F(InitGoogleTestTest, ListTestsTrue) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_list_tests=1\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(true), false);\n}\n\n// Tests having a --gtest_list_tests flag with a \"false\" value\nTEST_F(InitGoogleTestTest, ListTestsFalse) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_list_tests=0\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(false), false);\n}\n\n// Tests parsing --gtest_list_tests=f.\nTEST_F(InitGoogleTestTest, ListTestsFalse_f) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_list_tests=f\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(false), false);\n}\n\n// Tests parsing --gtest_list_tests=F.\nTEST_F(InitGoogleTestTest, ListTestsFalse_F) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_list_tests=F\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(false), false);\n}\n\n// Tests parsing --gtest_output (invalid).\nTEST_F(InitGoogleTestTest, OutputEmpty) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_output\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    \"--gtest_output\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true);\n}\n\n// Tests parsing --gtest_output=xml\nTEST_F(InitGoogleTestTest, OutputXml) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_output=xml\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Output(\"xml\"), false);\n}\n\n// Tests parsing --gtest_output=xml:file\nTEST_F(InitGoogleTestTest, OutputXmlFile) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_output=xml:file\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Output(\"xml:file\"), false);\n}\n\n// Tests parsing --gtest_output=xml:directory/path/\nTEST_F(InitGoogleTestTest, OutputXmlDirectory) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_output=xml:directory/path/\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2,\n                            Flags::Output(\"xml:directory/path/\"), false);\n}\n\n// Tests having a --gtest_print_time flag\nTEST_F(InitGoogleTestTest, PrintTimeFlag) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_print_time\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(true), false);\n}\n\n// Tests having a --gtest_print_time flag with a \"true\" value\nTEST_F(InitGoogleTestTest, PrintTimeTrue) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_print_time=1\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(true), false);\n}\n\n// Tests having a --gtest_print_time flag with a \"false\" value\nTEST_F(InitGoogleTestTest, PrintTimeFalse) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_print_time=0\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(false), false);\n}\n\n// Tests parsing --gtest_print_time=f.\nTEST_F(InitGoogleTestTest, PrintTimeFalse_f) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_print_time=f\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(false), false);\n}\n\n// Tests parsing --gtest_print_time=F.\nTEST_F(InitGoogleTestTest, PrintTimeFalse_F) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_print_time=F\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(false), false);\n}\n\n// Tests parsing --gtest_random_seed=number\nTEST_F(InitGoogleTestTest, RandomSeed) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_random_seed=1000\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::RandomSeed(1000), false);\n}\n\n// Tests parsing --gtest_repeat=number\nTEST_F(InitGoogleTestTest, Repeat) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_repeat=1000\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Repeat(1000), false);\n}\n\n// Tests having a --gtest_also_run_disabled_tests flag\nTEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFlag) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_also_run_disabled_tests\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2,\n                              Flags::AlsoRunDisabledTests(true), false);\n}\n\n// Tests having a --gtest_also_run_disabled_tests flag with a \"true\" value\nTEST_F(InitGoogleTestTest, AlsoRunDisabledTestsTrue) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_also_run_disabled_tests=1\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2,\n                              Flags::AlsoRunDisabledTests(true), false);\n}\n\n// Tests having a --gtest_also_run_disabled_tests flag with a \"false\" value\nTEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFalse) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_also_run_disabled_tests=0\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2,\n                              Flags::AlsoRunDisabledTests(false), false);\n}\n\n// Tests parsing --gtest_shuffle.\nTEST_F(InitGoogleTestTest, ShuffleWithoutValue) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_shuffle\",\n    NULL\n};\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(true), false);\n}\n\n// Tests parsing --gtest_shuffle=0.\nTEST_F(InitGoogleTestTest, ShuffleFalse_0) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_shuffle=0\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(false), false);\n}\n\n// Tests parsing a --gtest_shuffle flag that has a \"true\"\n// definition.\nTEST_F(InitGoogleTestTest, ShuffleTrue) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_shuffle=1\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(true), false);\n}\n\n// Tests parsing --gtest_stack_trace_depth=number.\nTEST_F(InitGoogleTestTest, StackTraceDepth) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_stack_trace_depth=5\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::StackTraceDepth(5), false);\n}\n\nTEST_F(InitGoogleTestTest, StreamResultTo) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_stream_result_to=localhost:1234\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(\n      argv, argv2, Flags::StreamResultTo(\"localhost:1234\"), false);\n}\n\n// Tests parsing --gtest_throw_on_failure.\nTEST_F(InitGoogleTestTest, ThrowOnFailureWithoutValue) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_throw_on_failure\",\n    NULL\n};\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(true), false);\n}\n\n// Tests parsing --gtest_throw_on_failure=0.\nTEST_F(InitGoogleTestTest, ThrowOnFailureFalse_0) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_throw_on_failure=0\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(false), false);\n}\n\n// Tests parsing a --gtest_throw_on_failure flag that has a \"true\"\n// definition.\nTEST_F(InitGoogleTestTest, ThrowOnFailureTrue) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_throw_on_failure=1\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(true), false);\n}\n\n#if GTEST_OS_WINDOWS\n// Tests parsing wide strings.\nTEST_F(InitGoogleTestTest, WideStrings) {\n  const wchar_t* argv[] = {\n    L\"foo.exe\",\n    L\"--gtest_filter=Foo*\",\n    L\"--gtest_list_tests=1\",\n    L\"--gtest_break_on_failure\",\n    L\"--non_gtest_flag\",\n    NULL\n  };\n\n  const wchar_t* argv2[] = {\n    L\"foo.exe\",\n    L\"--non_gtest_flag\",\n    NULL\n  };\n\n  Flags expected_flags;\n  expected_flags.break_on_failure = true;\n  expected_flags.filter = \"Foo*\";\n  expected_flags.list_tests = true;\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, expected_flags, false);\n}\n# endif  // GTEST_OS_WINDOWS\n\n#if GTEST_USE_OWN_FLAGFILE_FLAG_\nclass FlagfileTest : public InitGoogleTestTest {\n public:\n  virtual void SetUp() {\n    InitGoogleTestTest::SetUp();\n\n    testdata_path_.Set(internal::FilePath(\n        internal::TempDir() + internal::GetCurrentExecutableName().string() +\n        \"_flagfile_test\"));\n    testing::internal::posix::RmDir(testdata_path_.c_str());\n    EXPECT_TRUE(testdata_path_.CreateFolder());\n  }\n\n  virtual void TearDown() {\n    testing::internal::posix::RmDir(testdata_path_.c_str());\n    InitGoogleTestTest::TearDown();\n  }\n\n  internal::FilePath CreateFlagfile(const char* contents) {\n    internal::FilePath file_path(internal::FilePath::GenerateUniqueFileName(\n        testdata_path_, internal::FilePath(\"unique\"), \"txt\"));\n    FILE* f = testing::internal::posix::FOpen(file_path.c_str(), \"w\");\n    fprintf(f, \"%s\", contents);\n    fclose(f);\n    return file_path;\n  }\n\n private:\n  internal::FilePath testdata_path_;\n};\n\n// Tests an empty flagfile.\nTEST_F(FlagfileTest, Empty) {\n  internal::FilePath flagfile_path(CreateFlagfile(\"\"));\n  std::string flagfile_flag =\n      std::string(\"--\" GTEST_FLAG_PREFIX_ \"flagfile=\") + flagfile_path.c_str();\n\n  const char* argv[] = {\n    \"foo.exe\",\n    flagfile_flag.c_str(),\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false);\n}\n\n// Tests passing a non-empty --gtest_filter flag via --gtest_flagfile.\nTEST_F(FlagfileTest, FilterNonEmpty) {\n  internal::FilePath flagfile_path(CreateFlagfile(\n      \"--\"  GTEST_FLAG_PREFIX_  \"filter=abc\"));\n  std::string flagfile_flag =\n      std::string(\"--\" GTEST_FLAG_PREFIX_ \"flagfile=\") + flagfile_path.c_str();\n\n  const char* argv[] = {\n    \"foo.exe\",\n    flagfile_flag.c_str(),\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(\"abc\"), false);\n}\n\n// Tests passing several flags via --gtest_flagfile.\nTEST_F(FlagfileTest, SeveralFlags) {\n  internal::FilePath flagfile_path(CreateFlagfile(\n      \"--\"  GTEST_FLAG_PREFIX_  \"filter=abc\\n\"\n      \"--\"  GTEST_FLAG_PREFIX_  \"break_on_failure\\n\"\n      \"--\"  GTEST_FLAG_PREFIX_  \"list_tests\"));\n  std::string flagfile_flag =\n      std::string(\"--\" GTEST_FLAG_PREFIX_ \"flagfile=\") + flagfile_path.c_str();\n\n  const char* argv[] = {\n    \"foo.exe\",\n    flagfile_flag.c_str(),\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  Flags expected_flags;\n  expected_flags.break_on_failure = true;\n  expected_flags.filter = \"abc\";\n  expected_flags.list_tests = true;\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, expected_flags, false);\n}\n#endif  // GTEST_USE_OWN_FLAGFILE_FLAG_\n\n// Tests current_test_info() in UnitTest.\nclass CurrentTestInfoTest : public Test {\n protected:\n  // Tests that current_test_info() returns NULL before the first test in\n  // the test case is run.\n  static void SetUpTestCase() {\n    // There should be no tests running at this point.\n    const TestInfo* test_info =\n      UnitTest::GetInstance()->current_test_info();\n    EXPECT_TRUE(test_info == NULL)\n        << \"There should be no tests running at this point.\";\n  }\n\n  // Tests that current_test_info() returns NULL after the last test in\n  // the test case has run.\n  static void TearDownTestCase() {\n    const TestInfo* test_info =\n      UnitTest::GetInstance()->current_test_info();\n    EXPECT_TRUE(test_info == NULL)\n        << \"There should be no tests running at this point.\";\n  }\n};\n\n// Tests that current_test_info() returns TestInfo for currently running\n// test by checking the expected test name against the actual one.\nTEST_F(CurrentTestInfoTest, WorksForFirstTestInATestCase) {\n  const TestInfo* test_info =\n    UnitTest::GetInstance()->current_test_info();\n  ASSERT_TRUE(NULL != test_info)\n      << \"There is a test running so we should have a valid TestInfo.\";\n  EXPECT_STREQ(\"CurrentTestInfoTest\", test_info->test_case_name())\n      << \"Expected the name of the currently running test case.\";\n  EXPECT_STREQ(\"WorksForFirstTestInATestCase\", test_info->name())\n      << \"Expected the name of the currently running test.\";\n}\n\n// Tests that current_test_info() returns TestInfo for currently running\n// test by checking the expected test name against the actual one.  We\n// use this test to see that the TestInfo object actually changed from\n// the previous invocation.\nTEST_F(CurrentTestInfoTest, WorksForSecondTestInATestCase) {\n  const TestInfo* test_info =\n    UnitTest::GetInstance()->current_test_info();\n  ASSERT_TRUE(NULL != test_info)\n      << \"There is a test running so we should have a valid TestInfo.\";\n  EXPECT_STREQ(\"CurrentTestInfoTest\", test_info->test_case_name())\n      << \"Expected the name of the currently running test case.\";\n  EXPECT_STREQ(\"WorksForSecondTestInATestCase\", test_info->name())\n      << \"Expected the name of the currently running test.\";\n}\n\n}  // namespace testing\n\n// These two lines test that we can define tests in a namespace that\n// has the name \"testing\" and is nested in another namespace.\nnamespace my_namespace {\nnamespace testing {\n\n// Makes sure that TEST knows to use ::testing::Test instead of\n// ::my_namespace::testing::Test.\nclass Test {};\n\n// Makes sure that an assertion knows to use ::testing::Message instead of\n// ::my_namespace::testing::Message.\nclass Message {};\n\n// Makes sure that an assertion knows to use\n// ::testing::AssertionResult instead of\n// ::my_namespace::testing::AssertionResult.\nclass AssertionResult {};\n\n// Tests that an assertion that should succeed works as expected.\nTEST(NestedTestingNamespaceTest, Success) {\n  EXPECT_EQ(1, 1) << \"This shouldn't fail.\";\n}\n\n// Tests that an assertion that should fail works as expected.\nTEST(NestedTestingNamespaceTest, Failure) {\n  EXPECT_FATAL_FAILURE(FAIL() << \"This failure is expected.\",\n                       \"This failure is expected.\");\n}\n\n}  // namespace testing\n}  // namespace my_namespace\n\n// Tests that one can call superclass SetUp and TearDown methods--\n// that is, that they are not private.\n// No tests are based on this fixture; the test \"passes\" if it compiles\n// successfully.\nclass ProtectedFixtureMethodsTest : public Test {\n protected:\n  virtual void SetUp() {\n    Test::SetUp();\n  }\n  virtual void TearDown() {\n    Test::TearDown();\n  }\n};\n\n// StreamingAssertionsTest tests the streaming versions of a representative\n// sample of assertions.\nTEST(StreamingAssertionsTest, Unconditional) {\n  SUCCEED() << \"expected success\";\n  EXPECT_NONFATAL_FAILURE(ADD_FAILURE() << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(FAIL() << \"expected failure\",\n                       \"expected failure\");\n}\n\n#ifdef __BORLANDC__\n// Silences warnings: \"Condition is always true\", \"Unreachable code\"\n# pragma option push -w-ccc -w-rch\n#endif\n\nTEST(StreamingAssertionsTest, Truth) {\n  EXPECT_TRUE(true) << \"unexpected failure\";\n  ASSERT_TRUE(true) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(false) << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_TRUE(false) << \"expected failure\",\n                       \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, Truth2) {\n  EXPECT_FALSE(false) << \"unexpected failure\";\n  ASSERT_FALSE(false) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(true) << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_FALSE(true) << \"expected failure\",\n                       \"expected failure\");\n}\n\n#ifdef __BORLANDC__\n// Restores warnings after previous \"#pragma option push\" supressed them\n# pragma option pop\n#endif\n\nTEST(StreamingAssertionsTest, IntegerEquals) {\n  EXPECT_EQ(1, 1) << \"unexpected failure\";\n  ASSERT_EQ(1, 1) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(1, 2) << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(1, 2) << \"expected failure\",\n                       \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, IntegerLessThan) {\n  EXPECT_LT(1, 2) << \"unexpected failure\";\n  ASSERT_LT(1, 2) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_LT(2, 1) << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_LT(2, 1) << \"expected failure\",\n                       \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, StringsEqual) {\n  EXPECT_STREQ(\"foo\", \"foo\") << \"unexpected failure\";\n  ASSERT_STREQ(\"foo\", \"foo\") << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_STREQ(\"foo\", \"bar\") << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_STREQ(\"foo\", \"bar\") << \"expected failure\",\n                       \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, StringsNotEqual) {\n  EXPECT_STRNE(\"foo\", \"bar\") << \"unexpected failure\";\n  ASSERT_STRNE(\"foo\", \"bar\") << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(\"foo\", \"foo\") << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_STRNE(\"foo\", \"foo\") << \"expected failure\",\n                       \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, StringsEqualIgnoringCase) {\n  EXPECT_STRCASEEQ(\"foo\", \"FOO\") << \"unexpected failure\";\n  ASSERT_STRCASEEQ(\"foo\", \"FOO\") << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRCASEEQ(\"foo\", \"bar\") << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_STRCASEEQ(\"foo\", \"bar\") << \"expected failure\",\n                       \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, StringNotEqualIgnoringCase) {\n  EXPECT_STRCASENE(\"foo\", \"bar\") << \"unexpected failure\";\n  ASSERT_STRCASENE(\"foo\", \"bar\") << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRCASENE(\"foo\", \"FOO\") << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_STRCASENE(\"bar\", \"BAR\") << \"expected failure\",\n                       \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, FloatingPointEquals) {\n  EXPECT_FLOAT_EQ(1.0, 1.0) << \"unexpected failure\";\n  ASSERT_FLOAT_EQ(1.0, 1.0) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(0.0, 1.0) << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_FLOAT_EQ(0.0, 1.0) << \"expected failure\",\n                       \"expected failure\");\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\nTEST(StreamingAssertionsTest, Throw) {\n  EXPECT_THROW(ThrowAnInteger(), int) << \"unexpected failure\";\n  ASSERT_THROW(ThrowAnInteger(), int) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW(ThrowAnInteger(), bool) <<\n                          \"expected failure\", \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_THROW(ThrowAnInteger(), bool) <<\n                       \"expected failure\", \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, NoThrow) {\n  EXPECT_NO_THROW(ThrowNothing()) << \"unexpected failure\";\n  ASSERT_NO_THROW(ThrowNothing()) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnInteger()) <<\n                          \"expected failure\", \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnInteger()) <<\n                       \"expected failure\", \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, AnyThrow) {\n  EXPECT_ANY_THROW(ThrowAnInteger()) << \"unexpected failure\";\n  ASSERT_ANY_THROW(ThrowAnInteger()) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(ThrowNothing()) <<\n                          \"expected failure\", \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_ANY_THROW(ThrowNothing()) <<\n                       \"expected failure\", \"expected failure\");\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// Tests that Google Test correctly decides whether to use colors in the output.\n\nTEST(ColoredOutputTest, UsesColorsWhenGTestColorFlagIsYes) {\n  GTEST_FLAG(color) = \"yes\";\n\n  SetEnv(\"TERM\", \"xterm\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n  EXPECT_TRUE(ShouldUseColor(false));  // Stdout is not a TTY.\n\n  SetEnv(\"TERM\", \"dumb\");  // TERM doesn't support colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n  EXPECT_TRUE(ShouldUseColor(false));  // Stdout is not a TTY.\n}\n\nTEST(ColoredOutputTest, UsesColorsWhenGTestColorFlagIsAliasOfYes) {\n  SetEnv(\"TERM\", \"dumb\");  // TERM doesn't support colors.\n\n  GTEST_FLAG(color) = \"True\";\n  EXPECT_TRUE(ShouldUseColor(false));  // Stdout is not a TTY.\n\n  GTEST_FLAG(color) = \"t\";\n  EXPECT_TRUE(ShouldUseColor(false));  // Stdout is not a TTY.\n\n  GTEST_FLAG(color) = \"1\";\n  EXPECT_TRUE(ShouldUseColor(false));  // Stdout is not a TTY.\n}\n\nTEST(ColoredOutputTest, UsesNoColorWhenGTestColorFlagIsNo) {\n  GTEST_FLAG(color) = \"no\";\n\n  SetEnv(\"TERM\", \"xterm\");  // TERM supports colors.\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n  EXPECT_FALSE(ShouldUseColor(false));  // Stdout is not a TTY.\n\n  SetEnv(\"TERM\", \"dumb\");  // TERM doesn't support colors.\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n  EXPECT_FALSE(ShouldUseColor(false));  // Stdout is not a TTY.\n}\n\nTEST(ColoredOutputTest, UsesNoColorWhenGTestColorFlagIsInvalid) {\n  SetEnv(\"TERM\", \"xterm\");  // TERM supports colors.\n\n  GTEST_FLAG(color) = \"F\";\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  GTEST_FLAG(color) = \"0\";\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  GTEST_FLAG(color) = \"unknown\";\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n}\n\nTEST(ColoredOutputTest, UsesColorsWhenStdoutIsTty) {\n  GTEST_FLAG(color) = \"auto\";\n\n  SetEnv(\"TERM\", \"xterm\");  // TERM supports colors.\n  EXPECT_FALSE(ShouldUseColor(false));  // Stdout is not a TTY.\n  EXPECT_TRUE(ShouldUseColor(true));    // Stdout is a TTY.\n}\n\nTEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) {\n  GTEST_FLAG(color) = \"auto\";\n\n#if GTEST_OS_WINDOWS\n  // On Windows, we ignore the TERM variable as it's usually not set.\n\n  SetEnv(\"TERM\", \"dumb\");\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"\");\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"xterm\");\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n#else\n  // On non-Windows platforms, we rely on TERM to determine if the\n  // terminal supports colors.\n\n  SetEnv(\"TERM\", \"dumb\");  // TERM doesn't support colors.\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"emacs\");  // TERM doesn't support colors.\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"vt100\");  // TERM doesn't support colors.\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"xterm-mono\");  // TERM doesn't support colors.\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"xterm\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"xterm-color\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"xterm-256color\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"screen\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"screen-256color\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"tmux\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"tmux-256color\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"rxvt-unicode\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"rxvt-unicode-256color\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"linux\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"cygwin\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n#endif  // GTEST_OS_WINDOWS\n}\n\n// Verifies that StaticAssertTypeEq works in a namespace scope.\n\nstatic bool dummy1 GTEST_ATTRIBUTE_UNUSED_ = StaticAssertTypeEq<bool, bool>();\nstatic bool dummy2 GTEST_ATTRIBUTE_UNUSED_ =\n    StaticAssertTypeEq<const int, const int>();\n\n// Verifies that StaticAssertTypeEq works in a class.\n\ntemplate <typename T>\nclass StaticAssertTypeEqTestHelper {\n public:\n  StaticAssertTypeEqTestHelper() { StaticAssertTypeEq<bool, T>(); }\n};\n\nTEST(StaticAssertTypeEqTest, WorksInClass) {\n  StaticAssertTypeEqTestHelper<bool>();\n}\n\n// Verifies that StaticAssertTypeEq works inside a function.\n\ntypedef int IntAlias;\n\nTEST(StaticAssertTypeEqTest, CompilesForEqualTypes) {\n  StaticAssertTypeEq<int, IntAlias>();\n  StaticAssertTypeEq<int*, IntAlias*>();\n}\n\nTEST(GetCurrentOsStackTraceExceptTopTest, ReturnsTheStackTrace) {\n  testing::UnitTest* const unit_test = testing::UnitTest::GetInstance();\n\n  // We don't have a stack walker in Google Test yet.\n  EXPECT_STREQ(\"\", GetCurrentOsStackTraceExceptTop(unit_test, 0).c_str());\n  EXPECT_STREQ(\"\", GetCurrentOsStackTraceExceptTop(unit_test, 1).c_str());\n}\n\nTEST(HasNonfatalFailureTest, ReturnsFalseWhenThereIsNoFailure) {\n  EXPECT_FALSE(HasNonfatalFailure());\n}\n\nstatic void FailFatally() { FAIL(); }\n\nTEST(HasNonfatalFailureTest, ReturnsFalseWhenThereIsOnlyFatalFailure) {\n  FailFatally();\n  const bool has_nonfatal_failure = HasNonfatalFailure();\n  ClearCurrentTestPartResults();\n  EXPECT_FALSE(has_nonfatal_failure);\n}\n\nTEST(HasNonfatalFailureTest, ReturnsTrueWhenThereIsNonfatalFailure) {\n  ADD_FAILURE();\n  const bool has_nonfatal_failure = HasNonfatalFailure();\n  ClearCurrentTestPartResults();\n  EXPECT_TRUE(has_nonfatal_failure);\n}\n\nTEST(HasNonfatalFailureTest, ReturnsTrueWhenThereAreFatalAndNonfatalFailures) {\n  FailFatally();\n  ADD_FAILURE();\n  const bool has_nonfatal_failure = HasNonfatalFailure();\n  ClearCurrentTestPartResults();\n  EXPECT_TRUE(has_nonfatal_failure);\n}\n\n// A wrapper for calling HasNonfatalFailure outside of a test body.\nstatic bool HasNonfatalFailureHelper() {\n  return testing::Test::HasNonfatalFailure();\n}\n\nTEST(HasNonfatalFailureTest, WorksOutsideOfTestBody) {\n  EXPECT_FALSE(HasNonfatalFailureHelper());\n}\n\nTEST(HasNonfatalFailureTest, WorksOutsideOfTestBody2) {\n  ADD_FAILURE();\n  const bool has_nonfatal_failure = HasNonfatalFailureHelper();\n  ClearCurrentTestPartResults();\n  EXPECT_TRUE(has_nonfatal_failure);\n}\n\nTEST(HasFailureTest, ReturnsFalseWhenThereIsNoFailure) {\n  EXPECT_FALSE(HasFailure());\n}\n\nTEST(HasFailureTest, ReturnsTrueWhenThereIsFatalFailure) {\n  FailFatally();\n  const bool has_failure = HasFailure();\n  ClearCurrentTestPartResults();\n  EXPECT_TRUE(has_failure);\n}\n\nTEST(HasFailureTest, ReturnsTrueWhenThereIsNonfatalFailure) {\n  ADD_FAILURE();\n  const bool has_failure = HasFailure();\n  ClearCurrentTestPartResults();\n  EXPECT_TRUE(has_failure);\n}\n\nTEST(HasFailureTest, ReturnsTrueWhenThereAreFatalAndNonfatalFailures) {\n  FailFatally();\n  ADD_FAILURE();\n  const bool has_failure = HasFailure();\n  ClearCurrentTestPartResults();\n  EXPECT_TRUE(has_failure);\n}\n\n// A wrapper for calling HasFailure outside of a test body.\nstatic bool HasFailureHelper() { return testing::Test::HasFailure(); }\n\nTEST(HasFailureTest, WorksOutsideOfTestBody) {\n  EXPECT_FALSE(HasFailureHelper());\n}\n\nTEST(HasFailureTest, WorksOutsideOfTestBody2) {\n  ADD_FAILURE();\n  const bool has_failure = HasFailureHelper();\n  ClearCurrentTestPartResults();\n  EXPECT_TRUE(has_failure);\n}\n\nclass TestListener : public EmptyTestEventListener {\n public:\n  TestListener() : on_start_counter_(NULL), is_destroyed_(NULL) {}\n  TestListener(int* on_start_counter, bool* is_destroyed)\n      : on_start_counter_(on_start_counter),\n        is_destroyed_(is_destroyed) {}\n\n  virtual ~TestListener() {\n    if (is_destroyed_)\n      *is_destroyed_ = true;\n  }\n\n protected:\n  virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {\n    if (on_start_counter_ != NULL)\n      (*on_start_counter_)++;\n  }\n\n private:\n  int* on_start_counter_;\n  bool* is_destroyed_;\n};\n\n// Tests the constructor.\nTEST(TestEventListenersTest, ConstructionWorks) {\n  TestEventListeners listeners;\n\n  EXPECT_TRUE(TestEventListenersAccessor::GetRepeater(&listeners) != NULL);\n  EXPECT_TRUE(listeners.default_result_printer() == NULL);\n  EXPECT_TRUE(listeners.default_xml_generator() == NULL);\n}\n\n// Tests that the TestEventListeners destructor deletes all the listeners it\n// owns.\nTEST(TestEventListenersTest, DestructionWorks) {\n  bool default_result_printer_is_destroyed = false;\n  bool default_xml_printer_is_destroyed = false;\n  bool extra_listener_is_destroyed = false;\n  TestListener* default_result_printer = new TestListener(\n      NULL, &default_result_printer_is_destroyed);\n  TestListener* default_xml_printer = new TestListener(\n      NULL, &default_xml_printer_is_destroyed);\n  TestListener* extra_listener = new TestListener(\n      NULL, &extra_listener_is_destroyed);\n\n  {\n    TestEventListeners listeners;\n    TestEventListenersAccessor::SetDefaultResultPrinter(&listeners,\n                                                        default_result_printer);\n    TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners,\n                                                       default_xml_printer);\n    listeners.Append(extra_listener);\n  }\n  EXPECT_TRUE(default_result_printer_is_destroyed);\n  EXPECT_TRUE(default_xml_printer_is_destroyed);\n  EXPECT_TRUE(extra_listener_is_destroyed);\n}\n\n// Tests that a listener Append'ed to a TestEventListeners list starts\n// receiving events.\nTEST(TestEventListenersTest, Append) {\n  int on_start_counter = 0;\n  bool is_destroyed = false;\n  TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);\n  {\n    TestEventListeners listeners;\n    listeners.Append(listener);\n    TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n        *UnitTest::GetInstance());\n    EXPECT_EQ(1, on_start_counter);\n  }\n  EXPECT_TRUE(is_destroyed);\n}\n\n// Tests that listeners receive events in the order they were appended to\n// the list, except for *End requests, which must be received in the reverse\n// order.\nclass SequenceTestingListener : public EmptyTestEventListener {\n public:\n  SequenceTestingListener(std::vector<std::string>* vector, const char* id)\n      : vector_(vector), id_(id) {}\n\n protected:\n  virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {\n    vector_->push_back(GetEventDescription(\"OnTestProgramStart\"));\n  }\n\n  virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {\n    vector_->push_back(GetEventDescription(\"OnTestProgramEnd\"));\n  }\n\n  virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,\n                                    int /*iteration*/) {\n    vector_->push_back(GetEventDescription(\"OnTestIterationStart\"));\n  }\n\n  virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,\n                                  int /*iteration*/) {\n    vector_->push_back(GetEventDescription(\"OnTestIterationEnd\"));\n  }\n\n private:\n  std::string GetEventDescription(const char* method) {\n    Message message;\n    message << id_ << \".\" << method;\n    return message.GetString();\n  }\n\n  std::vector<std::string>* vector_;\n  const char* const id_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(SequenceTestingListener);\n};\n\nTEST(EventListenerTest, AppendKeepsOrder) {\n  std::vector<std::string> vec;\n  TestEventListeners listeners;\n  listeners.Append(new SequenceTestingListener(&vec, \"1st\"));\n  listeners.Append(new SequenceTestingListener(&vec, \"2nd\"));\n  listeners.Append(new SequenceTestingListener(&vec, \"3rd\"));\n\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n      *UnitTest::GetInstance());\n  ASSERT_EQ(3U, vec.size());\n  EXPECT_STREQ(\"1st.OnTestProgramStart\", vec[0].c_str());\n  EXPECT_STREQ(\"2nd.OnTestProgramStart\", vec[1].c_str());\n  EXPECT_STREQ(\"3rd.OnTestProgramStart\", vec[2].c_str());\n\n  vec.clear();\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramEnd(\n      *UnitTest::GetInstance());\n  ASSERT_EQ(3U, vec.size());\n  EXPECT_STREQ(\"3rd.OnTestProgramEnd\", vec[0].c_str());\n  EXPECT_STREQ(\"2nd.OnTestProgramEnd\", vec[1].c_str());\n  EXPECT_STREQ(\"1st.OnTestProgramEnd\", vec[2].c_str());\n\n  vec.clear();\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestIterationStart(\n      *UnitTest::GetInstance(), 0);\n  ASSERT_EQ(3U, vec.size());\n  EXPECT_STREQ(\"1st.OnTestIterationStart\", vec[0].c_str());\n  EXPECT_STREQ(\"2nd.OnTestIterationStart\", vec[1].c_str());\n  EXPECT_STREQ(\"3rd.OnTestIterationStart\", vec[2].c_str());\n\n  vec.clear();\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestIterationEnd(\n      *UnitTest::GetInstance(), 0);\n  ASSERT_EQ(3U, vec.size());\n  EXPECT_STREQ(\"3rd.OnTestIterationEnd\", vec[0].c_str());\n  EXPECT_STREQ(\"2nd.OnTestIterationEnd\", vec[1].c_str());\n  EXPECT_STREQ(\"1st.OnTestIterationEnd\", vec[2].c_str());\n}\n\n// Tests that a listener removed from a TestEventListeners list stops receiving\n// events and is not deleted when the list is destroyed.\nTEST(TestEventListenersTest, Release) {\n  int on_start_counter = 0;\n  bool is_destroyed = false;\n  // Although Append passes the ownership of this object to the list,\n  // the following calls release it, and we need to delete it before the\n  // test ends.\n  TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);\n  {\n    TestEventListeners listeners;\n    listeners.Append(listener);\n    EXPECT_EQ(listener, listeners.Release(listener));\n    TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n        *UnitTest::GetInstance());\n    EXPECT_TRUE(listeners.Release(listener) == NULL);\n  }\n  EXPECT_EQ(0, on_start_counter);\n  EXPECT_FALSE(is_destroyed);\n  delete listener;\n}\n\n// Tests that no events are forwarded when event forwarding is disabled.\nTEST(EventListenerTest, SuppressEventForwarding) {\n  int on_start_counter = 0;\n  TestListener* listener = new TestListener(&on_start_counter, NULL);\n\n  TestEventListeners listeners;\n  listeners.Append(listener);\n  ASSERT_TRUE(TestEventListenersAccessor::EventForwardingEnabled(listeners));\n  TestEventListenersAccessor::SuppressEventForwarding(&listeners);\n  ASSERT_FALSE(TestEventListenersAccessor::EventForwardingEnabled(listeners));\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n      *UnitTest::GetInstance());\n  EXPECT_EQ(0, on_start_counter);\n}\n\n// Tests that events generated by Google Test are not forwarded in\n// death test subprocesses.\nTEST(EventListenerDeathTest, EventsNotForwardedInDeathTestSubprecesses) {\n  EXPECT_DEATH_IF_SUPPORTED({\n      GTEST_CHECK_(TestEventListenersAccessor::EventForwardingEnabled(\n          *GetUnitTestImpl()->listeners())) << \"expected failure\";},\n      \"expected failure\");\n}\n\n// Tests that a listener installed via SetDefaultResultPrinter() starts\n// receiving events and is returned via default_result_printer() and that\n// the previous default_result_printer is removed from the list and deleted.\nTEST(EventListenerTest, default_result_printer) {\n  int on_start_counter = 0;\n  bool is_destroyed = false;\n  TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);\n\n  TestEventListeners listeners;\n  TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, listener);\n\n  EXPECT_EQ(listener, listeners.default_result_printer());\n\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n      *UnitTest::GetInstance());\n\n  EXPECT_EQ(1, on_start_counter);\n\n  // Replacing default_result_printer with something else should remove it\n  // from the list and destroy it.\n  TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, NULL);\n\n  EXPECT_TRUE(listeners.default_result_printer() == NULL);\n  EXPECT_TRUE(is_destroyed);\n\n  // After broadcasting an event the counter is still the same, indicating\n  // the listener is not in the list anymore.\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n      *UnitTest::GetInstance());\n  EXPECT_EQ(1, on_start_counter);\n}\n\n// Tests that the default_result_printer listener stops receiving events\n// when removed via Release and that is not owned by the list anymore.\nTEST(EventListenerTest, RemovingDefaultResultPrinterWorks) {\n  int on_start_counter = 0;\n  bool is_destroyed = false;\n  // Although Append passes the ownership of this object to the list,\n  // the following calls release it, and we need to delete it before the\n  // test ends.\n  TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);\n  {\n    TestEventListeners listeners;\n    TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, listener);\n\n    EXPECT_EQ(listener, listeners.Release(listener));\n    EXPECT_TRUE(listeners.default_result_printer() == NULL);\n    EXPECT_FALSE(is_destroyed);\n\n    // Broadcasting events now should not affect default_result_printer.\n    TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n        *UnitTest::GetInstance());\n    EXPECT_EQ(0, on_start_counter);\n  }\n  // Destroying the list should not affect the listener now, too.\n  EXPECT_FALSE(is_destroyed);\n  delete listener;\n}\n\n// Tests that a listener installed via SetDefaultXmlGenerator() starts\n// receiving events and is returned via default_xml_generator() and that\n// the previous default_xml_generator is removed from the list and deleted.\nTEST(EventListenerTest, default_xml_generator) {\n  int on_start_counter = 0;\n  bool is_destroyed = false;\n  TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);\n\n  TestEventListeners listeners;\n  TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, listener);\n\n  EXPECT_EQ(listener, listeners.default_xml_generator());\n\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n      *UnitTest::GetInstance());\n\n  EXPECT_EQ(1, on_start_counter);\n\n  // Replacing default_xml_generator with something else should remove it\n  // from the list and destroy it.\n  TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, NULL);\n\n  EXPECT_TRUE(listeners.default_xml_generator() == NULL);\n  EXPECT_TRUE(is_destroyed);\n\n  // After broadcasting an event the counter is still the same, indicating\n  // the listener is not in the list anymore.\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n      *UnitTest::GetInstance());\n  EXPECT_EQ(1, on_start_counter);\n}\n\n// Tests that the default_xml_generator listener stops receiving events\n// when removed via Release and that is not owned by the list anymore.\nTEST(EventListenerTest, RemovingDefaultXmlGeneratorWorks) {\n  int on_start_counter = 0;\n  bool is_destroyed = false;\n  // Although Append passes the ownership of this object to the list,\n  // the following calls release it, and we need to delete it before the\n  // test ends.\n  TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);\n  {\n    TestEventListeners listeners;\n    TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, listener);\n\n    EXPECT_EQ(listener, listeners.Release(listener));\n    EXPECT_TRUE(listeners.default_xml_generator() == NULL);\n    EXPECT_FALSE(is_destroyed);\n\n    // Broadcasting events now should not affect default_xml_generator.\n    TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n        *UnitTest::GetInstance());\n    EXPECT_EQ(0, on_start_counter);\n  }\n  // Destroying the list should not affect the listener now, too.\n  EXPECT_FALSE(is_destroyed);\n  delete listener;\n}\n\n// Sanity tests to ensure that the alternative, verbose spellings of\n// some of the macros work.  We don't test them thoroughly as that\n// would be quite involved.  Since their implementations are\n// straightforward, and they are rarely used, we'll just rely on the\n// users to tell us when they are broken.\nGTEST_TEST(AlternativeNameTest, Works) {  // GTEST_TEST is the same as TEST.\n  GTEST_SUCCEED() << \"OK\";  // GTEST_SUCCEED is the same as SUCCEED.\n\n  // GTEST_FAIL is the same as FAIL.\n  EXPECT_FATAL_FAILURE(GTEST_FAIL() << \"An expected failure\",\n                       \"An expected failure\");\n\n  // GTEST_ASSERT_XY is the same as ASSERT_XY.\n\n  GTEST_ASSERT_EQ(0, 0);\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_EQ(0, 1) << \"An expected failure\",\n                       \"An expected failure\");\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_EQ(1, 0) << \"An expected failure\",\n                       \"An expected failure\");\n\n  GTEST_ASSERT_NE(0, 1);\n  GTEST_ASSERT_NE(1, 0);\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_NE(0, 0) << \"An expected failure\",\n                       \"An expected failure\");\n\n  GTEST_ASSERT_LE(0, 0);\n  GTEST_ASSERT_LE(0, 1);\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_LE(1, 0) << \"An expected failure\",\n                       \"An expected failure\");\n\n  GTEST_ASSERT_LT(0, 1);\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_LT(0, 0) << \"An expected failure\",\n                       \"An expected failure\");\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_LT(1, 0) << \"An expected failure\",\n                       \"An expected failure\");\n\n  GTEST_ASSERT_GE(0, 0);\n  GTEST_ASSERT_GE(1, 0);\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_GE(0, 1) << \"An expected failure\",\n                       \"An expected failure\");\n\n  GTEST_ASSERT_GT(1, 0);\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_GT(0, 1) << \"An expected failure\",\n                       \"An expected failure\");\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_GT(1, 1) << \"An expected failure\",\n                       \"An expected failure\");\n}\n\n// Tests for internal utilities necessary for implementation of the universal\n// printing.\n// TODO(vladl@google.com): Find a better home for them.\n\nclass ConversionHelperBase {};\nclass ConversionHelperDerived : public ConversionHelperBase {};\n\n// Tests that IsAProtocolMessage<T>::value is a compile-time constant.\nTEST(IsAProtocolMessageTest, ValueIsCompileTimeConstant) {\n  GTEST_COMPILE_ASSERT_(IsAProtocolMessage<ProtocolMessage>::value,\n                        const_true);\n  GTEST_COMPILE_ASSERT_(!IsAProtocolMessage<int>::value, const_false);\n}\n\n// Tests that IsAProtocolMessage<T>::value is true when T is\n// proto2::Message or a sub-class of it.\nTEST(IsAProtocolMessageTest, ValueIsTrueWhenTypeIsAProtocolMessage) {\n  EXPECT_TRUE(IsAProtocolMessage< ::proto2::Message>::value);\n  EXPECT_TRUE(IsAProtocolMessage<ProtocolMessage>::value);\n}\n\n// Tests that IsAProtocolMessage<T>::value is false when T is neither\n// ProtocolMessage nor a sub-class of it.\nTEST(IsAProtocolMessageTest, ValueIsFalseWhenTypeIsNotAProtocolMessage) {\n  EXPECT_FALSE(IsAProtocolMessage<int>::value);\n  EXPECT_FALSE(IsAProtocolMessage<const ConversionHelperBase>::value);\n}\n\n// Tests that CompileAssertTypesEqual compiles when the type arguments are\n// equal.\nTEST(CompileAssertTypesEqual, CompilesWhenTypesAreEqual) {\n  CompileAssertTypesEqual<void, void>();\n  CompileAssertTypesEqual<int*, int*>();\n}\n\n// Tests that RemoveReference does not affect non-reference types.\nTEST(RemoveReferenceTest, DoesNotAffectNonReferenceType) {\n  CompileAssertTypesEqual<int, RemoveReference<int>::type>();\n  CompileAssertTypesEqual<const char, RemoveReference<const char>::type>();\n}\n\n// Tests that RemoveReference removes reference from reference types.\nTEST(RemoveReferenceTest, RemovesReference) {\n  CompileAssertTypesEqual<int, RemoveReference<int&>::type>();\n  CompileAssertTypesEqual<const char, RemoveReference<const char&>::type>();\n}\n\n// Tests GTEST_REMOVE_REFERENCE_.\n\ntemplate <typename T1, typename T2>\nvoid TestGTestRemoveReference() {\n  CompileAssertTypesEqual<T1, GTEST_REMOVE_REFERENCE_(T2)>();\n}\n\nTEST(RemoveReferenceTest, MacroVersion) {\n  TestGTestRemoveReference<int, int>();\n  TestGTestRemoveReference<const char, const char&>();\n}\n\n\n// Tests that RemoveConst does not affect non-const types.\nTEST(RemoveConstTest, DoesNotAffectNonConstType) {\n  CompileAssertTypesEqual<int, RemoveConst<int>::type>();\n  CompileAssertTypesEqual<char&, RemoveConst<char&>::type>();\n}\n\n// Tests that RemoveConst removes const from const types.\nTEST(RemoveConstTest, RemovesConst) {\n  CompileAssertTypesEqual<int, RemoveConst<const int>::type>();\n  CompileAssertTypesEqual<char[2], RemoveConst<const char[2]>::type>();\n  CompileAssertTypesEqual<char[2][3], RemoveConst<const char[2][3]>::type>();\n}\n\n// Tests GTEST_REMOVE_CONST_.\n\ntemplate <typename T1, typename T2>\nvoid TestGTestRemoveConst() {\n  CompileAssertTypesEqual<T1, GTEST_REMOVE_CONST_(T2)>();\n}\n\nTEST(RemoveConstTest, MacroVersion) {\n  TestGTestRemoveConst<int, int>();\n  TestGTestRemoveConst<double&, double&>();\n  TestGTestRemoveConst<char, const char>();\n}\n\n// Tests GTEST_REMOVE_REFERENCE_AND_CONST_.\n\ntemplate <typename T1, typename T2>\nvoid TestGTestRemoveReferenceAndConst() {\n  CompileAssertTypesEqual<T1, GTEST_REMOVE_REFERENCE_AND_CONST_(T2)>();\n}\n\nTEST(RemoveReferenceToConstTest, Works) {\n  TestGTestRemoveReferenceAndConst<int, int>();\n  TestGTestRemoveReferenceAndConst<double, double&>();\n  TestGTestRemoveReferenceAndConst<char, const char>();\n  TestGTestRemoveReferenceAndConst<char, const char&>();\n  TestGTestRemoveReferenceAndConst<const char*, const char*>();\n}\n\n// Tests that AddReference does not affect reference types.\nTEST(AddReferenceTest, DoesNotAffectReferenceType) {\n  CompileAssertTypesEqual<int&, AddReference<int&>::type>();\n  CompileAssertTypesEqual<const char&, AddReference<const char&>::type>();\n}\n\n// Tests that AddReference adds reference to non-reference types.\nTEST(AddReferenceTest, AddsReference) {\n  CompileAssertTypesEqual<int&, AddReference<int>::type>();\n  CompileAssertTypesEqual<const char&, AddReference<const char>::type>();\n}\n\n// Tests GTEST_ADD_REFERENCE_.\n\ntemplate <typename T1, typename T2>\nvoid TestGTestAddReference() {\n  CompileAssertTypesEqual<T1, GTEST_ADD_REFERENCE_(T2)>();\n}\n\nTEST(AddReferenceTest, MacroVersion) {\n  TestGTestAddReference<int&, int>();\n  TestGTestAddReference<const char&, const char&>();\n}\n\n// Tests GTEST_REFERENCE_TO_CONST_.\n\ntemplate <typename T1, typename T2>\nvoid TestGTestReferenceToConst() {\n  CompileAssertTypesEqual<T1, GTEST_REFERENCE_TO_CONST_(T2)>();\n}\n\nTEST(GTestReferenceToConstTest, Works) {\n  TestGTestReferenceToConst<const char&, char>();\n  TestGTestReferenceToConst<const int&, const int>();\n  TestGTestReferenceToConst<const double&, double>();\n  TestGTestReferenceToConst<const std::string&, const std::string&>();\n}\n\n// Tests that ImplicitlyConvertible<T1, T2>::value is a compile-time constant.\nTEST(ImplicitlyConvertibleTest, ValueIsCompileTimeConstant) {\n  GTEST_COMPILE_ASSERT_((ImplicitlyConvertible<int, int>::value), const_true);\n  GTEST_COMPILE_ASSERT_((!ImplicitlyConvertible<void*, int*>::value),\n                        const_false);\n}\n\n// Tests that ImplicitlyConvertible<T1, T2>::value is true when T1 can\n// be implicitly converted to T2.\nTEST(ImplicitlyConvertibleTest, ValueIsTrueWhenConvertible) {\n  EXPECT_TRUE((ImplicitlyConvertible<int, double>::value));\n  EXPECT_TRUE((ImplicitlyConvertible<double, int>::value));\n  EXPECT_TRUE((ImplicitlyConvertible<int*, void*>::value));\n  EXPECT_TRUE((ImplicitlyConvertible<int*, const int*>::value));\n  EXPECT_TRUE((ImplicitlyConvertible<ConversionHelperDerived&,\n                                     const ConversionHelperBase&>::value));\n  EXPECT_TRUE((ImplicitlyConvertible<const ConversionHelperBase,\n                                     ConversionHelperBase>::value));\n}\n\n// Tests that ImplicitlyConvertible<T1, T2>::value is false when T1\n// cannot be implicitly converted to T2.\nTEST(ImplicitlyConvertibleTest, ValueIsFalseWhenNotConvertible) {\n  EXPECT_FALSE((ImplicitlyConvertible<double, int*>::value));\n  EXPECT_FALSE((ImplicitlyConvertible<void*, int*>::value));\n  EXPECT_FALSE((ImplicitlyConvertible<const int*, int*>::value));\n  EXPECT_FALSE((ImplicitlyConvertible<ConversionHelperBase&,\n                                      ConversionHelperDerived&>::value));\n}\n\n// Tests IsContainerTest.\n\nclass NonContainer {};\n\nTEST(IsContainerTestTest, WorksForNonContainer) {\n  EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<int>(0)));\n  EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<char[5]>(0)));\n  EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<NonContainer>(0)));\n}\n\nTEST(IsContainerTestTest, WorksForContainer) {\n  EXPECT_EQ(sizeof(IsContainer),\n            sizeof(IsContainerTest<std::vector<bool> >(0)));\n  EXPECT_EQ(sizeof(IsContainer),\n            sizeof(IsContainerTest<std::map<int, double> >(0)));\n}\n\n// Tests ArrayEq().\n\nTEST(ArrayEqTest, WorksForDegeneratedArrays) {\n  EXPECT_TRUE(ArrayEq(5, 5L));\n  EXPECT_FALSE(ArrayEq('a', 0));\n}\n\nTEST(ArrayEqTest, WorksForOneDimensionalArrays) {\n  // Note that a and b are distinct but compatible types.\n  const int a[] = { 0, 1 };\n  long b[] = { 0, 1 };\n  EXPECT_TRUE(ArrayEq(a, b));\n  EXPECT_TRUE(ArrayEq(a, 2, b));\n\n  b[0] = 2;\n  EXPECT_FALSE(ArrayEq(a, b));\n  EXPECT_FALSE(ArrayEq(a, 1, b));\n}\n\nTEST(ArrayEqTest, WorksForTwoDimensionalArrays) {\n  const char a[][3] = { \"hi\", \"lo\" };\n  const char b[][3] = { \"hi\", \"lo\" };\n  const char c[][3] = { \"hi\", \"li\" };\n\n  EXPECT_TRUE(ArrayEq(a, b));\n  EXPECT_TRUE(ArrayEq(a, 2, b));\n\n  EXPECT_FALSE(ArrayEq(a, c));\n  EXPECT_FALSE(ArrayEq(a, 2, c));\n}\n\n// Tests ArrayAwareFind().\n\nTEST(ArrayAwareFindTest, WorksForOneDimensionalArray) {\n  const char a[] = \"hello\";\n  EXPECT_EQ(a + 4, ArrayAwareFind(a, a + 5, 'o'));\n  EXPECT_EQ(a + 5, ArrayAwareFind(a, a + 5, 'x'));\n}\n\nTEST(ArrayAwareFindTest, WorksForTwoDimensionalArray) {\n  int a[][2] = { { 0, 1 }, { 2, 3 }, { 4, 5 } };\n  const int b[2] = { 2, 3 };\n  EXPECT_EQ(a + 1, ArrayAwareFind(a, a + 3, b));\n\n  const int c[2] = { 6, 7 };\n  EXPECT_EQ(a + 3, ArrayAwareFind(a, a + 3, c));\n}\n\n// Tests CopyArray().\n\nTEST(CopyArrayTest, WorksForDegeneratedArrays) {\n  int n = 0;\n  CopyArray('a', &n);\n  EXPECT_EQ('a', n);\n}\n\nTEST(CopyArrayTest, WorksForOneDimensionalArrays) {\n  const char a[3] = \"hi\";\n  int b[3];\n#ifndef __BORLANDC__  // C++Builder cannot compile some array size deductions.\n  CopyArray(a, &b);\n  EXPECT_TRUE(ArrayEq(a, b));\n#endif\n\n  int c[3];\n  CopyArray(a, 3, c);\n  EXPECT_TRUE(ArrayEq(a, c));\n}\n\nTEST(CopyArrayTest, WorksForTwoDimensionalArrays) {\n  const int a[2][3] = { { 0, 1, 2 }, { 3, 4, 5 } };\n  int b[2][3];\n#ifndef __BORLANDC__  // C++Builder cannot compile some array size deductions.\n  CopyArray(a, &b);\n  EXPECT_TRUE(ArrayEq(a, b));\n#endif\n\n  int c[2][3];\n  CopyArray(a, 2, c);\n  EXPECT_TRUE(ArrayEq(a, c));\n}\n\n// Tests NativeArray.\n\nTEST(NativeArrayTest, ConstructorFromArrayWorks) {\n  const int a[3] = { 0, 1, 2 };\n  NativeArray<int> na(a, 3, RelationToSourceReference());\n  EXPECT_EQ(3U, na.size());\n  EXPECT_EQ(a, na.begin());\n}\n\nTEST(NativeArrayTest, CreatesAndDeletesCopyOfArrayWhenAskedTo) {\n  typedef int Array[2];\n  Array* a = new Array[1];\n  (*a)[0] = 0;\n  (*a)[1] = 1;\n  NativeArray<int> na(*a, 2, RelationToSourceCopy());\n  EXPECT_NE(*a, na.begin());\n  delete[] a;\n  EXPECT_EQ(0, na.begin()[0]);\n  EXPECT_EQ(1, na.begin()[1]);\n\n  // We rely on the heap checker to verify that na deletes the copy of\n  // array.\n}\n\nTEST(NativeArrayTest, TypeMembersAreCorrect) {\n  StaticAssertTypeEq<char, NativeArray<char>::value_type>();\n  StaticAssertTypeEq<int[2], NativeArray<int[2]>::value_type>();\n\n  StaticAssertTypeEq<const char*, NativeArray<char>::const_iterator>();\n  StaticAssertTypeEq<const bool(*)[2], NativeArray<bool[2]>::const_iterator>();\n}\n\nTEST(NativeArrayTest, MethodsWork) {\n  const int a[3] = { 0, 1, 2 };\n  NativeArray<int> na(a, 3, RelationToSourceCopy());\n  ASSERT_EQ(3U, na.size());\n  EXPECT_EQ(3, na.end() - na.begin());\n\n  NativeArray<int>::const_iterator it = na.begin();\n  EXPECT_EQ(0, *it);\n  ++it;\n  EXPECT_EQ(1, *it);\n  it++;\n  EXPECT_EQ(2, *it);\n  ++it;\n  EXPECT_EQ(na.end(), it);\n\n  EXPECT_TRUE(na == na);\n\n  NativeArray<int> na2(a, 3, RelationToSourceReference());\n  EXPECT_TRUE(na == na2);\n\n  const int b1[3] = { 0, 1, 1 };\n  const int b2[4] = { 0, 1, 2, 3 };\n  EXPECT_FALSE(na == NativeArray<int>(b1, 3, RelationToSourceReference()));\n  EXPECT_FALSE(na == NativeArray<int>(b2, 4, RelationToSourceCopy()));\n}\n\nTEST(NativeArrayTest, WorksForTwoDimensionalArray) {\n  const char a[2][3] = { \"hi\", \"lo\" };\n  NativeArray<char[3]> na(a, 2, RelationToSourceReference());\n  ASSERT_EQ(2U, na.size());\n  EXPECT_EQ(a, na.begin());\n}\n\n// Tests SkipPrefix().\n\nTEST(SkipPrefixTest, SkipsWhenPrefixMatches) {\n  const char* const str = \"hello\";\n\n  const char* p = str;\n  EXPECT_TRUE(SkipPrefix(\"\", &p));\n  EXPECT_EQ(str, p);\n\n  p = str;\n  EXPECT_TRUE(SkipPrefix(\"hell\", &p));\n  EXPECT_EQ(str + 4, p);\n}\n\nTEST(SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch) {\n  const char* const str = \"world\";\n\n  const char* p = str;\n  EXPECT_FALSE(SkipPrefix(\"W\", &p));\n  EXPECT_EQ(str, p);\n\n  p = str;\n  EXPECT_FALSE(SkipPrefix(\"world!\", &p));\n  EXPECT_EQ(str, p);\n}\n\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_xml_outfile1_test_.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: keith.ray@gmail.com (Keith Ray)\n//\n// gtest_xml_outfile1_test_ writes some xml via TestProperty used by\n// gtest_xml_outfiles_test.py\n\n#include \"gtest/gtest.h\"\n\nclass PropertyOne : public testing::Test {\n protected:\n  virtual void SetUp() {\n    RecordProperty(\"SetUpProp\", 1);\n  }\n  virtual void TearDown() {\n    RecordProperty(\"TearDownProp\", 1);\n  }\n};\n\nTEST_F(PropertyOne, TestSomeProperties) {\n  RecordProperty(\"TestSomeProperty\", 1);\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_xml_outfile2_test_.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: keith.ray@gmail.com (Keith Ray)\n//\n// gtest_xml_outfile2_test_ writes some xml via TestProperty used by\n// gtest_xml_outfiles_test.py\n\n#include \"gtest/gtest.h\"\n\nclass PropertyTwo : public testing::Test {\n protected:\n  virtual void SetUp() {\n    RecordProperty(\"SetUpProp\", 2);\n  }\n  virtual void TearDown() {\n    RecordProperty(\"TearDownProp\", 2);\n  }\n};\n\nTEST_F(PropertyTwo, TestSomeProperties) {\n  RecordProperty(\"TestSomeProperty\", 2);\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_xml_outfiles_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Unit test for the gtest_xml_output module.\"\"\"\n\n__author__ = \"keith.ray@gmail.com (Keith Ray)\"\n\nimport os\nfrom xml.dom import minidom, Node\n\nimport gtest_test_utils\nimport gtest_xml_test_utils\n\n\nGTEST_OUTPUT_SUBDIR = \"xml_outfiles\"\nGTEST_OUTPUT_1_TEST = \"gtest_xml_outfile1_test_\"\nGTEST_OUTPUT_2_TEST = \"gtest_xml_outfile2_test_\"\n\nEXPECTED_XML_1 = \"\"\"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\" timestamp=\"*\" name=\"AllTests\">\n  <testsuite name=\"PropertyOne\" tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"TestSomeProperties\" status=\"run\" time=\"*\" classname=\"PropertyOne\" SetUpProp=\"1\" TestSomeProperty=\"1\" TearDownProp=\"1\" />\n  </testsuite>\n</testsuites>\n\"\"\"\n\nEXPECTED_XML_2 = \"\"\"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\" timestamp=\"*\" name=\"AllTests\">\n  <testsuite name=\"PropertyTwo\" tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"TestSomeProperties\" status=\"run\" time=\"*\" classname=\"PropertyTwo\" SetUpProp=\"2\" TestSomeProperty=\"2\" TearDownProp=\"2\" />\n  </testsuite>\n</testsuites>\n\"\"\"\n\n\nclass GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase):\n  \"\"\"Unit test for Google Test's XML output functionality.\"\"\"\n\n  def setUp(self):\n    # We want the trailing '/' that the last \"\" provides in os.path.join, for\n    # telling Google Test to create an output directory instead of a single file\n    # for xml output.\n    self.output_dir_ = os.path.join(gtest_test_utils.GetTempDir(),\n                                    GTEST_OUTPUT_SUBDIR, \"\")\n    self.DeleteFilesAndDir()\n\n  def tearDown(self):\n    self.DeleteFilesAndDir()\n\n  def DeleteFilesAndDir(self):\n    try:\n      os.remove(os.path.join(self.output_dir_, GTEST_OUTPUT_1_TEST + \".xml\"))\n    except os.error:\n      pass\n    try:\n      os.remove(os.path.join(self.output_dir_, GTEST_OUTPUT_2_TEST + \".xml\"))\n    except os.error:\n      pass\n    try:\n      os.rmdir(self.output_dir_)\n    except os.error:\n      pass\n\n  def testOutfile1(self):\n    self._TestOutFile(GTEST_OUTPUT_1_TEST, EXPECTED_XML_1)\n\n  def testOutfile2(self):\n    self._TestOutFile(GTEST_OUTPUT_2_TEST, EXPECTED_XML_2)\n\n  def _TestOutFile(self, test_name, expected_xml):\n    gtest_prog_path = gtest_test_utils.GetTestExecutablePath(test_name)\n    command = [gtest_prog_path, \"--gtest_output=xml:%s\" % self.output_dir_]\n    p = gtest_test_utils.Subprocess(command,\n                                    working_dir=gtest_test_utils.GetTempDir())\n    self.assert_(p.exited)\n    self.assertEquals(0, p.exit_code)\n\n    # TODO(wan@google.com): libtool causes the built test binary to be\n    #   named lt-gtest_xml_outfiles_test_ instead of\n    #   gtest_xml_outfiles_test_.  To account for this possibillity, we\n    #   allow both names in the following code.  We should remove this\n    #   hack when Chandler Carruth's libtool replacement tool is ready.\n    output_file_name1 = test_name + \".xml\"\n    output_file1 = os.path.join(self.output_dir_, output_file_name1)\n    output_file_name2 = 'lt-' + output_file_name1\n    output_file2 = os.path.join(self.output_dir_, output_file_name2)\n    self.assert_(os.path.isfile(output_file1) or os.path.isfile(output_file2),\n                 output_file1)\n\n    expected = minidom.parseString(expected_xml)\n    if os.path.isfile(output_file1):\n      actual = minidom.parse(output_file1)\n    else:\n      actual = minidom.parse(output_file2)\n    self.NormalizeXml(actual.documentElement)\n    self.AssertEquivalentNodes(expected.documentElement,\n                               actual.documentElement)\n    expected.unlink()\n    actual.unlink()\n\n\nif __name__ == \"__main__\":\n  os.environ[\"GTEST_STACK_TRACE_DEPTH\"] = \"0\"\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_xml_output_unittest.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2006, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Unit test for the gtest_xml_output module\"\"\"\n\n__author__ = 'eefacm@gmail.com (Sean Mcafee)'\n\nimport datetime\nimport errno\nimport os\nimport re\nimport sys\nfrom xml.dom import minidom, Node\n\nimport gtest_test_utils\nimport gtest_xml_test_utils\n\n\nGTEST_FILTER_FLAG = '--gtest_filter'\nGTEST_LIST_TESTS_FLAG = '--gtest_list_tests'\nGTEST_OUTPUT_FLAG         = \"--gtest_output\"\nGTEST_DEFAULT_OUTPUT_FILE = \"test_detail.xml\"\nGTEST_PROGRAM_NAME = \"gtest_xml_output_unittest_\"\n\nSUPPORTS_STACK_TRACES = False\n\nif SUPPORTS_STACK_TRACES:\n  STACK_TRACE_TEMPLATE = '\\nStack trace:\\n*'\nelse:\n  STACK_TRACE_TEMPLATE = ''\n\nEXPECTED_NON_EMPTY_XML = \"\"\"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites tests=\"23\" failures=\"4\" disabled=\"2\" errors=\"0\" time=\"*\" timestamp=\"*\" name=\"AllTests\" ad_hoc_property=\"42\">\n  <testsuite name=\"SuccessfulTest\" tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"Succeeds\" status=\"run\" time=\"*\" classname=\"SuccessfulTest\"/>\n  </testsuite>\n  <testsuite name=\"FailedTest\" tests=\"1\" failures=\"1\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"Fails\" status=\"run\" time=\"*\" classname=\"FailedTest\">\n      <failure message=\"gtest_xml_output_unittest_.cc:*&#x0A;      Expected: 1&#x0A;To be equal to: 2\" type=\"\"><![CDATA[gtest_xml_output_unittest_.cc:*\n      Expected: 1\nTo be equal to: 2%(stack)s]]></failure>\n    </testcase>\n  </testsuite>\n  <testsuite name=\"MixedResultTest\" tests=\"3\" failures=\"1\" disabled=\"1\" errors=\"0\" time=\"*\">\n    <testcase name=\"Succeeds\" status=\"run\" time=\"*\" classname=\"MixedResultTest\"/>\n    <testcase name=\"Fails\" status=\"run\" time=\"*\" classname=\"MixedResultTest\">\n      <failure message=\"gtest_xml_output_unittest_.cc:*&#x0A;      Expected: 1&#x0A;To be equal to: 2\" type=\"\"><![CDATA[gtest_xml_output_unittest_.cc:*\n      Expected: 1\nTo be equal to: 2%(stack)s]]></failure>\n      <failure message=\"gtest_xml_output_unittest_.cc:*&#x0A;      Expected: 2&#x0A;To be equal to: 3\" type=\"\"><![CDATA[gtest_xml_output_unittest_.cc:*\n      Expected: 2\nTo be equal to: 3%(stack)s]]></failure>\n    </testcase>\n    <testcase name=\"DISABLED_test\" status=\"notrun\" time=\"*\" classname=\"MixedResultTest\"/>\n  </testsuite>\n  <testsuite name=\"XmlQuotingTest\" tests=\"1\" failures=\"1\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"OutputsCData\" status=\"run\" time=\"*\" classname=\"XmlQuotingTest\">\n      <failure message=\"gtest_xml_output_unittest_.cc:*&#x0A;Failed&#x0A;XML output: &lt;?xml encoding=&quot;utf-8&quot;&gt;&lt;top&gt;&lt;![CDATA[cdata text]]&gt;&lt;/top&gt;\" type=\"\"><![CDATA[gtest_xml_output_unittest_.cc:*\nFailed\nXML output: <?xml encoding=\"utf-8\"><top><![CDATA[cdata text]]>]]&gt;<![CDATA[</top>%(stack)s]]></failure>\n    </testcase>\n  </testsuite>\n  <testsuite name=\"InvalidCharactersTest\" tests=\"1\" failures=\"1\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"InvalidCharactersInMessage\" status=\"run\" time=\"*\" classname=\"InvalidCharactersTest\">\n      <failure message=\"gtest_xml_output_unittest_.cc:*&#x0A;Failed&#x0A;Invalid characters in brackets []\" type=\"\"><![CDATA[gtest_xml_output_unittest_.cc:*\nFailed\nInvalid characters in brackets []%(stack)s]]></failure>\n    </testcase>\n  </testsuite>\n  <testsuite name=\"DisabledTest\" tests=\"1\" failures=\"0\" disabled=\"1\" errors=\"0\" time=\"*\">\n    <testcase name=\"DISABLED_test_not_run\" status=\"notrun\" time=\"*\" classname=\"DisabledTest\"/>\n  </testsuite>\n  <testsuite name=\"PropertyRecordingTest\" tests=\"4\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\" SetUpTestCase=\"yes\" TearDownTestCase=\"aye\">\n    <testcase name=\"OneProperty\" status=\"run\" time=\"*\" classname=\"PropertyRecordingTest\" key_1=\"1\"/>\n    <testcase name=\"IntValuedProperty\" status=\"run\" time=\"*\" classname=\"PropertyRecordingTest\" key_int=\"1\"/>\n    <testcase name=\"ThreeProperties\" status=\"run\" time=\"*\" classname=\"PropertyRecordingTest\" key_1=\"1\" key_2=\"2\" key_3=\"3\"/>\n    <testcase name=\"TwoValuesForOneKeyUsesLastValue\" status=\"run\" time=\"*\" classname=\"PropertyRecordingTest\" key_1=\"2\"/>\n  </testsuite>\n  <testsuite name=\"NoFixtureTest\" tests=\"3\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n     <testcase name=\"RecordProperty\" status=\"run\" time=\"*\" classname=\"NoFixtureTest\" key=\"1\"/>\n     <testcase name=\"ExternalUtilityThatCallsRecordIntValuedProperty\" status=\"run\" time=\"*\" classname=\"NoFixtureTest\" key_for_utility_int=\"1\"/>\n     <testcase name=\"ExternalUtilityThatCallsRecordStringValuedProperty\" status=\"run\" time=\"*\" classname=\"NoFixtureTest\" key_for_utility_string=\"1\"/>\n  </testsuite>\n  <testsuite name=\"Single/ValueParamTest\" tests=\"4\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"HasValueParamAttribute/0\" value_param=\"33\" status=\"run\" time=\"*\" classname=\"Single/ValueParamTest\" />\n    <testcase name=\"HasValueParamAttribute/1\" value_param=\"42\" status=\"run\" time=\"*\" classname=\"Single/ValueParamTest\" />\n    <testcase name=\"AnotherTestThatHasValueParamAttribute/0\" value_param=\"33\" status=\"run\" time=\"*\" classname=\"Single/ValueParamTest\" />\n    <testcase name=\"AnotherTestThatHasValueParamAttribute/1\" value_param=\"42\" status=\"run\" time=\"*\" classname=\"Single/ValueParamTest\" />\n  </testsuite>\n  <testsuite name=\"TypedTest/0\" tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"HasTypeParamAttribute\" type_param=\"*\" status=\"run\" time=\"*\" classname=\"TypedTest/0\" />\n  </testsuite>\n  <testsuite name=\"TypedTest/1\" tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"HasTypeParamAttribute\" type_param=\"*\" status=\"run\" time=\"*\" classname=\"TypedTest/1\" />\n  </testsuite>\n  <testsuite name=\"Single/TypeParameterizedTestCase/0\" tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"HasTypeParamAttribute\" type_param=\"*\" status=\"run\" time=\"*\" classname=\"Single/TypeParameterizedTestCase/0\" />\n  </testsuite>\n  <testsuite name=\"Single/TypeParameterizedTestCase/1\" tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"HasTypeParamAttribute\" type_param=\"*\" status=\"run\" time=\"*\" classname=\"Single/TypeParameterizedTestCase/1\" />\n  </testsuite>\n</testsuites>\"\"\" % {'stack': STACK_TRACE_TEMPLATE}\n\nEXPECTED_FILTERED_TEST_XML = \"\"\"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\"\n            timestamp=\"*\" name=\"AllTests\" ad_hoc_property=\"42\">\n  <testsuite name=\"SuccessfulTest\" tests=\"1\" failures=\"0\" disabled=\"0\"\n             errors=\"0\" time=\"*\">\n    <testcase name=\"Succeeds\" status=\"run\" time=\"*\" classname=\"SuccessfulTest\"/>\n  </testsuite>\n</testsuites>\"\"\"\n\nEXPECTED_EMPTY_XML = \"\"\"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites tests=\"0\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\"\n            timestamp=\"*\" name=\"AllTests\">\n</testsuites>\"\"\"\n\nGTEST_PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath(GTEST_PROGRAM_NAME)\n\nSUPPORTS_TYPED_TESTS = 'TypedTest' in gtest_test_utils.Subprocess(\n    [GTEST_PROGRAM_PATH, GTEST_LIST_TESTS_FLAG], capture_stderr=False).output\n\n\nclass GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):\n  \"\"\"\n  Unit test for Google Test's XML output functionality.\n  \"\"\"\n\n  # This test currently breaks on platforms that do not support typed and\n  # type-parameterized tests, so we don't run it under them.\n  if SUPPORTS_TYPED_TESTS:\n    def testNonEmptyXmlOutput(self):\n      \"\"\"\n      Runs a test program that generates a non-empty XML output, and\n      tests that the XML output is expected.\n      \"\"\"\n      self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_NON_EMPTY_XML, 1)\n\n  def testEmptyXmlOutput(self):\n    \"\"\"Verifies XML output for a Google Test binary without actual tests.\n\n    Runs a test program that generates an empty XML output, and\n    tests that the XML output is expected.\n    \"\"\"\n\n    self._TestXmlOutput('gtest_no_test_unittest', EXPECTED_EMPTY_XML, 0)\n\n  def testTimestampValue(self):\n    \"\"\"Checks whether the timestamp attribute in the XML output is valid.\n\n    Runs a test program that generates an empty XML output, and checks if\n    the timestamp attribute in the testsuites tag is valid.\n    \"\"\"\n    actual = self._GetXmlOutput('gtest_no_test_unittest', [], 0)\n    date_time_str = actual.documentElement.getAttributeNode('timestamp').value\n    # datetime.strptime() is only available in Python 2.5+ so we have to\n    # parse the expected datetime manually.\n    match = re.match(r'(\\d+)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)', date_time_str)\n    self.assertTrue(\n        re.match,\n        'XML datettime string %s has incorrect format' % date_time_str)\n    date_time_from_xml = datetime.datetime(\n        year=int(match.group(1)), month=int(match.group(2)),\n        day=int(match.group(3)), hour=int(match.group(4)),\n        minute=int(match.group(5)), second=int(match.group(6)))\n\n    time_delta = abs(datetime.datetime.now() - date_time_from_xml)\n    # timestamp value should be near the current local time\n    self.assertTrue(time_delta < datetime.timedelta(seconds=600),\n                    'time_delta is %s' % time_delta)\n    actual.unlink()\n\n  def testDefaultOutputFile(self):\n    \"\"\"\n    Confirms that Google Test produces an XML output file with the expected\n    default name if no name is explicitly specified.\n    \"\"\"\n    output_file = os.path.join(gtest_test_utils.GetTempDir(),\n                               GTEST_DEFAULT_OUTPUT_FILE)\n    gtest_prog_path = gtest_test_utils.GetTestExecutablePath(\n        'gtest_no_test_unittest')\n    try:\n      os.remove(output_file)\n    except OSError:\n      e = sys.exc_info()[1]\n      if e.errno != errno.ENOENT:\n        raise\n\n    p = gtest_test_utils.Subprocess(\n        [gtest_prog_path, '%s=xml' % GTEST_OUTPUT_FLAG],\n        working_dir=gtest_test_utils.GetTempDir())\n    self.assert_(p.exited)\n    self.assertEquals(0, p.exit_code)\n    self.assert_(os.path.isfile(output_file))\n\n  def testSuppressedXmlOutput(self):\n    \"\"\"\n    Tests that no XML file is generated if the default XML listener is\n    shut down before RUN_ALL_TESTS is invoked.\n    \"\"\"\n\n    xml_path = os.path.join(gtest_test_utils.GetTempDir(),\n                            GTEST_PROGRAM_NAME + 'out.xml')\n    if os.path.isfile(xml_path):\n      os.remove(xml_path)\n\n    command = [GTEST_PROGRAM_PATH,\n               '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path),\n               '--shut_down_xml']\n    p = gtest_test_utils.Subprocess(command)\n    if p.terminated_by_signal:\n      # p.signal is avalable only if p.terminated_by_signal is True.\n      self.assertFalse(\n          p.terminated_by_signal,\n          '%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal))\n    else:\n      self.assert_(p.exited)\n      self.assertEquals(1, p.exit_code,\n                        \"'%s' exited with code %s, which doesn't match \"\n                        'the expected exit code %s.'\n                        % (command, p.exit_code, 1))\n\n    self.assert_(not os.path.isfile(xml_path))\n\n  def testFilteredTestXmlOutput(self):\n    \"\"\"Verifies XML output when a filter is applied.\n\n    Runs a test program that executes only some tests and verifies that\n    non-selected tests do not show up in the XML output.\n    \"\"\"\n\n    self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_FILTERED_TEST_XML, 0,\n                        extra_args=['%s=SuccessfulTest.*' % GTEST_FILTER_FLAG])\n\n  def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code):\n    \"\"\"\n    Returns the xml output generated by running the program gtest_prog_name.\n    Furthermore, the program's exit code must be expected_exit_code.\n    \"\"\"\n    xml_path = os.path.join(gtest_test_utils.GetTempDir(),\n                            gtest_prog_name + 'out.xml')\n    gtest_prog_path = gtest_test_utils.GetTestExecutablePath(gtest_prog_name)\n\n    command = ([gtest_prog_path, '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path)] +\n               extra_args)\n    p = gtest_test_utils.Subprocess(command)\n    if p.terminated_by_signal:\n      self.assert_(False,\n                   '%s was killed by signal %d' % (gtest_prog_name, p.signal))\n    else:\n      self.assert_(p.exited)\n      self.assertEquals(expected_exit_code, p.exit_code,\n                        \"'%s' exited with code %s, which doesn't match \"\n                        'the expected exit code %s.'\n                        % (command, p.exit_code, expected_exit_code))\n    actual = minidom.parse(xml_path)\n    return actual\n\n  def _TestXmlOutput(self, gtest_prog_name, expected_xml,\n                     expected_exit_code, extra_args=None):\n    \"\"\"\n    Asserts that the XML document generated by running the program\n    gtest_prog_name matches expected_xml, a string containing another\n    XML document.  Furthermore, the program's exit code must be\n    expected_exit_code.\n    \"\"\"\n\n    actual = self._GetXmlOutput(gtest_prog_name, extra_args or [],\n                                expected_exit_code)\n    expected = minidom.parseString(expected_xml)\n    self.NormalizeXml(actual.documentElement)\n    self.AssertEquivalentNodes(expected.documentElement,\n                               actual.documentElement)\n    expected.unlink()\n    actual.unlink()\n\n\nif __name__ == '__main__':\n  os.environ['GTEST_STACK_TRACE_DEPTH'] = '1'\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_xml_output_unittest_.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: eefacm@gmail.com (Sean Mcafee)\n\n// Unit test for Google Test XML output.\n//\n// A user can specify XML output in a Google Test program to run via\n// either the GTEST_OUTPUT environment variable or the --gtest_output\n// flag.  This is used for testing such functionality.\n//\n// This program will be invoked from a Python unit test.  Don't run it\n// directly.\n\n#include \"gtest/gtest.h\"\n\nusing ::testing::InitGoogleTest;\nusing ::testing::TestEventListeners;\nusing ::testing::TestWithParam;\nusing ::testing::UnitTest;\nusing ::testing::Test;\nusing ::testing::Values;\n\nclass SuccessfulTest : public Test {\n};\n\nTEST_F(SuccessfulTest, Succeeds) {\n  SUCCEED() << \"This is a success.\";\n  ASSERT_EQ(1, 1);\n}\n\nclass FailedTest : public Test {\n};\n\nTEST_F(FailedTest, Fails) {\n  ASSERT_EQ(1, 2);\n}\n\nclass DisabledTest : public Test {\n};\n\nTEST_F(DisabledTest, DISABLED_test_not_run) {\n  FAIL() << \"Unexpected failure: Disabled test should not be run\";\n}\n\nTEST(MixedResultTest, Succeeds) {\n  EXPECT_EQ(1, 1);\n  ASSERT_EQ(1, 1);\n}\n\nTEST(MixedResultTest, Fails) {\n  EXPECT_EQ(1, 2);\n  ASSERT_EQ(2, 3);\n}\n\nTEST(MixedResultTest, DISABLED_test) {\n  FAIL() << \"Unexpected failure: Disabled test should not be run\";\n}\n\nTEST(XmlQuotingTest, OutputsCData) {\n  FAIL() << \"XML output: \"\n            \"<?xml encoding=\\\"utf-8\\\"><top><![CDATA[cdata text]]></top>\";\n}\n\n// Helps to test that invalid characters produced by test code do not make\n// it into the XML file.\nTEST(InvalidCharactersTest, InvalidCharactersInMessage) {\n  FAIL() << \"Invalid characters in brackets [\\x1\\x2]\";\n}\n\nclass PropertyRecordingTest : public Test {\n public:\n  static void SetUpTestCase() { RecordProperty(\"SetUpTestCase\", \"yes\"); }\n  static void TearDownTestCase() { RecordProperty(\"TearDownTestCase\", \"aye\"); }\n};\n\nTEST_F(PropertyRecordingTest, OneProperty) {\n  RecordProperty(\"key_1\", \"1\");\n}\n\nTEST_F(PropertyRecordingTest, IntValuedProperty) {\n  RecordProperty(\"key_int\", 1);\n}\n\nTEST_F(PropertyRecordingTest, ThreeProperties) {\n  RecordProperty(\"key_1\", \"1\");\n  RecordProperty(\"key_2\", \"2\");\n  RecordProperty(\"key_3\", \"3\");\n}\n\nTEST_F(PropertyRecordingTest, TwoValuesForOneKeyUsesLastValue) {\n  RecordProperty(\"key_1\", \"1\");\n  RecordProperty(\"key_1\", \"2\");\n}\n\nTEST(NoFixtureTest, RecordProperty) {\n  RecordProperty(\"key\", \"1\");\n}\n\nvoid ExternalUtilityThatCallsRecordProperty(const std::string& key, int value) {\n  testing::Test::RecordProperty(key, value);\n}\n\nvoid ExternalUtilityThatCallsRecordProperty(const std::string& key,\n                                            const std::string& value) {\n  testing::Test::RecordProperty(key, value);\n}\n\nTEST(NoFixtureTest, ExternalUtilityThatCallsRecordIntValuedProperty) {\n  ExternalUtilityThatCallsRecordProperty(\"key_for_utility_int\", 1);\n}\n\nTEST(NoFixtureTest, ExternalUtilityThatCallsRecordStringValuedProperty) {\n  ExternalUtilityThatCallsRecordProperty(\"key_for_utility_string\", \"1\");\n}\n\n// Verifies that the test parameter value is output in the 'value_param'\n// XML attribute for value-parameterized tests.\nclass ValueParamTest : public TestWithParam<int> {};\nTEST_P(ValueParamTest, HasValueParamAttribute) {}\nTEST_P(ValueParamTest, AnotherTestThatHasValueParamAttribute) {}\nINSTANTIATE_TEST_CASE_P(Single, ValueParamTest, Values(33, 42));\n\n#if GTEST_HAS_TYPED_TEST\n// Verifies that the type parameter name is output in the 'type_param'\n// XML attribute for typed tests.\ntemplate <typename T> class TypedTest : public Test {};\ntypedef testing::Types<int, long> TypedTestTypes;\nTYPED_TEST_CASE(TypedTest, TypedTestTypes);\nTYPED_TEST(TypedTest, HasTypeParamAttribute) {}\n#endif\n\n#if GTEST_HAS_TYPED_TEST_P\n// Verifies that the type parameter name is output in the 'type_param'\n// XML attribute for type-parameterized tests.\ntemplate <typename T> class TypeParameterizedTestCase : public Test {};\nTYPED_TEST_CASE_P(TypeParameterizedTestCase);\nTYPED_TEST_P(TypeParameterizedTestCase, HasTypeParamAttribute) {}\nREGISTER_TYPED_TEST_CASE_P(TypeParameterizedTestCase, HasTypeParamAttribute);\ntypedef testing::Types<int, long> TypeParameterizedTestCaseTypes;\nINSTANTIATE_TYPED_TEST_CASE_P(Single,\n                              TypeParameterizedTestCase,\n                              TypeParameterizedTestCaseTypes);\n#endif\n\nint main(int argc, char** argv) {\n  InitGoogleTest(&argc, argv);\n\n  if (argc > 1 && strcmp(argv[1], \"--shut_down_xml\") == 0) {\n    TestEventListeners& listeners = UnitTest::GetInstance()->listeners();\n    delete listeners.Release(listeners.default_xml_generator());\n  }\n  testing::Test::RecordProperty(\"ad_hoc_property\", \"42\");\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "utils/googletest/googletest/test/gtest_xml_test_utils.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2006, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Unit test utilities for gtest_xml_output\"\"\"\n\n__author__ = 'eefacm@gmail.com (Sean Mcafee)'\n\nimport re\nfrom xml.dom import minidom, Node\n\nimport gtest_test_utils\n\n\nGTEST_OUTPUT_FLAG         = '--gtest_output'\nGTEST_DEFAULT_OUTPUT_FILE = 'test_detail.xml'\n\nclass GTestXMLTestCase(gtest_test_utils.TestCase):\n  \"\"\"\n  Base class for tests of Google Test's XML output functionality.\n  \"\"\"\n\n\n  def AssertEquivalentNodes(self, expected_node, actual_node):\n    \"\"\"\n    Asserts that actual_node (a DOM node object) is equivalent to\n    expected_node (another DOM node object), in that either both of\n    them are CDATA nodes and have the same value, or both are DOM\n    elements and actual_node meets all of the following conditions:\n\n    *  It has the same tag name as expected_node.\n    *  It has the same set of attributes as expected_node, each with\n       the same value as the corresponding attribute of expected_node.\n       Exceptions are any attribute named \"time\", which needs only be\n       convertible to a floating-point number and any attribute named\n       \"type_param\" which only has to be non-empty.\n    *  It has an equivalent set of child nodes (including elements and\n       CDATA sections) as expected_node.  Note that we ignore the\n       order of the children as they are not guaranteed to be in any\n       particular order.\n    \"\"\"\n\n    if expected_node.nodeType == Node.CDATA_SECTION_NODE:\n      self.assertEquals(Node.CDATA_SECTION_NODE, actual_node.nodeType)\n      self.assertEquals(expected_node.nodeValue, actual_node.nodeValue)\n      return\n\n    self.assertEquals(Node.ELEMENT_NODE, actual_node.nodeType)\n    self.assertEquals(Node.ELEMENT_NODE, expected_node.nodeType)\n    self.assertEquals(expected_node.tagName, actual_node.tagName)\n\n    expected_attributes = expected_node.attributes\n    actual_attributes   = actual_node  .attributes\n    self.assertEquals(\n        expected_attributes.length, actual_attributes.length,\n        'attribute numbers differ in element %s:\\nExpected: %r\\nActual: %r' % (\n            actual_node.tagName, expected_attributes.keys(),\n            actual_attributes.keys()))\n    for i in range(expected_attributes.length):\n      expected_attr = expected_attributes.item(i)\n      actual_attr   = actual_attributes.get(expected_attr.name)\n      self.assert_(\n          actual_attr is not None,\n          'expected attribute %s not found in element %s' %\n          (expected_attr.name, actual_node.tagName))\n      self.assertEquals(\n          expected_attr.value, actual_attr.value,\n          ' values of attribute %s in element %s differ: %s vs %s' %\n          (expected_attr.name, actual_node.tagName,\n           expected_attr.value, actual_attr.value))\n\n    expected_children = self._GetChildren(expected_node)\n    actual_children = self._GetChildren(actual_node)\n    self.assertEquals(\n        len(expected_children), len(actual_children),\n        'number of child elements differ in element ' + actual_node.tagName)\n    for child_id, child in expected_children.items():\n      self.assert_(child_id in actual_children,\n                   '<%s> is not in <%s> (in element %s)' %\n                   (child_id, actual_children, actual_node.tagName))\n      self.AssertEquivalentNodes(child, actual_children[child_id])\n\n  identifying_attribute = {\n    'testsuites': 'name',\n    'testsuite': 'name',\n    'testcase':  'name',\n    'failure':   'message',\n    }\n\n  def _GetChildren(self, element):\n    \"\"\"\n    Fetches all of the child nodes of element, a DOM Element object.\n    Returns them as the values of a dictionary keyed by the IDs of the\n    children.  For <testsuites>, <testsuite> and <testcase> elements, the ID\n    is the value of their \"name\" attribute; for <failure> elements, it is\n    the value of the \"message\" attribute; CDATA sections and non-whitespace\n    text nodes are concatenated into a single CDATA section with ID\n    \"detail\".  An exception is raised if any element other than the above\n    four is encountered, if two child elements with the same identifying\n    attributes are encountered, or if any other type of node is encountered.\n    \"\"\"\n\n    children = {}\n    for child in element.childNodes:\n      if child.nodeType == Node.ELEMENT_NODE:\n        self.assert_(child.tagName in self.identifying_attribute,\n                     'Encountered unknown element <%s>' % child.tagName)\n        childID = child.getAttribute(self.identifying_attribute[child.tagName])\n        self.assert_(childID not in children)\n        children[childID] = child\n      elif child.nodeType in [Node.TEXT_NODE, Node.CDATA_SECTION_NODE]:\n        if 'detail' not in children:\n          if (child.nodeType == Node.CDATA_SECTION_NODE or\n              not child.nodeValue.isspace()):\n            children['detail'] = child.ownerDocument.createCDATASection(\n                child.nodeValue)\n        else:\n          children['detail'].nodeValue += child.nodeValue\n      else:\n        self.fail('Encountered unexpected node type %d' % child.nodeType)\n    return children\n\n  def NormalizeXml(self, element):\n    \"\"\"\n    Normalizes Google Test's XML output to eliminate references to transient\n    information that may change from run to run.\n\n    *  The \"time\" attribute of <testsuites>, <testsuite> and <testcase>\n       elements is replaced with a single asterisk, if it contains\n       only digit characters.\n    *  The \"timestamp\" attribute of <testsuites> elements is replaced with a\n       single asterisk, if it contains a valid ISO8601 datetime value.\n    *  The \"type_param\" attribute of <testcase> elements is replaced with a\n       single asterisk (if it sn non-empty) as it is the type name returned\n       by the compiler and is platform dependent.\n    *  The line info reported in the first line of the \"message\"\n       attribute and CDATA section of <failure> elements is replaced with the\n       file's basename and a single asterisk for the line number.\n    *  The directory names in file paths are removed.\n    *  The stack traces are removed.\n    \"\"\"\n\n    if element.tagName == 'testsuites':\n      timestamp = element.getAttributeNode('timestamp')\n      timestamp.value = re.sub(r'^\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d$',\n                               '*', timestamp.value)\n    if element.tagName in ('testsuites', 'testsuite', 'testcase'):\n      time = element.getAttributeNode('time')\n      time.value = re.sub(r'^\\d+(\\.\\d+)?$', '*', time.value)\n      type_param = element.getAttributeNode('type_param')\n      if type_param and type_param.value:\n        type_param.value = '*'\n    elif element.tagName == 'failure':\n      source_line_pat = r'^.*[/\\\\](.*:)\\d+\\n'\n      # Replaces the source line information with a normalized form.\n      message = element.getAttributeNode('message')\n      message.value = re.sub(source_line_pat, '\\\\1*\\n', message.value)\n      for child in element.childNodes:\n        if child.nodeType == Node.CDATA_SECTION_NODE:\n          # Replaces the source line information with a normalized form.\n          cdata = re.sub(source_line_pat, '\\\\1*\\n', child.nodeValue)\n          # Removes the actual stack trace.\n          child.nodeValue = re.sub(r'\\nStack trace:\\n(.|\\n)*',\n                                   '', cdata)\n    for child in element.childNodes:\n      if child.nodeType == Node.ELEMENT_NODE:\n        self.NormalizeXml(child)\n"
  },
  {
    "path": "utils/googletest/googletest/test/production.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// This is part of the unit test for include/gtest/gtest_prod.h.\n\n#include \"production.h\"\n\nPrivateCode::PrivateCode() : x_(0) {}\n"
  },
  {
    "path": "utils/googletest/googletest/test/production.h",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// This is part of the unit test for include/gtest/gtest_prod.h.\n\n#ifndef GTEST_TEST_PRODUCTION_H_\n#define GTEST_TEST_PRODUCTION_H_\n\n#include \"gtest/gtest_prod.h\"\n\nclass PrivateCode {\n public:\n  // Declares a friend test that does not use a fixture.\n  FRIEND_TEST(PrivateCodeTest, CanAccessPrivateMembers);\n\n  // Declares a friend test that uses a fixture.\n  FRIEND_TEST(PrivateCodeFixtureTest, CanAccessPrivateMembers);\n\n  PrivateCode();\n\n  int x() const { return x_; }\n private:\n  void set_x(int an_x) { x_ = an_x; }\n  int x_;\n};\n\n#endif  // GTEST_TEST_PRODUCTION_H_\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/Config/DebugProject.xcconfig",
    "content": "//\n//  DebugProject.xcconfig\n//\n//  These are Debug Configuration project settings for the gtest framework and\n//  examples. It is set in the \"Based On:\" dropdown in the \"Project\" info\n//  dialog.\n//  This file is based on the Xcode Configuration files in:\n//  http://code.google.com/p/google-toolbox-for-mac/\n// \n\n#include \"General.xcconfig\"\n\n// No optimization\nGCC_OPTIMIZATION_LEVEL = 0\n\n// Deployment postprocessing is what triggers Xcode to strip, turn it off\nDEPLOYMENT_POSTPROCESSING = NO\n\n// Dead code stripping off\nDEAD_CODE_STRIPPING = NO\n\n// Debug symbols should be on obviously\nGCC_GENERATE_DEBUGGING_SYMBOLS = YES\n\n// Define the DEBUG macro in all debug builds\nOTHER_CFLAGS = $(OTHER_CFLAGS) -DDEBUG=1\n\n// These are turned off to avoid STL incompatibilities with client code\n// // Turns on special C++ STL checks to \"encourage\" good STL use\n// GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) _GLIBCXX_DEBUG_PEDANTIC _GLIBCXX_DEBUG _GLIBCPP_CONCEPT_CHECKS\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/Config/FrameworkTarget.xcconfig",
    "content": "//\n//  FrameworkTarget.xcconfig\n//\n//  These are Framework target settings for the gtest framework and examples. It\n//  is set in the \"Based On:\" dropdown in the \"Target\" info dialog.\n//  This file is based on the Xcode Configuration files in:\n//  http://code.google.com/p/google-toolbox-for-mac/\n// \n\n// Dynamic libs need to be position independent\nGCC_DYNAMIC_NO_PIC = NO\n\n// Dynamic libs should not have their external symbols stripped.\nSTRIP_STYLE = non-global\n\n// Let the user install by specifying the $DSTROOT with xcodebuild\nSKIP_INSTALL = NO\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/Config/General.xcconfig",
    "content": "//\n//  General.xcconfig\n//\n//  These are General configuration settings for the gtest framework and\n//  examples.\n//  This file is based on the Xcode Configuration files in:\n//  http://code.google.com/p/google-toolbox-for-mac/\n// \n\n// Build for PPC and Intel, 32- and 64-bit\nARCHS = i386 x86_64 ppc ppc64\n\n// Zerolink prevents link warnings so turn it off\nZERO_LINK = NO\n\n// Prebinding considered unhelpful in 10.3 and later\nPREBINDING = NO\n\n// Strictest warning policy\nWARNING_CFLAGS = -Wall -Werror -Wendif-labels -Wnewline-eof -Wno-sign-compare -Wshadow\n\n// Work around Xcode bugs by using external strip. See:\n// http://lists.apple.com/archives/Xcode-users/2006/Feb/msg00050.html\nSEPARATE_STRIP = YES\n\n// Force C99 dialect\nGCC_C_LANGUAGE_STANDARD = c99\n\n// not sure why apple defaults this on, but it's pretty risky\nALWAYS_SEARCH_USER_PATHS = NO\n\n// Turn on position dependent code for most cases (overridden where appropriate)\nGCC_DYNAMIC_NO_PIC = YES\n\n// Default SDK and minimum OS version is 10.4\nSDKROOT = $(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk\nMACOSX_DEPLOYMENT_TARGET = 10.4\nGCC_VERSION = 4.0\n\n// VERSIONING BUILD SETTINGS (used in Info.plist)\nGTEST_VERSIONINFO_ABOUT =  © 2008 Google Inc.\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/Config/ReleaseProject.xcconfig",
    "content": "//\n//  ReleaseProject.xcconfig\n//\n//  These are Release Configuration project settings for the gtest framework\n//  and examples. It is set in the \"Based On:\" dropdown in the \"Project\" info\n//  dialog.\n//  This file is based on the Xcode Configuration files in:\n//  http://code.google.com/p/google-toolbox-for-mac/\n// \n\n#include \"General.xcconfig\"\n\n// subconfig/Release.xcconfig\n\n// Optimize for space and size (Apple recommendation)\nGCC_OPTIMIZATION_LEVEL = s\n\n// Deploment postprocessing is what triggers Xcode to strip\nDEPLOYMENT_POSTPROCESSING = YES\n\n// No symbols\nGCC_GENERATE_DEBUGGING_SYMBOLS = NO\n\n// Dead code strip does not affect ObjC code but can help for C\nDEAD_CODE_STRIPPING = YES\n\n// NDEBUG is used by things like assert.h, so define it for general compat.\n// ASSERT going away in release tends to create unused vars.\nOTHER_CFLAGS = $(OTHER_CFLAGS) -DNDEBUG=1 -Wno-unused-variable\n\n// When we strip we want to strip all symbols in release, but save externals.\nSTRIP_STYLE = all\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/Config/StaticLibraryTarget.xcconfig",
    "content": "//\n//  StaticLibraryTarget.xcconfig\n//\n//  These are static library target settings for libgtest.a. It\n//  is set in the \"Based On:\" dropdown in the \"Target\" info dialog.\n//  This file is based on the Xcode Configuration files in:\n//  http://code.google.com/p/google-toolbox-for-mac/\n// \n\n// Static libs can be included in bundles so make them position independent\nGCC_DYNAMIC_NO_PIC = NO\n\n// Static libs should not have their internal globals or external symbols\n// stripped.\nSTRIP_STYLE = debugging\n\n// Let the user install by specifying the $DSTROOT with xcodebuild\nSKIP_INSTALL = NO\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/Config/TestTarget.xcconfig",
    "content": "//\n//  TestTarget.xcconfig\n//\n//  These are Test target settings for the gtest framework and examples. It\n//  is set in the \"Based On:\" dropdown in the \"Target\" info dialog.\n\nPRODUCT_NAME = $(TARGET_NAME)\nHEADER_SEARCH_PATHS = ../include\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/Resources/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>English</string>\n\t<key>CFBundleExecutable</key>\n\t<string>${EXECUTABLE_NAME}</string>\n\t<key>CFBundleIconFile</key>\n\t<string></string>\n\t<key>CFBundleIdentifier</key>\n\t<string>com.google.${PRODUCT_NAME}</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundlePackageType</key>\n\t<string>FMWK</string>\n\t<key>CFBundleSignature</key>\n\t<string>????</string>\n\t<key>CFBundleVersion</key>\n\t<string>GTEST_VERSIONINFO_LONG</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>GTEST_VERSIONINFO_SHORT</string>\n\t<key>CFBundleGetInfoString</key>\n\t<string>${PRODUCT_NAME} GTEST_VERSIONINFO_LONG, ${GTEST_VERSIONINFO_ABOUT}</string>\n\t<key>NSHumanReadableCopyright</key>\n\t<string>${GTEST_VERSIONINFO_ABOUT}</string>\n\t<key>CSResourcesFileMapped</key>\n\t<true/>\n</dict>\n</plist>\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/Samples/FrameworkSample/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>English</string>\n\t<key>CFBundleExecutable</key>\n\t<string>${EXECUTABLE_NAME}</string>\n\t<key>CFBundleIconFile</key>\n\t<string></string>\n\t<key>CFBundleIdentifier</key>\n\t<string>com.google.gtest.${PRODUCT_NAME:identifier}</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string>${PRODUCT_NAME}</string>\n\t<key>CFBundlePackageType</key>\n\t<string>FMWK</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>1.0</string>\n\t<key>CFBundleSignature</key>\n\t<string>????</string>\n\t<key>CFBundleVersion</key>\n\t<string>1.0</string>\n\t<key>CSResourcesFileMapped</key>\n\t<true/>\n</dict>\n</plist>\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/Samples/FrameworkSample/WidgetFramework.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 42;\n\tobjects = {\n\n/* Begin PBXAggregateTarget section */\n\t\t4024D162113D7D2400C7059E /* Test */ = {\n\t\t\tisa = PBXAggregateTarget;\n\t\t\tbuildConfigurationList = 4024D169113D7D4600C7059E /* Build configuration list for PBXAggregateTarget \"Test\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t4024D161113D7D2400C7059E /* ShellScript */,\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t4024D166113D7D3100C7059E /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = Test;\n\t\t\tproductName = TestAndBuild;\n\t\t};\n\t\t4024D1E9113D83FF00C7059E /* TestAndBuild */ = {\n\t\t\tisa = PBXAggregateTarget;\n\t\t\tbuildConfigurationList = 4024D1F0113D842B00C7059E /* Build configuration list for PBXAggregateTarget \"TestAndBuild\" */;\n\t\t\tbuildPhases = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t4024D1ED113D840900C7059E /* PBXTargetDependency */,\n\t\t\t\t4024D1EF113D840D00C7059E /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = TestAndBuild;\n\t\t\tproductName = TestAndBuild;\n\t\t};\n/* End PBXAggregateTarget section */\n\n/* Begin PBXBuildFile section */\n\t\t3B7EB1250E5AEE3500C7F239 /* widget.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3B7EB1230E5AEE3500C7F239 /* widget.cc */; };\n\t\t3B7EB1260E5AEE3500C7F239 /* widget.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B7EB1240E5AEE3500C7F239 /* widget.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t3B7EB1280E5AEE4600C7F239 /* widget_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3B7EB1270E5AEE4600C7F239 /* widget_test.cc */; };\n\t\t3B7EB1480E5AF3B400C7F239 /* Widget.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8D07F2C80486CC7A007CD1D0 /* Widget.framework */; };\n\t\t4024D188113D7D7800C7059E /* libgtest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4024D185113D7D5500C7059E /* libgtest.a */; };\n\t\t4024D189113D7D7A00C7059E /* libgtest_main.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4024D183113D7D5500C7059E /* libgtest_main.a */; };\n/* End PBXBuildFile section */\n\n/* Begin PBXContainerItemProxy section */\n\t\t3B07BDF00E3F3FAE00647869 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 8D07F2BC0486CC7A007CD1D0;\n\t\t\tremoteInfo = gTestExample;\n\t\t};\n\t\t4024D165113D7D3100C7059E /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 3B07BDE90E3F3F9E00647869;\n\t\t\tremoteInfo = WidgetFrameworkTest;\n\t\t};\n\t\t4024D1EC113D840900C7059E /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 8D07F2BC0486CC7A007CD1D0;\n\t\t\tremoteInfo = WidgetFramework;\n\t\t};\n\t\t4024D1EE113D840D00C7059E /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 4024D162113D7D2400C7059E;\n\t\t\tremoteInfo = Test;\n\t\t};\n/* End PBXContainerItemProxy section */\n\n/* Begin PBXFileReference section */\n\t\t3B07BDEA0E3F3F9E00647869 /* WidgetFrameworkTest */ = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.executable\"; includeInIndex = 0; path = WidgetFrameworkTest; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t3B7EB1230E5AEE3500C7F239 /* widget.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = widget.cc; sourceTree = \"<group>\"; };\n\t\t3B7EB1240E5AEE3500C7F239 /* widget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = widget.h; sourceTree = \"<group>\"; };\n\t\t3B7EB1270E5AEE4600C7F239 /* widget_test.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = widget_test.cc; sourceTree = \"<group>\"; };\n\t\t4024D183113D7D5500C7059E /* libgtest_main.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libgtest_main.a; path = /usr/local/lib/libgtest_main.a; sourceTree = \"<absolute>\"; };\n\t\t4024D185113D7D5500C7059E /* libgtest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libgtest.a; path = /usr/local/lib/libgtest.a; sourceTree = \"<absolute>\"; };\n\t\t4024D1E2113D838200C7059E /* runtests.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = runtests.sh; sourceTree = \"<group>\"; };\n\t\t8D07F2C70486CC7A007CD1D0 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = \"<group>\"; };\n\t\t8D07F2C80486CC7A007CD1D0 /* Widget.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Widget.framework; sourceTree = BUILT_PRODUCTS_DIR; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\t3B07BDE80E3F3F9E00647869 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4024D189113D7D7A00C7059E /* libgtest_main.a in Frameworks */,\n\t\t\t\t4024D188113D7D7800C7059E /* libgtest.a in Frameworks */,\n\t\t\t\t3B7EB1480E5AF3B400C7F239 /* Widget.framework in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t8D07F2C30486CC7A007CD1D0 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\t034768DDFF38A45A11DB9C8B /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8D07F2C80486CC7A007CD1D0 /* Widget.framework */,\n\t\t\t\t3B07BDEA0E3F3F9E00647869 /* WidgetFrameworkTest */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0867D691FE84028FC02AAC07 /* gTestExample */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4024D1E1113D836C00C7059E /* Scripts */,\n\t\t\t\t08FB77ACFE841707C02AAC07 /* Source */,\n\t\t\t\t089C1665FE841158C02AAC07 /* Resources */,\n\t\t\t\t3B07BE350E4094E400647869 /* Test */,\n\t\t\t\t0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */,\n\t\t\t\t034768DDFF38A45A11DB9C8B /* Products */,\n\t\t\t);\n\t\t\tname = gTestExample;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4024D183113D7D5500C7059E /* libgtest_main.a */,\n\t\t\t\t4024D185113D7D5500C7059E /* libgtest.a */,\n\t\t\t);\n\t\t\tname = \"External Frameworks and Libraries\";\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t089C1665FE841158C02AAC07 /* Resources */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8D07F2C70486CC7A007CD1D0 /* Info.plist */,\n\t\t\t);\n\t\t\tname = Resources;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t08FB77ACFE841707C02AAC07 /* Source */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t3B7EB1230E5AEE3500C7F239 /* widget.cc */,\n\t\t\t\t3B7EB1240E5AEE3500C7F239 /* widget.h */,\n\t\t\t);\n\t\t\tname = Source;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t3B07BE350E4094E400647869 /* Test */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t3B7EB1270E5AEE4600C7F239 /* widget_test.cc */,\n\t\t\t);\n\t\t\tname = Test;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4024D1E1113D836C00C7059E /* Scripts */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4024D1E2113D838200C7059E /* runtests.sh */,\n\t\t\t);\n\t\t\tname = Scripts;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXHeadersBuildPhase section */\n\t\t8D07F2BD0486CC7A007CD1D0 /* Headers */ = {\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t3B7EB1260E5AEE3500C7F239 /* widget.h in Headers */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXHeadersBuildPhase section */\n\n/* Begin PBXNativeTarget section */\n\t\t3B07BDE90E3F3F9E00647869 /* WidgetFrameworkTest */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 3B07BDF40E3F3FB600647869 /* Build configuration list for PBXNativeTarget \"WidgetFrameworkTest\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t3B07BDE70E3F3F9E00647869 /* Sources */,\n\t\t\t\t3B07BDE80E3F3F9E00647869 /* Frameworks */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t3B07BDF10E3F3FAE00647869 /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = WidgetFrameworkTest;\n\t\t\tproductName = gTestExampleTest;\n\t\t\tproductReference = 3B07BDEA0E3F3F9E00647869 /* WidgetFrameworkTest */;\n\t\t\tproductType = \"com.apple.product-type.tool\";\n\t\t};\n\t\t8D07F2BC0486CC7A007CD1D0 /* WidgetFramework */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 4FADC24208B4156D00ABE55E /* Build configuration list for PBXNativeTarget \"WidgetFramework\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t8D07F2C10486CC7A007CD1D0 /* Sources */,\n\t\t\t\t8D07F2C30486CC7A007CD1D0 /* Frameworks */,\n\t\t\t\t8D07F2BD0486CC7A007CD1D0 /* Headers */,\n\t\t\t\t8D07F2BF0486CC7A007CD1D0 /* Resources */,\n\t\t\t\t8D07F2C50486CC7A007CD1D0 /* Rez */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = WidgetFramework;\n\t\t\tproductInstallPath = \"$(HOME)/Library/Frameworks\";\n\t\t\tproductName = gTestExample;\n\t\t\tproductReference = 8D07F2C80486CC7A007CD1D0 /* Widget.framework */;\n\t\t\tproductType = \"com.apple.product-type.framework\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\t0867D690FE84028FC02AAC07 /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tbuildConfigurationList = 4FADC24608B4156D00ABE55E /* Build configuration list for PBXProject \"WidgetFramework\" */;\n\t\t\tcompatibilityVersion = \"Xcode 2.4\";\n\t\t\thasScannedForEncodings = 1;\n\t\t\tmainGroup = 0867D691FE84028FC02AAC07 /* gTestExample */;\n\t\t\tproductRefGroup = 034768DDFF38A45A11DB9C8B /* Products */;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\t8D07F2BC0486CC7A007CD1D0 /* WidgetFramework */,\n\t\t\t\t3B07BDE90E3F3F9E00647869 /* WidgetFrameworkTest */,\n\t\t\t\t4024D162113D7D2400C7059E /* Test */,\n\t\t\t\t4024D1E9113D83FF00C7059E /* TestAndBuild */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXResourcesBuildPhase section */\n\t\t8D07F2BF0486CC7A007CD1D0 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXResourcesBuildPhase section */\n\n/* Begin PBXRezBuildPhase section */\n\t\t8D07F2C50486CC7A007CD1D0 /* Rez */ = {\n\t\t\tisa = PBXRezBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXRezBuildPhase section */\n\n/* Begin PBXShellScriptBuildPhase section */\n\t\t4024D161113D7D2400C7059E /* ShellScript */ = {\n\t\t\tisa = PBXShellScriptBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tinputPaths = (\n\t\t\t);\n\t\t\toutputPaths = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t\tshellPath = /bin/sh;\n\t\t\tshellScript = \"/bin/bash $SRCROOT/runtests.sh $BUILT_PRODUCTS_DIR/WidgetFrameworkTest\\n\";\n\t\t};\n/* End PBXShellScriptBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\t3B07BDE70E3F3F9E00647869 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t3B7EB1280E5AEE4600C7F239 /* widget_test.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t8D07F2C10486CC7A007CD1D0 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t3B7EB1250E5AEE3500C7F239 /* widget.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin PBXTargetDependency section */\n\t\t3B07BDF10E3F3FAE00647869 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 8D07F2BC0486CC7A007CD1D0 /* WidgetFramework */;\n\t\t\ttargetProxy = 3B07BDF00E3F3FAE00647869 /* PBXContainerItemProxy */;\n\t\t};\n\t\t4024D166113D7D3100C7059E /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 3B07BDE90E3F3F9E00647869 /* WidgetFrameworkTest */;\n\t\t\ttargetProxy = 4024D165113D7D3100C7059E /* PBXContainerItemProxy */;\n\t\t};\n\t\t4024D1ED113D840900C7059E /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 8D07F2BC0486CC7A007CD1D0 /* WidgetFramework */;\n\t\t\ttargetProxy = 4024D1EC113D840900C7059E /* PBXContainerItemProxy */;\n\t\t};\n\t\t4024D1EF113D840D00C7059E /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 4024D162113D7D2400C7059E /* Test */;\n\t\t\ttargetProxy = 4024D1EE113D840D00C7059E /* PBXContainerItemProxy */;\n\t\t};\n/* End PBXTargetDependency section */\n\n/* Begin XCBuildConfiguration section */\n\t\t3B07BDEC0E3F3F9F00647869 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tPRODUCT_NAME = WidgetFrameworkTest;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t3B07BDED0E3F3F9F00647869 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tPRODUCT_NAME = WidgetFrameworkTest;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4024D163113D7D2400C7059E /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tPRODUCT_NAME = TestAndBuild;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4024D164113D7D2400C7059E /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tPRODUCT_NAME = TestAndBuild;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4024D1EA113D83FF00C7059E /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tPRODUCT_NAME = TestAndBuild;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4024D1EB113D83FF00C7059E /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tPRODUCT_NAME = TestAndBuild;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4FADC24308B4156D00ABE55E /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tDYLIB_COMPATIBILITY_VERSION = 1;\n\t\t\t\tDYLIB_CURRENT_VERSION = 1;\n\t\t\t\tFRAMEWORK_VERSION = A;\n\t\t\t\tINFOPLIST_FILE = Info.plist;\n\t\t\t\tINSTALL_PATH = \"@loader_path/../Frameworks\";\n\t\t\t\tPRODUCT_NAME = Widget;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4FADC24408B4156D00ABE55E /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tDYLIB_COMPATIBILITY_VERSION = 1;\n\t\t\t\tDYLIB_CURRENT_VERSION = 1;\n\t\t\t\tFRAMEWORK_VERSION = A;\n\t\t\t\tINFOPLIST_FILE = Info.plist;\n\t\t\t\tINSTALL_PATH = \"@loader_path/../Frameworks\";\n\t\t\t\tPRODUCT_NAME = Widget;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4FADC24708B4156D00ABE55E /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = 4.0;\n\t\t\t\tSDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4FADC24808B4156D00ABE55E /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = 4.0;\n\t\t\t\tSDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\t3B07BDF40E3F3FB600647869 /* Build configuration list for PBXNativeTarget \"WidgetFrameworkTest\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t3B07BDEC0E3F3F9F00647869 /* Debug */,\n\t\t\t\t3B07BDED0E3F3F9F00647869 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4024D169113D7D4600C7059E /* Build configuration list for PBXAggregateTarget \"Test\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4024D163113D7D2400C7059E /* Debug */,\n\t\t\t\t4024D164113D7D2400C7059E /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4024D1F0113D842B00C7059E /* Build configuration list for PBXAggregateTarget \"TestAndBuild\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4024D1EA113D83FF00C7059E /* Debug */,\n\t\t\t\t4024D1EB113D83FF00C7059E /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4FADC24208B4156D00ABE55E /* Build configuration list for PBXNativeTarget \"WidgetFramework\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4FADC24308B4156D00ABE55E /* Debug */,\n\t\t\t\t4FADC24408B4156D00ABE55E /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4FADC24608B4156D00ABE55E /* Build configuration list for PBXProject \"WidgetFramework\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4FADC24708B4156D00ABE55E /* Debug */,\n\t\t\t\t4FADC24808B4156D00ABE55E /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = 0867D690FE84028FC02AAC07 /* Project object */;\n}\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/Samples/FrameworkSample/runtests.sh",
    "content": "#!/bin/bash\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n# Executes the samples and tests for the Google Test Framework.\n\n# Help the dynamic linker find the path to the libraries.\nexport DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR\nexport DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR\n\n# Create some executables.\ntest_executables=$@\n\n# Now execute each one in turn keeping track of how many succeeded and failed.\nsucceeded=0\nfailed=0\nfailed_list=()\nfor test in ${test_executables[*]}; do\n  \"$test\"\n  result=$?\n  if [ $result -eq 0 ]; then\n    succeeded=$(( $succeeded + 1 ))\n  else\n    failed=$(( failed + 1 ))\n    failed_list=\"$failed_list $test\"\n  fi\ndone\n\n# Report the successes and failures to the console.\necho \"Tests complete with $succeeded successes and $failed failures.\"\nif [ $failed -ne 0 ]; then\n  echo \"The following tests failed:\"\n  echo $failed_list\nfi\nexit $failed\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/Samples/FrameworkSample/widget.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: preston.a.jackson@gmail.com (Preston Jackson)\n//\n// Google Test - FrameworkSample\n// widget.cc\n//\n\n// Widget is a very simple class used for demonstrating the use of gtest\n\n#include \"widget.h\"\n\nWidget::Widget(int number, const std::string& name)\n    : number_(number),\n      name_(name) {}\n\nWidget::~Widget() {}\n\nfloat Widget::GetFloatValue() const {\n  return number_;\n}\n\nint Widget::GetIntValue() const {\n  return static_cast<int>(number_);\n}\n\nstd::string Widget::GetStringValue() const {\n  return name_;\n}\n\nvoid Widget::GetCharPtrValue(char* buffer, size_t max_size) const {\n  // Copy the char* representation of name_ into buffer, up to max_size.\n  strncpy(buffer, name_.c_str(), max_size-1);\n  buffer[max_size-1] = '\\0';\n  return;\n}\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/Samples/FrameworkSample/widget.h",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: preston.a.jackson@gmail.com (Preston Jackson)\n//\n// Google Test - FrameworkSample\n// widget.h\n//\n\n// Widget is a very simple class used for demonstrating the use of gtest. It\n// simply stores two values a string and an integer, which are returned via\n// public accessors in multiple forms.\n\n#import <string>\n\nclass Widget {\n public:\n  Widget(int number, const std::string& name);\n  ~Widget();\n\n  // Public accessors to number data\n  float GetFloatValue() const;\n  int GetIntValue() const;\n\n  // Public accessors to the string data\n  std::string GetStringValue() const;\n  void GetCharPtrValue(char* buffer, size_t max_size) const;\n\n private:\n  // Data members\n  float number_;\n  std::string name_;\n};\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/Samples/FrameworkSample/widget_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: preston.a.jackson@gmail.com (Preston Jackson)\n//\n// Google Test - FrameworkSample\n// widget_test.cc\n//\n\n// This is a simple test file for the Widget class in the Widget.framework\n\n#include <string>\n#include \"gtest/gtest.h\"\n\n#include <Widget/widget.h>\n\n// This test verifies that the constructor sets the internal state of the\n// Widget class correctly.\nTEST(WidgetInitializerTest, TestConstructor) {\n  Widget widget(1.0f, \"name\");\n  EXPECT_FLOAT_EQ(1.0f, widget.GetFloatValue());\n  EXPECT_EQ(std::string(\"name\"), widget.GetStringValue());\n}\n\n// This test verifies the conversion of the float and string values to int and\n// char*, respectively.\nTEST(WidgetInitializerTest, TestConversion) {\n  Widget widget(1.0f, \"name\");\n  EXPECT_EQ(1, widget.GetIntValue());\n\n  size_t max_size = 128;\n  char buffer[max_size];\n  widget.GetCharPtrValue(buffer, max_size);\n  EXPECT_STREQ(\"name\", buffer);\n}\n\n// Use the Google Test main that is linked into the framework. It does something\n// like this:\n// int main(int argc, char** argv) {\n//   testing::InitGoogleTest(&argc, argv);\n//   return RUN_ALL_TESTS();\n// }\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/Scripts/runtests.sh",
    "content": "#!/bin/bash\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n# Executes the samples and tests for the Google Test Framework.\n\n# Help the dynamic linker find the path to the libraries.\nexport DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR\nexport DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR\n\n# Create some executables.\ntest_executables=(\"$BUILT_PRODUCTS_DIR/gtest_unittest-framework\"\n                  \"$BUILT_PRODUCTS_DIR/gtest_unittest\"\n                  \"$BUILT_PRODUCTS_DIR/sample1_unittest-framework\"\n                  \"$BUILT_PRODUCTS_DIR/sample1_unittest-static\")\n\n# Now execute each one in turn keeping track of how many succeeded and failed. \nsucceeded=0\nfailed=0\nfailed_list=()\nfor test in ${test_executables[*]}; do\n  \"$test\"\n  result=$?\n  if [ $result -eq 0 ]; then\n    succeeded=$(( $succeeded + 1 ))\n  else\n    failed=$(( failed + 1 ))\n    failed_list=\"$failed_list $test\"\n  fi\ndone\n\n# Report the successes and failures to the console.\necho \"Tests complete with $succeeded successes and $failed failures.\"\nif [ $failed -ne 0 ]; then\n  echo \"The following tests failed:\"\n  echo $failed_list\nfi\nexit $failed\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/Scripts/versiongenerate.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"A script to prepare version informtion for use the gtest Info.plist file.\n\n  This script extracts the version information from the configure.ac file and\n  uses it to generate a header file containing the same information. The\n  #defines in this header file will be included in during the generation of\n  the Info.plist of the framework, giving the correct value to the version\n  shown in the Finder.\n\n  This script makes the following assumptions (these are faults of the script,\n  not problems with the Autoconf):\n    1. The AC_INIT macro will be contained within the first 1024 characters\n       of configure.ac\n    2. The version string will be 3 integers separated by periods and will be\n       surrounded by squre brackets, \"[\" and \"]\" (e.g. [1.0.1]). The first\n       segment represents the major version, the second represents the minor\n       version and the third represents the fix version.\n    3. No \")\" character exists between the opening \"(\" and closing \")\" of\n       AC_INIT, including in comments and character strings.\n\"\"\"\n\nimport sys\nimport re\n\n# Read the command line argument (the output directory for Version.h)\nif (len(sys.argv) < 3):\n  print \"Usage: versiongenerate.py input_dir output_dir\"\n  sys.exit(1)\nelse:\n  input_dir = sys.argv[1]\n  output_dir = sys.argv[2]\n\n# Read the first 1024 characters of the configure.ac file\nconfig_file = open(\"%s/configure.ac\" % input_dir, 'r')\nbuffer_size = 1024\nopening_string = config_file.read(buffer_size)\nconfig_file.close()\n\n# Extract the version string from the AC_INIT macro\n#   The following init_expression means:\n#     Extract three integers separated by periods and surrounded by squre\n#     brackets(e.g. \"[1.0.1]\") between \"AC_INIT(\" and \")\". Do not be greedy\n#     (*? is the non-greedy flag) since that would pull in everything between\n#     the first \"(\" and the last \")\" in the file.\nversion_expression = re.compile(r\"AC_INIT\\(.*?\\[(\\d+)\\.(\\d+)\\.(\\d+)\\].*?\\)\",\n                                re.DOTALL)\nversion_values = version_expression.search(opening_string)\nmajor_version = version_values.group(1)\nminor_version = version_values.group(2)\nfix_version = version_values.group(3)\n\n# Write the version information to a header file to be included in the\n# Info.plist file.\nfile_data = \"\"\"//\n// DO NOT MODIFY THIS FILE (but you can delete it)\n//\n// This file is autogenerated by the versiongenerate.py script. This script\n// is executed in a \"Run Script\" build phase when creating gtest.framework. This\n// header file is not used during compilation of C-source. Rather, it simply\n// defines some version strings for substitution in the Info.plist. Because of\n// this, we are not not restricted to C-syntax nor are we using include guards.\n//\n\n#define GTEST_VERSIONINFO_SHORT %s.%s\n#define GTEST_VERSIONINFO_LONG %s.%s.%s\n\n\"\"\" % (major_version, minor_version, major_version, minor_version, fix_version)\nversion_file = open(\"%s/Version.h\" % output_dir, 'w')\nversion_file.write(file_data)\nversion_file.close()\n"
  },
  {
    "path": "utils/googletest/googletest/xcode/gtest.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXAggregateTarget section */\n\t\t3B238F5F0E828B5400846E11 /* Check */ = {\n\t\t\tisa = PBXAggregateTarget;\n\t\t\tbuildConfigurationList = 3B238FA30E828BB600846E11 /* Build configuration list for PBXAggregateTarget \"Check\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t3B238F5E0E828B5400846E11 /* ShellScript */,\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t40899F9D0FFA740F000B29AE /* PBXTargetDependency */,\n\t\t\t\t40C849F7101A43440083642A /* PBXTargetDependency */,\n\t\t\t\t4089A0980FFAD34A000B29AE /* PBXTargetDependency */,\n\t\t\t\t40C849F9101A43490083642A /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = Check;\n\t\t\tproductName = Check;\n\t\t};\n\t\t40C44ADC0E3798F4008FCC51 /* Version Info */ = {\n\t\t\tisa = PBXAggregateTarget;\n\t\t\tbuildConfigurationList = 40C44AE40E379905008FCC51 /* Build configuration list for PBXAggregateTarget \"Version Info\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t40C44ADB0E3798F4008FCC51 /* Generate Version.h */,\n\t\t\t);\n\t\t\tcomments = \"The generation of Version.h must be performed in its own target. Since the Info.plist is preprocessed before any of the other build phases in gtest, the Version.h file would not be ready if included as a build phase of that target.\";\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = \"Version Info\";\n\t\t\tproductName = Version.h;\n\t\t};\n/* End PBXAggregateTarget section */\n\n/* Begin PBXBuildFile section */\n\t\t224A12A30E9EADCC00BD17FD /* gtest-test-part.h in Headers */ = {isa = PBXBuildFile; fileRef = 224A12A20E9EADCC00BD17FD /* gtest-test-part.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t3BF6F2A00E79B5AD000F2EEE /* gtest-type-util.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 3BF6F29F0E79B5AD000F2EEE /* gtest-type-util.h */; };\n\t\t3BF6F2A50E79B616000F2EEE /* gtest-typed-test.h in Headers */ = {isa = PBXBuildFile; fileRef = 3BF6F2A40E79B616000F2EEE /* gtest-typed-test.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t404884380E2F799B00CF7658 /* gtest-death-test.h in Headers */ = {isa = PBXBuildFile; fileRef = 404883DB0E2F799B00CF7658 /* gtest-death-test.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t404884390E2F799B00CF7658 /* gtest-message.h in Headers */ = {isa = PBXBuildFile; fileRef = 404883DC0E2F799B00CF7658 /* gtest-message.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t4048843A0E2F799B00CF7658 /* gtest-spi.h in Headers */ = {isa = PBXBuildFile; fileRef = 404883DD0E2F799B00CF7658 /* gtest-spi.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t4048843B0E2F799B00CF7658 /* gtest.h in Headers */ = {isa = PBXBuildFile; fileRef = 404883DE0E2F799B00CF7658 /* gtest.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t4048843C0E2F799B00CF7658 /* gtest_pred_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 404883DF0E2F799B00CF7658 /* gtest_pred_impl.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t4048843D0E2F799B00CF7658 /* gtest_prod.h in Headers */ = {isa = PBXBuildFile; fileRef = 404883E00E2F799B00CF7658 /* gtest_prod.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t404884500E2F799B00CF7658 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 404883F60E2F799B00CF7658 /* README.md */; };\n\t\t404884A00E2F7BE600CF7658 /* gtest-death-test-internal.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 404883E20E2F799B00CF7658 /* gtest-death-test-internal.h */; };\n\t\t404884A10E2F7BE600CF7658 /* gtest-filepath.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 404883E30E2F799B00CF7658 /* gtest-filepath.h */; };\n\t\t404884A20E2F7BE600CF7658 /* gtest-internal.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 404883E40E2F799B00CF7658 /* gtest-internal.h */; };\n\t\t404884A30E2F7BE600CF7658 /* gtest-port.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 404883E50E2F799B00CF7658 /* gtest-port.h */; };\n\t\t404884A40E2F7BE600CF7658 /* gtest-string.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 404883E60E2F799B00CF7658 /* gtest-string.h */; };\n\t\t404884AC0E2F7CD900CF7658 /* CHANGES in Resources */ = {isa = PBXBuildFile; fileRef = 404884A90E2F7CD900CF7658 /* CHANGES */; };\n\t\t404884AD0E2F7CD900CF7658 /* CONTRIBUTORS in Resources */ = {isa = PBXBuildFile; fileRef = 404884AA0E2F7CD900CF7658 /* CONTRIBUTORS */; };\n\t\t404884AE0E2F7CD900CF7658 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 404884AB0E2F7CD900CF7658 /* LICENSE */; };\n\t\t40899F3A0FFA70D4000B29AE /* gtest-all.cc in Sources */ = {isa = PBXBuildFile; fileRef = 224A12A10E9EADA700BD17FD /* gtest-all.cc */; };\n\t\t40899F500FFA7281000B29AE /* gtest-tuple.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 40899F4D0FFA7271000B29AE /* gtest-tuple.h */; };\n\t\t40899F530FFA72A0000B29AE /* gtest_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3B238C120E7FE13C00846E11 /* gtest_unittest.cc */; };\n\t\t4089A0440FFAD1BE000B29AE /* sample1.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4089A02C0FFACF7F000B29AE /* sample1.cc */; };\n\t\t4089A0460FFAD1BE000B29AE /* sample1_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4089A02E0FFACF7F000B29AE /* sample1_unittest.cc */; };\n\t\t40C848FF101A21150083642A /* gtest-all.cc in Sources */ = {isa = PBXBuildFile; fileRef = 224A12A10E9EADA700BD17FD /* gtest-all.cc */; };\n\t\t40C84915101A21DF0083642A /* gtest_main.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4048840D0E2F799B00CF7658 /* gtest_main.cc */; };\n\t\t40C84916101A235B0083642A /* libgtest_main.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 40C8490B101A217E0083642A /* libgtest_main.a */; };\n\t\t40C84921101A23AD0083642A /* libgtest_main.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 40C8490B101A217E0083642A /* libgtest_main.a */; };\n\t\t40C84978101A36540083642A /* libgtest_main.a in Resources */ = {isa = PBXBuildFile; fileRef = 40C8490B101A217E0083642A /* libgtest_main.a */; };\n\t\t40C84980101A36850083642A /* gtest_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3B238C120E7FE13C00846E11 /* gtest_unittest.cc */; };\n\t\t40C84982101A36850083642A /* libgtest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 40C848FA101A209C0083642A /* libgtest.a */; };\n\t\t40C84983101A36850083642A /* libgtest_main.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 40C8490B101A217E0083642A /* libgtest_main.a */; };\n\t\t40C8498F101A36A60083642A /* sample1.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4089A02C0FFACF7F000B29AE /* sample1.cc */; };\n\t\t40C84990101A36A60083642A /* sample1_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4089A02E0FFACF7F000B29AE /* sample1_unittest.cc */; };\n\t\t40C84992101A36A60083642A /* libgtest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 40C848FA101A209C0083642A /* libgtest.a */; };\n\t\t40C84993101A36A60083642A /* libgtest_main.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 40C8490B101A217E0083642A /* libgtest_main.a */; };\n\t\t40C849A2101A37050083642A /* gtest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4539C8FF0EC27F6400A70F4C /* gtest.framework */; };\n\t\t40C849A4101A37150083642A /* gtest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4539C8FF0EC27F6400A70F4C /* gtest.framework */; };\n\t\t4539C9340EC280AE00A70F4C /* gtest-param-test.h in Headers */ = {isa = PBXBuildFile; fileRef = 4539C9330EC280AE00A70F4C /* gtest-param-test.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t4539C9380EC280E200A70F4C /* gtest-linked_ptr.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 4539C9350EC280E200A70F4C /* gtest-linked_ptr.h */; };\n\t\t4539C9390EC280E200A70F4C /* gtest-param-util-generated.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 4539C9360EC280E200A70F4C /* gtest-param-util-generated.h */; };\n\t\t4539C93A0EC280E200A70F4C /* gtest-param-util.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 4539C9370EC280E200A70F4C /* gtest-param-util.h */; };\n\t\t4567C8181264FF71007740BE /* gtest-printers.h in Headers */ = {isa = PBXBuildFile; fileRef = 4567C8171264FF71007740BE /* gtest-printers.h */; settings = {ATTRIBUTES = (Public, ); }; };\n/* End PBXBuildFile section */\n\n/* Begin PBXContainerItemProxy section */\n\t\t40899F9C0FFA740F000B29AE /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40899F420FFA7184000B29AE;\n\t\t\tremoteInfo = gtest_unittest;\n\t\t};\n\t\t4089A0970FFAD34A000B29AE /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 4089A0120FFACEFC000B29AE;\n\t\t\tremoteInfo = sample1_unittest;\n\t\t};\n\t\t408BEC0F1046CFE900DEF522 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C848F9101A209C0083642A;\n\t\t\tremoteInfo = \"gtest-static\";\n\t\t};\n\t\t40C44AE50E379922008FCC51 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C44ADC0E3798F4008FCC51;\n\t\t\tremoteInfo = Version.h;\n\t\t};\n\t\t40C8497C101A36850083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C848F9101A209C0083642A;\n\t\t\tremoteInfo = \"gtest-static\";\n\t\t};\n\t\t40C8497E101A36850083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C8490A101A217E0083642A;\n\t\t\tremoteInfo = \"gtest_main-static\";\n\t\t};\n\t\t40C8498B101A36A60083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C848F9101A209C0083642A;\n\t\t\tremoteInfo = \"gtest-static\";\n\t\t};\n\t\t40C8498D101A36A60083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C8490A101A217E0083642A;\n\t\t\tremoteInfo = \"gtest_main-static\";\n\t\t};\n\t\t40C8499B101A36DC0083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C8490A101A217E0083642A;\n\t\t\tremoteInfo = \"gtest_main-static\";\n\t\t};\n\t\t40C8499D101A36E50083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 8D07F2BC0486CC7A007CD1D0;\n\t\t\tremoteInfo = \"gtest-framework\";\n\t\t};\n\t\t40C8499F101A36F10083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 8D07F2BC0486CC7A007CD1D0;\n\t\t\tremoteInfo = \"gtest-framework\";\n\t\t};\n\t\t40C849F6101A43440083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C8497A101A36850083642A;\n\t\t\tremoteInfo = \"gtest_unittest-static\";\n\t\t};\n\t\t40C849F8101A43490083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C84989101A36A60083642A;\n\t\t\tremoteInfo = \"sample1_unittest-static\";\n\t\t};\n/* End PBXContainerItemProxy section */\n\n/* Begin PBXCopyFilesBuildPhase section */\n\t\t404884A50E2F7C0400CF7658 /* Copy Headers Internal */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = Headers/internal;\n\t\t\tdstSubfolderSpec = 6;\n\t\t\tfiles = (\n\t\t\t\t404884A00E2F7BE600CF7658 /* gtest-death-test-internal.h in Copy Headers Internal */,\n\t\t\t\t404884A10E2F7BE600CF7658 /* gtest-filepath.h in Copy Headers Internal */,\n\t\t\t\t404884A20E2F7BE600CF7658 /* gtest-internal.h in Copy Headers Internal */,\n\t\t\t\t4539C9380EC280E200A70F4C /* gtest-linked_ptr.h in Copy Headers Internal */,\n\t\t\t\t4539C9390EC280E200A70F4C /* gtest-param-util-generated.h in Copy Headers Internal */,\n\t\t\t\t4539C93A0EC280E200A70F4C /* gtest-param-util.h in Copy Headers Internal */,\n\t\t\t\t404884A30E2F7BE600CF7658 /* gtest-port.h in Copy Headers Internal */,\n\t\t\t\t404884A40E2F7BE600CF7658 /* gtest-string.h in Copy Headers Internal */,\n\t\t\t\t40899F500FFA7281000B29AE /* gtest-tuple.h in Copy Headers Internal */,\n\t\t\t\t3BF6F2A00E79B5AD000F2EEE /* gtest-type-util.h in Copy Headers Internal */,\n\t\t\t);\n\t\t\tname = \"Copy Headers Internal\";\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXCopyFilesBuildPhase section */\n\n/* Begin PBXFileReference section */\n\t\t224A12A10E9EADA700BD17FD /* gtest-all.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = \"gtest-all.cc\"; sourceTree = \"<group>\"; };\n\t\t224A12A20E9EADCC00BD17FD /* gtest-test-part.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = \"gtest-test-part.h\"; sourceTree = \"<group>\"; };\n\t\t3B238C120E7FE13C00846E11 /* gtest_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gtest_unittest.cc; sourceTree = \"<group>\"; };\n\t\t3B87D2100E96B92E000D1852 /* runtests.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = runtests.sh; sourceTree = \"<group>\"; };\n\t\t3BF6F29F0E79B5AD000F2EEE /* gtest-type-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-type-util.h\"; sourceTree = \"<group>\"; };\n\t\t3BF6F2A40E79B616000F2EEE /* gtest-typed-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-typed-test.h\"; sourceTree = \"<group>\"; };\n\t\t403EE37C0E377822004BD1E2 /* versiongenerate.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = versiongenerate.py; sourceTree = \"<group>\"; };\n\t\t404883DB0E2F799B00CF7658 /* gtest-death-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-death-test.h\"; sourceTree = \"<group>\"; };\n\t\t404883DC0E2F799B00CF7658 /* gtest-message.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-message.h\"; sourceTree = \"<group>\"; };\n\t\t404883DD0E2F799B00CF7658 /* gtest-spi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-spi.h\"; sourceTree = \"<group>\"; };\n\t\t404883DE0E2F799B00CF7658 /* gtest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gtest.h; sourceTree = \"<group>\"; };\n\t\t404883DF0E2F799B00CF7658 /* gtest_pred_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gtest_pred_impl.h; sourceTree = \"<group>\"; };\n\t\t404883E00E2F799B00CF7658 /* gtest_prod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gtest_prod.h; sourceTree = \"<group>\"; };\n\t\t404883E20E2F799B00CF7658 /* gtest-death-test-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-death-test-internal.h\"; sourceTree = \"<group>\"; };\n\t\t404883E30E2F799B00CF7658 /* gtest-filepath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-filepath.h\"; sourceTree = \"<group>\"; };\n\t\t404883E40E2F799B00CF7658 /* gtest-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-internal.h\"; sourceTree = \"<group>\"; };\n\t\t404883E50E2F799B00CF7658 /* gtest-port.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-port.h\"; sourceTree = \"<group>\"; };\n\t\t404883E60E2F799B00CF7658 /* gtest-string.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-string.h\"; sourceTree = \"<group>\"; };\n\t\t404883F60E2F799B00CF7658 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = README.md; path = ../README.md; sourceTree = SOURCE_ROOT; };\n\t\t4048840D0E2F799B00CF7658 /* gtest_main.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gtest_main.cc; sourceTree = \"<group>\"; };\n\t\t404884A90E2F7CD900CF7658 /* CHANGES */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CHANGES; path = ../CHANGES; sourceTree = SOURCE_ROOT; };\n\t\t404884AA0E2F7CD900CF7658 /* CONTRIBUTORS */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CONTRIBUTORS; path = ../CONTRIBUTORS; sourceTree = SOURCE_ROOT; };\n\t\t404884AB0E2F7CD900CF7658 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = SOURCE_ROOT; };\n\t\t40899F430FFA7184000B29AE /* gtest_unittest-framework */ = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.executable\"; includeInIndex = 0; path = \"gtest_unittest-framework\"; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t40899F4D0FFA7271000B29AE /* gtest-tuple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-tuple.h\"; sourceTree = \"<group>\"; };\n\t\t40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = StaticLibraryTarget.xcconfig; sourceTree = \"<group>\"; };\n\t\t4089A0130FFACEFC000B29AE /* sample1_unittest-framework */ = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.executable\"; includeInIndex = 0; path = \"sample1_unittest-framework\"; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t4089A02C0FFACF7F000B29AE /* sample1.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sample1.cc; sourceTree = \"<group>\"; };\n\t\t4089A02D0FFACF7F000B29AE /* sample1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sample1.h; sourceTree = \"<group>\"; };\n\t\t4089A02E0FFACF7F000B29AE /* sample1_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sample1_unittest.cc; sourceTree = \"<group>\"; };\n\t\t40C848FA101A209C0083642A /* libgtest.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgtest.a; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t40C8490B101A217E0083642A /* libgtest_main.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgtest_main.a; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t40C84987101A36850083642A /* gtest_unittest */ = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.executable\"; includeInIndex = 0; path = gtest_unittest; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t40C84997101A36A60083642A /* sample1_unittest-static */ = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.executable\"; includeInIndex = 0; path = \"sample1_unittest-static\"; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t40D4CDF10E30E07400294801 /* DebugProject.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugProject.xcconfig; sourceTree = \"<group>\"; };\n\t\t40D4CDF20E30E07400294801 /* FrameworkTarget.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FrameworkTarget.xcconfig; sourceTree = \"<group>\"; };\n\t\t40D4CDF30E30E07400294801 /* General.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = General.xcconfig; sourceTree = \"<group>\"; };\n\t\t40D4CDF40E30E07400294801 /* ReleaseProject.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ReleaseProject.xcconfig; sourceTree = \"<group>\"; };\n\t\t40D4CF510E30F5E200294801 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = \"<group>\"; };\n\t\t4539C8FF0EC27F6400A70F4C /* gtest.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = gtest.framework; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t4539C9330EC280AE00A70F4C /* gtest-param-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-param-test.h\"; sourceTree = \"<group>\"; };\n\t\t4539C9350EC280E200A70F4C /* gtest-linked_ptr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-linked_ptr.h\"; sourceTree = \"<group>\"; };\n\t\t4539C9360EC280E200A70F4C /* gtest-param-util-generated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-param-util-generated.h\"; sourceTree = \"<group>\"; };\n\t\t4539C9370EC280E200A70F4C /* gtest-param-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-param-util.h\"; sourceTree = \"<group>\"; };\n\t\t4567C8171264FF71007740BE /* gtest-printers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-printers.h\"; sourceTree = \"<group>\"; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\t40899F410FFA7184000B29AE /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C849A4101A37150083642A /* gtest.framework in Frameworks */,\n\t\t\t\t40C84916101A235B0083642A /* libgtest_main.a in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4089A0110FFACEFC000B29AE /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C849A2101A37050083642A /* gtest.framework in Frameworks */,\n\t\t\t\t40C84921101A23AD0083642A /* libgtest_main.a in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t40C84981101A36850083642A /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C84982101A36850083642A /* libgtest.a in Frameworks */,\n\t\t\t\t40C84983101A36850083642A /* libgtest_main.a in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t40C84991101A36A60083642A /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C84992101A36A60083642A /* libgtest.a in Frameworks */,\n\t\t\t\t40C84993101A36A60083642A /* libgtest_main.a in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\t034768DDFF38A45A11DB9C8B /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4539C8FF0EC27F6400A70F4C /* gtest.framework */,\n\t\t\t\t40C848FA101A209C0083642A /* libgtest.a */,\n\t\t\t\t40C8490B101A217E0083642A /* libgtest_main.a */,\n\t\t\t\t40899F430FFA7184000B29AE /* gtest_unittest-framework */,\n\t\t\t\t40C84987101A36850083642A /* gtest_unittest */,\n\t\t\t\t4089A0130FFACEFC000B29AE /* sample1_unittest-framework */,\n\t\t\t\t40C84997101A36A60083642A /* sample1_unittest-static */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0867D691FE84028FC02AAC07 /* gtest */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t40D4CDF00E30E07400294801 /* Config */,\n\t\t\t\t08FB77ACFE841707C02AAC07 /* Source */,\n\t\t\t\t40D4CF4E0E30F5E200294801 /* Resources */,\n\t\t\t\t403EE37B0E377822004BD1E2 /* Scripts */,\n\t\t\t\t034768DDFF38A45A11DB9C8B /* Products */,\n\t\t\t);\n\t\t\tname = gtest;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t08FB77ACFE841707C02AAC07 /* Source */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t404884A90E2F7CD900CF7658 /* CHANGES */,\n\t\t\t\t404884AA0E2F7CD900CF7658 /* CONTRIBUTORS */,\n\t\t\t\t404884AB0E2F7CD900CF7658 /* LICENSE */,\n\t\t\t\t404883F60E2F799B00CF7658 /* README.md */,\n\t\t\t\t404883D90E2F799B00CF7658 /* include */,\n\t\t\t\t4089A02F0FFACF84000B29AE /* samples */,\n\t\t\t\t404884070E2F799B00CF7658 /* src */,\n\t\t\t\t3B238BF00E7FE13B00846E11 /* test */,\n\t\t\t);\n\t\t\tname = Source;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t3B238BF00E7FE13B00846E11 /* test */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t3B238C120E7FE13C00846E11 /* gtest_unittest.cc */,\n\t\t\t);\n\t\t\tname = test;\n\t\t\tpath = ../test;\n\t\t\tsourceTree = SOURCE_ROOT;\n\t\t};\n\t\t403EE37B0E377822004BD1E2 /* Scripts */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t403EE37C0E377822004BD1E2 /* versiongenerate.py */,\n\t\t\t\t3B87D2100E96B92E000D1852 /* runtests.sh */,\n\t\t\t);\n\t\t\tpath = Scripts;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t404883D90E2F799B00CF7658 /* include */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t404883DA0E2F799B00CF7658 /* gtest */,\n\t\t\t);\n\t\t\tname = include;\n\t\t\tpath = ../include;\n\t\t\tsourceTree = SOURCE_ROOT;\n\t\t};\n\t\t404883DA0E2F799B00CF7658 /* gtest */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t404883E10E2F799B00CF7658 /* internal */,\n\t\t\t\t224A12A20E9EADCC00BD17FD /* gtest-test-part.h */,\n\t\t\t\t404883DB0E2F799B00CF7658 /* gtest-death-test.h */,\n\t\t\t\t404883DC0E2F799B00CF7658 /* gtest-message.h */,\n\t\t\t\t4539C9330EC280AE00A70F4C /* gtest-param-test.h */,\n\t\t\t\t4567C8171264FF71007740BE /* gtest-printers.h */,\n\t\t\t\t404883DD0E2F799B00CF7658 /* gtest-spi.h */,\n\t\t\t\t404883DE0E2F799B00CF7658 /* gtest.h */,\n\t\t\t\t404883DF0E2F799B00CF7658 /* gtest_pred_impl.h */,\n\t\t\t\t404883E00E2F799B00CF7658 /* gtest_prod.h */,\n\t\t\t\t3BF6F2A40E79B616000F2EEE /* gtest-typed-test.h */,\n\t\t\t);\n\t\t\tpath = gtest;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t404883E10E2F799B00CF7658 /* internal */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t404883E20E2F799B00CF7658 /* gtest-death-test-internal.h */,\n\t\t\t\t404883E30E2F799B00CF7658 /* gtest-filepath.h */,\n\t\t\t\t404883E40E2F799B00CF7658 /* gtest-internal.h */,\n\t\t\t\t4539C9350EC280E200A70F4C /* gtest-linked_ptr.h */,\n\t\t\t\t4539C9360EC280E200A70F4C /* gtest-param-util-generated.h */,\n\t\t\t\t4539C9370EC280E200A70F4C /* gtest-param-util.h */,\n\t\t\t\t404883E50E2F799B00CF7658 /* gtest-port.h */,\n\t\t\t\t404883E60E2F799B00CF7658 /* gtest-string.h */,\n\t\t\t\t40899F4D0FFA7271000B29AE /* gtest-tuple.h */,\n\t\t\t\t3BF6F29F0E79B5AD000F2EEE /* gtest-type-util.h */,\n\t\t\t);\n\t\t\tpath = internal;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t404884070E2F799B00CF7658 /* src */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t224A12A10E9EADA700BD17FD /* gtest-all.cc */,\n\t\t\t\t4048840D0E2F799B00CF7658 /* gtest_main.cc */,\n\t\t\t);\n\t\t\tname = src;\n\t\t\tpath = ../src;\n\t\t\tsourceTree = SOURCE_ROOT;\n\t\t};\n\t\t4089A02F0FFACF84000B29AE /* samples */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4089A02C0FFACF7F000B29AE /* sample1.cc */,\n\t\t\t\t4089A02D0FFACF7F000B29AE /* sample1.h */,\n\t\t\t\t4089A02E0FFACF7F000B29AE /* sample1_unittest.cc */,\n\t\t\t);\n\t\t\tname = samples;\n\t\t\tpath = ../samples;\n\t\t\tsourceTree = SOURCE_ROOT;\n\t\t};\n\t\t40D4CDF00E30E07400294801 /* Config */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t40D4CDF10E30E07400294801 /* DebugProject.xcconfig */,\n\t\t\t\t40D4CDF20E30E07400294801 /* FrameworkTarget.xcconfig */,\n\t\t\t\t40D4CDF30E30E07400294801 /* General.xcconfig */,\n\t\t\t\t40D4CDF40E30E07400294801 /* ReleaseProject.xcconfig */,\n\t\t\t\t40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */,\n\t\t\t);\n\t\t\tpath = Config;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t40D4CF4E0E30F5E200294801 /* Resources */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t40D4CF510E30F5E200294801 /* Info.plist */,\n\t\t\t);\n\t\t\tpath = Resources;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXHeadersBuildPhase section */\n\t\t8D07F2BD0486CC7A007CD1D0 /* Headers */ = {\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t404884380E2F799B00CF7658 /* gtest-death-test.h in Headers */,\n\t\t\t\t404884390E2F799B00CF7658 /* gtest-message.h in Headers */,\n\t\t\t\t4539C9340EC280AE00A70F4C /* gtest-param-test.h in Headers */,\n\t\t\t\t4567C8181264FF71007740BE /* gtest-printers.h in Headers */,\n\t\t\t\t3BF6F2A50E79B616000F2EEE /* gtest-typed-test.h in Headers */,\n\t\t\t\t4048843A0E2F799B00CF7658 /* gtest-spi.h in Headers */,\n\t\t\t\t4048843B0E2F799B00CF7658 /* gtest.h in Headers */,\n\t\t\t\t4048843C0E2F799B00CF7658 /* gtest_pred_impl.h in Headers */,\n\t\t\t\t4048843D0E2F799B00CF7658 /* gtest_prod.h in Headers */,\n\t\t\t\t224A12A30E9EADCC00BD17FD /* gtest-test-part.h in Headers */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXHeadersBuildPhase section */\n\n/* Begin PBXNativeTarget section */\n\t\t40899F420FFA7184000B29AE /* gtest_unittest-framework */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 40899F4A0FFA71BC000B29AE /* Build configuration list for PBXNativeTarget \"gtest_unittest-framework\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t40899F400FFA7184000B29AE /* Sources */,\n\t\t\t\t40899F410FFA7184000B29AE /* Frameworks */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t40C849A0101A36F10083642A /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = \"gtest_unittest-framework\";\n\t\t\tproductName = gtest_unittest;\n\t\t\tproductReference = 40899F430FFA7184000B29AE /* gtest_unittest-framework */;\n\t\t\tproductType = \"com.apple.product-type.tool\";\n\t\t};\n\t\t4089A0120FFACEFC000B29AE /* sample1_unittest-framework */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 4089A0240FFACF01000B29AE /* Build configuration list for PBXNativeTarget \"sample1_unittest-framework\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t4089A0100FFACEFC000B29AE /* Sources */,\n\t\t\t\t4089A0110FFACEFC000B29AE /* Frameworks */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t40C8499E101A36E50083642A /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = \"sample1_unittest-framework\";\n\t\t\tproductName = sample1_unittest;\n\t\t\tproductReference = 4089A0130FFACEFC000B29AE /* sample1_unittest-framework */;\n\t\t\tproductType = \"com.apple.product-type.tool\";\n\t\t};\n\t\t40C848F9101A209C0083642A /* gtest-static */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 40C84902101A212E0083642A /* Build configuration list for PBXNativeTarget \"gtest-static\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t40C848F7101A209C0083642A /* Sources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = \"gtest-static\";\n\t\t\tproductName = \"gtest-static\";\n\t\t\tproductReference = 40C848FA101A209C0083642A /* libgtest.a */;\n\t\t\tproductType = \"com.apple.product-type.library.static\";\n\t\t};\n\t\t40C8490A101A217E0083642A /* gtest_main-static */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 40C84912101A21D20083642A /* Build configuration list for PBXNativeTarget \"gtest_main-static\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t40C84908101A217E0083642A /* Sources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = \"gtest_main-static\";\n\t\t\tproductName = \"gtest_main-static\";\n\t\t\tproductReference = 40C8490B101A217E0083642A /* libgtest_main.a */;\n\t\t\tproductType = \"com.apple.product-type.library.static\";\n\t\t};\n\t\t40C8497A101A36850083642A /* gtest_unittest-static */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 40C84984101A36850083642A /* Build configuration list for PBXNativeTarget \"gtest_unittest-static\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t40C8497F101A36850083642A /* Sources */,\n\t\t\t\t40C84981101A36850083642A /* Frameworks */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t40C8497B101A36850083642A /* PBXTargetDependency */,\n\t\t\t\t40C8497D101A36850083642A /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = \"gtest_unittest-static\";\n\t\t\tproductName = gtest_unittest;\n\t\t\tproductReference = 40C84987101A36850083642A /* gtest_unittest */;\n\t\t\tproductType = \"com.apple.product-type.tool\";\n\t\t};\n\t\t40C84989101A36A60083642A /* sample1_unittest-static */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 40C84994101A36A60083642A /* Build configuration list for PBXNativeTarget \"sample1_unittest-static\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t40C8498E101A36A60083642A /* Sources */,\n\t\t\t\t40C84991101A36A60083642A /* Frameworks */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t40C8498A101A36A60083642A /* PBXTargetDependency */,\n\t\t\t\t40C8498C101A36A60083642A /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = \"sample1_unittest-static\";\n\t\t\tproductName = sample1_unittest;\n\t\t\tproductReference = 40C84997101A36A60083642A /* sample1_unittest-static */;\n\t\t\tproductType = \"com.apple.product-type.tool\";\n\t\t};\n\t\t8D07F2BC0486CC7A007CD1D0 /* gtest-framework */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 4FADC24208B4156D00ABE55E /* Build configuration list for PBXNativeTarget \"gtest-framework\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t8D07F2C10486CC7A007CD1D0 /* Sources */,\n\t\t\t\t8D07F2BD0486CC7A007CD1D0 /* Headers */,\n\t\t\t\t404884A50E2F7C0400CF7658 /* Copy Headers Internal */,\n\t\t\t\t8D07F2BF0486CC7A007CD1D0 /* Resources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t40C44AE60E379922008FCC51 /* PBXTargetDependency */,\n\t\t\t\t408BEC101046CFE900DEF522 /* PBXTargetDependency */,\n\t\t\t\t40C8499C101A36DC0083642A /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = \"gtest-framework\";\n\t\t\tproductInstallPath = \"$(HOME)/Library/Frameworks\";\n\t\t\tproductName = gtest;\n\t\t\tproductReference = 4539C8FF0EC27F6400A70F4C /* gtest.framework */;\n\t\t\tproductType = \"com.apple.product-type.framework\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\t0867D690FE84028FC02AAC07 /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tattributes = {\n\t\t\t\tLastUpgradeCheck = 0460;\n\t\t\t};\n\t\t\tbuildConfigurationList = 4FADC24608B4156D00ABE55E /* Build configuration list for PBXProject \"gtest\" */;\n\t\t\tcompatibilityVersion = \"Xcode 3.2\";\n\t\t\tdevelopmentRegion = English;\n\t\t\thasScannedForEncodings = 1;\n\t\t\tknownRegions = (\n\t\t\t\tEnglish,\n\t\t\t\tJapanese,\n\t\t\t\tFrench,\n\t\t\t\tGerman,\n\t\t\t\ten,\n\t\t\t);\n\t\t\tmainGroup = 0867D691FE84028FC02AAC07 /* gtest */;\n\t\t\tproductRefGroup = 034768DDFF38A45A11DB9C8B /* Products */;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\t8D07F2BC0486CC7A007CD1D0 /* gtest-framework */,\n\t\t\t\t40C848F9101A209C0083642A /* gtest-static */,\n\t\t\t\t40C8490A101A217E0083642A /* gtest_main-static */,\n\t\t\t\t40899F420FFA7184000B29AE /* gtest_unittest-framework */,\n\t\t\t\t40C8497A101A36850083642A /* gtest_unittest-static */,\n\t\t\t\t4089A0120FFACEFC000B29AE /* sample1_unittest-framework */,\n\t\t\t\t40C84989101A36A60083642A /* sample1_unittest-static */,\n\t\t\t\t3B238F5F0E828B5400846E11 /* Check */,\n\t\t\t\t40C44ADC0E3798F4008FCC51 /* Version Info */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXResourcesBuildPhase section */\n\t\t8D07F2BF0486CC7A007CD1D0 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t404884500E2F799B00CF7658 /* README.md in Resources */,\n\t\t\t\t404884AC0E2F7CD900CF7658 /* CHANGES in Resources */,\n\t\t\t\t404884AD0E2F7CD900CF7658 /* CONTRIBUTORS in Resources */,\n\t\t\t\t404884AE0E2F7CD900CF7658 /* LICENSE in Resources */,\n\t\t\t\t40C84978101A36540083642A /* libgtest_main.a in Resources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXResourcesBuildPhase section */\n\n/* Begin PBXShellScriptBuildPhase section */\n\t\t3B238F5E0E828B5400846E11 /* ShellScript */ = {\n\t\t\tisa = PBXShellScriptBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tinputPaths = (\n\t\t\t);\n\t\t\toutputPaths = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t\tshellPath = /bin/sh;\n\t\t\tshellScript = \"# Remember, this \\\"Run Script\\\" build phase will be executed from $SRCROOT\\n/bin/bash Scripts/runtests.sh\";\n\t\t};\n\t\t40C44ADB0E3798F4008FCC51 /* Generate Version.h */ = {\n\t\t\tisa = PBXShellScriptBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tinputPaths = (\n\t\t\t\t\"$(SRCROOT)/Scripts/versiongenerate.py\",\n\t\t\t\t\"$(SRCROOT)/../configure.ac\",\n\t\t\t);\n\t\t\tname = \"Generate Version.h\";\n\t\t\toutputPaths = (\n\t\t\t\t\"$(PROJECT_TEMP_DIR)/Version.h\",\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t\tshellPath = /bin/sh;\n\t\t\tshellScript = \"# Remember, this \\\"Run Script\\\" build phase will be executed from $SRCROOT\\n/usr/bin/python Scripts/versiongenerate.py ../ $PROJECT_TEMP_DIR\";\n\t\t};\n/* End PBXShellScriptBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\t40899F400FFA7184000B29AE /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40899F530FFA72A0000B29AE /* gtest_unittest.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4089A0100FFACEFC000B29AE /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4089A0440FFAD1BE000B29AE /* sample1.cc in Sources */,\n\t\t\t\t4089A0460FFAD1BE000B29AE /* sample1_unittest.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t40C848F7101A209C0083642A /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C848FF101A21150083642A /* gtest-all.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t40C84908101A217E0083642A /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C84915101A21DF0083642A /* gtest_main.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t40C8497F101A36850083642A /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C84980101A36850083642A /* gtest_unittest.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t40C8498E101A36A60083642A /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C8498F101A36A60083642A /* sample1.cc in Sources */,\n\t\t\t\t40C84990101A36A60083642A /* sample1_unittest.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t8D07F2C10486CC7A007CD1D0 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40899F3A0FFA70D4000B29AE /* gtest-all.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin PBXTargetDependency section */\n\t\t40899F9D0FFA740F000B29AE /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40899F420FFA7184000B29AE /* gtest_unittest-framework */;\n\t\t\ttargetProxy = 40899F9C0FFA740F000B29AE /* PBXContainerItemProxy */;\n\t\t};\n\t\t4089A0980FFAD34A000B29AE /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 4089A0120FFACEFC000B29AE /* sample1_unittest-framework */;\n\t\t\ttargetProxy = 4089A0970FFAD34A000B29AE /* PBXContainerItemProxy */;\n\t\t};\n\t\t408BEC101046CFE900DEF522 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C848F9101A209C0083642A /* gtest-static */;\n\t\t\ttargetProxy = 408BEC0F1046CFE900DEF522 /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C44AE60E379922008FCC51 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C44ADC0E3798F4008FCC51 /* Version Info */;\n\t\t\ttargetProxy = 40C44AE50E379922008FCC51 /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C8497B101A36850083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C848F9101A209C0083642A /* gtest-static */;\n\t\t\ttargetProxy = 40C8497C101A36850083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C8497D101A36850083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C8490A101A217E0083642A /* gtest_main-static */;\n\t\t\ttargetProxy = 40C8497E101A36850083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C8498A101A36A60083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C848F9101A209C0083642A /* gtest-static */;\n\t\t\ttargetProxy = 40C8498B101A36A60083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C8498C101A36A60083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C8490A101A217E0083642A /* gtest_main-static */;\n\t\t\ttargetProxy = 40C8498D101A36A60083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C8499C101A36DC0083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C8490A101A217E0083642A /* gtest_main-static */;\n\t\t\ttargetProxy = 40C8499B101A36DC0083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C8499E101A36E50083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 8D07F2BC0486CC7A007CD1D0 /* gtest-framework */;\n\t\t\ttargetProxy = 40C8499D101A36E50083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C849A0101A36F10083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 8D07F2BC0486CC7A007CD1D0 /* gtest-framework */;\n\t\t\ttargetProxy = 40C8499F101A36F10083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C849F7101A43440083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C8497A101A36850083642A /* gtest_unittest-static */;\n\t\t\ttargetProxy = 40C849F6101A43440083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C849F9101A43490083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C84989101A36A60083642A /* sample1_unittest-static */;\n\t\t\ttargetProxy = 40C849F8101A43490083642A /* PBXContainerItemProxy */;\n\t\t};\n/* End PBXTargetDependency section */\n\n/* Begin XCBuildConfiguration section */\n\t\t3B238F600E828B5400846E11 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tPRODUCT_NAME = Check;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t3B238F610E828B5400846E11 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tCOPY_PHASE_STRIP = YES;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tPRODUCT_NAME = Check;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t\tZERO_LINK = NO;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t40899F450FFA7185000B29AE /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = ../;\n\t\t\t\tPRODUCT_NAME = \"gtest_unittest-framework\";\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t40899F460FFA7185000B29AE /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = ../;\n\t\t\t\tPRODUCT_NAME = \"gtest_unittest-framework\";\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4089A0150FFACEFD000B29AE /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tPRODUCT_NAME = \"sample1_unittest-framework\";\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4089A0160FFACEFD000B29AE /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tPRODUCT_NAME = \"sample1_unittest-framework\";\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t40C44ADF0E3798F4008FCC51 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.7;\n\t\t\t\tPRODUCT_NAME = gtest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t\tTARGET_NAME = gtest;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t40C44AE00E3798F4008FCC51 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.7;\n\t\t\t\tPRODUCT_NAME = gtest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t\tTARGET_NAME = gtest;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t40C848FB101A209D0083642A /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tGCC_INLINES_ARE_PRIVATE_EXTERN = YES;\n\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = YES;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t../,\n\t\t\t\t\t../include/,\n\t\t\t\t);\n\t\t\t\tPRODUCT_NAME = gtest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t40C848FC101A209D0083642A /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tGCC_INLINES_ARE_PRIVATE_EXTERN = YES;\n\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = YES;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t../,\n\t\t\t\t\t../include/,\n\t\t\t\t);\n\t\t\t\tPRODUCT_NAME = gtest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t40C8490E101A217F0083642A /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t../,\n\t\t\t\t\t../include/,\n\t\t\t\t);\n\t\t\t\tPRODUCT_NAME = gtest_main;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t40C8490F101A217F0083642A /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t../,\n\t\t\t\t\t../include/,\n\t\t\t\t);\n\t\t\t\tPRODUCT_NAME = gtest_main;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t40C84985101A36850083642A /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = ../;\n\t\t\t\tPRODUCT_NAME = gtest_unittest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t40C84986101A36850083642A /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = ../;\n\t\t\t\tPRODUCT_NAME = gtest_unittest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t40C84995101A36A60083642A /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tPRODUCT_NAME = \"sample1_unittest-static\";\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t40C84996101A36A60083642A /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tPRODUCT_NAME = \"sample1_unittest-static\";\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4FADC24308B4156D00ABE55E /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40D4CDF20E30E07400294801 /* FrameworkTarget.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tDYLIB_COMPATIBILITY_VERSION = 1;\n\t\t\t\tDYLIB_CURRENT_VERSION = 1;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t../,\n\t\t\t\t\t../include/,\n\t\t\t\t);\n\t\t\t\tINFOPLIST_FILE = Resources/Info.plist;\n\t\t\t\tINFOPLIST_PREFIX_HEADER = \"$(PROJECT_TEMP_DIR)/Version.h\";\n\t\t\t\tINFOPLIST_PREPROCESS = YES;\n\t\t\t\tPRODUCT_NAME = gtest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t\tVERSIONING_SYSTEM = \"apple-generic\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4FADC24408B4156D00ABE55E /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40D4CDF20E30E07400294801 /* FrameworkTarget.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tDYLIB_COMPATIBILITY_VERSION = 1;\n\t\t\t\tDYLIB_CURRENT_VERSION = 1;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t../,\n\t\t\t\t\t../include/,\n\t\t\t\t);\n\t\t\t\tINFOPLIST_FILE = Resources/Info.plist;\n\t\t\t\tINFOPLIST_PREFIX_HEADER = \"$(PROJECT_TEMP_DIR)/Version.h\";\n\t\t\t\tINFOPLIST_PREPROCESS = YES;\n\t\t\t\tPRODUCT_NAME = gtest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t\tVERSIONING_SYSTEM = \"apple-generic\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4FADC24708B4156D00ABE55E /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40D4CDF10E30E07400294801 /* DebugProject.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4FADC24808B4156D00ABE55E /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40D4CDF40E30E07400294801 /* ReleaseProject.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\t3B238FA30E828BB600846E11 /* Build configuration list for PBXAggregateTarget \"Check\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t3B238F600E828B5400846E11 /* Debug */,\n\t\t\t\t3B238F610E828B5400846E11 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t40899F4A0FFA71BC000B29AE /* Build configuration list for PBXNativeTarget \"gtest_unittest-framework\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t40899F450FFA7185000B29AE /* Debug */,\n\t\t\t\t40899F460FFA7185000B29AE /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4089A0240FFACF01000B29AE /* Build configuration list for PBXNativeTarget \"sample1_unittest-framework\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4089A0150FFACEFD000B29AE /* Debug */,\n\t\t\t\t4089A0160FFACEFD000B29AE /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t40C44AE40E379905008FCC51 /* Build configuration list for PBXAggregateTarget \"Version Info\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t40C44ADF0E3798F4008FCC51 /* Debug */,\n\t\t\t\t40C44AE00E3798F4008FCC51 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t40C84902101A212E0083642A /* Build configuration list for PBXNativeTarget \"gtest-static\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t40C848FB101A209D0083642A /* Debug */,\n\t\t\t\t40C848FC101A209D0083642A /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t40C84912101A21D20083642A /* Build configuration list for PBXNativeTarget \"gtest_main-static\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t40C8490E101A217F0083642A /* Debug */,\n\t\t\t\t40C8490F101A217F0083642A /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t40C84984101A36850083642A /* Build configuration list for PBXNativeTarget \"gtest_unittest-static\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t40C84985101A36850083642A /* Debug */,\n\t\t\t\t40C84986101A36850083642A /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t40C84994101A36A60083642A /* Build configuration list for PBXNativeTarget \"sample1_unittest-static\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t40C84995101A36A60083642A /* Debug */,\n\t\t\t\t40C84996101A36A60083642A /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4FADC24208B4156D00ABE55E /* Build configuration list for PBXNativeTarget \"gtest-framework\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4FADC24308B4156D00ABE55E /* Debug */,\n\t\t\t\t4FADC24408B4156D00ABE55E /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4FADC24608B4156D00ABE55E /* Build configuration list for PBXProject \"gtest\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4FADC24708B4156D00ABE55E /* Debug */,\n\t\t\t\t4FADC24808B4156D00ABE55E /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = 0867D690FE84028FC02AAC07 /* Project object */;\n}\n"
  },
  {
    "path": "utils/hacks/query-run/query-filter.py",
    "content": "#!/usr/bin/env python\n# vim: set sw=4 ts=4 softtabstop=4 expandtab:\nimport argparse\nimport logging\nimport os\nimport pprint\nimport re\nimport sys\nimport yaml\n\n_logger = None\n\nif hasattr(yaml, 'CLoader'):\n    # Use libyaml which is faster\n    _loader = yaml.CLoader\nelse:\n    _loader = yaml.Loader\n\n###############################################################################\n# Filters\n###############################################################################\n\ndef filter_only_sat_type(run_info, satisfiable):\n    _logger.info('Keeping only results that has sat: {}'.format(satisfiable))\n    original_count = len(run_info.keys())\n    assert satisfiable is None or isinstance(satisfiable, bool)\n    sat_runs = { k:v for (k, v) in run_info.items() if v['sat'] is satisfiable }\n    assert isinstance(sat_runs, dict)\n    _logger.info('Removed {} queries'.format(original_count - len(sat_runs.keys())))\n    return sat_runs\n\ndef _filter_n_speed(run_info, n, slowest):\n    assert isinstance(run_info, dict)\n    assert isinstance(n, int)\n    assert isinstance(slowest, bool)\n    runs_ordered_by_run_time = sorted(runs_info.items(), key=lambda t: t[1]['wallclock_time'])\n    if slowest:\n        runs_ordered_by_run_time_slowest_first = runs_ordered_by_run_time.reverse()\n    if n < len(runs_ordered_by_run_time_slowest_first):\n        runs_ordered_by_run_time_slowest_first = runs_ordered_by_run_time[:n]\n    # Make into dictionary again\n    d = dict(runs_ordered_by_run_time_slowest_first)\n    assert isinstance(d, dict)\n    return d\n\ndef filter_gt_exec_time(run_info, min_time):\n    _logger.info('Keeping only results that had exec time >= {}'.format(min_time))\n    assert isinstance(run_info, dict)\n    assert isinstance(min_time, float)\n    original_count = len(run_info.keys())\n    d = dict()\n    for query_name, data in run_info.items():\n        exec_time = data['wallclock_time']\n        if exec_time >= min_time:\n            d[query_name] = data\n    _logger.info('Removed {} queries'.format(original_count - len(d.keys())))\n    return d\n\ndef filter_lt_exec_time(run_info, max_time):\n    _logger.info('Keeping only results that had exec time < {}'.format(max_time))\n    assert isinstance(run_info, dict)\n    assert isinstance(max_time, float)\n    original_count = len(run_info.keys())\n    d = dict()\n    for query_name, data in run_info.items():\n        exec_time = data['wallclock_time']\n        if exec_time < max_time:\n            d[query_name] = data\n    _logger.info('Removed {} queries'.format(original_count - len(d.keys())))\n    return d\n\ndef filter_n_slowest(run_info, n):\n    _logger.info('Keeping only {} slowest queries: {}'.format(n))\n    original_count = len(run_info.keys())\n    r = _filter_n_speed(run_info, n, slowest=True)\n    _logger.info('Removed {} queries'.format(original_count - len(r.keys())))\n    return r\n\ndef filter_n_fastest(run_info, n):\n    _logger.info('Keeping only {} fastest queries: {}'.format(n))\n    original_count = len(run_info.keys())\n    r = _filter_n_speed(run_info, n, slowest=False)\n    _logger.info('Removed {} queries'.format(original_count - len(r.keys())))\n    return r\n\ndef filter_has_array_decls(run_info, queries_root_dir):\n    _logger.info('Keeping only queries that have array decls')\n    original_count = len(run_info.keys())\n    assert isinstance(run_info, dict)\n    # Match (declare-fun a1 () (Array (_ BitVec 32) (_ BitVec 8)))\n    RE_ARRAY_DECL = re.compile(r'^\\s*\\(\\s*declare-fun\\s.+\\(Array')\n    RE_DECLS_END = re.compile(r'^\\s*\\(\\s*assert')\n    RE_DECL = re.compile(r'^\\s*\\(\\s*declare-fun')\n    array_use = dict()\n    for query_name, data in run_info.items():\n        query_path = os.path.join(queries_root_dir, query_name)\n        if not os.path.exists(query_path):\n            _logger.error('Could not find query \"{}\"'.format(query_path))\n            return 1\n        decls_found = False\n        with open(query_path, 'r') as f:\n            _logger.debug('Loaded \"{}\"'.format(f.name))\n            handled = False\n            for line in f:\n                if not decls_found and RE_DECL.match(line):\n                    # Contains at least one decl\n                    decls_found = True\n                if RE_ARRAY_DECL.match(line):\n                    # Uses array\n                    array_use[query_name] = data\n                    handled = True\n                    break\n                if RE_DECLS_END.match(line):\n                    # Try to early exit from scanning lines\n                    handled = True\n                    break\n            if not handled:\n                # Not handling should only happen if the benchmark contains no decls\n                assert not decls_found\n    assert isinstance(array_use, dict)\n    _logger.info('Removed {} queries'.format(original_count - len(array_use.keys())))\n    return array_use\n\ndef filter_has_no_array_decls(run_info, queries_root_dir):\n    _logger.info('Keeping only queries that do not have array decls')\n    original_count = len(run_info.keys())\n    assert isinstance(run_info, dict)\n    # Match (declare-fun a1 () (Array (_ BitVec 32) (_ BitVec 8)))\n    RE_ARRAY_DECL = re.compile(r'^\\s*\\(\\s*declare-fun\\s.+\\(Array')\n    RE_DECLS_END = re.compile(r'^\\s*\\(\\s*assert')\n    RE_DECL = re.compile(r'^\\s*\\(\\s*declare-fun')\n    not_array_use = dict()\n    for query_name, data in run_info.items():\n        query_path = os.path.join(queries_root_dir, query_name)\n        if not os.path.exists(query_path):\n            _logger.error('Could not find query \"{}\"'.format(query_path))\n            return 1\n        with open(query_path, 'r') as f:\n            _logger.debug('Loaded \"{}\"'.format(f.name))\n            found_array_decl = False\n            for line in f:\n                if RE_ARRAY_DECL.match(line):\n                    # Uses array\n                    found_array_decl = True\n                    break\n                if RE_DECLS_END.match(line):\n                    # Try to early exit from scanning lines\n                    break\n            if not found_array_decl:\n                not_array_use[query_name] = data\n    assert isinstance(not_array_use, dict)\n    _logger.info('Removed {} queries'.format(original_count - len(not_array_use.keys())))\n    return not_array_use\n\ndef filter_decls(run_info, queries_root_dir):\n    _logger.info('Keeping only queries that have decls')\n    original_count = len(run_info.keys())\n    assert isinstance(run_info, dict)\n    # Match (declare-fun a1 () (Array (_ BitVec 32) (_ BitVec 8)))\n    RE_DECL = re.compile(r'^\\s*\\(\\s*declare-fun')\n    RE_DECLS_END = re.compile(r'^\\s*\\(\\s*assert')\n    use_decl = dict()\n    for query_name, data in run_info.items():\n        query_path = os.path.join(queries_root_dir, query_name)\n        if not os.path.exists(query_path):\n            _logger.error('Could not find query \"{}\"'.format(query_path))\n            return 1\n        with open(query_path, 'r') as f:\n            _logger.debug('Loaded \"{}\"'.format(f.name))\n            found_decl = False\n            for line in f:\n                if RE_DECL.match(line):\n                    # Found a decl\n                    found_decl = True\n                    break\n                if RE_DECLS_END.match(line):\n                    # Try to early exit from scanning lines\n                    break\n            if found_decl:\n                use_decl[query_name] = data\n    assert isinstance(use_decl, dict)\n    _logger.info('Removed {} queries'.format(original_count - len(use_decl.keys())))\n    return use_decl\n\ndef filter_no_decls(run_info, queries_root_dir):\n    _logger.info('Keeping only queries that have no decls')\n    original_count = len(run_info.keys())\n    assert isinstance(run_info, dict)\n    # Match (declare-fun a1 () (Array (_ BitVec 32) (_ BitVec 8)))\n    RE_DECL = re.compile(r'^\\s*\\(\\s*declare-fun')\n    RE_DECLS_END = re.compile(r'^\\s*\\(\\s*assert')\n    no_use_decl = dict()\n    for query_name, data in run_info.items():\n        query_path = os.path.join(queries_root_dir, query_name)\n        if not os.path.exists(query_path):\n            _logger.error('Could not find query \"{}\"'.format(query_path))\n            return 1\n        with open(query_path, 'r') as f:\n            _logger.debug('Loaded \"{}\"'.format(f.name))\n            found_decl = False\n            for line in f:\n                if RE_DECL.match(line):\n                    # Found a decl\n                    found_decl = True\n                    break\n                if RE_DECLS_END.match(line):\n                    # Try to early exit from scanning lines\n                    break\n            if not found_decl:\n                no_use_decl[query_name] = data\n    assert isinstance(no_use_decl, dict)\n    _logger.info('Removed {} queries'.format(original_count - len(no_use_decl.keys())))\n    return no_use_decl\n\ndef filter_uses_fp_to_ieee_bv(run_info, queries_root_dir):\n    _logger.info('Keeping only queries that use fp.to_ieee_bv')\n    original_count = len(run_info.keys())\n    assert isinstance(run_info, dict)\n    RE_USE_IEEE = re.compile(r'\\(fp.to_ieee_bv')\n    use_ieee_bv = dict()\n    for query_name, data in run_info.items():\n        query_path = os.path.join(queries_root_dir, query_name)\n        if not os.path.exists(query_path):\n            _logger.error('Could not find query \"{}\"'.format(query_path))\n            return 1\n        with open(query_path, 'r') as f:\n            _logger.debug('Loaded \"{}\"'.format(f.name))\n            found_decl = False\n            for line in f:\n                if RE_USE_IEEE.search(line):\n                    use_ieee_bv[query_name] = data\n                    break\n    assert isinstance(use_ieee_bv, dict)\n    _logger.info('Removed {} queries'.format(original_count - len(use_ieee_bv.keys())))\n    return use_ieee_bv\n\ndef filter_uses_qf_fpbv(run_info, queries_root_dir):\n    # FIXME: This isn't quite right. We aren't filtering out stuff like reals and quantifiers\n    # FIXME: We aren't checking for bitvector operations/sorts.\n    _logger.info('Keeping only queries that use QF_FPBV')\n    original_count = len(run_info.keys())\n\n    # First keep only queries that have declarations. We don't want empty queries\n    temp_run_info = filter_decls(run_info, queries_root_dir)\n\n    # Filter out queries that have arrays\n    temp_run_info2 = filter_has_no_array_decls(temp_run_info, queries_root_dir)\n\n    # Keep only queries that use the floating point theory\n    temp_run_info3 = filter_uses_floating_point_theory(temp_run_info2, queries_root_dir)\n\n    _logger.info('Removed {} queries'.format(original_count - len(temp_run_info3.keys())))\n    return temp_run_info3\n\ndef filter_uses_qf_fpabv(run_info, queries_root_dir):\n    # FIXME: This isn't quite right. We aren't filtering out stuff like reals and quantifiers\n    # FIXME: We aren't checking for bitvector operations/sorts.\n    _logger.info('Keeping only queries that use QF_FPABV')\n    original_count = len(run_info.keys())\n\n    # First keep only queries that have declarations. We don't want empty queries\n    temp_run_info = filter_decls(run_info, queries_root_dir)\n\n    # Keep queries that declare arrays\n    temp_run_info2 = filter_has_array_decls(temp_run_info, queries_root_dir)\n\n    # Keep only queries that use the floating point theory\n    temp_run_info3 = filter_uses_floating_point_theory(temp_run_info2, queries_root_dir)\n\n    _logger.info('Removed {} queries'.format(original_count - len(temp_run_info3.keys())))\n    return temp_run_info3\n\ndef filter_non_zero_exit_code(run_info, queries_root_dir):\n    _logger.info('Keeping only queries with non-zero exit code')\n    original_count = len(run_info.keys())\n    non_zero_ec = dict()\n    for query_name, data in run_info.items():\n        if data['exit_code'] != 0:\n            non_zero_ec[query_name] = data\n    _logger.info('Removed {} queries'.format(original_count - len(non_zero_ec.keys())))\n    return non_zero_ec\n\n\ndef filter_uses_floating_point_theory(run_info, queries_root_dir):\n    _logger.info('Keeping only queries that use floating point theory')\n    original_count = len(run_info.keys())\n    assert isinstance(run_info, dict)\n    # We look for fp constants, fp declarations and conversions to fp sorts\n    # as indicators that floating point is being used\n    RE_FP_CONSTANTS = re.compile(\n        r'(\\(_ +oo \\d+ \\d+\\))|'\n        r'(\\(_ -oo \\d+ \\d+\\))|'\n        r'(\\(_ +zero \\d+ \\d+\\))|'\n        r'(\\(_ -zero \\d+ \\d+\\))|'\n        r'(\\(_ NaN \\d+ \\d+\\))|'\n        r'(\\(fp #b)'\n    )\n    RE_FP_DECL = re.compile(r'^\\s*\\(\\s*declare-fun\\s.+\\(_ FloatingPoint')\n    RE_FP_CONV = re.compile(r'\\(_ to_fp')\n    use_fp = dict()\n    for query_name, data in run_info.items():\n        query_path = os.path.join(queries_root_dir, query_name)\n        if not os.path.exists(query_path):\n            _logger.error('Could not find query \"{}\"'.format(query_path))\n            return 1\n        with open(query_path, 'r') as f:\n            #_logger.debug('Loaded \"{}\"'.format(f.name))\n            match_found = False\n            for line in f:\n                if RE_FP_DECL.match(line):\n                    match_found = True\n                if RE_FP_CONSTANTS.search(line):\n                    match_found = True\n                if RE_FP_CONV.search(line):\n                    match_found = True\n                if match_found:\n                    use_fp[query_name] = data\n                    break\n            if not match_found:\n                _logger.debug('\"{}\" does not seem to use fp'.format(query_name))\n    assert isinstance(use_fp, dict)\n    _logger.info('Removed {} queries'.format(original_count - len(use_fp.keys())))\n    return use_fp\n\n# Entry point\ndef main(args):\n    global _logger\n    parser = argparse.ArgumentParser(description=__doc__)\n    parser.add_argument(\"-l\", \"--log-level\", type=str, default=\"info\",\n                        dest=\"log_level\",\n                        choices=['debug', 'info', 'warning', 'error'])\n    parser.add_argument(\"--log-file\",\n                        dest='log_file',\n                        type=str,\n                        default=None,\n                        help=\"Log to specified file\")\n    parser.add_argument(\"--log-only-file\",\n                        dest='log_only_file',\n                        action='store_true',\n                        default=False,\n                        help='Only log to file specified by --log-file and not the console')\n    parser.add_argument(\"--filter\",\n        choices= [\n            \"sat\",\n            \"slowest\",\n            \"fastest\",\n            \"has_array_decls\",\n            \"no_array_decls\",\n            \"has_decls\",\n            \"no_decls\",\n            \"min_exec_time\",\n            \"max_exec_time\",\n            \"uses_fp_to_ieee_bv\",\n            \"uses_fp_theory\",\n            \"uses_qf_fpbv\",\n            \"uses_qf_fpabv\",\n            \"non_zero_exit_code\",\n        ],\n        default=[],\n        action='append',\n    )\n    parser.add_argument(\"--min-exec-time\",\n        dest=\"min_exec_time\",\n        type=float,\n        default=20.0,\n        help='The minimum execution time to use for min_exec_time filter',\n    )\n    parser.add_argument(\"--max-exec-time\",\n        dest=\"max_exec_time\",\n        type=float,\n        default=20.0,\n        help='The maximum execution time to use for max_exec_time filter',\n    )\n    parser.add_argument(\"--sat\",\n        choices=['sat','unsat','unknown'],\n        default='sat',\n        help='When using sat filter keep only queries with this answer',\n    )\n    parser.add_argument(\"--num-slowest\",\n        dest=\"num_slowest\",\n        default=10,\n        help=\"Number of results to keep that are slowest\"\n    )\n    parser.add_argument(\"--num-fastest\",\n        dest=\"num_fastest\",\n        default=10,\n        help=\"Number of results to keep that are fastest\"\n    )\n    parser.add_argument(\"--queries-root-dir\",\n        dest=\"queries_root_dir\",\n        default=os.path.join(os.getcwd(), \"queries\"),\n    )\n    parser.add_argument(\"queries_yaml_file\",\n        type=argparse.FileType('r')\n    )\n    parser.add_argument(\"-o\", \"--output-yaml-file\",\n        dest='output_yaml_file',\n        type=argparse.FileType('w'),\n        default=sys.stdout,\n    )\n    pargs = parser.parse_args(args)\n\n    # Handle logging\n    logLevel = getattr(logging, pargs.log_level.upper(), None)\n    if logLevel == logging.DEBUG:\n        logFormat = ('%(levelname)s:%(threadName)s: %(filename)s:%(lineno)d '\n                     '%(funcName)s()  : %(message)s')\n    else:\n        logFormat = '%(levelname)s:%(threadName)s: %(message)s'\n\n    if not pargs.log_only_file:\n        # Add default console level with appropriate formatting and level.\n        logging.basicConfig(level=logLevel, format=logFormat)\n    else:\n        if pargs.log_file is None:\n            parser.error('--log-file-only must be used with --log-file')\n        logging.getLogger().setLevel(logLevel)\n    if pargs.log_file is not None:\n        file_handler = logging.FileHandler(pargs.log_file)\n        log_formatter = logging.Formatter(logFormat)\n        file_handler.setFormatter(log_formatter)\n        logging.getLogger().addHandler(file_handler)\n    _logger = logging.getLogger(__name__)\n\n    # Open queries\n    _logger.info('Loading \"{}\"'.format(pargs.queries_yaml_file.name))\n    queries_data = yaml.load(pargs.queries_yaml_file, Loader=_loader)\n    _logger.info('Finished loading')\n\n    run_info = queries_data['run_info']\n    original_length = len(run_info.keys())\n    _logger.info('Input has {} queries'.format(original_length))\n\n    assert isinstance(run_info, dict)\n    # Go through filters and apply them\n    for filter_ty in pargs.filter:\n        if filter_ty == 'sat':\n            sat_type = None\n            if pargs.sat == 'sat':\n                sat_type = True\n            elif pargs.sat == 'unsat':\n                sat_type = False\n            run_info = filter_only_sat_type(run_info, sat_type)\n        elif filter_ty == 'slowest':\n            run_info = filter_n_slowest(run_info, pargs.num_slowest)\n        elif filter_ty == 'fastest':\n            run_info = filter_n_fastest(run_info, pargs.num_fastest)\n        elif filter_ty == 'has_array_decls':\n            run_info = filter_has_array_decls(run_info, pargs.queries_root_dir)\n        elif filter_ty == 'no_array_decls':\n            run_info = filter_has_no_array_decls(run_info, pargs.queries_root_dir)\n        elif filter_ty == 'has_decls':\n            run_info = filter_decls(run_info, pargs.queries_root_dir)\n        elif filter_ty == 'no_decls':\n            run_info = filter_no_decls(run_info, pargs.queries_root_dir)\n        elif filter_ty == 'min_exec_time':\n            run_info = filter_gt_exec_time(run_info, pargs.min_exec_time)\n        elif filter_ty == 'max_exec_time':\n            run_info = filter_lt_exec_time(run_info, pargs.max_exec_time)\n        elif filter_ty == 'uses_fp_to_ieee_bv':\n            run_info = filter_uses_fp_to_ieee_bv(run_info, pargs.queries_root_dir)\n        elif filter_ty == 'uses_fp_theory':\n            run_info = filter_uses_floating_point_theory(run_info, pargs.queries_root_dir)\n        elif filter_ty == 'uses_qf_fpbv':\n            run_info = filter_uses_qf_fpbv(run_info, pargs.queries_root_dir)\n        elif filter_ty == 'uses_qf_fpabv':\n            run_info = filter_uses_qf_fpabv(run_info, pargs.queries_root_dir)\n        elif filter_ty == 'non_zero_exit_code':\n            run_info = filter_non_zero_exit_code(run_info, pargs.queries_root_dir)\n        else:\n            raise Exception('Unhandled filter \"{}\"'.format(filter_ty))\n        assert isinstance(run_info, dict)\n\n    queries_data['run_info'] = run_info\n    new_length = len(run_info.keys())\n    _logger.info('Final Output has {} queries'.format(new_length))\n    _logger.info('{} queries removed in total'.format(original_length - new_length))\n\n    # Write result out\n    raw_text = yaml.dump(queries_data, default_flow_style=False)\n    pargs.output_yaml_file.write(raw_text)\n    pargs.output_yaml_file.close()\n    return 0\n\nif __name__ == '__main__':\n    sys.exit(main(sys.argv[1:]))\n\n"
  },
  {
    "path": "utils/hacks/query-run/query-info.py",
    "content": "#!/usr/bin/env python\n# vim: set sw=4 ts=4 softtabstop=4 expandtab:\nimport argparse\nimport logging\nimport os\nimport pprint\nimport re\nimport sys\nimport yaml\n\n_logger = None\n\nif hasattr(yaml, 'CLoader'):\n    # Use libyaml which is faster\n    _loader = yaml.CLoader\nelse:\n    _loader = yaml.Loader\n\ndef main(args):\n    global _logger\n    parser = argparse.ArgumentParser(description=__doc__)\n    parser.add_argument(\"-l\", \"--log-level\", type=str, default=\"info\",\n                        dest=\"log_level\",\n                        choices=['debug', 'info', 'warning', 'error'])\n    parser.add_argument(\"--log-file\",\n                        dest='log_file',\n                        type=str,\n                        default=None,\n                        help=\"Log to specified file\")\n    parser.add_argument(\"--log-only-file\",\n                        dest='log_only_file',\n                        action='store_true',\n                        default=False,\n                        help='Only log to file specified by --log-file and not the console')\n    parser.add_argument(\"--analyse\",\n        choices=['all','sat','unsat','unknown'],\n        default='all',\n        help='Select group of queries for analysis',\n    )\n    parser.add_argument(\"--num-results\",\n        dest=\"num_results\",\n        default=10,\n        help=\"Number of results to display as slowest and fastest\"\n    )\n    parser.add_argument(\"--plot\",\n        default=False,\n        action='store_true'\n    )\n    parser.add_argument(\"--check-fp-to-ieeebv\",\n        dest=\"check_fp_to_ieeebv\",\n        default=False,\n        action='store_true'\n    )\n    parser.add_argument(\"--count-array-free\",\n        dest=\"count_array_free\",\n        default=False,\n        action='store_true',\n        help='Count number of benchmarks that do not use arrays',\n    )\n    parser.add_argument(\"--plot-bins\",\n        type=int,\n        dest='plot_number_of_bins',\n        default=100,\n        help='Number of bins for histogram plot'\n    )\n    parser.add_argument(\"--queries-root-dir\",\n        dest=\"queries_root_dir\",\n        default=os.path.join(os.getcwd(), \"queries\"),\n    )\n    parser.add_argument(\"queries_yaml_file\",\n        type=argparse.FileType('r')\n    )\n    pargs = parser.parse_args(args)\n\n    # Handle logging\n    logLevel = getattr(logging, pargs.log_level.upper(), None)\n    if logLevel == logging.DEBUG:\n        logFormat = ('%(levelname)s:%(threadName)s: %(filename)s:%(lineno)d '\n                     '%(funcName)s()  : %(message)s')\n    else:\n        logFormat = '%(levelname)s:%(threadName)s: %(message)s'\n\n    if not pargs.log_only_file:\n        # Add default console level with appropriate formatting and level.\n        logging.basicConfig(level=logLevel, format=logFormat)\n    else:\n        if pargs.log_file is None:\n            parser.error('--log-file-only must be used with --log-file')\n        logging.getLogger().setLevel(logLevel)\n    if pargs.log_file is not None:\n        file_handler = logging.FileHandler(pargs.log_file)\n        log_formatter = logging.Formatter(logFormat)\n        file_handler.setFormatter(log_formatter)\n        logging.getLogger().addHandler(file_handler)\n    _logger = logging.getLogger(__name__)\n\n    # Open queries\n    _logger.info('Loading \"{}\"'.format(pargs.queries_yaml_file.name))\n    queries_data = yaml.load(pargs.queries_yaml_file, Loader=_loader)\n    _logger.info('Finished loading')\n\n    run_info = queries_data['run_info']\n    assert isinstance(run_info, dict)\n\n    # Collect sat/unsat/unknown runs\n    sat_runs = { k:v for (k, v) in run_info.items() if v['sat'] is True }\n    unsat_runs = { k:v for (k, v) in run_info.items() if v['sat'] is False }\n    unknown_runs = { k:v for (k, v) in run_info.items() if v['sat'] is None }\n    print(\"# of queries: {}\".format(len(run_info.keys())))\n    print(\"# of sat queries: {}\".format(len(sat_runs)))\n    print(\"# of unsat queries: {}\".format(len(unsat_runs)))\n    print(\"# of unknown queries: {}\".format(len(unknown_runs)))\n\n    if pargs.check_fp_to_ieeebv:\n        uses_fp_to_ieeebv = set()\n        for query_name, data in unknown_runs.items():\n            query_path = os.path.join(pargs.queries_root_dir, query_name)\n            if not os.path.exists(query_path):\n                _logger.error('Could not find query \"{}\"'.format(query_path))\n                return 1\n            with open(query_path, 'r') as f:\n                for line in f:\n                    if line.find('(fp.to_ieee_bv') != -1:\n                        uses_fp_to_ieeebv.add(query_name)\n                        break\n        print(\"# of unknown queries that use fp.to_ieee_bv: {}\".format(len(uses_fp_to_ieeebv)))\n        # Compute queries that where unknown that don't use this function\n        queries_result_unknown_not_use_fp_to_ieee_bv = set(unknown_runs.keys()).difference(uses_fp_to_ieeebv)\n        print(\"# of unknown queries that does not use fp.to_ieee_bv: {}\".format(len(queries_result_unknown_not_use_fp_to_ieee_bv)))\n        for q in queries_result_unknown_not_use_fp_to_ieee_bv:\n            print(\"  {}:\\n{}\".format(q, pprint.pformat(run_info[q])))\n        print(\"#\"*80)\n\n\n    # Pick subset to analyse\n    runs_to_analyse = None\n    if pargs.analyse == 'all':\n        runs_to_analyse = run_info\n    elif pargs.analyse == 'sat':\n        runs_to_analyse = sat_runs\n    elif pargs.analyse == 'unsat':\n        runs_to_analyse = unsat_runs\n    elif pargs.analyse == 'unknown':\n        runs_to_analyse = unknown_runs\n    else:\n        raise Exception('Unhandled group to analyse: {}'.format(pargs.analyse))\n\n    if pargs.count_array_free:\n        _logger.info('Counting benchmarks using/not using arrays')\n        # Match (declare-fun a1 () (Array (_ BitVec 32) (_ BitVec 8)))\n        RE_ARRAY_DECL = re.compile(r'^\\s*\\(\\s*declare-fun\\s.+\\(Array')\n        RE_DECLS_END = re.compile(r'^\\s*\\(\\s*assert')\n        RE_DECL = re.compile(r'^\\s*\\(\\s*declare-fun')\n        no_array_use = set()\n        array_use = set()\n        no_decls = set()\n        for query_name, data in runs_to_analyse.items():\n            query_path = os.path.join(pargs.queries_root_dir, query_name)\n            if not os.path.exists(query_path):\n                _logger.error('Could not find query \"{}\"'.format(query_path))\n                return 1\n            decls_found = False\n            with open(query_path, 'r') as f:\n                _logger.debug('Loaded \"{}\"'.format(f.name))\n                handled = False\n                for line in f:\n                    if not decls_found and RE_DECL.match(line):\n                        # Contains at least one decl\n                        decls_found = True\n                    if RE_ARRAY_DECL.match(line):\n                        # Uses array\n                        array_use.add(query_name)\n                        handled = True\n                        break\n                    if RE_DECLS_END.match(line):\n                        # If we've got this far we can't have seen any array declarations\n                        no_array_use.add(query_name)\n                        handled = True\n                        break\n                if not handled:\n                    # Not handling should only happen if the benchmark contains no decls\n                    assert not decls_found\n                    no_array_use.add(query_name)\n                if not decls_found:\n                    no_decls.add(query_name)\n\n        print(\"# of benchmarks not using arrays: {}\".format(len(no_array_use)))\n        print(\"# of benchmarks using arrays: {}\".format(len(array_use)))\n        print(\"# of benchmarks without decls: {}\".format(len(no_decls)))\n        no_array_use_but_has_delcs = no_array_use.difference(no_decls)\n        print(\"# of benchmarks not using arrays (but has decls): {}\".format(len(no_array_use_but_has_delcs)))\n\n    # Collect the fastest and slowest\n    runs_ordered_by_run_time = sorted(runs_to_analyse.items(), key=lambda t: t[1]['wallclock_time'])\n    runs_ordered_by_run_time_slowest_first = runs_ordered_by_run_time.copy()\n    runs_ordered_by_run_time_slowest_first.reverse()\n\n    print(\"#\"*80)\n    max_time = runs_ordered_by_run_time_slowest_first[0][1]['wallclock_time']\n    print(\"{} slowest queries:\".format(pargs.num_results))\n    for index in range(0, pargs.num_results):\n        key, value = runs_ordered_by_run_time_slowest_first[index]\n        print(\"{}:\\n{}\".format(key, pprint.pformat(value)))\n    print(\"#\"*80)\n    print(\"{} fastest queries:\".format(pargs.num_results))\n    for index in range(0, pargs.num_results):\n        key, value = runs_ordered_by_run_time[index]\n        print(\"{}:\\n{}\".format(key, pprint.pformat(value)))\n    print(\"#\"*80)\n\n    # Optional plotting\n    if pargs.plot:\n        plot_histogram(runs_to_analyse, pargs.plot_number_of_bins)\n    return 0\n\ndef plot_histogram(runs, nbins):\n    import matplotlib.pyplot as plt\n    execution_times = [ r['wallclock_time'] for r in runs.values() ]\n    min_exec = min(execution_times)\n    max_exec = max(execution_times)\n    bin_width = max_exec / nbins\n    _logger.info('Bin width: {}'.format(bin_width))\n    n, bins, patches = plt.hist(\n        execution_times,\n        bins=nbins,\n        range=(0, max_exec),\n    )\n    _logger.info('n: {}'.format(n))\n    _logger.info('bins: {}'.format(bins))\n    \n    plt.grid(True)\n    plt.xlabel('Execution Time (s)')\n    plt.ylabel('Count')\n    plt.show()\n\nif __name__ == '__main__':\n    sys.exit(main(sys.argv[1:]))\n\n"
  },
  {
    "path": "utils/hacks/query-run/run-queries.py",
    "content": "#!/usr/bin/env python\n# vim: set sw=4 ts=4 softtabstop=4 expandtab:\nimport argparse\nimport concurrent.futures\nimport datetime\nimport logging\nimport os\nimport pprint\nimport psutil\nimport random\nimport signal\nimport subprocess\nimport sys\nimport time\nimport yaml\n\"\"\"\nScript to run a set of queries found in directory and\nrecord their execution time and result.\n\"\"\"\n\n_logger = logging.getLogger(__name__)\n\n# HACK: http://stackoverflow.com/questions/26475636/measure-elapsed-time-amount-of-memory-and-cpu-used-by-the-extern-program\nclass ResourcePopen(subprocess.Popen):\n    def _try_wait(self, wait_flags):\n        \"\"\"All callers to this function MUST hold self._waitpid_lock.\"\"\"\n        try:\n            (pid, sts, res) = self._eintr_retry_call(os.wait4, self.pid, wait_flags)\n        except OSError as e:\n            if e.errno != errno.ECHILD:\n                raise\n            # This happens if SIGCLD is set to be ignored or waiting\n            # for child processes has otherwise been disabled for our\n            # process.  This child is dead, we can't get the status.\n            pid = self.pid\n            sts = 0\n            self.rusage = None\n        else:\n            self.rusage = res\n        return (pid, sts)\n\n    def _eintr_retry_call(self, func, *args):\n        while True:\n            try:\n                return func(*args)\n            except (OSError, IOError) as e:\n                if e.errno == errno.EINTR:\n                    continue\n                raise e\njobs = None\n\ndef handleInterrupt(signum, _):\n    global jobs\n    _logger.error('Received signal {}. Trying to kill jobs'.format(signum))\n    if jobs != None:\n        # Cancel any existing futures\n        for future in jobs.keys():\n            future.cancel()\n        # Now kill the runners\n        for runner in { j[0] for j in jobs.values()}:\n            runner.kill()\n\ndef main(args):\n    global jobs\n    parser = argparse.ArgumentParser(description=__doc__)\n    parser.add_argument(\"-l\", \"--log-level\", type=str, default=\"info\",\n                        dest=\"log_level\",\n                        choices=['debug', 'info', 'warning', 'error'])\n    parser.add_argument(\"--log-file\",\n                        dest='log_file',\n                        type=str,\n                        default=None,\n                        help=\"Log to specified file\")\n    parser.add_argument(\"--log-only-file\",\n                        dest='log_only_file',\n                        action='store_true',\n                        default=False,\n                        help='Only log to file specified by --log-file and not the console')\n    parser.add_argument(\n        \"-j\",\n        \"--jobs\",\n        type=int,\n        default=\"1\",\n        help=\"Number of jobs to run in parallel (Default %(default)s)\")\n    parser.add_argument(\n        \"--per-query-timeout\",\n        dest=\"per_query_timeout\",\n        type=float,\n        help=\"Per query timeout in seconds\",\n        default=0.0,\n    )\n    parser.add_argument(\n        \"--per-query-max-memory\",\n        dest=\"per_query_max_memory\",\n        help=\"Per query max memory usage in MiB\",\n        type=int,\n        default=0\n    )\n    parser.add_argument(\n        \"--solver-exe\",\n        type=str,\n        dest=\"solver_executable\",\n        default=\"/usr/bin/z3\",\n    )\n    parser.add_argument('--randomize-execution-order',\n        dest='randomize_execution_order',\n        action='store_true',\n    )\n    parser.add_argument(\"--runner\",\n        dest='runner',\n        default='z3',\n        choices=['z3', 'mathsat5', 'fake', 'jfs'],\n    )\n    parser.add_argument(\"query_dir\",\n        help=\"Directory to search for queries\")\n    parser.add_argument(\"yaml_output\", help=\"path to write YAML output to\")\n    pargs = parser.parse_args(args)\n\n\n    # Handle logging\n    logLevel = getattr(logging, pargs.log_level.upper(), None)\n    if logLevel == logging.DEBUG:\n        logFormat = ('%(levelname)s:%(threadName)s: %(filename)s:%(lineno)d '\n                     '%(funcName)s()  : %(message)s')\n    else:\n        logFormat = '%(levelname)s:%(threadName)s: %(message)s'\n\n    if not pargs.log_only_file:\n        # Add default console level with appropriate formatting and level.\n        logging.basicConfig(level=logLevel, format=logFormat)\n    else:\n        if pargs.log_file is None:\n            parser.error('--log-file-only must be used with --log-file')\n        logging.getLogger().setLevel(logLevel)\n    if pargs.log_file is not None:\n        file_handler = logging.FileHandler(pargs.log_file)\n        log_formatter = logging.Formatter(logFormat)\n        file_handler.setFormatter(log_formatter)\n        logging.getLogger().addHandler(file_handler)\n\n    if pargs.jobs <= 0:\n        _logger.error('jobs must be <= 0')\n        return 1\n\n    if os.path.exists(pargs.yaml_output):\n        _logger.error('\"{}\" already exists'.format(pargs.yaml_output))\n        return 1\n\n    # Check directory\n    if not os.path.isdir(pargs.query_dir):\n        _logger.error('\"{}\" is not a directory'.format(pargs.query_dir))\n        return 1\n\n    if not os.path.exists(pargs.solver_executable):\n        _logger.error('Could not find solver executable \"{}\"'.format(pargs.solver_executable))\n        return 1\n\n    start_time = time.monotonic()\n    start_date = datetime.datetime.now()\n\n    signal.signal(signal.SIGINT, handleInterrupt)\n    signal.signal(signal.SIGTERM, handleInterrupt)\n\n    # Collect queries\n    query_dir_root = os.path.abspath(pargs.query_dir)\n    query_files = set() # Relative to query_dir\n    for dirpath, _, filenames in os.walk(query_dir_root):\n        # Compute dir prefix\n        assert dirpath.startswith(query_dir_root)\n        prefix_path = dirpath[len(query_dir_root):]\n        if prefix_path.startswith(os.sep):\n            prefix_path = prefix_path[1:]\n        for f in sorted(filenames):\n            if not f.endswith('.smt2'):\n                _logger.debug('Skipping \"{}\";'.format(f))\n                continue\n            query_path = os.path.join(prefix_path, f)\n            _logger.info('Found \"{}\"'.format(query_path))\n            if query_path in query_files:\n                _logger.error('Found duplicate \"{}\"'.format(query_path))\n                return 1\n            query_files.add(query_path)\n    _logger.info('Found {} queries'.format(len(query_files)))\n\n    # Create Runners\n    runnerClass = None\n    if pargs.runner == 'z3':\n        runnerClass = Z3Runner\n    elif pargs.runner == 'mathsat5':\n        runnerClass = MathSat5Runner\n    elif pargs.runner == 'fake':\n        runnerClass = FakeRunner\n    elif pargs.runner == 'jfs':\n        runnerClass = JFSRunner\n    else:\n        _logger.error('Runner {} is not available'.format(pargs.runner))\n        return 1\n    run_info = {}\n    jobs = {}\n    ordered_query_files = None\n    if pargs.randomize_execution_order:\n        _logger.info('Randomizing execution order')\n        random.seed()\n        ordered_query_files = list(sorted(query_files))\n        random.shuffle(ordered_query_files)\n    else:\n        _logger.info('Using sorted execution order')\n        ordered_query_files = sorted(query_files)\n    try:\n        with concurrent.futures.ThreadPoolExecutor(max_workers=pargs.jobs) as executor:\n            # Submit jobs\n            for query in ordered_query_files:\n                query_file = os.path.join(query_dir_root, query)\n                _logger.info('Submitting \"{}\"'.format(query))\n                runner = runnerClass(\n                    pargs.solver_executable,\n                    query_file,\n                    pargs.per_query_timeout,\n                    pargs.per_query_max_memory\n                )\n                future = executor.submit(runner.run)\n                jobs[future] = (runner, query)\n            # Receive jobs\n            completed_jobs_count = 0\n            for future in concurrent.futures.as_completed(jobs):\n                query = jobs[future][1]\n                if future.done() and not future.cancelled():\n                    result = future.result()\n                    completed_jobs_count += 1\n                    _logger.info('\"{}\" completed ({}/{}, {:.2f}%)'.format(\n                        query,\n                        completed_jobs_count,\n                        len(jobs),\n                        100.0*(float(completed_jobs_count)/len(jobs)))\n                    )\n                    run_info[query] = result\n    except KeyboardInterrupt:\n        _logger.error('Keyboard interrupt')\n    except Exception as e:\n        raise e\n    finally:\n        # Stop catching signals and just use default handlers\n        signal.signal(signal.SIGINT, signal.SIG_DFL)\n        signal.signal(signal.SIGTERM, signal.SIG_DFL)\n\n\n    end_time = time.monotonic()\n    end_date = datetime.datetime.now()\n    run_time = end_time - start_time\n    _logger.info('Start date: {}'.format(start_date.isoformat(' ')))\n    _logger.info('End date: {}'.format(end_date.isoformat(' ')))\n    _logger.info('Run time: {} seconds'.format(run_time))\n\n    output_data = {\n        'start_date': start_date.isoformat(' '),\n        'end_date': end_date.isoformat(' '),\n        'run_time': run_time,\n        'run_info': run_info,\n    }\n\n    # Write results out\n    with open(pargs.yaml_output, 'w') as f:\n        raw_text = yaml.dump(output_data, default_flow_style=False)\n        f.write(raw_text)\n    return 0\n\n\nclass Z3Runner:\n    def __init__(self, executable, query, timeout, max_memory_mib):\n        assert isinstance(executable, str)\n        assert isinstance(query, str)\n        assert isinstance(timeout, float)\n        self.executable = executable\n        self.query = query\n        self.timeout = timeout\n        self.proc = None\n        self.max_memory_mib = max_memory_mib\n\n    def _run_info_default(self):\n        run_info = {\n            'exit_code': None,\n            'sat': None,\n            'user_time': None,\n            'sys_time': None,\n            'wallclock_time': None\n        }\n        return run_info\n\n    def run(self):\n        run_info = self._run_info_default()\n        cmd_line = [\n            self.executable,\n            '-smt2'\n        ]\n        if self.timeout > 0.0:\n            cmd_line.append( '-T:{}'.format(self.timeout))\n        if self.max_memory_mib > 0:\n            cmd_line.append('-memory:{}'.format(self.max_memory_mib))\n\n        cmd_line.append(self.query)\n\n        _logger.info('Running: {}'.format(cmd_line))\n        start_time = time.perf_counter()\n        self.proc = ResourcePopen(cmd_line, stdout=subprocess.PIPE)\n        stdout, _ = self.proc.communicate()\n        end_time = time.perf_counter()\n        stdout = stdout.decode()\n        _logger.info('Got \"{}\"'.format(stdout))\n        run_info['exit_code'] = self.proc.returncode\n        # Try to parse out result\n        run_info['sat'] = self.parse_smtlib_result(stdout)\n        try:\n            # Seconds\n            run_info['user_time'] = self.proc.rusage.ru_utime\n            run_info['sys_time'] = self.proc.rusage.ru_stime\n        except Exception:\n            pass\n        run_info['wallclock_time'] = end_time - start_time\n        _logger.info('Outcome: {}:\\n{}'.format(\n            self.query,\n            pprint.pformat(run_info)))\n        return run_info\n\n    def kill(self):\n        if self.proc != None:\n            self.proc.kill()\n\n    def parse_smtlib_result(self, stdout):\n        if stdout.startswith('sat'):\n            return True\n        elif stdout.startswith('unsat'):\n            return False\n        else:\n            return None\n\nclass MathSat5Runner(Z3Runner):\n    def run(self):\n        run_info = self._run_info_default()\n        cmd_line = [\n            self.executable,\n            '-input=smt2'\n        ]\n        if self.max_memory_mib > 0:\n            _logger.error('Forcing memory limit not supported')\n            raise Exception('Forcing memory limit not supported')\n\n        cmd_line.append(self.query)\n\n        _logger.info('Running: {}'.format(cmd_line))\n        start_time = time.perf_counter()\n        self.proc = ResourcePopen(cmd_line, stdout=subprocess.PIPE)\n        stdout = None\n        try:\n            # Mathsat5 doesn't have a timeout option so we have to\n            # enforce it outselves.\n            stdout, _ = self.proc.communicate(timeout=self.timeout if self.timeout > 0 else None)\n        except subprocess.TimeoutExpired as e:\n            _logger.error('Timeout occurred')\n            self.proc.kill()\n            self.proc.wait()\n        end_time = time.perf_counter()\n\n        run_info['exit_code'] = self.proc.returncode\n        if stdout:\n            stdout = stdout.decode()\n            _logger.info('Got \"{}\"'.format(stdout))\n            # Try to parse out result\n            run_info['sat'] = self.parse_smtlib_result(stdout)\n        else:\n            run_info['sat'] = None\n        try:\n            # Seconds\n            run_info['user_time'] = self.proc.rusage.ru_utime\n            run_info['sys_time'] = self.proc.rusage.ru_stime\n        except Exception:\n            pass\n        run_info['wallclock_time'] = end_time - start_time\n        _logger.info('Outcome: {}:\\n{}'.format(\n            self.query,\n            pprint.pformat(run_info)))\n        return run_info\n\nclass FakeRunner(Z3Runner):\n    def run(self):\n        return self._run_info_default()\n\nclass JFSRunner(Z3Runner):\n    def run(self):\n        run_info = self._run_info_default()\n        cmd_line = [\n            self.executable,\n        ]\n        if self.max_memory_mib > 0:\n            _logger.error('Forcing memory limit not supported')\n            raise Exception('Forcing memory limit not supported')\n\n        cmd_line.append(self.query)\n\n        _logger.info('Running: {}'.format(cmd_line))\n        start_time = time.perf_counter()\n        self.proc = ResourcePopen(cmd_line, stdout=subprocess.PIPE)\n        stdout = None\n        try:\n            # JFS has a timeout option but it doesn't work yet so we have to\n            # enforce it outselves.\n            stdout, _ = self.proc.communicate(timeout=self.timeout if self.timeout > 0 else None)\n        except subprocess.TimeoutExpired as e:\n            _logger.error('Timeout occurred')\n            self.proc.kill()\n            self.proc.wait()\n        end_time = time.perf_counter()\n\n        run_info['exit_code'] = self.proc.returncode\n        if stdout:\n            stdout = stdout.decode()\n            _logger.info('Got \"{}\"'.format(stdout))\n            # Try to parse out result\n            run_info['sat'] = self.parse_smtlib_result(stdout)\n        else:\n            run_info['sat'] = None\n        try:\n            # Seconds\n            run_info['user_time'] = self.proc.rusage.ru_utime\n            run_info['sys_time'] = self.proc.rusage.ru_stime\n        except Exception:\n            pass\n        run_info['wallclock_time'] = end_time - start_time\n        _logger.info('Outcome: {}:\\n{}'.format(\n            self.query,\n            pprint.pformat(run_info)))\n        return run_info\nif __name__ == '__main__':\n    sys.exit(main(sys.argv[1:]))\n\n"
  },
  {
    "path": "utils/not/CMakeLists.txt",
    "content": "add_executable(\"not\"\n  not.cpp\n)\njfs_get_llvm_components(NOT_NEEDED_LIBS Support)\ntarget_include_directories(\"not\" PRIVATE ${JFS_COMPONENT_EXTRA_INCLUDE_DIRS})\ntarget_compile_options(\"not\" PRIVATE ${JFS_COMPONENT_CXX_FLAGS})\ntarget_compile_definitions(\"not\" PRIVATE ${JFS_COMPONENT_CXX_DEFINES})\ntarget_link_libraries(\"not\" PRIVATE ${NOT_NEEDED_LIBS})\n"
  },
  {
    "path": "utils/not/LICENSE.TXT",
    "content": "==============================================================================\nLLVM Release License\n==============================================================================\nUniversity of Illinois/NCSA\nOpen Source License\n\nCopyright (c) 2003-2017 University of Illinois at Urbana-Champaign.\nAll rights reserved.\n\nDeveloped by:\n\n    LLVM Team\n\n    University of Illinois at Urbana-Champaign\n\n    http://llvm.org\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal with\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\n    * Redistributions of source code must retain the above copyright notice,\n      this list of conditions and the following disclaimers.\n\n    * Redistributions in binary form must reproduce the above copyright notice,\n      this list of conditions and the following disclaimers in the\n      documentation and/or other materials provided with the distribution.\n\n    * Neither the names of the LLVM Team, University of Illinois at\n      Urbana-Champaign, nor the names of its contributors may be used to\n      endorse or promote products derived from this Software without specific\n      prior written permission.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nCONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\nSOFTWARE.\n\n==============================================================================\nCopyrights and Licenses for Third Party Software Distributed with LLVM:\n==============================================================================\nThe LLVM software contains code written by third parties.  Such software will\nhave its own individual LICENSE.TXT file in the directory in which it appears.\nThis file will describe the copyrights, license, and restrictions which apply\nto that code.\n\nThe disclaimer of warranty in the University of Illinois Open Source License\napplies to all code in the LLVM Distribution, and nothing in any of the\nother licenses gives permission to use the names of the LLVM Team or the\nUniversity of Illinois to endorse or promote products derived from this\nSoftware.\n\nThe following pieces of software have additional or alternate copyrights,\nlicenses, and/or restrictions:\n\nProgram             Directory\n-------             ---------\nGoogle Test         llvm/utils/unittest/googletest\nOpenBSD regex       llvm/lib/Support/{reg*, COPYRIGHT.regex}\npyyaml tests        llvm/test/YAMLParser/{*.data, LICENSE.TXT}\nARM contributions   llvm/lib/Target/ARM/LICENSE.TXT\nmd5 contributions   llvm/lib/Support/MD5.cpp llvm/include/llvm/Support/MD5.h\n"
  },
  {
    "path": "utils/not/not.cpp",
    "content": "//===- not.cpp - The 'not' testing tool -----------------------------------===//\n//\n//                     The LLVM Compiler Infrastructure\n//\n// This file is distributed under the University of Illinois Open Source\n// License. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n// Usage:\n//   not cmd\n//     Will return true if cmd doesn't crash and returns false.\n//   not --crash cmd\n//     Will return true if cmd crashes (e.g. for testing crash reporting).\n\n#include \"llvm/Support/Program.h\"\n#include \"llvm/Support/raw_ostream.h\"\nusing namespace llvm;\n\nint main(int argc, const char **argv) {\n  bool ExpectCrash = false;\n\n  ++argv;\n  --argc;\n\n  if (argc > 0 && StringRef(argv[0]) == \"--crash\") {\n    ++argv;\n    --argc;\n    ExpectCrash = true;\n  }\n\n  if (argc == 0)\n    return 1;\n\n  auto Program = sys::findProgramByName(argv[0]);\n  if (!Program) {\n    errs() << \"Error: Unable to find `\" << argv[0]\n           << \"' in PATH: \" << Program.getError().message() << \"\\n\";\n    return 1;\n  }\n\n  std::string ErrMsg;\n  int Result = sys::ExecuteAndWait(*Program, argv, nullptr, {}, 0, 0, &ErrMsg);\n#ifdef _WIN32\n  // Handle abort() in msvcrt -- It has exit code as 3.  abort(), aka\n  // unreachable, should be recognized as a crash.  However, some binaries use\n  // exit code 3 on non-crash failure paths, so only do this if we expect a\n  // crash.\n  if (ExpectCrash && Result == 3)\n    Result = -3;\n#endif\n  if (Result < 0) {\n    errs() << \"Error: \" << ErrMsg << \"\\n\";\n    if (ExpectCrash)\n      return 0;\n    return 1;\n  }\n\n  if (ExpectCrash)\n    return 1;\n\n  return Result == 0;\n}\n"
  },
  {
    "path": "utils/suppressions/lsan/README.md",
    "content": "# LeakSanitizer Suppressions\n\nThe file `lsan_sup.txt` contains suppresions for\nthe LeakSanitizer.\n\nRun the tests like so\n\n```\nLSAN_OPTIONS=suppressions=/full/path/to/lsan_sup.txt make systemtests\n```\n"
  },
  {
    "path": "utils/suppressions/lsan/lsan_sup.txt",
    "content": "# In JFS and FileCheck tools LLVM's signal handler code\n# seems to leak.\nleak:CreateSigAltStack\n"
  },
  {
    "path": "utils/suppressions/supr_env.sh",
    "content": "# This file should be sourced to update\n# the environment with sanitizer suppressions\nset -x\nSUPPRESSIONS_ROOT_DIR=\"$(cd \"${BASH_SOURCE[0]%/*}\" && pwd )\"\nif [ -d \"${SUPPRESSIONS_ROOT_DIR}\" ]; then\n  export LSAN_OPTIONS=\"suppressions=${SUPPRESSIONS_ROOT_DIR}/lsan/lsan_sup.txt\"\n  export UBSAN_OPTIONS=\"suppressions=${SUPPRESSIONS_ROOT_DIR}/ubsan/ubsan_sup.txt,halt_on_error=1\"\nelse\n echo \"SUPPRESSIONS_ROOT_DIR \\\"${SUPPRESSIONS_ROOT_DIR}\\\" is invalid\"\nfi\nset +x\n"
  },
  {
    "path": "utils/suppressions/ubsan/README.md",
    "content": "# UndefinedBehaviourSanitizer Suppressions\n\nThe file `ubsan_supt.txt` contains suppressions\nfor the UndefinedBehaviourSanitizer\n\nRun the tests like so\n\n```\nUBSAN_OPTIONS=suppressions=/full/path/to/ubsan_sup.txt make unittests\n```\n"
  },
  {
    "path": "utils/suppressions/ubsan/ubsan_sup.txt",
    "content": "# Apparently `vptr` is incompatible with\n# `-fno-rtti` which we use. I guess this is\n# why UBSan complains. This suppression file\n# suppresses these warnings.\nvptr:gtest.cc\nvptr:gtest.h\n# We seem to get pointer alignment problems with libstdc++'s\n# std::shared_ptr<...>. Ignore for now.\nalignment:shared_ptr_base.h\n"
  }
]