Ejemplo n.º 1
0
 def test_polynoms_diff_when_lenghts_are_equal2(self):
     a = Polynome([3, 6, 2])
     b = Polynome([-1, -2, -2])
     c = a - b
     self.assertEqual("4x^2 + 8x + 4", c.ToString())
    def test_polynomeA_not_equal_to_number(self):
        a = Polynome([1, 2])

        self.assertTrue(a != 2)
    def test_polynomeA_equals_polynomeB(self):
        a = Polynome([1, 2, 3, 4])
        b = Polynome([1, 2, 3, 4])

        self.assertTrue(a == b)
Ejemplo n.º 4
0
    def test_mult_polynom_by_number(self):
        polynom = Polynome([1, 3, 4, 0]) * -1

        self.assertEqual("- x^3 - 3x^2 - 4x", polynom.ToString())
    def test_polynomeA_not_equal_to_character(self):
        a = Polynome([1, 2])

        self.assertTrue(a != "b")
Ejemplo n.º 6
0
    def test_toString_when_minus1_at_start(self):
        polynom = Polynome([-1, -3, -4, 0])

        self.assertEqual("- x^3 - 3x^2 - 4x", polynom.ToString())
Ejemplo n.º 7
0
    def test_mult_polynoms1(self):
        a = Polynome([1, 2])
        b = Polynome([2, 1])
        c = a * b

        self.assertEqual("2x^2 + 5x + 2", c.ToString())
Ejemplo n.º 8
0
 def test_polynoms_sum_when_second_lenght_bigger2(self):
     a = Polynome([4, 3, 4, 5, 0])
     b = Polynome([-2, -0.0001])
     c = b + a
     self.assertEqual("4x^4 + 3x^3 + 4x^2 + 3x - 0.0001", c.ToString())
Ejemplo n.º 9
0
 def test_polynoms_sum_when_fisrt_lenght_bigger1(self):
     a = Polynome([1, 2])
     b = Polynome([2])
     c = a + b
     self.assertEqual("x + 4", c.ToString())
Ejemplo n.º 10
0
 def test_polynoms_sum_when_lenghts_are_equal2(self):
     a = Polynome([3, 6, 2])
     b = Polynome([-1, -2, -2])
     c = a + b
     self.assertEqual("2x^2 + 4x", c.ToString())
Ejemplo n.º 11
0
 def test_polynoms_sum_when_second_lenght_bigger1(self):
     a = Polynome([1, 2])
     b = Polynome([2])
     c = b + a
     self.assertEqual("x + 4", c.ToString())
Ejemplo n.º 12
0
 def test_polynoms_sum_when_lenghts_are_equal1(self):
     a = Polynome([1, 2])
     b = Polynome([-1, -2])
     c = a + b
     self.assertEqual("0", c.ToString())
Ejemplo n.º 13
0
 def test_polynoms_diff_when_second_lenght_bigger2(self):
     a = Polynome([4, 3, 4, 5, 0])
     b = Polynome([-2, -0.0001])
     c = b - a
     self.assertEqual("- 4x^4 - 3x^3 - 4x^2 - 7x - 0.0001", c.ToString())
Ejemplo n.º 14
0
 def test_polynoms_diff_when_second_lenght_bigger1(self):
     a = Polynome([1, 2])
     b = Polynome([2])
     c = b - a
     self.assertEqual("- x", c.ToString())
Ejemplo n.º 15
0
    def test_toString_when_all_cooefs_are_zero(self):
        polynom = Polynome([0, -0, 0])

        self.assertEqual("0", polynom.ToString())
Ejemplo n.º 16
0
    def test_toString_when_one_cooef_is_zero(self):
        polynom = Polynome([2, 0, -1])

        self.assertEqual("2x^2 - 1", polynom.ToString())
Ejemplo n.º 17
0
    def test_toString_when_cooefs_with_floating_points(self):
        polynom = Polynome([0.102, -1.1, -4.5000, 0.00120])

        self.assertEqual("0.102x^3 - 1.1x^2 - 4.5x + 0.0012",
                         polynom.ToString())
Ejemplo n.º 18
0
    def test_toString_when_only_one_cooef_0(self):
        polynom = Polynome([0])

        self.assertEqual("0", polynom.ToString())
Ejemplo n.º 19
0
    def test_toString_when_polynom_has_cooef1(self):
        polynom = Polynome([8, -4, -2, 1, -2, -1, 0])

        self.assertEqual("8x^6 - 4x^5 - 2x^4 + x^3 - 2x^2 - x",
                         polynom.ToString())
Ejemplo n.º 20
0
    def test_toString_when_cooefs_end_with_1(self):
        polynom = Polynome([2, 3, 1])

        self.assertEqual("2x^2 + 3x + 1", polynom.ToString())
Ejemplo n.º 21
0
    def test_mult_polynoms2(self):
        a = Polynome([4, 0, -3, -1])
        b = Polynome([2, -1, 1, 0])
        c = a * b

        self.assertEqual("8x^6 - 4x^5 - 2x^4 + x^3 - 2x^2 - x", c.ToString())
Ejemplo n.º 22
0
    def test_toString_when_first_cooef_is_zero(self):
        polynom = Polynome([0, 3, 1])

        self.assertEqual("3x + 1", polynom.ToString())
Ejemplo n.º 23
0
    def test_polynomeA_not_equal_polynomeB_when_they_have_same_length(self):
        a = Polynome([1, 2])
        b = Polynome([1, 3])

        self.assertTrue(a != b)
Ejemplo n.º 24
0
    def test_toString_when_first_and_last_cooefs_are_zero(self):
        polynom = Polynome([0, 3, 0])

        self.assertEqual("3x", polynom.ToString())
Ejemplo n.º 25
0
    def test_polynomeA_not_equal_to_character2(self):
        a = Polynome([1, 2])

        self.assertFalse(a == "b")
Ejemplo n.º 26
0
    def test_toString_when_last_cooef_is_zero(self):
        polynom = Polynome([-4, 3, 0])

        self.assertEqual("- 4x^2 + 3x", polynom.ToString())
Ejemplo n.º 27
0
    def test_polynomeA_not_equal_to_list(self):
        a = Polynome([1, 2])

        self.assertTrue(a != [1, 2])
Ejemplo n.º 28
0
    def test_toString_when_three_cooefs(self):
        polynom = Polynome([1, 2, 3])

        self.assertEqual("x^2 + 2x + 3", polynom.ToString())
Ejemplo n.º 29
0
    def test_successed_initialization(self):

        Polynome([1, 2, 3]);
        Polynome([0]);
        Polynome([-0]);
Ejemplo n.º 30
0
 def test_polynoms_diff_when_lenghts_are_equal1(self):
     a = Polynome([1, 2])
     b = Polynome([-1, -2])
     c = a - b
     self.assertEqual("2x + 4", c.ToString())