Make Metadata tests pass on Windows
PiperOrigin-RevId: 513365428
This commit is contained in:
parent
82ee00f25d
commit
f15637b62c
|
@ -29,7 +29,7 @@ limitations under the License.
|
|||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#endif // _WIN32
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
|
|
@ -16,6 +16,7 @@ cc_test(
|
|||
"//mediapipe/framework/port:gtest_main",
|
||||
"//mediapipe/framework/port:status",
|
||||
"//mediapipe/tasks/cc:common",
|
||||
"//mediapipe/tasks/cc/core:utils",
|
||||
"//mediapipe/tasks/cc/metadata:metadata_extractor",
|
||||
"@com_google_absl//absl/status",
|
||||
"@com_google_absl//absl/status:statusor",
|
||||
|
|
|
@ -25,12 +25,14 @@ limitations under the License.
|
|||
#include "mediapipe/framework/port/status_macros.h"
|
||||
#include "mediapipe/framework/port/status_matchers.h"
|
||||
#include "mediapipe/tasks/cc/common.h"
|
||||
#include "mediapipe/tasks/cc/core/utils.h"
|
||||
|
||||
namespace mediapipe {
|
||||
namespace tasks {
|
||||
namespace metadata {
|
||||
namespace {
|
||||
|
||||
using core::LoadBinaryContent;
|
||||
using ::testing::Optional;
|
||||
|
||||
constexpr char kTestDataDirectory[] = "mediapipe/tasks/testdata/metadata";
|
||||
|
@ -53,8 +55,8 @@ constexpr char kRandomTextFile[] = "external_file";
|
|||
|
||||
absl::StatusOr<std::unique_ptr<ModelMetadataExtractor>> CreateMetadataExtractor(
|
||||
std::string model_name, std::string* file_contents) {
|
||||
MP_RETURN_IF_ERROR(file::GetContents(
|
||||
file::JoinPath("./", kTestDataDirectory, model_name), file_contents));
|
||||
*file_contents = LoadBinaryContent(
|
||||
file::JoinPath("./", kTestDataDirectory, model_name).c_str());
|
||||
return ModelMetadataExtractor::CreateFromModelBuffer(file_contents->data(),
|
||||
file_contents->length());
|
||||
}
|
||||
|
|
|
@ -26,7 +26,11 @@ using ::testing::MatchesRegex;
|
|||
|
||||
TEST(MetadataParserTest, MatadataParserVersionIsWellFormed) {
|
||||
// Validates that the version is well-formed (x.y.z).
|
||||
#ifdef _WIN32
|
||||
EXPECT_THAT(kMatadataParserVersion, MatchesRegex("\\d+\\.\\d+\\.\\d+"));
|
||||
#else
|
||||
EXPECT_THAT(kMatadataParserVersion, MatchesRegex("[0-9]+\\.[0-9]+\\.[0-9]+"));
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -83,7 +83,11 @@ TEST(MetadataVersionTest,
|
|||
builder.GetSize(), &min_version),
|
||||
kTfLiteOk);
|
||||
// Validates that the version is well-formed (x.y.z).
|
||||
#ifdef _WIN32
|
||||
EXPECT_THAT(min_version, MatchesRegex("\\d+\\.\\d+\\.\\d+"));
|
||||
#else
|
||||
EXPECT_THAT(min_version, MatchesRegex("[0-9]+\\.[0-9]+\\.[0-9]+"));
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
TEST(MetadataVersionTest,
|
||||
|
|
Loading…
Reference in New Issue
Block a user