diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /ipc/chromium/gtest/name_unittest.cc | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ipc/chromium/gtest/name_unittest.cc')
-rw-r--r-- | ipc/chromium/gtest/name_unittest.cc | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/ipc/chromium/gtest/name_unittest.cc b/ipc/chromium/gtest/name_unittest.cc new file mode 100644 index 0000000000..ecb34100d8 --- /dev/null +++ b/ipc/chromium/gtest/name_unittest.cc @@ -0,0 +1,78 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "mojo/core/ports/name.h" + +#include "testing/gtest/include/gtest/gtest.h" + +namespace mojo { +namespace core { +namespace ports { +namespace test { + +TEST(NameTest, Defaults) +{ + PortName default_port_name; + EXPECT_EQ(kInvalidPortName, default_port_name); + + NodeName default_node_name; + EXPECT_EQ(kInvalidNodeName, default_node_name); +} + +TEST(NameTest, PortNameChecks) +{ + PortName port_name_a(50, 100); + PortName port_name_b(50, 100); + PortName port_name_c(100, 50); + + EXPECT_EQ(port_name_a, port_name_b); + EXPECT_NE(port_name_a, port_name_c); + EXPECT_NE(port_name_b, port_name_c); + + EXPECT_LT(port_name_a, port_name_c); + EXPECT_LT(port_name_b, port_name_c); + EXPECT_FALSE(port_name_a < port_name_b); + EXPECT_FALSE(port_name_b < port_name_a); + + std::hash<PortName> port_hash_fn; + + size_t hash_a = port_hash_fn(port_name_a); + size_t hash_b = port_hash_fn(port_name_b); + size_t hash_c = port_hash_fn(port_name_c); + + EXPECT_EQ(hash_a, hash_b); + EXPECT_NE(hash_a, hash_c); + EXPECT_NE(hash_b, hash_c); +} + +TEST(NameTest, NodeNameChecks) +{ + NodeName node_name_a(50, 100); + NodeName node_name_b(50, 100); + NodeName node_name_c(100, 50); + + EXPECT_EQ(node_name_a, node_name_b); + EXPECT_NE(node_name_a, node_name_c); + EXPECT_NE(node_name_b, node_name_c); + + EXPECT_LT(node_name_a, node_name_c); + EXPECT_LT(node_name_b, node_name_c); + EXPECT_FALSE(node_name_a < node_name_b); + EXPECT_FALSE(node_name_b < node_name_a); + + std::hash<NodeName> node_hash_fn; + + size_t hash_a = node_hash_fn(node_name_a); + size_t hash_b = node_hash_fn(node_name_b); + size_t hash_c = node_hash_fn(node_name_c); + + EXPECT_EQ(hash_a, hash_b); + EXPECT_NE(hash_a, hash_c); + EXPECT_NE(hash_b, hash_c); +} + +} // namespace test +} // namespace ports +} // namespace core +} // namespace mojo |