File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,10 @@ int selected = 0;
14
14
15
15
class TestCandidateWord : public CandidateWord {
16
16
public:
17
- TestCandidateWord (int number)
18
- : CandidateWord(Text(std::to_string(number))), number_(number) {}
17
+ TestCandidateWord (int number, Text comment = {})
18
+ : CandidateWord(Text(std::to_string(number))), number_(number) {
19
+ setComment (std::move (comment));
20
+ }
19
21
void select (InputContext *) const override { selected = number_; }
20
22
21
23
private:
@@ -303,9 +305,17 @@ void test_label() {
303
305
FCITX_ASSERT (candidatelist.label (9 ).toString () == " ,. " );
304
306
}
305
307
308
+ void test_comment () {
309
+ TestCandidateWord candidate (1 , Text (" comment" ));
310
+ FCITX_ASSERT (candidate.text ().toString () == " 1" );
311
+ FCITX_ASSERT (candidate.comment ().toString () == " comment" );
312
+ FCITX_ASSERT (candidate.textWithComment ().toString () == " 1 comment" );
313
+ }
314
+
306
315
int main () {
307
316
test_basic ();
308
317
test_faulty_placeholder ();
309
318
test_label ();
319
+ test_comment ();
310
320
return 0 ;
311
321
}
Original file line number Diff line number Diff line change 6
6
*/
7
7
#include < fcitx-utils/log.h>
8
8
#include < fcitx/text.h>
9
+ #include " fcitx-utils/textformatflags.h"
9
10
using namespace fcitx ;
10
11
11
12
void test_basic () {
@@ -33,6 +34,14 @@ void test_basic() {
33
34
FCITX_ASSERT (lines[2 ].toStringForCommit () == " " );
34
35
FCITX_ASSERT (lines[3 ].toStringForCommit () == " Z" );
35
36
FCITX_ASSERT (lines[4 ].toStringForCommit () == " 1" );
37
+
38
+ text = Text (" ABC" );
39
+ Text another = Text (" DEF" , TextFormatFlag::Bold);
40
+ another.append (" GHI" , TextFormatFlag::Italic);
41
+ text.append (another);
42
+ FCITX_ASSERT (text.toString () == " ABCDEFGHI" );
43
+ FCITX_ASSERT (text.formatAt (1 ) == TextFormatFlag::Bold);
44
+ FCITX_ASSERT (text.formatAt (2 ) == TextFormatFlag::Italic);
36
45
}
37
46
38
47
void test_normalize () {
You can’t perform that action at this time.
0 commit comments