Before a generic medication is placed on the market, it must undergo stringent testing to ensure it is the same quality etc. as the original medication.
Pharmacists cannot dispense a generic medication if it is not what's called "flagged" as being proven the same as the medication you have been prescribed.
Also, if your doctor does not wish you to have the generic product, they will indicate this on your prescription. If you have any concerns with being dispensed the generic, please discuss this with your doctor and pharmacist.