Affix

 view release on metacpan or  search on metacpan

t/021_shakedown.t  view on Meta::CPAN

use v5.40;
use lib '../lib', 'lib';
use blib;
use Test2::Tools::Affix qw[:all];
use Test2::V0 -no_srand => 1;
use Affix qw[:all];
#
my $c_source = <<'END_C';
#include "std.h"
//ext: .c

#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

// Primitives & Globals for Pinning
DLLEXPORT int32_t global_counter = 100;
DLLEXPORT double  global_pi      = 3.14159;
DLLEXPORT char    global_buffer[64] = "Initial";

DLLEXPORT int32_t get_counter() { return global_counter; }
DLLEXPORT void    set_counter(int32_t v) { global_counter = v; }

// Structs & Nested Types
typedef struct {
    int x;
    int y;
} Point;

typedef struct {
    Point top_left;
    Point bottom_right;
    char label[16];
} Rect;

DLLEXPORT int rect_area_val(Rect r) {
    int w = r.bottom_right.x - r.top_left.x;
    int h = r.bottom_right.y - r.top_left.y;
    return w * h;
}

DLLEXPORT void move_rect_ptr(Rect* r, int dx, int dy) {
    if (r) {
        r->top_left.x += dx;
        r->top_left.y += dy;
        r->bottom_right.x += dx;
        r->bottom_right.y += dy;
        snprintf(r->label, 16, "Moved");
    }
}

DLLEXPORT Point return_struct_val(int x, int y) {
    Point p = { x, y };
    return p;
}

// Recursive Linked List
typedef struct Node {
    int value;
    struct Node* next;



( run in 1.038 second using v1.01-cache-2.11-cpan-aadc1410aed )