Last active
July 3, 2024 12:18
-
-
Save ksamuel/1a4191cf55f1b4a3f02ae61bf1af4954 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_bluesky_link_calculator(): | |
assert ( | |
bsk_calculate_link_size("http://google.com") | |
== bsk_calculate_link_size("https://google.com") | |
== bsk_calculate_link_size("https://google.com/") | |
== bsk_calculate_link_size("https://google.com#") | |
== 10 | |
) | |
assert ( | |
bsk_calculate_link_size("https://google.com//") | |
== bsk_calculate_link_size("https://google.com##") | |
== 12 | |
) | |
assert bsk_calculate_link_size("google.com") == 10 | |
assert bsk_calculate_link_size("google.com/") == 11 | |
assert bsk_calculate_link_size("google.com/#") == 12 | |
assert bsk_calculate_link_size("https://bitecode.dev/notes") == 18 | |
assert bsk_calculate_link_size("https://www.bitecode.dev/notes") == 22 | |
assert bsk_calculate_link_size("https://www.bitecode.dev/notes/") == 23 | |
assert bsk_calculate_link_size("https://www.bitecode.dev/notes/#") == 23 | |
assert bsk_calculate_link_size("https://www.bitecode.dev/notes#") == 22 | |
assert bsk_calculate_link_size("https://www.bitecode.dev/notes#tag") == 26 | |
assert bsk_calculate_link_size("https://www.bitecode.dev/notes?a=1") == 26 | |
assert bsk_calculate_link_size("https://www.bitecode.dev/notes?a=1#tag") == 30 | |
assert bsk_calculate_link_size("https://www.bitecode.dev/notes?a=1#") == 26 | |
assert ( | |
bsk_calculate_link_size("https://substack.com/@bitecode/note/c-60714440") == 28 | |
) | |
assert ( | |
bsk_calculate_link_size( | |
"https://docs.python.org/3/library/stdtypes.html#str.split" | |
) | |
== 31 | |
) | |
long_url = "https://www.thelongestdomainnameintheworldandthensomeandthensomemoreandmore.com" | |
long_domain = long_url.strip("https://") | |
assert bsk_calculate_link_size(long_url) == len(long_domain) | |
assert bsk_calculate_link_size(long_url + "/") == len(long_domain) | |
assert bsk_calculate_link_size(long_url + "/test") == len(long_domain) + 5 | |
assert bsk_calculate_link_size(long_url + "/" + "a" * 20) == len(long_domain) + 16 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment