diff --git a/src/core/tests/check.cpp b/src/core/tests/check.cpp index 73f2ecfeaf3..42d086da6ac 100644 --- a/src/core/tests/check.cpp +++ b/src/core/tests/check.cpp @@ -89,7 +89,11 @@ TEST(check, ngraph_check_with_explanation) { } TEST(check, ov_throw_exception_check_relative_path_to_source) { + using namespace testing; const auto path = ov::util::path_join({"src", "core", "tests", "check.cpp"}); - const auto exp_msg = "Exception from " + path + ":" + std::to_string(__LINE__ + 1) + ":\nTest message"; - OV_EXPECT_THROW(OPENVINO_THROW("Test message"), ov::Exception, testing::HasSubstr(exp_msg)); + const auto exp_native_slash = "Exception from " + path + ":"; + const auto exp_fwd_slash = "Exception from src/core/tests/check.cpp:"; + OV_EXPECT_THROW(OPENVINO_THROW("Test message"), + ov::Exception, + AnyOf(StartsWith(exp_native_slash), StartsWith(exp_fwd_slash))); }