<commit_before>require 'test/unit'

class CppUnitTest < Test::Unit::TestCase

  def testCppUnit
    Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) {
      output = `./cppunit_test`
      assert_equal 1, $?.exitstatus
      assert_match /^[\.FE]+$/, output
      assert_match /Run:\s+\d+\s+Failures:\s+\d+\s+Errors:\s+\d+/, output
    }
  end

  def testCppUnitHelp
    Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) {
      %w(-h --help).each {|opt|
        output = `./cppunit_test #{opt}`
        assert_equal 0, $?.exitstatus
        assert_match /Show this help message/, output
      }
    }
  end

  def testCppUnitBadOption
    Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) {
      output = `./cppunit_test -x 2>&1`
      assert_equal 1, $?.exitstatus
      assert_match /invalid option -x/, output
    }<commit_msg>Using open3 for windows<commit_after>require 'test/unit'
require 'open3'

class CppUnitTest < Test::Unit::TestCase

  def testCppUnit
    Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) {
      output = `./cppunit_test`
      assert_equal 1, $?.exitstatus
      assert_match /^[\.FE]+$/, output
      assert_match /Run:\s+\d+\s+Failures:\s+\d+\s+Errors:\s+\d+/, output
    }
  end

  def testCppUnitHelp
    Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) {
      %w(-h --help).each {|opt|
        output = `./cppunit_test #{opt}`
        assert_equal 0, $?.exitstatus
        assert_match /Show this help message/, output
      }
    }
  end

  def testCppUnitBadOption
    Dir.chdir(File.join(File.dirname(__FILE__), '..', 'build', 'test', ENV['CONFIGURATION'].to_s)) {
      output, error, status = Open3.capture3 './cppunit_test -x'
      assert_equal 1, status.exitstatus
      assert_match /invalid option -x/, error
    }
{'fraction_non_alphanumeric': 0.1793969849246231, 'fraction_numerical': 0.006030150753768844, 'mean_word_length': 3.006036217303823, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5355595', 'n_tokens_mistral': 707, 'n_tokens_neox': 700, 'n_words': 133}