-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow parsing the empty string (as None)
- Loading branch information
Showing
3 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
from builtins import int | ||
|
||
from OMPython import OMTypedParser | ||
|
||
import unittest | ||
|
||
typeCheck = OMTypedParser.parseString | ||
|
||
|
||
class TypeCheckTester(unittest.TestCase): | ||
def testNewlineBehaviour(self): | ||
pass | ||
|
||
def testBoolean(self): | ||
self.assertEqual(typeCheck('true'), True) | ||
self.assertEqual(typeCheck('false'), False) | ||
|
||
def testInt(self): | ||
self.assertEqual(typeCheck('2'), 2) | ||
self.assertEqual(type(typeCheck('1')), int) | ||
self.assertEqual(type(typeCheck('123123123123123123232323')), int) | ||
self.assertEqual(type(typeCheck('9223372036854775808')), int) | ||
|
||
def testFloat(self): | ||
self.assertEqual(type(typeCheck('1.2e3')), float) | ||
|
||
def testIdent(self): | ||
self.assertEqual(typeCheck('blabla2'), "blabla2") | ||
pass | ||
|
||
def testEmpty(self): | ||
self.assertEqual(typeCheck(''), None) | ||
pass | ||
|
||
def testStr(self): | ||
pass | ||
|
||
def testUnStringable(self): | ||
pass | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |