diff --git a/Tests/LexerTests.cs b/Tests/LexerTests.cs index 212e29c..6c8b5d4 100644 --- a/Tests/LexerTests.cs +++ b/Tests/LexerTests.cs @@ -19,8 +19,8 @@ public static void Vectorize_GivenEmptyString_ReturnsEmptyFloatArray() TestContext.WriteLine($"Resulting float array: {Utility.FormatFloatArray(result)}"); // Assert - Assert.IsNotNull(result); - Assert.IsEmpty(result); + Assert.That(result, Is.Not.Null); + Assert.That(result, Is.Empty); TestContext.WriteLine($"Test passed: Empty input string returns an empty float array."); } @@ -36,8 +36,8 @@ public static void Vectorize_GivenString_ConvertsToFloatArray() TestContext.WriteLine($"Resulting float array: {Utility.FormatFloatArray(result)}"); // Assert - Assert.IsNotNull(result); - Assert.That(result.Length, Is.EqualTo(1)); + Assert.That(result, Is.Not.Null); + Assert.That(result, Has.Length.EqualTo(1)); TestContext.WriteLine($"Test passed: Input string 'Test' converts to a float array with length 1."); } @@ -57,7 +57,7 @@ public static void Vectorize_GivenStringWithNonAsciiCharacters_DoesNotThrowExcep public static void Vectorize_GivenNullInput_ThrowsLexerException() { // Arrange - string input = null; + string? input = null; TestContext.WriteLine($"Testing with null input string."); // Act & Assert @@ -78,5 +78,23 @@ public static void Vectorize_GivenStringExceedingMaxChars_ThrowsLexerException() Assert.That(ex.Message, Is.EqualTo($"Input exceeds the maximum length of {Lexer.k_MaxChars} characters.")); TestContext.WriteLine($"Test passed: Input string exceeding max characters throws LexerException."); } + + [Test] + public static void Vectorize_GivenSingleCharacter_ConvertsToFloat() + { + // Arrange + var input = "T"; + TestContext.WriteLine($"Testing with single character input: '{input}'."); + + // Act + var result = Lexer.Vectorize(input); + TestContext.WriteLine($"Resulting float array: {Utility.FormatFloatArray(result)}"); + + // Assert + Assert.That(result, Is.Not.Null); + Assert.That(result, Has.Length.EqualTo(1)); + Assert.That(result[0], Is.EqualTo((float)input[0])); + TestContext.WriteLine($"Test passed: Single character input 'T' converts to a float array with correct value."); + } } }