Line through a box

I have a 3x3 box. I need to check if a line (which I have the starting and finishing points of) makes a “tic-tac-toe” line. I need to find if the line goes through 3 consecutive boxes. Right now I am checking every possibilities. How would I do this?