Brief searching suggests that proteins are measured with a nitrogen content test and fats are determined by mixing the food with a non-polar solvent to see how much dissolves. Carbohydrates seem trickier and I haven't found a great explanation. Water solubility might work once the other components are removed.