liblouis: Automated Testing of Translation Tables

1 
1 5 Automated Testing of Translation Tables
1 *****************************************
1 
1 There are a number of automated tests for liblouis and they are proving
1 to be of tremendous value.  When changing the code the developers can
1 run the tests to see if anything broke.
1 
1    For testing the translation tables there are basically two
1 approaches: there are the harness tests and the doctests.  They were
1 created at roughly the same time using different technologies, have
1 influenced each other and have gone through improvements and technology
1 changes.  For now they are both based on Python so you need to have that
1 installed.  The philosophies of the two are slightly different:
1 
1 Harness tests
1      The harness tests are data driven, i.e.  you give the test data,
1      i.e.  a string to translate and the expected output.  The data is
1      in a standard format, i.e.  json.  They work with both Python2 and
1      Python3, however since the format is json it is perceivable that
1      somebody would write some C code which takes the data in the
1      harness file and runs it through liblouis so they could also run
1      without Python and without ucs4.
1 
1 Doctests
1      The doctests on the other hand are based on a technology used in
1      Python where you define your tests as if you were sitting at a
1      terminal session with a Python interpreter.  So the tests look like
1      you typed a command and got some output, e.g.
1 
1           >>> translate(['table.ctb'], "Hello", mode=compbrlLeftCursor)
1           ("HELLO", [0,1,2,3], [0,1,2,3], 0)
1 
1      There is a convenience wrapper which hides away much of the
1      complexity of above example so you can write stuff like
1 
1           >>> t.braille('the cat sat on the mat')
1           u'! cat sat on ! mat'
1 
1      But essentially you are writing code, so the doctests allow you to
1      do more flexible tests that are much closer to the raw iron.  For
1      technical reasons the doctests will probably only ever work in
1      either Python2 or Python3 but not both and they will never run from
1      C.
1 
1    To sum it up, the recommendation is that for normal table testing you
1 should use the test harness.  It has a lot of momentum and the format is
1 a standard.  If you want to be closer to the raw Python API of liblouis,
1 if you want to test some more intricate scenarios (involving inpos,
1 modes, etc) then the doctests are for you.
1 

Menu