Mercurial > hg > svcore
comparison base/test/TestScaleTickIntervals.h @ 1409:21ba60008200 scale-ticks
More fixes, more tests, including some more that now fail
author | Chris Cannam |
---|---|
date | Wed, 03 May 2017 18:01:25 +0100 |
parents | f89365917d02 |
children | c4af57d59434 |
comparison
equal
deleted
inserted
replaced
1408:f89365917d02 | 1409:21ba60008200 |
---|---|
67 private slots: | 67 private slots: |
68 void linear_0_1_10() | 68 void linear_0_1_10() |
69 { | 69 { |
70 auto ticks = ScaleTickIntervals::linear({ 0, 1, 10 }); | 70 auto ticks = ScaleTickIntervals::linear({ 0, 1, 10 }); |
71 vector<ScaleTickIntervals::Tick> expected { | 71 vector<ScaleTickIntervals::Tick> expected { |
72 { 0.0, "0.00" }, | 72 { 0.0, "0.0" }, |
73 { 0.1, "0.10" }, | 73 { 0.1, "0.1" }, |
74 { 0.2, "0.20" }, | 74 { 0.2, "0.2" }, |
75 { 0.3, "0.30" }, | 75 { 0.3, "0.3" }, |
76 { 0.4, "0.40" }, | 76 { 0.4, "0.4" }, |
77 { 0.5, "0.50" }, | 77 { 0.5, "0.5" }, |
78 { 0.6, "0.60" }, | 78 { 0.6, "0.6" }, |
79 { 0.7, "0.70" }, | 79 { 0.7, "0.7" }, |
80 { 0.8, "0.80" }, | 80 { 0.8, "0.8" }, |
81 { 0.9, "0.90" }, | 81 { 0.9, "0.9" }, |
82 { 1.0, "1.00" } | 82 { 1.0, "1.0" } |
83 }; | |
84 compareTicks(ticks.ticks, expected); | |
85 } | |
86 | |
87 void linear_0_5_5() | |
88 { | |
89 auto ticks = ScaleTickIntervals::linear({ 0, 5, 5 }); | |
90 vector<ScaleTickIntervals::Tick> expected { | |
91 { 0, "0" }, | |
92 { 1, "1" }, | |
93 { 2, "2" }, | |
94 { 3, "3" }, | |
95 { 4, "4" }, | |
96 { 5, "5" }, | |
97 }; | |
98 compareTicks(ticks.ticks, expected); | |
99 } | |
100 | |
101 void linear_0_10_5() | |
102 { | |
103 auto ticks = ScaleTickIntervals::linear({ 0, 10, 5 }); | |
104 vector<ScaleTickIntervals::Tick> expected { | |
105 { 0, "0" }, | |
106 { 2, "2" }, | |
107 { 4, "4" }, | |
108 { 6, "6" }, | |
109 { 8, "8" }, | |
110 { 10, "10" } | |
83 }; | 111 }; |
84 compareTicks(ticks.ticks, expected); | 112 compareTicks(ticks.ticks, expected); |
85 } | 113 } |
86 | 114 |
87 void linear_0_0p1_5() | 115 void linear_0_0p1_5() |
88 { | 116 { |
89 auto ticks = ScaleTickIntervals::linear({ 0, 0.1, 5 }); | 117 auto ticks = ScaleTickIntervals::linear({ 0, 0.1, 5 }); |
90 vector<ScaleTickIntervals::Tick> expected { | 118 vector<ScaleTickIntervals::Tick> expected { |
91 { 0.0, "0.00" }, | 119 { 0.00, "0.00" }, |
92 { 0.02, "0.02" }, | 120 { 0.02, "0.02" }, |
93 { 0.04, "0.04" }, | 121 { 0.04, "0.04" }, |
94 { 0.06, "0.06" }, | 122 { 0.06, "0.06" }, |
95 { 0.08, "0.08" }, | 123 { 0.08, "0.08" }, |
96 { 0.1, "0.10" } | 124 { 0.10, "0.10" } |
97 }; | 125 }; |
98 compareTicks(ticks.ticks, expected); | 126 compareTicks(ticks.ticks, expected); |
99 } | 127 } |
100 | 128 |
101 void linear_0_0p01_5() | 129 void linear_0_0p01_5() |
102 { | 130 { |
103 auto ticks = ScaleTickIntervals::linear({ 0, 0.01, 5 }); | 131 auto ticks = ScaleTickIntervals::linear({ 0, 0.01, 5 }); |
104 vector<ScaleTickIntervals::Tick> expected { | 132 vector<ScaleTickIntervals::Tick> expected { |
105 { 0.00, "0.000" }, | 133 { 0.000, "0.000" }, |
106 { 0.002, "0.002" }, | 134 { 0.002, "0.002" }, |
107 { 0.004, "0.004" }, | 135 { 0.004, "0.004" }, |
108 { 0.006, "0.006" }, | 136 { 0.006, "0.006" }, |
109 { 0.008, "0.008" }, | 137 { 0.008, "0.008" }, |
110 { 0.01, "0.010" } | 138 { 0.010, "0.010" } |
139 }; | |
140 compareTicks(ticks.ticks, expected); | |
141 } | |
142 | |
143 void linear_0_0p005_5() | |
144 { | |
145 auto ticks = ScaleTickIntervals::linear({ 0, 0.005, 5 }); | |
146 vector<ScaleTickIntervals::Tick> expected { | |
147 { 0.000, "0.000" }, | |
148 { 0.001, "0.001" }, | |
149 { 0.002, "0.002" }, | |
150 { 0.003, "0.003" }, | |
151 { 0.004, "0.004" }, | |
152 { 0.005, "0.005" } | |
111 }; | 153 }; |
112 compareTicks(ticks.ticks, expected); | 154 compareTicks(ticks.ticks, expected); |
113 } | 155 } |
114 | 156 |
115 void linear_0_0p001_5() | 157 void linear_0_0p001_5() |
116 { | 158 { |
117 auto ticks = ScaleTickIntervals::linear({ 0, 0.001, 5 }); | 159 auto ticks = ScaleTickIntervals::linear({ 0, 0.001, 5 }); |
118 vector<ScaleTickIntervals::Tick> expected { | 160 vector<ScaleTickIntervals::Tick> expected { |
119 { 0.000, "0.0e+00" }, | 161 { 0.0000, "0.0e+00" }, |
120 { 0.0002, "2.0e-04" }, | 162 { 0.0002, "2.0e-04" }, |
121 { 0.0004, "4.0e-04" }, | 163 { 0.0004, "4.0e-04" }, |
122 { 0.0006, "6.0e-04" }, | 164 { 0.0006, "6.0e-04" }, |
123 { 0.0008, "8.0e-04" }, | 165 { 0.0008, "8.0e-04" }, |
124 { 0.001, "1.0e-03" } | 166 { 0.0010, "1.0e-03" } |
125 }; | 167 }; |
126 compareTicks(ticks.ticks, expected); | 168 compareTicks(ticks.ticks, expected); |
127 } | 169 } |
128 | 170 |
129 void linear_1_1p001_5() | 171 void linear_1_1p001_5() |
130 { | 172 { |
131 auto ticks = ScaleTickIntervals::linear({ 1, 1.001, 5 }); | 173 auto ticks = ScaleTickIntervals::linear({ 1, 1.001, 5 }); |
132 vector<ScaleTickIntervals::Tick> expected { | 174 vector<ScaleTickIntervals::Tick> expected { |
133 { 1.000, "1.0000" }, | 175 { 1.0000, "1.0000" }, |
134 { 1.0002, "1.0002" }, | 176 { 1.0002, "1.0002" }, |
135 { 1.0004, "1.0004" }, | 177 { 1.0004, "1.0004" }, |
136 { 1.0006, "1.0006" }, | 178 { 1.0006, "1.0006" }, |
137 { 1.0008, "1.0008" }, | 179 { 1.0008, "1.0008" }, |
138 { 1.001, "1.0010" } | 180 { 1.0010, "1.0010" } |
181 }; | |
182 compareTicks(ticks.ticks, expected); | |
183 } | |
184 | |
185 void linear_10000_10010_5() | |
186 { | |
187 auto ticks = ScaleTickIntervals::linear({ 10000, 10010, 5 }); | |
188 vector<ScaleTickIntervals::Tick> expected { | |
189 { 10000, "10000" }, | |
190 { 10002, "10002" }, | |
191 { 10004, "10004" }, | |
192 { 10006, "10006" }, | |
193 { 10008, "10008" }, | |
194 { 10010, "10010" }, | |
195 }; | |
196 compareTicks(ticks.ticks, expected); | |
197 } | |
198 | |
199 void linear_10000_20000_5() | |
200 { | |
201 auto ticks = ScaleTickIntervals::linear({ 10000, 20000, 5 }); | |
202 vector<ScaleTickIntervals::Tick> expected { | |
203 { 10000, "10000" }, | |
204 { 12000, "12000" }, | |
205 { 14000, "14000" }, | |
206 { 16000, "16000" }, | |
207 { 18000, "18000" }, | |
208 { 20000, "20000" }, | |
209 }; | |
210 compareTicks(ticks.ticks, expected); | |
211 } | |
212 | |
213 void linear_m1_1_10() | |
214 { | |
215 auto ticks = ScaleTickIntervals::linear({ -1, 1, 10 }); | |
216 vector<ScaleTickIntervals::Tick> expected { | |
217 { -1.0, "-1.0" }, | |
218 { -0.8, "-0.8" }, | |
219 { -0.6, "-0.6" }, | |
220 { -0.4, "-0.4" }, | |
221 { -0.2, "-0.2" }, | |
222 { 0.0, "0.0" }, | |
223 { 0.2, "0.2" }, | |
224 { 0.4, "0.4" }, | |
225 { 0.6, "0.6" }, | |
226 { 0.8, "0.8" }, | |
227 { 1.0, "1.0" } | |
139 }; | 228 }; |
140 compareTicks(ticks.ticks, expected); | 229 compareTicks(ticks.ticks, expected); |
141 } | 230 } |
142 }; | 231 }; |
143 | 232 |