-module(complex_numbers_tests). % This file is automatically generated from the exercises canonical data. -include_lib("erl_exercism/include/exercism.hrl"). -include_lib("eunit/include/eunit.hrl"). imaginary_unit_test() -> ?assert(complex_numbers:equal(complex_numbers:new(-1, 0), complex_numbers:mul(complex_numbers:new(0, 1), complex_numbers:new(0, 1)))). add_purely_real_numbers_test() -> ?assert(complex_numbers:equal(complex_numbers:new(3, 0), complex_numbers:add(complex_numbers:new(1, 0), complex_numbers:new(2, 0)))). add_purely_imaginary_numbers_test() -> ?assert(complex_numbers:equal(complex_numbers:new(0, 3), complex_numbers:add(complex_numbers:new(0, 1), complex_numbers:new(0, 2)))). add_numbers_with_real_and_imaginary_part_test() -> ?assert(complex_numbers:equal(complex_numbers:new(4, 6), complex_numbers:add(complex_numbers:new(1, 2), complex_numbers:new(3, 4)))). subtract_purely_real_numbers_test() -> ?assert(complex_numbers:equal(complex_numbers:new(-1, 0), complex_numbers:sub(complex_numbers:new(1, 0), complex_numbers:new(2, 0)))). subtract_purely_imaginary_numbers_test() -> ?assert(complex_numbers:equal(complex_numbers:new(0, -1), complex_numbers:sub(complex_numbers:new(0, 1), complex_numbers:new(0, 2)))). subtract_numbers_with_real_and_imaginary_part_test() -> ?assert(complex_numbers:equal(complex_numbers:new(-2, -2), complex_numbers:sub(complex_numbers:new(1, 2), complex_numbers:new(3, 4)))). multiply_purely_real_numbers_test() -> ?assert(complex_numbers:equal(complex_numbers:new(2, 0), complex_numbers:mul(complex_numbers:new(1, 0), complex_numbers:new(2, 0)))). multiply_purely_imaginary_numbers_test() -> ?assert(complex_numbers:equal(complex_numbers:new(-2, 0), complex_numbers:mul(complex_numbers:new(0, 1), complex_numbers:new(0, 2)))). multiply_numbers_with_real_and_imaginary_part_test() -> ?assert(complex_numbers:equal(complex_numbers:new(-5, 10), complex_numbers:mul(complex_numbers:new(1, 2), complex_numbers:new(3, 4)))). divide_purely_real_numbers_test() -> ?assert(complex_numbers:equal(complex_numbers:new(5.0e-1, 0), complex_numbers:divide(complex_numbers:new(1, 0), complex_numbers:new(2, 0)))). divide_purely_imaginary_numbers_test() -> ?assert(complex_numbers:equal(complex_numbers:new(5.0e-1, 0), complex_numbers:divide(complex_numbers:new(0, 1), complex_numbers:new(0, 2)))). divide_numbers_with_real_and_imaginary_part_test() -> ?assert(complex_numbers:equal(complex_numbers:new(4.4e-1, 8.0e-2), complex_numbers:divide(complex_numbers:new(1, 2), complex_numbers:new(3, 4)))). absolute_value_of_a_positive_purely_real_number_test() -> ?assert(5 == complex_numbers:abs(complex_numbers:new(5, 0))). absolute_value_of_a_negative_purely_real_number_test() -> ?assert(5 == complex_numbers:abs(complex_numbers:new(-5, 0))). absolute_value_of_a_purely_imaginary_number_with_positive_imaginary_part_test() -> ?assert(5 == complex_numbers:abs(complex_numbers:new(0, 5))). absolute_value_of_a_purely_imaginary_number_with_negative_imaginary_part_test() -> ?assert(5 == complex_numbers:abs(complex_numbers:new(0, -5))). absolute_value_of_a_number_with_real_and_imaginary_part_test() -> ?assert(5 == complex_numbers:abs(complex_numbers:new(3, 4))). conjugate_a_purely_real_number_test() -> ?assert(complex_numbers:equal(complex_numbers:new(5, 0), complex_numbers:conjugate(complex_numbers:new(5, 0)))). conjugate_a_purely_imaginary_number_test() -> ?assert(complex_numbers:equal(complex_numbers:new(0, -5), complex_numbers:conjugate(complex_numbers:new(0, 5)))). conjugate_a_number_with_real_and_imaginary_part_test() -> ?assert(complex_numbers:equal(complex_numbers:new(1, -1), complex_numbers:conjugate(complex_numbers:new(1, 1)))). real_part_of_a_purely_real_number_test() -> ?assert(1 == complex_numbers:real(complex_numbers:new(1, 0))). real_part_of_a_purely_imaginary_number_test() -> ?assert(0 == complex_numbers:real(complex_numbers:new(0, 1))). real_part_of_a_number_with_real_and_imaginary_part_test() -> ?assert(1 == complex_numbers:real(complex_numbers:new(1, 2))). imaginary_part_of_a_purely_real_number_test() -> ?assert(0 == complex_numbers:imaginary(complex_numbers:new(1, 0))). imaginary_part_of_a_purely_imaginary_number_test() -> ?assert(1 == complex_numbers:imaginary(complex_numbers:new(0, 1))). imaginary_part_of_a_number_with_real_and_imaginary_part_test() -> ?assert(2 == complex_numbers:imaginary(complex_numbers:new(1, 2))). eulers_identityformula_test() -> ?assert(complex_numbers:equal(complex_numbers:new(-1, 0), complex_numbers:exp(complex_numbers:new(0, 3.14159265358979311600)))). exponential_of_0_test() -> ?assert(complex_numbers:equal(complex_numbers:new(1, 0), complex_numbers:exp(complex_numbers:new(0, 0)))). exponential_of_a_purely_real_number_test() -> ?assert(complex_numbers:equal(complex_numbers:new(2.71828182845904509080, 0), complex_numbers:exp(complex_numbers:new(1, 0)))). version_test() -> ?assertMatch(1, complex_numbers:test_version()).