This will match exactly if the time domain signal is properly recreated from the Inverse DFT as expressed in the sine and cosine form. In this case the DFT and inverse DFT are transform pairs so can be expressed in either domain with no loss of information.
Here is the general form for (painfully) computing the inverse DFT from sines and cosines which helps show the mathematical utility of always using the complex form of frequency when dealing with complex sinals ($e^{j\omega t}$ instead of $\cos(\omega t)+j\sin(\omega t)$). (And ultimately using the FFT algorithm and not the direct DFT equation is much simpler but this is insightful).
Given the Inverse DFT as:
$$x_n = \sum_{k=0}^{N-1}X_ke^{j2\pi nk/N}$$
When N is odd this is equally of the form:
$$x_n = X_0 + \sum_{k=1}^{(N-1)/2}\big(X_ke^{j2\pi nk/N}+ X_{[N-k]}e^{-j2\pi nk/N}\big)$$
If $x_n$ was real then $X_{[N-k]} = X^*_k$ leading to further simplifications, but in general for complex $x_n$ the above is given as below using $\omega_n = 2\pi n/N$ and the relationship $A e^{j\theta} = A\cos(\theta)+jA\sin(\theta)$:
$$x_n = X_0+\sum_{k=1}^{(N-1)/2}(X_k+X_{[N-k]})cos(k \omega_n)+j\sum_{k=1}^{(N-1)/2}(X_k-X_{[N-k]})sin(k\omega_n)$$
When N is even the inverse DFT is of the form:
$$x_n = X_0+\sum_{k=1}^{N/2-1}\big(X_ke^{j2\pi nk/N}+ X_{[N-k]}e^{-j2\pi nk/N}\big)+ X_{[N/2]}e^{j\pi n}$$
Which similarly becomes:
$$x_n = X_0 +(-1)^nX_{[N/2]} \ldots \\+ \sum_{k=1}^{N/2-1}(X_k+X_{[N-k]})cos(k \omega_n)+j\sum_{k=1}^{N/2-1}(X_k-X_{[N-k]})sin(k\omega_n)$$
In the OP's case where only the first $m$ frequencies of the DFT are used (corrresponding to $X_0$ when $m=0$, $X_1$ and $X_{[N-1]}$ when $m=1$ etc... and notably $X_{[N/2]}=0$, then regardless of $N$ is odd or even the result is:
$$x_n = X_0 + \sum_{k=1}^m(X_k+X_{[N-k]})cos(k \omega_n)+j\sum_{k=1}^m(X_k-X_{[N-k]})sin(k\omega_n)$$
I also want to add this important additional note that this is actually a very poor way to implement a filter (it is called the frequency sampling approach, where the coefficients of the implemented FIR filter would be the IFFT of this frequency domain mask). It will indeed provide the results exactly as given in frequency at each bin center (in this case pass each frequency at the bin centers below 10 Hz with magnitude 1, and each frequency above 10 Hz with magnitude 0), but for all frequencies in between the bin centers both in the passband and stopband it will have a lot more deviation from other optimized filter design approaches (such as least squares and equi-ripple filter design).
This response at this post by @hotpaw2 explains this further in more detail:
Why is it a bad idea to filter by zeroing out FFT bins?.