# HG changeset patch # User Chris Cannam # Date 1480409930 0 # Node ID 7cff8367d9b1be63b046411071968bc60056caa3 # Parent 47ee4706055cd7b28e54f0dd3a9196d24c71b6cd Add test for last change to ColumnOp diff -r 47ee4706055c -r 7cff8367d9b1 base/test/TestColumnOp.h --- a/base/test/TestColumnOp.h Mon Nov 28 18:09:59 2016 +0000 +++ b/base/test/TestColumnOp.h Tue Nov 29 08:58:50 2016 +0000 @@ -23,6 +23,8 @@ #include +//#define REPORT 1 + using namespace std; class TestColumnOp : public QObject @@ -252,7 +254,22 @@ QCOMPARE(actual, expected); } - + void distribute_nonlinear_someshrinking_interpolated() { + // But we *should* interpolate if the mapping involves + // 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 }; + 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 }; + actual = (C::distribute(in, 4, binfory, 0, true)); + report(actual); + QCOMPARE(actual, expected); + } }; #endif