summary refs log blame commit diff stats
path: root/test/tc_utfwidth.py
blob: cf564990ed994d10b9dd62b23ba01a3319140bea (plain) (tree)









































                                                                       
# -*- encoding: utf8 -*-
# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

if __name__ == '__main__': from __init__ import init; init()

from unittest import TestCase, main
from ranger.ext.utfwidth import *

a_ascii = "a"      # width = 1, bytes = 1
a_umlaut = "ä"     # width = 1, bytes = 2
a_katakana = "ア"  # width = 2, bytes = 3
# need one with width = 1 & bytes = 3

class Test(TestCase):
	def test_utf_byte_length(self):
		self.assertEqual(1, utf_byte_length(a_ascii[0]))
		self.assertEqual(2, utf_byte_length(a_umlaut[0]))
		self.assertEqual(3, utf_byte_length(a_katakana[0]))

	def test_uwid(self):
		self.assertEqual(1, uwid(a_ascii))
		self.assertEqual(1, uwid(a_umlaut))
		self.assertEqual(2, uwid(a_katakana))
		self.assertEqual(3, uwid(a_katakana + a_umlaut))
		self.assertEqual(4, uwid("asdf"))
		self.assertEqual(5, uwid("löööl"))
		self.assertEqual(6, uwid("バババ"))

if __name__ == '__main__': main()
eight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
###
### prt-get conf
###

# note: the order matters: the package found first is used
prtdir /usr/ports/core
prtdir /usr/ports/ports
prtdir /usr/ports/opt
prtdir /usr/ports/xorg
prtdir /usr/ports/contrib
prtdir /usr/ports/mate
#prtdir /usr/ports/kde5
#prtdir /usr/ports/romster
#prtdir /usr/ports/tb
#prtdir /usr/ports/timcowchip
#prtdir /usr/ports/6c37
#prtdir /usr/ports/nilp
#prtdir /usr/ports/nullspoon
#prtdir /usr/ports/dbrooke
#prtdir /usr/ports/pitillo

# 6c37 team provides a collection with freetype-iu, fontconfig-iu
# and cairo-iu ports.
# the following line enables the user maintained contrib collection
# prtdir /usr/ports/6c37-dropin
# prtdir /usr/ports/6c37


# the following line enables the multilib compat-32 collection
#prtdir /usr/ports/compat-32

### use mypackage form local directory
# prtdir /home/packages/build:mypackage

### log options:
writelog enabled         # (enabled|disabled)
logmode  overwrite       # (append|overwrite)
rmlog_on_success yes     # (no|yes)
logfile  /usr/ports/pkgbuild/%n-%v-%r.log
                           # path, %p=path to port dir, %n=port name
                           #       %v=version, %r=release

### use alternate cache file (default: /var/lib/pkg/prt-get.cache
# cachefile /mnt/nfs/cache

### print README information:
readme verbose           # (verbose|compact|disabled)

### prefer higher versions in sysup / diff
preferhigher yes     # (yes|no)

### use regexp search
# useregex no        # (yes|no)

### run pre- and post-installs scripts; yes is equivalent to the
### --install-scripts option
runscripts yes            # (no|yes)


### EXPERT SECTION ###

### alternative commands
makecommand      sudo -H -u pkgmk -g pkgmk fakeroot pkgmk
addcommand       sudo pkgadd
removecommand    sudo pkgrm
runscriptcommand sudo sh