Convert-Binary-C

 view release on metacpan or  search on metacpan

tests/218_member.t  view on Meta::CPAN

################################################################################
#
# Copyright (c) 2002-2024 Marcus Holland-Moritz. All rights reserved.
# This program is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
################################################################################

use Test;
use Convert::Binary::C @ARGV;

$^W = 1;

BEGIN {
  plan tests => 417;
}

my $CCCFG = require './tests/include/config.pl';

%basic = ( char => 1, short => 1, int => 1,
           long => 1, signed => 1, unsigned => 1,
           float => 1, double => 1, void => 1 );

eval {
  $c = Convert::Binary::C->new(
         ShortSize    => 2,
         IntSize      => 4,
         LongSize     => 4,
         LongLongSize => 8,
         EnumSize     => 4,
         PointerSize  => 4,
         Alignment    => 4,
       )->parse( <<ENDC );

typedef struct {
  int    a;
  short  b[3][1];
  long  *c;
  char   d;
  char  *e[2];
} Typedef, *PTypedef, ATypedef[2][3];

struct Struct {
  char  *a[2][2];
  struct {
    int  a;
    enum {
      ENUM
    }    b[2], *c;
  }      b[3], *c[2];
};

union Union {
  struct {
    char  color[2];
    long  size;
    union {
      struct {
        char a;
      }     foo;
      char  taste;
    }     stuff;
  }       apple;
  char    grape[3];
  struct {
    union {
      long  weight;
      short foo;
      enum { FOO } test;
      struct {
        char  a;
        union {
          short b;
          char  c;
        };
      }     compound;
    };
    short price[3];



( run in 1.829 second using v1.01-cache-2.11-cpan-d8267643d1d )