mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-18 03:49:41 +00:00
Merge commit '515e28309153ae8ab6fa3cbed81b44e2c01c43cd' into develop
This commit is contained in:
@@ -1,21 +1,18 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2018-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <unistd.h>
|
||||
#include "testing_utils.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
#include <gmock/gmock.h>
|
||||
#include "testing_utils.hpp"
|
||||
#include <unistd.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace ck_tile::test {
|
||||
|
||||
namespace {
|
||||
|
||||
} // namespace
|
||||
|
||||
// Wagner-Fischer Algorithm for Computing Edit Distance and Inline Diff
|
||||
//
|
||||
// OUTPUT FORMAT: [expected|actual] for differences, plain text for matches
|
||||
@@ -216,4 +213,88 @@ void StringEqWithDiffMatcher::DescribeNegationTo(std::ostream* os) const
|
||||
return ::testing::MakeMatcher(new StringEqWithDiffMatcher(expected));
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const InstanceSet& set)
|
||||
{
|
||||
// These sets can grow very large, and so its not very nice or useful to print them
|
||||
// in the event of a mismatch. Just print a brief description here, and use
|
||||
// InstancesMatcher to print a more useful message.
|
||||
return (os << "(set of " << set.instances.size() << " instances)");
|
||||
}
|
||||
|
||||
InstanceMatcher::InstanceMatcher(const InstanceSet& expected) : expected_(expected) {}
|
||||
|
||||
::testing::Matcher<InstanceSet> InstancesMatch(const InstanceSet& expected)
|
||||
{
|
||||
return ::testing::MakeMatcher(new InstanceMatcher(expected));
|
||||
}
|
||||
|
||||
bool InstanceMatcher::MatchAndExplain(InstanceSet actual,
|
||||
::testing::MatchResultListener* listener) const
|
||||
{
|
||||
if(actual.instances == expected_.instances)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(listener->IsInterested())
|
||||
{
|
||||
std::vector<std::string> instances;
|
||||
std::set_difference(expected_.instances.begin(),
|
||||
expected_.instances.end(),
|
||||
actual.instances.begin(),
|
||||
actual.instances.end(),
|
||||
std::back_inserter(instances));
|
||||
|
||||
*listener << "\n";
|
||||
|
||||
if(instances.size() > 0)
|
||||
{
|
||||
*listener << " Missing: " << instances.size() << "\n";
|
||||
for(const auto& instance : instances)
|
||||
{
|
||||
if(instance == "")
|
||||
{
|
||||
*listener << "- (empty string)\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
*listener << "- " << instance << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
instances.clear();
|
||||
std::set_difference(actual.instances.begin(),
|
||||
actual.instances.end(),
|
||||
expected_.instances.begin(),
|
||||
expected_.instances.end(),
|
||||
std::back_inserter(instances));
|
||||
|
||||
if(instances.size() > 0)
|
||||
{
|
||||
*listener << "Unexpected: " << instances.size() << "\n";
|
||||
for(const auto& instance : instances)
|
||||
{
|
||||
if(instance == "")
|
||||
{
|
||||
*listener << "- (empty string)\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
*listener << "- " << instance << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void InstanceMatcher::DescribeTo(std::ostream* os) const { *os << expected_; }
|
||||
|
||||
void InstanceMatcher::DescribeNegationTo(std::ostream* os) const
|
||||
{
|
||||
*os << "is not equal to " << expected_;
|
||||
}
|
||||
|
||||
} // namespace ck_tile::test
|
||||
|
||||
Reference in New Issue
Block a user