#
# Commands covered: xl_read (built-in zip reader)
#
# Regression test for ticket a308a654f0: the built-in zip reader passed
# the uncompressed size of a zip member as buffer size hint to
# [zlib inflate], which only accepts 16 to 65536 - reading any file
# with an XML part larger than 64 KB failed.
#

#
# (c) 2026 Alexander Schoepe
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#

if {[lsearch [namespace children] ::tcltest] == -1} {
  package require tcltest 2
  namespace import -force ::tcltest::*
  loadTestedCommands
}


package require ooxml


test BigPart-1.1 {read a workbook whose sheet XML exceeds 64 KB} {
  set spreadsheet [::ooxml::xl_write new]
  set sheet [$spreadsheet worksheet Big]
  for {set row 0} {$row < 2000} {incr row} {
    $spreadsheet row $sheet
    $spreadsheet cell $sheet "row $row [string repeat x 40]" -string
    $spreadsheet cell $sheet $row
  }
  $spreadsheet write bigpart.xlsx
  $spreadsheet destroy

  array set wb [::ooxml::xl_read bigpart.xlsx]
  set result [list $wb(0,max_row) $wb(0,v,1999,1)]
  array unset wb
  set result
} {1999 1999}

file delete -force bigpart.xlsx


# cleanup
::tcltest::cleanupTests
return
