All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
If this was just a thought that came to your mind and then you rejected it, then you would not break the fast by this as Allaah has forgiven the whispers that arise in the hearts of the people of this nation until one acts upon them or talks about them.
Therefore, if this whisper that came to your mind was that you hesitated to break the fast, then your fasting is not invalidated according to the most correct opinion of the scholars, because in principle the intention of fasting is still there (valid until one interrupts it).
However, if you were fully determined to break the fast, then your fasting has become void according to the most correct opinion of the scholars, because the lacking of the intention which is a condition for the validity of fasting. In which case, if this fasting was an obligatory fasting [like a day of Ramadan], then you are obliged to make it up, and if it was optional, then if you intended to continue fasting after you had had the intention of breaking it, then your fasting is correct because observing a supererogatory fasting is permissible while making the intention by day, as is the view of the majority of the scholars .
However, some scholars are of the view that the intention must be made before Zawaal [before the sun is at its meridian] and some of them are of the view that the fasting is valid even if the intention was made after the sun is at its meridian.
Allaah Knows best.