[Groonga-commit] groonga/groonga [master] Add a test for binary operation for UInt8 type

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Mar 1 19:11:11 JST 2013


Kouhei Sutou	2013-03-01 19:11:11 +0900 (Fri, 01 Mar 2013)

  New Revision: ca558730a7e8b1176364722d10827fb48ad7df85
  https://github.com/groonga/groonga/commit/ca558730a7e8b1176364722d10827fb48ad7df85

  Log:
    Add a test for binary operation for UInt8 type
    
    Operation: X - Y

  Added files:
    test/command/suite/select/operation/minus/uint8.expected
    test/command/suite/select/operation/minus/uint8.test
  Modified files:
    lib/expr.c

  Modified: lib/expr.c (+22 -0)
===================================================================
--- lib/expr.c    2013-03-01 17:48:59 +0900 (1dc4eee)
+++ lib/expr.c    2013-03-01 19:11:11 +0900 (2f6c539)
@@ -1924,6 +1924,14 @@ grn_proc_call(grn_ctx *ctx, grn_obj *proc, int nargs, grn_obj *caller)
       set(ctx, res, integer_operation(x_, y_));                         \
     }                                                                   \
     break;                                                              \
+  case GRN_DB_UINT8 :                                                   \
+    {                                                                   \
+      uint8_t y_;                                                       \
+      y_ = GRN_UINT8_VALUE(y);                                          \
+      right_expression_check(y_);                                       \
+      set(ctx, res, integer_operation(x_, y_));                         \
+    }                                                                   \
+    break;                                                              \
   case GRN_DB_INT32 :                                                   \
     {                                                                   \
       int y_;                                                           \
@@ -2016,6 +2024,20 @@ grn_proc_call(grn_ctx *ctx, grn_obj *proc, int nargs, grn_obj *caller)
                                             invalid_type_error);        \
     }                                                                   \
     break;                                                              \
+  case GRN_DB_UINT8 :                                                   \
+    {                                                                   \
+      uint8_t x_;                                                       \
+      x_ = GRN_UINT8_VALUE(x);                                          \
+      left_expression_check(x_);                                        \
+      NUMERIC_ARITHMETIC_OPERATION_DISPATCH(GRN_UINT8_SET,              \
+                                            GRN_UINT8_VALUE,            \
+                                            x_, y, res,                 \
+                                            integer8_operation,         \
+                                            float_operation,            \
+                                            right_expression_check,     \
+                                            invalid_type_error);        \
+    }                                                                   \
+    break;                                                              \
   case GRN_DB_INT32 :                                                   \
     {                                                                   \
       int x_;                                                           \

  Added: test/command/suite/select/operation/minus/uint8.expected (+45 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/operation/minus/uint8.expected    2013-03-01 19:11:11 +0900 (afd9632)
@@ -0,0 +1,45 @@
+table_create Values TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Values value1 COLUMN_SCALAR UInt8
+[[0,0.0,0.0],true]
+column_create Values value2 COLUMN_SCALAR UInt8
+[[0,0.0,0.0],true]
+load --table Values
+[
+{"value1": 5, "value2": 1}
+]
+[[0,0.0,0.0],1]
+select Values   --filter true   --scorer '_score = value1 - value2'   --output_columns 'value1, value2, _score'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "value1",
+          "UInt8"
+        ],
+        [
+          "value2",
+          "UInt8"
+        ],
+        [
+          "_score",
+          "Int32"
+        ]
+      ],
+      [
+        5,
+        1,
+        4
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/operation/minus/uint8.test (+13 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/operation/minus/uint8.test    2013-03-01 19:11:11 +0900 (9711811)
@@ -0,0 +1,13 @@
+table_create Values TABLE_NO_KEY
+column_create Values value1 COLUMN_SCALAR UInt8
+column_create Values value2 COLUMN_SCALAR UInt8
+
+load --table Values
+[
+{"value1": 5, "value2": 1}
+]
+
+select Values \
+  --filter true \
+  --scorer '_score = value1 - value2' \
+  --output_columns 'value1, value2, _score'
-------------- next part --------------
HTML����������������������������...
Download 



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