aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/core/src/firebase/firestore/model/field_value.cc
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2018-05-22 13:21:08 -0700
committerGravatar GitHub <noreply@github.com>2018-05-22 13:21:08 -0700
commitd439bbccd4b90583a89d209d2cc81308aabca8ac (patch)
tree13fb14cc905f667e1470bcc14a3c84dfb6a7a109 /Firestore/core/src/firebase/firestore/model/field_value.cc
parent476be0ba2ba8340296a5b5b05f27f3ded4bd6c72 (diff)
Add a HARD_ASSERT C++ assertion macro (#1304)
* Add HARD_ASSERT * Use HARD_ASSERT * Remove FIREBASE_ASSERT * Remove StringPrintf
Diffstat (limited to 'Firestore/core/src/firebase/firestore/model/field_value.cc')
-rw-r--r--Firestore/core/src/firebase/firestore/model/field_value.cc28
1 files changed, 13 insertions, 15 deletions
diff --git a/Firestore/core/src/firebase/firestore/model/field_value.cc b/Firestore/core/src/firebase/firestore/model/field_value.cc
index 35253c8..4f92c8b 100644
--- a/Firestore/core/src/firebase/firestore/model/field_value.cc
+++ b/Firestore/core/src/firebase/firestore/model/field_value.cc
@@ -23,7 +23,7 @@
#include <vector>
#include "Firestore/core/src/firebase/firestore/util/comparison.h"
-#include "Firestore/core/src/firebase/firestore/util/firebase_assert.h"
+#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
using firebase::firestore::util::Comparator;
@@ -130,8 +130,7 @@ FieldValue& FieldValue::operator=(const FieldValue& value) {
break;
}
default:
- FIREBASE_ASSERT_MESSAGE_WITH_EXPRESSION(
- false, lhs.type(), "Unsupported type %d", value.type());
+ HARD_FAIL("Unsupported type %s", value.type());
}
return *this;
}
@@ -168,10 +167,10 @@ FieldValue& FieldValue::operator=(FieldValue&& value) {
FieldValue FieldValue::Set(const FieldPath& field_path,
FieldValue value) const {
- FIREBASE_ASSERT_MESSAGE(type() == Type::Object,
- "Cannot set field for non-object FieldValue");
- FIREBASE_ASSERT_MESSAGE(!field_path.empty(),
- "Cannot set field for empty path on FieldValue");
+ HARD_ASSERT(type() == Type::Object,
+ "Cannot set field for non-object FieldValue");
+ HARD_ASSERT(!field_path.empty(),
+ "Cannot set field for empty path on FieldValue");
// Set the value by recursively calling on child object.
const std::string& child_name = field_path.first_segment();
const ObjectValue::Map& object_map = object_value_.internal_value;
@@ -195,10 +194,10 @@ FieldValue FieldValue::Set(const FieldPath& field_path,
}
FieldValue FieldValue::Delete(const FieldPath& field_path) const {
- FIREBASE_ASSERT_MESSAGE(type() == Type::Object,
- "Cannot delete field for non-object FieldValue");
- FIREBASE_ASSERT_MESSAGE(!field_path.empty(),
- "Cannot delete field for empty path on FieldValue");
+ HARD_ASSERT(type() == Type::Object,
+ "Cannot delete field for non-object FieldValue");
+ HARD_ASSERT(!field_path.empty(),
+ "Cannot delete field for empty path on FieldValue");
// Delete the value by recursively calling on child object.
const std::string& child_name = field_path.first_segment();
const ObjectValue::Map& object_map = object_value_.internal_value;
@@ -223,8 +222,8 @@ FieldValue FieldValue::Delete(const FieldPath& field_path) const {
}
absl::optional<FieldValue> FieldValue::Get(const FieldPath& field_path) const {
- FIREBASE_ASSERT_MESSAGE(type() == Type::Object,
- "Cannot get field for non-object FieldValue");
+ HARD_ASSERT(type() == Type::Object,
+ "Cannot get field for non-object FieldValue");
const FieldValue* current = this;
for (const auto& path : field_path) {
if (current->type() != Type::Object) {
@@ -435,8 +434,7 @@ bool operator<(const FieldValue& lhs, const FieldValue& rhs) {
case Type::Object:
return lhs.object_value_ < rhs.object_value_;
default:
- FIREBASE_ASSERT_MESSAGE_WITH_EXPRESSION(
- false, lhs.type(), "Unsupported type %d", lhs.type());
+ HARD_FAIL("Unsupported type %s", lhs.type());
// return false if assertion does not abort the program. We will say
// each unsupported type takes only one value thus everything is equal.
return false;