<commit_before>require 'test_helper'

class CheckerTest < Test::Unit::TestCase

  test "PDF as pages with clear margins tested as pages" do
    checker = PDF::Margins::Checker.new(pdf_path('clear-margins-pages.pdf'), 15, 15, 15, 15)
    assert_equal [], checker.issues
  end

  test "PDF as spreads with clear margins tested as spreads" do
    checker = PDF::Margins::Checker.new(pdf_path('clear-margins-spreads.pdf'), 15, 15, 15, 15, true)
    assert_equal [], checker.issues
  end

  test "PDF as spreads with clear margins tested as pages" do
    checker = PDF::Margins::Checker.new(pdf_path('clear-margins-spreads.pdf'), 15, 15, 15, 15)
    assert_equal [
      PDF::Margins::Issue.new(1, :left),
      PDF::Margins::Issue.new(2, :right),
      PDF::Margins::Issue.new(3, :left),
      PDF::Margins::Issue.new(4, :right)
    ], checker.issues
  end

  test "PDF as pages with dirty left margin" do
    checker = PDF::Margins::Checker.new(pdf_path('left-margin-only.pdf'), 15, 15, 15, 15)
    assert_equal [
      PDF::Margins::Issue.new(1, :left)
    ], checker.issues
  end

  test "PDF as pages with dirty right margin" do
    checker = PDF::Margins::Checker.new(pdf_path('right-margin-only.pdf'), 15, 15, 15, 15)
    assert_equal [
      PDF::Margins::Issue.new(1, :right)
    ], checker.issues
  end

  test "PDF with dirty top margin as spreads" do
    checker = PDF::Margins::Checker.new(pdf_path('top-margin-only.pdf'), 15, 15, 15, 15, true)
    assert_equal [
      PDF::Margins::Issue.new(1, :top),
      PDF::Margins::Issue.new(2, :top),
      PDF::Margins::Issue.new(3, :top),
      PDF::Margins::Issue.new(4, :top)
    ], checker.issues
  end

  test "PDF with dirty bottom margin as spreads" do
    checker = PDF::Margins::Checker.new(pdf_path('bottom-margin-only.pdf'), 15, 15, 15, 15, true)
    assert_equal [
      PDF::Margins::Issue.new(1, :bottom),
      PDF::Margins::Issue.new(2, :bottom),
      PDF::Margins::Issue.new(3, :bottom),
      PDF::Margins::Issue.new(4, :bottom)
    ], checker.issues
  end

end<commit_msg>Test top/bottom margins as pages as well as spreads.<commit_after>require 'test_helper'

class CheckerTest < Test::Unit::TestCase

  test "PDF as pages with clear margins tested as pages" do
    checker = PDF::Margins::Checker.new(pdf_path('clear-margins-pages.pdf'), 15, 15, 15, 15)
    assert_equal [], checker.issues
  end

  test "PDF as spreads with clear margins tested as spreads" do
    checker = PDF::Margins::Checker.new(pdf_path('clear-margins-spreads.pdf'), 15, 15, 15, 15, true)
    assert_equal [], checker.issues
  end

  test "PDF as spreads with clear margins tested as pages" do
    checker = PDF::Margins::Checker.new(pdf_path('clear-margins-spreads.pdf'), 15, 15, 15, 15)
    assert_equal [
      PDF::Margins::Issue.new(1, :left),
      PDF::Margins::Issue.new(2, :right),
      PDF::Margins::Issue.new(3, :left),
      PDF::Margins::Issue.new(4, :right)
    ], checker.issues
  end

  test "PDF as pages with dirty left margin" do
    checker = PDF::Margins::Checker.new(pdf_path('left-margin-only.pdf'), 15, 15, 15, 15)
    assert_equal [
      PDF::Margins::Issue.new(1, :left)
    ], checker.issues
  end

  test "PDF as pages with dirty right margin" do
    checker = PDF::Margins::Checker.new(pdf_path('right-margin-only.pdf'), 15, 15, 15, 15)
    assert_equal [
      PDF::Margins::Issue.new(1, :right)
    ], checker.issues
  end

  test "PDF with dirty top margin as spreads" do
    checker = PDF::Margins::Checker.new(pdf_path('top-margin-only.pdf'), 15, 15, 15, 15, true)
    assert_equal [
      PDF::Margins::Issue.new(1, :top),
      PDF::Margins::Issue.new(2, :top),
      PDF::Margins::Issue.new(3, :top),
      PDF::Margins::Issue.new(4, :top)
    ], checker.issues
  end

  test "PDF with dirty bottom margin as spreads" do
    checker = PDF::Margins::Checker.new(pdf_path('bottom-margin-only.pdf'), 15, 15, 15, 15, true)
    assert_equal [
      PDF::Margins::Issue.new(1, :bottom),
      PDF::Margins::Issue.new(2, :bottom),
      PDF::Margins::Issue.new(3, :bottom),
      PDF::Margins::Issue.new(4, :bottom)
    ], checker.issues
  end

  test "PDF with dirty top margin as pages" do
    checker = PDF::Margins::Checker.new(pdf_path('top-margin-only.pdf'), 15, 15, 15, 15)
    assert_equal [
      PDF::Margins::Issue.new(1, :top),
      PDF::Margins::Issue.new(2, :top),
      PDF::Margins::Issue.new(3, :top),
      PDF::Margins::Issue.new(4, :top)
    ], checker.issues
  end

  test "PDF with dirty bottom margin as pages" do
    checker = PDF::Margins::Checker.new(pdf_path('bottom-margin-only.pdf'), 15, 15, 15, 15)
    assert_equal [
      PDF::Margins::Issue.new(1, :bottom),
      PDF::Margins::Issue.new(2, :bottom),
      PDF::Margins::Issue.new(3, :bottom),
      PDF::Margins::Issue.new(4, :bottom)
    ], checker.issues
  end

end
{'fraction_non_alphanumeric': 0.16062926930242186, 'fraction_numerical': 0.03394742289381081, 'mean_word_length': 3.6595949855351977, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6774569', 'n_tokens_mistral': 1935, 'n_tokens_neox': 1696, 'n_words': 397}