Added test for valid/invalid unicode characters

This commit is contained in:
cumul
2020-02-24 01:35:00 +09:00
committed by cumul0529
parent 247d9cd887
commit 8b90b55518
3 changed files with 28 additions and 0 deletions
+12
View File
@@ -482,6 +482,18 @@ class NginxParserTest(util.NginxTest):
called = True
self.assertTrue(called)
def test_valid_unicode_characters(self):
nparser = parser.NginxParser(self.config_path)
# pylint: disable=protected-access
parsed = nparser._parse_files(nparser.abs_path('unicode_support/valid_unicode_comments.conf'))
self.assertEqual(['server'], parsed[0][2][0])
self.assertEqual(['listen', '80'], parsed[0][2][1][3])
def test_invalid_unicode_characters(self):
nparser = parser.NginxParser(self.config_path)
# pylint: disable=protected-access
parsed = nparser._parse_files(nparser.abs_path('unicode_support/invalid_unicode_comments.conf'))
self.assertEqual([], parsed)
if __name__ == "__main__":
@@ -0,0 +1,7 @@
# This configuration file is saved with EUC-KR (a.k.a. cp949) encoding,
# including some Korean alphabets.
server {
# 안녕하세요. 80번 포트에서 요청을 기다린다.
listen 80;
}
@@ -0,0 +1,9 @@
# This configuration file is saved with valid UTF-8 encoding,
# including some CJK alphabets.
server {
# 안녕하세요. 80번 포트에서 요청을 기다린다.
# こんにちは。80番ポートからリクエストを待つ。
# 你好。等待端口80上的请求。
listen 80;
}