For any (sane) code, when you generate an RSA key you generate the private key then the public key is derived from it.
The onion address is the base32 encoded first 10 bytes of the sha1 sum of the asn1 encoded public key. So the private key derives directly to the public key and the address derives directly from the public key.
So, to ensure that the address matches, just generate the private key, derive the public key from it, encode the public key into it's asn1 encoding, sha1 hash the whole key, take the first 10 bytes of the sum and encode them into base32, giving you 16 base32 digits.
There is no guarantee that a given address maps to a private key, since the hashing process loses information (the set of possible public keys is larger than the set of possible 10 byte truncated sha1 values) it's possible that two distinct private keys generate two distinct public keys which happen to share the same first 10 bytes of their hash. There is no one-to-one mapping between the two values, you can ensure that a specific private key maps to a specific address, but not the other way around.