Пример #1
0
    def test_altura_mayor_0(self):
        arbol_dummy2 = ArbolGeneral()
        arbol_dummy2._ArbolGeneral__raiz = self.ng2
        self.assertEqual(1, arbol_dummy2.altura())

        arbol_dummy3 = ArbolGeneral()
        arbol_dummy3._ArbolGeneral__raiz = self.ng2
        self.assertEqual(1, arbol_dummy3.altura())

        self.assertEqual(2, self.arbol_general.altura())
Пример #2
0
    def setUp(self):
        #self.DUMMY_0 = 'dummy0'
        #self.DUMMY_1 = 'dummy1'
        #self.DUMMY_2 = 'dummy2'
        #self.DUMMY_3 = 'dummy3'

        #self.lista = ListaConPyLista()
        #self.lista.agregar(self.DUMMY_0, 0)
        #self.lista.agregar(self.DUMMY_1, 1)
        #self.lista.agregar(self.DUMMY_2, 2)
        #self.lista.agregar(self.DUMMY_3, 2)

        #self.nodo_general = NodoGeneral()
        #self.nodo_general.setDato(self.DUMMY_0)
        #self.nodo_general.setHijos(self.lista)
        """
                        1
                        |
                   ----- -----
                  |           |
                  2           3
                  |           |
                -- --       -- --
               |     |     |     |
               4     5     6     7

        """
        self.ng7 = NodoGeneral()
        self.ng6 = NodoGeneral()
        self.ng5 = NodoGeneral()
        self.ng4 = NodoGeneral()
        self.ng2 = NodoGeneral()
        self.ng3 = NodoGeneral()
        self.ng1 = NodoGeneral()

        self.ng7._NodoGeneral__dato = 7
        self.ng6._NodoGeneral__dato = 6
        self.ng5._NodoGeneral__dato = 5
        self.ng4._NodoGeneral__dato = 4
        self.ng3._NodoGeneral__dato = 3
        self.ng2._NodoGeneral__dato = 2
        self.ng1._NodoGeneral__dato = 1

        self.l1 = ListaConPyLista()
        self.l2 = ListaConPyLista()
        self.l3 = ListaConPyLista()
        self.l4 = ListaConPyLista()
        self.l5 = ListaConPyLista()
        self.l6 = ListaConPyLista()
        self.l7 = ListaConPyLista()

        self.ag1 = ArbolGeneral()
        self.ag2 = ArbolGeneral()
        self.ag3 = ArbolGeneral()
        self.ag4 = ArbolGeneral()
        self.ag5 = ArbolGeneral()
        self.ag6 = ArbolGeneral()
        self.ag7 = ArbolGeneral()

        self.l3.agregar(self.ng6, 0)
        self.l3.agregar(self.ng7, 1)
        self.ng3._NodoGeneral__listaHijos = self.l3

        self.l2.agregar(self.ng4, 0)
        self.l2.agregar(self.ng5, 1)
        self.ng2._NodoGeneral__listaHijos = self.l2

        self.l1.agregar(self.ng2, 0)
        self.l1.agregar(self.ng3, 1)
        self.ng1._NodoGeneral__listaHijos = self.l1

        self.arbol_general = ArbolGeneral()
        self.arbol_general._ArbolGeneral__raiz = self.ng1
Пример #3
0
 def test_nivel_sin_datos(self):
     arbol_dummy = ArbolGeneral()
     self.assertEqual(-1, arbol_dummy.nivel(self.ng1))
Пример #4
0
    def test_altura_cero(self):
        arbol_dummy = ArbolGeneral()
        arbol_dummy._ArbolGeneral__raiz = self.ng7

        self.assertEqual(0, arbol_dummy.altura())
Пример #5
0
 def test_altura_sin_datos(self):
     arbol_dummy = ArbolGeneral()
     self.assertEqual(-1, arbol_dummy.altura())
Пример #6
0
    def test_get_hijos_none(self):
        arbol_dummy = ArbolGeneral()
        arbol_dummy._ArbolGeneral__raiz = self.ng7

        self.assertEqual(str(ListaConPyLista()), str(arbol_dummy.getHijos()))
Пример #7
0
 def test_inicio(self):
     ag = ArbolGeneral()
     self.assertEqual(None, ag._ArbolGeneral__raiz)