diff --git a/.cmake-format.py b/.cmake-format.py new file mode 100644 index 0000000000..a9489146f0 --- /dev/null +++ b/.cmake-format.py @@ -0,0 +1,21 @@ +# If a statement is wrapped to more than one line, than dangle the closing +# parenthesis on it's own line. +dangle_parens = True +dangle_align = 'child' + +# If true, the parsers may infer whether or not an argument list is sortable +# (without annotation). +autosort = True + +# How wide to allow formatted cmake files +line_width = 100 + +additional_commands = { + "target_sources": { + "kwargs": { + "PUBLIC": "*", + "PRIVATE": "*", + "INTERFACE": "*", + } + }, +} diff --git a/.github/travis/cmake-build.sh b/.github/travis/cmake-build.sh new file mode 100755 index 0000000000..734e03d747 --- /dev/null +++ b/.github/travis/cmake-build.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -xe +rm -rf build +mkdir build +cd build +cmake .. \ + -DCMAKE_TOOLCHAIN_FILE="../cmake/AvrGcc.cmake" \ + -DCMAKE_BUILD_TYPE=Release \ + -G Ninja +ninja ALL_FIRMWARE diff --git a/.github/travis/cmake-lang.sh b/.github/travis/cmake-lang.sh new file mode 100755 index 0000000000..38404d53b7 --- /dev/null +++ b/.github/travis/cmake-lang.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -xe +rm -rf build +mkdir build +cd build +cmake .. \ + -DCMAKE_TOOLCHAIN_FILE="../cmake/AvrGcc.cmake" \ + -DCMAKE_BUILD_TYPE=Release \ + -G Ninja + +# ignore all failures in order to show as much output as possible +ninja -k0 check_lang || true diff --git a/.github/travis/cmake-test.sh b/.github/travis/cmake-test.sh new file mode 100755 index 0000000000..ec41633b3c --- /dev/null +++ b/.github/travis/cmake-test.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -xe +rm -rf build +mkdir build +cd build +cmake .. -G Ninja +ninja tests +ctest diff --git a/.github/travis/legacy-build.sh b/.github/travis/legacy-build.sh new file mode 100755 index 0000000000..063ef62ec9 --- /dev/null +++ b/.github/travis/legacy-build.sh @@ -0,0 +1,22 @@ +#!/bin/sh +set -xe +cp Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h Firmware/Configuration_prusa.h +bash -x build.sh || { echo "1_75mm_MK3S-EINSy10a-E3Dv6full variant failed" && false; } +bash -x build.sh EN_FARM || { echo "1_75mm_MK3S-EINSy10a-E3Dv6full EN_FARM failed" && false; } +rm Firmware/Configuration_prusa.h +cp Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h Firmware/Configuration_prusa.h +bash -x build.sh || { echo "1_75mm_MK3-EINSy10a-E3Dv6full variant failed" && false; } +bash -x build.sh EN_FARM || { echo "1_75mm_MK3-EINSy10a-E3Dv6full EN_FARM failed" && false; } +rm Firmware/Configuration_prusa.h +cp Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h Firmware/Configuration_prusa.h +bash -x build.sh || { echo "1_75mm_MK25S-RAMBo13a-E3Dv6full variant failed" && false; } +rm Firmware/Configuration_prusa.h +cp Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h Firmware/Configuration_prusa.h +bash -x build.sh || { echo "1_75mm_MK25S-RAMBo10a-E3Dv6full variant failed" && false; } +rm Firmware/Configuration_prusa.h +cp Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h Firmware/Configuration_prusa.h +bash -x build.sh || { echo "1_75mm_MK25-RAMBo13a-E3Dv6full variant failed" && false; } +rm Firmware/Configuration_prusa.h +cp Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h Firmware/Configuration_prusa.h +bash -x build.sh || { echo "1_75mm_MK25-RAMBo10a-E3Dv6full variant failed" && false; } +rm Firmware/Configuration_prusa.h diff --git a/.gitignore b/.gitignore index f0b014e034..a027eb0e80 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,12 @@ /.settings /.project /.cproject -/.vscode + +# cmake +/build/ +/build_gen/ +/.dependencies +/compile_commands.json # Temporary configuration /Firmware/Configuration_prusa.h diff --git a/.travis.yml b/.travis.yml index 0d638b4a0c..b183e53a09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,31 +1,48 @@ dist: focal +language: minimal + before_install: - - sudo apt-get install -y ninja-build python3-polib python3-pyelftools - # Arduino IDE adds a lot of noise caused by network traffic, trying to firewall it off + # Prepare the dependencies for the old build environment + - sudo apt-get install -y python3-polib python3-pyelftools python3-regex + + # Undo whatever *GARBAGE* travis is doing with python and restore the system version + - mkdir -p .dependencies/python3 + - ln -sf /usr/bin/python3 .dependencies/python3/python3 + - PATH=$PWD/.dependencies/python3:$PATH + + # Bootstrap cmake/ninja for the new build environment + - ./utils/bootstrap.py + - PATH=$(./utils/bootstrap.py --print-dependency-directory "cmake")/bin:$PATH + - PATH=$(./utils/bootstrap.py --print-dependency-directory "ninja"):$PATH + + # Arduino IDE adds a lot of noise caused by network traffic, firewall it off - sudo iptables -P INPUT DROP - sudo iptables -P FORWARD DROP - sudo iptables -P OUTPUT ACCEPT - sudo iptables -A INPUT -i lo -j ACCEPT - sudo iptables -A OUTPUT -o lo -j ACCEPT - sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT -script: - - cp Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh || { echo "1_75mm_MK3S-EINSy10a-E3Dv6full variant failed" && false; } - - bash -x build.sh EN_ONLY || { echo "1_75mm_MK3S-EINSy10a-E3Dv6full EN_ONLY failed" && false; } - - rm Firmware/Configuration_prusa.h - - cp Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh || { echo "1_75mm_MK3-EINSy10a-E3Dv6full variant failed" && false; } - - bash -x build.sh EN_ONLY || { echo "1_75mm_MK3-EINSy10a-E3Dv6full EN_ONLY failed" && false; } - - rm Firmware/Configuration_prusa.h - - cp Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh || { echo "1_75mm_MK25S-RAMBo13a-E3Dv6full variant failed" && false; } - - rm Firmware/Configuration_prusa.h - - cp Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh || { echo "1_75mm_MK25S-RAMBo10a-E3Dv6full variant failed" && false; } - - rm Firmware/Configuration_prusa.h - - cp Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh || { echo "1_75mm_MK25-RAMBo13a-E3Dv6full variant failed" && false; } - - rm Firmware/Configuration_prusa.h - - cp Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h Firmware/Configuration_prusa.h - - bash -x build.sh || { echo "1_75mm_MK25-RAMBo10a-E3Dv6full variant failed" && false; } - - rm Firmware/Configuration_prusa.h + +jobs: + include: + # legacy build.sh environment + - stage: legacy + script: ./.github/travis/legacy-build.sh + + # cmake-based build + - stage: cmake + script: ./.github/travis/cmake-build.sh + + # cmake tests + - stage: tests + script: ./.github/travis/cmake-test.sh + + # language checks + - stage: lang + script: ./.github/travis/cmake-lang.sh + +stages: + - cmake + - lang + - legacy + - tests diff --git a/.vscode/cmake-kits.json b/.vscode/cmake-kits.json new file mode 100644 index 0000000000..8e3bae6d64 --- /dev/null +++ b/.vscode/cmake-kits.json @@ -0,0 +1,10 @@ +[ + { + "name": "avr-gcc", + "toolchainFile": "${workspaceFolder}/cmake/AvrGcc.cmake", + "cmakeSettings": { + "CMAKE_MAKE_PROGRAM": "${workspaceFolder}/.dependencies/ninja-1.10.2/ninja", + "CMAKE_BUILD_TYPE": "Release" + } + } +] diff --git a/.vscode/cmake-variants.yaml b/.vscode/cmake-variants.yaml new file mode 100644 index 0000000000..70f8df827d --- /dev/null +++ b/.vscode/cmake-variants.yaml @@ -0,0 +1,11 @@ +buildType: + default: debug + choices: + debug: + short: Debug + long: Emit debug information + buildType: Debug + release: + short: Release + long: Optimize generated code + buildType: Release diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..05a5dad053 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "cmake.configureOnOpen": true, + "cmake.copyCompileCommands": "${workspaceFolder}/compile_commands.json", + "cmake.cmakePath": "${workspaceFolder}/.dependencies/cmake-3.22.5/bin/cmake", + "cmake.generator": "Ninja", + "files.insertFinalNewline": true, + "files.associations": { + "xlocale": "cpp" + } +} diff --git a/CMakeLists.txt b/CMakeLists.txt index db867e9bdc..5078a20c0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,23 +1,530 @@ -cmake_minimum_required(VERSION 3.1) - -set (CMAKE_CXX_STANDARD 11) - -project(cmake_test) - -# Prepare "Catch" library for other executables -set(CATCH_INCLUDE_DIR Catch2) -add_library(Catch INTERFACE) -target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR}) - -# Make test executable -set(TEST_SOURCES - Tests/tests.cpp - Tests/Example_test.cpp - Tests/Timer_test.cpp - Tests/AutoDeplete_test.cpp - Tests/PrusaStatistics_test.cpp - Firmware/Timer.cpp -) -add_executable(tests ${TEST_SOURCES}) -target_include_directories(tests PRIVATE Tests) -target_link_libraries(tests Catch) +cmake_minimum_required(VERSION 3.19) +include(cmake/Utilities.cmake) +include(cmake/GetGitRevisionDescription.cmake) +include(cmake/ReproducibleBuild.cmake) + +set(PROJECT_VERSION_SUFFIX + "" + CACHE + STRING + "Full version suffix to be shown on the info screen in settings (e.g. full_version=4.0.3-BETA+1035.PR111.B4, suffix=-BETA+1035.PR111.B4). Defaults to '+..' if set to ''." + ) +set(PROJECT_VERSION_SUFFIX_SHORT + "" + CACHE + STRING + "Short version suffix to be shown on splash screen. Defaults to '+' if set to ''." + ) +set(BUILD_NUMBER + "" + CACHE STRING "Build number of the firmware. Resolved automatically if not specified." + ) + +include(cmake/ProjectVersion.cmake) +resolve_version_variables() + +set(PROJECT_VERSION_FLAVOUR + "" + CACHE STRING "Firmware flavour to build - DEBUG, DEVEL, APLHA, BETA or RC" + ) +set(PROJECT_VERSION_FLAVOUR_REVISION + "" + CACHE STRING "Firmware flavour version, e.g. 1 for RC1, etc" + ) + +if(NOT PROJECT_VERSION_FLAVOUR STREQUAL "") + set(PROJECT_VERSION "${PROJECT_VERSION}-${PROJECT_VERSION_FLAVOUR}") + add_compile_definitions(FW_FLAVOR=${PROJECT_VERSION_FLAVOUR}) + if(NOT PROJECT_VERSION_FLAVOUR_REVISION STREQUAL "") + set(PROJECT_VERSION "${PROJECT_VERSION}${PROJECT_VERSION_FLAVOUR_REVISION}") + add_compile_definitions(FW_FLAVERSION=${PROJECT_VERSION_FLAVOUR_REVISION}) + endif() +endif() + +# Inform user about the resolved settings +message(STATUS "Project version: ${PROJECT_VERSION}") +message( + STATUS "Project version with short suffix: ${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX_SHORT}" + ) + +set(FN_PREFIX "FW${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX_SHORT}") + +message( + WARNING + " +***************** YOUR ATTENTION PLEASE ***************** +CMake support is experimental. There is no guarantee at this time. If you have problems you are encouraged to fall back to the tried-and-true methods. +*********************** THANK YOU ********************** +We now return to your regularly scheduled Firmware Build." + ) + +option(SECONDARY_LANGUAGES "Secondary language support in the firmware" ON) + +# Language configuration +set(MAIN_LANGUAGES + cs de es fr it pl + CACHE STRING "The list of 'main' languages to be included, in the correct order" + ) +set(COMMUNITY_LANGUAGES + nl + ro + hu + hr + sk + sv + no + CACHE STRING "The list of community languages to be included, in the correct order" + ) +set(SELECTED_LANGUAGES ${MAIN_LANGUAGES} ${COMMUNITY_LANGUAGES}) + +get_dependency_directory(prusa3dboards PRUSA_BOARDS_DIR) +project(Prusa-Firmware) +add_subdirectory(lib) + +# Get LANG_MAX_SIZE from sources +file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/Firmware/config.h MAX_SIZE_LINE + REGEX "^#define \+LANG_SIZE_RESERVED \+" + ) +string(REGEX MATCH "0x[0-9]+" MAX_SIZE_HEX "${MAX_SIZE_LINE}") +math(EXPR LANG_MAX_SIZE "${MAX_SIZE_HEX}" OUTPUT_FORMAT DECIMAL) +message("Language maximum size (from config.h): ${LANG_MAX_SIZE} bytes") + +# Ditto, this in xflash_layout.h but needs invocation of the preprocessor... :-/ +set(LANG_BIN_MAX 249856) + +# Check GCC Version +get_recommended_gcc_version(RECOMMENDED_TOOLCHAIN_VERSION) +if(CMAKE_CROSSCOMPILING AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL + ${RECOMMENDED_TOOLCHAIN_VERSION} + ) + message(WARNING "Recommended AVR toolchain is ${RECOMMENDED_TOOLCHAIN_VERSION}" + ", but you have ${CMAKE_CXX_COMPILER_VERSION}" + ) + +elseif(NOT CMAKE_CROSSCOMPILING AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + message( + WARNING + "Recommended compiler for host tools and unittests is GCC, you have ${CMAKE_CXX_COMPILER_ID}." + ) +endif() + +# append custom C/C++ flags +if(CUSTOM_COMPILE_OPTIONS) + string(REPLACE " " ";" CUSTOM_COMPILE_OPTIONS "${CUSTOM_COMPILE_OPTIONS}") + add_compile_options(${CUSTOM_COMPILE_OPTIONS}) +endif() + +# +# Global Compiler & Linker Configuration +# + +# enable warnings +add_compile_options(-Wall -Wextra -Wno-expansion-to-defined -Wsign-compare) + +# default standards for all targets +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) + +# support _DEBUG macro (some code uses to recognize debug builds) +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + add_compile_definitions(_DEBUG) +endif() + +# +# Firmware - get file lists. +# +set(FW_SOURCES + adc.cpp + backlight.cpp + BlinkM.cpp + bootapp.c + cardreader.cpp + cmdqueue.cpp + Configuration.cpp + ConfigurationStore.cpp + conv2str.cpp + Dcodes.cpp + eeprom.cpp + fancheck.cpp + Filament_sensor.cpp + first_lay_cal.cpp + heatbed_pwm.cpp + la10compat.cpp + language.c + lcd.cpp + Marlin_main.cpp + MarlinSerial.cpp + menu.cpp + mesh_bed_calibration.cpp + mesh_bed_leveling.cpp + messages.cpp + mmu2.cpp + mmu2_crc.cpp + mmu2_error_converter.cpp + mmu2_fsensor.cpp + mmu2_log.cpp + mmu2_power.cpp + mmu2_progress_converter.cpp + mmu2_protocol.cpp + mmu2_protocol_logic.cpp + mmu2_reporting.cpp + mmu2_serial.cpp + motion_control.cpp + optiboot_xflash.cpp + pat9125.cpp + planner.cpp + Prusa_farm.cpp + qr_solve.cpp + rbuf.c + Sd2Card.cpp + SdBaseFile.cpp + SdFatUtil.cpp + SdFile.cpp + SdVolume.cpp + Servo.cpp + sm4.c + sound.cpp + speed_lookuptable.cpp + spi.c + SpoolJoin.cpp + stepper.cpp + swi2c.c + swspi.cpp + Tcodes.cpp + temperature.cpp + timer02.c + Timer.cpp + tmc2130.cpp + tone04.c + twi.cpp + uart2.c + ultralcd.cpp + util.cpp + vector_3.cpp + xflash.c + xflash_dump.cpp + xyzcal.cpp + ) +list(TRANSFORM FW_SOURCES PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/Firmware/) + +set(AVR_SOURCES + wiring_digital.c + WInterrupts.c + wiring_pulse.c + hooks.c + wiring.c + wiring_analog.c + wiring_shift.c + CDC.cpp + PluggableUSB.cpp + HardwareSerial.cpp + HardwareSerial0.cpp + HardwareSerial1.cpp + HardwareSerial3.cpp + IPAddress.cpp + HardwareSerial2.cpp + Print.cpp + Stream.cpp + Tone.cpp + USBCore.cpp + WMath.cpp + WString.cpp + abi.cpp + main.cpp + ) +list(TRANSFORM AVR_SOURCES PREPEND ${PRUSA_BOARDS_DIR}/cores/prusa_einsy_rambo/) + +# +# Target configuration +# +if(CMAKE_CROSSCOMPILING) + # TODO: get date from the last git commit to set as epoch + set_source_epoch(0) + + # default optimization flags + set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") + set(CMAKE_CXX_FLAGS_RELEASE "-Os -g -DNDEBUG") + set(CMAKE_C_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) + set(CMAKE_C_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) + + # mcu and target-related settings + add_compile_options( + -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_PRUSA_EINSY_RAMBO + -DARDUINO_ARCH_AVR + ) + add_link_options(-mmcu=atmega2560 -Wl,-u,vfprintf -lprintf_flt -lm) + + # disable some C++ language features + add_compile_options($<$:-fno-threadsafe-statics>) + add_compile_options($<$:-fno-rtti>) + + # disable exceptions + add_compile_options($<$:-fno-exceptions>) + add_compile_options($<$:-fno-unwind-tables>) + + # split and gc sections + add_compile_options(-ffunction-sections -fdata-sections) + add_link_options(-ffunction-sections -fdata-sections -Wl,--gc-sections) + + # LTO (with custom options) + add_compile_options(-flto -fno-fat-lto-objects) + add_link_options(-flto) + + # Create this target before we apply the GC options + add_library(avr_core STATIC ${AVR_SOURCES}) + set_reproducible_target(avr_core) + target_include_directories( + avr_core PRIVATE ${PRUSA_BOARDS_DIR}/cores/prusa_einsy_rambo/ + ${PRUSA_BOARDS_DIR}/variants/prusa_einsy_rambo/ + ) +endif() + +# Meta targets to build absolutely everything +add_custom_target(ALL_FIRMWARE) +add_custom_target(ALL_ENGLISH) +add_custom_target(ALL_MULTILANG) +add_dependencies(ALL_FIRMWARE ALL_ENGLISH ALL_MULTILANG) +set_target_properties(ALL_MULTILANG PROPERTIES EXCLUDE_FROM_ALL FALSE) + +function(add_base_binary variant_name) + add_executable(${variant_name} ${FW_SOURCES} ${FW_HEADERS} ${VARIANT_CFG_DST}) + set_target_properties(${variant_name} PROPERTIES EXCLUDE_FROM_ALL TRUE) + set_reproducible_target(${variant_name}) + + target_include_directories( + ${variant_name} + PRIVATE ${PRUSA_BOARDS_DIR}/cores/prusa_einsy_rambo/ + ${PRUSA_BOARDS_DIR}/variants/prusa_einsy_rambo/ ${CMAKE_SOURCE_DIR}/Firmware + ) + + target_link_libraries(${variant_name} avr_core) + + # configure linker script + set(LINKER_SCRIPT ${PRUSA_BOARDS_DIR}/ldscripts/avr6.xn) + target_link_options(${variant_name} PUBLIC -Wl,-T,${LINKER_SCRIPT}) + + # limit the text section to 248K (256K - 8k reserved for the bootloader) + target_link_options(${variant_name} PUBLIC -Wl,--defsym=__TEXT_REGION_LENGTH__=248K) + + # produce ASM listing. Note we also specify the .map as a byproduct so it gets cleaned because + # link_options doesn't have a "generated outputs" feature. + add_custom_command( + TARGET ${variant_name} + POST_BUILD + COMMAND ${CMAKE_OBJDUMP} --prefix ${CMAKE_SOURCE_DIR} -CSd ${variant_name} > ${variant_name}.asm + BYPRODUCTS ${variant_name}.asm ${variant_name}.map + ) + + # inform about the firmware's size in terminal + add_custom_command( + TARGET ${variant_name} + POST_BUILD + COMMAND ${CMAKE_SIZE_UTIL} -C --mcu=atmega2560 ${variant_name} + ) + report_size(${variant_name}) + + # generate linker map file + target_link_options( + ${variant_name} PUBLIC -Wl,-Map=${CMAKE_CURRENT_BINARY_DIR}/${variant_name}.map + ) + + target_compile_definitions(${variant_name} PRIVATE CMAKE_CONTROL) +endfunction() + +function(fw_add_variant variant_name) + set(variant_header "variants/${variant_name}.h") + string(REPLACE "1_75mm_" "" variant_name "${variant_name}") + string(REPLACE "-E3Dv6full" "" variant_name "${variant_name}") + + # Single-language build + set(FW_EN "${variant_name}_EN-only") + set(FW_HEX ${CMAKE_BINARY_DIR}/${FN_PREFIX}-${FW_EN}.hex) + + add_base_binary(${FW_EN}) + target_compile_definitions(${FW_EN} PUBLIC LANG_MODE=0 FW_VARIANT="${variant_header}") + add_custom_command( + TARGET ${FW_EN} + POST_BUILD + COMMAND ${CMAKE_OBJCOPY} -O ihex ${FW_EN} ${FW_EN}.hex + COMMAND ${CMAKE_COMMAND} -E create_hardlink ${FW_EN}.hex ${FW_HEX} + BYPRODUCTS ${FW_EN}.hex ${FW_HEX} + COMMENT "Generating ${FW_EN}.hex" + ) + add_dependencies(ALL_ENGLISH ${FW_EN}) + + # Multi-language build/s + set(FW_LANG_BASE "${variant_name}_Multilang_base") + set(FW_LANG_PATCH "${variant_name}_Multilang_patch") + add_base_binary(${FW_LANG_BASE}) + target_compile_definitions(${FW_LANG_BASE} PUBLIC LANG_MODE=1 FW_VARIANT="${variant_header}") + + # Construct language map + set(LANG_TMP_DIR lang) + set(LANG_MAP ${LANG_TMP_DIR}/${variant_name}_lang.map) + + add_custom_command( + OUTPUT ${LANG_MAP} + COMMAND ${CMAKE_OBJCOPY} -O binary ${FW_LANG_BASE} ${FW_LANG_PATCH}.bin + COMMAND ${CMAKE_SOURCE_DIR}/lang/lang-map.py ${FW_LANG_BASE} ${FW_LANG_PATCH}.bin > ${LANG_MAP} + COMMAND ${CMAKE_OBJCOPY} -I binary -O ihex ${FW_LANG_PATCH}.bin ${FW_LANG_PATCH}.hex + DEPENDS ${FW_LANG_BASE} + BYPRODUCTS ${FW_LANG_PATCH}.bin ${FW_LANG_PATCH}.hex + COMMENT "Generating ${variant_name} language map" + ) + + # Base targets for language checks + add_custom_target(check_lang_${variant_name}) + add_dependencies(check_lang check_lang_${variant_name}) + + # Build language catalogs + set(LANG_BINS "") + foreach(LANG IN LISTS SELECTED_LANGUAGES) + set(LANG_BIN ${LANG_TMP_DIR}/${variant_name}_${LANG}.bin) + set(PO_FILE "${CMAKE_SOURCE_DIR}/lang/po/Firmware_${LANG}.po") + + # Full language checks + add_custom_target( + check_lang_${variant_name}_${LANG} + COMMENT "Checking ${variant_name} language ${LANG}" + COMMAND ${CMAKE_SOURCE_DIR}/lang/lang-check.py --map ${LANG_MAP} ${PO_FILE} + DEPENDS ${LANG_MAP} ${PO_FILE} + USES_TERMINAL + ) + add_dependencies(check_lang_${variant_name} check_lang_${variant_name}_${LANG}) + add_dependencies(check_lang_${LANG} check_lang_${variant_name}_${LANG}) + + add_custom_command( + OUTPUT ${LANG_BIN} + # Check po file for errors _only_ + COMMAND ${CMAKE_SOURCE_DIR}/lang/lang-check.py --errors-only --map ${LANG_MAP} ${PO_FILE} + # Build the catalog + COMMAND ${CMAKE_SOURCE_DIR}/lang/lang-build.py ${LANG_MAP} ${PO_FILE} ${LANG_BIN} + # Check bin size + COMMAND ${CMAKE_COMMAND} -DLANG_MAX_SIZE=${LANG_MAX_SIZE} -DLANG_FILE=${LANG_BIN} -P + ${PROJECT_CMAKE_DIR}/Check_lang_size.cmake + DEPENDS ${LANG_MAP} ${PO_FILE} + COMMENT "Generating ${variant_name}_${LANG}.bin" + ) + list(APPEND LANG_BINS ${LANG_BIN}) + endforeach() + + string(FIND ${variant_name} "MK3" HAS_XFLASH) + if(${HAS_XFLASH} GREATER_EQUAL 0) + # X-Flash based build (catalogs appended to patched binary) + set(FW_LANG_FINAL "${variant_name}_Multilang") + set(LANG_HEX ${CMAKE_BINARY_DIR}/${FN_PREFIX}-${FW_LANG_FINAL}.hex) + set(LANG_CATBIN ${LANG_TMP_DIR}/${variant_name}_cat.bin) + set(LANG_CATHEX ${LANG_TMP_DIR}/${variant_name}_cat.hex) + + add_custom_command( + OUTPUT ${LANG_CATBIN} + COMMAND ${CMAKE_COMMAND} -E cat ${LANG_BINS} > ${LANG_CATBIN} + DEPENDS ${LANG_BINS} + COMMENT "Merging language catalogs" + ) + #[[ + #add_custom_command(OUTPUT ${LANG_FINAL_BIN} + # COMMAND ${CMAKE_COMMAND} -DLANG_MAX_SIZE=${LANG_BIN_MAX} -DLANG_FILE=${LANG_FINAL_BIN} + # -P ${PROJECT_CMAKE_DIR}/Check_final_lang_bin_size.cmake + # APPEND) + #]] + add_custom_command( + OUTPUT ${LANG_CATHEX} + COMMAND ${CMAKE_OBJCOPY} -I binary -O ihex ${LANG_CATBIN} ${LANG_CATHEX} + DEPENDS ${LANG_CATBIN} + COMMENT "Generating Hex for language data" + ) + + add_custom_command( + OUTPUT ${FW_LANG_FINAL}.hex + COMMAND ${CMAKE_COMMAND} -E cat ${FW_LANG_PATCH}.hex ${LANG_CATHEX} > ${FW_LANG_FINAL}.hex + COMMAND ${CMAKE_COMMAND} -E create_hardlink ${FW_LANG_FINAL}.hex ${LANG_HEX} + BYPRODUCTS ${LANG_HEX} + DEPENDS ${FW_LANG_PATCH}.hex ${LANG_CATHEX} + COMMENT "Generating final ${FW_LANG_FINAL}.hex" + ) + + add_custom_target(${FW_LANG_FINAL} DEPENDS ${FW_LANG_FINAL}.hex) + add_dependencies(ALL_MULTILANG ${FW_LANG_FINAL}) + else() + set(ALL_VARIANT_HEXES "") + # Non-xflash, e.g. MK2.5 + foreach(LANG IN LISTS SELECTED_LANGUAGES) + set(FW_LANG_FINAL ${variant_name}-en_${LANG}) + set(LANG_HEX ${CMAKE_BINARY_DIR}/${FN_PREFIX}-${FW_LANG_FINAL}.hex) + set(LANG_BIN ${LANG_TMP_DIR}/${variant_name}_${LANG}.bin) + + # Patched binary with pre-baked secondary language + add_custom_command( + OUTPUT ${FW_LANG_FINAL}.bin + COMMAND ${CMAKE_OBJCOPY} -O binary ${FW_LANG_BASE} ${FW_LANG_FINAL}.bin + COMMAND ${CMAKE_SOURCE_DIR}/lang/lang-patchsec.py ${FW_LANG_BASE} ${LANG_BIN} + ${FW_LANG_FINAL}.bin + DEPENDS ${FW_LANG_BASE} ${LANG_BIN} + COMMENT "Generating ${FW_LANG_FINAL}.bin" + ) + + # Final hex files + add_custom_command( + OUTPUT ${FW_LANG_FINAL}.hex + COMMAND ${CMAKE_OBJCOPY} -I binary -O ihex ${FW_LANG_FINAL}.bin ${FW_LANG_FINAL}.hex + COMMAND ${CMAKE_COMMAND} -E create_hardlink ${FW_LANG_FINAL}.hex ${LANG_HEX} + BYPRODUCTS ${LANG_HEX} + DEPENDS ${FW_LANG_FINAL}.bin + COMMENT "Creating ${FW_LANG_FINAL}.hex" + ) + + add_custom_target(${FW_LANG_FINAL} DEPENDS ${FW_LANG_FINAL}.hex) + list(APPEND ALL_VARIANT_HEXES ${FW_LANG_FINAL}) + endforeach() + add_custom_target("${variant_name}-All-Languages" DEPENDS ${ALL_VARIANT_HEXES}) + add_dependencies(ALL_MULTILANG "${variant_name}-All-Languages") + endif() +endfunction() + +if(CMAKE_CROSSCOMPILING) + + # Main target for language checks + add_custom_target(check_lang) + foreach(LANG IN LISTS SELECTED_LANGUAGES) + add_custom_target(check_lang_${LANG}) + add_dependencies(check_lang check_lang_${LANG}) + endforeach() + + # build a list of all supported variants + file( + GLOB ALL_VARIANTS + RELATIVE ${PROJECT_SOURCE_DIR}/Firmware/variants + ${PROJECT_SOURCE_DIR}/Firmware/variants/*.h + ) + list(TRANSFORM ALL_VARIANTS REPLACE "\.h$" "") + set(FW_VARIANTS + ${ALL_VARIANTS} + CACHE STRING "Firmware variants to be built" + ) + + foreach(THIS_VAR IN LISTS FW_VARIANTS) + if(NOT ${THIS_VAR} IN_LIST ALL_VARIANTS) + message(FATAL_ERROR "Variant ${THIS_VAR} does not exist") + endif() + + message("Variant added: ${THIS_VAR}") + string(REPLACE "-E3Dv6full" "" DIR_NAME "${THIS_VAR}") + string(REPLACE "1_75mm_" "" DIR_NAME "${DIR_NAME}") + + # Generate a file in a subfolder so that we can organize things a little more neatly in VS code + file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build_gen/${DIR_NAME}) + file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/build_gen/${DIR_NAME}/CMakeLists.txt + "project(${DIR_NAME})\nfw_add_variant(${THIS_VAR})" + ) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/build_gen/${DIR_NAME}) + endforeach(THIS_VAR IN LISTS FW_VARIANTS) +endif() + +# +# Tests +# +if(NOT CMAKE_CROSSCOMPILING) + enable_testing() + add_subdirectory(tests) +endif() diff --git a/Firmware/Configuration.cpp b/Firmware/Configuration.cpp index f878492857..082ac07066 100644 --- a/Firmware/Configuration.cpp +++ b/Firmware/Configuration.cpp @@ -1,5 +1,5 @@ #include "Configuration.h" -#include "Configuration_prusa.h" +#include "Configuration_var.h" const uint16_t _nPrinterType PROGMEM=PRINTER_TYPE; const char _sPrinterName[] PROGMEM=PRINTER_NAME; diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index af36b36169..0a5355592e 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -63,7 +63,14 @@ extern PGM_P sPrinterName; #undef DEBUG_BUILD #endif -#include "Configuration_prusa.h" +#ifndef SOURCE_DATE_EPOCH +#define SOURCE_DATE_EPOCH __DATE__ +#endif +#ifndef SOURCE_TIME_EPOCH +#define SOURCE_TIME_EPOCH __TIME__ +#endif + +#include "Configuration_var.h" #define FW_PRUSA3D_MAGIC "PRUSA3DFW" #define FW_PRUSA3D_MAGIC_LEN 10 @@ -78,9 +85,7 @@ extern PGM_P sPrinterName; // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. -//#define STRING_VERSION "1.0.2" - -#define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time +#define STRING_VERSION_CONFIG_H SOURCE_DATE_EPOCH " " SOURCE_TIME_EPOCH // build date and time #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. // SERIAL_PORT selects which serial port should be used for communication with the host. diff --git a/Firmware/ConfigurationStore.cpp b/Firmware/ConfigurationStore.cpp index 0917ee181b..8bc1cd5a19 100644 --- a/Firmware/ConfigurationStore.cpp +++ b/Firmware/ConfigurationStore.cpp @@ -5,7 +5,7 @@ #include "temperature.h" #include "ultralcd.h" #include "ConfigurationStore.h" -#include "Configuration_prusa.h" +#include "Configuration_var.h" #ifdef MESH_BED_LEVELING #include "mesh_bed_leveling.h" diff --git a/Firmware/Configuration_var.h b/Firmware/Configuration_var.h new file mode 100644 index 0000000000..c7dab9d0ab --- /dev/null +++ b/Firmware/Configuration_var.h @@ -0,0 +1,10 @@ +// Include the printer's variant configuration header +#pragma once + +// This is set by the cmake build to be able to take control of +// the variant header without breaking existing build mechanisms. +#ifndef CMAKE_CONTROL +#include "Configuration_prusa.h" +#else +#include FW_VARIANT +#endif diff --git a/Firmware/Filament_sensor.cpp b/Firmware/Filament_sensor.cpp index 5b235f121a..a435130ec3 100644 --- a/Firmware/Filament_sensor.cpp +++ b/Firmware/Filament_sensor.cpp @@ -278,7 +278,9 @@ void IR_sensor_analog::voltUpdate(uint16_t raw) { // to be called from the ADC I } uint16_t IR_sensor_analog::getVoltRaw() { - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { return voltRaw; } + uint16_t ret; + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { ret = voltRaw; } + return ret; } const char *IR_sensor_analog::getIRVersionText() { @@ -339,7 +341,9 @@ bool IR_sensor_analog::checkVoltage(uint16_t raw) { } bool IR_sensor_analog::getVoltReady() const { - ATOMIC_BLOCK(ATOMIC_RESTORESTATE){ return voltReady; } + bool ret; + ATOMIC_BLOCK(ATOMIC_RESTORESTATE){ ret = voltReady; } + return ret; } void IR_sensor_analog::clearVoltReady(){ @@ -462,7 +466,9 @@ void PAT9125_sensor::settings_init() { } int16_t PAT9125_sensor::getStepCount() { - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { return stepCount; } + int16_t ret; + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { ret = stepCount; } + return ret; } void PAT9125_sensor::resetStepCount() { diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index f5148fe6cb..a6af23fdb1 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -386,7 +386,9 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_ void bed_check(float x_dimension, float y_dimension, int x_points_num, int y_points_num, float shift_x, float shift_y); #endif //HEATBED_ANALYSIS float temp_comp_interpolation(float temperature); +#if 0 void show_fw_version_warnings(); +#endif uint8_t check_printer_version(); #ifdef PINDA_THERMISTOR diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 504c0c727a..d067e9b44e 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -828,30 +828,31 @@ void factory_reset() } KEEPALIVE_STATE(IN_HANDLER); } - +#if 0 void show_fw_version_warnings() { if (FW_DEV_VERSION == FW_VERSION_GOLD || FW_DEV_VERSION == FW_VERSION_RC) return; switch (FW_DEV_VERSION) { - case(FW_VERSION_ALPHA): lcd_show_fullscreen_message_and_wait_P(_i("You are using firmware alpha version. This is development version. Using this version is not recommended and may cause printer damage.")); break;////MSG_FW_VERSION_ALPHA c=20 r=8 - case(FW_VERSION_BETA): lcd_show_fullscreen_message_and_wait_P(_i("You are using firmware beta version. This is development version. Using this version is not recommended and may cause printer damage.")); break;////MSG_FW_VERSION_BETA c=20 r=8 + case(FW_VERSION_BETA): lcd_show_fullscreen_message_and_wait_P(MSG_FW_VERSION_BETA); break; + case(FW_VERSION_ALPHA): case(FW_VERSION_DEVEL): case(FW_VERSION_DEBUG): lcd_update_enable(false); lcd_clear(); - #if FW_DEV_VERSION == FW_VERSION_DEVEL + #if (FW_DEV_VERSION == FW_VERSION_DEVEL || FW_DEV_VERSION == FW_VERSION_ALPHA) lcd_puts_at_P(0, 0, PSTR("Development build !!")); #else lcd_puts_at_P(0, 0, PSTR("Debbugging build !!!")); #endif lcd_puts_at_P(0, 1, PSTR("May destroy printer!")); - lcd_puts_at_P(0, 2, PSTR("ver ")); lcd_puts_P(PSTR(FW_VERSION_FULL)); - lcd_puts_at_P(0, 3, PSTR(FW_REPOSITORY)); + lcd_puts_at_P(0, 2, PSTR("FW")); lcd_puts_P(PSTR(FW_VERSION_FULL)); + lcd_puts_at_P(0, 3, PSTR("Repo: ")); lcd_puts_P(PSTR(FW_REPOSITORY)); lcd_wait_for_click(); break; // default: lcd_show_fullscreen_message_and_wait_P(_i("WARNING: This is an unofficial, unsupported build. Use at your own risk!")); break;////MSG_FW_VERSION_UNKNOWN c=20 r=8 } lcd_update_enable(true); } +#endif #if defined(FILAMENT_SENSOR) && defined(FSENSOR_PROBING) //! @brief try to check if firmware is on right type of printer @@ -1216,8 +1217,6 @@ void setup() SERIAL_ECHOPGM(STRING_VERSION_CONFIG_H); SERIAL_ECHORPGM(_n(" | Author: "));////MSG_AUTHOR SERIAL_ECHOLNPGM(STRING_CONFIG_H_AUTHOR); - SERIAL_ECHOPGM("Compiled: "); - SERIAL_ECHOLNPGM(__DATE__); #endif #endif @@ -1487,7 +1486,9 @@ void setup() #if defined(FILAMENT_SENSOR) && defined(FSENSOR_PROBING) check_if_fw_is_on_right_printer(); #endif //defined(FILAMENT_SENSOR) && defined(FSENSOR_PROBING) +#if 0 show_fw_version_warnings(); +#endif } switch (hw_changed) { @@ -1593,17 +1594,17 @@ void setup() manage_heater(); // Update temperatures #ifdef DEBUG_UVLO_AUTOMATIC_RECOVER printf_P(_N("Power panic detected!\nCurrent bed temp:%d\nSaved bed temp:%d\n"), (int)degBed(), eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_BED)); -#endif +#endif if ( degBed() > ( (float)eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_BED) - AUTOMATIC_UVLO_BED_TEMP_OFFSET) ){ #ifdef DEBUG_UVLO_AUTOMATIC_RECOVER puts_P(_N("Automatic recovery!")); - #endif + #endif recover_print(1); } else{ #ifdef DEBUG_UVLO_AUTOMATIC_RECOVER puts_P(_N("Normal recovery!")); - #endif + #endif if ( lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_RECOVER_PRINT), false) == LCD_LEFT_BUTTON_CHOICE) { recover_print(0); } else { @@ -4570,7 +4571,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF); retract(false,retracted_swap[active_extruder]); #else retract(false); - #endif + #endif break; #endif //FWRETRACT @@ -11345,11 +11346,11 @@ void restore_print_from_ram_and_continue(float e_move) // restore bed temperature (bed can be disabled during a thermal warning) if (degBed() != saved_bed_temperature) setTargetBed(saved_bed_temperature); - fanSpeed = saved_fan_speed; - restore_extruder_temperature_from_ram(); - axis_relative_modes ^= (-saved_extruder_relative_mode ^ axis_relative_modes) & E_AXIS_MASK; - float e = saved_pos[E_AXIS] - e_move; - plan_set_e_position(e); + fanSpeed = saved_fan_speed; + restore_extruder_temperature_from_ram(); + axis_relative_modes ^= (-saved_extruder_relative_mode ^ axis_relative_modes) & E_AXIS_MASK; + float e = saved_pos[E_AXIS] - e_move; + plan_set_e_position(e); #ifdef FANCHECK fans_check_enabled = false; diff --git a/Firmware/Sd2Card.cpp b/Firmware/Sd2Card.cpp index 0e8fc4515f..aa0d3ccfeb 100644 --- a/Firmware/Sd2Card.cpp +++ b/Firmware/Sd2Card.cpp @@ -311,13 +311,16 @@ bool Sd2Card::init(uint8_t sckRateID) { // must supply min of 74 clock cycles with CS high. for (uint8_t i = 0; i < 10; i++) spiSend(0XFF); + WRITE(MISO, 1); // temporarily enable the MISO line pullup // command to go idle in SPI mode while ((status_ = cardCommand(CMD0, 0)) != R1_IDLE_STATE) { if (((uint16_t)_millis() - t0) > SD_INIT_TIMEOUT) { + WRITE(MISO, 0); // disable the MISO line pullup error(SD_CARD_ERROR_CMD0); goto fail; } } + WRITE(MISO, 0); // disable the MISO line pullup // send 0xFF until 0xFF received to give card some clock cycles t0 = (uint16_t)_millis(); diff --git a/Firmware/config.h b/Firmware/config.h index 7fe42a0c6f..eb57b9b162 100644 --- a/Firmware/config.h +++ b/Firmware/config.h @@ -2,7 +2,7 @@ #define _CONFIG_H -#include "Configuration_prusa.h" +#include "Configuration_var.h" #include "pins.h" #if (defined(VOLT_IR_PIN) && defined(IR_SENSOR)) @@ -60,9 +60,13 @@ #define TMC2130_SPCR SPI_SPCR(TMC2130_SPI_RATE, 1, 1, 1, 0) #define TMC2130_SPSR SPI_SPSR(TMC2130_SPI_RATE) +// This is set by the cmake build to be able to take control of +// the language flag, without breaking existing build mechanisms. +#ifndef CMAKE_CONTROL //LANG - Multi-language support //#define LANG_MODE 0 // primary language only #define LANG_MODE 1 // sec. language support +#endif #define LANG_SIZE_RESERVED 0x3500 // reserved space for secondary language (13568 bytes). // 0x3D00 Maximum 15616 bytes as it depends on xflash_layout.h diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index d442cde3fb..c7adb6dcd4 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -4,7 +4,7 @@ * @author 3d-gussner */ /** \ingroup eeprom_table */ - + //! _This is a EEPROM table of currently implemented in Prusa firmware (dynamically generated from doxygen)._ @@ -37,29 +37,29 @@ typedef struct static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEPROM_SHEETS_SIZEOF."); #endif /** @defgroup eeprom_table EEPROM Table - * - + * + --------------------------------------------------------------------------------- EEPROM 8-bit Empty value = 0xFFh 255 - + EEPROM 16-bit Empty value = 0xFFFFh 65535 - + _Italic = unused or default_ - + __Bold = Status__ - - In Default/FactoryReset column the - - - __L__ Language - - __S__ Statistics - - __P__ Shipping prep - - __M__ Service/Maintenance prep - - __S/P__ Statistics and Shipping prep - + + In Default/FactoryReset column the + + - __L__ Language + - __S__ Statistics + - __P__ Shipping prep + - __M__ Service/Maintenance prep + - __S/P__ Statistics and Shipping prep + will overwrite existing values to 0 or default. A FactoryReset All Data will overwrite the whole EEPROM with ffh and some values will be initialized automatically, others need a reset / reboot. - + --------------------------------------------------------------------------------- How can you use the debug codes? - Serial terminal like Putty. @@ -67,283 +67,291 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP - _Pronterface_ does __not__ support D-codes ### !!! D-codes are case sensitive so please don't use upper case A,C or X in the address you want to read !!! - + #### Useful tools/links: - To convert hex to ascii https://www.rapidtables.com/convert/number/hex-to-ascii.html - - To convert hex to dec https://www.rapidtables.com/convert/number/hex-to-decimal.html - - Version: 1.0.1 - + To convert hex to ascii https://www.rapidtables.com/convert/number/hex-to-ascii.html + + To convert hex to dec https://www.rapidtables.com/convert/number/hex-to-decimal.html + + Version: 1.0.2 + --------------------------------------------------------------------------------- - - -| Address begin | Bit/Type | Name | Valid values | Default/FactoryReset | Description | Gcode/Function| Debug code -| :-- | :-- | :-- | :--: | :--: | :-- | :--: | :--: -| 0x0FFFh 4095 | uchar | EEPROM_SILENT | 00h 0 | ffh 255 | TMC Stealth mode: __off__ / miniRambo Power mode | LCD menu | D3 Ax0fff C1 -| ^ | ^ | ^ | 01h 1 | ^ | TMC Stealth mode: __on__ / miniRambo Silent mode | ^ | ^ -| ^ | ^ | ^ | 02h 2 | ^ | miniRambo Auto mode | ^ | ^ -| 0x0FFEh 4094 | uchar | EEPROM_LANG | 00h 0 | ffh 255 __L__ | English / LANG_ID_PRI | LCD menu | D3 Ax0ffe C1 -| ^ | ^ | ^ | 01h 1 | ^ | Other language LANG_ID_SEC | ^ | ^ -| 0x0FFCh 4092 | uint16 | EEPROM_BABYSTEP_X | ??? | ff ffh 65535 | Babystep for X axis _unsued_ | ??? | D3 Ax0ffc C2 -| 0x0FFAh 4090 | uint16 | EEPROM_BABYSTEP_Y | ??? | ff ffh 65535 | Babystep for Y axis _unsued_ | ^ | D3 Ax0ffa C2 -| 0x0FF8h 4088 | uint16 | EEPROM_BABYSTEP_Z | ??? | ff ffh 65535 | Babystep for Z axis _lagacy_ | ^ | D3 Ax0ff8 C2 -| ^ | ^ | ^ | ^ | ^ | multiple values stored now in EEPROM_Sheets_base | ^ | ^ -| 0x0FF7h 4087 | uint8 | EEPROM_CALIBRATION_STATUS | ffh 255 | ffh 255 | Assembled _default_ | ??? | D3 Ax0ff7 C1 -| ^ | ^ | ^ | 01h 1 | ^ | Calibrated | ^ | ^ -| ^ | ^ | ^ | e6h 230 | ^ | needs Live Z adjustment | ^ | ^ -| ^ | ^ | ^ | f0h 240 | ^ __P__ | needs Z calibration | ^ | ^ -| ^ | ^ | ^ | fah 250 | ^ | needs XYZ calibration | ^ | ^ -| ^ | ^ | ^ | 00h 0 | ^ | Unknown | ^ | ^ -| 0x0FF5h 4085 | uint16 | EEPROM_BABYSTEP_Z0 | ??? | ff ffh 65535 | Babystep for Z ??? | ??? | D3 Ax0ff5 C2 -| 0x0FF1h 4081 | uint32 | EEPROM_FILAMENTUSED | ??? | 00 00 00 00h 0 __S/P__| Filament used in meters | ??? | D3 Ax0ff1 C4 -| 0x0FEDh 4077 | uint32 | EEPROM_TOTALTIME | ??? | 00 00 00 00h 0 __S/P__| Total print time | ??? | D3 Ax0fed C4 -| 0x0FE5h 4069 | float | EEPROM_BED_CALIBRATION_CENTER | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fe5 C8 -| 0x0FDDh 4061 | float | EEPROM_BED_CALIBRATION_VEC_X | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fdd C8 -| 0x0FD5h 4053 | float | EEPROM_BED_CALIBRATION_VEC_Y | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fd5 C8 -| 0x0FC5h 4037 | int16 | EEPROM_BED_CALIBRATION_Z_JITTER | ??? | ff ffh 65535 | ??? | ??? | D3 Ax0fc5 C16 -| 0x0FC4h 4036 | bool | EEPROM_FARM_MODE | 00h 0 | ffh 255 __P__ | Prusa farm mode: __off__ | G99 | D3 Ax0fc4 C1 -| ^ | ^ | ^ | 01h 1 | ^ | Prusa farm mode: __on__ | G98 | ^ -| 0x0FC3h 4035 | free | _EEPROM_FREE_NR1_ | ??? | ffh 255 | _Free EEPROM space_ | _free space_ | D3 Ax0fc3 C1 -| 0x0FC1h 4033 | ??? | EEPROM_FARM_NUMBER | 000-999 | ff ffh / 000 __P__ | Prusa farm number _only 0-9 are allowed: 000-999_ | LCD menu | D3 Ax0fc1 C2 -| 0x0FC0h 4032 | bool | EEPROM_BED_CORRECTION_VALID | 00h 0 | 00h 0 | Bed correction invalid | ??? | D3 Ax0fc0 C1 -| ^ | ^ | ^ | ffh 255 | | Bed correction valid | ??? | ^ -| 0x0FBFh 4031 | char | EEPROM_BED_CORRECTION_LEFT | 00h ffh | 00h 0 | Bed manual correction left | LCD menu | D3 Ax0fbf C1 -| ^ | ^ | ^ | ^ | ^ | At this moment limited to +-100um | G80 Lxxx | ^ -| 0x0FBEh 4030 | char | EEPROM_BED_CORRECTION_RIGHT | 00h ffh | 00h 0 | Bed manual correction right | LCD menu | D3 Ax0fbe C1 -| ^ | ^ | ^ | ^ | ^ | At this moment limited to +-100um | G80 Rxxx | ^ -| 0x0FBDh 4029 | char | EEPROM_BED_CORRECTION_FRONT | 00h ffh | 00h 0 | Bed manual correction front | LCD menu | D3 Ax0fbd C1 -| ^ | ^ | ^ | ^ | ^ | At this moment limited to +-100um | G80 Fxxx | ^ -| 0x0FBCh 4028 | char | EEPROM_BED_CORRECTION_BACK | 00h ffh | 00h 0 | Bed manual correction back | LCD menu | D3 Ax0fbc C1 -| ^ | ^ | ^ | ^ | ^ | At this moment limited to +-100um | G80 Bxxx | ^ -| 0x0FBBh 4027 | bool | EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY | 00h 0 | ffh 255 | Toshiba Air: __off__ | LCD menu | D3 Ax0fbb C1 -| ^ | ^ | ^ | 01h 1 | ^ | Toshiba Air: __on__ | ^ | ^ -| 0x0FBAh 4026 | uchar | EEPROM_PRINT_FLAG | ??? | ??? | _unsued_ | ??? | D3 Ax0fba C1 -| 0x0FB0h 4016 | int16 | EEPROM_PROBE_TEMP_SHIFT | ??? | ??? | ??? | ??? | D3 Ax0fb0 C10 -| 0x0FAFh 4015 | bool | EEPROM_TEMP_CAL_ACTIVE | 00h 0 | 00h 0 | PINDA Temp cal.: __inactive__ | LCD menu | D3 Ax0faf C1 -| ^ | ^ | ^ | ffh 255 | ^ | PINDA Temp cal.: __active__ | ^ | ^ -| 0x0FA7h 4007 | ??? | _EEPROM_FREE_NR6_ | ??? | | _Free EEPROM space_ | ??? | D3 Ax0fae C8 -| ^ | ^ | ^ | ^ | 00 00 00 00h | ^ | ^ | ^ -| 0x0FA6h 4006 | uint8 | EEPROM_CALIBRATION_STATUS_PINDA | 00h 0 | ffh 255 | PINDA Temp: __not calibrated__ | ??? | D3 Ax0fa6 C1 -| ^ | ^ | ^ | 01h 1 | ^ | PINDA Temp: __calibrated__ | ^ | ^ -| 0x0FA5h 4005 | uint8 | EEPROM_UVLO | 00h 0 | ffh 255 | Power Panic flag: __inactive__ | ??? | D3 Ax0fa5 C1 -| ^ | ^ | ^ | 01h 1 | ^ | Power Panic flag: __active__ | ^ | ^ -| ^ | ^ | ^ | 02h 2 | ^ | Power Panic flag: __???__ | ^ | ^ -| 0x0F9Dh 3997 | float | EEPROM_UVLO_CURRENT_POSITION | ??? | ffh 255 | Power Panic position | ??? | D3 Ax0f9d C8 -| 0x0F95h 3989 | char | EEPROM_FILENAME | ??? | ffh 255 | Power Panic Filename | ??? | D3 Ax0f95 C8 -| 0x0F91h 3985 | uint32 | EEPROM_FILE_POSITION | ??? | ff ff ff ffh | Power Panic File Position | ??? | D3 Ax0f91 C4 -| 0x0F8Dh 3981 | float | EEPROM_UVLO_CURRENT_POSITION_Z | ??? | ff ff ff ffh | Power Panic Z Position | ^ | D3 Ax0f8d C4 -| 0x0F8Ch 3980 | ??? | EEPROM_UVLO_UNUSED_001 | ??? | ffh 255 | Power Panic _unused_ | ^ | D3 Ax0f8c C1 -| 0x0F8Bh 3979 | uint8 | EEPROM_UVLO_TARGET_BED | ??? | ffh 255 | Power Panic Bed temperature | ^ | D3 Ax0f8b C1 -| 0x0F89h 3977 | uint16 | EEPROM_UVLO_FEEDRATE | ??? | ff ffh 65535 | Power Panic Feedrate | ^ | D3 Ax0f89 C2 -| 0x0F88h 3976 | uint8 | EEPROM_UVLO_FAN_SPEED | ??? | ffh 255 | Power Panic Fan speed | ^ | D3 Ax0f88 C1 -| 0x0F87h 3975 | uint8 | EEPROM_FAN_CHECK_ENABLED | 00h 0 | ??? | Fan Check __disabled__ | LCD menu | D3 Ax0f87 C1 -| ^ | ^ | ^ | 01h 1 | ffh 255 | Fan Check __enabled__ | ^ | ^ -| 0x0F75h 3957 | uint16 | EEPROM_UVLO_MESH_BED_LEVELING | ??? | ff ffh 65535 | Power Panic Mesh Bed Leveling | ??? | D3 Ax0f75 C18 -| 0x0F73h 3955 | uint16 | EEPROM_UVLO_Z_MICROSTEPS | ??? | ff ffh 65535 | Power Panic Z microsteps | ??? | D3 Ax0f73 C2 -| 0x0F72h 3954 | uint8 | EEPROM_UVLO_E_ABS | ??? | ffh 255 | Power Panic ??? position | ??? | D3 Ax0f72 C1 -| 0x0F6Eh 3950 | float | EEPROM_UVLO_CURRENT_POSITION_E | ??? | ff ff ff ffh | Power Panic E position | ??? | D3 Ax0f6e C4 -| 0x0F6Ch 3948 | uint16_t | EEPROM_UVLO_SAVED_SEGMENT_IDX | all | ff ffh 65535 | Power Panic index of multi-segment move | ??? | D3 Ax0f6c C2 -| 0x0F6Bh 3947 | ??? | _EEPROM_FREE_NR4_ | ??? | ffh 255 | _Free EEPROM space_ | _free space_ | D3 Ax0f6b C1 -| 0x0F6Ah 3946 | ??? | _EEPROM_FREE_NR5_ | ??? | ffh 255 | _Free EEPROM space_ | _free space_ | D3 Ax0f6a C1 -| 0x0F69h 3945 | uint8 | EEPROM_CRASH_DET | ffh 255 | ffh 255 | Crash detection: __enabled__ | LCD menu | D3 Ax0f69 C1 -| ^ | ^ | ^ | 00h 0 | ^ | Crash detection: __disabled__ | LCD menu | ^ -| 0x0F68h 3944 | uint8 | EEPROM_CRASH_COUNT_Y | 00h-ffh 0-255 | ffh 255 __S/P__ | Crashes detected on y axis | ??? | D3 Ax0f68 C1 -| 0x0F67h 3943 | uint8 | EEPROM_FSENSOR | 01h 1 | ffh 255 __P__ | Filament sensor: __enabled__ | LCD menu | D3 Ax0f67 C1 -| ^ | ^ | ^ | 00h 0 | ^ | Filament sensor: __disabled__ | LCD menu | ^ -| 0x0F65h 3942 | uint8 | EEPROM_CRASH_COUNT_X | 00h-ffh 0-255 | ffh 255 __S/P__ | Crashes detected on x axis | ??? | D3 Ax0f66 C1 -| 0x0F65h 3941 | uint8 | EEPROM_FERROR_COUNT | 00h-ffh 0-255 | ffh 255 __S/P__ | Filament sensor error counter | ??? | D3 Ax0f65 C1 -| 0x0F64h 3940 | uint8 | EEPROM_POWER_COUNT | 00h-ffh 0-255 | ffh 255 __S/P__ | Power failure counter | ??? | D3 Ax0f64 C1 -| 0x0F60h 3936 | float | EEPROM_XYZ_CAL_SKEW | ??? | ff ff ff ffh | XYZ skew value | ??? | D3 Ax0f60 C4 -| 0x0F5Fh 3935 | uint8 | EEPROM_WIZARD_ACTIVE | 01h 1 | 01h 1 __P__ | Wizard __active__ | ??? | D3 Ax0f5f C1 -| ^ | ^ | ^ | 00h 0 | ^ | Wizard __inactive__ | ^ | ^ -| ^ | ^ | ^ | 02h 2 | 02h 2 __M__ | Wizard active - Z cal after shipping/service prep | ^ | ^ -| 0x0F5Dh 3933 | uint16 | EEPROM_BELTSTATUS_X | ??? | ff ffh | X Beltstatus | ??? | D3 Ax0f5d C2 -| 0x0F5Bh 3931 | uint16 | EEPROM_BELTSTATUS_Y | ??? | ff ffh | Y Beltstatus | ??? | D3 Ax0f5b C2 -| 0x0F5Ah 3930 | uint8 | EEPROM_DIR_DEPTH | 00h-ffh 0-255 | ffh 255 | Directory depth | ??? | D3 Ax0f5a C1 -| 0x0F0Ah 3850 | uint8 | EEPROM_DIRS | ??? | ffh 255 | Directories ??? | ??? | D3 Ax0f0a C80 -| 0x0F09h 3849 | uint8 | EEPROM_SD_SORT | 00h 0 | ffh 255 | SD card sort by: __time__ | LCD menu | D3 Ax0f09 C1 -| ^ | ^ | ^ | 01h 1 | ^ | SD card sort by: __alphabet__ | LCD menu | ^ -| ^ | ^ | ^ | 02h 1 | ^ | SD card: __not sorted__ | LCD menu | ^ -| 0x0F08h 3848 | uint8 | EEPROM_SECOND_SERIAL_ACTIVE | 00h 0 | ffh 255 | RPi Port: __disabled__ | LCD menu | D3 Ax0f08 C1 -| ^ | ^ | ^ | 01h 1 | ^ | RPi Port: __enabled__ | LCD menu | ^ -| 0x0F07h 3847 | uint8 | EEPROM_FSENS_AUTOLOAD_ENABLED | 01h 1 | ffh 255 __P__ | Filament autoload: __enabled__ | LCD menu | D3 Ax0f07 C1 -| ^ | ^ | ^ | 00h 0 | ^ | Filament autoload: __disabled__ | LCD menu | ^ -| 0x0F05h 3845 | uint16 | EEPROM_CRASH_COUNT_X_TOT | 0000-fffe | ff ffh __S/P__ | Total crashes on x axis | ??? | D3 Ax0f05 C2 -| 0x0F03h 3843 | uint16 | EEPROM_CRASH_COUNT_Y_TOT | 0000-fffe | ff ffh __S/P__ | Total crashes on y axis | ??? | D3 Ax0f03 C2 -| 0x0F01h 3841 | uint16 | EEPROM_FERROR_COUNT_TOT | 0000-fffe | ff ffh __S/P__ | Total filament sensor errors | ??? | D3 Ax0f01 C2 -| 0x0EFFh 3839 | uint16 | EEPROM_POWER_COUNT_TOT | 0000-fffe | ff ffh __S/P__ | Total power failures | ??? | D3 Ax0eff C2 -| 0x0EFEh 3838 | uint8 | EEPROM_TMC2130_HOME_X_ORIGIN | ??? | ffh 255 | ??? | ??? | D3 Ax0efe C1 -| 0x0EFDh 3837 | uint8 | EEPROM MC2130_HOME_X_BSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0efd C1 -| 0x0EFCh 3836 | uint8 | EEPROM_TMC2130_HOME_X_FSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0efc C1 -| 0x0EFBh 3835 | uint8 | EEPROM_TMC2130_HOME_Y_ORIGIN | ??? | ffh 255 | ??? | ??? | D3 Ax0efb C1 -| 0x0EFAh 3834 | uint8 | EEPROM_TMC2130_HOME_Y_BSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0efa C1 -| 0x0EF9h 3833 | uint8 | EEPROM_TMC2130_HOME_Y_FSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0ef9 C1 -| 0x0EF8h 3832 | uint8 | EEPROM_TMC2130_HOME_ENABLED | ??? | ffh 255 | ??? | ??? | D3 Ax0ef8 C1 -| 0x0EF7h 3831 | uint8 | EEPROM_TMC2130_WAVE_X_FAC | ??? | ffh 255 | ??? | ??? | D3 Ax0ef7 C1 -| 0x0EF6h 3830 | uint8 | EEPROM_TMC2130_WAVE_Y_FAC | ??? | ffh 255 | ??? | ??? | D3 Ax0ef6 C1 -| 0x0EF5h 3829 | uint8 | EEPROM_TMC2130_WAVE_Z_FAC | ??? | ffh 255 | ??? | ??? | D3 Ax0ef5 C1 -| 0x0EF4h 3828 | uint8 | EEPROM_TMC2130_WAVE_E_FAC | ??? | ffh 255 | ??? | ??? | D3 Ax0ef4 C1 -| 0x0EF3h 3827 | uint8 | EEPROM_TMC2130_X_MRES | ??? | ffh 255 | ??? | ??? | D3 Ax0ef3 C1 -| 0x0EF2h 3826 | uint8 | EEPROM_TMC2130_Y_MRES | ??? | ffh 255 | ??? | ??? | D3 Ax0ef2 C1 -| 0x0EF1h 3825 | uint8 | EEPROM_TMC2130_Z_MRES | ??? | ffh 255 | ??? | ??? | D3 Ax0ef1 C1 -| 0x0EF0h 3824 | uint8 | EEPROM_TMC2130_E_MRES | ??? | ffh 255 | ??? | ??? | D3 Ax0ef0 C1 -| 0x0EEE 3822 | uint16 | EEPROM_PRINTER_TYPE | ??? | ff ffh 65535 | Printer Type | ??? | D3 Ax0eee C2 -| ^ | ^ | ^ | 64 00h 100 | ^ | PRINTER_MK1 | ??? | ^ -| ^ | ^ | ^ | c8 00h 200 | ^ | PRINTER_MK2 | ??? | ^ -| ^ | ^ | ^ | c9 00h 201 | ^ | PRINTER_MK2 with MMU1 | ??? | ^ -| ^ | ^ | ^ | ca 00h 202 | ^ | PRINTER_MK2S | ??? | ^ -| ^ | ^ | ^ | cb 00h 203 | ^ | PRINTER_MK2S with MMU1 | ??? | ^ -| ^ | ^ | ^ | fa 00h 250 | ^ | PRINTER_MK2.5 | ??? | ^ -| ^ | ^ | ^ | 1a 4fh 20250 | ^ | PRINTER_MK2.5 with MMU2 | ??? | ^ -| ^ | ^ | ^ | fc 00h 252 | ^ | PRINTER_MK2.5S | ??? | ^ -| ^ | ^ | ^ | 1c 4fh 20252 | ^ | PRINTER_MK2.5S with MMU2S | ??? | ^ -| ^ | ^ | ^ | 2c 01h 300 | ^ | PRINTER_MK3 | ??? | ^ -| ^ | ^ | ^ | 4c 4fh 20300 | ^ | PRINTER_MK3 with MMU2 | ??? | ^ -| ^ | ^ | ^ | 2e 01h 302 | ^ | PRINTER_MK3S | ??? | ^ -| ^ | ^ | ^ | 4e 4fh 20302 | ^ | PRINTER_MK3S with MMU2S | ??? | ^ -| 0x0EEC 3820 | uint16 | EEPROM_BOARD_TYPE | ??? | ff ffh 65535 | Board Type | ??? | D3 Ax0eec C2 -| ^ | ^ | ^ | c8 00h 200 | ^ | BOARD_RAMBO_MINI_1_0 | ??? | ^ -| ^ | ^ | ^ | cb 00h 203 | ^ | BOARD_RAMBO_MINI_1_3 | ??? | ^ -| ^ | ^ | ^ | 36 01h 310 | ^ | BOARD_EINSY_1_0a | ??? | ^ -| 0x0EE8 3816 | float | EEPROM_EXTRUDER_MULTIPLIER_0 | ??? | ff ff ff ffh | Power panic Extruder 0 multiplier | ??? | D3 Ax0ee8 C4 -| 0x0EE4 3812 | float | EEPROM_EXTRUDER_MULTIPLIER_1 | ??? | ff ff ff ffh | Power panic Extruder 1 multiplier | ??? | D3 Ax0ee4 C4 -| 0x0EE0 3808 | float | EEPROM_EXTRUDER_MULTIPLIER_2 | ??? | ff ff ff ffh | Power panic Extruder 2 multiplier | ??? | D3 Ax0ee0 C4 -| 0x0EDE 3806 | uint16 | EEPROM_EXTRUDEMULTIPLY | ??? | ff ffh 65535 | Power panic Extruder multiplier | ??? | D3 Ax0ede C2 -| 0x0EDA 3802 | float | EEPROM_UVLO_TINY_CURRENT_POSITION_Z | ??? | ff ff ff ffh | Power panic Z position | ??? | D3 Ax0eda C4 -| 0x0ED8 3800 | uint16 | EEPROM_UVLO_TARGET_HOTEND | ??? | ff ffh 65535 | Power panic target Hotend temperature | ??? | D3 Ax0ed8 C2 -| 0x0ED7 3799 | uint8 | EEPROM_SOUND_MODE | 00h 0 | ffh 255 | Sound mode: __loud__ | ??? | D3 Ax0ed7 C1 -| ^ | ^ | ^ | 01h 1 | ^ | Sound mode: __once__ | ^ | ^ -| ^ | ^ | ^ | 02h 1 | ^ | Sound mode: __silent__ | ^ | ^ -| ^ | ^ | ^ | 03h 1 | ^ | Sound mode: __assist__ | ^ | ^ -| 0x0ED6 3798 | bool | EEPROM_SPOOL_JOIN | 01h 1 | ffh 255 | MMU2/s autodeplete: __on__ | ??? | D3 Ax0ed6 C1 -| ^ | ^ | ^ | 00h 0 | ^ | MMU2/s autodeplete: __off__ | ^ | ^ -| 0x0ED5 3797 | bool | EEPROM_FSENS_RUNOUT_ENABLED | 01h 1 | ffh 255 __P__ | Filament runout: __enabled__ | LCD menu | D3 Ax0ed5 C1 -| ^ | ^ | ^ | 00h 0 | ^ | Filament runout: __disabled__ | LCD menu | ^ -| 0x0ED3 3795 | uint16 | EEPROM_MMU_FAIL_TOT | ??? | ff ffh 65535 __S/P__ | MMU2/s total failures | ??? | D3 Ax0ed3 C2 -| 0x0ED2 3794 | uint8 | EEPROM_MMU_FAIL | ??? | ffh 255 __S/P__ | MMU2/s fails during print | ??? | D3 Ax0ed2 C1 -| 0x0ED0 3792 | uint16 | EEPROM_MMU_LOAD_FAIL_TOT | ??? | ff ffh 65535 __S/P__ | MMU2/s total load failures | ??? | D3 Ax0ed0 C2 -| 0x0ECF 3791 | uint8 | EEPROM_MMU_LOAD_FAIL | ??? | ffh 255 __S/P__ | MMU2/s load failures during print | ??? | D3 Ax0ecf C1 -| 0x0ECE 3790 | uint8 | EEPROM_MMU_CUTTER_ENABLED | 00h 0 | ffh 255 | MMU2/s cutter: __disabled__ | LCD menu | D3 Ax0ece C1 -| ^ | ^ | ^ | 01h 1 | ^ | MMU2/s cutter: __enabled__ | ^ | ^ -| ^ | ^ | ^ | 02h 2 | ^ | MMU2/s cutter: __always__ | ^ | ^ -| 0x0DAE 3502 | uint16 | EEPROM_UVLO_MESH_BED_LEVELING_FULL | ??? | ff ffh 65535 | Power panic Mesh bed leveling points | ??? | D3 Ax0dae C288 -| 0x0DAD 3501 | uint8 | EEPROM_MBL_TYPE | ??? | ffh 255 | Mesh bed leveling precision _unused atm_ | ??? | D3 Ax0dad C1 -| 0x0DAC 3500 | bool | EEPROM_MBL_MAGNET_ELIMINATION | 01h 1 | ffh 255 | Mesh bed leveling does: __ignores__ magnets | LCD menu | D3 Ax0dac C1 -| ^ | ^ | ^ | 00h 0 | ^ | Mesh bed leveling does: __NOT ignores__ magnets | ^ | ^ -| 0x0DAB 3499 | uint8 | EEPROM_MBL_POINTS_NR | 03h 3 | ffh 255 | Mesh bed leveling points: __3x3__ | LCD menu | D3 Ax0dab C1 -| ^ | ^ | ^ | 07h 7 | ^ | Mesh bed leveling points: __7x7__ | ^ | ^ -| 0x0DAA 3498 | uint8 | EEPROM_MBL_PROBE_NR | 03h 3 | ffh 255 | MBL times measurements for each point: __3__ | LCD menu | D3 Ax0daa C1 -| ^ | ^ | ^ | 05h 5 | ^ | MBL times measurements for each point: __5__ | ^ | ^ -| ^ | ^ | ^ | 01h 1 | ^ | MBL times measurements for each point: __1__ | ^ | ^ -| 0x0DA9 3497 | uint8 | EEPROM_MMU_STEALTH | 01h 1 | ffh 255 | MMU2/s Silent mode: __on__ | ??? | D3 Ax0da9 C1 -| ^ | ^ | ^ | 00h 0 | ^ | MMU2/s Silent mode: __off__ | ^ | ^ -| 0x0DA8 3496 | uint8 | EEPROM_CHECK_MODE | 01h 1 | ffh 255 | Check mode for nozzle is: __warn__ | LCD menu | D3 Ax0da8 C1 -| ^ | ^ | ^ | 02h 0 | ^ | Check mode for nozzle is: __strict__ | ^ | ^ -| ^ | ^ | ^ | 00h 0 | ^ | Check mode for nozzle is: __none__ | ^ | ^ -| 0x0DA7 3495 | uint8 | EEPROM_NOZZLE_DIAMETER | 28h 40 | ffh 255 | Nozzle diameter is: __40 or 0.40mm__ | LCD menu | D3 Ax0da7 C1 -| ^ | ^ | ^ | 3ch 60 | ^ | Nozzle diameter is: __60 or 0.60mm__ | ^ | ^ -| ^ | ^ | ^ | 3ch 80 | ^ | Nozzle diameter is: __80 or 0.80mm__ | ^ | ^ -| ^ | ^ | ^ | 19h 25 | ^ | Nozzle diameter is: __25 or 0.25mm__ | ^ | ^ -| 0x0DA5 3493 | uint16 | EEPROM_NOZZLE_DIAMETER_uM | 9001h | ff ffh 65535 | Nozzle diameter is: __400um__ | LCD menu | D3 Ax0da5 C2 -| ^ | ^ | ^ | 5802h | ^ | Nozzle diameter is: __600um__ | ^ | ^ -| ^ | ^ | ^ | 2003h | ^ | Nozzle diameter is: __800um__ | ^ | ^ -| ^ | ^ | ^ | fa00h | ^ | Nozzle diameter is: __250um__ | ^ | ^ -| 0x0DA4 3492 | uint8 | EEPROM_CHECK_MODEL | 01h 1 | ffh 255 | Check mode for printer model is: __warn__ | LCD menu | D3 Ax0da4 C1 -| ^ | ^ | ^ | 02h 0 | ^ | Check mode for printer model is: __strict__ | ^ | ^ -| ^ | ^ | ^ | 00h 0 | ^ | Check mode for printer model is: __none__ | ^ | ^ -| 0x0DA3 3491 | uint8 | EEPROM_CHECK_VERSION | 01h 1 | ffh 255 | Check mode for firmware is: __warn__ | LCD menu | D3 Ax0da3 C1 -| ^ | ^ | ^ | 02h 0 | ^ | Check mode for firmware is: __strict__ | ^ | ^ -| ^ | ^ | ^ | 00h 0 | ^ | Check mode for firmware is: __none__ | ^ | ^ -| 0x0DA2 3490 | uint8 | EEPROM_CHECK_GCODE | 01h 1 | ffh 255 | Check mode for gcode is: __warn__ _unused atm_ | LCD menu | D3 Ax0da2 C1 -| ^ | ^ | ^ | 02h 0 | ^ | Check mode for gcode is: __strict__ _unused atm_ | ^ | ^ -| ^ | ^ | ^ | 00h 0 | ^ | Check mode for gcode is: __none__ _unused atm_ | ^ | ^ -| 0x0D49 3401 | uint16 | EEPROM_SHEETS_BASE | ??? | ffh 255 | ??? | LCD menu | D3 Ax0d49 C89 -| 0x0D49 3401 | char | _1st Sheet block_ | 536d6f6f746831| ffffffffffffff | 1st sheet - Name: _Smooth1_ | ^ | D3 Ax0d49 C7 -| 0x0D50 3408 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 1st sheet - Z offset | ^ | D3 Ax0d50 C2 -| 0x0D52 3410 | uint8 | ^ | 00h 0 | ffh 255 | 1st sheet - bed temp | ^ | D3 Ax0d52 C1 -| 0x0D53 3411 | uint8 | ^ | 00h 0 | ffh 255 | 1st sheet - PINDA temp | ^ | D3 Ax0d53 C1 -| 0x0D54 3412 | char | _2nd Sheet block_ | 536d6f6f746832| ffffffffffffff | 2nd sheet - Name: _Smooth2_ | ^ | D3 Ax0d54 C7 -| 0x0D5B 3419 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 2nd sheet - Z offset | ^ | D3 Ax0d5b C2 -| 0x0D5D 3421 | uint8 | ^ | 00h 0 | ffh 255 | 2nd sheet - bed temp | ^ | D3 Ax0d5d C1 -| 0x0D5E 3422 | uint8 | ^ | 00h 0 | ffh 255 | 2nd sheet - PINDA temp | ^ | D3 Ax0d5e C1 -| 0x0D5F 3423 | char | _3rd Sheet block_ | 54657874757231| ffffffffffffff | 3rd sheet - Name: _Textur1_ | ^ | D3 Ax0d5f C7 -| 0x0D66 3430 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 3rd sheet - Z offset | ^ | D3 Ax0d66 C2 -| 0x0D68 3432 | uint8 | ^ | 00h 0 | ffh 255 | 3rd sheet - bed temp | ^ | D3 Ax0d68 C1 -| 0x0D69 3433 | uint8 | ^ | 00h 0 | ffh 255 | 3rd sheet - PINDA temp | ^ | D3 Ax0d69 C1 -| 0x0D6A 3434 | char | _4th Sheet block_ | 54657874757232| ffffffffffffff | 4th sheet - Name: _Textur2_ | ^ | D3 Ax0d6a C7 -| 0x0D71 3441 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 4th sheet - Z offset | ^ | D3 Ax0d71 C2 -| 0x0D73 3443 | uint8 | ^ | 00h 0 | ffh 255 | 4th sheet - bed temp | ^ | D3 Ax0d73 C1 -| 0x0D74 3444 | uint8 | ^ | 00h 0 | ffh 255 | 4th sheet - PINDA temp | ^ | D3 Ax0d74 C1 -| 0x0D75 3445 | char | _5th Sheet block_ | 536174696e2031| ffffffffffffff | 5th sheet - Name: _Satin 1_ | ^ | D3 Ax0d75 C7 -| 0x0D7C 3452 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 5th sheet - Z offset | ^ | D3 Ax0d7c C2 -| 0x0D7E 3454 | uint8 | ^ | 00h 0 | ffh 255 | 5th sheet - bed temp | ^ | D3 Ax0d7e C1 -| 0x0D7F 3455 | uint8 | ^ | 00h 0 | ffh 255 | 5th sheet - PINDA temp | ^ | D3 Ax0d7f C1 -| 0x0D80 3456 | char | _6th Sheet block_ | 536174696e2032| ffffffffffffff | 6th sheet - Name: _Satin 2_ | ^ | D3 Ax0d80 C7 -| 0x0D87 3463 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 6th sheet - Z offset | ^ | D3 Ax0d87 C2 -| 0x0D89 3465 | uint8 | ^ | 00h 0 | ffh 255 | 6th sheet - bed temp | ^ | D3 Ax0d89 C1 -| 0x0D8A 3466 | uint8 | ^ | 00h 0 | ffh 255 | 6th sheet - PINDA temp | ^ | D3 Ax0d8a C1 -| 0x0D8B 3467 | char | _7th Sheet block_ | 437573746f6d31| ffffffffffffff | 7th sheet - Name: _Custom1_ | ^ | D3 Ax0d8b C7 -| 0x0D92 3474 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 7th sheet - Z offset | ^ | D3 Ax0d92 C2 -| 0x0D94 3476 | uint8 | ^ | 00h 0 | ffh 255 | 7th sheet - bed temp | ^ | D3 Ax0d94 C1 -| 0x0D95 3477 | uint8 | ^ | 00h 0 | ffh 255 | 7th sheet - PINDA temp | ^ | D3 Ax0d95 C1 -| 0x0D96 3478 | char | _8th Sheet block_ | 437573746f6d32| ffffffffffffff | 8th sheet - Name: _Custom2_ | ^ | D3 Ax0d96 C7 -| 0x0D9D 3485 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 8th sheet - Z offset | ^ | D3 Ax0d9d C2 -| 0x0D9F 3487 | uint8 | ^ | 00h 0 | ffh 255 | 8th sheet - bed temp | ^ | D3 Ax0d9f C1 -| 0x0DA0 3488 | uint8 | ^ | 00h 0 | ffh 255 | 8th sheet - PINDA temp | ^ | D3 Ax0da0 C1 -| 0x0DA1 3489 | uint8 | ??? | 00h 0 | ffh 255 | ??? | ??? | D3 Ax0da1 C1 -| 0x0D48 3400 | uint8 | EEPROM_FSENSOR_PCB | ffh 255 | ffh 255 | Filament Sensor type IR unknown | LCD Support | D3 Ax0d48 C1 -| ^ | ^ | ^ | 00h 0 | ^ | Filament Sensor type IR 0.3 or older | ^ | ^ -| ^ | ^ | ^ | 01h 1 | ^ | Filament Sensor type IR 0.4 or newer | ^ | ^ -| 0x0D47 3399 | uint8 | EEPROM_FSENSOR_ACTION_NA | 00h 0 | ffh 255 | Filament Sensor action: __Continue__ | LCD menu | D3 Ax0d47 C1 -| ^ | ^ | ^ | 01h 1 | ^ | Filament Sensor action: __Pause__ | ^ | ^ -| 0x0D37 3383 | float | EEPROM_UVLO_SAVED_START_POSITION | ??? | ff ff ff ffh | Power panic saved start position all-axis | ??? | D3 Ax0d37 C16 -| ^ | ^ | ^ | ??? | ^ | Power panic saved start position e-axis | ^ | D3 Ax0d43 C4 -| ^ | ^ | ^ | ??? | ^ | Power panic saved start position z-axis | ^ | D3 Ax0d3f C4 -| ^ | ^ | ^ | ??? | ^ | Power panic saved start position y-axis | ^ | D3 Ax0d3b C4 -| ^ | ^ | ^ | ??? | ^ | Power panic saved start position x-axis | ^ | D3 Ax0d37 C4 -| 0x0D35 3381 | uint16 | EEPROM_UVLO_FEEDMULTIPLY | ??? | ff ffh 65355 | Power panic saved feed multiplier | ??? | D3 Ax0d35 C2 -| 0x0D34 3380 | uint8 | EEPROM_BACKLIGHT_LEVEL_HIGH | 00h - ffh | 82h 130 | LCD backlight bright: __128__ Dim value to 255 | LCD menu | D3 Ax0d34 C1 -| 0x0D33 3379 | uint8 | EEPROM_BACKLIGHT_LEVEL_LOW | 00h - ffh | 32h 50 | LCD backlight dim: __50__ 0 to Bright value | LCD menu | D3 Ax0d33 C1 -| 0x0D32 3378 | uint8 | EEPROM_BACKLIGHT_MODE | 02h 2 | ffh 255 | LCD backlight mode: __Auto__ | LCD menu | D3 Ax0d32 C1 -| ^ | ^ | ^ | 01h 1 | ^ | LCD backlight mode: __Bright__ | ^ | ^ -| ^ | ^ | ^ | 00h 0 | ^ | LCD backlight mode: __Dim__ | ^ | ^ -| 0x0D30 3376 | uint16 | EEPROM_BACKLIGHT_TIMEOUT | 01 00 - ff ff | 0a 00h 65535 | LCD backlight timeout: __10__ seconds | LCD menu | D3 Ax0d30 C2 -| 0x0D2C 3372 | float | EEPROM_UVLO_LA_K | ??? | ff ff ff ffh | Power panic saved Linear Advanced K value | ??? | D3 Ax0d2c C4 -| 0x0D2B 3371 | uint8 | EEPROM_ALTFAN_OVERRIDE | ffh 255 | ffh 255 | ALTFAN override unknown state | LCD menu | D3 Ax0d2b C1 -| ^ | ^ | ^ | 00h 0 | ^ | ALTFAN override deactivated | ^ | ^ -| ^ | ^ | ^ | 01h 1 | ^ | ALTFAN override activated | ^ | ^ -| 0x0D2A 3370 | uint8 | EEPROM_EXPERIMENTAL_VISIBILITY | ffh 255 | ffh 255 | Experimental menu visibility unknown state | LCD menu | D3 Ax0d2a C1 -| ^ | ^ | ^ | 00h 0 | ^ | Experimental menu visibility hidden | ^ | ^ -| ^ | ^ | ^ | 01h 1 | ^ | Experimental menu visibility visible | ^ | ^ -| 0x0D29 3369 | uint8 | EEPROM_PINDA_TEMP_COMPENSATION | ffh 255 | ffh 255 | PINDA temp compensation unknown state | LCD menu | D3 Ax0d29 C1 -| ^ | ^ | ^ | 00h 0 | ^ | PINDA has no temp compensation PINDA v1/2 | ^ | ^ -| ^ | ^ | ^ | 01h 1 | ^ | PINDA has temp compensation aka SuperPINDA | ^ | ^ -| 0x0D15 3349 | char[20] | EEPROM_PRUSA_SN | SN[19] == 0 | ffffffffffffffff... | PRUSA Serial number string | PRUSA SN | D3 Ax0d15 C20 -| 0x0D11 3345 | float | EEPROM_UVLO_ACCELL | ??? | ff ff ff ffh | Power panic saved normal acceleration | ??? | D3 Ax0d11 C4 -| 0x0D0D 3341 | float | EEPROM_UVLO_RETRACT_ACCELL | ??? | ff ff ff ffh | Power panic saved retract acceleration | ??? | D3 Ax0d0d C4 -| 0x0D09 3337 | float | EEPROM_UVLO_TRAVEL_ACCELL | ??? | ff ff ff ffh | Power panic saved travel acceleration | ??? | D3 Ax0d09 C4 -| 0x0D05 3333 | uint32_t | EEPROM_JOB_ID | ??? | 00 00 00 00h | Job ID used by host software | D3 only | D3 Ax0d05 C4 -| 0x0D04 3332 | uint8_t | EEPROM_ECOOL_ENABLE | ffh 255 | ^ | Disable extruder motor scaling for non-farm print | LCD menu | D3 Ax0d04 C1 -| ^ | ^ | ^ | 2ah 42 | ^ | Enable extruder motor scaling for non-farm print | ^ | D3 Ax0d04 C1 -| 0x0D03 3321 | uint8_t | EEPROM_FW_CRASH_FLAG | ffh 255 | ffh 255 | Last FW crash reason (dump_crash_reason) | D21/D22 | D3 Ax0d03 C1 -| ^ | ^ | ^ | 00h 0 | ^ | manual | ^ | ^ -| ^ | ^ | ^ | 01h 1 | ^ | stack_error | ^ | ^ -| ^ | ^ | ^ | 02h 2 | ^ | watchdog | ^ | ^ -| ^ | ^ | ^ | 03h 3 | ^ | bad_isr | ^ | ^ -| ^ | ^ | ^ | 04h 4 | ^ | bad_pullup_temp_isr | ^ | ^ -| ^ | ^ | ^ | 05h 5 | ^ | bad_pullup_step_isr | ^ | ^ -| 0x0D02 3320 | uint8_t | EEPROM_FSENSOR_JAM_DETECTION | 01h 1 | ff/01 | fsensor pat9125 jam detection feature | LCD menu | D3 Ax0d02 C1 -| 0x0D01 3319 | uint8_t | EEPROM_MMU_ENABLED | 01h 1 | ff/01 | MMU enabled | LCD menu | D3 Ax0d01 C1 - -| Address begin | Bit/Type | Name | Valid values | Default/FactoryReset | Description | Gcode/Function| Debug code -| :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: -| 0x0012 18 | uint16 | EEPROM_FIRMWARE_VERSION_END | ??? | ff ffh 65535 | ??? | ??? | D3 Ax0012 C2 -| 0x0010 16 | uint16 | EEPROM_FIRMWARE_VERSION_FLAVOR | ??? | ff ffh 65535 | ??? | ??? | D3 Ax0010 C2 -| 0x000E 14 | uint16 | EEPROM_FIRMWARE_VERSION_REVISION | ??? | ff ffh 65535 | Firmware version revision number DEV/ALPHA/BETA/RC| ??? | D3 Ax000e C2 -| 0x000C 12 | uint16 | EEPROM_FIRMWARE_VERSION_MINOR | ??? | ff ffh 65535 | Firmware version minor number | ??? | D3 Ax000c C2 -| 0x000A 10 | uint16 | EEPROM_FIRMWARE_VERSION_MAJOR | ??? | ff ffh 65535 | Firmware version major number | ??? | D3 Ax000a C2 -| 0x0000 0 | char | FW_PRUSA3D_MAGIC | ??? | ffffffffffffffffffff | __`PRUSA3DFW`__ | ??? | D3 Ax0000 C10 + + +|Address begin|Bit/Type | Name | Valid values | Default/FactoryReset | Description |Gcode/Function| Debug code +| :-- | :-- | :-- | :--: | :--: | :-- | :--: | :--: +| 0x0FFF 4095 | uchar | EEPROM_SILENT | 00h 0 | ffh 255 | TMC Stealth mode: __off__ / miniRambo Power mode | LCD menu | D3 Ax0fff C1 +| ^ | ^ | ^ | 01h 1 | ^ | TMC Stealth mode: __on__ / miniRambo Silent mode | ^ | ^ +| ^ | ^ | ^ | 02h 2 | ^ | miniRambo Auto mode | ^ | ^ +| 0x0FFE 4094 | uchar | EEPROM_LANG | 00h 0 | ffh 255 __L__ | English / LANG_ID_PRI | LCD menu | D3 Ax0ffe C1 +| ^ | ^ | ^ | 01h 1 | ^ | Other language LANG_ID_SEC | ^ | ^ +| 0x0FFC 4092 | uint16 | EEPROM_BABYSTEP_X | ??? | ff ffh 65535 | Babystep for X axis _unsued_ | ??? | D3 Ax0ffc C2 +| 0x0FFA 4090 | uint16 | EEPROM_BABYSTEP_Y | ??? | ff ffh 65535 | Babystep for Y axis _unsued_ | ^ | D3 Ax0ffa C2 +| 0x0FF8 4088 | uint16 | EEPROM_BABYSTEP_Z | ??? | ff ffh 65535 | Babystep for Z axis _lagacy_ | ^ | D3 Ax0ff8 C2 +| ^ | ^ | ^ | ^ | ^ | multiple values stored now in EEPROM_Sheets_base | ^ | ^ +| 0x0FF7 4087 | uint8 | EEPROM_CALIBRATION_STATUS | ffh 255 | ffh 255 | Assembled _default_ | ??? | D3 Ax0ff7 C1 +| ^ | ^ | ^ | 01h 1 | ^ | Calibrated | ^ | ^ +| ^ | ^ | ^ | e6h 230 | ^ | needs Live Z adjustment | ^ | ^ +| ^ | ^ | ^ | f0h 240 | ^ __P__ | needs Z calibration | ^ | ^ +| ^ | ^ | ^ | fah 250 | ^ | needs XYZ calibration | ^ | ^ +| ^ | ^ | ^ | 00h 0 | ^ | Unknown | ^ | ^ +| 0x0FF5 4085 | uint16 | EEPROM_BABYSTEP_Z0 | ??? | ff ffh 65535 | Babystep for Z ??? | ??? | D3 Ax0ff5 C2 +| 0x0FF1 4081 | unint32 | EEPROM_FILAMENTUSED | ??? | 00 00 00 00h 0 __S/P__| Filament used in meters | ??? | D3 Ax0ff1 C4 +| 0x0FED 4077 | unint32 | EEPROM_TOTALTIME | ??? | 00 00 00 00h 0 __S/P__| Total print time | ??? | D3 Ax0fed C4 +| 0x0FE5 4069 | float | EEPROM_BED_CALIBRATION_CENTER | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fe5 C8 +| 0x0FDD 4061 | float | EEPROM_BED_CALIBRATION_VEC_X | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fdd C8 +| 0x0FD5 4053 | float | EEPROM_BED_CALIBRATION_VEC_Y | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fd5 C8 +| 0x0FC5 4037 | int16 | EEPROM_BED_CALIBRATION_Z_JITTER | ??? | ff ffh 65535 | ??? | ??? | D3 Ax0fc5 C16 +| 0x0FC4 4036 | bool | EEPROM_FARM_MODE | 00h 0 | ffh 255 __P__ | Prusa farm mode: __off__ | G99 | D3 Ax0fc4 C1 +| ^ | ^ | ^ | 01h 1 | ^ | Prusa farm mode: __on__ | G98 | ^ +| 0x0FC3 4035 | free | _EEPROM_FREE_NR1_ | ??? | ffh 255 | _Free EEPROM space_ | _free space_ | D3 Ax0fc3 C1 +| 0x0FC1 4033 | ??? | EEPROM_FARM_NUMBER | 000-999 | ff ffh / 000 __P__ | Prusa farm number _only 0-9 are allowed: 000-999_ | LCD menu | D3 Ax0fc1 C2 +| 0x0FC0 4032 | bool | EEPROM_BED_CORRECTION_VALID | 00h 0 | 00h 0 | Bed correction invalid | ??? | D3 Ax0fc0 C1 +| ^ | ^ | ^ | ffh 255 | ^ | Bed correction valid | ??? | ^ +| 0x0FBF 4031 | char | EEPROM_BED_CORRECTION_LEFT | 00h ffh | 00h 0 | Bed manual correction left | LCD menu | D3 Ax0fbf C1 +| ^ | ^ | ^ | ^ | ^ | At this moment limited to +-100um | G80 Lxxx | ^ +| 0x0FBE 4030 | char | EEPROM_BED_CORRECTION_RIGHT | 00h ffh | 00h 0 | Bed manual correction right | LCD menu | D3 Ax0fbe C1 +| ^ | ^ | ^ | ^ | ^ | At this moment limited to +-100um | G80 Rxxx | ^ +| 0x0FBD 4029 | char | EEPROM_BED_CORRECTION_FRONT | 00h ffh | 00h 0 | Bed manual correction front | LCD menu | D3 Ax0fbd C1 +| ^ | ^ | ^ | ^ | ^ | At this moment limited to +-100um | G80 Fxxx | ^ +| 0x0FBC 4028 | char | EEPROM_BED_CORRECTION_BACK | 00h ffh | 00h 0 | Bed manual correction back | LCD menu | D3 Ax0fbc C1 +| ^ | ^ | ^ | ^ | ^ | At this moment limited to +-100um | G80 Bxxx | ^ +| 0x0FBB 4027 | bool | EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY | 00h 0 | ffh 255 | Toshiba Air: __off__ | LCD menu | D3 Ax0fbb C1 +| ^ | ^ | ^ | 01h 1 | ^ | Toshiba Air: __on__ | ^ | ^ +| 0x0FBA 4026 | uchar | EEPROM_PRINT_FLAG | ??? | ??? | _unsued_ | ??? | D3 Ax0fba C1 +| 0x0FB0 4016 | int16 | EEPROM_PROBE_TEMP_SHIFT | ??? | ??? | ??? | ??? | D3 Ax0fb0 C10 +| 0x0FAF 4015 | bool | EEPROM_TEMP_CAL_ACTIVE | 00h 0 | 00h 0 | PINDA Temp cal.: __inactive__ | LCD menu | D3 Ax0faf C1 +| ^ | ^ | ^ | ffh 255 | ^ | PINDA Temp cal.: __active__ | ^ | ^ +| 0x0FA7 4007 | ??? | _EEPROM_FREE_NR6_ | ??? | ffh 255 | _Free EEPROM space_ | ??? | D3 Ax0fae C8 +| ^ | ^ | ^ | ^ | 00 00 00 00h | ^ | ^ | ^ +| 0x0FA6 4006 | uint8 | EEPROM_CALIBRATION_STATUS_PINDA | 00h 0 | ffh 255 | PINDA Temp: __not calibrated__ | ??? | D3 Ax0fa6 C1 +| ^ | ^ | ^ | 01h 1 | ^ | PINDA Temp: __calibrated__ | ^ | ^ +| 0x0FA5 4005 | uint8 | EEPROM_UVLO | 00h 0 | ffh 255 | Power Panic flag: __inactive__ | ??? | D3 Ax0fa5 C1 +| ^ | ^ | ^ | 01h 1 | ^ | Power Panic flag: __active__ | ^ | ^ +| ^ | ^ | ^ | 02h 2 | ^ | Power Panic flag: __???__ | ^ | ^ +| 0x0F9D 3997 | float | EEPROM_UVLO_CURRENT_POSITION | ??? | ffh 255 | Power Panic position | ??? | D3 Ax0f9d C8 +| 0x0F95 3989 | char | EEPROM_FILENAME | ??? | ffh 255 | Power Panic Filename | ??? | D3 Ax0f95 C8 +| 0x0F91 3985 | unint32 | EEPROM_FILE_POSITION | ??? | ff ff ff ffh | Power Panic File Position | ??? | D3 Ax0f91 C4 +| 0x0F8D 3981 | float | EEPROM_UVLO_CURRENT_POSITION_Z | ??? | ff ff ff ffh | Power Panic Z Position | ^ | D3 Ax0f8d C4 +| 0x0F8C 3980 | ??? | EEPROM_UVLO_UNUSED_001 | ??? | ffh 255 | Power Panic _unused_ | ^ | D3 Ax0f8c C1 +| 0x0F8B 3979 | uint8 | EEPROM_UVLO_TARGET_BED | ??? | ffh 255 | Power Panic Bed temperature | ^ | D3 Ax0f8b C1 +| 0x0F89 3977 | uint16 | EEPROM_UVLO_FEEDRATE | ??? | ff ffh 65535 | Power Panic Feedrate | ^ | D3 Ax0f89 C2 +| 0x0F88 3976 | uint8 | EEPROM_UVLO_FAN_SPEED | ??? | ffh 255 | Power Panic Fan speed | ^ | D3 Ax0f88 C1 +| 0x0F87 3975 | uint8 | EEPROM_FAN_CHECK_ENABLED | 00h 0 | ??? | Fan Check __disabled__ | LCD menu | D3 Ax0f87 C1 +| ^ | ^ | ^ | 01h 1 | ffh 255 | Fan Check __enabled__ | ^ | ^ +| 0x0F75 3957 | uint16 | EEPROM_UVLO_MESH_BED_LEVELING | ??? | ff ffh 65535 | Power Panic Mesh Bed Leveling | ??? | D3 Ax0f75 C18 +| 0x0F73 3955 | uint16 | EEPROM_UVLO_Z_MICROSTEPS | ??? | ff ffh 65535 | Power Panic Z microsteps | ??? | D3 Ax0f73 C2 +| 0x0F72 3954 | uint8 | EEPROM_UVLO_E_ABS | ??? | ffh 255 | Power Panic ??? position | ??? | D3 Ax0f72 C1 +| 0x0F6E 3950 | float | EEPROM_UVLO_CURRENT_POSITION_E | ??? | ff ff ff ffh | Power Panic E position | ??? | D3 Ax0f6e C4 +| 0x0F6C 3948 | uint16 | EEPROM_UVLO_SAVED_SEGMENT_IDX | all | ff ffh 65535 | Power Panic index of multi-segment move | ??? | D3 Ax0f6c C2 +| 0x0F6B 3947 | ??? | _EEPROM_FREE_NR4_ | ??? | ffh 255 | _Free EEPROM space_ | _free space_ | D3 Ax0f6b C1 +| 0x0F6A 3946 | ??? | _EEPROM_FREE_NR5_ | ??? | ffh 255 | _Free EEPROM space_ | _free space_ | D3 Ax0f6a C1 +| 0x0F69 3945 | uint8 | EEPROM_CRASH_DET | ffh 255 | ffh 255 | Crash detection: __enabled__ | LCD menu | D3 Ax0f69 C1 +| ^ | ^ | ^ | 00h 0 | ^ | Crash detection: __disabled__ | LCD menu | ^ +| 0x0F68 3944 | uint8 | EEPROM_CRASH_COUNT_Y | 00h-ffh 0-255| ffh 255 __S/P__ | Crashes detected on y axis | ??? | D3 Ax0f68 C1 +| 0x0F67 3943 | uint8 | EEPROM_FSENSOR | 01h 1 | ffh 255 __P__ | Filament sensor: __enabled__ | LCD menu | D3 Ax0f67 C1 +| ^ | ^ | ^ | 00h 0 | ^ | Filament sensor: __disabled__ | LCD menu | ^ +| 0x0F65 3942 | uint8 | EEPROM_CRASH_COUNT_X | 00h-ffh 0-255| ffh 255 __S/P__ | Crashes detected on x axis | ??? | D3 Ax0f66 C1 +| 0x0F65 3941 | uint8 | EEPROM_FERROR_COUNT | 00h-ffh 0-255| ffh 255 __S/P__ | Filament sensor error counter | ??? | D3 Ax0f65 C1 +| 0x0F64 3940 | uint8 | EEPROM_POWER_COUNT | 00h-ffh 0-255| ffh 255 __S/P__ | Power failure counter | ??? | D3 Ax0f64 C1 +| 0x0F60 3936 | float | EEPROM_XYZ_CAL_SKEW | ??? | ff ff ff ffh | XYZ skew value | ??? | D3 Ax0f60 C4 +| 0x0F5F 3935 | uint8 | EEPROM_WIZARD_ACTIVE | 01h 1 | 01h 1 __P__ | Wizard __active__ | ??? | D3 Ax0f5f C1 +| ^ | ^ | ^ | 00h 0 | ^ | Wizard __inactive__ | ^ | ^ +| ^ | ^ | ^ | 02h 2 | 02h 2 __M__ | Wizard active - Z cal after shipping/service prep | ^ | ^ +| 0x0F5D 3933 | uint16 | EEPROM_BELTSTATUS_X | ??? | ff ffh | X Beltstatus | ??? | D3 Ax0f5d C2 +| 0x0F5B 3931 | uint16 | EEPROM_BELTSTATUS_Y | ??? | ff ffh | Y Beltstatus | ??? | D3 Ax0f5b C2 +| 0x0F5A 3930 | uint8 | EEPROM_DIR_DEPTH | 00h-ffh 0-255| ffh 255 | Directory depth | ??? | D3 Ax0f5a C1 +| 0x0F0A 3850 | uint8 | EEPROM_DIRS | ??? | ffh 255 | Directories ??? | ??? | D3 Ax0f0a C80 +| 0x0F09 3849 | uint8 | EEPROM_SD_SORT | 00h 0 | ffh 255 | SD card sort by: __time__ | LCD menu | D3 Ax0f09 C1 +| ^ | ^ | ^ | 01h 1 | ^ | SD card sort by: __alphabet__ | LCD menu | ^ +| ^ | ^ | ^ | 02h 2 | ^ | SD card: __not sorted__ | LCD menu | ^ +| 0x0F08 3848 | uint8 | EEPROM_SECOND_SERIAL_ACTIVE | 00h 0 | ffh 255 | RPi Port: __disabled__ | LCD menu | D3 Ax0f08 C1 +| ^ | ^ | ^ | 01h 1 | ^ | RPi Port: __enabled__ | LCD menu | ^ +| 0x0F07 3847 | uint8 | EEPROM_FSENS_AUTOLOAD_ENABLED | 01h 1 | ffh 255 __P__ | Filament autoload: __enabled__ | LCD menu | D3 Ax0f07 C1 +| ^ | ^ | ^ | 00h 0 | ^ | Filament autoload: __disabled__ | LCD menu | ^ +| 0x0F05 3845 | uint16 | EEPROM_CRASH_COUNT_X_TOT | 0000-fffe | ff ffh __S/P__ | Total crashes on x axis | ??? | D3 Ax0f05 C2 +| 0x0F03 3843 | uint16 | EEPROM_CRASH_COUNT_Y_TOT | 0000-fffe | ff ffh __S/P__ | Total crashes on y axis | ??? | D3 Ax0f03 C2 +| 0x0F01 3841 | uint16 | EEPROM_FERROR_COUNT_TOT | 0000-fffe | ff ffh __S/P__ | Total filament sensor errors | ??? | D3 Ax0f01 C2 +| 0x0EFF 3839 | uint16 | EEPROM_POWER_COUNT_TOT | 0000-fffe | ff ffh __S/P__ | Total power failures | ??? | D3 Ax0eff C2 +| 0x0EFE 3838 | uint8 | EEPROM_TMC2130_HOME_X_ORIGIN | ??? | ffh 255 | ??? | ??? | D3 Ax0efe C1 +| 0x0EFD 3837 | uint8 | EEPROM_TMC2130_HOME_X_BSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0efd C1 +| 0x0EFC 3836 | uint8 | EEPROM_TMC2130_HOME_X_FSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0efc C1 +| 0x0EFB 3835 | uint8 | EEPROM_TMC2130_HOME_Y_ORIGIN | ??? | ffh 255 | ??? | ??? | D3 Ax0efb C1 +| 0x0EFA 3834 | uint8 | EEPROM_TMC2130_HOME_Y_BSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0efa C1 +| 0x0EF9 3833 | uint8 | EEPROM_TMC2130_HOME_Y_FSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0ef9 C1 +| 0x0EF8 3832 | uint8 | EEPROM_TMC2130_HOME_ENABLED | ??? | ffh 255 | ??? | ??? | D3 Ax0ef8 C1 +| 0x0EF7 3831 | uint8 | EEPROM_TMC2130_WAVE_X_FAC | ??? | ffh 255 | ??? | ??? | D3 Ax0ef7 C1 +| 0x0EF6 3830 | uint8 | EEPROM_TMC2130_WAVE_Y_FAC | ??? | ffh 255 | ??? | ??? | D3 Ax0ef6 C1 +| 0x0EF5 3829 | uint8 | EEPROM_TMC2130_WAVE_Z_FAC | ??? | ffh 255 | ??? | ??? | D3 Ax0ef5 C1 +| 0x0EF4 3828 | uint8 | EEPROM_TMC2130_WAVE_E_FAC | ??? | ffh 255 | ??? | ??? | D3 Ax0ef4 C1 +| 0x0EF3 3827 | uint8 | EEPROM_TMC2130_X_MRES | ??? | ffh 255 | ??? | ??? | D3 Ax0ef3 C1 +| 0x0EF2 3826 | uint8 | EEPROM_TMC2130_Y_MRES | ??? | ffh 255 | ??? | ??? | D3 Ax0ef2 C1 +| 0x0EF1 3825 | uint8 | EEPROM_TMC2130_Z_MRES | ??? | ffh 255 | ??? | ??? | D3 Ax0ef1 C1 +| 0x0EF0 3824 | uint8 | EEPROM_TMC2130_E_MRES | ??? | ffh 255 | ??? | ??? | D3 Ax0ef0 C1 +| 0x0EEE 3822 | uint16 | EEPROM_PRINTER_TYPE | ??? | ff ffh 65535 | Printer Type | ??? | D3 Ax0eee C2 +| ^ | ^ | ^ | 64 00h 100 | ^ | PRINTER_MK1 | ??? | ^ +| ^ | ^ | ^ | c8 00h 200 | ^ | PRINTER_MK2 | ??? | ^ +| ^ | ^ | ^ | c9 00h 201 | ^ | PRINTER_MK2 with MMU1 | ??? | ^ +| ^ | ^ | ^ | ca 00h 202 | ^ | PRINTER_MK2S | ??? | ^ +| ^ | ^ | ^ | cb 00h 203 | ^ | PRINTER_MK2S with MMU1 | ??? | ^ +| ^ | ^ | ^ | fa 00h 250 | ^ | PRINTER_MK2.5 | ??? | ^ +| ^ | ^ | ^ | 1a 4fh 20250 | ^ | PRINTER_MK2.5 with MMU2 | ??? | ^ +| ^ | ^ | ^ | fc 00h 252 | ^ | PRINTER_MK2.5S | ??? | ^ +| ^ | ^ | ^ | 1c 4fh 20252 | ^ | PRINTER_MK2.5S with MMU2S | ??? | ^ +| ^ | ^ | ^ | 2c 01h 300 | ^ | PRINTER_MK3 | ??? | ^ +| ^ | ^ | ^ | 4c 4fh 20300 | ^ | PRINTER_MK3 with MMU2 | ??? | ^ +| ^ | ^ | ^ | 2e 01h 302 | ^ | PRINTER_MK3S | ??? | ^ +| ^ | ^ | ^ | 4e 4fh 20302 | ^ | PRINTER_MK3S with MMU2S | ??? | ^ +| 0x0EEC 3820 | uint16 | EEPROM_BOARD_TYPE | ??? | ff ffh 65535 | Board Type | ??? | D3 Ax0eec C2 +| ^ | ^ | ^ | c8 00h 200 | ^ | BOARD_RAMBO_MINI_1_0 | ??? | ^ +| ^ | ^ | ^ | cb 00h 203 | ^ | BOARD_RAMBO_MINI_1_3 | ??? | ^ +| ^ | ^ | ^ | 36 01h 310 | ^ | BOARD_EINSY_1_0a | ??? | ^ +| 0x0EE8 3816 | float | EEPROM_EXTRUDER_MULTIPLIER_0 | ??? | ff ff ff ffh | Power panic Extruder 0 multiplier | ??? | D3 Ax0ee8 C4 +| 0x0EE4 3812 | float | EEPROM_EXTRUDER_MULTIPLIER_1 | ??? | ff ff ff ffh | Power panic Extruder 1 multiplier | ??? | D3 Ax0ee4 C4 +| 0x0EE0 3808 | float | EEPROM_EXTRUDER_MULTIPLIER_2 | ??? | ff ff ff ffh | Power panic Extruder 2 multiplier | ??? | D3 Ax0ee0 C4 +| 0x0EDE 3806 | uint16 | EEPROM_EXTRUDEMULTIPLY | ??? | ff ffh 65535 | Power panic Extruder multiplier | ??? | D3 Ax0ede C2 +| 0x0EDA 3802 | float | EEPROM_UVLO_TINY_CURRENT_POSITION_Z | ??? | ff ff ff ffh | Power panic Z position | ??? | D3 Ax0eda C4 +| 0x0ED8 3800 | uint16 | EEPROM_UVLO_TARGET_HOTEND | ??? | ff ffh 65535 | Power panic target Hotend temperature | ??? | D3 Ax0ed8 C2 +| 0x0ED7 3799 | uint8 | EEPROM_SOUND_MODE | 00h 0 | ffh 255 | Sound mode: __loud__ | ??? | D3 Ax0ed7 C1 +| ^ | ^ | ^ | 01h 1 | ^ | Sound mode: __once__ | ^ | ^ +| ^ | ^ | ^ | 02h 2 | ^ | Sound mode: __silent__ | ^ | ^ +| ^ | ^ | ^ | 03h 3 | ^ | Sound mode: __assist__ | ^ | ^ +| 0x0ED6 3798 | bool | EEPROM_SPOOL_JOIN | 01h 1 | ffh 255 | MMU2/s autodeplete: __on__ | ??? | D3 Ax0ed6 C1 +| ^ | ^ | ^ | 00h 0 | ^ | MMU2/s autodeplete: __off__ | ^ | ^ +| 0x0ED5 3797 | bool | EEPROM_FSENS_RUNOUT_ENABLED | 01h 1 | ffh 255 __P__ | Filament runout: __enabled__ | LCD menu | D3 Ax0ed5 C1 +| ^ | ^ | ^ | 00h 0 | ^ | Filament runout: __disabled__ | LCD menu | ^ +| 0x0ED3 3795 | uint16 | EEPROM_MMU_FAIL_TOT | ??? | ff ffh 65535 __S/P__ | MMU2/s total failures | ??? | D3 Ax0ed3 C2 +| 0x0ED2 3794 | uint8 | EEPROM_MMU_FAIL | ??? | ffh 255 __S/P__ | MMU2/s fails during print | ??? | D3 Ax0ed2 C1 +| 0x0ED0 3792 | uint16 | EEPROM_MMU_LOAD_FAIL_TOT | ??? | ff ffh 65535 __S/P__ | MMU2/s total load failures | ??? | D3 Ax0ed0 C2 +| 0x0ECF 3791 | uint8 | EEPROM_MMU_LOAD_FAIL | ??? | ffh 255 __S/P__ | MMU2/s load failures during print | ??? | D3 Ax0ecf C1 +| 0x0ECE 3790 | uint8 | EEPROM_MMU_CUTTER_ENABLED | 00h 0 | ffh 255 | MMU2/s cutter: __disabled__ | LCD menu | D3 Ax0ece C1 +| ^ | ^ | ^ | 01h 1 | ^ | MMU2/s cutter: __enabled__ | ^ | ^ +| ^ | ^ | ^ | 02h 2 | ^ | MMU2/s cutter: __always__ | ^ | ^ +| 0x0DAE 3502 | uint16 | EEPROM_UVLO_MESH_BED_LEVELING_FULL | ??? | ff ffh 65535 | Power panic Mesh bed leveling points | ??? | D3 Ax0dae C288 +| 0x0DAD 3501 | uint8 | EEPROM_MBL_TYPE | ??? | ffh 255 | Mesh bed leveling precision _unused atm_ | ??? | D3 Ax0dad C1 +| 0x0DAC 3500 | bool | EEPROM_MBL_MAGNET_ELIMINATION | 01h 1 | ffh 255 | Mesh bed leveling does: __ignores__ magnets | LCD menu | D3 Ax0dac C1 +| ^ | ^ | ^ | 00h 0 | ^ | Mesh bed leveling does: __NOT ignores__ magnets | ^ | ^ +| 0x0DAB 3499 | uint8 | EEPROM_MBL_POINTS_NR | 03h 3 | ffh 255 | Mesh bed leveling points: __3x3__ | LCD menu | D3 Ax0dab C1 +| ^ | ^ | ^ | 07h 7 | ^ | Mesh bed leveling points: __7x7__ | ^ | ^ +| 0x0DAA 3498 | uint8 | EEPROM_MBL_PROBE_NR | 03h 3 | ffh 255 | MBL times measurements for each point: __3__ | LCD menu | D3 Ax0daa C1 +| ^ | ^ | ^ | 05h 5 | ^ | MBL times measurements for each point: __5__ | ^ | ^ +| ^ | ^ | ^ | 01h 1 | ^ | MBL times measurements for each point: __1__ | ^ | ^ +| 0x0DA9 3497 | uint8 | EEPROM_MMU_STEALTH | 01h 1 | ffh 255 | MMU2/s Silent mode: __on__ | ??? | D3 Ax0da9 C1 +| ^ | ^ | ^ | 00h 0 | ^ | MMU2/s Silent mode: __off__ | ^ | ^ +| 0x0DA8 3496 | uint8 | EEPROM_CHECK_MODE | 01h 1 | ffh 255 | Check mode for nozzle is: __warn__ | LCD menu | D3 Ax0da8 C1 +| ^ | ^ | ^ | 02h 2 | ^ | Check mode for nozzle is: __strict__ | ^ | ^ +| ^ | ^ | ^ | 00h 0 | ^ | Check mode for nozzle is: __none__ | ^ | ^ +| 0x0DA7 3495 | uint8 | EEPROM_NOZZLE_DIAMETER | 28h 40 | ffh 255 | Nozzle diameter is: __40 or 0.40mm__ | LCD menu | D3 Ax0da7 C1 +| ^ | ^ | ^ | 3ch 60 | ^ | Nozzle diameter is: __60 or 0.60mm__ | ^ | ^ +| ^ | ^ | ^ | 3ch 80 | ^ | Nozzle diameter is: __80 or 0.80mm__ | ^ | ^ +| ^ | ^ | ^ | 19h 25 | ^ | Nozzle diameter is: __25 or 0.25mm__ | ^ | ^ +| 0x0DA5 3493 | uint16 | EEPROM_NOZZLE_DIAMETER_uM | 9001h | ff ffh 65535 | Nozzle diameter is: __400um__ | LCD menu | D3 Ax0da5 C2 +| ^ | ^ | ^ | 5802h | ^ | Nozzle diameter is: __600um__ | ^ | ^ +| ^ | ^ | ^ | 2003h | ^ | Nozzle diameter is: __800um__ | ^ | ^ +| ^ | ^ | ^ | fa00h | ^ | Nozzle diameter is: __250um__ | ^ | ^ +| 0x0DA4 3492 | uint8 | EEPROM_CHECK_MODEL | 01h 1 | ffh 255 | Check mode for printer model is: __warn__ | LCD menu | D3 Ax0da4 C1 +| ^ | ^ | ^ | 02h 2 | ^ | Check mode for printer model is: __strict__ | ^ | ^ +| ^ | ^ | ^ | 00h 0 | ^ | Check mode for printer model is: __none__ | ^ | ^ +| 0x0DA3 3491 | uint8 | EEPROM_CHECK_VERSION | 01h 1 | ffh 255 | Check mode for firmware is: __warn__ | LCD menu | D3 Ax0da3 C1 +| ^ | ^ | ^ | 02h 2 | ^ | Check mode for firmware is: __strict__ | ^ | ^ +| ^ | ^ | ^ | 00h 0 | ^ | Check mode for firmware is: __none__ | ^ | ^ +| 0x0DA2 3490 | uint8 | EEPROM_CHECK_GCODE | 01h 1 | ffh 255 | Check mode for gcode is: __warn__ _unused atm_ | LCD menu | D3 Ax0da2 C1 +| ^ | ^ | ^ | 02h 2 | ^ | Check mode for gcode is: __strict__ _unused atm_ | ^ | ^ +| ^ | ^ | ^ | 00h 0 | ^ | Check mode for gcode is: __none__ _unused atm_ | ^ | ^ +| 0x0D49 3401 | uint16 | EEPROM_SHEETS_BASE | ??? | ffh 255 | ??? | LCD menu | D3 Ax0d49 C89 +| 0x0D49 3401 | char | _1st Sheet block_ |536d6f6f746831| ffffffffffffff | 1st sheet - Name: _Smooth1_ | ^ | D3 Ax0d49 C7 +| 0x0D50 3408 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 1st sheet - Z offset | ^ | D3 Ax0d50 C2 +| 0x0D52 3410 | uint8 | ^ | 00h 0 | ffh 255 | 1st sheet - bed temp | ^ | D3 Ax0d52 C1 +| 0x0D53 3411 | uint8 | ^ | 00h 0 | ffh 255 | 1st sheet - PINDA temp | ^ | D3 Ax0d53 C1 +| 0x0D54 3412 | char | _2nd Sheet block_ |536d6f6f746832| ffffffffffffff | 2nd sheet - Name: _Smooth2_ | ^ | D3 Ax0d54 C7 +| 0x0D5B 3419 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 2nd sheet - Z offset | ^ | D3 Ax0d5b C2 +| 0x0D5D 3421 | uint8 | ^ | 00h 0 | ffh 255 | 2nd sheet - bed temp | ^ | D3 Ax0d5d C1 +| 0x0D5E 3422 | uint8 | ^ | 00h 0 | ffh 255 | 2nd sheet - PINDA temp | ^ | D3 Ax0d5e C1 +| 0x0D5F 3423 | char | _3rd Sheet block_ |54657874757231| ffffffffffffff | 3rd sheet - Name: _Textur1_ | ^ | D3 Ax0d5f C7 +| 0x0D66 3430 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 3rd sheet - Z offset | ^ | D3 Ax0d66 C2 +| 0x0D68 3432 | uint8 | ^ | 00h 0 | ffh 255 | 3rd sheet - bed temp | ^ | D3 Ax0d68 C1 +| 0x0D69 3433 | uint8 | ^ | 00h 0 | ffh 255 | 3rd sheet - PINDA temp | ^ | D3 Ax0d69 C1 +| 0x0D6A 3434 | char | _4th Sheet block_ |54657874757232| ffffffffffffff | 4th sheet - Name: _Textur2_ | ^ | D3 Ax0d6a C7 +| 0x0D71 3441 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 4th sheet - Z offset | ^ | D3 Ax0d71 C2 +| 0x0D73 3443 | uint8 | ^ | 00h 0 | ffh 255 | 4th sheet - bed temp | ^ | D3 Ax0d73 C1 +| 0x0D74 3444 | uint8 | ^ | 00h 0 | ffh 255 | 4th sheet - PINDA temp | ^ | D3 Ax0d74 C1 +| 0x0D75 3445 | char | _5th Sheet block_ |536174696e2031| ffffffffffffff | 5th sheet - Name: _Satin 1_ | ^ | D3 Ax0d75 C7 +| 0x0D7C 3452 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 5th sheet - Z offset | ^ | D3 Ax0d7c C2 +| 0x0D7E 3454 | uint8 | ^ | 00h 0 | ffh 255 | 5th sheet - bed temp | ^ | D3 Ax0d7e C1 +| 0x0D7F 3455 | uint8 | ^ | 00h 0 | ffh 255 | 5th sheet - PINDA temp | ^ | D3 Ax0d7f C1 +| 0x0D80 3456 | char | _6th Sheet block_ |536174696e2032| ffffffffffffff | 6th sheet - Name: _Satin 2_ | ^ | D3 Ax0d80 C7 +| 0x0D87 3463 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 6th sheet - Z offset | ^ | D3 Ax0d87 C2 +| 0x0D89 3465 | uint8 | ^ | 00h 0 | ffh 255 | 6th sheet - bed temp | ^ | D3 Ax0d89 C1 +| 0x0D8A 3466 | uint8 | ^ | 00h 0 | ffh 255 | 6th sheet - PINDA temp | ^ | D3 Ax0d8a C1 +| 0x0D8B 3467 | char | _7th Sheet block_ |437573746f6d31| ffffffffffffff | 7th sheet - Name: _Custom1_ | ^ | D3 Ax0d8b C7 +| 0x0D92 3474 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 7th sheet - Z offset | ^ | D3 Ax0d92 C2 +| 0x0D94 3476 | uint8 | ^ | 00h 0 | ffh 255 | 7th sheet - bed temp | ^ | D3 Ax0d94 C1 +| 0x0D95 3477 | uint8 | ^ | 00h 0 | ffh 255 | 7th sheet - PINDA temp | ^ | D3 Ax0d95 C1 +| 0x0D96 3478 | char | _8th Sheet block_ |437573746f6d32| ffffffffffffff | 8th sheet - Name: _Custom2_ | ^ | D3 Ax0d96 C7 +| 0x0D9D 3485 | uint16 | ^ | 00 00h 0 | ff ffh 65535 | 8th sheet - Z offset | ^ | D3 Ax0d9d C2 +| 0x0D9F 3487 | uint8 | ^ | 00h 0 | ffh 255 | 8th sheet - bed temp | ^ | D3 Ax0d9f C1 +| 0x0DA0 3488 | uint8 | ^ | 00h 0 | ffh 255 | 8th sheet - PINDA temp | ^ | D3 Ax0da0 C1 +| 0x0DA1 3489 | uint8 | active_sheet | 00h 0 | ffh 255 | Active sheet index | ^ | D3 Ax0da1 C1 +| 0x0D48 3400 | uint8 | EEPROM_FSENSOR_PCB | ffh 255 | ffh 255 | Filament Sensor type IR unknown | LCD Support | D3 Ax0d48 C1 +| ^ | ^ | ^ | 00h 0 | ^ | Filament Sensor type IR 0.3 or older | ^ | ^ +| ^ | ^ | ^ | 01h 1 | ^ | Filament Sensor type IR 0.4 or newer | ^ | ^ +| 0x0D47 3399 | uint8 | EEPROM_FSENSOR_ACTION_NA | 00h 0 | ffh 255 | Filament Sensor action: __Continue__ | LCD menu | D3 Ax0d47 C1 +| ^ | ^ | ^ | 01h 1 | ^ | Filament Sensor action: __Pause__ | ^ | ^ +| 0x0D37 3383 | float | EEPROM_UVLO_SAVED_START_POSITION | ??? | ff ff ff ffh | Power panic saved start position all-axis | ??? | D3 Ax0d37 C16 +| ^ | ^ | ^ | ??? | ^ | Power panic saved start position e-axis | ^ | D3 Ax0d43 C4 +| ^ | ^ | ^ | ??? | ^ | Power panic saved start position z-axis | ^ | D3 Ax0d3f C4 +| ^ | ^ | ^ | ??? | ^ | Power panic saved start position y-axis | ^ | D3 Ax0d3b C4 +| ^ | ^ | ^ | ??? | ^ | Power panic saved start position x-axis | ^ | D3 Ax0d37 C4 +| 0x0D35 3381 | uint16 | EEPROM_UVLO_FEEDMULTIPLY | ??? | ff ffh 65355 | Power panic saved feed multiplier | ??? | D3 Ax0d35 C2 +| 0x0D34 3380 | uint8 | EEPROM_BACKLIGHT_LEVEL_HIGH | 00h - ffh | 82h 130 | LCD backlight bright: __128__ Dim value to 255 | LCD menu | D3 Ax0d34 C1 +| 0x0D33 3379 | uint8 | EEPROM_BACKLIGHT_LEVEL_LOW | 00h - ffh | 32h 50 | LCD backlight dim: __50__ 0 to Bright value | LCD menu | D3 Ax0d33 C1 +| 0x0D32 3378 | uint8 | EEPROM_BACKLIGHT_MODE | 02h 2 | ffh 255 | LCD backlight mode: __Auto__ | LCD menu | D3 Ax0d32 C1 +| ^ | ^ | ^ | 01h 1 | ^ | LCD backlight mode: __Bright__ | ^ | ^ +| ^ | ^ | ^ | 00h 0 | ^ | LCD backlight mode: __Dim__ | ^ | ^ +| 0x0D30 3376 | uint16 | EEPROM_BACKLIGHT_TIMEOUT | 01 00 - ff ff| 0a 00h 65535 | LCD backlight timeout: __10__ seconds | LCD menu | D3 Ax0d30 C2 +| 0x0D2C 3372 | float | EEPROM_UVLO_LA_K | ??? | ff ff ff ffh | Power panic saved Linear Advanced K value | ??? | D3 Ax0d2c C4 +| 0x0D2B 3371 | uint8 | EEPROM_ALTFAN_OVERRIDE | ffh 255 | ffh 255 | ALTFAN override unknown state | LCD menu | D3 Ax0d2b C1 +| ^ | ^ | ^ | 00h 0 | ^ | ALTFAN override deactivated | ^ | ^ +| ^ | ^ | ^ | 01h 1 | ^ | ALTFAN override activated | ^ | ^ +| 0x0D2A 3370 | uint8 | EEPROM_EXPERIMENTAL_VISIBILITY | ffh 255 | ffh 255 | Experimental menu visibility unknown state | LCD menu | D3 Ax0d2a C1 +| ^ | ^ | ^ | 00h 0 | ^ | Experimental menu visibility hidden | ^ | ^ +| ^ | ^ | ^ | 01h 1 | ^ | Experimental menu visibility visible | ^ | ^ +| 0x0D29 3369 | uint8 | EEPROM_PINDA_TEMP_COMPENSATION | ffh 255 | ffh 255 | PINDA temp compensation unknown state | LCD menu | D3 Ax0d29 C1 +| ^ | ^ | ^ | 00h 0 | ^ | PINDA has no temp compensation PINDA v1/2 | ^ | ^ +| ^ | ^ | ^ | 01h 1 | ^ | PINDA has temp compensation aka SuperPINDA | ^ | ^ +| 0x0D15 3349 | char[20]| EEPROM_PRUSA_SN | SN[19] == 0 | ffffffffffffffff... | PRUSA Serial number string | PRUSA SN | D3 Ax0d15 C20 +| 0x0D11 3345 | float | EEPROM_UVLO_ACCELL | ??? | ff ff ff ffh | Power panic saved normal acceleration | ??? | D3 Ax0d11 C4 +| 0x0D0D 3341 | float | EEPROM_UVLO_RETRACT_ACCELL | ??? | ff ff ff ffh | Power panic saved retract acceleration | ??? | D3 Ax0d0d C4 +| 0x0D09 3337 | float | EEPROM_UVLO_TRAVEL_ACCELL | ??? | ff ff ff ffh | Power panic saved travel acceleration | ??? | D3 Ax0d09 C4 +| 0x0D05 3333 | unint32 | EEPROM_JOB_ID | ??? | 00 00 00 00h | Job ID used by host software | D3 only | D3 Ax0d05 C4 +| 0x0D04 3332 | uint8 | EEPROM_ECOOL_ENABLE | ffh 255 | ^ | Disable extruder motor scaling for non-farm print | LCD menu | D3 Ax0d04 C1 +| ^ | ^ | ^ | 2ah 42 | ^ | Enable extruder motor scaling for non-farm print | ^ | D3 Ax0d04 C1 +| 0x0D03 3331 | uint8 | EEPROM_FW_CRASH_FLAG | ffh 255 | ffh 255 | Last FW crash reason (dump_crash_reason) | D21/D22 | D3 Ax0d03 C1 +| ^ | ^ | ^ | 00h 0 | ^ | manual | ^ | ^ +| ^ | ^ | ^ | 01h 1 | ^ | stack_error | ^ | ^ +| ^ | ^ | ^ | 02h 2 | ^ | watchdog | ^ | ^ +| ^ | ^ | ^ | 03h 3 | ^ | bad_isr | ^ | ^ +| ^ | ^ | ^ | 04h 4 | ^ | bad_pullup_temp_isr | ^ | ^ +| ^ | ^ | ^ | 05h 5 | ^ | bad_pullup_step_isr | ^ | ^ +| 0x0D02 3330 | uint8 | EEPROM_TEMP_MODEL_ENABLE | 00h 0 | ff/00 | Temp model deactivated | Temp model | D3 Ax0d02 C1 +| ^ | ^ | ^ | 01h 1 | ^ | Temp model activated | ^ | ^ +| 0x0CFE 3326 | float | EEPROM_TEMP_MODEL_P | ??? | ff ff ff ffh | Temp model power (W) | Temp model | D3 Ax0cfe C4 +| 0x0CFA 3322 | float | EEPROM_TEMP_MODEL_C | ??? | ff ff ff ffh | Temp model capacitance (J/K) | Temp model | D3 Ax0cfa C4 +| 0x0CBA 3258 |float[16]| EEPROM_TEMP_MODEL_R | ??? | ff ff ff ffh | Temp model resistance (K/W) | Temp model | D3 Ax0cba C64 +| 0x0CB6 3254 | float | EEPROM_TEMP_MODEL_Ta_corr | ??? | ff ff ff ffh | Temp model ambient temperature correction (K) | Temp model | D3 Ax0cb6 C4 +| 0x0CB2 3250 | float | EEPROM_TEMP_MODEL_W | ??? | ff ff ff ffh | Temp model warning threshold (K/s) | Temp model | D3 Ax0cb2 C4 +| 0x0CAE 3246 | float | EEPROM_TEMP_MODEL_E | ??? | ff ff ff ffh | Temp model error threshold (K/s) | Temp model | D3 Ax0cae C4 +| 0x0CAD 3245 | uint8 | EEPROM_FSENSOR_JAM_DETECTION | 01h 1 | ff/01 | fsensor pat9125 jam detection feature | LCD menu | D3 Ax0cad C1 +| 0x0CAC 3244 | uint8 | EEPROM_MMU_ENABLED | 01h 1 | ff/01 | MMU enabled | LCD menu | D3 Ax0cac C1 + +|Address begin|Bit/Type | Name | Valid values | Default/FactoryReset | Description |Gcode/Function| Debug code +| :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: +| 0x0012 18 | uint16 | EEPROM_FIRMWARE_VERSION_END | ??? | ff ffh 65535 | ??? | ??? | D3 Ax0012 C2 +| 0x0010 16 | uint16 | EEPROM_FIRMWARE_VERSION_FLAVOR | ??? | ff ffh 65535 | ??? | ??? | D3 Ax0010 C2 +| 0x000E 14 | uint16 | EEPROM_FIRMWARE_VERSION_REVISION | ??? | ff ffh 65535 | Firmware version revision number DEV/ALPHA/BETA/RC| ??? | D3 Ax000e C2 +| 0x000C 12 | uint16 | EEPROM_FIRMWARE_VERSION_MINOR | ??? | ff ffh 65535 | Firmware version minor number | ??? | D3 Ax000c C2 +| 0x000A 10 | uint16 | EEPROM_FIRMWARE_VERSION_MAJOR | ??? | ff ffh 65535 | Firmware version major number | ??? | D3 Ax000a C2 +| 0x0000 0 | char | FW_PRUSA3D_MAGIC | ??? | ffffffffffffffffffff | __`PRUSA3DFW`__ | ??? | D3 Ax0000 C10 */ #define EEPROM_EMPTY_VALUE 0xFF @@ -384,19 +392,19 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP #define EEPROM_BED_CORRECTION_REAR (EEPROM_BED_CORRECTION_FRONT-1) #define EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY (EEPROM_BED_CORRECTION_REAR-1) #define EEPROM_PRINT_FLAG (EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY-1) -#define EEPROM_PROBE_TEMP_SHIFT (EEPROM_PRINT_FLAG - 2*5) //5 x int for storing pinda probe temp shift relative to 50 C; unit: motor steps +#define EEPROM_PROBE_TEMP_SHIFT (EEPROM_PRINT_FLAG - 2*5) //5 x int for storing pinda probe temp shift relative to 50 C; unit: motor steps #define EEPROM_TEMP_CAL_ACTIVE (EEPROM_PROBE_TEMP_SHIFT - 1) #define _EEPROM_FREE_NR6_ (EEPROM_TEMP_CAL_ACTIVE - 2*4) //4 x int (used to be for bowden lengths for SNMM) #define EEPROM_CALIBRATION_STATUS_PINDA (_EEPROM_FREE_NR6_ - 1) //0 - not calibrated; 1 - calibrated #define EEPROM_UVLO (EEPROM_CALIBRATION_STATUS_PINDA - 1) //1 - uvlo during print #define EEPROM_UVLO_CURRENT_POSITION (EEPROM_UVLO-2*4) // 2 x float for current_position in X and Y axes #define EEPROM_FILENAME (EEPROM_UVLO_CURRENT_POSITION - 8) //8chars to store filename without extension -#define EEPROM_FILE_POSITION (EEPROM_FILENAME - 4) //32 bit for uint32_t file position +#define EEPROM_FILE_POSITION (EEPROM_FILENAME - 4) //32 bit for uint32_t file position #define EEPROM_UVLO_CURRENT_POSITION_Z (EEPROM_FILE_POSITION - 4) //float for current position in Z #define EEPROM_UVLO_UNUSED_001 (EEPROM_UVLO_CURRENT_POSITION_Z - 1) // uint8_t (unused) #define EEPROM_UVLO_TARGET_BED (EEPROM_UVLO_UNUSED_001 - 1) #define EEPROM_UVLO_FEEDRATE (EEPROM_UVLO_TARGET_BED - 2) //uint16_t -#define EEPROM_UVLO_FAN_SPEED (EEPROM_UVLO_FEEDRATE - 1) +#define EEPROM_UVLO_FAN_SPEED (EEPROM_UVLO_FEEDRATE - 1) #define EEPROM_FAN_CHECK_ENABLED (EEPROM_UVLO_FAN_SPEED - 1) #define EEPROM_UVLO_MESH_BED_LEVELING (EEPROM_FAN_CHECK_ENABLED - 9*2) #define EEPROM_UVLO_Z_MICROSTEPS (EEPROM_UVLO_MESH_BED_LEVELING - 2) // uint16_t (could be removed) @@ -407,12 +415,12 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP #define EEPROM_FREE_NR4 (EEPROM_UVLO_SAVED_SEGMENT_IDX - 1) // FREE EEPROM SPACE #define EEPROM_FREE_NR5 (EEPROM_FREE_NR4 - 1) // FREE EEPROM SPACE -// Crash detection mode EEPROM setting -#define EEPROM_CRASH_DET (EEPROM_FREE_NR5 - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-12) +// Crash detection mode EEPROM setting +#define EEPROM_CRASH_DET (EEPROM_FREE_NR5 - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-12) // Crash detection counter Y (last print) #define EEPROM_CRASH_COUNT_Y (EEPROM_CRASH_DET - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-15) -// Filament sensor on/off EEPROM setting -#define EEPROM_FSENSOR (EEPROM_CRASH_COUNT_Y - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-14) +// Filament sensor on/off EEPROM setting +#define EEPROM_FSENSOR (EEPROM_CRASH_COUNT_Y - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-14) // Crash detection counter X (last print) #define EEPROM_CRASH_COUNT_X (EEPROM_FSENSOR - 1) // uint8 (orig EEPROM_UVLO_MESH_BED_LEVELING-15) // Filament runout/error coutner (last print) @@ -442,7 +450,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP #define EEPROM_POWER_COUNT_TOT (EEPROM_FERROR_COUNT_TOT - 2) // uint16 //////////////////////////////////////// -// TMC2130 Accurate sensorless homing +// TMC2130 Accurate sensorless homing // X-axis home origin (stepper phase in microsteps, 0..63 for 16ustep resolution) #define EEPROM_TMC2130_HOME_X_ORIGIN (EEPROM_POWER_COUNT_TOT - 1) // uint8 @@ -507,7 +515,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP #define EEPROM_UVLO_MESH_BED_LEVELING_FULL (EEPROM_MMU_CUTTER_ENABLED - 12*12*2) //allow 12 calibration points for future expansion #define EEPROM_MBL_TYPE (EEPROM_UVLO_MESH_BED_LEVELING_FULL-1) //uint8_t for mesh bed leveling precision -#define EEPROM_MBL_MAGNET_ELIMINATION (EEPROM_MBL_TYPE -1) +#define EEPROM_MBL_MAGNET_ELIMINATION (EEPROM_MBL_TYPE -1) #define EEPROM_MBL_POINTS_NR (EEPROM_MBL_MAGNET_ELIMINATION -1) //uint8_t number of points in one exis for mesh bed leveling #define EEPROM_MBL_PROBE_NR (EEPROM_MBL_POINTS_NR-1) //number of measurements for each point diff --git a/Firmware/first_lay_cal.cpp b/Firmware/first_lay_cal.cpp index 5d7f0aa9b5..4e9d8ca075 100644 --- a/Firmware/first_lay_cal.cpp +++ b/Firmware/first_lay_cal.cpp @@ -4,7 +4,7 @@ //! @brief First layer (Z offset) calibration #include "first_lay_cal.h" -#include "Configuration_prusa.h" +#include "Configuration_var.h" #include "language.h" #include "Marlin.h" #include "cmdqueue.h" @@ -48,8 +48,8 @@ void lay1cal_load_filament(char *cmd_buffer, uint8_t filament) //! @brief Print intro line void lay1cal_intro_line() { - static const char cmd_intro_mmu_3[] PROGMEM = "G1 X55.0 E32.0 F1073.0"; - static const char cmd_intro_mmu_4[] PROGMEM = "G1 X5.0 E32.0 F1800.0"; + static const char cmd_intro_mmu_3[] PROGMEM = "G1 X55.0 E29.0 F1073.0"; + static const char cmd_intro_mmu_4[] PROGMEM = "G1 X5.0 E29.0 F1800.0"; static const char cmd_intro_mmu_5[] PROGMEM = "G1 X55.0 E8.0 F2000.0"; static const char cmd_intro_mmu_6[] PROGMEM = "G1 Z0.3 F1000.0"; static const char cmd_intro_mmu_7[] PROGMEM = "G92 E0.0"; diff --git a/Firmware/lcd.h b/Firmware/lcd.h index 20c05f3ef8..b7a8d28367 100644 --- a/Firmware/lcd.h +++ b/Firmware/lcd.h @@ -204,11 +204,12 @@ class LcdUpdateDisabler extern void lcd_set_custom_characters(void); extern void lcd_set_custom_characters_nextpage(void); -//! @brief Consume click event +//! @brief Consume click and longpress event inline void lcd_consume_click() { lcd_button_pressed = 0; lcd_buttons &= 0xff^EN_C; + lcd_longpress_trigger = 0; } diff --git a/Firmware/messages.cpp b/Firmware/messages.cpp index 6c68a9ea4f..bb6157b55d 100644 --- a/Firmware/messages.cpp +++ b/Firmware/messages.cpp @@ -1,8 +1,8 @@ //messages.c #include "language.h" -//this is because we need include Configuration_prusa.h (CUSTOM_MENDEL_NAME) -#include "Configuration_prusa.h" +//this is because we need CUSTOM_MENDEL_NAME +#include "Configuration_var.h" //internationalized messages const char MSG_ALWAYS[] PROGMEM_I1 = ISTR("Always"); ////MSG_ALWAYS c=6 @@ -172,6 +172,9 @@ extern const char MSG_THERMAL_ANOMALY[] PROGMEM_I1 = ISTR("THERMAL ANOMALY");/// extern const char MSG_LOAD_ALL[] PROGMEM_I1 = ISTR("Load All"); ////MSG_LOAD_ALL c=18 //not internationalized messages +#if 0 +const char MSG_FW_VERSION_BETA[] PROGMEM_N1 = "You are using a BETA firmware version! It is in a development state! Use this version with CAUTION as it may DAMAGE the printer!"; ////MSG_FW_VERSION_BETA c=20 r=8 +#endif const char MSG_SPOOL_JOIN[] PROGMEM_N1 = "SpoolJoin"; ////MSG_SPOOL_JOIN c=13 const char MSG_FIRMWARE[] PROGMEM_N1 = "Firmware"; ////MSG_FIRMWARE c=8 const char MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY[] PROGMEM_N1 = "FlashAir"; ////MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY c=8 diff --git a/Firmware/messages.h b/Firmware/messages.h index 4c1c72c584..6ef93700aa 100644 --- a/Firmware/messages.h +++ b/Firmware/messages.h @@ -76,7 +76,6 @@ extern const char MSG_NO[]; extern const char MSG_NOZZLE[]; extern const char MSG_PAPER[]; extern const char MSG_PAUSE_PRINT[]; -extern const char MSG_PINDA[]; extern const char MSG_PLACE_STEEL_SHEET[]; extern const char MSG_PLEASE_WAIT[]; extern const char MSG_POWER_FAILURES[]; @@ -90,7 +89,6 @@ extern const char MSG_REMOVE_STEEL_SHEET[]; extern const char MSG_RESET[]; extern const char MSG_RESUME_PRINT[]; extern const char MSG_RESUMING_PRINT[]; -extern const char MSG_SD_WORKDIR_FAIL[]; extern const char MSG_SELFTEST_PART_FAN[]; extern const char MSG_SELFTEST_EXTRUDER_FAN[]; extern const char MSG_SELFTEST_FAILED[]; @@ -130,24 +128,20 @@ extern const char MSG_WIZARD_WELCOME[]; extern const char MSG_WIZARD_WELCOME_SHIPPING[]; extern const char MSG_YES[]; extern const char MSG_V2_CALIBRATION[]; -extern const char MSG_WELCOME[]; extern const char MSG_OFF[]; extern const char MSG_ON[]; extern const char MSG_NA[]; -extern const char MSG_SPOOL_JOIN[]; extern const char MSG_CUTTER[]; extern const char MSG_NONE[]; extern const char MSG_WARN[]; extern const char MSG_STRICT[]; extern const char MSG_MODEL[]; -extern const char MSG_FIRMWARE[]; extern const char MSG_GCODE[]; extern const char MSG_GCODE_DIFF_PRINTER_CONTINUE[]; extern const char MSG_GCODE_DIFF_PRINTER_CANCELLED[]; extern const char MSG_NOZZLE_DIAMETER[]; extern const char MSG_MMU_MODE[]; extern const char MSG_SD_CARD[]; -extern const char MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY[]; extern const char MSG_SORT[]; extern const char MSG_SORT_TIME[]; extern const char MSG_SORT_ALPHA[]; @@ -182,6 +176,15 @@ extern const char MSG_THERMAL_ANOMALY[]; extern const char MSG_LOAD_ALL[]; //not internationalized messages +#if 0 +extern const char MSG_FW_VERSION_BETA[]; +#endif +extern const char MSG_SPOOL_JOIN[]; +extern const char MSG_FIRMWARE[]; +extern const char MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY[]; +extern const char MSG_PINDA[]; +extern const char MSG_WELCOME[]; +extern const char MSG_SD_WORKDIR_FAIL[]; extern const char MSG_BROWNOUT_RESET[]; extern const char MSG_EXTERNAL_RESET[]; extern const char MSG_FILE_SAVED[]; diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 95e234e746..714c833b7d 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -39,7 +39,10 @@ static constexpr float MMU2_LOAD_TO_NOZZLE_LENGTH = 87.0F + 5.0F; // - ToolChange shall not try to push filament into the very tip of the nozzle // to have some space for additional G-code to tune the extruded filament length // in the profile -static constexpr float MMU2_TOOL_CHANGE_LOAD_LENGTH = 30.0F; +// Beware - this value is used to initialize the MMU logic layer - it will be sent to the MMU upon line up (written into its 8bit register 0x0b) +// However - in the G-code we can get a request to set the extra load distance at runtime to something else (M708 A0xb Xsomething). +// The printer intercepts such a call and sets its extra load distance to match the new value as well. +static constexpr uint8_t MMU2_TOOL_CHANGE_LOAD_LENGTH = 5; // mm static constexpr float MMU2_LOAD_TO_NOZZLE_FEED_RATE = 20.0F; // mm/s static constexpr float MMU2_UNLOAD_TO_FINDA_FEED_RATE = 120.0F; // mm/s @@ -102,7 +105,7 @@ MMU2 mmu2; MMU2::MMU2() : is_mmu_error_monitor_active(false) - , logic(&mmu2Serial) + , logic(&mmu2Serial, MMU2_TOOL_CHANGE_LOAD_LENGTH) , extruder(MMU2_NO_TOOL) , tool_change_extruder(MMU2_NO_TOOL) , resume_position() @@ -197,6 +200,12 @@ bool MMU2::ReadRegister(uint8_t address){ bool MMU2::WriteRegister(uint8_t address, uint16_t data){ if( ! WaitForMMUReady()) return false; + + // special case - intercept requests of extra loading distance and perform the change even on the printer's side + if( address == 0x0b ){ + logic.PlanExtraLoadDistance(data); + } + logic.WriteRegister(address, data); // we may signal the accepted/rejected status of the response as return value of this function manage_response(false, false); return true; @@ -216,7 +225,7 @@ void MMU2::mmu_loop() { if (is_mmu_error_monitor_active){ // Call this every iteration to keep the knob rotation responsive // This includes when mmu_loop is called within manage_response - ReportErrorHook((uint16_t)lastErrorCode, mmu2.MMUCurrentErrorCode() == ErrorCode::OK ? ErrorSourcePrinter : ErrorSourceMMU); + ReportErrorHook((uint16_t)lastErrorCode); } avoidRecursion = false; @@ -380,6 +389,8 @@ bool MMU2::set_filament_type(uint8_t index, uint8_t type) { return false; // @@TODO - this is not supported in the new MMU yet + index = index; // @@TODO + type = type; // @@TODO // cmd_arg = filamentType; // command(MMU_CMD_F0 + index); @@ -571,10 +582,13 @@ void MMU2::SaveAndPark(bool move_axes, bool turn_off_nozzle) { raise_z(MMU_ERR_Z_PAUSE_LIFT); // move XY aside - current_position[X_AXIS] = MMU_ERR_X_PAUSE_POS; - current_position[Y_AXIS] = MMU_ERR_Y_PAUSE_POS; - plan_buffer_line_curposXYZE(NOZZLE_PARK_XY_FEEDRATE); - st_synchronize(); + if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) + { + current_position[X_AXIS] = MMU_ERR_X_PAUSE_POS; + current_position[Y_AXIS] = MMU_ERR_Y_PAUSE_POS; + plan_buffer_line_curposXYZE(NOZZLE_PARK_XY_FEEDRATE); + st_synchronize(); + } } if (turn_off_nozzle){ @@ -793,7 +807,7 @@ void MMU2::execute_extruder_sequence(const E_Step *sequence, uint8_t steps) { } } -void MMU2::ReportError(ErrorCode ec, uint8_t res) { +void MMU2::ReportError(ErrorCode ec, ErrorSource res) { // Due to a potential lossy error reporting layers linked to this hook // we'd better report everything to make sure especially the error states // do not get lost. @@ -819,13 +833,14 @@ void MMU2::ReportError(ErrorCode ec, uint8_t res) { break; } - ReportErrorHook((uint16_t)ec, res); - if( ec != lastErrorCode ){ // deduplicate: only report changes in error codes into the log lastErrorCode = ec; + lastErrorSource = res; LogErrorEvent_P( _O(PrusaErrorTitle(PrusaErrorCodeIndex((uint16_t)ec))) ); } + ReportErrorHook((uint16_t)ec); + static_assert(mmu2Magic[0] == 'M' && mmu2Magic[1] == 'M' && mmu2Magic[2] == 'U' @@ -900,8 +915,8 @@ void MMU2::OnMMUProgressMsgSame(ProgressCode pc){ loadFilamentStarted = false; // After the MMU knows the FSENSOR is triggered it will: // 1. Push the filament by additional 30mm (see fsensorToNozzle) - // 2. Disengage the idler and push another 5mm. - current_position[E_AXIS] += 30.0f + 2.0f; + // 2. Disengage the idler and push another 2mm. + current_position[E_AXIS] += logic.ExtraLoadDistance() + 2; plan_buffer_line_curposXYZE(MMU2_LOAD_TO_NOZZLE_FEED_RATE); break; case FilamentState::NOT_PRESENT: diff --git a/Firmware/mmu2.h b/Firmware/mmu2.h index 0056537264..6dfced7f4d 100644 --- a/Firmware/mmu2.h +++ b/Firmware/mmu2.h @@ -70,9 +70,10 @@ class MMU2 { }; /// Source of operation error - enum ReportErrorSource: uint8_t { + enum ErrorSource: uint8_t { ErrorSourcePrinter = 0, ErrorSourceMMU = 1, + ErrorSourceNone = 0xFF, }; /// Perform a reset of the MMU @@ -164,6 +165,9 @@ class MMU2 { /// @returns Current error code inline ErrorCode MMUCurrentErrorCode() const { return logic.Error(); } + /// @returns Last error source + inline ErrorSource MMULastErrorSource() const { return lastErrorSource; } + /// @returns the version of the connected MMU FW. /// In the future we'll return the trully detected FW version Version GetMMUFWVersion()const { @@ -218,7 +222,7 @@ class MMU2 { /// Reports an error into attached ExtUIs /// @param ec error code, see ErrorCode /// @param res reporter error source, is either Printer (0) or MMU (1) - void ReportError(ErrorCode ec, uint8_t res); + void ReportError(ErrorCode ec, ErrorSource res); /// Reports progress of operations into attached ExtUIs /// @param pc progress code, see ProgressCode @@ -264,6 +268,7 @@ class MMU2 { ProgressCode lastProgressCode = ProgressCode::OK; ErrorCode lastErrorCode = ErrorCode::MMU_NOT_RESPONDING; + ErrorSource lastErrorSource = ErrorSource::ErrorSourceNone; Buttons lastButton = Buttons::NoButton; StepStatus logicStepLastStatus; @@ -279,9 +284,8 @@ class MMU2 { /// unlike the mid-print ToolChange commands, which only load the first ~30mm and then the G-code takes over. bool loadingToNozzle; - uint8_t retryAttempts; - bool inAutoRetry; + uint8_t retryAttempts; }; /// following Marlin's way of doing stuff - one and only instance of MMU implementation in the code base diff --git a/Firmware/mmu2/error_codes.h b/Firmware/mmu2/error_codes.h index 0dcb305732..7709246533 100644 --- a/Firmware/mmu2/error_codes.h +++ b/Firmware/mmu2/error_codes.h @@ -37,11 +37,11 @@ enum class ErrorCode : uint_fast16_t { HOMING_FAILED = 0x8007, ///< generic homing failed error - always reported with the corresponding axis bit set (Idler or Selector) as follows: HOMING_SELECTOR_FAILED = HOMING_FAILED | TMC_SELECTOR_BIT, ///< E32903 the Selector was unable to home properly - that means something is blocking its movement HOMING_IDLER_FAILED = HOMING_FAILED | TMC_IDLER_BIT, ///< E33031 the Idler was unable to home properly - that means something is blocking its movement - STALLED_PULLEY = HOMING_FAILED | TMC_PULLEY_BIT, ///< E32839 for the Pulley "homing" means just stallguard detected during Pulley's operation (Pulley doesn't home) + STALLED_PULLEY = HOMING_FAILED | TMC_PULLEY_BIT, ///< E32839 for the Pulley "homing" means just StallGuard detected during Pulley's operation (Pulley doesn't home) FINDA_VS_EEPROM_DISREPANCY = 0x8008, ///< E32776 FINDA is pressed but we have no such record in EEPROM - this can only happen at the start of the MMU and can be resolved by issuing an Unload command - FSENSOR_TOO_EARLY = 0x8009, ///< E32777 FSensor triggered while doing FastFeedToExtruder - that means either: + FSENSOR_TOO_EARLY = 0x8009, ///< E32777 FSensor triggered while doing FastFeedToBondtech - that means either: ///< - the PTFE is too short ///< - a piece of filament was left inside - pushed in front of the loaded filament causing the fsensor trigger too early ///< - fsensor is faulty producing bogus triggers @@ -60,7 +60,7 @@ enum class ErrorCode : uint_fast16_t { /// TMC driver init error - TMC dead or bad communication /// - E33344 Pulley TMC driver - /// - E33404 Selector TMC driver + /// - E33408 Selector TMC driver /// - E33536 Idler TMC driver /// - E33728 All 3 TMC driver TMC_IOIN_MISMATCH = 0x8200, @@ -105,5 +105,12 @@ enum class ErrorCode : uint_fast16_t { /// - E49280 Selector TMC driver /// - E49408 Idler TMC driver /// - E49600 All 3 TMC driver - TMC_OVER_TEMPERATURE_ERROR = 0xC000 + TMC_OVER_TEMPERATURE_ERROR = 0xC000, + + /// TMC driver - IO pins are unreliable. While in theory it's recoverable, in practice it most likely + /// means your hardware is borked (we can't command the drivers reliably via STEP/EN/DIR due to electrical + /// issues or hardware fault. Possible "fixable" cause is undervoltage on the 5v logic line. + /// Unfixable possible cause: bad or cracked solder joints on the PCB, failed shift register, failed driver. + MMU_SOLDERING_NEEDS_ATTENTION = 0xC200, + }; diff --git a/Firmware/mmu2/errors_list.h b/Firmware/mmu2/errors_list.h index 322bf0356d..a6d0e7b8aa 100644 --- a/Firmware/mmu2/errors_list.h +++ b/Firmware/mmu2/errors_list.h @@ -54,6 +54,9 @@ typedef enum : uint16_t { ERR_ELECTRICAL_SELECTOR_TMC_DRIVER_SHORTED = 314, ERR_ELECTRICAL_IDLER_TMC_DRIVER_SHORTED = 324, + ERR_ELECTRICAL_PULLEY_SELFTEST_FAILED = 305, + ERR_ELECTRICAL_SELECTOR_SELFTEST_FAILED = 315, + ERR_ELECTRICAL_IDLER_SELFTEST_FAILED = 325, ERR_CONNECT = 400, ERR_CONNECT_MMU_NOT_RESPONDING = 401, @@ -104,6 +107,9 @@ static const constexpr uint16_t errorCodes[] PROGMEM = { ERR_ELECTRICAL_PULLEY_TMC_DRIVER_SHORTED, ERR_ELECTRICAL_SELECTOR_TMC_DRIVER_SHORTED, ERR_ELECTRICAL_IDLER_TMC_DRIVER_SHORTED, + ERR_ELECTRICAL_PULLEY_SELFTEST_FAILED, + ERR_ELECTRICAL_SELECTOR_SELFTEST_FAILED, + ERR_ELECTRICAL_IDLER_SELFTEST_FAILED, ERR_CONNECT_MMU_NOT_RESPONDING, ERR_CONNECT_COMMUNICATION_ERROR, ERR_SYSTEM_FILAMENT_ALREADY_LOADED, @@ -143,6 +149,7 @@ static const char MSG_TITLE_TMC_UNDERVOLTAGE_ERROR[] PROGMEM_I1 = ISTR("TMC UND static const char MSG_TITLE_TMC_DRIVER_SHORTED[] PROGMEM_I1 = ISTR("TMC DRIVER SHORTED"); ////MSG_TITLE_TMC_DRIVER_SHORTED c=20 //static const char MSG_TITLE_TMC_DRIVER_SHORTED[] PROGMEM_I1 = ISTR("TMC DRIVER SHORTED"); //static const char MSG_TITLE_TMC_DRIVER_SHORTED[] PROGMEM_I1 = ISTR("TMC DRIVER SHORTED"); +static const char MSG_TITLE_SELFTEST_FAILED[] PROGMEM_I1 = ISTR("MMU SELFTEST FAILED"); ////MSG_TITLE_SELFTEST_FAILED c=20 static const char MSG_TITLE_MMU_NOT_RESPONDING[] PROGMEM_I1 = ISTR("MMU NOT RESPONDING"); ////MSG_TITLE_MMU_NOT_RESPONDING c=20 static const char MSG_TITLE_COMMUNICATION_ERROR[] PROGMEM_I1 = ISTR("COMMUNICATION ERROR"); ////MSG_TITLE_COMMUNICATION_ERROR c=20 static const char MSG_TITLE_FIL_ALREADY_LOADED[] PROGMEM_I1 = ISTR("FILAMENT ALREADY LOA"); ////MSG_TITLE_FIL_ALREADY_LOADED c=20 @@ -181,6 +188,9 @@ static const char * const errorTitles [] PROGMEM = { _R(MSG_TITLE_TMC_DRIVER_SHORTED), _R(MSG_TITLE_TMC_DRIVER_SHORTED), _R(MSG_TITLE_TMC_DRIVER_SHORTED), + _R(MSG_TITLE_SELFTEST_FAILED), + _R(MSG_TITLE_SELFTEST_FAILED), + _R(MSG_TITLE_SELFTEST_FAILED), _R(MSG_TITLE_MMU_NOT_RESPONDING), _R(MSG_TITLE_COMMUNICATION_ERROR), _R(MSG_TITLE_FIL_ALREADY_LOADED), @@ -261,6 +271,9 @@ static const char * const errorDescs[] PROGMEM = { _R(MSG_DESC_TMC), // descPULLEY_TMC_DRIVER_SHORTED _R(MSG_DESC_TMC), // descSELECTOR_TMC_DRIVER_SHORTED _R(MSG_DESC_TMC), // descIDLER_TMC_DRIVER_SHORTED + _R(MSG_DESC_TMC), // descPULLEY_SELFTEST_FAILED + _R(MSG_DESC_TMC), // descSELECTOR_SELFTEST_FAILED + _R(MSG_DESC_TMC), // descIDLER_SELFTEST_FAILED _R(MSG_DESC_MMU_NOT_RESPONDING), _R(MSG_DESC_COMMUNICATION_ERROR), _R(MSG_DESC_FILAMENT_ALREADY_LOADED), @@ -273,18 +286,19 @@ static const char * const errorDescs[] PROGMEM = { // we have max 3 buttons/operations to select from // one of them is "More" to show the explanation text normally hidden in the next screens. +// It is displayed with W (Double down arrow, special character from CGRAM) // 01234567890123456789 -// >bttxt >bttxt>MoreW -// Therefore at least some of the buttons, which can occur on the screen together, need to be 5-chars long max @@TODO. +// >bttxt >bttxt >W +// Therefore at least some of the buttons, which can occur on the screen together, can only be 8-chars long max @@TODO. // Beware - we only have space for 2 buttons on the LCD while the MMU has 3 buttons // -> the left button on the MMU is not used/rendered on the LCD (it is also almost unused on the MMU side) -static const char MSG_BTN_RETRY[] PROGMEM_I1 = ISTR("Retry"); ////MSG_BTN_RETRY c=5 -static const char MSG_BTN_CONTINUE[] PROGMEM_I1 = ISTR("Done"); ////MSG_BTN_CONTINUE c=5 +static const char MSG_BTN_RETRY[] PROGMEM_I1 = ISTR("Retry"); ////MSG_BTN_RETRY c=8 +static const char MSG_BTN_CONTINUE[] PROGMEM_I1 = ISTR("Done"); ////MSG_BTN_CONTINUE c=8 static const char MSG_BTN_RESTART_MMU[] PROGMEM_I1 = ISTR("Reset MMU"); ////MSG_BTN_RESTART_MMU c=9 -static const char MSG_BTN_UNLOAD[] PROGMEM_I1 = ISTR("Unload"); ////MSG_BTN_UNLOAD c=6 -static const char MSG_BTN_STOP[] PROGMEM_I1 = ISTR("Stop"); ////MSG_BTN_STOP c=5 +static const char MSG_BTN_UNLOAD[] PROGMEM_I1 = ISTR("Unload"); ////MSG_BTN_UNLOAD c=8 +static const char MSG_BTN_STOP[] PROGMEM_I1 = ISTR("Stop"); ////MSG_BTN_STOP c=8 static const char MSG_BTN_DISABLE_MMU[] PROGMEM_I1 = ISTR("Disable"); ////MSG_BTN_DISABLE_MMU c=9 -static const char MSG_BTN_MORE[] PROGMEM_I1 = ISTR("More\x06"); ////MSG_BTN_MORE c=5 +static const char MSG_BTN_MORE[] PROGMEM_N1 = ISTR("\x06"); ////MSG_BTN_MORE c=8 // Used to parse the buttons from Btns(). static const char * const btnOperation[] PROGMEM = { @@ -335,6 +349,9 @@ static const uint8_t errorButtons[] PROGMEM = { Btns(ButtonOperations::RestartMMU, ButtonOperations::NoOperation),//PULLEY_TMC_DRIVER_SHORTED Btns(ButtonOperations::RestartMMU, ButtonOperations::NoOperation),//SELECTOR_TMC_DRIVER_SHORTED Btns(ButtonOperations::RestartMMU, ButtonOperations::NoOperation),//IDLER_TMC_DRIVER_SHORTED + Btns(ButtonOperations::RestartMMU, ButtonOperations::NoOperation),//PULLEY_SELFTEST_FAILED + Btns(ButtonOperations::RestartMMU, ButtonOperations::NoOperation),//SELECTOR_SELFTEST_FAILED + Btns(ButtonOperations::RestartMMU, ButtonOperations::NoOperation),//IDLER_SELFTEST_FAILED Btns(ButtonOperations::RestartMMU, ButtonOperations::NoOperation),//MMU_NOT_RESPONDING Btns(ButtonOperations::RestartMMU, ButtonOperations::NoOperation),//COMMUNICATION_ERROR diff --git a/Firmware/mmu2_error_converter.cpp b/Firmware/mmu2_error_converter.cpp index fd000226f6..49f476adcc 100644 --- a/Firmware/mmu2_error_converter.cpp +++ b/Firmware/mmu2_error_converter.cpp @@ -79,6 +79,20 @@ uint8_t PrusaErrorCodeIndex(uint16_t ec) { case (uint16_t)ErrorCode::FINDA_VS_EEPROM_DISREPANCY: return FindErrorIndex(ERR_SYSTEM_UNLOAD_MANUALLY); } + + // Electrical issues which can be detected somehow. + // Need to be placed before TMC-related errors in order to process couples of error bits between single ones + // and to keep the code size down. + if (ec & (uint16_t)ErrorCode::TMC_PULLEY_BIT) { + if ((ec & (uint16_t)ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION) == (uint16_t)ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION) + return FindErrorIndex(ERR_ELECTRICAL_PULLEY_SELFTEST_FAILED); + } else if (ec & (uint16_t)ErrorCode::TMC_SELECTOR_BIT) { + if ((ec & (uint16_t)ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION) == (uint16_t)ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION) + return FindErrorIndex(ERR_ELECTRICAL_SELECTOR_SELFTEST_FAILED); + } else if (ec & (uint16_t)ErrorCode::TMC_IDLER_BIT) { + if ((ec & (uint16_t)ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION) == (uint16_t)ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION) + return FindErrorIndex(ERR_ELECTRICAL_IDLER_SELFTEST_FAILED); + } // TMC-related errors - multiple of these can occur at once // - in such a case we report the first which gets found/converted into Prusa-Error-Codes (usually the fact, that one TMC has an issue is serious enough) @@ -132,24 +146,24 @@ uint16_t PrusaErrorCode(uint8_t i){ return pgm_read_word(errorCodes + i); } -const char * const PrusaErrorTitle(uint8_t i){ - return (const char * const)pgm_read_ptr(errorTitles + i); +const char * PrusaErrorTitle(uint8_t i){ + return (const char *)pgm_read_ptr(errorTitles + i); } -const char * const PrusaErrorDesc(uint8_t i){ - return (const char * const)pgm_read_ptr(errorDescs + i); +const char * PrusaErrorDesc(uint8_t i){ + return (const char *)pgm_read_ptr(errorDescs + i); } uint8_t PrusaErrorButtons(uint8_t i){ return pgm_read_byte(errorButtons + i); } -const char * const PrusaErrorButtonTitle(uint8_t bi){ +const char * PrusaErrorButtonTitle(uint8_t bi){ // -1 represents the hidden NoOperation button which is not drawn in any way - return (const char * const)pgm_read_ptr(btnOperation + bi - 1); + return (const char *)pgm_read_ptr(btnOperation + bi - 1); } -const char * const PrusaErrorButtonMore(){ +const char * PrusaErrorButtonMore(){ return _R(MSG_BTN_MORE); } diff --git a/Firmware/mmu2_error_converter.h b/Firmware/mmu2_error_converter.h index 597cc35a5d..0e158aa2f7 100644 --- a/Firmware/mmu2_error_converter.h +++ b/Firmware/mmu2_error_converter.h @@ -11,11 +11,11 @@ uint8_t PrusaErrorCodeIndex(uint16_t ec); /// @returns pointer to a PROGMEM string representing the Title of the Prusa-Error-Codes error /// @param i index of the error - obtained by calling ErrorCodeIndex -const char * const PrusaErrorTitle(uint8_t i); +const char * PrusaErrorTitle(uint8_t i); /// @returns pointer to a PROGMEM string representing the multi-page Description of the Prusa-Error-Codes error /// @param i index of the error - obtained by calling ErrorCodeIndex -const char * const PrusaErrorDesc(uint8_t i); +const char * PrusaErrorDesc(uint8_t i); /// @returns the actual numerical value of the Prusa-Error-Codes error /// @param i index of the error - obtained by calling ErrorCodeIndex @@ -27,10 +27,10 @@ uint8_t PrusaErrorButtons(uint8_t i); /// @returns pointer to a PROGMEM string representing the Title of a button /// @param i index of the error - obtained by calling PrusaErrorButtons + extracting low or high nibble from the Btns pair -const char * const PrusaErrorButtonTitle(uint8_t bi); +const char * PrusaErrorButtonTitle(uint8_t bi); /// @returns pointer to a PROGMEM string representing the "More" button -const char * const PrusaErrorButtonMore(); +const char * PrusaErrorButtonMore(); /// Sets the selected button for later pick-up by the MMU state machine. /// Used to save the GUI selection/decoupling diff --git a/Firmware/mmu2_power.cpp b/Firmware/mmu2_power.cpp index a0359f0168..ed9f8adb73 100644 --- a/Firmware/mmu2_power.cpp +++ b/Firmware/mmu2_power.cpp @@ -1,5 +1,5 @@ #include "mmu2_power.h" -#include "Configuration_prusa.h" +#include "Configuration_var.h" #include "pins.h" #include "fastio.h" #include diff --git a/Firmware/mmu2_progress_converter.cpp b/Firmware/mmu2_progress_converter.cpp index b7d3fcf343..b44951385d 100644 --- a/Firmware/mmu2_progress_converter.cpp +++ b/Firmware/mmu2_progress_converter.cpp @@ -62,11 +62,11 @@ static const char * const progressTexts[] PROGMEM = { _R(MSG_PROGRESS_FEED_FSENSOR) }; -const char * const ProgressCodeToText(uint16_t pc){ +const char * ProgressCodeToText(uint16_t pc){ // @@TODO ?? a better fallback option? return ( pc <= (sizeof(progressTexts) / sizeof(progressTexts[0])) ) - ? static_cast(pgm_read_ptr(&progressTexts[pc])) - : static_cast(pgm_read_ptr(&progressTexts[0])); + ? static_cast(pgm_read_ptr(&progressTexts[pc])) + : static_cast(pgm_read_ptr(&progressTexts[0])); } } // namespace MMU2 diff --git a/Firmware/mmu2_progress_converter.h b/Firmware/mmu2_progress_converter.h index 72dcc031ba..19cb1e3fc5 100644 --- a/Firmware/mmu2_progress_converter.h +++ b/Firmware/mmu2_progress_converter.h @@ -4,6 +4,6 @@ namespace MMU2 { -const char * const ProgressCodeToText(uint16_t pc); +const char * ProgressCodeToText(uint16_t pc); } diff --git a/Firmware/mmu2_protocol.cpp b/Firmware/mmu2_protocol.cpp index 16fe69f4ab..c794432383 100644 --- a/Firmware/mmu2_protocol.cpp +++ b/Firmware/mmu2_protocol.cpp @@ -112,6 +112,10 @@ DecodeStatus Protocol::DecodeRequest(uint8_t c) { rqState = RequestStates::Code; return DecodeStatus::MessageCompleted; } + } else { + requestMsg.code = RequestMsgCodes::unknown; + rqState = RequestStates::Error; + return DecodeStatus::Error; } default: //case error: if (IsNewLine(c)) { diff --git a/Firmware/mmu2_protocol_logic.cpp b/Firmware/mmu2_protocol_logic.cpp index ce1cecebc1..b2fbc5c830 100644 --- a/Firmware/mmu2_protocol_logic.cpp +++ b/Firmware/mmu2_protocol_logic.cpp @@ -6,7 +6,22 @@ namespace MMU2 { -static const uint8_t supportedMmuFWVersion[3] PROGMEM = { 2, 1, 3 }; +static const uint8_t supportedMmuFWVersion[3] PROGMEM = { 2, 1, 4 }; + +const uint8_t ProtocolLogic::regs8Addrs[ProtocolLogic::regs8Count] PROGMEM = { + 8, // FINDA state + 0x1b, // Selector slot + 0x1c, // Idler slot +}; + +const uint8_t ProtocolLogic::regs16Addrs[ProtocolLogic::regs16Count] PROGMEM = { + 4, // MMU errors - aka statistics + 0x1a, // Pulley position [mm] +}; + +const uint8_t ProtocolLogic::initRegs8Addrs[ProtocolLogic::initRegs8Count] PROGMEM = { + 0x0b, // extra load distance +}; void ProtocolLogic::CheckAndReportAsyncEvents() { // even when waiting for a query period, we need to report a change in filament sensor's state @@ -22,9 +37,51 @@ void ProtocolLogic::SendQuery() { scopeState = ScopeState::QuerySent; } -void ProtocolLogic::SendFINDAQuery() { - SendMsg(RequestMsg(RequestMsgCodes::Finda, 0)); - scopeState = ScopeState::FINDAReqSent; +void ProtocolLogic::StartReading8bitRegisters() { + regIndex = 0; + SendReadRegister(pgm_read_byte(regs8Addrs + regIndex), ScopeState::Reading8bitRegisters); +} + +void ProtocolLogic::ProcessRead8bitRegister(){ + regs8[regIndex] = rsp.paramValue; + ++regIndex; + if(regIndex >= regs8Count){ + // proceed with reading 16bit registers + StartReading16bitRegisters(); + } else { + SendReadRegister(pgm_read_byte(regs8Addrs + regIndex), ScopeState::Reading8bitRegisters); + } +} + +void ProtocolLogic::StartReading16bitRegisters() { + regIndex = 0; + SendReadRegister(pgm_read_byte(regs16Addrs + regIndex), ScopeState::Reading16bitRegisters); +} + +ProtocolLogic::ScopeState __attribute__((noinline)) ProtocolLogic::ProcessRead16bitRegister(ProtocolLogic::ScopeState stateAtEnd){ + regs16[regIndex] = rsp.paramValue; + ++regIndex; + if(regIndex >= regs16Count){ + return stateAtEnd; + } else { + SendReadRegister(pgm_read_byte(regs16Addrs + regIndex), ScopeState::Reading16bitRegisters); + } + return ScopeState::Reading16bitRegisters; +} + +void ProtocolLogic::StartWritingInitRegisters() { + regIndex = 0; + SendWriteRegister(pgm_read_byte(initRegs8Addrs + regIndex), initRegs8[regIndex], ScopeState::WritingInitRegisters); +} + +bool __attribute__((noinline)) ProtocolLogic::ProcessWritingInitRegister(){ + ++regIndex; + if(regIndex >= initRegs8Count){ + return true; + } else { + SendWriteRegister(pgm_read_byte(initRegs8Addrs + regIndex), initRegs8[regIndex], ScopeState::WritingInitRegisters); + } + return false; } void ProtocolLogic::SendAndUpdateFilamentSensor() { @@ -224,9 +281,12 @@ StepStatus ProtocolLogic::StartSeqStep() { SendVersion(3); } else { mmuFwVersionBuild = rsp.paramValue; // just register the build number - // Start General Interrogation after line up. - // For now we just send the state of the filament sensor, but we may request - // data point states from the MMU as well. TBD in the future, especially with another protocol + // Start General Interrogation after line up - initial parametrization is started + StartWritingInitRegisters(); + } + return Processing; + case ScopeState::WritingInitRegisters: + if( ProcessWritingInitRegister() ){ SendAndUpdateFilamentSensor(); } return Processing; @@ -313,14 +373,13 @@ StepStatus ProtocolLogic::CommandStep() { case ScopeState::QuerySent: return ProcessCommandQueryResponse(); case ScopeState::FilamentSensorStateSent: - SendFINDAQuery(); + StartReading8bitRegisters(); return Processing; - case ScopeState::FINDAReqSent: - findaPressed = rsp.paramValue; - SendReadRegister(4, ScopeState::StatisticsSent); + case ScopeState::Reading8bitRegisters: + ProcessRead8bitRegister(); return Processing; - case ScopeState::StatisticsSent: - scopeState = ScopeState::Wait; + case ScopeState::Reading16bitRegisters: + scopeState = ProcessRead16bitRegister(ScopeState::Wait); return Processing; case ScopeState::ButtonSent: if (rsp.paramCode == ResponseMsgParamCodes::Accepted) { @@ -371,7 +430,7 @@ StepStatus ProtocolLogic::IdleStep() { // The user pushed a button on the MMU. Save it, do what we need to do // to prepare, then pass it back to the MMU so it can work its magic. buttonCode = static_cast(rsp.paramValue); - SendFINDAQuery(); + StartReading8bitRegisters(); return ButtonPushed; case ResponseMsgParamCodes::Processing: // @@TODO we may actually use this branch to report progress of manual operation on the MMU @@ -382,29 +441,27 @@ StepStatus ProtocolLogic::IdleStep() { break; default: errorCode = static_cast(rsp.paramValue); - SendFINDAQuery(); // continue Idle state without restarting the communication + StartReading8bitRegisters(); // continue Idle state without restarting the communication return CommandError; } break; default: return ProtocolError; } - SendFINDAQuery(); + StartReading8bitRegisters(); return Processing; - case ScopeState::FINDAReqSent: - findaPressed = rsp.paramValue; - SendReadRegister(4, ScopeState::StatisticsSent); + case ScopeState::Reading8bitRegisters: + ProcessRead8bitRegister(); return Processing; - case ScopeState::StatisticsSent: - failStatistics = rsp.paramValue; - scopeState = ScopeState::Ready; - return Finished; + case ScopeState::Reading16bitRegisters: + scopeState = ProcessRead16bitRegister(ScopeState::Ready); + return scopeState == ScopeState::Ready ? Finished : Processing; case ScopeState::ButtonSent: if (rsp.paramCode == ResponseMsgParamCodes::Accepted) { // Button was accepted, decrement the retry. mmu2.DecrementRetryAttempts(); } - SendFINDAQuery(); + StartReading8bitRegisters(); return Processing; case ScopeState::ReadRegisterSent: if (rsp.paramCode == ResponseMsgParamCodes::Accepted) { @@ -430,7 +487,7 @@ StepStatus ProtocolLogic::IdleStep() { return Finished; } -ProtocolLogic::ProtocolLogic(MMU2Serial *uart) +ProtocolLogic::ProtocolLogic(MMU2Serial *uart, uint8_t extraLoadDistance) : currentScope(Scope::Stopped) , scopeState(ScopeState::Ready) , plannedRq(RequestMsgCodes::unknown, 0) @@ -444,8 +501,10 @@ ProtocolLogic::ProtocolLogic(MMU2Serial *uart) , progressCode(ProgressCode::OK) , buttonCode(NoButton) , lastFSensor((uint8_t)WhereIsFilament()) - , findaPressed(false) - , failStatistics(0) + , regs8 { 0, 0, 0 } + , regs16 { 0, 0 } + , initRegs8 { extraLoadDistance } + , regIndex(0) , mmuFwVersion { 0, 0, 0 } {} diff --git a/Firmware/mmu2_protocol_logic.h b/Firmware/mmu2_protocol_logic.h index ea13724063..35000c031a 100644 --- a/Firmware/mmu2_protocol_logic.h +++ b/Firmware/mmu2_protocol_logic.h @@ -1,5 +1,6 @@ #pragma once #include +#include // #include //@@TODO Don't we have STL for AVR somewhere? template class array { @@ -70,7 +71,7 @@ class DropOutFilter { /// Logic layer of the MMU vs. printer communication protocol class ProtocolLogic { public: - ProtocolLogic(MMU2Serial *uart); + ProtocolLogic(MMU2Serial *uart, uint8_t extraLoadDistance); /// Start/Enable communication with the MMU void Start(); @@ -91,6 +92,17 @@ class ProtocolLogic { void ReadRegister(uint8_t address); void WriteRegister(uint8_t address, uint16_t data); + /// Sets the extra load distance to be reported to the MMU. + /// Beware - this call doesn't send anything to the MMU. + /// The MMU gets the newly set value either by a communication restart or via an explicit WriteRegister call + inline void PlanExtraLoadDistance(uint8_t eld_mm){ + initRegs8[0] = eld_mm; + } + /// @returns the currently preset extra load distance + inline uint8_t ExtraLoadDistance()const { + return initRegs8[0]; + } + /// Step the state machine StepStatus Step(); @@ -110,11 +122,11 @@ class ProtocolLogic { } inline bool FindaPressed() const { - return findaPressed; + return regs8[0]; } inline uint16_t FailStatistics() const { - return failStatistics; + return regs16[0]; } inline uint8_t MmuFwVersionMajor() const { @@ -187,10 +199,11 @@ class ProtocolLogic { QuerySent, CommandSent, FilamentSensorStateSent, - FINDAReqSent, - StatisticsSent, + Reading8bitRegisters, + Reading16bitRegisters, + WritingInitRegisters, ButtonSent, - ReadRegisterSent, + ReadRegisterSent, // standalone requests for reading registers - from higher layers WriteRegisterSent, // States which do not expect a message - MSb set @@ -217,7 +230,13 @@ class ProtocolLogic { /// So far, the only such a case is the filament sensor, but there can be more like this in the future. void CheckAndReportAsyncEvents(); void SendQuery(); - void SendFINDAQuery(); + void StartReading8bitRegisters(); + void ProcessRead8bitRegister(); + void StartReading16bitRegisters(); + ScopeState ProcessRead16bitRegister(ProtocolLogic::ScopeState stateAtEnd); + void StartWritingInitRegisters(); + /// @returns true when all registers have been written into the MMU + bool ProcessWritingInitRegister(); void SendAndUpdateFilamentSensor(); void SendButton(uint8_t btn); void SendVersion(uint8_t stage); @@ -278,7 +297,7 @@ class ProtocolLogic { State state; ///< internal state of ProtocolLogic Protocol protocol; ///< protocol codec - + array lastReceivedBytes; ///< remembers the last few bytes of incoming communication for diagnostic purposes uint8_t lrb; @@ -290,8 +309,25 @@ class ProtocolLogic { uint8_t lastFSensor; ///< last state of filament sensor - bool findaPressed; - uint16_t failStatistics; + // 8bit registers + static constexpr uint8_t regs8Count = 3; + static_assert(regs8Count > 0); // code is not ready for empty lists of registers + static const uint8_t regs8Addrs[regs8Count] PROGMEM; + uint8_t regs8[regs8Count]; + + // 16bit registers + static constexpr uint8_t regs16Count = 2; + static_assert(regs16Count > 0); // code is not ready for empty lists of registers + static const uint8_t regs16Addrs[regs16Count] PROGMEM; + uint16_t regs16[regs16Count]; + + // 8bit init values to be sent to the MMU after line up + static constexpr uint8_t initRegs8Count = 1; + static_assert(initRegs8Count > 0); // code is not ready for empty lists of registers + static const uint8_t initRegs8Addrs[initRegs8Count] PROGMEM; + uint8_t initRegs8[initRegs8Count]; + + uint8_t regIndex; uint8_t mmuFwVersion[3]; uint16_t mmuFwVersionBuild; diff --git a/Firmware/mmu2_reporting.cpp b/Firmware/mmu2_reporting.cpp index 37b316d4f7..df32fab211 100644 --- a/Firmware/mmu2_reporting.cpp +++ b/Firmware/mmu2_reporting.cpp @@ -11,14 +11,14 @@ namespace MMU2 { -const char * const ProgressCodeToText(uint16_t pc); // we may join progress convertor and reporter together +const char * ProgressCodeToText(uint16_t pc); // we may join progress convertor and reporter together -void BeginReport(CommandInProgress cip, uint16_t ec) { +void BeginReport(CommandInProgress /*cip*/, uint16_t ec) { custom_message_type = CustomMsg::MMUProgress; lcd_setstatuspgm( _T(ProgressCodeToText(ec)) ); } -void EndReport(CommandInProgress cip, uint16_t ec) { +void EndReport(CommandInProgress /*cip*/, uint16_t /*ec*/) { // clear the status msg line - let the printed filename get visible again custom_message_type = CustomMsg::Status; } @@ -52,7 +52,7 @@ static void ReportErrorHookStaticRender(uint8_t ei) { //! |MMU FW update needed| <- title/header of the error: max 20 characters //! |prusa3d.com/ERR04504| <- URL 20 characters //! |FI:1 FS:1 5>3 t201°| <- status line, t is thermometer symbol - //! |>Retry >Done >MoreW | <- buttons + //! |>Retry >Done >W| <- buttons bool two_choices = false; // Read and determine what operations should be shown on the menu @@ -74,9 +74,9 @@ static void ReportErrorHookStaticRender(uint8_t ei) { lcd_printf_P(PSTR("%.20S\nprusa3d.com/ERR04%hu"), _T(PrusaErrorTitle(ei)), PrusaErrorCode(ei) ); ReportErrorHookSensorLineRender(); - + // Render the choices - lcd_show_choices_prompt_P(two_choices ? LCD_LEFT_BUTTON_CHOICE : LCD_MIDDLE_BUTTON_CHOICE, _T(PrusaErrorButtonTitle(button_op_middle)), _T(two_choices ? PrusaErrorButtonMore() : PrusaErrorButtonTitle(button_op_right)), two_choices ? 10 : 7, two_choices ? nullptr : _T(PrusaErrorButtonMore())); + lcd_show_choices_prompt_P(two_choices ? LCD_LEFT_BUTTON_CHOICE : LCD_MIDDLE_BUTTON_CHOICE, _T(PrusaErrorButtonTitle(button_op_middle)), _T(two_choices ? PrusaErrorButtonMore() : PrusaErrorButtonTitle(button_op_right)), two_choices ? 18 : 9, two_choices ? nullptr : _T(PrusaErrorButtonMore())); } extern void ReportErrorHookSensorLineRender() @@ -166,12 +166,13 @@ static uint8_t ReportErrorHookMonitor(uint8_t ei) { lcd_print(current_selection == LCD_LEFT_BUTTON_CHOICE ? '>': ' '); if (two_choices == false) { - lcd_set_cursor(7, 3); + lcd_set_cursor(9, 3); lcd_print(current_selection == LCD_MIDDLE_BUTTON_CHOICE ? '>': ' '); - lcd_set_cursor(13, 3); + lcd_set_cursor(18, 3); lcd_print(current_selection == LCD_RIGHT_BUTTON_CHOICE ? '>': ' '); } else { - lcd_set_cursor(10, 3); + // More button for two button screen + lcd_set_cursor(18, 3); lcd_print(current_selection == LCD_MIDDLE_BUTTON_CHOICE ? '>': ' '); } // Consume rotation event and make feedback sound @@ -216,8 +217,8 @@ enum class ReportErrorHookStates : uint8_t { enum ReportErrorHookStates ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN; -void ReportErrorHook(uint16_t ec, uint8_t res) { - if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK && res == MMU2::ErrorSourceMMU) +void ReportErrorHook(uint16_t ec) { + if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK && mmu2.MMULastErrorSource() == MMU2::ErrorSourceMMU) { // If the error code suddenly changes to OK, that means // a button was pushed on the MMU and the LCD should diff --git a/Firmware/mmu2_reporting.h b/Firmware/mmu2_reporting.h index 7e9fa587fb..e361bd3f21 100644 --- a/Firmware/mmu2_reporting.h +++ b/Firmware/mmu2_reporting.h @@ -27,9 +27,8 @@ void EndReport(CommandInProgress cip, uint16_t ec); * Render MMU error screen on the LCD. This must be non-blocking * and allow the MMU and printer to communicate with each other. * @param[in] ec error code - * @param[in] res reporter error source, is either Printer (0) or MMU (1) */ -void ReportErrorHook(uint16_t ec, uint8_t res); +void ReportErrorHook(uint16_t ec); /// Called when the MMU sends operation progress update void ReportProgressHook(CommandInProgress cip, uint16_t ec); diff --git a/Firmware/mmu2_serial.cpp b/Firmware/mmu2_serial.cpp index 5ac8e3e293..f26f44f414 100644 --- a/Firmware/mmu2_serial.cpp +++ b/Firmware/mmu2_serial.cpp @@ -19,7 +19,7 @@ void MMU2Serial::flush() { // @@TODO - clear the output buffer } -size_t MMU2Serial::write(const uint8_t *buffer, size_t size) { +void MMU2Serial::write(const uint8_t *buffer, size_t size) { while(size--){ fputc(*buffer, uart2io); ++buffer; diff --git a/Firmware/mmu2_serial.h b/Firmware/mmu2_serial.h index 176a8f3369..43066af18e 100644 --- a/Firmware/mmu2_serial.h +++ b/Firmware/mmu2_serial.h @@ -12,7 +12,7 @@ class MMU2Serial { void close(); int read(); void flush(); - size_t write(const uint8_t *buffer, size_t size); + void write(const uint8_t *buffer, size_t size); }; extern MMU2Serial mmu2Serial; diff --git a/Firmware/pat9125.cpp b/Firmware/pat9125.cpp index 18cf7c1ae8..7a1e191c9a 100644 --- a/Firmware/pat9125.cpp +++ b/Firmware/pat9125.cpp @@ -4,7 +4,7 @@ #include #include "config.h" #include -#include "Configuration_prusa.h" +#include "Configuration_var.h" #if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125) diff --git a/Firmware/sm4.c b/Firmware/sm4.c index 0b6f2f50c6..994e016aac 100644 --- a/Firmware/sm4.c +++ b/Firmware/sm4.c @@ -9,7 +9,7 @@ #include "boards.h" #define false 0 #define true 1 -#include "Configuration_prusa.h" +#include "Configuration_var.h" #ifdef NEW_XYZCAL diff --git a/Firmware/swi2c.c b/Firmware/swi2c.c index d143ec600d..032b39a83c 100644 --- a/Firmware/swi2c.c +++ b/Firmware/swi2c.c @@ -4,7 +4,7 @@ #include #include #include "stdbool.h" -#include "Configuration_prusa.h" +#include "Configuration_var.h" #include "pins.h" #include "fastio.h" diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index c7d9c55491..47e9a846cb 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -44,7 +44,7 @@ #include "adc.h" #include "ConfigurationStore.h" #include "Timer.h" -#include "Configuration_prusa.h" +#include "Configuration_var.h" #include "Prusa_farm.h" #if (ADC_OVRSAMPL != OVERSAMPLENR) @@ -1210,27 +1210,27 @@ FORCE_INLINE static void soft_pwm_core() static unsigned char slow_pwm_count = 0; static unsigned char state_heater_0 = 0; static unsigned char state_timer_heater_0 = 0; -#endif +#endif #if (EXTRUDERS > 1) || defined(HEATERS_PARALLEL) static unsigned char soft_pwm_1; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_1 = 0; static unsigned char state_timer_heater_1 = 0; -#endif +#endif #endif #if EXTRUDERS > 2 static unsigned char soft_pwm_2; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_2 = 0; static unsigned char state_timer_heater_2 = 0; -#endif +#endif #endif #if HEATER_BED_PIN > -1 // @@DR static unsigned char soft_pwm_b; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_b = 0; static unsigned char state_timer_heater_b = 0; -#endif +#endif #endif #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) @@ -2904,6 +2904,7 @@ void temp_model_autotune(int16_t temp, bool selftest) temp_model_report_settings(); } + lcd_consume_click(); menu_unset_block(MENU_BLOCK_TEMP_MODEL_AUTOTUNE); } diff --git a/Firmware/tone04.c b/Firmware/tone04.c index 55a0a0e9c0..f9a427c328 100644 --- a/Firmware/tone04.c +++ b/Firmware/tone04.c @@ -3,7 +3,7 @@ // timer2 is used for System timer. #include "system_timer.h" -#include "Configuration_prusa.h" +#include "Configuration_var.h" #ifdef SYSTEM_TIMER_2 diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 8a8bf7fa57..38a1e33010 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -297,32 +297,19 @@ const char STR_SEPARATOR[] PROGMEM = "------------"; static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* longFilename) { - char c; - uint8_t n = LCD_WIDTH - 1; + uint8_t len = LCD_WIDTH - 1; lcd_set_cursor(0, row); - lcd_print((lcd_encoder == menu_item)?'>':' '); - while( ((c = *longFilename) != '\0') && (n>0) ) - { - lcd_print(c); - longFilename++; - n--; - } - lcd_space(n); + lcd_print((lcd_encoder == menu_item)?'>':' '); + lcd_print_pad(longFilename, len); } + static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* longFilename) { - char c; - uint8_t n = LCD_WIDTH - 2; + uint8_t len = LCD_WIDTH - 2; lcd_set_cursor(0, row); - lcd_print((lcd_encoder == menu_item)?'>':' '); - lcd_print(LCD_STR_FOLDER[0]); - while( ((c = *longFilename) != '\0') && (n>0) ) - { - lcd_print(c); - longFilename++; - n--; - } - lcd_space(n); + lcd_print((lcd_encoder == menu_item)?'>':' '); + lcd_print(LCD_STR_FOLDER[0]); + lcd_print_pad(longFilename, len); } @@ -621,6 +608,8 @@ void lcdui_print_status_line(void) { case CustomMsg::M117: // M117 Set the status line message on the LCD case CustomMsg::Status: // Nothing special, print status message normally case CustomMsg::M0Wait: // M0/M1 Wait command working even from SD + case CustomMsg::FilamentLoading: // If loading filament, print status + case CustomMsg::MMUProgress: // MMU Progress Codes lcd_print_pad(lcd_status_message, LCD_WIDTH); break; case CustomMsg::MeshBedLeveling: // If mesh bed leveling in progress, show the status @@ -643,9 +632,6 @@ void lcdui_print_status_line(void) { } } break; - case CustomMsg::FilamentLoading: // If loading filament, print status - lcd_print_pad(lcd_status_message, LCD_WIDTH); - break; case CustomMsg::PidCal: // PID tuning in progress lcd_print_pad(lcd_status_message, LCD_WIDTH); if (pid_cycle <= pid_number_of_cycles && custom_message_state > 0) { @@ -670,10 +656,6 @@ void lcdui_print_status_line(void) { case CustomMsg::Resuming: // Resuming lcd_puts_at_P(0, 3, _T(MSG_RESUMING_PRINT)); break; - case CustomMsg::MMUProgress: - // set up at mmu2_reporting.cpp, just do nothing here - lcd_print(lcd_status_message); - break; } } } @@ -1657,7 +1639,7 @@ static void lcd_support_menu() MENU_ITEM_BACK_P(PSTR(NOZZLE_TYPE)); MENU_ITEM_BACK_P(STR_SEPARATOR); MENU_ITEM_BACK_P(_i("Date:"));////MSG_DATE c=17 - MENU_ITEM_BACK_P(PSTR(__DATE__)); + MENU_ITEM_BACK_P(PSTR(SOURCE_DATE_EPOCH)); #if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG) MENU_ITEM_BACK_P(STR_SEPARATOR); @@ -3165,25 +3147,21 @@ uint8_t lcd_show_multiscreen_message_yes_no_and_wait_P(const char *msg, bool all //! @param selected Show first choice as selected if true, the second otherwise //! @param first_choice text caption of first possible choice //! @param second_choice text caption of second possible choice -//! @param second_col column on LCD where second choice is rendered. If third choice is set, this value is hardcoded to 7 +//! @param second_col column on LCD where second choice is rendered. //! @param third_choice text caption of third, optional, choice. void lcd_show_choices_prompt_P(uint8_t selected, const char *first_choice, const char *second_choice, uint8_t second_col, const char *third_choice) { lcd_set_cursor(0, 3); lcd_print(selected == LCD_LEFT_BUTTON_CHOICE ? '>': ' '); lcd_puts_P(first_choice); + lcd_set_cursor(second_col, 3); + lcd_print(selected == LCD_MIDDLE_BUTTON_CHOICE ? '>': ' '); + lcd_puts_P(second_choice); if (third_choice) { - lcd_set_cursor(7, 3); - lcd_print(selected == LCD_MIDDLE_BUTTON_CHOICE ? '>': ' '); - lcd_puts_P(second_choice); - lcd_set_cursor(13, 3); + lcd_set_cursor(18, 3); lcd_print(selected == LCD_RIGHT_BUTTON_CHOICE ? '>': ' '); lcd_puts_P(third_choice); - } else { - lcd_set_cursor(second_col, 3); - lcd_print(selected == LCD_MIDDLE_BUTTON_CHOICE ? '>': ' '); - lcd_puts_P(second_choice); } } @@ -7525,12 +7503,12 @@ static void lcd_updatestatus(const char *message, bool progmem = false) else strncpy(lcd_status_message, message, LCD_WIDTH); - lcd_status_message[LCD_WIDTH] = 0; + lcd_status_message[LCD_WIDTH] = 0; - SERIAL_PROTOCOLLNRPGM(MSG_LCD_STATUS_CHANGED); + SERIAL_PROTOCOLLNRPGM(MSG_LCD_STATUS_CHANGED); - // hack lcd_draw_update to 1, i.e. without clear - lcd_draw_update = 1; + // hack lcd_draw_update to 1, i.e. without clear + lcd_draw_update = 1; } void lcd_setstatus(const char* message) diff --git a/Firmware/xyzcal.cpp b/Firmware/xyzcal.cpp index e8689d3b5a..311371c982 100644 --- a/Firmware/xyzcal.cpp +++ b/Firmware/xyzcal.cpp @@ -1,6 +1,6 @@ //xyzcal.cpp - xyz calibration with image processing -#include "Configuration_prusa.h" +#include "Configuration_var.h" #ifdef NEW_XYZCAL #include "xyzcal.h" @@ -551,7 +551,7 @@ void go_manhattan(int16_t x, int16_t y, int16_t z, int16_t acc, uint16_t min_del // DBG(_n("\n")); } -void xyzcal_scan_pixels_32x32_Zhop(int16_t cx, int16_t cy, int16_t min_z, int16_t max_z, uint16_t delay_us, uint8_t *pixels){ +void __attribute__((noinline)) xyzcal_scan_pixels_32x32_Zhop(int16_t cx, int16_t cy, int16_t min_z, int16_t max_z, uint16_t delay_us, uint8_t *pixels){ if (!pixels) return; int16_t z_trig; diff --git a/PF-build.sh b/PF-build.sh index 4396f7f2f1..c64ccdd7ef 100755 --- a/PF-build.sh +++ b/PF-build.sh @@ -85,7 +85,7 @@ # 15 Feb 2019, 3d-gussner, troubleshooting and minor fixes # 16 Feb 2019, 3d-gussner, Script can be run using arguments # $1 = variant, example "1_75mm_MK3-EINSy10a-E3Dv6full.h" at this moment it is not possible to use ALL -# $2 = multi language OR English only [ALL/EN_ONLY] +# $2 = multi language OR English only [ALL/EN_FARM] # $3 = development status [GOLD/RC/BETA/ALPHA/DEVEL/DEBUG] # If one argument is wrong a list of valid one will be shown # 13 Mar 2019, 3d-gussner, MKbel updated the Linux build environment to version 1.0.2 with an Fix maximum firmware flash size. @@ -124,7 +124,7 @@ # After compiling All multi-language variants it makes it easier to find missing or unused translations. # 12 May 2020, DRracer , Cleanup double MK2/s MK25/s `not_tran` and `not_used` files # 13 May 2020, leptun , If cleanup files do not exist don't try to. -# 01 Oct 2020, 3d-gussner, Bug fix if using argument EN_ONLY. Thank to @leptun for pointing out. +# 01 Oct 2020, 3d-gussner, Bug fix if using argument EN_FARM. Thank to @leptun for pointing out. # Change Build number to script commits 'git rev-list --count HEAD PF-build.sh' # 02 Oct 2020, 3d-gussner, Add UNKNOWN as argument option # 05 Oct 2020, 3d-gussner, Disable pause and warnings using command line with all needed arguments @@ -268,7 +268,7 @@ echo " -d : '$(tput setaf 2)GOLD$(tput sgr0)', '$(tput setaf 2)RC$(tput sgr0)', echo " -g : '$(tput setaf 2)0$(tput sgr0)' no '$(tput setaf 2)1$(tput sgr0)' lite '$(tput setaf 2)2$(tput sgr0)' fancy '$(tput setaf 2)3$(tput sgr0)' lite with Quad_HR '$(tput setaf 2)4$(tput sgr0)' fancy with Quad_HR" echo " -i : '$(tput setaf 2)1.8.5$(tput sgr0)', '$(tput setaf 2)1.8.19$(tput sgr0)'" echo " -j : '$(tput setaf 2)0$(tput sgr0)' no, '$(tput setaf 2)1$(tput sgr0)' yes" -echo " -l : '$(tput setaf 2)ALL$(tput sgr0)' for multi language or '$(tput setaf 2)EN_ONLY$(tput sgr0)' for English only" +echo " -l : '$(tput setaf 2)ALL$(tput sgr0)' for multi language or '$(tput setaf 2)EN_FARM$(tput sgr0)' for English only" echo " -m : '$(tput setaf 2)0$(tput sgr0)' no, '$(tput setaf 2)1$(tput sgr0)' yes '$(tput setaf 2)2$(tput sgr0)' with MMU2" echo " -n : '$(tput setaf 2)0$(tput sgr0)' no, '$(tput setaf 2)1$(tput sgr0)' yes" echo " -o : '$(tput setaf 2)1$(tput sgr0)' force or '$(tput setaf 2)0$(tput sgr0)' block output and delays" @@ -530,19 +530,6 @@ fi } # End: Check python ... needed during language build -#Start: Check gawk ... needed during language build -check_gawk() -{ -if ! type gawk > /dev/null; then - if [ $TARGET_OS == "linux" ]; then - echo "$(tput setaf 1)Missing 'gawk' which is important to run this script" - echo "install it with the command $(tput setaf 2)'sudo apt-get install gawk'." - #sudo apt-get update && apt-get install gawk - failures 4 - fi -fi -} -#End: Check gawk ... needed during language build #### Start: Set build environment set_build_env_variables() @@ -551,20 +538,20 @@ BUILD_ENV="1.0.8" BOARD="prusa_einsy_rambo" BOARD_PACKAGE_NAME="PrusaResearch" if [ "$ARDUINO_ENV" == "1.8.19" ]; then - BOARD_VERSION="1.0.5-2" + BOARD_VERSION="1.0.6" else BOARD_VERSION="1.0.4" fi if [ "$ARDUINO_ENV" == "1.8.19" ]; then - BOARD_URL="https://raw.githubusercontent.com/prusa3d/Arduino_Boards/devel/IDE_Board_Manager/package_prusa3d_index.json" - #BOARD_URL="https://raw.githubusercontent.com/3d-gussner/Arduino_Boards/devel/IDE_Board_Manager/package_prusa3d_index.json" + BOARD_URL="https://raw.githubusercontent.com/prusa3d/Arduino_Boards/master/IDE_Board_Manager/package_prusa3d_index.json" + #BOARD_URL="https://raw.githubusercontent.com/3d-gussner/Arduino_Boards/master/IDE_Board_Manager/package_prusa3d_index.json" else BOARD_URL="https://raw.githubusercontent.com/prusa3d/Arduino_Boards/master/IDE_Board_Manager/package_prusa3d_index.json" fi BOARD_FILENAME="prusa3dboards" if [ "$ARDUINO_ENV" == "1.8.19" ]; then - BOARD_FILE_URL="https://raw.githubusercontent.com/prusa3d/Arduino_Boards/devel/IDE_Board_Manager/prusa3dboards-$BOARD_VERSION.tar.bz2" - #BOARD_FILE_URL="https://raw.githubusercontent.com/3d-gussner/Arduino_Boards/devel/IDE_Board_Manager/prusa3dboards-$BOARD_VERSION.tar.bz2" + BOARD_FILE_URL="https://raw.githubusercontent.com/prusa3d/Arduino_Boards/master/IDE_Board_Manager/prusa3dboards-$BOARD_VERSION.tar.bz2" + #BOARD_FILE_URL="https://raw.githubusercontent.com/3d-gussner/Arduino_Boards/master/IDE_Board_Manager/prusa3dboards-$BOARD_VERSION.tar.bz2" else BOARD_FILE_URL="https://raw.githubusercontent.com/prusa3d/Arduino_Boards/master/IDE_Board_Manager/prusa3dboards-$BOARD_VERSION.tar.bz2" fi @@ -882,7 +869,7 @@ else fi fi -#'-l' argument defines if it is an English only version. Known values EN_ONLY / ALL +#'-l' argument defines if it is an English only version. Known values EN_FARM / ALL #Check default language mode MULTI_LANGUAGE_CHECK=$(grep --max-count=1 "^#define LANG_MODE *" $SCRIPT_PATH/Firmware/config.h|sed -e's/ */ /g'|cut -d ' ' -f3) @@ -897,7 +884,7 @@ if [ -z "$language_flag" ] ; then break ;; "English only") - LANGUAGES="EN_ONLY" + LANGUAGES="EN_FARM" break ;; *) @@ -906,11 +893,11 @@ if [ -z "$language_flag" ] ; then esac done else - if [[ "$language_flag" == "ALL" || "$language_flag" == "EN_ONLY" ]] ; then + if [[ "$language_flag" == "ALL" || "$language_flag" == "EN_FARM" ]] ; then LANGUAGES=$language_flag else echo "$(tput setaf 1)Language argument is wrong!$(tput sgr0)" - echo "Only $(tput setaf 2)'ALL'$(tput sgr0) or $(tput setaf 2)'EN_ONLY'$(tput sgr0) are allowed as language '-l' argument!" + echo "Only $(tput setaf 2)'ALL'$(tput sgr0) or $(tput setaf 2)'EN_FARM'$(tput sgr0) are allowed as language '-l' argument!" failures 5 fi fi @@ -1110,9 +1097,9 @@ prepare_hex_folders() if [ $OUTPUT == "1" ] ; then read -t 10 -p "Press Enter to continue..." fi - elif [[ -f "$SCRIPT_PATH/../$OUTPUT_FOLDER/$OUTPUT_FILENAME-EN_ONLY.hex" && "$LANGUAGES" == "EN_ONLY" ]]; then + elif [[ -f "$SCRIPT_PATH/../$OUTPUT_FOLDER/$OUTPUT_FILENAME-EN_FARM.hex" && "$LANGUAGES" == "EN_FARM" ]]; then echo "" - ls -1 $SCRIPT_PATH/../$OUTPUT_FOLDER/$OUTPUT_FILENAME-EN_ONLY.hex | xargs -n1 basename + ls -1 $SCRIPT_PATH/../$OUTPUT_FOLDER/$OUTPUT_FILENAME-EN_FARM.hex | xargs -n1 basename echo "$(tput setaf 6)This hex file to be compiled already exists! To cancel this process press CRTL+C and rename existing hex file.$(tput sgr 0)" if [ $OUTPUT == "1" ] ; then read -t 10 -p "Press Enter to continue..." @@ -1171,7 +1158,7 @@ prepare_variant_for_compiling() sed -i -- 's/#define FW_REPOSITORY "Unknown"/#define FW_REPOSITORY "Prusa3d"/g' $SCRIPT_PATH/Firmware/Configuration.h #Prepare English only or multi-language version to be build - if [ $LANGUAGES == "EN_ONLY" ]; then + if [ $LANGUAGES == "EN_FARM" ]; then echo " " echo "English only language firmware will be built" sed -i -- "s/^#define LANG_MODE *1/#define LANG_MODE 0/g" $SCRIPT_PATH/Firmware/config.h @@ -1379,17 +1366,17 @@ create_multi_firmware() } #### End: Create and save Multi Language Prusa Firmware -#### Start: Save EN_ONLY language Prusa Firmware +#### Start: Save EN_FARM language Prusa Firmware save_en_firmware() { #else echo "$(tput setaf 2)Copying English only firmware to PF-build-hex folder$(tput sgr 0)" - cp -f $BUILD_PATH/Firmware.ino.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/$OUTPUT_FILENAME-EN_ONLY.hex || failures 12 + cp -f $BUILD_PATH/Firmware.ino.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/$OUTPUT_FILENAME-EN_FARM.hex || failures 12 echo "$(tput setaf 2)Copying English only elf file to PF-build-hex folder$(tput sgr 0)" - cp -f $BUILD_PATH/Firmware.ino.elf $SCRIPT_PATH/../$OUTPUT_FOLDER/$OUTPUT_FILENAME-EN_ONLY.elf || failures 12 + cp -f $BUILD_PATH/Firmware.ino.elf $SCRIPT_PATH/../$OUTPUT_FOLDER/$OUTPUT_FILENAME-EN_FARM.elf || failures 12 #fi } -#### End: Save EN_ONLY language Prusa Firmware +#### End: Save EN_FARM language Prusa Firmware #### Start: Cleanup Firmware cleanup_firmware() @@ -1562,7 +1549,7 @@ if [[ ! -z "$mk404_flag" && "$variant_flag" != "All " ]]; then #cd ../MK404/master/build -#Decide which hex file to use EN_ONLY or Multi language +#Decide which hex file to use EN_FARM or Multi language if [ "$LANGUAGES" == "ALL" ]; then if [[ "$MK404_PRINTER" == "MK3" || "$MK404_PRINTER" == "MK3S" ]]; then MK404_firmware_file=$SCRIPT_PATH/../$OUTPUT_FOLDER/$OUTPUT_FILENAME.hex @@ -1575,7 +1562,7 @@ if [[ ! -z "$mk404_flag" && "$variant_flag" != "All " ]]; then done fi else - MK404_firmware_file=$SCRIPT_PATH/../$OUTPUT_FOLDER/$OUTPUT_FILENAME-EN_ONLY.hex + MK404_firmware_file=$SCRIPT_PATH/../$OUTPUT_FOLDER/$OUTPUT_FILENAME-EN_FARM.hex fi # Start MK404 @@ -1601,7 +1588,6 @@ check_OS check_wget check_zip check_python -check_gawk #### Check for options/flags echo "Check for options" diff --git a/build.sh b/build.sh index 3146e12b02..8b09fde77f 100755 --- a/build.sh +++ b/build.sh @@ -32,7 +32,7 @@ if [ ! -f "$SCRIPT_PATH/Firmware/Configuration_prusa.h" ]; then cp $SCRIPT_PATH/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 8 fi -if [[ ! -z $LANGUAGES && $LANGUAGES == "EN_ONLY" ]]; then +if [[ ! -z $LANGUAGES && $LANGUAGES == "EN_FARM" ]]; then echo "English only language firmware will be built" sed -i -- "s/^#define LANG_MODE *1/#define LANG_MODE 0/g" $SCRIPT_PATH/Firmware/config.h else diff --git a/cmake/AnyAvrGcc.cmake b/cmake/AnyAvrGcc.cmake new file mode 100644 index 0000000000..656a35e5c9 --- /dev/null +++ b/cmake/AnyAvrGcc.cmake @@ -0,0 +1,101 @@ +get_filename_component(PROJECT_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) +include("${PROJECT_CMAKE_DIR}/Utilities.cmake") +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR avr) + +# +# Utilities + +if(MINGW + OR CYGWIN + OR WIN32 + ) + set(UTIL_SEARCH_CMD where) + set(EXECUTABLE_SUFFIX ".exe") +elseif(UNIX OR APPLE) + set(UTIL_SEARCH_CMD which) + set(EXECUTABLE_SUFFIX "") +endif() + +set(TOOLCHAIN_PREFIX avr-) + +# +# Looking up the toolchain +# + +if(AVR_TOOLCHAIN_DIR) + # using toolchain set by AvrGcc.cmake (locked version) + message("ToolChain dir is ${AVR_TOOLCHAIN_DIR}") + set(BINUTILS_PATH "${AVR_TOOLCHAIN_DIR}/bin") +else() + # search for ANY avr-gcc toolchain + execute_process( + COMMAND ${UTIL_SEARCH_CMD} ${TOOLCHAIN_PREFIX}gcc + OUTPUT_VARIABLE AVR_GCC_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE FIND_RESULT + ) + # found? + if(NOT "${FIND_RESULT}" STREQUAL "0") + message(FATAL_ERROR "avr-gcc not found") + endif() + get_filename_component(BINUTILS_PATH "${AVR_GCC_PATH}" DIRECTORY) + get_filename_component(AVR_TOOLCHAIN_DIR ${BINUTILS_PATH} DIRECTORY) +endif() + +# +# Setup CMake +# + +# Without that flag CMake is not able to pass test compilation check +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +set(CMAKE_C_COMPILER + "${BINUTILS_PATH}/${TOOLCHAIN_PREFIX}gcc${EXECUTABLE_SUFFIX}" + CACHE FILEPATH "" FORCE + ) +set(CMAKE_ASM_COMPILER + "${BINUTILS_PATH}/${TOOLCHAIN_PREFIX}gcc${EXECUTABLE_SUFFIX}" + CACHE FILEPATH "" FORCE + ) +set(CMAKE_CXX_COMPILER + "${BINUTILS_PATH}/${TOOLCHAIN_PREFIX}g++${EXECUTABLE_SUFFIX}" + CACHE FILEPATH "" FORCE + ) +set(CMAKE_EXE_LINKER_FLAGS_INIT + "" + CACHE STRING "" FORCE + ) + +set(CMAKE_ASM_COMPILE_OBJECT + " -o -c " + CACHE STRING "" FORCE + ) + +set(CMAKE_AR + "${BINUTILS_PATH}/${TOOLCHAIN_PREFIX}gcc-ar${EXECUTABLE_SUFFIX}" + CACHE FILEPATH "ar" FORCE + ) + +set(CMAKE_RANLIB + "${BINUTILS_PATH}/${TOOLCHAIN_PREFIX}gcc-ranlib${EXECUTABLE_SUFFIX}" + CACHE FILEPATH "ranlib" FORCE + ) + +set(CMAKE_OBJCOPY + "${BINUTILS_PATH}/${TOOLCHAIN_PREFIX}objcopy${EXECUTABLE_SUFFIX}" + CACHE INTERNAL "objcopy tool" + ) +set(CMAKE_OBJDUMP + "${BINUTILS_PATH}/${TOOLCHAIN_PREFIX}objdump${EXECUTABLE_SUFFIX}" + CACHE INTERNAL "objdump tool" + ) +set(CMAKE_SIZE_UTIL + "${BINUTILS_PATH}/${TOOLCHAIN_PREFIX}size${EXECUTABLE_SUFFIX}" + CACHE INTERNAL "size tool" + ) + +set(CMAKE_FIND_ROOT_PATH "${AVR_TOOLCHAIN_DIR}") +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/AvrGcc.cmake b/cmake/AvrGcc.cmake new file mode 100644 index 0000000000..c9d8eb1a46 --- /dev/null +++ b/cmake/AvrGcc.cmake @@ -0,0 +1,4 @@ +get_filename_component(PROJECT_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) +include("${PROJECT_CMAKE_DIR}/Utilities.cmake") +get_dependency_directory("avr-gcc" AVR_TOOLCHAIN_DIR) +include("${PROJECT_CMAKE_DIR}/AnyAvrGcc.cmake") diff --git a/cmake/Check_final_lang_bin_size.cmake b/cmake/Check_final_lang_bin_size.cmake new file mode 100644 index 0000000000..18079ea22d --- /dev/null +++ b/cmake/Check_final_lang_bin_size.cmake @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.18) +FILE(SIZE ${LANG_FILE} FILE_SIZE) +get_filename_component(FILE_BASE ${LANG_FILE} NAME) +MATH(EXPR PADDED_SIZE "((${FILE_SIZE}+4096-1) / 4096 * 4096 )") +message(STATUS "${FILE_BASE} raw size ${FILE_SIZE} bytes (${PADDED_SIZE} b padded)") +if(${PADDED_SIZE} GREATER ${LANG_MAX_SIZE}) + message(FATAL_ERROR "Language file ${FILE_BASE} (${PADDED_SIZE}b) exceeds maximum allowed size of ${LANG_MAX_SIZE} bytes - Aborting!") +else() + MATH(EXPR SIZE_PCT "( ${PADDED_SIZE} * 100) / ${LANG_MAX_SIZE} " ) + message(STATUS "Language file ${FILE_BASE} is ${PADDED_SIZE} bytes, ${SIZE_PCT}% of allowed space - OK") +endif() diff --git a/cmake/Check_lang_size.cmake b/cmake/Check_lang_size.cmake new file mode 100644 index 0000000000..5aba2fb1ec --- /dev/null +++ b/cmake/Check_lang_size.cmake @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.18) +FILE(SIZE ${LANG_FILE} FILE_SIZE) +get_filename_component(FILE_BASE ${LANG_FILE} NAME) +MATH(EXPR PADDED_SIZE "((${FILE_SIZE}+256-1) / 256 * 256 )") +MATH(EXPR FREE_SPACE "(${LANG_MAX_SIZE}-${FILE_SIZE})") +if(${PADDED_SIZE} GREATER ${LANG_MAX_SIZE}) + message(FATAL_ERROR "Language file ${FILE_BASE} (${PADDED_SIZE}b) exceeds maximum allowed size of ${LANG_MAX_SIZE} bytes - Aborting!") +else() + MATH(EXPR SIZE_PCT "( ${PADDED_SIZE} * 100) / ${LANG_MAX_SIZE} " ) + message(STATUS "Language file ${FILE_BASE} is ${PADDED_SIZE} (${FILE_SIZE}) bytes, ${SIZE_PCT}% of allowed space. Free bytes ${FREE_SPACE} - OK") +endif() diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake new file mode 100644 index 0000000000..0eccbc1223 --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake @@ -0,0 +1,232 @@ +# * Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can trust the values of the +# variables in your build system. +# +# get_git_head_revision( [ ...]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe( [ ...]) +# +# Returns the results of git describe on the source tree, and adjusting the output so that it tests +# false if an error occurs. +# +# git_get_exact_tag( [ ...]) +# +# Returns the results of git describe --exact-match on the source tree, and adjusting the output so +# that it tests false if there was no exact matching tag. +# +# git_local_changes() +# +# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. Uses the return code of +# "git diff-index --quiet HEAD --". Does not regard untracked files. +# +# git_count_parent_commits() +# +# Returns number of commits preceeding current commit -1 if git rev-list --count HEAD failed or +# "GIT-NOTFOUND" if git executable was not found or "HEAD-HASH-NOTFOUND" if head hash was not found. +# I don't know if get_git_head_revision() must be called internally or not, as reason of calling it +# is not clear for me also in git_local_changes(). +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. Distributed under the Boost Software License, Version +# 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, to find the path to this +# module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(get_git_head_revision _refspecvar _hashvar) + set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories + set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") + get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) + if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) + # We have reached the root directory, we are not in git + set(${_refspecvar} + "GITDIR-NOTFOUND" + PARENT_SCOPE + ) + set(${_hashvar} + "GITDIR-NOTFOUND" + PARENT_SCOPE + ) + return() + endif() + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + endwhile() + # check if this is a submodule + if(NOT IS_DIRECTORY ${GIT_DIR}) + file(READ ${GIT_DIR} submodule) + string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) + get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) + get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) + endif() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${GIT_DIR}/HEAD") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) + + configure_file( + "${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" "${GIT_DATA}/grabRef.cmake" @ONLY + ) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} + "${HEAD_REF}" + PARENT_SCOPE + ) + set(${_hashvar} + "${HEAD_HASH}" + PARENT_SCOPE + ) +endfunction() + +function(git_describe _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} + "GIT-NOTFOUND" + PARENT_SCOPE + ) + return() + endif() + if(NOT hash) + set(${_var} + "HEAD-HASH-NOTFOUND" + PARENT_SCOPE + ) + return() + endif() + + # TODO sanitize if((${ARGN}" MATCHES "&&") OR (ARGN MATCHES "||") OR (ARGN MATCHES "\\;")) + # message("Please report the following error to the project!") message(FATAL_ERROR "Looks like + # someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") endif() + + # message(STATUS "Arguments to execute_process: ${ARGN}") + + execute_process( + COMMAND "${GIT_EXECUTABLE}" describe ${hash} ${ARGN} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE res + OUTPUT_VARIABLE out + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} + "${out}" + PARENT_SCOPE + ) +endfunction() + +function(git_get_exact_tag _var) + git_describe(out --exact-match ${ARGN}) + set(${_var} + "${out}" + PARENT_SCOPE + ) +endfunction() + +function(git_local_changes _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} + "GIT-NOTFOUND" + PARENT_SCOPE + ) + return() + endif() + if(NOT hash) + set(${_var} + "HEAD-HASH-NOTFOUND" + PARENT_SCOPE + ) + return() + endif() + + execute_process( + COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD -- + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE res + OUTPUT_VARIABLE out + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(res EQUAL 0) + set(${_var} + "CLEAN" + PARENT_SCOPE + ) + else() + set(${_var} + "DIRTY" + PARENT_SCOPE + ) + endif() +endfunction() + +function(git_count_parent_commits _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} + "GIT-NOTFOUND" + PARENT_SCOPE + ) + return() + endif() + if(NOT hash) + set(${_var} + "HEAD-HASH-NOTFOUND" + PARENT_SCOPE + ) + return() + endif() + + execute_process( + COMMAND "${GIT_EXECUTABLE}" rev-list --count HEAD + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE res + OUTPUT_VARIABLE out + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(res EQUAL 0) + set(${_var} + "${out}" + PARENT_SCOPE + ) + else() + set(${_var} + "-1" + PARENT_SCOPE + ) + endif() + +endfunction() diff --git a/cmake/GetGitRevisionDescription.cmake.in b/cmake/GetGitRevisionDescription.cmake.in new file mode 100644 index 0000000000..f7d93ddf81 --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake.in @@ -0,0 +1,37 @@ +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. Distributed under the Boost Software License, Version +# 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + else() + configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) + file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) + if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") + set(HEAD_HASH "${CMAKE_MATCH_1}") + endif() + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() diff --git a/cmake/ProjectVersion.cmake b/cmake/ProjectVersion.cmake new file mode 100644 index 0000000000..f8da76d2a0 --- /dev/null +++ b/cmake/ProjectVersion.cmake @@ -0,0 +1,70 @@ +# +# This file is responsible for setting the following variables: +# +# ~~~ +# BUILD_NUMBER (1035) +# PROJECT_VERSION (4.0.3) +# PROJECT_VERSION_FULL (4.0.3-BETA+1035.PR111.B4) +# PROJECT_VERSION_SUFFIX (-BETA+1035.PR111.B4) +# PROJECT_VERSION_SUFFIX_SHORT (+1035) +# +# The `PROJECT_VERSION` variable is set as soon as the file is included. +# To set the rest, the function `resolve_version_variables` has to be called. +# +# ~~~ + +FILE(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/Firmware/Configuration.h CFG_VER_DATA REGEX "#define FW_[A-Z]+ ([0-9]+)" ) +LIST(GET CFG_VER_DATA 0 PROJECT_VERSION_MAJOR) +LIST(GET CFG_VER_DATA 1 PROJECT_VERSION_MINOR) +LIST(GET CFG_VER_DATA 2 PROJECT_VERSION_REV) +STRING(REGEX MATCH "FW_MAJOR ([0-9]+)" PROJECT_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") +SET(PROJECT_VERSION_MAJOR "${CMAKE_MATCH_1}") + +STRING(REGEX MATCH "FW_MINOR ([0-9]+)" PROJECT_VERSION_MINOR "${PROJECT_VERSION_MINOR}") +SET(PROJECT_VERSION_MINOR ${CMAKE_MATCH_1}) + +STRING(REGEX MATCH "FW_REVISION +([0-9]+)" PROJECT_VERSION_REV "${PROJECT_VERSION_REV}") +SET(PROJECT_VERSION_REV ${CMAKE_MATCH_1}) + +SET(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_REV}") + + +function(resolve_version_variables) + # BUILD_NUMBER + if(NOT BUILD_NUMBER) + git_count_parent_commits(BUILD_NUMBER) + set(ERRORS "GIT-NOTFOUND" "HEAD-HASH-NOTFOUND") + if(BUILD_NUMBER IN_LIST ERRORS) + message(WARNING "Failed to resolve build number: ${BUILD_NUMBER}. Setting to zero.") + set(BUILD_NUMBER "0") + endif() + set(BUILD_NUMBER + ${BUILD_NUMBER} + PARENT_SCOPE + ) + endif() + + # PROJECT_VERSION_SUFFIX + if(PROJECT_VERSION_SUFFIX STREQUAL "") + # TODO: set to +.dirty?.debug? + set(PROJECT_VERSION_SUFFIX "+${BUILD_NUMBER}.LOCAL") + set(PROJECT_VERSION_SUFFIX + "+${BUILD_NUMBER}.LOCAL" + PARENT_SCOPE + ) + endif() + + # PROJECT_VERSION_SUFFIX_SHORT + if(PROJECT_VERSION_SUFFIX_SHORT STREQUAL "") + set(PROJECT_VERSION_SUFFIX_SHORT + "+${BUILD_NUMBER}" + PARENT_SCOPE + ) + endif() + + # PROJECT_VERSION_FULL + set(PROJECT_VERSION_FULL + "${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX}" + PARENT_SCOPE + ) +endfunction() diff --git a/cmake/ReproducibleBuild.cmake b/cmake/ReproducibleBuild.cmake new file mode 100644 index 0000000000..bdc7995138 --- /dev/null +++ b/cmake/ReproducibleBuild.cmake @@ -0,0 +1,66 @@ +# +# Functions and utilities for build reproducibility +# + +# Set a target to be reproducible +function(set_reproducible_target target) + # properties for static libraries + set_target_properties(${target} PROPERTIES STATIC_LIBRARY_OPTIONS "-D") + + # properties on executables + target_link_options(${target} PRIVATE -fdebug-prefix-map=${CMAKE_SOURCE_DIR}=) + target_link_options(${target} PRIVATE -fdebug-prefix-map=${CMAKE_BINARY_DIR}=) + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "8") + target_compile_options(${target} PRIVATE -ffile-prefix-map=${CMAKE_SOURCE_DIR}=) + endif() + + # properties on sources + get_target_property(sources ${target} SOURCES) + get_target_property(source_dir ${target} SOURCE_DIR) + foreach(file IN LISTS sources) + cmake_path(ABSOLUTE_PATH file BASE_DIRECTORY ${source_dir}) + cmake_path(RELATIVE_PATH file BASE_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE rpath) + set_property( + SOURCE ${file} + DIRECTORY ${source_dir} + APPEND + PROPERTY COMPILE_OPTIONS "-frandom-seed=${rpath}" + ) + endforeach() +endfunction() + +# Get the list of targets for all directories +function(get_all_targets _result _dir) + get_property( + _subdirs + DIRECTORY "${_dir}" + PROPERTY SUBDIRECTORIES + ) + foreach(_subdir IN LISTS _subdirs) + get_all_targets(${_result} "${_subdir}") + endforeach() + get_directory_property(_sub_targets DIRECTORY "${_dir}" BUILDSYSTEM_TARGETS) + set(${_result} + ${${_result}} ${_sub_targets} + PARENT_SCOPE + ) +endfunction() + +# Make every target reproducible +function(set_all_targets_reproducible) + get_all_targets(targets ${CMAKE_SOURCE_DIR}) + foreach(target IN LISTS targets) + set_reproducible_target(${target}) + endforeach() +endfunction() + +# Set source epoch +function(set_source_epoch epoch) + set(ENV{SOURCE_DATE_EPOCH} ${epoch}) + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8") + string(TIMESTAMP SOURCE_DATE_EPOCH "%Y-%m-%d") + add_compile_definitions(SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH}") + string(TIMESTAMP SOURCE_TIME_EPOCH "%H:%M:%S") + add_compile_definitions(SOURCE_TIME_EPOCH="${SOURCE_TIME_EPOCH}") + endif() +endfunction() diff --git a/cmake/Utilities.cmake b/cmake/Utilities.cmake new file mode 100644 index 0000000000..1ae37d25cf --- /dev/null +++ b/cmake/Utilities.cmake @@ -0,0 +1,65 @@ +get_filename_component(PROJECT_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) +get_filename_component(PROJECT_ROOT_DIR "${PROJECT_CMAKE_DIR}" DIRECTORY) + +find_package(Python3 COMPONENTS Interpreter) +if(NOT Python3_FOUND) + message(FATAL_ERROR "Python3 not found.") +endif() + +function(get_recommended_gcc_version var) + execute_process( + COMMAND "${Python3_EXECUTABLE}" "${PROJECT_ROOT_DIR}/utils/bootstrap.py" + "--print-dependency-version" "avr-gcc" + OUTPUT_VARIABLE RECOMMENDED_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE RETVAL + ) + + if(NOT "${RETVAL}" STREQUAL "0") + message(FATAL_ERROR "Failed to obtain recommended gcc version from utils/bootstrap.py") + endif() + + set(${var} + ${RECOMMENDED_VERSION} + PARENT_SCOPE + ) +endfunction() + +function(get_dependency_directory dependency var) + execute_process( + COMMAND "${Python3_EXECUTABLE}" "${PROJECT_ROOT_DIR}/utils/bootstrap.py" + "--print-dependency-directory" "${dependency}" + OUTPUT_VARIABLE DEPENDENCY_DIRECTORY + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE RETVAL + ) + + if(NOT "${RETVAL}" STREQUAL "0") + message(FATAL_ERROR "Failed to find directory with ${dependency}") + endif() + + file(TO_CMAKE_PATH "${DEPENDENCY_DIRECTORY}" DEPENDENCY_DIRECTORY) + set(${var} + ${DEPENDENCY_DIRECTORY} + PARENT_SCOPE + ) +endfunction() + +function(objcopy target format suffix) + add_custom_command( + TARGET ${target} POST_BUILD + COMMAND "${CMAKE_OBJCOPY}" -O ${format} -S "$" + "${CMAKE_CURRENT_BINARY_DIR}/${target}${suffix}" + COMMENT "Generating ${format} from ${target}..." + BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/${target}${suffix}" + ) +endfunction() + +function(report_size target) + add_custom_command( + TARGET ${target} POST_BUILD + COMMAND echo "" # visually separate the output + COMMAND "${CMAKE_SIZE_UTIL}" -B "$" + USES_TERMINAL + ) +endfunction() diff --git a/lang/lang-check.py b/lang/lang-check.py index cc5310fa48..618b6b03d6 100755 --- a/lang/lang-check.py +++ b/lang/lang-check.py @@ -211,7 +211,7 @@ def check_translation(entry, msgids, is_pot, no_warning, no_suggest, warn_empty, return (errors == 0) # Missing translation - if len(translation) == 0 and (known_msgid or warn_empty): + if len(translation) == 0 and (warn_empty or (not no_warning and known_msgid)): errors += 1 if rows == 1: print(yellow("[W]: Empty translation for \"%s\" on line %d" % (source, line))) @@ -307,6 +307,9 @@ def main(): parser.add_argument( "--no-suggest", action="store_true", help="Disable suggestions") + parser.add_argument( + "--errors-only", action="store_true", + help="Only check errors") parser.add_argument( "--pot", action="store_true", help="Do not check translations") @@ -331,6 +334,10 @@ def main(): print("{}: file does not exist or is not a regular file".format(args.po), file=stderr) return 1 + if args.errors_only: + args.no_warning = True + args.no_suggest = True + # load the symbol map to supress empty (but unused) translation warnings msgids = None if args.map: diff --git a/lang/po/Firmware.pot b/lang/po/Firmware.pot index 7226c13b02..0bedf7c5f8 100644 --- a/lang/po/Firmware.pot +++ b/lang/po/Firmware.pot @@ -434,7 +434,7 @@ msgid "" "heatbed?" msgstr "" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "" @@ -1176,12 +1176,6 @@ msgstr "" msgid "More details online." msgstr "" -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1713,7 +1707,7 @@ msgstr "" msgid "Retract from FINDA" msgstr "" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "" @@ -1969,7 +1963,7 @@ msgstr "" msgid "Steel sheets" msgstr "" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "" @@ -2140,7 +2134,7 @@ msgid "" " is free. Check FINDA connection." msgstr "" -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "" diff --git a/lang/po/Firmware_cs.po b/lang/po/Firmware_cs.po index 04e175c8f9..c15f591c04 100644 --- a/lang/po/Firmware_cs.po +++ b/lang/po/Firmware_cs.po @@ -455,7 +455,7 @@ msgid "" msgstr "" "Chcete opakovat posledni krok a pozmenit vzdalenost mezi tryskou a podlozkou?" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "" @@ -1210,12 +1210,6 @@ msgstr "" msgid "More details online." msgstr "" -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1761,7 +1755,7 @@ msgstr "Obnoveni tisku" msgid "Retract from FINDA" msgstr "" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "" @@ -2025,7 +2019,7 @@ msgstr "Tichy" msgid "Steel sheets" msgstr "Tiskove platy" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "" @@ -2200,7 +2194,7 @@ msgid "" "is free. Check FINDA connection." msgstr "" -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "" diff --git a/lang/po/Firmware_da.po b/lang/po/Firmware_da.po index 3c1a18afb3..e89dc77a62 100644 --- a/lang/po/Firmware_da.po +++ b/lang/po/Firmware_da.po @@ -442,7 +442,7 @@ msgid "" "heatbed?" msgstr "" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "" @@ -1185,12 +1185,6 @@ msgstr "" msgid "More details online." msgstr "" -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1722,7 +1716,7 @@ msgstr "" msgid "Retract from FINDA" msgstr "" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "" @@ -1978,7 +1972,7 @@ msgstr "" msgid "Steel sheets" msgstr "" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "" @@ -2149,7 +2143,7 @@ msgid "" "is free. Check FINDA connection." msgstr "" -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "" diff --git a/lang/po/Firmware_de.po b/lang/po/Firmware_de.po index ccc4de8eff..380b9f2dc7 100644 --- a/lang/po/Firmware_de.po +++ b/lang/po/Firmware_de.po @@ -459,7 +459,7 @@ msgstr "" "Möchten Sie den letzten Schritt wiederholen, um den Abstand zwischen Düse " "und Druckbett neu einzustellen?" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "Klar" @@ -1240,12 +1240,6 @@ msgstr "Modell" msgid "More details online." msgstr "Weiter Details online." -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "Mehr⏬" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1801,7 +1795,7 @@ msgstr "Druck fortgesetzt" msgid "Retract from FINDA" msgstr "Einziehen von FINDA" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "Wdh." @@ -2067,7 +2061,7 @@ msgstr "Leise" msgid "Steel sheets" msgstr "Stahlbleche" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "Stop" @@ -2252,7 +2246,7 @@ msgstr "" "Unerwarteter FINDA-Wert. Stellen Sie sicher, dass sich kein Filament unter " "FINDA befindet und der Selektor frei ist. Prüfen Sie die FINDA-Verbindung." -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "Entla." diff --git a/lang/po/Firmware_es.po b/lang/po/Firmware_es.po index d4e3de31a3..8d02eded6a 100644 --- a/lang/po/Firmware_es.po +++ b/lang/po/Firmware_es.po @@ -455,7 +455,7 @@ msgid "" msgstr "" "Quieres repetir el ultimo paso para reajustar la distancia boquilla-base?" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "" @@ -1212,12 +1212,6 @@ msgstr "Modelo" msgid "More details online." msgstr "" -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1773,7 +1767,7 @@ msgstr "Continuan. impresion" msgid "Retract from FINDA" msgstr "" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "" @@ -2044,7 +2038,7 @@ msgstr "Sigilo" msgid "Steel sheets" msgstr "Lamina de acero" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "" @@ -2220,7 +2214,7 @@ msgid "" "is free. Check FINDA connection." msgstr "" -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "" diff --git a/lang/po/Firmware_fr.po b/lang/po/Firmware_fr.po index bf937572d8..c5c090c137 100644 --- a/lang/po/Firmware_fr.po +++ b/lang/po/Firmware_fr.po @@ -458,7 +458,7 @@ msgstr "" "Voulez-vous refaire l'etape pour reajuster la hauteur entre la buse et le " "plateau chauffant?" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "" @@ -1219,12 +1219,6 @@ msgstr "Modele" msgid "More details online." msgstr "" -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1776,7 +1770,7 @@ msgstr "Reprise de l'impr." msgid "Retract from FINDA" msgstr "" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "" @@ -2045,7 +2039,7 @@ msgstr "Furtif" msgid "Steel sheets" msgstr "Plaques en acier" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "" @@ -2221,7 +2215,7 @@ msgid "" "is free. Check FINDA connection." msgstr "" -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "" diff --git a/lang/po/Firmware_hr.po b/lang/po/Firmware_hr.po index 5359db4c20..db607e4559 100644 --- a/lang/po/Firmware_hr.po +++ b/lang/po/Firmware_hr.po @@ -453,7 +453,7 @@ msgstr "" "Zelite li ponoviti zadnji korak za ponovno podesavanje udaljenosti izmedu " "mlaznice i grijace podloge?" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "" @@ -1210,12 +1210,6 @@ msgstr "" msgid "More details online." msgstr "" -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1762,7 +1756,7 @@ msgstr "Nastavak printa" msgid "Retract from FINDA" msgstr "" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "" @@ -2032,7 +2026,7 @@ msgstr "Tiho" msgid "Steel sheets" msgstr "Celicna ploca" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "" @@ -2207,7 +2201,7 @@ msgid "" "is free. Check FINDA connection." msgstr "" -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "" diff --git a/lang/po/Firmware_hu.po b/lang/po/Firmware_hu.po index 9979075114..dd4b016063 100644 --- a/lang/po/Firmware_hu.po +++ b/lang/po/Firmware_hu.po @@ -456,7 +456,7 @@ msgstr "" "Meg szeretned ismetelni az utolso lepest, hogy finomhangold a fuvoka es az " "asztal kozotti tavolsagot?" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "" @@ -1214,12 +1214,6 @@ msgstr "Modell" msgid "More details online." msgstr "" -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1769,7 +1763,7 @@ msgstr "Nyomtatas folytatasa" msgid "Retract from FINDA" msgstr "" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "" @@ -2036,7 +2030,7 @@ msgstr "Halk" msgid "Steel sheets" msgstr "Acellapok" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "" @@ -2212,7 +2206,7 @@ msgid "" "is free. Check FINDA connection." msgstr "" -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "" diff --git a/lang/po/Firmware_it.po b/lang/po/Firmware_it.po index b0924c0e51..2815e7f274 100644 --- a/lang/po/Firmware_it.po +++ b/lang/po/Firmware_it.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: Prusa-Firmware\n" "POT-Creation-Date: Wed 16 Mar 2022 09:24:52 AM CET\n" -"PO-Revision-Date: 2022-05-23 13:09+0200\n" +"PO-Revision-Date: 2022-10-13 22:49+0200\n" "Last-Translator: \n" "Language-Team: \n" "Language: it\n" @@ -16,94 +16,94 @@ msgstr "" "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" #. MSG_IR_03_OR_OLDER c=18 -#: ../../Firmware/Filament_sensor.cpp:287 -#: ../../Firmware/Filament_sensor.cpp:362 ../../Firmware/messages.cpp:165 +#: ../../Firmware/Filament_sensor.cpp:289 +#: ../../Firmware/Filament_sensor.cpp:366 ../../Firmware/messages.cpp:165 msgid " 0.3 or older" msgstr " 0.3 o inferiore" #. MSG_IR_04_OR_NEWER c=18 -#: ../../Firmware/Filament_sensor.cpp:289 -#: ../../Firmware/Filament_sensor.cpp:365 ../../Firmware/messages.cpp:164 +#: ../../Firmware/Filament_sensor.cpp:291 +#: ../../Firmware/Filament_sensor.cpp:369 ../../Firmware/messages.cpp:164 msgid " 0.4 or newer" msgstr " 0.4 o superiore" #. MSG_SELFTEST_FS_LEVEL c=20 -#: ../../Firmware/ultralcd.cpp:7035 +#: ../../Firmware/ultralcd.cpp:7018 msgid "%s level expected" msgstr "atteso livello %s" #. MSG_CANCEL c=10 -#: ../../Firmware/messages.cpp:18 ../../Firmware/ultralcd.cpp:1980 -#: ../../Firmware/ultralcd.cpp:3806 +#: ../../Firmware/messages.cpp:18 ../../Firmware/ultralcd.cpp:1967 +#: ../../Firmware/ultralcd.cpp:3789 msgid ">Cancel" msgstr ">Annulla" #. MSG_BABYSTEPPING_Z c=15 #. Beware: must include the ':' as its last character -#: ../../Firmware/ultralcd.cpp:2668 +#: ../../Firmware/ultralcd.cpp:2655 msgid "Adjusting Z:" msgstr "Compensaz. Z:" #. MSG_SELFTEST_CHECK_ALLCORRECT c=20 -#: ../../Firmware/ultralcd.cpp:7311 +#: ../../Firmware/ultralcd.cpp:7294 msgid "All correct" msgstr "Nessun errore" #. MSG_WIZARD_DONE c=20 r=3 -#: ../../Firmware/messages.cpp:119 ../../Firmware/ultralcd.cpp:4133 -#: ../../Firmware/ultralcd.cpp:4142 +#: ../../Firmware/messages.cpp:119 ../../Firmware/ultralcd.cpp:4116 +#: ../../Firmware/ultralcd.cpp:4125 msgid "All is done. Happy printing!" msgstr "Tutto fatto. Buona stampa!" #. MSG_SORT_ALPHA c=8 -#: ../../Firmware/messages.cpp:142 ../../Firmware/ultralcd.cpp:4402 +#: ../../Firmware/messages.cpp:142 ../../Firmware/ultralcd.cpp:4385 msgid "Alphabet" msgstr "Alfabeti" #. MSG_ALWAYS c=6 -#: ../../Firmware/messages.cpp:8 ../../Firmware/ultralcd.cpp:4287 +#: ../../Firmware/messages.cpp:8 ../../Firmware/ultralcd.cpp:4270 msgid "Always" -msgstr "" +msgstr "Sempre" #. MSG_AMBIENT c=14 -#: ../../Firmware/ultralcd.cpp:1406 +#: ../../Firmware/ultralcd.cpp:1393 msgid "Ambient" msgstr "Ambiente" #. MSG_CONFIRM_CARRIAGE_AT_THE_TOP c=20 r=2 -#: ../../Firmware/ultralcd.cpp:2981 +#: ../../Firmware/ultralcd.cpp:2968 msgid "Are left and right Z~carriages all up?" msgstr "I carrelli Z sin/des sono altezza max?" #. MSG_SOUND_BLIND c=7 -#: ../../Firmware/messages.cpp:147 ../../Firmware/ultralcd.cpp:4457 +#: ../../Firmware/messages.cpp:147 ../../Firmware/ultralcd.cpp:4440 msgid "Assist" msgstr "Assist." #. MSG_AUTO c=6 -#: ../../Firmware/messages.cpp:161 ../../Firmware/ultralcd.cpp:5862 +#: ../../Firmware/messages.cpp:161 ../../Firmware/ultralcd.cpp:5845 msgid "Auto" msgstr "Auto" #. MSG_AUTO_HOME c=18 -#: ../../Firmware/Marlin_main.cpp:3261 ../../Firmware/messages.cpp:9 -#: ../../Firmware/ultralcd.cpp:4871 +#: ../../Firmware/Marlin_main.cpp:3262 ../../Firmware/messages.cpp:9 +#: ../../Firmware/ultralcd.cpp:4854 msgid "Auto home" msgstr "Trova origine" #. MSG_AUTO_POWER c=10 -#: ../../Firmware/messages.cpp:106 ../../Firmware/ultralcd.cpp:4362 -#: ../../Firmware/ultralcd.cpp:5777 +#: ../../Firmware/messages.cpp:106 ../../Firmware/ultralcd.cpp:4345 +#: ../../Firmware/ultralcd.cpp:5760 msgid "Auto power" msgstr "Automatico" #. MSG_AUTOLOAD_FILAMENT c=18 -#: ../../Firmware/ultralcd.cpp:5584 +#: ../../Firmware/ultralcd.cpp:5567 msgid "AutoLoad filament" msgstr "Autocaric. filam." #. MSG_AUTOLOADING_ENABLED c=20 r=4 -#: ../../Firmware/ultralcd.cpp:2301 +#: ../../Firmware/ultralcd.cpp:2288 msgid "" "Autoloading filament is active, just press the knob and insert filament..." msgstr "Caricamento automatico attivo, premi la manopola e inserisci il filam." @@ -115,50 +115,50 @@ msgid "Avoiding grind" msgstr "" #. MSG_SELFTEST_AXIS c=16 -#: ../../Firmware/ultralcd.cpp:7014 +#: ../../Firmware/ultralcd.cpp:6997 msgid "Axis" msgstr "Assi" #. MSG_SELFTEST_AXIS_LENGTH c=20 -#: ../../Firmware/ultralcd.cpp:7013 +#: ../../Firmware/ultralcd.cpp:6996 msgid "Axis length" msgstr "Lunghezza dell'asse" #. MSG_BACK c=18 -#: ../../Firmware/messages.cpp:63 ../../Firmware/ultralcd.cpp:2749 -#: ../../Firmware/ultralcd.cpp:4223 ../../Firmware/ultralcd.cpp:5859 -#: ../../Firmware/ultralcd.cpp:7826 +#: ../../Firmware/messages.cpp:63 ../../Firmware/ultralcd.cpp:2736 +#: ../../Firmware/ultralcd.cpp:4206 ../../Firmware/ultralcd.cpp:5842 +#: ../../Firmware/ultralcd.cpp:7806 msgid "Back" msgstr "Indietro" #. MSG_BED c=13 -#: ../../Firmware/Marlin_main.cpp:2029 ../../Firmware/Marlin_main.cpp:4792 -#: ../../Firmware/Marlin_main.cpp:4844 ../../Firmware/messages.cpp:12 -#: ../../Firmware/ultralcd.cpp:1404 ../../Firmware/ultralcd.cpp:5734 -#: ../../Firmware/ultralcd.cpp:5889 +#: ../../Firmware/Marlin_main.cpp:2030 ../../Firmware/Marlin_main.cpp:4793 +#: ../../Firmware/Marlin_main.cpp:4845 ../../Firmware/messages.cpp:12 +#: ../../Firmware/ultralcd.cpp:1391 ../../Firmware/ultralcd.cpp:5717 +#: ../../Firmware/ultralcd.cpp:5872 msgid "Bed" msgstr "Piano" #. MSG_BED_HEATING c=20 -#: ../../Firmware/Marlin_main.cpp:6293 ../../Firmware/messages.cpp:14 -#: ../../Firmware/ultralcd.cpp:585 +#: ../../Firmware/Marlin_main.cpp:6294 ../../Firmware/messages.cpp:14 +#: ../../Firmware/ultralcd.cpp:582 msgid "Bed Heating" msgstr "Riscald. piano" #. MSG_BED_DONE c=20 -#: ../../Firmware/Marlin_main.cpp:6331 ../../Firmware/messages.cpp:13 -#: ../../Firmware/ultralcd.cpp:588 +#: ../../Firmware/Marlin_main.cpp:6332 ../../Firmware/messages.cpp:13 +#: ../../Firmware/ultralcd.cpp:585 msgid "Bed done" msgstr "Piano fatto." #. MSG_BED_CORRECTION_MENU c=18 -#: ../../Firmware/ultralcd.cpp:4883 +#: ../../Firmware/ultralcd.cpp:4866 msgid "Bed level correct" msgstr "Correz. liv.piano" #. MSG_BED_LEVELING_FAILED_POINT_LOW c=20 r=6 -#: ../../Firmware/Marlin_main.cpp:2209 ../../Firmware/Marlin_main.cpp:2985 -#: ../../Firmware/Marlin_main.cpp:2995 +#: ../../Firmware/Marlin_main.cpp:2210 ../../Firmware/Marlin_main.cpp:2986 +#: ../../Firmware/Marlin_main.cpp:2996 #: ../../Firmware/mesh_bed_calibration.cpp:2858 #: ../../Firmware/mesh_bed_calibration.cpp:2866 #: ../../Firmware/mesh_bed_calibration.cpp:2892 ../../Firmware/messages.cpp:15 @@ -170,55 +170,55 @@ msgstr "" "reset." #. MSG_SELFTEST_BEDHEATER c=20 -#: ../../Firmware/ultralcd.cpp:6971 +#: ../../Firmware/ultralcd.cpp:6954 msgid "Bed/Heater" msgstr "Piano/Riscald." #. MSG_BELT_STATUS c=18 -#: ../../Firmware/messages.cpp:17 ../../Firmware/ultralcd.cpp:1457 -#: ../../Firmware/ultralcd.cpp:1726 +#: ../../Firmware/messages.cpp:17 ../../Firmware/ultralcd.cpp:1444 +#: ../../Firmware/ultralcd.cpp:1713 msgid "Belt status" msgstr "Stato cinghie" #. MSG_BELTTEST c=18 -#: ../../Firmware/ultralcd.cpp:4873 +#: ../../Firmware/ultralcd.cpp:4856 msgid "Belt test" msgstr "Test cinghie" #. MSG_RECOVER_PRINT c=20 r=2 -#: ../../Firmware/Marlin_main.cpp:1585 ../../Firmware/Marlin_main.cpp:1607 +#: ../../Firmware/Marlin_main.cpp:1586 ../../Firmware/Marlin_main.cpp:1608 #: ../../Firmware/messages.cpp:81 msgid "Blackout occurred. Recover print?" msgstr "Blackout rilevato. Recuperare stampa?" #. MSG_BRIGHT c=6 -#: ../../Firmware/messages.cpp:159 ../../Firmware/ultralcd.cpp:5862 +#: ../../Firmware/messages.cpp:159 ../../Firmware/ultralcd.cpp:5845 msgid "Bright" msgstr "Chiaro" #. MSG_BRIGHTNESS c=18 -#: ../../Firmware/messages.cpp:155 ../../Firmware/ultralcd.cpp:4821 -#: ../../Firmware/ultralcd.cpp:5787 +#: ../../Firmware/messages.cpp:155 ../../Firmware/ultralcd.cpp:4804 +#: ../../Firmware/ultralcd.cpp:5770 msgid "Brightness" msgstr "Luminosita'" #. MSG_TITLE_COMMUNICATION_ERROR c=20 -#: ../../Firmware/mmu2/errors_list.h:147 ../../Firmware/mmu2/errors_list.h:185 +#: ../../Firmware/mmu2/errors_list.h:154 ../../Firmware/mmu2/errors_list.h:195 msgid "COMMUNICATION ERROR" -msgstr "" +msgstr "ERRORE COMUNICAZIONE" #. MSG_CALIBRATE_BED c=18 -#: ../../Firmware/ultralcd.cpp:4877 +#: ../../Firmware/ultralcd.cpp:4860 msgid "Calibrate XYZ" msgstr "Calibra XYZ" #. MSG_HOMEYZ c=18 -#: ../../Firmware/messages.cpp:50 ../../Firmware/ultralcd.cpp:4879 +#: ../../Firmware/messages.cpp:50 ../../Firmware/ultralcd.cpp:4862 msgid "Calibrate Z" msgstr "Calibra Z" #. MSG_MOVE_CARRIAGE_TO_THE_TOP c=20 r=8 -#: ../../Firmware/ultralcd.cpp:2944 +#: ../../Firmware/ultralcd.cpp:2931 msgid "" "Calibrating XYZ. Rotate the knob to move the Z carriage up to the end " "stoppers. Click when done." @@ -227,13 +227,13 @@ msgstr "" "all'altezza massima. Click per terminare." #. MSG_CALIBRATE_Z_AUTO c=20 r=2 -#: ../../Firmware/Marlin_main.cpp:2166 ../../Firmware/messages.cpp:19 -#: ../../Firmware/ultralcd.cpp:633 +#: ../../Firmware/Marlin_main.cpp:2167 ../../Firmware/messages.cpp:19 +#: ../../Firmware/ultralcd.cpp:632 msgid "Calibrating Z" msgstr "Calibrando Z" #. MSG_MOVE_CARRIAGE_TO_THE_TOP_Z c=20 r=8 -#: ../../Firmware/ultralcd.cpp:2943 +#: ../../Firmware/ultralcd.cpp:2930 msgid "" "Calibrating Z. Rotate the knob to move the Z carriage up to the end " "stoppers. Click when done." @@ -242,141 +242,141 @@ msgstr "" "all'altezza massima. Click per terminare." #. MSG_CALIBRATING_HOME c=20 -#: ../../Firmware/ultralcd.cpp:7313 +#: ../../Firmware/ultralcd.cpp:7296 msgid "Calibrating home" msgstr "Calibrazione Home" #. MSG_CALIBRATION c=18 -#: ../../Firmware/messages.cpp:67 ../../Firmware/ultralcd.cpp:5594 +#: ../../Firmware/messages.cpp:67 ../../Firmware/ultralcd.cpp:5577 msgid "Calibration" msgstr "Calibrazione" #. MSG_HOMEYZ_DONE c=20 -#: ../../Firmware/ultralcd.cpp:644 +#: ../../Firmware/ultralcd.cpp:643 msgid "Calibration done" msgstr "Calibr. completa" #. MSG_DESC_CANNOT_MOVE c=20 r=4 -#: ../../Firmware/mmu2/errors_list.h:203 ../../Firmware/mmu2/errors_list.h:243 -#: ../../Firmware/mmu2/errors_list.h:245 +#: ../../Firmware/mmu2/errors_list.h:213 ../../Firmware/mmu2/errors_list.h:253 +#: ../../Firmware/mmu2/errors_list.h:255 msgid "Can't move Selector or Idler." msgstr "" #. MSG_DESC_FILAMENT_ALREADY_LOADED c=20 r=8 -#: ../../Firmware/mmu2/errors_list.h:228 ../../Firmware/mmu2/errors_list.h:266 +#: ../../Firmware/mmu2/errors_list.h:238 ../../Firmware/mmu2/errors_list.h:279 msgid "Cannot perform the action, filament is already loaded. Unload it first." msgstr "" #. MSG_SD_REMOVED c=20 -#: ../../Firmware/ultralcd.cpp:7700 +#: ../../Firmware/ultralcd.cpp:7680 msgid "Card removed" msgstr "SD rimossa" #. MSG_CNG_SDCARD c=18 -#: ../../Firmware/ultralcd.cpp:5547 +#: ../../Firmware/ultralcd.cpp:5530 msgid "Change SD card" -msgstr "" +msgstr "Cambia scheda SD" #. MSG_FILAMENTCHANGE c=18 -#: ../../Firmware/messages.cpp:39 ../../Firmware/ultralcd.cpp:5506 -#: ../../Firmware/ultralcd.cpp:5743 +#: ../../Firmware/messages.cpp:39 ../../Firmware/ultralcd.cpp:5489 +#: ../../Firmware/ultralcd.cpp:5726 msgid "Change filament" msgstr "Cambia filamento" #. MSG_CHANGE_SUCCESS c=20 -#: ../../Firmware/ultralcd.cpp:2179 +#: ../../Firmware/ultralcd.cpp:2166 msgid "Change success!" msgstr "Cambio riuscito!" #. MSG_CORRECTLY c=20 -#: ../../Firmware/ultralcd.cpp:2227 +#: ../../Firmware/ultralcd.cpp:2214 msgid "Changed correctly?" msgstr "Cambio corretto?" #. MSG_CHECKING_X c=20 -#: ../../Firmware/messages.cpp:21 ../../Firmware/ultralcd.cpp:6187 -#: ../../Firmware/ultralcd.cpp:7303 +#: ../../Firmware/messages.cpp:21 ../../Firmware/ultralcd.cpp:6170 +#: ../../Firmware/ultralcd.cpp:7286 msgid "Checking X axis" msgstr "Verifica asse X" #. MSG_CHECKING_Y c=20 -#: ../../Firmware/messages.cpp:22 ../../Firmware/ultralcd.cpp:6196 -#: ../../Firmware/ultralcd.cpp:7304 +#: ../../Firmware/messages.cpp:22 ../../Firmware/ultralcd.cpp:6179 +#: ../../Firmware/ultralcd.cpp:7287 msgid "Checking Y axis" msgstr "Verifica asse Y" #. MSG_SELFTEST_CHECK_Z c=20 -#: ../../Firmware/ultralcd.cpp:7305 +#: ../../Firmware/ultralcd.cpp:7288 msgid "Checking Z axis" msgstr "Verifica asse Z" #. MSG_SELFTEST_CHECK_BED c=20 -#: ../../Firmware/messages.cpp:93 ../../Firmware/ultralcd.cpp:7306 +#: ../../Firmware/messages.cpp:93 ../../Firmware/ultralcd.cpp:7289 msgid "Checking bed" msgstr "Verifica piano" #. MSG_SELFTEST_CHECK_ENDSTOPS c=20 -#: ../../Firmware/ultralcd.cpp:7302 +#: ../../Firmware/ultralcd.cpp:7285 msgid "Checking endstops" msgstr "Verifica finecorsa" #. MSG_CHECKING_FILE c=17 -#: ../../Firmware/ultralcd.cpp:7401 +#: ../../Firmware/ultralcd.cpp:7384 msgid "Checking file" msgstr "Verifica file" #. MSG_SELFTEST_CHECK_HOTEND c=20 -#: ../../Firmware/ultralcd.cpp:7308 +#: ../../Firmware/ultralcd.cpp:7291 msgid "Checking hotend" msgstr "Verifica ugello" #. MSG_SELFTEST_CHECK_FSENSOR c=20 -#: ../../Firmware/messages.cpp:94 ../../Firmware/ultralcd.cpp:7309 -#: ../../Firmware/ultralcd.cpp:7310 +#: ../../Firmware/messages.cpp:94 ../../Firmware/ultralcd.cpp:7292 +#: ../../Firmware/ultralcd.cpp:7293 msgid "Checking sensors" msgstr "Controllo sensori" #. MSG_CHECKS c=18 -#: ../../Firmware/ultralcd.cpp:4728 +#: ../../Firmware/ultralcd.cpp:4711 msgid "Checks" msgstr "Controlli" #. MSG_NOT_COLOR c=19 -#: ../../Firmware/ultralcd.cpp:2230 +#: ../../Firmware/ultralcd.cpp:2217 msgid "Color not correct" msgstr "Colore non puro" #. MSG_COMMUNITY_MADE c=18 -#: ../../Firmware/messages.cpp:23 ../../Firmware/ultralcd.cpp:3696 +#: ../../Firmware/messages.cpp:23 ../../Firmware/ultralcd.cpp:3679 msgid "Community made" msgstr "Contribuiti" #. MSG_CONTINUE_SHORT c=5 -#: ../../Firmware/messages.cpp:153 ../../Firmware/ultralcd.cpp:4245 +#: ../../Firmware/messages.cpp:153 ../../Firmware/ultralcd.cpp:4228 msgid "Cont." msgstr "Cont." #. MSG_COOLDOWN c=18 -#: ../../Firmware/messages.cpp:25 ../../Firmware/ultralcd.cpp:2138 +#: ../../Firmware/messages.cpp:25 ../../Firmware/ultralcd.cpp:2125 msgid "Cooldown" msgstr "Raffredda" #. MSG_COPY_SEL_LANG c=20 r=3 -#: ../../Firmware/ultralcd.cpp:3634 +#: ../../Firmware/ultralcd.cpp:3617 msgid "Copy selected language?" msgstr "Copiare la lingua selezionata?" #. MSG_CRASH c=7 -#: ../../Firmware/messages.cpp:26 ../../Firmware/ultralcd.cpp:1247 -#: ../../Firmware/ultralcd.cpp:1276 +#: ../../Firmware/messages.cpp:26 ../../Firmware/ultralcd.cpp:1234 +#: ../../Firmware/ultralcd.cpp:1263 msgid "Crash" msgstr "Impatto" #. MSG_CRASHDETECT c=13 -#: ../../Firmware/messages.cpp:28 ../../Firmware/ultralcd.cpp:4339 -#: ../../Firmware/ultralcd.cpp:4340 ../../Firmware/ultralcd.cpp:4342 -#: ../../Firmware/ultralcd.cpp:5763 ../../Firmware/ultralcd.cpp:5765 -#: ../../Firmware/ultralcd.cpp:5769 +#: ../../Firmware/messages.cpp:28 ../../Firmware/ultralcd.cpp:4322 +#: ../../Firmware/ultralcd.cpp:4323 ../../Firmware/ultralcd.cpp:4325 +#: ../../Firmware/ultralcd.cpp:5746 ../../Firmware/ultralcd.cpp:5748 +#: ../../Firmware/ultralcd.cpp:5752 msgid "Crash det." msgstr "Rileva.crash" @@ -386,7 +386,7 @@ msgid "Crash detected." msgstr "Rilevato impatto." #. MSG_CRASH_DET_ONLY_IN_NORMAL c=20 r=4 -#: ../../Firmware/ultralcd.cpp:3538 +#: ../../Firmware/ultralcd.cpp:3521 msgid "" "Crash detection can\n" "be turned on only in\n" @@ -397,36 +397,36 @@ msgstr "" "in Modalita normale" #. MSG_CUT_FILAMENT c=17 -#: ../../Firmware/messages.cpp:61 ../../Firmware/ultralcd.cpp:5155 -#: ../../Firmware/ultralcd.cpp:5578 +#: ../../Firmware/messages.cpp:61 ../../Firmware/ultralcd.cpp:5138 +#: ../../Firmware/ultralcd.cpp:5561 msgid "Cut filament" msgstr "Taglia filamento" #. MSG_CUTTER c=9 -#: ../../Firmware/messages.cpp:129 ../../Firmware/ultralcd.cpp:4282 -#: ../../Firmware/ultralcd.cpp:4287 ../../Firmware/ultralcd.cpp:4292 +#: ../../Firmware/messages.cpp:129 ../../Firmware/ultralcd.cpp:4265 +#: ../../Firmware/ultralcd.cpp:4270 ../../Firmware/ultralcd.cpp:4275 msgid "Cutter" msgstr "Tagliatr." #. MSG_DATE c=17 -#: ../../Firmware/ultralcd.cpp:1667 +#: ../../Firmware/ultralcd.cpp:1654 msgid "Date:" msgstr "Data:" #. MSG_DIM c=6 -#: ../../Firmware/messages.cpp:160 ../../Firmware/ultralcd.cpp:5862 +#: ../../Firmware/messages.cpp:160 ../../Firmware/ultralcd.cpp:5845 msgid "Dim" msgstr "Scuro" #. MSG_BTN_DISABLE_MMU c=9 -#: ../../Firmware/mmu2/errors_list.h:286 ../../Firmware/mmu2/errors_list.h:296 +#: ../../Firmware/mmu2/errors_list.h:300 ../../Firmware/mmu2/errors_list.h:310 msgid "Disable" -msgstr "" +msgstr "Disattiva" #. MSG_DISABLE_STEPPERS c=18 -#: ../../Firmware/ultralcd.cpp:4764 +#: ../../Firmware/ultralcd.cpp:4747 msgid "Disable steppers" -msgstr "Disabilita motori" +msgstr "Disattiva motori" #. MSG_PROGRESS_DISENGAGE_IDLER c=20 #: ../../Firmware/mmu2_progress_converter.cpp:10 @@ -436,7 +436,7 @@ msgid "Disengaging idler" msgstr "" #. MSG_BABYSTEP_Z_NOT_SET c=20 r=12 -#: ../../Firmware/Marlin_main.cpp:1530 ../../Firmware/Marlin_main.cpp:3400 +#: ../../Firmware/Marlin_main.cpp:1531 ../../Firmware/Marlin_main.cpp:3401 #: ../../Firmware/messages.cpp:11 msgid "" "Distance between tip of the nozzle and the bed surface has not been set yet. " @@ -448,7 +448,7 @@ msgstr "" "Calibrazione primo strato." #. MSG_WIZARD_REPEAT_V2_CAL c=20 r=7 -#: ../../Firmware/ultralcd.cpp:4107 +#: ../../Firmware/ultralcd.cpp:4090 msgid "" "Do you want to repeat last step to readjust distance between nozzle and " "heatbed?" @@ -456,13 +456,13 @@ msgstr "" "Desideri ripetere l'ultimo passaggio per migliorare la distanza fra ugello e " "piatto?" -#. MSG_BTN_CONTINUE c=5 -#: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 +#. MSG_BTN_CONTINUE c=8 +#: ../../Firmware/mmu2/errors_list.h:296 ../../Firmware/mmu2/errors_list.h:306 msgid "Done" -msgstr "" +msgstr "Fatto" #. MSG_EXTRUDER_CORRECTION c=13 -#: ../../Firmware/ultralcd.cpp:4176 +#: ../../Firmware/ultralcd.cpp:4159 msgid "E-correct:" msgstr "Correzione-E:" @@ -491,13 +491,13 @@ msgid "ERR Wait for User" msgstr "" #. MSG_ERROR c=10 -#: ../../Firmware/messages.cpp:29 ../../Firmware/ultralcd.cpp:2282 +#: ../../Firmware/messages.cpp:29 ../../Firmware/ultralcd.cpp:2269 msgid "ERROR:" msgstr "ERRORE:" #. MSG_EJECT_FILAMENT c=17 -#: ../../Firmware/messages.cpp:60 ../../Firmware/ultralcd.cpp:5137 -#: ../../Firmware/ultralcd.cpp:5575 +#: ../../Firmware/messages.cpp:60 ../../Firmware/ultralcd.cpp:5120 +#: ../../Firmware/ultralcd.cpp:5558 msgid "Eject filament" msgstr "Espelli fil." @@ -509,17 +509,17 @@ msgid "Ejecting filament" msgstr "Espellendo filamento" #. MSG_SELFTEST_ENDSTOP c=16 -#: ../../Firmware/ultralcd.cpp:6984 +#: ../../Firmware/ultralcd.cpp:6967 msgid "Endstop" msgstr "Finecorsa" #. MSG_SELFTEST_ENDSTOP_NOTHIT c=20 -#: ../../Firmware/ultralcd.cpp:6989 +#: ../../Firmware/ultralcd.cpp:6972 msgid "Endstop not hit" msgstr "Finec. fuori portata" #. MSG_SELFTEST_ENDSTOPS c=20 -#: ../../Firmware/ultralcd.cpp:6975 +#: ../../Firmware/ultralcd.cpp:6958 msgid "Endstops" msgstr "Finecorsa" @@ -531,127 +531,127 @@ msgid "Engaging idler" msgstr "" #. MSG_EXTRUDER c=17 -#: ../../Firmware/Marlin_main.cpp:3519 ../../Firmware/Tcodes.cpp:35 +#: ../../Firmware/Marlin_main.cpp:3520 ../../Firmware/Tcodes.cpp:35 #: ../../Firmware/Tcodes.cpp:51 ../../Firmware/messages.cpp:30 -#: ../../Firmware/ultralcd.cpp:3512 +#: ../../Firmware/ultralcd.cpp:3495 msgid "Extruder" msgstr "Estrusore" #. MSG_EXTRUDER_FAN_SPEED c=16 -#: ../../Firmware/messages.cpp:35 ../../Firmware/ultralcd.cpp:1144 -#: ../../Firmware/ultralcd.cpp:7319 +#: ../../Firmware/messages.cpp:35 ../../Firmware/ultralcd.cpp:1131 +#: ../../Firmware/ultralcd.cpp:7302 msgid "Extruder fan:" msgstr "Vent. estrusore:" #. MSG_INFO_EXTRUDER c=18 -#: ../../Firmware/ultralcd.cpp:1722 +#: ../../Firmware/ultralcd.cpp:1709 msgid "Extruder info" msgstr "Info estrusore" #. MSG_FSENSOR_AUTOLOAD c=13 -#: ../../Firmware/messages.cpp:45 ../../Firmware/ultralcd.cpp:4230 -#: ../../Firmware/ultralcd.cpp:4237 +#: ../../Firmware/messages.cpp:45 ../../Firmware/ultralcd.cpp:4213 +#: ../../Firmware/ultralcd.cpp:4220 msgid "F. autoload" msgstr "Autocar.fil." #. MSG_FSENSOR_JAM_DETECTION c=13 -#: ../../Firmware/messages.cpp:46 ../../Firmware/ultralcd.cpp:4232 -#: ../../Firmware/ultralcd.cpp:4239 +#: ../../Firmware/messages.cpp:46 ../../Firmware/ultralcd.cpp:4215 +#: ../../Firmware/ultralcd.cpp:4222 msgid "F. jam detect" -msgstr "" +msgstr "Ril. blocco" #. MSG_FSENSOR_RUNOUT c=13 -#: ../../Firmware/messages.cpp:44 ../../Firmware/ultralcd.cpp:4229 -#: ../../Firmware/ultralcd.cpp:4236 +#: ../../Firmware/messages.cpp:44 ../../Firmware/ultralcd.cpp:4212 +#: ../../Firmware/ultralcd.cpp:4219 msgid "F. runout" -msgstr "" +msgstr "Ril. fine fil" #. MSG_TITLE_FIL_ALREADY_LOADED c=20 -#: ../../Firmware/mmu2/errors_list.h:148 ../../Firmware/mmu2/errors_list.h:186 +#: ../../Firmware/mmu2/errors_list.h:155 ../../Firmware/mmu2/errors_list.h:196 msgid "FILAMENT ALREADY LOA" msgstr "" #. MSG_TITLE_FINDA_DIDNT_TRIGGER c=20 -#: ../../Firmware/mmu2/errors_list.h:118 ../../Firmware/mmu2/errors_list.h:156 +#: ../../Firmware/mmu2/errors_list.h:124 ../../Firmware/mmu2/errors_list.h:163 msgid "FINDA DIDNT TRIGGER" msgstr "" #. MSG_DESC_FINDA_DIDNT_GO_OFF c=20 r=8 -#: ../../Firmware/mmu2/errors_list.h:197 ../../Firmware/mmu2/errors_list.h:237 +#: ../../Firmware/mmu2/errors_list.h:207 ../../Firmware/mmu2/errors_list.h:247 msgid "" "FINDA didn't switch off while unloading filament. Try unloading manually. " "Ensure filament can move and FINDA works." msgstr "" #. MSG_DESC_FINDA_DIDNT_TRIGGER c=20 r=8 -#: ../../Firmware/mmu2/errors_list.h:196 ../../Firmware/mmu2/errors_list.h:236 +#: ../../Firmware/mmu2/errors_list.h:206 ../../Firmware/mmu2/errors_list.h:246 msgid "" "FINDA didn't trigger while loading the filament. Ensure the filament can " "move and FINDA works." msgstr "" #. MSG_TITLE_FINDA_DIDNT_GO_OFF c=20 -#: ../../Firmware/mmu2/errors_list.h:119 ../../Firmware/mmu2/errors_list.h:157 +#: ../../Firmware/mmu2/errors_list.h:125 ../../Firmware/mmu2/errors_list.h:164 msgid "FINDA: FILAM. STUCK" msgstr "" #. MSG_FS_ACTION c=10 -#: ../../Firmware/messages.cpp:152 ../../Firmware/ultralcd.cpp:4245 -#: ../../Firmware/ultralcd.cpp:4248 +#: ../../Firmware/messages.cpp:152 ../../Firmware/ultralcd.cpp:4228 +#: ../../Firmware/ultralcd.cpp:4231 msgid "FS Action" msgstr "Azione FS" #. MSG_TITLE_FSENSOR_DIDNT_TRIGGER c=20 -#: ../../Firmware/mmu2/errors_list.h:120 ../../Firmware/mmu2/errors_list.h:158 +#: ../../Firmware/mmu2/errors_list.h:126 ../../Firmware/mmu2/errors_list.h:165 msgid "FSENSOR DIDNT TRIGG." msgstr "" #. MSG_TITLE_FSENSOR_TOO_EARLY c=20 -#: ../../Firmware/mmu2/errors_list.h:123 ../../Firmware/mmu2/errors_list.h:161 +#: ../../Firmware/mmu2/errors_list.h:129 ../../Firmware/mmu2/errors_list.h:168 msgid "FSENSOR TOO EARLY" msgstr "" #. MSG_TITLE_FSENSOR_DIDNT_GO_OFF c=20 -#: ../../Firmware/mmu2/errors_list.h:121 ../../Firmware/mmu2/errors_list.h:159 +#: ../../Firmware/mmu2/errors_list.h:127 ../../Firmware/mmu2/errors_list.h:166 msgid "FSENSOR: FIL. STUCK" msgstr "" #. MSG_TITLE_FW_RUNTIME_ERROR c=20 -#: ../../Firmware/mmu2/errors_list.h:152 ../../Firmware/mmu2/errors_list.h:190 +#: ../../Firmware/mmu2/errors_list.h:159 ../../Firmware/mmu2/errors_list.h:200 msgid "FW RUNTIME ERROR" msgstr "" #. MSG_FAIL_STATS c=18 -#: ../../Firmware/ultralcd.cpp:5602 +#: ../../Firmware/ultralcd.cpp:5585 msgid "Fail stats" msgstr "Stat. fallimenti" #. MSG_MMU_FAIL_STATS c=18 -#: ../../Firmware/ultralcd.cpp:5605 +#: ../../Firmware/ultralcd.cpp:5588 msgid "Fail stats MMU" msgstr "Stat.fall. MMU" #. MSG_FALSE_TRIGGERING c=20 -#: ../../Firmware/ultralcd.cpp:7030 +#: ../../Firmware/ultralcd.cpp:7013 msgid "False triggering" msgstr "Falso innesco" #. MSG_FAN_SPEED c=14 -#: ../../Firmware/messages.cpp:34 ../../Firmware/ultralcd.cpp:5736 -#: ../../Firmware/ultralcd.cpp:5891 +#: ../../Firmware/messages.cpp:34 ../../Firmware/ultralcd.cpp:5719 +#: ../../Firmware/ultralcd.cpp:5874 msgid "Fan speed" msgstr "Velocita vent." #. MSG_SELFTEST_FAN c=20 -#: ../../Firmware/messages.cpp:90 ../../Firmware/ultralcd.cpp:7141 -#: ../../Firmware/ultralcd.cpp:7299 ../../Firmware/ultralcd.cpp:7300 -#: ../../Firmware/ultralcd.cpp:7301 +#: ../../Firmware/messages.cpp:90 ../../Firmware/ultralcd.cpp:7124 +#: ../../Firmware/ultralcd.cpp:7282 ../../Firmware/ultralcd.cpp:7283 +#: ../../Firmware/ultralcd.cpp:7284 msgid "Fan test" msgstr "Test ventola" #. MSG_FANS_CHECK c=13 -#: ../../Firmware/messages.cpp:31 ../../Firmware/ultralcd.cpp:4782 -#: ../../Firmware/ultralcd.cpp:5754 +#: ../../Firmware/messages.cpp:31 ../../Firmware/ultralcd.cpp:4765 +#: ../../Firmware/ultralcd.cpp:5737 msgid "Fans check" msgstr "Control.vent" @@ -680,111 +680,111 @@ msgid "Feeding to nozzle" msgstr "" #. MSG_FIL_RUNOUTS c=15 -#: ../../Firmware/messages.cpp:32 ../../Firmware/ultralcd.cpp:1246 -#: ../../Firmware/ultralcd.cpp:1275 ../../Firmware/ultralcd.cpp:1329 -#: ../../Firmware/ultralcd.cpp:1331 +#: ../../Firmware/messages.cpp:32 ../../Firmware/ultralcd.cpp:1233 +#: ../../Firmware/ultralcd.cpp:1262 ../../Firmware/ultralcd.cpp:1316 +#: ../../Firmware/ultralcd.cpp:1318 msgid "Fil. runouts" msgstr "Fil. esauriti" #. MSG_FSENSOR c=12 -#: ../../Firmware/messages.cpp:47 ../../Firmware/ultralcd.cpp:3473 -#: ../../Firmware/ultralcd.cpp:4225 ../../Firmware/ultralcd.cpp:4768 -#: ../../Firmware/ultralcd.cpp:5747 +#: ../../Firmware/messages.cpp:47 ../../Firmware/ultralcd.cpp:3456 +#: ../../Firmware/ultralcd.cpp:4208 ../../Firmware/ultralcd.cpp:4751 +#: ../../Firmware/ultralcd.cpp:5730 msgid "Fil. sensor" msgstr "Sensore fil." #. MSG_FILAMENT c=17 #: ../../Firmware/Tcodes.cpp:33 ../../Firmware/messages.cpp:33 -#: ../../Firmware/ultralcd.cpp:3806 +#: ../../Firmware/ultralcd.cpp:3789 msgid "Filament" msgstr "Filamento" #. MSG_FILAMENT_CLEAN c=20 r=2 -#: ../../Firmware/messages.cpp:37 ../../Firmware/ultralcd.cpp:2290 -#: ../../Firmware/ultralcd.cpp:2294 +#: ../../Firmware/messages.cpp:37 ../../Firmware/ultralcd.cpp:2277 +#: ../../Firmware/ultralcd.cpp:2281 msgid "Filament extruding & with correct color?" msgstr "Filamento estruso e con colore corretto?" #. MSG_NOT_LOADED c=19 -#: ../../Firmware/ultralcd.cpp:2229 +#: ../../Firmware/ultralcd.cpp:2216 msgid "Filament not loaded" msgstr "Fil. non caricato" #. MSG_SELFTEST_FILAMENT_SENSOR c=17 -#: ../../Firmware/messages.cpp:96 ../../Firmware/ultralcd.cpp:7025 -#: ../../Firmware/ultralcd.cpp:7029 ../../Firmware/ultralcd.cpp:7033 -#: ../../Firmware/ultralcd.cpp:7328 +#: ../../Firmware/messages.cpp:96 ../../Firmware/ultralcd.cpp:7008 +#: ../../Firmware/ultralcd.cpp:7012 ../../Firmware/ultralcd.cpp:7016 +#: ../../Firmware/ultralcd.cpp:7311 msgid "Filament sensor" msgstr "Sensore filam." #. MSG_DESC_FSENSOR_DIDNT_GO_OFF c=20 r=8 -#: ../../Firmware/mmu2/errors_list.h:199 ../../Firmware/mmu2/errors_list.h:239 +#: ../../Firmware/mmu2/errors_list.h:209 ../../Firmware/mmu2/errors_list.h:249 msgid "" "Filament sensor didn't switch off while unloading filament. Ensure filament " "can move and the sensor works." msgstr "" #. MSG_DESC_FSENSOR_DIDNT_TRIGGER c=20 r=8 -#: ../../Firmware/mmu2/errors_list.h:198 ../../Firmware/mmu2/errors_list.h:238 +#: ../../Firmware/mmu2/errors_list.h:208 ../../Firmware/mmu2/errors_list.h:248 msgid "" "Filament sensor didn't trigger while loading the filament. Ensure the " "filament reached the fsensor and the sensor works." msgstr "" #. MSG_DESC_FSENSOR_TOO_EARLY c=20 r=8 -#: ../../Firmware/mmu2/errors_list.h:201 ../../Firmware/mmu2/errors_list.h:241 +#: ../../Firmware/mmu2/errors_list.h:211 ../../Firmware/mmu2/errors_list.h:251 msgid "" "Filament sensor triggered too early while loading to extruder. Check there " "isn't anything stuck in PTFE tube. Check that sensor reads properly." msgstr "" #. MSG_FILAMENT_USED c=19 -#: ../../Firmware/ultralcd.cpp:2363 +#: ../../Firmware/ultralcd.cpp:2350 msgid "Filament used" msgstr "Fil. utilizzato" #. MSG_FILE_INCOMPLETE c=20 r=3 -#: ../../Firmware/ultralcd.cpp:7460 +#: ../../Firmware/ultralcd.cpp:7442 msgid "File incomplete. Continue anyway?" msgstr "File incompleto. Continuare comunque?" #. MSG_FINISHING_MOVEMENTS c=20 #: ../../Firmware/messages.cpp:41 ../../Firmware/mmu2_progress_converter.cpp:43 -#: ../../Firmware/ultralcd.cpp:5323 ../../Firmware/ultralcd.cpp:5643 +#: ../../Firmware/ultralcd.cpp:5306 ../../Firmware/ultralcd.cpp:5626 msgid "Finishing movements" msgstr "Finaliz. spostamenti" #. MSG_V2_CALIBRATION c=18 -#: ../../Firmware/messages.cpp:125 ../../Firmware/ultralcd.cpp:4869 -#: ../../Firmware/ultralcd.cpp:5433 +#: ../../Firmware/messages.cpp:125 ../../Firmware/ultralcd.cpp:4852 +#: ../../Firmware/ultralcd.cpp:5416 msgid "First layer cal." msgstr "Cal. primo strato" #. MSG_WIZARD_SELFTEST c=20 r=8 -#: ../../Firmware/ultralcd.cpp:4032 +#: ../../Firmware/ultralcd.cpp:4015 msgid "First, I will run the selftest to check most common assembly problems." msgstr "" "Per primo avviero l'autotest per controllare gli errori di assemblaggio piu " "comuni." #. MSG_FLOW c=15 -#: ../../Firmware/ultralcd.cpp:5737 +#: ../../Firmware/ultralcd.cpp:5720 msgid "Flow" msgstr "Flusso" #. MSG_SELFTEST_PART_FAN c=20 -#: ../../Firmware/messages.cpp:87 ../../Firmware/ultralcd.cpp:6995 -#: ../../Firmware/ultralcd.cpp:7147 ../../Firmware/ultralcd.cpp:7152 +#: ../../Firmware/messages.cpp:87 ../../Firmware/ultralcd.cpp:6978 +#: ../../Firmware/ultralcd.cpp:7130 ../../Firmware/ultralcd.cpp:7135 msgid "Front print fan?" msgstr "Ventola frontale?" #. MSG_BED_CORRECTION_FRONT c=14 -#: ../../Firmware/ultralcd.cpp:2752 +#: ../../Firmware/ultralcd.cpp:2739 msgid "Front side[μm]" msgstr "Fronte [μm]" #. MSG_SELFTEST_FANS c=20 -#: ../../Firmware/ultralcd.cpp:7019 +#: ../../Firmware/ultralcd.cpp:7002 msgid "Front/left fans" msgstr "Ventola frontale/sin" @@ -833,42 +833,42 @@ msgstr "" "firmware. Stampa annullata." #. MSG_GCODE c=8 -#: ../../Firmware/messages.cpp:134 ../../Firmware/ultralcd.cpp:4653 -#: ../../Firmware/ultralcd.cpp:4656 ../../Firmware/ultralcd.cpp:4659 -#: ../../Firmware/ultralcd.cpp:4662 +#: ../../Firmware/messages.cpp:134 ../../Firmware/ultralcd.cpp:4636 +#: ../../Firmware/ultralcd.cpp:4639 ../../Firmware/ultralcd.cpp:4642 +#: ../../Firmware/ultralcd.cpp:4645 msgid "Gcode" -msgstr "" +msgstr "Gcode" #. MSG_HW_SETUP c=18 -#: ../../Firmware/messages.cpp:103 ../../Firmware/ultralcd.cpp:4670 -#: ../../Firmware/ultralcd.cpp:4689 ../../Firmware/ultralcd.cpp:4789 +#: ../../Firmware/messages.cpp:103 ../../Firmware/ultralcd.cpp:4653 +#: ../../Firmware/ultralcd.cpp:4672 ../../Firmware/ultralcd.cpp:4772 msgid "HW Setup" msgstr "Impostazioni HW" #. MSG_SELFTEST_HEATERTHERMISTOR c=20 -#: ../../Firmware/ultralcd.cpp:6967 +#: ../../Firmware/ultralcd.cpp:6950 msgid "Heater/Thermistor" msgstr "Riscald./Termist." #. MSG_HEATING c=20 -#: ../../Firmware/Marlin_main.cpp:6236 ../../Firmware/messages.cpp:48 -#: ../../Firmware/ultralcd.cpp:577 +#: ../../Firmware/Marlin_main.cpp:6237 ../../Firmware/messages.cpp:48 +#: ../../Firmware/ultralcd.cpp:574 msgid "Heating" msgstr "Riscaldamento..." #. MSG_BED_HEATING_SAFETY_DISABLED c=20 r=4 -#: ../../Firmware/Marlin_main.cpp:9477 +#: ../../Firmware/Marlin_main.cpp:9478 msgid "Heating disabled by safety timer." msgstr "Riscaldamento fermato dal timer di sicurezza." #. MSG_HEATING_COMPLETE c=20 -#: ../../Firmware/Marlin_main.cpp:6267 ../../Firmware/messages.cpp:49 -#: ../../Firmware/ultralcd.cpp:580 +#: ../../Firmware/Marlin_main.cpp:6268 ../../Firmware/messages.cpp:49 +#: ../../Firmware/ultralcd.cpp:577 msgid "Heating done." msgstr "Riscald. completo" #. MSG_WIZARD_WELCOME_SHIPPING c=20 r=12 -#: ../../Firmware/messages.cpp:123 ../../Firmware/ultralcd.cpp:4008 +#: ../../Firmware/messages.cpp:123 ../../Firmware/ultralcd.cpp:3991 msgid "" "Hi, I am your Original Prusa i3 printer. I will guide you through a short " "setup process, in which the Z-axis will be calibrated. Then, you will be " @@ -879,7 +879,7 @@ msgstr "" "stampare." #. MSG_WIZARD_WELCOME c=20 r=7 -#: ../../Firmware/messages.cpp:122 ../../Firmware/ultralcd.cpp:4011 +#: ../../Firmware/messages.cpp:122 ../../Firmware/ultralcd.cpp:3994 msgid "" "Hi, I am your Original Prusa i3 printer. Would you like me to guide you " "through the setup process?" @@ -888,9 +888,9 @@ msgstr "" "processo di configurazione?" #. MSG_HIGH_POWER c=10 -#: ../../Firmware/messages.cpp:105 ../../Firmware/ultralcd.cpp:4356 -#: ../../Firmware/ultralcd.cpp:4365 ../../Firmware/ultralcd.cpp:5775 -#: ../../Firmware/ultralcd.cpp:5778 +#: ../../Firmware/messages.cpp:105 ../../Firmware/ultralcd.cpp:4339 +#: ../../Firmware/ultralcd.cpp:4348 ../../Firmware/ultralcd.cpp:5758 +#: ../../Firmware/ultralcd.cpp:5761 msgid "High power" msgstr "Forte" @@ -898,35 +898,35 @@ msgstr "Forte" #: ../../Firmware/mmu2_progress_converter.cpp:29 #: ../../Firmware/mmu2_progress_converter.cpp:60 msgid "Homing" -msgstr "" +msgstr "Homing" #. MSG_WIZARD_XYZ_CAL c=20 r=8 -#: ../../Firmware/ultralcd.cpp:4041 +#: ../../Firmware/ultralcd.cpp:4024 msgid "I will run xyz calibration now. It will take approx. 12 mins." msgstr "Adesso avviero una Calibrazione XYZ. Puo durare circa 12 min." #. MSG_WIZARD_Z_CAL c=20 r=8 -#: ../../Firmware/ultralcd.cpp:4049 +#: ../../Firmware/ultralcd.cpp:4032 msgid "I will run z calibration now." msgstr "Adesso avviero la Calibrazione Z." #. MSG_TITLE_IDLER_CANNOT_HOME c=20 -#: ../../Firmware/mmu2/errors_list.h:127 ../../Firmware/mmu2/errors_list.h:164 +#: ../../Firmware/mmu2/errors_list.h:133 ../../Firmware/mmu2/errors_list.h:171 msgid "IDLER CANNOT HOME" msgstr "" #. MSG_TITLE_IDLER_CANNOT_MOVE c=20 -#: ../../Firmware/mmu2/errors_list.h:126 ../../Firmware/mmu2/errors_list.h:165 +#: ../../Firmware/mmu2/errors_list.h:132 ../../Firmware/mmu2/errors_list.h:172 msgid "IDLER CANNOT MOVE" msgstr "" #. MSG_TITLE_INVALID_TOOL c=20 -#: ../../Firmware/mmu2/errors_list.h:149 ../../Firmware/mmu2/errors_list.h:187 +#: ../../Firmware/mmu2/errors_list.h:156 ../../Firmware/mmu2/errors_list.h:197 msgid "INVALID TOOL" msgstr "" #. MSG_ADDITIONAL_SHEETS c=20 r=9 -#: ../../Firmware/ultralcd.cpp:4115 +#: ../../Firmware/ultralcd.cpp:4098 msgid "" "If you have additional steel sheets, calibrate their presets in Settings - " "HW Setup - Steel sheets." @@ -937,25 +937,25 @@ msgstr "" #. MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE1 c=20 r=4 #: ../../Firmware/mesh_bed_calibration.cpp:2530 msgid "Improving bed calibration point" -msgstr "" +msgstr "Miglioramento punto di calibrazione del piatto" #. MSG_INFO_SCREEN c=18 -#: ../../Firmware/messages.cpp:117 ../../Firmware/ultralcd.cpp:5487 +#: ../../Firmware/messages.cpp:117 ../../Firmware/ultralcd.cpp:5470 msgid "Info screen" msgstr "Schermata info" #. MSG_INIT_SDCARD c=18 -#: ../../Firmware/ultralcd.cpp:5554 +#: ../../Firmware/ultralcd.cpp:5537 msgid "Init. SD card" -msgstr "" +msgstr "Inizial. scheda SD" #. MSG_INSERT_FILAMENT c=20 -#: ../../Firmware/ultralcd.cpp:2165 +#: ../../Firmware/ultralcd.cpp:2152 msgid "Insert filament" msgstr "Inserire filamento" #. MSG_INSERT_FIL c=20 r=6 -#: ../../Firmware/ultralcd.cpp:6233 +#: ../../Firmware/ultralcd.cpp:6216 msgid "" "Insert the filament (do not load it) into the extruder and then press the " "knob." @@ -963,21 +963,21 @@ msgstr "" "Inserire filamento (senza caricarlo) nell'estrusore e premere la manopola." #. MSG_DESC_FW_RUNTIME_ERROR c=20 r=11 -#: ../../Firmware/mmu2/errors_list.h:232 ../../Firmware/mmu2/errors_list.h:270 +#: ../../Firmware/mmu2/errors_list.h:242 ../../Firmware/mmu2/errors_list.h:283 msgid "" "Internal runtime error. Try resetting the MMU unit or updating the firmware. " "If the issue persists, contact support." msgstr "" #. MSG_FILAMENT_LOADED c=20 r=2 -#: ../../Firmware/messages.cpp:38 ../../Firmware/ultralcd.cpp:3827 -#: ../../Firmware/ultralcd.cpp:4074 +#: ../../Firmware/messages.cpp:38 ../../Firmware/ultralcd.cpp:3810 +#: ../../Firmware/ultralcd.cpp:4057 msgid "Is filament loaded?" msgstr "Il filamento e' stato caricato?" #. MSG_STEEL_SHEET_CHECK c=20 r=2 -#: ../../Firmware/Marlin_main.cpp:3301 ../../Firmware/Marlin_main.cpp:4911 -#: ../../Firmware/messages.cpp:110 ../../Firmware/ultralcd.cpp:4050 +#: ../../Firmware/Marlin_main.cpp:3302 ../../Firmware/Marlin_main.cpp:4912 +#: ../../Firmware/messages.cpp:110 ../../Firmware/ultralcd.cpp:4033 msgid "Is steel sheet on heatbed?" msgstr "Piastra d'acciaio su piano riscaldato?" @@ -987,261 +987,262 @@ msgid "Iteration" msgstr "Iterazione" #. MSG_LAST_PRINT c=18 -#: ../../Firmware/messages.cpp:54 ../../Firmware/ultralcd.cpp:1166 -#: ../../Firmware/ultralcd.cpp:1299 +#: ../../Firmware/messages.cpp:54 ../../Firmware/ultralcd.cpp:1153 +#: ../../Firmware/ultralcd.cpp:1286 msgid "Last print" msgstr "Ultima stampa" #. MSG_LAST_PRINT_FAILURES c=20 -#: ../../Firmware/messages.cpp:55 ../../Firmware/ultralcd.cpp:1186 -#: ../../Firmware/ultralcd.cpp:1273 ../../Firmware/ultralcd.cpp:1328 +#: ../../Firmware/messages.cpp:55 ../../Firmware/ultralcd.cpp:1173 +#: ../../Firmware/ultralcd.cpp:1260 ../../Firmware/ultralcd.cpp:1315 msgid "Last print failures" msgstr "Errori ultima stampa" #. MSG_LEFT c=10 -#: ../../Firmware/ultralcd.cpp:2494 +#: ../../Firmware/ultralcd.cpp:2481 msgid "Left" msgstr "Sinistra" #. MSG_SELFTEST_EXTRUDER_FAN c=20 -#: ../../Firmware/messages.cpp:88 ../../Firmware/ultralcd.cpp:7001 -#: ../../Firmware/ultralcd.cpp:7147 ../../Firmware/ultralcd.cpp:7152 +#: ../../Firmware/messages.cpp:88 ../../Firmware/ultralcd.cpp:6984 +#: ../../Firmware/ultralcd.cpp:7130 ../../Firmware/ultralcd.cpp:7135 msgid "Left hotend fan?" msgstr "Vent SX hotend?" #. MSG_BED_CORRECTION_LEFT c=14 -#: ../../Firmware/ultralcd.cpp:2750 +#: ../../Firmware/ultralcd.cpp:2737 msgid "Left side [μm]" msgstr "Sinistra [μm]" #. MSG_BL_HIGH c=12 -#: ../../Firmware/messages.cpp:156 ../../Firmware/ultralcd.cpp:5860 +#: ../../Firmware/messages.cpp:156 ../../Firmware/ultralcd.cpp:5843 msgid "Level Bright" msgstr "Liv. Chiaro" #. MSG_BL_LOW c=12 -#: ../../Firmware/messages.cpp:157 ../../Firmware/ultralcd.cpp:5861 +#: ../../Firmware/messages.cpp:157 ../../Firmware/ultralcd.cpp:5844 msgid "Level Dimmed" msgstr "Liv. Scuro" #. MSG_LIN_CORRECTION c=18 -#: ../../Firmware/ultralcd.cpp:4797 +#: ../../Firmware/ultralcd.cpp:4780 msgid "Lin. correction" msgstr "Correzione lineare" #. MSG_BABYSTEP_Z c=18 -#: ../../Firmware/messages.cpp:10 ../../Firmware/ultralcd.cpp:4809 -#: ../../Firmware/ultralcd.cpp:5502 +#: ../../Firmware/messages.cpp:10 ../../Firmware/ultralcd.cpp:4792 +#: ../../Firmware/ultralcd.cpp:5485 msgid "Live adjust Z" msgstr "Compensazione Z" #. MSG_LOAD_ALL c=18 -#: ../../Firmware/messages.cpp:172 ../../Firmware/ultralcd.cpp:5098 -#: ../../Firmware/ultralcd.cpp:5178 +#: ../../Firmware/messages.cpp:172 ../../Firmware/ultralcd.cpp:5081 +#: ../../Firmware/ultralcd.cpp:5161 msgid "Load All" -msgstr "" +msgstr "Carica tutti" #. MSG_LOAD_FILAMENT c=17 -#: ../../Firmware/messages.cpp:56 ../../Firmware/ultralcd.cpp:5100 -#: ../../Firmware/ultralcd.cpp:5119 ../../Firmware/ultralcd.cpp:5180 -#: ../../Firmware/ultralcd.cpp:5571 ../../Firmware/ultralcd.cpp:5589 +#: ../../Firmware/messages.cpp:56 ../../Firmware/ultralcd.cpp:5083 +#: ../../Firmware/ultralcd.cpp:5102 ../../Firmware/ultralcd.cpp:5163 +#: ../../Firmware/ultralcd.cpp:5554 ../../Firmware/ultralcd.cpp:5572 msgid "Load filament" msgstr "Carica filamento" #. MSG_LOAD_TO_EXTRUDER c=18 -#: ../../Firmware/messages.cpp:57 ../../Firmware/ultralcd.cpp:5572 +#: ../../Firmware/messages.cpp:57 ../../Firmware/ultralcd.cpp:5555 msgid "Load to extruder" msgstr "" #. MSG_LOAD_TO_NOZZLE c=18 -#: ../../Firmware/ultralcd.cpp:5573 +#: ../../Firmware/ultralcd.cpp:5556 msgid "Load to nozzle" msgstr "Carica ugello" #. MSG_LOADING_COLOR c=20 -#: ../../Firmware/ultralcd.cpp:2201 +#: ../../Firmware/ultralcd.cpp:2188 msgid "Loading color" msgstr "Caricando colore" #. MSG_LOADING_FILAMENT c=20 -#: ../../Firmware/Marlin_main.cpp:3651 ../../Firmware/messages.cpp:58 -#: ../../Firmware/mmu2.cpp:438 ../../Firmware/mmu2.cpp:468 +#: ../../Firmware/Marlin_main.cpp:3652 ../../Firmware/messages.cpp:58 +#: ../../Firmware/mmu2.cpp:456 ../../Firmware/mmu2.cpp:486 #: ../../Firmware/mmu2_progress_converter.cpp:51 -#: ../../Firmware/ultralcd.cpp:2212 ../../Firmware/ultralcd.cpp:3919 +#: ../../Firmware/ultralcd.cpp:2199 ../../Firmware/ultralcd.cpp:3902 msgid "Loading filament" msgstr "Caricando filamento" #. MSG_LOOSE_PULLEY c=20 -#: ../../Firmware/ultralcd.cpp:7007 +#: ../../Firmware/ultralcd.cpp:6990 msgid "Loose pulley" msgstr "Puleggia lenta" #. MSG_SOUND_LOUD c=7 -#: ../../Firmware/messages.cpp:145 ../../Firmware/ultralcd.cpp:4448 -#: ../../Firmware/ultralcd.cpp:4460 +#: ../../Firmware/messages.cpp:145 ../../Firmware/ultralcd.cpp:4431 +#: ../../Firmware/ultralcd.cpp:4443 msgid "Loud" msgstr "Forte" #. MSG_TITLE_FW_UPDATE_NEEDED c=20 -#: ../../Firmware/mmu2/errors_list.h:151 ../../Firmware/mmu2/errors_list.h:189 +#: ../../Firmware/mmu2/errors_list.h:158 ../../Firmware/mmu2/errors_list.h:199 msgid "MMU FW UPDATE NEEDED" msgstr "" #. MSG_DESC_QUEUE_FULL c=20 r=8 -#: ../../Firmware/mmu2/errors_list.h:230 ../../Firmware/mmu2/errors_list.h:268 +#: ../../Firmware/mmu2/errors_list.h:240 ../../Firmware/mmu2/errors_list.h:281 msgid "MMU Firmware internal error, please reset the MMU." msgstr "" #. MSG_MMU_MODE c=8 -#: ../../Firmware/messages.cpp:138 ../../Firmware/ultralcd.cpp:4379 -#: ../../Firmware/ultralcd.cpp:4380 +#: ../../Firmware/messages.cpp:138 ../../Firmware/ultralcd.cpp:4362 +#: ../../Firmware/ultralcd.cpp:4363 msgid "MMU Mode" msgstr "Mod. MMU" #. MSG_TITLE_MMU_NOT_RESPONDING c=20 -#: ../../Firmware/mmu2/errors_list.h:146 ../../Firmware/mmu2/errors_list.h:184 +#: ../../Firmware/mmu2/errors_list.h:153 ../../Firmware/mmu2/errors_list.h:194 msgid "MMU NOT RESPONDING" msgstr "" #. MSG_MMU_RESTORE_TEMP c=20 r=4 -#: ../../Firmware/mmu2.cpp:598 +#: ../../Firmware/mmu2.cpp:619 msgid "MMU Retry: Restoring temperature..." msgstr "" +#. MSG_TITLE_SELFTEST_FAILED c=20 +#: ../../Firmware/mmu2/errors_list.h:152 ../../Firmware/mmu2/errors_list.h:191 +#: ../../Firmware/mmu2/errors_list.h:192 ../../Firmware/mmu2/errors_list.h:193 +msgid "MMU SELFTEST FAILED" +msgstr "" + #. MSG_MMU_FAILS c=15 -#: ../../Firmware/messages.cpp:68 ../../Firmware/ultralcd.cpp:1187 -#: ../../Firmware/ultralcd.cpp:1215 +#: ../../Firmware/messages.cpp:68 ../../Firmware/ultralcd.cpp:1174 +#: ../../Firmware/ultralcd.cpp:1202 msgid "MMU fails" msgstr "Fallimenti MMU" #. MSG_MMU_LOAD_FAILS c=15 -#: ../../Firmware/messages.cpp:69 ../../Firmware/ultralcd.cpp:1188 +#: ../../Firmware/messages.cpp:69 ../../Firmware/ultralcd.cpp:1175 msgid "MMU load fails" msgstr "Car MMU falliti" #. MSG_DESC_COMMUNICATION_ERROR c=20 r=9 -#: ../../Firmware/mmu2/errors_list.h:227 ../../Firmware/mmu2/errors_list.h:265 +#: ../../Firmware/mmu2/errors_list.h:237 ../../Firmware/mmu2/errors_list.h:278 msgid "" "MMU unit not responding correctly. Check the wiring and connectors. If the " "issue persists, contact support." msgstr "" #. MSG_DESC_MMU_NOT_RESPONDING c=20 r=8 -#: ../../Firmware/mmu2/errors_list.h:226 ../../Firmware/mmu2/errors_list.h:264 +#: ../../Firmware/mmu2/errors_list.h:236 ../../Firmware/mmu2/errors_list.h:277 msgid "" "MMU unit not responding. Check the wiring and connectors. If the issue " "persists, contact support." msgstr "" #. MSG_MMU_CONNECTED c=18 -#: ../../Firmware/ultralcd.cpp:1679 +#: ../../Firmware/ultralcd.cpp:1666 msgid "MMU2 connected" msgstr "MMU2 connessa" #. MSG_MAGNETS_COMP c=13 -#: ../../Firmware/messages.cpp:151 ../../Firmware/ultralcd.cpp:5834 +#: ../../Firmware/messages.cpp:151 ../../Firmware/ultralcd.cpp:5817 msgid "Magnets comp." msgstr "Comp. Magneti" #. MSG_MAIN c=18 -#: ../../Firmware/messages.cpp:62 ../../Firmware/ultralcd.cpp:1165 -#: ../../Firmware/ultralcd.cpp:1298 ../../Firmware/ultralcd.cpp:1340 -#: ../../Firmware/ultralcd.cpp:1644 ../../Firmware/ultralcd.cpp:4757 -#: ../../Firmware/ultralcd.cpp:4863 ../../Firmware/ultralcd.cpp:5097 -#: ../../Firmware/ultralcd.cpp:5117 ../../Firmware/ultralcd.cpp:5135 -#: ../../Firmware/ultralcd.cpp:5153 ../../Firmware/ultralcd.cpp:5177 -#: ../../Firmware/ultralcd.cpp:5730 +#: ../../Firmware/messages.cpp:62 ../../Firmware/ultralcd.cpp:1152 +#: ../../Firmware/ultralcd.cpp:1285 ../../Firmware/ultralcd.cpp:1327 +#: ../../Firmware/ultralcd.cpp:1631 ../../Firmware/ultralcd.cpp:4740 +#: ../../Firmware/ultralcd.cpp:4846 ../../Firmware/ultralcd.cpp:5080 +#: ../../Firmware/ultralcd.cpp:5100 ../../Firmware/ultralcd.cpp:5118 +#: ../../Firmware/ultralcd.cpp:5136 ../../Firmware/ultralcd.cpp:5160 +#: ../../Firmware/ultralcd.cpp:5713 msgid "Main" msgstr "Menu principale" #. MSG_MEASURED_SKEW c=14 -#: ../../Firmware/ultralcd.cpp:2535 +#: ../../Firmware/ultralcd.cpp:2522 msgid "Measured skew" msgstr "Dev. misurata" #. MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1 c=20 r=3 -#: ../../Firmware/Marlin_main.cpp:3282 +#: ../../Firmware/Marlin_main.cpp:3283 #: ../../Firmware/mesh_bed_calibration.cpp:2836 ../../Firmware/messages.cpp:66 msgid "Measuring reference height of calibration point" msgstr "Misura altezza di rif. del punto di calib." #. MSG_MESH c=12 -#: ../../Firmware/messages.cpp:148 ../../Firmware/ultralcd.cpp:5830 +#: ../../Firmware/messages.cpp:148 ../../Firmware/ultralcd.cpp:5813 msgid "Mesh" msgstr "Griglia" #. MSG_MESH_BED_LEVELING c=18 -#: ../../Firmware/messages.cpp:149 ../../Firmware/ultralcd.cpp:4794 -#: ../../Firmware/ultralcd.cpp:4881 +#: ../../Firmware/messages.cpp:149 ../../Firmware/ultralcd.cpp:4777 +#: ../../Firmware/ultralcd.cpp:4864 msgid "Mesh Bed Leveling" msgstr "Liv. griglia piano" #. MSG_MODE c=6 -#: ../../Firmware/messages.cpp:104 ../../Firmware/ultralcd.cpp:4334 -#: ../../Firmware/ultralcd.cpp:4336 ../../Firmware/ultralcd.cpp:4356 -#: ../../Firmware/ultralcd.cpp:4359 ../../Firmware/ultralcd.cpp:4362 -#: ../../Firmware/ultralcd.cpp:4365 ../../Firmware/ultralcd.cpp:5761 -#: ../../Firmware/ultralcd.cpp:5768 ../../Firmware/ultralcd.cpp:5775 -#: ../../Firmware/ultralcd.cpp:5776 ../../Firmware/ultralcd.cpp:5777 -#: ../../Firmware/ultralcd.cpp:5778 ../../Firmware/ultralcd.cpp:5862 +#: ../../Firmware/messages.cpp:104 ../../Firmware/ultralcd.cpp:4317 +#: ../../Firmware/ultralcd.cpp:4319 ../../Firmware/ultralcd.cpp:4339 +#: ../../Firmware/ultralcd.cpp:4342 ../../Firmware/ultralcd.cpp:4345 +#: ../../Firmware/ultralcd.cpp:4348 ../../Firmware/ultralcd.cpp:5744 +#: ../../Firmware/ultralcd.cpp:5751 ../../Firmware/ultralcd.cpp:5758 +#: ../../Firmware/ultralcd.cpp:5759 ../../Firmware/ultralcd.cpp:5760 +#: ../../Firmware/ultralcd.cpp:5761 ../../Firmware/ultralcd.cpp:5845 msgid "Mode" msgstr "Mod." #. MSG_MODE_CHANGE_IN_PROGRESS c=20 r=3 -#: ../../Firmware/ultralcd.cpp:3587 +#: ../../Firmware/ultralcd.cpp:3570 msgid "Mode change in progress..." msgstr "Cambio modalita in corso..." #. MSG_MODEL c=8 -#: ../../Firmware/messages.cpp:133 ../../Firmware/ultralcd.cpp:4573 -#: ../../Firmware/ultralcd.cpp:4576 ../../Firmware/ultralcd.cpp:4579 -#: ../../Firmware/ultralcd.cpp:4582 +#: ../../Firmware/messages.cpp:133 ../../Firmware/ultralcd.cpp:4556 +#: ../../Firmware/ultralcd.cpp:4559 ../../Firmware/ultralcd.cpp:4562 +#: ../../Firmware/ultralcd.cpp:4565 msgid "Model" msgstr "Modello" #. MSG_DESC_TMC c=20 r=8 -#: ../../Firmware/mmu2/errors_list.h:207 ../../Firmware/mmu2/errors_list.h:246 -#: ../../Firmware/mmu2/errors_list.h:247 ../../Firmware/mmu2/errors_list.h:248 -#: ../../Firmware/mmu2/errors_list.h:249 ../../Firmware/mmu2/errors_list.h:250 -#: ../../Firmware/mmu2/errors_list.h:251 ../../Firmware/mmu2/errors_list.h:252 -#: ../../Firmware/mmu2/errors_list.h:253 ../../Firmware/mmu2/errors_list.h:254 -#: ../../Firmware/mmu2/errors_list.h:255 ../../Firmware/mmu2/errors_list.h:256 +#: ../../Firmware/mmu2/errors_list.h:217 ../../Firmware/mmu2/errors_list.h:256 #: ../../Firmware/mmu2/errors_list.h:257 ../../Firmware/mmu2/errors_list.h:258 #: ../../Firmware/mmu2/errors_list.h:259 ../../Firmware/mmu2/errors_list.h:260 #: ../../Firmware/mmu2/errors_list.h:261 ../../Firmware/mmu2/errors_list.h:262 -#: ../../Firmware/mmu2/errors_list.h:263 +#: ../../Firmware/mmu2/errors_list.h:263 ../../Firmware/mmu2/errors_list.h:264 +#: ../../Firmware/mmu2/errors_list.h:265 ../../Firmware/mmu2/errors_list.h:266 +#: ../../Firmware/mmu2/errors_list.h:267 ../../Firmware/mmu2/errors_list.h:268 +#: ../../Firmware/mmu2/errors_list.h:269 ../../Firmware/mmu2/errors_list.h:270 +#: ../../Firmware/mmu2/errors_list.h:271 ../../Firmware/mmu2/errors_list.h:272 +#: ../../Firmware/mmu2/errors_list.h:273 ../../Firmware/mmu2/errors_list.h:274 +#: ../../Firmware/mmu2/errors_list.h:275 ../../Firmware/mmu2/errors_list.h:276 msgid "More details online." -msgstr "" - -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "" +msgstr "Piu dettagli online." #. MSG_SELFTEST_MOTOR c=18 -#: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 -#: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 +#: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6964 +#: ../../Firmware/ultralcd.cpp:6973 ../../Firmware/ultralcd.cpp:6991 msgid "Motor" msgstr "Motore" #. MSG_MOVE_X c=18 -#: ../../Firmware/ultralcd.cpp:3509 +#: ../../Firmware/ultralcd.cpp:3492 msgid "Move X" msgstr "Sposta X" #. MSG_MOVE_Y c=18 -#: ../../Firmware/ultralcd.cpp:3510 +#: ../../Firmware/ultralcd.cpp:3493 msgid "Move Y" msgstr "Sposta Y" #. MSG_MOVE_Z c=18 -#: ../../Firmware/ultralcd.cpp:3511 +#: ../../Firmware/ultralcd.cpp:3494 msgid "Move Z" msgstr "Sposta Z" #. MSG_MOVE_AXIS c=18 -#: ../../Firmware/ultralcd.cpp:4763 +#: ../../Firmware/ultralcd.cpp:4746 msgid "Move axis" msgstr "Muovi asse" @@ -1253,10 +1254,10 @@ msgstr "" #. MSG_NA c=3 #: ../../Firmware/menu.cpp:196 ../../Firmware/messages.cpp:128 -#: ../../Firmware/ultralcd.cpp:2500 ../../Firmware/ultralcd.cpp:2545 -#: ../../Firmware/ultralcd.cpp:3434 ../../Firmware/ultralcd.cpp:4229 -#: ../../Firmware/ultralcd.cpp:4230 ../../Firmware/ultralcd.cpp:4232 -#: ../../Firmware/ultralcd.cpp:5834 +#: ../../Firmware/ultralcd.cpp:2487 ../../Firmware/ultralcd.cpp:2532 +#: ../../Firmware/ultralcd.cpp:3417 ../../Firmware/ultralcd.cpp:4212 +#: ../../Firmware/ultralcd.cpp:4213 ../../Firmware/ultralcd.cpp:4215 +#: ../../Firmware/ultralcd.cpp:5817 msgid "N/A" msgstr "N/D" @@ -1266,75 +1267,75 @@ msgid "New firmware version available:" msgstr "Nuova vers. firmware disponibile:" #. MSG_NO c=4 -#: ../../Firmware/messages.cpp:70 ../../Firmware/ultralcd.cpp:2802 -#: ../../Firmware/ultralcd.cpp:3170 ../../Firmware/ultralcd.cpp:4747 -#: ../../Firmware/ultralcd.cpp:5997 +#: ../../Firmware/messages.cpp:70 ../../Firmware/ultralcd.cpp:2789 +#: ../../Firmware/ultralcd.cpp:3157 ../../Firmware/ultralcd.cpp:4730 +#: ../../Firmware/ultralcd.cpp:5980 msgid "No" msgstr "No" #. MSG_NO_CARD c=18 -#: ../../Firmware/ultralcd.cpp:5552 +#: ../../Firmware/ultralcd.cpp:5535 msgid "No SD card" msgstr "Nessuna SD" #. MSG_NO_MOVE c=20 -#: ../../Firmware/Marlin_main.cpp:5402 +#: ../../Firmware/Marlin_main.cpp:5403 msgid "No move." msgstr "Nessun movimento." #. MSG_NONE c=8 -#: ../../Firmware/messages.cpp:130 ../../Firmware/ultralcd.cpp:4403 -#: ../../Firmware/ultralcd.cpp:4491 ../../Firmware/ultralcd.cpp:4500 -#: ../../Firmware/ultralcd.cpp:4573 ../../Firmware/ultralcd.cpp:4582 -#: ../../Firmware/ultralcd.cpp:4612 ../../Firmware/ultralcd.cpp:4621 -#: ../../Firmware/ultralcd.cpp:4653 ../../Firmware/ultralcd.cpp:4662 +#: ../../Firmware/messages.cpp:130 ../../Firmware/ultralcd.cpp:4386 +#: ../../Firmware/ultralcd.cpp:4474 ../../Firmware/ultralcd.cpp:4483 +#: ../../Firmware/ultralcd.cpp:4556 ../../Firmware/ultralcd.cpp:4565 +#: ../../Firmware/ultralcd.cpp:4595 ../../Firmware/ultralcd.cpp:4604 +#: ../../Firmware/ultralcd.cpp:4636 ../../Firmware/ultralcd.cpp:4645 msgid "None" msgstr "Nessuno" #. MSG_NORMAL c=7 -#: ../../Firmware/messages.cpp:108 ../../Firmware/ultralcd.cpp:4334 -#: ../../Firmware/ultralcd.cpp:4379 ../../Firmware/ultralcd.cpp:4395 -#: ../../Firmware/ultralcd.cpp:4414 ../../Firmware/ultralcd.cpp:5761 +#: ../../Firmware/messages.cpp:108 ../../Firmware/ultralcd.cpp:4317 +#: ../../Firmware/ultralcd.cpp:4362 ../../Firmware/ultralcd.cpp:4378 +#: ../../Firmware/ultralcd.cpp:4397 ../../Firmware/ultralcd.cpp:5744 msgid "Normal" msgstr "Normale" #. MSG_SELFTEST_NOTCONNECTED c=20 -#: ../../Firmware/ultralcd.cpp:6968 +#: ../../Firmware/ultralcd.cpp:6951 msgid "Not connected" msgstr "Non connesso" #. MSG_SELFTEST_FAN_NO c=19 -#: ../../Firmware/messages.cpp:91 ../../Firmware/ultralcd.cpp:7166 -#: ../../Firmware/ultralcd.cpp:7181 ../../Firmware/ultralcd.cpp:7189 +#: ../../Firmware/messages.cpp:91 ../../Firmware/ultralcd.cpp:7149 +#: ../../Firmware/ultralcd.cpp:7164 ../../Firmware/ultralcd.cpp:7172 msgid "Not spinning" msgstr "Non gira" #. MSG_WIZARD_V2_CAL c=20 r=8 -#: ../../Firmware/ultralcd.cpp:3928 +#: ../../Firmware/ultralcd.cpp:3911 msgid "" "Now I will calibrate distance between tip of the nozzle and heatbed surface." msgstr "Adesso calibro la distanza fra ugello e superfice del piatto." #. MSG_WIZARD_WILL_PREHEAT c=20 r=4 -#: ../../Firmware/ultralcd.cpp:4059 +#: ../../Firmware/ultralcd.cpp:4042 msgid "Now I will preheat nozzle for PLA." msgstr "Adesso preriscaldero l'ugello per PLA." #. MSG_REMOVE_TEST_PRINT c=20 r=4 -#: ../../Firmware/ultralcd.cpp:4048 +#: ../../Firmware/ultralcd.cpp:4031 msgid "Now remove the test print from steel sheet." msgstr "Ora rimuovete la stampa di prova dalla piastra in acciaio." #. MSG_NOZZLE c=10 -#: ../../Firmware/messages.cpp:71 ../../Firmware/ultralcd.cpp:1403 -#: ../../Firmware/ultralcd.cpp:4491 ../../Firmware/ultralcd.cpp:4494 -#: ../../Firmware/ultralcd.cpp:4497 ../../Firmware/ultralcd.cpp:4500 -#: ../../Firmware/ultralcd.cpp:5733 ../../Firmware/ultralcd.cpp:5880 +#: ../../Firmware/messages.cpp:71 ../../Firmware/ultralcd.cpp:1390 +#: ../../Firmware/ultralcd.cpp:4474 ../../Firmware/ultralcd.cpp:4477 +#: ../../Firmware/ultralcd.cpp:4480 ../../Firmware/ultralcd.cpp:4483 +#: ../../Firmware/ultralcd.cpp:5716 ../../Firmware/ultralcd.cpp:5863 msgid "Nozzle" msgstr "Ugello" #. MSG_NOZZLE_DIAMETER c=10 -#: ../../Firmware/messages.cpp:137 ../../Firmware/ultralcd.cpp:4544 +#: ../../Firmware/messages.cpp:137 ../../Firmware/ultralcd.cpp:4527 msgid "Nozzle d." msgstr "Dia.Ugello" @@ -1342,24 +1343,24 @@ msgstr "Dia.Ugello" #: ../../Firmware/mmu2_progress_converter.cpp:8 #: ../../Firmware/mmu2_progress_converter.cpp:34 msgid "OK" -msgstr "" +msgstr "OK" #. MSG_OFF c=3 #: ../../Firmware/SpoolJoin.cpp:40 ../../Firmware/menu.cpp:467 -#: ../../Firmware/messages.cpp:126 ../../Firmware/ultralcd.cpp:4225 -#: ../../Firmware/ultralcd.cpp:4236 ../../Firmware/ultralcd.cpp:4237 -#: ../../Firmware/ultralcd.cpp:4239 ../../Firmware/ultralcd.cpp:4264 -#: ../../Firmware/ultralcd.cpp:4292 ../../Firmware/ultralcd.cpp:4340 -#: ../../Firmware/ultralcd.cpp:4775 ../../Firmware/ultralcd.cpp:4782 -#: ../../Firmware/ultralcd.cpp:4801 ../../Firmware/ultralcd.cpp:4805 -#: ../../Firmware/ultralcd.cpp:5657 ../../Firmware/ultralcd.cpp:5754 -#: ../../Firmware/ultralcd.cpp:5765 ../../Firmware/ultralcd.cpp:5834 -#: ../../Firmware/ultralcd.cpp:7829 ../../Firmware/ultralcd.cpp:7833 +#: ../../Firmware/messages.cpp:126 ../../Firmware/ultralcd.cpp:4208 +#: ../../Firmware/ultralcd.cpp:4219 ../../Firmware/ultralcd.cpp:4220 +#: ../../Firmware/ultralcd.cpp:4222 ../../Firmware/ultralcd.cpp:4247 +#: ../../Firmware/ultralcd.cpp:4275 ../../Firmware/ultralcd.cpp:4323 +#: ../../Firmware/ultralcd.cpp:4758 ../../Firmware/ultralcd.cpp:4765 +#: ../../Firmware/ultralcd.cpp:4784 ../../Firmware/ultralcd.cpp:4788 +#: ../../Firmware/ultralcd.cpp:5640 ../../Firmware/ultralcd.cpp:5737 +#: ../../Firmware/ultralcd.cpp:5748 ../../Firmware/ultralcd.cpp:5817 +#: ../../Firmware/ultralcd.cpp:7809 ../../Firmware/ultralcd.cpp:7813 msgid "Off" msgstr "Off" #. MSG_DEFAULT_SETTINGS_LOADED c=20 r=6 -#: ../../Firmware/Marlin_main.cpp:1513 +#: ../../Firmware/Marlin_main.cpp:1514 msgid "Old settings found. Default PID, Esteps etc. will be set." msgstr "" "Sono state trovate impostazioni vecchie. Verranno impostati i valori " @@ -1367,62 +1368,62 @@ msgstr "" #. MSG_ON c=3 #: ../../Firmware/SpoolJoin.cpp:38 ../../Firmware/messages.cpp:127 -#: ../../Firmware/ultralcd.cpp:4225 ../../Firmware/ultralcd.cpp:4236 -#: ../../Firmware/ultralcd.cpp:4237 ../../Firmware/ultralcd.cpp:4239 -#: ../../Firmware/ultralcd.cpp:4264 ../../Firmware/ultralcd.cpp:4282 -#: ../../Firmware/ultralcd.cpp:4339 ../../Firmware/ultralcd.cpp:4775 -#: ../../Firmware/ultralcd.cpp:4782 ../../Firmware/ultralcd.cpp:4801 -#: ../../Firmware/ultralcd.cpp:4805 ../../Firmware/ultralcd.cpp:5754 -#: ../../Firmware/ultralcd.cpp:5763 ../../Firmware/ultralcd.cpp:5834 -#: ../../Firmware/ultralcd.cpp:7829 ../../Firmware/ultralcd.cpp:7833 +#: ../../Firmware/ultralcd.cpp:4208 ../../Firmware/ultralcd.cpp:4219 +#: ../../Firmware/ultralcd.cpp:4220 ../../Firmware/ultralcd.cpp:4222 +#: ../../Firmware/ultralcd.cpp:4247 ../../Firmware/ultralcd.cpp:4265 +#: ../../Firmware/ultralcd.cpp:4322 ../../Firmware/ultralcd.cpp:4758 +#: ../../Firmware/ultralcd.cpp:4765 ../../Firmware/ultralcd.cpp:4784 +#: ../../Firmware/ultralcd.cpp:4788 ../../Firmware/ultralcd.cpp:5737 +#: ../../Firmware/ultralcd.cpp:5746 ../../Firmware/ultralcd.cpp:5817 +#: ../../Firmware/ultralcd.cpp:7809 ../../Firmware/ultralcd.cpp:7813 msgid "On" msgstr "On" #. MSG_SOUND_ONCE c=7 -#: ../../Firmware/messages.cpp:146 ../../Firmware/ultralcd.cpp:4451 +#: ../../Firmware/messages.cpp:146 ../../Firmware/ultralcd.cpp:4434 msgid "Once" msgstr "Singolo" #. MSG_PAUSED_THERMAL_ERROR c=20 -#: ../../Firmware/Marlin_main.cpp:9677 ../../Firmware/messages.cpp:168 +#: ../../Firmware/Marlin_main.cpp:9678 ../../Firmware/messages.cpp:168 msgid "PAUSED THERMAL ERROR" -msgstr "" +msgstr "PAUSA ERRORE TERMICO" #. MSG_PID_RUNNING c=20 -#: ../../Firmware/ultralcd.cpp:1036 +#: ../../Firmware/ultralcd.cpp:1023 msgid "PID cal." msgstr "Calibrazione PID" #. MSG_PID_FINISHED c=20 -#: ../../Firmware/ultralcd.cpp:1041 +#: ../../Firmware/ultralcd.cpp:1028 msgid "PID cal. finished" msgstr "Calib. PID completa" #. MSG_PID_EXTRUDER c=17 -#: ../../Firmware/ultralcd.cpp:4884 +#: ../../Firmware/ultralcd.cpp:4867 msgid "PID calibration" msgstr "Calibrazione PID" #. MSG_PINDA_PREHEAT c=20 -#: ../../Firmware/ultralcd.cpp:666 +#: ../../Firmware/ultralcd.cpp:662 msgid "PINDA Heating" msgstr "Riscaldamento PINDA" #. MSG_PINDA_CALIBRATION c=13 -#: ../../Firmware/Marlin_main.cpp:4957 ../../Firmware/Marlin_main.cpp:5060 -#: ../../Firmware/messages.cpp:113 ../../Firmware/ultralcd.cpp:663 -#: ../../Firmware/ultralcd.cpp:4801 ../../Firmware/ultralcd.cpp:4891 +#: ../../Firmware/Marlin_main.cpp:4958 ../../Firmware/Marlin_main.cpp:5061 +#: ../../Firmware/messages.cpp:113 ../../Firmware/ultralcd.cpp:659 +#: ../../Firmware/ultralcd.cpp:4784 ../../Firmware/ultralcd.cpp:4874 msgid "PINDA cal." msgstr "Calib. PINDA" #. MSG_PINDA_CAL_FAILED c=20 r=4 -#: ../../Firmware/ultralcd.cpp:3384 +#: ../../Firmware/ultralcd.cpp:3367 msgid "PINDA calibration failed" msgstr "Calibrazione temperatura fallita" #. MSG_PINDA_CALIBRATION_DONE c=20 r=8 -#: ../../Firmware/Marlin_main.cpp:5137 ../../Firmware/messages.cpp:114 -#: ../../Firmware/ultralcd.cpp:3378 +#: ../../Firmware/Marlin_main.cpp:5138 ../../Firmware/messages.cpp:114 +#: ../../Firmware/ultralcd.cpp:3361 msgid "" "PINDA calibration is finished and active. It can be disabled in menu " "Settings->PINDA cal." @@ -1431,7 +1432,7 @@ msgstr "" "Impostazioni ->Calib. PINDA" #. MSG_TITLE_PULLEY_CANNOT_MOVE c=20 -#: ../../Firmware/mmu2/errors_list.h:122 ../../Firmware/mmu2/errors_list.h:160 +#: ../../Firmware/mmu2/errors_list.h:128 ../../Firmware/mmu2/errors_list.h:167 msgid "PULLEY CANNOT MOVE" msgstr "" @@ -1442,13 +1443,13 @@ msgid "Parking selector" msgstr "" #. MSG_PAUSE c=5 -#: ../../Firmware/messages.cpp:154 ../../Firmware/ultralcd.cpp:4248 +#: ../../Firmware/messages.cpp:154 ../../Firmware/ultralcd.cpp:4231 msgid "Pause" msgstr "Pausa" #. MSG_PAUSE_PRINT c=18 -#: ../../Firmware/messages.cpp:73 ../../Firmware/ultralcd.cpp:5516 -#: ../../Firmware/ultralcd.cpp:5518 +#: ../../Firmware/messages.cpp:73 ../../Firmware/ultralcd.cpp:5499 +#: ../../Firmware/ultralcd.cpp:5501 msgid "Pause print" msgstr "Metti in pausa" @@ -1459,7 +1460,7 @@ msgid "Performing cut" msgstr "" #. MSG_PAPER c=20 r=10 -#: ../../Firmware/Marlin_main.cpp:3306 ../../Firmware/messages.cpp:72 +#: ../../Firmware/Marlin_main.cpp:3307 ../../Firmware/messages.cpp:72 msgid "" "Place a sheet of paper under the nozzle during the calibration of first 4 " "points. If the nozzle catches the paper, power off the printer immediately." @@ -1468,7 +1469,7 @@ msgstr "" "punti. In caso l'ugello muova il foglio spegnere subito la stampante." #. MSG_WIZARD_CALIBRATION_FAILED c=20 r=8 -#: ../../Firmware/messages.cpp:118 ../../Firmware/ultralcd.cpp:4138 +#: ../../Firmware/messages.cpp:118 ../../Firmware/ultralcd.cpp:4121 msgid "" "Please check our handbook and fix the problem. Then resume the Wizard by " "rebooting the printer." @@ -1477,34 +1478,34 @@ msgstr "" "riprendi il Wizard dopo aver riavviato la stampante." #. MSG_CHECK_IR_CONNECTION c=20 r=4 -#: ../../Firmware/ultralcd.cpp:6258 +#: ../../Firmware/ultralcd.cpp:6241 msgid "Please check the IR sensor connection, unload filament if present." msgstr "Controllare il collegamento al sensore e rimuovere il filamento." #. MSG_SELFTEST_PLEASECHECK c=20 -#: ../../Firmware/ultralcd.cpp:6962 +#: ../../Firmware/ultralcd.cpp:6945 msgid "Please check:" msgstr "Verifica:" #. MSG_WIZARD_CLEAN_HEATBED c=20 r=8 -#: ../../Firmware/ultralcd.cpp:4110 +#: ../../Firmware/ultralcd.cpp:4093 msgid "Please clean heatbed and then press the knob." msgstr "Per favore pulisci il piatto, poi premi la manopola." #. MSG_CONFIRM_NOZZLE_CLEAN c=20 r=8 -#: ../../Firmware/Marlin_main.cpp:3280 ../../Firmware/messages.cpp:24 +#: ../../Firmware/Marlin_main.cpp:3281 ../../Firmware/messages.cpp:24 msgid "Please clean the nozzle for calibration. Click when done." msgstr "Pulire l'ugello per la calibrazione, poi fare click." #. MSG_WIZARD_LOAD_FILAMENT c=20 r=6 -#: ../../Firmware/ultralcd.cpp:3915 +#: ../../Firmware/ultralcd.cpp:3898 msgid "" "Please insert filament into the extruder, then press the knob to load it." msgstr "" "Inserisci il filamento nell'estrusore, poi premi la manopola per caricarlo." #. MSG_MMU_INSERT_FILAMENT_FIRST_TUBE c=20 r=6 -#: ../../Firmware/ultralcd.cpp:3912 +#: ../../Firmware/ultralcd.cpp:3895 msgid "" "Please insert filament into the first tube of the MMU, then press the knob " "to load it." @@ -1513,50 +1514,50 @@ msgstr "" "manopola per caricarlo." #. MSG_PLEASE_LOAD_PLA c=20 r=4 -#: ../../Firmware/ultralcd.cpp:3835 +#: ../../Firmware/ultralcd.cpp:3818 msgid "Please load filament first." msgstr "Per favore prima carica il filamento." #. MSG_CHECK_IDLER c=20 r=5 -#: ../../Firmware/Marlin_main.cpp:3581 +#: ../../Firmware/Marlin_main.cpp:3582 msgid "Please open idler and remove filament manually." msgstr "Aprire la guida filam. e rimuovere il filam. a mano" #. MSG_PLACE_STEEL_SHEET c=20 r=5 #: ../../Firmware/mesh_bed_calibration.cpp:2795 ../../Firmware/messages.cpp:74 -#: ../../Firmware/ultralcd.cpp:4052 +#: ../../Firmware/ultralcd.cpp:4035 msgid "Please place steel sheet on heatbed." msgstr "Per favore posizionate la piastra d'acciaio sul piano riscaldato." #. MSG_PRESS_TO_UNLOAD c=20 r=4 -#: ../../Firmware/Marlin_main.cpp:11532 ../../Firmware/Marlin_main.cpp:11585 +#: ../../Firmware/Marlin_main.cpp:11533 ../../Firmware/Marlin_main.cpp:11586 #: ../../Firmware/messages.cpp:78 msgid "Please press the knob to unload filament" msgstr "Premete la manopola per scaricare il filamento" #. MSG_PULL_OUT_FILAMENT c=20 r=4 -#: ../../Firmware/messages.cpp:80 ../../Firmware/ultralcd.cpp:5221 +#: ../../Firmware/messages.cpp:80 ../../Firmware/ultralcd.cpp:5204 msgid "Please pull out filament immediately" msgstr "Estrarre il filamento immediatamente" #. MSG_REMOVE_SHIPPING_HELPERS c=20 r=3 -#: ../../Firmware/ultralcd.cpp:4047 +#: ../../Firmware/ultralcd.cpp:4030 msgid "Please remove shipping helpers first." msgstr "Per favore rimuovete i materiali da spedizione" #. MSG_REMOVE_STEEL_SHEET c=20 r=4 -#: ../../Firmware/Marlin_main.cpp:3303 ../../Firmware/Marlin_main.cpp:4921 +#: ../../Firmware/Marlin_main.cpp:3304 ../../Firmware/Marlin_main.cpp:4922 #: ../../Firmware/messages.cpp:83 msgid "Please remove steel sheet from heatbed." msgstr "Rimuovete la piastra di acciaio dal piano riscaldato" #. MSG_RUN_XYZ c=20 r=4 -#: ../../Firmware/Marlin_main.cpp:4897 +#: ../../Firmware/Marlin_main.cpp:4898 msgid "Please run XYZ calibration first." msgstr "Esegui la calibrazione XYZ prima." #. MSG_UNLOAD_FILAMENT_REPEAT c=20 r=4 -#: ../../Firmware/ultralcd.cpp:6255 +#: ../../Firmware/ultralcd.cpp:6238 msgid "Please unload the filament first, then repeat this action." msgstr "Scaricare prima il filamento, poi ripetere l'operazione." @@ -1566,51 +1567,51 @@ msgid "Please upgrade." msgstr "Prego aggiornare." #. MSG_PLEASE_WAIT c=20 -#: ../../Firmware/Marlin_main.cpp:3577 ../../Firmware/Marlin_main.cpp:3595 -#: ../../Firmware/Marlin_main.cpp:7957 ../../Firmware/messages.cpp:75 -#: ../../Firmware/ultralcd.cpp:2202 ../../Firmware/ultralcd.cpp:2213 +#: ../../Firmware/Marlin_main.cpp:3578 ../../Firmware/Marlin_main.cpp:3596 +#: ../../Firmware/Marlin_main.cpp:7958 ../../Firmware/messages.cpp:75 +#: ../../Firmware/ultralcd.cpp:2189 ../../Firmware/ultralcd.cpp:2200 msgid "Please wait" msgstr "Attendere" #. MSG_POWER_FAILURES c=15 -#: ../../Firmware/messages.cpp:76 ../../Firmware/ultralcd.cpp:1245 -#: ../../Firmware/ultralcd.cpp:1274 +#: ../../Firmware/messages.cpp:76 ../../Firmware/ultralcd.cpp:1232 +#: ../../Firmware/ultralcd.cpp:1261 msgid "Power failures" msgstr "Interr. corr." #. MSG_PREHEAT c=18 -#: ../../Firmware/ultralcd.cpp:5511 +#: ../../Firmware/ultralcd.cpp:5494 msgid "Preheat" msgstr "Preriscalda" #. MSG_PREHEAT_NOZZLE c=20 -#: ../../Firmware/messages.cpp:77 ../../Firmware/ultralcd.cpp:2283 +#: ../../Firmware/messages.cpp:77 ../../Firmware/ultralcd.cpp:2270 msgid "Preheat the nozzle!" msgstr "Prerisc. ugello!" #. MSG_WIZARD_HEATING c=20 r=3 -#: ../../Firmware/messages.cpp:120 ../../Firmware/ultralcd.cpp:2898 -#: ../../Firmware/ultralcd.cpp:3897 ../../Firmware/ultralcd.cpp:3899 +#: ../../Firmware/messages.cpp:120 ../../Firmware/ultralcd.cpp:2885 +#: ../../Firmware/ultralcd.cpp:3880 ../../Firmware/ultralcd.cpp:3882 msgid "Preheating nozzle. Please wait." msgstr "Preriscaldando l'ugello. Attendere prego." #. MSG_PREHEATING_TO_CUT c=20 -#: ../../Firmware/ultralcd.cpp:2001 +#: ../../Firmware/ultralcd.cpp:1988 msgid "Preheating to cut" msgstr "Preriscalda. taglio" #. MSG_PREHEATING_TO_EJECT c=20 -#: ../../Firmware/ultralcd.cpp:1998 +#: ../../Firmware/ultralcd.cpp:1985 msgid "Preheating to eject" msgstr "Preriscalda. espuls." #. MSG_PREHEATING_TO_LOAD c=20 -#: ../../Firmware/ultralcd.cpp:1989 +#: ../../Firmware/ultralcd.cpp:1976 msgid "Preheating to load" msgstr "Preriscald. carico" #. MSG_PREHEATING_TO_UNLOAD c=20 -#: ../../Firmware/ultralcd.cpp:1994 +#: ../../Firmware/ultralcd.cpp:1981 msgid "Preheating to unload" msgstr "Preriscald. scarico" @@ -1621,48 +1622,48 @@ msgid "Preparing blade" msgstr "" #. MSG_PRESS_KNOB c=20 -#: ../../Firmware/ultralcd.cpp:1809 +#: ../../Firmware/ultralcd.cpp:1796 msgid "Press the knob" msgstr "Premere la manopola" #. MSG_PRESS_TO_PREHEAT c=20 r=4 -#: ../../Firmware/Marlin_main.cpp:11563 +#: ../../Firmware/Marlin_main.cpp:11564 msgid "Press the knob to preheat nozzle and continue." msgstr "Premete la manopola per preriscaldare l'ugello e continuare." #. MSG_PRINT_ABORTED c=20 -#: ../../Firmware/messages.cpp:79 ../../Firmware/ultralcd.cpp:871 +#: ../../Firmware/messages.cpp:79 ../../Firmware/ultralcd.cpp:858 msgid "Print aborted" msgstr "Stampa interrotta" #. MSG_PRINT_FAN_SPEED c=16 -#: ../../Firmware/messages.cpp:36 ../../Firmware/ultralcd.cpp:1144 -#: ../../Firmware/ultralcd.cpp:7322 +#: ../../Firmware/messages.cpp:36 ../../Firmware/ultralcd.cpp:1131 +#: ../../Firmware/ultralcd.cpp:7305 msgid "Print fan:" msgstr "Vent.stam:" #. MSG_CARD_MENU c=18 -#: ../../Firmware/messages.cpp:20 ../../Firmware/ultralcd.cpp:5544 +#: ../../Firmware/messages.cpp:20 ../../Firmware/ultralcd.cpp:5527 msgid "Print from SD" msgstr "Stampa da SD" #. MSG_PRINT_PAUSED c=20 -#: ../../Firmware/ultralcd.cpp:885 +#: ../../Firmware/ultralcd.cpp:872 msgid "Print paused" msgstr "Stampa in pausa" #. MSG_PRINT_TIME c=19 -#: ../../Firmware/ultralcd.cpp:2364 +#: ../../Firmware/ultralcd.cpp:2351 msgid "Print time" msgstr "Tempo di stampa" #. MSG_PRINTER_IP c=18 -#: ../../Firmware/ultralcd.cpp:1711 +#: ../../Firmware/ultralcd.cpp:1698 msgid "Printer IP Addr:" msgstr "Ind. IP stampante:" #. MSG_FOLLOW_CALIBRATION_FLOW c=20 r=8 -#: ../../Firmware/Marlin_main.cpp:1526 ../../Firmware/messages.cpp:42 +#: ../../Firmware/Marlin_main.cpp:1527 ../../Firmware/messages.cpp:42 msgid "" "Printer has not been calibrated yet. Please follow the manual, chapter First " "steps, section Calibration flow." @@ -1685,7 +1686,7 @@ msgstr "" "Stampa annullata." #. MSG_DESC_PULLEY_STALLED c=20 r=8 -#: ../../Firmware/mmu2/errors_list.h:200 ../../Firmware/mmu2/errors_list.h:240 +#: ../../Firmware/mmu2/errors_list.h:210 ../../Firmware/mmu2/errors_list.h:250 msgid "Pulley motor stalled. Ensure the pulley can move and check the wiring." msgstr "" @@ -1696,68 +1697,68 @@ msgid "Pushing filament" msgstr "" #. MSG_TITLE_QUEUE_FULL c=20 -#: ../../Firmware/mmu2/errors_list.h:150 ../../Firmware/mmu2/errors_list.h:188 +#: ../../Firmware/mmu2/errors_list.h:157 ../../Firmware/mmu2/errors_list.h:198 msgid "QUEUE FULL" msgstr "" #. MSG_RPI_PORT c=13 -#: ../../Firmware/messages.cpp:143 ../../Firmware/ultralcd.cpp:4805 +#: ../../Firmware/messages.cpp:143 ../../Firmware/ultralcd.cpp:4788 msgid "RPi port" msgstr "Porta RPi" #. MSG_BED_CORRECTION_REAR c=14 -#: ../../Firmware/ultralcd.cpp:2753 +#: ../../Firmware/ultralcd.cpp:2740 msgid "Rear side [μm]" msgstr "Retro [μm]" #. MSG_RECOVERING_PRINT c=20 -#: ../../Firmware/Marlin_main.cpp:10899 +#: ../../Firmware/Marlin_main.cpp:10900 msgid "Recovering print" msgstr "Recupero stampa" #. MSG_REMOVE_OLD_FILAMENT c=20 r=5 -#: ../../Firmware/Marlin_main.cpp:3461 +#: ../../Firmware/Marlin_main.cpp:3462 msgid "Remove old filament and press the knob to start loading new filament." msgstr "" "Rimuovi il filamento precedente e premi la manopola per caricare il nuovo " "filamento." #. MSG_RENAME c=18 -#: ../../Firmware/ultralcd.cpp:5435 +#: ../../Firmware/ultralcd.cpp:5418 msgid "Rename" msgstr "Rinomina" #. MSG_DESC_INVALID_TOOL c=20 r=8 -#: ../../Firmware/mmu2/errors_list.h:229 ../../Firmware/mmu2/errors_list.h:267 +#: ../../Firmware/mmu2/errors_list.h:239 ../../Firmware/mmu2/errors_list.h:280 msgid "" "Requested filament tool is not available on this hardware. Check the G-code " "for tool index out of range (T0-T4)." msgstr "" #. MSG_RESET c=14 -#: ../../Firmware/messages.cpp:84 ../../Firmware/ultralcd.cpp:2754 -#: ../../Firmware/ultralcd.cpp:5436 +#: ../../Firmware/messages.cpp:84 ../../Firmware/ultralcd.cpp:2741 +#: ../../Firmware/ultralcd.cpp:5419 msgid "Reset" msgstr "Reset" #. MSG_BTN_RESTART_MMU c=9 -#: ../../Firmware/mmu2/errors_list.h:283 ../../Firmware/mmu2/errors_list.h:293 +#: ../../Firmware/mmu2/errors_list.h:297 ../../Firmware/mmu2/errors_list.h:307 msgid "Reset MMU" msgstr "" #. MSG_CALIBRATE_BED_RESET c=18 -#: ../../Firmware/ultralcd.cpp:4888 +#: ../../Firmware/ultralcd.cpp:4871 msgid "Reset XYZ calibr." msgstr "Reset calibr. XYZ." #. MSG_RESUME_PRINT c=18 #: ../../Firmware/Marlin_main.cpp:644 ../../Firmware/messages.cpp:85 -#: ../../Firmware/ultralcd.cpp:5530 ../../Firmware/ultralcd.cpp:5532 +#: ../../Firmware/ultralcd.cpp:5513 ../../Firmware/ultralcd.cpp:5515 msgid "Resume print" msgstr "Riprendi stampa" #. MSG_RESUMING_PRINT c=20 -#: ../../Firmware/messages.cpp:86 ../../Firmware/ultralcd.cpp:674 +#: ../../Firmware/messages.cpp:86 ../../Firmware/ultralcd.cpp:670 msgid "Resuming print" msgstr "Riprendi stampa" @@ -1767,10 +1768,10 @@ msgstr "Riprendi stampa" msgid "Retract from FINDA" msgstr "" -#. MSG_BTN_RETRY c=5 -#: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 +#. MSG_BTN_RETRY c=8 +#: ../../Firmware/mmu2/errors_list.h:295 ../../Firmware/mmu2/errors_list.h:305 msgid "Retry" -msgstr "" +msgstr "Riprova" #. MSG_PROGRESS_RETURN_SELECTOR c=20 #: ../../Firmware/mmu2_progress_converter.cpp:25 @@ -1779,17 +1780,17 @@ msgid "Returning selector" msgstr "" #. MSG_RIGHT c=10 -#: ../../Firmware/ultralcd.cpp:2495 +#: ../../Firmware/ultralcd.cpp:2482 msgid "Right" msgstr "Destra" #. MSG_BED_CORRECTION_RIGHT c=14 -#: ../../Firmware/ultralcd.cpp:2751 +#: ../../Firmware/ultralcd.cpp:2738 msgid "Right side[μm]" msgstr "Destra [μm]" #. MSG_WIZARD_RERUN c=20 r=7 -#: ../../Firmware/ultralcd.cpp:3857 +#: ../../Firmware/ultralcd.cpp:3840 msgid "" "Running Wizard will delete current calibration results and start from the " "beginning. Continue?" @@ -1798,40 +1799,40 @@ msgstr "" "ricominciare dall'inizio. Continuare?" #. MSG_SD_CARD c=8 -#: ../../Firmware/messages.cpp:139 ../../Firmware/ultralcd.cpp:4393 -#: ../../Firmware/ultralcd.cpp:4395 ../../Firmware/ultralcd.cpp:4412 -#: ../../Firmware/ultralcd.cpp:4414 +#: ../../Firmware/messages.cpp:139 ../../Firmware/ultralcd.cpp:4376 +#: ../../Firmware/ultralcd.cpp:4378 ../../Firmware/ultralcd.cpp:4395 +#: ../../Firmware/ultralcd.cpp:4397 msgid "SD card" msgstr "Mem. SD" #. MSG_TITLE_SELECTOR_CANNOT_HOME c=20 -#: ../../Firmware/mmu2/errors_list.h:125 ../../Firmware/mmu2/errors_list.h:162 +#: ../../Firmware/mmu2/errors_list.h:131 ../../Firmware/mmu2/errors_list.h:169 msgid "SELECTOR CANNOT HOME" msgstr "" #. MSG_TITLE_SELECTOR_CANNOT_MOVE c=20 -#: ../../Firmware/mmu2/errors_list.h:124 ../../Firmware/mmu2/errors_list.h:163 +#: ../../Firmware/mmu2/errors_list.h:130 ../../Firmware/mmu2/errors_list.h:170 msgid "SELECTOR CANNOT MOVE" msgstr "" #. MSG_STOPPED c=20 -#: ../../Firmware/Marlin_main.cpp:9706 ../../Firmware/messages.cpp:112 +#: ../../Firmware/Marlin_main.cpp:9707 ../../Firmware/messages.cpp:112 msgid "STOPPED." msgstr "ARRESTATO." #. MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 c=20 r=3 -#: ../../Firmware/Marlin_main.cpp:3286 ../../Firmware/Marlin_main.cpp:3308 +#: ../../Firmware/Marlin_main.cpp:3287 ../../Firmware/Marlin_main.cpp:3309 #: ../../Firmware/mesh_bed_calibration.cpp:2233 ../../Firmware/messages.cpp:40 msgid "Searching bed calibration point" msgstr "Ricerca punti calibrazione piano" #. MSG_SELECT c=18 -#: ../../Firmware/ultralcd.cpp:5428 +#: ../../Firmware/ultralcd.cpp:5411 msgid "Select" msgstr "Seleziona" #. MSG_SELECT_FIL_1ST_LAYERCAL c=20 r=7 -#: ../../Firmware/ultralcd.cpp:3932 +#: ../../Firmware/ultralcd.cpp:3915 msgid "" "Select a filament for the First Layer Calibration and select it in the on-" "screen menu." @@ -1840,32 +1841,32 @@ msgstr "" "menu sullo schermo." #. MSG_SELECT_EXTRUDER c=20 -#: ../../Firmware/Marlin_main.cpp:3519 ../../Firmware/Tcodes.cpp:35 +#: ../../Firmware/Marlin_main.cpp:3520 ../../Firmware/Tcodes.cpp:35 #: ../../Firmware/Tcodes.cpp:51 ../../Firmware/messages.cpp:52 msgid "Select extruder:" msgstr "Seleziona estrusore:" #. MSG_SELECT_FILAMENT c=20 #: ../../Firmware/Tcodes.cpp:33 ../../Firmware/messages.cpp:53 -#: ../../Firmware/ultralcd.cpp:3805 +#: ../../Firmware/ultralcd.cpp:3788 msgid "Select filament:" msgstr "Seleziona il filam.:" #. MSG_SELECT_LANGUAGE c=18 -#: ../../Firmware/messages.cpp:99 ../../Firmware/ultralcd.cpp:3650 -#: ../../Firmware/ultralcd.cpp:4812 +#: ../../Firmware/messages.cpp:99 ../../Firmware/ultralcd.cpp:3633 +#: ../../Firmware/ultralcd.cpp:4795 msgid "Select language" msgstr "Seleziona lingua" #. MSG_SEL_PREHEAT_TEMP c=20 r=6 -#: ../../Firmware/ultralcd.cpp:4084 +#: ../../Firmware/ultralcd.cpp:4067 msgid "Select nozzle preheat temperature which matches your material." msgstr "" "Selezionate la temperatura per il preriscaldamento dell'ugello adatta al " "vostro materiale." #. MSG_SELECT_TEMP_MATCHES_MATERIAL c=20 r=4 -#: ../../Firmware/ultralcd.cpp:3937 +#: ../../Firmware/ultralcd.cpp:3920 msgid "Select temperature which matches your material." msgstr "Seleziona la temperatura appropriata per il tuo materiale." @@ -1876,61 +1877,61 @@ msgid "Selecting fil. slot" msgstr "" #. MSG_SELFTEST_OK c=20 -#: ../../Firmware/ultralcd.cpp:6522 +#: ../../Firmware/ultralcd.cpp:6505 msgid "Self test OK" msgstr "Autotest OK" #. MSG_SELFTEST_START c=20 -#: ../../Firmware/ultralcd.cpp:6295 +#: ../../Firmware/ultralcd.cpp:6278 msgid "Self test start" msgstr "Avvia autotest" #. MSG_SELFTEST c=18 -#: ../../Firmware/ultralcd.cpp:4875 +#: ../../Firmware/ultralcd.cpp:4858 msgid "Selftest" msgstr "Autotest" #. MSG_SELFTEST_ERROR c=20 -#: ../../Firmware/ultralcd.cpp:6961 +#: ../../Firmware/ultralcd.cpp:6944 msgid "Selftest error!" msgstr "Errore Autotest!" #. MSG_SELFTEST_FAILED c=20 -#: ../../Firmware/messages.cpp:89 ../../Firmware/ultralcd.cpp:6526 -#: ../../Firmware/ultralcd.cpp:7048 ../../Firmware/ultralcd.cpp:7312 +#: ../../Firmware/messages.cpp:89 ../../Firmware/ultralcd.cpp:6509 +#: ../../Firmware/ultralcd.cpp:7031 ../../Firmware/ultralcd.cpp:7295 msgid "Selftest failed" msgstr "Autotest fallito" #. MSG_FORCE_SELFTEST c=20 r=8 -#: ../../Firmware/Marlin_main.cpp:1545 +#: ../../Firmware/Marlin_main.cpp:1546 msgid "Selftest will be run to calibrate accurate sensorless rehoming." msgstr "Verra effettuato un self test per calibrare l'homing senza sensori" #. MSG_INFO_SENSORS c=18 -#: ../../Firmware/ultralcd.cpp:1723 +#: ../../Firmware/ultralcd.cpp:1710 msgid "Sensor info" msgstr "Info Sensore" #. MSG_FS_VERIFIED c=20 r=3 -#: ../../Firmware/ultralcd.cpp:6262 +#: ../../Firmware/ultralcd.cpp:6245 msgid "Sensor verified, remove the filament now." msgstr "Sensore verificato, rimuovere il filamento." #. MSG_SET_TEMPERATURE c=20 -#: ../../Firmware/ultralcd.cpp:2771 +#: ../../Firmware/ultralcd.cpp:2758 msgid "Set temperature:" msgstr "Imposta temperatura:" #. MSG_SETTINGS c=18 -#: ../../Firmware/messages.cpp:98 ../../Firmware/ultralcd.cpp:3508 -#: ../../Firmware/ultralcd.cpp:3667 ../../Firmware/ultralcd.cpp:4168 -#: ../../Firmware/ultralcd.cpp:5593 ../../Firmware/ultralcd.cpp:5825 -#: ../../Firmware/ultralcd.cpp:5878 +#: ../../Firmware/messages.cpp:98 ../../Firmware/ultralcd.cpp:3491 +#: ../../Firmware/ultralcd.cpp:3650 ../../Firmware/ultralcd.cpp:4151 +#: ../../Firmware/ultralcd.cpp:5576 ../../Firmware/ultralcd.cpp:5808 +#: ../../Firmware/ultralcd.cpp:5861 msgid "Settings" msgstr "Impostazioni" #. MSG_SEVERE_SKEW c=14 -#: ../../Firmware/ultralcd.cpp:2538 +#: ../../Firmware/ultralcd.cpp:2525 msgid "Severe skew" msgstr "Deviaz. forte" @@ -1941,7 +1942,7 @@ msgid "Sheet" msgstr "Piano" #. MSG_SHEET_OFFSET c=20 r=4 -#: ../../Firmware/ultralcd.cpp:3795 +#: ../../Firmware/ultralcd.cpp:3778 msgid "" "Sheet %.7s\n" "Z offset: %+1.3fmm\n" @@ -1954,18 +1955,18 @@ msgstr "" "%cReset" #. MSG_SHOW_END_STOPS c=18 -#: ../../Firmware/ultralcd.cpp:4886 +#: ../../Firmware/ultralcd.cpp:4869 msgid "Show end stops" msgstr "Stato finecorsa" #. MSG_SILENT c=7 -#: ../../Firmware/messages.cpp:107 ../../Firmware/ultralcd.cpp:4359 -#: ../../Firmware/ultralcd.cpp:4454 ../../Firmware/ultralcd.cpp:5776 +#: ../../Firmware/messages.cpp:107 ../../Firmware/ultralcd.cpp:4342 +#: ../../Firmware/ultralcd.cpp:4437 ../../Firmware/ultralcd.cpp:5759 msgid "Silent" msgstr "Silenz." #. MSG_SLIGHT_SKEW c=14 -#: ../../Firmware/ultralcd.cpp:2537 +#: ../../Firmware/ultralcd.cpp:2524 msgid "Slight skew" msgstr "Deviaz. lieve" @@ -1979,13 +1980,13 @@ msgstr "" "e 100 perche siano ordinati." #. MSG_ZLEVELING_ENFORCED c=20 r=4 -#: ../../Firmware/Marlin_main.cpp:3052 +#: ../../Firmware/Marlin_main.cpp:3053 msgid "Some problem encountered, Z-leveling enforced ..." msgstr "Sono stati rilevati problemi, avviato livellamento Z ..." #. MSG_SORT c=7 -#: ../../Firmware/messages.cpp:140 ../../Firmware/ultralcd.cpp:4401 -#: ../../Firmware/ultralcd.cpp:4402 ../../Firmware/ultralcd.cpp:4403 +#: ../../Firmware/messages.cpp:140 ../../Firmware/ultralcd.cpp:4384 +#: ../../Firmware/ultralcd.cpp:4385 ../../Firmware/ultralcd.cpp:4386 msgid "Sort" msgstr "Ordina" @@ -1996,155 +1997,155 @@ msgid "Sorting files" msgstr "Ordinando i file" #. MSG_SOUND c=9 -#: ../../Firmware/messages.cpp:144 ../../Firmware/ultralcd.cpp:4448 -#: ../../Firmware/ultralcd.cpp:4451 ../../Firmware/ultralcd.cpp:4454 -#: ../../Firmware/ultralcd.cpp:4457 ../../Firmware/ultralcd.cpp:4460 +#: ../../Firmware/messages.cpp:144 ../../Firmware/ultralcd.cpp:4431 +#: ../../Firmware/ultralcd.cpp:4434 ../../Firmware/ultralcd.cpp:4437 +#: ../../Firmware/ultralcd.cpp:4440 ../../Firmware/ultralcd.cpp:4443 msgid "Sound" msgstr "Suono" #. MSG_SPEED c=15 -#: ../../Firmware/ultralcd.cpp:5731 +#: ../../Firmware/ultralcd.cpp:5714 msgid "Speed" msgstr "Velocita" #. MSG_SELFTEST_FAN_YES c=19 -#: ../../Firmware/messages.cpp:92 ../../Firmware/ultralcd.cpp:7164 -#: ../../Firmware/ultralcd.cpp:7179 ../../Firmware/ultralcd.cpp:7187 +#: ../../Firmware/messages.cpp:92 ../../Firmware/ultralcd.cpp:7147 +#: ../../Firmware/ultralcd.cpp:7162 ../../Firmware/ultralcd.cpp:7170 msgid "Spinning" msgstr "Gira" #. MSG_TEMP_CAL_WARNING c=20 r=4 -#: ../../Firmware/Marlin_main.cpp:4910 +#: ../../Firmware/Marlin_main.cpp:4911 msgid "Stable ambient temperature 21-26C is needed a rigid stand is required." msgstr "" "Sono necessari una temperatura ambiente di 21-26C e una superficie rigida." #. MSG_STATISTICS c=18 -#: ../../Firmware/ultralcd.cpp:5598 +#: ../../Firmware/ultralcd.cpp:5581 msgid "Statistics" msgstr "Statistiche" #. MSG_STEALTH c=7 -#: ../../Firmware/messages.cpp:109 ../../Firmware/ultralcd.cpp:4336 -#: ../../Firmware/ultralcd.cpp:4380 ../../Firmware/ultralcd.cpp:5768 +#: ../../Firmware/messages.cpp:109 ../../Firmware/ultralcd.cpp:4319 +#: ../../Firmware/ultralcd.cpp:4363 ../../Firmware/ultralcd.cpp:5751 msgid "Stealth" msgstr "Silenz." #. MSG_STEEL_SHEETS c=18 -#: ../../Firmware/messages.cpp:65 ../../Firmware/ultralcd.cpp:4726 -#: ../../Firmware/ultralcd.cpp:5425 +#: ../../Firmware/messages.cpp:65 ../../Firmware/ultralcd.cpp:4709 +#: ../../Firmware/ultralcd.cpp:5408 msgid "Steel sheets" msgstr "Piani d'acciaio" -#. MSG_BTN_STOP c=5 -#: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 +#. MSG_BTN_STOP c=8 +#: ../../Firmware/mmu2/errors_list.h:299 ../../Firmware/mmu2/errors_list.h:309 msgid "Stop" -msgstr "" +msgstr "Stop" #. MSG_STOP_PRINT c=18 -#: ../../Firmware/messages.cpp:111 ../../Firmware/ultralcd.cpp:5537 -#: ../../Firmware/ultralcd.cpp:5996 +#: ../../Firmware/messages.cpp:111 ../../Firmware/ultralcd.cpp:5520 +#: ../../Firmware/ultralcd.cpp:5979 msgid "Stop print" msgstr "Arresta stampa" #. MSG_STRICT c=8 -#: ../../Firmware/messages.cpp:132 ../../Firmware/ultralcd.cpp:4497 -#: ../../Firmware/ultralcd.cpp:4579 ../../Firmware/ultralcd.cpp:4618 -#: ../../Firmware/ultralcd.cpp:4659 +#: ../../Firmware/messages.cpp:132 ../../Firmware/ultralcd.cpp:4480 +#: ../../Firmware/ultralcd.cpp:4562 ../../Firmware/ultralcd.cpp:4601 +#: ../../Firmware/ultralcd.cpp:4642 msgid "Strict" msgstr "Esatto" #. MSG_SUPPORT c=18 -#: ../../Firmware/ultralcd.cpp:5607 +#: ../../Firmware/ultralcd.cpp:5590 msgid "Support" msgstr "Supporto" #. MSG_SELFTEST_SWAPPED c=16 -#: ../../Firmware/ultralcd.cpp:7020 +#: ../../Firmware/ultralcd.cpp:7003 msgid "Swapped" msgstr "Scambiato" #. MSG_THERMAL_ANOMALY c=20 #: ../../Firmware/messages.cpp:170 ../../Firmware/temperature.cpp:2440 msgid "THERMAL ANOMALY" -msgstr "" +msgstr "ANOMALIA TERMICA" #. MSG_TM_AUTOTUNE_FAILED c=20 #: ../../Firmware/temperature.cpp:2897 msgid "TM autotune failed" -msgstr "" +msgstr "Autocal. MT fallita" #. MSG_TITLE_TMC_DRIVER_ERROR c=20 -#: ../../Firmware/mmu2/errors_list.h:134 ../../Firmware/mmu2/errors_list.h:172 -#: ../../Firmware/mmu2/errors_list.h:173 ../../Firmware/mmu2/errors_list.h:174 +#: ../../Firmware/mmu2/errors_list.h:140 ../../Firmware/mmu2/errors_list.h:179 +#: ../../Firmware/mmu2/errors_list.h:180 ../../Firmware/mmu2/errors_list.h:181 msgid "TMC DRIVER ERROR" msgstr "" #. MSG_TITLE_TMC_DRIVER_RESET c=20 -#: ../../Firmware/mmu2/errors_list.h:137 ../../Firmware/mmu2/errors_list.h:175 -#: ../../Firmware/mmu2/errors_list.h:176 ../../Firmware/mmu2/errors_list.h:177 +#: ../../Firmware/mmu2/errors_list.h:143 ../../Firmware/mmu2/errors_list.h:182 +#: ../../Firmware/mmu2/errors_list.h:183 ../../Firmware/mmu2/errors_list.h:184 msgid "TMC DRIVER RESET" msgstr "" #. MSG_TITLE_TMC_DRIVER_SHORTED c=20 -#: ../../Firmware/mmu2/errors_list.h:143 ../../Firmware/mmu2/errors_list.h:181 -#: ../../Firmware/mmu2/errors_list.h:182 ../../Firmware/mmu2/errors_list.h:183 +#: ../../Firmware/mmu2/errors_list.h:149 ../../Firmware/mmu2/errors_list.h:188 +#: ../../Firmware/mmu2/errors_list.h:189 ../../Firmware/mmu2/errors_list.h:190 msgid "TMC DRIVER SHORTED" msgstr "" #. MSG_TITLE_TMC_OVERHEAT_ERROR c=20 -#: ../../Firmware/mmu2/errors_list.h:131 ../../Firmware/mmu2/errors_list.h:169 -#: ../../Firmware/mmu2/errors_list.h:170 ../../Firmware/mmu2/errors_list.h:171 +#: ../../Firmware/mmu2/errors_list.h:137 ../../Firmware/mmu2/errors_list.h:176 +#: ../../Firmware/mmu2/errors_list.h:177 ../../Firmware/mmu2/errors_list.h:178 msgid "TMC OVERHEAT ERROR" msgstr "" #. MSG_TITLE_TMC_UNDERVOLTAGE_ERROR c=20 -#: ../../Firmware/mmu2/errors_list.h:140 ../../Firmware/mmu2/errors_list.h:178 -#: ../../Firmware/mmu2/errors_list.h:179 ../../Firmware/mmu2/errors_list.h:180 +#: ../../Firmware/mmu2/errors_list.h:146 ../../Firmware/mmu2/errors_list.h:185 +#: ../../Firmware/mmu2/errors_list.h:186 ../../Firmware/mmu2/errors_list.h:187 msgid "TMC UNDERVOLTAGE ERR" msgstr "" #. MSG_TEMP_MODEL_AUTOTUNE c=20 #: ../../Firmware/temperature.cpp:2882 msgid "Temp. model autotune" -msgstr "" +msgstr "Cal. modello termico" #. MSG_TEMPERATURE c=18 -#: ../../Firmware/ultralcd.cpp:4759 +#: ../../Firmware/ultralcd.cpp:4742 msgid "Temperature" msgstr "Temperatura" #. MSG_MENU_TEMPERATURES c=18 -#: ../../Firmware/ultralcd.cpp:1729 +#: ../../Firmware/ultralcd.cpp:1716 msgid "Temperatures" msgstr "Temperature" #. MSG_TESTING_FILAMENT c=20 -#: ../../Firmware/messages.cpp:59 ../../Firmware/mmu2.cpp:426 +#: ../../Firmware/messages.cpp:59 ../../Firmware/mmu2.cpp:444 msgid "Testing filament" msgstr "" #. MSG_DESC_IDLER_CANNOT_HOME c=20 r=8 -#: ../../Firmware/mmu2/errors_list.h:205 ../../Firmware/mmu2/errors_list.h:244 +#: ../../Firmware/mmu2/errors_list.h:215 ../../Firmware/mmu2/errors_list.h:254 msgid "" "The Idler cannot home properly. Check for anything blocking its movement." msgstr "" #. MSG_DESC_FW_UPDATE_NEEDED c=20 r=9 -#: ../../Firmware/mmu2/errors_list.h:231 ../../Firmware/mmu2/errors_list.h:269 +#: ../../Firmware/mmu2/errors_list.h:241 ../../Firmware/mmu2/errors_list.h:282 msgid "" "The MMU unit reports its FW version incompatible with the printer's " "firmware. Make sure the MMU firmware is up to date." msgstr "" #. MSG_DESC_SELECTOR_CANNOT_HOME c=20 r=8 -#: ../../Firmware/mmu2/errors_list.h:202 ../../Firmware/mmu2/errors_list.h:242 +#: ../../Firmware/mmu2/errors_list.h:212 ../../Firmware/mmu2/errors_list.h:252 msgid "" "The Selector cannot home properly. Check for anything blocking its movement." msgstr "" #. MSG_WIZARD_V2_CAL_2 c=20 r=12 -#: ../../Firmware/ultralcd.cpp:3940 +#: ../../Firmware/ultralcd.cpp:3923 msgid "" "The printer will start printing a zig-zag line. Rotate the knob until you " "reach the optimal height. Check the pictures in the handbook (Calibration " @@ -2155,7 +2156,7 @@ msgstr "" "manuale (capitolo sulla calibrazione)." #. MSG_FOLLOW_Z_CALIBRATION_FLOW c=20 r=9 -#: ../../Firmware/Marlin_main.cpp:1539 ../../Firmware/messages.cpp:43 +#: ../../Firmware/Marlin_main.cpp:1540 ../../Firmware/messages.cpp:43 msgid "" "There is still a need to make Z calibration. Please follow the manual, " "chapter First steps, section Calibration flow." @@ -2164,69 +2165,69 @@ msgstr "" "Primi Passi, sezione Sequenza di Calibrazione." #. MSG_SORT_TIME c=8 -#: ../../Firmware/messages.cpp:141 ../../Firmware/ultralcd.cpp:4401 +#: ../../Firmware/messages.cpp:141 ../../Firmware/ultralcd.cpp:4384 msgid "Time" msgstr "Cron." #. MSG_TIMEOUT c=12 -#: ../../Firmware/messages.cpp:158 ../../Firmware/ultralcd.cpp:5863 +#: ../../Firmware/messages.cpp:158 ../../Firmware/ultralcd.cpp:5846 msgid "Timeout" msgstr "Timeout" #. MSG_TOTAL c=6 -#: ../../Firmware/messages.cpp:101 ../../Firmware/ultralcd.cpp:1167 -#: ../../Firmware/ultralcd.cpp:1300 +#: ../../Firmware/messages.cpp:101 ../../Firmware/ultralcd.cpp:1154 +#: ../../Firmware/ultralcd.cpp:1287 msgid "Total" msgstr "Totale" #. MSG_TOTAL_FAILURES c=20 -#: ../../Firmware/messages.cpp:102 ../../Firmware/ultralcd.cpp:1214 -#: ../../Firmware/ultralcd.cpp:1244 ../../Firmware/ultralcd.cpp:1330 +#: ../../Firmware/messages.cpp:102 ../../Firmware/ultralcd.cpp:1201 +#: ../../Firmware/ultralcd.cpp:1231 ../../Firmware/ultralcd.cpp:1317 msgid "Total failures" msgstr "Totale fallimenti" #. MSG_TOTAL_FILAMENT c=19 -#: ../../Firmware/ultralcd.cpp:2385 +#: ../../Firmware/ultralcd.cpp:2372 msgid "Total filament" msgstr "Filamento totale" #. MSG_TOTAL_PRINT_TIME c=19 -#: ../../Firmware/ultralcd.cpp:2386 +#: ../../Firmware/ultralcd.cpp:2373 msgid "Total print time" msgstr "Tempo stampa totale" #. MSG_TUNE c=18 -#: ../../Firmware/ultralcd.cpp:5509 +#: ../../Firmware/ultralcd.cpp:5492 msgid "Tune" msgstr "Regola" #. MSG_TITLE_UNLOAD_MANUALLY c=20 -#: ../../Firmware/mmu2/errors_list.h:153 ../../Firmware/mmu2/errors_list.h:191 +#: ../../Firmware/mmu2/errors_list.h:160 ../../Firmware/mmu2/errors_list.h:201 msgid "UNLOAD MANUALLY" msgstr "" #. MSG_DESC_UNLOAD_MANUALLY c=20 r=8 -#: ../../Firmware/mmu2/errors_list.h:233 ../../Firmware/mmu2/errors_list.h:271 +#: ../../Firmware/mmu2/errors_list.h:243 ../../Firmware/mmu2/errors_list.h:284 msgid "" "Unexpected FINDA reading. Ensure no filament is under FINDA and the selector " "is free. Check FINDA connection." msgstr "" -#. MSG_BTN_UNLOAD c=6 -#: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 +#. MSG_BTN_UNLOAD c=8 +#: ../../Firmware/mmu2/errors_list.h:298 ../../Firmware/mmu2/errors_list.h:308 msgid "Unload" msgstr "" #. MSG_UNLOAD_FILAMENT c=16 -#: ../../Firmware/messages.cpp:115 ../../Firmware/ultralcd.cpp:5574 -#: ../../Firmware/ultralcd.cpp:5591 +#: ../../Firmware/messages.cpp:115 ../../Firmware/ultralcd.cpp:5557 +#: ../../Firmware/ultralcd.cpp:5574 msgid "Unload filament" msgstr "Scarica filam." #. MSG_UNLOADING_FILAMENT c=20 -#: ../../Firmware/Marlin_main.cpp:3502 ../../Firmware/messages.cpp:116 +#: ../../Firmware/Marlin_main.cpp:3503 ../../Firmware/messages.cpp:116 #: ../../Firmware/mmu2_progress_converter.cpp:50 -#: ../../Firmware/ultralcd.cpp:5193 +#: ../../Firmware/ultralcd.cpp:5176 msgid "Unloading filament" msgstr "Scaricando filamento" @@ -2243,23 +2244,23 @@ msgid "Unloading to pulley" msgstr "" #. MSG_FIL_FAILED c=20 r=5 -#: ../../Firmware/ultralcd.cpp:6265 +#: ../../Firmware/ultralcd.cpp:6248 msgid "Verification failed, remove the filament and try again." msgstr "Verifica fallita, rimuovere il filamento e riprovare." #. MSG_MENU_VOLTAGES c=18 -#: ../../Firmware/ultralcd.cpp:1732 +#: ../../Firmware/ultralcd.cpp:1719 msgid "Voltages" msgstr "Voltaggi" #. MSG_TITLE_TMC_WARNING_TMC_TOO_HOT c=20 -#: ../../Firmware/mmu2/errors_list.h:128 ../../Firmware/mmu2/errors_list.h:166 -#: ../../Firmware/mmu2/errors_list.h:167 ../../Firmware/mmu2/errors_list.h:168 +#: ../../Firmware/mmu2/errors_list.h:134 ../../Firmware/mmu2/errors_list.h:173 +#: ../../Firmware/mmu2/errors_list.h:174 ../../Firmware/mmu2/errors_list.h:175 msgid "WARNING TMC TOO HOT" msgstr "" #. MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4 -#: ../../Firmware/ultralcd.cpp:3551 +#: ../../Firmware/ultralcd.cpp:3534 msgid "" "WARNING:\n" "Crash detection\n" @@ -2272,217 +2273,208 @@ msgstr "" "Modalita silenziosa" #. MSG_USERWAIT c=20 -#: ../../Firmware/Marlin_main.cpp:4115 +#: ../../Firmware/Marlin_main.cpp:4116 msgid "Wait for user..." msgstr "Attendendo utente..." #. MSG_WAITING_TEMP_PINDA c=20 r=3 -#: ../../Firmware/ultralcd.cpp:2879 +#: ../../Firmware/ultralcd.cpp:2866 msgid "Waiting for PINDA probe cooling" msgstr "In attesa del raffreddamento della sonda PINDA" #. MSG_WAITING_TEMP c=20 r=4 -#: ../../Firmware/ultralcd.cpp:2911 +#: ../../Firmware/ultralcd.cpp:2898 msgid "Waiting for nozzle and bed cooling" msgstr "In attesa del raffreddamento dell'ugello e del piano" #. MSG_WARN c=8 -#: ../../Firmware/messages.cpp:131 ../../Firmware/ultralcd.cpp:4494 -#: ../../Firmware/ultralcd.cpp:4576 ../../Firmware/ultralcd.cpp:4615 -#: ../../Firmware/ultralcd.cpp:4656 +#: ../../Firmware/messages.cpp:131 ../../Firmware/ultralcd.cpp:4477 +#: ../../Firmware/ultralcd.cpp:4559 ../../Firmware/ultralcd.cpp:4598 +#: ../../Firmware/ultralcd.cpp:4639 msgid "Warn" msgstr "Avviso" #. MSG_CHANGED_BOTH c=20 r=4 -#: ../../Firmware/Marlin_main.cpp:1505 +#: ../../Firmware/Marlin_main.cpp:1506 msgid "Warning: both printer type and motherboard type changed." msgstr "Attenzione: tipo di stampante e di scheda madre cambiati." #. MSG_CHANGED_MOTHERBOARD c=20 r=4 -#: ../../Firmware/Marlin_main.cpp:1497 +#: ../../Firmware/Marlin_main.cpp:1498 msgid "Warning: motherboard type changed." msgstr "Avviso: tipo di scheda madre cambiato" #. MSG_CHANGED_PRINTER c=20 r=4 -#: ../../Firmware/Marlin_main.cpp:1501 +#: ../../Firmware/Marlin_main.cpp:1502 msgid "Warning: printer type changed." msgstr "Avviso: tipo di stampante cambiato." #. MSG_UNLOAD_SUCCESSFUL c=20 r=2 -#: ../../Firmware/Marlin_main.cpp:3574 +#: ../../Firmware/Marlin_main.cpp:3575 msgid "Was filament unload successful?" msgstr "Filamento scaricato con successo?" #. MSG_SELFTEST_WIRINGERROR c=18 -#: ../../Firmware/messages.cpp:97 ../../Firmware/ultralcd.cpp:6972 -#: ../../Firmware/ultralcd.cpp:6976 ../../Firmware/ultralcd.cpp:6996 -#: ../../Firmware/ultralcd.cpp:7002 ../../Firmware/ultralcd.cpp:7026 +#: ../../Firmware/messages.cpp:97 ../../Firmware/ultralcd.cpp:6955 +#: ../../Firmware/ultralcd.cpp:6959 ../../Firmware/ultralcd.cpp:6979 +#: ../../Firmware/ultralcd.cpp:6985 ../../Firmware/ultralcd.cpp:7009 msgid "Wiring error" msgstr "Errore cablaggio" #. MSG_WIZARD c=17 -#: ../../Firmware/ultralcd.cpp:4866 +#: ../../Firmware/ultralcd.cpp:4849 msgid "Wizard" msgstr "Wizard" #. MSG_X_CORRECTION c=13 -#: ../../Firmware/ultralcd.cpp:4172 +#: ../../Firmware/ultralcd.cpp:4155 msgid "X-correct:" msgstr "Correzione-X:" #. MSG_XFLASH c=18 -#: ../../Firmware/ultralcd.cpp:5609 +#: ../../Firmware/ultralcd.cpp:5592 msgid "XFLASH init" -msgstr "" +msgstr "Inizializza XFLASH" #. MSG_XYZ_DETAILS c=18 -#: ../../Firmware/ultralcd.cpp:1721 +#: ../../Firmware/ultralcd.cpp:1708 msgid "XYZ cal. details" msgstr "XYZ Cal. dettagli" #. MSG_BED_SKEW_OFFSET_DETECTION_SKEW_EXTREME c=20 r=8 -#: ../../Firmware/ultralcd.cpp:3356 +#: ../../Firmware/ultralcd.cpp:3339 msgid "XYZ calibration all right. Skew will be corrected automatically." msgstr "" "Calibrazione XYZ corretta. La distorsione verra compensata automaticamente." #. MSG_BED_SKEW_OFFSET_DETECTION_SKEW_MILD c=20 r=8 -#: ../../Firmware/ultralcd.cpp:3353 +#: ../../Firmware/ultralcd.cpp:3336 msgid "XYZ calibration all right. X/Y axes are slightly skewed. Good job!" msgstr "Calibrazion XYZ corretta. Assi X/Y leggermente storti. Ben fatto!" #. MSG_BED_SKEW_OFFSET_DETECTION_WARNING_FRONT_BOTH_FAR c=20 r=8 -#: ../../Firmware/ultralcd.cpp:3334 +#: ../../Firmware/ultralcd.cpp:3317 msgid "XYZ calibration compromised. Front calibration points not reachable." msgstr "Calibrazione XYZ compromessa. Punti anteriori non raggiungibili." #. MSG_BED_SKEW_OFFSET_DETECTION_WARNING_FRONT_LEFT_FAR c=20 r=8 -#: ../../Firmware/ultralcd.cpp:3340 +#: ../../Firmware/ultralcd.cpp:3323 msgid "" "XYZ calibration compromised. Left front calibration point not reachable." -msgstr "" +msgstr "Calibrazione XYZ compromessa. Punto anteriore sinistro non raggiungibile." #. MSG_BED_SKEW_OFFSET_DETECTION_WARNING_FRONT_RIGHT_FAR c=20 r=8 -#: ../../Firmware/ultralcd.cpp:3337 +#: ../../Firmware/ultralcd.cpp:3320 msgid "" "XYZ calibration compromised. Right front calibration point not reachable." -msgstr "" -"Calibrazione XYZ compromessa. Punto anteriore destro non raggiungibile." +msgstr "Calibrazione XYZ compromessa. Punto anteriore destro non raggiungibile." #. MSG_BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND c=20 r=6 -#: ../../Firmware/ultralcd.cpp:3316 +#: ../../Firmware/ultralcd.cpp:3299 msgid "XYZ calibration failed. Bed calibration point was not found." msgstr "" "Calibrazione XYZ fallita. Il punto di calibrazione sul piano non e' stato " "trovato." #. MSG_BED_SKEW_OFFSET_DETECTION_FAILED_FRONT_BOTH_FAR c=20 r=6 -#: ../../Firmware/ultralcd.cpp:3322 +#: ../../Firmware/ultralcd.cpp:3305 msgid "XYZ calibration failed. Front calibration points not reachable." msgstr "Calibrazione XYZ fallita. Punti anteriori non raggiungibili." #. MSG_BED_SKEW_OFFSET_DETECTION_FAILED_FRONT_LEFT_FAR c=20 r=8 -#: ../../Firmware/ultralcd.cpp:3328 +#: ../../Firmware/ultralcd.cpp:3311 msgid "XYZ calibration failed. Left front calibration point not reachable." -msgstr "" +msgstr "Calibrazione XYZ fallita. Punto anteriore sinistro non raggiungibile." #. MSG_BED_SKEW_OFFSET_DETECTION_FITTING_FAILED c=20 r=8 -#: ../../Firmware/messages.cpp:16 ../../Firmware/ultralcd.cpp:3319 -#: ../../Firmware/ultralcd.cpp:3347 +#: ../../Firmware/messages.cpp:16 ../../Firmware/ultralcd.cpp:3302 +#: ../../Firmware/ultralcd.cpp:3330 msgid "XYZ calibration failed. Please consult the manual." msgstr "Calibrazione XYZ fallita. Si prega di consultare il manuale." #. MSG_BED_SKEW_OFFSET_DETECTION_FAILED_FRONT_RIGHT_FAR c=20 r=6 -#: ../../Firmware/ultralcd.cpp:3325 +#: ../../Firmware/ultralcd.cpp:3308 msgid "XYZ calibration failed. Right front calibration point not reachable." msgstr "Calibrazione XYZ fallita. Punto anteriore destro non raggiungibile." #. MSG_BED_SKEW_OFFSET_DETECTION_PERFECT c=20 r=8 -#: ../../Firmware/ultralcd.cpp:3350 +#: ../../Firmware/ultralcd.cpp:3333 msgid "XYZ calibration ok. X/Y axes are perpendicular. Congratulations!" msgstr "Calibrazione XYZ OK. Gli assi X/Y sono perpendicolari. Complimenti!" #. MSG_Y_DIST_FROM_MIN c=20 -#: ../../Firmware/ultralcd.cpp:2492 +#: ../../Firmware/ultralcd.cpp:2479 msgid "Y distance from min" msgstr "Distanza Y dal min" #. MSG_Y_CORRECTION c=13 -#: ../../Firmware/ultralcd.cpp:4173 +#: ../../Firmware/ultralcd.cpp:4156 msgid "Y-correct:" msgstr "Correzione-Y:" #. MSG_YES c=4 -#: ../../Firmware/messages.cpp:124 ../../Firmware/ultralcd.cpp:2228 -#: ../../Firmware/ultralcd.cpp:2798 ../../Firmware/ultralcd.cpp:3170 -#: ../../Firmware/ultralcd.cpp:4747 ../../Firmware/ultralcd.cpp:5998 +#: ../../Firmware/messages.cpp:124 ../../Firmware/ultralcd.cpp:2215 +#: ../../Firmware/ultralcd.cpp:2785 ../../Firmware/ultralcd.cpp:3157 +#: ../../Firmware/ultralcd.cpp:4730 ../../Firmware/ultralcd.cpp:5981 msgid "Yes" msgstr "Si" -#. MSG_FW_VERSION_ALPHA c=20 r=8 -#: ../../Firmware/Marlin_main.cpp:835 -msgid "" -"You are using firmware alpha version. This is development version. Using " -"this version is not recommended and may cause printer damage." -msgstr "" - -#. MSG_FW_VERSION_BETA c=20 r=8 -#: ../../Firmware/Marlin_main.cpp:836 -msgid "" -"You are using firmware beta version. This is development version. Using this " -"version is not recommended and may cause printer damage." -msgstr "" - #. MSG_WIZARD_QUIT c=20 r=8 -#: ../../Firmware/messages.cpp:121 ../../Firmware/ultralcd.cpp:4149 +#: ../../Firmware/messages.cpp:121 ../../Firmware/ultralcd.cpp:4132 msgid "You can always resume the Wizard from Calibration -> Wizard." msgstr "" "E possibile riprendere il Wizard in qualsiasi momento attraverso " "Calibrazione -> Wizard." #. MSG_Z_CORRECTION c=13 -#: ../../Firmware/ultralcd.cpp:4174 +#: ../../Firmware/ultralcd.cpp:4157 msgid "Z-correct:" msgstr "Correzione-Z:" #. MSG_Z_PROBE_NR c=14 -#: ../../Firmware/messages.cpp:150 ../../Firmware/ultralcd.cpp:5833 +#: ../../Firmware/messages.cpp:150 ../../Firmware/ultralcd.cpp:5816 msgid "Z-probe nr." msgstr "Nr. Z-test" #. MSG_MEASURED_OFFSET c=20 -#: ../../Firmware/ultralcd.cpp:2563 +#: ../../Firmware/ultralcd.cpp:2550 msgid "[0;0] point offset" msgstr "[0;0] punto offset" #. MSG_PRESS c=20 r=2 -#: ../../Firmware/ultralcd.cpp:2170 +#: ../../Firmware/ultralcd.cpp:2157 msgid "and press the knob" msgstr "e cliccare manopola" #. MSG_TO_LOAD_FIL c=20 -#: ../../Firmware/ultralcd.cpp:1817 +#: ../../Firmware/ultralcd.cpp:1804 msgid "to load filament" msgstr "per caricare il fil." #. MSG_TO_UNLOAD_FIL c=20 -#: ../../Firmware/ultralcd.cpp:1821 +#: ../../Firmware/ultralcd.cpp:1808 msgid "to unload filament" msgstr "per scaricare fil." #. MSG_UNKNOWN c=13 -#: ../../Firmware/ultralcd.cpp:1688 +#: ../../Firmware/ultralcd.cpp:1675 msgid "unknown" msgstr "sconosciuto" #. MSG_IR_UNKNOWN c=18 -#: ../../Firmware/Filament_sensor.cpp:291 ../../Firmware/messages.cpp:166 +#: ../../Firmware/Filament_sensor.cpp:293 ../../Firmware/messages.cpp:166 msgid "unknown state" msgstr "stato sconosciuto" +#. MSG_BTN_MORE c=8 +#: ../../Firmware/mmu2/errors_list.h:301 +#: ../../Firmware/mmu2_error_converter.cpp:167 +msgid "⏬" +msgstr "⏬" + #. MSG_REFRESH c=18 -#: ../../Firmware/messages.cpp:82 ../../Firmware/ultralcd.cpp:6086 -#: ../../Firmware/ultralcd.cpp:6089 +#: ../../Firmware/messages.cpp:82 ../../Firmware/ultralcd.cpp:6069 +#: ../../Firmware/ultralcd.cpp:6072 msgid "🔃Refresh" msgstr "🔃Ricaricare" diff --git a/lang/po/Firmware_lb.po b/lang/po/Firmware_lb.po index 60568e4156..88b4c19463 100644 --- a/lang/po/Firmware_lb.po +++ b/lang/po/Firmware_lb.po @@ -442,7 +442,7 @@ msgid "" "heatbed?" msgstr "" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "" @@ -1185,12 +1185,6 @@ msgstr "" msgid "More details online." msgstr "" -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1722,7 +1716,7 @@ msgstr "" msgid "Retract from FINDA" msgstr "" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "" @@ -1978,7 +1972,7 @@ msgstr "" msgid "Steel sheets" msgstr "" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "" @@ -2149,7 +2143,7 @@ msgid "" "is free. Check FINDA connection." msgstr "" -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "" diff --git a/lang/po/Firmware_lt.po b/lang/po/Firmware_lt.po index 57b7088995..81dcca9c21 100644 --- a/lang/po/Firmware_lt.po +++ b/lang/po/Firmware_lt.po @@ -442,7 +442,7 @@ msgid "" "heatbed?" msgstr "" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "" @@ -1185,12 +1185,6 @@ msgstr "" msgid "More details online." msgstr "" -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1722,7 +1716,7 @@ msgstr "" msgid "Retract from FINDA" msgstr "" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "" @@ -1978,7 +1972,7 @@ msgstr "" msgid "Steel sheets" msgstr "" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "" @@ -2149,7 +2143,7 @@ msgid "" "is free. Check FINDA connection." msgstr "" -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "" diff --git a/lang/po/Firmware_nl.po b/lang/po/Firmware_nl.po index 2746f6cea2..85f6bb3bd3 100644 --- a/lang/po/Firmware_nl.po +++ b/lang/po/Firmware_nl.po @@ -459,7 +459,7 @@ msgstr "" "Wilt u de laatste stap herhalen om de afstand tussen de tuit en de bed " "opnieuw in te stellen?" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "Klaar" @@ -1232,12 +1232,6 @@ msgstr "Model" msgid "More details online." msgstr "Meer details online." -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "Meer⏬" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1790,7 +1784,7 @@ msgstr "Hervatten print" msgid "Retract from FINDA" msgstr "Intrekken van FINDA" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "Retry" @@ -2062,7 +2056,7 @@ msgstr "Stil" msgid "Steel sheets" msgstr "Staalplaten" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "Stop" @@ -2244,7 +2238,7 @@ msgstr "" "Onverwachte FINDA-aflezing. Zorg ervoor dat er geen filament onder FINDA zit" " en dat de selecteur vrij is. Controleer de FINDA-verbinding." -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "Ontla." diff --git a/lang/po/Firmware_no.po b/lang/po/Firmware_no.po index 70a61db16f..5807689fd8 100644 --- a/lang/po/Firmware_no.po +++ b/lang/po/Firmware_no.po @@ -456,7 +456,7 @@ msgstr "" "Vil du repetere det siste trinnet for å omjustere avstanden mellom dysen og " "platen?" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "" @@ -1207,12 +1207,6 @@ msgstr "Modell" msgid "More details online." msgstr "" -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1755,7 +1749,7 @@ msgstr "Gjenopptar print" msgid "Retract from FINDA" msgstr "" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "" @@ -2018,7 +2012,7 @@ msgstr "Stille" msgid "Steel sheets" msgstr "Stål plate" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "" @@ -2194,7 +2188,7 @@ msgid "" "is free. Check FINDA connection." msgstr "" -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "" diff --git a/lang/po/Firmware_pl.po b/lang/po/Firmware_pl.po index 252dc2cc74..44c378c17a 100644 --- a/lang/po/Firmware_pl.po +++ b/lang/po/Firmware_pl.po @@ -456,7 +456,7 @@ msgstr "" "Chcesz powtorzyc ostatni krok i ponownie ustawic odleglosc miedzy dysza a " "stolikiem?" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "" @@ -1211,12 +1211,6 @@ msgstr "" msgid "More details online." msgstr "" -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1762,7 +1756,7 @@ msgstr "Wznawianie druku" msgid "Retract from FINDA" msgstr "" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "" @@ -2031,7 +2025,7 @@ msgstr "Cichy" msgid "Steel sheets" msgstr "Plyty stalowe" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "" @@ -2207,7 +2201,7 @@ msgid "" "is free. Check FINDA connection." msgstr "" -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "" diff --git a/lang/po/Firmware_ro.po b/lang/po/Firmware_ro.po index afd0d3400d..8ab26784c4 100644 --- a/lang/po/Firmware_ro.po +++ b/lang/po/Firmware_ro.po @@ -457,7 +457,7 @@ msgstr "" "Vreti sa repetati ultimul pas pentru a reajusta distanta dintre varf si " "suprafata de print?" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "Gata" @@ -1227,12 +1227,6 @@ msgstr "Model" msgid "More details online." msgstr "Mai multe detalii online" -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "More⏬" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1781,7 +1775,7 @@ msgstr "Reluare print..." msgid "Retract from FINDA" msgstr "Retract de la FINDA" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "Retry" @@ -2050,7 +2044,7 @@ msgstr "Silent." msgid "Steel sheets" msgstr "Suprafete print" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "Stop" @@ -2230,7 +2224,7 @@ msgstr "" "Citire FINDA neasteptata.Asig. ca nu este Fil. sub FINDA si SELECTOR" "Verifica conexiune FINDA" -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "Unload" diff --git a/lang/po/Firmware_sk.po b/lang/po/Firmware_sk.po index f0714d1be9..ed55bba6ce 100644 --- a/lang/po/Firmware_sk.po +++ b/lang/po/Firmware_sk.po @@ -4,16 +4,16 @@ msgid "" msgstr "" "Project-Id-Version: Prusa-Firmware\n" "POT-Creation-Date: Wed 16 Mar 2022 09:25:13 AM CET\n" -"PO-Revision-Date: Wed 16 Mar 2022 09:25:13 AM CET\n" +"PO-Revision-Date: 2022-09-22 09:05+0200\n" "Last-Translator: \n" "Language-Team: \n" "Language: sk\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 2.0.7\n" -"X-Poedit-SourceCharset: UTF-8\n" "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" +"X-Generator: Poedit 3.1.1\n" +"X-Poedit-SourceCharset: UTF-8\n" #. MSG_IR_03_OR_OLDER c=18 #: ../../Firmware/Filament_sensor.cpp:287 @@ -63,7 +63,7 @@ msgstr "Abeceda" #. MSG_ALWAYS c=6 #: ../../Firmware/messages.cpp:8 ../../Firmware/ultralcd.cpp:4287 msgid "Always" -msgstr "" +msgstr "Vzdy" #. MSG_AMBIENT c=14 #: ../../Firmware/ultralcd.cpp:1406 @@ -83,13 +83,13 @@ msgstr "Asist." #. MSG_AUTO c=6 #: ../../Firmware/messages.cpp:161 ../../Firmware/ultralcd.cpp:5862 msgid "Auto" -msgstr "" +msgstr "Auto" #. MSG_AUTO_HOME c=18 #: ../../Firmware/Marlin_main.cpp:3261 ../../Firmware/messages.cpp:9 #: ../../Firmware/ultralcd.cpp:4871 msgid "Auto home" -msgstr "" +msgstr "Auto home" #. MSG_AUTO_POWER c=10 #: ../../Firmware/messages.cpp:106 ../../Firmware/ultralcd.cpp:4362 @@ -113,7 +113,7 @@ msgstr "" #: ../../Firmware/mmu2_progress_converter.cpp:16 #: ../../Firmware/mmu2_progress_converter.cpp:42 msgid "Avoiding grind" -msgstr "" +msgstr "Avoiding grind" #. MSG_SELFTEST_AXIS c=16 #: ../../Firmware/ultralcd.cpp:7014 @@ -155,7 +155,7 @@ msgstr "Podlozka OK." #. MSG_BED_CORRECTION_MENU c=18 #: ../../Firmware/ultralcd.cpp:4883 msgid "Bed level correct" -msgstr "Korekcie podlozky" +msgstr "Korekcia podlozky" #. MSG_BED_LEVELING_FAILED_POINT_LOW c=20 r=6 #: ../../Firmware/Marlin_main.cpp:2209 ../../Firmware/Marlin_main.cpp:2985 @@ -205,7 +205,7 @@ msgstr "Podsvietenie" #. MSG_TITLE_COMMUNICATION_ERROR c=20 #: ../../Firmware/mmu2/errors_list.h:147 ../../Firmware/mmu2/errors_list.h:185 msgid "COMMUNICATION ERROR" -msgstr "" +msgstr "COMMUNICATION ERROR" #. MSG_CALIBRATE_BED c=18 #: ../../Firmware/ultralcd.cpp:4877 @@ -260,12 +260,13 @@ msgstr "Kalibracia OK" #: ../../Firmware/mmu2/errors_list.h:203 ../../Firmware/mmu2/errors_list.h:243 #: ../../Firmware/mmu2/errors_list.h:245 msgid "Can't move Selector or Idler." -msgstr "" +msgstr "Selektor alebo Idler nie je mozne presunut." #. MSG_DESC_FILAMENT_ALREADY_LOADED c=20 r=8 #: ../../Firmware/mmu2/errors_list.h:228 ../../Firmware/mmu2/errors_list.h:266 msgid "Cannot perform the action, filament is already loaded. Unload it first." msgstr "" +"Nie je mozne vykonat akciu, filament je uz zavedeny. Najskor ho vytiahnite." #. MSG_SD_REMOVED c=20 #: ../../Firmware/ultralcd.cpp:7700 @@ -275,7 +276,7 @@ msgstr "Karta vysunuta" #. MSG_CNG_SDCARD c=18 #: ../../Firmware/ultralcd.cpp:5547 msgid "Change SD card" -msgstr "" +msgstr "Zmenit SD kartu" #. MSG_FILAMENTCHANGE c=18 #: ../../Firmware/messages.cpp:39 ../../Firmware/ultralcd.cpp:5506 @@ -286,7 +287,7 @@ msgstr "Vymenit filament" #. MSG_CHANGE_SUCCESS c=20 #: ../../Firmware/ultralcd.cpp:2179 msgid "Change success!" -msgstr "Zmena uspesna!" +msgstr "Vymena uspesna!" #. MSG_CORRECTLY c=20 #: ../../Firmware/ultralcd.cpp:2227 @@ -339,7 +340,7 @@ msgstr "Kontrola senzorov" #. MSG_CHECKS c=18 #: ../../Firmware/ultralcd.cpp:4728 msgid "Checks" -msgstr "Kontrola" +msgstr "Kontroly" #. MSG_NOT_COLOR c=19 #: ../../Firmware/ultralcd.cpp:2230 @@ -392,15 +393,15 @@ msgid "" "be turned on only in\n" "Normal mode" msgstr "" -"Crash detekcia moze\n" +"Detekcia narazu moze\n" "byt zapnuta len v\n" -"Normal mode" +"Normalnom rezime" #. MSG_CUT_FILAMENT c=17 #: ../../Firmware/messages.cpp:61 ../../Firmware/ultralcd.cpp:5155 #: ../../Firmware/ultralcd.cpp:5578 msgid "Cut filament" -msgstr "Odstrihnut" +msgstr "Odstrihnut filam." #. MSG_CUTTER c=9 #: ../../Firmware/messages.cpp:129 ../../Firmware/ultralcd.cpp:4282 @@ -416,12 +417,12 @@ msgstr "Datum:" #. MSG_DIM c=6 #: ../../Firmware/messages.cpp:160 ../../Firmware/ultralcd.cpp:5862 msgid "Dim" -msgstr "Temny" +msgstr "Tmavy" #. MSG_BTN_DISABLE_MMU c=9 #: ../../Firmware/mmu2/errors_list.h:286 ../../Firmware/mmu2/errors_list.h:296 msgid "Disable" -msgstr "" +msgstr "Vypnut" #. MSG_DISABLE_STEPPERS c=18 #: ../../Firmware/ultralcd.cpp:4764 @@ -433,7 +434,7 @@ msgstr "Vypnut motory" #: ../../Firmware/mmu2_progress_converter.cpp:36 #: ../../Firmware/mmu2_progress_converter.cpp:44 msgid "Disengaging idler" -msgstr "" +msgstr "Uvolnenie idlera" #. MSG_BABYSTEP_Z_NOT_SET c=20 r=12 #: ../../Firmware/Marlin_main.cpp:1530 ../../Firmware/Marlin_main.cpp:3400 @@ -455,10 +456,10 @@ msgstr "" "Chcete opakovat posledny krok a pozmenit vzdialenost medzi tryskou a " "podlozkou?" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" -msgstr "" +msgstr "Hotov" #. MSG_EXTRUDER_CORRECTION c=13 #: ../../Firmware/ultralcd.cpp:4176 @@ -469,30 +470,30 @@ msgstr "Korekcia E:" #: ../../Firmware/mmu2_progress_converter.cpp:19 #: ../../Firmware/mmu2_progress_converter.cpp:48 msgid "ERR Help filament" -msgstr "" +msgstr "ERR Help filament" #. MSG_PROGRESS_ERR_INTERNAL c=20 #: ../../Firmware/mmu2_progress_converter.cpp:18 #: ../../Firmware/mmu2_progress_converter.cpp:47 msgid "ERR Internal" -msgstr "" +msgstr "ERR Internal" #. MSG_PROGRESS_ERR_TMC c=20 #: ../../Firmware/mmu2_progress_converter.cpp:20 #: ../../Firmware/mmu2_progress_converter.cpp:49 msgid "ERR TMC failed" -msgstr "" +msgstr "ERR TMC failed" #. MSG_PROGRESS_WAIT_USER c=20 #: ../../Firmware/mmu2_progress_converter.cpp:17 #: ../../Firmware/mmu2_progress_converter.cpp:46 msgid "ERR Wait for User" -msgstr "" +msgstr "ERR Wait for User" #. MSG_ERROR c=10 #: ../../Firmware/messages.cpp:29 ../../Firmware/ultralcd.cpp:2282 msgid "ERROR:" -msgstr "CHYBA:" +msgstr "ERROR:" #. MSG_EJECT_FILAMENT c=17 #: ../../Firmware/messages.cpp:60 ../../Firmware/ultralcd.cpp:5137 @@ -505,7 +506,7 @@ msgstr "Vysunut fil." #: ../../Firmware/mmu2_progress_converter.cpp:27 #: ../../Firmware/mmu2_progress_converter.cpp:58 msgid "Ejecting filament" -msgstr "Vysuvam filament" +msgstr "Vysunutie filamentu" #. MSG_SELFTEST_ENDSTOP c=16 #: ../../Firmware/ultralcd.cpp:6984 @@ -527,25 +528,25 @@ msgstr "Konc. spinace" #: ../../Firmware/mmu2_progress_converter.cpp:35 #: ../../Firmware/mmu2_progress_converter.cpp:45 msgid "Engaging idler" -msgstr "" +msgstr "Zapojenie idlera" #. MSG_EXTRUDER c=17 #: ../../Firmware/Marlin_main.cpp:3519 ../../Firmware/Tcodes.cpp:35 #: ../../Firmware/Tcodes.cpp:51 ../../Firmware/messages.cpp:30 #: ../../Firmware/ultralcd.cpp:3512 msgid "Extruder" -msgstr "" +msgstr "Extruder" #. MSG_EXTRUDER_FAN_SPEED c=16 #: ../../Firmware/messages.cpp:35 ../../Firmware/ultralcd.cpp:1144 #: ../../Firmware/ultralcd.cpp:7319 msgid "Extruder fan:" -msgstr "Lavy vent.:" +msgstr "Extruder vent.:" #. MSG_INFO_EXTRUDER c=18 #: ../../Firmware/ultralcd.cpp:1722 msgid "Extruder info" -msgstr "" +msgstr "Extruder info" #. MSG_FSENSOR_AUTOLOAD c=13 #: ../../Firmware/messages.cpp:45 ../../Firmware/ultralcd.cpp:4230 @@ -557,23 +558,23 @@ msgstr "F. autozav." #: ../../Firmware/messages.cpp:46 ../../Firmware/ultralcd.cpp:4232 #: ../../Firmware/ultralcd.cpp:4239 msgid "F. jam detect" -msgstr "" +msgstr "F. zasek" #. MSG_FSENSOR_RUNOUT c=13 #: ../../Firmware/messages.cpp:44 ../../Firmware/ultralcd.cpp:4229 #: ../../Firmware/ultralcd.cpp:4236 msgid "F. runout" -msgstr "" +msgstr "F. vypadok" #. MSG_TITLE_FIL_ALREADY_LOADED c=20 #: ../../Firmware/mmu2/errors_list.h:148 ../../Firmware/mmu2/errors_list.h:186 msgid "FILAMENT ALREADY LOA" -msgstr "" +msgstr "FILAMENT ALREADY LOA" #. MSG_TITLE_FINDA_DIDNT_TRIGGER c=20 #: ../../Firmware/mmu2/errors_list.h:118 ../../Firmware/mmu2/errors_list.h:156 msgid "FINDA DIDNT TRIGGER" -msgstr "" +msgstr "FINDA DIDNT TRIGGER" #. MSG_DESC_FINDA_DIDNT_GO_OFF c=20 r=8 #: ../../Firmware/mmu2/errors_list.h:197 ../../Firmware/mmu2/errors_list.h:237 @@ -581,6 +582,8 @@ msgid "" "FINDA didn't switch off while unloading filament. Try unloading manually. " "Ensure filament can move and FINDA works." msgstr "" +"FINDA sa nevypol pocas vyberania filamentu. Skuste to manualne. Uistite sa, " +"ze filament sa moze hybat a FINDA funguje." #. MSG_DESC_FINDA_DIDNT_TRIGGER c=20 r=8 #: ../../Firmware/mmu2/errors_list.h:196 ../../Firmware/mmu2/errors_list.h:236 @@ -588,47 +591,49 @@ msgid "" "FINDA didn't trigger while loading the filament. Ensure the filament can " "move and FINDA works." msgstr "" +"FINDA sa nezopol pocas zavedenia filamentu. Uiste sa, ze FINDA funguje " +"spravne." #. MSG_TITLE_FINDA_DIDNT_GO_OFF c=20 #: ../../Firmware/mmu2/errors_list.h:119 ../../Firmware/mmu2/errors_list.h:157 msgid "FINDA: FILAM. STUCK" -msgstr "" +msgstr "FINDA: FILAM. STUCK" #. MSG_FS_ACTION c=10 #: ../../Firmware/messages.cpp:152 ../../Firmware/ultralcd.cpp:4245 #: ../../Firmware/ultralcd.cpp:4248 msgid "FS Action" -msgstr "FS reakcia" +msgstr "FS Akcia" #. MSG_TITLE_FSENSOR_DIDNT_TRIGGER c=20 #: ../../Firmware/mmu2/errors_list.h:120 ../../Firmware/mmu2/errors_list.h:158 msgid "FSENSOR DIDNT TRIGG." -msgstr "" +msgstr "FSENSOR DIDNT TRIGG." #. MSG_TITLE_FSENSOR_TOO_EARLY c=20 #: ../../Firmware/mmu2/errors_list.h:123 ../../Firmware/mmu2/errors_list.h:161 msgid "FSENSOR TOO EARLY" -msgstr "" +msgstr "FSENSOR TOO EARLY" #. MSG_TITLE_FSENSOR_DIDNT_GO_OFF c=20 #: ../../Firmware/mmu2/errors_list.h:121 ../../Firmware/mmu2/errors_list.h:159 msgid "FSENSOR: FIL. STUCK" -msgstr "" +msgstr "FSENSOR: FIL. STUCK" #. MSG_TITLE_FW_RUNTIME_ERROR c=20 #: ../../Firmware/mmu2/errors_list.h:152 ../../Firmware/mmu2/errors_list.h:190 msgid "FW RUNTIME ERROR" -msgstr "" +msgstr "FW RUNTIME ERROR" #. MSG_FAIL_STATS c=18 #: ../../Firmware/ultralcd.cpp:5602 msgid "Fail stats" -msgstr "Zlyhanie" +msgstr "Statistiky zlyhani" #. MSG_MMU_FAIL_STATS c=18 #: ../../Firmware/ultralcd.cpp:5605 msgid "Fail stats MMU" -msgstr "Zlyhanie MMU" +msgstr "Zlyhania MMU" #. MSG_FALSE_TRIGGERING c=20 #: ../../Firmware/ultralcd.cpp:7030 @@ -658,25 +663,25 @@ msgstr "Kontr. vent." #: ../../Firmware/mmu2_progress_converter.cpp:13 #: ../../Firmware/mmu2_progress_converter.cpp:39 msgid "Feeding to FINDA" -msgstr "" +msgstr "Zavedenie do FINDA" #. MSG_PROGRESS_FEED_FSENSOR c=20 #: ../../Firmware/mmu2_progress_converter.cpp:31 #: ../../Firmware/mmu2_progress_converter.cpp:62 msgid "Feeding to FSensor" -msgstr "" +msgstr "Zavedenie do Fsensor" #. MSG_PROGRESS_FEED_EXTRUDER c=20 #: ../../Firmware/mmu2_progress_converter.cpp:14 #: ../../Firmware/mmu2_progress_converter.cpp:40 msgid "Feeding to extruder" -msgstr "" +msgstr "Zavedenie do extrud." #. MSG_PROGRESS_FEED_NOZZLE c=20 #: ../../Firmware/mmu2_progress_converter.cpp:15 #: ../../Firmware/mmu2_progress_converter.cpp:41 msgid "Feeding to nozzle" -msgstr "" +msgstr "Zavedenie do trysky" #. MSG_FIL_RUNOUTS c=15 #: ../../Firmware/messages.cpp:32 ../../Firmware/ultralcd.cpp:1246 @@ -696,7 +701,7 @@ msgstr "Fil. senzor" #: ../../Firmware/Tcodes.cpp:33 ../../Firmware/messages.cpp:33 #: ../../Firmware/ultralcd.cpp:3806 msgid "Filament" -msgstr "" +msgstr "Filament" #. MSG_FILAMENT_CLEAN c=20 r=2 #: ../../Firmware/messages.cpp:37 ../../Firmware/ultralcd.cpp:2290 @@ -722,6 +727,8 @@ msgid "" "Filament sensor didn't switch off while unloading filament. Ensure filament " "can move and the sensor works." msgstr "" +"Senzor filamentu sa nevypol pocas vyberania filamentu. Skontrolujte, ze sa " +"filament moze hybat a senzor funguje spravne." #. MSG_DESC_FSENSOR_DIDNT_TRIGGER c=20 r=8 #: ../../Firmware/mmu2/errors_list.h:198 ../../Firmware/mmu2/errors_list.h:238 @@ -729,6 +736,8 @@ msgid "" "Filament sensor didn't trigger while loading the filament. Ensure the " "filament reached the fsensor and the sensor works." msgstr "" +"Senzor filamentu sa nezopol pocas zavedenia filamentu. Skontrolujte, ze " +"filament dosiahol fsenzor a senzor funguje spravne." #. MSG_DESC_FSENSOR_TOO_EARLY c=20 r=8 #: ../../Firmware/mmu2/errors_list.h:201 ../../Firmware/mmu2/errors_list.h:241 @@ -736,6 +745,8 @@ msgid "" "Filament sensor triggered too early while loading to extruder. Check there " "isn't anything stuck in PTFE tube. Check that sensor reads properly." msgstr "" +"Filament senzor sa zopol priskoro pocas zavedenia do extruderu. Skontrolujte " +"ci je PTFE trubicka priechodzia a senzor funguje spravne." #. MSG_FILAMENT_USED c=19 #: ../../Firmware/ultralcd.cpp:2363 @@ -780,7 +791,7 @@ msgstr "Predny tlacovy vent?" #. MSG_BED_CORRECTION_FRONT c=14 #: ../../Firmware/ultralcd.cpp:2752 msgid "Front side[μm]" -msgstr "Vpredu [μm]" +msgstr "Predna st.[μm]" #. MSG_SELFTEST_FANS c=20 #: ../../Firmware/ultralcd.cpp:7019 @@ -835,7 +846,7 @@ msgstr "" #: ../../Firmware/ultralcd.cpp:4656 ../../Firmware/ultralcd.cpp:4659 #: ../../Firmware/ultralcd.cpp:4662 msgid "Gcode" -msgstr "" +msgstr "G-code" #. MSG_HW_SETUP c=18 #: ../../Firmware/messages.cpp:103 ../../Firmware/ultralcd.cpp:4670 @@ -895,7 +906,7 @@ msgstr "Vys. vykon" #: ../../Firmware/mmu2_progress_converter.cpp:29 #: ../../Firmware/mmu2_progress_converter.cpp:60 msgid "Homing" -msgstr "" +msgstr "Navrat" #. MSG_WIZARD_XYZ_CAL c=20 r=8 #: ../../Firmware/ultralcd.cpp:4041 @@ -910,17 +921,17 @@ msgstr "Teraz urobim kalibraciu Z." #. MSG_TITLE_IDLER_CANNOT_HOME c=20 #: ../../Firmware/mmu2/errors_list.h:127 ../../Firmware/mmu2/errors_list.h:164 msgid "IDLER CANNOT HOME" -msgstr "" +msgstr "IDLER CANNOT HOME" #. MSG_TITLE_IDLER_CANNOT_MOVE c=20 #: ../../Firmware/mmu2/errors_list.h:126 ../../Firmware/mmu2/errors_list.h:165 msgid "IDLER CANNOT MOVE" -msgstr "" +msgstr "IDLER CANNOT MOVE" #. MSG_TITLE_INVALID_TOOL c=20 #: ../../Firmware/mmu2/errors_list.h:149 ../../Firmware/mmu2/errors_list.h:187 msgid "INVALID TOOL" -msgstr "" +msgstr "INVALID TOOL" #. MSG_ADDITIONAL_SHEETS c=20 r=9 #: ../../Firmware/ultralcd.cpp:4115 @@ -934,7 +945,7 @@ msgstr "" #. MSG_IMPROVE_BED_OFFSET_AND_SKEW_LINE1 c=20 r=4 #: ../../Firmware/mesh_bed_calibration.cpp:2530 msgid "Improving bed calibration point" -msgstr "" +msgstr "Zlepsenie bodu kalibracie podlozky" #. MSG_INFO_SCREEN c=18 #: ../../Firmware/messages.cpp:117 ../../Firmware/ultralcd.cpp:5487 @@ -944,7 +955,7 @@ msgstr "Informacie" #. MSG_INIT_SDCARD c=18 #: ../../Firmware/ultralcd.cpp:5554 msgid "Init. SD card" -msgstr "" +msgstr "Nacitanie SD karty" #. MSG_INSERT_FILAMENT c=20 #: ../../Firmware/ultralcd.cpp:2165 @@ -964,6 +975,8 @@ msgid "" "Internal runtime error. Try resetting the MMU unit or updating the firmware. " "If the issue persists, contact support." msgstr "" +"Interna chyba. Skuste resetovat MMU alebo aktualizovat firmware. Ak chyba " +"pretrvava, kontaktujte podporu." #. MSG_FILAMENT_LOADED c=20 r=2 #: ../../Firmware/messages.cpp:38 ../../Firmware/ultralcd.cpp:3827 @@ -1008,7 +1021,7 @@ msgstr "Lavy vent na tryske?" #. MSG_BED_CORRECTION_LEFT c=14 #: ../../Firmware/ultralcd.cpp:2750 msgid "Left side [μm]" -msgstr "Vlavo [μm]" +msgstr "Lava str.[μm]" #. MSG_BL_HIGH c=12 #: ../../Firmware/messages.cpp:156 ../../Firmware/ultralcd.cpp:5860 @@ -1035,7 +1048,7 @@ msgstr "Doladenie osi Z" #: ../../Firmware/messages.cpp:172 ../../Firmware/ultralcd.cpp:5098 #: ../../Firmware/ultralcd.cpp:5178 msgid "Load All" -msgstr "" +msgstr "Zaviest vsetko" #. MSG_LOAD_FILAMENT c=17 #: ../../Firmware/messages.cpp:56 ../../Firmware/ultralcd.cpp:5100 @@ -1047,7 +1060,7 @@ msgstr "Zaviest filament" #. MSG_LOAD_TO_EXTRUDER c=18 #: ../../Firmware/messages.cpp:57 ../../Firmware/ultralcd.cpp:5572 msgid "Load to extruder" -msgstr "" +msgstr "Zaviest do extr." #. MSG_LOAD_TO_NOZZLE c=18 #: ../../Firmware/ultralcd.cpp:5573 @@ -1081,12 +1094,12 @@ msgstr "Hlasny" #. MSG_TITLE_FW_UPDATE_NEEDED c=20 #: ../../Firmware/mmu2/errors_list.h:151 ../../Firmware/mmu2/errors_list.h:189 msgid "MMU FW UPDATE NEEDED" -msgstr "" +msgstr "MMU FW UPDATE NEEDED" #. MSG_DESC_QUEUE_FULL c=20 r=8 #: ../../Firmware/mmu2/errors_list.h:230 ../../Firmware/mmu2/errors_list.h:268 msgid "MMU Firmware internal error, please reset the MMU." -msgstr "" +msgstr "Chyba MMU Firmwaru, resetujte MMU." #. MSG_MMU_MODE c=8 #: ../../Firmware/messages.cpp:138 ../../Firmware/ultralcd.cpp:4379 @@ -1097,12 +1110,12 @@ msgstr "MMU mod" #. MSG_TITLE_MMU_NOT_RESPONDING c=20 #: ../../Firmware/mmu2/errors_list.h:146 ../../Firmware/mmu2/errors_list.h:184 msgid "MMU NOT RESPONDING" -msgstr "" +msgstr "MMU NOT RESPONDING" #. MSG_MMU_RESTORE_TEMP c=20 r=4 #: ../../Firmware/mmu2.cpp:598 msgid "MMU Retry: Restoring temperature..." -msgstr "" +msgstr "MMU: Obnovenie teploty..." #. MSG_MMU_FAILS c=15 #: ../../Firmware/messages.cpp:68 ../../Firmware/ultralcd.cpp:1187 @@ -1121,6 +1134,8 @@ msgid "" "MMU unit not responding correctly. Check the wiring and connectors. If the " "issue persists, contact support." msgstr "" +"MMU neodpoveda spravne. Skontrolujte zapojenie a konektory. Ak chyba " +"pretrvava, kontaktujte podporu." #. MSG_DESC_MMU_NOT_RESPONDING c=20 r=8 #: ../../Firmware/mmu2/errors_list.h:226 ../../Firmware/mmu2/errors_list.h:264 @@ -1128,6 +1143,8 @@ msgid "" "MMU unit not responding. Check the wiring and connectors. If the issue " "persists, contact support." msgstr "" +"MMU neodpoveda. Skontrolujte zapojenie a konektory. Ak chyba pretrvava, " +"kontaktujte podporu." #. MSG_MMU_CONNECTED c=18 #: ../../Firmware/ultralcd.cpp:1679 @@ -1164,13 +1181,13 @@ msgstr "Meriam referencnu vysku kalibracneho bodu" #. MSG_MESH c=12 #: ../../Firmware/messages.cpp:148 ../../Firmware/ultralcd.cpp:5830 msgid "Mesh" -msgstr "" +msgstr "Mriezka" #. MSG_MESH_BED_LEVELING c=18 #: ../../Firmware/messages.cpp:149 ../../Firmware/ultralcd.cpp:4794 #: ../../Firmware/ultralcd.cpp:4881 msgid "Mesh Bed Leveling" -msgstr "" +msgstr "Vyrovnanie podl." #. MSG_MODE c=6 #: ../../Firmware/messages.cpp:104 ../../Firmware/ultralcd.cpp:4334 @@ -1193,7 +1210,7 @@ msgstr "Prebieha zmena modu..." #: ../../Firmware/ultralcd.cpp:4576 ../../Firmware/ultralcd.cpp:4579 #: ../../Firmware/ultralcd.cpp:4582 msgid "Model" -msgstr "" +msgstr "Model" #. MSG_DESC_TMC c=20 r=8 #: ../../Firmware/mmu2/errors_list.h:207 ../../Firmware/mmu2/errors_list.h:246 @@ -1207,19 +1224,13 @@ msgstr "" #: ../../Firmware/mmu2/errors_list.h:261 ../../Firmware/mmu2/errors_list.h:262 #: ../../Firmware/mmu2/errors_list.h:263 msgid "More details online." -msgstr "" - -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "" +msgstr "Viac podrobnosti online." #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 msgid "Motor" -msgstr "" +msgstr "Motor" #. MSG_MOVE_X c=18 #: ../../Firmware/ultralcd.cpp:3509 @@ -1245,7 +1256,7 @@ msgstr "Posunut os" #: ../../Firmware/mmu2_progress_converter.cpp:30 #: ../../Firmware/mmu2_progress_converter.cpp:61 msgid "Moving selector" -msgstr "" +msgstr "Presun selektora" #. MSG_NA c=3 #: ../../Firmware/menu.cpp:196 ../../Firmware/messages.cpp:128 @@ -1254,7 +1265,7 @@ msgstr "" #: ../../Firmware/ultralcd.cpp:4230 ../../Firmware/ultralcd.cpp:4232 #: ../../Firmware/ultralcd.cpp:5834 msgid "N/A" -msgstr "" +msgstr "N/A" #. MSG_NEW_FIRMWARE_AVAILABLE c=20 r=2 #: ../../Firmware/util.cpp:199 @@ -1292,7 +1303,7 @@ msgstr "Ziadne" #: ../../Firmware/ultralcd.cpp:4379 ../../Firmware/ultralcd.cpp:4395 #: ../../Firmware/ultralcd.cpp:4414 ../../Firmware/ultralcd.cpp:5761 msgid "Normal" -msgstr "" +msgstr "Normal" #. MSG_SELFTEST_NOTCONNECTED c=20 #: ../../Firmware/ultralcd.cpp:6968 @@ -1314,7 +1325,7 @@ msgstr "Teraz skalibrujem vzdialenost medzi koncom trysky a povrchom podlozky." #. MSG_WIZARD_WILL_PREHEAT c=20 r=4 #: ../../Firmware/ultralcd.cpp:4059 msgid "Now I will preheat nozzle for PLA." -msgstr "Teraz predhrejem trysku pre PLA." +msgstr "Teraz predohrejem trysku pre PLA." #. MSG_REMOVE_TEST_PRINT c=20 r=4 #: ../../Firmware/ultralcd.cpp:4048 @@ -1338,7 +1349,7 @@ msgstr "Tryska" #: ../../Firmware/mmu2_progress_converter.cpp:8 #: ../../Firmware/mmu2_progress_converter.cpp:34 msgid "OK" -msgstr "" +msgstr "OK" #. MSG_OFF c=3 #: ../../Firmware/SpoolJoin.cpp:40 ../../Firmware/menu.cpp:467 @@ -1380,7 +1391,7 @@ msgstr "Raz" #. MSG_PAUSED_THERMAL_ERROR c=20 #: ../../Firmware/Marlin_main.cpp:9677 ../../Firmware/messages.cpp:168 msgid "PAUSED THERMAL ERROR" -msgstr "" +msgstr "PAUSED THERMAL ERROR" #. MSG_PID_RUNNING c=20 #: ../../Firmware/ultralcd.cpp:1036 @@ -1412,7 +1423,7 @@ msgstr "PINDA kal." #. MSG_PINDA_CAL_FAILED c=20 r=4 #: ../../Firmware/ultralcd.cpp:3384 msgid "PINDA calibration failed" -msgstr "Teplotna kalibracia zlyhala" +msgstr "Kalibracia PINDA zlyhala" #. MSG_PINDA_CALIBRATION_DONE c=20 r=8 #: ../../Firmware/Marlin_main.cpp:5137 ../../Firmware/messages.cpp:114 @@ -1421,19 +1432,19 @@ msgid "" "PINDA calibration is finished and active. It can be disabled in menu " "Settings->PINDA cal." msgstr "" -"PINDA kalibracia dokoncena a je teraz aktivna. Da je mozno deaktivovat v " -"menu Nastavenie->PINDA kal." +"PINDA kalibracia dokoncena a je teraz aktivna. Je mozne ju deaktivovat v " +"menu Nastavenia->PINDA kal." #. MSG_TITLE_PULLEY_CANNOT_MOVE c=20 #: ../../Firmware/mmu2/errors_list.h:122 ../../Firmware/mmu2/errors_list.h:160 msgid "PULLEY CANNOT MOVE" -msgstr "" +msgstr "PULLEY CANNOT MOVE" #. MSG_PROGRESS_PARK_SELECTOR c=20 #: ../../Firmware/mmu2_progress_converter.cpp:26 #: ../../Firmware/mmu2_progress_converter.cpp:57 msgid "Parking selector" -msgstr "" +msgstr "Parkovanie selektora" #. MSG_PAUSE c=5 #: ../../Firmware/messages.cpp:154 ../../Firmware/ultralcd.cpp:4248 @@ -1450,7 +1461,7 @@ msgstr "Pozastavit tlac" #: ../../Firmware/mmu2_progress_converter.cpp:24 #: ../../Firmware/mmu2_progress_converter.cpp:55 msgid "Performing cut" -msgstr "" +msgstr "Strihanie" #. MSG_PAPER c=20 r=10 #: ../../Firmware/Marlin_main.cpp:3306 ../../Firmware/messages.cpp:72 @@ -1528,7 +1539,7 @@ msgstr "Umiestnite prosim platnu na podlozku" #: ../../Firmware/Marlin_main.cpp:11532 ../../Firmware/Marlin_main.cpp:11585 #: ../../Firmware/messages.cpp:78 msgid "Please press the knob to unload filament" -msgstr "Pre vysunutie filamentu stlacte prosim tlacidlo" +msgstr "Pre vysunutie filamentu stlacte tlacidlo" #. MSG_PULL_OUT_FILAMENT c=20 r=4 #: ../../Firmware/messages.cpp:80 ../../Firmware/ultralcd.cpp:5221 @@ -1538,18 +1549,18 @@ msgstr "Prosim vyberte urychlene filament" #. MSG_REMOVE_SHIPPING_HELPERS c=20 r=3 #: ../../Firmware/ultralcd.cpp:4047 msgid "Please remove shipping helpers first." -msgstr "Najskor prosim odstrante prevozne suciastky." +msgstr "Najskor prosim odstrante prevozne pomocky." #. MSG_REMOVE_STEEL_SHEET c=20 r=4 #: ../../Firmware/Marlin_main.cpp:3303 ../../Firmware/Marlin_main.cpp:4921 #: ../../Firmware/messages.cpp:83 msgid "Please remove steel sheet from heatbed." -msgstr "Odstrante prosim platnu z pozdlozky." +msgstr "Odstrante prosim platnu z podlozky." #. MSG_RUN_XYZ c=20 r=4 #: ../../Firmware/Marlin_main.cpp:4897 msgid "Please run XYZ calibration first." -msgstr "Nejskor spustte kalibraciu XYZ." +msgstr "Najskor spustite kalibraciu XYZ." #. MSG_UNLOAD_FILAMENT_REPEAT c=20 r=4 #: ../../Firmware/ultralcd.cpp:6255 @@ -1582,7 +1593,7 @@ msgstr "Predohrev" #. MSG_PREHEAT_NOZZLE c=20 #: ../../Firmware/messages.cpp:77 ../../Firmware/ultralcd.cpp:2283 msgid "Preheat the nozzle!" -msgstr "Predhrejte trysku!" +msgstr "Predohrejte trysku!" #. MSG_WIZARD_HEATING c=20 r=3 #: ../../Firmware/messages.cpp:120 ../../Firmware/ultralcd.cpp:2898 @@ -1593,7 +1604,7 @@ msgstr "Predhrev trysky. Prosim cakajte." #. MSG_PREHEATING_TO_CUT c=20 #: ../../Firmware/ultralcd.cpp:2001 msgid "Preheating to cut" -msgstr "Predhrev k strihu" +msgstr "Predohrev k strihu" #. MSG_PREHEATING_TO_EJECT c=20 #: ../../Firmware/ultralcd.cpp:1998 @@ -1608,13 +1619,13 @@ msgstr "Predhrev k zavedeniu" #. MSG_PREHEATING_TO_UNLOAD c=20 #: ../../Firmware/ultralcd.cpp:1994 msgid "Preheating to unload" -msgstr "Predhrev k vybratiu" +msgstr "Predohrev k vybratiu" #. MSG_PROGRESS_PREPARE_BLADE c=20 #: ../../Firmware/mmu2_progress_converter.cpp:22 #: ../../Firmware/mmu2_progress_converter.cpp:53 msgid "Preparing blade" -msgstr "" +msgstr "Priprava cepele" #. MSG_PRESS_KNOB c=20 #: ../../Firmware/ultralcd.cpp:1809 @@ -1684,27 +1695,29 @@ msgstr "" #: ../../Firmware/mmu2/errors_list.h:200 ../../Firmware/mmu2/errors_list.h:240 msgid "Pulley motor stalled. Ensure the pulley can move and check the wiring." msgstr "" +"Motor remenice sa zasekol. Skontrolujte, ze sa remenica moze hybat a jej " +"zapojenie." #. MSG_PROGRESS_PUSH_FILAMENT c=20 #: ../../Firmware/mmu2_progress_converter.cpp:23 #: ../../Firmware/mmu2_progress_converter.cpp:54 msgid "Pushing filament" -msgstr "" +msgstr "Tlacenie filamentu" #. MSG_TITLE_QUEUE_FULL c=20 #: ../../Firmware/mmu2/errors_list.h:150 ../../Firmware/mmu2/errors_list.h:188 msgid "QUEUE FULL" -msgstr "" +msgstr "QUEUE FULL" #. MSG_RPI_PORT c=13 #: ../../Firmware/messages.cpp:143 ../../Firmware/ultralcd.cpp:4805 msgid "RPi port" -msgstr "" +msgstr "RPi port" #. MSG_BED_CORRECTION_REAR c=14 #: ../../Firmware/ultralcd.cpp:2753 msgid "Rear side [μm]" -msgstr "Vzadu [μm]" +msgstr "Zadna str.[μm]" #. MSG_RECOVERING_PRINT c=20 #: ../../Firmware/Marlin_main.cpp:10899 @@ -1727,17 +1740,19 @@ msgid "" "Requested filament tool is not available on this hardware. Check the G-code " "for tool index out of range (T0-T4)." msgstr "" +"Pozadovany nastroj filamentu nie je k dispozicii. Skontrolujte G-code pre " +"nastroj mimo rozsah (T0-T4)." #. MSG_RESET c=14 #: ../../Firmware/messages.cpp:84 ../../Firmware/ultralcd.cpp:2754 #: ../../Firmware/ultralcd.cpp:5436 msgid "Reset" -msgstr "" +msgstr "Reset" #. MSG_BTN_RESTART_MMU c=9 #: ../../Firmware/mmu2/errors_list.h:283 ../../Firmware/mmu2/errors_list.h:293 msgid "Reset MMU" -msgstr "" +msgstr "Reset MMU" #. MSG_CALIBRATE_BED_RESET c=18 #: ../../Firmware/ultralcd.cpp:4888 @@ -1759,18 +1774,18 @@ msgstr "Obnovenie tlace" #: ../../Firmware/mmu2_progress_converter.cpp:28 #: ../../Firmware/mmu2_progress_converter.cpp:59 msgid "Retract from FINDA" -msgstr "" +msgstr "Vybrat z FINDA" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" -msgstr "" +msgstr "Znova" #. MSG_PROGRESS_RETURN_SELECTOR c=20 #: ../../Firmware/mmu2_progress_converter.cpp:25 #: ../../Firmware/mmu2_progress_converter.cpp:56 msgid "Returning selector" -msgstr "" +msgstr "Navrat selektora" #. MSG_RIGHT c=10 #: ../../Firmware/ultralcd.cpp:2495 @@ -1780,7 +1795,7 @@ msgstr "Vpravo" #. MSG_BED_CORRECTION_RIGHT c=14 #: ../../Firmware/ultralcd.cpp:2751 msgid "Right side[μm]" -msgstr "Vpravo [μm]" +msgstr "Prava str.[μm]" #. MSG_WIZARD_RERUN c=20 r=7 #: ../../Firmware/ultralcd.cpp:3857 @@ -1801,12 +1816,12 @@ msgstr "SD karta" #. MSG_TITLE_SELECTOR_CANNOT_HOME c=20 #: ../../Firmware/mmu2/errors_list.h:125 ../../Firmware/mmu2/errors_list.h:162 msgid "SELECTOR CANNOT HOME" -msgstr "" +msgstr "SELECTOR CANNOT HOME" #. MSG_TITLE_SELECTOR_CANNOT_MOVE c=20 #: ../../Firmware/mmu2/errors_list.h:124 ../../Firmware/mmu2/errors_list.h:163 msgid "SELECTOR CANNOT MOVE" -msgstr "" +msgstr "SELECTOR CANNOT MOVE" #. MSG_STOPPED c=20 #: ../../Firmware/Marlin_main.cpp:9706 ../../Firmware/messages.cpp:112 @@ -1835,7 +1850,7 @@ msgstr "Zvolte filament pre kalibraciu prvej vrstvy z nasledujuceho menu" #: ../../Firmware/Marlin_main.cpp:3519 ../../Firmware/Tcodes.cpp:35 #: ../../Firmware/Tcodes.cpp:51 ../../Firmware/messages.cpp:52 msgid "Select extruder:" -msgstr "Vyberte extruder:" +msgstr "Zvolte extruder:" #. MSG_SELECT_FILAMENT c=20 #: ../../Firmware/Tcodes.cpp:33 ../../Firmware/messages.cpp:53 @@ -1863,38 +1878,38 @@ msgstr "Zvolte teplotu, ktora odpoveda vasmu materialu." #: ../../Firmware/mmu2_progress_converter.cpp:21 #: ../../Firmware/mmu2_progress_converter.cpp:52 msgid "Selecting fil. slot" -msgstr "" +msgstr "Vyber slotu fil." #. MSG_SELFTEST_OK c=20 #: ../../Firmware/ultralcd.cpp:6522 msgid "Self test OK" -msgstr "" +msgstr "Samotest OK" #. MSG_SELFTEST_START c=20 #: ../../Firmware/ultralcd.cpp:6295 msgid "Self test start" -msgstr "" +msgstr "Zaciatok testu" #. MSG_SELFTEST c=18 #: ../../Firmware/ultralcd.cpp:4875 msgid "Selftest" -msgstr "" +msgstr "Samotest" #. MSG_SELFTEST_ERROR c=20 #: ../../Firmware/ultralcd.cpp:6961 msgid "Selftest error!" -msgstr "Chyba Selftestu!" +msgstr "Chyba samotestu!" #. MSG_SELFTEST_FAILED c=20 #: ../../Firmware/messages.cpp:89 ../../Firmware/ultralcd.cpp:6526 #: ../../Firmware/ultralcd.cpp:7048 ../../Firmware/ultralcd.cpp:7312 msgid "Selftest failed" -msgstr "Selftest zlyhal" +msgstr "Samotest zlyhal" #. MSG_FORCE_SELFTEST c=20 r=8 #: ../../Firmware/Marlin_main.cpp:1545 msgid "Selftest will be run to calibrate accurate sensorless rehoming." -msgstr "Pre kalibraciu presneho rehomovania bude teraz spusteny selftest." +msgstr "Bude spusteny test pre kalibraciu presneho navratu." #. MSG_INFO_SENSORS c=18 #: ../../Firmware/ultralcd.cpp:1723 @@ -1917,7 +1932,7 @@ msgstr "Nastavte teplotu:" #: ../../Firmware/ultralcd.cpp:5593 ../../Firmware/ultralcd.cpp:5825 #: ../../Firmware/ultralcd.cpp:5878 msgid "Settings" -msgstr "Nastavenie" +msgstr "Nastavenia" #. MSG_SEVERE_SKEW c=14 #: ../../Firmware/ultralcd.cpp:2538 @@ -2025,10 +2040,10 @@ msgstr "Tichy" msgid "Steel sheets" msgstr "Platne" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" -msgstr "" +msgstr "Zast." #. MSG_STOP_PRINT c=18 #: ../../Firmware/messages.cpp:111 ../../Firmware/ultralcd.cpp:5537 @@ -2056,47 +2071,47 @@ msgstr "Prehodene" #. MSG_THERMAL_ANOMALY c=20 #: ../../Firmware/messages.cpp:170 ../../Firmware/temperature.cpp:2440 msgid "THERMAL ANOMALY" -msgstr "" +msgstr "THERMAL ANOMALY" #. MSG_TM_AUTOTUNE_FAILED c=20 #: ../../Firmware/temperature.cpp:2897 msgid "TM autotune failed" -msgstr "" +msgstr "TM autotune failed" #. MSG_TITLE_TMC_DRIVER_ERROR c=20 #: ../../Firmware/mmu2/errors_list.h:134 ../../Firmware/mmu2/errors_list.h:172 #: ../../Firmware/mmu2/errors_list.h:173 ../../Firmware/mmu2/errors_list.h:174 msgid "TMC DRIVER ERROR" -msgstr "" +msgstr "TMC DRIVER ERROR" #. MSG_TITLE_TMC_DRIVER_RESET c=20 #: ../../Firmware/mmu2/errors_list.h:137 ../../Firmware/mmu2/errors_list.h:175 #: ../../Firmware/mmu2/errors_list.h:176 ../../Firmware/mmu2/errors_list.h:177 msgid "TMC DRIVER RESET" -msgstr "" +msgstr "TMC DRIVER RESET" #. MSG_TITLE_TMC_DRIVER_SHORTED c=20 #: ../../Firmware/mmu2/errors_list.h:143 ../../Firmware/mmu2/errors_list.h:181 #: ../../Firmware/mmu2/errors_list.h:182 ../../Firmware/mmu2/errors_list.h:183 msgid "TMC DRIVER SHORTED" -msgstr "" +msgstr "TMC DRIVER SHORTED" #. MSG_TITLE_TMC_OVERHEAT_ERROR c=20 #: ../../Firmware/mmu2/errors_list.h:131 ../../Firmware/mmu2/errors_list.h:169 #: ../../Firmware/mmu2/errors_list.h:170 ../../Firmware/mmu2/errors_list.h:171 msgid "TMC OVERHEAT ERROR" -msgstr "" +msgstr "TMC OVERHEAT ERROR" #. MSG_TITLE_TMC_UNDERVOLTAGE_ERROR c=20 #: ../../Firmware/mmu2/errors_list.h:140 ../../Firmware/mmu2/errors_list.h:178 #: ../../Firmware/mmu2/errors_list.h:179 ../../Firmware/mmu2/errors_list.h:180 msgid "TMC UNDERVOLTAGE ERR" -msgstr "" +msgstr "TMC UNDERVOLTAGE ERR" #. MSG_TEMP_MODEL_AUTOTUNE c=20 #: ../../Firmware/temperature.cpp:2882 msgid "Temp. model autotune" -msgstr "" +msgstr "Autom. nast. teploty" #. MSG_TEMPERATURE c=18 #: ../../Firmware/ultralcd.cpp:4759 @@ -2111,13 +2126,14 @@ msgstr "Teploty" #. MSG_TESTING_FILAMENT c=20 #: ../../Firmware/messages.cpp:59 ../../Firmware/mmu2.cpp:426 msgid "Testing filament" -msgstr "" +msgstr "Kontrola filamentu" #. MSG_DESC_IDLER_CANNOT_HOME c=20 r=8 #: ../../Firmware/mmu2/errors_list.h:205 ../../Firmware/mmu2/errors_list.h:244 msgid "" "The Idler cannot home properly. Check for anything blocking its movement." msgstr "" +"Idler sa nemoze vratit na miesto. Skontrolujte ci nieco neblokuje jeho pohyb." #. MSG_DESC_FW_UPDATE_NEEDED c=20 r=9 #: ../../Firmware/mmu2/errors_list.h:231 ../../Firmware/mmu2/errors_list.h:269 @@ -2125,12 +2141,16 @@ msgid "" "The MMU unit reports its FW version incompatible with the printer's " "firmware. Make sure the MMU firmware is up to date." msgstr "" +"Verzia FW MMU je nekompatibilna s FW tlaciarne. Skontrolujte aktualizacie " +"MMU firmwaru." #. MSG_DESC_SELECTOR_CANNOT_HOME c=20 r=8 #: ../../Firmware/mmu2/errors_list.h:202 ../../Firmware/mmu2/errors_list.h:242 msgid "" "The Selector cannot home properly. Check for anything blocking its movement." msgstr "" +"Selektor sa nemoze vratit na miesto. Skontrolujte ci nieco neblokuje jeho " +"pohyb." #. MSG_WIZARD_V2_CAL_2 c=20 r=12 #: ../../Firmware/ultralcd.cpp:3940 @@ -2159,7 +2179,7 @@ msgstr "Cas" #. MSG_TIMEOUT c=12 #: ../../Firmware/messages.cpp:158 ../../Firmware/ultralcd.cpp:5863 msgid "Timeout" -msgstr "" +msgstr "Casovac" #. MSG_TOTAL c=6 #: ../../Firmware/messages.cpp:101 ../../Firmware/ultralcd.cpp:1167 @@ -2191,7 +2211,7 @@ msgstr "Ladit" #. MSG_TITLE_UNLOAD_MANUALLY c=20 #: ../../Firmware/mmu2/errors_list.h:153 ../../Firmware/mmu2/errors_list.h:191 msgid "UNLOAD MANUALLY" -msgstr "" +msgstr "UNLOAD MANUALLY" #. MSG_DESC_UNLOAD_MANUALLY c=20 r=8 #: ../../Firmware/mmu2/errors_list.h:233 ../../Firmware/mmu2/errors_list.h:271 @@ -2199,11 +2219,13 @@ msgid "" "Unexpected FINDA reading. Ensure no filament is under FINDA and the selector " "is free. Check FINDA connection." msgstr "" +"Neocakavane nacitanie FINDA. Skontrolujte, ze filament nie je pod FINDA a " +"selektor je volny. Skontrolujte pripojenie FINDA." -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" -msgstr "" +msgstr "Vysuv" #. MSG_UNLOAD_FILAMENT c=16 #: ../../Firmware/messages.cpp:115 ../../Firmware/ultralcd.cpp:5574 @@ -2216,19 +2238,19 @@ msgstr "Vybrat filament" #: ../../Firmware/mmu2_progress_converter.cpp:50 #: ../../Firmware/ultralcd.cpp:5193 msgid "Unloading filament" -msgstr "Vysuvam filament" +msgstr "Vysuvanie filamentu" #. MSG_PROGRESS_UNLOAD_FINDA c=20 #: ../../Firmware/mmu2_progress_converter.cpp:11 #: ../../Firmware/mmu2_progress_converter.cpp:37 msgid "Unloading to FINDA" -msgstr "" +msgstr "Vysuvanie do FINDA" #. MSG_PROGRESS_UNLOAD_PULLEY c=20 #: ../../Firmware/mmu2_progress_converter.cpp:12 #: ../../Firmware/mmu2_progress_converter.cpp:38 msgid "Unloading to pulley" -msgstr "" +msgstr "Vysuv. do remenice" #. MSG_FIL_FAILED c=20 r=5 #: ../../Firmware/ultralcd.cpp:6265 @@ -2244,7 +2266,7 @@ msgstr "Napatie" #: ../../Firmware/mmu2/errors_list.h:128 ../../Firmware/mmu2/errors_list.h:166 #: ../../Firmware/mmu2/errors_list.h:167 ../../Firmware/mmu2/errors_list.h:168 msgid "WARNING TMC TOO HOT" -msgstr "" +msgstr "WARNING TMC TOO HOT" #. MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4 #: ../../Firmware/ultralcd.cpp:3551 @@ -2257,7 +2279,7 @@ msgstr "" "POZOR:\n" "Crash detekcia\n" "deaktivovana v\n" -"Stealth mode" +"Tichom rezime" #. MSG_USERWAIT c=20 #: ../../Firmware/Marlin_main.cpp:4115 @@ -2267,7 +2289,7 @@ msgstr "Caka sa na uzivatela" #. MSG_WAITING_TEMP_PINDA c=20 r=3 #: ../../Firmware/ultralcd.cpp:2879 msgid "Waiting for PINDA probe cooling" -msgstr "Cakanie na schladnutie PINDA" +msgstr "Caka sa na ochladenie PINDA" #. MSG_WAITING_TEMP c=20 r=4 #: ../../Firmware/ultralcd.cpp:2911 @@ -2284,12 +2306,12 @@ msgstr "Varovat" #. MSG_CHANGED_BOTH c=20 r=4 #: ../../Firmware/Marlin_main.cpp:1505 msgid "Warning: both printer type and motherboard type changed." -msgstr "Varovanie: doslo k zmene typu tlaciarne a motherboardu." +msgstr "Varovanie: doslo k zmene typu tlaciarne a maticnej dosky." #. MSG_CHANGED_MOTHERBOARD c=20 r=4 #: ../../Firmware/Marlin_main.cpp:1497 msgid "Warning: motherboard type changed." -msgstr "Varovanie: doslo k zmene typu motherboardu." +msgstr "Varovanie: doslo k zmene typu maticnej dosky." #. MSG_CHANGED_PRINTER c=20 r=4 #: ../../Firmware/Marlin_main.cpp:1501 @@ -2321,7 +2343,7 @@ msgstr "Korekcia X:" #. MSG_XFLASH c=18 #: ../../Firmware/ultralcd.cpp:5609 msgid "XFLASH init" -msgstr "" +msgstr "XFLASH init" #. MSG_XYZ_DETAILS c=18 #: ../../Firmware/ultralcd.cpp:1721 @@ -2332,7 +2354,7 @@ msgstr "Detaily XYZ kal." #: ../../Firmware/ultralcd.cpp:3356 msgid "XYZ calibration all right. Skew will be corrected automatically." msgstr "" -"Kalibracia XYZ v poradku. Skosenie bude automaticky vyrovnane pri tlaci." +"Kalibracia XYZ v poriadku. Skosenie bude automaticky vyrovnane pri tlaci." #. MSG_BED_SKEW_OFFSET_DETECTION_SKEW_MILD c=20 r=8 #: ../../Firmware/ultralcd.cpp:3353 @@ -2342,19 +2364,19 @@ msgstr "Kalibracia XYZ v poriadku. X/Y osi mierne skosene. Dobra praca!" #. MSG_BED_SKEW_OFFSET_DETECTION_WARNING_FRONT_BOTH_FAR c=20 r=8 #: ../../Firmware/ultralcd.cpp:3334 msgid "XYZ calibration compromised. Front calibration points not reachable." -msgstr "Kalibracia XYZ nepresna. Predne kalibracne body su velmi vpredu." +msgstr "Kalibracia XYZ je nepresna. Predne kalibracne body su nedostupne." #. MSG_BED_SKEW_OFFSET_DETECTION_WARNING_FRONT_LEFT_FAR c=20 r=8 #: ../../Firmware/ultralcd.cpp:3340 msgid "" "XYZ calibration compromised. Left front calibration point not reachable." -msgstr "" +msgstr "Kalibracia XYZ je nepresna. Lavy predny bod je nedostupny." #. MSG_BED_SKEW_OFFSET_DETECTION_WARNING_FRONT_RIGHT_FAR c=20 r=8 #: ../../Firmware/ultralcd.cpp:3337 msgid "" "XYZ calibration compromised. Right front calibration point not reachable." -msgstr "Kalibracia XYZ nepresna. Pravy predny bod je velmi vpredu." +msgstr "Kalibracia XYZ je nepresna. Pravy predny bod je nedostupny." #. MSG_BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND c=20 r=6 #: ../../Firmware/ultralcd.cpp:3316 @@ -2364,14 +2386,12 @@ msgstr "Kalibracia XYZ zlyhala. Kalibracny bod podlozky nenajdeny." #. MSG_BED_SKEW_OFFSET_DETECTION_FAILED_FRONT_BOTH_FAR c=20 r=6 #: ../../Firmware/ultralcd.cpp:3322 msgid "XYZ calibration failed. Front calibration points not reachable." -msgstr "" -"Kalibracia XYZ zlyhala. Predne kalibracne body velmi vpredu. Zrovnajte " -"tlaciaren." +msgstr "Kalibracia XYZ zlyhala. Predne kalibracne body su nedostupne." #. MSG_BED_SKEW_OFFSET_DETECTION_FAILED_FRONT_LEFT_FAR c=20 r=8 #: ../../Firmware/ultralcd.cpp:3328 msgid "XYZ calibration failed. Left front calibration point not reachable." -msgstr "" +msgstr "Kalibracia XYZ zlyhala. Lavy predny bod je nedostupny" #. MSG_BED_SKEW_OFFSET_DETECTION_FITTING_FAILED c=20 r=8 #: ../../Firmware/messages.cpp:16 ../../Firmware/ultralcd.cpp:3319 @@ -2382,13 +2402,12 @@ msgstr "Kalibracia XYZ zlyhala. Nahliadnite do manualu." #. MSG_BED_SKEW_OFFSET_DETECTION_FAILED_FRONT_RIGHT_FAR c=20 r=6 #: ../../Firmware/ultralcd.cpp:3325 msgid "XYZ calibration failed. Right front calibration point not reachable." -msgstr "" -"Kalibracia XYZ zlyhala. Pravy predny bod velmi vpredu. Zrovnajte tlaciaren." +msgstr "Kalibracia XYZ zlyhala. Pravy predny bod je nedostupny." #. MSG_BED_SKEW_OFFSET_DETECTION_PERFECT c=20 r=8 #: ../../Firmware/ultralcd.cpp:3350 msgid "XYZ calibration ok. X/Y axes are perpendicular. Congratulations!" -msgstr "Kalibracia XYZ v poradku. X/Y osi su kolme. Gratulujem!" +msgstr "Kalibracia XYZ v poradku. X/Y osi su kolme. Gratulujeme!" #. MSG_Y_DIST_FROM_MIN c=20 #: ../../Firmware/ultralcd.cpp:2492 @@ -2413,6 +2432,8 @@ msgid "" "You are using firmware alpha version. This is development version. Using " "this version is not recommended and may cause printer damage." msgstr "" +"Pouzivate ALPHA verziu firmveru. Toto je vyvojova verzia. Pouzivanie tejto " +"verzie sa neodporuca a moze sposobit poskodenie tlaciarne." #. MSG_FW_VERSION_BETA c=20 r=8 #: ../../Firmware/Marlin_main.cpp:836 @@ -2420,6 +2441,8 @@ msgid "" "You are using firmware beta version. This is development version. Using this " "version is not recommended and may cause printer damage." msgstr "" +"Pouzivate BETA verziu firmveru. Toto je vyvojova verzia. Pouzivanie tejto " +"verzie sa neodporuca a moze sposobit poskodenie tlaciarne." #. MSG_WIZARD_QUIT c=20 r=8 #: ../../Firmware/messages.cpp:121 ../../Firmware/ultralcd.cpp:4149 diff --git a/lang/po/Firmware_sl.po b/lang/po/Firmware_sl.po index 56386235fa..6f03c114cd 100644 --- a/lang/po/Firmware_sl.po +++ b/lang/po/Firmware_sl.po @@ -442,7 +442,7 @@ msgid "" "heatbed?" msgstr "" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "" @@ -1185,12 +1185,6 @@ msgstr "" msgid "More details online." msgstr "" -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1722,7 +1716,7 @@ msgstr "" msgid "Retract from FINDA" msgstr "" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "" @@ -1978,7 +1972,7 @@ msgstr "" msgid "Steel sheets" msgstr "" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "" @@ -2149,7 +2143,7 @@ msgid "" "is free. Check FINDA connection." msgstr "" -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "" diff --git a/lang/po/Firmware_sv.po b/lang/po/Firmware_sv.po index 31a33ed626..1a2a3c0029 100644 --- a/lang/po/Firmware_sv.po +++ b/lang/po/Firmware_sv.po @@ -456,7 +456,7 @@ msgstr "" "Vill du upprepa det sista steget för att justera avståndet mellan munstycket " "och värmebädden?" -#. MSG_BTN_CONTINUE c=5 +#. MSG_BTN_CONTINUE c=8 #: ../../Firmware/mmu2/errors_list.h:282 ../../Firmware/mmu2/errors_list.h:292 msgid "Done" msgstr "" @@ -1214,12 +1214,6 @@ msgstr "Modell" msgid "More details online." msgstr "" -#. MSG_BTN_MORE c=5 -#: ../../Firmware/mmu2/errors_list.h:287 -#: ../../Firmware/mmu2_error_converter.cpp:153 -msgid "More⏬" -msgstr "" - #. MSG_SELFTEST_MOTOR c=18 #: ../../Firmware/messages.cpp:95 ../../Firmware/ultralcd.cpp:6981 #: ../../Firmware/ultralcd.cpp:6990 ../../Firmware/ultralcd.cpp:7008 @@ -1770,7 +1764,7 @@ msgstr "Återupptar utskrift" msgid "Retract from FINDA" msgstr "" -#. MSG_BTN_RETRY c=5 +#. MSG_BTN_RETRY c=8 #: ../../Firmware/mmu2/errors_list.h:281 ../../Firmware/mmu2/errors_list.h:291 msgid "Retry" msgstr "" @@ -2036,7 +2030,7 @@ msgstr "Tyst" msgid "Steel sheets" msgstr "Metallskivor" -#. MSG_BTN_STOP c=5 +#. MSG_BTN_STOP c=8 #: ../../Firmware/mmu2/errors_list.h:285 ../../Firmware/mmu2/errors_list.h:295 msgid "Stop" msgstr "" @@ -2211,7 +2205,7 @@ msgid "" "is free. Check FINDA connection." msgstr "" -#. MSG_BTN_UNLOAD c=6 +#. MSG_BTN_UNLOAD c=8 #: ../../Firmware/mmu2/errors_list.h:284 ../../Firmware/mmu2/errors_list.h:294 msgid "Unload" msgstr "" diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100644 index 0000000000..09159f60e8 --- /dev/null +++ b/lib/CMakeLists.txt @@ -0,0 +1,3 @@ +if(NOT CMAKE_CROSSCOMPILING) + add_subdirectory(Catch2) +endif() diff --git a/lib/Catch2/.clang-format b/lib/Catch2/.clang-format new file mode 100644 index 0000000000..2a82aacfdc --- /dev/null +++ b/lib/Catch2/.clang-format @@ -0,0 +1,25 @@ +--- +AccessModifierOffset: '-4' +AlignEscapedNewlines: Left +AllowAllConstructorInitializersOnNextLine: 'true' +BinPackArguments: 'false' +BinPackParameters: 'false' +BreakConstructorInitializers: AfterColon +ConstructorInitializerAllOnOneLineOrOnePerLine: 'true' +DerivePointerAlignment: 'false' +FixNamespaceComments: 'true' +IncludeBlocks: Regroup +IndentCaseLabels: 'false' +IndentPPDirectives: AfterHash +IndentWidth: '4' +Language: Cpp +NamespaceIndentation: All +PointerAlignment: Left +SpaceBeforeCtorInitializerColon: 'false' +SpaceInEmptyParentheses: 'false' +SpacesInParentheses: 'true' +Standard: Cpp11 +TabWidth: '4' +UseTab: Never + +... diff --git a/lib/Catch2/.conan/build.py b/lib/Catch2/.conan/build.py new file mode 100644 index 0000000000..37975a8a1e --- /dev/null +++ b/lib/Catch2/.conan/build.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import re +from cpt.packager import ConanMultiPackager +from cpt.ci_manager import CIManager +from cpt.printer import Printer + + +class BuilderSettings(object): + @property + def username(self): + """ Set catchorg as package's owner + """ + return os.getenv("CONAN_USERNAME", "catchorg") + + @property + def login_username(self): + """ Set Bintray login username + """ + return os.getenv("CONAN_LOGIN_USERNAME", "horenmar") + + @property + def upload(self): + """ Set Catch2 repository to be used on upload. + The upload server address could be customized by env var + CONAN_UPLOAD. If not defined, the method will check the branch name. + Only master or CONAN_STABLE_BRANCH_PATTERN will be accepted. + The master branch will be pushed to testing channel, because it does + not match the stable pattern. Otherwise it will upload to stable + channel. + """ + return os.getenv("CONAN_UPLOAD", "https://api.bintray.com/conan/catchorg/catch2") + + @property + def upload_only_when_stable(self): + """ Force to upload when running over tag branch + """ + return os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", "True").lower() in ["true", "1", "yes"] + + @property + def stable_branch_pattern(self): + """ Only upload the package the branch name is like a tag + """ + return os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+") + + @property + def reference(self): + """ Read project version from branch create Conan reference + """ + return os.getenv("CONAN_REFERENCE", "Catch2/{}".format(self._version)) + + @property + def channel(self): + """ Default Conan package channel when not stable + """ + return os.getenv("CONAN_CHANNEL", "testing") + + @property + def _version(self): + """ Get version name from cmake file + """ + pattern = re.compile(r"project\(Catch2 LANGUAGES CXX VERSION (\d+\.\d+\.\d+)\)") + version = "latest" + with open("CMakeLists.txt") as file: + for line in file: + result = pattern.search(line) + if result: + version = result.group(1) + return version + + @property + def _branch(self): + """ Get branch name from CI manager + """ + printer = Printer(None) + ci_manager = CIManager(printer) + return ci_manager.get_branch() + + +if __name__ == "__main__": + settings = BuilderSettings() + builder = ConanMultiPackager( + reference=settings.reference, + channel=settings.channel, + upload=settings.upload, + upload_only_when_stable=settings.upload_only_when_stable, + stable_branch_pattern=settings.stable_branch_pattern, + login_username=settings.login_username, + username=settings.username, + test_folder=os.path.join(".conan", "test_package")) + builder.add() + builder.run() diff --git a/lib/Catch2/.conan/test_package/CMakeLists.txt b/lib/Catch2/.conan/test_package/CMakeLists.txt new file mode 100644 index 0000000000..db05659904 --- /dev/null +++ b/lib/Catch2/.conan/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.2.0) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Catch2 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} CONAN_PKG::Catch2) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) diff --git a/lib/Catch2/.conan/test_package/conanfile.py b/lib/Catch2/.conan/test_package/conanfile.py new file mode 100644 index 0000000000..0a0da54aa1 --- /dev/null +++ b/lib/Catch2/.conan/test_package/conanfile.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +from conans import ConanFile, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + assert os.path.isfile(os.path.join(self.deps_cpp_info["Catch2"].rootpath, "licenses", "LICENSE.txt")) + bin_path = os.path.join("bin", "test_package") + self.run("%s -s" % bin_path, run_environment=True) diff --git a/lib/Catch2/.conan/test_package/test_package.cpp b/lib/Catch2/.conan/test_package/test_package.cpp new file mode 100644 index 0000000000..cff50de549 --- /dev/null +++ b/lib/Catch2/.conan/test_package/test_package.cpp @@ -0,0 +1,15 @@ +#define CATCH_CONFIG_MAIN + +#include + +int Factorial( int number ) { + return number <= 1 ? 1 : Factorial( number - 1 ) * number; +} + +TEST_CASE( "Factorial Tests", "[single-file]" ) { + REQUIRE( Factorial(0) == 1 ); + REQUIRE( Factorial(1) == 1 ); + REQUIRE( Factorial(2) == 2 ); + REQUIRE( Factorial(3) == 6 ); + REQUIRE( Factorial(10) == 3628800 ); +} \ No newline at end of file diff --git a/lib/Catch2/.gitattributes b/lib/Catch2/.gitattributes new file mode 100644 index 0000000000..23f98fffa3 --- /dev/null +++ b/lib/Catch2/.gitattributes @@ -0,0 +1,22 @@ +# This sets the default behaviour, overriding core.autocrlf +* text=auto + +# All source files should have unix line-endings in the repository, +# but convert to native line-endings on checkout +*.cpp text +*.h text +*.hpp text + +# Windows specific files should retain windows line-endings +*.sln text eol=crlf + +# Keep executable scripts with LFs so they can be run after being +# checked out on Windows +*.py text eol=lf + + +# Keep the single include header with LFs to make sure it is uploaded, +# hashed etc with LF +single_include/**/*.hpp eol=lf +# Also keep the LICENCE file with LFs for the same reason +LICENCE.txt eol=lf diff --git a/lib/Catch2/.github/FUNDING.yml b/lib/Catch2/.github/FUNDING.yml new file mode 100644 index 0000000000..4d8a0e95ae --- /dev/null +++ b/lib/Catch2/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: "https://www.paypal.me/horenmar" diff --git a/lib/Catch2/.github/ISSUE_TEMPLATE/bug_report.md b/lib/Catch2/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000000..dbeff1152f --- /dev/null +++ b/lib/Catch2/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,29 @@ +--- +name: Bug report +about: Create an issue that documents a bug +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Reproduction steps** +Steps to reproduce the bug. + + + +**Platform information:** + + - OS: **Windows NT** + - Compiler+version: **GCC v2.9.5** + - Catch version: **v1.2.3** + + +**Additional context** +Add any other context about the problem here. diff --git a/lib/Catch2/.github/ISSUE_TEMPLATE/feature_request.md b/lib/Catch2/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000000..be9b9eeaec --- /dev/null +++ b/lib/Catch2/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,14 @@ +--- +name: Feature request +about: Create an issue that requests a feature or other improvement +title: '' +labels: '' +assignees: '' + +--- + +**Description** +Describe the feature/change you request and why do you want it. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/lib/Catch2/.github/pull_request_template.md b/lib/Catch2/.github/pull_request_template.md new file mode 100644 index 0000000000..ea2b7bb5fa --- /dev/null +++ b/lib/Catch2/.github/pull_request_template.md @@ -0,0 +1,28 @@ + + + +## Description + + +## GitHub Issues + diff --git a/lib/Catch2/.gitignore b/lib/Catch2/.gitignore new file mode 100644 index 0000000000..dd12a74ba6 --- /dev/null +++ b/lib/Catch2/.gitignore @@ -0,0 +1,31 @@ +*.build +*.pbxuser +*.mode1v3 +*.ncb +*.suo +Debug +Release +*.user +*.xcuserstate +.DS_Store +xcuserdata +CatchSelfTest.xcscheme +Breakpoints.xcbkptlist +projects/VS2010/TestCatch/_UpgradeReport_Files/ +projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj.filters +projects/VisualStudio/TestCatch/UpgradeLog.XML +projects/CMake/.idea +projects/CMake/cmake-build-debug +UpgradeLog.XML +Resources/DWARF +projects/Generated +*.pyc +DerivedData +*.xccheckout +Build +.idea +.vs +cmake-build-* +benchmark-dir +.conan/test_package/build +bazel-* diff --git a/lib/Catch2/.gitrepo b/lib/Catch2/.gitrepo new file mode 100644 index 0000000000..720de74265 --- /dev/null +++ b/lib/Catch2/.gitrepo @@ -0,0 +1,12 @@ +; DO NOT EDIT (unless you know what you are doing) +; +; This subdirectory is a git "subrepo", and this file is maintained by the +; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme +; +[subrepo] + remote = git@github.com:catchorg/Catch2.git + branch = v2.x + commit = 5c88067bd339465513af4aec606bd2292f1b594a + parent = c58a5298d683f9b137f23a929eac699cd776f66c + method = merge + cmdver = 0.4.3 diff --git a/lib/Catch2/.travis.yml b/lib/Catch2/.travis.yml new file mode 100644 index 0000000000..0fe2abb198 --- /dev/null +++ b/lib/Catch2/.travis.yml @@ -0,0 +1,339 @@ +language: cpp + +branches: + except: + - /dev-appveyor.*/ + +common_sources: &all_sources + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty + - llvm-toolchain-trusty-3.9 + - llvm-toolchain-trusty-4.0 + - llvm-toolchain-xenial-5.0 + - llvm-toolchain-xenial-6.0 + +matrix: + include: + + # 1/ Linux Clang Builds + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-3.5'] + env: COMPILER='clang++-3.5' + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-3.6'] + env: COMPILER='clang++-3.6' + + # Clang 3.7 is intentionally skipped as we cannot get it easily on + # TravisCI container + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['lcov', 'clang-3.8'] + env: COMPILER='clang++-3.8' + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-3.9'] + env: COMPILER='clang++-3.9' + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-4.0'] + env: COMPILER='clang++-4.0' + + - os: linux + dist: xenial + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-5.0'] + env: COMPILER='clang++-5.0' + + - os: linux + dist: xenial + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-6.0'] + env: COMPILER='clang++-6.0' + + # 2/ Linux GCC Builds + - os: linux + compiler: gcc + addons: + apt: + sources: *all_sources + packages: ['g++-4.8'] + env: COMPILER='g++-4.8' + + - os: linux + compiler: gcc + addons: + apt: + sources: *all_sources + packages: ['g++-4.9'] + env: COMPILER='g++-4.9' + + - os: linux + compiler: gcc + addons: + apt: + sources: *all_sources + packages: ['g++-5'] + env: COMPILER='g++-5' + + - os: linux + compiler: gcc + addons: &gcc6 + apt: + sources: *all_sources + packages: ['g++-6'] + env: COMPILER='g++-6' + + - os: linux + compiler: gcc + addons: &gcc7 + apt: + sources: *all_sources + packages: ['g++-7'] + env: COMPILER='g++-7' + + - os: linux + compiler: gcc + addons: &gcc8 + apt: + sources: *all_sources + packages: ['g++-8'] + env: COMPILER='g++-8' + + # 3b/ Linux C++14 Clang builds + # Note that we need newer libstdc++ for C++14 support + - os: linux + compiler: clang + addons: + apt: + packages: ['clang-3.8', 'libstdc++-6-dev'] + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty + env: COMPILER='clang++-3.8' CPP14=1 + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-3.9', 'libstdc++-6-dev'] + env: COMPILER='clang++-3.9' CPP14=1 + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-4.0', 'libstdc++-6-dev'] + env: COMPILER='clang++-4.0' CPP14=1 + + - os: linux + dist: xenial + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-5.0', 'libstdc++-6-dev'] + env: COMPILER='clang++-5.0' CPP14=1 + + - os: linux + dist: xenial + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-6.0', 'libstdc++-6-dev'] + env: COMPILER='clang++-6.0' CPP14=1 + + + # 4a/ Linux C++14 GCC builds + - os: linux + compiler: gcc + addons: *gcc6 + env: COMPILER='g++-6' CPP14=1 + + - os: linux + compiler: gcc + addons: *gcc7 + env: COMPILER='g++-7' CPP14=1 + + - os: linux + compiler: gcc + addons: *gcc8 + env: COMPILER='g++-8' CPP14=1 + + # 5/ OSX Clang Builds + - os: osx + osx_image: xcode7.3 + compiler: clang + env: COMPILER='clang++' + + - os: osx + osx_image: xcode8 + compiler: clang + env: COMPILER='clang++' + + - os: osx + osx_image: xcode9 + compiler: clang + env: COMPILER='clang++' + + - os: osx + osx_image: xcode9.1 + compiler: clang + env: COMPILER='clang++' + + - os: osx + osx_image: xcode9.1 + compiler: clang + env: COMPILER='clang++' CPP14=1 + + # 6/ Special builds -- examples, coverage, valgrind, etc. + - os: linux + compiler: gcc + addons: + apt: + sources: *all_sources + packages: ['lcov', 'g++-7'] + env: COMPILER='g++-7' CPP14=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1 + + - os: linux + compiler: clang + addons: + apt: + packages: ['clang-3.8', 'lcov'] + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty + env: COMPILER='clang++-3.8' EXAMPLES=1 COVERAGE=1 EXTRAS=1 + + - os: linux + compiler: gcc + addons: + apt: + sources: *all_sources + packages: ['valgrind', 'lcov', 'g++-7'] + env: COMPILER='g++-7' CPP14=1 VALGRIND=1 + + - os: osx + osx_image: xcode9.1 + compiler: clang + env: COMPILER='clang++' CPP14=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1 + + # 7/ C++17 builds + - os: linux + compiler: gcc + addons: *gcc7 + env: COMPILER='g++-7' CPP17=1 + + - os: linux + compiler: gcc + addons: *gcc7 + env: COMPILER='g++-7' EXAMPLES=1 COVERAGE=1 EXTRAS=1 CPP17=1 + + - os: linux + dist: xenial + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-6.0', 'libstdc++-8-dev'] + env: COMPILER='clang++-6.0' CPP17=1 + + - os: linux + dist: xenial + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-6.0', 'libstdc++-8-dev'] + env: COMPILER='clang++-6.0' CPP17=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1 + + # 8/ Conan + - language: python + python: + - "3.7" + dist: xenial + install: + - pip install conan-package-tools + env: + - CONAN_GCC_VERSIONS=8 + - CONAN_DOCKER_IMAGE=conanio/gcc8 + script: + - python .conan/build.py + +install: + - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" + - mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR} + - | + if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then + CMAKE_URL="http://cmake.org/files/v3.8/cmake-3.8.2-Linux-x86_64.tar.gz" + mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake + export PATH=${DEPS_DIR}/cmake/bin:${PATH} + elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then + which cmake || brew install cmake; + fi + +before_script: + - export CXX=${COMPILER} + - cd ${TRAVIS_BUILD_DIR} + # Regenerate single header file, so it is tested in the examples... + - python scripts/generateSingleHeader.py + + - | + if [[ ${CPP17} -eq 1 ]]; then + export CPP_STANDARD=17 + elif [[ ${CPP14} -eq 1 ]]; then + export CPP_STANDARD=14 + else + export CPP_STANDARD=11 + fi + + # Use Debug builds for running Valgrind and building examples + - cmake -H. -BBuild-Debug -DCMAKE_BUILD_TYPE=Debug -Wdev -DCATCH_USE_VALGRIND=${VALGRIND} -DCATCH_BUILD_EXAMPLES=${EXAMPLES} -DCATCH_ENABLE_COVERAGE=${COVERAGE} -DCATCH_BUILD_EXTRA_TESTS=${EXTRAS} -DCMAKE_CXX_STANDARD=${CPP_STANDARD} -DCMAKE_CXX_STANDARD_REQUIRED=On -DCMAKE_CXX_EXTENSIONS=OFF + # Don't bother with release build for coverage build + - cmake -H. -BBuild-Release -DCMAKE_BUILD_TYPE=Release -Wdev -DCMAKE_CXX_STANDARD=${CPP_STANDARD} -DCMAKE_CXX_STANDARD_REQUIRED=On -DCMAKE_CXX_EXTENSIONS=OFF + + +script: + - cd Build-Debug + - make -j 2 + - CTEST_OUTPUT_ON_FAILURE=1 ctest -j 2 + # Coverage collection does not work for OS X atm + - | + if [[ "${TRAVIS_OS_NAME}" == "linux" ]] && [[ "${COVERAGE}" == "1" ]]; then + make gcov + make lcov + bash <(curl -s https://codecov.io/bash) -X gcov || echo "Codecov did not collect coverage reports" + fi + - # Go to release build + - cd ../Build-Release + - make -j 2 + - CTEST_OUTPUT_ON_FAILURE=1 ctest -j 2 diff --git a/lib/Catch2/BUILD.bazel b/lib/Catch2/BUILD.bazel new file mode 100644 index 0000000000..229c550ea0 --- /dev/null +++ b/lib/Catch2/BUILD.bazel @@ -0,0 +1,17 @@ +# Load the cc_library rule. +load("@rules_cc//cc:defs.bzl", "cc_library") + +# Header-only rule to export catch2/catch.hpp. +cc_library( + name = "catch2", + hdrs = ["single_include/catch2/catch.hpp"], + includes = ["single_include/"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "catch2_with_main", + srcs = ["src/catch_with_main.cpp"], + visibility = ["//visibility:public"], + deps = ["//:catch2"], +) diff --git a/lib/Catch2/CMake/Catch2Config.cmake.in b/lib/Catch2/CMake/Catch2Config.cmake.in new file mode 100644 index 0000000000..c485219cdb --- /dev/null +++ b/lib/Catch2/CMake/Catch2Config.cmake.in @@ -0,0 +1,10 @@ +@PACKAGE_INIT@ + + +# Avoid repeatedly including the targets +if(NOT TARGET Catch2::Catch2) + # Provide path for scripts + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + + include(${CMAKE_CURRENT_LIST_DIR}/Catch2Targets.cmake) +endif() diff --git a/lib/Catch2/CMake/FindGcov.cmake b/lib/Catch2/CMake/FindGcov.cmake new file mode 100644 index 0000000000..414171134c --- /dev/null +++ b/lib/Catch2/CMake/FindGcov.cmake @@ -0,0 +1,157 @@ +# This file is part of CMake-codecov. +# +# Copyright (c) +# 2015-2017 RWTH Aachen University, Federal Republic of Germany +# +# See the LICENSE file in the package base directory for details +# +# Written by Alexander Haase, alexander.haase@rwth-aachen.de +# + + +# include required Modules +include(FindPackageHandleStandardArgs) + + +# Search for gcov binary. +set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) +set(CMAKE_REQUIRED_QUIET ${codecov_FIND_QUIETLY}) + +get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) +foreach (LANG ${ENABLED_LANGUAGES}) + # Gcov evaluation is dependent on the used compiler. Check gcov support for + # each compiler that is used. If gcov binary was already found for this + # compiler, do not try to find it again. + if (NOT GCOV_${CMAKE_${LANG}_COMPILER_ID}_BIN) + get_filename_component(COMPILER_PATH "${CMAKE_${LANG}_COMPILER}" PATH) + + if ("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "GNU") + # Some distributions like OSX (homebrew) ship gcov with the compiler + # version appended as gcov-x. To find this binary we'll build the + # suggested binary name with the compiler version. + string(REGEX MATCH "^[0-9]+" GCC_VERSION + "${CMAKE_${LANG}_COMPILER_VERSION}") + + find_program(GCOV_BIN NAMES gcov-${GCC_VERSION} gcov + HINTS ${COMPILER_PATH}) + + elseif ("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "Clang") + # Some distributions like Debian ship llvm-cov with the compiler + # version appended as llvm-cov-x.y. To find this binary we'll build + # the suggested binary name with the compiler version. + string(REGEX MATCH "^[0-9]+.[0-9]+" LLVM_VERSION + "${CMAKE_${LANG}_COMPILER_VERSION}") + + # llvm-cov prior version 3.5 seems to be not working with coverage + # evaluation tools, but these versions are compatible with the gcc + # gcov tool. + if(LLVM_VERSION VERSION_GREATER 3.4) + find_program(LLVM_COV_BIN NAMES "llvm-cov-${LLVM_VERSION}" + "llvm-cov" HINTS ${COMPILER_PATH}) + mark_as_advanced(LLVM_COV_BIN) + + if (LLVM_COV_BIN) + find_program(LLVM_COV_WRAPPER "llvm-cov-wrapper" PATHS + ${CMAKE_MODULE_PATH}) + if (LLVM_COV_WRAPPER) + set(GCOV_BIN "${LLVM_COV_WRAPPER}" CACHE FILEPATH "") + + # set additional parameters + set(GCOV_${CMAKE_${LANG}_COMPILER_ID}_ENV + "LLVM_COV_BIN=${LLVM_COV_BIN}" CACHE STRING + "Environment variables for llvm-cov-wrapper.") + mark_as_advanced(GCOV_${CMAKE_${LANG}_COMPILER_ID}_ENV) + endif () + endif () + endif () + + if (NOT GCOV_BIN) + # Fall back to gcov binary if llvm-cov was not found or is + # incompatible. This is the default on OSX, but may crash on + # recent Linux versions. + find_program(GCOV_BIN gcov HINTS ${COMPILER_PATH}) + endif () + endif () + + + if (GCOV_BIN) + set(GCOV_${CMAKE_${LANG}_COMPILER_ID}_BIN "${GCOV_BIN}" CACHE STRING + "${LANG} gcov binary.") + + if (NOT CMAKE_REQUIRED_QUIET) + message("-- Found gcov evaluation for " + "${CMAKE_${LANG}_COMPILER_ID}: ${GCOV_BIN}") + endif() + + unset(GCOV_BIN CACHE) + endif () + endif () +endforeach () + + + + +# Add a new global target for all gcov targets. This target could be used to +# generate the gcov files for the whole project instead of calling -gcov +# for each target. +if (NOT TARGET gcov) + add_custom_target(gcov) +endif (NOT TARGET gcov) + + + +# This function will add gcov evaluation for target . Only sources of +# this target will be evaluated and no dependencies will be added. It will call +# Gcov on any source file of once and store the gcov file in the same +# directory. +function (add_gcov_target TNAME) + set(TDIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TNAME}.dir) + + # We don't have to check, if the target has support for coverage, thus this + # will be checked by add_coverage_target in Findcoverage.cmake. Instead we + # have to determine which gcov binary to use. + get_target_property(TSOURCES ${TNAME} SOURCES) + set(SOURCES "") + set(TCOMPILER "") + foreach (FILE ${TSOURCES}) + codecov_path_of_source(${FILE} FILE) + if (NOT "${FILE}" STREQUAL "") + codecov_lang_of_source(${FILE} LANG) + if (NOT "${LANG}" STREQUAL "") + list(APPEND SOURCES "${FILE}") + set(TCOMPILER ${CMAKE_${LANG}_COMPILER_ID}) + endif () + endif () + endforeach () + + # If no gcov binary was found, coverage data can't be evaluated. + if (NOT GCOV_${TCOMPILER}_BIN) + message(WARNING "No coverage evaluation binary found for ${TCOMPILER}.") + return() + endif () + + set(GCOV_BIN "${GCOV_${TCOMPILER}_BIN}") + set(GCOV_ENV "${GCOV_${TCOMPILER}_ENV}") + + + set(BUFFER "") + foreach(FILE ${SOURCES}) + get_filename_component(FILE_PATH "${TDIR}/${FILE}" PATH) + + # call gcov + add_custom_command(OUTPUT ${TDIR}/${FILE}.gcov + COMMAND ${GCOV_ENV} ${GCOV_BIN} ${TDIR}/${FILE}.gcno > /dev/null + DEPENDS ${TNAME} ${TDIR}/${FILE}.gcno + WORKING_DIRECTORY ${FILE_PATH} + ) + + list(APPEND BUFFER ${TDIR}/${FILE}.gcov) + endforeach() + + + # add target for gcov evaluation of + add_custom_target(${TNAME}-gcov DEPENDS ${BUFFER}) + + # add evaluation target to the global gcov target. + add_dependencies(gcov ${TNAME}-gcov) +endfunction (add_gcov_target) diff --git a/lib/Catch2/CMake/FindLcov.cmake b/lib/Catch2/CMake/FindLcov.cmake new file mode 100644 index 0000000000..beb925ae06 --- /dev/null +++ b/lib/Catch2/CMake/FindLcov.cmake @@ -0,0 +1,354 @@ +# This file is part of CMake-codecov. +# +# Copyright (c) +# 2015-2017 RWTH Aachen University, Federal Republic of Germany +# +# See the LICENSE file in the package base directory for details +# +# Written by Alexander Haase, alexander.haase@rwth-aachen.de +# + + +# configuration +set(LCOV_DATA_PATH "${CMAKE_BINARY_DIR}/lcov/data") +set(LCOV_DATA_PATH_INIT "${LCOV_DATA_PATH}/init") +set(LCOV_DATA_PATH_CAPTURE "${LCOV_DATA_PATH}/capture") +set(LCOV_HTML_PATH "${CMAKE_BINARY_DIR}/lcov/html") + + + + +# Search for Gcov which is used by Lcov. +find_package(Gcov) + + + + +# This function will add lcov evaluation for target . Only sources of +# this target will be evaluated and no dependencies will be added. It will call +# geninfo on any source file of once and store the info file in the same +# directory. +# +# Note: This function is only a wrapper to define this function always, even if +# coverage is not supported by the compiler or disabled. This function must +# be defined here, because the module will be exited, if there is no coverage +# support by the compiler or it is disabled by the user. +function (add_lcov_target TNAME) + if (LCOV_FOUND) + # capture initial coverage data + lcov_capture_initial_tgt(${TNAME}) + + # capture coverage data after execution + lcov_capture_tgt(${TNAME}) + endif () +endfunction (add_lcov_target) + + + + +# include required Modules +include(FindPackageHandleStandardArgs) + +# Search for required lcov binaries. +find_program(LCOV_BIN lcov) +find_program(GENINFO_BIN geninfo) +find_program(GENHTML_BIN genhtml) +find_package_handle_standard_args(lcov + REQUIRED_VARS LCOV_BIN GENINFO_BIN GENHTML_BIN +) + +# enable genhtml C++ demangeling, if c++filt is found. +set(GENHTML_CPPFILT_FLAG "") +find_program(CPPFILT_BIN c++filt) +if (NOT CPPFILT_BIN STREQUAL "") + set(GENHTML_CPPFILT_FLAG "--demangle-cpp") +endif (NOT CPPFILT_BIN STREQUAL "") + +# enable no-external flag for lcov, if available. +if (GENINFO_BIN AND NOT DEFINED GENINFO_EXTERN_FLAG) + set(FLAG "") + execute_process(COMMAND ${GENINFO_BIN} --help OUTPUT_VARIABLE GENINFO_HELP) + string(REGEX MATCH "external" GENINFO_RES "${GENINFO_HELP}") + if (GENINFO_RES) + set(FLAG "--no-external") + endif () + + set(GENINFO_EXTERN_FLAG "${FLAG}" + CACHE STRING "Geninfo flag to exclude system sources.") +endif () + +# If Lcov was not found, exit module now. +if (NOT LCOV_FOUND) + return() +endif (NOT LCOV_FOUND) + + + + +# Create directories to be used. +file(MAKE_DIRECTORY ${LCOV_DATA_PATH_INIT}) +file(MAKE_DIRECTORY ${LCOV_DATA_PATH_CAPTURE}) + +set(LCOV_REMOVE_PATTERNS "") + +# This function will merge lcov files to a single target file. Additional lcov +# flags may be set with setting LCOV_EXTRA_FLAGS before calling this function. +function (lcov_merge_files OUTFILE ...) + # Remove ${OUTFILE} from ${ARGV} and generate lcov parameters with files. + list(REMOVE_AT ARGV 0) + + # Generate merged file. + string(REPLACE "${CMAKE_BINARY_DIR}/" "" FILE_REL "${OUTFILE}") + add_custom_command(OUTPUT "${OUTFILE}.raw" + COMMAND cat ${ARGV} > ${OUTFILE}.raw + DEPENDS ${ARGV} + COMMENT "Generating ${FILE_REL}" + ) + + add_custom_command(OUTPUT "${OUTFILE}" + COMMAND ${LCOV_BIN} --quiet -a ${OUTFILE}.raw --output-file ${OUTFILE} + --base-directory ${PROJECT_SOURCE_DIR} ${LCOV_EXTRA_FLAGS} + COMMAND ${LCOV_BIN} --quiet -r ${OUTFILE} ${LCOV_REMOVE_PATTERNS} + --output-file ${OUTFILE} ${LCOV_EXTRA_FLAGS} + DEPENDS ${OUTFILE}.raw + COMMENT "Post-processing ${FILE_REL}" + ) +endfunction () + + + + +# Add a new global target to generate initial coverage reports for all targets. +# This target will be used to generate the global initial info file, which is +# used to gather even empty report data. +if (NOT TARGET lcov-capture-init) + add_custom_target(lcov-capture-init) + set(LCOV_CAPTURE_INIT_FILES "" CACHE INTERNAL "") +endif (NOT TARGET lcov-capture-init) + + +# This function will add initial capture of coverage data for target , +# which is needed to get also data for objects, which were not loaded at +# execution time. It will call geninfo for every source file of once and +# store the info file in the same directory. +function (lcov_capture_initial_tgt TNAME) + # We don't have to check, if the target has support for coverage, thus this + # will be checked by add_coverage_target in Findcoverage.cmake. Instead we + # have to determine which gcov binary to use. + get_target_property(TSOURCES ${TNAME} SOURCES) + set(SOURCES "") + set(TCOMPILER "") + foreach (FILE ${TSOURCES}) + codecov_path_of_source(${FILE} FILE) + if (NOT "${FILE}" STREQUAL "") + codecov_lang_of_source(${FILE} LANG) + if (NOT "${LANG}" STREQUAL "") + list(APPEND SOURCES "${FILE}") + set(TCOMPILER ${CMAKE_${LANG}_COMPILER_ID}) + endif () + endif () + endforeach () + + # If no gcov binary was found, coverage data can't be evaluated. + if (NOT GCOV_${TCOMPILER}_BIN) + message(WARNING "No coverage evaluation binary found for ${TCOMPILER}.") + return() + endif () + + set(GCOV_BIN "${GCOV_${TCOMPILER}_BIN}") + set(GCOV_ENV "${GCOV_${TCOMPILER}_ENV}") + + + set(TDIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TNAME}.dir) + set(GENINFO_FILES "") + foreach(FILE ${SOURCES}) + # generate empty coverage files + set(OUTFILE "${TDIR}/${FILE}.info.init") + list(APPEND GENINFO_FILES ${OUTFILE}) + + add_custom_command(OUTPUT ${OUTFILE} COMMAND ${GCOV_ENV} ${GENINFO_BIN} + --quiet --base-directory ${PROJECT_SOURCE_DIR} --initial + --gcov-tool ${GCOV_BIN} --output-filename ${OUTFILE} + ${GENINFO_EXTERN_FLAG} ${TDIR}/${FILE}.gcno + DEPENDS ${TNAME} + COMMENT "Capturing initial coverage data for ${FILE}" + ) + endforeach() + + # Concatenate all files generated by geninfo to a single file per target. + set(OUTFILE "${LCOV_DATA_PATH_INIT}/${TNAME}.info") + set(LCOV_EXTRA_FLAGS "--initial") + lcov_merge_files("${OUTFILE}" ${GENINFO_FILES}) + add_custom_target(${TNAME}-capture-init ALL DEPENDS ${OUTFILE}) + + # add geninfo file generation to global lcov-geninfo target + add_dependencies(lcov-capture-init ${TNAME}-capture-init) + set(LCOV_CAPTURE_INIT_FILES "${LCOV_CAPTURE_INIT_FILES}" + "${OUTFILE}" CACHE INTERNAL "" + ) +endfunction (lcov_capture_initial_tgt) + + +# This function will generate the global info file for all targets. It has to be +# called after all other CMake functions in the root CMakeLists.txt file, to get +# a full list of all targets that generate coverage data. +function (lcov_capture_initial) + # Skip this function (and do not create the following targets), if there are + # no input files. + if ("${LCOV_CAPTURE_INIT_FILES}" STREQUAL "") + return() + endif () + + # Add a new target to merge the files of all targets. + set(OUTFILE "${LCOV_DATA_PATH_INIT}/all_targets.info") + lcov_merge_files("${OUTFILE}" ${LCOV_CAPTURE_INIT_FILES}) + add_custom_target(lcov-geninfo-init ALL DEPENDS ${OUTFILE} + lcov-capture-init + ) +endfunction (lcov_capture_initial) + + + + +# Add a new global target to generate coverage reports for all targets. This +# target will be used to generate the global info file. +if (NOT TARGET lcov-capture) + add_custom_target(lcov-capture) + set(LCOV_CAPTURE_FILES "" CACHE INTERNAL "") +endif (NOT TARGET lcov-capture) + + +# This function will add capture of coverage data for target , which is +# needed to get also data for objects, which were not loaded at execution time. +# It will call geninfo for every source file of once and store the info +# file in the same directory. +function (lcov_capture_tgt TNAME) + # We don't have to check, if the target has support for coverage, thus this + # will be checked by add_coverage_target in Findcoverage.cmake. Instead we + # have to determine which gcov binary to use. + get_target_property(TSOURCES ${TNAME} SOURCES) + set(SOURCES "") + set(TCOMPILER "") + foreach (FILE ${TSOURCES}) + codecov_path_of_source(${FILE} FILE) + if (NOT "${FILE}" STREQUAL "") + codecov_lang_of_source(${FILE} LANG) + if (NOT "${LANG}" STREQUAL "") + list(APPEND SOURCES "${FILE}") + set(TCOMPILER ${CMAKE_${LANG}_COMPILER_ID}) + endif () + endif () + endforeach () + + # If no gcov binary was found, coverage data can't be evaluated. + if (NOT GCOV_${TCOMPILER}_BIN) + message(WARNING "No coverage evaluation binary found for ${TCOMPILER}.") + return() + endif () + + set(GCOV_BIN "${GCOV_${TCOMPILER}_BIN}") + set(GCOV_ENV "${GCOV_${TCOMPILER}_ENV}") + + + set(TDIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TNAME}.dir) + set(GENINFO_FILES "") + foreach(FILE ${SOURCES}) + # Generate coverage files. If no .gcda file was generated during + # execution, the empty coverage file will be used instead. + set(OUTFILE "${TDIR}/${FILE}.info") + list(APPEND GENINFO_FILES ${OUTFILE}) + + add_custom_command(OUTPUT ${OUTFILE} + COMMAND test -f "${TDIR}/${FILE}.gcda" + && ${GCOV_ENV} ${GENINFO_BIN} --quiet --base-directory + ${PROJECT_SOURCE_DIR} --gcov-tool ${GCOV_BIN} + --output-filename ${OUTFILE} ${GENINFO_EXTERN_FLAG} + ${TDIR}/${FILE}.gcda + || cp ${OUTFILE}.init ${OUTFILE} + DEPENDS ${TNAME} ${TNAME}-capture-init + COMMENT "Capturing coverage data for ${FILE}" + ) + endforeach() + + # Concatenate all files generated by geninfo to a single file per target. + set(OUTFILE "${LCOV_DATA_PATH_CAPTURE}/${TNAME}.info") + lcov_merge_files("${OUTFILE}" ${GENINFO_FILES}) + add_custom_target(${TNAME}-geninfo DEPENDS ${OUTFILE}) + + # add geninfo file generation to global lcov-capture target + add_dependencies(lcov-capture ${TNAME}-geninfo) + set(LCOV_CAPTURE_FILES "${LCOV_CAPTURE_FILES}" "${OUTFILE}" CACHE INTERNAL + "" + ) + + # Add target for generating html output for this target only. + file(MAKE_DIRECTORY ${LCOV_HTML_PATH}/${TNAME}) + add_custom_target(${TNAME}-genhtml + COMMAND ${GENHTML_BIN} --quiet --sort --prefix ${PROJECT_SOURCE_DIR} + --baseline-file ${LCOV_DATA_PATH_INIT}/${TNAME}.info + --output-directory ${LCOV_HTML_PATH}/${TNAME} + --title "${CMAKE_PROJECT_NAME} - target ${TNAME}" + ${GENHTML_CPPFILT_FLAG} ${OUTFILE} + DEPENDS ${TNAME}-geninfo ${TNAME}-capture-init + ) +endfunction (lcov_capture_tgt) + + +# This function will generate the global info file for all targets. It has to be +# called after all other CMake functions in the root CMakeLists.txt file, to get +# a full list of all targets that generate coverage data. +function (lcov_capture) + # Skip this function (and do not create the following targets), if there are + # no input files. + if ("${LCOV_CAPTURE_FILES}" STREQUAL "") + return() + endif () + + # Add a new target to merge the files of all targets. + set(OUTFILE "${LCOV_DATA_PATH_CAPTURE}/all_targets.info") + lcov_merge_files("${OUTFILE}" ${LCOV_CAPTURE_FILES}) + add_custom_target(lcov-geninfo DEPENDS ${OUTFILE} lcov-capture) + + # Add a new global target for all lcov targets. This target could be used to + # generate the lcov html output for the whole project instead of calling + # -geninfo and -genhtml for each target. It will also be + # used to generate a html site for all project data together instead of one + # for each target. + if (NOT TARGET lcov) + file(MAKE_DIRECTORY ${LCOV_HTML_PATH}/all_targets) + add_custom_target(lcov + COMMAND ${GENHTML_BIN} --quiet --sort + --baseline-file ${LCOV_DATA_PATH_INIT}/all_targets.info + --output-directory ${LCOV_HTML_PATH}/all_targets + --title "${CMAKE_PROJECT_NAME}" --prefix "${PROJECT_SOURCE_DIR}" + ${GENHTML_CPPFILT_FLAG} ${OUTFILE} + DEPENDS lcov-geninfo-init lcov-geninfo + ) + endif () +endfunction (lcov_capture) + + + + +# Add a new global target to generate the lcov html report for the whole project +# instead of calling -genhtml for each target (to create an own report +# for each target). Instead of the lcov target it does not require geninfo for +# all targets, so you have to call -geninfo to generate the info files +# the targets you'd like to have in your report or lcov-geninfo for generating +# info files for all targets before calling lcov-genhtml. +file(MAKE_DIRECTORY ${LCOV_HTML_PATH}/selected_targets) +if (NOT TARGET lcov-genhtml) + add_custom_target(lcov-genhtml + COMMAND ${GENHTML_BIN} + --quiet + --output-directory ${LCOV_HTML_PATH}/selected_targets + --title \"${CMAKE_PROJECT_NAME} - targets `find + ${LCOV_DATA_PATH_CAPTURE} -name \"*.info\" ! -name + \"all_targets.info\" -exec basename {} .info \\\;`\" + --prefix ${PROJECT_SOURCE_DIR} + --sort + ${GENHTML_CPPFILT_FLAG} + `find ${LCOV_DATA_PATH_CAPTURE} -name \"*.info\" ! -name + \"all_targets.info\"` + ) +endif (NOT TARGET lcov-genhtml) diff --git a/lib/Catch2/CMake/Findcodecov.cmake b/lib/Catch2/CMake/Findcodecov.cmake new file mode 100644 index 0000000000..2c0f2fee5f --- /dev/null +++ b/lib/Catch2/CMake/Findcodecov.cmake @@ -0,0 +1,258 @@ +# This file is part of CMake-codecov. +# +# Copyright (c) +# 2015-2017 RWTH Aachen University, Federal Republic of Germany +# +# See the LICENSE file in the package base directory for details +# +# Written by Alexander Haase, alexander.haase@rwth-aachen.de +# + + +# Add an option to choose, if coverage should be enabled or not. If enabled +# marked targets will be build with coverage support and appropriate targets +# will be added. If disabled coverage will be ignored for *ALL* targets. +option(ENABLE_COVERAGE "Enable coverage build." OFF) + +set(COVERAGE_FLAG_CANDIDATES + # gcc and clang + "-O0 -g -fprofile-arcs -ftest-coverage" + + # gcc and clang fallback + "-O0 -g --coverage" +) + + +# Add coverage support for target ${TNAME} and register target for coverage +# evaluation. If coverage is disabled or not supported, this function will +# simply do nothing. +# +# Note: This function is only a wrapper to define this function always, even if +# coverage is not supported by the compiler or disabled. This function must +# be defined here, because the module will be exited, if there is no coverage +# support by the compiler or it is disabled by the user. +function (add_coverage TNAME) + # only add coverage for target, if coverage is support and enabled. + if (ENABLE_COVERAGE) + foreach (TNAME ${ARGV}) + add_coverage_target(${TNAME}) + endforeach () + endif () +endfunction (add_coverage) + + +# Add global target to gather coverage information after all targets have been +# added. Other evaluation functions could be added here, after checks for the +# specific module have been passed. +# +# Note: This function is only a wrapper to define this function always, even if +# coverage is not supported by the compiler or disabled. This function must +# be defined here, because the module will be exited, if there is no coverage +# support by the compiler or it is disabled by the user. +function (coverage_evaluate) + # add lcov evaluation + if (LCOV_FOUND) + lcov_capture_initial() + lcov_capture() + endif (LCOV_FOUND) +endfunction () + + +# Exit this module, if coverage is disabled. add_coverage is defined before this +# return, so this module can be exited now safely without breaking any build- +# scripts. +if (NOT ENABLE_COVERAGE) + return() +endif () + + + + +# Find the reuired flags foreach language. +set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) +set(CMAKE_REQUIRED_QUIET ${codecov_FIND_QUIETLY}) + +get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) +foreach (LANG ${ENABLED_LANGUAGES}) + # Coverage flags are not dependent on language, but the used compiler. So + # instead of searching flags foreach language, search flags foreach compiler + # used. + set(COMPILER ${CMAKE_${LANG}_COMPILER_ID}) + if (NOT COVERAGE_${COMPILER}_FLAGS) + foreach (FLAG ${COVERAGE_FLAG_CANDIDATES}) + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Try ${COMPILER} code coverage flag = [${FLAG}]") + endif() + + set(CMAKE_REQUIRED_FLAGS "${FLAG}") + unset(COVERAGE_FLAG_DETECTED CACHE) + + if (${LANG} STREQUAL "C") + include(CheckCCompilerFlag) + check_c_compiler_flag("${FLAG}" COVERAGE_FLAG_DETECTED) + + elseif (${LANG} STREQUAL "CXX") + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag("${FLAG}" COVERAGE_FLAG_DETECTED) + + elseif (${LANG} STREQUAL "Fortran") + # CheckFortranCompilerFlag was introduced in CMake 3.x. To be + # compatible with older Cmake versions, we will check if this + # module is present before we use it. Otherwise we will define + # Fortran coverage support as not available. + include(CheckFortranCompilerFlag OPTIONAL + RESULT_VARIABLE INCLUDED) + if (INCLUDED) + check_fortran_compiler_flag("${FLAG}" + COVERAGE_FLAG_DETECTED) + elseif (NOT CMAKE_REQUIRED_QUIET) + message("-- Performing Test COVERAGE_FLAG_DETECTED") + message("-- Performing Test COVERAGE_FLAG_DETECTED - Failed" + " (Check not supported)") + endif () + endif() + + if (COVERAGE_FLAG_DETECTED) + set(COVERAGE_${COMPILER}_FLAGS "${FLAG}" + CACHE STRING "${COMPILER} flags for code coverage.") + mark_as_advanced(COVERAGE_${COMPILER}_FLAGS) + break() + else () + message(WARNING "Code coverage is not available for ${COMPILER}" + " compiler. Targets using this compiler will be " + "compiled without it.") + endif () + endforeach () + endif () +endforeach () + +set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) + + + + +# Helper function to get the language of a source file. +function (codecov_lang_of_source FILE RETURN_VAR) + get_filename_component(FILE_EXT "${FILE}" EXT) + string(TOLOWER "${FILE_EXT}" FILE_EXT) + string(SUBSTRING "${FILE_EXT}" 1 -1 FILE_EXT) + + get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) + foreach (LANG ${ENABLED_LANGUAGES}) + list(FIND CMAKE_${LANG}_SOURCE_FILE_EXTENSIONS "${FILE_EXT}" TEMP) + if (NOT ${TEMP} EQUAL -1) + set(${RETURN_VAR} "${LANG}" PARENT_SCOPE) + return() + endif () + endforeach() + + set(${RETURN_VAR} "" PARENT_SCOPE) +endfunction () + + +# Helper function to get the relative path of the source file destination path. +# This path is needed by FindGcov and FindLcov cmake files to locate the +# captured data. +function (codecov_path_of_source FILE RETURN_VAR) + string(REGEX MATCH "TARGET_OBJECTS:([^ >]+)" _source ${FILE}) + + # If expression was found, SOURCEFILE is a generator-expression for an + # object library. Currently we found no way to call this function automatic + # for the referenced target, so it must be called in the directoryso of the + # object library definition. + if (NOT "${_source}" STREQUAL "") + set(${RETURN_VAR} "" PARENT_SCOPE) + return() + endif () + + + string(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" "" FILE "${FILE}") + if(IS_ABSOLUTE ${FILE}) + file(RELATIVE_PATH FILE ${CMAKE_CURRENT_SOURCE_DIR} ${FILE}) + endif() + + # get the right path for file + string(REPLACE ".." "__" PATH "${FILE}") + + set(${RETURN_VAR} "${PATH}" PARENT_SCOPE) +endfunction() + + + + +# Add coverage support for target ${TNAME} and register target for coverage +# evaluation. +function(add_coverage_target TNAME) + # Check if all sources for target use the same compiler. If a target uses + # e.g. C and Fortran mixed and uses different compilers (e.g. clang and + # gfortran) this can trigger huge problems, because different compilers may + # use different implementations for code coverage. + get_target_property(TSOURCES ${TNAME} SOURCES) + set(TARGET_COMPILER "") + set(ADDITIONAL_FILES "") + foreach (FILE ${TSOURCES}) + # If expression was found, FILE is a generator-expression for an object + # library. Object libraries will be ignored. + string(REGEX MATCH "TARGET_OBJECTS:([^ >]+)" _file ${FILE}) + if ("${_file}" STREQUAL "") + codecov_lang_of_source(${FILE} LANG) + if (LANG) + list(APPEND TARGET_COMPILER ${CMAKE_${LANG}_COMPILER_ID}) + + list(APPEND ADDITIONAL_FILES "${FILE}.gcno") + list(APPEND ADDITIONAL_FILES "${FILE}.gcda") + endif () + endif () + endforeach () + + list(REMOVE_DUPLICATES TARGET_COMPILER) + list(LENGTH TARGET_COMPILER NUM_COMPILERS) + + if (NUM_COMPILERS GREATER 1) + message(WARNING "Can't use code coverage for target ${TNAME}, because " + "it will be compiled by incompatible compilers. Target will be " + "compiled without code coverage.") + return() + + elseif (NUM_COMPILERS EQUAL 0) + message(WARNING "Can't use code coverage for target ${TNAME}, because " + "it uses an unknown compiler. Target will be compiled without " + "code coverage.") + return() + + elseif (NOT DEFINED "COVERAGE_${TARGET_COMPILER}_FLAGS") + # A warning has been printed before, so just return if flags for this + # compiler aren't available. + return() + endif() + + + # enable coverage for target + set_property(TARGET ${TNAME} APPEND_STRING + PROPERTY COMPILE_FLAGS " ${COVERAGE_${TARGET_COMPILER}_FLAGS}") + set_property(TARGET ${TNAME} APPEND_STRING + PROPERTY LINK_FLAGS " ${COVERAGE_${TARGET_COMPILER}_FLAGS}") + + + # Add gcov files generated by compiler to clean target. + set(CLEAN_FILES "") + foreach (FILE ${ADDITIONAL_FILES}) + codecov_path_of_source(${FILE} FILE) + list(APPEND CLEAN_FILES "CMakeFiles/${TNAME}.dir/${FILE}") + endforeach() + + set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES + "${CLEAN_FILES}") + + + add_gcov_target(${TNAME}) + add_lcov_target(${TNAME}) +endfunction(add_coverage_target) + + + + +# Include modules for parsing the collected data and output it in a readable +# format (like gcov and lcov). +find_package(Gcov) +find_package(Lcov) diff --git a/lib/Catch2/CMake/MiscFunctions.cmake b/lib/Catch2/CMake/MiscFunctions.cmake new file mode 100644 index 0000000000..262f7cd829 --- /dev/null +++ b/lib/Catch2/CMake/MiscFunctions.cmake @@ -0,0 +1,26 @@ +#checks that the given hard-coded list contains all headers + sources in the given folder +function(CheckFileList LIST_VAR FOLDER) + set(MESSAGE " should be added to the variable ${LIST_VAR}") + set(MESSAGE "${MESSAGE} in ${CMAKE_CURRENT_LIST_FILE}\n") + file(GLOB GLOBBED_LIST "${FOLDER}/*.cpp" + "${FOLDER}/*.hpp" + "${FOLDER}/*.h") + list(REMOVE_ITEM GLOBBED_LIST ${${LIST_VAR}}) + foreach(EXTRA_ITEM ${GLOBBED_LIST}) + string(REPLACE "${CATCH_DIR}/" "" RELATIVE_FILE_NAME "${EXTRA_ITEM}") + message(AUTHOR_WARNING "The file \"${RELATIVE_FILE_NAME}\"${MESSAGE}") + endforeach() +endfunction() + +function(CheckFileListRec LIST_VAR FOLDER) + set(MESSAGE " should be added to the variable ${LIST_VAR}") + set(MESSAGE "${MESSAGE} in ${CMAKE_CURRENT_LIST_FILE}\n") + file(GLOB_RECURSE GLOBBED_LIST "${FOLDER}/*.cpp" + "${FOLDER}/*.hpp" + "${FOLDER}/*.h") + list(REMOVE_ITEM GLOBBED_LIST ${${LIST_VAR}}) + foreach(EXTRA_ITEM ${GLOBBED_LIST}) + string(REPLACE "${CATCH_DIR}/" "" RELATIVE_FILE_NAME "${EXTRA_ITEM}") + message(AUTHOR_WARNING "The file \"${RELATIVE_FILE_NAME}\"${MESSAGE}") + endforeach() +endfunction() diff --git a/lib/Catch2/CMake/catch2.pc.in b/lib/Catch2/CMake/catch2.pc.in new file mode 100644 index 0000000000..3ac9fbd1a6 --- /dev/null +++ b/lib/Catch2/CMake/catch2.pc.in @@ -0,0 +1,7 @@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: Catch2 +Description: A modern, C++-native, header-only, test framework for C++11 +URL: https://github.com/catchorg/Catch2 +Version: @Catch2_VERSION@ +Cflags: -I${includedir} diff --git a/lib/Catch2/CMake/llvm-cov-wrapper b/lib/Catch2/CMake/llvm-cov-wrapper new file mode 100755 index 0000000000..2ac3310248 --- /dev/null +++ b/lib/Catch2/CMake/llvm-cov-wrapper @@ -0,0 +1,56 @@ +#!/bin/sh + +# This file is part of CMake-codecov. +# +# Copyright (c) +# 2015-2017 RWTH Aachen University, Federal Republic of Germany +# +# See the LICENSE file in the package base directory for details +# +# Written by Alexander Haase, alexander.haase@rwth-aachen.de +# + +if [ -z "$LLVM_COV_BIN" ] +then + echo "LLVM_COV_BIN not set!" >& 2 + exit 1 +fi + + +# Get LLVM version to find out. +LLVM_VERSION=$($LLVM_COV_BIN -version | grep -i "LLVM version" \ + | sed "s/^\([A-Za-z ]*\)\([0-9]\).\([0-9]\).*$/\2.\3/g") + +if [ "$1" = "-v" ] +then + echo "llvm-cov-wrapper $LLVM_VERSION" + exit 0 +fi + + +if [ -n "$LLVM_VERSION" ] +then + MAJOR=$(echo $LLVM_VERSION | cut -d'.' -f1) + MINOR=$(echo $LLVM_VERSION | cut -d'.' -f2) + + if [ $MAJOR -eq 3 ] && [ $MINOR -le 4 ] + then + if [ -f "$1" ] + then + filename=$(basename "$1") + extension="${filename##*.}" + + case "$extension" in + "gcno") exec $LLVM_COV_BIN --gcno="$1" ;; + "gcda") exec $LLVM_COV_BIN --gcda="$1" ;; + esac + fi + fi + + if [ $MAJOR -eq 3 ] && [ $MINOR -le 5 ] + then + exec $LLVM_COV_BIN $@ + fi +fi + +exec $LLVM_COV_BIN gcov $@ diff --git a/lib/Catch2/CMakeLists.txt b/lib/Catch2/CMakeLists.txt new file mode 100644 index 0000000000..0370ea3cbc --- /dev/null +++ b/lib/Catch2/CMakeLists.txt @@ -0,0 +1,255 @@ +cmake_minimum_required(VERSION 3.5) + +# detect if Catch is being bundled, +# disable testsuite in that case +if(NOT DEFINED PROJECT_NAME) + set(NOT_SUBPROJECT ON) +else() + set(NOT_SUBPROJECT OFF) +endif() + +# Catch2's build breaks if done in-tree. You probably should not build +# things in tree anyway, but we can allow projects that include Catch2 +# as a subproject to build in-tree as long as it is not in our tree. +if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + message(FATAL_ERROR "Building in-source is not supported! Create a build dir and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt") +endif() + + +project(Catch2 LANGUAGES CXX VERSION 2.13.6) + +# Provide path for scripts +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake") + +include(GNUInstallDirs) + +option(CATCH_USE_VALGRIND "Perform SelfTests with Valgrind" OFF) +option(CATCH_BUILD_TESTING "Build SelfTest project" ON) +option(CATCH_BUILD_EXAMPLES "Build documentation examples" OFF) +option(CATCH_BUILD_EXTRA_TESTS "Build extra tests" OFF) +option(CATCH_BUILD_STATIC_LIBRARY "Builds static library from the main implementation. EXPERIMENTAL" OFF) +option(CATCH_ENABLE_COVERAGE "Generate coverage for codecov.io" OFF) +option(CATCH_ENABLE_WERROR "Enable all warnings as errors" ON) +option(CATCH_INSTALL_DOCS "Install documentation alongside library" ON) +option(CATCH_INSTALL_HELPERS "Install contrib alongside library" ON) + +# define some folders +set(CATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(SELF_TEST_DIR ${CATCH_DIR}/projects/SelfTest) +set(BENCHMARK_DIR ${CATCH_DIR}/projects/Benchmark) +set(HEADER_DIR ${CATCH_DIR}/include) + +if(USE_WMAIN) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:wmainCRTStartup") +endif() + +if(NOT_SUBPROJECT) + include(CTest) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) + if(BUILD_TESTING AND CATCH_BUILD_TESTING) + find_package(PythonInterp) + if (NOT PYTHONINTERP_FOUND) + message(FATAL_ERROR "Python not found, but required for tests") + endif() + add_subdirectory(projects) + endif() +endif() + +if(CATCH_BUILD_EXAMPLES) + add_subdirectory(examples) +endif() + +if(CATCH_BUILD_EXTRA_TESTS) + add_subdirectory(projects/ExtraTests) +endif() + +# add catch as a 'linkable' target +add_library(Catch2 INTERFACE) + + + +# depend on some obvious c++11 features so the dependency is transitively added dependents +target_compile_features(Catch2 + INTERFACE + cxx_alignas + cxx_alignof + cxx_attributes + cxx_auto_type + cxx_constexpr + cxx_defaulted_functions + cxx_deleted_functions + cxx_final + cxx_lambdas + cxx_noexcept + cxx_override + cxx_range_for + cxx_rvalue_references + cxx_static_assert + cxx_strong_enums + cxx_trailing_return_types + cxx_unicode_literals + cxx_user_literals + cxx_variadic_macros +) + +target_include_directories(Catch2 + INTERFACE + $ + $ +) + +if (ANDROID) + target_link_libraries(Catch2 INTERFACE log) +endif() + +# provide a namespaced alias for clients to 'link' against if catch is included as a sub-project +add_library(Catch2::Catch2 ALIAS Catch2) + +# Hacky support for compiling the impl into a static lib +if (CATCH_BUILD_STATIC_LIBRARY) + add_library(Catch2WithMain ${CMAKE_CURRENT_LIST_DIR}/src/catch_with_main.cpp) + target_link_libraries(Catch2WithMain PUBLIC Catch2) + add_library(Catch2::Catch2WithMain ALIAS Catch2WithMain) + + # Make the build reproducible on versions of g++ and clang that supports -ffile-prefix-map + if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 8) OR + ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 10)) + target_compile_options(Catch2WithMain PRIVATE "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.") + endif() +endif(CATCH_BUILD_STATIC_LIBRARY) + +# Only perform the installation steps when Catch is not being used as +# a subproject via `add_subdirectory`, or the destinations will break, +# see https://github.com/catchorg/Catch2/issues/1373 +if (NOT_SUBPROJECT) + include(CMakePackageConfigHelpers) + set(CATCH_CMAKE_CONFIG_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Catch2") + + configure_package_config_file( + ${CMAKE_CURRENT_LIST_DIR}/CMake/Catch2Config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake + INSTALL_DESTINATION + ${CATCH_CMAKE_CONFIG_DESTINATION} + ) + + # Workaround lack of generator expressions in install(TARGETS + set(InstallationTargets Catch2) + if (TARGET Catch2WithMain) + list(APPEND InstallationTargets Catch2WithMain) + endif() + + + # create and install an export set for catch target as Catch2::Catch + install( + TARGETS + ${InstallationTargets} + EXPORT + Catch2Targets + DESTINATION + ${CMAKE_INSTALL_LIBDIR} + ) + + + install( + EXPORT + Catch2Targets + NAMESPACE + Catch2:: + DESTINATION + ${CATCH_CMAKE_CONFIG_DESTINATION} + ) + + # By default, FooConfigVersion is tied to architecture that it was + # generated on. Because Catch2 is header-only, it is arch-independent + # and thus Catch2ConfigVersion should not be tied to the architecture + # it was generated on. + # + # CMake does not provide a direct customization point for this in + # `write_basic_package_version_file`, but it can be accomplished + # indirectly by temporarily redefining `CMAKE_SIZEOF_VOID_P` to an + # empty string. Note that just undefining the variable could be + # insufficient in cases where the variable was already in CMake cache + set(CATCH2_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) + set(CMAKE_SIZEOF_VOID_P "") + write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/Catch2ConfigVersion.cmake" + COMPATIBILITY + SameMajorVersion + ) + set(CMAKE_SIZEOF_VOID_P ${CATCH2_CMAKE_SIZEOF_VOID_P}) + + install( + DIRECTORY + "single_include/" + DESTINATION + "${CMAKE_INSTALL_INCLUDEDIR}" + ) + + install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/Catch2ConfigVersion.cmake" + DESTINATION + ${CATCH_CMAKE_CONFIG_DESTINATION} + ) + + # Install documentation + if(CATCH_INSTALL_DOCS) + install( + DIRECTORY + docs/ + DESTINATION + "${CMAKE_INSTALL_DOCDIR}" + ) + endif() + + if(CATCH_INSTALL_HELPERS) + # Install CMake scripts + install( + FILES + "contrib/ParseAndAddCatchTests.cmake" + "contrib/Catch.cmake" + "contrib/CatchAddTests.cmake" + DESTINATION + ${CATCH_CMAKE_CONFIG_DESTINATION} + ) + + # Install debugger helpers + install( + FILES + "contrib/gdbinit" + "contrib/lldbinit" + DESTINATION + ${CMAKE_INSTALL_DATAROOTDIR}/Catch2 + ) + endif() + + ## Provide some pkg-config integration + set(PKGCONFIG_INSTALL_DIR + "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig" + CACHE PATH "Path where catch2.pc is installed" + ) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/CMake/catch2.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/catch2.pc + @ONLY + ) + install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/catch2.pc" + DESTINATION + ${PKGCONFIG_INSTALL_DIR} + ) + + # CPack/CMake started taking the package version from project version 3.12 + # So we need to set the version manually for older CMake versions + if(${CMAKE_VERSION} VERSION_LESS "3.12.0") + set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) + endif() + + set(CPACK_PACKAGE_CONTACT "https://github.com/catchorg/Catch2/") + + + include( CPack ) + +endif(NOT_SUBPROJECT) diff --git a/lib/Catch2/CODE_OF_CONDUCT.md b/lib/Catch2/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000..be1a688e01 --- /dev/null +++ b/lib/Catch2/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at github@philnash.me. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/lib/Catch2/LICENSE.txt b/lib/Catch2/LICENSE.txt new file mode 100644 index 0000000000..36b7cd93cd --- /dev/null +++ b/lib/Catch2/LICENSE.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/lib/Catch2/README.md b/lib/Catch2/README.md new file mode 100644 index 0000000000..6d4776da6f --- /dev/null +++ b/lib/Catch2/README.md @@ -0,0 +1,37 @@ + +![catch logo](artwork/catch2-logo-small.png) + +[![Github Releases](https://img.shields.io/github/release/catchorg/catch2.svg)](https://github.com/catchorg/catch2/releases) +[![Build Status](https://travis-ci.org/catchorg/Catch2.svg?branch=v2.x)](https://travis-ci.org/catchorg/Catch2) +[![Build status](https://ci.appveyor.com/api/projects/status/github/catchorg/Catch2?svg=true)](https://ci.appveyor.com/project/catchorg/catch2) +[![codecov](https://codecov.io/gh/catchorg/Catch2/branch/v2.x/graph/badge.svg)](https://codecov.io/gh/catchorg/Catch2) +[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/6JUH8Eybx4CtvkJS) +[![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD) + + +The latest version of the single header can be downloaded directly using this link + +## Catch2 is released! + +If you've been using an earlier version of Catch, please see the +Breaking Changes section of [the release notes](https://github.com/catchorg/Catch2/releases/tag/v2.0.1) +before moving to Catch2. You might also like to read [this blog post](https://levelofindirection.com/blog/catch2-released.html) for more details. + +## What's the Catch? + +Catch2 is a multi-paradigm test framework for C++. which also supports +Objective-C (and maybe C). +It is primarily distributed as a single header file, although certain +extensions may require additional headers. + +## How to use it +This documentation comprises these three parts: + +* [Why do we need yet another C++ Test Framework?](docs/why-catch.md#top) +* [Tutorial](docs/tutorial.md#top) - getting started +* [Reference section](docs/Readme.md#top) - all the details + +## More +* Issues and bugs can be raised on the [Issue tracker on GitHub](https://github.com/catchorg/Catch2/issues) +* For discussion or questions please use [the dedicated Google Groups forum](https://groups.google.com/forum/?fromgroups#!forum/catch-forum) or our [Discord](https://discord.gg/4CWS9zD) +* See [who else is using Catch2](docs/opensource-users.md#top) diff --git a/lib/Catch2/WORKSPACE b/lib/Catch2/WORKSPACE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/Catch2/appveyor.yml b/lib/Catch2/appveyor.yml new file mode 100644 index 0000000000..dfd443163a --- /dev/null +++ b/lib/Catch2/appveyor.yml @@ -0,0 +1,101 @@ +# version string format -- This will be overwritten later anyway +version: "{build}" + +# We need a more up to date pip because Python 2.7 is EOL soon +init: + - set PATH=C:\Python35\Scripts;%PATH% + + +branches: + except: + - /dev-travis.+/ + +os: + - Visual Studio 2017 + - Visual Studio 2015 + +environment: + matrix: + - additional_flags: "/permissive- /std:c++latest" + wmain: 0 + + - additional_flags: "" + wmain: 0 + + - additional_flags: "/D_UNICODE /DUNICODE" + wmain: 1 + coverage: 0 + + # Have a coverage dimension + - additional_flags: "" + wmain: 0 + coverage: 1 + + # Have an examples dimension + - additional_flags: "" + wmain: 0 + examples: 1 + + +matrix: + exclude: + - os: Visual Studio 2015 + additional_flags: "/permissive- /std:c++latest" + + - os: Visual Studio 2015 + additional_flags: "/D_UNICODE /DUNICODE" + + # Exclude unwanted coverage configurations + - coverage: 1 + platform: Win32 + + - coverage: 1 + os: Visual Studio 2015 + + - coverage: 1 + configuration: Release + + # Exclude unwanted examples configurations + - examples: 1 + platform: Win32 + + - examples: 1 + os: Visual Studio 2015 + + - examples: 1 + configuration: Release + + +install: + - ps: if (($env:CONFIGURATION) -eq "Debug" -And ($env:coverage) -eq "1" ) { pip --disable-pip-version-check install codecov } + - ps: if (($env:CONFIGURATION) -eq "Debug" -And ($env:coverage) -eq "1" ) { .\misc\installOpenCppCoverage.ps1 } + +# Win32 and x64 are CMake-compatible solution platform names. +# This allows us to pass %PLATFORM% to CMake -A. +platform: + - Win32 + - x64 + +# build Configurations, i.e. Debug, Release, etc. +configuration: + - Debug + - Release + +#Cmake will autodetect the compiler, but we set the arch +before_build: + - set CXXFLAGS=%additional_flags% + # Indirection because appveyor doesn't handle multiline batch scripts properly + # https://stackoverflow.com/questions/37627248/how-to-split-a-command-over-multiple-lines-in-appveyor-yml/37647169#37647169 + # https://help.appveyor.com/discussions/questions/3888-multi-line-cmd-or-powershell-warning-ignore + - cmd: .\misc\appveyorBuildConfigurationScript.bat + + +# build with MSBuild +build: + project: Build\Catch2.sln # path to Visual Studio solution or project + parallel: true # enable MSBuild parallel builds + verbosity: normal # MSBuild verbosity level {quiet|minimal|normal|detailed} + +test_script: + - set CTEST_OUTPUT_ON_FAILURE=1 + - cmd: .\misc\appveyorTestRunScript.bat diff --git a/lib/Catch2/artwork/catch2-c-logo.png b/lib/Catch2/artwork/catch2-c-logo.png new file mode 100644 index 0000000000..b1066b8ee7 Binary files /dev/null and b/lib/Catch2/artwork/catch2-c-logo.png differ diff --git a/lib/Catch2/artwork/catch2-hand-logo.png b/lib/Catch2/artwork/catch2-hand-logo.png new file mode 100644 index 0000000000..ab857eaab7 Binary files /dev/null and b/lib/Catch2/artwork/catch2-hand-logo.png differ diff --git a/lib/Catch2/artwork/catch2-logo-small.png b/lib/Catch2/artwork/catch2-logo-small.png new file mode 100644 index 0000000000..742e81e15c Binary files /dev/null and b/lib/Catch2/artwork/catch2-logo-small.png differ diff --git a/lib/Catch2/codecov.yml b/lib/Catch2/codecov.yml new file mode 100644 index 0000000000..d26329af1b --- /dev/null +++ b/lib/Catch2/codecov.yml @@ -0,0 +1,25 @@ +coverage: + precision: 2 + round: nearest + range: "60...90" + status: + project: + default: + threshold: 2% + patch: + default: + target: 80% + ignore: + - "projects/SelfTest" + - "**/catch_reporter_tap.hpp" + - "**/catch_reporter_automake.hpp" + - "**/catch_reporter_teamcity.hpp" + - "**/catch_reporter_sonarqube.hpp" + - "**/external/clara.hpp" + + +codecov: + branch: v2.x + +comment: + layout: "diff" diff --git a/lib/Catch2/conanfile.py b/lib/Catch2/conanfile.py new file mode 100644 index 0000000000..75a07b8cb2 --- /dev/null +++ b/lib/Catch2/conanfile.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +from conans import ConanFile, CMake + + +class CatchConan(ConanFile): + name = "Catch2" + description = "A modern, C++-native, header-only, framework for unit-tests, TDD and BDD" + topics = ("conan", "catch2", "header-only", "unit-test", "tdd", "bdd") + url = "https://github.com/catchorg/Catch2" + homepage = url + license = "BSL-1.0" + exports = "LICENSE.txt" + exports_sources = ("single_include/*", "CMakeLists.txt", "CMake/*", "contrib/*", "src/*") + generators = "cmake" + + def package(self): + cmake = CMake(self) + cmake.definitions["BUILD_TESTING"] = "OFF" + cmake.definitions["CATCH_INSTALL_DOCS"] = "OFF" + cmake.definitions["CATCH_INSTALL_HELPERS"] = "ON" + cmake.configure(build_folder='build') + cmake.install() + + self.copy(pattern="LICENSE.txt", dst="licenses") + + def package_id(self): + self.info.header_only() + + def package_info(self): + self.cpp_info.builddirs.append("lib/cmake/Catch2") diff --git a/lib/Catch2/contrib/Catch.cmake b/lib/Catch2/contrib/Catch.cmake new file mode 100644 index 0000000000..a388516203 --- /dev/null +++ b/lib/Catch2/contrib/Catch.cmake @@ -0,0 +1,206 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +Catch +----- + +This module defines a function to help use the Catch test framework. + +The :command:`catch_discover_tests` discovers tests by asking the compiled test +executable to enumerate its tests. This does not require CMake to be re-run +when tests change. However, it may not work in a cross-compiling environment, +and setting test properties is less convenient. + +This command is intended to replace use of :command:`add_test` to register +tests, and will create a separate CTest test for each Catch test case. Note +that this is in some cases less efficient, as common set-up and tear-down logic +cannot be shared by multiple test cases executing in the same instance. +However, it provides more fine-grained pass/fail information to CTest, which is +usually considered as more beneficial. By default, the CTest test name is the +same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``. + +.. command:: catch_discover_tests + + Automatically add tests with CTest by querying the compiled test executable + for available tests:: + + catch_discover_tests(target + [TEST_SPEC arg1...] + [EXTRA_ARGS arg1...] + [WORKING_DIRECTORY dir] + [TEST_PREFIX prefix] + [TEST_SUFFIX suffix] + [PROPERTIES name1 value1...] + [TEST_LIST var] + [REPORTER reporter] + [OUTPUT_DIR dir] + [OUTPUT_PREFIX prefix} + [OUTPUT_SUFFIX suffix] + ) + + ``catch_discover_tests`` sets up a post-build command on the test executable + that generates the list of tests by parsing the output from running the test + with the ``--list-test-names-only`` argument. This ensures that the full + list of tests is obtained. Since test discovery occurs at build time, it is + not necessary to re-run CMake when the list of tests changes. + However, it requires that :prop_tgt:`CROSSCOMPILING_EMULATOR` is properly set + in order to function in a cross-compiling environment. + + Additionally, setting properties on tests is somewhat less convenient, since + the tests are not available at CMake time. Additional test properties may be + assigned to the set of tests as a whole using the ``PROPERTIES`` option. If + more fine-grained test control is needed, custom content may be provided + through an external CTest script using the :prop_dir:`TEST_INCLUDE_FILES` + directory property. The set of discovered tests is made accessible to such a + script via the ``_TESTS`` variable. + + The options are: + + ``target`` + Specifies the Catch executable, which must be a known CMake executable + target. CMake will substitute the location of the built executable when + running the test. + + ``TEST_SPEC arg1...`` + Specifies test cases, wildcarded test cases, tags and tag expressions to + pass to the Catch executable with the ``--list-test-names-only`` argument. + + ``EXTRA_ARGS arg1...`` + Any extra arguments to pass on the command line to each test case. + + ``WORKING_DIRECTORY dir`` + Specifies the directory in which to run the discovered test cases. If this + option is not provided, the current binary directory is used. + + ``TEST_PREFIX prefix`` + Specifies a ``prefix`` to be prepended to the name of each discovered test + case. This can be useful when the same test executable is being used in + multiple calls to ``catch_discover_tests()`` but with different + ``TEST_SPEC`` or ``EXTRA_ARGS``. + + ``TEST_SUFFIX suffix`` + Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of + every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may + be specified. + + ``PROPERTIES name1 value1...`` + Specifies additional properties to be set on all tests discovered by this + invocation of ``catch_discover_tests``. + + ``TEST_LIST var`` + Make the list of tests available in the variable ``var``, rather than the + default ``_TESTS``. This can be useful when the same test + executable is being used in multiple calls to ``catch_discover_tests()``. + Note that this variable is only available in CTest. + + ``REPORTER reporter`` + Use the specified reporter when running the test case. The reporter will + be passed to the Catch executable as ``--reporter reporter``. + + ``OUTPUT_DIR dir`` + If specified, the parameter is passed along as + ``--out dir/`` to Catch executable. The actual file name is the + same as the test name. This should be used instead of + ``EXTRA_ARGS --out foo`` to avoid race conditions writing the result output + when using parallel test execution. + + ``OUTPUT_PREFIX prefix`` + May be used in conjunction with ``OUTPUT_DIR``. + If specified, ``prefix`` is added to each output file name, like so + ``--out dir/prefix``. + + ``OUTPUT_SUFFIX suffix`` + May be used in conjunction with ``OUTPUT_DIR``. + If specified, ``suffix`` is added to each output file name, like so + ``--out dir/suffix``. This can be used to add a file extension to + the output e.g. ".xml". + +#]=======================================================================] + +#------------------------------------------------------------------------------ +function(catch_discover_tests TARGET) + cmake_parse_arguments( + "" + "" + "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;REPORTER;OUTPUT_DIR;OUTPUT_PREFIX;OUTPUT_SUFFIX" + "TEST_SPEC;EXTRA_ARGS;PROPERTIES" + ${ARGN} + ) + + if(NOT _WORKING_DIRECTORY) + set(_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endif() + if(NOT _TEST_LIST) + set(_TEST_LIST ${TARGET}_TESTS) + endif() + + ## Generate a unique name based on the extra arguments + string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS} ${_REPORTER} ${_OUTPUT_DIR} ${_OUTPUT_PREFIX} ${_OUTPUT_SUFFIX}") + string(SUBSTRING ${args_hash} 0 7 args_hash) + + # Define rule to generate test list for aforementioned test executable + set(ctest_include_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_include-${args_hash}.cmake") + set(ctest_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_tests-${args_hash}.cmake") + get_property(crosscompiling_emulator + TARGET ${TARGET} + PROPERTY CROSSCOMPILING_EMULATOR + ) + add_custom_command( + TARGET ${TARGET} POST_BUILD + BYPRODUCTS "${ctest_tests_file}" + COMMAND "${CMAKE_COMMAND}" + -D "TEST_TARGET=${TARGET}" + -D "TEST_EXECUTABLE=$" + -D "TEST_EXECUTOR=${crosscompiling_emulator}" + -D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}" + -D "TEST_SPEC=${_TEST_SPEC}" + -D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}" + -D "TEST_PROPERTIES=${_PROPERTIES}" + -D "TEST_PREFIX=${_TEST_PREFIX}" + -D "TEST_SUFFIX=${_TEST_SUFFIX}" + -D "TEST_LIST=${_TEST_LIST}" + -D "TEST_REPORTER=${_REPORTER}" + -D "TEST_OUTPUT_DIR=${_OUTPUT_DIR}" + -D "TEST_OUTPUT_PREFIX=${_OUTPUT_PREFIX}" + -D "TEST_OUTPUT_SUFFIX=${_OUTPUT_SUFFIX}" + -D "CTEST_FILE=${ctest_tests_file}" + -P "${_CATCH_DISCOVER_TESTS_SCRIPT}" + VERBATIM + ) + + file(WRITE "${ctest_include_file}" + "if(EXISTS \"${ctest_tests_file}\")\n" + " include(\"${ctest_tests_file}\")\n" + "else()\n" + " add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n" + "endif()\n" + ) + + if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") + # Add discovered tests to directory TEST_INCLUDE_FILES + set_property(DIRECTORY + APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}" + ) + else() + # Add discovered tests as directory TEST_INCLUDE_FILE if possible + get_property(test_include_file_set DIRECTORY PROPERTY TEST_INCLUDE_FILE SET) + if (NOT ${test_include_file_set}) + set_property(DIRECTORY + PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}" + ) + else() + message(FATAL_ERROR + "Cannot set more than one TEST_INCLUDE_FILE" + ) + endif() + endif() + +endfunction() + +############################################################################### + +set(_CATCH_DISCOVER_TESTS_SCRIPT + ${CMAKE_CURRENT_LIST_DIR}/CatchAddTests.cmake + CACHE INTERNAL "Catch2 full path to CatchAddTests.cmake helper file" +) diff --git a/lib/Catch2/contrib/CatchAddTests.cmake b/lib/Catch2/contrib/CatchAddTests.cmake new file mode 100644 index 0000000000..184e506e5d --- /dev/null +++ b/lib/Catch2/contrib/CatchAddTests.cmake @@ -0,0 +1,135 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +set(prefix "${TEST_PREFIX}") +set(suffix "${TEST_SUFFIX}") +set(spec ${TEST_SPEC}) +set(extra_args ${TEST_EXTRA_ARGS}) +set(properties ${TEST_PROPERTIES}) +set(reporter ${TEST_REPORTER}) +set(output_dir ${TEST_OUTPUT_DIR}) +set(output_prefix ${TEST_OUTPUT_PREFIX}) +set(output_suffix ${TEST_OUTPUT_SUFFIX}) +set(script) +set(suite) +set(tests) + +function(add_command NAME) + set(_args "") + # use ARGV* instead of ARGN, because ARGN splits arrays into multiple arguments + math(EXPR _last_arg ${ARGC}-1) + foreach(_n RANGE 1 ${_last_arg}) + set(_arg "${ARGV${_n}}") + if(_arg MATCHES "[^-./:a-zA-Z0-9_]") + set(_args "${_args} [==[${_arg}]==]") # form a bracket_argument + else() + set(_args "${_args} ${_arg}") + endif() + endforeach() + set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE) +endfunction() + +# Run test executable to get list of available tests +if(NOT EXISTS "${TEST_EXECUTABLE}") + message(FATAL_ERROR + "Specified test executable '${TEST_EXECUTABLE}' does not exist" + ) +endif() +execute_process( + COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-test-names-only + OUTPUT_VARIABLE output + RESULT_VARIABLE result + WORKING_DIRECTORY "${TEST_WORKING_DIR}" +) +# Catch --list-test-names-only reports the number of tests, so 0 is... surprising +if(${result} EQUAL 0) + message(WARNING + "Test executable '${TEST_EXECUTABLE}' contains no tests!\n" + ) +elseif(${result} LESS 0) + message(FATAL_ERROR + "Error running test executable '${TEST_EXECUTABLE}':\n" + " Result: ${result}\n" + " Output: ${output}\n" + ) +endif() + +string(REPLACE "\n" ";" output "${output}") + +# Run test executable to get list of available reporters +execute_process( + COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-reporters + OUTPUT_VARIABLE reporters_output + RESULT_VARIABLE reporters_result + WORKING_DIRECTORY "${TEST_WORKING_DIR}" +) +if(${reporters_result} EQUAL 0) + message(WARNING + "Test executable '${TEST_EXECUTABLE}' contains no reporters!\n" + ) +elseif(${reporters_result} LESS 0) + message(FATAL_ERROR + "Error running test executable '${TEST_EXECUTABLE}':\n" + " Result: ${reporters_result}\n" + " Output: ${reporters_output}\n" + ) +endif() +string(FIND "${reporters_output}" "${reporter}" reporter_is_valid) +if(reporter AND ${reporter_is_valid} EQUAL -1) + message(FATAL_ERROR + "\"${reporter}\" is not a valid reporter!\n" + ) +endif() + +# Prepare reporter +if(reporter) + set(reporter_arg "--reporter ${reporter}") +endif() + +# Prepare output dir +if(output_dir AND NOT IS_ABSOLUTE ${output_dir}) + set(output_dir "${TEST_WORKING_DIR}/${output_dir}") + if(NOT EXISTS ${output_dir}) + file(MAKE_DIRECTORY ${output_dir}) + endif() +endif() + +# Parse output +foreach(line ${output}) + set(test ${line}) + # Escape characters in test case names that would be parsed by Catch2 + set(test_name ${test}) + foreach(char , [ ]) + string(REPLACE ${char} "\\${char}" test_name ${test_name}) + endforeach(char) + # ...add output dir + if(output_dir) + string(REGEX REPLACE "[^A-Za-z0-9_]" "_" test_name_clean ${test_name}) + set(output_dir_arg "--out ${output_dir}/${output_prefix}${test_name_clean}${output_suffix}") + endif() + + # ...and add to script + add_command(add_test + "${prefix}${test}${suffix}" + ${TEST_EXECUTOR} + "${TEST_EXECUTABLE}" + "${test_name}" + ${extra_args} + "${reporter_arg}" + "${output_dir_arg}" + ) + add_command(set_tests_properties + "${prefix}${test}${suffix}" + PROPERTIES + WORKING_DIRECTORY "${TEST_WORKING_DIR}" + ${properties} + ) + list(APPEND tests "${prefix}${test}${suffix}") +endforeach() + +# Create a list of all discovered tests, which users may use to e.g. set +# properties on the tests +add_command(set ${TEST_LIST} ${tests}) + +# Write CTest script +file(WRITE "${CTEST_FILE}" "${script}") diff --git a/lib/Catch2/contrib/ParseAndAddCatchTests.cmake b/lib/Catch2/contrib/ParseAndAddCatchTests.cmake new file mode 100644 index 0000000000..4771e02996 --- /dev/null +++ b/lib/Catch2/contrib/ParseAndAddCatchTests.cmake @@ -0,0 +1,252 @@ +#==================================================================================================# +# supported macros # +# - TEST_CASE, # +# - TEMPLATE_TEST_CASE # +# - SCENARIO, # +# - TEST_CASE_METHOD, # +# - CATCH_TEST_CASE, # +# - CATCH_TEMPLATE_TEST_CASE # +# - CATCH_SCENARIO, # +# - CATCH_TEST_CASE_METHOD. # +# # +# Usage # +# 1. make sure this module is in the path or add this otherwise: # +# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake.modules/") # +# 2. make sure that you've enabled testing option for the project by the call: # +# enable_testing() # +# 3. add the lines to the script for testing target (sample CMakeLists.txt): # +# project(testing_target) # +# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake.modules/") # +# enable_testing() # +# # +# find_path(CATCH_INCLUDE_DIR "catch.hpp") # +# include_directories(${INCLUDE_DIRECTORIES} ${CATCH_INCLUDE_DIR}) # +# # +# file(GLOB SOURCE_FILES "*.cpp") # +# add_executable(${PROJECT_NAME} ${SOURCE_FILES}) # +# # +# include(ParseAndAddCatchTests) # +# ParseAndAddCatchTests(${PROJECT_NAME}) # +# # +# The following variables affect the behavior of the script: # +# # +# PARSE_CATCH_TESTS_VERBOSE (Default OFF) # +# -- enables debug messages # +# PARSE_CATCH_TESTS_NO_HIDDEN_TESTS (Default OFF) # +# -- excludes tests marked with [!hide], [.] or [.foo] tags # +# PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME (Default ON) # +# -- adds fixture class name to the test name # +# PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME (Default ON) # +# -- adds cmake target name to the test name # +# PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS (Default OFF) # +# -- causes CMake to rerun when file with tests changes so that new tests will be discovered # +# # +# One can also set (locally) the optional variable OptionalCatchTestLauncher to precise the way # +# a test should be run. For instance to use test MPI, one can write # +# set(OptionalCatchTestLauncher ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${NUMPROC}) # +# just before calling this ParseAndAddCatchTests function # +# # +# The AdditionalCatchParameters optional variable can be used to pass extra argument to the test # +# command. For example, to include successful tests in the output, one can write # +# set(AdditionalCatchParameters --success) # +# # +# After the script, the ParseAndAddCatchTests_TESTS property for the target, and for each source # +# file in the target is set, and contains the list of the tests extracted from that target, or # +# from that file. This is useful, for example to add further labels or properties to the tests. # +# # +#==================================================================================================# + +if (CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.8) + message(FATAL_ERROR "ParseAndAddCatchTests requires CMake 2.8.8 or newer") +endif() + +option(PARSE_CATCH_TESTS_VERBOSE "Print Catch to CTest parser debug messages" OFF) +option(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS "Exclude tests with [!hide], [.] or [.foo] tags" OFF) +option(PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME "Add fixture class name to the test name" ON) +option(PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME "Add target name to the test name" ON) +option(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS "Add test file to CMAKE_CONFIGURE_DEPENDS property" OFF) + +function(ParseAndAddCatchTests_PrintDebugMessage) + if(PARSE_CATCH_TESTS_VERBOSE) + message(STATUS "ParseAndAddCatchTests: ${ARGV}") + endif() +endfunction() + +# This removes the contents between +# - block comments (i.e. /* ... */) +# - full line comments (i.e. // ... ) +# contents have been read into '${CppCode}'. +# !keep partial line comments +function(ParseAndAddCatchTests_RemoveComments CppCode) + string(ASCII 2 CMakeBeginBlockComment) + string(ASCII 3 CMakeEndBlockComment) + string(REGEX REPLACE "/\\*" "${CMakeBeginBlockComment}" ${CppCode} "${${CppCode}}") + string(REGEX REPLACE "\\*/" "${CMakeEndBlockComment}" ${CppCode} "${${CppCode}}") + string(REGEX REPLACE "${CMakeBeginBlockComment}[^${CMakeEndBlockComment}]*${CMakeEndBlockComment}" "" ${CppCode} "${${CppCode}}") + string(REGEX REPLACE "\n[ \t]*//+[^\n]+" "\n" ${CppCode} "${${CppCode}}") + + set(${CppCode} "${${CppCode}}" PARENT_SCOPE) +endfunction() + +# Worker function +function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget) + # If SourceFile is an object library, do not scan it (as it is not a file). Exit without giving a warning about a missing file. + if(SourceFile MATCHES "\\\$") + ParseAndAddCatchTests_PrintDebugMessage("Detected OBJECT library: ${SourceFile} this will not be scanned for tests.") + return() + endif() + # According to CMake docs EXISTS behavior is well-defined only for full paths. + get_filename_component(SourceFile ${SourceFile} ABSOLUTE) + if(NOT EXISTS ${SourceFile}) + message(WARNING "Cannot find source file: ${SourceFile}") + return() + endif() + ParseAndAddCatchTests_PrintDebugMessage("parsing ${SourceFile}") + file(STRINGS ${SourceFile} Contents NEWLINE_CONSUME) + + # Remove block and fullline comments + ParseAndAddCatchTests_RemoveComments(Contents) + + # Find definition of test names + # https://regex101.com/r/JygOND/1 + string(REGEX MATCHALL "[ \t]*(CATCH_)?(TEMPLATE_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([ \t\n]*\"[^\"]*\"[ \t\n]*(,[ \t\n]*\"[^\"]*\")?(,[ \t\n]*[^\,\)]*)*\\)[ \t\n]*\{+[ \t]*(//[^\n]*[Tt][Ii][Mm][Ee][Oo][Uu][Tt][ \t]*[0-9]+)*" Tests "${Contents}") + + if(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS AND Tests) + ParseAndAddCatchTests_PrintDebugMessage("Adding ${SourceFile} to CMAKE_CONFIGURE_DEPENDS property") + set_property( + DIRECTORY + APPEND + PROPERTY CMAKE_CONFIGURE_DEPENDS ${SourceFile} + ) + endif() + + # check CMP0110 policy for new add_test() behavior + if(POLICY CMP0110) + cmake_policy(GET CMP0110 _cmp0110_value) # new add_test() behavior + else() + # just to be thorough explicitly set the variable + set(_cmp0110_value) + endif() + + foreach(TestName ${Tests}) + # Strip newlines + string(REGEX REPLACE "\\\\\n|\n" "" TestName "${TestName}") + + # Get test type and fixture if applicable + string(REGEX MATCH "(CATCH_)?(TEMPLATE_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([^,^\"]*" TestTypeAndFixture "${TestName}") + string(REGEX MATCH "(CATCH_)?(TEMPLATE_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)" TestType "${TestTypeAndFixture}") + string(REGEX REPLACE "${TestType}\\([ \t]*" "" TestFixture "${TestTypeAndFixture}") + + # Get string parts of test definition + string(REGEX MATCHALL "\"+([^\\^\"]|\\\\\")+\"+" TestStrings "${TestName}") + + # Strip wrapping quotation marks + string(REGEX REPLACE "^\"(.*)\"$" "\\1" TestStrings "${TestStrings}") + string(REPLACE "\";\"" ";" TestStrings "${TestStrings}") + + # Validate that a test name and tags have been provided + list(LENGTH TestStrings TestStringsLength) + if(TestStringsLength GREATER 2 OR TestStringsLength LESS 1) + message(FATAL_ERROR "You must provide a valid test name and tags for all tests in ${SourceFile}") + endif() + + # Assign name and tags + list(GET TestStrings 0 Name) + if("${TestType}" STREQUAL "SCENARIO") + set(Name "Scenario: ${Name}") + endif() + if(PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME AND "${TestType}" MATCHES "(CATCH_)?TEST_CASE_METHOD" AND TestFixture ) + set(CTestName "${TestFixture}:${Name}") + else() + set(CTestName "${Name}") + endif() + if(PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME) + set(CTestName "${TestTarget}:${CTestName}") + endif() + # add target to labels to enable running all tests added from this target + set(Labels ${TestTarget}) + if(TestStringsLength EQUAL 2) + list(GET TestStrings 1 Tags) + string(TOLOWER "${Tags}" Tags) + # remove target from labels if the test is hidden + if("${Tags}" MATCHES ".*\\[!?(hide|\\.)\\].*") + list(REMOVE_ITEM Labels ${TestTarget}) + endif() + string(REPLACE "]" ";" Tags "${Tags}") + string(REPLACE "[" "" Tags "${Tags}") + else() + # unset tags variable from previous loop + unset(Tags) + endif() + + list(APPEND Labels ${Tags}) + + set(HiddenTagFound OFF) + foreach(label ${Labels}) + string(REGEX MATCH "^!hide|^\\." result ${label}) + if(result) + set(HiddenTagFound ON) + break() + endif(result) + endforeach(label) + if(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS AND ${HiddenTagFound} AND ${CMAKE_VERSION} VERSION_LESS "3.9") + ParseAndAddCatchTests_PrintDebugMessage("Skipping test \"${CTestName}\" as it has [!hide], [.] or [.foo] label") + else() + ParseAndAddCatchTests_PrintDebugMessage("Adding test \"${CTestName}\"") + if(Labels) + ParseAndAddCatchTests_PrintDebugMessage("Setting labels to ${Labels}") + endif() + + # Escape commas in the test spec + string(REPLACE "," "\\," Name ${Name}) + + # Work around CMake 3.18.0 change in `add_test()`, before the escaped quotes were necessary, + # only with CMake 3.18.0 the escaped double quotes confuse the call. This change is reverted in 3.18.1 + # And properly introduced in 3.19 with the CMP0110 policy + if(_cmp0110_value STREQUAL "NEW" OR ${CMAKE_VERSION} VERSION_EQUAL "3.18") + ParseAndAddCatchTests_PrintDebugMessage("CMP0110 set to NEW, no need for add_test(\"\") workaround") + else() + ParseAndAddCatchTests_PrintDebugMessage("CMP0110 set to OLD adding \"\" for add_test() workaround") + set(CTestName "\"${CTestName}\"") + endif() + + # Handle template test cases + if("${TestTypeAndFixture}" MATCHES ".*TEMPLATE_.*") + set(Name "${Name} - *") + endif() + + # Add the test and set its properties + add_test(NAME "${CTestName}" COMMAND ${OptionalCatchTestLauncher} $ ${Name} ${AdditionalCatchParameters}) + # Old CMake versions do not document VERSION_GREATER_EQUAL, so we use VERSION_GREATER with 3.8 instead + if(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS AND ${HiddenTagFound} AND ${CMAKE_VERSION} VERSION_GREATER "3.8") + ParseAndAddCatchTests_PrintDebugMessage("Setting DISABLED test property") + set_tests_properties("${CTestName}" PROPERTIES DISABLED ON) + else() + set_tests_properties("${CTestName}" PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran" + LABELS "${Labels}") + endif() + set_property( + TARGET ${TestTarget} + APPEND + PROPERTY ParseAndAddCatchTests_TESTS "${CTestName}") + set_property( + SOURCE ${SourceFile} + APPEND + PROPERTY ParseAndAddCatchTests_TESTS "${CTestName}") + endif() + + + endforeach() +endfunction() + +# entry point +function(ParseAndAddCatchTests TestTarget) + message(DEPRECATION "ParseAndAddCatchTest: function deprecated because of possibility of missed test cases. Consider using 'catch_discover_tests' from 'Catch.cmake'") + ParseAndAddCatchTests_PrintDebugMessage("Started parsing ${TestTarget}") + get_target_property(SourceFiles ${TestTarget} SOURCES) + ParseAndAddCatchTests_PrintDebugMessage("Found the following sources: ${SourceFiles}") + foreach(SourceFile ${SourceFiles}) + ParseAndAddCatchTests_ParseFile(${SourceFile} ${TestTarget}) + endforeach() + ParseAndAddCatchTests_PrintDebugMessage("Finished parsing ${TestTarget}") +endfunction() diff --git a/lib/Catch2/contrib/gdbinit b/lib/Catch2/contrib/gdbinit new file mode 100644 index 0000000000..fb3608aeba --- /dev/null +++ b/lib/Catch2/contrib/gdbinit @@ -0,0 +1,16 @@ +# +# This file provides a way to skip stepping into Catch code when debugging with gdb. +# +# With the gdb "skip" command you can tell gdb to skip files or functions during debugging. +# see https://xaizek.github.io/2016-05-26/skipping-standard-library-in-gdb/ for an example +# +# Basically the following line tells gdb to skip all functions containing the +# regexp "Catch", which matches the complete Catch namespace. +# If you want to skip just some parts of the Catch code you can modify the +# regexp accordingly. +# +# If you want to permanently skip stepping into Catch code copy the following +# line into your ~/.gdbinit file +# + +skip -rfu Catch diff --git a/lib/Catch2/contrib/lldbinit b/lib/Catch2/contrib/lldbinit new file mode 100644 index 0000000000..4f13634d0b --- /dev/null +++ b/lib/Catch2/contrib/lldbinit @@ -0,0 +1,16 @@ +# +# This file provides a way to skip stepping into Catch code when debugging with lldb. +# +# With the setting "target.process.thread.step-avoid-regexp" you can tell lldb +# to skip functions matching the regexp +# +# Basically the following line tells lldb to skip all functions containing the +# regexp "Catch", which matches the complete Catch namespace. +# If you want to skip just some parts of the Catch code you can modify the +# regexp accordingly. +# +# If you want to permanently skip stepping into Catch code copy the following +# line into your ~/.lldbinit file +# + +settings set target.process.thread.step-avoid-regexp Catch \ No newline at end of file diff --git a/lib/Catch2/docs/Readme.md b/lib/Catch2/docs/Readme.md new file mode 100644 index 0000000000..0bbb104ecb --- /dev/null +++ b/lib/Catch2/docs/Readme.md @@ -0,0 +1,41 @@ + +# Reference + +To get the most out of Catch2, start with the [tutorial](tutorial.md#top). +Once you're up and running consider the following reference material. + +Writing tests: +* [Assertion macros](assertions.md#top) +* [Matchers](matchers.md#top) +* [Logging macros](logging.md#top) +* [Test cases and sections](test-cases-and-sections.md#top) +* [Test fixtures](test-fixtures.md#top) +* [Reporters](reporters.md#top) +* [Event Listeners](event-listeners.md#top) +* [Data Generators](generators.md#top) +* [Other macros](other-macros.md#top) +* [Micro benchmarking](benchmarks.md#top) + +Fine tuning: +* [Supplying your own main()](own-main.md#top) +* [Compile-time configuration](configuration.md#top) +* [String Conversions](tostring.md#top) + +Running: +* [Command line](command-line.md#top) + +Odds and ends: +* [CMake integration](cmake-integration.md#top) +* [CI and other miscellaneous pieces](ci-and-misc.md#top) + +FAQ: +* [Why are my tests slow to compile?](slow-compiles.md#top) +* [Known limitations](limitations.md#top) + +Other: +* [Why Catch?](why-catch.md#top) +* [Open Source Projects using Catch](opensource-users.md#top) +* [Commercial Projects using Catch](commercial-users.md#top) +* [Contributing](contributing.md#top) +* [Release Notes](release-notes.md#top) +* [Deprecations and incoming changes](deprecations.md#top) diff --git a/lib/Catch2/docs/assertions.md b/lib/Catch2/docs/assertions.md new file mode 100644 index 0000000000..682eb6e7ce --- /dev/null +++ b/lib/Catch2/docs/assertions.md @@ -0,0 +1,201 @@ + +# Assertion Macros + +**Contents**
+[Natural Expressions](#natural-expressions)
+[Exceptions](#exceptions)
+[Matcher expressions](#matcher-expressions)
+[Thread Safety](#thread-safety)
+[Expressions with commas](#expressions-with-commas)
+ +Most test frameworks have a large collection of assertion macros to capture all possible conditional forms (```_EQUALS```, ```_NOTEQUALS```, ```_GREATER_THAN``` etc). + +Catch is different. Because it decomposes natural C-style conditional expressions most of these forms are reduced to one or two that you will use all the time. That said there is a rich set of auxiliary macros as well. We'll describe all of these here. + +Most of these macros come in two forms: + +## Natural Expressions + +The ```REQUIRE``` family of macros tests an expression and aborts the test case if it fails. +The ```CHECK``` family are equivalent but execution continues in the same test case even if the assertion fails. This is useful if you have a series of essentially orthogonal assertions and it is useful to see all the results rather than stopping at the first failure. + +* **REQUIRE(** _expression_ **)** and +* **CHECK(** _expression_ **)** + +Evaluates the expression and records the result. If an exception is thrown, it is caught, reported, and counted as a failure. These are the macros you will use most of the time. + +Examples: +``` +CHECK( str == "string value" ); +CHECK( thisReturnsTrue() ); +REQUIRE( i == 42 ); +``` + +* **REQUIRE_FALSE(** _expression_ **)** and +* **CHECK_FALSE(** _expression_ **)** + +Evaluates the expression and records the _logical NOT_ of the result. If an exception is thrown it is caught, reported, and counted as a failure. +(these forms exist as a workaround for the fact that ! prefixed expressions cannot be decomposed). + +Example: +``` +REQUIRE_FALSE( thisReturnsFalse() ); +``` + +Do note that "overly complex" expressions cannot be decomposed and thus will not compile. This is done partly for practical reasons (to keep the underlying expression template machinery to minimum) and partly for philosophical reasons (assertions should be simple and deterministic). + +Examples: +* `CHECK(a == 1 && b == 2);` +This expression is too complex because of the `&&` operator. If you want to check that 2 or more properties hold, you can either put the expression into parenthesis, which stops decomposition from working, or you need to decompose the expression into two assertions: `CHECK( a == 1 ); CHECK( b == 2);` +* `CHECK( a == 2 || b == 1 );` +This expression is too complex because of the `||` operator. If you want to check that one of several properties hold, you can put the expression into parenthesis (unlike with `&&`, expression decomposition into several `CHECK`s is not possible). + + +### Floating point comparisons + +When comparing floating point numbers - especially if at least one of them has been computed - great care must be taken to allow for rounding errors and inexact representations. + +Catch provides a way to perform tolerant comparisons of floating point values through use of a wrapper class called `Approx`. `Approx` can be used on either side of a comparison expression. It overloads the comparisons operators to take a tolerance into account. Here's a simple example: + +```cpp +REQUIRE( performComputation() == Approx( 2.1 ) ); +``` + +Catch also provides a user-defined literal for `Approx`; `_a`. It resides in +the `Catch::literals` namespace and can be used like so: +```cpp +using namespace Catch::literals; +REQUIRE( performComputation() == 2.1_a ); +``` + +`Approx` is constructed with defaults that should cover most simple cases. +For the more complex cases, `Approx` provides 3 customization points: + +* __epsilon__ - epsilon serves to set the coefficient by which a result +can differ from `Approx`'s value before it is rejected. +_By default set to `std::numeric_limits::epsilon()*100`._ +* __margin__ - margin serves to set the the absolute value by which +a result can differ from `Approx`'s value before it is rejected. +_By default set to `0.0`._ +* __scale__ - scale is used to change the magnitude of `Approx` for relative check. +_By default set to `0.0`._ + +#### epsilon example +```cpp +Approx target = Approx(100).epsilon(0.01); +100.0 == target; // Obviously true +200.0 == target; // Obviously still false +100.5 == target; // True, because we set target to allow up to 1% difference +``` + +#### margin example +```cpp +Approx target = Approx(100).margin(5); +100.0 == target; // Obviously true +200.0 == target; // Obviously still false +104.0 == target; // True, because we set target to allow absolute difference of at most 5 +``` + +#### scale +Scale can be useful if the computation leading to the result worked +on different scale than is used by the results. Since allowed difference +between Approx's value and compared value is based primarily on Approx's value +(the allowed difference is computed as +`(Approx::scale + Approx::value) * epsilon`), the resulting comparison could +need rescaling to be correct. + + +## Exceptions + +* **REQUIRE_NOTHROW(** _expression_ **)** and +* **CHECK_NOTHROW(** _expression_ **)** + +Expects that no exception is thrown during evaluation of the expression. + +* **REQUIRE_THROWS(** _expression_ **)** and +* **CHECK_THROWS(** _expression_ **)** + +Expects that an exception (of any type) is be thrown during evaluation of the expression. + +* **REQUIRE_THROWS_AS(** _expression_, _exception type_ **)** and +* **CHECK_THROWS_AS(** _expression_, _exception type_ **)** + +Expects that an exception of the _specified type_ is thrown during evaluation of the expression. Note that the _exception type_ is extended with `const&` and you should not include it yourself. + +* **REQUIRE_THROWS_WITH(** _expression_, _string or string matcher_ **)** and +* **CHECK_THROWS_WITH(** _expression_, _string or string matcher_ **)** + +Expects that an exception is thrown that, when converted to a string, matches the _string_ or _string matcher_ provided (see next section for Matchers). + +e.g. +```cpp +REQUIRE_THROWS_WITH( openThePodBayDoors(), Contains( "afraid" ) && Contains( "can't do that" ) ); +REQUIRE_THROWS_WITH( dismantleHal(), "My mind is going" ); +``` + +* **REQUIRE_THROWS_MATCHES(** _expression_, _exception type_, _matcher for given exception type_ **)** and +* **CHECK_THROWS_MATCHES(** _expression_, _exception type_, _matcher for given exception type_ **)** + +Expects that exception of _exception type_ is thrown and it matches provided matcher (see the [documentation for Matchers](matchers.md#top)). + + +_Please note that the `THROW` family of assertions expects to be passed a single expression, not a statement or series of statements. If you want to check a more complicated sequence of operations, you can use a C++11 lambda function._ + +```cpp +REQUIRE_NOTHROW([&](){ + int i = 1; + int j = 2; + auto k = i + j; + if (k == 3) { + throw 1; + } +}()); +``` + + + +## Matcher expressions + +To support Matchers a slightly different form is used. Matchers have [their own documentation](matchers.md#top). + +* **REQUIRE_THAT(** _lhs_, _matcher expression_ **)** and +* **CHECK_THAT(** _lhs_, _matcher expression_ **)** + +Matchers can be composed using `&&`, `||` and `!` operators. + +## Thread Safety + +Currently assertions in Catch are not thread safe. +For more details, along with workarounds, see the section on [the limitations page](limitations.md#thread-safe-assertions). + +## Expressions with commas + +Because the preprocessor parses code using different rules than the +compiler, multiple-argument assertions (e.g. `REQUIRE_THROWS_AS`) have +problems with commas inside the provided expressions. As an example +`REQUIRE_THROWS_AS(std::pair(1, 2), std::invalid_argument);` +will fail to compile, because the preprocessor sees 3 arguments provided, +but the macro accepts only 2. There are two possible workarounds. + +1) Use typedef: +```cpp +using int_pair = std::pair; +REQUIRE_THROWS_AS(int_pair(1, 2), std::invalid_argument); +``` + +This solution is always applicable, but makes the meaning of the code +less clear. + +2) Parenthesize the expression: +```cpp +TEST_CASE_METHOD((Fixture), "foo", "[bar]") { + SUCCEED(); +} +``` + +This solution is not always applicable, because it might require extra +changes on the Catch's side to work. + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/benchmarks.md b/lib/Catch2/docs/benchmarks.md new file mode 100644 index 0000000000..a41839fd18 --- /dev/null +++ b/lib/Catch2/docs/benchmarks.md @@ -0,0 +1,254 @@ + +# Authoring benchmarks + +> [Introduced](https://github.com/catchorg/Catch2/issues/1616) in Catch 2.9.0. + +_Note that benchmarking support is disabled by default and to enable it, +you need to define `CATCH_CONFIG_ENABLE_BENCHMARKING`. For more details, +see the [compile-time configuration documentation](configuration.md#top)._ + +Writing benchmarks is not easy. Catch simplifies certain aspects but you'll +always need to take care about various aspects. Understanding a few things about +the way Catch runs your code will be very helpful when writing your benchmarks. + +First off, let's go over some terminology that will be used throughout this +guide. + +- *User code*: user code is the code that the user provides to be measured. +- *Run*: one run is one execution of the user code. +- *Sample*: one sample is one data point obtained by measuring the time it takes + to perform a certain number of runs. One sample can consist of more than one + run if the clock available does not have enough resolution to accurately + measure a single run. All samples for a given benchmark execution are obtained + with the same number of runs. + +## Execution procedure + +Now I can explain how a benchmark is executed in Catch. There are three main +steps, though the first does not need to be repeated for every benchmark. + +1. *Environmental probe*: before any benchmarks can be executed, the clock's +resolution is estimated. A few other environmental artifacts are also estimated +at this point, like the cost of calling the clock function, but they almost +never have any impact in the results. + +2. *Estimation*: the user code is executed a few times to obtain an estimate of +the amount of runs that should be in each sample. This also has the potential +effect of bringing relevant code and data into the caches before the actual +measurement starts. + +3. *Measurement*: all the samples are collected sequentially by performing the +number of runs estimated in the previous step for each sample. + +This already gives us one important rule for writing benchmarks for Catch: the +benchmarks must be repeatable. The user code will be executed several times, and +the number of times it will be executed during the estimation step cannot be +known beforehand since it depends on the time it takes to execute the code. +User code that cannot be executed repeatedly will lead to bogus results or +crashes. + +## Benchmark specification + +Benchmarks can be specified anywhere inside a Catch test case. +There is a simple and a slightly more advanced version of the `BENCHMARK` macro. + +Let's have a look how a naive Fibonacci implementation could be benchmarked: +```c++ +std::uint64_t Fibonacci(std::uint64_t number) { + return number < 2 ? 1 : Fibonacci(number - 1) + Fibonacci(number - 2); +} +``` +Now the most straight forward way to benchmark this function, is just adding a `BENCHMARK` macro to our test case: +```c++ +TEST_CASE("Fibonacci") { + CHECK(Fibonacci(0) == 1); + // some more asserts.. + CHECK(Fibonacci(5) == 8); + // some more asserts.. + + // now let's benchmark: + BENCHMARK("Fibonacci 20") { + return Fibonacci(20); + }; + + BENCHMARK("Fibonacci 25") { + return Fibonacci(25); + }; + + BENCHMARK("Fibonacci 30") { + return Fibonacci(30); + }; + + BENCHMARK("Fibonacci 35") { + return Fibonacci(35); + }; +} +``` +There's a few things to note: +- As `BENCHMARK` expands to a lambda expression it is necessary to add a semicolon after + the closing brace (as opposed to the first experimental version). +- The `return` is a handy way to avoid the compiler optimizing away the benchmark code. + +Running this already runs the benchmarks and outputs something similar to: +``` +------------------------------------------------------------------------------- +Fibonacci +------------------------------------------------------------------------------- +C:\path\to\Catch2\Benchmark.tests.cpp(10) +............................................................................... +benchmark name samples iterations estimated + mean low mean high mean + std dev low std dev high std dev +------------------------------------------------------------------------------- +Fibonacci 20 100 416439 83.2878 ms + 2 ns 2 ns 2 ns + 0 ns 0 ns 0 ns + +Fibonacci 25 100 400776 80.1552 ms + 3 ns 3 ns 3 ns + 0 ns 0 ns 0 ns + +Fibonacci 30 100 396873 79.3746 ms + 17 ns 17 ns 17 ns + 0 ns 0 ns 0 ns + +Fibonacci 35 100 145169 87.1014 ms + 468 ns 464 ns 473 ns + 21 ns 15 ns 34 ns +``` + +### Advanced benchmarking +The simplest use case shown above, takes no arguments and just runs the user code that needs to be measured. +However, if using the `BENCHMARK_ADVANCED` macro and adding a `Catch::Benchmark::Chronometer` argument after +the macro, some advanced features are available. The contents of the simple benchmarks are invoked once per run, +while the blocks of the advanced benchmarks are invoked exactly twice: +once during the estimation phase, and another time during the execution phase. + +```c++ +BENCHMARK("simple"){ return long_computation(); }; + +BENCHMARK_ADVANCED("advanced")(Catch::Benchmark::Chronometer meter) { + set_up(); + meter.measure([] { return long_computation(); }); +}; +``` + +These advanced benchmarks no longer consist entirely of user code to be measured. +In these cases, the code to be measured is provided via the +`Catch::Benchmark::Chronometer::measure` member function. This allows you to set up any +kind of state that might be required for the benchmark but is not to be included +in the measurements, like making a vector of random integers to feed to a +sorting algorithm. + +A single call to `Catch::Benchmark::Chronometer::measure` performs the actual measurements +by invoking the callable object passed in as many times as necessary. Anything +that needs to be done outside the measurement can be done outside the call to +`measure`. + +The callable object passed in to `measure` can optionally accept an `int` +parameter. + +```c++ +meter.measure([](int i) { return long_computation(i); }); +``` + +If it accepts an `int` parameter, the sequence number of each run will be passed +in, starting with 0. This is useful if you want to measure some mutating code, +for example. The number of runs can be known beforehand by calling +`Catch::Benchmark::Chronometer::runs`; with this one can set up a different instance to be +mutated by each run. + +```c++ +std::vector v(meter.runs()); +std::fill(v.begin(), v.end(), test_string()); +meter.measure([&v](int i) { in_place_escape(v[i]); }); +``` + +Note that it is not possible to simply use the same instance for different runs +and resetting it between each run since that would pollute the measurements with +the resetting code. + +It is also possible to just provide an argument name to the simple `BENCHMARK` macro to get +the same semantics as providing a callable to `meter.measure` with `int` argument: + +```c++ +BENCHMARK("indexed", i){ return long_computation(i); }; +``` + +### Constructors and destructors + +All of these tools give you a lot mileage, but there are two things that still +need special handling: constructors and destructors. The problem is that if you +use automatic objects they get destroyed by the end of the scope, so you end up +measuring the time for construction and destruction together. And if you use +dynamic allocation instead, you end up including the time to allocate memory in +the measurements. + +To solve this conundrum, Catch provides class templates that let you manually +construct and destroy objects without dynamic allocation and in a way that lets +you measure construction and destruction separately. + +```c++ +BENCHMARK_ADVANCED("construct")(Catch::Benchmark::Chronometer meter) { + std::vector> storage(meter.runs()); + meter.measure([&](int i) { storage[i].construct("thing"); }); +}; + +BENCHMARK_ADVANCED("destroy")(Catch::Benchmark::Chronometer meter) { + std::vector> storage(meter.runs()); + for(auto&& o : storage) + o.construct("thing"); + meter.measure([&](int i) { storage[i].destruct(); }); +}; +``` + +`Catch::Benchmark::storage_for` objects are just pieces of raw storage suitable for `T` +objects. You can use the `Catch::Benchmark::storage_for::construct` member function to call a constructor and +create an object in that storage. So if you want to measure the time it takes +for a certain constructor to run, you can just measure the time it takes to run +this function. + +When the lifetime of a `Catch::Benchmark::storage_for` object ends, if an actual object was +constructed there it will be automatically destroyed, so nothing leaks. + +If you want to measure a destructor, though, we need to use +`Catch::Benchmark::destructable_object`. These objects are similar to +`Catch::Benchmark::storage_for` in that construction of the `T` object is manual, but +it does not destroy anything automatically. Instead, you are required to call +the `Catch::Benchmark::destructable_object::destruct` member function, which is what you +can use to measure the destruction time. + +### The optimizer + +Sometimes the optimizer will optimize away the very code that you want to +measure. There are several ways to use results that will prevent the optimiser +from removing them. You can use the `volatile` keyword, or you can output the +value to standard output or to a file, both of which force the program to +actually generate the value somehow. + +Catch adds a third option. The values returned by any function provided as user +code are guaranteed to be evaluated and not optimised out. This means that if +your user code consists of computing a certain value, you don't need to bother +with using `volatile` or forcing output. Just `return` it from the function. +That helps with keeping the code in a natural fashion. + +Here's an example: + +```c++ +// may measure nothing at all by skipping the long calculation since its +// result is not used +BENCHMARK("no return"){ long_calculation(); }; + +// the result of long_calculation() is guaranteed to be computed somehow +BENCHMARK("with return"){ return long_calculation(); }; +``` + +However, there's no other form of control over the optimizer whatsoever. It is +up to you to write a benchmark that actually measures what you want and doesn't +just measure the time to do a whole bunch of nothing. + +To sum up, there are two simple rules: whatever you would do in handwritten code +to control optimization still works in Catch; and Catch makes return values +from user code into observable effects that can't be optimized away. + +Adapted from nonius' documentation. diff --git a/lib/Catch2/docs/ci-and-misc.md b/lib/Catch2/docs/ci-and-misc.md new file mode 100644 index 0000000000..40b7cec927 --- /dev/null +++ b/lib/Catch2/docs/ci-and-misc.md @@ -0,0 +1,112 @@ + +# CI and other odd pieces + +**Contents**
+[Continuous Integration systems](#continuous-integration-systems)
+[Other reporters](#other-reporters)
+[Low-level tools](#low-level-tools)
+[CMake](#cmake)
+ +This page talks about how Catch integrates with Continuous Integration +Build Systems may refer to low-level tools, like CMake, or larger systems that run on servers, like Jenkins or TeamCity. This page will talk about both. + +## Continuous Integration systems + +Probably the most important aspect to using Catch with a build server is the use of different reporters. Catch comes bundled with three reporters that should cover the majority of build servers out there - although adding more for better integration with some is always a possibility (currently we also offer TeamCity, TAP, Automake and SonarQube reporters). + +Two of these reporters are built in (XML and JUnit) and the third (TeamCity) is included as a separate header. It's possible that the other two may be split out in the future too - as that would make the core of Catch smaller for those that don't need them. + +### XML Reporter +```-r xml``` + +The XML Reporter writes in an XML format that is specific to Catch. + +The advantage of this format is that it corresponds well to the way Catch works (especially the more unusual features, such as nested sections) and is a fully streaming format - that is it writes output as it goes, without having to store up all its results before it can start writing. + +The disadvantage is that, being specific to Catch, no existing build servers understand the format natively. It can be used as input to an XSLT transformation that could convert it to, say, HTML - although this loses the streaming advantage, of course. + +### JUnit Reporter +```-r junit``` + +The JUnit Reporter writes in an XML format that mimics the JUnit ANT schema. + +The advantage of this format is that the JUnit Ant schema is widely understood by most build servers and so can usually be consumed with no additional work. + +The disadvantage is that this schema was designed to correspond to how JUnit works - and there is a significant mismatch with how Catch works. Additionally the format is not streamable (because opening elements hold counts of failed and passing tests as attributes) - so the whole test run must complete before it can be written. + +## Other reporters +Other reporters are not part of the single-header distribution and need +to be downloaded and included separately. All reporters are stored in +`single_include` directory in the git repository, and are named +`catch_reporter_*.hpp`. For example, to use the TeamCity reporter you +need to download `single_include/catch_reporter_teamcity.hpp` and include +it after Catch itself. + +```cpp +#define CATCH_CONFIG_MAIN +#include "catch.hpp" +#include "catch_reporter_teamcity.hpp" +``` + +### TeamCity Reporter +```-r teamcity``` + +The TeamCity Reporter writes TeamCity service messages to stdout. In order to be able to use this reporter an additional header must also be included. + +Being specific to TeamCity this is the best reporter to use with it - but it is completely unsuitable for any other purpose. It is a streaming format (it writes as it goes) - although test results don't appear in the TeamCity interface until the completion of a suite (usually the whole test run). + +### Automake Reporter +```-r automake``` + +The Automake Reporter writes out the [meta tags](https://www.gnu.org/software/automake/manual/html_node/Log-files-generation-and-test-results-recording.html#Log-files-generation-and-test-results-recording) expected by automake via `make check`. + +### TAP (Test Anything Protocol) Reporter +```-r tap``` + +Because of the incremental nature of Catch's test suites and ability to run specific tests, our implementation of TAP reporter writes out the number of tests in a suite last. + +### SonarQube Reporter +```-r sonarqube``` +[SonarQube Generic Test Data](https://docs.sonarqube.org/latest/analysis/generic-test/) XML format for tests metrics. + +## Low-level tools + +### Precompiled headers (PCHs) + +Catch offers prototypal support for being included in precompiled headers, but because of its single-header nature it does need some actions by the user: +* The precompiled header needs to define `CATCH_CONFIG_ALL_PARTS` +* The implementation file needs to + * undefine `TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED` + * define `CATCH_CONFIG_IMPL_ONLY` + * define `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER` + * include "catch.hpp" again + + +### CodeCoverage module (GCOV, LCOV...) + +If you are using GCOV tool to get testing coverage of your code, and are not sure how to integrate it with CMake and Catch, there should be an external example over at https://github.com/fkromer/catch_cmake_coverage + + +### pkg-config + +Catch2 provides a rudimentary pkg-config integration, by registering itself +under the name `catch2`. This means that after Catch2 is installed, you +can use `pkg-config` to get its include path: `pkg-config --cflags catch2`. + +### gdb and lldb scripts + +Catch2's `contrib` folder also contains two simple debugger scripts, +`gdbinit` for `gdb` and `lldbinit` for `lldb`. If loaded into their +respective debugger, these will tell it to step over Catch2's internals +when stepping through code. + + +## CMake + +[As it has been getting kinda long, the documentation of Catch2's +integration with CMake has been moved to its own page.](cmake-integration.md#top) + + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/cmake-integration.md b/lib/Catch2/docs/cmake-integration.md new file mode 100644 index 0000000000..1cab907add --- /dev/null +++ b/lib/Catch2/docs/cmake-integration.md @@ -0,0 +1,291 @@ + +# CMake integration + +**Contents**
+[CMake target](#cmake-target)
+[Automatic test registration](#automatic-test-registration)
+[CMake project options](#cmake-project-options)
+[Installing Catch2 from git repository](#installing-catch2-from-git-repository)
+[Installing Catch2 from vcpkg](#installing-catch2-from-vcpkg)
+ +Because we use CMake to build Catch2, we also provide a couple of +integration points for our users. + +1) Catch2 exports a (namespaced) CMake target +2) Catch2's repository contains CMake scripts for automatic registration +of `TEST_CASE`s in CTest + +## CMake target + +Catch2's CMake build exports an interface target `Catch2::Catch2`. Linking +against it will add the proper include path and all necessary capabilities +to the resulting binary. + +This means that if Catch2 has been installed on the system, it should be +enough to do: +```cmake +find_package(Catch2 REQUIRED) +target_link_libraries(tests Catch2::Catch2) +``` + + +This target is also provided when Catch2 is used as a subdirectory. +Assuming that Catch2 has been cloned to `lib/Catch2`: +```cmake +add_subdirectory(lib/Catch2) +target_link_libraries(tests Catch2::Catch2) +``` + +Another possibility is to use [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html): +```cmake +Include(FetchContent) + +FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v2.13.1) + +FetchContent_MakeAvailable(Catch2) + +target_link_libraries(tests Catch2::Catch2) +``` + +## Automatic test registration + +Catch2's repository also contains two CMake scripts that help users +with automatically registering their `TEST_CASE`s with CTest. They +can be found in the `contrib` folder, and are + +1) `Catch.cmake` (and its dependency `CatchAddTests.cmake`) +2) `ParseAndAddCatchTests.cmake` (deprecated) + +If Catch2 has been installed in system, both of these can be used after +doing `find_package(Catch2 REQUIRED)`. Otherwise you need to add them +to your CMake module path. + +### `Catch.cmake` and `CatchAddTests.cmake` + +`Catch.cmake` provides function `catch_discover_tests` to get tests from +a target. This function works by running the resulting executable with +`--list-test-names-only` flag, and then parsing the output to find all +existing tests. + +#### Usage +```cmake +cmake_minimum_required(VERSION 3.5) + +project(baz LANGUAGES CXX VERSION 0.0.1) + +find_package(Catch2 REQUIRED) +add_executable(foo test.cpp) +target_link_libraries(foo Catch2::Catch2) + +include(CTest) +include(Catch) +catch_discover_tests(foo) +``` + + +#### Customization +`catch_discover_tests` can be given several extra argumets: +```cmake +catch_discover_tests(target + [TEST_SPEC arg1...] + [EXTRA_ARGS arg1...] + [WORKING_DIRECTORY dir] + [TEST_PREFIX prefix] + [TEST_SUFFIX suffix] + [PROPERTIES name1 value1...] + [TEST_LIST var] + [REPORTER reporter] + [OUTPUT_DIR dir] + [OUTPUT_PREFIX prefix] + [OUTPUT_SUFFIX suffix] +) +``` + +* `TEST_SPEC arg1...` + +Specifies test cases, wildcarded test cases, tags and tag expressions to +pass to the Catch executable alongside the `--list-test-names-only` flag. + + +* `EXTRA_ARGS arg1...` + +Any extra arguments to pass on the command line to each test case. + + +* `WORKING_DIRECTORY dir` + +Specifies the directory in which to run the discovered test cases. If this +option is not provided, the current binary directory is used. + + +* `TEST_PREFIX prefix` + +Specifies a _prefix_ to be added to the name of each discovered test case. +This can be useful when the same test executable is being used in multiple +calls to `catch_discover_tests()`, with different `TEST_SPEC` or `EXTRA_ARGS`. + + +* `TEST_SUFFIX suffix` + +Same as `TEST_PREFIX`, except it specific the _suffix_ for the test names. +Both `TEST_PREFIX` and `TEST_SUFFIX` can be specified at the same time. + + +* `PROPERTIES name1 value1...` + +Specifies additional properties to be set on all tests discovered by this +invocation of `catch_discover_tests`. + + +* `TEST_LIST var` + +Make the list of tests available in the variable `var`, rather than the +default `_TESTS`. This can be useful when the same test +executable is being used in multiple calls to `catch_discover_tests()`. +Note that this variable is only available in CTest. + +* `REPORTER reporter` + +Use the specified reporter when running the test case. The reporter will +be passed to the test runner as `--reporter reporter`. + +* `OUTPUT_DIR dir` + +If specified, the parameter is passed along as +`--out dir/` to test executable. The actual file name is the +same as the test name. This should be used instead of +`EXTRA_ARGS --out foo` to avoid race conditions writing the result output +when using parallel test execution. + +* `OUTPUT_PREFIX prefix` + +May be used in conjunction with `OUTPUT_DIR`. +If specified, `prefix` is added to each output file name, like so +`--out dir/prefix`. + +* `OUTPUT_SUFFIX suffix` + +May be used in conjunction with `OUTPUT_DIR`. +If specified, `suffix` is added to each output file name, like so +`--out dir/suffix`. This can be used to add a file extension to +the output file name e.g. ".xml". + + +### `ParseAndAddCatchTests.cmake` + +⚠ This script is [deprecated](https://github.com/catchorg/Catch2/pull/2120) +in Catch 2.13.4 and superseded by the above approach using `catch_discover_tests`. +See [#2092](https://github.com/catchorg/Catch2/issues/2092) for details. + +`ParseAndAddCatchTests` works by parsing all implementation files +associated with the provided target, and registering them via CTest's +`add_test`. This approach has some limitations, such as the fact that +commented-out tests will be registered anyway. More serious, only a +subset of the assertion macros currently available in Catch can be +detected by this script and tests with any macros that cannot be +parsed are *silently ignored*. + + +#### Usage + +```cmake +cmake_minimum_required(VERSION 3.5) + +project(baz LANGUAGES CXX VERSION 0.0.1) + +find_package(Catch2 REQUIRED) +add_executable(foo test.cpp) +target_link_libraries(foo Catch2::Catch2) + +include(CTest) +include(ParseAndAddCatchTests) +ParseAndAddCatchTests(foo) +``` + + +#### Customization + +`ParseAndAddCatchTests` provides some customization points: +* `PARSE_CATCH_TESTS_VERBOSE` -- When `ON`, the script prints debug +messages. Defaults to `OFF`. +* `PARSE_CATCH_TESTS_NO_HIDDEN_TESTS` -- When `ON`, hidden tests (tests +tagged with any of `[!hide]`, `[.]` or `[.foo]`) will not be registered. +Defaults to `OFF`. +* `PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME` -- When `ON`, adds fixture +class name to the test name in CTest. Defaults to `ON`. +* `PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME` -- When `ON`, adds target +name to the test name in CTest. Defaults to `ON`. +* `PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS` -- When `ON`, adds test +file to `CMAKE_CONFIGURE_DEPENDS`. This means that the CMake configuration +step will be re-ran when the test files change, letting new tests be +automatically discovered. Defaults to `OFF`. + + +Optionally, one can specify a launching command to run tests by setting the +variable `OptionalCatchTestLauncher` before calling `ParseAndAddCatchTests`. For +instance to run some tests using `MPI` and other sequentially, one can write +```cmake +set(OptionalCatchTestLauncher ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${NUMPROC}) +ParseAndAddCatchTests(mpi_foo) +unset(OptionalCatchTestLauncher) +ParseAndAddCatchTests(bar) +``` + +## CMake project options + +Catch2's CMake project also provides some options for other projects +that consume it. These are + +* `CATCH_BUILD_TESTING` -- When `ON`, Catch2's SelfTest project will be +built. Defaults to `ON`. Note that Catch2 also obeys `BUILD_TESTING` CMake +variable, so _both_ of them need to be `ON` for the SelfTest to be built, +and either of them can be set to `OFF` to disable building SelfTest. +* `CATCH_BUILD_EXAMPLES` -- When `ON`, Catch2's usage examples will be +built. Defaults to `OFF`. +* `CATCH_INSTALL_DOCS` -- When `ON`, Catch2's documentation will be +included in the installation. Defaults to `ON`. +* `CATCH_INSTALL_HELPERS` -- When `ON`, Catch2's contrib folder will be +included in the installation. Defaults to `ON`. +* `BUILD_TESTING` -- When `ON` and the project is not used as a subproject, +Catch2's test binary will be built. Defaults to `ON`. + + +## Installing Catch2 from git repository + +If you cannot install Catch2 from a package manager (e.g. Ubuntu 16.04 +provides catch only in version 1.2.0) you might want to install it from +the repository instead. Assuming you have enough rights, you can just +install it to the default location, like so: +``` +$ git clone https://github.com/catchorg/Catch2.git +$ cd Catch2 +$ cmake -Bbuild -H. -DBUILD_TESTING=OFF +$ sudo cmake --build build/ --target install +``` + +If you do not have superuser rights, you will also need to specify +[CMAKE_INSTALL_PREFIX](https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html) +when configuring the build, and then modify your calls to +[find_package](https://cmake.org/cmake/help/latest/command/find_package.html) +accordingly. + +## Installing Catch2 from vcpkg + +Alternatively, you can build and install Catch2 using [vcpkg](https://github.com/microsoft/vcpkg/) dependency manager: +``` +git clone https://github.com/Microsoft/vcpkg.git +cd vcpkg +./bootstrap-vcpkg.sh +./vcpkg integrate install +./vcpkg install catch2 +``` + +The catch2 port in vcpkg is kept up to date by microsoft team members and community contributors. +If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository. + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/command-line.md b/lib/Catch2/docs/command-line.md new file mode 100644 index 0000000000..a99a107261 --- /dev/null +++ b/lib/Catch2/docs/command-line.md @@ -0,0 +1,421 @@ + +# Command line + +**Contents**
+[Specifying which tests to run](#specifying-which-tests-to-run)
+[Choosing a reporter to use](#choosing-a-reporter-to-use)
+[Breaking into the debugger](#breaking-into-the-debugger)
+[Showing results for successful tests](#showing-results-for-successful-tests)
+[Aborting after a certain number of failures](#aborting-after-a-certain-number-of-failures)
+[Listing available tests, tags or reporters](#listing-available-tests-tags-or-reporters)
+[Sending output to a file](#sending-output-to-a-file)
+[Naming a test run](#naming-a-test-run)
+[Eliding assertions expected to throw](#eliding-assertions-expected-to-throw)
+[Make whitespace visible](#make-whitespace-visible)
+[Warnings](#warnings)
+[Reporting timings](#reporting-timings)
+[Load test names to run from a file](#load-test-names-to-run-from-a-file)
+[Just test names](#just-test-names)
+[Specify the order test cases are run](#specify-the-order-test-cases-are-run)
+[Specify a seed for the Random Number Generator](#specify-a-seed-for-the-random-number-generator)
+[Identify framework and version according to the libIdentify standard](#identify-framework-and-version-according-to-the-libidentify-standard)
+[Wait for key before continuing](#wait-for-key-before-continuing)
+[Specify the number of benchmark samples to collect](#specify-the-number-of-benchmark-samples-to-collect)
+[Specify the number of resamples for bootstrapping](#specify-the-number-of-resamples-for-bootstrapping)
+[Specify the confidence-interval for bootstrapping](#specify-the-confidence-interval-for-bootstrapping)
+[Disable statistical analysis of collected benchmark samples](#disable-statistical-analysis-of-collected-benchmark-samples)
+[Specify the amount of time in milliseconds spent on warming up each test](#specify-the-amount-of-time-in-milliseconds-spent-on-warming-up-each-test)
+[Usage](#usage)
+[Specify the section to run](#specify-the-section-to-run)
+[Filenames as tags](#filenames-as-tags)
+[Override output colouring](#override-output-colouring)
+ +Catch works quite nicely without any command line options at all - but for those times when you want greater control the following options are available. +Click one of the following links to take you straight to that option - or scroll on to browse the available options. + + ` ...`
+ ` -h, -?, --help`
+ ` -l, --list-tests`
+ ` -t, --list-tags`
+ ` -s, --success`
+ ` -b, --break`
+ ` -e, --nothrow`
+ ` -i, --invisibles`
+ ` -o, --out`
+ ` -r, --reporter`
+ ` -n, --name`
+ ` -a, --abort`
+ ` -x, --abortx`
+ ` -w, --warn`
+ ` -d, --durations`
+ ` -f, --input-file`
+ ` -c, --section`
+ ` -#, --filenames-as-tags`
+ + +
+ + ` --list-test-names-only`
+ ` --list-reporters`
+ ` --order`
+ ` --rng-seed`
+ ` --libidentify`
+ ` --wait-for-keypress`
+ ` --benchmark-samples`
+ ` --benchmark-resamples`
+ ` --benchmark-confidence-interval`
+ ` --benchmark-no-analysis`
+ ` --benchmark-warmup-time`
+ ` --use-colour`
+ +
+ + + + +## Specifying which tests to run + +
<test-spec> ...
+ +Test cases, wildcarded test cases, tags and tag expressions are all passed directly as arguments. Tags are distinguished by being enclosed in square brackets. + +If no test specs are supplied then all test cases, except "hidden" tests, are run. +A test is hidden by giving it any tag starting with (or just) a period (```.```) - or, in the deprecated case, tagged ```[hide]``` or given name starting with `'./'`. To specify hidden tests from the command line ```[.]``` or ```[hide]``` can be used *regardless of how they were declared*. + +Specs must be enclosed in quotes if they contain spaces. If they do not contain spaces the quotes are optional. + +Wildcards consist of the `*` character at the beginning and/or end of test case names and can substitute for any number of any characters (including none). + +Test specs are case insensitive. + +If a spec is prefixed with `exclude:` or the `~` character then the pattern matches an exclusion. This means that tests matching the pattern are excluded from the set - even if a prior inclusion spec included them. Subsequent inclusion specs will take precedence, however. +Inclusions and exclusions are evaluated in left-to-right order. + +Test case examples: + +
thisTestOnly            Matches the test case called, 'thisTestOnly'
+"this test only"        Matches the test case called, 'this test only'
+these*                  Matches all cases starting with 'these'
+exclude:notThis         Matches all tests except, 'notThis'
+~notThis                Matches all tests except, 'notThis'
+~*private*              Matches all tests except those that contain 'private'
+a* ~ab* abc             Matches all tests that start with 'a', except those that
+                        start with 'ab', except 'abc', which is included
+-# [#somefile]          Matches all tests from the file 'somefile.cpp'
+
+ +Names within square brackets are interpreted as tags. +A series of tags form an AND expression whereas a comma-separated sequence forms an OR expression. e.g.: + +
[one][two],[three]
+This matches all tests tagged `[one]` and `[two]`, as well as all tests tagged `[three]` + +Test names containing special characters, such as `,` or `[` can specify them on the command line using `\`. +`\` also escapes itself. + + +## Choosing a reporter to use + +
-r, --reporter <reporter>
+ +A reporter is an object that formats and structures the output of running tests, and potentially summarises the results. By default a console reporter is used that writes, IDE friendly, textual output. Catch comes bundled with some alternative reporters, but more can be added in client code.
+The bundled reporters are: + +
-r console
+-r compact
+-r xml
+-r junit
+
+ +The JUnit reporter is an xml format that follows the structure of the JUnit XML Report ANT task, as consumed by a number of third-party tools, including Continuous Integration servers such as Hudson. If not otherwise needed, the standard XML reporter is preferred as this is a streaming reporter, whereas the Junit reporter needs to hold all its results until the end so it can write the overall results into attributes of the root node. + + +## Breaking into the debugger +
-b, --break
+ +Under most debuggers Catch2 is capable of automatically breaking on a test +failure. This allows the user to see the current state of the test during +failure. + + +## Showing results for successful tests +
-s, --success
+ +Usually you only want to see reporting for failed tests. Sometimes it's useful to see *all* the output (especially when you don't trust that that test you just added worked first time!). +To see successful, as well as failing, test results just pass this option. Note that each reporter may treat this option differently. The Junit reporter, for example, logs all results regardless. + + +## Aborting after a certain number of failures +
-a, --abort
+-x, --abortx [<failure threshold>]
+
+ +If a ```REQUIRE``` assertion fails the test case aborts, but subsequent test cases are still run. +If a ```CHECK``` assertion fails even the current test case is not aborted. + +Sometimes this results in a flood of failure messages and you'd rather just see the first few. Specifying ```-a``` or ```--abort``` on its own will abort the whole test run on the first failed assertion of any kind. Use ```-x``` or ```--abortx``` followed by a number to abort after that number of assertion failures. + + +## Listing available tests, tags or reporters +
-l, --list-tests
+-t, --list-tags
+--list-reporters
+
+ +```-l``` or ```--list-tests``` will list all registered tests, along with any tags. +If one or more test-specs have been supplied too then only the matching tests will be listed. + +```-t``` or ```--list-tags``` lists all available tags, along with the number of test cases they match. Again, supplying test specs limits the tags that match. + +```--list-reporters``` lists the available reporters. + + +## Sending output to a file +
-o, --out <filename>
+
+ +Use this option to send all output to a file. By default output is sent to stdout (note that uses of stdout and stderr *from within test cases* are redirected and included in the report - so even stderr will effectively end up on stdout). + + +## Naming a test run +
-n, --name <name for test run>
+ +If a name is supplied it will be used by the reporter to provide an overall name for the test run. This can be useful if you are sending to a file, for example, and need to distinguish different test runs - either from different Catch executables or runs of the same executable with different options. If not supplied the name is defaulted to the name of the executable. + + +## Eliding assertions expected to throw +
-e, --nothrow
+ +Skips all assertions that test that an exception is thrown, e.g. ```REQUIRE_THROWS```. + +These can be a nuisance in certain debugging environments that may break when exceptions are thrown (while this is usually optional for handled exceptions, it can be useful to have enabled if you are trying to track down something unexpected). + +Sometimes exceptions are expected outside of one of the assertions that tests for them (perhaps thrown and caught within the code-under-test). The whole test case can be skipped when using ```-e``` by marking it with the ```[!throws]``` tag. + +When running with this option any throw checking assertions are skipped so as not to contribute additional noise. Be careful if this affects the behaviour of subsequent tests. + + +## Make whitespace visible +
-i, --invisibles
+ +If a string comparison fails due to differences in whitespace - especially leading or trailing whitespace - it can be hard to see what's going on. +This option transforms tabs and newline characters into ```\t``` and ```\n``` respectively when printing. + + +## Warnings +
-w, --warn <warning name>
+ +Enables reporting of suspicious test states. There are currently two +available warnings + +``` + NoAssertions // Fail test case / leaf section if no assertions + // (e.g. `REQUIRE`) is encountered. + NoTests // Return non-zero exit code when no test cases were run + // Also calls reporter's noMatchingTestCases method +``` + + + +## Reporting timings +
-d, --durations <yes/no>
+ +When set to ```yes``` Catch will report the duration of each test case, in milliseconds. Note that it does this regardless of whether a test case passes or fails. Note, also, the certain reporters (e.g. Junit) always report test case durations regardless of this option being set or not. + +
-D, --min-duration <value>
+ +> `--min-duration` was [introduced](https://github.com/catchorg/Catch2/pull/1910) in Catch 2.13.0 + +When set, Catch will report the duration of each test case that took more +than <value> seconds, in milliseconds. This option is overriden by both +`-d yes` and `-d no`, so that either all durations are reported, or none +are. + + + +## Load test names to run from a file +
-f, --input-file <filename>
+ +Provide the name of a file that contains a list of test case names - one per line. Blank lines are skipped and anything after the comment character, ```#```, is ignored. + +A useful way to generate an initial instance of this file is to use the list-test-names-only option. This can then be manually curated to specify a specific subset of tests - or in a specific order. + + +## Just test names +
--list-test-names-only
+ +This option lists all available tests in a non-indented form, one on each line. This makes it ideal for saving to a file and feeding back into the ```-f``` or ```--input-file``` option. + + + +## Specify the order test cases are run +
--order <decl|lex|rand>
+ +Test cases are ordered one of three ways: + +### decl +Declaration order (this is the default order if no --order argument is provided). +Tests in the same TU are sorted using their declaration orders, different +TUs are in an implementation (linking) dependent order. + + +### lex +Lexicographic order. Tests are sorted by their name, their tags are ignored. + + +### rand + +Randomly sorted. The order is dependent on Catch2's random seed (see +[`--rng-seed`](#rng-seed)), and is subset invariant. What this means +is that as long as the random seed is fixed, running only some tests +(e.g. via tag) does not change their relative order. + +> The subset stability was introduced in Catch2 v2.12.0 + + + +## Specify a seed for the Random Number Generator +
--rng-seed <'time'|number>
+ +Sets a seed for the random number generator using ```std::srand()```. +If a number is provided this is used directly as the seed so the random pattern is repeatable. +Alternatively if the keyword ```time``` is provided then the result of calling ```std::time(0)``` is used and so the pattern becomes unpredictable. In some cases, you might need to pass the keyword ```time``` in double quotes instead of single quotes. + +In either case the actual value for the seed is printed as part of Catch's output so if an issue is discovered that is sensitive to test ordering the ordering can be reproduced - even if it was originally seeded from ```std::time(0)```. + + +## Identify framework and version according to the libIdentify standard +
--libidentify
+ +See [The LibIdentify repo for more information and examples](https://github.com/janwilmans/LibIdentify). + + +## Wait for key before continuing +
--wait-for-keypress <never|start|exit|both>
+ +Will cause the executable to print a message and wait until the return/ enter key is pressed before continuing - +either before running any tests, after running all tests - or both, depending on the argument. + + +## Specify the number of benchmark samples to collect +
--benchmark-samples <# of samples>
+ +> [Introduced](https://github.com/catchorg/Catch2/issues/1616) in Catch 2.9.0. + +When running benchmarks a number of "samples" is collected. This is the base data for later statistical analysis. +Per sample a clock resolution dependent number of iterations of the user code is run, which is independent of the number of samples. Defaults to 100. + + +## Specify the number of resamples for bootstrapping +
--benchmark-resamples <# of resamples>
+ +> [Introduced](https://github.com/catchorg/Catch2/issues/1616) in Catch 2.9.0. + +After the measurements are performed, statistical [bootstrapping] is performed +on the samples. The number of resamples for that bootstrapping is configurable +but defaults to 100000. Due to the bootstrapping it is possible to give +estimates for the mean and standard deviation. The estimates come with a lower +bound and an upper bound, and the confidence interval (which is configurable but +defaults to 95%). + + [bootstrapping]: http://en.wikipedia.org/wiki/Bootstrapping_%28statistics%29 + + +## Specify the confidence-interval for bootstrapping +
--benchmark-confidence-interval <confidence-interval>
+ +> [Introduced](https://github.com/catchorg/Catch2/issues/1616) in Catch 2.9.0. + +The confidence-interval is used for statistical bootstrapping on the samples to +calculate the upper and lower bounds of mean and standard deviation. +Must be between 0 and 1 and defaults to 0.95. + + +## Disable statistical analysis of collected benchmark samples +
--benchmark-no-analysis
+ +> [Introduced](https://github.com/catchorg/Catch2/issues/1616) in Catch 2.9.0. + +When this flag is specified no bootstrapping or any other statistical analysis is performed. +Instead the user code is only measured and the plain mean from the samples is reported. + + +## Specify the amount of time in milliseconds spent on warming up each test +
--benchmark-warmup-time
+ +> [Introduced](https://github.com/catchorg/Catch2/pull/1844) in Catch 2.11.2. + +Configure the amount of time spent warming up each test. + + +## Usage +
-h, -?, --help
+ +Prints the command line arguments to stdout + + + +## Specify the section to run +
-c, --section <section name>
+ +To limit execution to a specific section within a test case, use this option one or more times. +To narrow to sub-sections use multiple instances, where each subsequent instance specifies a deeper nesting level. + +E.g. if you have: + +
+TEST_CASE( "Test" ) {
+  SECTION( "sa" ) {
+    SECTION( "sb" ) {
+      /*...*/
+    }
+    SECTION( "sc" ) {
+      /*...*/
+    }
+  }
+  SECTION( "sd" ) {
+    /*...*/
+  }
+}
+
+ +Then you can run `sb` with: +
./MyExe Test -c sa -c sb
+ +Or run just `sd` with: +
./MyExe Test -c sd
+ +To run all of `sa`, including `sb` and `sc` use: +
./MyExe Test -c sa
+ +There are some limitations of this feature to be aware of: +- Code outside of sections being skipped will still be executed - e.g. any set-up code in the TEST_CASE before the +start of the first section.
+- At time of writing, wildcards are not supported in section names. +- If you specify a section without narrowing to a test case first then all test cases will be executed +(but only matching sections within them). + + + +## Filenames as tags +
-#, --filenames-as-tags
+ +When this option is used then every test is given an additional tag which is formed of the unqualified +filename it is found in, with any extension stripped, prefixed with the `#` character. + +So, for example, tests within the file `~\Dev\MyProject\Ferrets.cpp` would be tagged `[#Ferrets]`. + + +## Override output colouring +
--use-colour <yes|no|auto>
+ +Catch colours output for terminals, but omits colouring when it detects that +output is being sent to a pipe. This is done to avoid interfering with automated +processing of output. + +`--use-colour yes` forces coloured output, `--use-colour no` disables coloured +output. The default behaviour is `--use-colour auto`. + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/commercial-users.md b/lib/Catch2/docs/commercial-users.md new file mode 100644 index 0000000000..7d2e87d387 --- /dev/null +++ b/lib/Catch2/docs/commercial-users.md @@ -0,0 +1,22 @@ + +# Commercial users of Catch + +As well as [Open Source](opensource-users.md#top) users Catch is widely used within proprietary code bases too. +Many organisations like to keep this information internal, and that's fine, +but if you're more open it would be great if we could list the names of as +many organisations as possible that use Catch somewhere in their codebase. +Enterprise environments often tend to be far more conservative in their tool adoption - +and being aware that other companies are using Catch can ease the path in. + +So if you are aware of Catch usage in your organisation, and are fairly confident there is no issue with sharing this +fact then please let us know - either directly, via a PR or +[issue](https://github.com/philsquared/Catch/issues), or on the [forums](https://groups.google.com/forum/?fromgroups#!forum/catch-forum). + + - Bloomberg + - [Bloomlife](https://bloomlife.com) + - NASA + - [Inscopix Inc.](https://www.inscopix.com/) + - [Makimo](https://makimo.pl/) + - [UX3D](https://ux3d.io) + - [King](https://king.com) + diff --git a/lib/Catch2/docs/configuration.md b/lib/Catch2/docs/configuration.md new file mode 100644 index 0000000000..940356adb5 --- /dev/null +++ b/lib/Catch2/docs/configuration.md @@ -0,0 +1,275 @@ + +# Compile-time configuration + +**Contents**
+[main()/ implementation](#main-implementation)
+[Reporter / Listener interfaces](#reporter--listener-interfaces)
+[Prefixing Catch macros](#prefixing-catch-macros)
+[Terminal colour](#terminal-colour)
+[Console width](#console-width)
+[stdout](#stdout)
+[Fallback stringifier](#fallback-stringifier)
+[Default reporter](#default-reporter)
+[C++11 toggles](#c11-toggles)
+[C++17 toggles](#c17-toggles)
+[Other toggles](#other-toggles)
+[Windows header clutter](#windows-header-clutter)
+[Enabling stringification](#enabling-stringification)
+[Disabling exceptions](#disabling-exceptions)
+[Overriding Catch's debug break (`-b`)](#overriding-catchs-debug-break--b)
+ +Catch is designed to "just work" as much as possible. For most people the only configuration needed is telling Catch which source file should host all the implementation code (```CATCH_CONFIG_MAIN```). + +Nonetheless there are still some occasions where finer control is needed. For these occasions Catch exposes a set of macros for configuring how it is built. + +## main()/ implementation + + CATCH_CONFIG_MAIN // Designates this as implementation file and defines main() + CATCH_CONFIG_RUNNER // Designates this as implementation file + +Although Catch is header only it still, internally, maintains a distinction between interface headers and headers that contain implementation. Only one source file in your test project should compile the implementation headers and this is controlled through the use of one of these macros - one of these identifiers should be defined before including Catch in *exactly one implementation file in your project*. + +## Reporter / Listener interfaces + + CATCH_CONFIG_EXTERNAL_INTERFACES // Brings in necessary headers for Reporter/Listener implementation + +Brings in various parts of Catch that are required for user defined Reporters and Listeners. This means that new Reporters and Listeners can be defined in this file as well as in the main file. + +Implied by both `CATCH_CONFIG_MAIN` and `CATCH_CONFIG_RUNNER`. + +## Prefixing Catch macros + + CATCH_CONFIG_PREFIX_ALL + +To keep test code clean and uncluttered Catch uses short macro names (e.g. ```TEST_CASE``` and ```REQUIRE```). Occasionally these may conflict with identifiers from platform headers or the system under test. In this case the above identifier can be defined. This will cause all the Catch user macros to be prefixed with ```CATCH_``` (e.g. ```CATCH_TEST_CASE``` and ```CATCH_REQUIRE```). + + +## Terminal colour + + CATCH_CONFIG_COLOUR_NONE // completely disables all text colouring + CATCH_CONFIG_COLOUR_WINDOWS // forces the Win32 console API to be used + CATCH_CONFIG_COLOUR_ANSI // forces ANSI colour codes to be used + +Yes, I am English, so I will continue to spell "colour" with a 'u'. + +When sending output to the terminal, if it detects that it can, Catch will use colourised text. On Windows the Win32 API, ```SetConsoleTextAttribute```, is used. On POSIX systems ANSI colour escape codes are inserted into the stream. + +For finer control you can define one of the above identifiers (these are mutually exclusive - but that is not checked so may behave unexpectedly if you mix them): + +Note that when ANSI colour codes are used "unistd.h" must be includable - along with a definition of ```isatty()``` + +Typically you should place the ```#define``` before #including "catch.hpp" in your main source file - but if you prefer you can define it for your whole project by whatever your IDE or build system provides for you to do so. + +## Console width + + CATCH_CONFIG_CONSOLE_WIDTH = x // where x is a number + +Catch formats output intended for the console to fit within a fixed number of characters. This is especially important as indentation is used extensively and uncontrolled line wraps break this. +By default a console width of 80 is assumed but this can be controlled by defining the above identifier to be a different value. + +## stdout + + CATCH_CONFIG_NOSTDOUT + +To support platforms that do not provide `std::cout`, `std::cerr` and +`std::clog`, Catch does not usem the directly, but rather calls +`Catch::cout`, `Catch::cerr` and `Catch::clog`. You can replace their +implementation by defining `CATCH_CONFIG_NOSTDOUT` and implementing +them yourself, their signatures are: + + std::ostream& cout(); + std::ostream& cerr(); + std::ostream& clog(); + +[You can see an example of replacing these functions here.]( +../examples/231-Cfg-OutputStreams.cpp) + + +## Fallback stringifier + +By default, when Catch's stringification machinery has to stringify +a type that does not specialize `StringMaker`, does not overload `operator<<`, +is not an enumeration and is not a range, it uses `"{?}"`. This can be +overridden by defining `CATCH_CONFIG_FALLBACK_STRINGIFIER` to name of a +function that should perform the stringification instead. + +All types that do not provide `StringMaker` specialization or `operator<<` +overload will be sent to this function (this includes enums and ranges). +The provided function must return `std::string` and must accept any type, +e.g. via overloading. + +_Note that if the provided function does not handle a type and this type +requires to be stringified, the compilation will fail._ + + +## Default reporter + +Catch's default reporter can be changed by defining macro +`CATCH_CONFIG_DEFAULT_REPORTER` to string literal naming the desired +default reporter. + +This means that defining `CATCH_CONFIG_DEFAULT_REPORTER` to `"console"` +is equivalent with the out-of-the-box experience. + + +## C++11 toggles + + CATCH_CONFIG_CPP11_TO_STRING // Use `std::to_string` + +Because we support platforms whose standard library does not contain +`std::to_string`, it is possible to force Catch to use a workaround +based on `std::stringstream`. On platforms other than Android, +the default is to use `std::to_string`. On Android, the default is to +use the `stringstream` workaround. As always, it is possible to override +Catch's selection, by defining either `CATCH_CONFIG_CPP11_TO_STRING` or +`CATCH_CONFIG_NO_CPP11_TO_STRING`. + + +## C++17 toggles + + CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS // Use std::uncaught_exceptions instead of std::uncaught_exception + CATCH_CONFIG_CPP17_STRING_VIEW // Override std::string_view support detection(Catch provides a StringMaker specialization by default) + CATCH_CONFIG_CPP17_VARIANT // Override std::variant support detection (checked by CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER) + CATCH_CONFIG_CPP17_OPTIONAL // Override std::optional support detection (checked by CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER) + CATCH_CONFIG_CPP17_BYTE // Override std::byte support detection (Catch provides a StringMaker specialization by default) + +> `CATCH_CONFIG_CPP17_STRING_VIEW` was [introduced](https://github.com/catchorg/Catch2/issues/1376) in Catch 2.4.1. + +Catch contains basic compiler/standard detection and attempts to use +some C++17 features whenever appropriate. This automatic detection +can be manually overridden in both directions, that is, a feature +can be enabled by defining the macro in the table above, and disabled +by using `_NO_` in the macro, e.g. `CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS`. + + +## Other toggles + + CATCH_CONFIG_COUNTER // Use __COUNTER__ to generate unique names for test cases + CATCH_CONFIG_WINDOWS_SEH // Enable SEH handling on Windows + CATCH_CONFIG_FAST_COMPILE // Sacrifices some (rather minor) features for compilation speed + CATCH_CONFIG_DISABLE_MATCHERS // Do not compile Matchers in this compilation unit + CATCH_CONFIG_POSIX_SIGNALS // Enable handling POSIX signals + CATCH_CONFIG_WINDOWS_CRTDBG // Enable leak checking using Windows's CRT Debug Heap + CATCH_CONFIG_DISABLE_STRINGIFICATION // Disable stringifying the original expression + CATCH_CONFIG_DISABLE // Disables assertions and test case registration + CATCH_CONFIG_WCHAR // Enables use of wchart_t + CATCH_CONFIG_EXPERIMENTAL_REDIRECT // Enables the new (experimental) way of capturing stdout/stderr + CATCH_CONFIG_ENABLE_BENCHMARKING // Enables the integrated benchmarking features (has a significant effect on compilation speed) + CATCH_CONFIG_USE_ASYNC // Force parallel statistical processing of samples during benchmarking + CATCH_CONFIG_ANDROID_LOGWRITE // Use android's logging system for debug output + CATCH_CONFIG_GLOBAL_NEXTAFTER // Use nextafter{,f,l} instead of std::nextafter + +> [`CATCH_CONFIG_ANDROID_LOGWRITE`](https://github.com/catchorg/Catch2/issues/1743) and [`CATCH_CONFIG_GLOBAL_NEXTAFTER`](https://github.com/catchorg/Catch2/pull/1739) were introduced in Catch 2.10.0 + +Currently Catch enables `CATCH_CONFIG_WINDOWS_SEH` only when compiled with MSVC, because some versions of MinGW do not have the necessary Win32 API support. + +`CATCH_CONFIG_POSIX_SIGNALS` is on by default, except when Catch is compiled under `Cygwin`, where it is disabled by default (but can be force-enabled by defining `CATCH_CONFIG_POSIX_SIGNALS`). + +`CATCH_CONFIG_WINDOWS_CRTDBG` is off by default. If enabled, Windows's CRT is used to check for memory leaks, and displays them after the tests finish running. + +`CATCH_CONFIG_WCHAR` is on by default, but can be disabled. Currently +it is only used in support for DJGPP cross-compiler. + +With the exception of `CATCH_CONFIG_EXPERIMENTAL_REDIRECT`, +these toggles can be disabled by using `_NO_` form of the toggle, +e.g. `CATCH_CONFIG_NO_WINDOWS_SEH`. + +### `CATCH_CONFIG_FAST_COMPILE` +This compile-time flag speeds up compilation of assertion macros by ~20%, +by disabling the generation of assertion-local try-catch blocks for +non-exception family of assertion macros ({`REQUIRE`,`CHECK`}{``,`_FALSE`, `_THAT`}). +This disables translation of exceptions thrown under these assertions, but +should not lead to false negatives. + +`CATCH_CONFIG_FAST_COMPILE` has to be either defined, or not defined, +in all translation units that are linked into single test binary. + +### `CATCH_CONFIG_DISABLE_MATCHERS` +When `CATCH_CONFIG_DISABLE_MATCHERS` is defined, all mentions of Catch's Matchers are ifdef-ed away from the translation unit. Doing so will speed up compilation of that TU. + +_Note: If you define `CATCH_CONFIG_DISABLE_MATCHERS` in the same file as Catch's main is implemented, your test executable will fail to link if you use Matchers anywhere._ + +### `CATCH_CONFIG_DISABLE_STRINGIFICATION` +This toggle enables a workaround for VS 2017 bug. For details see [known limitations](limitations.md#visual-studio-2017----raw-string-literal-in-assert-fails-to-compile). + +### `CATCH_CONFIG_DISABLE` +This toggle removes most of Catch from given file. This means that `TEST_CASE`s are not registered and assertions are turned into no-ops. Useful for keeping tests within implementation files (ie for functions with internal linkage), instead of in external files. + +This feature is considered experimental and might change at any point. + +_Inspired by Doctest's `DOCTEST_CONFIG_DISABLE`_ + +## Windows header clutter + +On Windows Catch includes `windows.h`. To minimize global namespace clutter in the implementation file, it defines `NOMINMAX` and `WIN32_LEAN_AND_MEAN` before including it. You can control this behaviour via two macros: + + CATCH_CONFIG_NO_NOMINMAX // Stops Catch from using NOMINMAX macro + CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN // Stops Catch from using WIN32_LEAN_AND_MEAN macro + + +## Enabling stringification + +By default, Catch does not stringify some types from the standard library. This is done to avoid dragging in various standard library headers by default. However, Catch does contain these and can be configured to provide them, using these macros: + + CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER // Provide StringMaker specialization for std::pair + CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER // Provide StringMaker specialization for std::tuple + CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER // Provide StringMaker specialization for std::chrono::duration, std::chrono::timepoint + CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER // Provide StringMaker specialization for std::variant, std::monostate (on C++17) + CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER // Provide StringMaker specialization for std::optional (on C++17) + CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS // Defines all of the above + +> `CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER` was [introduced](https://github.com/catchorg/Catch2/issues/1380) in Catch 2.4.1. + +> `CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER` was [introduced](https://github.com/catchorg/Catch2/issues/1510) in Catch 2.6.0. + +## Disabling exceptions + +> Introduced in Catch 2.4.0. + +By default, Catch2 uses exceptions to signal errors and to abort tests +when an assertion from the `REQUIRE` family of assertions fails. We also +provide an experimental support for disabling exceptions. Catch2 should +automatically detect when it is compiled with exceptions disabled, but +it can be forced to compile without exceptions by defining + + CATCH_CONFIG_DISABLE_EXCEPTIONS + +Note that when using Catch2 without exceptions, there are 2 major +limitations: + +1) If there is an error that would normally be signalled by an exception, +the exception's message will instead be written to `Catch::cerr` and +`std::terminate` will be called. +2) If an assertion from the `REQUIRE` family of macros fails, +`std::terminate` will be called after the active reporter returns. + + +There is also a customization point for the exact behaviour of what +happens instead of exception being thrown. To use it, define + + CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER + +and provide a definition for this function: + +```cpp +namespace Catch { + [[noreturn]] + void throw_exception(std::exception const&); +} +``` + +## Overriding Catch's debug break (`-b`) + +> [Introduced](https://github.com/catchorg/Catch2/pull/1846) in Catch 2.11.2. + +You can override Catch2's break-into-debugger code by defining the +`CATCH_BREAK_INTO_DEBUGGER()` macro. This can be used if e.g. Catch2 does +not know your platform, or your platform is misdetected. + +The macro will be used as is, that is, `CATCH_BREAK_INTO_DEBUGGER();` +must compile and must break into debugger. + + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/contributing.md b/lib/Catch2/docs/contributing.md new file mode 100644 index 0000000000..f23e3a1161 --- /dev/null +++ b/lib/Catch2/docs/contributing.md @@ -0,0 +1,231 @@ + +# Contributing to Catch2 + +**Contents**
+[Using Git(Hub)](#using-github)
+[Testing your changes](#testing-your-changes)
+[Writing documentation](#writing-documentation)
+[Writing code](#writing-code)
+[CoC](#coc)
+ +So you want to contribute something to Catch2? That's great! Whether it's +a bug fix, a new feature, support for additional compilers - or just +a fix to the documentation - all contributions are very welcome and very +much appreciated. Of course so are bug reports, other comments, and +questions, but generally it is a better idea to ask questions in our +[Discord](https://discord.gg/4CWS9zD), than in the issue tracker. + + +This page covers some guidelines and helpful tips for contributing +to the codebase itself. + +## Using Git(Hub) + +Ongoing development happens in the `v2.x` branch for Catch2 v2, and in +`devel` for the next major version, v3. + +Commits should be small and atomic. A commit is atomic when, after it is +applied, the codebase, tests and all, still works as expected. Small +commits are also preferred, as they make later operations with git history, +whether it is bisecting, reverting, or something else, easier. + +_When submitting a pull request please do not include changes to the +single include. This means do not include them in your git commits!_ + + +When addressing review comments in a MR, please do not rebase/squash the +commits immediately. Doing so makes it harder to review the new changes, +slowing down the process of merging a MR. Instead, when addressing review +comments, you should append new commits to the branch and only squash +them into other commits when the MR is ready to be merged. We recommend +creating new commits with `git commit --fixup` (or `--squash`) and then +later squashing them with `git rebase --autosquash` to make things easier. + + + +## Testing your changes + +_Note: Running Catch2's tests requires Python3_ + + +Catch2 has multiple layers of tests that are then run as part of our CI. +The most obvious one are the unit tests compiled into the `SelfTest` +binary. These are then used in "Approval tests", which run (almost) all +tests from `SelfTest` through a specific reporter and then compare the +generated output with a known good output ("Baseline"). By default, new +tests should be placed here. + +However, not all tests can be written as plain unit tests. For example, +checking that Catch2 orders tests randomly when asked to, and that this +random ordering is subset-invariant, is better done as an integration +test using an external check script. Catch2 integration tests are written +using CTest, either as a direct command invocation + pass/fail regex, +or by delegating the check to a Python script. + +There are also two more kinds of tests, examples and "ExtraTests". +Examples serve as a compilation test on the single-header distribution, +and present a small and self-contained snippets of using Catch2 for +writing tests. ExtraTests then are tests that either take a long time +to run, or require separate compilation, e.g. because of testing compile +time configuration options, and take a long time because of that. + +Both of these are compiled against the single-header distribution of +Catch2, and thus might require you to regenerate it manually. This is +done by calling the `generateSingleHeader.py` script in `scripts`. + +Examples and ExtraTests are not compiled by default. To compile them, +add `-DCATCH_BUILD_EXAMPLES=ON` and `-DCATCH_BUILD_EXTRA_TESTS=ON` to +the invocation of CMake configuration step. + +Bringing this all together, the steps below should configure, build, +and run all tests in the `Debug` compilation. + +1. Regenerate the single header distribution +``` +$ cd Catch2 +$ ./scripts/generateSingleHeader.py +``` +2. Configure the full test build +``` +$ cmake -Bdebug-build -H. -DCMAKE_BUILD_TYPE=Debug -DCATCH_BUILD_EXAMPLES=ON -DCATCH_BUILD_EXTRA_TESTS=ON +``` +3. Run the actual build +``` +$ cmake --build debug-build +``` +4. Run the tests using CTest +``` +$ cd debug-build +$ ctest -j 4 --output-on-failure -C Debug +``` + + +## Writing documentation + +If you have added new feature to Catch2, it needs documentation, so that +other people can use it as well. This section collects some technical +information that you will need for updating Catch2's documentation, and +possibly some generic advise as well. + +### Technicalities + +First, the technicalities: + +* If you have introduced a new document, there is a simple template you +should use. It provides you with the top anchor mentioned to link to +(more below), and also with a backlink to the top of the documentation: +```markdown + +# Cool feature + +Text that explains how to use the cool feature. + + +--- + +[Home](Readme.md#top) +``` + +* Crosslinks to different pages should target the `top` anchor, like this +`[link to contributing](contributing.md#top)`. + +* We introduced version tags to the documentation, which show users in +which version a specific feature was introduced. This means that newly +written documentation should be tagged with a placeholder, that will +be replaced with the actual version upon release. There are 2 styles +of placeholders used through the documentation, you should pick one that +fits your text better (if in doubt, take a look at the existing version +tags for other features). + * `> [Introduced](link-to-issue-or-PR) in Catch X.Y.Z` - this + placeholder is usually used after a section heading + * `> X (Y and Z) was [introduced](link-to-issue-or-PR) in Catch X.Y.Z` + - this placeholder is used when you need to tag a subpart of something, + e.g. a list + +* For pages with more than 4 subheadings, we provide a table of contents +(ToC) at the top of the page. Because GitHub markdown does not support +automatic generation of ToC, it has to be handled semi-manually. Thus, +if you've added a new subheading to some page, you should add it to the +ToC. This can be done either manually, or by running the +`updateDocumentToC.py` script in the `scripts/` folder. + +### Contents + +Now, for some content tips: + +* Usage examples are good. However, having large code snippets inline +can make the documentation less readable, and so the inline snippets +should be kept reasonably short. To provide more complex compilable +examples, consider adding new .cpp file to `examples/`. + +* Don't be afraid to introduce new pages. The current documentation +tends towards long pages, but a lot of that is caused by legacy, and +we know that some of the pages are overly big and unfocused. + +* When adding information to an existing page, please try to keep your +formatting, style and changes consistent with the rest of the page. + +* Any documentation has multiple different audiences, that desire +different information from the text. The 3 basic user-types to try and +cover are: + * A beginner to Catch2, who requires closer guidance for the usage of Catch2. + * Advanced user of Catch2, who want to customize their usage. + * Experts, looking for full reference of Catch2's capabilities. + + +## Writing code + +If want to contribute code, this section contains some simple rules +and tips on things like code formatting, code constructions to avoid, +and so on. + + +### Formatting + +To make code formatting simpler for the contributors, Catch2 provides +its own config for `clang-format`. However, because it is currently +impossible to replicate existing Catch2's formatting in clang-format, +using it to reformat a whole file would cause massive diffs. To keep +the size of your diffs reasonable, you should only use clang-format +on the newly changed code. + + +### Code constructs to watch out for + +This section is a (sadly incomplete) listing of various constructs that +are problematic and are not always caught by our CI infrastructure. + + +#### Naked exceptions and exceptions-related function + +If you are throwing an exception, it should be done via `CATCH_ERROR` +or `CATCH_RUNTIME_ERROR` in `catch_enforce.h`. These macros will handle +the differences between compilation with or without exceptions for you. +However, some platforms (IAR) also have problems with exceptions-related +functions, such as `std::current_exceptions`. We do not have IAR in our +CI, but luckily there should not be too many reasons to use these. +However, if you do, they should be kept behind a +`CATCH_CONFIG_DISABLE_EXCEPTIONS` macro. + + +#### Unqualified usage of functions from C's stdlib + +If you are using a function from C's stdlib, please include the header +as `` and call the function qualified. The common knowledge that +there is no difference is wrong, QNX and VxWorks won't compile if you +include the header as `` and call the function unqualified. + + +## CoC + +This project has a [CoC](../CODE_OF_CONDUCT.md). Please adhere to it +while contributing to Catch2. + +----------- + +_This documentation will always be in-progress as new information comes +up, but we are trying to keep it as up to date as possible._ + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/deprecations.md b/lib/Catch2/docs/deprecations.md new file mode 100644 index 0000000000..e496c27e53 --- /dev/null +++ b/lib/Catch2/docs/deprecations.md @@ -0,0 +1,144 @@ + +# Deprecations and incoming changes + +This page documents current deprecations and upcoming planned changes +inside Catch2. The difference between these is that a deprecated feature +will be removed, while a planned change to a feature means that the +feature will behave differently, but will still be present. Obviously, +either of these is a breaking change, and thus will not happen until +at least the next major release. + + +## Deprecations + +### `--list-*` return values + +The return codes of the `--list-*` family of command line arguments +will no longer be equal to the number of tests/tags/etc found, instead +it will be 0 for success and non-zero for failure. + + +### `--list-test-names-only` + +`--list-test-names-only` command line argument will be removed. + + +### `ANON_TEST_CASE` + +`ANON_TEST_CASE` is scheduled for removal, as it can be fully replaced +by a `TEST_CASE` with no arguments. + + +### Secondary description amongst tags + +Currently, the tags part of `TEST_CASE` (and others) macro can also +contain text that is not part of tags. This text is then separated into +a "description" of the test case, but the description is then never used +apart from writing it out for `--list-tests -v high`. + +Because it isn't actually used nor documented, and brings complications +to Catch2's internals, description support will be removed. + +### SourceLineInfo::empty() + +There should be no reason to ever have an empty `SourceLineInfo`, so the +method will be removed. + + +### Composing lvalues of already composed matchers + +Because a significant bug in this use case has persisted for 2+ years +without a bug report, and to simplify the implementation, code that +composes lvalues of composed matchers will not compile. That is, +this code will no longer work: + +```cpp + auto m1 = Contains("string"); + auto m2 = Contains("random"); + auto composed1 = m1 || m2; + auto m3 = Contains("different"); + auto composed2 = composed1 || m3; + REQUIRE_THAT(foo(), !composed1); + REQUIRE_THAT(foo(), composed2); +``` + +Instead you will have to write this: + +```cpp + auto m1 = Contains("string"); + auto m2 = Contains("random"); + auto m3 = Contains("different"); + REQUIRE_THAT(foo(), !(m1 || m2)); + REQUIRE_THAT(foo(), m1 || m2 || m3); +``` + +### `ParseAndAddCatchTests.cmake` + +The CMake/CTest integration using `ParseAndAddCatchTests.cmake` is deprecated, +as it can be replaced by `Catch.cmake` that provides the function +`catch_discover_tests` to get tests directly from a CMake target via the +command line interface instead of parsing C++ code with regular expressions. + + +## Planned changes + + +### Reporter verbosities + +The current implementation of verbosities, where the reporter is checked +up-front whether it supports the requested verbosity, is fundamentally +misguided and will be changed. The new implementation will no longer check +whether the specified reporter supports the requested verbosity, instead +it will be up to the reporters to deal with verbosities as they see fit +(with an expectation that unsupported verbosities will be, at most, +warnings, but not errors). + + +### Output format of `--list-*` command line parameters + +The various list operations will be piped through reporters. This means +that e.g. XML reporter will write the output as machine-parseable XML, +while the Console reporter will keep the current, human-oriented output. + + +### `CHECKED_IF` and `CHECKED_ELSE` + +To make the `CHECKED_IF` and `CHECKED_ELSE` macros more useful, they will +be marked as "OK to fail" (`Catch::ResultDisposition::SuppressFail` flag +will be added), which means that their failure will not fail the test, +making the `else` actually useful. + + +### Change semantics of `[.]` and tag exclusion + +Currently, given these 2 tests +```cpp +TEST_CASE("A", "[.][foo]") {} +TEST_CASE("B", "[.][bar]") {} +``` +specifying `[foo]` as the testspec will run test "A" and specifying +`~[foo]` will run test "B", even though it is hidden. Also, specifying +`~[baz]` will run both tests. This behaviour is often surprising and will +be changed so that hidden tests are included in a run only if they +positively match a testspec. + + +### Console Colour API + +The API for Catch2's console colour will be changed to take an extra +argument, the stream to which the colour code should be applied. + + +### Type erasure in the `PredicateMatcher` + +Currently, the `PredicateMatcher` uses `std::function` for type erasure, +so that type of the matcher is always `PredicateMatcher`, regardless +of the type of the predicate. Because of the high compilation overhead +of `std::function`, and the fact that the type erasure is used only rarely, +`PredicateMatcher` will no longer be type erased in the future. Instead, +the predicate type will be made part of the PredicateMatcher's type. + + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/event-listeners.md b/lib/Catch2/docs/event-listeners.md new file mode 100644 index 0000000000..6231100667 --- /dev/null +++ b/lib/Catch2/docs/event-listeners.md @@ -0,0 +1,75 @@ + +# Event Listeners + +A `Listener` is a class you can register with Catch that will then be passed events, +such as a test case starting or ending, as they happen during a test run. +`Listeners` are actually types of `Reporters`, with a few small differences: + +1. Once registered in code they are automatically used - you don't need to specify them on the command line +2. They are called in addition to (just before) any reporters, and you can register multiple listeners. +3. They derive from `Catch::TestEventListenerBase`, which has default stubs for all the events, +so you are not forced to implement events you're not interested in. +4. You register a listener with `CATCH_REGISTER_LISTENER` + + +## Implementing a Listener +Simply derive a class from `Catch::TestEventListenerBase` and implement the methods you are interested in, either in +the main source file (i.e. the one that defines `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER`), or in a +file that defines `CATCH_CONFIG_EXTERNAL_INTERFACES`. + +Then register it using `CATCH_REGISTER_LISTENER`. + +For example ([complete source code](../examples/210-Evt-EventListeners.cpp)): + +```c++ +#define CATCH_CONFIG_MAIN +#include "catch.hpp" + +struct MyListener : Catch::TestEventListenerBase { + + using TestEventListenerBase::TestEventListenerBase; // inherit constructor + + void testCaseStarting( Catch::TestCaseInfo const& testInfo ) override { + // Perform some setup before a test case is run + } + + void testCaseEnded( Catch::TestCaseStats const& testCaseStats ) override { + // Tear-down after a test case is run + } +}; +CATCH_REGISTER_LISTENER( MyListener ) +``` + +_Note that you should not use any assertion macros within a Listener!_ + +## Events that can be hooked + +The following are the methods that can be overridden in the Listener: + +```c++ +// The whole test run, starting and ending +virtual void testRunStarting( TestRunInfo const& testRunInfo ); +virtual void testRunEnded( TestRunStats const& testRunStats ); + +// Test cases starting and ending +virtual void testCaseStarting( TestCaseInfo const& testInfo ); +virtual void testCaseEnded( TestCaseStats const& testCaseStats ); + +// Sections starting and ending +virtual void sectionStarting( SectionInfo const& sectionInfo ); +virtual void sectionEnded( SectionStats const& sectionStats ); + +// Assertions before/ after +virtual void assertionStarting( AssertionInfo const& assertionInfo ); +virtual bool assertionEnded( AssertionStats const& assertionStats ); + +// A test is being skipped (because it is "hidden") +virtual void skipTest( TestCaseInfo const& testInfo ); +``` + +More information about the events (e.g. name of the test case) is contained in the structs passed as arguments - +just look in the source code to see what fields are available. + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/generators.md b/lib/Catch2/docs/generators.md new file mode 100644 index 0000000000..d48cf06b4f --- /dev/null +++ b/lib/Catch2/docs/generators.md @@ -0,0 +1,219 @@ + +# Data Generators + +> Introduced in Catch 2.6.0. + +Data generators (also known as _data driven/parametrized test cases_) +let you reuse the same set of assertions across different input values. +In Catch2, this means that they respect the ordering and nesting +of the `TEST_CASE` and `SECTION` macros, and their nested sections +are run once per each value in a generator. + +This is best explained with an example: +```cpp +TEST_CASE("Generators") { + auto i = GENERATE(1, 3, 5); + REQUIRE(is_odd(i)); +} +``` + +The "Generators" `TEST_CASE` will be entered 3 times, and the value of +`i` will be 1, 3, and 5 in turn. `GENERATE`s can also be used multiple +times at the same scope, in which case the result will be a cartesian +product of all elements in the generators. This means that in the snippet +below, the test case will be run 6 (2\*3) times. + +```cpp +TEST_CASE("Generators") { + auto i = GENERATE(1, 2); + auto j = GENERATE(3, 4, 5); +} +``` + +There are 2 parts to generators in Catch2, the `GENERATE` macro together +with the already provided generators, and the `IGenerator` interface +that allows users to implement their own generators. + + +## Combining `GENERATE` and `SECTION`. + +`GENERATE` can be seen as an implicit `SECTION`, that goes from the place +`GENERATE` is used, to the end of the scope. This can be used for various +effects. The simplest usage is shown below, where the `SECTION` "one" +runs 4 (2\*2) times, and `SECTION` "two" is run 6 times (2\*3). + +```cpp +TEST_CASE("Generators") { + auto i = GENERATE(1, 2); + SECTION("one") { + auto j = GENERATE(-3, -2); + REQUIRE(j < i); + } + SECTION("two") { + auto k = GENERATE(4, 5, 6); + REQUIRE(i != k); + } +} +``` + +The specific order of the `SECTION`s will be "one", "one", "two", "two", +"two", "one"... + + +The fact that `GENERATE` introduces a virtual `SECTION` can also be used +to make a generator replay only some `SECTION`s, without having to +explicitly add a `SECTION`. As an example, the code below reports 3 +assertions, because the "first" section is run once, but the "second" +section is run twice. + +```cpp +TEST_CASE("GENERATE between SECTIONs") { + SECTION("first") { REQUIRE(true); } + auto _ = GENERATE(1, 2); + SECTION("second") { REQUIRE(true); } +} +``` + +This can lead to surprisingly complex test flows. As an example, the test +below will report 14 assertions: + +```cpp +TEST_CASE("Complex mix of sections and generates") { + auto i = GENERATE(1, 2); + SECTION("A") { + SUCCEED("A"); + } + auto j = GENERATE(3, 4); + SECTION("B") { + SUCCEED("B"); + } + auto k = GENERATE(5, 6); + SUCCEED(); +} +``` + +> The ability to place `GENERATE` between two `SECTION`s was [introduced](https://github.com/catchorg/Catch2/issues/1938) in Catch 2.13.0. + +## Provided generators + +Catch2's provided generator functionality consists of three parts, + +* `GENERATE` macro, that serves to integrate generator expression with +a test case, +* 2 fundamental generators + * `SingleValueGenerator` -- contains only single element + * `FixedValuesGenerator` -- contains multiple elements +* 5 generic generators that modify other generators + * `FilterGenerator` -- filters out elements from a generator + for which the predicate returns "false" + * `TakeGenerator` -- takes first `n` elements from a generator + * `RepeatGenerator` -- repeats output from a generator `n` times + * `MapGenerator` -- returns the result of applying `Func` + on elements from a different generator + * `ChunkGenerator` -- returns chunks (inside `std::vector`) of n elements from a generator +* 4 specific purpose generators + * `RandomIntegerGenerator` -- generates random Integrals from range + * `RandomFloatGenerator` -- generates random Floats from range + * `RangeGenerator` -- generates all values inside an arithmetic range + * `IteratorGenerator` -- copies and returns values from an iterator range + +> `ChunkGenerator`, `RandomIntegerGenerator`, `RandomFloatGenerator` and `RangeGenerator` were introduced in Catch 2.7.0. + +> `IteratorGenerator` was introduced in Catch 2.10.0. + +The generators also have associated helper functions that infer their +type, making their usage much nicer. These are + +* `value(T&&)` for `SingleValueGenerator` +* `values(std::initializer_list)` for `FixedValuesGenerator` +* `table(std::initializer_list>)` for `FixedValuesGenerator>` +* `filter(predicate, GeneratorWrapper&&)` for `FilterGenerator` +* `take(count, GeneratorWrapper&&)` for `TakeGenerator` +* `repeat(repeats, GeneratorWrapper&&)` for `RepeatGenerator` +* `map(func, GeneratorWrapper&&)` for `MapGenerator` (map `U` to `T`, deduced from `Func`) +* `map(func, GeneratorWrapper&&)` for `MapGenerator` (map `U` to `T`) +* `chunk(chunk-size, GeneratorWrapper&&)` for `ChunkGenerator` +* `random(IntegerOrFloat a, IntegerOrFloat b)` for `RandomIntegerGenerator` or `RandomFloatGenerator` +* `range(Arithemtic start, Arithmetic end)` for `RangeGenerator` with a step size of `1` +* `range(Arithmetic start, Arithmetic end, Arithmetic step)` for `RangeGenerator` with a custom step size +* `from_range(InputIterator from, InputIterator to)` for `IteratorGenerator` +* `from_range(Container const&)` for `IteratorGenerator` + +> `chunk()`, `random()` and both `range()` functions were introduced in Catch 2.7.0. + +> `from_range` has been introduced in Catch 2.10.0 + +> `range()` for floating point numbers has been introduced in Catch 2.11.0 + +And can be used as shown in the example below to create a generator +that returns 100 odd random number: + +```cpp +TEST_CASE("Generating random ints", "[example][generator]") { + SECTION("Deducing functions") { + auto i = GENERATE(take(100, filter([](int i) { return i % 2 == 1; }, random(-100, 100)))); + REQUIRE(i > -100); + REQUIRE(i < 100); + REQUIRE(i % 2 == 1); + } +} +``` + + +Apart from registering generators with Catch2, the `GENERATE` macro has +one more purpose, and that is to provide simple way of generating trivial +generators, as seen in the first example on this page, where we used it +as `auto i = GENERATE(1, 2, 3);`. This usage converted each of the three +literals into a single `SingleValueGenerator` and then placed them all in +a special generator that concatenates other generators. It can also be +used with other generators as arguments, such as `auto i = GENERATE(0, 2, +take(100, random(300, 3000)));`. This is useful e.g. if you know that +specific inputs are problematic and want to test them separately/first. + +**For safety reasons, you cannot use variables inside the `GENERATE` macro. +This is done because the generator expression _will_ outlive the outside +scope and thus capturing references is dangerous. If you need to use +variables inside the generator expression, make sure you thought through +the lifetime implications and use `GENERATE_COPY` or `GENERATE_REF`.** + +> `GENERATE_COPY` and `GENERATE_REF` were introduced in Catch 2.7.1. + +You can also override the inferred type by using `as` as the first +argument to the macro. This can be useful when dealing with string literals, +if you want them to come out as `std::string`: + +```cpp +TEST_CASE("type conversion", "[generators]") { + auto str = GENERATE(as{}, "a", "bb", "ccc"); + REQUIRE(str.size() > 0); +} +``` + +## Generator interface + +You can also implement your own generators, by deriving from the +`IGenerator` interface: + +```cpp +template +struct IGenerator : GeneratorUntypedBase { + // via GeneratorUntypedBase: + // Attempts to move the generator to the next element. + // Returns true if successful (and thus has another element that can be read) + virtual bool next() = 0; + + // Precondition: + // The generator is either freshly constructed or the last call to next() returned true + virtual T const& get() const = 0; +}; +``` + +However, to be able to use your custom generator inside `GENERATE`, it +will need to be wrapped inside a `GeneratorWrapper`. +`GeneratorWrapper` is a value wrapper around a +`std::unique_ptr>`. + +For full example of implementing your own generator, look into Catch2's +examples, specifically +[Generators: Create your own generator](../examples/300-Gen-OwnGenerator.cpp). + diff --git a/lib/Catch2/docs/limitations.md b/lib/Catch2/docs/limitations.md new file mode 100644 index 0000000000..65483b87bb --- /dev/null +++ b/lib/Catch2/docs/limitations.md @@ -0,0 +1,187 @@ + +# Known limitations + +Over time, some limitations of Catch2 emerged. Some of these are due +to implementation details that cannot be easily changed, some of these +are due to lack of development resources on our part, and some of these +are due to plain old 3rd party bugs. + + +## Implementation limits +### Sections nested in loops + +If you are using `SECTION`s inside loops, you have to create them with +different name per loop's iteration. The recommended way to do so is to +incorporate the loop's counter into section's name, like so: + +```cpp +TEST_CASE( "Looped section" ) { + for (char i = '0'; i < '5'; ++i) { + SECTION(std::string("Looped section ") + i) { + SUCCEED( "Everything is OK" ); + } + } +} +``` + +or with a `DYNAMIC_SECTION` macro (that was made for exactly this purpose): + +```cpp +TEST_CASE( "Looped section" ) { + for (char i = '0'; i < '5'; ++i) { + DYNAMIC_SECTION( "Looped section " << i) { + SUCCEED( "Everything is OK" ); + } + } +} +``` + +### Tests might be run again if last section fails + +If the last section in a test fails, it might be run again. This is because +Catch2 discovers `SECTION`s dynamically, as they are about to run, and +if the last section in test case is aborted during execution (e.g. via +the `REQUIRE` family of macros), Catch2 does not know that there are no +more sections in that test case and must run the test case again. + + +### MinGW/CygWin compilation (linking) is extremely slow + +Compiling Catch2 with MinGW can be exceedingly slow, especially during +the linking step. As far as we can tell, this is caused by deficiencies +in its default linker. If you can tell MinGW to instead use lld, via +`-fuse-ld=lld`, the link time should drop down to reasonable length +again. + + +## Features +This section outlines some missing features, what is their status and their possible workarounds. + +### Thread safe assertions +Catch2's assertion macros are not thread safe. This does not mean that +you cannot use threads inside Catch's test, but that only single thread +can interact with Catch's assertions and other macros. + +This means that this is ok +```cpp + std::vector threads; + std::atomic cnt{ 0 }; + for (int i = 0; i < 4; ++i) { + threads.emplace_back([&]() { + ++cnt; ++cnt; ++cnt; ++cnt; + }); + } + for (auto& t : threads) { t.join(); } + REQUIRE(cnt == 16); +``` +because only one thread passes the `REQUIRE` macro and this is not +```cpp + std::vector threads; + std::atomic cnt{ 0 }; + for (int i = 0; i < 4; ++i) { + threads.emplace_back([&]() { + ++cnt; ++cnt; ++cnt; ++cnt; + CHECK(cnt == 16); + }); + } + for (auto& t : threads) { t.join(); } + REQUIRE(cnt == 16); +``` + +Because C++11 provides the necessary tools to do this, we are planning +to remove this limitation in the future. + +### Process isolation in a test +Catch does not support running tests in isolated (forked) processes. While this might in the future, the fact that Windows does not support forking and only allows full-on process creation and the desire to keep code as similar as possible across platforms, mean that this is likely to take significant development time, that is not currently available. + +### Running multiple tests in parallel +Catch's test execution is strictly serial. If you find yourself with a test suite that takes too long to run and you want to make it parallel, there are 2 feasible solutions + * You can split your tests into multiple binaries and then run these binaries in parallel. + * You can have Catch list contained test cases and then run the same test binary multiple times in parallel, passing each instance list of test cases it should run. + +Both of these solutions have their problems, but should let you wring parallelism out of your test suite. + +## 3rd party bugs +This section outlines known bugs in 3rd party components (this means compilers, standard libraries, standard runtimes). + +### Visual Studio 2017 -- raw string literal in assert fails to compile +There is a known bug in Visual Studio 2017 (VC 15), that causes compilation error when preprocessor attempts to stringize a raw string literal (`#` preprocessor is applied to it). This snippet is sufficient to trigger the compilation error: +```cpp +#define CATCH_CONFIG_MAIN +#include "catch.hpp" + +TEST_CASE("test") { + CHECK(std::string(R"("\)") == "\"\\"); +} +``` + +Catch provides a workaround, it is possible to disable stringification of original expressions by defining `CATCH_CONFIG_DISABLE_STRINGIFICATION`: +```cpp +#define CATCH_CONFIG_FAST_COMPILE +#define CATCH_CONFIG_DISABLE_STRINGIFICATION +#include "catch.hpp" + +TEST_CASE("test") { + CHECK(std::string(R"("\)") == "\"\\"); +} +``` + +_Do note that this changes the output somewhat_ +``` +catchwork\test1.cpp(6): +PASSED: + CHECK( Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION ) +with expansion: + ""\" == ""\" +``` + +### Visual Studio 2015 -- Alignment compilation error (C2718) + +VS 2015 has a known bug, where `declval` can cause compilation error +if `T` has alignment requirements that it cannot meet. + + +A workaround is to explicitly specialize `Catch::is_range` for given +type (this avoids code path that uses `declval` in a SFINAE context). + + +### Visual Studio 2015 -- Wrong line number reported in debug mode +VS 2015 has a known bug where `__LINE__` macro can be improperly expanded under certain circumstances, while compiling multi-file project in Debug mode. + +A workaround is to compile the binary in Release mode. + +### Clang/G++ -- skipping leaf sections after an exception +Some versions of `libc++` and `libstdc++` (or their runtimes) have a bug with `std::uncaught_exception()` getting stuck returning `true` after rethrow, even if there are no active exceptions. One such case is this snippet, which skipped the sections "a" and "b", when compiled against `libcxxrt` from master +```cpp +#define CATCH_CONFIG_MAIN +#include + +TEST_CASE("a") { + CHECK_THROWS(throw 3); +} + +TEST_CASE("b") { + int i = 0; + SECTION("a") { i = 1; } + SECTION("b") { i = 2; } + CHECK(i > 0); +} +``` + +If you are seeing a problem like this, i.e. a weird test paths that trigger only under Clang with `libc++`, or only under very specific version of `libstdc++`, it is very likely you are seeing this. The only known workaround is to use a fixed version of your standard library. + +### Clang/G++ -- `Matches` string matcher always returns false +This is a bug in `libstdc++-4.8`, where all matching methods from `` return false. Since `Matches` uses `` internally, if the underlying implementation does not work, it doesn't work either. + +Workaround: Use newer version of `libstdc++`. + + +### libstdc++, `_GLIBCXX_DEBUG` macro and random ordering of tests + +Running a Catch2 binary compiled against libstdc++ with `_GLIBCXX_DEBUG` +macro defined with `--order rand` will cause a debug check to trigger and +abort the run due to self-assignment. +[This is a known bug inside libstdc++](https://stackoverflow.com/questions/22915325/avoiding-self-assignment-in-stdshuffle/23691322) + +Workaround: Don't use `--order rand` when compiling against debug-enabled +libstdc++. diff --git a/lib/Catch2/docs/list-of-examples.md b/lib/Catch2/docs/list-of-examples.md new file mode 100644 index 0000000000..c3514ed5b5 --- /dev/null +++ b/lib/Catch2/docs/list-of-examples.md @@ -0,0 +1,49 @@ + +# List of examples + +## Already available + +- Catch main: [Catch-provided main](../examples/000-CatchMain.cpp) +- Test Case: [Single-file](../examples/010-TestCase.cpp) +- Test Case: [Multiple-file 1](../examples/020-TestCase-1.cpp), [2](../examples/020-TestCase-2.cpp) +- Assertion: [REQUIRE, CHECK](../examples/030-Asn-Require-Check.cpp) +- Fixture: [Sections](../examples/100-Fix-Section.cpp) +- Fixture: [Class-based fixtures](../examples/110-Fix-ClassFixture.cpp) +- BDD: [SCENARIO, GIVEN, WHEN, THEN](../examples/120-Bdd-ScenarioGivenWhenThen.cpp) +- Report: [Catch-provided main](../examples/200-Rpt-CatchMain.cpp) +- Report: [TeamCity reporter](../examples/207-Rpt-TeamCityReporter.cpp) +- Listener: [Listeners](../examples/210-Evt-EventListeners.cpp) +- Configuration: [Provide your own output streams](../examples/231-Cfg-OutputStreams.cpp) +- Generators: [Create your own generator](../examples/300-Gen-OwnGenerator.cpp) +- Generators: [Use map to convert types in GENERATE expression](../examples/301-Gen-MapTypeConversion.cpp) +- Generators: [Run test with a table of input values](../examples/302-Gen-Table.cpp) +- Generators: [Use variables in generator expressions](../examples/310-Gen-VariablesInGenerators.cpp) +- Generators: [Use custom variable capture in generator expressions](../examples/311-Gen-CustomCapture.cpp) + + +## Planned + +- Assertion: [REQUIRE_THAT and Matchers](../examples/040-Asn-RequireThat.cpp) +- Assertion: [REQUIRE_NO_THROW](../examples/050-Asn-RequireNoThrow.cpp) +- Assertion: [REQUIRE_THROWS](../examples/050-Asn-RequireThrows.cpp) +- Assertion: [REQUIRE_THROWS_AS](../examples/070-Asn-RequireThrowsAs.cpp) +- Assertion: [REQUIRE_THROWS_WITH](../examples/080-Asn-RequireThrowsWith.cpp) +- Assertion: [REQUIRE_THROWS_MATCHES](../examples/090-Asn-RequireThrowsMatches.cpp) +- Floating point: [Approx - Comparisons](../examples/130-Fpt-Approx.cpp) +- Logging: [CAPTURE - Capture expression](../examples/140-Log-Capture.cpp) +- Logging: [INFO - Provide information with failure](../examples/150-Log-Info.cpp) +- Logging: [WARN - Issue warning](../examples/160-Log-Warn.cpp) +- Logging: [FAIL, FAIL_CHECK - Issue message and force failure/continue](../examples/170-Log-Fail.cpp) +- Logging: [SUCCEED - Issue message and continue](../examples/180-Log-Succeed.cpp) +- Report: [User-defined type](../examples/190-Rpt-ReportUserDefinedType.cpp) +- Report: [User-defined reporter](../examples/202-Rpt-UserDefinedReporter.cpp) +- Report: [Automake reporter](../examples/205-Rpt-AutomakeReporter.cpp) +- Report: [TAP reporter](../examples/206-Rpt-TapReporter.cpp) +- Report: [Multiple reporter](../examples/208-Rpt-MultipleReporters.cpp) +- Configuration: [Provide your own main()](../examples/220-Cfg-OwnMain.cpp) +- Configuration: [Compile-time configuration](../examples/230-Cfg-CompileTimeConfiguration.cpp) +- Configuration: [Run-time configuration](../examples/240-Cfg-RunTimeConfiguration.cpp) + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/logging.md b/lib/Catch2/docs/logging.md new file mode 100644 index 0000000000..476b1e0848 --- /dev/null +++ b/lib/Catch2/docs/logging.md @@ -0,0 +1,159 @@ + +# Logging macros + +Additional messages can be logged during a test case. Note that the messages logged with `INFO` are scoped and thus will not be reported if failure occurs in scope preceding the message declaration. An example: + +```cpp +TEST_CASE("Foo") { + INFO("Test case start"); + for (int i = 0; i < 2; ++i) { + INFO("The number is " << i); + CHECK(i == 0); + } +} + +TEST_CASE("Bar") { + INFO("Test case start"); + for (int i = 0; i < 2; ++i) { + INFO("The number is " << i); + CHECK(i == i); + } + CHECK(false); +} +``` +When the `CHECK` fails in the "Foo" test case, then two messages will be printed. +``` +Test case start +The number is 1 +``` +When the last `CHECK` fails in the "Bar" test case, then only one message will be printed: `Test case start`. + +## Logging without local scope + +> [Introduced](https://github.com/catchorg/Catch2/issues/1522) in Catch 2.7.0. + +`UNSCOPED_INFO` is similar to `INFO` with two key differences: + +- Lifetime of an unscoped message is not tied to its own scope. +- An unscoped message can be reported by the first following assertion only, regardless of the result of that assertion. + +In other words, lifetime of `UNSCOPED_INFO` is limited by the following assertion (or by the end of test case/section, whichever comes first) whereas lifetime of `INFO` is limited by its own scope. + +These differences make this macro useful for reporting information from helper functions or inner scopes. An example: + +```cpp +void print_some_info() { + UNSCOPED_INFO("Info from helper"); +} + +TEST_CASE("Baz") { + print_some_info(); + for (int i = 0; i < 2; ++i) { + UNSCOPED_INFO("The number is " << i); + } + CHECK(false); +} + +TEST_CASE("Qux") { + INFO("First info"); + UNSCOPED_INFO("First unscoped info"); + CHECK(false); + + INFO("Second info"); + UNSCOPED_INFO("Second unscoped info"); + CHECK(false); +} +``` + +"Baz" test case prints: +``` +Info from helper +The number is 0 +The number is 1 +``` + +With "Qux" test case, two messages will be printed when the first `CHECK` fails: +``` +First info +First unscoped info +``` + +"First unscoped info" message will be cleared after the first `CHECK`, while "First info" message will persist until the end of the test case. Therefore, when the second `CHECK` fails, three messages will be printed: +``` +First info +Second info +Second unscoped info +``` + +## Streaming macros + +All these macros allow heterogeneous sequences of values to be streaming using the insertion operator (```<<```) in the same way that std::ostream, std::cout, etc support it. + +E.g.: +```c++ +INFO( "The number is " << i ); +``` + +(Note that there is no initial ```<<``` - instead the insertion sequence is placed in parentheses.) +These macros come in three forms: + +**INFO(** _message expression_ **)** + +The message is logged to a buffer, but only reported with next assertions that are logged. This allows you to log contextual information in case of failures which is not shown during a successful test run (for the console reporter, without -s). Messages are removed from the buffer at the end of their scope, so may be used, for example, in loops. + +_Note that in Catch2 2.x.x `INFO` can be used without a trailing semicolon as there is a trailing semicolon inside macro. +This semicolon will be removed with next major version. It is highly advised to use a trailing semicolon after `INFO` macro._ + +**UNSCOPED_INFO(** _message expression_ **)** + +> [Introduced](https://github.com/catchorg/Catch2/issues/1522) in Catch 2.7.0. + +Similar to `INFO`, but messages are not limited to their own scope: They are removed from the buffer after each assertion, section or test case, whichever comes first. + +**WARN(** _message expression_ **)** + +The message is always reported but does not fail the test. + +**FAIL(** _message expression_ **)** + +The message is reported and the test case fails. + +**FAIL_CHECK(** _message expression_ **)** + +AS `FAIL`, but does not abort the test + +## Quickly capture value of variables or expressions + +**CAPTURE(** _expression1_, _expression2_, ... **)** + +Sometimes you just want to log a value of variable, or expression. For +convenience, we provide the `CAPTURE` macro, that can take a variable, +or an expression, and prints out that variable/expression and its value +at the time of capture. + +e.g. `CAPTURE( theAnswer );` will log message "theAnswer := 42", while +```cpp +int a = 1, b = 2, c = 3; +CAPTURE( a, b, c, a + b, c > b, a == 1); +``` +will log a total of 6 messages: +``` +a := 1 +b := 2 +c := 3 +a + b := 3 +c > b := true +a == 1 := true +``` + +You can also capture expressions that use commas inside parentheses +(e.g. function calls), brackets, or braces (e.g. initializers). To +properly capture expression that contains template parameters list +(in other words, it contains commas between angle brackets), you need +to enclose the expression inside parentheses: +`CAPTURE( (std::pair{1, 2}) );` + + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/matchers.md b/lib/Catch2/docs/matchers.md new file mode 100644 index 0000000000..bdb7dac473 --- /dev/null +++ b/lib/Catch2/docs/matchers.md @@ -0,0 +1,207 @@ + +# Matchers + +Matchers are an alternative way to do assertions which are easily extensible and composable. +This makes them well suited to use with more complex types (such as collections) or your own custom types. +Matchers were first popularised by the [Hamcrest](https://en.wikipedia.org/wiki/Hamcrest) family of frameworks. + +## In use + +Matchers are introduced with the `REQUIRE_THAT` or `CHECK_THAT` macros, which take two arguments. +The first argument is the thing (object or value) under test. The second part is a match _expression_, +which consists of either a single matcher or one or more matchers combined using `&&`, `||` or `!` operators. + +For example, to assert that a string ends with a certain substring: + + ```c++ +using Catch::Matchers::EndsWith; // or Catch::EndsWith +std::string str = getStringFromSomewhere(); +REQUIRE_THAT( str, EndsWith( "as a service" ) ); +``` + +The matcher objects can take multiple arguments, allowing more fine tuning. +The built-in string matchers, for example, take a second argument specifying whether the comparison is +case sensitive or not: + +```c++ +REQUIRE_THAT( str, EndsWith( "as a service", Catch::CaseSensitive::No ) ); + ``` + +And matchers can be combined: + +```c++ +REQUIRE_THAT( str, + EndsWith( "as a service" ) || + (StartsWith( "Big data" ) && !Contains( "web scale" ) ) ); +``` + +_The combining operators do not take ownership of the matcher objects. +This means that if you store the combined object, you have to ensure that +the matcher objects outlive its last use. What this means is that code +like this leads to a use-after-free and (hopefully) a crash:_ + +```cpp +TEST_CASE("Bugs, bugs, bugs", "[Bug]"){ + std::string str = "Bugs as a service"; + + auto match_expression = Catch::EndsWith( "as a service" ) || + (Catch::StartsWith( "Big data" ) && !Catch::Contains( "web scale" ) ); + REQUIRE_THAT(str, match_expression); +} +``` + + +## Built in matchers +Catch2 provides some matchers by default. They can be found in the +`Catch::Matchers::foo` namespace and are imported into the `Catch` +namespace as well. + +There are two parts to each of the built-in matchers, the matcher +type itself and a helper function that provides template argument +deduction when creating templated matchers. As an example, the matcher +for checking that two instances of `std::vector` are identical is +`EqualsMatcher`, but the user is expected to use the `Equals` +helper function instead. + + +### String matchers +The string matchers are `StartsWith`, `EndsWith`, `Contains`, `Equals` and `Matches`. The first four match a literal (sub)string against a result, while `Matches` takes and matches an ECMAScript regex. Do note that `Matches` matches the string as a whole, meaning that "abc" will not match against "abcd", but "abc.*" will. + +Each of the provided `std::string` matchers also takes an optional second argument, that decides case sensitivity (by-default, they are case sensitive). + + +### Vector matchers +Catch2 currently provides 5 built-in matchers that work on `std::vector`. +These are + + * `Contains` which checks whether a specified vector is present in the result + * `VectorContains` which checks whether a specified element is present in the result + * `Equals` which checks whether the result is exactly equal (order matters) to a specific vector + * `UnorderedEquals` which checks whether the result is equal to a specific vector under a permutation + * `Approx` which checks whether the result is "approx-equal" (order matters, but comparison is done via `Approx`) to a specific vector +> Approx matcher was [introduced](https://github.com/catchorg/Catch2/issues/1499) in Catch 2.7.2. + + +### Floating point matchers +Catch2 provides 3 matchers for working with floating point numbers. These +are `WithinAbsMatcher`, `WithinUlpsMatcher` and `WithinRelMatcher`. + +The `WithinAbsMatcher` matcher accepts floating point numbers that are +within a certain distance of target. It should be constructed with the +`WithinAbs(double target, double margin)` helper. + +The `WithinUlpsMatcher` matcher accepts floating point numbers that are +within a certain number of [ULPs](https://en.wikipedia.org/wiki/Unit_in_the_last_place) +of the target. Because ULP comparisons need to be done differently for +`float`s and for `double`s, there are two overloads of the helpers for +this matcher, `WithinULP(float target, int64_t ULPs)`, and +`WithinULP(double target, int64_t ULPs)`. + +The `WithinRelMatcher` matcher accepts floating point numbers that are +_approximately equal_ with the target number with some specific tolerance. +In other words, it checks that `|lhs - rhs| <= epsilon * max(|lhs|, |rhs|)`, +with special casing for `INFINITY` and `NaN`. There are _4_ overloads of +the helpers for this matcher, `WithinRel(double target, double margin)`, +`WithinRel(float target, float margin)`, `WithinRel(double target)`, and +`WithinRel(float target)`. The latter two provide a default epsilon of +machine epsilon * 100. + +> `WithinRel` matcher was introduced in Catch 2.10.0 + +### Generic matchers +Catch also aims to provide a set of generic matchers. Currently this set +contains only a matcher that takes arbitrary callable predicate and applies +it onto the provided object. + +Because of type inference limitations, the argument type of the predicate +has to be provided explicitly. Example: +```cpp +REQUIRE_THAT("Hello olleH", + Predicate( + [] (std::string const& str) -> bool { return str.front() == str.back(); }, + "First and last character should be equal") +); +``` + +The second argument is an optional description of the predicate, and is +used only during reporting of the result. + + +### Exception matchers +Catch2 also provides an exception matcher that can be used to verify +that an exception's message exactly matches desired string. The matcher +is `ExceptionMessageMatcher`, and we also provide a helper function +`Message`. + +The matched exception must publicly derive from `std::exception` and +the message matching is done _exactly_, including case. + +> `ExceptionMessageMatcher` was introduced in Catch 2.10.0 + +Example use: +```cpp +REQUIRE_THROWS_MATCHES(throwsDerivedException(), DerivedException, Message("DerivedException::what")); +``` + +## Custom matchers +It's easy to provide your own matchers to extend Catch or just to work with your own types. + +You need to provide two things: +1. A matcher class, derived from `Catch::MatcherBase` - where `T` is the type being tested. +The constructor takes and stores any arguments needed (e.g. something to compare against) and you must +override two methods: `match()` and `describe()`. +2. A simple builder function. This is what is actually called from the test code and allows overloading. + +Here's an example for asserting that an integer falls within a given range +(note that it is all inline for the sake of keeping the example short): + +```c++ +// The matcher class +class IntRange : public Catch::MatcherBase { + int m_begin, m_end; +public: + IntRange( int begin, int end ) : m_begin( begin ), m_end( end ) {} + + // Performs the test for this matcher + bool match( int const& i ) const override { + return i >= m_begin && i <= m_end; + } + + // Produces a string describing what this matcher does. It should + // include any provided data (the begin/ end in this case) and + // be written as if it were stating a fact (in the output it will be + // preceded by the value under test). + virtual std::string describe() const override { + std::ostringstream ss; + ss << "is between " << m_begin << " and " << m_end; + return ss.str(); + } +}; + +// The builder function +inline IntRange IsBetween( int begin, int end ) { + return IntRange( begin, end ); +} + +// ... + +// Usage +TEST_CASE("Integers are within a range") +{ + CHECK_THAT( 3, IsBetween( 1, 10 ) ); + CHECK_THAT( 100, IsBetween( 1, 10 ) ); +} +``` + +Running this test gives the following in the console: + +``` +/**/TestFile.cpp:123: FAILED: + CHECK_THAT( 100, IsBetween( 1, 10 ) ) +with expansion: + 100 is between 1 and 10 +``` + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/opensource-users.md b/lib/Catch2/docs/opensource-users.md new file mode 100644 index 0000000000..6cc557a892 --- /dev/null +++ b/lib/Catch2/docs/opensource-users.md @@ -0,0 +1,126 @@ + +# Open Source projects using Catch + +Catch is great for open source. With its [liberal license](../LICENSE.txt) and single-header, dependency-free, distribution +it's easy to just drop the header into your project and start writing tests - what's not to like? + +As a result Catch is now being used in many Open Source projects, including some quite well known ones. +This page is an attempt to track those projects. Obviously it can never be complete. +This effort largely relies on the maintainers of the projects themselves updating this page and submitting a PR +(or, if you prefer contact one of the maintainers of Catch directly, use the +[forums](https://groups.google.com/forum/?fromgroups#!forum/catch-forum)), or raise an [issue](https://github.com/philsquared/Catch/issues) to let us know). +Of course users of those projects might want to update this page too. That's fine - as long you're confident the project maintainers won't mind. +If you're an Open Source project maintainer and see your project listed here but would rather it wasn't - +just let us know via any of the previously mentioned means - although I'm sure there won't be many who feel that way. + +Listing a project here does not imply endorsement and the plan is to keep these ordered alphabetically to avoid an implication of relative importance. + +## Libraries & Frameworks + +### [ApprovalTests.cpp](https://github.com/approvals/ApprovalTests.cpp) +C++11 implementation of Approval Tests, for quick, convenient testing of legacy code. + +### [args](https://github.com/Taywee/args) +A simple header-only C++ argument parser library. + +### [Azmq](https://github.com/zeromq/azmq) +Boost Asio style bindings for ZeroMQ. + +### [Cataclysm: Dark Days Ahead](https://github.com/CleverRaven/Cataclysm-DDA) +Post-apocalyptic survival RPG. + +### [ChaiScript](https://github.com/ChaiScript/ChaiScript) +A, header-only, embedded scripting language designed from the ground up to directly target C++ and take advantage of modern C++ development techniques. + +### [ChakraCore](https://github.com/Microsoft/ChakraCore) +The core part of the Chakra JavaScript engine that powers Microsoft Edge. + +### [Clara](https://github.com/philsquared/Clara) +A, single-header-only, type-safe, command line parser - which also prints formatted usage strings. + +### [Couchbase-lite-core](https://github.com/couchbase/couchbase-lite-core) +The next-generation core storage and query engine for Couchbase Lite. + +### [cppcodec](https://github.com/tplgy/cppcodec) +Header-only C++11 library to encode/decode base64, base64url, base32, base32hex and hex (a.k.a. base16) as specified in RFC 4648, plus Crockford's base32. + +### [DtCraft](https://github.com/twhuang-uiuc/DtCraft) +A High-performance Cluster Computing Engine. + +### [forest](https://github.com/xorz57/forest) +Template Library of Tree Data Structures. + +### [Fuxedo](https://github.com/fuxedo/fuxedo) +Open source Oracle Tuxedo-like XATMI middleware for C and C++. + +### [Inja](https://github.com/pantor/inja) +A header-only template engine for modern C++. + +### [libcluon](https://github.com/chrberger/libcluon) +A single-header-only library written in C++14 to glue distributed software components (UDP, TCP, shared memory) supporting natively Protobuf, LCM/ZCM, MsgPack, and JSON for dynamic message transformations in-between. + +### [MNMLSTC Core](https://github.com/mnmlstc/core) +A small and easy to use C++11 library that adds a functionality set that will be available in C++14 and later, as well as some useful additions. + +### [nanodbc](https://github.com/lexicalunit/nanodbc/) +A small C++ library wrapper for the native C ODBC API. + +### [Nonius](https://github.com/libnonius/nonius) +A header-only framework for benchmarking small snippets of C++ code. + +### [polymorphic_value](https://github.com/jbcoe/polymorphic_value) +A polymorphic value-type for C++. + +### [Ppconsul](https://github.com/oliora/ppconsul) +A C++ client library for Consul. Consul is a distributed tool for discovering and configuring services in your infrastructure. + +### [Reactive-Extensions/ RxCpp](https://github.com/Reactive-Extensions/RxCpp) +A library of algorithms for values-distributed-in-time. + +### [SOCI](https://github.com/SOCI/soci) +The C++ Database Access Library. + +### [TextFlowCpp](https://github.com/philsquared/textflowcpp) +A small, single-header-only, library for wrapping and composing columns of text. + +### [thor](https://github.com/xorz57/thor) +Wrapper Library for CUDA. + +### [toml++](https://github.com/marzer/tomlplusplus) +A header-only TOML parser and serializer for modern C++. + +### [Trompeloeil](https://github.com/rollbear/trompeloeil) +A thread-safe header-only mocking framework for C++14. + +## Applications & Tools + +### [App Mesh](https://github.com/laoshanxi/app-mesh) +A high available cloud native micro-service application management platform implemented by modern C++. + +### [ArangoDB](https://github.com/arangodb/arangodb) +ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values. + +### [Giada - Your Hardcore Loop Machine](https://github.com/monocasual/giada) +Minimal, open-source and cross-platform audio tool for live music production. + +### [MAME](https://github.com/mamedev/mame) +MAME originally stood for Multiple Arcade Machine Emulator. + +### [Newsbeuter](https://github.com/akrennmair/newsbeuter) +Newsbeuter is an open-source RSS/Atom feed reader for text terminals. + +### [PopHead](https://github.com/SPC-Some-Polish-Coders/PopHead) +A 2D, Zombie, RPG game which is being made on our own engine. + +### [raspigcd](https://github.com/pantadeusz/raspigcd) +Low level CLI app and library for execution of GCODE on Raspberry Pi without any additional microcontrolers (just RPi + Stepsticks). + +### [SpECTRE](https://github.com/sxs-collaboration/spectre) +SpECTRE is a code for multi-scale, multi-physics problems in astrophysics and gravitational physics. + +### [Standardese](https://github.com/foonathan/standardese) +Standardese aims to be a nextgen Doxygen. + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/other-macros.md b/lib/Catch2/docs/other-macros.md new file mode 100644 index 0000000000..994115f16d --- /dev/null +++ b/lib/Catch2/docs/other-macros.md @@ -0,0 +1,154 @@ + +# Other macros + +This page serves as a reference for macros that are not documented +elsewhere. For now, these macros are separated into 2 rough categories, +"assertion related macros" and "test case related macros". + +## Assertion related macros + +* `CHECKED_IF` and `CHECKED_ELSE` + +`CHECKED_IF( expr )` is an `if` replacement, that also applies Catch2's +stringification machinery to the _expr_ and records the result. As with +`if`, the block after a `CHECKED_IF` is entered only if the expression +evaluates to `true`. `CHECKED_ELSE( expr )` work similarly, but the block +is entered only if the _expr_ evaluated to `false`. + +Example: +```cpp +int a = ...; +int b = ...; +CHECKED_IF( a == b ) { + // This block is entered when a == b +} CHECKED_ELSE ( a == b ) { + // This block is entered when a != b +} +``` + +* `CHECK_NOFAIL` + +`CHECK_NOFAIL( expr )` is a variant of `CHECK` that does not fail the test +case if _expr_ evaluates to `false`. This can be useful for checking some +assumption, that might be violated without the test necessarily failing. + +Example output: +``` +main.cpp:6: +FAILED - but was ok: + CHECK_NOFAIL( 1 == 2 ) + +main.cpp:7: +PASSED: + CHECK( 2 == 2 ) +``` + +* `SUCCEED` + +`SUCCEED( msg )` is mostly equivalent with `INFO( msg ); REQUIRE( true );`. +In other words, `SUCCEED` is for cases where just reaching a certain line +means that the test has been a success. + +Example usage: +```cpp +TEST_CASE( "SUCCEED showcase" ) { + int I = 1; + SUCCEED( "I is " << I ); +} +``` + +* `STATIC_REQUIRE` + +> [Introduced](https://github.com/catchorg/Catch2/issues/1362) in Catch 2.4.2. + +`STATIC_REQUIRE( expr )` is a macro that can be used the same way as a +`static_assert`, but also registers the success with Catch2, so it is +reported as a success at runtime. The whole check can also be deferred +to the runtime, by defining `CATCH_CONFIG_RUNTIME_STATIC_REQUIRE` before +including the Catch2 header. + +Example: +```cpp +TEST_CASE("STATIC_REQUIRE showcase", "[traits]") { + STATIC_REQUIRE( std::is_void::value ); + STATIC_REQUIRE_FALSE( std::is_void::value ); +} +``` + +## Test case related macros + +* `METHOD_AS_TEST_CASE` + +`METHOD_AS_TEST_CASE( member-function-pointer, description )` lets you +register a member function of a class as a Catch2 test case. The class +will be separately instantiated for each method registered in this way. + +```cpp +class TestClass { + std::string s; + +public: + TestClass() + :s( "hello" ) + {} + + void testCase() { + REQUIRE( s == "hello" ); + } +}; + + +METHOD_AS_TEST_CASE( TestClass::testCase, "Use class's method as a test case", "[class]" ) +``` + +* `REGISTER_TEST_CASE` + +`REGISTER_TEST_CASE( function, description )` let's you register +a `function` as a test case. The function has to have `void()` signature, +the description can contain both name and tags. + +Example: +```cpp +REGISTER_TEST_CASE( someFunction, "ManuallyRegistered", "[tags]" ); +``` + +_Note that the registration still has to happen before Catch2's session +is initiated. This means that it either needs to be done in a global +constructor, or before Catch2's session is created in user's own main._ + + +* `ANON_TEST_CASE` + +`ANON_TEST_CASE` is a `TEST_CASE` replacement that will autogenerate +unique name. The advantage of this is that you do not have to think +of a name for the test case,`the disadvantage is that the name doesn't +necessarily remain stable across different links, and thus it might be +hard to run directly. + +Example: +```cpp +ANON_TEST_CASE() { + SUCCEED("Hello from anonymous test case"); +} +``` + +* `DYNAMIC_SECTION` + +> Introduced in Catch 2.3.0. + +`DYNAMIC_SECTION` is a `SECTION` where the user can use `operator<<` to +create the final name for that section. This can be useful with e.g. +generators, or when creating a `SECTION` dynamically, within a loop. + +Example: +```cpp +TEST_CASE( "looped SECTION tests" ) { + int a = 1; + + for( int b = 0; b < 10; ++b ) { + DYNAMIC_SECTION( "b is currently: " << b ) { + CHECK( b > a ); + } + } +} +``` diff --git a/lib/Catch2/docs/own-main.md b/lib/Catch2/docs/own-main.md new file mode 100644 index 0000000000..06ea243dab --- /dev/null +++ b/lib/Catch2/docs/own-main.md @@ -0,0 +1,131 @@ + +# Supplying main() yourself + +**Contents**
+[Let Catch take full control of args and config](#let-catch-take-full-control-of-args-and-config)
+[Amending the config](#amending-the-config)
+[Adding your own command line options](#adding-your-own-command-line-options)
+[Version detection](#version-detection)
+ +The easiest way to use Catch is to let it supply ```main()``` for you and handle configuring itself from the command line. + +This is achieved by writing ```#define CATCH_CONFIG_MAIN``` before the ```#include "catch.hpp"``` in *exactly one* source file. + +Sometimes, though, you need to write your own version of main(). You can do this by writing ```#define CATCH_CONFIG_RUNNER``` instead. Now you are free to write ```main()``` as normal and call into Catch yourself manually. You now have a lot of flexibility - but here are three recipes to get your started: + +**Important note: you can only provide `main` in the same file you defined `CATCH_CONFIG_RUNNER`.** + +## Let Catch take full control of args and config + +If you just need to have code that executes before and/ or after Catch this is the simplest option. + +```c++ +#define CATCH_CONFIG_RUNNER +#include "catch.hpp" + +int main( int argc, char* argv[] ) { + // global setup... + + int result = Catch::Session().run( argc, argv ); + + // global clean-up... + + return result; +} +``` + +## Amending the config + +If you still want Catch to process the command line, but you want to programmatically tweak the config, you can do so in one of two ways: + +```c++ +#define CATCH_CONFIG_RUNNER +#include "catch.hpp" + +int main( int argc, char* argv[] ) +{ + Catch::Session session; // There must be exactly one instance + + // writing to session.configData() here sets defaults + // this is the preferred way to set them + + int returnCode = session.applyCommandLine( argc, argv ); + if( returnCode != 0 ) // Indicates a command line error + return returnCode; + + // writing to session.configData() or session.Config() here + // overrides command line args + // only do this if you know you need to + + int numFailed = session.run(); + + // numFailed is clamped to 255 as some unices only use the lower 8 bits. + // This clamping has already been applied, so just return it here + // You can also do any post run clean-up here + return numFailed; +} +``` + +Take a look at the definitions of Config and ConfigData to see what you can do with them. + +To take full control of the config simply omit the call to ```applyCommandLine()```. + +## Adding your own command line options + +Catch embeds a powerful command line parser called [Clara](https://github.com/philsquared/Clara). +As of Catch2 (and Clara 1.0) Clara allows you to write _composable_ option and argument parsers, +so extending Catch's own command line options is now easy. + +```c++ +#define CATCH_CONFIG_RUNNER +#include "catch.hpp" + +int main( int argc, char* argv[] ) +{ + Catch::Session session; // There must be exactly one instance + + int height = 0; // Some user variable you want to be able to set + + // Build a new parser on top of Catch's + using namespace Catch::clara; + auto cli + = session.cli() // Get Catch's composite command line parser + | Opt( height, "height" ) // bind variable to a new option, with a hint string + ["-g"]["--height"] // the option names it will respond to + ("how high?"); // description string for the help output + + // Now pass the new composite back to Catch so it uses that + session.cli( cli ); + + // Let Catch (using Clara) parse the command line + int returnCode = session.applyCommandLine( argc, argv ); + if( returnCode != 0 ) // Indicates a command line error + return returnCode; + + // if set on the command line then 'height' is now set at this point + if( height > 0 ) + std::cout << "height: " << height << std::endl; + + return session.run(); +} +``` + +See the [Clara documentation](https://github.com/philsquared/Clara/blob/master/README.md) for more details. + + +## Version detection + +Catch provides a triplet of macros providing the header's version, + +* `CATCH_VERSION_MAJOR` +* `CATCH_VERSION_MINOR` +* `CATCH_VERSION_PATCH` + +these macros expand into a single number, that corresponds to the appropriate +part of the version. As an example, given single header version v2.3.4, +the macros would expand into `2`, `3`, and `4` respectively. + + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/release-notes.md b/lib/Catch2/docs/release-notes.md new file mode 100644 index 0000000000..4d173dc1aa --- /dev/null +++ b/lib/Catch2/docs/release-notes.md @@ -0,0 +1,1284 @@ + + +# Release notes +**Contents**
+[2.13.6](#2136)
+[2.13.5](#2135)
+[2.13.4](#2134)
+[2.13.3](#2133)
+[2.13.2](#2132)
+[2.13.1](#2131)
+[2.13.0](#2130)
+[2.12.4](#2124)
+[2.12.3](#2123)
+[2.12.2](#2122)
+[2.12.1](#2121)
+[2.12.0](#2120)
+[2.11.3](#2113)
+[2.11.2](#2112)
+[2.11.1](#2111)
+[2.11.0](#2110)
+[2.10.2](#2102)
+[2.10.1](#2101)
+[2.10.0](#2100)
+[2.9.2](#292)
+[2.9.1](#291)
+[2.9.0](#290)
+[2.8.0](#280)
+[2.7.2](#272)
+[2.7.1](#271)
+[2.7.0](#270)
+[2.6.1](#261)
+[2.6.0](#260)
+[2.5.0](#250)
+[2.4.2](#242)
+[2.4.1](#241)
+[2.4.0](#240)
+[2.3.0](#230)
+[2.2.3](#223)
+[2.2.2](#222)
+[2.2.1](#221)
+[2.2.0](#220)
+[2.1.2](#212)
+[2.1.1](#211)
+[2.1.0](#210)
+[2.0.1](#201)
+[Older versions](#older-versions)
+[Even Older versions](#even-older-versions)
+ + +## 2.13.6 + +### Fixes +* Disabling all signal handlers no longer breaks compilation (#2212, #2213) + +### Miscellaneous +* `catch_discover_tests` should handle escaped semicolon (`;`) better (#2214, #2215) + + +## 2.13.5 + +### Improvements +* Detection of MAC and IPHONE platforms has been improved (#2140, #2157) +* Added workaround for bug in XLC 16.1.0.1 (#2155) +* Add detection for LCC when it is masquerading as GCC (#2199) +* Modified posix signal handling so it supports newer libcs (#2178) + * `MINSIGSTKSZ` was no longer usable in constexpr context. + +### Fixes +* Fixed compilation of benchmarking when `min` and `max` macros are defined (#2159) + * Including `windows.h` without `NOMINMAX` remains a really bad idea, don't do it + +### Miscellaneous +* `Catch2WithMain` target (static library) is no longer built by default (#2142) + * Building it by default was at best unnecessary overhead for people not using it, and at worst it caused trouble with install paths + * To have it built, set CMake option `CATCH_BUILD_STATIC_LIBRARY` to `ON` +* The check whether Catch2 is being built as a subproject is now more reliable (#2202, #2204) + * The problem was that if the variable name used internally was defined the project including Catch2 as subproject, it would not be properly overwritten for Catch2's CMake. + + +## 2.13.4 + +### Improvements +* Improved the hashing algorithm used for shuffling test cases (#2070) + * `TEST_CASE`s that differ only in the last character should be properly shuffled + * Note that this means that v2.13.4 gives you a different order of test cases than 2.13.3, even given the same seed. + +### Miscellaneous +* Deprecated `ParseAndAddCatchTests` CMake integration (#2092) + * It is impossible to implement it properly for all the different test case variants Catch2 provides, and there are better options provided. + * Use `catch_discover_tests` instead, which uses runtime information about available tests. +* Fixed bug in `catch_discover_tests` that would cause it to fail when used in specific project structures (#2119) +* Added Bazel build file +* Added an experimental static library target to CMake + + +## 2.13.3 + +### Fixes +* Fixed possible infinite loop when combining generators with section filter (`-c` option) (#2025) + +### Miscellaneous +* Fixed `ParseAndAddCatchTests` not finding `TEST_CASE`s without tags (#2055, #2056) +* `ParseAndAddCatchTests` supports `CMP0110` policy for changing behaviour of `add_test` (#2057) + * This was the shortlived change in CMake 3.18.0 that temporarily broke `ParseAndAddCatchTests` + + +## 2.13.2 + +### Improvements +* Implemented workaround for AppleClang shadowing bug (#2030) +* Implemented workaround for NVCC ICE (#2005, #2027) + +### Fixes +* Fixed detection of `std::uncaught_exceptions` support under non-msvc platforms (#2021) +* Fixed the experimental stdout/stderr capture under Windows (#2013) + +### Miscellaneous +* `catch_discover_tests` has been improved significantly (#2023, #2039) + * You can now specify which reporter should be used + * You can now modify where the output will be written + * `WORKING_DIRECTORY` setting is respected +* `ParseAndAddCatchTests` now supports `TEMPLATE_TEST_CASE` macros (#2031) +* Various documentation fixes and improvements (#2022, #2028, #2034) + + +## 2.13.1 + +### Improvements +* `ParseAndAddCatchTests` handles CMake v3.18.0 correctly (#1984) +* Improved autodetection of `std::byte` (#1992) +* Simplified implementation of templated test cases (#2007) + * This should have a tiny positive effect on its compilation throughput + +### Fixes +* Automatic stringification of ranges handles sentinel ranges properly (#2004) + + +## 2.13.0 + +### Improvements +* `GENERATE` can now follow a `SECTION` at the same level of nesting (#1938) + * The `SECTION`(s) before the `GENERATE` will not be run multiple times, the following ones will. +* Added `-D`/`--min-duration` command line flag (#1910) + * If a test takes longer to finish than the provided value, its name and duration will be printed. + * This flag is overriden by setting `-d`/`--duration`. + +### Fixes +* `TAPReporter` no longer skips successful assertions (#1983) + + +## 2.12.4 + +### Improvements +* Added support for MacOS on ARM (#1971) + + +## 2.12.3 + +### Fixes +* `GENERATE` nested in a for loop no longer creates multiple generators (#1913) +* Fixed copy paste error breaking `TEMPLATE_TEST_CASE_SIG` for 6 or more arguments (#1954) +* Fixed potential UB when handling non-ASCII characters in CLI args (#1943) + +### Improvements +* There can be multiple calls to `GENERATE` on a single line +* Improved `fno-except` support for platforms that do not provide shims for exception-related std functions (#1950) + * E.g. the Green Hills C++ compiler +* XmlReporter now also reports test-case-level statistics (#1958) + * This is done via a new element, `OverallResultsCases` + +### Miscellaneous +* Added `.clang-format` file to the repo (#1182, #1920) +* Rewrote contributing docs + * They should explain the different levels of testing and so on much better + + +## 2.12.2 + +### Fixes +* Fixed compilation failure if `is_range` ADL found deleted function (#1929) +* Fixed potential UB in `CAPTURE` if the expression contained non-ASCII characters (#1925) + +### Improvements +* `std::result_of` is not used if `std::invoke_result` is available (#1934) +* JUnit reporter writes out `status` attribute for tests (#1899) +* Suppresed clang-tidy's `hicpp-vararg` warning (#1921) + * Catch2 was already suppressing the `cppcoreguidelines-pro-type-vararg` alias of the warning + + +## 2.12.1 + +### Fixes +* Vector matchers now support initializer list literals better + +### Improvements +* Added support for `^` (bitwise xor) to `CHECK` and `REQUIRE` + + +## 2.12.0 + +### Improvements +* Running tests in random order (`--order rand`) has been reworked significantly (#1908) + * Given same seed, all platforms now produce the same order + * Given same seed, the relative order of tests does not change if you select only a subset of them +* Vector matchers support custom allocators (#1909) +* `|` and `&` (bitwise or and bitwise and) are now supported in `CHECK` and `REQUIRE` + * The resulting type must be convertible to `bool` + +### Fixes +* Fixed computation of benchmarking column widths in ConsoleReporter (#1885, #1886) +* Suppressed clang-tidy's `cppcoreguidelines-pro-type-vararg` in assertions (#1901) + * It was a false positive trigered by the new warning support workaround +* Fixed bug in test specification parser handling of OR'd patterns using escaping (#1905) + +### Miscellaneous +* Worked around IBM XL's codegen bug (#1907) + * It would emit code for _destructors_ of temporaries in an unevaluated context +* Improved detection of stdlib's support for `std::uncaught_exceptions` (#1911) + + +## 2.11.3 + +### Fixes +* Fixed compilation error caused by lambdas in assertions under MSVC + + +## 2.11.2 + +### Improvements +* GCC and Clang now issue warnings for suspicious code in assertions (#1880) + * E.g. `REQUIRE( int != unsigned int )` will now issue mixed signedness comparison warning + * This has always worked on MSVC, but it now also works for GCC and current Clang versions +* Colorization of "Test filters" output should be more robust now +* `--wait-for-keypress` now also accepts `never` as an option (#1866) +* Reporters no longer round-off nanoseconds when reporting benchmarking results (#1876) +* Catch2's debug break now supports iOS while using Thumb instruction set (#1862) +* It is now possible to customize benchmark's warm-up time when running the test binary (#1844) + * `--benchmark-warmup-time {ms}` +* User can now specify how Catch2 should break into debugger (#1846) + +### Fixes +* Fixes missing `` include in benchmarking (#1831) +* Fixed missing `` include in benchmarking (#1874) +* Hidden test cases are now also tagged with `[!hide]` as per documentation (#1847) +* Detection of whether libc provides `std::nextafter` has been improved (#1854) +* Detection of `wmain` no longer incorrectly looks for `WIN32` macro (#1849) + * Now it just detects Windows platform +* Composing already-composed matchers no longer modifies the partially-composed matcher expression + * This bug has been present for the last ~2 years and nobody reported it + + +## 2.11.1 + +### Improvements +* Breaking into debugger is supported on iOS (#1817) +* `google-build-using-namespace` clang-tidy warning is suppressed (#1799) + +### Fixes +* Clang on Windows is no longer assumed to implement MSVC's traditional preprocessor (#1806) +* `ObjectStorage` now behaves properly in `const` contexts (#1820) +* `GENERATE_COPY(a, b)` now compiles properly (#1809, #1815) +* Some more cleanups in the benchmarking support + + +## 2.11.0 + +### Improvements +* JUnit reporter output now contains more details in case of failure (#1347, #1719) +* Added SonarQube Test Data reporter (#1738) + * It is in a separate header, just like the TAP, Automake, and TeamCity reporters +* `range` generator now allows floating point numbers (#1776) +* Reworked part of internals to increase throughput + + +### Fixes +* The single header version should contain full benchmarking support (#1800) +* `[.foo]` is now properly parsed as `[.][foo]` when used on the command line (#1798) +* Fixed compilation of benchmarking on platforms where `steady_clock::period` is not `std::nano` (#1794) + + + +## 2.10.2 + +### Improvements +* Catch2 will now compile on platform where `INFINITY` is double (#1782) + + +### Fixes +* Warning suppressed during listener registration will no longer leak + + + +## 2.10.1 + +### Improvements +* Catch2 now guards itself against `min` and `max` macros from `windows.h` (#1772) +* Templated tests will now compile with ICC (#1748) +* `WithinULP` matcher now uses scientific notation for stringification (#1760) + + +### Fixes +* Templated tests no longer trigger `-Wunused-templates` (#1762) +* Suppressed clang-analyzer false positive in context getter (#1230, #1735) + + +### Miscellaneous +* CMake no longer prohibits in-tree build when Catch2 is used as a subproject (#1773, #1774) + + + +## 2.10.0 + +### Fixes +* `TEMPLATE_LIST_TEST_CASE` now properly handles non-copyable and non-movable types (#1729) +* Fixed compilation error on Solaris caused by a system header defining macro `TT` (#1722, #1723) +* `REGISTER_ENUM` will now fail at compilation time if the registered enum is too large +* Removed use of `std::is_same_v` in C++17 mode (#1757) +* Fixed parsing of escaped special characters when reading test specs from a file (#1767, #1769) + + +### Improvements +* Trailing and leading whitespace in test/section specs are now ignored. +* Writing to Android debug log now uses `__android_log_write` instead of `__android_log_print` +* Android logging support can now be turned on/off at compile time (#1743) + * The toggle is `CATCH_CONFIG_ANDROID_LOGWRITE` +* Added a generator that returns elements of a range + * Use via `from_range(from, to)` or `from_range(container)` +* Added support for CRTs that do not provide `std::nextafter` (#1739) + * They must still provide global `nextafter{f,l,}` + * Enabled via `CATCH_CONFIG_GLOBAL_NEXTAFTER` +* Special cased `Approx(inf)` not to match non-infinite values + * Very strictly speaking this might be a breaking change, but it should match user expectations better +* The output of benchmarking through the Console reporter when `--benchmark-no-analysis` is set is now much simpler (#1768) +* Added a matcher that can be used for checking an exceptions message (#1649, #1728) + * The matcher helper function is called `Message` + * The exception must publicly derive from `std::exception` + * The matching is done exactly, including case and whitespace +* Added a matcher that can be used for checking relative equality of floating point numbers (#1746) + * Unlike `Approx`, it considers both sides when determining the allowed margin + * Special cases `NaN` and `INFINITY` to match user expectations + * The matcher helper function is called `WithinRel` +* The ULP matcher now allows for any possible distance between the two numbers +* The random number generators now use Catch-global instance of RNG (#1734, #1736) + * This means that nested random number generators actually generate different numbers + + +### Miscellaneous +* In-repo PNGs have been optimized to lower overhead of using Catch2 via git clone +* Catch2 now uses its own implementation of the URBG concept + * In the future we also plan to use our own implementation of the distributions from `` to provide cross-platform repeatability of random results + + + +## 2.9.2 + +### Fixes +* `ChunkGenerator` can now be used with chunks of size 0 (#1671) +* Nested subsections are now run properly when specific section is run via the `-c` argument (#1670, #1673) +* Catch2 now consistently uses `_WIN32` to detect Windows platform (#1676) +* `TEMPLATE_LIST_TEST_CASE` now support non-default constructible type lists (#1697) +* Fixed a crash in the XMLReporter when a benchmark throws exception during warmup (#1706) +* Fixed a possible infinite loop in CompactReporter (#1715) +* Fixed `-w NoTests` returning 0 even when no tests were matched (#1449, #1683, #1684) +* Fixed matcher compilation under Obj-C++ (#1661) + +### Improvements +* `RepeatGenerator` and `FixedValuesGenerator` now fail to compile when used with `bool` (#1692) + * Previously they would fail at runtime. +* Catch2 now supports Android's debug logging for its debug output (#1710) +* Catch2 now detects and configures itself for the RTX platform (#1693) + * You still need to pass `--benchmark-no-analysis` if you are using benchmarking under RTX +* Removed a "storage class is not first" warning when compiling Catch2 with PGI compiler (#1717) + +### Miscellaneous +* Documentation now contains indication when a specific feature was introduced (#1695) + * These start with Catch2 v2.3.0, (a bit over a year ago). + * `docs/contributing.md` has been updated to provide contributors guidance on how to add these to newly written documentation +* Various other documentation improvements + * ToC fixes + * Documented `--order` and `--rng-seed` command line options + * Benchmarking documentation now clearly states that it requires opt-in + * Documented `CATCH_CONFIG_CPP17_OPTIONAL` and `CATCH_CONFIG_CPP17_BYTE` macros + * Properly documented built-in vector matchers + * Improved `*_THROWS_MATCHES` documentation a bit +* CMake config file is now arch-independent even if `CMAKE_SIZEOF_VOID_P` is in CMake cache (#1660) +* `CatchAddTests` now properly escapes `[` and `]` in test names (#1634, #1698) +* Reverted `CatchAddTests` adding tags as CTest labels (#1658) + * The script broke when test names were too long + * Overwriting `LABELS` caused trouble for users who set them manually + * CMake does not let users append to `LABELS` if the test name has spaces + + +## 2.9.1 + +### Fixes +* Fix benchmarking compilation failure in files without `CATCH_CONFIG_EXTERNAL_INTERFACES` (or implementation) + +## 2.9.0 + +### Improvements +* The experimental benchmarking support has been replaced by integrating Nonius code (#1616) + * This provides a much more featurefull micro-benchmarking support. + * Due to the compilation cost, it is disabled by default. See the documentation for details. + * As far as backwards compatibility is concerned, this feature is still considered experimental in that we might change the interface based on user feedback. +* `WithinULP` matcher now shows the acceptable range (#1581) +* Template test cases now support type lists (#1627) + + +## 2.8.0 + +### Improvements +* Templated test cases no longer check whether the provided types are unique (#1628) + * This allows you to e.g. test over `uint32_t`, `uint64_t`, and `size_t` without compilation failing +* The precision of floating point stringification can be modified by user (#1612, #1614) +* We now provide `REGISTER_ENUM` convenience macro for generating `StringMaker` specializations for enums + * See the "String conversion" documentation for details +* Added new set of macros for template test cases that enables the use of NTTPs (#1531, #1609) + * See "Test cases and sections" documentation for details + +### Fixes +* `UNSCOPED_INFO` macro now has a prefixed/disabled/prefixed+disabled versions (#1611) +* Reporting errors at startup should no longer cause a segfault under certain circumstances (#1626) + + +### Miscellaneous +* CMake will now prevent you from attempting in-tree build (#1636, #1638) + * Previously it would break with an obscure error message during the build step + + +## 2.7.2 + +### Improvements +* Added an approximate vector matcher (#1499) + +### Fixes +* Filters will no longer be shown if there were none +* Fixed compilation error when using Homebrew GCC on OS X (#1588, #1589) +* Fixed the console reporter not showing messages that start with a newline (#1455, #1470) +* Modified JUnit reporter's output so that rng seed and filters are reported according to the JUnit schema (#1598) +* Fixed some obscure warnings and static analysis passes + +### Miscellaneous +* Various improvements to `ParseAndAddCatchTests` (#1559, #1601) + * When a target is parsed, it receives `ParseAndAddCatchTests_TESTS` property which summarizes found tests + * Fixed problem with tests not being found if the `OptionalCatchTestLauncher` variables is used + * Including the script will no longer forcefully modify `CMAKE_MINIMUM_REQUIRED_VERSION` + * CMake object libraries are ignored when parsing to avoid needless warnings +* `CatchAddTests` now adds test's tags to their CTest labels (#1600) +* Added basic CPack support to our build + +## 2.7.1 + +### Improvements +* Reporters now print out the filters applied to test cases (#1550, #1585) +* Added `GENERATE_COPY` and `GENERATE_REF` macros that can use variables inside the generator expression + * Because of the significant danger of lifetime issues, the default `GENERATE` macro still does not allow variables +* The `map` generator helper now deduces the mapped return type (#1576) + +### Fixes +* Fixed ObjC++ compilation (#1571) +* Fixed test tag parsing so that `[.foo]` is now parsed as `[.][foo]`. +* Suppressed warning caused by the Windows headers defining SE codes in different manners (#1575) + +## 2.7.0 + +### Improvements +* `TEMPLATE_PRODUCT_TEST_CASE` now uses the resulting type in the name, instead of the serial number (#1544) +* Catch2's single header is now strictly ASCII (#1542) +* Added generator for random integral/floating point types + * The types are inferred within the `random` helper +* Added back RangeGenerator (#1526) + * RangeGenerator returns elements within a certain range +* Added ChunkGenerator generic transform (#1538) + * A ChunkGenerator returns the elements from different generator in chunks of n elements +* Added `UNSCOPED_INFO` (#415, #983, #1522) + * This is a variant of `INFO` that lives until next assertion/end of the test case. + + +### Fixes +* All calls to C stdlib functions are now `std::` qualified (#1541) + * Code brought in from Clara was also updated. +* Running tests will no longer open the specified output file twice (#1545) + * This would cause trouble when the file was not a file, but rather a named pipe + * Fixes the CLion/Resharper integration with Catch +* Fixed `-Wunreachable-code` occurring with (old) ccache+cmake+clang combination (#1540) +* Fixed `-Wdefaulted-function-deleted` warning with Clang 8 (#1537) +* Catch2's type traits and helpers are now properly namespaced inside `Catch::` (#1548) +* Fixed std{out,err} redirection for failing test (#1514, #1525) + * Somehow, this bug has been present for well over a year before it was reported + + +### Contrib +* `ParseAndAddCatchTests` now properly escapes commas in the test name + + + +## 2.6.1 + +### Improvements +* The JUnit reporter now also reports random seed (#1520, #1521) + +### Fixes +* The TAP reporter now formats comments with test name properly (#1529) +* `CATCH_REQUIRE_THROWS`'s internals were unified with `REQUIRE_THROWS` (#1536) + * This fixes a potential `-Wunused-value` warning when used +* Fixed a potential segfault when using any of the `--list-*` options (#1533, #1534) + + +## 2.6.0 + +**With this release the data generator feature is now fully supported.** + + +### Improvements +* Added `TEMPLATE_PRODUCT_TEST_CASE` (#1454, #1468) + * This allows you to easily test various type combinations, see documentation for details +* The error message for `&&` and `||` inside assertions has been improved (#1273, #1480) +* The error message for chained comparisons inside assertions has been improved (#1481) +* Added `StringMaker` specialization for `std::optional` (#1510) +* The generator interface has been redone once again (#1516) + * It is no longer considered experimental and is fully supported + * The new interface supports "Input" generators + * The generator documentation has been fully updated + * We also added 2 generator examples + + +### Fixes +* Fixed `-Wredundant-move` on newer Clang (#1474) +* Removed unreachable mentions `std::current_exception`, `std::rethrow_exception` in no-exceptions mode (#1462) + * This should fix compilation with IAR +* Fixed missing `` include (#1494) +* Fixed various static analysis warnings + * Unrestored stream state in `XmlWriter` (#1489) + * Potential division by zero in `estimateClockResolution` (#1490) + * Uninitialized member in `RunContext` (#1491) + * `SourceLineInfo` move ops are now marked `noexcept` + * `CATCH_BREAK_INTO_DEBUGGER` is now always a function +* Fix double run of a test case if user asks for a specific section (#1394, #1492) +* ANSI colour code output now respects `-o` flag and writes to the file as well (#1502) +* Fixed detection of `std::variant` support for compilers other than Clang (#1511) + + +### Contrib +* `ParseAndAddCatchTests` has learned how to use `DISABLED` CTest property (#1452) +* `ParseAndAddCatchTests` now works when there is a whitspace before the test name (#1493) + + +### Miscellaneous +* We added new issue templates for reporting issues on GitHub +* `contributing.md` has been updated to reflect the current test status (#1484) + + + +## 2.5.0 + +### Improvements +* Added support for templated tests via `TEMPLATE_TEST_CASE` (#1437) + + +### Fixes +* Fixed compilation of `PredicateMatcher` by removing partial specialization of `MatcherMethod` +* Listeners now implicitly support any verbosity (#1426) +* Fixed compilation with Embarcadero builder by introducing `Catch::isnan` polyfill (#1438) +* Fixed `CAPTURE` asserting for non-trivial captures (#1436, #1448) + + +### Miscellaneous +* We should now be providing first party Conan support via https://bintray.com/catchorg/Catch2 (#1443) +* Added new section "deprecations and planned changes" to the documentation + * It contains summary of what is deprecated and might change with next major version +* From this release forward, the released headers should be pgp signed (#430) + * KeyID `E29C 46F3 B8A7 5028 6079 3B7D ECC9 C20E 314B 2360` + * or https://codingnest.com/files/horenmar-publickey.asc + + +## 2.4.2 + +### Improvements +* XmlReporter now also outputs the RNG seed that was used in a run (#1404) +* `Catch::Session::applyCommandLine` now also accepts `wchar_t` arguments. + * However, Catch2 still does not support unicode. +* Added `STATIC_REQUIRE` macro (#1356, #1362) +* Catch2's singleton's are now cleaned up even if tests are run (#1411) + * This is mostly useful as a FP prevention for users who define their own main. +* Specifying an invalid reporter via `-r` is now reported sooner (#1351, #1422) + + +### Fixes +* Stringification no longer assumes that `char` is signed (#1399, #1407) + * This caused a `Wtautological-compare` warning. +* SFINAE for `operator<<` no longer sees different overload set than the actual insertion (#1403) + + +### Contrib +* `catch_discover_tests` correctly adds tests with comma in name (#1327, #1409) +* Added a new customization point in how the tests are launched to `catch_discover_tests` + + +## 2.4.1 + +### Improvements +* Added a StringMaker for `std::(w)string_view` (#1375, #1376) +* Added a StringMaker for `std::variant` (#1380) + * This one is disabled by default to avoid increased compile-time drag +* Added detection for cygwin environment without `std::to_string` (#1396, #1397) + +### Fixes +* `UnorderedEqualsMatcher` will no longer accept erroneously accept +vectors that share suffix, but are not permutation of the desired vector +* Abort after (`-x N`) can no longer be overshot by nested `REQUIRES` and +subsequently ignored (#1391, #1392) + + +## 2.4.0 + +**This release brings two new experimental features, generator support +and a `-fno-exceptions` support. Being experimental means that they +will not be subject to the usual stability guarantees provided by semver.** + +### Improvements +* Various small runtime performance improvements +* `CAPTURE` macro is now variadic +* Added `AND_GIVEN` macro (#1360) +* Added experimental support for data generators + * See [their documentation](generators.md) for details +* Added support for compiling and running Catch without exceptions + * Doing so limits the functionality somewhat + * Look [into the documentation](configuration.md#disablingexceptions) for details + +### Fixes +* Suppressed `-Wnon-virtual-dtor` warnings in Matchers (#1357) +* Suppressed `-Wunreachable-code` warnings in floating point matchers (#1350) + +### CMake +* It is now possible to override which Python is used to run Catch's tests (#1365) +* Catch now provides infrastructure for adding tests that check compile-time configuration +* Catch no longer tries to install itself when used as a subproject (#1373) +* Catch2ConfigVersion.cmake is now generated as arch-independent (#1368) + * This means that installing Catch from 32-bit machine and copying it to 64-bit one works + * This fixes conan installation of Catch + + +## 2.3.0 + +**This release changes the include paths provided by our CMake and +pkg-config integration. The proper include path for the single-header +when using one of the above is now ``. This change +also necessitated changes to paths inside the repository, so that the +single-header version is now at `single_include/catch2/catch.hpp`, rather +than `single_include/catch.hpp`.** + + + +### Fixes +* Fixed Objective-C++ build +* `-Wunused-variable` suppression no longer leaks from Catch's header under Clang +* Implementation of the experimental new output capture can now be disabled (#1335) + * This allows building Catch2 on platforms that do not provide things like `dup` or `tmpfile`. +* The JUnit and XML reporters will no longer skip over successful tests when running without `-s` (#1264, #1267, #1310) + * See improvements for more details + +### Improvements +* pkg-config and CMake integration has been rewritten + * If you use them, the new include path is `#include ` + * CMake installation now also installs scripts from `contrib/` + * For details see the [new documentation](cmake-integration.md#top) +* Reporters now have a new customization point, `ReporterPreferences::shouldReportAllAssertions` + * When this is set to `false` and the tests are run without `-s`, passing assertions are not sent to the reporter. + * Defaults to `false`. +* Added `DYNAMIC_SECTION`, a section variant that constructs its name using stream + * This means that you can do `DYNAMIC_SECTION("For X := " << x)`. + + +## 2.2.3 + +**To fix some of the bugs, some behavior had to change in potentially breaking manner.** +**This means that even though this is a patch release, it might not be a drop-in replacement.** + +### Fixes +* Listeners are now called before reporter + * This was always documented to be the case, now it actually works that way +* Catch's commandline will no longer accept multiple reporters + * This was done because multiple reporters never worked properly and broke things in non-obvious ways + * **This has potential to be a breaking change** +* MinGW is now detected as Windows platform w/o SEH support (#1257) + * This means that Catch2 no longer tries to use POSIX signal handling when compiled with MinGW +* Fixed potential UB in parsing tags using non-ASCII characters (#1266) + * Note that Catch2 still supports only ASCII test names/tags/etc +* `TEST_CASE_METHOD` can now be used on classnames containing commas (#1245) + * You have to enclose the classname in extra set of parentheses +* Fixed insufficient alt stack size for POSIX signal handling (#1225) +* Fixed compilation error on Android due to missing `std::to_string` in C++11 mode (#1280) +* Fixed the order of user-provided `FALLBACK_STRINGIFIER` in stringification machinery (#1024) + * It was intended to be replacement for built-in fallbacks, but it was used _after_ them. + * **This has potential to be a breaking change** +* Fixed compilation error when a type has an `operator<<` with templated lhs (#1285, #1306) + +### Improvements +* Added a new, experimental, output capture (#1243) + * This capture can also redirect output written via C apis, e.g. `printf` + * To opt-in, define `CATCH_CONFIG_EXPERIMENTAL_REDIRECT` in the implementation file +* Added a new fallback stringifier for classes derived from `std::exception` + * Both `StringMaker` specialization and `operator<<` overload are given priority + +### Miscellaneous +* `contrib/` now contains dbg scripts that skip over Catch's internals (#904, #1283) + * `gdbinit` for gdb `lldbinit` for lldb +* `CatchAddTests.cmake` no longer strips whitespace from tests (#1265, #1281) +* Online documentation now describes `--use-colour` option (#1263) + + +## 2.2.2 + +### Fixes +* Fixed bug in `WithinAbs::match()` failing spuriously (#1228) +* Fixed clang-tidy diagnostic about virtual call in destructor (#1226) +* Reduced the number of GCC warnings suppression leaking out of the header (#1090, #1091) + * Only `-Wparentheses` should be leaking now +* Added upper bound on the time benchmark timer calibration is allowed to take (#1237) + * On platforms where `std::chrono::high_resolution_clock`'s resolution is low, the calibration would appear stuck +* Fixed compilation error when stringifying static arrays of `unsigned char`s (#1238) + +### Improvements +* XML encoder now hex-encodes invalid UTF-8 sequences (#1207) + * This affects xml and junit reporters + * Some invalid UTF-8 parts are left as is, e.g. surrogate pairs. This is because certain extensions of UTF-8 allow them, such as WTF-8. +* CLR objects (`T^`) can now be stringified (#1216) + * This affects code compiled as C++/CLI +* Added `PredicateMatcher`, a matcher that takes an arbitrary predicate function (#1236) + * See [documentation for details](https://github.com/catchorg/Catch2/blob/v2.x/docs/matchers.md) + +### Others +* Modified CMake-installed pkg-config to allow `#include `(#1239) + * The plans to standardize on `#include ` are still in effect + + +## 2.2.1 + +### Fixes +* Fixed compilation error when compiling Catch2 with `std=c++17` against libc++ (#1214) + * Clara (Catch2's CLI parsing library) used `std::optional` without including it explicitly +* Fixed Catch2 return code always being 0 (#1215) + * In the words of STL, "We feel superbad about letting this in" + + +## 2.2.0 + +### Fixes +* Hidden tests are not listed by default when listing tests (#1175) + * This makes `catch_discover_tests` CMake script work better +* Fixed regression that meant `` could potentially not be included properly (#1197) +* Fixed installing `Catch2ConfigVersion.cmake` when Catch2 is a subproject. + +### Improvements +* Added an option to warn (+ exit with error) when no tests were ran (#1158) + * Use as `-w NoTests` +* Added provisional support for Emscripten (#1114) +* [Added a way to override the fallback stringifier](https://github.com/catchorg/Catch2/blob/v2.x/docs/configuration.md#fallback-stringifier) (#1024) + * This allows project's own stringification machinery to be easily reused for Catch +* `Catch::Session::run()` now accepts `char const * const *`, allowing it to accept array of string literals (#1031, #1178) + * The embedded version of Clara was bumped to v1.1.3 +* Various minor performance improvements +* Added support for DJGPP DOS crosscompiler (#1206) + + +## 2.1.2 + +### Fixes +* Fixed compilation error with `-fno-rtti` (#1165) +* Fixed NoAssertion warnings +* `operator<<` is used before range-based stringification (#1172) +* Fixed `-Wpedantic` warnings (extra semicolons and binary literals) (#1173) + + +### Improvements +* Added `CATCH_VERSION_{MAJOR,MINOR,PATCH}` macros (#1131) +* Added `BrightYellow` colour for use in reporters (#979) + * It is also used by ConsoleReporter for reconstructed expressions + +### Other changes +* Catch is now exported as a CMake package and linkable target (#1170) + +## 2.1.1 + +### Improvements +* Static arrays are now properly stringified like ranges across MSVC/GCC/Clang +* Embedded newer version of Clara -- v1.1.1 + * This should fix some warnings dragged in from Clara +* MSVC's CLR exceptions are supported + + +### Fixes +* Fixed compilation when comparison operators do not return bool (#1147) +* Fixed CLR exceptions blowing up the executable during translation (#1138) + + +### Other changes +* Many CMake changes + * `NO_SELFTEST` option is deprecated, use `BUILD_TESTING` instead. + * Catch specific CMake options were prefixed with `CATCH_` for namespacing purposes + * Other changes to simplify Catch2's packaging + + + +## 2.1.0 + +### Improvements +* Various performance improvements + * On top of the performance regression fixes +* Experimental support for PCH was added (#1061) +* `CATCH_CONFIG_EXTERNAL_INTERFACES` now brings in declarations of Console, Compact, XML and JUnit reporters +* `MatcherBase` no longer has a pointless second template argument +* Reduced the number of warning suppressions that leak into user's code + * Bugs in g++ 4.x and 5.x mean that some of them have to be left in + + +### Fixes +* Fixed performance regression from Catch classic + * One of the performance improvement patches for Catch classic was not applied to Catch2 +* Fixed platform detection for iOS (#1084) +* Fixed compilation when `g++` is used together with `libc++` (#1110) +* Fixed TeamCity reporter compilation with the single header version + * To fix the underlying issue we will be versioning reporters in single_include folder per release +* The XML reporter will now report `WARN` messages even when not used with `-s` +* Fixed compilation when `VectorContains` matcher was combined using `&&` (#1092) +* Fixed test duration overflowing after 10 seconds (#1125, #1129) +* Fixed `std::uncaught_exception` deprecation warning (#1124) + + +### New features +* New Matchers + * Regex matcher for strings, `Matches`. + * Set-equal matcher for vectors, `UnorderedEquals` + * Floating point matchers, `WithinAbs` and `WithinULP`. +* Stringification now attempts to decompose all containers (#606) + * Containers are objects that respond to ADL `begin(T)` and `end(T)`. + + +### Other changes +* Reporters will now be versioned in the `single_include` folder to ensure their compatibility with the last released version + + + + +## 2.0.1 + +### Breaking changes +* Removed C++98 support +* Removed legacy reporter support +* Removed legacy generator support + * Generator support will come back later, reworked +* Removed `Catch::toString` support + * The new stringification machinery uses `Catch::StringMaker` specializations first and `operator<<` overloads second. +* Removed legacy `SCOPED_MSG` and `SCOPED_INFO` macros +* Removed `INTERNAL_CATCH_REGISTER_REPORTER` + * `CATCH_REGISTER_REPORTER` should be used to register reporters +* Removed legacy `[hide]` tag + * `[.]`, `[.foo]` and `[!hide]` are still supported +* Output into debugger is now colourized +* `*_THROWS_AS(expr, exception_type)` now unconditionally appends `const&` to the exception type. +* `CATCH_CONFIG_FAST_COMPILE` now affects the `CHECK_` family of assertions as well as `REQUIRE_` family of assertions + * This is most noticeable in `CHECK(throws())`, which would previously report failure, properly stringify the exception and continue. Now it will report failure and stop executing current section. +* Removed deprecated matcher utility functions `Not`, `AllOf` and `AnyOf`. + * They are superseded by operators `!`, `&&` and `||`, which are natural and do not have limited arity +* Removed support for non-const comparison operators + * Non-const comparison operators are an abomination that should not exist + * They were breaking support for comparing function to function pointer +* `std::pair` and `std::tuple` are no longer stringified by default + * This is done to avoid dragging in `` and `` headers in common path + * Their stringification can be enabled per-file via new configuration macros +* `Approx` is subtly different and hopefully behaves more as users would expect + * `Approx::scale` defaults to `0.0` + * `Approx::epsilon` no longer applies to the larger of the two compared values, but only to the `Approx`'s value + * `INFINITY == Approx(INFINITY)` returns true + + +### Improvements +* Reporters and Listeners can be defined in files different from the main file + * The file has to define `CATCH_CONFIG_EXTERNAL_INTERFACES` before including catch.hpp. +* Errors that happen during set up before main are now caught and properly reported once main is entered + * If you are providing your own main, you can access and use these as well. +* New assertion macros, *_THROWS_MATCHES(expr, exception_type, matcher) are provided + * As the arguments suggest, these allow you to assert that an expression throws desired type of exception and pass the exception to a matcher. +* JUnit reporter no longer has significantly different output for test cases with and without sections +* Most assertions now support expressions containing commas (ie `REQUIRE(foo() == std::vector{1, 2, 3});`) +* Catch now contains experimental micro benchmarking support + * See `projects/SelfTest/Benchmark.tests.cpp` for examples + * The support being experiment means that it can be changed without prior notice +* Catch uses new CLI parsing library (Clara) + * Users can now easily add new command line options to the final executable + * This also leads to some changes in `Catch::Session` interface +* All parts of matchers can be removed from a TU by defining `CATCH_CONFIG_DISABLE_MATCHERS` + * This can be used to somewhat speed up compilation times +* An experimental implementation of `CATCH_CONFIG_DISABLE` has been added + * Inspired by Doctest's `DOCTEST_CONFIG_DISABLE` + * Useful for implementing tests in source files + * ie for functions in anonymous namespaces + * Removes all assertions + * Prevents `TEST_CASE` registrations + * Exception translators are not registered + * Reporters are not registered + * Listeners are not registered +* Reporters/Listeners are now notified of fatal errors + * This means specific signals or structured exceptions + * The Reporter/Listener interface provides default, empty, implementation to preserve backward compatibility +* Stringification of `std::chrono::duration` and `std::chrono::time_point` is now supported + * Needs to be enabled by a per-file compile time configuration option +* Add `pkg-config` support to CMake install command + + +### Fixes +* Don't use console colour if running in XCode +* Explicit constructor in reporter base class +* Swept out `-Wweak-vtables`, `-Wexit-time-destructors`, `-Wglobal-constructors` warnings +* Compilation for Universal Windows Platform (UWP) is supported + * SEH handling and colorized output are disabled when compiling for UWP +* Implemented a workaround for `std::uncaught_exception` issues in libcxxrt + * These issues caused incorrect section traversals + * The workaround is only partial, user's test can still trigger the issue by using `throw;` to rethrow an exception +* Suppressed C4061 warning under MSVC + + +### Internal changes +* The development version now uses .cpp files instead of header files containing implementation. + * This makes partial rebuilds much faster during development +* The expression decomposition layer has been rewritten +* The evaluation layer has been rewritten +* New library (TextFlow) is used for formatting text to output + + +## Older versions + +### 1.12.x + +#### 1.12.2 +##### Fixes +* Fixed missing include + +#### 1.12.1 + +##### Fixes +* Fixed deprecation warning in `ScopedMessage::~ScopedMessage` +* All uses of `min` or `max` identifiers are now wrapped in parentheses + * This avoids problems when Windows headers define `min` and `max` macros + +#### 1.12.0 + +##### Fixes +* Fixed compilation for strict C++98 mode (ie not gnu++98) and older compilers (#1103) +* `INFO` messages are included in the `xml` reporter output even without `-s` specified. + + +### 1.11.x + +#### 1.11.0 + +##### Fixes +* The original expression in `REQUIRE_FALSE( expr )` is now reporter properly as `!( expr )` (#1051) + * Previously the parentheses were missing and `x != y` would be expanded as `!x != x` +* `Approx::Margin` is now inclusive (#952) + * Previously it was meant and documented as inclusive, but the check itself wasn't + * This means that `REQUIRE( 0.25f == Approx( 0.0f ).margin( 0.25f ) )` passes, instead of fails +* `RandomNumberGenerator::result_type` is now unsigned (#1050) + +##### Improvements +* `__JETBRAINS_IDE__` macro handling is now CLion version specific (#1017) + * When CLion 2017.3 or newer is detected, `__COUNTER__` is used instead of +* TeamCity reporter now explicitly flushes output stream after each report (#1057) + * On some platforms, output from redirected streams would show up only after the tests finished running +* `ParseAndAddCatchTests` now can add test files as dependency to CMake configuration + * This means you do not have to manually rerun CMake configuration step to detect new tests + +### 1.10.x + +#### 1.10.0 + +##### Fixes +* Evaluation layer has been rewritten (backported from Catch 2) + * The new layer is much simpler and fixes some issues (#981) +* Implemented workaround for VS 2017 raw string literal stringification bug (#995) +* Fixed interaction between `[!shouldfail]` and `[!mayfail]` tags and sections + * Previously sections with failing assertions would be marked as failed, not failed-but-ok + +##### Improvements +* Added [libidentify](https://github.com/janwilmans/LibIdentify) support +* Added "wait-for-keypress" option + +### 1.9.x + +#### 1.9.6 + +##### Improvements +* Catch's runtime overhead has been significantly decreased (#937, #939) +* Added `--list-extra-info` cli option (#934). + * It lists all tests together with extra information, ie filename, line number and description. + + + +#### 1.9.5 + +##### Fixes +* Truthy expressions are now reconstructed properly, not as booleans (#914) +* Various warnings are no longer erroneously suppressed in test files (files that include `catch.hpp`, but do not define `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER`) (#871) +* Catch no longer fails to link when main is compiled as C++, but linked against Objective-C (#855) +* Fixed incorrect gcc version detection when deciding to use `__COUNTER__` (#928) + * Previously any GCC with minor version less than 3 would be incorrectly classified as not supporting `__COUNTER__`. +* Suppressed C4996 warning caused by upcoming updated to MSVC 2017, marking `std::uncaught_exception` as deprecated. (#927) + +##### Improvements +* CMake integration script now incorporates debug messages and registers tests in an improved way (#911) +* Various documentation improvements + + + +#### 1.9.4 + +##### Fixes +* `CATCH_FAIL` macro no longer causes compilation error without variadic macro support +* `INFO` messages are no longer cleared after being reported once + +##### Improvements and minor changes +* Catch now uses `wmain` when compiled under Windows and `UNICODE` is defined. + * Note that Catch still officially supports only ASCII + +#### 1.9.3 + +##### Fixes +* Completed the fix for (lack of) uint64_t in earlier Visual Studios + +#### 1.9.2 + +##### Improvements and minor changes +* All of `Approx`'s member functions now accept strong typedefs in C++11 mode (#888) + * Previously `Approx::scale`, `Approx::epsilon`, `Approx::margin` and `Approx::operator()` didn't. + + +##### Fixes +* POSIX signals are now disabled by default under QNX (#889) + * QNX does not support current enough (2001) POSIX specification +* JUnit no longer counts exceptions as failures if given test case is marked as ok to fail. +* `Catch::Option` should now have its storage properly aligned. +* Catch no longer attempts to define `uint64_t` on windows (#862) + * This was causing trouble when compiled under Cygwin + +##### Other +* Catch is now compiled under MSVC 2017 using `std:c++latest` (C++17 mode) in CI +* We now provide cmake script that autoregisters Catch tests into ctest. + * See `contrib` folder. + + +#### 1.9.1 + +##### Fixes +* Unexpected exceptions are no longer ignored by default (#885, #887) + + +#### 1.9.0 + + +##### Improvements and minor changes +* Catch no longer attempts to ensure the exception type passed by user in `REQUIRE_THROWS_AS` is a constant reference. + * It was causing trouble when `REQUIRE_THROWS_AS` was used inside templated functions + * This actually reverts changes made in v1.7.2 +* Catch's `Version` struct should no longer be double freed when multiple instances of Catch tests are loaded into single program (#858) + * It is now a static variable in an inline function instead of being an `extern`ed struct. +* Attempt to register invalid tag or tag alias now throws instead of calling `exit()`. + * Because this happen before entering main, it still aborts execution + * Further improvements to this are coming +* `CATCH_CONFIG_FAST_COMPILE` now speeds-up compilation of `REQUIRE*` assertions by further ~15%. + * The trade-off is disabling translation of unexpected exceptions into text. +* When Catch is compiled using C++11, `Approx` is now constructible with anything that can be explicitly converted to `double`. +* Captured messages are now printed on unexpected exceptions + +##### Fixes: +* Clang's `-Wexit-time-destructors` should be suppressed for Catch's internals +* GCC's `-Wparentheses` is now suppressed for all TU's that include `catch.hpp`. + * This is functionally a revert of changes made in 1.8.0, where we tried using `_Pragma` based suppression. This should have kept the suppression local to Catch's assertions, but bugs in GCC's handling of `_Pragma`s in C++ mode meant that it did not always work. +* You can now tell Catch to use C++11-based check when checking whether a type can be streamed to output. + * This fixes cases when an unstreamable type has streamable private base (#877) + * [Details can be found in documentation](configuration.md#catch_config_cpp11_stream_insertable_check) + + +##### Other notes: +* We have added VS 2017 to our CI +* Work on Catch 2 should start soon + + + +### 1.8.x + +#### 1.8.2 + + +##### Improvements and minor changes +* TAP reporter now behaves as if `-s` was always set + * This should be more consistent with the protocol desired behaviour. +* Compact reporter now obeys `-d yes` argument (#780) + * The format is "XXX.123 s: " (3 decimal places are always present). + * Before it did not report the durations at all. +* XML reporter now behaves the same way as Console reporter in regards to `INFO` + * This means it reports `INFO` messages on success, if output on success (`-s`) is enabled. + * Previously it only reported `INFO` messages on failure. +* `CAPTURE(expr)` now stringifies `expr` in the same way assertion macros do (#639) +* Listeners are now finally [documented](event-listeners.md#top). + * Listeners provide a way to hook into events generated by running your tests, including start and end of run, every test case, every section and every assertion. + + +##### Fixes: +* Catch no longer attempts to reconstruct expression that led to a fatal error (#810) + * This fixes possible signal/SEH loop when processing expressions, where the signal was triggered by expression decomposition. +* Fixed (C4265) missing virtual destructor warning in Matchers (#844) +* `std::string`s are now taken by `const&` everywhere (#842). + * Previously some places were taking them by-value. +* Catch should no longer change errno (#835). + * This was caused by libstdc++ bug that we now work around. +* Catch now provides `FAIL_CHECK( ... )` macro (#765). + * Same as `FAIL( ... )`, but does not abort the test. +* Functions like `fabs`, `tolower`, `memset`, `isalnum` are now used with `std::` qualification (#543). +* Clara no longer assumes first argument (binary name) is always present (#729) + * If it is missing, empty string is used as default. +* Clara no longer reads 1 character past argument string (#830) +* Regression in Objective-C bindings (Matchers) fixed (#854) + + +##### Other notes: +* We have added VS 2013 and 2015 to our CI +* Catch Classic (1.x.x) now contains its own, forked, version of Clara (the argument parser). + + + +#### 1.8.1 + +##### Fixes + +Cygwin issue with `gettimeofday` - `#define` was not early enough + +#### 1.8.0 + +##### New features/ minor changes + +* Matchers have new, simpler (and documented) interface. + * Catch provides string and vector matchers. + * For details see [Matchers documentation](matchers.md#top). +* Changed console reporter test duration reporting format (#322) + * Old format: `Some simple comparisons between doubles completed in 0.000123s` + * New format: `xxx.123s: Some simple comparisons between doubles` _(There will always be exactly 3 decimal places)_ +* Added opt-in leak detection under MSVC + Windows (#439) + * Enable it by compiling Catch's main with `CATCH_CONFIG_WINDOWS_CRTDBG` +* Introduced new compile-time flag, `CATCH_CONFIG_FAST_COMPILE`, trading features for compilation speed. + * Moves debug breaks out of tests and into implementation, speeding up test compilation time (~10% on linux). + * _More changes are coming_ +* Added [TAP (Test Anything Protocol)](https://testanything.org/) and [Automake](https://www.gnu.org/software/automake/manual/html_node/Log-files-generation-and-test-results-recording.html#Log-files-generation-and-test-results-recording) reporters. + * These are not present in the default single-include header and need to be downloaded from GitHub separately. + * For details see [documentation about integrating with build systems](build-systems.md#top). +* XML reporter now reports filename as part of the `Section` and `TestCase` tags. +* `Approx` now supports an optional margin of absolute error + * It has also received [new documentation](assertions.md#top). + +##### Fixes +* Silenced C4312 ("conversion from int to 'ClassName *") warnings in the evaluate layer. +* Fixed C4512 ("assignment operator could not be generated") warnings under VS2013. +* Cygwin compatibility fixes + * Signal handling is no longer compiled by default. + * Usage of `gettimeofday` inside Catch should no longer cause compilation errors. +* Improved `-Wparentheses` suppression for gcc (#674) + * When compiled with gcc 4.8 or newer, the suppression is localized to assertions only + * Otherwise it is suppressed for the whole TU +* Fixed test spec parser issue (with escapes in multiple names) + +##### Other +* Various documentation fixes and improvements + + +### 1.7.x + +#### 1.7.2 + +##### Fixes and minor improvements +Xml: + +(technically the first two are breaking changes but are also fixes and arguably break few if any people) +* C-escape control characters instead of XML encoding them (which requires XML 1.1) +* Revert XML output to XML 1.0 +* Can provide stylesheet references by extending the XML reporter +* Added description and tags attributes to XML Reporter +* Tags are closed and the stream flushed more eagerly to avoid stdout interpolation + + +Other: +* `REQUIRE_THROWS_AS` now catches exception by `const&` and reports expected type +* In `SECTION`s the file/ line is now of the `SECTION`. not the `TEST_CASE` +* Added std:: qualification to some functions from C stdlib +* Removed use of RTTI (`dynamic_cast`) that had crept back in +* Silenced a few more warnings in different circumstances +* Travis improvements + +#### 1.7.1 + +##### Fixes: +* Fixed inconsistency in defining `NOMINMAX` and `WIN32_LEAN_AND_MEAN` inside `catch.hpp`. +* Fixed SEH-related compilation error under older MinGW compilers, by making Windows SEH handling opt-in for compilers other than MSVC. + * For specifics, look into the [documentation](configuration.md#top). +* Fixed compilation error under MinGW caused by improper compiler detection. +* Fixed XML reporter sometimes leaving an empty output file when a test ends with signal/structured exception. +* Fixed XML reporter not reporting captured stdout/stderr. +* Fixed possible infinite recursion in Windows SEH. +* Fixed possible compilation error caused by Catch's operator overloads being ambiguous in regards to user-defined templated operators. + +#### 1.7.0 + +##### Features/ Changes: +* Catch now runs significantly faster for passing tests + * Microbenchmark focused on Catch's overhead went from ~3.4s to ~0.7s. + * Real world test using [JSON for Modern C++](https://github.com/nlohmann/json)'s test suite went from ~6m 25s to ~4m 14s. +* Catch can now run specific sections within test cases. + * For now the support is only basic (no wildcards or tags), for details see the [documentation](command-line.md#top). +* Catch now supports SEH on Windows as well as signals on Linux. + * After receiving a signal, Catch reports failing assertion and then passes the signal onto the previous handler. +* Approx can be used to compare values against strong typedefs (available in C++11 mode only). + * Strong typedefs mean types that are explicitly convertible to double. +* CHECK macro no longer stops executing section if an exception happens. +* Certain characters (space, tab, etc) are now pretty printed. + * This means that a `char c = ' '; REQUIRE(c == '\t');` would be printed as `' ' == '\t'`, instead of ` == 9`. + +##### Fixes: +* Text formatting no longer attempts to access out-of-bounds characters under certain conditions. +* THROW family of assertions no longer trigger `-Wunused-value` on expressions containing explicit cast. +* Breaking into debugger under OS X works again and no longer required `DEBUG` to be defined. +* Compilation no longer breaks under certain compiler if a lambda is used inside assertion macro. + +##### Other: +* Catch's CMakeLists now defines install command. +* Catch's CMakeLists now generates projects with warnings enabled. + + +### 1.6.x + +#### 1.6.1 + +##### Features/ Changes: +* Catch now supports breaking into debugger on Linux + +##### Fixes: +* Generators no longer leak memory (generators are still unsupported in general) +* JUnit reporter now reports UTC timestamps, instead of "tbd" +* `CHECK_THAT` macro is now properly defined as `CATCH_CHECK_THAT` when using `CATCH_` prefixed macros + +##### Other: +* Types with overloaded `&&` operator are no longer evaluated twice when used in an assertion macro. +* The use of `__COUNTER__` is suppressed when Catch is parsed by CLion + * This change is not active when compiling a binary +* Approval tests can now be run on Windows +* CMake will now warn if a file is present in the `include` folder but not is not enumerated as part of the project +* Catch now defines `NOMINMAX` and `WIN32_LEAN_AND_MEAN` before including `windows.h` + * This can be disabled if needed, see [documentation](configuration.md#top) for details. + + +#### 1.6.0 + +##### Cmake/ projects: +* Moved CMakeLists.txt to root, made it friendlier for CLion and generating XCode and VS projects, and removed the manually maintained XCode and VS projects. + +##### Features/ Changes: +* Approx now supports `>=` and `<=` +* Can now use `\` to escape chars in test names on command line +* Standardize C++11 feature toggles + +##### Fixes: +* Blue shell colour +* Missing argument to `CATCH_CHECK_THROWS` +* Don't encode extended ASCII in XML +* use `std::shuffle` on more compilers (fixes deprecation warning/error) +* Use `__COUNTER__` more consistently (where available) + +##### Other: +* Tweaks and changes to scripts - particularly for Approval test - to make them more portable + + +## Even Older versions +Release notes were not maintained prior to v1.6.0, but you should be able to work them out from the Git history + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/release-process.md b/lib/Catch2/docs/release-process.md new file mode 100644 index 0000000000..130a89226f --- /dev/null +++ b/lib/Catch2/docs/release-process.md @@ -0,0 +1,73 @@ + +# How to release + +When enough changes have accumulated, it is time to release new version of Catch. This document describes the process in doing so, that no steps are forgotten. Note that all referenced scripts can be found in the `scripts/` directory. + +## Necessary steps + +These steps are necessary and have to be performed before each new release. They serve to make sure that the new release is correct and linked-to from the standard places. + + +### Testing + +All of the tests are currently run in our CI setup based on TravisCI and +AppVeyor. As long as the last commit tested green, the release can +proceed. + + +### Incrementing version number + +Catch uses a variant of [semantic versioning](http://semver.org/), with breaking API changes (and thus major version increments) being very rare. Thus, the release will usually increment the patch version, when it only contains couple of bugfixes, or minor version, when it contains new functionality, or larger changes in implementation of current functionality. + +After deciding which part of version number should be incremented, you can use one of the `*Release.py` scripts to perform the required changes to Catch. + +This will take care of generating the single include header, updating +version numbers everywhere and pushing the new version to Wandbox. + + +### Release notes + +Once a release is ready, release notes need to be written. They should summarize changes done since last release. For rough idea of expected notes see previous releases. Once written, release notes should be added to `docs/release-notes.md`. + + +### Commit and push update to GitHub + +After version number is incremented, single-include header is regenerated and release notes are updated, changes should be committed and pushed to GitHub. + + +### Release on GitHub + +After pushing changes to GitHub, GitHub release *needs* to be created. +Tag version and release title should be same as the new version, +description should contain the release notes for the current release. +Single header version of `catch.hpp` *needs* to be attached as a binary, +as that is where the official download link links to. Preferably +it should use linux line endings. All non-bundled reporters (Automake, TAP, +TeamCity, SonarQube) should also be attached as binaries, as they might be +dependent on a specific version of the single-include header. + +Since 2.5.0, the release tag and the "binaries" (headers) should be PGP +signed. + +#### Signing a tag + +To create a signed tag, use `git tag -s `, where `` +is the version being released, e.g. `git tag -s v2.6.0`. + +Use the version name as the short message and the release notes as +the body (long) message. + +#### Signing the headers + +This will create ASCII-armored signatures for the headers that are +uploaded to the GitHub release: + +``` +$ gpg2 --armor --output catch.hpp.asc --detach-sig catch.hpp +$ gpg2 --armor --output catch_reporter_automake.hpp.asc --detach-sig catch_reporter_automake.hpp +$ gpg2 --armor --output catch_reporter_teamcity.hpp.asc --detach-sig catch_reporter_teamcity.hpp +$ gpg2 --armor --output catch_reporter_tap.hpp.asc --detach-sig catch_reporter_tap.hpp +$ gpg2 --armor --output catch_reporter_sonarqube.hpp.asc --detach-sig catch_reporter_sonarqube.hpp +``` + +_GPG does not support signing multiple files in single invocation._ diff --git a/lib/Catch2/docs/reporters.md b/lib/Catch2/docs/reporters.md new file mode 100644 index 0000000000..a33e55bf11 --- /dev/null +++ b/lib/Catch2/docs/reporters.md @@ -0,0 +1,47 @@ + +# Reporters + +Catch has a modular reporting system and comes bundled with a handful of useful reporters built in. +You can also write your own reporters. + +## Using different reporters + +The reporter to use can easily be controlled from the command line. +To specify a reporter use [`-r` or `--reporter`](command-line.md#choosing-a-reporter-to-use), followed by the name of the reporter, e.g.: + +``` +-r xml +``` + +If you don't specify a reporter then the console reporter is used by default. +There are four reporters built in to the single include: + +* `console` writes as lines of text, formatted to a typical terminal width, with colours if a capable terminal is detected. +* `compact` similar to `console` but optimised for minimal output - each entry on one line +* `junit` writes xml that corresponds to Ant's [junitreport](http://help.catchsoftware.com/display/ET/JUnit+Format) target. Useful for build systems that understand Junit. +Because of the way the junit format is structured the run must complete before anything is written. +* `xml` writes an xml format tailored to Catch. Unlike `junit` this is a streaming format so results are delivered progressively. + +There are a few additional reporters, for specific build systems, in the Catch repository (in `include\reporters`) which you can `#include` in your project if you would like to make use of them. +Do this in one source file - the same one you have `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER`. + +* `teamcity` writes the native, streaming, format that [TeamCity](https://www.jetbrains.com/teamcity/) understands. +Use this when building as part of a TeamCity build to see results as they happen ([code example](../examples/207-Rpt-TeamCityReporter.cpp)). +* `tap` writes in the TAP ([Test Anything Protocol](https://en.wikipedia.org/wiki/Test_Anything_Protocol)) format. +* `automake` writes in a format that correspond to [automake .trs](https://www.gnu.org/software/automake/manual/html_node/Log-files-generation-and-test-results-recording.html) files +* `sonarqube` writes the [SonarQube Generic Test Data](https://docs.sonarqube.org/latest/analysis/generic-test/) XML format. + +You see what reporters are available from the command line by running with `--list-reporters`. + +By default all these reports are written to stdout, but can be redirected to a file with [`-o` or `--out`](command-line.md#sending-output-to-a-file) + +## Writing your own reporter + +You can write your own custom reporter and register it with Catch. +At time of writing the interface is subject to some changes so is not, yet, documented here. +If you are determined you shouldn't have too much trouble working it out from the existing implementations - +but do keep in mind upcoming changes (these will be minor, simplifying, changes such as not needing to forward calls to the base class). + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/slow-compiles.md b/lib/Catch2/docs/slow-compiles.md new file mode 100644 index 0000000000..63e628fbc1 --- /dev/null +++ b/lib/Catch2/docs/slow-compiles.md @@ -0,0 +1,106 @@ + +# Why do my tests take so long to compile? + +**Contents**
+[Short answer](#short-answer)
+[Long answer](#long-answer)
+[Practical example](#practical-example)
+[Using the static library Catch2WithMain](#using-the-static-library-catch2withmain)
+[Other possible solutions](#other-possible-solutions)
+ +Several people have reported that test code written with Catch takes much longer to compile than they would expect. Why is that? + +Catch is implemented entirely in headers. There is a little overhead due to this - but not as much as you might think - and you can minimise it simply by organising your test code as follows: + +## Short answer +Exactly one source file must ```#define``` either ```CATCH_CONFIG_MAIN``` or ```CATCH_CONFIG_RUNNER``` before ```#include```-ing Catch. In this file *do not write any test cases*! In most cases that means this file will just contain two lines (the ```#define``` and the ```#include```). + +## Long answer + +Usually C++ code is split between a header file, containing declarations and prototypes, and an implementation file (.cpp) containing the definition, or implementation, code. Each implementation file, along with all the headers that it includes (and which those headers include, etc), is expanded into a single entity called a translation unit - which is then passed to the compiler and compiled down to an object file. + +But functions and methods can also be written inline in header files. The downside to this is that these definitions will then be compiled in *every* translation unit that includes the header. + +Because Catch is implemented *entirely* in headers you might think that the whole of Catch must be compiled into every translation unit that uses it! Actually it's not quite as bad as that. Catch mitigates this situation by effectively maintaining the traditional separation between the implementation code and declarations. Internally the implementation code is protected by ```#ifdef```s and is conditionally compiled into only one translation unit. This translation unit is that one that ```#define```s ```CATCH_CONFIG_MAIN``` or ```CATCH_CONFIG_RUNNER```. Let's call this the main source file. + +As a result the main source file *does* compile the whole of Catch every time! So it makes sense to dedicate this file to *only* ```#define```-ing the identifier and ```#include```-ing Catch (and implementing the runner code, if you're doing that). Keep all your test cases in other files. This way you won't pay the recompilation cost for the whole of Catch. + +## Practical example +Assume you have the `Factorial` function from the [tutorial](tutorial.md#top) in `factorial.cpp` (with forward declaration in `factorial.h`) and want to test it and keep the compile times down when adding new tests. Then you should have 2 files, `tests-main.cpp` and `tests-factorial.cpp`: + +```cpp +// tests-main.cpp +#define CATCH_CONFIG_MAIN +#include "catch.hpp" +``` + +```cpp +// tests-factorial.cpp +#include "catch.hpp" + +#include "factorial.h" + +TEST_CASE( "Factorials are computed", "[factorial]" ) { + REQUIRE( Factorial(1) == 1 ); + REQUIRE( Factorial(2) == 2 ); + REQUIRE( Factorial(3) == 6 ); + REQUIRE( Factorial(10) == 3628800 ); +} +``` + +After compiling `tests-main.cpp` once, it is enough to link it with separately compiled `tests-factorial.cpp`. This means that adding more tests to `tests-factorial.cpp`, will not result in recompiling Catch's main and the resulting compilation times will decrease substantially. + +``` +$ g++ tests-main.cpp -c +$ g++ factorial.cpp -c +$ g++ tests-main.o factorial.o tests-factorial.cpp -o tests && ./tests -r compact +Passed 1 test case with 4 assertions. +``` + +Now, the next time we change the file `tests-factorial.cpp` (say we add `REQUIRE( Factorial(0) == 1)`), it is enough to recompile the tests instead of recompiling main as well: + +``` +$ g++ tests-main.o factorial.o tests-factorial.cpp -o tests && ./tests -r compact +tests-factorial.cpp:11: failed: Factorial(0) == 1 for: 0 == 1 +Failed 1 test case, failed 1 assertion. +``` + + +## Using the static library Catch2WithMain + +Catch2 also provides a static library that implements the runner. Note +that this support is experimental, due to interactions between Catch2 v2 +implementation and C++ linking limitations. + +As with the `Catch2` target, the `Catch2WithMain` CMake target can be used +either from a subdirectory, or from installed build. + + +### CMake +```cmake +add_executable(tests-factorial tests-factorial.cpp) + +target_link_libraries(tests-factorial Catch2::Catch2WithMain) +``` + +### bazel +```python +cc_test( + name = "hello_world_test", + srcs = [ + "test/hello_world_test.cpp", + ], + deps = [ + "lib_hello_world", + "@catch2//:catch2_with_main", + ], +) +``` + + +## Other possible solutions +You can also opt to sacrifice some features in order to speed-up Catch's compilation times. For details see the [documentation on Catch's compile-time configuration](configuration.md#other-toggles). + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/test-cases-and-sections.md b/lib/Catch2/docs/test-cases-and-sections.md new file mode 100644 index 0000000000..53f9e1504e --- /dev/null +++ b/lib/Catch2/docs/test-cases-and-sections.md @@ -0,0 +1,275 @@ + +# Test cases and sections + +**Contents**
+[Tags](#tags)
+[Tag aliases](#tag-aliases)
+[BDD-style test cases](#bdd-style-test-cases)
+[Type parametrised test cases](#type-parametrised-test-cases)
+[Signature based parametrised test cases](#signature-based-parametrised-test-cases)
+ +While Catch fully supports the traditional, xUnit, style of class-based fixtures containing test case methods this is not the preferred style. + +Instead Catch provides a powerful mechanism for nesting test case sections within a test case. For a more detailed discussion see the [tutorial](tutorial.md#test-cases-and-sections). + +Test cases and sections are very easy to use in practice: + +* **TEST_CASE(** _test name_ \[, _tags_ \] **)** +* **SECTION(** _section name_ **)** + +_test name_ and _section name_ are free form, quoted, strings. The optional _tags_ argument is a quoted string containing one or more tags enclosed in square brackets. Tags are discussed below. Test names must be unique within the Catch executable. + +For examples see the [Tutorial](tutorial.md#top) + +## Tags + +Tags allow an arbitrary number of additional strings to be associated with a test case. Test cases can be selected (for running, or just for listing) by tag - or even by an expression that combines several tags. At their most basic level they provide a simple way to group several related tests together. + +As an example - given the following test cases: + + TEST_CASE( "A", "[widget]" ) { /* ... */ } + TEST_CASE( "B", "[widget]" ) { /* ... */ } + TEST_CASE( "C", "[gadget]" ) { /* ... */ } + TEST_CASE( "D", "[widget][gadget]" ) { /* ... */ } + +The tag expression, ```"[widget]"``` selects A, B & D. ```"[gadget]"``` selects C & D. ```"[widget][gadget]"``` selects just D and ```"[widget],[gadget]"``` selects all four test cases. + +For more detail on command line selection see [the command line docs](command-line.md#specifying-which-tests-to-run) + +Tag names are not case sensitive and can contain any ASCII characters. This means that tags `[tag with spaces]` and `[I said "good day"]` are both allowed tags and can be filtered on. Escapes are not supported however and `[\]]` is not a valid tag. + +### Special Tags + +All tag names beginning with non-alphanumeric characters are reserved by Catch. Catch defines a number of "special" tags, which have meaning to the test runner itself. These special tags all begin with a symbol character. Following is a list of currently defined special tags and their meanings. + +* `[!hide]` or `[.]` - causes test cases to be skipped from the default list (i.e. when no test cases have been explicitly selected through tag expressions or name wildcards). The hide tag is often combined with another, user, tag (for example `[.][integration]` - so all integration tests are excluded from the default run but can be run by passing `[integration]` on the command line). As a short-cut you can combine these by simply prefixing your user tag with a `.` - e.g. `[.integration]`. Because the hide tag has evolved to have several forms, all forms are added as tags if you use one of them. + +* `[!throws]` - lets Catch know that this test is likely to throw an exception even if successful. This causes the test to be excluded when running with `-e` or `--nothrow`. + +* `[!mayfail]` - doesn't fail the test if any given assertion fails (but still reports it). This can be useful to flag a work-in-progress, or a known issue that you don't want to immediately fix but still want to track in your tests. + +* `[!shouldfail]` - like `[!mayfail]` but *fails* the test if it *passes*. This can be useful if you want to be notified of accidental, or third-party, fixes. + +* `[!nonportable]` - Indicates that behaviour may vary between platforms or compilers. + +* `[#]` - running with `-#` or `--filenames-as-tags` causes Catch to add the filename, prefixed with `#` (and with any extension stripped), as a tag to all contained tests, e.g. tests in testfile.cpp would all be tagged `[#testfile]`. + +* `[@]` - tag aliases all begin with `@` (see below). + +* `[!benchmark]` - this test case is actually a benchmark. This is an experimental feature, and currently has no documentation. If you want to try it out, look at `projects/SelfTest/Benchmark.tests.cpp` for details. + +## Tag aliases + +Between tag expressions and wildcarded test names (as well as combinations of the two) quite complex patterns can be constructed to direct which test cases are run. If a complex pattern is used often it is convenient to be able to create an alias for the expression. This can be done, in code, using the following form: + + CATCH_REGISTER_TAG_ALIAS( , ) + +Aliases must begin with the `@` character. An example of a tag alias is: + + CATCH_REGISTER_TAG_ALIAS( "[@nhf]", "[failing]~[.]" ) + +Now when `[@nhf]` is used on the command line this matches all tests that are tagged `[failing]`, but which are not also hidden. + +## BDD-style test cases + +In addition to Catch's take on the classic style of test cases, Catch supports an alternative syntax that allow tests to be written as "executable specifications" (one of the early goals of [Behaviour Driven Development](http://dannorth.net/introducing-bdd/)). This set of macros map on to ```TEST_CASE```s and ```SECTION```s, with a little internal support to make them smoother to work with. + +* **SCENARIO(** _scenario name_ \[, _tags_ \] **)** + +This macro maps onto ```TEST_CASE``` and works in the same way, except that the test case name will be prefixed by "Scenario: " + +* **GIVEN(** _something_ **)** +* **WHEN(** _something_ **)** +* **THEN(** _something_ **)** + +These macros map onto ```SECTION```s except that the section names are the _something_s prefixed by "given: ", "when: " or "then: " respectively. + +* **AND_GIVEN(** _something_ **)** +* **AND_WHEN(** _something_ **)** +* **AND_THEN(** _something_ **)** + +Similar to ```GIVEN```, ```WHEN``` and ```THEN``` except that the prefixes start with "and ". These are used to chain ```GIVEN```s, ```WHEN```s and ```THEN```s together. + +> `AND_GIVEN` was [introduced](https://github.com/catchorg/Catch2/issues/1360) in Catch 2.4.0. + +When any of these macros are used the console reporter recognises them and formats the test case header such that the Givens, Whens and Thens are aligned to aid readability. + +Other than the additional prefixes and the formatting in the console reporter these macros behave exactly as ```TEST_CASE```s and ```SECTION```s. As such there is nothing enforcing the correct sequencing of these macros - that's up to the programmer! + +## Type parametrised test cases + +In addition to `TEST_CASE`s, Catch2 also supports test cases parametrised +by types, in the form of `TEMPLATE_TEST_CASE`, +`TEMPLATE_PRODUCT_TEST_CASE` and `TEMPLATE_LIST_TEST_CASE`. + +* **TEMPLATE_TEST_CASE(** _test name_ , _tags_, _type1_, _type2_, ..., _typen_ **)** + +> [Introduced](https://github.com/catchorg/Catch2/issues/1437) in Catch 2.5.0. + +_test name_ and _tag_ are exactly the same as they are in `TEST_CASE`, +with the difference that the tag string must be provided (however, it +can be empty). _type1_ through _typen_ is the list of types for which +this test case should run, and, inside the test code, the current type +is available as the `TestType` type. + +Because of limitations of the C++ preprocessor, if you want to specify +a type with multiple template parameters, you need to enclose it in +parentheses, e.g. `std::map` needs to be passed as +`(std::map)`. + +Example: +```cpp +TEMPLATE_TEST_CASE( "vectors can be sized and resized", "[vector][template]", int, std::string, (std::tuple) ) { + + std::vector v( 5 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + + SECTION( "resizing bigger changes size and capacity" ) { + v.resize( 10 ); + + REQUIRE( v.size() == 10 ); + REQUIRE( v.capacity() >= 10 ); + } + SECTION( "resizing smaller changes size but not capacity" ) { + v.resize( 0 ); + + REQUIRE( v.size() == 0 ); + REQUIRE( v.capacity() >= 5 ); + + SECTION( "We can use the 'swap trick' to reset the capacity" ) { + std::vector empty; + empty.swap( v ); + + REQUIRE( v.capacity() == 0 ); + } + } + SECTION( "reserving smaller does not change size or capacity" ) { + v.reserve( 0 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + } +} +``` + +* **TEMPLATE_PRODUCT_TEST_CASE(** _test name_ , _tags_, (_template-type1_, _template-type2_, ..., _template-typen_), (_template-arg1_, _template-arg2_, ..., _template-argm_) **)** + +> [Introduced](https://github.com/catchorg/Catch2/issues/1468) in Catch 2.6.0. + +_template-type1_ through _template-typen_ is list of template template +types which should be combined with each of _template-arg1_ through + _template-argm_, resulting in _n * m_ test cases. Inside the test case, +the resulting type is available under the name of `TestType`. + +To specify more than 1 type as a single _template-type_ or _template-arg_, +you must enclose the types in an additional set of parentheses, e.g. +`((int, float), (char, double))` specifies 2 template-args, each +consisting of 2 concrete types (`int`, `float` and `char`, `double` +respectively). You can also omit the outer set of parentheses if you +specify only one type as the full set of either the _template-types_, +or the _template-args_. + + +Example: +```cpp +template< typename T> +struct Foo { + size_t size() { + return 0; + } +}; + +TEMPLATE_PRODUCT_TEST_CASE("A Template product test case", "[template][product]", (std::vector, Foo), (int, float)) { + TestType x; + REQUIRE(x.size() == 0); +} +``` + +You can also have different arities in the _template-arg_ packs: +```cpp +TEMPLATE_PRODUCT_TEST_CASE("Product with differing arities", "[template][product]", std::tuple, (int, (int, double), (int, double, float))) { + TestType x; + REQUIRE(std::tuple_size::value >= 1); +} +``` + +_While there is an upper limit on the number of types you can specify +in single `TEMPLATE_TEST_CASE` or `TEMPLATE_PRODUCT_TEST_CASE`, the limit +is very high and should not be encountered in practice._ + +* **TEMPLATE_LIST_TEST_CASE(** _test name_, _tags_, _type list_ **)** + +> [Introduced](https://github.com/catchorg/Catch2/issues/1627) in Catch 2.9.0. + +_type list_ is a generic list of types on which test case should be instantiated. +List can be `std::tuple`, `boost::mpl::list`, `boost::mp11::mp_list` or anything with +`template ` signature. + +This allows you to reuse the _type list_ in multiple test cases. + +Example: +```cpp +using MyTypes = std::tuple; +TEMPLATE_LIST_TEST_CASE("Template test case with test types specified inside std::tuple", "[template][list]", MyTypes) +{ + REQUIRE(sizeof(TestType) > 0); +} +``` + + +## Signature based parametrised test cases + +> [Introduced](https://github.com/catchorg/Catch2/issues/1609) in Catch 2.8.0. + +In addition to [type parametrised test cases](#type-parametrised-test-cases) Catch2 also supports +signature base parametrised test cases, in form of `TEMPLATE_TEST_CASE_SIG` and `TEMPLATE_PRODUCT_TEST_CASE_SIG`. +These test cases have similar syntax like [type parametrised test cases](#type-parametrised-test-cases), with one +additional positional argument which specifies the signature. + +### Signature +Signature has some strict rules for these tests cases to work properly: +* signature with multiple template parameters e.g. `typename T, size_t S` must have this format in test case declaration + `((typename T, size_t S), T, S)` +* signature with variadic template arguments e.g. `typename T, size_t S, typename...Ts` must have this format in test case declaration + `((typename T, size_t S, typename...Ts), T, S, Ts...)` +* signature with single non type template parameter e.g. `int V` must have this format in test case declaration `((int V), V)` +* signature with single type template parameter e.g. `typename T` should not be used as it is in fact `TEMPLATE_TEST_CASE` + +Currently Catch2 support up to 11 template parameters in signature + +### Examples + +* **TEMPLATE_TEST_CASE_SIG(** _test name_ , _tags_, _signature_, _type1_, _type2_, ..., _typen_ **)** + +Inside `TEMPLATE_TEST_CASE_SIG` test case you can use the names of template parameters as defined in _signature_. + +```cpp +TEMPLATE_TEST_CASE_SIG("TemplateTestSig: arrays can be created from NTTP arguments", "[vector][template][nttp]", + ((typename T, int V), T, V), (int,5), (float,4), (std::string,15), ((std::tuple), 6)) { + + std::array v; + REQUIRE(v.size() > 1); +} +``` + +* **TEMPLATE_PRODUCT_TEST_CASE_SIG(** _test name_ , _tags_, _signature_, (_template-type1_, _template-type2_, ..., _template-typen_), (_template-arg1_, _template-arg2_, ..., _template-argm_) **)** + +```cpp + +template +struct Bar { + size_t size() { return S; } +}; + +TEMPLATE_PRODUCT_TEST_CASE_SIG("A Template product test case with array signature", "[template][product][nttp]", ((typename T, size_t S), T, S), (std::array, Bar), ((int, 9), (float, 42))) { + TestType x; + REQUIRE(x.size() > 0); +} +``` + + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/test-fixtures.md b/lib/Catch2/docs/test-fixtures.md new file mode 100644 index 0000000000..832bba1280 --- /dev/null +++ b/lib/Catch2/docs/test-fixtures.md @@ -0,0 +1,143 @@ + +# Test fixtures + +## Defining test fixtures + +Although Catch allows you to group tests together as sections within a test case, it can still be convenient, sometimes, to group them using a more traditional test fixture. Catch fully supports this too. You define the test fixture as a simple structure: + +```c++ +class UniqueTestsFixture { + private: + static int uniqueID; + protected: + DBConnection conn; + public: + UniqueTestsFixture() : conn(DBConnection::createConnection("myDB")) { + } + protected: + int getID() { + return ++uniqueID; + } + }; + + int UniqueTestsFixture::uniqueID = 0; + + TEST_CASE_METHOD(UniqueTestsFixture, "Create Employee/No Name", "[create]") { + REQUIRE_THROWS(conn.executeSQL("INSERT INTO employee (id, name) VALUES (?, ?)", getID(), "")); + } + TEST_CASE_METHOD(UniqueTestsFixture, "Create Employee/Normal", "[create]") { + REQUIRE(conn.executeSQL("INSERT INTO employee (id, name) VALUES (?, ?)", getID(), "Joe Bloggs")); + } +``` + +The two test cases here will create uniquely-named derived classes of UniqueTestsFixture and thus can access the `getID()` protected method and `conn` member variables. This ensures that both the test cases are able to create a DBConnection using the same method (DRY principle) and that any ID's created are unique such that the order that tests are executed does not matter. + + +Catch2 also provides `TEMPLATE_TEST_CASE_METHOD` and +`TEMPLATE_PRODUCT_TEST_CASE_METHOD` that can be used together +with templated fixtures and templated template fixtures to perform +tests for multiple different types. Unlike `TEST_CASE_METHOD`, +`TEMPLATE_TEST_CASE_METHOD` and `TEMPLATE_PRODUCT_TEST_CASE_METHOD` do +require the tag specification to be non-empty, as it is followed by +further macro arguments. + +Also note that, because of limitations of the C++ preprocessor, if you +want to specify a type with multiple template parameters, you need to +enclose it in parentheses, e.g. `std::map` needs to be +passed as `(std::map)`. +In the case of `TEMPLATE_PRODUCT_TEST_CASE_METHOD`, if a member of the +type list should consist of more than single type, it needs to be enclosed +in another pair of parentheses, e.g. `(std::map, std::pair)` and +`((int, float), (char, double))`. + +Example: +```cpp +template< typename T > +struct Template_Fixture { + Template_Fixture(): m_a(1) {} + + T m_a; +}; + +TEMPLATE_TEST_CASE_METHOD(Template_Fixture,"A TEMPLATE_TEST_CASE_METHOD based test run that succeeds", "[class][template]", int, float, double) { + REQUIRE( Template_Fixture::m_a == 1 ); +} + +template +struct Template_Template_Fixture { + Template_Template_Fixture() {} + + T m_a; +}; + +template +struct Foo_class { + size_t size() { + return 0; + } +}; + +TEMPLATE_PRODUCT_TEST_CASE_METHOD(Template_Template_Fixture, "A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test succeeds", "[class][template]", (Foo_class, std::vector), int) { + REQUIRE( Template_Template_Fixture::m_a.size() == 0 ); +} +``` + +_While there is an upper limit on the number of types you can specify +in single `TEMPLATE_TEST_CASE_METHOD` or `TEMPLATE_PRODUCT_TEST_CASE_METHOD`, +the limit is very high and should not be encountered in practice._ + +## Signature-based parametrised test fixtures + +> [Introduced](https://github.com/catchorg/Catch2/issues/1609) in Catch 2.8.0. + +Catch2 also provides `TEMPLATE_TEST_CASE_METHOD_SIG` and `TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG` to support +fixtures using non-type template parameters. These test cases work similar to `TEMPLATE_TEST_CASE_METHOD` and `TEMPLATE_PRODUCT_TEST_CASE_METHOD`, +with additional positional argument for [signature](test-cases-and-sections.md#signature-based-parametrised-test-cases). + +Example: +```cpp +template +struct Nttp_Fixture{ + int value = V; +}; + +TEMPLATE_TEST_CASE_METHOD_SIG(Nttp_Fixture, "A TEMPLATE_TEST_CASE_METHOD_SIG based test run that succeeds", "[class][template][nttp]",((int V), V), 1, 3, 6) { + REQUIRE(Nttp_Fixture::value > 0); +} + +template +struct Template_Fixture_2 { + Template_Fixture_2() {} + + T m_a; +}; + +template< typename T, size_t V> +struct Template_Foo_2 { + size_t size() { return V; } +}; + +TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(Template_Fixture_2, "A TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG based test run that succeeds", "[class][template][product][nttp]", ((typename T, size_t S), T, S),(std::array, Template_Foo_2), ((int,2), (float,6))) +{ + REQUIRE(Template_Fixture_2{}.m_a.size() >= 2); +} +``` + +## Template fixtures with types specified in template type lists + +Catch2 also provides `TEMPLATE_LIST_TEST_CASE_METHOD` to support template fixtures with types specified in +template type lists like `std::tuple`, `boost::mpl::list` or `boost::mp11::mp_list`. This test case works the same as `TEMPLATE_TEST_CASE_METHOD`, +only difference is the source of types. This allows you to reuse the template type list in multiple test cases. + +Example: +```cpp +using MyTypes = std::tuple; +TEMPLATE_LIST_TEST_CASE_METHOD(Template_Fixture, "Template test case method with test types specified inside std::tuple", "[class][template][list]", MyTypes) +{ + REQUIRE( Template_Fixture::m_a == 1 ); +} +``` + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/tostring.md b/lib/Catch2/docs/tostring.md new file mode 100644 index 0000000000..156c895a6e --- /dev/null +++ b/lib/Catch2/docs/tostring.md @@ -0,0 +1,132 @@ + +# String conversions + +**Contents**
+[operator << overload for std::ostream](#operator--overload-for-stdostream)
+[Catch::StringMaker specialisation](#catchstringmaker-specialisation)
+[Catch::is_range specialisation](#catchis_range-specialisation)
+[Exceptions](#exceptions)
+[Enums](#enums)
+[Floating point precision](#floating-point-precision)
+ + +Catch needs to be able to convert types you use in assertions and logging expressions into strings (for logging and reporting purposes). +Most built-in or std types are supported out of the box but there are two ways that you can tell Catch how to convert your own types (or other, third-party types) into strings. + +## operator << overload for std::ostream + +This is the standard way of providing string conversions in C++ - and the chances are you may already provide this for your own purposes. If you're not familiar with this idiom it involves writing a free function of the form: + +```cpp +std::ostream& operator << ( std::ostream& os, T const& value ) { + os << convertMyTypeToString( value ); + return os; +} +``` + +(where ```T``` is your type and ```convertMyTypeToString``` is where you'll write whatever code is necessary to make your type printable - it doesn't have to be in another function). + +You should put this function in the same namespace as your type, or the global namespace, and have it declared before including Catch's header. + +## Catch::StringMaker specialisation +If you don't want to provide an ```operator <<``` overload, or you want to convert your type differently for testing purposes, you can provide a specialization for `Catch::StringMaker`: + +```cpp +namespace Catch { + template<> + struct StringMaker { + static std::string convert( T const& value ) { + return convertMyTypeToString( value ); + } + }; +} +``` + +## Catch::is_range specialisation +As a fallback, Catch attempts to detect if the type can be iterated +(`begin(T)` and `end(T)` are valid) and if it can be, it is stringified +as a range. For certain types this can lead to infinite recursion, so +it can be disabled by specializing `Catch::is_range` like so: + +```cpp +namespace Catch { + template<> + struct is_range { + static const bool value = false; + }; +} + +``` + + +## Exceptions + +By default all exceptions deriving from `std::exception` will be translated to strings by calling the `what()` method. For exception types that do not derive from `std::exception` - or if `what()` does not return a suitable string - use `CATCH_TRANSLATE_EXCEPTION`. This defines a function that takes your exception type, by reference, and returns a string. It can appear anywhere in the code - it doesn't have to be in the same translation unit. For example: + +```cpp +CATCH_TRANSLATE_EXCEPTION( MyType& ex ) { + return ex.message(); +} +``` + +## Enums + +> Introduced in Catch 2.8.0. + +Enums that already have a `<<` overload for `std::ostream` will convert to strings as expected. +If you only need to convert enums to strings for test reporting purposes you can provide a `StringMaker` specialisations as any other type. +However, as a convenience, Catch provides the `REGISTER_ENUM` helper macro that will generate the `StringMaker` specialiation for you with minimal code. +Simply provide it the (qualified) enum name, followed by all the enum values, and you're done! + +E.g. + +```cpp +enum class Fruits { Banana, Apple, Mango }; + +CATCH_REGISTER_ENUM( Fruits, Fruits::Banana, Fruits::Apple, Fruits::Mango ) + +TEST_CASE() { + REQUIRE( Fruits::Mango == Fruits::Apple ); +} +``` + +... or if the enum is in a namespace: +```cpp +namespace Bikeshed { + enum class Colours { Red, Green, Blue }; +} + +// Important!: This macro must appear at top level scope - not inside a namespace +// You can fully qualify the names, or use a using if you prefer +CATCH_REGISTER_ENUM( Bikeshed::Colours, + Bikeshed::Colours::Red, + Bikeshed::Colours::Green, + Bikeshed::Colours::Blue ) + +TEST_CASE() { + REQUIRE( Bikeshed::Colours::Red == Bikeshed::Colours::Blue ); +} +``` + +## Floating point precision + +> [Introduced](https://github.com/catchorg/Catch2/issues/1614) in Catch 2.8.0. + +Catch provides a built-in `StringMaker` specialization for both `float` +and `double`. By default, it uses what we think is a reasonable precision, +but you can customize it by modifying the `precision` static variable +inside the `StringMaker` specialization, like so: + +```cpp + Catch::StringMaker::precision = 15; + const float testFloat1 = 1.12345678901234567899f; + const float testFloat2 = 1.12345678991234567899f; + REQUIRE(testFloat1 == testFloat2); +``` + +This assertion will fail and print out the `testFloat1` and `testFloat2` +to 15 decimal places. + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/tutorial.md b/lib/Catch2/docs/tutorial.md new file mode 100644 index 0000000000..d10cb70add --- /dev/null +++ b/lib/Catch2/docs/tutorial.md @@ -0,0 +1,279 @@ + +# Tutorial + +**Contents**
+[Getting Catch2](#getting-catch2)
+[Where to put it?](#where-to-put-it)
+[Writing tests](#writing-tests)
+[Test cases and sections](#test-cases-and-sections)
+[BDD-Style](#bdd-style)
+[Scaling up](#scaling-up)
+[Type parametrised test cases](#type-parametrised-test-cases)
+[Next steps](#next-steps)
+ +## Getting Catch2 + +The simplest way to get Catch2 is to download the latest [single header version](https://raw.githubusercontent.com/catchorg/Catch2/v2.x/single_include/catch2/catch.hpp). The single header is generated by merging a set of individual headers but it is still just normal source code in a header file. + +Alternative ways of getting Catch2 include using your system package +manager, or installing it using [its CMake package](cmake-integration.md#installing-catch2-from-git-repository). + +The full source for Catch2, including test projects, documentation, and other things, is hosted on GitHub. [http://catch-lib.net](http://catch-lib.net) will redirect you there. + + +## Where to put it? + +Catch2 is header only. All you need to do is drop the file somewhere reachable from your project - either in some central location you can set your header search path to find, or directly into your project tree itself! This is a particularly good option for other Open-Source projects that want to use Catch for their test suite. See [this blog entry for more on that](https://levelofindirection.com/blog/unit-testing-in-cpp-and-objective-c-just-got-ridiculously-easier-still.html). + +The rest of this tutorial will assume that the Catch2 single-include header (or the include folder) is available unqualified - but you may need to prefix it with a folder name if necessary. + +_If you have installed Catch2 from system package manager, or CMake +package, you need to include the header as `#include `_ + +## Writing tests + +Let's start with a really simple example ([code](../examples/010-TestCase.cpp)). Say you have written a function to calculate factorials and now you want to test it (let's leave aside TDD for now). + +```c++ +unsigned int Factorial( unsigned int number ) { + return number <= 1 ? number : Factorial(number-1)*number; +} +``` + +To keep things simple we'll put everything in a single file (see later for more on how to structure your test files). + +```c++ +#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file +#include "catch.hpp" + +unsigned int Factorial( unsigned int number ) { + return number <= 1 ? number : Factorial(number-1)*number; +} + +TEST_CASE( "Factorials are computed", "[factorial]" ) { + REQUIRE( Factorial(1) == 1 ); + REQUIRE( Factorial(2) == 2 ); + REQUIRE( Factorial(3) == 6 ); + REQUIRE( Factorial(10) == 3628800 ); +} +``` + +This will compile to a complete executable which responds to [command line arguments](command-line.md#top). If you just run it with no arguments it will execute all test cases (in this case there is just one), report any failures, report a summary of how many tests passed and failed and return the number of failed tests (useful for if you just want a yes/ no answer to: "did it work"). + +If you run this as written it will pass. Everything is good. Right? +Well, there is still a bug here. In fact the first version of this tutorial I posted here genuinely had the bug in! So it's not completely contrived (thanks to Daryle Walker (```@CTMacUser```) for pointing this out). + +What is the bug? Well what is the factorial of zero? +[The factorial of zero is one](http://mathforum.org/library/drmath/view/57128.html) - which is just one of those things you have to know (and remember!). + +Let's add that to the test case: + +```c++ +TEST_CASE( "Factorials are computed", "[factorial]" ) { + REQUIRE( Factorial(0) == 1 ); + REQUIRE( Factorial(1) == 1 ); + REQUIRE( Factorial(2) == 2 ); + REQUIRE( Factorial(3) == 6 ); + REQUIRE( Factorial(10) == 3628800 ); +} +``` + +Now we get a failure - something like: + +``` +Example.cpp:9: FAILED: + REQUIRE( Factorial(0) == 1 ) +with expansion: + 0 == 1 +``` + +Note that we get the actual return value of Factorial(0) printed for us (0) - even though we used a natural expression with the == operator. That lets us immediately see what the problem is. + +Let's change the factorial function to: + +```c++ +unsigned int Factorial( unsigned int number ) { + return number > 1 ? Factorial(number-1)*number : 1; +} +``` + +Now all the tests pass. + +Of course there are still more issues to deal with. For example we'll hit problems when the return value starts to exceed the range of an unsigned int. With factorials that can happen quite quickly. You might want to add tests for such cases and decide how to handle them. We'll stop short of doing that here. + +### What did we do here? + +Although this was a simple test it's been enough to demonstrate a few things about how Catch is used. Let's take a moment to consider those before we move on. + +1. All we did was ```#define``` one identifier and ```#include``` one header and we got everything - even an implementation of ```main()``` that will [respond to command line arguments](command-line.md#top). You can only use that ```#define``` in one implementation file, for (hopefully) obvious reasons. Once you have more than one file with unit tests in you'll just ```#include "catch.hpp"``` and go. Usually it's a good idea to have a dedicated implementation file that just has ```#define CATCH_CONFIG_MAIN``` and ```#include "catch.hpp"```. You can also provide your own implementation of main and drive Catch yourself (see [Supplying-your-own-main()](own-main.md#top)). +2. We introduce test cases with the ```TEST_CASE``` macro. This macro takes one or two arguments - a free form test name and, optionally, one or more tags (for more see Test cases and Sections). The test name must be unique. You can run sets of tests by specifying a wildcarded test name or a tag expression. See the [command line docs](command-line.md#top) for more information on running tests. +3. The name and tags arguments are just strings. We haven't had to declare a function or method - or explicitly register the test case anywhere. Behind the scenes a function with a generated name is defined for you, and automatically registered using static registry classes. By abstracting the function name away we can name our tests without the constraints of identifier names. +4. We write our individual test assertions using the ```REQUIRE``` macro. Rather than a separate macro for each type of condition we express the condition naturally using C/C++ syntax. Behind the scenes a simple set of expression templates captures the left-hand-side and right-hand-side of the expression so we can display the values in our test report. As we'll see later there _are_ other assertion macros - but because of this technique the number of them is drastically reduced. + + +## Test cases and sections + +Most test frameworks have a class-based fixture mechanism. That is, test cases map to methods on a class and common setup and teardown can be performed in ```setup()``` and ```teardown()``` methods (or constructor/ destructor in languages, like C++, that support deterministic destruction). + +While Catch fully supports this way of working there are a few problems with the approach. In particular the way your code must be split up, and the blunt granularity of it, may cause problems. You can only have one setup/ teardown pair across a set of methods, but sometimes you want slightly different setup in each method, or you may even want several levels of setup (a concept which we will clarify later on in this tutorial). It was problems like these that led James Newkirk, who led the team that built NUnit, to start again from scratch and build xUnit). + +Catch takes a different approach (to both NUnit and xUnit) that is a more natural fit for C++ and the C family of languages. This is best explained through an example ([code](../examples/100-Fix-Section.cpp)): + +```c++ +TEST_CASE( "vectors can be sized and resized", "[vector]" ) { + + std::vector v( 5 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + + SECTION( "resizing bigger changes size and capacity" ) { + v.resize( 10 ); + + REQUIRE( v.size() == 10 ); + REQUIRE( v.capacity() >= 10 ); + } + SECTION( "resizing smaller changes size but not capacity" ) { + v.resize( 0 ); + + REQUIRE( v.size() == 0 ); + REQUIRE( v.capacity() >= 5 ); + } + SECTION( "reserving bigger changes capacity but not size" ) { + v.reserve( 10 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 10 ); + } + SECTION( "reserving smaller does not change size or capacity" ) { + v.reserve( 0 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + } +} +``` + +For each ```SECTION``` the ```TEST_CASE``` is executed from the start - so as we enter each section we know that size is 5 and capacity is at least 5. We enforced those requirements with the ```REQUIRE```s at the top level so we can be confident in them. +This works because the ```SECTION``` macro contains an if statement that calls back into Catch to see if the section should be executed. One leaf section is executed on each run through a ```TEST_CASE```. The other sections are skipped. Next time through the next section is executed, and so on until no new sections are encountered. + +So far so good - this is already an improvement on the setup/teardown approach because now we see our setup code inline and use the stack. + +The power of sections really shows, however, when we need to execute a sequence of checked operations. Continuing the vector example, we might want to verify that attempting to reserve a capacity smaller than the current capacity of the vector changes nothing. We can do that, naturally, like so: + +```c++ + SECTION( "reserving bigger changes capacity but not size" ) { + v.reserve( 10 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 10 ); + + SECTION( "reserving smaller again does not change capacity" ) { + v.reserve( 7 ); + + REQUIRE( v.capacity() >= 10 ); + } + } +``` + +Sections can be nested to an arbitrary depth (limited only by your stack size). Each leaf section (i.e. a section that contains no nested sections) will be executed exactly once, on a separate path of execution from any other leaf section (so no leaf section can interfere with another). A failure in a parent section will prevent nested sections from running - but then that's the idea. + +## BDD-Style + +If you name your test cases and sections appropriately you can achieve a BDD-style specification structure. This became such a useful way of working that first class support has been added to Catch. Scenarios can be specified using ```SCENARIO```, ```GIVEN```, ```WHEN``` and ```THEN``` macros, which map on to ```TEST_CASE```s and ```SECTION```s, respectively. For more details see [Test cases and sections](test-cases-and-sections.md#top). + +The vector example can be adjusted to use these macros like so ([example code](../examples/120-Bdd-ScenarioGivenWhenThen.cpp)): + +```c++ +SCENARIO( "vectors can be sized and resized", "[vector]" ) { + + GIVEN( "A vector with some items" ) { + std::vector v( 5 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + + WHEN( "the size is increased" ) { + v.resize( 10 ); + + THEN( "the size and capacity change" ) { + REQUIRE( v.size() == 10 ); + REQUIRE( v.capacity() >= 10 ); + } + } + WHEN( "the size is reduced" ) { + v.resize( 0 ); + + THEN( "the size changes but not capacity" ) { + REQUIRE( v.size() == 0 ); + REQUIRE( v.capacity() >= 5 ); + } + } + WHEN( "more capacity is reserved" ) { + v.reserve( 10 ); + + THEN( "the capacity changes but not the size" ) { + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 10 ); + } + } + WHEN( "less capacity is reserved" ) { + v.reserve( 0 ); + + THEN( "neither size nor capacity are changed" ) { + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + } + } + } +} +``` + +Conveniently, these tests will be reported as follows when run: + +``` +Scenario: vectors can be sized and resized + Given: A vector with some items + When: more capacity is reserved + Then: the capacity changes but not the size +``` + + +## Scaling up + +To keep the tutorial simple we put all our code in a single file. This is fine to get started - and makes jumping into Catch even quicker and easier. As you write more real-world tests, though, this is not really the best approach. + +The requirement is that the following block of code ([or equivalent](own-main.md#top)): + +```c++ +#define CATCH_CONFIG_MAIN +#include "catch.hpp" +``` + +appears in _exactly one_ source file. Use as many additional cpp files (or whatever you call your implementation files) as you need for your tests, partitioned however makes most sense for your way of working. Each additional file need only ```#include "catch.hpp"``` - do not repeat the ```#define```! + +In fact it is usually a good idea to put the block with the ```#define``` [in its own source file](slow-compiles.md#top) (code example [main](../examples/020-TestCase-1.cpp), [tests](../examples/020-TestCase-2.cpp)). + +Do not write your tests in header files! + + +## Type parametrised test cases + +Test cases in Catch2 can be also parametrised by type, via the +`TEMPLATE_TEST_CASE` and `TEMPLATE_PRODUCT_TEST_CASE` macros, +which behave in the same way the `TEST_CASE` macro, but are run for +every type or type combination. + +For more details, see our documentation on [test cases and +sections](test-cases-and-sections.md#type-parametrised-test-cases). + + +## Next steps + +This has been a brief introduction to get you up and running with Catch, and to point out some of the key differences between Catch and other frameworks you may already be familiar with. This will get you going quite far already and you are now in a position to dive in and write some tests. + +Of course there is more to learn - most of which you should be able to page-fault in as you go. Please see the ever-growing [Reference section](Readme.md#top) for what's available. + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/docs/why-catch.md b/lib/Catch2/docs/why-catch.md new file mode 100644 index 0000000000..86cc55bc56 --- /dev/null +++ b/lib/Catch2/docs/why-catch.md @@ -0,0 +1,46 @@ + +# Why do we need yet another C++ test framework? + +Good question. For C++ there are quite a number of established frameworks, +including (but not limited to), +[Google Test](http://code.google.com/p/googletest/), +[Boost.Test](http://www.boost.org/doc/libs/1_49_0/libs/test/doc/html/index.html), +[CppUnit](http://sourceforge.net/apps/mediawiki/cppunit/index.php?title=Main_Page), +[Cute](http://www.cute-test.com), +[many, many more](http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C.2B.2B). + +So what does Catch bring to the party that differentiates it from these? Apart from a Catchy name, of course. + +## Key Features + +* Quick and Really easy to get started. Just download catch.hpp, `#include` it and you're away. +* No external dependencies. As long as you can compile C++11 and have a C++ standard library available. +* Write test cases as, self-registering, functions (or methods, if you prefer). +* Divide test cases into sections, each of which is run in isolation (eliminates the need for fixtures). +* Use BDD-style Given-When-Then sections as well as traditional unit test cases. +* Only one core assertion macro for comparisons. Standard C/C++ operators are used for the comparison - yet the full expression is decomposed and lhs and rhs values are logged. +* Tests are named using free-form strings - no more couching names in legal identifiers. + +## Other core features + +* Tests can be tagged for easily running ad-hoc groups of tests. +* Failures can (optionally) break into the debugger on Windows and Mac. +* Output is through modular reporter objects. Basic textual and XML reporters are included. Custom reporters can easily be added. +* JUnit xml output is supported for integration with third-party tools, such as CI servers. +* A default main() function is provided, but you can supply your own for complete control (e.g. integration into your own test runner GUI). +* A command line parser is provided and can still be used if you choose to provided your own main() function. +* Catch can test itself. +* Alternative assertion macro(s) report failures but don't abort the test case +* Floating point tolerance comparisons are built in using an expressive Approx() syntax. +* Internal and friendly macros are isolated so name clashes can be managed +* Matchers + +## Who else is using Catch? + +See the list of [open source projects using Catch](opensource-users.md#top). + +See the [tutorial](tutorial.md#top) to get more of a taste of using Catch in practice + +--- + +[Home](Readme.md#top) diff --git a/lib/Catch2/examples/000-CatchMain.cpp b/lib/Catch2/examples/000-CatchMain.cpp new file mode 100644 index 0000000000..2894d425ad --- /dev/null +++ b/lib/Catch2/examples/000-CatchMain.cpp @@ -0,0 +1,15 @@ +// 000-CatchMain.cpp + +// In a Catch project with multiple files, dedicate one file to compile the +// source code of Catch itself and reuse the resulting object file for linking. + +// Let Catch provide main(): +#define CATCH_CONFIG_MAIN + +#include + +// That's it + +// Compile implementation of Catch for use with files that do contain tests: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -c 000-CatchMain.cpp +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% -c 000-CatchMain.cpp diff --git a/lib/Catch2/examples/010-TestCase.cpp b/lib/Catch2/examples/010-TestCase.cpp new file mode 100644 index 0000000000..c00b8a8f39 --- /dev/null +++ b/lib/Catch2/examples/010-TestCase.cpp @@ -0,0 +1,36 @@ +// 010-TestCase.cpp + +// Let Catch provide main(): +#define CATCH_CONFIG_MAIN + +#include + +int Factorial( int number ) { + return number <= 1 ? number : Factorial( number - 1 ) * number; // fail +// return number <= 1 ? 1 : Factorial( number - 1 ) * number; // pass +} + +TEST_CASE( "Factorial of 0 is 1 (fail)", "[single-file]" ) { + REQUIRE( Factorial(0) == 1 ); +} + +TEST_CASE( "Factorials of 1 and higher are computed (pass)", "[single-file]" ) { + REQUIRE( Factorial(1) == 1 ); + REQUIRE( Factorial(2) == 2 ); + REQUIRE( Factorial(3) == 6 ); + REQUIRE( Factorial(10) == 3628800 ); +} + +// Compile & run: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 010-TestCase 010-TestCase.cpp && 010-TestCase --success +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% 010-TestCase.cpp && 010-TestCase --success + +// Expected compact output (all assertions): +// +// prompt> 010-TestCase --reporter compact --success +// 010-TestCase.cpp:14: failed: Factorial(0) == 1 for: 0 == 1 +// 010-TestCase.cpp:18: passed: Factorial(1) == 1 for: 1 == 1 +// 010-TestCase.cpp:19: passed: Factorial(2) == 2 for: 2 == 2 +// 010-TestCase.cpp:20: passed: Factorial(3) == 6 for: 6 == 6 +// 010-TestCase.cpp:21: passed: Factorial(10) == 3628800 for: 3628800 (0x375f00) == 3628800 (0x375f00) +// Failed 1 test case, failed 1 assertion. diff --git a/lib/Catch2/examples/020-TestCase-1.cpp b/lib/Catch2/examples/020-TestCase-1.cpp new file mode 100644 index 0000000000..ab0249e4dd --- /dev/null +++ b/lib/Catch2/examples/020-TestCase-1.cpp @@ -0,0 +1,35 @@ +// 020-TestCase-1.cpp + +// In a Catch project with multiple files, dedicate one file to compile the +// source code of Catch itself and reuse the resulting object file for linking. + +// Let Catch provide main(): +#define CATCH_CONFIG_MAIN + +#include + +TEST_CASE( "1: All test cases reside in other .cpp files (empty)", "[multi-file:1]" ) { +} + +// ^^^ +// Normally no TEST_CASEs in this file. +// Here just to show there are two source files via option --list-tests. + +// Compile & run: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -c 020-TestCase-1.cpp +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 020-TestCase TestCase-1.o 020-TestCase-2.cpp && 020-TestCase --success +// +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% -c 020-TestCase-1.cpp +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% -Fe020-TestCase.exe 020-TestCase-1.obj 020-TestCase-2.cpp && 020-TestCase --success + +// Expected test case listing: +// +// prompt> 020-TestCase --list-tests * +// Matching test cases: +// 1: All test cases reside in other .cpp files (empty) +// [multi-file:1] +// 2: Factorial of 0 is computed (fail) +// [multi-file:2] +// 2: Factorials of 1 and higher are computed (pass) +// [multi-file:2] +// 3 matching test cases diff --git a/lib/Catch2/examples/020-TestCase-2.cpp b/lib/Catch2/examples/020-TestCase-2.cpp new file mode 100644 index 0000000000..08b313e0cf --- /dev/null +++ b/lib/Catch2/examples/020-TestCase-2.cpp @@ -0,0 +1,33 @@ +// 020-TestCase-2.cpp + +// main() provided by Catch in file 020-TestCase-1.cpp. + +#include + +int Factorial( int number ) { + return number <= 1 ? number : Factorial( number - 1 ) * number; // fail +// return number <= 1 ? 1 : Factorial( number - 1 ) * number; // pass +} + +TEST_CASE( "2: Factorial of 0 is 1 (fail)", "[multi-file:2]" ) { + REQUIRE( Factorial(0) == 1 ); +} + +TEST_CASE( "2: Factorials of 1 and higher are computed (pass)", "[multi-file:2]" ) { + REQUIRE( Factorial(1) == 1 ); + REQUIRE( Factorial(2) == 2 ); + REQUIRE( Factorial(3) == 6 ); + REQUIRE( Factorial(10) == 3628800 ); +} + +// Compile: see 020-TestCase-1.cpp + +// Expected compact output (all assertions): +// +// prompt> 020-TestCase --reporter compact --success +// 020-TestCase-2.cpp:13: failed: Factorial(0) == 1 for: 0 == 1 +// 020-TestCase-2.cpp:17: passed: Factorial(1) == 1 for: 1 == 1 +// 020-TestCase-2.cpp:18: passed: Factorial(2) == 2 for: 2 == 2 +// 020-TestCase-2.cpp:19: passed: Factorial(3) == 6 for: 6 == 6 +// 020-TestCase-2.cpp:20: passed: Factorial(10) == 3628800 for: 3628800 (0x375f00) == 3628800 (0x375f00) +// Failed 1 test case, failed 1 assertion. diff --git a/lib/Catch2/examples/030-Asn-Require-Check.cpp b/lib/Catch2/examples/030-Asn-Require-Check.cpp new file mode 100644 index 0000000000..f814a1b3ca --- /dev/null +++ b/lib/Catch2/examples/030-Asn-Require-Check.cpp @@ -0,0 +1,74 @@ +// 030-Asn-Require-Check.cpp + +// Catch has two natural expression assertion macro's: +// - REQUIRE() stops at first failure. +// - CHECK() continues after failure. + +// There are two variants to support decomposing negated expressions: +// - REQUIRE_FALSE() stops at first failure. +// - CHECK_FALSE() continues after failure. + +// main() provided in 000-CatchMain.cpp + +#include + +std::string one() { + return "1"; +} + +TEST_CASE( "Assert that something is true (pass)", "[require]" ) { + REQUIRE( one() == "1" ); +} + +TEST_CASE( "Assert that something is true (fail)", "[require]" ) { + REQUIRE( one() == "x" ); +} + +TEST_CASE( "Assert that something is true (stop at first failure)", "[require]" ) { + WARN( "REQUIRE stops at first failure:" ); + + REQUIRE( one() == "x" ); + REQUIRE( one() == "1" ); +} + +TEST_CASE( "Assert that something is true (continue after failure)", "[check]" ) { + WARN( "CHECK continues after failure:" ); + + CHECK( one() == "x" ); + REQUIRE( one() == "1" ); +} + +TEST_CASE( "Assert that something is false (stops at first failure)", "[require-false]" ) { + WARN( "REQUIRE_FALSE stops at first failure:" ); + + REQUIRE_FALSE( one() == "1" ); + REQUIRE_FALSE( one() != "1" ); +} + +TEST_CASE( "Assert that something is false (continue after failure)", "[check-false]" ) { + WARN( "CHECK_FALSE continues after failure:" ); + + CHECK_FALSE( one() == "1" ); + REQUIRE_FALSE( one() != "1" ); +} + +// Compile & run: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 030-Asn-Require-Check 030-Asn-Require-Check.cpp 000-CatchMain.o && 030-Asn-Require-Check --success +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% 030-Asn-Require-Check.cpp 000-CatchMain.obj && 030-Asn-Require-Check --success + +// Expected compact output (all assertions): +// +// prompt> 030-Asn-Require-Check.exe --reporter compact --success +// 030-Asn-Require-Check.cpp:20: passed: one() == "1" for: "1" == "1" +// 030-Asn-Require-Check.cpp:24: failed: one() == "x" for: "1" == "x" +// 030-Asn-Require-Check.cpp:28: warning: 'REQUIRE stops at first failure:' +// 030-Asn-Require-Check.cpp:30: failed: one() == "x" for: "1" == "x" +// 030-Asn-Require-Check.cpp:35: warning: 'CHECK continues after failure:' +// 030-Asn-Require-Check.cpp:37: failed: one() == "x" for: "1" == "x" +// 030-Asn-Require-Check.cpp:38: passed: one() == "1" for: "1" == "1" +// 030-Asn-Require-Check.cpp:42: warning: 'REQUIRE_FALSE stops at first failure:' +// 030-Asn-Require-Check.cpp:44: failed: !(one() == "1") for: !("1" == "1") +// 030-Asn-Require-Check.cpp:49: warning: 'CHECK_FALSE continues after failure:' +// 030-Asn-Require-Check.cpp:51: failed: !(one() == "1") for: !("1" == "1") +// 030-Asn-Require-Check.cpp:52: passed: !(one() != "1") for: !("1" != "1") +// Failed 5 test cases, failed 5 assertions. diff --git a/lib/Catch2/examples/100-Fix-Section.cpp b/lib/Catch2/examples/100-Fix-Section.cpp new file mode 100644 index 0000000000..d0b9f2da5b --- /dev/null +++ b/lib/Catch2/examples/100-Fix-Section.cpp @@ -0,0 +1,69 @@ +// 100-Fix-Section.cpp + +// Catch has two ways to express fixtures: +// - Sections (this file) +// - Traditional class-based fixtures + +// main() provided in 000-CatchMain.cpp + +#include + +TEST_CASE( "vectors can be sized and resized", "[vector]" ) { + + // For each section, vector v is anew: + + std::vector v( 5 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + + SECTION( "resizing bigger changes size and capacity" ) { + v.resize( 10 ); + + REQUIRE( v.size() == 10 ); + REQUIRE( v.capacity() >= 10 ); + } + SECTION( "resizing smaller changes size but not capacity" ) { + v.resize( 0 ); + + REQUIRE( v.size() == 0 ); + REQUIRE( v.capacity() >= 5 ); + } + SECTION( "reserving bigger changes capacity but not size" ) { + v.reserve( 10 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 10 ); + } + SECTION( "reserving smaller does not change size or capacity" ) { + v.reserve( 0 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + } +} + +// Compile & run: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 100-Fix-Section 100-Fix-Section.cpp 000-CatchMain.o && 100-Fix-Section --success +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% 100-Fix-Section.cpp 000-CatchMain.obj && 100-Fix-Section --success + +// Expected compact output (all assertions): +// +// prompt> 100-Fix-Section.exe --reporter compact --success +// 100-Fix-Section.cpp:17: passed: v.size() == 5 for: 5 == 5 +// 100-Fix-Section.cpp:18: passed: v.capacity() >= 5 for: 5 >= 5 +// 100-Fix-Section.cpp:23: passed: v.size() == 10 for: 10 == 10 +// 100-Fix-Section.cpp:24: passed: v.capacity() >= 10 for: 10 >= 10 +// 100-Fix-Section.cpp:17: passed: v.size() == 5 for: 5 == 5 +// 100-Fix-Section.cpp:18: passed: v.capacity() >= 5 for: 5 >= 5 +// 100-Fix-Section.cpp:29: passed: v.size() == 0 for: 0 == 0 +// 100-Fix-Section.cpp:30: passed: v.capacity() >= 5 for: 5 >= 5 +// 100-Fix-Section.cpp:17: passed: v.size() == 5 for: 5 == 5 +// 100-Fix-Section.cpp:18: passed: v.capacity() >= 5 for: 5 >= 5 +// 100-Fix-Section.cpp:35: passed: v.size() == 5 for: 5 == 5 +// 100-Fix-Section.cpp:36: passed: v.capacity() >= 10 for: 10 >= 10 +// 100-Fix-Section.cpp:17: passed: v.size() == 5 for: 5 == 5 +// 100-Fix-Section.cpp:18: passed: v.capacity() >= 5 for: 5 >= 5 +// 100-Fix-Section.cpp:41: passed: v.size() == 5 for: 5 == 5 +// 100-Fix-Section.cpp:42: passed: v.capacity() >= 5 for: 5 >= 5 +// Passed 1 test case with 16 assertions. diff --git a/lib/Catch2/examples/110-Fix-ClassFixture.cpp b/lib/Catch2/examples/110-Fix-ClassFixture.cpp new file mode 100644 index 0000000000..e42fd17585 --- /dev/null +++ b/lib/Catch2/examples/110-Fix-ClassFixture.cpp @@ -0,0 +1,63 @@ +// 110-Fix-ClassFixture.cpp + +// Catch has two ways to express fixtures: +// - Sections +// - Traditional class-based fixtures (this file) + +// main() provided in 000-CatchMain.cpp + +#include + +class DBConnection +{ +public: + static DBConnection createConnection( std::string const & /*dbName*/ ) { + return DBConnection(); + } + + bool executeSQL( std::string const & /*query*/, int const /*id*/, std::string const & arg ) { + if ( arg.length() == 0 ) { + throw std::logic_error("empty SQL query argument"); + } + return true; // ok + } +}; + +class UniqueTestsFixture +{ +protected: + UniqueTestsFixture() + : conn( DBConnection::createConnection( "myDB" ) ) + {} + + int getID() { + return ++uniqueID; + } + +protected: + DBConnection conn; + +private: + static int uniqueID; +}; + +int UniqueTestsFixture::uniqueID = 0; + +TEST_CASE_METHOD( UniqueTestsFixture, "Create Employee/No Name", "[create]" ) { + REQUIRE_THROWS( conn.executeSQL( "INSERT INTO employee (id, name) VALUES (?, ?)", getID(), "") ); +} + +TEST_CASE_METHOD( UniqueTestsFixture, "Create Employee/Normal", "[create]" ) { + REQUIRE( conn.executeSQL( "INSERT INTO employee (id, name) VALUES (?, ?)", getID(), "Joe Bloggs" ) ); +} + +// Compile & run: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 110-Fix-ClassFixture 110-Fix-ClassFixture.cpp 000-CatchMain.o && 110-Fix-ClassFixture --success +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% 110-Fix-ClassFixture.cpp 000-CatchMain.obj && 110-Fix-ClassFixture --success + +// Expected compact output (all assertions): +// +// prompt> 110-Fix-ClassFixture.exe --reporter compact --success +// 110-Fix-ClassFixture.cpp:47: passed: conn.executeSQL( "INSERT INTO employee (id, name) VALUES (?, ?)", getID(), "") +// 110-Fix-ClassFixture.cpp:51: passed: conn.executeSQL( "INSERT INTO employee (id, name) VALUES (?, ?)", getID(), "Joe Bloggs" ) for: true +// Passed both 2 test cases with 2 assertions. diff --git a/lib/Catch2/examples/120-Bdd-ScenarioGivenWhenThen.cpp b/lib/Catch2/examples/120-Bdd-ScenarioGivenWhenThen.cpp new file mode 100644 index 0000000000..d1b9ce558a --- /dev/null +++ b/lib/Catch2/examples/120-Bdd-ScenarioGivenWhenThen.cpp @@ -0,0 +1,73 @@ +// 120-Bdd-ScenarioGivenWhenThen.cpp + +// main() provided in 000-CatchMain.cpp + +#include + +SCENARIO( "vectors can be sized and resized", "[vector]" ) { + + GIVEN( "A vector with some items" ) { + std::vector v( 5 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + + WHEN( "the size is increased" ) { + v.resize( 10 ); + + THEN( "the size and capacity change" ) { + REQUIRE( v.size() == 10 ); + REQUIRE( v.capacity() >= 10 ); + } + } + WHEN( "the size is reduced" ) { + v.resize( 0 ); + + THEN( "the size changes but not capacity" ) { + REQUIRE( v.size() == 0 ); + REQUIRE( v.capacity() >= 5 ); + } + } + WHEN( "more capacity is reserved" ) { + v.reserve( 10 ); + + THEN( "the capacity changes but not the size" ) { + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 10 ); + } + } + WHEN( "less capacity is reserved" ) { + v.reserve( 0 ); + + THEN( "neither size nor capacity are changed" ) { + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + } + } + } +} + +// Compile & run: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 120-Bdd-ScenarioGivenWhenThen 120-Bdd-ScenarioGivenWhenThen.cpp 000-CatchMain.o && 120-Bdd-ScenarioGivenWhenThen --success +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% 120-Bdd-ScenarioGivenWhenThen.cpp 000-CatchMain.obj && 120-Bdd-ScenarioGivenWhenThen --success + +// Expected compact output (all assertions): +// +// prompt> 120-Bdd-ScenarioGivenWhenThen.exe --reporter compact --success +// 120-Bdd-ScenarioGivenWhenThen.cpp:12: passed: v.size() == 5 for: 5 == 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:13: passed: v.capacity() >= 5 for: 5 >= 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:19: passed: v.size() == 10 for: 10 == 10 +// 120-Bdd-ScenarioGivenWhenThen.cpp:20: passed: v.capacity() >= 10 for: 10 >= 10 +// 120-Bdd-ScenarioGivenWhenThen.cpp:12: passed: v.size() == 5 for: 5 == 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:13: passed: v.capacity() >= 5 for: 5 >= 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:27: passed: v.size() == 0 for: 0 == 0 +// 120-Bdd-ScenarioGivenWhenThen.cpp:28: passed: v.capacity() >= 5 for: 5 >= 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:12: passed: v.size() == 5 for: 5 == 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:13: passed: v.capacity() >= 5 for: 5 >= 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:35: passed: v.size() == 5 for: 5 == 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:36: passed: v.capacity() >= 10 for: 10 >= 10 +// 120-Bdd-ScenarioGivenWhenThen.cpp:12: passed: v.size() == 5 for: 5 == 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:13: passed: v.capacity() >= 5 for: 5 >= 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:43: passed: v.size() == 5 for: 5 == 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:44: passed: v.capacity() >= 5 for: 5 >= 5 +// Passed 1 test case with 16 assertions. diff --git a/lib/Catch2/examples/200-Rpt-CatchMain.cpp b/lib/Catch2/examples/200-Rpt-CatchMain.cpp new file mode 100644 index 0000000000..b84c804dd5 --- /dev/null +++ b/lib/Catch2/examples/200-Rpt-CatchMain.cpp @@ -0,0 +1,27 @@ +// 200-Rpt-CatchMain.cpp + +// In a Catch project with multiple files, dedicate one file to compile the +// source code of Catch itself and reuse the resulting object file for linking. + +// Let Catch provide main(): +#define CATCH_CONFIG_MAIN + +#include + +#ifdef CATCH_EXAMPLE_RPT_1 +#include CATCH_EXAMPLE_RPT_1 +#endif + +#ifdef CATCH_EXAMPLE_RPT_2 +#include CATCH_EXAMPLE_RPT_2 +#endif + +#ifdef CATCH_EXAMPLE_RPT_3 +#include CATCH_EXAMPLE_RPT_3 +#endif + +// That's it + +// Compile implementation of Catch for use with files that do contain tests: +// - g++ -std=c++11 -Wall -I$(CATCH_ROOT) -DCATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_teamcity.hpp\" -o 200-Rpt-CatchMainTeamCity.o -c 200-Rpt-CatchMain.cpp +// cl -EHsc -I%CATCH_ROOT% -DCATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_teamcity.hpp\" -Fo200-Rpt-CatchMainTeamCity.obj -c 200-Rpt-CatchMain.cpp diff --git a/lib/Catch2/examples/207-Rpt-TeamCityReporter.cpp b/lib/Catch2/examples/207-Rpt-TeamCityReporter.cpp new file mode 100644 index 0000000000..d28460f400 --- /dev/null +++ b/lib/Catch2/examples/207-Rpt-TeamCityReporter.cpp @@ -0,0 +1,171 @@ +// 207-Rpt-TeamCityReporter.cpp + +// Catch has built-in and external reporters: +// Built-in: +// - compact +// - console +// - junit +// - xml +// External: +// - automake +// - tap +// - teamcity (this example) + +// main() and reporter code provided in 200-Rpt-CatchMain.cpp + +#include + +#ifdef _MSC_VER +# pragma warning (disable : 4702) // Disable warning: unreachable code +#endif + +TEST_CASE( "TeamCity passes unconditionally succeeding assertion", "[teamcity]" ) { + + SUCCEED(); +} + +TEST_CASE( "TeamCity reports unconditionally failing assertion", "[teamcity]" ) { + + FAIL(); +} + +TEST_CASE( "TeamCity reports failing check", "[teamcity]" ) { + + REQUIRE( 3 == 7 ); +} + +TEST_CASE( "TeamCity reports failing check-false", "[teamcity]" ) { + + REQUIRE_FALSE( 3 == 3 ); +} + +TEST_CASE( "TeamCity reports failing check-that", "[teamcity]" ) { + + using namespace Catch; + + REQUIRE_THAT( "hello", Contains( "world" ) ); +} + +TEST_CASE( "TeamCity reports unexpected exception", "[teamcity]" ) { + + REQUIRE( (throw std::runtime_error("surprise!"), true) ); +} + +TEST_CASE( "TeamCity reports undesired exception", "[teamcity]" ) { + + REQUIRE_NOTHROW( (throw std::runtime_error("surprise!"), true) ); +} + +TEST_CASE( "TeamCity reports missing expected exception", "[teamcity]" ) { + + REQUIRE_THROWS( true ); +} + +TEST_CASE( "TeamCity reports missing specific expected exception", "[teamcity]" ) { + + REQUIRE_THROWS_AS( throw std::bad_alloc(), std::runtime_error ); +} + +TEST_CASE( "TeamCity reports unexpected message in expected exception", "[teamcity]" ) { + + using namespace Catch; + + CHECK_THROWS_WITH( throw std::runtime_error("hello"), "world" ); + CHECK_THROWS_WITH( throw std::runtime_error("hello"), Contains("world") ); +} + +struct MyException: public std::runtime_error +{ + MyException( char const * text ) + : std::runtime_error( text ) {} + + ~MyException() override; +}; + +// prevent -Wweak-vtables: +MyException::~MyException() = default; + +struct MyExceptionMatcher : Catch::MatcherBase< std::runtime_error > +{ + std::string m_text; + + MyExceptionMatcher( char const * text ) + : m_text( text ) + {} + + ~MyExceptionMatcher() override; + + bool match( std::runtime_error const & arg ) const override + { + return m_text == arg.what() ; + } + + std::string describe() const override + { + return "it's me"; + } +}; + +// prevent -Wweak-vtables: +MyExceptionMatcher::~MyExceptionMatcher() = default; + +TEST_CASE( "TeamCity failing check-throws-matches", "[teamcity]" ) { + + CHECK_THROWS_MATCHES( throw MyException("hello"), MyException, MyExceptionMatcher("world") ); +} + +// [!throws] - lets Catch know that this test is likely to throw an exception even if successful. +// This causes the test to be excluded when running with -e or --nothrow. + +// No special effects for the reporter. + +TEST_CASE( "TeamCity throwing exception with tag [!throws]", "[teamcity][!throws]" ) { + + REQUIRE_THROWS( throw std::runtime_error("unsurprisingly") ); +} + +// [!mayfail] - doesn't fail the test if any given assertion fails (but still reports it). This can be useful to flag a work-in-progress, or a known issue that you don't want to immediately fix but still want to track in your tests. + +TEST_CASE( "TeamCity failing assertion with tag [!mayfail]", "[teamcity][!mayfail] " ) { + + REQUIRE( 3 == 7 ); // doesn't fail test case this time, reports: testIgnored + REQUIRE( 3 == 3 ); +} + +// [!shouldfail] - like [!mayfail] but fails the test if it passes. +// This can be useful if you want to be notified of accidental, or third-party, fixes. + +TEST_CASE( "TeamCity succeeding assertion with tag [!shouldfail]", "[teamcity][!shouldfail]" ) { + + SUCCEED( "Marked [!shouldfail]" ); +} + +// Compile & run: +// - g++ -std=c++11 -Wall -I$(CATCH_ROOT) -DCATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_teamcity.hpp\" -o 200-Rpt-CatchMainTeamCity.o -c 200-Rpt-CatchMain.cpp +// - g++ -std=c++11 -Wall -I$(CATCH_ROOT) -o 207-Rpt-TeamCityReporter 207-Rpt-TeamCityReporter.cpp 200-Rpt-CatchMainTeamCity.o && 207-Rpt-TeamCityReporter --list-reporters +// +// - cl -EHsc -I%CATCH_ROOT% -DCATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_teamcity.hpp\" -Fo200-Rpt-CatchMainTeamCity.obj -c 200-Rpt-CatchMain.cpp +// - cl -EHsc -I%CATCH_ROOT% 207-Rpt-TeamCityReporter.cpp 200-Rpt-CatchMainTeamCity.o && 207-Rpt-TeamCityReporter --list-reporters + +// Compilation output (--list-reporters): +// Available reporters: +// compact: Reports test results on a single line, suitable for IDEs +// console: Reports test results as plain lines of text +// junit: Reports test results in an XML format that looks like Ant's +// junitreport target +// teamcity: Reports test results as TeamCity service messages +// xml: Reports test results as an XML document + +// Expected output (abbreviated and broken into shorter lines): +// +// prompt> 207-Rpt-TeamCityReporter.exe --reporter teamcity +// ##teamcity[testSuiteStarted name='207-Rpt-TeamCityReporter.exe'] +// ##teamcity[testStarted name='TeamCity passes unconditionally succeeding assertion'] +// ##teamcity[testFinished name='TeamCity passes unconditionally succeeding assertion' duration='1'] +// ##teamcity[testStarted name='TeamCity reports unconditionally failing assertion'] +// ##teamcity[testFailed name='TeamCity reports unconditionally failing assertion' / +// message='.../examples/207-Rpt-TeamCityReporter.cpp:23|n/ +// ...............................................................................|n|n/ +// .../examples/207-Rpt-TeamCityReporter.cpp:25|nexplicit failure'] +// ##teamcity[testFinished name='TeamCity reports unconditionally failing assertion' duration='3'] +// ... diff --git a/lib/Catch2/examples/210-Evt-EventListeners.cpp b/lib/Catch2/examples/210-Evt-EventListeners.cpp new file mode 100644 index 0000000000..044a29e3a2 --- /dev/null +++ b/lib/Catch2/examples/210-Evt-EventListeners.cpp @@ -0,0 +1,422 @@ +// 210-Evt-EventListeners.cpp + +// Contents: +// 1. Printing of listener data +// 2. My listener and registration +// 3. Test cases + +// main() provided in 000-CatchMain.cpp + +// Let Catch provide the required interfaces: +#define CATCH_CONFIG_EXTERNAL_INTERFACES + +#include +#include + +// ----------------------------------------------------------------------- +// 1. Printing of listener data: +// + +std::string ws(int const level) { + return std::string( 2 * level, ' ' ); +} + +template< typename T > +std::ostream& operator<<( std::ostream& os, std::vector const& v ) { + os << "{ "; + for ( const auto& x : v ) + os << x << ", "; + return os << "}"; +} + +// struct SourceLineInfo { +// char const* file; +// std::size_t line; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::SourceLineInfo const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- file: " << info.file << "\n" + << ws(level+1) << "- line: " << info.line << "\n"; +} + +//struct MessageInfo { +// std::string macroName; +// std::string message; +// SourceLineInfo lineInfo; +// ResultWas::OfType type; +// unsigned int sequence; +//}; + +void print( std::ostream& os, int const level, Catch::MessageInfo const& info ) { + os << ws(level+1) << "- macroName: '" << info.macroName << "'\n" + << ws(level+1) << "- message '" << info.message << "'\n"; + print( os,level+1 , "- lineInfo", info.lineInfo ); + os << ws(level+1) << "- sequence " << info.sequence << "\n"; +} + +void print( std::ostream& os, int const level, std::string const& title, std::vector const& v ) { + os << ws(level ) << title << ":\n"; + for ( const auto& x : v ) + { + os << ws(level+1) << "{\n"; + print( os, level+2, x ); + os << ws(level+1) << "}\n"; + } +// os << ws(level+1) << "\n"; +} + +// struct TestRunInfo { +// std::string name; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::TestRunInfo const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- name: " << info.name << "\n"; +} + +// struct Counts { +// std::size_t total() const; +// bool allPassed() const; +// bool allOk() const; +// +// std::size_t passed = 0; +// std::size_t failed = 0; +// std::size_t failedButOk = 0; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::Counts const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- total(): " << info.total() << "\n" + << ws(level+1) << "- allPassed(): " << info.allPassed() << "\n" + << ws(level+1) << "- allOk(): " << info.allOk() << "\n" + << ws(level+1) << "- passed: " << info.passed << "\n" + << ws(level+1) << "- failed: " << info.failed << "\n" + << ws(level+1) << "- failedButOk: " << info.failedButOk << "\n"; +} + +// struct Totals { +// Counts assertions; +// Counts testCases; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::Totals const& info ) { + os << ws(level) << title << ":\n"; + print( os, level+1, "- assertions", info.assertions ); + print( os, level+1, "- testCases" , info.testCases ); +} + +// struct TestRunStats { +// TestRunInfo runInfo; +// Totals totals; +// bool aborting; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::TestRunStats const& info ) { + os << ws(level) << title << ":\n"; + print( os, level+1 , "- runInfo", info.runInfo ); + print( os, level+1 , "- totals" , info.totals ); + os << ws(level+1) << "- aborting: " << info.aborting << "\n"; +} + +// struct TestCaseInfo { +// enum SpecialProperties{ +// None = 0, +// IsHidden = 1 << 1, +// ShouldFail = 1 << 2, +// MayFail = 1 << 3, +// Throws = 1 << 4, +// NonPortable = 1 << 5, +// Benchmark = 1 << 6 +// }; +// +// bool isHidden() const; +// bool throws() const; +// bool okToFail() const; +// bool expectedToFail() const; +// +// std::string tagsAsString() const; +// +// std::string name; +// std::string className; +// std::string description; +// std::vector tags; +// std::vector lcaseTags; +// SourceLineInfo lineInfo; +// SpecialProperties properties; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::TestCaseInfo const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- isHidden(): " << info.isHidden() << "\n" + << ws(level+1) << "- throws(): " << info.throws() << "\n" + << ws(level+1) << "- okToFail(): " << info.okToFail() << "\n" + << ws(level+1) << "- expectedToFail(): " << info.expectedToFail() << "\n" + << ws(level+1) << "- tagsAsString(): '" << info.tagsAsString() << "'\n" + << ws(level+1) << "- name: '" << info.name << "'\n" + << ws(level+1) << "- className: '" << info.className << "'\n" + << ws(level+1) << "- description: '" << info.description << "'\n" + << ws(level+1) << "- tags: " << info.tags << "\n" + << ws(level+1) << "- lcaseTags: " << info.lcaseTags << "\n"; + print( os, level+1 , "- lineInfo", info.lineInfo ); + os << ws(level+1) << "- properties (flags): 0x" << std::hex << info.properties << std::dec << "\n"; +} + +// struct TestCaseStats { +// TestCaseInfo testInfo; +// Totals totals; +// std::string stdOut; +// std::string stdErr; +// bool aborting; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::TestCaseStats const& info ) { + os << ws(level ) << title << ":\n"; + print( os, level+1 , "- testInfo", info.testInfo ); + print( os, level+1 , "- totals" , info.totals ); + os << ws(level+1) << "- stdOut: " << info.stdOut << "\n" + << ws(level+1) << "- stdErr: " << info.stdErr << "\n" + << ws(level+1) << "- aborting: " << info.aborting << "\n"; +} + +// struct SectionInfo { +// std::string name; +// std::string description; +// SourceLineInfo lineInfo; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::SectionInfo const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- name: " << info.name << "\n"; + print( os, level+1 , "- lineInfo", info.lineInfo ); +} + +// struct SectionStats { +// SectionInfo sectionInfo; +// Counts assertions; +// double durationInSeconds; +// bool missingAssertions; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::SectionStats const& info ) { + os << ws(level ) << title << ":\n"; + print( os, level+1 , "- sectionInfo", info.sectionInfo ); + print( os, level+1 , "- assertions" , info.assertions ); + os << ws(level+1) << "- durationInSeconds: " << info.durationInSeconds << "\n" + << ws(level+1) << "- missingAssertions: " << info.missingAssertions << "\n"; +} + +// struct AssertionInfo +// { +// StringRef macroName; +// SourceLineInfo lineInfo; +// StringRef capturedExpression; +// ResultDisposition::Flags resultDisposition; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::AssertionInfo const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- macroName: '" << info.macroName << "'\n"; + print( os, level+1 , "- lineInfo" , info.lineInfo ); + os << ws(level+1) << "- capturedExpression: '" << info.capturedExpression << "'\n" + << ws(level+1) << "- resultDisposition (flags): 0x" << std::hex << info.resultDisposition << std::dec << "\n"; +} + +//struct AssertionResultData +//{ +// std::string reconstructExpression() const; +// +// std::string message; +// mutable std::string reconstructedExpression; +// LazyExpression lazyExpression; +// ResultWas::OfType resultType; +//}; + +void print( std::ostream& os, int const level, std::string const& title, Catch::AssertionResultData const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- reconstructExpression(): '" << info.reconstructExpression() << "'\n" + << ws(level+1) << "- message: '" << info.message << "'\n" + << ws(level+1) << "- lazyExpression: '" << "(info.lazyExpression)" << "'\n" + << ws(level+1) << "- resultType: '" << info.resultType << "'\n"; +} + +//class AssertionResult { +// bool isOk() const; +// bool succeeded() const; +// ResultWas::OfType getResultType() const; +// bool hasExpression() const; +// bool hasMessage() const; +// std::string getExpression() const; +// std::string getExpressionInMacro() const; +// bool hasExpandedExpression() const; +// std::string getExpandedExpression() const; +// std::string getMessage() const; +// SourceLineInfo getSourceInfo() const; +// std::string getTestMacroName() const; +// +// AssertionInfo m_info; +// AssertionResultData m_resultData; +//}; + +void print( std::ostream& os, int const level, std::string const& title, Catch::AssertionResult const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- isOk(): " << info.isOk() << "\n" + << ws(level+1) << "- succeeded(): " << info.succeeded() << "\n" + << ws(level+1) << "- getResultType(): " << info.getResultType() << "\n" + << ws(level+1) << "- hasExpression(): " << info.hasExpression() << "\n" + << ws(level+1) << "- hasMessage(): " << info.hasMessage() << "\n" + << ws(level+1) << "- getExpression(): '" << info.getExpression() << "'\n" + << ws(level+1) << "- getExpressionInMacro(): '" << info.getExpressionInMacro() << "'\n" + << ws(level+1) << "- hasExpandedExpression(): " << info.hasExpandedExpression() << "\n" + << ws(level+1) << "- getExpandedExpression(): " << info.getExpandedExpression() << "'\n" + << ws(level+1) << "- getMessage(): '" << info.getMessage() << "'\n"; + print( os, level+1 , "- getSourceInfo(): ", info.getSourceInfo() ); + os << ws(level+1) << "- getTestMacroName(): '" << info.getTestMacroName() << "'\n"; + +// print( os, level+1 , "- *** m_info (AssertionInfo)", info.m_info ); +// print( os, level+1 , "- *** m_resultData (AssertionResultData)", info.m_resultData ); +} + +// struct AssertionStats { +// AssertionResult assertionResult; +// std::vector infoMessages; +// Totals totals; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::AssertionStats const& info ) { + os << ws(level ) << title << ":\n"; + print( os, level+1 , "- assertionResult", info.assertionResult ); + print( os, level+1 , "- infoMessages", info.infoMessages ); + print( os, level+1 , "- totals", info.totals ); +} + +// ----------------------------------------------------------------------- +// 2. My listener and registration: +// + +char const * dashed_line = + "--------------------------------------------------------------------------"; + +struct MyListener : Catch::TestEventListenerBase { + + using TestEventListenerBase::TestEventListenerBase; // inherit constructor + + // Get rid of Wweak-tables + ~MyListener(); + + // The whole test run starting + void testRunStarting( Catch::TestRunInfo const& testRunInfo ) override { + std::cout + << std::boolalpha + << "\nEvent: testRunStarting:\n"; + print( std::cout, 1, "- testRunInfo", testRunInfo ); + } + + // The whole test run ending + void testRunEnded( Catch::TestRunStats const& testRunStats ) override { + std::cout + << dashed_line + << "\nEvent: testRunEnded:\n"; + print( std::cout, 1, "- testRunStats", testRunStats ); + } + + // A test is being skipped (because it is "hidden") + void skipTest( Catch::TestCaseInfo const& testInfo ) override { + std::cout + << dashed_line + << "\nEvent: skipTest:\n"; + print( std::cout, 1, "- testInfo", testInfo ); + } + + // Test cases starting + void testCaseStarting( Catch::TestCaseInfo const& testInfo ) override { + std::cout + << dashed_line + << "\nEvent: testCaseStarting:\n"; + print( std::cout, 1, "- testInfo", testInfo ); + } + + // Test cases ending + void testCaseEnded( Catch::TestCaseStats const& testCaseStats ) override { + std::cout << "\nEvent: testCaseEnded:\n"; + print( std::cout, 1, "testCaseStats", testCaseStats ); + } + + // Sections starting + void sectionStarting( Catch::SectionInfo const& sectionInfo ) override { + std::cout << "\nEvent: sectionStarting:\n"; + print( std::cout, 1, "- sectionInfo", sectionInfo ); + } + + // Sections ending + void sectionEnded( Catch::SectionStats const& sectionStats ) override { + std::cout << "\nEvent: sectionEnded:\n"; + print( std::cout, 1, "- sectionStats", sectionStats ); + } + + // Assertions before/ after + void assertionStarting( Catch::AssertionInfo const& assertionInfo ) override { + std::cout << "\nEvent: assertionStarting:\n"; + print( std::cout, 1, "- assertionInfo", assertionInfo ); + } + + bool assertionEnded( Catch::AssertionStats const& assertionStats ) override { + std::cout << "\nEvent: assertionEnded:\n"; + print( std::cout, 1, "- assertionStats", assertionStats ); + return true; + } +}; + +CATCH_REGISTER_LISTENER( MyListener ) + +// Get rid of Wweak-tables +MyListener::~MyListener() {} + + +// ----------------------------------------------------------------------- +// 3. Test cases: +// + +TEST_CASE( "1: Hidden testcase", "[.hidden]" ) { +} + +TEST_CASE( "2: Testcase with sections", "[tag-A][tag-B]" ) { + + int i = 42; + + REQUIRE( i == 42 ); + + SECTION("Section 1") { + INFO("Section 1"); + i = 7; + SECTION("Section 1.1") { + INFO("Section 1.1"); + REQUIRE( i == 42 ); + } + } + + SECTION("Section 2") { + INFO("Section 2"); + REQUIRE( i == 42 ); + } + WARN("At end of test case"); +} + +struct Fixture { + int fortytwo() const { + return 42; + } +}; + +TEST_CASE_METHOD( Fixture, "3: Testcase with class-based fixture", "[tag-C][tag-D]" ) { + REQUIRE( fortytwo() == 42 ); +} + +// Compile & run: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 210-Evt-EventListeners 210-Evt-EventListeners.cpp 000-CatchMain.o && 210-Evt-EventListeners --success +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% 210-Evt-EventListeners.cpp 000-CatchMain.obj && 210-Evt-EventListeners --success + +// Expected compact output (all assertions): +// +// prompt> 210-Evt-EventListeners --reporter compact --success +// result omitted for brevity. diff --git a/lib/Catch2/examples/231-Cfg-OutputStreams.cpp b/lib/Catch2/examples/231-Cfg-OutputStreams.cpp new file mode 100644 index 0000000000..8c65cc4499 --- /dev/null +++ b/lib/Catch2/examples/231-Cfg-OutputStreams.cpp @@ -0,0 +1,56 @@ +// 231-Cfg-OutputStreams.cpp +// Show how to replace the streams with a simple custom made streambuf. + +// Note that this reimplementation _does not_ follow `std::cerr` +// semantic, because it buffers the output. For most uses however, +// there is no important difference between having `std::cerr` buffered +// or unbuffered. + +#define CATCH_CONFIG_NOSTDOUT +#define CATCH_CONFIG_MAIN +#include + + +class out_buff : public std::stringbuf { + std::FILE* m_stream; +public: + out_buff(std::FILE* stream):m_stream(stream) {} + ~out_buff(); + int sync() override { + int ret = 0; + for (unsigned char c : str()) { + if (putc(c, m_stream) == EOF) { + ret = -1; + break; + } + } + // Reset the buffer to avoid printing it multiple times + str(""); + return ret; + } +}; + +out_buff::~out_buff() { pubsync(); } + +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wexit-time-destructors" // static variables in cout/cerr/clog +#endif + +namespace Catch { + std::ostream& cout() { + static std::ostream ret(new out_buff(stdout)); + return ret; + } + std::ostream& clog() { + static std::ostream ret(new out_buff(stderr)); + return ret; + } + std::ostream& cerr() { + return clog(); + } +} + + +TEST_CASE("This binary uses putc to write out output", "[compilation-only]") { + SUCCEED("Nothing to test."); +} diff --git a/lib/Catch2/examples/300-Gen-OwnGenerator.cpp b/lib/Catch2/examples/300-Gen-OwnGenerator.cpp new file mode 100644 index 0000000000..c8b6a65df7 --- /dev/null +++ b/lib/Catch2/examples/300-Gen-OwnGenerator.cpp @@ -0,0 +1,59 @@ +// 300-Gen-OwnGenerator.cpp +// Shows how to define a custom generator. + +// Specifically we will implement a random number generator for integers +// It will have infinite capacity and settable lower/upper bound + +#include + +#include + +// This class shows how to implement a simple generator for Catch tests +class RandomIntGenerator : public Catch::Generators::IGenerator { + std::minstd_rand m_rand; + std::uniform_int_distribution<> m_dist; + int current_number; +public: + + RandomIntGenerator(int low, int high): + m_rand(std::random_device{}()), + m_dist(low, high) + { + static_cast(next()); + } + + int const& get() const override; + bool next() override { + current_number = m_dist(m_rand); + return true; + } +}; + +// Avoids -Wweak-vtables +int const& RandomIntGenerator::get() const { + return current_number; +} + +// This helper function provides a nicer UX when instantiating the generator +// Notice that it returns an instance of GeneratorWrapper, which +// is a value-wrapper around std::unique_ptr>. +Catch::Generators::GeneratorWrapper random(int low, int high) { + return Catch::Generators::GeneratorWrapper(std::unique_ptr>(new RandomIntGenerator(low, high))); +} + +// The two sections in this test case are equivalent, but the first one +// is much more readable/nicer to use +TEST_CASE("Generating random ints", "[example][generator]") { + SECTION("Nice UX") { + auto i = GENERATE(take(100, random(-100, 100))); + REQUIRE(i >= -100); + REQUIRE(i <= 100); + } + SECTION("Creating the random generator directly") { + auto i = GENERATE(take(100, GeneratorWrapper(std::unique_ptr>(new RandomIntGenerator(-100, 100))))); + REQUIRE(i >= -100); + REQUIRE(i <= 100); + } +} + +// Compiling and running this file will result in 400 successful assertions diff --git a/lib/Catch2/examples/301-Gen-MapTypeConversion.cpp b/lib/Catch2/examples/301-Gen-MapTypeConversion.cpp new file mode 100644 index 0000000000..54eab571e2 --- /dev/null +++ b/lib/Catch2/examples/301-Gen-MapTypeConversion.cpp @@ -0,0 +1,58 @@ +// 301-Gen-MapTypeConversion.cpp +// Shows how to use map to modify generator's return type. + +// Specifically we wrap a std::string returning generator with a generator +// that converts the strings using stoi, so the returned type is actually +// an int. + +#include + +#include +#include + +// Returns a line from a stream. You could have it e.g. read lines from +// a file, but to avoid problems with paths in examples, we will use +// a fixed stringstream. +class LineGenerator : public Catch::Generators::IGenerator { + std::string m_line; + std::stringstream m_stream; +public: + LineGenerator() { + m_stream.str("1\n2\n3\n4\n"); + if (!next()) { + throw Catch::GeneratorException("Couldn't read a single line"); + } + } + + std::string const& get() const override; + + bool next() override { + return !!std::getline(m_stream, m_line); + } +}; + +std::string const& LineGenerator::get() const { + return m_line; +} + +// This helper function provides a nicer UX when instantiating the generator +// Notice that it returns an instance of GeneratorWrapper, which +// is a value-wrapper around std::unique_ptr>. +Catch::Generators::GeneratorWrapper lines(std::string /* ignored for example */) { + return Catch::Generators::GeneratorWrapper( + std::unique_ptr>( + new LineGenerator() + ) + ); +} + + + +TEST_CASE("filter can convert types inside the generator expression", "[example][generator]") { + auto num = GENERATE(map([](std::string const& line) { return std::stoi(line); }, + lines("fake-file"))); + + REQUIRE(num > 0); +} + +// Compiling and running this file will result in 4 successful assertions diff --git a/lib/Catch2/examples/302-Gen-Table.cpp b/lib/Catch2/examples/302-Gen-Table.cpp new file mode 100644 index 0000000000..14a0405ebf --- /dev/null +++ b/lib/Catch2/examples/302-Gen-Table.cpp @@ -0,0 +1,54 @@ +// 302-Gen-Table.cpp +// Shows how to use table to run a test many times with different inputs. Lifted from examples on +// issue #850. + +#include +#include + +struct TestSubject { + // this is the method we are going to test. It returns the length of the + // input string. + size_t GetLength( const std::string& input ) const { return input.size(); } +}; + + +TEST_CASE("Table allows pre-computed test inputs and outputs", "[example][generator]") { + using std::make_tuple; + // do setup here as normal + TestSubject subj; + + SECTION("This section is run for each row in the table") { + std::string test_input; + size_t expected_output; + std::tie( test_input, expected_output ) = + GENERATE( table( + { /* In this case one of the parameters to our test case is the + * expected output, but this is not required. There could be + * multiple expected values in the table, which can have any + * (fixed) number of columns. + */ + make_tuple( "one", 3 ), + make_tuple( "two", 3 ), + make_tuple( "three", 5 ), + make_tuple( "four", 4 ) } ) ); + + // run the test + auto result = subj.GetLength(test_input); + // capture the input data to go with the outputs. + CAPTURE(test_input); + // check it matches the pre-calculated data + REQUIRE(result == expected_output); + } // end section +} + +/* Possible simplifications where less legacy toolchain support is needed: + * + * - With libstdc++6 or newer, the make_tuple() calls can be omitted + * (technically C++17 but does not require -std in GCC/Clang). See + * https://stackoverflow.com/questions/12436586/tuple-vector-and-initializer-list + * + * - In C++17 mode std::tie() and the preceeding variable delcarations can be + * replaced by structured bindings: auto [test_input, expected] = GENERATE( + * table({ ... + */ +// Compiling and running this file will result in 4 successful assertions diff --git a/lib/Catch2/examples/310-Gen-VariablesInGenerators.cpp b/lib/Catch2/examples/310-Gen-VariablesInGenerators.cpp new file mode 100644 index 0000000000..422815d248 --- /dev/null +++ b/lib/Catch2/examples/310-Gen-VariablesInGenerators.cpp @@ -0,0 +1,33 @@ +// 310-Gen-VariablesInGenerator.cpp +// Shows how to use variables when creating generators. + +// Note that using variables inside generators is dangerous and should +// be done only if you know what you are doing, because the generators +// _WILL_ outlive the variables -- thus they should be either captured +// by value directly, or copied by the generators during construction. + +#include + +TEST_CASE("Generate random doubles across different ranges", + "[generator][example][advanced]") { + // Workaround for old libstdc++ + using record = std::tuple; + // Set up 3 ranges to generate numbers from + auto r = GENERATE(table({ + record{3, 4}, + record{-4, -3}, + record{10, 1000} + })); + + // This will not compile (intentionally), because it accesses a variable + // auto number = GENERATE(take(50, random(std::get<0>(r), std::get<1>(r)))); + + // GENERATE_COPY copies all variables mentioned inside the expression + // thus this will work. + auto number = GENERATE_COPY(take(50, random(std::get<0>(r), std::get<1>(r)))); + + REQUIRE(std::abs(number) > 0); +} + +// Compiling and running this file will result in 150 successful assertions + diff --git a/lib/Catch2/examples/311-Gen-CustomCapture.cpp b/lib/Catch2/examples/311-Gen-CustomCapture.cpp new file mode 100644 index 0000000000..970512c2cf --- /dev/null +++ b/lib/Catch2/examples/311-Gen-CustomCapture.cpp @@ -0,0 +1,41 @@ +// 311-Gen-CustomCapture.cpp +// Shows how to provide custom capture list to the generator expression + +// Note that using variables inside generators is dangerous and should +// be done only if you know what you are doing, because the generators +// _WILL_ outlive the variables. Also, even if you know what you are +// doing, you should probably use GENERATE_COPY or GENERATE_REF macros +// instead. However, if your use case requires having a +// per-variable custom capture list, this example shows how to achieve +// that. + +#include + +TEST_CASE("Generate random doubles across different ranges", + "[generator][example][advanced]") { + // Workaround for old libstdc++ + using record = std::tuple; + // Set up 3 ranges to generate numbers from + auto r1 = GENERATE(table({ + record{3, 4}, + record{-4, -3}, + record{10, 1000} + })); + + auto r2(r1); + + // This will take r1 by reference and r2 by value. + // Note that there are no advantages for doing so in this example, + // it is done only for expository purposes. + auto number = Catch::Generators::generate( "custom capture generator", CATCH_INTERNAL_LINEINFO, + [&r1, r2]{ + using namespace Catch::Generators; + return makeGenerators(take(50, random(std::get<0>(r1), std::get<1>(r2)))); + } + ); + + REQUIRE(std::abs(number) > 0); +} + +// Compiling and running this file will result in 150 successful assertions + diff --git a/lib/Catch2/examples/CMakeLists.txt b/lib/Catch2/examples/CMakeLists.txt new file mode 100644 index 0000000000..d9842486e7 --- /dev/null +++ b/lib/Catch2/examples/CMakeLists.txt @@ -0,0 +1,158 @@ +# +# Build examples. +# +# Requires CATCH_BUILD_EXAMPLES to be defined 'true', see ../CMakeLists.txt. +# + +cmake_minimum_required( VERSION 3.0 ) + +project( CatchExamples CXX ) + +message( STATUS "Examples included" ) + +# define folders used: + +set( EXAMPLES_DIR ${CATCH_DIR}/examples ) +set( HEADER_DIR ${CATCH_DIR}/single_include ) +set( REPORTER_HEADER_DIR ${CATCH_DIR}/include/reporters ) + +# single-file sources: + +set( SOURCES_SINGLE_FILE + 010-TestCase.cpp + 231-Cfg-OutputStreams.cpp +) + +# multiple-file modules: + +set( SOURCES_020 + 020-TestCase-1.cpp + 020-TestCase-2.cpp +) + +# main for idiomatic test sources: + +set( SOURCES_IDIOMATIC_MAIN + 000-CatchMain.cpp +) + +# sources to combine with 000-CatchMain.cpp: + +set( SOURCES_IDIOMATIC_TESTS + 030-Asn-Require-Check.cpp + 100-Fix-Section.cpp + 110-Fix-ClassFixture.cpp + 120-Bdd-ScenarioGivenWhenThen.cpp + 210-Evt-EventListeners.cpp + 300-Gen-OwnGenerator.cpp + 301-Gen-MapTypeConversion.cpp + 302-Gen-Table.cpp + 310-Gen-VariablesInGenerators.cpp + 311-Gen-CustomCapture.cpp +) + +# main-s for reporter-specific test sources: + +set( SOURCES_REPORTERS_MAIN + 200-Rpt-CatchMain.cpp +) + +string( REPLACE ".cpp" "" BASENAMES_REPORTERS_MAIN 200-Rpt-CatchMain.cpp ) + +set( NAMES_REPORTERS TeamCity ) + +foreach( reporter ${NAMES_REPORTERS} ) + list( APPEND SOURCES_SPECIFIC_REPORTERS_MAIN ${BASENAMES_REPORTERS_MAIN}${reporter}.cpp ) +endforeach() + +# sources to combine with 200-Rpt-CatchMain{Reporter}.cpp: + +set( SOURCES_REPORTERS_TESTS + 207-Rpt-TeamCityReporter.cpp +) + +# check if all sources are listed, warn if not: + +set( SOURCES_ALL + ${SOURCES_020} + ${SOURCES_SINGLE_FILE} + ${SOURCES_IDIOMATIC_MAIN} + ${SOURCES_IDIOMATIC_TESTS} + ${SOURCES_REPORTERS_MAIN} + ${SOURCES_REPORTERS_TESTS} +) + +foreach( name ${SOURCES_ALL} ) + list( APPEND SOURCES_ALL_PATH ${EXAMPLES_DIR}/${name} ) +endforeach() + +CheckFileList( SOURCES_ALL_PATH ${EXAMPLES_DIR} ) + +# create target names: + +string( REPLACE ".cpp" "" BASENAMES_SINGLE_FILE "${SOURCES_SINGLE_FILE}" ) +string( REPLACE ".cpp" "" BASENAMES_IDIOMATIC_TESTS "${SOURCES_IDIOMATIC_TESTS}" ) +string( REPLACE ".cpp" "" BASENAMES_REPORTERS_TESTS "${SOURCES_REPORTERS_TESTS}" ) +string( REPLACE ".cpp" "" BASENAMES_REPORTERS_MAIN "${SOURCES_REPORTERS_MAIN}" ) + +set( TARGETS_SINGLE_FILE ${BASENAMES_SINGLE_FILE} ) +set( TARGETS_IDIOMATIC_TESTS ${BASENAMES_IDIOMATIC_TESTS} ) +set( TARGETS_REPORTERS_TESTS ${BASENAMES_REPORTERS_TESTS} ) +set( TARGETS_REPORTERS_MAIN ${BASENAMES_REPORTERS_MAIN} ) + +set( TARGETS_ALL + ${TARGETS_SINGLE_FILE} + 020-TestCase + ${TARGETS_IDIOMATIC_TESTS} CatchMain + ${TARGETS_REPORTERS_TESTS} CatchMainTeamCity +) + +# define program targets: + +add_library( CatchMain OBJECT ${EXAMPLES_DIR}/${SOURCES_IDIOMATIC_MAIN} ${HEADER_DIR}/catch2/catch.hpp ) +#add_library( CatchMainAutomake OBJECT ${EXAMPLES_DIR}/200-Rpt-CatchMain.cpp ${HEADER_DIR}/catch2/catch.hpp ) +#add_library( CatchMainTap OBJECT ${EXAMPLES_DIR}/200-Rpt-CatchMain.cpp ${HEADER_DIR}/catch2/catch.hpp ) +add_library( CatchMainTeamCity OBJECT ${EXAMPLES_DIR}/200-Rpt-CatchMain.cpp ${HEADER_DIR}/catch2/catch.hpp ) + +#target_compile_definitions( CatchMainAutomake PRIVATE CATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_automake.hpp\" ) +#target_compile_definitions( CatchMainTap PRIVATE CATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_tap.hpp\" ) +target_compile_definitions( CatchMainTeamCity PRIVATE CATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_teamcity.hpp\" ) + +foreach( name ${TARGETS_SINGLE_FILE} ) + add_executable( ${name} ${EXAMPLES_DIR}/${name}.cpp ${HEADER_DIR}/catch2/catch.hpp ) +endforeach() + +foreach( name ${TARGETS_IDIOMATIC_TESTS} ) + add_executable( ${name} ${EXAMPLES_DIR}/${name}.cpp $ ${HEADER_DIR}/catch2/catch.hpp ) +endforeach() + +add_executable( 020-TestCase ${EXAMPLES_DIR}/020-TestCase-1.cpp ${EXAMPLES_DIR}/020-TestCase-2.cpp ${HEADER_DIR}/catch2/catch.hpp ) + +#add_executable( 207-Rpt-AutomakeReporter ${EXAMPLES_DIR}/207-Rpt-AutomakeReporter.cpp $ ${HEADER_DIR}/catch2/catch.hpp ) +#add_executable( 207-Rpt-TapReporter ${EXAMPLES_DIR}/207-Rpt-TapReporter.cpp $ ${HEADER_DIR}/catch2/catch.hpp ) +add_executable( 207-Rpt-TeamCityReporter ${EXAMPLES_DIR}/207-Rpt-TeamCityReporter.cpp $ ${HEADER_DIR}/catch2/catch.hpp ) + +#foreach( name ${TARGETS_REPORTERS_TESTS} ) +# add_executable( ${name} ${EXAMPLES_DIR}/${name}.cpp $ ${HEADER_DIR}/catch2/catch.hpp ) +#endforeach() + +foreach( name ${TARGETS_ALL} ) + target_include_directories( ${name} PRIVATE ${HEADER_DIR} ${CATCH_DIR} ) + + set_property(TARGET ${name} PROPERTY CXX_STANDARD 11) + set_property(TARGET ${name} PROPERTY CXX_EXTENSIONS OFF) + + # Add desired warnings + if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" ) + target_compile_options( ${name} PRIVATE -Wall -Wextra -Wunreachable-code ) + endif() + # Clang specific warning go here + if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) + # Actually keep these + target_compile_options( ${name} PRIVATE -Wweak-vtables -Wexit-time-destructors -Wglobal-constructors -Wmissing-noreturn ) + endif() + if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" ) + target_compile_options( ${name} PRIVATE /W4 /w44265 /WX ) + endif() +endforeach() + diff --git a/lib/Catch2/include/catch.hpp b/lib/Catch2/include/catch.hpp new file mode 100644 index 0000000000..d178c7780a --- /dev/null +++ b/lib/Catch2/include/catch.hpp @@ -0,0 +1,496 @@ +/* + * Created by Phil on 22/10/2010. + * Copyright 2010 Two Blue Cubes Ltd + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#ifndef TWOBLUECUBES_CATCH_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_HPP_INCLUDED + +#define CATCH_VERSION_MAJOR 2 +#define CATCH_VERSION_MINOR 13 +#define CATCH_VERSION_PATCH 6 + +#ifdef __clang__ +# pragma clang system_header +#elif defined __GNUC__ +# pragma GCC system_header +#endif + +#include "internal/catch_suppress_warnings.h" + +#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) +# define CATCH_IMPL +# define CATCH_CONFIG_ALL_PARTS +#endif + +// In the impl file, we want to have access to all parts of the headers +// Can also be used to sanely support PCHs +#if defined(CATCH_CONFIG_ALL_PARTS) +# define CATCH_CONFIG_EXTERNAL_INTERFACES +# if defined(CATCH_CONFIG_DISABLE_MATCHERS) +# undef CATCH_CONFIG_DISABLE_MATCHERS +# endif +# if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) +# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER +# endif +#endif + +#if !defined(CATCH_CONFIG_IMPL_ONLY) +#include "internal/catch_platform.h" + +#ifdef CATCH_IMPL +# ifndef CLARA_CONFIG_MAIN +# define CLARA_CONFIG_MAIN_NOT_DEFINED +# define CLARA_CONFIG_MAIN +# endif +#endif + +#include "internal/catch_user_interfaces.h" +#include "internal/catch_tag_alias_autoregistrar.h" +#include "internal/catch_test_registry.h" +#include "internal/catch_capture.hpp" +#include "internal/catch_section.h" +#include "internal/catch_interfaces_exception.h" +#include "internal/catch_approx.h" +#include "internal/catch_compiler_capabilities.h" +#include "internal/catch_string_manip.h" + +#ifndef CATCH_CONFIG_DISABLE_MATCHERS +#include "internal/catch_capture_matchers.h" +#endif +#include "internal/catch_generators.hpp" +#include "internal/catch_generators_generic.hpp" +#include "internal/catch_generators_specific.hpp" + +// These files are included here so the single_include script doesn't put them +// in the conditionally compiled sections +#include "internal/catch_test_case_info.h" +#include "internal/catch_interfaces_runner.h" + +#ifdef __OBJC__ +#include "internal/catch_objc.hpp" +#endif + +// Benchmarking needs the externally-facing parts of reporters to work +#if defined(CATCH_CONFIG_EXTERNAL_INTERFACES) || defined(CATCH_CONFIG_ENABLE_BENCHMARKING) +#include "internal/catch_external_interfaces.h" +#endif + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) +#include "internal/benchmark/catch_benchmarking_all.hpp" +#endif + +#endif // ! CATCH_CONFIG_IMPL_ONLY + +#ifdef CATCH_IMPL +#include "internal/catch_impl.hpp" +#endif + +#ifdef CATCH_CONFIG_MAIN +#include "internal/catch_default_main.hpp" +#endif + + +#if !defined(CATCH_CONFIG_IMPL_ONLY) + +#ifdef CLARA_CONFIG_MAIN_NOT_DEFINED +# undef CLARA_CONFIG_MAIN +#endif + +#if !defined(CATCH_CONFIG_DISABLE) +////// +// If this config identifier is defined then all CATCH macros are prefixed with CATCH_ +#ifdef CATCH_CONFIG_PREFIX_ALL + +#define CATCH_REQUIRE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define CATCH_REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) + +#define CATCH_REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) +#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr ) +#endif// CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ ) + +#define CATCH_CHECK( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) +#define CATCH_CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CATCH_CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ ) + +#define CATCH_CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) +#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) + +#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg ) +#define CATCH_UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "CATCH_UNSCOPED_INFO", msg ) +#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( "CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) +#define CATCH_CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CATCH_CAPTURE",__VA_ARGS__ ) + +#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) +#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) +#define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) +#define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) +#define CATCH_DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ ) +#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) + +#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE() + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ ) +#define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) +#else +#define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) ) +#endif + + +#if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE) +#define CATCH_STATIC_REQUIRE( ... ) static_assert( __VA_ARGS__ , #__VA_ARGS__ ); CATCH_SUCCEED( #__VA_ARGS__ ) +#define CATCH_STATIC_REQUIRE_FALSE( ... ) static_assert( !(__VA_ARGS__), "!(" #__VA_ARGS__ ")" ); CATCH_SUCCEED( #__VA_ARGS__ ) +#else +#define CATCH_STATIC_REQUIRE( ... ) CATCH_REQUIRE( __VA_ARGS__ ) +#define CATCH_STATIC_REQUIRE_FALSE( ... ) CATCH_REQUIRE_FALSE( __VA_ARGS__ ) +#endif + + +// "BDD-style" convenience wrappers +#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ ) +#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) +#define CATCH_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Given: " << desc ) +#define CATCH_AND_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( "And given: " << desc ) +#define CATCH_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " When: " << desc ) +#define CATCH_AND_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And when: " << desc ) +#define CATCH_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Then: " << desc ) +#define CATCH_AND_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And: " << desc ) + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) +#define CATCH_BENCHMARK(...) \ + INTERNAL_CATCH_BENCHMARK(INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____B_E_N_C_H____), INTERNAL_CATCH_GET_1_ARG(__VA_ARGS__,,), INTERNAL_CATCH_GET_2_ARG(__VA_ARGS__,,)) +#define CATCH_BENCHMARK_ADVANCED(name) \ + INTERNAL_CATCH_BENCHMARK_ADVANCED(INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____B_E_N_C_H____), name) +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + +// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required +#else + +#define REQUIRE( ... ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) + +#define REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) +#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ ) + +#define CHECK( ... ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) +#define CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ ) + +#define CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) +#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) + + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) + +#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg ) +#define UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "UNSCOPED_INFO", msg ) +#define WARN( msg ) INTERNAL_CATCH_MSG( "WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) +#define CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), "CAPTURE",__VA_ARGS__ ) + +#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) +#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) +#define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) +#define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) +#define DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ ) +#define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE() + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ ) +#define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) +#define TEMPLATE_LIST_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(__VA_ARGS__) +#define TEMPLATE_LIST_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#else +#define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) ) +#define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG( __VA_ARGS__ ) ) +#define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) ) +#define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) ) +#define TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) ) +#define TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( __VA_ARGS__ ) ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, __VA_ARGS__ ) ) +#define TEMPLATE_LIST_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE( __VA_ARGS__ ) ) +#define TEMPLATE_LIST_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD( className, __VA_ARGS__ ) ) +#endif + + +#if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE) +#define STATIC_REQUIRE( ... ) static_assert( __VA_ARGS__, #__VA_ARGS__ ); SUCCEED( #__VA_ARGS__ ) +#define STATIC_REQUIRE_FALSE( ... ) static_assert( !(__VA_ARGS__), "!(" #__VA_ARGS__ ")" ); SUCCEED( "!(" #__VA_ARGS__ ")" ) +#else +#define STATIC_REQUIRE( ... ) REQUIRE( __VA_ARGS__ ) +#define STATIC_REQUIRE_FALSE( ... ) REQUIRE_FALSE( __VA_ARGS__ ) +#endif + +#endif + +#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) + +// "BDD-style" convenience wrappers +#define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ ) +#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) + +#define GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Given: " << desc ) +#define AND_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( "And given: " << desc ) +#define WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " When: " << desc ) +#define AND_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And when: " << desc ) +#define THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Then: " << desc ) +#define AND_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And: " << desc ) + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) +#define BENCHMARK(...) \ + INTERNAL_CATCH_BENCHMARK(INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____B_E_N_C_H____), INTERNAL_CATCH_GET_1_ARG(__VA_ARGS__,,), INTERNAL_CATCH_GET_2_ARG(__VA_ARGS__,,)) +#define BENCHMARK_ADVANCED(name) \ + INTERNAL_CATCH_BENCHMARK_ADVANCED(INTERNAL_CATCH_UNIQUE_NAME(____C_A_T_C_H____B_E_N_C_H____), name) +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + +using Catch::Detail::Approx; + +#else // CATCH_CONFIG_DISABLE + +////// +// If this config identifier is defined then all CATCH macros are prefixed with CATCH_ +#ifdef CATCH_CONFIG_PREFIX_ALL + +#define CATCH_REQUIRE( ... ) (void)(0) +#define CATCH_REQUIRE_FALSE( ... ) (void)(0) + +#define CATCH_REQUIRE_THROWS( ... ) (void)(0) +#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0) +#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif// CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_REQUIRE_NOTHROW( ... ) (void)(0) + +#define CATCH_CHECK( ... ) (void)(0) +#define CATCH_CHECK_FALSE( ... ) (void)(0) +#define CATCH_CHECKED_IF( ... ) if (__VA_ARGS__) +#define CATCH_CHECKED_ELSE( ... ) if (!(__VA_ARGS__)) +#define CATCH_CHECK_NOFAIL( ... ) (void)(0) + +#define CATCH_CHECK_THROWS( ... ) (void)(0) +#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) (void)(0) +#define CATCH_CHECK_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_CHECK_NOTHROW( ... ) (void)(0) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THAT( arg, matcher ) (void)(0) + +#define CATCH_REQUIRE_THAT( arg, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define CATCH_INFO( msg ) (void)(0) +#define CATCH_UNSCOPED_INFO( msg ) (void)(0) +#define CATCH_WARN( msg ) (void)(0) +#define CATCH_CAPTURE( msg ) (void)(0) + +#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define CATCH_METHOD_AS_TEST_CASE( method, ... ) +#define CATCH_REGISTER_TEST_CASE( Function, ... ) (void)(0) +#define CATCH_SECTION( ... ) +#define CATCH_DYNAMIC_SECTION( ... ) +#define CATCH_FAIL( ... ) (void)(0) +#define CATCH_FAIL_CHECK( ... ) (void)(0) +#define CATCH_SUCCEED( ... ) (void)(0) + +#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) +#define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__) +#define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__) +#define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#else +#define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) ) +#define CATCH_TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__) ) +#define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#endif + +// "BDD-style" convenience wrappers +#define CATCH_SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), className ) +#define CATCH_GIVEN( desc ) +#define CATCH_AND_GIVEN( desc ) +#define CATCH_WHEN( desc ) +#define CATCH_AND_WHEN( desc ) +#define CATCH_THEN( desc ) +#define CATCH_AND_THEN( desc ) + +#define CATCH_STATIC_REQUIRE( ... ) (void)(0) +#define CATCH_STATIC_REQUIRE_FALSE( ... ) (void)(0) + +// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required +#else + +#define REQUIRE( ... ) (void)(0) +#define REQUIRE_FALSE( ... ) (void)(0) + +#define REQUIRE_THROWS( ... ) (void)(0) +#define REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0) +#define REQUIRE_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define REQUIRE_NOTHROW( ... ) (void)(0) + +#define CHECK( ... ) (void)(0) +#define CHECK_FALSE( ... ) (void)(0) +#define CHECKED_IF( ... ) if (__VA_ARGS__) +#define CHECKED_ELSE( ... ) if (!(__VA_ARGS__)) +#define CHECK_NOFAIL( ... ) (void)(0) + +#define CHECK_THROWS( ... ) (void)(0) +#define CHECK_THROWS_AS( expr, exceptionType ) (void)(0) +#define CHECK_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CHECK_NOTHROW( ... ) (void)(0) + + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THAT( arg, matcher ) (void)(0) + +#define REQUIRE_THAT( arg, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define INFO( msg ) (void)(0) +#define UNSCOPED_INFO( msg ) (void)(0) +#define WARN( msg ) (void)(0) +#define CAPTURE( msg ) (void)(0) + +#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define METHOD_AS_TEST_CASE( method, ... ) +#define REGISTER_TEST_CASE( Function, ... ) (void)(0) +#define SECTION( ... ) +#define DYNAMIC_SECTION( ... ) +#define FAIL( ... ) (void)(0) +#define FAIL_CHECK( ... ) (void)(0) +#define SUCCEED( ... ) (void)(0) +#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) +#define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__) +#define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__) +#define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#else +#define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(__VA_ARGS__) ) +#define TEMPLATE_TEST_CASE_SIG( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(__VA_ARGS__) ) +#define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(className, __VA_ARGS__ ) ) +#define TEMPLATE_TEST_CASE_METHOD_SIG( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION(className, __VA_ARGS__ ) ) +#define TEMPLATE_PRODUCT_TEST_CASE( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_SIG( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#endif + +#define STATIC_REQUIRE( ... ) (void)(0) +#define STATIC_REQUIRE_FALSE( ... ) (void)(0) + +#endif + +#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) + +// "BDD-style" convenience wrappers +#define SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) ) +#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), className ) + +#define GIVEN( desc ) +#define AND_GIVEN( desc ) +#define WHEN( desc ) +#define AND_WHEN( desc ) +#define THEN( desc ) +#define AND_THEN( desc ) + +using Catch::Detail::Approx; + + +#endif + +#endif // ! CATCH_CONFIG_IMPL_ONLY + +#include "internal/catch_reenable_warnings.h" + +#endif // TWOBLUECUBES_CATCH_HPP_INCLUDED diff --git a/lib/Catch2/include/catch_with_main.hpp b/lib/Catch2/include/catch_with_main.hpp new file mode 100644 index 0000000000..54aa651f66 --- /dev/null +++ b/lib/Catch2/include/catch_with_main.hpp @@ -0,0 +1,14 @@ + /* + * Created by Phil on 01/11/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_WITH_MAIN_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_WITH_MAIN_HPP_INCLUDED + +#define CATCH_CONFIG_MAIN +#include "catch.hpp" + +#endif // TWOBLUECUBES_CATCH_WITH_MAIN_HPP_INCLUDED diff --git a/lib/Catch2/include/external/clara.hpp b/lib/Catch2/include/external/clara.hpp new file mode 100644 index 0000000000..a0836487d2 --- /dev/null +++ b/lib/Catch2/include/external/clara.hpp @@ -0,0 +1,1268 @@ +// Copyright 2017 Two Blue Cubes Ltd. All rights reserved. +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See https://github.com/philsquared/Clara for more details + +// Clara v1.1.5 + +#ifndef CATCH_CLARA_HPP_INCLUDED +#define CATCH_CLARA_HPP_INCLUDED + +#ifndef CATCH_CLARA_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_CONFIG_CONSOLE_WIDTH 80 +#endif + +#ifndef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_CLARA_CONFIG_CONSOLE_WIDTH +#endif + +#ifndef CLARA_CONFIG_OPTIONAL_TYPE +#ifdef __has_include +#if __has_include() && __cplusplus >= 201703L +#include +#define CLARA_CONFIG_OPTIONAL_TYPE std::optional +#endif +#endif +#endif + + +// ----------- #included from clara_textflow.hpp ----------- + +// TextFlowCpp +// +// A single-header library for wrapping and laying out basic text, by Phil Nash +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This project is hosted at https://github.com/philsquared/textflowcpp + +#ifndef CATCH_CLARA_TEXTFLOW_HPP_INCLUDED +#define CATCH_CLARA_TEXTFLOW_HPP_INCLUDED + +#include +#include +#include +#include + +#ifndef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH 80 +#endif + + +namespace Catch { +namespace clara { +namespace TextFlow { + +inline auto isWhitespace(char c) -> bool { + static std::string chars = " \t\n\r"; + return chars.find(c) != std::string::npos; +} +inline auto isBreakableBefore(char c) -> bool { + static std::string chars = "[({<|"; + return chars.find(c) != std::string::npos; +} +inline auto isBreakableAfter(char c) -> bool { + static std::string chars = "])}>.,:;*+-=&/\\"; + return chars.find(c) != std::string::npos; +} + +class Columns; + +class Column { + std::vector m_strings; + size_t m_width = CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH; + size_t m_indent = 0; + size_t m_initialIndent = std::string::npos; + +public: + class iterator { + friend Column; + + Column const& m_column; + size_t m_stringIndex = 0; + size_t m_pos = 0; + + size_t m_len = 0; + size_t m_end = 0; + bool m_suffix = false; + + iterator(Column const& column, size_t stringIndex) + : m_column(column), + m_stringIndex(stringIndex) {} + + auto line() const -> std::string const& { return m_column.m_strings[m_stringIndex]; } + + auto isBoundary(size_t at) const -> bool { + assert(at > 0); + assert(at <= line().size()); + + return at == line().size() || + (isWhitespace(line()[at]) && !isWhitespace(line()[at - 1])) || + isBreakableBefore(line()[at]) || + isBreakableAfter(line()[at - 1]); + } + + void calcLength() { + assert(m_stringIndex < m_column.m_strings.size()); + + m_suffix = false; + auto width = m_column.m_width - indent(); + m_end = m_pos; + if (line()[m_pos] == '\n') { + ++m_end; + } + while (m_end < line().size() && line()[m_end] != '\n') + ++m_end; + + if (m_end < m_pos + width) { + m_len = m_end - m_pos; + } else { + size_t len = width; + while (len > 0 && !isBoundary(m_pos + len)) + --len; + while (len > 0 && isWhitespace(line()[m_pos + len - 1])) + --len; + + if (len > 0) { + m_len = len; + } else { + m_suffix = true; + m_len = width - 1; + } + } + } + + auto indent() const -> size_t { + auto initial = m_pos == 0 && m_stringIndex == 0 ? m_column.m_initialIndent : std::string::npos; + return initial == std::string::npos ? m_column.m_indent : initial; + } + + auto addIndentAndSuffix(std::string const &plain) const -> std::string { + return std::string(indent(), ' ') + (m_suffix ? plain + "-" : plain); + } + + public: + using difference_type = std::ptrdiff_t; + using value_type = std::string; + using pointer = value_type * ; + using reference = value_type & ; + using iterator_category = std::forward_iterator_tag; + + explicit iterator(Column const& column) : m_column(column) { + assert(m_column.m_width > m_column.m_indent); + assert(m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent); + calcLength(); + if (m_len == 0) + m_stringIndex++; // Empty string + } + + auto operator *() const -> std::string { + assert(m_stringIndex < m_column.m_strings.size()); + assert(m_pos <= m_end); + return addIndentAndSuffix(line().substr(m_pos, m_len)); + } + + auto operator ++() -> iterator& { + m_pos += m_len; + if (m_pos < line().size() && line()[m_pos] == '\n') + m_pos += 1; + else + while (m_pos < line().size() && isWhitespace(line()[m_pos])) + ++m_pos; + + if (m_pos == line().size()) { + m_pos = 0; + ++m_stringIndex; + } + if (m_stringIndex < m_column.m_strings.size()) + calcLength(); + return *this; + } + auto operator ++(int) -> iterator { + iterator prev(*this); + operator++(); + return prev; + } + + auto operator ==(iterator const& other) const -> bool { + return + m_pos == other.m_pos && + m_stringIndex == other.m_stringIndex && + &m_column == &other.m_column; + } + auto operator !=(iterator const& other) const -> bool { + return !operator==(other); + } + }; + using const_iterator = iterator; + + explicit Column(std::string const& text) { m_strings.push_back(text); } + + auto width(size_t newWidth) -> Column& { + assert(newWidth > 0); + m_width = newWidth; + return *this; + } + auto indent(size_t newIndent) -> Column& { + m_indent = newIndent; + return *this; + } + auto initialIndent(size_t newIndent) -> Column& { + m_initialIndent = newIndent; + return *this; + } + + auto width() const -> size_t { return m_width; } + auto begin() const -> iterator { return iterator(*this); } + auto end() const -> iterator { return { *this, m_strings.size() }; } + + inline friend std::ostream& operator << (std::ostream& os, Column const& col) { + bool first = true; + for (auto line : col) { + if (first) + first = false; + else + os << "\n"; + os << line; + } + return os; + } + + auto operator + (Column const& other)->Columns; + + auto toString() const -> std::string { + std::ostringstream oss; + oss << *this; + return oss.str(); + } +}; + +class Spacer : public Column { + +public: + explicit Spacer(size_t spaceWidth) : Column("") { + width(spaceWidth); + } +}; + +class Columns { + std::vector m_columns; + +public: + + class iterator { + friend Columns; + struct EndTag {}; + + std::vector const& m_columns; + std::vector m_iterators; + size_t m_activeIterators; + + iterator(Columns const& columns, EndTag) + : m_columns(columns.m_columns), + m_activeIterators(0) { + m_iterators.reserve(m_columns.size()); + + for (auto const& col : m_columns) + m_iterators.push_back(col.end()); + } + + public: + using difference_type = std::ptrdiff_t; + using value_type = std::string; + using pointer = value_type * ; + using reference = value_type & ; + using iterator_category = std::forward_iterator_tag; + + explicit iterator(Columns const& columns) + : m_columns(columns.m_columns), + m_activeIterators(m_columns.size()) { + m_iterators.reserve(m_columns.size()); + + for (auto const& col : m_columns) + m_iterators.push_back(col.begin()); + } + + auto operator ==(iterator const& other) const -> bool { + return m_iterators == other.m_iterators; + } + auto operator !=(iterator const& other) const -> bool { + return m_iterators != other.m_iterators; + } + auto operator *() const -> std::string { + std::string row, padding; + + for (size_t i = 0; i < m_columns.size(); ++i) { + auto width = m_columns[i].width(); + if (m_iterators[i] != m_columns[i].end()) { + std::string col = *m_iterators[i]; + row += padding + col; + if (col.size() < width) + padding = std::string(width - col.size(), ' '); + else + padding = ""; + } else { + padding += std::string(width, ' '); + } + } + return row; + } + auto operator ++() -> iterator& { + for (size_t i = 0; i < m_columns.size(); ++i) { + if (m_iterators[i] != m_columns[i].end()) + ++m_iterators[i]; + } + return *this; + } + auto operator ++(int) -> iterator { + iterator prev(*this); + operator++(); + return prev; + } + }; + using const_iterator = iterator; + + auto begin() const -> iterator { return iterator(*this); } + auto end() const -> iterator { return { *this, iterator::EndTag() }; } + + auto operator += (Column const& col) -> Columns& { + m_columns.push_back(col); + return *this; + } + auto operator + (Column const& col) -> Columns { + Columns combined = *this; + combined += col; + return combined; + } + + inline friend std::ostream& operator << (std::ostream& os, Columns const& cols) { + + bool first = true; + for (auto line : cols) { + if (first) + first = false; + else + os << "\n"; + os << line; + } + return os; + } + + auto toString() const -> std::string { + std::ostringstream oss; + oss << *this; + return oss.str(); + } +}; + +inline auto Column::operator + (Column const& other) -> Columns { + Columns cols; + cols += *this; + cols += other; + return cols; +} +} + +} +} +#endif // CATCH_CLARA_TEXTFLOW_HPP_INCLUDED + +// ----------- end of #include from clara_textflow.hpp ----------- +// ........... back in clara.hpp + +#include +#include +#include +#include +#include + +#if !defined(CATCH_PLATFORM_WINDOWS) && ( defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) ) +#define CATCH_PLATFORM_WINDOWS +#endif + +namespace Catch { namespace clara { +namespace detail { + + // Traits for extracting arg and return type of lambdas (for single argument lambdas) + template + struct UnaryLambdaTraits : UnaryLambdaTraits {}; + + template + struct UnaryLambdaTraits { + static const bool isValid = false; + }; + + template + struct UnaryLambdaTraits { + static const bool isValid = true; + using ArgType = typename std::remove_const::type>::type; + using ReturnType = ReturnT; + }; + + class TokenStream; + + // Transport for raw args (copied from main args, or supplied via init list for testing) + class Args { + friend TokenStream; + std::string m_exeName; + std::vector m_args; + + public: + Args( int argc, char const* const* argv ) + : m_exeName(argv[0]), + m_args(argv + 1, argv + argc) {} + + Args( std::initializer_list args ) + : m_exeName( *args.begin() ), + m_args( args.begin()+1, args.end() ) + {} + + auto exeName() const -> std::string { + return m_exeName; + } + }; + + // Wraps a token coming from a token stream. These may not directly correspond to strings as a single string + // may encode an option + its argument if the : or = form is used + enum class TokenType { + Option, Argument + }; + struct Token { + TokenType type; + std::string token; + }; + + inline auto isOptPrefix( char c ) -> bool { + return c == '-' +#ifdef CATCH_PLATFORM_WINDOWS + || c == '/' +#endif + ; + } + + // Abstracts iterators into args as a stream of tokens, with option arguments uniformly handled + class TokenStream { + using Iterator = std::vector::const_iterator; + Iterator it; + Iterator itEnd; + std::vector m_tokenBuffer; + + void loadBuffer() { + m_tokenBuffer.resize( 0 ); + + // Skip any empty strings + while( it != itEnd && it->empty() ) + ++it; + + if( it != itEnd ) { + auto const &next = *it; + if( isOptPrefix( next[0] ) ) { + auto delimiterPos = next.find_first_of( " :=" ); + if( delimiterPos != std::string::npos ) { + m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } ); + m_tokenBuffer.push_back( { TokenType::Argument, next.substr( delimiterPos + 1 ) } ); + } else { + if( next[1] != '-' && next.size() > 2 ) { + std::string opt = "- "; + for( size_t i = 1; i < next.size(); ++i ) { + opt[1] = next[i]; + m_tokenBuffer.push_back( { TokenType::Option, opt } ); + } + } else { + m_tokenBuffer.push_back( { TokenType::Option, next } ); + } + } + } else { + m_tokenBuffer.push_back( { TokenType::Argument, next } ); + } + } + } + + public: + explicit TokenStream( Args const &args ) : TokenStream( args.m_args.begin(), args.m_args.end() ) {} + + TokenStream( Iterator it, Iterator itEnd ) : it( it ), itEnd( itEnd ) { + loadBuffer(); + } + + explicit operator bool() const { + return !m_tokenBuffer.empty() || it != itEnd; + } + + auto count() const -> size_t { return m_tokenBuffer.size() + (itEnd - it); } + + auto operator*() const -> Token { + assert( !m_tokenBuffer.empty() ); + return m_tokenBuffer.front(); + } + + auto operator->() const -> Token const * { + assert( !m_tokenBuffer.empty() ); + return &m_tokenBuffer.front(); + } + + auto operator++() -> TokenStream & { + if( m_tokenBuffer.size() >= 2 ) { + m_tokenBuffer.erase( m_tokenBuffer.begin() ); + } else { + if( it != itEnd ) + ++it; + loadBuffer(); + } + return *this; + } + }; + + + class ResultBase { + public: + enum Type { + Ok, LogicError, RuntimeError + }; + + protected: + ResultBase( Type type ) : m_type( type ) {} + virtual ~ResultBase() = default; + + virtual void enforceOk() const = 0; + + Type m_type; + }; + + template + class ResultValueBase : public ResultBase { + public: + auto value() const -> T const & { + enforceOk(); + return m_value; + } + + protected: + ResultValueBase( Type type ) : ResultBase( type ) {} + + ResultValueBase( ResultValueBase const &other ) : ResultBase( other ) { + if( m_type == ResultBase::Ok ) + new( &m_value ) T( other.m_value ); + } + + ResultValueBase( Type, T const &value ) : ResultBase( Ok ) { + new( &m_value ) T( value ); + } + + auto operator=( ResultValueBase const &other ) -> ResultValueBase & { + if( m_type == ResultBase::Ok ) + m_value.~T(); + ResultBase::operator=(other); + if( m_type == ResultBase::Ok ) + new( &m_value ) T( other.m_value ); + return *this; + } + + ~ResultValueBase() override { + if( m_type == Ok ) + m_value.~T(); + } + + union { + T m_value; + }; + }; + + template<> + class ResultValueBase : public ResultBase { + protected: + using ResultBase::ResultBase; + }; + + template + class BasicResult : public ResultValueBase { + public: + template + explicit BasicResult( BasicResult const &other ) + : ResultValueBase( other.type() ), + m_errorMessage( other.errorMessage() ) + { + assert( type() != ResultBase::Ok ); + } + + template + static auto ok( U const &value ) -> BasicResult { return { ResultBase::Ok, value }; } + static auto ok() -> BasicResult { return { ResultBase::Ok }; } + static auto logicError( std::string const &message ) -> BasicResult { return { ResultBase::LogicError, message }; } + static auto runtimeError( std::string const &message ) -> BasicResult { return { ResultBase::RuntimeError, message }; } + + explicit operator bool() const { return m_type == ResultBase::Ok; } + auto type() const -> ResultBase::Type { return m_type; } + auto errorMessage() const -> std::string { return m_errorMessage; } + + protected: + void enforceOk() const override { + + // Errors shouldn't reach this point, but if they do + // the actual error message will be in m_errorMessage + assert( m_type != ResultBase::LogicError ); + assert( m_type != ResultBase::RuntimeError ); + if( m_type != ResultBase::Ok ) + std::abort(); + } + + std::string m_errorMessage; // Only populated if resultType is an error + + BasicResult( ResultBase::Type type, std::string const &message ) + : ResultValueBase(type), + m_errorMessage(message) + { + assert( m_type != ResultBase::Ok ); + } + + using ResultValueBase::ResultValueBase; + using ResultBase::m_type; + }; + + enum class ParseResultType { + Matched, NoMatch, ShortCircuitAll, ShortCircuitSame + }; + + class ParseState { + public: + + ParseState( ParseResultType type, TokenStream const &remainingTokens ) + : m_type(type), + m_remainingTokens( remainingTokens ) + {} + + auto type() const -> ParseResultType { return m_type; } + auto remainingTokens() const -> TokenStream { return m_remainingTokens; } + + private: + ParseResultType m_type; + TokenStream m_remainingTokens; + }; + + using Result = BasicResult; + using ParserResult = BasicResult; + using InternalParseResult = BasicResult; + + struct HelpColumns { + std::string left; + std::string right; + }; + + template + inline auto convertInto( std::string const &source, T& target ) -> ParserResult { + std::stringstream ss; + ss << source; + ss >> target; + if( ss.fail() ) + return ParserResult::runtimeError( "Unable to convert '" + source + "' to destination type" ); + else + return ParserResult::ok( ParseResultType::Matched ); + } + inline auto convertInto( std::string const &source, std::string& target ) -> ParserResult { + target = source; + return ParserResult::ok( ParseResultType::Matched ); + } + inline auto convertInto( std::string const &source, bool &target ) -> ParserResult { + std::string srcLC = source; + std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( unsigned char c ) { return static_cast( std::tolower(c) ); } ); + if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on") + target = true; + else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off") + target = false; + else + return ParserResult::runtimeError( "Expected a boolean value but did not recognise: '" + source + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + } +#ifdef CLARA_CONFIG_OPTIONAL_TYPE + template + inline auto convertInto( std::string const &source, CLARA_CONFIG_OPTIONAL_TYPE& target ) -> ParserResult { + T temp; + auto result = convertInto( source, temp ); + if( result ) + target = std::move(temp); + return result; + } +#endif // CLARA_CONFIG_OPTIONAL_TYPE + + struct NonCopyable { + NonCopyable() = default; + NonCopyable( NonCopyable const & ) = delete; + NonCopyable( NonCopyable && ) = delete; + NonCopyable &operator=( NonCopyable const & ) = delete; + NonCopyable &operator=( NonCopyable && ) = delete; + }; + + struct BoundRef : NonCopyable { + virtual ~BoundRef() = default; + virtual auto isContainer() const -> bool { return false; } + virtual auto isFlag() const -> bool { return false; } + }; + struct BoundValueRefBase : BoundRef { + virtual auto setValue( std::string const &arg ) -> ParserResult = 0; + }; + struct BoundFlagRefBase : BoundRef { + virtual auto setFlag( bool flag ) -> ParserResult = 0; + virtual auto isFlag() const -> bool { return true; } + }; + + template + struct BoundValueRef : BoundValueRefBase { + T &m_ref; + + explicit BoundValueRef( T &ref ) : m_ref( ref ) {} + + auto setValue( std::string const &arg ) -> ParserResult override { + return convertInto( arg, m_ref ); + } + }; + + template + struct BoundValueRef> : BoundValueRefBase { + std::vector &m_ref; + + explicit BoundValueRef( std::vector &ref ) : m_ref( ref ) {} + + auto isContainer() const -> bool override { return true; } + + auto setValue( std::string const &arg ) -> ParserResult override { + T temp; + auto result = convertInto( arg, temp ); + if( result ) + m_ref.push_back( temp ); + return result; + } + }; + + struct BoundFlagRef : BoundFlagRefBase { + bool &m_ref; + + explicit BoundFlagRef( bool &ref ) : m_ref( ref ) {} + + auto setFlag( bool flag ) -> ParserResult override { + m_ref = flag; + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + template + struct LambdaInvoker { + static_assert( std::is_same::value, "Lambda must return void or clara::ParserResult" ); + + template + static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult { + return lambda( arg ); + } + }; + + template<> + struct LambdaInvoker { + template + static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult { + lambda( arg ); + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + template + inline auto invokeLambda( L const &lambda, std::string const &arg ) -> ParserResult { + ArgType temp{}; + auto result = convertInto( arg, temp ); + return !result + ? result + : LambdaInvoker::ReturnType>::invoke( lambda, temp ); + } + + + template + struct BoundLambda : BoundValueRefBase { + L m_lambda; + + static_assert( UnaryLambdaTraits::isValid, "Supplied lambda must take exactly one argument" ); + explicit BoundLambda( L const &lambda ) : m_lambda( lambda ) {} + + auto setValue( std::string const &arg ) -> ParserResult override { + return invokeLambda::ArgType>( m_lambda, arg ); + } + }; + + template + struct BoundFlagLambda : BoundFlagRefBase { + L m_lambda; + + static_assert( UnaryLambdaTraits::isValid, "Supplied lambda must take exactly one argument" ); + static_assert( std::is_same::ArgType, bool>::value, "flags must be boolean" ); + + explicit BoundFlagLambda( L const &lambda ) : m_lambda( lambda ) {} + + auto setFlag( bool flag ) -> ParserResult override { + return LambdaInvoker::ReturnType>::invoke( m_lambda, flag ); + } + }; + + enum class Optionality { Optional, Required }; + + struct Parser; + + class ParserBase { + public: + virtual ~ParserBase() = default; + virtual auto validate() const -> Result { return Result::ok(); } + virtual auto parse( std::string const& exeName, TokenStream const &tokens) const -> InternalParseResult = 0; + virtual auto cardinality() const -> size_t { return 1; } + + auto parse( Args const &args ) const -> InternalParseResult { + return parse( args.exeName(), TokenStream( args ) ); + } + }; + + template + class ComposableParserImpl : public ParserBase { + public: + template + auto operator|( T const &other ) const -> Parser; + + template + auto operator+( T const &other ) const -> Parser; + }; + + // Common code and state for Args and Opts + template + class ParserRefImpl : public ComposableParserImpl { + protected: + Optionality m_optionality = Optionality::Optional; + std::shared_ptr m_ref; + std::string m_hint; + std::string m_description; + + explicit ParserRefImpl( std::shared_ptr const &ref ) : m_ref( ref ) {} + + public: + template + ParserRefImpl( T &ref, std::string const &hint ) + : m_ref( std::make_shared>( ref ) ), + m_hint( hint ) + {} + + template + ParserRefImpl( LambdaT const &ref, std::string const &hint ) + : m_ref( std::make_shared>( ref ) ), + m_hint(hint) + {} + + auto operator()( std::string const &description ) -> DerivedT & { + m_description = description; + return static_cast( *this ); + } + + auto optional() -> DerivedT & { + m_optionality = Optionality::Optional; + return static_cast( *this ); + }; + + auto required() -> DerivedT & { + m_optionality = Optionality::Required; + return static_cast( *this ); + }; + + auto isOptional() const -> bool { + return m_optionality == Optionality::Optional; + } + + auto cardinality() const -> size_t override { + if( m_ref->isContainer() ) + return 0; + else + return 1; + } + + auto hint() const -> std::string { return m_hint; } + }; + + class ExeName : public ComposableParserImpl { + std::shared_ptr m_name; + std::shared_ptr m_ref; + + template + static auto makeRef(LambdaT const &lambda) -> std::shared_ptr { + return std::make_shared>( lambda) ; + } + + public: + ExeName() : m_name( std::make_shared( "" ) ) {} + + explicit ExeName( std::string &ref ) : ExeName() { + m_ref = std::make_shared>( ref ); + } + + template + explicit ExeName( LambdaT const& lambda ) : ExeName() { + m_ref = std::make_shared>( lambda ); + } + + // The exe name is not parsed out of the normal tokens, but is handled specially + auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override { + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) ); + } + + auto name() const -> std::string { return *m_name; } + auto set( std::string const& newName ) -> ParserResult { + + auto lastSlash = newName.find_last_of( "\\/" ); + auto filename = ( lastSlash == std::string::npos ) + ? newName + : newName.substr( lastSlash+1 ); + + *m_name = filename; + if( m_ref ) + return m_ref->setValue( filename ); + else + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + class Arg : public ParserRefImpl { + public: + using ParserRefImpl::ParserRefImpl; + + auto parse( std::string const &, TokenStream const &tokens ) const -> InternalParseResult override { + auto validationResult = validate(); + if( !validationResult ) + return InternalParseResult( validationResult ); + + auto remainingTokens = tokens; + auto const &token = *remainingTokens; + if( token.type != TokenType::Argument ) + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) ); + + assert( !m_ref->isFlag() ); + auto valueRef = static_cast( m_ref.get() ); + + auto result = valueRef->setValue( remainingTokens->token ); + if( !result ) + return InternalParseResult( result ); + else + return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) ); + } + }; + + inline auto normaliseOpt( std::string const &optName ) -> std::string { +#ifdef CATCH_PLATFORM_WINDOWS + if( optName[0] == '/' ) + return "-" + optName.substr( 1 ); + else +#endif + return optName; + } + + class Opt : public ParserRefImpl { + protected: + std::vector m_optNames; + + public: + template + explicit Opt( LambdaT const &ref ) : ParserRefImpl( std::make_shared>( ref ) ) {} + + explicit Opt( bool &ref ) : ParserRefImpl( std::make_shared( ref ) ) {} + + template + Opt( LambdaT const &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {} + + template + Opt( T &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {} + + auto operator[]( std::string const &optName ) -> Opt & { + m_optNames.push_back( optName ); + return *this; + } + + auto getHelpColumns() const -> std::vector { + std::ostringstream oss; + bool first = true; + for( auto const &opt : m_optNames ) { + if (first) + first = false; + else + oss << ", "; + oss << opt; + } + if( !m_hint.empty() ) + oss << " <" << m_hint << ">"; + return { { oss.str(), m_description } }; + } + + auto isMatch( std::string const &optToken ) const -> bool { + auto normalisedToken = normaliseOpt( optToken ); + for( auto const &name : m_optNames ) { + if( normaliseOpt( name ) == normalisedToken ) + return true; + } + return false; + } + + using ParserBase::parse; + + auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override { + auto validationResult = validate(); + if( !validationResult ) + return InternalParseResult( validationResult ); + + auto remainingTokens = tokens; + if( remainingTokens && remainingTokens->type == TokenType::Option ) { + auto const &token = *remainingTokens; + if( isMatch(token.token ) ) { + if( m_ref->isFlag() ) { + auto flagRef = static_cast( m_ref.get() ); + auto result = flagRef->setFlag( true ); + if( !result ) + return InternalParseResult( result ); + if( result.value() == ParseResultType::ShortCircuitAll ) + return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) ); + } else { + auto valueRef = static_cast( m_ref.get() ); + ++remainingTokens; + if( !remainingTokens ) + return InternalParseResult::runtimeError( "Expected argument following " + token.token ); + auto const &argToken = *remainingTokens; + if( argToken.type != TokenType::Argument ) + return InternalParseResult::runtimeError( "Expected argument following " + token.token ); + auto result = valueRef->setValue( argToken.token ); + if( !result ) + return InternalParseResult( result ); + if( result.value() == ParseResultType::ShortCircuitAll ) + return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) ); + } + return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) ); + } + } + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) ); + } + + auto validate() const -> Result override { + if( m_optNames.empty() ) + return Result::logicError( "No options supplied to Opt" ); + for( auto const &name : m_optNames ) { + if( name.empty() ) + return Result::logicError( "Option name cannot be empty" ); +#ifdef CATCH_PLATFORM_WINDOWS + if( name[0] != '-' && name[0] != '/' ) + return Result::logicError( "Option name must begin with '-' or '/'" ); +#else + if( name[0] != '-' ) + return Result::logicError( "Option name must begin with '-'" ); +#endif + } + return ParserRefImpl::validate(); + } + }; + + struct Help : Opt { + Help( bool &showHelpFlag ) + : Opt([&]( bool flag ) { + showHelpFlag = flag; + return ParserResult::ok( ParseResultType::ShortCircuitAll ); + }) + { + static_cast( *this ) + ("display usage information") + ["-?"]["-h"]["--help"] + .optional(); + } + }; + + + struct Parser : ParserBase { + + mutable ExeName m_exeName; + std::vector m_options; + std::vector m_args; + + auto operator|=( ExeName const &exeName ) -> Parser & { + m_exeName = exeName; + return *this; + } + + auto operator|=( Arg const &arg ) -> Parser & { + m_args.push_back(arg); + return *this; + } + + auto operator|=( Opt const &opt ) -> Parser & { + m_options.push_back(opt); + return *this; + } + + auto operator|=( Parser const &other ) -> Parser & { + m_options.insert(m_options.end(), other.m_options.begin(), other.m_options.end()); + m_args.insert(m_args.end(), other.m_args.begin(), other.m_args.end()); + return *this; + } + + template + auto operator|( T const &other ) const -> Parser { + return Parser( *this ) |= other; + } + + // Forward deprecated interface with '+' instead of '|' + template + auto operator+=( T const &other ) -> Parser & { return operator|=( other ); } + template + auto operator+( T const &other ) const -> Parser { return operator|( other ); } + + auto getHelpColumns() const -> std::vector { + std::vector cols; + for (auto const &o : m_options) { + auto childCols = o.getHelpColumns(); + cols.insert( cols.end(), childCols.begin(), childCols.end() ); + } + return cols; + } + + void writeToStream( std::ostream &os ) const { + if (!m_exeName.name().empty()) { + os << "usage:\n" << " " << m_exeName.name() << " "; + bool required = true, first = true; + for( auto const &arg : m_args ) { + if (first) + first = false; + else + os << " "; + if( arg.isOptional() && required ) { + os << "["; + required = false; + } + os << "<" << arg.hint() << ">"; + if( arg.cardinality() == 0 ) + os << " ... "; + } + if( !required ) + os << "]"; + if( !m_options.empty() ) + os << " options"; + os << "\n\nwhere options are:" << std::endl; + } + + auto rows = getHelpColumns(); + size_t consoleWidth = CATCH_CLARA_CONFIG_CONSOLE_WIDTH; + size_t optWidth = 0; + for( auto const &cols : rows ) + optWidth = (std::max)(optWidth, cols.left.size() + 2); + + optWidth = (std::min)(optWidth, consoleWidth/2); + + for( auto const &cols : rows ) { + auto row = + TextFlow::Column( cols.left ).width( optWidth ).indent( 2 ) + + TextFlow::Spacer(4) + + TextFlow::Column( cols.right ).width( consoleWidth - 7 - optWidth ); + os << row << std::endl; + } + } + + friend auto operator<<( std::ostream &os, Parser const &parser ) -> std::ostream& { + parser.writeToStream( os ); + return os; + } + + auto validate() const -> Result override { + for( auto const &opt : m_options ) { + auto result = opt.validate(); + if( !result ) + return result; + } + for( auto const &arg : m_args ) { + auto result = arg.validate(); + if( !result ) + return result; + } + return Result::ok(); + } + + using ParserBase::parse; + + auto parse( std::string const& exeName, TokenStream const &tokens ) const -> InternalParseResult override { + + struct ParserInfo { + ParserBase const* parser = nullptr; + size_t count = 0; + }; + const size_t totalParsers = m_options.size() + m_args.size(); + assert( totalParsers < 512 ); + // ParserInfo parseInfos[totalParsers]; // <-- this is what we really want to do + ParserInfo parseInfos[512]; + + { + size_t i = 0; + for (auto const &opt : m_options) parseInfos[i++].parser = &opt; + for (auto const &arg : m_args) parseInfos[i++].parser = &arg; + } + + m_exeName.set( exeName ); + + auto result = InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) ); + while( result.value().remainingTokens() ) { + bool tokenParsed = false; + + for( size_t i = 0; i < totalParsers; ++i ) { + auto& parseInfo = parseInfos[i]; + if( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) { + result = parseInfo.parser->parse(exeName, result.value().remainingTokens()); + if (!result) + return result; + if (result.value().type() != ParseResultType::NoMatch) { + tokenParsed = true; + ++parseInfo.count; + break; + } + } + } + + if( result.value().type() == ParseResultType::ShortCircuitAll ) + return result; + if( !tokenParsed ) + return InternalParseResult::runtimeError( "Unrecognised token: " + result.value().remainingTokens()->token ); + } + // !TBD Check missing required options + return result; + } + }; + + template + template + auto ComposableParserImpl::operator|( T const &other ) const -> Parser { + return Parser() | static_cast( *this ) | other; + } +} // namespace detail + + +// A Combined parser +using detail::Parser; + +// A parser for options +using detail::Opt; + +// A parser for arguments +using detail::Arg; + +// Wrapper for argc, argv from main() +using detail::Args; + +// Specifies the name of the executable +using detail::ExeName; + +// Convenience wrapper for option parser that specifies the help option +using detail::Help; + +// enum of result types from a parse +using detail::ParseResultType; + +// Result type for parser operation +using detail::ParserResult; + + +}} // namespace Catch::clara + + +#endif // CATCH_CLARA_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/catch_benchmark.hpp b/lib/Catch2/include/internal/benchmark/catch_benchmark.hpp new file mode 100644 index 0000000000..ec8dde0861 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/catch_benchmark.hpp @@ -0,0 +1,122 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + // Benchmark +#ifndef TWOBLUECUBES_CATCH_BENCHMARK_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_BENCHMARK_HPP_INCLUDED + +#include "../catch_config.hpp" +#include "../catch_context.h" +#include "../catch_interfaces_reporter.h" +#include "../catch_test_registry.h" + +#include "catch_chronometer.hpp" +#include "catch_clock.hpp" +#include "catch_environment.hpp" +#include "catch_execution_plan.hpp" +#include "detail/catch_estimate_clock.hpp" +#include "detail/catch_complete_invoke.hpp" +#include "detail/catch_analyse.hpp" +#include "detail/catch_benchmark_function.hpp" +#include "detail/catch_run_for_at_least.hpp" + +#include +#include +#include +#include +#include + +namespace Catch { + namespace Benchmark { + struct Benchmark { + Benchmark(std::string &&name) + : name(std::move(name)) {} + + template + Benchmark(std::string &&name, FUN &&func) + : fun(std::move(func)), name(std::move(name)) {} + + template + ExecutionPlan> prepare(const IConfig &cfg, Environment> env) const { + auto min_time = env.clock_resolution.mean * Detail::minimum_ticks; + auto run_time = std::max(min_time, std::chrono::duration_cast(cfg.benchmarkWarmupTime())); + auto&& test = Detail::run_for_at_least(std::chrono::duration_cast>(run_time), 1, fun); + int new_iters = static_cast(std::ceil(min_time * test.iterations / test.elapsed)); + return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), fun, std::chrono::duration_cast>(cfg.benchmarkWarmupTime()), Detail::warmup_iterations }; + } + + template + void run() { + IConfigPtr cfg = getCurrentContext().getConfig(); + + auto env = Detail::measure_environment(); + + getResultCapture().benchmarkPreparing(name); + CATCH_TRY{ + auto plan = user_code([&] { + return prepare(*cfg, env); + }); + + BenchmarkInfo info { + name, + plan.estimated_duration.count(), + plan.iterations_per_sample, + cfg->benchmarkSamples(), + cfg->benchmarkResamples(), + env.clock_resolution.mean.count(), + env.clock_cost.mean.count() + }; + + getResultCapture().benchmarkStarting(info); + + auto samples = user_code([&] { + return plan.template run(*cfg, env); + }); + + auto analysis = Detail::analyse(*cfg, env, samples.begin(), samples.end()); + BenchmarkStats> stats{ info, analysis.samples, analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance }; + getResultCapture().benchmarkEnded(stats); + + } CATCH_CATCH_ALL{ + if (translateActiveException() != Detail::benchmarkErrorMsg) // benchmark errors have been reported, otherwise rethrow. + std::rethrow_exception(std::current_exception()); + } + } + + // sets lambda to be used in fun *and* executes benchmark! + template ::value, int>::type = 0> + Benchmark & operator=(Fun func) { + fun = Detail::BenchmarkFunction(func); + run(); + return *this; + } + + explicit operator bool() { + return true; + } + + private: + Detail::BenchmarkFunction fun; + std::string name; + }; + } +} // namespace Catch + +#define INTERNAL_CATCH_GET_1_ARG(arg1, arg2, ...) arg1 +#define INTERNAL_CATCH_GET_2_ARG(arg1, arg2, ...) arg2 + +#define INTERNAL_CATCH_BENCHMARK(BenchmarkName, name, benchmarkIndex)\ + if( Catch::Benchmark::Benchmark BenchmarkName{name} ) \ + BenchmarkName = [&](int benchmarkIndex) + +#define INTERNAL_CATCH_BENCHMARK_ADVANCED(BenchmarkName, name)\ + if( Catch::Benchmark::Benchmark BenchmarkName{name} ) \ + BenchmarkName = [&] + +#endif // TWOBLUECUBES_CATCH_BENCHMARK_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/catch_benchmarking_all.hpp b/lib/Catch2/include/internal/benchmark/catch_benchmarking_all.hpp new file mode 100644 index 0000000000..7717f8993b --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/catch_benchmarking_all.hpp @@ -0,0 +1,29 @@ +/* + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + +// A proxy header that includes all of the benchmarking headers to allow +// concise include of the benchmarking features. You should prefer the +// individual includes in standard use. + +#include "catch_benchmark.hpp" +#include "catch_chronometer.hpp" +#include "catch_clock.hpp" +#include "catch_constructor.hpp" +#include "catch_environment.hpp" +#include "catch_estimate.hpp" +#include "catch_execution_plan.hpp" +#include "catch_optimizer.hpp" +#include "catch_outlier_classification.hpp" +#include "catch_sample_analysis.hpp" +#include "detail/catch_analyse.hpp" +#include "detail/catch_benchmark_function.hpp" +#include "detail/catch_complete_invoke.hpp" +#include "detail/catch_estimate_clock.hpp" +#include "detail/catch_measure.hpp" +#include "detail/catch_repeat.hpp" +#include "detail/catch_run_for_at_least.hpp" +#include "detail/catch_stats.hpp" +#include "detail/catch_timing.hpp" diff --git a/lib/Catch2/include/internal/benchmark/catch_chronometer.hpp b/lib/Catch2/include/internal/benchmark/catch_chronometer.hpp new file mode 100644 index 0000000000..1022017d08 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/catch_chronometer.hpp @@ -0,0 +1,71 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +// User-facing chronometer + +#ifndef TWOBLUECUBES_CATCH_CHRONOMETER_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_CHRONOMETER_HPP_INCLUDED + +#include "catch_clock.hpp" +#include "catch_optimizer.hpp" +#include "detail/catch_complete_invoke.hpp" +#include "../catch_meta.hpp" + +namespace Catch { + namespace Benchmark { + namespace Detail { + struct ChronometerConcept { + virtual void start() = 0; + virtual void finish() = 0; + virtual ~ChronometerConcept() = default; + }; + template + struct ChronometerModel final : public ChronometerConcept { + void start() override { started = Clock::now(); } + void finish() override { finished = Clock::now(); } + + ClockDuration elapsed() const { return finished - started; } + + TimePoint started; + TimePoint finished; + }; + } // namespace Detail + + struct Chronometer { + public: + template + void measure(Fun&& fun) { measure(std::forward(fun), is_callable()); } + + int runs() const { return k; } + + Chronometer(Detail::ChronometerConcept& meter, int k) + : impl(&meter) + , k(k) {} + + private: + template + void measure(Fun&& fun, std::false_type) { + measure([&fun](int) { return fun(); }, std::true_type()); + } + + template + void measure(Fun&& fun, std::true_type) { + Detail::optimizer_barrier(); + impl->start(); + for (int i = 0; i < k; ++i) invoke_deoptimized(fun, i); + impl->finish(); + Detail::optimizer_barrier(); + } + + Detail::ChronometerConcept* impl; + int k; + }; + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_CHRONOMETER_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/catch_clock.hpp b/lib/Catch2/include/internal/benchmark/catch_clock.hpp new file mode 100644 index 0000000000..32a3e868b9 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/catch_clock.hpp @@ -0,0 +1,40 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +// Clocks + +#ifndef TWOBLUECUBES_CATCH_CLOCK_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_CLOCK_HPP_INCLUDED + +#include +#include + +namespace Catch { + namespace Benchmark { + template + using ClockDuration = typename Clock::duration; + template + using FloatDuration = std::chrono::duration; + + template + using TimePoint = typename Clock::time_point; + + using default_clock = std::chrono::steady_clock; + + template + struct now { + TimePoint operator()() const { + return Clock::now(); + } + }; + + using fp_seconds = std::chrono::duration>; + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_CLOCK_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/catch_constructor.hpp b/lib/Catch2/include/internal/benchmark/catch_constructor.hpp new file mode 100644 index 0000000000..4fc0404239 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/catch_constructor.hpp @@ -0,0 +1,79 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +// Constructor and destructor helpers + +#ifndef TWOBLUECUBES_CATCH_CONSTRUCTOR_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_CONSTRUCTOR_HPP_INCLUDED + +#include + +namespace Catch { + namespace Benchmark { + namespace Detail { + template + struct ObjectStorage + { + using TStorage = typename std::aligned_storage::value>::type; + + ObjectStorage() : data() {} + + ObjectStorage(const ObjectStorage& other) + { + new(&data) T(other.stored_object()); + } + + ObjectStorage(ObjectStorage&& other) + { + new(&data) T(std::move(other.stored_object())); + } + + ~ObjectStorage() { destruct_on_exit(); } + + template + void construct(Args&&... args) + { + new (&data) T(std::forward(args)...); + } + + template + typename std::enable_if::type destruct() + { + stored_object().~T(); + } + + private: + // If this is a constructor benchmark, destruct the underlying object + template + void destruct_on_exit(typename std::enable_if::type* = 0) { destruct(); } + // Otherwise, don't + template + void destruct_on_exit(typename std::enable_if::type* = 0) { } + + T& stored_object() { + return *static_cast(static_cast(&data)); + } + + T const& stored_object() const { + return *static_cast(static_cast(&data)); + } + + + TStorage data; + }; + } + + template + using storage_for = Detail::ObjectStorage; + + template + using destructable_object = Detail::ObjectStorage; + } +} + +#endif // TWOBLUECUBES_CATCH_CONSTRUCTOR_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/catch_environment.hpp b/lib/Catch2/include/internal/benchmark/catch_environment.hpp new file mode 100644 index 0000000000..5595124987 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/catch_environment.hpp @@ -0,0 +1,38 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +// Environment information + +#ifndef TWOBLUECUBES_CATCH_ENVIRONMENT_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_ENVIRONMENT_HPP_INCLUDED + +#include "catch_clock.hpp" +#include "catch_outlier_classification.hpp" + +namespace Catch { + namespace Benchmark { + template + struct EnvironmentEstimate { + Duration mean; + OutlierClassification outliers; + + template + operator EnvironmentEstimate() const { + return { mean, outliers }; + } + }; + template + struct Environment { + using clock_type = Clock; + EnvironmentEstimate> clock_resolution; + EnvironmentEstimate> clock_cost; + }; + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_ENVIRONMENT_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/catch_estimate.hpp b/lib/Catch2/include/internal/benchmark/catch_estimate.hpp new file mode 100644 index 0000000000..a3c913ce69 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/catch_estimate.hpp @@ -0,0 +1,31 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + // Statistics estimates + +#ifndef TWOBLUECUBES_CATCH_ESTIMATE_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_ESTIMATE_HPP_INCLUDED + +namespace Catch { + namespace Benchmark { + template + struct Estimate { + Duration point; + Duration lower_bound; + Duration upper_bound; + double confidence_interval; + + template + operator Estimate() const { + return { point, lower_bound, upper_bound, confidence_interval }; + } + }; + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_ESTIMATE_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/catch_execution_plan.hpp b/lib/Catch2/include/internal/benchmark/catch_execution_plan.hpp new file mode 100644 index 0000000000..e56c83aa7c --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/catch_execution_plan.hpp @@ -0,0 +1,58 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + // Execution plan + +#ifndef TWOBLUECUBES_CATCH_EXECUTION_PLAN_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_EXECUTION_PLAN_HPP_INCLUDED + +#include "../catch_config.hpp" +#include "catch_clock.hpp" +#include "catch_environment.hpp" +#include "detail/catch_benchmark_function.hpp" +#include "detail/catch_repeat.hpp" +#include "detail/catch_run_for_at_least.hpp" + +#include + +namespace Catch { + namespace Benchmark { + template + struct ExecutionPlan { + int iterations_per_sample; + Duration estimated_duration; + Detail::BenchmarkFunction benchmark; + Duration warmup_time; + int warmup_iterations; + + template + operator ExecutionPlan() const { + return { iterations_per_sample, estimated_duration, benchmark, warmup_time, warmup_iterations }; + } + + template + std::vector> run(const IConfig &cfg, Environment> env) const { + // warmup a bit + Detail::run_for_at_least(std::chrono::duration_cast>(warmup_time), warmup_iterations, Detail::repeat(now{})); + + std::vector> times; + times.reserve(cfg.benchmarkSamples()); + std::generate_n(std::back_inserter(times), cfg.benchmarkSamples(), [this, env] { + Detail::ChronometerModel model; + this->benchmark(Chronometer(model, iterations_per_sample)); + auto sample_time = model.elapsed() - env.clock_cost.mean; + if (sample_time < FloatDuration::zero()) sample_time = FloatDuration::zero(); + return sample_time / iterations_per_sample; + }); + return times; + } + }; + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_EXECUTION_PLAN_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/catch_optimizer.hpp b/lib/Catch2/include/internal/benchmark/catch_optimizer.hpp new file mode 100644 index 0000000000..bda7c6d7e9 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/catch_optimizer.hpp @@ -0,0 +1,68 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + // Hinting the optimizer + +#ifndef TWOBLUECUBES_CATCH_OPTIMIZER_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_OPTIMIZER_HPP_INCLUDED + +#if defined(_MSC_VER) +# include // atomic_thread_fence +#endif + +namespace Catch { + namespace Benchmark { +#if defined(__GNUC__) || defined(__clang__) + template + inline void keep_memory(T* p) { + asm volatile("" : : "g"(p) : "memory"); + } + inline void keep_memory() { + asm volatile("" : : : "memory"); + } + + namespace Detail { + inline void optimizer_barrier() { keep_memory(); } + } // namespace Detail +#elif defined(_MSC_VER) + +#pragma optimize("", off) + template + inline void keep_memory(T* p) { + // thanks @milleniumbug + *reinterpret_cast(p) = *reinterpret_cast(p); + } + // TODO equivalent keep_memory() +#pragma optimize("", on) + + namespace Detail { + inline void optimizer_barrier() { + std::atomic_thread_fence(std::memory_order_seq_cst); + } + } // namespace Detail + +#endif + + template + inline void deoptimize_value(T&& x) { + keep_memory(&x); + } + + template + inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if::value>::type { + deoptimize_value(std::forward(fn) (std::forward(args...))); + } + + template + inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if::value>::type { + std::forward(fn) (std::forward(args...)); + } + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_OPTIMIZER_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/catch_outlier_classification.hpp b/lib/Catch2/include/internal/benchmark/catch_outlier_classification.hpp new file mode 100644 index 0000000000..66a0adf579 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/catch_outlier_classification.hpp @@ -0,0 +1,29 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +// Outlier information +#ifndef TWOBLUECUBES_CATCH_OUTLIERS_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_OUTLIERS_HPP_INCLUDED + +namespace Catch { + namespace Benchmark { + struct OutlierClassification { + int samples_seen = 0; + int low_severe = 0; // more than 3 times IQR below Q1 + int low_mild = 0; // 1.5 to 3 times IQR below Q1 + int high_mild = 0; // 1.5 to 3 times IQR above Q3 + int high_severe = 0; // more than 3 times IQR above Q3 + + int total() const { + return low_severe + low_mild + high_mild + high_severe; + } + }; + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_OUTLIERS_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/catch_sample_analysis.hpp b/lib/Catch2/include/internal/benchmark/catch_sample_analysis.hpp new file mode 100644 index 0000000000..4550d0bc4e --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/catch_sample_analysis.hpp @@ -0,0 +1,50 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +// Benchmark results + +#ifndef TWOBLUECUBES_CATCH_BENCHMARK_RESULTS_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_BENCHMARK_RESULTS_HPP_INCLUDED + +#include "catch_clock.hpp" +#include "catch_estimate.hpp" +#include "catch_outlier_classification.hpp" + +#include +#include +#include +#include + +namespace Catch { + namespace Benchmark { + template + struct SampleAnalysis { + std::vector samples; + Estimate mean; + Estimate standard_deviation; + OutlierClassification outliers; + double outlier_variance; + + template + operator SampleAnalysis() const { + std::vector samples2; + samples2.reserve(samples.size()); + std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](Duration d) { return Duration2(d); }); + return { + std::move(samples2), + mean, + standard_deviation, + outliers, + outlier_variance, + }; + } + }; + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_BENCHMARK_RESULTS_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/detail/catch_analyse.hpp b/lib/Catch2/include/internal/benchmark/detail/catch_analyse.hpp new file mode 100644 index 0000000000..a3becbe4d8 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/detail/catch_analyse.hpp @@ -0,0 +1,78 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + // Run and analyse one benchmark + +#ifndef TWOBLUECUBES_CATCH_DETAIL_ANALYSE_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_DETAIL_ANALYSE_HPP_INCLUDED + +#include "../catch_clock.hpp" +#include "../catch_sample_analysis.hpp" +#include "catch_stats.hpp" + +#include +#include +#include + +namespace Catch { + namespace Benchmark { + namespace Detail { + template + SampleAnalysis analyse(const IConfig &cfg, Environment, Iterator first, Iterator last) { + if (!cfg.benchmarkNoAnalysis()) { + std::vector samples; + samples.reserve(last - first); + std::transform(first, last, std::back_inserter(samples), [](Duration d) { return d.count(); }); + + auto analysis = Catch::Benchmark::Detail::analyse_samples(cfg.benchmarkConfidenceInterval(), cfg.benchmarkResamples(), samples.begin(), samples.end()); + auto outliers = Catch::Benchmark::Detail::classify_outliers(samples.begin(), samples.end()); + + auto wrap_estimate = [](Estimate e) { + return Estimate { + Duration(e.point), + Duration(e.lower_bound), + Duration(e.upper_bound), + e.confidence_interval, + }; + }; + std::vector samples2; + samples2.reserve(samples.size()); + std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](double d) { return Duration(d); }); + return { + std::move(samples2), + wrap_estimate(analysis.mean), + wrap_estimate(analysis.standard_deviation), + outliers, + analysis.outlier_variance, + }; + } else { + std::vector samples; + samples.reserve(last - first); + + Duration mean = Duration(0); + int i = 0; + for (auto it = first; it < last; ++it, ++i) { + samples.push_back(Duration(*it)); + mean += Duration(*it); + } + mean /= i; + + return { + std::move(samples), + Estimate{mean, mean, mean, 0.0}, + Estimate{Duration(0), Duration(0), Duration(0), 0.0}, + OutlierClassification{}, + 0.0 + }; + } + } + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_DETAIL_ANALYSE_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/detail/catch_benchmark_function.hpp b/lib/Catch2/include/internal/benchmark/detail/catch_benchmark_function.hpp new file mode 100644 index 0000000000..60c7f1d692 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/detail/catch_benchmark_function.hpp @@ -0,0 +1,105 @@ + /* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + // Dumb std::function implementation for consistent call overhead + +#ifndef TWOBLUECUBES_CATCH_DETAIL_BENCHMARK_FUNCTION_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_DETAIL_BENCHMARK_FUNCTION_HPP_INCLUDED + +#include "../catch_chronometer.hpp" +#include "catch_complete_invoke.hpp" +#include "../../catch_meta.hpp" + +#include +#include +#include +#include + +namespace Catch { + namespace Benchmark { + namespace Detail { + template + using Decay = typename std::decay::type; + template + struct is_related + : std::is_same, Decay> {}; + + /// We need to reinvent std::function because every piece of code that might add overhead + /// in a measurement context needs to have consistent performance characteristics so that we + /// can account for it in the measurement. + /// Implementations of std::function with optimizations that aren't always applicable, like + /// small buffer optimizations, are not uncommon. + /// This is effectively an implementation of std::function without any such optimizations; + /// it may be slow, but it is consistently slow. + struct BenchmarkFunction { + private: + struct callable { + virtual void call(Chronometer meter) const = 0; + virtual callable* clone() const = 0; + virtual ~callable() = default; + }; + template + struct model : public callable { + model(Fun&& fun) : fun(std::move(fun)) {} + model(Fun const& fun) : fun(fun) {} + + model* clone() const override { return new model(*this); } + + void call(Chronometer meter) const override { + call(meter, is_callable()); + } + void call(Chronometer meter, std::true_type) const { + fun(meter); + } + void call(Chronometer meter, std::false_type) const { + meter.measure(fun); + } + + Fun fun; + }; + + struct do_nothing { void operator()() const {} }; + + template + BenchmarkFunction(model* c) : f(c) {} + + public: + BenchmarkFunction() + : f(new model{ {} }) {} + + template ::value, int>::type = 0> + BenchmarkFunction(Fun&& fun) + : f(new model::type>(std::forward(fun))) {} + + BenchmarkFunction(BenchmarkFunction&& that) + : f(std::move(that.f)) {} + + BenchmarkFunction(BenchmarkFunction const& that) + : f(that.f->clone()) {} + + BenchmarkFunction& operator=(BenchmarkFunction&& that) { + f = std::move(that.f); + return *this; + } + + BenchmarkFunction& operator=(BenchmarkFunction const& that) { + f.reset(that.f->clone()); + return *this; + } + + void operator()(Chronometer meter) const { f->call(meter); } + + private: + std::unique_ptr f; + }; + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_DETAIL_BENCHMARK_FUNCTION_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/detail/catch_complete_invoke.hpp b/lib/Catch2/include/internal/benchmark/detail/catch_complete_invoke.hpp new file mode 100644 index 0000000000..f6a083d486 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/detail/catch_complete_invoke.hpp @@ -0,0 +1,68 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +// Invoke with a special case for void + +#ifndef TWOBLUECUBES_CATCH_DETAIL_COMPLETE_INVOKE_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_DETAIL_COMPLETE_INVOKE_HPP_INCLUDED + +#include "../../catch_enforce.h" +#include "../../catch_meta.hpp" + +#include +#include + +namespace Catch { + namespace Benchmark { + namespace Detail { + template + struct CompleteType { using type = T; }; + template <> + struct CompleteType { struct type {}; }; + + template + using CompleteType_t = typename CompleteType::type; + + template + struct CompleteInvoker { + template + static Result invoke(Fun&& fun, Args&&... args) { + return std::forward(fun)(std::forward(args)...); + } + }; + template <> + struct CompleteInvoker { + template + static CompleteType_t invoke(Fun&& fun, Args&&... args) { + std::forward(fun)(std::forward(args)...); + return {}; + } + }; + + // invoke and not return void :( + template + CompleteType_t> complete_invoke(Fun&& fun, Args&&... args) { + return CompleteInvoker>::invoke(std::forward(fun), std::forward(args)...); + } + + const std::string benchmarkErrorMsg = "a benchmark failed to run successfully"; + } // namespace Detail + + template + Detail::CompleteType_t> user_code(Fun&& fun) { + CATCH_TRY{ + return Detail::complete_invoke(std::forward(fun)); + } CATCH_CATCH_ALL{ + getResultCapture().benchmarkFailed(translateActiveException()); + CATCH_RUNTIME_ERROR(Detail::benchmarkErrorMsg); + } + } + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_DETAIL_COMPLETE_INVOKE_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/detail/catch_estimate_clock.hpp b/lib/Catch2/include/internal/benchmark/detail/catch_estimate_clock.hpp new file mode 100644 index 0000000000..391f5d24ce --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/detail/catch_estimate_clock.hpp @@ -0,0 +1,115 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + // Environment measurement + +#ifndef TWOBLUECUBES_CATCH_DETAIL_ESTIMATE_CLOCK_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_DETAIL_ESTIMATE_CLOCK_HPP_INCLUDED + +#include "../catch_clock.hpp" +#include "../catch_environment.hpp" +#include "catch_stats.hpp" +#include "catch_measure.hpp" +#include "catch_run_for_at_least.hpp" +#include "../catch_clock.hpp" + +#include +#include +#include +#include +#include + +namespace Catch { + namespace Benchmark { + namespace Detail { + template + std::vector resolution(int k) { + std::vector> times; + times.reserve(k + 1); + std::generate_n(std::back_inserter(times), k + 1, now{}); + + std::vector deltas; + deltas.reserve(k); + std::transform(std::next(times.begin()), times.end(), times.begin(), + std::back_inserter(deltas), + [](TimePoint a, TimePoint b) { return static_cast((a - b).count()); }); + + return deltas; + } + + const auto warmup_iterations = 10000; + const auto warmup_time = std::chrono::milliseconds(100); + const auto minimum_ticks = 1000; + const auto warmup_seed = 10000; + const auto clock_resolution_estimation_time = std::chrono::milliseconds(500); + const auto clock_cost_estimation_time_limit = std::chrono::seconds(1); + const auto clock_cost_estimation_tick_limit = 100000; + const auto clock_cost_estimation_time = std::chrono::milliseconds(10); + const auto clock_cost_estimation_iterations = 10000; + + template + int warmup() { + return run_for_at_least(std::chrono::duration_cast>(warmup_time), warmup_seed, &resolution) + .iterations; + } + template + EnvironmentEstimate> estimate_clock_resolution(int iterations) { + auto r = run_for_at_least(std::chrono::duration_cast>(clock_resolution_estimation_time), iterations, &resolution) + .result; + return { + FloatDuration(mean(r.begin(), r.end())), + classify_outliers(r.begin(), r.end()), + }; + } + template + EnvironmentEstimate> estimate_clock_cost(FloatDuration resolution) { + auto time_limit = (std::min)( + resolution * clock_cost_estimation_tick_limit, + FloatDuration(clock_cost_estimation_time_limit)); + auto time_clock = [](int k) { + return Detail::measure([k] { + for (int i = 0; i < k; ++i) { + volatile auto ignored = Clock::now(); + (void)ignored; + } + }).elapsed; + }; + time_clock(1); + int iters = clock_cost_estimation_iterations; + auto&& r = run_for_at_least(std::chrono::duration_cast>(clock_cost_estimation_time), iters, time_clock); + std::vector times; + int nsamples = static_cast(std::ceil(time_limit / r.elapsed)); + times.reserve(nsamples); + std::generate_n(std::back_inserter(times), nsamples, [time_clock, &r] { + return static_cast((time_clock(r.iterations) / r.iterations).count()); + }); + return { + FloatDuration(mean(times.begin(), times.end())), + classify_outliers(times.begin(), times.end()), + }; + } + + template + Environment> measure_environment() { + static Environment>* env = nullptr; + if (env) { + return *env; + } + + auto iters = Detail::warmup(); + auto resolution = Detail::estimate_clock_resolution(iters); + auto cost = Detail::estimate_clock_cost(resolution.mean); + + env = new Environment>{ resolution, cost }; + return *env; + } + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_DETAIL_ESTIMATE_CLOCK_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/detail/catch_measure.hpp b/lib/Catch2/include/internal/benchmark/detail/catch_measure.hpp new file mode 100644 index 0000000000..c3bd35fab3 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/detail/catch_measure.hpp @@ -0,0 +1,35 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +// Measure + +#ifndef TWOBLUECUBES_CATCH_DETAIL_MEASURE_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_DETAIL_MEASURE_HPP_INCLUDED + +#include "../catch_clock.hpp" +#include "catch_complete_invoke.hpp" +#include "catch_timing.hpp" + +#include + +namespace Catch { + namespace Benchmark { + namespace Detail { + template + TimingOf measure(Fun&& fun, Args&&... args) { + auto start = Clock::now(); + auto&& r = Detail::complete_invoke(fun, std::forward(args)...); + auto end = Clock::now(); + auto delta = end - start; + return { delta, std::forward(r), 1 }; + } + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_DETAIL_MEASURE_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/detail/catch_repeat.hpp b/lib/Catch2/include/internal/benchmark/detail/catch_repeat.hpp new file mode 100644 index 0000000000..ab240792b7 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/detail/catch_repeat.hpp @@ -0,0 +1,37 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +// repeat algorithm + +#ifndef TWOBLUECUBES_CATCH_DETAIL_REPEAT_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_DETAIL_REPEAT_HPP_INCLUDED + +#include +#include + +namespace Catch { + namespace Benchmark { + namespace Detail { + template + struct repeater { + void operator()(int k) const { + for (int i = 0; i < k; ++i) { + fun(); + } + } + Fun fun; + }; + template + repeater::type> repeat(Fun&& fun) { + return { std::forward(fun) }; + } + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_DETAIL_REPEAT_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/detail/catch_run_for_at_least.hpp b/lib/Catch2/include/internal/benchmark/detail/catch_run_for_at_least.hpp new file mode 100644 index 0000000000..339507bac7 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/detail/catch_run_for_at_least.hpp @@ -0,0 +1,65 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +// Run a function for a minimum amount of time + +#ifndef TWOBLUECUBES_CATCH_RUN_FOR_AT_LEAST_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_RUN_FOR_AT_LEAST_HPP_INCLUDED + +#include "../catch_clock.hpp" +#include "../catch_chronometer.hpp" +#include "catch_measure.hpp" +#include "catch_complete_invoke.hpp" +#include "catch_timing.hpp" +#include "../../catch_meta.hpp" + +#include +#include + +namespace Catch { + namespace Benchmark { + namespace Detail { + template + TimingOf measure_one(Fun&& fun, int iters, std::false_type) { + return Detail::measure(fun, iters); + } + template + TimingOf measure_one(Fun&& fun, int iters, std::true_type) { + Detail::ChronometerModel meter; + auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters)); + + return { meter.elapsed(), std::move(result), iters }; + } + + template + using run_for_at_least_argument_t = typename std::conditional::value, Chronometer, int>::type; + + struct optimized_away_error : std::exception { + const char* what() const noexcept override { + return "could not measure benchmark, maybe it was optimized away"; + } + }; + + template + TimingOf> run_for_at_least(ClockDuration how_long, int seed, Fun&& fun) { + auto iters = seed; + while (iters < (1 << 30)) { + auto&& Timing = measure_one(fun, iters, is_callable()); + + if (Timing.elapsed >= how_long) { + return { Timing.elapsed, std::move(Timing.result), iters }; + } + iters *= 2; + } + throw optimized_away_error{}; + } + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_RUN_FOR_AT_LEAST_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/detail/catch_stats.cpp b/lib/Catch2/include/internal/benchmark/detail/catch_stats.cpp new file mode 100644 index 0000000000..dcb51b15ea --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/detail/catch_stats.cpp @@ -0,0 +1,224 @@ +/* + * Created by Martin on 15/06/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +// Statistical analysis tools + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + +#include "catch_stats.hpp" + +#include "../../catch_compiler_capabilities.h" + +#include +#include + + +#if defined(CATCH_CONFIG_USE_ASYNC) +#include +#endif + +namespace { + double erf_inv(double x) { + // Code accompanying the article "Approximating the erfinv function" in GPU Computing Gems, Volume 2 + double w, p; + + w = -log((1.0 - x) * (1.0 + x)); + + if (w < 6.250000) { + w = w - 3.125000; + p = -3.6444120640178196996e-21; + p = -1.685059138182016589e-19 + p * w; + p = 1.2858480715256400167e-18 + p * w; + p = 1.115787767802518096e-17 + p * w; + p = -1.333171662854620906e-16 + p * w; + p = 2.0972767875968561637e-17 + p * w; + p = 6.6376381343583238325e-15 + p * w; + p = -4.0545662729752068639e-14 + p * w; + p = -8.1519341976054721522e-14 + p * w; + p = 2.6335093153082322977e-12 + p * w; + p = -1.2975133253453532498e-11 + p * w; + p = -5.4154120542946279317e-11 + p * w; + p = 1.051212273321532285e-09 + p * w; + p = -4.1126339803469836976e-09 + p * w; + p = -2.9070369957882005086e-08 + p * w; + p = 4.2347877827932403518e-07 + p * w; + p = -1.3654692000834678645e-06 + p * w; + p = -1.3882523362786468719e-05 + p * w; + p = 0.0001867342080340571352 + p * w; + p = -0.00074070253416626697512 + p * w; + p = -0.0060336708714301490533 + p * w; + p = 0.24015818242558961693 + p * w; + p = 1.6536545626831027356 + p * w; + } else if (w < 16.000000) { + w = sqrt(w) - 3.250000; + p = 2.2137376921775787049e-09; + p = 9.0756561938885390979e-08 + p * w; + p = -2.7517406297064545428e-07 + p * w; + p = 1.8239629214389227755e-08 + p * w; + p = 1.5027403968909827627e-06 + p * w; + p = -4.013867526981545969e-06 + p * w; + p = 2.9234449089955446044e-06 + p * w; + p = 1.2475304481671778723e-05 + p * w; + p = -4.7318229009055733981e-05 + p * w; + p = 6.8284851459573175448e-05 + p * w; + p = 2.4031110387097893999e-05 + p * w; + p = -0.0003550375203628474796 + p * w; + p = 0.00095328937973738049703 + p * w; + p = -0.0016882755560235047313 + p * w; + p = 0.0024914420961078508066 + p * w; + p = -0.0037512085075692412107 + p * w; + p = 0.005370914553590063617 + p * w; + p = 1.0052589676941592334 + p * w; + p = 3.0838856104922207635 + p * w; + } else { + w = sqrt(w) - 5.000000; + p = -2.7109920616438573243e-11; + p = -2.5556418169965252055e-10 + p * w; + p = 1.5076572693500548083e-09 + p * w; + p = -3.7894654401267369937e-09 + p * w; + p = 7.6157012080783393804e-09 + p * w; + p = -1.4960026627149240478e-08 + p * w; + p = 2.9147953450901080826e-08 + p * w; + p = -6.7711997758452339498e-08 + p * w; + p = 2.2900482228026654717e-07 + p * w; + p = -9.9298272942317002539e-07 + p * w; + p = 4.5260625972231537039e-06 + p * w; + p = -1.9681778105531670567e-05 + p * w; + p = 7.5995277030017761139e-05 + p * w; + p = -0.00021503011930044477347 + p * w; + p = -0.00013871931833623122026 + p * w; + p = 1.0103004648645343977 + p * w; + p = 4.8499064014085844221 + p * w; + } + return p * x; + } + + double standard_deviation(std::vector::iterator first, std::vector::iterator last) { + auto m = Catch::Benchmark::Detail::mean(first, last); + double variance = std::accumulate(first, last, 0., [m](double a, double b) { + double diff = b - m; + return a + diff * diff; + }) / (last - first); + return std::sqrt(variance); + } + +} + +namespace Catch { + namespace Benchmark { + namespace Detail { + + double weighted_average_quantile(int k, int q, std::vector::iterator first, std::vector::iterator last) { + auto count = last - first; + double idx = (count - 1) * k / static_cast(q); + int j = static_cast(idx); + double g = idx - j; + std::nth_element(first, first + j, last); + auto xj = first[j]; + if (g == 0) return xj; + + auto xj1 = *std::min_element(first + (j + 1), last); + return xj + g * (xj1 - xj); + } + + + double erfc_inv(double x) { + return erf_inv(1.0 - x); + } + + double normal_quantile(double p) { + static const double ROOT_TWO = std::sqrt(2.0); + + double result = 0.0; + assert(p >= 0 && p <= 1); + if (p < 0 || p > 1) { + return result; + } + + result = -erfc_inv(2.0 * p); + // result *= normal distribution standard deviation (1.0) * sqrt(2) + result *= /*sd * */ ROOT_TWO; + // result += normal disttribution mean (0) + return result; + } + + + double outlier_variance(Estimate mean, Estimate stddev, int n) { + double sb = stddev.point; + double mn = mean.point / n; + double mg_min = mn / 2.; + double sg = (std::min)(mg_min / 4., sb / std::sqrt(n)); + double sg2 = sg * sg; + double sb2 = sb * sb; + + auto c_max = [n, mn, sb2, sg2](double x) -> double { + double k = mn - x; + double d = k * k; + double nd = n * d; + double k0 = -n * nd; + double k1 = sb2 - n * sg2 + nd; + double det = k1 * k1 - 4 * sg2 * k0; + return (int)(-2. * k0 / (k1 + std::sqrt(det))); + }; + + auto var_out = [n, sb2, sg2](double c) { + double nc = n - c; + return (nc / n) * (sb2 - nc * sg2); + }; + + return (std::min)(var_out(1), var_out((std::min)(c_max(0.), c_max(mg_min)))) / sb2; + } + + + bootstrap_analysis analyse_samples(double confidence_level, int n_resamples, std::vector::iterator first, std::vector::iterator last) { + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS + static std::random_device entropy; + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + + auto n = static_cast(last - first); // seriously, one can't use integral types without hell in C++ + + auto mean = &Detail::mean::iterator>; + auto stddev = &standard_deviation; + +#if defined(CATCH_CONFIG_USE_ASYNC) + auto Estimate = [=](double(*f)(std::vector::iterator, std::vector::iterator)) { + auto seed = entropy(); + return std::async(std::launch::async, [=] { + std::mt19937 rng(seed); + auto resampled = resample(rng, n_resamples, first, last, f); + return bootstrap(confidence_level, first, last, resampled, f); + }); + }; + + auto mean_future = Estimate(mean); + auto stddev_future = Estimate(stddev); + + auto mean_estimate = mean_future.get(); + auto stddev_estimate = stddev_future.get(); +#else + auto Estimate = [=](double(*f)(std::vector::iterator, std::vector::iterator)) { + auto seed = entropy(); + std::mt19937 rng(seed); + auto resampled = resample(rng, n_resamples, first, last, f); + return bootstrap(confidence_level, first, last, resampled, f); + }; + + auto mean_estimate = Estimate(mean); + auto stddev_estimate = Estimate(stddev); +#endif // CATCH_USE_ASYNC + + double outlier_variance = Detail::outlier_variance(mean_estimate, stddev_estimate, n); + + return { mean_estimate, stddev_estimate, outlier_variance }; + } + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING diff --git a/lib/Catch2/include/internal/benchmark/detail/catch_stats.hpp b/lib/Catch2/include/internal/benchmark/detail/catch_stats.hpp new file mode 100644 index 0000000000..1bcbc259b9 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/detail/catch_stats.hpp @@ -0,0 +1,160 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +// Statistical analysis tools + +#ifndef TWOBLUECUBES_CATCH_DETAIL_ANALYSIS_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_DETAIL_ANALYSIS_HPP_INCLUDED + +#include "../catch_clock.hpp" +#include "../catch_estimate.hpp" +#include "../catch_outlier_classification.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Catch { + namespace Benchmark { + namespace Detail { + using sample = std::vector; + + double weighted_average_quantile(int k, int q, std::vector::iterator first, std::vector::iterator last); + + template + OutlierClassification classify_outliers(Iterator first, Iterator last) { + std::vector copy(first, last); + + auto q1 = weighted_average_quantile(1, 4, copy.begin(), copy.end()); + auto q3 = weighted_average_quantile(3, 4, copy.begin(), copy.end()); + auto iqr = q3 - q1; + auto los = q1 - (iqr * 3.); + auto lom = q1 - (iqr * 1.5); + auto him = q3 + (iqr * 1.5); + auto his = q3 + (iqr * 3.); + + OutlierClassification o; + for (; first != last; ++first) { + auto&& t = *first; + if (t < los) ++o.low_severe; + else if (t < lom) ++o.low_mild; + else if (t > his) ++o.high_severe; + else if (t > him) ++o.high_mild; + ++o.samples_seen; + } + return o; + } + + template + double mean(Iterator first, Iterator last) { + auto count = last - first; + double sum = std::accumulate(first, last, 0.); + return sum / count; + } + + template + sample resample(URng& rng, int resamples, Iterator first, Iterator last, Estimator& estimator) { + auto n = last - first; + std::uniform_int_distribution dist(0, n - 1); + + sample out; + out.reserve(resamples); + std::generate_n(std::back_inserter(out), resamples, [n, first, &estimator, &dist, &rng] { + std::vector resampled; + resampled.reserve(n); + std::generate_n(std::back_inserter(resampled), n, [first, &dist, &rng] { return first[dist(rng)]; }); + return estimator(resampled.begin(), resampled.end()); + }); + std::sort(out.begin(), out.end()); + return out; + } + + template + sample jackknife(Estimator&& estimator, Iterator first, Iterator last) { + auto n = last - first; + auto second = std::next(first); + sample results; + results.reserve(n); + + for (auto it = first; it != last; ++it) { + std::iter_swap(it, first); + results.push_back(estimator(second, last)); + } + + return results; + } + + inline double normal_cdf(double x) { + return std::erfc(-x / std::sqrt(2.0)) / 2.0; + } + + double erfc_inv(double x); + + double normal_quantile(double p); + + template + Estimate bootstrap(double confidence_level, Iterator first, Iterator last, sample const& resample, Estimator&& estimator) { + auto n_samples = last - first; + + double point = estimator(first, last); + // Degenerate case with a single sample + if (n_samples == 1) return { point, point, point, confidence_level }; + + sample jack = jackknife(estimator, first, last); + double jack_mean = mean(jack.begin(), jack.end()); + double sum_squares, sum_cubes; + std::tie(sum_squares, sum_cubes) = std::accumulate(jack.begin(), jack.end(), std::make_pair(0., 0.), [jack_mean](std::pair sqcb, double x) -> std::pair { + auto d = jack_mean - x; + auto d2 = d * d; + auto d3 = d2 * d; + return { sqcb.first + d2, sqcb.second + d3 }; + }); + + double accel = sum_cubes / (6 * std::pow(sum_squares, 1.5)); + int n = static_cast(resample.size()); + double prob_n = std::count_if(resample.begin(), resample.end(), [point](double x) { return x < point; }) / (double)n; + // degenerate case with uniform samples + if (prob_n == 0) return { point, point, point, confidence_level }; + + double bias = normal_quantile(prob_n); + double z1 = normal_quantile((1. - confidence_level) / 2.); + + auto cumn = [n](double x) -> int { + return std::lround(normal_cdf(x) * n); }; + auto a = [bias, accel](double b) { return bias + b / (1. - accel * b); }; + double b1 = bias + z1; + double b2 = bias - z1; + double a1 = a(b1); + double a2 = a(b2); + auto lo = (std::max)(cumn(a1), 0); + auto hi = (std::min)(cumn(a2), n - 1); + + return { point, resample[lo], resample[hi], confidence_level }; + } + + double outlier_variance(Estimate mean, Estimate stddev, int n); + + struct bootstrap_analysis { + Estimate mean; + Estimate standard_deviation; + double outlier_variance; + }; + + bootstrap_analysis analyse_samples(double confidence_level, int n_resamples, std::vector::iterator first, std::vector::iterator last); + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_DETAIL_ANALYSIS_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/benchmark/detail/catch_timing.hpp b/lib/Catch2/include/internal/benchmark/detail/catch_timing.hpp new file mode 100644 index 0000000000..fc24886a08 --- /dev/null +++ b/lib/Catch2/include/internal/benchmark/detail/catch_timing.hpp @@ -0,0 +1,33 @@ +/* + * Created by Joachim on 16/04/2019. + * Adapted from donated nonius code. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +// Timing + +#ifndef TWOBLUECUBES_CATCH_DETAIL_TIMING_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_DETAIL_TIMING_HPP_INCLUDED + +#include "../catch_clock.hpp" +#include "catch_complete_invoke.hpp" + +#include +#include + +namespace Catch { + namespace Benchmark { + template + struct Timing { + Duration elapsed; + Result result; + int iterations; + }; + template + using TimingOf = Timing, Detail::CompleteType_t>>; + } // namespace Benchmark +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_DETAIL_TIMING_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_approx.cpp b/lib/Catch2/include/internal/catch_approx.cpp new file mode 100644 index 0000000000..32b5e0437e --- /dev/null +++ b/lib/Catch2/include/internal/catch_approx.cpp @@ -0,0 +1,88 @@ +/* + * Created by Martin on 19/07/2017. + * Copyright 2017 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_approx.h" +#include "catch_enforce.h" + +#include +#include + +namespace { + +// Performs equivalent check of std::fabs(lhs - rhs) <= margin +// But without the subtraction to allow for INFINITY in comparison +bool marginComparison(double lhs, double rhs, double margin) { + return (lhs + margin >= rhs) && (rhs + margin >= lhs); +} + +} + +namespace Catch { +namespace Detail { + + Approx::Approx ( double value ) + : m_epsilon( std::numeric_limits::epsilon()*100 ), + m_margin( 0.0 ), + m_scale( 0.0 ), + m_value( value ) + {} + + Approx Approx::custom() { + return Approx( 0 ); + } + + Approx Approx::operator-() const { + auto temp(*this); + temp.m_value = -temp.m_value; + return temp; + } + + + std::string Approx::toString() const { + ReusableStringStream rss; + rss << "Approx( " << ::Catch::Detail::stringify( m_value ) << " )"; + return rss.str(); + } + + bool Approx::equalityComparisonImpl(const double other) const { + // First try with fixed margin, then compute margin based on epsilon, scale and Approx's value + // Thanks to Richard Harris for his help refining the scaled margin value + return marginComparison(m_value, other, m_margin) + || marginComparison(m_value, other, m_epsilon * (m_scale + std::fabs(std::isinf(m_value)? 0 : m_value))); + } + + void Approx::setMargin(double newMargin) { + CATCH_ENFORCE(newMargin >= 0, + "Invalid Approx::margin: " << newMargin << '.' + << " Approx::Margin has to be non-negative."); + m_margin = newMargin; + } + + void Approx::setEpsilon(double newEpsilon) { + CATCH_ENFORCE(newEpsilon >= 0 && newEpsilon <= 1.0, + "Invalid Approx::epsilon: " << newEpsilon << '.' + << " Approx::epsilon has to be in [0, 1]"); + m_epsilon = newEpsilon; + } + +} // end namespace Detail + +namespace literals { + Detail::Approx operator "" _a(long double val) { + return Detail::Approx(val); + } + Detail::Approx operator "" _a(unsigned long long val) { + return Detail::Approx(val); + } +} // end namespace literals + +std::string StringMaker::convert(Catch::Detail::Approx const& value) { + return value.toString(); +} + +} // end namespace Catch diff --git a/lib/Catch2/include/internal/catch_approx.h b/lib/Catch2/include/internal/catch_approx.h new file mode 100644 index 0000000000..4522e5ad70 --- /dev/null +++ b/lib/Catch2/include/internal/catch_approx.h @@ -0,0 +1,132 @@ +/* + * Created by Phil on 28/04/2011. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED + +#include "catch_tostring.h" + +#include + +namespace Catch { +namespace Detail { + + class Approx { + private: + bool equalityComparisonImpl(double other) const; + // Validates the new margin (margin >= 0) + // out-of-line to avoid including stdexcept in the header + void setMargin(double margin); + // Validates the new epsilon (0 < epsilon < 1) + // out-of-line to avoid including stdexcept in the header + void setEpsilon(double epsilon); + + public: + explicit Approx ( double value ); + + static Approx custom(); + + Approx operator-() const; + + template ::value>::type> + Approx operator()( T const& value ) { + Approx approx( static_cast(value) ); + approx.m_epsilon = m_epsilon; + approx.m_margin = m_margin; + approx.m_scale = m_scale; + return approx; + } + + template ::value>::type> + explicit Approx( T const& value ): Approx(static_cast(value)) + {} + + + template ::value>::type> + friend bool operator == ( const T& lhs, Approx const& rhs ) { + auto lhs_v = static_cast(lhs); + return rhs.equalityComparisonImpl(lhs_v); + } + + template ::value>::type> + friend bool operator == ( Approx const& lhs, const T& rhs ) { + return operator==( rhs, lhs ); + } + + template ::value>::type> + friend bool operator != ( T const& lhs, Approx const& rhs ) { + return !operator==( lhs, rhs ); + } + + template ::value>::type> + friend bool operator != ( Approx const& lhs, T const& rhs ) { + return !operator==( rhs, lhs ); + } + + template ::value>::type> + friend bool operator <= ( T const& lhs, Approx const& rhs ) { + return static_cast(lhs) < rhs.m_value || lhs == rhs; + } + + template ::value>::type> + friend bool operator <= ( Approx const& lhs, T const& rhs ) { + return lhs.m_value < static_cast(rhs) || lhs == rhs; + } + + template ::value>::type> + friend bool operator >= ( T const& lhs, Approx const& rhs ) { + return static_cast(lhs) > rhs.m_value || lhs == rhs; + } + + template ::value>::type> + friend bool operator >= ( Approx const& lhs, T const& rhs ) { + return lhs.m_value > static_cast(rhs) || lhs == rhs; + } + + template ::value>::type> + Approx& epsilon( T const& newEpsilon ) { + double epsilonAsDouble = static_cast(newEpsilon); + setEpsilon(epsilonAsDouble); + return *this; + } + + template ::value>::type> + Approx& margin( T const& newMargin ) { + double marginAsDouble = static_cast(newMargin); + setMargin(marginAsDouble); + return *this; + } + + template ::value>::type> + Approx& scale( T const& newScale ) { + m_scale = static_cast(newScale); + return *this; + } + + std::string toString() const; + + private: + double m_epsilon; + double m_margin; + double m_scale; + double m_value; + }; +} // end namespace Detail + +namespace literals { + Detail::Approx operator "" _a(long double val); + Detail::Approx operator "" _a(unsigned long long val); +} // end namespace literals + +template<> +struct StringMaker { + static std::string convert(Catch::Detail::Approx const& value); +}; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_assertionhandler.cpp b/lib/Catch2/include/internal/catch_assertionhandler.cpp new file mode 100644 index 0000000000..fd14c85a2f --- /dev/null +++ b/lib/Catch2/include/internal/catch_assertionhandler.cpp @@ -0,0 +1,122 @@ +/* + * Created by Phil on 8/8/2017. + * Copyright 2017 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_assertionhandler.h" +#include "catch_assertionresult.h" +#include "catch_interfaces_runner.h" +#include "catch_interfaces_config.h" +#include "catch_context.h" +#include "catch_debugger.h" +#include "catch_interfaces_registry_hub.h" +#include "catch_capture_matchers.h" +#include "catch_run_context.h" +#include "catch_enforce.h" + +namespace Catch { + + namespace { + auto operator <<( std::ostream& os, ITransientExpression const& expr ) -> std::ostream& { + expr.streamReconstructedExpression( os ); + return os; + } + } + + LazyExpression::LazyExpression( bool isNegated ) + : m_isNegated( isNegated ) + {} + + LazyExpression::LazyExpression( LazyExpression const& other ) : m_isNegated( other.m_isNegated ) {} + + LazyExpression::operator bool() const { + return m_transientExpression != nullptr; + } + + auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream& { + if( lazyExpr.m_isNegated ) + os << "!"; + + if( lazyExpr ) { + if( lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression() ) + os << "(" << *lazyExpr.m_transientExpression << ")"; + else + os << *lazyExpr.m_transientExpression; + } + else { + os << "{** error - unchecked empty expression requested **}"; + } + return os; + } + + AssertionHandler::AssertionHandler + ( StringRef const& macroName, + SourceLineInfo const& lineInfo, + StringRef capturedExpression, + ResultDisposition::Flags resultDisposition ) + : m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition }, + m_resultCapture( getResultCapture() ) + {} + + void AssertionHandler::handleExpr( ITransientExpression const& expr ) { + m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction ); + } + void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef const& message) { + m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction ); + } + + auto AssertionHandler::allowThrows() const -> bool { + return getCurrentContext().getConfig()->allowThrows(); + } + + void AssertionHandler::complete() { + setCompleted(); + if( m_reaction.shouldDebugBreak ) { + + // If you find your debugger stopping you here then go one level up on the + // call-stack for the code that caused it (typically a failed assertion) + + // (To go back to the test and change execution, jump over the throw, next) + CATCH_BREAK_INTO_DEBUGGER(); + } + if (m_reaction.shouldThrow) { +#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + throw Catch::TestFailureException(); +#else + CATCH_ERROR( "Test failure requires aborting test!" ); +#endif + } + } + void AssertionHandler::setCompleted() { + m_completed = true; + } + + void AssertionHandler::handleUnexpectedInflightException() { + m_resultCapture.handleUnexpectedInflightException( m_assertionInfo, Catch::translateActiveException(), m_reaction ); + } + + void AssertionHandler::handleExceptionThrownAsExpected() { + m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction); + } + void AssertionHandler::handleExceptionNotThrownAsExpected() { + m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction); + } + + void AssertionHandler::handleUnexpectedExceptionNotThrown() { + m_resultCapture.handleUnexpectedExceptionNotThrown( m_assertionInfo, m_reaction ); + } + + void AssertionHandler::handleThrowingCallSkipped() { + m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction); + } + + // This is the overload that takes a string and infers the Equals matcher from it + // The more general overload, that takes any string matcher, is in catch_capture_matchers.cpp + void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef const& matcherString ) { + handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString ); + } + +} // namespace Catch diff --git a/lib/Catch2/include/internal/catch_assertionhandler.h b/lib/Catch2/include/internal/catch_assertionhandler.h new file mode 100644 index 0000000000..3089e662c4 --- /dev/null +++ b/lib/Catch2/include/internal/catch_assertionhandler.h @@ -0,0 +1,88 @@ +/* + * Created by Phil on 8/8/2017. + * Copyright 2017 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_ASSERTIONHANDLER_H_INCLUDED +#define TWOBLUECUBES_CATCH_ASSERTIONHANDLER_H_INCLUDED + +#include "catch_assertioninfo.h" +#include "catch_decomposer.h" +#include "catch_interfaces_capture.h" + +namespace Catch { + + struct TestFailureException{}; + struct AssertionResultData; + struct IResultCapture; + class RunContext; + + class LazyExpression { + friend class AssertionHandler; + friend struct AssertionStats; + friend class RunContext; + + ITransientExpression const* m_transientExpression = nullptr; + bool m_isNegated; + public: + LazyExpression( bool isNegated ); + LazyExpression( LazyExpression const& other ); + LazyExpression& operator = ( LazyExpression const& ) = delete; + + explicit operator bool() const; + + friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&; + }; + + struct AssertionReaction { + bool shouldDebugBreak = false; + bool shouldThrow = false; + }; + + class AssertionHandler { + AssertionInfo m_assertionInfo; + AssertionReaction m_reaction; + bool m_completed = false; + IResultCapture& m_resultCapture; + + public: + AssertionHandler + ( StringRef const& macroName, + SourceLineInfo const& lineInfo, + StringRef capturedExpression, + ResultDisposition::Flags resultDisposition ); + ~AssertionHandler() { + if ( !m_completed ) { + m_resultCapture.handleIncomplete( m_assertionInfo ); + } + } + + + template + void handleExpr( ExprLhs const& expr ) { + handleExpr( expr.makeUnaryExpr() ); + } + void handleExpr( ITransientExpression const& expr ); + + void handleMessage(ResultWas::OfType resultType, StringRef const& message); + + void handleExceptionThrownAsExpected(); + void handleUnexpectedExceptionNotThrown(); + void handleExceptionNotThrownAsExpected(); + void handleThrowingCallSkipped(); + void handleUnexpectedInflightException(); + + void complete(); + void setCompleted(); + + // query + auto allowThrows() const -> bool; + }; + + void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef const& matcherString ); + +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_ASSERTIONHANDLER_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_assertioninfo.h b/lib/Catch2/include/internal/catch_assertioninfo.h new file mode 100644 index 0000000000..5f136bf738 --- /dev/null +++ b/lib/Catch2/include/internal/catch_assertioninfo.h @@ -0,0 +1,31 @@ +/* + * Created by Phil on 8/8/2017. + * Copyright 2017 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_ASSERTIONINFO_H_INCLUDED +#define TWOBLUECUBES_CATCH_ASSERTIONINFO_H_INCLUDED + +#include "catch_result_type.h" +#include "catch_common.h" +#include "catch_stringref.h" + +namespace Catch { + + struct AssertionInfo + { + StringRef macroName; + SourceLineInfo lineInfo; + StringRef capturedExpression; + ResultDisposition::Flags resultDisposition; + + // We want to delete this constructor but a compiler bug in 4.8 means + // the struct is then treated as non-aggregate + //AssertionInfo() = delete; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_ASSERTIONINFO_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_assertionresult.cpp b/lib/Catch2/include/internal/catch_assertionresult.cpp new file mode 100644 index 0000000000..608a9add69 --- /dev/null +++ b/lib/Catch2/include/internal/catch_assertionresult.cpp @@ -0,0 +1,104 @@ +/* + * Created by Phil on 8/8/12 + * Copyright 2012 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_assertionresult.h" + +namespace Catch { + AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression): + lazyExpression(_lazyExpression), + resultType(_resultType) {} + + std::string AssertionResultData::reconstructExpression() const { + + if( reconstructedExpression.empty() ) { + if( lazyExpression ) { + ReusableStringStream rss; + rss << lazyExpression; + reconstructedExpression = rss.str(); + } + } + return reconstructedExpression; + } + + AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data ) + : m_info( info ), + m_resultData( data ) + {} + + // Result was a success + bool AssertionResult::succeeded() const { + return Catch::isOk( m_resultData.resultType ); + } + + // Result was a success, or failure is suppressed + bool AssertionResult::isOk() const { + return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition ); + } + + ResultWas::OfType AssertionResult::getResultType() const { + return m_resultData.resultType; + } + + bool AssertionResult::hasExpression() const { + return !m_info.capturedExpression.empty(); + } + + bool AssertionResult::hasMessage() const { + return !m_resultData.message.empty(); + } + + std::string AssertionResult::getExpression() const { + // Possibly overallocating by 3 characters should be basically free + std::string expr; expr.reserve(m_info.capturedExpression.size() + 3); + if (isFalseTest(m_info.resultDisposition)) { + expr += "!("; + } + expr += m_info.capturedExpression; + if (isFalseTest(m_info.resultDisposition)) { + expr += ')'; + } + return expr; + } + + std::string AssertionResult::getExpressionInMacro() const { + std::string expr; + if( m_info.macroName.empty() ) + expr = static_cast(m_info.capturedExpression); + else { + expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 ); + expr += m_info.macroName; + expr += "( "; + expr += m_info.capturedExpression; + expr += " )"; + } + return expr; + } + + bool AssertionResult::hasExpandedExpression() const { + return hasExpression() && getExpandedExpression() != getExpression(); + } + + std::string AssertionResult::getExpandedExpression() const { + std::string expr = m_resultData.reconstructExpression(); + return expr.empty() + ? getExpression() + : expr; + } + + std::string AssertionResult::getMessage() const { + return m_resultData.message; + } + SourceLineInfo AssertionResult::getSourceInfo() const { + return m_info.lineInfo; + } + + StringRef AssertionResult::getTestMacroName() const { + return m_info.macroName; + } + +} // end namespace Catch diff --git a/lib/Catch2/include/internal/catch_assertionresult.h b/lib/Catch2/include/internal/catch_assertionresult.h new file mode 100644 index 0000000000..3c91ea58da --- /dev/null +++ b/lib/Catch2/include/internal/catch_assertionresult.h @@ -0,0 +1,59 @@ +/* + * Created by Phil on 28/10/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED +#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED + +#include +#include "catch_assertioninfo.h" +#include "catch_result_type.h" +#include "catch_common.h" +#include "catch_stringref.h" +#include "catch_assertionhandler.h" + +namespace Catch { + + struct AssertionResultData + { + AssertionResultData() = delete; + + AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression ); + + std::string message; + mutable std::string reconstructedExpression; + LazyExpression lazyExpression; + ResultWas::OfType resultType; + + std::string reconstructExpression() const; + }; + + class AssertionResult { + public: + AssertionResult() = delete; + AssertionResult( AssertionInfo const& info, AssertionResultData const& data ); + + bool isOk() const; + bool succeeded() const; + ResultWas::OfType getResultType() const; + bool hasExpression() const; + bool hasMessage() const; + std::string getExpression() const; + std::string getExpressionInMacro() const; + bool hasExpandedExpression() const; + std::string getExpandedExpression() const; + std::string getMessage() const; + SourceLineInfo getSourceInfo() const; + StringRef getTestMacroName() const; + + //protected: + AssertionInfo m_info; + AssertionResultData m_resultData; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_capture.hpp b/lib/Catch2/include/internal/catch_capture.hpp new file mode 100644 index 0000000000..a65b3aeca9 --- /dev/null +++ b/lib/Catch2/include/internal/catch_capture.hpp @@ -0,0 +1,159 @@ +/* + * Created by Phil on 18/10/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED + +#include "catch_assertionhandler.h" +#include "catch_interfaces_capture.h" +#include "catch_message.h" +#include "catch_stringref.h" + +#if !defined(CATCH_CONFIG_DISABLE) + +#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) + #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__ +#else + #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION" +#endif + +#if defined(CATCH_CONFIG_FAST_COMPILE) || defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + +/////////////////////////////////////////////////////////////////////////////// +// Another way to speed-up compilation is to omit local try-catch for REQUIRE* +// macros. +#define INTERNAL_CATCH_TRY +#define INTERNAL_CATCH_CATCH( capturer ) + +#else // CATCH_CONFIG_FAST_COMPILE + +#define INTERNAL_CATCH_TRY try +#define INTERNAL_CATCH_CATCH( handler ) catch(...) { handler.handleUnexpectedInflightException(); } + +#endif + +#define INTERNAL_CATCH_REACT( handler ) handler.complete(); + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TEST( macroName, resultDisposition, ... ) \ + do { \ + /* The expression should not be evaluated, but warnings should hopefully be checked */ \ + CATCH_INTERNAL_IGNORE_BUT_WARN(__VA_ARGS__); \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ + INTERNAL_CATCH_TRY { \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( (void)0, (false) && static_cast( !!(__VA_ARGS__) ) ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_IF( macroName, resultDisposition, ... ) \ + INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \ + if( Catch::getResultCapture().lastAssertionPassed() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_ELSE( macroName, resultDisposition, ... ) \ + INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \ + if( !Catch::getResultCapture().lastAssertionPassed() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ + try { \ + static_cast(__VA_ARGS__); \ + catchAssertionHandler.handleExceptionNotThrownAsExpected(); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleUnexpectedInflightException(); \ + } \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(__VA_ARGS__); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleExceptionThrownAsExpected(); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr) ", " CATCH_INTERNAL_STRINGIFY(exceptionType), resultDisposition ); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(expr); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( exceptionType const& ) { \ + catchAssertionHandler.handleExceptionThrownAsExpected(); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleUnexpectedInflightException(); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::StringRef(), resultDisposition ); \ + catchAssertionHandler.handleMessage( messageType, ( Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop() ).m_stream.str() ); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_CAPTURE( varName, macroName, ... ) \ + auto varName = Catch::Capturer( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info, #__VA_ARGS__ ); \ + varName.captureValues( 0, __VA_ARGS__ ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_INFO( macroName, log ) \ + Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ); + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_UNSCOPED_INFO( macroName, log ) \ + Catch::getResultCapture().emplaceUnscopedMessage( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ) + +/////////////////////////////////////////////////////////////////////////////// +// Although this is matcher-based, it can be used with just a string +#define INTERNAL_CATCH_THROWS_STR_MATCHES( macroName, resultDisposition, matcher, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(__VA_ARGS__); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( ... ) { \ + Catch::handleExceptionMatchExpr( catchAssertionHandler, matcher, #matcher##_catch_sr ); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +#endif // CATCH_CONFIG_DISABLE + +#endif // TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_capture_matchers.cpp b/lib/Catch2/include/internal/catch_capture_matchers.cpp new file mode 100644 index 0000000000..6f320449a2 --- /dev/null +++ b/lib/Catch2/include/internal/catch_capture_matchers.cpp @@ -0,0 +1,24 @@ +/* + * Created by Phil on 9/8/2017. + * Copyright 2017 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#include "catch_capture_matchers.h" +#include "catch_interfaces_registry_hub.h" + +namespace Catch { + + using StringMatcher = Matchers::Impl::MatcherBase; + + // This is the general overload that takes a any string matcher + // There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers + // the Equals matcher (so the header does not mention matchers) + void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef const& matcherString ) { + std::string exceptionMessage = Catch::translateActiveException(); + MatchExpr expr( exceptionMessage, matcher, matcherString ); + handler.handleExpr( expr ); + } + +} // namespace Catch diff --git a/lib/Catch2/include/internal/catch_capture_matchers.h b/lib/Catch2/include/internal/catch_capture_matchers.h new file mode 100644 index 0000000000..5386e5e179 --- /dev/null +++ b/lib/Catch2/include/internal/catch_capture_matchers.h @@ -0,0 +1,88 @@ +/* + * Created by Phil on 9/8/2017 + * Copyright 2017 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_CAPTURE_MATCHERS_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_CAPTURE_MATCHERS_HPP_INCLUDED + +#include "catch_capture.hpp" +#include "catch_matchers.h" +#include "catch_matchers_exception.hpp" +#include "catch_matchers_floating.h" +#include "catch_matchers_generic.hpp" +#include "catch_matchers_string.h" +#include "catch_matchers_vector.h" +#include "catch_stringref.h" + +namespace Catch { + + template + class MatchExpr : public ITransientExpression { + ArgT const& m_arg; + MatcherT m_matcher; + StringRef m_matcherString; + public: + MatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef const& matcherString ) + : ITransientExpression{ true, matcher.match( arg ) }, + m_arg( arg ), + m_matcher( matcher ), + m_matcherString( matcherString ) + {} + + void streamReconstructedExpression( std::ostream &os ) const override { + auto matcherAsString = m_matcher.toString(); + os << Catch::Detail::stringify( m_arg ) << ' '; + if( matcherAsString == Detail::unprintableString ) + os << m_matcherString; + else + os << matcherAsString; + } + }; + + using StringMatcher = Matchers::Impl::MatcherBase; + + void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef const& matcherString ); + + template + auto makeMatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef const& matcherString ) -> MatchExpr { + return MatchExpr( arg, matcher, matcherString ); + } + +} // namespace Catch + + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + INTERNAL_CATCH_TRY { \ + catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher, #matcher##_catch_sr ) ); \ + } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_THROWS_MATCHES( macroName, exceptionType, resultDisposition, matcher, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(exceptionType) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(__VA_ARGS__ ); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( exceptionType const& ex ) { \ + catchAssertionHandler.handleExpr( Catch::makeMatchExpr( ex, matcher, #matcher##_catch_sr ) ); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleUnexpectedInflightException(); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +#endif // TWOBLUECUBES_CATCH_CAPTURE_MATCHERS_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_clara.h b/lib/Catch2/include/internal/catch_clara.h new file mode 100644 index 0000000000..bdf70250b9 --- /dev/null +++ b/lib/Catch2/include/internal/catch_clara.h @@ -0,0 +1,38 @@ +/* + * Created by Phil on 10/2/2014. + * Copyright 2014 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ +#ifndef TWOBLUECUBES_CATCH_CLARA_H_INCLUDED +#define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED + +// Use Catch's value for console width (store Clara's off to the side, if present) +#ifdef CLARA_CONFIG_CONSOLE_WIDTH +#define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#undef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#endif +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH-1 + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#pragma clang diagnostic ignored "-Wexit-time-destructors" +#pragma clang diagnostic ignored "-Wshadow" +#endif + +#include "../external/clara.hpp" + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// Restore Clara's value for console width, if present +#ifdef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH +#undef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH +#endif + +#endif // TWOBLUECUBES_CATCH_CLARA_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_commandline.cpp b/lib/Catch2/include/internal/catch_commandline.cpp new file mode 100644 index 0000000000..673d3b70bc --- /dev/null +++ b/lib/Catch2/include/internal/catch_commandline.cpp @@ -0,0 +1,230 @@ +/* + * Created by Phil on 02/11/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_commandline.h" + +#include "catch_string_manip.h" + +#include "catch_interfaces_registry_hub.h" +#include "catch_interfaces_reporter.h" + +#include +#include + +namespace Catch { + + clara::Parser makeCommandLineParser( ConfigData& config ) { + + using namespace clara; + + auto const setWarning = [&]( std::string const& warning ) { + auto warningSet = [&]() { + if( warning == "NoAssertions" ) + return WarnAbout::NoAssertions; + + if ( warning == "NoTests" ) + return WarnAbout::NoTests; + + return WarnAbout::Nothing; + }(); + + if (warningSet == WarnAbout::Nothing) + return ParserResult::runtimeError( "Unrecognised warning: '" + warning + "'" ); + config.warnings = static_cast( config.warnings | warningSet ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const loadTestNamesFromFile = [&]( std::string const& filename ) { + std::ifstream f( filename.c_str() ); + if( !f.is_open() ) + return ParserResult::runtimeError( "Unable to load input file: '" + filename + "'" ); + + std::string line; + while( std::getline( f, line ) ) { + line = trim(line); + if( !line.empty() && !startsWith( line, '#' ) ) { + if( !startsWith( line, '"' ) ) + line = '"' + line + '"'; + config.testsOrTags.push_back( line ); + config.testsOrTags.emplace_back( "," ); + } + } + //Remove comma in the end + if(!config.testsOrTags.empty()) + config.testsOrTags.erase( config.testsOrTags.end()-1 ); + + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setTestOrder = [&]( std::string const& order ) { + if( startsWith( "declared", order ) ) + config.runOrder = RunTests::InDeclarationOrder; + else if( startsWith( "lexical", order ) ) + config.runOrder = RunTests::InLexicographicalOrder; + else if( startsWith( "random", order ) ) + config.runOrder = RunTests::InRandomOrder; + else + return clara::ParserResult::runtimeError( "Unrecognised ordering: '" + order + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setRngSeed = [&]( std::string const& seed ) { + if( seed != "time" ) + return clara::detail::convertInto( seed, config.rngSeed ); + config.rngSeed = static_cast( std::time(nullptr) ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setColourUsage = [&]( std::string const& useColour ) { + auto mode = toLower( useColour ); + + if( mode == "yes" ) + config.useColour = UseColour::Yes; + else if( mode == "no" ) + config.useColour = UseColour::No; + else if( mode == "auto" ) + config.useColour = UseColour::Auto; + else + return ParserResult::runtimeError( "colour mode must be one of: auto, yes or no. '" + useColour + "' not recognised" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setWaitForKeypress = [&]( std::string const& keypress ) { + auto keypressLc = toLower( keypress ); + if (keypressLc == "never") + config.waitForKeypress = WaitForKeypress::Never; + else if( keypressLc == "start" ) + config.waitForKeypress = WaitForKeypress::BeforeStart; + else if( keypressLc == "exit" ) + config.waitForKeypress = WaitForKeypress::BeforeExit; + else if( keypressLc == "both" ) + config.waitForKeypress = WaitForKeypress::BeforeStartAndExit; + else + return ParserResult::runtimeError( "keypress argument must be one of: never, start, exit or both. '" + keypress + "' not recognised" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setVerbosity = [&]( std::string const& verbosity ) { + auto lcVerbosity = toLower( verbosity ); + if( lcVerbosity == "quiet" ) + config.verbosity = Verbosity::Quiet; + else if( lcVerbosity == "normal" ) + config.verbosity = Verbosity::Normal; + else if( lcVerbosity == "high" ) + config.verbosity = Verbosity::High; + else + return ParserResult::runtimeError( "Unrecognised verbosity, '" + verbosity + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setReporter = [&]( std::string const& reporter ) { + IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories(); + + auto lcReporter = toLower( reporter ); + auto result = factories.find( lcReporter ); + + if( factories.end() != result ) + config.reporterName = lcReporter; + else + return ParserResult::runtimeError( "Unrecognized reporter, '" + reporter + "'. Check available with --list-reporters" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + + auto cli + = ExeName( config.processName ) + | Help( config.showHelp ) + | Opt( config.listTests ) + ["-l"]["--list-tests"] + ( "list all/matching test cases" ) + | Opt( config.listTags ) + ["-t"]["--list-tags"] + ( "list all/matching tags" ) + | Opt( config.showSuccessfulTests ) + ["-s"]["--success"] + ( "include successful tests in output" ) + | Opt( config.shouldDebugBreak ) + ["-b"]["--break"] + ( "break into debugger on failure" ) + | Opt( config.noThrow ) + ["-e"]["--nothrow"] + ( "skip exception tests" ) + | Opt( config.showInvisibles ) + ["-i"]["--invisibles"] + ( "show invisibles (tabs, newlines)" ) + | Opt( config.outputFilename, "filename" ) + ["-o"]["--out"] + ( "output filename" ) + | Opt( setReporter, "name" ) + ["-r"]["--reporter"] + ( "reporter to use (defaults to console)" ) + | Opt( config.name, "name" ) + ["-n"]["--name"] + ( "suite name" ) + | Opt( [&]( bool ){ config.abortAfter = 1; } ) + ["-a"]["--abort"] + ( "abort at first failure" ) + | Opt( [&]( int x ){ config.abortAfter = x; }, "no. failures" ) + ["-x"]["--abortx"] + ( "abort after x failures" ) + | Opt( setWarning, "warning name" ) + ["-w"]["--warn"] + ( "enable warnings" ) + | Opt( [&]( bool flag ) { config.showDurations = flag ? ShowDurations::Always : ShowDurations::Never; }, "yes|no" ) + ["-d"]["--durations"] + ( "show test durations" ) + | Opt( config.minDuration, "seconds" ) + ["-D"]["--min-duration"] + ( "show test durations for tests taking at least the given number of seconds" ) + | Opt( loadTestNamesFromFile, "filename" ) + ["-f"]["--input-file"] + ( "load test names to run from a file" ) + | Opt( config.filenamesAsTags ) + ["-#"]["--filenames-as-tags"] + ( "adds a tag for the filename" ) + | Opt( config.sectionsToRun, "section name" ) + ["-c"]["--section"] + ( "specify section to run" ) + | Opt( setVerbosity, "quiet|normal|high" ) + ["-v"]["--verbosity"] + ( "set output verbosity" ) + | Opt( config.listTestNamesOnly ) + ["--list-test-names-only"] + ( "list all/matching test cases names only" ) + | Opt( config.listReporters ) + ["--list-reporters"] + ( "list all reporters" ) + | Opt( setTestOrder, "decl|lex|rand" ) + ["--order"] + ( "test case order (defaults to decl)" ) + | Opt( setRngSeed, "'time'|number" ) + ["--rng-seed"] + ( "set a specific seed for random numbers" ) + | Opt( setColourUsage, "yes|no" ) + ["--use-colour"] + ( "should output be colourised" ) + | Opt( config.libIdentify ) + ["--libidentify"] + ( "report name and version according to libidentify standard" ) + | Opt( setWaitForKeypress, "never|start|exit|both" ) + ["--wait-for-keypress"] + ( "waits for a keypress before exiting" ) + | Opt( config.benchmarkSamples, "samples" ) + ["--benchmark-samples"] + ( "number of samples to collect (default: 100)" ) + | Opt( config.benchmarkResamples, "resamples" ) + ["--benchmark-resamples"] + ( "number of resamples for the bootstrap (default: 100000)" ) + | Opt( config.benchmarkConfidenceInterval, "confidence interval" ) + ["--benchmark-confidence-interval"] + ( "confidence interval for the bootstrap (between 0 and 1, default: 0.95)" ) + | Opt( config.benchmarkNoAnalysis ) + ["--benchmark-no-analysis"] + ( "perform only measurements; do not perform any analysis" ) + | Opt( config.benchmarkWarmupTime, "benchmarkWarmupTime" ) + ["--benchmark-warmup-time"] + ( "amount of time in milliseconds spent on warming up each test (default: 100)" ) + | Arg( config.testsOrTags, "test name|pattern|tags" ) + ( "which test or tests to use" ); + + return cli; + } + +} // end namespace Catch diff --git a/lib/Catch2/include/internal/catch_commandline.h b/lib/Catch2/include/internal/catch_commandline.h new file mode 100644 index 0000000000..b73cfa2ddb --- /dev/null +++ b/lib/Catch2/include/internal/catch_commandline.h @@ -0,0 +1,20 @@ +/* + * Created by Phil on 02/11/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED + +#include "catch_config.hpp" +#include "catch_clara.h" + +namespace Catch { + + clara::Parser makeCommandLineParser( ConfigData& config ); + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_common.cpp b/lib/Catch2/include/internal/catch_common.cpp new file mode 100644 index 0000000000..790acbe538 --- /dev/null +++ b/lib/Catch2/include/internal/catch_common.cpp @@ -0,0 +1,43 @@ +/* + * Created by Phil on 27/11/2013. + * Copyright 2013 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_common.h" +#include "catch_context.h" +#include "catch_interfaces_config.h" + +#include +#include + +namespace Catch { + + bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const noexcept { + return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0); + } + bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const noexcept { + // We can assume that the same file will usually have the same pointer. + // Thus, if the pointers are the same, there is no point in calling the strcmp + return line < other.line || ( line == other.line && file != other.file && (std::strcmp(file, other.file) < 0)); + } + + std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { +#ifndef __GNUG__ + os << info.file << '(' << info.line << ')'; +#else + os << info.file << ':' << info.line; +#endif + return os; + } + + std::string StreamEndStop::operator+() const { + return std::string(); + } + + NonCopyable::NonCopyable() = default; + NonCopyable::~NonCopyable() = default; + +} diff --git a/lib/Catch2/include/internal/catch_common.h b/lib/Catch2/include/internal/catch_common.h new file mode 100644 index 0000000000..5e097fbf83 --- /dev/null +++ b/lib/Catch2/include/internal/catch_common.h @@ -0,0 +1,92 @@ +/* + * Created by Phil on 29/10/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_COMMON_H_INCLUDED +#define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED + +#include "catch_compiler_capabilities.h" + +#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line +#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) +#ifdef CATCH_CONFIG_COUNTER +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) +#else +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) +#endif + +#include +#include +#include + +// We need a dummy global operator<< so we can bring it into Catch namespace later +struct Catch_global_namespace_dummy {}; +std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); + +namespace Catch { + + struct CaseSensitive { enum Choice { + Yes, + No + }; }; + + class NonCopyable { + NonCopyable( NonCopyable const& ) = delete; + NonCopyable( NonCopyable && ) = delete; + NonCopyable& operator = ( NonCopyable const& ) = delete; + NonCopyable& operator = ( NonCopyable && ) = delete; + + protected: + NonCopyable(); + virtual ~NonCopyable(); + }; + + struct SourceLineInfo { + + SourceLineInfo() = delete; + SourceLineInfo( char const* _file, std::size_t _line ) noexcept + : file( _file ), + line( _line ) + {} + + SourceLineInfo( SourceLineInfo const& other ) = default; + SourceLineInfo& operator = ( SourceLineInfo const& ) = default; + SourceLineInfo( SourceLineInfo&& ) noexcept = default; + SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; + + bool empty() const noexcept { return file[0] == '\0'; } + bool operator == ( SourceLineInfo const& other ) const noexcept; + bool operator < ( SourceLineInfo const& other ) const noexcept; + + char const* file; + std::size_t line; + }; + + std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); + + // Bring in operator<< from global namespace into Catch namespace + // This is necessary because the overload of operator<< above makes + // lookup stop at namespace Catch + using ::operator<<; + + // Use this in variadic streaming macros to allow + // >> +StreamEndStop + // as well as + // >> stuff +StreamEndStop + struct StreamEndStop { + std::string operator+() const; + }; + template + T const& operator + ( T const& value, StreamEndStop ) { + return value; + } +} + +#define CATCH_INTERNAL_LINEINFO \ + ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) + +#endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED + diff --git a/lib/Catch2/include/internal/catch_compiler_capabilities.h b/lib/Catch2/include/internal/catch_compiler_capabilities.h new file mode 100644 index 0000000000..9efda561e1 --- /dev/null +++ b/lib/Catch2/include/internal/catch_compiler_capabilities.h @@ -0,0 +1,377 @@ +/* + * Created by Phil on 15/04/2013. + * Copyright 2013 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED + +// Detect a number of compiler features - by compiler +// The following features are defined: +// +// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? +// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? +// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? +// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled? +// **************** +// Note to maintainers: if new toggles are added please document them +// in configuration.md, too +// **************** + +// In general each macro has a _NO_ form +// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. +// Many features, at point of detection, define an _INTERNAL_ macro, so they +// can be combined, en-mass, with the _NO_ forms later. + +#include "catch_platform.h" + +#ifdef __cplusplus + +# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) +# define CATCH_CPP14_OR_GREATER +# endif + +# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) +# define CATCH_CPP17_OR_GREATER +# endif + +#endif + +// Only GCC compiler should be used in this block, so other compilers trying to +// mask themselves as GCC should be ignored. +#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) + +# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) + +#endif + +#if defined(__clang__) + +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) + +// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug +// which results in calls to destructors being emitted for each temporary, +// without a matching initialization. In practice, this can result in something +// like `std::string::~string` being called on an uninitialized value. +// +// For example, this code will likely segfault under IBM XL: +// ``` +// REQUIRE(std::string("12") + "34" == "1234") +// ``` +// +// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. +# if !defined(__ibmxl__) && !defined(__CUDACC__) +# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */ +# endif + + +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ + _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") + +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) + +# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) + +# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) + +# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) + +#endif // __clang__ + + +//////////////////////////////////////////////////////////////////////////////// +// Assume that non-Windows platforms support posix signals by default +#if !defined(CATCH_PLATFORM_WINDOWS) + #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS +#endif + +//////////////////////////////////////////////////////////////////////////////// +// We know some environments not to support full POSIX signals +#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) + #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS +#endif + +#ifdef __OS400__ +# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS +# define CATCH_CONFIG_COLOUR_NONE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Android somehow still does not support std::to_string +#if defined(__ANDROID__) +# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING +# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Not all Windows environments support SEH properly +#if defined(__MINGW32__) +# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH +#endif + +//////////////////////////////////////////////////////////////////////////////// +// PS4 +#if defined(__ORBIS__) +# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Cygwin +#ifdef __CYGWIN__ + +// Required for some versions of Cygwin to declare gettimeofday +// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin +# define _BSD_SOURCE +// some versions of cygwin (most) do not support std::to_string. Use the libstd check. +// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813 +# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ + && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) + +# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING + +# endif +#endif // __CYGWIN__ + +//////////////////////////////////////////////////////////////////////////////// +// Visual C++ +#if defined(_MSC_VER) + +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) + + +// Universal Windows platform does not support SEH +// Or console colours (or console at all...) +# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) +# define CATCH_CONFIG_COLOUR_NONE +# else +# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH +# endif + +// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ +// _MSVC_TRADITIONAL == 0 means new conformant preprocessor +// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor +# if !defined(__clang__) // Handle Clang masquerading for msvc +# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) +# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +# endif // MSVC_TRADITIONAL +# endif // __clang__ + +#endif // _MSC_VER + +#if defined(_REENTRANT) || defined(_MSC_VER) +// Enable async processing, as -pthread is specified or no additional linking is required +# define CATCH_INTERNAL_CONFIG_USE_ASYNC +#endif // _MSC_VER + +//////////////////////////////////////////////////////////////////////////////// +// Check if we are compiled with -fno-exceptions or equivalent +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED +#endif + +//////////////////////////////////////////////////////////////////////////////// +// DJGPP +#ifdef __DJGPP__ +# define CATCH_INTERNAL_CONFIG_NO_WCHAR +#endif // __DJGPP__ + +//////////////////////////////////////////////////////////////////////////////// +// Embarcadero C++Build +#if defined(__BORLANDC__) + #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN +#endif + +//////////////////////////////////////////////////////////////////////////////// + +// Use of __COUNTER__ is suppressed during code analysis in +// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly +// handled by it. +// Otherwise all supported compilers support COUNTER macro, +// but user still might want to turn it off +#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) + #define CATCH_INTERNAL_CONFIG_COUNTER +#endif + + +//////////////////////////////////////////////////////////////////////////////// + +// RTX is a special version of Windows that is real time. +// This means that it is detected as Windows, but does not provide +// the same set of capabilities as real Windows does. +#if defined(UNDER_RTSS) || defined(RTX64_BUILD) + #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH + #define CATCH_INTERNAL_CONFIG_NO_ASYNC + #define CATCH_CONFIG_COLOUR_NONE +#endif + +#if !defined(_GLIBCXX_USE_C99_MATH_TR1) +#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER +#endif + +// Various stdlib support checks that require __has_include +#if defined(__has_include) + // Check if string_view is available and usable + #if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW + #endif + + // Check if optional is available and usable + # if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL + # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) + + // Check if byte is available and usable + # if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # include + # if __cpp_lib_byte > 0 + # define CATCH_INTERNAL_CONFIG_CPP17_BYTE + # endif + # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) + + // Check if variant is available and usable + # if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # if defined(__clang__) && (__clang_major__ < 8) + // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 + // fix should be in clang 8, workaround in libstdc++ 8.2 + # include + # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) + # define CATCH_CONFIG_NO_CPP17_VARIANT + # else + # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT + # endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) + # else + # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT + # endif // defined(__clang__) && (__clang_major__ < 8) + # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) +#endif // defined(__has_include) + + +#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) +# define CATCH_CONFIG_COUNTER +#endif +#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH) +# define CATCH_CONFIG_WINDOWS_SEH +#endif +// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. +#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) +# define CATCH_CONFIG_POSIX_SIGNALS +#endif +// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions. +#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR) +# define CATCH_CONFIG_WCHAR +#endif + +#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) +# define CATCH_CONFIG_CPP11_TO_STRING +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL) +# define CATCH_CONFIG_CPP17_OPTIONAL +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) +# define CATCH_CONFIG_CPP17_STRING_VIEW +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT) +# define CATCH_CONFIG_CPP17_VARIANT +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE) +# define CATCH_CONFIG_CPP17_BYTE +#endif + + +#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) +# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE +#endif + +#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE) +# define CATCH_CONFIG_NEW_CAPTURE +#endif + +#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) +# define CATCH_CONFIG_DISABLE_EXCEPTIONS +#endif + +#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN) +# define CATCH_CONFIG_POLYFILL_ISNAN +#endif + +#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) +# define CATCH_CONFIG_USE_ASYNC +#endif + +#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) +# define CATCH_CONFIG_ANDROID_LOGWRITE +#endif + +#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) +# define CATCH_CONFIG_GLOBAL_NEXTAFTER +#endif + + +// Even if we do not think the compiler has that warning, we still have +// to provide a macro that can be used by the code. +#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION +#endif +#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS +#endif + +// The goal of this macro is to avoid evaluation of the arguments, but +// still have the compiler warn on problems inside... +#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN) +# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) +#endif + +#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) +# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#elif defined(__clang__) && (__clang_major__ < 5) +# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#endif + +#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#endif + +#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) +#define CATCH_TRY if ((true)) +#define CATCH_CATCH_ALL if ((false)) +#define CATCH_CATCH_ANON(type) if ((false)) +#else +#define CATCH_TRY try +#define CATCH_CATCH_ALL catch (...) +#define CATCH_CATCH_ANON(type) catch (type) +#endif + +#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) +#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#endif + +#endif // TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED + diff --git a/lib/Catch2/include/internal/catch_config.cpp b/lib/Catch2/include/internal/catch_config.cpp new file mode 100644 index 0000000000..252bec62ef --- /dev/null +++ b/lib/Catch2/include/internal/catch_config.cpp @@ -0,0 +1,86 @@ +/* + * Created by Martin on 19/07/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_config.hpp" +#include "catch_enforce.h" +#include "catch_stringref.h" + +namespace Catch { + + Config::Config( ConfigData const& data ) + : m_data( data ), + m_stream( openStream() ) + { + // We need to trim filter specs to avoid trouble with superfluous + // whitespace (esp. important for bdd macros, as those are manually + // aligned with whitespace). + + for (auto& elem : m_data.testsOrTags) { + elem = trim(elem); + } + for (auto& elem : m_data.sectionsToRun) { + elem = trim(elem); + } + + TestSpecParser parser(ITagAliasRegistry::get()); + if (!m_data.testsOrTags.empty()) { + m_hasTestFilters = true; + for (auto const& testOrTags : m_data.testsOrTags) { + parser.parse(testOrTags); + } + } + m_testSpec = parser.testSpec(); + } + + std::string const& Config::getFilename() const { + return m_data.outputFilename ; + } + + bool Config::listTests() const { return m_data.listTests; } + bool Config::listTestNamesOnly() const { return m_data.listTestNamesOnly; } + bool Config::listTags() const { return m_data.listTags; } + bool Config::listReporters() const { return m_data.listReporters; } + + std::string Config::getProcessName() const { return m_data.processName; } + std::string const& Config::getReporterName() const { return m_data.reporterName; } + + std::vector const& Config::getTestsOrTags() const { return m_data.testsOrTags; } + std::vector const& Config::getSectionsToRun() const { return m_data.sectionsToRun; } + + TestSpec const& Config::testSpec() const { return m_testSpec; } + bool Config::hasTestFilters() const { return m_hasTestFilters; } + + bool Config::showHelp() const { return m_data.showHelp; } + + // IConfig interface + bool Config::allowThrows() const { return !m_data.noThrow; } + std::ostream& Config::stream() const { return m_stream->stream(); } + std::string Config::name() const { return m_data.name.empty() ? m_data.processName : m_data.name; } + bool Config::includeSuccessfulResults() const { return m_data.showSuccessfulTests; } + bool Config::warnAboutMissingAssertions() const { return !!(m_data.warnings & WarnAbout::NoAssertions); } + bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); } + ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; } + double Config::minDuration() const { return m_data.minDuration; } + RunTests::InWhatOrder Config::runOrder() const { return m_data.runOrder; } + unsigned int Config::rngSeed() const { return m_data.rngSeed; } + UseColour::YesOrNo Config::useColour() const { return m_data.useColour; } + bool Config::shouldDebugBreak() const { return m_data.shouldDebugBreak; } + int Config::abortAfter() const { return m_data.abortAfter; } + bool Config::showInvisibles() const { return m_data.showInvisibles; } + Verbosity Config::verbosity() const { return m_data.verbosity; } + + bool Config::benchmarkNoAnalysis() const { return m_data.benchmarkNoAnalysis; } + int Config::benchmarkSamples() const { return m_data.benchmarkSamples; } + double Config::benchmarkConfidenceInterval() const { return m_data.benchmarkConfidenceInterval; } + unsigned int Config::benchmarkResamples() const { return m_data.benchmarkResamples; } + std::chrono::milliseconds Config::benchmarkWarmupTime() const { return std::chrono::milliseconds(m_data.benchmarkWarmupTime); } + + IStream const* Config::openStream() { + return Catch::makeStream(m_data.outputFilename); + } + +} // end namespace Catch diff --git a/lib/Catch2/include/internal/catch_config.hpp b/lib/Catch2/include/internal/catch_config.hpp new file mode 100644 index 0000000000..fd7de5b2d4 --- /dev/null +++ b/lib/Catch2/include/internal/catch_config.hpp @@ -0,0 +1,133 @@ +/* + * Created by Phil on 08/11/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED + +#include "catch_test_spec_parser.h" +#include "catch_interfaces_config.h" + +// Libstdc++ doesn't like incomplete classes for unique_ptr +#include "catch_stream.h" + +#include +#include +#include + +#ifndef CATCH_CONFIG_CONSOLE_WIDTH +#define CATCH_CONFIG_CONSOLE_WIDTH 80 +#endif + +namespace Catch { + + struct IStream; + + struct ConfigData { + bool listTests = false; + bool listTags = false; + bool listReporters = false; + bool listTestNamesOnly = false; + + bool showSuccessfulTests = false; + bool shouldDebugBreak = false; + bool noThrow = false; + bool showHelp = false; + bool showInvisibles = false; + bool filenamesAsTags = false; + bool libIdentify = false; + + int abortAfter = -1; + unsigned int rngSeed = 0; + + bool benchmarkNoAnalysis = false; + unsigned int benchmarkSamples = 100; + double benchmarkConfidenceInterval = 0.95; + unsigned int benchmarkResamples = 100000; + std::chrono::milliseconds::rep benchmarkWarmupTime = 100; + + Verbosity verbosity = Verbosity::Normal; + WarnAbout::What warnings = WarnAbout::Nothing; + ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter; + double minDuration = -1; + RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder; + UseColour::YesOrNo useColour = UseColour::Auto; + WaitForKeypress::When waitForKeypress = WaitForKeypress::Never; + + std::string outputFilename; + std::string name; + std::string processName; +#ifndef CATCH_CONFIG_DEFAULT_REPORTER +#define CATCH_CONFIG_DEFAULT_REPORTER "console" +#endif + std::string reporterName = CATCH_CONFIG_DEFAULT_REPORTER; +#undef CATCH_CONFIG_DEFAULT_REPORTER + + std::vector testsOrTags; + std::vector sectionsToRun; + }; + + + class Config : public IConfig { + public: + + Config() = default; + Config( ConfigData const& data ); + virtual ~Config() = default; + + std::string const& getFilename() const; + + bool listTests() const; + bool listTestNamesOnly() const; + bool listTags() const; + bool listReporters() const; + + std::string getProcessName() const; + std::string const& getReporterName() const; + + std::vector const& getTestsOrTags() const override; + std::vector const& getSectionsToRun() const override; + + TestSpec const& testSpec() const override; + bool hasTestFilters() const override; + + bool showHelp() const; + + // IConfig interface + bool allowThrows() const override; + std::ostream& stream() const override; + std::string name() const override; + bool includeSuccessfulResults() const override; + bool warnAboutMissingAssertions() const override; + bool warnAboutNoTests() const override; + ShowDurations::OrNot showDurations() const override; + double minDuration() const override; + RunTests::InWhatOrder runOrder() const override; + unsigned int rngSeed() const override; + UseColour::YesOrNo useColour() const override; + bool shouldDebugBreak() const override; + int abortAfter() const override; + bool showInvisibles() const override; + Verbosity verbosity() const override; + bool benchmarkNoAnalysis() const override; + int benchmarkSamples() const override; + double benchmarkConfidenceInterval() const override; + unsigned int benchmarkResamples() const override; + std::chrono::milliseconds benchmarkWarmupTime() const override; + + private: + + IStream const* openStream(); + ConfigData m_data; + + std::unique_ptr m_stream; + TestSpec m_testSpec; + bool m_hasTestFilters = false; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_config_uncaught_exceptions.hpp b/lib/Catch2/include/internal/catch_config_uncaught_exceptions.hpp new file mode 100644 index 0000000000..eac9078eb4 --- /dev/null +++ b/lib/Catch2/include/internal/catch_config_uncaught_exceptions.hpp @@ -0,0 +1,44 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +/** \file + * Wrapper for UNCAUGHT_EXCEPTIONS configuration option + * + * For some functionality, Catch2 requires to know whether there is + * an active exception. Because `std::uncaught_exception` is deprecated + * in C++17, we want to use `std::uncaught_exceptions` if possible. + */ + +#ifndef CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP +#define CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP + +#if defined(_MSC_VER) +# if _MSC_VER >= 1900 // Visual Studio 2015 or newer +# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +# endif +#endif + + +#include + +#if defined(__cpp_lib_uncaught_exceptions) \ + && !defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) + +# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +#endif // __cpp_lib_uncaught_exceptions + + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) \ + && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) \ + && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) + +# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +#endif + + +#endif // CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP diff --git a/lib/Catch2/include/internal/catch_console_colour.cpp b/lib/Catch2/include/internal/catch_console_colour.cpp new file mode 100644 index 0000000000..de0fff4318 --- /dev/null +++ b/lib/Catch2/include/internal/catch_console_colour.cpp @@ -0,0 +1,243 @@ +/* + * Created by Phil on 25/2/2012. + * Copyright 2012 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif + + +#include "catch_console_colour.h" +#include "catch_enforce.h" +#include "catch_errno_guard.h" +#include "catch_interfaces_config.h" +#include "catch_stream.h" +#include "catch_context.h" +#include "catch_platform.h" +#include "catch_debugger.h" +#include "catch_windows_h_proxy.h" + +#include + +namespace Catch { + namespace { + + struct IColourImpl { + virtual ~IColourImpl() = default; + virtual void use( Colour::Code _colourCode ) = 0; + }; + + struct NoColourImpl : IColourImpl { + void use( Colour::Code ) override {} + + static IColourImpl* instance() { + static NoColourImpl s_instance; + return &s_instance; + } + }; + + } // anon namespace +} // namespace Catch + +#if !defined( CATCH_CONFIG_COLOUR_NONE ) && !defined( CATCH_CONFIG_COLOUR_WINDOWS ) && !defined( CATCH_CONFIG_COLOUR_ANSI ) +# ifdef CATCH_PLATFORM_WINDOWS +# define CATCH_CONFIG_COLOUR_WINDOWS +# else +# define CATCH_CONFIG_COLOUR_ANSI +# endif +#endif + + +#if defined ( CATCH_CONFIG_COLOUR_WINDOWS ) ///////////////////////////////////////// + +namespace Catch { +namespace { + + class Win32ColourImpl : public IColourImpl { + public: + Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) ) + { + CONSOLE_SCREEN_BUFFER_INFO csbiInfo; + GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo ); + originalForegroundAttributes = csbiInfo.wAttributes & ~( BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY ); + originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY ); + } + + void use( Colour::Code _colourCode ) override { + switch( _colourCode ) { + case Colour::None: return setTextAttribute( originalForegroundAttributes ); + case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); + case Colour::Red: return setTextAttribute( FOREGROUND_RED ); + case Colour::Green: return setTextAttribute( FOREGROUND_GREEN ); + case Colour::Blue: return setTextAttribute( FOREGROUND_BLUE ); + case Colour::Cyan: return setTextAttribute( FOREGROUND_BLUE | FOREGROUND_GREEN ); + case Colour::Yellow: return setTextAttribute( FOREGROUND_RED | FOREGROUND_GREEN ); + case Colour::Grey: return setTextAttribute( 0 ); + + case Colour::LightGrey: return setTextAttribute( FOREGROUND_INTENSITY ); + case Colour::BrightRed: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED ); + case Colour::BrightGreen: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN ); + case Colour::BrightWhite: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); + case Colour::BrightYellow: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN ); + + case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" ); + + default: + CATCH_ERROR( "Unknown colour requested" ); + } + } + + private: + void setTextAttribute( WORD _textAttribute ) { + SetConsoleTextAttribute( stdoutHandle, _textAttribute | originalBackgroundAttributes ); + } + HANDLE stdoutHandle; + WORD originalForegroundAttributes; + WORD originalBackgroundAttributes; + }; + + IColourImpl* platformColourInstance() { + static Win32ColourImpl s_instance; + + IConfigPtr config = getCurrentContext().getConfig(); + UseColour::YesOrNo colourMode = config + ? config->useColour() + : UseColour::Auto; + if( colourMode == UseColour::Auto ) + colourMode = UseColour::Yes; + return colourMode == UseColour::Yes + ? &s_instance + : NoColourImpl::instance(); + } + +} // end anon namespace +} // end namespace Catch + +#elif defined( CATCH_CONFIG_COLOUR_ANSI ) ////////////////////////////////////// + +#include + +namespace Catch { +namespace { + + // use POSIX/ ANSI console terminal codes + // Thanks to Adam Strzelecki for original contribution + // (http://github.com/nanoant) + // https://github.com/philsquared/Catch/pull/131 + class PosixColourImpl : public IColourImpl { + public: + void use( Colour::Code _colourCode ) override { + switch( _colourCode ) { + case Colour::None: + case Colour::White: return setColour( "[0m" ); + case Colour::Red: return setColour( "[0;31m" ); + case Colour::Green: return setColour( "[0;32m" ); + case Colour::Blue: return setColour( "[0;34m" ); + case Colour::Cyan: return setColour( "[0;36m" ); + case Colour::Yellow: return setColour( "[0;33m" ); + case Colour::Grey: return setColour( "[1;30m" ); + + case Colour::LightGrey: return setColour( "[0;37m" ); + case Colour::BrightRed: return setColour( "[1;31m" ); + case Colour::BrightGreen: return setColour( "[1;32m" ); + case Colour::BrightWhite: return setColour( "[1;37m" ); + case Colour::BrightYellow: return setColour( "[1;33m" ); + + case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" ); + default: CATCH_INTERNAL_ERROR( "Unknown colour requested" ); + } + } + static IColourImpl* instance() { + static PosixColourImpl s_instance; + return &s_instance; + } + + private: + void setColour( const char* _escapeCode ) { + getCurrentContext().getConfig()->stream() + << '\033' << _escapeCode; + } + }; + + bool useColourOnPlatform() { + return +#if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE) + !isDebuggerActive() && +#endif +#if !(defined(__DJGPP__) && defined(__STRICT_ANSI__)) + isatty(STDOUT_FILENO) +#else + false +#endif + ; + } + IColourImpl* platformColourInstance() { + ErrnoGuard guard; + IConfigPtr config = getCurrentContext().getConfig(); + UseColour::YesOrNo colourMode = config + ? config->useColour() + : UseColour::Auto; + if( colourMode == UseColour::Auto ) + colourMode = useColourOnPlatform() + ? UseColour::Yes + : UseColour::No; + return colourMode == UseColour::Yes + ? PosixColourImpl::instance() + : NoColourImpl::instance(); + } + +} // end anon namespace +} // end namespace Catch + +#else // not Windows or ANSI /////////////////////////////////////////////// + +namespace Catch { + + static IColourImpl* platformColourInstance() { return NoColourImpl::instance(); } + +} // end namespace Catch + +#endif // Windows/ ANSI/ None + +namespace Catch { + + Colour::Colour( Code _colourCode ) { use( _colourCode ); } + Colour::Colour( Colour&& other ) noexcept { + m_moved = other.m_moved; + other.m_moved = true; + } + Colour& Colour::operator=( Colour&& other ) noexcept { + m_moved = other.m_moved; + other.m_moved = true; + return *this; + } + + Colour::~Colour(){ if( !m_moved ) use( None ); } + + void Colour::use( Code _colourCode ) { + static IColourImpl* impl = platformColourInstance(); + // Strictly speaking, this cannot possibly happen. + // However, under some conditions it does happen (see #1626), + // and this change is small enough that we can let practicality + // triumph over purity in this case. + if (impl != nullptr) { + impl->use( _colourCode ); + } + } + + std::ostream& operator << ( std::ostream& os, Colour const& ) { + return os; + } + +} // end namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif + diff --git a/lib/Catch2/include/internal/catch_console_colour.h b/lib/Catch2/include/internal/catch_console_colour.h new file mode 100644 index 0000000000..ec653424e4 --- /dev/null +++ b/lib/Catch2/include/internal/catch_console_colour.h @@ -0,0 +1,69 @@ +/* + * Created by Phil on 25/2/2012. + * Copyright 2012 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED + +#include "catch_common.h" + +namespace Catch { + + struct Colour { + enum Code { + None = 0, + + White, + Red, + Green, + Blue, + Cyan, + Yellow, + Grey, + + Bright = 0x10, + + BrightRed = Bright | Red, + BrightGreen = Bright | Green, + LightGrey = Bright | Grey, + BrightWhite = Bright | White, + BrightYellow = Bright | Yellow, + + // By intention + FileName = LightGrey, + Warning = BrightYellow, + ResultError = BrightRed, + ResultSuccess = BrightGreen, + ResultExpectedFailure = Warning, + + Error = BrightRed, + Success = Green, + + OriginalExpression = Cyan, + ReconstructedExpression = BrightYellow, + + SecondaryText = LightGrey, + Headers = White + }; + + // Use constructed object for RAII guard + Colour( Code _colourCode ); + Colour( Colour&& other ) noexcept; + Colour& operator=( Colour&& other ) noexcept; + ~Colour(); + + // Use static method for one-shot changes + static void use( Code _colourCode ); + + private: + bool m_moved = false; + }; + + std::ostream& operator << ( std::ostream& os, Colour const& ); + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_context.cpp b/lib/Catch2/include/internal/catch_context.cpp new file mode 100644 index 0000000000..e444a6b3f1 --- /dev/null +++ b/lib/Catch2/include/internal/catch_context.cpp @@ -0,0 +1,70 @@ +/* + * Created by Phil on 31/12/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#include "catch_context.h" +#include "catch_common.h" +#include "catch_random_number_generator.h" + +namespace Catch { + + class Context : public IMutableContext, NonCopyable { + + public: // IContext + IResultCapture* getResultCapture() override { + return m_resultCapture; + } + IRunner* getRunner() override { + return m_runner; + } + + IConfigPtr const& getConfig() const override { + return m_config; + } + + ~Context() override; + + public: // IMutableContext + void setResultCapture( IResultCapture* resultCapture ) override { + m_resultCapture = resultCapture; + } + void setRunner( IRunner* runner ) override { + m_runner = runner; + } + void setConfig( IConfigPtr const& config ) override { + m_config = config; + } + + friend IMutableContext& getCurrentMutableContext(); + + private: + IConfigPtr m_config; + IRunner* m_runner = nullptr; + IResultCapture* m_resultCapture = nullptr; + }; + + IMutableContext *IMutableContext::currentContext = nullptr; + + void IMutableContext::createContext() + { + currentContext = new Context(); + } + + void cleanUpContext() { + delete IMutableContext::currentContext; + IMutableContext::currentContext = nullptr; + } + IContext::~IContext() = default; + IMutableContext::~IMutableContext() = default; + Context::~Context() = default; + + + SimplePcg32& rng() { + static SimplePcg32 s_rng; + return s_rng; + } + +} diff --git a/lib/Catch2/include/internal/catch_context.h b/lib/Catch2/include/internal/catch_context.h new file mode 100644 index 0000000000..c579c3992f --- /dev/null +++ b/lib/Catch2/include/internal/catch_context.h @@ -0,0 +1,64 @@ +/* + * Created by Phil on 31/12/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED +#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED + +#include + +namespace Catch { + + struct IResultCapture; + struct IRunner; + struct IConfig; + struct IMutableContext; + + using IConfigPtr = std::shared_ptr; + + struct IContext + { + virtual ~IContext(); + + virtual IResultCapture* getResultCapture() = 0; + virtual IRunner* getRunner() = 0; + virtual IConfigPtr const& getConfig() const = 0; + }; + + struct IMutableContext : IContext + { + virtual ~IMutableContext(); + virtual void setResultCapture( IResultCapture* resultCapture ) = 0; + virtual void setRunner( IRunner* runner ) = 0; + virtual void setConfig( IConfigPtr const& config ) = 0; + + private: + static IMutableContext *currentContext; + friend IMutableContext& getCurrentMutableContext(); + friend void cleanUpContext(); + static void createContext(); + }; + + inline IMutableContext& getCurrentMutableContext() + { + if( !IMutableContext::currentContext ) + IMutableContext::createContext(); + // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) + return *IMutableContext::currentContext; + } + + inline IContext& getCurrentContext() + { + return getCurrentMutableContext(); + } + + void cleanUpContext(); + + class SimplePcg32; + SimplePcg32& rng(); +} + +#endif // TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_debug_console.cpp b/lib/Catch2/include/internal/catch_debug_console.cpp new file mode 100644 index 0000000000..a341d81089 --- /dev/null +++ b/lib/Catch2/include/internal/catch_debug_console.cpp @@ -0,0 +1,41 @@ +/* + * Created by Martin on 29/08/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + +#include "catch_debug_console.h" +#include "catch_compiler_capabilities.h" +#include "catch_stream.h" +#include "catch_platform.h" +#include "catch_windows_h_proxy.h" + +#if defined(CATCH_CONFIG_ANDROID_LOGWRITE) +#include + + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + __android_log_write( ANDROID_LOG_DEBUG, "Catch", text.c_str() ); + } + } + +#elif defined(CATCH_PLATFORM_WINDOWS) + + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + ::OutputDebugStringA( text.c_str() ); + } + } + +#else + + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + // !TBD: Need a version for Mac/ XCode and other IDEs + Catch::cout() << text; + } + } + +#endif // Platform diff --git a/lib/Catch2/include/internal/catch_debug_console.h b/lib/Catch2/include/internal/catch_debug_console.h new file mode 100644 index 0000000000..2c229a8348 --- /dev/null +++ b/lib/Catch2/include/internal/catch_debug_console.h @@ -0,0 +1,17 @@ +/* + * Created by Martin on 29/08/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ +#ifndef TWOBLUECUBES_CATCH_DEBUG_CONSOLE_H_INCLUDED +#define TWOBLUECUBES_CATCH_DEBUG_CONSOLE_H_INCLUDED + +#include + +namespace Catch { + void writeToDebugConsole( std::string const& text ); +} + +#endif // TWOBLUECUBES_CATCH_DEBUG_CONSOLE_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_debugger.cpp b/lib/Catch2/include/internal/catch_debugger.cpp new file mode 100644 index 0000000000..d4f7478010 --- /dev/null +++ b/lib/Catch2/include/internal/catch_debugger.cpp @@ -0,0 +1,122 @@ +/* + * Created by Phil on 27/12/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + +#include "catch_debugger.h" +#include "catch_errno_guard.h" +#include "catch_stream.h" +#include "catch_platform.h" + +#if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE) + +# include +# include +# include +# include +# include + +#ifdef __apple_build_version__ + // These headers will only compile with AppleClang (XCode) + // For other compilers (Clang, GCC, ... ) we need to exclude them +# include +#endif + + namespace Catch { + #ifdef __apple_build_version__ + // The following function is taken directly from the following technical note: + // https://developer.apple.com/library/archive/qa/qa1361/_index.html + + // Returns true if the current process is being debugged (either + // running under the debugger or has a debugger attached post facto). + bool isDebuggerActive(){ + int mib[4]; + struct kinfo_proc info; + std::size_t size; + + // Initialize the flags so that, if sysctl fails for some bizarre + // reason, we get a predictable result. + + info.kp_proc.p_flag = 0; + + // Initialize mib, which tells sysctl the info we want, in this case + // we're looking for information about a specific process ID. + + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = getpid(); + + // Call sysctl. + + size = sizeof(info); + if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, nullptr, 0) != 0 ) { + Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl; + return false; + } + + // We're being debugged if the P_TRACED flag is set. + + return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); + } + #else + bool isDebuggerActive() { + // We need to find another way to determine this for non-appleclang compilers on macOS + return false; + } + #endif + } // namespace Catch + +#elif defined(CATCH_PLATFORM_LINUX) + #include + #include + + namespace Catch{ + // The standard POSIX way of detecting a debugger is to attempt to + // ptrace() the process, but this needs to be done from a child and not + // this process itself to still allow attaching to this process later + // if wanted, so is rather heavy. Under Linux we have the PID of the + // "debugger" (which doesn't need to be gdb, of course, it could also + // be strace, for example) in /proc/$PID/status, so just get it from + // there instead. + bool isDebuggerActive(){ + // Libstdc++ has a bug, where std::ifstream sets errno to 0 + // This way our users can properly assert over errno values + ErrnoGuard guard; + std::ifstream in("/proc/self/status"); + for( std::string line; std::getline(in, line); ) { + static const int PREFIX_LEN = 11; + if( line.compare(0, PREFIX_LEN, "TracerPid:\t") == 0 ) { + // We're traced if the PID is not 0 and no other PID starts + // with 0 digit, so it's enough to check for just a single + // character. + return line.length() > PREFIX_LEN && line[PREFIX_LEN] != '0'; + } + } + + return false; + } + } // namespace Catch +#elif defined(_MSC_VER) + extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); + namespace Catch { + bool isDebuggerActive() { + return IsDebuggerPresent() != 0; + } + } +#elif defined(__MINGW32__) + extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); + namespace Catch { + bool isDebuggerActive() { + return IsDebuggerPresent() != 0; + } + } +#else + namespace Catch { + bool isDebuggerActive() { return false; } + } +#endif // Platform diff --git a/lib/Catch2/include/internal/catch_debugger.h b/lib/Catch2/include/internal/catch_debugger.h new file mode 100644 index 0000000000..a0148aa88f --- /dev/null +++ b/lib/Catch2/include/internal/catch_debugger.h @@ -0,0 +1,65 @@ +/* + * Created by Phil on 3/12/2013. + * Copyright 2013 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ +#ifndef TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED +#define TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED + +#include "catch_platform.h" + +namespace Catch { + bool isDebuggerActive(); +} + +#ifdef CATCH_PLATFORM_MAC + + #if defined(__i386__) || defined(__x86_64__) + #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ + #elif defined(__aarch64__) + #define CATCH_TRAP() __asm__(".inst 0xd4200000") + #endif + +#elif defined(CATCH_PLATFORM_IPHONE) + + // use inline assembler + #if defined(__i386__) || defined(__x86_64__) + #define CATCH_TRAP() __asm__("int $3") + #elif defined(__aarch64__) + #define CATCH_TRAP() __asm__(".inst 0xd4200000") + #elif defined(__arm__) && !defined(__thumb__) + #define CATCH_TRAP() __asm__(".inst 0xe7f001f0") + #elif defined(__arm__) && defined(__thumb__) + #define CATCH_TRAP() __asm__(".inst 0xde01") + #endif + +#elif defined(CATCH_PLATFORM_LINUX) + // If we can use inline assembler, do it because this allows us to break + // directly at the location of the failing check instead of breaking inside + // raise() called from it, i.e. one stack frame below. + #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64)) + #define CATCH_TRAP() asm volatile ("int $3") /* NOLINT */ + #else // Fall back to the generic way. + #include + + #define CATCH_TRAP() raise(SIGTRAP) + #endif +#elif defined(_MSC_VER) + #define CATCH_TRAP() __debugbreak() +#elif defined(__MINGW32__) + extern "C" __declspec(dllimport) void __stdcall DebugBreak(); + #define CATCH_TRAP() DebugBreak() +#endif + +#ifndef CATCH_BREAK_INTO_DEBUGGER + #ifdef CATCH_TRAP + #define CATCH_BREAK_INTO_DEBUGGER() []{ if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } }() + #else + #define CATCH_BREAK_INTO_DEBUGGER() []{}() + #endif +#endif + +#endif // TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_decomposer.cpp b/lib/Catch2/include/internal/catch_decomposer.cpp new file mode 100644 index 0000000000..8c19629bba --- /dev/null +++ b/lib/Catch2/include/internal/catch_decomposer.cpp @@ -0,0 +1,24 @@ +/* + * Created by Phil Nash on 8/8/2017. + * Copyright 2017 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_decomposer.h" +#include "catch_config.hpp" + +namespace Catch { + + ITransientExpression::~ITransientExpression() = default; + + void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) { + if( lhs.size() + rhs.size() < 40 && + lhs.find('\n') == std::string::npos && + rhs.find('\n') == std::string::npos ) + os << lhs << " " << op << " " << rhs; + else + os << lhs << "\n" << op << "\n" << rhs; + } +} diff --git a/lib/Catch2/include/internal/catch_decomposer.h b/lib/Catch2/include/internal/catch_decomposer.h new file mode 100644 index 0000000000..9320c4ddf8 --- /dev/null +++ b/lib/Catch2/include/internal/catch_decomposer.h @@ -0,0 +1,259 @@ +/* + * Created by Phil Nash on 8/8/2017. + * Copyright 2017 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_DECOMPOSER_H_INCLUDED +#define TWOBLUECUBES_CATCH_DECOMPOSER_H_INCLUDED + +#include "catch_tostring.h" +#include "catch_stringref.h" +#include "catch_meta.hpp" + +#include + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4389) // '==' : signed/unsigned mismatch +#pragma warning(disable:4018) // more "signed/unsigned mismatch" +#pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform) +#pragma warning(disable:4180) // qualifier applied to function type has no meaning +#pragma warning(disable:4800) // Forcing result to true or false +#endif + +namespace Catch { + + struct ITransientExpression { + auto isBinaryExpression() const -> bool { return m_isBinaryExpression; } + auto getResult() const -> bool { return m_result; } + virtual void streamReconstructedExpression( std::ostream &os ) const = 0; + + ITransientExpression( bool isBinaryExpression, bool result ) + : m_isBinaryExpression( isBinaryExpression ), + m_result( result ) + {} + + // We don't actually need a virtual destructor, but many static analysers + // complain if it's not here :-( + virtual ~ITransientExpression(); + + bool m_isBinaryExpression; + bool m_result; + + }; + + void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ); + + template + class BinaryExpr : public ITransientExpression { + LhsT m_lhs; + StringRef m_op; + RhsT m_rhs; + + void streamReconstructedExpression( std::ostream &os ) const override { + formatReconstructedExpression + ( os, Catch::Detail::stringify( m_lhs ), m_op, Catch::Detail::stringify( m_rhs ) ); + } + + public: + BinaryExpr( bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs ) + : ITransientExpression{ true, comparisonResult }, + m_lhs( lhs ), + m_op( op ), + m_rhs( rhs ) + {} + + template + auto operator && ( T ) const -> BinaryExpr const { + static_assert(always_false::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template + auto operator || ( T ) const -> BinaryExpr const { + static_assert(always_false::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template + auto operator == ( T ) const -> BinaryExpr const { + static_assert(always_false::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template + auto operator != ( T ) const -> BinaryExpr const { + static_assert(always_false::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template + auto operator > ( T ) const -> BinaryExpr const { + static_assert(always_false::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template + auto operator < ( T ) const -> BinaryExpr const { + static_assert(always_false::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template + auto operator >= ( T ) const -> BinaryExpr const { + static_assert(always_false::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template + auto operator <= ( T ) const -> BinaryExpr const { + static_assert(always_false::value, + "chained comparisons are not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + }; + + template + class UnaryExpr : public ITransientExpression { + LhsT m_lhs; + + void streamReconstructedExpression( std::ostream &os ) const override { + os << Catch::Detail::stringify( m_lhs ); + } + + public: + explicit UnaryExpr( LhsT lhs ) + : ITransientExpression{ false, static_cast(lhs) }, + m_lhs( lhs ) + {} + }; + + + // Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int) + template + auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return static_cast(lhs == rhs); } + template + auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast( rhs ); } + template + auto compareEqual( T* const& lhs, long rhs ) -> bool { return lhs == reinterpret_cast( rhs ); } + template + auto compareEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) == rhs; } + template + auto compareEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) == rhs; } + + template + auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return static_cast(lhs != rhs); } + template + auto compareNotEqual( T* const& lhs, int rhs ) -> bool { return lhs != reinterpret_cast( rhs ); } + template + auto compareNotEqual( T* const& lhs, long rhs ) -> bool { return lhs != reinterpret_cast( rhs ); } + template + auto compareNotEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) != rhs; } + template + auto compareNotEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) != rhs; } + + + template + class ExprLhs { + LhsT m_lhs; + public: + explicit ExprLhs( LhsT lhs ) : m_lhs( lhs ) {} + + template + auto operator == ( RhsT const& rhs ) -> BinaryExpr const { + return { compareEqual( m_lhs, rhs ), m_lhs, "==", rhs }; + } + auto operator == ( bool rhs ) -> BinaryExpr const { + return { m_lhs == rhs, m_lhs, "==", rhs }; + } + + template + auto operator != ( RhsT const& rhs ) -> BinaryExpr const { + return { compareNotEqual( m_lhs, rhs ), m_lhs, "!=", rhs }; + } + auto operator != ( bool rhs ) -> BinaryExpr const { + return { m_lhs != rhs, m_lhs, "!=", rhs }; + } + + template + auto operator > ( RhsT const& rhs ) -> BinaryExpr const { + return { static_cast(m_lhs > rhs), m_lhs, ">", rhs }; + } + template + auto operator < ( RhsT const& rhs ) -> BinaryExpr const { + return { static_cast(m_lhs < rhs), m_lhs, "<", rhs }; + } + template + auto operator >= ( RhsT const& rhs ) -> BinaryExpr const { + return { static_cast(m_lhs >= rhs), m_lhs, ">=", rhs }; + } + template + auto operator <= ( RhsT const& rhs ) -> BinaryExpr const { + return { static_cast(m_lhs <= rhs), m_lhs, "<=", rhs }; + } + template + auto operator | (RhsT const& rhs) -> BinaryExpr const { + return { static_cast(m_lhs | rhs), m_lhs, "|", rhs }; + } + template + auto operator & (RhsT const& rhs) -> BinaryExpr const { + return { static_cast(m_lhs & rhs), m_lhs, "&", rhs }; + } + template + auto operator ^ (RhsT const& rhs) -> BinaryExpr const { + return { static_cast(m_lhs ^ rhs), m_lhs, "^", rhs }; + } + + template + auto operator && ( RhsT const& ) -> BinaryExpr const { + static_assert(always_false::value, + "operator&& is not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + template + auto operator || ( RhsT const& ) -> BinaryExpr const { + static_assert(always_false::value, + "operator|| is not supported inside assertions, " + "wrap the expression inside parentheses, or decompose it"); + } + + auto makeUnaryExpr() const -> UnaryExpr { + return UnaryExpr{ m_lhs }; + } + }; + + void handleExpression( ITransientExpression const& expr ); + + template + void handleExpression( ExprLhs const& expr ) { + handleExpression( expr.makeUnaryExpr() ); + } + + struct Decomposer { + template + auto operator <= ( T const& lhs ) -> ExprLhs { + return ExprLhs{ lhs }; + } + + auto operator <=( bool value ) -> ExprLhs { + return ExprLhs{ value }; + } + }; + +} // end namespace Catch + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#endif // TWOBLUECUBES_CATCH_DECOMPOSER_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_default_main.hpp b/lib/Catch2/include/internal/catch_default_main.hpp new file mode 100644 index 0000000000..aab5cba3ea --- /dev/null +++ b/lib/Catch2/include/internal/catch_default_main.hpp @@ -0,0 +1,47 @@ +/* + * Created by Phil on 20/05/2011. + * Copyright 2011 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_DEFAULT_MAIN_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_DEFAULT_MAIN_HPP_INCLUDED + +#include "catch_session.h" +#include "catch_platform.h" + +#ifndef __OBJC__ + +#if defined(CATCH_CONFIG_WCHAR) && defined(CATCH_PLATFORM_WINDOWS) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN) +// Standard C/C++ Win32 Unicode wmain entry point +extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) { +#else +// Standard C/C++ main entry point +int main (int argc, char * argv[]) { +#endif + + return Catch::Session().run( argc, argv ); +} + +#else // __OBJC__ + +// Objective-C entry point +int main (int argc, char * const argv[]) { +#if !CATCH_ARC_ENABLED + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; +#endif + + Catch::registerTestMethods(); + int result = Catch::Session().run( argc, (char**)argv ); + +#if !CATCH_ARC_ENABLED + [pool drain]; +#endif + + return result; +} + +#endif // __OBJC__ + +#endif // TWOBLUECUBES_CATCH_DEFAULT_MAIN_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_enforce.cpp b/lib/Catch2/include/internal/catch_enforce.cpp new file mode 100644 index 0000000000..903d43be23 --- /dev/null +++ b/lib/Catch2/include/internal/catch_enforce.cpp @@ -0,0 +1,40 @@ +/* + * Created by Martin on 03/09/2018. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_enforce.h" + +#include + + +namespace Catch { +#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER) + [[noreturn]] + void throw_exception(std::exception const& e) { + Catch::cerr() << "Catch will terminate because it needed to throw an exception.\n" + << "The message was: " << e.what() << '\n'; + std::terminate(); + } +#endif + + [[noreturn]] + void throw_logic_error(std::string const& msg) { + throw_exception(std::logic_error(msg)); + } + + [[noreturn]] + void throw_domain_error(std::string const& msg) { + throw_exception(std::domain_error(msg)); + } + + [[noreturn]] + void throw_runtime_error(std::string const& msg) { + throw_exception(std::runtime_error(msg)); + } + + + +} // namespace Catch; diff --git a/lib/Catch2/include/internal/catch_enforce.h b/lib/Catch2/include/internal/catch_enforce.h new file mode 100644 index 0000000000..0484724d2a --- /dev/null +++ b/lib/Catch2/include/internal/catch_enforce.h @@ -0,0 +1,53 @@ +/* + * Created by Martin on 01/08/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_ENFORCE_H_INCLUDED +#define TWOBLUECUBES_CATCH_ENFORCE_H_INCLUDED + +#include "catch_common.h" +#include "catch_compiler_capabilities.h" +#include "catch_stream.h" + +#include + +namespace Catch { +#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + template + [[noreturn]] + void throw_exception(Ex const& e) { + throw e; + } +#else // ^^ Exceptions are enabled // Exceptions are disabled vv + [[noreturn]] + void throw_exception(std::exception const& e); +#endif + + [[noreturn]] + void throw_logic_error(std::string const& msg); + [[noreturn]] + void throw_domain_error(std::string const& msg); + [[noreturn]] + void throw_runtime_error(std::string const& msg); + +} // namespace Catch; + +#define CATCH_MAKE_MSG(...) \ + (Catch::ReusableStringStream() << __VA_ARGS__).str() + +#define CATCH_INTERNAL_ERROR(...) \ + Catch::throw_logic_error(CATCH_MAKE_MSG( CATCH_INTERNAL_LINEINFO << ": Internal Catch2 error: " << __VA_ARGS__)) + +#define CATCH_ERROR(...) \ + Catch::throw_domain_error(CATCH_MAKE_MSG( __VA_ARGS__ )) + +#define CATCH_RUNTIME_ERROR(...) \ + Catch::throw_runtime_error(CATCH_MAKE_MSG( __VA_ARGS__ )) + +#define CATCH_ENFORCE( condition, ... ) \ + do{ if( !(condition) ) CATCH_ERROR( __VA_ARGS__ ); } while(false) + + +#endif // TWOBLUECUBES_CATCH_ENFORCE_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_enum_values_registry.cpp b/lib/Catch2/include/internal/catch_enum_values_registry.cpp new file mode 100644 index 0000000000..a119d15222 --- /dev/null +++ b/lib/Catch2/include/internal/catch_enum_values_registry.cpp @@ -0,0 +1,75 @@ +/* + * Created by Phil on 4/4/2019. + * Copyright 2019 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#include "catch_enum_values_registry.h" +#include "catch_string_manip.h" +#include "catch_stream.h" + +#include +#include + +namespace Catch { + + IMutableEnumValuesRegistry::~IMutableEnumValuesRegistry() {} + + namespace Detail { + + namespace { + // Extracts the actual name part of an enum instance + // In other words, it returns the Blue part of Bikeshed::Colour::Blue + StringRef extractInstanceName(StringRef enumInstance) { + // Find last occurrence of ":" + size_t name_start = enumInstance.size(); + while (name_start > 0 && enumInstance[name_start - 1] != ':') { + --name_start; + } + return enumInstance.substr(name_start, enumInstance.size() - name_start); + } + } + + std::vector parseEnums( StringRef enums ) { + auto enumValues = splitStringRef( enums, ',' ); + std::vector parsed; + parsed.reserve( enumValues.size() ); + for( auto const& enumValue : enumValues ) { + parsed.push_back(trim(extractInstanceName(enumValue))); + } + return parsed; + } + + EnumInfo::~EnumInfo() {} + + StringRef EnumInfo::lookup( int value ) const { + for( auto const& valueToName : m_values ) { + if( valueToName.first == value ) + return valueToName.second; + } + return "{** unexpected enum value **}"_sr; + } + + std::unique_ptr makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector const& values ) { + std::unique_ptr enumInfo( new EnumInfo ); + enumInfo->m_name = enumName; + enumInfo->m_values.reserve( values.size() ); + + const auto valueNames = Catch::Detail::parseEnums( allValueNames ); + assert( valueNames.size() == values.size() ); + std::size_t i = 0; + for( auto value : values ) + enumInfo->m_values.emplace_back(value, valueNames[i++]); + + return enumInfo; + } + + EnumInfo const& EnumValuesRegistry::registerEnum( StringRef enumName, StringRef allValueNames, std::vector const& values ) { + m_enumInfos.push_back(makeEnumInfo(enumName, allValueNames, values)); + return *m_enumInfos.back(); + } + + } // Detail +} // Catch + diff --git a/lib/Catch2/include/internal/catch_enum_values_registry.h b/lib/Catch2/include/internal/catch_enum_values_registry.h new file mode 100644 index 0000000000..ae252fbf32 --- /dev/null +++ b/lib/Catch2/include/internal/catch_enum_values_registry.h @@ -0,0 +1,35 @@ +/* + * Created by Phil on 4/4/2019. + * Copyright 2019 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_ENUMVALUESREGISTRY_H_INCLUDED +#define TWOBLUECUBES_CATCH_ENUMVALUESREGISTRY_H_INCLUDED + +#include "catch_interfaces_enum_values_registry.h" + +#include +#include + +namespace Catch { + + namespace Detail { + + std::unique_ptr makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector const& values ); + + class EnumValuesRegistry : public IMutableEnumValuesRegistry { + + std::vector> m_enumInfos; + + EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector const& values) override; + }; + + std::vector parseEnums( StringRef enums ); + + } // Detail + +} // Catch + +#endif //TWOBLUECUBES_CATCH_ENUMVALUESREGISTRY_H_INCLUDED \ No newline at end of file diff --git a/lib/Catch2/include/internal/catch_errno_guard.cpp b/lib/Catch2/include/internal/catch_errno_guard.cpp new file mode 100644 index 0000000000..070583bc7d --- /dev/null +++ b/lib/Catch2/include/internal/catch_errno_guard.cpp @@ -0,0 +1,15 @@ +/* + * Created by Martin on 06/03/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_errno_guard.h" + +#include + +namespace Catch { + ErrnoGuard::ErrnoGuard():m_oldErrno(errno){} + ErrnoGuard::~ErrnoGuard() { errno = m_oldErrno; } +} diff --git a/lib/Catch2/include/internal/catch_errno_guard.h b/lib/Catch2/include/internal/catch_errno_guard.h new file mode 100644 index 0000000000..b1d1fc1c75 --- /dev/null +++ b/lib/Catch2/include/internal/catch_errno_guard.h @@ -0,0 +1,22 @@ +/* + * Created by Martin on 06/03/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_ERRNO_GUARD_H_INCLUDED +#define TWOBLUECUBES_CATCH_ERRNO_GUARD_H_INCLUDED + +namespace Catch { + + class ErrnoGuard { + public: + ErrnoGuard(); + ~ErrnoGuard(); + private: + int m_oldErrno; + }; + +} + +#endif // TWOBLUECUBES_CATCH_ERRNO_GUARD_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_exception_translator_registry.cpp b/lib/Catch2/include/internal/catch_exception_translator_registry.cpp new file mode 100644 index 0000000000..cef36e513c --- /dev/null +++ b/lib/Catch2/include/internal/catch_exception_translator_registry.cpp @@ -0,0 +1,89 @@ +/* + * Created by Phil on 20/04/2011. + * Copyright 2011 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_exception_translator_registry.h" +#include "catch_assertionhandler.h" +#include "catch_compiler_capabilities.h" +#include "catch_enforce.h" + +#ifdef __OBJC__ +#import "Foundation/Foundation.h" +#endif + +namespace Catch { + + ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() { + } + + void ExceptionTranslatorRegistry::registerTranslator( const IExceptionTranslator* translator ) { + m_translators.push_back( std::unique_ptr( translator ) ); + } + +#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + std::string ExceptionTranslatorRegistry::translateActiveException() const { + try { +#ifdef __OBJC__ + // In Objective-C try objective-c exceptions first + @try { + return tryTranslators(); + } + @catch (NSException *exception) { + return Catch::Detail::stringify( [exception description] ); + } +#else + // Compiling a mixed mode project with MSVC means that CLR + // exceptions will be caught in (...) as well. However, these + // do not fill-in std::current_exception and thus lead to crash + // when attempting rethrow. + // /EHa switch also causes structured exceptions to be caught + // here, but they fill-in current_exception properly, so + // at worst the output should be a little weird, instead of + // causing a crash. + if (std::current_exception() == nullptr) { + return "Non C++ exception. Possibly a CLR exception."; + } + return tryTranslators(); +#endif + } + catch( TestFailureException& ) { + std::rethrow_exception(std::current_exception()); + } + catch( std::exception& ex ) { + return ex.what(); + } + catch( std::string& msg ) { + return msg; + } + catch( const char* msg ) { + return msg; + } + catch(...) { + return "Unknown exception"; + } + } + + std::string ExceptionTranslatorRegistry::tryTranslators() const { + if (m_translators.empty()) { + std::rethrow_exception(std::current_exception()); + } else { + return m_translators[0]->translate(m_translators.begin() + 1, m_translators.end()); + } + } + +#else // ^^ Exceptions are enabled // Exceptions are disabled vv + std::string ExceptionTranslatorRegistry::translateActiveException() const { + CATCH_INTERNAL_ERROR("Attempted to translate active exception under CATCH_CONFIG_DISABLE_EXCEPTIONS!"); + } + + std::string ExceptionTranslatorRegistry::tryTranslators() const { + CATCH_INTERNAL_ERROR("Attempted to use exception translators under CATCH_CONFIG_DISABLE_EXCEPTIONS!"); + } +#endif + + +} diff --git a/lib/Catch2/include/internal/catch_exception_translator_registry.h b/lib/Catch2/include/internal/catch_exception_translator_registry.h new file mode 100644 index 0000000000..bb07c13133 --- /dev/null +++ b/lib/Catch2/include/internal/catch_exception_translator_registry.h @@ -0,0 +1,30 @@ +/* + * Created by Phil on 20/04/2011. + * Copyright 2011 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED + +#include "catch_interfaces_exception.h" +#include +#include +#include + +namespace Catch { + + class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry { + public: + ~ExceptionTranslatorRegistry(); + virtual void registerTranslator( const IExceptionTranslator* translator ); + std::string translateActiveException() const override; + std::string tryTranslators() const; + + private: + std::vector> m_translators; + }; +} + +#endif // TWOBLUECUBES_CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_external_interfaces.h b/lib/Catch2/include/internal/catch_external_interfaces.h new file mode 100644 index 0000000000..d025494549 --- /dev/null +++ b/lib/Catch2/include/internal/catch_external_interfaces.h @@ -0,0 +1,20 @@ +/* + * Created by Martin on 17/08/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_EXTERNAL_INTERFACES_H_INCLUDED +#define TWOBLUECUBES_CATCH_EXTERNAL_INTERFACES_H_INCLUDED + +#include "../reporters/catch_reporter_bases.hpp" +#include "catch_console_colour.h" +#include "catch_reporter_registrars.hpp" + +// Allow users to base their work off existing reporters +#include "../reporters/catch_reporter_compact.h" +#include "../reporters/catch_reporter_console.h" +#include "../reporters/catch_reporter_junit.h" +#include "../reporters/catch_reporter_xml.h" + +#endif // TWOBLUECUBES_CATCH_EXTERNAL_INTERFACES_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_fatal_condition.cpp b/lib/Catch2/include/internal/catch_fatal_condition.cpp new file mode 100644 index 0000000000..873e2ed53a --- /dev/null +++ b/lib/Catch2/include/internal/catch_fatal_condition.cpp @@ -0,0 +1,244 @@ +/* + * Created by Phil on 21/08/2014 + * Copyright 2014 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + +/** \file + * This file provides platform specific implementations of FatalConditionHandler + * + * This means that there is a lot of conditional compilation, and platform + * specific code. Currently, Catch2 supports a dummy handler (if no + * handler is desired), and 2 platform specific handlers: + * * Windows' SEH + * * POSIX signals + * + * Consequently, various pieces of code below are compiled if either of + * the platform specific handlers is enabled, or if none of them are + * enabled. It is assumed that both cannot be enabled at the same time, + * and doing so should cause a compilation error. + * + * If another platform specific handler is added, the compile guards + * below will need to be updated taking these assumptions into account. + */ + +#include "catch_fatal_condition.h" + +#include "catch_context.h" +#include "catch_enforce.h" +#include "catch_run_context.h" +#include "catch_windows_h_proxy.h" + +#include + +#if !defined( CATCH_CONFIG_WINDOWS_SEH ) && !defined( CATCH_CONFIG_POSIX_SIGNALS ) + +namespace Catch { + + // If neither SEH nor signal handling is required, the handler impls + // do not have to do anything, and can be empty. + void FatalConditionHandler::engage_platform() {} + void FatalConditionHandler::disengage_platform() {} + FatalConditionHandler::FatalConditionHandler() = default; + FatalConditionHandler::~FatalConditionHandler() = default; + +} // end namespace Catch + +#endif // !CATCH_CONFIG_WINDOWS_SEH && !CATCH_CONFIG_POSIX_SIGNALS + +#if defined( CATCH_CONFIG_WINDOWS_SEH ) && defined( CATCH_CONFIG_POSIX_SIGNALS ) +#error "Inconsistent configuration: Windows' SEH handling and POSIX signals cannot be enabled at the same time" +#endif // CATCH_CONFIG_WINDOWS_SEH && CATCH_CONFIG_POSIX_SIGNALS + +#if defined( CATCH_CONFIG_WINDOWS_SEH ) || defined( CATCH_CONFIG_POSIX_SIGNALS ) + +namespace { + //! Signals fatal error message to the run context + void reportFatal( char const * const message ) { + Catch::getCurrentContext().getResultCapture()->handleFatalErrorCondition( message ); + } + + //! Minimal size Catch2 needs for its own fatal error handling. + //! Picked anecdotally, so it might not be sufficient on all + //! platforms, and for all configurations. + constexpr std::size_t minStackSizeForErrors = 32 * 1024; +} // end unnamed namespace + +#endif // CATCH_CONFIG_WINDOWS_SEH || CATCH_CONFIG_POSIX_SIGNALS + +#if defined( CATCH_CONFIG_WINDOWS_SEH ) + +namespace Catch { + + struct SignalDefs { DWORD id; const char* name; }; + + // There is no 1-1 mapping between signals and windows exceptions. + // Windows can easily distinguish between SO and SigSegV, + // but SigInt, SigTerm, etc are handled differently. + static SignalDefs signalDefs[] = { + { static_cast(EXCEPTION_ILLEGAL_INSTRUCTION), "SIGILL - Illegal instruction signal" }, + { static_cast(EXCEPTION_STACK_OVERFLOW), "SIGSEGV - Stack overflow" }, + { static_cast(EXCEPTION_ACCESS_VIOLATION), "SIGSEGV - Segmentation violation signal" }, + { static_cast(EXCEPTION_INT_DIVIDE_BY_ZERO), "Divide by zero error" }, + }; + + static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { + for (auto const& def : signalDefs) { + if (ExceptionInfo->ExceptionRecord->ExceptionCode == def.id) { + reportFatal(def.name); + } + } + // If its not an exception we care about, pass it along. + // This stops us from eating debugger breaks etc. + return EXCEPTION_CONTINUE_SEARCH; + } + + // Since we do not support multiple instantiations, we put these + // into global variables and rely on cleaning them up in outlined + // constructors/destructors + static PVOID exceptionHandlerHandle = nullptr; + + + // For MSVC, we reserve part of the stack memory for handling + // memory overflow structured exception. + FatalConditionHandler::FatalConditionHandler() { + ULONG guaranteeSize = static_cast(minStackSizeForErrors); + if (!SetThreadStackGuarantee(&guaranteeSize)) { + // We do not want to fully error out, because needing + // the stack reserve should be rare enough anyway. + Catch::cerr() + << "Failed to reserve piece of stack." + << " Stack overflows will not be reported successfully."; + } + } + + // We do not attempt to unset the stack guarantee, because + // Windows does not support lowering the stack size guarantee. + FatalConditionHandler::~FatalConditionHandler() = default; + + + void FatalConditionHandler::engage_platform() { + // Register as first handler in current chain + exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException); + if (!exceptionHandlerHandle) { + CATCH_RUNTIME_ERROR("Could not register vectored exception handler"); + } + } + + void FatalConditionHandler::disengage_platform() { + if (!RemoveVectoredExceptionHandler(exceptionHandlerHandle)) { + CATCH_RUNTIME_ERROR("Could not unregister vectored exception handler"); + } + exceptionHandlerHandle = nullptr; + } + +} // end namespace Catch + +#endif // CATCH_CONFIG_WINDOWS_SEH + +#if defined( CATCH_CONFIG_POSIX_SIGNALS ) + +#include + +namespace Catch { + + struct SignalDefs { + int id; + const char* name; + }; + + static SignalDefs signalDefs[] = { + { SIGINT, "SIGINT - Terminal interrupt signal" }, + { SIGILL, "SIGILL - Illegal instruction signal" }, + { SIGFPE, "SIGFPE - Floating point error signal" }, + { SIGSEGV, "SIGSEGV - Segmentation violation signal" }, + { SIGTERM, "SIGTERM - Termination request signal" }, + { SIGABRT, "SIGABRT - Abort (abnormal termination) signal" } + }; + +// Older GCCs trigger -Wmissing-field-initializers for T foo = {} +// which is zero initialization, but not explicit. We want to avoid +// that. +#if defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + + static char* altStackMem = nullptr; + static std::size_t altStackSize = 0; + static stack_t oldSigStack{}; + static struct sigaction oldSigActions[sizeof(signalDefs) / sizeof(SignalDefs)]{}; + + static void restorePreviousSignalHandlers() { + // We set signal handlers back to the previous ones. Hopefully + // nobody overwrote them in the meantime, and doesn't expect + // their signal handlers to live past ours given that they + // installed them after ours.. + for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { + sigaction(signalDefs[i].id, &oldSigActions[i], nullptr); + } + // Return the old stack + sigaltstack(&oldSigStack, nullptr); + } + + static void handleSignal( int sig ) { + char const * name = ""; + for (auto const& def : signalDefs) { + if (sig == def.id) { + name = def.name; + break; + } + } + // We need to restore previous signal handlers and let them do + // their thing, so that the users can have the debugger break + // when a signal is raised, and so on. + restorePreviousSignalHandlers(); + reportFatal( name ); + raise( sig ); + } + + FatalConditionHandler::FatalConditionHandler() { + assert(!altStackMem && "Cannot initialize POSIX signal handler when one already exists"); + if (altStackSize == 0) { + altStackSize = std::max(static_cast(SIGSTKSZ), minStackSizeForErrors); + } + altStackMem = new char[altStackSize](); + } + + FatalConditionHandler::~FatalConditionHandler() { + delete[] altStackMem; + // We signal that another instance can be constructed by zeroing + // out the pointer. + altStackMem = nullptr; + } + + void FatalConditionHandler::engage_platform() { + stack_t sigStack; + sigStack.ss_sp = altStackMem; + sigStack.ss_size = altStackSize; + sigStack.ss_flags = 0; + sigaltstack(&sigStack, &oldSigStack); + struct sigaction sa = { }; + + sa.sa_handler = handleSignal; + sa.sa_flags = SA_ONSTACK; + for (std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i) { + sigaction(signalDefs[i].id, &sa, &oldSigActions[i]); + } + } + +#if defined(__GNUC__) +# pragma GCC diagnostic pop +#endif + + + void FatalConditionHandler::disengage_platform() { + restorePreviousSignalHandlers(); + } + +} // end namespace Catch + +#endif // CATCH_CONFIG_POSIX_SIGNALS diff --git a/lib/Catch2/include/internal/catch_fatal_condition.h b/lib/Catch2/include/internal/catch_fatal_condition.h new file mode 100644 index 0000000000..b5744f8f21 --- /dev/null +++ b/lib/Catch2/include/internal/catch_fatal_condition.h @@ -0,0 +1,68 @@ +/* + * Created by Phil on 21/08/2014 + * Copyright 2014 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ +#ifndef TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED +#define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED + +#include "catch_platform.h" +#include "catch_compiler_capabilities.h" + +#include + +namespace Catch { + + // Wrapper for platform-specific fatal error (signals/SEH) handlers + // + // Tries to be cooperative with other handlers, and not step over + // other handlers. This means that unknown structured exceptions + // are passed on, previous signal handlers are called, and so on. + // + // Can only be instantiated once, and assumes that once a signal + // is caught, the binary will end up terminating. Thus, there + class FatalConditionHandler { + bool m_started = false; + + // Install/disengage implementation for specific platform. + // Should be if-defed to work on current platform, can assume + // engage-disengage 1:1 pairing. + void engage_platform(); + void disengage_platform(); + public: + // Should also have platform-specific implementations as needed + FatalConditionHandler(); + ~FatalConditionHandler(); + + void engage() { + assert(!m_started && "Handler cannot be installed twice."); + m_started = true; + engage_platform(); + } + + void disengage() { + assert(m_started && "Handler cannot be uninstalled without being installed first"); + m_started = false; + disengage_platform(); + } + }; + + //! Simple RAII guard for (dis)engaging the FatalConditionHandler + class FatalConditionHandlerGuard { + FatalConditionHandler* m_handler; + public: + FatalConditionHandlerGuard(FatalConditionHandler* handler): + m_handler(handler) { + m_handler->engage(); + } + ~FatalConditionHandlerGuard() { + m_handler->disengage(); + } + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_generators.cpp b/lib/Catch2/include/internal/catch_generators.cpp new file mode 100644 index 0000000000..c6d60a70ad --- /dev/null +++ b/lib/Catch2/include/internal/catch_generators.cpp @@ -0,0 +1,32 @@ +/* + * Created by Phil Nash on 15/6/2018. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_generators.hpp" +#include "catch_random_number_generator.h" +#include "catch_interfaces_capture.h" + +#include +#include + +namespace Catch { + +IGeneratorTracker::~IGeneratorTracker() {} + +const char* GeneratorException::what() const noexcept { + return m_msg; +} + +namespace Generators { + + GeneratorUntypedBase::~GeneratorUntypedBase() {} + + auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& { + return getResultCapture().acquireGeneratorTracker( generatorName, lineInfo ); + } + +} // namespace Generators +} // namespace Catch diff --git a/lib/Catch2/include/internal/catch_generators.hpp b/lib/Catch2/include/internal/catch_generators.hpp new file mode 100644 index 0000000000..e253ea0966 --- /dev/null +++ b/lib/Catch2/include/internal/catch_generators.hpp @@ -0,0 +1,219 @@ +/* + * Created by Phil Nash on 15/6/2018. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED + +#include "catch_interfaces_generatortracker.h" +#include "catch_common.h" +#include "catch_enforce.h" +#include "catch_stringref.h" + +#include +#include +#include + +#include +#include + +namespace Catch { + +class GeneratorException : public std::exception { + const char* const m_msg = ""; + +public: + GeneratorException(const char* msg): + m_msg(msg) + {} + + const char* what() const noexcept override final; +}; + +namespace Generators { + + // !TBD move this into its own location? + namespace pf{ + template + std::unique_ptr make_unique( Args&&... args ) { + return std::unique_ptr(new T(std::forward(args)...)); + } + } + + template + struct IGenerator : GeneratorUntypedBase { + virtual ~IGenerator() = default; + + // Returns the current element of the generator + // + // \Precondition The generator is either freshly constructed, + // or the last call to `next()` returned true + virtual T const& get() const = 0; + using type = T; + }; + + template + class SingleValueGenerator final : public IGenerator { + T m_value; + public: + SingleValueGenerator(T&& value) : m_value(std::move(value)) {} + + T const& get() const override { + return m_value; + } + bool next() override { + return false; + } + }; + + template + class FixedValuesGenerator final : public IGenerator { + static_assert(!std::is_same::value, + "FixedValuesGenerator does not support bools because of std::vector" + "specialization, use SingleValue Generator instead."); + std::vector m_values; + size_t m_idx = 0; + public: + FixedValuesGenerator( std::initializer_list values ) : m_values( values ) {} + + T const& get() const override { + return m_values[m_idx]; + } + bool next() override { + ++m_idx; + return m_idx < m_values.size(); + } + }; + + template + class GeneratorWrapper final { + std::unique_ptr> m_generator; + public: + GeneratorWrapper(std::unique_ptr> generator): + m_generator(std::move(generator)) + {} + T const& get() const { + return m_generator->get(); + } + bool next() { + return m_generator->next(); + } + }; + + template + GeneratorWrapper value(T&& value) { + return GeneratorWrapper(pf::make_unique>(std::forward(value))); + } + template + GeneratorWrapper values(std::initializer_list values) { + return GeneratorWrapper(pf::make_unique>(values)); + } + + template + class Generators : public IGenerator { + std::vector> m_generators; + size_t m_current = 0; + + void populate(GeneratorWrapper&& generator) { + m_generators.emplace_back(std::move(generator)); + } + void populate(T&& val) { + m_generators.emplace_back(value(std::forward(val))); + } + template + void populate(U&& val) { + populate(T(std::forward(val))); + } + template + void populate(U&& valueOrGenerator, Gs &&... moreGenerators) { + populate(std::forward(valueOrGenerator)); + populate(std::forward(moreGenerators)...); + } + + public: + template + Generators(Gs &&... moreGenerators) { + m_generators.reserve(sizeof...(Gs)); + populate(std::forward(moreGenerators)...); + } + + T const& get() const override { + return m_generators[m_current].get(); + } + + bool next() override { + if (m_current >= m_generators.size()) { + return false; + } + const bool current_status = m_generators[m_current].next(); + if (!current_status) { + ++m_current; + } + return m_current < m_generators.size(); + } + }; + + + template + GeneratorWrapper> table( std::initializer_list::type...>> tuples ) { + return values>( tuples ); + } + + // Tag type to signal that a generator sequence should convert arguments to a specific type + template + struct as {}; + + template + auto makeGenerators( GeneratorWrapper&& generator, Gs &&... moreGenerators ) -> Generators { + return Generators(std::move(generator), std::forward(moreGenerators)...); + } + template + auto makeGenerators( GeneratorWrapper&& generator ) -> Generators { + return Generators(std::move(generator)); + } + template + auto makeGenerators( T&& val, Gs &&... moreGenerators ) -> Generators { + return makeGenerators( value( std::forward( val ) ), std::forward( moreGenerators )... ); + } + template + auto makeGenerators( as, U&& val, Gs &&... moreGenerators ) -> Generators { + return makeGenerators( value( T( std::forward( val ) ) ), std::forward( moreGenerators )... ); + } + + auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker&; + + template + // Note: The type after -> is weird, because VS2015 cannot parse + // the expression used in the typedef inside, when it is in + // return type. Yeah. + auto generate( StringRef generatorName, SourceLineInfo const& lineInfo, L const& generatorExpression ) -> decltype(std::declval().get()) { + using UnderlyingType = typename decltype(generatorExpression())::type; + + IGeneratorTracker& tracker = acquireGeneratorTracker( generatorName, lineInfo ); + if (!tracker.hasGenerator()) { + tracker.setGenerator(pf::make_unique>(generatorExpression())); + } + + auto const& generator = static_cast const&>( *tracker.getGenerator() ); + return generator.get(); + } + +} // namespace Generators +} // namespace Catch + +#define GENERATE( ... ) \ + Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ + CATCH_INTERNAL_LINEINFO, \ + [ ]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) +#define GENERATE_COPY( ... ) \ + Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ + CATCH_INTERNAL_LINEINFO, \ + [=]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) +#define GENERATE_REF( ... ) \ + Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \ + CATCH_INTERNAL_LINEINFO, \ + [&]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) + +#endif // TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_generators_generic.hpp b/lib/Catch2/include/internal/catch_generators_generic.hpp new file mode 100644 index 0000000000..c341014795 --- /dev/null +++ b/lib/Catch2/include/internal/catch_generators_generic.hpp @@ -0,0 +1,237 @@ +/* + * Created by Martin on 23/2/2019. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_GENERATORS_GENERIC_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_GENERATORS_GENERIC_HPP_INCLUDED + +#include "catch_generators.hpp" +#include "catch_meta.hpp" + +namespace Catch { +namespace Generators { + + template + class TakeGenerator : public IGenerator { + GeneratorWrapper m_generator; + size_t m_returned = 0; + size_t m_target; + public: + TakeGenerator(size_t target, GeneratorWrapper&& generator): + m_generator(std::move(generator)), + m_target(target) + { + assert(target != 0 && "Empty generators are not allowed"); + } + T const& get() const override { + return m_generator.get(); + } + bool next() override { + ++m_returned; + if (m_returned >= m_target) { + return false; + } + + const auto success = m_generator.next(); + // If the underlying generator does not contain enough values + // then we cut short as well + if (!success) { + m_returned = m_target; + } + return success; + } + }; + + template + GeneratorWrapper take(size_t target, GeneratorWrapper&& generator) { + return GeneratorWrapper(pf::make_unique>(target, std::move(generator))); + } + + + template + class FilterGenerator : public IGenerator { + GeneratorWrapper m_generator; + Predicate m_predicate; + public: + template + FilterGenerator(P&& pred, GeneratorWrapper&& generator): + m_generator(std::move(generator)), + m_predicate(std::forward

(pred)) + { + if (!m_predicate(m_generator.get())) { + // It might happen that there are no values that pass the + // filter. In that case we throw an exception. + auto has_initial_value = next(); + if (!has_initial_value) { + Catch::throw_exception(GeneratorException("No valid value found in filtered generator")); + } + } + } + + T const& get() const override { + return m_generator.get(); + } + + bool next() override { + bool success = m_generator.next(); + if (!success) { + return false; + } + while (!m_predicate(m_generator.get()) && (success = m_generator.next()) == true); + return success; + } + }; + + + template + GeneratorWrapper filter(Predicate&& pred, GeneratorWrapper&& generator) { + return GeneratorWrapper(std::unique_ptr>(pf::make_unique>(std::forward(pred), std::move(generator)))); + } + + template + class RepeatGenerator : public IGenerator { + static_assert(!std::is_same::value, + "RepeatGenerator currently does not support bools" + "because of std::vector specialization"); + GeneratorWrapper m_generator; + mutable std::vector m_returned; + size_t m_target_repeats; + size_t m_current_repeat = 0; + size_t m_repeat_index = 0; + public: + RepeatGenerator(size_t repeats, GeneratorWrapper&& generator): + m_generator(std::move(generator)), + m_target_repeats(repeats) + { + assert(m_target_repeats > 0 && "Repeat generator must repeat at least once"); + } + + T const& get() const override { + if (m_current_repeat == 0) { + m_returned.push_back(m_generator.get()); + return m_returned.back(); + } + return m_returned[m_repeat_index]; + } + + bool next() override { + // There are 2 basic cases: + // 1) We are still reading the generator + // 2) We are reading our own cache + + // In the first case, we need to poke the underlying generator. + // If it happily moves, we are left in that state, otherwise it is time to start reading from our cache + if (m_current_repeat == 0) { + const auto success = m_generator.next(); + if (!success) { + ++m_current_repeat; + } + return m_current_repeat < m_target_repeats; + } + + // In the second case, we need to move indices forward and check that we haven't run up against the end + ++m_repeat_index; + if (m_repeat_index == m_returned.size()) { + m_repeat_index = 0; + ++m_current_repeat; + } + return m_current_repeat < m_target_repeats; + } + }; + + template + GeneratorWrapper repeat(size_t repeats, GeneratorWrapper&& generator) { + return GeneratorWrapper(pf::make_unique>(repeats, std::move(generator))); + } + + template + class MapGenerator : public IGenerator { + // TBD: provide static assert for mapping function, for friendly error message + GeneratorWrapper m_generator; + Func m_function; + // To avoid returning dangling reference, we have to save the values + T m_cache; + public: + template + MapGenerator(F2&& function, GeneratorWrapper&& generator) : + m_generator(std::move(generator)), + m_function(std::forward(function)), + m_cache(m_function(m_generator.get())) + {} + + T const& get() const override { + return m_cache; + } + bool next() override { + const auto success = m_generator.next(); + if (success) { + m_cache = m_function(m_generator.get()); + } + return success; + } + }; + + template > + GeneratorWrapper map(Func&& function, GeneratorWrapper&& generator) { + return GeneratorWrapper( + pf::make_unique>(std::forward(function), std::move(generator)) + ); + } + + template + GeneratorWrapper map(Func&& function, GeneratorWrapper&& generator) { + return GeneratorWrapper( + pf::make_unique>(std::forward(function), std::move(generator)) + ); + } + + template + class ChunkGenerator final : public IGenerator> { + std::vector m_chunk; + size_t m_chunk_size; + GeneratorWrapper m_generator; + bool m_used_up = false; + public: + ChunkGenerator(size_t size, GeneratorWrapper generator) : + m_chunk_size(size), m_generator(std::move(generator)) + { + m_chunk.reserve(m_chunk_size); + if (m_chunk_size != 0) { + m_chunk.push_back(m_generator.get()); + for (size_t i = 1; i < m_chunk_size; ++i) { + if (!m_generator.next()) { + Catch::throw_exception(GeneratorException("Not enough values to initialize the first chunk")); + } + m_chunk.push_back(m_generator.get()); + } + } + } + std::vector const& get() const override { + return m_chunk; + } + bool next() override { + m_chunk.clear(); + for (size_t idx = 0; idx < m_chunk_size; ++idx) { + if (!m_generator.next()) { + return false; + } + m_chunk.push_back(m_generator.get()); + } + return true; + } + }; + + template + GeneratorWrapper> chunk(size_t size, GeneratorWrapper&& generator) { + return GeneratorWrapper>( + pf::make_unique>(size, std::move(generator)) + ); + } + +} // namespace Generators +} // namespace Catch + + +#endif // TWOBLUECUBES_CATCH_GENERATORS_GENERIC_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_generators_specific.hpp b/lib/Catch2/include/internal/catch_generators_specific.hpp new file mode 100644 index 0000000000..dee8e711ab --- /dev/null +++ b/lib/Catch2/include/internal/catch_generators_specific.hpp @@ -0,0 +1,175 @@ +/* + * Created by Martin on 15/6/2018. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_GENERATORS_SPECIFIC_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_GENERATORS_SPECIFIC_HPP_INCLUDED + +#include "catch_context.h" +#include "catch_generators.hpp" +#include "catch_interfaces_config.h" +#include "catch_random_number_generator.h" + +#include + +namespace Catch { +namespace Generators { + +template +class RandomFloatingGenerator final : public IGenerator { + Catch::SimplePcg32& m_rng; + std::uniform_real_distribution m_dist; + Float m_current_number; +public: + + RandomFloatingGenerator(Float a, Float b): + m_rng(rng()), + m_dist(a, b) { + static_cast(next()); + } + + Float const& get() const override { + return m_current_number; + } + bool next() override { + m_current_number = m_dist(m_rng); + return true; + } +}; + +template +class RandomIntegerGenerator final : public IGenerator { + Catch::SimplePcg32& m_rng; + std::uniform_int_distribution m_dist; + Integer m_current_number; +public: + + RandomIntegerGenerator(Integer a, Integer b): + m_rng(rng()), + m_dist(a, b) { + static_cast(next()); + } + + Integer const& get() const override { + return m_current_number; + } + bool next() override { + m_current_number = m_dist(m_rng); + return true; + } +}; + +// TODO: Ideally this would be also constrained against the various char types, +// but I don't expect users to run into that in practice. +template +typename std::enable_if::value && !std::is_same::value, +GeneratorWrapper>::type +random(T a, T b) { + return GeneratorWrapper( + pf::make_unique>(a, b) + ); +} + +template +typename std::enable_if::value, +GeneratorWrapper>::type +random(T a, T b) { + return GeneratorWrapper( + pf::make_unique>(a, b) + ); +} + + +template +class RangeGenerator final : public IGenerator { + T m_current; + T m_end; + T m_step; + bool m_positive; + +public: + RangeGenerator(T const& start, T const& end, T const& step): + m_current(start), + m_end(end), + m_step(step), + m_positive(m_step > T(0)) + { + assert(m_current != m_end && "Range start and end cannot be equal"); + assert(m_step != T(0) && "Step size cannot be zero"); + assert(((m_positive && m_current <= m_end) || (!m_positive && m_current >= m_end)) && "Step moves away from end"); + } + + RangeGenerator(T const& start, T const& end): + RangeGenerator(start, end, (start < end) ? T(1) : T(-1)) + {} + + T const& get() const override { + return m_current; + } + + bool next() override { + m_current += m_step; + return (m_positive) ? (m_current < m_end) : (m_current > m_end); + } +}; + +template +GeneratorWrapper range(T const& start, T const& end, T const& step) { + static_assert(std::is_arithmetic::value && !std::is_same::value, "Type must be numeric"); + return GeneratorWrapper(pf::make_unique>(start, end, step)); +} + +template +GeneratorWrapper range(T const& start, T const& end) { + static_assert(std::is_integral::value && !std::is_same::value, "Type must be an integer"); + return GeneratorWrapper(pf::make_unique>(start, end)); +} + + +template +class IteratorGenerator final : public IGenerator { + static_assert(!std::is_same::value, + "IteratorGenerator currently does not support bools" + "because of std::vector specialization"); + + std::vector m_elems; + size_t m_current = 0; +public: + template + IteratorGenerator(InputIterator first, InputSentinel last):m_elems(first, last) { + if (m_elems.empty()) { + Catch::throw_exception(GeneratorException("IteratorGenerator received no valid values")); + } + } + + T const& get() const override { + return m_elems[m_current]; + } + + bool next() override { + ++m_current; + return m_current != m_elems.size(); + } +}; + +template ::value_type> +GeneratorWrapper from_range(InputIterator from, InputSentinel to) { + return GeneratorWrapper(pf::make_unique>(from, to)); +} + +template +GeneratorWrapper from_range(Container const& cnt) { + return GeneratorWrapper(pf::make_unique>(cnt.begin(), cnt.end())); +} + + +} // namespace Generators +} // namespace Catch + + +#endif // TWOBLUECUBES_CATCH_GENERATORS_SPECIFIC_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_impl.hpp b/lib/Catch2/include/internal/catch_impl.hpp new file mode 100644 index 0000000000..0b29a39f07 --- /dev/null +++ b/lib/Catch2/include/internal/catch_impl.hpp @@ -0,0 +1,33 @@ +/* + * Created by Phil on 5/8/2012. + * Copyright 2012 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#endif + +// Keep these here for external reporters +#include "catch_test_spec.h" +#include "catch_test_case_tracker.h" + +#include "catch_leak_detector.h" + +// Cpp files will be included in the single-header file here +// ~*~* CATCH_CPP_STITCH_PLACE *~*~ + +namespace Catch { + LeakDetector leakDetector; +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#endif // TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_interfaces_capture.cpp b/lib/Catch2/include/internal/catch_interfaces_capture.cpp new file mode 100644 index 0000000000..3c090bfe99 --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_capture.cpp @@ -0,0 +1,5 @@ +#include "catch_interfaces_capture.h" + +namespace Catch { + IResultCapture::~IResultCapture() = default; +} diff --git a/lib/Catch2/include/internal/catch_interfaces_capture.h b/lib/Catch2/include/internal/catch_interfaces_capture.h new file mode 100644 index 0000000000..ccca73de30 --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_capture.h @@ -0,0 +1,100 @@ +/* + * Created by Phil on 07/01/2011. + * Copyright 2011 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED + +#include +#include + +#include "catch_stringref.h" +#include "catch_result_type.h" + +namespace Catch { + + class AssertionResult; + struct AssertionInfo; + struct SectionInfo; + struct SectionEndInfo; + struct MessageInfo; + struct MessageBuilder; + struct Counts; + struct AssertionReaction; + struct SourceLineInfo; + + struct ITransientExpression; + struct IGeneratorTracker; + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + struct BenchmarkInfo; + template > + struct BenchmarkStats; +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + struct IResultCapture { + + virtual ~IResultCapture(); + + virtual bool sectionStarted( SectionInfo const& sectionInfo, + Counts& assertions ) = 0; + virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0; + virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0; + + virtual auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& = 0; + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + virtual void benchmarkPreparing( std::string const& name ) = 0; + virtual void benchmarkStarting( BenchmarkInfo const& info ) = 0; + virtual void benchmarkEnded( BenchmarkStats<> const& stats ) = 0; + virtual void benchmarkFailed( std::string const& error ) = 0; +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + virtual void pushScopedMessage( MessageInfo const& message ) = 0; + virtual void popScopedMessage( MessageInfo const& message ) = 0; + + virtual void emplaceUnscopedMessage( MessageBuilder const& builder ) = 0; + + virtual void handleFatalErrorCondition( StringRef message ) = 0; + + virtual void handleExpr + ( AssertionInfo const& info, + ITransientExpression const& expr, + AssertionReaction& reaction ) = 0; + virtual void handleMessage + ( AssertionInfo const& info, + ResultWas::OfType resultType, + StringRef const& message, + AssertionReaction& reaction ) = 0; + virtual void handleUnexpectedExceptionNotThrown + ( AssertionInfo const& info, + AssertionReaction& reaction ) = 0; + virtual void handleUnexpectedInflightException + ( AssertionInfo const& info, + std::string const& message, + AssertionReaction& reaction ) = 0; + virtual void handleIncomplete + ( AssertionInfo const& info ) = 0; + virtual void handleNonExpr + ( AssertionInfo const &info, + ResultWas::OfType resultType, + AssertionReaction &reaction ) = 0; + + + + virtual bool lastAssertionPassed() = 0; + virtual void assertionPassed() = 0; + + // Deprecated, do not use: + virtual std::string getCurrentTestName() const = 0; + virtual const AssertionResult* getLastResult() const = 0; + virtual void exceptionEarlyReported() = 0; + }; + + IResultCapture& getResultCapture(); +} + +#endif // TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_interfaces_config.cpp b/lib/Catch2/include/internal/catch_interfaces_config.cpp new file mode 100644 index 0000000000..6617da6919 --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_config.cpp @@ -0,0 +1,5 @@ +#include "catch_interfaces_config.h" + +namespace Catch { + IConfig::~IConfig() = default; +} diff --git a/lib/Catch2/include/internal/catch_interfaces_config.h b/lib/Catch2/include/internal/catch_interfaces_config.h new file mode 100644 index 0000000000..e9c2cf9662 --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_config.h @@ -0,0 +1,92 @@ +/* + * Created by Phil on 05/06/2012. + * Copyright 2012 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED + +#include "catch_common.h" +#include "catch_option.hpp" + +#include +#include +#include +#include +#include + +namespace Catch { + + enum class Verbosity { + Quiet = 0, + Normal, + High + }; + + struct WarnAbout { enum What { + Nothing = 0x00, + NoAssertions = 0x01, + NoTests = 0x02 + }; }; + + struct ShowDurations { enum OrNot { + DefaultForReporter, + Always, + Never + }; }; + struct RunTests { enum InWhatOrder { + InDeclarationOrder, + InLexicographicalOrder, + InRandomOrder + }; }; + struct UseColour { enum YesOrNo { + Auto, + Yes, + No + }; }; + struct WaitForKeypress { enum When { + Never, + BeforeStart = 1, + BeforeExit = 2, + BeforeStartAndExit = BeforeStart | BeforeExit + }; }; + + class TestSpec; + + struct IConfig : NonCopyable { + + virtual ~IConfig(); + + virtual bool allowThrows() const = 0; + virtual std::ostream& stream() const = 0; + virtual std::string name() const = 0; + virtual bool includeSuccessfulResults() const = 0; + virtual bool shouldDebugBreak() const = 0; + virtual bool warnAboutMissingAssertions() const = 0; + virtual bool warnAboutNoTests() const = 0; + virtual int abortAfter() const = 0; + virtual bool showInvisibles() const = 0; + virtual ShowDurations::OrNot showDurations() const = 0; + virtual double minDuration() const = 0; + virtual TestSpec const& testSpec() const = 0; + virtual bool hasTestFilters() const = 0; + virtual std::vector const& getTestsOrTags() const = 0; + virtual RunTests::InWhatOrder runOrder() const = 0; + virtual unsigned int rngSeed() const = 0; + virtual UseColour::YesOrNo useColour() const = 0; + virtual std::vector const& getSectionsToRun() const = 0; + virtual Verbosity verbosity() const = 0; + + virtual bool benchmarkNoAnalysis() const = 0; + virtual int benchmarkSamples() const = 0; + virtual double benchmarkConfidenceInterval() const = 0; + virtual unsigned int benchmarkResamples() const = 0; + virtual std::chrono::milliseconds benchmarkWarmupTime() const = 0; + }; + + using IConfigPtr = std::shared_ptr; +} + +#endif // TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_interfaces_enum_values_registry.h b/lib/Catch2/include/internal/catch_interfaces_enum_values_registry.h new file mode 100644 index 0000000000..81592c9bd2 --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_enum_values_registry.h @@ -0,0 +1,46 @@ +/* + * Created by Phil on 4/4/2019. + * Copyright 2019 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_INTERFACESENUMVALUESREGISTRY_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACESENUMVALUESREGISTRY_H_INCLUDED + +#include "catch_stringref.h" + +#include + +namespace Catch { + + namespace Detail { + struct EnumInfo { + StringRef m_name; + std::vector> m_values; + + ~EnumInfo(); + + StringRef lookup( int value ) const; + }; + } // namespace Detail + + struct IMutableEnumValuesRegistry { + virtual ~IMutableEnumValuesRegistry(); + + virtual Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector const& values ) = 0; + + template + Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::initializer_list values ) { + static_assert(sizeof(int) >= sizeof(E), "Cannot serialize enum to int"); + std::vector intValues; + intValues.reserve( values.size() ); + for( auto enumValue : values ) + intValues.push_back( static_cast( enumValue ) ); + return registerEnum( enumName, allEnums, intValues ); + } + }; + +} // Catch + +#endif //TWOBLUECUBES_CATCH_INTERFACESENUMVALUESREGISTRY_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_interfaces_exception.cpp b/lib/Catch2/include/internal/catch_interfaces_exception.cpp new file mode 100644 index 0000000000..705d8c87a6 --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_exception.cpp @@ -0,0 +1,6 @@ +#include "catch_interfaces_exception.h" + +namespace Catch { + IExceptionTranslator::~IExceptionTranslator() = default; + IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() = default; +} diff --git a/lib/Catch2/include/internal/catch_interfaces_exception.h b/lib/Catch2/include/internal/catch_interfaces_exception.h new file mode 100644 index 0000000000..43840ea090 --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_exception.h @@ -0,0 +1,88 @@ +/* + * Created by Phil on 20/04/2011. + * Copyright 2011 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED + +#include "catch_interfaces_registry_hub.h" + +#if defined(CATCH_CONFIG_DISABLE) + #define INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( translatorName, signature) \ + static std::string translatorName( signature ) +#endif + +#include +#include +#include + +namespace Catch { + using exceptionTranslateFunction = std::string(*)(); + + struct IExceptionTranslator; + using ExceptionTranslators = std::vector>; + + struct IExceptionTranslator { + virtual ~IExceptionTranslator(); + virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0; + }; + + struct IExceptionTranslatorRegistry { + virtual ~IExceptionTranslatorRegistry(); + + virtual std::string translateActiveException() const = 0; + }; + + class ExceptionTranslatorRegistrar { + template + class ExceptionTranslator : public IExceptionTranslator { + public: + + ExceptionTranslator( std::string(*translateFunction)( T& ) ) + : m_translateFunction( translateFunction ) + {} + + std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const override { +#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + return ""; +#else + try { + if( it == itEnd ) + std::rethrow_exception(std::current_exception()); + else + return (*it)->translate( it+1, itEnd ); + } + catch( T& ex ) { + return m_translateFunction( ex ); + } +#endif + } + + protected: + std::string(*m_translateFunction)( T& ); + }; + + public: + template + ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) { + getMutableRegistryHub().registerTranslator + ( new ExceptionTranslator( translateFunction ) ); + } + }; +} + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \ + static std::string translatorName( signature ); \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + static std::string translatorName( signature ) + +#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) + +#endif // TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_interfaces_generatortracker.h b/lib/Catch2/include/internal/catch_interfaces_generatortracker.h new file mode 100644 index 0000000000..c1b1391ff1 --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_generatortracker.h @@ -0,0 +1,39 @@ +/* + * Created by Phil Nash on 26/6/2018. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#ifndef TWOBLUECUBES_CATCH_INTERFACES_GENERATORTRACKER_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_GENERATORTRACKER_INCLUDED + +#include + +namespace Catch { + + namespace Generators { + class GeneratorUntypedBase { + public: + GeneratorUntypedBase() = default; + virtual ~GeneratorUntypedBase(); + // Attempts to move the generator to the next element + // + // Returns true iff the move succeeded (and a valid element + // can be retrieved). + virtual bool next() = 0; + }; + using GeneratorBasePtr = std::unique_ptr; + + } // namespace Generators + + struct IGeneratorTracker { + virtual ~IGeneratorTracker(); + virtual auto hasGenerator() const -> bool = 0; + virtual auto getGenerator() const -> Generators::GeneratorBasePtr const& = 0; + virtual void setGenerator( Generators::GeneratorBasePtr&& generator ) = 0; + }; + +} // namespace Catch + +#endif //TWOBLUECUBES_CATCH_INTERFACES_GENERATORTRACKER_INCLUDED diff --git a/lib/Catch2/include/internal/catch_interfaces_registry_hub.cpp b/lib/Catch2/include/internal/catch_interfaces_registry_hub.cpp new file mode 100644 index 0000000000..7a22d649e9 --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_registry_hub.cpp @@ -0,0 +1,6 @@ +#include "catch_interfaces_registry_hub.h" + +namespace Catch { + IRegistryHub::~IRegistryHub() = default; + IMutableRegistryHub::~IMutableRegistryHub() = default; +} diff --git a/lib/Catch2/include/internal/catch_interfaces_registry_hub.h b/lib/Catch2/include/internal/catch_interfaces_registry_hub.h new file mode 100644 index 0000000000..19ffbf2635 --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_registry_hub.h @@ -0,0 +1,61 @@ +/* + * Created by Phil on 5/8/2012. + * Copyright 2012 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED + +#include "catch_common.h" + +#include +#include + +namespace Catch { + + class TestCase; + struct ITestCaseRegistry; + struct IExceptionTranslatorRegistry; + struct IExceptionTranslator; + struct IReporterRegistry; + struct IReporterFactory; + struct ITagAliasRegistry; + struct IMutableEnumValuesRegistry; + + class StartupExceptionRegistry; + + using IReporterFactoryPtr = std::shared_ptr; + + struct IRegistryHub { + virtual ~IRegistryHub(); + + virtual IReporterRegistry const& getReporterRegistry() const = 0; + virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; + virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0; + virtual IExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const = 0; + + + virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0; + }; + + struct IMutableRegistryHub { + virtual ~IMutableRegistryHub(); + virtual void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) = 0; + virtual void registerListener( IReporterFactoryPtr const& factory ) = 0; + virtual void registerTest( TestCase const& testInfo ) = 0; + virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; + virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0; + virtual void registerStartupException() noexcept = 0; + virtual IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() = 0; + }; + + IRegistryHub const& getRegistryHub(); + IMutableRegistryHub& getMutableRegistryHub(); + void cleanUp(); + std::string translateActiveException(); + +} + +#endif // TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_interfaces_reporter.cpp b/lib/Catch2/include/internal/catch_interfaces_reporter.cpp new file mode 100644 index 0000000000..0c367c5bce --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_reporter.cpp @@ -0,0 +1,114 @@ +/* + * Created by Martin on 19/07/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_interfaces_reporter.h" +#include "../reporters/catch_reporter_listening.h" + +namespace Catch { + + ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig ) + : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {} + + ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream ) + : m_stream( &_stream ), m_fullConfig( _fullConfig ) {} + + std::ostream& ReporterConfig::stream() const { return *m_stream; } + IConfigPtr ReporterConfig::fullConfig() const { return m_fullConfig; } + + + TestRunInfo::TestRunInfo( std::string const& _name ) : name( _name ) {} + + GroupInfo::GroupInfo( std::string const& _name, + std::size_t _groupIndex, + std::size_t _groupsCount ) + : name( _name ), + groupIndex( _groupIndex ), + groupsCounts( _groupsCount ) + {} + + AssertionStats::AssertionStats( AssertionResult const& _assertionResult, + std::vector const& _infoMessages, + Totals const& _totals ) + : assertionResult( _assertionResult ), + infoMessages( _infoMessages ), + totals( _totals ) + { + assertionResult.m_resultData.lazyExpression.m_transientExpression = _assertionResult.m_resultData.lazyExpression.m_transientExpression; + + if( assertionResult.hasMessage() ) { + // Copy message into messages list. + // !TBD This should have been done earlier, somewhere + MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() ); + builder << assertionResult.getMessage(); + builder.m_info.message = builder.m_stream.str(); + + infoMessages.push_back( builder.m_info ); + } + } + + AssertionStats::~AssertionStats() = default; + + SectionStats::SectionStats( SectionInfo const& _sectionInfo, + Counts const& _assertions, + double _durationInSeconds, + bool _missingAssertions ) + : sectionInfo( _sectionInfo ), + assertions( _assertions ), + durationInSeconds( _durationInSeconds ), + missingAssertions( _missingAssertions ) + {} + + SectionStats::~SectionStats() = default; + + + TestCaseStats::TestCaseStats( TestCaseInfo const& _testInfo, + Totals const& _totals, + std::string const& _stdOut, + std::string const& _stdErr, + bool _aborting ) + : testInfo( _testInfo ), + totals( _totals ), + stdOut( _stdOut ), + stdErr( _stdErr ), + aborting( _aborting ) + {} + + TestCaseStats::~TestCaseStats() = default; + + + TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo, + Totals const& _totals, + bool _aborting ) + : groupInfo( _groupInfo ), + totals( _totals ), + aborting( _aborting ) + {} + + TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo ) + : groupInfo( _groupInfo ), + aborting( false ) + {} + + TestGroupStats::~TestGroupStats() = default; + + TestRunStats::TestRunStats( TestRunInfo const& _runInfo, + Totals const& _totals, + bool _aborting ) + : runInfo( _runInfo ), + totals( _totals ), + aborting( _aborting ) + {} + + TestRunStats::~TestRunStats() = default; + + void IStreamingReporter::fatalErrorEncountered( StringRef ) {} + bool IStreamingReporter::isMulti() const { return false; } + + IReporterFactory::~IReporterFactory() = default; + IReporterRegistry::~IReporterRegistry() = default; + +} // end namespace Catch diff --git a/lib/Catch2/include/internal/catch_interfaces_reporter.h b/lib/Catch2/include/internal/catch_interfaces_reporter.h new file mode 100644 index 0000000000..751ef2c240 --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_reporter.h @@ -0,0 +1,270 @@ +/* + * Created by Phil on 31/12/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED + +#include "catch_section_info.h" +#include "catch_common.h" +#include "catch_config.hpp" +#include "catch_totals.h" +#include "catch_test_case_info.h" +#include "catch_assertionresult.h" +#include "catch_message.h" +#include "catch_option.hpp" +#include "catch_stringref.h" + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) +#include "benchmark/catch_estimate.hpp" +#include "benchmark/catch_outlier_classification.hpp" +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + +#include +#include +#include +#include +#include +#include + +namespace Catch { + + struct ReporterConfig { + explicit ReporterConfig( IConfigPtr const& _fullConfig ); + + ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream ); + + std::ostream& stream() const; + IConfigPtr fullConfig() const; + + private: + std::ostream* m_stream; + IConfigPtr m_fullConfig; + }; + + struct ReporterPreferences { + bool shouldRedirectStdOut = false; + bool shouldReportAllAssertions = false; + }; + + template + struct LazyStat : Option { + LazyStat& operator=( T const& _value ) { + Option::operator=( _value ); + used = false; + return *this; + } + void reset() { + Option::reset(); + used = false; + } + bool used = false; + }; + + struct TestRunInfo { + TestRunInfo( std::string const& _name ); + std::string name; + }; + struct GroupInfo { + GroupInfo( std::string const& _name, + std::size_t _groupIndex, + std::size_t _groupsCount ); + + std::string name; + std::size_t groupIndex; + std::size_t groupsCounts; + }; + + struct AssertionStats { + AssertionStats( AssertionResult const& _assertionResult, + std::vector const& _infoMessages, + Totals const& _totals ); + + AssertionStats( AssertionStats const& ) = default; + AssertionStats( AssertionStats && ) = default; + AssertionStats& operator = ( AssertionStats const& ) = delete; + AssertionStats& operator = ( AssertionStats && ) = delete; + virtual ~AssertionStats(); + + AssertionResult assertionResult; + std::vector infoMessages; + Totals totals; + }; + + struct SectionStats { + SectionStats( SectionInfo const& _sectionInfo, + Counts const& _assertions, + double _durationInSeconds, + bool _missingAssertions ); + SectionStats( SectionStats const& ) = default; + SectionStats( SectionStats && ) = default; + SectionStats& operator = ( SectionStats const& ) = default; + SectionStats& operator = ( SectionStats && ) = default; + virtual ~SectionStats(); + + SectionInfo sectionInfo; + Counts assertions; + double durationInSeconds; + bool missingAssertions; + }; + + struct TestCaseStats { + TestCaseStats( TestCaseInfo const& _testInfo, + Totals const& _totals, + std::string const& _stdOut, + std::string const& _stdErr, + bool _aborting ); + + TestCaseStats( TestCaseStats const& ) = default; + TestCaseStats( TestCaseStats && ) = default; + TestCaseStats& operator = ( TestCaseStats const& ) = default; + TestCaseStats& operator = ( TestCaseStats && ) = default; + virtual ~TestCaseStats(); + + TestCaseInfo testInfo; + Totals totals; + std::string stdOut; + std::string stdErr; + bool aborting; + }; + + struct TestGroupStats { + TestGroupStats( GroupInfo const& _groupInfo, + Totals const& _totals, + bool _aborting ); + TestGroupStats( GroupInfo const& _groupInfo ); + + TestGroupStats( TestGroupStats const& ) = default; + TestGroupStats( TestGroupStats && ) = default; + TestGroupStats& operator = ( TestGroupStats const& ) = default; + TestGroupStats& operator = ( TestGroupStats && ) = default; + virtual ~TestGroupStats(); + + GroupInfo groupInfo; + Totals totals; + bool aborting; + }; + + struct TestRunStats { + TestRunStats( TestRunInfo const& _runInfo, + Totals const& _totals, + bool _aborting ); + + TestRunStats( TestRunStats const& ) = default; + TestRunStats( TestRunStats && ) = default; + TestRunStats& operator = ( TestRunStats const& ) = default; + TestRunStats& operator = ( TestRunStats && ) = default; + virtual ~TestRunStats(); + + TestRunInfo runInfo; + Totals totals; + bool aborting; + }; + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + struct BenchmarkInfo { + std::string name; + double estimatedDuration; + int iterations; + int samples; + unsigned int resamples; + double clockResolution; + double clockCost; + }; + + template + struct BenchmarkStats { + BenchmarkInfo info; + + std::vector samples; + Benchmark::Estimate mean; + Benchmark::Estimate standardDeviation; + Benchmark::OutlierClassification outliers; + double outlierVariance; + + template + operator BenchmarkStats() const { + std::vector samples2; + samples2.reserve(samples.size()); + std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](Duration d) { return Duration2(d); }); + return { + info, + std::move(samples2), + mean, + standardDeviation, + outliers, + outlierVariance, + }; + } + }; +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + struct IStreamingReporter { + virtual ~IStreamingReporter() = default; + + // Implementing class must also provide the following static methods: + // static std::string getDescription(); + // static std::set getSupportedVerbosities() + + virtual ReporterPreferences getPreferences() const = 0; + + virtual void noMatchingTestCases( std::string const& spec ) = 0; + + virtual void reportInvalidArguments(std::string const&) {} + + virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; + virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0; + + virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; + virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; + +#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) + virtual void benchmarkPreparing( std::string const& ) {} + virtual void benchmarkStarting( BenchmarkInfo const& ) {} + virtual void benchmarkEnded( BenchmarkStats<> const& ) {} + virtual void benchmarkFailed( std::string const& ) {} +#endif // CATCH_CONFIG_ENABLE_BENCHMARKING + + virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; + + // The return value indicates if the messages buffer should be cleared: + virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0; + + virtual void sectionEnded( SectionStats const& sectionStats ) = 0; + virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; + virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0; + virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; + + virtual void skipTest( TestCaseInfo const& testInfo ) = 0; + + // Default empty implementation provided + virtual void fatalErrorEncountered( StringRef name ); + + virtual bool isMulti() const; + }; + using IStreamingReporterPtr = std::unique_ptr; + + struct IReporterFactory { + virtual ~IReporterFactory(); + virtual IStreamingReporterPtr create( ReporterConfig const& config ) const = 0; + virtual std::string getDescription() const = 0; + }; + using IReporterFactoryPtr = std::shared_ptr; + + struct IReporterRegistry { + using FactoryMap = std::map; + using Listeners = std::vector; + + virtual ~IReporterRegistry(); + virtual IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const = 0; + virtual FactoryMap const& getFactories() const = 0; + virtual Listeners const& getListeners() const = 0; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_interfaces_runner.cpp b/lib/Catch2/include/internal/catch_interfaces_runner.cpp new file mode 100644 index 0000000000..8d419a1447 --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_runner.cpp @@ -0,0 +1,5 @@ +#include "catch_interfaces_runner.h" + +namespace Catch { + IRunner::~IRunner() = default; +} diff --git a/lib/Catch2/include/internal/catch_interfaces_runner.h b/lib/Catch2/include/internal/catch_interfaces_runner.h new file mode 100644 index 0000000000..a0deaf7e66 --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_runner.h @@ -0,0 +1,19 @@ +/* + * Created by Phil on 07/01/2011. + * Copyright 2011 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED + +namespace Catch { + + struct IRunner { + virtual ~IRunner(); + virtual bool aborting() const = 0; + }; +} + +#endif // TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_interfaces_tag_alias_registry.h b/lib/Catch2/include/internal/catch_interfaces_tag_alias_registry.h new file mode 100644 index 0000000000..24bc535ce8 --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_tag_alias_registry.h @@ -0,0 +1,28 @@ +/* + * Created by Phil on 27/6/2014. + * Copyright 2014 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_INTERFACES_TAG_ALIAS_REGISTRY_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_TAG_ALIAS_REGISTRY_H_INCLUDED + +#include + +namespace Catch { + + struct TagAlias; + + struct ITagAliasRegistry { + virtual ~ITagAliasRegistry(); + // Nullptr if not present + virtual TagAlias const* find( std::string const& alias ) const = 0; + virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; + + static ITagAliasRegistry const& get(); + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_INTERFACES_TAG_ALIAS_REGISTRY_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_interfaces_testcase.cpp b/lib/Catch2/include/internal/catch_interfaces_testcase.cpp new file mode 100644 index 0000000000..9b35e0342f --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_testcase.cpp @@ -0,0 +1,6 @@ +#include "catch_interfaces_testcase.h" + +namespace Catch { + ITestInvoker::~ITestInvoker() = default; + ITestCaseRegistry::~ITestCaseRegistry() = default; +} diff --git a/lib/Catch2/include/internal/catch_interfaces_testcase.h b/lib/Catch2/include/internal/catch_interfaces_testcase.h new file mode 100644 index 0000000000..2492c07de6 --- /dev/null +++ b/lib/Catch2/include/internal/catch_interfaces_testcase.h @@ -0,0 +1,38 @@ +/* + * Created by Phil on 07/01/2011. + * Copyright 2011 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED + +#include + +namespace Catch { + + class TestSpec; + + struct ITestInvoker { + virtual void invoke () const = 0; + virtual ~ITestInvoker(); + }; + + class TestCase; + struct IConfig; + + struct ITestCaseRegistry { + virtual ~ITestCaseRegistry(); + virtual std::vector const& getAllTests() const = 0; + virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; + }; + + bool isThrowSafe( TestCase const& testCase, IConfig const& config ); + bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); + std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); + std::vector const& getAllTestCasesSorted( IConfig const& config ); + +} + +#endif // TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_leak_detector.cpp b/lib/Catch2/include/internal/catch_leak_detector.cpp new file mode 100644 index 0000000000..7a30e8a140 --- /dev/null +++ b/lib/Catch2/include/internal/catch_leak_detector.cpp @@ -0,0 +1,37 @@ +/* + * Created by Martin on 12/07/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + #include "catch_leak_detector.h" + #include "catch_interfaces_registry_hub.h" + + +#ifdef CATCH_CONFIG_WINDOWS_CRTDBG +#include + +namespace Catch { + + LeakDetector::LeakDetector() { + int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); + flag |= _CRTDBG_LEAK_CHECK_DF; + flag |= _CRTDBG_ALLOC_MEM_DF; + _CrtSetDbgFlag(flag); + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); + // Change this to leaking allocation's number to break there + _CrtSetBreakAlloc(-1); + } +} + +#else + + Catch::LeakDetector::LeakDetector() {} + +#endif + +Catch::LeakDetector::~LeakDetector() { + Catch::cleanUp(); +} diff --git a/lib/Catch2/include/internal/catch_leak_detector.h b/lib/Catch2/include/internal/catch_leak_detector.h new file mode 100644 index 0000000000..633457ac8f --- /dev/null +++ b/lib/Catch2/include/internal/catch_leak_detector.h @@ -0,0 +1,18 @@ +/* + * Created by Martin on 12/07/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_LEAK_DETECTOR_H_INCLUDED +#define TWOBLUECUBES_CATCH_LEAK_DETECTOR_H_INCLUDED + +namespace Catch { + + struct LeakDetector { + LeakDetector(); + ~LeakDetector(); + }; + +} +#endif // TWOBLUECUBES_CATCH_LEAK_DETECTOR_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_list.cpp b/lib/Catch2/include/internal/catch_list.cpp new file mode 100644 index 0000000000..9f748e4ca3 --- /dev/null +++ b/lib/Catch2/include/internal/catch_list.cpp @@ -0,0 +1,173 @@ +/* + * Created by Phil on 5/11/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_list.h" + +#include "catch_interfaces_registry_hub.h" +#include "catch_interfaces_reporter.h" +#include "catch_interfaces_testcase.h" + +#include "catch_context.h" +#include "catch_stream.h" +#include "catch_text.h" + +#include "catch_console_colour.h" +#include "catch_test_spec_parser.h" +#include "catch_tostring.h" +#include "catch_string_manip.h" + +#include +#include +#include + +namespace Catch { + + std::size_t listTests( Config const& config ) { + TestSpec const& testSpec = config.testSpec(); + if( config.hasTestFilters() ) + Catch::cout() << "Matching test cases:\n"; + else { + Catch::cout() << "All available test cases:\n"; + } + + auto matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); + for( auto const& testCaseInfo : matchedTestCases ) { + Colour::Code colour = testCaseInfo.isHidden() + ? Colour::SecondaryText + : Colour::None; + Colour colourGuard( colour ); + + Catch::cout() << Column( testCaseInfo.name ).initialIndent( 2 ).indent( 4 ) << "\n"; + if( config.verbosity() >= Verbosity::High ) { + Catch::cout() << Column( Catch::Detail::stringify( testCaseInfo.lineInfo ) ).indent(4) << std::endl; + std::string description = testCaseInfo.description; + if( description.empty() ) + description = "(NO DESCRIPTION)"; + Catch::cout() << Column( description ).indent(4) << std::endl; + } + if( !testCaseInfo.tags.empty() ) + Catch::cout() << Column( testCaseInfo.tagsAsString() ).indent( 6 ) << "\n"; + } + + if( !config.hasTestFilters() ) + Catch::cout() << pluralise( matchedTestCases.size(), "test case" ) << '\n' << std::endl; + else + Catch::cout() << pluralise( matchedTestCases.size(), "matching test case" ) << '\n' << std::endl; + return matchedTestCases.size(); + } + + std::size_t listTestsNamesOnly( Config const& config ) { + TestSpec const& testSpec = config.testSpec(); + std::size_t matchedTests = 0; + std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); + for( auto const& testCaseInfo : matchedTestCases ) { + matchedTests++; + if( startsWith( testCaseInfo.name, '#' ) ) + Catch::cout() << '"' << testCaseInfo.name << '"'; + else + Catch::cout() << testCaseInfo.name; + if ( config.verbosity() >= Verbosity::High ) + Catch::cout() << "\t@" << testCaseInfo.lineInfo; + Catch::cout() << std::endl; + } + return matchedTests; + } + + void TagInfo::add( std::string const& spelling ) { + ++count; + spellings.insert( spelling ); + } + + std::string TagInfo::all() const { + size_t size = 0; + for (auto const& spelling : spellings) { + // Add 2 for the brackes + size += spelling.size() + 2; + } + + std::string out; out.reserve(size); + for (auto const& spelling : spellings) { + out += '['; + out += spelling; + out += ']'; + } + return out; + } + + std::size_t listTags( Config const& config ) { + TestSpec const& testSpec = config.testSpec(); + if( config.hasTestFilters() ) + Catch::cout() << "Tags for matching test cases:\n"; + else { + Catch::cout() << "All available tags:\n"; + } + + std::map tagCounts; + + std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); + for( auto const& testCase : matchedTestCases ) { + for( auto const& tagName : testCase.getTestCaseInfo().tags ) { + std::string lcaseTagName = toLower( tagName ); + auto countIt = tagCounts.find( lcaseTagName ); + if( countIt == tagCounts.end() ) + countIt = tagCounts.insert( std::make_pair( lcaseTagName, TagInfo() ) ).first; + countIt->second.add( tagName ); + } + } + + for( auto const& tagCount : tagCounts ) { + ReusableStringStream rss; + rss << " " << std::setw(2) << tagCount.second.count << " "; + auto str = rss.str(); + auto wrapper = Column( tagCount.second.all() ) + .initialIndent( 0 ) + .indent( str.size() ) + .width( CATCH_CONFIG_CONSOLE_WIDTH-10 ); + Catch::cout() << str << wrapper << '\n'; + } + Catch::cout() << pluralise( tagCounts.size(), "tag" ) << '\n' << std::endl; + return tagCounts.size(); + } + + std::size_t listReporters() { + Catch::cout() << "Available reporters:\n"; + IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories(); + std::size_t maxNameLen = 0; + for( auto const& factoryKvp : factories ) + maxNameLen = (std::max)( maxNameLen, factoryKvp.first.size() ); + + for( auto const& factoryKvp : factories ) { + Catch::cout() + << Column( factoryKvp.first + ":" ) + .indent(2) + .width( 5+maxNameLen ) + + Column( factoryKvp.second->getDescription() ) + .initialIndent(0) + .indent(2) + .width( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 ) + << "\n"; + } + Catch::cout() << std::endl; + return factories.size(); + } + + Option list( std::shared_ptr const& config ) { + Option listedCount; + getCurrentMutableContext().setConfig( config ); + if( config->listTests() ) + listedCount = listedCount.valueOr(0) + listTests( *config ); + if( config->listTestNamesOnly() ) + listedCount = listedCount.valueOr(0) + listTestsNamesOnly( *config ); + if( config->listTags() ) + listedCount = listedCount.valueOr(0) + listTags( *config ); + if( config->listReporters() ) + listedCount = listedCount.valueOr(0) + listReporters(); + return listedCount; + } + +} // end namespace Catch diff --git a/lib/Catch2/include/internal/catch_list.h b/lib/Catch2/include/internal/catch_list.h new file mode 100644 index 0000000000..cea7bbabf2 --- /dev/null +++ b/lib/Catch2/include/internal/catch_list.h @@ -0,0 +1,38 @@ +/* + * Created by Phil on 5/11/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_LIST_H_INCLUDED +#define TWOBLUECUBES_CATCH_LIST_H_INCLUDED + +#include "catch_option.hpp" +#include "catch_config.hpp" + +#include + +namespace Catch { + + std::size_t listTests( Config const& config ); + + std::size_t listTestsNamesOnly( Config const& config ); + + struct TagInfo { + void add( std::string const& spelling ); + std::string all() const; + + std::set spellings; + std::size_t count = 0; + }; + + std::size_t listTags( Config const& config ); + + std::size_t listReporters(); + + Option list( std::shared_ptr const& config ); + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_LIST_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_matchers.cpp b/lib/Catch2/include/internal/catch_matchers.cpp new file mode 100644 index 0000000000..32104a1123 --- /dev/null +++ b/lib/Catch2/include/internal/catch_matchers.cpp @@ -0,0 +1,28 @@ +/* + * Created by Phil Nash on 19/07/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_matchers.h" + +namespace Catch { +namespace Matchers { + namespace Impl { + + std::string MatcherUntypedBase::toString() const { + if( m_cachedToString.empty() ) + m_cachedToString = describe(); + return m_cachedToString; + } + + MatcherUntypedBase::~MatcherUntypedBase() = default; + + } // namespace Impl +} // namespace Matchers + +using namespace Matchers; +using Matchers::Impl::MatcherBase; + +} // namespace Catch diff --git a/lib/Catch2/include/internal/catch_matchers.h b/lib/Catch2/include/internal/catch_matchers.h new file mode 100644 index 0000000000..518a6e0d34 --- /dev/null +++ b/lib/Catch2/include/internal/catch_matchers.h @@ -0,0 +1,174 @@ +/* + * Created by Phil Nash on 04/03/2012. + * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED + +#include "catch_common.h" + +#include +#include + +namespace Catch { +namespace Matchers { + namespace Impl { + + template struct MatchAllOf; + template struct MatchAnyOf; + template struct MatchNotOf; + + class MatcherUntypedBase { + public: + MatcherUntypedBase() = default; + MatcherUntypedBase ( MatcherUntypedBase const& ) = default; + MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = delete; + std::string toString() const; + + protected: + virtual ~MatcherUntypedBase(); + virtual std::string describe() const = 0; + mutable std::string m_cachedToString; + }; + +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wnon-virtual-dtor" +#endif + + template + struct MatcherMethod { + virtual bool match( ObjectT const& arg ) const = 0; + }; + +#if defined(__OBJC__) + // Hack to fix Catch GH issue #1661. Could use id for generic Object support. + // use of const for Object pointers is very uncommon and under ARC it causes some kind of signature mismatch that breaks compilation + template<> + struct MatcherMethod { + virtual bool match( NSString* arg ) const = 0; + }; +#endif + +#ifdef __clang__ +# pragma clang diagnostic pop +#endif + + template + struct MatcherBase : MatcherUntypedBase, MatcherMethod { + + + MatchAllOf operator && ( MatcherBase const& other ) const; + MatchAnyOf operator || ( MatcherBase const& other ) const; + MatchNotOf operator ! () const; + }; + + template + struct MatchAllOf : MatcherBase { + bool match( ArgT const& arg ) const override { + for( auto matcher : m_matchers ) { + if (!matcher->match(arg)) + return false; + } + return true; + } + std::string describe() const override { + std::string description; + description.reserve( 4 + m_matchers.size()*32 ); + description += "( "; + bool first = true; + for( auto matcher : m_matchers ) { + if( first ) + first = false; + else + description += " and "; + description += matcher->toString(); + } + description += " )"; + return description; + } + + MatchAllOf operator && ( MatcherBase const& other ) { + auto copy(*this); + copy.m_matchers.push_back( &other ); + return copy; + } + + std::vector const*> m_matchers; + }; + template + struct MatchAnyOf : MatcherBase { + + bool match( ArgT const& arg ) const override { + for( auto matcher : m_matchers ) { + if (matcher->match(arg)) + return true; + } + return false; + } + std::string describe() const override { + std::string description; + description.reserve( 4 + m_matchers.size()*32 ); + description += "( "; + bool first = true; + for( auto matcher : m_matchers ) { + if( first ) + first = false; + else + description += " or "; + description += matcher->toString(); + } + description += " )"; + return description; + } + + MatchAnyOf operator || ( MatcherBase const& other ) { + auto copy(*this); + copy.m_matchers.push_back( &other ); + return copy; + } + + std::vector const*> m_matchers; + }; + + template + struct MatchNotOf : MatcherBase { + + MatchNotOf( MatcherBase const& underlyingMatcher ) : m_underlyingMatcher( underlyingMatcher ) {} + + bool match( ArgT const& arg ) const override { + return !m_underlyingMatcher.match( arg ); + } + + std::string describe() const override { + return "not " + m_underlyingMatcher.toString(); + } + MatcherBase const& m_underlyingMatcher; + }; + + template + MatchAllOf MatcherBase::operator && ( MatcherBase const& other ) const { + return MatchAllOf() && *this && other; + } + template + MatchAnyOf MatcherBase::operator || ( MatcherBase const& other ) const { + return MatchAnyOf() || *this || other; + } + template + MatchNotOf MatcherBase::operator ! () const { + return MatchNotOf( *this ); + } + + } // namespace Impl + +} // namespace Matchers + +using namespace Matchers; +using Matchers::Impl::MatcherBase; + +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_matchers_exception.cpp b/lib/Catch2/include/internal/catch_matchers_exception.cpp new file mode 100644 index 0000000000..b18810e828 --- /dev/null +++ b/lib/Catch2/include/internal/catch_matchers_exception.cpp @@ -0,0 +1,30 @@ +/* + * Created by Martin Hořeňovský on 13/10/2019. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_matchers_exception.hpp" + + +namespace Catch { +namespace Matchers { +namespace Exception { + +bool ExceptionMessageMatcher::match(std::exception const& ex) const { + return ex.what() == m_message; +} + +std::string ExceptionMessageMatcher::describe() const { + return "exception message matches \"" + m_message + "\""; +} + +} +Exception::ExceptionMessageMatcher Message(std::string const& message) { + return Exception::ExceptionMessageMatcher(message); +} + +// namespace Exception +} // namespace Matchers +} // namespace Catch diff --git a/lib/Catch2/include/internal/catch_matchers_exception.hpp b/lib/Catch2/include/internal/catch_matchers_exception.hpp new file mode 100644 index 0000000000..a80b3607b1 --- /dev/null +++ b/lib/Catch2/include/internal/catch_matchers_exception.hpp @@ -0,0 +1,36 @@ +/* + * Created by Martin Hořeňovský on 13/10/2019. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_MATCHERS_EXCEPTION_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_MATCHERS_EXCEPTION_HPP_INCLUDED + +#include "catch_matchers.h" + +namespace Catch { +namespace Matchers { +namespace Exception { + +class ExceptionMessageMatcher : public MatcherBase { + std::string m_message; +public: + + ExceptionMessageMatcher(std::string const& message): + m_message(message) + {} + + bool match(std::exception const& ex) const override; + + std::string describe() const override; +}; + +} // namespace Exception + +Exception::ExceptionMessageMatcher Message(std::string const& message); + +} // namespace Matchers +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_MATCHERS_EXCEPTION_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_matchers_floating.cpp b/lib/Catch2/include/internal/catch_matchers_floating.cpp new file mode 100644 index 0000000000..6fefe9875c --- /dev/null +++ b/lib/Catch2/include/internal/catch_matchers_floating.cpp @@ -0,0 +1,237 @@ +/* + * Created by Martin on 07/11/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_matchers_floating.h" +#include "catch_enforce.h" +#include "catch_polyfills.hpp" +#include "catch_to_string.hpp" +#include "catch_tostring.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace Catch { +namespace { + + int32_t convert(float f) { + static_assert(sizeof(float) == sizeof(int32_t), "Important ULP matcher assumption violated"); + int32_t i; + std::memcpy(&i, &f, sizeof(f)); + return i; + } + + int64_t convert(double d) { + static_assert(sizeof(double) == sizeof(int64_t), "Important ULP matcher assumption violated"); + int64_t i; + std::memcpy(&i, &d, sizeof(d)); + return i; + } + + template + bool almostEqualUlps(FP lhs, FP rhs, uint64_t maxUlpDiff) { + // Comparison with NaN should always be false. + // This way we can rule it out before getting into the ugly details + if (Catch::isnan(lhs) || Catch::isnan(rhs)) { + return false; + } + + auto lc = convert(lhs); + auto rc = convert(rhs); + + if ((lc < 0) != (rc < 0)) { + // Potentially we can have +0 and -0 + return lhs == rhs; + } + + // static cast as a workaround for IBM XLC + auto ulpDiff = std::abs(static_cast(lc - rc)); + return static_cast(ulpDiff) <= maxUlpDiff; + } + +#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) + + float nextafter(float x, float y) { + return ::nextafterf(x, y); + } + + double nextafter(double x, double y) { + return ::nextafter(x, y); + } + +#endif // ^^^ CATCH_CONFIG_GLOBAL_NEXTAFTER ^^^ + +template +FP step(FP start, FP direction, uint64_t steps) { + for (uint64_t i = 0; i < steps; ++i) { +#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) + start = Catch::nextafter(start, direction); +#else + start = std::nextafter(start, direction); +#endif + } + return start; +} + +// Performs equivalent check of std::fabs(lhs - rhs) <= margin +// But without the subtraction to allow for INFINITY in comparison +bool marginComparison(double lhs, double rhs, double margin) { + return (lhs + margin >= rhs) && (rhs + margin >= lhs); +} + +template +void write(std::ostream& out, FloatingPoint num) { + out << std::scientific + << std::setprecision(std::numeric_limits::max_digits10 - 1) + << num; +} + +} // end anonymous namespace + +namespace Matchers { +namespace Floating { + + enum class FloatingPointKind : uint8_t { + Float, + Double + }; + + + WithinAbsMatcher::WithinAbsMatcher(double target, double margin) + :m_target{ target }, m_margin{ margin } { + CATCH_ENFORCE(margin >= 0, "Invalid margin: " << margin << '.' + << " Margin has to be non-negative."); + } + + // Performs equivalent check of std::fabs(lhs - rhs) <= margin + // But without the subtraction to allow for INFINITY in comparison + bool WithinAbsMatcher::match(double const& matchee) const { + return (matchee + m_margin >= m_target) && (m_target + m_margin >= matchee); + } + + std::string WithinAbsMatcher::describe() const { + return "is within " + ::Catch::Detail::stringify(m_margin) + " of " + ::Catch::Detail::stringify(m_target); + } + + + WithinUlpsMatcher::WithinUlpsMatcher(double target, uint64_t ulps, FloatingPointKind baseType) + :m_target{ target }, m_ulps{ ulps }, m_type{ baseType } { + CATCH_ENFORCE(m_type == FloatingPointKind::Double + || m_ulps < (std::numeric_limits::max)(), + "Provided ULP is impossibly large for a float comparison."); + } + +#if defined(__clang__) +#pragma clang diagnostic push +// Clang <3.5 reports on the default branch in the switch below +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif + + bool WithinUlpsMatcher::match(double const& matchee) const { + switch (m_type) { + case FloatingPointKind::Float: + return almostEqualUlps(static_cast(matchee), static_cast(m_target), m_ulps); + case FloatingPointKind::Double: + return almostEqualUlps(matchee, m_target, m_ulps); + default: + CATCH_INTERNAL_ERROR( "Unknown FloatingPointKind value" ); + } + } + +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + + std::string WithinUlpsMatcher::describe() const { + std::stringstream ret; + + ret << "is within " << m_ulps << " ULPs of "; + + if (m_type == FloatingPointKind::Float) { + write(ret, static_cast(m_target)); + ret << 'f'; + } else { + write(ret, m_target); + } + + ret << " (["; + if (m_type == FloatingPointKind::Double) { + write(ret, step(m_target, static_cast(-INFINITY), m_ulps)); + ret << ", "; + write(ret, step(m_target, static_cast( INFINITY), m_ulps)); + } else { + // We have to cast INFINITY to float because of MinGW, see #1782 + write(ret, step(static_cast(m_target), static_cast(-INFINITY), m_ulps)); + ret << ", "; + write(ret, step(static_cast(m_target), static_cast( INFINITY), m_ulps)); + } + ret << "])"; + + return ret.str(); + } + + WithinRelMatcher::WithinRelMatcher(double target, double epsilon): + m_target(target), + m_epsilon(epsilon){ + CATCH_ENFORCE(m_epsilon >= 0., "Relative comparison with epsilon < 0 does not make sense."); + CATCH_ENFORCE(m_epsilon < 1., "Relative comparison with epsilon >= 1 does not make sense."); + } + + bool WithinRelMatcher::match(double const& matchee) const { + const auto relMargin = m_epsilon * (std::max)(std::fabs(matchee), std::fabs(m_target)); + return marginComparison(matchee, m_target, + std::isinf(relMargin)? 0 : relMargin); + } + + std::string WithinRelMatcher::describe() const { + Catch::ReusableStringStream sstr; + sstr << "and " << m_target << " are within " << m_epsilon * 100. << "% of each other"; + return sstr.str(); + } + +}// namespace Floating + + + +Floating::WithinUlpsMatcher WithinULP(double target, uint64_t maxUlpDiff) { + return Floating::WithinUlpsMatcher(target, maxUlpDiff, Floating::FloatingPointKind::Double); +} + +Floating::WithinUlpsMatcher WithinULP(float target, uint64_t maxUlpDiff) { + return Floating::WithinUlpsMatcher(target, maxUlpDiff, Floating::FloatingPointKind::Float); +} + +Floating::WithinAbsMatcher WithinAbs(double target, double margin) { + return Floating::WithinAbsMatcher(target, margin); +} + +Floating::WithinRelMatcher WithinRel(double target, double eps) { + return Floating::WithinRelMatcher(target, eps); +} + +Floating::WithinRelMatcher WithinRel(double target) { + return Floating::WithinRelMatcher(target, std::numeric_limits::epsilon() * 100); +} + +Floating::WithinRelMatcher WithinRel(float target, float eps) { + return Floating::WithinRelMatcher(target, eps); +} + +Floating::WithinRelMatcher WithinRel(float target) { + return Floating::WithinRelMatcher(target, std::numeric_limits::epsilon() * 100); +} + + +} // namespace Matchers +} // namespace Catch diff --git a/lib/Catch2/include/internal/catch_matchers_floating.h b/lib/Catch2/include/internal/catch_matchers_floating.h new file mode 100644 index 0000000000..0f2ff49ff5 --- /dev/null +++ b/lib/Catch2/include/internal/catch_matchers_floating.h @@ -0,0 +1,70 @@ +/* + * Created by Martin on 07/11/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_MATCHERS_FLOATING_H_INCLUDED +#define TWOBLUECUBES_CATCH_MATCHERS_FLOATING_H_INCLUDED + +#include "catch_matchers.h" + +namespace Catch { +namespace Matchers { + + namespace Floating { + + enum class FloatingPointKind : uint8_t; + + struct WithinAbsMatcher : MatcherBase { + WithinAbsMatcher(double target, double margin); + bool match(double const& matchee) const override; + std::string describe() const override; + private: + double m_target; + double m_margin; + }; + + struct WithinUlpsMatcher : MatcherBase { + WithinUlpsMatcher(double target, uint64_t ulps, FloatingPointKind baseType); + bool match(double const& matchee) const override; + std::string describe() const override; + private: + double m_target; + uint64_t m_ulps; + FloatingPointKind m_type; + }; + + // Given IEEE-754 format for floats and doubles, we can assume + // that float -> double promotion is lossless. Given this, we can + // assume that if we do the standard relative comparison of + // |lhs - rhs| <= epsilon * max(fabs(lhs), fabs(rhs)), then we get + // the same result if we do this for floats, as if we do this for + // doubles that were promoted from floats. + struct WithinRelMatcher : MatcherBase { + WithinRelMatcher(double target, double epsilon); + bool match(double const& matchee) const override; + std::string describe() const override; + private: + double m_target; + double m_epsilon; + }; + + } // namespace Floating + + // The following functions create the actual matcher objects. + // This allows the types to be inferred + Floating::WithinUlpsMatcher WithinULP(double target, uint64_t maxUlpDiff); + Floating::WithinUlpsMatcher WithinULP(float target, uint64_t maxUlpDiff); + Floating::WithinAbsMatcher WithinAbs(double target, double margin); + Floating::WithinRelMatcher WithinRel(double target, double eps); + // defaults epsilon to 100*numeric_limits::epsilon() + Floating::WithinRelMatcher WithinRel(double target); + Floating::WithinRelMatcher WithinRel(float target, float eps); + // defaults epsilon to 100*numeric_limits::epsilon() + Floating::WithinRelMatcher WithinRel(float target); + +} // namespace Matchers +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_MATCHERS_FLOATING_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_matchers_generic.cpp b/lib/Catch2/include/internal/catch_matchers_generic.cpp new file mode 100644 index 0000000000..300102e0bd --- /dev/null +++ b/lib/Catch2/include/internal/catch_matchers_generic.cpp @@ -0,0 +1,9 @@ +#include "catch_matchers_generic.hpp" + +std::string Catch::Matchers::Generic::Detail::finalizeDescription(const std::string& desc) { + if (desc.empty()) { + return "matches undescribed predicate"; + } else { + return "matches predicate: \"" + desc + '"'; + } +} diff --git a/lib/Catch2/include/internal/catch_matchers_generic.hpp b/lib/Catch2/include/internal/catch_matchers_generic.hpp new file mode 100644 index 0000000000..7d57c9d441 --- /dev/null +++ b/lib/Catch2/include/internal/catch_matchers_generic.hpp @@ -0,0 +1,58 @@ +/* + * Created by Martin Hořeňovský on 03/04/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_MATCHERS_GENERIC_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_MATCHERS_GENERIC_HPP_INCLUDED + +#include "catch_common.h" +#include "catch_matchers.h" + +#include +#include + +namespace Catch { +namespace Matchers { +namespace Generic { + +namespace Detail { + std::string finalizeDescription(const std::string& desc); +} + +template +class PredicateMatcher : public MatcherBase { + std::function m_predicate; + std::string m_description; +public: + + PredicateMatcher(std::function const& elem, std::string const& descr) + :m_predicate(std::move(elem)), + m_description(Detail::finalizeDescription(descr)) + {} + + bool match( T const& item ) const override { + return m_predicate(item); + } + + std::string describe() const override { + return m_description; + } +}; + +} // namespace Generic + + // The following functions create the actual matcher objects. + // The user has to explicitly specify type to the function, because + // inferring std::function is hard (but possible) and + // requires a lot of TMP. + template + Generic::PredicateMatcher Predicate(std::function const& predicate, std::string const& description = "") { + return Generic::PredicateMatcher(predicate, description); + } + +} // namespace Matchers +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_MATCHERS_GENERIC_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_matchers_string.cpp b/lib/Catch2/include/internal/catch_matchers_string.cpp new file mode 100644 index 0000000000..1e3e72fdfe --- /dev/null +++ b/lib/Catch2/include/internal/catch_matchers_string.cpp @@ -0,0 +1,118 @@ +/* + * Created by Phil Nash on 08/02/2017. + * Copyright (c) 2017 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_matchers_string.h" +#include "catch_string_manip.h" +#include "catch_tostring.h" + +#include + +namespace Catch { +namespace Matchers { + + namespace StdString { + + CasedString::CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity ) + : m_caseSensitivity( caseSensitivity ), + m_str( adjustString( str ) ) + {} + std::string CasedString::adjustString( std::string const& str ) const { + return m_caseSensitivity == CaseSensitive::No + ? toLower( str ) + : str; + } + std::string CasedString::caseSensitivitySuffix() const { + return m_caseSensitivity == CaseSensitive::No + ? " (case insensitive)" + : std::string(); + } + + + StringMatcherBase::StringMatcherBase( std::string const& operation, CasedString const& comparator ) + : m_comparator( comparator ), + m_operation( operation ) { + } + + std::string StringMatcherBase::describe() const { + std::string description; + description.reserve(5 + m_operation.size() + m_comparator.m_str.size() + + m_comparator.caseSensitivitySuffix().size()); + description += m_operation; + description += ": \""; + description += m_comparator.m_str; + description += "\""; + description += m_comparator.caseSensitivitySuffix(); + return description; + } + + EqualsMatcher::EqualsMatcher( CasedString const& comparator ) : StringMatcherBase( "equals", comparator ) {} + + bool EqualsMatcher::match( std::string const& source ) const { + return m_comparator.adjustString( source ) == m_comparator.m_str; + } + + + ContainsMatcher::ContainsMatcher( CasedString const& comparator ) : StringMatcherBase( "contains", comparator ) {} + + bool ContainsMatcher::match( std::string const& source ) const { + return contains( m_comparator.adjustString( source ), m_comparator.m_str ); + } + + + StartsWithMatcher::StartsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "starts with", comparator ) {} + + bool StartsWithMatcher::match( std::string const& source ) const { + return startsWith( m_comparator.adjustString( source ), m_comparator.m_str ); + } + + + EndsWithMatcher::EndsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "ends with", comparator ) {} + + bool EndsWithMatcher::match( std::string const& source ) const { + return endsWith( m_comparator.adjustString( source ), m_comparator.m_str ); + } + + + + RegexMatcher::RegexMatcher(std::string regex, CaseSensitive::Choice caseSensitivity): m_regex(std::move(regex)), m_caseSensitivity(caseSensitivity) {} + + bool RegexMatcher::match(std::string const& matchee) const { + auto flags = std::regex::ECMAScript; // ECMAScript is the default syntax option anyway + if (m_caseSensitivity == CaseSensitive::Choice::No) { + flags |= std::regex::icase; + } + auto reg = std::regex(m_regex, flags); + return std::regex_match(matchee, reg); + } + + std::string RegexMatcher::describe() const { + return "matches " + ::Catch::Detail::stringify(m_regex) + ((m_caseSensitivity == CaseSensitive::Choice::Yes)? " case sensitively" : " case insensitively"); + } + + } // namespace StdString + + + StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::EqualsMatcher( StdString::CasedString( str, caseSensitivity) ); + } + StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::ContainsMatcher( StdString::CasedString( str, caseSensitivity) ); + } + StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::EndsWithMatcher( StdString::CasedString( str, caseSensitivity) ); + } + StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::StartsWithMatcher( StdString::CasedString( str, caseSensitivity) ); + } + + StdString::RegexMatcher Matches(std::string const& regex, CaseSensitive::Choice caseSensitivity) { + return StdString::RegexMatcher(regex, caseSensitivity); + } + +} // namespace Matchers +} // namespace Catch diff --git a/lib/Catch2/include/internal/catch_matchers_string.h b/lib/Catch2/include/internal/catch_matchers_string.h new file mode 100644 index 0000000000..fdbc03ce75 --- /dev/null +++ b/lib/Catch2/include/internal/catch_matchers_string.h @@ -0,0 +1,80 @@ +/* + * Created by Phil Nash on 08/02/2017. + * Copyright (c) 2017 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_MATCHERS_STRING_H_INCLUDED +#define TWOBLUECUBES_CATCH_MATCHERS_STRING_H_INCLUDED + +#include "catch_matchers.h" + +#include + +namespace Catch { +namespace Matchers { + + namespace StdString { + + struct CasedString + { + CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity ); + std::string adjustString( std::string const& str ) const; + std::string caseSensitivitySuffix() const; + + CaseSensitive::Choice m_caseSensitivity; + std::string m_str; + }; + + struct StringMatcherBase : MatcherBase { + StringMatcherBase( std::string const& operation, CasedString const& comparator ); + std::string describe() const override; + + CasedString m_comparator; + std::string m_operation; + }; + + struct EqualsMatcher : StringMatcherBase { + EqualsMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + struct ContainsMatcher : StringMatcherBase { + ContainsMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + struct StartsWithMatcher : StringMatcherBase { + StartsWithMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + struct EndsWithMatcher : StringMatcherBase { + EndsWithMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + + struct RegexMatcher : MatcherBase { + RegexMatcher( std::string regex, CaseSensitive::Choice caseSensitivity ); + bool match( std::string const& matchee ) const override; + std::string describe() const override; + + private: + std::string m_regex; + CaseSensitive::Choice m_caseSensitivity; + }; + + } // namespace StdString + + + // The following functions create the actual matcher objects. + // This allows the types to be inferred + + StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::RegexMatcher Matches( std::string const& regex, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + +} // namespace Matchers +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_MATCHERS_STRING_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_matchers_vector.h b/lib/Catch2/include/internal/catch_matchers_vector.h new file mode 100644 index 0000000000..bbe7c78475 --- /dev/null +++ b/lib/Catch2/include/internal/catch_matchers_vector.h @@ -0,0 +1,180 @@ +/* + * Created by Phil Nash on 21/02/2017. + * Copyright (c) 2017 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_MATCHERS_VECTOR_H_INCLUDED +#define TWOBLUECUBES_CATCH_MATCHERS_VECTOR_H_INCLUDED + +#include "catch_matchers.h" +#include "catch_approx.h" + +#include + +namespace Catch { +namespace Matchers { + + namespace Vector { + template + struct ContainsElementMatcher : MatcherBase> { + + ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {} + + bool match(std::vector const &v) const override { + for (auto const& el : v) { + if (el == m_comparator) { + return true; + } + } + return false; + } + + std::string describe() const override { + return "Contains: " + ::Catch::Detail::stringify( m_comparator ); + } + + T const& m_comparator; + }; + + template + struct ContainsMatcher : MatcherBase> { + + ContainsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} + + bool match(std::vector const &v) const override { + // !TBD: see note in EqualsMatcher + if (m_comparator.size() > v.size()) + return false; + for (auto const& comparator : m_comparator) { + auto present = false; + for (const auto& el : v) { + if (el == comparator) { + present = true; + break; + } + } + if (!present) { + return false; + } + } + return true; + } + std::string describe() const override { + return "Contains: " + ::Catch::Detail::stringify( m_comparator ); + } + + std::vector const& m_comparator; + }; + + template + struct EqualsMatcher : MatcherBase> { + + EqualsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} + + bool match(std::vector const &v) const override { + // !TBD: This currently works if all elements can be compared using != + // - a more general approach would be via a compare template that defaults + // to using !=. but could be specialised for, e.g. std::vector etc + // - then just call that directly + if (m_comparator.size() != v.size()) + return false; + for (std::size_t i = 0; i < v.size(); ++i) + if (m_comparator[i] != v[i]) + return false; + return true; + } + std::string describe() const override { + return "Equals: " + ::Catch::Detail::stringify( m_comparator ); + } + std::vector const& m_comparator; + }; + + template + struct ApproxMatcher : MatcherBase> { + + ApproxMatcher(std::vector const& comparator) : m_comparator( comparator ) {} + + bool match(std::vector const &v) const override { + if (m_comparator.size() != v.size()) + return false; + for (std::size_t i = 0; i < v.size(); ++i) + if (m_comparator[i] != approx(v[i])) + return false; + return true; + } + std::string describe() const override { + return "is approx: " + ::Catch::Detail::stringify( m_comparator ); + } + template ::value>::type> + ApproxMatcher& epsilon( T const& newEpsilon ) { + approx.epsilon(newEpsilon); + return *this; + } + template ::value>::type> + ApproxMatcher& margin( T const& newMargin ) { + approx.margin(newMargin); + return *this; + } + template ::value>::type> + ApproxMatcher& scale( T const& newScale ) { + approx.scale(newScale); + return *this; + } + + std::vector const& m_comparator; + mutable Catch::Detail::Approx approx = Catch::Detail::Approx::custom(); + }; + + template + struct UnorderedEqualsMatcher : MatcherBase> { + UnorderedEqualsMatcher(std::vector const& target) : m_target(target) {} + bool match(std::vector const& vec) const override { + if (m_target.size() != vec.size()) { + return false; + } + return std::is_permutation(m_target.begin(), m_target.end(), vec.begin()); + } + + std::string describe() const override { + return "UnorderedEquals: " + ::Catch::Detail::stringify(m_target); + } + private: + std::vector const& m_target; + }; + + } // namespace Vector + + // The following functions create the actual matcher objects. + // This allows the types to be inferred + + template, typename AllocMatch = AllocComp> + Vector::ContainsMatcher Contains( std::vector const& comparator ) { + return Vector::ContainsMatcher( comparator ); + } + + template> + Vector::ContainsElementMatcher VectorContains( T const& comparator ) { + return Vector::ContainsElementMatcher( comparator ); + } + + template, typename AllocMatch = AllocComp> + Vector::EqualsMatcher Equals( std::vector const& comparator ) { + return Vector::EqualsMatcher( comparator ); + } + + template, typename AllocMatch = AllocComp> + Vector::ApproxMatcher Approx( std::vector const& comparator ) { + return Vector::ApproxMatcher( comparator ); + } + + template, typename AllocMatch = AllocComp> + Vector::UnorderedEqualsMatcher UnorderedEquals(std::vector const& target) { + return Vector::UnorderedEqualsMatcher( target ); + } + +} // namespace Matchers +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_MATCHERS_VECTOR_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_message.cpp b/lib/Catch2/include/internal/catch_message.cpp new file mode 100644 index 0000000000..97983a1e8e --- /dev/null +++ b/lib/Catch2/include/internal/catch_message.cpp @@ -0,0 +1,142 @@ +/* + * Created by Phil Nash on 1/2/2013. + * Copyright 2013 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_message.h" +#include "catch_interfaces_capture.h" +#include "catch_uncaught_exceptions.h" +#include "catch_enforce.h" + +#include +#include + +namespace Catch { + + MessageInfo::MessageInfo( StringRef const& _macroName, + SourceLineInfo const& _lineInfo, + ResultWas::OfType _type ) + : macroName( _macroName ), + lineInfo( _lineInfo ), + type( _type ), + sequence( ++globalCount ) + {} + + bool MessageInfo::operator==( MessageInfo const& other ) const { + return sequence == other.sequence; + } + + bool MessageInfo::operator<( MessageInfo const& other ) const { + return sequence < other.sequence; + } + + // This may need protecting if threading support is added + unsigned int MessageInfo::globalCount = 0; + + + //////////////////////////////////////////////////////////////////////////// + + Catch::MessageBuilder::MessageBuilder( StringRef const& macroName, + SourceLineInfo const& lineInfo, + ResultWas::OfType type ) + :m_info(macroName, lineInfo, type) {} + + //////////////////////////////////////////////////////////////////////////// + + + ScopedMessage::ScopedMessage( MessageBuilder const& builder ) + : m_info( builder.m_info ), m_moved() + { + m_info.message = builder.m_stream.str(); + getResultCapture().pushScopedMessage( m_info ); + } + + ScopedMessage::ScopedMessage( ScopedMessage&& old ) + : m_info( old.m_info ), m_moved() + { + old.m_moved = true; + } + + ScopedMessage::~ScopedMessage() { + if ( !uncaught_exceptions() && !m_moved ){ + getResultCapture().popScopedMessage(m_info); + } + } + + + Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) { + auto trimmed = [&] (size_t start, size_t end) { + while (names[start] == ',' || isspace(static_cast(names[start]))) { + ++start; + } + while (names[end] == ',' || isspace(static_cast(names[end]))) { + --end; + } + return names.substr(start, end - start + 1); + }; + auto skipq = [&] (size_t start, char quote) { + for (auto i = start + 1; i < names.size() ; ++i) { + if (names[i] == quote) + return i; + if (names[i] == '\\') + ++i; + } + CATCH_INTERNAL_ERROR("CAPTURE parsing encountered unmatched quote"); + }; + + size_t start = 0; + std::stack openings; + for (size_t pos = 0; pos < names.size(); ++pos) { + char c = names[pos]; + switch (c) { + case '[': + case '{': + case '(': + // It is basically impossible to disambiguate between + // comparison and start of template args in this context +// case '<': + openings.push(c); + break; + case ']': + case '}': + case ')': +// case '>': + openings.pop(); + break; + case '"': + case '\'': + pos = skipq(pos, c); + break; + case ',': + if (start != pos && openings.empty()) { + m_messages.emplace_back(macroName, lineInfo, resultType); + m_messages.back().message = static_cast(trimmed(start, pos)); + m_messages.back().message += " := "; + start = pos; + } + } + } + assert(openings.empty() && "Mismatched openings"); + m_messages.emplace_back(macroName, lineInfo, resultType); + m_messages.back().message = static_cast(trimmed(start, names.size() - 1)); + m_messages.back().message += " := "; + } + Capturer::~Capturer() { + if ( !uncaught_exceptions() ){ + assert( m_captured == m_messages.size() ); + for( size_t i = 0; i < m_captured; ++i ) + m_resultCapture.popScopedMessage( m_messages[i] ); + } + } + + void Capturer::captureValue( size_t index, std::string const& value ) { + assert( index < m_messages.size() ); + m_messages[index].message += value; + m_resultCapture.pushScopedMessage( m_messages[index] ); + m_captured++; + } + +} // end namespace Catch diff --git a/lib/Catch2/include/internal/catch_message.h b/lib/Catch2/include/internal/catch_message.h new file mode 100644 index 0000000000..748f5ac567 --- /dev/null +++ b/lib/Catch2/include/internal/catch_message.h @@ -0,0 +1,99 @@ +/* + * Created by Phil Nash on 1/2/2013. + * Copyright 2013 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_MESSAGE_H_INCLUDED +#define TWOBLUECUBES_CATCH_MESSAGE_H_INCLUDED + +#include "catch_result_type.h" +#include "catch_common.h" +#include "catch_stream.h" +#include "catch_interfaces_capture.h" +#include "catch_tostring.h" + +#include +#include + +namespace Catch { + + struct MessageInfo { + MessageInfo( StringRef const& _macroName, + SourceLineInfo const& _lineInfo, + ResultWas::OfType _type ); + + StringRef macroName; + std::string message; + SourceLineInfo lineInfo; + ResultWas::OfType type; + unsigned int sequence; + + bool operator == ( MessageInfo const& other ) const; + bool operator < ( MessageInfo const& other ) const; + private: + static unsigned int globalCount; + }; + + struct MessageStream { + + template + MessageStream& operator << ( T const& value ) { + m_stream << value; + return *this; + } + + ReusableStringStream m_stream; + }; + + struct MessageBuilder : MessageStream { + MessageBuilder( StringRef const& macroName, + SourceLineInfo const& lineInfo, + ResultWas::OfType type ); + + template + MessageBuilder& operator << ( T const& value ) { + m_stream << value; + return *this; + } + + MessageInfo m_info; + }; + + class ScopedMessage { + public: + explicit ScopedMessage( MessageBuilder const& builder ); + ScopedMessage( ScopedMessage& duplicate ) = delete; + ScopedMessage( ScopedMessage&& old ); + ~ScopedMessage(); + + MessageInfo m_info; + bool m_moved; + }; + + class Capturer { + std::vector m_messages; + IResultCapture& m_resultCapture = getResultCapture(); + size_t m_captured = 0; + public: + Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ); + ~Capturer(); + + void captureValue( size_t index, std::string const& value ); + + template + void captureValues( size_t index, T const& value ) { + captureValue( index, Catch::Detail::stringify( value ) ); + } + + template + void captureValues( size_t index, T const& value, Ts const&... values ) { + captureValue( index, Catch::Detail::stringify(value) ); + captureValues( index+1, values... ); + } + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_MESSAGE_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_meta.hpp b/lib/Catch2/include/internal/catch_meta.hpp new file mode 100644 index 0000000000..b54cecc20a --- /dev/null +++ b/lib/Catch2/include/internal/catch_meta.hpp @@ -0,0 +1,50 @@ +/* + * Created by Jozef on 02/12/2018. + * Copyright 2018 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#ifndef TWOBLUECUBES_CATCH_META_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_META_HPP_INCLUDED + +#include + +namespace Catch { + template + struct always_false : std::false_type {}; + + template struct true_given : std::true_type {}; + struct is_callable_tester { + template + true_given()(std::declval()...))> static test(int); + template + std::false_type static test(...); + }; + + template + struct is_callable; + + template + struct is_callable : decltype(is_callable_tester::test(0)) {}; + + +#if defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703 + // std::result_of is deprecated in C++17 and removed in C++20. Hence, it is + // replaced with std::invoke_result here. + template + using FunctionReturnType = std::remove_reference_t>>; +#else + // Keep ::type here because we still support C++11 + template + using FunctionReturnType = typename std::remove_reference::type>::type>::type; +#endif + +} // namespace Catch + +namespace mpl_{ + struct na; +} + +#endif // TWOBLUECUBES_CATCH_META_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_objc.hpp b/lib/Catch2/include/internal/catch_objc.hpp new file mode 100644 index 0000000000..a1c8e0740f --- /dev/null +++ b/lib/Catch2/include/internal/catch_objc.hpp @@ -0,0 +1,215 @@ +/* + * Created by Phil on 14/11/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_OBJC_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_OBJC_HPP_INCLUDED + +#include "catch_objc_arc.hpp" + +#import + +#include + +// NB. Any general catch headers included here must be included +// in catch.hpp first to make sure they are included by the single +// header for non obj-usage +#include "catch_test_case_info.h" +#include "catch_string_manip.h" +#include "catch_tostring.h" + +/////////////////////////////////////////////////////////////////////////////// +// This protocol is really only here for (self) documenting purposes, since +// all its methods are optional. +@protocol OcFixture + +@optional + +-(void) setUp; +-(void) tearDown; + +@end + +namespace Catch { + + class OcMethod : public ITestInvoker { + + public: + OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {} + + virtual void invoke() const { + id obj = [[m_cls alloc] init]; + + performOptionalSelector( obj, @selector(setUp) ); + performOptionalSelector( obj, m_sel ); + performOptionalSelector( obj, @selector(tearDown) ); + + arcSafeRelease( obj ); + } + private: + virtual ~OcMethod() {} + + Class m_cls; + SEL m_sel; + }; + + namespace Detail{ + + + inline std::string getAnnotation( Class cls, + std::string const& annotationName, + std::string const& testCaseName ) { + NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()]; + SEL sel = NSSelectorFromString( selStr ); + arcSafeRelease( selStr ); + id value = performOptionalSelector( cls, sel ); + if( value ) + return [(NSString*)value UTF8String]; + return ""; + } + } + + inline std::size_t registerTestMethods() { + std::size_t noTestMethods = 0; + int noClasses = objc_getClassList( nullptr, 0 ); + + Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses); + objc_getClassList( classes, noClasses ); + + for( int c = 0; c < noClasses; c++ ) { + Class cls = classes[c]; + { + u_int count; + Method* methods = class_copyMethodList( cls, &count ); + for( u_int m = 0; m < count ; m++ ) { + SEL selector = method_getName(methods[m]); + std::string methodName = sel_getName(selector); + if( startsWith( methodName, "Catch_TestCase_" ) ) { + std::string testCaseName = methodName.substr( 15 ); + std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); + std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); + const char* className = class_getName( cls ); + + getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, NameAndTags( name.c_str(), desc.c_str() ), SourceLineInfo("",0) ) ); + noTestMethods++; + } + } + free(methods); + } + } + return noTestMethods; + } + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) + + namespace Matchers { + namespace Impl { + namespace NSStringMatchers { + + struct StringHolder : MatcherBase{ + StringHolder( NSString* substr ) : m_substr( [substr copy] ){} + StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){} + StringHolder() { + arcSafeRelease( m_substr ); + } + + bool match( NSString* str ) const override { + return false; + } + + NSString* CATCH_ARC_STRONG m_substr; + }; + + struct Equals : StringHolder { + Equals( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str isEqualToString:m_substr]; + } + + std::string describe() const override { + return "equals string: " + Catch::Detail::stringify( m_substr ); + } + }; + + struct Contains : StringHolder { + Contains( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str rangeOfString:m_substr].location != NSNotFound; + } + + std::string describe() const override { + return "contains string: " + Catch::Detail::stringify( m_substr ); + } + }; + + struct StartsWith : StringHolder { + StartsWith( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str rangeOfString:m_substr].location == 0; + } + + std::string describe() const override { + return "starts with: " + Catch::Detail::stringify( m_substr ); + } + }; + struct EndsWith : StringHolder { + EndsWith( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str rangeOfString:m_substr].location == [str length] - [m_substr length]; + } + + std::string describe() const override { + return "ends with: " + Catch::Detail::stringify( m_substr ); + } + }; + + } // namespace NSStringMatchers + } // namespace Impl + + inline Impl::NSStringMatchers::Equals + Equals( NSString* substr ){ return Impl::NSStringMatchers::Equals( substr ); } + + inline Impl::NSStringMatchers::Contains + Contains( NSString* substr ){ return Impl::NSStringMatchers::Contains( substr ); } + + inline Impl::NSStringMatchers::StartsWith + StartsWith( NSString* substr ){ return Impl::NSStringMatchers::StartsWith( substr ); } + + inline Impl::NSStringMatchers::EndsWith + EndsWith( NSString* substr ){ return Impl::NSStringMatchers::EndsWith( substr ); } + + } // namespace Matchers + + using namespace Matchers; + +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +} // namespace Catch + +/////////////////////////////////////////////////////////////////////////////// +#define OC_MAKE_UNIQUE_NAME( root, uniqueSuffix ) root##uniqueSuffix +#define OC_TEST_CASE2( name, desc, uniqueSuffix ) \ ++(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Name_test_, uniqueSuffix ) \ +{ \ +return @ name; \ +} \ ++(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Description_test_, uniqueSuffix ) \ +{ \ +return @ desc; \ +} \ +-(void) OC_MAKE_UNIQUE_NAME( Catch_TestCase_test_, uniqueSuffix ) + +#define OC_TEST_CASE( name, desc ) OC_TEST_CASE2( name, desc, __LINE__ ) + +#endif // TWOBLUECUBES_CATCH_OBJC_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_objc_arc.hpp b/lib/Catch2/include/internal/catch_objc_arc.hpp new file mode 100644 index 0000000000..6bcd6b82bc --- /dev/null +++ b/lib/Catch2/include/internal/catch_objc_arc.hpp @@ -0,0 +1,51 @@ +/* + * Created by Phil on 1/08/2012. + * Copyright 2012 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_OBJC_ARC_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_OBJC_ARC_HPP_INCLUDED + +#import + +#ifdef __has_feature +#define CATCH_ARC_ENABLED __has_feature(objc_arc) +#else +#define CATCH_ARC_ENABLED 0 +#endif + +void arcSafeRelease( NSObject* obj ); +id performOptionalSelector( id obj, SEL sel ); + +#if !CATCH_ARC_ENABLED +inline void arcSafeRelease( NSObject* obj ) { + [obj release]; +} +inline id performOptionalSelector( id obj, SEL sel ) { + if( [obj respondsToSelector: sel] ) + return [obj performSelector: sel]; + return nil; +} +#define CATCH_UNSAFE_UNRETAINED +#define CATCH_ARC_STRONG +#else +inline void arcSafeRelease( NSObject* ){} +inline id performOptionalSelector( id obj, SEL sel ) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" +#endif + if( [obj respondsToSelector: sel] ) + return [obj performSelector: sel]; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + return nil; +} +#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained +#define CATCH_ARC_STRONG __strong +#endif + +#endif // TWOBLUECUBES_CATCH_OBJC_ARC_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_option.hpp b/lib/Catch2/include/internal/catch_option.hpp new file mode 100644 index 0000000000..d790b24587 --- /dev/null +++ b/lib/Catch2/include/internal/catch_option.hpp @@ -0,0 +1,73 @@ +/* + * Created by Phil on 02/12/2012. + * Copyright 2012 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_OPTION_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_OPTION_HPP_INCLUDED + +namespace Catch { + + // An optional type + template + class Option { + public: + Option() : nullableValue( nullptr ) {} + Option( T const& _value ) + : nullableValue( new( storage ) T( _value ) ) + {} + Option( Option const& _other ) + : nullableValue( _other ? new( storage ) T( *_other ) : nullptr ) + {} + + ~Option() { + reset(); + } + + Option& operator= ( Option const& _other ) { + if( &_other != this ) { + reset(); + if( _other ) + nullableValue = new( storage ) T( *_other ); + } + return *this; + } + Option& operator = ( T const& _value ) { + reset(); + nullableValue = new( storage ) T( _value ); + return *this; + } + + void reset() { + if( nullableValue ) + nullableValue->~T(); + nullableValue = nullptr; + } + + T& operator*() { return *nullableValue; } + T const& operator*() const { return *nullableValue; } + T* operator->() { return nullableValue; } + const T* operator->() const { return nullableValue; } + + T valueOr( T const& defaultValue ) const { + return nullableValue ? *nullableValue : defaultValue; + } + + bool some() const { return nullableValue != nullptr; } + bool none() const { return nullableValue == nullptr; } + + bool operator !() const { return nullableValue == nullptr; } + explicit operator bool() const { + return some(); + } + + private: + T *nullableValue; + alignas(alignof(T)) char storage[sizeof(T)]; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_OPTION_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_output_redirect.cpp b/lib/Catch2/include/internal/catch_output_redirect.cpp new file mode 100644 index 0000000000..6928d160e3 --- /dev/null +++ b/lib/Catch2/include/internal/catch_output_redirect.cpp @@ -0,0 +1,147 @@ +/* + * Created by Martin on 28/04/2018. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_output_redirect.h" +#include "catch_enforce.h" + +#include +#include +#include +#include +#include + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + #if defined(_MSC_VER) + #include //_dup and _dup2 + #define dup _dup + #define dup2 _dup2 + #define fileno _fileno + #else + #include // dup and dup2 + #endif +#endif + + +namespace Catch { + + RedirectedStream::RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream ) + : m_originalStream( originalStream ), + m_redirectionStream( redirectionStream ), + m_prevBuf( m_originalStream.rdbuf() ) + { + m_originalStream.rdbuf( m_redirectionStream.rdbuf() ); + } + + RedirectedStream::~RedirectedStream() { + m_originalStream.rdbuf( m_prevBuf ); + } + + RedirectedStdOut::RedirectedStdOut() : m_cout( Catch::cout(), m_rss.get() ) {} + auto RedirectedStdOut::str() const -> std::string { return m_rss.str(); } + + RedirectedStdErr::RedirectedStdErr() + : m_cerr( Catch::cerr(), m_rss.get() ), + m_clog( Catch::clog(), m_rss.get() ) + {} + auto RedirectedStdErr::str() const -> std::string { return m_rss.str(); } + + RedirectedStreams::RedirectedStreams(std::string& redirectedCout, std::string& redirectedCerr) + : m_redirectedCout(redirectedCout), + m_redirectedCerr(redirectedCerr) + {} + + RedirectedStreams::~RedirectedStreams() { + m_redirectedCout += m_redirectedStdOut.str(); + m_redirectedCerr += m_redirectedStdErr.str(); + } + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + +#if defined(_MSC_VER) + TempFile::TempFile() { + if (tmpnam_s(m_buffer)) { + CATCH_RUNTIME_ERROR("Could not get a temp filename"); + } + if (fopen_s(&m_file, m_buffer, "w+")) { + char buffer[100]; + if (strerror_s(buffer, errno)) { + CATCH_RUNTIME_ERROR("Could not translate errno to a string"); + } + CATCH_RUNTIME_ERROR("Could not open the temp file: '" << m_buffer << "' because: " << buffer); + } + } +#else + TempFile::TempFile() { + m_file = std::tmpfile(); + if (!m_file) { + CATCH_RUNTIME_ERROR("Could not create a temp file."); + } + } + +#endif + + TempFile::~TempFile() { + // TBD: What to do about errors here? + std::fclose(m_file); + // We manually create the file on Windows only, on Linux + // it will be autodeleted +#if defined(_MSC_VER) + std::remove(m_buffer); +#endif + } + + + FILE* TempFile::getFile() { + return m_file; + } + + std::string TempFile::getContents() { + std::stringstream sstr; + char buffer[100] = {}; + std::rewind(m_file); + while (std::fgets(buffer, sizeof(buffer), m_file)) { + sstr << buffer; + } + return sstr.str(); + } + + OutputRedirect::OutputRedirect(std::string& stdout_dest, std::string& stderr_dest) : + m_originalStdout(dup(1)), + m_originalStderr(dup(2)), + m_stdoutDest(stdout_dest), + m_stderrDest(stderr_dest) { + dup2(fileno(m_stdoutFile.getFile()), 1); + dup2(fileno(m_stderrFile.getFile()), 2); + } + + OutputRedirect::~OutputRedirect() { + Catch::cout() << std::flush; + fflush(stdout); + // Since we support overriding these streams, we flush cerr + // even though std::cerr is unbuffered + Catch::cerr() << std::flush; + Catch::clog() << std::flush; + fflush(stderr); + + dup2(m_originalStdout, 1); + dup2(m_originalStderr, 2); + + m_stdoutDest += m_stdoutFile.getContents(); + m_stderrDest += m_stderrFile.getContents(); + } + +#endif // CATCH_CONFIG_NEW_CAPTURE + +} // namespace Catch + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + #if defined(_MSC_VER) + #undef dup + #undef dup2 + #undef fileno + #endif +#endif diff --git a/lib/Catch2/include/internal/catch_output_redirect.h b/lib/Catch2/include/internal/catch_output_redirect.h new file mode 100644 index 0000000000..3d1c2d4517 --- /dev/null +++ b/lib/Catch2/include/internal/catch_output_redirect.h @@ -0,0 +1,116 @@ +/* + * Created by Martin on 28/04/2018. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H +#define TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H + +#include "catch_platform.h" +#include "catch_stream.h" + +#include +#include +#include + +namespace Catch { + + class RedirectedStream { + std::ostream& m_originalStream; + std::ostream& m_redirectionStream; + std::streambuf* m_prevBuf; + + public: + RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream ); + ~RedirectedStream(); + }; + + class RedirectedStdOut { + ReusableStringStream m_rss; + RedirectedStream m_cout; + public: + RedirectedStdOut(); + auto str() const -> std::string; + }; + + // StdErr has two constituent streams in C++, std::cerr and std::clog + // This means that we need to redirect 2 streams into 1 to keep proper + // order of writes + class RedirectedStdErr { + ReusableStringStream m_rss; + RedirectedStream m_cerr; + RedirectedStream m_clog; + public: + RedirectedStdErr(); + auto str() const -> std::string; + }; + + class RedirectedStreams { + public: + RedirectedStreams(RedirectedStreams const&) = delete; + RedirectedStreams& operator=(RedirectedStreams const&) = delete; + RedirectedStreams(RedirectedStreams&&) = delete; + RedirectedStreams& operator=(RedirectedStreams&&) = delete; + + RedirectedStreams(std::string& redirectedCout, std::string& redirectedCerr); + ~RedirectedStreams(); + private: + std::string& m_redirectedCout; + std::string& m_redirectedCerr; + RedirectedStdOut m_redirectedStdOut; + RedirectedStdErr m_redirectedStdErr; + }; + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + + // Windows's implementation of std::tmpfile is terrible (it tries + // to create a file inside system folder, thus requiring elevated + // privileges for the binary), so we have to use tmpnam(_s) and + // create the file ourselves there. + class TempFile { + public: + TempFile(TempFile const&) = delete; + TempFile& operator=(TempFile const&) = delete; + TempFile(TempFile&&) = delete; + TempFile& operator=(TempFile&&) = delete; + + TempFile(); + ~TempFile(); + + std::FILE* getFile(); + std::string getContents(); + + private: + std::FILE* m_file = nullptr; + #if defined(_MSC_VER) + char m_buffer[L_tmpnam] = { 0 }; + #endif + }; + + + class OutputRedirect { + public: + OutputRedirect(OutputRedirect const&) = delete; + OutputRedirect& operator=(OutputRedirect const&) = delete; + OutputRedirect(OutputRedirect&&) = delete; + OutputRedirect& operator=(OutputRedirect&&) = delete; + + + OutputRedirect(std::string& stdout_dest, std::string& stderr_dest); + ~OutputRedirect(); + + private: + int m_originalStdout = -1; + int m_originalStderr = -1; + TempFile m_stdoutFile; + TempFile m_stderrFile; + std::string& m_stdoutDest; + std::string& m_stderrDest; + }; + +#endif + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H diff --git a/lib/Catch2/include/internal/catch_platform.h b/lib/Catch2/include/internal/catch_platform.h new file mode 100644 index 0000000000..82c5e144d5 --- /dev/null +++ b/lib/Catch2/include/internal/catch_platform.h @@ -0,0 +1,30 @@ +/* + * Created by Phil on 16/8/2013. + * Copyright 2013 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ +#ifndef TWOBLUECUBES_CATCH_PLATFORM_H_INCLUDED +#define TWOBLUECUBES_CATCH_PLATFORM_H_INCLUDED + +// See e.g.: +// https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html +#ifdef __APPLE__ +# include +# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \ + (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1) +# define CATCH_PLATFORM_MAC +# elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1) +# define CATCH_PLATFORM_IPHONE +# endif + +#elif defined(linux) || defined(__linux) || defined(__linux__) +# define CATCH_PLATFORM_LINUX + +#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) +# define CATCH_PLATFORM_WINDOWS +#endif + +#endif // TWOBLUECUBES_CATCH_PLATFORM_H_INCLUDED diff --git a/lib/Catch2/include/internal/catch_polyfills.cpp b/lib/Catch2/include/internal/catch_polyfills.cpp new file mode 100644 index 0000000000..68a2c827c4 --- /dev/null +++ b/lib/Catch2/include/internal/catch_polyfills.cpp @@ -0,0 +1,31 @@ +/* + * Created by Martin on 17/11/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch_polyfills.hpp" + +#include + +namespace Catch { + +#if !defined(CATCH_CONFIG_POLYFILL_ISNAN) + bool isnan(float f) { + return std::isnan(f); + } + bool isnan(double d) { + return std::isnan(d); + } +#else + // For now we only use this for embarcadero + bool isnan(float f) { + return std::_isnan(f); + } + bool isnan(double d) { + return std::_isnan(d); + } +#endif + +} // end namespace Catch diff --git a/lib/Catch2/include/internal/catch_polyfills.hpp b/lib/Catch2/include/internal/catch_polyfills.hpp new file mode 100644 index 0000000000..ba4189ef3d --- /dev/null +++ b/lib/Catch2/include/internal/catch_polyfills.hpp @@ -0,0 +1,15 @@ +/* + * Created by Martin on 17/11/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_CATCH_POLYFILLS_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_POLYFILLS_HPP_INCLUDED + +namespace Catch { + bool isnan(float f); + bool isnan(double d); +} + +#endif // TWOBLUECUBES_CATCH_POLYFILLS_HPP_INCLUDED diff --git a/lib/Catch2/include/internal/catch_preprocessor.hpp b/lib/Catch2/include/internal/catch_preprocessor.hpp new file mode 100644 index 0000000000..928384eb99 --- /dev/null +++ b/lib/Catch2/include/internal/catch_preprocessor.hpp @@ -0,0 +1,237 @@ + +/* + * Created by Jozef on 12/11/2018. + * Copyright 2017 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#ifndef TWOBLUECUBES_CATCH_PREPROCESSOR_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_PREPROCESSOR_HPP_INCLUDED + +#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ +#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) + +#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ +// MSVC needs more evaluations +#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) +#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) +#else +#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) +#endif + +#define CATCH_REC_END(...) +#define CATCH_REC_OUT + +#define CATCH_EMPTY() +#define CATCH_DEFER(id) id CATCH_EMPTY() + +#define CATCH_REC_GET_END2() 0, CATCH_REC_END +#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 +#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 +#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT +#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0) +#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) + +#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) + +#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) + +// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results, +// and passes userdata as the first parameter to each invocation, +// e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c) +#define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) + +#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) + +#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) +#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ +#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ +#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF +#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ +#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) +#else +// MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF +#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) +#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ +#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) +#endif + +#define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ +#define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) + +#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper()) +#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) +#else +#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper())) +#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) +#endif + +#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\ + CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__) + +#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) +#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) +#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) +#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) +#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) +#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) +#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _3, _4, _5, _6) +#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) +#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) +#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) +#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) + +#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N + +#define INTERNAL_CATCH_TYPE_GEN\ + template struct TypeList {};\ + template\ + constexpr auto get_wrapper() noexcept -> TypeList { return {}; }\ + template class...> struct TemplateTypeList{};\ + template class...Cs>\ + constexpr auto get_wrapper() noexcept -> TemplateTypeList { return {}; }\ + template\ + struct append;\ + template\ + struct rewrap;\ + template class, typename...>\ + struct create;\ + template class, typename>\ + struct convert;\ + \ + template \ + struct append { using type = T; };\ + template< template class L1, typename...E1, template class L2, typename...E2, typename...Rest>\ + struct append, L2, Rest...> { using type = typename append, Rest...>::type; };\ + template< template class L1, typename...E1, typename...Rest>\ + struct append, TypeList, Rest...> { using type = L1; };\ + \ + template< template class Container, template class List, typename...elems>\ + struct rewrap, List> { using type = TypeList>; };\ + template< template class Container, template class List, class...Elems, typename...Elements>\ + struct rewrap, List, Elements...> { using type = typename append>, typename rewrap, Elements...>::type>::type; };\ + \ + template