From 75e562d0f040da7c96afa648326b00df23274606 Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Thu, 2 Jan 2025 11:57:42 +0100 Subject: [PATCH] C#: Add test using the new escape char for ESCAPE. --- csharp/ql/test/library-tests/strings/Strings.cs | 12 ++++++++++++ .../library-tests/strings/stringLiterals.expected | 4 ++++ .../ql/test/library-tests/strings/stringLiterals.ql | 5 +++++ 3 files changed, 21 insertions(+) create mode 100644 csharp/ql/test/library-tests/strings/Strings.cs create mode 100644 csharp/ql/test/library-tests/strings/stringLiterals.expected create mode 100644 csharp/ql/test/library-tests/strings/stringLiterals.ql diff --git a/csharp/ql/test/library-tests/strings/Strings.cs b/csharp/ql/test/library-tests/strings/Strings.cs new file mode 100644 index 000000000000..23cfc556a97b --- /dev/null +++ b/csharp/ql/test/library-tests/strings/Strings.cs @@ -0,0 +1,12 @@ +using System; + +public class TestClass +{ + public void M() + { + var x1 = "Hello world"; + var x2 = "\u001b"; + var x3 = "\x1b"; + var x4 = "\e"; + } +} diff --git a/csharp/ql/test/library-tests/strings/stringLiterals.expected b/csharp/ql/test/library-tests/strings/stringLiterals.expected new file mode 100644 index 000000000000..9481f7f1fa27 --- /dev/null +++ b/csharp/ql/test/library-tests/strings/stringLiterals.expected @@ -0,0 +1,4 @@ +| Strings.cs:7:18:7:30 | "Hello world" | Hello world | +| Strings.cs:8:18:8:25 | "\u001b" | \u001b | +| Strings.cs:9:18:9:23 | "\u001b" | \u001b | +| Strings.cs:10:18:10:21 | "\u001b" | \u001b | diff --git a/csharp/ql/test/library-tests/strings/stringLiterals.ql b/csharp/ql/test/library-tests/strings/stringLiterals.ql new file mode 100644 index 000000000000..9f074053272f --- /dev/null +++ b/csharp/ql/test/library-tests/strings/stringLiterals.ql @@ -0,0 +1,5 @@ +import csharp + +query predicate stringLiterals(StringLiteral lit, string value) { + lit.fromSource() and value = lit.getValue() +}