diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6af0822 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.14) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +project(PasswordManager) + +set(FLAGS -Wall -Werror -Wpedantic -Wextra) + +enable_testing() + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug) +endif() + +if(CMAKE_BUILD_TYPE MATCHES Release) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Release/) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Release/) +else() + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Debug/) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Debug/) +endif() + +include_directories(headers) +add_subdirectory(source) diff --git a/headers/PasswordManager.h b/headers/PasswordManager.h new file mode 100644 index 0000000..bf7bb80 --- /dev/null +++ b/headers/PasswordManager.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +class PasswordManager { +public: + PasswordManager() = default; + PasswordManager(const std::string& password); + + ~PasswordManager(); +private: + std::string password_; +}; \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt new file mode 100644 index 0000000..38f7951 --- /dev/null +++ b/source/CMakeLists.txt @@ -0,0 +1,5 @@ +project(PasswordManager) + +add_executable(passwordManager main.cpp PasswordManager.cpp) + +add_subdirectory(test) \ No newline at end of file diff --git a/source/PasswordManager.cpp b/source/PasswordManager.cpp new file mode 100644 index 0000000..0e74e1b --- /dev/null +++ b/source/PasswordManager.cpp @@ -0,0 +1,13 @@ +#include + +#include "PasswordManager.h" + +PasswordManager::PasswordManager(const std::string& password) + : password_(password) +{ + std::cout << "Password is: " << password_ << '\n'; +} + +PasswordManager::~PasswordManager() { + std::cout << "Password manager destructor\n"; +} \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp new file mode 100644 index 0000000..d5ad91e --- /dev/null +++ b/source/main.cpp @@ -0,0 +1,10 @@ +#include + +#include "PasswordManager.h" + +int main() { + std::string password = "haslo"; + PasswordManager passwordManager(password); + + return 0; +} \ No newline at end of file diff --git a/source/test/CMakeLists.txt b/source/test/CMakeLists.txt new file mode 100644 index 0000000..697d529 --- /dev/null +++ b/source/test/CMakeLists.txt @@ -0,0 +1,18 @@ +include(FetchContent) + +set(TEST_NAME ${PROJECT_NAME}-UT) + +FetchContent_Declare( + googletest + GIT_REPOSITORY "https://github.com/google/googletest.git" + GIT_TAG release-1.11.0 +) + +FetchContent_MakeAvailable(googletest) + +add_executable(${TEST_NAME} test.cpp) +target_link_libraries(${TEST_NAME} gtest_main) +set_target_properties(${TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/test") + +include(GoogleTest) +gtest_discover_tests(${TEST_NAME}) \ No newline at end of file diff --git a/source/test/test.cpp b/source/test/test.cpp new file mode 100644 index 0000000..779f984 --- /dev/null +++ b/source/test/test.cpp @@ -0,0 +1,6 @@ +#include "gtest/gtest.h" +#include "PasswordManager.h" + +TEST(CheckIfCMakeWorks, returnsTrue) { + ASSERT_TRUE(true); +} \ No newline at end of file