# What is it I am doing wrong using \tl_case:Nn …?

When using document command arguments for case distinctions I routinely have been using the \str_case:nn function, which works fine as is evident from the output of the \myStrCase command. When attempting to use the \tl_case:Nn function instead, by loading the argument into a _tl type variable, things go miserably wrong. The variable seems to be loaded with the correct value, and is then flagged as correct as far as the \tl_case:Nn function is concerned, but the corresponding code is not executed. Why?

\documentclass{article}
%=======================
\usepackage[check-declarations,log-functions]{expl3}
\usepackage{xparse}
%-----------------------
\ExplSyntaxOn
\tl_new:N \l_rn_Aux_tl
\NewDocumentCommand\myStrCase{O{emph}m}
{
\str_case:nnTF {#1}
{
{emph}{\textit{#2}}
{Emph}{\textbf{\textit{#2}}}
{uline}{\underline{#2}}
}
{}
{!~ERROR:~parameter~\#1~=~#1~invalid}
}  %  \myStrCase
\NewDocumentCommand\myTlCase{O{emph}m}
{
\tl_set:Nx \l_rn_Aux_tl {#1}
checking~what~was~passed:~\l_rn_Aux_tl \\
\tl_case:NnTF \l_rn_Aux_tl
{
emph {\textit{#2}}
Emph {\textbf{\textit{#2}}}
uline {\underline{#2}}
}
{parameter~\#1~=~#1~valid}
{!~ERROR:~parameter~\#1~=~#1~invalid}
}  %  \myTlCase
\ExplSyntaxOff
%-----------------------
\begin{document}
\subsection{using str\_case:}
\myStrCase{Hi There}\\
\myStrCase[emph]{Hi There}\\
\myStrCase[Emph]{Hi There}\\
\myStrCase[uline]{Hi There}\\
\myStrCase[xxx]{Hi There}
\subsection{using tl\_case:}
\myTlCase[emph]{Hi There}\\
\myTlCase[xxx]{Hi There}
\end{document}


\tl_case:NnTF <test token list variable>

You will find "token list variable" and not "token list" therein. Hence you are asked to provide one token (a variable/N-type argument). So to use this construction you would need to save your options into variables and use these within \tl_case.