File tree Expand file tree Collapse file tree 2 files changed +68
-0
lines changed
exercises/practice/satellite Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,10 @@ if ! [[ $PWD =~ exercises/concept/ ]]; then
4646 esac
4747fi
4848
49+ if ! grep -q cleanupTests " ${tests} " ; then
50+ die " $exercise : last line of test suite must be 'cleanupTests'"
51+ fi
52+
4953cleanup () {
5054 rm -rf " ${tmpdir} "
5155}
Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ package require tcltest
33namespace import ::tcltest::*
44source testHelpers.tcl
55
6+ # uncomment for more verbose test results
7+ # configure -verbose {body error usec}
8+
69# ###########################################################
710source " satellite.tcl"
811
@@ -49,4 +52,65 @@ test satellite-2.3 "Reject traversals with repeated elements" -body {
4952} -returnCodes error -result " traversals must contain unique elements"
5053
5154
55+ skip sattelite-3.1
56+ test sattelite-3.1 " A degenerate binary tree" -body {
57+ treeFromTraversals {a b c d} {d c b a}
58+ } -returnCodes ok -match dictionary -result {
59+ v a
60+ l {
61+ v b
62+ l {
63+ v c
64+ l { v d l {} r {} }
65+ r {}
66+ }
67+ r {}
68+ }
69+ r {}
70+ }
71+
72+ skip sattelite-3.2
73+ test sattelite-3.2 " Another degenerate binary tree" -body {
74+ treeFromTraversals {a b c d} {a b c d}
75+ } -returnCodes ok -match dictionary -result {
76+ v a
77+ l {}
78+ r {
79+ v b
80+ l {}
81+ r {
82+ v c
83+ l {}
84+ r { v d l {} r {} }
85+ }
86+ }
87+ }
88+
89+ skip sattelite-3.3
90+ test sattelite-3.3 " Tree with many more items" -body {
91+ set preorder {a b d g h c e f i}
92+ set inorder {g d h b a e c i f}
93+ treeFromTraversals $preorder $inorder
94+ } -returnCodes ok -match dictionary -result {
95+ v a
96+ l {
97+ v b
98+ l {
99+ v d
100+ l { v g l {} r {} }
101+ r { v h l {} r {} }
102+ }
103+ r {}
104+ }
105+ r {
106+ v c
107+ l { v e l {} r {} }
108+ r {
109+ v f
110+ l { v i l {} r {} }
111+ r {}
112+ }
113+ }
114+ }
115+
52116cleanupTests
You can’t perform that action at this time.
0 commit comments