-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathtests.bal
65 lines (63 loc) · 2 KB
/
tests.bal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import ballerina/io;
import ballerina/test;
@test:Config {
dataProvider: validData,
groups: ["sample"]
}
function testGetTopXBillionaires(string[] countries, int 'limit, string[] expected) {
string[]|error actual = getTopXBillionaires(countries, 'limit);
if actual is error {
io:println(actual.message());
test:assertFail("Failed to fetch top billionaires");
}
test:assertEquals(actual, expected);
}
function validData() returns map<[string[], int, string[]]> {
return {
"case1": [
["United States"],
3,
["Elon Musk", "Jeff Bezos", "Bill Gates"]
],
"case2": [
["China", "India"],
5,
["Mukesh Ambani","Zhong Shanshan","Ma Huateng","Colin Huang","Pony Ma"]
],
"case3": [
["China", "India", "Japan", "Hong Kong"],
10,
["Mukesh Ambani","Zhong Shanshan","Ma Huateng","Colin Huang","Pony Ma","Gautam Adani & family","Jack Ma","He Xiangjian","Zhang Yiming","Li Ka-shing"]
],
"case4": [
["Russia", "Italy", "France", "Germany", "Australia"],
3,
["Bernard Arnault & family","Francoise Bettencourt Meyers & family","Francois Pinault & family"]
],
"case5": [
["Indonesia", "Japan", "Hong Kong"],
7,
["Li Ka-shing","Tadashi Yanai & family","Masayoshi Son","Takemitsu Takizaki","Nobutada Saji & family","Takemitsu Takizaki","Takemitsu Takizaki"]
],
"case6": [
["India"],
1,
["Mukesh Ambani"]
],
"case7": [
["Russia"],
3,
["Vladimir Lisin","Vladimir Potanin","Alexey Mordashov & family"]
],
"case8": [
["Mexico"],
1,
["Carlos Slim Helu & family"]
],
"case9": [
["Canada", "Finland"],
2,
["David Thomson & family","Antti Herlin & family"]
]
};
}