def test_function(self) :
     inputs, outputs = [], []
     for i in range(20) :
         val = np.random.randint(1,9999)
         inputs.append((val,)) 
         outputs.append(np.floor( val / 1000))
     assert( fc.check_func('numberOfThousands', inputs, outputs ) ) 
 def test_vals_correct(self):
     inputs, outputs = [], []
     for i in range(2, 10):
         inputs.append((i, ))
         myset = set([0])
         for j in range(i):
             for k in range(j + 1):
                 myset.add(j * k)
         outputs.append(myset)
     assert (fc.check_func('genMultiplications', inputs, outputs))
 def test_isInNaturals(self):
     inputs, outputs = [], []
     for i in range(20):
         a, b = np.random.randint(0, 20), np.random.randint(0, 20)
         inputs.append((
             a,
             b,
         ))
         if a - b > 0: outputs.append(1)
         else: outputs.append(0)
     assert (fc.check_func('isInNaturals', inputs, outputs))
 def test_function(self):
     inputs, outputs = [], []
     for i in range(20):
         val = np.random.randint(0, 63)
         inputs.append((val, ))
         oval = np.zeros(6)
         for j in range(6):
             ppp = 2**(5 - j)
             oval[j] = int(np.floor(val / ppp))
             val = val - oval[j] * ppp
         outputs.append(oval)
     assert (fc.check_func('getBinary', inputs, outputs))
 def test_function(self) :
     inputs, outputs = [], []
     for i in range(50) :
         val = np.random.randint(1,9999)
         inputs.append((val,))
         oval = np.zeros(4)
         for j in range(4) : 
             ppp = 10**(3-j)
             oval[j] = int(np.floor( val / ppp ) )
             val = val - oval[j]*ppp
         outputs.append( oval )
     assert( fc.check_func('getNumberArray', inputs, outputs ) )
 def test_isRational(self):
     inputs, outputs = [(
         1,
         0,
     )], [0]
     for i in range(200):
         a, b = np.random.randint(-10, 10), np.random.randint(-10, 10)
         inputs.append((
             a,
             b,
         ))
         if b == 0: outputs.append(0)
         else: outputs.append(1)
     assert (fc.check_func('isRational', inputs, outputs))
 def test_function(self) : 
     inputs, outputs, num = [], [], ""
     for i in range(1,400) :
         if (i+10)%100==0 : num = num.replace("LXXX","IC").replace("IX","")
         elif i%100==0 : num = num.replace("IC","C").replace("IX","")
         elif (i+10)%50==0 : num = num.replace("XXX","IL").replace("IX","")
         elif i%50==0 : num = num.replace("IL","L").replace("IX","")
         elif (i+1)%10==0 : num = num.replace("VIII","IX")
         elif i%10==0 : num = num.replace("IX","X")
         elif (i+1)%5==0 : num = num.replace("III","IV")
         elif i%5==0 : num = num.replace("IV","V")
         else : num = num + "I"
         inputs.append((i,))
         outputs.append( num ) 
     assert( fc.check_func( 'romanNumeral', inputs, outputs ) ) 
Beispiel #8
0
 def test_function(self):
     inputs, outputs = [], []
     for b in range(2, 11):
         for i in range(20):
             val = np.random.randint(0, 127)
             inputs.append((
                 val,
                 b,
             ))
             outval = np.zeros(7)
             for j in range(7):
                 ppp = b**(6 - j)
                 outval[j] = int(np.floor(val / ppp))
                 val = val - outval[j] * ppp
             outputs.append(outval)
     assert (fc.check_func('convertToBase', inputs, outputs))