The following function tests if the last word on the line is longer than the window width.
(defun too-long-p ()
"Returns t if last word on the line is longer than the window's
column width."
(save-excursion
(end-of-line)
(> (length (thing-at-point 'word))
(window-total-width))))
And here's a version that addresses the "both" issue you raised, but I suspect the former may be closer to what you want.
(defun too-long-p ()
"Returns t if last word on the line is longer than the window's
column width."
(save-excursion
(beginning-of-line)
(forward-word)
(and (eolp)
(> (length (thing-at-point 'word))
(window-total-width)))))
In response to the comments, try this one (although I can't recall if tabs break lines, so you may need to edit the regexp):
(defun too-long-p ()
"Returns t if last word on the line is longer than the window's
column width."
(save-excursion
(beginning-of-line)
(unless (re-search-forward "[ \t]"
(+ (point-at-bol) (window-total-width)) t)
(> (length (thing-at-point 'line)) (window-total-width)))))