forked from JOSMANC/WoodCutterBuddy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
33 lines (26 loc) · 945 Bytes
/
Copy pathtests.py
File metadata and controls
33 lines (26 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'''
Tests for WoodCutterBuddy
'''
import numpy as np
from WoodCutterBuddy import woodcutterbuddy, knapsack
def test_knapsack():
items = [(7, 2.9), (30, 1)]
C = 21
test1 = np.array_equal([3, 0], np.round(knapsack(items, C)))
items = [(6, 2.9), (3, 1), (5, 2.)]
C = 21
test2 = np.array_equal([3, 1, 0], np.round(knapsack(items, C)))
if ((test1+test2) == 2):
print 'knapsack tests passed'
def test_woodcutterbuddy():
supplies = (np.array([1, 2, 1]), np.array([2, 3, 6]))
cuts, cut_counts = woodcutterbuddy(supplies[0], supplies[1])
test1a = np.array_equal(np.array([[4, 1, 1],
[0, 2, 0],
[0, 0, 1]]), cuts)
test1b = np.array_equal(np.array([0, 1, 1]), cut_counts)
if ((test1a+test1b) == 2):
print 'woodcutterbuddy test passed'
if __name__ == "__main__":
test_knapsack()
test_woodcutterbuddy()