示例#1
0
 def test_or_else(self):
     self.assertEqual(EMPTY.or_else(1), 1)
     self.assertIsNone(Optional(None).or_else(10))
     self.assertEqual(Optional(10).or_else(1), 10)
示例#2
0
 def test_present(self):
     self.assertFalse(EMPTY.present())
     self.assertTrue(Optional(None).present())
     self.assertTrue(Optional(1).present())
示例#3
0
 def test_get1(self):
     self.assertIsNone(Optional(None).get())
     self.assertEqual(Optional(1).get(), 1)
示例#4
0
 def test_EMPTY(self):
     self.assertNotEqual(EMPTY, Optional(None))
     self.assertNotEqual(Optional(None), EMPTY)
     self.assertNotEqual(EMPTY, Optional(1))
     self.assertNotEqual(Optional(1), EMPTY)