[liblouis-liblouisxml] Re: proposal for a test harness

  • From: Christian Egli <christian.egli@xxxxxx>
  • To: Mesar Hameed <mesar.hameed@xxxxxxxxx>
  • Date: Thu, 01 Mar 2012 11:58:15 +0100

Hi Mesar

Mesar Hameed <mesar.hameed@xxxxxxxxx> writes:

> Ok, please find attached, liblouis is now imported directly from source.

Here's a followup to my post from yesterday. I implemented your test as
doctest and I like it quite a bit. It is quite concise, yet verbose and
I think it can easily be undertood by an author of braille tables. An
example is attached. Save the file in the test dir and run the tests as
follows:

python -m doctest -v tests.txt

Thanks
Christian

Liblouis tests
==============

This is an example test file in reStructuredText format. First import
the ``louis`` module:

    >>> import sys
    >>> sys.path.insert(1, "../python/")
    >>> import louis

Then define the table you want to test

    >>> tables = ['en-GB-g2.ctb']

Now do some tests.

Check that "the" is correctly contracted
    >>> louis.translateString(tables, 'the cat sat on the mat')
    u'! cat sat on ! mat'

Make sure that "to" is contracted correctly and joined to next word.
    >>> louis.translateString(tables, 'to the moon')
    u'6! moon'

Check that "to" at end of line doesn't get contracted, and that "went"
is expanded when cursor is positioned within the word. ``translate``
returns a tuple where the first element contains the contracted
braille and the fourth element contains the position of the cursor in
the output
    >>> louis.translate(tables, 'you went to', cursorPos=4, 
mode=louis.compbrlAtCursor)[0]
    u'y went to'
    >>> louis.translate(tables, 'you went to', cursorPos=4, 
mode=louis.compbrlAtCursor)[3]
    2
-- 
Christian Egli
Swiss Library for the Blind, Visually Impaired and Print Disabled
Grubenstrasse 12, CH-8045 Zürich, Switzerland


-----
Jetzt kostenlos eidgenoessische und kantonale Abstimmungsunterlagen aus 17 
Kantonen
zum Hoeren auf CD abonnieren: medienverlag@xxxxxx

Other related posts: