├── .gitattributes ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSE ├── README.md ├── class_parser ├── CMakeLists.txt ├── README.md ├── annotations.cpp ├── annotations.h ├── ast_action.cpp ├── ast_action.h ├── ast_consumer.cpp ├── ast_consumer.h ├── clang.h ├── clang_fwd.h ├── clang_helper_functions.h ├── class_handler.cpp ├── class_handler.h ├── class_parser.cpp ├── class_parser.h ├── design.txt ├── helper_functions.cpp ├── helper_functions.h ├── log.h ├── output_modules.h ├── output_modules │ ├── bidirectional_output.cpp │ ├── bidirectional_output.h │ ├── bindings_output.cpp │ ├── bindings_output.h │ ├── javascript_stub_output.cpp │ ├── javascript_stub_output.h │ ├── javascript_subclass_template.cpp │ ├── javascript_subclass_template.h │ └── noop_output.h ├── parsed_method.cpp ├── parsed_method.h ├── qual_type_wrapper.cpp ├── qual_type_wrapper.h ├── test │ ├── CMakeLists.txt │ ├── class_parser_input_files │ │ ├── sample.cpp │ │ └── sample.h │ └── test.cpp ├── type.h ├── wrapped_class.cpp └── wrapped_class.h ├── docs ├── README.md └── mac_build.txt ├── doxygen.cfg ├── googletest ├── .gitignore ├── .travis.yml ├── BUILD.bazel ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── Makefile.am ├── README.md ├── WORKSPACE ├── appveyor.yml ├── ci │ ├── build-linux-autotools.sh │ ├── build-linux-bazel.sh │ ├── env-linux.sh │ ├── env-osx.sh │ ├── get-nprocessors.sh │ ├── install-linux.sh │ ├── install-osx.sh │ ├── log-config.sh │ └── travis.sh ├── configure.ac ├── googlemock │ ├── CHANGES │ ├── CMakeLists.txt │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── Makefile.am │ ├── README.md │ ├── build-aux │ │ └── .keep │ ├── cmake │ │ ├── gmock.pc.in │ │ └── gmock_main.pc.in │ ├── configure.ac │ ├── docs │ │ ├── CheatSheet.md │ │ ├── CookBook.md │ │ ├── DesignDoc.md │ │ ├── DevGuide.md │ │ ├── Documentation.md │ │ ├── ForDummies.md │ │ ├── FrequentlyAskedQuestions.md │ │ └── KnownIssues.md │ ├── include │ │ └── gmock │ │ │ ├── gmock-actions.h │ │ │ ├── gmock-cardinalities.h │ │ │ ├── gmock-generated-actions.h │ │ │ ├── gmock-generated-actions.h.pump │ │ │ ├── gmock-generated-function-mockers.h │ │ │ ├── gmock-generated-function-mockers.h.pump │ │ │ ├── gmock-generated-matchers.h │ │ │ ├── gmock-generated-matchers.h.pump │ │ │ ├── gmock-generated-nice-strict.h │ │ │ ├── gmock-generated-nice-strict.h.pump │ │ │ ├── gmock-matchers.h │ │ │ ├── gmock-more-actions.h │ │ │ ├── gmock-more-matchers.h │ │ │ ├── gmock-spec-builders.h │ │ │ ├── gmock.h │ │ │ └── internal │ │ │ ├── custom │ │ │ ├── gmock-generated-actions.h │ │ │ ├── gmock-generated-actions.h.pump │ │ │ ├── gmock-matchers.h │ │ │ └── gmock-port.h │ │ │ ├── gmock-generated-internal-utils.h │ │ │ ├── gmock-generated-internal-utils.h.pump │ │ │ ├── gmock-internal-utils.h │ │ │ └── gmock-port.h │ ├── make │ │ └── Makefile │ ├── msvc │ │ ├── 2005 │ │ │ ├── gmock.sln │ │ │ ├── gmock.vcproj │ │ │ ├── gmock_config.vsprops │ │ │ ├── gmock_main.vcproj │ │ │ └── gmock_test.vcproj │ │ ├── 2010 │ │ │ ├── gmock.sln │ │ │ ├── gmock.vcxproj │ │ │ ├── gmock_config.props │ │ │ ├── gmock_main.vcxproj │ │ │ └── gmock_test.vcxproj │ │ └── 2015 │ │ │ ├── gmock.sln │ │ │ ├── gmock.vcxproj │ │ │ ├── gmock_config.props │ │ │ ├── gmock_main.vcxproj │ │ │ └── gmock_test.vcxproj │ ├── scripts │ │ ├── fuse_gmock_files.py │ │ ├── generator │ │ │ ├── LICENSE │ │ │ ├── README │ │ │ ├── README.cppclean │ │ │ ├── cpp │ │ │ │ ├── __init__.py │ │ │ │ ├── ast.py │ │ │ │ ├── gmock_class.py │ │ │ │ ├── gmock_class_test.py │ │ │ │ ├── keywords.py │ │ │ │ ├── tokenize.py │ │ │ │ └── utils.py │ │ │ └── gmock_gen.py │ │ ├── gmock-config.in │ │ ├── gmock_doctor.py │ │ ├── upload.py │ │ └── upload_gmock.py │ ├── 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-generated-actions_test.cc │ │ ├── gmock-generated-function-mockers_test.cc │ │ ├── gmock-generated-internal-utils_test.cc │ │ ├── gmock-generated-matchers_test.cc │ │ ├── gmock-internal-utils_test.cc │ │ ├── gmock-matchers_test.cc │ │ ├── gmock-more-actions_test.cc │ │ ├── gmock-nice-strict_test.cc │ │ ├── gmock-port_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 │ ├── CHANGES │ ├── CMakeLists.txt │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── Makefile.am │ ├── README.md │ ├── build-aux │ │ └── .keep │ ├── cmake │ │ ├── gtest.pc.in │ │ ├── gtest_main.pc.in │ │ └── internal_utils.cmake │ ├── codegear │ │ ├── gtest.cbproj │ │ ├── gtest.groupproj │ │ ├── gtest_all.cc │ │ ├── gtest_link.cc │ │ ├── gtest_main.cbproj │ │ └── gtest_unittest.cbproj │ ├── configure.ac │ ├── docs │ │ ├── AdvancedGuide.md │ │ ├── DevGuide.md │ │ ├── Documentation.md │ │ ├── FAQ.md │ │ ├── Pkgconfig.md │ │ ├── Primer.md │ │ ├── PumpManual.md │ │ ├── Samples.md │ │ └── XcodeGuide.md │ ├── include │ │ └── gtest │ │ │ ├── gtest-death-test.h │ │ │ ├── gtest-message.h │ │ │ ├── gtest-param-test.h │ │ │ ├── gtest-param-test.h.pump │ │ │ ├── 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 │ │ │ ├── gtest-port.h │ │ │ ├── gtest-printers.h │ │ │ └── gtest.h │ │ │ ├── gtest-death-test-internal.h │ │ │ ├── gtest-filepath.h │ │ │ ├── gtest-internal.h │ │ │ ├── gtest-linked_ptr.h │ │ │ ├── gtest-param-util-generated.h │ │ │ ├── gtest-param-util-generated.h.pump │ │ │ ├── gtest-param-util.h │ │ │ ├── gtest-port-arch.h │ │ │ ├── gtest-port.h │ │ │ ├── gtest-string.h │ │ │ ├── gtest-tuple.h │ │ │ ├── gtest-tuple.h.pump │ │ │ ├── gtest-type-util.h │ │ │ └── gtest-type-util.h.pump │ ├── m4 │ │ ├── acx_pthread.m4 │ │ └── gtest.m4 │ ├── make │ │ └── Makefile │ ├── msvc │ │ └── 2010 │ │ │ ├── gtest-md.sln │ │ │ ├── gtest-md.vcxproj │ │ │ ├── gtest-md.vcxproj.filters │ │ │ ├── gtest.sln │ │ │ ├── gtest.vcxproj │ │ │ ├── gtest.vcxproj.filters │ │ │ ├── gtest_main-md.vcxproj │ │ │ ├── gtest_main-md.vcxproj.filters │ │ │ ├── gtest_main.vcxproj │ │ │ ├── gtest_main.vcxproj.filters │ │ │ ├── gtest_prod_test-md.vcxproj │ │ │ ├── gtest_prod_test-md.vcxproj.filters │ │ │ ├── gtest_prod_test.vcxproj │ │ │ ├── gtest_prod_test.vcxproj.filters │ │ │ ├── gtest_unittest-md.vcxproj │ │ │ ├── gtest_unittest-md.vcxproj.filters │ │ │ ├── gtest_unittest.vcxproj │ │ │ └── gtest_unittest.vcxproj.filters │ ├── 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 │ ├── scripts │ │ ├── common.py │ │ ├── fuse_gtest_files.py │ │ ├── gen_gtest_pred_impl.py │ │ ├── gtest-config.in │ │ ├── pump.py │ │ ├── release_docs.py │ │ ├── test │ │ │ └── Makefile │ │ ├── upload.py │ │ └── upload_gtest.py │ ├── src │ │ ├── gtest-all.cc │ │ ├── gtest-death-test.cc │ │ ├── gtest-filepath.cc │ │ ├── gtest-internal-inl.h │ │ ├── gtest-port.cc │ │ ├── gtest-printers.cc │ │ ├── gtest-test-part.cc │ │ ├── gtest-typed-test.cc │ │ ├── gtest.cc │ │ └── gtest_main.cc │ ├── test │ │ ├── BUILD.bazel │ │ ├── gtest-death-test_ex_test.cc │ │ ├── gtest-death-test_test.cc │ │ ├── gtest-filepath_test.cc │ │ ├── gtest-linked_ptr_test.cc │ │ ├── gtest-listener_test.cc │ │ ├── gtest-message_test.cc │ │ ├── gtest-options_test.cc │ │ ├── gtest-param-test2_test.cc │ │ ├── gtest-param-test_test.cc │ │ ├── gtest-param-test_test.h │ │ ├── gtest-port_test.cc │ │ ├── gtest-printers_test.cc │ │ ├── gtest-test-part_test.cc │ │ ├── gtest-tuple_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_break_on_failure_unittest.py │ │ ├── gtest_break_on_failure_unittest_.cc │ │ ├── gtest_catch_exceptions_test.py │ │ ├── gtest_catch_exceptions_test_.cc │ │ ├── gtest_color_test.py │ │ ├── gtest_color_test_.cc │ │ ├── gtest_env_var_test.py │ │ ├── gtest_env_var_test_.cc │ │ ├── gtest_environment_test.cc │ │ ├── gtest_filter_unittest.py │ │ ├── gtest_filter_unittest_.cc │ │ ├── gtest_help_test.py │ │ ├── gtest_help_test_.cc │ │ ├── gtest_list_tests_unittest.py │ │ ├── gtest_list_tests_unittest_.cc │ │ ├── gtest_main_unittest.cc │ │ ├── gtest_no_test_unittest.cc │ │ ├── gtest_output_test.py │ │ ├── gtest_output_test_.cc │ │ ├── gtest_output_test_golden_lin.txt │ │ ├── gtest_pred_impl_unittest.cc │ │ ├── gtest_premature_exit_test.cc │ │ ├── gtest_prod_test.cc │ │ ├── gtest_repeat_test.cc │ │ ├── gtest_shuffle_test.py │ │ ├── gtest_shuffle_test_.cc │ │ ├── gtest_sole_header_test.cc │ │ ├── gtest_stress_test.cc │ │ ├── gtest_test_utils.py │ │ ├── gtest_throw_on_failure_ex_test.cc │ │ ├── gtest_throw_on_failure_test.py │ │ ├── gtest_throw_on_failure_test_.cc │ │ ├── gtest_uninitialized_test.py │ │ ├── gtest_uninitialized_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 │ └── xcode │ │ ├── Config │ │ ├── DebugProject.xcconfig │ │ ├── FrameworkTarget.xcconfig │ │ ├── General.xcconfig │ │ ├── ReleaseProject.xcconfig │ │ ├── StaticLibraryTarget.xcconfig │ │ └── TestTarget.xcconfig │ │ ├── Resources │ │ └── Info.plist │ │ ├── Samples │ │ └── FrameworkSample │ │ │ ├── Info.plist │ │ │ ├── WidgetFramework.xcodeproj │ │ │ └── project.pbxproj │ │ │ ├── runtests.sh │ │ │ ├── widget.cc │ │ │ ├── widget.h │ │ │ └── widget_test.cc │ │ ├── Scripts │ │ ├── runtests.sh │ │ └── versiongenerate.py │ │ └── gtest.xcodeproj │ │ └── project.pbxproj └── travis.sh ├── include └── v8toolkit │ ├── any.h │ ├── bidirectional.h │ ├── call_callable.h │ ├── call_javascript_function.h │ ├── cast_to_js.h │ ├── cast_to_js_impl.h │ ├── cast_to_native.h │ ├── cast_to_native_impl.h │ ├── casts.h │ ├── casts_eastl.h │ ├── casts_impl.h │ ├── debugger.h │ ├── exceptions.h │ ├── javascript.h │ ├── log.h │ ├── parameter_builder.h │ ├── stdfunctionreplacement.h │ ├── type_traits.h │ ├── unspecified_parameter_value.h │ ├── v8_class_wrapper.h │ ├── v8_class_wrapper_impl.h │ ├── v8helpers.h │ ├── v8toolkit.h │ └── wrapped_class_base.h ├── samples ├── bidirectional.js ├── bidirectional_sample.cpp ├── bidirectional_sample_make_script ├── code.js ├── compilation_timing_sample.cpp ├── compilation_timing_script ├── debugger_sample.cpp ├── debugger_sample.js ├── exception_sample.cpp ├── javascript_sample.cpp ├── module.js ├── module2.js ├── modules │ ├── a.js │ └── b.json ├── pure_v8_api_base_code_for_reproducing_issues.cpp ├── sample.cpp ├── sample2.js ├── thread_sample.cpp ├── toolbox_sample.cpp └── toolbox_sample.js ├── src ├── debugger.cpp ├── javascript.cpp ├── v8helpers.cpp └── v8toolkit.cpp ├── test ├── CMakeLists.txt ├── fixtures.h ├── mocks.h ├── runtime_error.js ├── syntax_error.js ├── test-bidirectional.cpp ├── test.cpp ├── testing.h ├── v8_class_wrapper-test.cpp ├── v8toolkit_test.cpp ├── valid_module.js └── wrapped_types_test.cpp └── v8toolkitConfig.cmake.in /.gitattributes: -------------------------------------------------------------------------------- 1 | googletest/* linguist-vendored 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | 30 | # Emacs backup files 31 | *~ 32 | 33 | # Doxygen docs 34 | generated_docs/ 35 | 36 | *.dSYM/ 37 | 38 | # Mac directory display metadat 39 | **/.DS_Store 40 | 41 | # clion cmake build directories 42 | cmake-build-* 43 | 44 | javascript 45 | natives_blob.bin 46 | sample 47 | snapshot_blob.bin 48 | thread_sample 49 | toolbox 50 | 51 | 52 | samples/exception_sample 53 | 54 | samples/javascript_sample 55 | 56 | samples/toolbox_sample 57 | samples/bidirectional_sample 58 | 59 | .idea/* -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "cmake-modules"] 2 | path = cmake-modules 3 | url = git@github.com:xaxxon/cmake-modules.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-2017 Zachary Hansen xaxxon@gmail.com 2 | 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | 10 | -------------------------------------------------------------------------------- /class_parser/README.md: -------------------------------------------------------------------------------- 1 | 2 | // Class Parser Config File 3 | // in xl-json format which allows comments, multi-line strings, and trailing commas 4 | 5 | 6 | // Format definition: 7 | 8 | { 9 | // settings associated with specific output modules 10 | "output_modules": { 11 | "BindingsOutputModule": { 12 | // default is 0 (unlimited) 13 | "max_declarations_per_file": 100 14 | } 15 | }, 16 | // The first bulk rename which matches will be used, so ordering within each 17 | // subsection's array is important 18 | "bulk_renames": { 19 | "static_functions": [ 20 | { 21 | "regex": "regex_to_match(.*)", 22 | "replace": "just_the_end$1" 23 | } 24 | ], 25 | "instance_members": [ 26 | { 27 | "regex": "regex_to_match(.*)", 28 | "replace": "just_the_end$1" 29 | } 30 | ] 31 | }, 32 | // override settings for how to handle functions and data members of wrapped types 33 | // Types which you control the definition for should be controlled with inline 34 | // attributes. This is mostly for third-party types with definitions which cannot 35 | // be changed 36 | "classes": { 37 | "namespace::ClassName": { 38 | "members": { 39 | "char * function_one() const &&": { 40 | "skip": true, 41 | "name": "different_name_for_function_two" 42 | }, 43 | "void namespace::ClassName::static_function_name(int * &)": { 44 | "skip": false, 45 | "name": "different_name_for_this_static_function" 46 | }, 47 | "int namespace::ClassName::data_member": { 48 | "skip": true, 49 | "name": "different_name_for_this_data_member" 50 | }, 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /class_parser/annotations.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "clang_fwd.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | namespace v8toolkit::class_parser { 14 | 15 | 16 | class Annotations { 17 | std::set annotations; 18 | 19 | void get_annotations_for_decl(const Decl * decl_to_check); 20 | 21 | 22 | public: 23 | 24 | Annotations(const Decl * decl_to_check) { 25 | get_annotations_for_decl(decl_to_check); 26 | } 27 | 28 | 29 | Annotations(const CXXMethodDecl * decl_to_check); 30 | 31 | Annotations() = default; 32 | 33 | const std::vector get() const; 34 | 35 | std::vector get_regex(const std::string & regex_string) const; 36 | 37 | bool has(const std::string & target) const { 38 | return std::find(annotations.begin(), annotations.end(), target) != annotations.end(); 39 | } 40 | 41 | void merge(const Annotations & other) { 42 | // cerr << fmt::format("Merging in {} annotations onto {} existing ones", other.get().size(), this->get().size()) << endl; 43 | annotations.insert(other.annotations.begin(), other.annotations.end()); 44 | } 45 | 46 | 47 | // holds a list of templates and associated annotations. These annotations will be merged with classes created 48 | // from the template. This allows metadata associated with all instantiations of a template 49 | static inline std::unordered_map annotations_for_class_templates; 50 | 51 | // any annotations on 'using' statements should be applied to the actual CXXRecordDecl being aliased (the right side) 52 | static inline std::unordered_map annotations_for_record_decls; 53 | 54 | 55 | // if a template instantiation is named with a 'using' statement, use that alias for the type isntead of the template/class name itself 56 | // this stops them all from being named the same thing - aka CppFactory, CppFactory, ... instead of MyThingFactory, MyOtherThingFactory, ... 57 | static inline std::unordered_map names_for_record_decls; 58 | 59 | 60 | Annotations(const CXXRecordDecl * decl_to_check); 61 | }; 62 | 63 | 64 | } -------------------------------------------------------------------------------- /class_parser/ast_action.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #pragma clang diagnostic push 6 | #pragma clang diagnostic ignored "-Wshadow" 7 | #include "clang/AST/ASTConsumer.h" 8 | #include "clang/Frontend/FrontendAction.h" 9 | #pragma clang diagnostic pop 10 | 11 | #include 12 | 13 | #include "wrapped_class.h" 14 | #include "helper_functions.h" 15 | 16 | #include "ast_consumer.h" 17 | #include "output_modules/javascript_stub_output.h" 18 | #include "output_modules/bindings_output.h" 19 | #include "output_modules/bidirectional_output.h" 20 | #include "output_modules/javascript_subclass_template.h" 21 | 22 | 23 | namespace v8toolkit::class_parser { 24 | 25 | // this doesn't change during the running of the plugin, so may as well just keep one copy of it for all to use 26 | inline CompilerInstance * compiler_instance = nullptr; 27 | 28 | 29 | // This is the class that is registered with LLVM. PluginASTAction is-a ASTFrontEndAction 30 | class PrintFunctionNamesAction : public clang::PluginASTAction { 31 | 32 | protected: 33 | // The value returned here is used internally to run checks against 34 | std::unique_ptr CreateASTConsumer(CompilerInstance & CI, 35 | llvm::StringRef) override; 36 | 37 | bool ParseArgs(const CompilerInstance & CI, 38 | const std::vector & args) override; 39 | 40 | void PrintHelp(llvm::raw_ostream & ros); 41 | 42 | 43 | public: 44 | 45 | static inline xl::json::Json config_data; 46 | static inline bool config_data_initialized = false; 47 | 48 | // open up output files 49 | PrintFunctionNamesAction(); 50 | ~PrintFunctionNamesAction(); 51 | 52 | // This is called when all parsing is done 53 | void EndSourceFileAction() override; 54 | 55 | std::vector> output_modules; 56 | 57 | bool BeginInvocation(CompilerInstance & ci) override; 58 | 59 | void add_output_module(unique_ptr output_module); 60 | 61 | /** 62 | * Returns Json object 63 | * @return 64 | */ 65 | static xl::json::Json get_config_data(); 66 | 67 | }; 68 | 69 | 70 | 71 | 72 | 73 | 74 | } -------------------------------------------------------------------------------- /class_parser/ast_consumer.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "ast_consumer.h" 3 | 4 | using namespace clang::ast_matchers; 5 | 6 | namespace v8toolkit::class_parser { 7 | 8 | ClassHandlerASTConsumer::ClassHandlerASTConsumer(CompilerInstance & ci, 9 | vector> const & output_modules) : 10 | class_handler(ci, output_modules) 11 | { 12 | 13 | #ifdef TEMPLATE_INFO_ONLY 14 | 15 | Matcher.addMatcher(decl(anyOf( 16 | classTemplateSpecializationDecl().bind("class"), 17 | cxxMethodDecl().bind("method") 18 | )), 19 | &class_handler); 20 | 21 | #else 22 | Matcher.addMatcher(cxxRecordDecl( 23 | allOf( 24 | // skip classes from v8toolkit::JSWrapper 25 | unless(isDerivedFrom("::v8toolkit::JSWrapper")), // JS-Classes will be completely regenerated 26 | 27 | // must be a struct or class 28 | anyOf(isStruct(), isClass()), 29 | unless(anyOf(matchesName("^::std::"), matchesName("^::eastl::"))), 30 | anyOf( // order of these matters. If a class matches more than one it will only be returned as the first 31 | 32 | // things here will always be wrapped 33 | allOf(isDefinition(), 34 | isDerivedFrom("::v8toolkit::WrappedClassBase"), 35 | cxxRecordDecl().bind( 36 | "class derived from WrappedClassBase")), 37 | 38 | // things here might be wrapped if they are a requirement from something else 39 | allOf(isDefinition(), 40 | cxxRecordDecl().bind("not std:: class")), 41 | 42 | // used for applying attributes to types you don't control 43 | allOf(unless(isDefinition()), 44 | cxxRecordDecl(hasAttr(attr::Annotate)).bind("forward declaration with annotation")) 45 | ) 46 | ) 47 | ), &class_handler); 48 | 49 | Matcher.addMatcher( 50 | namedDecl( 51 | allOf( 52 | hasAttr(attr::Annotate), // must have V8TOOLKIT_NAME_ALIAS set 53 | unless(matchesName("^::std::")), 54 | unless(matchesName("^::__") 55 | ) 56 | ) 57 | ).bind("named decl"), &class_handler); 58 | #endif 59 | 60 | } 61 | 62 | } 63 | 64 | -------------------------------------------------------------------------------- /class_parser/ast_consumer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "clang/AST/ASTConsumer.h" 4 | 5 | #include "class_handler.h" 6 | 7 | namespace v8toolkit::class_parser { 8 | 9 | 10 | /** 11 | * Defines what will be matched and sent to 12 | */ 13 | class ClassHandlerASTConsumer : public clang::ASTConsumer { 14 | private: 15 | 16 | // matcher that is parameterized in constructor 17 | ast_matchers::MatchFinder Matcher; 18 | 19 | // MatchCallback object called for each element matched by matcher 20 | ClassHandler class_handler; 21 | 22 | public: 23 | ClassHandlerASTConsumer(CompilerInstance & CI, vector> const & output_modules); 24 | 25 | void HandleTranslationUnit(ASTContext & Context) override { 26 | log.info(LogSubjects::Subjects::ClassParser, "HandleTranslationUnit"); 27 | 28 | // Run the matchers when we have the whole TU parsed. 29 | // matchers configured in constructor 30 | Matcher.matchAST(Context); 31 | } 32 | 33 | 34 | }; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /class_parser/clang.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xaxxon/v8toolkit/6cf23bfc0b7d20e4476aef5e0463b9316a818b90/class_parser/clang.h -------------------------------------------------------------------------------- /class_parser/clang_fwd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | namespace clang { 5 | 6 | class Decl; 7 | 8 | class CXXMethodDecl; 9 | 10 | class ClassTemplateDecl; 11 | 12 | class CXXRecordDecl; 13 | 14 | class NamedDecl; 15 | 16 | class CompilerInstance; 17 | 18 | class TypeDecl; 19 | 20 | class CXXConstructorDecl; 21 | 22 | class FunctionTemplateDecl; 23 | 24 | class ParmVarDecl; 25 | 26 | class FunctionTemplateDecl; 27 | 28 | class SourceManager; 29 | class SourceRange; 30 | class FileID; 31 | 32 | class QualType; 33 | 34 | class FieldDecl; 35 | 36 | namespace driver {} 37 | namespace tooling {} 38 | namespace comments { 39 | 40 | 41 | class FullComment; 42 | 43 | } 44 | 45 | 46 | } // end namespace clang 47 | 48 | 49 | 50 | using namespace clang; 51 | using namespace clang::driver; 52 | using namespace clang::tooling; 53 | using namespace clang::comments; 54 | -------------------------------------------------------------------------------- /class_parser/clang_helper_functions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "helper_functions.h" 4 | #include "clang/AST/Type.h" 5 | 6 | namespace v8toolkit::class_parser { 7 | 8 | 9 | QualType get_plain_type(QualType qual_type); 10 | 11 | 12 | // for a possibly templated type, return either the stripped down original type or the default template parameter type 13 | QualType get_substitution_type_for_type(QualType original_type, std::unordered_map const & template_types); 14 | 15 | 16 | } // end namespace v8toolkit::class_parser -------------------------------------------------------------------------------- /class_parser/class_handler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #pragma clang diagnostic push 4 | #pragma clang diagnostic ignored "-Wshadow" 5 | #include "clang/ASTMatchers/ASTMatchFinder.h" 6 | #pragma clang diagnostic pop 7 | 8 | #include "output_modules.h" 9 | 10 | namespace v8toolkit::class_parser { 11 | 12 | 13 | class ClassHandler : public ast_matchers::MatchFinder::MatchCallback { 14 | private: 15 | SourceManager & source_manager; 16 | 17 | std::set names_used; 18 | vector> const & output_modules; 19 | 20 | public: 21 | 22 | 23 | CompilerInstance & ci; 24 | 25 | /** 26 | * This runs per-match from ClassHandlerASTConsumer, but always on the same ClassHandler (this) object 27 | */ 28 | virtual void run(const ast_matchers::MatchFinder::MatchResult & Result) override; 29 | 30 | 31 | ClassHandler(CompilerInstance & CI, vector> const & output_modules); 32 | 33 | ~ClassHandler(); 34 | 35 | // all matcher callbacks have been run, now do anything to process the entirety of the data 36 | virtual void onEndOfTranslationUnit() override; 37 | 38 | // Run after compiling but before running the plugin over the contents of the AST 39 | virtual void onStartOfTranslationUnit() override; 40 | 41 | }; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /class_parser/log.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | 5 | #include 6 | 7 | 8 | namespace v8toolkit::class_parser { 9 | 10 | struct LogSubjects { 11 | inline static std::string subject_names[] = { 12 | "comments", "class", "methods", "data members", "enums", "constructors", "destructors", "bidirectional output", 13 | "bindings output", "javascript stub output", "jsdoc", "should be wrapped", "class parser", "config file", 14 | "exception" 15 | }; 16 | 17 | public: 18 | enum Subjects { 19 | Comments, // for log messages about parsing comments 20 | Class, 21 | Methods, 22 | DataMembers, 23 | Enums, 24 | Constructors, 25 | Destructors, 26 | BidirectionalOutput, 27 | BindingsOutput, 28 | JavaScriptStubOutput, 29 | JSDoc, 30 | ShouldBeWrapped, 31 | ClassParser, 32 | ConfigFile, 33 | Exception, 34 | 35 | LOG_LAST_SUBJECT 36 | 37 | }; 38 | }; 39 | 40 | using LogLevelsT = xl::log::DefaultLevels; 41 | using LogT = xl::log::Log; 42 | 43 | 44 | #if 0 45 | auto printer = [](LogT::LogMessage const & message){std::cerr << fmt::format("{}", message.string) << std::endl;}; 46 | inline LogT log(printer); 47 | #else 48 | extern LogT log; 49 | #endif 50 | 51 | } // end namespace v8toolkit::class_parser -------------------------------------------------------------------------------- /class_parser/output_modules/bidirectional_output.h: -------------------------------------------------------------------------------- 1 | // one file for N classes 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | #include "../output_modules.h" 11 | 12 | 13 | namespace v8toolkit::class_parser::bidirectional_output { 14 | 15 | 16 | // returns whether a WrappedClass object should be part of the JavaScript stub 17 | class BidirectionalCriteria : public OutputCriteria { 18 | bool operator()(WrappedClass const & c); 19 | }; 20 | 21 | 22 | 23 | class BidirectionalOutputStreamProvider : public OutputStreamProvider { 24 | private: 25 | // std::stringstream string_stream; 26 | std::ofstream output_file; 27 | public: 28 | std::ostream & get_class_collection_stream() override; 29 | 30 | ostream & get_class_stream(WrappedClass const & c) override; 31 | 32 | 33 | ~BidirectionalOutputStreamProvider() 34 | { 35 | std::cerr << fmt::format("closing BidirectionalOutputStreamProvider object\n"); 36 | this->output_file.close(); 37 | } 38 | }; 39 | 40 | 41 | 42 | class BidirectionalOutputModule : public OutputModule { 43 | private: 44 | BidirectionalCriteria criteria; 45 | public: 46 | 47 | std::stringstream string_stream; 48 | 49 | BidirectionalOutputModule(std::unique_ptr output_stream_provider = 50 | std::make_unique()) : 51 | OutputModule(std::move(output_stream_provider)) 52 | {} 53 | 54 | void process(std::vector wrapped_classes) override; 55 | 56 | string get_name() override; 57 | 58 | OutputCriteria & get_criteria() override; 59 | }; 60 | 61 | 62 | } // end namespace v8toolkit::class_parser -------------------------------------------------------------------------------- /class_parser/output_modules/bindings_output.h: -------------------------------------------------------------------------------- 1 | // one file for N classes 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | #include "../output_modules.h" 11 | 12 | 13 | namespace v8toolkit::class_parser::bindings_output { 14 | 15 | 16 | // returns whether a WrappedClass object should be part of the JavaScript stub 17 | struct BindingsCriteria : public OutputCriteria { 18 | bool operator()(WrappedClass const & c); 19 | }; 20 | 21 | 22 | class BindingsOutputStreamProvider : public OutputStreamProvider { 23 | private: 24 | std::stringstream string_stream; 25 | int count = 0; 26 | std::ofstream output_stream; 27 | public: 28 | std::ostream & get_class_collection_stream() override; 29 | ~BindingsOutputStreamProvider() 30 | {} 31 | }; 32 | 33 | 34 | 35 | class BindingsOutputModule : public OutputModule { 36 | protected: 37 | size_t max_declarations_per_file = 0; // default to unlimited 38 | BindingsCriteria criteria; 39 | public: 40 | /** 41 | * Creates a new object for outputing bindings commands for compilation into a v8toolkit program 42 | * @param max_declarations_per_file how many declaration "points" go into one file before the next one is started 43 | */ 44 | BindingsOutputModule(size_t max_declarations_per_file = -1, 45 | std::unique_ptr output_stream_provider = 46 | std::make_unique()); 47 | 48 | OutputCriteria & get_criteria() override; 49 | 50 | void process(std::vector wrapped_classes) override; 51 | 52 | string get_name() override; 53 | 54 | size_t get_max_declarations_per_file() const { 55 | return this->max_declarations_per_file; 56 | } 57 | }; 58 | 59 | 60 | } // end namespace v8toolkit::class_parser// N files to M classes -------------------------------------------------------------------------------- /class_parser/output_modules/javascript_stub_output.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | #include "../output_modules.h" 10 | 11 | 12 | namespace v8toolkit::class_parser::javascript_stub_output { 13 | 14 | 15 | // returns whether a WrappedClass object should be part of the JavaScript stub 16 | class JavascriptStubCriteria : public OutputCriteria { 17 | bool operator()(WrappedClass const & c) { 18 | // cerr << "Checking class criteria" << endl; 19 | 20 | if (c.bidirectional) { 21 | log.info(LogSubjects::Subjects::JavaScriptStubOutput, "Skipping generation of js stub for {} because it's a bidirectional type", c.class_name); 22 | return false; 23 | } 24 | 25 | return true; 26 | } 27 | }; 28 | 29 | class JavascriptStubOutputStreamProvider : public OutputStreamProvider { 30 | private: 31 | std::unique_ptr output_stream; 32 | public: 33 | virtual std::ostream & get_class_collection_stream(); 34 | ~JavascriptStubOutputStreamProvider(); 35 | 36 | }; 37 | 38 | 39 | 40 | 41 | class JavascriptStubOutputModule : public OutputModule { 42 | private: 43 | JavascriptStubCriteria criteria; 44 | public: 45 | JavascriptStubOutputModule(); 46 | JavascriptStubOutputModule(std::unique_ptr output_stream_provider); 47 | void process(std::vector wrapped_classes) override; 48 | 49 | OutputCriteria & get_criteria() override; 50 | 51 | string get_name() override; 52 | }; 53 | 54 | 55 | } // end namespace v8toolkit::class_parser::javascript_stub_output 56 | 57 | -------------------------------------------------------------------------------- /class_parser/output_modules/javascript_subclass_template.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | #include "../output_modules.h" 10 | 11 | 12 | namespace v8toolkit::class_parser::javascript_subclass_template_output { 13 | 14 | 15 | // returns whether a WrappedClass object should be part of the JavaScript stub 16 | class JavascriptSubclassTemplateCriteria : public OutputCriteria { 17 | bool operator()(WrappedClass const & c); 18 | }; 19 | 20 | 21 | 22 | class JavascriptSubclassTemplateOutputStreamProvider : public OutputStreamProvider { 23 | private: 24 | std::ofstream output_file; 25 | public: 26 | std::ostream & get_class_collection_stream() override; 27 | 28 | ostream & get_class_stream(WrappedClass const & c) override; 29 | 30 | 31 | ~JavascriptSubclassTemplateOutputStreamProvider() 32 | {} 33 | }; 34 | 35 | 36 | 37 | class JavascriptSubclassTemplateOutputModule : public OutputModule { 38 | private: 39 | JavascriptSubclassTemplateCriteria criteria; 40 | public: 41 | 42 | std::stringstream string_stream; 43 | 44 | JavascriptSubclassTemplateOutputModule( 45 | std::unique_ptr output_stream_provider = 46 | std::make_unique()) : 47 | 48 | OutputModule(std::move(output_stream_provider)) 49 | {} 50 | 51 | void process(std::vector wrapped_classes) override; 52 | 53 | string get_name() override; 54 | 55 | OutputCriteria & get_criteria() override; 56 | }; 57 | 58 | 59 | } // end namespace v8toolkit::class_parser -------------------------------------------------------------------------------- /class_parser/output_modules/noop_output.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | #include "../output_modules.h" 10 | 11 | 12 | namespace v8toolkit::class_parser::noop_output { 13 | 14 | 15 | /** 16 | * Handy little OutputModule for when you need to trick the system into running even though you don't want 17 | * a real OutputModule to run 18 | */ 19 | class NoOpOutputModule : public OutputModule { 20 | OutputCriteria criteria; 21 | public: 22 | std::stringstream string_stream; 23 | NoOpOutputModule():OutputModule(std::make_unique(string_stream)) {} 24 | void process(std::vector wrapped_classes) override {}; 25 | 26 | OutputCriteria & get_criteria() override { 27 | return criteria; 28 | } 29 | 30 | string get_name() override { 31 | return "NoOpOutputModule"; 32 | } 33 | }; 34 | 35 | 36 | } // end namespace v8toolkit::class_parser::noop_output 37 | 38 | -------------------------------------------------------------------------------- /class_parser/qual_type_wrapper.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "clang/AST/Type.h" 3 | 4 | #include "qual_type_wrapper.h" 5 | 6 | namespace v8toolkit::class_wrapper { 7 | 8 | QualTypeWrapper::QualTypeWrapper() = default; 9 | 10 | QualType & QualTypeWrapper::get() const { 11 | return *this->qual_type; 12 | } 13 | 14 | QualTypeWrapper::~QualTypeWrapper() = default; 15 | 16 | QualTypeWrapper::QualTypeWrapper(QualType const & qual_type) : 17 | qual_type(std::make_unique(qual_type)) 18 | {} 19 | 20 | QualTypeWrapper::QualTypeWrapper(QualTypeWrapper const & other) : 21 | qual_type(std::make_unique(other.get())) {} 22 | 23 | QualType const * QualTypeWrapper::operator->() const { 24 | return this->qual_type.get(); 25 | } 26 | 27 | QualType * QualTypeWrapper::operator->() { 28 | return this->qual_type.get(); 29 | } 30 | 31 | QualType const & QualTypeWrapper::operator*() const { 32 | return *this->qual_type; 33 | } 34 | 35 | QualType & QualTypeWrapper::operator*() { 36 | return *this->qual_type; 37 | } 38 | 39 | 40 | QualTypeWrapper & QualTypeWrapper::operator=(QualTypeWrapper const & other) { 41 | this->qual_type = std::make_unique(*other); 42 | return *this; 43 | } 44 | 45 | QualTypeWrapper & QualTypeWrapper::operator=(QualType const & other_qual_type) { 46 | this->qual_type = std::make_unique(other_qual_type); 47 | return *this; 48 | } 49 | 50 | 51 | } // end namespace v8toolkit::class_wrapper -------------------------------------------------------------------------------- /class_parser/qual_type_wrapper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "clang_fwd.h" 6 | 7 | 8 | namespace v8toolkit::class_wrapper { 9 | 10 | 11 | class QualTypeWrapper { 12 | private: 13 | std::unique_ptr qual_type; 14 | 15 | public: 16 | QualTypeWrapper(); 17 | QualTypeWrapper(QualType const & qual_type); 18 | 19 | ~QualTypeWrapper(); 20 | 21 | QualTypeWrapper(QualTypeWrapper const & other); 22 | 23 | QualTypeWrapper(QualTypeWrapper &&) = default; 24 | 25 | QualTypeWrapper & operator=(QualTypeWrapper const & other); 26 | 27 | QualTypeWrapper & operator=(QualType const & qual_type); 28 | 29 | QualTypeWrapper & operator=(QualTypeWrapper &&) = delete; 30 | 31 | QualType * operator->(); 32 | 33 | QualType & operator*(); 34 | 35 | QualType const * operator->() const; 36 | 37 | QualType const & operator*() const; 38 | 39 | QualType & get() const; 40 | }; 41 | 42 | } // end namespace v8toolkit::class_wrapper 43 | 44 | using namespace v8toolkit::class_wrapper; 45 | -------------------------------------------------------------------------------- /class_parser/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project ("Class Parser Test") 2 | set(CMAKE_VERBOSE_MAKEFILE on) 3 | 4 | 5 | 6 | add_executable(test-class-parser test.cpp ${CLASS_PARSER_SOURCES}) 7 | target_include_directories(test-class-parser SYSTEM PRIVATE 8 | ${gtest_SOURCE_DIR}/include 9 | ${gmock_SOURCE_DIR}/include 10 | ${CLANG_HOME}/include) 11 | 12 | 13 | # Uncomment next line to print debugging info from xl::template library 14 | target_compile_definitions(test-class-parser PRIVATE -DXL_TEMPLATE_LOG_ENABLE -DTEST_MODE -DXL_TEMPLATE_LOG_ENABLE 15 | -DV8_INCLUDE_DIR="${V8_INCLUDE_DIR}" 16 | -DCLANG_HOME="${CLANG_HOME}" 17 | ) 18 | 19 | 20 | find_package(fmt REQUIRED) 21 | target_link_libraries(test-class-parser fmt gmock gmock_main c++fs) 22 | 23 | # Can't have RTTI because the clang libs don't have it which means 24 | target_compile_options(test-class-parser PRIVATE -fno-rtti) 25 | 26 | target_link_libraries(test-class-parser clangFrontend clangSerialization clangASTMatchers clangSema 27 | clangAnalysis clangRewriteFrontend clangEdit clangDriver clangLex 28 | LLVMSymbolize LLVMDebugInfoPDB LLVMScalarOpts LLVMInstCombine LLVMInstrumentation LLVMBitWriter 29 | LLVMTransformUtils LLVMExecutionEngine LLVMTarget LLVMAnalysis LLVMRuntimeDyld 30 | LLVMObject LLVMBitReader LLVMCore clangParse clangAST 31 | clangBasic clangParse clangTooling c++experimental pcre) 32 | 33 | 34 | add_custom_target(copy_test_resources) 35 | add_custom_command(TARGET copy_test_resources PRE_BUILD 36 | COMMAND ${CMAKE_COMMAND} -E copy 37 | ${CMAKE_CURRENT_SOURCE_DIR}/../class_parser.h 38 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include/v8toolkit/wrapped_class_base.h 39 | ${PROJECT_BINARY_DIR}/ 40 | ) 41 | 42 | add_dependencies(test-class-parser gmock gtest copy_test_resources) 43 | 44 | 45 | -------------------------------------------------------------------------------- /class_parser/test/class_parser_input_files/sample.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | using namespace std; 11 | #include "class_parser.h" 12 | #include "wrapped_class_base.h" 13 | // 14 | //// simulate classes actually in v8_class_wrapper.h 15 | //namespace v8toolkit { 16 | // template 17 | // class V8ClassWrapper; 18 | // 19 | // 20 | // class WrappedClassBase{}; 21 | // 22 | // template 23 | // class JSWrapper{}; 24 | //} 25 | // 26 | // 27 | //class Uninteresting{}; 28 | // 29 | //class OnlyUsedInTemplate{}; 30 | // 31 | //template 32 | //class TemplatedClass{}; 33 | // 34 | //class FooGrandParent : public v8toolkit::WrappedClassBase { 35 | //public: 36 | // FooGrandParent(char, char, char); 37 | // virtual void foo_grandparent_but_not_foo_virtual(); 38 | //}; 39 | // 40 | //class V8TOOLKIT_WRAPPED_CLASS FooParent : public FooGrandParent { 41 | //public: 42 | //// FooParent(); 43 | //// virtual void fooparent_purevirtual_tobeoverridden() = 0; 44 | //// virtual void fooparent_virtual_tobeoverridden(); 45 | //// virtual void fooparent_virtual(char * a, int b, const volatile short & c); 46 | //// static int fooparent_static_method(const int *){return 8;} 47 | //// 48 | //// virtual int const_virtual_not_overwritten(int, int, int) const; 49 | //// 50 | //// char fooparent_char(); 51 | //// int fp_i; 52 | // 53 | // virtual void foo_parent_virtual(int, int, int); 54 | // virtual void foo_parent_pure_virtual(char, char, char, char) = 0; 55 | // virtual void foo_grandparent_but_not_foo_virtual() override; 56 | // 57 | // // marked final in derived type 58 | // virtual void final_virtual(); 59 | // 60 | //}; 61 | // 62 | // 63 | // 64 | // 65 | //namespace v8toolkit { 66 | // 67 | // class EmptyFactoryBase {}; 68 | // 69 | // class WrappedClassBase; 70 | // 71 | // template 72 | // class V8TOOLKIT_DO_NOT_WRAP_CONSTRUCTORS FlexibleParent : public WrappedClassBase {}; 73 | // 74 | // 75 | // 76 | //template 77 | // class TypeList; 78 | // 79 | //template< 80 | // class Base, 81 | // class Child, 82 | // class ExternalTypeList, 83 | // template class ParentType, 84 | // class FactoryBase> 85 | // class CppFactory; 86 | // 87 | 88 | /* 89 | template< 90 | class, 91 | class Child, 92 | class ExternalTypeList, 93 | template class ParentType, 94 | class FactoryBase> 95 | 96 | class V8TOOLKIT_SKIP CppFactory; 97 | */ 98 | //} 99 | 100 | 101 | -------------------------------------------------------------------------------- /class_parser/type.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #pragma clang diagnostic push 10 | #pragma clang diagnostic ignored "-Wshadow" 11 | #include 12 | #pragma clang diagnostic pop 13 | 14 | namespace v8toolkit::class_parser { 15 | 16 | struct WrappedClass; 17 | 18 | // represents qualified type 19 | struct TypeInfo { 20 | 21 | private: 22 | static std::string 23 | convert_simple_typename_to_jsdoc(std::string simple_type_name, 24 | std::string const & = ""); 25 | 26 | // Mapping between external template names and default types, such as: 27 | // template T foo(); 28 | // for the return value type T, this tells it it has a default type of int 29 | std::unordered_map template_parameter_types; 30 | 31 | // the type cannot be gotten because after template substitution there may not 32 | // be an actual 33 | // Type object for the resulting type. It is only available as a string. 34 | // However, the "plain type" is guaranteed to exist as a Type object 35 | 36 | public: 37 | QualType const type; 38 | 39 | explicit TypeInfo(QualType const &type, 40 | std::unordered_map const 41 | &template_parameter_types = {}); 42 | 43 | ~TypeInfo(); 44 | 45 | CXXRecordDecl const *get_plain_type_decl() const; 46 | 47 | TypeInfo get_plain_type() const; 48 | 49 | /// name of actual type 50 | std::string get_name() const; 51 | 52 | /// name of type without reference or pointers, but keeps "core" constness 53 | std::string get_plain_name() const; 54 | 55 | /// corresponding javascript type 56 | std::string get_jsdoc_type_name(std::string const & = "") const; 57 | 58 | // return if the type (or the type being pointed/referred to) is const (not is 59 | // the pointer const) double * const => false double const * => true 60 | bool is_const() const; 61 | 62 | /** 63 | * returns non-const version of this type (may be the same if not const to 64 | * begin with) 65 | * @return non-const version of this type 66 | */ 67 | TypeInfo without_const() const; 68 | 69 | bool is_templated() const; 70 | 71 | void for_each_templated_type(std::function) const; 72 | 73 | bool is_void() const; 74 | 75 | // returns the root incldues for this type (including any template type 76 | // parameters it may have) 77 | std::set get_root_includes() const; 78 | 79 | operator QualType() { return this->type; } 80 | 81 | WrappedClass * get_wrapped_class() const; 82 | 83 | }; 84 | 85 | } // end namespace v8toolkit::class_parser -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | ## V8 Toolkit Class Parser 2 | 3 | 4 | 5 | 6 | 7 | ### Config File 8 | 9 | For classes which cannot be annotated (such as third party code), a config file may be specified 10 | to the class parser plugin to change the way the bindings are generated. Attributes in this 11 | file will always override annotations in code. 12 | 13 | The layout and supported attributes are shown below: 14 | 15 | { 16 | "classes": { 17 | "namespace::ClassName1": { 18 | // Name to wrap class as 19 | "name": "different_name_for_ClassName1", 20 | "member_functions": { 21 | "member_function_signature_1": { 22 | // whether to skip wrapping this function 23 | "skip": true, 24 | 25 | // name to wrap function as 26 | "name": "different_name_for_member_function_name_1" 27 | }, 28 | "member_function_signature_2": {...} 29 | }, 30 | "static_functions": {...}, // same as member_functions 31 | "data_members": {...} // same as member_functions 32 | }, 33 | "namespace::ClassName2": {...} 34 | } 35 | } 36 | 37 | The exact string representation is important and must match the internal presentation in class 38 | parser. It may be useful to view the generated log file to see the internally used names 39 | in order to make sure to match them in your config file. 40 | 41 | -------------------------------------------------------------------------------- /docs/mac_build.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Building with GNI: 7 | -- 8 | 9 | May require 10.12 SDK - may be able to edit that in mac_sdk_overrides.gni 10 | 11 | 12 | 13 | 14 | 15 | 16 | To see available build flags: 17 | gn args out.gn/x64.release --list 18 | 19 | https://github.com/v8/v8/wiki/Building-with-GN 20 | 21 | -------------------------------------------------------------------------------- /googletest/.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 -------------------------------------------------------------------------------- /googletest/.travis.yml: -------------------------------------------------------------------------------- 1 | # Build matrix / environment variable are explained on: 2 | # http://about.travis-ci.org/docs/user/build-configuration/ 3 | # This file can be validated on: 4 | # http://lint.travis-ci.org/ 5 | 6 | install: 7 | # /usr/bin/gcc is 4.6 always, but gcc-X.Y is available. 8 | - if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi 9 | # /usr/bin/clang is 3.4, lets override with modern one. 10 | - if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="clang++-3.7" CC="clang-3.7"; ln -sf /usr/bin/ccache /$HOME/bin/$CXX; ln -sf /usr/bin/ccache /$HOME/bin/$CC; fi 11 | # ccache on OS X needs installation first 12 | - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install ccache; export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi 13 | # reset ccache statistics 14 | - ccache --zero-stats 15 | - echo ${PATH} 16 | - echo ${CXX} 17 | - ${CXX} --version 18 | - ${CXX} -v 19 | addons: 20 | apt: 21 | # List of whitelisted in travis packages for ubuntu-precise can be found here: 22 | # https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise 23 | # List of whitelisted in travis apt-sources: 24 | # https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json 25 | sources: 26 | - ubuntu-toolchain-r-test 27 | - llvm-toolchain-precise-3.7 28 | packages: 29 | - g++-4.9 30 | - clang-3.7 31 | os: 32 | - linux 33 | - osx 34 | language: cpp 35 | cache: ccache 36 | before_cache: 37 | # print statistics before uploading new cache 38 | - ccache --show-stats 39 | compiler: 40 | - gcc 41 | - clang 42 | script: ./travis.sh 43 | env: 44 | matrix: 45 | - BUILD_TYPE=Debug VERBOSE=1 46 | - BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 47 | notifications: 48 | email: false 49 | sudo: false 50 | -------------------------------------------------------------------------------- /googletest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6.4) 2 | 3 | if (POLICY CMP0048) 4 | cmake_policy(SET CMP0048 NEW) 5 | endif (POLICY CMP0048) 6 | 7 | project( googletest-distribution ) 8 | 9 | enable_testing() 10 | 11 | include(CMakeDependentOption) 12 | if (CMAKE_VERSION VERSION_LESS 2.8.5) 13 | set(CMAKE_INSTALL_BINDIR "bin" CACHE STRING "User executables (bin)") 14 | set(CMAKE_INSTALL_LIBDIR "lib${LIB_SUFFIX}" CACHE STRING "Object code libraries (lib)") 15 | set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE STRING "C header files (include)") 16 | mark_as_advanced(CMAKE_INSTALL_BINDIR CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR) 17 | else() 18 | include(GNUInstallDirs) 19 | endif() 20 | 21 | option(BUILD_GTEST "Builds the googletest subproject" OFF) 22 | 23 | #Note that googlemock target already builds googletest 24 | option(BUILD_GMOCK "Builds the googlemock subproject" ON) 25 | 26 | cmake_dependent_option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON "BUILD_GTEST OR BUILD_GMOCK" OFF) 27 | cmake_dependent_option(INSTALL_GMOCK "Enable installation of googlemock. (Projects embedding googlemock may want to turn this OFF.)" ON "BUILD_GMOCK" OFF) 28 | 29 | if(BUILD_GMOCK) 30 | add_subdirectory( googlemock ) 31 | elseif(BUILD_GTEST) 32 | add_subdirectory( googletest ) 33 | endif() 34 | -------------------------------------------------------------------------------- /googletest/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 | -------------------------------------------------------------------------------- /googletest/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | ACLOCAL_AMFLAGS = -I m4 3 | 4 | AUTOMAKE_OPTIONS = foreign 5 | 6 | # Build . before src so that our all-local and clean-local hooks kicks in at 7 | # the right time. 8 | SUBDIRS = googletest googlemock 9 | 10 | EXTRA_DIST = \ 11 | BUILD.bazel \ 12 | CMakeLists.txt \ 13 | README.md \ 14 | WORKSPACE 15 | -------------------------------------------------------------------------------- /googletest/WORKSPACE: -------------------------------------------------------------------------------- 1 | workspace(name = "com_google_googletest") 2 | 3 | # Abseil 4 | http_archive( 5 | name = "com_google_absl", 6 | urls = ["https://github.com/abseil/abseil-cpp/archive/master.zip"], 7 | strip_prefix = "abseil-cpp-master", 8 | ) 9 | -------------------------------------------------------------------------------- /googletest/ci/build-linux-autotools.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2017 Google Inc. 3 | # All Rights Reserved. 4 | # 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 | set -e 33 | 34 | . ci/get-nprocessors.sh 35 | 36 | # Create the configuration script 37 | autoreconf -i 38 | 39 | # Run in a subdirectory to keep the sources clean 40 | mkdir build || true 41 | cd build 42 | ../configure 43 | 44 | make -j ${NPROCESSORS:-2} 45 | -------------------------------------------------------------------------------- /googletest/ci/build-linux-bazel.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2017 Google Inc. 3 | # All Rights Reserved. 4 | # 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 | set -e 33 | 34 | bazel build --curses=no //...:all 35 | bazel test --curses=no //...:all 36 | bazel test --curses=no //...:all --define absl=1 37 | -------------------------------------------------------------------------------- /googletest/ci/env-linux.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2017 Google Inc. 3 | # All Rights Reserved. 4 | # 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 | # 33 | # This file should be sourced, and not executed as a standalone script. 34 | # 35 | 36 | # TODO() - we can check if this is being sourced using $BASH_VERSION and $BASH_SOURCE[0] != ${0}. 37 | 38 | if [ "${TRAVIS_OS_NAME}" = "linux" ]; then 39 | if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi 40 | if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi 41 | fi 42 | -------------------------------------------------------------------------------- /googletest/ci/env-osx.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2017 Google Inc. 3 | # All Rights Reserved. 4 | # 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 | # 33 | # This file should be sourced, and not executed as a standalone script. 34 | # 35 | 36 | # TODO() - we can check if this is being sourced using $BASH_VERSION and $BASH_SOURCE[0] != ${0}. 37 | 38 | if [ "${TRAVIS_OS_NAME}" = "linux" ]; then 39 | if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi 40 | fi 41 | -------------------------------------------------------------------------------- /googletest/ci/get-nprocessors.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2017 Google Inc. 3 | # All Rights Reserved. 4 | # 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 | # This file is typically sourced by another script. 33 | # if possible, ask for the precise number of processors, 34 | # otherwise take 2 processors as reasonable default; see 35 | # https://docs.travis-ci.com/user/speeding-up-the-build/#Makefile-optimization 36 | if [ -x /usr/bin/getconf ]; then 37 | NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN) 38 | else 39 | NPROCESSORS=2 40 | fi 41 | 42 | # as of 2017-09-04 Travis CI reports 32 processors, but GCC build 43 | # crashes if parallelized too much (maybe memory consumption problem), 44 | # so limit to 4 processors for the time being. 45 | if [ $NPROCESSORS -gt 4 ] ; then 46 | echo "$0:Note: Limiting processors to use by make from $NPROCESSORS to 4." 47 | NPROCESSORS=4 48 | fi 49 | -------------------------------------------------------------------------------- /googletest/ci/install-linux.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2017 Google Inc. 3 | # All Rights Reserved. 4 | # 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 | set -eu 33 | 34 | if [ "${TRAVIS_OS_NAME}" != linux ]; then 35 | echo "Not a Linux build; skipping installation" 36 | exit 0 37 | fi 38 | 39 | 40 | if [ "${TRAVIS_SUDO}" = "true" ]; then 41 | echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | \ 42 | sudo tee /etc/apt/sources.list.d/bazel.list 43 | curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add - 44 | sudo apt-get update && sudo apt-get install -y bazel gcc-4.9 g++-4.9 clang-3.7 45 | elif [ "${CXX}" = "clang++" ]; then 46 | # Use ccache, assuming $HOME/bin is in the path, which is true in the Travis build environment. 47 | ln -sf /usr/bin/ccache $HOME/bin/${CXX}; 48 | ln -sf /usr/bin/ccache $HOME/bin/${CC}; 49 | fi 50 | -------------------------------------------------------------------------------- /googletest/ci/install-osx.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2017 Google Inc. 3 | # All Rights Reserved. 4 | # 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 | set -eu 33 | 34 | if [ "${TRAVIS_OS_NAME}" != "osx" ]; then 35 | echo "Not a macOS build; skipping installation" 36 | exit 0 37 | fi 38 | 39 | brew install ccache 40 | -------------------------------------------------------------------------------- /googletest/ci/log-config.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2017 Google Inc. 3 | # All Rights Reserved. 4 | # 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 | set -e 33 | 34 | # ccache on OS X needs installation first 35 | # reset ccache statistics 36 | ccache --zero-stats 37 | 38 | echo PATH=${PATH} 39 | 40 | echo "Compiler configuration:" 41 | echo CXX=${CXX} 42 | echo CC=${CC} 43 | echo CXXFLAGS=${CXXFLAGS} 44 | 45 | echo "C++ compiler version:" 46 | ${CXX} --version || echo "${CXX} does not seem to support the --version flag" 47 | ${CXX} -v || echo "${CXX} does not seem to support the -v flag" 48 | 49 | echo "C compiler version:" 50 | ${CC} --version || echo "${CXX} does not seem to support the --version flag" 51 | ${CC} -v || echo "${CXX} does not seem to support the -v flag" 52 | -------------------------------------------------------------------------------- /googletest/ci/travis.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | set -evx 3 | 4 | . ci/get-nprocessors.sh 5 | 6 | # if possible, ask for the precise number of processors, 7 | # otherwise take 2 processors as reasonable default; see 8 | # https://docs.travis-ci.com/user/speeding-up-the-build/#Makefile-optimization 9 | if [ -x /usr/bin/getconf ]; then 10 | NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN) 11 | else 12 | NPROCESSORS=2 13 | fi 14 | # as of 2017-09-04 Travis CI reports 32 processors, but GCC build 15 | # crashes if parallelized too much (maybe memory consumption problem), 16 | # so limit to 4 processors for the time being. 17 | if [ $NPROCESSORS -gt 4 ] ; then 18 | echo "$0:Note: Limiting processors to use by make from $NPROCESSORS to 4." 19 | NPROCESSORS=4 20 | fi 21 | # Tell make to use the processors. No preceding '-' required. 22 | MAKEFLAGS="j${NPROCESSORS}" 23 | export MAKEFLAGS 24 | 25 | env | sort 26 | 27 | mkdir build || true 28 | cd build 29 | cmake -Dgtest_build_samples=ON \ 30 | -Dgtest_build_tests=ON \ 31 | -Dgmock_build_tests=ON \ 32 | -DCMAKE_CXX_FLAGS=$CXX_FLAGS \ 33 | -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ 34 | .. 35 | make 36 | CTEST_OUTPUT_ON_FAILURE=1 make test 37 | -------------------------------------------------------------------------------- /googletest/configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT([Google C++ Mocking and Testing Frameworks], 2 | [1.8.0], 3 | [googlemock@googlegroups.com], 4 | [googletest]) 5 | 6 | # Provide various options to initialize the Autoconf and configure processes. 7 | AC_PREREQ([2.59]) 8 | AC_CONFIG_SRCDIR([./README.md]) 9 | AC_CONFIG_AUX_DIR([build-aux]) 10 | AC_CONFIG_FILES([Makefile]) 11 | AC_CONFIG_SUBDIRS([googletest googlemock]) 12 | 13 | AM_INIT_AUTOMAKE 14 | 15 | # Output the generated files. No further autoconf macros may be used. 16 | AC_OUTPUT 17 | -------------------------------------------------------------------------------- /googletest/googlemock/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file contains a list of people who've made non-trivial 2 | # contribution to the Google C++ Mocking 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 | Benoit Sigoure 7 | Bogdan Piloca 8 | Chandler Carruth 9 | Dave MacLachlan 10 | David Anderson 11 | Dean Sturtevant 12 | Gene Volovich 13 | Hal Burch 14 | Jeffrey Yasskin 15 | Jim Keller 16 | Joe Walnes 17 | Jon Wray 18 | Keir Mierle 19 | Keith Ray 20 | Kostya Serebryany 21 | Lev Makhlis 22 | Manuel Klimek 23 | Mario Tanev 24 | Mark Paskin 25 | Markus Heule 26 | Matthew Simmons 27 | Mike Bland 28 | Neal Norwitz 29 | Nermin Ozkiranartli 30 | Owen Carlsen 31 | Paneendra Ba 32 | Paul Menage 33 | Piotr Kaminski 34 | Russ Rufer 35 | Sverre Sundsdal 36 | Takeshi Yoshino 37 | Vadim Berman 38 | Vlad Losev 39 | Wolfgang Klier 40 | Zhanyong Wan 41 | -------------------------------------------------------------------------------- /googletest/googlemock/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 | -------------------------------------------------------------------------------- /googletest/googlemock/build-aux/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xaxxon/v8toolkit/6cf23bfc0b7d20e4476aef5e0463b9316a818b90/googletest/googlemock/build-aux/.keep -------------------------------------------------------------------------------- /googletest/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 | Libs: -L${libdir} -lgmock @CMAKE_THREAD_LIBS_INIT@ 9 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ 10 | -------------------------------------------------------------------------------- /googletest/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 | Libs: -L${libdir} -lgmock_main @CMAKE_THREAD_LIBS_INIT@ 9 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ 10 | -------------------------------------------------------------------------------- /googletest/googlemock/docs/Documentation.md: -------------------------------------------------------------------------------- 1 | This page lists all documentation markdown files for Google Mock **(the 2 | current git version)** 3 | -- **if you use a former version of Google Mock, please read the 4 | documentation for that specific version instead (e.g. by checking out 5 | the respective git branch/tag).** 6 | 7 | * [ForDummies](ForDummies.md) -- start here if you are new to Google Mock. 8 | * [CheatSheet](CheatSheet.md) -- a quick reference. 9 | * [CookBook](CookBook.md) -- recipes for doing various tasks using Google Mock. 10 | * [FrequentlyAskedQuestions](FrequentlyAskedQuestions.md) -- check here before asking a question on the mailing list. 11 | 12 | To contribute code to Google Mock, read: 13 | 14 | * [CONTRIBUTING](../CONTRIBUTING.md) -- read this _before_ writing your first patch. 15 | * [Pump Manual](../../googletest/docs/PumpManual.md) -- how we generate some of Google Mock's source files. 16 | -------------------------------------------------------------------------------- /googletest/googlemock/docs/KnownIssues.md: -------------------------------------------------------------------------------- 1 | As any non-trivial software system, Google Mock has some known limitations and problems. We are working on improving it, and welcome your help! The follow is a list of issues we know about. 2 | 3 | 4 | 5 | ## README contains outdated information on Google Mock's compatibility with other testing frameworks ## 6 | 7 | The `README` file in release 1.1.0 still says that Google Mock only works with Google Test. Actually, you can configure Google Mock to work with any testing framework you choose. 8 | 9 | ## Tests failing on machines using Power PC CPUs (e.g. some Macs) ## 10 | 11 | `gmock_output_test` and `gmock-printers_test` are known to fail with Power PC CPUs. This is due to portability issues with these tests, and is not an indication of problems in Google Mock itself. You can safely ignore them. 12 | 13 | ## Failed to resolve libgtest.so.0 in tests when built against installed Google Test ## 14 | 15 | This only applies if you manually built and installed Google Test, and then built a Google Mock against it (either explicitly, or because gtest-config was in your path post-install). In this situation, Libtool has a known issue with certain systems' ldconfig setup: 16 | 17 | http://article.gmane.org/gmane.comp.sysutils.automake.general/9025 18 | 19 | This requires a manual run of "sudo ldconfig" after the "sudo make install" for Google Test before any binaries which link against it can be executed. This isn't a bug in our install, but we should at least have documented it or hacked a work-around into our install. We should have one of these solutions in our next release. -------------------------------------------------------------------------------- /googletest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h: -------------------------------------------------------------------------------- 1 | // This file was GENERATED by command: 2 | // pump.py gmock-generated-actions.h.pump 3 | // DO NOT EDIT BY HAND!!! 4 | 5 | #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ 6 | #define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ 7 | 8 | #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ 9 | -------------------------------------------------------------------------------- /googletest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump: -------------------------------------------------------------------------------- 1 | $$ -*- mode: c++; -*- 2 | $$ This is a Pump source file (http://go/pump). Please use Pump to convert 3 | $$ it to callback-actions.h. 4 | $$ 5 | $var max_callback_arity = 5 6 | $$}} This meta comment fixes auto-indentation in editors. 7 | #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ 8 | #define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ 9 | 10 | #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ 11 | -------------------------------------------------------------------------------- /googletest/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 | // ============================================================ 31 | // An installation-specific extension point for gmock-matchers.h. 32 | // ============================================================ 33 | // 34 | // Adds google3 callback support to CallableTraits. 35 | // 36 | #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_CALLBACK_MATCHERS_H_ 37 | #define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_CALLBACK_MATCHERS_H_ 38 | 39 | #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_CALLBACK_MATCHERS_H_ 40 | -------------------------------------------------------------------------------- /googletest/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. 31 | // The following macros can be defined: 32 | // 33 | // Flag related macros: 34 | // GMOCK_DECLARE_bool_(name) 35 | // GMOCK_DECLARE_int32_(name) 36 | // GMOCK_DECLARE_string_(name) 37 | // GMOCK_DEFINE_bool_(name, default_val, doc) 38 | // GMOCK_DEFINE_int32_(name, default_val, doc) 39 | // GMOCK_DEFINE_string_(name, default_val, doc) 40 | // 41 | // ** Custom implementation starts here ** 42 | 43 | #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ 44 | #define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ 45 | 46 | #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ 47 | -------------------------------------------------------------------------------- /googletest/googlemock/msvc/2005/gmock.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gmock", "gmock.vcproj", "{34681F0D-CE45-415D-B5F2-5C662DFE3BD5}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gmock_test", "gmock_test.vcproj", "{F10D22F8-AC7B-4213-8720-608E7D878CD2}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gmock_main", "gmock_main.vcproj", "{E4EF614B-30DF-4954-8C53-580A0BF6B589}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Win32 = Debug|Win32 13 | Release|Win32 = Release|Win32 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|Win32.Build.0 = Debug|Win32 18 | {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|Win32.ActiveCfg = Release|Win32 19 | {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|Win32.Build.0 = Release|Win32 20 | {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|Win32.ActiveCfg = Debug|Win32 21 | {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|Win32.Build.0 = Debug|Win32 22 | {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|Win32.ActiveCfg = Release|Win32 23 | {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|Win32.Build.0 = Release|Win32 24 | {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|Win32.ActiveCfg = Debug|Win32 25 | {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|Win32.Build.0 = Debug|Win32 26 | {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|Win32.ActiveCfg = Release|Win32 27 | {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|Win32.Build.0 = Release|Win32 28 | EndGlobalSection 29 | GlobalSection(SolutionProperties) = preSolution 30 | HideSolutionNode = FALSE 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /googletest/googlemock/msvc/2005/gmock_config.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 15 | 16 | -------------------------------------------------------------------------------- /googletest/googlemock/msvc/2010/gmock_config.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ../../../googletest 5 | 6 | 7 | <_ProjectFileVersion>10.0.30319.1 8 | 9 | 10 | 11 | $(GTestDir)/include;%(AdditionalIncludeDirectories) 12 | 13 | 14 | 15 | 16 | $(GTestDir) 17 | 18 | 19 | -------------------------------------------------------------------------------- /googletest/googlemock/msvc/2015/gmock_config.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ../../../googletest 5 | 6 | 7 | <_ProjectFileVersion>10.0.30319.1 8 | 9 | 10 | 11 | $(GTestDir)/include;%(AdditionalIncludeDirectories) 12 | 13 | 14 | 15 | 16 | $(GTestDir) 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /googletest/googlemock/scripts/generator/README: -------------------------------------------------------------------------------- 1 | 2 | The Google Mock class generator is an application that is part of cppclean. 3 | For more information about cppclean, see the README.cppclean file or 4 | visit http://code.google.com/p/cppclean/ 5 | 6 | cppclean requires Python 2.3.5 or later. If you don't have Python installed 7 | on your system, you will also need to install it. You can download Python 8 | from: http://www.python.org/download/releases/ 9 | 10 | To use the Google Mock class generator, you need to call it 11 | on the command line passing the header file and class for which you want 12 | to generate a Google Mock class. 13 | 14 | Make sure to install the scripts somewhere in your path. Then you can 15 | run the program. 16 | 17 | gmock_gen.py header-file.h [ClassName]... 18 | 19 | If no ClassNames are specified, all classes in the file are emitted. 20 | 21 | To change the indentation from the default of 2, set INDENT in 22 | the environment. For example to use an indent of 4 spaces: 23 | 24 | INDENT=4 gmock_gen.py header-file.h ClassName 25 | 26 | This version was made from SVN revision 281 in the cppclean repository. 27 | 28 | Known Limitations 29 | ----------------- 30 | Not all code will be generated properly. For example, when mocking templated 31 | classes, the template information is lost. You will need to add the template 32 | information manually. 33 | 34 | Not all permutations of using multiple pointers/references will be rendered 35 | properly. These will also have to be fixed manually. 36 | -------------------------------------------------------------------------------- /googletest/googlemock/scripts/generator/cpp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xaxxon/v8toolkit/6cf23bfc0b7d20e4476aef5e0463b9316a818b90/googletest/googlemock/scripts/generator/cpp/__init__.py -------------------------------------------------------------------------------- /googletest/googlemock/scripts/generator/cpp/keywords.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2007 Neal Norwitz 4 | # Portions Copyright 2007 Google Inc. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | 18 | """C++ keywords and helper utilities for determining keywords.""" 19 | 20 | __author__ = 'nnorwitz@google.com (Neal Norwitz)' 21 | 22 | 23 | try: 24 | # Python 3.x 25 | import builtins 26 | except ImportError: 27 | # Python 2.x 28 | import __builtin__ as builtins 29 | 30 | 31 | if not hasattr(builtins, 'set'): 32 | # Nominal support for Python 2.3. 33 | from sets import Set as set 34 | 35 | 36 | TYPES = set('bool char int long short double float void wchar_t unsigned signed'.split()) 37 | TYPE_MODIFIERS = set('auto register const inline extern static virtual volatile mutable'.split()) 38 | ACCESS = set('public protected private friend'.split()) 39 | 40 | CASTS = set('static_cast const_cast dynamic_cast reinterpret_cast'.split()) 41 | 42 | OTHERS = set('true false asm class namespace using explicit this operator sizeof'.split()) 43 | OTHER_TYPES = set('new delete typedef struct union enum typeid typename template'.split()) 44 | 45 | CONTROL = set('case switch default if else return goto'.split()) 46 | EXCEPTION = set('try catch throw'.split()) 47 | LOOP = set('while do for break continue'.split()) 48 | 49 | ALL = TYPES | TYPE_MODIFIERS | ACCESS | CASTS | OTHERS | OTHER_TYPES | CONTROL | EXCEPTION | LOOP 50 | 51 | 52 | def IsKeyword(token): 53 | return token in ALL 54 | 55 | def IsBuiltinType(token): 56 | if token in ('virtual', 'inline'): 57 | # These only apply to methods, they can't be types by themselves. 58 | return False 59 | return token in TYPES or token in TYPE_MODIFIERS 60 | -------------------------------------------------------------------------------- /googletest/googlemock/scripts/generator/cpp/utils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2007 Neal Norwitz 4 | # Portions Copyright 2007 Google Inc. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | 18 | """Generic utilities for C++ parsing.""" 19 | 20 | __author__ = 'nnorwitz@google.com (Neal Norwitz)' 21 | 22 | 23 | import sys 24 | 25 | 26 | # Set to True to see the start/end token indices. 27 | DEBUG = True 28 | 29 | 30 | def ReadFile(filename, print_error=True): 31 | """Returns the contents of a file.""" 32 | try: 33 | fp = open(filename) 34 | try: 35 | return fp.read() 36 | finally: 37 | fp.close() 38 | except IOError: 39 | if print_error: 40 | print('Error reading %s: %s' % (filename, sys.exc_info()[1])) 41 | return None 42 | -------------------------------------------------------------------------------- /googletest/googlemock/scripts/generator/gmock_gen.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2008 Google Inc. All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | """Driver for starting up Google Mock class generator.""" 18 | 19 | __author__ = 'nnorwitz@google.com (Neal Norwitz)' 20 | 21 | import os 22 | import sys 23 | 24 | if __name__ == '__main__': 25 | # Add the directory of this script to the path so we can import gmock_class. 26 | sys.path.append(os.path.dirname(__file__)) 27 | 28 | from cpp import gmock_class 29 | # Fix the docstring in case they require the usage. 30 | gmock_class.__doc__ = gmock_class.__doc__.replace('gmock_class.py', __file__) 31 | gmock_class.main() 32 | -------------------------------------------------------------------------------- /googletest/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 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Google C++ Mocking Framework (Google Mock) 33 | // 34 | // This file #includes all Google Mock implementation .cc files. The 35 | // purpose is to allow a user to build Google Mock by compiling this 36 | // file alone. 37 | 38 | // This line ensures that gmock.h can be compiled on its own, even 39 | // when it's fused. 40 | #include "gmock/gmock.h" 41 | 42 | // The following lines pull in the real gmock *.cc files. 43 | #include "src/gmock-cardinalities.cc" 44 | #include "src/gmock-internal-utils.cc" 45 | #include "src/gmock-matchers.cc" 46 | #include "src/gmock-spec-builders.cc" 47 | #include "src/gmock.cc" 48 | -------------------------------------------------------------------------------- /googletest/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 | // Author: vladl@google.com (Vlad Losev) 31 | 32 | // Google Mock - a framework for writing C++ mock classes. 33 | // 34 | // This file tests the internal cross-platform support utilities. 35 | 36 | #include "gmock/internal/gmock-port.h" 37 | #include "gtest/gtest.h" 38 | 39 | // NOTE: if this file is left without tests for some reason, put a dummy 40 | // test here to make references to symbols in the gtest library and avoid 41 | // 'undefined symbol' linker errors in gmock_main: 42 | 43 | TEST(DummyTest, Dummy) {} 44 | -------------------------------------------------------------------------------- /googletest/googlemock/test/gmock_all_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Tests for Google C++ Mocking Framework (Google Mock) 33 | // 34 | // Some users use a build system that Google Mock doesn't support directly, 35 | // yet they still want to build and run Google Mock's own tests. This file 36 | // includes most such tests, making it easier for these users to maintain 37 | // their build scripts (they just need to build this file, even though the 38 | // below list of actual *_test.cc files might change). 39 | #include "test/gmock-actions_test.cc" 40 | #include "test/gmock-cardinalities_test.cc" 41 | #include "test/gmock-generated-actions_test.cc" 42 | #include "test/gmock-generated-function-mockers_test.cc" 43 | #include "test/gmock-generated-internal-utils_test.cc" 44 | #include "test/gmock-generated-matchers_test.cc" 45 | #include "test/gmock-internal-utils_test.cc" 46 | #include "test/gmock-matchers_test.cc" 47 | #include "test/gmock-more-actions_test.cc" 48 | #include "test/gmock-nice-strict_test.cc" 49 | #include "test/gmock-port_test.cc" 50 | #include "test/gmock-spec-builders_test.cc" 51 | #include "test/gmock_test.cc" 52 | -------------------------------------------------------------------------------- /googletest/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 | // Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev) 31 | 32 | // Google Mock - a framework for writing C++ mock classes. 33 | // 34 | // This file is for verifying that various Google Mock constructs do not 35 | // produce linker errors when instantiated in different translation units. 36 | // Please see gmock_link_test.h for details. 37 | 38 | #define LinkTest LinkTest2 39 | 40 | #include "test/gmock_link_test.h" 41 | -------------------------------------------------------------------------------- /googletest/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 | // Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev) 31 | 32 | // Google Mock - a framework for writing C++ mock classes. 33 | // 34 | // This file is for verifying that various Google Mock constructs do not 35 | // produce linker errors when instantiated in different translation units. 36 | // Please see gmock_link_test.h for details. 37 | 38 | #define LinkTest LinkTest1 39 | 40 | #include "test/gmock_link_test.h" 41 | -------------------------------------------------------------------------------- /googletest/googletest/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file contains a list of people who've made non-trivial 2 | # contribution to the Google C++ Testing Framework project. People 3 | # who commit code to the project are encouraged to add their names 4 | # here. Please keep the list sorted by first names. 5 | 6 | Ajay Joshi 7 | Balázs Dán 8 | Bharat Mediratta 9 | Chandler Carruth 10 | Chris Prince 11 | Chris Taylor 12 | Dan Egnor 13 | Eric Roman 14 | Hady Zalek 15 | Jeffrey Yasskin 16 | Jói Sigurðsson 17 | Keir Mierle 18 | Keith Ray 19 | Kenton Varda 20 | Manuel Klimek 21 | Markus Heule 22 | Mika Raento 23 | Miklós Fazekas 24 | Pasi Valminen 25 | Patrick Hanna 26 | Patrick Riley 27 | Peter Kaminski 28 | Preston Jackson 29 | Rainer Klaffenboeck 30 | Russ Cox 31 | Russ Rufer 32 | Sean Mcafee 33 | Sigurður Ásgeirsson 34 | Tracy Bialik 35 | Vadim Berman 36 | Vlad Losev 37 | Zhanyong Wan 38 | -------------------------------------------------------------------------------- /googletest/googletest/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 | -------------------------------------------------------------------------------- /googletest/googletest/build-aux/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xaxxon/v8toolkit/6cf23bfc0b7d20e4476aef5e0463b9316a818b90/googletest/googletest/build-aux/.keep -------------------------------------------------------------------------------- /googletest/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@ @CMAKE_THREAD_LIBS_INIT@ 10 | -------------------------------------------------------------------------------- /googletest/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 9 | Libs: -L${libdir} -lgtest_main @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ 11 | -------------------------------------------------------------------------------- /googletest/googletest/codegear/gtest.groupproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {c1d923e0-6cba-4332-9b6f-3420acbf5091} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Default.Personality 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /googletest/googletest/codegear/gtest_all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: Josh Kelley (joshkel@gmail.com) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // C++Builder's IDE cannot build a static library from files with hyphens 35 | // in their name. See http://qc.codegear.com/wc/qcmain.aspx?d=70977 . 36 | // This file serves as a workaround. 37 | 38 | #include "src/gtest-all.cc" 39 | -------------------------------------------------------------------------------- /googletest/googletest/codegear/gtest_link.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: Josh Kelley (joshkel@gmail.com) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // Links gtest.lib and gtest_main.lib into the current project in C++Builder. 35 | // This means that these libraries can't be renamed, but it's the only way to 36 | // ensure that Debug versus Release test builds are linked against the 37 | // appropriate Debug or Release build of the libraries. 38 | 39 | #pragma link "gtest.lib" 40 | #pragma link "gtest_main.lib" 41 | -------------------------------------------------------------------------------- /googletest/googletest/docs/Documentation.md: -------------------------------------------------------------------------------- 1 | This page lists all documentation markdown files for Google Test **(the 2 | current git version)** 3 | -- **if you use a former version of Google Test, please read the 4 | documentation for that specific version instead (e.g. by checking out 5 | the respective git branch/tag).** 6 | 7 | * [Primer](Primer.md) -- start here if you are new to Google Test. 8 | * [Samples](Samples.md) -- learn from examples. 9 | * [AdvancedGuide](AdvancedGuide.md) -- learn more about Google Test. 10 | * [XcodeGuide](XcodeGuide.md) -- how to use Google Test in Xcode on Mac. 11 | * [Frequently-Asked Questions](FAQ.md) -- check here before asking a question on the mailing list. 12 | 13 | To contribute code to Google Test, read: 14 | 15 | * [CONTRIBUTING](../../CONTRIBUTING.md) -- read this _before_ writing your first patch. 16 | * [PumpManual](PumpManual.md) -- how we generate some of Google Test's source files. 17 | -------------------------------------------------------------------------------- /googletest/googletest/docs/Samples.md: -------------------------------------------------------------------------------- 1 | If you're like us, you'd like to look at some Google Test sample code. The 2 | [samples folder](../samples) has a number of well-commented samples showing how to use a 3 | variety of Google Test features. 4 | 5 | * [Sample #1](../samples/sample1_unittest.cc) shows the basic steps of using Google Test to test C++ functions. 6 | * [Sample #2](../samples/sample2_unittest.cc) shows a more complex unit test for a class with multiple member functions. 7 | * [Sample #3](../samples/sample3_unittest.cc) uses a test fixture. 8 | * [Sample #4](../samples/sample4_unittest.cc) is another basic example of using Google Test. 9 | * [Sample #5](../samples/sample5_unittest.cc) teaches how to reuse a test fixture in multiple test cases by deriving sub-fixtures from it. 10 | * [Sample #6](../samples/sample6_unittest.cc) demonstrates type-parameterized tests. 11 | * [Sample #7](../samples/sample7_unittest.cc) teaches the basics of value-parameterized tests. 12 | * [Sample #8](../samples/sample8_unittest.cc) shows using `Combine()` in value-parameterized tests. 13 | * [Sample #9](../samples/sample9_unittest.cc) shows use of the listener API to modify Google Test's console output and the use of its reflection API to inspect test results. 14 | * [Sample #10](../samples/sample10_unittest.cc) shows use of the listener API to implement a primitive memory leak checker. 15 | -------------------------------------------------------------------------------- /googletest/googletest/include/gtest/gtest_prod.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Google C++ Testing Framework definitions useful in production code. 33 | 34 | #ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 35 | #define GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 36 | 37 | // When you need to test the private or protected members of a class, 38 | // use the FRIEND_TEST macro to declare your tests as friends of the 39 | // class. For example: 40 | // 41 | // class MyClass { 42 | // private: 43 | // void PrivateMethod(); 44 | // FRIEND_TEST(MyClassTest, PrivateMethodWorks); 45 | // }; 46 | // 47 | // class MyClassTest : public testing::Test { 48 | // // ... 49 | // }; 50 | // 51 | // TEST_F(MyClassTest, PrivateMethodWorks) { 52 | // // Can call MyClass::PrivateMethod() here. 53 | // } 54 | // 55 | // Note: The test class must be in the same namespace as the class being tested. 56 | // For example, putting MyClassTest in an anonymous namespace will not work. 57 | 58 | #define FRIEND_TEST(test_case_name, test_name)\ 59 | friend class test_case_name##_##test_name##_Test 60 | 61 | #endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 62 | -------------------------------------------------------------------------------- /googletest/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 | // See documentation at gtest/gtest-printers.h for details on how to define a 35 | // custom printer. 36 | // 37 | // ** Custom implementation starts here ** 38 | 39 | #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 40 | #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 41 | 42 | #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 43 | -------------------------------------------------------------------------------- /googletest/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. 31 | // The following macros can be defined: 32 | // 33 | // GTEST_OS_STACK_TRACE_GETTER_ - The name of an implementation of 34 | // OsStackTraceGetterInterface. 35 | // 36 | // GTEST_CUSTOM_TEMPDIR_FUNCTION_ - An override for testing::TempDir(). 37 | // See testing::TempDir for semantics and 38 | // signature. 39 | // 40 | // ** Custom implementation starts here ** 41 | 42 | #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 43 | #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 44 | 45 | #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 46 | -------------------------------------------------------------------------------- /googletest/googletest/msvc/2010/gtest-md.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | -------------------------------------------------------------------------------- /googletest/googletest/msvc/2010/gtest.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | -------------------------------------------------------------------------------- /googletest/googletest/msvc/2010/gtest_main-md.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | -------------------------------------------------------------------------------- /googletest/googletest/msvc/2010/gtest_main.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | -------------------------------------------------------------------------------- /googletest/googletest/msvc/2010/gtest_prod_test-md.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | 22 | 23 | Header Files 24 | 25 | 26 | -------------------------------------------------------------------------------- /googletest/googletest/msvc/2010/gtest_prod_test.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | 22 | 23 | Header Files 24 | 25 | 26 | -------------------------------------------------------------------------------- /googletest/googletest/msvc/2010/gtest_unittest-md.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | -------------------------------------------------------------------------------- /googletest/googletest/msvc/2010/gtest_unittest.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | -------------------------------------------------------------------------------- /googletest/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 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #ifndef GTEST_SAMPLES_SAMPLE1_H_ 35 | #define GTEST_SAMPLES_SAMPLE1_H_ 36 | 37 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1. 38 | int Factorial(int n); 39 | 40 | // Returns true iff n is a prime number. 41 | bool IsPrime(int n); 42 | 43 | #endif // GTEST_SAMPLES_SAMPLE1_H_ 44 | -------------------------------------------------------------------------------- /googletest/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 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #include "sample2.h" 35 | 36 | #include 37 | 38 | // Clones a 0-terminated C string, allocating memory using new. 39 | const char* MyString::CloneCString(const char* a_c_string) { 40 | if (a_c_string == NULL) return NULL; 41 | 42 | const size_t len = strlen(a_c_string); 43 | char* const clone = new char[ len + 1 ]; 44 | memcpy(clone, a_c_string, len + 1); 45 | 46 | return clone; 47 | } 48 | 49 | // Sets the 0-terminated C string this MyString object 50 | // represents. 51 | void MyString::Set(const char* a_c_string) { 52 | // Makes sure this works when c_string == c_string_ 53 | const char* const temp = MyString::CloneCString(a_c_string); 54 | delete[] c_string_; 55 | c_string_ = temp; 56 | } 57 | -------------------------------------------------------------------------------- /googletest/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 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #include 35 | 36 | #include "sample4.h" 37 | 38 | // Returns the current counter value, and increments it. 39 | int Counter::Increment() { 40 | return counter_++; 41 | } 42 | 43 | // Prints the current counter value to STDOUT. 44 | void Counter::Print() const { 45 | printf("%d", counter_); 46 | } 47 | -------------------------------------------------------------------------------- /googletest/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 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #ifndef GTEST_SAMPLES_SAMPLE4_H_ 35 | #define GTEST_SAMPLES_SAMPLE4_H_ 36 | 37 | // A simple monotonic counter. 38 | class Counter { 39 | private: 40 | int counter_; 41 | 42 | public: 43 | // Creates a counter that starts at 0. 44 | Counter() : counter_(0) {} 45 | 46 | // Returns the current counter value, and increments it. 47 | int Increment(); 48 | 49 | // Prints the current counter value to STDOUT. 50 | void Print() const; 51 | }; 52 | 53 | #endif // GTEST_SAMPLES_SAMPLE4_H_ 54 | -------------------------------------------------------------------------------- /googletest/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 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "sample4.h" 33 | #include "gtest/gtest.h" 34 | 35 | namespace { 36 | // Tests the Increment() method. 37 | 38 | TEST(Counter, Increment) { 39 | Counter c; 40 | 41 | // EXPECT_EQ() evaluates its arguments exactly once, so they 42 | // can have side effects. 43 | 44 | EXPECT_EQ(0, c.Increment()); 45 | EXPECT_EQ(1, c.Increment()); 46 | EXPECT_EQ(2, c.Increment()); 47 | } 48 | 49 | } // namespace 50 | -------------------------------------------------------------------------------- /googletest/googletest/scripts/test/Makefile: -------------------------------------------------------------------------------- 1 | # A Makefile for fusing Google Test and building a sample test against it. 2 | # 3 | # SYNOPSIS: 4 | # 5 | # make [all] - makes everything. 6 | # make TARGET - makes the given target. 7 | # make check - makes everything and runs the built sample test. 8 | # make clean - removes all files generated by make. 9 | 10 | # Points to the root of fused Google Test, relative to where this file is. 11 | FUSED_GTEST_DIR = output 12 | 13 | # Paths to the fused gtest files. 14 | FUSED_GTEST_H = $(FUSED_GTEST_DIR)/gtest/gtest.h 15 | FUSED_GTEST_ALL_CC = $(FUSED_GTEST_DIR)/gtest/gtest-all.cc 16 | 17 | # Where to find the sample test. 18 | SAMPLE_DIR = ../../samples 19 | 20 | # Where to find gtest_main.cc. 21 | GTEST_MAIN_CC = ../../src/gtest_main.cc 22 | 23 | # Flags passed to the preprocessor. 24 | # We have no idea here whether pthreads is available in the system, so 25 | # disable its use. 26 | CPPFLAGS += -I$(FUSED_GTEST_DIR) -DGTEST_HAS_PTHREAD=0 27 | 28 | # Flags passed to the C++ compiler. 29 | CXXFLAGS += -g 30 | 31 | all : sample1_unittest 32 | 33 | check : all 34 | ./sample1_unittest 35 | 36 | clean : 37 | rm -rf $(FUSED_GTEST_DIR) sample1_unittest *.o 38 | 39 | $(FUSED_GTEST_H) : 40 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR) 41 | 42 | $(FUSED_GTEST_ALL_CC) : 43 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR) 44 | 45 | gtest-all.o : $(FUSED_GTEST_H) $(FUSED_GTEST_ALL_CC) 46 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(FUSED_GTEST_DIR)/gtest/gtest-all.cc 47 | 48 | gtest_main.o : $(FUSED_GTEST_H) $(GTEST_MAIN_CC) 49 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_MAIN_CC) 50 | 51 | sample1.o : $(SAMPLE_DIR)/sample1.cc $(SAMPLE_DIR)/sample1.h 52 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1.cc 53 | 54 | sample1_unittest.o : $(SAMPLE_DIR)/sample1_unittest.cc \ 55 | $(SAMPLE_DIR)/sample1.h $(FUSED_GTEST_H) 56 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1_unittest.cc 57 | 58 | sample1_unittest : sample1.o sample1_unittest.o gtest-all.o gtest_main.o 59 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@ 60 | -------------------------------------------------------------------------------- /googletest/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 | // Author: mheule@google.com (Markus Heule) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // Sometimes it's desirable to build Google Test by compiling a single file. 35 | // This file serves this purpose. 36 | 37 | // This line ensures that gtest.h can be compiled on its own, even 38 | // when it's fused. 39 | #include "gtest/gtest.h" 40 | 41 | // The following lines pull in the real gtest *.cc files. 42 | #include "src/gtest.cc" 43 | #include "src/gtest-death-test.cc" 44 | #include "src/gtest-filepath.cc" 45 | #include "src/gtest-port.cc" 46 | #include "src/gtest-printers.cc" 47 | #include "src/gtest-test-part.cc" 48 | #include "src/gtest-typed-test.cc" 49 | -------------------------------------------------------------------------------- /googletest/googletest/src/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | 31 | #include 32 | #include "gtest/gtest.h" 33 | 34 | GTEST_API_ int main(int argc, char **argv) { 35 | printf("Running main() from gtest_main.cc\n"); 36 | testing::InitGoogleTest(&argc, argv); 37 | return RUN_ALL_TESTS(); 38 | } 39 | -------------------------------------------------------------------------------- /googletest/googletest/test/gtest-param-test_test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Authors: vladl@google.com (Vlad Losev) 31 | // 32 | // The Google C++ Testing Framework (Google Test) 33 | // 34 | // This header file provides classes and functions used internally 35 | // for testing Google Test itself. 36 | 37 | #ifndef GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 38 | #define GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 39 | 40 | #include "gtest/gtest.h" 41 | 42 | // Test fixture for testing definition and instantiation of a test 43 | // in separate translation units. 44 | class ExternalInstantiationTest : public ::testing::TestWithParam { 45 | }; 46 | 47 | // Test fixture for testing instantiation of a test in multiple 48 | // translation units. 49 | class InstantiationInMultipleTranslaionUnitsTest 50 | : public ::testing::TestWithParam { 51 | }; 52 | 53 | #endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 54 | -------------------------------------------------------------------------------- /googletest/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 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include 33 | 34 | #include "gtest-typed-test_test.h" 35 | #include "gtest/gtest.h" 36 | 37 | #if GTEST_HAS_TYPED_TEST_P 38 | 39 | // Tests that the same type-parameterized test case can be 40 | // instantiated in different translation units linked together. 41 | // (ContainerTest is also instantiated in gtest-typed-test_test.cc.) 42 | INSTANTIATE_TYPED_TEST_CASE_P(Vector, ContainerTest, 43 | testing::Types >); 44 | 45 | #endif // GTEST_HAS_TYPED_TEST_P 46 | -------------------------------------------------------------------------------- /googletest/googletest/test/gtest-typed-test_test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #ifndef GTEST_TEST_GTEST_TYPED_TEST_TEST_H_ 33 | #define GTEST_TEST_GTEST_TYPED_TEST_TEST_H_ 34 | 35 | #include "gtest/gtest.h" 36 | 37 | #if GTEST_HAS_TYPED_TEST_P 38 | 39 | using testing::Test; 40 | 41 | // For testing that the same type-parameterized test case can be 42 | // instantiated in different translation units linked together. 43 | // ContainerTest will be instantiated in both gtest-typed-test_test.cc 44 | // and gtest-typed-test2_test.cc. 45 | 46 | template 47 | class ContainerTest : public Test { 48 | }; 49 | 50 | TYPED_TEST_CASE_P(ContainerTest); 51 | 52 | TYPED_TEST_P(ContainerTest, CanBeDefaultConstructed) { 53 | TypeParam container; 54 | } 55 | 56 | TYPED_TEST_P(ContainerTest, InitialSizeIsZero) { 57 | TypeParam container; 58 | EXPECT_EQ(0U, container.size()); 59 | } 60 | 61 | REGISTER_TYPED_TEST_CASE_P(ContainerTest, 62 | CanBeDefaultConstructed, InitialSizeIsZero); 63 | 64 | #endif // GTEST_HAS_TYPED_TEST_P 65 | 66 | #endif // GTEST_TEST_GTEST_TYPED_TEST_TEST_H_ 67 | -------------------------------------------------------------------------------- /googletest/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 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Tests for Google C++ Testing Framework (Google Test) 33 | // 34 | // Sometimes it's desirable to build most of Google Test's own tests 35 | // by compiling a single file. This file serves this purpose. 36 | #include "gtest-filepath_test.cc" 37 | #include "gtest-linked_ptr_test.cc" 38 | #include "gtest-message_test.cc" 39 | #include "gtest-options_test.cc" 40 | #include "gtest-port_test.cc" 41 | #include "gtest_pred_impl_unittest.cc" 42 | #include "gtest_prod_test.cc" 43 | #include "gtest-test-part_test.cc" 44 | #include "gtest-typed-test_test.cc" 45 | #include "gtest-typed-test2_test.cc" 46 | #include "gtest_unittest.cc" 47 | #include "production.cc" 48 | -------------------------------------------------------------------------------- /googletest/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 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | // This program is meant to be run by gtest_help_test.py. Do not run 33 | // it directly. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | // When a help flag is specified, this program should skip the tests 38 | // and exit with 0; otherwise the following test will be executed, 39 | // causing this program to exit with a non-zero code. 40 | TEST(HelpFlagTest, ShouldNotBeRun) { 41 | ASSERT_TRUE(false) << "Tests shouldn't be run when --help is specified."; 42 | } 43 | 44 | #if GTEST_HAS_DEATH_TEST 45 | TEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {} 46 | #endif 47 | -------------------------------------------------------------------------------- /googletest/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 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | 34 | // Tests that we don't have to define main() when we link to 35 | // gtest_main instead of gtest. 36 | 37 | namespace { 38 | 39 | TEST(GTestMainTest, ShouldSucceed) { 40 | } 41 | 42 | } // namespace 43 | 44 | // We are using the main() function defined in gtest_main.cc, so we 45 | // don't define it here. 46 | -------------------------------------------------------------------------------- /googletest/googletest/test/gtest_no_test_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Tests that a Google Test program that has no test defined can run 31 | // successfully. 32 | // 33 | // Author: wan@google.com (Zhanyong Wan) 34 | 35 | #include "gtest/gtest.h" 36 | 37 | int main(int argc, char **argv) { 38 | testing::InitGoogleTest(&argc, argv); 39 | 40 | // An ad-hoc assertion outside of all tests. 41 | // 42 | // This serves three purposes: 43 | // 44 | // 1. It verifies that an ad-hoc assertion can be executed even if 45 | // no test is defined. 46 | // 2. It verifies that a failed ad-hoc assertion causes the test 47 | // program to fail. 48 | // 3. We had a bug where the XML output won't be generated if an 49 | // assertion is executed before RUN_ALL_TESTS() is called, even 50 | // though --gtest_output=xml is specified. This makes sure the 51 | // bug is fixed and doesn't regress. 52 | EXPECT_EQ(1, 2); 53 | 54 | // The above EXPECT_EQ() should cause RUN_ALL_TESTS() to return non-zero. 55 | return RUN_ALL_TESTS() ? 0 : 1; 56 | } 57 | -------------------------------------------------------------------------------- /googletest/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 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Unit test for gtest/gtest_prod.h. 33 | 34 | #include "production.h" 35 | #include "gtest/gtest.h" 36 | 37 | // Tests that private members can be accessed from a TEST declared as 38 | // a friend of the class. 39 | TEST(PrivateCodeTest, CanAccessPrivateMembers) { 40 | PrivateCode a; 41 | EXPECT_EQ(0, a.x_); 42 | 43 | a.set_x(1); 44 | EXPECT_EQ(1, a.x_); 45 | } 46 | 47 | typedef testing::Test PrivateCodeFixtureTest; 48 | 49 | // Tests that private members can be accessed from a TEST_F declared 50 | // as a friend of the class. 51 | TEST_F(PrivateCodeFixtureTest, CanAccessPrivateMembers) { 52 | PrivateCode a; 53 | EXPECT_EQ(0, a.x_); 54 | 55 | a.set_x(2); 56 | EXPECT_EQ(2, a.x_); 57 | } 58 | -------------------------------------------------------------------------------- /googletest/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 | // Author: mheule@google.com (Markus Heule) 31 | // 32 | // This test verifies that it's possible to use Google Test by including 33 | // the gtest.h header file alone. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | namespace { 38 | 39 | void Subroutine() { 40 | EXPECT_EQ(42, 42); 41 | } 42 | 43 | TEST(NoFatalFailureTest, ExpectNoFatalFailure) { 44 | EXPECT_NO_FATAL_FAILURE(;); 45 | EXPECT_NO_FATAL_FAILURE(SUCCEED()); 46 | EXPECT_NO_FATAL_FAILURE(Subroutine()); 47 | EXPECT_NO_FATAL_FAILURE({ SUCCEED(); }); 48 | } 49 | 50 | TEST(NoFatalFailureTest, AssertNoFatalFailure) { 51 | ASSERT_NO_FATAL_FAILURE(;); 52 | ASSERT_NO_FATAL_FAILURE(SUCCEED()); 53 | ASSERT_NO_FATAL_FAILURE(Subroutine()); 54 | ASSERT_NO_FATAL_FAILURE({ SUCCEED(); }); 55 | } 56 | 57 | } // namespace 58 | -------------------------------------------------------------------------------- /googletest/googletest/test/gtest_uninitialized_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | 34 | TEST(DummyTest, Dummy) { 35 | // This test doesn't verify anything. We just need it to create a 36 | // realistic stage for testing the behavior of Google Test when 37 | // RUN_ALL_TESTS() is called without 38 | // testing::InitGoogleTest() being called first. 39 | } 40 | 41 | int main() { 42 | return RUN_ALL_TESTS(); 43 | } 44 | -------------------------------------------------------------------------------- /googletest/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 | // 31 | // gtest_xml_outfile1_test_ writes some xml via TestProperty used by 32 | // gtest_xml_outfiles_test.py 33 | 34 | #include "gtest/gtest.h" 35 | 36 | class PropertyOne : public testing::Test { 37 | protected: 38 | virtual void SetUp() { 39 | RecordProperty("SetUpProp", 1); 40 | } 41 | virtual void TearDown() { 42 | RecordProperty("TearDownProp", 1); 43 | } 44 | }; 45 | 46 | TEST_F(PropertyOne, TestSomeProperties) { 47 | RecordProperty("TestSomeProperty", 1); 48 | } 49 | -------------------------------------------------------------------------------- /googletest/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 | // 31 | // gtest_xml_outfile2_test_ writes some xml via TestProperty used by 32 | // gtest_xml_outfiles_test.py 33 | 34 | #include "gtest/gtest.h" 35 | 36 | class PropertyTwo : public testing::Test { 37 | protected: 38 | virtual void SetUp() { 39 | RecordProperty("SetUpProp", 2); 40 | } 41 | virtual void TearDown() { 42 | RecordProperty("TearDownProp", 2); 43 | } 44 | }; 45 | 46 | TEST_F(PropertyTwo, TestSomeProperties) { 47 | RecordProperty("TestSomeProperty", 2); 48 | } 49 | -------------------------------------------------------------------------------- /googletest/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 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // This is part of the unit test for gtest_prod.h. 33 | 34 | #include "production.h" 35 | 36 | PrivateCode::PrivateCode() : x_(0) {} 37 | -------------------------------------------------------------------------------- /googletest/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 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // This is part of the unit test for gtest_prod.h. 33 | 34 | #ifndef GTEST_TEST_PRODUCTION_H_ 35 | #define GTEST_TEST_PRODUCTION_H_ 36 | 37 | #include "gtest/gtest_prod.h" 38 | 39 | class PrivateCode { 40 | public: 41 | // Declares a friend test that does not use a fixture. 42 | FRIEND_TEST(PrivateCodeTest, CanAccessPrivateMembers); 43 | 44 | // Declares a friend test that uses a fixture. 45 | FRIEND_TEST(PrivateCodeFixtureTest, CanAccessPrivateMembers); 46 | 47 | PrivateCode(); 48 | 49 | int x() const { return x_; } 50 | private: 51 | void set_x(int an_x) { x_ = an_x; } 52 | int x_; 53 | }; 54 | 55 | #endif // GTEST_TEST_PRODUCTION_H_ 56 | -------------------------------------------------------------------------------- /googletest/googletest/xcode/Config/DebugProject.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // DebugProject.xcconfig 3 | // 4 | // These are Debug Configuration project settings for the gtest framework and 5 | // examples. It is set in the "Based On:" dropdown in the "Project" info 6 | // dialog. 7 | // This file is based on the Xcode Configuration files in: 8 | // http://code.google.com/p/google-toolbox-for-mac/ 9 | // 10 | 11 | #include "General.xcconfig" 12 | 13 | // No optimization 14 | GCC_OPTIMIZATION_LEVEL = 0 15 | 16 | // Deployment postprocessing is what triggers Xcode to strip, turn it off 17 | DEPLOYMENT_POSTPROCESSING = NO 18 | 19 | // Dead code stripping off 20 | DEAD_CODE_STRIPPING = NO 21 | 22 | // Debug symbols should be on obviously 23 | GCC_GENERATE_DEBUGGING_SYMBOLS = YES 24 | 25 | // Define the DEBUG macro in all debug builds 26 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DDEBUG=1 27 | 28 | // These are turned off to avoid STL incompatibilities with client code 29 | // // Turns on special C++ STL checks to "encourage" good STL use 30 | // GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) _GLIBCXX_DEBUG_PEDANTIC _GLIBCXX_DEBUG _GLIBCPP_CONCEPT_CHECKS 31 | -------------------------------------------------------------------------------- /googletest/googletest/xcode/Config/FrameworkTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // FrameworkTarget.xcconfig 3 | // 4 | // These are Framework target settings for the gtest framework and examples. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Dynamic libs need to be position independent 11 | GCC_DYNAMIC_NO_PIC = NO 12 | 13 | // Dynamic libs should not have their external symbols stripped. 14 | STRIP_STYLE = non-global 15 | 16 | // Let the user install by specifying the $DSTROOT with xcodebuild 17 | SKIP_INSTALL = NO 18 | -------------------------------------------------------------------------------- /googletest/googletest/xcode/Config/General.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // General.xcconfig 3 | // 4 | // These are General configuration settings for the gtest framework and 5 | // examples. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Build for PPC and Intel, 32- and 64-bit 11 | ARCHS = i386 x86_64 ppc ppc64 12 | 13 | // Zerolink prevents link warnings so turn it off 14 | ZERO_LINK = NO 15 | 16 | // Prebinding considered unhelpful in 10.3 and later 17 | PREBINDING = NO 18 | 19 | // Strictest warning policy 20 | WARNING_CFLAGS = -Wall -Werror -Wendif-labels -Wnewline-eof -Wno-sign-compare -Wshadow 21 | 22 | // Work around Xcode bugs by using external strip. See: 23 | // http://lists.apple.com/archives/Xcode-users/2006/Feb/msg00050.html 24 | SEPARATE_STRIP = YES 25 | 26 | // Force C99 dialect 27 | GCC_C_LANGUAGE_STANDARD = c99 28 | 29 | // not sure why apple defaults this on, but it's pretty risky 30 | ALWAYS_SEARCH_USER_PATHS = NO 31 | 32 | // Turn on position dependent code for most cases (overridden where appropriate) 33 | GCC_DYNAMIC_NO_PIC = YES 34 | 35 | // Default SDK and minimum OS version is 10.4 36 | SDKROOT = $(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk 37 | MACOSX_DEPLOYMENT_TARGET = 10.4 38 | GCC_VERSION = 4.0 39 | 40 | // VERSIONING BUILD SETTINGS (used in Info.plist) 41 | GTEST_VERSIONINFO_ABOUT = © 2008 Google Inc. 42 | -------------------------------------------------------------------------------- /googletest/googletest/xcode/Config/ReleaseProject.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // ReleaseProject.xcconfig 3 | // 4 | // These are Release Configuration project settings for the gtest framework 5 | // and examples. It is set in the "Based On:" dropdown in the "Project" info 6 | // dialog. 7 | // This file is based on the Xcode Configuration files in: 8 | // http://code.google.com/p/google-toolbox-for-mac/ 9 | // 10 | 11 | #include "General.xcconfig" 12 | 13 | // subconfig/Release.xcconfig 14 | 15 | // Optimize for space and size (Apple recommendation) 16 | GCC_OPTIMIZATION_LEVEL = s 17 | 18 | // Deploment postprocessing is what triggers Xcode to strip 19 | DEPLOYMENT_POSTPROCESSING = YES 20 | 21 | // No symbols 22 | GCC_GENERATE_DEBUGGING_SYMBOLS = NO 23 | 24 | // Dead code strip does not affect ObjC code but can help for C 25 | DEAD_CODE_STRIPPING = YES 26 | 27 | // NDEBUG is used by things like assert.h, so define it for general compat. 28 | // ASSERT going away in release tends to create unused vars. 29 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DNDEBUG=1 -Wno-unused-variable 30 | 31 | // When we strip we want to strip all symbols in release, but save externals. 32 | STRIP_STYLE = all 33 | -------------------------------------------------------------------------------- /googletest/googletest/xcode/Config/StaticLibraryTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // StaticLibraryTarget.xcconfig 3 | // 4 | // These are static library target settings for libgtest.a. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Static libs can be included in bundles so make them position independent 11 | GCC_DYNAMIC_NO_PIC = NO 12 | 13 | // Static libs should not have their internal globals or external symbols 14 | // stripped. 15 | STRIP_STYLE = debugging 16 | 17 | // Let the user install by specifying the $DSTROOT with xcodebuild 18 | SKIP_INSTALL = NO 19 | -------------------------------------------------------------------------------- /googletest/googletest/xcode/Config/TestTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // TestTarget.xcconfig 3 | // 4 | // These are Test target settings for the gtest framework and examples. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | 7 | PRODUCT_NAME = $(TARGET_NAME) 8 | HEADER_SEARCH_PATHS = ../include 9 | -------------------------------------------------------------------------------- /googletest/googletest/xcode/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.google.${PRODUCT_NAME} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | GTEST_VERSIONINFO_LONG 21 | CFBundleShortVersionString 22 | GTEST_VERSIONINFO_SHORT 23 | CFBundleGetInfoString 24 | ${PRODUCT_NAME} GTEST_VERSIONINFO_LONG, ${GTEST_VERSIONINFO_ABOUT} 25 | NSHumanReadableCopyright 26 | ${GTEST_VERSIONINFO_ABOUT} 27 | CSResourcesFileMapped 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /googletest/googletest/xcode/Samples/FrameworkSample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.google.gtest.${PRODUCT_NAME:identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | CSResourcesFileMapped 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /googletest/googletest/xcode/Samples/FrameworkSample/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2008, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Executes the samples and tests for the Google Test Framework. 33 | 34 | # Help the dynamic linker find the path to the libraries. 35 | export DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR 36 | export DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR 37 | 38 | # Create some executables. 39 | test_executables=$@ 40 | 41 | # Now execute each one in turn keeping track of how many succeeded and failed. 42 | succeeded=0 43 | failed=0 44 | failed_list=() 45 | for test in ${test_executables[*]}; do 46 | "$test" 47 | result=$? 48 | if [ $result -eq 0 ]; then 49 | succeeded=$(( $succeeded + 1 )) 50 | else 51 | failed=$(( failed + 1 )) 52 | failed_list="$failed_list $test" 53 | fi 54 | done 55 | 56 | # Report the successes and failures to the console. 57 | echo "Tests complete with $succeeded successes and $failed failures." 58 | if [ $failed -ne 0 ]; then 59 | echo "The following tests failed:" 60 | echo $failed_list 61 | fi 62 | exit $failed 63 | -------------------------------------------------------------------------------- /googletest/googletest/xcode/Samples/FrameworkSample/widget.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: preston.a.jackson@gmail.com (Preston Jackson) 31 | // 32 | // Google Test - FrameworkSample 33 | // widget.cc 34 | // 35 | 36 | // Widget is a very simple class used for demonstrating the use of gtest 37 | 38 | #include "widget.h" 39 | 40 | Widget::Widget(int number, const std::string& name) 41 | : number_(number), 42 | name_(name) {} 43 | 44 | Widget::~Widget() {} 45 | 46 | float Widget::GetFloatValue() const { 47 | return number_; 48 | } 49 | 50 | int Widget::GetIntValue() const { 51 | return static_cast(number_); 52 | } 53 | 54 | std::string Widget::GetStringValue() const { 55 | return name_; 56 | } 57 | 58 | void Widget::GetCharPtrValue(char* buffer, size_t max_size) const { 59 | // Copy the char* representation of name_ into buffer, up to max_size. 60 | strncpy(buffer, name_.c_str(), max_size-1); 61 | buffer[max_size-1] = '\0'; 62 | return; 63 | } 64 | -------------------------------------------------------------------------------- /googletest/googletest/xcode/Samples/FrameworkSample/widget.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: preston.a.jackson@gmail.com (Preston Jackson) 31 | // 32 | // Google Test - FrameworkSample 33 | // widget.h 34 | // 35 | 36 | // Widget is a very simple class used for demonstrating the use of gtest. It 37 | // simply stores two values a string and an integer, which are returned via 38 | // public accessors in multiple forms. 39 | 40 | #import 41 | 42 | class Widget { 43 | public: 44 | Widget(int number, const std::string& name); 45 | ~Widget(); 46 | 47 | // Public accessors to number data 48 | float GetFloatValue() const; 49 | int GetIntValue() const; 50 | 51 | // Public accessors to the string data 52 | std::string GetStringValue() const; 53 | void GetCharPtrValue(char* buffer, size_t max_size) const; 54 | 55 | private: 56 | // Data members 57 | float number_; 58 | std::string name_; 59 | }; 60 | -------------------------------------------------------------------------------- /googletest/travis.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | set -evx 3 | 4 | # if possible, ask for the precise number of processors, 5 | # otherwise take 2 processors as reasonable default; see 6 | # https://docs.travis-ci.com/user/speeding-up-the-build/#Makefile-optimization 7 | if [ -x /usr/bin/getconf ]; then 8 | NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN) 9 | else 10 | NPROCESSORS=2 11 | fi 12 | # as of 2017-09-04 Travis CI reports 32 processors, but GCC build 13 | # crashes if parallelized too much (maybe memory consumption problem), 14 | # so limit to 4 processors for the time being. 15 | if [ $NPROCESSORS -gt 4 ] ; then 16 | echo "$0:Note: Limiting processors to use by make from $NPROCESSORS to 4." 17 | NPROCESSORS=4 18 | fi 19 | # Tell make to use the processors. No preceding '-' required. 20 | MAKEFLAGS="j${NPROCESSORS}" 21 | export MAKEFLAGS 22 | 23 | env | sort 24 | 25 | mkdir build || true 26 | cd build 27 | cmake -Dgtest_build_samples=ON \ 28 | -Dgtest_build_tests=ON \ 29 | -Dgmock_build_tests=ON \ 30 | -DCMAKE_CXX_FLAGS=$CXX_FLAGS \ 31 | -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ 32 | .. 33 | make 34 | CTEST_OUTPUT_ON_FAILURE=1 make test 35 | -------------------------------------------------------------------------------- /include/v8toolkit/any.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include "v8helpers.h" 8 | 9 | namespace v8toolkit { 10 | 11 | /** 12 | * Class used to store an object of an arbitrary type and allow runtime querying of the type contained 13 | * via dyanmic_cast of the AnyBase object to an AnyPtr object. 14 | */ 15 | struct AnyBase { 16 | virtual ~AnyBase(); 17 | 18 | std::string type_name; 19 | 20 | AnyBase(const std::string type_name) 21 | : type_name(std::move(type_name)) {} 22 | 23 | template 24 | T const * get() const; 25 | 26 | template 27 | T * get(); 28 | 29 | }; 30 | 31 | 32 | /** 33 | * Holds a pointer to an object that is either a T or derived from T. If an AnyBase object can by 34 | * dynamic_cast'd to this type, then it is known that the pointer is compatible with type T. 35 | */ 36 | template 37 | struct AnyPtr : public AnyBase { 38 | private: 39 | static_assert(!std::is_pointer::value && !std::is_reference::value, "AnyPtr must be specified with a non-pointer/reference type"); 40 | 41 | T * data; 42 | 43 | public: 44 | AnyPtr(T * data) : 45 | AnyBase(xl::demangle()), 46 | data(data) {} 47 | 48 | 49 | /** 50 | * Returns the stored pointer to the object of type T 51 | * @return 52 | */ 53 | T * get() const { 54 | return this->data; 55 | } 56 | 57 | /** 58 | * Returns the object of type T if it is compatible with T or nullptr otherwise 59 | * @param any_base AnyBase object to test to see if it contains an object of type T 60 | * @return Type T object if contained object is compatible or nullptr if not 61 | */ 62 | static T * check(AnyBase * any_base) { 63 | return dynamic_cast(any_base); 64 | } 65 | }; 66 | 67 | 68 | template 69 | T const * AnyBase::get() const { 70 | if (auto any = dynamic_cast const *>(this)) { 71 | return any->get(); 72 | } 73 | } 74 | 75 | template 76 | T * AnyBase::get() { 77 | if (auto any = dynamic_cast *>(this)) { 78 | return any->get(); 79 | } 80 | } 81 | 82 | 83 | 84 | } // end namespace v8toolkit -------------------------------------------------------------------------------- /include/v8toolkit/cast_to_js.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | #include 4 | 5 | #include "type_traits.h" 6 | 7 | namespace v8toolkit { 8 | 9 | struct CastToJSDefaultBehavior; 10 | 11 | /** 12 | * Casts from a native type to a boxed Javascript type 13 | */ 14 | template 15 | struct CastToJS { 16 | static_assert(always_false_v, "Fallback CastToJS template isn't allowed - make sure header with specialization desired is included at this point"); 17 | }; 18 | 19 | 20 | /** 21 | * Subclass this type to specialize specific calls for CastToJS differently than the default implementations. 22 | * The call chain of CastToJS will prefer specializations matching the behavior but fall back to CastToJS 23 | * impleementations where no behavior-specific specialization is present 24 | * @tparam Derived CRTP type deriving from this 25 | */ 26 | template class CastTemplate> 27 | struct CastToJSBehaviorBase{ 28 | template 29 | v8::Local operator()(T && t) { 30 | return CastTemplate()(v8::Isolate::GetCurrent(), std::forward(t)); 31 | } 32 | }; 33 | 34 | 35 | /** 36 | * Default behavior, always call CastToJS for the entire call chain 37 | */ 38 | struct CastToJSDefaultBehavior : CastToJSBehaviorBase {}; 39 | 40 | 41 | #define CAST_TO_JS(TYPE, FUNCTION_BODY) \ 42 | template \ 43 | struct v8toolkit::CastToJS< \ 44 | T, Behavior, std::enable_if_t, TYPE>>> { \ 45 | v8::Local operator()(v8::Isolate *isolate, \ 46 | TYPE const &value) const FUNCTION_BODY \ 47 | }; 48 | 49 | } // end namespace v8toolkit 50 | -------------------------------------------------------------------------------- /include/v8toolkit/casts.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "cast_to_js.h" 4 | #include "cast_to_native.h" 5 | -------------------------------------------------------------------------------- /include/v8toolkit/casts_impl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "casts.h" 4 | #include "v8toolkit.h" 5 | 6 | #include "cast_to_js_impl.h" 7 | #include "cast_to_native_impl.h" 8 | 9 | #ifdef V8TOOLKIT_ENABLE_EASTL_SUPPORT 10 | #include "casts_eastl.h" 11 | #endif 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /include/v8toolkit/log.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | #include 6 | 7 | namespace v8toolkit { 8 | 9 | struct LoggingSubjects { 10 | inline static std::string subject_names[] = {"Object Management", 11 | "Runtime Exception", 12 | "Compilation Exception", 13 | "wrapped function call", 14 | "wrapped data member access", 15 | "debug websocket", 16 | "V8 Toolkit", 17 | "default" 18 | 19 | }; 20 | 21 | enum class Subjects { 22 | V8_OBJECT_MANAGEMENT, // when core V8 objects are created or town down 23 | RUNTIME_EXCEPTION, 24 | COMPILATION_EXCEPTION, 25 | WRAPPED_FUNCTION_CALL, 26 | WRAPPED_DATA_MEMBER_ACCESS, 27 | DebugWebSocket, 28 | V8TOOLKIT, 29 | Default, 30 | LOG_LAST_SUBJECT 31 | }; 32 | }; 33 | 34 | 35 | using LogT = xl::log::Log; 36 | inline LogT log; 37 | 38 | } // end namespace v8toolkit -------------------------------------------------------------------------------- /include/v8toolkit/wrapped_class_base.h: -------------------------------------------------------------------------------- 1 | #ifndef V8TOOLKIT_WRAPPED_CLASS_BASE_H 2 | #define V8TOOLKIT_WRAPPED_CLASS_BASE_H 3 | 4 | namespace v8toolkit { 5 | /** 6 | * Inheriting from this tells v8toolkit the derived type is to be wrapped for use in JavaScript 7 | * Alternatives if altering inheritance isn't possible (such as a type from a third-party library): 8 | * (preferred): specialize v8toolkit::is_wrapped_type type trait for type to inherit from std::true_type 9 | * (last resort): #define V8TOOLKIT_V8CLASSWRAPPER_FULL_TEMPLATE_SFINAE_PREFIX with appropriate SFINAE 10 | */ 11 | class WrappedClassBase {}; 12 | 13 | } 14 | 15 | #endif -------------------------------------------------------------------------------- /samples/bidirectional.js: -------------------------------------------------------------------------------- 1 | var cpp_method_result = "C++ string"; 2 | var js_method_result = "JS string"; 3 | 4 | let thing2_i_val = 24; 5 | 6 | 7 | let thing_factory_4 = create_thing_factory( 8 | thing_factory_3, 9 | { 10 | get_string: function(){return js_method_result;}, 11 | thing_factory_4_function: function(){}, 12 | 13 | }, // This is the actual prototype object shared by all new instances of the type 14 | function(str){ // This function is called on each new object, creating non-shared, per-object properties 15 | this.per_object_property = str; 16 | }, 4); 17 | 18 | 19 | let thing_factory_5 = create_thing_factory( 20 | thing_factory_4, 21 | { 22 | thing_factory_5_function: function(){}, 23 | }, 24 | function(str){ 25 | this.per_object_property = str; 26 | }, 5); 27 | 28 | 29 | 30 | var thing = new Thing(42, "test"); 31 | printobj(thing); 32 | assert("thing.get_string() === cpp_method_result"); 33 | assert("thing.thing_only_function() == \"thing only function\""); 34 | 35 | 36 | let count = 0; 37 | let thing41 = thing_factory_4.create(++count); 38 | 39 | assert("thing41.get_string() == js_method_result"); 40 | assert("thing41.per_object_property == 1"); 41 | 42 | println("Creating thing4 - should only be one Thing created before 'thing42'"); 43 | let thing42 = thing_factory_4.create(++count); 44 | println("thing42"); 45 | printobjall(thing42); 46 | assert("thing42.i == 4"); 47 | assert("thing42.per_object_property == 2"); 48 | 49 | thing41.per_object_property++; 50 | assert("thing41.per_object_property == 2"); 51 | assert("thing42.per_object_property == 2"); 52 | 53 | 54 | let thing51 = thing_factory_5.create(++count); 55 | assert("thing51.i == 5"); 56 | 57 | 58 | 59 | // 60 | // var subclassed_thing = Thing.subclass({}, base_thing); 61 | // assert("subclassed_thing.get_string() === cpp_method_result"); 62 | // 63 | // var subclassed_thing2 = subclass_thing({get_string: function(){return js_method_result}}); 64 | // assert("subclassed_thing2.get_string() === js_method_result"); 65 | 66 | // 67 | // var weird = Object.create(Object.create(subclassed_thing)); 68 | // assert("weird.get_string() === cpp_method_result"); 69 | // 70 | // weird.get_string = function(){return js_method_result}; 71 | // var weirder = Object.create(Object.create(weird)); 72 | // assert("weirder.get_string() === js_method_result"); 73 | 74 | 75 | -------------------------------------------------------------------------------- /samples/bidirectional_sample_make_script: -------------------------------------------------------------------------------- 1 | clang++ -g -fsanitize=undefined -fno-sanitize=vptr -std=c++17 -stdlib=libc++ bidirectional_sample.cpp -I../include/v8toolkit/ -I /Users/xaxxon/v8/include/ -DXL_USE_PCRE -DXL_USE_LIB_FMT -I ../class_parser/ -L/Users/xaxxon/v8libs/x64.debug.shared -L /Users/xaxxon/Downloads/clang+llvm-5.0.0/lib -lpcre -lc++experimental -lfmt -lv8toolkit -lv8 -lv8_libplatform -lv8_libbase -licui18n -licuuc -lboost_system 2 | -------------------------------------------------------------------------------- /samples/code.js: -------------------------------------------------------------------------------- 1 | 2 | // var p = new Point(); 3 | // println(p.x); 4 | // println(p.y); 5 | // println(p.stringthing()); 6 | // p.thing(4, "four"); 7 | 8 | // run garbage collector tests if javascript-exposed GC is enabled 9 | assert (typeof gc == 'function'); 10 | gc(); 11 | var gc_test_1 = new Point(); 12 | assert(point_instance_count() === 1); 13 | 14 | gc_test_1 = undefined; 15 | gc(); 16 | assert(point_instance_count() === 0); 17 | 18 | 19 | var line = new Line(); 20 | printobj(line.get_point()); 21 | let f = function(){} 22 | println("Pringing traditional function:"); 23 | printobj(f); 24 | line.get_point().get_foo(); 25 | assert(line.get_point().get_foo().i === 42); 26 | 27 | println(); 28 | 29 | 30 | println("Testing printobj for object that is not a c++ wrapped object"); 31 | printobj({}); 32 | println(); 33 | 34 | // getting two objects by reference should have the same underlying c++ objects 35 | // because they return an object by reference 36 | 37 | // These two objects should have the same backing c++ object 38 | var p1 = line.get_point(); 39 | var p2 = line.get_point(); 40 | assert(p1 === p2); 41 | 42 | 43 | // getting two objects by rvalue should have different underlying c++ objects 44 | // because they return on object as an rvalue that must have a copy made 45 | 46 | // These two objects should have different backing c++ object 47 | var l1 = line.get_point().get_foo(); 48 | var l2 = line.get_point().get_foo(); 49 | assert(l1 !== l2); 50 | 51 | // Comparing objects obtained from data members of class types should have the same c++ object 52 | var line_point_1 = line.p; 53 | var line_point_2 = line.p; 54 | assert(line_point_1 === line_point_2); 55 | 56 | 57 | var override_method_point = new Point(); 58 | printobj(override_method_point); 59 | println("About to run the original thing()"); 60 | override_method_point.thing(1, 'a'); 61 | override_method_point.thing = function(){println("This is not the original thing method!!")}; 62 | // printobj(override_method_point); 63 | override_method_point.thing(1, 'b'); 64 | 65 | 66 | gc(); 67 | "yay" -------------------------------------------------------------------------------- /samples/compilation_timing_script: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | export BUILD_COMMAND="time clang++ -g0 -DXL_USE_PCRE -DXL_USE_LIB_FMT -I${V8_INCLUDES} compilation_timing_sample.cpp -I../include -std=c++1z -c" 5 | 6 | 7 | echo ${BUILD_COMMAND} -DV8HELPERS 8 | ${BUILD_COMMAND} -DV8HELPERS 9 | echo 10 | echo ${BUILD_COMMAND} -DV8TOOLKIT 11 | ${BUILD_COMMAND} -DV8TOOLKIT 12 | echo 13 | echo ${BUILD_COMMAND} -DV8_CLASS_WRAPPER 14 | ${BUILD_COMMAND} -DV8_CLASS_WRAPPER 15 | echo 16 | echo ${BUILD_COMMAND} -DJAVASCRIPT 17 | ${BUILD_COMMAND} -DJAVASCRIPT 18 | echo 19 | echo ${BUILD_COMMAND} -DSTD_FUNCTIONS 20 | ${BUILD_COMMAND} -DSTD_FUNCTIONS 21 | echo 22 | echo ${BUILD_COMMAND} -DCREATE_CONTEXT 23 | ${BUILD_COMMAND} -DCREATE_CONTEXT 24 | echo 25 | echo ${BUILD_COMMAND} -DWRAP_EMPTY_CLASS 26 | ${BUILD_COMMAND} -DWRAP_EMPTY_CLASS 27 | echo 28 | 29 | 30 | echo ${BUILD_COMMAND} -DWRAP_DATA_MEMBER_CLASS 31 | ${BUILD_COMMAND} -DWRAP_DATA_MEMBER_CLASS 32 | echo 33 | echo ${BUILD_COMMAND} -DWRAP_5_INT_DATA_MEMBERS_CLASS 34 | ${BUILD_COMMAND} -DWRAP_5_INT_DATA_MEMBERS_CLASS 35 | echo 36 | echo ${BUILD_COMMAND} -DWRAP_5_DIFFERENT_DATA_MEMBERS_CLASS 37 | ${BUILD_COMMAND} -DWRAP_5_DIFFERENT_DATA_MEMBERS_CLASS 38 | echo 39 | 40 | # Same as above but two different classes with identical contents 41 | echo ${BUILD_COMMAND} -DWRAP_5_DIFFERENT_DATA_MEMBERS_2_CLASSES 42 | ${BUILD_COMMAND} -DWRAP_5_DIFFERENT_DATA_MEMBERS_2_CLASSES 43 | echo 44 | 45 | 46 | echo ${BUILD_COMMAND} -DWRAP_VOID_VOID_MEMBER_FUNCTION_CLASS 47 | ${BUILD_COMMAND} -DWRAP_VOID_VOID_MEMBER_FUNCTION_CLASS 48 | echo 49 | 50 | echo ${BUILD_COMMAND} -DWRAP_MEMBER_FUNCTION_5_TIMES_CLASS 51 | ${BUILD_COMMAND} -DWRAP_MEMBER_FUNCTION_5_TIMES_CLASS 52 | echo 53 | 54 | echo ${BUILD_COMMAND} -DWRAP_INT_VOID_MEMBER_FUNCTION_CLASS 55 | ${BUILD_COMMAND} -DWRAP_INT_VOID_MEMBER_FUNCTION_CLASS 56 | echo 57 | 58 | echo ${BUILD_COMMAND} -DWRAP_5_DIFFERENT_MEMBER_FUNCTION_CLASS 59 | ${BUILD_COMMAND} -DWRAP_5_DIFFERENT_MEMBER_FUNCTION_CLASS 60 | echo 61 | 62 | echo ${BUILD_COMMAND} -DWRAP_5_DIFFERENT_MEMBER_FUNCTION_2_CLASSES 63 | ${BUILD_COMMAND} -DWRAP_5_DIFFERENT_MEMBER_FUNCTION_2_CLASSES 64 | echo 65 | 66 | echo ${BUILD_COMMAND} -DWRAP_10_DIFFERENT_MEMBER_FUNCTION_CLASS 67 | ${BUILD_COMMAND} -DWRAP_10_DIFFERENT_MEMBER_FUNCTION_CLASS 68 | echo 69 | 70 | echo ${BUILD_COMMAND} -DWRAP_COMPLEX_MEMBER_FUNCTION_CLASS 71 | ${BUILD_COMMAND} -DWRAP_COMPLEX_MEMBER_FUNCTION_CLASS 72 | echo 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /samples/debugger_sample.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | 4 | clang++ -std=c++17 debugger_sample.cpp -I ../../v8/include/ -I ../include/v8toolkit/ -I /usr/local/include -DXL_USE_PCRE -DXL_USE_LIB_FMT -lv8toolkit_shared -lboost_system -lpcre -L /Users/xaxxon/v8libs/x64.debug.shared/ -licui18n -licuuc -lv8 -lv8_libbase -lv8_libplatform -g 5 | 6 | */ 7 | 8 | 9 | 10 | #include 11 | 12 | #include "stdlib.h" 13 | #include "debugger.h" 14 | #include "log.h" 15 | 16 | using namespace v8toolkit; 17 | 18 | int main(int argc, char** argv) { 19 | 20 | v8toolkit::Platform::init(argc, argv, argv[1]); 21 | auto isolate = v8toolkit::Platform::create_isolate(); 22 | isolate->add_print(); 23 | auto context = isolate->create_debug_context(9002); 24 | 25 | context->get_channel().wait_for_connection(); 26 | 27 | auto script = context->compile("a = 1;\r\na+=1;", "hard-coded-text-a.js"); 28 | auto script2 = context->compile("b = 2;\r\nb+=2;", "hard-coded-text-b.js"); 29 | const char * debugger_sample_js_filename = "debugger_sample.js"; 30 | auto script_3_source = v8toolkit::get_file_contents(debugger_sample_js_filename) 31 | if (!script_3_source) { 32 | assert(false); 33 | } 34 | auto script3 = context->compile(*script_3_source, debugger_sample_js_filename); 35 | 36 | (*context)([&] { 37 | 38 | context->require_directory("modules"); 39 | 40 | 41 | using namespace v8toolkit::literals; 42 | v8::ScriptOrigin script_origin(v8::String::NewFromUtf8(*isolate, context->get_url("test/path/compile_function_in_context").c_str()), 43 | 0_v8, // line offset 44 | 12_v8, // column offset - stupid having to shift it over for the string length that gets put on it 45 | v8::Local(), // resource_is_shared_cross_origin 46 | 100_v8); 47 | 48 | 49 | v8::ScriptCompiler::Source source("println(\"in code from CompileFunctionInContext\");"_v8, script_origin); 50 | auto maybe_function = v8::ScriptCompiler::CompileFunctionInContext(*context, &source, 0, nullptr, 0, nullptr); 51 | assert(!maybe_function.IsEmpty()); 52 | auto function = maybe_function.ToLocalChecked(); 53 | std::cerr << fmt::format("infinite loop waiting for debugger operations") << std::endl; 54 | while (true) { 55 | (void)function->Call(*context, context->get_context()->Global(), 0, nullptr); 56 | script3->run(); 57 | context->get_channel().poll(); 58 | usleep(1000000); 59 | } 60 | }); 61 | } 62 | -------------------------------------------------------------------------------- /samples/debugger_sample.js: -------------------------------------------------------------------------------- 1 | function c(num){ 2 | println(num); 3 | let c=10; 4 | } 5 | 6 | function b(some_number){ 7 | some_number += 5; 8 | c(some_number); 9 | } 10 | 11 | function a(){ 12 | println("Beginning of a()"); 13 | let some_var = 5; 14 | some_var += 5; 15 | b(some_var); 16 | // println("End of a()"); 17 | 18 | } 19 | 20 | a(); 21 | // println("In debugger_sample.js"); -------------------------------------------------------------------------------- /samples/exception_sample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "javascript.h" 4 | 5 | using namespace v8toolkit; 6 | 7 | // This program verifies exceptions thrown in FunctionTemplates are properly 8 | // passed through V8 and rethrown on the other side 9 | int main(int argc, char ** argv) { 10 | 11 | Platform::init(argc, argv, argv[0]); 12 | auto i = Platform::create_isolate(); 13 | auto c = i->create_context(); 14 | try{ 15 | c->run("doesnotexist.doesnotexist"); 16 | } catch(...){ 17 | printf("caught doesnotexist.doesnotexist exception\n"); 18 | } 19 | try{ 20 | c->run("throw 4;"); 21 | } catch(...){ 22 | printf("caught throw 4 exception\n"); 23 | } 24 | try{ 25 | c->run("throw {a:4, b:3}"); 26 | } catch(...){ 27 | printf("caught throw 4 exception\n"); 28 | } 29 | } -------------------------------------------------------------------------------- /samples/module.js: -------------------------------------------------------------------------------- 1 | module.exports.function = function(){return "module.js function output"}; 2 | module.exports.a = "a"; 3 | module.exports.five = 5; 4 | println("This line of output expected once"); 5 | 6 | function module_function(){ 7 | println("module_function INSIDE MODULE.JS"); 8 | } 9 | -------------------------------------------------------------------------------- /samples/module2.js: -------------------------------------------------------------------------------- 1 | module.exports.function = function(){return "module2.js function output"}; 2 | module.exports.a = "a"; 3 | module.exports.five = 5; 4 | println("This output expected once"); 5 | // module_function(); // this isn't available from module.js since it was defined in the 'pretend' function wrapping 6 | // every module -------------------------------------------------------------------------------- /samples/modules/a.js: -------------------------------------------------------------------------------- 1 | exports.a=function(){return "a";} 2 | -------------------------------------------------------------------------------- /samples/modules/b.json: -------------------------------------------------------------------------------- 1 | {"aa": [1,2,3,{"a":4, "b": 5}, 6,7,8]} 2 | -------------------------------------------------------------------------------- /samples/sample2.js: -------------------------------------------------------------------------------- 1 | dumpdata=function(data){ 2 | if(Array.isArray(data)) { 3 | return sprintf("[ %s ]", data.map(function(e){return dumpdata(e);}).join(", ")); 4 | 5 | } else if (typeof(data)=="object") { 6 | return sprintf("{ %s }", Object.keys(data).map(function(k){ 7 | return sprintf("%s: %s", k, dumpdata(data[k])); 8 | }).join(", ")); 9 | 10 | } else { 11 | return data; 12 | } 13 | } 14 | 15 | println(dumpdata(v)); 16 | println(dumpdata(l)); 17 | println('These may not be in order'); 18 | println(dumpdata(m)); 19 | println(dumpdata(m2)); 20 | println(dumpdata(d)); 21 | println(dumpdata(mm)); 22 | println(dumpdata(a)); 23 | println(dumpdata(composite)); 24 | -------------------------------------------------------------------------------- /samples/toolbox_sample.js: -------------------------------------------------------------------------------- 1 | println("Bar"); 2 | bar(); 3 | println("foo5"); 4 | foo(5); 5 | println("foo2"); 6 | foo(2); 7 | println("assert point instance count 1"); 8 | println(point_instance_count()); 9 | assert(point_instance_count() == 1); 10 | println("exposed var 42"); 11 | println(exposed_variable); 12 | assert(exposed_variable === 42); 13 | exposed_variable = 420; 14 | println("exposed var 420"); 15 | assert(exposed_variable === 420); 16 | 17 | // This line should be ignored 18 | exposed_variable_readonly=4; 19 | println("exposed var still 420"); 20 | assert(exposed_variable === 420); 21 | 22 | println("Lambda func 100 => 101"); 23 | assert(lambda_function(100) == 101); 24 | 25 | println("Testing print functions:") 26 | printfln("This should print out '1 a 2 b 3 c': %d a %d b %d c", [1,2,3]); 27 | println("This should print out '1 2 3': ", [1,2,3]); 28 | 29 | 30 | function some_global_function(){ 31 | println("In some global function"); 32 | } 33 | 34 | var caught_expected_exception = false; 35 | try { 36 | require("this-module-does-not-exist.js"); 37 | } catch (e) { 38 | caught_expected_exception = true; 39 | } 40 | assert(caught_expected_exception); 41 | 42 | var require_result = require("module.js"); 43 | assert(require_result.a === "a"); 44 | assert(require_result.five === 5); 45 | assert(require_result.function !== undefined); 46 | assert(require_result.bogus === undefined); 47 | assert(require_result.function() === "module.js function output"); 48 | 49 | var require_result = require("module.js"); 50 | assert(require_result.function() === "module.js function output"); 51 | 52 | 53 | var module2_results = require("module2.js"); 54 | assert(module2_results.function() === "module2.js function output"); 55 | // printobj(module2_results); 56 | // printobj(module_list()); 57 | 58 | // must return "yay" for this test 59 | "yay" -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | project ("v8toolkit Test") 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-backtrace-limit=0") 5 | 6 | 7 | set(CMAKE_VERBOSE_MAKEFILE on) 8 | 9 | 10 | include_directories(${gtest_SOURCE_DIR}/include) 11 | include_directories(${gmock_SOURCE_DIR}/include) 12 | 13 | file(GLOB TEST_SRC 14 | *.cpp 15 | ) 16 | 17 | add_definitions(-DGOOGLE_TEST) 18 | 19 | set(CLANG_HOME $ENV{CLANG_HOME}) 20 | link_directories(. ${CLANG_HOME}/lib) 21 | 22 | 23 | add_executable(test-v8toolkit ${TEST_SRC}) 24 | add_dependencies(test-v8toolkit copy_snapshots v8toolkit_shared) 25 | 26 | 27 | add_dependencies(test-v8toolkit gmock gtest) 28 | message("${MY_SRC}") 29 | 30 | # Causing false positives on vector re-allocations 31 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") 32 | 33 | #SdlStaticLibs(test-apb) 34 | 35 | target_link_libraries(test-v8toolkit v8toolkit_shared fmt gmock gmock_main ${V8_SHARED_LIBS} boost_system EASTL c++fs) 36 | add_custom_target(copy_javascript_sources) 37 | add_custom_command(TARGET copy_javascript_sources PRE_BUILD 38 | COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/*.js ${PROJECT_BINARY_DIR}) 39 | 40 | 41 | add_dependencies(test-v8toolkit copy_javascript_sources) -------------------------------------------------------------------------------- /test/fixtures.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "v8toolkit/javascript.h" 4 | #include "v8toolkit/v8toolkit.h" 5 | #include "v8toolkit/v8helpers.h" 6 | #include "testing.h" 7 | 8 | class ExampleFixture : public ::testing::Test { 9 | public: 10 | 11 | ExampleFixture() 12 | {} 13 | 14 | ~ExampleFixture() {} 15 | 16 | virtual void SetUp() { 17 | } 18 | 19 | }; 20 | 21 | class PlatformFixture : public ::testing::Test { 22 | public: 23 | PlatformFixture() { 24 | 25 | } 26 | }; 27 | 28 | 29 | class JavaScriptFixture : public PlatformFixture { 30 | 31 | public: 32 | v8toolkit::IsolatePtr i; 33 | v8toolkit::ContextPtr c; 34 | v8::Isolate * isolate; 35 | JavaScriptFixture() { 36 | i = v8toolkit::Platform::create_isolate(); 37 | i->add_print(); 38 | i->add_assert(); 39 | } 40 | 41 | void create_context() { 42 | c = i->create_context(); 43 | isolate = i->get_isolate(); 44 | 45 | // does a does a deep comparison between the two objects passed and if they don't match, it prints out the info 46 | // and then fails a GoogleTest EXPECT_EQ match. Just using EXPECT_EQ works, but you can't print out what the 47 | // comparison was 48 | c->add_function("EXPECT_EQJS", [this](v8::Local lhs, v8::Local rhs) { 49 | if (!v8toolkit::compare_contents(lhs, rhs)) { 50 | std::cerr << fmt::format("EXPECT_EQJS failed: {} != {}", *v8::String::Utf8Value(i->get_isolate(), lhs), *v8::String::Utf8Value(i->get_isolate(), rhs)) << std::endl; 51 | std::cerr << fmt::format("{}", v8toolkit::stringify_value(lhs)) << std::endl; 52 | std::cerr << fmt::format("{}", v8toolkit::stringify_value(rhs)) << std::endl; 53 | EXPECT_TRUE(v8toolkit::compare_contents(lhs, rhs)); 54 | } 55 | }); 56 | 57 | c->add_function("EXPECT_TRUE", [](bool expected_true_value) { 58 | if (expected_true_value == false) { 59 | std::cerr << fmt::format("put breakpoint here") << std::endl; 60 | } 61 | EXPECT_TRUE(expected_true_value); 62 | }); 63 | } 64 | 65 | }; 66 | -------------------------------------------------------------------------------- /test/mocks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class DeleteMe {}; 4 | 5 | 6 | class ExampleMock : public DeleteMe { 7 | public: 8 | 9 | // MOCK_CONST_METHOD(...) 10 | 11 | 12 | }; 13 | -------------------------------------------------------------------------------- /test/runtime_error.js: -------------------------------------------------------------------------------- 1 | new Object().a.b.c; -------------------------------------------------------------------------------- /test/syntax_error.js: -------------------------------------------------------------------------------- 1 | }}}}} -------------------------------------------------------------------------------- /test/test-bidirectional.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/v8toolkit/bidirectional.h" 2 | 3 | 4 | 5 | 6 | class BidirectionalCppClass { 7 | 8 | public: 9 | virtual void virtual_void_func(){} 10 | 11 | 12 | }; -------------------------------------------------------------------------------- /test/test.cpp: -------------------------------------------------------------------------------- 1 | #include "testing.h" 2 | 3 | #include "v8toolkit/javascript.h" 4 | 5 | using namespace testing; 6 | 7 | int main(int argc, char* argv[]) { 8 | // std::cerr << fmt::format("platform::init") << std::endl; 9 | v8toolkit::Platform::init(argc, argv, "../"); 10 | // std::cerr << fmt::format("platform::init done") << std::endl; 11 | testing::InitGoogleTest(&argc, argv); 12 | return RUN_ALL_TESTS(); 13 | } -------------------------------------------------------------------------------- /test/testing.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | using ::testing::_; 9 | using ::testing::Return; 10 | 11 | 12 | #include "mocks.h" 13 | #include "fixtures.h" 14 | 15 | using namespace std; 16 | 17 | #include "v8toolkit/v8_class_wrapper.h" 18 | #include "v8toolkit/javascript.h" 19 | 20 | 21 | using namespace v8toolkit; 22 | using std::unique_ptr; 23 | using std::make_unique; 24 | -------------------------------------------------------------------------------- /test/valid_module.js: -------------------------------------------------------------------------------- 1 | exports.foo = "foo"; -------------------------------------------------------------------------------- /v8toolkitConfig.cmake.in: -------------------------------------------------------------------------------- 1 | set(V8TOOLKIT_VERSION @V8TOOLKIT_VERSION@) 2 | 3 | # Include xlTargets.cmake from the same directory 4 | get_filename_component( 5 | TARGETS_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE) 6 | include("${TARGETS_CMAKE_DIR}/v8toolkitTargets.cmake") 7 | 8 | 9 | 10 | 11 | 12 | @PACKAGE_INIT@ 13 | 14 | set_and_check(V8TOOLKIT_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") 15 | --------------------------------------------------------------------------------