''' Purpose: provide testers for test 2 ''' def test_tog() : import tog strings1 = [ "tango", "apple", "banana", "manna", "nada" ] strings2 = [ "000", "001", "010", "011", "100", "101", "110", "111"] strings3 = [ ] s11 = "an"; s21 = "na" s12 = "0"; s22 = "11" s13 = "0"; s23 = "" result1 = tog.thob( s11, s21, strings1 ) result2 = tog.thob( s12, s22, strings2 ) result3 = tog.thob( s13, s23, strings3 ) print( "thob( '" + s11 + "', '" + s21 + "',", 'strings1 ):', result1 ) print( "thob( '" + s12 + "', '" + s22 + "',", 'strings2 ):', result2 ) print( "thob( '" + s13 + "', '" + s23 + "', ", 'strings3 ):', result3 ) def test_atad( ): import atad d1 = [ [ 3, 1, 4, 1, 5, 9, 2 ], [ 6, 5, 3, 5, 8, 9, 7, 9, 3, 2 ], [ 3, 8, 4, 6, 2, 6, 4, 3, 3 ], [ 8, 3, 2, 7, 9, 5, 0 ] ] d2 = [ [ 2, 8, 8, 4, 1 ], [ 9, 7, 1, 6, 9, 3, 9, 9 ], [ 3, 7, 5, 1, 0, 5, 8, 2, 0, 9, 7, 4, 9 ] ] d3 = [ [ 4, 4 ], [ ], [ 5, 9, 2, 3, 0, 7, 8, 1, 6, 4 ] ] v1 = 9 v2 = 8 v3 = 5 tests = [ [ v1, d1 ], [ v2, d2 ], [ v3, d3 ] ] n = len( tests ) for i in range( 0, n ) : v, d = tests[ i ] result = atad.nbr( v, d ) print( 'nbr( d' + str( i+1 ) + ',', v, '):', result ) def test_spin() : import spin o1 = ( 50, 100, 200 ) o2 = ( 241, 59, 136 ) o3 = ( 90, 109, 80 ) tests = [ o1, o2, o3 ] for opixel in tests : result = spin.color( opixel ) print( 'spin(', opixel, '):', result ) def test_can() : import can x1 = [ 4, -5, 2, -5, 9 ] x2 = [ 0, 8, 0, -7, 4, 4, 0 ] x3 = [ 6, 8, 0, 2, 4 ] result1 = can.cmp( x1 ) result2 = can.cmp( x2 ) result3 = can.cmp( x3 ) print( 'cmp( x1 ):', result1 ) print( 'cmp( x2 ):', result2 ) print( 'cmp( x3 ):', result3 ) def test_cre() : import cre v1 = 0; nr1 = 2; nc1 = 5 v2 = "a"; nr2 = 3; nc2 = 2 v3 = True; nr3 = 4; nc3 = 0 result1 = cre.tea( v1, nr1, nc1 ) result2 = cre.tea( v2, nr2, nc2 ) result3 = cre.tea( v3, nr3, nc3 ) print( 'tea( ', str( v1 ) + ', ' + str( nr1 ) + ', ' + str( nc1 ) + ' ) :', result1 ) print( 'tea(', " '" + v2 + "', " + str( nr2 ) + ', ' + str( nc2 ) + ' ) :', result2 ) print( 'tea(', str( v3 ) + ', ' + str( nr3 ) + ', ' + str( nc3 ) + ' ) :', result3 ) def test_wid() : import wid x1 = [ 'a', 'b', 'c', 'd', 'e' ] y1 = [ 1, 2, 3, 4, 5 ] x2 = [ 3, 1, 4, 1 ] y2 = [ 'odd', 'odd', 'even', 'odd' ] result1 = wid.get( x1, y1 ) result2 = wid.get( x2, y2 ) print( 'get( x1, y1 ):', result1 ) print( 'get( x2, y2 ):', result2 ) def test_duck() : import duck result = duck.quack() print( 'quack():', result ) def test_mm() : import mm tests = [ 0.0154324*5, 1, 2000 ] for lbs in tests : result = mm.conv( lbs ) print( 'conv(', lbs, '):', result ) def test_com() : import com tests = [ [ 5, 3 ], [ 8, 2], [ 12, 4 ] ] for test in tests : n, c = test result = com.sob( n, c ) print( 'sob(', str( n ) + ',', c, '):', result )