示例#1
0
 def testMethod():
     func = lib.getFunction('mylen', _fileName)
     for (l, r) in [([], 0), ([5], 1), (['a', 'b'], 2)]:
         res = func(l)
         if not assertlib.exact(res, r):
             return False, "mylen(%r) should be %i, but got %r" % \
                 (l, r, res)
     return True
示例#2
0
 def testMethod():
     func = lib.getFunction('convertFromSeconds', _fileName)
     for (s, exp) in [(610, [0, 0, 10, 10]), (100000, [1, 3, 46, 40])]:
         res = func(s)
         if not assertlib.exact(res, exp):
             return False, "convertFromSeconds(%i) should be %r, but got %r" % \
             (s, exp, res)
     return True
示例#3
0
 def testMethod():
     func = lib.getFunction('flipside', _fileName)
     for (s, exp) in [('homework', 'workhome'), ('carpets', 'petscar')]:
         res = func(s)
         if not assertlib.exact(res, exp):
             return False, "flipside(%s) should be %s, but got %s" % (
                 s, exp, res)
     return True
示例#4
0
 def testMethod():
     func = lib.getFunction('checkends', _fileName)
     for (s, exp) in [('no match', False), ('hah! a match', True),
                      ('q', True)]:
         res = func(s)
         if not assertlib.exact(res, exp):
             return False, "checkends(%s) should be %r, but got %r" % (
                 s, exp, res)
     return True
示例#5
0
 def testMethod():
     func = lib.getFunction('ind', _fileName)
     for (n, l, r) in [(42, [55, 77, 42, 12, 42, 100], 2),
                       (42, range(100), 42), ('i', 'team', 4)]:
         res = func(n, l)
         if not assertlib.exact(res, r):
             return False, "ind(%i, %r) should be %i, but got %r" % \
                 (l, r, res)
     return True
示例#6
0
 def testMethod():
     func = lib.getFunction('transcribe', _fileName)
     for (s, r) in [('ACGT TGCA', 'UGCAACGU'), ('GATTACA', 'CUAAUGU'),
                    ('cs5', '')]:
         res = func(s)
         if not assertlib.exact(res, r):
             return False, "transcribe(%s) should be %s, but got %r" % \
                 (s, r, res)
     return True
示例#7
0
 def testMethod():
     func = lib.getFunction('one_dna_to_rna', _fileName)
     for (s, r) in [('A', 'U'), ('C', 'G'), ('G', 'C'), ('T', 'A'),
                    (' ', ''), ('.', ''), ('0', '')]:
         res = func(s)
         if not assertlib.exact(res, r):
             return False, "one_dna_to_rna(%s) should be %s, but got %r" % (
                 s, r, res)
     return True
示例#8
0
 def testMethod():
     func = lib.getFunction('dbl', _fileName)
     for i in range(1, 10):
         res = func(i)
         exp = i * 2
         if not assertlib.exact(res, exp):
             return False, "%i doubled should be %i, but got %i" % (i, exp,
                                                                    res)
     return True
示例#9
0
 def testMethod():
     eps = 0.00001
     func = lib.getFunction('scrabbleScore', _fileName)
     for (s, r) in [('quetzal', 25), ('jonquil', 23), ('syzygy', 25)]:
         res = func(s)
         if not assertlib.exact(res, r):
             return False, "scrabbleScore(%s) should be %i, but got %r" % \
                 (s, r, res)
     return True
示例#10
0
 def testMethod():
     func = lib.getFunction('front3', _fileName)
     for s in ['Java', 'Chocolate', 'abc']:
         res = func(s)
         exp = s[:3] * 3
         if not assertlib.exact(res, exp):
             return False, "front3(%s) should be %s, but got %s" % (s, exp,
                                                                    res)
     return True
示例#11
0
 def testMethod():
     func = lib.getFunction('mult', _fileName)
     for i in range(10):
         for j in range(10):
             exp = i * j
             res = func(i, j)
             if not assertlib.exact(res, exp):
                 return False, "mult(%i, %i) should be %i, but got %r" % \
                     (i, j, r, res)
     return True
示例#12
0
 def testMethod():
     eps = 0.00001
     func = lib.getFunction('letterScore', _fileName)
     for (letters, r) in [('aeilnorstu', 1), ('dg', 2), ('bcmp', 3),
                          ('fhvwy', 4), ('k', 5), ('jx', 8), ('qz', 10),
                          (' ./=+!9', 0)]:
         for l in letters:
             res = func(l)
             if not assertlib.exact(res, r):
                 return False, "letterScore(%s) should be %i, but got %r" % (
                     l, r, res)
     return True
示例#13
0
def answer9(test):
    test.test = lambda: assertlib.exact(
        lib.outputOf(_fileName).split("\n")[9], "legomyego")
    test.description = lambda: "correct output for answer9"
示例#14
0
def answer10(test):
    test.test = lambda: assertlib.exact(
        lib.outputOf(_fileName).split("\n")[10], "clearcall")
    test.description = lambda: "correct output for answer10"
示例#15
0
def answer0(test):
    test.test = lambda: assertlib.exact(
        lib.outputOf(_fileName).split("\n")[0], "[2, 5, 9]")
    test.description = lambda: "correct output for answer0"
示例#16
0
def answer8(test):
    test.test = lambda: assertlib.exact(
        lib.outputOf(_fileName).split("\n")[8], "hardeharharhar")
    test.description = lambda: "correct output for answer8"
示例#17
0
def answer7(test):
    test.test = lambda: assertlib.exact(
        lib.outputOf(_fileName).split("\n")[7], "arveyudd")
    test.description = lambda: "correct output for answer7"
示例#18
0
def answer6(test):
    test.test = lambda: assertlib.exact(
        lib.outputOf(_fileName).split("\n")[6], "collude")
    test.description = lambda: "correct output for answer6"
示例#19
0
def answer5(test):
    test.test = lambda: assertlib.exact(
        lib.outputOf(_fileName).split("\n")[5], "heyyou")
    test.description = lambda: "correct output for answer5"
示例#20
0
def answer4(test):
    test.test = lambda: assertlib.exact(
        lib.outputOf(_fileName).split("\n")[4], "[1, 2, 3, 4, 5]")
    test.description = lambda: "correct output for answer4"
示例#21
0
def answer2(test):
    test.test = lambda: assertlib.exact(
        lib.outputOf(_fileName).split("\n")[2], "[9, 1, 1]")
    test.description = lambda: "correct output for answer2"