Skip to content

Commit 529d41c

Browse files
committed
Added tests for greedy algorithm
1 parent 6a28e44 commit 529d41c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_greedy_algorithm.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- coding: utf-8 -*-
2+
import unittest
3+
4+
from pygorithm.greedy_algorithm import (
5+
fractional_knapsack,
6+
)
7+
8+
9+
class TestFractionalKnapsack(unittest.TestCase):
10+
def test_fractional_knapsack(self):
11+
value = [60, 100, 120]
12+
weight = [10, 20, 30]
13+
W = 50
14+
self.assertEqual(fractional_knapsack.knapsack(W, value, weight), 240)
15+
16+
if __name__ == '__main__':
17+
unittest.main()

0 commit comments

Comments
 (0)