Skip to content

Commit

Permalink
refactor: clean up imports and variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
ni-jessica committed Oct 24, 2023
1 parent 21c94a5 commit 63ff24a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
.DS_Store
.vscode
6 changes: 2 additions & 4 deletions backend/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iostream>

#include "crow.h"
#include "database.hpp"
#include "password.hpp"
Expand All @@ -13,8 +11,8 @@ int main()
db.execute("CREATE TABLE passwords (password TEXT);");

// generate and insert the passwords into the database
std::unordered_set<std::string> passwordSet = password::generatePasswords(10, 20);
for (const auto &password : passwordSet)
std::unordered_set<std::string> password_set = password::generatePasswords(100, 20);
for (const auto &password : password_set)
{
db.execute("INSERT INTO passwords (password) VALUES ('" + password + "');");
}
Expand Down
4 changes: 2 additions & 2 deletions backend/src/password.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace password
* @brief Returns a set of passwords, where each password contains at least one lowercase
* letter, at least one uppercase letter, at least one digit, and at least special character.
*
* @param numPasswords The number of passwords to generate.
* @param maxChars The maximum number of characters for a password.
* @param num_passwords The number of passwords to generate.
* @param max_chars The maximum number of characters for a password.
* @return std::unordered_set<std::string> The passwords generated.
*/
std::unordered_set<std::string> generatePasswords(int num_passwords, int max_chars);
Expand Down
6 changes: 3 additions & 3 deletions backend/tests/testPasswordGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ bool hasSymbol(const std::string &password)

TEST_CASE("Test generatePassword creates valid passwords")
{
std::unordered_set<std::string> passwordSet = password::generatePasswords(3, 12);
std::unordered_set<std::string> password_set = password::generatePasswords(3, 12);
// function generated 3 passwords
CHECK(passwordSet.size() == 3);
CHECK(password_set.size() == 3);

for (const auto &password : passwordSet)
for (const auto &password : password_set)
{
CHECK(password.length() >= 10);
CHECK(hasLettersAndDigit(password));
Expand Down

0 comments on commit 63ff24a

Please sign in to comment.