diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..7623e2db --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,16 @@ +--- +Checks: > + *, + -altera-struct-pack-align, + -fuchsia-*, + -google-*, + -zircon-*, + -abseil-*, + -modernize-use-trailing-return-type, + -llvm-*, + -llvmlibc-*, + -cppcoreguidelines-virtual-class-destructor, +CheckOptions: [{ key: misc-non-private-member-variables-in-classes, value: IgnoreClassesWithAllMemberVariablesBeingPublic }] +WarningsAsErrors: '*' +HeaderFilterRegex: '' +FormatStyle: none diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..4fcbb21f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,53 @@ +name: Build + +on: + push: + branches: + - dev + pull_request: + +jobs: + client-windows: + name: Client on Windows + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - name: Create build dir + run: mkdir -p build + - name: Run CMake + run: cd build && cmake -G "Unix Makefiles" .. + - name: Build + run: cd build && make client + client-linux: + name: Client on Linux (Ubuntu) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create build dir + run: mkdir -p build + - name: Run CMake + run: cd build && cmake .. + - name: Build + run: cd build && make client + server-windows: + name: Server on Windows + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - name: Create build dir + run: mkdir -p build + - name: Run CMake + run: cd build && cmake -G "Unix Makefiles" .. + - name: Build + run: cd build && make server + server-linux: + name: Server on Linux (Ubuntu) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create build dir + run: mkdir -p build + - name: Run CMake + run: cd build && cmake .. + - name: Build + run: cd build && make server diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..59c1742a --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,22 @@ +name: Lint + +on: + push: + branches: + - dev + pull_request: + +jobs: + clang-tidy: + name: clang-tidy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create build dir + run: mkdir -p build + - name: Run CMake + run: cd build && cmake .. + - name: clang-tidy version + run: clang-tidy --version + - name: Lint + run: cd build && make lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..4fbbcb6d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,75 @@ +name: Test + +on: + push: + branches: + - dev + pull_request: + +jobs: + client-windows: + name: Client on Windows + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - name: Create build dir + run: mkdir -p build + - name: Run CMake + run: cd build && cmake -G "Unix Makefiles" .. + - name: Test + run: cd build && make run_client_tests + client-linux: + name: Client on Linux (Ubuntu) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create build dir + run: mkdir -p build + - name: Run CMake + run: cd build && cmake .. + - name: Test + run: cd build && make run_client_tests + server-windows: + name: Server on Windows + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - name: Create build dir + run: mkdir -p build + - name: Run CMake + run: cd build && cmake -G "Unix Makefiles" .. + - name: Test + run: cd build && make run_server_tests + server-linux: + name: Server on Linux (Ubuntu) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create build dir + run: mkdir -p build + - name: Run CMake + run: cd build && cmake .. + - name: Test + run: cd build && make run_server_tests + shared-windows: + name: Shared on Windows + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - name: Create build dir + run: mkdir -p build + - name: Run CMake + run: cd build && cmake -G "Unix Makefiles" .. + - name: Test + run: cd build && make run_shared_tests + shared-linux: + name: Shared on Linux (Ubuntu) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create build dir + run: mkdir -p build + - name: Run CMake + run: cd build && cmake .. + - name: Test + run: cd build && make run_shared_tests diff --git a/.gitignore b/.gitignore index 1a7990b9..2ae8e785 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ build/ assets/* .vscode/ .vs/ +.cache/ docs/* !docs/.gitkeep \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b995da8..4a39e321 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,12 @@ endif() set(CMAKE_CXX_STANDARD 20) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/bin) +# Generate a "compile_commands.json" file for clang-tidy and VScode to use +set(CMAKE_EXPORT_COMPILE_COMMANDS True) + +# Add google test to CMake +add_subdirectory(dependencies/google-test) + # If we need any compiler / linker flags, add them here SET(GCC_COMPILE_FLAGS "") SET(GCC_LINK_FLAGS "") @@ -28,4 +34,13 @@ SET(INCLUDE_DIRECTORY ${PROJECT_SOURCE_DIR}/include) add_subdirectory(src/shared) # define game_shared_lib add_subdirectory(src/client) # create client executable -add_subdirectory(src/server) # create server executable \ No newline at end of file +add_subdirectory(src/server) # create server executable + +# this might not be compatible on Windows due to how find is used +file(GLOB_RECURSE LINT_FILES "src/*.cpp" "include/*.hpp") +find_program(CLANG_TIDY "clang-tidy") +add_custom_target(lint + COMMAND ${CLANG_TIDY} + -p=. + ${LINT_FILES} +) \ No newline at end of file diff --git a/README.md b/README.md index 5fcdf9f3..dddbb472 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ TODO: Game description here, with screenshots. - in the popup window put in this URL: `https://github.com/ucsd-cse125-sp24/group3.git` - Alternatively, you can use the command line and then open Visual Studio in the directory where you cloned it: - `git clone https://github.com/ucsd-cse125-sp24/group3.git` -3. Everything should just work™. To run the program, you can click on the green arrow at the top bar that says "Select Startup Item." There is a dropdown arrow on the right side which will let you select between running the client and the server. +3. Everything should just work�. To run the program, you can click on the green arrow at the top bar that says "Select Startup Item." There is a dropdown arrow on the right side which will let you select between running the client and the server. ### Linux / Mac @@ -137,3 +137,51 @@ View deployed documentation [here](https://cse125.ucsd.edu/2024/cse125g3/site/do 2. Run `doxygen` from the root of the directory 3. Open the `html` files in the `docs` directory of the repo + +## Testing + +We are using [GoogleTest](https://google.github.io/googletest/) for unit testing. They run automatically in GitHub actions or can also be done manually. + +There are three categories of unit tests: + +1. Client tests for client specific code +2. Server tests for server specific code +2. Shared tests for code shared between the client and server + +### Running Tests Locally + +From the build directory run the following commands for each testing category: + +```sh +make run_client_tests +make run_server_tests +make run_shared_tests +``` + +### Adding New Tests + +1. Add a new `.cpp` file to the testing directory you want (either `src/client/tests`, `src/server/tests` or `src/shared/tests`). + +2. Add a testing function with the GoogleTest `TEST` macro. See [this](https://google.github.io/googletest/reference/assertions.html) page to see all the available assertions. +```cpp +// Tests factorial of positive numbers. +TEST(FactorialTest, HandlesPositiveInput) { + EXPECT_EQ(Factorial(1), 1); + EXPECT_EQ(Factorial(2), 2); + EXPECT_EQ(Factorial(3), 6); + EXPECT_EQ(Factorial(8), 40320); +} +``` +3. Run the tests locally with the steps above or with GitHub actions + +## Linting + +We are using [clang-tidy](https://clang.llvm.org/extra/clang-tidy/) for linting and code style. They run automatically with GitHub actions. + +### Linting locally + +#### Linux/macOS +Install clang-tidy on your system. [Here are instructions for Debian/Ubuntu Linux distros](https://apt.llvm.org/). [Here is a Stack Overflow of people attempting to install it on macOS](https://stackoverflow.com/questions/53111082/how-to-install-clang-tidy-on-macos). + +#### Windows +Visual Studio supports [clang-tidy natively](https://learn.microsoft.com/en-us/cpp/code-quality/clang-tidy?view=msvc-170) diff --git a/dependencies/.clang-tidy b/dependencies/.clang-tidy new file mode 100644 index 00000000..8f3d2744 --- /dev/null +++ b/dependencies/.clang-tidy @@ -0,0 +1,3 @@ +# Disable all checks in this folder. +Checks: '-*' + diff --git a/dependencies/google-test/CMakeLists.txt b/dependencies/google-test/CMakeLists.txt new file mode 100644 index 00000000..acd761dd --- /dev/null +++ b/dependencies/google-test/CMakeLists.txt @@ -0,0 +1,69 @@ +# Download and unpack googletest at configure time +# See: http://crascit.com/2015/07/25/cmake-gtest/ +configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) +# Call CMake to download and Google Test +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) +if(result) + message(FATAL_ERROR "CMake step for googletest failed: ${result}") +endif() +# Build the downloaded google test +execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) +if(result) + message(FATAL_ERROR "Build step for googletest failed: ${result}") +endif() + +# Prevent overriding the parent project's compiler/linker +# settings on Windows +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +# Prevent installation of GTest with your project +set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) +set(INSTALL_GMOCK OFF CACHE BOOL "" FORCE) + +# Add googletest directly to our build. This defines +# the gtest and gtest_main targets. +add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src + ${CMAKE_CURRENT_BINARY_DIR}/googletest-build) + +# This is a bit of a hack that can be used to get gtest libraries to build in C++11 if you aren't using CMAKE_CXX_STANDARD +# +#set(CXX11_FEATURES +# cxx_nullptr +# cxx_auto_type +# cxx_delegating_constructors +#) +#target_compile_features(gtest +# PRIVATE +# ${CXX11_FEATURES} +#) +# +#target_compile_features(gmock_main +# PRIVATE +# ${CXX11_FEATURES} +#) +# +#target_compile_features(gmock +# PRIVATE +# ${CXX11_FEATURES} +#) +# +#target_compile_features(gmock_main +# PRIVATE +# ${CXX11_FEATURES} +#) + +# Add aliases for GTest and GMock libraries +if(NOT TARGET GTest::GTest) + add_library(GTest::GTest ALIAS gtest) + add_library(GTest::Main ALIAS gtest_main) +endif() + +if(NOT TARGET GTest::GMock) + add_library(GMock::GMock ALIAS gmock) + add_library(GMock::Main ALIAS gmock_main) +endif() + + diff --git a/dependencies/google-test/CMakeLists.txt.in b/dependencies/google-test/CMakeLists.txt.in new file mode 100644 index 00000000..4b9cab31 --- /dev/null +++ b/dependencies/google-test/CMakeLists.txt.in @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.0) + +project(googletest-download NONE) + +include(ExternalProject) + +# Version bfc0ffc8a698072c794ae7299db9cb6866f4c0bc happens to be master when I set this up. +# To prevent an issue with accidentally installing GTest / GMock with your project you should use a +# commit after 9469fb687d040b60c8749b7617fee4e77c7f6409 +# Note: This is after the release of v1.8 +ExternalProject_Add(googletest + URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz + SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + DOWNLOAD_EXTRACT_TIMESTAMP true +) + diff --git a/include/client/client.hpp b/include/client/client.hpp index 83e3b177..1604ccd0 100644 --- a/include/client/client.hpp +++ b/include/client/client.hpp @@ -2,7 +2,7 @@ class Client { public: - Client(); + Client() = default; private: }; diff --git a/include/server/server.hpp b/include/server/server.hpp index 4971cfd5..38009003 100644 --- a/include/server/server.hpp +++ b/include/server/server.hpp @@ -2,7 +2,7 @@ class Server { public: - Server(); + Server() = default; private: }; diff --git a/include/shared/game/gamestate.hpp b/include/shared/game/gamestate.hpp index 84eeb46d..fcfa32fa 100644 --- a/include/shared/game/gamestate.hpp +++ b/include/shared/game/gamestate.hpp @@ -6,14 +6,14 @@ class GameState : public Serializable { public: - GameState(); + GameState() = default; /** * Serializes GameState instances to be sent over the * network. * @return serialized string of GameState */ - std::string serialize() const override; + [[nodiscard]] std::string serialize() const override; private: }; diff --git a/include/shared/utilities/serializable.hpp b/include/shared/utilities/serializable.hpp index 6f9f4c96..d869d17f 100644 --- a/include/shared/utilities/serializable.hpp +++ b/include/shared/utilities/serializable.hpp @@ -9,6 +9,6 @@ class Serializable { public: // Maybe we want to change the return type of this to not be string? - virtual std::string serialize() const = 0; + [[nodiscard]] virtual std::string serialize() const = 0; }; diff --git a/shell.nix b/shell.nix index 585ecdd0..3b353143 100644 --- a/shell.nix +++ b/shell.nix @@ -10,5 +10,6 @@ mkShell { gcc13 doxygen + clang-tools_14 ]; } diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 61737ac8..3060d90f 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -1,11 +1,16 @@ set(TARGET_NAME client) +set(LIB_NAME game_client_lib) set(FILES - main.cpp client.cpp ) -add_executable(${TARGET_NAME} ${FILES}) +add_library(${LIB_NAME} STATIC ${FILES}) +target_include_directories(${LIB_NAME} PRIVATE ${INCLUDE_DIRECTORY}) + +add_executable(${TARGET_NAME} main.cpp) target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_DIRECTORY}) -target_link_libraries(${TARGET_NAME} PRIVATE game_shared_lib) \ No newline at end of file +target_link_libraries(${TARGET_NAME} PRIVATE ${LIB_NAME} game_shared_lib) + +add_subdirectory(tests) # define client unit tests \ No newline at end of file diff --git a/src/client/client.cpp b/src/client/client.cpp index e4870209..1fd6b497 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1,5 +1,2 @@ #include "client/client.hpp" -Client::Client() { - -} diff --git a/src/client/main.cpp b/src/client/main.cpp index a90c04a4..e5c0ee0f 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -9,5 +9,5 @@ int main() { std::cout << "I am a client!\n"; // Test that shared lib is linked correctly - std::cout << "Random number: " << randomInt(0, 100) << "\n"; + std::cout << "Random number: " << randomInt(0, 100) << "\n"; // NOLINT } diff --git a/src/client/tests/.clang-tidy b/src/client/tests/.clang-tidy new file mode 100644 index 00000000..2f122e33 --- /dev/null +++ b/src/client/tests/.clang-tidy @@ -0,0 +1,2 @@ +# Disable all checks in this folder. +Checks: '-*' diff --git a/src/client/tests/CMakeLists.txt b/src/client/tests/CMakeLists.txt new file mode 100644 index 00000000..4a24ea32 --- /dev/null +++ b/src/client/tests/CMakeLists.txt @@ -0,0 +1,25 @@ +set(TARGET_NAME client_tests) + +set(FILES + hello_client_test.cpp +) + +add_executable(${TARGET_NAME} ${FILES} ${CLIENT_FILES}) +target_link_libraries(${TARGET_NAME} PRIVATE game_client_lib game_shared_lib) + +target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_DIRECTORY}) + +target_link_libraries(${TARGET_NAME} PUBLIC gtest_main) +add_test(NAME ${TARGET_NAME} COMMAND ${TARGET_NAME}) + +# setup make target +set(RUN_TESTS_TARGET "run_${TARGET_NAME}") +add_custom_target(${RUN_TESTS_TARGET}) +add_custom_command( + TARGET ${RUN_TESTS_TARGET} + COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET_NAME}" + ARGS "--output-on-failure" +) +add_dependencies(${RUN_TESTS_TARGET} ${TARGET_NAME}) + + diff --git a/src/client/tests/hello_client_test.cpp b/src/client/tests/hello_client_test.cpp new file mode 100644 index 00000000..9fafe69b --- /dev/null +++ b/src/client/tests/hello_client_test.cpp @@ -0,0 +1,9 @@ +#include + +#include "client/client.hpp" + +TEST(HelloClientTest, HelloWorld) { + Client c; + + EXPECT_TRUE(true); +} diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index d32bc275..ec0692e5 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -1,11 +1,16 @@ set(TARGET_NAME server) +set(LIB_NAME game_server_lib) set(FILES - main.cpp server.cpp ) -add_executable(${TARGET_NAME} ${FILES}) +add_library(${LIB_NAME} STATIC ${FILES}) +target_include_directories(${LIB_NAME} PRIVATE ${INCLUDE_DIRECTORY}) + +add_executable(${TARGET_NAME} main.cpp) target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_DIRECTORY}) -target_link_libraries(${TARGET_NAME} PRIVATE game_shared_lib) \ No newline at end of file +target_link_libraries(${TARGET_NAME} PRIVATE ${LIB_NAME} game_shared_lib) + +add_subdirectory(tests) # define server unit tests \ No newline at end of file diff --git a/src/server/main.cpp b/src/server/main.cpp index dd1e5145..438b1d4c 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -9,5 +9,5 @@ int main() { std::cout << "I am a server!\n"; // Test that shared lib is linked correctly - std::cout << "Random number: " << randomInt(0, 100) << "\n"; + std::cout << "Random number: " << randomInt(0, 100) << "\n"; // NOLINT } diff --git a/src/server/server.cpp b/src/server/server.cpp index a9d6e465..71526213 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -1,5 +1,2 @@ #include "server/server.hpp" -Server::Server() { - -} diff --git a/src/server/tests/.clang-tidy b/src/server/tests/.clang-tidy new file mode 100644 index 00000000..2f122e33 --- /dev/null +++ b/src/server/tests/.clang-tidy @@ -0,0 +1,2 @@ +# Disable all checks in this folder. +Checks: '-*' diff --git a/src/server/tests/CMakeLists.txt b/src/server/tests/CMakeLists.txt new file mode 100644 index 00000000..5c018366 --- /dev/null +++ b/src/server/tests/CMakeLists.txt @@ -0,0 +1,25 @@ +set(TARGET_NAME server_tests) + +set(FILES + hello_server_test.cpp +) + +add_executable(${TARGET_NAME} ${FILES}) +target_link_libraries(${TARGET_NAME} PRIVATE game_server_lib game_shared_lib) + +target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_DIRECTORY}) + +target_link_libraries(${TARGET_NAME} PUBLIC gtest_main) +add_test(NAME ${TARGET_NAME} COMMAND ${TARGET_NAME}) + +# setup make target +set(RUN_TESTS_TARGET "run_${TARGET_NAME}") +add_custom_target(${RUN_TESTS_TARGET}) +add_custom_command( + TARGET ${RUN_TESTS_TARGET} + COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET_NAME}" + ARGS "--output-on-failure" +) +add_dependencies(${RUN_TESTS_TARGET} ${TARGET_NAME}) + + diff --git a/src/server/tests/hello_server_test.cpp b/src/server/tests/hello_server_test.cpp new file mode 100644 index 00000000..eac48b18 --- /dev/null +++ b/src/server/tests/hello_server_test.cpp @@ -0,0 +1,9 @@ +#include + +#include "server/server.hpp" + +TEST(HelloServerTest, HelloWorld) { + Server s; + + EXPECT_TRUE(true); +} diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt index f58d3e84..0ef2f687 100644 --- a/src/shared/CMakeLists.txt +++ b/src/shared/CMakeLists.txt @@ -9,4 +9,6 @@ set(FILES ) add_library(${LIB_NAME} STATIC ${FILES}) -target_include_directories(${LIB_NAME} PRIVATE ${INCLUDE_DIRECTORY}) \ No newline at end of file +target_include_directories(${LIB_NAME} PRIVATE ${INCLUDE_DIRECTORY}) + +add_subdirectory(tests) # define shared unit tests \ No newline at end of file diff --git a/src/shared/game/gamestate.cpp b/src/shared/game/gamestate.cpp index da0c1060..603fb829 100644 --- a/src/shared/game/gamestate.cpp +++ b/src/shared/game/gamestate.cpp @@ -2,10 +2,6 @@ #include -GameState::GameState() { - -} - std::string GameState::serialize() const { return ""; } diff --git a/src/shared/tests/.clang-tidy b/src/shared/tests/.clang-tidy new file mode 100644 index 00000000..2f122e33 --- /dev/null +++ b/src/shared/tests/.clang-tidy @@ -0,0 +1,2 @@ +# Disable all checks in this folder. +Checks: '-*' diff --git a/src/shared/tests/CMakeLists.txt b/src/shared/tests/CMakeLists.txt new file mode 100644 index 00000000..e78f8e83 --- /dev/null +++ b/src/shared/tests/CMakeLists.txt @@ -0,0 +1,25 @@ +set(TARGET_NAME shared_tests) + +set(FILES + hello_shared_test.cpp +) + +add_executable(${TARGET_NAME} ${FILES}) +target_link_libraries(${TARGET_NAME} PRIVATE game_shared_lib) + +target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_DIRECTORY}) + +target_link_libraries(${TARGET_NAME} PUBLIC gtest_main) +add_test(NAME ${TARGET_NAME} COMMAND ${TARGET_NAME}) + +# setup make target +set(RUN_TESTS_TARGET "run_${TARGET_NAME}") +add_custom_target(${RUN_TESTS_TARGET}) +add_custom_command( + TARGET ${RUN_TESTS_TARGET} + COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET_NAME}" + ARGS "--output-on-failure" +) +add_dependencies(${RUN_TESTS_TARGET} ${TARGET_NAME}) + + diff --git a/src/shared/tests/hello_shared_test.cpp b/src/shared/tests/hello_shared_test.cpp new file mode 100644 index 00000000..ddeaae74 --- /dev/null +++ b/src/shared/tests/hello_shared_test.cpp @@ -0,0 +1,5 @@ +#include + +TEST(HelloSharedTest, HelloWorld) { + EXPECT_TRUE(true); +} diff --git a/src/shared/utilities/rng.cpp b/src/shared/utilities/rng.cpp index 22ddec56..d8d51574 100644 --- a/src/shared/utilities/rng.cpp +++ b/src/shared/utilities/rng.cpp @@ -4,15 +4,15 @@ #include double random(double min, double max) { - static std::random_device rd; - static std::mt19937 generator(rd()); + static std::random_device random_device; + static std::mt19937 generator(random_device()); std::uniform_real_distribution<> distro(min, max); return distro(generator); } int randomInt(int min, int max) { - static std::random_device rd; - static std::mt19937 generator(rd()); + static std::random_device random_device; + static std::mt19937 generator(random_device()); std::uniform_int_distribution<> distro(min, max); return distro(generator); } \ No newline at end of file