1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <gtest/gtest.h> 18 19 #include <sys/types.h> 20 #include <regex.h> 21 22 TEST(regex, smoke) { 23 // A quick test of all the regex functions. 24 regex_t re; 25 ASSERT_EQ(0, regcomp(&re, "ab*c", 0)); 26 ASSERT_EQ(0, regexec(&re, "abbbc", 0, NULL, 0)); 27 ASSERT_EQ(REG_NOMATCH, regexec(&re, "foo", 0, NULL, 0)); 28 29 char buf[80]; 30 regerror(REG_NOMATCH, &re, buf, sizeof(buf)); 31 #if __BIONIC__ 32 ASSERT_STREQ("regexec() failed to match", buf); 33 #else 34 ASSERT_STREQ("No match", buf); 35 #endif 36 37 regfree(&re); 38 } 39