TITLE: Proof of $f = g \in L^1_{loc}$ if $f$ and $g$ act equally on $C_c^\infty$
QUESTION [5 upvotes]: Let $f$ and $g$ be locally integrable, say on $R^n$ (for arbitrary open domains, just extend trivially). Suppose
$\forall \phi \in C_c^\infty : \int f \phi dx = \int g \phi dx$.
Let $K = supp(\phi)$. If $f,g \in L^2(K)$, we see by Hilbert space theory $f = g$ almost everywhere, as the $C_c^\infty(K)$ is dense in $L^2(K)$.
So the theorem holds for $f,g \in L^2_{loc}$. But $L^\infty_{loc} \subset L^2_{loc}$ is dense in $L^1_{loc}$ (in the respective topology), hence we have $f = g$ almost everywhere even for $L^1_{loc}$.
I haven't seen this proof in literature, and I wonder whether there is a gap. If that is the case, do you know a better proof?

REPLY [4 votes]: Another way to do this is to let $\phi(x)$ be a smooth cutoff function equal to $1$ on some ball $B(a,r)$. Then your condition implies that the Fourier coefficient $\int_{R^n}(f(x) - g(x))\phi(x)e^{i\xi \cdot x}\,dx$ is zero for all $\xi \in R^n$. By the uniqueness theorem for the Fourier transform, $(f(x) - g(x))\phi(x) = 0$ a.e, so $f(x) = g(x)$ a.e. on the ball $B(a,r)$. This ball was arbitrary so $f(x) = g(x)$ a.e.