\documentclass[a4paper]{article}
\usepackage{german}
\usepackage[utf8]{inputenc}

\usepackage{pgfplots}
\usepackage{pgfplots.assert}

\usetikzlibrary{intersections}
\usetikzlibrary{fillbetween}

\def\showPathSegment#1{%
	\begin{tikzpicture}
		\draw[help lines] plot coordinates {
			  (2,0) (3,1) (4,0) (5,1) (6,0)
		};

		\draw[help lines] plot coordinates {
			(0,1) (1,0) (2,0.5) (6,0.5)
		};

		\pgfsetcolor{blue}
		\expandafter\pgfsetpathandBB\csname #1\endcsname
		\pgfusepath{stroke}
	\end{tikzpicture}
}

\begin{document}

	\makeatletter
\begin{tikzpicture}

	% this here is the test case of
	% unittest_intersections_lib_3.00_3.tex :
	\draw[name path global=A] plot coordinates {
		  (2,0) (3,1) (4,0) (5,1) (6,0)
	};

	\draw[name path global=B] plot coordinates {
		(0,1) (1,0) (2,0.5) (6,0.5)
	};

	\pgfintersectionofpaths%
		{%
			\expandafter\pgfsetpath\csname tikz@intersect@path@name@A\endcsname%
		}%
		{%
			\expandafter\pgfsetpath\csname tikz@intersect@path@name@B\endcsname%
		}%

	\pgfplotsassertequalstok{4}{\pgfintersectionsolutions}{}

	\foreach \i in {1,2,...,\pgfintersectionsolutions} {%
		\begingroup
		\pgftransformshift{%
			\pgfpointintersectionsolution{\i}%
			\message{TEST OUPUT: solution \i = \the\pgf@x, \the\pgf@y^^J}%
		}%
		\node at (0,0) {\i};
		\endgroup
	}%
\end{tikzpicture}

	\pgfintersectionofpaths%
		{%
			\expandafter\pgfsetpath\csname tikz@intersect@path@name@A\endcsname%
		}%
		{%
			\expandafter\pgfsetpath\csname tikz@intersect@path@name@B\endcsname%
		}%
	\pgfpointintersectionsolution{1}%
	\pgfplotsassertequalstok{\the\pgf@x, \the\pgf@y}{71.13918pt, 14.2278pt}{solution 1}
	\pgfpointintersectionsolution{2}%
	\pgfplotsassertequalstok{\the\pgf@x, \the\pgf@y}{99.59497pt, 14.2278pt}{solution 2}
	\pgfpointintersectionsolution{3}%
	\pgfplotsassertequalstok{\the\pgf@x, \the\pgf@y}{128.05057pt, 14.2278pt}{solution 3}
	\pgfpointintersectionsolution{4}%
	\pgfplotsassertequalstok{\the\pgf@x, \the\pgf@y}{156.50636pt, 14.2278pt}{solution 4}


	\pgfintersectiongetsolutionsegmentindices{1}\Aindex\Bindex
	\pgfplotsassertequalstok{0}{\Aindex}{solution 1 path A}
	\pgfplotsassertequalstok{2}{\Bindex}{solution 1 path B}
	
	\pgfintersectiongetsolutionsegmentindices{2}\Aindex\Bindex
	\pgfplotsassertequalstok{1}{\Aindex}{solution 2 path A}
	\pgfplotsassertequalstok{2}{\Bindex}{solution 2 path B}

	\pgfintersectiongetsolutionsegmentindices{3}\Aindex\Bindex
	\pgfplotsassertequalstok{2}{\Aindex}{solution 3 path A}
	\pgfplotsassertequalstok{2}{\Bindex}{solution 3 path B}

	\pgfintersectiongetsolutionsegmentindices{4}\Aindex\Bindex
	\pgfplotsassertequalstok{3}{\Aindex}{solution 4 path A}
	\pgfplotsassertequalstok{2}{\Bindex}{solution 4 path B}


%\tracingcommands=2\tracingmacros=2
 A:
	\message{Insert intersections into FIRST argument of \string\pgfintersectionofpaths:^^J}
	{
	\def\inputValue{%
		\pgfsyssoftpath@movetotoken {56.90549pt}{0.0pt}%
		\pgfsyssoftpath@linetotoken {85.35823pt}{28.45274pt}%
		\pgfsyssoftpath@linetotoken {113.81097pt}{0.0pt}%
		\pgfsyssoftpath@linetotoken {142.26372pt}{28.45274pt}%
		\pgfsyssoftpath@linetotoken {170.71646pt}{0.0pt}%
	}
	\pgfplotsassertequalstok{\meaning\pgf@intersect@path@a}{\meaning\inputValue}{The input path}

	\message{INPUT : \meaning\pgf@intersect@path@a^^J}%

	\pgfcomputeintersectionsegments{1}

	\message{OUTPUT: \meaning\pgfretval^^J}%
	\expandafter\def\csname expected@a@0\endcsname{%
		\pgfsyssoftpath@movetotoken {56.90549pt}{0.0pt}%
\pgfsyssoftpath@linetotoken{71.13918pt}{14.2278pt}%
	}
	\expandafter\def\csname expected@a@1\endcsname{%
		\pgfsyssoftpath@movetotoken{71.13918pt}{14.2278pt}%
		\pgfsyssoftpath@linetotoken {85.35823pt}{28.45274pt}%
\pgfsyssoftpath@linetotoken{99.59497pt}{14.2278pt}%
	}
	\expandafter\def\csname expected@a@2\endcsname{%
		\pgfsyssoftpath@movetotoken{99.59497pt}{14.2278pt}%
		\pgfsyssoftpath@linetotoken {113.81097pt}{0.0pt}%
\pgfsyssoftpath@linetotoken{128.05057pt}{14.2278pt}%
	}
	\expandafter\def\csname expected@a@3\endcsname{%
		\pgfsyssoftpath@movetotoken{128.05057pt}{14.2278pt}%
		\pgfsyssoftpath@linetotoken {142.26372pt}{28.45274pt}%
\pgfsyssoftpath@linetotoken{156.50636pt}{14.2278pt}%
	}
	\expandafter\def\csname expected@a@4\endcsname{%
		\pgfsyssoftpath@movetotoken{156.50636pt}{14.2278pt}%
		\pgfsyssoftpath@linetotoken {170.71646pt}{0.0pt}%
	}
	\pgfplotsassertequalstok{\pgfretval}{5}{expected value was wrong}
	\pgfplotsassertequalstok{\expandafter\meaning\csname pgf@intersect@path@split@a@0\endcsname}{\expandafter\meaning\csname expected@a@0\endcsname}{expected value was wrong}
	\pgfplotsassertequalstok{\expandafter\meaning\csname pgf@intersect@path@split@a@1\endcsname}{\expandafter\meaning\csname expected@a@1\endcsname}{expected value was wrong}
	\pgfplotsassertequalstok{\expandafter\meaning\csname pgf@intersect@path@split@a@2\endcsname}{\expandafter\meaning\csname expected@a@2\endcsname}{expected value was wrong}
	\pgfplotsassertequalstok{\expandafter\meaning\csname pgf@intersect@path@split@a@3\endcsname}{\expandafter\meaning\csname expected@a@3\endcsname}{expected value was wrong}
	\pgfplotsassertequalstok{\expandafter\meaning\csname pgf@intersect@path@split@a@4\endcsname}{\expandafter\meaning\csname expected@a@4\endcsname}{expected value was wrong}

	0 : \showPathSegment{pgf@intersect@path@split@a@0}

	1 : \showPathSegment{pgf@intersect@path@split@a@1}

	2 : \showPathSegment{pgf@intersect@path@split@a@2}

	3 : \showPathSegment{pgf@intersect@path@split@a@3}

	4 : \showPathSegment{pgf@intersect@path@split@a@4}


	}

 B:

	\message{Insert intersections into SECOND argument of \string\pgfintersectionofpaths:^^J}
	{
	\def\inputValue{%
		\pgfsyssoftpath@movetotoken {0.0pt}{28.45274pt}%
		\pgfsyssoftpath@linetotoken {28.45274pt}{0.0pt}%
		\pgfsyssoftpath@linetotoken {56.90549pt}{14.22636pt}%
		\pgfsyssoftpath@linetotoken {170.71646pt}{14.22636pt}%
	}
	\pgfplotsassertequalstok{\meaning\pgf@intersect@path@b}{\meaning\inputValue}{The input path}

	\message{INPUT : \meaning\pgf@intersect@path@b^^J}%

	\pgfcomputeintersectionsegments{2}

	\message{OUTPUT: \meaning\pgfretval^^J}%
	\expandafter\def\csname expected@b@0\endcsname{%
		\pgfsyssoftpath@movetotoken {0.0pt}{28.45274pt}%
		\pgfsyssoftpath@linetotoken {28.45274pt}{0.0pt}%
		\pgfsyssoftpath@linetotoken {56.90549pt}{14.22636pt}%
\pgfsyssoftpath@linetotoken{71.13918pt}{14.2278pt}%
	}
	\expandafter\def\csname expected@b@1\endcsname{%
		\pgfsyssoftpath@movetotoken{71.13918pt}{14.2278pt}%
\pgfsyssoftpath@linetotoken{99.59497pt}{14.2278pt}%
	}
	\expandafter\def\csname expected@b@2\endcsname{%
		\pgfsyssoftpath@movetotoken{99.59497pt}{14.2278pt}%
\pgfsyssoftpath@linetotoken{128.05057pt}{14.2278pt}%
	}
	\expandafter\def\csname expected@b@3\endcsname{%
		\pgfsyssoftpath@movetotoken{128.05057pt}{14.2278pt}%
\pgfsyssoftpath@linetotoken{156.50636pt}{14.2278pt}%
	}
	\expandafter\def\csname expected@b@4\endcsname{%
		\pgfsyssoftpath@movetotoken{156.50636pt}{14.2278pt}%
		\pgfsyssoftpath@linetotoken {170.71646pt}{14.22636pt}%
	}
	\pgfplotsassertequalstok{\pgfretval}{5}{expected value was wrong}
	\pgfplotsassertequalstok{\expandafter\meaning\csname pgf@intersect@path@split@b@0\endcsname}{\expandafter\meaning\csname expected@b@0\endcsname}{expected value was wrong}
	\pgfplotsassertequalstok{\expandafter\meaning\csname pgf@intersect@path@split@b@1\endcsname}{\expandafter\meaning\csname expected@b@1\endcsname}{expected value was wrong}
	\pgfplotsassertequalstok{\expandafter\meaning\csname pgf@intersect@path@split@b@2\endcsname}{\expandafter\meaning\csname expected@b@2\endcsname}{expected value was wrong}
	\pgfplotsassertequalstok{\expandafter\meaning\csname pgf@intersect@path@split@b@3\endcsname}{\expandafter\meaning\csname expected@b@3\endcsname}{expected value was wrong}
	\pgfplotsassertequalstok{\expandafter\meaning\csname pgf@intersect@path@split@b@4\endcsname}{\expandafter\meaning\csname expected@b@4\endcsname}{expected value was wrong}

	0 : \showPathSegment{pgf@intersect@path@split@b@0}

	1 : \showPathSegment{pgf@intersect@path@split@b@1}

	2 : \showPathSegment{pgf@intersect@path@split@b@2}

	3 : \showPathSegment{pgf@intersect@path@split@b@3}

	4 : \showPathSegment{pgf@intersect@path@split@b@4}

	}
\end{document}

