-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-union-value
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/Tests/FlatSharpCompilerTests/EscapedCharInAttributeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
namespace FlatSharpTests | ||
{ | ||
public class EscapedCharInAttributeTests | ||
{ | ||
[Fact] | ||
public void EscapedCharInAttribute_DoubleQuote() | ||
{ | ||
string schema = "namespace ns;attribute custom;table Foo { Bar : int (custom: \"hello,\\\"world\\\"\"); }"; | ||
|
||
var assembly = FlatSharpCompiler.CompileAndLoadAssembly(schema, new()); | ||
var foo = assembly.GetType("ns.Foo"); | ||
var bar = foo.GetProperty("Bar"); | ||
var metaAttr = bar.GetCustomAttribute<FlatBufferMetadataAttribute>(); | ||
Assert.NotNull(metaAttr.Value); | ||
Assert.Equal("hello,\"world\"", metaAttr.Value.ToString()); | ||
} | ||
|
||
[Fact] | ||
public void EscapedCharInAttribute_SingleQuote() | ||
{ | ||
string schema = "namespace ns;attribute custom;table Foo { Bar : int (custom: \"hello,'world'\"); }"; | ||
|
||
var assembly = FlatSharpCompiler.CompileAndLoadAssembly(schema, new()); | ||
var foo = assembly.GetType("ns.Foo"); | ||
var bar = foo.GetProperty("Bar"); | ||
var metaAttr = bar.GetCustomAttribute<FlatBufferMetadataAttribute>(); | ||
Assert.NotNull(metaAttr.Value); | ||
Assert.Equal("hello,'world'", metaAttr.Value.ToString()); | ||
} | ||
|
||
[Fact] | ||
public void EscapedCharInAttribute_BackSlash() | ||
{ | ||
string schema = "namespace ns;attribute custom;table Foo { Bar : int (custom: \"hello,\\\\world\"); }"; | ||
|
||
var assembly = FlatSharpCompiler.CompileAndLoadAssembly(schema, new()); | ||
var foo = assembly.GetType("ns.Foo"); | ||
var bar = foo.GetProperty("Bar"); | ||
var metaAttr = bar.GetCustomAttribute<FlatBufferMetadataAttribute>(); | ||
Assert.NotNull(metaAttr.Value); | ||
Assert.Equal("hello,\\world", metaAttr.Value.ToString()); | ||
} | ||
} | ||
} |