don't crash when looking for matches when some options are null

This commit is contained in:
haven1433
2023-01-21 21:57:16 -06:00
parent 7d1e6065d5
commit f305d7a7a6
2 changed files with 16 additions and 0 deletions

View File

@@ -183,6 +183,7 @@ namespace HavenSoft.HexManiac.Core {
}
public static bool MatchesPartial(this string full, string partial, bool onlyCheckLettersAndDigits = false) {
if (full == null) return false;
return MatchLength(full, partial, onlyCheckLettersAndDigits) == partial.Length;
}

View File

@@ -5,6 +5,7 @@ using HavenSoft.HexManiac.Core.Models.Runs;
using HavenSoft.HexManiac.Core.ViewModels.Tools;
using HavenSoft.HexManiac.Core.ViewModels.Visitors;
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
@@ -574,6 +575,20 @@ You said no!
Assert.Equal(2, Tool.Contents.Count);
}
[Fact]
public void AnimationScript_PlaySeWithPan_CanDecode() {
var animationpan = new List<string>(192.Range<string>(i => null));
animationpan[63] = "sound_pan_target";
ViewPort.Model.SetList(nameof(animationpan), animationpan);
ViewPort.Edit("19 00 00 00 ");
Tool.Mode = CodeMode.AnimationScript;
ViewPort.Goto.Execute(0);
var help = Tool.AnimationScriptParser.GetHelp(ViewPort.Model, new HelpContext("playsewithpan mus_dummy 0", 25));
Assert.NotNull(help);
}
// TODO test that we get an error (not an exception) if we do auto on an unformatted pointer
}
}