The test results depend on many factors (how long you used, in what amounts, when did you use for the last time, what type of substance, what quality (pureness) and what type of substance, your own metabolic rhythm, body weight, renal function, etc. etc.).
Another reason is the validity of the test being used (sensitivity - how well the test detects the presence of a condition, and specificity - how well the test rules out the condition).
Therefore, one can probably test positive on cocaine even though he/she has not taken it (false-positive result) because such tests are never 100% sensitive or 100% negative (in the context when the substance is not so pure, so the concentration is not high).
This depends on the thresholds the test uses (cut-off points for differentiating between the presence or absence of a condition).
The same goes for THC
testing, which resulted negative even though it is thought to be positive for up to 90 days after use.
Therefore, the parameters of the tests used together with the factors mentioned above could yield a false-positive result or a false negative result.
The solution is to be tested again or to undertake a more robust (more sensitive) testing option.
Hope I have answered your query. Let me know if I can assist you further.
Dr Ervin Toçi, General & Family Physician