Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras committed Feb 13, 2024
1 parent d0f384d commit 893cc25
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions Tests/Parser/Internal/ScriptBuilderContextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ class ScriptBuilderContextTests
"once((byte(0x001234) == 1 || byte(0x002345) == 2) && never(byte(0x004567) == 4))")]
[TestCase("N:0xH001234=1_M:0xH002345=2.100.",
"measured(repeated(100, byte(0x001234) == 1 && byte(0x002345) == 2))")]
[TestCase("N:0xH001234=1_M:0xH002345=2",
"measured(tally(0, byte(0x001234) == 1 && byte(0x002345) == 2))")]
[TestCase("O:0xH001234=1_M:0xH002345=2",
"measured(tally(0, byte(0x001234) == 1 || byte(0x002345) == 2))")]
public void TestAppendRequirements(string input, string expected)
{
var trigger = Trigger.Deserialize(input);
Expand All @@ -84,5 +80,30 @@ public void TestAppendRequirements(string input, string expected)
// make sure we didn't modify the source requirements
Assert.That(trigger.Serialize(), Is.EqualTo(input));
}

[TestCase("N:0xH001234=1_M:0xH002345=2",
"measured(tally(0, byte(0x001234) == 1 && byte(0x002345) == 2))")]
[TestCase("O:0xH001234=1_M:0xH002345=2",
"measured(tally(0, byte(0x001234) == 1 || byte(0x002345) == 2))")]
public void TestAppendRequirementsValue(string input, string expected)
{
var trigger = Trigger.Deserialize(input);
var groups = RequirementEx.Combine(trigger.Core.Requirements);
var context = new ScriptBuilderContext() { IsValue = true };

var builder = new StringBuilder();
foreach (var group in groups)
{
if (builder.Length > 0)
builder.Append('|');

context.AppendRequirements(builder, group.Requirements);
}

Assert.That(builder.ToString(), Is.EqualTo(expected));

// make sure we didn't modify the source requirements
Assert.That(trigger.Serialize(), Is.EqualTo(input));
}
}
}

0 comments on commit 893cc25

Please sign in to comment.