#!/usr/bin/env ruby
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

require "test/unit"
begin
  require "bdb"
  $have_bdb_so = true
rescue LoadError
  $have_bdb_so = false
end

$LOAD_PATH.unshift("../../compat") unless $LOAD_PATH.include?("../../compat")
$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
require "qwik/util-path"

class CheckBerkeleyDB < Test::Unit::TestCase
  def test_bdb
    path = "test.db".path
    path.unlink if path.exist?
    options = BDB::CREATE | BDB::EXCL # do not over write
    db = BDB::Hash.open(path.to_s, nil, options)
    db.put("1", "t")
    assert_equal("t", db.get("1"))
    db.close
    path.unlink if path.exist?
  end
end
