# test some libuninameslist functions (if the library is included).

cnt = UnicodeBlockCountFromLib()
if ( cnt < 1 )
  Print("No NamesList library - Nothing to test.")
  Quit()
endif

if ( cnt < 294 )
  Print("Pre-20170701 or older library - Nothing to test beyond here.")
  Quit()
endif
ver = UnicodeNamesListVersion()
Print("Libuninameslist version is :",ver)


# test Names2 functions (if we have libuninameslist version>=10.9)
if ( cnt < 305 )
  Print("Pre-20180408 or older library - Nothing to test beyond here.")
  Quit()
endif

cnt = UnicodeNames2GetCntFromLib()
Print("Libuninameslist internal table has ",cnt," Names2.")
if ( cnt < 25 )
  Print("Test Names2 functions. Must be libuninameslist 10.9 or newer.")
  Error("Expected 25 or more values that have Names2.")
endif

# none of these are -1 if library loaded
u0 = UnicodeNames2NxtUniFromLib(0)
u1 = UnicodeNames2NxtUniFromLib(1)
u2 = UnicodeNames2NxtUniFromLib(2)
Print("Sample of internal table has ",u0,", ",u1,", ",u2," as the first 3 unicode values.")
if ( u0 < 0 || u1 < 1 || u2 < 2 )
  Error("these values may be different, but expected 418,419,1801 for ver10.9.")
endif

# We know these Names2 exist, but these 'tX' values may change if more errors found
t0 = UnicodeNames2GetNxtFromLib(0x01A2)
t1 = UnicodeNames2GetNxtFromLib(0xFEFF)
t2 = UnicodeNames2GetNxtFromLib(118981)
Print("Internal table[",t0,"]=0x01A2, table[",t1,"]=0xFEFF, table[",t2,"]=118981 as expected Names2 values.")
if ( t0 < 0 || t1 < 0 || t2 < 0 )
  Error("These Names2 must exist, so we expected these to return valid table locations.")
endif

s0 = UnicodeNames2FrmTabFromLib(3)
Print("Example unicode from table[3]=",s0)
s1 = UnicodeNames2FromLib(65)
s2 = UnicodeNames2FromLib(0x709)
Print("There should be no Names2 for character 65, the value returned is=",s1)
Print("There should be a Names2 for character 0x709, the value returned is=",s2)
if ( Strlen(s0)<3 || Strlen(s2)<3 )
  Error("Expected to return a valid Names2 string.")
endif

Print("All Tests done and valid.")

