Ticket #627: 0001-Force-float-to-disambiguise-float-double-invocation-.patch

File 0001-Force-float-to-disambiguise-float-double-invocation-.patch, 1.8 KB (added by Dagobert Michelsen, 11 years ago)

Disabiguise invocation of log() in tests/api_weight.cc

  • tests/api_weight.cc

    From faeb07f303894b6be6234c7988fc7b358fd6d02f Mon Sep 17 00:00:00 2001
    From: Dagobert Michelsen <dam@opencsw.org>
    Date: Wed, 25 Sep 2013 15:21:43 +0200
    Subject: [PATCH] Force float to disambiguise float/double invocation of log
    
    ---
     tests/api_weight.cc | 8 ++++----
     1 file changed, 4 insertions(+), 4 deletions(-)
    
    diff --git a/tests/api_weight.cc b/tests/api_weight.cc
    index 792a7ae..b03d8c5 100644
    a b DEFINE_TESTCASE(tfidfweight3, backend) {  
    141141    TEST_EQUAL(mset.size(), 2);
    142142    // doc 2 should have higher weight than 4 as only tf(wdf) will dominate.
    143143    mset_expect_order(mset, 2, 4);
    144     TEST_EQUAL_DOUBLE(mset[0].get_weight(), (8 * log(6 / 2)));
     144    TEST_EQUAL_DOUBLE(mset[0].get_weight(), (8 * log(6.0f / 2)));
    145145
    146146    // Check for "bnn" and for both branches of 'b'.
    147147    enquire.set_query(Xapian::Query("test"));
    DEFINE_TESTCASE(tfidfweight3, backend) {  
    157157    mset = enquire.get_mset(0, 10);
    158158    TEST_EQUAL(mset.size(), 2);
    159159    mset_expect_order(mset, 2, 4);
    160     TEST_EQUAL_DOUBLE(mset[0].get_weight(), (1 + log(8))); // idfn=1 and so wt=tfn=1+log(tf)
     160    TEST_EQUAL_DOUBLE(mset[0].get_weight(), (1 + log(8.0f))); // idfn=1 and so wt=tfn=1+log(tf)
    161161    TEST_EQUAL_DOUBLE(mset[1].get_weight(), 1.0);         // idfn=1 and wt=tfn=1+log(tf)=1+log(1)=1
    162162
    163163    // Check for "snn"
    DEFINE_TESTCASE(tfidfweight3, backend) {  
    194194    mset = enquire.get_mset(0, 10);
    195195    TEST_EQUAL(mset.size(), 2);
    196196    mset_expect_order(mset, 2, 4);
    197     TEST_EQUAL_DOUBLE(mset[0].get_weight(), 8 * log((6 - 2) / 2));
    198     TEST_EQUAL_DOUBLE(mset[1].get_weight(), 1 * log((6 - 2) / 2));
     197    TEST_EQUAL_DOUBLE(mset[0].get_weight(), 8 * log((6.0f - 2) / 2));
     198    TEST_EQUAL_DOUBLE(mset[1].get_weight(), 1 * log((6.0f - 2) / 2));
    199199
    200200    return true;
    201201}