Introduces new unit tests for Snowflake and SQL Server-specific SQL breakdown classes (DELETE, INSERT, UPDATE, PROCEDURE) and various general SQL utility functions. This significantly increases test coverage, ensuring robustness and correctness across different SQL dialects and helper logic.
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using Strata.SqlTools.SqlBreakdown.Utilities;
|
|
|
|
namespace Strata.SqlTools.SqlBreakdown.Tests.Utilities;
|
|
|
|
[TestFixture]
|
|
public class StringUtilsTests
|
|
{
|
|
[TestCase('a', -842352705)]
|
|
[TestCase('z', -842352730)]
|
|
[TestCase('A', -842352673)]
|
|
[TestCase('Z', -842352698)]
|
|
[TestCase('0', -842352768)]
|
|
[TestCase('9', -842352759)]
|
|
[TestCase(' ', -842352737)]
|
|
[TestCase('-', -842352782)]
|
|
public void GetHashCode32Bit_KnownCharacters_ReturnsHardcodedHash(char c, int expected)
|
|
{
|
|
// Act & Assert
|
|
Assert.That(StringUtils.GetHashCode32Bit(c), Is.EqualTo(expected));
|
|
}
|
|
|
|
[Test]
|
|
public void GetHashCode32Bit_UnmappedCharacter_UsesConsistentFallback()
|
|
{
|
|
// Arrange - '!' is not in the hardcoded table
|
|
const char c = '!';
|
|
var expected = -842352737 - (int)c;
|
|
|
|
// Act & Assert
|
|
Assert.That(StringUtils.GetHashCode32Bit(c), Is.EqualTo(expected));
|
|
}
|
|
|
|
[Test]
|
|
public void GetHashCode32Bit_SameCharacter_IsDeterministic()
|
|
{
|
|
// Act & Assert - critical: TranslateTextToGuid relies on stable hashing
|
|
Assert.That(StringUtils.GetHashCode32Bit('q'), Is.EqualTo(StringUtils.GetHashCode32Bit('q')));
|
|
}
|
|
}
|