Skip to content

Commit

Permalink
Improved test coverage for types file
Browse files Browse the repository at this point in the history
  • Loading branch information
runfalk committed Dec 22, 2015
1 parent d918755 commit d751290
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spans/tests/test_types.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import pickle
import sys

from datetime import date, datetime, timedelta
from unittest import TestCase

from .._compat import uchr
from ..types import *

class TestIntRange(TestCase):
Expand Down Expand Up @@ -315,10 +317,19 @@ def test_invalid_bounds(self):
with self.assertRaises(ValueError):
floatrange(10.0, 5.0)

def test_less_than(self):
# Special case that discrete ranges can't cover
self.assertTrue(floatrange(1.0) < floatrange(1.0, lower_inc=False))
self.assertFalse(floatrange(1.0, lower_inc=False) < floatrange(1.0))

def test_contains(self):
self.assertTrue(floatrange(1.0, 5.0).contains(1.0))
self.assertTrue(floatrange(1.0, 5.0).contains(3.0))
self.assertFalse(floatrange(1.0, 5.0, lower_inc=False).contains(1.0))
self.assertTrue(
floatrange(1.0, 5.0, upper_inc=True).contains(5.0))
self.assertTrue(
floatrange(1.0, 5.0, lower_inc=False, upper_inc=True).contains(5.0))
self.assertFalse(floatrange(1.0, 5.0).contains(5.0))

def test_startswith(self):
Expand Down Expand Up @@ -382,6 +393,12 @@ def test_prev(self):
self.assertEqual(strrange.prev(u""), u"")
self.assertEqual(strrange.prev(u"b"), u"a")

# Confirm that wrap around is correct
self.assertEqual(strrange.prev(uchr(0)), uchr(sys.maxunicode))

def test_next(self):
self.assertEqual(strrange.next(u""), u"")
self.assertEqual(strrange.next(u"a"), u"b")

# Confirm that wrap around is correct
self.assertEqual(strrange.next(uchr(sys.maxunicode)), uchr(0))

0 comments on commit d751290

Please sign in to comment.