You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by GitBox <gi...@apache.org> on 2021/04/01 17:27:00 UTC

[GitHub] [qpid-proton] DreamPearl commented on pull request #303: [WIP] PROTON-2357: Improve test coverage in url.cpp

DreamPearl commented on pull request #303:
URL: https://github.com/apache/qpid-proton/pull/303#issuecomment-812057572


   I think it's not possible to add test coverage for `i.clear(std::ios::failbit)` as if we try to make `if(!s.empty())` false then `s` has to be empty which means `if(!i.fail() && !i.bad())` will become false. Thus the targeted line can not be executed.
   ```cpp
   std::istream& operator>>(std::istream& i, url& u) {
       std::string s;
       i >> s;
       if (!i.fail() && !i.bad()) {
           if (!s.empty()) {
               url::impl* p = new url::impl(s);
               p->defaults();
               u.impl_.reset(p);
           } else {
               i.clear(std::ios::failbit);  // Not covered by test
           }
       }
       return i;
   } 
   ```
   I added the following code snippet in url_test.cpp to test the targeted line but it was not getting covered under test coverage.
   
   ```cpp
   {
              url u("amqp://foo:xyz/path");
              std::istringstream i(" ");
              CHECK(false==i.fail());
              i>>u;
              CHECK(std::string("amqp://foo:xyz/path") == std::string(u));
              CHECK(true==i.fail());
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org