aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/core/test
diff options
context:
space:
mode:
Diffstat (limited to 'Firestore/core/test')
-rw-r--r--Firestore/core/test/firebase/firestore/model/CMakeLists.txt3
-rw-r--r--Firestore/core/test/firebase/firestore/model/field_mask_test.cc56
-rw-r--r--Firestore/core/test/firebase/firestore/model/field_transform_test.cc39
-rw-r--r--Firestore/core/test/firebase/firestore/model/field_value_test.cc3
-rw-r--r--Firestore/core/test/firebase/firestore/model/transform_operations_test.cc51
-rw-r--r--Firestore/core/test/firebase/firestore/remote/datastore_test.cc5
-rw-r--r--Firestore/core/test/firebase/firestore/remote/serializer_test.cc5
-rw-r--r--Firestore/core/test/firebase/firestore/util/autoid_test.cc4
-rw-r--r--Firestore/core/test/firebase/firestore/util/comparison_test.cc5
-rw-r--r--Firestore/core/test/firebase/firestore/util/secure_random_test.cc2
-rw-r--r--Firestore/core/test/firebase/firestore/util/string_printf_test.cc2
-rw-r--r--Firestore/core/test/firebase/firestore/util/string_util_test.cc2
12 files changed, 164 insertions, 13 deletions
diff --git a/Firestore/core/test/firebase/firestore/model/CMakeLists.txt b/Firestore/core/test/firebase/firestore/model/CMakeLists.txt
index 2c2281f..3bac89d 100644
--- a/Firestore/core/test/firebase/firestore/model/CMakeLists.txt
+++ b/Firestore/core/test/firebase/firestore/model/CMakeLists.txt
@@ -18,12 +18,15 @@ cc_test(
database_id_test.cc
document_key_test.cc
document_test.cc
+ field_mask_test.cc
field_path_test.cc
+ field_transform_test.cc
field_value_test.cc
maybe_document_test.cc
no_document_test.cc
resource_path_test.cc
snapshot_version_test.cc
+ transform_operations_test.cc
DEPENDS
firebase_firestore_model
)
diff --git a/Firestore/core/test/firebase/firestore/model/field_mask_test.cc b/Firestore/core/test/firebase/firestore/model/field_mask_test.cc
new file mode 100644
index 0000000..52d5951
--- /dev/null
+++ b/Firestore/core/test/firebase/firestore/model/field_mask_test.cc
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2018 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Firestore/core/src/firebase/firestore/model/field_mask.h"
+
+#include <vector>
+
+#include "Firestore/core/src/firebase/firestore/model/field_path.h"
+#include "gtest/gtest.h"
+
+namespace firebase {
+namespace firestore {
+namespace model {
+
+TEST(FieldMask, ConstructorAndEqual) {
+ FieldMask mask_a{FieldPath::FromServerFormat("foo"),
+ FieldPath::FromServerFormat("bar")};
+ std::vector<FieldPath> field_path_vector{FieldPath::FromServerFormat("foo"),
+ FieldPath::FromServerFormat("bar")};
+ FieldMask mask_b{field_path_vector};
+ FieldMask mask_c{std::vector<FieldPath>{FieldPath::FromServerFormat("foo"),
+ FieldPath::FromServerFormat("bar")}};
+ EXPECT_EQ(mask_a, mask_b);
+ EXPECT_EQ(mask_b, mask_c);
+}
+
+TEST(FieldMask, Getter) {
+ FieldMask mask{FieldPath::FromServerFormat("foo"),
+ FieldPath::FromServerFormat("bar")};
+ EXPECT_EQ(std::vector<FieldPath>({FieldPath::FromServerFormat("foo"),
+ FieldPath::FromServerFormat("bar")}),
+ std::vector<FieldPath>(mask.begin(), mask.end()));
+}
+
+TEST(FieldMask, ToString) {
+ FieldMask mask{FieldPath::FromServerFormat("foo"),
+ FieldPath::FromServerFormat("bar")};
+ EXPECT_EQ("{ foo bar }", mask.ToString());
+}
+
+} // namespace model
+} // namespace firestore
+} // namespace firebase
diff --git a/Firestore/core/test/firebase/firestore/model/field_transform_test.cc b/Firestore/core/test/firebase/firestore/model/field_transform_test.cc
new file mode 100644
index 0000000..b66aeef
--- /dev/null
+++ b/Firestore/core/test/firebase/firestore/model/field_transform_test.cc
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2018 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Firestore/core/src/firebase/firestore/model/field_transform.h"
+#include "Firestore/core/src/firebase/firestore/model/transform_operations.h"
+#include "Firestore/core/test/firebase/firestore/testutil/testutil.h"
+
+#include "absl/memory/memory.h"
+#include "gtest/gtest.h"
+
+namespace firebase {
+namespace firestore {
+namespace model {
+
+TEST(FieldTransform, Getter) {
+ FieldTransform transform(testutil::Field("foo"),
+ absl::make_unique<ServerTimestampTransform>(
+ ServerTimestampTransform::Get()));
+
+ EXPECT_EQ(testutil::Field("foo"), transform.path());
+ EXPECT_EQ(ServerTimestampTransform::Get(), transform.transformation());
+}
+
+} // namespace model
+} // namespace firestore
+} // namespace firebase
diff --git a/Firestore/core/test/firebase/firestore/model/field_value_test.cc b/Firestore/core/test/firebase/firestore/model/field_value_test.cc
index 40be2d5..08db76d 100644
--- a/Firestore/core/test/firebase/firestore/model/field_value_test.cc
+++ b/Firestore/core/test/firebase/firestore/model/field_value_test.cc
@@ -16,8 +16,7 @@
#include "Firestore/core/src/firebase/firestore/model/field_value.h"
-#include <limits.h>
-
+#include <climits>
#include <vector>
#include "gtest/gtest.h"
diff --git a/Firestore/core/test/firebase/firestore/model/transform_operations_test.cc b/Firestore/core/test/firebase/firestore/model/transform_operations_test.cc
new file mode 100644
index 0000000..0ef95db
--- /dev/null
+++ b/Firestore/core/test/firebase/firestore/model/transform_operations_test.cc
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2018 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Firestore/core/src/firebase/firestore/model/transform_operations.h"
+
+#include "gtest/gtest.h"
+
+namespace firebase {
+namespace firestore {
+namespace model {
+
+class DummyOperation : public TransformOperation {
+ public:
+ DummyOperation() {
+ }
+
+ Type type() const override {
+ return Type::Test;
+ }
+
+ bool operator==(const TransformOperation& other) const override {
+ return this == &other;
+ }
+};
+
+TEST(TransformOperations, ServerTimestamp) {
+ ServerTimestampTransform transform = ServerTimestampTransform::Get();
+ EXPECT_EQ(TransformOperation::Type::ServerTimestamp, transform.type());
+
+ ServerTimestampTransform another = ServerTimestampTransform::Get();
+ DummyOperation dummy;
+ EXPECT_EQ(transform, another);
+ EXPECT_NE(transform, dummy);
+}
+
+} // namespace model
+} // namespace firestore
+} // namespace firebase
diff --git a/Firestore/core/test/firebase/firestore/remote/datastore_test.cc b/Firestore/core/test/firebase/firestore/remote/datastore_test.cc
index 42a9a8c..53e95a9 100644
--- a/Firestore/core/test/firebase/firestore/remote/datastore_test.cc
+++ b/Firestore/core/test/firebase/firestore/remote/datastore_test.cc
@@ -16,8 +16,9 @@
#include "Firestore/core/src/firebase/firestore/remote/datastore.h"
-#include <grpc/grpc.h>
-#include <gtest/gtest.h>
+#include "grpc/grpc.h"
+
+#include "gtest/gtest.h"
TEST(Datastore, CanLinkToGrpc) {
// This test doesn't actually do anything interesting as far as actually
diff --git a/Firestore/core/test/firebase/firestore/remote/serializer_test.cc b/Firestore/core/test/firebase/firestore/remote/serializer_test.cc
index 862ac97..947c2fe 100644
--- a/Firestore/core/test/firebase/firestore/remote/serializer_test.cc
+++ b/Firestore/core/test/firebase/firestore/remote/serializer_test.cc
@@ -42,10 +42,12 @@
#include <vector>
#include "Firestore/core/src/firebase/firestore/model/field_value.h"
+#include "Firestore/core/src/firebase/firestore/util/status.h"
#include "gtest/gtest.h"
using firebase::firestore::model::FieldValue;
using firebase::firestore::remote::Serializer;
+using firebase::firestore::util::Status;
TEST(Serializer, CanLinkToNanopb) {
// This test doesn't actually do anything interesting as far as actually using
@@ -67,7 +69,8 @@ class SerializerTest : public ::testing::Test {
FieldValue::Type type) {
EXPECT_EQ(type, model.type());
std::vector<uint8_t> actual_bytes;
- serializer.EncodeFieldValue(model, &actual_bytes);
+ Status status = serializer.EncodeFieldValue(model, &actual_bytes);
+ EXPECT_TRUE(status.ok());
EXPECT_EQ(bytes, actual_bytes);
FieldValue actual_model = serializer.DecodeFieldValue(bytes);
EXPECT_EQ(type, actual_model.type());
diff --git a/Firestore/core/test/firebase/firestore/util/autoid_test.cc b/Firestore/core/test/firebase/firestore/util/autoid_test.cc
index 079b990..808850b 100644
--- a/Firestore/core/test/firebase/firestore/util/autoid_test.cc
+++ b/Firestore/core/test/firebase/firestore/util/autoid_test.cc
@@ -16,9 +16,9 @@
#include "Firestore/core/src/firebase/firestore/util/autoid.h"
-#include <ctype.h>
+#include <cctype>
-#include <gtest/gtest.h>
+#include "gtest/gtest.h"
using firebase::firestore::util::CreateAutoId;
diff --git a/Firestore/core/test/firebase/firestore/util/comparison_test.cc b/Firestore/core/test/firebase/firestore/util/comparison_test.cc
index ccb3011..a03aec8 100644
--- a/Firestore/core/test/firebase/firestore/util/comparison_test.cc
+++ b/Firestore/core/test/firebase/firestore/util/comparison_test.cc
@@ -16,9 +16,8 @@
#include "Firestore/core/src/firebase/firestore/util/comparison.h"
-#include <inttypes.h>
-#include <math.h>
-
+#include <cinttypes>
+#include <cmath>
#include <limits>
#include "Firestore/core/src/firebase/firestore/util/string_printf.h"
diff --git a/Firestore/core/test/firebase/firestore/util/secure_random_test.cc b/Firestore/core/test/firebase/firestore/util/secure_random_test.cc
index 0b7a51b..b0dfdd6 100644
--- a/Firestore/core/test/firebase/firestore/util/secure_random_test.cc
+++ b/Firestore/core/test/firebase/firestore/util/secure_random_test.cc
@@ -16,7 +16,7 @@
#include "Firestore/core/src/firebase/firestore/util/secure_random.h"
-#include <gtest/gtest.h>
+#include "gtest/gtest.h"
using firebase::firestore::util::SecureRandom;
diff --git a/Firestore/core/test/firebase/firestore/util/string_printf_test.cc b/Firestore/core/test/firebase/firestore/util/string_printf_test.cc
index 085be84..14cc9c8 100644
--- a/Firestore/core/test/firebase/firestore/util/string_printf_test.cc
+++ b/Firestore/core/test/firebase/firestore/util/string_printf_test.cc
@@ -16,7 +16,7 @@
#include "Firestore/core/src/firebase/firestore/util/string_printf.h"
-#include <gtest/gtest.h>
+#include "gtest/gtest.h"
namespace firebase {
namespace firestore {
diff --git a/Firestore/core/test/firebase/firestore/util/string_util_test.cc b/Firestore/core/test/firebase/firestore/util/string_util_test.cc
index f94596f..a85c849 100644
--- a/Firestore/core/test/firebase/firestore/util/string_util_test.cc
+++ b/Firestore/core/test/firebase/firestore/util/string_util_test.cc
@@ -16,7 +16,7 @@
#include "Firestore/core/src/firebase/firestore/util/string_util.h"
-#include <gtest/gtest.h>
+#include "gtest/gtest.h"
namespace firebase {
namespace firestore {