TTestInsightRestClient.Create(baseUrl: string); - empty string results in range check error

Issue #126 invalid
Walter Prins created an issue

Context: https://bitbucket.org/sglienke/testinsight/wiki/FAQ

I was trying the above which includes a call to TestInsightDUnit’s RunRegisteredTests() procedure. The current release of TestInsight.DUnit.pas’s RunRegisteredTests procedure however demands a baseUrl parameter.

I therefore provided an empty string as value. This seems to work fine, except when range checking is enabled.

If range checking is enabled then the following line in TTestInsightRestClient.Create() causes the range check violation:

The only problem seems to be that the expression baseUrl[Length(baseUrl)] assumes that baseUrl is not empty.

The suggested fix is to explicitly add a condition to check whether the string is empty and if so then also perform the append.

Comments (3)

  1. Stefan Glienke repo owner

    Well, it can theoretically happen if you pass an empty string and the inifile does not exist or does not contain the baseurl value - but then something else is terribly wrong and the TI client would not have any way to communicate with the IDE anyway.

    However at least the tests would continue to run (without any reporting to the IDE though) - so I am going to fix this regardless.

  2. Log in to comment