diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2708616 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,124 @@ + +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + + workflow_dispatch: + +jobs: + GCC: + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Install build infrastructure + run: sudo apt-get install -y build-essential cmake ninja-build gcc-13 g++-13 libstdc++-13-dev + + - name: Build test + run: | + mkdir -p build/test + cd build/test + cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DQRCODE_TESTS_ENABLED:BOOL=True ../../ + ninja + + - name: Run test + run: build/test/test/libqrcode_test + + - name: Build demo + run: | + mkdir -p build/demo + cd build/demo + cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLIBQRCODE_INCLUDE_DIR=$GITHUB_WORKSPACE/include/ ../../demo + ninja + + - name: Run demo + run: | + build/demo/demo "Hello World!" >> result.svg + diff -u --ignore-space-change --strip-trailing-cr --ignore-blank-lines demo/qrcode.svg result.svg + + Clang: + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Install build infrastructure + run: sudo apt-get install -y build-essential cmake ninja-build clang-15 libstdc++-13-dev + + - name: Build test + run: | + mkdir -p build/test + cd build/test + cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DQRCODE_TESTS_ENABLED:BOOL=True ../../ + ninja + + - name: Run test + run: build/test/test/libqrcode_test + + - name: Build demo + run: | + mkdir -p build/demo + cd build/demo + cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLIBQRCODE_INCLUDE_DIR=$GITHUB_WORKSPACE/include/ ../../demo + ninja + + - name: Run demo + run: | + build/demo/demo "Hello World!" >> result.svg + diff -u --ignore-space-change --strip-trailing-cr --ignore-blank-lines demo/qrcode.svg result.svg + + AppleClang: + runs-on: macos-15 + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Build test + run: | + mkdir -p build/test + cd build/test + cmake -GXcode -DQRCODE_TESTS_ENABLED:BOOL=True ../../ + xcodebuild -scheme ALL_BUILD -configuration Release build + + - name: Run test + run: build/test/test/Release/libqrcode_test + + - name: Build demo + run: | + mkdir -p build/demo + cd build/demo + cmake -GXcode -DLIBQRCODE_INCLUDE_DIR=$GITHUB_WORKSPACE/include/ ../../demo + xcodebuild -scheme ALL_BUILD -configuration Release build + + - name: Run demo + run: | + build/demo/Release/demo "Hello World!" >> result.svg + diff -u --ignore-space-change --strip-trailing-cr --ignore-blank-lines demo/qrcode.svg result.svg + + MSVC: + runs-on: windows-2022 + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Build test + shell: cmd + run: ${{ '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" && mkdir build\test && cd build\test && cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DQRCODE_TESTS_ENABLED:BOOL=True ../../ && ninja' }} + + - name: Run test + run: build/test/test/libqrcode_test + + - name: Build demo + shell: cmd + run: ${{ '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" && mkdir build\demo && cd build\demo && cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLIBQRCODE_INCLUDE_DIR="%cd%/include" ../../demo && ninja' }} + + - name: Run demo + run: | + . build/demo/demo "Hello World!" >> result.svg + Compare-Object (Get-Content demo/qrcode.svg) (Get-Content result.svg) + diff --git a/.github/workflows/ci_build.yml b/.github/workflows/ci_build.yml deleted file mode 100644 index 38188f7..0000000 --- a/.github/workflows/ci_build.yml +++ /dev/null @@ -1,32 +0,0 @@ - -name: CI - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - - workflow_dispatch: - -jobs: - ci_on_linux: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Run tests - run: ./test/linux_run.sh - - - name: Run conan demo - run: ./conan_demo/run.sh "Hello World!" - - ci_on_windows: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v2 - - - name: Run tests - run: ./test/win_run.ps1 diff --git a/.gitignore b/.gitignore index 57286ba..0619ec0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ .vscode/ -build.log -qrcode.svg +build/ +out/ +.vs/ +.DS_Store +CMakeSettings.json \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index f94c725..4c921b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # # The MIT License # -# Copyright (c) 2021 Sebastian Bauer +# Copyright (c) 2025 Melissa Bauer # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ endfunction() project(libqrcode) enable_testing() -enable_cxx(20) +enable_cxx(23) add_library(qrcode INTERFACE) @@ -166,9 +166,8 @@ target_sources(qrcode INTERFACE ) target_include_directories(qrcode INTERFACE "include") -target_link_libraries(qrcode INTERFACE $<$:stdc++ m>) -target_link_libraries(qrcode INTERFACE $<$:stdc++ m>) -target_compile_options(qrcode INTERFACE $<$:/std:c++latest>) +target_link_libraries(qrcode INTERFACE $<$:stdc++ m>) +target_link_libraries(qrcode INTERFACE $<$:m>) if (QRCODE_TESTS_ENABLED) add_subdirectory(test) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..33205d7 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,29 @@ +{ + "version": 10, + "cmakeMinimumRequired": { + "major": 3, + "minor": 23, + "patch": 0 + }, + "configurePresets": [ + { + "name": "apple-clang-with-tests", + "displayName": "AppleClang - With Tests", + "description": "macos build", + "generator": "Xcode", + "binaryDir": "${sourceDir}/build/with-tests", + "cacheVariables": { + "QRCODE_TESTS_ENABLED": { + "type": "BOOL", + "value": "ON" + } + } + } + ], + "buildPresets": [ + { + "name": "build-apple-clang-with-tests", + "configurePreset": "apple-clang-with-tests" + } + ] +} \ No newline at end of file diff --git a/LICENSE b/LICENSE index a6ec1e9..08b8a55 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ -Copyright (c) 2021 Sebastian Bauer +Copyright (c) 2025 Melissa Bauer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index b6cd8e7..4ad39a8 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,13 @@ # Introduction -libqrcode is C++20 header-only library for generating QR/Micro QR Codes. +libqrcode is C++23 header-only library for generating QR/Micro QR Codes. Features include: * Header-only library * Completely constexpr * Code is (unit-)tested with `static_asserts` during compile-time * Utilizes standard library only -* Uses C++20 Ranges +* Uses Ranges * No C++ exceptions (however) -* Supports Conan package manager # QR support Supported: @@ -29,13 +28,9 @@ Supported: * Encodings: Numeric, alphanumeric, byte and kanji encoding (where possible) # Usage -One can either use the conan recipe provided in this repository or directly integrate the library -into your project. As this libary is header-only, it should be quite easy to setup. -Add the libqrcode include directory to your project's header search path - In your project, just in include the header [`qrcode/qrcode.h`](include/qrcode/qrcode.h). -Micro QR api is located within namespace `micro_qr`. -QR api is located within namespace `qr`. +Micro QR API is located within namespace `micro_qr`. +QR API is located within namespace `qr`. #### Simple example ``` @@ -89,41 +84,21 @@ int main() ``` # Requirements -* C++20 compiler and standard library +* C++ compiler and standard library * Supported: - * gcc10 and libstdc++-10-dev or higher (see [`test/linux.Dockerfile`](test/linux.Dockerfile)) - * msvc: Visual Studio 2019 16.10.0 (see [`test/win.Dockerfile`](test/win.Dockerfile)) -* Not supported: - * clang doesn't seem to support all featured of C++20 needed to make this work - * macOS (due to lack of C++20 features), support will be added in the future + * gcc13 and libstdc++-13-dev + * clang15 and libstdc++-13-dev + * msvc: Visual Studio 2022 17.14.9 + * macos: AppleClang 16.0.0 # How to build * Since the library is header-only, building is actually not necessary. -* Just put the `include` folder of this project into your header search path and it should just work. +* Just place the `include` folder of this project into your header search path. * However, if you'd like to run the tests, please select the top-level of the project in order to run _CMake_. -* For more information, please have a look at the _Dockerfile_ in the test folder and consider the remarks below. ## How to run the tests -If you would like to run the tests, one has to add the following cmake flag: `-DQRCODE_TESTS_ENABLED:BOOL=True` - -## Debug builds using MSVC -Building with tests enabled in _Debug_ configuration won't build due to an issue in _Microsoft_'s STL implementation. _Release_ configuration works though. +If you would like to run the tests, one has to add the following _CMake_ flag: `-DQRCODE_TESTS_ENABLED:BOOL=True` # CI builds -CI builds usually consists of a test build and a conan demo build. -If and only if both builds were successful, the CI state is green. - -# Tests -All tests are usually built and run in docker containers. -See [`test/linux.Dockerfile`](test/linux.Dockerfile) for more info. -You can also hit [`test/linux_run.sh`](test/linux_run.sh) which creates and -runs the docker image for you. - -# Conan -The library supports _Conan_ out of the box. The [`conan_demo/Dockerfile`](conan_demo/Dockerfile) -and [`conan_demo/run.sh`](conan_demo/run.sh) are for demonstration purposes. -It creates a small command-line tool which can create QR symbols from a given text message. - -Please note: -The _Conan_ build is part of the CI checks. -The tool has to be compiled successfully in order to clear this stage. +The CI pipeline consist of test builds and demo builds for _GCC_, _Clang_, _AppleClang_ and _MSVC_. +If and only if all builds were successful, the CI state is green. diff --git a/conan_demo/Dockerfile b/conan_demo/Dockerfile deleted file mode 100644 index b3d9bd0..0000000 --- a/conan_demo/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM ubuntu:20.04 - -RUN apt-get update && \ - apt-get upgrade -y && \ - DEBIAN_FRONTEND="noninteractive" apt-get install -y build-essential cmake ninja-build gcc-10 g++-10 libstdc++-10-dev && \ - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 && \ - update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10 && \ - apt-get install -y python3-pip && pip3 install conan - -ARG user_name="container_user" -RUN useradd -m $user_name - -# library -RUN mkdir -p /home/$user_name/libqrcode/library && chown $user_name:$user_name /home/$user_name/libqrcode/library -COPY --chown=$user_name:$user_name CMakeLists.txt /home/$user_name/libqrcode/library/ -COPY --chown=$user_name:$user_name conanfile.py /home/$user_name/libqrcode/library/ -COPY --chown=$user_name:$user_name include/ /home/$user_name/libqrcode/library/include - -# conan demo -RUN mkdir -p /home/$user_name/libqrcode/demo/src && chown $user_name:$user_name /home/$user_name/libqrcode/demo/src && \ - mkdir -p /home/$user_name/libqrcode/demo/bin && chown $user_name:$user_name /home/$user_name/libqrcode/demo/bin -COPY --chown=$user_name:$user_name conan_demo/ /home/$user_name/libqrcode/demo/src - -USER $user_name -WORKDIR /home/$user_name/libqrcode/demo/bin -RUN conan create ../../library demo/test && \ - conan install ../src && \ - cmake -GNinja ../src && \ - ninja - -ENTRYPOINT [ "./demo" ] \ No newline at end of file diff --git a/conan_demo/conanfile.txt b/conan_demo/conanfile.txt deleted file mode 100644 index 020edfa..0000000 --- a/conan_demo/conanfile.txt +++ /dev/null @@ -1,5 +0,0 @@ -[requires] -libqrcode/v1.0@demo/test - -[generators] -cmake_find_package \ No newline at end of file diff --git a/conan_demo/run.sh b/conan_demo/run.sh deleted file mode 100755 index 7b22491..0000000 --- a/conan_demo/run.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -ex - -cd "${0%/*}" - -container_name="libqrcode_demo_build" -docker build -t $container_name -f Dockerfile ../ >&2 -time docker run -i $container_name "$@" diff --git a/conanfile.py b/conanfile.py deleted file mode 100644 index 1d3dc2b..0000000 --- a/conanfile.py +++ /dev/null @@ -1,22 +0,0 @@ -from conans import ConanFile - -class LibqrcodeConan(ConanFile): - name = "libqrcode" - version = "v1.0" - exports_sources = "include/*" - no_copy_source = True - url = "https://github.com/yax-lakam-tuun/libqrcode" - license = "MIT License" - description = "A header-only C++20 library for generating QR Codes" - settings = "os" - - def build(self): - pass - - def package(self): - self.copy("*.h") - - def package_info(self): - if not self.settings.os == "Windows": - self.cpp_info.libs.append("stdc++") - self.cpp_info.libs.append("m") diff --git a/conan_demo/CMakeLists.txt b/demo/CMakeLists.txt similarity index 65% rename from conan_demo/CMakeLists.txt rename to demo/CMakeLists.txt index 0176545..7bfb843 100644 --- a/conan_demo/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -1,7 +1,7 @@ # # The MIT License # -# Copyright (c) 2021 Sebastian Bauer +# Copyright (c) 2025 Melissa Bauer # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -30,12 +30,16 @@ endfunction() project(libqrcode_demo) enable_testing() -enable_cxx(20) +enable_cxx(23) -set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) -find_package(libqrcode REQUIRED) +set(LIBQRCODE_INCLUDE_DIR CACHE PATH "Path to libqrcode include directory") +if(NOT LIBQRCODE_INCLUDE_DIR) + message(FATAL_ERROR "Please specify location of libqrcode include folder") +endif() add_executable(demo demo.cpp) -target_compile_options(demo PRIVATE $<$:-Wall -Wextra -Wpedantic>) -target_compile_options(demo PRIVATE $<$:-Wall -Wextra -Wpedantic>) -target_link_libraries(demo PRIVATE libqrcode::libqrcode) +target_include_directories(demo PRIVATE ${LIBQRCODE_INCLUDE_DIR}) +target_compile_options(demo PRIVATE $<$:-Wall -Wextra -Wpedantic -Werror>) +target_compile_options(demo PRIVATE $<$:-Wall -Wextra -Wpedantic -Werror>) +target_compile_options(demo PRIVATE $<$:-Wall -Wextra -Wpedantic -Werror>) +target_link_options(demo PRIVATE $<$:/STACK:16777216>) \ No newline at end of file diff --git a/conan_demo/demo.cpp b/demo/demo.cpp similarity index 98% rename from conan_demo/demo.cpp rename to demo/demo.cpp index 198d568..259f51e 100644 --- a/conan_demo/demo.cpp +++ b/demo/demo.cpp @@ -213,12 +213,14 @@ int main(int argc, char** argv) } print_options(std::cerr, *options); + using std::begin; + using std::end; auto message = options->message; auto std_input = cx::vector{}; if (empty(options->message)) { std_input = read_message(std::cin); - message = std::string_view{cx::begin(std_input), cx::end(std_input)}; + message = std::string_view{begin(std_input), end(std_input)}; } print_message(std::cerr, message); diff --git a/demo/qrcode.svg b/demo/qrcode.svg new file mode 100755 index 0000000..1a1c7e0 --- /dev/null +++ b/demo/qrcode.svg @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/include/cx/cmath.h b/include/cx/cmath.h index 4fa09ef..9084ea9 100644 --- a/include/cx/cmath.h +++ b/include/cx/cmath.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/cx/vector.h b/include/cx/vector.h index 61b648e..39a9cb8 100644 --- a/include/cx/vector.h +++ b/include/cx/vector.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,11 +23,13 @@ */ #pragma once +#include #include #include #include +#include -namespace cx +namespace cx::detail { // poor man's constexpr stack-based vector template @@ -117,22 +119,6 @@ namespace cx elements[current_size++] = T{std::forward(args)...}; } - constexpr auto erase(const_iterator first, const_iterator last) - { - auto const dst = begin() + (first - begin()); - auto const src = begin() + (last - begin()); - - auto const old_end = end(); - auto const new_end = std::move(src, old_end, dst); - - current_size = new_end - begin(); - - if constexpr (!std::is_trivially_destructible_v) - std::destroy(new_end, old_end); - - return new_end; - } - constexpr auto& operator[](int index) const noexcept { return elements[index]; } constexpr auto& operator[](int index) noexcept { return elements[index]; } @@ -160,18 +146,31 @@ namespace cx container elements; }; + template + constexpr auto operator==(vector const& a, vector const& b) noexcept + { + return std::ranges::equal(a, b); + } +} + +namespace cx +{ + // msvc or the C++ standard library respectively seems to have problems in constexpr sitations, + // use old implementation in constexpr instead +#ifdef _MSC_VER + template + using vector = std::conditional_t, std::vector>; + using std::ranges::begin; using std::ranges::end; using std::ranges::rbegin; using std::ranges::rend; using std::ranges::size; using std::ranges::empty; - +#else template - constexpr auto operator==(cx::vector const& a, cx::vector const& b) noexcept - { - return std::equal(begin(a), end(a), begin(b), end(b)); - } + using vector = std::vector; +#endif } #ifdef QRCODE_TESTS_ENABLED @@ -221,8 +220,11 @@ namespace cx::test constexpr auto cx_vectors_can_be_initialized_with_preexisting_elements() { - constexpr auto v = cx::vector{1,2,3,4,5}; - static_assert(std::ranges::equal(v, std::array{1,2,3,4,5})); + static_assert([]() + { + auto const v = cx::vector{1,2,3,4,5}; + return std::ranges::equal(v, std::array{1,2,3,4,5}); + }()); } constexpr auto cx_vectors_have_a_size() @@ -234,13 +236,6 @@ namespace cx::test static_assert(size(cx::vector{3,1,4,7}) == 4); } - constexpr auto cx_vectors_have_a_maximum_size_of_40000_this_is_enough_space_for_qr_applications() - { - static_assert(cx::vector{}.max_size() == 40000); - static_assert(cx::vector{}.max_size() == 40000); - static_assert(cx::vector{}.max_size() == 40000); - } - constexpr auto cx_vectors_can_be_asked_whether_they_are_empty() { static_assert(empty(cx::vector{})); @@ -249,39 +244,50 @@ namespace cx::test constexpr auto cx_vectors_can_be_initialized_with_preexisting_elements_less_than_cx_vectors_capacity() { - constexpr auto v = cx::vector{1,2,3}; - static_assert(std::ranges::equal(v, std::array{1,2,3})); - static_assert(size(v) == 3); + static_assert([]() + { + auto const v = cx::vector{1,2,3}; + return std::ranges::equal(v, std::array{1,2,3}) + && size(v) == 3; + }()); } constexpr auto cx_vectors_can_be_initialized_with_a_specified_number_of_elements_equal_or_less_than_cx_vectors_capacity() { - constexpr auto v = cx::vector(4); - static_assert(std::ranges::equal(v, std::array{int{}, int{}, int{}, int{}})); - static_assert(size(v) == 4); + static_assert([]() + { + auto const v = cx::vector(4); + return std::ranges::equal(v, std::array{int{}, int{}, int{}, int{}}) + && size(v) == 4; + }()); } constexpr auto cx_vectors_can_be_initialized_with_a_specified_number_of_elements_and_a_fill_element_equal_or_less_than_cx_vectors_capacity() { - constexpr auto v = cx::vector(4,-2); - static_assert(std::ranges::equal(v, std::array{-2,-2,-2,-2})); - static_assert(size(v) == 4); + static_assert([]() + { + auto const v = cx::vector(4,-2); + return std::ranges::equal(v, std::array{-2,-2,-2,-2}) + && size(v) == 4; + }()); } constexpr auto cx_vectors_can_be_initialized_from_iterator_range() { - constexpr auto some_elements = std::array{1,2,3,4,5}; - - constexpr auto v = cx::vector{begin(some_elements), end(some_elements)}; - - static_assert(std::ranges::equal(v, std::array{1,2,3,4,5})); + static_assert([]() + { + auto const some_elements = std::array{1,2,3,4,5}; + auto const v = cx::vector{begin(some_elements), end(some_elements)}; + return std::ranges::equal(v, std::array{1,2,3,4,5}); + }()); + } constexpr auto cx_vectors_allow_accessing_their_elements_by_reverse_iterators() { - auto f = [] + static_assert([] { - constexpr auto v = cx::vector{1,2,3,4,5}; + auto const v = cx::vector{1,2,3,4,5}; auto const& cv = v; auto r = rbegin(v); @@ -296,8 +302,7 @@ namespace cx::test if (&*(rend(v)-1) != &*begin(v)) return false; if (&*(rend(cv)-1) != &*begin(v)) return false; return true; - }; - static_assert(f()); + }()); } constexpr auto cx_vectors_allow_explicit_read_access_to_their_first_element_if_vector_has_any_data() @@ -308,7 +313,7 @@ namespace cx::test constexpr auto cx_vectors_allow_explicit_write_access_to_their_first_element_if_vector_has_any_data() { - auto f = [] + static_assert([] { auto v = cx::vector{3,1,4,1,5}; auto const& cv = v; @@ -318,8 +323,7 @@ namespace cx::test v.front() = 7; return element == 7 && const_element == 7; - }; - static_assert(f()); + }()); } constexpr auto cx_vectors_allow_explicit_read_access_to_theirlast_element_if_vector_has_any_data() @@ -330,7 +334,7 @@ namespace cx::test constexpr auto cx_vectors_allow_explicit_write_access_to_their_last_element_if_vector_has_any_data() { - auto f = [] + static_assert([] { auto v = cx::vector{3,1,4,1,5}; auto const& cv = v; @@ -340,103 +344,12 @@ namespace cx::test v.back() = 7; return element == 7 && const_element == 7; - }; - static_assert(f()); - } - - constexpr auto cx_vectors_allow_erasing_elements_from_specified_range() - { - auto f = [] - { - auto v = cx::vector{3,1,4,1,5}; - - v.erase(begin(v)+3, end(v)); - - return v; - }; - static_assert(std::ranges::equal(f(), std::array{3,1,4})); - } - - constexpr auto cx_vectors_allow_erasing_elements_from_specified_range___erasing_everything() - { - auto f = [] - { - auto v = cx::vector{3,1,4,1,5,8,9,2,7,0}; - - v.erase(begin(v), end(v)); - - return begin(v) ==end(v); - }; - static_assert(f()); - } - - constexpr auto cx_vectors_allow_erasing_elements_from_specified_range___tail_is_longer_than_erased_range() - { - auto f = [] - { - auto v = cx::vector{3,1,4,1,5,8,9,2,7,0}; - - v.erase(begin(v)+2, begin(v)+5); - - return v; - }; - constexpr auto result = f(); - - static_assert(std::ranges::equal(result, std::array{3,1,8,9,2,7,0})); - static_assert(size(result) == 7); - } - - constexpr auto cx_vectors_allow_erasing_elements_from_specified_range___move_assigns_elements_at_their_new_positions() - { - auto f = [] - { - struct only_move_assignable - { - constexpr only_move_assignable() : state{0} {} - constexpr only_move_assignable(int value) : state{value} {} - only_move_assignable(only_move_assignable const&) = delete; - only_move_assignable(only_move_assignable&&) = delete; - only_move_assignable& operator=(only_move_assignable const&) = delete; - only_move_assignable& operator=(only_move_assignable&&) = default; - ~only_move_assignable() = default; - constexpr auto operator==(only_move_assignable const& rhs) const noexcept { return state == rhs.state; } - - int state; - }; - - auto v = cx::vector{}; - v.push_back({3}); - v.push_back({1}); - v.push_back({4}); - - v.erase(begin(v), begin(v)+1); - - auto i = begin(v); - for (auto& n : {only_move_assignable{1}, only_move_assignable{4}}) - if (!(*(i++) == n)) - return false; - - return size(v) == 2; - }; - static_assert(f()); - } - - constexpr auto cx_vectors_allow_erasing_elements_from_specified_range___returns_iterator_following_the_last_removed_element() - { - auto f = [] - { - auto v = cx::vector{3,1,4,1,5,8,9,2,7,0}; - - auto iterator = v.erase(begin(v)+2, begin(v)+3); - - return iterator == (begin(v)+9); - }; - static_assert(f()); + }()); } constexpr auto cx_vectors_support_read_only_index_access() { - auto f = [] + static_assert([]() { auto v = cx::vector{1,2,3,4,5}; @@ -445,13 +358,12 @@ namespace cx::test *(begin(v)+3) = 7; return by_value == 4 && by_reference == 7; - }; - static_assert(f()); + }()); } constexpr auto cx_vectors_support_write_index_access() { - auto f = [] + static_assert([]() { auto v = cx::vector{1,2,3,4,5}; @@ -460,8 +372,7 @@ namespace cx::test by_reference = 7; return by_value == 4 && by_reference == 7; - }; - static_assert(f()); + }()); } } #endif diff --git a/include/qrcode/code/bit_view.h b/include/qrcode/code/bit_view.h index ad3571c..04a6ac6 100644 --- a/include/qrcode/code/bit_view.h +++ b/include/qrcode/code/bit_view.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -97,9 +97,9 @@ namespace qrcode::code::detail constexpr bit_view_sentinel() noexcept = default; template - [[nodiscard]] friend constexpr auto operator==( + friend constexpr auto operator==( bit_view_iterator const& iterator, - bit_view_sentinel const& sentinel) noexcept; + bit_view_sentinel const& sentinel) noexcept -> bool; private: template @@ -115,7 +115,7 @@ namespace qrcode::code::detail template [[nodiscard]] constexpr auto operator==( bit_view_iterator const& iterator, - bit_view_sentinel const& sentinel) noexcept + bit_view_sentinel const& sentinel) noexcept -> bool { return sentinel.equal(iterator); } diff --git a/include/qrcode/code/block_info.h b/include/qrcode/code/block_info.h index 8269325..981b0da 100644 --- a/include/qrcode/code/block_info.h +++ b/include/qrcode/code/block_info.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/code/byte_view.h b/include/qrcode/code/byte_view.h index 4901d2f..7f0576d 100644 --- a/include/qrcode/code/byte_view.h +++ b/include/qrcode/code/byte_view.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,6 +31,7 @@ #include #include #include +#include namespace qrcode::code::detail { @@ -90,13 +91,13 @@ namespace qrcode::code::detail } [[nodiscard]] friend constexpr auto operator==( - byte_view_iterator const& iterator, std::default_sentinel_t const&) noexcept + byte_view_iterator const& iterator, std::default_sentinel_t const&) noexcept -> bool { return !iterator.current_value.has_value(); } [[nodiscard]] friend constexpr auto operator==( - byte_view_iterator const& a, byte_view_iterator const& b) noexcept + byte_view_iterator const& a, byte_view_iterator const& b) noexcept -> bool { return a.bit_iterator == b.bit_iterator && a.current_value == b.current_value; diff --git a/include/qrcode/code/code_block.h b/include/qrcode/code/code_block.h index 7e1e7fa..0aa72ae 100644 --- a/include/qrcode/code/code_block.h +++ b/include/qrcode/code/code_block.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/code/code_capacity.h b/include/qrcode/code/code_capacity.h index 50b818e..f9c3a5d 100644 --- a/include/qrcode/code/code_capacity.h +++ b/include/qrcode/code/code_capacity.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/code/codeword_view.h b/include/qrcode/code/codeword_view.h index 5a0040c..1eeea9f 100644 --- a/include/qrcode/code/codeword_view.h +++ b/include/qrcode/code/codeword_view.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/code/error_correction_code.h b/include/qrcode/code/error_correction_code.h index 33cf3d8..0159432 100644 --- a/include/qrcode/code/error_correction_code.h +++ b/include/qrcode/code/error_correction_code.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/code/error_correction_polynomial.h b/include/qrcode/code/error_correction_polynomial.h index a84cbb1..ee30099 100644 --- a/include/qrcode/code/error_correction_polynomial.h +++ b/include/qrcode/code/error_correction_polynomial.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/code/extended_remainder.h b/include/qrcode/code/extended_remainder.h index f05d4bf..025d186 100644 --- a/include/qrcode/code/extended_remainder.h +++ b/include/qrcode/code/extended_remainder.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/code/format_encoding.h b/include/qrcode/code/format_encoding.h index 8af5629..3fdc2de 100644 --- a/include/qrcode/code/format_encoding.h +++ b/include/qrcode/code/format_encoding.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/code/gf2p8.h b/include/qrcode/code/gf2p8.h index d694a0a..5b7da4a 100644 --- a/include/qrcode/code/gf2p8.h +++ b/include/qrcode/code/gf2p8.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/code/lfsr.h b/include/qrcode/code/lfsr.h index 2e361fc..380aebf 100644 --- a/include/qrcode/code/lfsr.h +++ b/include/qrcode/code/lfsr.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/code/padding_view.h b/include/qrcode/code/padding_view.h index de14fff..1d769ec 100644 --- a/include/qrcode/code/padding_view.h +++ b/include/qrcode/code/padding_view.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -80,7 +80,7 @@ namespace qrcode::code::detail } [[nodiscard]] friend constexpr auto operator==( - padding_view_iterator const& a, padding_view_iterator const& b) noexcept + padding_view_iterator const& a, padding_view_iterator const& b) noexcept -> bool { return a.iterator == b.iterator && a.padding == b.padding @@ -88,7 +88,7 @@ namespace qrcode::code::detail } [[nodiscard]] friend constexpr auto operator==( - padding_view_iterator const& iterator, std::default_sentinel_t const&) noexcept + padding_view_iterator const& iterator, std::default_sentinel_t const&) noexcept -> bool { return iterator.iterator == iterator.sentinel && !iterator.current_padding.has_value(); @@ -105,7 +105,7 @@ namespace qrcode::code::detail template [[nodiscard]] constexpr auto operator!=( padding_view_iterator const& a, - padding_view_iterator const& b) noexcept + padding_view_iterator const& b) noexcept -> bool { return !(*a == b); } @@ -113,7 +113,7 @@ namespace qrcode::code::detail template [[nodiscard]] constexpr auto operator!=( padding_view_iterator const& iterator, - std::default_sentinel_t const& sentinel) noexcept + std::default_sentinel_t const& sentinel) noexcept -> bool { return !(*iterator == sentinel); } diff --git a/include/qrcode/code/polynomial.h b/include/qrcode/code/polynomial.h index 927a51b..932a776 100644 --- a/include/qrcode/code/polynomial.h +++ b/include/qrcode/code/polynomial.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/code/polynomial_view.h b/include/qrcode/code/polynomial_view.h index 0dd9016..7ebda76 100644 --- a/include/qrcode/code/polynomial_view.h +++ b/include/qrcode/code/polynomial_view.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -110,7 +110,7 @@ namespace qrcode::code::detail } [[nodiscard]] friend constexpr auto operator==( - polynomial_view_iterator const& a, polynomial_view_iterator const& b) noexcept + polynomial_view_iterator const& a, polynomial_view_iterator const& b) noexcept -> bool { return a.iterator == b.iterator && a.polynomial_info == b.polynomial_info @@ -118,7 +118,7 @@ namespace qrcode::code::detail } [[nodiscard]] friend constexpr auto operator==( - polynomial_view_iterator const& iterator, std::default_sentinel_t) noexcept + polynomial_view_iterator const& iterator, std::default_sentinel_t) noexcept -> bool { return !iterator.current_value.has_value(); } diff --git a/include/qrcode/code/sequence.h b/include/qrcode/code/sequence.h index a5fe209..e1e6aa5 100644 --- a/include/qrcode/code/sequence.h +++ b/include/qrcode/code/sequence.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/code/sequence_description.h b/include/qrcode/code/sequence_description.h index 9173733..65f02b5 100644 --- a/include/qrcode/code/sequence_description.h +++ b/include/qrcode/code/sequence_description.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/code/sequence_permutation.h b/include/qrcode/code/sequence_permutation.h index d0aa6f7..d1fba7b 100644 --- a/include/qrcode/code/sequence_permutation.h +++ b/include/qrcode/code/sequence_permutation.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -82,7 +82,7 @@ namespace qrcode::code::detail concept indexable_range = requires(T t) { { t[int{}] } -> std::convertible_to; - std::ranges::range; + requires std::ranges::range; }; template @@ -148,42 +148,48 @@ namespace qrcode::code::detail::test namespace qrcode::code { constexpr auto data_codeword_permutation_returns_an_array_representing_the_lookup_table_where_to_place_data_codewords_in_the_sequence() - { - constexpr auto any_sequence = sequence_description{{2,1}, {3,2}, 6}; - - constexpr auto permutation = data_codeword_permutation(any_sequence); - - static_assert(permutation(0) == 0); // 0 1 - static_assert(permutation(1) == 3); // 2 3 4 - static_assert(permutation(2) == 1); // 5 6 7 - static_assert(permutation(3) == 4); // => 0 2 5 1 3 6 4 7 - static_assert(permutation(4) == 6); // => 0 3 1 4 6 2 5 7 - static_assert(permutation(5) == 2); - static_assert(permutation(6) == 5); - static_assert(permutation(7) == 7); + { + static_assert([]() + { + constexpr auto any_sequence = sequence_description{{2,1}, {3,2}, 6}; + + auto const permutation = data_codeword_permutation(any_sequence); + + return permutation(0) == 0 // 0 1 + && permutation(1) == 3 // 2 3 4 + && permutation(2) == 1 // 5 6 7 + && permutation(3) == 4 // => 0 2 5 1 3 6 4 7 + && permutation(4) == 6 // => 0 3 1 4 6 2 5 7 + && permutation(5) == 2 + && permutation(6) == 5 + && permutation(7) == 7; + }()); } constexpr auto error_codeword_permutation_returns_an_array_represening_the_lookup_table_where_to_place_error_codewords_in_the_sequence() - { - constexpr auto any_sequence = sequence_description{{13,4},{14,1},3}; - - constexpr auto permutation = error_codeword_permutation(any_sequence); - - static_assert(permutation(0) == 0); // 0 1 2 - static_assert(permutation(1) == 5); // 3 4 5 - static_assert(permutation(2) == 10); // 6 7 8 - static_assert(permutation(3) == 1); // 9 10 11 - static_assert(permutation(4) == 6); // 12 13 14 - static_assert(permutation(5) == 11); // => 0 3 6 9 12 1 4 7 10 13 2 5 8 11 14 - static_assert(permutation(6) == 2); // => 0 5 10 1 6 11 2 7 12 3 8 13 4 9 14 - static_assert(permutation(7) == 7); - static_assert(permutation(8) == 12); - static_assert(permutation(9) == 3); - static_assert(permutation(10) == 8); - static_assert(permutation(11) == 13); - static_assert(permutation(12) == 4); - static_assert(permutation(13) == 9); - static_assert(permutation(14) == 14); + { + static_assert([]() + { + constexpr auto any_sequence = sequence_description{{13,4},{14,1},3}; + + auto const permutation = error_codeword_permutation(any_sequence); + + return permutation(0) == 0 // 0 1 2 + && permutation(1) == 5 // 3 4 5 + && permutation(2) == 10 // 6 7 8 + && permutation(3) == 1 // 9 10 11 + && permutation(4) == 6 // 12 13 14 + && permutation(5) == 11 // => 0 3 6 9 12 1 4 7 10 13 2 5 8 11 14 + && permutation(6) == 2 // => 0 5 10 1 6 11 2 7 12 3 8 13 4 9 14 + && permutation(7) == 7 + && permutation(8) == 12 + && permutation(9) == 3 + && permutation(10) == 8 + && permutation(11) == 13 + && permutation(12) == 4 + && permutation(13) == 9 + && permutation(14) == 14; + }()); } } #endif diff --git a/include/qrcode/code/sequence_view.h b/include/qrcode/code/sequence_view.h index 8c0c078..a4794df 100644 --- a/include/qrcode/code/sequence_view.h +++ b/include/qrcode/code/sequence_view.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/alphanumeric.h b/include/qrcode/data/alphanumeric.h index bff7263..05c1637 100644 --- a/include/qrcode/data/alphanumeric.h +++ b/include/qrcode/data/alphanumeric.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/alphanumeric_encoder.h b/include/qrcode/data/alphanumeric_encoder.h index dd3f065..e9c0526 100644 --- a/include/qrcode/data/alphanumeric_encoder.h +++ b/include/qrcode/data/alphanumeric_encoder.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/alphanumeric_encoding.h b/include/qrcode/data/alphanumeric_encoding.h index 77cbb70..a1a78b5 100644 --- a/include/qrcode/data/alphanumeric_encoding.h +++ b/include/qrcode/data/alphanumeric_encoding.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/best_fit/best_encoder.h b/include/qrcode/data/best_fit/best_encoder.h index 2356b48..869e90a 100644 --- a/include/qrcode/data/best_fit/best_encoder.h +++ b/include/qrcode/data/best_fit/best_encoder.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/best_fit/data_encoding.h b/include/qrcode/data/best_fit/data_encoding.h index 4e20ddf..56ac127 100644 --- a/include/qrcode/data/best_fit/data_encoding.h +++ b/include/qrcode/data/best_fit/data_encoding.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/best_fit/data_length.h b/include/qrcode/data/best_fit/data_length.h index 9d1fa32..b571d86 100644 --- a/include/qrcode/data/best_fit/data_length.h +++ b/include/qrcode/data/best_fit/data_length.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/bit_stream.h b/include/qrcode/data/bit_stream.h index 9309abd..3a4050d 100644 --- a/include/qrcode/data/bit_stream.h +++ b/include/qrcode/data/bit_stream.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/byte.h b/include/qrcode/data/byte.h index b6a34c6..d5cec8b 100644 --- a/include/qrcode/data/byte.h +++ b/include/qrcode/data/byte.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/byte_encoder.h b/include/qrcode/data/byte_encoder.h index 6b1d2f9..cd15bc6 100644 --- a/include/qrcode/data/byte_encoder.h +++ b/include/qrcode/data/byte_encoder.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/encoders.h b/include/qrcode/data/encoders.h index 5e19c40..742fc97 100644 --- a/include/qrcode/data/encoders.h +++ b/include/qrcode/data/encoders.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/indicator.h b/include/qrcode/data/indicator.h index 9549842..d20599e 100644 --- a/include/qrcode/data/indicator.h +++ b/include/qrcode/data/indicator.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/kanji.h b/include/qrcode/data/kanji.h index e4f8b37..0af02e3 100644 --- a/include/qrcode/data/kanji.h +++ b/include/qrcode/data/kanji.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/kanji_encoder.h b/include/qrcode/data/kanji_encoder.h index 89f70e2..df58796 100644 --- a/include/qrcode/data/kanji_encoder.h +++ b/include/qrcode/data/kanji_encoder.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/kanji_encoding.h b/include/qrcode/data/kanji_encoding.h index 0dbf749..e10ca87 100644 --- a/include/qrcode/data/kanji_encoding.h +++ b/include/qrcode/data/kanji_encoding.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/numeric.h b/include/qrcode/data/numeric.h index 8983996..293b9ec 100644 --- a/include/qrcode/data/numeric.h +++ b/include/qrcode/data/numeric.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/numeric_encoder.h b/include/qrcode/data/numeric_encoder.h index a2eedd4..2bdfbce 100644 --- a/include/qrcode/data/numeric_encoder.h +++ b/include/qrcode/data/numeric_encoder.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/numeric_encoding.h b/include/qrcode/data/numeric_encoding.h index d0cc5ed..289195d 100644 --- a/include/qrcode/data/numeric_encoding.h +++ b/include/qrcode/data/numeric_encoding.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/optimizer/data_encoding.h b/include/qrcode/data/optimizer/data_encoding.h index 45dda32..1b6e1d6 100644 --- a/include/qrcode/data/optimizer/data_encoding.h +++ b/include/qrcode/data/optimizer/data_encoding.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/optimizer/data_length.h b/include/qrcode/data/optimizer/data_length.h index b002614..9a80414 100644 --- a/include/qrcode/data/optimizer/data_length.h +++ b/include/qrcode/data/optimizer/data_length.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/optimizer/determine_mode.h b/include/qrcode/data/optimizer/determine_mode.h index 3802c36..3d0bf9c 100644 --- a/include/qrcode/data/optimizer/determine_mode.h +++ b/include/qrcode/data/optimizer/determine_mode.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/optimizer/dispatch_mode.h b/include/qrcode/data/optimizer/dispatch_mode.h index 6ebce1f..6b288a8 100644 --- a/include/qrcode/data/optimizer/dispatch_mode.h +++ b/include/qrcode/data/optimizer/dispatch_mode.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/optimizer/mode.h b/include/qrcode/data/optimizer/mode.h index ecae7a2..88069c6 100644 --- a/include/qrcode/data/optimizer/mode.h +++ b/include/qrcode/data/optimizer/mode.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/optimizer/optimize.h b/include/qrcode/data/optimizer/optimize.h index f1da3fc..29f3d2e 100644 --- a/include/qrcode/data/optimizer/optimize.h +++ b/include/qrcode/data/optimizer/optimize.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/data/optimizer/optimizer_state.h b/include/qrcode/data/optimizer/optimizer_state.h index 0087518..18f3a83 100644 --- a/include/qrcode/data/optimizer/optimizer_state.h +++ b/include/qrcode/data/optimizer/optimizer_state.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/eci/assignment_number.h b/include/qrcode/eci/assignment_number.h index 37ebeff..77d99b8 100644 --- a/include/qrcode/eci/assignment_number.h +++ b/include/qrcode/eci/assignment_number.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/eci/message_header.h b/include/qrcode/eci/message_header.h index 8167c6d..17b3405 100644 --- a/include/qrcode/eci/message_header.h +++ b/include/qrcode/eci/message_header.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/eci/view.h b/include/qrcode/eci/view.h index 7d61cf2..a68e37e 100644 --- a/include/qrcode/eci/view.h +++ b/include/qrcode/eci/view.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/micro_qr/best_version.h b/include/qrcode/micro_qr/best_version.h index 3e514a6..10b4299 100644 --- a/include/qrcode/micro_qr/best_version.h +++ b/include/qrcode/micro_qr/best_version.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/micro_qr/code_bits.h b/include/qrcode/micro_qr/code_bits.h index ce8fcf4..e5e4566 100644 --- a/include/qrcode/micro_qr/code_bits.h +++ b/include/qrcode/micro_qr/code_bits.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/micro_qr/code_capacity.h b/include/qrcode/micro_qr/code_capacity.h index 9623687..e0e6fda 100644 --- a/include/qrcode/micro_qr/code_capacity.h +++ b/include/qrcode/micro_qr/code_capacity.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/micro_qr/encoders.h b/include/qrcode/micro_qr/encoders.h index 7c6a4b3..2105f70 100644 --- a/include/qrcode/micro_qr/encoders.h +++ b/include/qrcode/micro_qr/encoders.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/micro_qr/error_correction.h b/include/qrcode/micro_qr/error_correction.h index 8a4b196..e4889e0 100644 --- a/include/qrcode/micro_qr/error_correction.h +++ b/include/qrcode/micro_qr/error_correction.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/micro_qr/finalize_symbol.h b/include/qrcode/micro_qr/finalize_symbol.h index 4c74988..a96ce5f 100644 --- a/include/qrcode/micro_qr/finalize_symbol.h +++ b/include/qrcode/micro_qr/finalize_symbol.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -60,44 +60,47 @@ namespace qrcode::micro_qr { constexpr auto finalize_determines_the_best_mask_and_stores_its_id_in_given_symbol() { - using qrcode::structure::make_matrix; - using namespace std::literals; - constexpr auto any_designator = *make_designator(symbol_version::M2, error_correction::level_L); - constexpr auto any_unmasked = make_matrix({13,13}, - "*******-*-*-*" - "*-----*--++,," - "*-***-*--,,++" - "*-***-*--,,,+" - "*-***-*--++,+" - "*-----*--,,,," - "*******--,,,+" - "---------,,+," - "*--------,,,," - "-,,,+,,+,,+,," - "*++++,+++,,,," - "-,,,+,,,,+,,," - "*,,,+,+,,,++,"sv - ); - constexpr auto selected_mask_id = 1; - - static_assert(finalize(any_unmasked, any_designator) == symbol{ - any_designator, selected_mask_id, - make_matrix({13,13}, + static_assert([]() + { + using qrcode::structure::make_matrix; + using namespace std::literals; + constexpr auto any_designator = *make_designator(symbol_version::M2, error_correction::level_L); + auto const any_unmasked = make_matrix({13,13}, "*******-*-*-*" - "*-----*-*++,+" + "*-----*--++,," + "*-***-*--,,++" + "*-***-*--,,,+" "*-***-*--++,+" - "*-***-*--++++" - "*-***-*-*++,," - "*-----*-*,,,+" - "*******--++++" - "---------++,," - "**-*----*,,,+" - "-++,+,+,+,+,+" - "*++,,+++++++," - "-,,+,+,,,,++," - "*++,+,,++,+++"sv - ) - }); + "*-----*--,,,," + "*******--,,,+" + "---------,,+," + "*--------,,,," + "-,,,+,,+,,+,," + "*++++,+++,,,," + "-,,,+,,,,+,,," + "*,,,+,+,,,++,"sv + ); + constexpr auto selected_mask_id = 1; + + return finalize(any_unmasked, any_designator) == symbol{ + any_designator, selected_mask_id, + make_matrix({13,13}, + "*******-*-*-*" + "*-----*-*++,+" + "*-***-*--++,+" + "*-***-*--++++" + "*-***-*-*++,," + "*-----*-*,,,+" + "*******--++++" + "---------++,," + "**-*----*,,,+" + "-++,+,+,+,+,+" + "*++,,+++++++," + "-,,+,+,,,,++," + "*++,+,,++,+++"sv + ) + }; + }()); } } #endif diff --git a/include/qrcode/micro_qr/finder_pattern.h b/include/qrcode/micro_qr/finder_pattern.h index a4bc6e4..bbce990 100644 --- a/include/qrcode/micro_qr/finder_pattern.h +++ b/include/qrcode/micro_qr/finder_pattern.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/micro_qr/format_information.h b/include/qrcode/micro_qr/format_information.h index cf281fd..cea8523 100644 --- a/include/qrcode/micro_qr/format_information.h +++ b/include/qrcode/micro_qr/format_information.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/micro_qr/generator_degree.h b/include/qrcode/micro_qr/generator_degree.h index f6538c0..067e13e 100644 --- a/include/qrcode/micro_qr/generator_degree.h +++ b/include/qrcode/micro_qr/generator_degree.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/micro_qr/mask_pattern.h b/include/qrcode/micro_qr/mask_pattern.h index 8f74ad3..e872869 100644 --- a/include/qrcode/micro_qr/mask_pattern.h +++ b/include/qrcode/micro_qr/mask_pattern.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/micro_qr/micro_qr.h b/include/qrcode/micro_qr/micro_qr.h index e301c81..27cc587 100644 --- a/include/qrcode/micro_qr/micro_qr.h +++ b/include/qrcode/micro_qr/micro_qr.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -133,68 +133,74 @@ namespace qrcode::micro_qr { constexpr auto micro_qr_symbols_can_be_generated_from_given_version_and_error_level() { - using qrcode::structure::make_matrix; - using namespace std::literals; - constexpr auto any_data = "01234567"sv; - constexpr auto any_version = symbol_version::M2; - constexpr auto any_error_level = error_correction::level_L; - constexpr auto selected_mask_id = 1; - - constexpr auto s = make_symbol(any_data, any_version, any_error_level).value(); - - static_assert(s == symbol{ - *make_designator(any_version, any_error_level), - selected_mask_id, - make_matrix({13,13}, - "*******-*-*-*" - "*-----*-*++,+" - "*-***-*--++,+" - "*-***-*--++++" - "*-***-*-*++,," - "*-----*-*,,,+" - "*******--++++" - "---------++,," - "**-*----*,,,+" - "-++,+,+,+,+,+" - "*++,,+++++++," - "-,,+,+,,,,++," - "*++,+,,++,+++"sv - ) - }); + static_assert([]() + { + using qrcode::structure::make_matrix; + using namespace std::literals; + constexpr auto any_data = "01234567"sv; + constexpr auto any_version = symbol_version::M2; + constexpr auto any_error_level = error_correction::level_L; + constexpr auto selected_mask_id = 1; + + auto const s = make_symbol(any_data, any_version, any_error_level).value(); + + return s == symbol{ + *make_designator(any_version, any_error_level), + selected_mask_id, + make_matrix({13,13}, + "*******-*-*-*" + "*-----*-*++,+" + "*-***-*--++,+" + "*-***-*--++++" + "*-***-*-*++,," + "*-----*-*,,,+" + "*******--++++" + "---------++,," + "**-*----*,,,+" + "-++,+,+,+,+,+" + "*++,,+++++++," + "-,,+,+,,,,++," + "*++,+,,++,+++"sv + ) + }; + }()); } constexpr auto micro_qr_symbols_can_be_generated_from_given_version_and_error_level2() { - using qrcode::structure::make_matrix; - using namespace std::literals; - constexpr auto any_data = "Wikipedia"sv; - constexpr auto any_error_level = error_correction::level_L; - constexpr auto selected_version = symbol_version::M3; - constexpr auto selected_mask_id = 2; - - constexpr auto s = make_symbol(any_data, any_error_level).value(); - - static_assert(s == symbol{ - *make_designator(selected_version, any_error_level), - selected_mask_id, - make_matrix({15,15}, - "*******-*-*-*-*" - "*-----*--,,+,+," - "*-***-*-*++++++" - "*-***-*-*,+,,++" - "*-***-*--,,+,++" - "*-----*-*,+,+,+" - "*******--+,,++," - "---------+,+,,+" - "******---,+,+,+" - "-,,+,,++,,,,+++" - "*++,++,++++,+++" - "-+,,,,+,,+++,+," - "*,+++++,+++,+,+" - "-+,,,,+,,+,+++," - "*++,++,+,+,++++"sv - ) - }); + static_assert([]() + { + using qrcode::structure::make_matrix; + using namespace std::literals; + constexpr auto any_data = "Wikipedia"sv; + constexpr auto any_error_level = error_correction::level_L; + constexpr auto selected_version = symbol_version::M3; + constexpr auto selected_mask_id = 2; + + auto const s = make_symbol(any_data, any_error_level).value(); + + return s == symbol{ + *make_designator(selected_version, any_error_level), + selected_mask_id, + make_matrix({15,15}, + "*******-*-*-*-*" + "*-----*--,,+,+," + "*-***-*-*++++++" + "*-***-*-*,+,,++" + "*-***-*--,,+,++" + "*-----*-*,+,+,+" + "*******--+,,++," + "---------+,+,,+" + "******---,+,+,+" + "-,,+,,++,,,,+++" + "*++,++,++++,+++" + "-+,,,,+,,+++,+," + "*,+++++,+++,+,+" + "-+,,,,+,,+,+++," + "*++,++,+,+,++++"sv + ) + }; + }()); } } #endif diff --git a/include/qrcode/micro_qr/penalty_score.h b/include/qrcode/micro_qr/penalty_score.h index 9dd41ee..d0992d7 100644 --- a/include/qrcode/micro_qr/penalty_score.h +++ b/include/qrcode/micro_qr/penalty_score.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -127,43 +127,50 @@ namespace qrcode::micro_qr::detail::test constexpr auto horizontal_score_counts_the_number_of_non_zeros_along_the_lower_side_edge() { - using namespace std::literals; - using qrcode::structure::make_matrix; - constexpr auto any_matrix = make_matrix({11,11}, - "..........." - "..........." - "..........." - "..........." - "..........." - "..........." - "..........." - "..........." - "..........." - "..........." - "++,,+,+,++,"sv - // 11001010110 - ); - static_assert(horizontal_score(any_matrix) == (/*1+*/1+0+0+1+0+1+0+1+1+0)); + static_assert([]() + { + using namespace std::literals; + using qrcode::structure::make_matrix; + const auto any_matrix = make_matrix({11,11}, + "..........." + "..........." + "..........." + "..........." + "..........." + "..........." + "..........." + "..........." + "..........." + "..........." + "++,,+,+,++,"sv + // 11001010110 + ); + return horizontal_score(any_matrix) == (/*1+*/1+0+0+1+0+1+0+1+1+0); + }()); } constexpr auto vertical_score_counts_the_number_of_non_zeros_along_the_right_side_edge() { - using namespace std::literals; - using qrcode::structure::make_matrix; - constexpr auto any_matrix = make_matrix({11,11}, - "..........+" // 1 - "..........+" // 1 - "..........," // 0 - "..........," // 0 - "..........+" // 1 - "..........," // 0 - "..........," // 0 - "..........+" // 1 - "..........+" // 1 - "..........," // 0 - "..........+"sv // 1 - ); - static_assert(vertical_score(any_matrix) == (/*1+*/1+0+0+1+0+0+1+1+0+1)); + static_assert([]() + { + using namespace std::literals; + using qrcode::structure::make_matrix; + auto const any_matrix = make_matrix({11,11}, + "..........+" // 1 + "..........+" // 1 + "..........," // 0 + "..........," // 0 + "..........+" // 1 + "..........," // 0 + "..........," // 0 + "..........+" // 1 + "..........+" // 1 + "..........," // 0 + "..........+"sv // 1 + ); + return vertical_score(any_matrix) == (/*1+*/1+0+0+1+0+0+1+1+0+1); + }()); + } constexpr auto negative_scores_are_infinite_by_default() @@ -194,28 +201,31 @@ namespace qrcode::micro_qr::test { constexpr auto penalty_score_returns_the_high_score_of_given_matrix() { - using namespace std::literals; - using qrcode::structure::make_matrix; - constexpr auto any_matrix = make_matrix({17,17}, - "................+" - "................+" - "................+" - "................," - "................," - "................+" - "................+" - "................," - "................+" - "................," - "................+" - "................," - "................+" - "................," - "................," - "................+" - "+,,+++,,+,+,,+,,,"sv - ); - static_assert(penalty_score(any_matrix).value == 104); + static_assert([]() + { + using namespace std::literals; + using qrcode::structure::make_matrix; + auto const any_matrix = make_matrix({17,17}, + "................+" + "................+" + "................+" + "................," + "................," + "................+" + "................+" + "................," + "................+" + "................," + "................+" + "................," + "................+" + "................," + "................," + "................+" + "+,,+++,,+,+,,+,,,"sv + ); + return penalty_score(any_matrix).value == 104; + }()); } } #endif \ No newline at end of file diff --git a/include/qrcode/micro_qr/raw_code.h b/include/qrcode/micro_qr/raw_code.h index 7e969e7..d8c180e 100644 --- a/include/qrcode/micro_qr/raw_code.h +++ b/include/qrcode/micro_qr/raw_code.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -67,31 +67,34 @@ namespace qrcode::micro_qr::test { constexpr auto micro_qr_code_can_be_generated_from_given_version_and_error_level() { - constexpr auto any_content = std::array{{ - 0,1,0,0,0,0,0,0, 0,0,0,1,1,0,0,0, 1,0,1,0,1,1,0,0, 1,1,0,0,0,0,1,1, 0,0,0,0,0,0,0,0, - 1,0,0,0,0,1,1,0, 0,0,0,0,1,1,0,1, 0,0,1,0,0,0,1,0, 1,0,1,0,1,1,1,0, 0,0,1,1,0,0,0,0 - }}; // 01234567 (level L) - constexpr auto any_version = symbol_version::M2; + static_assert([]() + { + constexpr auto any_content = std::array{{ + 0,1,0,0,0,0,0,0, 0,0,0,1,1,0,0,0, 1,0,1,0,1,1,0,0, 1,1,0,0,0,0,1,1, 0,0,0,0,0,0,0,0, + 1,0,0,0,0,1,1,0, 0,0,0,0,1,1,0,1, 0,0,1,0,0,0,1,0, 1,0,1,0,1,1,1,0, 0,0,1,1,0,0,0,0 + }}; // 01234567 (level L) + constexpr auto any_version = symbol_version::M2; - constexpr auto symbol = make_raw_code(any_version, any_content); + auto const symbol = make_raw_code(any_version, any_content); - using qrcode::structure::make_matrix; - using namespace std::literals; - static_assert(symbol == make_matrix({13,13}, - "*******-*-*-*" - "*-----*--++,," - "*-***-*--,,++" - "*-***-*--,,,+" - "*-***-*--++,+" - "*-----*--,,,," - "*******--,,,+" - "---------,,+," - "*--------,,,," - "-,,,+,,+,,+,," - "*++++,+++,,,," - "-,,,+,,,,+,,," - "*,,,+,+,,,++,"sv - )); + using qrcode::structure::make_matrix; + using namespace std::literals; + return symbol == make_matrix({13,13}, + "*******-*-*-*" + "*-----*--++,," + "*-***-*--,,++" + "*-***-*--,,,+" + "*-***-*--++,+" + "*-----*--,,,," + "*******--,,,+" + "---------,,+," + "*--------,,,," + "-,,,+,,+,,+,," + "*++++,+++,,,," + "-,,,+,,,,+,,," + "*,,,+,+,,,++,"sv + ); + }()); } } #endif \ No newline at end of file diff --git a/include/qrcode/micro_qr/separator_pattern.h b/include/qrcode/micro_qr/separator_pattern.h index 1276910..1a809d0 100644 --- a/include/qrcode/micro_qr/separator_pattern.h +++ b/include/qrcode/micro_qr/separator_pattern.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/micro_qr/symbol_designator.h b/include/qrcode/micro_qr/symbol_designator.h index e5f7b2a..4155888 100644 --- a/include/qrcode/micro_qr/symbol_designator.h +++ b/include/qrcode/micro_qr/symbol_designator.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -46,7 +46,7 @@ namespace qrcode::micro_qr return designator.error_level; } - [[nodiscard]] friend constexpr auto make_designator( + friend constexpr auto make_designator( symbol_version version, std::optional error_level) noexcept -> std::optional; diff --git a/include/qrcode/micro_qr/symbol_number.h b/include/qrcode/micro_qr/symbol_number.h index ca6371f..050fbb5 100644 --- a/include/qrcode/micro_qr/symbol_number.h +++ b/include/qrcode/micro_qr/symbol_number.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/micro_qr/symbol_version.h b/include/qrcode/micro_qr/symbol_version.h index 1bbca9b..5949fc3 100644 --- a/include/qrcode/micro_qr/symbol_version.h +++ b/include/qrcode/micro_qr/symbol_version.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/micro_qr/timing_pattern.h b/include/qrcode/micro_qr/timing_pattern.h index 153d778..2ed8a9a 100644 --- a/include/qrcode/micro_qr/timing_pattern.h +++ b/include/qrcode/micro_qr/timing_pattern.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/micro_qr/total_data_bits.h b/include/qrcode/micro_qr/total_data_bits.h index dc31e98..e485324 100644 --- a/include/qrcode/micro_qr/total_data_bits.h +++ b/include/qrcode/micro_qr/total_data_bits.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/adjacent_score.h b/include/qrcode/qr/adjacent_score.h index 6b75fda..9e634b4 100644 --- a/include/qrcode/qr/adjacent_score.h +++ b/include/qrcode/qr/adjacent_score.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/alignment_pattern.h b/include/qrcode/qr/alignment_pattern.h index 6ff4a68..5995f13 100644 --- a/include/qrcode/qr/alignment_pattern.h +++ b/include/qrcode/qr/alignment_pattern.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -128,6 +128,11 @@ namespace qrcode::qr::detail std::ranges::copy(bits, begin(range)); } }; + + [[nodiscard]] constexpr auto size(alignment_pattern const& pattern) noexcept + { + return pattern.size(); + } } namespace qrcode::qr @@ -262,7 +267,7 @@ namespace qrcode::qr::detail::test constexpr auto alignment_positions_returns_all_positions_of_center_modules_of_alignment_patterns() { static_assert(std::ranges::equal(alignment_positions(dimension{21,21}), std::array{})); - static_assert(std::ranges::equal(alignment_positions(dimension{25,25}), std::array{{18,18}})); + static_assert(std::ranges::equal(alignment_positions(dimension{25,25}), std::array{position{18,18}})); static_assert(std::ranges::equal(alignment_positions( dimension{45,45}), std::array{{{22,6},{6,22},{22,22},{38,22},{22,38},{38,38}}})); } diff --git a/include/qrcode/qr/best_version.h b/include/qrcode/qr/best_version.h index cbeabd4..23a0ba7 100644 --- a/include/qrcode/qr/best_version.h +++ b/include/qrcode/qr/best_version.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/code_bits.h b/include/qrcode/qr/code_bits.h index 2ccd715..2bc2ef7 100644 --- a/include/qrcode/qr/code_bits.h +++ b/include/qrcode/qr/code_bits.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/code_capacity.h b/include/qrcode/qr/code_capacity.h index 3f16f71..9e149b9 100644 --- a/include/qrcode/qr/code_capacity.h +++ b/include/qrcode/qr/code_capacity.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/dark_module_score.h b/include/qrcode/qr/dark_module_score.h index 76d967f..6e44cee 100644 --- a/include/qrcode/qr/dark_module_score.h +++ b/include/qrcode/qr/dark_module_score.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -85,15 +85,18 @@ namespace qrcode::qr::detail::test { constexpr auto dark_module_count_returns_the_number_of_dark_modules() { - using qrcode::structure::make_matrix; - - constexpr auto some_modules = make_matrix({7,3}, std::array{ - 1,0,0,0,0,0,1, - 1,0,1,1,0,0,1, - 0,0,0,0,0,0,1 - }); - - static_assert(dark_module_count(some_modules) == 7); + static_assert([]() + { + using qrcode::structure::make_matrix; + + auto const some_modules = make_matrix({7,3}, std::array{ + 1,0,0,0,0,0,1, + 1,0,1,1,0,0,1, + 0,0,0,0,0,0,1 + }); + + return dark_module_count(some_modules) == 7; + }()); } constexpr auto nearest_five_percentage_step_returns_the_distance_to_50_percent_in_five_percent_steps() @@ -118,15 +121,18 @@ namespace qrcode::qr::test { constexpr auto dark_module_score_returns_the_penalty_score_derived_from_number_of_five_percent_steps_away_from_50_percent_dark_modules() { - using qrcode::structure::make_matrix; - - constexpr auto some_modules = make_matrix({7,3}, std::array{ - 1,0,0,0,0,0,1, - 1,0,1,1,0,0,1, - 0,0,0,0,0,0,1 - }); - - static_assert(dark_module_score(some_modules) == (3 * penalty_weight(4))); + static_assert([]() + { + using qrcode::structure::make_matrix; + + auto const some_modules = make_matrix({7,3}, std::array{ + 1,0,0,0,0,0,1, + 1,0,1,1,0,0,1, + 0,0,0,0,0,0,1 + }); + + return dark_module_score(some_modules) == (3 * penalty_weight(4)); + }()); } } #endif \ No newline at end of file diff --git a/include/qrcode/qr/data_encoding.h b/include/qrcode/qr/data_encoding.h index 7bfb52b..0c63bce 100644 --- a/include/qrcode/qr/data_encoding.h +++ b/include/qrcode/qr/data_encoding.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/data_length.h b/include/qrcode/qr/data_length.h index 1604416..2b03555 100644 --- a/include/qrcode/qr/data_length.h +++ b/include/qrcode/qr/data_length.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/encoders.h b/include/qrcode/qr/encoders.h index 56213ee..bd6de52 100644 --- a/include/qrcode/qr/encoders.h +++ b/include/qrcode/qr/encoders.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/error_correction.h b/include/qrcode/qr/error_correction.h index bd1e06c..bb6d2ae 100644 --- a/include/qrcode/qr/error_correction.h +++ b/include/qrcode/qr/error_correction.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/finalize_symbol.h b/include/qrcode/qr/finalize_symbol.h index a047f9c..073a49c 100644 --- a/include/qrcode/qr/finalize_symbol.h +++ b/include/qrcode/qr/finalize_symbol.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -59,62 +59,65 @@ namespace qrcode::qr { constexpr auto finalize_determines_the_best_mask_and_stores_its_id_in_given_symbol() { - using qrcode::structure::make_matrix; - using namespace std::literals; + static_assert([]() + { + using qrcode::structure::make_matrix; + using namespace std::literals; - constexpr auto any_designator = symbol_designator{symbol_version{1}, error_correction::level_M}; - constexpr auto any_unmasked = make_matrix({21,21}, - "*******--,,+,-*******" - "*-----*--,++,-*-----*" - "*-***-*--+,,+-*-***-*" - "*-***-*--,,,+-*-***-*" - "*-***-*--+++,-*-***-*" - "*-----*--+,,,-*-----*" - "*******-*-*-*-*******" - "---------+,+,--------" - "------*--,,,,--------" - "+,,,,+-++++,,,,,,+,,," - "+,++,,*+,,,+++,+++,++" - "+,,++,-,,,,,+,,,++,,," - "+,,,++*+++,+++,++,+,," - "--------*+++,+++,+,,," - "*******--,+,,,+,,,+,," - "*-----*--+++,+++,,,,+" - "*-***-*--+,,,,,,,+,,," - "*-***-*--,,,,,,,,,+,," - "*-***-*--+++++,++,,,," - "*-----*--+,,+,,,+,,+," - "*******--,++++,++,,,,"sv - ); - constexpr auto selected_mask_id = 0; - - static_assert(finalize(any_unmasked, any_designator) == symbol{ - any_designator, - selected_mask_id, - make_matrix({21,21}, - "*******--,+++-*******" - "*-----*-*++,,-*-----*" - "*-***-*--++,,-*-***-*" - "*-***-*--+,++-*-***-*" - "*-***-*-*+,++-*-***-*" - "*-----*--,,+,-*-----*" + constexpr auto any_designator = symbol_designator{symbol_version{1}, error_correction::level_M}; + auto const any_unmasked = make_matrix({21,21}, + "*******--,,+,-*******" + "*-----*--,++,-*-----*" + "*-***-*--+,,+-*-***-*" + "*-***-*--,,,+-*-***-*" + "*-***-*--+++,-*-***-*" + "*-----*--+,,,-*-----*" "*******-*-*-*-*******" - "---------,,,,--------" - "*-*-*-*--,+,+---*--*-" - "++,+,,-,+,++,+,+,,,+," - ",,,++,*++,++,+++,+++," - "++,,++-+,+,+++,++,,+," - ",,+,,+*+,+++,+++,,,,+" - "--------*,+,,,+,,,,+," - "*******--,,,+,,,+,,,+" - "*-----*--,+,,,+,,+,++" - "*-***-*-*++,+,+,+++,+" - "*-***-*--+,+,+,+,+++," - "*-***-*-*+,+,+++,,+,+" - "*-----*--,,+++,+++,,," - "*******-*,,+,+++,,+,+"sv - ) - }); + "---------+,+,--------" + "------*--,,,,--------" + "+,,,,+-++++,,,,,,+,,," + "+,++,,*+,,,+++,+++,++" + "+,,++,-,,,,,+,,,++,,," + "+,,,++*+++,+++,++,+,," + "--------*+++,+++,+,,," + "*******--,+,,,+,,,+,," + "*-----*--+++,+++,,,,+" + "*-***-*--+,,,,,,,+,,," + "*-***-*--,,,,,,,,,+,," + "*-***-*--+++++,++,,,," + "*-----*--+,,+,,,+,,+," + "*******--,++++,++,,,,"sv + ); + constexpr auto selected_mask_id = 0; + + return finalize(any_unmasked, any_designator) == symbol{ + any_designator, + selected_mask_id, + make_matrix({21,21}, + "*******--,+++-*******" + "*-----*-*++,,-*-----*" + "*-***-*--++,,-*-***-*" + "*-***-*--+,++-*-***-*" + "*-***-*-*+,++-*-***-*" + "*-----*--,,+,-*-----*" + "*******-*-*-*-*******" + "---------,,,,--------" + "*-*-*-*--,+,+---*--*-" + "++,+,,-,+,++,+,+,,,+," + ",,,++,*++,++,+++,+++," + "++,,++-+,+,+++,++,,+," + ",,+,,+*+,+++,+++,,,,+" + "--------*,+,,,+,,,,+," + "*******--,,,+,,,+,,,+" + "*-----*--,+,,,+,,+,++" + "*-***-*-*++,+,+,+++,+" + "*-***-*--+,+,+,+,+++," + "*-***-*-*+,+,+++,,+,+" + "*-----*--,,+++,+++,,," + "*******-*,,+,+++,,+,+"sv + ) + }; + }()); } } #endif diff --git a/include/qrcode/qr/finder_like_score.h b/include/qrcode/qr/finder_like_score.h index d7cd4f9..affbe79 100644 --- a/include/qrcode/qr/finder_like_score.h +++ b/include/qrcode/qr/finder_like_score.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -138,34 +138,41 @@ namespace qrcode::qr::detail::test constexpr auto horizontal_finder_like_score_searches_horizontally_for_finder_pattern_in_given_matrix_and_returns_penalties_if_pattern_has_been_found() { - using qrcode::structure::make_matrix; - constexpr auto some_modules = make_matrix({11,3}, std::array{ - 1,0,1,1,1,0,1,0,0,0,0, - 1,0,0,0,0,0,1,0,0,0,1, - 0,0,0,0,1,0,1,1,1,0,1, - }); - - static_assert(horizontal_finder_like_score(some_modules) == (2 * penalty_weight(3))); + static_assert([]() + { + using qrcode::structure::make_matrix; + auto const some_modules = make_matrix({11,3}, std::array{ + 1,0,1,1,1,0,1,0,0,0,0, + 1,0,0,0,0,0,1,0,0,0,1, + 0,0,0,0,1,0,1,1,1,0,1, + }); + + return horizontal_finder_like_score(some_modules) == (2 * penalty_weight(3)); + }()); } constexpr auto vertical_finder_like_score_searches_vertically_for_finder_pattern_in_given_matrix_and_returns_penalties_if_pattern_has_been_found() { - using qrcode::structure::make_matrix; - constexpr auto some_modules = make_matrix({3,11}, std::array{ - 1,1,0, - 0,0,0, - 1,0,0, - 1,0,0, - 1,0,1, - 0,0,0, - 1,1,1, - 0,0,1, - 0,0,1, - 0,0,0, - 0,1,1 - }); - - static_assert(vertical_finder_like_score(some_modules) == (2 * penalty_weight(3))); + static_assert([]() + { + using qrcode::structure::make_matrix; + auto const some_modules = make_matrix({3,11}, std::array{ + 1,1,0, + 0,0,0, + 1,0,0, + 1,0,0, + 1,0,1, + 0,0,0, + 1,1,1, + 0,0,1, + 0,0,1, + 0,0,0, + 0,1,1 + }); + + return vertical_finder_like_score(some_modules) == (2 * penalty_weight(3)); + }()); + } } @@ -173,22 +180,25 @@ namespace qrcode::qr::test { constexpr auto finder_like_score_searches_for_finder_pattern_in_given_matrix_and_returns_penalties_if_pattern_has_been_found() { - using qrcode::structure::make_matrix; - constexpr auto some_modules = make_matrix({11,11}, std::array{ - 1,1,1,1,1,1,1,0,0,0,1, - 1,0,0,0,0,0,1,0,0,0,0, - 1,0,1,1,1,0,1,0,0,0,0, - 1,0,1,1,1,0,1,0,0,0,1, - 1,0,1,1,1,0,1,0,1,0,1, - 1,0,0,0,0,0,1,0,0,0,1, - 1,1,1,1,1,1,1,0,1,0,1, - 0,0,0,0,0,0,0,0,1,0,1, - 1,1,0,0,1,1,1,0,1,0,1, - 1,0,0,0,0,0,1,0,0,1,1, - 0,0,0,1,1,0,1,0,1,0,0 - }); - - static_assert(finder_like_score(some_modules) == (3 * penalty_weight(3))); + static_assert([]() + { + using qrcode::structure::make_matrix; + auto const some_modules = make_matrix({11,11}, std::array{ + 1,1,1,1,1,1,1,0,0,0,1, + 1,0,0,0,0,0,1,0,0,0,0, + 1,0,1,1,1,0,1,0,0,0,0, + 1,0,1,1,1,0,1,0,0,0,1, + 1,0,1,1,1,0,1,0,1,0,1, + 1,0,0,0,0,0,1,0,0,0,1, + 1,1,1,1,1,1,1,0,1,0,1, + 0,0,0,0,0,0,0,0,1,0,1, + 1,1,0,0,1,1,1,0,1,0,1, + 1,0,0,0,0,0,1,0,0,1,1, + 0,0,0,1,1,0,1,0,1,0,0 + }); + + return finder_like_score(some_modules) == (3 * penalty_weight(3)); + }()); } } #endif \ No newline at end of file diff --git a/include/qrcode/qr/finder_pattern.h b/include/qrcode/qr/finder_pattern.h index 8fb00d1..9b23cfd 100644 --- a/include/qrcode/qr/finder_pattern.h +++ b/include/qrcode/qr/finder_pattern.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -74,11 +74,14 @@ namespace qrcode::qr } }; - using std::size; + [[nodiscard]] constexpr auto size(finder_pattern const& pattern) noexcept + { + return pattern.size(); + } [[nodiscard]] constexpr auto finder_locations(dimension symbol_size) noexcept { - constexpr auto pattern = size(finder_pattern{}); + auto const pattern = size(finder_pattern{}); auto const left = width(symbol_size) - width(pattern); auto const bottom = height(symbol_size) - height(pattern); return std::array{{{0,0}, {left,0}, {0, bottom}}}; diff --git a/include/qrcode/qr/fit_version.h b/include/qrcode/qr/fit_version.h index 0712e4d..5cd3d1d 100644 --- a/include/qrcode/qr/fit_version.h +++ b/include/qrcode/qr/fit_version.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/format_information.h b/include/qrcode/qr/format_information.h index 47b5634..2f1da10 100644 --- a/include/qrcode/qr/format_information.h +++ b/include/qrcode/qr/format_information.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/generator_degree.h b/include/qrcode/qr/generator_degree.h index 712703d..0a879b6 100644 --- a/include/qrcode/qr/generator_degree.h +++ b/include/qrcode/qr/generator_degree.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/mask_pattern.h b/include/qrcode/qr/mask_pattern.h index fb4985f..a01ef1a 100644 --- a/include/qrcode/qr/mask_pattern.h +++ b/include/qrcode/qr/mask_pattern.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/optimized_data_encoding.h b/include/qrcode/qr/optimized_data_encoding.h index 0d010b3..8cad218 100644 --- a/include/qrcode/qr/optimized_data_encoding.h +++ b/include/qrcode/qr/optimized_data_encoding.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/optimized_data_length.h b/include/qrcode/qr/optimized_data_length.h index f02e984..64920d1 100644 --- a/include/qrcode/qr/optimized_data_length.h +++ b/include/qrcode/qr/optimized_data_length.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/penalty_score.h b/include/qrcode/qr/penalty_score.h index 8306ee9..0bad2a2 100644 --- a/include/qrcode/qr/penalty_score.h +++ b/include/qrcode/qr/penalty_score.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -49,43 +49,46 @@ namespace qrcode::qr::test { constexpr auto penalty_scores_consist_of_adjacent_score_and_same_color_score_and_finder_like_score_and_dark_module_score() { - using qrcode::structure::make_matrix; - using namespace std::literals; + static_assert([]() + { + using qrcode::structure::make_matrix; + using namespace std::literals; - constexpr auto any_matrix = make_matrix({21,21}, - "*******.**....*******" - "*.....*.*..*..*.....*" - "*.***.*.*..**.*.***.*" - "*.***.*.*.....*.***.*" - "*.***.*.*.*...*.***.*" - "*.....*...*...*.....*" - "*******.*.*.*.*******" - "........*............" - ".**.*.**....*.*.*****" - ".*......****....*...*" - "..**.***.**...*.**..." - ".**.**.*..**.*.*.***." - "*...*.*.*.***.***.*.*" - "........**.*..*...*.*" - "*******.*.*....*.**.." - "*.....*..*.**.**.*..." - "*.***.*.*.*...*******" - "*.***.*..*.*.*.*...*." - "*.***.*.*...****.*..*" - "*.....*.*.**.*...*.**" - "*******.....****....*"sv - ); + auto const any_matrix = make_matrix({21,21}, + "*******.**....*******" + "*.....*.*..*..*.....*" + "*.***.*.*..**.*.***.*" + "*.***.*.*.....*.***.*" + "*.***.*.*.*...*.***.*" + "*.....*...*...*.....*" + "*******.*.*.*.*******" + "........*............" + ".**.*.**....*.*.*****" + ".*......****....*...*" + "..**.***.**...*.**..." + ".**.**.*..**.*.*.***." + "*...*.*.*.***.***.*.*" + "........**.*..*...*.*" + "*******.*.*....*.**.." + "*.....*..*.**.**.*..." + "*.***.*.*.*...*******" + "*.***.*..*.*.*.*...*." + "*.***.*.*...****.*..*" + "*.....*.*.**.*...*.**" + "*******.....****....*"sv + ); - constexpr auto s1 = adjacent_score(any_matrix); - constexpr auto s2 = same_color_score(any_matrix); - constexpr auto s3 = finder_like_score(any_matrix); - constexpr auto s4 = dark_module_score(any_matrix); + auto const s1 = adjacent_score(any_matrix); + auto const s2 = same_color_score(any_matrix); + auto const s3 = finder_like_score(any_matrix); + auto const s4 = dark_module_score(any_matrix); - static_assert(s1 == 180); - static_assert(s2 == 90); - static_assert(s3 == 80); - static_assert(s4 == 0); - static_assert(penalty_score(any_matrix) == (s1+s2+s3+s4)); + return s1 == 180 + && s2 == 90 + && s3 == 80 + && s4 == 0 + && penalty_score(any_matrix) == (s1+s2+s3+s4); + }()); } } #endif \ No newline at end of file diff --git a/include/qrcode/qr/penalty_weight.h b/include/qrcode/qr/penalty_weight.h index 2b90752..ab79428 100644 --- a/include/qrcode/qr/penalty_weight.h +++ b/include/qrcode/qr/penalty_weight.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/qr.h b/include/qrcode/qr/qr.h index c8b0ce4..0d5d5d8 100644 --- a/include/qrcode/qr/qr.h +++ b/include/qrcode/qr/qr.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -97,137 +97,149 @@ namespace qrcode::qr { constexpr auto qr_symbols_can_be_generated_from_given_version_and_error_level() { - using qrcode::structure::make_matrix; - using namespace std::literals; - - constexpr auto any_data = "01234567"sv; - constexpr auto any_version = symbol_version{1}; - constexpr auto any_error_level = error_correction::level_M; - constexpr auto selected_mask_id = 0; - - constexpr auto s = make_symbol(any_data, any_version, any_error_level).value(); - - static_assert(s == symbol{ - symbol_designator{any_version, any_error_level}, - selected_mask_id, - make_matrix({21,21}, - "*******--,+++-*******" - "*-----*-*++,,-*-----*" - "*-***-*--++,,-*-***-*" - "*-***-*--+,++-*-***-*" - "*-***-*-*+,++-*-***-*" - "*-----*--,,+,-*-----*" - "*******-*-*-*-*******" - "---------,,,,--------" - "*-*-*-*--,+,+---*--*-" - "++,+,,-,+,++,+,+,,,+," - ",,,++,*++,++,+++,+++," - "++,,++-+,+,+++,++,,+," - ",,+,,+*+,+++,+++,,,,+" - "--------*,+,,,+,,,,+," - "*******--,,,+,,,+,,,+" - "*-----*--,+,,,+,,+,++" - "*-***-*-*++,+,+,+++,+" - "*-***-*--+,+,+,+,+++," - "*-***-*-*+,+,+++,,+,+" - "*-----*--,,+++,+++,,," - "*******-*,,+,+++,,+,+"sv - ) - }); + static_assert([]() + { + using qrcode::structure::make_matrix; + using namespace std::literals; + + constexpr auto any_data = "01234567"sv; + constexpr auto any_version = symbol_version{1}; + constexpr auto any_error_level = error_correction::level_M; + constexpr auto selected_mask_id = 0; + + auto const s = make_symbol(any_data, any_version, any_error_level).value(); + + return s == symbol{ + symbol_designator{any_version, any_error_level}, + selected_mask_id, + make_matrix({21,21}, + "*******--,+++-*******" + "*-----*-*++,,-*-----*" + "*-***-*--++,,-*-***-*" + "*-***-*--+,++-*-***-*" + "*-***-*-*+,++-*-***-*" + "*-----*--,,+,-*-----*" + "*******-*-*-*-*******" + "---------,,,,--------" + "*-*-*-*--,+,+---*--*-" + "++,+,,-,+,++,+,+,,,+," + ",,,++,*++,++,+++,+++," + "++,,++-+,+,+++,++,,+," + ",,+,,+*+,+++,+++,,,,+" + "--------*,+,,,+,,,,+," + "*******--,,,+,,,+,,,+" + "*-----*--,+,,,+,,+,++" + "*-***-*-*++,+,+,+++,+" + "*-***-*--+,+,+,+,+++," + "*-***-*-*+,+,+++,,+,+" + "*-----*--,,+++,+++,,," + "*******-*,,+,+++,,+,+"sv + ) + }; + }()); } constexpr auto qr_symbols_can_be_generated_from_given_error_level_and_message() { - using qrcode::structure::make_matrix; - using namespace std::literals; - - constexpr auto any_data = "ABRACADABRA"sv; - constexpr auto any_version = symbol_version{1}; - constexpr auto any_error_level = error_correction::level_M; - constexpr auto selected_mask_id = 7; - - constexpr auto s = make_symbol(any_data, any_error_level).value(); - - static_assert(s == symbol{ - symbol_designator{any_version, any_error_level}, - selected_mask_id, - make_matrix({21,21}, - "*******--,,,,-*******" - "*-----*--+,++-*-----*" - "*-***-*--+++,-*-***-*" - "*-***-*--,,++-*-***-*" - "*-***-*--+,++-*-***-*" - "*-----*-*,+,,-*-----*" - "*******-*-*-*-*******" - "---------+,,,--------" - "*--*-**-*,+++*-*-----" - "++,,+,-++,,+,++++++,," - ",,++++*,,+++,++,,++,," - ",,,,,+-+,,,,+++++,+++" - ",,++,,*,++++,,+,,+++," - "--------*+,,,+++++,+," - "*******--++++,+,++,,+" - "*-----*-*+,,,,+++++,," - "*-***-*--++,+++,+,+,+" - "*-***-*-*,,,,++,,,+++" - "*-***-*--,++,++,,++,+" - "*-----*--,,++,,+,++,+" - "*******-*+,,,+,,+,+,,"sv - ) - }); + static_assert([]() + { + using qrcode::structure::make_matrix; + using namespace std::literals; + + constexpr auto any_data = "ABRACADABRA"sv; + constexpr auto any_version = symbol_version{1}; + constexpr auto any_error_level = error_correction::level_M; + constexpr auto selected_mask_id = 7; + + auto const s = make_symbol(any_data, any_error_level).value(); + + return s == symbol{ + symbol_designator{any_version, any_error_level}, + selected_mask_id, + make_matrix({21,21}, + "*******--,,,,-*******" + "*-----*--+,++-*-----*" + "*-***-*--+++,-*-***-*" + "*-***-*--,,++-*-***-*" + "*-***-*--+,++-*-***-*" + "*-----*-*,+,,-*-----*" + "*******-*-*-*-*******" + "---------+,,,--------" + "*--*-**-*,+++*-*-----" + "++,,+,-++,,+,++++++,," + ",,++++*,,+++,++,,++,," + ",,,,,+-+,,,,+++++,+++" + ",,++,,*,++++,,+,,+++," + "--------*+,,,+++++,+," + "*******--++++,+,++,,+" + "*-----*-*+,,,,+++++,," + "*-***-*--++,+++,+,+,+" + "*-***-*-*,,,,++,,,+++" + "*-***-*--,++,++,,++,+" + "*-----*--,,++,,+,++,+" + "*******-*+,,,+,,+,+,,"sv + ) + }; + }()); } constexpr auto qr_symbol_generation_fails_if_data_is_too_large_for_given_symbol_version() { - using namespace std::literals; - constexpr auto any_data = "This is way too long. Sorry! This does not work!!!"sv; - constexpr auto any_version = symbol_version{1}; - constexpr auto any_error_level = error_correction::level_L; + static_assert([]() + { + using namespace std::literals; + constexpr auto any_data = "This is way too long. Sorry! This does not work!!!"sv; + constexpr auto any_version = symbol_version{1}; + constexpr auto any_error_level = error_correction::level_L; - constexpr auto s = make_symbol(any_data, any_version, any_error_level); + auto const s = make_symbol(any_data, any_version, any_error_level); - static_assert(!s.has_value()); + return !s.has_value(); + }()); } constexpr auto qr_symbols_support_eci_encoding() { - using qrcode::structure::make_matrix; - using namespace std::literals; - - constexpr auto any_eci_message = eci::view{eci::assignment_number{9}, "\xC1\xC2\xC3\xC4\xC5"sv}; - constexpr auto any_version = symbol_version{1}; - constexpr auto any_error_level = error_correction::level_L; - constexpr auto selected_mask_id = 5; - - constexpr auto s = make_symbol(any_eci_message, any_version, any_error_level).value(); - - static_assert(s == symbol{ - symbol_designator{any_version, any_error_level}, - selected_mask_id, - make_matrix({21,21}, - "*******--,,,+-*******" - "*-----*--,+,+-*-----*" - "*-***-*--,+++-*-***-*" - "*-***-*-*,+,+-*-***-*" - "*-***-*-*+,,+-*-***-*" - "*-----*--+,+,-*-----*" - "*******-*-*-*-*******" - "---------,,,,--------" - "**---***-,,+,---**---" - ",,,+,,-+,,,+++,,++,++" - ",,+++,*,,,,,+,++,,++," - "+,,,,+-,+,,++++,,,+,," - "++,+,+*,+,,++++++,+++" - "--------*,,,+,,+,+,,," - "*******-*,++,+,,,,++," - "*-----*-*++,,,+,+,+++" - "*-***-*--,,+,+,,+,,,+" - "*-***-*--+,++++,,+,,," - "*-***-*--,++++,,+++++" - "*-----*-*+,++++,,,+++" - "*******-*++,+,,,++,+,"sv - ) - }); + static_assert([]() + { + using qrcode::structure::make_matrix; + using namespace std::literals; + + constexpr auto any_eci_message = eci::view{eci::assignment_number{9}, "\xC1\xC2\xC3\xC4\xC5"sv}; + constexpr auto any_version = symbol_version{1}; + constexpr auto any_error_level = error_correction::level_L; + constexpr auto selected_mask_id = 5; + + auto const s = make_symbol(any_eci_message, any_version, any_error_level).value(); + + return s == symbol{ + symbol_designator{any_version, any_error_level}, + selected_mask_id, + make_matrix({21,21}, + "*******--,,,+-*******" + "*-----*--,+,+-*-----*" + "*-***-*--,+++-*-***-*" + "*-***-*-*,+,+-*-***-*" + "*-***-*-*+,,+-*-***-*" + "*-----*--+,+,-*-----*" + "*******-*-*-*-*******" + "---------,,,,--------" + "**---***-,,+,---**---" + ",,,+,,-+,,,+++,,++,++" + ",,+++,*,,,,,+,++,,++," + "+,,,,+-,+,,++++,,,+,," + "++,+,+*,+,,++++++,+++" + "--------*,,,+,,+,+,,," + "*******-*,++,+,,,,++," + "*-----*-*++,,,+,+,+++" + "*-***-*--,,+,+,,+,,,+" + "*-***-*--+,++++,,+,,," + "*-***-*--,++++,,+++++" + "*-----*-*+,++++,,,+++" + "*******-*++,+,,,++,+,"sv + ) + }; + }()); } } #endif diff --git a/include/qrcode/qr/raw_code.h b/include/qrcode/qr/raw_code.h index e22bfd0..6da8ba6 100644 --- a/include/qrcode/qr/raw_code.h +++ b/include/qrcode/qr/raw_code.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -73,43 +73,46 @@ namespace qrcode::qr { constexpr auto qr_codes_can_be_generated_from_given_version_and_content_bits() { - using qrcode::structure::make_matrix; - using namespace std::literals; + static_assert([]() + { + using qrcode::structure::make_matrix; + using namespace std::literals; - constexpr auto any_content = std::array{{ - 0,0,0,1,0,0,0,0, 0,0,1,0,0,0,0,0, 0,0,0,0,1,1,0,0, 0,1,0,1,0,1,1,0, 0,1,1,0,0,0,0,1, - 1,0,0,0,0,0,0,0, 1,1,1,0,1,1,0,0, 0,0,0,1,0,0,0,1, 1,1,1,0,1,1,0,0, 0,0,0,1,0,0,0,1, - 1,1,1,0,1,1,0,0, 0,0,0,1,0,0,0,1, 1,1,1,0,1,1,0,0, 0,0,0,1,0,0,0,1, 1,1,1,0,1,1,0,0, - 0,0,0,1,0,0,0,1, 1,0,1,0,0,1,0,1, 0,0,1,0,0,1,0,0, 1,1,0,1,0,1,0,0, 1,1,0,0,0,0,0,1, - 1,1,1,0,1,1,0,1, 0,0,1,1,0,1,1,0, 1,1,0,0,0,1,1,1, 1,0,0,0,0,1,1,1, 0,0,1,0,1,1,0,0, - 0,1,0,1,0,1,0,1 - }}; // 01234567 - constexpr auto any_version = symbol_version{1}; - constexpr auto code = make_raw_code(any_version, any_content); + constexpr auto any_content = std::array{{ + 0,0,0,1,0,0,0,0, 0,0,1,0,0,0,0,0, 0,0,0,0,1,1,0,0, 0,1,0,1,0,1,1,0, 0,1,1,0,0,0,0,1, + 1,0,0,0,0,0,0,0, 1,1,1,0,1,1,0,0, 0,0,0,1,0,0,0,1, 1,1,1,0,1,1,0,0, 0,0,0,1,0,0,0,1, + 1,1,1,0,1,1,0,0, 0,0,0,1,0,0,0,1, 1,1,1,0,1,1,0,0, 0,0,0,1,0,0,0,1, 1,1,1,0,1,1,0,0, + 0,0,0,1,0,0,0,1, 1,0,1,0,0,1,0,1, 0,0,1,0,0,1,0,0, 1,1,0,1,0,1,0,0, 1,1,0,0,0,0,0,1, + 1,1,1,0,1,1,0,1, 0,0,1,1,0,1,1,0, 1,1,0,0,0,1,1,1, 1,0,0,0,0,1,1,1, 0,0,1,0,1,1,0,0, + 0,1,0,1,0,1,0,1 + }}; // 01234567 + constexpr auto any_version = symbol_version{1}; + auto const code = make_raw_code(any_version, any_content); - static_assert(code == make_matrix({21,21}, - "*******--,,+,-*******" - "*-----*--,++,-*-----*" - "*-***-*--+,,+-*-***-*" - "*-***-*--,,,+-*-***-*" - "*-***-*--+++,-*-***-*" - "*-----*--+,,,-*-----*" - "*******-*-*-*-*******" - "---------+,+,--------" - "------*--,,,,--------" - "+,,,,+-++++,,,,,,+,,," - "+,++,,*+,,,+++,+++,++" - "+,,++,-,,,,,+,,,++,,," - "+,,,++*+++,+++,++,+,," - "--------*+++,+++,+,,," - "*******--,+,,,+,,,+,," - "*-----*--+++,+++,,,,+" - "*-***-*--+,,,,,,,+,,," - "*-***-*--,,,,,,,,,+,," - "*-***-*--+++++,++,,,," - "*-----*--+,,+,,,+,,+," - "*******--,++++,++,,,,"sv - )); + return code == make_matrix({21,21}, + "*******--,,+,-*******" + "*-----*--,++,-*-----*" + "*-***-*--+,,+-*-***-*" + "*-***-*--,,,+-*-***-*" + "*-***-*--+++,-*-***-*" + "*-----*--+,,,-*-----*" + "*******-*-*-*-*******" + "---------+,+,--------" + "------*--,,,,--------" + "+,,,,+-++++,,,,,,+,,," + "+,++,,*+,,,+++,+++,++" + "+,,++,-,,,,,+,,,++,,," + "+,,,++*+++,+++,++,+,," + "--------*+++,+++,+,,," + "*******--,+,,,+,,,+,," + "*-----*--+++,+++,,,,+" + "*-***-*--+,,,,,,,+,,," + "*-***-*--,,,,,,,,,+,," + "*-***-*--+++++,++,,,," + "*-----*--+,,+,,,+,,+," + "*******--,++++,++,,,,"sv + ); + }()); } } #endif diff --git a/include/qrcode/qr/same_color_score.h b/include/qrcode/qr/same_color_score.h index ee69d17..5a53b46 100644 --- a/include/qrcode/qr/same_color_score.h +++ b/include/qrcode/qr/same_color_score.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/separator_pattern.h b/include/qrcode/qr/separator_pattern.h index 3addf06..de3ece6 100644 --- a/include/qrcode/qr/separator_pattern.h +++ b/include/qrcode/qr/separator_pattern.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/symbol_designator.h b/include/qrcode/qr/symbol_designator.h index 62827b0..56ae311 100644 --- a/include/qrcode/qr/symbol_designator.h +++ b/include/qrcode/qr/symbol_designator.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/symbol_version.h b/include/qrcode/qr/symbol_version.h index 811a680..d514716 100644 --- a/include/qrcode/qr/symbol_version.h +++ b/include/qrcode/qr/symbol_version.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/timing_pattern.h b/include/qrcode/qr/timing_pattern.h index fa9c794..4967b50 100644 --- a/include/qrcode/qr/timing_pattern.h +++ b/include/qrcode/qr/timing_pattern.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/total_blocks.h b/include/qrcode/qr/total_blocks.h index 00e2512..fcbb3eb 100644 --- a/include/qrcode/qr/total_blocks.h +++ b/include/qrcode/qr/total_blocks.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/total_data_bits.h b/include/qrcode/qr/total_data_bits.h index a8446b8..3900dc2 100644 --- a/include/qrcode/qr/total_data_bits.h +++ b/include/qrcode/qr/total_data_bits.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/version_category.h b/include/qrcode/qr/version_category.h index c657257..858ae61 100644 --- a/include/qrcode/qr/version_category.h +++ b/include/qrcode/qr/version_category.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qr/version_information.h b/include/qrcode/qr/version_information.h index a4e7011..664d723 100644 --- a/include/qrcode/qr/version_information.h +++ b/include/qrcode/qr/version_information.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/qrcode.h b/include/qrcode/qrcode.h index e9291b7..977fa14 100644 --- a/include/qrcode/qrcode.h +++ b/include/qrcode/qrcode.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/result.h b/include/qrcode/result.h index 5bf6c9f..f473722 100644 --- a/include/qrcode/result.h +++ b/include/qrcode/result.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/structure/apply_mask.h b/include/qrcode/structure/apply_mask.h index a3825a4..ca4fdb0 100644 --- a/include/qrcode/structure/apply_mask.h +++ b/include/qrcode/structure/apply_mask.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -86,21 +86,24 @@ namespace qrcode::structure::test { constexpr auto apply_mask_returns_a_callable_which_wraps_the_given_simple_boolean_mask_to_mask_any_given_matrix() { - using namespace std::literals; - constexpr auto any_mask = [](int i, int j) { return i == 1 && j == 0; }; - constexpr auto any_matrix = make_matrix({3,3}, - ",,," - ",,," - ",,,"sv - ); + static_assert([]() + { + using namespace std::literals; + constexpr auto any_mask = [](int i, int j) { return i == 1 && j == 0; }; + auto const any_matrix = make_matrix({3,3}, + ",,," + ",,," + ",,,"sv + ); - constexpr auto f = apply_mask_functor(any_mask); + constexpr auto f = apply_mask_functor(any_mask); - static_assert(f(any_matrix) == make_matrix({3,3}, - ",,," - "+,," - ",,,"sv - )); + return f(any_matrix) == make_matrix({3,3}, + ",,," + "+,," + ",,,"sv + ); + }()); } } #endif \ No newline at end of file diff --git a/include/qrcode/structure/cartesian_product_view.h b/include/qrcode/structure/cartesian_product_view.h index 50081e0..c7413d0 100644 --- a/include/qrcode/structure/cartesian_product_view.h +++ b/include/qrcode/structure/cartesian_product_view.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -86,7 +86,7 @@ namespace qrcode::structure::detail } [[nodiscard]] friend constexpr auto operator==( - cartesian_iterator const& iterator, std::default_sentinel_t) noexcept + cartesian_iterator const& iterator, std::default_sentinel_t) noexcept -> bool { using std::ranges::end; return iterator.i1 == end(*(iterator.range1)); @@ -173,11 +173,10 @@ namespace qrcode::structure::test auto range = cartesian_product_view{std::array{1,2,3,4}, std::array{6,7,8}}; - using positions = std::initializer_list; - return std::ranges::equal(range, positions{ - {1,6},{2,6},{3,6},{4,6}, - {1,7},{2,7},{3,7},{4,7}, - {1,8},{2,8},{3,8},{4,8} + return std::ranges::equal(range, std::array{ + position{1,6}, position{2,6}, position{3,6}, position{4,6}, + position{1,7}, position{2,7}, position{3,7}, position{4,7}, + position{1,8}, position{2,8}, position{3,8}, position{4,8} }); }; static_assert(f()); @@ -190,12 +189,14 @@ namespace qrcode::structure::test auto const range = cartesian_product_view{std::array{1,2,3,4}, std::array{6,7,8}}; - using positions = std::initializer_list; - return std::ranges::equal(range, positions{ - {1,6},{2,6},{3,6},{4,6}, - {1,7},{2,7},{3,7},{4,7}, - {1,8},{2,8},{3,8},{4,8} - }); + return std::ranges::equal( + range, + std::array{ + position{1,6}, position{2,6}, position{3,6}, position{4,6}, + position{1,7}, position{2,7}, position{3,7}, position{4,7}, + position{1,8}, position{2,8}, position{3,8}, position{4,8} + } + ); }; static_assert(f()); } @@ -207,8 +208,13 @@ namespace qrcode::structure::test auto const range = views::cartesian_product(std::array{1,2}, std::array{6,7,8}); - using positions = std::initializer_list; - return std::ranges::equal(range, positions{{1,6},{2,6},{1,7},{2,7},{1,8},{2,8}}); + return std::ranges::equal( + range, + std::array{ + position{1,6}, position{2,6}, position{1,7}, + position{2,7},position{1,8},position{2,8} + } + ); }; static_assert(f()); } @@ -221,8 +227,10 @@ namespace qrcode::structure::test views::cartesian_product(std::array{1,2}, std::array{6,7,8}) | std::views::filter([](auto point) { return point.y > 6; }); - using positions = std::initializer_list; - return std::ranges::equal(range, positions{{1,7},{2,7},{1,8},{2,8}}); + return std::ranges::equal( + range, + std::array{position{1,7},position{2,7},position{1,8},position{2,8}} + ); }; static_assert(f()); } diff --git a/include/qrcode/structure/data_masking.h b/include/qrcode/structure/data_masking.h index 48a334b..33a5f16 100644 --- a/include/qrcode/structure/data_masking.h +++ b/include/qrcode/structure/data_masking.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/structure/dimension.h b/include/qrcode/structure/dimension.h index db4e82f..aecbc9d 100644 --- a/include/qrcode/structure/dimension.h +++ b/include/qrcode/structure/dimension.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/structure/element_view.h b/include/qrcode/structure/element_view.h index 740477c..98ec555 100644 --- a/include/qrcode/structure/element_view.h +++ b/include/qrcode/structure/element_view.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/structure/horizontal_view.h b/include/qrcode/structure/horizontal_view.h index db08f93..7f5a177 100644 --- a/include/qrcode/structure/horizontal_view.h +++ b/include/qrcode/structure/horizontal_view.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/structure/make_matrix.h b/include/qrcode/structure/make_matrix.h index a4ec9d4..69ffbd7 100644 --- a/include/qrcode/structure/make_matrix.h +++ b/include/qrcode/structure/make_matrix.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/structure/matrix.h b/include/qrcode/structure/matrix.h index 57e5480..b7d1b13 100644 --- a/include/qrcode/structure/matrix.h +++ b/include/qrcode/structure/matrix.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -130,30 +130,37 @@ namespace qrcode::structure::test { constexpr auto matrix_elements_are_all_default_initialized() { - constexpr auto any_size = dimension{3, 2}; - - constexpr auto any_matrix = matrix{any_size}; - - static_assert(element_at(any_matrix, {0,0}) == 0); - static_assert(element_at(any_matrix, {1,0}) == 0); - static_assert(element_at(any_matrix, {2,0}) == 0); - static_assert(element_at(any_matrix, {0,1}) == 0); - static_assert(element_at(any_matrix, {1,1}) == 0); - static_assert(element_at(any_matrix, {2,1}) == 0); + static_assert([]() + { + constexpr auto any_size = dimension{3, 2}; + + auto const any_matrix = matrix{any_size}; + + return element_at(any_matrix, {0,0}) == 0 + && element_at(any_matrix, {1,0}) == 0 + && element_at(any_matrix, {2,0}) == 0 + && element_at(any_matrix, {0,1}) == 0 + && element_at(any_matrix, {1,1}) == 0 + && element_at(any_matrix, {2,1}) == 0; + }()); } constexpr auto matrix_elements_can_be_initialized_by_fill_value() { - constexpr auto any_size = dimension{3, 2}; - - constexpr auto any_matrix = matrix{any_size, -1}; - - static_assert(element_at(any_matrix, {0,0}) == -1); - static_assert(element_at(any_matrix, {1,0}) == -1); - static_assert(element_at(any_matrix, {2,0}) == -1); - static_assert(element_at(any_matrix, {0,1}) == -1); - static_assert(element_at(any_matrix, {1,1}) == -1); - static_assert(element_at(any_matrix, {2,1}) == -1); + static_assert([]() + { + constexpr auto any_size = dimension{3, 2}; + constexpr auto any_fill_value = 42; + + auto const any_matrix = matrix{any_size, any_fill_value}; + + return element_at(any_matrix, {0,0}) == any_fill_value + && element_at(any_matrix, {1,0}) == any_fill_value + && element_at(any_matrix, {2,0}) == any_fill_value + && element_at(any_matrix, {0,1}) == any_fill_value + && element_at(any_matrix, {1,1}) == any_fill_value + && element_at(any_matrix, {2,1}) == any_fill_value; + }()); } constexpr auto matrices_define_their_element_type_as_value_type() @@ -182,7 +189,7 @@ namespace qrcode::structure::test constexpr auto matrices_support_random_access_to_their_elements_when_given_matrix_is_non_const() { - auto f = [] + static_assert([]() { auto any_matrix = matrix{dimension{5,9}}; constexpr auto any_position = position{4,6}; @@ -195,13 +202,12 @@ namespace qrcode::structure::test return element_at(any_matrix, any_position) == any_value && element_at(any_matrix, other_position) == other_value; - }; - static_assert(f()); + }()); } constexpr auto matrices_support_readonly_access_to_their_elements_when_given_matrix_is_const() { - auto f = [] + static_assert([]() { auto any_matrix = matrix{dimension{5,9}}; constexpr auto any_position = position{4,6}; @@ -215,24 +221,26 @@ namespace qrcode::structure::test return element_at(const_matrix, any_position) == any_value && element_at(const_matrix, other_position) == other_value; - }; - static_assert(f()); + }()); } constexpr auto matrix_can_be_asked_whether_a_point_lies_inside() { - constexpr auto any_size = dimension{3, 2}; + static_assert([]() + { + constexpr auto any_size = dimension{3, 2}; - constexpr auto any_matrix = matrix{any_size}; - - static_assert(contains(any_matrix, {0,0})); - static_assert(!contains(any_matrix, {-1,0})); - static_assert(contains(any_matrix, {1,0})); - static_assert(!contains(any_matrix, {0,-1})); - static_assert(contains(any_matrix, {2,1})); - static_assert(!contains(any_matrix, {5,1})); - static_assert(contains(any_matrix, {0,1})); - static_assert(!contains(any_matrix, {0,10})); + auto const any_matrix = matrix{any_size}; + + return contains(any_matrix, { 0, 0}) + && !contains(any_matrix, {-1, 0}) + && contains(any_matrix, { 1, 0}) + && !contains(any_matrix, { 0, -1}) + && contains(any_matrix, { 2, 1}) + && !contains(any_matrix, { 5, 1}) + && contains(any_matrix, { 0, 1}) + && !contains(any_matrix, { 0, 10}); + }()); } } #endif diff --git a/include/qrcode/structure/module.h b/include/qrcode/structure/module.h index e8f4ecd..081b418 100644 --- a/include/qrcode/structure/module.h +++ b/include/qrcode/structure/module.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/structure/module_traits.h b/include/qrcode/structure/module_traits.h index 639608e..70d5b6a 100644 --- a/include/qrcode/structure/module_traits.h +++ b/include/qrcode/structure/module_traits.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/structure/occupied_columns.h b/include/qrcode/structure/occupied_columns.h index 975c1c3..0d6bf32 100644 --- a/include/qrcode/structure/occupied_columns.h +++ b/include/qrcode/structure/occupied_columns.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/structure/place_data.h b/include/qrcode/structure/place_data.h index a839a25..5ae0374 100644 --- a/include/qrcode/structure/place_data.h +++ b/include/qrcode/structure/place_data.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -57,7 +57,7 @@ namespace qrcode::structure *i = *d; assert(d == end(data)); - std::fill(i, end(range), module_traits::make_data(0)); + std::ranges::fill(i, end(range), module_traits::make_data(0)); } } diff --git a/include/qrcode/structure/position.h b/include/qrcode/structure/position.h index 3c0d4b8..511e98c 100644 --- a/include/qrcode/structure/position.h +++ b/include/qrcode/structure/position.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/structure/separator_pattern.h b/include/qrcode/structure/separator_pattern.h index 8ac84b3..344466a 100644 --- a/include/qrcode/structure/separator_pattern.h +++ b/include/qrcode/structure/separator_pattern.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/structure/skip_column_view.h b/include/qrcode/structure/skip_column_view.h index a9492d2..2496c5f 100644 --- a/include/qrcode/structure/skip_column_view.h +++ b/include/qrcode/structure/skip_column_view.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/structure/timing_pattern.h b/include/qrcode/structure/timing_pattern.h index 7d103a0..b7c5d66 100644 --- a/include/qrcode/structure/timing_pattern.h +++ b/include/qrcode/structure/timing_pattern.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/structure/vertical_view.h b/include/qrcode/structure/vertical_view.h index 9de210f..f928914 100644 --- a/include/qrcode/structure/vertical_view.h +++ b/include/qrcode/structure/vertical_view.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/structure/zigzag_view.h b/include/qrcode/structure/zigzag_view.h index 4ccfcb5..31a8e45 100644 --- a/include/qrcode/structure/zigzag_view.h +++ b/include/qrcode/structure/zigzag_view.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/svg.h b/include/qrcode/svg.h index 543d357..a3300a5 100644 --- a/include/qrcode/svg.h +++ b/include/qrcode/svg.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/include/qrcode/symbol.h b/include/qrcode/symbol.h index c66a7cd..d1be888 100644 --- a/include/qrcode/symbol.h +++ b/include/qrcode/symbol.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -156,11 +156,14 @@ namespace qrcode::test constexpr auto symbols_can_be_constructed_with_given_module_matrix() { - constexpr auto any_matrix = matrix{{4,6}}; - constexpr auto any_designator = designator_stub{1, 2}; - constexpr auto any_mask_pattern = 7; - - static_assert(modules(symbol{any_designator, any_mask_pattern, any_matrix}) == any_matrix); + static_assert([]() + { + auto const any_matrix = matrix{{4,6}}; + constexpr auto any_designator = designator_stub{1, 2}; + constexpr auto any_mask_pattern = 7; + + return modules(symbol{any_designator, any_mask_pattern, any_matrix}) == any_matrix; + }()); } constexpr auto symbols_have_a_designator() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fa899fa..1a8bca0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,7 @@ # # The MIT License # -# Copyright (c) 2021 Sebastian Bauer +# Copyright (c) 2025 Melissa Bauer # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,25 +23,24 @@ # cmake_minimum_required(VERSION 3.15) -function(run_after_build target) - add_custom_command(TARGET ${target} POST_BUILD COMMAND ${target}) -endfunction() - add_executable(libqrcode_test main.cpp) -target_compile_options(libqrcode_test PRIVATE $<$:-Wall -Wextra -Wpedantic>) -target_compile_options(libqrcode_test PRIVATE $<$:-Wall -Wextra -Wpedantic>) - target_compile_options(libqrcode_test PRIVATE $<$: + -Wall -Wextra -Wpedantic -Werror -fconstexpr-depth=9999999 -fconstexpr-ops-limit=9999999999 -fconcepts-diagnostics-depth=10>) + target_compile_options(libqrcode_test PRIVATE $<$: + -Wall -Wextra -Wpedantic -Werror -fconstexpr-steps=999999999>) + +target_compile_options(libqrcode_test PRIVATE $<$: + -Wall -Wextra -Wpedantic -Werror + -fconstexpr-steps=999999999>) + target_compile_options(libqrcode_test PRIVATE $<$: /constexpr:steps999999999>) target_compile_options(libqrcode_test PRIVATE -DQRCODE_TESTS_ENABLED) target_link_libraries(libqrcode_test PRIVATE qrcode) -run_after_build(libqrcode_test) - add_test(NAME libqrcode_test COMMAND libqrcode_test) diff --git a/test/linux.Dockerfile b/test/linux.Dockerfile deleted file mode 100644 index 5c33088..0000000 --- a/test/linux.Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM ubuntu:20.04 - -RUN apt-get update && \ - apt-get upgrade -y && \ - DEBIAN_FRONTEND="noninteractive" apt-get install -y build-essential cmake ninja-build gcc-10 g++-10 libstdc++-10-dev && \ - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 && \ - update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10 - -ARG user_name="container_user" -RUN useradd -m $user_name - -RUN mkdir -p /home/$user_name/libqrcode/src && chown $user_name:$user_name /home/$user_name/libqrcode/src && \ - mkdir -p /home/$user_name/libqrcode/bin && chown $user_name:$user_name /home/$user_name/libqrcode/bin -COPY --chown=$user_name:$user_name CMakeLists.txt /home/$user_name/libqrcode/src/ -COPY --chown=$user_name:$user_name include/ /home/$user_name/libqrcode/src/include -COPY --chown=$user_name:$user_name test/ /home/$user_name/libqrcode/src/test - -USER $user_name -WORKDIR /home/$user_name/libqrcode/bin -CMD [ "bash", "-c", "cmake -GNinja -DQRCODE_TESTS_ENABLED:BOOL=True ../src/ && ninja" ] \ No newline at end of file diff --git a/test/linux_run.sh b/test/linux_run.sh deleted file mode 100755 index 937c75e..0000000 --- a/test/linux_run.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -ex - -cd "${0%/*}" - -container_name="libqrcode_test_build" -docker build -t $container_name -f linux.Dockerfile ../ -time docker run --rm $container_name diff --git a/test/main.cpp b/test/main.cpp index f17377a..55788b4 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2021 Sebastian Bauer + * Copyright (c) 2025 Melissa Bauer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/test/win.Dockerfile b/test/win.Dockerfile deleted file mode 100644 index 61eb4c7..0000000 --- a/test/win.Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM mcr.microsoft.com/windows/servercore:ltsc2019 - -SHELL ["cmd", "/S", "/C"] -ADD https://download.visualstudio.microsoft.com/download/pr/cb1d5164-e767-4886-8955-2df3a7c816a8/b9ff67da6d68d6a653a612fd401283cc213b4ec4bae349dd3d9199659a7d9354/vs_BuildTools.exe C:/TEMP/vs_buildtools.exe -RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache \ - --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended \ - --add Microsoft.VisualStudio.Component.VC.ATL \ - --add Microsoft.VisualStudio.Component.VC.ATLMFC \ - --installPath C:\BuildTools \ - || IF "%ERRORLEVEL%"=="3010" EXIT 0 - -COPY CMakeLists.txt C:/Code/libqrcode/src/ -COPY include/ C:/Code/libqrcode/src/include -COPY test/ C:/Code/libqrcode/src/test -RUN cd C:/Code/libqrcode && mkdir "C:/Code/libqrcode/bin" - -WORKDIR C:/Code/libqrcode/bin -ENTRYPOINT ["C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"] -CMD [ "/c", "cmake -G\"Visual Studio 16 2019\" -DQRCODE_TESTS_ENABLED:BOOL=True ../src/; cmake --build ./ --config Release" ] diff --git a/test/win_run.ps1 b/test/win_run.ps1 deleted file mode 100755 index 7bde17e..0000000 --- a/test/win_run.ps1 +++ /dev/null @@ -1,11 +0,0 @@ - -Push-Location $PSScriptRoot - -try { - $ContainerName="libqrcode_test_build" - docker build -t $ContainerName -f win.Dockerfile ../ - docker run --rm $ContainerName -} -finally { - Pop-Location -}