def testSingleNode(self): """Tests a single node is expanded to a list with the label string.""" # 'ab' -> [ 'ab' ] node1 = ( 'ab', [ None ] ) words = [ 'ab' ] self.assertEqual(make_dafsa.to_words(node1), words)
def testChain(self): """Tests a sequence of nodes are preoperly expanded.""" # 'ab' -> 'cd' => [ 'abcd' ] node2 = ( 'cd', [ None ] ) node1 = ( 'ab', [ node2 ] ) words = [ 'abcd' ] self.assertEqual(make_dafsa.to_words(node1), words)
def testInnerTerminator(self): """Tests a sequence with an inner terminator is expanded to two strings.""" # 'a' -> 'b' # \ => [ 'ab', 'a' ] # {sink} node2 = ( 'b', [ None ] ) node1 = ( 'a', [ node2, None ] ) words = [ 'ab', 'a' ] self.assertEqual(make_dafsa.to_words(node1), words)
def testDiamond(self): """Tests a diamond can be expanded to a word list.""" # 'cd' # / \ # 'ab' 'gh' # \ / # 'ef' node4 = ( 'gh', [ None ] ) node3 = ( 'ef', [ node4 ] ) node2 = ( 'cd', [ node4 ] ) node1 = ( 'ab', [ node2, node3 ] ) words = [ 'abcdgh', 'abefgh' ] self.assertEqual(make_dafsa.to_words(node1), words)
def testSink(self): """Tests the sink is exapnded to a list with an empty string.""" node1 = None words = [ '' ] self.assertEqual(make_dafsa.to_words(node1), words)