test_sanitize_doxygen_text_repairs_invalid_utf8¶
Tests › tests/test_build_docs_db.py
What this test is for
Why it exists
doxygen writes descriptions straight from source comments into its sqlite output; a non-UTF-8 comment lands as raw invalid bytes in a TEXT column. sanitize_doxygen_text must repair them in place (matching the docs server's read-side errors='replace') and leave clean rows untouched.
Verifies REQ-DDB-PIPE-001 REQ-DDB-PIPE-010
Given
db = tmp_path / "doxy.db"conn = sqlite3.connect(str(db))
5 more
for tbl in ("memberdef", "compounddef"): conn.execute(f"CREATE TABLE {tbl} (briefdescription TEXT, detaileddescription TEXT)")conn.execute("INSERT INTO memberdef VALUES (?, ?)", ("clean brief", "clean detail"))conn.execute( "INSERT INTO memberdef VALUES (?, ?)", (b"bad \xa4 brief", b"detail \xa4\xa4 here"), )conn.commit()conn.close()
When
fixed = sanitize_doxygen_text(db)check = sqlite3.connect(str(db))check.text_factory = bytes
3 more
rows = check.execute( "SELECT briefdescription, detaileddescription FROM memberdef ORDER BY rowid" ).fetchall()check.close()for brief, detail in rows: brief.decode("utf-8") detail.decode("utf-8")
Then
- ✓ fixed equals 2
- ✓ rows[0] equals (b"clean brief", b"clean detail")
- ✓ rows[1][0] contains b"\xef\xbf\xbd"
tests/test_build_docs_db.py:122 · its file's page
What it checks (3)
assert fixed == 2, "both poisoned columns of the bad row should be repaired"observessanitize_doxygen_textviafixedassert rows[0] == (b"clean brief", b"clean detail")not attributedassert b"\xef\xbf\xbd" in rows[1][0]not attributed
Where the product reaches it
No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.
Call flow
What it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Requirements it verifies (2)
| requirement | linked by | implementers exercised |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | unknown |
| REQ-DDB-PIPE-010 | catalog | unknown |
Also reaches 1 requirement
Its run touches their code; that is reach, not proof.
- REQ-DDB-INDEX-001 measured