--[[----------------------------------------------------------------------------

LuaPatchStringFormatTest.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2010 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: All information contained herein is, and remain the property of
Adobe Systems Incorporated and its suppliers, if any. The intellectual and
technical concepts contained herein are proprietary to Adobe Systems
Incorporated and its suppliers and may be covered by U.S. and Foreign
Patents, patents in process, and are protected by trade secret or copyright
law.  Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

------------------------------------------------------------------------------]]

local LuaPatchStringFormatTest = {}

--------------------------------------------------------------------------------

function LuaPatchStringFormatTest.testNilSafety()

	-- Verify that we have patched Lua's original string.format function to
	-- be safe for nil values.
	
	local result = string.format( "this should say nil: %s", nil )
	assert( result == "this should say nil: nil" )
	
	result = string.format( "this should also say nil: %s" ) -- intentionally providing no value
	assert( result == "this should also say nil: nil" )
	
	-- FIXME [scouten/epoley 2010-11-03]: Apply this to flags other than %s.
	
end

--------------------------------------------------------------------------------

function LuaPatchStringFormatTest.testTableSafety()

	-- Verify that we have patched Lua's original string.format function to
	-- be safe for table values.
	
	local result = string.format( "this should say table (something): %s", {} )
	assert( result:find "this should say table %(something%): table" )
	
end

--------------------------------------------------------------------------------

return LuaPatchStringFormatTest
