Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SORT_KEYをテストする #399

Merged
merged 5 commits into from
Mar 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Cthulhu7th_ChineseTraditional < Base
NAME = '克蘇魯神話第7版'

# ゲームシステム名の読みがな
SORT_KEY = '国際化:Chinese Traditional:克蘇魯神話'
SORT_KEY = '国際化:Chinese Traditional:克蘇魯神話第7版'

# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
Expand Down
2 changes: 1 addition & 1 deletion lib/bcdice/game_system/Cthulhu7th_Korean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Cthulhu7th_Korean < Base
NAME = '크툴루의 부름 7판'

# ゲームシステム名の読みがな
SORT_KEY = '国際化:Korean:크툴루'
SORT_KEY = '国際化:Korean:크툴루의 부름 7판'

# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
Expand Down
2 changes: 1 addition & 1 deletion lib/bcdice/game_system/Cthulhu_ChineseTraditional.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Cthulhu_ChineseTraditional < Cthulhu
NAME = '克蘇魯神話'

# ゲームシステム名の読みがな
SORT_KEY = '国際化:Chinese Traditional:克蘇魯神話7'
SORT_KEY = '国際化:Chinese Traditional:克蘇魯神話'

# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
Expand Down
2 changes: 1 addition & 1 deletion lib/bcdice/game_system/Cthulhu_Korean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Cthulhu_Korean < Cthulhu
NAME = '크툴루'

# ゲームシステム名の読みがな
SORT_KEY = '国際化:Korean:크툴루의부름7'
SORT_KEY = '国際化:Korean:크툴루'

# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
Expand Down
2 changes: 1 addition & 1 deletion lib/bcdice/game_system/MeikyuKingdomBasic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MeikyuKingdomBasic < MeikyuKingdom
NAME = '迷宮キングダム 基本ルールブック'

# ゲームシステム名の読みがな
SORT_KEY = 'めいきゆうきんくたむ きほんるうるふつく'
SORT_KEY = 'めいきゆうきんくたむきほんるうるふつく'

# ダイスボットの使い方
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
Expand Down
20 changes: 20 additions & 0 deletions test/test_sort_key.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

require "test/unit"
require "bcdice"
require "bcdice/game_system"

class TestSortKey < Test::Unit::TestCase
HIRAGANA_BASIC_CHARS = "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん"

data do
BCDice.all_game_systems.map { |s| [s::ID, s::SORT_KEY] }.to_h
end
def test_sort_key(sort_key)
assert_match(
/\A(?:[#{HIRAGANA_BASIC_CHARS}][\d.A-Za-z#{HIRAGANA_BASIC_CHARS}]*|国際化:[\w ]+:.+|\*たいすほつと)\z/,
sort_key,
"SORT_KEY \"#{sort_key}\" はSORT_KEYの規約に違反しています。規約は docs/dicebot_sort_key.md を参照してください"
)
end
end