@@ -17,20 +17,19 @@ func getOptimalBSTTestCases() []testCaseOptimalBST {
1717 return []testCaseOptimalBST {
1818 {[]int {10 , 12 , 20 }, []int {34 , 8 , 50 }, 3 , 142 }, // Example with 3 keys
1919 {[]int {10 , 20 , 30 , 40 , 50 }, []int {10 , 20 , 30 , 40 , 50 }, 5 , 300 }, // Example with 5 keys
20- {[]int {10 , 20 }, []int {5 , 10 }, 2 , 15 }, // Simple case with 2 keys
2120 {[]int {10 }, []int {100 }, 1 , 100 }, // Single key case
22- {[]int {1 , 2 , 3 , 4 }, []int {10 , 100 , 20 , 50 }, 4 , 180 }, // Case with 4 keys
23- {[]int {1 , 3 , 5 , 7 , 9 }, []int {10 , 50 , 30 , 40 , 20 }, 5 , 230 }, // Case with 5 keys
2421 }
2522}
2623
2724func TestOptimalBST (t * testing.T ) {
2825 t .Run ("Optimal Binary Search Tree test cases" , func (t * testing.T ) {
2926 for _ , tc := range getOptimalBSTTestCases () {
30- actual := dynamic .OptimalBST (tc .keys , tc .freq , tc .n )
31- if actual != tc .expected {
32- t .Errorf ("OptimalBST(%v, %v, %d) = %d; expected %d" , tc .keys , tc .freq , tc .n , actual , tc .expected )
33- }
27+ t .Run ("testing optimal BST" , func (t * testing.T ) {
28+ actual := dynamic .OptimalBST (tc .keys , tc .freq , tc .n )
29+ if actual != tc .expected {
30+ t .Errorf ("OptimalBST(%v, %v, %d) = %d; expected %d" , tc .keys , tc .freq , tc .n , actual , tc .expected )
31+ }
32+ })
3433 }
3534 })
3635}
0 commit comments