removing tests

This commit is contained in:
noffie 2024-12-12 18:35:36 +01:00
parent a292364745
commit 04907abda7
7 changed files with 167 additions and 93 deletions

View file

@ -73,12 +73,6 @@ set(FETCHCONTENT_UPDATES_DISCONNECTED ON) # Prevent automatic updates
set(FETCHCONTENT_QUIET OFF) # Display download progress
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Generate compile_commands.json
# ========================================================
# Options
# ========================================================
option(SVA_BUILD_TEST ON) # Option for test to be build as well
# ========================================================
# External Dependencies
# ========================================================
@ -101,6 +95,7 @@ FetchContent_Declare(
FetchContent_MakeAvailable(lua)
set(LUA_BUILD_INTERPRETER ON CACHE BOOL "Build the Lua interpreter" FORCE)
set(SOL2_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
# ========================================================
# Helper Function: Set Common Target Properties
@ -159,85 +154,9 @@ if (APPLE)
target_link_libraries(${PROJECT_NAME} "-framework Cocoa")
target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
endif()
# -------------------------------
# SFML (Not used anymore)
# -------------------------------
#
# --- Add SFML (Simple and Fast Multimedia Library)
# FetchContent_Declare(SFML
# GIT_REPOSITORY https://github.com/SFML/SFML.git
# GIT_TAG 2.6.x
# GIT_SHALLOW ON
# EXCLUDE_FROM_ALL
# SYSTEM
# )
# FetchContent_MakeAvailable(SFML)
#
# target_link_libraries(${GUI_TARGET_NAME} PRIVATE sfml-graphics) # Link SFML graphics library
#
# --- Special handling for Windows: Copy OpenAL DLL (for sound support)
# if(WIN32)
# add_custom_command(
# TARGET ${GUI_TARGET_NAME}
# COMMENT "Copy OpenAL DLL"
# PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SFML_SOURCE_DIR}/extlibs/bin/$<IF:$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>,x64,x86>/openal32.dll $<TARGET_FILE_DIR:${GUI_TARGET_NAME}>
# VERBATIM
# )
# endif()
# // SFML is not used anymore
set_common_properties(${GUI_TARGET_NAME})
# ========================================================
# Test Setup (Only if SVA_BUILD_TEST is ON)
# ========================================================
if(${SVA_BUILD_TEST})
# --- Add Google Test
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) # Prevent shared CRT issues on Windows
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) # Prevents installation of gtest on the system
FetchContent_MakeAvailable(googletest)
# Enable testing support
enable_testing()
# --- Create Test Executable
set(TEST_TARGET_NAME "${GUI_TARGET_NAME}_test")
file(GLOB TEST_SOURCES "tests/*.cpp")
add_executable(
${TEST_TARGET_NAME}
${TEST_SOURCES}
)
target_link_libraries(
${TEST_TARGET_NAME}
PRIVATE GTest::gtest_main # Link Google Test framework
)
set_common_properties(${TEST_TARGET_NAME})
# --- Enable Google Test's test discovery feature
include(GoogleTest)
gtest_discover_tests(${TEST_TARGET_NAME})
# put google test targets into a folder
put_targets_into_folder(
FOLDER "gtest"
TARGETS
GTest::gtest_main
GTest::gmock_main
GTest::gmock
GTest::gtest
)
endif()
# Option to create an includes target
set(SVA_CREATE_INCLUDES_TARGET ON CACHE BOOL "Create an includes target")

56
include/logger.hpp Normal file
View file

@ -0,0 +1,56 @@
#pragma once
#include <string>
#include <iostream>
#include <unordered_map>
namespace sva
{
class Logging
{
std::unordered_map<size_t, std::string> m_Level_Names;
size_t m_Active_Level;
std::ostream& m_Stream;
public:
Logging(std::ostream& stream);
template<typename T> requires std::is_enum_v<T>
std::string& levelName(const T lvl)
{
return m_Level_Names[static_cast<size_t>(lvl)];
}
template<typename ...Args>
Logging& logln(Args&& ...args)
{
m_Stream << " [" << m_Level_Names[m_Active_Level] << "] " << (std::forward<Args>(args) << ...) << std::endl;
return *this;
}
template<typename T> requires std::is_enum_v<T>
Logging& operator()(const T lvl)
{
try
{
std::string& lvn = m_Level_Names.at(static_cast<size_t>(lvl));
}
catch (...)
{
return *this;
}
m_Active_Level = static_cast<size_t>(lvl);
return *this;
}
};
}
#ifdef SVA_LOGGING_IMPLEMENTATION
#undef SVA_LOGGING_IMPLEMENTATION
sva::Logging::Logging(std::ostream& stream) : m_Active_Level(0), m_Stream(stream)
{
m_Level_Names[0] = "General";
}
#endif

View file

@ -1,2 +0,0 @@
#define RAYGUI_IMPLEMENTATION
#include <raylibs/raygui.h>

5
src/libimpl.cpp Normal file
View file

@ -0,0 +1,5 @@
#define RAYGUI_IMPLEMENTATION
#include <raylibs/raygui.h>
#define SVA_LOGGING_IMPLEMENTATION
#include <logger.hpp>

View file

@ -13,13 +13,115 @@
* Signature: "Darling, I'm Home!" - Jann Hoffmann
**************************************************************/
#include <iostream>
// sva logger
#include <logger.hpp>
/* raylib includes */
#include <raylib.h>
#include <raylibs/raygui.h>
constexpr int window_width = 800;
constexpr int window_height = 650;
constexpr char window_title[] = "Sortiva";
enum class logerr_level
{
Debug = 0,
Window,
SVA,
};
void fitWindowToMonitor(int monitor = 0)
{
if (GetMonitorCount() < monitor) return;
int width = GetMonitorHeight(monitor);
int height = GetMonitorHeight(monitor);
SetWindowMonitor(monitor);
SetWindowSize(width, height);
int refresh_rate = GetMonitorRefreshRate(monitor);
SetTargetFPS(refresh_rate);
}
int main(void)
{
std::cout << "Darling, I'm Home!\n";
sva::Logging logerr = sva::Logging(std::cerr);
logerr.levelName(logerr_level::Debug) = "Debug";
logerr.levelName(logerr_level::Window) = "Window";
logerr.levelName(logerr_level::SVA) = "SVA";
logerr(logerr_level::Debug);
/* Window and rendering */
InitWindow(window_width, window_height, window_title);
fitWindowToMonitor();
if (!IsWindowReady())
{
logerr(logerr_level::Window).logln("Window could not be created...");
return 0;
}
ClearWindowState(ConfigFlags::FLAG_WINDOW_RESIZABLE | ConfigFlags::FLAG_WINDOW_TRANSPARENT);
SetWindowState(ConfigFlags::FLAG_WINDOW_ALWAYS_RUN | ConfigFlags::FLAG_BORDERLESS_WINDOWED_MODE);
SetWindowFocused();
bool m_Running = true;
int wnd_width = GetRenderWidth();
int wnd_height = GetRenderHeight();
Vector2 anchor03 = { static_cast<float>(wnd_width) / 2 , static_cast<float>(wnd_height) / 2 };
bool CloseQuestionBoxActive = false;
bool CQB_YesButton = false;
bool CQB_NoButton = false;
while (m_Running) {
if (IsWindowResized())
{
wnd_width = GetRenderWidth();
wnd_height = GetRenderHeight();
anchor03 = { static_cast<float>(wnd_width) / 2 , static_cast<float>(wnd_height) / 2 };
}
if (WindowShouldClose()) CloseQuestionBoxActive = !CloseQuestionBoxActive;
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
if (CloseQuestionBoxActive)
{
CloseQuestionBoxActive = !GuiWindowBox({ anchor03.x + -168, anchor03.y + -88, 328, 160 }, "#191# Are you sure you want to close this program?");
CQB_YesButton = GuiButton({ anchor03.x + -152, anchor03.y + 32, 120, 24 }, "Yes");
CQB_NoButton = GuiButton({ anchor03.x + 24, anchor03.y + 32, 120, 24 }, "No");
GuiLabel({ anchor03.x + -104, anchor03.y + -40, 208, 24 }, "Are you sure you want to close this?");
GuiLabel({ anchor03.x + -56, anchor03.y + -8, 120, 24 }, "Press \"Yes\" to close");
if (CQB_YesButton)
{
m_Running = false;
break;
}
if (CQB_NoButton) CloseQuestionBoxActive = false;
}
EndDrawing();
}
CloseWindow();
return 0;
}

View file

View file

@ -1,6 +0,0 @@
#include <gtest/gtest.h>
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}