@@ -8,8 +8,8 @@ package memo
88import "testing"
99
1010type testAux struct {
11- fullScanCount uint8
12- unboundedCardinality bool
11+ fullScanCount uint16
12+ unboundedReadCount uint16
1313}
1414
1515func TestCostLess (t * testing.T ) {
@@ -39,8 +39,8 @@ func TestCostLess(t *testing.T) {
3939 {Cost {C : 2.0 }, Cost {C : 1.0 , Penalties : UnboundedCardinalityPenalty }, true },
4040 {Cost {C : 1.0 , Penalties : UnboundedCardinalityPenalty }, Cost {C : 2.0 }, false },
4141 // Auxiliary information should not affect the comparison.
42- {Cost {C : 1.0 , aux : testAux {0 , false }}, Cost {C : 1.0 , aux : testAux {1 , true }}, false },
43- {Cost {C : 1.0 , aux : testAux {1 , true }}, Cost {C : 1.0 , aux : testAux {0 , false }}, false },
42+ {Cost {C : 1.0 , aux : testAux {0 , 0 }}, Cost {C : 1.0 , aux : testAux {1 , 1 }}, false },
43+ {Cost {C : 1.0 , aux : testAux {1 , 1 }}, Cost {C : 1.0 , aux : testAux {0 , 0 }}, false },
4444 }
4545 for _ , tc := range testCases {
4646 if tc .left .Less (tc .right ) != tc .expected {
@@ -60,8 +60,8 @@ func TestCostAdd(t *testing.T) {
6060 {Cost {C : 1.0 , Penalties : FullScanPenalty }, Cost {C : 2.0 }, Cost {C : 3.0 , Penalties : FullScanPenalty }},
6161 {Cost {C : 1.0 }, Cost {C : 2.0 , Penalties : HugeCostPenalty }, Cost {C : 3.0 , Penalties : HugeCostPenalty }},
6262 {Cost {C : 1.0 , Penalties : UnboundedCardinalityPenalty }, Cost {C : 2.0 , Penalties : HugeCostPenalty }, Cost {C : 3.0 , Penalties : HugeCostPenalty | UnboundedCardinalityPenalty }},
63- {Cost {C : 1.0 , aux : testAux {1 , false }}, Cost {C : 1.0 , aux : testAux {2 , true }}, Cost {C : 2.0 , aux : testAux {3 , true }}},
64- {Cost {C : 1.0 , aux : testAux {200 , true }}, Cost {C : 1.0 , aux : testAux {100 , false }}, Cost {C : 2.0 , aux : testAux {255 , true }}},
63+ {Cost {C : 1.0 , aux : testAux {1 , 4 }}, Cost {C : 1.0 , aux : testAux {2 , 5 }}, Cost {C : 2.0 , aux : testAux {3 , 9 }}},
64+ {Cost {C : 1.0 , aux : testAux {65530 , 65530 }}, Cost {C : 1.0 , aux : testAux {100 , 100 }}, Cost {C : 2.0 , aux : testAux {65535 , 65535 }}},
6565 }
6666 for _ , tc := range testCases {
6767 tc .left .Add (tc .right )
@@ -76,18 +76,18 @@ func TestCostSummary(t *testing.T) {
7676 c Cost
7777 expected string
7878 }{
79- {Cost {C : 1.0 }, "1::0f " },
80- {Cost {C : 1.23 }, "1.23::0f " },
81- {Cost {C : 1.23456 }, "1.23456::0f " },
82- {Cost {C : 1.23 , Penalties : HugeCostPenalty }, "1.23:H:0f " },
83- {Cost {C : 1.23 , Penalties : FullScanPenalty }, "1.23:F:0f " },
84- {Cost {C : 1.23 , Penalties : UnboundedCardinalityPenalty }, "1.23:U:0f " },
85- {Cost {C : 1.23 , Penalties : HugeCostPenalty | FullScanPenalty | UnboundedCardinalityPenalty }, "1.23:HFU:0f " },
86- {Cost {C : 1.23 , Penalties : HugeCostPenalty | FullScanPenalty | UnboundedCardinalityPenalty }, "1.23:HFU:0f " },
87- {Cost {C : 1.23 , aux : testAux {5 , false }}, "1.23::5f " },
88- {Cost {C : 1.23 , aux : testAux {0 , true }}, "1.23::0fu " },
89- {Cost {C : 1.23 , aux : testAux {5 , true }}, "1.23::5fu " },
90- {Cost {C : 1.23 , Penalties : HugeCostPenalty | FullScanPenalty , aux : testAux {5 , true }}, "1.23:HF:5fu " },
79+ {Cost {C : 1.0 }, "1::0f0u " },
80+ {Cost {C : 1.23 }, "1.23::0f0u " },
81+ {Cost {C : 1.23456 }, "1.23456::0f0u " },
82+ {Cost {C : 1.23 , Penalties : HugeCostPenalty }, "1.23:H:0f0u " },
83+ {Cost {C : 1.23 , Penalties : FullScanPenalty }, "1.23:F:0f0u " },
84+ {Cost {C : 1.23 , Penalties : UnboundedCardinalityPenalty }, "1.23:U:0f0u " },
85+ {Cost {C : 1.23 , Penalties : HugeCostPenalty | FullScanPenalty | UnboundedCardinalityPenalty }, "1.23:HFU:0f0u " },
86+ {Cost {C : 1.23 , Penalties : HugeCostPenalty | FullScanPenalty | UnboundedCardinalityPenalty }, "1.23:HFU:0f0u " },
87+ {Cost {C : 1.23 , aux : testAux {5 , 0 }}, "1.23::5f0u " },
88+ {Cost {C : 1.23 , aux : testAux {0 , 6 }}, "1.23::0f6u " },
89+ {Cost {C : 1.23 , aux : testAux {5 , 10 }}, "1.23::5f10u " },
90+ {Cost {C : 1.23 , Penalties : HugeCostPenalty | FullScanPenalty , aux : testAux {5 , 9 }}, "1.23:HF:5f9u " },
9191 }
9292 for _ , tc := range testCases {
9393 if r := tc .c .Summary (); r != tc .expected {
0 commit comments