package processor import ( "os" "strings" "testing" "cook/utils" ) func TestRealAfflictionsXML(t *testing.T) { // Read the real Afflictions.xml file content, err := os.ReadFile("../testfiles/Afflictions.xml") if err != nil { t.Fatalf("Failed to read Afflictions.xml: %v", err) } original := string(content) // Test 1: Double all maxstrength values using helper functions command := utils.ModifyCommand{ Name: "double_maxstrength", Lua: ` -- Double all maxstrength attributes in Affliction elements local afflictions = findElements(root, "Affliction") for _, affliction in ipairs(afflictions) do modifyNumAttr(affliction, "maxstrength", function(val) return val * 2 end) end modified = true `, } commands, err := ProcessXML(original, command, "Afflictions.xml") if err != nil { t.Fatalf("ProcessXML failed: %v", err) } if len(commands) == 0 { t.Fatal("Expected modifications but got none") } t.Logf("Generated %d surgical modifications", len(commands)) // Apply modifications result, count := utils.ExecuteModifications(commands, original) t.Logf("Applied %d modifications", count) // Verify specific changes if !strings.Contains(result, `maxstrength="20"`) { t.Errorf("Expected to find maxstrength=\"20\" (doubled from 10)") } if !strings.Contains(result, `maxstrength="480"`) { t.Errorf("Expected to find maxstrength=\"480\" (doubled from 240)") } if !strings.Contains(result, `maxstrength="12"`) { t.Errorf("Expected to find maxstrength=\"12\" (doubled from 6)") } // Verify formatting preserved (XML declaration should be there) if !strings.Contains(result, `