Determining health risks associated with carpets
I think you need to know what you're looking for. Testing for mold is about all you can do, without sending samples off to a lab. $200 (homeallergentesting.com) is an expensive way to be told: yes, you own a cat. 


If it's new carpet, it may still be offgassing.
If it's old carpet, especially a previous owner's, toss it without a second thought.


Disclaimer: I've never 'tested for' anything. I just proceed with the solution as if it were the problem (and my solution to anything wrong with installed carpet is putting it in the dumpster, where it belonged in the first place).