2026-06-10 21:22:43 +01:00
using Xunit ;
namespace CultMath.Tests ;
public sealed class HlslMirrorTests
{
2026-07-12 19:33:59 +01:00
[Fact]
2026-07-22 03:47:38 +01:00
public void HlslMirrorDoesNotPublishGeometryKernels ( )
2026-07-12 19:33:59 +01:00
{
2026-07-12 19:49:33 +01:00
var source = File . ReadAllText ( Path . Combine ( GetRepositoryRoot ( ) , "shaders" , "CultMath.hlsl" ) ) ;
2026-07-22 03:47:38 +01:00
Assert . DoesNotContain ( "AdvancedErosionFilter.hlsl" , source ) ;
Assert . DoesNotContain ( "Planetary.hlsl" , source ) ;
Assert . DoesNotContain ( "spherical_erosion" , source ) ;
Assert . DoesNotContain ( "planetary_radial_refinement" , source ) ;
2026-07-12 19:49:33 +01:00
}
2026-06-10 21:22:43 +01:00
[Fact]
public void HlslMirrorPublishesCultMathPrimitives ( )
{
var include = File . ReadAllText ( Path . Combine ( GetRepositoryRoot ( ) , "shaders" , "CultMath.hlsl" ) ) ;
var requiredSymbols = new [ ]
{
"cultmath_radians" ,
"cultmath_degrees" ,
"cultmath_frac" ,
"cultmath_clamp" ,
"cultmath_saturate" ,
"cultmath_lerp" ,
"cultmath_step" ,
"cultmath_smoothstep" ,
"cultmath_smootherstep" ,
"cultmath_lengthsq" ,
"cultmath_distance" ,
"cultmath_normalize" ,
"cultmath_reflect" ,
2026-07-12 19:33:59 +01:00
"cultmath_rotate" ,
2026-06-10 21:22:43 +01:00
"cultmath_csum" ,
"cultmath_decay" ,
"cultmath_damp" ,
"cultmath_catmullrom" ,
"cultmath_quadratic_bezier" ,
"cultmath_cubic_bezier" ,
"cultmath_hash" ,
"cultmath_value_noise" ,
2026-07-17 07:45:28 +01:00
"cultmath_simplex_noise" ,
2026-06-10 21:22:43 +01:00
"cultmath_value_noise_bicubic" ,
"cultmath_value_noise_texture" ,
"cultmath_value_noise_texture_bicubic" ,
} ;
foreach ( var symbol in requiredSymbols )
{
Assert . Contains ( symbol , include ) ;
}
Assert . Contains ( "CULTMATH_NORMALIZE_EPSILON" , include ) ;
Assert . Contains ( "max(length(value), CULTMATH_NORMALIZE_EPSILON)" , include ) ;
}
private static string GetRepositoryRoot ( )
{
var directory = new DirectoryInfo ( AppContext . BaseDirectory ) ;
while ( directory is not null )
{
if ( File . Exists ( Path . Combine ( directory . FullName , "CultMath.slnx" ) ) )
{
return directory . FullName ;
}
directory = directory . Parent ;
}
throw new InvalidOperationException ( "Could not locate CultMath repository root." ) ;
}
}