|
| 1 | +======================== |
| 2 | +Character Finder Utility |
| 3 | +======================== |
| 4 | + |
| 5 | +Usage tips |
| 6 | +========== |
| 7 | + |
| 8 | +`cf.py` works as an executable on Unix-like systems, |
| 9 | +if you have `python3` on your `$PATH`:: |
| 10 | + |
| 11 | + $ chmod +x cf.py |
| 12 | + $ ./cf.py cat eyes |
| 13 | + U+1F638 😸 GRINNING CAT FACE WITH SMILING EYES |
| 14 | + U+1F63B 😻 SMILING CAT FACE WITH HEART-SHAPED EYES |
| 15 | + U+1F63D 😽 KISSING CAT FACE WITH CLOSED EYES |
| 16 | + |
| 17 | +Use `wc -l` to count the number of hits:: |
| 18 | + |
| 19 | + $ ./cf.py hieroglyph | wc -l |
| 20 | + 1663 |
| 21 | + |
| 22 | +With `tee` you can get the output and the count:: |
| 23 | + |
| 24 | + $ ./cf.py trigram | tee >(wc -l) |
| 25 | + U+2630 ☰ TRIGRAM FOR HEAVEN |
| 26 | + U+2631 ☱ TRIGRAM FOR LAKE |
| 27 | + U+2632 ☲ TRIGRAM FOR FIRE |
| 28 | + U+2633 ☳ TRIGRAM FOR THUNDER |
| 29 | + U+2634 ☴ TRIGRAM FOR WIND |
| 30 | + U+2635 ☵ TRIGRAM FOR WATER |
| 31 | + U+2636 ☶ TRIGRAM FOR MOUNTAIN |
| 32 | + U+2637 ☷ TRIGRAM FOR EARTH |
| 33 | + 8 |
| 34 | + |
| 35 | + |
| 36 | +Running the tests |
| 37 | +================= |
| 38 | + |
| 39 | +Run the ``doctest`` module from the command line on |
| 40 | +this README.rst file (using ``-v`` to make tests visible):: |
| 41 | + |
| 42 | + $ python3 -m doctest README.rst -v |
| 43 | + |
| 44 | +That's what the ``test.sh`` script does. |
| 45 | + |
| 46 | + |
| 47 | +Tests |
| 48 | +----- |
| 49 | + |
| 50 | +Import functions for testing:: |
| 51 | + |
| 52 | + >>> from cf import find, main |
| 53 | + |
| 54 | +Test ``find`` with single result:: |
| 55 | + |
| 56 | + >>> find('sign', 'registered') # doctest:+NORMALIZE_WHITESPACE |
| 57 | + U+00AE ® REGISTERED SIGN |
| 58 | + |
| 59 | +Test ``find`` with two results:: |
| 60 | + |
| 61 | + >>> find('chess', 'queen', last=0xFFFF) # doctest:+NORMALIZE_WHITESPACE |
| 62 | + U+2655 ♕ WHITE CHESS QUEEN |
| 63 | + U+265B ♛ BLACK CHESS QUEEN |
| 64 | + |
| 65 | +Test ``find`` with no results:: |
| 66 | + |
| 67 | + >>> find('no_such_character') |
| 68 | + |
| 69 | +Test ``main`` with no words:: |
| 70 | + |
| 71 | + >>> main([]) |
| 72 | + Please provide words to find. |
0 commit comments