// ==========================================================
// AutoPOE2 - Master Unit Test Runner
// Modularized 5-Domain Architecture (2026 Industrial Standards)
// ==========================================================

#include "test_harness.hpp"
#include <iostream>

int g_failures = 0;
int g_checks = 0;

int main() {
    std::cout << "=================================================" << std::endl;
    std::cout << "   AutoPOE2 Core Engine - Unit Tests             " << std::endl;
    std::cout << "=================================================" << std::endl;

    // Domain 1: Protocol & IPC (15 tests)
    TestProtocolLayout();
    TestTelemetrySeqlock();
    TestTelemetryStress();
    TestCommandRing();
    TestCommandRingConcurrency();
    TestWatchdog();
    TestLogSensor();
    TestLogSensorReplayLatestZone();
    TestLogSensorPreferClientTxt();
    TestKMBoxSmoothEngine();
    TestWatchdogPassiveCoPilotDegrade();
    TestWatcherInvariantContract();
    TestCliFlagsAndConfigInvariants();
    TestCommonKernelLibraries();
    TestKmboxBidirectionalAndKitingLock();
    TestWindowUtilsWin32Helpers();
    TestIpcCommandDirectivesAndProfileSwitching();

    // Domain 2: Memory & Engine (28 tests)
    TestAobScanner();
    TestOffsetsStore();
    TestRpmSelfProcess();
    TestSimulatedEntityManager();
    TestPlayerFinder();
    TestXYZSanityAndFiltering();
    TestAutoPositionScan();
    TestAutoDetectManaPool();
    TestTerrainReader();
    TestChunkBoundaryOverlapRegression();
    TestCrossVitalValidationAndStaleOffsetRegression();
    TestXYZ2DPlanarMovementRegression();
    TestVitalsStructuralRejection();
    TestVitalsScoringAndDynamicAdaptation();
    TestChaosInoculationCiBuild();
    TestRealtimeCharacterStateAndLogSensors();
    TestAuthenticPid36104CiEsWardAndXYZAutolock();
    TestCIVitalsHighESAndWardRejection();
    TestPointerChainResolver();
    TestSha256NistVectorsAndPeFingerprint();
    TestClientBuildShiftAndOffsetRegistryGate();
    TestRegistryLiveLabel();
    TestVitalsFingerprintCiHud();
    TestVitalsFingerprintRegionEdge();
    TestAuthenticPid36104LifeDumpNoInlineMana();
    TestScanCurMaxPairFindsDetachedManaSpirit();
    TestDynamicXyzAutolockAndStaticAnchorRejection();
    TestWardManaDisambiguationAndNoFalseLock();

    // Domain 3: Combat & Reflex (14 tests)
    TestHumanCurve();
    TestReflexManager();
    TestComboManager();
    TestKitingEngine();
    TestMonkCombatCombo();
    TestRangedCombatAndKiting();
    TestPostDeathRespawnAndArenaTransition();
    TestCIChargedStaffRotationAndSurvival();
    TestSkillsTomlAndUnstuckHandlerInvariants();
    TestFlexibleSkillEngineAndCrossInteractions();
    TestAutoRespawnCoordinatesInvariants();
    TestBossRageFlaskAndUniqueFlaskInvariants();
    TestActuatorNonBlockingAndZeroHeap();
    TestBossTelegraphEvasionAndBurstRotation();
    TestMicroStutterSteppingAndAutoTargeting();
    TestBossInvulnerabilityAndPhaseController();
    TestPredictiveAimController();
    TestQuinticBezierAndHumanizedMouse();
    TestSeqlockBreachDeliriumStressAndLatency();
    TestTelegraphEvasionArbiter();
    TestMonsterPackClusteringAndContinuousClearing();
    TestCharacterFsmMapClearLegitimacyV2();
    TestHumanizedInputArbiterAndJerkMinimization();

    // Domain 4: Navigation & Spatial (10 tests)
    TestTerrainGridAndLineOfSight();
    TestPathfinderAStar();
    TestIsometricProjectionInvariants();
    TestEndgameMapScenariosAndBossRush();
    TestJumpPointSearchPathfinder();
    TestExplorationHeatmapAndFrontier();
    TestScenarioFastClearAndAtlasRush();
    TestWorldToWasdIsometricInvariants();
    TestQuestNavigatorColdStartProbingAndInventoryInvariants();
    TestTangentSlideAndObstacleAvoidanceInvariants();

    // Domain 5: Brain & FSM (14 tests)
    TestLootController();
    TestQuestNavigator();
    TestAutoLogin();
    TestTownQuestEngine();
    TestBotBrainArbiterInvariants();
    TestAreaEventMemoryAndTaxonomyInvariants();
    TestPickitFilterAndHiddenItemRejectionInvariants();
    TestInventoryHandlerFsmAndTownOnlyInvariants();
    TestMapDeviceHandlerAndClosedLoopInvariants();
    TestNpcRecognitionAndDialogueInvariants();
    TestMapDevicePreciseTargetingAndClosedLoop();
    TestAtlasNodeSelectorAndMapDeviceFsm();
    TestMapDeviceDynamicZoomAnd3DProjectionInvariants();
    TestCharacterFSMAndHideoutAutonomousLoopInvariants();
    TestAutonomyGapResolution();
    TestBrainConflictGatekeeperAndPortalRetry();
    TestCoreCoordinatorAndZoneClassifierUpgrade();
    TestDualModeNavigationAndAbstractComboEngine();
    TestMapDeviceUiVerificationAndPrecisionTargeting();
    TestExiledBotSmoothMovementAndPriorities();

    // Division 2 Upgrades: Perception, NavMesh Bitset & SIMD Scanner (Tests 98, 99, 100)
    TestNavMeshBitsetFusion();
    TestSimdSignatureScanner();
    TestLootDensityClustering();

    std::cout << "=================================================" << std::endl;
    if (g_failures == 0) {
        std::cout << "[RESULT] TẤT CẢ " << g_checks << " KIỂM TRA ĐỀU ĐẠT (PASS)" << std::endl;
        return 0;
    }
    std::cout << "[RESULT] " << g_failures << "/" << g_checks << " KIỂM TRA THẤT BẠI" << std::endl;
    return 1;
}
