// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. package util import ( "testing" ) func testEscapeAssertion(t *testing.T, s string, res string) { t.Helper() myRes := EscapeAssertion(s) t.Logf("%s: %s", s, myRes) if myRes != res { t.Errorf("%s: %s, supposed to be %s", s, myRes, res) } } func TestEscapeAssertion(t *testing.T) { testEscapeAssertion(t, "r_sub == r_obj.value", "r_sub == r_obj.value") testEscapeAssertion(t, "p_sub == r_sub.value", "p_sub == r_sub.value") testEscapeAssertion(t, "r.attr.value == p.attr", "r_attr.value == p_attr") testEscapeAssertion(t, "r.attr.value == p.attr", "r_attr.value == p_attr") testEscapeAssertion(t, "r.attp.value || p.attr", "r_attp.value || p_attr") testEscapeAssertion(t, "r2.attr.value == p2.attr", "r2_attr.value == p2_attr") testEscapeAssertion(t, "r2.attp.value || p2.attr", "r2_attp.value || p2_attr") testEscapeAssertion(t, "r.attp.value &&p.attr", "r_attp.value &&p_attr") testEscapeAssertion(t, "r.attp.value >p.attr", "r_attp.value >p_attr") testEscapeAssertion(t, "r.attp.value