excel_to_code 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,31 @@
1
1
  #include "excel_to_c_runtime.c"
2
2
 
3
3
  int test_functions() {
4
+ // Assertions
5
+ assert_equal(NA, NA, "NA == NA");
6
+ assert_equal(ZERO, EXCEL_NUMBER(0), "ZERO == ZERO");
7
+ assert_equal(EXCEL_NUMBER(-0.0), EXCEL_NUMBER(0.0), "Negative ZERO == ZERO");
8
+ assert_equal(EXCEL_NUMBER(0.0), EXCEL_NUMBER(-0.0), "ZERO == negative ZERO");
9
+ assert_equal(EXCEL_NUMBER(0.0), EXCEL_NUMBER(1e-10), "Expected zero, got almost zero");
10
+ assert_equal(EXCEL_NUMBER(0.0), EXCEL_NUMBER(-1e-10), "Expected zero, got negative almost zero");
11
+ assert_equal(EXCEL_NUMBER(-0.0), EXCEL_NUMBER(1e-10), "Expected negative zero, got almost zero");
12
+ assert_equal(EXCEL_NUMBER(-0.0), EXCEL_NUMBER(-1e-10), "Expected negative zero, got negative almost zero");
13
+
4
14
  // Test ABS
5
15
  assert(excel_abs(ONE).number == 1);
6
- assert(excel_abs(new_excel_number(-1)).number == 1);
16
+ assert(excel_abs(EXCEL_NUMBER(-1)).number == 1);
7
17
  assert(excel_abs(VALUE).type == ExcelError);
8
18
 
9
19
  // Test ADD
10
- assert(add(ONE,new_excel_number(-2.5)).number == -1.5);
20
+ assert(add(ONE,EXCEL_NUMBER(-2.5)).number == -1.5);
11
21
  assert(add(ONE,VALUE).type == ExcelError);
12
22
 
13
23
  // Test AND
14
- ExcelValue true_array1[] = { TRUE, new_excel_number(10)};
24
+ ExcelValue true_array1[] = { TRUE, EXCEL_NUMBER(10)};
15
25
  ExcelValue true_array2[] = { ONE };
16
- ExcelValue false_array1[] = { FALSE, new_excel_number(10)};
17
- ExcelValue false_array2[] = { TRUE, new_excel_number(0)};
18
- // ExcelValue error_array1[] = { new_excel_number(10)}; // Not implemented
26
+ ExcelValue false_array1[] = { FALSE, EXCEL_NUMBER(10)};
27
+ ExcelValue false_array2[] = { TRUE, EXCEL_NUMBER(0)};
28
+ // ExcelValue error_array1[] = { EXCEL_NUMBER(10)}; // Not implemented
19
29
  ExcelValue error_array2[] = { TRUE, NA};
20
30
  assert(excel_and(2,true_array1).number == 1);
21
31
  assert(excel_and(1,true_array2).number == 1);
@@ -25,19 +35,19 @@ int test_functions() {
25
35
  assert(excel_and(2,error_array2).type == ExcelError);
26
36
 
27
37
  // Test AVERAGE
28
- ExcelValue array1[] = { new_excel_number(10), new_excel_number(5), TRUE, FALSE};
29
- ExcelValue array1_v = new_excel_range(array1,2,2);
30
- ExcelValue array2[] = { array1_v, new_excel_number(9), new_excel_string("Hello")};
31
- ExcelValue array3[] = { array1_v, new_excel_number(9), new_excel_string("Hello"), VALUE};
38
+ ExcelValue array1[] = { EXCEL_NUMBER(10), EXCEL_NUMBER(5), TRUE, FALSE};
39
+ ExcelValue array1_v = EXCEL_RANGE(array1,2,2);
40
+ ExcelValue array2[] = { array1_v, EXCEL_NUMBER(9), EXCEL_STRING("Hello")};
41
+ ExcelValue array3[] = { array1_v, EXCEL_NUMBER(9), EXCEL_STRING("Hello"), VALUE};
32
42
  assert(average(4, array1).number == 7.5);
33
43
  assert(average(3, array2).number == 8);
34
44
  assert(average(4, array3).type == ExcelError);
35
45
 
36
46
  // Test CHOOSE
37
47
  assert(choose(ONE,4,array1).number == 10);
38
- assert(choose(new_excel_number(4),4,array1).type == ExcelBoolean);
39
- assert(choose(new_excel_number(0),4,array1).type == ExcelError);
40
- assert(choose(new_excel_number(5),4,array1).type == ExcelError);
48
+ assert(choose(EXCEL_NUMBER(4),4,array1).type == ExcelBoolean);
49
+ assert(choose(EXCEL_NUMBER(0),4,array1).type == ExcelError);
50
+ assert(choose(EXCEL_NUMBER(5),4,array1).type == ExcelError);
41
51
  assert(choose(ONE,4,array3).type == ExcelError);
42
52
 
43
53
  // Test COUNT
@@ -46,179 +56,179 @@ int test_functions() {
46
56
  assert(count(4,array3).number == 3);
47
57
 
48
58
  // Test Large
49
- ExcelValue large_test_array_1[] = { new_excel_number(10), new_excel_number(100), new_excel_number(500), BLANK };
50
- ExcelValue large_test_array_1_v = new_excel_range(large_test_array_1, 1, 4);
51
- assert(large(large_test_array_1_v, new_excel_number(1)).number == 500);
52
- assert(large(large_test_array_1_v, new_excel_number(2)).number == 100);
53
- assert(large(large_test_array_1_v, new_excel_number(3)).number == 10);
54
- assert(large(large_test_array_1_v, new_excel_number(4)).type == ExcelError);
55
- assert(large(new_excel_number(500), new_excel_number(1)).number == 500);
56
- ExcelValue large_test_array_2[] = { new_excel_number(10), new_excel_number(100), new_excel_number(500), VALUE };
57
- ExcelValue large_test_array_2_v = new_excel_range(large_test_array_2, 1, 4);
58
- assert(large(large_test_array_2_v,new_excel_number(2)).type == ExcelError);
59
- assert(large(new_excel_number(500),VALUE).type == ExcelError);
59
+ ExcelValue large_test_array_1[] = { EXCEL_NUMBER(10), EXCEL_NUMBER(100), EXCEL_NUMBER(500), BLANK };
60
+ ExcelValue large_test_array_1_v = EXCEL_RANGE(large_test_array_1, 1, 4);
61
+ assert(large(large_test_array_1_v, EXCEL_NUMBER(1)).number == 500);
62
+ assert(large(large_test_array_1_v, EXCEL_NUMBER(2)).number == 100);
63
+ assert(large(large_test_array_1_v, EXCEL_NUMBER(3)).number == 10);
64
+ assert(large(large_test_array_1_v, EXCEL_NUMBER(4)).type == ExcelError);
65
+ assert(large(EXCEL_NUMBER(500), EXCEL_NUMBER(1)).number == 500);
66
+ ExcelValue large_test_array_2[] = { EXCEL_NUMBER(10), EXCEL_NUMBER(100), EXCEL_NUMBER(500), VALUE };
67
+ ExcelValue large_test_array_2_v = EXCEL_RANGE(large_test_array_2, 1, 4);
68
+ assert(large(large_test_array_2_v,EXCEL_NUMBER(2)).type == ExcelError);
69
+ assert(large(EXCEL_NUMBER(500),VALUE).type == ExcelError);
60
70
 
61
71
 
62
72
  // Test COUNTA
63
- ExcelValue count_a_test_array_1[] = { new_excel_number(10), new_excel_number(5), TRUE, FALSE, new_excel_string("Hello"), VALUE, BLANK};
64
- ExcelValue count_a_test_array_1_v = new_excel_range(count_a_test_array_1,7,1);
65
- ExcelValue count_a_test_array_2[] = {new_excel_string("Bye"),count_a_test_array_1_v};
73
+ ExcelValue count_a_test_array_1[] = { EXCEL_NUMBER(10), EXCEL_NUMBER(5), TRUE, FALSE, EXCEL_STRING("Hello"), VALUE, BLANK};
74
+ ExcelValue count_a_test_array_1_v = EXCEL_RANGE(count_a_test_array_1,7,1);
75
+ ExcelValue count_a_test_array_2[] = {EXCEL_STRING("Bye"),count_a_test_array_1_v};
66
76
  assert(counta(7, count_a_test_array_1).number == 6);
67
77
  assert(counta(2, count_a_test_array_2).number == 7);
68
78
 
69
79
  // Test divide
70
- assert(divide(new_excel_number(12.4),new_excel_number(3.2)).number == 3.875);
71
- assert(divide(new_excel_number(12.4),new_excel_number(0)).type == ExcelError);
80
+ assert(divide(EXCEL_NUMBER(12.4),EXCEL_NUMBER(3.2)).number == 3.875);
81
+ assert(divide(EXCEL_NUMBER(12.4),EXCEL_NUMBER(0)).type == ExcelError);
72
82
 
73
83
  // Test excel_equal
74
- assert(excel_equal(new_excel_number(1.2),new_excel_number(3.4)).type == ExcelBoolean);
75
- assert(excel_equal(new_excel_number(1.2),new_excel_number(3.4)).number == false);
76
- assert(excel_equal(new_excel_number(1.2),new_excel_number(1.2)).number == true);
77
- assert(excel_equal(new_excel_string("hello"), new_excel_string("HELLO")).number == true);
78
- assert(excel_equal(new_excel_string("hello world"), new_excel_string("HELLO")).number == false);
79
- assert(excel_equal(new_excel_string("1"), ONE).number == false);
84
+ assert(excel_equal(EXCEL_NUMBER(1.2),EXCEL_NUMBER(3.4)).type == ExcelBoolean);
85
+ assert(excel_equal(EXCEL_NUMBER(1.2),EXCEL_NUMBER(3.4)).number == false);
86
+ assert(excel_equal(EXCEL_NUMBER(1.2),EXCEL_NUMBER(1.2)).number == true);
87
+ assert(excel_equal(EXCEL_STRING("hello"), EXCEL_STRING("HELLO")).number == true);
88
+ assert(excel_equal(EXCEL_STRING("hello world"), EXCEL_STRING("HELLO")).number == false);
89
+ assert(excel_equal(EXCEL_STRING("1"), ONE).number == false);
80
90
  assert(excel_equal(DIV0, ONE).type == ExcelError);
81
91
 
82
92
  // Test not_equal
83
- assert(not_equal(new_excel_number(1.2),new_excel_number(3.4)).type == ExcelBoolean);
84
- assert(not_equal(new_excel_number(1.2),new_excel_number(3.4)).number == true);
85
- assert(not_equal(new_excel_number(1.2),new_excel_number(1.2)).number == false);
86
- assert(not_equal(new_excel_string("hello"), new_excel_string("HELLO")).number == false);
87
- assert(not_equal(new_excel_string("hello world"), new_excel_string("HELLO")).number == true);
88
- assert(not_equal(new_excel_string("1"), ONE).number == true);
93
+ assert(not_equal(EXCEL_NUMBER(1.2),EXCEL_NUMBER(3.4)).type == ExcelBoolean);
94
+ assert(not_equal(EXCEL_NUMBER(1.2),EXCEL_NUMBER(3.4)).number == true);
95
+ assert(not_equal(EXCEL_NUMBER(1.2),EXCEL_NUMBER(1.2)).number == false);
96
+ assert(not_equal(EXCEL_STRING("hello"), EXCEL_STRING("HELLO")).number == false);
97
+ assert(not_equal(EXCEL_STRING("hello world"), EXCEL_STRING("HELLO")).number == true);
98
+ assert(not_equal(EXCEL_STRING("1"), ONE).number == true);
89
99
  assert(not_equal(DIV0, ONE).type == ExcelError);
90
100
 
91
101
  // Test excel_if
92
102
  // Two argument version
93
- assert(excel_if_2(TRUE,new_excel_number(10)).type == ExcelNumber);
94
- assert(excel_if_2(TRUE,new_excel_number(10)).number == 10);
95
- assert(excel_if_2(FALSE,new_excel_number(10)).type == ExcelBoolean);
96
- assert(excel_if_2(FALSE,new_excel_number(10)).number == false);
97
- assert(excel_if_2(NA,new_excel_number(10)).type == ExcelError);
103
+ assert(excel_if_2(TRUE,EXCEL_NUMBER(10)).type == ExcelNumber);
104
+ assert(excel_if_2(TRUE,EXCEL_NUMBER(10)).number == 10);
105
+ assert(excel_if_2(FALSE,EXCEL_NUMBER(10)).type == ExcelBoolean);
106
+ assert(excel_if_2(FALSE,EXCEL_NUMBER(10)).number == false);
107
+ assert(excel_if_2(NA,EXCEL_NUMBER(10)).type == ExcelError);
98
108
  // Three argument version
99
- assert(excel_if(TRUE,new_excel_number(10),new_excel_number(20)).type == ExcelNumber);
100
- assert(excel_if(TRUE,new_excel_number(10),new_excel_number(20)).number == 10);
101
- assert(excel_if(FALSE,new_excel_number(10),new_excel_number(20)).type == ExcelNumber);
102
- assert(excel_if(FALSE,new_excel_number(10),new_excel_number(20)).number == 20);
103
- assert(excel_if(NA,new_excel_number(10),new_excel_number(20)).type == ExcelError);
104
- assert(excel_if(TRUE,new_excel_number(10),NA).type == ExcelNumber);
105
- assert(excel_if(TRUE,new_excel_number(10),NA).number == 10);
109
+ assert(excel_if(TRUE,EXCEL_NUMBER(10),EXCEL_NUMBER(20)).type == ExcelNumber);
110
+ assert(excel_if(TRUE,EXCEL_NUMBER(10),EXCEL_NUMBER(20)).number == 10);
111
+ assert(excel_if(FALSE,EXCEL_NUMBER(10),EXCEL_NUMBER(20)).type == ExcelNumber);
112
+ assert(excel_if(FALSE,EXCEL_NUMBER(10),EXCEL_NUMBER(20)).number == 20);
113
+ assert(excel_if(NA,EXCEL_NUMBER(10),EXCEL_NUMBER(20)).type == ExcelError);
114
+ assert(excel_if(TRUE,EXCEL_NUMBER(10),NA).type == ExcelNumber);
115
+ assert(excel_if(TRUE,EXCEL_NUMBER(10),NA).number == 10);
106
116
 
107
117
  // Test excel_match
108
- ExcelValue excel_match_array_1[] = { new_excel_number(10), new_excel_number(100) };
109
- ExcelValue excel_match_array_1_v = new_excel_range(excel_match_array_1,1,2);
110
- ExcelValue excel_match_array_2[] = { new_excel_string("Pear"), new_excel_string("Bear"), new_excel_string("Apple") };
111
- ExcelValue excel_match_array_2_v = new_excel_range(excel_match_array_2,3,1);
112
- ExcelValue excel_match_array_4[] = { ONE, BLANK, new_excel_number(0) };
113
- ExcelValue excel_match_array_4_v = new_excel_range(excel_match_array_4,1,3);
114
- ExcelValue excel_match_array_5[] = { ONE, new_excel_number(0), BLANK };
115
- ExcelValue excel_match_array_5_v = new_excel_range(excel_match_array_5,1,3);
118
+ ExcelValue excel_match_array_1[] = { EXCEL_NUMBER(10), EXCEL_NUMBER(100) };
119
+ ExcelValue excel_match_array_1_v = EXCEL_RANGE(excel_match_array_1,1,2);
120
+ ExcelValue excel_match_array_2[] = { EXCEL_STRING("Pear"), EXCEL_STRING("Bear"), EXCEL_STRING("Apple") };
121
+ ExcelValue excel_match_array_2_v = EXCEL_RANGE(excel_match_array_2,3,1);
122
+ ExcelValue excel_match_array_4[] = { ONE, BLANK, EXCEL_NUMBER(0) };
123
+ ExcelValue excel_match_array_4_v = EXCEL_RANGE(excel_match_array_4,1,3);
124
+ ExcelValue excel_match_array_5[] = { ONE, EXCEL_NUMBER(0), BLANK };
125
+ ExcelValue excel_match_array_5_v = EXCEL_RANGE(excel_match_array_5,1,3);
116
126
 
117
127
  // Two argument version
118
- assert(excel_match_2(new_excel_number(14),excel_match_array_1_v).number == 1);
119
- assert(excel_match_2(new_excel_number(110),excel_match_array_1_v).number == 2);
120
- assert(excel_match_2(new_excel_number(-10),excel_match_array_1_v).type == ExcelError);
128
+ assert(excel_match_2(EXCEL_NUMBER(14),excel_match_array_1_v).number == 1);
129
+ assert(excel_match_2(EXCEL_NUMBER(110),excel_match_array_1_v).number == 2);
130
+ assert(excel_match_2(EXCEL_NUMBER(-10),excel_match_array_1_v).type == ExcelError);
121
131
 
122
132
  // Three argument version
123
- assert(excel_match(new_excel_number(10.0), excel_match_array_1_v, new_excel_number(0) ).number == 1);
124
- assert(excel_match(new_excel_number(100.0), excel_match_array_1_v, new_excel_number(0) ).number == 2);
125
- assert(excel_match(new_excel_number(1000.0), excel_match_array_1_v, new_excel_number(0) ).type == ExcelError);
126
- assert(excel_match(new_excel_string("bEAr"), excel_match_array_2_v, new_excel_number(0) ).number == 2);
127
- assert(excel_match(new_excel_number(1000.0), excel_match_array_1_v, ONE ).number == 2);
128
- assert(excel_match(new_excel_number(1.0), excel_match_array_1_v, ONE ).type == ExcelError);
129
- assert(excel_match(new_excel_string("Care"), excel_match_array_2_v, new_excel_number(-1) ).number == 1 );
130
- assert(excel_match(new_excel_string("Zebra"), excel_match_array_2_v, new_excel_number(-1) ).type == ExcelError);
131
- assert(excel_match(new_excel_string("a"), excel_match_array_2_v, new_excel_number(-1) ).number == 2);
133
+ assert(excel_match(EXCEL_NUMBER(10.0), excel_match_array_1_v, EXCEL_NUMBER(0) ).number == 1);
134
+ assert(excel_match(EXCEL_NUMBER(100.0), excel_match_array_1_v, EXCEL_NUMBER(0) ).number == 2);
135
+ assert(excel_match(EXCEL_NUMBER(1000.0), excel_match_array_1_v, EXCEL_NUMBER(0) ).type == ExcelError);
136
+ assert(excel_match(EXCEL_STRING("bEAr"), excel_match_array_2_v, EXCEL_NUMBER(0) ).number == 2);
137
+ assert(excel_match(EXCEL_NUMBER(1000.0), excel_match_array_1_v, ONE ).number == 2);
138
+ assert(excel_match(EXCEL_NUMBER(1.0), excel_match_array_1_v, ONE ).type == ExcelError);
139
+ assert(excel_match(EXCEL_STRING("Care"), excel_match_array_2_v, EXCEL_NUMBER(-1) ).number == 1 );
140
+ assert(excel_match(EXCEL_STRING("Zebra"), excel_match_array_2_v, EXCEL_NUMBER(-1) ).type == ExcelError);
141
+ assert(excel_match(EXCEL_STRING("a"), excel_match_array_2_v, EXCEL_NUMBER(-1) ).number == 2);
132
142
 
133
143
  // When not given a range
134
- assert(excel_match(new_excel_number(10.0), new_excel_number(10), new_excel_number(0.0)).number == 1);
135
- assert(excel_match(new_excel_number(20.0), new_excel_number(10), new_excel_number(0.0)).type == ExcelError);
136
- assert(excel_match(new_excel_number(10.0), excel_match_array_1_v, BLANK).number == 1);
144
+ assert(excel_match(EXCEL_NUMBER(10.0), EXCEL_NUMBER(10), EXCEL_NUMBER(0.0)).number == 1);
145
+ assert(excel_match(EXCEL_NUMBER(20.0), EXCEL_NUMBER(10), EXCEL_NUMBER(0.0)).type == ExcelError);
146
+ assert(excel_match(EXCEL_NUMBER(10.0), excel_match_array_1_v, BLANK).number == 1);
137
147
 
138
148
  // Test more than on
139
149
  // .. numbers
140
- assert(more_than(ONE,new_excel_number(2)).number == false);
150
+ assert(more_than(ONE,EXCEL_NUMBER(2)).number == false);
141
151
  assert(more_than(ONE,ONE).number == false);
142
- assert(more_than(ONE,new_excel_number(0)).number == true);
152
+ assert(more_than(ONE,EXCEL_NUMBER(0)).number == true);
143
153
  // .. booleans
144
154
  assert(more_than(FALSE,FALSE).number == false);
145
155
  assert(more_than(FALSE,TRUE).number == false);
146
156
  assert(more_than(TRUE,FALSE).number == true);
147
157
  assert(more_than(TRUE,TRUE).number == false);
148
158
  // ..strings
149
- assert(more_than(new_excel_string("HELLO"),new_excel_string("Ardvark")).number == true);
150
- assert(more_than(new_excel_string("HELLO"),new_excel_string("world")).number == false);
151
- assert(more_than(new_excel_string("HELLO"),new_excel_string("hello")).number == false);
159
+ assert(more_than(EXCEL_STRING("HELLO"),EXCEL_STRING("Ardvark")).number == true);
160
+ assert(more_than(EXCEL_STRING("HELLO"),EXCEL_STRING("world")).number == false);
161
+ assert(more_than(EXCEL_STRING("HELLO"),EXCEL_STRING("hello")).number == false);
152
162
  // ..blanks
153
163
  assert(more_than(BLANK,ONE).number == false);
154
- assert(more_than(BLANK,new_excel_number(-1)).number == true);
164
+ assert(more_than(BLANK,EXCEL_NUMBER(-1)).number == true);
155
165
  assert(more_than(ONE,BLANK).number == true);
156
- assert(more_than(new_excel_number(-1),BLANK).number == false);
166
+ assert(more_than(EXCEL_NUMBER(-1),BLANK).number == false);
157
167
  // .. of different types
158
- assert(more_than(TRUE,new_excel_string("Hello")).number == true);
159
- assert(more_than(FALSE,new_excel_string("Hello")).number == true);
160
- assert(more_than(new_excel_string("Hello"), ONE).number == true);
161
- assert(more_than(ONE,new_excel_string("Hello")).number == false);
162
- assert(more_than(new_excel_string("Hello"), TRUE).number == false);
163
- assert(more_than(new_excel_string("Hello"), FALSE).number == false);
168
+ assert(more_than(TRUE,EXCEL_STRING("Hello")).number == true);
169
+ assert(more_than(FALSE,EXCEL_STRING("Hello")).number == true);
170
+ assert(more_than(EXCEL_STRING("Hello"), ONE).number == true);
171
+ assert(more_than(ONE,EXCEL_STRING("Hello")).number == false);
172
+ assert(more_than(EXCEL_STRING("Hello"), TRUE).number == false);
173
+ assert(more_than(EXCEL_STRING("Hello"), FALSE).number == false);
164
174
 
165
175
  // Test less than on
166
176
  // .. numbers
167
- assert(less_than(ONE,new_excel_number(2)).number == true);
177
+ assert(less_than(ONE,EXCEL_NUMBER(2)).number == true);
168
178
  assert(less_than(ONE,ONE).number == false);
169
- assert(less_than(ONE,new_excel_number(0)).number == false);
179
+ assert(less_than(ONE,EXCEL_NUMBER(0)).number == false);
170
180
  // .. booleans
171
181
  assert(less_than(FALSE,FALSE).number == false);
172
182
  assert(less_than(FALSE,TRUE).number == true);
173
183
  assert(less_than(TRUE,FALSE).number == false);
174
184
  assert(less_than(TRUE,TRUE).number == false);
175
185
  // ..strings
176
- assert(less_than(new_excel_string("HELLO"),new_excel_string("Ardvark")).number == false);
177
- assert(less_than(new_excel_string("HELLO"),new_excel_string("world")).number == true);
178
- assert(less_than(new_excel_string("HELLO"),new_excel_string("hello")).number == false);
186
+ assert(less_than(EXCEL_STRING("HELLO"),EXCEL_STRING("Ardvark")).number == false);
187
+ assert(less_than(EXCEL_STRING("HELLO"),EXCEL_STRING("world")).number == true);
188
+ assert(less_than(EXCEL_STRING("HELLO"),EXCEL_STRING("hello")).number == false);
179
189
  // ..blanks
180
190
  assert(less_than(BLANK,ONE).number == true);
181
- assert(less_than(BLANK,new_excel_number(-1)).number == false);
191
+ assert(less_than(BLANK,EXCEL_NUMBER(-1)).number == false);
182
192
  assert(less_than(ONE,BLANK).number == false);
183
- assert(less_than(new_excel_number(-1),BLANK).number == true);
193
+ assert(less_than(EXCEL_NUMBER(-1),BLANK).number == true);
184
194
  // .. of different types
185
- assert(less_than(TRUE,new_excel_string("Hello")).number == false);
186
- assert(less_than(FALSE,new_excel_string("Hello")).number == false);
187
- assert(less_than(new_excel_string("Hello"), ONE).number == false);
188
- assert(less_than(ONE,new_excel_string("Hello")).number == true);
189
- assert(less_than(new_excel_string("Hello"), TRUE).number == true);
190
- assert(less_than(new_excel_string("Hello"), FALSE).number == true);
195
+ assert(less_than(TRUE,EXCEL_STRING("Hello")).number == false);
196
+ assert(less_than(FALSE,EXCEL_STRING("Hello")).number == false);
197
+ assert(less_than(EXCEL_STRING("Hello"), ONE).number == false);
198
+ assert(less_than(ONE,EXCEL_STRING("Hello")).number == true);
199
+ assert(less_than(EXCEL_STRING("Hello"), TRUE).number == true);
200
+ assert(less_than(EXCEL_STRING("Hello"), FALSE).number == true);
191
201
 
192
202
  // Test FIND function
193
203
  // ... should find the first occurrence of one string in another, returning :value if the string doesn't match
194
- assert(find_2(new_excel_string("one"),new_excel_string("onetwothree")).number == 1);
195
- assert(find_2(new_excel_string("one"),new_excel_string("twoonethree")).number == 4);
196
- assert(find_2(new_excel_string("one"),new_excel_string("twoonthree")).type == ExcelError);
204
+ assert(find_2(EXCEL_STRING("one"),EXCEL_STRING("onetwothree")).number == 1);
205
+ assert(find_2(EXCEL_STRING("one"),EXCEL_STRING("twoonethree")).number == 4);
206
+ assert(find_2(EXCEL_STRING("one"),EXCEL_STRING("twoonthree")).type == ExcelError);
197
207
  // ... should find the first occurrence of one string in another after a given index, returning :value if the string doesn't match
198
- assert(find(new_excel_string("one"),new_excel_string("onetwothree"),ONE).number == 1);
199
- assert(find(new_excel_string("one"),new_excel_string("twoonethree"),new_excel_number(5)).type == ExcelError);
200
- assert(find(new_excel_string("one"),new_excel_string("oneone"),new_excel_number(2)).number == 4);
208
+ assert(find(EXCEL_STRING("one"),EXCEL_STRING("onetwothree"),ONE).number == 1);
209
+ assert(find(EXCEL_STRING("one"),EXCEL_STRING("twoonethree"),EXCEL_NUMBER(5)).type == ExcelError);
210
+ assert(find(EXCEL_STRING("one"),EXCEL_STRING("oneone"),EXCEL_NUMBER(2)).number == 4);
201
211
  // ... should be possible for the start_num to be a string, if that string converts to a number
202
- assert(find(new_excel_string("one"),new_excel_string("oneone"),new_excel_string("2")).number == 4);
212
+ assert(find(EXCEL_STRING("one"),EXCEL_STRING("oneone"),EXCEL_STRING("2")).number == 4);
203
213
  // ... should return a :value error when given anything but a number as the third argument
204
- assert(find(new_excel_string("one"),new_excel_string("oneone"),new_excel_string("a")).type == ExcelError);
214
+ assert(find(EXCEL_STRING("one"),EXCEL_STRING("oneone"),EXCEL_STRING("a")).type == ExcelError);
205
215
  // ... should return a :value error when given a third argument that is less than 1 or greater than the length of the string
206
- assert(find(new_excel_string("one"),new_excel_string("oneone"),new_excel_number(0)).type == ExcelError);
207
- assert(find(new_excel_string("one"),new_excel_string("oneone"),new_excel_number(-1)).type == ExcelError);
208
- assert(find(new_excel_string("one"),new_excel_string("oneone"),new_excel_number(7)).type == ExcelError);
216
+ assert(find(EXCEL_STRING("one"),EXCEL_STRING("oneone"),EXCEL_NUMBER(0)).type == ExcelError);
217
+ assert(find(EXCEL_STRING("one"),EXCEL_STRING("oneone"),EXCEL_NUMBER(-1)).type == ExcelError);
218
+ assert(find(EXCEL_STRING("one"),EXCEL_STRING("oneone"),EXCEL_NUMBER(7)).type == ExcelError);
209
219
  // ... BLANK in the first argument matches any character
210
- assert(find_2(BLANK,new_excel_string("abcdefg")).number == 1);
211
- assert(find(BLANK,new_excel_string("abcdefg"),new_excel_number(4)).number == 4);
220
+ assert(find_2(BLANK,EXCEL_STRING("abcdefg")).number == 1);
221
+ assert(find(BLANK,EXCEL_STRING("abcdefg"),EXCEL_NUMBER(4)).number == 4);
212
222
  // ... should treat BLANK in the second argument as an empty string
213
223
  assert(find_2(BLANK,BLANK).number == 1);
214
- assert(find_2(new_excel_string("a"),BLANK).type == ExcelError);
224
+ assert(find_2(EXCEL_STRING("a"),BLANK).type == ExcelError);
215
225
  // ... should return an error if any argument is an error
216
- assert(find(new_excel_string("one"),new_excel_string("onetwothree"),NA).type == ExcelError);
217
- assert(find(new_excel_string("one"),NA,ONE).type == ExcelError);
218
- assert(find(NA,new_excel_string("onetwothree"),ONE).type == ExcelError);
226
+ assert(find(EXCEL_STRING("one"),EXCEL_STRING("onetwothree"),NA).type == ExcelError);
227
+ assert(find(EXCEL_STRING("one"),NA,ONE).type == ExcelError);
228
+ assert(find(NA,EXCEL_STRING("onetwothree"),ONE).type == ExcelError);
219
229
 
220
230
  // Test the IFERROR function
221
- assert(iferror(new_excel_string("ok"),ONE).type == ExcelString);
231
+ assert(iferror(EXCEL_STRING("ok"),ONE).type == ExcelString);
222
232
  assert(iferror(VALUE,ONE).type == ExcelNumber);
223
233
 
224
234
  // Test the ISERR function
@@ -240,33 +250,33 @@ int test_functions() {
240
250
  assert(iserr(FALSE).number == 0);
241
251
  assert(iserr(ONE).number == 0);
242
252
  assert(iserr(ONE).number == 0);
243
- assert(iserr(new_excel_string("Hello")).number == 0);
244
- assert(iserr(new_excel_string("Hello")).number == 0);
253
+ assert(iserr(EXCEL_STRING("Hello")).number == 0);
254
+ assert(iserr(EXCEL_STRING("Hello")).number == 0);
245
255
 
246
256
  // Test the INDEX function
247
- ExcelValue index_array_1[] = { new_excel_number(10), new_excel_number(20), BLANK };
248
- ExcelValue index_array_1_v_column = new_excel_range(index_array_1,3,1);
249
- ExcelValue index_array_1_v_row = new_excel_range(index_array_1,1,3);
250
- ExcelValue index_array_2[] = { BLANK, ONE, new_excel_number(10), new_excel_number(11), new_excel_number(100), new_excel_number(101) };
251
- ExcelValue index_array_2_v = new_excel_range(index_array_2,3,2);
257
+ ExcelValue index_array_1[] = { EXCEL_NUMBER(10), EXCEL_NUMBER(20), BLANK };
258
+ ExcelValue index_array_1_v_column = EXCEL_RANGE(index_array_1,3,1);
259
+ ExcelValue index_array_1_v_row = EXCEL_RANGE(index_array_1,1,3);
260
+ ExcelValue index_array_2[] = { BLANK, ONE, EXCEL_NUMBER(10), EXCEL_NUMBER(11), EXCEL_NUMBER(100), EXCEL_NUMBER(101) };
261
+ ExcelValue index_array_2_v = EXCEL_RANGE(index_array_2,3,2);
252
262
  // ... if given one argument should return the value at that offset in the range
253
- assert(excel_index_2(index_array_1_v_column,new_excel_number(2.0)).number == 20);
254
- assert(excel_index_2(index_array_1_v_row,new_excel_number(2.0)).number == 20);
263
+ assert(excel_index_2(index_array_1_v_column,EXCEL_NUMBER(2.0)).number == 20);
264
+ assert(excel_index_2(index_array_1_v_row,EXCEL_NUMBER(2.0)).number == 20);
255
265
  // ... but not if the range is not a single row or single column
256
- assert(excel_index_2(index_array_2_v,new_excel_number(2.0)).type == ExcelError);
266
+ assert(excel_index_2(index_array_2_v,EXCEL_NUMBER(2.0)).type == ExcelError);
257
267
  // ... it should return the value in the array at position row_number, column_number
258
- assert(excel_index(new_excel_number(10),ONE,ONE).number == 10);
259
- assert(excel_index(index_array_2_v,new_excel_number(1.0),new_excel_number(2.0)).number == 1);
260
- assert(excel_index(index_array_2_v,new_excel_number(2.0),new_excel_number(1.0)).number == 10);
261
- assert(excel_index(index_array_2_v,new_excel_number(3.0),new_excel_number(1.0)).number == 100);
262
- assert(excel_index(index_array_2_v,new_excel_number(3.0),new_excel_number(3.0)).type == ExcelError);
268
+ assert(excel_index(EXCEL_NUMBER(10),ONE,ONE).number == 10);
269
+ assert(excel_index(index_array_2_v,EXCEL_NUMBER(1.0),EXCEL_NUMBER(2.0)).number == 1);
270
+ assert(excel_index(index_array_2_v,EXCEL_NUMBER(2.0),EXCEL_NUMBER(1.0)).number == 10);
271
+ assert(excel_index(index_array_2_v,EXCEL_NUMBER(3.0),EXCEL_NUMBER(1.0)).number == 100);
272
+ assert(excel_index(index_array_2_v,EXCEL_NUMBER(3.0),EXCEL_NUMBER(3.0)).type == ExcelError);
263
273
  // ... it should return ZERO not blank, if a blank cell is picked
264
- assert(excel_index(index_array_2_v,new_excel_number(1.0),new_excel_number(1.0)).type == ExcelNumber);
265
- assert(excel_index(index_array_2_v,new_excel_number(1.0),new_excel_number(1.0)).number == 0);
266
- assert(excel_index_2(index_array_1_v_row,new_excel_number(3.0)).type == ExcelNumber);
267
- assert(excel_index_2(index_array_1_v_row,new_excel_number(3.0)).number == 0);
274
+ assert(excel_index(index_array_2_v,EXCEL_NUMBER(1.0),EXCEL_NUMBER(1.0)).type == ExcelNumber);
275
+ assert(excel_index(index_array_2_v,EXCEL_NUMBER(1.0),EXCEL_NUMBER(1.0)).number == 0);
276
+ assert(excel_index_2(index_array_1_v_row,EXCEL_NUMBER(3.0)).type == ExcelNumber);
277
+ assert(excel_index_2(index_array_1_v_row,EXCEL_NUMBER(3.0)).number == 0);
268
278
  // ... it should return the whole row if given a zero column number
269
- ExcelValue index_result_1_v = excel_index(index_array_2_v,new_excel_number(1.0),new_excel_number(0.0));
279
+ ExcelValue index_result_1_v = excel_index(index_array_2_v,EXCEL_NUMBER(1.0),EXCEL_NUMBER(0.0));
270
280
  assert(index_result_1_v.type == ExcelRange);
271
281
  assert(index_result_1_v.rows == 1);
272
282
  assert(index_result_1_v.columns == 2);
@@ -274,7 +284,7 @@ int test_functions() {
274
284
  assert(index_result_1_a[0].number == 0);
275
285
  assert(index_result_1_a[1].number == 1);
276
286
  // ... it should return the whole column if given a zero row number
277
- ExcelValue index_result_2_v = excel_index(index_array_2_v,new_excel_number(0),new_excel_number(1.0));
287
+ ExcelValue index_result_2_v = excel_index(index_array_2_v,EXCEL_NUMBER(0),EXCEL_NUMBER(1.0));
278
288
  assert(index_result_2_v.type == ExcelRange);
279
289
  assert(index_result_2_v.rows == 3);
280
290
  assert(index_result_2_v.columns == 1);
@@ -283,55 +293,56 @@ int test_functions() {
283
293
  assert(index_result_2_a[1].number == 10);
284
294
  assert(index_result_2_a[2].number == 100);
285
295
  // ... it should return a :ref error when given arguments outside array range
286
- assert(excel_index_2(index_array_1_v_row,new_excel_number(-1)).type == ExcelError);
287
- assert(excel_index_2(index_array_1_v_row,new_excel_number(4)).type == ExcelError);
296
+ assert(excel_index_2(index_array_1_v_row,EXCEL_NUMBER(-1)).type == ExcelError);
297
+ assert(excel_index_2(index_array_1_v_row,EXCEL_NUMBER(4)).type == ExcelError);
288
298
  // ... it should treat BLANK as zero if given as a required row or column number
289
- assert(excel_index(index_array_2_v,new_excel_number(1.0),BLANK).type == ExcelRange);
290
- assert(excel_index(index_array_2_v,BLANK,new_excel_number(2.0)).type == ExcelRange);
299
+ assert(excel_index(index_array_2_v,EXCEL_NUMBER(1.0),BLANK).type == ExcelRange);
300
+ assert(excel_index(index_array_2_v,BLANK,EXCEL_NUMBER(2.0)).type == ExcelRange);
291
301
  // ... it should return an error if an argument is an error
292
302
  assert(excel_index(NA,NA,NA).type == ExcelError);
293
303
  // ... it should return a single value if single column and passed zero as column number
294
- assert(excel_index(index_array_1_v_column,new_excel_number(2.0), ZERO).number == 20);
295
- assert(excel_index(index_array_1_v_row,ZERO, new_excel_number(2.0)).number == 20);
304
+ assert(excel_index(index_array_1_v_column,EXCEL_NUMBER(2.0), ZERO).number == 20);
305
+ assert(excel_index(index_array_1_v_row,ZERO, EXCEL_NUMBER(2.0)).number == 20);
296
306
 
297
307
 
298
308
  // LEFT(string,[characters])
299
309
  // ... should return the left n characters from a string
300
- assert(strcmp(left_1(new_excel_string("ONE")).string,"O") == 0);
301
- assert(strcmp(left(new_excel_string("ONE"),ONE).string,"O") == 0);
302
- assert(strcmp(left(new_excel_string("ONE"),new_excel_number(3)).string,"ONE") == 0);
310
+ assert(strcmp(left_1(EXCEL_STRING("ONE")).string,"O") == 0);
311
+ assert(strcmp(left(EXCEL_STRING("ONE"),ONE).string,"O") == 0);
312
+ assert(strcmp(left(EXCEL_STRING("ONE"),EXCEL_NUMBER(3)).string,"ONE") == 0);
303
313
  // ... should turn numbers into strings before processing
304
- assert(strcmp(left(new_excel_number(1.31e12),new_excel_number(3)).string, "131") == 0);
314
+ assert(strcmp(left(EXCEL_NUMBER(1.31e12),EXCEL_NUMBER(3)).string, "131") == 0);
305
315
  // ... should turn booleans into the words TRUE and FALSE before processing
306
- assert(strcmp(left(TRUE,new_excel_number(3)).string,"TRU") == 0);
307
- assert(strcmp(left(FALSE,new_excel_number(3)).string,"FAL") == 0);
316
+ assert(strcmp(left(TRUE,EXCEL_NUMBER(3)).string,"TRU") == 0);
317
+ assert(strcmp(left(FALSE,EXCEL_NUMBER(3)).string,"FAL") == 0);
308
318
  // ... should return BLANK if given BLANK for either argument
309
- assert(left(BLANK,new_excel_number(3)).type == ExcelEmpty);
310
- assert(left(new_excel_string("ONE"),BLANK).type == ExcelEmpty);
319
+ assert(left(BLANK,EXCEL_NUMBER(3)).type == ExcelEmpty);
320
+ assert(left(EXCEL_STRING("ONE"),BLANK).type == ExcelEmpty);
311
321
  // ... should return an error if an argument is an error
312
322
  assert(left_1(NA).type == ExcelError);
313
- assert(left(new_excel_string("ONE"),NA).type == ExcelError);
314
- assert(left(new_excel_string("ONE"),new_excel_number(-10)).type == ExcelError);
323
+ assert(left(EXCEL_STRING("ONE"),NA).type == ExcelError);
324
+ assert(left(EXCEL_STRING("ONE"),EXCEL_NUMBER(-10)).type == ExcelError);
325
+ assert_equal(EXCEL_STRING("ONE"), left(EXCEL_STRING("ONE"), EXCEL_NUMBER(100)), "LEFT if number of characters greater than string length");
315
326
 
316
327
  // Test less than or equal to
317
328
  // .. numbers
318
- assert(less_than_or_equal(ONE,new_excel_number(2)).number == true);
329
+ assert(less_than_or_equal(ONE,EXCEL_NUMBER(2)).number == true);
319
330
  assert(less_than_or_equal(ONE,ONE).number == true);
320
- assert(less_than_or_equal(ONE,new_excel_number(0)).number == false);
331
+ assert(less_than_or_equal(ONE,EXCEL_NUMBER(0)).number == false);
321
332
  // .. booleans
322
333
  assert(less_than_or_equal(FALSE,FALSE).number == true);
323
334
  assert(less_than_or_equal(FALSE,TRUE).number == true);
324
335
  assert(less_than_or_equal(TRUE,FALSE).number == false);
325
336
  assert(less_than_or_equal(TRUE,TRUE).number == true);
326
337
  // ..strings
327
- assert(less_than_or_equal(new_excel_string("HELLO"),new_excel_string("Ardvark")).number == false);
328
- assert(less_than_or_equal(new_excel_string("HELLO"),new_excel_string("world")).number == true);
329
- assert(less_than_or_equal(new_excel_string("HELLO"),new_excel_string("hello")).number == true);
338
+ assert(less_than_or_equal(EXCEL_STRING("HELLO"),EXCEL_STRING("Ardvark")).number == false);
339
+ assert(less_than_or_equal(EXCEL_STRING("HELLO"),EXCEL_STRING("world")).number == true);
340
+ assert(less_than_or_equal(EXCEL_STRING("HELLO"),EXCEL_STRING("hello")).number == true);
330
341
  // ..blanks
331
342
  assert(less_than_or_equal(BLANK,ONE).number == true);
332
- assert(less_than_or_equal(BLANK,new_excel_number(-1)).number == false);
343
+ assert(less_than_or_equal(BLANK,EXCEL_NUMBER(-1)).number == false);
333
344
  assert(less_than_or_equal(ONE,BLANK).number == false);
334
- assert(less_than_or_equal(new_excel_number(-1),BLANK).number == true);
345
+ assert(less_than_or_equal(EXCEL_NUMBER(-1),BLANK).number == true);
335
346
 
336
347
  // Test MAX
337
348
  assert(max(4, array1).number == 10);
@@ -345,105 +356,105 @@ int test_functions() {
345
356
 
346
357
  // Test MOD
347
358
  // ... should return the remainder of a number
348
- assert(mod(new_excel_number(10), new_excel_number(3)).number == 1.0);
349
- assert(mod(new_excel_number(10), new_excel_number(5)).number == 0.0);
359
+ assert(mod(EXCEL_NUMBER(10), EXCEL_NUMBER(3)).number == 1.0);
360
+ assert(mod(EXCEL_NUMBER(10), EXCEL_NUMBER(5)).number == 0.0);
350
361
  // ... should be possible for the the arguments to be strings, if they convert to a number
351
- assert(mod(new_excel_string("3.5"),new_excel_string("2")).number == 1.5);
362
+ assert(mod(EXCEL_STRING("3.5"),EXCEL_STRING("2")).number == 1.5);
352
363
  // ... should treat BLANK as zero
353
- assert(mod(BLANK,new_excel_number(10)).number == 0);
354
- assert(mod(new_excel_number(10),BLANK).type == ExcelError);
364
+ assert(mod(BLANK,EXCEL_NUMBER(10)).number == 0);
365
+ assert(mod(EXCEL_NUMBER(10),BLANK).type == ExcelError);
355
366
  assert(mod(BLANK,BLANK).type == ExcelError);
356
367
  // ... should treat true as 1 and FALSE as 0
357
- assert((mod(new_excel_number(1.1),TRUE).number - 0.1) < 0.001);
358
- assert(mod(new_excel_number(1.1),FALSE).type == ExcelError);
359
- assert(mod(FALSE,new_excel_number(10)).number == 0);
368
+ assert((mod(EXCEL_NUMBER(1.1),TRUE).number - 0.1) < 0.001);
369
+ assert(mod(EXCEL_NUMBER(1.1),FALSE).type == ExcelError);
370
+ assert(mod(FALSE,EXCEL_NUMBER(10)).number == 0);
360
371
  // ... should return an error when given inappropriate arguments
361
- assert(mod(new_excel_string("Asdasddf"),new_excel_string("adsfads")).type == ExcelError);
372
+ assert(mod(EXCEL_STRING("Asdasddf"),EXCEL_STRING("adsfads")).type == ExcelError);
362
373
  // ... should return an error if an argument is an error
363
- assert(mod(new_excel_number(1),VALUE).type == ExcelError);
364
- assert(mod(VALUE,new_excel_number(1)).type == ExcelError);
374
+ assert(mod(EXCEL_NUMBER(1),VALUE).type == ExcelError);
375
+ assert(mod(VALUE,EXCEL_NUMBER(1)).type == ExcelError);
365
376
  assert(mod(VALUE,VALUE).type == ExcelError);
366
377
 
367
378
  // Test more than or equal to on
368
379
  // .. numbers
369
- assert(more_than_or_equal(ONE,new_excel_number(2)).number == false);
380
+ assert(more_than_or_equal(ONE,EXCEL_NUMBER(2)).number == false);
370
381
  assert(more_than_or_equal(ONE,ONE).number == true);
371
- assert(more_than_or_equal(ONE,new_excel_number(0)).number == true);
382
+ assert(more_than_or_equal(ONE,EXCEL_NUMBER(0)).number == true);
372
383
  // .. booleans
373
384
  assert(more_than_or_equal(FALSE,FALSE).number == true);
374
385
  assert(more_than_or_equal(FALSE,TRUE).number == false);
375
386
  assert(more_than_or_equal(TRUE,FALSE).number == true);
376
387
  assert(more_than_or_equal(TRUE,TRUE).number == true);
377
388
  // ..strings
378
- assert(more_than_or_equal(new_excel_string("HELLO"),new_excel_string("Ardvark")).number == true);
379
- assert(more_than_or_equal(new_excel_string("HELLO"),new_excel_string("world")).number == false);
380
- assert(more_than_or_equal(new_excel_string("HELLO"),new_excel_string("hello")).number == true);
389
+ assert(more_than_or_equal(EXCEL_STRING("HELLO"),EXCEL_STRING("Ardvark")).number == true);
390
+ assert(more_than_or_equal(EXCEL_STRING("HELLO"),EXCEL_STRING("world")).number == false);
391
+ assert(more_than_or_equal(EXCEL_STRING("HELLO"),EXCEL_STRING("hello")).number == true);
381
392
  // ..blanks
382
393
  assert(more_than_or_equal(BLANK,BLANK).number == true);
383
394
  assert(more_than_or_equal(BLANK,ONE).number == false);
384
- assert(more_than_or_equal(BLANK,new_excel_number(-1)).number == true);
395
+ assert(more_than_or_equal(BLANK,EXCEL_NUMBER(-1)).number == true);
385
396
  assert(more_than_or_equal(ONE,BLANK).number == true);
386
- assert(more_than_or_equal(new_excel_number(-1),BLANK).number == false);
397
+ assert(more_than_or_equal(EXCEL_NUMBER(-1),BLANK).number == false);
387
398
 
388
399
  // Test negative
389
400
  // ... should return the negative of its arguments
390
- assert(negative(new_excel_number(1)).number == -1);
391
- assert(negative(new_excel_number(-1)).number == 1);
401
+ assert(negative(EXCEL_NUMBER(1)).number == -1);
402
+ assert(negative(EXCEL_NUMBER(-1)).number == 1);
392
403
  // ... should treat strings that only contain numbers as numbers
393
- assert(negative(new_excel_string("10")).number == -10);
394
- assert(negative(new_excel_string("-1.3")).number == 1.3);
404
+ assert(negative(EXCEL_STRING("10")).number == -10);
405
+ assert(negative(EXCEL_STRING("-1.3")).number == 1.3);
395
406
  // ... should return an error when given inappropriate arguments
396
- assert(negative(new_excel_string("Asdasddf")).type == ExcelError);
407
+ assert(negative(EXCEL_STRING("Asdasddf")).type == ExcelError);
397
408
  // ... should treat BLANK as zero
398
409
  assert(negative(BLANK).number == 0);
399
410
 
400
411
  // Test PMT(rate,number_of_periods,present_value) - optional arguments not yet implemented
401
412
  // ... should calculate the monthly payment required for a given principal, interest rate and loan period
402
- assert((pmt(new_excel_number(0.1),new_excel_number(10),new_excel_number(100)).number - -16.27) < 0.01);
403
- assert((pmt(new_excel_number(0.0123),new_excel_number(99.1),new_excel_number(123.32)).number - -2.159) < 0.01);
404
- assert((pmt(new_excel_number(0),new_excel_number(2),new_excel_number(10)).number - -5) < 0.01);
413
+ assert((pmt(EXCEL_NUMBER(0.1),EXCEL_NUMBER(10),EXCEL_NUMBER(100)).number - -16.27) < 0.01);
414
+ assert((pmt(EXCEL_NUMBER(0.0123),EXCEL_NUMBER(99.1),EXCEL_NUMBER(123.32)).number - -2.159) < 0.01);
415
+ assert((pmt(EXCEL_NUMBER(0),EXCEL_NUMBER(2),EXCEL_NUMBER(10)).number - -5) < 0.01);
405
416
 
406
417
  // Test power
407
418
  // ... should return power of its arguments
408
- assert(power(new_excel_number(2),new_excel_number(3)).number == 8);
409
- assert(power(new_excel_number(4.0),new_excel_number(0.5)).number == 2.0);
410
- assert(power(new_excel_number(-4.0),new_excel_number(0.5)).type == ExcelError);
419
+ assert(power(EXCEL_NUMBER(2),EXCEL_NUMBER(3)).number == 8);
420
+ assert(power(EXCEL_NUMBER(4.0),EXCEL_NUMBER(0.5)).number == 2.0);
421
+ assert(power(EXCEL_NUMBER(-4.0),EXCEL_NUMBER(0.5)).type == ExcelError);
411
422
 
412
423
  // Test round
413
- assert(excel_round(new_excel_number(1.1), new_excel_number(0)).number == 1.0);
414
- assert(excel_round(new_excel_number(1.5), new_excel_number(0)).number == 2.0);
415
- assert(excel_round(new_excel_number(1.56),new_excel_number(1)).number == 1.6);
416
- assert(excel_round(new_excel_number(-1.56),new_excel_number(1)).number == -1.6);
424
+ assert(excel_round(EXCEL_NUMBER(1.1), EXCEL_NUMBER(0)).number == 1.0);
425
+ assert(excel_round(EXCEL_NUMBER(1.5), EXCEL_NUMBER(0)).number == 2.0);
426
+ assert(excel_round(EXCEL_NUMBER(1.56),EXCEL_NUMBER(1)).number == 1.6);
427
+ assert(excel_round(EXCEL_NUMBER(-1.56),EXCEL_NUMBER(1)).number == -1.6);
417
428
 
418
429
  // Test rounddown
419
- assert(rounddown(new_excel_number(1.1), new_excel_number(0)).number == 1.0);
420
- assert(rounddown(new_excel_number(1.5), new_excel_number(0)).number == 1.0);
421
- assert(rounddown(new_excel_number(1.56),new_excel_number(1)).number == 1.5);
422
- assert(rounddown(new_excel_number(-1.56),new_excel_number(1)).number == -1.5);
430
+ assert(rounddown(EXCEL_NUMBER(1.1), EXCEL_NUMBER(0)).number == 1.0);
431
+ assert(rounddown(EXCEL_NUMBER(1.5), EXCEL_NUMBER(0)).number == 1.0);
432
+ assert(rounddown(EXCEL_NUMBER(1.56),EXCEL_NUMBER(1)).number == 1.5);
433
+ assert(rounddown(EXCEL_NUMBER(-1.56),EXCEL_NUMBER(1)).number == -1.5);
423
434
 
424
435
  // Test int
425
- assert(excel_int(new_excel_number(8.9)).number == 8.0);
426
- assert(excel_int(new_excel_number(-8.9)).number == -9.0);
436
+ assert(excel_int(EXCEL_NUMBER(8.9)).number == 8.0);
437
+ assert(excel_int(EXCEL_NUMBER(-8.9)).number == -9.0);
427
438
 
428
439
  // Test roundup
429
- assert(roundup(new_excel_number(1.1), new_excel_number(0)).number == 2.0);
430
- assert(roundup(new_excel_number(1.5), new_excel_number(0)).number == 2.0);
431
- assert(roundup(new_excel_number(1.56),new_excel_number(1)).number == 1.6);
432
- assert(roundup(new_excel_number(-1.56),new_excel_number(1)).number == -1.6);
440
+ assert(roundup(EXCEL_NUMBER(1.1), EXCEL_NUMBER(0)).number == 2.0);
441
+ assert(roundup(EXCEL_NUMBER(1.5), EXCEL_NUMBER(0)).number == 2.0);
442
+ assert(roundup(EXCEL_NUMBER(1.56),EXCEL_NUMBER(1)).number == 1.6);
443
+ assert(roundup(EXCEL_NUMBER(-1.56),EXCEL_NUMBER(1)).number == -1.6);
433
444
 
434
445
  // Test string joining
435
- ExcelValue string_join_array_1[] = {new_excel_string("Hello "), new_excel_string("world")};
436
- ExcelValue string_join_array_2[] = {new_excel_string("Hello "), new_excel_string("world"), new_excel_string("!")};
437
- ExcelValue string_join_array_3[] = {new_excel_string("Top "), new_excel_number(10.0)};
438
- ExcelValue string_join_array_4[] = {new_excel_string("Top "), new_excel_number(10.5)};
439
- ExcelValue string_join_array_5[] = {new_excel_string("Top "), TRUE, FALSE};
446
+ ExcelValue string_join_array_1[] = {EXCEL_STRING("Hello "), EXCEL_STRING("world")};
447
+ ExcelValue string_join_array_2[] = {EXCEL_STRING("Hello "), EXCEL_STRING("world"), EXCEL_STRING("!")};
448
+ ExcelValue string_join_array_3[] = {EXCEL_STRING("Top "), EXCEL_NUMBER(10.0)};
449
+ ExcelValue string_join_array_4[] = {EXCEL_STRING("Top "), EXCEL_NUMBER(10.5)};
450
+ ExcelValue string_join_array_5[] = {EXCEL_STRING("Top "), TRUE, FALSE};
440
451
  // ... should return a string by combining its arguments
441
452
  // inspect_excel_value(string_join(2, string_join_array_1));
442
453
  assert(string_join(2, string_join_array_1).string[6] == 'w');
443
454
  assert(string_join(2, string_join_array_1).string[11] == '\0');
444
455
  // ... should cope with an arbitrary number of arguments
445
456
  assert(string_join(3, string_join_array_2).string[11] == '!');
446
- assert(string_join(3, string_join_array_3).string[12] == '\0');
457
+ assert_equal(EXCEL_STRING("Top 10"), string_join(2, string_join_array_3), "String join with numbers");
447
458
  // ... should convert values to strings as it goes
448
459
  assert(string_join(2, string_join_array_3).string[4] == '1');
449
460
  assert(string_join(2, string_join_array_3).string[5] == '0');
@@ -457,100 +468,107 @@ int test_functions() {
457
468
  // ... should convert TRUE and FALSE into strings
458
469
  assert(string_join(3,string_join_array_5).string[4] == 'T');
459
470
  // Should deal with very long string joins
460
- ExcelValue string_join_array_6[] = {new_excel_string("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"), new_excel_string("012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789")};
471
+ ExcelValue string_join_array_6[] = {EXCEL_STRING("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"), EXCEL_STRING("012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789")};
461
472
  assert(string_join(2, string_join_array_6).string[0] == '0');
462
- free_all_allocated_memory();
473
+ // Even ones that are greater than 200 characters
474
+ ExcelValue string_join_array_6b[] = {EXCEL_STRING("Can we increase crop yields? Between 1987 and 2007 they increased by around 1.9% per year globally, but over recent years the annual % increase has been lower than this. Current average food energy yields are "), EXCEL_STRING("Can we increase crop yields? Between 1987 and 2007 they increased by around 1.9% per year globally, but over recent years the annual % increase has been lower than this. Current average food energy yields are ")};
475
+ assert_equal(EXCEL_STRING("Can we increase crop yields? Between 1987 and 2007 they increased by around 1.9% per year globally, but over recent years the annual % increase has been lower than this. Current average food energy yields are Can we increase crop yields? Between 1987 and 2007 they increased by around 1.9% per year globally, but over recent years the annual % increase has been lower than this. Current average food energy yields are "), string_join(2, string_join_array_6b), "String join > 200 character");
476
+ // Should deal with some edge cases
477
+ ExcelValue string_join_array_7[] = { NA };
478
+ assert_equal(NA, string_join(1, string_join_array_7), "String_join should return an error when passed an error");
479
+ ExcelValue string_join_array_8[] = { EXCEL_RANGE(string_join_array_7, 1, 1) };
480
+ assert_equal(VALUE, string_join(1, string_join_array_8), "String_join should return VALUE when passed a range");
463
481
 
464
482
  // Test SUBTOTAL function
465
- ExcelValue subtotal_array_1[] = {new_excel_number(10),new_excel_number(100),BLANK};
466
- ExcelValue subtotal_array_1_v = new_excel_range(subtotal_array_1,3,1);
467
- ExcelValue subtotal_array_2[] = {new_excel_number(1),new_excel_string("two"),subtotal_array_1_v};
468
-
469
- // new_excel_number(1.0);
470
- // inspect_excel_value(new_excel_number(1.0));
471
- // inspect_excel_value(new_excel_range(subtotal_array_2,3,1));
472
- // inspect_excel_value(subtotal(new_excel_number(1.0),3,subtotal_array_2));
473
-
474
- assert(subtotal(new_excel_number(1.0),3,subtotal_array_2).number == 111.0/3.0);
475
- assert(subtotal(new_excel_number(2.0),3,subtotal_array_2).number == 3);
476
- assert(subtotal(new_excel_number(3.0),7, count_a_test_array_1).number == 6);
477
- assert(subtotal(new_excel_number(3.0),3,subtotal_array_2).number == 4);
478
- assert(subtotal(new_excel_number(9.0),3,subtotal_array_2).number == 111);
479
- assert(subtotal(new_excel_number(101.0),3,subtotal_array_2).number == 111.0/3.0);
480
- assert(subtotal(new_excel_number(102.0),3,subtotal_array_2).number == 3);
481
- assert(subtotal(new_excel_number(103.0),3,subtotal_array_2).number == 4);
482
- assert(subtotal(new_excel_number(109.0),3,subtotal_array_2).number == 111);
483
+ ExcelValue subtotal_array_1[] = {EXCEL_NUMBER(10),EXCEL_NUMBER(100),BLANK};
484
+ ExcelValue subtotal_array_1_v = EXCEL_RANGE(subtotal_array_1,3,1);
485
+ ExcelValue subtotal_array_2[] = {EXCEL_NUMBER(1),EXCEL_STRING("two"),subtotal_array_1_v};
486
+
487
+ // EXCEL_NUMBER(1.0);
488
+ // inspect_excel_value(EXCEL_NUMBER(1.0));
489
+ // inspect_excel_value(EXCEL_RANGE(subtotal_array_2,3,1));
490
+ // inspect_excel_value(subtotal(EXCEL_NUMBER(1.0),3,subtotal_array_2));
491
+
492
+ assert(subtotal(EXCEL_NUMBER(1.0),3,subtotal_array_2).number == 111.0/3.0);
493
+ assert(subtotal(EXCEL_NUMBER(2.0),3,subtotal_array_2).number == 3);
494
+ assert(subtotal(EXCEL_NUMBER(3.0),7, count_a_test_array_1).number == 6);
495
+ assert(subtotal(EXCEL_NUMBER(3.0),3,subtotal_array_2).number == 4);
496
+ assert(subtotal(EXCEL_NUMBER(9.0),3,subtotal_array_2).number == 111);
497
+ assert(subtotal(EXCEL_NUMBER(101.0),3,subtotal_array_2).number == 111.0/3.0);
498
+ assert(subtotal(EXCEL_NUMBER(102.0),3,subtotal_array_2).number == 3);
499
+ assert(subtotal(EXCEL_NUMBER(103.0),3,subtotal_array_2).number == 4);
500
+ assert(subtotal(EXCEL_NUMBER(109.0),3,subtotal_array_2).number == 111);
483
501
 
484
502
  // Test SUMIFS function
485
- ExcelValue sumifs_array_1[] = {new_excel_number(10),new_excel_number(100),BLANK};
486
- ExcelValue sumifs_array_1_v = new_excel_range(sumifs_array_1,3,1);
487
- ExcelValue sumifs_array_2[] = {new_excel_string("pear"),new_excel_string("bear"),new_excel_string("apple")};
488
- ExcelValue sumifs_array_2_v = new_excel_range(sumifs_array_2,3,1);
489
- ExcelValue sumifs_array_3[] = {new_excel_number(1),new_excel_number(2),new_excel_number(3),new_excel_number(4),new_excel_number(5),new_excel_number(5)};
490
- ExcelValue sumifs_array_3_v = new_excel_range(sumifs_array_3,6,1);
491
- ExcelValue sumifs_array_4[] = {new_excel_string("CO2"),new_excel_string("CH4"),new_excel_string("N2O"),new_excel_string("CH4"),new_excel_string("N2O"),new_excel_string("CO2")};
492
- ExcelValue sumifs_array_4_v = new_excel_range(sumifs_array_4,6,1);
493
- ExcelValue sumifs_array_5[] = {new_excel_string("1A"),new_excel_string("1A"),new_excel_string("1A"),new_excel_number(4),new_excel_number(4),new_excel_number(5)};
494
- ExcelValue sumifs_array_5_v = new_excel_range(sumifs_array_5,6,1);
503
+ ExcelValue sumifs_array_1[] = {EXCEL_NUMBER(10),EXCEL_NUMBER(100),BLANK};
504
+ ExcelValue sumifs_array_1_v = EXCEL_RANGE(sumifs_array_1,3,1);
505
+ ExcelValue sumifs_array_2[] = {EXCEL_STRING("pear"),EXCEL_STRING("bear"),EXCEL_STRING("apple")};
506
+ ExcelValue sumifs_array_2_v = EXCEL_RANGE(sumifs_array_2,3,1);
507
+ ExcelValue sumifs_array_3[] = {EXCEL_NUMBER(1),EXCEL_NUMBER(2),EXCEL_NUMBER(3),EXCEL_NUMBER(4),EXCEL_NUMBER(5),EXCEL_NUMBER(5)};
508
+ ExcelValue sumifs_array_3_v = EXCEL_RANGE(sumifs_array_3,6,1);
509
+ ExcelValue sumifs_array_4[] = {EXCEL_STRING("CO2"),EXCEL_STRING("CH4"),EXCEL_STRING("N2O"),EXCEL_STRING("CH4"),EXCEL_STRING("N2O"),EXCEL_STRING("CO2")};
510
+ ExcelValue sumifs_array_4_v = EXCEL_RANGE(sumifs_array_4,6,1);
511
+ ExcelValue sumifs_array_5[] = {EXCEL_STRING("1A"),EXCEL_STRING("1A"),EXCEL_STRING("1A"),EXCEL_NUMBER(4),EXCEL_NUMBER(4),EXCEL_NUMBER(5)};
512
+ ExcelValue sumifs_array_5_v = EXCEL_RANGE(sumifs_array_5,6,1);
495
513
 
496
514
  // ... should only sum values that meet all of the criteria
497
- ExcelValue sumifs_array_6[] = { sumifs_array_1_v, new_excel_number(10), sumifs_array_2_v, new_excel_string("Bear") };
515
+ ExcelValue sumifs_array_6[] = { sumifs_array_1_v, EXCEL_NUMBER(10), sumifs_array_2_v, EXCEL_STRING("Bear") };
498
516
  assert(sumifs(sumifs_array_1_v,4,sumifs_array_6).number == 0.0);
499
517
 
500
- ExcelValue sumifs_array_7[] = { sumifs_array_1_v, new_excel_number(10), sumifs_array_2_v, new_excel_string("Pear") };
518
+ ExcelValue sumifs_array_7[] = { sumifs_array_1_v, EXCEL_NUMBER(10), sumifs_array_2_v, EXCEL_STRING("Pear") };
501
519
  assert(sumifs(sumifs_array_1_v,4,sumifs_array_7).number == 10.0);
502
520
 
503
521
  // ... should work when single cells are given where ranges expected
504
- ExcelValue sumifs_array_8[] = { new_excel_string("CAR"), new_excel_string("CAR"), new_excel_string("FCV"), new_excel_string("FCV")};
505
- assert(sumifs(new_excel_number(0.143897265452564), 4, sumifs_array_8).number == 0.143897265452564);
522
+ ExcelValue sumifs_array_8[] = { EXCEL_STRING("CAR"), EXCEL_STRING("CAR"), EXCEL_STRING("FCV"), EXCEL_STRING("FCV")};
523
+ assert(sumifs(EXCEL_NUMBER(0.143897265452564), 4, sumifs_array_8).number == 0.143897265452564);
506
524
 
507
525
  // ... should match numbers with strings that contain numbers
508
- ExcelValue sumifs_array_9[] = { new_excel_number(10), new_excel_string("10.0")};
509
- assert(sumifs(new_excel_number(100),2,sumifs_array_9).number == 100);
526
+ ExcelValue sumifs_array_9[] = { EXCEL_NUMBER(10), EXCEL_STRING("10.0")};
527
+ assert(sumifs(EXCEL_NUMBER(100),2,sumifs_array_9).number == 100);
510
528
 
511
- ExcelValue sumifs_array_9b[] = { new_excel_string("10"), new_excel_number(10.0)};
512
- assert(sumifs(new_excel_number(100),2,sumifs_array_9b).number == 100);
529
+ ExcelValue sumifs_array_9b[] = { EXCEL_STRING("10"), EXCEL_NUMBER(10.0)};
530
+ assert(sumifs(EXCEL_NUMBER(100),2,sumifs_array_9b).number == 100);
513
531
 
514
- ExcelValue sumifs_array_10[] = { sumifs_array_4_v, new_excel_string("CO2"), sumifs_array_5_v, new_excel_number(2)};
532
+ ExcelValue sumifs_array_10[] = { sumifs_array_4_v, EXCEL_STRING("CO2"), sumifs_array_5_v, EXCEL_NUMBER(2)};
515
533
  assert(sumifs(sumifs_array_3_v,4, sumifs_array_10).number == 0);
516
534
 
517
535
  // ... should match with strings that contain criteria
518
- ExcelValue sumifs_array_10a[] = { sumifs_array_3_v, new_excel_string("=5")};
536
+ ExcelValue sumifs_array_10a[] = { sumifs_array_3_v, EXCEL_STRING("=5")};
519
537
  assert(sumifs(sumifs_array_3_v,2, sumifs_array_10a).number == 10);
520
538
 
521
- ExcelValue sumifs_array_10b[] = { sumifs_array_3_v, new_excel_string("<>3")};
539
+ ExcelValue sumifs_array_10b[] = { sumifs_array_3_v, EXCEL_STRING("<>3")};
522
540
  assert(sumifs(sumifs_array_3_v,2, sumifs_array_10b).number == 17);
523
541
 
524
- ExcelValue sumifs_array_10c[] = { sumifs_array_3_v, new_excel_string("<3")};
542
+ ExcelValue sumifs_array_10c[] = { sumifs_array_3_v, EXCEL_STRING("<3")};
525
543
  assert(sumifs(sumifs_array_3_v,2, sumifs_array_10c).number == 3);
526
544
 
527
- ExcelValue sumifs_array_10d[] = { sumifs_array_3_v, new_excel_string("<=3")};
545
+ ExcelValue sumifs_array_10d[] = { sumifs_array_3_v, EXCEL_STRING("<=3")};
528
546
  assert(sumifs(sumifs_array_3_v,2, sumifs_array_10d).number == 6);
529
547
 
530
- ExcelValue sumifs_array_10e[] = { sumifs_array_3_v, new_excel_string(">3")};
548
+ ExcelValue sumifs_array_10e[] = { sumifs_array_3_v, EXCEL_STRING(">3")};
531
549
  assert(sumifs(sumifs_array_3_v,2, sumifs_array_10e).number == 14);
532
550
 
533
- ExcelValue sumifs_array_10f[] = { sumifs_array_3_v, new_excel_string(">=3")};
551
+ ExcelValue sumifs_array_10f[] = { sumifs_array_3_v, EXCEL_STRING(">=3")};
534
552
  assert(sumifs(sumifs_array_3_v,2, sumifs_array_10f).number == 17);
535
553
 
536
554
  // ... BLANK in check range should match empty strings, BLANK in criteria should match zero
537
- ExcelValue sumifs_array_11[] = { BLANK, new_excel_number(0)};
538
- assert(sumifs(new_excel_number(100),2,sumifs_array_11).number == 0);
555
+ ExcelValue sumifs_array_11[] = { BLANK, EXCEL_NUMBER(0)};
556
+ assert(sumifs(EXCEL_NUMBER(100),2,sumifs_array_11).number == 0);
539
557
 
540
- ExcelValue sumifs_array_11b[] = { BLANK, new_excel_string("")};
541
- assert(sumifs(new_excel_number(100),2,sumifs_array_11b).number == 100);
558
+ ExcelValue sumifs_array_11b[] = { BLANK, EXCEL_STRING("")};
559
+ assert(sumifs(EXCEL_NUMBER(100),2,sumifs_array_11b).number == 100);
542
560
 
543
- ExcelValue sumifs_array_11c[] = { new_excel_string(""), BLANK};
544
- assert(sumifs(new_excel_number(100),2,sumifs_array_11c).number == 0);
561
+ ExcelValue sumifs_array_11c[] = { EXCEL_STRING(""), BLANK};
562
+ assert(sumifs(EXCEL_NUMBER(100),2,sumifs_array_11c).number == 0);
545
563
 
546
- ExcelValue sumifs_array_12[] = {new_excel_number(0), BLANK};
547
- assert(sumifs(new_excel_number(100),2,sumifs_array_12).number == 100);
564
+ ExcelValue sumifs_array_12[] = {EXCEL_NUMBER(0), BLANK};
565
+ assert(sumifs(EXCEL_NUMBER(100),2,sumifs_array_12).number == 100);
548
566
 
549
567
  ExcelValue sumifs_array_13[] = {BLANK, BLANK};
550
- assert(sumifs(new_excel_number(100),2,sumifs_array_13).number == 0);
568
+ assert(sumifs(EXCEL_NUMBER(100),2,sumifs_array_13).number == 0);
551
569
 
552
- ExcelValue sumifs_array_14[] = {new_excel_number(10), BLANK};
553
- assert(sumifs(new_excel_number(100),2,sumifs_array_14).number == 0);
570
+ ExcelValue sumifs_array_14[] = {EXCEL_NUMBER(10), BLANK};
571
+ assert(sumifs(EXCEL_NUMBER(100),2,sumifs_array_14).number == 0);
554
572
 
555
573
  // ... should return an error if range argument is an error
556
574
  ExcelValue sumifs_array_15[] = {ONE, ONE};
@@ -559,36 +577,36 @@ int test_functions() {
559
577
 
560
578
  // Test SUMIF
561
579
  // ... where there is only a check range
562
- assert(sumif_2(sumifs_array_1_v,new_excel_string(">0")).number == 110.0);
563
- assert(sumif_2(sumifs_array_1_v,new_excel_string(">10")).number == 100.0);
564
- assert(sumif_2(sumifs_array_1_v,new_excel_string("<100")).number == 10.0);
580
+ assert(sumif_2(sumifs_array_1_v,EXCEL_STRING(">0")).number == 110.0);
581
+ assert(sumif_2(sumifs_array_1_v,EXCEL_STRING(">10")).number == 100.0);
582
+ assert(sumif_2(sumifs_array_1_v,EXCEL_STRING("<100")).number == 10.0);
565
583
 
566
584
  // ... where there is a seprate sum range
567
- ExcelValue sumif_array_1[] = {new_excel_number(15),new_excel_number(20), new_excel_number(30)};
568
- ExcelValue sumif_array_1_v = new_excel_range(sumif_array_1,3,1);
569
- assert(sumif(sumifs_array_1_v,new_excel_string("10"),sumif_array_1_v).number == 15);
585
+ ExcelValue sumif_array_1[] = {EXCEL_NUMBER(15),EXCEL_NUMBER(20), EXCEL_NUMBER(30)};
586
+ ExcelValue sumif_array_1_v = EXCEL_RANGE(sumif_array_1,3,1);
587
+ assert(sumif(sumifs_array_1_v,EXCEL_STRING("10"),sumif_array_1_v).number == 15);
570
588
 
571
589
 
572
590
  // Test SUMPRODUCT
573
- ExcelValue sumproduct_1[] = { new_excel_number(10), new_excel_number(100), BLANK};
574
- ExcelValue sumproduct_2[] = { BLANK, new_excel_number(100), new_excel_number(10), BLANK};
591
+ ExcelValue sumproduct_1[] = { EXCEL_NUMBER(10), EXCEL_NUMBER(100), BLANK};
592
+ ExcelValue sumproduct_2[] = { BLANK, EXCEL_NUMBER(100), EXCEL_NUMBER(10), BLANK};
575
593
  ExcelValue sumproduct_3[] = { BLANK };
576
- ExcelValue sumproduct_4[] = { new_excel_number(10), new_excel_number(100), new_excel_number(1000)};
577
- ExcelValue sumproduct_5[] = { new_excel_number(1), new_excel_number(2), new_excel_number(3)};
578
- ExcelValue sumproduct_6[] = { new_excel_number(1), new_excel_number(2), new_excel_number(4), new_excel_number(5)};
579
- ExcelValue sumproduct_7[] = { new_excel_number(10), new_excel_number(20), new_excel_number(40), new_excel_number(50)};
580
- ExcelValue sumproduct_8[] = { new_excel_number(11), new_excel_number(21), new_excel_number(41), new_excel_number(51)};
594
+ ExcelValue sumproduct_4[] = { EXCEL_NUMBER(10), EXCEL_NUMBER(100), EXCEL_NUMBER(1000)};
595
+ ExcelValue sumproduct_5[] = { EXCEL_NUMBER(1), EXCEL_NUMBER(2), EXCEL_NUMBER(3)};
596
+ ExcelValue sumproduct_6[] = { EXCEL_NUMBER(1), EXCEL_NUMBER(2), EXCEL_NUMBER(4), EXCEL_NUMBER(5)};
597
+ ExcelValue sumproduct_7[] = { EXCEL_NUMBER(10), EXCEL_NUMBER(20), EXCEL_NUMBER(40), EXCEL_NUMBER(50)};
598
+ ExcelValue sumproduct_8[] = { EXCEL_NUMBER(11), EXCEL_NUMBER(21), EXCEL_NUMBER(41), EXCEL_NUMBER(51)};
581
599
  ExcelValue sumproduct_9[] = { BLANK, BLANK };
582
600
 
583
- ExcelValue sumproduct_1_v = new_excel_range( sumproduct_1, 3, 1);
584
- ExcelValue sumproduct_2_v = new_excel_range( sumproduct_2, 3, 1);
585
- ExcelValue sumproduct_3_v = new_excel_range( sumproduct_3, 1, 1);
586
- // ExcelValue sumproduct_4_v = new_excel_range( sumproduct_4, 1, 3); // Unused
587
- ExcelValue sumproduct_5_v = new_excel_range( sumproduct_5, 3, 1);
588
- ExcelValue sumproduct_6_v = new_excel_range( sumproduct_6, 2, 2);
589
- ExcelValue sumproduct_7_v = new_excel_range( sumproduct_7, 2, 2);
590
- ExcelValue sumproduct_8_v = new_excel_range( sumproduct_8, 2, 2);
591
- ExcelValue sumproduct_9_v = new_excel_range( sumproduct_9, 2, 1);
601
+ ExcelValue sumproduct_1_v = EXCEL_RANGE( sumproduct_1, 3, 1);
602
+ ExcelValue sumproduct_2_v = EXCEL_RANGE( sumproduct_2, 3, 1);
603
+ ExcelValue sumproduct_3_v = EXCEL_RANGE( sumproduct_3, 1, 1);
604
+ // ExcelValue sumproduct_4_v = EXCEL_RANGE( sumproduct_4, 1, 3); // Unused
605
+ ExcelValue sumproduct_5_v = EXCEL_RANGE( sumproduct_5, 3, 1);
606
+ ExcelValue sumproduct_6_v = EXCEL_RANGE( sumproduct_6, 2, 2);
607
+ ExcelValue sumproduct_7_v = EXCEL_RANGE( sumproduct_7, 2, 2);
608
+ ExcelValue sumproduct_8_v = EXCEL_RANGE( sumproduct_8, 2, 2);
609
+ ExcelValue sumproduct_9_v = EXCEL_RANGE( sumproduct_9, 2, 1);
592
610
 
593
611
  // ... should multiply together and then sum the elements in row or column areas given as arguments
594
612
  ExcelValue sumproducta_1[] = {sumproduct_1_v, sumproduct_2_v};
@@ -611,7 +629,7 @@ int test_functions() {
611
629
  assert(sumproduct(3,sumproducta_5).number == 1*10*11 + 2*20*21 + 4*40*41 + 5*50*51);
612
630
 
613
631
  // ... should raise an error if BLANK values outside of an array
614
- ExcelValue sumproducta_6[] = {BLANK,new_excel_number(1)};
632
+ ExcelValue sumproducta_6[] = {BLANK,EXCEL_NUMBER(1)};
615
633
  assert(sumproduct(2,sumproducta_6).type == ExcelError);
616
634
 
617
635
  // ... should ignore non-numeric values within an array
@@ -623,110 +641,111 @@ int test_functions() {
623
641
  assert(sumproduct(1,sumproducta_8).type == ExcelError);
624
642
 
625
643
  // Test VLOOKUP
626
- ExcelValue vlookup_a1[] = {new_excel_number(1),new_excel_number(10),new_excel_number(2),new_excel_number(20),new_excel_number(3),new_excel_number(30)};
627
- ExcelValue vlookup_a2[] = {new_excel_string("hello"),new_excel_number(10),new_excel_number(2),new_excel_number(20),new_excel_number(3),new_excel_number(30)};
628
- ExcelValue vlookup_a3[] = {BLANK,new_excel_number(10),new_excel_number(2),new_excel_number(20),new_excel_number(3),new_excel_number(30)};
629
- ExcelValue vlookup_a1_v = new_excel_range(vlookup_a1,3,2);
630
- ExcelValue vlookup_a2_v = new_excel_range(vlookup_a2,3,2);
631
- ExcelValue vlookup_a3_v = new_excel_range(vlookup_a3,3,2);
644
+ ExcelValue vlookup_a1[] = {EXCEL_NUMBER(1),EXCEL_NUMBER(10),EXCEL_NUMBER(2),EXCEL_NUMBER(20),EXCEL_NUMBER(3),EXCEL_NUMBER(30)};
645
+ ExcelValue vlookup_a2[] = {EXCEL_STRING("hello"),EXCEL_NUMBER(10),EXCEL_NUMBER(2),EXCEL_NUMBER(20),EXCEL_NUMBER(3),EXCEL_NUMBER(30)};
646
+ ExcelValue vlookup_a3[] = {BLANK,EXCEL_NUMBER(10),EXCEL_NUMBER(2),EXCEL_NUMBER(20),EXCEL_NUMBER(3),EXCEL_NUMBER(30)};
647
+ ExcelValue vlookup_a1_v = EXCEL_RANGE(vlookup_a1,3,2);
648
+ ExcelValue vlookup_a2_v = EXCEL_RANGE(vlookup_a2,3,2);
649
+ ExcelValue vlookup_a3_v = EXCEL_RANGE(vlookup_a3,3,2);
632
650
  // ... should match the first argument against the first column of the table in the second argument, returning the value in the column specified by the third argument
633
- assert(vlookup_3(new_excel_number(2.0),vlookup_a1_v,new_excel_number(2)).number == 20);
634
- assert(vlookup_3(new_excel_number(1.5),vlookup_a1_v,new_excel_number(2)).number == 10);
635
- assert(vlookup_3(new_excel_number(0.5),vlookup_a1_v,new_excel_number(2)).type == ExcelError);
636
- assert(vlookup_3(new_excel_number(10),vlookup_a1_v,new_excel_number(2)).number == 30);
637
- assert(vlookup_3(new_excel_number(2.6),vlookup_a1_v,new_excel_number(2)).number == 20);
651
+ assert(vlookup_3(EXCEL_NUMBER(2.0),vlookup_a1_v,EXCEL_NUMBER(2)).number == 20);
652
+ assert(vlookup_3(EXCEL_NUMBER(1.5),vlookup_a1_v,EXCEL_NUMBER(2)).number == 10);
653
+ assert(vlookup_3(EXCEL_NUMBER(0.5),vlookup_a1_v,EXCEL_NUMBER(2)).type == ExcelError);
654
+ assert(vlookup_3(EXCEL_NUMBER(10),vlookup_a1_v,EXCEL_NUMBER(2)).number == 30);
655
+ assert(vlookup_3(EXCEL_NUMBER(2.6),vlookup_a1_v,EXCEL_NUMBER(2)).number == 20);
638
656
  // ... has a four argument variant that matches the lookup type
639
- assert(vlookup(new_excel_number(2.6),vlookup_a1_v,new_excel_number(2),TRUE).number == 20);
640
- assert(vlookup(new_excel_number(2.6),vlookup_a1_v,new_excel_number(2),FALSE).type == ExcelError);
641
- assert(vlookup(new_excel_string("HELLO"),vlookup_a2_v,new_excel_number(2),FALSE).number == 10);
642
- assert(vlookup(new_excel_string("HELMP"),vlookup_a2_v,new_excel_number(2),TRUE).number == 10);
657
+ assert(vlookup(EXCEL_NUMBER(2.6),vlookup_a1_v,EXCEL_NUMBER(2),TRUE).number == 20);
658
+ assert(vlookup(EXCEL_NUMBER(2.6),vlookup_a1_v,EXCEL_NUMBER(2),FALSE).type == ExcelError);
659
+ assert(vlookup(EXCEL_STRING("HELLO"),vlookup_a2_v,EXCEL_NUMBER(2),FALSE).number == 10);
660
+ assert(vlookup(EXCEL_STRING("HELMP"),vlookup_a2_v,EXCEL_NUMBER(2),TRUE).number == 10);
643
661
  // .. the four argument variant should accept 0 and 1 instead of TRUE and FALSE
644
- assert(vlookup(new_excel_string("HELLO"),vlookup_a2_v,new_excel_number(2),ZERO).number == 10);
645
- assert(vlookup(new_excel_string("HELMP"),vlookup_a2_v,new_excel_number(2),ONE).number == 10);
662
+ assert(vlookup(EXCEL_STRING("HELLO"),vlookup_a2_v,EXCEL_NUMBER(2),ZERO).number == 10);
663
+ assert(vlookup(EXCEL_STRING("HELMP"),vlookup_a2_v,EXCEL_NUMBER(2),ONE).number == 10);
646
664
  // ... BLANK should not match with anything" do
647
- assert(vlookup_3(BLANK,vlookup_a3_v,new_excel_number(2)).type == ExcelError);
665
+ assert(vlookup_3(BLANK,vlookup_a3_v,EXCEL_NUMBER(2)).type == ExcelError);
648
666
  // ... should return an error if an argument is an error" do
649
- assert(vlookup(VALUE,vlookup_a1_v,new_excel_number(2),FALSE).type == ExcelError);
650
- assert(vlookup(new_excel_number(2.0),VALUE,new_excel_number(2),FALSE).type == ExcelError);
651
- assert(vlookup(new_excel_number(2.0),vlookup_a1_v,VALUE,FALSE).type == ExcelError);
652
- assert(vlookup(new_excel_number(2.0),vlookup_a1_v,new_excel_number(2),VALUE).type == ExcelError);
667
+ assert(vlookup(VALUE,vlookup_a1_v,EXCEL_NUMBER(2),FALSE).type == ExcelError);
668
+ assert(vlookup(EXCEL_NUMBER(2.0),VALUE,EXCEL_NUMBER(2),FALSE).type == ExcelError);
669
+ assert(vlookup(EXCEL_NUMBER(2.0),vlookup_a1_v,VALUE,FALSE).type == ExcelError);
670
+ assert(vlookup(EXCEL_NUMBER(2.0),vlookup_a1_v,EXCEL_NUMBER(2),VALUE).type == ExcelError);
653
671
  assert(vlookup(VALUE,VALUE,VALUE,VALUE).type == ExcelError);
654
672
 
655
673
  // Test HLOOKUP
656
- ExcelValue hlookup_a1[] = {new_excel_number(1),new_excel_number(2),new_excel_number(3),new_excel_number(10),new_excel_number(20),new_excel_number(30)};
657
- ExcelValue hlookup_a2[] = {new_excel_string("hello"),new_excel_number(2),new_excel_number(3),new_excel_number(10),new_excel_number(20),new_excel_number(30)};
658
- ExcelValue hlookup_a3[] = {BLANK,new_excel_number(2),new_excel_number(3),new_excel_number(10),new_excel_number(20),new_excel_number(30)};
659
- ExcelValue hlookup_a1_v = new_excel_range(hlookup_a1,2,3);
660
- ExcelValue hlookup_a2_v = new_excel_range(hlookup_a2,2,3);
661
- ExcelValue hlookup_a3_v = new_excel_range(hlookup_a3,2,3);
674
+ ExcelValue hlookup_a1[] = {EXCEL_NUMBER(1),EXCEL_NUMBER(2),EXCEL_NUMBER(3),EXCEL_NUMBER(10),EXCEL_NUMBER(20),EXCEL_NUMBER(30)};
675
+ ExcelValue hlookup_a2[] = {EXCEL_STRING("hello"),EXCEL_NUMBER(2),EXCEL_NUMBER(3),EXCEL_NUMBER(10),EXCEL_NUMBER(20),EXCEL_NUMBER(30)};
676
+ ExcelValue hlookup_a3[] = {BLANK,EXCEL_NUMBER(2),EXCEL_NUMBER(3),EXCEL_NUMBER(10),EXCEL_NUMBER(20),EXCEL_NUMBER(30)};
677
+ ExcelValue hlookup_a1_v = EXCEL_RANGE(hlookup_a1,2,3);
678
+ ExcelValue hlookup_a2_v = EXCEL_RANGE(hlookup_a2,2,3);
679
+ ExcelValue hlookup_a3_v = EXCEL_RANGE(hlookup_a3,2,3);
662
680
  // ... should match the first argument against the first column of the table in the second argument, returning the value in the column specified by the third argument
663
- assert(hlookup_3(new_excel_number(2.0),hlookup_a1_v,new_excel_number(2)).number == 20);
664
- assert(hlookup_3(new_excel_number(1.5),hlookup_a1_v,new_excel_number(2)).number == 10);
665
- assert(hlookup_3(new_excel_number(0.5),hlookup_a1_v,new_excel_number(2)).type == ExcelError);
666
- assert(hlookup_3(new_excel_number(10),hlookup_a1_v,new_excel_number(2)).number == 30);
667
- assert(hlookup_3(new_excel_number(2.6),hlookup_a1_v,new_excel_number(2)).number == 20);
681
+ assert(hlookup_3(EXCEL_NUMBER(2.0),hlookup_a1_v,EXCEL_NUMBER(2)).number == 20);
682
+ assert(hlookup_3(EXCEL_NUMBER(1.5),hlookup_a1_v,EXCEL_NUMBER(2)).number == 10);
683
+ assert(hlookup_3(EXCEL_NUMBER(0.5),hlookup_a1_v,EXCEL_NUMBER(2)).type == ExcelError);
684
+ assert(hlookup_3(EXCEL_NUMBER(10),hlookup_a1_v,EXCEL_NUMBER(2)).number == 30);
685
+ assert(hlookup_3(EXCEL_NUMBER(2.6),hlookup_a1_v,EXCEL_NUMBER(2)).number == 20);
668
686
  // ... has a four argument variant that matches the lookup type
669
- assert(hlookup(new_excel_number(2.6),hlookup_a1_v,new_excel_number(2),TRUE).number == 20);
670
- assert(hlookup(new_excel_number(2.6),hlookup_a1_v,new_excel_number(2),FALSE).type == ExcelError);
671
- assert(hlookup(new_excel_string("HELLO"),hlookup_a2_v,new_excel_number(2),FALSE).number == 10);
672
- assert(hlookup(new_excel_string("HELMP"),hlookup_a2_v,new_excel_number(2),TRUE).number == 10);
687
+ assert(hlookup(EXCEL_NUMBER(2.6),hlookup_a1_v,EXCEL_NUMBER(2),TRUE).number == 20);
688
+ assert(hlookup(EXCEL_NUMBER(2.6),hlookup_a1_v,EXCEL_NUMBER(2),FALSE).type == ExcelError);
689
+ assert(hlookup(EXCEL_STRING("HELLO"),hlookup_a2_v,EXCEL_NUMBER(2),FALSE).number == 10);
690
+ assert(hlookup(EXCEL_STRING("HELMP"),hlookup_a2_v,EXCEL_NUMBER(2),TRUE).number == 10);
673
691
  // ... that four argument variant should accept 0 or 1 for the lookup type
674
- assert(hlookup(new_excel_number(2.6),hlookup_a1_v,new_excel_number(2),ONE).number == 20);
675
- assert(hlookup(new_excel_number(2.6),hlookup_a1_v,new_excel_number(2),ZERO).type == ExcelError);
676
- assert(hlookup(new_excel_string("HELLO"),hlookup_a2_v,new_excel_number(2),ZERO).number == 10);
677
- assert(hlookup(new_excel_string("HELMP"),hlookup_a2_v,new_excel_number(2),ONE).number == 10);
692
+ assert(hlookup(EXCEL_NUMBER(2.6),hlookup_a1_v,EXCEL_NUMBER(2),ONE).number == 20);
693
+ assert(hlookup(EXCEL_NUMBER(2.6),hlookup_a1_v,EXCEL_NUMBER(2),ZERO).type == ExcelError);
694
+ assert(hlookup(EXCEL_STRING("HELLO"),hlookup_a2_v,EXCEL_NUMBER(2),ZERO).number == 10);
695
+ assert(hlookup(EXCEL_STRING("HELMP"),hlookup_a2_v,EXCEL_NUMBER(2),ONE).number == 10);
678
696
  // ... BLANK should not match with anything" do
679
- assert(hlookup_3(BLANK,hlookup_a3_v,new_excel_number(2)).type == ExcelError);
697
+ assert(hlookup_3(BLANK,hlookup_a3_v,EXCEL_NUMBER(2)).type == ExcelError);
680
698
  // ... should return an error if an argument is an error" do
681
- assert(hlookup(VALUE,hlookup_a1_v,new_excel_number(2),FALSE).type == ExcelError);
682
- assert(hlookup(new_excel_number(2.0),VALUE,new_excel_number(2),FALSE).type == ExcelError);
683
- assert(hlookup(new_excel_number(2.0),hlookup_a1_v,VALUE,FALSE).type == ExcelError);
684
- assert(hlookup(new_excel_number(2.0),hlookup_a1_v,new_excel_number(2),VALUE).type == ExcelError);
699
+ assert(hlookup(VALUE,hlookup_a1_v,EXCEL_NUMBER(2),FALSE).type == ExcelError);
700
+ assert(hlookup(EXCEL_NUMBER(2.0),VALUE,EXCEL_NUMBER(2),FALSE).type == ExcelError);
701
+ assert(hlookup(EXCEL_NUMBER(2.0),hlookup_a1_v,VALUE,FALSE).type == ExcelError);
702
+ assert(hlookup(EXCEL_NUMBER(2.0),hlookup_a1_v,EXCEL_NUMBER(2),VALUE).type == ExcelError);
685
703
  assert(hlookup(VALUE,VALUE,VALUE,VALUE).type == ExcelError);
686
704
 
687
705
  // Test SUM
688
- ExcelValue sum_array_0[] = {new_excel_number(1084.4557258064517),new_excel_number(32.0516914516129),new_excel_number(137.36439193548387)};
689
- ExcelValue sum_array_0_v = new_excel_range(sum_array_0,3,1);
706
+ ExcelValue sum_array_0[] = {EXCEL_NUMBER(1084.4557258064517),EXCEL_NUMBER(32.0516914516129),EXCEL_NUMBER(137.36439193548387)};
707
+ ExcelValue sum_array_0_v = EXCEL_RANGE(sum_array_0,3,1);
690
708
  ExcelValue sum_array_1[] = {sum_array_0_v};
691
709
  assert(sum(1,sum_array_1).number == 1253.8718091935484);
692
710
 
693
711
  // Test PV
694
- assert((int) pv_3(new_excel_number(0.03), new_excel_number(12), new_excel_number(100)).number == -995);
695
- assert((int) pv_4(new_excel_number(0.03), new_excel_number(12), new_excel_number(-100), new_excel_number(100)).number == 925);
696
- assert((int) pv_5(new_excel_number(0.03), new_excel_number(12), new_excel_number(-100), new_excel_number(-100), new_excel_number(1)).number == 1095);
712
+ assert((int) pv_3(EXCEL_NUMBER(0.03), EXCEL_NUMBER(12), EXCEL_NUMBER(100)).number == -995);
713
+ assert((int) pv_4(EXCEL_NUMBER(0.03), EXCEL_NUMBER(12), EXCEL_NUMBER(-100), EXCEL_NUMBER(100)).number == 925);
714
+ assert((int) pv_5(EXCEL_NUMBER(0.03), EXCEL_NUMBER(12), EXCEL_NUMBER(-100), EXCEL_NUMBER(-100), EXCEL_NUMBER(1)).number == 1095);
697
715
 
698
716
  // Test TEXT
699
- assert(strcmp(text(new_excel_number(1.0), new_excel_string("0%")).string, "100%") == 0);
700
- assert(strcmp(text(new_excel_string("1"), new_excel_string("0%")).string, "100%") == 0);
701
- assert(strcmp(text(new_excel_string("0.00251"), new_excel_string("0.0%")).string, "0.3%") == 0);
702
- assert(strcmp(text(BLANK, new_excel_string("0%")).string, "0%") == 0);
703
- assert(strcmp(text(new_excel_number(1.0), BLANK).string, "") == 0);
704
- assert(strcmp(text(new_excel_string("ASGASD"), new_excel_string("0%")).string, "ASGASD") == 0);
705
- assert(strcmp(text(new_excel_number(1.1518), new_excel_string("0")).string, "1") == 0);
706
- assert(strcmp(text(new_excel_number(1.1518), ZERO).string, "1") == 0);
707
- assert(strcmp(text(new_excel_number(1.1518), new_excel_string("0.0")).string, "1.2") == 0);
708
- assert(strcmp(text(new_excel_number(1.1518), new_excel_string("0.00")).string, "1.15") == 0);
709
- assert(strcmp(text(new_excel_number(1.1518), new_excel_string("0.000")).string, "1.152") == 0);
710
- assert(strcmp(text(new_excel_number(12.51), new_excel_string("0000")).string, "0013") == 0);
711
- assert(strcmp(text(new_excel_number(125101), new_excel_string("0000")).string, "125101") == 0);
712
- assert(strcmp(text(new_excel_number(123456789.123456), new_excel_string("#,##")).string, "123,456,789") == 0);
713
- assert(strcmp(text(new_excel_number(123456789.123456), new_excel_string("#,##0")).string, "123,456,789") == 0);
714
- assert(strcmp(text(new_excel_number(123456789.123456), new_excel_string("#,##0.0")).string, "123,456,789.1") == 0);
717
+ assert(strcmp(text(EXCEL_NUMBER(1.0), EXCEL_STRING("0%")).string, "100%") == 0);
718
+ assert(strcmp(text(EXCEL_STRING("1"), EXCEL_STRING("0%")).string, "100%") == 0);
719
+ assert(strcmp(text(EXCEL_STRING("0.00251"), EXCEL_STRING("0.0%")).string, "0.3%") == 0);
720
+ assert(strcmp(text(BLANK, EXCEL_STRING("0%")).string, "0%") == 0);
721
+ assert(strcmp(text(EXCEL_NUMBER(1.0), BLANK).string, "") == 0);
722
+ assert(strcmp(text(EXCEL_STRING("ASGASD"), EXCEL_STRING("0%")).string, "ASGASD") == 0);
723
+ assert(strcmp(text(EXCEL_NUMBER(1.1518), EXCEL_STRING("0")).string, "1") == 0);
724
+ assert(strcmp(text(EXCEL_NUMBER(1.1518), ZERO).string, "1") == 0);
725
+ assert(strcmp(text(EXCEL_NUMBER(1.1518), EXCEL_STRING("0.0")).string, "1.2") == 0);
726
+ assert(strcmp(text(EXCEL_NUMBER(1.1518), EXCEL_STRING("0.00")).string, "1.15") == 0);
727
+ assert(strcmp(text(EXCEL_NUMBER(1.1518), EXCEL_STRING("0.000")).string, "1.152") == 0);
728
+ assert(strcmp(text(EXCEL_NUMBER(12.51), EXCEL_STRING("0000")).string, "0013") == 0);
729
+ assert(strcmp(text(EXCEL_NUMBER(125101), EXCEL_STRING("0000")).string, "125101") == 0);
730
+ assert(strcmp(text(EXCEL_NUMBER(123456789.123456), EXCEL_STRING("#,##")).string, "123,456,789") == 0);
731
+ assert(strcmp(text(EXCEL_NUMBER(123456789.123456), EXCEL_STRING("#,##0")).string, "123,456,789") == 0);
732
+ assert(strcmp(text(EXCEL_NUMBER(123456789.123456), EXCEL_STRING("#,##0.0")).string, "123,456,789.1") == 0);
733
+ assert(strcmp(text(EXCEL_NUMBER(123456789.123456), EXCEL_STRING("!#,##0.0")).string, "Text format not recognised") == 0);
715
734
 
716
735
  // Test LOG
717
736
  // One argument variant assumes LOG base 10
718
- assert(excel_log(new_excel_number(10)).number == 1);
719
- assert(excel_log(new_excel_number(100)).number == 2);
720
- assert(excel_log(new_excel_number(0)).type == ExcelError);
737
+ assert(excel_log(EXCEL_NUMBER(10)).number == 1);
738
+ assert(excel_log(EXCEL_NUMBER(100)).number == 2);
739
+ assert(excel_log(EXCEL_NUMBER(0)).type == ExcelError);
721
740
  // Two argument variant allows LOG base to be specified
722
- assert(excel_log_2(new_excel_number(8),new_excel_number(2)).number == 3.0);
723
- assert(excel_log_2(new_excel_number(8),new_excel_number(0)).type == ExcelError);
741
+ assert(excel_log_2(EXCEL_NUMBER(8),EXCEL_NUMBER(2)).number == 3.0);
742
+ assert(excel_log_2(EXCEL_NUMBER(8),EXCEL_NUMBER(0)).type == ExcelError);
724
743
 
725
744
  // Test LN
726
- assert(ln(new_excel_number(10)).number == 2.302585092994046);
727
- assert(ln(new_excel_number(8)).number == 2.0794415416798357);
728
- assert(ln(new_excel_number(0)).type == ExcelError);
729
- assert(ln(new_excel_number(-1)).type == ExcelError);
745
+ assert(ln(EXCEL_NUMBER(10)).number == 2.302585092994046);
746
+ assert(ln(EXCEL_NUMBER(8)).number == 2.0794415416798357);
747
+ assert(ln(EXCEL_NUMBER(0)).type == ExcelError);
748
+ assert(ln(EXCEL_NUMBER(-1)).type == ExcelError);
730
749
 
731
750
  // Test MMULT (Matrix multiplication)
732
751
  ExcelValue mmult_1[] = { ONE, TWO, THREE, FOUR};
@@ -735,11 +754,11 @@ int test_functions() {
735
754
  ExcelValue mmult_4[] = { THREE, FOUR};
736
755
  ExcelValue mmult_5[] = { ONE, BLANK, THREE, FOUR};
737
756
 
738
- ExcelValue mmult_1_v = new_excel_range( mmult_1, 2, 2);
739
- ExcelValue mmult_2_v = new_excel_range( mmult_2, 2, 2);
740
- ExcelValue mmult_3_v = new_excel_range( mmult_3, 1, 2);
741
- ExcelValue mmult_4_v = new_excel_range( mmult_4, 2, 1);
742
- ExcelValue mmult_5_v = new_excel_range( mmult_5, 2, 2);
757
+ ExcelValue mmult_1_v = EXCEL_RANGE( mmult_1, 2, 2);
758
+ ExcelValue mmult_2_v = EXCEL_RANGE( mmult_2, 2, 2);
759
+ ExcelValue mmult_3_v = EXCEL_RANGE( mmult_3, 1, 2);
760
+ ExcelValue mmult_4_v = EXCEL_RANGE( mmult_4, 2, 1);
761
+ ExcelValue mmult_5_v = EXCEL_RANGE( mmult_5, 2, 2);
743
762
 
744
763
  // Treat the ranges as matrices and multiply them
745
764
  ExcelValue mmult_result_1_v = mmult(mmult_1_v, mmult_2_v);
@@ -787,17 +806,17 @@ int test_functions() {
787
806
  assert(mmult_result_5_a[3].type == ExcelError);
788
807
 
789
808
  // Test the RANK() function
790
- ExcelValue rank_1_a[] = { FIVE, BLANK, THREE, ONE, ONE, FOUR, FIVE, TRUE, SIX, new_excel_string("Hi")};
791
- ExcelValue rank_2_a[] = { FIVE, BLANK, THREE, NA, ONE, FOUR, FIVE, TRUE, SIX, new_excel_string("Hi")};
792
- ExcelValue rank_1_v = new_excel_range( rank_1_a, 2, 5);
793
- ExcelValue rank_2_v = new_excel_range( rank_2_a, 2, 5);
809
+ ExcelValue rank_1_a[] = { FIVE, BLANK, THREE, ONE, ONE, FOUR, FIVE, TRUE, SIX, EXCEL_STRING("Hi")};
810
+ ExcelValue rank_2_a[] = { FIVE, BLANK, THREE, NA, ONE, FOUR, FIVE, TRUE, SIX, EXCEL_STRING("Hi")};
811
+ ExcelValue rank_1_v = EXCEL_RANGE( rank_1_a, 2, 5);
812
+ ExcelValue rank_2_v = EXCEL_RANGE( rank_2_a, 2, 5);
794
813
 
795
814
  // Basics
796
815
  assert(rank(THREE, rank_1_v, ZERO).number == 5);
797
816
  assert(rank_2(THREE, rank_1_v).number == 5);
798
817
  assert(rank(THREE, rank_1_v, ONE).number == 3);
799
818
  assert(rank(ONE, rank_1_v, ZERO).number == 6);
800
- assert(rank(new_excel_string("3"), rank_1_v, ONE).number == 3);
819
+ assert(rank(EXCEL_STRING("3"), rank_1_v, ONE).number == 3);
801
820
 
802
821
  // Errors
803
822
  assert(rank(TEN, rank_1_v, ZERO).type == ExcelError);
@@ -809,8 +828,8 @@ int test_functions() {
809
828
  assert(excel_isnumber(ONE).number == 1);
810
829
  assert(excel_isnumber(BLANK).type == ExcelBoolean);
811
830
  assert(excel_isnumber(BLANK).number == 0);
812
- assert(excel_isnumber(new_excel_string("Hello")).type == ExcelBoolean);
813
- assert(excel_isnumber(new_excel_string("Hello")).number == 0);
831
+ assert(excel_isnumber(EXCEL_STRING("Hello")).type == ExcelBoolean);
832
+ assert(excel_isnumber(EXCEL_STRING("Hello")).number == 0);
814
833
  assert(excel_isnumber(TRUE).type == ExcelBoolean);
815
834
  assert(excel_isnumber(TRUE).number == 0);
816
835
 
@@ -818,7 +837,7 @@ int test_functions() {
818
837
  assert(excel_exp(BLANK).number == 1);
819
838
  assert(excel_exp(ZERO).number == 1);
820
839
  assert(excel_exp(ONE).number == 2.718281828459045);
821
- assert(excel_exp(new_excel_string("1")).number == 2.718281828459045);
840
+ assert(excel_exp(EXCEL_STRING("1")).number == 2.718281828459045);
822
841
  assert(excel_exp(FALSE).number == 1);
823
842
  assert(excel_exp(TRUE).number == 2.718281828459045);
824
843
  assert(excel_exp(DIV0).type == ExcelError);
@@ -830,122 +849,123 @@ int test_functions() {
830
849
  assert(excel_isblank(ZERO).number == false);
831
850
  assert(excel_isblank(TRUE).number == false);
832
851
  assert(excel_isblank(FALSE).number == false);
833
- assert(excel_isblank(new_excel_string("")).number == false);
852
+ assert(excel_isblank(EXCEL_STRING("")).number == false);
834
853
 
835
854
  // Test AVERAGEIFS function
836
- ExcelValue averageifs_array_1[] = {new_excel_number(10),new_excel_number(100),BLANK};
837
- ExcelValue averageifs_array_1_v = new_excel_range(averageifs_array_1,3,1);
838
- ExcelValue averageifs_array_2[] = {new_excel_string("pear"),new_excel_string("bear"),new_excel_string("apple")};
839
- ExcelValue averageifs_array_2_v = new_excel_range(averageifs_array_2,3,1);
840
- ExcelValue averageifs_array_3[] = {new_excel_number(1),new_excel_number(2),new_excel_number(3),new_excel_number(4),new_excel_number(5),new_excel_number(5)};
841
- ExcelValue averageifs_array_3_v = new_excel_range(averageifs_array_3,6,1);
842
- ExcelValue averageifs_array_4[] = {new_excel_string("CO2"),new_excel_string("CH4"),new_excel_string("N2O"),new_excel_string("CH4"),new_excel_string("N2O"),new_excel_string("CO2")};
843
- ExcelValue averageifs_array_4_v = new_excel_range(averageifs_array_4,6,1);
844
- ExcelValue averageifs_array_5[] = {new_excel_string("1A"),new_excel_string("1A"),new_excel_string("1A"),new_excel_number(4),new_excel_number(4),new_excel_number(5)};
845
- ExcelValue averageifs_array_5_v = new_excel_range(averageifs_array_5,6,1);
855
+ ExcelValue averageifs_array_1[] = {EXCEL_NUMBER(10),EXCEL_NUMBER(100),BLANK};
856
+ ExcelValue averageifs_array_1_v = EXCEL_RANGE(averageifs_array_1,3,1);
857
+ ExcelValue averageifs_array_2[] = {EXCEL_STRING("pear"),EXCEL_STRING("bear"),EXCEL_STRING("apple")};
858
+ ExcelValue averageifs_array_2_v = EXCEL_RANGE(averageifs_array_2,3,1);
859
+ ExcelValue averageifs_array_3[] = {EXCEL_NUMBER(1),EXCEL_NUMBER(2),EXCEL_NUMBER(3),EXCEL_NUMBER(4),EXCEL_NUMBER(5),EXCEL_NUMBER(5)};
860
+ ExcelValue averageifs_array_3_v = EXCEL_RANGE(averageifs_array_3,6,1);
861
+ ExcelValue averageifs_array_4[] = {EXCEL_STRING("CO2"),EXCEL_STRING("CH4"),EXCEL_STRING("N2O"),EXCEL_STRING("CH4"),EXCEL_STRING("N2O"),EXCEL_STRING("CO2")};
862
+ ExcelValue averageifs_array_4_v = EXCEL_RANGE(averageifs_array_4,6,1);
863
+ ExcelValue averageifs_array_5[] = {EXCEL_STRING("1A"),EXCEL_STRING("1A"),EXCEL_STRING("1A"),EXCEL_NUMBER(4),EXCEL_NUMBER(4),EXCEL_NUMBER(5)};
864
+ ExcelValue averageifs_array_5_v = EXCEL_RANGE(averageifs_array_5,6,1);
846
865
 
847
866
  // ... should only average values that meet all of the criteria
848
- ExcelValue averageifs_array_6[] = { averageifs_array_1_v, new_excel_number(10), averageifs_array_2_v, new_excel_string("Bear") };
867
+ ExcelValue averageifs_array_6[] = { averageifs_array_1_v, EXCEL_NUMBER(10), averageifs_array_2_v, EXCEL_STRING("Bear") };
849
868
  assert(averageifs(averageifs_array_1_v,4,averageifs_array_6).type == ExcelError);
850
869
 
851
- ExcelValue averageifs_array_7[] = { averageifs_array_1_v, new_excel_number(10), averageifs_array_2_v, new_excel_string("Pear") };
870
+ ExcelValue averageifs_array_7[] = { averageifs_array_1_v, EXCEL_NUMBER(10), averageifs_array_2_v, EXCEL_STRING("Pear") };
852
871
  assert(averageifs(averageifs_array_1_v,4,averageifs_array_7).number == 10.0);
853
872
 
854
873
  // ... should work when single cells are given where ranges expected
855
- ExcelValue averageifs_array_8[] = { new_excel_string("CAR"), new_excel_string("CAR"), new_excel_string("FCV"), new_excel_string("FCV")};
856
- assert(averageifs(new_excel_number(0.143897265452564), 4, averageifs_array_8).number == 0.143897265452564);
874
+ ExcelValue averageifs_array_8[] = { EXCEL_STRING("CAR"), EXCEL_STRING("CAR"), EXCEL_STRING("FCV"), EXCEL_STRING("FCV")};
875
+ assert(averageifs(EXCEL_NUMBER(0.143897265452564), 4, averageifs_array_8).number == 0.143897265452564);
857
876
 
858
877
  // ... should match numbers with strings that contain numbers
859
- ExcelValue averageifs_array_9[] = { new_excel_number(10), new_excel_string("10.0")};
860
- assert(averageifs(new_excel_number(100),2,averageifs_array_9).number == 100);
878
+ ExcelValue averageifs_array_9[] = { EXCEL_NUMBER(10), EXCEL_STRING("10.0")};
879
+ assert(averageifs(EXCEL_NUMBER(100),2,averageifs_array_9).number == 100);
861
880
 
862
- ExcelValue averageifs_array_10[] = { averageifs_array_4_v, new_excel_string("CO2"), averageifs_array_5_v, new_excel_number(2)};
881
+ ExcelValue averageifs_array_10[] = { averageifs_array_4_v, EXCEL_STRING("CO2"), averageifs_array_5_v, EXCEL_NUMBER(2)};
863
882
  assert(averageifs(averageifs_array_3_v,4, averageifs_array_10).type == ExcelError);
864
883
 
865
884
  // ... should match with strings that contain criteria
866
- ExcelValue averageifs_array_10a[] = { averageifs_array_3_v, new_excel_string("=5")};
885
+ ExcelValue averageifs_array_10a[] = { averageifs_array_3_v, EXCEL_STRING("=5")};
867
886
  assert(averageifs(averageifs_array_3_v,2, averageifs_array_10a).number == 5);
868
887
 
869
- ExcelValue averageifs_array_10b[] = { averageifs_array_3_v, new_excel_string("<>3")};
888
+ ExcelValue averageifs_array_10b[] = { averageifs_array_3_v, EXCEL_STRING("<>3")};
870
889
  assert(averageifs(averageifs_array_3_v,2, averageifs_array_10b).number == 3.4);
871
890
 
872
- ExcelValue averageifs_array_10c[] = { averageifs_array_3_v, new_excel_string("<3")};
891
+ ExcelValue averageifs_array_10c[] = { averageifs_array_3_v, EXCEL_STRING("<3")};
873
892
  assert(averageifs(averageifs_array_3_v,2, averageifs_array_10c).number == 1.5);
874
893
 
875
- ExcelValue averageifs_array_10d[] = { averageifs_array_3_v, new_excel_string("<=3")};
894
+ ExcelValue averageifs_array_10d[] = { averageifs_array_3_v, EXCEL_STRING("<=3")};
876
895
  assert(averageifs(averageifs_array_3_v,2, averageifs_array_10d).number == 2);
877
896
 
878
- ExcelValue averageifs_array_10e[] = { averageifs_array_3_v, new_excel_string(">3")};
897
+ ExcelValue averageifs_array_10e[] = { averageifs_array_3_v, EXCEL_STRING(">3")};
879
898
  assert(averageifs(averageifs_array_3_v,2, averageifs_array_10e).number == 14.0/3.0);
880
899
 
881
- ExcelValue averageifs_array_10f[] = { averageifs_array_3_v, new_excel_string(">=3")};
900
+ ExcelValue averageifs_array_10f[] = { averageifs_array_3_v, EXCEL_STRING(">=3")};
882
901
  assert(averageifs(averageifs_array_3_v,2, averageifs_array_10f).number == (3.0+4.0+5.0+5.0)/4.0);
883
902
 
884
903
  // ... should treat BLANK as an empty string when in the check_range, but not in the criteria
885
- ExcelValue averageifs_array_11[] = { BLANK, new_excel_number(20)};
886
- assert(averageifs(new_excel_number(100),2,averageifs_array_11).type == ExcelError);
904
+ ExcelValue averageifs_array_11[] = { BLANK, EXCEL_NUMBER(20)};
905
+ assert(averageifs(EXCEL_NUMBER(100),2,averageifs_array_11).type == ExcelError);
887
906
 
888
- ExcelValue averageifs_array_12[] = {new_excel_number(0), BLANK};
889
- assert(averageifs(new_excel_number(100),2,averageifs_array_12).number == 100);
907
+ ExcelValue averageifs_array_12[] = {EXCEL_NUMBER(0), BLANK};
908
+ assert(averageifs(EXCEL_NUMBER(100),2,averageifs_array_12).number == 100);
890
909
 
891
910
  ExcelValue averageifs_array_13[] = {BLANK, BLANK};
892
- assert(averageifs(new_excel_number(100),2,averageifs_array_13).type == ExcelError);
911
+ assert(averageifs(EXCEL_NUMBER(100),2,averageifs_array_13).type == ExcelError);
893
912
 
894
913
  // ... should return an error if range argument is an error
895
914
  assert(averageifs(REF,2,averageifs_array_13).type == ExcelError);
896
915
 
897
916
  // Tests for the FORECAST function
898
- ExcelValue forecast_array1[] = { new_excel_number(1), new_excel_number(2), new_excel_number(3), new_excel_number(4), new_excel_number(5)};
899
- ExcelValue forecast_array2[] = { new_excel_number(2), new_excel_number(3), new_excel_number(4), new_excel_number(5), new_excel_number(6)};
900
- ExcelValue forecast_array1_v = new_excel_range(forecast_array1,5,1);
901
- ExcelValue forecast_array2_v = new_excel_range(forecast_array2,5,1);
917
+ ExcelValue forecast_array1[] = { EXCEL_NUMBER(1), EXCEL_NUMBER(2), EXCEL_NUMBER(3), EXCEL_NUMBER(4), EXCEL_NUMBER(5)};
918
+ ExcelValue forecast_array2[] = { EXCEL_NUMBER(2), EXCEL_NUMBER(3), EXCEL_NUMBER(4), EXCEL_NUMBER(5), EXCEL_NUMBER(6)};
919
+ ExcelValue forecast_array1_v = EXCEL_RANGE(forecast_array1,5,1);
920
+ ExcelValue forecast_array2_v = EXCEL_RANGE(forecast_array2,5,1);
902
921
 
903
- assert(forecast(new_excel_number(0), forecast_array2_v, forecast_array1_v).number == 1);
904
- assert(forecast(new_excel_number(1), forecast_array2_v, forecast_array1_v).number == 2);
905
- assert(forecast(new_excel_number(6), forecast_array2_v, forecast_array1_v).number == 7);
922
+ assert(forecast(EXCEL_NUMBER(0), forecast_array2_v, forecast_array1_v).number == 1);
923
+ assert(forecast(EXCEL_NUMBER(1), forecast_array2_v, forecast_array1_v).number == 2);
924
+ assert(forecast(EXCEL_NUMBER(6), forecast_array2_v, forecast_array1_v).number == 7);
906
925
 
907
- ExcelValue forecast_array3[] = { BLANK, new_excel_number(2), new_excel_number(3), new_excel_number(4), BLANK};
908
- ExcelValue forecast_array3_v = new_excel_range(forecast_array3,5,1);
926
+ ExcelValue forecast_array3[] = { BLANK, EXCEL_NUMBER(2), EXCEL_NUMBER(3), EXCEL_NUMBER(4), BLANK};
927
+ ExcelValue forecast_array3_v = EXCEL_RANGE(forecast_array3,5,1);
909
928
 
910
- assert(forecast(new_excel_number(6), forecast_array2_v, forecast_array3_v).number == 7);
929
+ assert(forecast(EXCEL_NUMBER(6), forecast_array2_v, forecast_array3_v).number == 7);
911
930
 
912
931
  // Tests ENSURE_IS_NUMBER function
913
- assert(ensure_is_number(new_excel_number(1.3)).type == ExcelNumber);
914
- assert(ensure_is_number(new_excel_number(1.3)).number == 1.3);
932
+ assert(ensure_is_number(EXCEL_NUMBER(1.3)).type == ExcelNumber);
933
+ assert(ensure_is_number(EXCEL_NUMBER(1.3)).number == 1.3);
915
934
  assert(ensure_is_number(BLANK).type == ExcelNumber);
916
935
  assert(ensure_is_number(BLANK).number == 0);
917
936
  assert(ensure_is_number(TRUE).type == ExcelNumber);
918
937
  assert(ensure_is_number(TRUE).number == 1.0);
919
938
  assert(ensure_is_number(FALSE).type == ExcelNumber);
920
939
  assert(ensure_is_number(FALSE).number == 0.0);
921
- assert(ensure_is_number(new_excel_string("1.3")).type == ExcelNumber);
922
- assert(ensure_is_number(new_excel_string("1.3")).number == 1.3);
923
- assert(ensure_is_number(new_excel_string("BASDASD")).type == ExcelError);
940
+ assert(ensure_is_number(EXCEL_STRING("1.3")).type == ExcelNumber);
941
+ assert(ensure_is_number(EXCEL_STRING("1.3")).number == 1.3);
942
+ assert(ensure_is_number(EXCEL_STRING("BASDASD")).type == ExcelError);
924
943
  assert(ensure_is_number(DIV0).type == ExcelError);
925
944
 
926
945
  // RIGHT(string,[characters])
927
946
  // ... should return the right n characters from a string
928
- assert(strcmp(right_1(new_excel_string("ONE")).string,"E") == 0);
929
- assert(strcmp(right(new_excel_string("ONE"),ONE).string,"E") == 0);
930
- assert(strcmp(right(new_excel_string("ONE"),new_excel_number(3)).string,"ONE") == 0);
947
+ assert(strcmp(right_1(EXCEL_STRING("ONE")).string,"E") == 0);
948
+ assert(strcmp(right(EXCEL_STRING("ONE"),ONE).string,"E") == 0);
949
+ assert(strcmp(right(EXCEL_STRING("ONE"),EXCEL_NUMBER(3)).string,"ONE") == 0);
931
950
  // ... should turn numbers into strings before processing
932
- assert(strcmp(right(new_excel_number(1.31e12),new_excel_number(3)).string, "000") == 0);
951
+ assert(strcmp(right(EXCEL_NUMBER(1.31e12),EXCEL_NUMBER(3)).string, "000") == 0);
933
952
  // ... should turn booleans into the words TRUE and FALSE before processing
934
- assert(strcmp(right(TRUE,new_excel_number(3)).string,"RUE") == 0);
935
- assert(strcmp(right(FALSE,new_excel_number(3)).string,"LSE") == 0);
953
+ assert(strcmp(right(TRUE,EXCEL_NUMBER(3)).string,"RUE") == 0);
954
+ assert(strcmp(right(FALSE,EXCEL_NUMBER(3)).string,"LSE") == 0);
936
955
  // ... should return BLANK if given BLANK for either argument
937
- assert(right(BLANK,new_excel_number(3)).type == ExcelEmpty);
938
- assert(right(new_excel_string("ONE"),BLANK).type == ExcelEmpty);
956
+ assert(right(BLANK,EXCEL_NUMBER(3)).type == ExcelEmpty);
957
+ assert(right(EXCEL_STRING("ONE"),BLANK).type == ExcelEmpty);
939
958
  // ... should return an error if an argument is an error
940
959
  assert(right_1(NA).type == ExcelError);
941
- assert(right(new_excel_string("ONE"),NA).type == ExcelError);
942
- assert(right(new_excel_string("ONE"),new_excel_number(-10)).type == ExcelError);
960
+ assert(right(EXCEL_STRING("ONE"),NA).type == ExcelError);
961
+ assert(right(EXCEL_STRING("ONE"),EXCEL_NUMBER(-10)).type == ExcelError);
962
+ assert_equal(EXCEL_STRING("ONE"), right(EXCEL_STRING("ONE"), EXCEL_NUMBER(100)), "RIGHT if number of characters greater than string length");
943
963
 
944
964
  // LEN(string)
945
965
  assert(len(BLANK).type == ExcelNumber);
946
966
  assert(len(BLANK).number == 0);
947
- assert(len(new_excel_string("Hello")).number == 5);
948
- assert(len(new_excel_number(123)).number == 3);
967
+ assert(len(EXCEL_STRING("Hello")).number == 5);
968
+ assert(len(EXCEL_NUMBER(123)).number == 3);
949
969
  assert(len(TRUE).number == 4);
950
970
  assert(len(FALSE).number == 5);
951
971
 
@@ -955,36 +975,36 @@ int test_functions() {
955
975
  assert(value(BLANK).number == 0);
956
976
  assert(value(ONE).type == ExcelNumber);
957
977
  assert(value(ONE).number == 1);
958
- assert(value(new_excel_string("1")).type == ExcelNumber);
959
- assert(value(new_excel_string("1")).number == 1);
960
- assert(value(new_excel_string("A1A")).type == ExcelError);
978
+ assert(value(EXCEL_STRING("1")).type == ExcelNumber);
979
+ assert(value(EXCEL_STRING("1")).number == 1);
980
+ assert(value(EXCEL_STRING("A1A")).type == ExcelError);
961
981
 
962
982
 
963
983
  // NPV(rate, flow1, flow2)
964
- ExcelValue npv_array1[] = { new_excel_number(110) };
965
- assert(npv(new_excel_number(0.1), 1, npv_array1).type == ExcelNumber);
966
- assert(npv(new_excel_number(0.1), 1, npv_array1).number-100 < 0.001);
984
+ ExcelValue npv_array1[] = { EXCEL_NUMBER(110) };
985
+ assert(npv(EXCEL_NUMBER(0.1), 1, npv_array1).type == ExcelNumber);
986
+ assert(npv(EXCEL_NUMBER(0.1), 1, npv_array1).number-100 < 0.001);
967
987
 
968
- ExcelValue npv_array2[] = { new_excel_number(110), new_excel_number(121) };
969
- assert((npv(new_excel_number(0.1), 2, npv_array2).number - 200) < 0.001);
988
+ ExcelValue npv_array2[] = { EXCEL_NUMBER(110), EXCEL_NUMBER(121) };
989
+ assert((npv(EXCEL_NUMBER(0.1), 2, npv_array2).number - 200) < 0.001);
970
990
 
971
- ExcelValue npv_array3[] = { new_excel_number(110), new_excel_number(121)};
972
- ExcelValue npv_array3_v = new_excel_range(npv_array3,2,1);
991
+ ExcelValue npv_array3[] = { EXCEL_NUMBER(110), EXCEL_NUMBER(121)};
992
+ ExcelValue npv_array3_v = EXCEL_RANGE(npv_array3,2,1);
973
993
  ExcelValue npv_array4[] = { npv_array3_v };
974
994
 
975
- assert((npv(new_excel_number(0.1), 1, npv_array4).number - 200) < 0.001);
995
+ assert((npv(EXCEL_NUMBER(0.1), 1, npv_array4).number - 200) < 0.001);
976
996
 
977
- assert(npv(new_excel_number(-1.0), 1, npv_array1).type == ExcelError);
997
+ assert(npv(EXCEL_NUMBER(-1.0), 1, npv_array1).type == ExcelError);
978
998
  assert(npv(BLANK, 1, npv_array1).number == 110);
979
999
 
980
1000
  ExcelValue npv_array5[] = { BLANK };
981
- assert(npv(new_excel_number(0.1), 1, npv_array5).number == 0);
1001
+ assert(npv(EXCEL_NUMBER(0.1), 1, npv_array5).number == 0);
982
1002
 
983
1003
  // Release memory
984
1004
  free_all_allocated_memory();
985
1005
 
986
1006
  // Yay!
987
- printf("All tests passed\n");
1007
+ printf("\nFinished tests\n");
988
1008
 
989
1009
  return 0;
990
1010
  }