From 907b1380a712ea7c703e25462fa9817551a79781 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Tue, 1 Mar 2016 17:23:18 -0500 Subject: [PATCH] Add tests to specify the string escaping behavior --- promql/lex_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/promql/lex_test.go b/promql/lex_test.go index cb1642aec..57d1238e9 100644 --- a/promql/lex_test.go +++ b/promql/lex_test.go @@ -99,6 +99,26 @@ var tests = []struct { input: "0x123", expected: []item{{itemNumber, 0, "0x123"}}, }, + // Test strings. + { + input: "\"test\\tsecuence\"", + expected: []item{{itemString, 0, `"test\tsecuence"`}}, + }, + { + input: "\"test\\\\.expression\"", + expected: []item{{itemString, 0, `"test\\.expression"`}}, + }, + { + input: "\"test\\.expression\"", + expected: []item{ + {itemError, 0, "unknown escape sequence U+002E '.'"}, + {itemString, 0, `"test\.expression"`}, + }, + }, + { + input: "`test\\.expression`", + expected: []item{{itemString, 0, "`test\\.expression`"}}, + }, { // See https://github.com/prometheus/prometheus/issues/939. input: ".٩",