#!/usr/bin/ruby
require "test/unit"
$:.unshift File.join(File.dirname(__FILE__), "..", "")
require "engine.rb"

class TestCriteria < Test::Unit::TestCase
  def test_root
    c = Criteria.new("/")
    assert_equal(c.expression, "/")
    assert(c.root?)
    assert(c.directory?)
    
    c = Criteria.new("")
    assert_equal(c.expression, "")
    assert(c.root?)
    assert(c.directory?)
  end
  
  def test_file_or_dir
    c = Criteria.new("/foo/bar/baz.html")
    assert(c.post?)
    assert(!c.directory?)
    
    c = Criteria.new("/foo/bar/")
    assert(!c.post?)
    assert(c.directory?)

    c = Criteria.new("/foo/bar/baz.htmlx")
    assert(!c.post?)
    assert(!c.directory?)
  end
end

