Convert-Binary-C
view release on metacpan or search on metacpan
tests/206_parse.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 => 116 }
my $CCCFG = require './tests/include/config.pl';
#===================================================================
# create object (1 tests)
#===================================================================
eval { $p = Convert::Binary::C->new };
ok($@,'',"failed to create Convert::Binary::C object");
#===================================================================
# try to parse empty file / empty code (2 tests)
#===================================================================
eval { $p->parse_file( 'tests/include/files/empty.h' ) };
ok($@,'',"failed to parse empty C-file");
eval { $p->parse( '' ) };
ok($@,'',"failed to parse empty C-code");
#===================================================================
# check that parse/parse_file return object references (4 tests)
#===================================================================
$p = eval { Convert::Binary::C->new->parse_file( 'tests/include/files/empty.h' ) };
ok($@,'',"failed to create Convert::Binary::C object");
ok(ref $p, 'Convert::Binary::C',
"object reference not blessed to Convert::Binary::C");
$p = eval { Convert::Binary::C->new->parse( '' ) };
ok($@,'',"failed to create Convert::Binary::C object");
ok(ref $p, 'Convert::Binary::C',
"object reference not blessed to Convert::Binary::C");
#===================================================================
# create object (1 tests)
#===================================================================
eval {
$p = Convert::Binary::C->new(
%$CCCFG,
EnumSize => 0,
);
};
ok($@,'',"failed to create Convert::Binary::C object");
#===================================================================
# try to parse a file with lots of includes (1 test)
#===================================================================
eval {
$p->parse_file( 'tests/include/include.c' );
};
ok($@,'',"failed to parse C-file");
#===================================================================
# check if context is correctly evaluated (10 tests)
# also do a quick check if the right stuff was parsed (12 tests)
#===================================================================
@enums = $p->enum;
@compounds = $p->compound;
@structs = $p->struct;
@unions = $p->union;
@typedefs = $p->typedef;
( run in 0.817 second using v1.01-cache-2.11-cpan-39bf76dae61 )