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
68ae3a08
Kaydet (Commit)
68ae3a08
authored
Tem 13, 2014
tarafından
Kohei Yoshida
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fdo#81309: Write test for this.
Change-Id: I98216a60b3b82bdac14cd777b85502dc09f82dd9
üst
14d24444
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
0 deletions
+119
-0
ucalc.cxx
sc/qa/unit/ucalc.cxx
+117
-0
ucalc.hxx
sc/qa/unit/ucalc.hxx
+2
-0
No files found.
sc/qa/unit/ucalc.cxx
Dosyayı görüntüle @
68ae3a08
...
@@ -5325,6 +5325,123 @@ void Test::testSortWithCellFormats()
...
@@ -5325,6 +5325,123 @@ void Test::testSortWithCellFormats()
m_pDoc
->
DeleteTab
(
0
);
m_pDoc
->
DeleteTab
(
0
);
}
}
void
Test
::
testSortRefUpdate
()
{
sc
::
AutoCalcSwitch
aACSwitch
(
*
m_pDoc
,
true
);
// turn auto calc on.
FormulaGrammarSwitch
aFGSwitch
(
m_pDoc
,
formula
::
FormulaGrammar
::
GRAM_ENGLISH_XL_R1C1
);
m_pDoc
->
InsertTab
(
0
,
"Sort"
);
// Set values to sort in column A.
m_pDoc
->
SetString
(
ScAddress
(
0
,
0
,
0
),
"Header"
);
double
aValues
[]
=
{
4.0
,
36.0
,
14.0
,
29.0
,
98.0
,
78.0
,
0.0
,
99.0
,
1.0
};
size_t
nCount
=
SAL_N_ELEMENTS
(
aValues
);
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
m_pDoc
->
SetValue
(
ScAddress
(
0
,
i
+
1
,
0
),
aValues
[
i
]);
// Set formulas to reference these values in column C.
m_pDoc
->
SetString
(
ScAddress
(
2
,
0
,
0
),
"Formula"
);
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
m_pDoc
->
SetString
(
ScAddress
(
2
,
1
+
i
,
0
),
"=RC[-2]"
);
// Check the values in column C.
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
{
double
fCheck
=
aValues
[
i
];
CPPUNIT_ASSERT_EQUAL
(
fCheck
,
m_pDoc
->
GetValue
(
ScAddress
(
2
,
i
+
1
,
0
)));
}
ScDBDocFunc
aFunc
(
getDocShell
());
// Define A1:A10 as sheet-local anonymous database range, else sort wouldn't run.
m_pDoc
->
SetAnonymousDBData
(
0
,
new
ScDBData
(
STR_DB_LOCAL_NONAME
,
0
,
0
,
0
,
0
,
9
));
// Sort A1:A10 (with a header row).
ScSortParam
aSortData
;
aSortData
.
nCol1
=
0
;
aSortData
.
nCol2
=
0
;
aSortData
.
nRow1
=
0
;
aSortData
.
nRow2
=
9
;
aSortData
.
bHasHeader
=
true
;
aSortData
.
maKeyState
[
0
].
bDoSort
=
true
;
aSortData
.
maKeyState
[
0
].
nField
=
0
;
aSortData
.
maKeyState
[
0
].
bAscending
=
true
;
bool
bSorted
=
aFunc
.
Sort
(
0
,
aSortData
,
true
,
true
,
true
);
CPPUNIT_ASSERT
(
bSorted
);
double
aSorted
[]
=
{
0.0
,
1.0
,
4.0
,
14.0
,
29.0
,
36.0
,
78.0
,
98.0
,
99.0
};
// Check the sort result.
CPPUNIT_ASSERT_EQUAL
(
OUString
(
"Header"
),
m_pDoc
->
GetString
(
ScAddress
(
0
,
0
,
0
)));
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
{
double
fCheck
=
aSorted
[
i
];
CPPUNIT_ASSERT_EQUAL
(
fCheck
,
m_pDoc
->
GetValue
(
ScAddress
(
0
,
i
+
1
,
0
)));
}
// Sorting should not alter the values in column C.
m_pDoc
->
CalcAll
();
// just in case...
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
{
double
fCheck
=
aValues
[
i
];
CPPUNIT_ASSERT_EQUAL
(
fCheck
,
m_pDoc
->
GetValue
(
ScAddress
(
2
,
i
+
1
,
0
)));
}
// C2 should now point to A4.
if
(
!
checkFormula
(
*
m_pDoc
,
ScAddress
(
2
,
1
,
0
),
"R[2]C[-2]"
))
CPPUNIT_FAIL
(
"Wrong formula in C2!"
);
// Undo the sort.
SfxUndoManager
*
pUndoMgr
=
m_pDoc
->
GetUndoManager
();
pUndoMgr
->
Undo
();
// Check the undo result.
CPPUNIT_ASSERT_EQUAL
(
OUString
(
"Header"
),
m_pDoc
->
GetString
(
ScAddress
(
0
,
0
,
0
)));
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
{
double
fCheck
=
aValues
[
i
];
CPPUNIT_ASSERT_EQUAL
(
fCheck
,
m_pDoc
->
GetValue
(
ScAddress
(
0
,
i
+
1
,
0
)));
}
// Values in column C should still be unaltered.
m_pDoc
->
CalcAll
();
// just in case...
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
{
double
fCheck
=
aValues
[
i
];
CPPUNIT_ASSERT_EQUAL
(
fCheck
,
m_pDoc
->
GetValue
(
ScAddress
(
2
,
i
+
1
,
0
)));
}
// C2 should now point to A2.
if
(
!
checkFormula
(
*
m_pDoc
,
ScAddress
(
2
,
1
,
0
),
"RC[-2]"
))
CPPUNIT_FAIL
(
"Wrong formula in C2!"
);
// Redo.
pUndoMgr
->
Redo
();
CPPUNIT_ASSERT_EQUAL
(
OUString
(
"Header"
),
m_pDoc
->
GetString
(
ScAddress
(
0
,
0
,
0
)));
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
{
double
fCheck
=
aSorted
[
i
];
CPPUNIT_ASSERT_EQUAL
(
fCheck
,
m_pDoc
->
GetValue
(
ScAddress
(
0
,
i
+
1
,
0
)));
}
// Sorting should not alter the values in column C.
m_pDoc
->
CalcAll
();
// just in case...
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
{
double
fCheck
=
aValues
[
i
];
CPPUNIT_ASSERT_EQUAL
(
fCheck
,
m_pDoc
->
GetValue
(
ScAddress
(
2
,
i
+
1
,
0
)));
}
// C2 should now point to A4.
if
(
!
checkFormula
(
*
m_pDoc
,
ScAddress
(
2
,
1
,
0
),
"R[2]C[-2]"
))
CPPUNIT_FAIL
(
"Wrong formula in C2!"
);
m_pDoc
->
DeleteTab
(
0
);
}
void
Test
::
testShiftCells
()
void
Test
::
testShiftCells
()
{
{
m_pDoc
->
InsertTab
(
0
,
"foo"
);
m_pDoc
->
InsertTab
(
0
,
"foo"
);
...
...
sc/qa/unit/ucalc.hxx
Dosyayı görüntüle @
68ae3a08
...
@@ -346,6 +346,7 @@ public:
...
@@ -346,6 +346,7 @@ public:
void
testSortWithStrings
();
void
testSortWithStrings
();
void
testSortInFormulaGroup
();
void
testSortInFormulaGroup
();
void
testSortWithCellFormats
();
void
testSortWithCellFormats
();
void
testSortRefUpdate
();
void
testShiftCells
();
void
testShiftCells
();
void
testNoteBasic
();
void
testNoteBasic
();
...
@@ -515,6 +516,7 @@ public:
...
@@ -515,6 +516,7 @@ public:
CPPUNIT_TEST
(
testSortWithStrings
);
CPPUNIT_TEST
(
testSortWithStrings
);
CPPUNIT_TEST
(
testSortInFormulaGroup
);
CPPUNIT_TEST
(
testSortInFormulaGroup
);
CPPUNIT_TEST
(
testSortWithCellFormats
);
CPPUNIT_TEST
(
testSortWithCellFormats
);
CPPUNIT_TEST
(
testSortRefUpdate
);
CPPUNIT_TEST
(
testShiftCells
);
CPPUNIT_TEST
(
testShiftCells
);
CPPUNIT_TEST
(
testNoteBasic
);
CPPUNIT_TEST
(
testNoteBasic
);
CPPUNIT_TEST
(
testNoteDeleteRow
);
CPPUNIT_TEST
(
testNoteDeleteRow
);
...
...
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