<s> import unittest <EOL> import pyglet <EOL> from graphics_common import * <EOL> __noninteractive = True <EOL> class TEST_CASE ( unittest . TestCase ) : <EOL> def check ( self , expected , result , dimensions ) : <EOL> if len ( expected ) != len ( result ) * dimensions / <NUM_LIT:4> : <EOL> self . fail ( '<STR_LIT>' ) <EOL> for d in range ( <NUM_LIT:2> ) : <EOL> for e , r in zip ( expected [ d : : dimensions ] , result [ d : : <NUM_LIT:4> ] ) : <EOL> if abs ( e - r ) > <NUM_LIT> : <EOL> self . fail ( '<STR_LIT>' % ( e , r ) ) <EOL> def generic_test ( self , v_fmt , v_data , <EOL> c_fmt = None , c_data = None , <EOL> t_fmt = None , t_data = None ) : <EOL> data = [ ( v_fmt , v_data ) ] <EOL> n_v = int ( v_fmt [ <NUM_LIT:1> ] ) <EOL> if c_fmt : <EOL> data . append ( ( c_fmt , c_data ) ) <EOL> n_c = int ( c_fmt [ <NUM_LIT:1> ] ) <EOL> if t_fmt : <EOL> data . append ( ( t_fmt , t_data ) ) <EOL> n_t = int ( t_fmt [ <NUM_LIT:1> ] ) <EOL> vertices , colors , tex_coords = get_feedback ( lambda : pyglet . graphics . draw ( n_vertices , GL_TRIANGLES , * data ) ) <EOL> self . check ( v_data , vertices , n_v ) <EOL> if c_fmt : <EOL> self . check ( c_data , colors , n_c ) <EOL> if t_fmt : <EOL> self . check ( t_data , tex_coords , n_t ) <EOL> def test_v2f ( self ) : <EOL> self . generic_test ( '<STR_LIT>' , v2f_data ) <EOL> def test_v3f ( self ) : <EOL> self . generic_test ( '<STR_LIT>' , v3f_data ) <EOL> def test_v2f_c3f ( self ) : <EOL> self . generic_test ( '<STR_LIT>' , v2f_data , '<STR_LIT>' , c3f_data ) <EOL> def test_v2f_c4f ( self ) : <EOL> self . generic_test ( '<STR_LIT>' , v2f_data , '<STR_LIT>' , c4f_data ) <EOL> def test_v3f_c3f ( self ) : <EOL> self . generic_test ( '<STR_LIT>' , v3f_data , '<STR_LIT>' , c3f_data ) <EOL> def test_v3f_c4f ( self ) : <EOL> self . generic_test ( '<STR_LIT>' , v3f_data , '<STR_LIT>' , c4f_data ) <EOL> def test_v2f_t2f ( self ) : <EOL> self . generic_test ( '<STR_LIT>' , v2f_data , None , None , '<STR_LIT>' , t2f_data ) <EOL> def test_v3f_c3f_t2f ( self ) : <EOL> self . generic_test ( '<STR_LIT>' , v3f_data , '<STR_LIT>' , c3f_data , '<STR_LIT>' , t2f_data ) <EOL> def test_v3f_c3f_t3f ( self ) : <EOL> self . generic_test ( '<STR_LIT>' , v3f_data , '<STR_LIT>' , c3f_data , '<STR_LIT>' , t3f_data ) <EOL> def test_v3f_c4f_t4f ( self ) : <EOL> self . generic_test ( '<STR_LIT>' , v3f_data , '<STR_LIT>' , c4f_data , '<STR_LIT>' , t4f_data ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
