Commit b3302857 authored by SETaratukhina's avatar SETaratukhina
Browse files

Update test.py

parent 9390a17d
Pipeline #3925 failed with stage
in 4 seconds
......@@ -2,33 +2,29 @@ import unittest
import math
from main import TAircraft, TMissle, RLS
class testRLS(unittest.TestCase):
def test_Aircraft(self):
def test_Aircraft(self):
aircraft = TAircraft(9, 30, 15, math.pi/6)
aircraft = TAircraft(10, 27, 16, math.pi/6)
aircraft.T0 = 0
aircraft.Move(10)
self.assertEqual(round(aircraft.x, 2), -12492.44)
self.assertEqual(round(aircraft .y, 2), -7187.71)
self.assertEqual(round(aircraft.x, 2), -13324.87)
self.assertEqual(round(aircraft .y, 2), -7671.89)
def test_Missle(self):
missle = TMissle(5, 10, 20, math.pi/6, 15)
missle = TMissle(10, 20, 40, math.pi/6, 15)
missle.T0 = 0
missle.Move(0.1)
self.assertEqual(round(missle.x, 2), -174.19)
self.assertEqual(round(missle.y, 2), -93.45)
self.assertEqual(round(missle.x, 2), -335.87)
self.assertEqual(round(missle.y, 2), -179.69)
def testRlsPeleng(self):
air1 = TAircraft(20, 10, 25, math.pi / 3)
air2 = TAircraft(2000, 2000, 200, math.pi / 6)
air1 = TAircraft(250, 100, 100, math.pi / 3)
air2 = TAircraft(200, 110, 100, math.pi / 4)
mis1 = TMissle(100, 50, 50, math.pi / 4, 30)
mis2 = TMissle(1100, 2100, 150, math.pi / 4, 30)
mis1 = TMissle(2500, -144, 1070, math.pi / 4, 50)
mis2 = TMissle(108, 277, 278, math.pi / 4, 50)
Rls = RLS(50, 100, 900)
Rls = RLS(50, 100, 1000)
Rls.Targets.append(air1)
Rls.Targets.append(air2)
Rls.Targets.append(mis1)
......@@ -40,14 +36,10 @@ class testRLS(unittest.TestCase):
for line in f:
lines.append(line)
f.close()
true_lines = ['0.1; Aircraft #1; D = 334.0743692766258; Az = 0.9795746556124477\n',
'0.1; Missle #1; D = 514.929470155641; Az = 0.8501314037713014\n',
'0.2; Aircraft #1; D = 574.4377296150348; Az = 1.006690412224313\n',
'0.3; Aircraft #1; D = 814.9350053796323; Az = 1.01828854721129\n']
true_lines = ['0.1; Aircraft #1; D = 879.5831366738453; Az = 1.1925584275755705\n','0.1; Aircraft #2; D = 854.9744193981306; Az = 0.8572177922360511\n']
self.assertEqual(lines, true_lines)
print('All tests passed correctly!')
if __name__ == '__main__':
unittest.main()
......@@ -57,3 +49,4 @@ if __name__ == '__main__':
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment