Skip to content

Commit 3ff4ec9

Browse files
committed
Add test_fuzzy_logic
1 parent 10bc341 commit 3ff4ec9

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

fuzzy_logic/test_fuzzy_logic.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import unittest
2+
from fuzzy_operations import FuzzySet
3+
4+
class TestFuzzySet(unittest.TestCase):
5+
def setUp(self):
6+
self.A = FuzzySet("A", 0, 0.5, 1)
7+
self.B = FuzzySet("B", 0.2, 0.7, 1)
8+
9+
def test_membership_within_boundaries(self):
10+
self.assertEqual(self.A.membership(0.1),0.2) # Modify with the expected value
11+
self.assertEqual(self.B.membership(0.6),0.8) # Modify with the expected value
12+
13+
def test_union(self):
14+
union_ab = self.A.union(self.B)
15+
self.assertEqual(union_ab.membership(0.1),0.1) # Modify with the expected value
16+
self.assertEqual(union_ab.membership(0.35),0.35) # Modify with the expected value
17+
18+
def test_intersection(self):
19+
intersection_ab = self.A.intersection(self.B)
20+
self.assertEqual(intersection_ab.membership(0.1),0.0) # Modify with the expected value
21+
self.assertEqual(intersection_ab.membership(0.35),0.18749999999999994) # Modify with the expected value
22+
23+
def test_complement(self):
24+
complement_a = self.A.complement()
25+
self.assertEqual(complement_a.membership(0.1),0.1) # Modify with the expected value
26+
self.assertEqual(complement_a.membership(0.75), 0.0) # Modify with the expected value
27+
28+
if __name__ == "__main__":
29+
unittest.main()

0 commit comments

Comments
 (0)