\documentclass{article}

\usepackage{pgfplots}

\usepackage{pgfplots.assert}%
\usepgfplotslibrary{fillbetween}

\begin{document}

{

\makeatletter
\tracingmacros=2 \tracingcommands=2
\message{CASE: inner moveto^^J}
\def\subject {\pgfsyssoftpath@movetotoken {1pt}{1pt}\pgfsyssoftpath@linetotoken {5pt}{1pt}\pgfsyssoftpath@movetotoken {1pt}{1pt}\pgfsyssoftpath@linetotoken {1pt}{2pt}}
\def\expected{\pgfsyssoftpath@movetotoken {1pt}{1pt}\pgfsyssoftpath@linetotoken {5pt}{1pt}\pgfsyssoftpath@linetotoken {1pt}{1pt}\pgfsyssoftpath@linetotoken {1pt}{2pt}}

\pgfpathfillbetween@connect@inner@movetos\subject
\pgfplotsassertequalstoknoexpand{\expected}{\subject}{Fails without args.}%


\message{CASE: two inner movetos adjacent to each other^^J}
\def\subject {\pgfsyssoftpath@movetotoken {1pt}{1pt}\pgfsyssoftpath@linetotoken {5pt}{1pt}\pgfsyssoftpath@movetotoken {1pt}{1pt}\pgfsyssoftpath@movetotoken{2pt}{2pt}\pgfsyssoftpath@linetotoken {1pt}{2pt}}
\def\expected{\pgfsyssoftpath@movetotoken {1pt}{1pt}\pgfsyssoftpath@linetotoken {5pt}{1pt}\pgfsyssoftpath@linetotoken {2pt}{2pt}\pgfsyssoftpath@linetotoken {1pt}{2pt}}

\pgfpathfillbetween@connect@inner@movetos\subject
\pgfplotsassertequalstoknoexpand{\expected}{\subject}{Fails without args.}%

\message{CASE: three inner movetos adjacent to each other^^J}
\def\subject {\pgfsyssoftpath@movetotoken {1pt}{1pt}\pgfsyssoftpath@linetotoken {5pt}{1pt}\pgfsyssoftpath@movetotoken {1pt}{1pt}\pgfsyssoftpath@movetotoken{2pt}{2pt}\pgfsyssoftpath@movetotoken{3pt}{3pt}\pgfsyssoftpath@linetotoken {1pt}{2pt}}
\def\expected{\pgfsyssoftpath@movetotoken {1pt}{1pt}\pgfsyssoftpath@linetotoken {5pt}{1pt}\pgfsyssoftpath@linetotoken {3pt}{3pt}\pgfsyssoftpath@linetotoken {1pt}{2pt}}

\pgfpathfillbetween@connect@inner@movetos\subject
\pgfplotsassertequalstoknoexpand{\expected}{\subject}{Fails without args.}%

\message{CASE: trailing moveto^^J}
\def\subject {\pgfsyssoftpath@movetotoken {1pt}{1pt}\pgfsyssoftpath@linetotoken {5pt}{1pt}\pgfsyssoftpath@linetotoken {1pt}{1pt}\pgfsyssoftpath@movetotoken {2pt}{1pt}}
\def\expected{\pgfsyssoftpath@movetotoken {1pt}{1pt}\pgfsyssoftpath@linetotoken {5pt}{1pt}\pgfsyssoftpath@linetotoken {1pt}{1pt}}

\pgfpathfillbetween@connect@inner@movetos\subject
\pgfplotsassertequalstoknoexpand{\expected}{\subject}{Fails without args.}%

\message{CASE: 2 trailing moveto^^J}
\def\subject {\pgfsyssoftpath@movetotoken {1pt}{1pt}\pgfsyssoftpath@linetotoken {5pt}{1pt}\pgfsyssoftpath@linetotoken {1pt}{1pt}\pgfsyssoftpath@movetotoken {2pt}{1pt}\pgfsyssoftpath@movetotoken{2pt}{2pt}}
\def\expected{\pgfsyssoftpath@movetotoken {1pt}{1pt}\pgfsyssoftpath@linetotoken {5pt}{1pt}\pgfsyssoftpath@linetotoken {1pt}{1pt}}

\pgfpathfillbetween@connect@inner@movetos\subject
\pgfplotsassertequalstoknoexpand{\expected}{\subject}{Fails without args.}%

OK.

}

\end{document}

