It also depends on if you are in a consent to search state or not. Some states the cops do not need reasonable cause to search, they can do it on a whim.

But from what you said, they didnt have any probably cause to warrant a search of your vehicle. Alot of cops ask because they hope for people to answer like you did, or get scared and fuck up. Play it calm and cool, dont be a dick to the cops, and everything should be ok.

They can only do what the law allows them to, keep up on your local laws, and you will be alot safer in the long run.