summaryrefslogtreecommitdiff
path: root/modules/spreadsheet/tests/unit_tests/csvRead.dia.ref
blob: 1228293df0b85e0660dd4db5a7c46d24f3f1c1e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// =============================================================================
// Copyright (C) 2011 - INRIA - Michael Baudin
// Copyright (C) 2010 - 2011 - INRIA - Allan CORNET
// =============================================================================
// <-- JVM NOT MANDATORY -->
path = SCI+"/modules/spreadsheet/tests/unit_tests/";
// =============================================================================
Mstr = [
"1" "0" "0" "0" "0"
"0" "1" "0" "0" "0"
"0" "0" "1" "0" "0"
];
//
r = csvRead(fullfile(path,"M_1.csv"),[],[],"string");
assert_checkequal (r,Mstr);
//
r = csvRead(fullfile(path,"M_2.csv"), ascii(9), [], "string");
assert_checkequal (r,Mstr);
//
r = csvRead(fullfile(path,"M_3.csv"), " ", ",", "string");
assert_checkequal (r,Mstr);
//
r = csvRead(fullfile(path,"M_4.csv"), ";", ",", "string");
assert_checkequal (r,Mstr);
// =============================================================================
Nstr = [
"Nan"   "1"    "Nan"
"-Inf"  "Inf"  "4"
];
//
r = csvRead(fullfile(path,"N_1.csv"), [], [], "string");
assert_checkequal (r,Nstr);
//
r = csvRead(fullfile(path,"N_2.csv"), ascii(9), [], "string");
assert_checkequal (r,Nstr);
//
r = csvRead(fullfile(path,"N_3.csv"), " ", ",", "string");
assert_checkequal (r,Nstr);
//
r = csvRead(fullfile(path,"N_4.csv"), ";", ",", "string");
assert_checkequal (r,Nstr);
// =============================================================================
Kstr = [
"1.1000000000000001" "0.10000000000000001"
"0.10000000000000001" "1.1000000000000001"
"0.10000000000000001" "0.10000000000000001"
];
Kstr2 = [
"1,1000000000000001" "0,10000000000000001"
"0,10000000000000001" "1,1000000000000001"
"0,10000000000000001" "0,10000000000000001"
];
//
r = csvRead(fullfile(path,"K_1.csv"), [], [], "string");
assert_checkequal (r,Kstr);
//
r = csvRead(fullfile(path,"K_2.csv"), ascii(9), [], "string");
assert_checkequal (r,Kstr);
//
r = csvRead(fullfile(path,"K_3.csv"), " ", ",", "string");
assert_checkequal (r,Kstr);
//
r = csvRead(fullfile(path,"K_4.csv"), ";", ",", "string");
assert_checkequal (r,Kstr);
//
r = csvRead(fullfile(path,"K_4.csv"), ";", [], "string");
assert_checkequal (r,Kstr2);
// =============================================================================
S = [
  "Allan",                  "2", "CORNET";
  "csv read/write toolbox", "3", "for scilab"
];
//
r = csvRead(fullfile(path,"S_1.csv"), "|", [], "string");
assert_checkequal (r,S);
//
r = csvRead(fullfile(path,"S_2.csv"), ascii(9), [], "string");
assert_checkequal (r,S);
//
r = csvRead(fullfile(path,"S_3.csv"), "!", ",", "string");
assert_checkequal (r,S);
//
r = csvRead(fullfile(path,"S_4.csv"), ";", ",", "string");
assert_checkequal (r,S);
//
r = csvRead(fullfile(path,"S_1.csv"), "|", ".", "string");
assert_checkequal (r,S);
//
r = csvRead(fullfile(path,"S_1.csv"), "|", ".", "double");
ref = [%nan , 2, %nan; %nan, 3, %nan];
assert_checkequal ( r , ref);
// =============================================================================
filename = fullfile(path,"data.csv");
N = csvRead(filename,",",".","double",["Nan", "0"]);
expected = [%inf, 0];
assert_checkequal ( N , expected );
// =============================================================================