cfacter 3.11.0.rc.20180314
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/facter/Makefile.erb +31 -0
- data/ext/facter/cpp-hocon/CMakeLists.txt +67 -0
- data/ext/facter/cpp-hocon/CONTRIBUTING.md +9 -0
- data/ext/facter/cpp-hocon/LICENSE +17 -0
- data/ext/facter/cpp-hocon/MAINTAINERS +33 -0
- data/ext/facter/cpp-hocon/README.md +74 -0
- data/ext/facter/cpp-hocon/acceptance/Gemfile +18 -0
- data/ext/facter/cpp-hocon/acceptance/Rakefile +7 -0
- data/ext/facter/cpp-hocon/acceptance/tests/fake.rb +0 -0
- data/ext/facter/cpp-hocon/appveyor.yml +41 -0
- data/ext/facter/cpp-hocon/lib/CMakeLists.txt +94 -0
- data/ext/facter/cpp-hocon/lib/Doxyfile.in +2312 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config.hpp +734 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config_exception.hpp +184 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config_include_context.hpp +51 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config_includer.hpp +53 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config_includer_file.hpp +30 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config_list.hpp +51 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config_mergeable.hpp +72 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config_object.hpp +81 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config_origin.hpp +98 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config_parse_options.hpp +139 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config_parseable.hpp +47 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config_render_options.hpp +128 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config_resolve_options.hpp +83 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config_syntax.hpp +24 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config_value.hpp +267 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/config_value_factory.hpp +48 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/functional_list.hpp +318 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/parser/config_document.hpp +95 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/parser/config_document_factory.hpp +39 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/parser/config_node.hpp +32 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/path.hpp +60 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/program_options.hpp +84 -0
- data/ext/facter/cpp-hocon/lib/inc/hocon/types.hpp +57 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/config_document_parser.hpp +83 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/config_parser.hpp +55 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/config_util.hpp +17 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/container.hpp +28 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/default_transformer.hpp +12 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/full_includer.hpp +13 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/nodes/abstract_config_node.hpp +16 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/nodes/abstract_config_node_value.hpp +12 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/nodes/config_node_array.hpp +17 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/nodes/config_node_comment.hpp +14 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/nodes/config_node_complex_value.hpp +25 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/nodes/config_node_concatenation.hpp +16 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/nodes/config_node_field.hpp +29 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/nodes/config_node_include.hpp +26 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/nodes/config_node_object.hpp +45 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/nodes/config_node_path.hpp +25 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/nodes/config_node_root.hpp +24 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/nodes/config_node_simple_value.hpp +21 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/nodes/config_node_single_token.hpp +20 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/parseable.hpp +128 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/path_builder.hpp +20 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/path_parser.hpp +55 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/replaceable_merge_stack.hpp +14 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/resolve_context.hpp +53 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/resolve_result.hpp +21 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/resolve_source.hpp +55 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/simple_config_document.hpp +28 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/simple_config_origin.hpp +67 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/simple_include_context.hpp +22 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/simple_includer.hpp +79 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/substitution_expression.hpp +28 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/token.hpp +45 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/tokenizer.hpp +143 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/tokens.hpp +135 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/unmergeable.hpp +20 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/values/config_boolean.hpp +26 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/values/config_concatenation.hpp +59 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/values/config_delayed_merge.hpp +53 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/values/config_delayed_merge_object.hpp +57 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/values/config_double.hpp +28 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/values/config_int.hpp +25 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/values/config_long.hpp +28 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/values/config_null.hpp +33 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/values/config_number.hpp +38 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/values/config_reference.hpp +38 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/values/config_string.hpp +32 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/values/simple_config_list.hpp +75 -0
- data/ext/facter/cpp-hocon/lib/inc/internal/values/simple_config_object.hpp +107 -0
- data/ext/facter/cpp-hocon/lib/namespaces.dox.in +6 -0
- data/ext/facter/cpp-hocon/lib/src/config.cc +573 -0
- data/ext/facter/cpp-hocon/lib/src/config_document_factory.cc +24 -0
- data/ext/facter/cpp-hocon/lib/src/config_document_parser.cc +620 -0
- data/ext/facter/cpp-hocon/lib/src/config_parse_options.cc +101 -0
- data/ext/facter/cpp-hocon/lib/src/config_parser.cc +399 -0
- data/ext/facter/cpp-hocon/lib/src/config_render_options.cc +44 -0
- data/ext/facter/cpp-hocon/lib/src/config_resolve_options.cc +24 -0
- data/ext/facter/cpp-hocon/lib/src/config_util.cc +95 -0
- data/ext/facter/cpp-hocon/lib/src/config_value_factory.cc +68 -0
- data/ext/facter/cpp-hocon/lib/src/default_transformer.cc +94 -0
- data/ext/facter/cpp-hocon/lib/src/nodes/abstract_config_node.cc +19 -0
- data/ext/facter/cpp-hocon/lib/src/nodes/config_node_array.cc +13 -0
- data/ext/facter/cpp-hocon/lib/src/nodes/config_node_comment.cc +15 -0
- data/ext/facter/cpp-hocon/lib/src/nodes/config_node_complex_value.cc +50 -0
- data/ext/facter/cpp-hocon/lib/src/nodes/config_node_concatenation.cc +14 -0
- data/ext/facter/cpp-hocon/lib/src/nodes/config_node_field.cc +80 -0
- data/ext/facter/cpp-hocon/lib/src/nodes/config_node_include.cc +38 -0
- data/ext/facter/cpp-hocon/lib/src/nodes/config_node_object.cc +318 -0
- data/ext/facter/cpp-hocon/lib/src/nodes/config_node_path.cc +47 -0
- data/ext/facter/cpp-hocon/lib/src/nodes/config_node_root.cc +70 -0
- data/ext/facter/cpp-hocon/lib/src/nodes/config_node_simple_value.cc +50 -0
- data/ext/facter/cpp-hocon/lib/src/nodes/config_node_single_token.cc +18 -0
- data/ext/facter/cpp-hocon/lib/src/parseable.cc +325 -0
- data/ext/facter/cpp-hocon/lib/src/path.cc +219 -0
- data/ext/facter/cpp-hocon/lib/src/path_builder.cc +38 -0
- data/ext/facter/cpp-hocon/lib/src/path_parser.cc +253 -0
- data/ext/facter/cpp-hocon/lib/src/resolve_context.cc +139 -0
- data/ext/facter/cpp-hocon/lib/src/resolve_source.cc +216 -0
- data/ext/facter/cpp-hocon/lib/src/simple_config_document.cc +69 -0
- data/ext/facter/cpp-hocon/lib/src/simple_config_origin.cc +246 -0
- data/ext/facter/cpp-hocon/lib/src/simple_include_context.cc +18 -0
- data/ext/facter/cpp-hocon/lib/src/simple_includer.cc +186 -0
- data/ext/facter/cpp-hocon/lib/src/substitution_expression.cc +35 -0
- data/ext/facter/cpp-hocon/lib/src/token.cc +52 -0
- data/ext/facter/cpp-hocon/lib/src/tokenizer.cc +568 -0
- data/ext/facter/cpp-hocon/lib/src/tokens.cc +257 -0
- data/ext/facter/cpp-hocon/lib/src/values/config_boolean.cc +34 -0
- data/ext/facter/cpp-hocon/lib/src/values/config_concatenation.cc +260 -0
- data/ext/facter/cpp-hocon/lib/src/values/config_delayed_merge.cc +223 -0
- data/ext/facter/cpp-hocon/lib/src/values/config_delayed_merge_object.cc +180 -0
- data/ext/facter/cpp-hocon/lib/src/values/config_double.cc +35 -0
- data/ext/facter/cpp-hocon/lib/src/values/config_int.cc +35 -0
- data/ext/facter/cpp-hocon/lib/src/values/config_long.cc +35 -0
- data/ext/facter/cpp-hocon/lib/src/values/config_null.cc +35 -0
- data/ext/facter/cpp-hocon/lib/src/values/config_number.cc +78 -0
- data/ext/facter/cpp-hocon/lib/src/values/config_object.cc +97 -0
- data/ext/facter/cpp-hocon/lib/src/values/config_reference.cc +85 -0
- data/ext/facter/cpp-hocon/lib/src/values/config_string.cc +47 -0
- data/ext/facter/cpp-hocon/lib/src/values/config_value.cc +289 -0
- data/ext/facter/cpp-hocon/lib/src/values/simple_config_list.cc +219 -0
- data/ext/facter/cpp-hocon/lib/src/values/simple_config_object.cc +515 -0
- data/ext/facter/cpp-hocon/lib/tests/CMakeLists.txt +42 -0
- data/ext/facter/cpp-hocon/lib/tests/concatenation_test.cc +401 -0
- data/ext/facter/cpp-hocon/lib/tests/conf_parser_test.cc +715 -0
- data/ext/facter/cpp-hocon/lib/tests/config_document_parser_test.cc +208 -0
- data/ext/facter/cpp-hocon/lib/tests/config_document_tests.cc +110 -0
- data/ext/facter/cpp-hocon/lib/tests/config_node_test.cc +338 -0
- data/ext/facter/cpp-hocon/lib/tests/config_substitution_test.cc +897 -0
- data/ext/facter/cpp-hocon/lib/tests/config_test.cc +151 -0
- data/ext/facter/cpp-hocon/lib/tests/config_value_factory_test.cc +60 -0
- data/ext/facter/cpp-hocon/lib/tests/config_value_test.cc +111 -0
- data/ext/facter/cpp-hocon/lib/tests/fixtures.hpp.in +3 -0
- data/ext/facter/cpp-hocon/lib/tests/fixtures/test01.conf +91 -0
- data/ext/facter/cpp-hocon/lib/tests/fixtures/test01.json +4 -0
- data/ext/facter/cpp-hocon/lib/tests/main.cc +8 -0
- data/ext/facter/cpp-hocon/lib/tests/path_test.cc +129 -0
- data/ext/facter/cpp-hocon/lib/tests/program_options.cc +63 -0
- data/ext/facter/cpp-hocon/lib/tests/test.conf +1 -0
- data/ext/facter/cpp-hocon/lib/tests/test_utils.cc +452 -0
- data/ext/facter/cpp-hocon/lib/tests/test_utils.hpp +139 -0
- data/ext/facter/cpp-hocon/lib/tests/token_test.cc +108 -0
- data/ext/facter/cpp-hocon/lib/tests/tokenizer_test.cc +694 -0
- data/ext/facter/cpp-hocon/lib/version.h.in +28 -0
- data/ext/facter/cpp-hocon/locales/CMakeLists.txt +4 -0
- data/ext/facter/cpp-hocon/locales/cpp-hocon.pot +767 -0
- data/ext/facter/extconf.rb +22 -0
- data/ext/facter/facter/CMakeLists.txt +183 -0
- data/ext/facter/facter/CONTRIBUTING.md +99 -0
- data/ext/facter/facter/Extensibility.md +133 -0
- data/ext/facter/facter/LICENSE +17 -0
- data/ext/facter/facter/MAINTAINERS +28 -0
- data/ext/facter/facter/README.md +295 -0
- data/ext/facter/facter/Rakefile +42 -0
- data/ext/facter/facter/acceptance/Gemfile +21 -0
- data/ext/facter/facter/acceptance/Rakefile +342 -0
- data/ext/facter/facter/acceptance/bin/ci-bootstrap-from-artifacts.sh +55 -0
- data/ext/facter/facter/acceptance/config/aio/options.rb +9 -0
- data/ext/facter/facter/acceptance/config/git/options.rb +7 -0
- data/ext/facter/facter/acceptance/config/nodes/aix-53-power.yaml +7 -0
- data/ext/facter/facter/acceptance/config/nodes/aix-61-power.yaml +7 -0
- data/ext/facter/facter/acceptance/config/nodes/aix-71-power.yaml +7 -0
- data/ext/facter/facter/acceptance/config/nodes/huaweios-6-powerpc.yaml +7 -0
- data/ext/facter/facter/acceptance/config/nodes/solaris-10-sparc.yaml +9 -0
- data/ext/facter/facter/acceptance/config/nodes/solaris-11-sparc.yaml +9 -0
- data/ext/facter/facter/acceptance/lib/facter/acceptance/base_fact_utils.rb +563 -0
- data/ext/facter/facter/acceptance/lib/facter/acceptance/user_fact_utils.rb +132 -0
- data/ext/facter/facter/acceptance/lib/helper.rb +1 -0
- data/ext/facter/facter/acceptance/lib/puppet/acceptance/common_utils.rb +10 -0
- data/ext/facter/facter/acceptance/lib/puppet/acceptance/git_utils.rb +19 -0
- data/ext/facter/facter/acceptance/lib/puppet/acceptance/install_utils.rb +58 -0
- data/ext/facter/facter/acceptance/setup/aio/pre-suite/010_Install.rb +22 -0
- data/ext/facter/facter/acceptance/setup/aio/pre-suite/021_InstallAristaModule.rb +12 -0
- data/ext/facter/facter/acceptance/setup/aio/pre-suite/022_Remove_LD_PRELOAD.rb +11 -0
- data/ext/facter/facter/acceptance/setup/common/00_EnvSetup.rb +64 -0
- data/ext/facter/facter/acceptance/setup/common/pre-suite/000-delete-puppet-when-none.rb +11 -0
- data/ext/facter/facter/acceptance/setup/git/pre-suite/01_TestSetup.rb +31 -0
- data/ext/facter/facter/acceptance/tests/custom_facts/custom_fact_with_10001_weight_overrides_external_fact.rb +30 -0
- data/ext/facter/facter/acceptance/tests/custom_facts/having_multiple_facts_in_one_file.rb +40 -0
- data/ext/facter/facter/acceptance/tests/custom_facts/using_win32ole_should_not_hang.rb +33 -0
- data/ext/facter/facter/acceptance/tests/external_facts/env_var_overrides_external_fact.rb +46 -0
- data/ext/facter/facter/acceptance/tests/external_facts/external_dir_overrides_default_external_fact.rb +34 -0
- data/ext/facter/facter/acceptance/tests/external_facts/external_fact_overrides_custom_fact.rb +29 -0
- data/ext/facter/facter/acceptance/tests/external_facts/external_fact_overrides_custom_fact_with_10000_weight_or_less.rb +30 -0
- data/ext/facter/facter/acceptance/tests/external_facts/external_fact_overrides_custom_fact_with_confine.rb +35 -0
- data/ext/facter/facter/acceptance/tests/external_facts/external_fact_stderr_messages_output_to_stderr.rb +49 -0
- data/ext/facter/facter/acceptance/tests/external_facts/external_facts_only_run_once.rb +43 -0
- data/ext/facter/facter/acceptance/tests/external_facts/fact_directory_precedence.rb +109 -0
- data/ext/facter/facter/acceptance/tests/external_facts/non_root_users_default_external_fact_directory.rb +142 -0
- data/ext/facter/facter/acceptance/tests/external_facts/root_uses_default_external_fact_dir.rb +34 -0
- data/ext/facter/facter/acceptance/tests/external_facts/structured_executable_facts.rb +139 -0
- data/ext/facter/facter/acceptance/tests/facter_returns_success_on_non_existent_fact.rb +9 -0
- data/ext/facter/facter/acceptance/tests/facts/dmi.rb +51 -0
- data/ext/facter/facter/acceptance/tests/facts/facterversion.rb +11 -0
- data/ext/facter/facter/acceptance/tests/facts/identity.rb +52 -0
- data/ext/facter/facter/acceptance/tests/facts/networking_facts.rb +76 -0
- data/ext/facter/facter/acceptance/tests/facts/non_root_users_without_errors.rb +32 -0
- data/ext/facter/facter/acceptance/tests/facts/operatingsystem_detection_after_clear_on_ubuntu.rb +26 -0
- data/ext/facter/facter/acceptance/tests/facts/os_processors_and_kernel.rb +20 -0
- data/ext/facter/facter/acceptance/tests/facts/partitions.rb +37 -0
- data/ext/facter/facter/acceptance/tests/facts/productname.rb +15 -0
- data/ext/facter/facter/acceptance/tests/facts/ruby.rb +59 -0
- data/ext/facter/facter/acceptance/tests/facts/validate_file_system_size_bytes.rb +37 -0
- data/ext/facter/facter/acceptance/tests/facts/verify_tmpfs_file_system.rb +54 -0
- data/ext/facter/facter/acceptance/tests/load_libfacter.rb +66 -0
- data/ext/facter/facter/acceptance/tests/no_errors_on_stderr.rb +10 -0
- data/ext/facter/facter/acceptance/tests/options/color.rb +16 -0
- data/ext/facter/facter/acceptance/tests/options/config.rb +27 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/blocklist.rb +35 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb +40 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/custom_dir_overridden_by_cli_custom_dir.rb +56 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/custom_facts.rb +42 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/custom_facts_list.rb +56 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/debug.rb +34 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/debug_override_config_file.rb +34 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/default_file_location.rb +37 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/external_dir_conflicts_with_cli_no_external_facts.rb +37 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/external_dir_overridden_by_cli_external_dir.rb +40 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/external_facts.rb +37 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/external_facts_list.rb +43 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/load_from_ruby.rb +73 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/log_level.rb +35 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_custom_dir.rb +43 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_facterlib.rb +43 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb +49 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/no_external_facts.rb +38 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/no_external_facts_and_external_dir.rb +34 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/no_ruby_disables_custom_facts.rb +52 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/no_ruby_disables_ruby_facts.rb +34 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/trace.rb +48 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/ttls_cached_facts_clear_by_empty_ttls_cache_list.rb +71 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/ttls_cached_facts_creates_json_cache_file.rb +48 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/ttls_cached_facts_expire_facts_do_not_read_the_old_cached_value.rb +58 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/ttls_cached_facts_expire_facts_refresh_the_cached_value.rb +61 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/ttls_cached_facts_read_from_the_cached_value.rb +57 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/ttls_cached_facts_that_are_corrupt_are_refreshed.rb +53 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/ttls_cached_facts_that_are_empty_return_an_empty_value.rb +53 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb +45 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/ttls_puppet_facts_honors_cached_facts.rb +54 -0
- data/ext/facter/facter/acceptance/tests/options/config_file/verbose.rb +34 -0
- data/ext/facter/facter/acceptance/tests/options/custom_facts.rb +34 -0
- data/ext/facter/facter/acceptance/tests/options/custom_facts_facterlib.rb +33 -0
- data/ext/facter/facter/acceptance/tests/options/custom_facts_list.rb +48 -0
- data/ext/facter/facter/acceptance/tests/options/custom_facts_load_path.rb +42 -0
- data/ext/facter/facter/acceptance/tests/options/debug.rb +12 -0
- data/ext/facter/facter/acceptance/tests/options/external_facts.rb +28 -0
- data/ext/facter/facter/acceptance/tests/options/external_facts_list.rb +35 -0
- data/ext/facter/facter/acceptance/tests/options/help.rb +13 -0
- data/ext/facter/facter/acceptance/tests/options/json.rb +43 -0
- data/ext/facter/facter/acceptance/tests/options/list_block_groups.rb +16 -0
- data/ext/facter/facter/acceptance/tests/options/list_cache_groups.rb +16 -0
- data/ext/facter/facter/acceptance/tests/options/log_level.rb +13 -0
- data/ext/facter/facter/acceptance/tests/options/no_block.rb +34 -0
- data/ext/facter/facter/acceptance/tests/options/no_cache_should_not_cache_facts.rb +43 -0
- data/ext/facter/facter/acceptance/tests/options/no_cache_should_not_load_cached_facts.rb +58 -0
- data/ext/facter/facter/acceptance/tests/options/no_cache_should_not_refresh_cached_facts.rb +63 -0
- data/ext/facter/facter/acceptance/tests/options/no_color.rb +16 -0
- data/ext/facter/facter/acceptance/tests/options/no_custom_facts.rb +34 -0
- data/ext/facter/facter/acceptance/tests/options/no_custom_facts_and_custom_dir.rb +19 -0
- data/ext/facter/facter/acceptance/tests/options/no_custom_facts_and_facterlib.rb +34 -0
- data/ext/facter/facter/acceptance/tests/options/no_custom_facts_and_load_path.rb +43 -0
- data/ext/facter/facter/acceptance/tests/options/no_external_facts.rb +28 -0
- data/ext/facter/facter/acceptance/tests/options/no_external_facts_and_external_dir.rb +19 -0
- data/ext/facter/facter/acceptance/tests/options/no_ruby.rb +44 -0
- data/ext/facter/facter/acceptance/tests/options/puppet_facts.rb +35 -0
- data/ext/facter/facter/acceptance/tests/options/show_legacy.rb +18 -0
- data/ext/facter/facter/acceptance/tests/options/strict.rb +11 -0
- data/ext/facter/facter/acceptance/tests/options/trace.rb +36 -0
- data/ext/facter/facter/acceptance/tests/options/verbose.rb +12 -0
- data/ext/facter/facter/acceptance/tests/options/version.rb +12 -0
- data/ext/facter/facter/acceptance/tests/options/yaml.rb +43 -0
- data/ext/facter/facter/acceptance/tests/ticket_1123_facter_with_invalid_locale.rb +22 -0
- data/ext/facter/facter/acceptance/tests/ticket_1238_hostname_fqdn.rb +57 -0
- data/ext/facter/facter/appveyor.yml +43 -0
- data/ext/facter/facter/cmake/FindBLKID.cmake +6 -0
- data/ext/facter/facter/cmake/FindCPPHOCON.cmake +6 -0
- data/ext/facter/facter/cmake/FindDependency.cmake +54 -0
- data/ext/facter/facter/cmake/FindOPENSSL.cmake +10 -0
- data/ext/facter/facter/cmake/FindRuby.cmake +286 -0
- data/ext/facter/facter/cmake/FindWHEREAMI.cmake +6 -0
- data/ext/facter/facter/cmake/FindYAMLCPP.cmake +17 -0
- data/ext/facter/facter/contrib/dockerfiles/travis-cpp-builder/Dockerfile +56 -0
- data/ext/facter/facter/contrib/dockerfiles/travis-facter-builder/Dockerfile +23 -0
- data/ext/facter/facter/contrib/dockerfiles/travis-facter-coverity/Dockerfile +40 -0
- data/ext/facter/facter/contrib/dockerfiles/travis-facter-coverity/_coverity-submit.erb +12 -0
- data/ext/facter/facter/contrib/dockerfiles/travis-facter-coverity/fix_curl_command.patch +32 -0
- data/ext/facter/facter/exe/CMakeLists.txt +39 -0
- data/ext/facter/facter/exe/facter.cc +377 -0
- data/ext/facter/facter/ext/build_defaults.yaml +16 -0
- data/ext/facter/facter/ext/debian/changelog.erb +11 -0
- data/ext/facter/facter/ext/debian/compat +1 -0
- data/ext/facter/facter/ext/debian/control +14 -0
- data/ext/facter/facter/ext/debian/copyright +19 -0
- data/ext/facter/facter/ext/debian/docs +2 -0
- data/ext/facter/facter/ext/debian/facter.install +4 -0
- data/ext/facter/facter/ext/debian/lintian-overrides +0 -0
- data/ext/facter/facter/ext/debian/rules +39 -0
- data/ext/facter/facter/ext/debian/source/format +1 -0
- data/ext/facter/facter/ext/project_data.yaml +30 -0
- data/ext/facter/facter/ext/redhat/facter.spec.erb +113 -0
- data/ext/facter/facter/ext/windows/facter.bat +8 -0
- data/ext/facter/facter/ext/windows/facter_interactive.bat +6 -0
- data/ext/facter/facter/ext/windows/run_facter_interactive.bat +9 -0
- data/ext/facter/facter/factergo/example/main.go +17 -0
- data/ext/facter/facter/factergo/facter.go +42 -0
- data/ext/facter/facter/factergo/facter_test.go +25 -0
- data/ext/facter/facter/lib/CMakeLists.txt +409 -0
- data/ext/facter/facter/lib/Doxyfile +2313 -0
- data/ext/facter/facter/lib/Facter.java.in +110 -0
- data/ext/facter/facter/lib/Gemfile +11 -0
- data/ext/facter/facter/lib/Rakefile +8 -0
- data/ext/facter/facter/lib/docs/generate.rb +25 -0
- data/ext/facter/facter/lib/docs/namespaces.dox +129 -0
- data/ext/facter/facter/lib/docs/template.erb +43 -0
- data/ext/facter/facter/lib/facter.rb.in +45 -0
- data/ext/facter/facter/lib/gemspec.in +21 -0
- data/ext/facter/facter/lib/inc/facter/cwrapper.hpp +18 -0
- data/ext/facter/facter/lib/inc/facter/facts/array_value.hpp +125 -0
- data/ext/facter/facter/lib/inc/facter/facts/collection.hpp +339 -0
- data/ext/facter/facter/lib/inc/facter/facts/external/resolver.hpp +49 -0
- data/ext/facter/facter/lib/inc/facter/facts/fact.hpp +669 -0
- data/ext/facter/facter/lib/inc/facter/facts/map_value.hpp +127 -0
- data/ext/facter/facter/lib/inc/facter/facts/os.hpp +202 -0
- data/ext/facter/facter/lib/inc/facter/facts/os_family.hpp +58 -0
- data/ext/facter/facter/lib/inc/facter/facts/resolver.hpp +126 -0
- data/ext/facter/facter/lib/inc/facter/facts/scalar_value.hpp +152 -0
- data/ext/facter/facter/lib/inc/facter/facts/value.hpp +164 -0
- data/ext/facter/facter/lib/inc/facter/facts/vm.hpp +157 -0
- data/ext/facter/facter/lib/inc/facter/logging/logging.hpp +192 -0
- data/ext/facter/facter/lib/inc/facter/ruby/ruby.hpp +62 -0
- data/ext/facter/facter/lib/inc/facter/util/config.hpp +84 -0
- data/ext/facter/facter/lib/inc/facter/util/string.hpp +72 -0
- data/ext/facter/facter/lib/inc/internal/facts/aix/disk_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/aix/filesystem_resolver.hpp +41 -0
- data/ext/facter/facter/lib/inc/internal/facts/aix/kernel_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/aix/memory_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/aix/networking_resolver.hpp +49 -0
- data/ext/facter/facter/lib/inc/internal/facts/aix/operating_system_resolver.hpp +24 -0
- data/ext/facter/facter/lib/inc/internal/facts/aix/processor_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/aix/serial_number_resolver.hpp +27 -0
- data/ext/facter/facter/lib/inc/internal/facts/bsd/filesystem_resolver.hpp +30 -0
- data/ext/facter/facter/lib/inc/internal/facts/bsd/networking_resolver.hpp +59 -0
- data/ext/facter/facter/lib/inc/internal/facts/bsd/uptime_resolver.hpp +24 -0
- data/ext/facter/facter/lib/inc/internal/facts/cache.hpp +71 -0
- data/ext/facter/facter/lib/inc/internal/facts/external/execution_resolver.hpp +31 -0
- data/ext/facter/facter/lib/inc/internal/facts/external/json_resolver.hpp +31 -0
- data/ext/facter/facter/lib/inc/internal/facts/external/text_resolver.hpp +31 -0
- data/ext/facter/facter/lib/inc/internal/facts/external/windows/powershell_resolver.hpp +34 -0
- data/ext/facter/facter/lib/inc/internal/facts/external/yaml_resolver.hpp +31 -0
- data/ext/facter/facter/lib/inc/internal/facts/freebsd/dmi_resolver.hpp +28 -0
- data/ext/facter/facter/lib/inc/internal/facts/freebsd/memory_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/freebsd/networking_resolver.hpp +42 -0
- data/ext/facter/facter/lib/inc/internal/facts/freebsd/operating_system_resolver.hpp +24 -0
- data/ext/facter/facter/lib/inc/internal/facts/freebsd/processor_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/freebsd/virtualization_resolver.hpp +27 -0
- data/ext/facter/facter/lib/inc/internal/facts/freebsd/zfs_resolver.hpp +24 -0
- data/ext/facter/facter/lib/inc/internal/facts/freebsd/zpool_resolver.hpp +24 -0
- data/ext/facter/facter/lib/inc/internal/facts/glib/load_average_resolver.hpp +24 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/disk_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/dmi_resolver.hpp +37 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/filesystem_resolver.hpp +40 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/fips_resolver.hpp +31 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/kernel_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/memory_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/networking_resolver.hpp +78 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/operating_system_resolver.hpp +28 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/os_cisco.hpp +114 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/os_coreos.hpp +56 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/os_cumulus.hpp +56 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/os_linux.hpp +72 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/processor_resolver.hpp +60 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/release_file.hpp +124 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/uptime_resolver.hpp +24 -0
- data/ext/facter/facter/lib/inc/internal/facts/linux/virtualization_resolver.hpp +50 -0
- data/ext/facter/facter/lib/inc/internal/facts/openbsd/dmi_resolver.hpp +28 -0
- data/ext/facter/facter/lib/inc/internal/facts/openbsd/memory_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/openbsd/networking_resolver.hpp +42 -0
- data/ext/facter/facter/lib/inc/internal/facts/openbsd/processor_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/openbsd/virtualization_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/osx/dmi_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/osx/memory_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/osx/networking_resolver.hpp +60 -0
- data/ext/facter/facter/lib/inc/internal/facts/osx/operating_system_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/osx/processor_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/osx/system_profiler_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/osx/virtualization_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/posix/identity_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/posix/kernel_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/posix/networking_resolver.hpp +48 -0
- data/ext/facter/facter/lib/inc/internal/facts/posix/operating_system_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/posix/processor_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/posix/ssh_resolver.hpp +28 -0
- data/ext/facter/facter/lib/inc/internal/facts/posix/timezone_resolver.hpp +24 -0
- data/ext/facter/facter/lib/inc/internal/facts/posix/uptime_resolver.hpp +32 -0
- data/ext/facter/facter/lib/inc/internal/facts/posix/xen_resolver.hpp +24 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/augeas_resolver.hpp +35 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/disk_resolver.hpp +81 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/dmi_resolver.hpp +115 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/ec2_resolver.hpp +30 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/filesystem_resolver.hpp +166 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/fips_resolver.hpp +46 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/gce_resolver.hpp +28 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/hypervisors_resolver.hpp +69 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/identity_resolver.hpp +73 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/kernel_resolver.hpp +66 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/ldom_resolver.hpp +64 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/load_average_resolver.hpp +37 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/memory_resolver.hpp +99 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/networking_resolver.hpp +155 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/operating_system_resolver.hpp +235 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/path_resolver.hpp +28 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/processor_resolver.hpp +80 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/ruby_resolver.hpp +56 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/ssh_resolver.hpp +105 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/system_profiler_resolver.hpp +127 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/timezone_resolver.hpp +36 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/uptime_resolver.hpp +36 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/virtualization_resolver.hpp +95 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/xen_resolver.hpp +55 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/zfs_resolver.hpp +59 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/zone_resolver.hpp +95 -0
- data/ext/facter/facter/lib/inc/internal/facts/resolvers/zpool_resolver.hpp +63 -0
- data/ext/facter/facter/lib/inc/internal/facts/solaris/disk_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/solaris/dmi_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/solaris/filesystem_resolver.hpp +29 -0
- data/ext/facter/facter/lib/inc/internal/facts/solaris/kernel_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/solaris/ldom_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/solaris/memory_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/solaris/networking_resolver.hpp +48 -0
- data/ext/facter/facter/lib/inc/internal/facts/solaris/operating_system_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/solaris/processor_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/solaris/virtualization_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/solaris/zfs_resolver.hpp +24 -0
- data/ext/facter/facter/lib/inc/internal/facts/solaris/zone_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/solaris/zpool_resolver.hpp +24 -0
- data/ext/facter/facter/lib/inc/internal/facts/windows/dmi_resolver.hpp +38 -0
- data/ext/facter/facter/lib/inc/internal/facts/windows/identity_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/windows/kernel_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/windows/memory_resolver.hpp +25 -0
- data/ext/facter/facter/lib/inc/internal/facts/windows/networking_resolver.hpp +74 -0
- data/ext/facter/facter/lib/inc/internal/facts/windows/operating_system_resolver.hpp +36 -0
- data/ext/facter/facter/lib/inc/internal/facts/windows/processor_resolver.hpp +36 -0
- data/ext/facter/facter/lib/inc/internal/facts/windows/timezone_resolver.hpp +24 -0
- data/ext/facter/facter/lib/inc/internal/facts/windows/uptime_resolver.hpp +32 -0
- data/ext/facter/facter/lib/inc/internal/facts/windows/virtualization_resolver.hpp +37 -0
- data/ext/facter/facter/lib/inc/internal/ruby/aggregate_resolution.hpp +77 -0
- data/ext/facter/facter/lib/inc/internal/ruby/chunk.hpp +83 -0
- data/ext/facter/facter/lib/inc/internal/ruby/confine.hpp +60 -0
- data/ext/facter/facter/lib/inc/internal/ruby/fact.hpp +108 -0
- data/ext/facter/facter/lib/inc/internal/ruby/module.hpp +165 -0
- data/ext/facter/facter/lib/inc/internal/ruby/resolution.hpp +126 -0
- data/ext/facter/facter/lib/inc/internal/ruby/ruby_value.hpp +119 -0
- data/ext/facter/facter/lib/inc/internal/ruby/simple_resolution.hpp +56 -0
- data/ext/facter/facter/lib/inc/internal/util/agent.hpp +29 -0
- data/ext/facter/facter/lib/inc/internal/util/aix/odm.hpp +373 -0
- data/ext/facter/facter/lib/inc/internal/util/aix/vmount.hpp +139 -0
- data/ext/facter/facter/lib/inc/internal/util/bsd/scoped_ifaddrs.hpp +33 -0
- data/ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp +45 -0
- data/ext/facter/facter/lib/inc/internal/util/posix/scoped_bio.hpp +34 -0
- data/ext/facter/facter/lib/inc/internal/util/posix/scoped_descriptor.hpp +27 -0
- data/ext/facter/facter/lib/inc/internal/util/scoped_file.hpp +36 -0
- data/ext/facter/facter/lib/inc/internal/util/solaris/k_stat.hpp +176 -0
- data/ext/facter/facter/lib/inc/internal/util/solaris/scoped_kstat.hpp +45 -0
- data/ext/facter/facter/lib/inc/internal/util/versions.hpp +34 -0
- data/ext/facter/facter/lib/inc/internal/util/windows/wsa.hpp +92 -0
- data/ext/facter/facter/lib/inc/internal/util/yaml.hpp +25 -0
- data/ext/facter/facter/lib/schema/core_facts.pot +2017 -0
- data/ext/facter/facter/lib/schema/facter.yaml +1947 -0
- data/ext/facter/facter/lib/schema/translation_tooling.rb +67 -0
- data/ext/facter/facter/lib/spec/unit/facter_spec.rb +136 -0
- data/ext/facter/facter/lib/spec_helper.rb.in +27 -0
- data/ext/facter/facter/lib/src/cwrapper.cc +45 -0
- data/ext/facter/facter/lib/src/facts/aix/collection.cc +32 -0
- data/ext/facter/facter/lib/src/facts/aix/disk_resolver.cc +66 -0
- data/ext/facter/facter/lib/src/facts/aix/filesystem_resolver.cc +132 -0
- data/ext/facter/facter/lib/src/facts/aix/kernel_resolver.cc +27 -0
- data/ext/facter/facter/lib/src/facts/aix/memory_resolver.cc +48 -0
- data/ext/facter/facter/lib/src/facts/aix/networking_resolver.cc +245 -0
- data/ext/facter/facter/lib/src/facts/aix/operating_system_resolver.cc +61 -0
- data/ext/facter/facter/lib/src/facts/aix/processor_resolver.cc +106 -0
- data/ext/facter/facter/lib/src/facts/aix/serial_number_resolver.cc +43 -0
- data/ext/facter/facter/lib/src/facts/array_value.cc +111 -0
- data/ext/facter/facter/lib/src/facts/bsd/collection.cc +27 -0
- data/ext/facter/facter/lib/src/facts/bsd/filesystem_resolver.cc +92 -0
- data/ext/facter/facter/lib/src/facts/bsd/networking_resolver.cc +175 -0
- data/ext/facter/facter/lib/src/facts/bsd/uptime_resolver.cc +23 -0
- data/ext/facter/facter/lib/src/facts/cache.cc +117 -0
- data/ext/facter/facter/lib/src/facts/collection.cc +661 -0
- data/ext/facter/facter/lib/src/facts/external/execution_resolver.cc +89 -0
- data/ext/facter/facter/lib/src/facts/external/json_resolver.cc +219 -0
- data/ext/facter/facter/lib/src/facts/external/resolver.cc +12 -0
- data/ext/facter/facter/lib/src/facts/external/text_resolver.cc +45 -0
- data/ext/facter/facter/lib/src/facts/external/windows/powershell_resolver.cc +117 -0
- data/ext/facter/facter/lib/src/facts/external/yaml_resolver.cc +45 -0
- data/ext/facter/facter/lib/src/facts/freebsd/collection.cc +41 -0
- data/ext/facter/facter/lib/src/facts/freebsd/dmi_resolver.cc +43 -0
- data/ext/facter/facter/lib/src/facts/freebsd/memory_resolver.cc +76 -0
- data/ext/facter/facter/lib/src/facts/freebsd/networking_resolver.cc +55 -0
- data/ext/facter/facter/lib/src/facts/freebsd/operating_system_resolver.cc +17 -0
- data/ext/facter/facter/lib/src/facts/freebsd/processor_resolver.cc +63 -0
- data/ext/facter/facter/lib/src/facts/freebsd/virtualization_resolver.cc +41 -0
- data/ext/facter/facter/lib/src/facts/freebsd/zfs_resolver.cc +12 -0
- data/ext/facter/facter/lib/src/facts/freebsd/zpool_resolver.cc +12 -0
- data/ext/facter/facter/lib/src/facts/glib/load_average_resolver.cc +22 -0
- data/ext/facter/facter/lib/src/facts/linux/collection.cc +44 -0
- data/ext/facter/facter/lib/src/facts/linux/disk_resolver.cc +80 -0
- data/ext/facter/facter/lib/src/facts/linux/dmi_resolver.cc +208 -0
- data/ext/facter/facter/lib/src/facts/linux/filesystem_resolver.cc +282 -0
- data/ext/facter/facter/lib/src/facts/linux/fips_resolver.cc +31 -0
- data/ext/facter/facter/lib/src/facts/linux/kernel_resolver.cc +20 -0
- data/ext/facter/facter/lib/src/facts/linux/memory_resolver.cc +50 -0
- data/ext/facter/facter/lib/src/facts/linux/networking_resolver.cc +275 -0
- data/ext/facter/facter/lib/src/facts/linux/operating_system_resolver.cc +175 -0
- data/ext/facter/facter/lib/src/facts/linux/os_linux.cc +393 -0
- data/ext/facter/facter/lib/src/facts/linux/processor_resolver.cc +200 -0
- data/ext/facter/facter/lib/src/facts/linux/uptime_resolver.cc +15 -0
- data/ext/facter/facter/lib/src/facts/linux/virtualization_resolver.cc +282 -0
- data/ext/facter/facter/lib/src/facts/map_value.cc +119 -0
- data/ext/facter/facter/lib/src/facts/openbsd/collection.cc +37 -0
- data/ext/facter/facter/lib/src/facts/openbsd/dmi_resolver.cc +47 -0
- data/ext/facter/facter/lib/src/facts/openbsd/memory_resolver.cc +76 -0
- data/ext/facter/facter/lib/src/facts/openbsd/networking_resolver.cc +55 -0
- data/ext/facter/facter/lib/src/facts/openbsd/processor_resolver.cc +59 -0
- data/ext/facter/facter/lib/src/facts/openbsd/virtualization_resolver.cc +20 -0
- data/ext/facter/facter/lib/src/facts/osx/collection.cc +39 -0
- data/ext/facter/facter/lib/src/facts/osx/dmi_resolver.cc +32 -0
- data/ext/facter/facter/lib/src/facts/osx/memory_resolver.cc +60 -0
- data/ext/facter/facter/lib/src/facts/osx/networking_resolver.cc +71 -0
- data/ext/facter/facter/lib/src/facts/osx/operating_system_resolver.cc +49 -0
- data/ext/facter/facter/lib/src/facts/osx/processor_resolver.cc +55 -0
- data/ext/facter/facter/lib/src/facts/osx/system_profiler_resolver.cc +66 -0
- data/ext/facter/facter/lib/src/facts/osx/virtualization_resolver.cc +46 -0
- data/ext/facter/facter/lib/src/facts/posix/cache.cc +9 -0
- data/ext/facter/facter/lib/src/facts/posix/collection.cc +48 -0
- data/ext/facter/facter/lib/src/facts/posix/identity_resolver.cc +79 -0
- data/ext/facter/facter/lib/src/facts/posix/kernel_resolver.cc +25 -0
- data/ext/facter/facter/lib/src/facts/posix/networking_resolver.cc +136 -0
- data/ext/facter/facter/lib/src/facts/posix/operatingsystem_resolver.cc +29 -0
- data/ext/facter/facter/lib/src/facts/posix/processor_resolver.cc +22 -0
- data/ext/facter/facter/lib/src/facts/posix/ssh_resolver.cc +116 -0
- data/ext/facter/facter/lib/src/facts/posix/timezone_resolver.cc +26 -0
- data/ext/facter/facter/lib/src/facts/posix/uptime_resolver.cc +53 -0
- data/ext/facter/facter/lib/src/facts/posix/xen_resolver.cc +43 -0
- data/ext/facter/facter/lib/src/facts/resolver.cc +105 -0
- data/ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc +56 -0
- data/ext/facter/facter/lib/src/facts/resolvers/disk_resolver.cc +69 -0
- data/ext/facter/facter/lib/src/facts/resolvers/dmi_resolver.cc +160 -0
- data/ext/facter/facter/lib/src/facts/resolvers/ec2_resolver.cc +174 -0
- data/ext/facter/facter/lib/src/facts/resolvers/filesystem_resolver.cc +118 -0
- data/ext/facter/facter/lib/src/facts/resolvers/fips_resolver.cc +23 -0
- data/ext/facter/facter/lib/src/facts/resolvers/gce_resolver.cc +276 -0
- data/ext/facter/facter/lib/src/facts/resolvers/hypervisors_resolver.cc +76 -0
- data/ext/facter/facter/lib/src/facts/resolvers/identity_resolver.cc +50 -0
- data/ext/facter/facter/lib/src/facts/resolvers/kernel_resolver.cc +62 -0
- data/ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc +60 -0
- data/ext/facter/facter/lib/src/facts/resolvers/load_average_resolver.cc +36 -0
- data/ext/facter/facter/lib/src/facts/resolvers/memory_resolver.cc +88 -0
- data/ext/facter/facter/lib/src/facts/resolvers/networking_resolver.cc +280 -0
- data/ext/facter/facter/lib/src/facts/resolvers/operating_system_resolver.cc +276 -0
- data/ext/facter/facter/lib/src/facts/resolvers/path_resolver.cc +25 -0
- data/ext/facter/facter/lib/src/facts/resolvers/processor_resolver.cc +70 -0
- data/ext/facter/facter/lib/src/facts/resolvers/ruby_resolver.cc +109 -0
- data/ext/facter/facter/lib/src/facts/resolvers/ssh_resolver.cc +77 -0
- data/ext/facter/facter/lib/src/facts/resolvers/system_profiler_resolver.cc +137 -0
- data/ext/facter/facter/lib/src/facts/resolvers/timezone_resolver.cc +27 -0
- data/ext/facter/facter/lib/src/facts/resolvers/uptime_resolver.cc +63 -0
- data/ext/facter/facter/lib/src/facts/resolvers/virtualization_resolver.cc +119 -0
- data/ext/facter/facter/lib/src/facts/resolvers/xen_resolver.cc +80 -0
- data/ext/facter/facter/lib/src/facts/resolvers/zfs_resolver.cc +63 -0
- data/ext/facter/facter/lib/src/facts/resolvers/zone_resolver.cc +91 -0
- data/ext/facter/facter/lib/src/facts/resolvers/zpool_resolver.cc +93 -0
- data/ext/facter/facter/lib/src/facts/scalar_value.cc +73 -0
- data/ext/facter/facter/lib/src/facts/solaris/collection.cc +51 -0
- data/ext/facter/facter/lib/src/facts/solaris/disk_resolver.cc +35 -0
- data/ext/facter/facter/lib/src/facts/solaris/dmi_resolver.cc +86 -0
- data/ext/facter/facter/lib/src/facts/solaris/filesystem_resolver.cc +92 -0
- data/ext/facter/facter/lib/src/facts/solaris/kernel_resolver.cc +24 -0
- data/ext/facter/facter/lib/src/facts/solaris/ldom_resolver.cc +87 -0
- data/ext/facter/facter/lib/src/facts/solaris/memory_resolver.cc +91 -0
- data/ext/facter/facter/lib/src/facts/solaris/networking_resolver.cc +183 -0
- data/ext/facter/facter/lib/src/facts/solaris/operating_system_resolver.cc +83 -0
- data/ext/facter/facter/lib/src/facts/solaris/processor_resolver.cc +105 -0
- data/ext/facter/facter/lib/src/facts/solaris/virtualization_resolver.cc +38 -0
- data/ext/facter/facter/lib/src/facts/solaris/zfs_resolver.cc +12 -0
- data/ext/facter/facter/lib/src/facts/solaris/zone_resolver.cc +33 -0
- data/ext/facter/facter/lib/src/facts/solaris/zpool_resolver.cc +12 -0
- data/ext/facter/facter/lib/src/facts/windows/cache.cc +11 -0
- data/ext/facter/facter/lib/src/facts/windows/collection.cc +91 -0
- data/ext/facter/facter/lib/src/facts/windows/dmi_resolver.cc +38 -0
- data/ext/facter/facter/lib/src/facts/windows/identity_resolver.cc +46 -0
- data/ext/facter/facter/lib/src/facts/windows/kernel_resolver.cc +78 -0
- data/ext/facter/facter/lib/src/facts/windows/memory_resolver.cc +25 -0
- data/ext/facter/facter/lib/src/facts/windows/networking_resolver.cc +227 -0
- data/ext/facter/facter/lib/src/facts/windows/operating_system_resolver.cc +125 -0
- data/ext/facter/facter/lib/src/facts/windows/processor_resolver.cc +99 -0
- data/ext/facter/facter/lib/src/facts/windows/timezone_resolver.cc +28 -0
- data/ext/facter/facter/lib/src/facts/windows/uptime_resolver.cc +26 -0
- data/ext/facter/facter/lib/src/facts/windows/virtualization_resolver.cc +63 -0
- data/ext/facter/facter/lib/src/java/facter.cc +185 -0
- data/ext/facter/facter/lib/src/logging/logging.cc +151 -0
- data/ext/facter/facter/lib/src/ruby/aggregate_resolution.cc +249 -0
- data/ext/facter/facter/lib/src/ruby/chunk.cc +136 -0
- data/ext/facter/facter/lib/src/ruby/confine.cc +84 -0
- data/ext/facter/facter/lib/src/ruby/fact.cc +382 -0
- data/ext/facter/facter/lib/src/ruby/module.cc +1130 -0
- data/ext/facter/facter/lib/src/ruby/resolution.cc +230 -0
- data/ext/facter/facter/lib/src/ruby/ruby.cc +150 -0
- data/ext/facter/facter/lib/src/ruby/ruby_value.cc +288 -0
- data/ext/facter/facter/lib/src/ruby/simple_resolution.cc +156 -0
- data/ext/facter/facter/lib/src/util/bsd/scoped_ifaddrs.cc +29 -0
- data/ext/facter/facter/lib/src/util/config/config.cc +83 -0
- data/ext/facter/facter/lib/src/util/config/posix/config.cc +12 -0
- data/ext/facter/facter/lib/src/util/config/windows/config.cc +14 -0
- data/ext/facter/facter/lib/src/util/posix/scoped_addrinfo.cc +41 -0
- data/ext/facter/facter/lib/src/util/posix/scoped_bio.cc +29 -0
- data/ext/facter/facter/lib/src/util/posix/scoped_descriptor.cc +20 -0
- data/ext/facter/facter/lib/src/util/scoped_file.cc +26 -0
- data/ext/facter/facter/lib/src/util/solaris/k_stat.cc +165 -0
- data/ext/facter/facter/lib/src/util/solaris/scoped_kstat.cc +31 -0
- data/ext/facter/facter/lib/src/util/string.cc +170 -0
- data/ext/facter/facter/lib/src/util/windows/wsa.cc +69 -0
- data/ext/facter/facter/lib/src/util/yaml.cc +72 -0
- data/ext/facter/facter/lib/tasks/spec.rake +26 -0
- data/ext/facter/facter/lib/tests/CMakeLists.txt +172 -0
- data/ext/facter/facter/lib/tests/collection_fixture.cc +15 -0
- data/ext/facter/facter/lib/tests/collection_fixture.hpp +19 -0
- data/ext/facter/facter/lib/tests/cwrapper.cc +22 -0
- data/ext/facter/facter/lib/tests/facts/array_value.cc +140 -0
- data/ext/facter/facter/lib/tests/facts/boolean_value.cc +67 -0
- data/ext/facter/facter/lib/tests/facts/cache.cc +100 -0
- data/ext/facter/facter/lib/tests/facts/collection.cc +576 -0
- data/ext/facter/facter/lib/tests/facts/double_value.cc +40 -0
- data/ext/facter/facter/lib/tests/facts/external/json_resolver.cc +62 -0
- data/ext/facter/facter/lib/tests/facts/external/posix/execution_resolver.cc +69 -0
- data/ext/facter/facter/lib/tests/facts/external/text_resolver.cc +46 -0
- data/ext/facter/facter/lib/tests/facts/external/windows/execution_resolver.cc +69 -0
- data/ext/facter/facter/lib/tests/facts/external/windows/powershell_resolver.cc +122 -0
- data/ext/facter/facter/lib/tests/facts/external/yaml_resolver.cc +70 -0
- data/ext/facter/facter/lib/tests/facts/integer_value.cc +69 -0
- data/ext/facter/facter/lib/tests/facts/linux/dmi_resolver.cc +116 -0
- data/ext/facter/facter/lib/tests/facts/linux/filesystem_resolver.cc +13 -0
- data/ext/facter/facter/lib/tests/facts/linux/processor_fixture.cc +259 -0
- data/ext/facter/facter/lib/tests/facts/linux/processor_fixture.hpp +77 -0
- data/ext/facter/facter/lib/tests/facts/linux/processor_resolver.cc +312 -0
- data/ext/facter/facter/lib/tests/facts/linux/virtualization_resolver.cc +48 -0
- data/ext/facter/facter/lib/tests/facts/map_value.cc +116 -0
- data/ext/facter/facter/lib/tests/facts/posix/collection.cc +39 -0
- data/ext/facter/facter/lib/tests/facts/posix/uptime_resolver.cc +52 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/augeas_resolver.cc +58 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/disk_resolver.cc +114 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/dmi_resolver.cc +152 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/filesystem_resolver.cc +206 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/identity_resolver.cc +83 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/kernel_resolver.cc +61 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/ldom_resolver.cc +86 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/memory_resolver.cc +135 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/networking_resolver.cc +507 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/operating_system_resolver.cc +247 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/processor_resolver.cc +157 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/ruby_resolver.cc +74 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/ssh_resolver.cc +103 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/system_profiler_resolver.cc +135 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/timezone_resolver.cc +49 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/uptime_resolver.cc +151 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/virtualization_resolver.cc +175 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/xen_resolver.cc +100 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc +65 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/zone_resolver.cc +122 -0
- data/ext/facter/facter/lib/tests/facts/resolvers/zpool_resolver.cc +69 -0
- data/ext/facter/facter/lib/tests/facts/schema.cc +796 -0
- data/ext/facter/facter/lib/tests/facts/string_value.cc +270 -0
- data/ext/facter/facter/lib/tests/facts/windows/collection.cc +60 -0
- data/ext/facter/facter/lib/tests/facts/windows/networking_resolver.cc +217 -0
- data/ext/facter/facter/lib/tests/fixtures.cc +62 -0
- data/ext/facter/facter/lib/tests/fixtures.hpp.in +27 -0
- data/ext/facter/facter/lib/tests/fixtures/execution/with space/command_with_space.bat +2 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/json/facts.json +12 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/json/invalid.json +1 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/ordering/bar/foo.yaml +1 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/ordering/foo/foo.yaml +1 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/posix/execution/error_message +4 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/posix/execution/facts +5 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/posix/execution/failed +3 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/posix/execution/not_executable +1 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/text/facts.txt +4 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/windows/execution/error_message.bat +4 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/windows/execution/facts.bat +4 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/windows/execution/failed.cmd +2 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/windows/execution/not_executable +1 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/windows/execution/ruby_script.rb +1 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/windows/powershell/error_message.ps1 +3 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/windows/powershell/facts.ps1 +4 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/windows/powershell/failed.ps1 +2 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/windows/powershell/json.ps1 +21 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/windows/powershell/not_executable +1 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/windows/powershell/yaml.ps1 +18 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/yaml/facts.yaml +15 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/yaml/invalid.yaml +1 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/z/303/266/facts.rb +3 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/external/z/303/266/facts.txt +1 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/linux/cloud/azure +3 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/linux/cloud/azure-unknown +3 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/linux/cloud/not-azure +0 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/linux/dmidecode/full.txt +83 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/linux/dmidecode/full_alternative.txt +83 -0
- data/ext/facter/facter/lib/tests/fixtures/facts/linux/dmidecode/none.txt +2 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/100_resolutions.rb +7 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/101_resolutions.rb +7 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/aggregate.rb +9 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/aggregate_invalid_require.rb +9 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/aggregate_with_block.rb +30 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/aggregate_with_cycle.rb +9 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/aggregate_with_invalid_merge.rb +13 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/aggregate_with_merge.rb +23 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/aggregate_with_require.rb +16 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/array_confine.rb +6 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/array_fact.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/bad_command.rb +19 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/bad_syntax.rb +2 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/bignum_fact_value.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/block_confine.rb +9 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/block_false_confine.rb +9 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/block_nil_confine.rb +9 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/block_true_confine.rb +9 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/boolean_false_confine.rb +6 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/boolean_false_fact.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/boolean_true_confine.rb +6 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/boolean_true_fact.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/command_with_space.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/confine_missing_fact.rb +22 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/confine_weight.rb +20 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/custom_dir/expect_network_init.rb +15 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/cycle.rb +7 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/debug.rb +7 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/debugging.rb +14 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/debugonce.rb +9 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/define_aggregate_fact.rb +13 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/define_fact.rb +9 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/double_fact.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/empty_command.rb +3 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/empty_fact.rb +1 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/empty_fact_with_value.rb +1 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/empty_setcode_command.rb +3 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/exec.rb +7 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/execute_on_fail_raise.rb +17 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/execute_on_fail_value.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/execute_timeout.rb +1 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/execution_failure.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/existing_aggregate_resolution.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/existing_simple_resolution.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/fact.rb +7 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/facter.rb +7 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/facterversion.rb +17 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/hash_fact.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/hash_with_non_string_key.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/integer_fact.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/log_exception.rb +21 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/lookup.rb +7 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/multi_confine.rb +6 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/named_resolution.rb +13 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/negative_number.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/nil_fact.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/nonexistent_command.rb +21 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/on_message.rb +16 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/range_confine.rb +6 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/regexp_confine.rb +6 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/ruby.rb +6 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/simple.rb +11 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/simple_command.rb +7 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/simple_confine.rb +6 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/simple_resolution.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/single_allocation.rb +7 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/stderr_output.rb +9 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/string_fact.rb +5 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/timeout.rb +10 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/trace.rb +22 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/uni/341/220/201dir/customfacts/342/204/242.rb +6 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/uses_exit_code.rb +7 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/value.rb +6 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/version.rb +2 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/warn.rb +7 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/warnonce.rb +9 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/weight.rb +20 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/weight_option.rb +17 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/which.rb +9 -0
- data/ext/facter/facter/lib/tests/fixtures/ruby/windows/ole.rb +7 -0
- data/ext/facter/facter/lib/tests/java/facter.cc +69 -0
- data/ext/facter/facter/lib/tests/log_capture.cc +29 -0
- data/ext/facter/facter/lib/tests/log_capture.hpp +35 -0
- data/ext/facter/facter/lib/tests/logging/logging.cc +69 -0
- data/ext/facter/facter/lib/tests/main.cc +20 -0
- data/ext/facter/facter/lib/tests/mock_server.cc +44 -0
- data/ext/facter/facter/lib/tests/mock_server.hpp +25 -0
- data/ext/facter/facter/lib/tests/ruby/ruby.cc +634 -0
- data/ext/facter/facter/lib/tests/ruby/ruby_dirfacts.cc +35 -0
- data/ext/facter/facter/lib/tests/ruby/ruby_helper.cc +41 -0
- data/ext/facter/facter/lib/tests/ruby/ruby_helper.hpp +8 -0
- data/ext/facter/facter/lib/tests/ruby/windows/ruby.cc +53 -0
- data/ext/facter/facter/lib/tests/util/bsd/scoped_ifaddrs.cc +10 -0
- data/ext/facter/facter/lib/tests/util/posix/scoped_addrinfo.cc +11 -0
- data/ext/facter/facter/lib/tests/util/posix/scoped_bio.cc +12 -0
- data/ext/facter/facter/lib/tests/util/posix/scoped_descriptor.cc +22 -0
- data/ext/facter/facter/lib/tests/util/string.cc +291 -0
- data/ext/facter/facter/lib/version.h.in +28 -0
- data/ext/facter/facter/locales/CMakeLists.txt +7 -0
- data/ext/facter/facter/locales/FACTER.pot +1508 -0
- data/ext/facter/facter/man/man8/facter.8 +205 -0
- data/ext/facter/facter/scripts/cpplint.py +4754 -0
- data/ext/facter/facter/scripts/travis_target.sh +83 -0
- data/ext/facter/facter/tasks/ci.rake +22 -0
- data/ext/facter/leatherman/CHANGELOG.md +430 -0
- data/ext/facter/leatherman/CMakeLists.txt +143 -0
- data/ext/facter/leatherman/CONTRIBUTING.md +98 -0
- data/ext/facter/leatherman/LICENSE +17 -0
- data/ext/facter/leatherman/LeathermanConfig.cmake.in +57 -0
- data/ext/facter/leatherman/LeathermanConfigVersion.cmake.in +11 -0
- data/ext/facter/leatherman/MAINTAINERS +28 -0
- data/ext/facter/leatherman/README.md +416 -0
- data/ext/facter/leatherman/appveyor.yml +47 -0
- data/ext/facter/leatherman/catch/CMakeLists.txt +1 -0
- data/ext/facter/leatherman/cmake/FindICU.cmake +690 -0
- data/ext/facter/leatherman/cmake/GetGitRevisionDescription.cmake +130 -0
- data/ext/facter/leatherman/cmake/GetGitRevisionDescription.cmake.in +38 -0
- data/ext/facter/leatherman/cmake/cflags.cmake +110 -0
- data/ext/facter/leatherman/cmake/generate_translations.cmake +17 -0
- data/ext/facter/leatherman/cmake/internal.cmake +241 -0
- data/ext/facter/leatherman/cmake/leatherman.cmake.in +369 -0
- data/ext/facter/leatherman/cmake/leatherman_config.cmake +80 -0
- data/ext/facter/leatherman/cmake/normalize_pot.cmake +17 -0
- data/ext/facter/leatherman/cmake/options.cmake +21 -0
- data/ext/facter/leatherman/cmake/pod2man.cmake +36 -0
- data/ext/facter/leatherman/curl/CMakeLists.txt +42 -0
- data/ext/facter/leatherman/curl/inc/leatherman/curl/client.hpp +441 -0
- data/ext/facter/leatherman/curl/inc/leatherman/curl/request.hpp +130 -0
- data/ext/facter/leatherman/curl/inc/leatherman/curl/response.hpp +80 -0
- data/ext/facter/leatherman/curl/src/client.cc +575 -0
- data/ext/facter/leatherman/curl/src/request.cc +112 -0
- data/ext/facter/leatherman/curl/src/response.cc +62 -0
- data/ext/facter/leatherman/curl/tests/CMakeLists.txt +22 -0
- data/ext/facter/leatherman/curl/tests/client_test.cc +613 -0
- data/ext/facter/leatherman/curl/tests/fixtures.cc +27 -0
- data/ext/facter/leatherman/curl/tests/fixtures.hpp +31 -0
- data/ext/facter/leatherman/curl/tests/mock_curl.cc +423 -0
- data/ext/facter/leatherman/curl/tests/mock_curl.hpp +85 -0
- data/ext/facter/leatherman/curl/tests/request_test.cc +85 -0
- data/ext/facter/leatherman/curl/tests/response_test.cc +58 -0
- data/ext/facter/leatherman/dynamic_library/CMakeLists.txt +43 -0
- data/ext/facter/leatherman/dynamic_library/inc/leatherman/dynamic_library/dynamic_library.hpp +122 -0
- data/ext/facter/leatherman/dynamic_library/src/dynamic_library.cc +57 -0
- data/ext/facter/leatherman/dynamic_library/src/posix/dynamic_library.cc +91 -0
- data/ext/facter/leatherman/dynamic_library/src/windows/dynamic_library.cc +128 -0
- data/ext/facter/leatherman/dynamic_library/tests/dynamic_library_tests.cc +94 -0
- data/ext/facter/leatherman/dynamic_library/tests/fixtures.hpp.in +3 -0
- data/ext/facter/leatherman/dynamic_library/tests/test-lib/goodbye.cc +5 -0
- data/ext/facter/leatherman/dynamic_library/tests/test-lib/hello.cc +7 -0
- data/ext/facter/leatherman/execution/CMakeLists.txt +65 -0
- data/ext/facter/leatherman/execution/inc/leatherman/execution/execution.hpp +488 -0
- data/ext/facter/leatherman/execution/src/execution.cc +510 -0
- data/ext/facter/leatherman/execution/src/posix/execution.cc +574 -0
- data/ext/facter/leatherman/execution/src/posix/generic/platform.cc +30 -0
- data/ext/facter/leatherman/execution/src/posix/platform.hpp +15 -0
- data/ext/facter/leatherman/execution/src/posix/solaris/platform.cc +197 -0
- data/ext/facter/leatherman/execution/src/windows/execution.cc +698 -0
- data/ext/facter/leatherman/execution/tests/fixtures.hpp.in +2 -0
- data/ext/facter/leatherman/execution/tests/fixtures/echo_pid +2 -0
- data/ext/facter/leatherman/execution/tests/fixtures/error_message +5 -0
- data/ext/facter/leatherman/execution/tests/fixtures/execution/selfkill.sh +3 -0
- data/ext/facter/leatherman/execution/tests/fixtures/execution/sleep.sh +3 -0
- data/ext/facter/leatherman/execution/tests/fixtures/facts +5 -0
- data/ext/facter/leatherman/execution/tests/fixtures/failed +3 -0
- data/ext/facter/leatherman/execution/tests/fixtures/ls/crlf.txt +3 -0
- data/ext/facter/leatherman/execution/tests/fixtures/ls/file1.txt +1 -0
- data/ext/facter/leatherman/execution/tests/fixtures/ls/file2.txt +1 -0
- data/ext/facter/leatherman/execution/tests/fixtures/ls/file3.txt +1 -0
- data/ext/facter/leatherman/execution/tests/fixtures/ls/file4.txt +7 -0
- data/ext/facter/leatherman/execution/tests/fixtures/not_executable +1 -0
- data/ext/facter/leatherman/execution/tests/fixtures/windows/error_message.bat +6 -0
- data/ext/facter/leatherman/execution/tests/fixtures/windows/facts.bat +4 -0
- data/ext/facter/leatherman/execution/tests/fixtures/windows/failed.cmd +2 -0
- data/ext/facter/leatherman/execution/tests/fixtures/windows/not_executable +1 -0
- data/ext/facter/leatherman/execution/tests/fixtures/windows/ruby_script.rb +1 -0
- data/ext/facter/leatherman/execution/tests/log_capture.cc +29 -0
- data/ext/facter/leatherman/execution/tests/log_capture.hpp +35 -0
- data/ext/facter/leatherman/execution/tests/lth_cat.cc +38 -0
- data/ext/facter/leatherman/execution/tests/lth_cat.hpp +9 -0
- data/ext/facter/leatherman/execution/tests/posix/execution.cc +728 -0
- data/ext/facter/leatherman/execution/tests/posix/solaris/execution.cc +54 -0
- data/ext/facter/leatherman/execution/tests/windows/execution.cc +789 -0
- data/ext/facter/leatherman/file_util/CMakeLists.txt +18 -0
- data/ext/facter/leatherman/file_util/inc/leatherman/file_util/directory.hpp +28 -0
- data/ext/facter/leatherman/file_util/inc/leatherman/file_util/file.hpp +95 -0
- data/ext/facter/leatherman/file_util/src/directory.cc +51 -0
- data/ext/facter/leatherman/file_util/src/file.cc +131 -0
- data/ext/facter/leatherman/file_util/tests/directory_utils_test.cc +87 -0
- data/ext/facter/leatherman/file_util/tests/file_utils_test.cc +195 -0
- data/ext/facter/leatherman/file_util/tests/fixtures.cc +37 -0
- data/ext/facter/leatherman/file_util/tests/fixtures.hpp +39 -0
- data/ext/facter/leatherman/json_container/CMakeLists.txt +11 -0
- data/ext/facter/leatherman/json_container/README.md +108 -0
- data/ext/facter/leatherman/json_container/inc/leatherman/json_container/json_container.hpp +443 -0
- data/ext/facter/leatherman/json_container/src/json_container.cc +655 -0
- data/ext/facter/leatherman/json_container/tests/json_container_test.cc +1129 -0
- data/ext/facter/leatherman/locale/CMakeLists.txt +46 -0
- data/ext/facter/leatherman/locale/disabled/locale.cc +38 -0
- data/ext/facter/leatherman/locale/inc/leatherman/locale/locale.hpp +263 -0
- data/ext/facter/leatherman/locale/locales/CMakeLists.txt +6 -0
- data/ext/facter/leatherman/locale/locales/fr.po +40 -0
- data/ext/facter/leatherman/locale/locales/leatherman_locale.pot +41 -0
- data/ext/facter/leatherman/locale/src/locale.cc +95 -0
- data/ext/facter/leatherman/locale/tests/format.cc +117 -0
- data/ext/facter/leatherman/locale/tests/locale.cc +190 -0
- data/ext/facter/leatherman/locales/CMakeLists.txt +7 -0
- data/ext/facter/leatherman/locales/leatherman.pot +717 -0
- data/ext/facter/leatherman/logging/CMakeLists.txt +43 -0
- data/ext/facter/leatherman/logging/inc/leatherman/logging/logging.hpp +264 -0
- data/ext/facter/leatherman/logging/locales/CMakeLists.txt +6 -0
- data/ext/facter/leatherman/logging/locales/fr.po +72 -0
- data/ext/facter/leatherman/logging/locales/leatherman_logging.pot +72 -0
- data/ext/facter/leatherman/logging/src/logging.cc +229 -0
- data/ext/facter/leatherman/logging/src/posix/logging.cc +39 -0
- data/ext/facter/leatherman/logging/src/windows/logging.cc +52 -0
- data/ext/facter/leatherman/logging/tests/logging.cc +118 -0
- data/ext/facter/leatherman/logging/tests/logging.hpp +88 -0
- data/ext/facter/leatherman/logging/tests/logging_i18n.cc +103 -0
- data/ext/facter/leatherman/logging/tests/logging_on_message.cc +61 -0
- data/ext/facter/leatherman/logging/tests/logging_stream.cc +159 -0
- data/ext/facter/leatherman/logging/tests/logging_stream_lines.cc +172 -0
- data/ext/facter/leatherman/logging/tests/posix/logging.cc +23 -0
- data/ext/facter/leatherman/logging/tests/windows/logging.cc +13 -0
- data/ext/facter/leatherman/nowide/CMakeLists.txt +7 -0
- data/ext/facter/leatherman/rapidjson/CMakeLists.txt +1 -0
- data/ext/facter/leatherman/ruby/CMakeLists.txt +26 -0
- data/ext/facter/leatherman/ruby/inc/leatherman/ruby/api.hpp +744 -0
- data/ext/facter/leatherman/ruby/src/api.cc +527 -0
- data/ext/facter/leatherman/ruby/src/posix/api.cc +14 -0
- data/ext/facter/leatherman/ruby/src/windows/api.cc +20 -0
- data/ext/facter/leatherman/ruby/tests/api-test.cc +206 -0
- data/ext/facter/leatherman/scripts/cpplint.py +6323 -0
- data/ext/facter/leatherman/tests/CMakeLists.txt +22 -0
- data/ext/facter/leatherman/tests/main.cc +17 -0
- data/ext/facter/leatherman/util/CMakeLists.txt +36 -0
- data/ext/facter/leatherman/util/inc/leatherman/util/environment.hpp +69 -0
- data/ext/facter/leatherman/util/inc/leatherman/util/option_set.hpp +228 -0
- data/ext/facter/leatherman/util/inc/leatherman/util/posix/scoped_descriptor.hpp +32 -0
- data/ext/facter/leatherman/util/inc/leatherman/util/regex.hpp +80 -0
- data/ext/facter/leatherman/util/inc/leatherman/util/scope_exit.hpp +62 -0
- data/ext/facter/leatherman/util/inc/leatherman/util/scoped_env.hpp +35 -0
- data/ext/facter/leatherman/util/inc/leatherman/util/scoped_resource.hpp +130 -0
- data/ext/facter/leatherman/util/inc/leatherman/util/strings.hpp +54 -0
- data/ext/facter/leatherman/util/inc/leatherman/util/time.hpp +36 -0
- data/ext/facter/leatherman/util/inc/leatherman/util/timer.hpp +43 -0
- data/ext/facter/leatherman/util/inc/leatherman/util/uri.hpp +23 -0
- data/ext/facter/leatherman/util/inc/leatherman/util/windows/scoped_handle.hpp +32 -0
- data/ext/facter/leatherman/util/src/environment.cc +29 -0
- data/ext/facter/leatherman/util/src/posix/environment.cc +75 -0
- data/ext/facter/leatherman/util/src/posix/scoped_descriptor.cc +23 -0
- data/ext/facter/leatherman/util/src/posix/time.cc +9 -0
- data/ext/facter/leatherman/util/src/scope_exit.cc +43 -0
- data/ext/facter/leatherman/util/src/scoped_env.cc +37 -0
- data/ext/facter/leatherman/util/src/strings.cc +41 -0
- data/ext/facter/leatherman/util/src/time.cc +49 -0
- data/ext/facter/leatherman/util/src/uri.cc +75 -0
- data/ext/facter/leatherman/util/src/windows/environment.cc +75 -0
- data/ext/facter/leatherman/util/src/windows/scoped_handle.cc +24 -0
- data/ext/facter/leatherman/util/src/windows/time.cc +10 -0
- data/ext/facter/leatherman/util/tests/environment.cc +90 -0
- data/ext/facter/leatherman/util/tests/option_set.cc +234 -0
- data/ext/facter/leatherman/util/tests/posix/environment.cc +36 -0
- data/ext/facter/leatherman/util/tests/scoped_env.cc +52 -0
- data/ext/facter/leatherman/util/tests/strings_test.cc +71 -0
- data/ext/facter/leatherman/util/tests/timer.cc +39 -0
- data/ext/facter/leatherman/util/tests/uri.cc +104 -0
- data/ext/facter/leatherman/util/tests/windows/environment.cc +30 -0
- data/ext/facter/leatherman/vendor/Catch-1.10.0.zip +0 -0
- data/ext/facter/leatherman/vendor/nowide/build/Jamfile.v2 +26 -0
- data/ext/facter/leatherman/vendor/nowide/doc/Doxyfile +1632 -0
- data/ext/facter/leatherman/vendor/nowide/doc/LICENSE_1_0.txt +23 -0
- data/ext/facter/leatherman/vendor/nowide/doc/gendoc.sh +11 -0
- data/ext/facter/leatherman/vendor/nowide/doc/main.txt +354 -0
- data/ext/facter/leatherman/vendor/nowide/include/boost/nowide/args.hpp +167 -0
- data/ext/facter/leatherman/vendor/nowide/include/boost/nowide/cenv.hpp +126 -0
- data/ext/facter/leatherman/vendor/nowide/include/boost/nowide/config.hpp +54 -0
- data/ext/facter/leatherman/vendor/nowide/include/boost/nowide/convert.hpp +154 -0
- data/ext/facter/leatherman/vendor/nowide/include/boost/nowide/cstdio.hpp +101 -0
- data/ext/facter/leatherman/vendor/nowide/include/boost/nowide/cstdlib.hpp +16 -0
- data/ext/facter/leatherman/vendor/nowide/include/boost/nowide/filebuf.hpp +415 -0
- data/ext/facter/leatherman/vendor/nowide/include/boost/nowide/fstream.hpp +283 -0
- data/ext/facter/leatherman/vendor/nowide/include/boost/nowide/integration/filesystem.hpp +28 -0
- data/ext/facter/leatherman/vendor/nowide/include/boost/nowide/iostream.hpp +99 -0
- data/ext/facter/leatherman/vendor/nowide/include/boost/nowide/stackstring.hpp +154 -0
- data/ext/facter/leatherman/vendor/nowide/include/boost/nowide/system.hpp +46 -0
- data/ext/facter/leatherman/vendor/nowide/include/boost/nowide/utf8_codecvt.hpp +499 -0
- data/ext/facter/leatherman/vendor/nowide/include/boost/nowide/windows.hpp +39 -0
- data/ext/facter/leatherman/vendor/nowide/index.html +16 -0
- data/ext/facter/leatherman/vendor/nowide/src/iostream.cpp +263 -0
- data/ext/facter/leatherman/vendor/nowide/standalone/CMakeLists.txt +104 -0
- data/ext/facter/leatherman/vendor/nowide/standalone/MinGW.cmake +9 -0
- data/ext/facter/leatherman/vendor/nowide/standalone/config.hpp +37 -0
- data/ext/facter/leatherman/vendor/nowide/standalone/convert +34 -0
- data/ext/facter/leatherman/vendor/nowide/standalone/encoding_errors.hpp +58 -0
- data/ext/facter/leatherman/vendor/nowide/standalone/encoding_utf.hpp +84 -0
- data/ext/facter/leatherman/vendor/nowide/standalone/run_convert_and_build.sh +17 -0
- data/ext/facter/leatherman/vendor/nowide/standalone/scoped_ptr.hpp +93 -0
- data/ext/facter/leatherman/vendor/nowide/standalone/utf.hpp +469 -0
- data/ext/facter/leatherman/vendor/nowide/template.hpp +19 -0
- data/ext/facter/leatherman/vendor/nowide/test/Jamfile.v2 +43 -0
- data/ext/facter/leatherman/vendor/nowide/test/test.hpp +25 -0
- data/ext/facter/leatherman/vendor/nowide/test/test_codecvt.cpp +254 -0
- data/ext/facter/leatherman/vendor/nowide/test/test_convert.cpp +101 -0
- data/ext/facter/leatherman/vendor/nowide/test/test_env.cpp +49 -0
- data/ext/facter/leatherman/vendor/nowide/test/test_fs.cpp +48 -0
- data/ext/facter/leatherman/vendor/nowide/test/test_fstream.cpp +184 -0
- data/ext/facter/leatherman/vendor/nowide/test/test_iostream.cpp +52 -0
- data/ext/facter/leatherman/vendor/nowide/test/test_stdio.cpp +60 -0
- data/ext/facter/leatherman/vendor/nowide/test/test_system.cpp +91 -0
- data/ext/facter/leatherman/vendor/rapidjson-1.0.2.zip +0 -0
- data/ext/facter/leatherman/windows/CMakeLists.txt +27 -0
- data/ext/facter/leatherman/windows/inc/leatherman/windows/file_util.hpp +23 -0
- data/ext/facter/leatherman/windows/inc/leatherman/windows/process.hpp +22 -0
- data/ext/facter/leatherman/windows/inc/leatherman/windows/registry.hpp +56 -0
- data/ext/facter/leatherman/windows/inc/leatherman/windows/system_error.hpp +23 -0
- data/ext/facter/leatherman/windows/inc/leatherman/windows/user.hpp +30 -0
- data/ext/facter/leatherman/windows/inc/leatherman/windows/windows.hpp +10 -0
- data/ext/facter/leatherman/windows/inc/leatherman/windows/wmi.hpp +188 -0
- data/ext/facter/leatherman/windows/src/file_util.cc +28 -0
- data/ext/facter/leatherman/windows/src/process.cc +42 -0
- data/ext/facter/leatherman/windows/src/registry.cc +96 -0
- data/ext/facter/leatherman/windows/src/system_error.cc +33 -0
- data/ext/facter/leatherman/windows/src/user.cc +76 -0
- data/ext/facter/leatherman/windows/src/wmi.cc +208 -0
- data/ext/facter/leatherman/windows/tests/file_utils_test.cc +13 -0
- metadata +1089 -0
@@ -0,0 +1,1129 @@
|
|
1
|
+
#include <catch.hpp>
|
2
|
+
#include <leatherman/json_container/json_container.hpp>
|
3
|
+
#include <iostream>
|
4
|
+
|
5
|
+
static const std::string JSON = "{\"foo\" : {\"bar\" : 2},"
|
6
|
+
" \"goo\" : 1,"
|
7
|
+
" \"bool\" : true,"
|
8
|
+
" \"string\" : \"a string\","
|
9
|
+
" \"string_with_null\" : \"a string\\u0000with\\u0000null\","
|
10
|
+
" \"null\" : null,"
|
11
|
+
" \"real\" : 3.1415,"
|
12
|
+
" \"vec\" : [1, 2], "
|
13
|
+
" \"string_vec\" : [\"one\", \"two\\u0000null\"], "
|
14
|
+
" \"nested\" : {"
|
15
|
+
" \"foo\" : \"bar\""
|
16
|
+
" }"
|
17
|
+
"}";
|
18
|
+
|
19
|
+
using namespace leatherman::json_container;
|
20
|
+
|
21
|
+
TEST_CASE("JsonContainer::JsonContainer - passing JSON string", "[data]") {
|
22
|
+
std::string json_value {};
|
23
|
+
|
24
|
+
SECTION("it should instantiate by passing any JSON value") {
|
25
|
+
SECTION("object") {
|
26
|
+
json_value = JSON;
|
27
|
+
}
|
28
|
+
|
29
|
+
SECTION("array") {
|
30
|
+
SECTION("of numbers") {
|
31
|
+
json_value = "[1, 2, 3]";
|
32
|
+
}
|
33
|
+
|
34
|
+
SECTION("of booleans") {
|
35
|
+
json_value = "[true, true]";
|
36
|
+
}
|
37
|
+
|
38
|
+
SECTION("of strings") {
|
39
|
+
json_value = "[\"spam\", \"eggs\", \"foo\"]";
|
40
|
+
}
|
41
|
+
|
42
|
+
SECTION("of objects") {
|
43
|
+
json_value = "[" + JSON + ",\n" + JSON + "]";
|
44
|
+
}
|
45
|
+
|
46
|
+
SECTION("of arrays") {
|
47
|
+
json_value = "[[1, 2, 3], [\"spam\", \"eggs\", \"foo\"]]";
|
48
|
+
}
|
49
|
+
|
50
|
+
SECTION("of values of different types") {
|
51
|
+
json_value = "[1, \"spam\",\n" + JSON + "]";
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
SECTION("std::string instance containing an empty JSON string") {
|
56
|
+
json_value = "\"\"";
|
57
|
+
}
|
58
|
+
|
59
|
+
SECTION("string") {
|
60
|
+
json_value = "\"foo\"";
|
61
|
+
}
|
62
|
+
|
63
|
+
SECTION("number - int") {
|
64
|
+
json_value = "42";
|
65
|
+
}
|
66
|
+
|
67
|
+
SECTION("number - float") {
|
68
|
+
json_value = "3.14159";
|
69
|
+
}
|
70
|
+
|
71
|
+
SECTION("boolean - true") {
|
72
|
+
json_value = "true";
|
73
|
+
}
|
74
|
+
|
75
|
+
SECTION("boolean - false") {
|
76
|
+
json_value = "false";
|
77
|
+
}
|
78
|
+
|
79
|
+
SECTION("null") {
|
80
|
+
json_value = "null";
|
81
|
+
}
|
82
|
+
|
83
|
+
REQUIRE_NOTHROW(JsonContainer { json_value });
|
84
|
+
}
|
85
|
+
|
86
|
+
SECTION("it should throw a data_parse_error in case of empty string") {
|
87
|
+
json_value = "";
|
88
|
+
REQUIRE_THROWS_AS(JsonContainer { json_value }, data_parse_error);
|
89
|
+
}
|
90
|
+
|
91
|
+
SECTION("it should throw a data_parse_error in case of invalid JSON") {
|
92
|
+
SECTION("bad object") {
|
93
|
+
json_value = "{\"foo\" : \"bar\", 42}";
|
94
|
+
}
|
95
|
+
|
96
|
+
SECTION("bad key") {
|
97
|
+
json_value = "{42 : \"bar\"}";
|
98
|
+
}
|
99
|
+
|
100
|
+
SECTION("bad array") {
|
101
|
+
json_value = "1, 2, 3";
|
102
|
+
}
|
103
|
+
|
104
|
+
REQUIRE_THROWS_AS(JsonContainer { json_value }, data_parse_error);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
TEST_CASE("JsonContainer::get for object entries", "[data]") {
|
109
|
+
JsonContainer data { JSON };
|
110
|
+
|
111
|
+
SECTION("it can get a root value") {
|
112
|
+
REQUIRE(data.get<int>("goo") == 1);
|
113
|
+
}
|
114
|
+
|
115
|
+
SECTION("it can get a nested value") {
|
116
|
+
REQUIRE(data.get<int>({"foo", "bar"}) == 2);
|
117
|
+
}
|
118
|
+
|
119
|
+
SECTION("it can get a bool value") {
|
120
|
+
REQUIRE(data.get<bool>("bool") == true);
|
121
|
+
}
|
122
|
+
|
123
|
+
SECTION("it can get a string value") {
|
124
|
+
REQUIRE(data.get<std::string>("string") == "a string");
|
125
|
+
}
|
126
|
+
|
127
|
+
SECTION("it can get a string value containing null character(s)") {
|
128
|
+
REQUIRE(data.get<std::string>("string_with_null") == std::string("a string\0with\0null", 18));
|
129
|
+
}
|
130
|
+
|
131
|
+
SECTION("it can get a double value") {
|
132
|
+
REQUIRE(data.get<double>("real") == 3.1415);
|
133
|
+
}
|
134
|
+
|
135
|
+
SECTION("it can get a vector") {
|
136
|
+
std::vector<int> tmp { 1, 2 };
|
137
|
+
std::vector<int> result { data.get<std::vector<int>>("vec") };
|
138
|
+
REQUIRE(tmp.size() == result.size());
|
139
|
+
REQUIRE(tmp[0] == result[0]);
|
140
|
+
REQUIRE(tmp[1] == result[1]);
|
141
|
+
}
|
142
|
+
|
143
|
+
SECTION("it can get a string vector") {
|
144
|
+
std::vector<std::string> tmp { "one", { "two\0null", 8 } };
|
145
|
+
std::vector<std::string> result { data.get<std::vector<std::string>>("string_vec") };
|
146
|
+
REQUIRE(tmp.size() == result.size());
|
147
|
+
REQUIRE(tmp[0] == result[0]);
|
148
|
+
REQUIRE(tmp[1] == result[1]);
|
149
|
+
}
|
150
|
+
|
151
|
+
SECTION("it can get the root object") {
|
152
|
+
REQUIRE(data.get<JsonContainer>().get<int>("goo") == 1);
|
153
|
+
}
|
154
|
+
|
155
|
+
SECTION("it should behave correctly given a null value") {
|
156
|
+
REQUIRE(data.get<std::string>("null") == "");
|
157
|
+
REQUIRE(data.get<int>("null") == 0);
|
158
|
+
REQUIRE(data.get<bool>("null") == false);
|
159
|
+
}
|
160
|
+
|
161
|
+
SECTION("it can get the root entry") {
|
162
|
+
SECTION("array of numbers") {
|
163
|
+
JsonContainer data_array { "[1, 2, 3]" };
|
164
|
+
auto array = data_array.get<std::vector<int>>();
|
165
|
+
std::vector<int> expected_array { 1, 2, 3 };
|
166
|
+
|
167
|
+
REQUIRE(array == expected_array);
|
168
|
+
}
|
169
|
+
|
170
|
+
SECTION("object") {
|
171
|
+
auto object = data.get<JsonContainer>();
|
172
|
+
|
173
|
+
REQUIRE(object.get<int>("goo") == 1);
|
174
|
+
}
|
175
|
+
|
176
|
+
SECTION("number") {
|
177
|
+
JsonContainer data_number { "42" };
|
178
|
+
auto number = data_number.get<int>();
|
179
|
+
|
180
|
+
REQUIRE(number == 42);
|
181
|
+
}
|
182
|
+
}
|
183
|
+
|
184
|
+
SECTION("it throws a data_key_error in case of unknown object entry") {
|
185
|
+
SECTION("unknown root object entry") {
|
186
|
+
REQUIRE_THROWS_AS(data.get<int>("unknown"), data_key_error);
|
187
|
+
}
|
188
|
+
|
189
|
+
SECTION("unknown nested object entry") {
|
190
|
+
REQUIRE_THROWS_AS(data.get<int>({ "nested", "unknown" }),
|
191
|
+
data_key_error);
|
192
|
+
}
|
193
|
+
}
|
194
|
+
|
195
|
+
SECTION("it throws a data_type_error in case of mismatch") {
|
196
|
+
SECTION("root entry") {
|
197
|
+
SECTION("not a boolean") {
|
198
|
+
REQUIRE_THROWS_AS(data.get<bool>("string"), data_type_error);
|
199
|
+
}
|
200
|
+
|
201
|
+
SECTION("not an integer") {
|
202
|
+
REQUIRE_THROWS_AS(data.get<int>("real"), data_type_error);
|
203
|
+
}
|
204
|
+
|
205
|
+
SECTION("not a double") {
|
206
|
+
REQUIRE_THROWS_AS(data.get<double>("goo"), data_type_error);
|
207
|
+
}
|
208
|
+
|
209
|
+
SECTION("not a string") {
|
210
|
+
REQUIRE_THROWS_AS(data.get<std::string>("real"), data_type_error);
|
211
|
+
}
|
212
|
+
|
213
|
+
SECTION("array mismatches") {
|
214
|
+
SECTION("not an array") {
|
215
|
+
REQUIRE_THROWS_AS(data.get<std::vector<int>>("goo"),
|
216
|
+
data_type_error);
|
217
|
+
}
|
218
|
+
|
219
|
+
SECTION("mismatch type on array entry") {
|
220
|
+
REQUIRE_THROWS_AS(data.get<double>("goo"), data_type_error);
|
221
|
+
}
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
SECTION("nested entry") {
|
226
|
+
data.set<JsonContainer>({ "foo", "spam" }, JsonContainer { JSON });
|
227
|
+
|
228
|
+
SECTION("not a boolean") {
|
229
|
+
REQUIRE_THROWS_AS(data.get<bool>({ "foo", "spam", "string" }),
|
230
|
+
data_type_error);
|
231
|
+
}
|
232
|
+
|
233
|
+
SECTION("not an integer") {
|
234
|
+
REQUIRE_THROWS_AS(data.get<int>({ "foo", "spam", "real" }),
|
235
|
+
data_type_error);
|
236
|
+
}
|
237
|
+
|
238
|
+
SECTION("not a double") {
|
239
|
+
REQUIRE_THROWS_AS(data.get<double>({ "foo", "spam", "goo" }),
|
240
|
+
data_type_error);
|
241
|
+
}
|
242
|
+
|
243
|
+
SECTION("not a string") {
|
244
|
+
REQUIRE_THROWS_AS(data.get<std::string>({ "foo", "spam", "real" }),
|
245
|
+
data_type_error);
|
246
|
+
}
|
247
|
+
|
248
|
+
SECTION("array mismatches") {
|
249
|
+
SECTION("not an array") {
|
250
|
+
REQUIRE_THROWS_AS(
|
251
|
+
data.get<std::vector<int>>({ "foo", "spam", "goo" }),
|
252
|
+
data_type_error);
|
253
|
+
}
|
254
|
+
|
255
|
+
SECTION("mismatch type on array entry") {
|
256
|
+
REQUIRE_THROWS_AS(data.get<double>({ "foo", "spam", "goo" }),
|
257
|
+
data_type_error);
|
258
|
+
}
|
259
|
+
}
|
260
|
+
}
|
261
|
+
}
|
262
|
+
|
263
|
+
SECTION("it can always return a JsonContainer instance of an entry") {
|
264
|
+
SECTION("scalars") {
|
265
|
+
SECTION("boolean") {
|
266
|
+
REQUIRE(data.get<JsonContainer>("bool").get<bool>() == true);
|
267
|
+
}
|
268
|
+
|
269
|
+
SECTION("integer") {
|
270
|
+
REQUIRE(data.get<JsonContainer>("goo").get<int>() == 1);
|
271
|
+
}
|
272
|
+
|
273
|
+
SECTION("double") {
|
274
|
+
REQUIRE(data.get<JsonContainer>("real").get<double>() == 3.1415);
|
275
|
+
}
|
276
|
+
|
277
|
+
SECTION("string") {
|
278
|
+
REQUIRE(data.get<JsonContainer>("string").get<std::string>()
|
279
|
+
== "a string");
|
280
|
+
}
|
281
|
+
}
|
282
|
+
|
283
|
+
SECTION("object") {
|
284
|
+
REQUIRE(data.get<JsonContainer>("nested").get<std::string>("foo")
|
285
|
+
== "bar");
|
286
|
+
}
|
287
|
+
|
288
|
+
SECTION("array") {
|
289
|
+
std::vector<int> expected_array {1, 2};
|
290
|
+
REQUIRE(data.get<JsonContainer>("vec").get<std::vector<int>>()
|
291
|
+
== expected_array);
|
292
|
+
}
|
293
|
+
}
|
294
|
+
|
295
|
+
SECTION("it can access array entries") {
|
296
|
+
SECTION("it throws a data_type_error in case of type mismatch") {
|
297
|
+
SECTION("root entry") {
|
298
|
+
JsonContainer a { "[1, 2, 3]" };
|
299
|
+
REQUIRE_THROWS_AS(a.get<std::string>(1), data_type_error);
|
300
|
+
}
|
301
|
+
|
302
|
+
SECTION("object entry") {
|
303
|
+
REQUIRE_THROWS_AS(data.get<std::string>("vec", 1),
|
304
|
+
data_type_error);
|
305
|
+
}
|
306
|
+
}
|
307
|
+
|
308
|
+
SECTION("it throws a data_index_error in case of index out of bounds") {
|
309
|
+
SECTION("root entry") {
|
310
|
+
JsonContainer a { "[1, 2, 3]" };
|
311
|
+
REQUIRE_THROWS_AS(a.get<int>(10), data_index_error);
|
312
|
+
}
|
313
|
+
|
314
|
+
SECTION("object entry") {
|
315
|
+
REQUIRE_THROWS_AS(data.get<int>("vec", 10), data_index_error);
|
316
|
+
}
|
317
|
+
}
|
318
|
+
|
319
|
+
SECTION("it can get a value") {
|
320
|
+
SECTION("boolean") {
|
321
|
+
JsonContainer b { "[false, false, true, false]" };
|
322
|
+
REQUIRE_FALSE(b.get<bool>(3));
|
323
|
+
}
|
324
|
+
|
325
|
+
SECTION("integer") {
|
326
|
+
JsonContainer i { "[1, 2, 3]" };
|
327
|
+
REQUIRE(i.get<int>(1) == 2);
|
328
|
+
}
|
329
|
+
|
330
|
+
SECTION("double") {
|
331
|
+
JsonContainer d { "[3.14, 2.718]" };
|
332
|
+
REQUIRE(d.get<double>(1) == 2.718);
|
333
|
+
}
|
334
|
+
|
335
|
+
SECTION("string") {
|
336
|
+
JsonContainer s { "[\"one\", \"two\"]" };
|
337
|
+
REQUIRE(s.get<std::string>(1) == "two");
|
338
|
+
}
|
339
|
+
|
340
|
+
SECTION("object") {
|
341
|
+
JsonContainer o { "[ {\"spam\":\"eggs\"}, {\"foo\":\"bar\"} ]" };
|
342
|
+
auto retrieved_o = o.get<JsonContainer>(0);
|
343
|
+
|
344
|
+
REQUIRE(retrieved_o.size() == 1u);
|
345
|
+
REQUIRE(retrieved_o.get<std::string>("spam") == "eggs");
|
346
|
+
}
|
347
|
+
|
348
|
+
SECTION("array") {
|
349
|
+
JsonContainer a { "[ [1, 2], [false, true], [\"ab\", \"cd\"] ]" };
|
350
|
+
std::vector<bool> e_a { false, true };
|
351
|
+
|
352
|
+
REQUIRE(a.get<std::vector<bool>>(1) == e_a);
|
353
|
+
}
|
354
|
+
}
|
355
|
+
|
356
|
+
SECTION("array with values of different types") {
|
357
|
+
JsonContainer a { "[ 1, \"foo\", true, [2.718, 3.14], 42, 42.0, "
|
358
|
+
"{\"spam\":\"eggs\"} ]" };
|
359
|
+
|
360
|
+
SECTION("boolean") {
|
361
|
+
REQUIRE(a.get<bool>(2));
|
362
|
+
}
|
363
|
+
|
364
|
+
SECTION("integer") {
|
365
|
+
REQUIRE(a.get<int>(0) == 1);
|
366
|
+
}
|
367
|
+
|
368
|
+
SECTION("double") {
|
369
|
+
REQUIRE(a.get<double>(5) == 42.0);
|
370
|
+
}
|
371
|
+
|
372
|
+
SECTION("string") {
|
373
|
+
REQUIRE(a.get<std::string>(1) == "foo");
|
374
|
+
}
|
375
|
+
|
376
|
+
SECTION("object") {
|
377
|
+
auto retrieved_o = a.get<JsonContainer>(6);
|
378
|
+
|
379
|
+
REQUIRE(retrieved_o.size() == 1u);
|
380
|
+
REQUIRE(retrieved_o.get<std::string>("spam") == "eggs");
|
381
|
+
}
|
382
|
+
|
383
|
+
SECTION("array") {
|
384
|
+
std::vector<double> expected_array { 2.718, 3.14 };
|
385
|
+
|
386
|
+
REQUIRE(a.get<std::vector<double>>(3) == expected_array);
|
387
|
+
}
|
388
|
+
}
|
389
|
+
}
|
390
|
+
}
|
391
|
+
|
392
|
+
TEST_CASE("JsonContainer::getWithDefault", "[data]") {
|
393
|
+
JsonContainer data { JSON };
|
394
|
+
JsonContainer data_a { "[1, 2, 3]" };
|
395
|
+
std::vector<int> ints { 1, 2, 3 };
|
396
|
+
std::vector<double> doubles { 1.0, 2.0, 3.0 };
|
397
|
+
std::vector<bool> bools { false, true, false };
|
398
|
+
std::vector<std::string> strings { "foo", "bar", "baz" };
|
399
|
+
|
400
|
+
SECTION("it can provide a default value if a root entry key is not found") {
|
401
|
+
REQUIRE(data.getWithDefault<int>("dne", 42) == 42);
|
402
|
+
REQUIRE(data.getWithDefault<double>("dne", 42.0) == 42.0);
|
403
|
+
REQUIRE(data.getWithDefault<bool>("dne", true) == true);
|
404
|
+
REQUIRE(data.getWithDefault<std::string>("dne", "foo") == "foo");
|
405
|
+
REQUIRE(data.getWithDefault<std::vector<int>>("dne", ints) == ints);
|
406
|
+
REQUIRE(data.getWithDefault<std::vector<double>>("dne", doubles) == doubles);
|
407
|
+
REQUIRE(data.getWithDefault<std::vector<bool>>("dne", bools) == bools);
|
408
|
+
REQUIRE(data.getWithDefault<std::vector<std::string>>("dne", strings) == strings);
|
409
|
+
}
|
410
|
+
|
411
|
+
SECTION("throw a data_type_error if the root entry is not an object") {
|
412
|
+
REQUIRE_THROWS_AS(data_a.getWithDefault<int>("foo", 42), data_type_error);
|
413
|
+
}
|
414
|
+
|
415
|
+
SECTION("it can provide a default value if a nested key is not found") {
|
416
|
+
JsonContainer lv_2 {};
|
417
|
+
lv_2.set<JsonContainer>("entry_3", data);
|
418
|
+
JsonContainer lv_1 {};
|
419
|
+
lv_1.set<JsonContainer>("entry_2", lv_2);
|
420
|
+
std::vector<JsonContainerKey> missing_entry { "entry_2", "entry_3", "dne" };
|
421
|
+
|
422
|
+
REQUIRE(lv_1.getWithDefault<int>(missing_entry, 42) == 42);
|
423
|
+
REQUIRE(lv_1.getWithDefault<double>(missing_entry, 42.0) == 42.0);
|
424
|
+
REQUIRE(lv_1.getWithDefault<bool>(missing_entry, true) == true);
|
425
|
+
REQUIRE(lv_1.getWithDefault<std::string>(missing_entry, "foo")
|
426
|
+
== "foo");
|
427
|
+
REQUIRE(lv_1.getWithDefault<std::vector<int>>(missing_entry, ints)
|
428
|
+
== ints);
|
429
|
+
REQUIRE(lv_1.getWithDefault<std::vector<double>>(missing_entry, doubles)
|
430
|
+
== doubles);
|
431
|
+
REQUIRE(lv_1.getWithDefault<std::vector<bool>>(missing_entry, bools)
|
432
|
+
== bools);
|
433
|
+
REQUIRE(lv_1.getWithDefault<std::vector<std::string>>(missing_entry, strings)
|
434
|
+
== strings);
|
435
|
+
}
|
436
|
+
|
437
|
+
SECTION("throw a data_type_error if the parent of a nested entry is not an object") {
|
438
|
+
JsonContainer more_data_a {};
|
439
|
+
more_data_a.set<std::vector<int>>("ints_entry", ints);
|
440
|
+
|
441
|
+
REQUIRE_THROWS_AS(more_data_a.getWithDefault<int>({ "ints_entry", "foo" }, 42),
|
442
|
+
data_type_error);
|
443
|
+
}
|
444
|
+
}
|
445
|
+
|
446
|
+
TEST_CASE("JsonContainer::toString", "[data]") {
|
447
|
+
SECTION("root entry") {
|
448
|
+
SECTION("object") {
|
449
|
+
JsonContainer o {};
|
450
|
+
o.set<std::string>("spam", "eggs");
|
451
|
+
REQUIRE(o.toString() == "{\"spam\":\"eggs\"}");
|
452
|
+
}
|
453
|
+
|
454
|
+
SECTION("array") {
|
455
|
+
JsonContainer a { "[1, 2, 3]" };
|
456
|
+
REQUIRE(a.toString() == "[1,2,3]");
|
457
|
+
}
|
458
|
+
|
459
|
+
SECTION("multi type array") {
|
460
|
+
JsonContainer mt_a { "[1, false, \"s\"]" };
|
461
|
+
REQUIRE(mt_a.toString() == "[1,false,\"s\"]");
|
462
|
+
}
|
463
|
+
|
464
|
+
SECTION("scalar") {
|
465
|
+
JsonContainer s { "42" };
|
466
|
+
REQUIRE(s.toString() == "42");
|
467
|
+
}
|
468
|
+
}
|
469
|
+
|
470
|
+
JsonContainer data { JSON };
|
471
|
+
|
472
|
+
SECTION("root object entry") {
|
473
|
+
REQUIRE(data.toString("goo") == "1");
|
474
|
+
}
|
475
|
+
|
476
|
+
SECTION("nested object entry") {
|
477
|
+
REQUIRE(data.toString({ "nested", "foo" }) == "\"bar\"");
|
478
|
+
}
|
479
|
+
}
|
480
|
+
|
481
|
+
TEST_CASE("JsonContainer::toPrettyString", "[data]") {
|
482
|
+
SECTION("does not throw when the root is") {
|
483
|
+
SECTION("a string") {
|
484
|
+
JsonContainer data_s { "\"some text\"" };
|
485
|
+
REQUIRE_NOTHROW(data_s.toPrettyString());
|
486
|
+
}
|
487
|
+
|
488
|
+
SECTION("an array") {
|
489
|
+
JsonContainer data_a { "[1, 2, 3]" };
|
490
|
+
REQUIRE_NOTHROW(data_a.toPrettyString());
|
491
|
+
}
|
492
|
+
|
493
|
+
SECTION("an object") {
|
494
|
+
JsonContainer data_o { JSON };
|
495
|
+
REQUIRE_NOTHROW(data_o.toPrettyString());
|
496
|
+
}
|
497
|
+
|
498
|
+
SECTION("an object containing nested objects with an array") {
|
499
|
+
JsonContainer data_ooa {};
|
500
|
+
JsonContainer tmp {};
|
501
|
+
tmp.set<std::vector<int>>("bar", { 1, 2, 3 });
|
502
|
+
JsonContainer tmp_two {};
|
503
|
+
tmp_two.set<JsonContainer>("spam", tmp);
|
504
|
+
tmp_two.set<std::vector<int>>("beans", { 55, 56, 57 });
|
505
|
+
JsonContainer tmp_three {};
|
506
|
+
tmp_three.set<JsonContainer>("eggs", tmp_two);
|
507
|
+
data_ooa.set<JsonContainer>("foo", tmp_three);
|
508
|
+
|
509
|
+
REQUIRE_NOTHROW(data_ooa.toPrettyString());
|
510
|
+
}
|
511
|
+
}
|
512
|
+
}
|
513
|
+
|
514
|
+
TEST_CASE("JsonContainer::toPrettyJson", "[data]") {
|
515
|
+
SECTION("it pretty prints valid json") {
|
516
|
+
SECTION("a null value") {
|
517
|
+
std::string EXPECTED_OUTPUT = "null";
|
518
|
+
|
519
|
+
JsonContainer data(EXPECTED_OUTPUT);
|
520
|
+
auto pretty_json = data.toPrettyJson();
|
521
|
+
REQUIRE(pretty_json == EXPECTED_OUTPUT);
|
522
|
+
}
|
523
|
+
|
524
|
+
SECTION("a double") {
|
525
|
+
std::string EXPECTED_OUTPUT = "42.5";
|
526
|
+
|
527
|
+
JsonContainer data(EXPECTED_OUTPUT);
|
528
|
+
auto pretty_json = data.toPrettyJson();
|
529
|
+
REQUIRE(pretty_json == EXPECTED_OUTPUT);
|
530
|
+
}
|
531
|
+
|
532
|
+
SECTION("a bool") {
|
533
|
+
std::string EXPECTED_OUTPUT = "true";
|
534
|
+
|
535
|
+
JsonContainer data(EXPECTED_OUTPUT);
|
536
|
+
auto pretty_json = data.toPrettyJson();
|
537
|
+
REQUIRE(pretty_json == EXPECTED_OUTPUT);
|
538
|
+
}
|
539
|
+
|
540
|
+
SECTION("an int") {
|
541
|
+
std::string EXPECTED_OUTPUT = "42";
|
542
|
+
|
543
|
+
JsonContainer data(EXPECTED_OUTPUT);
|
544
|
+
auto pretty_json = data.toPrettyJson();
|
545
|
+
REQUIRE(pretty_json == EXPECTED_OUTPUT);
|
546
|
+
}
|
547
|
+
|
548
|
+
SECTION("a string") {
|
549
|
+
std::string EXPECTED_OUTPUT = "\"string\"";
|
550
|
+
|
551
|
+
JsonContainer data(EXPECTED_OUTPUT);
|
552
|
+
auto pretty_json = data.toPrettyJson();
|
553
|
+
REQUIRE(pretty_json == EXPECTED_OUTPUT);
|
554
|
+
}
|
555
|
+
|
556
|
+
SECTION("a simple array") {
|
557
|
+
std::string EXPECTED_OUTPUT =
|
558
|
+
"[\n"
|
559
|
+
" null,\n"
|
560
|
+
" 42.5,\n"
|
561
|
+
" true,\n"
|
562
|
+
" 42,\n"
|
563
|
+
" \"string\"\n"
|
564
|
+
"]";
|
565
|
+
|
566
|
+
JsonContainer data(EXPECTED_OUTPUT);
|
567
|
+
auto pretty_json = data.toPrettyJson();
|
568
|
+
REQUIRE(pretty_json == EXPECTED_OUTPUT);
|
569
|
+
}
|
570
|
+
|
571
|
+
SECTION("a simple object") {
|
572
|
+
std::string EXPECTED_OUTPUT =
|
573
|
+
"{\n"
|
574
|
+
" \"null-key\": null,\n"
|
575
|
+
" \"double-key\": 42.5,\n"
|
576
|
+
" \"bool-key\": true,\n"
|
577
|
+
" \"int-key\": 42,\n"
|
578
|
+
" \"string-key\": \"string\"\n"
|
579
|
+
"}";
|
580
|
+
|
581
|
+
JsonContainer data(EXPECTED_OUTPUT);
|
582
|
+
auto pretty_json = data.toPrettyJson();
|
583
|
+
REQUIRE(pretty_json == EXPECTED_OUTPUT);
|
584
|
+
}
|
585
|
+
|
586
|
+
SECTION("a nested object") {
|
587
|
+
std::string EXPECTED_OUTPUT =
|
588
|
+
"{\n"
|
589
|
+
" \"object-key\": {\n"
|
590
|
+
" \"null-key\": null,\n"
|
591
|
+
" \"double-key\": 42.5,\n"
|
592
|
+
" \"bool-key\": true,\n"
|
593
|
+
" \"int-key\": 42,\n"
|
594
|
+
" \"string-key\": \"string\"\n"
|
595
|
+
" },\n"
|
596
|
+
" \"array-key\": [\n"
|
597
|
+
" null,\n"
|
598
|
+
" 42.5,\n"
|
599
|
+
" true,\n"
|
600
|
+
" 42,\n"
|
601
|
+
" \"string\"\n"
|
602
|
+
" ]\n"
|
603
|
+
"}";
|
604
|
+
|
605
|
+
JsonContainer data(EXPECTED_OUTPUT);
|
606
|
+
auto pretty_json = data.toPrettyJson();
|
607
|
+
REQUIRE(pretty_json == EXPECTED_OUTPUT);
|
608
|
+
}
|
609
|
+
|
610
|
+
SECTION("a nested array") {
|
611
|
+
std::string EXPECTED_OUTPUT =
|
612
|
+
"[\n"
|
613
|
+
" {\n"
|
614
|
+
" \"null-key\": null,\n"
|
615
|
+
" \"double-key\": 42.5,\n"
|
616
|
+
" \"bool-key\": true,\n"
|
617
|
+
" \"int-key\": 42,\n"
|
618
|
+
" \"string-key\": \"string\"\n"
|
619
|
+
" },\n"
|
620
|
+
" [\n"
|
621
|
+
" null,\n"
|
622
|
+
" 42.5,\n"
|
623
|
+
" true,\n"
|
624
|
+
" 42,\n"
|
625
|
+
" \"string\"\n"
|
626
|
+
" ]\n"
|
627
|
+
"]";
|
628
|
+
|
629
|
+
JsonContainer data(EXPECTED_OUTPUT);
|
630
|
+
auto pretty_json = data.toPrettyJson();
|
631
|
+
REQUIRE(pretty_json == EXPECTED_OUTPUT);
|
632
|
+
}
|
633
|
+
}
|
634
|
+
|
635
|
+
SECTION("handles variable padding") {
|
636
|
+
std::string EXPECTED_OUTPUT =
|
637
|
+
"{\n"
|
638
|
+
" \"object-key\": {\n"
|
639
|
+
" \"null-key\": null,\n"
|
640
|
+
" \"double-key\": 42.5,\n"
|
641
|
+
" \"bool-key\": true,\n"
|
642
|
+
" \"int-key\": 42,\n"
|
643
|
+
" \"string-key\": \"string\"\n"
|
644
|
+
" },\n"
|
645
|
+
" \"array-key\": [\n"
|
646
|
+
" null,\n"
|
647
|
+
" 42.5,\n"
|
648
|
+
" true,\n"
|
649
|
+
" 42,\n"
|
650
|
+
" \"string\"\n"
|
651
|
+
" ]\n"
|
652
|
+
"}";
|
653
|
+
|
654
|
+
JsonContainer data(EXPECTED_OUTPUT);
|
655
|
+
auto pretty_json = data.toPrettyJson(2);
|
656
|
+
REQUIRE(pretty_json == EXPECTED_OUTPUT);
|
657
|
+
}
|
658
|
+
}
|
659
|
+
|
660
|
+
TEST_CASE("JsonContainer::empty", "[data]") {
|
661
|
+
SECTION("works correctly for an empty JsonContainer instance") {
|
662
|
+
JsonContainer data {};
|
663
|
+
REQUIRE(data.empty());
|
664
|
+
}
|
665
|
+
|
666
|
+
SECTION("works correctly if the root is an empty array") {
|
667
|
+
JsonContainer data { "[]" };
|
668
|
+
REQUIRE(data.empty());
|
669
|
+
}
|
670
|
+
|
671
|
+
SECTION("works correctly for an non-empty JsonContainer instance") {
|
672
|
+
JsonContainer data {};
|
673
|
+
data.set<int>("spam", 1);
|
674
|
+
REQUIRE_FALSE(data.empty());
|
675
|
+
}
|
676
|
+
|
677
|
+
SECTION("works correctly if the root is an non-empty array") {
|
678
|
+
JsonContainer data { "[1, 2, 3]" };
|
679
|
+
REQUIRE_FALSE(data.empty());
|
680
|
+
}
|
681
|
+
}
|
682
|
+
|
683
|
+
TEST_CASE("JsonContainer::size", "[data]") {
|
684
|
+
SECTION("works correctly on the root (no key argument)") {
|
685
|
+
SECTION("empty object") {
|
686
|
+
JsonContainer data {};
|
687
|
+
REQUIRE(data.size() == 0u);
|
688
|
+
}
|
689
|
+
|
690
|
+
SECTION("the root is an empty array") {
|
691
|
+
JsonContainer data { "[]" };
|
692
|
+
REQUIRE(data.size() == 0u);
|
693
|
+
}
|
694
|
+
|
695
|
+
SECTION("non-empty singleton object") {
|
696
|
+
JsonContainer data {};
|
697
|
+
data.set<int>("spam", 1);
|
698
|
+
REQUIRE(data.size() == 1u);
|
699
|
+
}
|
700
|
+
|
701
|
+
SECTION("non-empty multi element object") {
|
702
|
+
JsonContainer bigger_data { JSON };
|
703
|
+
REQUIRE(bigger_data.size() == 10u);
|
704
|
+
}
|
705
|
+
|
706
|
+
SECTION("non-empty array") {
|
707
|
+
JsonContainer data { "[1, 2, 3]" };
|
708
|
+
REQUIRE(data.size() == 3u);
|
709
|
+
}
|
710
|
+
}
|
711
|
+
|
712
|
+
JsonContainer data { JSON };
|
713
|
+
|
714
|
+
SECTION("works correctly on an object entry") {
|
715
|
+
SECTION("entry is a scalar") {
|
716
|
+
REQUIRE(data.size("goo") == 0u);
|
717
|
+
}
|
718
|
+
|
719
|
+
SECTION("entry is an object") {
|
720
|
+
REQUIRE(data.size("foo") == 1u);
|
721
|
+
}
|
722
|
+
|
723
|
+
SECTION("entry is an array") {
|
724
|
+
REQUIRE(data.size("vec") == 2u);
|
725
|
+
}
|
726
|
+
}
|
727
|
+
|
728
|
+
SECTION("works correctly on a nested entry") {
|
729
|
+
data.set<JsonContainer>({ "foo", "spam" }, JsonContainer { JSON });
|
730
|
+
|
731
|
+
SECTION("entry is a scalar") {
|
732
|
+
REQUIRE(data.size({ "foo", "spam", "goo" }) == 0u);
|
733
|
+
}
|
734
|
+
|
735
|
+
SECTION("entry is an object") {
|
736
|
+
REQUIRE(data.size({ "foo", "spam", "nested" }) == 1u);
|
737
|
+
}
|
738
|
+
|
739
|
+
SECTION("entry is an array") {
|
740
|
+
REQUIRE(data.size({ "foo", "spam", "vec" }) == 2u);
|
741
|
+
}
|
742
|
+
}
|
743
|
+
}
|
744
|
+
|
745
|
+
TEST_CASE("JsonContainer::includes", "[data]") {
|
746
|
+
SECTION("does not throw for an empty JsonContainer instance") {
|
747
|
+
JsonContainer data {};
|
748
|
+
REQUIRE_FALSE(data.includes("foo"));
|
749
|
+
}
|
750
|
+
|
751
|
+
SECTION("it should not throw if the root is not a JSON object") {
|
752
|
+
JsonContainer data { "[1, 2, 3]" };
|
753
|
+
REQUIRE_FALSE(data.includes("foo"));
|
754
|
+
}
|
755
|
+
|
756
|
+
SECTION("Document/object lookups") {
|
757
|
+
JsonContainer msg { JSON };
|
758
|
+
REQUIRE(msg.includes("foo") == true);
|
759
|
+
REQUIRE(msg.includes({ "foo", "bar" }) == true);
|
760
|
+
REQUIRE(msg.includes({ "foo", "baz" }) == false);
|
761
|
+
}
|
762
|
+
|
763
|
+
SECTION("Non object/document lookups") {
|
764
|
+
JsonContainer msg { "\"foo\"" };
|
765
|
+
REQUIRE(msg.includes({ "bar", "bar" }) == false);
|
766
|
+
REQUIRE(msg.includes("foo") == false);
|
767
|
+
}
|
768
|
+
}
|
769
|
+
|
770
|
+
TEST_CASE("JsonContainer::set", "[data]") {
|
771
|
+
JsonContainer msg {};
|
772
|
+
|
773
|
+
SECTION("it should add a new pair to the root") {
|
774
|
+
msg.set<int>("foo", 4);
|
775
|
+
REQUIRE(msg.get<int>("foo") == 4);
|
776
|
+
}
|
777
|
+
|
778
|
+
SECTION("it allows the creation of a nested structure") {
|
779
|
+
msg.set<int>({"level1", "level21"}, 0);
|
780
|
+
msg.set<bool>("bool1", true);
|
781
|
+
msg.set<std::string>({"level1", "level22"}, "a string");
|
782
|
+
msg.set<std::string>("level11", "different string");
|
783
|
+
REQUIRE(msg.get<int>({ "level1", "level21" }) == 0);
|
784
|
+
REQUIRE(msg.get<bool>("bool1") == true);
|
785
|
+
REQUIRE(msg.get<std::string>({"level1", "level22"}) == "a string");
|
786
|
+
REQUIRE(msg.get<std::string>("level11") == "different string");
|
787
|
+
}
|
788
|
+
|
789
|
+
SECTION("it allows resetting an integer value") {
|
790
|
+
msg.set<int>("i entry", 0);
|
791
|
+
REQUIRE(msg.includes("i entry"));
|
792
|
+
REQUIRE(msg.get<int>("i entry") == 0);
|
793
|
+
|
794
|
+
msg.set<int>("i entry", 5);
|
795
|
+
REQUIRE(msg.get<int>("i entry") == 5);
|
796
|
+
}
|
797
|
+
|
798
|
+
SECTION("it allows resetting a double value") {
|
799
|
+
msg.set<double>("d entry", 3.14159);
|
800
|
+
REQUIRE(msg.includes("d entry"));
|
801
|
+
REQUIRE(msg.get<double>("d entry") == 3.14159);
|
802
|
+
|
803
|
+
msg.set<double>("d entry", 2.71828);
|
804
|
+
REQUIRE(msg.get<double>("d entry") == 2.71828);
|
805
|
+
}
|
806
|
+
|
807
|
+
SECTION("it allows resetting a boolean value") {
|
808
|
+
msg.set<bool>("b entry", true);
|
809
|
+
REQUIRE(msg.includes("b entry"));
|
810
|
+
REQUIRE(msg.get<bool>("b entry") == true);
|
811
|
+
|
812
|
+
msg.set<bool>("b entry", false);
|
813
|
+
REQUIRE(msg.get<bool>("b entry") == false);
|
814
|
+
}
|
815
|
+
|
816
|
+
SECTION("it allows resetting a string value") {
|
817
|
+
msg.set<std::string>("s entry", "bar");
|
818
|
+
REQUIRE(msg.includes("s entry"));
|
819
|
+
REQUIRE(msg.get<std::string>("s entry") == "bar");
|
820
|
+
|
821
|
+
msg.set<std::string>("s entry", "spam");
|
822
|
+
REQUIRE(msg.get<std::string>("s entry") == "spam");
|
823
|
+
}
|
824
|
+
|
825
|
+
SECTION("it allows resetting a string vector value") {
|
826
|
+
std::vector<std::string> s_v { "foo", "bar" };
|
827
|
+
msg.set<std::vector<std::string>>("s_v entry", s_v);
|
828
|
+
REQUIRE(msg.includes("s_v entry"));
|
829
|
+
REQUIRE(msg.get<std::vector<std::string>>("s_v entry") == s_v);
|
830
|
+
|
831
|
+
std::vector<std::string> s_v_other { "spam", "eggs" };
|
832
|
+
msg.set<std::vector<std::string>>("s_v entry", s_v_other);
|
833
|
+
REQUIRE(msg.get<std::vector<std::string>>("s_v entry") == s_v_other);
|
834
|
+
}
|
835
|
+
|
836
|
+
SECTION("it allows resetting a JsonContainer value") {
|
837
|
+
JsonContainer d {};
|
838
|
+
d.set<int>("i", 1);
|
839
|
+
|
840
|
+
msg.set<JsonContainer>("d_c entry", d);
|
841
|
+
auto i_entry = msg.get<JsonContainer>("d_c entry");
|
842
|
+
|
843
|
+
// Expecting msg = { "d_c entry" : {"i" : 1} }
|
844
|
+
REQUIRE(msg.includes("d_c entry"));
|
845
|
+
REQUIRE(i_entry.get<int>("i") == 1);
|
846
|
+
|
847
|
+
JsonContainer d_other {};
|
848
|
+
d_other.set<bool>("b", true);
|
849
|
+
|
850
|
+
msg.set<JsonContainer>("d_c entry", d_other);
|
851
|
+
auto b_entry = msg.get<JsonContainer>("d_c entry");
|
852
|
+
|
853
|
+
// Expecting msg = { "d_c entry" : {"b" : true} }
|
854
|
+
REQUIRE(b_entry.get<bool>("b"));
|
855
|
+
}
|
856
|
+
|
857
|
+
SECTION("it can set a key to a vector") {
|
858
|
+
std::vector<std::string> strings { "foo", "bar" };
|
859
|
+
msg.set<std::vector<std::string>>("sv", strings);
|
860
|
+
|
861
|
+
std::vector<int> ints { 4, 2 };
|
862
|
+
msg.set<std::vector<int>>("iv", ints);
|
863
|
+
|
864
|
+
std::vector<bool> bools { true, false };
|
865
|
+
msg.set<std::vector<bool>>("bv", bools);
|
866
|
+
|
867
|
+
std::vector<double> doubles { 0.00, 9.99 };
|
868
|
+
msg.set<std::vector<double>>("dv", doubles);
|
869
|
+
|
870
|
+
REQUIRE(msg.get<std::vector<std::string>>("sv")[0] == "foo");
|
871
|
+
REQUIRE(msg.get<std::vector<std::string>>("sv")[1] == "bar");
|
872
|
+
|
873
|
+
REQUIRE(msg.get<std::vector<int>>("iv")[0] == 4);
|
874
|
+
REQUIRE(msg.get<std::vector<int>>("iv")[1] == 2);
|
875
|
+
|
876
|
+
REQUIRE(msg.get<std::vector<bool>>("bv")[0] == true);
|
877
|
+
REQUIRE(msg.get<std::vector<bool>>("bv")[1] == false);
|
878
|
+
|
879
|
+
REQUIRE(msg.get<std::vector<double>>("dv")[0] == 0.00);
|
880
|
+
REQUIRE(msg.get<std::vector<double>>("dv")[1] == 9.99);
|
881
|
+
}
|
882
|
+
|
883
|
+
SECTION("it should throw a data_key_error in case root is not an object") {
|
884
|
+
std::string json_array { "[1, 2, 3]" };
|
885
|
+
JsonContainer data_array { json_array };
|
886
|
+
|
887
|
+
REQUIRE_THROWS_AS(data_array.set<std::string>("foo", "bar"),
|
888
|
+
data_key_error);
|
889
|
+
}
|
890
|
+
|
891
|
+
SECTION("it should throw a data_key_error in case a known inner key is not "
|
892
|
+
"associated with a JSON object") {
|
893
|
+
JsonContainer d_c { JSON };
|
894
|
+
|
895
|
+
REQUIRE_THROWS_AS(d_c.set<std::string>({ "vec", "foo" }, "bar"),
|
896
|
+
data_key_error);
|
897
|
+
}
|
898
|
+
}
|
899
|
+
|
900
|
+
TEST_CASE("JsonContainer::keys", "[data]") {
|
901
|
+
SECTION("It returns a vector of keys") {
|
902
|
+
JsonContainer data { "{ \"a\" : 1, "
|
903
|
+
" \"b\" : 2, "
|
904
|
+
" \"c\\u0000null\" : 2}" };
|
905
|
+
std::vector<std::string> expected_keys { "a", "b", { "c\0null", 6 } };
|
906
|
+
|
907
|
+
REQUIRE(data.keys() == expected_keys);
|
908
|
+
}
|
909
|
+
|
910
|
+
SECTION("It returns an empty vector when the JsonContainer is empty") {
|
911
|
+
JsonContainer data {};
|
912
|
+
REQUIRE(data.keys().size() == 0u);
|
913
|
+
}
|
914
|
+
|
915
|
+
SECTION("It returns an empty vector when the JsonContainer is an array") {
|
916
|
+
JsonContainer data_array { "[1, 2, 3]" };
|
917
|
+
REQUIRE(data_array.keys().size() == 0u);
|
918
|
+
}
|
919
|
+
}
|
920
|
+
|
921
|
+
TEST_CASE("JsonContainer::type", "[data]") {
|
922
|
+
JsonContainer data {};
|
923
|
+
|
924
|
+
SECTION("When no key is passed it retrieves the type of the root value") {
|
925
|
+
SECTION("array") {
|
926
|
+
JsonContainer data_array { "[1, 2, 3]" };
|
927
|
+
REQUIRE(data_array.type() == DataType::Array);
|
928
|
+
}
|
929
|
+
|
930
|
+
SECTION("object") {
|
931
|
+
data.set<bool>("b_entry", false);
|
932
|
+
REQUIRE(data.type() == DataType::Object);
|
933
|
+
}
|
934
|
+
|
935
|
+
SECTION("integer") {
|
936
|
+
JsonContainer data_number { "42" };
|
937
|
+
REQUIRE(data_number.type() == DataType::Int);
|
938
|
+
}
|
939
|
+
}
|
940
|
+
|
941
|
+
SECTION("When a single key is passed") {
|
942
|
+
SECTION("it throws a data_key_error if the key is unknown") {
|
943
|
+
REQUIRE_THROWS_AS(data.type("foo"),
|
944
|
+
data_key_error);
|
945
|
+
}
|
946
|
+
|
947
|
+
SECTION("it can distinguish a Bool (false) value") {
|
948
|
+
data.set<bool>("b_entry", false);
|
949
|
+
REQUIRE(data.type("b_entry") == DataType::Bool);
|
950
|
+
}
|
951
|
+
|
952
|
+
SECTION("it can distinguish a Bool (true) value") {
|
953
|
+
data.set<bool>("b_entry", true);
|
954
|
+
REQUIRE(data.type("b_entry") == DataType::Bool);
|
955
|
+
}
|
956
|
+
|
957
|
+
SECTION("it can distinguish an Object (JsonContainer) value") {
|
958
|
+
JsonContainer tmp {};
|
959
|
+
tmp.set<std::string>("eggs", "spam");
|
960
|
+
data.set<JsonContainer>("obj_entry", tmp);
|
961
|
+
REQUIRE(data.type("obj_entry") == DataType::Object);
|
962
|
+
}
|
963
|
+
|
964
|
+
SECTION("it can distinguish an Array value") {
|
965
|
+
std::vector<std::string> tmp { "one", "two", "three" };
|
966
|
+
data.set<std::vector<std::string>>("array_entry", tmp);
|
967
|
+
REQUIRE(data.type("array_entry") == DataType::Array);
|
968
|
+
}
|
969
|
+
|
970
|
+
SECTION("it can distinguish a String value") {
|
971
|
+
data.set<std::string>("eggs", "spam");
|
972
|
+
REQUIRE(data.type("eggs") == DataType::String);
|
973
|
+
}
|
974
|
+
|
975
|
+
SECTION("it can distinguish an Int value") {
|
976
|
+
data.set<int>("int_entry", 42);
|
977
|
+
REQUIRE(data.type("int_entry") == DataType::Int);
|
978
|
+
}
|
979
|
+
|
980
|
+
SECTION("it can distinguish a Double value") {
|
981
|
+
SECTION("defined by set") {
|
982
|
+
data.set<double>("d_entry", 2.71828);
|
983
|
+
REQUIRE(data.type("d_entry") == DataType::Double);
|
984
|
+
}
|
985
|
+
|
986
|
+
SECTION("defined by JSON string given to the ctor") {
|
987
|
+
JsonContainer data_number { "2.71828" };
|
988
|
+
REQUIRE(data_number.type() == DataType::Double);
|
989
|
+
}
|
990
|
+
}
|
991
|
+
|
992
|
+
SECTION("it can distinguish a null value") {
|
993
|
+
JsonContainer data_with_null { "{\"the_null\" : null}" };
|
994
|
+
REQUIRE(data_with_null.type("the_null") == DataType::Null);
|
995
|
+
}
|
996
|
+
}
|
997
|
+
|
998
|
+
SECTION("When multiple keys are passed") {
|
999
|
+
JsonContainer tmp {};
|
1000
|
+
data.set<JsonContainer>("stuff", tmp);
|
1001
|
+
|
1002
|
+
SECTION("it throws a data_key_error if a key is unknown") {
|
1003
|
+
REQUIRE_THROWS_AS(data.type({ "stuff", "bar" }),
|
1004
|
+
data_key_error);
|
1005
|
+
}
|
1006
|
+
|
1007
|
+
SECTION("it can distinguish a Bool (false) value") {
|
1008
|
+
data.set<bool>({ "stuff", "b_entry" }, false);
|
1009
|
+
REQUIRE(data.type({ "stuff", "b_entry" }) == DataType::Bool);
|
1010
|
+
}
|
1011
|
+
|
1012
|
+
SECTION("it can distinguish a Bool (true) value") {
|
1013
|
+
data.set<bool>({ "stuff", "b_entry" }, true);
|
1014
|
+
REQUIRE(data.type({ "stuff", "b_entry" }) == DataType::Bool);
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
SECTION("it can distinguish an Object (JsonContainer) value") {
|
1018
|
+
JsonContainer tmp {};
|
1019
|
+
tmp.set<std::string>("eggs", "spam");
|
1020
|
+
data.set<JsonContainer>({ "stuff", "obj_entry" }, tmp);
|
1021
|
+
REQUIRE(data.type({ "stuff", "obj_entry" }) == DataType::Object);
|
1022
|
+
}
|
1023
|
+
|
1024
|
+
SECTION("it can distinguish an Array value") {
|
1025
|
+
std::vector<std::string> tmp { "one", "two", "three" };
|
1026
|
+
data.set<std::vector<std::string>>({ "stuff", "array_entry" }, tmp);
|
1027
|
+
REQUIRE(data.type({ "stuff", "array_entry" }) == DataType::Array);
|
1028
|
+
}
|
1029
|
+
|
1030
|
+
SECTION("it can distinguish a String value") {
|
1031
|
+
data.set<std::string>({ "stuff", "eggs" }, "spam");
|
1032
|
+
REQUIRE(data.type({ "stuff", "eggs" }) == DataType::String);
|
1033
|
+
}
|
1034
|
+
|
1035
|
+
SECTION("it can distinguish an Int value") {
|
1036
|
+
data.set<int>({ "stuff", "int_entry" }, 42);
|
1037
|
+
REQUIRE(data.type({ "stuff", "int_entry" }) == DataType::Int);
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
SECTION("it can distinguish a Double value") {
|
1041
|
+
data.set<double>({ "stuff", "d_entry" }, 2.71828);
|
1042
|
+
REQUIRE(data.type({ "stuff", "d_entry" }) == DataType::Double);
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
SECTION("it can distinguish a null value") {
|
1046
|
+
JsonContainer data_with_null { "{\"the_null\" : null}" };
|
1047
|
+
data.set<JsonContainer>({ "stuff", "more_stuff" }, data_with_null);
|
1048
|
+
auto data_type = data.type({ "stuff", "more_stuff", "the_null" });
|
1049
|
+
REQUIRE(data_type == DataType::Null);
|
1050
|
+
}
|
1051
|
+
}
|
1052
|
+
}
|
1053
|
+
|
1054
|
+
TEST_CASE("JsonContainer::type for arrays entries", "[data]") {
|
1055
|
+
JsonContainer data { "[false, -42, 3.14, \"spam\", {\"foo\" : [3, true]}, "
|
1056
|
+
"[1, 2, 3, 4] ]" };
|
1057
|
+
|
1058
|
+
SECTION("root entry") {
|
1059
|
+
SECTION("array") {
|
1060
|
+
JsonContainer not_an_aray { JSON };
|
1061
|
+
REQUIRE_THROWS_AS(not_an_aray.type(1), data_type_error);
|
1062
|
+
}
|
1063
|
+
|
1064
|
+
SECTION("array with values of different types") {
|
1065
|
+
JsonContainer data_array { "[1, \"spam\", false]" };
|
1066
|
+
REQUIRE(data_array.type() == DataType::Array);
|
1067
|
+
}
|
1068
|
+
|
1069
|
+
SECTION("boolean") {
|
1070
|
+
REQUIRE(data.type(0) == DataType::Bool);
|
1071
|
+
}
|
1072
|
+
|
1073
|
+
SECTION("integer") {
|
1074
|
+
REQUIRE(data.type(1) == DataType::Int);
|
1075
|
+
}
|
1076
|
+
|
1077
|
+
SECTION("double") {
|
1078
|
+
REQUIRE(data.type(2) == DataType::Double);
|
1079
|
+
}
|
1080
|
+
|
1081
|
+
SECTION("string") {
|
1082
|
+
REQUIRE(data.type(3) == DataType::String);
|
1083
|
+
}
|
1084
|
+
|
1085
|
+
SECTION("object") {
|
1086
|
+
REQUIRE(data.type(4) == DataType::Object);
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
SECTION("array") {
|
1090
|
+
REQUIRE(data.type(5) == DataType::Array);
|
1091
|
+
}
|
1092
|
+
}
|
1093
|
+
|
1094
|
+
SECTION("object entry") {
|
1095
|
+
JsonContainer o { JSON };
|
1096
|
+
o.set<JsonContainer>("multi type array", data);
|
1097
|
+
|
1098
|
+
SECTION("container") {
|
1099
|
+
REQUIRE(o.type("multi type array") == DataType::Array);
|
1100
|
+
}
|
1101
|
+
|
1102
|
+
SECTION("double") {
|
1103
|
+
REQUIRE(o.type("multi type array", 2) == DataType::Double);
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
SECTION("string") {
|
1107
|
+
REQUIRE(o.type("multi type array", 3) == DataType::String);
|
1108
|
+
}
|
1109
|
+
}
|
1110
|
+
|
1111
|
+
SECTION("nested entry") {
|
1112
|
+
JsonContainer o { JSON };
|
1113
|
+
o.set<JsonContainer>({ "nested", "multi type array" }, data);
|
1114
|
+
|
1115
|
+
SECTION("container") {
|
1116
|
+
REQUIRE(o.type({ "nested", "multi type array" }) == DataType::Array);
|
1117
|
+
}
|
1118
|
+
|
1119
|
+
SECTION("double") {
|
1120
|
+
REQUIRE(o.type({ "nested", "multi type array" }, 2)
|
1121
|
+
== DataType::Double);
|
1122
|
+
}
|
1123
|
+
|
1124
|
+
SECTION("string") {
|
1125
|
+
REQUIRE(o.type({ "nested", "multi type array" }, 3)
|
1126
|
+
== DataType::String);
|
1127
|
+
}
|
1128
|
+
}
|
1129
|
+
}
|