/ docs / test / test_validation.jl
test_validation.jl
 1  #!/usr/bin/env julia
 2  
 3  """
 4  Simple test script to verify the link validation and content consistency functionality.
 5  """
 6  
 7  push!(LOAD_PATH, @__DIR__)
 8  
 9  include("LinkValidator.jl")
10  include("ContentConsistency.jl") 
11  include("config_validator.jl")
12  
13  using .LinkValidator
14  using .ContentConsistency
15  using .ConfigValidator
16  
17  # Test configuration
18  config = load_default_config()
19  
20  println("🧪 Testing Link Validation...")
21  
22  # Test link extraction
23  test_content = """
24  # Test Document
25  
26  This is a [test link](https://example.com) and an [internal link](../other.md).
27  
28  Here's a reference link [ref link][1] and a bare URL: https://github.com
29  
30  [1]: https://docs.julialang.org
31  """
32  
33  links = LinkValidator.extract_links(test_content, "test.md")
34  println("Extracted $(length(links)) links:")
35  for (url, line) in links
36      println("  Line $line: $url")
37  end
38  
39  println("\n🧪 Testing Content Consistency...")
40  
41  # Test terminology checking
42  test_content2 = """
43  # Test Document
44  
45  This document uses julia instead of Julia.
46  We also mention the api instead of API.
47  """
48  
49  write("test_temp.md", test_content2)
50  try
51      results = check_terminology_consistency("test_temp.md", config)
52      println("Found $(length(results)) terminology issues:")
53      for result in results
54          println("  Line $(result.line): $(result.issue)")
55          if result.suggestion !== nothing
56              println("    Suggestion: $(result.suggestion)")
57          end
58      end
59  finally
60      rm("test_temp.md", force=true)
61  end
62  
63  println("\n✅ Basic validation tests completed!")