susumu.yata
null+****@clear*****
Wed Mar 5 14:55:24 JST 2014
susumu.yata 2014-03-05 14:55:24 +0900 (Wed, 05 Mar 2014) New Revision: 175cb023b8ec796e80ed42fa6aa8b17a3254fa20 https://github.com/groonga/grnxx/commit/175cb023b8ec796e80ed42fa6aa8b17a3254fa20 Message: Add tests for LOGICAL_AND/OR. Redmine: refs #2354. Modified files: test/test_grnxx.cpp Modified: test/test_grnxx.cpp (+36 -0) =================================================================== --- test/test_grnxx.cpp 2014-03-05 14:08:39 +0900 (2738920) +++ test/test_grnxx.cpp 2014-03-05 14:55:24 +0900 (1b8d0a6) @@ -459,6 +459,42 @@ void test_calc() { assert(num_row_ids == 0); } + // ゼロによる除算を回避する. + { + std::unique_ptr<grnxx::Calc> calc( + table->create_calc("!((Integer != 0) && ((100 / Integer) == 0))")); + assert(calc); + std::vector<grnxx::RowID> row_ids(all_row_ids); + grnxx::Int64 num_row_ids = calc->filter(&*row_ids.begin(), row_ids.size()); + assert(num_row_ids != 0); + grnxx::Int64 count = 0; + for (grnxx::Int64 i = 0; i < 1000; ++i) { + grnxx::RowID row_id = grnxx::MIN_ROW_ID + i; + if ((integer_data[i] == 0) || ((100 / integer_data[i]) != 0)) { + assert(row_ids[count] == row_id); + assert(++count <= num_row_ids); + } + } + } + + // ゼロによる除算を回避する. + { + std::unique_ptr<grnxx::Calc> calc( + table->create_calc("((Integer == 0) || ((100 / Integer) != 0)) == TRUE")); + assert(calc); + std::vector<grnxx::RowID> row_ids(all_row_ids); + grnxx::Int64 num_row_ids = calc->filter(&*row_ids.begin(), row_ids.size()); + assert(num_row_ids != 0); + grnxx::Int64 count = 0; + for (grnxx::Int64 i = 0; i < 1000; ++i) { + grnxx::RowID row_id = grnxx::MIN_ROW_ID + i; + if ((integer_data[i] == 0) || ((100 / integer_data[i]) != 0)) { + assert(row_ids[count] == row_id); + assert(++count <= num_row_ids); + } + } + } + // オーバーフローを起こす. { std::unique_ptr<grnxx::Calc> calc( -------------- next part -------------- HTML����������������������������... Download