Skip to content

Commit

Permalink
refactor: use anonymous namespace for helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
csirianni committed Oct 24, 2023
1 parent 95d7f6e commit ddb990a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions backend/test/password.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
#include <catch2/catch_test_macros.hpp>
#include "../src/password.hpp"

bool hasLettersAndDigit(const std::string &password)
namespace
{
const std::regex pattern("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).+$");
return regex_match(password, pattern);
}
bool hasLettersAndDigit(const std::string &password)
{
const std::regex pattern("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).+$");
return regex_match(password, pattern);
}

bool hasSymbol(const std::string &password)
{
return password.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890") != std::string::npos;
bool hasSymbol(const std::string &password)
{
return password.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890") != std::string::npos;
}
}

TEST_CASE("Test generatePassword creates valid passwords")
Expand Down

0 comments on commit ddb990a

Please sign in to comment.