aboutsummaryrefslogtreecommitdiff
path: root/doc/ref/test.texi
blob: e16d2cc0d5084665bd9720a8f12aef5a2e61c275 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
@node Utilities for Testing Code
@chapter Utilities for Testing Code

The module @code{(hnh test util)} contains a number of general
utilities which I have only found useful when running tests.

@defun µs x
Multiply @var{x} by @math{10^6}, transforming seconds into
micro seconds.
@end defun

@defun transform-time-of-day tod
Merges the pair returned by @code{gettimeofday} into one large
integer, measured in microseconds.

@example
(transform-time-of-day (gettimeofday))
⇒ 1697460136217839
@end example
@end defun

@defun green str
@defunx red str
@defunx yellow str
@defunx bold str
Wrap the give string in ANSI escape sequences.

@c TODO should be replaced by a general system.
@end defun

@defun make-indent depth
Returns a string conisting of 2 × @var{depth} spaces.
@end defun

@defun string-replace-head s1 s2
Return a new string, which contains @code{s2 ++ s1[len(s2):]}.
@end defun

@defun diff a b
Return a line diff between object @var{a} and @var{b}. If both objects
are strings then they will be passed directoly to the line diff
function, but if either is a non-string then they will both first be
passed through @code{pretty-print} in write mode (instead of display mode).

Currently the diff command used is
@example
git diff --no-index --color-moved=default --color=always a b
@end example
@end defun

@section xmllint

The module @code{(hnh test xmllint)} provides a wrapper around the
xmllint program.

@defun xmllint str
Run xmllint on @var{str}, returning the result as a new string.
@end defun