File: test_vnl-paste.pl

package info (click to toggle)
vnlog 1.42-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 992 kB
  • sloc: perl: 4,682; ansic: 752; python: 462; sh: 116; makefile: 7
file content (125 lines) | stat: -rwxr-xr-x 2,011 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env perl
use strict;
use warnings;

use feature ':5.10';

use FindBin '$RealBin';
use lib $RealBin;

use IPC::Run 'run';
use TestHelpers qw(test_init check);

use Term::ANSIColor;
my $Nfailed = 0;


my $data1 = <<'EOF';
## gathered from sensor model xxx
# humidity temperature
90 25
80 20
81 19
82 18
70 15
EOF

my $data2 = <<'EOF';
# position
10
20
## we moved the sensor
150
160
170
EOF

my $data3 = <<'EOF';
# position
12
18
155
168
190
EOF

test_init('vnl-paste', \$Nfailed,
          '$data1'     => $data1,
          '$data2'     => $data2,
          '$data3'     => $data3);


check( <<'EOF', '$data1', '$data2' );
# humidity temperature position 
90 25	10
80 20	20
81 19	150
82 18	160
70 15	170
EOF

check( <<'EOF', '$data1', '$data2', '$data3' );
# humidity temperature position position 
90 25	10	12
80 20	20	18
81 19	150	155
82 18	160	168
70 15	170	190
EOF

check( <<'EOF', qw(--vnl-suffix1 _a --vnl-prefix2 b_), '$data1', '$data2', '$data3' );
# humidity_a temperature_a b_position position 
90 25	10	12
80 20	20	18
81 19	150	155
82 18	160	168
70 15	170	190
EOF

check( <<'EOF', '--vnl-suffix', ',_a,_b', '$data1', '$data2', '$data3' );
# humidity temperature position_a position_b 
90 25	10	12
80 20	20	18
81 19	150	155
82 18	160	168
70 15	170	190
EOF

check( <<'EOF', '--vnl-suffix', '_a,_b', '$data1', '$data2', '$data3' );
# humidity_a temperature_a position_b position 
90 25	10	12
80 20	20	18
81 19	150	155
82 18	160	168
70 15	170	190
EOF

check( <<'EOF', '--vnl-suffix', '_a,_b,', '$data1', '$data2', '$data3' );
# humidity_a temperature_a position_b position 
90 25	10	12
80 20	20	18
81 19	150	155
82 18	160	168
70 15	170	190
EOF

check( <<'EOF', qw(--vnl-autosuffix), '$data1', '$data2', '$data3' );
# humidity_1 temperature_1 position_2 position_3 
90 25	10	12
80 20	20	18
81 19	150	155
82 18	160	168
70 15	170	190
EOF


if($Nfailed == 0 )
{
    say colored(["green"], "All tests passed!");
    exit 0;
}
else
{
    say colored(["red"], "$Nfailed tests failed!");
    exit 1;
}