hyprlang/tests/fuzz/main.cpp
Zach DeCook 573cf83c51
core: Fix compilation and tests on 32bit architectures (#20)
* Fix compilation on 32-bit architectures

The 1234L suffix creates a 'long', which is not 64-bit on 32-bit architectures.

* Use stoll instead of stol to fix colors on 32-bit systems

on 32 bit systems, 'long' is 32 bits and 'long long' is 64 bits,
so the 'long long' functions need to be used.

* Fix rgba and rgb values on 32-bit

* Use a cast to Hyprlang::INT
2024-02-12 18:03:04 +00:00

42 lines
1.1 KiB
C++

#include <iostream>
#include <hyprlang.hpp>
#define FUZZ_ITERS 1337
std::string garbage() {
srand(time(nullptr));
int len = rand() % 10000;
std::string chars;
for (int i = 0; i < len; ++i) {
chars += rand() % 254 + 1;
}
return chars;
}
int main(int argc, char** argv, char** envp) {
Hyprlang::CConfig config("./eeeeeeeUnused", {.allowMissingConfig = true});
config.addConfigValue("test", {(Hyprlang::INT)0});
config.parseDynamic("");
config.parseDynamic("", "");
config.parseDynamic("}");
for (size_t i = 0; i < FUZZ_ITERS; ++i) {
config.parseDynamic(garbage().c_str(), garbage().c_str());
config.parseDynamic((garbage() + "=" + garbage()).c_str());
config.parseDynamic(garbage().c_str());
config.parseDynamic((garbage() + " {").c_str());
config.parseDynamic((std::string{"test = "} + garbage()).c_str());
config.parseDynamic((std::string{"$"} + garbage()).c_str());
config.parseDynamic((std::string{"$VAR = "} + garbage()).c_str());
}
config.parseDynamic("}");
std::cout << "Success, no fuzzing errors\n";
return 0;
}