Fix get_directory() to return / on Linux (#18820)

This commit is contained in:
Vitaliy Urusovskij 2023-07-27 17:24:07 +04:00 committed by GitHub
parent 2bd49cc1f8
commit 4be69bdd5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -87,7 +87,7 @@ std::string ov::util::get_directory(const std::string& s) {
// Linux-style separator
auto pos = s.find_last_of('/');
if (pos != std::string::npos) {
rc = s.substr(0, pos);
rc = s.substr(0, pos ? pos : 1);
return rc;
}
// Windows-style separator

View File

@ -0,0 +1,14 @@
// Copyright (C) 2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/util/file_util.hpp"
using namespace testing;
using namespace ov::util;
TEST(UtilsTests, get_directory_returns_root) {
ASSERT_EQ(get_directory("/test"), "/");
}