[Groonga-commit] groonga/grnxx at 44f9df4 [master] Add tests for score adjustment by Expression. (#37)

Back to archive index

susumu.yata null+****@clear*****
Mon Aug 18 17:25:41 JST 2014


susumu.yata	2014-08-18 17:25:41 +0900 (Mon, 18 Aug 2014)

  New Revision: 44f9df466e78069b251553db61aa47ffe1218658
  https://github.com/groonga/grnxx/commit/44f9df466e78069b251553db61aa47ffe1218658

  Message:
    Add tests for score adjustment by Expression. (#37)

  Modified files:
    test/test_expression.cpp

  Modified: test/test_expression.cpp (+54 -0)
===================================================================
--- test/test_expression.cpp    2014-08-18 17:22:37 +0900 (023e622)
+++ test/test_expression.cpp    2014-08-18 17:25:41 +0900 (6acbd0c)
@@ -488,6 +488,13 @@ void test_positive() {
     grnxx::Int row_id = records.get_row_id(i);
     assert(float_results[i] == test.float_values[row_id]);
   }
+
+  assert(expression->adjust(&error, &records));
+  assert(records.size() == test.table->num_rows());
+  for (grnxx::Int i = 0; i < records.size(); ++i) {
+    grnxx::Int row_id = records.get_row_id(i);
+    assert(records.get_score(i) == test.float_values[row_id]);
+  }
 }
 
 void test_negative() {
@@ -534,6 +541,13 @@ void test_negative() {
     grnxx::Int row_id = records.get_row_id(i);
     assert(float_results[i] == -test.float_values[row_id]);
   }
+
+  assert(expression->adjust(&error, &records));
+  assert(records.size() == test.table->num_rows());
+  for (grnxx::Int i = 0; i < records.size(); ++i) {
+    grnxx::Int row_id = records.get_row_id(i);
+    assert(records.get_score(i) == -test.float_values[row_id]);
+  }
 }
 
 void test_to_int() {
@@ -590,6 +604,14 @@ void test_to_float() {
     assert(float_results[i] ==
            static_cast<grnxx::Float>(test.int_values[row_id]));
   }
+
+  assert(expression->adjust(&error, &records));
+  assert(records.size() == test.table->num_rows());
+  for (grnxx::Int i = 0; i < records.size(); ++i) {
+    grnxx::Int row_id = records.get_row_id(i);
+    assert(records.get_score(i) ==
+           static_cast<grnxx::Float>(test.int_values[row_id]));
+  }
 }
 
 void test_logical_and() {
@@ -1628,6 +1650,14 @@ void test_plus() {
     assert(float_results[i] ==
            (test.float_values[row_id] + test.float2_values[row_id]));
   }
+
+  assert(expression->adjust(&error, &records));
+  assert(records.size() == test.table->num_rows());
+  for (grnxx::Int i = 0; i < records.size(); ++i) {
+    grnxx::Int row_id = records.get_row_id(i);
+    assert(records.get_score(i) ==
+           (test.float_values[row_id] + test.float2_values[row_id]));
+  }
 }
 
 void test_minus() {
@@ -1678,6 +1708,14 @@ void test_minus() {
     assert(float_results[i] ==
            (test.float_values[row_id] - test.float2_values[row_id]));
   }
+
+  assert(expression->adjust(&error, &records));
+  assert(records.size() == test.table->num_rows());
+  for (grnxx::Int i = 0; i < records.size(); ++i) {
+    grnxx::Int row_id = records.get_row_id(i);
+    assert(records.get_score(i) ==
+           (test.float_values[row_id] - test.float2_values[row_id]));
+  }
 }
 
 void test_multiplication() {
@@ -1728,6 +1766,14 @@ void test_multiplication() {
     assert(float_results[i] ==
            (test.float_values[row_id] * test.float2_values[row_id]));
   }
+
+  assert(expression->adjust(&error, &records));
+  assert(records.size() == test.table->num_rows());
+  for (grnxx::Int i = 0; i < records.size(); ++i) {
+    grnxx::Int row_id = records.get_row_id(i);
+    assert(records.get_score(i) ==
+           (test.float_values[row_id] * test.float2_values[row_id]));
+  }
 }
 
 void test_division() {
@@ -1796,6 +1842,14 @@ void test_division() {
     assert(float_results[i] ==
            (test.float_values[row_id] / test.float2_values[row_id]));
   }
+
+  assert(expression->adjust(&error, &records));
+  assert(records.size() == test.table->num_rows());
+  for (grnxx::Int i = 0; i < records.size(); ++i) {
+    grnxx::Int row_id = records.get_row_id(i);
+    assert(records.get_score(i) ==
+           (test.float_values[row_id] / test.float2_values[row_id]));
+  }
 }
 
 void test_modulus() {
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index