exhaustive_test.cc revision 5821806d5e7f356e8fa4b058a389a808ea183019
18d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// Copyright 2008 The RE2 Authors. All Rights Reserved. 28d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// Use of this source code is governed by a BSD-style 38d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// license that can be found in the LICENSE file. 48d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 58d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// Exhaustive testing of regular expression matching. 6fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt 7fb79edc9df1f20461e90e478363d207348213d35Dmitry Shmidt#include "util/test.h" 88d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "re2/testing/exhaustive_tester.h" 98d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtnamespace re2 { 118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 128d520ff1dc2da35cdca849e982051b86468016d8Dmitry ShmidtDECLARE_string(regexp_engines); 138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// Test very simple expressions. 158d520ff1dc2da35cdca849e982051b86468016d8Dmitry ShmidtTEST(EgrepLiterals, Lowercase) { 168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt EgrepTest(3, 2, "abc.", 3, "abc", ""); 178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt} 188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// Test mixed-case expressions. 208d520ff1dc2da35cdca849e982051b86468016d8Dmitry ShmidtTEST(EgrepLiterals, MixedCase) { 218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt EgrepTest(3, 2, "AaBb.", 2, "AaBb", ""); 228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt} 238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// Test mixed-case in case-insensitive mode. 258d520ff1dc2da35cdca849e982051b86468016d8Dmitry ShmidtTEST(EgrepLiterals, FoldCase) { 268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt // The punctuation characters surround A-Z and a-z 278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt // in the ASCII table. This looks for bugs in the 288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt // bytemap range code in the DFA. 298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt EgrepTest(3, 2, "abAB.", 2, "aBc@_~", "(?i:%s)"); 308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt} 318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt// Test very simple expressions. 338d520ff1dc2da35cdca849e982051b86468016d8Dmitry ShmidtTEST(EgrepLiterals, UTF8) { 348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt EgrepTest(3, 2, "ab.", 4, "a\xE2\x98\xBA", ""); 358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt} 368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt} // namespace re2 388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt 398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt