Shedding more light on the issue, Federer, a 17-time Grand Slam champion, revealed that he has been tested only once in 10 years of regular training trips to his Dubai base.
He said that he was surprised when Sharapova made her confession, but added that the incident shows that even top players can get caught in the system.
Sharapova has been provisionally suspended from the sport by the International Tennis Federation after revealing that she had tested positive for the banned substance meldonium.
Sharapova's major sponsors Nike, Tag Heuer and Porsche have all distanced themselves from her since her announcement.
The Russian tennis star said that she had been taking the drug since 2006 legally for years for health reasons.
Meldonium was placed on the banned list by the World Anti-Doping Agency from this year.