For $f(x)>0 \hspace{5 mm} \forall\hspace{1 mm}x $ such that $-\infty<x<\infty$, when the following equality would not hold true ?
$$\begin{aligned} \int_{-\infty}^{\infty}xf(x)dx\stackrel{?}{=}\int_{0}^{\infty}xf(x)dx-\int_{-\infty}^{0}|x|f(x)dx \end{aligned}$$
Motivation: mean of Cauchy distrbution is undefined.
If $x < 0$, then $|x| = -x$ and so $x = -|x|$. Therefore,
$\displaystyle\int_{-\infty}^{\infty}xf(x)\,dx$
$= \displaystyle\int_{0}^{\infty}xf(x)\,dx + \int_{-\infty}^{0}xf(x)\,dx$
$= \displaystyle\int_{0}^{\infty}xf(x)\,dx + \int_{-\infty}^{0}-|x|f(x)\,dx$
$= \displaystyle\int_{0}^{\infty}xf(x)\,dx - \int_{-\infty}^{0}|x|f(x)\,dx$,
provided that all the integrals converge.
However, if either $\displaystyle\int_{0}^{\infty}xf(x)\,dx$ or $\displaystyle\int_{-\infty}^{0}|x|f(x)\,dx$ doesn't converge, as in the case of the Cauchy distribution $f(x) = \dfrac{1}{\pi(1+x^2)}$, then of course, this isn't valid.