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() +}