code-chronicles-code / leetcode-curriculum

https://code-chronicles-code.github.io/leetcode-curriculum/
MIT License
9 stars 12 forks source link

Add test for `Number.prototype.chr` goody #395

Closed Gobleizer closed 2 months ago

Gobleizer commented 3 months ago

Resolves #113.

miorel commented 3 months ago

I can see the file at https://github.com/code-chronicles-code/leetcode-curriculum/blob/2ad7586de4ae68d10661131c29882dea5d5cf920/workspaces/adventure-pack/goodies/typescript/Number.prototype.chr/index.test.ts but yeah, for some reason GitHub thinks it's a binary file. @Gobleizer I'm not sure which of the non-ASCII characters is the culprit... Emojis are usually fine.

Gobleizer commented 3 months ago

I believe it is the Null Character (https://unicode-explorer.com/c/0000) which is the result when you attempt to get a character from number 0. I can see it won't appear in the file preview. But it was necessary to make the test pass, because a null character is not the same as an empty string. image

miorel commented 3 months ago

Perhaps we should use escapes for the null character? So "\0", similar to "\n" for newlines?

Gobleizer commented 3 months ago

Awesome point. Fixed.

Gobleizer commented 3 months ago

What do you all think if I added inner describe blocks? I like having it.each, but I dislike not having clear titles as to what a group of tests is doing right at the top of that group in code. The test print out is actually better now since I can print unique strings for each test, which is fun.

Gobleizer commented 3 months ago

Yeah I went ahead and nested the describe blocks.

miorel commented 2 months ago

Hey @Gobleizer I took this PR as-is since I'm about to work on some changes that might otherwise cause you some merge conflicts. Feel free to do a follow-up with any additional changes from the discussion.

Thanks again for working on this!