MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / main

Function main

Libraries/QRCode/tests/run-tests.cpp:24–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24int main() {
25 std::clock_t t0, totalNayuki, totalRicMoo;
26
27 int total = 0, passed = 0;
28 for (char version = 1; version <= 40; version++) {
29 if (LOCK_VERSION != 0 && LOCK_VERSION != version) { continue; }
30
31 for (char ecc = 0; ecc < 4; ecc++) {
32 const qrcodegen::QrCode::Ecc *errCorLvl;
33 switch (ecc) {
34 case 0:
35 errCorLvl = &qrcodegen::QrCode::Ecc::LOW;
36 break;
37 case 1:
38 errCorLvl = &qrcodegen::QrCode::Ecc::MEDIUM;
39 break;
40 case 2:
41 errCorLvl = &qrcodegen::QrCode::Ecc::QUARTILE;
42 break;
43 case 3:
44 errCorLvl = &qrcodegen::QrCode::Ecc::HIGH;
45 break;
46 }
47
48 for (char tc = 0; tc < 3; tc++) {
49 char *data;
50 switch(tc) {
51 case 0:
52 data = (char*)"HELLO";
53 break;
54 case 1:
55 data = (char*)"Hello";
56 break;
57 case 2:
58 data = (char*)"1234";
59 break;
60 }
61 t0 = std::clock();
62 const qrcodegen::QrCode nayuki = qrcodegen::QrCode::encodeText(data, version, *errCorLvl);
63 totalNayuki += std::clock() - t0;
64
65 t0 = std::clock();
66 QRCode ricmoo;
67 uint8_t ricmooBytes[qrcode_getBufferSize(version)];
68 qrcode_initText(&ricmoo, ricmooBytes, version, ecc, data);
69 totalRicMoo += std::clock() - t0;
70
71 uint32_t badModules = check(nayuki, &ricmoo);
72 if (badModules) {
73 printf("Failed test case: version=%d, ecc=%d, data=\"%s\", faliured=%d\n", version, ecc, data, badModules);
74 } else {
75 passed++;
76 }
77
78 total++;
79 }
80 }
81 }

Callers

nothing calls this directly

Calls 3

qrcode_getBufferSizeFunction · 0.85
qrcode_initTextFunction · 0.85
checkFunction · 0.70

Tested by

no test coverage detected