Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ltrzesniewski committed May 10, 2024
1 parent 092440e commit fb578eb
Showing 1 changed file with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,40 @@ enum Counter
]);
}

[Test]
public void should_handle_discard_as_first_enum_value()
{
var msg = ParseValid(
"""
enum Counter
{
_,
One
}
"""
);

var enumDef = msg.Enums.ExpectedSingle();
enumDef.Members.Select(m => m.InferredValueAsString).ShouldEqual(["1"]);
}

[Test]
public void should_handle_explicit_first_enum_value()
{
var msg = ParseValid(
"""
enum Counter
{
One = 1,
Two
}
"""
);

var enumDef = msg.Enums.ExpectedSingle();
enumDef.Members.Select(m => m.InferredValueAsString).ShouldEqual(["1", "2"]);
}

[Test]
public void should_handle_double_angled_brackets()
{
Expand Down Expand Up @@ -956,7 +990,7 @@ private static ParsedContracts Parse([LanguageInjection("csharp")] string defini
Console.WriteLine($"MESSAGE: {message}({string.Join(", ", message.Parameters.Select(p => $"[{p.Tag}] {p}"))})");

foreach (var member in contracts.Enums)
Console.WriteLine($"ENUM: {member}");
Console.WriteLine($"ENUM: {member} {{ {string.Join(", ", member.Members.Select(m => $"{m.Name} = {m.InferredValueAsNumber ?? m.InferredValueAsString ?? "(unknown)"}"))} }}");

return contracts;
}
Expand Down

0 comments on commit fb578eb

Please sign in to comment.