Add test for #11881

Closes #11881.

This code has been copied from the original issue and updated for
modern Rust APIs.