@@ -17,10 +17,10 @@ using namespace TAP;
17
17
/* Tests for atomic type stamps */
18
18
19
19
char sample_data_char[] = " Some string" ;
20
- short int sample_data_int16[] = {1 , -2 , -3 , 4 , 555 , 66 };
21
- int sample_data_int32[] = {10 , -20 , - 30 , 40 , 500 , 6 };
22
- long long sample_data_int64[] = {100 , -200 , -300 , 400 , 5 , 6 };
23
- double sample_data_double[] = {1.4142 , 2 , 3.1415 , 4.2e01 , 5 , 6 , 7 };
20
+ short int sample_data_int16[] = {1 , -2 , -3 , 4 , 555 , 66 , 777 , 8 };
21
+ int sample_data_int32[] = {10 , -20 , - 30 , 40 , 500 , 6 , 77 , 888 };
22
+ long long sample_data_int64[] = {100 , -200 , -300 , 400 , 5 , 6 , 7000 , 808 };
23
+ double sample_data_double[] = {1.4142 , 2 , 3.1415 , 4.2e01 , 5 , 6 , 7 };
24
24
25
25
int
26
26
main ()
@@ -30,10 +30,10 @@ main()
30
30
size_t sample_data_int64_size = sizeof (sample_data_int64);
31
31
size_t sample_data_double_size = sizeof (double ) * 7 ;
32
32
33
- TEST_START (21 );
33
+ TEST_START (29 );
34
34
35
35
/* Check that Bin and Str Char stamps works well */
36
- { /* 1, 2, 3 */
36
+ { /* 1..4 */
37
37
Blob blob (sample_data_char, strlen (sample_data_char));
38
38
StampArithm<char > stamp;
39
39
std::vector<char > v = blob.ShiftSingleStampBin (stamp);
@@ -45,10 +45,14 @@ main()
45
45
46
46
char c = stamp.ExtractValue (blob);
47
47
is (c, ' m' , " extract char as value works well" );
48
+
49
+ sized_ptr<char > sp =stamp.ExtractPValue (blob);
50
+ char * p = sp;
51
+ is (*p, ' e' , " Extract poiner to value works well" );
48
52
}
49
53
50
54
/* Check that Bin and Srt Int16 stamps works well */
51
- { /* 4, 5, 6, 7, 8 */
55
+ { /* 5..11 */
52
56
Blob blob ((char *)sample_data_int16, sample_data_int16_size);
53
57
StampArithm<short int > stamp;
54
58
std::vector<char > v = blob.ShiftSingleStampBin (stamp);
@@ -68,10 +72,18 @@ main()
68
72
69
73
signed short int si = stamp_signed.ExtractValue (blob);
70
74
is (si, 555 , " Extract signed int16 as value" );
75
+
76
+ sized_ptr<unsigned short int > usp =stamp_unsigned.ExtractPValue (blob);
77
+ unsigned short int * up = usp;
78
+ is (*up, 66 , " Extract poiner to value for unsigned int16 works well" );
79
+
80
+ sized_ptr<signed short int > ssp =stamp_signed.ExtractPValue (blob);
81
+ signed short int * sp = ssp;
82
+ is (*sp, 777 , " Extract poiner to value for signed int16 works well" );
71
83
}
72
84
73
85
/* Check that Bin and Srt Int32 stamps works well */
74
- { /* 9, 10, 11, 12, 13 */
86
+ { /* 12..18 */
75
87
Blob blob ((char *)sample_data_int32, sample_data_int32_size);
76
88
StampArithm<int > stamp;
77
89
@@ -94,11 +106,18 @@ main()
94
106
signed int si = stamp_signed.ExtractValue (blob);
95
107
is (si, 500 , " Extract signed int32 as value" );
96
108
109
+ sized_ptr<unsigned int > usp =stamp_unsigned.ExtractPValue (blob);
110
+ unsigned int * up = usp;
111
+ is (*up, 6 , " Extract poiner to value for unsigned int32 works well" );
112
+
113
+ sized_ptr<signed int > ssp =stamp_signed.ExtractPValue (blob);
114
+ signed int * sp = ssp;
115
+ is (*sp, 77 , " Extract poiner to value for signed int32 works well" );
97
116
}
98
117
99
118
100
119
/* Check that Bin and Srt Int64 stamps works well */
101
- { /* 14, 15, 16, 17, 18 */
120
+ { /* 19..25 */
102
121
Blob blob ((char *)sample_data_int64, sample_data_int64_size);
103
122
StampArithm<long long > stamp;
104
123
@@ -120,10 +139,19 @@ main()
120
139
121
140
signed long long si = stamp_signed.ExtractValue (blob);
122
141
is (si, 5 , " Extract signed int32 as value" );
142
+
143
+ sized_ptr<unsigned long long > usp =stamp_unsigned.ExtractPValue (blob);
144
+ unsigned long long * up = usp;
145
+ is (*up, 6 , " Extract poiner to value for unsigned int64 works well" );
146
+
147
+ sized_ptr<signed long long > ssp =stamp_signed.ExtractPValue (blob);
148
+ signed long long * sp = ssp;
149
+ is (*sp, 7000 , " Extract poiner to value for signed int64 works well" );
150
+
123
151
}
124
152
125
153
/* Test Double stamp */
126
- { /* 19, 20, 21 */
154
+ { /* 26..29 */
127
155
Blob blob ((char *)sample_data_double, sample_data_double_size);
128
156
StampArithm<double > stamp;
129
157
std::vector<char > v = blob.ShiftSingleStampBin (stamp);
@@ -135,6 +163,11 @@ main()
135
163
136
164
double d = stamp.ExtractValue (blob);
137
165
is (d, 3.1415 , " Extract double as value" );
166
+
167
+ sized_ptr<double > sp =stamp.ExtractPValue (blob);
168
+ double * p = sp;
169
+ is (*p, 42 , " Extract poiner to value for double works well" );
170
+
138
171
}
139
172
TEST_END;
140
173
}
0 commit comments