require 'test/unit'
require File.dirname(__FILE__) + '/set_share_mem'

class TC < Test::Unit::TestCase
  def test_apollo
    src = <<EOT
program Apollo;

(*
modified
  [ap-list:0665] by KUMAGAI Hidetake
*)

{$I heverdef.inc}

uses
{$IFDEF WIN32} FastShareMem, {$ENDIF}
{$IFDEF DELPHI9}
  UxTheme,
{$ENDIF}
  SysUtils,
  Classes,
  FileCtrl,
  Forms,
  Rubies,
{$IFDEF PHIEMBED}
  PhiMainUnit, uError,
{$ELSE}
  Pythia,
{$ENDIF}
  Console in 'Console.pas' {FormConsole},
  Browser in 'Browser.pas' {FormBrowser},
  Resource in 'Resource.pas';

{$R *.res}
EOT
    assert_equal src, set_share_mem(src)
  end

  def test_apollo_q
    src = <<EOT
program Apollo_q;

uses
  FastShareMem,
  SysUtils,
  Windows,
  Registry;

{$R *.res}

EOT
    assert_equal src, set_share_mem(src)
  end

  def test_cal
    src = <<EOT
library cal;

uses Classes, ComCtrls, Rubies, uDefUtils, Pythia, CalHandle;

{$E so}
EOT

    expected = <<EOT
library cal;

uses
{$IFDEF WIN32} FastShareMem, {$ENDIF}
  Classes, ComCtrls, Rubies, uDefUtils, Pythia, CalHandle;

{$E so}
EOT
    assert_equal expected, set_share_mem(src)
  end

  def test_chart
    src = <<EOT
library chart;

uses
  Pythia,
  uBarSeries,
  uFastLineSeries,
  uLineSeries,
  uAreaSeries,
  uPieSeries,
  uChartSeries,
  uChartSeriesList,
  uChart;

{$E so}

EOT

    expected = <<EOT
library chart;

uses
{$IFDEF WIN32} FastShareMem, {$ENDIF}
  Pythia,
  uBarSeries,
  uFastLineSeries,
  uLineSeries,
  uAreaSeries,
  uPieSeries,
  uChartSeries,
  uChartSeriesList,
  uChart;

{$E so}

EOT
    assert_equal expected, set_share_mem(src)
  end

end
