parent
4ddf68f6a0
commit
f6f225eaf8
|
@ -0,0 +1,37 @@
|
|||
from buffer import Buffer
|
||||
from point import Point
|
||||
|
||||
def p(x, y):
|
||||
return Point(x, y)
|
||||
|
||||
def setup():
|
||||
global b
|
||||
b = Buffer()
|
||||
b.set_lines(['one two three', 'four five'])
|
||||
|
||||
def fail(f):
|
||||
def new():
|
||||
try:
|
||||
f()
|
||||
except:
|
||||
return
|
||||
raise Exception("code did not raise an error")
|
||||
# set __name__ to accomodate nose's test detection
|
||||
new.__name__ = f.__name__
|
||||
return new
|
||||
|
||||
def test1(): assert b.make_string() == 'one two three\nfour five'
|
||||
def test2(): assert b.get_substring(p(0, 0), p(4, 0)) == 'one '
|
||||
def test3(): assert b.get_substring(p(0, 0), p(13, 0)) == 'one two three'
|
||||
|
||||
@fail
|
||||
def test4(): b.get_substring(p(0, 0), p(14, 0))
|
||||
|
||||
def test5(): assert b.get_substring(p(0, 0), p(0, 1)) == 'one two three\n'
|
||||
def test6(): assert b.get_substring(p(0, 1), p(9, 1)) == 'four five'
|
||||
|
||||
@fail
|
||||
def test7(): b.get_substring(p(0, 1), p(10, 1))
|
||||
|
||||
@fail
|
||||
def test8(): b.get_substring(p(0, 2), p(1, 2))
|
Loading…
Reference in New Issue