The definition of fasting in Islam is abstaining from eating, drinking and sexual relations with the intention of worship from dawn to sunset. It is not permitted to eat or swallow anything while fasting, thus tasting something does not invalidate fasting. However, it is not a proper conduct to taste food without having a valid reason. Brushing teeth with a toothpaste while fasting is permissible as long as the person does not swallow it. Nevertheless, I would recommend you to brush your teeth without using toothpaste while fasting.