<commit_before>#
# test/unit/bio/test_command.rb - Unit test for external command execution methods
#
# Copyright::	Copyright (C) 2005-2006
#               <NAME> <<EMAIL>>,
# 		<NAME> <<EMAIL>>
# License::	Ruby's
#
#  $Id: test_command.rb,v 1.2 2006/07/14 14:23:48 ngoto Exp $
#

require 'pathname'
libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3, 'lib')).cleanpath.to_s
$:.unshift(libpath) unless $:.include?(libpath)


require 'test/unit'
require 'bio/command'

module Bio
  class TestCommand < Test::Unit::TestCase
    
    def test_command_constants
      Bio::Command::UNSAFE_CHARS_UNIX
      Bio::Command::QUOTE_CHARS_WINDOWS
      Bio::Command::UNESCAPABLE_CHARS
    end

    def test_escape_shell_windows
      str = "bio_ruby.123@456:789"
      assert_equal("bio_ruby.123@456:789",
                   Bio::Command.escape_shell_windows(str))
      str = "bio\'\"r u\"b\\y123@456:789"
      assert_equal("\"bio'\"\"r u\"\"b\\y123@456:789\"",
                   Bio::Command.escape_shell_windows(str))
    end

    def test_escape_shell_unix
      str = "bio_ruby.123@456:789"
      assert_equal("bio_ruby.123@456:789",
                   Bio::Command.escape_shell_unix(str))
      str = "bio\'\"r u\"b\\y123@456:789"
      assert_equal("bio\\'\\\"r\\ u\\\"b\\\\y123@456:789",
                   Bio::Command.escape_shell_unix(str))
    end

    def test_escape_shell
      str = "bio_ruby.123@456:789"
      assert_equal("bio_ruby.123@456:789",
                   Bio::Command.escape_shell(str))
      str = "bio\'\"r u\"b\\y123@456:789"
      case RUBY_PLATFORM
      when /mswin32|bccwin32/
        assert_equal("\"bio'\"\"r u\"\"b\\y123@456:789\"",
                     Bio::Command.escape_shell(str))
      else
        assert_equal("bio\\'\\\"r\\ u\\\"b\\\\y123@456:789",
                     Bio::Command.escape_shell(str))
      end
    end

    def test_make_command_line
      ary = [ "ruby", 
        "test.rb", "atgcatgc", "bio\'\"r u\"b\\y123@456:789" ]
      case RUBY_PLATFORM
      when /mswin32|bccwin32/
        assert_equal("ruby" + 
                       " test.rb atgcatgc" + 
                       " \"bio'\"\"r u\"\"b\\y123@456:789\"",
                     Bio::Command.make_command_line(ary))
      else
        assert_equal("ruby" + 
                       " test.rb atgcatgc" + 
                       " bio\\'\\\"r\\ u\\\"b\\\\y123@456:789",
                     Bio::Command.make_command_line(ary))
      end
    end

    def test_make_command_line_windows
      ary = [ "C:\\Program Files\\Ruby\\bin\\ruby.exe", 
        "test.rb", "atgcatgc", "bio\'\"r u\"b\\y123@456:789" ]
      assert_equal("\"C:\\Program Files\\Ruby\\bin\\ruby.exe\"" + 
                     " test.rb atgcatgc" + 
                     " \"bio'\"\"r u\"\"b\\y123@456:789\"",
                   Bio::Command.make_command_line_windows(ary))
    end

    def test_make_command_line_unix
      ary = [ "/usr/local/bin/ruby", 
        "test.rb", "atgcatgc", "bio\'\"r u\"b\\y123@456:789" ]
      assert_equal("/usr/local/bin/ruby" + 
                     " test.rb atgcatgc" +
                     " bio\\'\\\"r\\ u\\\"b\\\\y123@456:789",
                   Bio::Command.make_command_line_unix(ary))
    end

    def test_call_command
      p $0
    end

    def test_call_command_popen
    end

    def test_call_command_fork
    end

    def test_call_command_open3
    end

    def test_query_command
    end

    def test_query_command_popen<commit_msg>removed forgotten debug code<commit_after>#
# test/unit/bio/test_command.rb - Unit test for external command execution methods
#
# Copyright::	Copyright (C) 2005-2006
#               <NAME> <<EMAIL>>,
# 		<NAME> <<EMAIL>>
# License::	Ruby's
#
#  $Id: test_command.rb,v 1.3 2006/07/27 03:50:36 ngoto Exp $
#

require 'pathname'
libpath = Pathname.new(File.join(File.dirname(__FILE__), ['..'] * 3, 'lib')).cleanpath.to_s
$:.unshift(libpath) unless $:.include?(libpath)


require 'test/unit'
require 'bio/command'

module Bio
  class TestCommand < Test::Unit::TestCase
    
    def test_command_constants
      Bio::Command::UNSAFE_CHARS_UNIX
      Bio::Command::QUOTE_CHARS_WINDOWS
      Bio::Command::UNESCAPABLE_CHARS
    end

    def test_escape_shell_windows
      str = "bio_ruby.123@456:789"
      assert_equal("bio_ruby.123@456:789",
                   Bio::Command.escape_shell_windows(str))
      str = "bio\'\"r u\"b\\y123@456:789"
      assert_equal("\"bio'\"\"r u\"\"b\\y123@456:789\"",
                   Bio::Command.escape_shell_windows(str))
    end

    def test_escape_shell_unix
      str = "bio_ruby.123@456:789"
      assert_equal("bio_ruby.123@456:789",
                   Bio::Command.escape_shell_unix(str))
      str = "bio\'\"r u\"b\\y123@456:789"
      assert_equal("bio\\'\\\"r\\ u\\\"b\\\\y123@456:789",
                   Bio::Command.escape_shell_unix(str))
    end

    def test_escape_shell
      str = "bio_ruby.123@456:789"
      assert_equal("bio_ruby.123@456:789",
                   Bio::Command.escape_shell(str))
      str = "bio\'\"r u\"b\\y123@456:789"
      case RUBY_PLATFORM
      when /mswin32|bccwin32/
        assert_equal("\"bio'\"\"r u\"\"b\\y123@456:789\"",
                     Bio::Command.escape_shell(str))
      else
        assert_equal("bio\\'\\\"r\\ u\\\"b\\\\y123@456:789",
                     Bio::Command.escape_shell(str))
      end
    end

    def test_make_command_line
      ary = [ "ruby", 
        "test.rb", "atgcatgc", "bio\'\"r u\"b\\y123@456:789" ]
      case RUBY_PLATFORM
      when /mswin32|bccwin32/
        assert_equal("ruby" + 
                       " test.rb atgcatgc" + 
                       " \"bio'\"\"r u\"\"b\\y123@456:789\"",
                     Bio::Command.make_command_line(ary))
      else
        assert_equal("ruby" + 
                       " test.rb atgcatgc" + 
                       " bio\\'\\\"r\\ u\\\"b\\\\y123@456:789",
                     Bio::Command.make_command_line(ary))
      end
    end

    def test_make_command_line_windows
      ary = [ "C:\\Program Files\\Ruby\\bin\\ruby.exe", 
        "test.rb", "atgcatgc", "bio\'\"r u\"b\\y123@456:789" ]
      assert_equal("\"C:\\Program Files\\Ruby\\bin\\ruby.exe\"" + 
                     " test.rb atgcatgc" + 
                     " \"bio'\"\"r u\"\"b\\y123@456:789\"",
                   Bio::Command.make_command_line_windows(ary))
    end

    def test_make_command_line_unix
      ary = [ "/usr/local/bin/ruby", 
        "test.rb", "atgcatgc", "bio\'\"r u\"b\\y123@456:789" ]
      assert_equal("/usr/local/bin/ruby" + 
                     " test.rb atgcatgc" +
                     " bio\\'\\\"r\\ u\\\"b\\\\y123@456:789",
                   Bio::Command.make_command_line_unix(ary))
    end

    def test_call_command
    end

    def test_call_command_popen
    end

    def test_call_command_fork
    end

    def test_call_command_open3
    end

    def test_query_command
    end

    def test_query_command_popen
{'fraction_non_alphanumeric': 0.16346153846153846, 'fraction_numerical': 0.061567164179104475, 'mean_word_length': 1.9504657070279425, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, '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': '98699', 'n_tokens_mistral': 2839, 'n_tokens_neox': 2445, 'n_words': 352}