diff options
| author | Kevin Laeufer | 2020-07-15 12:21:26 -0700 |
|---|---|---|
| committer | GitHub | 2020-07-15 19:21:26 +0000 |
| commit | 24be0ac3121e8f5d7b4bf8d6247e305ed0f0a656 (patch) | |
| tree | 9acbdf85c86985921a84fa329838062a78e71588 /src/test/scala/firrtlTests/ProtoBufSpec.scala | |
| parent | 005a3d1644742029e744a64c2d9c452969bc64ff (diff) | |
ir: store FileInfo string in escaped format (#1690)
This should speed up the common case
as the compiler never operates on the
unescaped string.
The new escape function also fixes a bug
where ']' was not escaped even though it
is the delimiting character for FileInfo.
In order to maintain backwards
compatibility for the ProtoBuf format,
this patch adds escape/unescape calls
when going from/to protobuf format.
For better performance we should consider
changing the protobuf format.
Diffstat (limited to 'src/test/scala/firrtlTests/ProtoBufSpec.scala')
| -rw-r--r-- | src/test/scala/firrtlTests/ProtoBufSpec.scala | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/ProtoBufSpec.scala b/src/test/scala/firrtlTests/ProtoBufSpec.scala index 14f94cb3..3a94ec3f 100644 --- a/src/test/scala/firrtlTests/ProtoBufSpec.scala +++ b/src/test/scala/firrtlTests/ProtoBufSpec.scala @@ -211,4 +211,19 @@ class ProtoBufSpec extends FirrtlFlatSpec { val expected = ir.ValidIf(ir.Reference("en"), ir.Reference("x"), UnknownType) FromProto.convert(ToProto.convert(vi).build) should equal (expected) } + + it should "appropriately escape and unescape FileInfo strings" in { + val pairs = Seq( + "test\\ntest" -> "test\ntest", + "test\\ttest" -> "test\ttest", + "test\\\\test" -> "test\\test", + "test\\]test" -> "test]test" + ) + + pairs.foreach { case (escaped, unescaped) => + val info = ir.FileInfo(escaped) + ToProto.convert(info).build().getText should equal (unescaped) + FromProto.convert(ToProto.convert(info).build) should equal (info) + } + } } |
