temporal manifest tests
This commit is contained in:
@@ -119,6 +119,65 @@ void TestInvalidManifest()
|
||||
std::filesystem::remove_all(root);
|
||||
}
|
||||
|
||||
void TestInvalidTemporalSettings()
|
||||
{
|
||||
struct Case
|
||||
{
|
||||
const char* directoryName;
|
||||
const char* temporalJson;
|
||||
const char* expectedError;
|
||||
};
|
||||
|
||||
const Case cases[] = {
|
||||
{ "bad-source", R"({ "enabled": true, "historySource": "previousOutput", "historyLength": 2 })", "Unsupported temporal historySource" },
|
||||
{ "missing-source", R"({ "enabled": true, "historyLength": 2 })", "historySource" },
|
||||
{ "missing-length", R"({ "enabled": true, "historySource": "source" })", "historyLength" },
|
||||
{ "string-length", R"({ "enabled": true, "historySource": "source", "historyLength": "2" })", "historyLength" },
|
||||
{ "zero-length", R"({ "enabled": true, "historySource": "source", "historyLength": 0 })", "positive integer" },
|
||||
{ "negative-length", R"({ "enabled": true, "historySource": "source", "historyLength": -1 })", "positive integer" },
|
||||
{ "fractional-length", R"({ "enabled": true, "historySource": "source", "historyLength": 1.5 })", "positive integer" },
|
||||
};
|
||||
|
||||
const std::filesystem::path root = MakeTestRoot();
|
||||
for (const Case& testCase : cases)
|
||||
{
|
||||
WriteShaderPackage(root, testCase.directoryName, std::string(R"({
|
||||
"id": ")") + testCase.directoryName + R"(",
|
||||
"name": "Bad Temporal",
|
||||
"temporal": )" + testCase.temporalJson + R"(,
|
||||
"parameters": []
|
||||
})");
|
||||
|
||||
ShaderPackageRegistry registry(4);
|
||||
ShaderPackage package;
|
||||
std::string error;
|
||||
Expect(!registry.ParseManifest(root / testCase.directoryName / "shader.json", package, error), "invalid temporal manifest is rejected");
|
||||
Expect(error.find(testCase.expectedError) != std::string::npos, "invalid temporal error explains the rejected field");
|
||||
}
|
||||
|
||||
std::filesystem::remove_all(root);
|
||||
}
|
||||
|
||||
void TestDisabledTemporalSettingsAreIgnored()
|
||||
{
|
||||
const std::filesystem::path root = MakeTestRoot();
|
||||
WriteShaderPackage(root, "disabled-temporal", R"({
|
||||
"id": "disabled-temporal",
|
||||
"name": "Disabled Temporal",
|
||||
"temporal": { "enabled": false, "historySource": "not-supported", "historyLength": 0 },
|
||||
"parameters": []
|
||||
})");
|
||||
|
||||
ShaderPackageRegistry registry(4);
|
||||
ShaderPackage package;
|
||||
std::string error;
|
||||
Expect(registry.ParseManifest(root / "disabled-temporal" / "shader.json", package, error), "disabled temporal settings are ignored");
|
||||
Expect(!package.temporal.enabled, "disabled temporal package stays non-temporal");
|
||||
Expect(package.temporal.effectiveHistoryLength == 0, "disabled temporal package has no effective history");
|
||||
|
||||
std::filesystem::remove_all(root);
|
||||
}
|
||||
|
||||
void TestDuplicateScan()
|
||||
{
|
||||
const std::filesystem::path root = MakeTestRoot();
|
||||
@@ -141,6 +200,8 @@ int main()
|
||||
TestValidManifest();
|
||||
TestMissingFontAsset();
|
||||
TestInvalidManifest();
|
||||
TestInvalidTemporalSettings();
|
||||
TestDisabledTemporalSettingsAreIgnored();
|
||||
TestDuplicateScan();
|
||||
|
||||
if (gFailures != 0)
|
||||
|
||||
Reference in New Issue
Block a user