├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── bicriteria_compress.cpp ├── bit_compress.cpp ├── cmake └── Modules │ └── Finddivsufsort.cmake ├── decompress.cpp ├── ext_libs ├── cppformat │ ├── .gitignore │ ├── .gitmodules │ ├── .travis.yml │ ├── CMakeLists.txt │ ├── cmake │ │ ├── FindSetEnv.cmake │ │ └── run-cmake.bat │ ├── format.cc │ ├── format.h │ ├── posix.cc │ └── posix.h ├── divsufsort │ ├── AUTHORS │ ├── CMakeLists.txt │ ├── CMakeModules │ │ ├── AppendCompilerFlags.cmake │ │ ├── CheckFunctionKeywords.cmake │ │ ├── CheckLFS.cmake │ │ ├── ProjectCPack.cmake │ │ └── cmake_uninstall.cmake.in │ ├── COPYING │ ├── INSTALL │ ├── README │ ├── VERSION │ ├── include │ │ ├── CMakeLists.txt │ │ ├── config.h.cmake │ │ ├── config.h.in │ │ ├── divsufsort.h.cmake │ │ ├── divsufsort64.h.in │ │ ├── divsufsort_private.h │ │ └── lfs.h.cmake │ └── lib │ │ ├── CMakeLists.txt │ │ ├── divsufsort.c │ │ ├── libdivsufsort.sym │ │ ├── libdivsufsort64.sym │ │ ├── sssort.c │ │ ├── trsort.c │ │ └── utils.c └── sha1 │ ├── sha1.cpp │ └── sha1.h ├── include ├── AVLtree.h ├── api.hpp ├── base_fsg.hpp ├── bicriteria_compress.hpp ├── bit_compress.hpp ├── bucket_fsg.hpp ├── c_time.hpp ├── cc_stats.hpp ├── class_info.hpp ├── cm_factory.hpp ├── cmd_parse.hpp ├── common.hpp ├── copy_routines.hpp ├── cost_model.hpp ├── decompress.hpp ├── edges.hpp ├── encoders.hpp ├── facilities.hpp ├── factories.hpp ├── factory.hpp ├── fast_fsg.hpp ├── format.hpp ├── fsg.hpp ├── generators.hpp ├── graph_cache.hpp ├── hw_counter.hpp ├── impl │ └── api_impl.hpp ├── io.hpp ├── list.hpp ├── list_gens.hpp ├── match_length.hpp ├── meter_printer.hpp ├── model_read.hpp ├── online_rsa.hpp ├── optimal_parser.hpp ├── parsing_manage.hpp ├── path_swapper.hpp ├── phrase_reader.hpp ├── rightmost_fsg.hpp ├── same_fsg.hpp ├── scan.hpp ├── solution_getter.hpp ├── solution_integrator.hpp ├── space_opt_subseq.hpp ├── target_read.hpp ├── tuple_executer.hpp ├── unaligned_io.hpp ├── utilities.hpp ├── wm_serializer.hpp └── write_parsing.hpp ├── libs ├── AVLtree.cpp ├── api.cpp ├── cm_factory.cpp ├── decompress_lib.cpp ├── encoders.cpp ├── facilities.cpp ├── format.cpp ├── generators.cpp ├── io.cpp ├── list.cpp ├── model_read.cpp ├── parsing_manage.cpp ├── path_swapper.cpp ├── phrase_reader.cpp ├── space_opt_subseq.cpp ├── target_read.cpp ├── unaligned_io.cpp ├── utilities.cpp ├── wm_serializer.cpp └── write_parsing.cpp ├── list_gens.cpp ├── main.cpp ├── models ├── delta-L0.mod ├── delta-L16.mod ├── delta-L8.mod ├── gamma-L0.mod ├── gamma-L16.mod ├── gamma-L8.mod ├── hybrid.mod ├── nibble4-L0.mod ├── nibble4-L16.mod ├── nibble4-L8.mod ├── nibble8-L0.mod ├── nibble8-L16.mod ├── nibble8-L8.mod ├── soda09-L0.mod ├── soda09-L16.mod └── soda09-L8.mod ├── readme.md ├── tests ├── CMakeLists.txt ├── api_test.cpp ├── cost_model_id.cpp ├── encoder_tests.cpp ├── ext_libs │ └── gtest-1.7.0 │ │ ├── CHANGES │ │ ├── CMakeLists.txt │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── README │ │ ├── aclocal.m4 │ │ ├── build-aux │ │ ├── config.guess │ │ ├── config.h.in │ │ ├── config.sub │ │ ├── depcomp │ │ ├── install-sh │ │ ├── ltmain.sh │ │ └── missing │ │ ├── cmake │ │ └── internal_utils.cmake │ │ ├── codegear │ │ ├── gtest.cbproj │ │ ├── gtest.groupproj │ │ ├── gtest_all.cc │ │ ├── gtest_link.cc │ │ ├── gtest_main.cbproj │ │ └── gtest_unittest.cbproj │ │ ├── configure │ │ ├── configure.ac │ │ ├── fused-src │ │ └── gtest │ │ │ ├── gtest-all.cc │ │ │ ├── gtest.h │ │ │ └── gtest_main.cc │ │ ├── include │ │ └── gtest │ │ │ ├── gtest-death-test.h │ │ │ ├── gtest-message.h │ │ │ ├── gtest-param-test.h │ │ │ ├── gtest-param-test.h.pump │ │ │ ├── gtest-printers.h │ │ │ ├── gtest-spi.h │ │ │ ├── gtest-test-part.h │ │ │ ├── gtest-typed-test.h │ │ │ ├── gtest.h │ │ │ ├── gtest_pred_impl.h │ │ │ ├── gtest_prod.h │ │ │ └── internal │ │ │ ├── gtest-death-test-internal.h │ │ │ ├── gtest-filepath.h │ │ │ ├── gtest-internal.h │ │ │ ├── gtest-linked_ptr.h │ │ │ ├── gtest-param-util-generated.h │ │ │ ├── gtest-param-util-generated.h.pump │ │ │ ├── gtest-param-util.h │ │ │ ├── gtest-port.h │ │ │ ├── gtest-string.h │ │ │ ├── gtest-tuple.h │ │ │ ├── gtest-tuple.h.pump │ │ │ ├── gtest-type-util.h │ │ │ └── gtest-type-util.h.pump │ │ ├── m4 │ │ ├── acx_pthread.m4 │ │ ├── gtest.m4 │ │ ├── libtool.m4 │ │ ├── ltoptions.m4 │ │ ├── ltsugar.m4 │ │ ├── ltversion.m4 │ │ └── lt~obsolete.m4 │ │ ├── make │ │ └── Makefile │ │ ├── msvc │ │ ├── gtest-md.sln │ │ ├── gtest-md.vcproj │ │ ├── gtest.sln │ │ ├── gtest.vcproj │ │ ├── gtest_main-md.vcproj │ │ ├── gtest_main.vcproj │ │ ├── gtest_prod_test-md.vcproj │ │ ├── gtest_prod_test.vcproj │ │ ├── gtest_unittest-md.vcproj │ │ └── gtest_unittest.vcproj │ │ ├── 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 │ │ ├── fuse_gtest_files.py │ │ ├── gen_gtest_pred_impl.py │ │ ├── gtest-config.in │ │ ├── pump.py │ │ └── test │ │ │ └── Makefile │ │ ├── src │ │ ├── gtest-all.cc │ │ ├── gtest-death-test.cc │ │ ├── gtest-filepath.cc │ │ ├── gtest-internal-inl.h │ │ ├── gtest-port.cc │ │ ├── gtest-printers.cc │ │ ├── gtest-test-part.cc │ │ ├── gtest-typed-test.cc │ │ ├── gtest.cc │ │ └── gtest_main.cc │ │ ├── test │ │ ├── gtest-death-test_ex_test.cc │ │ ├── gtest-death-test_test.cc │ │ ├── gtest-filepath_test.cc │ │ ├── gtest-linked_ptr_test.cc │ │ ├── gtest-listener_test.cc │ │ ├── gtest-message_test.cc │ │ ├── gtest-options_test.cc │ │ ├── gtest-param-test2_test.cc │ │ ├── gtest-param-test_test.cc │ │ ├── gtest-param-test_test.h │ │ ├── gtest-port_test.cc │ │ ├── gtest-printers_test.cc │ │ ├── gtest-test-part_test.cc │ │ ├── gtest-tuple_test.cc │ │ ├── gtest-typed-test2_test.cc │ │ ├── gtest-typed-test_test.cc │ │ ├── gtest-typed-test_test.h │ │ ├── gtest-unittest-api_test.cc │ │ ├── gtest_all_test.cc │ │ ├── gtest_break_on_failure_unittest.py │ │ ├── gtest_break_on_failure_unittest_.cc │ │ ├── gtest_catch_exceptions_test.py │ │ ├── gtest_catch_exceptions_test_.cc │ │ ├── gtest_color_test.py │ │ ├── gtest_color_test_.cc │ │ ├── gtest_env_var_test.py │ │ ├── gtest_env_var_test_.cc │ │ ├── gtest_environment_test.cc │ │ ├── gtest_filter_unittest.py │ │ ├── gtest_filter_unittest_.cc │ │ ├── gtest_help_test.py │ │ ├── gtest_help_test_.cc │ │ ├── gtest_list_tests_unittest.py │ │ ├── gtest_list_tests_unittest_.cc │ │ ├── gtest_main_unittest.cc │ │ ├── gtest_no_test_unittest.cc │ │ ├── gtest_output_test.py │ │ ├── gtest_output_test_.cc │ │ ├── gtest_output_test_golden_lin.txt │ │ ├── gtest_pred_impl_unittest.cc │ │ ├── gtest_premature_exit_test.cc │ │ ├── gtest_prod_test.cc │ │ ├── gtest_repeat_test.cc │ │ ├── gtest_shuffle_test.py │ │ ├── gtest_shuffle_test_.cc │ │ ├── gtest_sole_header_test.cc │ │ ├── gtest_stress_test.cc │ │ ├── gtest_test_utils.py │ │ ├── gtest_throw_on_failure_ex_test.cc │ │ ├── gtest_throw_on_failure_test.py │ │ ├── gtest_throw_on_failure_test_.cc │ │ ├── gtest_uninitialized_test.py │ │ ├── gtest_uninitialized_test_.cc │ │ ├── gtest_unittest.cc │ │ ├── gtest_xml_outfile1_test_.cc │ │ ├── gtest_xml_outfile2_test_.cc │ │ ├── gtest_xml_outfiles_test.py │ │ ├── gtest_xml_output_unittest.py │ │ ├── gtest_xml_output_unittest_.cc │ │ ├── gtest_xml_test_utils.py │ │ ├── production.cc │ │ └── production.h │ │ └── xcode │ │ ├── Config │ │ ├── DebugProject.xcconfig │ │ ├── FrameworkTarget.xcconfig │ │ ├── General.xcconfig │ │ ├── ReleaseProject.xcconfig │ │ ├── StaticLibraryTarget.xcconfig │ │ └── TestTarget.xcconfig │ │ ├── Resources │ │ └── Info.plist │ │ ├── Samples │ │ └── FrameworkSample │ │ │ ├── Info.plist │ │ │ ├── WidgetFramework.xcodeproj │ │ │ └── project.pbxproj │ │ │ ├── runtests.sh │ │ │ ├── widget.cc │ │ │ ├── widget.h │ │ │ └── widget_test.cc │ │ ├── Scripts │ │ ├── runtests.sh │ │ └── versiongenerate.py │ │ └── gtest.xcodeproj │ │ └── project.pbxproj ├── fast_solution_integrator.cpp ├── fsg_bench.cpp ├── fsg_check.cpp ├── graph_cacher.cpp ├── include │ └── fsg_check.hpp ├── model_read_test.cpp ├── solution_getter_test.cpp └── swapper_test.cpp └── tools ├── CMakeLists.txt ├── calibrator.cpp ├── calibrator.sh └── get_latencies.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | CMakeLists.txt.user 3 | build/ 4 | in_dev/ 5 | bc_zip.sublime-workspace 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | addons: 4 | apt: 5 | sources: 6 | - ubuntu-toolchain-r-test 7 | packages: 8 | - gcc-4.8 9 | - g++-4.8 10 | - libboost-all-dev 11 | 12 | install: 13 | - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi 14 | 15 | compiler: 16 | - gcc 17 | 18 | before_script: 19 | - mkdir build 20 | - cd build 21 | - cmake .. -DCMAKE_BUILD_TYPE=Release 22 | 23 | script: make 24 | -------------------------------------------------------------------------------- /cmake/Modules/Finddivsufsort.cmake: -------------------------------------------------------------------------------- 1 | # find divsufsort library of Yuta Mori 2 | 3 | # search in /usr/local/include and ~/include for divsufsort includes 4 | find_path(divsufsort_INCLUDE_DIRS divsufsort.h /usr/local/include ~/include ~/.local/include "$ENV{divsufsort_ROOT}") 5 | # search in /usr/local/lib and ~/lib for divsufsort library 6 | find_library(divsufsort_LIBRARIES divsufsort /usr/local/lib ~/lib ~/.local/lib "$ENV{divsufsort_ROOT}") 7 | 8 | set(divsufsort_FOUND TRUE) 9 | 10 | if(NOT divsufsort_INCLUDE_DIRS) 11 | set(divsufsort_FOUND FALSE) 12 | endif(NOT divsufsort_INCLUDE_DIRS) 13 | 14 | if(NOT divsufsort_LIBRARIES) 15 | set(divsufsort_FOUND FALSE) 16 | else() 17 | get_filename_component(divsufsort_LIBRARY_DIRS ${divsufsort_LIBRARIES} PATH) 18 | message("-- Found divsufsort library in ${divsufsort_LIBRARY_DIRS}") 19 | message("-- Found divsufsort include files in ${divsufsort_INCLUDE_DIRS}") 20 | endif(NOT divsufsort_LIBRARIES) 21 | -------------------------------------------------------------------------------- /decompress.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | 19 | std::uint64_t decompress_file(const char *tool_name, int argc, char **argv, std::ostream &out) 20 | { 21 | argc -= 2; 22 | argv += 2; 23 | if (argc < 2) { 24 | throw cmd_error(join_s(tool_name, " input output")); 25 | } 26 | char *input = *argv++; 27 | char *output = *argv++; 28 | 29 | size_t file_size; 30 | auto data_holder = read_file(input, &file_size, 8); 31 | byte *data = data_holder.get(); 32 | 33 | dec_output dec_res = decompress_full(data); 34 | 35 | out << "Encoder: " << dec_res.enc_name << std::endl; 36 | out << "Decompression time: " << dec_res.dec_time / (std::nano::den / std::milli::den) << " msecs" << std::endl; 37 | 38 | // Now we should write "uncompressed". 39 | std::ofstream out_file; 40 | open_file(out_file, output); 41 | write_file(out_file, dec_res.rep.get(), dec_res.uncompressed_size); 42 | 43 | out << "Original size: " << dec_res.uncompressed_size << std::endl; 44 | return dec_res.dec_time; 45 | } -------------------------------------------------------------------------------- /ext_libs/cppformat/.gitignore: -------------------------------------------------------------------------------- 1 | /_CPack_Packages 2 | /doc/conf.py 3 | /doc/doxyxml 4 | /doc/html 5 | /Testing 6 | /*-test 7 | /install_manifest.txt 8 | /tinyformat_speed_test 9 | *~ 10 | *.a 11 | *.zip 12 | cmake_install.cmake 13 | CPack*Config.cmake 14 | CTestTestfile.cmake 15 | CMakeCache.txt 16 | CMakeFiles 17 | Makefile 18 | -------------------------------------------------------------------------------- /ext_libs/cppformat/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "breathe"] 2 | path = breathe 3 | url = git://github.com/vitaut/breathe.git 4 | [submodule "doc/sphinx-bootstrap-theme"] 5 | path = doc/sphinx-bootstrap-theme 6 | url = https://github.com/cppformat/sphinx-bootstrap-theme.git 7 | [submodule "doc/sphinx_rtd_theme"] 8 | path = doc/sphinx_rtd_theme 9 | url = https://github.com/cppformat/sphinx_rtd_theme.git 10 | -------------------------------------------------------------------------------- /ext_libs/cppformat/.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | os: 4 | - linux 5 | - osx 6 | 7 | before_install: 8 | - if [ $TRAVIS_OS_NAME == osx ]; then curl http://www.cmake.org/files/v2.8/cmake-2.8.12.2-Darwin64-universal.tar.gz -o cmake.tar.gz; fi 9 | - if [ $TRAVIS_OS_NAME == osx ]; then tar xzf cmake.tar.gz; fi 10 | - if [ $TRAVIS_OS_NAME == osx ]; then export PATH=$PATH:"cmake-2.8.12.2-Darwin64-universal/CMake 2.8-12.app/Contents/bin"; fi 11 | - git submodule update --init 12 | 13 | env: 14 | - BUILD_TYPE=Debug 15 | - BUILD_TYPE=Release 16 | 17 | script: 18 | - cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DFMT_EXTRA_TESTS=ON . 19 | - make -j4 20 | - CTEST_OUTPUT_ON_FAILURE=1 make test 21 | 22 | after_failure: 23 | - cat Testing/Temporary/LastTest.log 24 | -------------------------------------------------------------------------------- /ext_libs/cppformat/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | 3 | # Set the default CMAKE_BUILD_TYPE to Release. 4 | # This should be done before the project command since the latter can set 5 | # CMAKE_BUILD_TYPE itself (it does so for nmake). 6 | if (NOT CMAKE_BUILD_TYPE) 7 | set(CMAKE_BUILD_TYPE Release CACHE STRING 8 | "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") 9 | endif () 10 | 11 | project(FORMAT) 12 | 13 | message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") 14 | 15 | include(CheckCXXCompilerFlag) 16 | check_cxx_compiler_flag(-std=c++11 HAVE_STD_CPP11_FLAG) 17 | if (HAVE_STD_CPP11_FLAG) 18 | set(CPP11_FLAG -std=c++11) 19 | else () 20 | check_cxx_compiler_flag(-std=c++0x HAVE_STD_CPP0X_FLAG) 21 | if (HAVE_STD_CPP0X_FLAG) 22 | set(CPP11_FLAG -std=c++0x) 23 | endif () 24 | endif () 25 | 26 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 27 | 28 | if (CMAKE_GENERATOR MATCHES "Visual Studio") 29 | # If Microsoft SDK is installed create script run-msbuild.bat that 30 | # calls SetEnv.cmd to to set up build environment and runs msbuild. 31 | # It is useful when building Visual Studio projects with the SDK 32 | # toolchain rather than Visual Studio. 33 | include(FindSetEnv) 34 | if (WINSDK_SETENV) 35 | set(MSBUILD_SETUP "call \"${WINSDK_SETENV}\"") 36 | endif () 37 | # Set FrameworkPathOverride to get rid of MSB3644 warnings. 38 | set(netfxpath "C:\\Program Files\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0") 39 | file(WRITE run-msbuild.bat "${MSBUILD_SETUP} ${CMAKE_MAKE_PROGRAM} -p:FrameworkPathOverride=\"${netfxpath}\" %*") 40 | endif () 41 | 42 | option(FMT_SHARED "Build shared library instead of static one" OFF) 43 | if (FMT_SHARED) 44 | set(shared SHARED) 45 | endif () 46 | 47 | set(FMT_SOURCES format.cc format.h) 48 | 49 | include(CheckSymbolExists) 50 | if (WIN32) 51 | check_symbol_exists(open io.h HAVE_OPEN) 52 | else () 53 | check_symbol_exists(open fcntl.h HAVE_OPEN) 54 | endif () 55 | 56 | if (HAVE_OPEN) 57 | add_definitions(-DFMT_USE_FILE_DESCRIPTORS=1) 58 | set(FMT_SOURCES ${FMT_SOURCES} posix.cc posix.h) 59 | endif () 60 | 61 | if (CPP11_FLAG) 62 | set(CMAKE_REQUIRED_FLAGS ${CPP11_FLAG}) 63 | endif () 64 | 65 | add_library(format ${shared} ${FMT_SOURCES}) 66 | if (CMAKE_COMPILER_IS_GNUCXX) 67 | set_target_properties(format PROPERTIES COMPILE_FLAGS "-Wall -Wextra -pedantic") 68 | endif () 69 | 70 | include_directories(.) 71 | 72 | # Check if variadic templates are working and not affected by GCC bug 39653: 73 | # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39653 74 | check_cxx_source_compiles(" 75 | template 76 | struct S { typedef typename S::type type; }; 77 | int main() {}" FMT_VARIADIC_TEMPLATES) 78 | if (NOT FMT_VARIADIC_TEMPLATES) 79 | add_definitions(-DGTEST_LANG_CXX11=0) 80 | endif () 81 | -------------------------------------------------------------------------------- /ext_libs/cppformat/cmake/FindSetEnv.cmake: -------------------------------------------------------------------------------- 1 | # A CMake script to find SetEnv.cmd. 2 | 3 | find_program(WINSDK_SETENV NAMES SetEnv.cmd 4 | PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]/bin") 5 | if (WINSDK_SETENV AND PRINT_PATH) 6 | execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${WINSDK_SETENV}") 7 | endif () 8 | -------------------------------------------------------------------------------- /ext_libs/cppformat/cmake/run-cmake.bat: -------------------------------------------------------------------------------- 1 | @echo on 2 | rem This scripts configures build environment and runs CMake. 3 | rem Use it instead of running CMake directly when building with 4 | rem the Microsoft SDK toolchain rather than Visual Studio. 5 | rem It is used in the same way as cmake, for example: 6 | rem 7 | rem run-cmake -G "Visual Studio 10 Win64" . 8 | 9 | for /F "delims=" %%i IN ('cmake "-DPRINT_PATH=1" -P %~dp0/FindSetEnv.cmake') DO set setenv=%%i 10 | if NOT "%setenv%" == "" call "%setenv%" 11 | cmake %* 12 | -------------------------------------------------------------------------------- /ext_libs/divsufsort/AUTHORS: -------------------------------------------------------------------------------- 1 | -- AUTHORS for libdivsufsort 2 | 3 | Yuta Mori 4 | -------------------------------------------------------------------------------- /ext_libs/divsufsort/CMakeModules/AppendCompilerFlags.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCSourceCompiles) 2 | include(CheckCXXSourceCompiles) 3 | 4 | macro(append_c_compiler_flags _flags _name _result) 5 | set(SAFE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) 6 | string(REGEX REPLACE "[-+/ ]" "_" cname "${_name}") 7 | string(TOUPPER "${cname}" cname) 8 | foreach(flag ${_flags}) 9 | string(REGEX REPLACE "^[-+/ ]+(.*)[-+/ ]*$" "\\1" flagname "${flag}") 10 | string(REGEX REPLACE "[-+/ ]" "_" flagname "${flagname}") 11 | string(TOUPPER "${flagname}" flagname) 12 | set(have_flag "HAVE_${cname}_${flagname}") 13 | set(CMAKE_REQUIRED_FLAGS "${flag}") 14 | check_c_source_compiles("int main() { return 0; }" ${have_flag}) 15 | if(${have_flag}) 16 | set(${_result} "${${_result}} ${flag}") 17 | endif(${have_flag}) 18 | endforeach(flag) 19 | set(CMAKE_REQUIRED_FLAGS ${SAFE_CMAKE_REQUIRED_FLAGS}) 20 | endmacro(append_c_compiler_flags) 21 | 22 | macro(append_cxx_compiler_flags _flags _name _result) 23 | set(SAFE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) 24 | string(REGEX REPLACE "[-+/ ]" "_" cname "${_name}") 25 | string(TOUPPER "${cname}" cname) 26 | foreach(flag ${_flags}) 27 | string(REGEX REPLACE "^[-+/ ]+(.*)[-+/ ]*$" "\\1" flagname "${flag}") 28 | string(REGEX REPLACE "[-+/ ]" "_" flagname "${flagname}") 29 | string(TOUPPER "${flagname}" flagname) 30 | set(have_flag "HAVE_${cname}_${flagname}") 31 | set(CMAKE_REQUIRED_FLAGS "${flag}") 32 | check_cxx_source_compiles("int main() { return 0; }" ${have_flag}) 33 | if(${have_flag}) 34 | set(${_result} "${${_result}} ${flag}") 35 | endif(${have_flag}) 36 | endforeach(flag) 37 | set(CMAKE_REQUIRED_FLAGS ${SAFE_CMAKE_REQUIRED_FLAGS}) 38 | endmacro(append_cxx_compiler_flags) 39 | -------------------------------------------------------------------------------- /ext_libs/divsufsort/CMakeModules/CheckFunctionKeywords.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCSourceCompiles) 2 | 3 | macro(check_function_keywords _wordlist) 4 | set(${_result} "") 5 | foreach(flag ${_wordlist}) 6 | string(REGEX REPLACE "[-+/ ()]" "_" flagname "${flag}") 7 | string(TOUPPER "${flagname}" flagname) 8 | set(have_flag "HAVE_${flagname}") 9 | check_c_source_compiles("${flag} void func(); void func() { } int main() { func(); return 0; }" ${have_flag}) 10 | if(${have_flag} AND NOT ${_result}) 11 | set(${_result} "${flag}") 12 | # break() 13 | endif(${have_flag} AND NOT ${_result}) 14 | endforeach(flag) 15 | endmacro(check_function_keywords) 16 | -------------------------------------------------------------------------------- /ext_libs/divsufsort/CMakeModules/ProjectCPack.cmake: -------------------------------------------------------------------------------- 1 | # If the cmake version includes cpack, use it 2 | IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") 3 | SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}") 4 | SET(CPACK_PACKAGE_VENDOR "${PROJECT_VENDOR}") 5 | SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") 6 | SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") 7 | SET(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") 8 | SET(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") 9 | SET(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") 10 | # SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME} ${PROJECT_VERSION}") 11 | SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION_FULL}") 12 | 13 | IF(NOT DEFINED CPACK_SYSTEM_NAME) 14 | SET(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") 15 | ENDIF(NOT DEFINED CPACK_SYSTEM_NAME) 16 | 17 | IF(${CPACK_SYSTEM_NAME} MATCHES Windows) 18 | IF(CMAKE_CL_64) 19 | SET(CPACK_SYSTEM_NAME win64-${CMAKE_SYSTEM_PROCESSOR}) 20 | ELSE(CMAKE_CL_64) 21 | SET(CPACK_SYSTEM_NAME win32-${CMAKE_SYSTEM_PROCESSOR}) 22 | ENDIF(CMAKE_CL_64) 23 | ENDIF(${CPACK_SYSTEM_NAME} MATCHES Windows) 24 | 25 | IF(NOT DEFINED CPACK_PACKAGE_FILE_NAME) 26 | SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}") 27 | ENDIF(NOT DEFINED CPACK_PACKAGE_FILE_NAME) 28 | 29 | SET(CPACK_PACKAGE_CONTACT "${PROJECT_CONTACT}") 30 | IF(UNIX) 31 | SET(CPACK_STRIP_FILES "") 32 | SET(CPACK_SOURCE_STRIP_FILES "") 33 | # SET(CPACK_PACKAGE_EXECUTABLES "ccmake" "CMake") 34 | ENDIF(UNIX) 35 | SET(CPACK_SOURCE_IGNORE_FILES "/CVS/" "/build/" "/\\\\.build/" "/\\\\.svn/" "~$") 36 | # include CPack model once all variables are set 37 | INCLUDE(CPack) 38 | ENDIF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") 39 | -------------------------------------------------------------------------------- /ext_libs/divsufsort/CMakeModules/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 2 | MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") 3 | ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 4 | 5 | FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 6 | STRING(REGEX REPLACE "\n" ";" files "${files}") 7 | 8 | SET(NUM 0) 9 | FOREACH(file ${files}) 10 | IF(EXISTS "$ENV{DESTDIR}${file}") 11 | MESSAGE(STATUS "Looking for \"$ENV{DESTDIR}${file}\" - found") 12 | SET(UNINSTALL_CHECK_${NUM} 1) 13 | ELSE(EXISTS "$ENV{DESTDIR}${file}") 14 | MESSAGE(STATUS "Looking for \"$ENV{DESTDIR}${file}\" - not found") 15 | SET(UNINSTALL_CHECK_${NUM} 0) 16 | ENDIF(EXISTS "$ENV{DESTDIR}${file}") 17 | MATH(EXPR NUM "1 + ${NUM}") 18 | ENDFOREACH(file) 19 | 20 | SET(NUM 0) 21 | FOREACH(file ${files}) 22 | IF(${UNINSTALL_CHECK_${NUM}}) 23 | MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") 24 | EXEC_PROGRAM( 25 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 26 | OUTPUT_VARIABLE rm_out 27 | RETURN_VALUE rm_retval 28 | ) 29 | IF(NOT "${rm_retval}" STREQUAL 0) 30 | MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") 31 | ENDIF(NOT "${rm_retval}" STREQUAL 0) 32 | ENDIF(${UNINSTALL_CHECK_${NUM}}) 33 | MATH(EXPR NUM "1 + ${NUM}") 34 | ENDFOREACH(file) 35 | 36 | FILE(REMOVE "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 37 | -------------------------------------------------------------------------------- /ext_libs/divsufsort/COPYING: -------------------------------------------------------------------------------- 1 | The libdivsufsort copyright is as follows: 2 | 3 | Copyright (c) 2003-2008 Yuta Mori All Rights Reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without 8 | restriction, including without limitation the rights to use, 9 | copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following 12 | conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | OTHER DEALINGS IN THE SOFTWARE. 25 | 26 | See also the libdivsufsort web site: 27 | http://libdivsufsort.googlecode.com/ for more information. 28 | -------------------------------------------------------------------------------- /ext_libs/divsufsort/INSTALL: -------------------------------------------------------------------------------- 1 | -- INSTALL for libdivsufsort 2 | 3 | 4 | Requirements: 5 | ============= 6 | 7 | * CMake version 2.4.2 or newer (http://www.cmake.org/) 8 | * An ANSI C compiler 9 | * GNU Make 10 | 11 | 12 | Compilation and Installation (with Unix Makefiles): 13 | =================================================== 14 | 15 | 1. Create a 'build' directory in the package source directory. 16 | 17 | $ cd libdivsufsort-?.?.? 18 | $ mkdir build 19 | $ cd build 20 | 21 | 2. Configure the package for your system. 22 | 23 | $ cmake -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX="/usr/local" .. 24 | 25 | 3. Compile the package. 26 | 27 | $ make 28 | 29 | 4. Install the library and header files. 30 | 31 | # make install 32 | -------------------------------------------------------------------------------- /ext_libs/divsufsort/VERSION: -------------------------------------------------------------------------------- 1 | 2.0.1 2 | -------------------------------------------------------------------------------- /ext_libs/divsufsort/include/config.h.cmake: -------------------------------------------------------------------------------- 1 | /* 2 | * config.h for libdivsufsort 3 | * Copyright (c) 2003-2008 Yuta Mori All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person 6 | * obtaining a copy of this software and associated documentation 7 | * files (the "Software"), to deal in the Software without 8 | * restriction, including without limitation the rights to use, 9 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following 12 | * conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #ifndef _CONFIG_H 28 | #define _CONFIG_H 1 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif /* __cplusplus */ 33 | 34 | /** Define to the version of this package. **/ 35 | #cmakedefine PROJECT_VERSION_FULL "${PROJECT_VERSION_FULL}" 36 | 37 | /** Define to 1 if you have the header files. **/ 38 | #cmakedefine HAVE_INTTYPES_H 1 39 | #cmakedefine HAVE_STDDEF_H 1 40 | #cmakedefine HAVE_STDINT_H 1 41 | #cmakedefine HAVE_STDLIB_H 1 42 | #cmakedefine HAVE_STRING_H 1 43 | #cmakedefine HAVE_STRINGS_H 1 44 | #cmakedefine HAVE_MEMORY_H 1 45 | #cmakedefine HAVE_SYS_TYPES_H 1 46 | 47 | /** for WinIO **/ 48 | #cmakedefine HAVE_IO_H 1 49 | #cmakedefine HAVE_FCNTL_H 1 50 | #cmakedefine HAVE__SETMODE 1 51 | #cmakedefine HAVE_SETMODE 1 52 | #cmakedefine HAVE__FILENO 1 53 | #cmakedefine HAVE_FOPEN_S 1 54 | #cmakedefine HAVE__O_BINARY 1 55 | #ifndef HAVE__SETMODE 56 | # if HAVE_SETMODE 57 | # define _setmode setmode 58 | # define HAVE__SETMODE 1 59 | # endif 60 | # if HAVE__SETMODE && !HAVE__O_BINARY 61 | # define _O_BINARY 0 62 | # define HAVE__O_BINARY 1 63 | # endif 64 | #endif 65 | 66 | /** for inline **/ 67 | #ifndef INLINE 68 | # define INLINE @INLINE@ 69 | #endif 70 | 71 | /** for VC++ warning **/ 72 | #ifdef _MSC_VER 73 | #pragma warning(disable: 4127) 74 | #endif 75 | 76 | 77 | #ifdef __cplusplus 78 | } /* extern "C" */ 79 | #endif /* __cplusplus */ 80 | 81 | #endif /* _CONFIG_H */ 82 | -------------------------------------------------------------------------------- /ext_libs/divsufsort/include/lfs.h.cmake: -------------------------------------------------------------------------------- 1 | /* 2 | * lfs.h for libdivsufsort 3 | * Copyright (c) 2003-2008 Yuta Mori All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person 6 | * obtaining a copy of this software and associated documentation 7 | * files (the "Software"), to deal in the Software without 8 | * restriction, including without limitation the rights to use, 9 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following 12 | * conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #ifndef _LFS_H 28 | #define _LFS_H 1 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif /* __cplusplus */ 33 | 34 | #ifndef __STRICT_ANSI__ 35 | # define LFS_OFF_T @LFS_OFF_T@ 36 | # define LFS_FOPEN @LFS_FOPEN@ 37 | # define LFS_FTELL @LFS_FTELL@ 38 | # define LFS_FSEEK @LFS_FSEEK@ 39 | # define LFS_PRId @LFS_PRID@ 40 | #else 41 | # define LFS_OFF_T long 42 | # define LFS_FOPEN fopen 43 | # define LFS_FTELL ftell 44 | # define LFS_FSEEK fseek 45 | # define LFS_PRId "ld" 46 | #endif 47 | #ifndef PRIdOFF_T 48 | # define PRIdOFF_T LFS_PRId 49 | #endif 50 | 51 | 52 | #ifdef __cplusplus 53 | } /* extern "C" */ 54 | #endif /* __cplusplus */ 55 | 56 | #endif /* _LFS_H */ 57 | -------------------------------------------------------------------------------- /ext_libs/divsufsort/lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include" 2 | "${CMAKE_CURRENT_BINARY_DIR}/../include") 3 | 4 | set(divsufsort_SRCS divsufsort.c sssort.c trsort.c utils.c) 5 | 6 | ## libdivsufsort ## 7 | add_library(divsufsort ${divsufsort_SRCS}) 8 | install(TARGETS divsufsort 9 | RUNTIME DESTINATION bin 10 | LIBRARY DESTINATION lib 11 | ARCHIVE DESTINATION lib) 12 | set_target_properties(divsufsort PROPERTIES 13 | VERSION "${LIBRARY_VERSION_FULL}" 14 | SOVERSION "${LIBRARY_VERSION_MAJOR}" 15 | DEFINE_SYMBOL DIVSUFSORT_BUILD_DLL 16 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../examples") 17 | 18 | ## libdivsufsort64 ## 19 | if(BUILD_DIVSUFSORT64) 20 | add_library(divsufsort64 ${divsufsort_SRCS}) 21 | install(TARGETS divsufsort64 22 | RUNTIME DESTINATION bin 23 | LIBRARY DESTINATION lib 24 | ARCHIVE DESTINATION lib) 25 | set_target_properties(divsufsort64 PROPERTIES 26 | VERSION "${LIBRARY_VERSION_FULL}" 27 | SOVERSION "${LIBRARY_VERSION_MAJOR}" 28 | DEFINE_SYMBOL DIVSUFSORT_BUILD_DLL 29 | COMPILE_FLAGS "-DBUILD_DIVSUFSORT64" 30 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../examples") 31 | endif(BUILD_DIVSUFSORT64) 32 | -------------------------------------------------------------------------------- /ext_libs/divsufsort/lib/libdivsufsort.sym: -------------------------------------------------------------------------------- 1 | divsufsort 2 | divbwt 3 | divsufsort_version 4 | bw_transform 5 | inverse_bw_transform 6 | sufcheck 7 | sa_search 8 | sa_simplesearch 9 | -------------------------------------------------------------------------------- /ext_libs/divsufsort/lib/libdivsufsort64.sym: -------------------------------------------------------------------------------- 1 | divsufsort64 2 | divbwt64 3 | divsufsort64_version 4 | bw_transform64 5 | inverse_bw_transform64 6 | sufcheck64 7 | sa_search64 8 | sa_simplesearch64 9 | -------------------------------------------------------------------------------- /ext_libs/sha1/sha1.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Micael Hildenborg 3 | 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 met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Micael Hildenborg nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Micael Hildenborg ''AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Micael Hildenborg BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef SHA1_DEFINED 29 | #define SHA1_DEFINED 30 | 31 | namespace sha1 32 | { 33 | 34 | /** 35 | @param src points to any kind of data to be hashed. 36 | @param bytelength the number of bytes to hash from the src pointer. 37 | @param hash should point to a buffer of at least 20 bytes of size for storing the sha1 result in. 38 | */ 39 | void calc(const void* src, const int bytelength, unsigned char* hash); 40 | 41 | /** 42 | @param hash is 20 bytes of sha1 hash. This is the same data that is the result from the calc function. 43 | @param hexstring should point to a buffer of at least 41 bytes of size for storing the hexadecimal representation of the hash. A zero will be written at position 40, so the buffer will be a valid zero ended string. 44 | */ 45 | void toHexString(const unsigned char* hash, char* hexstring); 46 | 47 | } // namespace sha1 48 | 49 | #endif // SHA1_DEFINED 50 | -------------------------------------------------------------------------------- /include/bicriteria_compress.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef BICRITERIA_COMPRESS_HPP 18 | #define BICRITERIA_COMPRESS_HPP 19 | 20 | void bicriteria_compress(char *tool_name, int argc, char **argv); 21 | 22 | #endif // BICRITERIA_COMPRESS_HPP 23 | -------------------------------------------------------------------------------- /include/bit_compress.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef BIT_COMPRESS_HPP 18 | #define BIT_COMPRESS_HPP 19 | 20 | void bit_compress(const char *tool_name, int argc, char **argv); 21 | 22 | #endif // BIT_COMPRESS_HPP 23 | -------------------------------------------------------------------------------- /include/bucket_fsg.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef BUCKET_FSG_HPP 18 | #define BUCKET_FSG_HPP 19 | 20 | #include 21 | #include 22 | 23 | 24 | template 25 | class bucket_fsg { 26 | private: 27 | size_t bucket_size; 28 | unsigned int bucket_idx; 29 | text_info ti; 30 | sa_getter &sa_cache; 31 | std::shared_ptr gen; 32 | cost_model cm; 33 | std::vector maxedges; 34 | 35 | bool next_gen() 36 | { 37 | #ifndef NDEBUG 38 | std::cout << "Generating bucket " << bucket_idx << std::endl; 39 | #endif 40 | if (bucket_idx * bucket_size >= ti.len) { 41 | return false; 42 | } 43 | byte *start = ti.text.get() + bucket_size * bucket_idx; 44 | size_t len = std::min(bucket_size, ti.len - bucket_size * bucket_idx); 45 | #ifndef NDEBUG 46 | std::cout << "Bucket length: " << len << std::endl; 47 | #endif 48 | std::shared_ptr text(start, null_deleter()); 49 | text_info new_ti(text, len); 50 | auto new_gen = gen_fact(new_ti, sa_cache).instantiate(cm); 51 | std::swap(gen, new_gen); 52 | bucket_idx++; 53 | return true; 54 | } 55 | 56 | public: 57 | bucket_fsg(text_info ti, sa_getter &sa_cache, size_t bucket_size, cost_model cm) 58 | : bucket_size(bucket_size), bucket_idx(0U), ti(ti), sa_cache(sa_cache), cm(cm) 59 | { 60 | next_gen(); 61 | maxedges.resize(gen->get_edges().size()); 62 | } 63 | 64 | std::vector &get_edges() 65 | { 66 | return maxedges; 67 | } 68 | 69 | inline bool gen_next(std::uint32_t *generated) 70 | { 71 | while (gen->gen_next(generated) == false) { 72 | if (next_gen() == false){ 73 | *generated = 0; 74 | return false; 75 | } 76 | } 77 | 78 | auto &gen_max = gen->get_edges(); 79 | std::copy(gen_max.begin(), std::next(gen_max.begin(), *generated), maxedges.begin()); 80 | return true; 81 | } 82 | }; 83 | 84 | #endif // BUCKET_FSG_HPP 85 | -------------------------------------------------------------------------------- /include/c_time.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef __CTIME__ 18 | #define __CTIME__ 19 | #include 20 | #include 21 | 22 | struct count_time { 23 | static time_t clock() 24 | { 25 | time_t usertime, systime; 26 | struct rusage usage; 27 | 28 | getrusage (RUSAGE_SELF, &usage); 29 | 30 | usertime = usage.ru_utime.tv_sec * 1000000 + usage.ru_utime.tv_usec; 31 | systime = usage.ru_stime.tv_sec * 1000000 + usage.ru_stime.tv_usec; 32 | 33 | return usertime + systime; 34 | } 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/class_info.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef CLASS_INFO_HPP 18 | #define CLASS_INFO_HPP 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | struct class_info { 26 | std::vector win; 27 | std::vector costs; 28 | size_t length; 29 | 30 | template 31 | class_info(T win_first, T win_last, U costs_first, U costs_last) { 32 | win.insert(win.end(), win_first, win_last); 33 | costs.insert(costs.end(), costs_first, costs_last); 34 | length = std::distance(win_first, win_last); 35 | } 36 | 37 | size_t extent() const { 38 | return win[length - 1]; 39 | } 40 | 41 | double get_cost(unsigned int i) 42 | { 43 | assert(i <= extent()); 44 | auto distance = std::distance(win.begin(), std::lower_bound(win.begin(), win.end(), i)); 45 | return costs[distance]; 46 | } 47 | }; 48 | 49 | #endif // CLASS_INFO_HPP 50 | -------------------------------------------------------------------------------- /include/cm_factory.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef __CM_FACTORY_HPP 18 | #define __CM_FACTORY_HPP 19 | 20 | #include 21 | 22 | class cm_factory { 23 | private: 24 | cost_model cost_; 25 | cost_model weight_; 26 | public: 27 | 28 | cm_factory() 29 | { 30 | 31 | } 32 | 33 | cm_factory(cost_model cost, cost_model weight); 34 | 35 | cost_model cost(); 36 | 37 | cost_model weight(); 38 | 39 | cost_model lambda(double lambda); 40 | }; 41 | 42 | #endif -------------------------------------------------------------------------------- /include/cmd_parse.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef CMD_PARSE_HPP 18 | #define CMD_PARSE_HPP 19 | #include 20 | 21 | /** Parsing exception */ 22 | class cmd_error : public std::runtime_error { 23 | private: 24 | const std::string usage; 25 | public: 26 | cmd_error(std::string usage) : 27 | std::runtime_error("Command line parsing error"), usage(usage) { } 28 | std::string cmd_usage() { return usage; } 29 | ~cmd_error() throw() { } 30 | }; 31 | 32 | #endif // CMD_PARSE_HPP 33 | -------------------------------------------------------------------------------- /include/facilities.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef __FACITILITIES_HPP_ 18 | #define __FACITILITIES_HPP_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | 30 | // Expands to the pair of iterators of v. 31 | #define ITERS(v) v.begin(), v.end() 32 | 33 | /* Measure time */ 34 | 35 | template 36 | struct measure 37 | { 38 | typedef typename TimeT::rep timerep_t; 39 | 40 | template 41 | static auto execution(F func) -> std::tuple 42 | { 43 | auto t_1 = std::chrono::high_resolution_clock::now(); 44 | auto v = func(); 45 | auto t_2 = std::chrono::high_resolution_clock::now(); 46 | auto duration = std::chrono::duration_cast< TimeT>(t_2 - t_1); 47 | 48 | return std::make_tuple(duration.count(), std::move(v)); 49 | } 50 | }; 51 | 52 | /** Return the number of bits of the minimal binary rep. of u */ 53 | size_t bits(unsigned int u); 54 | 55 | template 56 | struct joiner; 57 | 58 | template 59 | struct joiner { 60 | static std::string join(T t, U... u) 61 | { 62 | std::stringstream ss; 63 | ss << t; 64 | return ss.str() + joiner::join(u...); 65 | } 66 | }; 67 | 68 | template <> 69 | struct joiner<> { 70 | static std::string join() 71 | { 72 | return ""; 73 | } 74 | }; 75 | 76 | template 77 | std::string join_s(T... t) 78 | { 79 | return joiner::join(t...); 80 | } 81 | 82 | template 83 | std::shared_ptr make_shared(std::unique_ptr &&p) 84 | { 85 | return std::shared_ptr(p.release(), std::default_delete()); 86 | } 87 | 88 | template 89 | std::shared_ptr make_shared(std::unique_ptr &&p) 90 | { 91 | return std::shared_ptr(p.release()); 92 | } 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /include/factories.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef FACTORIES_HPP 18 | #define FACTORIES_HPP 19 | 20 | #include "fast_fsg.hpp" 21 | #include "fsg.hpp" 22 | 23 | template 24 | class ffsg_factory { 25 | private: 26 | std::shared_ptr text; 27 | size_t length; 28 | class_info dst, len; 29 | std::shared_ptr> sa; 30 | public: 31 | ffsg_factory(std::shared_ptr text, size_t length, class_info dst, class_info len) 32 | : text(text), length(length), dst(dst), len(len) 33 | { 34 | sa = get_sa(text.get(), length); 35 | } 36 | 37 | fast_fsg get() 38 | { 39 | return fast_fsg(text, length, sa, dst, len); 40 | } 41 | }; 42 | 43 | #endif // FACTORIES_HPP 44 | -------------------------------------------------------------------------------- /include/factory.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef FACTORY_HPP 18 | #define FACTORY_HPP 19 | 20 | #include 21 | 22 | /** 23 | * Wraps a constructor into a function. 24 | */ 25 | template 26 | class ctor { 27 | public: 28 | template 29 | std::unique_ptr operator()(Args ...args) 30 | { 31 | return make_unique(args...); 32 | } 33 | }; 34 | 35 | /** 36 | * Defines a generic factory. 37 | * - Base: Base type 38 | * - T: Instantiated type 39 | */ 40 | template 41 | class generic_factory { 42 | private: 43 | std::function()> ctor_; 44 | public: 45 | template 46 | generic_factory(Args... args) 47 | { 48 | ctor_ = std::bind(ctor(), args...); 49 | } 50 | 51 | std::unique_ptr get() 52 | { 53 | return ctor_(); 54 | } 55 | }; 56 | 57 | #endif // FACTORY_HPP 58 | -------------------------------------------------------------------------------- /include/format.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef FORMAT_HPP 18 | #define FORMAT_HPP 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | typedef std::uint32_t uncomp_size_t; 26 | // INJECT/EJECT SIZE //////////////////////////////////////////////////////////////////////// 27 | template 28 | byte *inject_size(byte *comp, T size) 29 | { 30 | *reinterpret_cast(comp) = size; 31 | return comp += sizeof(size); 32 | } 33 | 34 | uncomp_size_t extract_size(byte *comp, byte **new_ptr); 35 | 36 | // PACK FUNCTIONS /////////////////////////////////////////////////////////////////////////// 37 | /** 38 | * @brief Unpacks parameters 39 | * @param data 40 | * Compressed data 41 | * @return 42 | * Gets the encoder name, the uncompressed length, the start of the encoded run and the encoded run length 43 | */ 44 | std::tuple unpack(byte *data); 45 | 46 | std::tuple ptr_unpack(byte *data); 47 | 48 | struct pack_info { 49 | std::unique_ptr parsing; 50 | size_t data_len; 51 | }; 52 | 53 | /** 54 | * @brief Packs the parameters and reserve enough space for the comp. representation 55 | * @param enc_name 56 | * The encoder name 57 | * @param orig_len 58 | * The decompressed file lenght 59 | * @param comp_len 60 | * The compressed length 61 | * @return 62 | * A pointer to the start of the comp. rep. and the length of the compressed rep. 63 | */ 64 | pack_info pack(std::string enc_name, size_t orig_len, size_t comp_len); 65 | ///////////////////////////////////////////////////////////////////////////////////////////// 66 | 67 | #endif // FORMAT_HPP 68 | -------------------------------------------------------------------------------- /include/hw_counter.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef __HW_COUNTER_HPP 18 | #define __HW_COUNTER_HPP 19 | 20 | extern "C" { 21 | #include "hw_counter.h" 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /include/impl/api_impl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef __API__IMPL__ 18 | #define __API__IMPL__ 19 | 20 | #include 21 | #include 22 | 23 | /** 24 | * Logic needed to implement some of this API, not meant to be used directly in client code 25 | */ 26 | namespace bczip { 27 | namespace impl { 28 | 29 | template 30 | class proper_nexts { 31 | private: 32 | byte *to_patch; 33 | size_t comp_len; 34 | size_t orig_len; 35 | edge_it_t lits; 36 | byte *output; 37 | public: 38 | 39 | proper_nexts( 40 | byte *to_patch, size_t comp_len, size_t orig_len, edge_it_t lits, byte *output 41 | ) 42 | : to_patch(to_patch), comp_len(comp_len), orig_len(orig_len), lits(lits), output(output) 43 | { 44 | 45 | } 46 | 47 | template 48 | void run() 49 | { 50 | typedef typename encoder_::encoder enc_t; 51 | // Get encoder and reader 52 | lzopt::phrase_reader reader(to_patch, orig_len); 53 | enc_t enc(output, comp_len); 54 | 55 | // Start patching 56 | while (!reader.end()) { 57 | unsigned int dst, len; 58 | reader.next(dst, len); 59 | // assert(*lits == last_lits); 60 | if (dst > 0) { 61 | assert(len > 0); 62 | enc.encode(dst, len); 63 | } else { 64 | reader.adjust_next(*lits); 65 | byte *run = reader.get_buffer(); 66 | enc.encode(run, len, *lits++); 67 | } 68 | } 69 | } 70 | }; 71 | } 72 | } 73 | 74 | #endif -------------------------------------------------------------------------------- /include/io.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef __IOS_ 18 | #define __IOS_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | class ioexception : public std::runtime_error { 26 | public: 27 | explicit ioexception(const char *what) : std::runtime_error(what) { } 28 | }; 29 | 30 | void open_file(std::ifstream &file, const char *name); 31 | 32 | void open_file(std::ofstream &file, const char *name); 33 | 34 | std::streamoff file_length(std::ifstream &f) throw (ioexception); 35 | 36 | template 37 | void read_some(std::ifstream &f, T *data, std::streamsize length) throw (ioexception) 38 | { 39 | f.read(reinterpret_cast(data), sizeof(T) * length); 40 | } 41 | 42 | template 43 | void read_data(std::ifstream &f, T *data, std::streamsize length) throw (ioexception) 44 | { 45 | f.read(reinterpret_cast(data), sizeof(T) * length); 46 | if (f.bad() || f.fail()) 47 | throw ioexception("Failed to read file"); 48 | } 49 | 50 | template 51 | void read_file(std::ifstream &f, T *data, std::streamsize length) throw (ioexception) 52 | { 53 | f.seekg(0, std::ios_base::beg); 54 | read_data(f, data, length); 55 | } 56 | 57 | template 58 | void write_file(std::ofstream &f, T *data, std::streamsize length) throw (ioexception) 59 | { 60 | f.write(reinterpret_cast(data), sizeof(T) * length); 61 | if (f.bad() || f.fail()) 62 | throw ioexception("Failed to write on file"); 63 | } 64 | 65 | template 66 | std::unique_ptr read_file(const char *name, size_t *size = nullptr, unsigned int extra = 0) 67 | { 68 | std::ifstream file; 69 | open_file(file, name); 70 | size_t l_size = file_length(file); 71 | if (size != nullptr) { 72 | *size = l_size; 73 | } 74 | std::unique_ptr to_ret(new T[l_size + extra]); 75 | std::fill(to_ret.get(), to_ret.get() + l_size + extra, T()); 76 | read_file(file, to_ret.get(), static_cast(l_size)); 77 | return std::move(to_ret); 78 | } 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /include/list.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef LIST_HPP 18 | #define LIST_HPP 19 | 20 | void list_encoders(); 21 | 22 | #endif // LIST_HPP 23 | -------------------------------------------------------------------------------- /include/list_gens.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef LIST_GENS_HPP 18 | #define LIST_GENS_HPP 19 | 20 | void list_generators(); 21 | 22 | #endif // LIST_GENS_HPP 23 | -------------------------------------------------------------------------------- /include/match_length.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef __MAXIMAL_LENGTH 18 | #define __MAXIMAL_LENGTH 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | template 25 | class maximal_length { 26 | private: 27 | /** Pointer to beginning of text */ 28 | T *text; 29 | /** Pointer to end-of-text */ 30 | T *end; 31 | /** Previously queried element */ 32 | std::int_fast64_t previous_pos; 33 | unsigned int pmatch; 34 | unsigned int smatch; 35 | 36 | void update_match(unsigned int position, unsigned int current, unsigned int &match) 37 | { 38 | T *match_p = text + position + match; 39 | T *cur_p = text + current + match; 40 | assert(match_p < cur_p); 41 | while (cur_p < end && *match_p == *cur_p) { 42 | match_p++; 43 | cur_p++; 44 | } 45 | match = cur_p - (text + current); 46 | } 47 | 48 | public: 49 | maximal_length(T * text, size_t len) : text(text), end(text + len), previous_pos(-1), pmatch(0), smatch(0) { } 50 | 51 | /** 52 | * @brief Find the longest match between T[pos] and T[pred] and T[succ]. 53 | * @param pred 54 | * The predecessor of T[pos] 55 | * @param succ 56 | * The successor of T[pos] 57 | * @param pos 58 | * The current position 59 | * @return 60 | * 61 | */ 62 | std::tuple match(unsigned int pred, unsigned int succ, unsigned int pos) 63 | { 64 | using std::make_tuple; 65 | auto distance = pos - previous_pos; 66 | previous_pos = pos; 67 | pmatch = pmatch > distance ? pmatch - distance : 0U; 68 | smatch = smatch > distance ? smatch - distance : 0U; 69 | auto no_match = std::numeric_limits::max(); 70 | if (pred != no_match) { 71 | update_match(pred, pos, pmatch); 72 | } 73 | if (succ != no_match) { 74 | update_match(succ, pos, smatch); 75 | } 76 | 77 | if (pmatch == 0 && smatch == 0) { 78 | return make_tuple(0, 0); 79 | } 80 | return pmatch > smatch ? make_tuple(pos - pred, pmatch) : make_tuple(pos - succ, smatch); 81 | } 82 | }; 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /include/meter_printer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef METER_PRINTER_HPP 18 | #define METER_PRINTER_HPP 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | class meter { 26 | private: 27 | unsigned int get_columns() 28 | { 29 | struct winsize w; 30 | ioctl(0, TIOCGWINSZ, &w); 31 | return w.ws_col; 32 | } 33 | 34 | unsigned int last_percent; 35 | public: 36 | meter() : last_percent(0U) 37 | { 38 | 39 | } 40 | 41 | void print_meter(double percent) { 42 | if (static_cast(percent * 100) <= last_percent) { 43 | return; 44 | } 45 | last_percent = percent * 100; 46 | auto columns = get_columns(); 47 | columns -= 6U; 48 | std::cerr << '\r' << "["; 49 | auto i = 0U; 50 | for (; i + 1 < columns * percent; i++) { 51 | std::cerr << '='; 52 | } 53 | std::cerr << ">"; 54 | ++i; 55 | for (; i < columns; i++) { 56 | std::cerr << " "; 57 | } 58 | std::cerr << "]" << std::flush; 59 | std::cerr << " " << std::right << static_cast(percent * 100) << std::flush; 60 | } 61 | }; 62 | 63 | class empty_observer { 64 | public: 65 | 66 | empty_observer(size_t = 0) 67 | { 68 | 69 | } 70 | 71 | void set_character(size_t position) 72 | { 73 | 74 | } 75 | 76 | void new_character() 77 | { 78 | 79 | } 80 | }; 81 | 82 | class fsg_meter { 83 | private: 84 | unsigned int current_char; 85 | meter m; 86 | size_t text_len; 87 | public: 88 | 89 | fsg_meter(size_t text_len) : current_char(0U), text_len(text_len) 90 | { 91 | 92 | } 93 | 94 | void set_character(size_t position) 95 | { 96 | assert(position >= current_char); 97 | current_char = position; 98 | m.print_meter(current_char / (text_len * 1.0)); 99 | } 100 | 101 | void new_character(size_t count = 1) 102 | { 103 | set_character(current_char + count); 104 | } 105 | 106 | }; 107 | 108 | #endif // METER_PRINTER_HPP 109 | -------------------------------------------------------------------------------- /include/model_read.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef MODEL_READ_HPP 18 | #define MODEL_READ_HPP 19 | 20 | #include "cost_model.hpp" 21 | 22 | /** 23 | * @brief Read a model from file. 24 | * @param file_name 25 | * The file where it is stored. Format: three groups of lines, delimited by empty lines. 26 | * First two groups: distances and lengths, one line per class cost (len, cost). 27 | * Third group: literal window, fixed and variable cost. 28 | * @param lit_window 29 | * Returns the literal window (output parameter) 30 | * @return 31 | * The cost model. 32 | */ 33 | cost_model read_model(const char *file_name, unsigned int *lit_window); 34 | 35 | #endif // MODEL_READ_HPP 36 | -------------------------------------------------------------------------------- /include/parsing_manage.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef __PARSING_MANAGE_HPP 18 | #define __PARSING_MANAGE_HPP 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | struct parsing { 25 | byte *begin; 26 | /* Compressed length, in bytes */ 27 | size_t comp_len; 28 | /* Decompressed length, in bytes */ 29 | size_t orig_len; 30 | }; 31 | 32 | class shared_parsing { 33 | private: 34 | std::shared_ptr compressed; 35 | byte *begin; 36 | size_t comp_len; 37 | size_t orig_len; 38 | public: 39 | shared_parsing(std::shared_ptr parsing, byte *begin, size_t comp_len, size_t orig_len) 40 | : compressed(parsing), begin(begin), comp_len(comp_len), orig_len (orig_len ) 41 | { 42 | 43 | } 44 | 45 | shared_parsing(std::shared_ptr parsing, size_t comp_len, size_t orig_len) 46 | : shared_parsing(parsing, parsing.get(), comp_len, orig_len) 47 | { 48 | 49 | } 50 | 51 | byte *ptr() 52 | { 53 | return begin; 54 | } 55 | 56 | size_t compressed_size() 57 | { 58 | return comp_len; 59 | } 60 | 61 | size_t uncompressed_size() 62 | { 63 | return orig_len; 64 | } 65 | 66 | parsing get_parsing() 67 | { 68 | auto p_len = comp_len - (begin - compressed.get()); 69 | return {begin, p_len, orig_len}; 70 | } 71 | }; 72 | 73 | /** 74 | * compress: start of compressed file (including header fields) 75 | * compress_length: compressed file length, in bytes. 76 | */ 77 | parsing get_parsing(byte *compress, size_t compress_length); 78 | 79 | parsing get_parsing(compressed_file &cf); 80 | 81 | std::shared_ptr dup_parsing(parsing &in, parsing &out); 82 | 83 | #endif -------------------------------------------------------------------------------- /include/rightmost_fsg.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef RIGHTMOST_FSG_HPP 18 | #define RIGHTMOST_FSG_HPP 19 | 20 | #include 21 | 22 | template 23 | class rm_protocol { 24 | fsg_protocol gen; 25 | std::vector max_edge; 26 | int next; 27 | public: 28 | template 29 | rm_protocol(T &&gen, size_t t_len, const std::vector &dst, 30 | const std::vector &len) 31 | : gen(fsg_protocol(std::forward(gen), t_len, dst, len)), max_edge(1), next(1U) 32 | { 33 | 34 | } 35 | 36 | inline bool gen_next(std::uint32_t *generated) 37 | { 38 | auto &inner_edges = gen.get_edges(); 39 | std::uint32_t gen_now; 40 | bool still_left = gen.gen_next(&gen_now); 41 | 42 | if (!still_left) { 43 | return false; 44 | } 45 | 46 | if (--next > 0 || gen_now == 0U) { 47 | next = std::max(0, next); 48 | *generated = 0U; 49 | return true; 50 | } 51 | 52 | edge_t &candidate = max_edge.front(); 53 | candidate = edge_t(0U); 54 | for (auto i = 0U; i < gen_now; i++) { 55 | auto cur = inner_edges[i]; 56 | if (cur.ell > candidate.ell) { 57 | candidate = cur; 58 | } 59 | } 60 | 61 | // assert(candidate.ell > 0U); 62 | assert(!candidate.invalid()); 63 | assert(candidate.ell <= std::numeric_limits::max()); 64 | next = candidate.ell; 65 | *generated = 1U; 66 | return true; 67 | } 68 | 69 | std::vector &get_edges() 70 | { 71 | return max_edge; 72 | } 73 | 74 | size_t get_tlen() 75 | { 76 | return gen.get_tlen(); 77 | } 78 | 79 | }; 80 | 81 | #endif // RIGHTMOST_FSG_HPP 82 | -------------------------------------------------------------------------------- /include/space_opt_subseq.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef __SPACE_OPT_SUBSEQ_HPP 18 | #define __SPACE_OPT_SUBSEQ_HPP 19 | #include 20 | #include 21 | 22 | namespace optimal_subseq { 23 | 24 | std::vector get_seq(std::vector dsts, std::uint64_t *cost = nullptr); 25 | 26 | std::vector get_father(std::vector dst, std::vector sol); 27 | 28 | std::vector get_thresholds( 29 | std::vector dst, std::vector sol, 30 | std::vector father 31 | ); 32 | 33 | std::vector get_costs( 34 | std::vector dst, std::vector sol, 35 | std::vector father 36 | ); 37 | 38 | std::vector get_opt_father(std::vector dst, std::vector sol); 39 | 40 | } 41 | 42 | #endif -------------------------------------------------------------------------------- /include/target_read.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef __TARGET_READ_HPP 18 | #define __TARGET_READ_HPP 19 | 20 | #include 21 | 22 | cost_model get_wm(const char *target, const char *encoder_name); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /include/tuple_executer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef TUPLE_EXECUTER_HPP 18 | #define TUPLE_EXECUTER_HPP 19 | 20 | #include 21 | 22 | template 23 | struct tuple_exec { 24 | template 25 | void execute(std::tuple &t, Fun_ &f) { 26 | f(std::get(t)); 27 | tuple_exec().execute(t, f); 28 | } 29 | }; 30 | 31 | template <> 32 | struct tuple_exec<-1> { 33 | template 34 | void execute(std::tuple &t, Fun_ &f) { 35 | } 36 | }; 37 | 38 | template 39 | void tuple_func(Fun_ &f, std::tuple t) 40 | { 41 | tuple_exec>::value - 1>().execute(t, f); 42 | } 43 | 44 | #endif // TUPLE_EXECUTER_HPP 45 | -------------------------------------------------------------------------------- /include/wm_serializer.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #ifndef __WM_SERIALIZER_ 18 | #define __WM_SERIALIZER_ 19 | 20 | #include 21 | #include 22 | 23 | std::string wm_serialize(const cost_model &wm); 24 | 25 | cost_model wm_unserialize(std::string serialized); 26 | 27 | cost_model wm_load(std::string encoder_name); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /libs/AVLtree.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include "AVLtree.h" 18 | 19 | int BMutil::first[256]; 20 | int BMutil::revfirst[256]; 21 | -------------------------------------------------------------------------------- /libs/cm_factory.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | 19 | #include 20 | #include 21 | 22 | std::vector fuse(std::vector v1, std::vector v2) 23 | { 24 | std::vector to_ret; 25 | to_ret.insert(to_ret.begin(), ITERS(v1)); 26 | to_ret.insert(to_ret.begin(), ITERS(v2)); 27 | std::sort(ITERS(to_ret)); 28 | auto new_end = std::unique(ITERS(to_ret)); 29 | to_ret.erase(new_end, to_ret.end()); 30 | return to_ret; 31 | } 32 | 33 | cost_model fuse(cost_model c1, cost_model c2, double lambda) 34 | { 35 | // "Fuse" distances and lengths 36 | std::vector distances, lengths; 37 | distances = fuse(c1.get_dst(), c2.get_dst()); 38 | lengths = fuse(c1.get_len(), c2.get_len()); 39 | 40 | // "Fuse" the cost matrix 41 | cost_matrix cm(distances.size(), lengths.size()); 42 | unsigned int dst_idx = 0; 43 | for (auto dst : distances) { 44 | unsigned int len_idx = 0; 45 | for (auto len : lengths) { 46 | unsigned int d_1, d_2, l_1, l_2; 47 | std::tie(d_1, l_1) = c1.get_idx(dst, len); 48 | std::tie(d_2, l_2) = c2.get_idx(dst, len); 49 | double cost_1 = c1.get_cost(d_1, l_1); 50 | double cost_2 = c2.get_cost(d_2, l_2); 51 | cm(dst_idx, len_idx) = cost_1 + lambda * cost_2; 52 | ++len_idx; 53 | } 54 | ++dst_idx; 55 | } 56 | 57 | // "Fuse" lit costs 58 | double lit_fix = c1.lit_cost(0) + lambda * c2.lit_cost(0); 59 | double lit_var = c1.lit_cost(1) + lambda * c2.lit_cost(1) - lit_fix; 60 | 61 | // "Fuse" the fixed cost 62 | double fixed_cost = c1.cost_per_char() + lambda * c2.cost_per_char(); 63 | 64 | // Return the cost model 65 | return cost_model(distances, lengths, cm, lit_fix, lit_var, fixed_cost); 66 | } 67 | 68 | cm_factory::cm_factory(cost_model cost, cost_model weight) 69 | : cost_(fuse(cost, weight, 0.0)), weight_(fuse(weight, cost, 0.0)) 70 | { 71 | 72 | } 73 | 74 | cost_model cm_factory::cost() 75 | { 76 | return cost_; 77 | } 78 | 79 | cost_model cm_factory::weight() 80 | { 81 | return weight_; 82 | } 83 | 84 | cost_model cm_factory::lambda(double lambda) 85 | { 86 | return fuse(cost_, weight_, lambda); 87 | } -------------------------------------------------------------------------------- /libs/decompress_lib.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | #include 19 | 20 | dec_output decompress_full(byte *data) 21 | { 22 | std::string enc_name; 23 | size_t orig_size; 24 | std::tie(enc_name, orig_size, data) = unpack(data); 25 | char *enc_ptr = const_cast(enc_name.data()); 26 | std::unique_ptr uncompressed = std::unique_ptr(new byte[orig_size + 8]); 27 | std::uint64_t nanosecs = decompress_raw(enc_ptr, data, uncompressed.get(), orig_size); 28 | return {std::move(uncompressed), enc_name, orig_size, nanosecs}; 29 | } -------------------------------------------------------------------------------- /libs/facilities.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | #include 19 | 20 | /** Fetches the current epoch, high-precision */ 21 | size_t bits(unsigned int u) { 22 | unsigned int i, j = 1; 23 | for (i = 0; j <= u; i++) j <<= 1; 24 | return i; 25 | } 26 | -------------------------------------------------------------------------------- /libs/format.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | 19 | #include 20 | #include 21 | 22 | uncomp_size_t extract_size(byte *comp, byte **new_ptr) 23 | { 24 | uncomp_size_t to_ret = *reinterpret_cast(comp); 25 | if (new_ptr != nullptr) { 26 | *new_ptr = comp += sizeof(to_ret); 27 | } 28 | return to_ret; 29 | } 30 | 31 | pack_info pack(std::string enc_name, size_t orig_len, size_t comp_len) 32 | { 33 | size_t data_len = comp_len + sizeof(uncomp_size_t) + enc_name.length() + 1; 34 | std::unique_ptr data_holder(new byte[data_len + 8]); 35 | byte *data = data_holder.get(); 36 | std::fill(data, data + data_len + 8, 0U); 37 | 38 | data = std::copy(enc_name.begin(), enc_name.end(), data); 39 | *data++ = '\0'; 40 | 41 | data = inject_size(data, orig_len); 42 | return {std::move(data_holder), data_len}; 43 | } 44 | 45 | std::tuple unpack(byte *data) 46 | { 47 | const size_t max_enc_name = 20; 48 | char enc_name[20]; 49 | std::strncpy(enc_name, const_cast(reinterpret_cast(data)), max_enc_name); 50 | enc_name[max_enc_name - 1] = '\0'; 51 | data += strnlen(enc_name, max_enc_name) + 1; 52 | size_t orig_size = extract_size(data, &data); 53 | return std::make_tuple(std::string(enc_name), orig_size, data); 54 | } 55 | 56 | std::tuple ptr_unpack(byte *data) 57 | { 58 | std::string enc_name; 59 | size_t size; 60 | byte *start; 61 | std::tie(enc_name, size, start) = unpack(data); 62 | char *name_start = reinterpret_cast(data); 63 | uncomp_size_t *len_ptr = reinterpret_cast(name_start + enc_name.length() + 1); 64 | return std::make_tuple(name_start, len_ptr, start); 65 | } -------------------------------------------------------------------------------- /libs/generators.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | 19 | std::string pick_gen(distance_kind kind) 20 | { 21 | switch (kind) { 22 | case REGULAR: 23 | return gen_ffsg_fact::name(); 24 | case MULTIPLE: 25 | return ffsg_fact::name(); 26 | default: 27 | return same_fsg_fact::name(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /libs/io.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include "io.hpp" 18 | 19 | void open_file(std::ifstream &file, const char *name) 20 | { 21 | file.open(name, std::ios::binary | std::ios::in); 22 | } 23 | 24 | void open_file(std::ofstream &file, const char *name) 25 | { 26 | file.open(name, std::ios::binary | std::ios::out | std::ios::trunc); 27 | } 28 | 29 | std::streamoff file_length(std::ifstream &f) throw (ioexception) 30 | { 31 | auto cur_pos = f.tellg(); 32 | f.seekg(0, std::ios_base::end); 33 | auto end = f.tellg(); 34 | f.seekg(cur_pos); 35 | if (f.bad() || f.fail()) 36 | throw ioexception("Failed to open file"); 37 | return end; 38 | } 39 | -------------------------------------------------------------------------------- /libs/list.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | #include "list.hpp" 19 | #include "encoders.hpp" 20 | 21 | void list_encoders() 22 | { 23 | encoders_ enc; 24 | std::vector names; 25 | enc.get_names(names); 26 | for (std::string i : names) { 27 | std::cout << i << std::endl; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /libs/model_read.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace { 28 | class_info read_ci(std::ifstream &input) 29 | { 30 | std::string line; 31 | std::vector Q_vec, cst_vec; 32 | 33 | while(bool(std::getline(input, line))) { 34 | if (line == "") { 35 | break; 36 | } 37 | std::uint64_t Q, cost; 38 | std::stringstream(line) >> Q >> cost; 39 | if (Q >= std::numeric_limits::max()) { 40 | Q_vec.push_back(std::numeric_limits::max()); 41 | } else { 42 | Q_vec.push_back(Q); 43 | } 44 | cst_vec.push_back(cost); 45 | } 46 | auto new_end = std::unique(Q_vec.begin(), Q_vec.end()); 47 | Q_vec.erase(new_end, Q_vec.end()); 48 | cst_vec.erase(std::next(cst_vec.begin(), Q_vec.size()), cst_vec.end()); 49 | return class_info(ITERS(Q_vec), ITERS(cst_vec)); 50 | } 51 | } 52 | 53 | cost_model read_model(const char *file_name, unsigned int *lit_window) 54 | { 55 | std::string line; 56 | std::ifstream input(file_name); 57 | 58 | class_info dst = read_ci(input), len = read_ci(input); 59 | 60 | /* Read literal model */ 61 | unsigned int lit_fix, lit_var; 62 | bool read = bool(std::getline(input, line)); 63 | std::stringstream(line) >> *lit_window; 64 | read = read && bool(std::getline(input, line)); 65 | std::stringstream(line) >> lit_fix; 66 | read = read && bool(std::getline(input, line)); 67 | std::stringstream(line) >> lit_var; 68 | 69 | if (dst.length == 0 || len.length == 0 || !read) { 70 | throw std::logic_error("Invalid model file."); 71 | } 72 | 73 | return cost_model(dst, len, lit_fix, lit_var); 74 | } 75 | -------------------------------------------------------------------------------- /libs/parsing_manage.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | 19 | parsing get_parsing(byte *compress, size_t compress_length) 20 | { 21 | std::string enc_name; 22 | size_t uncomp_length; 23 | byte *start; 24 | std::tie(enc_name, uncomp_length, start) = unpack(compress); 25 | size_t comp_length = compress + compress_length - start; 26 | return {start, comp_length, uncomp_length}; 27 | } 28 | 29 | parsing get_parsing(compressed_file &cf) 30 | { 31 | return get_parsing(cf.data.get(), cf.total_size); 32 | } 33 | 34 | std::shared_ptr dup_parsing(parsing &in, parsing &out) 35 | { 36 | std::shared_ptr to_ret(new byte[in.comp_len + 8], std::default_delete()); 37 | std::fill(to_ret.get(), to_ret.get() + in.comp_len + 8, 0); 38 | out = {to_ret.get(), in.comp_len, in.orig_len}; 39 | return to_ret; 40 | } -------------------------------------------------------------------------------- /libs/path_swapper.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | 19 | class swapper_fact { 20 | private: 21 | parsing p_1; 22 | double cost_1; 23 | double weight_1; 24 | parsing p_2; 25 | double cost_2; 26 | double weight_2; 27 | cost_model cost_cm; 28 | cost_model weight_cm; 29 | public: 30 | swapper_fact( 31 | parsing p_1, double cost_1, double weight_1, 32 | parsing p_2, double cost_2, double weight_2, 33 | cost_model cost_cm, cost_model weight_cm 34 | ) 35 | : p_1(p_1), cost_1(cost_1), weight_1(weight_1), 36 | p_2(p_2), cost_2(cost_2), weight_2(weight_2), 37 | cost_cm(cost_cm), weight_cm(weight_cm) 38 | { 39 | 40 | } 41 | 42 | template 43 | std::unique_ptr get_instance() const 44 | { 45 | return make_unique>(p_1, cost_1, weight_1, p_2, cost_2, weight_2, cost_cm, weight_cm); 46 | } 47 | 48 | }; 49 | 50 | std::vector path_swap( 51 | std::string encoder_name, 52 | parsing p_1, double cost_1, double weight_1, 53 | parsing p_2, double cost_2, double weight_2, 54 | cost_model cost_cm, cost_model weight_cm, double W 55 | ) 56 | { 57 | swapper_fact fact(p_1, cost_1, weight_1, p_2, cost_2, weight_2, cost_cm, weight_cm); 58 | auto swap = encoders_().instantiate(encoder_name, fact); 59 | return swap->swap(W); 60 | } -------------------------------------------------------------------------------- /libs/phrase_reader.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | #include 19 | 20 | std::unique_ptr lzopt::get_phrase_reader(byte *compressed_file) 21 | { 22 | using namespace lzopt; 23 | std::string enc_name; 24 | size_t t_len; 25 | byte *start; 26 | std::tie(enc_name, t_len, start) = unpack(compressed_file); 27 | 28 | return lzopt::get_phrase_reader(enc_name, start, t_len); 29 | } 30 | 31 | std::unique_ptr lzopt::get_phrase_reader(std::string enc_name, byte *start, size_t text_len) 32 | { 33 | pr_factory fct(start, text_len); 34 | return encoders_().instantiate(enc_name, fct); 35 | } 36 | -------------------------------------------------------------------------------- /libs/target_read.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | std::string read_field(const char *file_name, std::string field_name) 29 | { 30 | size_t file_size; 31 | auto file = read_file(file_name, &file_size, 1); 32 | (file.get())[file_size] = '\0'; 33 | std::string s(file.get()); 34 | 35 | std::stringstream ss(s); 36 | std::string field_start = "== "; 37 | bool field_found = false; 38 | std::stringstream res; 39 | const size_t max_line = 4096; 40 | char line[max_line]; 41 | while (ss.getline(line, max_line)) { 42 | if (field_found == false && std::string(line) == ("== " + field_name)) { 43 | field_found = true; 44 | } else if (field_found == true) { 45 | if (std::string(line).substr(0, field_start.size()) == field_start) { 46 | return res.str(); 47 | } else { 48 | res << (res.str().empty() ? "" : "\n") << line; 49 | } 50 | } 51 | } 52 | return res.str(); 53 | } 54 | 55 | cost_model get_wm(const char *target, const char *encoder_name) 56 | { 57 | std::string model; 58 | try { 59 | model = read_field(join_s(target, ".tgt").c_str(), encoder_name); 60 | } catch (...) { 61 | throw std::logic_error(join_s("No model ", target, " found.")); 62 | } 63 | if (model.empty()) { 64 | throw std::logic_error(join_s( 65 | "No time model for the couple (target, encoder) = (", 66 | target, 67 | ", ", 68 | encoder_name, 69 | ")." 70 | )); 71 | } 72 | return wm_unserialize(model); 73 | } -------------------------------------------------------------------------------- /libs/unaligned_io.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | 19 | std::array unaligned_io::reader_masks = {0U, 1U, 3U, 7U, (1U << 4) - 1, (1U << 5) - 1, (1U << 6) - 1, (1U << 7) - 1, 0xFF}; 20 | -------------------------------------------------------------------------------- /libs/write_parsing.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | #include 19 | 20 | void write_parsing(std::vector &sol, text_info ti, std::string file_name, std::string encoder_name) 21 | { 22 | writer_factory fact; 23 | encoders_().instantiate(encoder_name, fact)->write(file_name, ti, sol); 24 | } 25 | 26 | class base_p_writer { 27 | public: 28 | virtual compressed_file write(const std::vector &sol, size_t parsing_length, text_info ti) = 0; 29 | }; 30 | 31 | template 32 | class true_p_writer : public base_p_writer { 33 | public: 34 | compressed_file write(const std::vector &sol, size_t parsing_length, text_info ti) 35 | { 36 | return write_parsing(sol, parsing_length, ti); 37 | } 38 | }; 39 | 40 | class w_fact { 41 | public: 42 | template 43 | std::unique_ptr get_instance() const 44 | { 45 | return make_unique>(); 46 | } 47 | }; 48 | 49 | compressed_file write_parsing(const std::vector &sol, text_info ti, std::string encoder_name, cost_model space_cm) 50 | { 51 | // (1) get parsing length 52 | auto p_len = parsing_length(ITERS(sol), space_cm); 53 | // (2) get writer object 54 | w_fact fact; 55 | auto w_obj = encoders_().instantiate(encoder_name, fact); 56 | // (3) return parsing 57 | return w_obj->write(sol, p_len, ti); 58 | } 59 | 60 | compressed_file write_parsing(const std::vector &sol, text_info ti, std::string encoder_name) 61 | { 62 | cost_model space_cm = encoders_().get_cm(encoder_name); 63 | return write_parsing(sol, ti, encoder_name, space_cm); 64 | } 65 | 66 | void write_parsing( 67 | std::string enc_name, const std::vector &sol, size_t parsing_length, text_info ti, byte *output 68 | ) 69 | { 70 | generic_parsing_writer func(sol, parsing_length, ti, output); 71 | encoders_().call(enc_name, func); 72 | } -------------------------------------------------------------------------------- /list_gens.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include "list_gens.hpp" 18 | #include "generators.hpp" 19 | 20 | void list_generators() 21 | { 22 | std::vector names; 23 | generators_().get_names(names); 24 | for (auto i : names) { 25 | std::cout << i << std::endl; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | namespace { 34 | 35 | void error_message(const char *message) 36 | { 37 | std::cerr << "ERROR: " << message << std::endl; 38 | } 39 | 40 | } 41 | 42 | int main(int argc, char *argv[]) 43 | { 44 | // List of commands 45 | const char *compress = "compress", *decompress = "decompress", 46 | *bit_optimal = "bit-optimal", *encoders = "encoders", *fsgs = "gens"; 47 | // Manage the command-line options 48 | if (argc < 2) { 49 | error_message("Must specify a command"); 50 | std::cerr << "Commands:\n"; 51 | std::cerr << compress << "\t" << decompress << "\t" << bit_optimal << "\t" << encoders << "\t" << fsgs << std::endl; 52 | return 0; 53 | } 54 | 55 | char *command = argv[1]; 56 | try { 57 | if (strcmp(command, compress) == 0) { 58 | bicriteria_compress(command, argc, argv); 59 | } else if (strcmp(command, decompress) == 0) { 60 | decompress_file(command, argc, argv); 61 | } else if (strcmp(command, bit_optimal) == 0) { 62 | bit_compress(bit_optimal, argc, argv); 63 | } else if (strcmp(command, encoders) == 0) { 64 | list_encoders(); 65 | } else if (strcmp(command, fsgs) == 0){ 66 | list_generators(); 67 | } else { 68 | error_message("Invalid command"); 69 | std::cerr << "Commands:\n"; 70 | std::cerr << compress << "\t" << decompress << "\t" << bit_optimal << "\t" << encoders << "\t" << fsgs << std::endl; 71 | } 72 | } catch (cmd_error &e) { 73 | std::stringstream what; 74 | what << "Tool " << command << " wrongly invoked" << std::endl; 75 | what << e.cmd_usage() << std::endl; 76 | error_message(what.str().c_str()); 77 | } catch (std::logic_error &e) { 78 | std::cout << "LOGIC ERROR while processing." << std::endl; 79 | std::cout << "Cause: " << e.what() << std::endl; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /models/delta-L0.mod: -------------------------------------------------------------------------------- 1 | 1 1 2 | 3 4 3 | 7 5 4 | 15 8 5 | 31 9 6 | 63 10 7 | 127 11 8 | 255 14 9 | 511 15 10 | 1023 16 11 | 2047 17 12 | 4095 18 13 | 8191 19 14 | 16383 20 15 | 32767 21 16 | 65535 24 17 | 131071 25 18 | 262143 26 19 | 524287 27 20 | 1048575 28 21 | 2097151 29 22 | 4194303 30 23 | 8388607 31 24 | 16777215 32 25 | 33554431 33 26 | 67108863 34 27 | 134217727 35 28 | 268435455 36 29 | 536870911 37 30 | 1073741823 38 31 | 2147483647 39 32 | 4294967295 42 33 | 8589934591 43 34 | 35 | 1 1 36 | 3 4 37 | 7 5 38 | 15 8 39 | 31 9 40 | 63 10 41 | 127 11 42 | 255 14 43 | 511 15 44 | 1023 16 45 | 2047 17 46 | 4095 18 47 | 8191 19 48 | 16383 20 49 | 32767 21 50 | 65535 24 51 | 131071 25 52 | 262143 26 53 | 524287 27 54 | 1048575 28 55 | 2097151 29 56 | 4194303 30 57 | 8388607 31 58 | 16777215 32 59 | 33554431 33 60 | 67108863 34 61 | 134217727 35 62 | 268435455 36 63 | 536870911 37 64 | 1073741823 38 65 | 2147483647 39 66 | 4294967295 42 67 | 8589934591 43 68 | 69 | 1 70 | 32 71 | 8 72 | -------------------------------------------------------------------------------- /models/delta-L16.mod: -------------------------------------------------------------------------------- 1 | 1 1 2 | 3 4 3 | 7 5 4 | 15 8 5 | 31 9 6 | 63 10 7 | 127 11 8 | 255 14 9 | 511 15 10 | 1023 16 11 | 2047 17 12 | 4095 18 13 | 8191 19 14 | 16383 20 15 | 32767 21 16 | 65535 24 17 | 131071 25 18 | 262143 26 19 | 524287 27 20 | 1048575 28 21 | 2097151 29 22 | 4194303 30 23 | 8388607 31 24 | 16777215 32 25 | 33554431 33 26 | 67108863 34 27 | 134217727 35 28 | 268435455 36 29 | 536870911 37 30 | 1073741823 38 31 | 2147483647 39 32 | 4294967295 42 33 | 8589934591 43 34 | 35 | 1 1 36 | 3 4 37 | 7 5 38 | 15 8 39 | 31 9 40 | 63 10 41 | 127 11 42 | 255 14 43 | 511 15 44 | 1023 16 45 | 2047 17 46 | 4095 18 47 | 8191 19 48 | 16383 20 49 | 32767 21 50 | 65535 24 51 | 131071 25 52 | 262143 26 53 | 524287 27 54 | 1048575 28 55 | 2097151 29 56 | 4194303 30 57 | 8388607 31 58 | 16777215 32 59 | 33554431 33 60 | 67108863 34 61 | 134217727 35 62 | 268435455 36 63 | 536870911 37 64 | 1073741823 38 65 | 2147483647 39 66 | 4294967295 42 67 | 8589934591 43 68 | 69 | 65536 70 | 40 71 | 8 72 | -------------------------------------------------------------------------------- /models/delta-L8.mod: -------------------------------------------------------------------------------- 1 | 1 1 2 | 3 4 3 | 7 5 4 | 15 8 5 | 31 9 6 | 63 10 7 | 127 11 8 | 255 14 9 | 511 15 10 | 1023 16 11 | 2047 17 12 | 4095 18 13 | 8191 19 14 | 16383 20 15 | 32767 21 16 | 65535 24 17 | 131071 25 18 | 262143 26 19 | 524287 27 20 | 1048575 28 21 | 2097151 29 22 | 4194303 30 23 | 8388607 31 24 | 16777215 32 25 | 33554431 33 26 | 67108863 34 27 | 134217727 35 28 | 268435455 36 29 | 536870911 37 30 | 1073741823 38 31 | 2147483647 39 32 | 4294967295 42 33 | 8589934591 43 34 | 35 | 1 1 36 | 3 4 37 | 7 5 38 | 15 8 39 | 31 9 40 | 63 10 41 | 127 11 42 | 255 14 43 | 511 15 44 | 1023 16 45 | 2047 17 46 | 4095 18 47 | 8191 19 48 | 16383 20 49 | 32767 21 50 | 65535 24 51 | 131071 25 52 | 262143 26 53 | 524287 27 54 | 1048575 28 55 | 2097151 29 56 | 4194303 30 57 | 8388607 31 58 | 16777215 32 59 | 33554431 33 60 | 67108863 34 61 | 134217727 35 62 | 268435455 36 63 | 536870911 37 64 | 1073741823 38 65 | 2147483647 39 66 | 4294967295 42 67 | 8589934591 43 68 | 69 | 256 70 | 40 71 | 8 72 | -------------------------------------------------------------------------------- /models/gamma-L0.mod: -------------------------------------------------------------------------------- 1 | 2 1 2 | 4 3 3 | 8 5 4 | 16 7 5 | 32 9 6 | 64 11 7 | 128 13 8 | 256 15 9 | 512 17 10 | 1024 19 11 | 2048 21 12 | 4096 23 13 | 8192 25 14 | 16384 27 15 | 32768 29 16 | 65536 31 17 | 131072 33 18 | 262144 35 19 | 524288 37 20 | 1048576 39 21 | 2097152 41 22 | 4194304 43 23 | 8388608 45 24 | 16777216 47 25 | 33554432 49 26 | 67108864 51 27 | 134217728 53 28 | 268435456 55 29 | 536870912 57 30 | 1073741824 59 31 | 2147483648 61 32 | 4294967296 63 33 | 34 | 2 1 35 | 4 3 36 | 8 5 37 | 16 7 38 | 32 9 39 | 64 11 40 | 128 13 41 | 256 15 42 | 512 17 43 | 1024 19 44 | 2048 21 45 | 4096 23 46 | 8192 25 47 | 16384 27 48 | 32768 29 49 | 65536 31 50 | 131072 33 51 | 262144 35 52 | 524288 37 53 | 1048576 39 54 | 2097152 41 55 | 4194304 43 56 | 8388608 45 57 | 16777216 47 58 | 33554432 49 59 | 67108864 51 60 | 134217728 53 61 | 268435456 55 62 | 536870912 57 63 | 1073741824 59 64 | 2147483648 61 65 | 4294967296 63 66 | 67 | 1 68 | 32 69 | 8 70 | -------------------------------------------------------------------------------- /models/gamma-L16.mod: -------------------------------------------------------------------------------- 1 | 2 1 2 | 4 3 3 | 8 5 4 | 16 7 5 | 32 9 6 | 64 11 7 | 128 13 8 | 256 15 9 | 512 17 10 | 1024 19 11 | 2048 21 12 | 4096 23 13 | 8192 25 14 | 16384 27 15 | 32768 29 16 | 65536 31 17 | 131072 33 18 | 262144 35 19 | 524288 37 20 | 1048576 39 21 | 2097152 41 22 | 4194304 43 23 | 8388608 45 24 | 16777216 47 25 | 33554432 49 26 | 67108864 51 27 | 134217728 53 28 | 268435456 55 29 | 536870912 57 30 | 1073741824 59 31 | 2147483648 61 32 | 4294967296 63 33 | 34 | 2 1 35 | 4 3 36 | 8 5 37 | 16 7 38 | 32 9 39 | 64 11 40 | 128 13 41 | 256 15 42 | 512 17 43 | 1024 19 44 | 2048 21 45 | 4096 23 46 | 8192 25 47 | 16384 27 48 | 32768 29 49 | 65536 31 50 | 131072 33 51 | 262144 35 52 | 524288 37 53 | 1048576 39 54 | 2097152 41 55 | 4194304 43 56 | 8388608 45 57 | 16777216 47 58 | 33554432 49 59 | 67108864 51 60 | 134217728 53 61 | 268435456 55 62 | 536870912 57 63 | 1073741824 59 64 | 2147483648 61 65 | 4294967296 63 66 | 67 | 65536 68 | 48 69 | 8 70 | -------------------------------------------------------------------------------- /models/gamma-L8.mod: -------------------------------------------------------------------------------- 1 | 2 1 2 | 4 3 3 | 8 5 4 | 16 7 5 | 32 9 6 | 64 11 7 | 128 13 8 | 256 15 9 | 512 17 10 | 1024 19 11 | 2048 21 12 | 4096 23 13 | 8192 25 14 | 16384 27 15 | 32768 29 16 | 65536 31 17 | 131072 33 18 | 262144 35 19 | 524288 37 20 | 1048576 39 21 | 2097152 41 22 | 4194304 43 23 | 8388608 45 24 | 16777216 47 25 | 33554432 49 26 | 67108864 51 27 | 134217728 53 28 | 268435456 55 29 | 536870912 57 30 | 1073741824 59 31 | 2147483648 61 32 | 4294967296 63 33 | 34 | 2 1 35 | 4 3 36 | 8 5 37 | 16 7 38 | 32 9 39 | 64 11 40 | 128 13 41 | 256 15 42 | 512 17 43 | 1024 19 44 | 2048 21 45 | 4096 23 46 | 8192 25 47 | 16384 27 48 | 32768 29 49 | 65536 31 50 | 131072 33 51 | 262144 35 52 | 524288 37 53 | 1048576 39 54 | 2097152 41 55 | 4194304 43 56 | 8388608 45 57 | 16777216 47 58 | 33554432 49 59 | 67108864 51 60 | 134217728 53 61 | 268435456 55 62 | 536870912 57 63 | 1073741824 59 64 | 2147483648 61 65 | 4294967296 63 66 | 67 | 256 68 | 40 69 | 8 70 | -------------------------------------------------------------------------------- /models/hybrid.mod: -------------------------------------------------------------------------------- 1 | 64 8 2 | 16384 16 3 | 4194304 24 4 | 1073741824 32 5 | 6 | 128 8 7 | 32768 16 8 | 9 | 1 10 | 40 11 | 0 12 | -------------------------------------------------------------------------------- /models/nibble4-L0.mod: -------------------------------------------------------------------------------- 1 | 8 4 2 | 72 8 3 | 584 12 4 | 4680 16 5 | 37448 20 6 | 299592 24 7 | 2396744 28 8 | 19173960 32 9 | 153391688 36 10 | 1227133512 40 11 | 9817068104 44 12 | 13 | 8 4 14 | 72 8 15 | 584 12 16 | 4680 16 17 | 37448 20 18 | 299592 24 19 | 2396744 28 20 | 19173960 32 21 | 153391688 36 22 | 1227133512 40 23 | 9817068104 44 24 | 25 | 1 26 | 32 27 | 8 28 | -------------------------------------------------------------------------------- /models/nibble4-L16.mod: -------------------------------------------------------------------------------- 1 | 8 4 2 | 72 8 3 | 584 12 4 | 4680 16 5 | 37448 20 6 | 299592 24 7 | 2396744 28 8 | 19173960 32 9 | 153391688 36 10 | 1227133512 40 11 | 9817068104 44 12 | 13 | 8 4 14 | 72 8 15 | 584 12 16 | 4680 16 17 | 37448 20 18 | 299592 24 19 | 2396744 28 20 | 19173960 32 21 | 153391688 36 22 | 1227133512 40 23 | 9817068104 44 24 | 25 | 65536 26 | 48 27 | 8 28 | -------------------------------------------------------------------------------- /models/nibble4-L8.mod: -------------------------------------------------------------------------------- 1 | 8 4 2 | 72 8 3 | 584 12 4 | 4680 16 5 | 37448 20 6 | 299592 24 7 | 2396744 28 8 | 19173960 32 9 | 153391688 36 10 | 1227133512 40 11 | 9817068104 44 12 | 13 | 8 4 14 | 72 8 15 | 584 12 16 | 4680 16 17 | 37448 20 18 | 299592 24 19 | 2396744 28 20 | 19173960 32 21 | 153391688 36 22 | 1227133512 40 23 | 9817068104 44 24 | 25 | 256 26 | 40 27 | 8 28 | -------------------------------------------------------------------------------- /models/nibble8-L0.mod: -------------------------------------------------------------------------------- 1 | 128 8 2 | 16512 16 3 | 2113664 24 4 | 270549120 32 5 | 34630287488 40 6 | 7 | 128 8 8 | 16512 16 9 | 2113664 24 10 | 270549120 32 11 | 34630287488 40 12 | 13 | 1 14 | 32 15 | 8 16 | -------------------------------------------------------------------------------- /models/nibble8-L16.mod: -------------------------------------------------------------------------------- 1 | 128 8 2 | 16512 16 3 | 2113664 24 4 | 270549120 32 5 | 34630287488 40 6 | 7 | 128 8 8 | 16512 16 9 | 2113664 24 10 | 270549120 32 11 | 34630287488 40 12 | 13 | 65536 14 | 48 15 | 8 16 | -------------------------------------------------------------------------------- /models/nibble8-L8.mod: -------------------------------------------------------------------------------- 1 | 128 8 2 | 16512 16 3 | 2113664 24 4 | 270549120 32 5 | 34630287488 40 6 | 7 | 128 8 8 | 16512 16 9 | 2113664 24 10 | 270549120 32 11 | 34630287488 40 12 | 13 | 256 14 | 40 15 | 8 16 | -------------------------------------------------------------------------------- /models/soda09-L0.mod: -------------------------------------------------------------------------------- 1 | 16384 15 2 | 278528 20 3 | 2375680 24 4 | 19152896 28 5 | 153370624 32 6 | 1227112448 36 7 | 8 | 8 4 9 | 16 5 10 | 24 6 11 | 32 7 12 | 48 9 13 | 64 10 14 | 80 11 15 | 112 13 16 | 176 15 17 | 304 17 18 | 560 19 19 | 1072 21 20 | 2096 23 21 | 4144 25 22 | 1052720 35 23 | 24 | 1 25 | 32 26 | 8 27 | -------------------------------------------------------------------------------- /models/soda09-L16.mod: -------------------------------------------------------------------------------- 1 | 16384 15 2 | 278528 20 3 | 2375680 24 4 | 19152896 28 5 | 153370624 32 6 | 1227112448 36 7 | 8 | 8 4 9 | 16 5 10 | 24 6 11 | 32 7 12 | 48 9 13 | 64 10 14 | 80 11 15 | 112 13 16 | 176 15 17 | 304 17 18 | 560 19 19 | 1072 21 20 | 2096 23 21 | 4144 25 22 | 1052720 35 23 | 24 | 65536 25 | 48 26 | 8 27 | -------------------------------------------------------------------------------- /models/soda09-L8.mod: -------------------------------------------------------------------------------- 1 | 16384 15 2 | 278528 20 3 | 2375680 24 4 | 19152896 28 5 | 153370624 32 6 | 1227112448 36 7 | 8 | 8 4 9 | 16 5 10 | 24 6 11 | 32 7 12 | 48 9 13 | 64 10 14 | 80 11 15 | 112 13 16 | 176 15 17 | 304 17 18 | 560 19 19 | 1072 21 20 | 2096 23 21 | 4144 25 22 | 1052720 35 23 | 24 | 256 25 | 40 26 | 8 27 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # **bc-zip** - Bicriteria Data Compressor 2 | 3 | ## Introduction 4 | 5 | *bc-zip* is a lossless, general-purpose, *optimizing* data compressor. 6 | 7 | It can be used to compress a file in order to achieve the *best* compression ratio. More technically, bc-zip computes the most succinct Lempel-Ziv parsing, which is the same scheme used by gzip, Snappy, LZO, and LZ4. It goes without saying that compressed files are considerably smaller when compressed with bc-zip than with the aforementioned compressors. 8 | 9 | Moreover, and more importantly, bc-zip can be used to obtain a compressed file such that the *decompression time is below a user-specified time and the compression ratio is maximized*, and the other way round (compression size bounded, decompression speed maximized). In this way, it is possible to achieve very good compression ratios *and* decompression speeds comparable or better than those achieved by state-of-the-art compressors Snappy and LZ4. Even better, it is possible to specify the decompression speed dictated by your application requirements, and let bc-zip automatically achieve the highest compression ratio with that constraint. 10 | 11 | This is achieved through an innovative way of modeling data compression as an optimization problem, along with the use of a decompression time model which accurately estimates the decompression time of a compressed file. 12 | 13 | Have a look at the [dedicated website](http://farruggia.github.io/bc-zip/) for compiling and usage instructions and more information about the bicriteria technology. 14 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Google Test 2 | add_subdirectory("ext_libs/gtest-1.7.0") 3 | 4 | # Test include directories 5 | include_directories("${gtest_SOURCE_DIR}/include" "${gtest_SOURCE_DIR}" "./include") 6 | 7 | # Google test executables 8 | add_executable(fsg_check fsg_check.cpp) 9 | add_dependencies(fsg_check googletest) 10 | m_link(fsg_check gtest bcobjs divsufsort) 11 | 12 | add_executable(encoder_tests encoder_tests.cpp) 13 | add_dependencies(encoder_tests googletest) 14 | m_link(encoder_tests bcobjs gtest) 15 | 16 | add_executable(api_test api_test.cpp) 17 | add_dependencies(api_test googletest) 18 | m_link(api_test bcobjs gtest divsufsort) 19 | 20 | add_executable(graph_cacher graph_cacher.cpp) 21 | add_dependencies(graph_cacher googletest) 22 | m_link(graph_cacher bcobjs gtest gtest_main divsufsort) 23 | 24 | # Register them as tests 25 | add_test(Encoder encoder_tests) 26 | add_test(Cacher graph_cacher test_file test_model) 27 | set_tests_properties(Cacher PROPERTIES REQUIRED_FILES "test_file;test_model.tmod") 28 | add_test(API api_test test_file) 29 | set_tests_properties(API PROPERTIES REQUIRED_FILES "test_file") 30 | 31 | add_executable(model_read_test model_read_test.cpp) 32 | m_link(model_read_test bcobjs divsufsort) 33 | 34 | add_executable(solution_getter_test solution_getter_test.cpp) 35 | m_link(solution_getter_test bcobjs gtest divsufsort) 36 | 37 | add_executable(fast_solution_integrator fast_solution_integrator.cpp) 38 | m_link(fast_solution_integrator bcobjs gtest divsufsort) 39 | 40 | add_executable(cost_model_id cost_model_id.cpp) 41 | m_link(cost_model_id bcobjs gtest divsufsort) 42 | 43 | add_executable(swapper_test swapper_test.cpp) 44 | m_link(swapper_test bcobjs gtest divsufsort) 45 | -------------------------------------------------------------------------------- /tests/cost_model_id.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | // TEST //////////////////////////////////////////////////////////////////////////////////////////////////////////////// 30 | class cost_model_id : public ::testing::Test { 31 | protected: 32 | 33 | static void SetUpTestCase() 34 | { 35 | 36 | } 37 | 38 | virtual void SetUp() 39 | { 40 | 41 | } 42 | 43 | public: 44 | static cm_factory cm_fact; 45 | 46 | static void set_cm(cost_model cm_, cost_model w_cm_) 47 | { 48 | cm_fact = cm_factory(cm_, w_cm_); 49 | } 50 | 51 | }; 52 | 53 | cm_factory cost_model_id::cm_fact; 54 | 55 | TEST_F(cost_model_id, all) 56 | { 57 | auto sha_cost = cm_fact.cost().id(); 58 | auto sha_weight = cm_fact.weight().id(); 59 | auto sha_l1 = cm_fact.lambda(1.0).id(); 60 | auto sha_l2 = cm_fact.lambda(2.0).id(); 61 | auto sha_l11 = cm_fact.lambda(1.0).id(); 62 | 63 | ASSERT_EQ(sha_l1, sha_l11); 64 | ASSERT_NE(sha_cost, sha_weight); 65 | ASSERT_NE(sha_cost, sha_l1); 66 | ASSERT_NE(sha_cost, sha_l2); 67 | ASSERT_NE(sha_cost, sha_l11); 68 | ASSERT_NE(sha_weight, sha_l1); 69 | ASSERT_NE(sha_weight, sha_l2); 70 | ASSERT_NE(sha_weight, sha_l11); 71 | ASSERT_NE(sha_l1, sha_l2); 72 | ASSERT_NE(sha_l2, sha_l11); 73 | 74 | ASSERT_EQ(sha_cost, cm_fact.cost().id()); 75 | ASSERT_EQ(cost_model().id(), ""); 76 | } 77 | 78 | 79 | int main(int argc, char **argv) 80 | { 81 | ::testing::InitGoogleTest(&argc, argv); 82 | if (argc < 3) { 83 | std::cerr << "ERROR: target file, encoder" << std::endl; 84 | exit(1); 85 | } 86 | char *target_file = *++argv; 87 | char *encoder_name = *++argv; 88 | cost_model cost = encoders_().get_cm(encoder_name); 89 | cost_model weight = get_wm(target_file, encoder_name); 90 | cost_model_id::set_cm(cost, weight); 91 | return RUN_ALL_TESTS(); 92 | } -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file contains a list of people who've made non-trivial 2 | # contribution to the Google C++ Testing Framework project. People 3 | # who commit code to the project are encouraged to add their names 4 | # here. Please keep the list sorted by first names. 5 | 6 | Ajay Joshi 7 | Balázs Dán 8 | Bharat Mediratta 9 | Chandler Carruth 10 | Chris Prince 11 | Chris Taylor 12 | Dan Egnor 13 | Eric Roman 14 | Hady Zalek 15 | Jeffrey Yasskin 16 | Jói Sigurðsson 17 | Keir Mierle 18 | Keith Ray 19 | Kenton Varda 20 | Manuel Klimek 21 | Markus Heule 22 | Mika Raento 23 | Miklós Fazekas 24 | Pasi Valminen 25 | Patrick Hanna 26 | Patrick Riley 27 | Peter Kaminski 28 | Preston Jackson 29 | Rainer Klaffenboeck 30 | Russ Cox 31 | Russ Rufer 32 | Sean Mcafee 33 | Sigurður Ásgeirsson 34 | Tracy Bialik 35 | Vadim Berman 36 | Vlad Losev 37 | Zhanyong Wan 38 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/build-aux/config.h.in: -------------------------------------------------------------------------------- 1 | /* build-aux/config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_DLFCN_H 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_INTTYPES_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_MEMORY_H 11 | 12 | /* Define if you have POSIX threads libraries and header files. */ 13 | #undef HAVE_PTHREAD 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_STDINT_H 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_STDLIB_H 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_STRINGS_H 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_STRING_H 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_SYS_STAT_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_SYS_TYPES_H 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_UNISTD_H 35 | 36 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 37 | */ 38 | #undef LT_OBJDIR 39 | 40 | /* Name of package */ 41 | #undef PACKAGE 42 | 43 | /* Define to the address where bug reports for this package should be sent. */ 44 | #undef PACKAGE_BUGREPORT 45 | 46 | /* Define to the full name of this package. */ 47 | #undef PACKAGE_NAME 48 | 49 | /* Define to the full name and version of this package. */ 50 | #undef PACKAGE_STRING 51 | 52 | /* Define to the one symbol short name of this package. */ 53 | #undef PACKAGE_TARNAME 54 | 55 | /* Define to the home page for this package. */ 56 | #undef PACKAGE_URL 57 | 58 | /* Define to the version of this package. */ 59 | #undef PACKAGE_VERSION 60 | 61 | /* Define to necessary symbol if this constant uses a non-standard name on 62 | your system. */ 63 | #undef PTHREAD_CREATE_JOINABLE 64 | 65 | /* Define to 1 if you have the ANSI C header files. */ 66 | #undef STDC_HEADERS 67 | 68 | /* Version number of package */ 69 | #undef VERSION 70 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/codegear/gtest.groupproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {c1d923e0-6cba-4332-9b6f-3420acbf5091} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Default.Personality 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/codegear/gtest_all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: Josh Kelley (joshkel@gmail.com) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // C++Builder's IDE cannot build a static library from files with hyphens 35 | // in their name. See http://qc.codegear.com/wc/qcmain.aspx?d=70977 . 36 | // This file serves as a workaround. 37 | 38 | #include "src/gtest-all.cc" 39 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/codegear/gtest_link.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: Josh Kelley (joshkel@gmail.com) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // Links gtest.lib and gtest_main.lib into the current project in C++Builder. 35 | // This means that these libraries can't be renamed, but it's the only way to 36 | // ensure that Debug versus Release test builds are linked against the 37 | // appropriate Debug or Release build of the libraries. 38 | 39 | #pragma link "gtest.lib" 40 | #pragma link "gtest_main.lib" 41 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/configure.ac: -------------------------------------------------------------------------------- 1 | m4_include(m4/acx_pthread.m4) 2 | 3 | # At this point, the Xcode project assumes the version string will be three 4 | # integers separated by periods and surrounded by square brackets (e.g. 5 | # "[1.0.1]"). It also asumes that there won't be any closing parenthesis 6 | # between "AC_INIT(" and the closing ")" including comments and strings. 7 | AC_INIT([Google C++ Testing Framework], 8 | [1.7.0], 9 | [googletestframework@googlegroups.com], 10 | [gtest]) 11 | 12 | # Provide various options to initialize the Autoconf and configure processes. 13 | AC_PREREQ([2.59]) 14 | AC_CONFIG_SRCDIR([./LICENSE]) 15 | AC_CONFIG_MACRO_DIR([m4]) 16 | AC_CONFIG_AUX_DIR([build-aux]) 17 | AC_CONFIG_HEADERS([build-aux/config.h]) 18 | AC_CONFIG_FILES([Makefile]) 19 | AC_CONFIG_FILES([scripts/gtest-config], [chmod +x scripts/gtest-config]) 20 | 21 | # Initialize Automake with various options. We require at least v1.9, prevent 22 | # pedantic complaints about package files, and enable various distribution 23 | # targets. 24 | AM_INIT_AUTOMAKE([1.9 dist-bzip2 dist-zip foreign subdir-objects]) 25 | 26 | # Check for programs used in building Google Test. 27 | AC_PROG_CC 28 | AC_PROG_CXX 29 | AC_LANG([C++]) 30 | AC_PROG_LIBTOOL 31 | 32 | # TODO(chandlerc@google.com): Currently we aren't running the Python tests 33 | # against the interpreter detected by AM_PATH_PYTHON, and so we condition 34 | # HAVE_PYTHON by requiring "python" to be in the PATH, and that interpreter's 35 | # version to be >= 2.3. This will allow the scripts to use a "/usr/bin/env" 36 | # hashbang. 37 | PYTHON= # We *do not* allow the user to specify a python interpreter 38 | AC_PATH_PROG([PYTHON],[python],[:]) 39 | AS_IF([test "$PYTHON" != ":"], 40 | [AM_PYTHON_CHECK_VERSION([$PYTHON],[2.3],[:],[PYTHON=":"])]) 41 | AM_CONDITIONAL([HAVE_PYTHON],[test "$PYTHON" != ":"]) 42 | 43 | # Configure pthreads. 44 | AC_ARG_WITH([pthreads], 45 | [AS_HELP_STRING([--with-pthreads], 46 | [use pthreads (default is yes)])], 47 | [with_pthreads=$withval], 48 | [with_pthreads=check]) 49 | 50 | have_pthreads=no 51 | AS_IF([test "x$with_pthreads" != "xno"], 52 | [ACX_PTHREAD( 53 | [], 54 | [AS_IF([test "x$with_pthreads" != "xcheck"], 55 | [AC_MSG_FAILURE( 56 | [--with-pthreads was specified, but unable to be used])])]) 57 | have_pthreads="$acx_pthread_ok"]) 58 | AM_CONDITIONAL([HAVE_PTHREADS],[test "x$have_pthreads" = "xyes"]) 59 | AC_SUBST(PTHREAD_CFLAGS) 60 | AC_SUBST(PTHREAD_LIBS) 61 | 62 | # TODO(chandlerc@google.com) Check for the necessary system headers. 63 | 64 | # TODO(chandlerc@google.com) Check the types, structures, and other compiler 65 | # and architecture characteristics. 66 | 67 | # Output the generated files. No further autoconf macros may be used. 68 | AC_OUTPUT 69 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/fused-src/gtest/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 | 32 | #include "gtest/gtest.h" 33 | 34 | GTEST_API_ int main(int argc, char **argv) { 35 | printf("Running main() from gtest_main.cc\n"); 36 | testing::InitGoogleTest(&argc, argv); 37 | return RUN_ALL_TESTS(); 38 | } 39 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/include/gtest/gtest_prod.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Google C++ Testing Framework definitions useful in production code. 33 | 34 | #ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 35 | #define GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 36 | 37 | // When you need to test the private or protected members of a class, 38 | // use the FRIEND_TEST macro to declare your tests as friends of the 39 | // class. For example: 40 | // 41 | // class MyClass { 42 | // private: 43 | // void MyMethod(); 44 | // FRIEND_TEST(MyClassTest, MyMethod); 45 | // }; 46 | // 47 | // class MyClassTest : public testing::Test { 48 | // // ... 49 | // }; 50 | // 51 | // TEST_F(MyClassTest, MyMethod) { 52 | // // Can call MyClass::MyMethod() here. 53 | // } 54 | 55 | #define FRIEND_TEST(test_case_name, test_name)\ 56 | friend class test_case_name##_##test_name##_Test 57 | 58 | #endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 59 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 3337 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.2]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3337]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.2' 20 | macro_revision='1.3337' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/msvc/gtest-md.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest-md", "gtest-md.vcproj", "{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_main-md", "gtest_main-md.vcproj", "{3AF54C8A-10BF-4332-9147-F68ED9862033}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_prod_test-md", "gtest_prod_test-md.vcproj", "{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | EndProjectSection 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_unittest-md", "gtest_unittest-md.vcproj", "{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}" 15 | ProjectSection(ProjectDependencies) = postProject 16 | EndProjectSection 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfiguration) = preSolution 20 | Debug = Debug 21 | Release = Release 22 | EndGlobalSection 23 | GlobalSection(ProjectConfiguration) = postSolution 24 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.ActiveCfg = Debug|Win32 25 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.Build.0 = Debug|Win32 26 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.ActiveCfg = Release|Win32 27 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.Build.0 = Release|Win32 28 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.ActiveCfg = Debug|Win32 29 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.Build.0 = Debug|Win32 30 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.ActiveCfg = Release|Win32 31 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.Build.0 = Release|Win32 32 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.ActiveCfg = Debug|Win32 33 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.Build.0 = Debug|Win32 34 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.ActiveCfg = Release|Win32 35 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.Build.0 = Release|Win32 36 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.ActiveCfg = Debug|Win32 37 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.Build.0 = Debug|Win32 38 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.ActiveCfg = Release|Win32 39 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.Build.0 = Release|Win32 40 | EndGlobalSection 41 | GlobalSection(ExtensibilityGlobals) = postSolution 42 | EndGlobalSection 43 | GlobalSection(ExtensibilityAddIns) = postSolution 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/msvc/gtest.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest", "gtest.vcproj", "{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_main", "gtest_main.vcproj", "{3AF54C8A-10BF-4332-9147-F68ED9862032}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_unittest", "gtest_unittest.vcproj", "{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | EndProjectSection 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_prod_test", "gtest_prod_test.vcproj", "{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}" 15 | ProjectSection(ProjectDependencies) = postProject 16 | EndProjectSection 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfiguration) = preSolution 20 | Debug = Debug 21 | Release = Release 22 | EndGlobalSection 23 | GlobalSection(ProjectConfiguration) = postSolution 24 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.ActiveCfg = Debug|Win32 25 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.Build.0 = Debug|Win32 26 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.ActiveCfg = Release|Win32 27 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.Build.0 = Release|Win32 28 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.ActiveCfg = Debug|Win32 29 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.Build.0 = Debug|Win32 30 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.ActiveCfg = Release|Win32 31 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.Build.0 = Release|Win32 32 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.ActiveCfg = Debug|Win32 33 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.Build.0 = Debug|Win32 34 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.ActiveCfg = Release|Win32 35 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.Build.0 = Release|Win32 36 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.ActiveCfg = Debug|Win32 37 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.Build.0 = Debug|Win32 38 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.ActiveCfg = Release|Win32 39 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.Build.0 = Release|Win32 40 | EndGlobalSection 41 | GlobalSection(ExtensibilityGlobals) = postSolution 42 | EndGlobalSection 43 | GlobalSection(ExtensibilityAddIns) = postSolution 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/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 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #include "sample1.h" 35 | 36 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1. 37 | int Factorial(int n) { 38 | int result = 1; 39 | for (int i = 1; i <= n; i++) { 40 | result *= i; 41 | } 42 | 43 | return result; 44 | } 45 | 46 | // Returns true iff n is a prime number. 47 | bool IsPrime(int n) { 48 | // Trivial case 1: small numbers 49 | if (n <= 1) return false; 50 | 51 | // Trivial case 2: even numbers 52 | if (n % 2 == 0) return n == 2; 53 | 54 | // Now, we have that n is odd and n >= 3. 55 | 56 | // Try to divide n by every odd number i, starting from 3 57 | for (int i = 3; ; i += 2) { 58 | // We only have to try i up to the squre root of n 59 | if (i > n/i) break; 60 | 61 | // Now, we have i <= n/i < n. 62 | // If n is divisible by i, n is not prime. 63 | if (n % i == 0) return false; 64 | } 65 | 66 | // n has no integer factor in the range (1, n), and thus is prime. 67 | return true; 68 | } 69 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/samples/sample1.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #ifndef GTEST_SAMPLES_SAMPLE1_H_ 35 | #define GTEST_SAMPLES_SAMPLE1_H_ 36 | 37 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1. 38 | int Factorial(int n); 39 | 40 | // Returns true iff n is a prime number. 41 | bool IsPrime(int n); 42 | 43 | #endif // GTEST_SAMPLES_SAMPLE1_H_ 44 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/samples/sample2.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #include "sample2.h" 35 | 36 | #include 37 | 38 | // Clones a 0-terminated C string, allocating memory using new. 39 | const char* MyString::CloneCString(const char* a_c_string) { 40 | if (a_c_string == NULL) return NULL; 41 | 42 | const size_t len = strlen(a_c_string); 43 | char* const clone = new char[ len + 1 ]; 44 | memcpy(clone, a_c_string, len + 1); 45 | 46 | return clone; 47 | } 48 | 49 | // Sets the 0-terminated C string this MyString object 50 | // represents. 51 | void MyString::Set(const char* a_c_string) { 52 | // Makes sure this works when c_string == c_string_ 53 | const char* const temp = MyString::CloneCString(a_c_string); 54 | delete[] c_string_; 55 | c_string_ = temp; 56 | } 57 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/samples/sample4.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #include 35 | 36 | #include "sample4.h" 37 | 38 | // Returns the current counter value, and increments it. 39 | int Counter::Increment() { 40 | return counter_++; 41 | } 42 | 43 | // Prints the current counter value to STDOUT. 44 | void Counter::Print() const { 45 | printf("%d", counter_); 46 | } 47 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/samples/sample4.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #ifndef GTEST_SAMPLES_SAMPLE4_H_ 35 | #define GTEST_SAMPLES_SAMPLE4_H_ 36 | 37 | // A simple monotonic counter. 38 | class Counter { 39 | private: 40 | int counter_; 41 | 42 | public: 43 | // Creates a counter that starts at 0. 44 | Counter() : counter_(0) {} 45 | 46 | // Returns the current counter value, and increments it. 47 | int Increment(); 48 | 49 | // Prints the current counter value to STDOUT. 50 | void Print() const; 51 | }; 52 | 53 | #endif // GTEST_SAMPLES_SAMPLE4_H_ 54 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/samples/sample4_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | #include "sample4.h" 34 | 35 | // Tests the Increment() method. 36 | TEST(Counter, Increment) { 37 | Counter c; 38 | 39 | // EXPECT_EQ() evaluates its arguments exactly once, so they 40 | // can have side effects. 41 | 42 | EXPECT_EQ(0, c.Increment()); 43 | EXPECT_EQ(1, c.Increment()); 44 | EXPECT_EQ(2, c.Increment()); 45 | } 46 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/scripts/test/Makefile: -------------------------------------------------------------------------------- 1 | # A Makefile for fusing Google Test and building a sample test against it. 2 | # 3 | # SYNOPSIS: 4 | # 5 | # make [all] - makes everything. 6 | # make TARGET - makes the given target. 7 | # make check - makes everything and runs the built sample test. 8 | # make clean - removes all files generated by make. 9 | 10 | # Points to the root of fused Google Test, relative to where this file is. 11 | FUSED_GTEST_DIR = output 12 | 13 | # Paths to the fused gtest files. 14 | FUSED_GTEST_H = $(FUSED_GTEST_DIR)/gtest/gtest.h 15 | FUSED_GTEST_ALL_CC = $(FUSED_GTEST_DIR)/gtest/gtest-all.cc 16 | 17 | # Where to find the sample test. 18 | SAMPLE_DIR = ../../samples 19 | 20 | # Where to find gtest_main.cc. 21 | GTEST_MAIN_CC = ../../src/gtest_main.cc 22 | 23 | # Flags passed to the preprocessor. 24 | # We have no idea here whether pthreads is available in the system, so 25 | # disable its use. 26 | CPPFLAGS += -I$(FUSED_GTEST_DIR) -DGTEST_HAS_PTHREAD=0 27 | 28 | # Flags passed to the C++ compiler. 29 | CXXFLAGS += -g 30 | 31 | all : sample1_unittest 32 | 33 | check : all 34 | ./sample1_unittest 35 | 36 | clean : 37 | rm -rf $(FUSED_GTEST_DIR) sample1_unittest *.o 38 | 39 | $(FUSED_GTEST_H) : 40 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR) 41 | 42 | $(FUSED_GTEST_ALL_CC) : 43 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR) 44 | 45 | gtest-all.o : $(FUSED_GTEST_H) $(FUSED_GTEST_ALL_CC) 46 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(FUSED_GTEST_DIR)/gtest/gtest-all.cc 47 | 48 | gtest_main.o : $(FUSED_GTEST_H) $(GTEST_MAIN_CC) 49 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_MAIN_CC) 50 | 51 | sample1.o : $(SAMPLE_DIR)/sample1.cc $(SAMPLE_DIR)/sample1.h 52 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1.cc 53 | 54 | sample1_unittest.o : $(SAMPLE_DIR)/sample1_unittest.cc \ 55 | $(SAMPLE_DIR)/sample1.h $(FUSED_GTEST_H) 56 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1_unittest.cc 57 | 58 | sample1_unittest : sample1.o sample1_unittest.o gtest-all.o gtest_main.o 59 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@ 60 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/src/gtest-all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: mheule@google.com (Markus Heule) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // Sometimes it's desirable to build Google Test by compiling a single file. 35 | // This file serves this purpose. 36 | 37 | // This line ensures that gtest.h can be compiled on its own, even 38 | // when it's fused. 39 | #include "gtest/gtest.h" 40 | 41 | // The following lines pull in the real gtest *.cc files. 42 | #include "src/gtest.cc" 43 | #include "src/gtest-death-test.cc" 44 | #include "src/gtest-filepath.cc" 45 | #include "src/gtest-port.cc" 46 | #include "src/gtest-printers.cc" 47 | #include "src/gtest-test-part.cc" 48 | #include "src/gtest-typed-test.cc" 49 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/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 | 32 | #include "gtest/gtest.h" 33 | 34 | GTEST_API_ int main(int argc, char **argv) { 35 | printf("Running main() from gtest_main.cc\n"); 36 | testing::InitGoogleTest(&argc, argv); 37 | return RUN_ALL_TESTS(); 38 | } 39 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/test/gtest-param-test_test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Authors: vladl@google.com (Vlad Losev) 31 | // 32 | // The Google C++ Testing Framework (Google Test) 33 | // 34 | // This header file provides classes and functions used internally 35 | // for testing Google Test itself. 36 | 37 | #ifndef GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 38 | #define GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 39 | 40 | #include "gtest/gtest.h" 41 | 42 | #if GTEST_HAS_PARAM_TEST 43 | 44 | // Test fixture for testing definition and instantiation of a test 45 | // in separate translation units. 46 | class ExternalInstantiationTest : public ::testing::TestWithParam { 47 | }; 48 | 49 | // Test fixture for testing instantiation of a test in multiple 50 | // translation units. 51 | class InstantiationInMultipleTranslaionUnitsTest 52 | : public ::testing::TestWithParam { 53 | }; 54 | 55 | #endif // GTEST_HAS_PARAM_TEST 56 | 57 | #endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 58 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/test/gtest-typed-test2_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include 33 | 34 | #include "test/gtest-typed-test_test.h" 35 | #include "gtest/gtest.h" 36 | 37 | #if GTEST_HAS_TYPED_TEST_P 38 | 39 | // Tests that the same type-parameterized test case can be 40 | // instantiated in different translation units linked together. 41 | // (ContainerTest is also instantiated in gtest-typed-test_test.cc.) 42 | INSTANTIATE_TYPED_TEST_CASE_P(Vector, ContainerTest, 43 | testing::Types >); 44 | 45 | #endif // GTEST_HAS_TYPED_TEST_P 46 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/test/gtest-typed-test_test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #ifndef GTEST_TEST_GTEST_TYPED_TEST_TEST_H_ 33 | #define GTEST_TEST_GTEST_TYPED_TEST_TEST_H_ 34 | 35 | #include "gtest/gtest.h" 36 | 37 | #if GTEST_HAS_TYPED_TEST_P 38 | 39 | using testing::Test; 40 | 41 | // For testing that the same type-parameterized test case can be 42 | // instantiated in different translation units linked together. 43 | // ContainerTest will be instantiated in both gtest-typed-test_test.cc 44 | // and gtest-typed-test2_test.cc. 45 | 46 | template 47 | class ContainerTest : public Test { 48 | }; 49 | 50 | TYPED_TEST_CASE_P(ContainerTest); 51 | 52 | TYPED_TEST_P(ContainerTest, CanBeDefaultConstructed) { 53 | TypeParam container; 54 | } 55 | 56 | TYPED_TEST_P(ContainerTest, InitialSizeIsZero) { 57 | TypeParam container; 58 | EXPECT_EQ(0U, container.size()); 59 | } 60 | 61 | REGISTER_TYPED_TEST_CASE_P(ContainerTest, 62 | CanBeDefaultConstructed, InitialSizeIsZero); 63 | 64 | #endif // GTEST_HAS_TYPED_TEST_P 65 | 66 | #endif // GTEST_TEST_GTEST_TYPED_TEST_TEST_H_ 67 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/test/gtest_all_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Tests for Google C++ Testing Framework (Google Test) 33 | // 34 | // Sometimes it's desirable to build most of Google Test's own tests 35 | // by compiling a single file. This file serves this purpose. 36 | #include "test/gtest-filepath_test.cc" 37 | #include "test/gtest-linked_ptr_test.cc" 38 | #include "test/gtest-message_test.cc" 39 | #include "test/gtest-options_test.cc" 40 | #include "test/gtest-port_test.cc" 41 | #include "test/gtest_pred_impl_unittest.cc" 42 | #include "test/gtest_prod_test.cc" 43 | #include "test/gtest-test-part_test.cc" 44 | #include "test/gtest-typed-test_test.cc" 45 | #include "test/gtest-typed-test2_test.cc" 46 | #include "test/gtest_unittest.cc" 47 | #include "test/production.cc" 48 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/test/gtest_help_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | // This program is meant to be run by gtest_help_test.py. Do not run 33 | // it directly. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | // When a help flag is specified, this program should skip the tests 38 | // and exit with 0; otherwise the following test will be executed, 39 | // causing this program to exit with a non-zero code. 40 | TEST(HelpFlagTest, ShouldNotBeRun) { 41 | ASSERT_TRUE(false) << "Tests shouldn't be run when --help is specified."; 42 | } 43 | 44 | #if GTEST_HAS_DEATH_TEST 45 | TEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {} 46 | #endif 47 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/test/gtest_main_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | 34 | // Tests that we don't have to define main() when we link to 35 | // gtest_main instead of gtest. 36 | 37 | namespace { 38 | 39 | TEST(GTestMainTest, ShouldSucceed) { 40 | } 41 | 42 | } // namespace 43 | 44 | // We are using the main() function defined in src/gtest_main.cc, so 45 | // we don't define it here. 46 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/test/gtest_no_test_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Tests that a Google Test program that has no test defined can run 31 | // successfully. 32 | // 33 | // Author: wan@google.com (Zhanyong Wan) 34 | 35 | #include "gtest/gtest.h" 36 | 37 | int main(int argc, char **argv) { 38 | testing::InitGoogleTest(&argc, argv); 39 | 40 | // An ad-hoc assertion outside of all tests. 41 | // 42 | // This serves three purposes: 43 | // 44 | // 1. It verifies that an ad-hoc assertion can be executed even if 45 | // no test is defined. 46 | // 2. It verifies that a failed ad-hoc assertion causes the test 47 | // program to fail. 48 | // 3. We had a bug where the XML output won't be generated if an 49 | // assertion is executed before RUN_ALL_TESTS() is called, even 50 | // though --gtest_output=xml is specified. This makes sure the 51 | // bug is fixed and doesn't regress. 52 | EXPECT_EQ(1, 2); 53 | 54 | // The above EXPECT_EQ() should cause RUN_ALL_TESTS() to return non-zero. 55 | return RUN_ALL_TESTS() ? 0 : 1; 56 | } 57 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/test/gtest_prod_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Unit test for include/gtest/gtest_prod.h. 33 | 34 | #include "gtest/gtest.h" 35 | #include "test/production.h" 36 | 37 | // Tests that private members can be accessed from a TEST declared as 38 | // a friend of the class. 39 | TEST(PrivateCodeTest, CanAccessPrivateMembers) { 40 | PrivateCode a; 41 | EXPECT_EQ(0, a.x_); 42 | 43 | a.set_x(1); 44 | EXPECT_EQ(1, a.x_); 45 | } 46 | 47 | typedef testing::Test PrivateCodeFixtureTest; 48 | 49 | // Tests that private members can be accessed from a TEST_F declared 50 | // as a friend of the class. 51 | TEST_F(PrivateCodeFixtureTest, CanAccessPrivateMembers) { 52 | PrivateCode a; 53 | EXPECT_EQ(0, a.x_); 54 | 55 | a.set_x(2); 56 | EXPECT_EQ(2, a.x_); 57 | } 58 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/test/gtest_sole_header_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: mheule@google.com (Markus Heule) 31 | // 32 | // This test verifies that it's possible to use Google Test by including 33 | // the gtest.h header file alone. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | namespace { 38 | 39 | void Subroutine() { 40 | EXPECT_EQ(42, 42); 41 | } 42 | 43 | TEST(NoFatalFailureTest, ExpectNoFatalFailure) { 44 | EXPECT_NO_FATAL_FAILURE(;); 45 | EXPECT_NO_FATAL_FAILURE(SUCCEED()); 46 | EXPECT_NO_FATAL_FAILURE(Subroutine()); 47 | EXPECT_NO_FATAL_FAILURE({ SUCCEED(); }); 48 | } 49 | 50 | TEST(NoFatalFailureTest, AssertNoFatalFailure) { 51 | ASSERT_NO_FATAL_FAILURE(;); 52 | ASSERT_NO_FATAL_FAILURE(SUCCEED()); 53 | ASSERT_NO_FATAL_FAILURE(Subroutine()); 54 | ASSERT_NO_FATAL_FAILURE({ SUCCEED(); }); 55 | } 56 | 57 | } // namespace 58 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/test/gtest_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 | __author__ = 'wan@google.com (Zhanyong Wan)' 35 | 36 | import gtest_test_utils 37 | 38 | 39 | COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_uninitialized_test_') 40 | 41 | 42 | def Assert(condition): 43 | if not condition: 44 | raise AssertionError 45 | 46 | 47 | def AssertEq(expected, actual): 48 | if expected != actual: 49 | print 'Expected: %s' % (expected,) 50 | print ' Actual: %s' % (actual,) 51 | raise AssertionError 52 | 53 | 54 | def TestExitCodeAndOutput(command): 55 | """Runs the given command and verifies its exit code and output.""" 56 | 57 | # Verifies that 'command' exits with code 1. 58 | p = gtest_test_utils.Subprocess(command) 59 | Assert(p.exited) 60 | AssertEq(1, p.exit_code) 61 | Assert('InitGoogleTest' in p.output) 62 | 63 | 64 | class GTestUninitializedTest(gtest_test_utils.TestCase): 65 | def testExitCodeAndOutput(self): 66 | TestExitCodeAndOutput(COMMAND) 67 | 68 | 69 | if __name__ == '__main__': 70 | gtest_test_utils.Main() 71 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/test/gtest_uninitialized_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | 34 | TEST(DummyTest, Dummy) { 35 | // This test doesn't verify anything. We just need it to create a 36 | // realistic stage for testing the behavior of Google Test when 37 | // RUN_ALL_TESTS() is called without testing::InitGoogleTest() being 38 | // called first. 39 | } 40 | 41 | int main() { 42 | return RUN_ALL_TESTS(); 43 | } 44 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/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 | // Author: keith.ray@gmail.com (Keith Ray) 31 | // 32 | // gtest_xml_outfile1_test_ writes some xml via TestProperty used by 33 | // gtest_xml_outfiles_test.py 34 | 35 | #include "gtest/gtest.h" 36 | 37 | class PropertyOne : public testing::Test { 38 | protected: 39 | virtual void SetUp() { 40 | RecordProperty("SetUpProp", 1); 41 | } 42 | virtual void TearDown() { 43 | RecordProperty("TearDownProp", 1); 44 | } 45 | }; 46 | 47 | TEST_F(PropertyOne, TestSomeProperties) { 48 | RecordProperty("TestSomeProperty", 1); 49 | } 50 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/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 | // Author: keith.ray@gmail.com (Keith Ray) 31 | // 32 | // gtest_xml_outfile2_test_ writes some xml via TestProperty used by 33 | // gtest_xml_outfiles_test.py 34 | 35 | #include "gtest/gtest.h" 36 | 37 | class PropertyTwo : public testing::Test { 38 | protected: 39 | virtual void SetUp() { 40 | RecordProperty("SetUpProp", 2); 41 | } 42 | virtual void TearDown() { 43 | RecordProperty("TearDownProp", 2); 44 | } 45 | }; 46 | 47 | TEST_F(PropertyTwo, TestSomeProperties) { 48 | RecordProperty("TestSomeProperty", 2); 49 | } 50 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/test/production.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // This is part of the unit test for include/gtest/gtest_prod.h. 33 | 34 | #include "production.h" 35 | 36 | PrivateCode::PrivateCode() : x_(0) {} 37 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/test/production.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // This is part of the unit test for include/gtest/gtest_prod.h. 33 | 34 | #ifndef GTEST_TEST_PRODUCTION_H_ 35 | #define GTEST_TEST_PRODUCTION_H_ 36 | 37 | #include "gtest/gtest_prod.h" 38 | 39 | class PrivateCode { 40 | public: 41 | // Declares a friend test that does not use a fixture. 42 | FRIEND_TEST(PrivateCodeTest, CanAccessPrivateMembers); 43 | 44 | // Declares a friend test that uses a fixture. 45 | FRIEND_TEST(PrivateCodeFixtureTest, CanAccessPrivateMembers); 46 | 47 | PrivateCode(); 48 | 49 | int x() const { return x_; } 50 | private: 51 | void set_x(int an_x) { x_ = an_x; } 52 | int x_; 53 | }; 54 | 55 | #endif // GTEST_TEST_PRODUCTION_H_ 56 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/xcode/Config/DebugProject.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // DebugProject.xcconfig 3 | // 4 | // These are Debug Configuration project settings for the gtest framework and 5 | // examples. It is set in the "Based On:" dropdown in the "Project" info 6 | // dialog. 7 | // This file is based on the Xcode Configuration files in: 8 | // http://code.google.com/p/google-toolbox-for-mac/ 9 | // 10 | 11 | #include "General.xcconfig" 12 | 13 | // No optimization 14 | GCC_OPTIMIZATION_LEVEL = 0 15 | 16 | // Deployment postprocessing is what triggers Xcode to strip, turn it off 17 | DEPLOYMENT_POSTPROCESSING = NO 18 | 19 | // Dead code stripping off 20 | DEAD_CODE_STRIPPING = NO 21 | 22 | // Debug symbols should be on obviously 23 | GCC_GENERATE_DEBUGGING_SYMBOLS = YES 24 | 25 | // Define the DEBUG macro in all debug builds 26 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DDEBUG=1 27 | 28 | // These are turned off to avoid STL incompatibilities with client code 29 | // // Turns on special C++ STL checks to "encourage" good STL use 30 | // GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) _GLIBCXX_DEBUG_PEDANTIC _GLIBCXX_DEBUG _GLIBCPP_CONCEPT_CHECKS 31 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/xcode/Config/FrameworkTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // FrameworkTarget.xcconfig 3 | // 4 | // These are Framework target settings for the gtest framework and examples. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Dynamic libs need to be position independent 11 | GCC_DYNAMIC_NO_PIC = NO 12 | 13 | // Dynamic libs should not have their external symbols stripped. 14 | STRIP_STYLE = non-global 15 | 16 | // Let the user install by specifying the $DSTROOT with xcodebuild 17 | SKIP_INSTALL = NO 18 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/xcode/Config/General.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // General.xcconfig 3 | // 4 | // These are General configuration settings for the gtest framework and 5 | // examples. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Build for PPC and Intel, 32- and 64-bit 11 | ARCHS = i386 x86_64 ppc ppc64 12 | 13 | // Zerolink prevents link warnings so turn it off 14 | ZERO_LINK = NO 15 | 16 | // Prebinding considered unhelpful in 10.3 and later 17 | PREBINDING = NO 18 | 19 | // Strictest warning policy 20 | WARNING_CFLAGS = -Wall -Werror -Wendif-labels -Wnewline-eof -Wno-sign-compare -Wshadow 21 | 22 | // Work around Xcode bugs by using external strip. See: 23 | // http://lists.apple.com/archives/Xcode-users/2006/Feb/msg00050.html 24 | SEPARATE_STRIP = YES 25 | 26 | // Force C99 dialect 27 | GCC_C_LANGUAGE_STANDARD = c99 28 | 29 | // not sure why apple defaults this on, but it's pretty risky 30 | ALWAYS_SEARCH_USER_PATHS = NO 31 | 32 | // Turn on position dependent code for most cases (overridden where appropriate) 33 | GCC_DYNAMIC_NO_PIC = YES 34 | 35 | // Default SDK and minimum OS version is 10.4 36 | SDKROOT = $(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk 37 | MACOSX_DEPLOYMENT_TARGET = 10.4 38 | GCC_VERSION = 4.0 39 | 40 | // VERSIONING BUILD SETTINGS (used in Info.plist) 41 | GTEST_VERSIONINFO_ABOUT = © 2008 Google Inc. 42 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/xcode/Config/ReleaseProject.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // ReleaseProject.xcconfig 3 | // 4 | // These are Release Configuration project settings for the gtest framework 5 | // and examples. It is set in the "Based On:" dropdown in the "Project" info 6 | // dialog. 7 | // This file is based on the Xcode Configuration files in: 8 | // http://code.google.com/p/google-toolbox-for-mac/ 9 | // 10 | 11 | #include "General.xcconfig" 12 | 13 | // subconfig/Release.xcconfig 14 | 15 | // Optimize for space and size (Apple recommendation) 16 | GCC_OPTIMIZATION_LEVEL = s 17 | 18 | // Deploment postprocessing is what triggers Xcode to strip 19 | DEPLOYMENT_POSTPROCESSING = YES 20 | 21 | // No symbols 22 | GCC_GENERATE_DEBUGGING_SYMBOLS = NO 23 | 24 | // Dead code strip does not affect ObjC code but can help for C 25 | DEAD_CODE_STRIPPING = YES 26 | 27 | // NDEBUG is used by things like assert.h, so define it for general compat. 28 | // ASSERT going away in release tends to create unused vars. 29 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DNDEBUG=1 -Wno-unused-variable 30 | 31 | // When we strip we want to strip all symbols in release, but save externals. 32 | STRIP_STYLE = all 33 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/xcode/Config/StaticLibraryTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // StaticLibraryTarget.xcconfig 3 | // 4 | // These are static library target settings for libgtest.a. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Static libs can be included in bundles so make them position independent 11 | GCC_DYNAMIC_NO_PIC = NO 12 | 13 | // Static libs should not have their internal globals or external symbols 14 | // stripped. 15 | STRIP_STYLE = debugging 16 | 17 | // Let the user install by specifying the $DSTROOT with xcodebuild 18 | SKIP_INSTALL = NO 19 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/xcode/Config/TestTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // TestTarget.xcconfig 3 | // 4 | // These are Test target settings for the gtest framework and examples. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | 7 | PRODUCT_NAME = $(TARGET_NAME) 8 | HEADER_SEARCH_PATHS = ../include 9 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/xcode/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.google.${PRODUCT_NAME} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | GTEST_VERSIONINFO_LONG 21 | CFBundleShortVersionString 22 | GTEST_VERSIONINFO_SHORT 23 | CFBundleGetInfoString 24 | ${PRODUCT_NAME} GTEST_VERSIONINFO_LONG, ${GTEST_VERSIONINFO_ABOUT} 25 | NSHumanReadableCopyright 26 | ${GTEST_VERSIONINFO_ABOUT} 27 | CSResourcesFileMapped 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/xcode/Samples/FrameworkSample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.google.gtest.${PRODUCT_NAME:identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | CSResourcesFileMapped 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/xcode/Samples/FrameworkSample/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2008, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Executes the samples and tests for the Google Test Framework. 33 | 34 | # Help the dynamic linker find the path to the libraries. 35 | export DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR 36 | export DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR 37 | 38 | # Create some executables. 39 | test_executables=$@ 40 | 41 | # Now execute each one in turn keeping track of how many succeeded and failed. 42 | succeeded=0 43 | failed=0 44 | failed_list=() 45 | for test in ${test_executables[*]}; do 46 | "$test" 47 | result=$? 48 | if [ $result -eq 0 ]; then 49 | succeeded=$(( $succeeded + 1 )) 50 | else 51 | failed=$(( failed + 1 )) 52 | failed_list="$failed_list $test" 53 | fi 54 | done 55 | 56 | # Report the successes and failures to the console. 57 | echo "Tests complete with $succeeded successes and $failed failures." 58 | if [ $failed -ne 0 ]; then 59 | echo "The following tests failed:" 60 | echo $failed_list 61 | fi 62 | exit $failed 63 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/xcode/Samples/FrameworkSample/widget.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: preston.a.jackson@gmail.com (Preston Jackson) 31 | // 32 | // Google Test - FrameworkSample 33 | // widget.cc 34 | // 35 | 36 | // Widget is a very simple class used for demonstrating the use of gtest 37 | 38 | #include "widget.h" 39 | 40 | Widget::Widget(int number, const std::string& name) 41 | : number_(number), 42 | name_(name) {} 43 | 44 | Widget::~Widget() {} 45 | 46 | float Widget::GetFloatValue() const { 47 | return number_; 48 | } 49 | 50 | int Widget::GetIntValue() const { 51 | return static_cast(number_); 52 | } 53 | 54 | std::string Widget::GetStringValue() const { 55 | return name_; 56 | } 57 | 58 | void Widget::GetCharPtrValue(char* buffer, size_t max_size) const { 59 | // Copy the char* representation of name_ into buffer, up to max_size. 60 | strncpy(buffer, name_.c_str(), max_size-1); 61 | buffer[max_size-1] = '\0'; 62 | return; 63 | } 64 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/xcode/Samples/FrameworkSample/widget.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: preston.a.jackson@gmail.com (Preston Jackson) 31 | // 32 | // Google Test - FrameworkSample 33 | // widget.h 34 | // 35 | 36 | // Widget is a very simple class used for demonstrating the use of gtest. It 37 | // simply stores two values a string and an integer, which are returned via 38 | // public accessors in multiple forms. 39 | 40 | #import 41 | 42 | class Widget { 43 | public: 44 | Widget(int number, const std::string& name); 45 | ~Widget(); 46 | 47 | // Public accessors to number data 48 | float GetFloatValue() const; 49 | int GetIntValue() const; 50 | 51 | // Public accessors to the string data 52 | std::string GetStringValue() const; 53 | void GetCharPtrValue(char* buffer, size_t max_size) const; 54 | 55 | private: 56 | // Data members 57 | float number_; 58 | std::string name_; 59 | }; 60 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/xcode/Samples/FrameworkSample/widget_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: preston.a.jackson@gmail.com (Preston Jackson) 31 | // 32 | // Google Test - FrameworkSample 33 | // widget_test.cc 34 | // 35 | 36 | // This is a simple test file for the Widget class in the Widget.framework 37 | 38 | #include 39 | #include "gtest/gtest.h" 40 | 41 | #include 42 | 43 | // This test verifies that the constructor sets the internal state of the 44 | // Widget class correctly. 45 | TEST(WidgetInitializerTest, TestConstructor) { 46 | Widget widget(1.0f, "name"); 47 | EXPECT_FLOAT_EQ(1.0f, widget.GetFloatValue()); 48 | EXPECT_EQ(std::string("name"), widget.GetStringValue()); 49 | } 50 | 51 | // This test verifies the conversion of the float and string values to int and 52 | // char*, respectively. 53 | TEST(WidgetInitializerTest, TestConversion) { 54 | Widget widget(1.0f, "name"); 55 | EXPECT_EQ(1, widget.GetIntValue()); 56 | 57 | size_t max_size = 128; 58 | char buffer[max_size]; 59 | widget.GetCharPtrValue(buffer, max_size); 60 | EXPECT_STREQ("name", buffer); 61 | } 62 | 63 | // Use the Google Test main that is linked into the framework. It does something 64 | // like this: 65 | // int main(int argc, char** argv) { 66 | // testing::InitGoogleTest(&argc, argv); 67 | // return RUN_ALL_TESTS(); 68 | // } 69 | -------------------------------------------------------------------------------- /tests/ext_libs/gtest-1.7.0/xcode/Scripts/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2008, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Executes the samples and tests for the Google Test Framework. 33 | 34 | # Help the dynamic linker find the path to the libraries. 35 | export DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR 36 | export DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR 37 | 38 | # Create some executables. 39 | test_executables=("$BUILT_PRODUCTS_DIR/gtest_unittest-framework" 40 | "$BUILT_PRODUCTS_DIR/gtest_unittest" 41 | "$BUILT_PRODUCTS_DIR/sample1_unittest-framework" 42 | "$BUILT_PRODUCTS_DIR/sample1_unittest-static") 43 | 44 | # Now execute each one in turn keeping track of how many succeeded and failed. 45 | succeeded=0 46 | failed=0 47 | failed_list=() 48 | for test in ${test_executables[*]}; do 49 | "$test" 50 | result=$? 51 | if [ $result -eq 0 ]; then 52 | succeeded=$(( $succeeded + 1 )) 53 | else 54 | failed=$(( failed + 1 )) 55 | failed_list="$failed_list $test" 56 | fi 57 | done 58 | 59 | # Report the successes and failures to the console. 60 | echo "Tests complete with $succeeded successes and $failed failures." 61 | if [ $failed -ne 0 ]; then 62 | echo "The following tests failed:" 63 | echo $failed_list 64 | fi 65 | exit $failed 66 | -------------------------------------------------------------------------------- /tests/fsg_check.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | template 26 | std::unique_ptr get_file(char *name, size_t *file_size = nullptr) 27 | { 28 | std::ifstream file; 29 | open_file(file, name); 30 | std::streamoff len = file_length(file); 31 | std::unique_ptr to_ret(new T[len]); 32 | read_file(file, to_ret.get(), static_cast(len)); 33 | if (file_size != nullptr){ 34 | *file_size = len; 35 | } 36 | return to_ret; 37 | } 38 | 39 | std::vector get_stuff(size_t file_len, unsigned int start, unsigned int mul) 40 | { 41 | std::vector to_ret; 42 | auto first = start / mul; 43 | while (first < file_len) { 44 | first *= mul; 45 | to_ret.push_back(first); 46 | } 47 | return to_ret; 48 | } 49 | 50 | std::vector get_dst(size_t file_len) 51 | { 52 | return get_stuff(file_len, 8, 2); 53 | } 54 | 55 | std::vector get_len(size_t file_len) 56 | { 57 | return get_stuff(file_len, 16, 3); 58 | } 59 | 60 | char* file_name; 61 | std::string gen_1; 62 | std::string gen_2; 63 | std::string model_file; 64 | 65 | TEST(fsg_check, compare) 66 | { 67 | std::unique_ptr file; 68 | size_t file_length; 69 | file = get_file(file_name, &file_length); 70 | text_info ti(file.release(), file_length); 71 | cost_model cm = wm_load(model_file); 72 | 73 | // Get functor 74 | compare_run cr(ti, cm); 75 | generators_().call(gen_1, gen_2, cr); 76 | } 77 | 78 | 79 | 80 | int main(int argc, char **argv) 81 | { 82 | ::testing::InitGoogleTest(&argc, argv); 83 | if (argc < 5) { 84 | std::cerr << "Usage: file_name generator_1 generator_2 cost_model" << std::endl; 85 | exit(1); 86 | } 87 | // Get text_info 88 | file_name = *++argv; 89 | gen_1 = *++argv; 90 | gen_2 = *++argv; 91 | model_file = *++argv; 92 | return RUN_ALL_TESTS(); 93 | } 94 | -------------------------------------------------------------------------------- /tests/model_read_test.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Andrea Farruggia 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 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | class_info read_ci(std::ifstream &input) 28 | { 29 | std::string line; 30 | std::vector Q_vec, cst_vec; 31 | 32 | while(bool(std::getline(input, line))) { 33 | if (line == "") { 34 | break; 35 | } 36 | std::uint64_t Q, cost; 37 | std::stringstream(line) >> Q >> cost; 38 | if (Q >= std::numeric_limits::max()) { 39 | Q_vec.push_back(std::numeric_limits::max()); 40 | } else { 41 | Q_vec.push_back(Q); 42 | } 43 | cst_vec.push_back(cost); 44 | } 45 | auto new_end = std::unique(Q_vec.begin(), Q_vec.end()); 46 | Q_vec.erase(new_end, Q_vec.end()); 47 | cst_vec.erase(std::next(cst_vec.begin(), Q_vec.size()), cst_vec.end()); 48 | return class_info(ITERS(Q_vec), ITERS(cst_vec)); 49 | } 50 | 51 | cost_model read_model(const char *file_name, unsigned int *lit_window) 52 | { 53 | std::string line; 54 | std::ifstream input(file_name); 55 | 56 | class_info dst = read_ci(input), len = read_ci(input); 57 | 58 | /* Read literal model */ 59 | unsigned int lit_fix, lit_var; 60 | bool read = bool(std::getline(input, line)); 61 | std::stringstream(line) >> *lit_window; 62 | read = read && bool(std::getline(input, line)); 63 | std::stringstream(line) >> lit_fix; 64 | read = read && bool(std::getline(input, line)); 65 | std::stringstream(line) >> lit_var; 66 | 67 | if (dst.length == 0 || len.length == 0 || !read) { 68 | throw std::logic_error("Invalid model file."); 69 | } 70 | 71 | return cost_model(dst, len, lit_fix, lit_var); 72 | } 73 | 74 | int main(int argc, char **argv) 75 | { 76 | if (argc < 2) { 77 | std::cerr << "No input file passed" << std::endl; 78 | } 79 | char *file_name = *++argv; 80 | unsigned int lit_window; 81 | cost_model cm = read_model(file_name, &lit_window); 82 | 83 | std::cout << get_cm_rep(cm) << std::endl; 84 | } 85 | -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(calibrator calibrator.cpp) 2 | m_link(calibrator decompress bcobjs) 3 | 4 | add_executable(get_latencies get_latencies.cpp) -------------------------------------------------------------------------------- /tools/calibrator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -lt 2 ] 4 | then 5 | echo "ERROR: too few arguments" 6 | echo "Usage: " 7 | exit 1 8 | fi 9 | 10 | FILE="${1}.tgt" 11 | LATENCY="${2}" 12 | ENCODER_LIST="soda09_16 hybrid-16" 13 | 14 | rm -f ${FILE} 15 | 16 | for ENC in ${ENCODER_LIST} 17 | do 18 | echo "== ${ENC}" | tee -a ${FILE} 19 | taskset 0x1 ./calibrator ${LATENCY} ${ENC} | tee -a ${FILE} 20 | echo "" >> ${FILE} 21 | done 22 | --------------------------------------------------------------------------------