├── .gitignore ├── CMakeLists.txt ├── COPYING ├── LICENSE.txt ├── README.md ├── apps ├── OGR.cpp ├── OGR.hpp ├── ProgramArgs.hpp ├── Utils.cpp ├── Utils.hpp ├── curse.cpp └── pdal_util_export.hpp ├── cmake ├── hexer_utils.cmake └── modules │ ├── FindCairo.cmake │ ├── GetGitRevisionDescription.cmake │ └── GetGitRevisionDescription.cmake.in ├── h3 ├── include │ ├── algos.h │ ├── alloc.h │ ├── baseCells.h │ ├── bbox.h │ ├── constants.h │ ├── coordijk.h │ ├── directedEdge.h │ ├── faceijk.h │ ├── h3Assert.h │ ├── h3Index.h │ ├── h3api.h │ ├── iterators.h │ ├── latLng.h │ ├── linkedGeo.h │ ├── localij.h │ ├── mathExtensions.h │ ├── polyfill.h │ ├── polygon.h │ ├── polygonAlgos.h │ ├── vec2d.h │ ├── vec3d.h │ ├── vertex.h │ └── vertexGraph.h └── lib │ ├── algos.c │ ├── baseCells.c │ ├── bbox.c │ ├── coordijk.c │ ├── directedEdge.c │ ├── faceijk.c │ ├── h3Assert.c │ ├── h3Index.c │ ├── iterators.c │ ├── latLng.c │ ├── linkedGeo.c │ ├── localij.c │ ├── mathExtensions.c │ ├── polyfill.c │ ├── polygon.c │ ├── vec2d.c │ ├── vec3d.c │ ├── vertex.c │ └── vertexGraph.c ├── hexer ├── BaseGrid.cpp ├── BaseGrid.hpp ├── H3grid.cpp ├── H3grid.hpp ├── HexGrid.cpp ├── HexGrid.hpp ├── HexId.hpp ├── Mathpair.hpp ├── Path.cpp ├── Path.hpp ├── Processor.cpp ├── Processor.hpp ├── Segment.hpp ├── Utils.hpp ├── exception.hpp ├── export.hpp └── hexer.hpp ├── hexer_defines.h.in ├── hobu-config.sh ├── images ├── h3bounds.png └── serpent.png ├── lazperf ├── Extractor.hpp ├── Inserter.hpp ├── charbuf.cpp ├── charbuf.hpp ├── coderbase.hpp ├── compressor.hpp ├── decoder.hpp ├── decompressor.hpp ├── detail │ ├── field_byte10.cpp │ ├── field_byte10.hpp │ ├── field_byte14.cpp │ ├── field_byte14.hpp │ ├── field_gpstime.hpp │ ├── field_gpstime10.cpp │ ├── field_gpstime10.hpp │ ├── field_nir14.cpp │ ├── field_nir14.hpp │ ├── field_point10.cpp │ ├── field_point10.hpp │ ├── field_point14.cpp │ ├── field_point14.hpp │ ├── field_rgb10.cpp │ ├── field_rgb10.hpp │ ├── field_rgb14.cpp │ ├── field_rgb14.hpp │ └── field_xyz.hpp ├── encoder.hpp ├── excepts.hpp ├── filestream.cpp ├── filestream.hpp ├── header.cpp ├── header.hpp ├── las.hpp ├── lazperf.cpp ├── lazperf.hpp ├── lazperf_base.hpp ├── lazperf_user_base.hpp ├── model.hpp ├── portable_endian.hpp ├── readers.cpp ├── readers.hpp ├── streams.hpp ├── utils.hpp ├── vlr.cpp ├── vlr.hpp ├── writers.cpp └── writers.hpp ├── make_shapes.py └── test ├── CMakeLists.txt ├── data ├── autzen_trim.las └── autzen_trim.laz ├── gridtest.cpp ├── gtest └── gtest-10-06-21 │ ├── CMakeLists.txt │ ├── CONTRIBUTING.md │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── README.md │ └── googletest │ ├── CMakeLists.txt │ ├── README.md │ ├── cmake │ ├── Config.cmake.in │ ├── gtest.pc.in │ ├── gtest_main.pc.in │ ├── internal_utils.cmake │ └── libgtest.la.in │ ├── docs │ └── README.md │ ├── include │ └── gtest │ │ ├── gtest-death-test.h │ │ ├── gtest-matchers.h │ │ ├── gtest-message.h │ │ ├── gtest-param-test.h │ │ ├── gtest-printers.h │ │ ├── gtest-spi.h │ │ ├── gtest-test-part.h │ │ ├── gtest-typed-test.h │ │ ├── gtest.h │ │ ├── gtest_pred_impl.h │ │ ├── gtest_prod.h │ │ └── internal │ │ ├── custom │ │ ├── README.md │ │ ├── gtest-port.h │ │ ├── gtest-printers.h │ │ └── gtest.h │ │ ├── gtest-death-test-internal.h │ │ ├── gtest-filepath.h │ │ ├── gtest-internal.h │ │ ├── gtest-param-util.h │ │ ├── gtest-port-arch.h │ │ ├── gtest-port.h │ │ ├── gtest-string.h │ │ └── gtest-type-util.h │ ├── samples │ ├── prime_tables.h │ ├── sample1.cc │ ├── sample1.h │ ├── sample10_unittest.cc │ ├── sample1_unittest.cc │ ├── sample2.cc │ ├── sample2.h │ ├── sample2_unittest.cc │ ├── sample3-inl.h │ ├── sample3_unittest.cc │ ├── sample4.cc │ ├── sample4.h │ ├── sample4_unittest.cc │ ├── sample5_unittest.cc │ ├── sample6_unittest.cc │ ├── sample7_unittest.cc │ ├── sample8_unittest.cc │ └── sample9_unittest.cc │ ├── scripts │ ├── README.md │ ├── common.py │ ├── fuse_gtest_files.py │ ├── gen_gtest_pred_impl.py │ ├── gtest-config.in │ ├── release_docs.py │ ├── run_with_path.py │ ├── upload.py │ └── upload_gtest.py │ ├── src │ ├── gtest-all.cc │ ├── gtest-death-test.cc │ ├── gtest-filepath.cc │ ├── gtest-internal-inl.h │ ├── gtest-matchers.cc │ ├── gtest-port.cc │ ├── gtest-printers.cc │ ├── gtest-test-part.cc │ ├── gtest-typed-test.cc │ ├── gtest.cc │ └── gtest_main.cc │ └── test │ ├── BUILD.bazel │ ├── googletest-break-on-failure-unittest.py │ ├── googletest-break-on-failure-unittest_.cc │ ├── googletest-catch-exceptions-test.py │ ├── googletest-catch-exceptions-test_.cc │ ├── googletest-color-test.py │ ├── googletest-color-test_.cc │ ├── googletest-death-test-test.cc │ ├── googletest-death-test_ex_test.cc │ ├── googletest-env-var-test.py │ ├── googletest-env-var-test_.cc │ ├── googletest-failfast-unittest.py │ ├── googletest-failfast-unittest_.cc │ ├── googletest-filepath-test.cc │ ├── googletest-filter-unittest.py │ ├── googletest-filter-unittest_.cc │ ├── googletest-global-environment-unittest.py │ ├── googletest-global-environment-unittest_.cc │ ├── googletest-json-outfiles-test.py │ ├── googletest-json-output-unittest.py │ ├── googletest-list-tests-unittest.py │ ├── googletest-list-tests-unittest_.cc │ ├── googletest-listener-test.cc │ ├── googletest-message-test.cc │ ├── googletest-options-test.cc │ ├── googletest-output-test-golden-lin.txt │ ├── googletest-output-test.py │ ├── googletest-output-test_.cc │ ├── googletest-param-test-invalid-name1-test.py │ ├── googletest-param-test-invalid-name1-test_.cc │ ├── googletest-param-test-invalid-name2-test.py │ ├── googletest-param-test-invalid-name2-test_.cc │ ├── googletest-param-test-test.cc │ ├── googletest-param-test-test.h │ ├── googletest-param-test2-test.cc │ ├── googletest-port-test.cc │ ├── googletest-printers-test.cc │ ├── googletest-setuptestsuite-test.py │ ├── googletest-setuptestsuite-test_.cc │ ├── googletest-shuffle-test.py │ ├── googletest-shuffle-test_.cc │ ├── googletest-test-part-test.cc │ ├── googletest-throw-on-failure-test.py │ ├── googletest-throw-on-failure-test_.cc │ ├── googletest-uninitialized-test.py │ ├── googletest-uninitialized-test_.cc │ ├── gtest-typed-test2_test.cc │ ├── gtest-typed-test_test.cc │ ├── gtest-typed-test_test.h │ ├── gtest-unittest-api_test.cc │ ├── gtest_all_test.cc │ ├── gtest_assert_by_exception_test.cc │ ├── gtest_environment_test.cc │ ├── gtest_help_test.py │ ├── gtest_help_test_.cc │ ├── gtest_json_test_utils.py │ ├── gtest_list_output_unittest.py │ ├── gtest_list_output_unittest_.cc │ ├── gtest_main_unittest.cc │ ├── gtest_no_test_unittest.cc │ ├── gtest_pred_impl_unittest.cc │ ├── gtest_premature_exit_test.cc │ ├── gtest_prod_test.cc │ ├── gtest_repeat_test.cc │ ├── gtest_skip_check_output_test.py │ ├── gtest_skip_environment_check_output_test.py │ ├── gtest_skip_in_environment_setup_test.cc │ ├── gtest_skip_test.cc │ ├── gtest_sole_header_test.cc │ ├── gtest_stress_test.cc │ ├── gtest_test_macro_stack_footprint_test.cc │ ├── gtest_test_utils.py │ ├── gtest_testbridge_test.py │ ├── gtest_testbridge_test_.cc │ ├── gtest_throw_on_failure_ex_test.cc │ ├── gtest_unittest.cc │ ├── gtest_xml_outfile1_test_.cc │ ├── gtest_xml_outfile2_test_.cc │ ├── gtest_xml_outfiles_test.py │ ├── gtest_xml_output_unittest.py │ ├── gtest_xml_output_unittest_.cc │ ├── gtest_xml_test_utils.py │ ├── production.cc │ └── production.h ├── pathstest.cpp └── test_main.hpp.in /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | 3 | syntax: glob 4 | 5 | CMakeFiles/ 6 | CMakeCache.txt 7 | .DS_Store 8 | CTestTestfile.cmake 9 | Makefile 10 | cmake_install.cmake 11 | *.exe 12 | *.dll 13 | *.lib 14 | *.lo 15 | *.o 16 | bin/ 17 | include/hexer/hexer_defines.h 18 | install_manifest.txt 19 | curse 20 | 21 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Unless otherwise indicated, all files in the PDAL distribution are 2 | 3 | Copyright (c) 2017, Hobu, Inc. (howard@hobu.co) 4 | 5 | and are released under the terms of the BSD open source license. 6 | 7 | This file contains the license terms of all files within PDAL. 8 | 9 | 10 | Overall PDAL license (BSD) 11 | =========================== 12 | 13 | Copyright (c) 2017, Hobu, Inc. (howard@hobu.co) 14 | 15 | All rights reserved. 16 | 17 | Redistribution and use in source and binary forms, with or without 18 | modification, are permitted provided that the following 19 | conditions are met: 20 | 21 | * Redistributions of source code must retain the above copyright 22 | notice, this list of conditions and the following disclaimer. 23 | * Redistributions in binary form must reproduce the above copyright 24 | notice, this list of conditions and the following disclaimer in 25 | the documentation and/or other materials provided 26 | with the distribution. 27 | * Neither the name of Hobu, Inc. or Flaxen Consulting LLC nor the 28 | names of its contributors may be used to endorse or promote 29 | products derived from this software without specific prior 30 | written permission. 31 | 32 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 35 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 36 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 37 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 38 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 39 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 40 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 41 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 42 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 43 | OF SUCH DAMAGE. 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hexer - Hexbin density and boundary generation 2 | 3 | Hexer is a [LGPL] C++ library that provides some classes for generating 4 | hexbin density surfaces and [multipolygon] boundaries for large point sets. I use 5 | the code for generating boundary polygons of large [LiDAR] collections, but it is 6 | useful in other contexts. 7 | 8 | Hexer also offers support for creating boundaries and density surfaces using Uber's [H3] 9 | geospatial indexing library. By specifying --grid h3, points can be summarized 10 | inside of H3's existing global hexagon grid. H3 [resolution] can be specified with -r, 11 | or Hexer can calculate an appropriate cell size based on the input. H3 processing 12 | currently only supports .LAS and .LAZ files with WGS84 (EPSG:4326) CRS. 13 | 14 | Hexer supports two operations at this time, density and boundary. You 15 | use hexer through the curse command: 16 | 17 | ``` 18 | [howardbutler@ardere hexer (master)]$ ./bin/curse --help 19 | -------------------------------------------------------------------- 20 | curse (hexer 1.4.0 at revision e2d559 with GDAL 3.9.1) 21 | -------------------------------------------------------------------- 22 | command [boundary] 23 | Command to run on points ('boundary' or 'density') 24 | 25 | input 26 | Input point set to curse 27 | 28 | output, o [] 29 | Specify an OGR-compatible output filename to write boundary. stdout used if none specified. 30 | 31 | edge [0] 32 | Edge distance of hexagon (hexgrid only) 33 | 34 | count [0] 35 | Number of points that must be in polygon for it to be positive space 36 | 37 | resolution, r [-1] 38 | H3 grid resolution: 0 (coarsest) - 15 (finest) 39 | 40 | grid [hexgrid] 41 | Grid type ('hexgrid' or 'h3'): proprietary HexGrid hexagons, or H3 indexed grid 42 | 43 | For more information, see the full documentation for hexer at: 44 | http://github.com/hobu/hexer 45 | 46 | ``` 47 | ### H3 Processing 48 | ``` 49 | $ curse density mylasfile.las --output myhexagons.shp --grid h3 50 | $ curse boundary mylasfile.las --output myboundary.shp --grid h3 -r 12 51 | ``` 52 | Uncompahgre boundary at H3 resolution 11 53 | 54 | 55 | ### Default Processing 56 | ``` 57 | $ curse boundary mypointfile.shp --output myboundary.shp 58 | $ curse density mylasfile.las --output myhexagons.shp --edge 100 59 | ``` 60 | 61 | Serpent Mound Hexbins 62 | 63 | [LGPL]: http://www.gnu.org/licenses/lgpl-2.1.html 64 | [LiDAR]: https://en.wikipedia.org/wiki/LIDAR 65 | [multipolygon]: http://en.wikipedia.org/wiki/Well-known_text 66 | [H3]: https://h3geo.org/ 67 | [resolution]: https://h3geo.org/docs/core-library/restable 68 | 69 | [map]: http://a.tiles.mapbox.com/v3/hobu.serpent-mound.html#16.00/39.0346/-83.4353 70 | 71 | -------------------------------------------------------------------------------- /apps/pdal_util_export.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) 2010, Howard Butler 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following 8 | * conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided 15 | * with the distribution. 16 | * * Neither the name of the Martin Isenburg or Iowa Department 17 | * of Natural Resources nor the names of its contributors may be 18 | * used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 28 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | ****************************************************************************/ 34 | 35 | // This eliminates the need to include pdal base includes in code for the Util 36 | // library. 37 | 38 | #pragma once 39 | 40 | #ifndef PDAL_DLL 41 | #if defined(_WIN32) 42 | # define PDAL_DLL __declspec(dllexport) 43 | #else 44 | # if defined(USE_GCC_VISIBILITY_FLAG) 45 | # define PDAL_DLL __attribute__ ((visibility("default"))) 46 | # else 47 | # define PDAL_DLL 48 | # endif 49 | #endif 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /cmake/modules/GetGitRevisionDescription.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # Internal file for GetGitRevisionDescription.cmake 3 | # 4 | # Requires CMake 2.6 or newer (uses the 'function' command) 5 | # 6 | # Original Author: 7 | # 2009-2010 Ryan Pavlik 8 | # http://academic.cleardefinition.com 9 | # Iowa State University HCI Graduate Program/VRAC 10 | # 11 | # Copyright Iowa State University 2009-2010. 12 | # Distributed under the Boost Software License, Version 1.0. 13 | # (See accompanying file LICENSE_1_0.txt or copy at 14 | # http://www.boost.org/LICENSE_1_0.txt) 15 | 16 | set(HEAD_HASH) 17 | 18 | file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) 19 | 20 | string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) 21 | if(HEAD_CONTENTS MATCHES "ref") 22 | # named branch 23 | string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") 24 | if(EXISTS "@GIT_DIR@/${HEAD_REF}") 25 | configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) 26 | elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}") 27 | configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) 28 | set(HEAD_HASH "${HEAD_REF}") 29 | endif() 30 | else() 31 | # detached HEAD 32 | configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) 33 | endif() 34 | 35 | if(NOT HEAD_HASH) 36 | file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) 37 | string(STRIP "${HEAD_HASH}" HEAD_HASH) 38 | endif() 39 | -------------------------------------------------------------------------------- /h3/include/algos.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018, 2020 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file algos.h 17 | * @brief Hexagon grid algorithms 18 | */ 19 | 20 | #ifndef ALGOS_H 21 | #define ALGOS_H 22 | 23 | #include "bbox.h" 24 | #include "coordijk.h" 25 | #include "h3api.h" 26 | #include "linkedGeo.h" 27 | #include "vertexGraph.h" 28 | 29 | // neighbor along the ijk coordinate system of the current face, rotated 30 | H3Error h3NeighborRotations(H3Index origin, Direction dir, int *rotations, 31 | H3Index *out); 32 | 33 | // IJK direction of neighbor 34 | Direction directionForNeighbor(H3Index origin, H3Index destination); 35 | 36 | // k-ring implementation 37 | void _kRingInternal(H3Index origin, int k, H3Index *out, int *distances, 38 | int maxIdx, int curK); 39 | 40 | // Create a vertex graph from a set of hexagons 41 | H3Error h3SetToVertexGraph(const H3Index *h3Set, const int numHexes, 42 | VertexGraph *out); 43 | 44 | // Create a LinkedGeoPolygon from a vertex graph 45 | void _vertexGraphToLinkedGeo(VertexGraph *graph, LinkedGeoPolygon *out); 46 | 47 | // Internal function for polygonToCells that traces a geoloop with hexagons of 48 | // a specific size 49 | H3Error _getEdgeHexagons(const GeoLoop *geoloop, int64_t numHexagons, int res, 50 | int64_t *numSearchHexes, H3Index *search, 51 | H3Index *found); 52 | 53 | // The safe gridDiskDistances algorithm. 54 | H3Error _gridDiskDistancesInternal(H3Index origin, int k, H3Index *out, 55 | int *distances, int64_t maxIdx, int curK); 56 | #endif 57 | -------------------------------------------------------------------------------- /h3/include/alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file alloc.h 17 | * @brief Memory management functions 18 | * 19 | * This file contains macros and the necessary declarations to be able 20 | * to point H3 at different memory management functions than the standard 21 | * malloc/free/etc functions. 22 | */ 23 | 24 | #ifndef ALLOC_H 25 | #define ALLOC_H 26 | 27 | #include "h3api.h" // for TJOIN 28 | 29 | #ifdef H3_ALLOC_PREFIX 30 | #define H3_MEMORY(name) TJOIN(H3_ALLOC_PREFIX, name) 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | void *H3_MEMORY(malloc)(size_t size); 37 | void *H3_MEMORY(calloc)(size_t num, size_t size); 38 | void *H3_MEMORY(realloc)(void *ptr, size_t size); 39 | void H3_MEMORY(free)(void *ptr); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #else 46 | #define H3_MEMORY(name) name 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /h3/include/baseCells.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file baseCells.h 17 | * @brief Base cell related lookup tables and access functions. 18 | */ 19 | 20 | #ifndef BASECELLS_H 21 | #define BASECELLS_H 22 | 23 | #include "constants.h" 24 | #include "coordijk.h" 25 | #include "faceijk.h" 26 | 27 | /** @struct BaseCellData 28 | * @brief information on a single base cell 29 | */ 30 | typedef struct { 31 | FaceIJK 32 | homeFijk; ///< "home" face and normalized ijk coordinates on that face 33 | int isPentagon; ///< is this base cell a pentagon? 34 | int cwOffsetPent[2]; ///< if a pentagon, what are its two clockwise offset 35 | /// faces? 36 | } BaseCellData; 37 | 38 | #define INVALID_BASE_CELL 127 39 | extern const int baseCellNeighbors[NUM_BASE_CELLS][7]; 40 | extern const int baseCellNeighbor60CCWRots[NUM_BASE_CELLS][7]; 41 | 42 | // resolution 0 base cell data lookup-table (global) 43 | extern const BaseCellData baseCellData[NUM_BASE_CELLS]; 44 | 45 | /** Maximum input for any component to face-to-base-cell lookup functions */ 46 | #define MAX_FACE_COORD 2 47 | 48 | /** Invalid number of rotations */ 49 | #define INVALID_ROTATIONS -1 50 | 51 | // Internal functions 52 | int _isBaseCellPentagon(int baseCell); 53 | bool _isBaseCellPolarPentagon(int baseCell); 54 | int _faceIjkToBaseCell(const FaceIJK *h); 55 | int _faceIjkToBaseCellCCWrot60(const FaceIJK *h); 56 | int _baseCellToCCWrot60(int baseCell, int face); 57 | void _baseCellToFaceIjk(int baseCell, FaceIJK *h); 58 | bool _baseCellIsCwOffset(int baseCell, int testFace); 59 | int _getBaseCellNeighbor(int baseCell, Direction dir); 60 | Direction _getBaseCellDirection(int originBaseCell, int destinationBaseCell); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /h3/include/bbox.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017, 2020-2021 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file bbox.h 17 | * @brief Geographic bounding box functions 18 | */ 19 | 20 | #ifndef BBOX_H 21 | #define BBOX_H 22 | 23 | #include 24 | 25 | #include "h3api.h" 26 | #include "latLng.h" 27 | 28 | /** @struct BBox 29 | * @brief Geographic bounding box with coordinates defined in radians 30 | */ 31 | typedef struct { 32 | double north; ///< north latitude 33 | double south; ///< south latitude 34 | double east; ///< east longitude 35 | double west; ///< west longitude 36 | } BBox; 37 | 38 | double bboxWidthRads(const BBox *bbox); 39 | double bboxHeightRads(const BBox *bbox); 40 | bool bboxIsTransmeridian(const BBox *bbox); 41 | void bboxCenter(const BBox *bbox, LatLng *center); 42 | bool bboxContains(const BBox *bbox, const LatLng *point); 43 | bool bboxContainsBBox(const BBox *a, const BBox *b); 44 | bool bboxOverlapsBBox(const BBox *a, const BBox *b); 45 | bool bboxEquals(const BBox *b1, const BBox *b2); 46 | CellBoundary bboxToCellBoundary(const BBox *bbox); 47 | H3Error bboxHexEstimate(const BBox *bbox, int res, int64_t *out); 48 | H3Error lineHexEstimate(const LatLng *origin, const LatLng *destination, 49 | int res, int64_t *out); 50 | void scaleBBox(BBox *bbox, double scale); 51 | void bboxNormalization(const BBox *a, const BBox *b, 52 | LongitudeNormalization *aNormalization, 53 | LongitudeNormalization *bNormalization); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /h3/include/constants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017, 2020 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file constants.h 17 | * @brief Constants used by more than one source code file. 18 | */ 19 | 20 | #ifndef CONSTANTS_H 21 | #define CONSTANTS_H 22 | 23 | #ifndef M_PI 24 | /** pi */ 25 | #define M_PI 3.14159265358979323846 26 | #endif 27 | 28 | #ifndef M_PI_2 29 | /** pi / 2.0 */ 30 | #define M_PI_2 1.5707963267948966 31 | #endif 32 | 33 | /** 2.0 * PI */ 34 | #define M_2PI 6.28318530717958647692528676655900576839433 35 | 36 | /** pi / 180 */ 37 | #define M_PI_180 0.0174532925199432957692369076848861271111 38 | /** 180 / pi */ 39 | #define M_180_PI 57.29577951308232087679815481410517033240547 40 | 41 | /** threshold epsilon */ 42 | #define EPSILON 0.0000000000000001 43 | /** sqrt(3) / 2.0 */ 44 | #define M_SQRT3_2 0.8660254037844386467637231707529361834714 45 | /** sin(60') */ 46 | #define M_SIN60 M_SQRT3_2 47 | /** 1/sin(60') **/ 48 | #define M_RSIN60 1.1547005383792515290182975610039149112953 49 | 50 | /** one third **/ 51 | #define M_ONETHIRD 0.333333333333333333333333333333333333333 52 | 53 | /** rotation angle between Class II and Class III resolution axes 54 | * (asin(sqrt(3.0 / 28.0))) */ 55 | #define M_AP7_ROT_RADS 0.333473172251832115336090755351601070065900389 56 | 57 | /** sin(M_AP7_ROT_RADS) */ 58 | #define M_SIN_AP7_ROT 0.3273268353539885718950318 59 | 60 | /** cos(M_AP7_ROT_RADS) */ 61 | #define M_COS_AP7_ROT 0.9449111825230680680167902 62 | 63 | /** earth radius in kilometers using WGS84 authalic radius */ 64 | #define EARTH_RADIUS_KM 6371.007180918475 65 | 66 | /** scaling factor from hex2d resolution 0 unit length 67 | * (or distance between adjacent cell center points 68 | * on the plane) to gnomonic unit length. */ 69 | #define RES0_U_GNOMONIC 0.38196601125010500003 70 | #define INV_RES0_U_GNOMONIC 2.61803398874989588842 71 | 72 | /** max H3 resolution; H3 version 1 has 16 resolutions, numbered 0 through 15 */ 73 | #define MAX_H3_RES 15 74 | 75 | /** The number of faces on an icosahedron */ 76 | #define NUM_ICOSA_FACES 20 77 | /** The number of H3 base cells */ 78 | #define NUM_BASE_CELLS 122 79 | /** The number of vertices in a hexagon */ 80 | #define NUM_HEX_VERTS 6 81 | /** The number of vertices in a pentagon */ 82 | #define NUM_PENT_VERTS 5 83 | /** The number of pentagons per resolution **/ 84 | #define NUM_PENTAGONS 12 85 | 86 | /** H3 index modes */ 87 | #define H3_CELL_MODE 1 88 | #define H3_DIRECTEDEDGE_MODE 2 89 | #define H3_EDGE_MODE 3 90 | #define H3_VERTEX_MODE 4 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /h3/include/directedEdge.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, 2020 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file directedEdge.h 17 | * @brief DirectedEdge functions for manipulating directed edge indexes. 18 | */ 19 | 20 | #ifndef DIRECTEDEDGE_H 21 | #define DIRECTEDEDGE_H 22 | 23 | #include "algos.h" 24 | #include "h3Index.h" 25 | 26 | // nothing non-public in this file 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /h3/include/iterators.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** @file iterators.h 18 | * @brief Iterator structs and functions for the children of a cell, 19 | * or cells at a given resolution. 20 | */ 21 | 22 | #ifndef ITERATORS_H 23 | #define ITERATORS_H 24 | 25 | #include 26 | 27 | #include "h3api.h" 28 | 29 | /** 30 | * IterCellsChildren: struct for iterating through the descendants of 31 | * a given cell. 32 | * 33 | * Constructors: 34 | * 35 | * Initialize with either `iterInitParent` or `iterInitBaseCellNum`. 36 | * `iterInitParent` sets up an iterator for all the children of a given 37 | * parent cell at a given resolution. 38 | * 39 | * `iterInitBaseCellNum` sets up an iterator for children cells, given 40 | * a base cell number (0--121). 41 | * 42 | * Iteration: 43 | * 44 | * Step iterator with `iterStepChild`. 45 | * During the lifetime of the `IterCellsChildren`, the current iterate 46 | * is accessed via the `IterCellsChildren.h` member. 47 | * When the iterator is exhausted or if there was an error in initialization, 48 | * `IterCellsChildren.h` will be `H3_NULL` even after calling `iterStepChild`. 49 | */ 50 | typedef struct { 51 | H3Index h; 52 | int _parentRes; // parent resolution 53 | int _skipDigit; // this digit skips `1` for pentagons 54 | } IterCellsChildren; 55 | 56 | DECLSPEC IterCellsChildren iterInitParent(H3Index h, int childRes); 57 | void _iterInitParent(H3Index h, int childRes, IterCellsChildren *iter); 58 | DECLSPEC IterCellsChildren iterInitBaseCellNum(int baseCellNum, int childRes); 59 | DECLSPEC void iterStepChild(IterCellsChildren *iter); 60 | 61 | /** 62 | * IterCellsResolution: struct for iterating through all cells at a given 63 | * resolution 64 | * 65 | * Constructor: 66 | * 67 | * Initialize with `IterCellsResolution`. 68 | * 69 | * Iteration: 70 | * 71 | * Step iterator with `iterStepRes`. 72 | * During the lifetime of the iterator the current iterate 73 | * is accessed via the `IterCellsResolution.h` member. 74 | * When the iterator is exhausted or if there was an error in initialization, 75 | * `IterCellsResolution.h` will be `H3_NULL` even after calling `iterStepRes`. 76 | */ 77 | typedef struct { 78 | H3Index h; 79 | int _baseCellNum; 80 | int _res; 81 | IterCellsChildren _itC; 82 | } IterCellsResolution; 83 | 84 | DECLSPEC IterCellsResolution iterInitRes(int res); 85 | DECLSPEC void iterStepRes(IterCellsResolution *iter); 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /h3/include/latLng.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file latLng.h 17 | * @brief Geodetic (lat/lng) functions. 18 | */ 19 | 20 | #ifndef GEOPOINT_H 21 | #define GEOPOINT_H 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "constants.h" 28 | #include "h3api.h" 29 | 30 | /** epsilon of ~0.1mm in degrees */ 31 | #define EPSILON_DEG .000000001 32 | /** epsilon of ~0.1mm in radians */ 33 | #define EPSILON_RAD (EPSILON_DEG * M_PI_180) 34 | 35 | typedef enum { 36 | NORMALIZE_NONE = 0, // Do not normalize 37 | NORMALIZE_EAST = 1, // Normalize negative numbers to the east 38 | NORMALIZE_WEST = 2 // Normalize positive numbers to the west 39 | } LongitudeNormalization; 40 | 41 | void setGeoDegs(LatLng *p, double latDegs, double lngDegs); 42 | double constrainLat(double lat); 43 | double constrainLng(double lng); 44 | double normalizeLng(const double lng, 45 | const LongitudeNormalization normalization); 46 | 47 | bool geoAlmostEqual(const LatLng *p1, const LatLng *p2); 48 | bool geoAlmostEqualThreshold(const LatLng *p1, const LatLng *p2, 49 | double threshold); 50 | 51 | // Internal functions 52 | 53 | double _posAngleRads(double rads); 54 | void _setGeoRads(LatLng *p, double latRads, double lngRads); 55 | double _geoAzimuthRads(const LatLng *p1, const LatLng *p2); 56 | void _geoAzDistanceRads(const LatLng *p1, double az, double distance, 57 | LatLng *p2); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /h3/include/localij.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file localij.h 17 | * @brief Local IJ coordinate space functions. 18 | */ 19 | 20 | #ifndef LOCALIJ_H 21 | #define LOCALIJ_H 22 | 23 | #include "coordijk.h" 24 | #include "h3api.h" 25 | 26 | H3Error cellToLocalIjk(H3Index origin, H3Index h3, CoordIJK *out); 27 | H3Error localIjkToCell(H3Index origin, const CoordIJK *ijk, H3Index *out); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /h3/include/mathExtensions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2018, 2022 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file mathExtensions.h 17 | * @brief Math functions that should've been in math.h but aren't 18 | */ 19 | 20 | #ifndef MATHEXTENSIONS_H 21 | #define MATHEXTENSIONS_H 22 | 23 | #include 24 | #include 25 | 26 | /** 27 | * MAX returns the maximum of two values. 28 | */ 29 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) 30 | 31 | /** Evaluates to true if a + b would overflow for int32 */ 32 | static inline bool ADD_INT32S_OVERFLOWS(int32_t a, int32_t b) { 33 | if (a > 0) { 34 | return INT32_MAX - a < b; 35 | } else { 36 | return INT32_MIN - a > b; 37 | } 38 | } 39 | 40 | /** Evaluates to true if a - b would overflow for int32 */ 41 | static inline bool SUB_INT32S_OVERFLOWS(int32_t a, int32_t b) { 42 | if (a >= 0) { 43 | return INT32_MIN + a >= b; 44 | } else { 45 | return INT32_MAX + a + 1 < b; 46 | } 47 | } 48 | 49 | // Internal functions 50 | int64_t _ipow(int64_t base, int64_t exp); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /h3/include/vec2d.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file vec2d.h 17 | * @brief 2D floating point vector functions. 18 | */ 19 | 20 | #ifndef VEC2D_H 21 | #define VEC2D_H 22 | 23 | #include 24 | 25 | /** @struct Vec2d 26 | * @brief 2D floating-point vector 27 | */ 28 | typedef struct { 29 | double x; ///< x component 30 | double y; ///< y component 31 | } Vec2d; 32 | 33 | // Internal functions 34 | 35 | double _v2dMag(const Vec2d *v); 36 | void _v2dIntersect(const Vec2d *p0, const Vec2d *p1, const Vec2d *p2, 37 | const Vec2d *p3, Vec2d *inter); 38 | bool _v2dAlmostEquals(const Vec2d *p0, const Vec2d *p1); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /h3/include/vec3d.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, 2020-2021 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file vec3d.h 17 | * @brief 3D floating point vector functions. 18 | */ 19 | 20 | #ifndef VEC3D_H 21 | #define VEC3D_H 22 | 23 | #include "latLng.h" 24 | 25 | /** @struct Vec3D 26 | * @brief 3D floating point structure 27 | */ 28 | typedef struct { 29 | double x; ///< x component 30 | double y; ///< y component 31 | double z; ///< z component 32 | } Vec3d; 33 | 34 | void _geoToVec3d(const LatLng *geo, Vec3d *point); 35 | double _pointSquareDist(const Vec3d *p1, const Vec3d *p2); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /h3/include/vertex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2021 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file vertex.h 17 | * @brief Functions for working with cell vertexes. 18 | */ 19 | 20 | #ifndef H3VERTEX_H 21 | #define H3VERTEX_H 22 | 23 | #include "faceijk.h" 24 | #include "h3Index.h" 25 | 26 | /** @struct PentagonDirectionFaces 27 | * @brief The faces in each axial direction of a given pentagon base cell 28 | */ 29 | typedef struct { 30 | int baseCell; ///< base cell number 31 | int faces[NUM_PENT_VERTS]; ///< face numbers for each axial direction, 32 | /// in order, starting with J 33 | } PentagonDirectionFaces; 34 | 35 | /** Invalid vertex number */ 36 | #define INVALID_VERTEX_NUM -1 37 | 38 | /** Max number of faces a base cell's descendants may appear on */ 39 | #define MAX_BASE_CELL_FACES 5 40 | 41 | int vertexNumForDirection(const H3Index origin, const Direction direction); 42 | Direction directionForVertexNum(const H3Index origin, const int vertexNum); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /h3/include/vertexGraph.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, 2020-2021 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file vertexGraph.h 17 | * @brief Data structure for storing a graph of vertices 18 | */ 19 | 20 | #ifndef VERTEX_GRAPH_H 21 | #define VERTEX_GRAPH_H 22 | 23 | #include 24 | #include 25 | 26 | #include "latLng.h" 27 | 28 | /** @struct VertexNode 29 | * @brief A single node in a vertex graph, part of a linked list 30 | */ 31 | typedef struct VertexNode VertexNode; 32 | struct VertexNode { 33 | LatLng from; 34 | LatLng to; 35 | VertexNode *next; 36 | }; 37 | 38 | /** @struct VertexGraph 39 | * @brief A data structure to store a graph of vertices 40 | */ 41 | typedef struct { 42 | VertexNode **buckets; 43 | int numBuckets; 44 | int size; 45 | int res; 46 | } VertexGraph; 47 | 48 | void initVertexGraph(VertexGraph *graph, int numBuckets, int res); 49 | 50 | void destroyVertexGraph(VertexGraph *graph); 51 | 52 | VertexNode *addVertexNode(VertexGraph *graph, const LatLng *fromVtx, 53 | const LatLng *toVtx); 54 | 55 | int removeVertexNode(VertexGraph *graph, VertexNode *node); 56 | 57 | VertexNode *findNodeForEdge(const VertexGraph *graph, const LatLng *fromVtx, 58 | const LatLng *toVtx); 59 | 60 | VertexNode *findNodeForVertex(const VertexGraph *graph, const LatLng *fromVtx); 61 | 62 | VertexNode *firstVertexNode(const VertexGraph *graph); 63 | 64 | // Internal functions 65 | uint32_t _hashVertex(const LatLng *vertex, int res, int numBuckets); 66 | void _initVertexNode(VertexNode *node, const LatLng *fromVtx, 67 | const LatLng *toVtx); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /h3/lib/h3Assert.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file h3Assert.c 17 | * @brief Support code for unit testing 18 | */ 19 | 20 | #include "h3Assert.h" 21 | 22 | #if defined(H3_COVERAGE_TEST) || defined(H3_DEBUG) 23 | /* 24 | ** Counter used for coverage testing. Does not come into play for 25 | ** release builds. 26 | ** 27 | ** Access to this global variable is not mutex protected. This might 28 | ** result in TSAN warnings. But as the variable does not exist in 29 | ** release builds, that should not be a concern. 30 | */ 31 | unsigned int h3CoverageCounter; 32 | #endif 33 | -------------------------------------------------------------------------------- /h3/lib/mathExtensions.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file mathExtensions.c 17 | * @brief Math functions that should've been in math.h but aren't 18 | */ 19 | 20 | #include "mathExtensions.h" 21 | 22 | /** 23 | * _ipow does integer exponentiation efficiently. Taken from StackOverflow. 24 | * 25 | * @param base the integer base (can be positive or negative) 26 | * @param exp the integer exponent (should be nonnegative) 27 | * 28 | * @return the exponentiated value 29 | */ 30 | int64_t _ipow(int64_t base, int64_t exp) { 31 | int64_t result = 1; 32 | while (exp) { 33 | if (exp & 1) result *= base; 34 | exp >>= 1; 35 | base *= base; 36 | } 37 | 38 | return result; 39 | } 40 | -------------------------------------------------------------------------------- /h3/lib/vec2d.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file vec2d.c 17 | * @brief 2D floating point vector functions. 18 | */ 19 | 20 | #include "vec2d.h" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | /** 27 | * Calculates the magnitude of a 2D cartesian vector. 28 | * @param v The 2D cartesian vector. 29 | * @return The magnitude of the vector. 30 | */ 31 | double _v2dMag(const Vec2d *v) { return sqrt(v->x * v->x + v->y * v->y); } 32 | 33 | /** 34 | * Finds the intersection between two lines. Assumes that the lines intersect 35 | * and that the intersection is not at an endpoint of either line. 36 | * @param p0 The first endpoint of the first line. 37 | * @param p1 The second endpoint of the first line. 38 | * @param p2 The first endpoint of the second line. 39 | * @param p3 The second endpoint of the second line. 40 | * @param inter The intersection point. 41 | */ 42 | void _v2dIntersect(const Vec2d *p0, const Vec2d *p1, const Vec2d *p2, 43 | const Vec2d *p3, Vec2d *inter) { 44 | Vec2d s1, s2; 45 | s1.x = p1->x - p0->x; 46 | s1.y = p1->y - p0->y; 47 | s2.x = p3->x - p2->x; 48 | s2.y = p3->y - p2->y; 49 | 50 | double t; 51 | t = (s2.x * (p0->y - p2->y) - s2.y * (p0->x - p2->x)) / 52 | (-s2.x * s1.y + s1.x * s2.y); 53 | 54 | inter->x = p0->x + (t * s1.x); 55 | inter->y = p0->y + (t * s1.y); 56 | } 57 | 58 | /** 59 | * Whether two 2D vectors are almost equal, within some threshold 60 | * @param v1 First vector to compare 61 | * @param v2 Second vector to compare 62 | * @return Whether the vectors are almost equal 63 | */ 64 | bool _v2dAlmostEquals(const Vec2d *v1, const Vec2d *v2) { 65 | return fabs(v1->x - v2->x) < FLT_EPSILON && 66 | fabs(v1->y - v2->y) < FLT_EPSILON; 67 | } 68 | -------------------------------------------------------------------------------- /h3/lib/vec3d.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, 2020-2021 Uber Technologies, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** @file vec3d.c 17 | * @brief 3D floating point vector functions. 18 | */ 19 | 20 | #include "vec3d.h" 21 | 22 | #include 23 | 24 | /** 25 | * Square of a number 26 | * 27 | * @param x The input number. 28 | * @return The square of the input number. 29 | */ 30 | double _square(double x) { return x * x; } 31 | 32 | /** 33 | * Calculate the square of the distance between two 3D coordinates. 34 | * 35 | * @param v1 The first 3D coordinate. 36 | * @param v2 The second 3D coordinate. 37 | * @return The square of the distance between the given points. 38 | */ 39 | double _pointSquareDist(const Vec3d *v1, const Vec3d *v2) { 40 | return _square(v1->x - v2->x) + _square(v1->y - v2->y) + 41 | _square(v1->z - v2->z); 42 | } 43 | 44 | /** 45 | * Calculate the 3D coordinate on unit sphere from the latitude and longitude. 46 | * 47 | * @param geo The latitude and longitude of the point. 48 | * @param v The 3D coordinate of the point. 49 | */ 50 | void _geoToVec3d(const LatLng *geo, Vec3d *v) { 51 | double r = cos(geo->lat); 52 | 53 | v->z = sin(geo->lat); 54 | v->x = cos(geo->lng) * r; 55 | v->y = sin(geo->lng) * r; 56 | } 57 | -------------------------------------------------------------------------------- /hexer/BaseGrid.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "Mathpair.hpp" 9 | #include "Path.hpp" 10 | #include "HexId.hpp" 11 | 12 | #include

13 | 14 | namespace hexer 15 | { 16 | 17 | class HexGrid; 18 | class H3Grid; 19 | 20 | class BaseGrid 21 | { 22 | public: 23 | void addPoint(Point& p); 24 | void findShapes(); 25 | void findParentPaths(); 26 | bool isDense(HexId hex); 27 | void toWKT(std::ostream& output) const; 28 | 29 | // test function: adds pre-defined hexagon coordinates to the grid 30 | void setHexes(const std::vector& hexes); 31 | 32 | void setSampleSize(int num) 33 | {m_maxSample = num; } 34 | std::vector const& rootPaths() const 35 | { return m_roots; } 36 | // returns all hexagons in the grid and their counts 37 | std::unordered_map const& getHexes() 38 | { return m_counts; } 39 | 40 | virtual void addXY(double& x, double& y) = 0; 41 | virtual Point findPoint(Segment& s) = 0; 42 | virtual bool isH3() = 0; 43 | 44 | virtual H3Index ij2h3(HexId ij) 45 | { return 0; } 46 | virtual HexId h32ij(H3Index h3) 47 | { return {0,0}; } 48 | 49 | protected: 50 | BaseGrid(int dense_limit) : m_denseLimit{dense_limit} 51 | {} 52 | int increment(HexId hex); 53 | 54 | int m_maxSample; 55 | /// map of cells bordering paths at side 0 or 3 56 | std::unordered_map m_hexPaths; 57 | /// map of all hexagons containing points, and the number of points within. 58 | std::unordered_map m_counts; 59 | 60 | private: 61 | virtual bool sampling() const = 0; 62 | virtual HexId findHexagon(Point p) = 0; 63 | virtual HexId edgeHex(HexId hex, int edge) const = 0; 64 | virtual void processHeight(double height) = 0; 65 | virtual bool inGrid(HexId& h) = 0; 66 | virtual HexId moveCoord(HexId& h) = 0; 67 | 68 | void handleSamplePoint(Point& p); 69 | void addRoot(HexId hex); 70 | void removeRoot(HexId hex); 71 | void findShape(HexId root); 72 | double distance(const Point& p1, const Point& p2); 73 | double computeHexSize(); 74 | void parentOrChild(Path& p); 75 | std::pair nextSegments(const Segment& s) const; 76 | 77 | /// Vector of points to use to determine hex height 78 | std::vector m_sample; 79 | /// Set of hexagons with non-dense neighbors at side 0 80 | std::unordered_set m_possibleRoots; 81 | /// List of all paths 82 | std::list m_paths; 83 | /// List of pointers to paths in m_paths to be written as roots 84 | std::vector m_roots; 85 | /// Minimum number of points for a cell to be dense 86 | int m_denseLimit; 87 | }; 88 | 89 | } // namespace hexer 90 | -------------------------------------------------------------------------------- /hexer/H3grid.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | #include "Mathpair.hpp" 9 | #include "export.hpp" 10 | #include "BaseGrid.hpp" 11 | #include "HexId.hpp" 12 | #include "exception.hpp" 13 | 14 | #include

15 | 16 | namespace hexer 17 | { 18 | 19 | using DirEdge = H3Index; 20 | 21 | class H3Grid : public BaseGrid 22 | { 23 | public: 24 | H3Grid(int dense_limit) 25 | : BaseGrid{dense_limit}, m_res{-1}, m_origin{0} 26 | {} 27 | H3Grid(int res, int dense_limit) 28 | : BaseGrid{dense_limit}, m_res{res}, m_origin{0} 29 | {} 30 | 31 | H3Index ij2h3(HexId ij) 32 | { H3Index h3; 33 | if (localIjToCell(m_origin, &ij, 0, &h3) != E_SUCCESS) { 34 | std::ostringstream oss; 35 | oss << "Can't convert IJ (" << ij.i << 36 | ", " << ij.j <<") to H3Index."; 37 | throw hexer_error(oss.str()); 38 | } 39 | return h3; } 40 | 41 | // Convert H3 index to IJ coordinates 42 | HexId h32ij(H3Index h3) 43 | { HexId ij; 44 | if (cellToLocalIj(m_origin, h3, 0, &ij) != E_SUCCESS) { 45 | std::ostringstream oss; 46 | oss << "Can't convert H3 index " << h3 << 47 | " to IJ."; 48 | throw hexer_error(oss.str()); 49 | } 50 | return ij; } 51 | 52 | HexId findHexagon(Point p); 53 | HexId edgeHex(HexId hex, int edge) const; 54 | Point findPoint(Segment& s); 55 | 56 | void addXY(double& x, double& y) 57 | { 58 | Point p{degsToRads(x), degsToRads(y)}; 59 | addPoint(p); 60 | } 61 | bool sampling() const 62 | { return m_res < 0; } 63 | bool inGrid(HexId& h) 64 | { return h.i >= m_minI; } 65 | HexId moveCoord(HexId& h) 66 | { return HexId{h.i - 1, h.j}; } 67 | bool isH3() 68 | { return true; } 69 | 70 | // test function: used when inserting pre-defined grids in tests, 71 | // sets origin outside of findHexagon() 72 | void setOrigin(H3Index idx) 73 | { m_origin = idx; } 74 | // test function: used to get grid resolution to run h3 latLngToCell() 75 | int getRes() const 76 | { return m_res; } 77 | 78 | private: 79 | void processHeight(double height); 80 | 81 | /// H3 resolution of the grid (0-15) 82 | int m_res; 83 | /// minimum I value for iterating through parent paths 84 | int m_minI; 85 | /// origin index for converting between H3Index and CoordIJ 86 | H3Index m_origin; 87 | 88 | }; 89 | 90 | } // namepsace hexer 91 | 92 | 93 | -------------------------------------------------------------------------------- /hexer/HexGrid.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BaseGrid.hpp" 4 | 5 | namespace hexer 6 | { 7 | 8 | static const double SQRT_3 = 1.732050808; 9 | 10 | class HexGrid : public BaseGrid 11 | { 12 | public: 13 | HexGrid(double height, int denseLimit) : BaseGrid(denseLimit) 14 | { processHeight(height); } 15 | HexGrid(int denseLimit) : BaseGrid(denseLimit), m_width{-1.0} 16 | {} 17 | 18 | 19 | void addXY(double& x, double& y) 20 | { 21 | Point p{x, y}; 22 | addPoint(p); 23 | } 24 | bool sampling() const 25 | { return m_width < 0; } 26 | Point offset(int idx) const 27 | { return m_offsets[idx]; } 28 | bool inGrid(HexId& h) 29 | { return h.j >= m_minY; } 30 | bool isH3() 31 | { return false; } 32 | HexId moveCoord(HexId& h) 33 | { return HexId{h.i, h.j - 1}; } 34 | Point findPoint(Segment& s); 35 | 36 | private: 37 | void processHeight(double height); 38 | HexId findHexagon(Point p); 39 | HexId edgeHex(HexId hex, int edge) const; 40 | 41 | /// Height of the hexagons in the grid (2x apothem) 42 | double m_height; 43 | /// Width of the hexagons in the grid 44 | double m_width; 45 | /// Minimum y - 1. 46 | int m_minY; 47 | /// Offsets of vertices of hexagon, going anti-clockwise from upper-left 48 | Point m_offsets[6]; 49 | /// Offset of the center of the hexagons. 50 | Point m_centerOffset; 51 | /// Origin of the hex grid in point coordinates 52 | Point m_origin; 53 | 54 | }; 55 | 56 | } // namespace hexer 57 | -------------------------------------------------------------------------------- /hexer/HexId.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include

4 | 5 | namespace hexer 6 | { 7 | 8 | struct HexId : public CoordIJ 9 | {}; 10 | 11 | inline bool operator<(HexId const& c1, HexId const& c2) 12 | { 13 | return (c1.i < c2.i) || ((c1.i == c2.i) && (c1.j < c2.j)); 14 | } 15 | 16 | inline bool operator == (const HexId& h1, const HexId& h2) 17 | { 18 | return h1.i == h2.i && h1.j == h2.j; 19 | } 20 | 21 | static HexId operator+(HexId const& c1, HexId const& c2) 22 | { return {c1.i + c2.i, c1.j + c2.j}; } 23 | } 24 | 25 | namespace std 26 | { 27 | template<> 28 | struct hash 29 | { 30 | std::size_t operator()(hexer::HexId const & id) const noexcept 31 | { 32 | hash h; 33 | 34 | return h(id.i) ^ (h(id.j) << 1); 35 | } 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /hexer/Mathpair.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) 2014, Hobu Inc. (howard@hobu.co) 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following 8 | * conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided 15 | * with the distribution. 16 | * * Neither the name of the Howard Butler or Hobu, Inc. 17 | * the names of its contributors may be 18 | * used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 28 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | ****************************************************************************/ 34 | 35 | #pragma once 36 | 37 | #include "export.hpp" 38 | 39 | namespace hexer 40 | { 41 | 42 | template 43 | struct Mathpair 44 | { 45 | public: 46 | Mathpair() : m_x(T(0)), m_y(T(0)) 47 | {} 48 | 49 | Mathpair(T x, T y) : m_x(x), m_y(y) 50 | {} 51 | 52 | T m_x; 53 | T m_y; 54 | 55 | void operator -= (const Mathpair& p) 56 | { 57 | m_x -= p.m_x; 58 | m_y -= p.m_y; 59 | } 60 | 61 | Mathpair& operator += (const Mathpair& p) 62 | { 63 | m_x += p.m_x; 64 | m_y += p.m_y; 65 | return *this; 66 | } 67 | 68 | friend Mathpair operator - (Mathpair p1, const Mathpair& p2) 69 | { 70 | p1 -= p2; 71 | return p1; 72 | } 73 | 74 | friend Mathpair operator + (Mathpair p1, const Mathpair& p2) 75 | { 76 | p1 += p2; 77 | return p1; 78 | } 79 | }; 80 | 81 | typedef Mathpair Point; 82 | typedef Mathpair Coord; 83 | 84 | } // namespace hexer 85 | 86 | -------------------------------------------------------------------------------- /hexer/Path.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace hexer 4 | { 5 | 6 | void Path::toWKT(std::ostream& output) const 7 | { 8 | auto outputPoint = [&output](const Point& p) -> void 9 | { 10 | output << p.m_x << " " << p.m_y; 11 | }; 12 | 13 | output << "("; 14 | 15 | auto pi = m_points.begin(); 16 | if (pi != m_points.end()) 17 | outputPoint(*pi++); 18 | for (; pi != m_points.end(); ++pi) 19 | { 20 | output << ", "; 21 | outputPoint(*pi); 22 | } 23 | 24 | output << ")"; 25 | 26 | std::vector paths = subPaths(); 27 | for (auto p : paths) 28 | { 29 | output <<","; 30 | p->toWKT(output); 31 | } 32 | } 33 | } // namespace hexer 34 | -------------------------------------------------------------------------------- /hexer/Processor.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) 2014, Hobu Inc. (howard@hobu.co) 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following 8 | * conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided 15 | * with the distribution. 16 | * * Neither the name of the Howard Butler or Hobu, Inc. 17 | * the names of its contributors may be 18 | * used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 28 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | ****************************************************************************/ 34 | #pragma once 35 | 36 | #include 37 | #include 38 | 39 | #include 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | 48 | namespace hexer 49 | { 50 | typedef std::function PointReader; 51 | typedef std::function HexReader; 52 | 53 | void process(BaseGrid& grid, PointReader, int count); 54 | void processLaz(BaseGrid& grid, std::ifstream& file); 55 | 56 | std::string GetFullVersion( void ); 57 | } // namespace hexer 58 | 59 | -------------------------------------------------------------------------------- /hexer/Segment.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) 2014, Hobu Inc. (howard@hobu.co) 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following 8 | * conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided 15 | * with the distribution. 16 | * * Neither the name of the Howard Butler or Hobu, Inc. 17 | * the names of its contributors may be 18 | * used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 28 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | ****************************************************************************/ 34 | #pragma once 35 | 36 | #include 37 | 38 | #include "HexId.hpp" 39 | 40 | namespace hexer 41 | { 42 | 43 | struct Segment 44 | { 45 | Segment(HexId hex, int edge) : hex(hex), edge(edge) 46 | {} 47 | 48 | bool horizontal() const 49 | { return edge == 0 || edge == 3; } 50 | 51 | /// Hexagon who's side is the segment. 52 | HexId hex; 53 | /// Which side of the hexagon. 54 | int edge; 55 | }; 56 | 57 | inline bool operator == (const Segment& s1, const Segment& s2) 58 | { 59 | return s1.hex == s2.hex && s1.edge == s2.edge; 60 | } 61 | 62 | inline bool operator != (const Segment& s1, const Segment& s2) 63 | { 64 | return !(s1 == s2); 65 | } 66 | 67 | inline std::ostream& operator << (std::ostream& out, const Segment& s) 68 | { 69 | out << "(" << s.hex.i << "," << s.hex.j << " - " << s.edge << ")"; 70 | return out; 71 | } 72 | 73 | } // namespace hexer 74 | -------------------------------------------------------------------------------- /hexer/Utils.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) 2014, Hobu Inc. (howard@hobu.co) 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following 8 | * conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided 15 | * with the distribution. 16 | * * Neither the name of the Howard Butler or Hobu, Inc. 17 | * the names of its contributors may be 18 | * used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 28 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | ****************************************************************************/ 34 | #pragma once 35 | 36 | #include 37 | #include 38 | 39 | namespace hexer 40 | { 41 | 42 | // compares two values to within a given tolerance 43 | // the value |tolerance| is compared to |actual - expected| 44 | template 45 | static bool compare_approx(const T& actual, const T& expected, 46 | const T& tolerance) 47 | { 48 | const double diff = std::abs((double)actual - (double)expected); 49 | const double delta = std::abs((double)tolerance); 50 | 51 | if (diff > delta) 52 | { 53 | return false; 54 | } 55 | return true; 56 | } 57 | 58 | template 59 | static bool compare_distance(const T& actual, const T& expected) 60 | { 61 | const T epsilon = std::numeric_limits::epsilon(); 62 | return compare_approx(actual, expected, epsilon); 63 | } 64 | 65 | } // namespace hexer 66 | 67 | -------------------------------------------------------------------------------- /hexer/exception.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) 2014, Hobu Inc. (howard@hobu.co) 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following 8 | * conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided 15 | * with the distribution. 16 | * * Neither the name of the Howard Butler or Hobu, Inc. 17 | * the names of its contributors may be 18 | * used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 28 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | ****************************************************************************/ 34 | #pragma once 35 | 36 | #include 37 | 38 | namespace hexer 39 | { 40 | 41 | class hexer_error : public std::runtime_error 42 | { 43 | public: 44 | hexer_error(std::string const& msg) 45 | : std::runtime_error(msg) 46 | {} 47 | }; 48 | 49 | } // namespace hexer 50 | 51 | -------------------------------------------------------------------------------- /hexer/export.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) 2014, Hobu Inc. (howard@hobu.co) 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following 8 | * conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided 15 | * with the distribution. 16 | * * Neither the name of the Howard Butler or Hobu, Inc. 17 | * the names of its contributors may be 18 | * used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 28 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | ****************************************************************************/ 34 | 35 | 36 | #ifndef INCLUDED_HEXER_EXPORT_HPP 37 | #define INCLUDED_HEXER_EXPORT_HPP 38 | 39 | #include 40 | 41 | #ifndef HEXER_DLL 42 | #if defined(HEXER_COMPILER_MSVC) && !defined(HEXER_DISABLE_DLL) 43 | #if defined(HEXER_DLL_EXPORT) 44 | # define HEXER_DLL __declspec(dllexport) 45 | #elif defined(HEXER_DLL_IMPORT) 46 | # define HEXER_DLL __declspec(dllimport) 47 | #else 48 | # define HEXER_DLL 49 | #endif 50 | #else 51 | # if defined(USE_GCC_VISIBILITY_FLAG) 52 | # define HEXER_DLL __attribute__ ((visibility("default"))) 53 | # else 54 | # define HEXER_DLL 55 | # endif 56 | #endif 57 | #endif 58 | 59 | #ifdef HEXER_COMPILER_MSVC 60 | #pragma warning(disable:4251)// [templated class] needs to have dll-interface... 61 | #endif 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /hexer/hexer.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) 2014, Hobu Inc. (howard@hobu.co) 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following 8 | * conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided 15 | * with the distribution. 16 | * * Neither the name of the Howard Butler or Hobu, Inc. 17 | * the names of its contributors may be 18 | * used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 28 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 | * OF SUCH DAMAGE. 33 | ****************************************************************************/ 34 | 35 | #ifndef INCLUDED_HEXER_HPP 36 | #define INCLUDED_HEXER_HPP 37 | 38 | #include 39 | #include 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /hexer_defines.h.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | /* 6 | * version settings 7 | */ 8 | #define HEXER_VERSION_MAJOR @HEXER_VERSION_MAJOR@ 9 | #define HEXER_VERSION_MINOR @HEXER_VERSION_MINOR@ 10 | #define HEXER_VERSION_PATCH @HEXER_VERSION_PATCH@ 11 | 12 | namespace hexer 13 | { 14 | const int hexerVersionMajor { @HEXER_VERSION_MAJOR@ }; 15 | const int hexerVersionMinor { @HEXER_VERSION_MINOR@ }; 16 | const int hexerVersionPatch { @HEXER_VERSION_PATCH@ }; 17 | const std::string hexerVersion { "@HEXER_VERSION@" }; 18 | const std::string hexerSha { "@GIT_SHA1@" }; 19 | } // namespace hexer 20 | 21 | 22 | /* 23 | * availability of 3rd-party libraries 24 | */ 25 | #cmakedefine HEXER_HAVE_CAIRO 26 | 27 | /* 28 | * availability of execinfo and backtrace 29 | */ 30 | #cmakedefine HEXER_HAVE_EXECINFO_H 31 | 32 | /* 33 | * Debug or Release build? 34 | */ 35 | #define HEXER_BUILD_TYPE "@CMAKE_BUILD_TYPE@" 36 | 37 | #cmakedefine WITH_DRAWING 38 | 39 | /* 40 | * platform compiler 41 | */ 42 | #cmakedefine HEXER_COMPILER_MSVC 43 | -------------------------------------------------------------------------------- /hobu-config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | CONFIG="Unix Makefiles" 4 | BUILD_TYPE="Release" 5 | if ! [ -z "$1" ]; then 6 | CONFIG="$1" 7 | fi 8 | 9 | rm -rf build 10 | mkdir -p build && cd build 11 | 12 | cmake .. -G "$CONFIG" \ 13 | -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \ 14 | -DCMAKE_INSTALL_PREFIX=${CONDA_PREFIX} \ 15 | -DWITH_DRAWING=ON 16 | -------------------------------------------------------------------------------- /images/h3bounds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hobuinc/hexer/64f25d03f07e64886a0977063037ae6574c33ba6/images/h3bounds.png -------------------------------------------------------------------------------- /images/serpent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hobuinc/hexer/64f25d03f07e64886a0977063037ae6574c33ba6/images/serpent.png -------------------------------------------------------------------------------- /lazperf/coderbase.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #pragma once 4 | 5 | typedef union U32I32F32 6 | { 7 | uint32_t u32; 8 | int32_t i32; 9 | float f32; 10 | } U32I32F32; 11 | 12 | typedef union U64I64F64 13 | { 14 | uint64_t u64; 15 | int64_t i64; 16 | double f64; 17 | } U64I64F64; 18 | 19 | /* this header byte needs to change in case incompatible change happen */ 20 | const int AC_HEADER_BYTE = 2; 21 | const int AC_BUFFER_SIZE = 1024; 22 | 23 | const uint32_t AC__MinLength = 0x01000000U; // threshold for renormalization 24 | const uint32_t AC__MaxLength = 0xFFFFFFFFU; // maximum AC interval length 25 | 26 | // Maximum values for binary models 27 | const uint32_t BM__LengthShift = 13; // length bits discarded before mult. 28 | const uint32_t BM__MaxCount = 1 << BM__LengthShift; // for adaptive models 29 | 30 | // Maximum values for general models 31 | const uint32_t DM__LengthShift = 15; // length bits discarded before mult. 32 | const uint32_t DM__MaxCount = 1 << DM__LengthShift; // for adaptive models 33 | -------------------------------------------------------------------------------- /lazperf/detail/field_byte10.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | PROGRAMMERS: 5 | 6 | martin.isenburg@rapidlasso.com - http://rapidlasso.com 7 | uday.karan@gmail.com - Hobu, Inc. 8 | andrew.bell.ia@gmail.com - Hobu Inc. 9 | 10 | COPYRIGHT: 11 | 12 | (c) 2007-2014, martin isenburg, rapidlasso - tools to catch reality 13 | (c) 2014, Uday Verma, Hobu, Inc. 14 | 15 | This is free software; you can redistribute and/or modify it under the 16 | terms of the Apache Public License 2.0 published by the Apache Software 17 | Foundation. See the COPYING file for more information. 18 | 19 | This software is distributed WITHOUT ANY WARRANTY and without even the 20 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | 22 | =============================================================================== 23 | */ 24 | 25 | #include 26 | 27 | namespace lazperf 28 | { 29 | namespace detail 30 | { 31 | 32 | class Byte10Base 33 | { 34 | protected: 35 | Byte10Base(size_t count); 36 | 37 | size_t count_; 38 | bool have_last_; 39 | std::vector lasts_; 40 | std::vector diffs_; 41 | std::deque models_; 42 | }; 43 | 44 | class Byte10Compressor : public Byte10Base 45 | { 46 | public: 47 | Byte10Compressor(encoders::arithmetic& encoder, size_t count); 48 | 49 | const char *compress(const char *buf); 50 | 51 | private: 52 | encoders::arithmetic& enc_; 53 | }; 54 | 55 | class Byte10Decompressor : public Byte10Base 56 | { 57 | public: 58 | Byte10Decompressor(decoders::arithmetic& decoder, size_t count); 59 | 60 | char *decompress(char *buf); 61 | 62 | private: 63 | decoders::arithmetic& dec_; 64 | }; 65 | 66 | } // namespace detail 67 | } // namespace lazperf 68 | -------------------------------------------------------------------------------- /lazperf/detail/field_byte14.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | FILE: field_byte14.hpp 5 | 6 | CONTENTS: 7 | 8 | 9 | PROGRAMMERS: 10 | 11 | martin.isenburg@rapidlasso.com - http://rapidlasso.com 12 | uday.karan@gmail.com - Hobu, Inc. 13 | 14 | COPYRIGHT: 15 | 16 | (c) 2007-2014, martin isenburg, rapidlasso - tools to catch reality 17 | (c) 2014, Uday Verma, Hobu, Inc. 18 | 19 | This is free software; you can redistribute and/or modify it under the 20 | terms of the Apache Public License 2.0 published by the Apache Software 21 | Foundation. See the COPYING file for more information. 22 | 23 | This software is distributed WITHOUT ANY WARRANTY and without even the 24 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 25 | 26 | CHANGE HISTORY: 27 | 28 | =============================================================================== 29 | */ 30 | 31 | namespace lazperf 32 | { 33 | namespace detail 34 | { 35 | 36 | class Byte14Base 37 | { 38 | protected: 39 | struct ChannelCtx 40 | { 41 | int have_last_; 42 | las::byte14 last_; 43 | std::vector byte_model_; 44 | 45 | ChannelCtx(size_t count) : have_last_(false), last_(count), 46 | byte_model_(count, models::arithmetic(256)) 47 | {} 48 | }; 49 | 50 | public: 51 | size_t count() const; 52 | 53 | protected: 54 | Byte14Base(size_t count); 55 | 56 | size_t count_; 57 | int last_channel_; 58 | std::array chan_ctxs_; 59 | std::vector> byte_dec_; 60 | }; 61 | 62 | class Byte14Compressor : public Byte14Base 63 | { 64 | public: 65 | Byte14Compressor(OutCbStream& stream, size_t count); 66 | 67 | void writeSizes(); 68 | void writeData(); 69 | const char *compress(const char *buf, int& sc); 70 | 71 | private: 72 | OutCbStream& stream_; 73 | std::vector valid_; 74 | std::vector> byte_enc_; 75 | }; 76 | 77 | class Byte14Decompressor : public Byte14Base 78 | { 79 | public: 80 | Byte14Decompressor(InCbStream& stream, size_t count); 81 | 82 | void dumpSums(); 83 | void readSizes(); 84 | void readData(); 85 | char *decompress(char *buf, int& sc); 86 | 87 | private: 88 | InCbStream& stream_; 89 | std::vector byte_cnt_; 90 | std::vector> byte_dec_; 91 | utils::Summer sumByte; 92 | }; 93 | 94 | } // namespace detail 95 | } // namespace lazperf 96 | -------------------------------------------------------------------------------- /lazperf/detail/field_gpstime10.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | FILE: field_gpstime.hpp 5 | 6 | CONTENTS: 7 | 8 | 9 | PROGRAMMERS: 10 | 11 | martin.isenburg@rapidlasso.com - http://rapidlasso.com 12 | uday.karan@gmail.com - Hobu, Inc. 13 | 14 | COPYRIGHT: 15 | 16 | (c) 2007-2014, martin isenburg, rapidlasso - tools to catch reality 17 | (c) 2014, Uday Verma, Hobu, Inc. 18 | 19 | This is free software; you can redistribute and/or modify it under the 20 | terms of the Apache Public License 2.0 published by the Apache Software 21 | Foundation. See the COPYING file for more information. 22 | 23 | This software is distributed WITHOUT ANY WARRANTY and without even the 24 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 25 | 26 | CHANGE HISTORY: 27 | 28 | =============================================================================== 29 | */ 30 | 31 | namespace lazperf 32 | { 33 | namespace detail 34 | { 35 | 36 | class Gpstime10Base 37 | { 38 | protected: 39 | Gpstime10Base(); 40 | 41 | bool have_last_; 42 | models::arithmetic m_gpstime_multi, m_gpstime_0diff; 43 | unsigned int last; 44 | unsigned int next; 45 | std::array last_gpstime; 46 | std::array last_gpstime_diff; 47 | std::array multi_extreme_counter; 48 | }; 49 | 50 | class Gpstime10Compressor : public Gpstime10Base 51 | { 52 | public: 53 | Gpstime10Compressor(encoders::arithmetic&); 54 | 55 | const char *compress(const char *c); 56 | 57 | private: 58 | void init(); 59 | 60 | encoders::arithmetic& enc_; 61 | bool compressor_inited_; 62 | compressors::integer ic_gpstime; 63 | }; 64 | 65 | class Gpstime10Decompressor : public Gpstime10Base 66 | { 67 | public: 68 | Gpstime10Decompressor(decoders::arithmetic&); 69 | 70 | char *decompress(char *c); 71 | 72 | private: 73 | void init(); 74 | 75 | decoders::arithmetic& dec_; 76 | bool decompressor_inited_; 77 | decompressors::integer ic_gpstime; 78 | }; 79 | 80 | } // namespace detail 81 | } // namespace lazperf 82 | -------------------------------------------------------------------------------- /lazperf/detail/field_nir14.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | FILE: field_nir14.hpp 5 | 6 | CONTENTS: 7 | 8 | 9 | PROGRAMMERS: 10 | 11 | martin.isenburg@rapidlasso.com - http://rapidlasso.com 12 | uday.karan@gmail.com - Hobu, Inc. 13 | 14 | COPYRIGHT: 15 | 16 | (c) 2007-2014, martin isenburg, rapidlasso - tools to catch reality 17 | (c) 2014, Uday Verma, Hobu, Inc. 18 | 19 | This is free software; you can redistribute and/or modify it under the 20 | terms of the Apache Public License 2.0 published by the Apache Software 21 | Foundation. See the COPYING file for more information. 22 | 23 | This software is distributed WITHOUT ANY WARRANTY and without even the 24 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 25 | 26 | CHANGE HISTORY: 27 | 28 | =============================================================================== 29 | */ 30 | 31 | namespace lazperf 32 | { 33 | namespace detail 34 | { 35 | 36 | class Nir14Base 37 | { 38 | protected: 39 | struct ChannelCtx 40 | { 41 | int have_last_; 42 | las::nir14 last_; 43 | models::arithmetic used_model_; 44 | std::array diff_model_; 45 | 46 | ChannelCtx() : have_last_{false}, used_model_(4), 47 | diff_model_{ models::arithmetic(256), models::arithmetic(256) } 48 | {} 49 | }; 50 | 51 | std::array chan_ctxs_; 52 | int last_channel_ = -1; 53 | }; 54 | 55 | class Nir14Compressor : public Nir14Base 56 | { 57 | public: 58 | Nir14Compressor(OutCbStream& stream) : stream_(stream), nir_enc_(false) 59 | {} 60 | 61 | void writeSizes(); 62 | void writeData(); 63 | const char *compress(const char *buf, int& sc); 64 | 65 | private: 66 | OutCbStream& stream_; 67 | encoders::arithmetic nir_enc_; 68 | }; 69 | 70 | class Nir14Decompressor : public Nir14Base 71 | { 72 | public: 73 | Nir14Decompressor(InCbStream& stream) : stream_(stream) 74 | {} 75 | 76 | void dumpSums(); 77 | void readSizes(); 78 | void readData(); 79 | char *decompress(char *buf, int& sc); 80 | 81 | private: 82 | InCbStream& stream_; 83 | uint32_t nir_cnt_; 84 | decoders::arithmetic nir_dec_; 85 | utils::Summer sumNir; 86 | }; 87 | 88 | } // namespace detail 89 | } // namespace lazperf 90 | -------------------------------------------------------------------------------- /lazperf/detail/field_point10.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | FILE: field_point10.hpp 5 | 6 | CONTENTS: 7 | 8 | 9 | PROGRAMMERS: 10 | 11 | martin.isenburg@rapidlasso.com - http://rapidlasso.com 12 | uday.karan@gmail.com - Hobu, Inc. 13 | 14 | COPYRIGHT: 15 | 16 | (c) 2007-2014, martin isenburg, rapidlasso - tools to catch reality 17 | (c) 2014, Uday Verma, Hobu, Inc. 18 | 19 | This is free software; you can redistribute and/or modify it under the 20 | terms of the Apache Public License 2.0 published by the Apache Software 21 | Foundation. See the COPYING file for more information. 22 | 23 | This software is distributed WITHOUT ANY WARRANTY and without even the 24 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 25 | 26 | CHANGE HISTORY: 27 | 28 | =============================================================================== 29 | */ 30 | 31 | #include "../compressor.hpp" 32 | #include "../decompressor.hpp" 33 | 34 | namespace lazperf 35 | { 36 | namespace detail 37 | { 38 | 39 | class Point10Base 40 | { 41 | protected: 42 | Point10Base(); 43 | ~Point10Base(); 44 | 45 | las::point10 last_; 46 | std::array last_intensity; 47 | 48 | std::array, 16> last_x_diff_median5; 49 | std::array, 16> last_y_diff_median5; 50 | 51 | std::array last_height; 52 | models::arithmetic m_changed_values; 53 | 54 | // Arithmetic model has no default constructor, so we store they here as raw pointers 55 | std::array m_scan_angle_rank; 56 | std::array m_bit_byte; 57 | std::array m_classification; 58 | std::array m_user_data; 59 | bool have_last_; 60 | }; 61 | 62 | class Point10Compressor : public Point10Base 63 | { 64 | public: 65 | Point10Compressor(encoders::arithmetic&); 66 | 67 | const char *compress(const char *buf); 68 | 69 | private: 70 | void init(); 71 | 72 | encoders::arithmetic& enc_; 73 | compressors::integer ic_intensity; 74 | compressors::integer ic_point_source_ID; 75 | compressors::integer ic_dx; 76 | compressors::integer ic_dy; 77 | compressors::integer ic_z; 78 | bool compressors_inited_; 79 | }; 80 | 81 | class Point10Decompressor : public Point10Base 82 | { 83 | public: 84 | Point10Decompressor(decoders::arithmetic&); 85 | 86 | char *decompress(char *buf); 87 | 88 | private: 89 | void init(); 90 | 91 | decoders::arithmetic& dec_; 92 | decompressors::integer ic_intensity; 93 | decompressors::integer ic_point_source_ID; 94 | decompressors::integer ic_dx; 95 | decompressors::integer ic_dy; 96 | decompressors::integer ic_z; 97 | bool decompressors_inited_; 98 | }; 99 | 100 | } // namespace detail 101 | } // namespace lazperf 102 | -------------------------------------------------------------------------------- /lazperf/detail/field_rgb10.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | PROGRAMMERS: 5 | 6 | martin.isenburg@rapidlasso.com - http://rapidlasso.com 7 | uday.karan@gmail.com - Hobu, Inc. 8 | 9 | COPYRIGHT: 10 | 11 | (c) 2007-2014, martin isenburg, rapidlasso - tools to catch reality 12 | (c) 2014, Uday Verma, Hobu, Inc. 13 | 14 | This is free software; you can redistribute and/or modify it under the 15 | terms of the Apache Public License 2.0 published by the Apache Software 16 | Foundation. See the COPYING file for more information. 17 | 18 | This software is distributed WITHOUT ANY WARRANTY and without even the 19 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | 21 | CHANGE HISTORY: 22 | 23 | =============================================================================== 24 | */ 25 | 26 | namespace lazperf 27 | { 28 | namespace detail 29 | { 30 | 31 | class Rgb10Base 32 | { 33 | protected: 34 | Rgb10Base(); 35 | 36 | bool have_last_; 37 | las::rgb last; 38 | 39 | models::arithmetic m_byte_used; 40 | models::arithmetic m_rgb_diff_0; 41 | models::arithmetic m_rgb_diff_1; 42 | models::arithmetic m_rgb_diff_2; 43 | models::arithmetic m_rgb_diff_3; 44 | models::arithmetic m_rgb_diff_4; 45 | models::arithmetic m_rgb_diff_5; 46 | }; 47 | 48 | class Rgb10Compressor : public Rgb10Base 49 | { 50 | public: 51 | Rgb10Compressor(encoders::arithmetic&); 52 | 53 | const char *compress(const char *buf); 54 | 55 | private: 56 | encoders::arithmetic& enc_; 57 | }; 58 | 59 | class Rgb10Decompressor : public Rgb10Base 60 | { 61 | public: 62 | Rgb10Decompressor(decoders::arithmetic&); 63 | 64 | char *decompress(char *buf); 65 | 66 | private: 67 | decoders::arithmetic& dec_; 68 | }; 69 | 70 | } // namespace detail 71 | } // namespace lazperf 72 | -------------------------------------------------------------------------------- /lazperf/detail/field_rgb14.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | FILE: field_rgb14.hpp 5 | 6 | CONTENTS: 7 | 8 | 9 | PROGRAMMERS: 10 | 11 | martin.isenburg@rapidlasso.com - http://rapidlasso.com 12 | uday.karan@gmail.com - Hobu, Inc. 13 | 14 | COPYRIGHT: 15 | 16 | (c) 2007-2014, martin isenburg, rapidlasso - tools to catch reality 17 | (c) 2014, Uday Verma, Hobu, Inc. 18 | 19 | This is free software; you can redistribute and/or modify it under the 20 | terms of the Apache Public License 2.0 published by the Apache Software 21 | Foundation. See the COPYING file for more information. 22 | 23 | This software is distributed WITHOUT ANY WARRANTY and without even the 24 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 25 | 26 | CHANGE HISTORY: 27 | 28 | =============================================================================== 29 | */ 30 | 31 | namespace lazperf 32 | { 33 | namespace detail 34 | { 35 | 36 | class Rgb14Base 37 | { 38 | protected: 39 | struct ChannelCtx 40 | { 41 | int have_last_; 42 | las::rgb14 last_; 43 | models::arithmetic used_model_; 44 | std::array diff_model_; 45 | 46 | ChannelCtx() : have_last_{false}, used_model_(128), 47 | diff_model_{ models::arithmetic(256), models::arithmetic(256), 48 | models::arithmetic(256), models::arithmetic(256), 49 | models::arithmetic(256), models::arithmetic(256) } 50 | {} 51 | }; 52 | 53 | std::array chan_ctxs_; 54 | int last_channel_ = -1; 55 | }; 56 | 57 | class Rgb14Compressor : public Rgb14Base 58 | { 59 | public: 60 | Rgb14Compressor(OutCbStream& stream) : stream_(stream), rgb_enc_(false) 61 | {} 62 | 63 | void writeSizes(); 64 | void writeData(); 65 | const char *compress(const char *buf, int& sc); 66 | 67 | private: 68 | OutCbStream& stream_; 69 | encoders::arithmetic rgb_enc_; 70 | }; 71 | 72 | class Rgb14Decompressor : public Rgb14Base 73 | { 74 | public: 75 | Rgb14Decompressor(InCbStream& stream) : stream_(stream) 76 | {} 77 | 78 | void dumpSums(); 79 | void readSizes(); 80 | void readData(); 81 | char *decompress(char *buf, int& sc); 82 | 83 | private: 84 | InCbStream& stream_; 85 | uint32_t rgb_cnt_; 86 | decoders::arithmetic rgb_dec_; 87 | utils::Summer sumRgb; 88 | }; 89 | 90 | } // namespace detail 91 | } // namespace laszip 92 | -------------------------------------------------------------------------------- /lazperf/excepts.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | FILE: excepts.hpp 5 | 6 | CONTENTS: 7 | Exception types 8 | 9 | PROGRAMMERS: 10 | 11 | martin.isenburg@rapidlasso.com - http://rapidlasso.com 12 | uday.karan@gmail.com - Hobu, Inc. 13 | 14 | COPYRIGHT: 15 | 16 | (c) 2007-2014, martin isenburg, rapidlasso - tools to catch reality 17 | (c) 2014, Uday Verma, Hobu, Inc. 18 | 19 | This is free software; you can redistribute and/or modify it under the 20 | terms of the Apache Public License 2.0 published by the Apache Software 21 | Foundation. See the COPYING file for more information. 22 | 23 | This software is distributed WITHOUT ANY WARRANTY and without even the 24 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 25 | 26 | CHANGE HISTORY: 27 | 28 | =============================================================================== 29 | */ 30 | 31 | #ifndef __excepts_hpp__ 32 | #define __excepts_hpp__ 33 | 34 | #include 35 | 36 | namespace lazperf 37 | { 38 | 39 | struct error : public std::runtime_error 40 | { 41 | error(const std::string& what) : std::runtime_error(what) 42 | {} 43 | }; 44 | 45 | } // namespace lazperf 46 | 47 | #endif // __excepts_hpp__ 48 | -------------------------------------------------------------------------------- /lazperf/filestream.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | FILE: filestream.hpp 5 | 6 | CONTENTS: 7 | Stream abstractions 8 | 9 | PROGRAMMERS: 10 | 11 | uday.karan@gmail.com - Hobu, Inc. 12 | 13 | COPYRIGHT: 14 | 15 | (c) 2014, Uday Verma, Hobu, Inc. 16 | 17 | This is free software; you can redistribute and/or modify it under the 18 | terms of the Apache Public License 2.0 published by the Apache Software 19 | Foundation. See the COPYING file for more information. 20 | 21 | This software is distributed WITHOUT ANY WARRANTY and without even the 22 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 23 | 24 | CHANGE HISTORY: 25 | 26 | =============================================================================== 27 | */ 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | #include "lazperf.hpp" 34 | 35 | namespace lazperf 36 | { 37 | 38 | // Convenience class 39 | 40 | struct OutFileStream 41 | { 42 | public: 43 | LAZPERF_EXPORT OutFileStream(std::ostream& out); 44 | 45 | LAZPERF_EXPORT void putBytes(const unsigned char *c, size_t len); 46 | LAZPERF_EXPORT OutputCb cb(); 47 | 48 | private: 49 | std::ostream& f_; 50 | }; 51 | 52 | // Convenience class 53 | 54 | struct InFileStream 55 | { 56 | struct Private; 57 | 58 | public: 59 | LAZPERF_EXPORT InFileStream(std::istream& in); 60 | LAZPERF_EXPORT ~InFileStream(); 61 | 62 | // This will force a fill on the next fetch. 63 | LAZPERF_EXPORT void reset(); 64 | LAZPERF_EXPORT InputCb cb(); 65 | 66 | private: 67 | std::unique_ptr p_; 68 | }; 69 | 70 | } // namespace lazperf 71 | 72 | -------------------------------------------------------------------------------- /lazperf/lazperf_base.hpp: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #define LAZPERF_MAJOR_VERSION 3 5 | #define LAZPERF_MINOR_VERSION 2 6 | #define LAZPERF_REVISION 0 7 | #define LAZPERF_VERSION 3.2.0 8 | 9 | #ifndef LAZPERF_VENDORED 10 | #ifdef _WIN32 11 | #define LAZPERF_EXPORT __declspec(dllexport) 12 | #else 13 | // This may not be necessary. The GCC doc says it take __declspec((dllexport)) 14 | #define LAZPERF_EXPORT __attribute__((visibility ("default"))) 15 | #endif 16 | #else 17 | #define LAZPERF_EXPORT 18 | #endif 19 | -------------------------------------------------------------------------------- /lazperf/lazperf_user_base.hpp: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #define LAZPERF_MAJOR_VERSION 1 5 | #define LAZPERF_MINOR_VERSION 3 6 | #define LAZPERF_REVISION 0 7 | #define LAZPERF_VERSION 1.3.0 8 | 9 | // Note that this __declspec(dllimport) is not necessary and you can remove it if you like. 10 | // It allows the compiler to make a potential optimization in calling exported functions 11 | // by using an indirect call rather than a call to a thunk which then calls the exported function. 12 | #ifdef _WIN32 13 | #define LAZPERF_EXPORT __declspec(dllimport) 14 | #else 15 | #define LAZPERF_EXPORT 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /lazperf/readers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | PROGRAMMERS: 5 | 6 | martin.isenburg@rapidlasso.com - http://rapidlasso.com 7 | uday.karan@gmail.com - Hobu, Inc. 8 | 9 | COPYRIGHT: 10 | 11 | (c) 2007-2014, martin isenburg, rapidlasso - tools to catch reality 12 | (c) 2014, Uday Verma, Hobu, Inc. 13 | 14 | This is free software; you can redistribute and/or modify it under the 15 | terms of the Apache Public License 2.0 published by the Apache Software 16 | Foundation. See the COPYING file for more information. 17 | 18 | This software is distributed WITHOUT ANY WARRANTY and without even the 19 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | 21 | =============================================================================== 22 | */ 23 | 24 | #pragma once 25 | 26 | #include "header.hpp" 27 | #include "vlr.hpp" 28 | 29 | namespace lazperf 30 | { 31 | namespace reader 32 | { 33 | 34 | class basic_file 35 | { 36 | FRIEND_TEST(io_tests, parses_laszip_vlr_correctly); 37 | struct Private; 38 | 39 | protected: 40 | basic_file(); 41 | ~basic_file(); 42 | 43 | bool open(std::istream& in); 44 | 45 | public: 46 | LAZPERF_EXPORT uint64_t pointCount() const; 47 | LAZPERF_EXPORT const header14& header() const; 48 | LAZPERF_EXPORT void readPoint(char *out); 49 | LAZPERF_EXPORT laz_vlr lazVlr() const; 50 | LAZPERF_EXPORT std::vector vlrData(const std::string& user_id, uint16_t record_id); 51 | 52 | private: 53 | // The file object is not copyable or copy constructible 54 | basic_file(const basic_file&) = delete; 55 | basic_file& operator = (const basic_file&) = delete; 56 | 57 | std::unique_ptr p_; 58 | }; 59 | 60 | class mem_file : public basic_file 61 | { 62 | struct Private; 63 | 64 | public: 65 | LAZPERF_EXPORT mem_file(char *buf, size_t count); 66 | LAZPERF_EXPORT ~mem_file(); 67 | 68 | private: 69 | std::unique_ptr p_; 70 | }; 71 | 72 | class generic_file : public basic_file 73 | { 74 | public: 75 | LAZPERF_EXPORT ~generic_file(); 76 | LAZPERF_EXPORT generic_file(std::istream& in); 77 | }; 78 | 79 | class named_file : public basic_file 80 | { 81 | struct Private; 82 | 83 | public: 84 | LAZPERF_EXPORT named_file(const std::string& filename); 85 | LAZPERF_EXPORT ~named_file(); 86 | 87 | private: 88 | std::unique_ptr p_; 89 | }; 90 | 91 | /// 92 | 93 | class chunk_decompressor 94 | { 95 | struct Private; 96 | public: 97 | LAZPERF_EXPORT chunk_decompressor(int format, int ebCount, const char *srcbuf); 98 | LAZPERF_EXPORT ~chunk_decompressor(); 99 | LAZPERF_EXPORT void decompress(char *outbuf); 100 | 101 | private: 102 | std::unique_ptr p_; 103 | }; 104 | 105 | } // namespace reader 106 | } // namespace lazperf 107 | 108 | -------------------------------------------------------------------------------- /lazperf/writers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | 4 | PROGRAMMERS: 5 | 6 | martin.isenburg@rapidlasso.com - http://rapidlasso.com 7 | uday.karan@gmail.com - Hobu, Inc. 8 | 9 | COPYRIGHT: 10 | 11 | (c) 2007-2014, martin isenburg, rapidlasso - tools to catch reality 12 | (c) 2014, Uday Verma, Hobu, Inc. 13 | 14 | This is free software; you can redistribute and/or modify it under the 15 | terms of the Apache Public License 2.0 published by the Apache Software 16 | Foundation. See the COPYING file for more information. 17 | 18 | This software is distributed WITHOUT ANY WARRANTY and without even the 19 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | 21 | =============================================================================== 22 | */ 23 | 24 | #pragma once 25 | 26 | #include 27 | 28 | #include "header.hpp" 29 | 30 | namespace lazperf 31 | { 32 | namespace writer 33 | { 34 | 35 | class basic_file 36 | { 37 | protected: 38 | struct Private; 39 | 40 | basic_file(); 41 | virtual ~basic_file(); 42 | 43 | public: 44 | LAZPERF_EXPORT bool open(std::ostream& out, const header12& h, uint32_t chunk_size); 45 | LAZPERF_EXPORT void writePoint(const char *p); 46 | LAZPERF_EXPORT void close(); 47 | LAZPERF_EXPORT uint64_t newChunk(); 48 | LAZPERF_EXPORT uint64_t firstChunkOffset() const; 49 | LAZPERF_EXPORT virtual bool compressed() const; 50 | 51 | protected: 52 | std::unique_ptr p_; 53 | }; 54 | 55 | class named_file : public basic_file 56 | { 57 | struct Private; 58 | 59 | public: 60 | struct LAZPERF_EXPORT config 61 | { 62 | public: 63 | vector3 scale; 64 | vector3 offset; 65 | unsigned int chunk_size; 66 | int pdrf; 67 | int minor_version; 68 | int extra_bytes; 69 | 70 | explicit config(); 71 | config(const vector3& scale, const vector3& offset, 72 | unsigned int chunksize = DefaultChunkSize); 73 | config(const header12& header); 74 | 75 | header12 to_header() const; 76 | }; 77 | 78 | LAZPERF_EXPORT named_file(const std::string& filename, const config& c); 79 | LAZPERF_EXPORT virtual ~named_file(); 80 | 81 | LAZPERF_EXPORT void close(); 82 | 83 | private: 84 | std::unique_ptr p_; 85 | }; 86 | 87 | class chunk_compressor 88 | { 89 | struct Private; 90 | public: 91 | LAZPERF_EXPORT chunk_compressor(int format, int ebCount); 92 | LAZPERF_EXPORT ~chunk_compressor(); 93 | LAZPERF_EXPORT void compress(const char *inbuf); 94 | LAZPERF_EXPORT std::vector done(); 95 | 96 | protected: 97 | std::unique_ptr p_; 98 | }; 99 | 100 | } // namespace writer 101 | } // namespace lazperf 102 | 103 | -------------------------------------------------------------------------------- /make_shapes.py: -------------------------------------------------------------------------------- 1 | import shapefile 2 | import random 3 | 4 | import pdb;pdb.set_trace() 5 | w = shapefile.Writer('points',shapefile.POINT) 6 | w.field("ID") 7 | 8 | size = 100000 9 | for i in range(size): 10 | x = float(random.randrange(0,size)) 11 | y = float(random.randrange(0,size)) 12 | 13 | 14 | yn = [True, False] 15 | if (random.choice(yn)): 16 | w.point(x,y) 17 | w.record(i) 18 | 19 | 20 | w.close() 21 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(GTEST_DIR gtest/gtest-10-06-21) 2 | 3 | set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) 4 | 5 | macro(HEXER_ADD_TEST _name) 6 | add_executable(${_name} ${_name}.cpp ${LIB_SRCS} ${LAZPERF_SRCS}) 7 | target_link_libraries(${_name} gtest ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${GDAL_LIBRARY} ${H3_LIB_NAME}) 8 | target_include_directories(${_name} PRIVATE ${GDAL_INCLUDE_DIR}) 9 | target_include_directories(${_name} PRIVATE ${GTEST_DIR}/include) 10 | target_include_directories(${_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 11 | target_include_directories(${_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) 12 | add_test(NAME ${_name} COMMAND ${HEXER_BINARY_DIR}/${_name}) 13 | endmacro(HEXER_ADD_TEST) 14 | 15 | configure_file(test_main.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/test_main.hpp) 16 | configure_file(${hexer_defines_h} ${CMAKE_CURRENT_BINARY_DIR}/hexer/hexer_defines.h) 17 | add_subdirectory(${GTEST_DIR}) 18 | 19 | HEXER_ADD_TEST(gridtest) 20 | HEXER_ADD_TEST(pathstest) 21 | 22 | -------------------------------------------------------------------------------- /test/data/autzen_trim.las: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hobuinc/hexer/64f25d03f07e64886a0977063037ae6574c33ba6/test/data/autzen_trim.las -------------------------------------------------------------------------------- /test/data/autzen_trim.laz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hobuinc/hexer/64f25d03f07e64886a0977063037ae6574c33ba6/test/data/autzen_trim.laz -------------------------------------------------------------------------------- /test/gridtest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "test_main.hpp" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include

14 | 15 | namespace hexer { 16 | 17 | void inputTest(std::string const& input) { 18 | 19 | std::unique_ptr grid; 20 | 21 | int density = 10; 22 | grid.reset(new HexGrid(density)); 23 | 24 | std::ifstream file(input, std::ios::binary); 25 | processLaz(*grid, file); 26 | 27 | int maxX = -1000000; 28 | int minX = 1000000; 29 | int maxY = -1000000; 30 | int minY = 1000000; 31 | int cnt = 0; 32 | const std::unordered_map& hexes = grid->getHexes(); 33 | for (auto it = hexes.begin(); it != hexes.end(); it++) { 34 | if (grid->isDense(it->first)){ 35 | maxX = std::max(it->first.i, maxX); 36 | minX = std::min(it->first.i, minX); 37 | maxY = std::max(it->first.j, maxY); 38 | minY = std::min(it->first.j, minY); 39 | } 40 | } 41 | EXPECT_EQ(maxX, 0); 42 | EXPECT_EQ(minX, -23); 43 | EXPECT_EQ(maxY, 1); 44 | EXPECT_EQ(minY, -9); 45 | } 46 | 47 | 48 | TEST(gridtest, grid_output_las) { 49 | inputTest(testFile("autzen_trim.las")); 50 | } 51 | 52 | TEST(gridtest, grid_output_laz) { 53 | inputTest(testFile("autzen_trim.laz")); 54 | } 55 | 56 | TEST(gridtest, test_h3_exist) { 57 | LatLng location; 58 | location.lat = degsToRads(40.689167); 59 | location.lng = degsToRads(-74.044444); 60 | int resolution = 10; 61 | H3Index index; 62 | EXPECT_EQ(latLngToCell(&location, resolution, &index), E_SUCCESS); 63 | } 64 | } //namespace hexer -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(GOOGLETEST_VERSION 1.10.0) 2 | add_subdirectory( googletest ) 3 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file contains a list of people who've made non-trivial 2 | # contribution to the Google C++ Testing Framework project. People 3 | # who commit code to the project are encouraged to add their names 4 | # here. Please keep the list sorted by first names. 5 | 6 | Ajay Joshi 7 | Balázs Dán 8 | Benoit Sigoure 9 | Bharat Mediratta 10 | Bogdan Piloca 11 | Chandler Carruth 12 | Chris Prince 13 | Chris Taylor 14 | Dan Egnor 15 | Dave MacLachlan 16 | David Anderson 17 | Dean Sturtevant 18 | Eric Roman 19 | Gene Volovich 20 | Hady Zalek 21 | Hal Burch 22 | Jeffrey Yasskin 23 | Jim Keller 24 | Joe Walnes 25 | Jon Wray 26 | Jói Sigurðsson 27 | Keir Mierle 28 | Keith Ray 29 | Kenton Varda 30 | Kostya Serebryany 31 | Krystian Kuzniarek 32 | Lev Makhlis 33 | Manuel Klimek 34 | Mario Tanev 35 | Mark Paskin 36 | Markus Heule 37 | Matthew Simmons 38 | Mika Raento 39 | Mike Bland 40 | Miklós Fazekas 41 | Neal Norwitz 42 | Nermin Ozkiranartli 43 | Owen Carlsen 44 | Paneendra Ba 45 | Pasi Valminen 46 | Patrick Hanna 47 | Patrick Riley 48 | Paul Menage 49 | Peter Kaminski 50 | Piotr Kaminski 51 | Preston Jackson 52 | Rainer Klaffenboeck 53 | Russ Cox 54 | Russ Rufer 55 | Sean Mcafee 56 | Sigurður Ásgeirsson 57 | Sverre Sundsdal 58 | Takeshi Yoshino 59 | Tracy Bialik 60 | Vadim Berman 61 | Vlad Losev 62 | Wolfgang Klier 63 | Zhanyong Wan 64 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/cmake/Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | include(CMakeFindDependencyMacro) 3 | if (@GTEST_HAS_PTHREAD@) 4 | set(THREADS_PREFER_PTHREAD_FLAG @THREADS_PREFER_PTHREAD_FLAG@) 5 | find_dependency(Threads) 6 | endif() 7 | 8 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") 9 | check_required_components("@project_name@") 10 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/cmake/gtest.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gtest 5 | Description: GoogleTest (without main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Libs: -L${libdir} -lgtest @CMAKE_THREAD_LIBS_INIT@ 9 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 10 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/cmake/gtest_main.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gtest_main 5 | Description: GoogleTest (with main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Requires: gtest = @PROJECT_VERSION@ 9 | Libs: -L${libdir} -lgtest_main @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 11 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/cmake/libgtest.la.in: -------------------------------------------------------------------------------- 1 | # libgtest.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Names of this library. 8 | library_names='libgtest.so' 9 | 10 | # Is this an already installed library? 11 | installed=yes 12 | 13 | # Should we warn about portability when linking against -modules? 14 | shouldnotlink=no 15 | 16 | # Files to dlopen/dlpreopen 17 | dlopen='' 18 | dlpreopen='' 19 | 20 | # Directory that this library needs to be installed in: 21 | libdir='@CMAKE_INSTALL_FULL_LIBDIR@' 22 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/docs/README.md: -------------------------------------------------------------------------------- 1 | # Content Moved 2 | 3 | We are working on updates to the GoogleTest documentation, which has moved to 4 | the top-level [docs](../../docs) directory. 5 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/include/gtest/gtest_prod.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Google C++ Testing and Mocking Framework definitions useful in production code. 32 | // GOOGLETEST_CM0003 DO NOT DELETE 33 | 34 | #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_ 35 | #define GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_ 36 | 37 | // When you need to test the private or protected members of a class, 38 | // use the FRIEND_TEST macro to declare your tests as friends of the 39 | // class. For example: 40 | // 41 | // class MyClass { 42 | // private: 43 | // void PrivateMethod(); 44 | // FRIEND_TEST(MyClassTest, PrivateMethodWorks); 45 | // }; 46 | // 47 | // class MyClassTest : public testing::Test { 48 | // // ... 49 | // }; 50 | // 51 | // TEST_F(MyClassTest, PrivateMethodWorks) { 52 | // // Can call MyClass::PrivateMethod() here. 53 | // } 54 | // 55 | // Note: The test class must be in the same namespace as the class being tested. 56 | // For example, putting MyClassTest in an anonymous namespace will not work. 57 | 58 | #define FRIEND_TEST(test_case_name, test_name)\ 59 | friend class test_case_name##_##test_name##_Test 60 | 61 | #endif // GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_ 62 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/include/gtest/internal/custom/README.md: -------------------------------------------------------------------------------- 1 | # Customization Points 2 | 3 | The custom directory is an injection point for custom user configurations. 4 | 5 | ## Header `gtest.h` 6 | 7 | ### The following macros can be defined: 8 | 9 | * `GTEST_OS_STACK_TRACE_GETTER_` - The name of an implementation of 10 | `OsStackTraceGetterInterface`. 11 | * `GTEST_CUSTOM_TEMPDIR_FUNCTION_` - An override for `testing::TempDir()`. See 12 | `testing::TempDir` for semantics and signature. 13 | 14 | ## Header `gtest-port.h` 15 | 16 | The following macros can be defined: 17 | 18 | ### Flag related macros: 19 | 20 | * `GTEST_FLAG(flag_name)` 21 | * `GTEST_USE_OWN_FLAGFILE_FLAG_` - Define to 0 when the system provides its 22 | own flagfile flag parsing. 23 | * `GTEST_DECLARE_bool_(name)` 24 | * `GTEST_DECLARE_int32_(name)` 25 | * `GTEST_DECLARE_string_(name)` 26 | * `GTEST_DEFINE_bool_(name, default_val, doc)` 27 | * `GTEST_DEFINE_int32_(name, default_val, doc)` 28 | * `GTEST_DEFINE_string_(name, default_val, doc)` 29 | 30 | ### Logging: 31 | 32 | * `GTEST_LOG_(severity)` 33 | * `GTEST_CHECK_(condition)` 34 | * Functions `LogToStderr()` and `FlushInfoLog()` have to be provided too. 35 | 36 | ### Threading: 37 | 38 | * `GTEST_HAS_NOTIFICATION_` - Enabled if Notification is already provided. 39 | * `GTEST_HAS_MUTEX_AND_THREAD_LOCAL_` - Enabled if `Mutex` and `ThreadLocal` 40 | are already provided. Must also provide `GTEST_DECLARE_STATIC_MUTEX_(mutex)` 41 | and `GTEST_DEFINE_STATIC_MUTEX_(mutex)` 42 | * `GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)` 43 | * `GTEST_LOCK_EXCLUDED_(locks)` 44 | 45 | ### Underlying library support features 46 | 47 | * `GTEST_HAS_CXXABI_H_` 48 | 49 | ### Exporting API symbols: 50 | 51 | * `GTEST_API_` - Specifier for exported symbols. 52 | 53 | ## Header `gtest-printers.h` 54 | 55 | * See documentation at `gtest/gtest-printers.h` for details on how to define a 56 | custom printer. 57 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/include/gtest/internal/custom/gtest-port.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 35 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 36 | 37 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 38 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/include/gtest/internal/custom/gtest-printers.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // This file provides an injection point for custom printers in a local 31 | // installation of gTest. 32 | // It will be included from gtest-printers.h and the overrides in this file 33 | // will be visible to everyone. 34 | // 35 | // Injection point for custom user configurations. See README for details 36 | // 37 | // ** Custom implementation starts here ** 38 | 39 | #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 40 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 41 | 42 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 43 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/include/gtest/internal/custom/gtest.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 35 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 36 | 37 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 38 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/samples/sample1.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | 32 | #include "sample1.h" 33 | 34 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1. 35 | int Factorial(int n) { 36 | int result = 1; 37 | for (int i = 1; i <= n; i++) { 38 | result *= i; 39 | } 40 | 41 | return result; 42 | } 43 | 44 | // Returns true if and only if n is a prime number. 45 | bool IsPrime(int n) { 46 | // Trivial case 1: small numbers 47 | if (n <= 1) return false; 48 | 49 | // Trivial case 2: even numbers 50 | if (n % 2 == 0) return n == 2; 51 | 52 | // Now, we have that n is odd and n >= 3. 53 | 54 | // Try to divide n by every odd number i, starting from 3 55 | for (int i = 3; ; i += 2) { 56 | // We only have to try i up to the square root of n 57 | if (i > n/i) break; 58 | 59 | // Now, we have i <= n/i < n. 60 | // If n is divisible by i, n is not prime. 61 | if (n % i == 0) return false; 62 | } 63 | 64 | // n has no integer factor in the range (1, n), and thus is prime. 65 | return true; 66 | } 67 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/samples/sample1.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | 32 | #ifndef GOOGLETEST_SAMPLES_SAMPLE1_H_ 33 | #define GOOGLETEST_SAMPLES_SAMPLE1_H_ 34 | 35 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1. 36 | int Factorial(int n); 37 | 38 | // Returns true if and only if n is a prime number. 39 | bool IsPrime(int n); 40 | 41 | #endif // GOOGLETEST_SAMPLES_SAMPLE1_H_ 42 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/samples/sample2.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | 32 | #include "sample2.h" 33 | 34 | #include 35 | 36 | // Clones a 0-terminated C string, allocating memory using new. 37 | const char* MyString::CloneCString(const char* a_c_string) { 38 | if (a_c_string == nullptr) return nullptr; 39 | 40 | const size_t len = strlen(a_c_string); 41 | char* const clone = new char[ len + 1 ]; 42 | memcpy(clone, a_c_string, len + 1); 43 | 44 | return clone; 45 | } 46 | 47 | // Sets the 0-terminated C string this MyString object 48 | // represents. 49 | void MyString::Set(const char* a_c_string) { 50 | // Makes sure this works when c_string == c_string_ 51 | const char* const temp = MyString::CloneCString(a_c_string); 52 | delete[] c_string_; 53 | c_string_ = temp; 54 | } 55 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/samples/sample4.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | 32 | #include 33 | 34 | #include "sample4.h" 35 | 36 | // Returns the current counter value, and increments it. 37 | int Counter::Increment() { 38 | return counter_++; 39 | } 40 | 41 | // Returns the current counter value, and decrements it. 42 | // counter can not be less than 0, return 0 in this case 43 | int Counter::Decrement() { 44 | if (counter_ == 0) { 45 | return counter_; 46 | } else { 47 | return counter_--; 48 | } 49 | } 50 | 51 | // Prints the current counter value to STDOUT. 52 | void Counter::Print() const { 53 | printf("%d", counter_); 54 | } 55 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/samples/sample4.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | #ifndef GOOGLETEST_SAMPLES_SAMPLE4_H_ 32 | #define GOOGLETEST_SAMPLES_SAMPLE4_H_ 33 | 34 | // A simple monotonic counter. 35 | class Counter { 36 | private: 37 | int counter_; 38 | 39 | public: 40 | // Creates a counter that starts at 0. 41 | Counter() : counter_(0) {} 42 | 43 | // Returns the current counter value, and increments it. 44 | int Increment(); 45 | 46 | // Returns the current counter value, and decrements it. 47 | int Decrement(); 48 | 49 | // Prints the current counter value to STDOUT. 50 | void Print() const; 51 | }; 52 | 53 | #endif // GOOGLETEST_SAMPLES_SAMPLE4_H_ 54 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/samples/sample4_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | #include "sample4.h" 32 | #include "gtest/gtest.h" 33 | 34 | namespace { 35 | // Tests the Increment() method. 36 | 37 | TEST(Counter, Increment) { 38 | Counter c; 39 | 40 | // Test that counter 0 returns 0 41 | EXPECT_EQ(0, c.Decrement()); 42 | 43 | // EXPECT_EQ() evaluates its arguments exactly once, so they 44 | // can have side effects. 45 | 46 | EXPECT_EQ(0, c.Increment()); 47 | EXPECT_EQ(1, c.Increment()); 48 | EXPECT_EQ(2, c.Increment()); 49 | 50 | EXPECT_EQ(3, c.Decrement()); 51 | } 52 | 53 | } // namespace 54 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/scripts/README.md: -------------------------------------------------------------------------------- 1 | # Please Note: 2 | 3 | Files in this directory are no longer supported by the maintainers. They 4 | represent mosty historical artifacts and supported by the community only. There 5 | is no guarantee whatsoever that these scripts still work. 6 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/scripts/run_with_path.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2010 Google Inc. All Rights Reserved. 4 | 5 | """Runs program specified in the command line with the substituted PATH. 6 | 7 | This script is needed for to support building under Pulse which is unable 8 | to override the existing PATH variable. 9 | """ 10 | 11 | import os 12 | import subprocess 13 | import sys 14 | 15 | SUBST_PATH_ENV_VAR_NAME = "SUBST_PATH" 16 | 17 | def main(): 18 | if SUBST_PATH_ENV_VAR_NAME in os.environ: 19 | os.environ["PATH"] = os.environ[SUBST_PATH_ENV_VAR_NAME] 20 | 21 | exit_code = subprocess.Popen(sys.argv[1:]).wait() 22 | 23 | # exit_code is negative (-signal) if the process has been terminated by 24 | # a signal. Returning negative exit code is not portable and so we return 25 | # 100 instead. 26 | if exit_code < 0: 27 | exit_code = 100 28 | 29 | sys.exit(exit_code) 30 | 31 | if __name__ == "__main__": 32 | main() 33 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/scripts/upload_gtest.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2009, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | """upload_gtest.py v0.1.0 -- uploads a Google Test patch for review. 33 | 34 | This simple wrapper passes all command line flags and 35 | --cc=googletestframework@googlegroups.com to upload.py. 36 | 37 | USAGE: upload_gtest.py [options for upload.py] 38 | """ 39 | 40 | __author__ = 'wan@google.com (Zhanyong Wan)' 41 | 42 | import os 43 | import sys 44 | 45 | CC_FLAG = '--cc=' 46 | GTEST_GROUP = 'googletestframework@googlegroups.com' 47 | 48 | 49 | def main(): 50 | # Finds the path to upload.py, assuming it is in the same directory 51 | # as this file. 52 | my_dir = os.path.dirname(os.path.abspath(__file__)) 53 | upload_py_path = os.path.join(my_dir, 'upload.py') 54 | 55 | # Adds Google Test discussion group to the cc line if it's not there 56 | # already. 57 | upload_py_argv = [upload_py_path] 58 | found_cc_flag = False 59 | for arg in sys.argv[1:]: 60 | if arg.startswith(CC_FLAG): 61 | found_cc_flag = True 62 | cc_line = arg[len(CC_FLAG):] 63 | cc_list = [addr for addr in cc_line.split(',') if addr] 64 | if GTEST_GROUP not in cc_list: 65 | cc_list.append(GTEST_GROUP) 66 | upload_py_argv.append(CC_FLAG + ','.join(cc_list)) 67 | else: 68 | upload_py_argv.append(arg) 69 | 70 | if not found_cc_flag: 71 | upload_py_argv.append(CC_FLAG + GTEST_GROUP) 72 | 73 | # Invokes upload.py with the modified command line flags. 74 | os.execv(upload_py_path, upload_py_argv) 75 | 76 | 77 | if __name__ == '__main__': 78 | main() 79 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/src/gtest-all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Google C++ Testing and Mocking Framework (Google Test) 32 | // 33 | // Sometimes it's desirable to build Google Test by compiling a single file. 34 | // This file serves this purpose. 35 | 36 | // This line ensures that gtest.h can be compiled on its own, even 37 | // when it's fused. 38 | #include "gtest/gtest.h" 39 | 40 | // The following lines pull in the real gtest *.cc files. 41 | #include "src/gtest.cc" 42 | #include "src/gtest-death-test.cc" 43 | #include "src/gtest-filepath.cc" 44 | #include "src/gtest-matchers.cc" 45 | #include "src/gtest-port.cc" 46 | #include "src/gtest-printers.cc" 47 | #include "src/gtest-test-part.cc" 48 | #include "src/gtest-typed-test.cc" 49 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/src/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | #include "gtest/gtest.h" 32 | 33 | #if GTEST_OS_ESP8266 || GTEST_OS_ESP32 34 | #if GTEST_OS_ESP8266 35 | extern "C" { 36 | #endif 37 | void setup() { 38 | testing::InitGoogleTest(); 39 | } 40 | 41 | void loop() { RUN_ALL_TESTS(); } 42 | 43 | #if GTEST_OS_ESP8266 44 | } 45 | #endif 46 | 47 | #else 48 | 49 | GTEST_API_ int main(int argc, char **argv) { 50 | printf("Running main() from %s\n", __FILE__); 51 | testing::InitGoogleTest(&argc, argv); 52 | return RUN_ALL_TESTS(); 53 | } 54 | #endif 55 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/googletest-color-test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | // A helper program for testing how Google Test determines whether to use 32 | // colors in the output. It prints "YES" and returns 1 if Google Test 33 | // decides to use colors, and prints "NO" and returns 0 otherwise. 34 | 35 | #include 36 | 37 | #include "gtest/gtest.h" 38 | #include "src/gtest-internal-inl.h" 39 | 40 | using testing::internal::ShouldUseColor; 41 | 42 | // The purpose of this is to ensure that the UnitTest singleton is 43 | // created before main() is entered, and thus that ShouldUseColor() 44 | // works the same way as in a real Google-Test-based test. We don't actual 45 | // run the TEST itself. 46 | TEST(GTestColorTest, Dummy) { 47 | } 48 | 49 | int main(int argc, char** argv) { 50 | testing::InitGoogleTest(&argc, argv); 51 | 52 | if (ShouldUseColor(true)) { 53 | // Google Test decides to use colors in the output (assuming it 54 | // goes to a TTY). 55 | printf("YES\n"); 56 | return 1; 57 | } else { 58 | // Google Test decides not to use colors in the output. 59 | printf("NO\n"); 60 | return 0; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/googletest-global-environment-unittest_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Unit test for Google Test global test environments. 31 | // 32 | // The program will be invoked from a Python unit test. Don't run it 33 | // directly. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | namespace { 38 | 39 | // An environment that always fails in its SetUp method. 40 | class FailingEnvironment final : public ::testing::Environment { 41 | public: 42 | void SetUp() override { FAIL() << "Canned environment setup error"; } 43 | }; 44 | 45 | // Register the environment. 46 | auto* const g_environment_ = 47 | ::testing::AddGlobalTestEnvironment(new FailingEnvironment); 48 | 49 | // A test that doesn't actually run. 50 | TEST(SomeTest, DoesFoo) { FAIL() << "Unexpected call"; } 51 | 52 | } // namespace 53 | 54 | int main(int argc, char** argv) { 55 | ::testing::InitGoogleTest(&argc, argv); 56 | 57 | return RUN_ALL_TESTS(); 58 | } 59 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/googletest-param-test-invalid-name1-test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2015 Google Inc. All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | """Verifies that Google Test warns the user when not initialized properly.""" 32 | 33 | import gtest_test_utils 34 | 35 | binary_name = 'googletest-param-test-invalid-name1-test_' 36 | COMMAND = gtest_test_utils.GetTestExecutablePath(binary_name) 37 | 38 | 39 | def Assert(condition): 40 | if not condition: 41 | raise AssertionError 42 | 43 | 44 | def TestExitCodeAndOutput(command): 45 | """Runs the given command and verifies its exit code and output.""" 46 | 47 | err = ('Parameterized test name \'"InvalidWithQuotes"\' is invalid') 48 | 49 | p = gtest_test_utils.Subprocess(command) 50 | Assert(p.terminated_by_signal) 51 | 52 | # Verify the output message contains appropriate output 53 | Assert(err in p.output) 54 | 55 | 56 | class GTestParamTestInvalidName1Test(gtest_test_utils.TestCase): 57 | 58 | def testExitCodeAndOutput(self): 59 | TestExitCodeAndOutput(COMMAND) 60 | 61 | 62 | if __name__ == '__main__': 63 | gtest_test_utils.Main() 64 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/googletest-param-test-invalid-name1-test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | #include "gtest/gtest.h" 32 | 33 | namespace { 34 | class DummyTest : public ::testing::TestWithParam {}; 35 | 36 | TEST_P(DummyTest, Dummy) { 37 | } 38 | 39 | INSTANTIATE_TEST_SUITE_P(InvalidTestName, 40 | DummyTest, 41 | ::testing::Values("InvalidWithQuotes"), 42 | ::testing::PrintToStringParamName()); 43 | 44 | } // namespace 45 | 46 | int main(int argc, char *argv[]) { 47 | testing::InitGoogleTest(&argc, argv); 48 | return RUN_ALL_TESTS(); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/googletest-param-test-invalid-name2-test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2015 Google Inc. All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | """Verifies that Google Test warns the user when not initialized properly.""" 32 | 33 | import gtest_test_utils 34 | 35 | binary_name = 'googletest-param-test-invalid-name2-test_' 36 | COMMAND = gtest_test_utils.GetTestExecutablePath(binary_name) 37 | 38 | 39 | def Assert(condition): 40 | if not condition: 41 | raise AssertionError 42 | 43 | 44 | def TestExitCodeAndOutput(command): 45 | """Runs the given command and verifies its exit code and output.""" 46 | 47 | err = ('Duplicate parameterized test name \'a\'') 48 | 49 | p = gtest_test_utils.Subprocess(command) 50 | Assert(p.terminated_by_signal) 51 | 52 | # Check for appropriate output 53 | Assert(err in p.output) 54 | 55 | 56 | class GTestParamTestInvalidName2Test(gtest_test_utils.TestCase): 57 | 58 | def testExitCodeAndOutput(self): 59 | TestExitCodeAndOutput(COMMAND) 60 | 61 | if __name__ == '__main__': 62 | gtest_test_utils.Main() 63 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/googletest-param-test-invalid-name2-test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | #include "gtest/gtest.h" 32 | 33 | namespace { 34 | class DummyTest : public ::testing::TestWithParam {}; 35 | 36 | std::string StringParamTestSuffix( 37 | const testing::TestParamInfo& info) { 38 | return std::string(info.param); 39 | } 40 | 41 | TEST_P(DummyTest, Dummy) { 42 | } 43 | 44 | INSTANTIATE_TEST_SUITE_P(DuplicateTestNames, 45 | DummyTest, 46 | ::testing::Values("a", "b", "a", "c"), 47 | StringParamTestSuffix); 48 | } // namespace 49 | 50 | int main(int argc, char *argv[]) { 51 | testing::InitGoogleTest(&argc, argv); 52 | return RUN_ALL_TESTS(); 53 | } 54 | 55 | 56 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/googletest-param-test-test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // The Google C++ Testing and Mocking Framework (Google Test) 31 | // 32 | // This header file provides classes and functions used internally 33 | // for testing Google Test itself. 34 | 35 | #ifndef GOOGLETEST_TEST_GOOGLETEST_PARAM_TEST_TEST_H_ 36 | #define GOOGLETEST_TEST_GOOGLETEST_PARAM_TEST_TEST_H_ 37 | 38 | #include "gtest/gtest.h" 39 | 40 | // Test fixture for testing definition and instantiation of a test 41 | // in separate translation units. 42 | class ExternalInstantiationTest : public ::testing::TestWithParam { 43 | }; 44 | 45 | // Test fixture for testing instantiation of a test in multiple 46 | // translation units. 47 | class InstantiationInMultipleTranslationUnitsTest 48 | : public ::testing::TestWithParam { 49 | }; 50 | 51 | #endif // GOOGLETEST_TEST_GOOGLETEST_PARAM_TEST_TEST_H_ 52 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/googletest-param-test2-test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Tests for Google Test itself. This verifies that the basic constructs of 32 | // Google Test work. 33 | 34 | #include "gtest/gtest.h" 35 | #include "test/googletest-param-test-test.h" 36 | 37 | using ::testing::Values; 38 | using ::testing::internal::ParamGenerator; 39 | 40 | // Tests that generators defined in a different translation unit 41 | // are functional. The test using extern_gen is defined 42 | // in googletest-param-test-test.cc. 43 | ParamGenerator extern_gen = Values(33); 44 | 45 | // Tests that a parameterized test case can be defined in one translation unit 46 | // and instantiated in another. The test is defined in 47 | // googletest-param-test-test.cc and ExternalInstantiationTest fixture class is 48 | // defined in gtest-param-test_test.h. 49 | INSTANTIATE_TEST_SUITE_P(MultiplesOf33, 50 | ExternalInstantiationTest, 51 | Values(33, 66)); 52 | 53 | // Tests that a parameterized test case can be instantiated 54 | // in multiple translation units. Another instantiation is defined 55 | // in googletest-param-test-test.cc and 56 | // InstantiationInMultipleTranslationUnitsTest fixture is defined in 57 | // gtest-param-test_test.h 58 | INSTANTIATE_TEST_SUITE_P(Sequence2, 59 | InstantiationInMultipleTranslationUnitsTest, 60 | Values(42*3, 42*4, 42*5)); 61 | 62 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/googletest-setuptestsuite-test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2019, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | """Verifies that SetUpTestSuite and TearDownTestSuite errors are noticed.""" 33 | 34 | import gtest_test_utils 35 | 36 | COMMAND = gtest_test_utils.GetTestExecutablePath( 37 | 'googletest-setuptestsuite-test_') 38 | 39 | 40 | class GTestSetUpTestSuiteTest(gtest_test_utils.TestCase): 41 | 42 | def testSetupErrorAndTearDownError(self): 43 | p = gtest_test_utils.Subprocess(COMMAND) 44 | self.assertNotEqual(p.exit_code, 0, msg=p.output) 45 | 46 | self.assertIn( 47 | '[ FAILED ] SetupFailTest: SetUpTestSuite or TearDownTestSuite\n' 48 | '[ FAILED ] TearDownFailTest: SetUpTestSuite or TearDownTestSuite\n' 49 | '\n' 50 | ' 2 FAILED TEST SUITES\n', 51 | p.output) 52 | 53 | if __name__ == '__main__': 54 | gtest_test_utils.Main() 55 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/googletest-setuptestsuite-test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | #include "gtest/gtest.h" 32 | 33 | class SetupFailTest : public ::testing::Test { 34 | protected: 35 | static void SetUpTestSuite() { 36 | ASSERT_EQ("", "SET_UP_FAIL"); 37 | } 38 | }; 39 | 40 | TEST_F(SetupFailTest, NoopPassingTest) {} 41 | 42 | class TearDownFailTest : public ::testing::Test { 43 | protected: 44 | static void TearDownTestSuite() { 45 | ASSERT_EQ("", "TEAR_DOWN_FAIL"); 46 | } 47 | }; 48 | 49 | TEST_F(TearDownFailTest, NoopPassingTest) {} 50 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/googletest-uninitialized-test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2008, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | """Verifies that Google Test warns the user when not initialized properly.""" 33 | 34 | import gtest_test_utils 35 | 36 | COMMAND = gtest_test_utils.GetTestExecutablePath('googletest-uninitialized-test_') 37 | 38 | 39 | def Assert(condition): 40 | if not condition: 41 | raise AssertionError 42 | 43 | 44 | def AssertEq(expected, actual): 45 | if expected != actual: 46 | print('Expected: %s' % (expected,)) 47 | print(' Actual: %s' % (actual,)) 48 | raise AssertionError 49 | 50 | 51 | def TestExitCodeAndOutput(command): 52 | """Runs the given command and verifies its exit code and output.""" 53 | 54 | # Verifies that 'command' exits with code 1. 55 | p = gtest_test_utils.Subprocess(command) 56 | if p.exited and p.exit_code == 0: 57 | Assert('IMPORTANT NOTICE' in p.output); 58 | Assert('InitGoogleTest' in p.output) 59 | 60 | 61 | class GTestUninitializedTest(gtest_test_utils.TestCase): 62 | def testExitCodeAndOutput(self): 63 | TestExitCodeAndOutput(COMMAND) 64 | 65 | 66 | if __name__ == '__main__': 67 | gtest_test_utils.Main() 68 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/googletest-uninitialized-test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | #include "gtest/gtest.h" 32 | 33 | TEST(DummyTest, Dummy) { 34 | // This test doesn't verify anything. We just need it to create a 35 | // realistic stage for testing the behavior of Google Test when 36 | // RUN_ALL_TESTS() is called without 37 | // testing::InitGoogleTest() being called first. 38 | } 39 | 40 | int main() { 41 | return RUN_ALL_TESTS(); 42 | } 43 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest-typed-test2_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | #include 32 | 33 | #include "test/gtest-typed-test_test.h" 34 | #include "gtest/gtest.h" 35 | 36 | // Tests that the same type-parameterized test case can be 37 | // instantiated in different translation units linked together. 38 | // (ContainerTest is also instantiated in gtest-typed-test_test.cc.) 39 | INSTANTIATE_TYPED_TEST_SUITE_P(Vector, ContainerTest, 40 | testing::Types >); 41 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest-typed-test_test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #ifndef GOOGLETEST_TEST_GTEST_TYPED_TEST_TEST_H_ 31 | #define GOOGLETEST_TEST_GTEST_TYPED_TEST_TEST_H_ 32 | 33 | #include "gtest/gtest.h" 34 | 35 | using testing::Test; 36 | 37 | // For testing that the same type-parameterized test case can be 38 | // instantiated in different translation units linked together. 39 | // ContainerTest will be instantiated in both gtest-typed-test_test.cc 40 | // and gtest-typed-test2_test.cc. 41 | 42 | template 43 | class ContainerTest : public Test { 44 | }; 45 | 46 | TYPED_TEST_SUITE_P(ContainerTest); 47 | 48 | TYPED_TEST_P(ContainerTest, CanBeDefaultConstructed) { 49 | TypeParam container; 50 | } 51 | 52 | TYPED_TEST_P(ContainerTest, InitialSizeIsZero) { 53 | TypeParam container; 54 | EXPECT_EQ(0U, container.size()); 55 | } 56 | 57 | REGISTER_TYPED_TEST_SUITE_P(ContainerTest, 58 | CanBeDefaultConstructed, InitialSizeIsZero); 59 | 60 | #endif // GOOGLETEST_TEST_GTEST_TYPED_TEST_TEST_H_ 61 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest_all_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Tests for Google C++ Testing and Mocking Framework (Google Test) 32 | // 33 | // Sometimes it's desirable to build most of Google Test's own tests 34 | // by compiling a single file. This file serves this purpose. 35 | #include "test/googletest-filepath-test.cc" 36 | #include "test/googletest-message-test.cc" 37 | #include "test/googletest-options-test.cc" 38 | #include "test/googletest-port-test.cc" 39 | #include "test/googletest-test-part-test.cc" 40 | #include "test/gtest-typed-test2_test.cc" 41 | #include "test/gtest-typed-test_test.cc" 42 | #include "test/gtest_pred_impl_unittest.cc" 43 | #include "test/gtest_prod_test.cc" 44 | #include "test/gtest_skip_test.cc" 45 | #include "test/gtest_unittest.cc" 46 | #include "test/production.cc" 47 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest_help_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | // This program is meant to be run by gtest_help_test.py. Do not run 32 | // it directly. 33 | 34 | #include "gtest/gtest.h" 35 | 36 | // When a help flag is specified, this program should skip the tests 37 | // and exit with 0; otherwise the following test will be executed, 38 | // causing this program to exit with a non-zero code. 39 | TEST(HelpFlagTest, ShouldNotBeRun) { 40 | ASSERT_TRUE(false) << "Tests shouldn't be run when --help is specified."; 41 | } 42 | 43 | #if GTEST_HAS_DEATH_TEST 44 | TEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {} 45 | #endif 46 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest_json_test_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, Google Inc. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above 11 | # copyright notice, this list of conditions and the following disclaimer 12 | # in the documentation and/or other materials provided with the 13 | # distribution. 14 | # * Neither the name of Google Inc. nor the names of its 15 | # contributors may be used to endorse or promote products derived from 16 | # this software without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | """Unit test utilities for gtest_json_output.""" 31 | 32 | import re 33 | 34 | 35 | def normalize(obj): 36 | """Normalize output object. 37 | 38 | Args: 39 | obj: Google Test's JSON output object to normalize. 40 | 41 | Returns: 42 | Normalized output without any references to transient information that may 43 | change from run to run. 44 | """ 45 | def _normalize(key, value): 46 | if key == 'time': 47 | return re.sub(r'^\d+(\.\d+)?s$', '*', value) 48 | elif key == 'timestamp': 49 | return re.sub(r'^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ$', '*', value) 50 | elif key == 'failure': 51 | value = re.sub(r'^.*[/\\](.*:)\d+\n', '\\1*\n', value) 52 | return re.sub(r'Stack trace:\n(.|\n)*', 'Stack trace:\n*', value) 53 | else: 54 | return normalize(value) 55 | if isinstance(obj, dict): 56 | return {k: _normalize(k, v) for k, v in obj.items()} 57 | if isinstance(obj, list): 58 | return [normalize(x) for x in obj] 59 | else: 60 | return obj 61 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest_main_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | #include "gtest/gtest.h" 32 | 33 | // Tests that we don't have to define main() when we link to 34 | // gtest_main instead of gtest. 35 | 36 | namespace { 37 | 38 | TEST(GTestMainTest, ShouldSucceed) { 39 | } 40 | 41 | } // namespace 42 | 43 | // We are using the main() function defined in gtest_main.cc, so we 44 | // don't define it here. 45 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest_no_test_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Tests that a Google Test program that has no test defined can run 31 | // successfully. 32 | 33 | #include "gtest/gtest.h" 34 | 35 | int main(int argc, char **argv) { 36 | testing::InitGoogleTest(&argc, argv); 37 | 38 | // An ad-hoc assertion outside of all tests. 39 | // 40 | // This serves three purposes: 41 | // 42 | // 1. It verifies that an ad-hoc assertion can be executed even if 43 | // no test is defined. 44 | // 2. It verifies that a failed ad-hoc assertion causes the test 45 | // program to fail. 46 | // 3. We had a bug where the XML output won't be generated if an 47 | // assertion is executed before RUN_ALL_TESTS() is called, even 48 | // though --gtest_output=xml is specified. This makes sure the 49 | // bug is fixed and doesn't regress. 50 | EXPECT_EQ(1, 2); 51 | 52 | // The above EXPECT_EQ() should cause RUN_ALL_TESTS() to return non-zero. 53 | return RUN_ALL_TESTS() ? 0 : 1; 54 | } 55 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest_prod_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Unit test for gtest_prod.h. 32 | 33 | #include "production.h" 34 | #include "gtest/gtest.h" 35 | 36 | // Tests that private members can be accessed from a TEST declared as 37 | // a friend of the class. 38 | TEST(PrivateCodeTest, CanAccessPrivateMembers) { 39 | PrivateCode a; 40 | EXPECT_EQ(0, a.x_); 41 | 42 | a.set_x(1); 43 | EXPECT_EQ(1, a.x_); 44 | } 45 | 46 | typedef testing::Test PrivateCodeFixtureTest; 47 | 48 | // Tests that private members can be accessed from a TEST_F declared 49 | // as a friend of the class. 50 | TEST_F(PrivateCodeFixtureTest, CanAccessPrivateMembers) { 51 | PrivateCode a; 52 | EXPECT_EQ(0, a.x_); 53 | 54 | a.set_x(2); 55 | EXPECT_EQ(2, a.x_); 56 | } 57 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest_skip_check_output_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2019 Google LLC. All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """Tests Google Test's gtest skip in environment setup behavior. 31 | 32 | This script invokes gtest_skip_in_environment_setup_test_ and verifies its 33 | output. 34 | """ 35 | 36 | import re 37 | 38 | import gtest_test_utils 39 | 40 | # Path to the gtest_skip_in_environment_setup_test binary 41 | EXE_PATH = gtest_test_utils.GetTestExecutablePath('gtest_skip_test') 42 | 43 | OUTPUT = gtest_test_utils.Subprocess([EXE_PATH]).output 44 | 45 | 46 | # Test. 47 | class SkipEntireEnvironmentTest(gtest_test_utils.TestCase): 48 | 49 | def testSkipEntireEnvironmentTest(self): 50 | self.assertIn('Skipped\nskipping single test\n', OUTPUT) 51 | skip_fixture = 'Skipped\nskipping all tests for this fixture\n' 52 | self.assertIsNotNone( 53 | re.search(skip_fixture + '.*' + skip_fixture, OUTPUT, flags=re.DOTALL), 54 | repr(OUTPUT)) 55 | self.assertNotIn('FAILED', OUTPUT) 56 | 57 | 58 | if __name__ == '__main__': 59 | gtest_test_utils.Main() 60 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest_skip_environment_check_output_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2019 Google LLC. All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """Tests Google Test's gtest skip in environment setup behavior. 31 | 32 | This script invokes gtest_skip_in_environment_setup_test_ and verifies its 33 | output. 34 | """ 35 | 36 | import gtest_test_utils 37 | 38 | # Path to the gtest_skip_in_environment_setup_test binary 39 | EXE_PATH = gtest_test_utils.GetTestExecutablePath( 40 | 'gtest_skip_in_environment_setup_test') 41 | 42 | OUTPUT = gtest_test_utils.Subprocess([EXE_PATH]).output 43 | 44 | 45 | # Test. 46 | class SkipEntireEnvironmentTest(gtest_test_utils.TestCase): 47 | 48 | def testSkipEntireEnvironmentTest(self): 49 | self.assertIn('Skipping the entire environment', OUTPUT) 50 | self.assertNotIn('FAILED', OUTPUT) 51 | 52 | 53 | if __name__ == '__main__': 54 | gtest_test_utils.Main() 55 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest_skip_in_environment_setup_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2019, Google LLC. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google LLC. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // This test verifies that skipping in the environment results in the 31 | // testcases being skipped. 32 | 33 | #include 34 | #include "gtest/gtest.h" 35 | 36 | class SetupEnvironment : public testing::Environment { 37 | public: 38 | void SetUp() override { GTEST_SKIP() << "Skipping the entire environment"; } 39 | }; 40 | 41 | TEST(Test, AlwaysFails) { EXPECT_EQ(true, false); } 42 | 43 | int main(int argc, char **argv) { 44 | testing::InitGoogleTest(&argc, argv); 45 | 46 | testing::AddGlobalTestEnvironment(new SetupEnvironment()); 47 | 48 | return RUN_ALL_TESTS(); 49 | } 50 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest_skip_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: arseny.aprelev@gmail.com (Arseny Aprelev) 31 | // 32 | 33 | #include "gtest/gtest.h" 34 | 35 | using ::testing::Test; 36 | 37 | TEST(SkipTest, DoesSkip) { 38 | GTEST_SKIP() << "skipping single test"; 39 | EXPECT_EQ(0, 1); 40 | } 41 | 42 | class Fixture : public Test { 43 | protected: 44 | void SetUp() override { 45 | GTEST_SKIP() << "skipping all tests for this fixture"; 46 | } 47 | }; 48 | 49 | TEST_F(Fixture, SkipsOneTest) { 50 | EXPECT_EQ(5, 7); 51 | } 52 | 53 | TEST_F(Fixture, SkipsAnotherTest) { 54 | EXPECT_EQ(99, 100); 55 | } 56 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest_sole_header_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // This test verifies that it's possible to use Google Test by including 32 | // the gtest.h header file alone. 33 | 34 | #include "gtest/gtest.h" 35 | 36 | namespace { 37 | 38 | void Subroutine() { 39 | EXPECT_EQ(42, 42); 40 | } 41 | 42 | TEST(NoFatalFailureTest, ExpectNoFatalFailure) { 43 | EXPECT_NO_FATAL_FAILURE(;); 44 | EXPECT_NO_FATAL_FAILURE(SUCCEED()); 45 | EXPECT_NO_FATAL_FAILURE(Subroutine()); 46 | EXPECT_NO_FATAL_FAILURE({ SUCCEED(); }); 47 | } 48 | 49 | TEST(NoFatalFailureTest, AssertNoFatalFailure) { 50 | ASSERT_NO_FATAL_FAILURE(;); 51 | ASSERT_NO_FATAL_FAILURE(SUCCEED()); 52 | ASSERT_NO_FATAL_FAILURE(Subroutine()); 53 | ASSERT_NO_FATAL_FAILURE({ SUCCEED(); }); 54 | } 55 | 56 | } // namespace 57 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest_testbridge_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2018 Google LLC. All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """Verifies that Google Test uses filter provided via testbridge.""" 31 | 32 | import os 33 | 34 | import gtest_test_utils 35 | 36 | binary_name = 'gtest_testbridge_test_' 37 | COMMAND = gtest_test_utils.GetTestExecutablePath(binary_name) 38 | TESTBRIDGE_NAME = 'TESTBRIDGE_TEST_ONLY' 39 | 40 | 41 | def Assert(condition): 42 | if not condition: 43 | raise AssertionError 44 | 45 | 46 | class GTestTestFilterTest(gtest_test_utils.TestCase): 47 | 48 | def testTestExecutionIsFiltered(self): 49 | """Tests that the test filter is picked up from the testbridge env var.""" 50 | subprocess_env = os.environ.copy() 51 | 52 | subprocess_env[TESTBRIDGE_NAME] = '*.TestThatSucceeds' 53 | p = gtest_test_utils.Subprocess(COMMAND, env=subprocess_env) 54 | 55 | self.assertEquals(0, p.exit_code) 56 | 57 | Assert('filter = *.TestThatSucceeds' in p.output) 58 | Assert('[ OK ] TestFilterTest.TestThatSucceeds' in p.output) 59 | Assert('[ PASSED ] 1 test.' in p.output) 60 | 61 | 62 | if __name__ == '__main__': 63 | gtest_test_utils.Main() 64 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest_testbridge_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018, Google LLC. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | 31 | // This program is meant to be run by gtest_test_filter_test.py. Do not run 32 | // it directly. 33 | 34 | #include "gtest/gtest.h" 35 | 36 | // These tests are used to detect if filtering is working. Only 37 | // 'TestThatSucceeds' should ever run. 38 | 39 | TEST(TestFilterTest, TestThatSucceeds) {} 40 | 41 | TEST(TestFilterTest, TestThatFails) { 42 | ASSERT_TRUE(false) << "This test should never be run."; 43 | } 44 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest_xml_outfile1_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // gtest_xml_outfile1_test_ writes some xml via TestProperty used by 31 | // gtest_xml_outfiles_test.py 32 | 33 | #include "gtest/gtest.h" 34 | 35 | class PropertyOne : public testing::Test { 36 | protected: 37 | void SetUp() override { RecordProperty("SetUpProp", 1); } 38 | void TearDown() override { RecordProperty("TearDownProp", 1); } 39 | }; 40 | 41 | TEST_F(PropertyOne, TestSomeProperties) { 42 | RecordProperty("TestSomeProperty", 1); 43 | } 44 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/gtest_xml_outfile2_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // gtest_xml_outfile2_test_ writes some xml via TestProperty used by 31 | // gtest_xml_outfiles_test.py 32 | 33 | #include "gtest/gtest.h" 34 | 35 | class PropertyTwo : public testing::Test { 36 | protected: 37 | void SetUp() override { RecordProperty("SetUpProp", 2); } 38 | void TearDown() override { RecordProperty("TearDownProp", 2); } 39 | }; 40 | 41 | TEST_F(PropertyTwo, TestSomeProperties) { 42 | RecordProperty("TestSomeProperty", 2); 43 | } 44 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/production.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // This is part of the unit test for gtest_prod.h. 32 | 33 | #include "production.h" 34 | 35 | PrivateCode::PrivateCode() : x_(0) {} 36 | -------------------------------------------------------------------------------- /test/gtest/gtest-10-06-21/googletest/test/production.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // This is part of the unit test for gtest_prod.h. 32 | 33 | #ifndef GOOGLETEST_TEST_PRODUCTION_H_ 34 | #define GOOGLETEST_TEST_PRODUCTION_H_ 35 | 36 | #include "gtest/gtest_prod.h" 37 | 38 | class PrivateCode { 39 | public: 40 | // Declares a friend test that does not use a fixture. 41 | FRIEND_TEST(PrivateCodeTest, CanAccessPrivateMembers); 42 | 43 | // Declares a friend test that uses a fixture. 44 | FRIEND_TEST(PrivateCodeFixtureTest, CanAccessPrivateMembers); 45 | 46 | PrivateCode(); 47 | 48 | int x() const { return x_; } 49 | private: 50 | void set_x(int an_x) { x_ = an_x; } 51 | int x_; 52 | }; 53 | 54 | #endif // GOOGLETEST_TEST_PRODUCTION_H_ 55 | -------------------------------------------------------------------------------- /test/test_main.hpp.in: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | GTEST_API_ int main(int argc, char **argv) { 4 | testing::InitGoogleTest(&argc, argv); 5 | return RUN_ALL_TESTS(); 6 | } 7 | 8 | std::string testFile(const std::string& filename) 9 | { 10 | return std::string("@HEXER_SOURCE_DIR@/test/data/") + filename; 11 | } 12 | --------------------------------------------------------------------------------