Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
5d1a9916
Kaydet (Commit)
5d1a9916
authored
Kas 08, 2011
tarafından
Kohei Yoshida
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Test case for VLOOKUP (in-exact lookup on sorted range).
üst
b45ef269
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
4 deletions
+90
-4
ucalc.cxx
sc/qa/unit/ucalc.cxx
+90
-4
No files found.
sc/qa/unit/ucalc.cxx
Dosyayı görüntüle @
5d1a9916
...
@@ -74,7 +74,7 @@
...
@@ -74,7 +74,7 @@
#include <iostream>
#include <iostream>
#include <vector>
#include <vector>
#define CALC_DEBUG_OUTPUT
1
#define CALC_DEBUG_OUTPUT
0
#include "helper/debughelper.hxx"
#include "helper/debughelper.hxx"
...
@@ -213,7 +213,7 @@ void printRange(ScDocument* pDoc, const ScRange& rRange, const char* pCaption)
...
@@ -213,7 +213,7 @@ void printRange(ScDocument* pDoc, const ScRange& rRange, const char* pCaption)
{
{
rtl
::
OUString
aVal
;
rtl
::
OUString
aVal
;
pDoc
->
GetString
(
nCol
,
nRow
,
rRange
.
aStart
.
Tab
(),
aVal
);
pDoc
->
GetString
(
nCol
,
nRow
,
rRange
.
aStart
.
Tab
(),
aVal
);
printer
.
set
(
nRow
,
nCol
,
aVal
);
printer
.
set
(
nRow
-
nRow1
,
nCol
-
nCol1
,
aVal
);
}
}
}
}
printer
.
print
(
pCaption
);
printer
.
print
(
pCaption
);
...
@@ -397,7 +397,7 @@ void Test::testCellFunctions()
...
@@ -397,7 +397,7 @@ void Test::testCellFunctions()
for
(
SCROW
i
=
0
;
i
<
nRows
;
++
i
)
for
(
SCROW
i
=
0
;
i
<
nRows
;
++
i
)
m_pDoc
->
SetString
(
0
,
i
,
0
,
rtl
::
OUString
::
createFromAscii
(
aData
[
i
]));
m_pDoc
->
SetString
(
0
,
i
,
0
,
rtl
::
OUString
::
createFromAscii
(
aData
[
i
]));
printRange
(
m_pDoc
,
ScRange
(
0
,
0
,
0
,
0
,
8
,
0
),
"data range"
);
printRange
(
m_pDoc
,
ScRange
(
0
,
0
,
0
,
0
,
8
,
0
),
"data range
for COUNTIF
"
);
// formulas and results
// formulas and results
struct
{
struct
{
...
@@ -431,12 +431,98 @@ void Test::testCellFunctions()
...
@@ -431,12 +431,98 @@ void Test::testCellFunctions()
bool
bGood
=
result
==
aChecks
[
i
].
fResult
;
bool
bGood
=
result
==
aChecks
[
i
].
fResult
;
if
(
!
bGood
)
if
(
!
bGood
)
{
{
cerr
<<
"row "
<<
(
nRow
+
1
)
<<
": formula"
<<
aChecks
[
i
].
pFormula
<<
" expected="
<<
aChecks
[
i
].
fResult
<<
" actual="
<<
result
<<
endl
;
cerr
<<
"row "
<<
(
nRow
+
1
)
<<
": formula"
<<
aChecks
[
i
].
pFormula
<<
" expected="
<<
aChecks
[
i
].
fResult
<<
" actual="
<<
result
<<
endl
;
CPPUNIT_ASSERT_MESSAGE
(
"Unexpected result for COUNTIF"
,
false
);
CPPUNIT_ASSERT_MESSAGE
(
"Unexpected result for COUNTIF"
,
false
);
}
}
}
}
}
}
{
// VLOOKUP
// Clear A1:F40.
clearRange
(
m_pDoc
,
ScRange
(
0
,
0
,
0
,
5
,
39
,
0
));
// Raw data
const
char
*
aData
[][
2
]
=
{
{
"Key"
,
"Val"
},
{
"10"
,
"3"
},
{
"20"
,
"4"
},
{
"30"
,
"5"
},
{
"40"
,
"6"
},
{
"50"
,
"7"
},
{
"60"
,
"8"
},
{
"70"
,
"9"
},
{
"A"
,
"10"
},
{
"B"
,
"11"
},
{
"C"
,
"12"
},
{
"D"
,
"13"
},
{
"E"
,
"14"
},
{
"F"
,
"15"
},
{
0
,
0
}
// terminator
};
// Insert raw data into A1:B14.
for
(
SCROW
i
=
0
;
aData
[
i
][
0
];
++
i
)
{
m_pDoc
->
SetString
(
0
,
i
,
0
,
rtl
::
OUString
::
createFromAscii
(
aData
[
i
][
0
]));
m_pDoc
->
SetString
(
1
,
i
,
0
,
rtl
::
OUString
::
createFromAscii
(
aData
[
i
][
1
]));
}
printRange
(
m_pDoc
,
ScRange
(
0
,
0
,
0
,
1
,
13
,
0
),
"raw data for VLOOKUP"
);
// Formula data
struct
{
const
char
*
pLookup
;
const
char
*
pFormula
;
double
fResult
;
}
aChecks
[]
=
{
{
"Lookup"
,
"Formula"
,
0
},
{
"12"
,
"=VLOOKUP(D2;A2:B14;2;1)"
,
3
},
{
"29"
,
"=VLOOKUP(D3;A2:B14;2;1)"
,
4
},
{
"31"
,
"=VLOOKUP(D4;A2:B14;2;1)"
,
5
},
{
"45"
,
"=VLOOKUP(D5;A2:B14;2;1)"
,
6
},
{
"56"
,
"=VLOOKUP(D6;A2:B14;2;1)"
,
7
},
{
"65"
,
"=VLOOKUP(D7;A2:B14;2;1)"
,
8
},
{
"78"
,
"=VLOOKUP(D8;A2:B14;2;1)"
,
9
},
{
"Andy"
,
"=VLOOKUP(D9;A2:B14;2;1)"
,
10
},
{
"Bruce"
,
"=VLOOKUP(D10;A2:B14;2;1)"
,
11
},
{
"Charlie"
,
"=VLOOKUP(D11;A2:B14;2;1)"
,
12
},
{
"David"
,
"=VLOOKUP(D12;A2:B14;2;1)"
,
13
},
{
"Edward"
,
"=VLOOKUP(D13;A2:B14;2;1)"
,
14
},
{
"Frank"
,
"=VLOOKUP(D14;A2:B14;2;1)"
,
15
},
{
"Henry"
,
"=VLOOKUP(D15;A2:B14;2;1)"
,
15
},
{
"100"
,
"=VLOOKUP(D16;A2:B14;2;1)"
,
9
},
{
"1000"
,
"=VLOOKUP(D17;A2:B14;2;1)"
,
9
},
{
"Zena"
,
"=VLOOKUP(D18;A2:B14;2;1)"
,
15
}
};
// Insert formula data into D1:E18.
for
(
size_t
i
=
0
;
i
<
SAL_N_ELEMENTS
(
aChecks
);
++
i
)
{
m_pDoc
->
SetString
(
3
,
i
,
0
,
rtl
::
OUString
::
createFromAscii
(
aChecks
[
i
].
pLookup
));
m_pDoc
->
SetString
(
4
,
i
,
0
,
rtl
::
OUString
::
createFromAscii
(
aChecks
[
i
].
pFormula
));
}
m_pDoc
->
CalcAll
();
printRange
(
m_pDoc
,
ScRange
(
3
,
0
,
0
,
4
,
17
,
0
),
"formula data for VLOOKUP"
);
// Verify results.
for
(
size_t
i
=
0
;
i
<
SAL_N_ELEMENTS
(
aChecks
);
++
i
)
{
if
(
i
==
0
)
// Skip the header row.
continue
;
m_pDoc
->
GetValue
(
4
,
i
,
0
,
result
);
bool
bGood
=
result
==
aChecks
[
i
].
fResult
;
if
(
!
bGood
)
{
cerr
<<
"row "
<<
(
i
+
1
)
<<
": lookup value='"
<<
aChecks
[
i
].
pLookup
<<
"' expected="
<<
aChecks
[
i
].
fResult
<<
" actual="
<<
result
<<
endl
;
CPPUNIT_ASSERT_MESSAGE
(
"Unexpected result for VLOOKUP"
,
false
);
}
}
}
m_pDoc
->
DeleteTab
(
0
);
m_pDoc
->
DeleteTab
(
0
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment