mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 10:32:29 +00:00
feat(big): add SetOne
This commit is contained in:
parent
8413214ae0
commit
b2cbc02189
3 changed files with 25 additions and 0 deletions
|
|
@ -82,6 +82,11 @@ void Mul(BigBuffer& a, const BigBuffer& b, const BigBuffer& c, BigStack& stack)
|
||||||
stack.UnmakeDistinct(a, aa);
|
stack.UnmakeDistinct(a, aa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetOne(BigBuffer& buffer) {
|
||||||
|
buffer.SetCount(1);
|
||||||
|
buffer[0] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void SetZero(BigBuffer& buffer) {
|
void SetZero(BigBuffer& buffer) {
|
||||||
buffer.Clear();
|
buffer.Clear();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ void Mul(BigBuffer& a, const BigBuffer& b, uint64_t c);
|
||||||
|
|
||||||
void Mul(BigBuffer& a, const BigBuffer& b, const BigBuffer& c, BigStack& stack);
|
void Mul(BigBuffer& a, const BigBuffer& b, const BigBuffer& c, BigStack& stack);
|
||||||
|
|
||||||
|
void SetOne(BigBuffer& buffer);
|
||||||
|
|
||||||
void SetZero(BigBuffer& buffer);
|
void SetZero(BigBuffer& buffer);
|
||||||
|
|
||||||
void ToBinary(TSGrowableArray<uint8_t>& output, const BigBuffer& buffer);
|
void ToBinary(TSGrowableArray<uint8_t>& output, const BigBuffer& buffer);
|
||||||
|
|
|
||||||
18
test/Big.cpp
18
test/Big.cpp
|
|
@ -421,6 +421,24 @@ TEST_CASE("SBigToBinaryBuffer", "[big]") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("SetOne", "[big]") {
|
||||||
|
SECTION("sets buffer to one") {
|
||||||
|
BigData* num;
|
||||||
|
SBigNew(&num);
|
||||||
|
uint64_t data = 0x123456789ABCDEF0;
|
||||||
|
SBigFromBinary(num, reinterpret_cast<uint8_t*>(&data), sizeof(data));
|
||||||
|
|
||||||
|
CHECK(num->Primary().Count() == 2);
|
||||||
|
|
||||||
|
SetOne(num->Primary());
|
||||||
|
|
||||||
|
CHECK(num->Primary().Count() == 1);
|
||||||
|
CHECK(num->Primary()[0] == 1);
|
||||||
|
|
||||||
|
SBigDel(num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("SetZero", "[big]") {
|
TEST_CASE("SetZero", "[big]") {
|
||||||
SECTION("sets buffer to zero") {
|
SECTION("sets buffer to zero") {
|
||||||
BigData* num;
|
BigData* num;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue