Release v0.6.18: verify conversion results and log problems only
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "ocr.h"
|
||||
#include "richtext.h"
|
||||
#include "storage.h"
|
||||
#include "diagnostics.h"
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
@@ -44,6 +45,34 @@ int main(int argc, char **argv)
|
||||
}
|
||||
try
|
||||
{
|
||||
{
|
||||
ks::DiagnosticJson record{{"attempt", "42"}, {"process", "editor.exe"}, {"command", "Convert / cycle"},
|
||||
{"source", "English"}, {"target", "Ukrainian"}, {"outcome", "Original text remained"},
|
||||
{"problem", true}, {"verification", "read-back-via-accessibility"},
|
||||
{"original", "hello\n\"quoted\""}, {"expected", ks::utf8(L"привіт")}, {"actual", "hello"},
|
||||
{"context", "copy\npaste"}};
|
||||
auto encoded = L"2026-10-31 12:00:00 Operation " + ks::wide(record.dump());
|
||||
auto rows = ks::parseOperationLog(encoded);
|
||||
require(rows.size() == 1 && rows[0].process == L"editor.exe" && rows[0].problem,
|
||||
"structured operation is one filterable row");
|
||||
require(rows[0].details.find(L"привіт") != std::wstring::npos &&
|
||||
rows[0].details.find(L"copy\r\npaste") != std::wstring::npos,
|
||||
"operation details preserve Unicode and normalize multiline text");
|
||||
record["problem"] = false;
|
||||
record["outcome"] = "Paste verified";
|
||||
rows = ks::parseOperationLog(encoded + L"\n2026-10-31 12:00:01 Operation " + ks::wide(record.dump()));
|
||||
require(rows.size() == 2 && !rows[1].problem, "verified operations remain distinguishable from problems");
|
||||
rows = ks::parseOperationLog(L"old incident\n first stage\n second stage\n2026-10-31 Operation {broken");
|
||||
require(rows.size() == 2 && rows[0].details.find(L"second stage") != std::wstring::npos &&
|
||||
rows[1].details.find(L"{broken") != std::wstring::npos,
|
||||
"legacy context is grouped and malformed records remain inspectable");
|
||||
require(ks::conversionReadbackOutcome(L"new", L"old", L"new") == L"Paste verified",
|
||||
"expected readback verifies paste");
|
||||
require(ks::conversionReadbackOutcome(L"old", L"old", L"new") == L"Original text remained",
|
||||
"original readback identifies unchanged editor text");
|
||||
require(ks::conversionReadbackOutcome(L"other", L"old", L"new") == L"Readback differs",
|
||||
"unexpected readback is never reported as success");
|
||||
}
|
||||
require(ks::diagnosticText(L"word") == L"\"word\" units=4 truncated=0",
|
||||
"diagnostic word preserved");
|
||||
require(ks::diagnosticText(L"\"\\\n\r\t") ==
|
||||
|
||||
Reference in New Issue
Block a user