-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
91 lines (73 loc) · 2.22 KB
/
index.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
86
87
88
89
90
91
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="theme-color" : content=rgb(223,219,219)>
<style>
body {
background-color: rgb(223, 219, 219);
}
</style>
</head>
<body>
<!-- unit tests -->
<h2>unit tests</h2>
<form id=unitTestForm name="unitTestForm">
<b>Unit Test #1</b><br>
<input id="unitTest1Input" name="unitTest1Input" type="int" /><br><br>
</form>
<button onclick="doUnitTests()">Execute Unit Test</button>
<!--this is the area where user is displayed-->
<div id="panel"><br>
<div id="unittestresults"></div>
</div>
<!-- output results for simple interest calculator -->
<span id="container"></span>
<script src="./main.js"></script>
<script>
//handle the run button
var form = document.getElementById("unitTestForm");
//unit test inputs and return values
var UnitTest1Input = 0;
var UnitTest1Ret = -1;;
form.addEventListener("click", doUnitTests);
doUnitTest1 = Module.cwrap('UnitTest1', 'number', ['number']);
//unit tests section
//executeUnitTest1
function executeUnitTest1(UnitTest1Input) {
//check for input values
if (UnitTest1Input != 0) {
return doUnitTest1(UnitTest1Input);
}
return -1;
}
//parse unit test input parameter
function parseInputInt(x, base) {
const parsed = parseInt(x, base);
if (isNaN(parsed)) { return 0; }
return parsed;
}
//check unit test selections
function doUnitTests() {
//run unit tests
var fieldNameElement = document.getElementById('unittestresults');
fieldNameElement.innerHTML = "";
//add unit tests here
const UnitTest1Input = form.elements['unitTest1Input'];
//check Unit Test 1 input value
let UnitTest1InputValue = parseInputInt(UnitTest1Input.value);
//run Unit Test 1 if input not left blank or 0
if (UnitTest1InputValue != 0) {
UnitTest1Ret = executeUnitTest1(UnitTest1InputValue);
if (UnitTest1Ret == 0) {
fieldNameElement.innerHTML += "Unit Test 1 Success \n";
}
else {
fieldNameElement.innerHTML += "Unit Test 1 Failed \n";
}
//end Unit Test 1
}
}
</script>
</body>
</html>