def test_read_4 (self) : r = StringIO.StringIO("") al = [] h = [] td = {} b = pfd_read(r, al, h, td) self.assert_(b == False)
def test_read_2 (self) : r = StringIO.StringIO("1 0\n") al = {} h = [] td = {} b = pfd_read(r, al, h, td) self.assert_(b == True) self.assert_(al[1] == [])
def test_read_3 (self) : r = StringIO.StringIO("5 4\n2 1 1\n3 1 2\n4 1 3\n5 1 4\n") al = {} h = [] td = {} b = pfd_read(r, al, h, td) self.assert_(b == True) self.assert_(al[1] == [2]) self.assert_(al[2] == [3]) self.assert_(al[3] == [4]) self.assert_(al[4] == [5]) self.assert_(al[5] == [])
def test_read_1 (self) : r = StringIO.StringIO("5 4\n3 2 1 5\n2 2 5 3\n4 1 3\n5 1 1\n") al = {} h = [] td = {} b = pfd_read(r, al, h, td) self.assert_(b == True) self.assert_(al[1] == [3, 5]) self.assert_(al[2] == []) self.assert_(al[3] == [2, 4]) self.assert_(al[4] == []) self.assert_(al[5] == [3, 2])
def test_read_3 (self) : vertices = [Vertex() for _ in range(3)] vertices[1].numPred = 1 vertices[1].listPred = [2] vertices[2].listSuc = [1] r = StringIO.StringIO("2 1\n1 1 2\n2 0") v = pfd_read(r) self.assert_(len(vertices) == len(v)) self.assert_(vertices[1].numPred == v[1].numPred) self.assert_(vertices[1].listPred == v[1].listPred) self.assert_(vertices[2].numPred == v[2].numPred) self.assert_(vertices[2].listPred == v[2].listPred) self.assert_(vertices[2].listSuc == v[2].listSuc)
def test_read_1 (self) : vertices = [Vertex() for _ in range(6)] vertices[3].numPred = 2 vertices[3].listPred = [1, 5] vertices[2].numPred = 2 vertices[2].listPred = [5, 3] vertices[1].listSuc = [3] vertices[3].listSuc = [2] vertices[5].listSuc = [3, 2] r = StringIO.StringIO("5 2\n3 2 1 5\n2 2 5 3\n") v = pfd_read(r) self.assert_(len(vertices) == len(v)) self.assert_(vertices[3].numPred == v[3].numPred) self.assert_(vertices[3].listPred == v[3].listPred) self.assert_(vertices[2].numPred == v[2].numPred) self.assert_(vertices[2].listPred == v[2].listPred) self.assert_(vertices[1].listSuc == v[1].listSuc) self.assert_(vertices[1].listPred == v[1].listPred) self.assert_(vertices[3].listSuc == v[3].listSuc) self.assert_(vertices[5].listSuc == v[5].listSuc)
def test_read_2 (self) : vertices = [Vertex() for _ in range(7)] vertices[2].numPred = 2 vertices[2].listPred = [1, 3] vertices[3].numPred = 1 vertices[3].listPred = [1] vertices[4].numPred = 3 vertices[4].listPred = [2, 5, 6] vertices[5].numPred = 1 vertices[5].listPred = [3] vertices[6].numPred = 1 vertices[6].listPred = [5] vertices[1].listSuc = [2, 3] vertices[2].listSuc = [4] vertices[3].listSuc = [2, 5] vertices[5].listSuc = [4, 6] vertices[6].listSuc = [4] r = StringIO.StringIO("6 5\n2 2 1 3\n3 1 1\n4 3 2 5 6\n5 1 3\n6 1 5\n") v = pfd_read(r) self.assert_(len(vertices) == len(v)) self.assert_(vertices[2].numPred == v[2].numPred) self.assert_(vertices[2].listPred == v[2].listPred) self.assert_(vertices[3].numPred == v[3].numPred) self.assert_(vertices[3].listPred == v[3].listPred) self.assert_(vertices[4].numPred == v[4].numPred) self.assert_(vertices[4].listPred == v[4].listPred) self.assert_(vertices[5].numPred == v[5].numPred) self.assert_(vertices[5].listPred == v[5].listPred) self.assert_(vertices[6].numPred == v[6].numPred) self.assert_(vertices[6].listPred == v[6].listPred) self.assert_(vertices[1].listSuc == v[1].listSuc) self.assert_(vertices[2].listSuc == v[2].listSuc) self.assert_(vertices[3].listSuc == v[3].listSuc) self.assert_(vertices[4].listSuc == v[4].listSuc) self.assert_(vertices[5].listSuc == v[5].listSuc) self.assert_(vertices[6].listSuc == v[6].listSuc)
def test_read_3 (self) : r = StringIO.StringIO("5 1\n5 1 1") a = pfd_read(r) self.assert_(a == [[0, [5]], [0, []], [0, []], [0, []], [1, []]])
def test_read_2 (self) : r = StringIO.StringIO("5 4\n3 2 1 5\n2 2 5 3\n4 1 3\n5 1 1") a = pfd_read(r) self.assert_(a == [[0, [3, 5]], [2, []], [2, [2, 4]], [1, []], [1, [3, 2]]])
def test_read_1 (self) : r = StringIO.StringIO("2 1\n1 1 2") a = pfd_read(r) self.assert_(a == [[1, []], [0, [1]]])
def test_read_3(self): r = StringIO.StringIO("5 1\n5 1 1") a = pfd_read(r) self.assert_(a == [[0, [5]], [0, []], [0, []], [0, []], [1, []]])
def test_read_2(self): r = StringIO.StringIO("5 4\n3 2 1 5\n2 2 5 3\n4 1 3\n5 1 1") a = pfd_read(r) self.assert_( a == [[0, [3, 5]], [2, []], [2, [2, 4]], [1, []], [1, [3, 2]]])
def test_read_1(self): r = StringIO.StringIO("2 1\n1 1 2") a = pfd_read(r) self.assert_(a == [[1, []], [0, [1]]])
def test_read_3 (self): r = StringIO.StringIO("8721 2983798\n") tk, rl = pfd_read(r) self.assert_(tk == 8721) self.assert_(rl == 2983798)
def test_read_2 (self): r = StringIO.StringIO("5 4\n") tk, rl = pfd_read(r) self.assert_(tk == 5) self.assert_(rl == 4)
def test_read_1 (self) : r = StringIO.StringIO("1 10\n") tk, rl = pfd_read(r) self.assert_(tk == 1) self.assert_(rl == 10)