If you doubt your salvation, it does not mean you are not saved. It means that you do not sufficiently understand and believe what the Lord Jesus Christ has accomplished on the cross to ensure your salvation. When you trust in what Christ has done and not your own faithfulness, then you will stop doubting. In other words, if your salvation depends upon your faithfulness and your goodness, then you should doubt.
Jesus fulfilled the law perfectly by never sinning (1 Pet. 2:22). He bore our sins in His body on the cross (1 Pet. 2:24). Jesus did everything that is necessary for us to be saved. We receive this salvation by faith in Christ (Ephesians 2:8-9). You must realize that your salvation does not depend upon your faithfulness. Instead, it depends on God's faithfulness. The Bible says that when we are faithless that He remains faithful (2 Tim. 2:13). He has promised to give us eternal life (John 3:16, 10:27-28), and God cannot break His promises.
Luke 11:10-13, “For everyone who asks, receives; and he who seeks, finds; and to him who knocks, it shall be opened. 11 “Now suppose one of you fathers is asked by his son for a fish; he will not give him a snake instead of a fish, will he? 12 “Or if he is asked for an egg, he will not give him a scorpion, will he? 13 “If you then, being evil, know how to give good gifts to your children, how much more shall your heavenly Father give the Holy Spirit to those who ask Him?”
In the land where Jesus lived and taught, there was a fish that resembled a snake. There was a scorpion that, when curled up, took the shape of an egg. Jesus is telling us that God will not fake us out when we ask Him for salvation. He does not play tricks on us. He does not deceive us. He is faithful and true. And even though we may doubt His word, God is still true. Even though we may wonder if we are saved when we look into our own hearts and see the failures, the sins we cannot master, the selfishness that seems to so easily raise its ugly head, we must realize that God saved us because of how good He is. He has always known what we were, what we are, and what we will be. And in spite of this, He chose to love us to save us.
Therefore, to trust God means to trust His love, and perfect love casts out fear (1 John 4:18).
2 Cor. 13:5 says to test yourselves.
“Test yourselves to see if you are in the faith; examine yourselves! Or do you not recognize this about yourselves, that Jesus Christ is in you--unless indeed you fail the test?” (2 Cor. 13:5).
Notice what Paul says in the above verse. He tells the Corinthians to test themselves--to examine themselves. This would not be necessary if it were a sin to doubt. After all, why would we test ourselves to see if we were in the faith if we don't have any doubt? Also, notice that Paul is saying that Jesus was in them. In other words, they were definitely Christians. So, Paul is telling them to examine themselves to make sure they're in the faith but that they needed to realize that Christ was indeed in them. It is only those who are in the faith, who are saved, who could really examine themselves to see if they are in. After all, the unsaved do not examine themselves to see if they are Christians.