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

WFDiagnosticLogRingBufferTest.lua

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

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

NOTICE: All information contained herein is, and remains 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 are protected by all applicable
intellectual property laws, including trade secret and copyright laws.
Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

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


--============================================================================--

local WFDiagnosticLogRingBufferTest = {}

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

function WFDiagnosticLogRingBufferTest.testBasic()

	local WFDiagnosticLogRingBuffer = require 'WFDiagnosticLogRingBuffer'

	assert( WFDiagnosticLogRingBuffer, 'imported' )

	local buffer = WFDiagnosticLogRingBuffer{ size=8, 'foo', 'bar' }

	for round = 1, 2 do

		for i = 1, 10 do
			if round == 1 then
				buffer:add( i, i * 2 + 100 )
			else
				buffer:add( function()
					return i, i * 2 + 100
				end )
			end
		end

		local visual1, visual2 = buffer:visualize 'boxAndWhisker'
		assert( visual1.title == 'foo' )
		assert( visual1[ '< box-and-whisker >' ][1] == 3 )
		assert( visual1[ '< box-and-whisker >' ][5] == 7 )

		assert( visual2.title == 'bar' )
		assert( visual2[ '< box-and-whisker >' ][1] == 106 )
		assert( visual2[ '< box-and-whisker >' ][5] == 114 )

		visual1, visual2 = buffer:visualize 'sparkline'

		assert( visual1.title == 'foo' )
		assert( visual1[ '< sparkline >' ][1] == 3 )
		assert( visual1[ '< sparkline >' ][5] == 7 )

		assert( visual2.title == 'bar' )
		assert( visual2[ '< sparkline >' ][1] == 106 )
		assert( visual2[ '< sparkline >' ][5] == 114 )

	end

end

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

return WFDiagnosticLogRingBufferTest
