ctkRangeWidgetValueProxyTest.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.commontk.org/LICENSE
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. // Qt includes
  15. #include <QApplication>
  16. #include <QTest>
  17. // CTK includes
  18. #include "ctkRangeWidget.h"
  19. #include "ctkLinearValueProxy.h"
  20. #include "ctkTest.h"
  21. #include "ctkValueProxy.h"
  22. namespace
  23. {
  24. //-----------------------------------------------------------------------------
  25. void getSpyReport(QSignalSpy& spy, double expectedValue)
  26. {
  27. QCOMPARE(spy.count(), 1);
  28. QList<QVariant> arguments = spy.takeFirst(); // take the first signal
  29. ctkTest::COMPARE(arguments.at(0).toDouble(), expectedValue);
  30. }
  31. //-----------------------------------------------------------------------------
  32. class CustomSpy : public QObject
  33. {
  34. Q_OBJECT
  35. public:
  36. CustomSpy()
  37. {
  38. this->AcknowledgedSignals = 0;
  39. }
  40. public slots:
  41. void onValuesChanged(double min, double max)
  42. {
  43. ++this->AcknowledgedSignals;
  44. this->MinSpyData.append(min);
  45. this->MaxSpyData.append(max);
  46. }
  47. public:
  48. void getSpyReport(double min, double max)
  49. {
  50. QCOMPARE(this->AcknowledgedSignals, 1);
  51. QCOMPARE(this->MinSpyData.size(), 1);
  52. ctkTest::COMPARE(this->MinSpyData[0], min);
  53. QCOMPARE(this->MaxSpyData.size(), 1);
  54. ctkTest::COMPARE(this->MaxSpyData[0], max);
  55. }
  56. QList<double> MinSpyData;
  57. QList<double> MaxSpyData;
  58. int AcknowledgedSignals;
  59. };
  60. } // end namespace
  61. //-----------------------------------------------------------------------------
  62. class ctkRangeWidgetValueProxyTester: public QObject
  63. {
  64. Q_OBJECT
  65. private slots:
  66. void testSetMinValue();
  67. void testSetMinValue_data();
  68. void testSetMaxValue();
  69. void testSetMaxValue_data();
  70. void testSetValues();
  71. void testSetValues_data();
  72. private:
  73. void testSetValueCommonData();
  74. void testSetPositionCommonData();
  75. };
  76. //-----------------------------------------------------------------------------
  77. void ctkRangeWidgetValueProxyTester::testSetValues()
  78. {
  79. // Setup
  80. ctkRangeWidget ranger;
  81. ranger.setMinimum(-200);
  82. ranger.setMaximum(200);
  83. ranger.setSingleStep(0.01);
  84. ranger.setMinimumValue(-32.6);
  85. ranger.setMaximumValue(32.6);
  86. QFETCH(double, coefficient);
  87. QFETCH(double, offset);
  88. ctkLinearValueProxy proxy;
  89. proxy.setCoefficient(coefficient);
  90. proxy.setOffset(offset);
  91. ranger.setValueProxy(&proxy);
  92. // \todo when valuesChanged is fixed
  93. // Spy
  94. //CustomSpy valuesSpy;
  95. //QObject::connect(&ranger, SIGNAL(valuesChanged(double, double)),
  96. // &valuesSpy, SLOT(onValuesChanged(double, double)));
  97. // Test
  98. QFETCH(double, min);
  99. QFETCH(double, max);
  100. ranger.setValues(min, max);
  101. QFETCH(double, expectedMin);
  102. QFETCH(double, expectedMax);
  103. //valuesSpy.getSpyReport(expectedMin, expectedMax);
  104. ctkTest::COMPARE(ranger.minimumValue(), expectedMin);
  105. ctkTest::COMPARE(ranger.maximumValue(), expectedMax);
  106. }
  107. //-----------------------------------------------------------------------------
  108. void ctkRangeWidgetValueProxyTester::testSetValues_data()
  109. {
  110. QTest::addColumn<double>("coefficient");
  111. QTest::addColumn<double>("offset");
  112. QTest::addColumn<double>("min");
  113. QTest::addColumn<double>("expectedMin");
  114. QTest::addColumn<double>("max");
  115. QTest::addColumn<double>("expectedMax");
  116. //---------------------------------------------------------------------------
  117. // Offset
  118. QTest::newRow("Offset only") << 1.0 << 49.19 << 0.1 << 0.1 << 0.2 << 0.2;
  119. QTest::newRow("Offset only: max+offset < min+offset < -200") << 1.0 << -42.19
  120. << -160.0 << -157.81
  121. << -190.9 << -157.81;
  122. QTest::newRow("Offset only: max+offset < -200 < min+offset") << 1.0 << -42.19
  123. << -0.1 << -157.81
  124. << -160.9 << -0.1;
  125. QTest::newRow("Offset only: -200 < max+offset < min+offset") << 1.0 << 42.19
  126. << -0.1 << -130.9
  127. << -130.9 << -0.1;
  128. QTest::newRow("Offset only: 200 < max+offset < min+offset") << 1.0 << 42.19
  129. << 160.0 << 157.81
  130. << 190.9 << 157.81;
  131. QTest::newRow("Offset only: max+offset < 200 < min+offset") << 1.0 << 42.19
  132. << 160.9 << -0.9
  133. << -0.9 << 157.81;
  134. QTest::newRow("Offset only: max+offset < min+offset < 200") << 1.0 << 42.19
  135. << 130.6 << -13.9
  136. << -13.9 << 130.6;
  137. QTest::newRow("Offset only: 200 < max = max_double = min = max_double")
  138. << 1.0 << 42.19
  139. << std::numeric_limits<double>::max() << 157.81
  140. << std::numeric_limits<double>::max() << 157.81;
  141. QTest::newRow("Offset only: max = -max_double < -200 < 200 < min = max_double")
  142. << 1.0 << 42.19
  143. << std::numeric_limits<double>::max() << -242.19
  144. << -std::numeric_limits<double>::max() << 157.81;
  145. QTest::newRow("Offset only: max = -max_double = min = -max_double < -200")
  146. << 1.0 << 42.19
  147. << - std::numeric_limits<double>::max() << -242.19
  148. << - std::numeric_limits<double>::max() << -242.19;
  149. QTest::newRow("Offset only: 200 < max = infinity = min = infinity")
  150. << 1.0 << 42.19
  151. << std::numeric_limits<double>::infinity() << 157.81
  152. << std::numeric_limits<double>::infinity() << 157.81;
  153. QTest::newRow("Offset only: max = -infinity < -200 < 200 < min = infinity")
  154. << 1.0 << 42.19
  155. << std::numeric_limits<double>::infinity() << -242.19
  156. << -std::numeric_limits<double>::infinity() << 157.81;
  157. QTest::newRow("Offset only: max = -infinity = min = -infinity < -200")
  158. << 1.0 << 42.19
  159. << - std::numeric_limits<double>::infinity() << -242.19
  160. << - std::numeric_limits<double>::infinity() << -242.19;
  161. QTest::newRow("Offset only: max = min = NaN")
  162. << 1.0 << 42.19
  163. << std::numeric_limits<double>::quiet_NaN() << 157.81
  164. << std::numeric_limits<double>::quiet_NaN() << 157.81;
  165. QTest::newRow("Offset only: max = NaN && min > 200")
  166. << 1.0 << 42.19
  167. << 630.0 << 157.81
  168. << std::numeric_limits<double>::quiet_NaN() << 157.81;
  169. QTest::newRow("Offset only: min = NaN && max < -200")
  170. << 1.0 << 42.19
  171. << std::numeric_limits<double>::quiet_NaN() << -74.79
  172. << -794348.12 << -74.79;
  173. //---------------------------------------------------------------------------
  174. // Coefficient
  175. QTest::newRow("Coeff only") << 5.0 << 0.0 << 0.1 << 0.1 << 0.2 << 0.2;
  176. QTest::newRow("Coeff only: max*coeff < min*coeff < -200") << 5.0 << 0.0
  177. << -160.0 << -40.0
  178. << -190.9 << -40.0;
  179. QTest::newRow("Coeff only: max*coeff < -200 < min*coeff") << 5.0 << 0.0
  180. << -0.1 << -40.0
  181. << -160.9 << -0.1;
  182. QTest::newRow("Coeff only: -200 < max*coeff < min*coeff") << 5.0 << 0.0
  183. << -0.1 << -20.9
  184. << -20.9 << -0.1;
  185. QTest::newRow("Coeff only: 200 < max*coeff < min*coeff") << 5.0 << 0.0
  186. << 160.0 << 40.0
  187. << 190.9 << 40.0;
  188. QTest::newRow("Coeff only: max*coeff < 200 < min*coeff") << 5.0 << 0.0
  189. << 160.9 << -0.9
  190. << -0.9 << 40.00;
  191. QTest::newRow("Coeff only: max*coeff < min*coeff < 200") << 5.0 << 0.0
  192. << 13.6 << -13.9
  193. << -13.9 << 13.6;
  194. QTest::newRow("Coeff only: 200 < max = max_double = min = max_double")
  195. << 5.0 << 0.0
  196. << std::numeric_limits<double>::max() << 40.0
  197. << std::numeric_limits<double>::max() << 40.0;
  198. QTest::newRow("Coeff only: max = -max_double < -200 < 200 < min = max_double")
  199. << 5.0 << 0.0
  200. << std::numeric_limits<double>::max() << -40.0
  201. << - std::numeric_limits<double>::max() << 40.0;
  202. QTest::newRow("Coeff only: max = -max_double = min = -max_double < -200")
  203. << 5.0 << 0.0
  204. << -std::numeric_limits<double>::max() << -40.0
  205. << -std::numeric_limits<double>::max() << -40.0;
  206. QTest::newRow("Coeff only: 200 < max = infinity = min = infinity")
  207. << 5.0 << 0.0
  208. << std::numeric_limits<double>::infinity() << 40.0
  209. << std::numeric_limits<double>::infinity() << 40.0;
  210. QTest::newRow("Coeff only: max = -infinity < -200 < 200 < min = infinity")
  211. << 5.0 << 0.0
  212. << std::numeric_limits<double>::infinity() << -40.0
  213. << -std::numeric_limits<double>::infinity() << 40.0;
  214. QTest::newRow("Coeff only: max = -infinity = min = -infinity < -200")
  215. << 5.0 << 0.0
  216. << - std::numeric_limits<double>::infinity() << -40.0
  217. << - std::numeric_limits<double>::infinity() << -40.0;
  218. QTest::newRow("Coeff only: max = min = NaN")
  219. << 5.0 << 0.0
  220. << std::numeric_limits<double>::quiet_NaN() << 40.0
  221. << std::numeric_limits<double>::quiet_NaN() << 40.0;
  222. QTest::newRow("Coeff only: max = NaN && min > 200")
  223. << 5.0 << 0.0
  224. << 630.0 << 40.0
  225. << std::numeric_limits<double>::quiet_NaN() << 40.0;
  226. QTest::newRow("Coeff only: min = NaN && max < -200")
  227. << 5.0 << 0.0
  228. << std::numeric_limits<double>::quiet_NaN() << -6.52
  229. << -794348.12 << -6.52;
  230. //---------------------------------------------------------------------------
  231. // Linear
  232. QTest::newRow("Linear") << 5.0 << 12.0 << 0.1 << 0.1 << 0.2 << 0.2;
  233. QTest::newRow("Linear:f(max) < f(min) < -200") << 5.0 << 12.0
  234. << -160.0 << -42.4
  235. << -190.9 << -42.4;
  236. QTest::newRow("Linear: f(max) < -200 < f(min)") << 5.0 << 12.0
  237. << -0.1 << -42.4
  238. << -160.9 << -0.1;
  239. QTest::newRow("Linear: -200 < f(max) < f(min)") << 5.0 << 12.0
  240. << -0.1 << -20.9
  241. << -20.9 << -0.1;
  242. QTest::newRow("Linear: 200 < f(max) < f(min)") << 5.0 << 12.0
  243. << 160.0 << 37.6
  244. << 190.9 << 37.6;
  245. QTest::newRow("Linear: f(max) < 200 < f(min)") << 5.0 << 12.0
  246. << 160.9 << -0.9
  247. << -0.9 << 37.6;
  248. QTest::newRow("Linear: f(max) < f(min) < 200") << 5.0 << 12.0
  249. << 13.6 << -13.9
  250. << -13.9 << 13.6;
  251. QTest::newRow("Linear: 200 < max = max_double = min = max_double")
  252. << 5.0 << 12.0
  253. << std::numeric_limits<double>::max() << 37.6
  254. << std::numeric_limits<double>::max() << 37.6;
  255. QTest::newRow("Linear: max = -max_double < -200 < 200 < min = max_double")
  256. << 5.0 << 12.0
  257. << std::numeric_limits<double>::max() << -42.4
  258. << - std::numeric_limits<double>::max() << 37.6;
  259. QTest::newRow("Linear: max = -max_double = min = -max_double < -200")
  260. << 5.0 << 12.0
  261. << -std::numeric_limits<double>::max() << -42.4
  262. << -std::numeric_limits<double>::max() << -42.4;
  263. QTest::newRow("Linear: 200 < max = infinity = min = infinity")
  264. << 5.0 << 12.0
  265. << std::numeric_limits<double>::infinity() << 37.6
  266. << std::numeric_limits<double>::infinity() << 37.6;
  267. QTest::newRow("Linear: max = -infinity < -200 < 200 < min = infinity")
  268. << 5.0 << 12.0
  269. << std::numeric_limits<double>::infinity() << -42.4
  270. << -std::numeric_limits<double>::infinity() << 37.6;
  271. QTest::newRow("Linear: max = -infinity = min = -infinity < -200")
  272. << 5.0 << 12.0
  273. << - std::numeric_limits<double>::infinity() << -42.4
  274. << - std::numeric_limits<double>::infinity() << -42.4;
  275. QTest::newRow("Linear: max = min = NaN")
  276. << 5.0 << 12.0
  277. << std::numeric_limits<double>::quiet_NaN() << 37.6
  278. << std::numeric_limits<double>::quiet_NaN() << 37.6;
  279. QTest::newRow("Linear: max = NaN && f(min) > 200")
  280. << 5.0 << 12.0
  281. << 630.0 << 37.6
  282. << std::numeric_limits<double>::quiet_NaN() << 37.6;
  283. QTest::newRow("Linear: min = NaN && f(max) < -200")
  284. << 5.0 << 12.0
  285. << std::numeric_limits<double>::quiet_NaN() << -8.92
  286. << -794348.12 << -8.92;
  287. }
  288. //-----------------------------------------------------------------------------
  289. void ctkRangeWidgetValueProxyTester::testSetMinValue()
  290. {
  291. // Setup
  292. ctkRangeWidget ranger;
  293. ranger.setMinimum(-200);
  294. ranger.setMaximum(200);
  295. ranger.setSingleStep(0.01);
  296. ranger.setMinimumValue(-32.6);
  297. QFETCH(double, coefficient);
  298. QFETCH(double, offset);
  299. ctkLinearValueProxy proxy;
  300. proxy.setCoefficient(coefficient);
  301. proxy.setOffset(offset);
  302. ranger.setValueProxy(&proxy);
  303. // \todo when valuesChanged is fixed
  304. // Spy
  305. //QSignalSpy valueSpy(&ranger, SIGNAL(minimumValueChanged(double)));
  306. // Test
  307. QFETCH(double, value);
  308. ranger.setMinimumValue(value);
  309. QFETCH(double, expectedValue);
  310. //getSpyReport(valueSpy, expectedValue);
  311. ctkTest::COMPARE(ranger.minimumValue(), expectedValue);
  312. }
  313. //-----------------------------------------------------------------------------
  314. void ctkRangeWidgetValueProxyTester::testSetMinValue_data()
  315. {
  316. QTest::addColumn<double>("coefficient");
  317. QTest::addColumn<double>("offset");
  318. QTest::addColumn<double>("value");
  319. QTest::addColumn<double>("expectedValue");
  320. //---------------------------------------------------------------------------
  321. // Offset
  322. QTest::newRow("Offset only") << 1.0 << 42.19 << 0.1 << 0.1;
  323. QTest::newRow("Offset only: less than min")
  324. << 1.0 << 42.19 << -510.0 << -242.19;
  325. QTest::newRow("Offset only: less than min but ok with offset")
  326. << 1.0 << 42.19 << -230.0 << -230.0;
  327. QTest::newRow("Offset only: less than min with offset")
  328. << 1.0 << -42.19 << -190.0 << -157.81;
  329. QTest::newRow("Offset only: more than max with offset")
  330. << 1.0 << 42.19 << 160.0 << 157.81;
  331. QTest::newRow("Offset only: more than max")
  332. << 1.0 << -42.19 << 65010.0 << 242.19;
  333. QTest::newRow("Offset only: less than max but ok with offset")
  334. << 1.0 << -42.19 << 229.1 << 229.1;
  335. QTest::newRow("Offset only: max")
  336. << 1.0 << 42.19 << std::numeric_limits<double>::max() << 157.81;
  337. QTest::newRow("Offset only: min")
  338. << 1.0 << 42.19 << -std::numeric_limits<double>::max() << -242.19;
  339. QTest::newRow("Offset only: infinity")
  340. << 1.0 << 42.19 << std::numeric_limits<double>::infinity() << 157.81;
  341. QTest::newRow("Offset only: - infinity")
  342. << 1.0 << 42.19 << -std::numeric_limits<double>::infinity() << -242.19;
  343. QTest::newRow("Offset only: Nan")
  344. << 1.0 << 42.19 << std::numeric_limits<double>::quiet_NaN() << 157.81;
  345. //---------------------------------------------------------------------------
  346. // Coefficient
  347. QTest::newRow("Coeff only") << 5.0 << 0.0 << 0.1 << 0.1;
  348. QTest::newRow("Coeff only: less than min")
  349. << 5.0 << 0.0 << -510.0 << -40.0;
  350. QTest::newRow("Coeff only: less than min but ok with coeff")
  351. << 0.5 << 0.0 << -230.0 << -230.0;
  352. QTest::newRow("Coeff only: less than min with coeff")
  353. << 5.0 << 0.0 << -190.0 << -40.0;
  354. QTest::newRow("Coeff only: more than max with coeff")
  355. << 5.0 << 0.0 << 160.0 << 40.0;
  356. QTest::newRow("Coeff only: more than max")
  357. << 5.0 << 0.0 << 65010.0 << 40.0;
  358. QTest::newRow("Offset only: less than max but ok with coeff")
  359. << 0.5 << 0.0 << 229.2 << 229.2;
  360. QTest::newRow("Coeff only: max")
  361. << 5.0 << 0.0 << std::numeric_limits<double>::max() << 40.0;
  362. QTest::newRow("Coeff only: min")
  363. << 5.0 << 0.0 << -std::numeric_limits<double>::max() << -40.0;
  364. QTest::newRow("Coeff only: infinity")
  365. << 5.0 << 0.0 << std::numeric_limits<double>::infinity() << 40.0;
  366. QTest::newRow("Coeff only: - infinity")
  367. << 5.0 << 0.0 << -std::numeric_limits<double>::infinity() << -40.0;
  368. QTest::newRow("Coeff only: Nan")
  369. << 5.0 << 0.0 << std::numeric_limits<double>::quiet_NaN() << 40.0;
  370. //---------------------------------------------------------------------------
  371. // Linear
  372. QTest::newRow("Linear") << 5.0 << 0.0 << 0.1 << 0.1;
  373. QTest::newRow("Linear: less than min")
  374. << 5.0 << 12.0 << -510.0 << -42.4;
  375. QTest::newRow("Linear: less than min but ok with function")
  376. << 0.5 << 12.0 << -230.0 << -230.0;
  377. QTest::newRow("Linear: less than min with function")
  378. << 5.0 << 12.0 << -61.5 << -42.4;
  379. QTest::newRow("Linear: more than max with function")
  380. << 5.0 << 12.0 << 160.0 << 37.6;
  381. QTest::newRow("Linear: more than max")
  382. << 5.0 << 12.0 << 65010.0 << 37.6;
  383. QTest::newRow("Offset only: less than max but ok with function")
  384. << 0.5 << 12.0 << 229.2 << 229.2;
  385. QTest::newRow("Linear: max")
  386. << 5.0 << 12.0 << std::numeric_limits<double>::max() << 37.6;
  387. QTest::newRow("Linear: min")
  388. << 5.0 << 12.0 << -std::numeric_limits<double>::max() << -42.4;
  389. QTest::newRow("Linear: infinity")
  390. << 5.0 << 12.0 << std::numeric_limits<double>::infinity() << 37.6;
  391. QTest::newRow("Linear: - infinity")
  392. << 5.0 << 12.0 << -std::numeric_limits<double>::infinity() << -42.4;
  393. QTest::newRow("Linear: Nan")
  394. << 5.0 << 12.0 << std::numeric_limits<double>::quiet_NaN() << 37.6;
  395. }
  396. //-----------------------------------------------------------------------------
  397. void ctkRangeWidgetValueProxyTester::testSetMaxValue()
  398. {
  399. // Setup
  400. ctkRangeWidget ranger;
  401. ranger.setMinimum(-200);
  402. ranger.setMaximum(200);
  403. ranger.setSingleStep(0.01);
  404. ranger.setMaximumValue(-32.6);
  405. QFETCH(double, coefficient);
  406. QFETCH(double, offset);
  407. ctkLinearValueProxy proxy;
  408. proxy.setCoefficient(coefficient);
  409. proxy.setOffset(offset);
  410. ranger.setValueProxy(&proxy);
  411. // \todo when valuesChanged is fixed
  412. // Spy
  413. //QSignalSpy valueSpy(&ranger, SIGNAL(maximumValueChanged(double)));
  414. // Test
  415. QFETCH(double, value);
  416. ranger.setMaximumValue(value);
  417. QFETCH(double, expectedValue);
  418. //getSpyReport(valueSpy, expectedValue);
  419. ctkTest::COMPARE(ranger.maximumValue(), expectedValue);
  420. }
  421. //-----------------------------------------------------------------------------
  422. void ctkRangeWidgetValueProxyTester::testSetMaxValue_data()
  423. {
  424. QTest::addColumn<double>("coefficient");
  425. QTest::addColumn<double>("offset");
  426. QTest::addColumn<double>("value");
  427. QTest::addColumn<double>("expectedValue");
  428. //---------------------------------------------------------------------------
  429. // Offset
  430. QTest::newRow("Offset only") << 1.0 << 42.19 << 0.1 << 0.1;
  431. QTest::newRow("Offset only: less than min")
  432. << 1.0 << 42.19 << -510.0 << -32.6 - 42.19;
  433. QTest::newRow("Offset only: less than min but ok with offset")
  434. << 1.0 << 42.19 << -230.0 << -32.6 - 42.19;
  435. QTest::newRow("Offset only: less than min with offset")
  436. << 1.0 << -42.19 << -190.0 << 9.59;
  437. QTest::newRow("Offset only: more than max with offset")
  438. << 1.0 << 42.19 << 160.0 << 157.81;
  439. QTest::newRow("Offset only: more than max")
  440. << 1.0 << -42.19 << 65010.0 << 242.19;
  441. QTest::newRow("Offset only: less than max but ok with offset")
  442. << 1.0 << -42.19 << 229.1 << 229.1;
  443. QTest::newRow("Offset only: max")
  444. << 1.0 << 42.19 << std::numeric_limits<double>::max() << 157.81;
  445. QTest::newRow("Offset only: min")
  446. << 1.0 << 42.19 << -std::numeric_limits<double>::max() << -74.79;
  447. QTest::newRow("Offset only: infinity")
  448. << 1.0 << 42.19 << std::numeric_limits<double>::infinity() << 157.81;
  449. QTest::newRow("Offset only: - infinity")
  450. << 1.0 << 42.19 << -std::numeric_limits<double>::infinity() << -74.79;
  451. QTest::newRow("Offset only: Nan")
  452. << 1.0 << 42.19 << std::numeric_limits<double>::quiet_NaN() << 157.81;
  453. //---------------------------------------------------------------------------
  454. // Coefficient
  455. QTest::newRow("Coeff only") << 5.0 << 0.0 << 0.1 << 0.1;
  456. QTest::newRow("Coeff only: less than min")
  457. << 5.0 << 0.0 << -510.0 << -6.52;
  458. QTest::newRow("Coeff only: less than min but ok with coeff")
  459. << 0.5 << 0.0 << -230.0 << -65.2;
  460. QTest::newRow("Coeff only: less than min with coeff")
  461. << 5.0 << 0.0 << -190.0 << -6.52;
  462. QTest::newRow("Coeff only: more than max with coeff")
  463. << 5.0 << 0.0 << 160.0 << 40.0;
  464. QTest::newRow("Coeff only: more than max")
  465. << 5.0 << 0.0 << 65010.0 << 40.0;
  466. QTest::newRow("Offset only: less than max but ok with coeff")
  467. << 0.5 << 0.0 << 229.2 << 229.2;
  468. QTest::newRow("Coeff only: max")
  469. << 5.0 << 0.0 << std::numeric_limits<double>::max() << 40.0;
  470. QTest::newRow("Coeff only: min")
  471. << 5.0 << 0.0 << -std::numeric_limits<double>::max() << -6.52;
  472. QTest::newRow("Coeff only: infinity")
  473. << 5.0 << 0.0 << std::numeric_limits<double>::infinity() << 40.0;
  474. QTest::newRow("Coeff only: - infinity")
  475. << 5.0 << 0.0 << -std::numeric_limits<double>::infinity() << -6.52;
  476. QTest::newRow("Coeff only: Nan")
  477. << 5.0 << 0.0 << std::numeric_limits<double>::quiet_NaN() << 40.0;
  478. //---------------------------------------------------------------------------
  479. // Linear
  480. QTest::newRow("Linear") << 5.0 << 0.0 << 0.1 << 0.1;
  481. QTest::newRow("Linear: less than min")
  482. << 5.0 << 12.0 << -510.0 << -8.92;
  483. QTest::newRow("Linear: less than min but ok with function")
  484. << 0.5 << 12.0 << -230.0 << -89.2;
  485. QTest::newRow("Linear: less than min with function")
  486. << 5.0 << 12.0 << -61.5 << -8.92;
  487. QTest::newRow("Linear: more than max with function")
  488. << 5.0 << 12.0 << 160.0 << 37.6;
  489. QTest::newRow("Linear: more than max")
  490. << 5.0 << 12.0 << 65010.0 << 37.6;
  491. QTest::newRow("Offset only: less than max but ok with function")
  492. << 0.5 << 12.0 << 229.2 << 229.2;
  493. QTest::newRow("Linear: max")
  494. << 5.0 << 12.0 << std::numeric_limits<double>::max() << 37.6;
  495. QTest::newRow("Linear: min")
  496. << 5.0 << 12.0 << -std::numeric_limits<double>::max() << -8.92;
  497. QTest::newRow("Linear: infinity")
  498. << 5.0 << 12.0 << std::numeric_limits<double>::infinity() << 37.6;
  499. QTest::newRow("Linear: - infinity")
  500. << 5.0 << 12.0 << -std::numeric_limits<double>::infinity() << -8.92;
  501. QTest::newRow("Linear: Nan")
  502. << 5.0 << 12.0 << std::numeric_limits<double>::quiet_NaN() << 37.6;
  503. }
  504. // ----------------------------------------------------------------------------
  505. CTK_TEST_MAIN(ctkRangeWidgetValueProxyTest)
  506. #include "moc_ctkRangeWidgetValueProxyTest.cpp"