Skip to content

Commit

Permalink
[ test ] Add bigger tests for sorted trees
Browse files Browse the repository at this point in the history
  • Loading branch information
buzden committed Sep 7, 2024
1 parent 1be90b4 commit 7e14159
Show file tree
Hide file tree
Showing 16 changed files with 544 additions and 0 deletions.
20 changes: 20 additions & 0 deletions examples/sorted-tree-indexed/tests/gens/sorted-big/Main.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Data.SortedBinTree.Gen
import Data.Fuel
import Data.List
import Data.List.Lazy
import Data.Primitives.Interpolation

import System.Random.Pure.StdGen

%default total

main : IO ()
main = do
let vals = unGenTryN 10 someStdGen $ genSortedBinTree1 $ limit 5
Lazy.for_ vals $ \(mi ** ma ** tree) => do
putStrLn "--------------"
let list = toList tree
putStrLn "min: \{mi}, max: \{ma}, length: \{length list}"
putStrLn "tree:\n\{tree}"
putStrLn "as list: \{show list}"
putStrLn "sorted: \{show $ sorted list}"
196 changes: 196 additions & 0 deletions examples/sorted-tree-indexed/tests/gens/sorted-big/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
--------------
min: 0, max: 9, length: 5
tree:
.
|
|- 0
|
|- .
|
|- .
| |
| |- .
| | |
| | |- 1
| | |
| | |- 2
| |
| |- 3
|
|- 9
as list: [0, 1, 2, 3, 9]
sorted: True
--------------
min: 3, max: 7, length: 3
tree:
.
|
|- .
| |
| |- 3
| |
| |- 4
|
|- 7
as list: [3, 4, 7]
sorted: True
--------------
min: 0, max: 6, length: 4
tree:
.
|
|- .
| |
| |- .
| | |
| | |- 0
| | |
| | |- 1
| |
| |- 2
|
|- 6
as list: [0, 1, 2, 6]
sorted: True
--------------
min: 3, max: 6, length: 3
tree:
.
|
|- .
| |
| |- 3
| |
| |- 4
|
|- 6
as list: [3, 4, 6]
sorted: True
--------------
min: 0, max: 7, length: 5
tree:
.
|
|- .
| |
| |- 0
| |
| |- 1
|
|- .
|
|- .
| |
| |- 3
| |
| |- 4
|
|- 7
as list: [0, 1, 3, 4, 7]
sorted: True
--------------
min: 0, max: 9, length: 6
tree:
.
|
|- .
| |
| |- .
| | |
| | |- 0
| | |
| | |- 1
| |
| |- .
| |
| |- .
| | |
| | |- 2
| | |
| | |- 3
| |
| |- 4
|
|- 9
as list: [0, 1, 2, 3, 4, 9]
sorted: True
--------------
min: 0, max: 6, length: 4
tree:
.
|
|- .
| |
| |- 0
| |
| |- 1
|
|- .
|
|- 2
|
|- 6
as list: [0, 1, 2, 6]
sorted: True
--------------
min: 0, max: 9, length: 5
tree:
.
|
|- .
| |
| |- .
| | |
| | |- .
| | | |
| | | |- 0
| | | |
| | | |- 1
| | |
| | |- 2
| |
| |- 4
|
|- 9
as list: [0, 1, 2, 4, 9]
sorted: True
--------------
min: 0, max: 7, length: 4
tree:
.
|
|- .
| |
| |- .
| | |
| | |- 0
| | |
| | |- 1
| |
| |- 4
|
|- 7
as list: [0, 1, 4, 7]
sorted: True
--------------
min: 0, max: 9, length: 5
tree:
.
|
|- .
| |
| |- .
| | |
| | |- .
| | | |
| | | |- 0
| | | |
| | | |- 1
| | |
| | |- 2
| |
| |- 4
|
|- 9
as list: [0, 1, 2, 4, 9]
sorted: True
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package a-test

depends = sorted-tree-indexed

executable = a-test
main = Main
20 changes: 20 additions & 0 deletions examples/sorted-tree-naive/tests/gens/sorted-big/Main.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Data.SortedBinTree.Gen
import Data.Fuel
import Data.List
import Data.List.Lazy
import Data.Primitives.Interpolation

import System.Random.Pure.StdGen

%default total

main : IO ()
main = do
let vals = unGenTryN 10 someStdGen $ genSortedBinTree $ limit 7
Lazy.for_ vals $ \tree => do
putStrLn "--------------"
let list = toList tree
putStrLn "length: \{length list}"
putStrLn "tree:\n\{tree}"
putStrLn "as list: \{show list}"
putStrLn "sorted: \{show $ sorted list}"
Loading

0 comments on commit 7e14159

Please sign in to comment.