AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
CascadeProcSuppressionTest.cpp File Reference

Unit tests for cascade proc suppression via SPELL_ATTR3_INSTANT_TARGET_PROCS. More...

#include "ProcChanceTestHelper.h"
#include "SpellInfoTestHelper.h"
#include "gtest/gtest.h"

Go to the source code of this file.

Classes

class  CascadeProcSuppressionTest
 
struct  RealSpellTestCase
 
class  CascadeProcRealSpellTest
 

Functions

 TEST_F (CascadeProcSuppressionTest, NormalSpellNormalAura_NotSuppressed)
 
 TEST_F (CascadeProcSuppressionTest, ProcDisabledSpell_NormalAura_Suppressed)
 
 TEST_F (CascadeProcSuppressionTest, ProcDisabledSpell_WithAttr_Suppressed)
 
 TEST_F (CascadeProcSuppressionTest, NormalSpell_AuraWithAttr_Suppressed)
 
 TEST_F (CascadeProcSuppressionTest, SpellInfo_WithAttr_HasAttributeReturnsTrue)
 
 TEST_F (CascadeProcSuppressionTest, SpellInfo_WithoutAttr_HasAttributeReturnsFalse)
 
 TEST_F (CascadeProcSuppressionTest, SpellInfo_WithMixedBits_HasAttributeReturnsTrue)
 
 TEST_P (CascadeProcRealSpellTest, VerifySuppressionForRealSpell)
 
 INSTANTIATE_TEST_SUITE_P (CascadeProcSuppression, CascadeProcRealSpellTest, ::testing::Values(RealSpellTestCase{"Seal Fate", 14195, true}, RealSpellTestCase{"Sword Specialization", 12281, true}, RealSpellTestCase{"Reckoning", 20178, true}, RealSpellTestCase{"Flurry", 16257, true}, RealSpellTestCase{"Eviscerate", 26865, false}), [](testing::TestParamInfo< RealSpellTestCase > const &info) { std::string name=info.param.name;std::replace(name.begin(), name.end(), ' ', '_');return name;})
 
 TEST_F (CascadeProcSuppressionTest, BothFlagsSet_StillSuppressed)
 
 TEST_F (CascadeProcSuppressionTest, OnlyOuterFlag_Suppressed)
 
 TEST_F (CascadeProcSuppressionTest, OnlyPerAuraFlag_Suppressed)
 

Detailed Description

Unit tests for cascade proc suppression via SPELL_ATTR3_INSTANT_TARGET_PROCS.

Tests the logic from Unit.cpp TriggerAurasProcOnEvent:

  • Outer check: Spell::IsProcDisabled() (TRIGGERED_DISALLOW_PROC_EVENTS) suppresses all cascade procs
  • Per-aura check: SPELL_ATTR3_INSTANT_TARGET_PROCS (0x80000) suppresses cascade for that aura
  • Normal spells/auras without these flags allow cascading
  • Both flags set simultaneously still suppresses correctly

Definition in file CascadeProcSuppressionTest.cpp.

Function Documentation

◆ INSTANTIATE_TEST_SUITE_P()

INSTANTIATE_TEST_SUITE_P ( CascadeProcSuppression  ,
CascadeProcRealSpellTest  ,
::testing::Values(RealSpellTestCase{"Seal Fate", 14195, true}, RealSpellTestCase{"Sword Specialization", 12281, true}, RealSpellTestCase{"Reckoning", 20178, true}, RealSpellTestCase{"Flurry", 16257, true}, RealSpellTestCase{"Eviscerate", 26865, false})  ,
[] (testing::TestParamInfo< RealSpellTestCase > const &info) { std::string name=info.param.name;std::replace(name.begin(), name.end(), ' ', '_');return name;}   
)

◆ TEST_F() [1/10]

TEST_F ( CascadeProcSuppressionTest  ,
BothFlagsSet_StillSuppressed   
)
192{
193 auto config = MakeConfig(true, true);
194
196 << "Both IsProcDisabled and INSTANT_TARGET_PROCS set should still suppress";
197}
static bool ShouldSuppressCascadingProc(CascadeProcConfig const &config)
Returns true if cascading procs should be suppressed for this aura.
Definition ProcChanceTestHelper.h:518

References ProcChanceTestHelper::ShouldSuppressCascadingProc().

◆ TEST_F() [2/10]

TEST_F ( CascadeProcSuppressionTest  ,
NormalSpell_AuraWithAttr_Suppressed   
)
85{
86 auto config = MakeConfig(false, true);
87
89 << "Aura with SPELL_ATTR3_INSTANT_TARGET_PROCS should suppress cascading procs";
90}

References ProcChanceTestHelper::ShouldSuppressCascadingProc().

◆ TEST_F() [3/10]

TEST_F ( CascadeProcSuppressionTest  ,
NormalSpellNormalAura_NotSuppressed   
)
53{
54 auto config = MakeConfig(false, false);
55
57 << "Normal spell + normal aura should not suppress cascading procs";
58}

References ProcChanceTestHelper::ShouldSuppressCascadingProc().

◆ TEST_F() [4/10]

TEST_F ( CascadeProcSuppressionTest  ,
OnlyOuterFlag_Suppressed   
)
200{
201 auto config = MakeConfig(true, false);
202
204 << "Only IsProcDisabled should be sufficient to suppress";
205}

References ProcChanceTestHelper::ShouldSuppressCascadingProc().

◆ TEST_F() [5/10]

TEST_F ( CascadeProcSuppressionTest  ,
OnlyPerAuraFlag_Suppressed   
)
208{
209 auto config = MakeConfig(false, true);
210
212 << "Only INSTANT_TARGET_PROCS should be sufficient to suppress";
213}

References ProcChanceTestHelper::ShouldSuppressCascadingProc().

◆ TEST_F() [6/10]

TEST_F ( CascadeProcSuppressionTest  ,
ProcDisabledSpell_NormalAura_Suppressed   
)
65{
66 auto config = MakeConfig(true, false);
67
69 << "Triggered spell with DISALLOW_PROC_EVENTS should suppress all cascading procs";
70}

References ProcChanceTestHelper::ShouldSuppressCascadingProc().

◆ TEST_F() [7/10]

TEST_F ( CascadeProcSuppressionTest  ,
ProcDisabledSpell_WithAttr_Suppressed   
)
73{
74 auto config = MakeConfig(true, true);
75
77 << "Both flags set should still suppress (double-suppress doesn't break)";
78}

References ProcChanceTestHelper::ShouldSuppressCascadingProc().

◆ TEST_F() [8/10]

TEST_F ( CascadeProcSuppressionTest  ,
SpellInfo_WithAttr_HasAttributeReturnsTrue   
)
97{
98 auto spellInfo = SpellInfoBuilder()
99 .WithId(99001)
101 .BuildUnique();
102
103 EXPECT_TRUE(spellInfo->HasAttribute(SPELL_ATTR3_INSTANT_TARGET_PROCS))
104 << "SpellInfo built with 0x80000 should report HasAttribute true";
105}
@ SPELL_ATTR3_INSTANT_TARGET_PROCS
Definition SharedDefines.h:500
Builder class for creating SpellInfo test instances.
Definition SpellInfoTestHelper.h:160
SpellInfoBuilder & WithId(uint32 id)
Definition SpellInfoTestHelper.h:164
std::unique_ptr< SpellInfo > BuildUnique()
Definition SpellInfoTestHelper.h:256
SpellInfoBuilder & WithAttributesEx3(uint32 attr)
Definition SpellInfoTestHelper.h:212

References SpellInfoBuilder::BuildUnique(), SPELL_ATTR3_INSTANT_TARGET_PROCS, SpellInfoBuilder::WithAttributesEx3(), and SpellInfoBuilder::WithId().

◆ TEST_F() [9/10]

TEST_F ( CascadeProcSuppressionTest  ,
SpellInfo_WithMixedBits_HasAttributeReturnsTrue   
)
119{
120 // 0x80001 = SPELL_ATTR3_INSTANT_TARGET_PROCS | SPELL_ATTR3_PVP_ENABLING (bit 0)
121 auto spellInfo = SpellInfoBuilder()
122 .WithId(99003)
123 .WithAttributesEx3(0x00080001)
124 .BuildUnique();
125
126 EXPECT_TRUE(spellInfo->HasAttribute(SPELL_ATTR3_INSTANT_TARGET_PROCS))
127 << "Other bits in AttributesEx3 should not interfere with attribute detection";
128}

References SpellInfoBuilder::BuildUnique(), SPELL_ATTR3_INSTANT_TARGET_PROCS, SpellInfoBuilder::WithAttributesEx3(), and SpellInfoBuilder::WithId().

◆ TEST_F() [10/10]

TEST_F ( CascadeProcSuppressionTest  ,
SpellInfo_WithoutAttr_HasAttributeReturnsFalse   
)
108{
109 auto spellInfo = SpellInfoBuilder()
110 .WithId(99002)
112 .BuildUnique();
113
114 EXPECT_FALSE(spellInfo->HasAttribute(SPELL_ATTR3_INSTANT_TARGET_PROCS))
115 << "SpellInfo built with 0 should report HasAttribute false";
116}

References SpellInfoBuilder::BuildUnique(), SPELL_ATTR3_INSTANT_TARGET_PROCS, SpellInfoBuilder::WithAttributesEx3(), and SpellInfoBuilder::WithId().

◆ TEST_P()

TEST_P ( CascadeProcRealSpellTest  ,
VerifySuppressionForRealSpell   
)
145{
146 auto const& tc = GetParam();
147
148 // Build a SpellInfo mimicking the real spell's AttributesEx3
149 auto spellInfo = SpellInfoBuilder()
150 .WithId(tc.spellId)
152 .BuildUnique();
153
154 // Verify attribute detection matches expectation
155 EXPECT_EQ(spellInfo->HasAttribute(SPELL_ATTR3_INSTANT_TARGET_PROCS), tc.hasAttr)
156 << tc.name << " (spell " << tc.spellId << ") attribute detection mismatch";
157
158 // Verify cascade suppression matches attribute presence
160 config.triggeringSpellIsProcDisabled = false;
161 config.auraHasDisableProcAttr = tc.hasAttr;
162
163 EXPECT_EQ(ProcChanceTestHelper::ShouldSuppressCascadingProc(config), tc.hasAttr)
164 << tc.name << " (spell " << tc.spellId << ") cascade suppression mismatch";
165}
Configuration for simulating cascade proc suppression.
Definition ProcChanceTestHelper.h:507
bool triggeringSpellIsProcDisabled
Definition ProcChanceTestHelper.h:508
bool auraHasDisableProcAttr
Definition ProcChanceTestHelper.h:509

References ProcChanceTestHelper::CascadeProcConfig::auraHasDisableProcAttr, ProcChanceTestHelper::ShouldSuppressCascadingProc(), SPELL_ATTR3_INSTANT_TARGET_PROCS, ProcChanceTestHelper::CascadeProcConfig::triggeringSpellIsProcDisabled, SpellInfoBuilder::WithAttributesEx3(), and SpellInfoBuilder::WithId().