From d8b9e5dea3618ab6497534fdb79d49568111a91f Mon Sep 17 00:00:00 2001 From: Alexandre Coderre-Chabot Date: Sun, 17 Nov 2024 21:48:20 -0800 Subject: [PATCH] Update ClangFormat and code formatting --- .clang-format | 90 ++++++++++++++----- .clang-tidy | 33 ++++--- CMakeLists.txt | 54 +++++------ README.md | 2 +- source/Configuration.hpp | 21 +++-- source/{Messenger => }/Emailer.hpp | 29 +++--- source/Matchings.hpp | 21 +++-- .../Argument.hpp => MessengerArgument.hpp} | 21 +++-- .../{Messenger/Main.cpp => MessengerMain.cpp} | 29 +++--- .../Program.hpp => MessengerProgram.hpp} | 23 ++--- .../Settings.hpp => MessengerSettings.hpp} | 33 +++---- source/Participant.hpp | 21 +++-- .../Argument.hpp => RandomizerArgument.hpp} | 21 +++-- .../Main.cpp => RandomizerMain.cpp} | 27 +++--- .../Program.hpp => RandomizerProgram.hpp} | 23 ++--- .../Settings.hpp => RandomizerSettings.hpp} | 38 ++++---- source/String.hpp | 21 +++-- test/Configuration.cpp | 29 +++--- test/CreateSampleParticipant.hpp | 30 +++++-- test/Emailer.cpp | 63 +++++++++++++ test/Matchings.cpp | 51 +++++------ test/Messenger/Emailer.cpp | 62 ------------- .../Settings.cpp => MessengerSettings.cpp} | 35 ++++---- test/Participant.cpp | 68 +++++++------- .../Settings.cpp => RandomizerSettings.cpp} | 37 ++++---- test/String.cpp | 33 ++++--- 26 files changed, 505 insertions(+), 410 deletions(-) rename source/{Messenger => }/Emailer.hpp (82%) rename source/{Messenger/Argument.hpp => MessengerArgument.hpp} (73%) rename source/{Messenger/Main.cpp => MessengerMain.cpp} (58%) rename source/{Messenger/Program.hpp => MessengerProgram.hpp} (69%) rename source/{Messenger/Settings.hpp => MessengerSettings.hpp} (86%) rename source/{Randomizer/Argument.hpp => RandomizerArgument.hpp} (76%) rename source/{Randomizer/Main.cpp => RandomizerMain.cpp} (61%) rename source/{Randomizer/Program.hpp => RandomizerProgram.hpp} (68%) rename source/{Randomizer/Settings.hpp => RandomizerSettings.hpp} (87%) create mode 100644 test/Emailer.cpp delete mode 100644 test/Messenger/Emailer.cpp rename test/{Messenger/Settings.cpp => MessengerSettings.cpp} (60%) rename test/{Randomizer/Settings.cpp => RandomizerSettings.cpp} (62%) diff --git a/.clang-format b/.clang-format index 1515027..f6dc5c1 100644 --- a/.clang-format +++ b/.clang-format @@ -1,43 +1,66 @@ --- -# Copyright © 2023 Alexandre Coderre-Chabot +# Copyright © 2023-2024 Alexandre Coderre-Chabot # -# https://github.com/acodcha/clang-format-tidy +# This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +# exchange event! # -# This file is licensed under the MIT license (https://mit-license.org). Permission is hereby -# granted, free of charge, to any person obtaining a copy of this software and associated -# documentation files (the "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: +# Secret Santa is hosted at: +# https://github.com/acodcha/phq +# +# Secret Santa is licensed under the MIT License: +# https://mit-license.org +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +# associated documentation files (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, publish, distribute, +# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: # - The above copyright notice and this permission notice shall be included in all copies or # substantial portions of the Software. # - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING # BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -# This is a configuration file for use with LLVM's ClangFormat automatic source code formatter -# (https://clang.llvm.org/docs/ClangFormat.html). This file is compatible with ClangFormat version -# 14.0.0 or any later version. To format your source code files, copy this file to the root -# directory of your source code repository, name it ".clang-format", and run: -# clang-format --style=file path/to/source/code/files +# This is a configuration file for use with LLVM's ClangFormat automatic source code formatter: +# https://clang.llvm.org/docs/ClangFormat.html +# +# This file is compatible with ClangFormat version 18.0.0 or any later version. To format source +# code files in the Secret Santa repository, run: +# clang-format --style=file -i path/to/source/code/files # AccessModifierOffset: -2 AlignAfterOpenBracket: Align AlignArrayOfStructures: Left -AlignConsecutiveAssignments: false -AlignConsecutiveBitFields: false -AlignConsecutiveDeclarations: false -AlignConsecutiveMacros: false +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false AlignEscapedNewlines: Left AlignOperands: Align AlignTrailingComments: true AllowAllArgumentsOnNextLine: true AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true +AllowBreakBeforeNoexceptSpecifier: OnlyWithParen AllowShortBlocksOnASingleLine: Empty AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: true AllowShortEnumsOnASingleLine: false AllowShortFunctionsOnASingleLine: Empty AllowShortIfStatementsOnASingleLine: Never @@ -51,6 +74,7 @@ AttributeMacros: ["__capability"] BinPackArguments: true BinPackParameters: true BitFieldColonSpacing: Both +BracedInitializerIndentWidth: 2 BraceWrapping: AfterCaseLabel: false AfterClass: false @@ -70,10 +94,14 @@ BraceWrapping: SplitEmptyFunction: false SplitEmptyRecord: false SplitEmptyNamespace: false +BreakAdjacentStringLiterals: false +BreakAfterAttributes: Never BreakAfterJavaFieldAnnotations: false +BreakArrays: false BreakBeforeBinaryOperators: NonAssignment BreakBeforeBraces: Custom -BreakBeforeConceptDeclarations: true +BreakBeforeConceptDeclarations: Always +BreakBeforeInlineASMColon: OnlyMultiline BreakBeforeTernaryOperators: false BreakConstructorInitializers: BeforeColon BreakInheritanceList: BeforeColon @@ -112,17 +140,28 @@ IndentCaseLabels: true IndentExternBlock: NoIndent IndentGotoLabels: true IndentPPDirectives: BeforeHash -IndentRequires: false +IndentRequiresClause: false IndentWidth: 2 IndentWrappedFunctionNames: false +InsertBraces: true +InsertNewlineAtEOF: true InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 JavaImportGroups: [] JavaScriptQuotes: Leave JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: false LambdaBodyIndentation: Signature +LineEnding: DeriveLF MacroBlockBegin: "" MacroBlockEnd: "" +Macros: [] MaxEmptyLinesToKeep: 1 NamespaceIndentation: None NamespaceMacros: [] @@ -138,6 +177,7 @@ PenaltyBreakBeforeFirstCallParameter: 4 PenaltyBreakComment: 8 PenaltyBreakFirstLessLess: 4 PenaltyBreakOpenParenthesis: 4 +PenaltyBreakScopeResolution: 50 PenaltyBreakString: 100 PenaltyBreakTemplateDeclaration: 0 PenaltyExcessCharacter: 10000 @@ -167,11 +207,15 @@ RawStringFormats: ReferenceAlignment: Left ReflowComments: true RemoveBracesLLVM: false +RemoveSemicolon: false +RequiresClausePosition: SingleLine +RequiresExpressionIndentation: OuterScope SeparateDefinitionBlocks: Leave ShortNamespaceLines: 0 +SkipMacroDefinitionBody: true SortIncludes: CaseInsensitive SortJavaStaticImport: Before -SortUsingDeclarations: true +SortUsingDeclarations: Lexicographic SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true @@ -181,6 +225,7 @@ SpaceBeforeCaseColon: false SpaceBeforeCpp11BracedList: false SpaceBeforeCtorInitializerColon: true SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false SpaceBeforeParens: Custom SpaceBeforeParensOptions: AfterControlStatements: true @@ -189,6 +234,8 @@ SpaceBeforeParensOptions: AfterFunctionDefinitionName: false AfterIfMacros: true AfterOverloadedOperator: false + AfterRequiresInClause: true + AfterRequiresInExpression: true BeforeNonEmptyParentheses: false SpaceBeforeRangeBasedForLoopColon: true SpaceBeforeSquareBrackets: false @@ -211,6 +258,7 @@ TabWidth: 8 TypenameMacros: ["STACK_OF", "LIST"] UseCRLF: false UseTab: Never +VerilogBreakBetweenInstancePorts: false WhitespaceSensitiveMacros: - "STRINGIZE" - "PP_STRINGIZE" diff --git a/.clang-tidy b/.clang-tidy index 234c8b9..819a8df 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,26 +1,33 @@ --- -# Copyright © 2023 Alexandre Coderre-Chabot +# Copyright © 2023-2024 Alexandre Coderre-Chabot # -# https://github.com/acodcha/clang-format-tidy +# This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +# exchange event! # -# This file is licensed under the MIT license (https://mit-license.org). Permission is hereby -# granted, free of charge, to any person obtaining a copy of this software and associated -# documentation files (the "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: +# Secret Santa is hosted at: +# https://github.com/acodcha/phq +# +# Secret Santa is licensed under the MIT License: +# https://mit-license.org +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +# associated documentation files (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, publish, distribute, +# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: # - The above copyright notice and this permission notice shall be included in all copies or # substantial portions of the Software. # - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING # BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -# This is a configuration file for use with LLVM's Clang-Tidy automatic source code linter -# (https://clang.llvm.org/extra/clang-tidy). To run the linter on your source code files, copy this -# file to the root directory of your source code repository, name it ".clang-tidy", and run: -# clang-tidy --extra-arg=-std=c++20 /path/to/source/code/files +# This is a configuration file for use with LLVM's Clang-Tidy automatic source code linter: +# https://clang.llvm.org/extra/clang-tidy +# +# To run the linter on source code files in the Secret Santa repository, run: +# clang-tidy --extra-arg=-std=c++17 /path/to/source/code/files # Checks: ' *, diff --git a/CMakeLists.txt b/CMakeLists.txt index b012d1b..c83cc02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,26 +1,26 @@ -# Copyright © 2023 Alexandre Coderre-Chabot +# Copyright © 2023-2024 Alexandre Coderre-Chabot # -# This file is licensed under the MIT license. For more information, visit: +# This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +# exchange event! +# +# Secret Santa is hosted at: +# https://github.com/acodcha/phq +# +# Secret Santa is licensed under the MIT License: # https://mit-license.org # -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +# associated documentation files (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, publish, distribute, +# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# - The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# -# This file was originally obtained from: -# https://github.com/acodcha/secret-santa +# - The above copyright notice and this permission notice shall be included in all copies or +# substantial portions of the Software. +# - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. cmake_minimum_required(VERSION 3.12 FATAL_ERROR) @@ -57,11 +57,11 @@ FetchContent_MakeAvailable(yaml-cpp) message(STATUS "The yaml-cpp library was fetched from: https://github.com/jbeder/yaml-cpp.git") # Define the Secret Santa Randomizer executable. -add_executable(secret-santa-randomizer ${PROJECT_SOURCE_DIR}/source/Randomizer/Main.cpp) +add_executable(secret-santa-randomizer ${PROJECT_SOURCE_DIR}/source/RandomizerMain.cpp) target_link_libraries(secret-santa-randomizer PUBLIC stdc++fs yaml-cpp) # Define the Secret Santa Messenger executable. -add_executable(secret-santa-messenger ${PROJECT_SOURCE_DIR}/source/Messenger/Main.cpp) +add_executable(secret-santa-messenger ${PROJECT_SOURCE_DIR}/source/MessengerMain.cpp) target_link_libraries(secret-santa-messenger PUBLIC stdc++fs yaml-cpp) # Configure the Secret Santa tests. @@ -93,15 +93,15 @@ if(TEST_SECRET_SANTA) target_link_libraries(test_configuration yaml-cpp GTest::gtest_main) gtest_discover_tests(test_configuration) + add_executable(test_emailer ${PROJECT_SOURCE_DIR}/test/Emailer.cpp) + target_link_libraries(test_emailer yaml-cpp GTest::gtest_main) + gtest_discover_tests(test_emailer) + add_executable(test_matchings ${PROJECT_SOURCE_DIR}/test/Matchings.cpp) target_link_libraries(test_matchings yaml-cpp GTest::gtest_main) gtest_discover_tests(test_matchings) - add_executable(test_messenger_emailer ${PROJECT_SOURCE_DIR}/test/Messenger/Emailer.cpp) - target_link_libraries(test_messenger_emailer yaml-cpp GTest::gtest_main) - gtest_discover_tests(test_messenger_emailer) - - add_executable(test_messenger_settings ${PROJECT_SOURCE_DIR}/test/Messenger/Settings.cpp) + add_executable(test_messenger_settings ${PROJECT_SOURCE_DIR}/test/MessengerSettings.cpp) target_link_libraries(test_messenger_settings yaml-cpp GTest::gtest_main) gtest_discover_tests(test_messenger_settings) @@ -109,7 +109,7 @@ if(TEST_SECRET_SANTA) target_link_libraries(test_participant yaml-cpp GTest::gtest_main) gtest_discover_tests(test_participant) - add_executable(test_randomizer_settings ${PROJECT_SOURCE_DIR}/test/Randomizer/Settings.cpp) + add_executable(test_randomizer_settings ${PROJECT_SOURCE_DIR}/test/RandomizerSettings.cpp) target_link_libraries(test_randomizer_settings yaml-cpp GTest::gtest_main) gtest_discover_tests(test_randomizer_settings) diff --git a/README.md b/README.md index a1942f8..3921c48 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![build and test](https://github.com/acodcha/secret-santa/actions/workflows/build_and_test.yaml/badge.svg?branch=main)](https://github.com/acodcha/secret-santa/actions/workflows/build_and_test.yaml) -Organizes a "Secret Santa" gift exchange event! Given a list of participant names, addresses, and emails, this project randomizes the gift exchange and sends instructions via email to each participant. +Simple C++ utility that organizes a "Secret Santa" gift exchange event! Given a list of participant names, addresses, and emails, this project randomizes the gift exchange and sends instructions via email to each participant. - [Requirements](#requirements) - [Configuration](#configuration) diff --git a/source/Configuration.hpp b/source/Configuration.hpp index 4b71961..174c9ec 100644 --- a/source/Configuration.hpp +++ b/source/Configuration.hpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,15 +15,12 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SECRET_SANTA_CONFIGURATION_HPP #define SECRET_SANTA_CONFIGURATION_HPP diff --git a/source/Messenger/Emailer.hpp b/source/Emailer.hpp similarity index 82% rename from source/Messenger/Emailer.hpp rename to source/Emailer.hpp index 6baea98..25a9dcd 100644 --- a/source/Messenger/Emailer.hpp +++ b/source/Emailer.hpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,23 +15,20 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SECRET_SANTA_MESSENGER_EMAILER_HPP #define SECRET_SANTA_MESSENGER_EMAILER_HPP -#include "../Configuration.hpp" -#include "../Matchings.hpp" +#include "Configuration.hpp" +#include "Matchings.hpp" -namespace SecretSanta::Messenger { +namespace SecretSanta { // Composes the full email message body for a given gifter. Prefixes a brief greeting to the given // main message body and appends the giftee information. @@ -104,6 +107,6 @@ void ComposeAndSendEmailMessages(const Configuration& configuration, const Match } } -} // namespace SecretSanta::Messenger +} // namespace SecretSanta #endif // SECRET_SANTA_MESSENGER_EMAILER_HPP diff --git a/source/Matchings.hpp b/source/Matchings.hpp index 6a9c879..beec04a 100644 --- a/source/Matchings.hpp +++ b/source/Matchings.hpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,15 +15,12 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SECRET_SANTA_MATCHINGS_HPP #define SECRET_SANTA_MATCHINGS_HPP diff --git a/source/Messenger/Argument.hpp b/source/MessengerArgument.hpp similarity index 73% rename from source/Messenger/Argument.hpp rename to source/MessengerArgument.hpp index 815a750..11bd085 100644 --- a/source/Messenger/Argument.hpp +++ b/source/MessengerArgument.hpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,15 +15,12 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SECRET_SANTA_MESSENGER_ARGUMENT_HPP #define SECRET_SANTA_MESSENGER_ARGUMENT_HPP diff --git a/source/Messenger/Main.cpp b/source/MessengerMain.cpp similarity index 58% rename from source/Messenger/Main.cpp rename to source/MessengerMain.cpp index 27e00f8..d7bc2cd 100644 --- a/source/Messenger/Main.cpp +++ b/source/MessengerMain.cpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,22 +15,19 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include -#include "../Configuration.hpp" -#include "../Matchings.hpp" +#include "Configuration.hpp" #include "Emailer.hpp" -#include "Settings.hpp" +#include "Matchings.hpp" +#include "MessengerSettings.hpp" int main(int argc, char* argv[]) { const SecretSanta::Messenger::Settings settings{argc, argv}; @@ -33,7 +36,7 @@ int main(int argc, char* argv[]) { const SecretSanta::Matchings matchings{settings.MatchingsFile()}; - SecretSanta::Messenger::ComposeAndSendEmailMessages(configuration, matchings); + SecretSanta::ComposeAndSendEmailMessages(configuration, matchings); std::cout << "End of " << SecretSanta::Messenger::Program::Title << "." << std::endl; diff --git a/source/Messenger/Program.hpp b/source/MessengerProgram.hpp similarity index 69% rename from source/Messenger/Program.hpp rename to source/MessengerProgram.hpp index fb5321a..3049350 100644 --- a/source/Messenger/Program.hpp +++ b/source/MessengerProgram.hpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,15 +15,12 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SECRET_SANTA_MESSENGER_PROGRAM_HPP #define SECRET_SANTA_MESSENGER_PROGRAM_HPP @@ -31,7 +34,7 @@ static const std::string Title{"Secret Santa Messenger"}; // Date and time at which the Secret Santa Messenger program was compiled. static const std::string CompilationDateAndTime{ - std::string{__DATE__} + ", " + std::string{__TIME__}}; + std::string{__DATE__} + ", " + std::string{__TIME__}}; // Description of the Secret Santa Messenger program. static const std::string Description{ diff --git a/source/Messenger/Settings.hpp b/source/MessengerSettings.hpp similarity index 86% rename from source/Messenger/Settings.hpp rename to source/MessengerSettings.hpp index ff14541..9c24576 100644 --- a/source/Messenger/Settings.hpp +++ b/source/MessengerSettings.hpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,15 +15,12 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SECRET_SANTA_MESSENGER_SETTINGS_HPP #define SECRET_SANTA_MESSENGER_SETTINGS_HPP @@ -28,9 +31,9 @@ #include #include -#include "../String.hpp" -#include "Argument.hpp" -#include "Program.hpp" +#include "MessengerArgument.hpp" +#include "MessengerProgram.hpp" +#include "String.hpp" namespace SecretSanta::Messenger { @@ -92,9 +95,9 @@ class Settings { // Compute the padding length of the argument patterns. const std::size_t length = std::max({ - Argument::Help().length(), - Argument::Configuration().length(), - Argument::Matchings().length(), + Argument::Help().length(), + Argument::Configuration().length(), + Argument::Matchings().length(), }); std::cout << "Arguments:" << std::endl; diff --git a/source/Participant.hpp b/source/Participant.hpp index 6dc1330..5ae329f 100644 --- a/source/Participant.hpp +++ b/source/Participant.hpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,15 +15,12 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SECRET_SANTA_PARTICIPANT_HPP #define SECRET_SANTA_PARTICIPANT_HPP diff --git a/source/Randomizer/Argument.hpp b/source/RandomizerArgument.hpp similarity index 76% rename from source/Randomizer/Argument.hpp rename to source/RandomizerArgument.hpp index f00fd0c..ef65d99 100644 --- a/source/Randomizer/Argument.hpp +++ b/source/RandomizerArgument.hpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,15 +15,12 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SECRET_SANTA_RANDOMIZER_ARGUMENT_HPP #define SECRET_SANTA_RANDOMIZER_ARGUMENT_HPP diff --git a/source/Randomizer/Main.cpp b/source/RandomizerMain.cpp similarity index 61% rename from source/Randomizer/Main.cpp rename to source/RandomizerMain.cpp index 0b1d4a4..e2236c5 100644 --- a/source/Randomizer/Main.cpp +++ b/source/RandomizerMain.cpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,21 +15,18 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include -#include "../Configuration.hpp" -#include "../Matchings.hpp" -#include "Settings.hpp" +#include "Configuration.hpp" +#include "Matchings.hpp" +#include "RandomizerSettings.hpp" int main(int argc, char* argv[]) { const SecretSanta::Randomizer::Settings settings{argc, argv}; diff --git a/source/Randomizer/Program.hpp b/source/RandomizerProgram.hpp similarity index 68% rename from source/Randomizer/Program.hpp rename to source/RandomizerProgram.hpp index fda7c4f..aa8c9f1 100644 --- a/source/Randomizer/Program.hpp +++ b/source/RandomizerProgram.hpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,15 +15,12 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SECRET_SANTA_RANDOMIZER_PROGRAM_HPP #define SECRET_SANTA_RANDOMIZER_PROGRAM_HPP @@ -31,7 +34,7 @@ static const std::string Title{"Secret Santa Randomizer"}; // Date and time at which the Secret Santa Randomizer program was compiled. static const std::string CompilationDateAndTime{ - std::string{__DATE__} + ", " + std::string{__TIME__}}; + std::string{__DATE__} + ", " + std::string{__TIME__}}; // Description of the Secret Santa Randomizer program. static const std::string Description{ diff --git a/source/Randomizer/Settings.hpp b/source/RandomizerSettings.hpp similarity index 87% rename from source/Randomizer/Settings.hpp rename to source/RandomizerSettings.hpp index 00a96d7..3305ec4 100644 --- a/source/Randomizer/Settings.hpp +++ b/source/RandomizerSettings.hpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,15 +15,12 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SECRET_SANTA_RANDOMIZER_SETTINGS_HPP #define SECRET_SANTA_RANDOMIZER_SETTINGS_HPP @@ -28,9 +31,9 @@ #include #include -#include "../String.hpp" -#include "Argument.hpp" -#include "Program.hpp" +#include "RandomizerArgument.hpp" +#include "RandomizerProgram.hpp" +#include "String.hpp" namespace SecretSanta::Randomizer { @@ -94,15 +97,14 @@ class Settings { std::cout << "Usage:" << std::endl; std::cout << indent << executable_name_ << " " << Argument::Configuration() << " [" - << Argument::Matchings() << "] " - << " [" << Argument::Seed() << "]" << std::endl; + << Argument::Matchings() << "] " << " [" << Argument::Seed() << "]" << std::endl; // Compute the padding length of the argument patterns. const std::size_t length = std::max({ - Argument::Help().length(), - Argument::Configuration().length(), - Argument::Matchings().length(), - Argument::Seed().length(), + Argument::Help().length(), + Argument::Configuration().length(), + Argument::Matchings().length(), + Argument::Seed().length(), }); std::cout << "Arguments:" << std::endl; diff --git a/source/String.hpp b/source/String.hpp index 7b413f8..8a37420 100644 --- a/source/String.hpp +++ b/source/String.hpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,15 +15,12 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SECRET_SANTA_STRING_HPP #define SECRET_SANTA_STRING_HPP diff --git a/test/Configuration.cpp b/test/Configuration.cpp index f05af66..d513392 100644 --- a/test/Configuration.cpp +++ b/test/Configuration.cpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,33 +15,28 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "../source/Configuration.hpp" #include -namespace SecretSanta { - namespace { TEST(Configuration, Constructor) { - const Configuration configuration{"../test/configuration.yaml"}; + const SecretSanta::Configuration configuration{"../test/configuration.yaml"}; EXPECT_EQ(configuration.MessageSubject(), "Secret Santa Gift Exchange 2023"); EXPECT_FALSE(configuration.MessageBody().empty()); EXPECT_EQ(configuration.Participants().size(), 3); } TEST(Configuration, DefaultConstructor) { - const Configuration configuration; + const SecretSanta::Configuration configuration; EXPECT_EQ(configuration.MessageSubject(), "Secret Santa Gift Exchange"); EXPECT_EQ(configuration.MessageBody(), "You are receiving this message because you opted to participate in a Secret Santa " @@ -44,5 +45,3 @@ TEST(Configuration, DefaultConstructor) { } } // namespace - -} // namespace SecretSanta diff --git a/test/CreateSampleParticipant.hpp b/test/CreateSampleParticipant.hpp index abc5d5a..4990f3a 100644 --- a/test/CreateSampleParticipant.hpp +++ b/test/CreateSampleParticipant.hpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,19 +15,17 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SECRET_SANTA_CREATE_SAMPLE_PARTICIPANT_HPP #define SECRET_SANTA_CREATE_SAMPLE_PARTICIPANT_HPP +#include #include #include "../source/Participant.hpp" @@ -51,6 +55,14 @@ YAML::Node CreateSampleParticipantC() { return node; } +std::set CreateSampleParticipants() { + std::set participants; + participants.emplace(CreateSampleParticipantA()); + participants.emplace(CreateSampleParticipantB()); + participants.emplace(CreateSampleParticipantC()); + return participants; +} + } // namespace SecretSanta #endif // SECRET_SANTA_CREATE_SAMPLE_PARTICIPANT_HPP diff --git a/test/Emailer.cpp b/test/Emailer.cpp new file mode 100644 index 0000000..0f9bebd --- /dev/null +++ b/test/Emailer.cpp @@ -0,0 +1,63 @@ +// Copyright © 2023-2024 Alexandre Coderre-Chabot +// +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: +// https://mit-license.org +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +// associated documentation files (the "Software"), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, publish, distribute, +// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// - The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#include "../source/Emailer.hpp" + +#include + +#include "CreateSampleParticipant.hpp" + +namespace { + +TEST(Emailer, ComposeFullMessageBody) { + const SecretSanta::Participant gifter{SecretSanta::CreateSampleParticipantA()}; + const SecretSanta::Participant giftee{SecretSanta::CreateSampleParticipantB()}; + + const std::string main_message_body{ + "You are receiving this message because you opted to participate in a Secret Santa " + "gift exchange!"}; + + const std::string result{SecretSanta::ComposeFullMessageBody( + SecretSanta::Participant{SecretSanta::CreateSampleParticipantA()}, + SecretSanta::Participant{SecretSanta::CreateSampleParticipantB()}, main_message_body)}; + + EXPECT_EQ(result, + "Hello Alice Smith,\n\nYou are receiving this message because you opted to participate " + "in a Secret Santa gift exchange!\n\nYour giftee is: Bob Johnson\n\nMail to:\n\nBob " + "Johnson SECRET SANTA\n456 Second St, Apt 2, Villagetown, CA 92345 USA\n\nThank you!"); +} + +TEST(Emailer, ComposeCommand) { + const SecretSanta::Participant gifter{SecretSanta::CreateSampleParticipantA()}; + const std::string message_subject{"My Message Subject"}; + const std::string message_body{"My Message Body"}; + + const std::string command{SecretSanta::ComposeCommand(gifter, message_subject, message_body)}; + + EXPECT_EQ( + command, + "echo \"My Message Body\" | s-nail --subject \"My Message Subject\" alice.smith@gmail.com"); +} + +} // namespace diff --git a/test/Matchings.cpp b/test/Matchings.cpp index 98b50b9..815c174 100644 --- a/test/Matchings.cpp +++ b/test/Matchings.cpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,15 +15,12 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "../source/Matchings.hpp" @@ -25,21 +28,12 @@ #include "CreateSampleParticipant.hpp" -namespace SecretSanta { - namespace { -std::set CreateSampleParticipants() { - std::set participants; - participants.emplace(CreateSampleParticipantA()); - participants.emplace(CreateSampleParticipantB()); - participants.emplace(CreateSampleParticipantC()); - return participants; -} - TEST(Matchings, ComparisonOperators) { - const Matchings first{std::set{Participant{CreateSampleParticipantA()}}}; - const Matchings second{CreateSampleParticipants()}; + const SecretSanta::Matchings first{std::set{ + SecretSanta::Participant{SecretSanta::CreateSampleParticipantA()}}}; + const SecretSanta::Matchings second{SecretSanta::CreateSampleParticipants()}; EXPECT_EQ(first, first); EXPECT_NE(first, second); EXPECT_LT(first, second); @@ -51,19 +45,20 @@ TEST(Matchings, ComparisonOperators) { } TEST(Matchings, ConstructorFromNoParticipants) { - const Matchings matchings{std::set()}; + const SecretSanta::Matchings matchings{std::set()}; EXPECT_TRUE(matchings.GiftersToGiftees().empty()); } TEST(Matchings, ConstructorFromOneParticipant) { - const Matchings matchings{std::set{Participant{CreateSampleParticipantA()}}}; + const SecretSanta::Matchings matchings{std::set{ + SecretSanta::Participant{SecretSanta::CreateSampleParticipantA()}}}; EXPECT_EQ(matchings.GiftersToGiftees().size(), 1); EXPECT_NE(matchings.GiftersToGiftees().find("Alice Smith"), matchings.GiftersToGiftees().cend()); EXPECT_EQ(matchings.GiftersToGiftees().at("Alice Smith"), "Alice Smith"); } TEST(Matchings, ConstructorFromThreeParticipants) { - const Matchings matchings{CreateSampleParticipants()}; + const SecretSanta::Matchings matchings{SecretSanta::CreateSampleParticipants()}; EXPECT_EQ(matchings.GiftersToGiftees().size(), 3); for (const std::pair& gifter_and_giftee : matchings.GiftersToGiftees()) { @@ -72,18 +67,16 @@ TEST(Matchings, ConstructorFromThreeParticipants) { } TEST(Matchings, DefaultConstructor) { - const Matchings matchings; + const SecretSanta::Matchings matchings; EXPECT_TRUE(matchings.GiftersToGiftees().empty()); } TEST(Matchings, ConstructorFromYamlFile) { - const Matchings first{CreateSampleParticipants()}; + const SecretSanta::Matchings first{SecretSanta::CreateSampleParticipants()}; const std::filesystem::path path = "matchings.yaml"; first.Write(path); - const Matchings second{path}; + const SecretSanta::Matchings second{path}; EXPECT_EQ(first, second); } } // namespace - -} // namespace SecretSanta diff --git a/test/Messenger/Emailer.cpp b/test/Messenger/Emailer.cpp deleted file mode 100644 index 2184e4c..0000000 --- a/test/Messenger/Emailer.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright © 2023-2024 Alexandre Coderre-Chabot -// -// This file is licensed under the MIT license. For more information, visit: -// https://mit-license.org -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -// associated documentation files (the "Software"), to deal in the Software without restriction, -// including without limitation the rights to use, copy, modify, merge, publish, distribute, -// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. -// - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa - -#include "../../source/Messenger/Emailer.hpp" - -#include - -#include "../CreateSampleParticipant.hpp" - -namespace SecretSanta::Messenger { - -namespace { - -TEST(MessengerEmailer, ComposeFullMessageBody) { - const Participant gifter{CreateSampleParticipantA()}; - const Participant giftee{CreateSampleParticipantB()}; - - const std::string main_message_body{ - "You are receiving this message because you opted to participate in a Secret Santa gift " - "exchange!"}; - - const std::string result = ComposeFullMessageBody(gifter, giftee, main_message_body); - - EXPECT_EQ(result, - "Hello Alice Smith,\n\nYou are receiving this message because you opted to participate " - "in a Secret Santa gift exchange!\n\nYour giftee is: Bob Johnson\n\nMail to:\n\nBob " - "Johnson SECRET SANTA\n456 Second St, Apt 2, Villagetown, CA 92345 USA\n\nThank you!"); -} - -TEST(MessengerEmailer, ComposeCommand) { - const Participant gifter{CreateSampleParticipantA()}; - const std::string message_subject{"My Message Subject"}; - const std::string message_body{"My Message Body"}; - - std::string command = ComposeCommand(gifter, message_subject, message_body); - - EXPECT_EQ( - command, - "echo \"My Message Body\" | s-nail --subject \"My Message Subject\" alice.smith@gmail.com"); -} - -} // namespace - -} // namespace SecretSanta::Messenger diff --git a/test/Messenger/Settings.cpp b/test/MessengerSettings.cpp similarity index 60% rename from test/Messenger/Settings.cpp rename to test/MessengerSettings.cpp index 393a236..2f102d7 100644 --- a/test/Messenger/Settings.cpp +++ b/test/MessengerSettings.cpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,22 +15,17 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#include "../../source/Messenger/Settings.hpp" +#include "../source/MessengerSettings.hpp" #include -namespace SecretSanta::Messenger { - namespace { TEST(MessengerSettings, Constructor) { @@ -36,24 +37,22 @@ TEST(MessengerSettings, Constructor) { char matchings_key[] = "--matchings"; char matchings_value[] = "path/to/some/directory/matchings.yaml"; - int argc = 5; + int argc{5}; char* argv[] = { - program, configuration_key, configuration_value, matchings_key, matchings_value, + program, configuration_key, configuration_value, matchings_key, matchings_value, }; - const Settings settings{argc, argv}; + const SecretSanta::Messenger::Settings settings{argc, argv}; EXPECT_EQ(settings.ConfigurationFile(), "path/to/some/directory/configuration.yaml"); EXPECT_EQ(settings.MatchingsFile(), "path/to/some/directory/matchings.yaml"); } TEST(MessengerSettings, DefaultConstructor) { - const Settings settings; + const SecretSanta::Messenger::Settings settings; EXPECT_EQ(settings.ConfigurationFile(), ""); EXPECT_EQ(settings.MatchingsFile(), ""); } } // namespace - -} // namespace SecretSanta::Messenger diff --git a/test/Participant.cpp b/test/Participant.cpp index f27cf68..0adbaaf 100644 --- a/test/Participant.cpp +++ b/test/Participant.cpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,15 +15,12 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "../source/Participant.hpp" @@ -25,13 +28,11 @@ #include "CreateSampleParticipant.hpp" -namespace SecretSanta { - namespace { TEST(Participant, ComparisonOperators) { - const Participant first{CreateSampleParticipantA()}; - const Participant second{CreateSampleParticipantB()}; + const SecretSanta::Participant first{SecretSanta::CreateSampleParticipantA()}; + const SecretSanta::Participant second{SecretSanta::CreateSampleParticipantB()}; EXPECT_EQ(first, first); EXPECT_NE(first, second); EXPECT_LT(first, second); @@ -43,7 +44,7 @@ TEST(Participant, ComparisonOperators) { } TEST(Participant, ConstructorFromName) { - const Participant participant{"Alice Smith"}; + const SecretSanta::Participant participant{"Alice Smith"}; EXPECT_EQ(participant.Name(), "Alice Smith"); EXPECT_TRUE(participant.Email().empty()); EXPECT_TRUE(participant.Address().empty()); @@ -51,7 +52,7 @@ TEST(Participant, ConstructorFromName) { } TEST(Participant, ConstructorFromYamlNode) { - const Participant participant{CreateSampleParticipantA()}; + const SecretSanta::Participant participant{SecretSanta::CreateSampleParticipantA()}; EXPECT_EQ(participant.Name(), "Alice Smith"); EXPECT_EQ(participant.Email(), "alice.smith@gmail.com"); EXPECT_EQ(participant.Address(), "123 First Ave, Apt 1, Townsville, CA 91234 USA"); @@ -59,20 +60,21 @@ TEST(Participant, ConstructorFromYamlNode) { } TEST(Participant, CopyAssignmentOperator) { - const Participant first{CreateSampleParticipantA()}; - Participant second = Participant{CreateSampleParticipantB()}; + const SecretSanta::Participant first{SecretSanta::CreateSampleParticipantA()}; + SecretSanta::Participant second = + SecretSanta::Participant{SecretSanta::CreateSampleParticipantB()}; second = first; EXPECT_EQ(second, first); } TEST(Participant, CopyConstructor) { - const Participant first{CreateSampleParticipantA()}; - const Participant second{first}; + const SecretSanta::Participant first{SecretSanta::CreateSampleParticipantA()}; + const SecretSanta::Participant second{first}; EXPECT_EQ(second, first); } TEST(Participant, DefaultConstructor) { - const Participant participant; + const SecretSanta::Participant participant; EXPECT_TRUE(participant.Name().empty()); EXPECT_TRUE(participant.Email().empty()); EXPECT_TRUE(participant.Address().empty()); @@ -80,34 +82,34 @@ TEST(Participant, DefaultConstructor) { } TEST(Participant, Hash) { - const Participant first{CreateSampleParticipantA()}; - const Participant second{CreateSampleParticipantB()}; - std::hash hash; + const SecretSanta::Participant first{SecretSanta::CreateSampleParticipantA()}; + const SecretSanta::Participant second{SecretSanta::CreateSampleParticipantB()}; + std::hash hash; EXPECT_NE(hash(first), hash(second)); } TEST(Participant, MoveAssignmentOperator) { - Participant first{CreateSampleParticipantA()}; - Participant second{CreateSampleParticipantB()}; + SecretSanta::Participant first{SecretSanta::CreateSampleParticipantA()}; + SecretSanta::Participant second{SecretSanta::CreateSampleParticipantB()}; second = std::move(first); - EXPECT_EQ(second, Participant(CreateSampleParticipantA())); + EXPECT_EQ(second, SecretSanta::Participant(SecretSanta::CreateSampleParticipantA())); } TEST(Participant, MoveConstructor) { - Participant first{CreateSampleParticipantA()}; - Participant second{std::move(first)}; - EXPECT_EQ(second, Participant(CreateSampleParticipantA())); + SecretSanta::Participant first{SecretSanta::CreateSampleParticipantA()}; + SecretSanta::Participant second{std::move(first)}; + EXPECT_EQ(second, SecretSanta::Participant(SecretSanta::CreateSampleParticipantA())); } TEST(Participant, Print) { - const Participant participant{CreateSampleParticipantA()}; + const SecretSanta::Participant participant{SecretSanta::CreateSampleParticipantA()}; EXPECT_EQ(participant.Print(), "Alice Smith (email: alice.smith@gmail.com; address: 123 First Ave, Apt 1, Townsville, " "CA 91234 USA; instructions: Leave the package with the doorman in the lobby.)"); } TEST(Participant, Stream) { - const Participant participant{CreateSampleParticipantA()}; + const SecretSanta::Participant participant{SecretSanta::CreateSampleParticipantA()}; std::stringstream stream; stream << participant; EXPECT_EQ(stream.str(), @@ -116,7 +118,7 @@ TEST(Participant, Stream) { } TEST(Participant, YAML) { - const Participant participant{CreateSampleParticipantA()}; + const SecretSanta::Participant participant{SecretSanta::CreateSampleParticipantA()}; const YAML::Node node{participant.YAML()}; ASSERT_TRUE(node.IsMap()); ASSERT_EQ(node.size(), 1); @@ -134,5 +136,3 @@ TEST(Participant, YAML) { } } // namespace - -} // namespace SecretSanta diff --git a/test/Randomizer/Settings.cpp b/test/RandomizerSettings.cpp similarity index 62% rename from test/Randomizer/Settings.cpp rename to test/RandomizerSettings.cpp index f425d28..3347922 100644 --- a/test/Randomizer/Settings.cpp +++ b/test/RandomizerSettings.cpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,22 +15,17 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#include "../../source/Randomizer/Settings.hpp" +#include "../source/RandomizerSettings.hpp" #include -namespace SecretSanta::Randomizer { - namespace { TEST(RandomizerSettings, Constructor) { @@ -39,14 +40,14 @@ TEST(RandomizerSettings, Constructor) { char seed_key[] = "--seed"; char seed_value[] = "42"; - int argc = 7; + int argc{7}; char* argv[] = { - program, configuration_key, configuration_value, matchings_key, - matchings_value, seed_key, seed_value, + program, configuration_key, configuration_value, matchings_key, + matchings_value, seed_key, seed_value, }; - const Settings settings{argc, argv}; + const SecretSanta::Randomizer::Settings settings{argc, argv}; EXPECT_EQ(settings.ConfigurationFile(), "path/to/some/directory/configuration.yaml"); EXPECT_EQ(settings.MatchingsFile(), "path/to/some/directory/matchings.yaml"); @@ -55,12 +56,10 @@ TEST(RandomizerSettings, Constructor) { } TEST(RandomizerSettings, DefaultConstructor) { - const Settings settings; + const SecretSanta::Randomizer::Settings settings; EXPECT_EQ(settings.ConfigurationFile(), ""); EXPECT_EQ(settings.MatchingsFile(), ""); EXPECT_EQ(settings.RandomSeed(), std::nullopt); } } // namespace - -} // namespace SecretSanta::Randomizer diff --git a/test/String.cpp b/test/String.cpp index 4045a33..ef74716 100644 --- a/test/String.cpp +++ b/test/String.cpp @@ -1,6 +1,12 @@ // Copyright © 2023-2024 Alexandre Coderre-Chabot // -// This file is licensed under the MIT license. For more information, visit: +// This file is part of Secret Santa, a simple C++ utility that organizes a "Secret Santa" gift +// exchange event! +// +// Secret Santa is hosted at: +// https://github.com/acodcha/phq +// +// Secret Santa is licensed under the MIT License: // https://mit-license.org // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and @@ -9,31 +15,24 @@ // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // - The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. +// substantial portions of the Software. // - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -// This file was originally obtained from: -// https://github.com/acodcha/secret-santa +// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "../source/String.hpp" #include -namespace SecretSanta { - namespace { TEST(String, PadToLength) { - EXPECT_EQ(PadToLength("", 0), ""); - EXPECT_EQ(PadToLength("", 10), " "); - EXPECT_EQ(PadToLength("Hello world!", 0), "Hello world!"); - EXPECT_EQ(PadToLength("Hello world!", 15), "Hello world! "); + EXPECT_EQ(SecretSanta::PadToLength("", 0), ""); + EXPECT_EQ(SecretSanta::PadToLength("", 10), " "); + EXPECT_EQ(SecretSanta::PadToLength("Hello world!", 0), "Hello world!"); + EXPECT_EQ(SecretSanta::PadToLength("Hello world!", 15), "Hello world! "); } } // namespace - -} // namespace SecretSanta