Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d18391e

Browse files
authored
Fix the testcases (leetcode-tools#12)
1 parent b9f0303 commit d18391e

File tree

5 files changed

+33
-16
lines changed

5 files changed

+33
-16
lines changed

‎test/mock/add-two-numbers.20161015.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"state":"ac","id":2,"category":"algorithms","name":"Add Two Numbers","key":"add-two-numbers","link":"https://leetcode.com/problems/add-two-numbers","locked":false,"percent":25.368142876074806,"level":"Medium","starred":true,"totalAC":"195263","totalSubmit":"769711","desc":"You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.\r\n\r\nInput: (2 -> 4 -> 3) + (5 -> 6 -> 4)\r\nOutput: 7 -> 0 -> 8","templates":[{"value":"cpp","text":"C++","defaultCode":"/**\r\n * Definition for singly-linked list.\r\n * struct ListNode {\r\n * int val;\r\n * ListNode *next;\r\n * ListNode(int x) : val(x), next(NULL) {}\r\n * };\r\n */\r\nclass Solution {\r\npublic:\r\n ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {\r\n \r\n }\r\n};"},{"value":"java","text":"Java","defaultCode":"/**\r\n * Definition for singly-linked list.\r\n * public class ListNode {\r\n * int val;\r\n * ListNode next;\r\n * ListNode(int x) { val = x; }\r\n * }\r\n */\r\npublic class Solution {\r\n public ListNode addTwoNumbers(ListNode l1, ListNode l2) {\r\n \r\n }\r\n}"},{"value":"python","text":"Python","defaultCode":"# Definition for singly-linked list.\r\n# class ListNode(object):\r\n# def __init__(self, x):\r\n# self.val = x\r\n# self.next = None\r\n\r\nclass Solution(object):\r\n def addTwoNumbers(self, l1, l2):\r\n \"\"\"\r\n :type l1: ListNode\r\n :type l2: ListNode\r\n :rtype: ListNode\r\n \"\"\"\r\n "},{"value":"c","text":"C","defaultCode":"/**\r\n * Definition for singly-linked list.\r\n * struct ListNode {\r\n * int val;\r\n * struct ListNode *next;\r\n * };\r\n */\r\nstruct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2) {\r\n \r\n}"},{"value":"csharp","text":"C#","defaultCode":"/**\r\n * Definition for singly-linked list.\r\n * public class ListNode {\r\n * public int val;\r\n * public ListNode next;\r\n * public ListNode(int x) { val = x; }\r\n * }\r\n */\r\npublic class Solution {\r\n public ListNode AddTwoNumbers(ListNode l1, ListNode l2) {\r\n \r\n }\r\n}"},{"value":"javascript","text":"JavaScript","defaultCode":"/**\r\n * Definition for singly-linked list.\r\n * function ListNode(val) {\r\n * this.val = val;\r\n * this.next = null;\r\n * }\r\n */\r\n/**\r\n * @param {ListNode} l1\r\n * @param {ListNode} l2\r\n * @return {ListNode}\r\n */\r\nvar addTwoNumbers = function(l1, l2) {\r\n \r\n};"},{"value":"ruby","text":"Ruby","defaultCode":"# Definition for singly-linked list.\r\n# class ListNode\r\n# attr_accessor :val, :next\r\n# def initialize(val)\r\n# @val = val\r\n# @next = nil\r\n# end\r\n# end\r\n\r\n# @param {ListNode} l1\r\n# @param {ListNode} l2\r\n# @return {ListNode}\r\ndef add_two_numbers(l1, l2)\r\n \r\nend"},{"value":"swift","text":"Swift","defaultCode":"/**\r\n * Definition for singly-linked list.\r\n * public class ListNode {\r\n * public var val: Int\r\n * public var next: ListNode?\r\n * public init(_ val: Int) {\r\n * self.val = val\r\n * self.next = nil\r\n * }\r\n * }\r\n */\r\nclass Solution {\r\n func addTwoNumbers(_ l1: ListNode?, _ l2: ListNode?) -> ListNode? {\r\n \r\n }\r\n}"},{"value":"golang","text":"Go","defaultCode":"/**\r\n * Definition for singly-linked list.\r\n * type ListNode struct {\r\n * Val int\r\n * Next *ListNode\r\n * }\r\n */\r\nfunc addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {\r\n \r\n}"}],"testcase":"[2,4,3]\n[5,6,4]","testable":true}
1+
{"state":"ac","id":2,"category":"algorithms","name":"Add Two Numbers","key":"add-two-numbers","link":"https://leetcode.com/problems/add-two-numbers","locked":false,"percent":25.368142876074806,"level":"Medium","starred":true,"totalAC":"195263","totalSubmit":"769711","likes": "1","dislikes": "1","desc":"You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.\r\n\r\nInput: (2 -> 4 -> 3) + (5 -> 6 -> 4)\r\nOutput: 7 -> 0 -> 8","templates":[{"value":"cpp","text":"C++","defaultCode":"/**\r\n * Definition for singly-linked list.\r\n * struct ListNode {\r\n * int val;\r\n * ListNode *next;\r\n * ListNode(int x) : val(x), next(NULL) {}\r\n * };\r\n */\r\nclass Solution {\r\npublic:\r\n ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {\r\n \r\n }\r\n};"},{"value":"java","text":"Java","defaultCode":"/**\r\n * Definition for singly-linked list.\r\n * public class ListNode {\r\n * int val;\r\n * ListNode next;\r\n * ListNode(int x) { val = x; }\r\n * }\r\n */\r\npublic class Solution {\r\n public ListNode addTwoNumbers(ListNode l1, ListNode l2) {\r\n \r\n }\r\n}"},{"value":"python","text":"Python","defaultCode":"# Definition for singly-linked list.\r\n# class ListNode(object):\r\n# def __init__(self, x):\r\n# self.val = x\r\n# self.next = None\r\n\r\nclass Solution(object):\r\n def addTwoNumbers(self, l1, l2):\r\n \"\"\"\r\n :type l1: ListNode\r\n :type l2: ListNode\r\n :rtype: ListNode\r\n \"\"\"\r\n "},{"value":"c","text":"C","defaultCode":"/**\r\n * Definition for singly-linked list.\r\n * struct ListNode {\r\n * int val;\r\n * struct ListNode *next;\r\n * };\r\n */\r\nstruct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2) {\r\n \r\n}"},{"value":"csharp","text":"C#","defaultCode":"/**\r\n * Definition for singly-linked list.\r\n * public class ListNode {\r\n * public int val;\r\n * public ListNode next;\r\n * public ListNode(int x) { val = x; }\r\n * }\r\n */\r\npublic class Solution {\r\n public ListNode AddTwoNumbers(ListNode l1, ListNode l2) {\r\n \r\n }\r\n}"},{"value":"javascript","text":"JavaScript","defaultCode":"/**\r\n * Definition for singly-linked list.\r\n * function ListNode(val) {\r\n * this.val = val;\r\n * this.next = null;\r\n * }\r\n */\r\n/**\r\n * @param {ListNode} l1\r\n * @param {ListNode} l2\r\n * @return {ListNode}\r\n */\r\nvar addTwoNumbers = function(l1, l2) {\r\n \r\n};"},{"value":"ruby","text":"Ruby","defaultCode":"# Definition for singly-linked list.\r\n# class ListNode\r\n# attr_accessor :val, :next\r\n# def initialize(val)\r\n# @val = val\r\n# @next = nil\r\n# end\r\n# end\r\n\r\n# @param {ListNode} l1\r\n# @param {ListNode} l2\r\n# @return {ListNode}\r\ndef add_two_numbers(l1, l2)\r\n \r\nend"},{"value":"swift","text":"Swift","defaultCode":"/**\r\n * Definition for singly-linked list.\r\n * public class ListNode {\r\n * public var val: Int\r\n * public var next: ListNode?\r\n * public init(_ val: Int) {\r\n * self.val = val\r\n * self.next = nil\r\n * }\r\n * }\r\n */\r\nclass Solution {\r\n func addTwoNumbers(_ l1: ListNode?, _ l2: ListNode?) -> ListNode? {\r\n \r\n }\r\n}"},{"value":"golang","text":"Go","defaultCode":"/**\r\n * Definition for singly-linked list.\r\n * type ListNode struct {\r\n * Val int\r\n * Next *ListNode\r\n * }\r\n */\r\nfunc addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {\r\n \r\n}"}],"testcase":"[2,4,3]\n[5,6,4]","testable":true}

‎test/plugins/test_cache.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ describe('plugin:cache', function() {
1616
let session;
1717

1818
const PROBLEMS = [
19-
{id: 0, fid: 0, name: 'name0', slug: 'slug0', starred: false, category: 'algorithms'},
20-
{id: 1, fid: 1, name: 'name1', slug: 'slug1', starred: true, category: 'algorithms'}
19+
{id: 0, fid: 0, name: 'name0', slug: 'slug0', starred: false, desc: '<pre></pre>',likes: '1',dislikes: '1',category: 'algorithms'},
20+
{id: 1, fid: 1, name: 'name1', slug: 'slug1', starred: true, desc: '<pre></pre>',likes: '1',dislikes: '1',category: 'algorithms'}
2121
];
2222
const PROBLEM = {id: 0, fid: 0, slug: 'slug0', category: 'algorithms'};
2323

@@ -128,7 +128,7 @@ describe('plugin:cache', function() {
128128
const ret = plugin.saveProblem(problem);
129129
assert.equal(ret, true);
130130
assert.deepEqual(cache.get('0.slug0.algorithms'),
131-
{id: 0, fid: 0, slug: 'slug0', name: 'name0', category: 'algorithms'});
131+
{id: 0, fid: 0, slug: 'slug0', name: 'name0', desc: '<pre></pre>',likes: '1',dislikes: '1',category: 'algorithms'});
132132
});
133133
}); // #saveProblem
134134

@@ -143,8 +143,8 @@ describe('plugin:cache', function() {
143143
plugin.getProblems(function(e, problems) {
144144
assert.equal(e, null);
145145
assert.deepEqual(problems, [
146-
{id: 0, fid: 0, name: 'name0', slug: 'slug0', value: 'value00', starred: false, category: 'algorithms'},
147-
{id: 1, fid: 1, name: 'name1', slug: 'slug1', starred: true, category: 'algorithms'}
146+
{id: 0, fid: 0, name: 'name0', slug: 'slug0', value: 'value00', starred: false, desc: '<pre></pre>',likes: '1',dislikes: '1',category: 'algorithms'},
147+
{id: 1, fid: 1, name: 'name1', slug: 'slug1', starred: true, desc: '<pre></pre>',likes: '1',dislikes: '1',category: 'algorithms'}
148148
]);
149149
done();
150150
});

‎test/plugins/test_leetcode.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@ describe('plugin:leetcode', function() {
190190
assert.equal(problem.totalSubmit, '175.7K');
191191
assert.equal(problem.desc,
192192
[
193+
'<p>',
194+
'Given two strings <b><i>s</i></b> and <b><i>t</i></b> which consist of only lowercase letters.</p>',
193195
'',
194-
'Given two strings s and t which consist of only lowercase letters.',
196+
'<p>String <b><i>t</i></b> is generated by random shuffling string <b><i>s</i></b> and then add one more letter at a random position.</p>',
195197
'',
196-
'String t is generated by random shuffling string s and then add one more letter at a random position.',
197-
'',
198-
'Find the letter that was added in t.',
199-
'',
200-
'Example:',
198+
'<p>Find the letter that was added in <b><i>t</i></b>.</p>',
201199
'',
200+
'<p><b>Example:</b>',
201+
'<pre>',
202202
'Input:',
203203
's = "abcd"',
204204
't = "abcde"',
@@ -208,7 +208,7 @@ describe('plugin:leetcode', function() {
208208
'',
209209
'Explanation:',
210210
"'e' is the letter that was added.",
211-
''
211+
'</pre>'
212212
].join('\r\n'));
213213

214214
assert.equal(problem.templates.length, 12);

‎test/test_core.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ describe('core', function() {
154154
file.isWindows = () => false;
155155

156156
const expected = [
157+
'/*',
158+
' * @lc app=leetcode id=2 lang=cpp',
159+
' *',
160+
' * [2] Add Two Numbers',
161+
' */',
157162
'/**',
158163
' * Definition for singly-linked list.',
159164
' * struct ListNode {',
@@ -184,6 +189,11 @@ describe('core', function() {
184189
file.isWindows = () => true;
185190

186191
const expected = [
192+
'/*',
193+
' * @lc app=leetcode id=2 lang=cpp',
194+
' *',
195+
' * [2] Add Two Numbers',
196+
' */',
187197
'/**',
188198
' * Definition for singly-linked list.',
189199
' * struct ListNode {',
@@ -223,6 +233,8 @@ describe('core', function() {
223233
' *',
224234
' * algorithms',
225235
' * Medium (25.37%)',
236+
' * Likes: 1',
237+
' * Dislikes: 1',
226238
' * Total Accepted: 195263',
227239
' * Total Submissions: 769711',
228240
' * Testcase Example: \'[2,4,3]\\n[5,6,4]\'',
@@ -273,6 +285,8 @@ describe('core', function() {
273285
'#',
274286
'# algorithms',
275287
'# Medium (25.37%)',
288+
'# Likes: 1',
289+
'# Dislikes: 1',
276290
'# Total Accepted: 195263',
277291
'# Total Submissions: 769711',
278292
'# Testcase Example: \'\'',

‎test/test_file.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,13 @@ describe('file', function() {
5050

5151
it('should listCodeDir ok', function() {
5252
const files = file.listCodeDir('lib/plugins');
53-
assert.equal(files.length, 3);
53+
assert.equal(files.length, 6);
5454
assert.equal(files[0].name, 'cache');
55-
assert.equal(files[1].name, 'leetcode');
56-
assert.equal(files[2].name, 'retry');
55+
assert.equal(files[1].name, 'company');
56+
assert.equal(files[2].name, 'leetcode.cn');
57+
assert.equal(files[3].name, 'leetcode');
58+
assert.equal(files[4].name, 'retry');
59+
assert.equal(files[5].name, 'solution.discuss');
5760
});
5861

5962
it('should pluginFile ok', function() {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /