@@ -24,13 +24,11 @@ class TDLTemplate(unittest.TestCase):
2424
2525 @classmethod
2626 def setUpClass (cls ):
27- tdl .setFont ('../fonts/libtcod/terminal8x8_gs_ro.png' )
2827 cls .console = tdl .init (WIDTH , HEIGHT , 'TDL UnitTest' , False , renderer = 'SDL' )
2928 # make a small window in the corner
3029 cls .window = tdl .Window (cls .console , 0 , 0 , WINWIDTH , WINHEIGHT )
3130
3231 def setUp (self ):
33- tdl .setFont ('../fonts/libtcod/terminal8x8_gs_ro.png' )
3432 tdl .event .get ()
3533 self .console .set_colors ((0 ,0 ,0 ), (0 ,0 ,0 ))
3634 self .console .clear ()
@@ -176,7 +174,42 @@ def test_drawCharWebcolor(self):
176174 # for x,y in self.getUndrawables():
177175 # with self.assertRaisesRegexp(AssertionError, r"\(%i, %i\)" % (x, y)):
178176 # self.console.drawChar(x, y, *(self.getRandomCharacter()))
177+
178+ def test_drawStr (self ):
179+ """quick regression test for drawStr"""
180+ width , height = self .console .getSize ()
181+ def str_check (array , string , desc ):
182+ fg , bg = self .getRandomColor (), self .getRandomColor ()
183+ self .console .clear ()
184+ self .console .drawStr (0 , 0 , string , fg , bg )
185+ self .flush ()
186+ i = 0
187+ for y in range (height ):
188+ for x in range (width ):
189+ self .assertEqual (self .console .getChar (x , y ), (array [i ], fg , bg ),
190+ '%s should be written out' % desc )
191+ i += 1
192+
193+ # array of numbers
194+ array = [random .getrandbits (8 ) for _ in range (width * height )]
195+ str_check (array , array , 'array of numbers' )
179196
197+ # array of strings
198+ #array = [random.getrandbits(8) for _ in range(width * height)]
199+ #array_str = [chr(c) for c in array]
200+ #str_check(array, array_str, 'array of characters')
201+
202+ # standard string
203+ array = [random .getrandbits (8 ) for _ in range (width * height )]
204+ string = '' .join ((chr (c ) for c in array ))
205+ str_check (array , string , 'standatd string' )
206+
207+ # Unicode string - Python 2
208+ array = [random .getrandbits (8 ) for _ in range (width * height )]
209+ unicode = u'' .join ((chr (c ) for c in array ))
210+ str_check (array , unicode , 'Unicode string' )
211+
212+
180213 def test_drawStrArray (self ):
181214 """strings will raise errors if they pass over the end of the console.
182215 The data will still be written however."""
0 commit comments