Skip to content

Instantly share code, notes, and snippets.

@typosone
Last active August 29, 2015 14:25
Show Gist options
  • Save typosone/dca841028879a9790039 to your computer and use it in GitHub Desktop.
Save typosone/dca841028879a9790039 to your computer and use it in GitHub Desktop.
学籍番号チェック関数のテストケース
import unittest
import student_code
class StudentCodeTest(unittest.TestCase):
exists_student_codes = [
's15001', 's15002', 's15003', 's15004', 's15005',
's15006', 's15007', 's15008', 's15009', 's15010',
's15011', 's15012', 's15013', 's15014',
'n15001', 'n15002', 'n15003', 'n15004', 'n15005',
'n15006', 'n15007', 'n15009', 'n15010',
'n15011',]
invalid_code_pattern = [
'as15001', 'an15001', 's14001', 'n14001', 's1501', 'n1502',
's150001', 'n150001', 's' ,'n' ,'15001', '1' ,'2', '3',
'c15101', 'c15201', 'c15301', 's1500g', 'n1500h', '15n0sd',
'15s01a', 'うんち', 's15001',
's15101', 'n15101', 's15201', 'n15201',]
def test_exists_code(self):
for code in self.exists_student_codes:
self.assertTrue(student_code.is_valid_student_code(code))
def test_invalid_code(self):
for code in self.invalid_code_pattern:
self.assertFalse(student_code.is_valid_student_code(code))
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment