Fixed infinite loop in diagnostics
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
bb6c7edcf2
commit
40e45b0112
|
@ -57,7 +57,11 @@ size_t DiagnosticsHolder::GetLineFromPosition(size_t i) {
|
|||
if (pos > i){
|
||||
topLimit = half;
|
||||
} else if (pos < i){
|
||||
if (bottomLimit == half){
|
||||
bottomLimit = half + 1;
|
||||
} else{
|
||||
bottomLimit = half;
|
||||
}
|
||||
} else{
|
||||
return half;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,18 @@ TEST_CASE( "Get diagnostic line", "[integration]" ) {
|
|||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "Get diagnostic line 2", "[integration]" ) {
|
||||
auto script = Script::Create(u"\n'\\x'");
|
||||
REQUIRE(script->Diagnostics -> HasErrors());
|
||||
auto diags = script->Diagnostics -> GetDiagnostics();
|
||||
REQUIRE(diags.size() == 1);
|
||||
CHECK(diags[0].GetCode() == Diagnostics::DiagnosticCode::InvalidStringControlCharacter);
|
||||
CHECK(diags[0].GetStartPosition() == 2);
|
||||
CHECK(diags[0].GetLength() == 2);
|
||||
CHECK(script->Diagnostics->GetLineFromPosition(diags[0].GetStartPosition()) == 1);
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "Get full diagnostic message", "[integration]" ) {
|
||||
auto script = Script::Create(uR"(
|
||||
"\x"
|
||||
|
|
Loading…
Reference in New Issue