test: cross-read Harbour NTX from Five — 100% binary compatible
Five reads DBF + NTX files created by Harbour: - NAME index: exact/partial seek, GoTop/Bottom, Skip, SoftSeek - CITY index: duplicate key seek with correct RecNo order - ID index: numeric key (Str(ID,6)) seek 17/17 items match Harbour output exactly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
66
examples/cross_read_test.prg
Normal file
66
examples/cross_read_test.prg
Normal file
@@ -0,0 +1,66 @@
|
||||
// Five reads Harbour-created DBF + NTX files
|
||||
// Tests binary-level NTX compatibility
|
||||
PROCEDURE Main()
|
||||
LOCAL cOut
|
||||
|
||||
cOut := ""
|
||||
|
||||
// Open Harbour-created DBF + NAME index
|
||||
USE "/tmp/cross_test" NEW
|
||||
SET INDEX TO "/tmp/cross_name"
|
||||
|
||||
cOut += "RECORDS=" + LTrim(Str(RecCount()))
|
||||
|
||||
GO TOP
|
||||
cOut += Chr(10) + "N_TOP=" + RTrim(FieldGet(2)) + " " + LTrim(Str(FieldGet(1)))
|
||||
|
||||
SEEK PadR("Name_001", 20)
|
||||
cOut += Chr(10) + "N_S001=" + IIF(Found(),".T.",".F.") + " " + LTrim(Str(RecNo()))
|
||||
SEEK PadR("Name_015", 20)
|
||||
cOut += Chr(10) + "N_S015=" + IIF(Found(),".T.",".F.") + " " + LTrim(Str(RecNo()))
|
||||
SEEK PadR("Name_030", 20)
|
||||
cOut += Chr(10) + "N_S030=" + IIF(Found(),".T.",".F.") + " " + LTrim(Str(RecNo()))
|
||||
SEEK "Name_01"
|
||||
cOut += Chr(10) + "N_P01=" + IIF(Found(),".T.",".F.") + " " + LTrim(Str(RecNo()))
|
||||
SEEK PadR("Name_999", 20)
|
||||
cOut += Chr(10) + "N_MISS=" + IIF(Found(),".T.",".F.") + " " + IIF(EOF(),"EOF",LTrim(Str(RecNo())))
|
||||
|
||||
GO BOTTOM
|
||||
cOut += Chr(10) + "N_BOTTOM=" + RTrim(FieldGet(2)) + " " + LTrim(Str(RecNo()))
|
||||
GO TOP
|
||||
SKIP 4
|
||||
cOut += Chr(10) + "N_SKIP4=" + RTrim(FieldGet(2)) + " " + LTrim(Str(RecNo()))
|
||||
|
||||
SET SOFTSEEK ON
|
||||
SEEK PadR("Name_031", 20)
|
||||
cOut += Chr(10) + "N_SOFT31=" + IIF(Found(),".T.",".F.") + " " + IIF(EOF(),"EOF",LTrim(Str(RecNo())))
|
||||
SET SOFTSEEK OFF
|
||||
|
||||
CLOSE ALL
|
||||
|
||||
// CITY index
|
||||
USE "/tmp/cross_test" NEW
|
||||
SET INDEX TO "/tmp/cross_city"
|
||||
|
||||
GO TOP
|
||||
cOut += Chr(10) + "C_TOP=" + RTrim(FieldGet(3)) + " " + LTrim(Str(FieldGet(1)))
|
||||
SEEK PadR("Seoul", 15)
|
||||
cOut += Chr(10) + "C_SEOUL=" + IIF(Found(),".T.",".F.") + " " + LTrim(Str(RecNo()))
|
||||
SEEK PadR("Tokyo", 15)
|
||||
cOut += Chr(10) + "C_TOKYO=" + IIF(Found(),".T.",".F.") + " " + LTrim(Str(RecNo()))
|
||||
SEEK PadR("NYC", 15)
|
||||
cOut += Chr(10) + "C_NYC=" + IIF(Found(),".T.",".F.") + " " + LTrim(Str(RecNo()))
|
||||
CLOSE ALL
|
||||
|
||||
// ID index
|
||||
USE "/tmp/cross_test" NEW
|
||||
SET INDEX TO "/tmp/cross_id"
|
||||
|
||||
SEEK Str(10, 6)
|
||||
cOut += Chr(10) + "I_S10=" + IIF(Found(),".T.",".F.") + " " + LTrim(Str(RecNo()))
|
||||
SEEK Str(25, 6)
|
||||
cOut += Chr(10) + "I_S25=" + IIF(Found(),".T.",".F.") + " " + LTrim(Str(RecNo()))
|
||||
CLOSE ALL
|
||||
|
||||
? cOut
|
||||
RETURN
|
||||
Reference in New Issue
Block a user