feat: complete Chinese tutorial text and layout validation

This commit is contained in:
DragonHD
2026-09-20 12:10:30 +08:00
parent 6cd5bcbfee
commit b7ae04ec18
7 changed files with 124 additions and 6 deletions
+15
View File
@@ -3,6 +3,21 @@ from script_text import extract_display_literals, patch_display_calls
class ScriptTextTests(unittest.TestCase):
def test_numeric_percent_in_prose_is_not_a_printf_conversion(self):
source = b'SetMissionDescription("speed 0% is pause; %s %d");'
result = patch_display_calls(source, {'speed 0% is pause; %s %d': '速度 0% 等于暂停;%s %d'})
self.assertIn('速度 0%'.encode('gb2312'), result)
with self.assertRaises(ValueError):
patch_display_calls(source, {'speed 0% is pause; %s %d': '速度 0% 等于暂停'})
def test_stock_tutorial_unescaped_function_key_is_a_display_span(self):
text = '\fTo use a charged spell select it by pressing the "F" KEY marked under it'
source = b'SetMissionDescription("\\fTo use a charged spell select it by pressing the "F" KEY marked under it");'
self.assertEqual(extract_display_literals(source)[0].text, text)
self.assertEqual(patch_display_calls(source, {text: '\f按 F 键'}),
'SetMissionDescription("\\f按 F 键");'.encode('gb2312'))
self.assertEqual(extract_display_literals(b'SetMissionDescription("other "F" text");'), [])
def test_only_direct_display_literals_change(self):
source = b'DisplayMessage("Help", "Move");\r\nEnableEvent("Move");\r\n'
result = patch_display_calls(source, {'Help': '帮助', 'Move': '移动'})