Skip to content

Commit 7594762

Browse files
committed
[Runtime] Update unit test for swift_getAssociated(Type|Conformance)Slow.
1 parent dc73c67 commit 7594762

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

unittests/runtime/CompatibilityOverride.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,25 @@ using namespace swift;
2424
bool EnableOverride;
2525
bool Ran;
2626

27+
namespace {
28+
template<typename T>
29+
T getEmptyValue() {
30+
return (T)0;
31+
}
32+
33+
template<>
34+
MetadataResponse getEmptyValue<MetadataResponse>() {
35+
return MetadataResponse{nullptr, MetadataState::Complete};
36+
}
37+
}
2738

2839
#define OVERRIDE(name, ret, attrs, namespace, typedArgs, namedArgs) \
2940
static ret name ## Override(COMPATIBILITY_UNPAREN typedArgs, \
3041
Original_ ## name originalImpl) { \
3142
if (!EnableOverride) \
3243
return originalImpl namedArgs; \
3344
Ran = true; \
34-
return (ret)0; \
45+
return getEmptyValue<ret>(); \
3546
}
3647
#include "../../stdlib/public/runtime/CompatibilityOverride.def"
3748

@@ -164,4 +175,20 @@ TEST_F(CompatibilityOverrideTest, test_swift_conformsToProtocol) {
164175
ASSERT_EQ(Result, nullptr);
165176
}
166177

178+
TEST_F(CompatibilityOverrideTest, test_swift_getAssociatedTypeWitnessSlow) {
179+
auto Result = swift_getAssociatedTypeWitnessSlow(MetadataState::Complete,
180+
nullptr, nullptr,
181+
nullptr, nullptr);
182+
ASSERT_EQ(Result.Value, nullptr);
183+
ASSERT_EQ(Result.State, MetadataState::Complete);
184+
}
185+
186+
TEST_F(CompatibilityOverrideTest,
187+
test_swift_getAssociatedConformanceWitnessSlow) {
188+
auto Result = swift_getAssociatedConformanceWitnessSlow(
189+
nullptr, nullptr, nullptr,
190+
nullptr, nullptr);
191+
ASSERT_EQ(Result, nullptr);
192+
}
193+
167194
#endif

0 commit comments

Comments
 (0)