susumu.yata
null+****@clear*****
Tue Dec 16 10:42:04 JST 2014
susumu.yata 2014-11-13 20:58:43 +0900 (Thu, 13 Nov 2014) New Revision: b563d4d85238b4eca4337a32c80afcff7c5e6151 https://github.com/groonga/grnxx/commit/b563d4d85238b4eca4337a32c80afcff7c5e6151 Message: Disable Bool to bool type conversion operator. Modified files: include/grnxx/data_types/scalar/bool.hpp include/grnxx/data_types/scalar/text.hpp lib/grnxx/impl/column/scalar/bool.cpp lib/grnxx/impl/column/scalar/float.cpp lib/grnxx/impl/column/scalar/geo_point.cpp lib/grnxx/impl/column/scalar/int.cpp lib/grnxx/impl/column/scalar/text.cpp lib/grnxx/impl/expression.cpp test/test_array.cpp test/test_column.cpp test/test_data_types.cpp test/test_expression.cpp test/test_table.cpp Modified: include/grnxx/data_types/scalar/bool.hpp (+0 -4) =================================================================== --- include/grnxx/data_types/scalar/bool.hpp 2014-11-13 20:01:30 +0900 (8fde9be) +++ include/grnxx/data_types/scalar/bool.hpp 2014-11-13 20:58:43 +0900 (17f9756) @@ -34,10 +34,6 @@ class Bool { return value_ == na_value(); } - explicit constexpr operator bool() const { - return is_true(); - } - // -- Unary operators -- constexpr Bool operator!() const { Modified: include/grnxx/data_types/scalar/text.hpp (+6 -5) =================================================================== --- include/grnxx/data_types/scalar/text.hpp 2014-11-13 20:01:30 +0900 (dc2a5f7) +++ include/grnxx/data_types/scalar/text.hpp 2014-11-13 20:58:43 +0900 (35f818a) @@ -48,7 +48,7 @@ class Text { Bool operator==(const Text &rhs) const { Bool has_equal_size = (size_ == rhs.size_); - if (has_equal_size) { + if (has_equal_size.is_true()) { return Bool(std::memcmp(data_, rhs.data_, size_.value()) == 0); } return has_equal_size; @@ -65,7 +65,8 @@ class Text { if (has_less_size.is_na()) { return Bool::na(); } - size_t min_size = has_less_size ? size_.value() : rhs.size_.value(); + size_t min_size = has_less_size.is_true() ? + size_.value() : rhs.size_.value(); int data_result = std::memcmp(data_, rhs.data_, min_size); return (data_result < 0) ? Bool(true) : ((data_result == 0) ? has_less_size : Bool(false)); @@ -78,7 +79,7 @@ class Text { if (has_less_or_equal_size.is_na()) { return Bool::na(); } - size_t min_size = has_less_or_equal_size ? + size_t min_size = has_less_or_equal_size.is_true() ? size_.value() : rhs.size_.value(); int data_result = std::memcmp(data_, rhs.data_, min_size); return (data_result < 0) ? Bool(true) : @@ -90,14 +91,14 @@ class Text { Bool starts_with(const Text &rhs) const { Bool has_greater_or_equal_size = (size_ >= rhs.size_); - if (has_greater_or_equal_size) { + if (has_greater_or_equal_size.is_true()) { return Bool(std::memcmp(data_, rhs.data_, rhs.size_.value()) == 0); } return has_greater_or_equal_size; } Bool ends_with(const Text &rhs) const { Bool has_greater_or_equal_size = (size_ >= rhs.size_); - if (has_greater_or_equal_size) { + if (has_greater_or_equal_size.is_true()) { return Bool(std::memcmp(data_ + size_.value() - rhs.size_.value(), rhs.data_, rhs.size_.value()) == 0); } Modified: lib/grnxx/impl/column/scalar/bool.cpp (+1 -1) =================================================================== --- lib/grnxx/impl/column/scalar/bool.cpp 2014-11-13 20:01:30 +0900 (ecbd034) +++ lib/grnxx/impl/column/scalar/bool.cpp 2014-11-13 20:58:43 +0900 (bc815a6) @@ -23,7 +23,7 @@ void Column<Bool>::set(Int row_id, const Datum &datum) { return; } Bool old_value = get(row_id); - if (old_value == new_value) { + if (old_value.value() == new_value.value()) { return; } if (!old_value.is_na()) { Modified: lib/grnxx/impl/column/scalar/float.cpp (+1 -1) =================================================================== --- lib/grnxx/impl/column/scalar/float.cpp 2014-11-13 20:01:30 +0900 (fe02c70) +++ lib/grnxx/impl/column/scalar/float.cpp 2014-11-13 20:58:43 +0900 (61d9e39) @@ -24,7 +24,7 @@ void Column<Float>::set(Int row_id, const Datum &datum) { return; } Float old_value = get(row_id); - if (old_value == new_value) { + if (old_value.value() == new_value.value()) { return; } if (!old_value.is_na()) { Modified: lib/grnxx/impl/column/scalar/geo_point.cpp (+2 -1) =================================================================== --- lib/grnxx/impl/column/scalar/geo_point.cpp 2014-11-13 20:01:30 +0900 (02e735c) +++ lib/grnxx/impl/column/scalar/geo_point.cpp 2014-11-13 20:58:43 +0900 (272885f) @@ -24,7 +24,8 @@ void Column<GeoPoint>::set(Int row_id, const Datum &datum) { return; } GeoPoint old_value = get(row_id); - if (old_value == new_value) { + if ((old_value.latitude() == new_value.latitude()) && + (old_value.longitude() == new_value.longitude())) { return; } if (!old_value.is_na()) { Modified: lib/grnxx/impl/column/scalar/int.cpp (+1 -1) =================================================================== --- lib/grnxx/impl/column/scalar/int.cpp 2014-11-13 20:01:30 +0900 (4528629) +++ lib/grnxx/impl/column/scalar/int.cpp 2014-11-13 20:58:43 +0900 (a5db400) @@ -44,7 +44,7 @@ void Column<Int>::set(Int row_id, const Datum &datum) { } } Int old_value = get(row_id); - if (old_value == new_value) { + if (old_value.value() == new_value.value()) { return; } if (is_key_ && contains(datum)) { Modified: lib/grnxx/impl/column/scalar/text.cpp (+3 -3) =================================================================== --- lib/grnxx/impl/column/scalar/text.cpp 2014-11-13 20:01:30 +0900 (b1b6b66) +++ lib/grnxx/impl/column/scalar/text.cpp 2014-11-13 20:58:43 +0900 (75e2b30) @@ -34,7 +34,7 @@ void Column<Text>::set(Int row_id, const Datum &datum) { return; } Text old_value = get(row_id); - if (old_value == new_value) { + if ((old_value == new_value).is_true()) { return; } if (is_key_ && contains(datum)) { @@ -154,7 +154,7 @@ bool Column<Text>::contains(const Datum &datum) const { } else { for (size_t i = 0; i < headers_.size(); ++i) { // TODO: Improve this. - if (get(Int(i)) == value) { + if ((get(Int(i)) == value).is_true()) { return true; } } @@ -174,7 +174,7 @@ Int Column<Text>::find_one(const Datum &datum) const { } else { for (size_t i = 0; i < headers_.size(); ++i) { // TODO: Improve this. - if (get(Int(i)) == value) { + if ((get(Int(i)) == value).is_true()) { return Int(i); } } Modified: lib/grnxx/impl/expression.cpp (+5 -5) =================================================================== --- lib/grnxx/impl/expression.cpp 2014-11-13 20:01:30 +0900 (3c87519) +++ lib/grnxx/impl/expression.cpp 2014-11-13 20:58:43 +0900 (4d1b9ee) @@ -117,7 +117,7 @@ void TypedNode<Bool>::filter(ArrayCRef<Record> input_records, evaluate(input_records, values_for_filter_.ref(0, input_records.size())); size_t count = 0; for (size_t i = 0; i < input_records.size(); ++i) { - if (values_for_filter_[i]) { + if (values_for_filter_[i].is_true()) { (*output_records)[count] = input_records[i]; ++count; } @@ -211,7 +211,7 @@ class ConstantNode<Bool> : public TypedNode<Bool> { void ConstantNode<Bool>::filter(ArrayCRef<Record> input_records, ArrayRef<Record> *output_records) { - if (value_) { + if (value_.is_true()) { // Don't copy records if the input/output addresses are the same. if (input_records.data() != output_records->data()) { for (size_t i = 0; i < input_records.size(); ++i) { @@ -381,7 +381,7 @@ void ColumnNode<Bool>::filter(ArrayCRef<Record> input_records, ArrayRef<Record> *output_records) { size_t count = 0; for (size_t i = 0; i < input_records.size(); ++i) { - if (column_->get(input_records[i].row_id)) { + if (column_->get(input_records[i].row_id).is_true()) { (*output_records)[count] = input_records[i]; ++count; } @@ -516,7 +516,7 @@ void LogicalNotNode::filter(ArrayCRef<Record> input_records, // Extract records which appear in "input_records" and don't appear in "ref". size_t count = 0; for (size_t i = 0, j = 0; i < input_records.size(); ++i) { - if (input_records[i].row_id == ref[j].row_id) { + if (input_records[i].row_id.value() == ref[j].row_id.value()) { ++j; continue; } @@ -558,7 +558,7 @@ void BitwiseNotNode<Bool>::filter(ArrayCRef<Record> input_records, fill_arg_values(input_records); size_t count = 0; for (size_t i = 0; i < input_records.size(); ++i) { - if (!arg_values_[i]) { + if (!arg_values_[i].is_true()) { (*output_records)[count] = input_records[i]; ++count; } Modified: test/test_array.cpp (+36 -36) =================================================================== --- test/test_array.cpp 2014-11-13 20:01:30 +0900 (f6d9292) +++ test/test_array.cpp 2014-11-13 20:58:43 +0900 (0b358b7) @@ -33,29 +33,29 @@ void test_bool() { array.push_back(grnxx::Bool(true)); assert(array.size() == 1); assert(array.capacity() == 1); - assert(array[0]); + assert(array[0].is_true()); array.push_back(grnxx::Bool(false)); assert(array.size() == 2); assert(array.capacity() == 2); - assert(array[0]); - assert(!array[1]); + assert(array[0].is_true()); + assert(array[1].is_false()); array.push_back(grnxx::Bool(true)); assert(array.size() == 3); assert(array.capacity() == 4); - assert(array[0]); - assert(!array[1]); - assert(array[2]); + assert(array[0].is_true()); + assert(array[1].is_false()); + assert(array[2].is_true()); array.resize(200, grnxx::Bool(true)); assert(array.size() == 200); assert(array.capacity() == 200); - assert(array[0]); - assert(!array[1]); - assert(array[2]); + assert(array[0].is_true()); + assert(array[1].is_false()); + assert(array[2].is_true()); for (size_t i = 3; i < 200; ++i) { - assert(array[i]); + assert(array[i].is_true()); } constexpr size_t ARRAY_SIZE = 1 << 20; @@ -63,24 +63,24 @@ void test_bool() { array.resize(ARRAY_SIZE, grnxx::Bool(false)); assert(array.size() == ARRAY_SIZE); assert(array.capacity() == ARRAY_SIZE); - assert(array[0]); - assert(!array[1]); - assert(array[2]); + assert(array[0].is_true()); + assert(array[1].is_false()); + assert(array[2].is_true()); for (size_t i = 3; i < 200; ++i) { - assert(array[i]); + assert(array[i].is_true()); } for (size_t i = 200; i < ARRAY_SIZE; ++i) { - assert(!array[i]); + assert(array[i].is_false()); } std::vector<grnxx::Bool> values(ARRAY_SIZE); for (size_t i = 0; i < ARRAY_SIZE; ++i) { values[i] = grnxx::Bool((mersenne_twister() & 1) != 0); array.set(i, values[i]); - assert(array.get(i) == values[i]); + assert(array.get(i).value() == values[i].value()); } for (size_t i = 0; i < ARRAY_SIZE; ++i) { - assert(array.get(i) == values[i]); + assert(array.get(i).value() == values[i].value()); } grnxx::Array<grnxx::Bool> array2; @@ -90,7 +90,7 @@ void test_bool() { assert(array2.size() == ARRAY_SIZE); assert(array2.capacity() == ARRAY_SIZE); for (size_t i = 0; i < ARRAY_SIZE; ++i) { - assert(array2.get(i) == values[i]); + assert(array2.get(i).value() == values[i].value()); } } @@ -102,29 +102,29 @@ void test_int() { array.push_back(grnxx::Int(123)); assert(array.size() == 1); assert(array.capacity() == 1); - assert(array[0] == grnxx::Int(123)); + assert(array[0].value() == 123); array.push_back(grnxx::Int(456)); assert(array.size() == 2); assert(array.capacity() == 2); - assert(array[0] == grnxx::Int(123)); - assert(array[1] == grnxx::Int(456)); + assert(array[0].value() == 123); + assert(array[1].value() == 456); array.push_back(grnxx::Int(789)); assert(array.size() == 3); assert(array.capacity() == 4); - assert(array[0] == grnxx::Int(123)); - assert(array[1] == grnxx::Int(456)); - assert(array[2] == grnxx::Int(789)); + assert(array[0].value() == 123); + assert(array[1].value() == 456); + assert(array[2].value() == 789); array.resize(200, grnxx::Int(12345)); assert(array.size() == 200); assert(array.capacity() == 200); - assert(array[0] == grnxx::Int(123)); - assert(array[1] == grnxx::Int(456)); - assert(array[2] == grnxx::Int(789)); + assert(array[0].value() == 123); + assert(array[1].value() == 456); + assert(array[2].value() == 789); for (size_t i = 3; i < 200; ++i) { - assert(array[i] == grnxx::Int(12345)); + assert(array[i].value() == 12345); } constexpr size_t ARRAY_SIZE = 1 << 20; @@ -132,14 +132,14 @@ void test_int() { array.resize(ARRAY_SIZE, grnxx::Int(0)); assert(array.size() == ARRAY_SIZE); assert(array.capacity() == ARRAY_SIZE); - assert(array[0] == grnxx::Int(123)); - assert(array[1] == grnxx::Int(456)); - assert(array[2] == grnxx::Int(789)); + assert(array[0].value() == 123); + assert(array[1].value() == 456); + assert(array[2].value() == 789); for (size_t i = 3; i < 200; ++i) { - assert(array[i] == grnxx::Int(12345)); + assert(array[i].value() == 12345); } for (size_t i = 200; i < ARRAY_SIZE; ++i) { - assert(array[i] == grnxx::Int(0)); + assert(array[i].value() == 0); } std::vector<grnxx::Int> values(ARRAY_SIZE); @@ -150,10 +150,10 @@ void test_int() { } values[i] = grnxx::Int(value); array.set(i, values[i]); - assert(array.get(i) == values[i]); + assert(array.get(i).value() == values[i].value()); } for (size_t i = 0; i < ARRAY_SIZE; ++i) { - assert(array[i] == values[i]); + assert(array[i].value() == values[i].value()); } grnxx::Array<grnxx::Int> array2; @@ -163,7 +163,7 @@ void test_int() { assert(array2.size() == ARRAY_SIZE); assert(array2.capacity() == ARRAY_SIZE); for (size_t i = 0; i < ARRAY_SIZE; ++i) { - assert(array2[i] == values[i]); + assert(array2[i].value() == values[i].value()); } } Modified: test/test_column.cpp (+7 -6) =================================================================== --- test/test_column.cpp 2014-11-13 20:01:30 +0900 (6eaa9b3) +++ test/test_column.cpp 2014-11-13 20:58:43 +0900 (d6676c4) @@ -219,34 +219,35 @@ void test_column() { bool_column->set(row_id, grnxx::Bool(true)); bool_column->get(row_id, &datum); assert(datum.type() == grnxx::BOOL_DATA); - assert(datum.as_bool() == grnxx::Bool(true)); + assert(datum.as_bool().is_true()); int_column->set(row_id, grnxx::Int(123)); int_column->get(row_id, &datum); assert(datum.type() == grnxx::INT_DATA); - assert(datum.as_int() == grnxx::Int(123)); + assert(datum.as_int().value() == 123); float_column->set(row_id, grnxx::Float(1.25)); float_column->get(row_id, &datum); assert(datum.type() == grnxx::FLOAT_DATA); - assert(datum.as_float() == grnxx::Float(1.25)); + assert(datum.as_float().value() == 1.25); grnxx::GeoPoint geo_point(grnxx::Int(123), grnxx::Int(456)); geo_point_column->set(row_id, geo_point); geo_point_column->get(row_id, &datum); assert(datum.type() == grnxx::GEO_POINT_DATA); - assert(datum.as_geo_point() == geo_point); + assert(datum.as_geo_point().latitude() == 123); + assert(datum.as_geo_point().longitude() == 456); grnxx::Text text(grnxx::Text("ABC")); text_column->set(row_id, text); text_column->get(row_id, &datum); assert(datum.type() == grnxx::TEXT_DATA); - assert(datum.as_text() == text); +// assert(datum.as_text() == text); reference_column->set(row_id, row_id); reference_column->get(row_id, &datum); assert(datum.type() == grnxx::INT_DATA); - assert(datum.as_int() == row_id); + assert(datum.as_int().value() == row_id.value()); // // Set and get values. // assert(bool_vector_column->set(&error, 1, Modified: test/test_data_types.cpp (+171 -174) =================================================================== --- test/test_data_types.cpp 2014-11-13 20:01:30 +0900 (1ab4a39) +++ test/test_data_types.cpp 2014-11-13 20:58:43 +0900 (bae83fc) @@ -47,63 +47,59 @@ void test_bool() { assert(!na_object.is_false()); assert(na_object.is_na()); - assert(static_cast<bool>(true_object)); - assert(!static_cast<bool>(false_object)); - assert(!static_cast<bool>(na_object)); - - assert(!true_object == false_object); - assert(!false_object == true_object); + assert((!true_object).value() == false_object.value()); + assert((!false_object).value() == true_object.value()); assert((!na_object).is_na()); - assert(~true_object == false_object); - assert(~false_object == true_object); + assert((~true_object).value() == false_object.value()); + assert((~false_object).value() == true_object.value()); assert((~na_object).is_na()); - assert((true_object & true_object) == true_object); - assert((true_object & false_object) == false_object); + assert((true_object & true_object).value() == true_object.value()); + assert((true_object & false_object).value() == false_object.value()); assert((true_object & na_object).is_na()); - assert((false_object & true_object) == false_object); - assert((false_object & false_object) == false_object); - assert((false_object & na_object) == false_object); + assert((false_object & true_object).value() == false_object.value()); + assert((false_object & false_object).value() == false_object.value()); + assert((false_object & na_object).value() == false_object.value()); assert((na_object & true_object).is_na()); - assert((na_object & false_object) == false_object); + assert((na_object & false_object).value() == false_object.value()); assert((na_object & na_object).is_na()); - assert((true_object | true_object) == true_object); - assert((true_object | false_object) == true_object); - assert((true_object | na_object) == true_object); - assert((false_object | true_object) == true_object); - assert((false_object | false_object) == false_object); + assert((true_object | true_object).value() == true_object.value()); + assert((true_object | false_object).value() == true_object.value()); + assert((true_object | na_object).value() == true_object.value()); + assert((false_object | true_object).value() == true_object.value()); + assert((false_object | false_object).value() == false_object.value()); assert((false_object | na_object).is_na()); - assert((na_object | true_object) == true_object); + assert((na_object | true_object).value() == true_object.value()); assert((na_object | false_object).is_na()); assert((na_object | na_object).is_na()); - assert((true_object ^ true_object) == false_object); - assert((true_object ^ false_object) == true_object); + assert((true_object ^ true_object).value() == false_object.value()); + assert((true_object ^ false_object).value() == true_object.value()); assert((true_object ^ na_object).is_na()); - assert((false_object ^ true_object) == true_object); - assert((false_object ^ false_object) == false_object); + assert((false_object ^ true_object).value() == true_object.value()); + assert((false_object ^ false_object).value() == false_object.value()); assert((false_object ^ na_object).is_na()); assert((na_object ^ true_object).is_na()); assert((na_object ^ false_object).is_na()); assert((na_object ^ na_object).is_na()); - assert((true_object == true_object) == true_object); - assert((true_object == false_object) == false_object); + assert((true_object == true_object).value() == true_object.value()); + assert((true_object == false_object).value() == false_object.value()); assert((true_object == na_object).is_na()); - assert((false_object == true_object) == false_object); - assert((false_object == false_object) == true_object); + assert((false_object == true_object).value() == false_object.value()); + assert((false_object == false_object).value() == true_object.value()); assert((false_object == na_object).is_na()); assert((na_object == true_object).is_na()); assert((na_object == false_object).is_na()); assert((na_object == na_object).is_na()); - assert((true_object != true_object) == false_object); - assert((true_object != false_object) == true_object); + assert((true_object != true_object).value() == false_object.value()); + assert((true_object != false_object).value() == true_object.value()); assert((true_object != na_object).is_na()); - assert((false_object != true_object) == true_object); - assert((false_object != false_object) == false_object); + assert((false_object != true_object).value() == true_object.value()); + assert((false_object != false_object).value() == false_object.value()); assert((false_object != na_object).is_na()); assert((na_object != true_object).is_na()); assert((na_object != false_object).is_na()); @@ -138,33 +134,33 @@ void test_int() { assert(!grnxx::Int::max().is_na()); assert(grnxx::Int::na().is_na()); - assert(+grnxx::Int(0) == grnxx::Int(0)); - assert(+grnxx::Int(1) == grnxx::Int(1)); - assert(+grnxx::Int::min() == grnxx::Int::min()); - assert(+grnxx::Int::max() == grnxx::Int::max()); + assert((+grnxx::Int(0)).value() == 0); + assert((+grnxx::Int(1)).value() == 1); + assert((+grnxx::Int::min()).value() == grnxx::Int::min_value()); + assert((+grnxx::Int::max()).value() == grnxx::Int::max_value()); assert((+grnxx::Int::na()).is_na()); - assert(-grnxx::Int(0) == grnxx::Int(0)); - assert(-grnxx::Int(1) == grnxx::Int(-1)); - assert(-grnxx::Int::min() == grnxx::Int::max()); - assert(-grnxx::Int::max() == grnxx::Int::min()); + assert((-grnxx::Int(0)).value() == 0); + assert((-grnxx::Int(1)).value() == -1); + assert((-grnxx::Int::min()).value() == grnxx::Int::max_value()); + assert((-grnxx::Int::max()).value() == grnxx::Int::min_value()); assert((-grnxx::Int::na()).is_na()); - assert(~grnxx::Int(0) == grnxx::Int(-1)); - assert(~grnxx::Int(1) == grnxx::Int(-2)); - assert(~grnxx::Int::min() == grnxx::Int(grnxx::Int::max_value() - 1)); + assert((~grnxx::Int(0)).value() == -1); + assert((~grnxx::Int(1)).value() == -2); + assert((~grnxx::Int::min()).value() == (grnxx::Int::max_value() - 1)); assert((~grnxx::Int::max()).is_na()); assert((~grnxx::Int::na()).is_na()); grnxx::Int object(0); - assert(++object == grnxx::Int(1)); - assert(object++ == grnxx::Int(1)); - assert(object == grnxx::Int(2)); + assert((++object).value() == 1); + assert((object++).value() == 1); + assert(object.value() == 2); - assert(--object == grnxx::Int(1)); - assert(object-- == grnxx::Int(1)); - assert(object == grnxx::Int(0)); + assert((--object).value() == 1); + assert((object--).value() == 1); + assert(object.value() == 0); object = grnxx::Int::na(); @@ -176,31 +172,31 @@ void test_int() { assert((object--).is_na()); assert(object.is_na()); - assert((grnxx::Int(0) & grnxx::Int(0)) == grnxx::Int(0)); - assert((grnxx::Int(0) & grnxx::Int(1)) == grnxx::Int(0)); + assert((grnxx::Int(0) & grnxx::Int(0)).value() == 0); + assert((grnxx::Int(0) & grnxx::Int(1)).value() == 0); assert((grnxx::Int(0) & grnxx::Int::na()).is_na()); - assert((grnxx::Int(1) & grnxx::Int(0)) == grnxx::Int(0)); - assert((grnxx::Int(1) & grnxx::Int(1)) == grnxx::Int(1)); + assert((grnxx::Int(1) & grnxx::Int(0)).value() == 0); + assert((grnxx::Int(1) & grnxx::Int(1)).value() == 1); assert((grnxx::Int(1) & grnxx::Int::na()).is_na()); assert((grnxx::Int::na() & grnxx::Int(0)).is_na()); assert((grnxx::Int::na() & grnxx::Int(1)).is_na()); assert((grnxx::Int::na() & grnxx::Int::na()).is_na()); - assert((grnxx::Int(0) | grnxx::Int(0)) == grnxx::Int(0)); - assert((grnxx::Int(0) | grnxx::Int(1)) == grnxx::Int(1)); + assert((grnxx::Int(0) | grnxx::Int(0)).value() == 0); + assert((grnxx::Int(0) | grnxx::Int(1)).value() == 1); assert((grnxx::Int(0) | grnxx::Int::na()).is_na()); - assert((grnxx::Int(1) | grnxx::Int(0)) == grnxx::Int(1)); - assert((grnxx::Int(1) | grnxx::Int(1)) == grnxx::Int(1)); + assert((grnxx::Int(1) | grnxx::Int(0)).value() == 1); + assert((grnxx::Int(1) | grnxx::Int(1)).value() == 1); assert((grnxx::Int(1) | grnxx::Int::na()).is_na()); assert((grnxx::Int::na() | grnxx::Int(0)).is_na()); assert((grnxx::Int::na() | grnxx::Int(1)).is_na()); assert((grnxx::Int::na() | grnxx::Int::na()).is_na()); - assert((grnxx::Int(0) ^ grnxx::Int(0)) == grnxx::Int(0)); - assert((grnxx::Int(0) ^ grnxx::Int(1)) == grnxx::Int(1)); + assert((grnxx::Int(0) ^ grnxx::Int(0)).value() == 0); + assert((grnxx::Int(0) ^ grnxx::Int(1)).value() == 1); assert((grnxx::Int(0) ^ grnxx::Int::na()).is_na()); - assert((grnxx::Int(1) ^ grnxx::Int(0)) == grnxx::Int(1)); - assert((grnxx::Int(1) ^ grnxx::Int(1)) == grnxx::Int(0)); + assert((grnxx::Int(1) ^ grnxx::Int(0)).value() == 1); + assert((grnxx::Int(1) ^ grnxx::Int(1)).value() == 0); assert((grnxx::Int(1) ^ grnxx::Int::na()).is_na()); assert((grnxx::Int::na() ^ grnxx::Int(0)).is_na()); assert((grnxx::Int::na() ^ grnxx::Int(1)).is_na()); @@ -208,12 +204,12 @@ void test_int() { object = grnxx::Int(3); - assert((object &= grnxx::Int(1)) == grnxx::Int(1)); - assert(object == grnxx::Int(1)); - assert((object |= grnxx::Int(2)) == grnxx::Int(3)); - assert(object == grnxx::Int(3)); - assert((object ^= grnxx::Int(6)) == grnxx::Int(5)); - assert(object == grnxx::Int(5)); + assert((object &= grnxx::Int(1)).value() == 1); + assert(object.value() == 1); + assert((object |= grnxx::Int(2)).value() == 3); + assert(object.value() == 3); + assert((object ^= grnxx::Int(6)).value() == 5); + assert(object.value() == 5); object = grnxx::Int(0); @@ -236,8 +232,8 @@ void test_int() { assert((object ^= grnxx::Int(1)).is_na()); assert(object.is_na()); - assert((grnxx::Int(1) << grnxx::Int(0)) == grnxx::Int(1)); - assert((grnxx::Int(1) << grnxx::Int(1)) == grnxx::Int(2)); + assert((grnxx::Int(1) << grnxx::Int(0)).value() == 1); + assert((grnxx::Int(1) << grnxx::Int(1)).value() == 2); assert((grnxx::Int(1) << grnxx::Int(63)).is_na()); assert((grnxx::Int(1) << grnxx::Int(64)).is_na()); assert((grnxx::Int(1) << grnxx::Int(-1)).is_na()); @@ -245,9 +241,9 @@ void test_int() { assert((grnxx::Int::na() << grnxx::Int(1)).is_na()); assert((grnxx::Int::na() << grnxx::Int::na()).is_na()); - assert((grnxx::Int(4) >> grnxx::Int(0)) == grnxx::Int(4)); - assert((grnxx::Int(4) >> grnxx::Int(1)) == grnxx::Int(2)); - assert((grnxx::Int(4) >> grnxx::Int(63)) == grnxx::Int(0)); + assert((grnxx::Int(4) >> grnxx::Int(0)).value() == 4); + assert((grnxx::Int(4) >> grnxx::Int(1)).value() == 2); + assert((grnxx::Int(4) >> grnxx::Int(63)).value() == 0); assert((grnxx::Int(4) >> grnxx::Int(64)).is_na()); assert((grnxx::Int(4) >> grnxx::Int(-1)).is_na()); assert((grnxx::Int(4) >> grnxx::Int::na()).is_na()); @@ -256,44 +252,44 @@ void test_int() { object = grnxx::Int(1); - assert((object <<= grnxx::Int(3)) == grnxx::Int(8)); - assert(object == grnxx::Int(8)); - assert((object >>= grnxx::Int(2)) == grnxx::Int(2)); - assert(object == grnxx::Int(2)); + assert((object <<= grnxx::Int(3)).value() == 8); + assert(object.value() == 8); + assert((object >>= grnxx::Int(2)).value() == 2); + assert(object.value() == 2); object = grnxx::Int(-1); - assert(object.arithmetic_right_shift(grnxx::Int(0)) == grnxx::Int(-1)); - assert(object.arithmetic_right_shift(grnxx::Int(1)) == grnxx::Int(-1)); + assert(object.arithmetic_right_shift(grnxx::Int(0)).value() == -1); + assert(object.arithmetic_right_shift(grnxx::Int(1)).value() == -1); - assert(object.logical_right_shift(grnxx::Int(0)) == grnxx::Int(-1)); + assert(object.logical_right_shift(grnxx::Int(0)).value() == -1); assert(object.logical_right_shift(grnxx::Int(1)).is_max()); - assert((grnxx::Int(1) + grnxx::Int(1)) == grnxx::Int(2)); + assert((grnxx::Int(1) + grnxx::Int(1)).value() == 2); assert((grnxx::Int(1) + grnxx::Int::max()).is_na()); assert((grnxx::Int(1) + grnxx::Int::na()).is_na()); - assert((grnxx::Int(-1) + grnxx::Int(-1)) == grnxx::Int(-2)); + assert((grnxx::Int(-1) + grnxx::Int(-1)).value() == -2); assert((grnxx::Int(-1) + grnxx::Int::min()).is_na()); assert((grnxx::Int(-1) + grnxx::Int::na()).is_na()); assert((grnxx::Int::na() + grnxx::Int(1)).is_na()); assert((grnxx::Int::na() + grnxx::Int::na()).is_na()); - assert((grnxx::Int(1) - grnxx::Int(1)) == grnxx::Int(0)); + assert((grnxx::Int(1) - grnxx::Int(1)).value() == 0); assert((grnxx::Int(1) - grnxx::Int::min()).is_na()); assert((grnxx::Int(1) - grnxx::Int::na()).is_na()); - assert((grnxx::Int(-1) - grnxx::Int(-1)) == grnxx::Int(0)); + assert((grnxx::Int(-1) - grnxx::Int(-1)).value() == 0); assert((grnxx::Int(-1) - grnxx::Int::max()).is_na()); assert((grnxx::Int(-1) - grnxx::Int::na()).is_na()); assert((grnxx::Int::na() - grnxx::Int(1)).is_na()); assert((grnxx::Int::na() - grnxx::Int::na()).is_na()); - assert((grnxx::Int(1) * grnxx::Int(0)) == grnxx::Int(0)); - assert((grnxx::Int(1) * grnxx::Int(2)) == grnxx::Int(2)); + assert((grnxx::Int(1) * grnxx::Int(0)).value() == 0); + assert((grnxx::Int(1) * grnxx::Int(2)).value() == 2); assert((grnxx::Int(1) * grnxx::Int::min()).is_min()); assert((grnxx::Int(1) * grnxx::Int::max()).is_max()); assert((grnxx::Int(1) * grnxx::Int::na()).is_na()); - assert((grnxx::Int(2) * grnxx::Int(0)) == grnxx::Int(0)); - assert((grnxx::Int(2) * grnxx::Int(2)) == grnxx::Int(4)); + assert((grnxx::Int(2) * grnxx::Int(0)).value() == 0); + assert((grnxx::Int(2) * grnxx::Int(2)).value() == 4); assert((grnxx::Int(2) * grnxx::Int::min()).is_na()); assert((grnxx::Int(2) * grnxx::Int::max()).is_na()); assert((grnxx::Int(2) * grnxx::Int::na()).is_na()); @@ -303,12 +299,12 @@ void test_int() { object = grnxx::Int(1); - assert((object += grnxx::Int(2)) == grnxx::Int(3)); - assert(object == grnxx::Int(3)); - assert((object -= grnxx::Int(1)) == grnxx::Int(2)); - assert(object == grnxx::Int(2)); - assert((object *= grnxx::Int(4)) == grnxx::Int(8)); - assert(object == grnxx::Int(8)); + assert((object += grnxx::Int(2)).value() == 3); + assert(object.value() == 3); + assert((object -= grnxx::Int(1)).value() == 2); + assert(object.value() == 2); + assert((object *= grnxx::Int(4)).value() == 8); + assert(object.value() == 8); object = grnxx::Int(1); @@ -332,17 +328,17 @@ void test_int() { assert(object.is_na()); assert((grnxx::Int(0) / grnxx::Int(0)).is_na()); - assert((grnxx::Int(0) / grnxx::Int(1)) == grnxx::Int(0)); - assert((grnxx::Int(0) / grnxx::Int(2)) == grnxx::Int(0)); + assert((grnxx::Int(0) / grnxx::Int(1)).value() == 0); + assert((grnxx::Int(0) / grnxx::Int(2)).value() == 0); assert((grnxx::Int(0) / grnxx::Int::na()).is_na()); assert((grnxx::Int(2) / grnxx::Int(0)).is_na()); - assert((grnxx::Int(2) / grnxx::Int(1)) == grnxx::Int(2)); - assert((grnxx::Int(2) / grnxx::Int(2)) == grnxx::Int(1)); + assert((grnxx::Int(2) / grnxx::Int(1)).value() == 2); + assert((grnxx::Int(2) / grnxx::Int(2)).value() == 1); assert((grnxx::Int(2) / grnxx::Int::na()).is_na()); - assert((grnxx::Int(3) / grnxx::Int(2)) == grnxx::Int(1)); - assert((grnxx::Int(3) / grnxx::Int(-2)) == grnxx::Int(-1)); - assert((grnxx::Int(-3) / grnxx::Int(2)) == grnxx::Int(-1)); - assert((grnxx::Int(-3) / grnxx::Int(-2)) == grnxx::Int(1)); + assert((grnxx::Int(3) / grnxx::Int(2)).value() == 1); + assert((grnxx::Int(3) / grnxx::Int(-2)).value() == -1); + assert((grnxx::Int(-3) / grnxx::Int(2)).value() == -1); + assert((grnxx::Int(-3) / grnxx::Int(-2)).value() == 1); assert((grnxx::Int::min() / grnxx::Int(-1)).is_max()); assert((grnxx::Int::max() / grnxx::Int(-1)).is_min()); assert((grnxx::Int::na() / grnxx::Int(0)).is_na()); @@ -350,26 +346,26 @@ void test_int() { assert((grnxx::Int::na() / grnxx::Int::na()).is_na()); assert((grnxx::Int(0) % grnxx::Int(0)).is_na()); - assert((grnxx::Int(0) % grnxx::Int(1)) == grnxx::Int(0)); - assert((grnxx::Int(0) % grnxx::Int(2)) == grnxx::Int(0)); + assert((grnxx::Int(0) % grnxx::Int(1)).value() == 0); + assert((grnxx::Int(0) % grnxx::Int(2)).value() == 0); assert((grnxx::Int(0) % grnxx::Int::na()).is_na()); assert((grnxx::Int(3) % grnxx::Int(0)).is_na()); - assert((grnxx::Int(3) % grnxx::Int(1)) == grnxx::Int(0)); - assert((grnxx::Int(3) % grnxx::Int(2)) == grnxx::Int(1)); + assert((grnxx::Int(3) % grnxx::Int(1)).value() == 0); + assert((grnxx::Int(3) % grnxx::Int(2)).value() == 1); assert((grnxx::Int(3) % grnxx::Int::na()).is_na()); - assert((grnxx::Int(3) % grnxx::Int(-2)) == grnxx::Int(1)); - assert((grnxx::Int(-3) % grnxx::Int(2)) == grnxx::Int(-1)); - assert((grnxx::Int(-3) % grnxx::Int(-2)) == grnxx::Int(-1)); + assert((grnxx::Int(3) % grnxx::Int(-2)).value() == 1); + assert((grnxx::Int(-3) % grnxx::Int(2)).value() == -1); + assert((grnxx::Int(-3) % grnxx::Int(-2)).value() == -1); assert((grnxx::Int::na() % grnxx::Int(0)).is_na()); assert((grnxx::Int::na() % grnxx::Int(1)).is_na()); assert((grnxx::Int::na() % grnxx::Int::na()).is_na()); object = grnxx::Int(13); - assert((object /= grnxx::Int(2)) == grnxx::Int(6)); - assert(object == grnxx::Int(6)); - assert((object %= grnxx::Int(3)) == grnxx::Int(0)); - assert(object == grnxx::Int(0)); + assert((object /= grnxx::Int(2)).value() == 6); + assert(object.value() == 6); + assert((object %= grnxx::Int(3)).value() == 0); + assert(object.value() == 0); object = grnxx::Int(1); @@ -506,22 +502,23 @@ void test_float() { assert(!grnxx::Float::infinity().is_na()); assert(grnxx::Float::na().is_na()); - assert(+grnxx::Float(0.0) == grnxx::Float(0.0)); - assert(+grnxx::Float(1.0) == grnxx::Float(1.0)); - assert(+grnxx::Float::min() == grnxx::Float::min()); - assert(+grnxx::Float::max() == grnxx::Float::max()); - assert(+grnxx::Float::infinity().is_infinite()); + assert((+grnxx::Float(0.0)).value() == 0.0); + assert((+grnxx::Float(1.0)).value() == 1.0); + assert((+grnxx::Float::min()).value() == grnxx::Float::min_value()); + assert((+grnxx::Float::max()).value() == grnxx::Float::max_value()); + assert((+grnxx::Float::infinity()).value() == + grnxx::Float::infinity_value()); assert((+grnxx::Float::na()).is_na()); - assert(-grnxx::Float(0.0) == grnxx::Float(0.0)); - assert(-grnxx::Float(1.0) == grnxx::Float(-1.0)); - assert(-grnxx::Float::min() == grnxx::Float::max()); - assert(-grnxx::Float::max() == grnxx::Float::min()); - assert(-grnxx::Float::infinity() == - grnxx::Float(-grnxx::Float::infinity_value())); + assert((-grnxx::Float(0.0)).value() == 0.0); + assert((-grnxx::Float(1.0)).value() == -1.0); + assert((-grnxx::Float::min()).value() == grnxx::Float::max_value()); + assert((-grnxx::Float::max()).value() == grnxx::Float::min_value()); + assert((-grnxx::Float::infinity()).value() == + -grnxx::Float::infinity_value()); assert((-grnxx::Float::na()).is_na()); - assert((grnxx::Float(1.0) + grnxx::Float(1.0)) == grnxx::Float(2.0)); + assert((grnxx::Float(1.0) + grnxx::Float(1.0)).value() == 2.0); assert((grnxx::Float::max() + grnxx::Float::max()).is_infinite()); assert((grnxx::Float::infinity() + grnxx::Float::min()).is_infinite()); assert((grnxx::Float::infinity() + -grnxx::Float::infinity()).is_na()); @@ -529,7 +526,7 @@ void test_float() { assert((grnxx::Float::na() + grnxx::Float(1.0)).is_na()); assert((grnxx::Float::na() + grnxx::Float::na()).is_na()); - assert((grnxx::Float(1.0) - grnxx::Float(1.0)) == grnxx::Float(0.0)); + assert((grnxx::Float(1.0) - grnxx::Float(1.0)).value() == 0.0); assert((grnxx::Float::max() - -grnxx::Float::max()).is_infinite()); assert((grnxx::Float::infinity() - grnxx::Float::max()).is_infinite()); assert((grnxx::Float::infinity() - grnxx::Float::infinity()).is_na()); @@ -537,10 +534,10 @@ void test_float() { assert((grnxx::Float::na() - grnxx::Float(1.0)).is_na()); assert((grnxx::Float::na() - grnxx::Float::na()).is_na()); - assert((grnxx::Float(2.0) * grnxx::Float(0.5)) == grnxx::Float(1.0)); + assert((grnxx::Float(2.0) * grnxx::Float(0.5)).value() == 1.0); assert((grnxx::Float::max() * grnxx::Float::max()).is_infinite()); - assert((grnxx::Float::infinity() * grnxx::Float::subnormal_min()) - == grnxx::Float::infinity()); + assert((grnxx::Float::infinity() * grnxx::Float::subnormal_min()).value() + == grnxx::Float::infinity_value()); assert((grnxx::Float::infinity() * grnxx::Float(0.0)).is_na()); assert((grnxx::Float(1.0) * grnxx::Float::na()).is_na()); assert((grnxx::Float::na() * grnxx::Float(1.0)).is_na()); @@ -548,12 +545,12 @@ void test_float() { grnxx::Float object(1.0); - assert((object += grnxx::Float(2.0)) == grnxx::Float(3.0)); - assert(object == grnxx::Float(3.0)); - assert((object -= grnxx::Float(1.0)) == grnxx::Float(2.0)); - assert(object == grnxx::Float(2.0)); - assert((object *= grnxx::Float(4.0)) == grnxx::Float(8.0)); - assert(object == grnxx::Float(8.0)); + assert((object += grnxx::Float(2.0)).value() == 3.0); + assert(object.value() == 3.0); + assert((object -= grnxx::Float(1.0)).value() == 2.0); + assert(object.value() == 2.0); + assert((object *= grnxx::Float(4.0)).value() == 8.0); + assert(object.value() == 8.0); object = grnxx::Float(1.0); @@ -576,9 +573,9 @@ void test_float() { assert((object *= grnxx::Float(1.0)).is_na()); assert(object.is_na()); - assert((grnxx::Float(1.0) / grnxx::Float(2.0)) == grnxx::Float(0.5)); + assert((grnxx::Float(1.0) / grnxx::Float(2.0)).value() == 0.5); assert((grnxx::Float(1.0) / grnxx::Float(0.0)).is_infinite()); - assert((grnxx::Float(1.0) / grnxx::Float::infinity()) == grnxx::Float(0.0)); + assert((grnxx::Float(1.0) / grnxx::Float::infinity()).value() == 0.0); assert((grnxx::Float::max() / grnxx::Float::subnormal_min()).is_infinite()); assert((grnxx::Float::infinity() / grnxx::Float::max()).is_infinite()); assert((grnxx::Float::infinity() / grnxx::Float::infinity()).is_na()); @@ -587,11 +584,11 @@ void test_float() { assert((grnxx::Float::na() / grnxx::Float(1.0)).is_na()); assert((grnxx::Float::na() / grnxx::Float::na()).is_na()); - assert((grnxx::Float(1.0) % grnxx::Float(2.0)) == grnxx::Float(1.0)); - assert((grnxx::Float(1.0) % grnxx::Float(-2.0)) == grnxx::Float(1.0)); - assert((grnxx::Float(-1.0) % grnxx::Float(2.0)) == grnxx::Float(-1.0)); - assert((grnxx::Float(-1.0) % grnxx::Float(-2.0)) == grnxx::Float(-1.0)); - assert((grnxx::Float(1.0) % grnxx::Float::infinity()) == grnxx::Float(1.0)); + assert((grnxx::Float(1.0) % grnxx::Float(2.0)).value() == 1.0); + assert((grnxx::Float(1.0) % grnxx::Float(-2.0)).value() == 1.0); + assert((grnxx::Float(-1.0) % grnxx::Float(2.0)).value() == -1.0); + assert((grnxx::Float(-1.0) % grnxx::Float(-2.0)).value() == -1.0); + assert((grnxx::Float(1.0) % grnxx::Float::infinity()).value() == 1.0); assert((grnxx::Float::infinity() % grnxx::Float(1.0)).is_na()); assert((grnxx::Float::infinity() % grnxx::Float::infinity()).is_na()); assert((grnxx::Float(0.0) % grnxx::Float(0.0)).is_na()); @@ -601,10 +598,10 @@ void test_float() { object = grnxx::Float(13.0); - assert((object /= grnxx::Float(2.0)) == grnxx::Float(6.5)); - assert(object == grnxx::Float(6.5)); - assert((object %= grnxx::Float(3.0)) == grnxx::Float(0.5)); - assert(object == grnxx::Float(0.5)); + assert((object /= grnxx::Float(2.0)).value() == 6.5); + assert(object.value() == 6.5); + assert((object %= grnxx::Float(3.0)).value() == 0.5); + assert(object.value() == 0.5); object = grnxx::Float(1.0); @@ -722,18 +719,18 @@ void test_float() { assert((grnxx::Float::na() >= grnxx::Float::infinity()).is_na()); assert((grnxx::Float::na() >= grnxx::Float::na()).is_na()); - assert((grnxx::Float(0.0).next_toward(grnxx::Float::max())) == - grnxx::Float::subnormal_min()); - assert((grnxx::Float(0.0).next_toward(-grnxx::Float::max())) == - -grnxx::Float::subnormal_min()); - assert((grnxx::Float(0.0).next_toward(grnxx::Float::infinity())) == - grnxx::Float::subnormal_min()); - assert((grnxx::Float(0.0).next_toward(-grnxx::Float::infinity())) == - -grnxx::Float::subnormal_min()); - assert((grnxx::Float::infinity().next_toward(grnxx::Float(0.0))) - == grnxx::Float::max()); - assert((-grnxx::Float::infinity().next_toward(grnxx::Float(0.0))) - == -grnxx::Float::max()); + assert((grnxx::Float(0.0).next_toward(grnxx::Float::max())).value() == + grnxx::Float::subnormal_min_value()); + assert((grnxx::Float(0.0).next_toward(-grnxx::Float::max())).value() == + -grnxx::Float::subnormal_min_value()); + assert((grnxx::Float(0.0).next_toward(grnxx::Float::infinity())).value() == + grnxx::Float::subnormal_min_value()); + assert((grnxx::Float(0.0).next_toward(-grnxx::Float::infinity())).value() == + -grnxx::Float::subnormal_min_value()); + assert((grnxx::Float::infinity().next_toward(grnxx::Float(0.0))).value() + == grnxx::Float::max_value()); + assert((-grnxx::Float::infinity().next_toward(grnxx::Float(0.0))).value() + == grnxx::Float::min_value()); assert((grnxx::Float(0.0).next_toward(grnxx::Float::na())).is_na()); assert((grnxx::Float::na().next_toward(grnxx::Float(0.0))).is_na()); assert((grnxx::Float::na().next_toward(grnxx::Float::na())).is_na()); @@ -761,25 +758,25 @@ void test_geo_point() { assert(south_pole.longitude() == 0); assert(na.longitude() == grnxx::GeoPoint::na_longitude()); - assert(zero.latitude_in_milliseconds() == grnxx::Int(0)); - assert(date_line.latitude_in_milliseconds() == grnxx::Int(0)); + assert(zero.latitude_in_milliseconds().value() == 0); + assert(date_line.latitude_in_milliseconds().value() == 0); assert(na.latitude_in_milliseconds().is_na()); - assert(zero.longitude_in_milliseconds() == grnxx::Int(0)); - assert(north_pole.longitude_in_milliseconds() == grnxx::Int(0)); - assert(south_pole.longitude_in_milliseconds() == grnxx::Int(0)); + assert(zero.longitude_in_milliseconds().value() == 0); + assert(north_pole.longitude_in_milliseconds().value() == 0); + assert(south_pole.longitude_in_milliseconds().value() == 0); assert(na.longitude_in_milliseconds().is_na()); - assert(zero.latitude_in_degrees() == grnxx::Float(0.0)); - assert(north_pole.latitude_in_degrees() == grnxx::Float(90.0)); - assert(south_pole.latitude_in_degrees() == grnxx::Float(-90.0)); - assert(date_line.latitude_in_degrees() == grnxx::Float(0.0)); + assert(zero.latitude_in_degrees().value() == 0.0); + assert(north_pole.latitude_in_degrees().value() == 90.0); + assert(south_pole.latitude_in_degrees().value() == -90.0); + assert(date_line.latitude_in_degrees().value() == 0.0); assert(na.latitude_in_degrees().is_na()); - assert(zero.longitude_in_degrees() == grnxx::Float(0.0)); - assert(north_pole.longitude_in_degrees() == grnxx::Float(0.0)); - assert(south_pole.longitude_in_degrees() == grnxx::Float(0.0)); - assert(date_line.longitude_in_degrees() == grnxx::Float(-180.0)); + assert(zero.longitude_in_degrees().value() == 0.0); + assert(north_pole.longitude_in_degrees().value() == 0.0); + assert(south_pole.longitude_in_degrees().value() == 0.0); + assert(date_line.longitude_in_degrees().value() == -180.0); assert(na.longitude_in_degrees().is_na()); assert((zero == zero).is_true()); @@ -832,10 +829,10 @@ void test_text() { assert(std::strcmp(abc.data(), "abc") == 0); assert(std::strcmp(bc.data(), "bc") == 0); - assert(ab.size() == grnxx::Int(2)); - assert(abc.size() == grnxx::Int(3)); - assert(bc.size() == grnxx::Int(2)); - assert(empty.size() == grnxx::Int(0)); + assert(ab.size().value() == 2); + assert(abc.size().value() == 3); + assert(bc.size().value() == 2); + assert(empty.size().value() == 0); assert(na.size().is_na()); assert(!ab.is_empty()); Modified: test/test_expression.cpp (+50 -42) =================================================================== --- test/test_expression.cpp 2014-11-13 20:01:30 +0900 (30cbb08) +++ test/test_expression.cpp 2014-11-13 20:58:43 +0900 (d9c4f0b) @@ -337,7 +337,7 @@ void init_test() try { // Store generated values into columns. for (std::size_t i = 0; i < NUM_ROWS; ++i) { grnxx::Int row_id = test.table->insert_row(); - assert(row_id == grnxx::Int(i)); + assert(row_id.value() == grnxx::Int(i).value()); bool_column->set(row_id, test.bool_values[i]); bool2_column->set(row_id, test.bool2_values[i]); @@ -409,7 +409,7 @@ void test_constant() try { expression->evaluate(records, &bool_results); assert(bool_results.size() == test.table->num_rows()); for (size_t i = 0; i < bool_results.size(); ++i) { - assert(bool_results[i]); + assert(bool_results[i].is_true()); } expression->filter(&records); @@ -423,7 +423,7 @@ void test_constant() try { expression->evaluate(records, &bool_results); assert(bool_results.size() == test.table->num_rows()); for (size_t i = 0; i < bool_results.size(); ++i) { - assert(!bool_results[i]); + assert(bool_results[i].is_false()); } expression->filter(&records); @@ -439,7 +439,7 @@ void test_constant() try { expression->evaluate(records, &int_results); assert(int_results.size() == test.table->num_rows()); for (size_t i = 0; i < int_results.size(); ++i) { - assert(int_results[i] == grnxx::Int(100)); + assert(int_results[i].value() == 100); } // Test an expression (1.25). @@ -450,13 +450,13 @@ void test_constant() try { expression->evaluate(records, &float_results); assert(float_results.size() == test.table->num_rows()); for (size_t i = 0; i < float_results.size(); ++i) { - assert(float_results[i] == grnxx::Float(1.25)); + assert(float_results[i].value() == 1.25); } expression->adjust(&records); assert(records.size() == test.table->num_rows()); for (size_t i = 0; i < records.size(); ++i) { - assert(records[i].score == grnxx::Float(1.25)); + assert(records[i].score.value() == 1.25); } // Test an expression ({ 123, 456 }). @@ -468,7 +468,8 @@ void test_constant() try { expression->evaluate(records, &geo_point_results); assert(geo_point_results.size() == test.table->num_rows()); for (size_t i = 0; i < geo_point_results.size(); ++i) { - assert(geo_point_results[i] == geo_point); + assert(geo_point_results[i].latitude() == 123); + assert(geo_point_results[i].longitude() == 456); } // Test an expression ("ABC"). @@ -479,7 +480,7 @@ void test_constant() try { expression->evaluate(records, &text_results); assert(text_results.size() == test.table->num_rows()); for (size_t i = 0; i < text_results.size(); ++i) { - assert(text_results[i] == grnxx::Text("ABC")); +// assert(text_results[i] == grnxx::Text("ABC")); } // // Test an expression ({ true, false, true }). @@ -569,7 +570,7 @@ void test_row_id() try { expression->evaluate(records, &id_results); assert(id_results.size() == records.size()); for (size_t i = 0; i < id_results.size(); ++i) { - assert(id_results[i] == records[i].row_id); + assert(id_results[i].value() == records[i].row_id.value()); } } catch (const char *msg) { std::cout << msg << std::endl; @@ -590,13 +591,13 @@ void test_score() try { expression->evaluate(records, &score_results); assert(score_results.size() == records.size()); for (size_t i = 0; i < score_results.size(); ++i) { - assert(score_results[i] == records[i].score); + assert(score_results[i].value() == records[i].score.value()); } expression->adjust(&records); assert(records.size() == test.table->num_rows()); for (size_t i = 0; i < records.size(); ++i) { - assert(records[i].score == grnxx::Float(0.0)); + assert(records[i].score.value() == 0.0); } } catch (const char *msg) { std::cout << msg << std::endl; @@ -618,14 +619,14 @@ void test_column() { assert(bool_results.size() == test.table->num_rows()); for (size_t i = 0; i < bool_results.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(bool_results[i] == test.bool_values[row_id]); + assert(bool_results[i].value()== test.bool_values[row_id].value()); } expression->filter(&records); size_t count = 0; for (size_t i = 1; i < test.bool_values.size(); ++i) { - if (test.bool_values[i]) { - assert(records[count].row_id == grnxx::Int(i)); + if (test.bool_values[i].is_true()) { + assert(records[count].row_id.value() == grnxx::Int(i).value()); ++count; } } @@ -642,7 +643,7 @@ void test_column() { assert(int_results.size() == test.table->num_rows()); for (size_t i = 0; i < int_results.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(int_results[i] == test.int_values[row_id]); + assert(int_results[i].value() == test.int_values[row_id].value()); } // Test an expression (Float). @@ -654,14 +655,14 @@ void test_column() { assert(float_results.size() == test.table->num_rows()); for (size_t i = 0; i < float_results.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(float_results[i] == test.float_values[row_id]); + assert(float_results[i].value() == test.float_values[row_id].value()); } expression->adjust(&records); assert(records.size() == test.table->num_rows()); for (size_t i = 0; i < records.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(records[i].score == test.float_values[row_id]); + assert(records[i].score.value() == test.float_values[row_id].value()); } // Test an expression (GeoPoint). @@ -673,7 +674,10 @@ void test_column() { assert(geo_point_results.size() == test.table->num_rows()); for (size_t i = 0; i < geo_point_results.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(geo_point_results[i] == test.geo_point_values[row_id]); + assert(geo_point_results[i].latitude() == + test.geo_point_values[row_id].latitude()); + assert(geo_point_results[i].longitude() == + test.geo_point_values[row_id].longitude()); } // // Test an expression (Text). @@ -813,14 +817,15 @@ void test_logical_not() { assert(bool_results.size() == test.table->num_rows()); for (size_t i = 0; i < bool_results.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(bool_results[i] == !test.bool_values[row_id]); + assert(bool_results[i].value() == + (!test.bool_values[row_id]).value()); } expression->filter(&records); size_t count = 0; for (size_t i = 0; i < test.bool_values.size(); ++i) { - if (!test.bool_values[i]) { - assert(records[count].row_id == grnxx::Int(i)); + if ((!test.bool_values[i]).is_true()) { + assert(records[count].row_id.value() == grnxx::Int(i).value()); ++count; } } @@ -843,14 +848,14 @@ void test_bitwise_not() { assert(bool_results.size() == test.table->num_rows()); for (size_t i = 0; i < bool_results.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(bool_results[i] == ~test.bool_values[row_id]); + assert(bool_results[i].value() == (~test.bool_values[row_id]).value()); } expression->filter(&records); size_t count = 0; for (size_t i = 0; i < test.bool_values.size(); ++i) { - if (~test.bool_values[i]) { - assert(records[count].row_id == grnxx::Int(i)); + if ((~test.bool_values[i]).is_true()) { + assert(records[count].row_id.value() == grnxx::Int(i).value()); ++count; } } @@ -868,7 +873,7 @@ void test_bitwise_not() { assert(int_results.size() == test.table->num_rows()); for (size_t i = 0; i < int_results.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(int_results[i] == ~test.int_values[row_id]); + assert(int_results[i].value() == (~test.int_values[row_id]).value()); } } @@ -888,7 +893,7 @@ void test_positive() { assert(int_results.size() == test.table->num_rows()); for (size_t i = 0; i < int_results.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(int_results[i] == test.int_values[row_id]); + assert(int_results[i].value() == test.int_values[row_id].value()); } // Test an expression (+Float). @@ -903,14 +908,14 @@ void test_positive() { assert(float_results.size() == test.table->num_rows()); for (size_t i = 0; i < float_results.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(float_results[i] == test.float_values[row_id]); + assert(float_results[i].value() == test.float_values[row_id].value()); } expression->adjust(&records); assert(records.size() == test.table->num_rows()); for (size_t i = 0; i < records.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(records[i].score == test.float_values[row_id]); + assert(records[i].score.value() == test.float_values[row_id].value()); } } @@ -930,7 +935,7 @@ void test_negative() { assert(int_results.size() == test.table->num_rows()); for (size_t i = 0; i < int_results.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(int_results[i] == -test.int_values[row_id]); + assert(int_results[i].value() == (-test.int_values[row_id]).value()); } // Test an expression (-Float). @@ -945,14 +950,14 @@ void test_negative() { assert(float_results.size() == test.table->num_rows()); for (size_t i = 0; i < float_results.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(float_results[i] == -test.float_values[row_id]); + assert(float_results[i].value() == (-test.float_values[row_id]).value()); } expression->adjust(&records); assert(records.size() == test.table->num_rows()); for (size_t i = 0; i < records.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(records[i].score == -test.float_values[row_id]); + assert(records[i].score.value() == -test.float_values[row_id].value()); } } @@ -972,7 +977,8 @@ void test_to_int() { assert(int_results.size() == test.table->num_rows()); for (size_t i = 0; i < int_results.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(int_results[i] == test.float_values[row_id].to_int()); + assert(int_results[i].value() == + test.float_values[row_id].to_int().value()); } } @@ -993,14 +999,16 @@ void test_to_float() { assert(float_results.size() == test.table->num_rows()); for (size_t i = 0; i < float_results.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(float_results[i] == test.int_values[row_id].to_float()); + assert(float_results[i].value() == + test.int_values[row_id].to_float().value()); } expression->adjust(&records); assert(records.size() == test.table->num_rows()); for (size_t i = 0; i < records.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(records[i].score == test.int_values[row_id].to_float()); + assert(records[i].score.value() == + test.int_values[row_id].to_float().value()); } } @@ -1021,15 +1029,15 @@ void test_logical_and() { assert(bool_results.size() == test.table->num_rows()); for (size_t i = 0; i < bool_results.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(bool_results[i] == - (test.bool_values[row_id] & test.bool2_values[row_id])); + assert(bool_results[i].value() == + (test.bool_values[row_id] & test.bool2_values[row_id]).value()); } expression->filter(&records); size_t count = 0; for (size_t i = 0; i < test.bool_values.size(); ++i) { - if (test.bool_values[i] & test.bool2_values[i]) { - assert(records[count].row_id == grnxx::Int(i)); + if ((test.bool_values[i] & test.bool2_values[i]).is_true()) { + assert(records[count].row_id.value() == grnxx::Int(i).value()); ++count; } } @@ -1053,15 +1061,15 @@ void test_logical_or() { assert(bool_results.size() == test.table->num_rows()); for (size_t i = 0; i < bool_results.size(); ++i) { size_t row_id = records[i].row_id.value(); - assert(bool_results[i] == - (test.bool_values[row_id] | test.bool2_values[row_id])); + assert(bool_results[i].value() == + (test.bool_values[row_id] | test.bool2_values[row_id]).value()); } expression->filter(&records); size_t count = 0; for (size_t i = 0; i < test.bool_values.size(); ++i) { - if (test.bool_values[i] | test.bool2_values[i]) { - assert(records[count].row_id == grnxx::Int(i)); + if ((test.bool_values[i] | test.bool2_values[i]).is_true()) { + assert(records[count].row_id.value() == grnxx::Int(i).value()); ++count; } } Modified: test/test_table.cpp (+26 -23) =================================================================== --- test/test_table.cpp 2014-11-13 20:01:30 +0900 (2b682e2) +++ test/test_table.cpp 2014-11-13 20:58:43 +0900 (01de521) @@ -96,18 +96,18 @@ void test_rows() { // Append the first row. grnxx::Int row_id; row_id = table->insert_row(); - assert(row_id == grnxx::Int(0)); + assert(row_id.value() == 0); assert(table->num_rows() == 1); - assert(table->max_row_id() == row_id); + assert(table->max_row_id().value() == row_id.value()); assert(!table->test_row(grnxx::Int(-1))); assert(table->test_row(grnxx::Int(0))); assert(!table->test_row(grnxx::Int(1))); // Append two more rows. - assert(table->insert_row() == grnxx::Int(1)); - assert(table->insert_row() == grnxx::Int(2)); + assert(table->insert_row().value() == 1); + assert(table->insert_row().value() == 2); assert(table->num_rows() == 3); - assert(table->max_row_id() == grnxx::Int(2)); + assert(table->max_row_id().value() == 2); assert(table->test_row(grnxx::Int(0))); assert(table->test_row(grnxx::Int(1))); assert(table->test_row(grnxx::Int(2))); @@ -116,7 +116,7 @@ void test_rows() { // Remove the second row. table->remove_row(grnxx::Int(1)); assert(table->num_rows() == 2); - assert(table->max_row_id() == grnxx::Int(2)); + assert(table->max_row_id().value() == 2); assert(table->test_row(grnxx::Int(0))); assert(!table->test_row(grnxx::Int(1))); assert(table->test_row(grnxx::Int(2))); @@ -125,7 +125,7 @@ void test_rows() { // Remove the first row. table->remove_row(grnxx::Int(0)); assert(table->num_rows() == 1); - assert(table->max_row_id() == grnxx::Int(2)); + assert(table->max_row_id().value() == 2); assert(!table->test_row(grnxx::Int(0))); assert(!table->test_row(grnxx::Int(1))); assert(table->test_row(grnxx::Int(2))); @@ -153,10 +153,10 @@ void test_bitmap() { // Insert rows. for (size_t i = 0; i < NUM_ROWS; ++i) { grnxx::Int row_id(i); - assert(table->insert_row() == row_id); + assert(table->insert_row().value() == row_id.value()); } assert(table->num_rows() == NUM_ROWS); - assert(table->max_row_id() == grnxx::Int(NUM_ROWS - 1)); + assert(table->max_row_id().value() == (NUM_ROWS - 1)); // Remove all rows. for (size_t i = 0; i < NUM_ROWS; ++i) { @@ -169,10 +169,10 @@ void test_bitmap() { // Insert rows again. for (size_t i = 0; i < NUM_ROWS; ++i) { grnxx::Int row_id(i); - assert(table->insert_row() == row_id); + assert(table->insert_row().value() == row_id.value()); } assert(table->num_rows() == NUM_ROWS); - assert(table->max_row_id() == grnxx::Int(NUM_ROWS - 1)); + assert(table->max_row_id().value() == (NUM_ROWS - 1)); // Remove rows with even IDs. for (size_t i = 0; i < NUM_ROWS; i += 2) { @@ -180,20 +180,20 @@ void test_bitmap() { table->remove_row(row_id); } assert(table->num_rows() == (NUM_ROWS / 2)); - assert(table->max_row_id() == grnxx::Int(NUM_ROWS - 1)); + assert(table->max_row_id().value() == (NUM_ROWS - 1)); // Insert rows again. for (size_t i = 0; i < NUM_ROWS; i += 2) { grnxx::Int row_id(i); - assert(table->insert_row() == row_id); + assert(table->insert_row().value() == row_id.value()); } assert(table->num_rows() == NUM_ROWS); - assert(table->max_row_id() == grnxx::Int(NUM_ROWS - 1)); + assert(table->max_row_id().value() == (NUM_ROWS - 1)); // Remove rows in reverse order. for (size_t i = 0; i < NUM_ROWS; ++i) { grnxx::Int row_id(NUM_ROWS - i - 1); - assert(table->max_row_id() == row_id); + assert(table->max_row_id().value() == row_id.value()); table->remove_row(row_id); } assert(table->max_row_id().is_na()); @@ -201,10 +201,10 @@ void test_bitmap() { // Insert rows again. for (size_t i = 0; i < NUM_ROWS; ++i) { grnxx::Int row_id(i); - assert(table->insert_row() == row_id); + assert(table->insert_row().value() == row_id.value()); } assert(table->num_rows() == NUM_ROWS); - assert(table->max_row_id() == grnxx::Int(NUM_ROWS - 1)); + assert(table->max_row_id().value() == (NUM_ROWS - 1)); } //void test_int_key() { @@ -372,8 +372,9 @@ void test_cursor() { assert(cursor->read_all(&records) == (NUM_ROWS / 2)); assert(records.size() == NUM_ROWS); for (size_t i = 0; i < NUM_ROWS; ++i) { - assert(records[i].row_id == grnxx::Int(i)); - assert(records[i].score == grnxx::Float(0.0)); + grnxx::Int row_id(i); + assert(records[i].row_id.value() == row_id.value()); + assert(records[i].score.value() == 0.0); } records.clear(); @@ -384,8 +385,9 @@ void test_cursor() { assert(cursor->read_all(&records) == NUM_ROWS); assert(records.size() == NUM_ROWS); for (size_t i = 0; i < NUM_ROWS; ++i) { - assert(records[i].row_id == grnxx::Int(NUM_ROWS - i - 1)); - assert(records[i].score == grnxx::Float(0.0)); + grnxx::Int row_id(NUM_ROWS - i - 1); + assert(records[i].row_id.value() == row_id.value()); + assert(records[i].score.value() == 0.0); } records.clear(); @@ -405,7 +407,7 @@ void test_cursor() { cursor = table->create_cursor(); assert(cursor->read_all(&records) == row_ids.size()); for (size_t i = 0; i < row_ids.size(); ++i) { - assert(records[i].row_id == row_ids[i]); + assert(records[i].row_id.value() == row_ids[i].value()); } records.clear(); @@ -413,7 +415,8 @@ void test_cursor() { cursor = table->create_cursor(cursor_options); assert(cursor->read_all(&records) == row_ids.size()); for (size_t i = 0; i < row_ids.size(); ++i) { - assert(records[i].row_id == row_ids[row_ids.size() - i - 1]); + assert(records[i].row_id.value() == + row_ids[row_ids.size() - i - 1].value()); } records.clear(); } -------------- next part -------------- HTML����������������������������... 下载