Преглед изворни кода

* strutils rtl unit dir + test of posex. (related to bug #15357)

git-svn-id: trunk@14785 -
marco пре 15 година
родитељ
комит
690b6e89ea
4 измењених фајлова са 63 додато и 4 уклоњено
  1. 1 0
      .gitattributes
  2. 10 3
      tests/Makefile
  3. 1 1
      tests/Makefile.fpc
  4. 51 0
      tests/test/units/strutils/posextest.pp

+ 1 - 0
.gitattributes

@@ -9369,6 +9369,7 @@ tests/test/units/sharemem/test1.pp svneol=native#text/plain
 tests/test/units/softfpu/sfttst.pp svneol=native#text/plain
 tests/test/units/strings/tstrcopy.pp svneol=native#text/plain
 tests/test/units/strings/tstrings1.pp svneol=native#text/plain
+tests/test/units/strutils/posextest.pp svneol=native#text/plain
 tests/test/units/system/interlocked1.pp svneol=native#text/plain
 tests/test/units/system/tabs.pp svneol=native#text/plain
 tests/test/units/system/talign.pp svneol=native#text/plain

+ 10 - 3
tests/Makefile

@@ -1,8 +1,8 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/12/10]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/01/23]
 #
 default: allexectests
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx haiku
 LIMIT83fs = go32v2 os2 emx watcom
@@ -607,6 +607,10 @@ ifeq ($(OS_TARGET),symbian)
 SHAREDLIBEXT=.dll
 SHORTSUFFIX=symbian
 endif
+ifeq ($(OS_TARGET),NativeNT)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=nativent
+endif
 else
 ifeq ($(OS_TARGET),go32v1)
 PPUEXT=.pp1
@@ -1192,6 +1196,9 @@ endif
 ifdef EXEFILES
 override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
 endif
+ifdef CLEAN_PROGRAMS
+override CLEANEXEFILES+=$(addprefix $(TARGETDIRPREFIX),$(addsuffix $(EXEEXT), $(CLEAN_PROGRAMS)))
+endif
 ifdef CLEAN_UNITS
 override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
 endif
@@ -1459,7 +1466,7 @@ endif
 ifndef LOG
 export LOG:=$(TEST_OUTPUTDIR)/log
 endif
-TESTSUBDIRS=cg cg/variants cg/cdecl opt units/system units/dos units/crt units/objects units/strings units/sysutils units/math units/sharemem
+TESTSUBDIRS=cg cg/variants cg/cdecl opt units/system units/dos units/crt units/objects units/strings units/sysutils units/math units/sharemem units/strutils
 TESTPACKAGESUBDIRS=packages/win-base packages/webtbs packages/hash packages/fcl-registry packages/fcl-process packages/zlib packages/fcl-db packages/fcl-base packages/fcl-xml packages/cocoaint
 ifdef QUICKTEST
 export QUICKTEST

+ 1 - 1
tests/Makefile.fpc

@@ -120,7 +120,7 @@ endif
 
 
 # Subdirs available in the test subdir
-TESTSUBDIRS=cg cg/variants cg/cdecl opt units/system units/dos units/crt units/objects units/strings units/sysutils units/math units/sharemem
+TESTSUBDIRS=cg cg/variants cg/cdecl opt units/system units/dos units/crt units/objects units/strings units/sysutils units/math units/sharemem units/strutils
 TESTPACKAGESUBDIRS=packages/win-base packages/webtbs packages/hash packages/fcl-registry packages/fcl-process packages/zlib packages/fcl-db packages/fcl-base packages/fcl-xml packages/cocoaint
 
 ifdef QUICKTEST

+ 51 - 0
tests/test/units/strutils/posextest.pp

@@ -0,0 +1,51 @@
+{$mode objfpc} {$h+}
+{$hints on}
+{$warnings on}
+
+uses strutils;
+
+var doexit : integer =0;
+
+procedure posTest(const substr,str:ansistring;start:integer;shouldberes:integer;testnr:integer);
+
+var res : integer;
+
+begin
+  res:=posex(substr,str,start);
+  if res<>shouldberes then
+   begin
+     writeln('test ',testnr:5,' resulted in ',res:5,' should be ',shouldberes);
+     doexit:=1;
+   end;
+  if res>0 then
+   begin
+     if copy(str,res,length(substr))<>substr then
+      begin
+        doexit:=1;
+        writeln('test ',testnr,' doesn''t match search phrase');
+      end;
+   end;
+end; 
+
+const 
+  S = 'Start'+#0#1+'BaseLevel'+#0#2+'Sublevel1'+#0#2+'Sublevel2'+#0#1+'LastOne';
+  Sub = 'LastOne';
+
+  s2 = '1234one8901one';
+  s3 = '1234one8901on';
+  s4 = '1234on234on3';
+begin
+  postest(sub,s,1,41,1);
+  postest('One',s,1,45,2);
+  postest('Start',s,1,1,3);
+  postest('one',s2,1,5,4);
+  postest('one',s2,6,12,5);
+  postest('one',s3,6,0,6);
+  postest('one',s3,0,0,7);
+  postest('one',s2,14,0,8);
+  postest('One',s2,1,0,9); // test if compare is case sensitive
+  postest('one',s4,1,0,10); // test if compare is case sensitive
+
+  if doexit>0 then
+    halt(1);
+end.