Skip to content

Commit aefbb51

Browse files
committed
测试
1 parent 700dbc8 commit aefbb51

File tree

2 files changed

+174
-1
lines changed

2 files changed

+174
-1
lines changed

design-an-atm-machine/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
export default function ATM() {
1+
export default ATM;
2+
type ATM = {
3+
deposit(banknotesCount: number[]): void;
4+
withdraw(amount: number): number[];
5+
};
6+
7+
function ATM(): ATM {
28
let moneyStore = new Map([
39
[20, 0],
410
[50, 0],

design-an-atm-machine/test.ts

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
2+
import { runScript } from "leetcode-class";
3+
import ATM from "./index.ts";
4+
Deno.test("design-an-atm-machine", () => {
5+
assertEquals(
6+
runScript(
7+
["ATM", "deposit", "withdraw", "deposit", "withdraw", "withdraw"],
8+
[[], [[0, 0, 1, 2, 1]], [600], [[0, 1, 0, 1, 1]], [600], [550]],
9+
[ATM],
10+
),
11+
[null, null, [0, 0, 1, 0, 1], null, [-1], [0, 1, 0, 0, 1]],
12+
);
13+
});
14+
Deno.test("design-an-atm-machine", () => {
15+
assertEquals(
16+
runScript(
17+
[
18+
"ATM",
19+
"withdraw",
20+
"withdraw",
21+
"withdraw",
22+
"deposit",
23+
"withdraw",
24+
"deposit",
25+
"deposit",
26+
"deposit",
27+
"withdraw",
28+
"deposit",
29+
"deposit",
30+
"withdraw",
31+
"withdraw",
32+
"withdraw",
33+
"deposit",
34+
"withdraw",
35+
"withdraw",
36+
"deposit",
37+
"deposit",
38+
"withdraw",
39+
"deposit",
40+
"deposit",
41+
"withdraw",
42+
"deposit",
43+
"deposit",
44+
"deposit",
45+
"deposit",
46+
"deposit",
47+
"withdraw",
48+
"deposit",
49+
"deposit",
50+
"deposit",
51+
"withdraw",
52+
"withdraw",
53+
"withdraw",
54+
"withdraw",
55+
"withdraw",
56+
"withdraw",
57+
"withdraw",
58+
"deposit",
59+
"withdraw",
60+
"withdraw",
61+
"deposit",
62+
"withdraw",
63+
"deposit",
64+
"withdraw",
65+
],
66+
[
67+
[],
68+
[761034295],
69+
[61525080],
70+
[174864345],
71+
[[358452, 666752, 106470, 349678, 54308]],
72+
[731538350],
73+
[[601825, 660860, 292958, 970473, 8734]],
74+
[[158352, 230840, 584830, 930578, 694508]],
75+
[[514076, 440930, 651443, 278260, 979506]],
76+
[497058270],
77+
[[133310, 708326, 899189, 33920, 347912]],
78+
[[303868, 383014, 987573, 463436, 12026]],
79+
[869223735],
80+
[181792350],
81+
[637002590],
82+
[[339075, 907619, 147999, 936557, 1981]],
83+
[752216315],
84+
[545310305],
85+
[[770860, 358659, 85899, 508223, 601813]],
86+
[[340254, 62912, 736965, 66084, 563153]],
87+
[860609765],
88+
[[472577, 898761, 759021, 711213, 991384]],
89+
[[352863, 993443, 470695, 771751, 885351]],
90+
[203746940],
91+
[[120462, 370974, 430415, 813965, 537750]],
92+
[[940761, 792840, 383659, 776650, 458842]],
93+
[[717775, 420637, 567990, 605599, 95258]],
94+
[[648203, 738843, 132683, 590799, 727288]],
95+
[[654744, 93342, 333659, 797144, 333668]],
96+
[789833560],
97+
[[608199, 496156, 841207, 700929, 455615]],
98+
[[196749, 158976, 15983, 957167, 277532]],
99+
[[136263, 500576, 687867, 846013, 779525]],
100+
[951029660],
101+
[470859140],
102+
[771294700],
103+
[390723140],
104+
[509143745],
105+
[815366855],
106+
[425443600],
107+
[[777238, 246202, 877954, 517113, 522097]],
108+
[75391260],
109+
[793642205],
110+
[[122930, 48921, 163827, 811227, 901960]],
111+
[856433570],
112+
[[842662, 59261, 38287, 570862, 937593]],
113+
[558135620],
114+
],
115+
[ATM],
116+
),
117+
[
118+
null,
119+
[-1],
120+
[-1],
121+
[-1],
122+
null,
123+
[-1],
124+
null,
125+
null,
126+
null,
127+
[1, 1, 0, 1, 994116],
128+
null,
129+
null,
130+
[-1],
131+
[0, 1, 1, 1, 363584],
132+
[2, 1, 1, 1336777, 739294],
133+
null,
134+
[-1],
135+
[-1],
136+
null,
137+
null,
138+
[-1],
139+
null,
140+
null,
141+
[2, 0, 0, 2, 407493],
142+
null,
143+
null,
144+
null,
145+
null,
146+
null,
147+
[-1],
148+
null,
149+
null,
150+
null,
151+
[-1],
152+
[2, 0, 1, 0, 941718],
153+
[0, 0, 0, 1, 1542589],
154+
[2, 0, 1, 0, 781446],
155+
[-1],
156+
[-1],
157+
[0, 0, 1, 0, 850887],
158+
null,
159+
[-1],
160+
[-1],
161+
null,
162+
[1, 1, 0, 0, 1712867],
163+
null,
164+
[1, 0, 1, 0, 1116271],
165+
],
166+
);
167+
});

0 commit comments

Comments
 (0)