feat: parse content text (base case).

This commit is contained in:
mattia
2025-02-16 18:26:28 +01:00
parent b7aae9a04f
commit d386c50499
32 changed files with 940 additions and 6 deletions

View File

@@ -0,0 +1,34 @@
using InkBlot.ParseHierarchy;
using Shouldly;
namespace InkBlot.Tests;
public class ContentTextTest
{
[Theory]
[InlineData("Hello!", "Hello!", 0)]
[InlineData("Hel-lo!", "Hel-lo!", 0)]
[InlineData("Hel\\lo!", "Hello!", 0)]
[InlineData("Hel<lo!", "Hel<lo!", 0)]
// TODO: check error situations better when diverts (->), threads (<-) and tags (#) are supported
[InlineData("Hel->lo!", "", 1)]
[InlineData("Hel<-lo!", "", 1)]
[InlineData("Hel#lo!", "", 1)]
public void TestBaseContentSuccess(string inkInput, string result, int numErrors)
{
// parse the story
var fileReader = new PreMadeFileReader([
("main.ink", inkInput)
]);
var parser = new InkBlotParser();
var (story, diagnostics) = parser.Parse(fileReader, "main.ink");
// check the diagnostic counts match
diagnostics.Count().ShouldBe(numErrors);
// check the contents match (only if there was no diagnostic)
if (numErrors != 0) return;
var contents = story.StoryNodes.ToArray();
contents.ShouldBe([new Content(result)]);
}
}