diff --git a/Assets/Scripts/Agents/Lexer.cs b/Assets/Scripts/Agents/Lexer.cs index db1c063..9d91b40 100644 --- a/Assets/Scripts/Agents/Lexer.cs +++ b/Assets/Scripts/Agents/Lexer.cs @@ -56,9 +56,6 @@ public static float[] Vectorize(string line) public static float[] VectorizeUTF8(string line) { - string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); - string logFilePath = Path.Combine(desktopPath, "VectorizeUTF8Log.txt"); - if (line == null) { throw new ArgumentNullException(nameof(line), "Input string cannot be null."); @@ -77,14 +74,9 @@ public static float[] VectorizeUTF8(string line) float[] vector = new float[utf8Bytes.Length]; const float multiplier = 1.0f / (1 << 23); - using (StreamWriter logWriter = new StreamWriter(logFilePath, true)) + for (int i = 0; i < utf8Bytes.Length; i++) { - logWriter.WriteLine($"Processing string: {line}"); - for (int i = 0; i < utf8Bytes.Length; i++) - { - vector[i] = utf8Bytes[i] * multiplier; - logWriter.WriteLine($"Byte {i}: {utf8Bytes[i]} -> Float: {vector[i]}"); - } + vector[i] = utf8Bytes[i] * multiplier; } return vector; diff --git a/Tests/LexerTests.cs b/Tests/LexerTests.cs index 6f90793..ef3ed3a 100644 --- a/Tests/LexerTests.cs +++ b/Tests/LexerTests.cs @@ -130,5 +130,25 @@ public static void VectorizeUTF8_GivenString_ConvertsToUtf8FloatArray() } TestContext.WriteLine($"Test passed: Input string '{input}' converts to expected UTF-8 float array."); } + + [Test] + public static void VectorizeUTF8_EmptyString_ReturnsEmptyArray() + { + // Arrange + string input = ""; + TestContext.WriteLine($"Testing with empty input string."); + + // Expected value for an empty string is an empty float array + var expected = new float[] { }; + + // Act + float[] result = Lexer.VectorizeUTF8(input); + TestContext.WriteLine($"Resulting float array: {Utility.FormatFloatArray(result)}"); + + // Assert + Assert.IsNotNull(result); + Assert.IsEmpty(result, "The result array should be empty for an empty input string."); + TestContext.WriteLine($"Test passed: Empty input string converts to expected empty UTF-8 float array."); + } } }