-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_runner_include.cfm
More file actions
66 lines (65 loc) · 1.68 KB
/
test_runner_include.cfm
File metadata and controls
66 lines (65 loc) · 1.68 KB
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
<cfif GetCurrentTemplatePath() eq GetBaseTemplatePath()>
<cfthrow message="This template should not be accessed directly." />
</cfif>
<cfoutput>
<!DOCTYPE html>
<html>
<head>
<title>#EncodeForHTML(Replace(ListLast(GetBaseTemplatePath(), '/\'), '.cfm', ''))#</title>
<style type="text/css">
table { border-collapse: collapse; }
table, th, td { border: 1px solid grey; }
th { text-align: left; padding: 2px 8px 2px 8px; }
td { padding: 2px 8px 2px 8px; }
span.correct { color: ##00ff00 }
span.incorrect { color: ##ff0000 }
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>Input</th>
<th>Expected output</th>
<th>Output</th>
<th>Status</th>
<th>Time taken</th>
</tr>
</thead>
<tbody>
<cfloop array="#testCases#" item="testCase">
<tr>
<td>
<cfset maxCharsToDisplay = 100 />
<pre>#EncodeForHTML(Left(testCase.input, maxCharsToDisplay))#<cfif Len(testCase.input) gt maxCharsToDisplay>…</cfif></pre>
</td>
<td>
<cfif StructKeyExists(testCase, 'expectedOutput')>
#EncodeForHTML(testCase.expectedOutput)#
</cfif>
</td>
<td>
<cfflush />
<cfset startTickCount = GetTickCount() />
<cfset actualOutput = solve(testCase.input) />
<cfset tickCountTaken = GetTickCount() - startTickCount />
#EncodeForHTML(actualOutput)#
<cfflush />
</td>
<td>
<cfif StructKeyExists(testCase, 'expectedOutput')>
<cfif actualOutput eq testCase.expectedOutput>
<span class="correct">Correct</span>
<cfelse>
<span class="incorrect">Incorrect</span>
</cfif>
</cfif>
</td>
<td>#tickCountTaken# ms</td>
</tr>
</cfloop>
</tbody>
</table>
</body>
</html>
</cfoutput>