mirror of
https://github.com/thunderbrewhq/squall.git
synced 2026-02-04 08:59:07 +00:00
chore(big): rewrite SBig tests to be black box tests
This commit is contained in:
parent
f0b31fb4f3
commit
06094084f3
3 changed files with 790 additions and 161 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "Test.hpp"
|
||||
#include "storm/Big.hpp"
|
||||
#include <vector>
|
||||
|
||||
class BigData;
|
||||
|
||||
|
|
@ -15,4 +16,30 @@ struct BigDataTest {
|
|||
BigData** operator &() { return # }
|
||||
operator BigDataPtr() const { return num; }
|
||||
BigData* operator->() const { return num; }
|
||||
|
||||
uint32_t ToUnsigned() {
|
||||
uint32_t result;
|
||||
SBigToUnsigned(num, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t BitLen() {
|
||||
// Work around a SBigBitLen crash on 0 (original behavior)
|
||||
if (SBigIsZero(num)) return 0;
|
||||
|
||||
uint32_t result = 0;
|
||||
SBigBitLen(num, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> ToBinaryBuffer() {
|
||||
uint32_t size = (this->BitLen() + 32) / 8;
|
||||
std::vector<uint8_t> data(size);
|
||||
|
||||
uint32_t bytes = 0;
|
||||
SBigToBinaryBuffer(this->num, data.data(), size, &bytes);
|
||||
data.resize(bytes);
|
||||
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue