OmniSciDB  343343d194
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UtilTest.cpp File Reference
#include "../Utils/Regexp.h"
#include "../Utils/StringLike.h"
#include "TestHelpers.h"
#include <gtest/gtest.h>
+ Include dependency graph for UtilTest.cpp:

Go to the source code of this file.

Functions

 TEST (Utils, StringLike)
 
 TEST (Utils, Regexp)
 
int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 48 of file UtilTest.cpp.

References logger::ERROR, TestHelpers::init_logger_stderr_only(), and LOG.

48  {
50  ::testing::InitGoogleTest(&argc, argv);
51 
52  int err{0};
53  try {
54  err = RUN_ALL_TESTS();
55  } catch (const std::exception& e) {
56  LOG(ERROR) << e.what();
57  }
58  return err;
59 }
#define LOG(tag)
Definition: Logger.h:182
void init_logger_stderr_only(int argc, char const *const *argv)
Definition: TestHelpers.h:194

+ Here is the call graph for this function:

TEST ( Utils  ,
StringLike   
)

Definition at line 23 of file UtilTest.cpp.

References string_ilike(), and string_like().

23  {
24  ASSERT_TRUE(string_like("abc", 3, "abc", 3, '\\'));
25  ASSERT_FALSE(string_like("abc", 3, "ABC", 3, '\\'));
26  ASSERT_TRUE(string_ilike("Xyzabc", 6, "xyz%", 4, '\\'));
27  ASSERT_TRUE(string_like("abcxyzefg", 9, "%xyz%", 5, '\\'));
28  ASSERT_TRUE(string_like("abcxyzefgXYZhij", 15, "%xyz%XYZ%", 9, '\\'));
29  ASSERT_TRUE(string_like("abcxOzefgXpZhij", 15, "%x_z%X_Z%", 9, '\\'));
30  ASSERT_TRUE(string_like("abc100%efg", 10, "%100!%___", 9, '!'));
31  ASSERT_TRUE(string_like("[ hello", 7, "%\\[%", 4, '\\'));
32  ASSERT_TRUE(string_like("hello [", 7, "%\\[%", 4, '\\'));
33 }
DEVICE bool string_ilike(const char *str, const int32_t str_len, const char *pattern, const int32_t pat_len, const char escape_char)
Definition: StringLike.cpp:257
DEVICE bool string_like(const char *str, const int32_t str_len, const char *pattern, const int32_t pat_len, const char escape_char)
Definition: StringLike.cpp:246

+ Here is the call graph for this function:

TEST ( Utils  ,
Regexp   
)

Definition at line 35 of file UtilTest.cpp.

References regexp_like().

35  {
36  ASSERT_TRUE(regexp_like("abc", 3, "abc", 3, '\\'));
37  ASSERT_FALSE(regexp_like("abc", 3, "ABC", 3, '\\'));
38  ASSERT_TRUE(regexp_like("Xyzabc", 6, "[xX]yz.*", 8, '\\'));
39  ASSERT_TRUE(regexp_like("abcxyzefg", 9, ".*xyz.*", 7, '\\'));
40  ASSERT_TRUE(regexp_like("abcxyzefgXYZhij", 15, ".*xyz.*XYZ.*", 12, '\\'));
41  ASSERT_TRUE(regexp_like("abcxOzefgXpZhij", 15, ".+x.z.*X.Z.*", 12, '\\'));
42  // Custom escape characters are not yet supported.
43  ASSERT_FALSE(regexp_like("abc100%efg", 10, ".+100!%...", 10, '!'));
44  ASSERT_TRUE(regexp_like("[ hello", 7, ".*\\[.*", 6, '\\'));
45  ASSERT_TRUE(regexp_like("hello [", 7, ".*\\[.*", 6, '\\'));
46 }
DEVICE bool regexp_like(const char *str, const int32_t str_len, const char *pattern, const int32_t pat_len, const char escape_char)
Definition: Regexp.cpp:40

+ Here is the call graph for this function: