├── .bazelignore ├── .clang-format ├── .codedocs ├── .github ├── dependabot.yml └── workflows │ ├── build.yml │ └── bzlmod-archive.yml ├── .gitignore ├── BUILD.bazel ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── MODULE.bazel ├── MODULE.bazel.lock ├── README.md ├── SECURITY.md ├── cmake_uninstall.cmake.in ├── docs ├── Breaking-Changes.md ├── How-To-Emit-YAML.md ├── How-To-Parse-A-Document-(Old-API).md ├── Strings.md ├── Tutorial.md ├── _config.yml └── index.md ├── include └── yaml-cpp │ ├── anchor.h │ ├── binary.h │ ├── contrib │ ├── anchordict.h │ └── graphbuilder.h │ ├── depthguard.h │ ├── dll.h │ ├── emitfromevents.h │ ├── emitter.h │ ├── emitterdef.h │ ├── emittermanip.h │ ├── emitterstyle.h │ ├── eventhandler.h │ ├── exceptions.h │ ├── fptostring.h │ ├── mark.h │ ├── node │ ├── convert.h │ ├── detail │ │ ├── impl.h │ │ ├── iterator.h │ │ ├── iterator_fwd.h │ │ ├── memory.h │ │ ├── node.h │ │ ├── node_data.h │ │ ├── node_iterator.h │ │ └── node_ref.h │ ├── emit.h │ ├── impl.h │ ├── iterator.h │ ├── node.h │ ├── parse.h │ ├── ptr.h │ └── type.h │ ├── noexcept.h │ ├── null.h │ ├── ostream_wrapper.h │ ├── parser.h │ ├── stlemitter.h │ ├── traits.h │ └── yaml.h ├── install.txt ├── src ├── binary.cpp ├── collectionstack.h ├── contrib │ ├── dragonbox.h │ ├── graphbuilder.cpp │ ├── graphbuilderadapter.cpp │ ├── graphbuilderadapter.h │ ├── yaml-cpp.natvis │ └── yaml-cpp.natvis.md ├── convert.cpp ├── depthguard.cpp ├── directives.cpp ├── directives.h ├── emit.cpp ├── emitfromevents.cpp ├── emitter.cpp ├── emitterstate.cpp ├── emitterstate.h ├── emitterutils.cpp ├── emitterutils.h ├── exceptions.cpp ├── exp.cpp ├── exp.h ├── fptostring.cpp ├── indentation.h ├── memory.cpp ├── node.cpp ├── node_data.cpp ├── nodebuilder.cpp ├── nodebuilder.h ├── nodeevents.cpp ├── nodeevents.h ├── null.cpp ├── ostream_wrapper.cpp ├── parse.cpp ├── parser.cpp ├── ptr_vector.h ├── regex_yaml.cpp ├── regex_yaml.h ├── regeximpl.h ├── scanner.cpp ├── scanner.h ├── scanscalar.cpp ├── scanscalar.h ├── scantag.cpp ├── scantag.h ├── scantoken.cpp ├── setting.h ├── simplekey.cpp ├── singledocparser.cpp ├── singledocparser.h ├── stream.cpp ├── stream.h ├── streamcharsource.h ├── stringsource.h ├── tag.cpp ├── tag.h └── token.h ├── test ├── BUILD.bazel ├── CMakeLists.txt ├── binary_test.cpp ├── cmake │ ├── CMakeLists.txt │ └── main.cpp ├── create-emitter-tests.py ├── fptostring_test.cpp ├── googletest-1.13.0 │ ├── .clang-format │ ├── .github │ │ ├── ISSUE_TEMPLATE │ │ │ ├── 00-bug_report.yml │ │ │ ├── 10-feature_request.yml │ │ │ └── config.yml │ │ └── workflows │ │ │ └── gtest-ci.yml │ ├── .gitignore │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── CONTRIBUTING.md │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── README.md │ ├── WORKSPACE │ ├── ci │ │ ├── linux-presubmit.sh │ │ ├── macos-presubmit.sh │ │ └── windows-presubmit.bat │ ├── docs │ │ ├── _config.yml │ │ ├── _data │ │ │ └── navigation.yml │ │ ├── _layouts │ │ │ └── default.html │ │ ├── _sass │ │ │ └── main.scss │ │ ├── advanced.md │ │ ├── assets │ │ │ └── css │ │ │ │ └── style.scss │ │ ├── community_created_documentation.md │ │ ├── faq.md │ │ ├── gmock_cheat_sheet.md │ │ ├── gmock_cook_book.md │ │ ├── gmock_faq.md │ │ ├── gmock_for_dummies.md │ │ ├── index.md │ │ ├── pkgconfig.md │ │ ├── platforms.md │ │ ├── primer.md │ │ ├── quickstart-bazel.md │ │ ├── quickstart-cmake.md │ │ ├── reference │ │ │ ├── actions.md │ │ │ ├── assertions.md │ │ │ ├── matchers.md │ │ │ ├── mocking.md │ │ │ └── testing.md │ │ └── samples.md │ ├── googlemock │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── cmake │ │ │ ├── gmock.pc.in │ │ │ └── gmock_main.pc.in │ │ ├── docs │ │ │ └── README.md │ │ ├── include │ │ │ └── gmock │ │ │ │ ├── gmock-actions.h │ │ │ │ ├── gmock-cardinalities.h │ │ │ │ ├── gmock-function-mocker.h │ │ │ │ ├── gmock-matchers.h │ │ │ │ ├── gmock-more-actions.h │ │ │ │ ├── gmock-more-matchers.h │ │ │ │ ├── gmock-nice-strict.h │ │ │ │ ├── gmock-spec-builders.h │ │ │ │ ├── gmock.h │ │ │ │ └── internal │ │ │ │ ├── custom │ │ │ │ ├── README.md │ │ │ │ ├── gmock-generated-actions.h │ │ │ │ ├── gmock-matchers.h │ │ │ │ └── gmock-port.h │ │ │ │ ├── gmock-internal-utils.h │ │ │ │ ├── gmock-port.h │ │ │ │ └── gmock-pp.h │ │ ├── src │ │ │ ├── gmock-all.cc │ │ │ ├── gmock-cardinalities.cc │ │ │ ├── gmock-internal-utils.cc │ │ │ ├── gmock-matchers.cc │ │ │ ├── gmock-spec-builders.cc │ │ │ ├── gmock.cc │ │ │ └── gmock_main.cc │ │ └── test │ │ │ ├── BUILD.bazel │ │ │ ├── gmock-actions_test.cc │ │ │ ├── gmock-cardinalities_test.cc │ │ │ ├── gmock-function-mocker_test.cc │ │ │ ├── gmock-internal-utils_test.cc │ │ │ ├── gmock-matchers-arithmetic_test.cc │ │ │ ├── gmock-matchers-comparisons_test.cc │ │ │ ├── gmock-matchers-containers_test.cc │ │ │ ├── gmock-matchers-misc_test.cc │ │ │ ├── gmock-matchers_test.h │ │ │ ├── gmock-more-actions_test.cc │ │ │ ├── gmock-nice-strict_test.cc │ │ │ ├── gmock-port_test.cc │ │ │ ├── gmock-pp-string_test.cc │ │ │ ├── gmock-pp_test.cc │ │ │ ├── gmock-spec-builders_test.cc │ │ │ ├── gmock_all_test.cc │ │ │ ├── gmock_ex_test.cc │ │ │ ├── gmock_leak_test.py │ │ │ ├── gmock_leak_test_.cc │ │ │ ├── gmock_link2_test.cc │ │ │ ├── gmock_link_test.cc │ │ │ ├── gmock_link_test.h │ │ │ ├── gmock_output_test.py │ │ │ ├── gmock_output_test_.cc │ │ │ ├── gmock_output_test_golden.txt │ │ │ ├── gmock_stress_test.cc │ │ │ ├── gmock_test.cc │ │ │ └── gmock_test_utils.py │ └── googletest │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── cmake │ │ ├── Config.cmake.in │ │ ├── gtest.pc.in │ │ ├── gtest_main.pc.in │ │ ├── internal_utils.cmake │ │ └── libgtest.la.in │ │ ├── docs │ │ └── README.md │ │ ├── include │ │ └── gtest │ │ │ ├── gtest-assertion-result.h │ │ │ ├── gtest-death-test.h │ │ │ ├── gtest-matchers.h │ │ │ ├── gtest-message.h │ │ │ ├── gtest-param-test.h │ │ │ ├── gtest-printers.h │ │ │ ├── gtest-spi.h │ │ │ ├── gtest-test-part.h │ │ │ ├── gtest-typed-test.h │ │ │ ├── gtest.h │ │ │ ├── gtest_pred_impl.h │ │ │ ├── gtest_prod.h │ │ │ └── internal │ │ │ ├── custom │ │ │ ├── README.md │ │ │ ├── gtest-port.h │ │ │ ├── gtest-printers.h │ │ │ └── gtest.h │ │ │ ├── gtest-death-test-internal.h │ │ │ ├── gtest-filepath.h │ │ │ ├── gtest-internal.h │ │ │ ├── gtest-param-util.h │ │ │ ├── gtest-port-arch.h │ │ │ ├── gtest-port.h │ │ │ ├── gtest-string.h │ │ │ └── gtest-type-util.h │ │ ├── samples │ │ ├── prime_tables.h │ │ ├── sample1.cc │ │ ├── sample1.h │ │ ├── sample10_unittest.cc │ │ ├── sample1_unittest.cc │ │ ├── sample2.cc │ │ ├── sample2.h │ │ ├── sample2_unittest.cc │ │ ├── sample3-inl.h │ │ ├── sample3_unittest.cc │ │ ├── sample4.cc │ │ ├── sample4.h │ │ ├── sample4_unittest.cc │ │ ├── sample5_unittest.cc │ │ ├── sample6_unittest.cc │ │ ├── sample7_unittest.cc │ │ ├── sample8_unittest.cc │ │ └── sample9_unittest.cc │ │ ├── src │ │ ├── gtest-all.cc │ │ ├── gtest-assertion-result.cc │ │ ├── gtest-death-test.cc │ │ ├── gtest-filepath.cc │ │ ├── gtest-internal-inl.h │ │ ├── gtest-matchers.cc │ │ ├── gtest-port.cc │ │ ├── gtest-printers.cc │ │ ├── gtest-test-part.cc │ │ ├── gtest-typed-test.cc │ │ ├── gtest.cc │ │ └── gtest_main.cc │ │ └── test │ │ ├── BUILD.bazel │ │ ├── googletest-break-on-failure-unittest.py │ │ ├── googletest-break-on-failure-unittest_.cc │ │ ├── googletest-catch-exceptions-test.py │ │ ├── googletest-catch-exceptions-test_.cc │ │ ├── googletest-color-test.py │ │ ├── googletest-color-test_.cc │ │ ├── googletest-death-test-test.cc │ │ ├── googletest-death-test_ex_test.cc │ │ ├── googletest-env-var-test.py │ │ ├── googletest-env-var-test_.cc │ │ ├── googletest-failfast-unittest.py │ │ ├── googletest-failfast-unittest_.cc │ │ ├── googletest-filepath-test.cc │ │ ├── googletest-filter-unittest.py │ │ ├── googletest-filter-unittest_.cc │ │ ├── googletest-global-environment-unittest.py │ │ ├── googletest-global-environment-unittest_.cc │ │ ├── googletest-json-outfiles-test.py │ │ ├── googletest-json-output-unittest.py │ │ ├── googletest-list-tests-unittest.py │ │ ├── googletest-list-tests-unittest_.cc │ │ ├── googletest-listener-test.cc │ │ ├── googletest-message-test.cc │ │ ├── googletest-options-test.cc │ │ ├── googletest-output-test-golden-lin.txt │ │ ├── googletest-output-test.py │ │ ├── googletest-output-test_.cc │ │ ├── googletest-param-test-invalid-name1-test.py │ │ ├── googletest-param-test-invalid-name1-test_.cc │ │ ├── googletest-param-test-invalid-name2-test.py │ │ ├── googletest-param-test-invalid-name2-test_.cc │ │ ├── googletest-param-test-test.cc │ │ ├── googletest-param-test-test.h │ │ ├── googletest-param-test2-test.cc │ │ ├── googletest-port-test.cc │ │ ├── googletest-printers-test.cc │ │ ├── googletest-setuptestsuite-test.py │ │ ├── googletest-setuptestsuite-test_.cc │ │ ├── googletest-shuffle-test.py │ │ ├── googletest-shuffle-test_.cc │ │ ├── googletest-test-part-test.cc │ │ ├── googletest-throw-on-failure-test.py │ │ ├── googletest-throw-on-failure-test_.cc │ │ ├── googletest-uninitialized-test.py │ │ ├── googletest-uninitialized-test_.cc │ │ ├── gtest-typed-test2_test.cc │ │ ├── gtest-typed-test_test.cc │ │ ├── gtest-typed-test_test.h │ │ ├── gtest-unittest-api_test.cc │ │ ├── gtest_all_test.cc │ │ ├── gtest_assert_by_exception_test.cc │ │ ├── gtest_dirs_test.cc │ │ ├── gtest_environment_test.cc │ │ ├── gtest_help_test.py │ │ ├── gtest_help_test_.cc │ │ ├── gtest_json_test_utils.py │ │ ├── gtest_list_output_unittest.py │ │ ├── gtest_list_output_unittest_.cc │ │ ├── gtest_main_unittest.cc │ │ ├── gtest_no_test_unittest.cc │ │ ├── gtest_pred_impl_unittest.cc │ │ ├── gtest_premature_exit_test.cc │ │ ├── gtest_prod_test.cc │ │ ├── gtest_repeat_test.cc │ │ ├── gtest_skip_check_output_test.py │ │ ├── gtest_skip_environment_check_output_test.py │ │ ├── gtest_skip_in_environment_setup_test.cc │ │ ├── gtest_skip_test.cc │ │ ├── gtest_sole_header_test.cc │ │ ├── gtest_stress_test.cc │ │ ├── gtest_test_macro_stack_footprint_test.cc │ │ ├── gtest_test_utils.py │ │ ├── gtest_testbridge_test.py │ │ ├── gtest_testbridge_test_.cc │ │ ├── gtest_throw_on_failure_ex_test.cc │ │ ├── gtest_unittest.cc │ │ ├── gtest_xml_outfile1_test_.cc │ │ ├── gtest_xml_outfile2_test_.cc │ │ ├── gtest_xml_outfiles_test.py │ │ ├── gtest_xml_output_unittest.py │ │ ├── gtest_xml_output_unittest_.cc │ │ ├── gtest_xml_test_utils.py │ │ ├── production.cc │ │ └── production.h ├── integration │ ├── BUILD.bazel │ ├── emitter_test.cpp │ ├── encoding_test.cpp │ ├── error_messages_test.cpp │ ├── gen_emitter_test.cpp │ ├── handler_spec_test.cpp │ ├── handler_test.cpp │ ├── handler_test.h │ ├── load_node_test.cpp │ └── node_spec_test.cpp ├── main.cpp ├── mock_event_handler.h ├── node │ └── node_test.cpp ├── ostream_wrapper_test.cpp ├── parser_test.cpp ├── regex_test.cpp └── specexamples.h ├── util ├── CMakeLists.txt ├── api.cpp ├── parse.cpp ├── read.cpp └── sandbox.cpp ├── yaml-cpp-config.cmake.in └── yaml-cpp.pc.in /.bazelignore: -------------------------------------------------------------------------------- 1 | test/googletest-1.13.0 2 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | # BasedOnStyle: Google 3 | AccessModifierOffset: -1 4 | ConstructorInitializerIndentWidth: 4 5 | AlignEscapedNewlinesLeft: true 6 | AlignTrailingComments: true 7 | AllowAllParametersOfDeclarationOnNextLine: true 8 | AllowShortIfStatementsOnASingleLine: false 9 | AllowShortLoopsOnASingleLine: false 10 | AlwaysBreakTemplateDeclarations: true 11 | AlwaysBreakBeforeMultilineStrings: true 12 | BreakBeforeBinaryOperators: false 13 | BreakBeforeTernaryOperators: true 14 | BreakConstructorInitializersBeforeComma: false 15 | BinPackParameters: true 16 | ColumnLimit: 80 17 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 18 | DerivePointerBinding: true 19 | ExperimentalAutoDetectBinPacking: false 20 | IndentCaseLabels: true 21 | MaxEmptyLinesToKeep: 1 22 | NamespaceIndentation: None 23 | ObjCSpaceBeforeProtocolList: false 24 | PenaltyBreakBeforeFirstCallParameter: 1 25 | PenaltyBreakComment: 60 26 | PenaltyBreakString: 1000 27 | PenaltyBreakFirstLessLess: 120 28 | PenaltyExcessCharacter: 1000000 29 | PenaltyReturnTypeOnItsOwnLine: 200 30 | PointerBindsToType: true 31 | SpacesBeforeTrailingComments: 2 32 | Cpp11BracedListStyle: true 33 | Standard: Cpp11 34 | IndentWidth: 2 35 | TabWidth: 8 36 | UseTab: Never 37 | BreakBeforeBraces: Attach 38 | IndentFunctionDeclarationAfterType: true 39 | SpacesInParentheses: false 40 | SpacesInAngles: false 41 | SpaceInEmptyParentheses: false 42 | SpacesInCStyleCastParentheses: false 43 | SpaceAfterControlStatementKeyword: true 44 | SpaceBeforeAssignmentOperators: true 45 | ContinuationIndentWidth: 4 46 | ... 47 | 48 | -------------------------------------------------------------------------------- /.codedocs: -------------------------------------------------------------------------------- 1 | # CodeDocs.xyz Configuration File 2 | 3 | # Optional project name, if left empty the GitHub repository name will be used. 4 | PROJECT_NAME = 5 | 6 | # One or more directories and files that contain example code to be included. 7 | EXAMPLE_PATH = 8 | 9 | # One or more directories and files to exclude from documentation generation. 10 | # Use relative paths with respect to the repository root directory. 11 | EXCLUDE = test/googletest-1.13.0/ 12 | 13 | # One or more wildcard patterns to exclude files and directories from document 14 | # generation. 15 | EXCLUDE_PATTERNS = 16 | 17 | # One or more symbols to exclude from document generation. Symbols can be 18 | # namespaces, classes, or functions. 19 | EXCLUDE_SYMBOLS = 20 | 21 | # Override the default parser (language) used for each file extension. 22 | EXTENSION_MAPPING = 23 | 24 | # Set the wildcard patterns used to filter out the source-files. 25 | # If left blank the default is: 26 | # *.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, 27 | # *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, 28 | # *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, *.md, *.mm, *.dox, *.py, 29 | # *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, *.qsf, *.as and *.js. 30 | FILE_PATTERNS = 31 | 32 | # Hide undocumented class members. 33 | HIDE_UNDOC_MEMBERS = 34 | 35 | # Hide undocumented classes. 36 | HIDE_UNDOC_CLASSES = 37 | 38 | # Specify a markdown page whose contents should be used as the main page 39 | # (index.html). This will override a page marked as \mainpage. For example, a 40 | # README.md file usually serves as a useful main page. 41 | USE_MDFILE_AS_MAINPAGE = README.md 42 | 43 | # Specify external repository to link documentation with. 44 | # This is similar to Doxygen's TAGFILES option, but will automatically link to 45 | # tags of other repositories already using CodeDocs. List each repository to 46 | # link with by giving its location in the form of owner/repository. 47 | # For example: 48 | # TAGLINKS = doxygen/doxygen CodeDocs/osg 49 | # Note: these repositories must already be built on CodeDocs. 50 | TAGLINKS = 51 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "monthly" 7 | groups: 8 | github-actions: 9 | patterns: 10 | - "*" 11 | 12 | -------------------------------------------------------------------------------- /.github/workflows/bzlmod-archive.yml: -------------------------------------------------------------------------------- 1 | name: Bazel Release 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | # A release archive is required for bzlmod 9 | # See: https://blog.bazel.build/2023/02/15/github-archive-checksum.html 10 | bazel-release-archive: 11 | runs-on: ubuntu-latest 12 | permissions: 13 | contents: write 14 | steps: 15 | - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 16 | - run: git archive $GITHUB_REF -o "yaml-cpp-${GITHUB_REF:10}.tar.gz" 17 | - run: gh release upload ${GITHUB_REF:10} "yaml-cpp-${GITHUB_REF:10}.tar.gz" 18 | env: 19 | GH_TOKEN: ${{ github.token }} 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | /tags 3 | /bazel-* 4 | -------------------------------------------------------------------------------- /BUILD.bazel: -------------------------------------------------------------------------------- 1 | yaml_cpp_defines = select({ 2 | # On Windows, ensure static linking is used. 3 | "@platforms//os:windows": ["YAML_CPP_STATIC_DEFINE", "YAML_CPP_NO_CONTRIB"], 4 | "//conditions:default": [], 5 | }) 6 | 7 | cc_library( 8 | name = "yaml-cpp_internal", 9 | visibility = ["//:__subpackages__"], 10 | strip_include_prefix = "src", 11 | hdrs = glob(["src/**/*.h"]), 12 | ) 13 | 14 | cc_library( 15 | name = "yaml-cpp", 16 | visibility = ["//visibility:public"], 17 | includes = ["include"], 18 | hdrs = glob(["include/**/*.h"]), 19 | srcs = glob(["src/**/*.cpp", "src/**/*.h"]), 20 | defines = yaml_cpp_defines, 21 | ) 22 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Style 2 | 3 | This project is formatted with [clang-format][fmt] using the style file at the root of the repository. Please run clang-format before sending a pull request. 4 | 5 | In general, try to follow the style of surrounding code. We mostly follow the [Google C++ style guide][cpp-style]. 6 | 7 | Commit messages should be in the imperative mood, as described in the [Git contributing file][git-contrib]: 8 | 9 | > Describe your changes in imperative mood, e.g. "make xyzzy do frotz" 10 | > instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy 11 | > to do frotz", as if you are giving orders to the codebase to change 12 | > its behaviour. 13 | 14 | [fmt]: http://clang.llvm.org/docs/ClangFormat.html 15 | [cpp-style]: https://google.github.io/styleguide/cppguide.html 16 | [git-contrib]: http://git.kernel.org/cgit/git/git.git/tree/Documentation/SubmittingPatches?id=HEAD 17 | 18 | # Tests 19 | 20 | Please verify the tests pass by configuring CMake with `-D YAML_CPP_BUILD_TESTS=ON` and running the target `test/yaml-cpp-tests`. 21 | 22 | If you are adding functionality, add tests accordingly. Note that the "spec tests" are reserved for examples directly from the YAML spec, so if you have new examples, put them in other test files. 23 | 24 | # Pull request process 25 | 26 | Every pull request undergoes a code review. Unfortunately, github's code review process isn't great, but we'll manage. During the code review, if you make changes, add new commits to the pull request for each change. Once the code review is complete, rebase against the master branch and squash into a single commit. 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2015 Jesse Beder. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /MODULE.bazel: -------------------------------------------------------------------------------- 1 | """ 2 | yaml-cpp is a YAML parser and emitter in c++ matching the YAML specification. 3 | """ 4 | 5 | module( 6 | name = "yaml-cpp", 7 | compatibility_level = 1, 8 | version = "0.8.0", 9 | ) 10 | 11 | bazel_dep(name = "platforms", version = "0.0.7") 12 | bazel_dep(name = "rules_cc", version = "0.0.8") 13 | 14 | bazel_dep(name = "googletest", version = "1.14.0", dev_dependency = True) 15 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Security updates are applied only to the latest release. 6 | 7 | ## Reporting a Vulnerability 8 | 9 | If you have discovered a security vulnerability in this project, please report it privately. **Do not disclose it as a public issue.** This gives us time to work with you to fix the issue before public exposure, reducing the chance that the exploit will be used before a patch is released. 10 | 11 | Please disclose it at [security advisory](https://github.com/jbeder/yaml-cpp/security/advisories/new). 12 | 13 | This project is maintained by a team of volunteers on a reasonable-effort basis. As such, vulnerabilities will be disclosed in a best effort base. 14 | -------------------------------------------------------------------------------- /cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") 3 | endif() 4 | 5 | file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) 6 | string(REGEX REPLACE "\n" ";" files "${files}") 7 | foreach(file ${files}) 8 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 9 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 10 | exec_program( 11 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 12 | OUTPUT_VARIABLE rm_out 13 | RETURN_VALUE rm_retval 14 | ) 15 | if(NOT "${rm_retval}" STREQUAL 0) 16 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 17 | endif() 18 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 19 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 20 | endif() 21 | endforeach() 22 | -------------------------------------------------------------------------------- /docs/Breaking-Changes.md: -------------------------------------------------------------------------------- 1 | # The following is a list of breaking changes to yaml-cpp, by version # 2 | 3 | # New API # 4 | 5 | ## HEAD ## 6 | 7 | * Throws an exception when trying to parse a negative number as an unsigned integer. 8 | * Supports the `as`/`as`, which throws an exception when the value exceeds the range of `int8_t`/`uint8_t`. 9 | 10 | ## 0.6.0 ## 11 | 12 | * Requires C++11. 13 | 14 | ## 0.5.3 ## 15 | 16 | _none_ 17 | 18 | ## 0.5.2 ## 19 | 20 | _none_ 21 | 22 | ## 0.5.1 ## 23 | 24 | * `Node::clear` was replaced by `Node::reset`, which takes an optional node, similar to smart pointers. 25 | 26 | ## 0.5.0 ## 27 | 28 | Initial version of the new API. 29 | 30 | # Old API # 31 | 32 | ## 0.3.0 ## 33 | 34 | _none_ 35 | 36 | ## 0.2.7 ## 37 | 38 | * `YAML::Binary` now takes `const unsigned char *` for the binary data (instead of `const char *`). 39 | 40 | ## 0.2.6 ## 41 | 42 | * `Node::GetType()` is now `Node::Type()`, and returns an enum `NodeType::value`, where: 43 | > > ` struct NodeType { enum value { Null, Scalar, Sequence, Map }; }; ` 44 | * `Node::GetTag()` is now `Node::Tag()` 45 | * `Node::Identity()` is removed, and `Node::IsAlias()` and `Node::IsReferenced()` have been merged into `Node::IsAliased()`. The reason: there's no reason to distinguish an alias node from its anchor - whichever happens to be emitted first will be the anchor, and the rest will be aliases. 46 | * `Node::Read` is now `Node::to`. This wasn't a documented function, so it shouldn't break anything. 47 | * `Node`'s comparison operators (for example, `operator == (const Node&, const T&)`) have all been removed. These weren't documented either (they were just used for the tests), so this shouldn't break anything either. 48 | * The emitter no longer produces the document start by default - if you want it, you can supply it with the manipulator `YAML::BeginDoc`. 49 | 50 | ## 0.2.5 ## 51 | 52 | This wiki was started with v0.2.5. -------------------------------------------------------------------------------- /docs/Strings.md: -------------------------------------------------------------------------------- 1 | # Encodings and `yaml-cpp` # 2 | 3 | `yaml-cpp` will parse any file as specified by the [YAML 1.2 spec](http://www.yaml.org/spec/1.2/spec.html#id2570322). Internally, it stores all strings in UTF-8, and representation is done with UTF-8. This means that in 4 | 5 | ``` 6 | std::string str; 7 | node >> str; 8 | ``` 9 | 10 | `str` will be UTF-8. Similarly, if you're accessing a map by string key, you need to pass the key in UTF-8. If your application uses a different encoding, you need to convert to and from UTF-8 to work with `yaml-cpp`. (It's possible we'll add some small conversion functions, but for now it's restricted.) 11 | 12 | --- 13 | 14 | For convenience, Richard Weeks has kindly provided a google gadget that converts Unicode to a string literal. It's a Google Gadget, so unfortunately it does not work on GitHub. Patches welcome to port it to a usable format here: 15 | 16 | ``` 17 | 18 | ``` -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | To learn how to use the library, see the [Tutorial](https://github.com/jbeder/yaml-cpp/wiki/Tutorial) and [How To Emit YAML](https://github.com/jbeder/yaml-cpp/wiki/How-To-Emit-YAML) 2 | -------------------------------------------------------------------------------- /include/yaml-cpp/anchor.h: -------------------------------------------------------------------------------- 1 | #ifndef ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | namespace YAML { 13 | using anchor_t = std::size_t; 14 | const anchor_t NullAnchor = 0; 15 | } 16 | 17 | #endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 18 | -------------------------------------------------------------------------------- /include/yaml-cpp/binary.h: -------------------------------------------------------------------------------- 1 | #ifndef BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | #include "yaml-cpp/dll.h" 14 | 15 | namespace YAML { 16 | YAML_CPP_API std::string EncodeBase64(const unsigned char *data, 17 | std::size_t size); 18 | YAML_CPP_API std::vector DecodeBase64(const std::string &input); 19 | 20 | class YAML_CPP_API Binary { 21 | public: 22 | Binary(const unsigned char *data_, std::size_t size_) 23 | : m_data{}, m_unownedData(data_), m_unownedSize(size_) {} 24 | Binary() : Binary(nullptr, 0) {} 25 | Binary(const Binary &) = default; 26 | Binary(Binary &&) = default; 27 | Binary &operator=(const Binary &) = default; 28 | Binary &operator=(Binary &&) = default; 29 | 30 | bool owned() const { return !m_unownedData; } 31 | std::size_t size() const { return owned() ? m_data.size() : m_unownedSize; } 32 | const unsigned char *data() const { 33 | return owned() ? &m_data[0] : m_unownedData; 34 | } 35 | 36 | void swap(std::vector &rhs) { 37 | if (m_unownedData) { 38 | m_data.swap(rhs); 39 | rhs.clear(); 40 | rhs.resize(m_unownedSize); 41 | std::copy(m_unownedData, m_unownedData + m_unownedSize, rhs.begin()); 42 | m_unownedData = nullptr; 43 | m_unownedSize = 0; 44 | } else { 45 | m_data.swap(rhs); 46 | } 47 | } 48 | 49 | bool operator==(const Binary &rhs) const { 50 | const std::size_t s = size(); 51 | if (s != rhs.size()) 52 | return false; 53 | const unsigned char *d1 = data(); 54 | const unsigned char *d2 = rhs.data(); 55 | for (std::size_t i = 0; i < s; i++) { 56 | if (*d1++ != *d2++) 57 | return false; 58 | } 59 | return true; 60 | } 61 | 62 | bool operator!=(const Binary &rhs) const { return !(*this == rhs); } 63 | 64 | private: 65 | std::vector m_data; 66 | const unsigned char *m_unownedData; 67 | std::size_t m_unownedSize; 68 | }; 69 | } // namespace YAML 70 | 71 | #endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 72 | -------------------------------------------------------------------------------- /include/yaml-cpp/contrib/anchordict.h: -------------------------------------------------------------------------------- 1 | #ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | #include "../anchor.h" 13 | 14 | namespace YAML { 15 | /** 16 | * An object that stores and retrieves values correlating to {@link anchor_t} 17 | * values. 18 | * 19 | *

Efficient implementation that can make assumptions about how 20 | * {@code anchor_t} values are assigned by the {@link Parser} class. 21 | */ 22 | template 23 | class AnchorDict { 24 | public: 25 | AnchorDict() : m_data{} {} 26 | void Register(anchor_t anchor, T value) { 27 | if (anchor > m_data.size()) { 28 | m_data.resize(anchor); 29 | } 30 | m_data[anchor - 1] = value; 31 | } 32 | 33 | T Get(anchor_t anchor) const { return m_data[anchor - 1]; } 34 | 35 | private: 36 | std::vector m_data; 37 | }; 38 | } // namespace YAML 39 | 40 | #endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 41 | -------------------------------------------------------------------------------- /include/yaml-cpp/dll.h: -------------------------------------------------------------------------------- 1 | #ifndef DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | // Definition YAML_CPP_STATIC_DEFINE using to building YAML-CPP as static 5 | // library (definition created by CMake or defined manually) 6 | 7 | // Definition yaml_cpp_EXPORTS using to building YAML-CPP as dll/so library 8 | // (definition created by CMake or defined manually) 9 | 10 | #ifdef YAML_CPP_STATIC_DEFINE 11 | # define YAML_CPP_API 12 | # define YAML_CPP_NO_EXPORT 13 | #else 14 | # if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__) 15 | # ifndef YAML_CPP_API 16 | # ifdef yaml_cpp_EXPORTS 17 | /* We are building this library */ 18 | # define YAML_CPP_API __declspec(dllexport) 19 | # else 20 | /* We are using this library */ 21 | # define YAML_CPP_API __declspec(dllimport) 22 | # endif 23 | # endif 24 | # ifndef YAML_CPP_NO_EXPORT 25 | # define YAML_CPP_NO_EXPORT 26 | # endif 27 | # else /* No _MSC_VER */ 28 | # ifndef YAML_CPP_API 29 | # ifdef yaml_cpp_EXPORTS 30 | /* We are building this library */ 31 | # define YAML_CPP_API __attribute__((visibility("default"))) 32 | # else 33 | /* We are using this library */ 34 | # define YAML_CPP_API __attribute__((visibility("default"))) 35 | # endif 36 | # endif 37 | # ifndef YAML_CPP_NO_EXPORT 38 | # define YAML_CPP_NO_EXPORT __attribute__((visibility("hidden"))) 39 | # endif 40 | # endif /* _MSC_VER */ 41 | #endif /* YAML_CPP_STATIC_DEFINE */ 42 | 43 | #ifndef YAML_CPP_DEPRECATED 44 | # ifdef _MSC_VER 45 | # define YAML_CPP_DEPRECATED __declspec(deprecated) 46 | # else 47 | # define YAML_CPP_DEPRECATED __attribute__ ((__deprecated__)) 48 | # endif 49 | #endif 50 | 51 | #ifndef YAML_CPP_DEPRECATED_EXPORT 52 | # define YAML_CPP_DEPRECATED_EXPORT YAML_CPP_API YAML_CPP_DEPRECATED 53 | #endif 54 | 55 | #ifndef YAML_CPP_DEPRECATED_NO_EXPORT 56 | # define YAML_CPP_DEPRECATED_NO_EXPORT YAML_CPP_NO_EXPORT YAML_CPP_DEPRECATED 57 | #endif 58 | 59 | #endif /* DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 */ 60 | -------------------------------------------------------------------------------- /include/yaml-cpp/emitfromevents.h: -------------------------------------------------------------------------------- 1 | #ifndef EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | #include "yaml-cpp/anchor.h" 13 | #include "yaml-cpp/emitterstyle.h" 14 | #include "yaml-cpp/eventhandler.h" 15 | 16 | namespace YAML { 17 | struct Mark; 18 | } // namespace YAML 19 | 20 | namespace YAML { 21 | class Emitter; 22 | 23 | class EmitFromEvents : public EventHandler { 24 | public: 25 | EmitFromEvents(Emitter& emitter); 26 | ~EmitFromEvents() override = default; 27 | 28 | void OnDocumentStart(const Mark& mark) override; 29 | void OnDocumentEnd() override; 30 | 31 | void OnNull(const Mark& mark, anchor_t anchor) override; 32 | void OnAlias(const Mark& mark, anchor_t anchor) override; 33 | void OnScalar(const Mark& mark, const std::string& tag, 34 | anchor_t anchor, const std::string& value) override; 35 | 36 | void OnSequenceStart(const Mark& mark, const std::string& tag, 37 | anchor_t anchor, EmitterStyle::value style) override; 38 | void OnSequenceEnd() override; 39 | 40 | void OnMapStart(const Mark& mark, const std::string& tag, 41 | anchor_t anchor, EmitterStyle::value style) override; 42 | void OnMapEnd() override; 43 | 44 | private: 45 | void BeginNode(); 46 | void EmitProps(const std::string& tag, anchor_t anchor); 47 | 48 | private: 49 | Emitter& m_emitter; 50 | 51 | struct State { 52 | enum value { WaitingForSequenceEntry, WaitingForKey, WaitingForValue }; 53 | }; 54 | std::stack m_stateStack; 55 | }; 56 | } 57 | 58 | #endif // EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 59 | -------------------------------------------------------------------------------- /include/yaml-cpp/emitterdef.h: -------------------------------------------------------------------------------- 1 | #ifndef EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | namespace YAML { 11 | struct EmitterNodeType { 12 | enum value { NoType, Property, Scalar, FlowSeq, BlockSeq, FlowMap, BlockMap }; 13 | }; 14 | } 15 | 16 | #endif // EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 17 | -------------------------------------------------------------------------------- /include/yaml-cpp/emitterstyle.h: -------------------------------------------------------------------------------- 1 | #ifndef EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | namespace YAML { 11 | namespace EmitterStyle { 12 | enum value { Default, Block, Flow }; 13 | } 14 | 15 | } 16 | 17 | #endif // EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 18 | -------------------------------------------------------------------------------- /include/yaml-cpp/eventhandler.h: -------------------------------------------------------------------------------- 1 | #ifndef EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | #include "yaml-cpp/anchor.h" 13 | #include "yaml-cpp/emitterstyle.h" 14 | 15 | namespace YAML { 16 | struct Mark; 17 | 18 | class EventHandler { 19 | public: 20 | virtual ~EventHandler() = default; 21 | 22 | virtual void OnDocumentStart(const Mark& mark) = 0; 23 | virtual void OnDocumentEnd() = 0; 24 | 25 | virtual void OnNull(const Mark& mark, anchor_t anchor) = 0; 26 | virtual void OnAlias(const Mark& mark, anchor_t anchor) = 0; 27 | virtual void OnScalar(const Mark& mark, const std::string& tag, 28 | anchor_t anchor, const std::string& value) = 0; 29 | 30 | virtual void OnSequenceStart(const Mark& mark, const std::string& tag, 31 | anchor_t anchor, EmitterStyle::value style) = 0; 32 | virtual void OnSequenceEnd() = 0; 33 | 34 | virtual void OnMapStart(const Mark& mark, const std::string& tag, 35 | anchor_t anchor, EmitterStyle::value style) = 0; 36 | virtual void OnMapEnd() = 0; 37 | 38 | virtual void OnAnchor(const Mark& /*mark*/, 39 | const std::string& /*anchor_name*/) { 40 | // empty default implementation for compatibility 41 | } 42 | }; 43 | } // namespace YAML 44 | 45 | #endif // EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 46 | -------------------------------------------------------------------------------- /include/yaml-cpp/fptostring.h: -------------------------------------------------------------------------------- 1 | #ifndef YAML_H_FPTOSTRING 2 | #define YAML_H_FPTOSTRING 3 | 4 | #include "yaml-cpp/dll.h" 5 | 6 | #include 7 | 8 | namespace YAML { 9 | // "precision = 0" refers to shortest known unique representation of the value 10 | YAML_CPP_API std::string FpToString(float v, size_t precision = 0); 11 | YAML_CPP_API std::string FpToString(double v, size_t precision = 0); 12 | YAML_CPP_API std::string FpToString(long double v, size_t precision = 0); 13 | } 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /include/yaml-cpp/mark.h: -------------------------------------------------------------------------------- 1 | #ifndef MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "yaml-cpp/dll.h" 11 | 12 | namespace YAML { 13 | struct YAML_CPP_API Mark { 14 | Mark() : pos(0), line(0), column(0) {} 15 | 16 | static const Mark null_mark() { return Mark(-1, -1, -1); } 17 | 18 | bool is_null() const { return pos == -1 && line == -1 && column == -1; } 19 | 20 | int pos; 21 | int line, column; 22 | 23 | private: 24 | Mark(int pos_, int line_, int column_) 25 | : pos(pos_), line(line_), column(column_) {} 26 | }; 27 | } 28 | 29 | #endif // MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 30 | -------------------------------------------------------------------------------- /include/yaml-cpp/node/detail/iterator_fwd.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "yaml-cpp/dll.h" 11 | #include 12 | #include 13 | #include 14 | 15 | namespace YAML { 16 | 17 | namespace detail { 18 | struct iterator_value; 19 | template 20 | class iterator_base; 21 | } 22 | 23 | using iterator = detail::iterator_base; 24 | using const_iterator = detail::iterator_base; 25 | } 26 | 27 | #endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 28 | -------------------------------------------------------------------------------- /include/yaml-cpp/node/detail/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | #include "yaml-cpp/dll.h" 13 | #include "yaml-cpp/node/ptr.h" 14 | 15 | namespace YAML { 16 | namespace detail { 17 | class node; 18 | } // namespace detail 19 | } // namespace YAML 20 | 21 | namespace YAML { 22 | namespace detail { 23 | class YAML_CPP_API memory { 24 | public: 25 | memory() : m_nodes{} {} 26 | node& create_node(); 27 | void merge(const memory& rhs); 28 | 29 | private: 30 | using Nodes = std::set; 31 | Nodes m_nodes; 32 | }; 33 | 34 | class YAML_CPP_API memory_holder { 35 | public: 36 | memory_holder() : m_pMemory(new memory) {} 37 | 38 | node& create_node() { return m_pMemory->create_node(); } 39 | void merge(memory_holder& rhs); 40 | 41 | private: 42 | shared_memory m_pMemory; 43 | }; 44 | } // namespace detail 45 | } // namespace YAML 46 | 47 | #endif // VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 48 | -------------------------------------------------------------------------------- /include/yaml-cpp/node/emit.h: -------------------------------------------------------------------------------- 1 | #ifndef NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | #include "yaml-cpp/dll.h" 14 | 15 | namespace YAML { 16 | class Emitter; 17 | class Node; 18 | 19 | /** 20 | * Emits the node to the given {@link Emitter}. If there is an error in writing, 21 | * {@link Emitter#good} will return false. 22 | */ 23 | YAML_CPP_API Emitter& operator<<(Emitter& out, const Node& node); 24 | 25 | /** Emits the node to the given output stream. */ 26 | YAML_CPP_API std::ostream& operator<<(std::ostream& out, const Node& node); 27 | 28 | /** Converts the node to a YAML string. */ 29 | YAML_CPP_API std::string Dump(const Node& node); 30 | } // namespace YAML 31 | 32 | #endif // NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 33 | -------------------------------------------------------------------------------- /include/yaml-cpp/node/iterator.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "yaml-cpp/dll.h" 11 | #include "yaml-cpp/node/node.h" 12 | #include "yaml-cpp/node/detail/iterator_fwd.h" 13 | #include "yaml-cpp/node/detail/iterator.h" 14 | #include 15 | #include 16 | #include 17 | 18 | // Assert in place so gcc + libc++ combination properly builds 19 | static_assert(std::is_constructible::value, "Node must be copy constructable"); 20 | 21 | namespace YAML { 22 | namespace detail { 23 | struct iterator_value : public Node, std::pair { 24 | iterator_value() = default; 25 | explicit iterator_value(const Node& rhs) 26 | : Node(rhs), 27 | std::pair(Node(Node::ZombieNode), Node(Node::ZombieNode)) {} 28 | explicit iterator_value(const Node& key, const Node& value) 29 | : Node(Node::ZombieNode), std::pair(key, value) {} 30 | }; 31 | } 32 | } 33 | 34 | #endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 35 | -------------------------------------------------------------------------------- /include/yaml-cpp/node/parse.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "yaml-cpp/dll.h" 15 | 16 | namespace YAML { 17 | class Node; 18 | 19 | /** 20 | * Loads the input string as a single YAML document. 21 | * 22 | * @throws {@link ParserException} if it is malformed. 23 | */ 24 | YAML_CPP_API Node Load(const std::string& input); 25 | 26 | /** 27 | * Loads the input string as a single YAML document. 28 | * 29 | * @throws {@link ParserException} if it is malformed. 30 | */ 31 | YAML_CPP_API Node Load(const char* input); 32 | 33 | /** 34 | * Loads the input stream as a single YAML document. 35 | * 36 | * @throws {@link ParserException} if it is malformed. 37 | */ 38 | YAML_CPP_API Node Load(std::istream& input); 39 | 40 | /** 41 | * Loads the input file as a single YAML document. 42 | * 43 | * @throws {@link ParserException} if it is malformed. 44 | * @throws {@link BadFile} if the file cannot be loaded. 45 | */ 46 | YAML_CPP_API Node LoadFile(const std::string& filename); 47 | 48 | /** 49 | * Loads the input string as a list of YAML documents. 50 | * 51 | * @throws {@link ParserException} if it is malformed. 52 | */ 53 | YAML_CPP_API std::vector LoadAll(const std::string& input); 54 | 55 | /** 56 | * Loads the input string as a list of YAML documents. 57 | * 58 | * @throws {@link ParserException} if it is malformed. 59 | */ 60 | YAML_CPP_API std::vector LoadAll(const char* input); 61 | 62 | /** 63 | * Loads the input stream as a list of YAML documents. 64 | * 65 | * @throws {@link ParserException} if it is malformed. 66 | */ 67 | YAML_CPP_API std::vector LoadAll(std::istream& input); 68 | 69 | /** 70 | * Loads the input file as a list of YAML documents. 71 | * 72 | * @throws {@link ParserException} if it is malformed. 73 | * @throws {@link BadFile} if the file cannot be loaded. 74 | */ 75 | YAML_CPP_API std::vector LoadAllFromFile(const std::string& filename); 76 | } // namespace YAML 77 | 78 | #endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 79 | -------------------------------------------------------------------------------- /include/yaml-cpp/node/ptr.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | namespace YAML { 13 | namespace detail { 14 | class node; 15 | class node_ref; 16 | class node_data; 17 | class memory; 18 | class memory_holder; 19 | 20 | using shared_node = std::shared_ptr; 21 | using shared_node_ref = std::shared_ptr; 22 | using shared_node_data = std::shared_ptr; 23 | using shared_memory_holder = std::shared_ptr; 24 | using shared_memory = std::shared_ptr; 25 | } 26 | } 27 | 28 | #endif // VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 29 | -------------------------------------------------------------------------------- /include/yaml-cpp/node/type.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | namespace YAML { 11 | namespace NodeType { 12 | enum value { Undefined, Null, Scalar, Sequence, Map }; 13 | } 14 | 15 | } 16 | 17 | #endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 18 | -------------------------------------------------------------------------------- /include/yaml-cpp/noexcept.h: -------------------------------------------------------------------------------- 1 | #ifndef NOEXCEPT_H_768872DA_476C_11EA_88B8_90B11C0C0FF8 2 | #define NOEXCEPT_H_768872DA_476C_11EA_88B8_90B11C0C0FF8 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | // This is here for compatibility with older versions of Visual Studio 11 | // which don't support noexcept. 12 | #if defined(_MSC_VER) && _MSC_VER < 1900 13 | #define YAML_CPP_NOEXCEPT _NOEXCEPT 14 | #else 15 | #define YAML_CPP_NOEXCEPT noexcept 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /include/yaml-cpp/null.h: -------------------------------------------------------------------------------- 1 | #ifndef NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "yaml-cpp/dll.h" 11 | #include 12 | 13 | namespace YAML { 14 | class Node; 15 | 16 | struct YAML_CPP_API _Null {}; 17 | inline bool operator==(const _Null&, const _Null&) { return true; } 18 | inline bool operator!=(const _Null&, const _Null&) { return false; } 19 | 20 | YAML_CPP_API bool IsNull(const Node& node); // old API only 21 | YAML_CPP_API bool IsNullString(const char* str, std::size_t size); 22 | 23 | extern YAML_CPP_API _Null Null; 24 | } 25 | 26 | #endif // NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 27 | -------------------------------------------------------------------------------- /include/yaml-cpp/ostream_wrapper.h: -------------------------------------------------------------------------------- 1 | #ifndef OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | #include "yaml-cpp/dll.h" 14 | 15 | namespace YAML { 16 | class YAML_CPP_API ostream_wrapper { 17 | public: 18 | ostream_wrapper(); 19 | explicit ostream_wrapper(std::ostream& stream); 20 | ostream_wrapper(const ostream_wrapper&) = delete; 21 | ostream_wrapper(ostream_wrapper&&) = delete; 22 | ostream_wrapper& operator=(const ostream_wrapper&) = delete; 23 | ostream_wrapper& operator=(ostream_wrapper&&) = delete; 24 | ~ostream_wrapper(); 25 | 26 | void write(const std::string& str); 27 | void write(const char* str, std::size_t size); 28 | 29 | void set_comment() { m_comment = true; } 30 | 31 | const char* str() const { 32 | if (m_pStream) { 33 | return nullptr; 34 | } else { 35 | m_buffer[m_pos] = '\0'; 36 | return &m_buffer[0]; 37 | } 38 | } 39 | 40 | std::size_t row() const { return m_row; } 41 | std::size_t col() const { return m_col; } 42 | std::size_t pos() const { return m_pos; } 43 | bool comment() const { return m_comment; } 44 | 45 | private: 46 | void update_pos(char ch); 47 | 48 | private: 49 | mutable std::vector m_buffer; 50 | std::ostream* const m_pStream; 51 | 52 | std::size_t m_pos; 53 | std::size_t m_row, m_col; 54 | bool m_comment; 55 | }; 56 | 57 | template 58 | inline ostream_wrapper& operator<<(ostream_wrapper& stream, 59 | const char (&str)[N]) { 60 | stream.write(str, N - 1); 61 | return stream; 62 | } 63 | 64 | inline ostream_wrapper& operator<<(ostream_wrapper& stream, 65 | const std::string& str) { 66 | stream.write(str); 67 | return stream; 68 | } 69 | 70 | inline ostream_wrapper& operator<<(ostream_wrapper& stream, char ch) { 71 | stream.write(&ch, 1); 72 | return stream; 73 | } 74 | } // namespace YAML 75 | 76 | #endif // OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 77 | -------------------------------------------------------------------------------- /include/yaml-cpp/stlemitter.h: -------------------------------------------------------------------------------- 1 | #ifndef STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace YAML { 16 | template 17 | inline Emitter& EmitSeq(Emitter& emitter, const Seq& seq) { 18 | emitter << BeginSeq; 19 | for (const auto& v : seq) 20 | emitter << v; 21 | emitter << EndSeq; 22 | return emitter; 23 | } 24 | 25 | template 26 | inline Emitter& operator<<(Emitter& emitter, const std::vector& v) { 27 | return EmitSeq(emitter, v); 28 | } 29 | 30 | template 31 | inline Emitter& operator<<(Emitter& emitter, const std::list& v) { 32 | return EmitSeq(emitter, v); 33 | } 34 | 35 | template 36 | inline Emitter& operator<<(Emitter& emitter, const std::set& v) { 37 | return EmitSeq(emitter, v); 38 | } 39 | 40 | template 41 | inline Emitter& operator<<(Emitter& emitter, const std::map& m) { 42 | emitter << BeginMap; 43 | for (const auto& v : m) 44 | emitter << Key << v.first << Value << v.second; 45 | emitter << EndMap; 46 | return emitter; 47 | } 48 | } 49 | 50 | #endif // STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 51 | -------------------------------------------------------------------------------- /include/yaml-cpp/yaml.h: -------------------------------------------------------------------------------- 1 | #ifndef YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "yaml-cpp/parser.h" 11 | #include "yaml-cpp/emitter.h" 12 | #include "yaml-cpp/emitterstyle.h" 13 | #include "yaml-cpp/stlemitter.h" 14 | #include "yaml-cpp/exceptions.h" 15 | 16 | #include "yaml-cpp/node/node.h" 17 | #include "yaml-cpp/node/impl.h" 18 | #include "yaml-cpp/node/convert.h" 19 | #include "yaml-cpp/node/iterator.h" 20 | #include "yaml-cpp/node/detail/impl.h" 21 | #include "yaml-cpp/node/parse.h" 22 | #include "yaml-cpp/node/emit.h" 23 | 24 | #endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 25 | -------------------------------------------------------------------------------- /install.txt: -------------------------------------------------------------------------------- 1 | *** With CMake *** 2 | 3 | yaml-cpp uses CMake to support cross-platform building. In a UNIX-like system, the basic steps to build are: 4 | 5 | 1. Download and install CMake (if you don't have root privileges, just install to a local directory, like ~/bin) 6 | 7 | 2. From the source directory, run: 8 | 9 | mkdir build 10 | cd build 11 | cmake .. 12 | 13 | and then the usual 14 | 15 | make 16 | make install 17 | 18 | 3. To clean up, just remove the 'build' directory. 19 | 20 | *** Without CMake *** 21 | 22 | If you don't want to use CMake, just add all .cpp files to a makefile. yaml-cpp does not need any special build settings, so no 'configure' file is necessary. 23 | 24 | (Note: this is pretty tedious. It's sooo much easier to use CMake.) 25 | -------------------------------------------------------------------------------- /src/collectionstack.h: -------------------------------------------------------------------------------- 1 | #ifndef COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | namespace YAML { 14 | struct CollectionType { 15 | enum value { NoCollection, BlockMap, BlockSeq, FlowMap, FlowSeq, CompactMap }; 16 | }; 17 | 18 | class CollectionStack { 19 | public: 20 | CollectionStack() : collectionStack{} {} 21 | CollectionType::value GetCurCollectionType() const { 22 | if (collectionStack.empty()) 23 | return CollectionType::NoCollection; 24 | return collectionStack.top(); 25 | } 26 | 27 | void PushCollectionType(CollectionType::value type) { 28 | collectionStack.push(type); 29 | } 30 | void PopCollectionType(CollectionType::value type) { 31 | assert(type == GetCurCollectionType()); 32 | (void)type; 33 | collectionStack.pop(); 34 | } 35 | 36 | private: 37 | std::stack collectionStack; 38 | }; 39 | } // namespace YAML 40 | 41 | #endif // COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 42 | -------------------------------------------------------------------------------- /src/contrib/graphbuilder.cpp: -------------------------------------------------------------------------------- 1 | #include "graphbuilderadapter.h" 2 | 3 | #include "yaml-cpp/parser.h" // IWYU pragma: keep 4 | 5 | namespace YAML { 6 | class GraphBuilderInterface; 7 | 8 | void* BuildGraphOfNextDocument(Parser& parser, 9 | GraphBuilderInterface& graphBuilder) { 10 | GraphBuilderAdapter eventHandler(graphBuilder); 11 | if (parser.HandleNextDocument(eventHandler)) { 12 | return eventHandler.RootNode(); 13 | } 14 | return nullptr; 15 | } 16 | } // namespace YAML 17 | -------------------------------------------------------------------------------- /src/contrib/yaml-cpp.natvis: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{invalid}} 6 | {{pNode==nullptr}} 7 | {{ {*m_pNode} }} 8 | 9 | m_pNode->m_pRef._Ptr->m_pData._Ptr->m_scalar 10 | m_pNode->m_pRef._Ptr->m_pData._Ptr->m_sequence 11 | m_pNode->m_pRef._Ptr->m_pData._Ptr->m_map 12 | m_pNode->m_pRef._Ptr->m_pData._Ptr 13 | 14 | 15 | 16 | 17 | {{node:pRef==nullptr}} 18 | {{node:pRef->pData==nullptr}} 19 | {{undefined}} 20 | {{{m_pRef._Ptr->m_pData._Ptr->m_scalar}}} 21 | {{ Map {m_pRef._Ptr->m_pData._Ptr->m_map}}} 22 | {{ Seq {m_pRef._Ptr->m_pData._Ptr->m_sequence}}} 23 | {{{m_pRef._Ptr->m_pData._Ptr->m_type}}} 24 | 25 | m_pRef._Ptr->m_pData._Ptr->m_scalar 26 | m_pRef._Ptr->m_pData._Ptr->m_sequence 27 | m_pRef._Ptr->m_pData._Ptr->m_map 28 | m_pRef._Ptr->m_pData._Ptr 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/contrib/yaml-cpp.natvis.md: -------------------------------------------------------------------------------- 1 | # MSVC debugger visualizer for YAML::Node 2 | 3 | ## How to use 4 | Add yaml-cpp.natvis to your Visual C++ project like any other source file. It will be included in the debug information, and improve debugger display on YAML::Node and contained types. 5 | 6 | ## Compatibility and Troubleshooting 7 | 8 | This has been tested for MSVC 2017. It is expected to be compatible with VS 2015 and VS 2019. If you have any problems, you can open an issue here: https://github.com/peterchen-cp/yaml-cpp-natvis 9 | 10 | -------------------------------------------------------------------------------- /src/convert.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "yaml-cpp/node/convert.h" 4 | 5 | namespace { 6 | // we're not gonna mess with the mess that is all the isupper/etc. functions 7 | bool IsLower(char ch) { return 'a' <= ch && ch <= 'z'; } 8 | bool IsUpper(char ch) { return 'A' <= ch && ch <= 'Z'; } 9 | char ToLower(char ch) { return IsUpper(ch) ? ch + 'a' - 'A' : ch; } 10 | 11 | std::string tolower(const std::string& str) { 12 | std::string s(str); 13 | std::transform(s.begin(), s.end(), s.begin(), ToLower); 14 | return s; 15 | } 16 | 17 | template 18 | bool IsEntirely(const std::string& str, T func) { 19 | return std::all_of(str.begin(), str.end(), [=](char ch) { return func(ch); }); 20 | } 21 | 22 | // IsFlexibleCase 23 | // . Returns true if 'str' is: 24 | // . UPPERCASE 25 | // . lowercase 26 | // . Capitalized 27 | bool IsFlexibleCase(const std::string& str) { 28 | if (str.empty()) 29 | return true; 30 | 31 | if (IsEntirely(str, IsLower)) 32 | return true; 33 | 34 | bool firstcaps = IsUpper(str[0]); 35 | std::string rest = str.substr(1); 36 | return firstcaps && (IsEntirely(rest, IsLower) || IsEntirely(rest, IsUpper)); 37 | } 38 | } // namespace 39 | 40 | namespace YAML { 41 | bool convert::decode(const Node& node, bool& rhs) { 42 | if (!node.IsScalar()) 43 | return false; 44 | 45 | // we can't use iostream bool extraction operators as they don't 46 | // recognize all possible values in the table below (taken from 47 | // http://yaml.org/type/bool.html) 48 | static const struct { 49 | std::string truename, falsename; 50 | } names[] = { 51 | {"y", "n"}, 52 | {"yes", "no"}, 53 | {"true", "false"}, 54 | {"on", "off"}, 55 | }; 56 | 57 | if (!IsFlexibleCase(node.Scalar())) 58 | return false; 59 | 60 | for (const auto& name : names) { 61 | if (name.truename == tolower(node.Scalar())) { 62 | rhs = true; 63 | return true; 64 | } 65 | 66 | if (name.falsename == tolower(node.Scalar())) { 67 | rhs = false; 68 | return true; 69 | } 70 | } 71 | 72 | return false; 73 | } 74 | } // namespace YAML 75 | -------------------------------------------------------------------------------- /src/depthguard.cpp: -------------------------------------------------------------------------------- 1 | #include "yaml-cpp/depthguard.h" 2 | 3 | namespace YAML { 4 | 5 | DeepRecursion::DeepRecursion(int depth, const Mark& mark_, 6 | const std::string& msg_) 7 | : ParserException(mark_, msg_), m_depth(depth) {} 8 | 9 | } // namespace YAML 10 | -------------------------------------------------------------------------------- /src/directives.cpp: -------------------------------------------------------------------------------- 1 | #include "directives.h" 2 | 3 | namespace YAML { 4 | Directives::Directives() : version{true, 1, 2}, tags{} {} 5 | 6 | std::string Directives::TranslateTagHandle( 7 | const std::string& handle) const { 8 | auto it = tags.find(handle); 9 | if (it == tags.end()) { 10 | if (handle == "!!") 11 | return "tag:yaml.org,2002:"; 12 | return handle; 13 | } 14 | 15 | return it->second; 16 | } 17 | } // namespace YAML 18 | -------------------------------------------------------------------------------- /src/directives.h: -------------------------------------------------------------------------------- 1 | #ifndef DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | namespace YAML { 14 | struct Version { 15 | bool isDefault; 16 | int major, minor; 17 | }; 18 | 19 | struct Directives { 20 | Directives(); 21 | 22 | std::string TranslateTagHandle(const std::string& handle) const; 23 | 24 | Version version; 25 | std::map tags; 26 | }; 27 | } 28 | 29 | #endif // DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66 30 | -------------------------------------------------------------------------------- /src/emit.cpp: -------------------------------------------------------------------------------- 1 | #include "yaml-cpp/node/emit.h" 2 | #include "nodeevents.h" 3 | #include "yaml-cpp/emitfromevents.h" 4 | #include "yaml-cpp/emitter.h" 5 | 6 | namespace YAML { 7 | Emitter& operator<<(Emitter& out, const Node& node) { 8 | EmitFromEvents emitFromEvents(out); 9 | NodeEvents events(node); 10 | events.Emit(emitFromEvents); 11 | return out; 12 | } 13 | 14 | std::ostream& operator<<(std::ostream& out, const Node& node) { 15 | Emitter emitter(out); 16 | emitter << node; 17 | return out; 18 | } 19 | 20 | std::string Dump(const Node& node) { 21 | Emitter emitter; 22 | emitter << node; 23 | return emitter.c_str(); 24 | } 25 | } // namespace YAML 26 | -------------------------------------------------------------------------------- /src/emitterutils.h: -------------------------------------------------------------------------------- 1 | #ifndef EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | #include "emitterstate.h" 13 | #include "yaml-cpp/emittermanip.h" 14 | #include "yaml-cpp/ostream_wrapper.h" 15 | 16 | namespace YAML { 17 | class ostream_wrapper; 18 | } // namespace YAML 19 | 20 | namespace YAML { 21 | class Binary; 22 | 23 | struct StringFormat { 24 | enum value { Plain, SingleQuoted, DoubleQuoted, Literal }; 25 | }; 26 | 27 | struct StringEscaping { 28 | enum value { None, NonAscii, JSON }; 29 | }; 30 | 31 | namespace Utils { 32 | StringFormat::value ComputeStringFormat(const char* str, std::size_t size, 33 | EMITTER_MANIP strFormat, 34 | FlowType::value flowType, 35 | bool escapeNonAscii); 36 | 37 | bool WriteSingleQuotedString(ostream_wrapper& out, const char* str, std::size_t size); 38 | bool WriteDoubleQuotedString(ostream_wrapper& out, const char* str, std::size_t size, 39 | StringEscaping::value stringEscaping); 40 | bool WriteLiteralString(ostream_wrapper& out, const char* str, std::size_t size, 41 | std::size_t indent); 42 | bool WriteChar(ostream_wrapper& out, char ch, 43 | StringEscaping::value stringEscapingStyle); 44 | bool WriteComment(ostream_wrapper& out, const char* str, std::size_t size, 45 | std::size_t postCommentIndent); 46 | bool WriteAlias(ostream_wrapper& out, const char* str, std::size_t size); 47 | bool WriteAnchor(ostream_wrapper& out, const char* str, std::size_t size); 48 | bool WriteTag(ostream_wrapper& out, const std::string& str, bool verbatim); 49 | bool WriteTagWithPrefix(ostream_wrapper& out, const std::string& prefix, 50 | const std::string& tag); 51 | bool WriteBinary(ostream_wrapper& out, const Binary& binary); 52 | } 53 | } 54 | 55 | #endif // EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 56 | -------------------------------------------------------------------------------- /src/exceptions.cpp: -------------------------------------------------------------------------------- 1 | #include "yaml-cpp/exceptions.h" 2 | #include "yaml-cpp/noexcept.h" 3 | 4 | namespace YAML { 5 | 6 | // These destructors are defined out-of-line so the vtable is only emitted once. 7 | Exception::~Exception() YAML_CPP_NOEXCEPT = default; 8 | ParserException::~ParserException() YAML_CPP_NOEXCEPT = default; 9 | RepresentationException::~RepresentationException() YAML_CPP_NOEXCEPT = default; 10 | InvalidScalar::~InvalidScalar() YAML_CPP_NOEXCEPT = default; 11 | KeyNotFound::~KeyNotFound() YAML_CPP_NOEXCEPT = default; 12 | InvalidNode::~InvalidNode() YAML_CPP_NOEXCEPT = default; 13 | BadConversion::~BadConversion() YAML_CPP_NOEXCEPT = default; 14 | BadDereference::~BadDereference() YAML_CPP_NOEXCEPT = default; 15 | BadSubscript::~BadSubscript() YAML_CPP_NOEXCEPT = default; 16 | BadPushback::~BadPushback() YAML_CPP_NOEXCEPT = default; 17 | BadInsert::~BadInsert() YAML_CPP_NOEXCEPT = default; 18 | EmitterException::~EmitterException() YAML_CPP_NOEXCEPT = default; 19 | BadFile::~BadFile() YAML_CPP_NOEXCEPT = default; 20 | } // namespace YAML 21 | -------------------------------------------------------------------------------- /src/indentation.h: -------------------------------------------------------------------------------- 1 | #ifndef INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | #include "yaml-cpp/ostream_wrapper.h" 13 | 14 | namespace YAML { 15 | struct Indentation { 16 | Indentation(std::size_t n_) : n(n_) {} 17 | std::size_t n; 18 | }; 19 | 20 | inline ostream_wrapper& operator<<(ostream_wrapper& out, 21 | const Indentation& indent) { 22 | for (std::size_t i = 0; i < indent.n; i++) 23 | out << ' '; 24 | return out; 25 | } 26 | 27 | struct IndentTo { 28 | IndentTo(std::size_t n_) : n(n_) {} 29 | std::size_t n; 30 | }; 31 | 32 | inline ostream_wrapper& operator<<(ostream_wrapper& out, 33 | const IndentTo& indent) { 34 | while (out.col() < indent.n) 35 | out << ' '; 36 | return out; 37 | } 38 | } 39 | 40 | #endif // INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 41 | -------------------------------------------------------------------------------- /src/memory.cpp: -------------------------------------------------------------------------------- 1 | #include "yaml-cpp/node/detail/memory.h" 2 | #include "yaml-cpp/node/detail/node.h" // IWYU pragma: keep 3 | #include "yaml-cpp/node/ptr.h" 4 | 5 | namespace YAML { 6 | namespace detail { 7 | 8 | void memory_holder::merge(memory_holder& rhs) { 9 | if (m_pMemory == rhs.m_pMemory) 10 | return; 11 | 12 | m_pMemory->merge(*rhs.m_pMemory); 13 | rhs.m_pMemory = m_pMemory; 14 | } 15 | 16 | node& memory::create_node() { 17 | shared_node pNode(new node); 18 | m_nodes.insert(pNode); 19 | return *pNode; 20 | } 21 | 22 | void memory::merge(const memory& rhs) { 23 | m_nodes.insert(rhs.m_nodes.begin(), rhs.m_nodes.end()); 24 | } 25 | } // namespace detail 26 | } // namespace YAML 27 | -------------------------------------------------------------------------------- /src/node.cpp: -------------------------------------------------------------------------------- 1 | #include "yaml-cpp/node/node.h" 2 | #include "nodebuilder.h" 3 | #include "nodeevents.h" 4 | 5 | namespace YAML { 6 | Node Clone(const Node& node) { 7 | NodeEvents events(node); 8 | NodeBuilder builder; 9 | events.Emit(builder); 10 | return builder.Root(); 11 | } 12 | } // namespace YAML 13 | -------------------------------------------------------------------------------- /src/nodebuilder.h: -------------------------------------------------------------------------------- 1 | #ifndef NODE_NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define NODE_NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | #include "yaml-cpp/anchor.h" 13 | #include "yaml-cpp/emitterstyle.h" 14 | #include "yaml-cpp/eventhandler.h" 15 | #include "yaml-cpp/node/ptr.h" 16 | 17 | namespace YAML { 18 | namespace detail { 19 | class node; 20 | } // namespace detail 21 | struct Mark; 22 | } // namespace YAML 23 | 24 | namespace YAML { 25 | class Node; 26 | 27 | class NodeBuilder : public EventHandler { 28 | public: 29 | NodeBuilder(); 30 | NodeBuilder(const NodeBuilder&) = delete; 31 | NodeBuilder(NodeBuilder&&) = delete; 32 | NodeBuilder& operator=(const NodeBuilder&) = delete; 33 | NodeBuilder& operator=(NodeBuilder&&) = delete; 34 | ~NodeBuilder() override; 35 | 36 | Node Root(); 37 | 38 | void OnDocumentStart(const Mark& mark) override; 39 | void OnDocumentEnd() override; 40 | 41 | void OnNull(const Mark& mark, anchor_t anchor) override; 42 | void OnAlias(const Mark& mark, anchor_t anchor) override; 43 | void OnScalar(const Mark& mark, const std::string& tag, 44 | anchor_t anchor, const std::string& value) override; 45 | 46 | void OnSequenceStart(const Mark& mark, const std::string& tag, 47 | anchor_t anchor, EmitterStyle::value style) override; 48 | void OnSequenceEnd() override; 49 | 50 | void OnMapStart(const Mark& mark, const std::string& tag, 51 | anchor_t anchor, EmitterStyle::value style) override; 52 | void OnMapEnd() override; 53 | 54 | private: 55 | detail::node& Push(const Mark& mark, anchor_t anchor); 56 | void Push(detail::node& node); 57 | void Pop(); 58 | void RegisterAnchor(anchor_t anchor, detail::node& node); 59 | 60 | private: 61 | detail::shared_memory_holder m_pMemory; 62 | detail::node* m_pRoot; 63 | 64 | using Nodes = std::vector; 65 | Nodes m_stack; 66 | Nodes m_anchors; 67 | 68 | using PushedKey = std::pair; 69 | std::vector m_keys; 70 | std::size_t m_mapDepth; 71 | }; 72 | } // namespace YAML 73 | 74 | #endif // NODE_NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 75 | -------------------------------------------------------------------------------- /src/nodeevents.h: -------------------------------------------------------------------------------- 1 | #ifndef NODE_NODEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define NODE_NODEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | #include "yaml-cpp/anchor.h" 14 | #include "yaml-cpp/node/ptr.h" 15 | 16 | namespace YAML { 17 | namespace detail { 18 | class node; 19 | } // namespace detail 20 | } // namespace YAML 21 | 22 | namespace YAML { 23 | class EventHandler; 24 | class Node; 25 | 26 | class NodeEvents { 27 | public: 28 | explicit NodeEvents(const Node& node); 29 | NodeEvents(const NodeEvents&) = delete; 30 | NodeEvents(NodeEvents&&) = delete; 31 | NodeEvents& operator=(const NodeEvents&) = delete; 32 | NodeEvents& operator=(NodeEvents&&) = delete; 33 | 34 | void Emit(EventHandler& handler); 35 | 36 | private: 37 | class AliasManager { 38 | public: 39 | AliasManager() : m_anchorByIdentity{}, m_curAnchor(0) {} 40 | 41 | void RegisterReference(const detail::node& node); 42 | anchor_t LookupAnchor(const detail::node& node) const; 43 | 44 | private: 45 | anchor_t _CreateNewAnchor() { return ++m_curAnchor; } 46 | 47 | private: 48 | using AnchorByIdentity = std::map; 49 | AnchorByIdentity m_anchorByIdentity; 50 | 51 | anchor_t m_curAnchor; 52 | }; 53 | 54 | void Setup(const detail::node& node); 55 | void Emit(const detail::node& node, EventHandler& handler, 56 | AliasManager& am) const; 57 | bool IsAliased(const detail::node& node) const; 58 | 59 | private: 60 | detail::shared_memory_holder m_pMemory; 61 | detail::node* m_root; 62 | 63 | using RefCount = std::map; 64 | RefCount m_refCount; 65 | }; 66 | } // namespace YAML 67 | 68 | #endif // NODE_NODEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 69 | -------------------------------------------------------------------------------- /src/null.cpp: -------------------------------------------------------------------------------- 1 | #include "yaml-cpp/null.h" 2 | #include 3 | 4 | namespace YAML { 5 | _Null Null; 6 | 7 | template 8 | static bool same(const char* str, std::size_t size, const char (&literal)[N]) { 9 | constexpr int literalSize = N - 1; // minus null terminator 10 | return size == literalSize && std::strncmp(str, literal, literalSize) == 0; 11 | } 12 | 13 | bool IsNullString(const char* str, std::size_t size) { 14 | return size == 0 || same(str, size, "~") || same(str, size, "null") || 15 | same(str, size, "Null") || same(str, size, "NULL"); 16 | } 17 | } // namespace YAML 18 | -------------------------------------------------------------------------------- /src/ostream_wrapper.cpp: -------------------------------------------------------------------------------- 1 | #include "yaml-cpp/ostream_wrapper.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace YAML { 8 | ostream_wrapper::ostream_wrapper() 9 | : m_buffer(1, '\0'), 10 | m_pStream(nullptr), 11 | m_pos(0), 12 | m_row(0), 13 | m_col(0), 14 | m_comment(false) {} 15 | 16 | ostream_wrapper::ostream_wrapper(std::ostream& stream) 17 | : m_buffer{}, 18 | m_pStream(&stream), 19 | m_pos(0), 20 | m_row(0), 21 | m_col(0), 22 | m_comment(false) {} 23 | 24 | ostream_wrapper::~ostream_wrapper() = default; 25 | 26 | void ostream_wrapper::write(const std::string& str) { 27 | if (m_pStream) { 28 | m_pStream->write(str.c_str(), str.size()); 29 | } else { 30 | m_buffer.resize(std::max(m_buffer.size(), m_pos + str.size() + 1)); 31 | std::copy(str.begin(), str.end(), m_buffer.begin() + m_pos); 32 | } 33 | 34 | for (char ch : str) { 35 | update_pos(ch); 36 | } 37 | } 38 | 39 | void ostream_wrapper::write(const char* str, std::size_t size) { 40 | if (m_pStream) { 41 | m_pStream->write(str, size); 42 | } else { 43 | m_buffer.resize(std::max(m_buffer.size(), m_pos + size + 1)); 44 | std::copy(str, str + size, m_buffer.begin() + m_pos); 45 | } 46 | 47 | for (std::size_t i = 0; i < size; i++) { 48 | update_pos(str[i]); 49 | } 50 | } 51 | 52 | void ostream_wrapper::update_pos(char ch) { 53 | m_pos++; 54 | m_col++; 55 | 56 | if (ch == '\n') { 57 | m_row++; 58 | m_col = 0; 59 | m_comment = false; 60 | } 61 | } 62 | } // namespace YAML 63 | -------------------------------------------------------------------------------- /src/parse.cpp: -------------------------------------------------------------------------------- 1 | #include "yaml-cpp/node/parse.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "nodebuilder.h" 7 | #include "yaml-cpp/node/impl.h" 8 | #include "yaml-cpp/node/node.h" 9 | #include "yaml-cpp/parser.h" 10 | 11 | namespace YAML { 12 | Node Load(const std::string& input) { 13 | std::stringstream stream(input); 14 | return Load(stream); 15 | } 16 | 17 | Node Load(const char* input) { 18 | std::stringstream stream(input); 19 | return Load(stream); 20 | } 21 | 22 | Node Load(std::istream& input) { 23 | Parser parser(input); 24 | NodeBuilder builder; 25 | if (!parser.HandleNextDocument(builder)) { 26 | return Node(); 27 | } 28 | 29 | return builder.Root(); 30 | } 31 | 32 | Node LoadFile(const std::string& filename) { 33 | std::ifstream fin(filename); 34 | if (!fin) { 35 | throw BadFile(filename); 36 | } 37 | return Load(fin); 38 | } 39 | 40 | std::vector LoadAll(const std::string& input) { 41 | std::stringstream stream(input); 42 | return LoadAll(stream); 43 | } 44 | 45 | std::vector LoadAll(const char* input) { 46 | std::stringstream stream(input); 47 | return LoadAll(stream); 48 | } 49 | 50 | std::vector LoadAll(std::istream& input) { 51 | std::vector docs; 52 | 53 | Parser parser(input); 54 | while (true) { 55 | NodeBuilder builder; 56 | if (!parser.HandleNextDocument(builder) || builder.Root().IsNull()) { 57 | break; 58 | } 59 | docs.push_back(builder.Root()); 60 | } 61 | 62 | return docs; 63 | } 64 | 65 | std::vector LoadAllFromFile(const std::string& filename) { 66 | std::ifstream fin(filename); 67 | if (!fin) { 68 | throw BadFile(filename); 69 | } 70 | return LoadAll(fin); 71 | } 72 | } // namespace YAML 73 | -------------------------------------------------------------------------------- /src/ptr_vector.h: -------------------------------------------------------------------------------- 1 | #ifndef PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace YAML { 16 | 17 | // TODO: This class is no longer needed 18 | template 19 | class ptr_vector { 20 | public: 21 | ptr_vector() : m_data{} {} 22 | ptr_vector(const ptr_vector&) = delete; 23 | ptr_vector(ptr_vector&&) = default; 24 | ptr_vector& operator=(const ptr_vector&) = delete; 25 | ptr_vector& operator=(ptr_vector&&) = default; 26 | 27 | void clear() { m_data.clear(); } 28 | 29 | std::size_t size() const { return m_data.size(); } 30 | bool empty() const { return m_data.empty(); } 31 | 32 | void push_back(std::unique_ptr&& t) { m_data.push_back(std::move(t)); } 33 | T& operator[](std::size_t i) { return *m_data[i]; } 34 | const T& operator[](std::size_t i) const { return *m_data[i]; } 35 | 36 | T& back() { return *(m_data.back().get()); } 37 | 38 | const T& back() const { return *(m_data.back().get()); } 39 | 40 | private: 41 | std::vector> m_data; 42 | }; 43 | } // namespace YAML 44 | 45 | #endif // PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 46 | -------------------------------------------------------------------------------- /src/regex_yaml.cpp: -------------------------------------------------------------------------------- 1 | #include "regex_yaml.h" 2 | 3 | namespace YAML { 4 | // constructors 5 | 6 | RegEx::RegEx(REGEX_OP op) : m_op(op), m_a(0), m_z(0), m_params{} {} 7 | RegEx::RegEx() : RegEx(REGEX_EMPTY) {} 8 | 9 | RegEx::RegEx(char ch) : m_op(REGEX_MATCH), m_a(ch), m_z(0), m_params{} {} 10 | 11 | RegEx::RegEx(char a, char z) : m_op(REGEX_RANGE), m_a(a), m_z(z), m_params{} {} 12 | 13 | RegEx::RegEx(const std::string& str, REGEX_OP op) 14 | : m_op(op), m_a(0), m_z(0), m_params(str.begin(), str.end()) {} 15 | 16 | // combination constructors 17 | RegEx operator!(const RegEx& ex) { 18 | RegEx ret(REGEX_NOT); 19 | ret.m_params.push_back(ex); 20 | return ret; 21 | } 22 | 23 | RegEx operator|(const RegEx& ex1, const RegEx& ex2) { 24 | RegEx ret(REGEX_OR); 25 | ret.m_params.push_back(ex1); 26 | ret.m_params.push_back(ex2); 27 | return ret; 28 | } 29 | 30 | RegEx operator&(const RegEx& ex1, const RegEx& ex2) { 31 | RegEx ret(REGEX_AND); 32 | ret.m_params.push_back(ex1); 33 | ret.m_params.push_back(ex2); 34 | return ret; 35 | } 36 | 37 | RegEx operator+(const RegEx& ex1, const RegEx& ex2) { 38 | RegEx ret(REGEX_SEQ); 39 | ret.m_params.push_back(ex1); 40 | ret.m_params.push_back(ex2); 41 | return ret; 42 | } 43 | } // namespace YAML 44 | -------------------------------------------------------------------------------- /src/scanscalar.h: -------------------------------------------------------------------------------- 1 | #ifndef SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | #include "regex_yaml.h" 13 | #include "stream.h" 14 | 15 | namespace YAML { 16 | enum CHOMP { STRIP = -1, CLIP, KEEP }; 17 | enum ACTION { NONE, BREAK, THROW }; 18 | enum FOLD { DONT_FOLD, FOLD_BLOCK, FOLD_FLOW }; 19 | 20 | struct ScanScalarParams { 21 | ScanScalarParams() 22 | : end(nullptr), 23 | eatEnd(false), 24 | indent(0), 25 | detectIndent(false), 26 | eatLeadingWhitespace(0), 27 | escape(0), 28 | fold(DONT_FOLD), 29 | trimTrailingSpaces(0), 30 | chomp(CLIP), 31 | onDocIndicator(NONE), 32 | onTabInIndentation(NONE), 33 | leadingSpaces(false) {} 34 | 35 | // input: 36 | const RegEx* end; // what condition ends this scalar? 37 | // unowned. 38 | bool eatEnd; // should we eat that condition when we see it? 39 | int indent; // what level of indentation should be eaten and ignored? 40 | bool detectIndent; // should we try to autodetect the indent? 41 | bool eatLeadingWhitespace; // should we continue eating this delicious 42 | // indentation after 'indent' spaces? 43 | char escape; // what character do we escape on (i.e., slash or single quote) 44 | // (0 for none) 45 | FOLD fold; // how do we fold line ends? 46 | bool trimTrailingSpaces; // do we remove all trailing spaces (at the very 47 | // end) 48 | CHOMP chomp; // do we strip, clip, or keep trailing newlines (at the very 49 | // end) 50 | // Note: strip means kill all, clip means keep at most one, keep means keep 51 | // all 52 | ACTION onDocIndicator; // what do we do if we see a document indicator? 53 | ACTION onTabInIndentation; // what do we do if we see a tab where we should 54 | // be seeing indentation spaces 55 | 56 | // output: 57 | bool leadingSpaces; 58 | }; 59 | 60 | std::string ScanScalar(Stream& INPUT, ScanScalarParams& params); 61 | } 62 | 63 | #endif // SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 64 | -------------------------------------------------------------------------------- /src/scantag.cpp: -------------------------------------------------------------------------------- 1 | #include "exp.h" 2 | #include "regex_yaml.h" 3 | #include "regeximpl.h" 4 | #include "stream.h" 5 | #include "yaml-cpp/exceptions.h" // IWYU pragma: keep 6 | #include "yaml-cpp/mark.h" 7 | 8 | namespace YAML { 9 | const std::string ScanVerbatimTag(Stream& INPUT) { 10 | std::string tag; 11 | 12 | // eat the start character 13 | INPUT.get(); 14 | 15 | while (INPUT) { 16 | if (INPUT.peek() == Keys::VerbatimTagEnd) { 17 | // eat the end character 18 | INPUT.get(); 19 | return tag; 20 | } 21 | 22 | int n = Exp::URI().Match(INPUT); 23 | if (n <= 0) 24 | break; 25 | 26 | tag += INPUT.get(n); 27 | } 28 | 29 | throw ParserException(INPUT.mark(), ErrorMsg::END_OF_VERBATIM_TAG); 30 | } 31 | 32 | const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle) { 33 | std::string tag; 34 | canBeHandle = true; 35 | Mark firstNonWordChar; 36 | 37 | while (INPUT) { 38 | if (INPUT.peek() == Keys::Tag) { 39 | if (!canBeHandle) 40 | throw ParserException(firstNonWordChar, ErrorMsg::CHAR_IN_TAG_HANDLE); 41 | break; 42 | } 43 | 44 | int n = 0; 45 | if (canBeHandle) { 46 | n = Exp::Word().Match(INPUT); 47 | if (n <= 0) { 48 | canBeHandle = false; 49 | firstNonWordChar = INPUT.mark(); 50 | } 51 | } 52 | 53 | if (!canBeHandle) 54 | n = Exp::Tag().Match(INPUT); 55 | 56 | if (n <= 0) 57 | break; 58 | 59 | tag += INPUT.get(n); 60 | } 61 | 62 | return tag; 63 | } 64 | 65 | const std::string ScanTagSuffix(Stream& INPUT) { 66 | std::string tag; 67 | 68 | while (INPUT) { 69 | int n = Exp::Tag().Match(INPUT); 70 | if (n <= 0) 71 | break; 72 | 73 | tag += INPUT.get(n); 74 | } 75 | 76 | if (tag.empty()) 77 | throw ParserException(INPUT.mark(), ErrorMsg::TAG_WITH_NO_SUFFIX); 78 | 79 | return tag; 80 | } 81 | } // namespace YAML 82 | -------------------------------------------------------------------------------- /src/scantag.h: -------------------------------------------------------------------------------- 1 | #ifndef SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include "stream.h" 12 | 13 | namespace YAML { 14 | const std::string ScanVerbatimTag(Stream& INPUT); 15 | const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle); 16 | const std::string ScanTagSuffix(Stream& INPUT); 17 | } 18 | 19 | #endif // SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 20 | -------------------------------------------------------------------------------- /src/singledocparser.h: -------------------------------------------------------------------------------- 1 | #ifndef SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "yaml-cpp/anchor.h" 15 | 16 | namespace YAML { 17 | class CollectionStack; 18 | template class DepthGuard; // depthguard.h 19 | class EventHandler; 20 | class Node; 21 | class Scanner; 22 | struct Directives; 23 | struct Mark; 24 | struct Token; 25 | 26 | class SingleDocParser { 27 | public: 28 | SingleDocParser(Scanner& scanner, const Directives& directives); 29 | SingleDocParser(const SingleDocParser&) = delete; 30 | SingleDocParser(SingleDocParser&&) = delete; 31 | SingleDocParser& operator=(const SingleDocParser&) = delete; 32 | SingleDocParser& operator=(SingleDocParser&&) = delete; 33 | ~SingleDocParser(); 34 | 35 | void HandleDocument(EventHandler& eventHandler); 36 | 37 | private: 38 | void HandleNode(EventHandler& eventHandler); 39 | 40 | void HandleSequence(EventHandler& eventHandler); 41 | void HandleBlockSequence(EventHandler& eventHandler); 42 | void HandleFlowSequence(EventHandler& eventHandler); 43 | 44 | void HandleMap(EventHandler& eventHandler); 45 | void HandleBlockMap(EventHandler& eventHandler); 46 | void HandleFlowMap(EventHandler& eventHandler); 47 | void HandleCompactMap(EventHandler& eventHandler); 48 | void HandleCompactMapWithNoKey(EventHandler& eventHandler); 49 | 50 | void ParseProperties(std::string& tag, anchor_t& anchor, 51 | std::string& anchor_name); 52 | void ParseTag(std::string& tag); 53 | void ParseAnchor(anchor_t& anchor, std::string& anchor_name); 54 | 55 | anchor_t RegisterAnchor(const std::string& name); 56 | anchor_t LookupAnchor(const Mark& mark, const std::string& name) const; 57 | 58 | private: 59 | int depth = 0; 60 | Scanner& m_scanner; 61 | const Directives& m_directives; 62 | std::unique_ptr m_pCollectionStack; 63 | 64 | using Anchors = std::map; 65 | Anchors m_anchors; 66 | 67 | anchor_t m_curAnchor; 68 | }; 69 | } // namespace YAML 70 | 71 | #endif // SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 72 | -------------------------------------------------------------------------------- /src/stream.h: -------------------------------------------------------------------------------- 1 | #ifndef STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "yaml-cpp/mark.h" 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace YAML { 19 | 20 | class StreamCharSource; 21 | 22 | class Stream { 23 | public: 24 | friend class StreamCharSource; 25 | 26 | Stream(std::istream& input); 27 | Stream(const Stream&) = delete; 28 | Stream(Stream&&) = delete; 29 | Stream& operator=(const Stream&) = delete; 30 | Stream& operator=(Stream&&) = delete; 31 | ~Stream(); 32 | 33 | operator bool() const; 34 | bool operator!() const { return !static_cast(*this); } 35 | 36 | char peek() const; 37 | char get(); 38 | std::string get(int n); 39 | void eat(int n = 1); 40 | 41 | static char eof() { return 0x04; } 42 | 43 | const Mark mark() const { return m_mark; } 44 | int pos() const { return m_mark.pos; } 45 | int line() const { return m_mark.line; } 46 | int column() const { return m_mark.column; } 47 | void ResetColumn() { m_mark.column = 0; } 48 | 49 | private: 50 | enum CharacterSet { utf8, utf16le, utf16be, utf32le, utf32be }; 51 | 52 | std::istream& m_input; 53 | Mark m_mark; 54 | 55 | CharacterSet m_charSet; 56 | char m_lineEndingSymbol{}; // 0 means it is not determined yet, must be '\n' or '\r' 57 | mutable std::deque m_readahead; 58 | unsigned char* const m_pPrefetched; 59 | mutable size_t m_nPrefetchedAvailable; 60 | mutable size_t m_nPrefetchedUsed; 61 | 62 | void AdvanceCurrent(); 63 | char CharAt(size_t i) const; 64 | bool ReadAheadTo(size_t i) const; 65 | bool _ReadAheadTo(size_t i) const; 66 | void StreamInUtf8() const; 67 | void StreamInUtf16() const; 68 | void StreamInUtf32() const; 69 | unsigned char GetNextByte() const; 70 | }; 71 | 72 | // CharAt 73 | // . Unchecked access 74 | inline char Stream::CharAt(size_t i) const { return m_readahead[i]; } 75 | 76 | inline bool Stream::ReadAheadTo(size_t i) const { 77 | if (m_readahead.size() > i) 78 | return true; 79 | return _ReadAheadTo(i); 80 | } 81 | } // namespace YAML 82 | 83 | #endif // STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 84 | -------------------------------------------------------------------------------- /src/streamcharsource.h: -------------------------------------------------------------------------------- 1 | #ifndef STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "yaml-cpp/noexcept.h" 11 | #include "stream.h" 12 | #include 13 | 14 | namespace YAML { 15 | 16 | class StreamCharSource { 17 | public: 18 | StreamCharSource(const Stream& stream) : m_offset(0), m_stream(stream) {} 19 | StreamCharSource(const StreamCharSource& source) = default; 20 | StreamCharSource(StreamCharSource&&) YAML_CPP_NOEXCEPT = default; 21 | StreamCharSource& operator=(const StreamCharSource&) = delete; 22 | StreamCharSource& operator=(StreamCharSource&&) = delete; 23 | ~StreamCharSource() = default; 24 | 25 | operator bool() const; 26 | char operator[](std::size_t i) const { return m_stream.CharAt(m_offset + i); } 27 | bool operator!() const { return !static_cast(*this); } 28 | 29 | const StreamCharSource operator+(int i) const; 30 | 31 | private: 32 | std::size_t m_offset; 33 | const Stream& m_stream; 34 | }; 35 | 36 | inline StreamCharSource::operator bool() const { 37 | return m_stream.ReadAheadTo(m_offset); 38 | } 39 | 40 | inline const StreamCharSource StreamCharSource::operator+(int i) const { 41 | StreamCharSource source(*this); 42 | if (static_cast(source.m_offset) + i >= 0) 43 | source.m_offset += static_cast(i); 44 | else 45 | source.m_offset = 0; 46 | return source; 47 | } 48 | } // namespace YAML 49 | 50 | #endif // STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 51 | -------------------------------------------------------------------------------- /src/stringsource.h: -------------------------------------------------------------------------------- 1 | #ifndef STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | namespace YAML { 13 | class StringCharSource { 14 | public: 15 | StringCharSource(const char* str, std::size_t size) 16 | : m_str(str), m_size(size), m_offset(0) {} 17 | 18 | operator bool() const { return m_offset < m_size; } 19 | char operator[](std::size_t i) const { return m_str[m_offset + i]; } 20 | bool operator!() const { return !static_cast(*this); } 21 | 22 | const StringCharSource operator+(int i) const { 23 | StringCharSource source(*this); 24 | if (static_cast(source.m_offset) + i >= 0) 25 | source.m_offset += i; 26 | else 27 | source.m_offset = 0; 28 | return source; 29 | } 30 | 31 | StringCharSource& operator++() { 32 | ++m_offset; 33 | return *this; 34 | } 35 | 36 | StringCharSource& operator+=(std::size_t offset) { 37 | m_offset += offset; 38 | return *this; 39 | } 40 | 41 | private: 42 | const char* m_str; 43 | std::size_t m_size; 44 | std::size_t m_offset; 45 | }; 46 | } 47 | 48 | #endif // STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 49 | -------------------------------------------------------------------------------- /src/tag.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "directives.h" // IWYU pragma: keep 5 | #include "tag.h" 6 | #include "token.h" 7 | 8 | namespace YAML { 9 | Tag::Tag(const Token& token) 10 | : type(static_cast(token.data)), handle{}, value{} { 11 | switch (type) { 12 | case VERBATIM: 13 | value = token.value; 14 | break; 15 | case PRIMARY_HANDLE: 16 | value = token.value; 17 | break; 18 | case SECONDARY_HANDLE: 19 | value = token.value; 20 | break; 21 | case NAMED_HANDLE: 22 | handle = token.value; 23 | value = token.params[0]; 24 | break; 25 | case NON_SPECIFIC: 26 | break; 27 | default: 28 | assert(false); 29 | } 30 | } 31 | 32 | std::string Tag::Translate(const Directives& directives) { 33 | switch (type) { 34 | case VERBATIM: 35 | return value; 36 | case PRIMARY_HANDLE: 37 | return directives.TranslateTagHandle("!") + value; 38 | case SECONDARY_HANDLE: 39 | return directives.TranslateTagHandle("!!") + value; 40 | case NAMED_HANDLE: 41 | return directives.TranslateTagHandle("!" + handle + "!") + value; 42 | case NON_SPECIFIC: 43 | // TODO: 44 | return "!"; 45 | default: 46 | assert(false); 47 | } 48 | throw std::runtime_error("yaml-cpp: internal error, bad tag type"); 49 | } 50 | } // namespace YAML 51 | -------------------------------------------------------------------------------- /src/tag.h: -------------------------------------------------------------------------------- 1 | #ifndef TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | namespace YAML { 13 | struct Directives; 14 | struct Token; 15 | 16 | struct Tag { 17 | enum TYPE { 18 | VERBATIM, 19 | PRIMARY_HANDLE, 20 | SECONDARY_HANDLE, 21 | NAMED_HANDLE, 22 | NON_SPECIFIC 23 | }; 24 | 25 | Tag(const Token& token); 26 | std::string Translate(const Directives& directives); 27 | 28 | TYPE type; 29 | std::string handle, value; 30 | }; 31 | } 32 | 33 | #endif // TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 34 | -------------------------------------------------------------------------------- /src/token.h: -------------------------------------------------------------------------------- 1 | #ifndef TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "yaml-cpp/mark.h" 11 | #include 12 | #include 13 | #include 14 | 15 | namespace YAML { 16 | constexpr const char* TokenNames[] = { 17 | "DIRECTIVE", "DOC_START", "DOC_END", "BLOCK_SEQ_START", 18 | "BLOCK_MAP_START", "BLOCK_SEQ_END", "BLOCK_MAP_END", "BLOCK_ENTRY", 19 | "FLOW_SEQ_START", "FLOW_MAP_START", "FLOW_SEQ_END", "FLOW_MAP_END", 20 | "FLOW_MAP_COMPACT", "FLOW_ENTRY", "KEY", "VALUE", 21 | "ANCHOR", "ALIAS", "TAG", "SCALAR", 22 | "NON_PLAIN_SCALAR"}; 23 | 24 | struct Token { 25 | // enums 26 | enum STATUS { VALID, INVALID, UNVERIFIED }; 27 | enum TYPE { 28 | DIRECTIVE, 29 | DOC_START, 30 | DOC_END, 31 | BLOCK_SEQ_START, 32 | BLOCK_MAP_START, 33 | BLOCK_SEQ_END, 34 | BLOCK_MAP_END, 35 | BLOCK_ENTRY, 36 | FLOW_SEQ_START, 37 | FLOW_MAP_START, 38 | FLOW_SEQ_END, 39 | FLOW_MAP_END, 40 | FLOW_MAP_COMPACT, 41 | FLOW_ENTRY, 42 | KEY, 43 | VALUE, 44 | ANCHOR, 45 | ALIAS, 46 | TAG, 47 | PLAIN_SCALAR, 48 | NON_PLAIN_SCALAR 49 | }; 50 | 51 | // data 52 | Token(TYPE type_, const Mark& mark_) 53 | : status(VALID), type(type_), mark(mark_), value{}, params{}, data(0) {} 54 | 55 | friend std::ostream& operator<<(std::ostream& out, const Token& token) { 56 | out << TokenNames[token.type] << std::string(": ") << token.value; 57 | for (const std::string& param : token.params) 58 | out << std::string(" ") << param; 59 | return out; 60 | } 61 | 62 | STATUS status; 63 | TYPE type; 64 | Mark mark; 65 | std::string value; 66 | std::vector params; 67 | int data; 68 | }; 69 | } // namespace YAML 70 | 71 | #endif // TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 72 | -------------------------------------------------------------------------------- /test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//test:__subpackages__"]) 2 | 3 | cc_library( 4 | name = "mock_event_handler", 5 | hdrs = ["mock_event_handler.h"], 6 | strip_include_prefix = "//test", 7 | ) 8 | 9 | cc_library( 10 | name = "specexamples", 11 | hdrs = ["specexamples.h"], 12 | strip_include_prefix = "//test", 13 | ) 14 | 15 | cc_test( 16 | name = "test", 17 | srcs = glob([ 18 | "*.cpp", 19 | "node/*.cpp", 20 | ]), 21 | deps = [ 22 | ":mock_event_handler", 23 | ":specexamples", 24 | "//:yaml-cpp", 25 | "//:yaml-cpp_internal", 26 | "@googletest//:gtest_main", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Threads REQUIRED) 2 | 3 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 4 | set(BUILD_MOCK ON CACHE BOOL "" FORCE) 5 | set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) 6 | 7 | if(YAML_USE_SYSTEM_GTEST) 8 | find_package(GTest) 9 | if (NOT GTEST_FOUND) 10 | message(FATAL_ERROR "system googletest was requested but not found") 11 | endif() 12 | else() 13 | add_subdirectory( 14 | "${CMAKE_CURRENT_SOURCE_DIR}/googletest-1.13.0" 15 | "${CMAKE_CURRENT_BINARY_DIR}/prefix") 16 | include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/googletest-1.13.0/googletest/include") 17 | endif() 18 | 19 | set(test-new-api-pattern "new-api/*.cpp") 20 | set(test-source-pattern "*.cpp" "integration/*.cpp" "node/*.cpp") 21 | if (CMAKE_VERSION VERSION_GREATER 3.11) 22 | list(INSERT test-new-api-pattern 0 CONFIGURE_DEPENDS) 23 | list(INSERT test-source-pattern 0 CONFIGURE_DEPENDS) 24 | endif() 25 | 26 | file(GLOB test-new-api-sources ${test-new-api-pattern}) 27 | file(GLOB test-sources ${test-source-pattern}) 28 | 29 | add_executable(yaml-cpp-tests "") 30 | target_sources(yaml-cpp-tests 31 | PRIVATE 32 | ${test-new-api-sources} 33 | ${test-sources}) 34 | target_include_directories(yaml-cpp-tests 35 | PRIVATE 36 | ${CMAKE_CURRENT_SOURCE_DIR}/integration 37 | ${CMAKE_CURRENT_SOURCE_DIR} 38 | ${PROJECT_SOURCE_DIR}/src) 39 | target_compile_options(yaml-cpp-tests 40 | PRIVATE 41 | $<$:-Wno-c99-extensions -Wno-variadic-macros -Wno-sign-compare> 42 | $<$:-Wno-variadic-macros -Wno-sign-compare -Wno-narrowing>) 43 | target_link_libraries(yaml-cpp-tests 44 | PRIVATE 45 | Threads::Threads 46 | yaml-cpp 47 | gtest 48 | gmock) 49 | 50 | set_property(TARGET yaml-cpp-tests PROPERTY CXX_STANDARD_REQUIRED ON) 51 | if (NOT DEFINED CMAKE_CXX_STANDARD) 52 | set_target_properties(yaml-cpp-tests PROPERTIES CXX_STANDARD 11) 53 | endif() 54 | 55 | 56 | add_test(NAME yaml-cpp::test COMMAND yaml-cpp-tests) 57 | 58 | if (build-windows-dll) 59 | add_custom_command( 60 | TARGET yaml-cpp-tests 61 | POST_BUILD COMMAND ${CMAKE_COMMAND} -E 62 | copy_if_different "$" "$") 63 | endif() 64 | -------------------------------------------------------------------------------- /test/binary_test.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | #include 3 | 4 | TEST(BinaryTest, DecodingSimple) { 5 | std::string input{90, 71, 86, 104, 90, 71, 74, 108, 90, 87, 89, 61}; 6 | const std::vector &result = YAML::DecodeBase64(input); 7 | EXPECT_EQ(std::string(result.begin(), result.end()), "deadbeef"); 8 | } 9 | 10 | TEST(BinaryTest, DecodingNoCrashOnNegative) { 11 | std::string input{-58, -1, -99, 109}; 12 | const std::vector &result = YAML::DecodeBase64(input); 13 | EXPECT_TRUE(result.empty()); 14 | } 15 | -------------------------------------------------------------------------------- /test/cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(yaml-cpp-consumer LANGUAGES CXX) 3 | 4 | find_package(yaml-cpp CONFIG REQUIRED) 5 | get_target_property(LIBRARY_TYPE yaml-cpp::yaml-cpp TYPE) 6 | 7 | if(LIBRARY_TYPE STREQUAL "SHARED_LIBRARY") 8 | if(NOT YAML_CPP_SHARED_LIBS_BUILT) 9 | message(FATAL_ERROR "Library type (${LIBRARY_TYPE}) contradicts config: ${YAML_CPP_SHARED_LIBS_BUILT}") 10 | endif() 11 | else() 12 | if(YAML_CPP_SHARED_LIBS_BUILT) 13 | message(FATAL_ERROR "Library type (${LIBRARY_TYPE}) contradicts config: ${YAML_CPP_SHARED_LIBS_BUILT}") 14 | endif() 15 | endif() 16 | 17 | add_executable(main main.cpp) 18 | if (NOT DEFINED CMAKE_CXX_STANDARD) 19 | set_target_properties(main PROPERTIES CXX_STANDARD 11) 20 | endif() 21 | target_link_libraries(main PRIVATE ${YAML_CPP_LIBRARIES}) 22 | -------------------------------------------------------------------------------- /test/cmake/main.cpp: -------------------------------------------------------------------------------- 1 | #include "yaml-cpp/yaml.h" 2 | 3 | int main(int, char**) { YAML::Parser foo{}; } 4 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/.clang-format: -------------------------------------------------------------------------------- 1 | # Run manually to reformat a file: 2 | # clang-format -i --style=file 3 | Language: Cpp 4 | BasedOnStyle: Google 5 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/.github/ISSUE_TEMPLATE/00-bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: Let us know that something does not work as expected. 3 | title: "[Bug]: Please title this bug report" 4 | body: 5 | - type: textarea 6 | id: what-happened 7 | attributes: 8 | label: Describe the issue 9 | description: What happened, and what did you expect to happen? 10 | validations: 11 | required: true 12 | - type: textarea 13 | id: steps 14 | attributes: 15 | label: Steps to reproduce the problem 16 | description: It is important that we are able to reproduce the problem that you are experiencing. Please provide all code and relevant steps to reproduce the problem, including your `BUILD`/`CMakeLists.txt` file and build commands. Links to a GitHub branch or [godbolt.org](https://godbolt.org/) that demonstrate the problem are also helpful. 17 | validations: 18 | required: true 19 | - type: textarea 20 | id: version 21 | attributes: 22 | label: What version of GoogleTest are you using? 23 | description: Please include the output of `git rev-parse HEAD` or the GoogleTest release version number that you are using. 24 | validations: 25 | required: true 26 | - type: textarea 27 | id: os 28 | attributes: 29 | label: What operating system and version are you using? 30 | description: If you are using a Linux distribution please include the name and version of the distribution as well. 31 | validations: 32 | required: true 33 | - type: textarea 34 | id: compiler 35 | attributes: 36 | label: What compiler and version are you using? 37 | description: Please include the output of `gcc -v` or `clang -v`, or the equivalent for your compiler. 38 | validations: 39 | required: true 40 | - type: textarea 41 | id: buildsystem 42 | attributes: 43 | label: What build system are you using? 44 | description: Please include the output of `bazel --version` or `cmake --version`, or the equivalent for your build system. 45 | validations: 46 | required: true 47 | - type: textarea 48 | id: additional 49 | attributes: 50 | label: Additional context 51 | description: Add any other context about the problem here. 52 | validations: 53 | required: false 54 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/.github/ISSUE_TEMPLATE/10-feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Propose a new feature. 3 | title: "[FR]: Please title this feature request" 4 | labels: "enhancement" 5 | body: 6 | - type: textarea 7 | id: version 8 | attributes: 9 | label: Does the feature exist in the most recent commit? 10 | description: We recommend using the latest commit from GitHub in your projects. 11 | validations: 12 | required: true 13 | - type: textarea 14 | id: why 15 | attributes: 16 | label: Why do we need this feature? 17 | description: Ideally, explain why a combination of existing features cannot be used instead. 18 | validations: 19 | required: true 20 | - type: textarea 21 | id: proposal 22 | attributes: 23 | label: Describe the proposal. 24 | description: Include a detailed description of the feature, with usage examples. 25 | validations: 26 | required: true 27 | - type: textarea 28 | id: platform 29 | attributes: 30 | label: Is the feature specific to an operating system, compiler, or build system version? 31 | description: If it is, please specify which versions. 32 | validations: 33 | required: true 34 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Get Help 4 | url: https://github.com/google/googletest/discussions 5 | about: Please ask and answer questions here. 6 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/.github/workflows/gtest-ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | env: 8 | BAZEL_CXXOPTS: -std=c++14 9 | 10 | jobs: 11 | Linux: 12 | runs-on: ubuntu-latest 13 | steps: 14 | 15 | - uses: actions/checkout@v3 16 | with: 17 | fetch-depth: 0 18 | 19 | - name: Tests 20 | run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... 21 | 22 | macOS: 23 | runs-on: macos-latest 24 | steps: 25 | 26 | - uses: actions/checkout@v3 27 | with: 28 | fetch-depth: 0 29 | 30 | - name: Tests 31 | run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... 32 | 33 | 34 | Windows: 35 | runs-on: windows-latest 36 | steps: 37 | 38 | - uses: actions/checkout@v3 39 | with: 40 | fetch-depth: 0 41 | 42 | - name: Tests 43 | run: bazel test --cxxopt=/std:c++14 --features=external_include_paths --test_output=errors ... 44 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore CI build directory 2 | build/ 3 | xcuserdata 4 | cmake-build-debug/ 5 | .idea/ 6 | bazel-bin 7 | bazel-genfiles 8 | bazel-googletest 9 | bazel-out 10 | bazel-testlogs 11 | # python 12 | *.pyc 13 | 14 | # Visual Studio files 15 | .vs 16 | *.sdf 17 | *.opensdf 18 | *.VC.opendb 19 | *.suo 20 | *.user 21 | _ReSharper.Caches/ 22 | Win32-Debug/ 23 | Win32-Release/ 24 | x64-Debug/ 25 | x64-Release/ 26 | 27 | # Ignore autoconf / automake files 28 | Makefile.in 29 | aclocal.m4 30 | configure 31 | build-aux/ 32 | autom4te.cache/ 33 | googletest/m4/libtool.m4 34 | googletest/m4/ltoptions.m4 35 | googletest/m4/ltsugar.m4 36 | googletest/m4/ltversion.m4 37 | googletest/m4/lt~obsolete.m4 38 | googlemock/m4 39 | 40 | # Ignore generated directories. 41 | googlemock/fused-src/ 42 | googletest/fused-src/ 43 | 44 | # macOS files 45 | .DS_Store 46 | googletest/.DS_Store 47 | googletest/xcode/.DS_Store 48 | 49 | # Ignore cmake generated directories and files. 50 | CMakeFiles 51 | CTestTestfile.cmake 52 | Makefile 53 | cmake_install.cmake 54 | googlemock/CMakeFiles 55 | googlemock/CTestTestfile.cmake 56 | googlemock/Makefile 57 | googlemock/cmake_install.cmake 58 | googlemock/gtest 59 | /bin 60 | /googlemock/gmock.dir 61 | /googlemock/gmock_main.dir 62 | /googlemock/RUN_TESTS.vcxproj.filters 63 | /googlemock/RUN_TESTS.vcxproj 64 | /googlemock/INSTALL.vcxproj.filters 65 | /googlemock/INSTALL.vcxproj 66 | /googlemock/gmock_main.vcxproj.filters 67 | /googlemock/gmock_main.vcxproj 68 | /googlemock/gmock.vcxproj.filters 69 | /googlemock/gmock.vcxproj 70 | /googlemock/gmock.sln 71 | /googlemock/ALL_BUILD.vcxproj.filters 72 | /googlemock/ALL_BUILD.vcxproj 73 | /lib 74 | /Win32 75 | /ZERO_CHECK.vcxproj.filters 76 | /ZERO_CHECK.vcxproj 77 | /RUN_TESTS.vcxproj.filters 78 | /RUN_TESTS.vcxproj 79 | /INSTALL.vcxproj.filters 80 | /INSTALL.vcxproj 81 | /googletest-distribution.sln 82 | /CMakeCache.txt 83 | /ALL_BUILD.vcxproj.filters 84 | /ALL_BUILD.vcxproj 85 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Note: CMake support is community-based. The maintainers do not use CMake 2 | # internally. 3 | 4 | cmake_minimum_required(VERSION 3.5) 5 | 6 | if (POLICY CMP0048) 7 | cmake_policy(SET CMP0048 NEW) 8 | endif (POLICY CMP0048) 9 | 10 | if (POLICY CMP0069) 11 | cmake_policy(SET CMP0069 NEW) 12 | endif (POLICY CMP0069) 13 | 14 | if (POLICY CMP0077) 15 | cmake_policy(SET CMP0077 NEW) 16 | endif (POLICY CMP0077) 17 | 18 | project(googletest-distribution) 19 | set(GOOGLETEST_VERSION 1.13.0) 20 | 21 | if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX) 22 | set(CMAKE_CXX_EXTENSIONS OFF) 23 | endif() 24 | 25 | enable_testing() 26 | 27 | include(CMakeDependentOption) 28 | include(GNUInstallDirs) 29 | 30 | #Note that googlemock target already builds googletest 31 | option(BUILD_GMOCK "Builds the googlemock subproject" ON) 32 | option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON) 33 | option(GTEST_HAS_ABSL "Use Abseil and RE2. Requires Abseil and RE2 to be separately added to the build." OFF) 34 | 35 | if(BUILD_GMOCK) 36 | add_subdirectory( googlemock ) 37 | else() 38 | add_subdirectory( googletest ) 39 | endif() 40 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file contains a list of people who've made non-trivial 2 | # contribution to the Google C++ Testing Framework project. People 3 | # who commit code to the project are encouraged to add their names 4 | # here. Please keep the list sorted by first names. 5 | 6 | Ajay Joshi 7 | Balázs Dán 8 | Benoit Sigoure 9 | Bharat Mediratta 10 | Bogdan Piloca 11 | Chandler Carruth 12 | Chris Prince 13 | Chris Taylor 14 | Dan Egnor 15 | Dave MacLachlan 16 | David Anderson 17 | Dean Sturtevant 18 | Eric Roman 19 | Gene Volovich 20 | Hady Zalek 21 | Hal Burch 22 | Jeffrey Yasskin 23 | Jim Keller 24 | Joe Walnes 25 | Jon Wray 26 | Jói Sigurðsson 27 | Keir Mierle 28 | Keith Ray 29 | Kenton Varda 30 | Kostya Serebryany 31 | Krystian Kuzniarek 32 | Lev Makhlis 33 | Manuel Klimek 34 | Mario Tanev 35 | Mark Paskin 36 | Markus Heule 37 | Martijn Vels 38 | Matthew Simmons 39 | Mika Raento 40 | Mike Bland 41 | Miklós Fazekas 42 | Neal Norwitz 43 | Nermin Ozkiranartli 44 | Owen Carlsen 45 | Paneendra Ba 46 | Pasi Valminen 47 | Patrick Hanna 48 | Patrick Riley 49 | Paul Menage 50 | Peter Kaminski 51 | Piotr Kaminski 52 | Preston Jackson 53 | Rainer Klaffenboeck 54 | Russ Cox 55 | Russ Rufer 56 | Sean Mcafee 57 | Sigurður Ásgeirsson 58 | Sverre Sundsdal 59 | Szymon Sobik 60 | Takeshi Yoshino 61 | Tracy Bialik 62 | Vadim Berman 63 | Vlad Losev 64 | Wolfgang Klier 65 | Zhanyong Wan 66 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/WORKSPACE: -------------------------------------------------------------------------------- 1 | workspace(name = "com_google_googletest") 2 | 3 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 4 | 5 | http_archive( 6 | name = "com_google_absl", # 2023-01-10T21:08:25Z 7 | sha256 = "f9a4e749f42c386a32a90fddf0e2913ed408d10c42f7f33ccf4c59ac4f0d1d05", 8 | strip_prefix = "abseil-cpp-52835439ca90d86b27bf8cd1708296e95604d724", 9 | urls = ["https://github.com/abseil/abseil-cpp/archive/52835439ca90d86b27bf8cd1708296e95604d724.zip"], 10 | ) 11 | 12 | # Note this must use a commit from the `abseil` branch of the RE2 project. 13 | # https://github.com/google/re2/tree/abseil 14 | http_archive( 15 | name = "com_googlesource_code_re2", # 2022-12-21T14:29:10Z 16 | sha256 = "b9ce3a51beebb38534d11d40f8928d40509b9e18a735f6a4a97ad3d014c87cb5", 17 | strip_prefix = "re2-d0b1f8f2ecc2ea74956c7608b6f915175314ff0e", 18 | urls = ["https://github.com/google/re2/archive/d0b1f8f2ecc2ea74956c7608b6f915175314ff0e.zip"], 19 | ) 20 | 21 | http_archive( 22 | name = "rules_python", # 2023-01-10T22:00:51Z 23 | sha256 = "5de54486a60ad8948dabe49605bb1c08053e04001a431ab3e96745b4d97a4419", 24 | strip_prefix = "rules_python-70cce26432187a60b4e950118791385e6fb3c26f", 25 | urls = ["https://github.com/bazelbuild/rules_python/archive/70cce26432187a60b4e950118791385e6fb3c26f.zip"], 26 | ) 27 | 28 | http_archive( 29 | name = "bazel_skylib", # 2022-11-16T18:29:32Z 30 | sha256 = "a22290c26d29d3ecca286466f7f295ac6cbe32c0a9da3a91176a90e0725e3649", 31 | strip_prefix = "bazel-skylib-5bfcb1a684550626ce138fe0fe8f5f702b3764c3", 32 | urls = ["https://github.com/bazelbuild/bazel-skylib/archive/5bfcb1a684550626ce138fe0fe8f5f702b3764c3.zip"], 33 | ) 34 | 35 | http_archive( 36 | name = "platforms", # 2022-11-09T19:18:22Z 37 | sha256 = "b4a3b45dc4202e2b3e34e3bc49d2b5b37295fc23ea58d88fb9e01f3642ad9b55", 38 | strip_prefix = "platforms-3fbc687756043fb58a407c2ea8c944bc2fe1d922", 39 | urls = ["https://github.com/bazelbuild/platforms/archive/3fbc687756043fb58a407c2ea8c944bc2fe1d922.zip"], 40 | ) 41 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/ci/windows-presubmit.bat: -------------------------------------------------------------------------------- 1 | SETLOCAL ENABLEDELAYEDEXPANSION 2 | 3 | SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-5.1.1-windows-x86_64.exe 4 | 5 | SET PATH=C:\Python37;%PATH% 6 | SET BAZEL_PYTHON=C:\python37\python.exe 7 | SET BAZEL_SH=C:\tools\msys64\usr\bin\bash.exe 8 | SET CMAKE_BIN="C:\Program Files\CMake\bin\cmake.exe" 9 | SET CTEST_BIN="C:\Program Files\CMake\bin\ctest.exe" 10 | SET CTEST_OUTPUT_ON_FAILURE=1 11 | 12 | IF EXIST git\googletest ( 13 | CD git\googletest 14 | ) ELSE IF EXIST github\googletest ( 15 | CD github\googletest 16 | ) 17 | 18 | IF %errorlevel% neq 0 EXIT /B 1 19 | 20 | :: ---------------------------------------------------------------------------- 21 | :: CMake Visual Studio 15 2017 Win64 22 | MKDIR cmake_msvc2017 23 | CD cmake_msvc2017 24 | 25 | %CMAKE_BIN% .. ^ 26 | -G "Visual Studio 15 2017 Win64" ^ 27 | -DPYTHON_EXECUTABLE:FILEPATH=c:\python37\python.exe ^ 28 | -DPYTHON_INCLUDE_DIR:PATH=c:\python37\include ^ 29 | -DPYTHON_LIBRARY:FILEPATH=c:\python37\lib\site-packages\pip ^ 30 | -Dgtest_build_samples=ON ^ 31 | -Dgtest_build_tests=ON ^ 32 | -Dgmock_build_tests=ON 33 | IF %errorlevel% neq 0 EXIT /B 1 34 | 35 | %CMAKE_BIN% --build . --target ALL_BUILD --config Debug -- -maxcpucount 36 | IF %errorlevel% neq 0 EXIT /B 1 37 | 38 | %CTEST_BIN% -C Debug --timeout 600 39 | IF %errorlevel% neq 0 EXIT /B 1 40 | 41 | CD .. 42 | RMDIR /S /Q cmake_msvc2017 43 | 44 | :: ---------------------------------------------------------------------------- 45 | :: Bazel Visual Studio 15 2017 Win64 46 | 47 | SET BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC 48 | %BAZEL_EXE% test ... ^ 49 | --compilation_mode=dbg ^ 50 | --copt=/std:c++14 ^ 51 | --copt=/WX ^ 52 | --features=external_include_paths ^ 53 | --keep_going ^ 54 | --test_output=errors ^ 55 | --test_tag_filters=-no_test_msvc2017 56 | IF %errorlevel% neq 0 EXIT /B 1 57 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/docs/_config.yml: -------------------------------------------------------------------------------- 1 | title: GoogleTest 2 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/docs/_data/navigation.yml: -------------------------------------------------------------------------------- 1 | nav: 2 | - section: "Get Started" 3 | items: 4 | - title: "Supported Platforms" 5 | url: "/platforms.html" 6 | - title: "Quickstart: Bazel" 7 | url: "/quickstart-bazel.html" 8 | - title: "Quickstart: CMake" 9 | url: "/quickstart-cmake.html" 10 | - section: "Guides" 11 | items: 12 | - title: "GoogleTest Primer" 13 | url: "/primer.html" 14 | - title: "Advanced Topics" 15 | url: "/advanced.html" 16 | - title: "Mocking for Dummies" 17 | url: "/gmock_for_dummies.html" 18 | - title: "Mocking Cookbook" 19 | url: "/gmock_cook_book.html" 20 | - title: "Mocking Cheat Sheet" 21 | url: "/gmock_cheat_sheet.html" 22 | - section: "References" 23 | items: 24 | - title: "Testing Reference" 25 | url: "/reference/testing.html" 26 | - title: "Mocking Reference" 27 | url: "/reference/mocking.html" 28 | - title: "Assertions" 29 | url: "/reference/assertions.html" 30 | - title: "Matchers" 31 | url: "/reference/matchers.html" 32 | - title: "Actions" 33 | url: "/reference/actions.html" 34 | - title: "Testing FAQ" 35 | url: "/faq.html" 36 | - title: "Mocking FAQ" 37 | url: "/gmock_faq.html" 38 | - title: "Code Samples" 39 | url: "/samples.html" 40 | - title: "Using pkg-config" 41 | url: "/pkgconfig.html" 42 | - title: "Community Documentation" 43 | url: "/community_created_documentation.html" 44 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/docs/_layouts/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {% seo %} 9 | 10 | 18 | 19 | 20 | 21 |

44 |
45 |
46 | {{ content }} 47 |
48 | 54 |
55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/docs/assets/css/style.scss: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | @import "jekyll-theme-primer"; 5 | @import "main"; 6 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/docs/community_created_documentation.md: -------------------------------------------------------------------------------- 1 | # Community-Created Documentation 2 | 3 | The following is a list, in no particular order, of links to documentation 4 | created by the Googletest community. 5 | 6 | * [Googlemock Insights](https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles/blob/master/googletest/insights.md), 7 | by [ElectricRCAircraftGuy](https://github.com/ElectricRCAircraftGuy) 8 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/docs/index.md: -------------------------------------------------------------------------------- 1 | # GoogleTest User's Guide 2 | 3 | ## Welcome to GoogleTest! 4 | 5 | GoogleTest is Google's C++ testing and mocking framework. This user's guide has 6 | the following contents: 7 | 8 | * [GoogleTest Primer](primer.md) - Teaches you how to write simple tests using 9 | GoogleTest. Read this first if you are new to GoogleTest. 10 | * [GoogleTest Advanced](advanced.md) - Read this when you've finished the 11 | Primer and want to utilize GoogleTest to its full potential. 12 | * [GoogleTest Samples](samples.md) - Describes some GoogleTest samples. 13 | * [GoogleTest FAQ](faq.md) - Have a question? Want some tips? Check here 14 | first. 15 | * [Mocking for Dummies](gmock_for_dummies.md) - Teaches you how to create mock 16 | objects and use them in tests. 17 | * [Mocking Cookbook](gmock_cook_book.md) - Includes tips and approaches to 18 | common mocking use cases. 19 | * [Mocking Cheat Sheet](gmock_cheat_sheet.md) - A handy reference for 20 | matchers, actions, invariants, and more. 21 | * [Mocking FAQ](gmock_faq.md) - Contains answers to some mocking-specific 22 | questions. 23 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/docs/platforms.md: -------------------------------------------------------------------------------- 1 | # Supported Platforms 2 | 3 | GoogleTest requires a codebase and compiler compliant with the C++11 standard or 4 | newer. 5 | 6 | The GoogleTest code is officially supported on the following platforms. 7 | Operating systems or tools not listed below are community-supported. For 8 | community-supported platforms, patches that do not complicate the code may be 9 | considered. 10 | 11 | If you notice any problems on your platform, please file an issue on the 12 | [GoogleTest GitHub Issue Tracker](https://github.com/google/googletest/issues). 13 | Pull requests containing fixes are welcome! 14 | 15 | ### Operating systems 16 | 17 | * Linux 18 | * macOS 19 | * Windows 20 | 21 | ### Compilers 22 | 23 | * gcc 5.0+ 24 | * clang 5.0+ 25 | * MSVC 2015+ 26 | 27 | **macOS users:** Xcode 9.3+ provides clang 5.0+. 28 | 29 | ### Build systems 30 | 31 | * [Bazel](https://bazel.build/) 32 | * [CMake](https://cmake.org/) 33 | 34 | Bazel is the build system used by the team internally and in tests. CMake is 35 | supported on a best-effort basis and by the community. 36 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/docs/samples.md: -------------------------------------------------------------------------------- 1 | # Googletest Samples 2 | 3 | If you're like us, you'd like to look at 4 | [googletest samples.](https://github.com/google/googletest/blob/main/googletest/samples) 5 | The sample directory has a number of well-commented samples showing how to use a 6 | variety of googletest features. 7 | 8 | * Sample #1 shows the basic steps of using googletest to test C++ functions. 9 | * Sample #2 shows a more complex unit test for a class with multiple member 10 | functions. 11 | * Sample #3 uses a test fixture. 12 | * Sample #4 teaches you how to use googletest and `googletest.h` together to 13 | get the best of both libraries. 14 | * Sample #5 puts shared testing logic in a base test fixture, and reuses it in 15 | derived fixtures. 16 | * Sample #6 demonstrates type-parameterized tests. 17 | * Sample #7 teaches the basics of value-parameterized tests. 18 | * Sample #8 shows using `Combine()` in value-parameterized tests. 19 | * Sample #9 shows use of the listener API to modify Google Test's console 20 | output and the use of its reflection API to inspect test results. 21 | * Sample #10 shows use of the listener API to implement a primitive memory 22 | leak checker. 23 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googlemock/README.md: -------------------------------------------------------------------------------- 1 | # Googletest Mocking (gMock) Framework 2 | 3 | ### Overview 4 | 5 | Google's framework for writing and using C++ mock classes. It can help you 6 | derive better designs of your system and write better tests. 7 | 8 | It is inspired by: 9 | 10 | * [jMock](http://www.jmock.org/) 11 | * [EasyMock](http://www.easymock.org/) 12 | * [Hamcrest](http://code.google.com/p/hamcrest/) 13 | 14 | It is designed with C++'s specifics in mind. 15 | 16 | gMock: 17 | 18 | - Provides a declarative syntax for defining mocks. 19 | - Can define partial (hybrid) mocks, which are a cross of real and mock 20 | objects. 21 | - Handles functions of arbitrary types and overloaded functions. 22 | - Comes with a rich set of matchers for validating function arguments. 23 | - Uses an intuitive syntax for controlling the behavior of a mock. 24 | - Does automatic verification of expectations (no record-and-replay needed). 25 | - Allows arbitrary (partial) ordering constraints on function calls to be 26 | expressed. 27 | - Lets a user extend it by defining new matchers and actions. 28 | - Does not use exceptions. 29 | - Is easy to learn and use. 30 | 31 | Details and examples can be found here: 32 | 33 | * [gMock for Dummies](https://google.github.io/googletest/gmock_for_dummies.html) 34 | * [Legacy gMock FAQ](https://google.github.io/googletest/gmock_faq.html) 35 | * [gMock Cookbook](https://google.github.io/googletest/gmock_cook_book.html) 36 | * [gMock Cheat Sheet](https://google.github.io/googletest/gmock_cheat_sheet.html) 37 | 38 | GoogleMock is a part of 39 | [GoogleTest C++ testing framework](http://github.com/google/googletest/) and a 40 | subject to the same requirements. 41 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googlemock/cmake/gmock.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gmock 5 | Description: GoogleMock (without main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Requires: gtest = @PROJECT_VERSION@ 9 | Libs: -L${libdir} -lgmock @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 11 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googlemock/cmake/gmock_main.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gmock_main 5 | Description: GoogleMock (with main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Requires: gmock = @PROJECT_VERSION@ 9 | Libs: -L${libdir} -lgmock_main @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 11 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googlemock/docs/README.md: -------------------------------------------------------------------------------- 1 | # Content Moved 2 | 3 | We are working on updates to the GoogleTest documentation, which has moved to 4 | the top-level [docs](../../docs) directory. 5 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googlemock/include/gmock/internal/custom/README.md: -------------------------------------------------------------------------------- 1 | # Customization Points 2 | 3 | The custom directory is an injection point for custom user configurations. 4 | 5 | ## Header `gmock-port.h` 6 | 7 | The following macros can be defined: 8 | 9 | ### Flag related macros: 10 | 11 | * `GMOCK_DECLARE_bool_(name)` 12 | * `GMOCK_DECLARE_int32_(name)` 13 | * `GMOCK_DECLARE_string_(name)` 14 | * `GMOCK_DEFINE_bool_(name, default_val, doc)` 15 | * `GMOCK_DEFINE_int32_(name, default_val, doc)` 16 | * `GMOCK_DEFINE_string_(name, default_val, doc)` 17 | * `GMOCK_FLAG_GET(flag_name)` 18 | * `GMOCK_FLAG_SET(flag_name, value)` 19 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googlemock/include/gmock/internal/custom/gmock-generated-actions.h: -------------------------------------------------------------------------------- 1 | // IWYU pragma: private, include "gmock/gmock.h" 2 | // IWYU pragma: friend gmock/.* 3 | 4 | #ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ 5 | #define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ 6 | 7 | #endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ 8 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googlemock/include/gmock/internal/custom/gmock-matchers.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Injection point for custom user configurations. See README for details 31 | 32 | // IWYU pragma: private, include "gmock/gmock.h" 33 | // IWYU pragma: friend gmock/.* 34 | 35 | #ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_ 36 | #define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_ 37 | #endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_ 38 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googlemock/include/gmock/internal/custom/gmock-port.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | // IWYU pragma: private, include "gmock/gmock.h" 35 | // IWYU pragma: friend gmock/.* 36 | 37 | #ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ 38 | #define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ 39 | 40 | #endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ 41 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googlemock/src/gmock-all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Google C++ Mocking Framework (Google Mock) 32 | // 33 | // This file #includes all Google Mock implementation .cc files. The 34 | // purpose is to allow a user to build Google Mock by compiling this 35 | // file alone. 36 | 37 | // This line ensures that gmock.h can be compiled on its own, even 38 | // when it's fused. 39 | #include "gmock/gmock.h" 40 | 41 | // The following lines pull in the real gmock *.cc files. 42 | #include "src/gmock-cardinalities.cc" 43 | #include "src/gmock-internal-utils.cc" 44 | #include "src/gmock-matchers.cc" 45 | #include "src/gmock-spec-builders.cc" 46 | #include "src/gmock.cc" 47 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googlemock/test/gmock-port_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Google Mock - a framework for writing C++ mock classes. 31 | // 32 | // This file tests the internal cross-platform support utilities. 33 | 34 | #include "gmock/internal/gmock-port.h" 35 | 36 | #include "gtest/gtest.h" 37 | 38 | // NOTE: if this file is left without tests for some reason, put a dummy 39 | // test here to make references to symbols in the gtest library and avoid 40 | // 'undefined symbol' linker errors in gmock_main: 41 | 42 | TEST(DummyTest, Dummy) {} 43 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googlemock/test/gmock_link2_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Google Mock - a framework for writing C++ mock classes. 31 | // 32 | // This file is for verifying that various Google Mock constructs do not 33 | // produce linker errors when instantiated in different translation units. 34 | // Please see gmock_link_test.h for details. 35 | 36 | #define LinkTest LinkTest2 37 | 38 | #include "test/gmock_link_test.h" 39 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googlemock/test/gmock_link_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Google Mock - a framework for writing C++ mock classes. 31 | // 32 | // This file is for verifying that various Google Mock constructs do not 33 | // produce linker errors when instantiated in different translation units. 34 | // Please see gmock_link_test.h for details. 35 | 36 | #define LinkTest LinkTest1 37 | 38 | #include "test/gmock_link_test.h" 39 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/cmake/Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | include(CMakeFindDependencyMacro) 3 | if (@GTEST_HAS_PTHREAD@) 4 | set(THREADS_PREFER_PTHREAD_FLAG @THREADS_PREFER_PTHREAD_FLAG@) 5 | find_dependency(Threads) 6 | endif() 7 | 8 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") 9 | check_required_components("@project_name@") 10 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/cmake/gtest.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gtest 5 | Description: GoogleTest (without main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Libs: -L${libdir} -lgtest @CMAKE_THREAD_LIBS_INIT@ 9 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 10 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/cmake/gtest_main.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gtest_main 5 | Description: GoogleTest (with main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Requires: gtest = @PROJECT_VERSION@ 9 | Libs: -L${libdir} -lgtest_main @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 11 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/cmake/libgtest.la.in: -------------------------------------------------------------------------------- 1 | # libgtest.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Names of this library. 8 | library_names='libgtest.so' 9 | 10 | # Is this an already installed library? 11 | installed=yes 12 | 13 | # Should we warn about portability when linking against -modules? 14 | shouldnotlink=no 15 | 16 | # Files to dlopen/dlpreopen 17 | dlopen='' 18 | dlpreopen='' 19 | 20 | # Directory that this library needs to be installed in: 21 | libdir='@CMAKE_INSTALL_FULL_LIBDIR@' 22 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/docs/README.md: -------------------------------------------------------------------------------- 1 | # Content Moved 2 | 3 | We are working on updates to the GoogleTest documentation, which has moved to 4 | the top-level [docs](../../docs) directory. 5 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/include/gtest/internal/custom/README.md: -------------------------------------------------------------------------------- 1 | # Customization Points 2 | 3 | The custom directory is an injection point for custom user configurations. 4 | 5 | ## Header `gtest.h` 6 | 7 | ### The following macros can be defined: 8 | 9 | * `GTEST_OS_STACK_TRACE_GETTER_` - The name of an implementation of 10 | `OsStackTraceGetterInterface`. 11 | * `GTEST_CUSTOM_TEMPDIR_FUNCTION_` - An override for `testing::TempDir()`. See 12 | `testing::TempDir` for semantics and signature. 13 | 14 | ## Header `gtest-port.h` 15 | 16 | The following macros can be defined: 17 | 18 | ### Logging: 19 | 20 | * `GTEST_LOG_(severity)` 21 | * `GTEST_CHECK_(condition)` 22 | * Functions `LogToStderr()` and `FlushInfoLog()` have to be provided too. 23 | 24 | ### Threading: 25 | 26 | * `GTEST_HAS_NOTIFICATION_` - Enabled if Notification is already provided. 27 | * `GTEST_HAS_MUTEX_AND_THREAD_LOCAL_` - Enabled if `Mutex` and `ThreadLocal` 28 | are already provided. Must also provide `GTEST_DECLARE_STATIC_MUTEX_(mutex)` 29 | and `GTEST_DEFINE_STATIC_MUTEX_(mutex)` 30 | * `GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)` 31 | * `GTEST_LOCK_EXCLUDED_(locks)` 32 | 33 | ### Underlying library support features 34 | 35 | * `GTEST_HAS_CXXABI_H_` 36 | 37 | ### Exporting API symbols: 38 | 39 | * `GTEST_API_` - Specifier for exported symbols. 40 | 41 | ## Header `gtest-printers.h` 42 | 43 | * See documentation at `gtest/gtest-printers.h` for details on how to define a 44 | custom printer. 45 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/include/gtest/internal/custom/gtest-port.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 35 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 36 | 37 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 38 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/include/gtest/internal/custom/gtest-printers.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // This file provides an injection point for custom printers in a local 31 | // installation of gTest. 32 | // It will be included from gtest-printers.h and the overrides in this file 33 | // will be visible to everyone. 34 | // 35 | // Injection point for custom user configurations. See README for details 36 | // 37 | // ** Custom implementation starts here ** 38 | 39 | #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 40 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 41 | 42 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 43 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/include/gtest/internal/custom/gtest.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 35 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 36 | 37 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 38 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/samples/sample1.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | 32 | #ifndef GOOGLETEST_SAMPLES_SAMPLE1_H_ 33 | #define GOOGLETEST_SAMPLES_SAMPLE1_H_ 34 | 35 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1. 36 | int Factorial(int n); 37 | 38 | // Returns true if and only if n is a prime number. 39 | bool IsPrime(int n); 40 | 41 | #endif // GOOGLETEST_SAMPLES_SAMPLE1_H_ 42 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/samples/sample2.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | 32 | #include "sample2.h" 33 | 34 | #include 35 | 36 | // Clones a 0-terminated C string, allocating memory using new. 37 | const char* MyString::CloneCString(const char* a_c_string) { 38 | if (a_c_string == nullptr) return nullptr; 39 | 40 | const size_t len = strlen(a_c_string); 41 | char* const clone = new char[len + 1]; 42 | memcpy(clone, a_c_string, len + 1); 43 | 44 | return clone; 45 | } 46 | 47 | // Sets the 0-terminated C string this MyString object 48 | // represents. 49 | void MyString::Set(const char* a_c_string) { 50 | // Makes sure this works when c_string == c_string_ 51 | const char* const temp = MyString::CloneCString(a_c_string); 52 | delete[] c_string_; 53 | c_string_ = temp; 54 | } 55 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/samples/sample4.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | 32 | #include "sample4.h" 33 | 34 | #include 35 | 36 | // Returns the current counter value, and increments it. 37 | int Counter::Increment() { return counter_++; } 38 | 39 | // Returns the current counter value, and decrements it. 40 | // counter can not be less than 0, return 0 in this case 41 | int Counter::Decrement() { 42 | if (counter_ == 0) { 43 | return counter_; 44 | } else { 45 | return counter_--; 46 | } 47 | } 48 | 49 | // Prints the current counter value to STDOUT. 50 | void Counter::Print() const { printf("%d", counter_); } 51 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/samples/sample4.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | #ifndef GOOGLETEST_SAMPLES_SAMPLE4_H_ 32 | #define GOOGLETEST_SAMPLES_SAMPLE4_H_ 33 | 34 | // A simple monotonic counter. 35 | class Counter { 36 | private: 37 | int counter_; 38 | 39 | public: 40 | // Creates a counter that starts at 0. 41 | Counter() : counter_(0) {} 42 | 43 | // Returns the current counter value, and increments it. 44 | int Increment(); 45 | 46 | // Returns the current counter value, and decrements it. 47 | int Decrement(); 48 | 49 | // Prints the current counter value to STDOUT. 50 | void Print() const; 51 | }; 52 | 53 | #endif // GOOGLETEST_SAMPLES_SAMPLE4_H_ 54 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/samples/sample4_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include "sample4.h" 31 | 32 | #include "gtest/gtest.h" 33 | 34 | namespace { 35 | // Tests the Increment() method. 36 | 37 | TEST(Counter, Increment) { 38 | Counter c; 39 | 40 | // Test that counter 0 returns 0 41 | EXPECT_EQ(0, c.Decrement()); 42 | 43 | // EXPECT_EQ() evaluates its arguments exactly once, so they 44 | // can have side effects. 45 | 46 | EXPECT_EQ(0, c.Increment()); 47 | EXPECT_EQ(1, c.Increment()); 48 | EXPECT_EQ(2, c.Increment()); 49 | 50 | EXPECT_EQ(3, c.Decrement()); 51 | } 52 | 53 | } // namespace 54 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/src/gtest-all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Google C++ Testing and Mocking Framework (Google Test) 32 | // 33 | // Sometimes it's desirable to build Google Test by compiling a single file. 34 | // This file serves this purpose. 35 | 36 | // This line ensures that gtest.h can be compiled on its own, even 37 | // when it's fused. 38 | #include "gtest/gtest.h" 39 | 40 | // The following lines pull in the real gtest *.cc files. 41 | #include "src/gtest-assertion-result.cc" 42 | #include "src/gtest-death-test.cc" 43 | #include "src/gtest-filepath.cc" 44 | #include "src/gtest-matchers.cc" 45 | #include "src/gtest-port.cc" 46 | #include "src/gtest-printers.cc" 47 | #include "src/gtest-test-part.cc" 48 | #include "src/gtest-typed-test.cc" 49 | #include "src/gtest.cc" 50 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/googletest-global-environment-unittest_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Unit test for Google Test global test environments. 31 | // 32 | // The program will be invoked from a Python unit test. Don't run it 33 | // directly. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | namespace { 38 | 39 | // An environment that always fails in its SetUp method. 40 | class FailingEnvironment final : public ::testing::Environment { 41 | public: 42 | void SetUp() override { FAIL() << "Canned environment setup error"; } 43 | }; 44 | 45 | // Register the environment. 46 | auto* const g_environment_ = 47 | ::testing::AddGlobalTestEnvironment(new FailingEnvironment); 48 | 49 | // A test that doesn't actually run. 50 | TEST(SomeTest, DoesFoo) { FAIL() << "Unexpected call"; } 51 | 52 | } // namespace 53 | 54 | int main(int argc, char** argv) { 55 | ::testing::InitGoogleTest(&argc, argv); 56 | 57 | return RUN_ALL_TESTS(); 58 | } 59 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/googletest-param-test-invalid-name1-test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include "gtest/gtest.h" 31 | 32 | namespace { 33 | class DummyTest : public ::testing::TestWithParam {}; 34 | 35 | TEST_P(DummyTest, Dummy) {} 36 | 37 | INSTANTIATE_TEST_SUITE_P(InvalidTestName, DummyTest, 38 | ::testing::Values("InvalidWithQuotes"), 39 | ::testing::PrintToStringParamName()); 40 | 41 | } // namespace 42 | 43 | int main(int argc, char *argv[]) { 44 | testing::InitGoogleTest(&argc, argv); 45 | return RUN_ALL_TESTS(); 46 | } 47 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/googletest-param-test-invalid-name2-test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include "gtest/gtest.h" 31 | 32 | namespace { 33 | class DummyTest : public ::testing::TestWithParam {}; 34 | 35 | std::string StringParamTestSuffix( 36 | const testing::TestParamInfo &info) { 37 | return std::string(info.param); 38 | } 39 | 40 | TEST_P(DummyTest, Dummy) {} 41 | 42 | INSTANTIATE_TEST_SUITE_P(DuplicateTestNames, DummyTest, 43 | ::testing::Values("a", "b", "a", "c"), 44 | StringParamTestSuffix); 45 | } // namespace 46 | 47 | int main(int argc, char *argv[]) { 48 | testing::InitGoogleTest(&argc, argv); 49 | return RUN_ALL_TESTS(); 50 | } 51 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/googletest-param-test-test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // The Google C++ Testing and Mocking Framework (Google Test) 31 | // 32 | // This header file provides classes and functions used internally 33 | // for testing Google Test itself. 34 | 35 | #ifndef GOOGLETEST_TEST_GOOGLETEST_PARAM_TEST_TEST_H_ 36 | #define GOOGLETEST_TEST_GOOGLETEST_PARAM_TEST_TEST_H_ 37 | 38 | #include "gtest/gtest.h" 39 | 40 | // Test fixture for testing definition and instantiation of a test 41 | // in separate translation units. 42 | class ExternalInstantiationTest : public ::testing::TestWithParam {}; 43 | 44 | // Test fixture for testing instantiation of a test in multiple 45 | // translation units. 46 | class InstantiationInMultipleTranslationUnitsTest 47 | : public ::testing::TestWithParam {}; 48 | 49 | #endif // GOOGLETEST_TEST_GOOGLETEST_PARAM_TEST_TEST_H_ 50 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/googletest-setuptestsuite-test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2019, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | """Verifies that SetUpTestSuite and TearDownTestSuite errors are noticed.""" 33 | 34 | from googletest.test import gtest_test_utils 35 | 36 | COMMAND = gtest_test_utils.GetTestExecutablePath( 37 | 'googletest-setuptestsuite-test_') 38 | 39 | 40 | class GTestSetUpTestSuiteTest(gtest_test_utils.TestCase): 41 | 42 | def testSetupErrorAndTearDownError(self): 43 | p = gtest_test_utils.Subprocess(COMMAND) 44 | self.assertNotEqual(p.exit_code, 0, msg=p.output) 45 | 46 | self.assertIn( 47 | '[ FAILED ] SetupFailTest: SetUpTestSuite or TearDownTestSuite\n' 48 | '[ FAILED ] TearDownFailTest: SetUpTestSuite or TearDownTestSuite\n' 49 | '\n' 50 | ' 2 FAILED TEST SUITES\n', 51 | p.output) 52 | 53 | if __name__ == '__main__': 54 | gtest_test_utils.Main() 55 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/googletest-setuptestsuite-test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include "gtest/gtest.h" 31 | 32 | class SetupFailTest : public ::testing::Test { 33 | protected: 34 | static void SetUpTestSuite() { ASSERT_EQ("", "SET_UP_FAIL"); } 35 | }; 36 | 37 | TEST_F(SetupFailTest, NoopPassingTest) {} 38 | 39 | class TearDownFailTest : public ::testing::Test { 40 | protected: 41 | static void TearDownTestSuite() { ASSERT_EQ("", "TEAR_DOWN_FAIL"); } 42 | }; 43 | 44 | TEST_F(TearDownFailTest, NoopPassingTest) {} 45 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/googletest-uninitialized-test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include "gtest/gtest.h" 31 | 32 | TEST(DummyTest, Dummy) { 33 | // This test doesn't verify anything. We just need it to create a 34 | // realistic stage for testing the behavior of Google Test when 35 | // RUN_ALL_TESTS() is called without 36 | // testing::InitGoogleTest() being called first. 37 | } 38 | 39 | int main() { return RUN_ALL_TESTS(); } 40 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/gtest-typed-test2_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | 32 | #include "gtest/gtest.h" 33 | #include "test/gtest-typed-test_test.h" 34 | 35 | // Tests that the same type-parameterized test case can be 36 | // instantiated in different translation units linked together. 37 | // (ContainerTest is also instantiated in gtest-typed-test_test.cc.) 38 | INSTANTIATE_TYPED_TEST_SUITE_P(Vector, ContainerTest, 39 | testing::Types >); 40 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/gtest_all_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Tests for Google C++ Testing and Mocking Framework (Google Test) 32 | // 33 | // Sometimes it's desirable to build most of Google Test's own tests 34 | // by compiling a single file. This file serves this purpose. 35 | #include "test/googletest-filepath-test.cc" 36 | #include "test/googletest-message-test.cc" 37 | #include "test/googletest-options-test.cc" 38 | #include "test/googletest-port-test.cc" 39 | #include "test/googletest-test-part-test.cc" 40 | #include "test/gtest-typed-test2_test.cc" 41 | #include "test/gtest-typed-test_test.cc" 42 | #include "test/gtest_pred_impl_unittest.cc" 43 | #include "test/gtest_prod_test.cc" 44 | #include "test/gtest_skip_test.cc" 45 | #include "test/gtest_unittest.cc" 46 | #include "test/production.cc" 47 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/gtest_help_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // This program is meant to be run by gtest_help_test.py. Do not run 31 | // it directly. 32 | 33 | #include "gtest/gtest.h" 34 | 35 | // When a help flag is specified, this program should skip the tests 36 | // and exit with 0; otherwise the following test will be executed, 37 | // causing this program to exit with a non-zero code. 38 | TEST(HelpFlagTest, ShouldNotBeRun) { 39 | ASSERT_TRUE(false) << "Tests shouldn't be run when --help is specified."; 40 | } 41 | 42 | #if GTEST_HAS_DEATH_TEST 43 | TEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {} 44 | #endif 45 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/gtest_main_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include "gtest/gtest.h" 31 | 32 | // Tests that we don't have to define main() when we link to 33 | // gtest_main instead of gtest. 34 | 35 | namespace { 36 | 37 | TEST(GTestMainTest, ShouldSucceed) {} 38 | 39 | } // namespace 40 | 41 | // We are using the main() function defined in gtest_main.cc, so we 42 | // don't define it here. 43 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/gtest_prod_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Unit test for gtest_prod.h. 32 | 33 | #include "production.h" 34 | #include "gtest/gtest.h" 35 | 36 | // Tests that private members can be accessed from a TEST declared as 37 | // a friend of the class. 38 | TEST(PrivateCodeTest, CanAccessPrivateMembers) { 39 | PrivateCode a; 40 | EXPECT_EQ(0, a.x_); 41 | 42 | a.set_x(1); 43 | EXPECT_EQ(1, a.x_); 44 | } 45 | 46 | typedef testing::Test PrivateCodeFixtureTest; 47 | 48 | // Tests that private members can be accessed from a TEST_F declared 49 | // as a friend of the class. 50 | TEST_F(PrivateCodeFixtureTest, CanAccessPrivateMembers) { 51 | PrivateCode a; 52 | EXPECT_EQ(0, a.x_); 53 | 54 | a.set_x(2); 55 | EXPECT_EQ(2, a.x_); 56 | } 57 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/gtest_skip_environment_check_output_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2019 Google LLC. All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """Tests Google Test's gtest skip in environment setup behavior. 31 | 32 | This script invokes gtest_skip_in_environment_setup_test_ and verifies its 33 | output. 34 | """ 35 | 36 | from googletest.test import gtest_test_utils 37 | 38 | # Path to the gtest_skip_in_environment_setup_test binary 39 | EXE_PATH = gtest_test_utils.GetTestExecutablePath( 40 | 'gtest_skip_in_environment_setup_test') 41 | 42 | OUTPUT = gtest_test_utils.Subprocess([EXE_PATH]).output 43 | 44 | 45 | # Test. 46 | class SkipEntireEnvironmentTest(gtest_test_utils.TestCase): 47 | 48 | def testSkipEntireEnvironmentTest(self): 49 | self.assertIn('Skipping the entire environment', OUTPUT) 50 | self.assertNotIn('FAILED', OUTPUT) 51 | 52 | 53 | if __name__ == '__main__': 54 | gtest_test_utils.Main() 55 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/gtest_skip_in_environment_setup_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2019, Google LLC. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google LLC. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // This test verifies that skipping in the environment results in the 31 | // testcases being skipped. 32 | 33 | #include 34 | 35 | #include "gtest/gtest.h" 36 | 37 | class SetupEnvironment : public testing::Environment { 38 | public: 39 | void SetUp() override { GTEST_SKIP() << "Skipping the entire environment"; } 40 | }; 41 | 42 | TEST(Test, AlwaysFails) { EXPECT_EQ(true, false); } 43 | 44 | int main(int argc, char **argv) { 45 | testing::InitGoogleTest(&argc, argv); 46 | 47 | testing::AddGlobalTestEnvironment(new SetupEnvironment()); 48 | 49 | return RUN_ALL_TESTS(); 50 | } 51 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/gtest_skip_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: arseny.aprelev@gmail.com (Arseny Aprelev) 31 | // 32 | 33 | #include "gtest/gtest.h" 34 | 35 | using ::testing::Test; 36 | 37 | TEST(SkipTest, DoesSkip) { 38 | GTEST_SKIP() << "skipping single test"; 39 | EXPECT_EQ(0, 1); 40 | } 41 | 42 | class Fixture : public Test { 43 | protected: 44 | void SetUp() override { 45 | GTEST_SKIP() << "skipping all tests for this fixture"; 46 | } 47 | }; 48 | 49 | TEST_F(Fixture, SkipsOneTest) { EXPECT_EQ(5, 7); } 50 | 51 | TEST_F(Fixture, SkipsAnotherTest) { EXPECT_EQ(99, 100); } 52 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/gtest_sole_header_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // This test verifies that it's possible to use Google Test by including 32 | // the gtest.h header file alone. 33 | 34 | #include "gtest/gtest.h" 35 | 36 | namespace { 37 | 38 | void Subroutine() { EXPECT_EQ(42, 42); } 39 | 40 | TEST(NoFatalFailureTest, ExpectNoFatalFailure) { 41 | EXPECT_NO_FATAL_FAILURE(;); 42 | EXPECT_NO_FATAL_FAILURE(SUCCEED()); 43 | EXPECT_NO_FATAL_FAILURE(Subroutine()); 44 | EXPECT_NO_FATAL_FAILURE({ SUCCEED(); }); 45 | } 46 | 47 | TEST(NoFatalFailureTest, AssertNoFatalFailure) { 48 | ASSERT_NO_FATAL_FAILURE(;); 49 | ASSERT_NO_FATAL_FAILURE(SUCCEED()); 50 | ASSERT_NO_FATAL_FAILURE(Subroutine()); 51 | ASSERT_NO_FATAL_FAILURE({ SUCCEED(); }); 52 | } 53 | 54 | } // namespace 55 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/gtest_testbridge_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018, Google LLC. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // This program is meant to be run by gtest_test_filter_test.py. Do not run 31 | // it directly. 32 | 33 | #include "gtest/gtest.h" 34 | 35 | // These tests are used to detect if filtering is working. Only 36 | // 'TestThatSucceeds' should ever run. 37 | 38 | TEST(TestFilterTest, TestThatSucceeds) {} 39 | 40 | TEST(TestFilterTest, TestThatFails) { 41 | ASSERT_TRUE(false) << "This test should never be run."; 42 | } 43 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/gtest_xml_outfile1_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // gtest_xml_outfile1_test_ writes some xml via TestProperty used by 31 | // gtest_xml_outfiles_test.py 32 | 33 | #include "gtest/gtest.h" 34 | 35 | class PropertyOne : public testing::Test { 36 | protected: 37 | void SetUp() override { RecordProperty("SetUpProp", 1); } 38 | void TearDown() override { RecordProperty("TearDownProp", 1); } 39 | }; 40 | 41 | TEST_F(PropertyOne, TestSomeProperties) { 42 | RecordProperty("TestSomeProperty", 1); 43 | } 44 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/gtest_xml_outfile2_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // gtest_xml_outfile2_test_ writes some xml via TestProperty used by 31 | // gtest_xml_outfiles_test.py 32 | 33 | #include "gtest/gtest.h" 34 | 35 | class PropertyTwo : public testing::Test { 36 | protected: 37 | void SetUp() override { RecordProperty("SetUpProp", 2); } 38 | void TearDown() override { RecordProperty("TearDownProp", 2); } 39 | }; 40 | 41 | TEST_F(PropertyTwo, TestSomeProperties) { 42 | // Validate we can write an unsigned size_t as a property 43 | size_t prop_two = 2; 44 | RecordProperty("TestSomeProperty", prop_two); 45 | } 46 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/production.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // This is part of the unit test for gtest_prod.h. 32 | 33 | #include "production.h" 34 | 35 | PrivateCode::PrivateCode() : x_(0) {} 36 | -------------------------------------------------------------------------------- /test/googletest-1.13.0/googletest/test/production.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // This is part of the unit test for gtest_prod.h. 32 | 33 | #ifndef GOOGLETEST_TEST_PRODUCTION_H_ 34 | #define GOOGLETEST_TEST_PRODUCTION_H_ 35 | 36 | #include "gtest/gtest_prod.h" 37 | 38 | class PrivateCode { 39 | public: 40 | // Declares a friend test that does not use a fixture. 41 | FRIEND_TEST(PrivateCodeTest, CanAccessPrivateMembers); 42 | 43 | // Declares a friend test that uses a fixture. 44 | FRIEND_TEST(PrivateCodeFixtureTest, CanAccessPrivateMembers); 45 | 46 | PrivateCode(); 47 | 48 | int x() const { return x_; } 49 | 50 | private: 51 | void set_x(int an_x) { x_ = an_x; } 52 | int x_; 53 | }; 54 | 55 | #endif // GOOGLETEST_TEST_PRODUCTION_H_ 56 | -------------------------------------------------------------------------------- /test/integration/BUILD.bazel: -------------------------------------------------------------------------------- 1 | cc_test( 2 | name = "test", 3 | srcs = glob([ 4 | "*.cpp", 5 | "*.h", 6 | ]), 7 | deps = [ 8 | "//:yaml-cpp", 9 | "//:yaml-cpp_internal", 10 | "//test:mock_event_handler", 11 | "//test:specexamples", 12 | "@googletest//:gtest_main", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /test/integration/handler_test.h: -------------------------------------------------------------------------------- 1 | #include "mock_event_handler.h" 2 | #include "yaml-cpp/yaml.h" // IWYU pragma: keep 3 | 4 | #include "gmock/gmock.h" 5 | #include "gtest/gtest.h" 6 | 7 | using ::testing::InSequence; 8 | using ::testing::NiceMock; 9 | using ::testing::StrictMock; 10 | 11 | namespace YAML { 12 | class HandlerTest : public ::testing::Test { 13 | protected: 14 | void Parse(const std::string& example) { 15 | std::stringstream stream(example); 16 | Parser parser(stream); 17 | while (parser.HandleNextDocument(handler)) { 18 | } 19 | } 20 | 21 | void IgnoreParse(const std::string& example) { 22 | std::stringstream stream(example); 23 | Parser parser(stream); 24 | while (parser.HandleNextDocument(nice_handler)) { 25 | } 26 | } 27 | 28 | InSequence sequence; 29 | StrictMock handler; 30 | NiceMock nice_handler; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /test/main.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | int main(int argc, char** argv) { 4 | ::testing::InitGoogleTest(&argc, argv); 5 | return RUN_ALL_TESTS(); 6 | } 7 | -------------------------------------------------------------------------------- /test/mock_event_handler.h: -------------------------------------------------------------------------------- 1 | #include "yaml-cpp/emitterstyle.h" 2 | #include "yaml-cpp/eventhandler.h" 3 | #include "yaml-cpp/mark.h" 4 | 5 | #include "gmock/gmock.h" 6 | 7 | #include 8 | 9 | namespace YAML { 10 | 11 | class MockEventHandler : public EventHandler { 12 | public: 13 | MOCK_METHOD1(OnDocumentStart, void(const Mark&)); 14 | MOCK_METHOD0(OnDocumentEnd, void()); 15 | 16 | MOCK_METHOD2(OnNull, void(const Mark&, anchor_t)); 17 | MOCK_METHOD2(OnAlias, void(const Mark&, anchor_t)); 18 | MOCK_METHOD4(OnScalar, void(const Mark&, const std::string&, anchor_t, 19 | const std::string&)); 20 | 21 | MOCK_METHOD4(OnSequenceStart, void(const Mark&, const std::string&, anchor_t, 22 | EmitterStyle::value)); 23 | MOCK_METHOD0(OnSequenceEnd, void()); 24 | 25 | MOCK_METHOD4(OnMapStart, void(const Mark&, const std::string&, anchor_t, 26 | EmitterStyle::value)); 27 | MOCK_METHOD0(OnMapEnd, void()); 28 | MOCK_METHOD2(OnAnchor, void(const Mark&, const std::string&)); 29 | }; 30 | } // namespace YAML 31 | -------------------------------------------------------------------------------- /test/ostream_wrapper_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "gtest/gtest.h" 5 | #include "yaml-cpp/ostream_wrapper.h" 6 | 7 | namespace { 8 | TEST(OstreamWrapperTest, BufferNoWrite) { 9 | YAML::ostream_wrapper wrapper; 10 | EXPECT_STREQ("", wrapper.str()); 11 | } 12 | 13 | TEST(OstreamWrapperTest, BufferWriteStr) { 14 | YAML::ostream_wrapper wrapper; 15 | wrapper.write(std::string("Hello, world")); 16 | EXPECT_STREQ("Hello, world", wrapper.str()); 17 | } 18 | 19 | TEST(OstreamWrapperTest, BufferWriteCStr) { 20 | YAML::ostream_wrapper wrapper; 21 | wrapper.write("Hello, world"); 22 | EXPECT_STREQ("Hello, world", wrapper.str()); 23 | } 24 | 25 | TEST(OstreamWrapperTest, StreamNoWrite) { 26 | std::stringstream stream; 27 | YAML::ostream_wrapper wrapper(stream); 28 | EXPECT_STREQ(NULL, wrapper.str()); 29 | EXPECT_EQ("", stream.str()); 30 | } 31 | 32 | TEST(OstreamWrapperTest, StreamWriteStr) { 33 | std::stringstream stream; 34 | YAML::ostream_wrapper wrapper(stream); 35 | wrapper.write(std::string("Hello, world")); 36 | EXPECT_STREQ(NULL, wrapper.str()); 37 | EXPECT_EQ("Hello, world", stream.str()); 38 | } 39 | 40 | TEST(OstreamWrapperTest, StreamWriteCStr) { 41 | std::stringstream stream; 42 | YAML::ostream_wrapper wrapper(stream); 43 | wrapper.write("Hello, world"); 44 | EXPECT_STREQ(NULL, wrapper.str()); 45 | EXPECT_EQ("Hello, world", stream.str()); 46 | } 47 | 48 | TEST(OstreamWrapperTest, Position) { 49 | YAML::ostream_wrapper wrapper; 50 | wrapper.write("Hello, world\n"); 51 | EXPECT_EQ(1, wrapper.row()); 52 | EXPECT_EQ(0, wrapper.col()); 53 | EXPECT_EQ(13, wrapper.pos()); 54 | } 55 | 56 | TEST(OstreamWrapperTest, Comment) { 57 | YAML::ostream_wrapper wrapper; 58 | wrapper.write("Hello, world "); 59 | wrapper.set_comment(); 60 | EXPECT_TRUE(wrapper.comment()); 61 | wrapper.write("foo"); 62 | EXPECT_TRUE(wrapper.comment()); 63 | wrapper.write("\n"); 64 | EXPECT_FALSE(wrapper.comment()); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /test/parser_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "yaml-cpp/parser.h" 3 | #include "yaml-cpp/exceptions.h" 4 | #include "mock_event_handler.h" 5 | #include "gtest/gtest.h" 6 | 7 | using YAML::Parser; 8 | using YAML::MockEventHandler; 9 | using ::testing::NiceMock; 10 | using ::testing::StrictMock; 11 | 12 | TEST(ParserTest, Empty) { 13 | Parser parser; 14 | 15 | EXPECT_FALSE(parser); 16 | 17 | StrictMock handler; 18 | EXPECT_FALSE(parser.HandleNextDocument(handler)); 19 | } 20 | 21 | TEST(ParserTest, CVE_2017_5950) { 22 | std::string excessive_recursion; 23 | for (auto i = 0; i != 16384; ++i) 24 | excessive_recursion.push_back('['); 25 | std::istringstream input{excessive_recursion}; 26 | Parser parser{input}; 27 | 28 | NiceMock handler; 29 | EXPECT_THROW(parser.HandleNextDocument(handler), YAML::DeepRecursion); 30 | } 31 | 32 | TEST(ParserTest, CVE_2018_20573) { 33 | std::string excessive_recursion; 34 | for (auto i = 0; i != 20535; ++i) 35 | excessive_recursion.push_back('{'); 36 | std::istringstream input{excessive_recursion}; 37 | Parser parser{input}; 38 | 39 | NiceMock handler; 40 | EXPECT_THROW(parser.HandleNextDocument(handler), YAML::DeepRecursion); 41 | } 42 | 43 | TEST(ParserTest, CVE_2018_20574) { 44 | std::string excessive_recursion; 45 | for (auto i = 0; i != 21989; ++i) 46 | excessive_recursion.push_back('{'); 47 | std::istringstream input{excessive_recursion}; 48 | Parser parser{input}; 49 | 50 | NiceMock handler; 51 | EXPECT_THROW(parser.HandleNextDocument(handler), YAML::DeepRecursion); 52 | } 53 | 54 | TEST(ParserTest, CVE_2019_6285) { 55 | std::string excessive_recursion; 56 | for (auto i = 0; i != 23100; ++i) 57 | excessive_recursion.push_back('['); 58 | excessive_recursion.push_back('f'); 59 | std::istringstream input{excessive_recursion}; 60 | Parser parser{input}; 61 | 62 | NiceMock handler; 63 | EXPECT_THROW(parser.HandleNextDocument(handler), YAML::DeepRecursion); 64 | } 65 | -------------------------------------------------------------------------------- /util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(yaml-cpp-sandbox sandbox.cpp) 2 | add_executable(yaml-cpp-parse parse.cpp) 3 | add_executable(yaml-cpp-read read.cpp) 4 | 5 | target_link_libraries(yaml-cpp-sandbox PRIVATE yaml-cpp) 6 | target_link_libraries(yaml-cpp-parse PRIVATE yaml-cpp) 7 | target_link_libraries(yaml-cpp-read PRIVATE yaml-cpp) 8 | 9 | set_property(TARGET yaml-cpp-sandbox PROPERTY OUTPUT_NAME sandbox) 10 | set_property(TARGET yaml-cpp-parse PROPERTY OUTPUT_NAME parse) 11 | set_property(TARGET yaml-cpp-read PROPERTY OUTPUT_NAME read) 12 | 13 | set_target_properties(yaml-cpp-sandbox 14 | PROPERTIES 15 | CXX_STANDARD_REQUIRED ON 16 | OUTPUT_NAME sandbox) 17 | 18 | set_target_properties(yaml-cpp-parse 19 | PROPERTIES 20 | CXX_STANDARD_REQUIRED ON 21 | OUTPUT_NAME parse) 22 | 23 | set_target_properties(yaml-cpp-read 24 | PROPERTIES 25 | CXX_STANDARD_REQUIRED ON 26 | OUTPUT_NAME read) 27 | 28 | if (NOT DEFINED CMAKE_CXX_STANDARD) 29 | set_target_properties(yaml-cpp-sandbox yaml-cpp-parse yaml-cpp-read 30 | PROPERTIES 31 | CXX_STANDARD 11) 32 | endif() 33 | -------------------------------------------------------------------------------- /util/parse.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "yaml-cpp/eventhandler.h" 6 | #include "yaml-cpp/yaml.h" // IWYU pragma: keep 7 | 8 | class NullEventHandler : public YAML::EventHandler { 9 | public: 10 | void OnDocumentStart(const YAML::Mark&) override {} 11 | void OnDocumentEnd() override {} 12 | 13 | void OnNull(const YAML::Mark&, YAML::anchor_t) override {} 14 | void OnAlias(const YAML::Mark&, YAML::anchor_t) override {} 15 | void OnScalar(const YAML::Mark&, const std::string&, YAML::anchor_t, 16 | const std::string&) override {} 17 | 18 | void OnSequenceStart(const YAML::Mark&, const std::string&, YAML::anchor_t, 19 | YAML::EmitterStyle::value) override {} 20 | void OnSequenceEnd() override {} 21 | 22 | void OnMapStart(const YAML::Mark&, const std::string&, YAML::anchor_t, 23 | YAML::EmitterStyle::value) override {} 24 | void OnMapEnd() override {} 25 | }; 26 | 27 | void parse(std::istream& input) { 28 | try { 29 | YAML::Node doc = YAML::Load(input); 30 | std::cout << doc << "\n"; 31 | } catch (const YAML::Exception& e) { 32 | std::cerr << e.what() << "\n"; 33 | } 34 | } 35 | 36 | int main(int argc, char** argv) { 37 | if (argc > 1) { 38 | std::ifstream fin; 39 | fin.open(argv[1]); 40 | parse(fin); 41 | } else { 42 | parse(std::cin); 43 | } 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /util/sandbox.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "yaml-cpp/emitterstyle.h" 4 | #include "yaml-cpp/eventhandler.h" 5 | #include "yaml-cpp/yaml.h" // IWYU pragma: keep 6 | 7 | class NullEventHandler : public YAML::EventHandler { 8 | public: 9 | using Mark = YAML::Mark; 10 | using anchor_t = YAML::anchor_t; 11 | 12 | NullEventHandler() = default; 13 | 14 | void OnDocumentStart(const Mark&) override {} 15 | void OnDocumentEnd() override {} 16 | void OnNull(const Mark&, anchor_t) override {} 17 | void OnAlias(const Mark&, anchor_t) override {} 18 | void OnScalar(const Mark&, const std::string&, anchor_t, 19 | const std::string&) override {} 20 | void OnSequenceStart(const Mark&, const std::string&, anchor_t, 21 | YAML::EmitterStyle::value) override {} 22 | void OnSequenceEnd() override {} 23 | void OnMapStart(const Mark&, const std::string&, anchor_t, 24 | YAML::EmitterStyle::value) override {} 25 | void OnMapEnd() override {} 26 | }; 27 | 28 | int main() { 29 | YAML::Node root; 30 | 31 | for (;;) { 32 | YAML::Node node; 33 | root = node; 34 | } 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /yaml-cpp-config.cmake.in: -------------------------------------------------------------------------------- 1 | # - Config file for the yaml-cpp package 2 | # It defines the following variables 3 | # YAML_CPP_INCLUDE_DIR - include directory 4 | # YAML_CPP_LIBRARY_DIR - directory containing libraries 5 | # YAML_CPP_SHARED_LIBS_BUILT - whether we have built shared libraries or not 6 | # YAML_CPP_LIBRARIES - libraries to link against 7 | 8 | @PACKAGE_INIT@ 9 | 10 | set_and_check(YAML_CPP_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") 11 | set_and_check(YAML_CPP_LIBRARY_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@") 12 | 13 | # Are we building shared libraries? 14 | set(YAML_CPP_SHARED_LIBS_BUILT @YAML_BUILD_SHARED_LIBS@) 15 | 16 | # Our library dependencies (contains definitions for IMPORTED targets) 17 | include("${CMAKE_CURRENT_LIST_DIR}/yaml-cpp-targets.cmake") 18 | 19 | # These are IMPORTED targets created by yaml-cpp-targets.cmake 20 | set(YAML_CPP_LIBRARIES "@EXPORT_TARGETS@") 21 | 22 | # Protect against multiple inclusion, which would fail when already imported targets are added once more. 23 | if(NOT TARGET yaml-cpp) 24 | add_library(yaml-cpp INTERFACE IMPORTED) 25 | target_link_libraries(yaml-cpp INTERFACE yaml-cpp::yaml-cpp) 26 | if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) 27 | set_target_properties(yaml-cpp PROPERTIES 28 | DEPRECATION "The target yaml-cpp is deprecated and will be removed in version 0.10.0. Use the yaml-cpp::yaml-cpp target instead." 29 | ) 30 | endif() 31 | endif() 32 | 33 | check_required_components(yaml-cpp) 34 | -------------------------------------------------------------------------------- /yaml-cpp.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 4 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 5 | 6 | Name: Yaml-cpp 7 | Description: A YAML parser and emitter for C++ 8 | Version: @YAML_CPP_VERSION@ 9 | Requires: 10 | Libs: -L${libdir} -lyaml-cpp 11 | Cflags: -I${includedir} 12 | --------------------------------------------------------------------------------