Skip to content

Commit dd14226

Browse files
committed
Allow cdk tests to run on connector.
Add parser-t.cc to common-t
1 parent 789ccc3 commit dd14226

File tree

4 files changed

+94
-2
lines changed

4 files changed

+94
-2
lines changed

cdk/parser/tests/parser-t.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program is free software; you can redistribute it and/or modify
@@ -890,6 +890,7 @@ const Expr_Test exprs[] =
890890
{ parser::Parser_mode::DOCUMENT, "-2*3+4.1%5 >> 6 & 7 >= 8 and true or docName not in ('foo%', 'bar%')"},
891891
{ parser::Parser_mode::DOCUMENT, "-2*3+4.1%5 >> 6 & 7 >= 8 and true or docName not between 'foo%' AND 'bar%'"},
892892
{ parser::Parser_mode::DOCUMENT, "-2*3+4.1%5 >> 6 & 7 >= 8 and true or docName not regexp 'foo.*'"},
893+
{ parser::Parser_mode::DOCUMENT, "-2*3+4.1%5 >> 6 & 7 >= 8 and true or docName not overlaps [foo, bar]"},
893894
{ parser::Parser_mode::DOCUMENT, "-2*3+4.1%5 >> 6 & 7 >= 8 and true or Schema.Table.docName = null"},
894895
{ parser::Parser_mode::DOCUMENT, "not (name <= 'foo' or not bar)"},
895896
{ parser::Parser_mode::DOCUMENT, "colName.Xpto[1].a[*].* + .1e-2"},
@@ -911,6 +912,9 @@ const Expr_Test exprs[] =
911912
{ parser::Parser_mode::TABLE , "CHARSET(CHAR(0x65))"},
912913
{ parser::Parser_mode::TABLE , "'abc' NOT LIKE 'ABC1'"},
913914
{ parser::Parser_mode::TABLE , "'a' REGEXP '^[a-d]'"},
915+
{ parser::Parser_mode::TABLE , "'a' OVERLAPS [a,d]"},
916+
{ parser::Parser_mode::TABLE , "`overlaps` oVeRlApS [foo, bar]"},
917+
{ parser::Parser_mode::TABLE , R"("overlaps" not OvErLaPs [foo, bar])"},
914918
{ parser::Parser_mode::TABLE , "'a' NOT RLIKE '^[a-d]'"},
915919
{ parser::Parser_mode::TABLE , "POSITION('bar' IN 'foobarbar')"},
916920
{ parser::Parser_mode::TABLE , "TRIM('barxxyz')"},
@@ -923,6 +927,9 @@ const Expr_Test exprs[] =
923927
{ parser::Parser_mode::DOCUMENT, "$.field1 IN $.field2"},
924928
{ parser::Parser_mode::DOCUMENT, "$.field1 NOT IN $.field2"},
925929
{ parser::Parser_mode::DOCUMENT, "a IN (b)"},
930+
//Commented untill WL12774 fixes it:
931+
// { parser::Parser_mode::DOCUMENT, "`overlaps` oVeRlApS [foo, bar]"},
932+
// { parser::Parser_mode::DOCUMENT, "`like` NOT LIKE :like"},
926933
{ parser::Parser_mode::TABLE , "cast(column as json) IN doc->'$.field.array'"},
927934
{ parser::Parser_mode::TABLE , "cast(column as json) NOT IN doc->'$.field.array'"},
928935
{ parser::Parser_mode::TABLE , "column->'$.field' IN [1,2,3]"},
@@ -1131,7 +1138,12 @@ const Expr_Test negative_exprs[] =
11311138
{ parser::Parser_mode::TABLE, "$.a**[0]" },
11321139
{ parser::Parser_mode::TABLE, "$.a**[*]" },
11331140
{ parser::Parser_mode::TABLE, "$.a**.bar" },
1134-
{ parser::Parser_mode::TABLE, "$.a**.foo" }
1141+
{ parser::Parser_mode::TABLE, "$.a**.foo" },
1142+
1143+
//Operators
1144+
{ parser::Parser_mode::DOCUMENT, "overlaps [a,b,c]" },
1145+
{ parser::Parser_mode::DOCUMENT, "not overlaps [a,b,c]" },
1146+
{ parser::Parser_mode::DOCUMENT, "[a,b,c] not overlaps" },
11351147
};
11361148

11371149

common/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ add_library(common STATIC
3434
)
3535

3636
target_link_libraries(common cdk uuid_gen)
37+
38+
add_subdirectory(tests)

common/tests/CMakeLists.txt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2+
#
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License, version 2.0, as
5+
# published by the Free Software Foundation.
6+
#
7+
# This program is also distributed with certain software (including
8+
# but not limited to OpenSSL) that is licensed under separate terms,
9+
# as designated in a particular file or component or in included license
10+
# documentation. The authors of MySQL hereby grant you an
11+
# additional permission to link the program and your derivative works
12+
# with the separately licensed software that they have included with
13+
# MySQL.
14+
#
15+
# Without limiting anything contained in the foregoing, this file,
16+
# which is part of MySQL Connector/C++, is also subject to the
17+
# Universal FOSS Exception, version 1.0, a copy of which can be found at
18+
# http://oss.oracle.com/licenses/universal-foss-exception.
19+
#
20+
# This program is distributed in the hope that it will be useful, but
21+
# WITHOUT ANY WARRANTY; without even the implied warranty of
22+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23+
# See the GNU General Public License, version 2.0, for more details.
24+
#
25+
# You should have received a copy of the GNU General Public License
26+
# along with this program; if not, write to the Free Software Foundation, Inc.,
27+
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28+
29+
#
30+
# Note: We must clear compile flags - the ones used to build the connector
31+
# are not good for building client code that uses the connector.
32+
#
33+
34+
set_property(
35+
DIRECTORY .
36+
PROPERTY COMPILE_DEFINITIONS ""
37+
)
38+
39+
if(WIN32)
40+
add_definitions(
41+
-D_CRT_SECURE_NO_WARNINGS
42+
-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
43+
)
44+
45+
endif()
46+
47+
#Add cdk includes because we are using their source tests
48+
add_test_includes(${PROJECT_SOURCE_DIR}/cdk/include)
49+
add_test_includes(${PROJECT_SOURCE_DIR}/cdk/extra/rapidjson/include)
50+
add_test_includes(${PROJECT_BINARY_DIR}/cdk/include)
51+
52+
ADD_TEST_LIBRARIES(cdk_parser)
53+
54+
ADD_NG_TEST(common-t
55+
${PROJECT_SOURCE_DIR}/cdk/parser/tests/parser-t.cc
56+
)
57+
58+

devapi/tests/crud-t.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,6 +2873,9 @@ TEST_F(Crud, overlaps)
28732873
res = coll.find(R"(food overlaps ["Meat"])").execute();
28742874
EXPECT_EQ(0, res.count());
28752875

2876+
res = coll.find(R"(food overlaps "Meat")").execute();
2877+
EXPECT_EQ(0, res.count());
2878+
28762879
// Not Overlaps tests
28772880

28782881
res = coll.find(R"(food not overlaps ["Soup"])").execute();
@@ -2892,4 +2895,21 @@ TEST_F(Crud, overlaps)
28922895
res = coll.find(R"(food not overlaps ["Meat"])").execute();
28932896
EXPECT_EQ(2, res.count());
28942897

2898+
res = coll.find(R"(food not overlaps "Meat")").execute();
2899+
EXPECT_EQ(2, res.count());
2900+
2901+
try {
2902+
coll.find(R"(food not overlaps and "Meat")").execute();
2903+
FAIL() << "No error thrown";
2904+
} catch (Error& e) {
2905+
std::cout << "Expected: " << e << std::endl;
2906+
}
2907+
2908+
try {
2909+
coll.find(R"(food and overlaps "Meat")").execute();
2910+
FAIL() << "No error thrown";
2911+
} catch (Error& e) {
2912+
std::cout << "Expected: " << e << std::endl;
2913+
}
2914+
28952915
}

0 commit comments

Comments
 (0)