-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnitTests.htm
56 lines (38 loc) · 1.42 KB
/
UnitTests.htm
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Unit Tests for my A* algorythm</title>
<link rel="stylesheet" href="./bower_components/qunit/qunit/qunit.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src = "./A-STAR.js"></script>
<script src="./bower_components/qunit/qunit/qunit.js"></script>
<script src="./bower_components/lodash/lodash.js"></script>
<script>
QUnit.test( "Testing the A-STAR library", function( assert ) {
var m = new ASTAR.Map([
{"x":123,"y":280,"connectedTo":[1,5]},
{"x":275,"y":94,"connectedTo":[0,2]},
{"x":638,"y":75,"connectedTo":[1,3,5]},
{"x":821,"y":280,"connectedTo":[2,4]},
{"x":657,"y":469,"connectedTo":[3,5]},
{"x":286,"y":462,"connectedTo":[4,0,2]}
]);
assert.ok(_.isEqual(m.path(0,5),[0,5]), "Test 1");
assert.ok(_.isEqual(m.path(1,4),[1,2,3,4]), "Test 2");
assert.ok(_.isEqual(m.path(2,5),[2,5]), "Test 3");
assert.ok(_.isEqual(m.path(1,3),[1,2,3]), "Test 4");
assert.ok(_.isEqual(m.path(3,0),[3,4,5,0]), "Test 4");
// Granted, not exactly a unit test, but this does its job just perfectly.
var b = m.append({"x":123,"y":340,"connectedTo":[0,1,5]});
alert(JSON.stringify(b));
var c = b.remove(2);
alert(JSON.stringify(c));
});
</script>
</body>
</html>