-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod_test.ts
114 lines (96 loc) · 3.3 KB
/
mod_test.ts
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
ShangShield.ts by Alyx Shang.
Licensed under the FSL v1.
*/
// Importing the "SecurityInfo"
// JSON interface for explicit typing.
import { SecurityInfo } from "./mod.ts";
// Importing all functions to test them.
import * as shangshield from './mod.ts';
// Importing the "assertEquals" function
// to run tests.
import { assertEquals } from "@std/assert";
// Defining variables that will not be changed
// and are needed for running testing.
const pwd: string = "1456HoglinSteak_@@";
const letterWeight: number = 15;
const specialCharWeight: number = 16;
const falseScore: number = 6;
const trueScore: number = 1213;
const cutOff: number = 100;
const testResult: SecurityInfo = {
password: pwd,
score: trueScore,
cutOff: 100,
isSecure: true
};
// Testing the "isDigit" function. (true case).
Deno.test(
"Testing the \"isDigit\" function. (true case)",
() => assertEquals(shangshield.isDigit("3"),(true))
)
// Testing the "isDigit" function. (false case)
Deno.test(
"Testing the \"isDigit\" function. (false case)",
() => assertEquals(shangshield.isDigit("A"),(false))
)
// Testing the "isLetter" function. (true case)
Deno.test(
"Testing the \"isLetter\" function. (true case)",
() => assertEquals(shangshield.isLetter("A"),(true))
)
// Testing the "isLetter" function. (false case)
Deno.test(
"Testing the \"isLetter\" function. (false case)",
() => assertEquals(shangshield.isLetter("3"),(false))
)
// Testing the "stringType" function. (letter)
Deno.test(
"Testing the \"stringType\" function. (letter)",
() => assertEquals(shangshield.stringType("A"), "letter")
)
// Testing the "stringType" function. (digit)
Deno.test(
"Testing the \"stringType\" function. (digit)",
() => assertEquals(shangshield.stringType("3"), "digit")
)
// Testing the "stringType" function. (special)
Deno.test(
"Testing the \"stringType\" function. (special)",
() => assertEquals(shangshield.stringType("@"), "special")
)
// Testing the "getPositionFromChar" function.
Deno.test(
"Testing the \"getPositionFromChar\" function.",
() => assertEquals(shangshield.getPositionFromChar("D"), 4)
)
// Testing the "digitDistance" function. (normal case)
Deno.test(
"Testing the \"digitDistance\" function. (normal case)",
() => assertEquals(shangshield.digitDistance(4, 24), 20)
)
// Testing the "digitDistance" function. (special case)
Deno.test(
"Testing the \"digitDistance\" function. (special case)",
() => assertEquals(shangshield.digitDistance(24, 4), 20)
)
// Testing the "isSecure" function. (true case)
Deno.test(
"Testing the \"isSecure\" function. (true case)",
() => assertEquals(shangshield.isSecure(pwd,letterWeight,specialCharWeight,100), true)
)
// Testing the "isSecure" function. (false case)
Deno.test(
"Testing the \"isSecure\" function. (false case)",
() => assertEquals(shangshield.isSecure("123456",letterWeight,specialCharWeight,100), false)
)
// Testing the "securityScore" function.
Deno.test(
"Testing the \"securityScore\" function.",
() => assertEquals(shangshield.securityScore("123456",letterWeight,specialCharWeight), falseScore)
)
// Testing the "shieldSummary" function.
Deno.test(
"Testing the \"shieldSummary\" function.",
() => assertEquals(shangshield.shieldSummary(pwd,letterWeight,specialCharWeight,cutOff), testResult)
)