From f711d55d465bd8838dc55bde1f4a25d582a6bb6b Mon Sep 17 00:00:00 2001 From: Sophia Pearson Date: Sun, 4 Sep 2022 21:52:27 +0200 Subject: tests: adjust tests to new design --- Tests/Game/CommandParserTestBase.gd | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Tests/Game/CommandParserTestBase.gd (limited to 'Tests/Game/CommandParserTestBase.gd') diff --git a/Tests/Game/CommandParserTestBase.gd b/Tests/Game/CommandParserTestBase.gd new file mode 100644 index 0000000..46b8b05 --- /dev/null +++ b/Tests/Game/CommandParserTestBase.gd @@ -0,0 +1,29 @@ +extends GutTest + +class_name CommandParserTestBase + +const CommandParser = preload("res://Scripts/Game/CommandParser.cs") + +var _instance: CommandParser + +func _to_bits(number: int, bits: int) -> Array: + var result = [] + for bit in bits: + result.append(number & 1) + number = number >> 1 + return result + +func before_each(): + _instance = autofree(CommandParser.new()) + +func generate_capitalization_permutations(text: String) -> Array: + var result = [] + + for permutation in pow(2, text.length()): + var mask = _to_bits(permutation, text.length()) + var copy = String(text) + for index in len(mask): + if mask[index] == 1: + copy[index] = copy[index].to_upper() + result.append(copy) + return result; -- cgit v1.2.3