summaryrefslogtreecommitdiff
path: root/Tests/ComponentTests/ParserTests/CommandParserTestBase.gd
blob: 6e452cb17e7ba402237f2f0bb49ca63fd486c941 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
extends GutTest

class_name CommandParserTestBase

const CommandParser = preload("res://Scripts/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;