Skip to content

Commit

Permalink
Recreation of generic API tests:
Browse files Browse the repository at this point in the history
- oapi.openfile() with "write-first" to have a known file in root.
  • Loading branch information
schnepe2 committed Jan 16, 2024
1 parent 49e7742 commit 1042f6b
Showing 1 changed file with 81 additions and 1 deletion.
82 changes: 81 additions & 1 deletion Script/Tests/GeneralApiTest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ data = "Hello world! Hello world! Hello world! Hello world!\n"
.. "Hello world! Hello world! Hello world! Hello world!"
vec = { x = 1.2, y = -3.4, z = 5.6 }

fname_root = "__delete_me__.txt"


-- ---------------------------------------------------
-- TEST(S)
Expand Down Expand Up @@ -91,7 +93,9 @@ pass()
-- ---------------------------------------------------
add_line("Test: oapi.formatvalue(value,prec)")
-- ---------------------------------------------------
-- some precisions...
-- rediculous precisions...
assert( oapi.formatvalue(PI,0) == " 3.141593")
assert( oapi.formatvalue(PI,1) == " 3.141593")
assert( oapi.formatvalue(PI,2) == " 3")
assert( oapi.formatvalue(PI,3) == " 3.1")
assert( oapi.formatvalue(PI,4) == " 3.14")
Expand All @@ -102,6 +106,55 @@ assert( oapi.formatvalue(PI,8) == " 3.141593")
assert( oapi.formatvalue(PI,9) == " 3.1415927")
assert( oapi.formatvalue(PI,10) == " 3.14159265")
assert( oapi.formatvalue(PI,11) == " 3.141592654")
assert( oapi.formatvalue(PI,12) == " 3.1415926536")
assert( oapi.formatvalue(PI,13) == " 3.14159265359")
assert( oapi.formatvalue(PI,14) == " 3.141592653590")
assert( oapi.formatvalue(PI,15) == " 3.1415926535898")
assert( oapi.formatvalue(PI,16) == " 3.14159265358979")
assert( oapi.formatvalue(PI,17) == " 3.141592653589790")
assert( oapi.formatvalue(PI,18) == " 3.1415926535897900")
assert( oapi.formatvalue(PI,19) == " 3.14159265358979001")
assert( oapi.formatvalue(PI,20) == " 3.141592653589790007")
assert( oapi.formatvalue(PI,21) == " 3.1415926535897900074")
assert( oapi.formatvalue(PI,22) == " 3.14159265358979000737")
assert( oapi.formatvalue(PI,23) == " 3.141592653589790007373")
assert( oapi.formatvalue(PI,24) == " 3.1415926535897900073735")
assert( oapi.formatvalue(PI,25) == " 3.14159265358979000737349")
assert( oapi.formatvalue(PI,26) == " 3.141592653589790007373495")
assert( oapi.formatvalue(PI,27) == " 3.1415926535897900073734945")
assert( oapi.formatvalue(PI,28) == " 3.14159265358979000737349452")
assert( oapi.formatvalue(PI,29) == " 3.141592653589790007373494518")
assert( oapi.formatvalue(PI,30) == " 3.1415926535897900073734945181")
assert( oapi.formatvalue(PI,31) == " 3.14159265358979000737349451811")
assert( oapi.formatvalue(PI,32) == " 3.141592653589790007373494518106")
assert( oapi.formatvalue(PI,33) == " 3.1415926535897900073734945181059")
assert( oapi.formatvalue(PI,34) == " 3.14159265358979000737349451810587")
assert( oapi.formatvalue(PI,35) == " 3.141592653589790007373494518105872")
assert( oapi.formatvalue(PI,36) == " 3.1415926535897900073734945181058720")
assert( oapi.formatvalue(PI,37) == " 3.14159265358979000737349451810587198")
assert( oapi.formatvalue(PI,38) == " 3.141592653589790007373494518105871975")
assert( oapi.formatvalue(PI,39) == " 3.1415926535897900073734945181058719754")
assert( oapi.formatvalue(PI,40) == " 3.14159265358979000737349451810587197542")
assert( oapi.formatvalue(PI,41) == " 3.141592653589790007373494518105871975422")
assert( oapi.formatvalue(PI,42) == " 3.1415926535897900073734945181058719754219")
assert( oapi.formatvalue(PI,43) == " 3.14159265358979000737349451810587197542191")
assert( oapi.formatvalue(PI,44) == " 3.141592653589790007373494518105871975421906")
assert( oapi.formatvalue(PI,45) == " 3.1415926535897900073734945181058719754219055")
assert( oapi.formatvalue(PI,46) == " 3.14159265358979000737349451810587197542190552")
assert( oapi.formatvalue(PI,47) == " 3.141592653589790007373494518105871975421905518")
assert( oapi.formatvalue(PI,48) == " 3.1415926535897900073734945181058719754219055176")
assert( oapi.formatvalue(PI,49) == " 3.14159265358979000737349451810587197542190551758")
assert( oapi.formatvalue(PI,50) == " 3.141592653589790007373494518105871975421905517578")
assert( oapi.formatvalue(PI,51) == " 3.1415926535897900073734945181058719754219055175781")
assert( oapi.formatvalue(PI,52) == " 3.14159265358979000737349451810587197542190551757812")
assert( oapi.formatvalue(PI,53) == " 3.141592653589790007373494518105871975421905517578125")
assert( oapi.formatvalue(PI,54) == " 3.1415926535897900073734945181058719754219055175781250")
assert( oapi.formatvalue(PI,55) == " 3.14159265358979000737349451810587197542190551757812500")
assert( oapi.formatvalue(PI,56) == " 3.141592653589790007373494518105871975421905517578125000")
assert( oapi.formatvalue(PI,57) == " 3.1415926535897900073734945181058719754219055175781250000")
assert( oapi.formatvalue(PI,58) == " 3.14159265358979000737349451810587197542190551757812500000")
assert( oapi.formatvalue(PI,59) == " 3.141592653589790007373494518105871975421905517578125000000")
assert( oapi.formatvalue(PI,60) == " 3.1415926535897900073734945181058719754219055175781250000000")
-- regular postfixes
assert( oapi.formatvalue(PI*1e1 ) == " 31.42" )
assert( oapi.formatvalue(PI*1e2 ) == " 314.2" )
Expand Down Expand Up @@ -148,6 +201,33 @@ pass()
-- ---------------------------------------------------


-- ---------------------------------------------------
add_line("Test: oapi.openfile(fname,FILE_OUT,root)")
-- ---------------------------------------------------
-- We need to create this file in ROOT first,
-- so we can be sure it is present when we do the
-- read-tests later on
mode = FILE_ACCESS_MODE.FILE_OUT
add_line(" ...FILE_OUT write (overwrite)")
f = oapi.openfile(fname_root, mode)
assert(f ~= nil)
oapi.closefile(f, mode)
pass()
-- ---------------------------------------------------


-- ---------------------------------------------------
add_line("Test: oapi.openfile(fname,FILE_IN,...)")
-- ---------------------------------------------------
mode = FILE_ACCESS_MODE.FILE_IN
add_line(" ...ROOT Orbiter main directory")
f = oapi.openfile(fname_root, mode, PATH_ROOT.ROOT)
assert(f ~= nil)
oapi.closefile(f, mode)
pass()
-- ---------------------------------------------------



-- ---------------------------------------------------
-- FINAL RESULT
Expand Down

0 comments on commit 1042f6b

Please sign in to comment.