def test_dynamic(self): """ Tests that the primary and the reference implementations yield the same result over 1000 sets of randomly generated inputs """ reps = 1000 while reps>0: sstr = rand_string(random.randint(10, 1000)) sset = rand_string(random.randint(1,256)) ref = checkStringRef(sstr, sset) out = stringcheck.checkString(sstr, sset) self.assertTrue(ref == out) reps -= 1
def test_static(self): """ Tests the primary implementation against known static examples """ self.assertTrue(stringcheck.checkString('Foo bar baz', all_ascii)==0) self.assertTrue(stringcheck.checkString('IsraelTechChallenge2015!', 't98765!')==22) self.assertTrue(stringcheck.checkString('testing testing', '123')==15)