Hi @tootzoe1 ! Thank you so much for you reply.
Your suggestion is accepted and tested.
Here is the result.(Only testing the last one,since case 1 is an OK for me)
Please feel free to ask for more , if you want more info or tests!
TLDR(joking)
Reference Assignment works.
But plain chaining without reference assignment keeps giving incredible result.
Test cases
case | result | note |
---|---|---|
VertexNodeShouldIncludeNickname61 | OK | using temp variable to save filtered result |
VertexNodeShouldIncludeNickname61WithChaining | NG | Chaining without using reference assignment |
VertexNodeShouldIncludeNickname61UsingRefAssign | OK | Chaining with reference assignment |
Test code
It("VertexNodeShouldIncludeNickname61",
[this]()
{
auto vertexes = grid->allVertexGridNodes();
auto Is61Found = vertexes.FindByPredicate(
[](const TSharedPtr<PositionableNode>& node) {
return node->nicknameByPosition == FIntPoint{6, 1} && node->belongedPlayer == PlayerType::Player1;
}); //
TestTrueExpr(Is61Found->IsValid());
TestTrueExpr(((*Is61Found)->nicknameByPosition == FIntPoint{6, 1}));
});
It("VertexNodeShouldIncludeNickname61WithChaining",
[this]()
{
auto Is61Found = grid->allVertexGridNodes().FindByPredicate(
[](const TSharedPtr<PositionableNode>& node) {
return node->nicknameByPosition == FIntPoint{6, 1} && node->belongedPlayer == PlayerType::Player1;
}); //
TestTrueExpr(Is61Found->IsValid());
TestTrueExpr(((*Is61Found)->nicknameByPosition == FIntPoint{6, 1}));
});
It("VertexNodeShouldIncludeNickname61UsingRefAssign",
[this]()
{
// testing reference assignment
auto Is61FoundByRefAssign{grid->allVertexGridNodes().FilterByPredicate(
[](const TSharedPtr<PositionableNode>& node) {
return node->nicknameByPosition == FIntPoint{6, 1} && node->belongedPlayer == PlayerType::Player1;
})}; //
if (TestTrueExpr(!Is61FoundByRefAssign.IsEmpty()))
{
TestTrueExpr(Is61FoundByRefAssign.Top().IsValid());
TestTrueExpr((Is61FoundByRefAssign.Top()->nicknameByPosition == FIntPoint{6, 1}));
}
});