From 824f16c8610b31ce06e4b6ff6927eb0df2da1953 Mon Sep 17 00:00:00 2001 From: "Laszlo.Moczo" Date: Thu, 22 Nov 2018 17:08:33 +0100 Subject: [PATCH] test: cover path.basename when path and ext are the same In path.basename was a case when the path and the extension is the same and this wasn't covered with tests. I covered this case both in Windows and Unix environments. PR-URL: https://github.com/nodejs/node/pull/24570 Reviewed-By: Luigi Pinca Reviewed-By: Refael Ackermann Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat --- test/parallel/test-path-basename.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/parallel/test-path-basename.js b/test/parallel/test-path-basename.js index 6b64e40b7eca7a..2d064271f7c862 100644 --- a/test/parallel/test-path-basename.js +++ b/test/parallel/test-path-basename.js @@ -29,6 +29,7 @@ assert.strictEqual(path.basename('/aaa/'), 'aaa'); assert.strictEqual(path.basename('/aaa/b'), 'b'); assert.strictEqual(path.basename('/a/b'), 'b'); assert.strictEqual(path.basename('//a'), 'a'); +assert.strictEqual(path.basename('a', 'a'), ''); // On Windows a backslash acts as a path separator. assert.strictEqual(path.win32.basename('\\dir\\basename.ext'), 'basename.ext'); @@ -53,6 +54,7 @@ assert.strictEqual(path.win32.basename('C:basename.ext\\'), 'basename.ext'); assert.strictEqual(path.win32.basename('C:basename.ext\\\\'), 'basename.ext'); assert.strictEqual(path.win32.basename('C:foo'), 'foo'); assert.strictEqual(path.win32.basename('file:stream'), 'file:stream'); +assert.strictEqual(path.win32.basename('a', 'a'), ''); // On unix a backslash is just treated as any other character. assert.strictEqual(path.posix.basename('\\dir\\basename.ext'),