A G6PD test measures the levels of glucose-6-phosphate dehydrogenase, an enzyme that helps red blood cells (RBCs) function and protects them from harmful byproducts during infections or certain medications. A deficiency in G6PD, a sex-linked disorder affecting males while females are carriers, can make RBCs vulnerable to hemolysis, leading to anemia.