summaryrefslogtreecommitdiff
path: root/tests/utils/test_text_util.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/utils/test_text_util.py')
-rw-r--r--tests/utils/test_text_util.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/utils/test_text_util.py b/tests/utils/test_text_util.py
index 9ac0707..dc3de85 100644
--- a/tests/utils/test_text_util.py
+++ b/tests/utils/test_text_util.py
@@ -35,12 +35,31 @@ class TestTextUtil(AgentTestCase):
data = ustr(b'\xef\xbb\xbfhehe', encoding='utf-8')
data = textutil.remove_bom(data)
self.assertNotEquals(0xbb, data[0])
-
+
+ #bom is comprised of a sequence of three bytes and ff length of the input is shorter
+ # than three bytes, remove_bom should not do anything
+ data = u"\xa7"
+ data = textutil.remove_bom(data)
+ self.assertEquals(data, data[0])
+
+ data = u"\xa7\xef"
+ data = textutil.remove_bom(data)
+ self.assertEquals(u"\xa7", data[0])
+ self.assertEquals(u"\xef", data[1])
+
#Test string without BOM is not affected
data = u"hehe"
data = textutil.remove_bom(data)
self.assertEquals(u"h", data[0])
+ data = u""
+ data = textutil.remove_bom(data)
+ self.assertEquals(u"", data)
+
+ data = u" "
+ data = textutil.remove_bom(data)
+ self.assertEquals(u" ", data)
+
def test_version_compare(self):
self.assertTrue(Version("1.0") < Version("1.1"))
self.assertTrue(Version("1.9") < Version("1.10"))