-
Notifications
You must be signed in to change notification settings - Fork 0
/
qunit_test_endrings.html
85 lines (54 loc) · 2.56 KB
/
qunit_test_endrings.html
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<meta charset="utf-8">
<title>Test Suite</title>
<link rel="stylesheet" href="../../qunit-2.19.4/qunit-2.19.4.css">
<!-- <link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.19.4.css"> -->
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<!-- <script src="https://code.jquery.com/qunit/qunit-2.19.4.js"></script> -->
<script src="../../qunit-2.19.4/qunit-2.19.4.js"></script>
<script src="../../qunit-assert-close-git/qunit-assert-close/qunit-assert-close.js"></script>
<script src="debug.js"></script>
<!-- <script src="BCLegs.js"></script> -->
<script src="BCEndRings.js"></script>
<script src="BirdcageBuilder.js"></script>
<!-- see https://www.smashingmagazine.com/2012/06/introduction-to-javascript-unit-testing/ -->
<script>
QUnit.module('Birdcage End Rings', function() {
// TODO - double check all NaN results are correct; try to make some better/more meaningful tests
// TODO test that all numbers are Numbers?
//QUnit.test('Constructor & Types', function(assert) {
//}
QUnit.test('General Math', function(assert) {
/* Confirming general Javascript Math/IEEE-754 assumptions */
assert.equal(Math.log(1), 0);
assert.equal(Math.log(0), Number.NEGATIVE_INFINITY);
assert.equal(Math.log(0) + 0.5, Number.NEGATIVE_INFINITY);
assert.equal(2*Math.log(0), Number.NEGATIVE_INFINITY);
assert.equal(2*Math.log(0) + 0.5, Number.NEGATIVE_INFINITY);
assert.true(Number.isNaN(0 * Infinity)); // inf * 0 is NaN
});
QUnit.test('Harct', function(assert) {
var er = new BCEndRings(16);
assert.equal(er.n_legs, 16);
assert.equal(er.harct(0), 0);
assert.equal(er.harct(-1), Number.NEGATIVE_INFINITY);
});
QUnit.test('Rectangular Self Inductance', function(assert) {
//var bb = new BirdcageBuilder(16, 128e6, 10, 12);
var er = new BCEndRings(16);
assert.true(Number.isNaN(er.calc_er_self_inductance_rect(0, 1)));
assert.equal(er.calc_er_self_inductance_rect(1, 2), 1);
});
QUnit.test('Tubular Self Inductance (R_inner = 0)', function(assert) {
var er = new BCEndRings(16);
assert.equal(er.calc_er_self_inductance_tube(1, 0, 4), -1.5);
assert.true(Number.isNaN(er.calc_er_self_inductance_tube(0, 0, 4)));
});
// TODO continue tests
// TODO test final mutual inductance result
// TODO could test against Android/Java intermediate results (Leg/Endring Self & Mutual Inductance) with setup from qunit_test_all_math.html
}); // end Birdcage End Rings tests
</script>
</body>