File: has_numeric_value_001.sh

package info (click to toggle)
cod-tools 2.3%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 114,852 kB
  • sloc: perl: 53,336; sh: 23,842; ansic: 6,318; xml: 1,982; yacc: 1,112; makefile: 716; python: 158; sql: 73
file content (63 lines) | stat: -rwxr-xr-x 1,620 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /bin/sh

#BEGIN DEPEND------------------------------------------------------------------
INPUT_MODULES='src/lib/perl5/COD/CIF/Tags/Manage.pm'
#END DEPEND--------------------------------------------------------------------

perl <<'END_SCRIPT'
#------------------------------------------------------------------------------
#$Author: antanas $
#$Date: 2018-05-25 06:05:43 +0300 (Pn, 25 geg. 2018) $ 
#$Revision: 6185 $
#$URL: svn://www.crystallography.net/cod-tools/tags/v2.3/tests/shtests/has_numeric_value_001.sh $
#------------------------------------------------------------------------------
#*
#* Unit test for the COD::CIF::Tags::Manage::has_numeric_value() subroutine.
#* Tests the way the subroutine considers the value of the 'values' hash.
#**

use strict;
use warnings;

use COD::CIF::Tags::Manage;
use COD::Serialise qw( serialiseRef );

##
#data_test
#loop_
#_value
#text
#5
#5(5)
#5.5
#5.5(5)
#'12'
#"12(5)"
#;42
#;
##
my $data_block =
{
  'tags'   => [ '_value' ],
  'loops'  => [ ],
  'inloop' => {},
  'values' => { '_value' => [ 'text', '5', '5(5)', '5.5', '5.5(5)', 12, '12(5)', 42, 30 ] },
  'precisions' => {},
  'types'  => {
    '_value' => [ 'UQSTRING', 'INT', 'INT', 'FLOAT', 'FLOAT', 'SQSTRING', 'DQSTRING', 'TEXTFIELD', undef ]
   },
};

my $data_name = '_value';

for (my $i = 0; $i < @{$data_block->{'values'}{$data_name}}; $i++) {
    my $numeric = COD::CIF::Tags::Manage::has_numeric_value(
                $data_block,
                $data_name,
                $i
    );
    print "Value at position $i is " .
           ($numeric ? 'numeric' : 'not numeric') . ".\n";
}

END_SCRIPT