Exemple #1
0
TEST(TStr, IsUInt64) {
	const TStr NormalCase = "22";
	const TStr NegativeCase = "-22";
	const TStr Zero = "0";
	const TStr MxVal = "18446744073709551615";
	const TStr Overflow = "18446744073709551616";

	uint64 Val;

	// normal
	ASSERT_TRUE(NormalCase.IsUInt64(Val));
	ASSERT_EQ(Val, 22);

	ASSERT_FALSE(NegativeCase.IsUInt64(Val));

	ASSERT_TRUE(Zero.IsUInt64(Val));
	ASSERT_EQ(Val, 0);

	ASSERT_TRUE(MxVal.IsUInt64(Val));
	ASSERT_EQ(Val, 18446744073709551615ul);

	ASSERT_FALSE(Overflow.IsUInt64(Val));

	// bounds
	ASSERT_TRUE(NormalCase.IsUInt64(true, 22, 22, Val));
	ASSERT_EQ(Val, 22);

	ASSERT_FALSE(NormalCase.IsUInt64(true, 20, 21, Val));
	ASSERT_ANY_THROW(NormalCase.IsUInt64(true, 22, 21, Val));
}
Exemple #2
0
uint64 TSAppSrvFun::GetFldUInt64(const TStrKdV& FldNmValPrV, const TStr& FldNm, const uint64& DefVal) {
	TStr IntStr = GetFldVal(FldNmValPrV, FldNm, TUInt64(DefVal).GetStr());
	EAssertR(IntStr.IsUInt64(), "Parameter '" + FldNm + "' not a number");
	return IntStr.GetUInt64();
}