\input regression-test.tex
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzphysics.thermodynamics}
\usetikzlibrary{tikzphysics.fluids,tikzphysics.piston}
\newdimen\actual
\newdimen\error
\newcommand{\assertcoord}[5]{%
 \pgfextractx{\actual}{\pgfpointanchor{#1}{#2}}\error=\actual\advance\error by-#3\relax
 \ifdim\error<0pt\error=-\error\fi
 \ifdim\error<.04pt\TYPE{PASS: #5 x}\else\TYPE{FAIL: #5 x got \the\actual}\fi
 \pgfextracty{\actual}{\pgfpointanchor{#1}{#2}}\error=\actual\advance\error by-#4\relax
 \ifdim\error<0pt\error=-\error\fi
 \ifdim\error<.04pt\TYPE{PASS: #5 y}\else\TYPE{FAIL: #5 y got \the\actual}\fi}

\newdimen\expectedx
\newdimen\expectedy
\newcommand{\sameanchor}[4]{%
 \pgfextractx{\expectedx}{\pgfpointanchor{#1}{#3}}%
 \pgfextracty{\expectedy}{\pgfpointanchor{#1}{#3}}%
 \assertcoord{#1}{#2}{\expectedx}{\expectedy}{#4}}
\begin{document}\START\setbox0=\hbox{\begin{tikzpicture}
\node[piston cylinder,piston cylinder width=20mm,piston cylinder height=4cm,piston position=.4] (P) {};
\node[piston cylinder,piston cylinder width=3cm,piston cylinder height=6cm,piston position=.75] (Other) {};
\foreach \p in {0,...,100}{\pgfpointanchor{P}{bottom-\p}}
\TYPE{PASS: piston bottom integer anchors}
\foreach \p in {0,...,100}{\pgfpointanchor{P}{right-\p}}
\TYPE{PASS: piston right integer anchors}
\foreach \p in {0,...,100}{\pgfpointanchor{P}{top-\p}}
\TYPE{PASS: piston top integer anchors}
\foreach \p in {0,...,100}{\pgfpointanchor{P}{left-\p}}
\TYPE{PASS: piston left integer anchors}
\foreach \p in {0,...,100}{\pgfpointanchor{P}{piston-\p}}
\TYPE{PASS: piston piston integer anchors}
\foreach \p in {0,...,100}{\pgfpointanchor{P}{axis-\p}}
\TYPE{PASS: piston axis integer anchors}
\foreach \p in {0,...,100}{\pgfpointanchor{P}{wall-left-\p}}
\TYPE{PASS: piston wall-left integer anchors}
\foreach \p in {0,...,100}{\pgfpointanchor{P}{wall-right-\p}}
\TYPE{PASS: piston wall-right integer anchors}
\foreach \p in {0,...,100}{\pgfpointanchor{P}{gas-axis-\p}}
\TYPE{PASS: piston gas-axis integer anchors}
\foreach \p in {0,...,100}{\pgfpointanchor{P}{gas-left-\p}}
\TYPE{PASS: piston gas-left integer anchors}
\foreach \p in {0,...,100}{\pgfpointanchor{P}{gas-right-\p}}
\TYPE{PASS: piston gas-right integer anchors}
\foreach \p in {0,...,100}{\pgfpointanchor{P}{piston-top-\p}}
\TYPE{PASS: piston piston-top integer anchors}
\foreach \p in {0,...,100}{\pgfpointanchor{P}{rod-\p}}
\TYPE{PASS: piston rod integer anchors}
\assertcoord{P}{piston-25}{-0.5cm}{-0.4cm}{piston-25 saved dimensions}
\assertcoord{P}{gas-center}{0cm}{-1.2cm}{gas-center saved dimensions}
\assertcoord{P}{heat-left}{-1cm}{-1.2cm}{heat-left saved dimensions}
\assertcoord{P}{heat-right}{1cm}{-1.2cm}{heat-right saved dimensions}
\assertcoord{P}{heat-bottom}{0cm}{-2cm}{heat-bottom saved dimensions}
\assertcoord{P}{gas-axis-0}{0cm}{-2cm}{gas-axis-0 saved dimensions}
\assertcoord{P}{gas-axis-100}{0cm}{-0.4cm}{gas-axis-100 saved dimensions}
\assertcoord{P}{gas-left-37}{-1cm}{-1.408cm}{gas-left-37 saved dimensions}
\assertcoord{P}{gas-right-75}{1cm}{-0.8cm}{gas-right-75 saved dimensions}
\assertcoord{P}{piston-top-50}{0cm}{-0.24cm}{piston-top-50 saved dimensions}
\assertcoord{P}{rod-start}{0cm}{-0.24cm}{rod-start saved dimensions}
\assertcoord{P}{rod-50}{0cm}{0.88cm}{rod-50 saved dimensions}
\assertcoord{P}{rod-100}{0cm}{2cm}{rod-100 saved dimensions}
\assertcoord{P}{work}{0cm}{2cm}{work saved dimensions}
\node[piston cylinder,rotate=90] (R) at (5,0) {};
\assertcoord{R}{gas-center}{5.525cm}{0cm}{rotated gas centre}
\assertcoord{R}{rod-end}{3.5cm}{0cm}{rotated rod tip}
\pic (E) {piston cylinder diagram};
\pic (C) at (5,0) {piston cylinder diagram={piston heat direction=out,piston work direction=in,piston position=.4}};
\pic (N) at (10,0) {piston cylinder diagram={piston heat direction=none,piston work direction=none}};
\pic (Again) at (15,0) {piston cylinder diagram};
\foreach \p in {0,...,100}{\pgfpointanchor{E-heat-\p}{center}}
\TYPE{PASS: E heat integer coordinates}
\foreach \p in {0,...,100}{\pgfpointanchor{E-work-\p}{center}}
\TYPE{PASS: E work integer coordinates}
\foreach \p in {0,...,100}{\pgfpointanchor{C-heat-\p}{center}}
\TYPE{PASS: C heat integer coordinates}
\foreach \p in {0,...,100}{\pgfpointanchor{C-work-\p}{center}}
\TYPE{PASS: C work integer coordinates}
\foreach \p in {0,...,100}{\pgfpointanchor{N-heat-\p}{center}}
\TYPE{PASS: N heat integer coordinates}
\foreach \p in {0,...,100}{\pgfpointanchor{N-work-\p}{center}}
\TYPE{PASS: N work integer coordinates}
\foreach \p in {0,...,100}{\pgfpointanchor{Again-heat-\p}{center}}
\TYPE{PASS: Again heat integer coordinates}
\foreach \p in {0,...,100}{\pgfpointanchor{Again-work-\p}{center}}
\TYPE{PASS: Again work integer coordinates}
\assertcoord{E-heat-0}{center}{-2.1cm}{-0.525cm}{E heat-0 direction}
\assertcoord{E-heat-100}{center}{-0.9cm}{-0.525cm}{E heat-100 direction}
\assertcoord{E-work-0}{center}{0cm}{1.5cm}{E work-0 direction}
\assertcoord{E-work-100}{center}{0cm}{2.5cm}{E work-100 direction}
\assertcoord{C-heat-0}{center}{4.1cm}{-0.9cm}{C heat-0 direction}
\assertcoord{C-heat-100}{center}{2.9cm}{-0.9cm}{C heat-100 direction}
\assertcoord{C-work-0}{center}{5cm}{2.5cm}{C work-0 direction}
\assertcoord{C-work-100}{center}{5cm}{1.5cm}{C work-100 direction}
\assertcoord{N-heat-0}{center}{9.1cm}{-0.525cm}{N heat-0 direction}
\assertcoord{N-work-0}{center}{10cm}{1.5cm}{N work-0 direction}
\assertcoord{Again-heat-0}{center}{12.9cm}{-0.525cm}{Again heat-0 direction}
\assertcoord{Again-work-0}{center}{15cm}{1.5cm}{Again work-0 direction}
\pic[rotate=90,scale=2,transform shape] (T) at (0,5) {piston cylinder diagram};
\assertcoord{T-cylinder}{gas-center}{1.05cm}{5cm}{transformed child}
\assertcoord{T-work-50}{center}{-4cm}{5cm}{transformed flow midpoint}
\end{tikzpicture}}\END\end{document}
