-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMapNavMeshTest.cpp
More file actions
70 lines (59 loc) · 2.36 KB
/
Copy pathMapNavMeshTest.cpp
File metadata and controls
70 lines (59 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "pch.h"
#include <gtest/gtest.h>
#include <filesystem>
#include <string>
#include <vector>
#include "spdlog/spdlog.h"
#include "spdlog/sinks/stdout_sinks.h"
#include "GameData/ResourceLoader.h"
#include "Map.h"
#include "NavMesh.h"
namespace
{
// 리소스는 통합 폴더(Client/Assets/Resources/GameData) 한 곳에서 읽는다.
std::string ResolveGameDataPath()
{
const std::string& p = GameDataPath::Resolve();
if (std::filesystem::exists(p + "Map.json"))
return p;
return "";
}
// Map::ValidateMapDataOnNavMesh 는 LOG("net") 로거를 사용한다.
// 테스트 하네스에는 등록돼 있지 않으므로 stdout 로거를 등록해 정합 로그를 보이게 한다.
void EnsureNetLogger()
{
if (!spdlog::get("net"))
{
auto logger = std::make_shared<spdlog::logger>(
"net", std::make_shared<spdlog::sinks::stdout_sink_mt>());
logger->set_level(spdlog::level::debug);
spdlog::register_logger(logger);
}
}
}
//---------------------------------------------------------------------------------------
// 씬-navmesh 정합: navmesh 바이너리가 배치된 맵(field 월드 맵)의 게이트/스폰 마커가
// 모두 navmesh 위에 있어야 한다. 씬을 수정하고 navmesh 재생성을 잊으면 여기서 잡힌다.
//---------------------------------------------------------------------------------------
TEST(MapNavMeshTest, MarkersAreOnNavMesh)
{
EnsureNetLogger();
std::string dataPath = ResolveGameDataPath();
ASSERT_FALSE(dataPath.empty()) << "GameData/Map.json 을 찾지 못했습니다.";
ASSERT_TRUE(ResourceLoader::Instance().LoadResources(dataPath)) << "LoadResources 실패";
int validated = 0;
for (const auto& [id, mapData] : ResourceLoader::Instance().GetMaps())
{
if (mapData->navmesh_path.empty())
continue;
std::string binPath = dataPath + mapData->navmesh_path;
if (!std::filesystem::exists(binPath))
continue; // navmesh 미배치 맵(씬 없는 샘플 맵)은 검증 대상이 아니다
NavMesh nav;
ASSERT_TRUE(nav.Load(binPath.c_str())) << "navmesh 로드 실패: " << binPath;
EXPECT_EQ(Map::ValidateMapDataOnNavMesh(mapData, &nav), 0)
<< "map " << id << " (" << mapData->name << ") 의 게이트/스폰 마커가 navmesh 밖에 있습니다.";
++validated;
}
EXPECT_GT(validated, 0) << "navmesh 가 배치된 맵이 하나도 없어 정합 검증이 수행되지 않았습니다.";
}