Skip to content

Commit

Permalink
unicode tests for reverse-string
Browse files Browse the repository at this point in the history
  • Loading branch information
glennj committed Mar 30, 2024
1 parent a429f06 commit 9a81f98
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 3 deletions.
27 changes: 24 additions & 3 deletions exercises/practice/reverse-string/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[c3b7d806-dced-49ee-8543-933fd1719b1c]
description = "an empty string"
Expand All @@ -19,3 +26,17 @@ description = "a palindrome"

[b9e7dec1-c6df-40bd-9fa3-cd7ded010c4c]
description = "an even-sized word"

[1bed0f8a-13b0-4bd3-9d59-3d0593326fa2]
description = "wide characters"

[93d7e1b8-f60f-4f3c-9559-4056e10d2ead]
description = "grapheme cluster with pre-combined form"
include = false
comment = "not implemented"
comment2= "see also https://www.npmjs.com/package/@stdlib/string-base-reverse-grapheme-clusters"

[1028b2c1-6763-4459-8540-2da47ca512d9]
description = "grapheme clusters"
include = false
comment = "not implemented"
43 changes: 43 additions & 0 deletions exercises/practice/reverse-string/test-reverse-string.bats
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,46 @@ END_INPUT
assert_equal "$output" "$expected"
}

@test 'wide characters' {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip

run jq -r -f reverse-string.jq << 'END_INPUT'
{
"value": "子猫"
}
END_INPUT

assert_success
expected="猫子"
assert_equal "$output" "$expected"
}

# Extra credit:

# @test 'grapheme cluster with pre-combined form' {
# [[ $BATS_RUN_SKIPPED == "true" ]] || skip
#
# run jq -r -f reverse-string.jq << 'END_INPUT'
# {
# "value": "Würstchenstand"
# }
# END_INPUT
#
# assert_success
# expected='dnatsnehctsrüW'
# assert_equal "$output" "$expected"
# }

# @test 'grapheme clusters' {
# [[ $BATS_RUN_SKIPPED == "true" ]] || skip
#
# run jq -r -f reverse-string.jq << 'END_INPUT'
# {
# "value": "ผู้เขียนโปรแกรม"
# }
# END_INPUT
#
# assert_success
# expected='มรกแรปโนยขีเผู้'
# assert_equal "$output" "$expected"
# }

0 comments on commit 9a81f98

Please sign in to comment.