Github user phrocker commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/219#discussion_r156815280
  
    --- Diff: 
libminifi/test/expression-language-tests/ExpressionLanguageTests.cpp ---
    @@ -235,3 +242,51 @@ TEST_CASE("GetFile PutFile dynamic attribute", 
"[expressionLanguageTestGetFilePu
         REQUIRE("extracted_attr" == output_str.str());
       }
     }
    +
    +TEST_CASE("Substring 2 arg", "[expressionLanguageSubstring2]") {  // NOLINT
    +  auto expr = expression::compile("text_before${attr:substring(6, 
8)}text_after");
    +
    +  auto flow_file_a = std::make_shared<MockFlowFile>();
    +  flow_file_a->addAttribute("attr", "__flow_a_attr_value_a__");
    +  REQUIRE("text_before_a_attr_text_after" == expr({flow_file_a}));
    +}
    +
    +TEST_CASE("Substring 1 arg", "[expressionLanguageSubstring1]") {  // NOLINT
    +  auto expr = 
expression::compile("text_before${attr:substring(6)}text_after");
    +
    +  auto flow_file_a = std::make_shared<MockFlowFile>();
    +  flow_file_a->addAttribute("attr", "__flow_a_attr_value_a__");
    +  REQUIRE("text_before_a_attr_value_a__text_after" == expr({flow_file_a}));
    +}
    +
    +TEST_CASE("Substring Before", "[expressionLanguageSubstringBefore]") {  // 
NOLINT
    +  auto expr = 
expression::compile("${attr:substringBefore('attr_value_a__')}");
    --- End diff --
    
    I saw the un-guarded substring calls in expr_substringBefore. I assumed 
that calling args[0] is likely not possible since there were no conditionals; 
however, what happens if the user enters attr:substrinBefore ? Will they 
receive an error that is gracefully handled? 


---

Reply via email to