Catch block not hit in unittest

Kagamin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Nov 24 05:42:25 PST 2016


Linux? Probably another bug.
Try this:
unittest
{
     import core.exception : UnicodeException;
     void f()
     {
         string ret;
         int i = -1;
         ret ~= i;
     }

     try
     {
         f();
     }
     catch(UnicodeException e)
     {
         assert(e.msg == "Invalid UTF-8 sequence");
     }
}


More information about the Digitalmars-d-learn mailing list