@@ -74,6 +74,7 @@ describe("advanced stream tests", () => {
7474 const initialMemory = process . memoryUsage ( ) ;
7575 let maxMemoryUsed = initialMemory . heapUsed ;
7676 let rowCount = 0 ;
77+ let idSum = 0 ; // Track sum of id column for data integrity verification
7778
7879 // Create a JSON transform stream with minimal allocation
7980 const jsonTransform = new stream . Transform ( {
@@ -87,6 +88,11 @@ describe("advanced stream tests", () => {
8788 try {
8889 rowCount ++ ;
8990
91+ // Add the id to our sum for data integrity verification
92+ const typedRow = row as Record < string , unknown > ;
93+ const id = typedRow . id as number ;
94+ idSum += id ;
95+
9096 if ( rowCount % 5000 === 0 ) {
9197 const currentMemory = process . memoryUsage ( ) ;
9298 maxMemoryUsed = Math . max ( maxMemoryUsed , currentMemory . heapUsed ) ;
@@ -232,6 +238,10 @@ describe("advanced stream tests", () => {
232238 expect ( rowCount ) . toBe ( seriesNum ) ;
233239 expect ( processedChunks ) . toBeGreaterThan ( 0 ) ;
234240
241+ // Verify data integrity: sum of 1 to N should be N*(N+1)/2
242+ const expectedSum = ( seriesNum * ( seriesNum + 1 ) ) / 2 ;
243+ expect ( idSum ) . toBe ( expectedSum ) ;
244+
235245 // Verify the file was created and has content
236246 expect ( fs . existsSync ( tempFilePath ) ) . toBe ( true ) ;
237247 const fileStats = fs . statSync ( tempFilePath ) ;
0 commit comments