Reminds me of the round trip property.
So, the other option is all the work with property-based testing and this is available for many languages already
There’s actually quite a few categories. I posted a survey paper covering four of them here:
One concept this is similar to is a “test oracle”, which always gives the correct output for any input but can’t be used in your production code. For example, it could be impractically slow, written in the wrong language, only ‘work’ for a subset of inputs, etc. Once you have a test oracle, though, your idea translates to testing that for a range of random inputs, your code matches the test oracle.
One place where this works well is when refactoring internals, because then your oracle is the original implementation.