test_sanitize_doxygen_text_repairs_invalid_utf8

Tests › tests/test_build_docs_db.py

passed Passed in the packaged run.

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

  1. db = tmp_path / "doxy.db"
  2. conn = sqlite3.connect(str(db))
5 more
  1. for tbl in ("memberdef", "compounddef"): conn.execute(f"CREATE TABLE {tbl} (briefdescription TEXT, detaileddescription TEXT)")
  2. conn.execute("INSERT INTO memberdef VALUES (?, ?)", ("clean brief", "clean detail"))
  3. conn.execute( "INSERT INTO memberdef VALUES (?, ?)", (b"bad \xa4 brief", b"detail \xa4\xa4 here"), )
  4. conn.commit()
  5. conn.close()
→

When

  1. fixed = sanitize_doxygen_text(db)
  2. check = sqlite3.connect(str(db))
  3. check.text_factory = bytes
3 more
  1. rows = check.execute( "SELECT briefdescription, detaileddescription FROM memberdef ORDER BY rowid" ).fetchall()
  2. check.close()
  3. for brief, detail in rows: brief.decode("utf-8") detail.decode("utf-8")
→

Then

  1. ✓ fixed equals 2
  2. ✓ rows[0] equals (b"clean brief", b"clean detail")
  3. ✓ rows[1][0] contains b"\xef\xbf\xbd"

tests/test_build_docs_db.py:122 · its file's page

What it checks (3)

  1. assert fixed == 2, "both poisoned columns of the bad row should be repaired" observes sanitize_doxygen_text via fixed
  2. assert rows[0] == (b"clean brief", b"clean detail") not attributed
  3. assert 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

test_sanitize_doxygen_text_repairs_invalid_utf8→sanitize_doxygen_text

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.

test_sanitize_doxygen_text_repairs_invalid_utf8 · 3 checkssanitize_doxygen_textREQ-DDB-INDEX-001 · measured

Requirements it verifies (2)

requirementlinked byimplementers exercised
REQ-DDB-PIPE-001catalogunknown
REQ-DDB-PIPE-010catalogunknown
Also reaches 1 requirement

Its run touches their code; that is reach, not proof.