Plan save-version targets in app core
This commit is contained in:
@@ -143,6 +143,62 @@ void document_file_write_prompts_only_for_existing_targets(pp::tests::Harness& h
|
||||
== pp::app::DocumentFileWriteDecision::prompt_overwrite);
|
||||
}
|
||||
|
||||
void document_version_target_starts_at_first_version(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto target = pp::app::find_next_document_version_target(
|
||||
"D:/Paint",
|
||||
"demo",
|
||||
[](const std::string&) { return false; });
|
||||
PP_EXPECT(harness, target);
|
||||
PP_EXPECT(harness, target.value().name == "demo.01");
|
||||
PP_EXPECT(harness, target.value().path == "D:/Paint/demo.01.ppi");
|
||||
}
|
||||
|
||||
void document_version_target_increments_existing_suffix(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto target = pp::app::find_next_document_version_target(
|
||||
"D:/Paint",
|
||||
"demo.07",
|
||||
[](const std::string&) { return false; });
|
||||
PP_EXPECT(harness, target);
|
||||
PP_EXPECT(harness, target.value().name == "demo.08");
|
||||
PP_EXPECT(harness, target.value().path == "D:/Paint/demo.08.ppi");
|
||||
}
|
||||
|
||||
void document_version_target_skips_existing_paths(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto target = pp::app::find_next_document_version_target(
|
||||
"D:/Paint",
|
||||
"demo",
|
||||
[](const std::string& path) {
|
||||
return path == "D:/Paint/demo.01.ppi" || path == "D:/Paint/demo.02.ppi";
|
||||
});
|
||||
PP_EXPECT(harness, target);
|
||||
PP_EXPECT(harness, target.value().name == "demo.03");
|
||||
PP_EXPECT(harness, target.value().path == "D:/Paint/demo.03.ppi");
|
||||
}
|
||||
|
||||
void document_version_target_preserves_legacy_nonnumeric_suffix_handling(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto target = pp::app::find_next_document_version_target(
|
||||
"D:/Paint",
|
||||
"demo.ab",
|
||||
[](const std::string&) { return false; });
|
||||
PP_EXPECT(harness, target);
|
||||
PP_EXPECT(harness, target.value().name == "demo.01");
|
||||
PP_EXPECT(harness, target.value().path == "D:/Paint/demo.01.ppi");
|
||||
}
|
||||
|
||||
void document_version_target_reports_when_no_slots_remain(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto target = pp::app::find_next_document_version_target(
|
||||
"D:/Paint",
|
||||
"demo.98",
|
||||
[](const std::string&) { return false; });
|
||||
PP_EXPECT(harness, !target);
|
||||
PP_EXPECT(harness, target.status().code == pp::foundation::StatusCode::out_of_range);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -162,5 +218,12 @@ int main()
|
||||
harness.run("document file target rejects empty name", document_file_target_rejects_empty_name);
|
||||
harness.run("document file target builds legacy ppi path", document_file_target_builds_legacy_ppi_path);
|
||||
harness.run("document file write prompts only for existing targets", document_file_write_prompts_only_for_existing_targets);
|
||||
harness.run("document version target starts at first version", document_version_target_starts_at_first_version);
|
||||
harness.run("document version target increments existing suffix", document_version_target_increments_existing_suffix);
|
||||
harness.run("document version target skips existing paths", document_version_target_skips_existing_paths);
|
||||
harness.run(
|
||||
"document version target preserves legacy nonnumeric suffix handling",
|
||||
document_version_target_preserves_legacy_nonnumeric_suffix_handling);
|
||||
harness.run("document version target reports when no slots remain", document_version_target_reports_when_no_slots_remain);
|
||||
return harness.finish();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user