File: get_coeditor_code_001.sh

package info (click to toggle)
cod-tools 3.11.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 159,136 kB
  • sloc: perl: 58,707; sh: 41,323; ansic: 7,268; xml: 1,982; yacc: 1,117; makefile: 731; python: 166
file content (83 lines) | stat: -rwxr-xr-x 3,227 bytes parent folder | download | duplicates (2)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh

#BEGIN DEPEND------------------------------------------------------------------
INPUT_MODULE=src/lib/perl5/COD/CIF/Data/CIF2COD.pm
#END DEPEND--------------------------------------------------------------------

IMPORT_MODULE=$(\
    echo ${INPUT_MODULE} | \
    perl -pe "s|^src/lib/perl5/||; s/[.]pm$//; s|/|::|g;" \
)

perl -M"${IMPORT_MODULE}" \
<<'END_SCRIPT'
#------------------------------------------------------------------------------
#$Author: antanas $
#$Date: 2024-05-26 16:42:43 +0300 (Sun, 26 May 2024) $ 
#$Revision: 10064 $
#$URL: svn+ssh://www.crystallography.net/home/coder/svn-repositories/cod-tools/tags/v3.11.0/tests/shtests/get_coeditor_code_001.sh $
#------------------------------------------------------------------------------
#*
#* Unit test for the COD::CIF::Data::CIF2COD::get_coeditor_code() subroutine.
#* Tests the way the subroutine handles IUCr journals.
#*
#* The current ad-hoc approach is to try to derive the coeditor code from
#* the original filename if the code is not explicitly provided using the
#* '_journal_coeditor_code' data item.
#**

use strict;
use warnings;

# use COD::CIF::Data::CIF2COD;

my $data_block = {
    '_cod_data_source_file' => [
      'ac1543.cif'
    ],
    '_journal_coeditor_code' => [
      'AC1541'
    ],
    '_journal_name_full' => [
      'Acta Crystallographica'
    ]
};
my $options = { 'journal' => 'Acta Crystallographica' } ;

# Proper code in the _journal_coeditor_code data item.
my $value = COD::CIF::Data::CIF2COD::get_coeditor_code($data_block, $options);
print 'case_001: ' . ( defined $value ? "'$value'" : 'undefined' ) . "\n";

# Code with the "sup..." postfix in the _journal_coeditor_code data item.
$data_block->{'_journal_coeditor_code'}[0] = 'AC1542SUP1';
$value = COD::CIF::Data::CIF2COD::get_coeditor_code($data_block, $options);
print 'case_002: ' . ( defined $value ? "'$value'" : 'undefined' ) . "\n";

# Delete the explicit coeditor code.
delete $data_block->{'_journal_coeditor_code'};

# No code in the _journal_coeditor_code data item, file name matches the IUCr
# coeditor code syntax.
$value = COD::CIF::Data::CIF2COD::get_coeditor_code($data_block, $options);
print 'case_003: ' . ( defined $value ? "'$value'" : 'undefined' ) . "\n";

# No code in the _journal_coeditor_code data item, original filename matches
# the IUCr code syntax with the "sup" postfix.
$data_block->{'_cod_data_source_file'}[0] = 'AC1544SUP1';
$value = COD::CIF::Data::CIF2COD::get_coeditor_code($data_block, $options);
print 'case_004: ' . ( defined $value ? "'$value'" : 'undefined' ) . "\n";

# No code in the _journal_coeditor_code data item, original filename does not
# match the IUCr coeditor code syntax.
$data_block->{'_cod_data_source_file'}[0] = '123456';
$value = COD::CIF::Data::CIF2COD::get_coeditor_code($data_block, $options);
print 'case_005: ' . ( defined $value ? "'$value'" : 'undefined' ) . "\n";

# Delete the recorded file name.
delete $data_block->{'_cod_data_source_file'};

# No code in the _journal_coeditor_code data item, no original filename.
$value = COD::CIF::Data::CIF2COD::get_coeditor_code($data_block, $options);
print 'Case_006: ' . ( defined $value ? "'$value'" : 'undefined' ) . "\n";

END_SCRIPT