Skip to content

Commit

Permalink
chore: add from json tests
Browse files Browse the repository at this point in the history
Add from json tests.

Signed-off-by: Melg Eight <public.melg8@gmail.com>
  • Loading branch information
melg8 committed May 10, 2024
1 parent 8e93508 commit 909740c
Show file tree
Hide file tree
Showing 14 changed files with 565 additions and 65 deletions.
4 changes: 2 additions & 2 deletions Testing/Temporary/LastTest.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Start testing: Apr 22 11:50 UTC
Start testing: May 10 00:39 UTC
----------------------------------------------------------
End testing: Apr 22 11:50 UTC
End testing: May 10 00:39 UTC
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ docker-run-shell:
format-all:
@ci/formatters/clang_format.sh

coal:
find {{invocation_directory()}} -type f -executable -name "coal" -exec {} \;
coala:
find {{invocation_directory()}} -type f -executable -name "coala" -exec {} \;
2 changes: 2 additions & 0 deletions sources/coal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
# SPDX-License-Identifier: MIT

add_subdirectory(application)
add_subdirectory(library)
add_subdirectory(tests)
35 changes: 18 additions & 17 deletions sources/coal/application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ find_package(glaze REQUIRED)

option(SPDLOG_NO_EXCEPTIONS "Compile with -fno-exceptions. Call abort() on any spdlog exceptions" ON)

file(GLOB_RECURSE ALL_COAL_APPLICATION_HEADERS
file(GLOB_RECURSE ALL_COALA_APPLICATION_HEADERS
"${CMAKE_CURRENT_SOURCE_DIR}/*.h")

message("adventure land headers:" "${ALL_COAL_APPLICATION_HEADERS}")
message("adventure land headers:" "${ALL_COALA_APPLICATION_HEADERS}")

file(GLOB_RECURSE ALL_COAL_APPLICATION_SOURCES
file(GLOB_RECURSE ALL_COALA_APPLICATION_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")

add_executable(coal "${ALL_COAL_APPLICATION_HEADERS}"
"${ALL_COAL_APPLICATION_SOURCES}")
add_executable(coala "${ALL_COALA_APPLICATION_HEADERS}"
"${ALL_COALA_APPLICATION_SOURCES}")

header_directories(ALL_COAL_INCLUDE_DIRECTORIES)
header_directories(ALL_COALA_INCLUDE_DIRECTORIES)

target_include_directories(coal PUBLIC
"${ALL_COAL_INCLUDE_DIRECTORIES}")
target_include_directories(coala PUBLIC
"${ALL_COALA_INCLUDE_DIRECTORIES}")


if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
Expand All @@ -38,12 +38,13 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_compiler_flags(-Wno-mismatched-new-delete)
endif()

target_link_libraries(coal PRIVATE Boost::cobalt
Boost::json
Boost::url
ctre::ctre
fmt::fmt
glaze::glaze
libassert::assert
OpenSSL::SSL
spdlog::spdlog)
target_link_libraries(coala PRIVATE Boost::cobalt
Boost::json
Boost::url
ctre::ctre
fmt::fmt
glaze::glaze
libassert::assert
OpenSSL::SSL
spdlog::spdlog
coal)
2 changes: 1 addition & 1 deletion sources/coal/application/sources/auth_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#ifndef AUTH_CLIENT_H
#define AUTH_CLIENT_H

#include <servers_and_characters_response_from_json.h>
#include <universal_declarations.h>
#include <servers_and_characters_response_parser.h>

#include <boost/cobalt.hpp>

Expand Down

This file was deleted.

15 changes: 15 additions & 0 deletions sources/coal/library/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: © 2024 Melg Eight <public.melg8@gmail.com>
#
# SPDX-License-Identifier: MIT


file(GLOB_RECURSE ALL_COAL_LIB_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
file(GLOB_RECURSE ALL_COAL_LIB_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")

add_library(coal STATIC "${ALL_COAL_LIB_HEADERS}"
"${ALL_COAL_LIB_SOURCES}")

header_directories(ALL_LIB_INCLUDE_DIRECTORIES)

target_include_directories(coal PUBLIC "${ALL_LIB_INCLUDE_DIRECTORIES}")

Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
//
// SPDX-License-Identifier: MIT

#include <servers_and_characters_response_parser.h>
#include <servers_and_characters_response_from_json.h>
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// SPDX-FileCopyrightText: © 2024 Melg Eight <public.melg8@gmail.com>
//
// SPDX-License-Identifier: MIT

#ifndef SERVERS_AND_CHARACTERS_RESPONSE_FROM_JSON_H
#define SERVERS_AND_CHARACTERS_RESPONSE_FROM_JSON_H

#include <cstdint>
#include <string>
#include <unordered_map>
#include <variant>
#include <vector>

namespace coal {

struct Character {
std::string id = {};
std::string name = {};
size_t level = {};
std::string type = {};
int online = {};
std::string skin = {};
std::unordered_map<std::string, std::string> cx = {};
std::string in = {};
std::string map = {};
double x = 0.0;
double y = 0.0;
std::string home = {};
};

using Characters = std::vector<Character>;

struct Server {
std::string name = {};
std::string region = {};
size_t players = 0u;
std::string key = {};
std::string addr = {};
int port = {};
};
using Servers = std::vector<Server>;

struct TutorialStatus {
size_t step = 0u;
std::vector<std::string> completed = {};
bool finished = false;
bool task = false;
size_t progress = 0;
};

using CodeElement = std::vector<std::variant<std::string, size_t>>;

using CodeMap = std::unordered_map<std::string, CodeElement>;

struct Reward {
std::string something;
};

using Rewards = std::vector<Reward>;

struct ServersAndCharactersResponse {
std::string type = {};
Servers servers = {};
Characters characters = {};
TutorialStatus tutorial = {};
CodeMap code_list = {};
int mail = 0;
Rewards rewards = {};
};

} // namespace coal

#endif // SERVERS_AND_CHARACTERS_RESPONSE_FROM_JSON_H
5 changes: 5 additions & 0 deletions sources/coal/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: © 2024 Melg Eight <public.melg8@gmail.com>
#
# SPDX-License-Identifier: MIT

add_subdirectory(unit_tests)
24 changes: 24 additions & 0 deletions sources/coal/tests/unit_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-FileCopyrightText: © 2024 Melg Eight <public.melg8@gmail.com>
#
# SPDX-License-Identifier: MIT

find_package(glaze REQUIRED)

file(GLOB_RECURSE ALL_COAL_TESTS_APPLICATION_HEADERS
"${CMAKE_CURRENT_SOURCE_DIR}/*.h")

file(GLOB_RECURSE ALL_COAL_TESTS_APPLICATION_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")

add_executable(coal_tests "${ALL_COAL_TESTS_APPLICATION_HEADERS}"
"${ALL_COAL_TESTS_APPLICATION_SOURCES}")

target_link_libraries(
coal_tests PUBLIC coal testing_framework glaze::glaze)

add_test(coal_tests coal_tests)

header_directories(ALL_COAL_TESTS_INCLUDE_DIRECTORIES)

target_include_directories(coal_tests PUBLIC
"${ALL_COAL_TESTS_INCLUDE_DIRECTORIES}")

0 comments on commit 909740c

Please sign in to comment.