Serene Runtime 1.0.0
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.

23#define CTX_TESTS(X) \
24 X("engine::make", test_engine_make), X("engine::srn_hash", test_srn_hash)

Function Documentation

◆ test_engine_make()

static void test_engine_make ( )
static

Definition at line 26 of file engine_tests.h.

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

◆ test_srn_hash()

static void test_srn_hash ( )
static

Definition at line 35 of file engine_tests.h.

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