10d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin// Copyright 2008 The RE2 Authors. All Rights Reserved. 20d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin// Use of this source code is governed by a BSD-style 30d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin// license that can be found in the LICENSE file. 40d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin 50d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin// Exhaustive testing of regular expression matching. 60d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin 70d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin#include "util/test.h" 80d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin#include "re2/testing/exhaustive_tester.h" 90d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin 100d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkinnamespace re2 { 110d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin 120d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander GutkinDECLARE_string(regexp_engines); 130d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin 140d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin// Test very simple expressions. 150d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander GutkinTEST(EgrepLiterals, Lowercase) { 160d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin EgrepTest(3, 2, "abc.", 3, "abc", ""); 170d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin} 180d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin 190d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin// Test mixed-case expressions. 200d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander GutkinTEST(EgrepLiterals, MixedCase) { 210d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin EgrepTest(3, 2, "AaBb.", 2, "AaBb", ""); 220d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin} 230d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin 240d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin// Test mixed-case in case-insensitive mode. 250d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander GutkinTEST(EgrepLiterals, FoldCase) { 260d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin // The punctuation characters surround A-Z and a-z 270d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin // in the ASCII table. This looks for bugs in the 280d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin // bytemap range code in the DFA. 290d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin EgrepTest(3, 2, "abAB.", 2, "aBc@_~", "(?i:%s)"); 300d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin} 310d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin 320d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin// Test very simple expressions. 330d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander GutkinTEST(EgrepLiterals, UTF8) { 340d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin EgrepTest(3, 2, "ab.", 4, "a\xE2\x98\xBA", ""); 350d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin} 360d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin 370d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin} // namespace re2 380d4c52358a1af421705c54bd8a9fdd8a30558a2eAlexander Gutkin 39