本文整理汇总了C++中UUID::getMostSignificantBits方法的典型用法代码示例。如果您正苦于以下问题:C++ UUID::getMostSignificantBits方法的具体用法?C++ UUID::getMostSignificantBits怎么用?C++ UUID::getMostSignificantBits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UUID
的用法示例。
在下文中一共展示了UUID::getMostSignificantBits方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testNameUUIDFromBytes
void UUIDTest::testNameUUIDFromBytes() {
char name[16] = {
(char) 0x6b, (char) 0xa7, (char) 0xb8, (char) 0x11,
(char) 0x9d, (char) 0xad, (char) 0x11, (char) 0xd1,
(char) 0x80, (char) 0xb4, (char) 0x00, (char) 0xc0,
(char) 0x4f, (char) 0xd4, (char) 0x30, (char) 0xc8 };
UUID uuid = UUID::nameUUIDFromBytes(&name[0], 16);
CPPUNIT_ASSERT_EQUAL(2, uuid.variant());
CPPUNIT_ASSERT_EQUAL(3, uuid.version());
CPPUNIT_ASSERT_EQUAL(0xaff565bc2f771745ULL, (unsigned long long) uuid.getLeastSignificantBits());
CPPUNIT_ASSERT_EQUAL(0x14cdb9b4de013faaLL, uuid.getMostSignificantBits());
uuid = UUID::nameUUIDFromBytes(std::vector<char>());
CPPUNIT_ASSERT_EQUAL(2, uuid.variant());
CPPUNIT_ASSERT_EQUAL(3, uuid.version());
CPPUNIT_ASSERT_EQUAL(0xa9800998ecf8427eULL, (unsigned long long) uuid.getLeastSignificantBits());
CPPUNIT_ASSERT_EQUAL(0xd41d8cd98f003204ULL, (unsigned long long) uuid.getMostSignificantBits());
CPPUNIT_ASSERT_THROW_MESSAGE(
"Should throw an NullPointerException exception",
UUID::nameUUIDFromBytes(NULL, 1),
NullPointerException);
}
示例2: equals
bool UUID::equals( const UUID& value ) const {
return this->getMostSignificantBits() == value.getMostSignificantBits() &&
this->getLeastSignificantBits() == value.getLeastSignificantBits();
}
示例3: testFromStringStringException
void UUIDTest::testFromStringStringException() {
UUID uuid = UUID::fromString("0-0-0-0-0");
CPPUNIT_ASSERT_THROW_MESSAGE(
"Should throw an IllegalArgumentException exception",
UUID::fromString("0-0-0-0-"),
IllegalArgumentException);
CPPUNIT_ASSERT_THROW_MESSAGE(
"Should throw an IllegalArgumentException exception",
UUID::fromString("00000"),
IllegalArgumentException);
CPPUNIT_ASSERT_THROW_MESSAGE(
"Should throw an IllegalArgumentException exception",
UUID::fromString("----"),
IllegalArgumentException);
CPPUNIT_ASSERT_THROW_MESSAGE(
"Should throw an IllegalArgumentException exception",
UUID::fromString("-0-0-0-0-0"),
IllegalArgumentException);
CPPUNIT_ASSERT_THROW_MESSAGE(
"Should throw an IllegalArgumentException exception",
UUID::fromString("-0-0-0-0"),
IllegalArgumentException);
CPPUNIT_ASSERT_THROW_MESSAGE(
"Should throw an IllegalArgumentException exception",
UUID::fromString("-0-0-0-"),
IllegalArgumentException);
CPPUNIT_ASSERT_THROW_MESSAGE(
"Should throw an IllegalArgumentException exception",
UUID::fromString("0--0-0-0"),
IllegalArgumentException);
CPPUNIT_ASSERT_THROW_MESSAGE(
"Should throw an IllegalArgumentException exception",
UUID::fromString("0-0-0-0-"),
IllegalArgumentException);
CPPUNIT_ASSERT_THROW_MESSAGE(
"Should throw an IllegalArgumentException exception",
UUID::fromString("-1-0-0-0-0"),
IllegalArgumentException);
uuid = UUID::fromString("123456789-0-0-0-0");
CPPUNIT_ASSERT_EQUAL(0x2345678900000000LL, uuid.getMostSignificantBits());
CPPUNIT_ASSERT_EQUAL(0x0LL, uuid.getLeastSignificantBits());
uuid = UUID::fromString("111123456789-0-0-0-0");
CPPUNIT_ASSERT_EQUAL(0x2345678900000000LL, uuid.getMostSignificantBits());
CPPUNIT_ASSERT_EQUAL(0x0LL, uuid.getLeastSignificantBits());
uuid = UUID::fromString("7fffffffffffffff-0-0-0-0");
CPPUNIT_ASSERT_EQUAL(0xffffffff00000000ULL, (unsigned long long) uuid.getMostSignificantBits());
CPPUNIT_ASSERT_EQUAL(0x0LL, uuid.getLeastSignificantBits());
CPPUNIT_ASSERT_THROW_MESSAGE(
"Should throw an IllegalArgumentException exception",
UUID::fromString("8000000000000000-0-0-0-0"),
NumberFormatException);
uuid = UUID::fromString("7fffffffffffffff-7fffffffffffffff-7fffffffffffffff-0-0");
CPPUNIT_ASSERT_EQUAL(0xffffffffffffffffULL, (unsigned long long) uuid.getMostSignificantBits());
CPPUNIT_ASSERT_EQUAL(0x0LL, uuid.getLeastSignificantBits());
uuid = UUID::fromString("0-0-0-7fffffffffffffff-7fffffffffffffff");
CPPUNIT_ASSERT_EQUAL(0x0LL, uuid.getMostSignificantBits());
CPPUNIT_ASSERT_EQUAL(0xffffffffffffffffULL, (unsigned long long) uuid.getLeastSignificantBits());
CPPUNIT_ASSERT_THROW_MESSAGE(
"Should throw an IllegalArgumentException exception",
UUID::fromString("0-0-0-8000000000000000-0"),
NumberFormatException);
CPPUNIT_ASSERT_THROW_MESSAGE(
"Should throw an IllegalArgumentException exception",
UUID::fromString("0-0-0-0-8000000000000000"),
NumberFormatException);
}