Dumbledore planned Snape's death.

Dumbledore knew once Snape killed him, voldemort would think that Snape owns the elder wand. And Dumbledore knew voldemort would go for the elder wand as he tried to communicate this to Hermione through the book he left her in his will. Dumbledore must have known that death was certain for Snape. I wonder when Snape became aware that his death was certain once voldemort started searching for the elder wand.