require_relative 'test_helper' class TestTerm < MiniTest::Unit::TestCase def test_initializer assert_equal 0, Term.new.coefficient assert_equal 0, Term.new.exponent end def test_parsing_with_standard_format assert_equal 4, Term.parse('4x^2').coefficient assert_equal 2, Term.parse('4x^2').exponent end def test_parsing_with_default_exponent_equal_to_one assert_equal 1, Term.parse('1x').coefficient assert_equal 1, Term.parse('1x').exponent end def test_parsing_with_default_coefficient_equal_to_one assert_equal 1.0, Term.parse('x^6').coefficient assert_equal 6, Term.parse('x^6').exponent end def test_parsing_variable_omitted assert_equal 6, Term.parse('6').coefficient assert_equal 0, Term.parse('6').exponent end end