BUG#: 3586
authors.kodali <s.kodali>
Fri, 21 Nov 2008 05:20:57 +0000 (05:20 +0000)
committers.kodali <s.kodali>
Fri, 21 Nov 2008 05:20:57 +0000 (05:20 +0000)
TITLE: CQLRegularExpression::match() method should change

src/Pegasus/CQL/CQLRegularExpression.cpp
src/Pegasus/CQL/CQLRegularExpression.h
src/Pegasus/CQL/CQLValueRep.cpp
src/Pegasus/CQL/tests/RegularExpression/RegularExpression.cpp

index 670ee954d7ca4b512de526545b9c93474f19648e..2442ad0a5c5e0ac7952b380050340b73b6f5a5db 100644 (file)
@@ -37,7 +37,8 @@
 
 PEGASUS_NAMESPACE_BEGIN
 
-CQLRegularExpression::CQLRegularExpression()
+CQLRegularExpression::CQLRegularExpression(const String& pattern):
+    pattern(pattern) 
 {
 }
 
@@ -46,8 +47,8 @@ CQLRegularExpression::~CQLRegularExpression()
 }
 
 
-Boolean CQLRegularExpression::match(const String& string,
-                                    const String& pattern)
+Boolean CQLRegularExpression::match(const String& string)
+                                    
 {
     Uint32 patIndex = 0;
     Uint32 strIndex = 0;
index cac52286ee8456caef2f0c8f6f6ab967f240cd91..f274434054405b7d562803994197d00a4262d921 100644 (file)
 //
 //==============================================================================
 //
-// Author: Dan Gorey (djgorey@us.ibm.com)
-//
-// Modified By: David Dillard, VERITAS Software Corp.
-//                  (david.dillard@veritas.com)
-//
 //%/////////////////////////////////////////////////////////////////////////////
 #ifndef Pegasus_CQLRegularExpression_h
 #define Pegasus_CQLRegularExpression_h
 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
 
 #include <Pegasus/CQL/Linkage.h>
+#include <Pegasus/Common/String.h>
 
 PEGASUS_NAMESPACE_BEGIN
 
-class String;
-
 class PEGASUS_CQL_LINKAGE CQLRegularExpression
 {
 public:
-    CQLRegularExpression();
+    CQLRegularExpression(const String& pattern);
     ~CQLRegularExpression();
 
-    Boolean match(const String& string, const String& pattern);
+    Boolean match(const String& string);
 
 private:
+    String pattern;
 
 };
 
index 35671dcd79e56f92ae5174b60f5a3a677d4b6cee..a864bc47f9223c760a92da47b891ef3283414438 100755 (executable)
@@ -936,10 +936,10 @@ Boolean CQLValueRep::like(const CQLValueRep& inVal)
    String rightside;
    inVal._theValue.get(rightside);
    
-   CQLRegularExpression re;
+   CQLRegularExpression re(rightside);
 
    PEG_METHOD_EXIT();
-   return re.match(leftside,rightside);
+   return re.match(leftside);
 
 }
 
index fac2d8f1363d4477eff7917e689e784f4f8bda8e..6057b3ead915e5bb51b7ffe9e53520b49680f743 100755 (executable)
 //
 //==============================================================================
 //
-// Authors: Dan Gorey (djgorey@us.ibm.com)
-//
-// Modified By:
-//
 //%/////////////////////////////////////////////////////////////////////////////
 
 #include <Pegasus/Common/PegasusAssert.h>
@@ -47,36 +43,33 @@ PEGASUS_USING_STD;
 void test01()
 {
     //result should return false
-    CQLRegularExpression re;
-
     const String p = "abc";
     const String s = ""; 
+    CQLRegularExpression re(p);
     
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == false);
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == false);
     return;
 }
 
 void test02()
 {
     //result should return false
-    CQLRegularExpression re;
-
     const String p = "";
     const String s = "abc"; 
-    
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == false);
+    CQLRegularExpression re(p);
+
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == false);
     return;
 }
 
 void test03()
 {
     //result should return true
-    CQLRegularExpression re;
-
     const String p = "abc";
     const String s = "abc"; 
-    
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == true);
+    CQLRegularExpression re(p);
+
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == true);
     return;
 }
 
@@ -84,189 +77,175 @@ void test03()
 void test04()
 {
     //result should return false
-    CQLRegularExpression re;
-
     const String p = "abcd";
     const String s = "abc"; 
+    CQLRegularExpression re(p);
     
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == false);
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == false);
     return;
 }
 
 void test05()
 {
     //result should return false
-    CQLRegularExpression re;
-
     const String p = "abc";
     const String s = "abcd"; 
+    CQLRegularExpression re(p);
     
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == false);
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == false);
     return;
 }
 
 void test06()
 {
     //result should return true
-    CQLRegularExpression re;
-
     const String p = "ab.";
     const String s = "ab?"; 
-    
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == true);
+    CQLRegularExpression re(p);
+
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == true);
     return;
 }
 
 void test07()
 {
     //result should return true
-    CQLRegularExpression re;
-                      
     const String p = ".a.b";
     const String s = "aa!b"; 
-    
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == true);
+    CQLRegularExpression re(p);
+
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == true);
     return;
 }
 
 void test08()
 {
     //result should return true
-    CQLRegularExpression re;
-
     const String p = "\\.ab";
     const String s = ".ab"; 
-    
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == true);
+    CQLRegularExpression re(p);
+
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == true);
     return;
 }
 
 void test09()
 {
     //result should return false
-    CQLRegularExpression re;
-
     const String p = "\\.ab";
     const String s = "\\.ab"; 
-    
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == false);
+    CQLRegularExpression re(p);
+
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == false);
     return;
 }
 
 void test10()
 {
     //result should return true
-    CQLRegularExpression re;
-
     const String p = ".*";
     const String s = "abcd"; 
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == true);
+    CQLRegularExpression re(p);
+
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == true);
     return;
 }
 
 void test11()
 {
     //result should return true
-    CQLRegularExpression re;
-
     const String p = "\\.*";
     const String s = "......"; 
-    
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == true);
+    CQLRegularExpression re(p);
+
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == true);
     return;
 }
 
 void test12()
 {
     //result should return true
-    CQLRegularExpression re;
-
     const String p = "abcd*";
     const String s = "abcddddd"; 
-    
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == true);
+    CQLRegularExpression re(p);
+
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == true);
     return;
 }
 
 void test13()
 {
     //result should return false
-    CQLRegularExpression re;
-
     const String p = "abcd*";
     const String s = "abcd"; 
-    
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == false);
+    CQLRegularExpression re(p);
+
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == false);
     return;
 }
 
 void test14()
 {
     //result should return true
-    CQLRegularExpression re;
-
     const String p = "ab*cd";
     const String s = "abbbbcd"; 
+    CQLRegularExpression re(p);
     
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == true);
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == true);
     return;
 }
 
 void test15()
 {
     //result should return true
-    CQLRegularExpression re;
-                      
     const String p = "ab.*cd";
     const String s = "ab123!cd"; 
-    
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == true);
+    CQLRegularExpression re(p);
+
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == true);
     return;
 }
 
 void test16()
 {
     //result should return true
-    CQLRegularExpression re;
-
     const String p = "\\*ab";
     const String s = "*ab"; 
-    
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == true);
+    CQLRegularExpression re(p);
+
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == true);
     return;
 }
 
 void test17()
 {
     //result should return false
-    CQLRegularExpression re;
-
     const String p = ".\\*";
     const String s = "****"; 
-    
-    PEGASUS_TEST_ASSERT ( (re.match(s, p)) == false);
+    CQLRegularExpression re(p);
+
+    PEGASUS_TEST_ASSERT ( (re.match(s)) == false);
     return;
 }
 
 void test18()
 {
     //result should return true
-    CQLRegularExpression re;
     Char16 utf16Chars[] =
         {
         0xD800,0x78BC, 0xDC01, 0x45A3,
         0x00};
 
     const String utf(utf16Chars);
+    CQLRegularExpression re(utf);
 
-    PEGASUS_TEST_ASSERT ( (re.match(utf, utf)) == true);
+    PEGASUS_TEST_ASSERT ( (re.match(utf)) == true);
     return;
 }
 
 void test19()
 {
     //result should return true
-    CQLRegularExpression re;
     Char16 utf16CharsP[] =
         {
         0xD800,0x78BC, 
@@ -280,16 +259,15 @@ void test19()
     0x00};
 
     const String utfString(utf16CharsS);
+    CQLRegularExpression re(utfPattern);
 
-
-    PEGASUS_TEST_ASSERT ( (re.match(utfString, utfPattern)) == true);
+    PEGASUS_TEST_ASSERT ( (re.match(utfString)) == true);
     return;
 }
 
 void test20()
 {
     //result should return true
-    CQLRegularExpression re;
     const String pattern = ".*";
 
     Char16 utf16CharsS[] =
@@ -298,16 +276,15 @@ void test20()
 
     String utfString(utf16CharsS);
     utfString.append("*");
+    CQLRegularExpression re(pattern);
 
-
-    PEGASUS_TEST_ASSERT ( (re.match(utfString,pattern)) == true);
+    PEGASUS_TEST_ASSERT ( (re.match(utfString)) == true);
     return;
 }
 
 void test21()
 {
     //result should return true
-    CQLRegularExpression re;
     Char16 utf16CharsP[] =
         {
         0xD800,0x78BC, 
@@ -322,9 +299,9 @@ void test21()
 
     String utfString(utf16CharsS);
     utfString.append("an3s");
+    CQLRegularExpression re(utfPattern);
 
-
-    PEGASUS_TEST_ASSERT ( (re.match(utfString, utfPattern)) == true);
+    PEGASUS_TEST_ASSERT ( (re.match(utfString)) == true);
     return;
 }