Set byte as default encoding method for small amounts of data
This commit is contained in:
parent
e011a5d7ed
commit
52f4bee621
@ -3,12 +3,17 @@
|
||||
#include "QRCode.hpp"
|
||||
#include "Encoder.hpp"
|
||||
#include "DataBlocks.hpp"
|
||||
#include "Tables.hpp"
|
||||
|
||||
QRCode::QRCode(string& input_, CorrectionLevel corr_lvl_, QRCodeMethod method_, char version_, unsigned char mask_n) :
|
||||
input{ input_ }, corr_lvl{ corr_lvl_ }, method{ method_ }, version{ version_ }, matrix(0)
|
||||
{
|
||||
if (method == QRCodeMethod::Dynamic)
|
||||
method = Method::determite_method(input);
|
||||
if (method == QRCodeMethod::Dynamic) {
|
||||
if (input.size() > Tables::max_capability.at(corr_lvl).at(0) / 8)
|
||||
method = Method::determite_method(input);
|
||||
else
|
||||
method = QRCodeMethod::Byte;
|
||||
}
|
||||
|
||||
Encoder encoder(input, corr_lvl, method, version);
|
||||
const BitArray& encoded_data = encoder.encode();
|
||||
|
@ -11,12 +11,13 @@ public:
|
||||
QRCodeConstructorMock(Parameters ...params) {};
|
||||
};
|
||||
TEST(QRCodeTests, ConstructsClass) {
|
||||
string inp("TEST");
|
||||
string inp("TESTTESTTESTTESTTESTTEST");
|
||||
QRCode qr(inp);
|
||||
|
||||
EXPECT_EQ(qr.input, "TEST");
|
||||
EXPECT_EQ(qr.input, "TESTTESTTESTTESTTESTTEST");
|
||||
EXPECT_EQ(qr.corr_lvl, CorrectionLevel::M);
|
||||
EXPECT_EQ(qr.method, QRCodeMethod::Alphabetic);
|
||||
EXPECT_EQ(qr.version, 1);
|
||||
}
|
||||
|
||||
TEST(QRCodeTests, CreatesQRCode) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user