Skip to content

Commit

Permalink
update test exe path in gh-wf, bump cpm, cxxopts and spdlog version, …
Browse files Browse the repository at this point in the history
…add formatter for Action::TargetType

Signed-off-by: Bryce Ferenczi <[email protected]>
  • Loading branch information
5had3z committed Aug 10, 2024
1 parent cd07f63 commit ccbe976
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 13 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ jobs:
run: |
export CC="/usr/bin/gcc-${{ matrix.gcc-version }}"
export CXX="/usr/bin/g++-${{ matrix.gcc-version }}"
cmake -B /home/runner/work/sc2-serializer/build -G Ninja -DSC2_PY_READER=OFF -DSC2_TESTS=ON -DBUILD_API_EXAMPLES=OFF
cmake -B /home/runner/work/sc2-serializer/build -G Ninja -DSC2_PY_READER=OFF -DSC2_TESTS=ON -DBUILD_API_EXAMPLES=OFF -DBUILD_API_TESTS=OFF
- name: Build and run tests
run: |
cmake --build /home/runner/work/sc2-serializer/build --parallel --config Release
/home/runner/work/sc2-serializer/build/test_database
/home/runner/work/sc2-serializer/build/test_readwrite
/home/runner/work/sc2-serializer/build/sc2_tests
- name: Archive build artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cpmaddpackage(
GITHUB_REPOSITORY
jarro2783/cxxopts
VERSION
2.2.1
3.2.0
OPTIONS
"CXXOPTS_BUILD_EXAMPLES NO"
"CXXOPTS_BUILD_TESTS NO"
Expand All @@ -41,7 +41,7 @@ cpmaddpackage(
GITHUB_REPOSITORY
gabime/spdlog
VERSION
1.12.0
1.14.1
OPTIONS
"SPDLOG_BUILD_PIC ON")

Expand Down
4 changes: 2 additions & 2 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors

set(CPM_DOWNLOAD_VERSION 0.38.6)
set(CPM_HASH_SUM "11c3fa5f1ba14f15d31c2fb63dbc8628ee133d81c8d764caad9a8db9e0bacb07")
set(CPM_DOWNLOAD_VERSION 0.40.2)
set(CPM_HASH_SUM "c8cdc32c03816538ce22781ed72964dc864b2a34a310d3b7104812a5ca2d835d")

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
Expand Down
24 changes: 24 additions & 0 deletions include/data_structures/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,28 @@ template<typename T> auto enumToOneHot(Action::TargetType e) noexcept -> std::ve
return detail::enumToOneHot_helper<T>(e, vals);
}


}// namespace cvt

/**
* @brief fmt formatter specialization for cvt::Action::TargetType
*/
template<> struct fmt::formatter<cvt::Action::TargetType> : formatter<string_view>
{
auto format(cvt::Action::TargetType a, format_context &ctx) const -> format_context::iterator
{
string_view ret = "Invalid";
switch (a) {
case cvt::Action::TargetType::Self:
ret = "Self";
break;
case cvt::Action::TargetType::OtherUnit:
ret = "OtherUnit";
break;
case cvt::Action::TargetType::Position:
ret = "Position";
break;
}
return formatter<string_view>::format(ret, ctx);
}
};
12 changes: 6 additions & 6 deletions include/data_structures/enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ auto enumToOneHot(E e) noexcept -> std::vector<T>
*/
template<> struct fmt::formatter<cvt::Alliance> : formatter<string_view>
{
auto format(cvt::Alliance a, format_context &ctx) const
auto format(cvt::Alliance a, format_context &ctx) const -> format_context::iterator
{
string_view ret = "Invalid";
switch (a) {
Expand All @@ -162,7 +162,7 @@ template<> struct fmt::formatter<cvt::Alliance> : formatter<string_view>
*/
template<> struct fmt::formatter<cvt::CloakState> : formatter<string_view>
{
auto format(cvt::CloakState c, format_context &ctx) const
auto format(cvt::CloakState c, format_context &ctx) const -> format_context::iterator
{
string_view ret = "Invalid";
switch (c) {
Expand Down Expand Up @@ -192,7 +192,7 @@ template<> struct fmt::formatter<cvt::CloakState> : formatter<string_view>
template<> struct fmt::formatter<cvt::Visibility> : formatter<string_view>
{
// auto format(cvt::Visibility v, format_context &ctx) const;
auto format(cvt::Visibility v, format_context &ctx) const
auto format(cvt::Visibility v, format_context &ctx) const -> format_context::iterator
{
string_view ret = "Invalid";
switch (v) {
Expand All @@ -215,7 +215,7 @@ template<> struct fmt::formatter<cvt::Visibility> : formatter<string_view>
*/
template<> struct fmt::formatter<cvt::AddOn> : formatter<string_view>
{
auto format(cvt::AddOn a, format_context &ctx) const
auto format(cvt::AddOn a, format_context &ctx) const -> format_context::iterator
{
string_view ret = "Invalid";
switch (a) {
Expand All @@ -238,7 +238,7 @@ template<> struct fmt::formatter<cvt::AddOn> : formatter<string_view>
*/
template<> struct fmt::formatter<cvt::Race> : formatter<string_view>
{
auto format(cvt::Race r, format_context &ctx) const
auto format(cvt::Race r, format_context &ctx) const -> format_context::iterator
{
string_view ret = "Invalid";
switch (r) {
Expand All @@ -264,7 +264,7 @@ template<> struct fmt::formatter<cvt::Race> : formatter<string_view>
*/
template<> struct fmt::formatter<cvt::Result> : formatter<string_view>
{
auto format(cvt::Result r, format_context &ctx) const
auto format(cvt::Result r, format_context &ctx) const -> format_context::iterator
{
string_view ret = "Invalid";
switch (r) {
Expand Down
9 changes: 9 additions & 0 deletions test/test_vectorization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@

#include <gtest/gtest.h>

TEST(AutoVectorTest, OneHotEnum)
{
ASSERT_EQ(cvt::numEnumValues<cvt::Alliance>(), 4uz);
auto e = cvt::Alliance::Ally;
auto oneHot = cvt::enumToOneHot<float>(e);
std::vector<float> expected = { 0.f, 1.f, 0.f, 0.f };
ASSERT_EQ(oneHot, expected);
}

TEST(AutoVectorTest, NeutralUnit)
{
cvt::NeutralUnit unit;
Expand Down

0 comments on commit ccbe976

Please sign in to comment.