TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was trying to figure out how to test my xpeek package (see https://github.com/jcsalomon/xpeek) and I came across What's the folk-lore on automatic testing of TeX programming? and Testing Framework API for LaTeX. Both of these mention the qstest package, but I’m having trouble understanding how to use it.

To be concrete, consider this test of xspace (xpeek can be used to implement \xspace, so this is not far removed from what I want to do):

\usepackage{xspace, qstest}

\begin{qstest}{test xspace}{}


This fails, yielding this error message:

! Package qstest Error: Failed: test xspace
 \Expect: foo\xspace .
 >foo\xspace ..

See the qstest package documentation for explanation.

Obviously I’m missing something fundamental here, but reading the qstest package documentation is not making things any clearer to me. Can anyone explain to me how to write the test so it succeeds?

share|improve this question
up vote 6 down vote accepted

"foo\xspace." and "foo." are indeed different, thus the test must fail. \Expect can expand the arguments if they are preceded by a star:


However, this will not help either, because \xspace is not expandable (\futurelet and other assignments). But we can put the argument in a box and measure the width. If \xspace would insert a space, the width of the box would be larger.

\begin{qstest}{test xspace}{}
share|improve this answer
Is that what the test macros inside your packages boil down to? Seems like quite a limitation. BTW, you & Will Robertson are the only ones whose packages on CTAN use qstest that I can find. – J. C. Salomon Aug 15 '12 at 16:32
@Salomon, you can take LuaTeX and look into the contents of boxes using Lua and check, whether is a space. Testing is sometimes something like finding relevant properties of a feature that can be checked against the expectations. – Heiko Oberdiek Aug 15 '12 at 16:41
LuaTeX is a rabbit-hole I’m not looking to climb down at the moment, but it’s good to know about. I’ve added a simple test-suite based on your answer to xpeek at this commit. – J. C. Salomon Aug 15 '12 at 19:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.