FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[[ Bug ]] Fix failing LCB varargs test on Linux by runrevmark · Pull Request #7024 · livecode/livecode · GitHub

This repository was archived by the owner on Aug 31, 2021. It is now read-only.
/ livecode Public archive
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .lcb  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
27 changes: 20 additions & 7 deletions tests/lcb/vm/foreign-invoke.lcb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,46 @@ foreign handler sprintf(in pTarget as Pointer, in pFormat as ZStringNative, ...)
foreign handler MCStringCreateWithCString(in pCString as Pointer, out rString as String) returns CBool binds to "<builtin>"

public handler TestForeignInvoke_Varargs()
variable tString1 as String
variable tString2 as String
variable tOutputBuffer as Pointer
unsafe
variable tOutputBuffer as Pointer
put malloc(4096) into tOutputBuffer
end unsafe

variable tString1 as String
unsafe
sprintf(tOutputBuffer, "no formats")
MCStringCreateWithCString(tOutputBuffer, tString1)
end unsafe
test "sprintf works with no variadic arguments" when tString1 is "no formats"

variable tString2 as String
unsafe
variable tInt as SInt16
variable tLong as SInt32
variable tLongLong as SInt64
variable tFloat as CFloat
variable tDouble as CDouble
variable tNothing as optional Pointer
put 1000 into tInt
put 1000000000 into tLong
put tLong * 1000000 into tLongLong
put 3.5 into tFloat
put 7.5 into tDouble
sprintf(tOutputBuffer, "%d %ld %lld %.1f %.1lf %p", tInt, tLong, tLongLong, tFloat, tDouble, tNothing)
sprintf(tOutputBuffer, "%d %ld %lld %.1f %.1lf", tInt, tLong, tLongLong, tFloat, tDouble)
MCStringCreateWithCString(tOutputBuffer, tString2)
end unsafe
test "sprintf works with variadic arguments" when tString2 is "1000 1000000000 1000000000000000 3.5 7.5"

variable tString3 as String
unsafe
variable tNothing as optional Pointer
sprintf(tOutputBuffer, "nullptr %p", tNothing)
MCStringCreateWithCString(tOutputBuffer, tString3)
end unsafe
test "sprintf works with nullptr variadic argument" when tString3 begins with "nullptr "

unsafe
free(tOutputBuffer)
end unsafe
test "sprintf works with no variadic arguments" when tString1 is "no formats"
test "sprintf works with variadic arguments" when tString2 is "1000 1000000000 1000000000000000 3.5 7.5 0x0"
end handler

--------
Expand Down

Back | FazBrowse Home | New Git URL