Update regression test
This commit is contained in:
@@ -2,6 +2,7 @@ package regression
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"modify/processor"
|
"modify/processor"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -83,64 +84,18 @@ func TestTalentsMechanicOutOfRange(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestIndexExplosions(t *testing.T) {
|
func TestIndexExplosions(t *testing.T) {
|
||||||
given := `<Talent identifier="quickfixer">
|
given, err := os.ReadFile("testfiles/OutpostItems.xml")
|
||||||
<Icon texture="Content/UI/TalentsIcons2.png" sheetindex="5,2" sheetelementsize="128,128"/>
|
if err != nil {
|
||||||
<Description tag="talentdescription.quickfixer">
|
t.Fatalf("Error reading file: %v", err)
|
||||||
<Replace tag="[amount]" value="20" color="gui.green"/>
|
}
|
||||||
<Replace tag="[duration]" value="10" color="gui.green"/>
|
|
||||||
</Description>
|
|
||||||
<Description tag="talentdescription.repairmechanicaldevicestwiceasfast"/>
|
|
||||||
<AbilityGroupEffect abilityeffecttype="None">
|
|
||||||
<Abilities>
|
|
||||||
<CharacterAbilityGiveStat stattype="MechanicalRepairSpeed" value="1"/>
|
|
||||||
</Abilities>
|
|
||||||
</AbilityGroupEffect>
|
|
||||||
<AbilityGroupEffect abilityeffecttype="OnRepairComplete">
|
|
||||||
<Conditions>
|
|
||||||
<AbilityConditionItem tags="fabricator,door,engine,oxygengenerator,pump,turretammosource,deconstructor,medicalfabricator,ductblock"/>
|
|
||||||
</Conditions>
|
|
||||||
<Abilities>
|
|
||||||
<CharacterAbilityApplyStatusEffects>
|
|
||||||
<StatusEffects>
|
|
||||||
<StatusEffect type="OnAbility" target="Character" disabledeltatime="true">
|
|
||||||
<Affliction identifier="quickfixer" amount="10.0"/>
|
|
||||||
</StatusEffect>
|
|
||||||
</StatusEffects>
|
|
||||||
</CharacterAbilityApplyStatusEffects>
|
|
||||||
</Abilities>
|
|
||||||
</AbilityGroupEffect>
|
|
||||||
</Talent>`
|
|
||||||
|
|
||||||
actual := `<Talent identifier="quickfixer">
|
expected, err := os.ReadFile("testfiles/OutpostItemsExpected.xml")
|
||||||
<Icon texture="Content/UI/TalentsIcons2.png" sheetindex="5,2" sheetelementsize="128,128"/>
|
if err != nil {
|
||||||
<Description tag="talentdescription.quickfixer">
|
t.Fatalf("Error reading file: %v", err)
|
||||||
<Replace tag="[amount]" value="30" color="gui.green"/>
|
}
|
||||||
<Replace tag="[duration]" value="20" color="gui.green"/>
|
|
||||||
</Description>
|
|
||||||
<Description tag="talentdescription.repairmechanicaldevicestwiceasfast"/>
|
|
||||||
<AbilityGroupEffect abilityeffecttype="None">
|
|
||||||
<Abilities>
|
|
||||||
<CharacterAbilityGiveStat stattype="MechanicalRepairSpeed" value="2"/>
|
|
||||||
</Abilities>
|
|
||||||
</AbilityGroupEffect>
|
|
||||||
<AbilityGroupEffect abilityeffecttype="OnRepairComplete">
|
|
||||||
<Conditions>
|
|
||||||
<AbilityConditionItem tags="fabricator,door,engine,oxygengenerator,pump,turretammosource,deconstructor,medicalfabricator,ductblock"/>
|
|
||||||
</Conditions>
|
|
||||||
<Abilities>
|
|
||||||
<CharacterAbilityApplyStatusEffects>
|
|
||||||
<StatusEffects>
|
|
||||||
<StatusEffect type="OnAbility" target="Character" disabledeltatime="true">
|
|
||||||
<Affliction identifier="quickfixer" amount="20"/>
|
|
||||||
</StatusEffect>
|
|
||||||
</StatusEffects>
|
|
||||||
</CharacterAbilityApplyStatusEffects>
|
|
||||||
</Abilities>
|
|
||||||
</AbilityGroupEffect>
|
|
||||||
</Talent>`
|
|
||||||
|
|
||||||
p := &processor.RegexProcessor{}
|
p := &processor.RegexProcessor{}
|
||||||
result, mods, matches, err := p.ProcessContent(given, `<Talent identifier="quickfixer">!anyvalue="(?<movementspeed>!num)"!anyvalue="(?<duration>!num)"!anyvalue="(?<repairspeed>!num)"!anyamount="(?<durationv>!num)"`, "movementspeed=round(movementspeed*1.5, 2) duration=round(duration*2, 2) repairspeed=round(repairspeed*2, 2) durationv=duration")
|
actual, mods, matches, err := p.ProcessContent(string(given), `LightComponent!anyrange="(!num)"`, "*4")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing content: %v", err)
|
t.Fatalf("Error processing content: %v", err)
|
||||||
@@ -154,7 +109,7 @@ func TestIndexExplosions(t *testing.T) {
|
|||||||
t.Errorf("Expected 1 modification, got %d", mods)
|
t.Errorf("Expected 1 modification, got %d", mods)
|
||||||
}
|
}
|
||||||
|
|
||||||
if result != actual {
|
if string(actual) != string(expected) {
|
||||||
t.Errorf("expected %s, got %s", actual, result)
|
t.Errorf("expected %s, got %s", expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1252
testfiles/OutpostItems.xml
Normal file
1252
testfiles/OutpostItems.xml
Normal file
File diff suppressed because it is too large
Load Diff
1252
testfiles/OutpostItemsExpected.xml
Normal file
1252
testfiles/OutpostItemsExpected.xml
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user