-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_base_util.py
42 lines (30 loc) · 1.59 KB
/
test_base_util.py
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
#coding: utf-8
# This file is part of https://github.com/marcus67/rechtschreibung
import unittest
import util
global logger
class TestUtil(unittest.TestCase):
def test_count_bits(self):
self.assertEqual(0, util.count_bits(0))
self.assertEqual(1, util.count_bits(1))
self.assertEqual(1, util.count_bits(16))
self.assertEqual(1, util.count_bits(65536))
self.assertEqual(4, util.count_bits(15))
def test_html_content_add_and_delete(self):
self.assertEqual(util.get_html_content(u"ac", u"abc", True), u"a<span id='ins'>b</span>c")
self.assertEqual(util.get_html_content(u"ac", u"abc", False), u"abc")
self.assertEqual(util.get_html_content(u"abc", u"ac", True), u"a<span id='del'>b</span>c")
self.assertEqual(util.get_html_content(u"abc", u"ac", False), u"ac")
self.assertEqual(util.get_html_content(u"abc", u"abc", True), u"abc")
self.assertEqual(util.get_html_content(u"abc", u"abc", False), u"abc")
def test_html_content_special_characters(self):
self.assertEqual(util.get_html_content(u"\n", u"\n", True), u"<BR/>")
self.assertEqual(util.get_html_content(u"\n", u"\n", False), u"<BR/>")
self.assertEqual(util.get_html_content(u"ė", u"ė", True), u"ē")
self.assertEqual(util.get_html_content(u"ė", u"ė", False), u"ē")
self.assertEqual(util.get_html_content(u"Ė", u"Ė", True), u"Ē")
self.assertEqual(util.get_html_content(u"Ė", u"Ė", False), u"Ē")
self.assertEqual(util.get_html_content(u'"', u'"', True), u""")
self.assertEqual(util.get_html_content(u'"', u'"', False), u""")
if __name__ == '__main__':
unittest.main()