%%
%% This is file `hycolor-test2.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% hycolor.dtx  (with options: `test,test2')
%% 
%% This is a generated file.
%% 
%% Project: hycolor
%% Version: 2011/01/30 v1.7
%% 
%% Copyright (C) 2007-2011 by
%%    Heiko Oberdiek <heiko.oberdiek at googlemail.com>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%%    http://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% This Current Maintainer of this work is Heiko Oberdiek.
%% 
%% This work consists of the main source file hycolor.dtx
%% and the derived files
%%    hycolor.sty, hycolor.pdf, hycolor.ins, hycolor.drv,
%%    xcolor-patch.sty, hycolor-test1.tex, hycolor-test2.tex,
%%    hycolor-test3.tex, hycolor-test-xcol1.tex,
%%    hycolor-test-xcol2.tex, hycolor-test-xcol3.tex,
%%    hycolor-test-xcol4.tex.
%% 
\ProvidesFile{hycolor-test2.tex}[2011/01/30 test file 2]
\let\pdfmatch\relax
\documentclass{article}

\usepackage{qstest}
\IncludeTests{*}
\LogTests{log}{*}{*}

\makeatletter

\newcommand*{\TestPackageName}{test-package}
\newcommand*{\TestOptionName}{test-option}

\newcommand\Message{}
\def\Message#1#{\immediate\write16}

\newcommand*{\ExpectError}[2]{%
  \begingroup
    \global\let\saved@errhelp\errhelp
    \global\let\saved@errmessage\errmessage
    \let\errhelp\@gobble
    \def\errmessage##1{%
      \xdef\@ExpectErrorMessage{##1}%
    }%
    \PackageError\TestPackageName{#1}\@ehc
    \def\errhelp##1{%
      \global\let\errhelp\saved@errhelp
    }%
    \global\let\@ResultErrorMessage\@empty
    \def\errmessage##1{%
      \xdef\@ResultErrorMessage{##1}%
      \global\let\errmessage\saved@errmessage
      % \Message{[ ##1}%
      % \Message{] (ignored error)}%
      % \Message{}%
    }%
    #2%
  \endgroup
  \Expect*{\@ResultErrorMessage}*{\@ExpectErrorMessage}%
}
\usepackage{scrlfile}
\usepackage{hycolor}[2011/01/30]
\begin{qstest}{X0134 without xcolor}{X0134, noxcolor}
  \def\test#1#2{%
    \HyColor@XZeroOneThreeFour{#1}\cmd\TestPackageName\TestOptionName
    \Expect*{\cmd}{#2}%
  }%
  \test{[empty]{}}{}%
  \test{[rgb]{1,0,0}}{1 0 0}%
  \test{[gray]{0.10}}{.1}%
  \test{[cmyk]{0,1,0,0}}{0 1 0 0}%
  \test{[rgb]{ 1 , 1 , 0 }}{1 1 0}%
  \def\errortest[#1]#2{%
    \ExpectError{%
      Color model `#1' is not supported\MessageBreak
      without package `xcolor' in\MessageBreak
      `test-option=[#1]{#2}'% hash-ok
    }{%
      \HyColor@XZeroOneThreeFour{[{#1}]{#2}}\cmd
          \TestPackageName\TestOptionName
      \Expect{true}*{\ifx\cmd\relax true\else false\fi}%
    }%
  }%
  \errortest[Gray]{10}%
  \errortest[cmy]{1,0,0}%
  \def\errortest#1{%
    \ExpectError{%
      This color specification is not supported\MessageBreak
      without package `xcolor' in\MessageBreak
      `test-option=#1'%
    }{%
      \HyColor@XZeroOneThreeFour{#1}\cmd\TestPackageName\TestOptionName
      \Expect{true}*{\ifx\cmd\relax true\else false\fi}%
    }%
  }%
  \errortest{yellow}%
\end{qstest}

\begin{qstest}{HyperrefBorderColor without xcolor}%
              {hyperef bordercolor, noxcolor}%
  \def\test#1#2{%
    \HyColor@HyperrefBorderColor{#1}\cmd\TestPackageName\TestOptionName
    \Expect*{\cmd}{#2}%
  }%
  \test{[rgb]{1,0,0}}{1 0 0}%
  \test{[gray]{0.10}}{.1 .1 .1}%
  \test{[rgb]{ 1 , 1 , 0 }}{1 1 0}%
  \def\errortest[#1]#2{%
    \ExpectError{%
      Color model `#1' is not supported\MessageBreak
      without package `xcolor' in\MessageBreak
      `test-option=[#1]{#2}'% hash-ok
    }{%
      \HyColor@HyperrefBorderColor{[{#1}]{#2}}\cmd
          \TestPackageName\TestOptionName
      \Expect{true}*{\ifx\cmd\relax true\else false\fi}%
    }%
  }%
  \errortest[Gray]{10}%
  \errortest[cmy]{1,0,0}%
  \errortest[cmyk]{0,1,0,0}%
  \def\errortest#1{%
    \ExpectError{%
      This color specification is not supported\MessageBreak
      without package `xcolor' in\MessageBreak
      `test-option=#1'%
    }{%
      \HyColor@HyperrefBorderColor{#1}\cmd
          \TestPackageName\TestOptionName
      \Expect{true}*{\ifx\cmd\relax true\else false\fi}%
    }%
  }%
  \errortest{yellow}%
\end{qstest}
\usepackage{xcolor}
\definecolor[named]{MyGreen}{rgb}{0,0.7,0}
\definecolor{mygreen}{named}{MyGreen}
\begin{qstest}{X0134 with xcolor}{hyperref, X0134, xcolor}
  \def\test#1#2{%
    \HyColor@XZeroOneThreeFour{#1}\cmd\PackageName\OptionName
    \Expect*{\cmd}{#2}%
  }%
  \test{[empty]{}}{}%
  \test{[gray]{0.1}}{.1}%
  \test{[rgb]{1,0.5,0.0}}{1 .5 0}%
  \test{[cmyk]{0,1,0,0.5}}{0 1 0 .5}%
  \test{[Gray]{10}}{.66667}%
  \test{red}{1 0 0}%
  \test{1 0 0}{1 0 0}%
  \test{001.0 .23 0}{1 .23 0}%
  \test{[named]{MyGreen}}{0 .7 0}%
  \test{mygreen}{0 .7 0}%
  \HyColor@XZeroOneThreeFour{}\cmd\PackageName\OptionName
  \Expect{true}*{\ifx\cmd\relax true\else false\fi}%
\end{qstest}

\begin{qstest}{FieldColor}{hyperref, field, FieldColor}
  \def\test#1#2{%
    \HyColor@FieldColor{#1}\cmd\PackageName\OptionName
    \Expect*{\cmd}{#2}%
  }%
  \test{}{}%
  \test{[gray]{0.7}}{.7 g}%
  \test{[rgb]{1,0,0}}{1 0 0 rg}%
  \test{[cmyk]{0,1,0,0}}{0 1 0 0 k}%
  \test{[cmy]{.5,.4,.3}}{.5 .6 .7 rg}%
\end{qstest}
\begin{document}
\end{document}
\endinput
%%
%% End of file `hycolor-test2.tex'.
