|
14 | 14 | // KIND, either express or implied. See the License for the |
15 | 15 | // specific language governing permissions and limitations |
16 | 16 | // under the License. |
17 | | -#include "vec/functions/function_string.h" |
18 | 17 |
|
19 | 18 | #include <gtest/gtest.h> |
20 | 19 | #include <time.h> |
21 | 20 |
|
22 | | -#include <iostream> |
23 | 21 | #include <string> |
24 | 22 |
|
25 | | -#include "exec/schema_scanner.h" |
26 | 23 | #include "function_test_util.h" |
27 | | -#include "runtime/row_batch.h" |
28 | 24 | #include "runtime/tuple_row.h" |
29 | 25 | #include "util/aes_util.h" |
30 | 26 | #include "util/url_coding.h" |
31 | 27 | #include "vec/core/field.h" |
32 | | -#include "vec/functions/simple_function_factory.h" |
33 | 28 |
|
34 | 29 | namespace doris { |
35 | 30 |
|
@@ -615,9 +610,74 @@ TEST(function_string_test, function_aes_decrypt_test) { |
615 | 610 | vectorized::check_function<vectorized::DataTypeString, true>(func_name, input_types, data_set); |
616 | 611 | } |
617 | 612 |
|
| 613 | +TEST(function_string_test, function_parse_url_test) { |
| 614 | + std::string func_name = "parse_url"; |
| 615 | + |
| 616 | + { |
| 617 | + std::vector<std::any> input_types = {TypeIndex::String, TypeIndex::String}; |
| 618 | + DataSet data_set = { |
| 619 | + {{std::string("zhangsan"), std::string("HOST")}, |
| 620 | + {Null()}}, |
| 621 | + {{std::string("facebook.com/path/p1"), std::string("HOST")}, |
| 622 | + {Null()}}, |
| 623 | + {{std::string("http://fb.com/path/p1.p?q=1#f"), std::string("HOST")}, |
| 624 | + {std::string("fb.com")}}, |
| 625 | + {{std::string("http://facebook.com/path/p1.php?query=1"), std::string("AUTHORITY")}, |
| 626 | + {std::string("facebook.com")}}, |
| 627 | + {{std::string("http://facebook.com/path/p1.php?query=1"), std::string("authority")}, |
| 628 | + {std::string("facebook.com")}}, |
| 629 | + {{std::string("http://www.baidu.com:9090/a/b/c.php"), std::string("FILE")}, |
| 630 | + {std::string("/a/b/c.php")}}, |
| 631 | + {{std::string("http://www.baidu.com:9090/a/b/c.php"), std::string("file")}, |
| 632 | + {std::string("/a/b/c.php")}}, |
| 633 | + {{std::string("http://www.baidu.com:9090/a/b/c.php"), std::string("PATH")}, |
| 634 | + {std::string("/a/b/c.php")}}, |
| 635 | + {{std::string("http://www.baidu.com:9090/a/b/c.php"), std::string("path")}, |
| 636 | + {std::string("/a/b/c.php")}}, |
| 637 | + {{std::string("http://facebook.com/path/p1.php?query=1"), std::string("PROTOCOL")}, |
| 638 | + {std::string("http")}}, |
| 639 | + {{std::string("http://facebook.com/path/p1.php?query=1"), std::string("protocol")}, |
| 640 | + {std::string("http")}}, |
| 641 | + {{std::string("http://www.baidu.com:9090?a=b"), std::string("QUERY")}, |
| 642 | + {std::string("a=b")}}, |
| 643 | + {{std::string("http://www.baidu.com:9090?a=b"), std::string("query")}, |
| 644 | + {std::string("a=b")}}, |
| 645 | + {{std::string("http://www.baidu.com:9090?a=b"), std::string("REF")}, |
| 646 | + {Null()}}, |
| 647 | + {{std::string("http://www.baidu.com:9090?a=b"), std::string("ref")}, |
| 648 | + {Null()}}, |
| 649 | + {{std::string("http://www.baidu.com:9090/a/b/c?a=b"), std::string("PORT")}, |
| 650 | + {std::string("9090")}}, |
| 651 | + {{std::string("http://www.baidu.com/a/b/c?a=b"), std::string("PORT")}, |
| 652 | + {Null()}}, |
| 653 | + {{std::string("http://fb.com/path/p1.p?q=1#f"), std::string("QUERY")}, |
| 654 | + {std::string("q=1")}} |
| 655 | + }; |
| 656 | + |
| 657 | + vectorized::check_function<vectorized::DataTypeString, true>(func_name, input_types, data_set); |
| 658 | + } |
| 659 | + |
| 660 | + { |
| 661 | + std::vector<std::any> input_types = {TypeIndex::String, TypeIndex::String, TypeIndex::String}; |
| 662 | + DataSet data_set = { |
| 663 | + {{std::string("http://fb.com/path/p1.p?q=1#f"), std::string("QUERY"), std::string("q")}, |
| 664 | + {std::string("1")}}, |
| 665 | + {{std::string("fb.com/path/p1.p?q=1#f"), std::string("QUERY"), std::string("q")}, |
| 666 | + {std::string("1")}}, |
| 667 | + {{std::string("http://facebook.com/path/p1"), std::string("QUERY"), std::string("q")}, |
| 668 | + {Null()}}, |
| 669 | + {{std::string("http://fb.com/path/p1.p?q=1#f"), std::string("HOST"), std::string("q")}, |
| 670 | + {Null()}} |
| 671 | + }; |
| 672 | + |
| 673 | + vectorized::check_function<vectorized::DataTypeString, true>(func_name, input_types, data_set); |
| 674 | + } |
| 675 | +} |
| 676 | + |
618 | 677 | } // namespace doris |
619 | 678 |
|
620 | 679 | int main(int argc, char** argv) { |
| 680 | + doris::CpuInfo::init(); |
621 | 681 | ::testing::InitGoogleTest(&argc, argv); |
622 | 682 | return RUN_ALL_TESTS(); |
623 | 683 | } |
0 commit comments