11{-# LANGUAGE ScopedTypeVariables #-}
22{-# LANGUAGE CPP #-}
3+ {-# LANGUAGE TypeApplications #-}
34
45module ArrayTests (arrayTests ) where
56
@@ -265,22 +266,22 @@ testSwap = testGroup "Swap Tests" [ caseTests, performanceTests, propertyTests ]
265266 -- Testing if swapping two elements works correctly.
266267 testValuesSwapped1 :: TestTree
267268 testValuesSwapped1 = testCase " Test Values Swapped Manual" $ do
268- let arr = CustomArray. makeArray 5 ( 0 :: Int )
269+ let arr = CustomArray. makeArray @ Int 5 0
269270 let arr1 = CustomArray. set arr 0 1
270271 let arr2 = CustomArray. set arr1 1 2
271272 let swappedArr = CustomOperations. swap arr2 0 1
272273 assertEqual " First element should be 2" 2 (CustomArray. get swappedArr 0 )
273274 assertEqual " Second element should be 1" 1 (CustomArray. get swappedArr 1 )
274275
275276 -- Testing if swapping two elements works correctly.
276- testValuesSwapped2 = valueSwapTest 5 0 0 1 1 ( 2 :: Int )
277- testValuesSwapped3 = valueSwapTest 10 1 1 2 2 ( 4 :: Int )
278- testValuesSwapped4 = valueSwapTest 20 1 2 3 4 ( 5 :: Int )
277+ testValuesSwapped2 = valueSwapTest @ Int 5 0 0 1 1 2
278+ testValuesSwapped3 = valueSwapTest @ Int 10 1 1 2 2 4
279+ testValuesSwapped4 = valueSwapTest @ Int 20 1 2 3 4 5
279280
280281 -- Testing that swapping an element with itself doesn't change anything.
281282 testSwapSameIndex :: TestTree
282283 testSwapSameIndex = testCase " Test Swapping Same Index" $ do
283- let arr = CustomArray. makeArray 5 ( 1 :: Int )
284+ let arr = CustomArray. makeArray @ Int 5 1
284285 swappedArr = CustomOperations. swap arr 2 2
285286 assertEqual " Array should remain unchanged" 1 (CustomArray. get swappedArr 2 )
286287
@@ -294,7 +295,7 @@ testSwap = testGroup "Swap Tests" [ caseTests, performanceTests, propertyTests ]
294295 -- Test performance of creating and splitting a large.
295296 testLargeArraySwap :: TestTree
296297 testLargeArraySwap = testCase " Test Large Array Swap" $ do
297- let largeArr = CustomArray. makeArray largeInt ( 0 :: Int )
298+ let largeArr = CustomArray. makeArray @ Int largeInt 0
298299 let updatedArr = CustomArray. set largeArr (largeInt- 1 ) 1
299300 let swappedArr = CustomOperations. swap updatedArr (largeInt- 1 ) 0
300301 assertEqual " Last element should be 0" 0 (CustomArray. get swappedArr (largeInt- 1 ))
@@ -340,8 +341,7 @@ testSplit = testGroup "Test Split" [
340341 -- Hardcoded array size and values.
341342 testSplitMid :: TestTree
342343 testSplitMid = testCase " Test Split Mid" $ do
343- -- let arr = CustomArray.makeArray 6 (1 :: Int)
344- let list = replicate 6 (1 :: Int )
344+ let list = replicate @ Int 6 1
345345 arr = CustomArray. fromList list
346346 let (leftArr, rightArr) = CustomOperations. splitMid arr
347347 assertEqual " Left array size should be 3" 3 (CustomArray. size leftArr)
@@ -354,7 +354,7 @@ testSplit = testGroup "Test Split" [
354354 -- Tests that splitting an empty array leads to two arrays of size 0.
355355 testSplitEmpty :: TestTree
356356 testSplitEmpty = testCase " Test Splitting Empty Array" $ do
357- let arr = CustomArray. makeArray 0 ( 0 :: Int )
357+ let arr = CustomArray. makeArray @ Int 0 0
358358 let (leftArr, rightArr) = CustomOperations. splitMid arr
359359 assertEqual " Left array size should be 0" 0 (CustomArray. size leftArr)
360360 assertEqual " Right array size should be 0" 0 (CustomArray. size rightArr)
0 commit comments