From 0cd976f3227c390c0516abe121a28a01a8c0b57b Mon Sep 17 00:00:00 2001 From: STELLSAN Date: Thu, 26 Sep 2024 16:50:16 +0300 Subject: [PATCH 1/2] added test for lab1 --- .../test_Nedelin_Dmitry_complex_number.cpp | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 modules/complex-number/test/test_Nedelin_Dmitry_complex_number.cpp diff --git a/modules/complex-number/test/test_Nedelin_Dmitry_complex_number.cpp b/modules/complex-number/test/test_Nedelin_Dmitry_complex_number.cpp new file mode 100644 index 000000000..c48754a4b --- /dev/null +++ b/modules/complex-number/test/test_Nedelin_Dmitry_complex_number.cpp @@ -0,0 +1,56 @@ +// Copyright 2024 Nedelin Dmitry + +#include + +#include "include/complex_number.h" + +TEST(Nedelin_Dmitry_ComplexNumberTest, contructor_test) { + ASSERT_NO_THROW(ComplexNumber()); + ASSERT_NO_THROW(ComplexNumber(-15.0, 23.2)); + ASSERT_NO_THROW(ComplexNumber(ComplexNumber(-58.5781, 952.9172))); +} + +TEST(Nedelin_Dmitry_ComplexNumberTest, getter_test) { + ComplexNumber z(296.127, 28.12); + + ASSERT_DOUBLE_EQ(z.getRe(), 296.127); + ASSERT_DOUBLE_EQ(z.getIm(), 28.12); +} + +TEST(Nedelin_Dmitry_ComplexNumberTest, setter_test) { + ComplexNumber z{}; + z.setRe(123.257); + z.setIm(-95.159); + + ASSERT_DOUBLE_EQ(z.getRe(), 123.257); + ASSERT_DOUBLE_EQ(z.getIm(), -95.159); +} + +TEST(Nedelin_Dmitry_ComplexNumberTest, sum_operator_test) { + ComplexNumber z1(16.5, 12.3); + ComplexNumber z2(-16.5, 12.3); + + ComplexNumber res = z1 + z2; + + ASSERT_DOUBLE_EQ(res.getRe(), 0.0); + ASSERT_DOUBLE_EQ(res.getIm(), 24.6); +} + +TEST(Nedelin_Dmitry_ComplexNumberTest, dif_opetator_test) { + ComplexNumber z1(7.3, 32.6); + ComplexNumber z2(-2.7, 32.6); + + ComplexNumber res = z1 - z2; + + ASSERT_DOUBLE_EQ(res.getRe(), 10.0); + ASSERT_DOUBLE_EQ(res.getIm(), 0.0); +} + +TEST(Nedelin_Dmitry_ComplexNumberTest, equal_operator_test) { + ComplexNumber z1(5.0, 2.0); + ComplexNumber z2(5.0, 2.0); + ComplexNumber z3(7.0, 1.0); + + EXPECT_FALSE(z1 == z3); + EXPECT_TRUE(z1 == z2); +} \ No newline at end of file From 1941492d35e4a58c8bf7a13e37d715b31a98a117 Mon Sep 17 00:00:00 2001 From: STELLSAN Date: Thu, 26 Sep 2024 16:52:27 +0300 Subject: [PATCH 2/2] fix_actions_0 --- .../complex-number/test/test_Nedelin_Dmitry_complex_number.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/complex-number/test/test_Nedelin_Dmitry_complex_number.cpp b/modules/complex-number/test/test_Nedelin_Dmitry_complex_number.cpp index c48754a4b..0325f592d 100644 --- a/modules/complex-number/test/test_Nedelin_Dmitry_complex_number.cpp +++ b/modules/complex-number/test/test_Nedelin_Dmitry_complex_number.cpp @@ -1,7 +1,6 @@ // Copyright 2024 Nedelin Dmitry #include - #include "include/complex_number.h" TEST(Nedelin_Dmitry_ComplexNumberTest, contructor_test) {