Given $$D = \{(x,y)\in R^2:0\leq y \leq 1-|x| \}$$
And joint distribution function:
$$ f_{X,Y}(x,y) = \begin{cases} 1 & (x,y)\in D \\ 0 & else \end{cases} $$
The exercise itself doesn't require to do that, but I tried to compute the marginal density functions of X and Y, just for practice, though something seems odd.
I started by plotting the region D:
And worked by definition:
$$ f_Y(y)=\int_{\infty}^{\infty}f_{X,Y}(x,y)dx=\int_{y-1}^{y+1}f_{X,Y}(x,y)dx = y+1-(y-1)=2 $$
$$ f_X(x)=\int_{\infty}^{\infty}f_{X,Y}(x,y)dy $$
$$ x<0: \\ f_X(x)=\int_{0}^{x+1}f_{X,Y}(x,y)dy=x+1 \\ x\geq 0: \\ f_X(x)=\int_{0}^{x-1}f_{X,Y}(x,y)dy=x-1 $$
So:
$$ f_X(x) = \begin{cases} x+1 & x<0 \\ x-1 & x\geq 0 \end{cases} $$
Are these correct? because I couldn't find a way to validate them. When I tried to integrate those densities over the whole region I got values $\ne1$ which implies that these are not valid density functions.
What have I done wrong?

$f_{Y}$ is right, but $f_{X}$ isn't.
$$f_{X} = \int_{0}^{1 - |x|} 1 \mathop{dy}$$