-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print content of columns for gtest #5243
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0f1029a
complete
xzhangxian1008 95cfb94
update
xzhangxian1008 9e8de2b
update
xzhangxian1008 7277852
merge
xzhangxian1008 304e4df
Merge branch 'master' into dev1
xzhangxian1008 5633cb0
update
xzhangxian1008 c426d28
update
xzhangxian1008 e5f8209
Merge branch 'master' into dev1
xzhangxian1008 e5a46e1
update
xzhangxian1008 dabae34
udpate
xzhangxian1008 0f622db
Merge branch 'master' into dev1
xzhangxian1008 1fc7443
add test
xzhangxian1008 1a8bf1a
Merge branch 'master' into dev1
xzhangxian1008 9bd3f39
add space
xzhangxian1008 2b9446a
update
xzhangxian1008 db56449
Merge branch 'master' into dev1
xzhangxian1008 feaa36e
Merge branch 'master' into dev1
ti-chi-bot 77ae901
Merge branch 'master' into dev1
ti-chi-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2022 PingCAP, Ltd. | ||
// | ||
// Licensed 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 <TestUtils/ExecutorTestUtils.h> | ||
#include <TestUtils/mockExecutor.h> | ||
|
||
namespace DB | ||
{ | ||
namespace tests | ||
{ | ||
|
||
class PrintColumnsTest : public DB::tests::ExecutorTest | ||
{ | ||
public: | ||
using ColStringType = std::optional<typename TypeTraits<String>::FieldType>; | ||
using ColInt32Type = std::optional<typename TypeTraits<Int32>::FieldType>; | ||
using ColumnWithString = std::vector<ColStringType>; | ||
using ColumnWithInt32 = std::vector<ColInt32Type>; | ||
|
||
void initializeContext() override | ||
{ | ||
test_cols.push_back(toNullableVec<Int32>("col1", ColumnWithInt32{36, 34, 32, 27, {}, {}})); | ||
test_cols.push_back(toNullableVec<String>("col2", ColumnWithString{"female", "male", "male", "female", "male", "female"})); | ||
col_len = test_cols[0].column->size(); | ||
} | ||
|
||
ColumnsWithTypeAndName test_cols; | ||
size_t col_len; | ||
const String result1{"col1: (0: Int64_36, 1: Int64_34, 2: Int64_32, 3: Int64_27, 4: NULL, 5: NULL)\ncol2: (0: 'female', 1: 'male', 2: 'male', 3: 'female', 4: 'male', 5: 'female')\n"}; | ||
const String result2{"col1: (0: Int64_36, 1: Int64_34, 2: Int64_32, 3: Int64_27, 4: NULL, 5: NULL)\ncol2: (0: 'female', 1: 'male', 2: 'male', 3: 'female', 4: 'male', 5: 'female')\n"}; | ||
const String result3{"col1: (0: Int64_36)\ncol2: (0: 'female')\n"}; | ||
const String result4{"col1: (1: Int64_34, 2: Int64_32, 3: Int64_27, 4: NULL)\ncol2: (1: 'male', 2: 'male', 3: 'female', 4: 'male')\n"}; | ||
}; | ||
|
||
TEST_F(PrintColumnsTest, SimpleTest) | ||
try | ||
{ | ||
EXPECT_EQ(getColumnsContent(test_cols), result1); | ||
EXPECT_EQ(getColumnsContent(test_cols, 0, col_len - 1), result2); | ||
EXPECT_EQ(getColumnsContent(test_cols, 0, 0), result3); | ||
EXPECT_EQ(getColumnsContent(test_cols, 1, col_len - 2), result4); | ||
} | ||
CATCH | ||
|
||
} // namespace tests | ||
} // namespace DB |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a unit test for the function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done