oaknut/tests/basic.cpp
2022-07-09 20:50:38 +01:00

31 lines
582 B
C++

// SPDX-FileCopyrightText: Copyright (c) 2022 merryhime <https://mary.rs>
// SPDX-License-Identifier: MIT
#include <cstdint>
#include <cstdio>
#include <catch2/catch_test_macros.hpp>
#include "oaknut/code_block.hpp"
#include "oaknut/oaknut.hpp"
TEST_CASE("Basic Test")
{
using namespace oaknut;
using namespace oaknut::util;
CodeBlock mem{4096};
CodeGenerator code{mem.ptr()};
mem.unprotect();
code.MOVZ(W0, 42);
code.RET(X30);
mem.protect();
mem.invalidate_all();
int result = ((int (*)())mem.ptr())();
REQUIRE(result == 42);
}