Serene Runtime 1.0.0-dev
C runtime for the Serene programming language
Loading...
Searching...
No Matches
engine_tests.h File Reference
#include "base.h"
Include dependency graph for engine_tests.h:

Go to the source code of this file.

Macros

#define CTX_TESTS(X)

Functions

static void test_engine_make ()
static void test_srn_hash ()

Macro Definition Documentation

◆ CTX_TESTS

#define CTX_TESTS ( X)
Value:
X("engine::make", test_engine_make), X("engine::srn_hash", test_srn_hash)
static void test_srn_hash()
static void test_engine_make()

Definition at line 23 of file engine_tests.h.

Function Documentation

◆ test_engine_make()

void test_engine_make ( )
static

Definition at line 25 of file engine_tests.h.

25 {
26 MAKE_ENGINE(mm, engine);
27 ASSERT_NOT_NULL(engine);
28 ASSERT_NOT_NULL(engine->mm);
29 ASSERT_NOT_NULL(engine->jit);
30}
#define ASSERT_NOT_NULL(x)
Definition base.h:30
#define MAKE_ENGINE(mm, engine)
Definition base.h:32

◆ test_srn_hash()

void test_srn_hash ( )
static

Definition at line 34 of file engine_tests.h.

34 {
35 MAKE_ENGINE(mm, engine);
36
37 engine->seed = 0xA5F17C3DU;
38
39 const char *data = "serene";
40 srn_hash_t h = srn_hash(engine, (void *)data, strlen(data));
41 TEST_CHECK(h == 0x76ea5383);
42
43 typedef struct d {
44 int foo;
45 int bar;
46 } d;
47
48 const d test1 = {.foo = 10, .bar = 22};
49 const d test2 = {.foo = 10, .bar = 12};
50
51 srn_hash_t h1 = srn_hash(engine, (void *)&test1, sizeof(test1));
52 srn_hash_t h2 = srn_hash(engine, (void *)&test2, sizeof(test2));
53 TEST_CHECK(h1 == 0xf240658b);
54 TEST_CHECK(h2 == 0x177e0a92);
55}
#define TEST_CHECK(cond)
Definition acutest.h:95
SRN_HASH_TYPE srn_hash_t
Definition context.h:44
srn_hash_t srn_hash(const srn_engine_t *engine, const void *data, size_t len)
Definition engine.c:166
Here is the call graph for this function: