Skip to content

Commit

Permalink
Fix StringValue.Create encode overload. (#750)
Browse files Browse the repository at this point in the history
Co-authored-by: Sébastien Ros <[email protected]>
  • Loading branch information
gumbarros and sebastienros authored Feb 1, 2025
1 parent bbc16a2 commit 023a49b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Fluid.Tests/StringValueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,17 @@ public void StringValueCreateNullShouldReturnEmpty()
// Assert
Assert.Equal(StringValue.Empty, stringValue);
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public void StringValue_Create_InitializesProperties(bool encode)
{
var stringValue = StringValue.Create("a", encode);

// Assert
Assert.Equal("a", stringValue.ToStringValue());
Assert.Equal(encode, stringValue.Encode);
}
}
}
4 changes: 2 additions & 2 deletions Fluid/Values/StringValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static StringValue Create(string s)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static StringValue Create(string s, bool encode)
{
return Create(s, encode);
return new StringValue(s, encode);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -93,7 +93,7 @@ public override bool Equals(FluidValue other)
return _value == other.ToStringValue();
}

// Delegating other types
// Delegating other types
if (other == BlankValue.Instance || other == NilValue.Instance || other == EmptyValue.Instance)
{
return other.Equals(this);
Expand Down

0 comments on commit 023a49b

Please sign in to comment.