diff --git a/test/mock/add-two-numbers.20161015.json b/test/mock/add-two-numbers.20161015.json index c8a4d61f..aaee38bd 100644 --- a/test/mock/add-two-numbers.20161015.json +++ b/test/mock/add-two-numbers.20161015.json @@ -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} +{"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} diff --git a/test/plugins/test_cache.js b/test/plugins/test_cache.js index 6b3114ca..4480b192 100644 --- a/test/plugins/test_cache.js +++ b/test/plugins/test_cache.js @@ -16,8 +16,8 @@ describe('plugin:cache', function() { let session; const PROBLEMS = [ - {id: 0, fid: 0, name: 'name0', slug: 'slug0', starred: false, category: 'algorithms'}, - {id: 1, fid: 1, name: 'name1', slug: 'slug1', starred: true, category: 'algorithms'} + {id: 0, fid: 0, name: 'name0', slug: 'slug0', starred: false, desc: '
', likes: '1', dislikes: '1', category: 'algorithms'}, + {id: 1, fid: 1, name: 'name1', slug: 'slug1', starred: true, desc: '', likes: '1', dislikes: '1', category: 'algorithms'} ]; const PROBLEM = {id: 0, fid: 0, slug: 'slug0', category: 'algorithms'}; @@ -128,7 +128,7 @@ describe('plugin:cache', function() { const ret = plugin.saveProblem(problem); assert.equal(ret, true); assert.deepEqual(cache.get('0.slug0.algorithms'), - {id: 0, fid: 0, slug: 'slug0', name: 'name0', category: 'algorithms'}); + {id: 0, fid: 0, slug: 'slug0', name: 'name0', desc: '', likes: '1', dislikes: '1', category: 'algorithms'}); }); }); // #saveProblem @@ -143,8 +143,8 @@ describe('plugin:cache', function() { plugin.getProblems(function(e, problems) { assert.equal(e, null); assert.deepEqual(problems, [ - {id: 0, fid: 0, name: 'name0', slug: 'slug0', value: 'value00', starred: false, category: 'algorithms'}, - {id: 1, fid: 1, name: 'name1', slug: 'slug1', starred: true, category: 'algorithms'} + {id: 0, fid: 0, name: 'name0', slug: 'slug0', value: 'value00', starred: false, desc: '', likes: '1', dislikes: '1', category: 'algorithms'}, + {id: 1, fid: 1, name: 'name1', slug: 'slug1', starred: true, desc: '', likes: '1', dislikes: '1', category: 'algorithms'} ]); done(); }); diff --git a/test/plugins/test_leetcode.js b/test/plugins/test_leetcode.js index ef099b9b..1719b4e3 100644 --- a/test/plugins/test_leetcode.js +++ b/test/plugins/test_leetcode.js @@ -190,15 +190,15 @@ describe('plugin:leetcode', function() { assert.equal(problem.totalSubmit, '175.7K'); assert.equal(problem.desc, [ + '', + 'Given two strings s and t which consist of only lowercase letters.
', '', - 'Given two strings s and t which consist of only lowercase letters.', + 'String t is generated by random shuffling string s and then add one more letter at a random position.
', '', - 'String t is generated by random shuffling string s and then add one more letter at a random position.', - '', - 'Find the letter that was added in t.', - '', - 'Example:', + 'Find the letter that was added in t.
', '', + 'Example:', + '
', 'Input:', 's = "abcd"', 't = "abcde"', @@ -208,7 +208,7 @@ describe('plugin:leetcode', function() { '', 'Explanation:', "'e' is the letter that was added.", - '' + '' ].join('\r\n')); assert.equal(problem.templates.length, 12); diff --git a/test/test_core.js b/test/test_core.js index 0a436bb4..61ea2efd 100644 --- a/test/test_core.js +++ b/test/test_core.js @@ -154,6 +154,11 @@ describe('core', function() { file.isWindows = () => false; const expected = [ + '/*', + ' * @lc app=leetcode id=2 lang=cpp', + ' *', + ' * [2] Add Two Numbers', + ' */', '/**', ' * Definition for singly-linked list.', ' * struct ListNode {', @@ -184,6 +189,11 @@ describe('core', function() { file.isWindows = () => true; const expected = [ + '/*', + ' * @lc app=leetcode id=2 lang=cpp', + ' *', + ' * [2] Add Two Numbers', + ' */', '/**', ' * Definition for singly-linked list.', ' * struct ListNode {', @@ -223,6 +233,8 @@ describe('core', function() { ' *', ' * algorithms', ' * Medium (25.37%)', + ' * Likes: 1', + ' * Dislikes: 1', ' * Total Accepted: 195263', ' * Total Submissions: 769711', ' * Testcase Example: \'[2,4,3]\\n[5,6,4]\'', @@ -273,6 +285,8 @@ describe('core', function() { '#', '# algorithms', '# Medium (25.37%)', + '# Likes: 1', + '# Dislikes: 1', '# Total Accepted: 195263', '# Total Submissions: 769711', '# Testcase Example: \'\'', diff --git a/test/test_file.js b/test/test_file.js index d458e83f..6bef3d5e 100644 --- a/test/test_file.js +++ b/test/test_file.js @@ -50,10 +50,13 @@ describe('file', function() { it('should listCodeDir ok', function() { const files = file.listCodeDir('lib/plugins'); - assert.equal(files.length, 3); + assert.equal(files.length, 6); assert.equal(files[0].name, 'cache'); - assert.equal(files[1].name, 'leetcode'); - assert.equal(files[2].name, 'retry'); + assert.equal(files[1].name, 'company'); + assert.equal(files[2].name, 'leetcode.cn'); + assert.equal(files[3].name, 'leetcode'); + assert.equal(files[4].name, 'retry'); + assert.equal(files[5].name, 'solution.discuss'); }); it('should pluginFile ok', function() {