1. solved the previous delayed unit test file size is too large (1.7G+) and the unit test link time is too long problem problems 2. Unify all unit tests into one file to significantly reduce unit test execution time to less than 3 mins 3. temporarily disable stream_load_test.cpp, metrics_action_test.cpp, load_channel_mgr_test.cpp because it will re-implement part of the code and affect other tests
107 lines
3.1 KiB
C++
107 lines
3.1 KiB
C++
// Licensed to the Apache Software Foundation (ASF) under one
|
|
// or more contributor license agreements. See the NOTICE file
|
|
// distributed with this work for additional information
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
// to you under the Apache License, Version 2.0 (the
|
|
// "License"); you may not use this file except in compliance
|
|
// with the License. You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing,
|
|
// software distributed under the License is distributed on an
|
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
// KIND, either express or implied. See the License for the
|
|
// specific language governing permissions and limitations
|
|
// under the License.
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <map>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "common/object_pool.h"
|
|
#include "exec/broker_scanner.h"
|
|
#include "exec/local_file_reader.h"
|
|
#include "exprs/cast_functions.h"
|
|
#include "gen_cpp/Descriptors_types.h"
|
|
#include "gen_cpp/PlanNodes_types.h"
|
|
#include "runtime/descriptors.h"
|
|
#include "runtime/mem_tracker.h"
|
|
#include "runtime/runtime_state.h"
|
|
#include "runtime/tuple.h"
|
|
#include "runtime/user_function_cache.h"
|
|
|
|
namespace doris {
|
|
|
|
class MultiBytesSeparatorTest : public testing::Test {
|
|
public:
|
|
MultiBytesSeparatorTest() {}
|
|
|
|
protected:
|
|
virtual void SetUp() {}
|
|
virtual void TearDown() {}
|
|
};
|
|
|
|
TEST_F(MultiBytesSeparatorTest, normal) {
|
|
TBrokerScanRangeParams params;
|
|
params.column_separator = ',';
|
|
params.line_delimiter = '\n';
|
|
params.column_separator_str = "AAAA";
|
|
params.line_delimiter_str = "BBB";
|
|
params.column_separator_length = 4;
|
|
params.line_delimiter_length = 3;
|
|
|
|
const std::vector<TBrokerRangeDesc> ranges;
|
|
const std::vector<TNetworkAddress> broker_addresses;
|
|
const std::vector<TExpr> pre_filter_texprs;
|
|
BrokerScanner scanner(nullptr, nullptr, params, ranges, broker_addresses, pre_filter_texprs,
|
|
nullptr);
|
|
|
|
#define private public
|
|
|
|
// 1.
|
|
{
|
|
std::string line = "AAAA";
|
|
Slice s(line);
|
|
scanner.split_line(s);
|
|
EXPECT_EQ(2, scanner._split_values.size());
|
|
EXPECT_EQ(0, scanner._split_values[0].size);
|
|
EXPECT_EQ(0, scanner._split_values[1].size);
|
|
}
|
|
|
|
// 2.
|
|
{
|
|
std::string line = "ABAA";
|
|
Slice s(line);
|
|
scanner.split_line(s);
|
|
EXPECT_EQ(1, scanner._split_values.size());
|
|
EXPECT_EQ(4, scanner._split_values[0].size);
|
|
}
|
|
|
|
// 3.
|
|
{
|
|
std::string line = "";
|
|
Slice s(line);
|
|
scanner.split_line(s);
|
|
EXPECT_EQ(1, scanner._split_values.size());
|
|
EXPECT_EQ(0, scanner._split_values[0].size);
|
|
}
|
|
|
|
// 4.
|
|
{
|
|
// 1234, AAAB, , AA
|
|
std::string line = "1234AAAAAAABAAAAAAAAAA";
|
|
Slice s(line);
|
|
scanner.split_line(s);
|
|
EXPECT_EQ(4, scanner._split_values.size());
|
|
EXPECT_EQ(4, scanner._split_values[0].size);
|
|
EXPECT_EQ(4, scanner._split_values[1].size);
|
|
EXPECT_EQ(0, scanner._split_values[2].size);
|
|
EXPECT_EQ(2, scanner._split_values[3].size);
|
|
}
|
|
}
|
|
|
|
} // end namespace doris
|