PorygonLang/tests/integration/diagnostic_tests.cpp

27 lines
900 B
C++

#ifdef TESTS_BUILD
#define CATCH_CONFIG_MAIN
#include <catch.hpp>
#include "../src/Script.hpp"
TEST_CASE( "Diagnostic invalid character", "[integration]" ) {
Script script = Script::Create("1 + 1 @");
REQUIRE(script.Diagnostics -> HasErrors());
auto diags = script.Diagnostics -> GetDiagnostics();
REQUIRE(diags.size() == 1);
CHECK(diags[0].GetCode() == DiagnosticCode::UnexpectedCharacter);
CHECK(diags[0].GetStartPosition() == 6);
CHECK(diags[0].GetLength() == 1);
}
TEST_CASE( "Diagnostic invalid token", "[integration]" ) {
Script script = Script::Create("1 +/ 1");
REQUIRE(script.Diagnostics -> HasErrors());
auto diags = script.Diagnostics -> GetDiagnostics();
REQUIRE(diags.size() == 1);
CHECK(diags[0].GetCode() == DiagnosticCode::UnexpectedToken);
CHECK(diags[0].GetStartPosition() == 3);
CHECK(diags[0].GetLength() == 1);
}
#endif