changeset 1380:bd1eb56df8d5

Fix some initialisers that are causing complaint from msvc (from double-to-float truncation)
author Chris Cannam
date Tue, 21 Feb 2017 21:07:54 +0000
parents 8db84bd61eaa
children ce08318aad83
files base/test/TestColumnOp.h
diffstat 1 files changed, 30 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/base/test/TestColumnOp.h	Tue Feb 07 14:55:19 2017 +0000
+++ b/base/test/TestColumnOp.h	Tue Feb 21 21:07:54 2017 +0000
@@ -55,7 +55,7 @@
         QCOMPARE(C::applyGain({}, 1.0), Column());
         Column c { 1, 2, 3, -4, 5, 6 };
         Column actual(C::applyGain(c, 1.5));
-        Column expected { 1.5, 3, 4.5, -6, 7.5, 9 };
+        Column expected { 1.5f, 3, 4.5f, -6, 7.5f, 9 };
         QCOMPARE(actual, expected);
         actual = C::applyGain(c, 1.0);
         QCOMPARE(actual, c);
@@ -68,7 +68,7 @@
         QCOMPARE(C::fftScale({}, 2.0), Column());
         Column c { 1, 2, 3, -4, 5 };
         Column actual(C::fftScale(c, 8));
-        Column expected { 0.25, 0.5, 0.75, -1, 1.25 };
+        Column expected { 0.25f, 0.5f, 0.75f, -1, 1.25f };
         QCOMPARE(actual, expected);
     }
 
@@ -79,33 +79,33 @@
     }
 
     void isPeak_obvious() {
-        Column c { 0.4, 0.5, 0.3 };
+        Column c { 0.4f, 0.5f, 0.3f };
         QVERIFY(!C::isPeak(c, 0));
         QVERIFY(C::isPeak(c, 1));
         QVERIFY(!C::isPeak(c, 2));
     }
 
     void isPeak_edges() {
-        Column c { 0.5, 0.4, 0.3 };
+        Column c { 0.5f, 0.4f, 0.3f };
         QVERIFY(C::isPeak(c, 0));
         QVERIFY(!C::isPeak(c, 1));
         QVERIFY(!C::isPeak(c, 2));
         QVERIFY(!C::isPeak(c, 3));
         QVERIFY(!C::isPeak(c, -1));
-        c = { 1.4, 1.5 };
+        c = { 1.4f, 1.5f };
         QVERIFY(!C::isPeak(c, 0));
         QVERIFY(C::isPeak(c, 1));
     }
 
     void isPeak_flat() {
-        Column c { 0.0, 0.0, 0.0 };
+        Column c { 0.0f, 0.0f, 0.0f };
         QVERIFY(C::isPeak(c, 0));
         QVERIFY(!C::isPeak(c, 1));
         QVERIFY(!C::isPeak(c, 2));
     }
 
     void isPeak_mixedSign() {
-        Column c { 0.4, -0.5, -0.3, -0.6, 0.1, -0.3 };
+        Column c { 0.4f, -0.5f, -0.3f, -0.6f, 0.1f, -0.3f };
         QVERIFY(C::isPeak(c, 0));
         QVERIFY(!C::isPeak(c, 1));
         QVERIFY(C::isPeak(c, 2));
@@ -115,12 +115,12 @@
     }
 
     void isPeak_duplicate() {
-        Column c({ 0.5, 0.5, 0.4, 0.4 });
+        Column c({ 0.5f, 0.5f, 0.4f, 0.4f });
         QVERIFY(C::isPeak(c, 0));
         QVERIFY(!C::isPeak(c, 1));
         QVERIFY(!C::isPeak(c, 2));
         QVERIFY(!C::isPeak(c, 3));
-        c = { 0.4, 0.4, 0.5, 0.5 };
+        c = { 0.4f, 0.4f, 0.5f, 0.5f };
         QVERIFY(C::isPeak(c, 0)); // counterintuitive but necessary
         QVERIFY(!C::isPeak(c, 1));
         QVERIFY(C::isPeak(c, 2));
@@ -129,10 +129,10 @@
 
     void peakPick() {
         QCOMPARE(C::peakPick({}), Column());
-        Column c({ 0.5, 0.5, 0.4, 0.4 });
-        QCOMPARE(C::peakPick(c), Column({ 0.5, 0.0, 0.0, 0.0 }));
-        c = Column({ 0.4, -0.5, -0.3, -0.6, 0.1, -0.3 });
-        QCOMPARE(C::peakPick(c), Column({ 0.4, 0.0, -0.3, 0.0, 0.1, 0.0 }));
+        Column c({ 0.5f, 0.5f, 0.4f, 0.4f });
+        QCOMPARE(C::peakPick(c), Column({ 0.5f, 0.0f, 0.0f, 0.0f }));
+        c = Column({ 0.4f, -0.5f, -0.3f, -0.6f, 0.1f, -0.3f });
+        QCOMPARE(C::peakPick(c), Column({ 0.4f, 0.0f, -0.3f, 0.0f, 0.1f, 0.0f }));
     }
 
     void normalize_null() {
@@ -155,44 +155,44 @@
     void normalize_sum1() {
         Column c { 1, 2, 4, 3 };
         QCOMPARE(C::normalize(c, ColumnNormalization::Sum1),
-                 Column({ 0.1, 0.2, 0.4, 0.3 }));
+                 Column({ 0.1f, 0.2f, 0.4f, 0.3f }));
     }
 
     void normalize_sum1_mixedSign() {
         Column c { 1, 2, -4, -3 };
         QCOMPARE(C::normalize(c, ColumnNormalization::Sum1),
-                 Column({ 0.1, 0.2, -0.4, -0.3 }));
+                 Column({ 0.1f, 0.2f, -0.4f, -0.3f }));
     }
 
     void normalize_max1() {
         Column c { 4, 3, 2, 1 };
         QCOMPARE(C::normalize(c, ColumnNormalization::Max1),
-                 Column({ 1.0, 0.75, 0.5, 0.25 }));
+                 Column({ 1.0f, 0.75f, 0.5f, 0.25f }));
     }
 
     void normalize_max1_mixedSign() {
         Column c { -4, -3, 2, 1 };
         QCOMPARE(C::normalize(c, ColumnNormalization::Max1),
-                 Column({ -1.0, -0.75, 0.5, 0.25 }));
+                 Column({ -1.0f, -0.75f, 0.5f, 0.25f }));
     }
 
     void normalize_hybrid() {
         // with max == 99, log10(max+1) == 2 so scale factor will be 2/99
         Column c { 22, 44, 99, 66 };
         QCOMPARE(C::normalize(c, ColumnNormalization::Hybrid),
-                 Column({ 44.0/99.0, 88.0/99.0, 2.0, 132.0/99.0 }));
+                 Column({ 44.0f/99.0f, 88.0f/99.0f, 2.0f, 132.0f/99.0f }));
     }
 
     void normalize_hybrid_mixedSign() {
         // with max == 99, log10(max+1) == 2 so scale factor will be 2/99
         Column c { 22, 44, -99, -66 };
         QCOMPARE(C::normalize(c, ColumnNormalization::Hybrid),
-                 Column({ 44.0/99.0, 88.0/99.0, -2.0, -132.0/99.0 }));
+                 Column({ 44.0f/99.0f, 88.0f/99.0f, -2.0f, -132.0f/99.0f }));
     }
     
     void distribute_simple() {
         Column in { 1, 2, 3 };
-        BinMapping binfory { 0.0, 0.5, 1.0, 1.5, 2.0, 2.5 };
+        BinMapping binfory { 0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 2.5f };
         Column expected { 1, 1, 2, 2, 3, 3 };
         Column actual(C::distribute(in, 6, binfory, 0, false));
         report(actual);
@@ -201,7 +201,7 @@
     
     void distribute_simple_interpolated() {
         Column in { 1, 2, 3 };
-        BinMapping binfory { 0.0, 0.5, 1.0, 1.5, 2.0, 2.5 };
+        BinMapping binfory { 0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 2.5f };
         // There is a 0.5-bin offset from the distribution you might
         // expect, because this corresponds visually to the way that
         // bin values are duplicated upwards in simple_distribution.
@@ -209,7 +209,7 @@
         // non-interpolated views retains the visual position of each
         // bin peak as somewhere in the middle of the scale area for
         // that bin.
-        Column expected { 1, 1, 1.5, 2, 2.5, 3 };
+        Column expected { 1, 1, 1.5f, 2, 2.5f, 3 };
         Column actual(C::distribute(in, 6, binfory, 0, true));
         report(actual);
         QCOMPARE(actual, expected);
@@ -217,7 +217,7 @@
     
     void distribute_nonlinear() {
         Column in { 1, 2, 3 };
-        BinMapping binfory { 0.0, 0.2, 0.5, 1.0, 2.0, 2.5 };
+        BinMapping binfory { 0.0f, 0.2f, 0.5f, 1.0f, 2.0f, 2.5f };
         Column expected { 1, 1, 1, 2, 3, 3 };
         Column actual(C::distribute(in, 6, binfory, 0, false));
         report(actual);
@@ -227,7 +227,7 @@
     void distribute_nonlinear_interpolated() {
         // See distribute_simple_interpolated
         Column in { 1, 2, 3 };
-        BinMapping binfory { 0.0, 0.2, 0.5, 1.0, 2.0, 2.5 };
+        BinMapping binfory { 0.0f, 0.2f, 0.5f, 1.0f, 2.0f, 2.5f };
         Column expected { 1, 1, 1, 1.5, 2.5, 3 };
         Column actual(C::distribute(in, 6, binfory, 0, true));
         report(actual);
@@ -236,7 +236,7 @@
     
     void distribute_shrinking() {
         Column in { 4, 1, 2, 3, 5, 6 };
-        BinMapping binfory { 0.0, 2.0, 4.0 };
+        BinMapping binfory { 0.0f, 2.0f, 4.0f };
         Column expected { 4, 3, 6 };
         Column actual(C::distribute(in, 3, binfory, 0, false));
         report(actual);
@@ -247,7 +247,7 @@
         // should be same as distribute_shrinking, we don't
         // interpolate when resizing down
         Column in { 4, 1, 2, 3, 5, 6 };
-        BinMapping binfory { 0.0, 2.0, 4.0 };
+        BinMapping binfory { 0.0f, 2.0f, 4.0f };
         Column expected { 4, 3, 6 };
         Column actual(C::distribute(in, 3, binfory, 0, true));
         report(actual);
@@ -259,13 +259,13 @@
         // shrinking some bins but expanding others.  See
         // distribute_simple_interpolated for note on 0.5 offset
         Column in { 4, 1, 2, 3, 5, 6 };
-        BinMapping binfory { 0.0, 3.0, 4.0, 4.5 };
-        Column expected { 4.0, 2.5, 4.0, 5.0 };
+        BinMapping binfory { 0.0f, 3.0f, 4.0f, 4.5f };
+        Column expected { 4.0f, 2.5f, 4.0f, 5.0f };
         Column actual(C::distribute(in, 4, binfory, 0, true));
         report(actual);
         QCOMPARE(actual, expected);
-        binfory = BinMapping { 0.5, 1.0, 2.0, 5.0 };
-        expected = { 4.0, 2.5, 1.5, 5.5 };
+        binfory = BinMapping { 0.5f, 1.0f, 2.0f, 5.0f };
+        expected = { 4.0f, 2.5f, 1.5f, 5.5f };
         actual = (C::distribute(in, 4, binfory, 0, true));
         report(actual);
         QCOMPARE(actual, expected);