Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qdatetimeparser.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | int QDateTimeParser::getDigit(const QDateTime &t, int index) const | - | ||||||||||||||||||
4 | { | - | ||||||||||||||||||
5 | if (index < 0
| 0-3487 | ||||||||||||||||||
6 | - | |||||||||||||||||||
7 | QMessageLogger(__FILE__, 76, __PRETTY_FUNCTION__).warning("QDateTimeParser::getDigit() Internal error (%s %d)", | - | ||||||||||||||||||
8 | QString(t.toString()).toLocal8Bit().constData(), index); | - | ||||||||||||||||||
9 | - | |||||||||||||||||||
10 | - | |||||||||||||||||||
11 | - | |||||||||||||||||||
12 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
13 | } | - | ||||||||||||||||||
14 | const SectionNode &node = sectionNodes.at(index); | - | ||||||||||||||||||
15 | switch (node.type) { | - | ||||||||||||||||||
16 | case executed 419 times by 1 test: Hour24Section:case Hour24Section: Executed by:
executed 419 times by 1 test: casecase Hour24Section: Executed by:
executed 305 times by 2 tests: Hour12Section:case Hour12Section: Executed by:
executed 305 times by 2 tests: returncase Hour12Section: Executed by:
executed 724 times by 2 tests: t.time().hour();return t.time().hour(); Executed by:
executed 724 times by 2 tests: return t.time().hour(); Executed by:
| 305-724 | ||||||||||||||||||
17 | case executed 316 times by 1 test: MinuteSection:case MinuteSection: Executed by:
executed 316 times by 1 test: returncase MinuteSection: Executed by:
executed 316 times by 1 test: t.time().minute();return t.time().minute(); Executed by:
executed 316 times by 1 test: return t.time().minute(); Executed by:
| 316 | ||||||||||||||||||
18 | case executed 299 times by 1 test: SecondSection:case SecondSection: Executed by:
executed 299 times by 1 test: returncase SecondSection: Executed by:
executed 299 times by 1 test: t.time().second();return t.time().second(); Executed by:
executed 299 times by 1 test: return t.time().second(); Executed by:
| 299 | ||||||||||||||||||
19 | case never executed: MSecSection:case MSecSection: never executed: returncase MSecSection: never executed: t.time().msec();return t.time().msec(); never executed: return t.time().msec(); | 0 | ||||||||||||||||||
20 | case executed 566 times by 2 tests: YearSection2Digits:case YearSection2Digits: Executed by:
executed 566 times by 2 tests: case YearSection2Digits: Executed by:
| 566 | ||||||||||||||||||
21 | case executed 183 times by 1 test: YearSection:case YearSection: Executed by:
executed 183 times by 1 test: returncase YearSection: Executed by:
executed 749 times by 2 tests: t.date().year();return t.date().year(); Executed by:
executed 749 times by 2 tests: return t.date().year(); Executed by:
| 183-749 | ||||||||||||||||||
22 | case executed 159 times by 4 tests: MonthSection:case MonthSection: Executed by:
executed 159 times by 4 tests: returncase MonthSection: Executed by:
executed 159 times by 4 tests: t.date().month();return t.date().month(); Executed by:
executed 159 times by 4 tests: return t.date().month(); Executed by:
| 159 | ||||||||||||||||||
23 | case executed 131 times by 1 test: DaySection:case DaySection: Executed by:
executed 131 times by 1 test: returncase DaySection: Executed by:
executed 131 times by 1 test: t.date().day();return t.date().day(); Executed by:
executed 131 times by 1 test: return t.date().day(); Executed by:
| 131 | ||||||||||||||||||
24 | case executed 90 times by 1 test: DayOfWeekSectionShort:case DayOfWeekSectionShort: Executed by:
executed 90 times by 1 test: case DayOfWeekSectionShort: Executed by:
| 90 | ||||||||||||||||||
25 | case executed 1013 times by 1 test: DayOfWeekSectionLong:case DayOfWeekSectionLong: Executed by:
executed 1013 times by 1 test: returncase DayOfWeekSectionLong: Executed by:
executed 1103 times by 1 test: t.date().day();return t.date().day(); Executed by:
executed 1103 times by 1 test: return t.date().day(); Executed by:
| 1013-1103 | ||||||||||||||||||
26 | case executed 6 times by 1 test: AmPmSection:case AmPmSection: Executed by:
executed 6 times by 1 test: returncase AmPmSection: Executed by:
executed 6 times by 1 test: t.time().hour() > 11 ? 1 : 0;return t.time().hour() > 11 ? 1 : 0; Executed by:
executed 6 times by 1 test: return t.time().hour() > 11 ? 1 : 0; Executed by:
| 6 | ||||||||||||||||||
27 | - | |||||||||||||||||||
28 | default never executed: :default: never executed: break;default: never executed: break; | 0 | ||||||||||||||||||
29 | } | - | ||||||||||||||||||
30 | - | |||||||||||||||||||
31 | - | |||||||||||||||||||
32 | QMessageLogger(__FILE__, 101, __PRETTY_FUNCTION__).warning("QDateTimeParser::getDigit() Internal error 2 (%s %d)", | - | ||||||||||||||||||
33 | QString(t.toString()).toLocal8Bit().constData(), index); | - | ||||||||||||||||||
34 | - | |||||||||||||||||||
35 | - | |||||||||||||||||||
36 | - | |||||||||||||||||||
37 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
38 | } | - | ||||||||||||||||||
39 | bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const | - | ||||||||||||||||||
40 | { | - | ||||||||||||||||||
41 | if (index < 0
| 0-4310 | ||||||||||||||||||
42 | - | |||||||||||||||||||
43 | QMessageLogger(__FILE__, 125, __PRETTY_FUNCTION__).warning("QDateTimeParser::setDigit() Internal error (%s %d %d)", | - | ||||||||||||||||||
44 | QString(v.toString()).toLocal8Bit().constData(), index, newVal); | - | ||||||||||||||||||
45 | - | |||||||||||||||||||
46 | - | |||||||||||||||||||
47 | - | |||||||||||||||||||
48 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||
49 | } | - | ||||||||||||||||||
50 | const SectionNode &node = sectionNodes.at(index); | - | ||||||||||||||||||
51 | - | |||||||||||||||||||
52 | const QDate date = v.date(); | - | ||||||||||||||||||
53 | const QTime time = v.time(); | - | ||||||||||||||||||
54 | int year = date.year(); | - | ||||||||||||||||||
55 | int month = date.month(); | - | ||||||||||||||||||
56 | int day = date.day(); | - | ||||||||||||||||||
57 | int hour = time.hour(); | - | ||||||||||||||||||
58 | int minute = time.minute(); | - | ||||||||||||||||||
59 | int second = time.second(); | - | ||||||||||||||||||
60 | int msec = time.msec(); | - | ||||||||||||||||||
61 | - | |||||||||||||||||||
62 | switch (node.type) { | - | ||||||||||||||||||
63 | case executed 478 times by 2 tests: Hour24Section:case Hour24Section: Executed by:
executed 478 times by 2 tests: casecase Hour24Section: Executed by:
executed 378 times by 2 tests: Hour12Section:case Hour12Section: Executed by:
executed 378 times by 2 tests: hour = newVal; break;case Hour12Section: Executed by:
executed 856 times by 3 tests: break; Executed by:
| 378-856 | ||||||||||||||||||
64 | case executed 470 times by 1 test: MinuteSection:case MinuteSection: Executed by:
executed 470 times by 1 test: minute = newVal; break;case MinuteSection: Executed by:
executed 470 times by 1 test: break; Executed by:
| 470 | ||||||||||||||||||
65 | case executed 434 times by 1 test: SecondSection:case SecondSection: Executed by:
executed 434 times by 1 test: second = newVal; break;case SecondSection: Executed by:
executed 434 times by 1 test: break; Executed by:
| 434 | ||||||||||||||||||
66 | case executed 36 times by 1 test: MSecSection:case MSecSection: Executed by:
executed 36 times by 1 test: msec = newVal; break;case MSecSection: Executed by:
executed 36 times by 1 test: break; Executed by:
| 36 | ||||||||||||||||||
67 | case executed 565 times by 2 tests: YearSection2Digits:case YearSection2Digits: Executed by:
executed 565 times by 2 tests: case YearSection2Digits: Executed by:
| 565 | ||||||||||||||||||
68 | case executed 154 times by 1 test: YearSection:case YearSection: Executed by:
executed 154 times by 1 test: year = newVal; break;case YearSection: Executed by:
executed 719 times by 2 tests: break; Executed by:
| 154-719 | ||||||||||||||||||
69 | case executed 241 times by 4 tests: MonthSection:case MonthSection: Executed by:
executed 241 times by 4 tests: month = newVal; break;case MonthSection: Executed by:
executed 241 times by 4 tests: break; Executed by:
| 241 | ||||||||||||||||||
70 | case executed 445 times by 2 tests: DaySection:case DaySection: Executed by:
executed 445 times by 2 tests: case DaySection: Executed by:
| 445 | ||||||||||||||||||
71 | case executed 90 times by 1 test: DayOfWeekSectionShort:case DayOfWeekSectionShort: Executed by:
executed 90 times by 1 test: case DayOfWeekSectionShort: Executed by:
| 90 | ||||||||||||||||||
72 | case executed 1013 times by 1 test: DayOfWeekSectionLong:case DayOfWeekSectionLong: Executed by:
executed 1013 times by 1 test: case DayOfWeekSectionLong: Executed by:
| 1013 | ||||||||||||||||||
73 | if (newVal > 31
| 0-1548 | ||||||||||||||||||
74 | - | |||||||||||||||||||
75 | - | |||||||||||||||||||
76 | - | |||||||||||||||||||
77 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||
78 | } | - | ||||||||||||||||||
79 | day = newVal; | - | ||||||||||||||||||
80 | break; executed 1548 times by 2 tests: break; Executed by:
| 1548 | ||||||||||||||||||
81 | case executed 6 times by 1 test: AmPmSection:case AmPmSection: Executed by:
executed 6 times by 1 test: hour = (newVal == 0case AmPmSection: Executed by:
executed 6 times by 1 test: break; Executed by:
| 2-6 | ||||||||||||||||||
82 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
83 | QMessageLogger(__FILE__, 165, __PRETTY_FUNCTION__).warning("QDateTimeParser::setDigit() Internal error (%s)", | - | ||||||||||||||||||
84 | QString(node.name()).toLocal8Bit().constData()); | - | ||||||||||||||||||
85 | break; never executed: break; | 0 | ||||||||||||||||||
86 | } | - | ||||||||||||||||||
87 | - | |||||||||||||||||||
88 | if (!(node.type & DaySectionMask)
| 1548-2762 | ||||||||||||||||||
89 | if (day < cachedDay
| 21-2741 | ||||||||||||||||||
90 | day = cachedDay; executed 21 times by 1 test: day = cachedDay; Executed by:
| 21 | ||||||||||||||||||
91 | const int max = QDate(year, month, 1).daysInMonth(); | - | ||||||||||||||||||
92 | if (day > max
| 76-2686 | ||||||||||||||||||
93 | day = max; | - | ||||||||||||||||||
94 | } executed 76 times by 3 tests: end of block Executed by:
| 76 | ||||||||||||||||||
95 | } executed 2762 times by 6 tests: end of block Executed by:
| 2762 | ||||||||||||||||||
96 | if (QDate::isValid(year, month, day)
| 0-4271 | ||||||||||||||||||
97 | v = QDateTime(QDate(year, month, day), QTime(hour, minute, second, msec), spec); | - | ||||||||||||||||||
98 | return executed 4271 times by 7 tests: true;return true; Executed by:
executed 4271 times by 7 tests: return true; Executed by:
| 4271 | ||||||||||||||||||
99 | } | - | ||||||||||||||||||
100 | return executed 39 times by 2 tests: false;return false; Executed by:
executed 39 times by 2 tests: return false; Executed by:
| 39 | ||||||||||||||||||
101 | } | - | ||||||||||||||||||
102 | int QDateTimeParser::absoluteMax(int s, const QDateTime &cur) const | - | ||||||||||||||||||
103 | { | - | ||||||||||||||||||
104 | const SectionNode &sn = sectionNode(s); | - | ||||||||||||||||||
105 | switch (sn.type) { | - | ||||||||||||||||||
106 | case executed 1665 times by 6 tests: Hour24Section:case Hour24Section: Executed by:
executed 1665 times by 6 tests: case Hour24Section: Executed by:
| 1665 | ||||||||||||||||||
107 | case executed 1157 times by 5 tests: Hour12Section:case Hour12Section: Executed by:
executed 1157 times by 5 tests: returncase Hour12Section: Executed by:
executed 2822 times by 8 tests: 23;return 23; Executed by:
executed 2822 times by 8 tests: return 23; Executed by:
| 1157-2822 | ||||||||||||||||||
108 | - | |||||||||||||||||||
109 | - | |||||||||||||||||||
110 | case executed 2268 times by 8 tests: MinuteSection:case MinuteSection: Executed by:
executed 2268 times by 8 tests: case MinuteSection: Executed by:
| 2268 | ||||||||||||||||||
111 | case executed 2062 times by 4 tests: SecondSection:case SecondSection: Executed by:
executed 2062 times by 4 tests: returncase SecondSection: Executed by:
executed 4330 times by 8 tests: 59;return 59; Executed by:
executed 4330 times by 8 tests: return 59; Executed by:
| 2062-4330 | ||||||||||||||||||
112 | case executed 237 times by 2 tests: MSecSection:case MSecSection: Executed by:
executed 237 times by 2 tests: returncase MSecSection: Executed by:
executed 237 times by 2 tests: 999;return 999; Executed by:
executed 237 times by 2 tests: return 999; Executed by:
| 237 | ||||||||||||||||||
113 | case executed 1439 times by 7 tests: YearSection2Digits:case YearSection2Digits: Executed by:
executed 1439 times by 7 tests: case YearSection2Digits: Executed by:
| 1439 | ||||||||||||||||||
114 | case executed 2034 times by 6 tests: YearSection:case YearSection: Executed by:
executed 2034 times by 6 tests: returncase YearSection: Executed by:
executed 3473 times by 10 tests: 9999;return 9999; Executed by:
executed 3473 times by 10 tests: return 9999; Executed by:
| 2034-3473 | ||||||||||||||||||
115 | - | |||||||||||||||||||
116 | - | |||||||||||||||||||
117 | - | |||||||||||||||||||
118 | case executed 1928 times by 7 tests: MonthSection:case MonthSection: Executed by:
executed 1928 times by 7 tests: returncase MonthSection: Executed by:
executed 1928 times by 7 tests: 12;return 12; Executed by:
executed 1928 times by 7 tests: return 12; Executed by:
| 1928 | ||||||||||||||||||
119 | case executed 2979 times by 10 tests: DaySection:case DaySection: Executed by:
executed 2979 times by 10 tests: case DaySection: Executed by:
| 2979 | ||||||||||||||||||
120 | case executed 90 times by 1 test: DayOfWeekSectionShort:case DayOfWeekSectionShort: Executed by:
executed 90 times by 1 test: case DayOfWeekSectionShort: Executed by:
| 90 | ||||||||||||||||||
121 | case executed 1013 times by 1 test: DayOfWeekSectionLong:case DayOfWeekSectionLong: Executed by:
executed 1013 times by 1 test: returncase DayOfWeekSectionLong: Executed by:
executed 4082 times by 10 tests: cur.isValid() ? cur.date().daysInMonth() : 31;return cur.isValid() ? cur.date().daysInMonth() : 31; Executed by:
executed 4082 times by 10 tests: return cur.isValid() ? cur.date().daysInMonth() : 31; Executed by:
| 1013-4082 | ||||||||||||||||||
122 | case executed 6 times by 1 test: AmPmSection:case AmPmSection: Executed by:
executed 6 times by 1 test: returncase AmPmSection: Executed by:
executed 6 times by 1 test: 1;return 1; Executed by:
executed 6 times by 1 test: return 1; Executed by:
| 6 | ||||||||||||||||||
123 | default never executed: :default: never executed: break;default: never executed: break; | 0 | ||||||||||||||||||
124 | } | - | ||||||||||||||||||
125 | QMessageLogger(__FILE__, 216, __PRETTY_FUNCTION__).warning("QDateTimeParser::absoluteMax() Internal error (%s)", | - | ||||||||||||||||||
126 | QString(sn.name()).toLocal8Bit().constData()); | - | ||||||||||||||||||
127 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
128 | } | - | ||||||||||||||||||
129 | - | |||||||||||||||||||
130 | - | |||||||||||||||||||
131 | - | |||||||||||||||||||
132 | - | |||||||||||||||||||
133 | - | |||||||||||||||||||
134 | - | |||||||||||||||||||
135 | - | |||||||||||||||||||
136 | int QDateTimeParser::absoluteMin(int s) const | - | ||||||||||||||||||
137 | { | - | ||||||||||||||||||
138 | const SectionNode &sn = sectionNode(s); | - | ||||||||||||||||||
139 | switch (sn.type) { | - | ||||||||||||||||||
140 | case executed 1665 times by 6 tests: Hour24Section:case Hour24Section: Executed by:
executed 1665 times by 6 tests: case Hour24Section: Executed by:
| 1665 | ||||||||||||||||||
141 | case executed 1157 times by 5 tests: Hour12Section:case Hour12Section: Executed by:
executed 1157 times by 5 tests: case Hour12Section: Executed by:
| 1157 | ||||||||||||||||||
142 | case executed 2257 times by 8 tests: MinuteSection:case MinuteSection: Executed by:
executed 2257 times by 8 tests: case MinuteSection: Executed by:
| 2257 | ||||||||||||||||||
143 | case executed 2050 times by 4 tests: SecondSection:case SecondSection: Executed by:
executed 2050 times by 4 tests: case SecondSection: Executed by:
| 2050 | ||||||||||||||||||
144 | case executed 237 times by 2 tests: MSecSection:case MSecSection: Executed by:
executed 237 times by 2 tests: case MSecSection: Executed by:
| 237 | ||||||||||||||||||
145 | case executed 1436 times by 7 tests: YearSection2Digits:case YearSection2Digits: Executed by:
executed 1436 times by 7 tests: case YearSection2Digits: Executed by:
| 1436 | ||||||||||||||||||
146 | case executed 2034 times by 6 tests: YearSection:case YearSection: Executed by:
executed 2034 times by 6 tests: returncase YearSection: Executed by:
executed 10836 times by 11 tests: 0;return 0; Executed by:
executed 10836 times by 11 tests: return 0; Executed by:
| 2034-10836 | ||||||||||||||||||
147 | case executed 1916 times by 7 tests: MonthSection:case MonthSection: Executed by:
executed 1916 times by 7 tests: case MonthSection: Executed by:
| 1916 | ||||||||||||||||||
148 | case executed 2955 times by 10 tests: DaySection:case DaySection: Executed by:
executed 2955 times by 10 tests: case DaySection: Executed by:
| 2955 | ||||||||||||||||||
149 | case executed 90 times by 1 test: DayOfWeekSectionShort:case DayOfWeekSectionShort: Executed by:
executed 90 times by 1 test: case DayOfWeekSectionShort: Executed by:
| 90 | ||||||||||||||||||
150 | case executed 1013 times by 1 test: DayOfWeekSectionLong:case DayOfWeekSectionLong: Executed by:
executed 1013 times by 1 test: returncase DayOfWeekSectionLong: Executed by:
executed 5974 times by 10 tests: 1;return 1; Executed by:
executed 5974 times by 10 tests: return 1; Executed by:
| 1013-5974 | ||||||||||||||||||
151 | case executed 6 times by 1 test: AmPmSection:case AmPmSection: Executed by:
executed 6 times by 1 test: returncase AmPmSection: Executed by:
executed 6 times by 1 test: 0;return 0; Executed by:
executed 6 times by 1 test: return 0; Executed by:
| 6 | ||||||||||||||||||
152 | default never executed: :default: never executed: break;default: never executed: break; | 0 | ||||||||||||||||||
153 | } | - | ||||||||||||||||||
154 | QMessageLogger(__FILE__, 245, __PRETTY_FUNCTION__).warning("QDateTimeParser::absoluteMin() Internal error (%s, %0x)", | - | ||||||||||||||||||
155 | QString(sn.name()).toLocal8Bit().constData(), sn.type); | - | ||||||||||||||||||
156 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
157 | } | - | ||||||||||||||||||
158 | - | |||||||||||||||||||
159 | - | |||||||||||||||||||
160 | - | |||||||||||||||||||
161 | - | |||||||||||||||||||
162 | - | |||||||||||||||||||
163 | - | |||||||||||||||||||
164 | - | |||||||||||||||||||
165 | const QDateTimeParser::SectionNode &QDateTimeParser::sectionNode(int sectionIndex) const | - | ||||||||||||||||||
166 | { | - | ||||||||||||||||||
167 | if (sectionIndex < 0
| 709-148184 | ||||||||||||||||||
168 | switch (sectionIndex) { | - | ||||||||||||||||||
169 | case executed 229 times by 4 tests: FirstSectionIndex:case FirstSectionIndex: Executed by:
executed 229 times by 4 tests: case FirstSectionIndex: Executed by:
| 229 | ||||||||||||||||||
170 | return executed 229 times by 4 tests: first;return first; Executed by:
executed 229 times by 4 tests: return first; Executed by:
| 229 | ||||||||||||||||||
171 | case executed 7 times by 1 test: LastSectionIndex:case LastSectionIndex: Executed by:
executed 7 times by 1 test: case LastSectionIndex: Executed by:
| 7 | ||||||||||||||||||
172 | return executed 7 times by 1 test: last;return last; Executed by:
executed 7 times by 1 test: return last; Executed by:
| 7 | ||||||||||||||||||
173 | case executed 473 times by 7 tests: NoSectionIndex:case NoSectionIndex: Executed by:
executed 473 times by 7 tests: case NoSectionIndex: Executed by:
| 473 | ||||||||||||||||||
174 | return executed 473 times by 7 tests: none;return none; Executed by:
executed 473 times by 7 tests: return none; Executed by:
| 473 | ||||||||||||||||||
175 | } | - | ||||||||||||||||||
176 | } never executed: else if (sectionIndex < sectionNodes.size()end of block
| 0-148184 | ||||||||||||||||||
177 | return executed 148184 times by 11 tests: sectionNodes.at(sectionIndex);return sectionNodes.at(sectionIndex); Executed by:
executed 148184 times by 11 tests: return sectionNodes.at(sectionIndex); Executed by:
| 148184 | ||||||||||||||||||
178 | } | - | ||||||||||||||||||
179 | - | |||||||||||||||||||
180 | QMessageLogger(__FILE__, 271, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionNode() Internal error (%d)", | - | ||||||||||||||||||
181 | sectionIndex); | - | ||||||||||||||||||
182 | return never executed: none;return none; never executed: return none; | 0 | ||||||||||||||||||
183 | } | - | ||||||||||||||||||
184 | - | |||||||||||||||||||
185 | QDateTimeParser::Section QDateTimeParser::sectionType(int sectionIndex) const | - | ||||||||||||||||||
186 | { | - | ||||||||||||||||||
187 | return executed 6740 times by 10 tests: sectionNode(sectionIndex).type;return sectionNode(sectionIndex).type; Executed by:
executed 6740 times by 10 tests: return sectionNode(sectionIndex).type; Executed by:
| 6740 | ||||||||||||||||||
188 | } | - | ||||||||||||||||||
189 | int QDateTimeParser::sectionPos(int sectionIndex) const | - | ||||||||||||||||||
190 | { | - | ||||||||||||||||||
191 | return executed 49357 times by 4 tests: sectionPos(sectionNode(sectionIndex));return sectionPos(sectionNode(sectionIndex)); Executed by:
executed 49357 times by 4 tests: return sectionPos(sectionNode(sectionIndex)); Executed by:
| 49357 | ||||||||||||||||||
192 | } | - | ||||||||||||||||||
193 | - | |||||||||||||||||||
194 | int QDateTimeParser::sectionPos(const SectionNode &sn) const | - | ||||||||||||||||||
195 | { | - | ||||||||||||||||||
196 | switch (sn.type) { | - | ||||||||||||||||||
197 | case executed 117 times by 4 tests: FirstSection:case FirstSection: Executed by:
executed 117 times by 4 tests: returncase FirstSection: Executed by:
executed 117 times by 4 tests: 0;return 0; Executed by:
executed 117 times by 4 tests: return 0; Executed by:
| 117 | ||||||||||||||||||
198 | case never executed: LastSection:case LastSection: never executed: returncase LastSection: never executed: displayText().size() - 1;return displayText().size() - 1; never executed: return displayText().size() - 1; | 0 | ||||||||||||||||||
199 | default executed 51900 times by 4 tests: :default: Executed by:
executed 51900 times by 4 tests: break;default: Executed by:
executed 51900 times by 4 tests: break; Executed by:
| 51900 | ||||||||||||||||||
200 | } | - | ||||||||||||||||||
201 | if (sn.pos == -1
| 0-51900 | ||||||||||||||||||
202 | QMessageLogger(__FILE__, 301, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionPos Internal error (%s)", QString(sn.name()).toLocal8Bit().constData()); | - | ||||||||||||||||||
203 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
204 | } | - | ||||||||||||||||||
205 | return executed 51900 times by 4 tests: sn.pos;return sn.pos; Executed by:
executed 51900 times by 4 tests: return sn.pos; Executed by:
| 51900 | ||||||||||||||||||
206 | } | - | ||||||||||||||||||
207 | static QString unquote(const QStringRef &str) | - | ||||||||||||||||||
208 | { | - | ||||||||||||||||||
209 | const QChar quote(QLatin1Char('\'')); | - | ||||||||||||||||||
210 | const QChar slash(QLatin1Char('\\')); | - | ||||||||||||||||||
211 | const QChar zero(QLatin1Char('0')); | - | ||||||||||||||||||
212 | QString ret; | - | ||||||||||||||||||
213 | QChar status(zero); | - | ||||||||||||||||||
214 | const int max = str.size(); | - | ||||||||||||||||||
215 | for (int i=0; i<max
| 476-991 | ||||||||||||||||||
216 | if (str.at(i) == quote
| 21-455 | ||||||||||||||||||
217 | if (status != quote
| 10-11 | ||||||||||||||||||
218 | status = quote; | - | ||||||||||||||||||
219 | } executed 11 times by 4 tests: else if (!ret.isEmpty()end of block Executed by:
| 0-11 | ||||||||||||||||||
220 | ret[ret.size() - 1] = quote; | - | ||||||||||||||||||
221 | } never executed: else {end of block | 0 | ||||||||||||||||||
222 | status = zero; | - | ||||||||||||||||||
223 | } executed 10 times by 4 tests: end of block Executed by:
| 10 | ||||||||||||||||||
224 | } else { | - | ||||||||||||||||||
225 | ret += str.at(i); | - | ||||||||||||||||||
226 | } executed 455 times by 5 tests: end of block Executed by:
| 455 | ||||||||||||||||||
227 | } | - | ||||||||||||||||||
228 | return executed 991 times by 10 tests: ret;return ret; Executed by:
executed 991 times by 10 tests: return ret; Executed by:
| 991 | ||||||||||||||||||
229 | } | - | ||||||||||||||||||
230 | static inline int countRepeat(const QString &str, int index, int maxCount) | - | ||||||||||||||||||
231 | { | - | ||||||||||||||||||
232 | int count = 1; | - | ||||||||||||||||||
233 | const QChar ch(str.at(index)); | - | ||||||||||||||||||
234 | const int max = qMin(index + maxCount, str.size()); | - | ||||||||||||||||||
235 | while (index + count < max
| 1948-7926 | ||||||||||||||||||
236 | ++count; | - | ||||||||||||||||||
237 | } executed 5978 times by 11 tests: end of block Executed by:
| 5978 | ||||||||||||||||||
238 | return executed 3898 times by 11 tests: count;return count; Executed by:
executed 3898 times by 11 tests: return count; Executed by:
| 3898 | ||||||||||||||||||
239 | } | - | ||||||||||||||||||
240 | - | |||||||||||||||||||
241 | static inline void appendSeparator(QStringList *list, const QString &string, int from, int size, int lastQuote) | - | ||||||||||||||||||
242 | { | - | ||||||||||||||||||
243 | const QStringRef separator = string.midRef(from, size); | - | ||||||||||||||||||
244 | list->append(lastQuote >= from ? unquote(separator) : separator.toString()); | - | ||||||||||||||||||
245 | } executed 3025 times by 11 tests: end of block Executed by:
| 3025 | ||||||||||||||||||
246 | - | |||||||||||||||||||
247 | - | |||||||||||||||||||
248 | bool QDateTimeParser::parseFormat(const QString &newFormat) | - | ||||||||||||||||||
249 | { | - | ||||||||||||||||||
250 | const QLatin1Char quote('\''); | - | ||||||||||||||||||
251 | const QLatin1Char slash('\\'); | - | ||||||||||||||||||
252 | const QLatin1Char zero('0'); | - | ||||||||||||||||||
253 | if (newFormat == displayFormat
| 2-1149 | ||||||||||||||||||
254 | return executed 173 times by 1 test: true;return true; Executed by:
executed 173 times by 1 test: return true; Executed by:
| 173 | ||||||||||||||||||
255 | } | - | ||||||||||||||||||
256 | - | |||||||||||||||||||
257 | if (false) QMessageLogger(__FILE__, 374, __PRETTY_FUNCTION__).debug("parseFormat: %s", newFormat.toLatin1().constData()); dead code: QMessageLogger(__FILE__, 374, __PRETTY_FUNCTION__).debug("parseFormat: %s", newFormat.toLatin1().constData()); | - | ||||||||||||||||||
258 | - | |||||||||||||||||||
259 | QVector<SectionNode> newSectionNodes; | - | ||||||||||||||||||
260 | Sections newDisplay = 0; | - | ||||||||||||||||||
261 | QStringList newSeparators; | - | ||||||||||||||||||
262 | int i, index = 0; | - | ||||||||||||||||||
263 | int add = 0; | - | ||||||||||||||||||
264 | QChar status(zero); | - | ||||||||||||||||||
265 | const int max = newFormat.size(); | - | ||||||||||||||||||
266 | int lastQuote = -1; | - | ||||||||||||||||||
267 | for (i = 0; i<max
| 1151-7177 | ||||||||||||||||||
268 | if (newFormat.at(i) == quote
| 21-7156 | ||||||||||||||||||
269 | lastQuote = i; | - | ||||||||||||||||||
270 | ++add; | - | ||||||||||||||||||
271 | if (status != quote
| 10-11 | ||||||||||||||||||
272 | status = quote; | - | ||||||||||||||||||
273 | } executed 11 times by 4 tests: else if (i > 0end of block Executed by:
| 0-11 | ||||||||||||||||||
274 | status = zero; | - | ||||||||||||||||||
275 | } executed 10 times by 4 tests: end of block Executed by:
| 10 | ||||||||||||||||||
276 | } executed 21 times by 4 tests: else if (status != quoteend of block Executed by:
| 21-7117 | ||||||||||||||||||
277 | const char sect = newFormat.at(i).toLatin1(); | - | ||||||||||||||||||
278 | switch (sect) { | - | ||||||||||||||||||
279 | case executed 81 times by 4 tests: 'H':case 'H': Executed by:
executed 81 times by 4 tests: case 'H': Executed by:
| 81 | ||||||||||||||||||
280 | case executed 319 times by 8 tests: 'h':case 'h': Executed by:
executed 319 times by 8 tests: case 'h': Executed by:
| 319 | ||||||||||||||||||
281 | if (parserType != QVariant::Date
| 3-397 | ||||||||||||||||||
282 | const Section hour = (
| 81-316 | ||||||||||||||||||
283 | const SectionNode sn = { hour, i - add, countRepeat(newFormat, i, 2), 0 }; | - | ||||||||||||||||||
284 | newSectionNodes.append(sn); | - | ||||||||||||||||||
285 | appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); | - | ||||||||||||||||||
286 | i += sn.count - 1; | - | ||||||||||||||||||
287 | index = i + 1; | - | ||||||||||||||||||
288 | newDisplay |= hour; | - | ||||||||||||||||||
289 | } executed 397 times by 8 tests: end of block Executed by:
| 397 | ||||||||||||||||||
290 | break; executed 400 times by 9 tests: break; Executed by:
| 400 | ||||||||||||||||||
291 | case executed 379 times by 8 tests: 'm':case 'm': Executed by:
executed 379 times by 8 tests: case 'm': Executed by:
| 379 | ||||||||||||||||||
292 | if (parserType != QVariant::Date
| 0-379 | ||||||||||||||||||
293 | const SectionNode sn = { MinuteSection, i - add, countRepeat(newFormat, i, 2), 0 }; | - | ||||||||||||||||||
294 | newSectionNodes.append(sn); | - | ||||||||||||||||||
295 | appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); | - | ||||||||||||||||||
296 | i += sn.count - 1; | - | ||||||||||||||||||
297 | index = i + 1; | - | ||||||||||||||||||
298 | newDisplay |= MinuteSection; | - | ||||||||||||||||||
299 | } executed 379 times by 8 tests: end of block Executed by:
| 379 | ||||||||||||||||||
300 | break; executed 379 times by 8 tests: break; Executed by:
| 379 | ||||||||||||||||||
301 | case executed 236 times by 4 tests: 's':case 's': Executed by:
executed 236 times by 4 tests: case 's': Executed by:
| 236 | ||||||||||||||||||
302 | if (parserType != QVariant::Date
| 0-236 | ||||||||||||||||||
303 | const SectionNode sn = { SecondSection, i - add, countRepeat(newFormat, i, 2), 0 }; | - | ||||||||||||||||||
304 | newSectionNodes.append(sn); | - | ||||||||||||||||||
305 | appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); | - | ||||||||||||||||||
306 | i += sn.count - 1; | - | ||||||||||||||||||
307 | index = i + 1; | - | ||||||||||||||||||
308 | newDisplay |= SecondSection; | - | ||||||||||||||||||
309 | } executed 236 times by 4 tests: end of block Executed by:
| 236 | ||||||||||||||||||
310 | break; executed 236 times by 4 tests: break; Executed by:
| 236 | ||||||||||||||||||
311 | - | |||||||||||||||||||
312 | case executed 47 times by 2 tests: 'z':case 'z': Executed by:
executed 47 times by 2 tests: case 'z': Executed by:
| 47 | ||||||||||||||||||
313 | if (parserType != QVariant::Date
| 0-47 | ||||||||||||||||||
314 | const SectionNode sn = { MSecSection, i - add, countRepeat(newFormat, i, 3) < 3 ? 1 : 3, 0 }; | - | ||||||||||||||||||
315 | newSectionNodes.append(sn); | - | ||||||||||||||||||
316 | appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); | - | ||||||||||||||||||
317 | i += sn.count - 1; | - | ||||||||||||||||||
318 | index = i + 1; | - | ||||||||||||||||||
319 | newDisplay |= MSecSection; | - | ||||||||||||||||||
320 | } executed 47 times by 2 tests: end of block Executed by:
| 47 | ||||||||||||||||||
321 | break; executed 47 times by 2 tests: break; Executed by:
| 47 | ||||||||||||||||||
322 | case executed 16 times by 5 tests: 'A':case 'A': Executed by:
executed 16 times by 5 tests: case 'A': Executed by:
| 16 | ||||||||||||||||||
323 | case executed 79 times by 4 tests: 'a':case 'a': Executed by:
executed 79 times by 4 tests: case 'a': Executed by:
| 79 | ||||||||||||||||||
324 | if (parserType != QVariant::Date
| 2-93 | ||||||||||||||||||
325 | const bool cap = (sect == 'A'); | - | ||||||||||||||||||
326 | const SectionNode sn = { AmPmSection, i - add, (cap ? 1 : 0), 0 }; | - | ||||||||||||||||||
327 | newSectionNodes.append(sn); | - | ||||||||||||||||||
328 | appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); | - | ||||||||||||||||||
329 | newDisplay |= AmPmSection; | - | ||||||||||||||||||
330 | if (i + 1 < newFormat.size()
| 1-92 | ||||||||||||||||||
331 | && newFormat.at(i+1) == (cap
| 0-92 | ||||||||||||||||||
332 | ++i; | - | ||||||||||||||||||
333 | } executed 92 times by 5 tests: end of block Executed by:
| 92 | ||||||||||||||||||
334 | index = i + 1; | - | ||||||||||||||||||
335 | } executed 93 times by 5 tests: end of block Executed by:
| 93 | ||||||||||||||||||
336 | break; executed 95 times by 6 tests: break; Executed by:
| 95 | ||||||||||||||||||
337 | case executed 863 times by 10 tests: 'y':case 'y': Executed by:
executed 863 times by 10 tests: case 'y': Executed by:
| 863 | ||||||||||||||||||
338 | if (parserType != QVariant::Time
| 4-859 | ||||||||||||||||||
339 | const int repeat = countRepeat(newFormat, i, 4); | - | ||||||||||||||||||
340 | if (repeat >= 2
| 1-858 | ||||||||||||||||||
341 | const SectionNode sn = { repeat == 4 ? YearSection : YearSection2Digits, | - | ||||||||||||||||||
342 | i - add, repeat == 4 ? 4 : 2, 0 }; | - | ||||||||||||||||||
343 | newSectionNodes.append(sn); | - | ||||||||||||||||||
344 | appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); | - | ||||||||||||||||||
345 | i += sn.count - 1; | - | ||||||||||||||||||
346 | index = i + 1; | - | ||||||||||||||||||
347 | newDisplay |= sn.type; | - | ||||||||||||||||||
348 | } executed 858 times by 10 tests: end of block Executed by:
| 858 | ||||||||||||||||||
349 | } executed 859 times by 10 tests: end of block Executed by:
| 859 | ||||||||||||||||||
350 | break; executed 863 times by 10 tests: break; Executed by:
| 863 | ||||||||||||||||||
351 | case executed 981 times by 10 tests: 'M':case 'M': Executed by:
executed 981 times by 10 tests: case 'M': Executed by:
| 981 | ||||||||||||||||||
352 | if (parserType != QVariant::Time
| 0-981 | ||||||||||||||||||
353 | const SectionNode sn = { MonthSection, i - add, countRepeat(newFormat, i, 4), 0 }; | - | ||||||||||||||||||
354 | newSectionNodes.append(sn); | - | ||||||||||||||||||
355 | newSeparators.append(unquote(newFormat.midRef(index, i - index))); | - | ||||||||||||||||||
356 | i += sn.count - 1; | - | ||||||||||||||||||
357 | index = i + 1; | - | ||||||||||||||||||
358 | newDisplay |= MonthSection; | - | ||||||||||||||||||
359 | } executed 981 times by 10 tests: end of block Executed by:
| 981 | ||||||||||||||||||
360 | break; executed 981 times by 10 tests: break; Executed by:
| 981 | ||||||||||||||||||
361 | case executed 999 times by 10 tests: 'd':case 'd': Executed by:
executed 999 times by 10 tests: case 'd': Executed by:
| 999 | ||||||||||||||||||
362 | if (parserType != QVariant::Time
| 0-999 | ||||||||||||||||||
363 | const int repeat = countRepeat(newFormat, i, 4); | - | ||||||||||||||||||
364 | const Section sectionType = (repeat == 4
| 31-968 | ||||||||||||||||||
365 | : (repeat == 3
| 6-962 | ||||||||||||||||||
366 | const SectionNode sn = { sectionType, i - add, repeat, 0 }; | - | ||||||||||||||||||
367 | newSectionNodes.append(sn); | - | ||||||||||||||||||
368 | appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); | - | ||||||||||||||||||
369 | i += sn.count - 1; | - | ||||||||||||||||||
370 | index = i + 1; | - | ||||||||||||||||||
371 | newDisplay |= sn.type; | - | ||||||||||||||||||
372 | } executed 999 times by 10 tests: end of block Executed by:
| 999 | ||||||||||||||||||
373 | break; executed 999 times by 10 tests: break; Executed by:
| 999 | ||||||||||||||||||
374 | - | |||||||||||||||||||
375 | default executed 3117 times by 10 tests: :default: Executed by:
executed 3117 times by 10 tests: default: Executed by:
| 3117 | ||||||||||||||||||
376 | break; executed 3117 times by 10 tests: break; Executed by:
| 3117 | ||||||||||||||||||
377 | } | - | ||||||||||||||||||
378 | } | - | ||||||||||||||||||
379 | } executed 7177 times by 11 tests: end of block Executed by:
| 7177 | ||||||||||||||||||
380 | if (newSectionNodes.isEmpty()
| 2-1140 | ||||||||||||||||||
381 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||
382 | } | - | ||||||||||||||||||
383 | - | |||||||||||||||||||
384 | if ((
| 218-931 | ||||||||||||||||||
385 | const int count = newSectionNodes.size(); | - | ||||||||||||||||||
386 | for (int i = 0; i < count
| 218-878 | ||||||||||||||||||
387 | SectionNode &node = newSectionNodes[i]; | - | ||||||||||||||||||
388 | if (node.type == Hour12Section
| 229-649 | ||||||||||||||||||
389 | node.type = Hour24Section; executed 229 times by 5 tests: node.type = Hour24Section; Executed by:
| 229 | ||||||||||||||||||
390 | } executed 878 times by 5 tests: end of block Executed by:
| 878 | ||||||||||||||||||
391 | } executed 218 times by 5 tests: end of block Executed by:
| 218 | ||||||||||||||||||
392 | - | |||||||||||||||||||
393 | if (index < max
| 16-1133 | ||||||||||||||||||
394 | appendSeparator(&newSeparators, newFormat, index, index - max, lastQuote); | - | ||||||||||||||||||
395 | } executed 16 times by 4 tests: else {end of block Executed by:
| 16 | ||||||||||||||||||
396 | newSeparators.append(QString()); | - | ||||||||||||||||||
397 | } executed 1133 times by 10 tests: end of block Executed by:
| 1133 | ||||||||||||||||||
398 | - | |||||||||||||||||||
399 | displayFormat = newFormat; | - | ||||||||||||||||||
400 | separators = newSeparators; | - | ||||||||||||||||||
401 | sectionNodes = newSectionNodes; | - | ||||||||||||||||||
402 | display = newDisplay; | - | ||||||||||||||||||
403 | last.pos = -1; | - | ||||||||||||||||||
404 | - | |||||||||||||||||||
405 | - | |||||||||||||||||||
406 | - | |||||||||||||||||||
407 | - | |||||||||||||||||||
408 | - | |||||||||||||||||||
409 | if (false) QMessageLogger(__FILE__, 526, __PRETTY_FUNCTION__).debug() << newFormat << displayFormat; dead code: QMessageLogger(__FILE__, 526, __PRETTY_FUNCTION__).debug() << newFormat << displayFormat; | - | ||||||||||||||||||
410 | if (false) QMessageLogger(__FILE__, 527, __PRETTY_FUNCTION__).debug("separators:\n'%s'", separators.join(QLatin1String("\n")).toLatin1().constData()); dead code: QMessageLogger(__FILE__, 527, __PRETTY_FUNCTION__).debug("separators:\n'%s'", separators.join(QLatin1String("\n")).toLatin1().constData()); | - | ||||||||||||||||||
411 | - | |||||||||||||||||||
412 | return executed 1149 times by 11 tests: true;return true; Executed by:
executed 1149 times by 11 tests: return true; Executed by:
| 1149 | ||||||||||||||||||
413 | } | - | ||||||||||||||||||
414 | - | |||||||||||||||||||
415 | - | |||||||||||||||||||
416 | - | |||||||||||||||||||
417 | - | |||||||||||||||||||
418 | - | |||||||||||||||||||
419 | - | |||||||||||||||||||
420 | - | |||||||||||||||||||
421 | int QDateTimeParser::sectionSize(int sectionIndex) const | - | ||||||||||||||||||
422 | { | - | ||||||||||||||||||
423 | if (sectionIndex < 0
| 0-18759 | ||||||||||||||||||
424 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
425 | - | |||||||||||||||||||
426 | if (sectionIndex >= sectionNodes.size()
| 0-18759 | ||||||||||||||||||
427 | QMessageLogger(__FILE__, 544, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionSize Internal error (%d)", sectionIndex); | - | ||||||||||||||||||
428 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
429 | } | - | ||||||||||||||||||
430 | - | |||||||||||||||||||
431 | if (sectionIndex == sectionNodes.size() - 1
| 4554-14205 | ||||||||||||||||||
432 | - | |||||||||||||||||||
433 | - | |||||||||||||||||||
434 | - | |||||||||||||||||||
435 | - | |||||||||||||||||||
436 | int sizeAdjustment = 0; | - | ||||||||||||||||||
437 | const int displayTextSize = displayText().size(); | - | ||||||||||||||||||
438 | if (displayTextSize != text.size()
| 23-4531 | ||||||||||||||||||
439 | - | |||||||||||||||||||
440 | int preceedingZeroesAdded = 0; | - | ||||||||||||||||||
441 | if (sectionNodes.size() > 1
| 0-23 | ||||||||||||||||||
442 | const auto begin = sectionNodes.cbegin(); | - | ||||||||||||||||||
443 | const auto end = begin + sectionIndex; | - | ||||||||||||||||||
444 | for (auto sectionIt = begin; sectionIt != end
| 23-40 | ||||||||||||||||||
445 | preceedingZeroesAdded += sectionIt->zeroesAdded; executed 40 times by 1 test: preceedingZeroesAdded += sectionIt->zeroesAdded; Executed by:
| 40 | ||||||||||||||||||
446 | } executed 23 times by 1 test: end of block Executed by:
| 23 | ||||||||||||||||||
447 | sizeAdjustment = preceedingZeroesAdded; | - | ||||||||||||||||||
448 | } executed 23 times by 1 test: end of block Executed by:
| 23 | ||||||||||||||||||
449 | - | |||||||||||||||||||
450 | return executed 4554 times by 1 test: displayTextSize + sizeAdjustment - sectionPos(sectionIndex) - separators.last().size();return displayTextSize + sizeAdjustment - sectionPos(sectionIndex) - separators.last().size(); Executed by:
executed 4554 times by 1 test: return displayTextSize + sizeAdjustment - sectionPos(sectionIndex) - separators.last().size(); Executed by:
| 4554 | ||||||||||||||||||
451 | } else { | - | ||||||||||||||||||
452 | return executed 14205 times by 4 tests: sectionPos(sectionIndex + 1) - sectionPos(sectionIndex)return sectionPos(sectionIndex + 1) - sectionPos(sectionIndex) - separators.at(sectionIndex + 1).size(); Executed by:
executed 14205 times by 4 tests: return sectionPos(sectionIndex + 1) - sectionPos(sectionIndex) - separators.at(sectionIndex + 1).size(); Executed by:
| 14205 | ||||||||||||||||||
453 | - separators.at(sectionIndex + 1).size(); executed 14205 times by 4 tests: return sectionPos(sectionIndex + 1) - sectionPos(sectionIndex) - separators.at(sectionIndex + 1).size(); Executed by:
| 14205 | ||||||||||||||||||
454 | } | - | ||||||||||||||||||
455 | } | - | ||||||||||||||||||
456 | - | |||||||||||||||||||
457 | - | |||||||||||||||||||
458 | int QDateTimeParser::sectionMaxSize(Section s, int count) const | - | ||||||||||||||||||
459 | { | - | ||||||||||||||||||
460 | - | |||||||||||||||||||
461 | int mcount = 12; | - | ||||||||||||||||||
462 | - | |||||||||||||||||||
463 | - | |||||||||||||||||||
464 | switch (s) { | - | ||||||||||||||||||
465 | case never executed: FirstSection:case FirstSection: never executed: case FirstSection: | 0 | ||||||||||||||||||
466 | case never executed: NoSection:case NoSection: never executed: case NoSection: | 0 | ||||||||||||||||||
467 | case never executed: LastSection:case LastSection: never executed: returncase LastSection: never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
468 | - | |||||||||||||||||||
469 | case executed 1726 times by 5 tests: AmPmSection:case AmPmSection: Executed by:
executed 1726 times by 5 tests: {case AmPmSection: Executed by:
| 1726 | ||||||||||||||||||
470 | const int lowerMax = qMin(getAmPmText(AmText, LowerCase).size(), | - | ||||||||||||||||||
471 | getAmPmText(PmText, LowerCase).size()); | - | ||||||||||||||||||
472 | const int upperMax = qMin(getAmPmText(AmText, UpperCase).size(), | - | ||||||||||||||||||
473 | getAmPmText(PmText, UpperCase).size()); | - | ||||||||||||||||||
474 | return executed 1726 times by 5 tests: qMin(4, qMin(lowerMax, upperMax));return qMin(4, qMin(lowerMax, upperMax)); Executed by:
executed 1726 times by 5 tests: return qMin(4, qMin(lowerMax, upperMax)); Executed by:
| 1726 | ||||||||||||||||||
475 | } | - | ||||||||||||||||||
476 | - | |||||||||||||||||||
477 | case executed 1483 times by 6 tests: Hour24Section:case Hour24Section: Executed by:
executed 1483 times by 6 tests: case Hour24Section: Executed by:
| 1483 | ||||||||||||||||||
478 | case executed 943 times by 5 tests: Hour12Section:case Hour12Section: Executed by:
executed 943 times by 5 tests: case Hour12Section: Executed by:
| 943 | ||||||||||||||||||
479 | case executed 2232 times by 8 tests: MinuteSection:case MinuteSection: Executed by:
executed 2232 times by 8 tests: case MinuteSection: Executed by:
| 2232 | ||||||||||||||||||
480 | case executed 1931 times by 4 tests: SecondSection:case SecondSection: Executed by:
executed 1931 times by 4 tests: case SecondSection: Executed by:
| 1931 | ||||||||||||||||||
481 | case executed 3222 times by 10 tests: DaySection:case DaySection: Executed by:
executed 3222 times by 10 tests: returncase DaySection: Executed by:
executed 9811 times by 11 tests: 2;return 2; Executed by:
executed 9811 times by 11 tests: return 2; Executed by:
| 3222-9811 | ||||||||||||||||||
482 | case executed 40 times by 3 tests: DayOfWeekSectionShort:case DayOfWeekSectionShort: Executed by:
executed 40 times by 3 tests: case DayOfWeekSectionShort: Executed by:
| 40 | ||||||||||||||||||
483 | case executed 424 times by 3 tests: DayOfWeekSectionLong:case DayOfWeekSectionLong: Executed by:
executed 424 times by 3 tests: case DayOfWeekSectionLong: Executed by:
| 424 | ||||||||||||||||||
484 | - | |||||||||||||||||||
485 | - | |||||||||||||||||||
486 | - | |||||||||||||||||||
487 | mcount = 7; | - | ||||||||||||||||||
488 | - | |||||||||||||||||||
489 | - | |||||||||||||||||||
490 | case executed 3676 times by 10 tests: MonthSection:case MonthSection: Executed by:
executed 3676 times by 10 tests: case MonthSection: Executed by:
code before this statement executed 464 times by 3 tests: case MonthSection: Executed by:
| 464-3676 | ||||||||||||||||||
491 | - | |||||||||||||||||||
492 | - | |||||||||||||||||||
493 | - | |||||||||||||||||||
494 | if (count <= 2
| 1929-2211 | ||||||||||||||||||
495 | return executed 2211 times by 7 tests: 2;return 2; Executed by:
executed 2211 times by 7 tests: return 2; Executed by:
| 2211 | ||||||||||||||||||
496 | - | |||||||||||||||||||
497 | { | - | ||||||||||||||||||
498 | int ret = 0; | - | ||||||||||||||||||
499 | const QLocale l = locale(); | - | ||||||||||||||||||
500 | const QLocale::FormatType format = count == 4
| 619-1310 | ||||||||||||||||||
501 | for (int i=1; i<=mcount
| 1929-20828 | ||||||||||||||||||
502 | const QString str = (s == MonthSection
| 3248-17580 | ||||||||||||||||||
503 | ? l.monthName(i, format) | - | ||||||||||||||||||
504 | : l.dayName(i, format)); | - | ||||||||||||||||||
505 | ret = qMax(str.size(), ret); | - | ||||||||||||||||||
506 | } executed 20828 times by 6 tests: end of block Executed by:
| 20828 | ||||||||||||||||||
507 | return executed 1929 times by 6 tests: ret;return ret; Executed by:
executed 1929 times by 6 tests: return ret; Executed by:
| 1929 | ||||||||||||||||||
508 | } | - | ||||||||||||||||||
509 | - | |||||||||||||||||||
510 | case executed 283 times by 2 tests: MSecSection:case MSecSection: Executed by:
executed 283 times by 2 tests: returncase MSecSection: Executed by:
executed 283 times by 2 tests: 3;return 3; Executed by:
executed 283 times by 2 tests: return 3; Executed by:
| 283 | ||||||||||||||||||
511 | case executed 2161 times by 6 tests: YearSection:case YearSection: Executed by:
executed 2161 times by 6 tests: returncase YearSection: Executed by:
executed 2161 times by 6 tests: 4;return 4; Executed by:
executed 2161 times by 6 tests: return 4; Executed by:
| 2161 | ||||||||||||||||||
512 | case executed 907 times by 7 tests: YearSection2Digits:case YearSection2Digits: Executed by:
executed 907 times by 7 tests: returncase YearSection2Digits: Executed by:
executed 907 times by 7 tests: 2;return 2; Executed by:
executed 907 times by 7 tests: return 2; Executed by:
| 907 | ||||||||||||||||||
513 | - | |||||||||||||||||||
514 | case never executed: CalendarPopupSection:case CalendarPopupSection: never executed: case CalendarPopupSection: | 0 | ||||||||||||||||||
515 | case never executed: Internal:case Internal: never executed: case Internal: | 0 | ||||||||||||||||||
516 | case never executed: TimeSectionMask:case TimeSectionMask: never executed: case TimeSectionMask: | 0 | ||||||||||||||||||
517 | case never executed: DateSectionMask:case DateSectionMask: never executed: case DateSectionMask: | 0 | ||||||||||||||||||
518 | case never executed: HourSectionMask:case HourSectionMask: never executed: case HourSectionMask: | 0 | ||||||||||||||||||
519 | case never executed: YearSectionMask:case YearSectionMask: never executed: case YearSectionMask: | 0 | ||||||||||||||||||
520 | case never executed: DayOfWeekSectionMask:case DayOfWeekSectionMask: never executed: case DayOfWeekSectionMask: | 0 | ||||||||||||||||||
521 | case never executed: DaySectionMask:case DaySectionMask: never executed: case DaySectionMask: | 0 | ||||||||||||||||||
522 | QMessageLogger(__FILE__, 639, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionMaxSize: Invalid section %s", | - | ||||||||||||||||||
523 | SectionNode::name(s).toLatin1().constData()); | - | ||||||||||||||||||
524 | - | |||||||||||||||||||
525 | case never executed: NoSectionIndex:case NoSectionIndex: never executed: case NoSectionIndex: code before this statement never executed: case NoSectionIndex: | 0 | ||||||||||||||||||
526 | case never executed: FirstSectionIndex:case FirstSectionIndex: never executed: case FirstSectionIndex: | 0 | ||||||||||||||||||
527 | case never executed: LastSectionIndex:case LastSectionIndex: never executed: case LastSectionIndex: | 0 | ||||||||||||||||||
528 | case never executed: CalendarPopupIndex:case CalendarPopupIndex: never executed: case CalendarPopupIndex: | 0 | ||||||||||||||||||
529 | - | |||||||||||||||||||
530 | break; never executed: break; | 0 | ||||||||||||||||||
531 | } | - | ||||||||||||||||||
532 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
533 | } | - | ||||||||||||||||||
534 | - | |||||||||||||||||||
535 | - | |||||||||||||||||||
536 | int QDateTimeParser::sectionMaxSize(int index) const | - | ||||||||||||||||||
537 | { | - | ||||||||||||||||||
538 | const SectionNode &sn = sectionNode(index); | - | ||||||||||||||||||
539 | return executed 19028 times by 11 tests: sectionMaxSize(sn.type, sn.count);return sectionMaxSize(sn.type, sn.count); Executed by:
executed 19028 times by 11 tests: return sectionMaxSize(sn.type, sn.count); Executed by:
| 19028 | ||||||||||||||||||
540 | } | - | ||||||||||||||||||
541 | QString QDateTimeParser::sectionText(const QString &text, int sectionIndex, int index) const | - | ||||||||||||||||||
542 | { | - | ||||||||||||||||||
543 | const SectionNode &sn = sectionNode(sectionIndex); | - | ||||||||||||||||||
544 | switch (sn.type) { | - | ||||||||||||||||||
545 | case never executed: NoSectionIndex:case NoSectionIndex: never executed: case NoSectionIndex: | 0 | ||||||||||||||||||
546 | case never executed: FirstSectionIndex:case FirstSectionIndex: never executed: case FirstSectionIndex: | 0 | ||||||||||||||||||
547 | case never executed: LastSectionIndex:case LastSectionIndex: never executed: case LastSectionIndex: | 0 | ||||||||||||||||||
548 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
549 | default executed 175 times by 1 test: :default: Executed by:
executed 175 times by 1 test: break;default: Executed by:
executed 175 times by 1 test: break; Executed by:
| 175 | ||||||||||||||||||
550 | } | - | ||||||||||||||||||
551 | - | |||||||||||||||||||
552 | return executed 175 times by 1 test: text.mid(index, sectionSize(sectionIndex));return text.mid(index, sectionSize(sectionIndex)); Executed by:
executed 175 times by 1 test: return text.mid(index, sectionSize(sectionIndex)); Executed by:
| 175 | ||||||||||||||||||
553 | } | - | ||||||||||||||||||
554 | - | |||||||||||||||||||
555 | QString QDateTimeParser::sectionText(int sectionIndex) const | - | ||||||||||||||||||
556 | { | - | ||||||||||||||||||
557 | const SectionNode &sn = sectionNode(sectionIndex); | - | ||||||||||||||||||
558 | return executed 46 times by 1 test: sectionText(displayText(), sectionIndex, sn.pos);return sectionText(displayText(), sectionIndex, sn.pos); Executed by:
executed 46 times by 1 test: return sectionText(displayText(), sectionIndex, sn.pos); Executed by:
| 46 | ||||||||||||||||||
559 | } | - | ||||||||||||||||||
560 | int QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionIndex, | - | ||||||||||||||||||
561 | QString &text, int &cursorPosition, int index, | - | ||||||||||||||||||
562 | State &state, int *usedptr) const | - | ||||||||||||||||||
563 | { | - | ||||||||||||||||||
564 | state = Invalid; | - | ||||||||||||||||||
565 | int num = 0; | - | ||||||||||||||||||
566 | const SectionNode &sn = sectionNode(sectionIndex); | - | ||||||||||||||||||
567 | if ((
| 0-15899 | ||||||||||||||||||
568 | QMessageLogger(__FILE__, 705, __PRETTY_FUNCTION__).warning("QDateTimeParser::parseSection Internal error (%s %d)", | - | ||||||||||||||||||
569 | QString(sn.name()).toLocal8Bit().constData(), sectionIndex); | - | ||||||||||||||||||
570 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
571 | } | - | ||||||||||||||||||
572 | - | |||||||||||||||||||
573 | const int sectionmaxsize = sectionMaxSize(sectionIndex); | - | ||||||||||||||||||
574 | QStringRef sectionTextRef = text.midRef(index, sectionmaxsize); | - | ||||||||||||||||||
575 | int sectiontextSize = sectionTextRef.size(); | - | ||||||||||||||||||
576 | - | |||||||||||||||||||
577 | if (false) QMessageLogger(__FILE__, 714, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sn.name() dead code: QMessageLogger(__FILE__, 714, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sn.name() << "with text" << text << "and st" << sectionTextRef << text.midRef(index, sectionmaxsize) << index; | - | ||||||||||||||||||
578 | << "with text" << text << "and st" << sectionTextRef dead code: QMessageLogger(__FILE__, 714, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sn.name() << "with text" << text << "and st" << sectionTextRef << text.midRef(index, sectionmaxsize) << index; | - | ||||||||||||||||||
579 | << text.midRef(index, sectionmaxsize) dead code: QMessageLogger(__FILE__, 714, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sn.name() << "with text" << text << "and st" << sectionTextRef << text.midRef(index, sectionmaxsize) << index; | - | ||||||||||||||||||
580 | << index; dead code: QMessageLogger(__FILE__, 714, __PRETTY_FUNCTION__).debug() << "sectionValue for" << sn.name() << "with text" << text << "and st" << sectionTextRef << text.midRef(index, sectionmaxsize) << index; | - | ||||||||||||||||||
581 | - | |||||||||||||||||||
582 | int used = 0; | - | ||||||||||||||||||
583 | switch (sn.type) { | - | ||||||||||||||||||
584 | case executed 863 times by 5 tests: AmPmSection:case AmPmSection: Executed by:
executed 863 times by 5 tests: {case AmPmSection: Executed by:
| 863 | ||||||||||||||||||
585 | QString sectiontext = sectionTextRef.toString(); | - | ||||||||||||||||||
586 | const int ampm = findAmPm(sectiontext, sectionIndex, &used); | - | ||||||||||||||||||
587 | switch (ampm) { | - | ||||||||||||||||||
588 | case executed 758 times by 5 tests: AM:case AM: Executed by:
executed 758 times by 5 tests: case AM: Executed by:
| 758 | ||||||||||||||||||
589 | case executed 103 times by 3 tests: PM:case PM: Executed by:
executed 103 times by 3 tests: case PM: Executed by:
| 103 | ||||||||||||||||||
590 | num = ampm; | - | ||||||||||||||||||
591 | state = Acceptable; | - | ||||||||||||||||||
592 | break; executed 861 times by 5 tests: break; Executed by:
| 861 | ||||||||||||||||||
593 | case never executed: PossibleAM:case PossibleAM: never executed: case PossibleAM: | 0 | ||||||||||||||||||
594 | case never executed: PossiblePM:case PossiblePM: never executed: case PossiblePM: | 0 | ||||||||||||||||||
595 | num = ampm - 2; | - | ||||||||||||||||||
596 | state = Intermediate; | - | ||||||||||||||||||
597 | break; never executed: break; | 0 | ||||||||||||||||||
598 | case never executed: PossibleBoth:case PossibleBoth: never executed: case PossibleBoth: | 0 | ||||||||||||||||||
599 | num = 0; | - | ||||||||||||||||||
600 | state = Intermediate; | - | ||||||||||||||||||
601 | break; never executed: break; | 0 | ||||||||||||||||||
602 | case executed 2 times by 2 tests: Neither:case Neither: Executed by:
executed 2 times by 2 tests: case Neither: Executed by:
| 2 | ||||||||||||||||||
603 | state = Invalid; | - | ||||||||||||||||||
604 | if (false) QMessageLogger(__FILE__, 741, __PRETTY_FUNCTION__).debug() << "invalid because findAmPm(" << sectiontext << ") returned -1"; dead code: QMessageLogger(__FILE__, 741, __PRETTY_FUNCTION__).debug() << "invalid because findAmPm(" << sectiontext << ") returned -1"; | - | ||||||||||||||||||
605 | break; executed 2 times by 2 tests: break; Executed by:
| 2 | ||||||||||||||||||
606 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
607 | if (false) QMessageLogger(__FILE__, 744, __PRETTY_FUNCTION__).debug("This should never happen (findAmPm returned %d)", ampm); dead code: QMessageLogger(__FILE__, 744, __PRETTY_FUNCTION__).debug("This should never happen (findAmPm returned %d)", ampm); | - | ||||||||||||||||||
608 | break; never executed: break; | 0 | ||||||||||||||||||
609 | } | - | ||||||||||||||||||
610 | if (state != Invalid
| 2-861 | ||||||||||||||||||
611 | text.replace(index, used, sectiontext.constData(), used); executed 861 times by 5 tests: text.replace(index, used, sectiontext.constData(), used); Executed by:
| 861 | ||||||||||||||||||
612 | break; executed 863 times by 5 tests: }break; Executed by:
| 863 | ||||||||||||||||||
613 | case executed 3195 times by 10 tests: MonthSection:case MonthSection: Executed by:
executed 3195 times by 10 tests: case MonthSection: Executed by:
| 3195 | ||||||||||||||||||
614 | case executed 40 times by 3 tests: DayOfWeekSectionShort:case DayOfWeekSectionShort: Executed by:
executed 40 times by 3 tests: case DayOfWeekSectionShort: Executed by:
| 40 | ||||||||||||||||||
615 | case executed 424 times by 3 tests: DayOfWeekSectionLong:case DayOfWeekSectionLong: Executed by:
executed 424 times by 3 tests: case DayOfWeekSectionLong: Executed by:
| 424 | ||||||||||||||||||
616 | if (sn.count >= 3
| 1733-1926 | ||||||||||||||||||
617 | QString sectiontext = sectionTextRef.toString(); | - | ||||||||||||||||||
618 | if (sn.type == MonthSection
| 464-1462 | ||||||||||||||||||
619 | int min = 1; | - | ||||||||||||||||||
620 | const QDate minDate = getMinimum().date(); | - | ||||||||||||||||||
621 | if (currentValue.date().year() == minDate.year()
| 17-1445 | ||||||||||||||||||
622 | min = minDate.month(); | - | ||||||||||||||||||
623 | } executed 17 times by 1 test: end of block Executed by:
| 17 | ||||||||||||||||||
624 | num = findMonth(sectiontext.toLower(), min, sectionIndex, §iontext, &used); | - | ||||||||||||||||||
625 | } executed 1462 times by 6 tests: else {end of block Executed by:
| 1462 | ||||||||||||||||||
626 | num = findDay(sectiontext.toLower(), 1, sectionIndex, §iontext, &used); | - | ||||||||||||||||||
627 | } executed 464 times by 3 tests: end of block Executed by:
| 464 | ||||||||||||||||||
628 | - | |||||||||||||||||||
629 | if (num != -1
| 5-1921 | ||||||||||||||||||
630 | state = (used == sectiontext.size()
| 107-1814 | ||||||||||||||||||
631 | text.replace(index, used, sectiontext.constData(), used); | - | ||||||||||||||||||
632 | } executed 1921 times by 6 tests: else {end of block Executed by:
| 1921 | ||||||||||||||||||
633 | state = Intermediate; | - | ||||||||||||||||||
634 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||
635 | break; executed 1926 times by 6 tests: break; Executed by:
| 1926 | ||||||||||||||||||
636 | } | - | ||||||||||||||||||
637 | case executed 2691 times by 10 tests: DaySection:case DaySection: Executed by:
executed 2691 times by 10 tests: case DaySection: Executed by:
code before this statement executed 1733 times by 7 tests: case DaySection: Executed by:
| 1733-2691 | ||||||||||||||||||
638 | case executed 1932 times by 6 tests: YearSection:case YearSection: Executed by:
executed 1932 times by 6 tests: case YearSection: Executed by:
| 1932 | ||||||||||||||||||
639 | case executed 880 times by 7 tests: YearSection2Digits:case YearSection2Digits: Executed by:
executed 880 times by 7 tests: case YearSection2Digits: Executed by:
| 880 | ||||||||||||||||||
640 | case executed 820 times by 5 tests: Hour12Section:case Hour12Section: Executed by:
executed 820 times by 5 tests: case Hour12Section: Executed by:
| 820 | ||||||||||||||||||
641 | case executed 1246 times by 6 tests: Hour24Section:case Hour24Section: Executed by:
executed 1246 times by 6 tests: case Hour24Section: Executed by:
| 1246 | ||||||||||||||||||
642 | case executed 1886 times by 8 tests: MinuteSection:case MinuteSection: Executed by:
executed 1886 times by 8 tests: case MinuteSection: Executed by:
| 1886 | ||||||||||||||||||
643 | case executed 1703 times by 4 tests: SecondSection:case SecondSection: Executed by:
executed 1703 times by 4 tests: case SecondSection: Executed by:
| 1703 | ||||||||||||||||||
644 | case executed 219 times by 2 tests: MSecSection:case MSecSection: Executed by:
executed 219 times by 2 tests: {case MSecSection: Executed by:
| 219 | ||||||||||||||||||
645 | if (sectiontextSize == 0
| 17-13093 | ||||||||||||||||||
646 | num = 0; | - | ||||||||||||||||||
647 | used = 0; | - | ||||||||||||||||||
648 | state = Intermediate; | - | ||||||||||||||||||
649 | } executed 17 times by 2 tests: else {end of block Executed by:
| 17 | ||||||||||||||||||
650 | const int absMax = absoluteMax(sectionIndex); | - | ||||||||||||||||||
651 | QLocale loc; | - | ||||||||||||||||||
652 | bool ok = true; | - | ||||||||||||||||||
653 | int last = -1; | - | ||||||||||||||||||
654 | used = -1; | - | ||||||||||||||||||
655 | - | |||||||||||||||||||
656 | QStringRef digitsStr = sectionTextRef; | - | ||||||||||||||||||
657 | for (int i = 0; i < sectiontextSize
| 12847-29808 | ||||||||||||||||||
658 | if (digitsStr.at(i).isSpace()
| 246-29562 | ||||||||||||||||||
659 | sectiontextSize = i; | - | ||||||||||||||||||
660 | break; executed 246 times by 4 tests: break; Executed by:
| 246 | ||||||||||||||||||
661 | } | - | ||||||||||||||||||
662 | } executed 29562 times by 11 tests: end of block Executed by:
| 29562 | ||||||||||||||||||
663 | - | |||||||||||||||||||
664 | const int max = qMin(sectionmaxsize, sectiontextSize); | - | ||||||||||||||||||
665 | for (int digits = max; digits >= 1
| 48-14065 | ||||||||||||||||||
666 | digitsStr.truncate(digits); | - | ||||||||||||||||||
667 | int tmp = (int)loc.toUInt(digitsStr, &ok); | - | ||||||||||||||||||
668 | if (ok
| 822-13053 | ||||||||||||||||||
669 | if (tmp > 12
| 2-820 | ||||||||||||||||||
670 | tmp = -1; | - | ||||||||||||||||||
671 | ok = false; | - | ||||||||||||||||||
672 | } executed 2 times by 1 test: else if (tmp == 12end of block Executed by:
| 2-720 | ||||||||||||||||||
673 | tmp = 0; | - | ||||||||||||||||||
674 | } executed 100 times by 3 tests: end of block Executed by:
| 100 | ||||||||||||||||||
675 | } executed 822 times by 5 tests: end of block Executed by:
| 822 | ||||||||||||||||||
676 | if (ok
| 6-13051 | ||||||||||||||||||
677 | if (false) QMessageLogger(__FILE__, 814, __PRETTY_FUNCTION__).debug() << sectionTextRef.left(digits) << tmp << digits; dead code: QMessageLogger(__FILE__, 814, __PRETTY_FUNCTION__).debug() << sectionTextRef.left(digits) << tmp << digits; | - | ||||||||||||||||||
678 | last = tmp; | - | ||||||||||||||||||
679 | used = digits; | - | ||||||||||||||||||
680 | break; executed 13045 times by 11 tests: break; Executed by:
| 13045 | ||||||||||||||||||
681 | } | - | ||||||||||||||||||
682 | } executed 1020 times by 7 tests: end of block Executed by:
| 1020 | ||||||||||||||||||
683 | - | |||||||||||||||||||
684 | if (last == -1
| 48-13045 | ||||||||||||||||||
685 | QChar first(sectionTextRef.at(0)); | - | ||||||||||||||||||
686 | if (separators.at(sectionIndex + 1).startsWith(first)
| 2-46 | ||||||||||||||||||
687 | used = 0; | - | ||||||||||||||||||
688 | state = Intermediate; | - | ||||||||||||||||||
689 | } executed 46 times by 2 tests: else {end of block Executed by:
| 46 | ||||||||||||||||||
690 | state = Invalid; | - | ||||||||||||||||||
691 | if (false) QMessageLogger(__FILE__, 828, __PRETTY_FUNCTION__).debug() << "invalid because" << sectionTextRef << "can't become a uint" << last << ok; dead code: QMessageLogger(__FILE__, 828, __PRETTY_FUNCTION__).debug() << "invalid because" << sectionTextRef << "can't become a uint" << last << ok; | - | ||||||||||||||||||
692 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
693 | } else { | - | ||||||||||||||||||
694 | num += last; | - | ||||||||||||||||||
695 | const FieldInfo fi = fieldInfo(sectionIndex); | - | ||||||||||||||||||
696 | const bool done = (used == sectionmaxsize); | - | ||||||||||||||||||
697 | if (!done
| 1515-11530 | ||||||||||||||||||
698 | for (int i=used; i<sectionmaxsize
| 78-148 | ||||||||||||||||||
699 | num *= 10; | - | ||||||||||||||||||
700 | } executed 148 times by 1 test: end of block Executed by:
| 148 | ||||||||||||||||||
701 | } executed 78 times by 1 test: end of block Executed by:
| 78 | ||||||||||||||||||
702 | const int absMin = absoluteMin(sectionIndex); | - | ||||||||||||||||||
703 | if (num < absMin
| 25-13020 | ||||||||||||||||||
704 | state = done
| 3-22 | ||||||||||||||||||
705 | if (done
| 3-22 | ||||||||||||||||||
706 | if (false) QMessageLogger(__FILE__, 843, __PRETTY_FUNCTION__).debug() << "invalid because" << num << "is less than absoluteMin" << absMin; dead code: QMessageLogger(__FILE__, 843, __PRETTY_FUNCTION__).debug() << "invalid because" << num << "is less than absoluteMin" << absMin; | - | ||||||||||||||||||
707 | } executed 25 times by 1 test: else if (num > absMaxend of block Executed by:
| 0-13020 | ||||||||||||||||||
708 | state = Intermediate; | - | ||||||||||||||||||
709 | } never executed: else if (!doneend of block
| 0-11527 | ||||||||||||||||||
710 | if (skipToNextSection(sectionIndex, currentValue, digitsStr)
| 27-438 | ||||||||||||||||||
711 | state = Acceptable; | - | ||||||||||||||||||
712 | const int missingZeroes = sectionmaxsize - digitsStr.size(); | - | ||||||||||||||||||
713 | text.insert(index, QString(missingZeroes, QLatin1Char('0'))); | - | ||||||||||||||||||
714 | used = sectionmaxsize; | - | ||||||||||||||||||
715 | cursorPosition += missingZeroes; | - | ||||||||||||||||||
716 | ++(const_cast<QDateTimeParser*>(this)->sectionNodes[sectionIndex].zeroesAdded); | - | ||||||||||||||||||
717 | } executed 27 times by 1 test: else {end of block Executed by:
| 27 | ||||||||||||||||||
718 | state = Intermediate;; | - | ||||||||||||||||||
719 | } executed 438 times by 4 tests: end of block Executed by:
| 438 | ||||||||||||||||||
720 | } else { | - | ||||||||||||||||||
721 | state = Acceptable; | - | ||||||||||||||||||
722 | } executed 12555 times by 11 tests: end of block Executed by:
| 12555 | ||||||||||||||||||
723 | } | - | ||||||||||||||||||
724 | } | - | ||||||||||||||||||
725 | break; executed 13110 times by 11 tests: }break; Executed by:
| 13110 | ||||||||||||||||||
726 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
727 | QMessageLogger(__FILE__, 864, __PRETTY_FUNCTION__).warning("QDateTimeParser::parseSection Internal error (%s %d)", | - | ||||||||||||||||||
728 | QString(sn.name()).toLocal8Bit().constData(), sectionIndex); | - | ||||||||||||||||||
729 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
730 | } | - | ||||||||||||||||||
731 | - | |||||||||||||||||||
732 | if (usedptr
| 0-15899 | ||||||||||||||||||
733 | * executed 15899 times by 11 tests: usedptr = used;*usedptr = used; Executed by:
executed 15899 times by 11 tests: *usedptr = used; Executed by:
| 15899 | ||||||||||||||||||
734 | - | |||||||||||||||||||
735 | return executed 15899 times by 11 tests: (state != Invalid ? num : -1);return (state != Invalid ? num : -1); Executed by:
executed 15899 times by 11 tests: return (state != Invalid ? num : -1); Executed by:
| 15899 | ||||||||||||||||||
736 | } | - | ||||||||||||||||||
737 | - | |||||||||||||||||||
738 | - | |||||||||||||||||||
739 | - | |||||||||||||||||||
740 | - | |||||||||||||||||||
741 | - | |||||||||||||||||||
742 | - | |||||||||||||||||||
743 | - | |||||||||||||||||||
744 | QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPosition, | - | ||||||||||||||||||
745 | const QDateTime ¤tValue, bool fixup) const | - | ||||||||||||||||||
746 | { | - | ||||||||||||||||||
747 | const QDateTime minimum = getMinimum(); | - | ||||||||||||||||||
748 | const QDateTime maximum = getMaximum(); | - | ||||||||||||||||||
749 | - | |||||||||||||||||||
750 | State state = Acceptable; | - | ||||||||||||||||||
751 | - | |||||||||||||||||||
752 | QDateTime newCurrentValue; | - | ||||||||||||||||||
753 | bool conflicts = false; | - | ||||||||||||||||||
754 | const int sectionNodesCount = sectionNodes.size(); | - | ||||||||||||||||||
755 | - | |||||||||||||||||||
756 | if (false) QMessageLogger(__FILE__, 893, __PRETTY_FUNCTION__).debug() << "parse" << input; dead code: QMessageLogger(__FILE__, 893, __PRETTY_FUNCTION__).debug() << "parse" << input; | - | ||||||||||||||||||
757 | { | - | ||||||||||||||||||
758 | int pos = 0; | - | ||||||||||||||||||
759 | int year, month, day; | - | ||||||||||||||||||
760 | const QDate currentDate = currentValue.date(); | - | ||||||||||||||||||
761 | const QTime currentTime = currentValue.time(); | - | ||||||||||||||||||
762 | currentDate.getDate(&year, &month, &day); | - | ||||||||||||||||||
763 | int year2digits = year % 100; | - | ||||||||||||||||||
764 | int hour = currentTime.hour(); | - | ||||||||||||||||||
765 | int hour12 = -1; | - | ||||||||||||||||||
766 | int minute = currentTime.minute(); | - | ||||||||||||||||||
767 | int second = currentTime.second(); | - | ||||||||||||||||||
768 | int msec = currentTime.msec(); | - | ||||||||||||||||||
769 | int dayofweek = currentDate.dayOfWeek(); | - | ||||||||||||||||||
770 | - | |||||||||||||||||||
771 | int ampm = -1; | - | ||||||||||||||||||
772 | Sections isSet = NoSection; | - | ||||||||||||||||||
773 | int num; | - | ||||||||||||||||||
774 | State tmpstate; | - | ||||||||||||||||||
775 | - | |||||||||||||||||||
776 | for (int index=0; state != Invalid
| 7-20637 | ||||||||||||||||||
777 | if (QStringRef(&input, pos, separators.at(index).size()) != separators.at(index)
| 122-15899 | ||||||||||||||||||
778 | if (false) QMessageLogger(__FILE__, 915, __PRETTY_FUNCTION__).debug() << "invalid because" << input.midRef(pos, separators.at(index).size()) dead code: QMessageLogger(__FILE__, 915, __PRETTY_FUNCTION__).debug() << "invalid because" << input.midRef(pos, separators.at(index).size()) << "!=" << separators.at(index) << index << pos << currentSectionIndex; | - | ||||||||||||||||||
779 | << "!=" << separators.at(index) dead code: QMessageLogger(__FILE__, 915, __PRETTY_FUNCTION__).debug() << "invalid because" << input.midRef(pos, separators.at(index).size()) << "!=" << separators.at(index) << index << pos << currentSectionIndex; | - | ||||||||||||||||||
780 | << index << pos << currentSectionIndex; dead code: QMessageLogger(__FILE__, 915, __PRETTY_FUNCTION__).debug() << "invalid because" << input.midRef(pos, separators.at(index).size()) << "!=" << separators.at(index) << index << pos << currentSectionIndex; | - | ||||||||||||||||||
781 | state = Invalid; | - | ||||||||||||||||||
782 | goto executed 122 times by 2 tests: end;goto end; Executed by:
executed 122 times by 2 tests: goto end; Executed by:
| 122 | ||||||||||||||||||
783 | } | - | ||||||||||||||||||
784 | pos += separators.at(index).size(); | - | ||||||||||||||||||
785 | sectionNodes[index].pos = pos; | - | ||||||||||||||||||
786 | int *current = 0; | - | ||||||||||||||||||
787 | const SectionNode sn = sectionNodes.at(index); | - | ||||||||||||||||||
788 | int used; | - | ||||||||||||||||||
789 | - | |||||||||||||||||||
790 | num = parseSection(currentValue, index, input, cursorPosition, pos, tmpstate, &used); | - | ||||||||||||||||||
791 | if (false) QMessageLogger(__FILE__, 928, __PRETTY_FUNCTION__).debug() << "sectionValue" << sn.name() << input dead code: QMessageLogger(__FILE__, 928, __PRETTY_FUNCTION__).debug() << "sectionValue" << sn.name() << input << "pos" << pos << "used" << used << stateName(tmpstate); | - | ||||||||||||||||||
792 | << "pos" << pos << "used" << used << stateName(tmpstate); dead code: QMessageLogger(__FILE__, 928, __PRETTY_FUNCTION__).debug() << "sectionValue" << sn.name() << input << "pos" << pos << "used" << used << stateName(tmpstate); | - | ||||||||||||||||||
793 | if (fixup
| 1-15826 | ||||||||||||||||||
794 | const FieldInfo fi = fieldInfo(index); | - | ||||||||||||||||||
795 | if ((
| 3-17 | ||||||||||||||||||
796 | const QString newText = QString::fromLatin1("%1").arg(num, sn.count, 10, QLatin1Char('0')); | - | ||||||||||||||||||
797 | input.replace(pos, used, newText); | - | ||||||||||||||||||
798 | used = sn.count; | - | ||||||||||||||||||
799 | } executed 17 times by 1 test: end of block Executed by:
| 17 | ||||||||||||||||||
800 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||
801 | pos += qMax(0, used); | - | ||||||||||||||||||
802 | - | |||||||||||||||||||
803 | state = qMin<State>(state, tmpstate); | - | ||||||||||||||||||
804 | if (state == Intermediate
| 12-14546 | ||||||||||||||||||
805 | state = Invalid; | - | ||||||||||||||||||
806 | break; executed 12 times by 4 tests: break; Executed by:
| 12 | ||||||||||||||||||
807 | } | - | ||||||||||||||||||
808 | - | |||||||||||||||||||
809 | if (false) QMessageLogger(__FILE__, 946, __PRETTY_FUNCTION__).debug() << index << sn.name() << "is set to" dead code: QMessageLogger(__FILE__, 946, __PRETTY_FUNCTION__).debug() << index << sn.name() << "is set to" << pos << "state is" << stateName(state); | - | ||||||||||||||||||
810 | << pos << "state is" << stateName(state); dead code: QMessageLogger(__FILE__, 946, __PRETTY_FUNCTION__).debug() << index << sn.name() << "is set to" << pos << "state is" << stateName(state); | - | ||||||||||||||||||
811 | - | |||||||||||||||||||
812 | - | |||||||||||||||||||
813 | if (state != Invalid
| 7-15880 | ||||||||||||||||||
814 | switch (sn.type) { | - | ||||||||||||||||||
815 | case executed 1245 times by 6 tests: Hour24Section:case Hour24Section: Executed by:
executed 1245 times by 6 tests: current = &hour; break;case Hour24Section: Executed by:
executed 1245 times by 6 tests: break; Executed by:
| 1245 | ||||||||||||||||||
816 | case executed 820 times by 5 tests: Hour12Section:case Hour12Section: Executed by:
executed 820 times by 5 tests: current = &hour12; break;case Hour12Section: Executed by:
executed 820 times by 5 tests: break; Executed by:
| 820 | ||||||||||||||||||
817 | case executed 1885 times by 8 tests: MinuteSection:case MinuteSection: Executed by:
executed 1885 times by 8 tests: current = &minute; break;case MinuteSection: Executed by:
executed 1885 times by 8 tests: break; Executed by:
| 1885 | ||||||||||||||||||
818 | case executed 1703 times by 4 tests: SecondSection:case SecondSection: Executed by:
executed 1703 times by 4 tests: current = &second; break;case SecondSection: Executed by:
executed 1703 times by 4 tests: break; Executed by:
| 1703 | ||||||||||||||||||
819 | case executed 219 times by 2 tests: MSecSection:case MSecSection: Executed by:
executed 219 times by 2 tests: current = &msec; break;case MSecSection: Executed by:
executed 219 times by 2 tests: break; Executed by:
| 219 | ||||||||||||||||||
820 | case executed 1932 times by 6 tests: YearSection:case YearSection: Executed by:
executed 1932 times by 6 tests: current = &year; break;case YearSection: Executed by:
executed 1932 times by 6 tests: break; Executed by:
| 1932 | ||||||||||||||||||
821 | case executed 879 times by 7 tests: YearSection2Digits:case YearSection2Digits: Executed by:
executed 879 times by 7 tests: current = &year2digits; break;case YearSection2Digits: Executed by:
executed 879 times by 7 tests: break; Executed by:
| 879 | ||||||||||||||||||
822 | case executed 3192 times by 10 tests: MonthSection:case MonthSection: Executed by:
executed 3192 times by 10 tests: current = &month; break;case MonthSection: Executed by:
executed 3192 times by 10 tests: break; Executed by:
| 3192 | ||||||||||||||||||
823 | case executed 40 times by 3 tests: DayOfWeekSectionShort:case DayOfWeekSectionShort: Executed by:
executed 40 times by 3 tests: case DayOfWeekSectionShort: Executed by:
| 40 | ||||||||||||||||||
824 | case executed 424 times by 3 tests: DayOfWeekSectionLong:case DayOfWeekSectionLong: Executed by:
executed 424 times by 3 tests: current = &dayofweek; break;case DayOfWeekSectionLong: Executed by:
executed 464 times by 3 tests: break; Executed by:
| 424-464 | ||||||||||||||||||
825 | case executed 2680 times by 10 tests: DaySection:case DaySection: Executed by:
executed 2680 times by 10 tests: current = &day; num = qMax<int>(1, num); break;case DaySection: Executed by:
executed 2680 times by 10 tests: break; Executed by:
| 2680 | ||||||||||||||||||
826 | case executed 861 times by 5 tests: AmPmSection:case AmPmSection: Executed by:
executed 861 times by 5 tests: current = &m; break;case AmPmSection: Executed by:
executed 861 times by 5 tests: break; Executed by:
| 861 | ||||||||||||||||||
827 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
828 | QMessageLogger(__FILE__, 965, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error (%s)", | - | ||||||||||||||||||
829 | QString(sn.name()).toLocal8Bit().constData()); | - | ||||||||||||||||||
830 | break; never executed: break; | 0 | ||||||||||||||||||
831 | } | - | ||||||||||||||||||
832 | if (!current
| 0-15880 | ||||||||||||||||||
833 | QMessageLogger(__FILE__, 970, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 2"); | - | ||||||||||||||||||
834 | return never executed: StateNode();return StateNode(); never executed: return StateNode(); | 0 | ||||||||||||||||||
835 | } | - | ||||||||||||||||||
836 | if (isSet & sn.type && *
| 101-416 | ||||||||||||||||||
837 | if (false) QMessageLogger(__FILE__, 974, __PRETTY_FUNCTION__).debug() << "CONFLICT " << sn.name() << *current << num; dead code: QMessageLogger(__FILE__, 974, __PRETTY_FUNCTION__).debug() << "CONFLICT " << sn.name() << *current << num; | - | ||||||||||||||||||
838 | conflicts = true; | - | ||||||||||||||||||
839 | if (index != currentSectionIndex
| 0-96 | ||||||||||||||||||
840 | continue; executed 96 times by 3 tests: continue; Executed by:
| 96 | ||||||||||||||||||
841 | } | - | ||||||||||||||||||
842 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||
843 | if (num != -1
| 5-15779 | ||||||||||||||||||
844 | * executed 15779 times by 11 tests: current = num;*current = num; Executed by:
executed 15779 times by 11 tests: *current = num; Executed by:
| 15779 | ||||||||||||||||||
845 | isSet |= sn.type; | - | ||||||||||||||||||
846 | } executed 15784 times by 11 tests: end of block Executed by:
| 15784 | ||||||||||||||||||
847 | } executed 15791 times by 11 tests: end of block Executed by:
| 15791 | ||||||||||||||||||
848 | - | |||||||||||||||||||
849 | if (state != Invalid
| 15-4616 | ||||||||||||||||||
850 | if (false) QMessageLogger(__FILE__, 987, __PRETTY_FUNCTION__).debug() << "invalid because" << input.midRef(pos) dead code: QMessageLogger(__FILE__, 987, __PRETTY_FUNCTION__).debug() << "invalid because" << input.midRef(pos) << "!=" << separators.last() << pos; | - | ||||||||||||||||||
851 | << "!=" << separators.last() << pos; dead code: QMessageLogger(__FILE__, 987, __PRETTY_FUNCTION__).debug() << "invalid because" << input.midRef(pos) << "!=" << separators.last() << pos; | - | ||||||||||||||||||
852 | state = Invalid; | - | ||||||||||||||||||
853 | } executed 15 times by 4 tests: end of block Executed by:
| 15 | ||||||||||||||||||
854 | - | |||||||||||||||||||
855 | if (state != Invalid
| 34-4601 | ||||||||||||||||||
856 | if (parserType != QVariant::Time
| 23-4578 | ||||||||||||||||||
857 | if (year % 100 != year2digits
| 359-4219 | ||||||||||||||||||
858 | if (!(isSet & YearSection)
| 1-16 | ||||||||||||||||||
859 | year = (year / 100) * 100; | - | ||||||||||||||||||
860 | year += year2digits; | - | ||||||||||||||||||
861 | } executed 16 times by 4 tests: else {end of block Executed by:
| 16 | ||||||||||||||||||
862 | conflicts = true; | - | ||||||||||||||||||
863 | const SectionNode &sn = sectionNode(currentSectionIndex); | - | ||||||||||||||||||
864 | if (sn.type == YearSection2Digits
| 0-1 | ||||||||||||||||||
865 | year = (year / 100) * 100; | - | ||||||||||||||||||
866 | year += year2digits; | - | ||||||||||||||||||
867 | } never executed: end of block | 0 | ||||||||||||||||||
868 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
869 | } | - | ||||||||||||||||||
870 | - | |||||||||||||||||||
871 | const QDate date(year, month, day); | - | ||||||||||||||||||
872 | const int diff = dayofweek - date.dayOfWeek(); | - | ||||||||||||||||||
873 | if (diff != 0
| 209-4054 | ||||||||||||||||||
874 | if (isSet & DaySection
| 2-26 | ||||||||||||||||||
875 | conflicts = true; executed 2 times by 1 test: conflicts = true; Executed by:
| 2 | ||||||||||||||||||
876 | const SectionNode &sn = sectionNode(currentSectionIndex); | - | ||||||||||||||||||
877 | if (sn.type & DayOfWeekSectionMask
| 0-28 | ||||||||||||||||||
878 | - | |||||||||||||||||||
879 | day += diff; | - | ||||||||||||||||||
880 | if (day <= 0
| 6-8 | ||||||||||||||||||
881 | day += 7; | - | ||||||||||||||||||
882 | } executed 8 times by 2 tests: else if (day > date.daysInMonth()end of block Executed by:
| 0-8 | ||||||||||||||||||
883 | day -= 7; | - | ||||||||||||||||||
884 | } never executed: end of block | 0 | ||||||||||||||||||
885 | if (false) QMessageLogger(__FILE__, 1022, __PRETTY_FUNCTION__).debug() << year << month << day << dayofweek dead code: QMessageLogger(__FILE__, 1022, __PRETTY_FUNCTION__).debug() << year << month << day << dayofweek << diff << QDate(year, month, day).dayOfWeek(); | - | ||||||||||||||||||
886 | << diff << QDate(year, month, day).dayOfWeek(); dead code: QMessageLogger(__FILE__, 1022, __PRETTY_FUNCTION__).debug() << year << month << day << dayofweek << diff << QDate(year, month, day).dayOfWeek(); | - | ||||||||||||||||||
887 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||||||||
888 | } executed 28 times by 3 tests: end of block Executed by:
| 28 | ||||||||||||||||||
889 | - | |||||||||||||||||||
890 | bool needfixday = false; | - | ||||||||||||||||||
891 | if (sectionType(currentSectionIndex) & DaySectionMask
| 1257-3321 | ||||||||||||||||||
892 | cachedDay = day; | - | ||||||||||||||||||
893 | } executed 1257 times by 1 test: else if (cachedDay > dayend of block Executed by:
| 12-3309 | ||||||||||||||||||
894 | day = cachedDay; | - | ||||||||||||||||||
895 | needfixday = true; | - | ||||||||||||||||||
896 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||
897 | - | |||||||||||||||||||
898 | if (!QDate::isValid(year, month, day)
| 88-4490 | ||||||||||||||||||
899 | if (day < 32
| 0-88 | ||||||||||||||||||
900 | cachedDay = day; | - | ||||||||||||||||||
901 | } executed 88 times by 2 tests: end of block Executed by:
| 88 | ||||||||||||||||||
902 | if (day > 28
| 0-51 | ||||||||||||||||||
903 | needfixday = true; | - | ||||||||||||||||||
904 | } executed 51 times by 2 tests: end of block Executed by:
| 51 | ||||||||||||||||||
905 | } executed 88 times by 2 tests: end of block Executed by:
| 88 | ||||||||||||||||||
906 | if (needfixday
| 51-4527 | ||||||||||||||||||
907 | if (context == FromString
| 1-50 | ||||||||||||||||||
908 | state = Invalid; | - | ||||||||||||||||||
909 | goto executed 1 time by 1 test: end;goto end; Executed by:
executed 1 time by 1 test: goto end; Executed by:
| 1 | ||||||||||||||||||
910 | } | - | ||||||||||||||||||
911 | if (state == Acceptable
| 0-50 | ||||||||||||||||||
912 | day = qMin<int>(day, QDate(year, month, 1).daysInMonth()); | - | ||||||||||||||||||
913 | - | |||||||||||||||||||
914 | const QLocale loc = locale(); | - | ||||||||||||||||||
915 | for (int i=0; i<sectionNodesCount
| 50-149 | ||||||||||||||||||
916 | const SectionNode sn = sectionNode(i); | - | ||||||||||||||||||
917 | if (sn.type & DaySection
| 38-111 | ||||||||||||||||||
918 | input.replace(sectionPos(sn), sectionSize(i), loc.toString(day)); | - | ||||||||||||||||||
919 | } executed 38 times by 1 test: else if (sn.type & DayOfWeekSectionMaskend of block Executed by:
| 14-97 | ||||||||||||||||||
920 | const int dayOfWeek = QDate(year, month, day).dayOfWeek(); | - | ||||||||||||||||||
921 | const QLocale::FormatType dayFormat = | - | ||||||||||||||||||
922 | (sn.type == DayOfWeekSectionShort
| 1-13 | ||||||||||||||||||
923 | ? QLocale::ShortFormat : QLocale::LongFormat); | - | ||||||||||||||||||
924 | const QString dayName(loc.dayName(dayOfWeek, dayFormat)); | - | ||||||||||||||||||
925 | input.replace(sectionPos(sn), sectionSize(i), dayName); | - | ||||||||||||||||||
926 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||
927 | } executed 149 times by 1 test: end of block Executed by:
| 149 | ||||||||||||||||||
928 | } executed 50 times by 1 test: else {end of block Executed by:
| 50 | ||||||||||||||||||
929 | state = qMin(Intermediate, state); | - | ||||||||||||||||||
930 | } never executed: end of block | 0 | ||||||||||||||||||
931 | } | - | ||||||||||||||||||
932 | } executed 4577 times by 10 tests: end of block Executed by:
| 4577 | ||||||||||||||||||
933 | - | |||||||||||||||||||
934 | if (parserType != QVariant::Date
| 919-3681 | ||||||||||||||||||
935 | if (isSet & Hour12Section
| 808-2873 | ||||||||||||||||||
936 | const bool hasHour = isSet & Hour24Section; | - | ||||||||||||||||||
937 | if (ampm == -1
| 0-808 | ||||||||||||||||||
938 | if (hasHour
| 0 | ||||||||||||||||||
939 | ampm = (hour < 12
| 0 | ||||||||||||||||||
940 | } never executed: else {end of block | 0 | ||||||||||||||||||
941 | ampm = 0; | - | ||||||||||||||||||
942 | } never executed: end of block | 0 | ||||||||||||||||||
943 | } | - | ||||||||||||||||||
944 | hour12 = (ampm == 0
| 78-730 | ||||||||||||||||||
945 | if (!hasHour
| 2-806 | ||||||||||||||||||
946 | hour = hour12; | - | ||||||||||||||||||
947 | } executed 806 times by 5 tests: else if (hour != hour12end of block Executed by:
| 0-806 | ||||||||||||||||||
948 | conflicts = true; | - | ||||||||||||||||||
949 | } never executed: end of block | 0 | ||||||||||||||||||
950 | } executed 808 times by 5 tests: else if (ampm != -1end of block Executed by:
| 51-2822 | ||||||||||||||||||
951 | if (!(isSet & (Hour24Section))
| 3-48 | ||||||||||||||||||
952 | hour = (12 * ampm); | - | ||||||||||||||||||
953 | } executed 3 times by 2 tests: else if ((end of block Executed by:
| 0-48 | ||||||||||||||||||
954 | conflicts = true; | - | ||||||||||||||||||
955 | } never executed: end of block | 0 | ||||||||||||||||||
956 | } executed 51 times by 3 tests: end of block Executed by:
| 51 | ||||||||||||||||||
957 | - | |||||||||||||||||||
958 | } executed 3681 times by 9 tests: end of block Executed by:
| 3681 | ||||||||||||||||||
959 | - | |||||||||||||||||||
960 | newCurrentValue = QDateTime(QDate(year, month, day), QTime(hour, minute, second, msec), spec); | - | ||||||||||||||||||
961 | if (false) QMessageLogger(__FILE__, 1098, __PRETTY_FUNCTION__).debug() << year << month << day << hour << minute << second << msec; dead code: QMessageLogger(__FILE__, 1098, __PRETTY_FUNCTION__).debug() << year << month << day << hour << minute << second << msec; | - | ||||||||||||||||||
962 | } executed 4600 times by 11 tests: end of block Executed by:
| 4600 | ||||||||||||||||||
963 | if (false) QMessageLogger(__FILE__, 1100, __PRETTY_FUNCTION__).debug("'%s' => '%s'(%s)", input.toLatin1().constData(), dead code: QMessageLogger(__FILE__, 1100, __PRETTY_FUNCTION__).debug("'%s' => '%s'(%s)", input.toLatin1().constData(), newCurrentValue.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")).toLatin1().constData(), stateName(state).toLatin1().constData()); | - | ||||||||||||||||||
964 | newCurrentValue.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")).toLatin1().constData(), dead code: QMessageLogger(__FILE__, 1100, __PRETTY_FUNCTION__).debug("'%s' => '%s'(%s)", input.toLatin1().constData(), newCurrentValue.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")).toLatin1().constData(), stateName(state).toLatin1().constData()); | - | ||||||||||||||||||
965 | stateName(state).toLatin1().constData()); dead code: QMessageLogger(__FILE__, 1100, __PRETTY_FUNCTION__).debug("'%s' => '%s'(%s)", input.toLatin1().constData(), newCurrentValue.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")).toLatin1().constData(), stateName(state).toLatin1().constData()); | - | ||||||||||||||||||
966 | } | - | ||||||||||||||||||
967 | end: code before this statement executed 4634 times by 11 tests: end: Executed by:
| 4634 | ||||||||||||||||||
968 | if (newCurrentValue.isValid()
| 194-4563 | ||||||||||||||||||
969 | if (context != FromString
| 0-4098 | ||||||||||||||||||
970 | const QLatin1Char space(' '); | - | ||||||||||||||||||
971 | if (newCurrentValue >= minimum
| 0-53 | ||||||||||||||||||
972 | QMessageLogger(__FILE__, 1109, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 3 (%s %s)", never executed: QMessageLogger(__FILE__, 1109, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 3 (%s %s)", QString(newCurrentValue.toString()).toLocal8Bit().constData(), QString(minimum.toString()).toLocal8Bit().constData()); | 0 | ||||||||||||||||||
973 | QString(newCurrentValue.toString()).toLocal8Bit().constData(), QString(minimum.toString()).toLocal8Bit().constData()); never executed: QMessageLogger(__FILE__, 1109, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 3 (%s %s)", QString(newCurrentValue.toString()).toLocal8Bit().constData(), QString(minimum.toString()).toLocal8Bit().constData()); | 0 | ||||||||||||||||||
974 | - | |||||||||||||||||||
975 | bool done = false; | - | ||||||||||||||||||
976 | state = Invalid; | - | ||||||||||||||||||
977 | for (int i=0; i<sectionNodesCount
| 9-138 | ||||||||||||||||||
978 | const SectionNode &sn = sectionNodes.at(i); | - | ||||||||||||||||||
979 | QString t = sectionText(input, i, sn.pos).toLower(); | - | ||||||||||||||||||
980 | if ((t.size() < sectionMaxSize(i)
| 0-74 | ||||||||||||||||||
981 | || t.contains(space)
| 0-74 | ||||||||||||||||||
982 | switch (sn.type) { | - | ||||||||||||||||||
983 | case never executed: AmPmSection:case AmPmSection: never executed: case AmPmSection: | 0 | ||||||||||||||||||
984 | switch (findAmPm(t, i)) { | - | ||||||||||||||||||
985 | case never executed: AM:case AM: never executed: case AM: | 0 | ||||||||||||||||||
986 | case never executed: PM:case PM: never executed: case PM: | 0 | ||||||||||||||||||
987 | state = Acceptable; | - | ||||||||||||||||||
988 | done = true; | - | ||||||||||||||||||
989 | break; never executed: break; | 0 | ||||||||||||||||||
990 | case never executed: Neither:case Neither: never executed: case Neither: | 0 | ||||||||||||||||||
991 | state = Invalid; | - | ||||||||||||||||||
992 | done = true; | - | ||||||||||||||||||
993 | break; never executed: break; | 0 | ||||||||||||||||||
994 | case never executed: PossibleAM:case PossibleAM: never executed: case PossibleAM: | 0 | ||||||||||||||||||
995 | case never executed: PossiblePM:case PossiblePM: never executed: case PossiblePM: | 0 | ||||||||||||||||||
996 | case never executed: PossibleBoth:case PossibleBoth: never executed: {case PossibleBoth: | 0 | ||||||||||||||||||
997 | const QDateTime copy(newCurrentValue.addSecs(12 * 60 * 60)); | - | ||||||||||||||||||
998 | if (copy >= minimum
| 0 | ||||||||||||||||||
999 | state = Intermediate; | - | ||||||||||||||||||
1000 | done = true; | - | ||||||||||||||||||
1001 | } never executed: end of block | 0 | ||||||||||||||||||
1002 | break; never executed: }break; | 0 | ||||||||||||||||||
1003 | } | - | ||||||||||||||||||
1004 | case executed 3 times by 1 test: case MonthSection: Executed by:
code before this statement never executed: case MonthSection: executed 3 times by 1 test: MonthSection:case MonthSection: Executed by:
code before this statement never executed: case MonthSection: executed 3 times by 1 test: case MonthSection: Executed by:
| 0-3 | ||||||||||||||||||
1005 | if (sn.count >= 3
| 0-3 | ||||||||||||||||||
1006 | const int currentMonth = newCurrentValue.date().month(); | - | ||||||||||||||||||
1007 | int tmp = currentMonth; | - | ||||||||||||||||||
1008 | - | |||||||||||||||||||
1009 | while ((
| 3-6 | ||||||||||||||||||
1010 | const QDateTime copy(newCurrentValue.addMonths(tmp - currentMonth)); | - | ||||||||||||||||||
1011 | if (copy >= minimum
| 0-6 | ||||||||||||||||||
1012 | break; never executed: break; | 0 | ||||||||||||||||||
1013 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||
1014 | if (tmp == -1
| 0-3 | ||||||||||||||||||
1015 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||
1016 | } | - | ||||||||||||||||||
1017 | state = Intermediate; | - | ||||||||||||||||||
1018 | done = true; | - | ||||||||||||||||||
1019 | break; never executed: break; | 0 | ||||||||||||||||||
1020 | } | - | ||||||||||||||||||
1021 | - | |||||||||||||||||||
1022 | default executed 52 times by 1 test: default: Executed by:
code before this statement never executed: default: executed 52 times by 1 test: :default: Executed by:
code before this statement never executed: default: executed 52 times by 1 test: {default: Executed by:
| 0-52 | ||||||||||||||||||
1023 | int toMin; | - | ||||||||||||||||||
1024 | int toMax; | - | ||||||||||||||||||
1025 | - | |||||||||||||||||||
1026 | if (sn.type & TimeSectionMask
| 20-32 | ||||||||||||||||||
1027 | if (newCurrentValue.daysTo(minimum) != 0
| 0-20 | ||||||||||||||||||
1028 | break; never executed: break; | 0 | ||||||||||||||||||
1029 | } | - | ||||||||||||||||||
1030 | const QTime time = newCurrentValue.time(); | - | ||||||||||||||||||
1031 | toMin = time.msecsTo(minimum.time()); | - | ||||||||||||||||||
1032 | if (newCurrentValue.daysTo(maximum) > 0
| 0-20 | ||||||||||||||||||
1033 | toMax = -1; | - | ||||||||||||||||||
1034 | } never executed: else {end of block | 0 | ||||||||||||||||||
1035 | toMax = time.msecsTo(maximum.time()); | - | ||||||||||||||||||
1036 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||
1037 | } else { | - | ||||||||||||||||||
1038 | toMin = newCurrentValue.daysTo(minimum); | - | ||||||||||||||||||
1039 | toMax = newCurrentValue.daysTo(maximum); | - | ||||||||||||||||||
1040 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||
1041 | const int maxChange = sn.maxChange(); | - | ||||||||||||||||||
1042 | if (toMin > maxChange
| 0-52 | ||||||||||||||||||
1043 | if (false) QMessageLogger(__FILE__, 1180, __PRETTY_FUNCTION__).debug() << "invalid because toMin > maxChange" << toMin dead code: QMessageLogger(__FILE__, 1180, __PRETTY_FUNCTION__).debug() << "invalid because toMin > maxChange" << toMin << maxChange << t << newCurrentValue << minimum; | - | ||||||||||||||||||
1044 | << maxChange << t << newCurrentValue << minimum; dead code: QMessageLogger(__FILE__, 1180, __PRETTY_FUNCTION__).debug() << "invalid because toMin > maxChange" << toMin << maxChange << t << newCurrentValue << minimum; | - | ||||||||||||||||||
1045 | state = Invalid; | - | ||||||||||||||||||
1046 | done = true; | - | ||||||||||||||||||
1047 | break; never executed: break; | 0 | ||||||||||||||||||
1048 | } else if (toMax > maxChange
| 14-38 | ||||||||||||||||||
1049 | toMax = -1; | - | ||||||||||||||||||
1050 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||
1051 | - | |||||||||||||||||||
1052 | const int min = getDigit(minimum, i); | - | ||||||||||||||||||
1053 | if (min == -1
| 0-52 | ||||||||||||||||||
1054 | QMessageLogger(__FILE__, 1191, __PRETTY_FUNCTION__).warning("QDateTimeParser::parse Internal error 4 (%s)", | - | ||||||||||||||||||
1055 | QString(sn.name()).toLocal8Bit().constData()); | - | ||||||||||||||||||
1056 | state = Invalid; | - | ||||||||||||||||||
1057 | done = true; | - | ||||||||||||||||||
1058 | break; never executed: break; | 0 | ||||||||||||||||||
1059 | } | - | ||||||||||||||||||
1060 | - | |||||||||||||||||||
1061 | int max = toMax != -1
| 14-38 | ||||||||||||||||||
1062 | int pos = cursorPosition - sn.pos; | - | ||||||||||||||||||
1063 | if (pos < 0
| 4-48 | ||||||||||||||||||
1064 | pos = -1; executed 45 times by 1 test: pos = -1; Executed by:
| 45 | ||||||||||||||||||
1065 | if (!potentialValue(t.simplified(), min, max, i, newCurrentValue, pos)
| 2-50 | ||||||||||||||||||
1066 | if (false) QMessageLogger(__FILE__, 1203, __PRETTY_FUNCTION__).debug() << "invalid because potentialValue(" << t.simplified() << min << max dead code: QMessageLogger(__FILE__, 1203, __PRETTY_FUNCTION__).debug() << "invalid because potentialValue(" << t.simplified() << min << max << sn.name() << "returned" << toMax << toMin << pos; | - | ||||||||||||||||||
1067 | << sn.name() << "returned" << toMax << toMin << pos; dead code: QMessageLogger(__FILE__, 1203, __PRETTY_FUNCTION__).debug() << "invalid because potentialValue(" << t.simplified() << min << max << sn.name() << "returned" << toMax << toMin << pos; | - | ||||||||||||||||||
1068 | state = Invalid; | - | ||||||||||||||||||
1069 | done = true; | - | ||||||||||||||||||
1070 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||
1071 | } | - | ||||||||||||||||||
1072 | state = Intermediate; | - | ||||||||||||||||||
1073 | done = true; | - | ||||||||||||||||||
1074 | break; executed 50 times by 1 test: }break; Executed by:
| 50 | ||||||||||||||||||
1075 | } | - | ||||||||||||||||||
1076 | } | - | ||||||||||||||||||
1077 | } executed 129 times by 1 test: end of block Executed by:
| 129 | ||||||||||||||||||
1078 | } executed 53 times by 1 test: else {end of block Executed by:
| 53 | ||||||||||||||||||
1079 | if (context == FromString
| 465-4045 | ||||||||||||||||||
1080 | - | |||||||||||||||||||
1081 | ((!(getMaximum().date().toJulianDay() == 4642999)) ? qt_assert("getMaximum().date().toJulianDay() == 4642999",__FILE__,1218) : qt_noop()); | - | ||||||||||||||||||
1082 | if (newCurrentValue.date().toJulianDay() > 4642999
| 0-465 | ||||||||||||||||||
1083 | state = Invalid; never executed: state = Invalid; | 0 | ||||||||||||||||||
1084 | } executed 465 times by 8 tests: else {end of block Executed by:
| 465 | ||||||||||||||||||
1085 | if (newCurrentValue > getMaximum()
| 1-4044 | ||||||||||||||||||
1086 | state = Invalid; executed 1 time by 1 test: state = Invalid; Executed by:
| 1 | ||||||||||||||||||
1087 | } executed 4045 times by 4 tests: end of block Executed by:
| 4045 | ||||||||||||||||||
1088 | - | |||||||||||||||||||
1089 | if (false) QMessageLogger(__FILE__, 1226, __PRETTY_FUNCTION__).debug() << "not checking intermediate because newCurrentValue is" << newCurrentValue << getMinimum() << getMaximum(); dead code: QMessageLogger(__FILE__, 1226, __PRETTY_FUNCTION__).debug() << "not checking intermediate because newCurrentValue is" << newCurrentValue << getMinimum() << getMaximum(); | - | ||||||||||||||||||
1090 | } executed 4510 times by 11 tests: end of block Executed by:
| 4510 | ||||||||||||||||||
1091 | } | - | ||||||||||||||||||
1092 | StateNode node; | - | ||||||||||||||||||
1093 | node.input = input; | - | ||||||||||||||||||
1094 | node.state = state; | - | ||||||||||||||||||
1095 | node.conflicts = conflicts; | - | ||||||||||||||||||
1096 | node.value = newCurrentValue.toTimeSpec(spec); | - | ||||||||||||||||||
1097 | text = input; | - | ||||||||||||||||||
1098 | return executed 4757 times by 11 tests: node;return node; Executed by:
executed 4757 times by 11 tests: return node; Executed by:
| 4757 | ||||||||||||||||||
1099 | } | - | ||||||||||||||||||
1100 | int QDateTimeParser::findMonth(const QString &str1, int startMonth, int sectionIndex, | - | ||||||||||||||||||
1101 | QString *usedMonth, int *used) const | - | ||||||||||||||||||
1102 | { | - | ||||||||||||||||||
1103 | int bestMatch = -1; | - | ||||||||||||||||||
1104 | int bestCount = 0; | - | ||||||||||||||||||
1105 | if (!str1.isEmpty()
| 0-1471 | ||||||||||||||||||
1106 | const SectionNode &sn = sectionNode(sectionIndex); | - | ||||||||||||||||||
1107 | if (sn.type != MonthSection
| 0-1471 | ||||||||||||||||||
1108 | QMessageLogger(__FILE__, 1254, __PRETTY_FUNCTION__).warning("QDateTimeParser::findMonth Internal error"); | - | ||||||||||||||||||
1109 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
1110 | } | - | ||||||||||||||||||
1111 | - | |||||||||||||||||||
1112 | QLocale::FormatType type = sn.count == 3
| 201-1270 | ||||||||||||||||||
1113 | QLocale l = locale(); | - | ||||||||||||||||||
1114 | - | |||||||||||||||||||
1115 | for (int month=startMonth; month<=12
| 118-6035 | ||||||||||||||||||
1116 | const QString monthName = l.monthName(month, type); | - | ||||||||||||||||||
1117 | QString str2 = monthName.toLower(); | - | ||||||||||||||||||
1118 | - | |||||||||||||||||||
1119 | if (str1.startsWith(str2)
| 1350-4685 | ||||||||||||||||||
1120 | if (used
| 0-1350 | ||||||||||||||||||
1121 | if (false) QMessageLogger(__FILE__, 1267, __PRETTY_FUNCTION__).debug() << "used is set to" << str2.size(); dead code: QMessageLogger(__FILE__, 1267, __PRETTY_FUNCTION__).debug() << "used is set to" << str2.size(); | - | ||||||||||||||||||
1122 | *used = str2.size(); | - | ||||||||||||||||||
1123 | } executed 1350 times by 6 tests: end of block Executed by:
| 1350 | ||||||||||||||||||
1124 | if (usedMonth
| 0-1350 | ||||||||||||||||||
1125 | * executed 1350 times by 6 tests: usedMonth = monthName;*usedMonth = monthName; Executed by:
executed 1350 times by 6 tests: *usedMonth = monthName; Executed by:
| 1350 | ||||||||||||||||||
1126 | - | |||||||||||||||||||
1127 | return executed 1350 times by 6 tests: month;return month; Executed by:
executed 1350 times by 6 tests: return month; Executed by:
| 1350 | ||||||||||||||||||
1128 | } | - | ||||||||||||||||||
1129 | if (context == FromString
| 1599-3086 | ||||||||||||||||||
1130 | continue; executed 3086 times by 5 tests: continue; Executed by:
| 3086 | ||||||||||||||||||
1131 | - | |||||||||||||||||||
1132 | const int limit = qMin(str1.size(), str2.size()); | - | ||||||||||||||||||
1133 | - | |||||||||||||||||||
1134 | if (false) QMessageLogger(__FILE__, 1280, __PRETTY_FUNCTION__).debug() << "limit is" << limit << str1 << str2; dead code: QMessageLogger(__FILE__, 1280, __PRETTY_FUNCTION__).debug() << "limit is" << limit << str1 << str2; | - | ||||||||||||||||||
1135 | bool equal = true; | - | ||||||||||||||||||
1136 | for (int i=0; i<limit
| 3-2263 | ||||||||||||||||||
1137 | if (str1.at(i) != str2.at(i)
| 667-1596 | ||||||||||||||||||
1138 | equal = false; | - | ||||||||||||||||||
1139 | if (i > bestCount
| 177-1419 | ||||||||||||||||||
1140 | bestCount = i; | - | ||||||||||||||||||
1141 | bestMatch = month; | - | ||||||||||||||||||
1142 | } executed 177 times by 1 test: end of block Executed by:
| 177 | ||||||||||||||||||
1143 | break; executed 1596 times by 1 test: break; Executed by:
| 1596 | ||||||||||||||||||
1144 | } | - | ||||||||||||||||||
1145 | } executed 667 times by 1 test: end of block Executed by:
| 667 | ||||||||||||||||||
1146 | if (equal
| 3-1596 | ||||||||||||||||||
1147 | if (used
| 0-3 | ||||||||||||||||||
1148 | * executed 3 times by 1 test: used = limit;*used = limit; Executed by:
executed 3 times by 1 test: *used = limit; Executed by:
| 3 | ||||||||||||||||||
1149 | if (usedMonth
| 0-3 | ||||||||||||||||||
1150 | * executed 3 times by 1 test: usedMonth = monthName;*usedMonth = monthName; Executed by:
executed 3 times by 1 test: *usedMonth = monthName; Executed by:
| 3 | ||||||||||||||||||
1151 | return executed 3 times by 1 test: month;return month; Executed by:
executed 3 times by 1 test: return month; Executed by:
| 3 | ||||||||||||||||||
1152 | } | - | ||||||||||||||||||
1153 | } executed 1596 times by 1 test: end of block Executed by:
| 1596 | ||||||||||||||||||
1154 | if (usedMonth
| 5-109 | ||||||||||||||||||
1155 | * executed 104 times by 1 test: usedMonth = l.monthName(bestMatch, type);*usedMonth = l.monthName(bestMatch, type); Executed by:
executed 104 times by 1 test: *usedMonth = l.monthName(bestMatch, type); Executed by:
| 104 | ||||||||||||||||||
1156 | } executed 118 times by 1 test: end of block Executed by:
| 118 | ||||||||||||||||||
1157 | if (used
| 9-109 | ||||||||||||||||||
1158 | if (false) QMessageLogger(__FILE__, 1304, __PRETTY_FUNCTION__).debug() << "used is set to" << bestCount; dead code: QMessageLogger(__FILE__, 1304, __PRETTY_FUNCTION__).debug() << "used is set to" << bestCount; | - | ||||||||||||||||||
1159 | *used = bestCount; | - | ||||||||||||||||||
1160 | } executed 109 times by 1 test: end of block Executed by:
| 109 | ||||||||||||||||||
1161 | return executed 118 times by 1 test: bestMatch;return bestMatch; Executed by:
executed 118 times by 1 test: return bestMatch; Executed by:
| 118 | ||||||||||||||||||
1162 | } | - | ||||||||||||||||||
1163 | - | |||||||||||||||||||
1164 | int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex, QString *usedDay, int *used) const | - | ||||||||||||||||||
1165 | { | - | ||||||||||||||||||
1166 | int bestMatch = -1; | - | ||||||||||||||||||
1167 | int bestCount = 0; | - | ||||||||||||||||||
1168 | if (!str1.isEmpty()
| 0-464 | ||||||||||||||||||
1169 | const SectionNode &sn = sectionNode(sectionIndex); | - | ||||||||||||||||||
1170 | if (!(sn.type & DaySectionMask)
| 0-464 | ||||||||||||||||||
1171 | QMessageLogger(__FILE__, 1317, __PRETTY_FUNCTION__).warning("QDateTimeParser::findDay Internal error"); | - | ||||||||||||||||||
1172 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
1173 | } | - | ||||||||||||||||||
1174 | const QLocale l = locale(); | - | ||||||||||||||||||
1175 | for (int day=startDay; day<=7
| 0-1838 | ||||||||||||||||||
1176 | const QString str2 = l.dayName(day, sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat); | - | ||||||||||||||||||
1177 | - | |||||||||||||||||||
1178 | if (str1.startsWith(str2.toLower())
| 464-1374 | ||||||||||||||||||
1179 | if (used
| 0-464 | ||||||||||||||||||
1180 | * executed 464 times by 3 tests: used = str2.size();*used = str2.size(); Executed by:
executed 464 times by 3 tests: *used = str2.size(); Executed by:
| 464 | ||||||||||||||||||
1181 | if (usedDay
| 0-464 | ||||||||||||||||||
1182 | *usedDay = str2; | - | ||||||||||||||||||
1183 | } executed 464 times by 3 tests: end of block Executed by:
| 464 | ||||||||||||||||||
1184 | return executed 464 times by 3 tests: day;return day; Executed by:
executed 464 times by 3 tests: return day; Executed by:
| 464 | ||||||||||||||||||
1185 | } | - | ||||||||||||||||||
1186 | if (context == FromString
| 53-1321 | ||||||||||||||||||
1187 | continue; executed 53 times by 2 tests: continue; Executed by:
| 53 | ||||||||||||||||||
1188 | - | |||||||||||||||||||
1189 | const int limit = qMin(str1.size(), str2.size()); | - | ||||||||||||||||||
1190 | bool found = true; | - | ||||||||||||||||||
1191 | for (int i=0; i<limit
| 0-1321 | ||||||||||||||||||
1192 | if (str1.at(i) != str2.at(i)
| 0-1321 | ||||||||||||||||||
1193 | if (i > bestCount
| 0-1321 | ||||||||||||||||||
1194 | bestCount = i; | - | ||||||||||||||||||
1195 | bestMatch = day; | - | ||||||||||||||||||
1196 | } never executed: end of block | 0 | ||||||||||||||||||
1197 | found = false; | - | ||||||||||||||||||
1198 | break; executed 1321 times by 1 test: break; Executed by:
| 1321 | ||||||||||||||||||
1199 | } | - | ||||||||||||||||||
1200 | - | |||||||||||||||||||
1201 | } never executed: end of block | 0 | ||||||||||||||||||
1202 | if (found
| 0-1321 | ||||||||||||||||||
1203 | if (used
| 0 | ||||||||||||||||||
1204 | * never executed: used = limit;*used = limit; never executed: *used = limit; | 0 | ||||||||||||||||||
1205 | if (usedDay
| 0 | ||||||||||||||||||
1206 | * never executed: usedDay = str2;*usedDay = str2; never executed: *usedDay = str2; | 0 | ||||||||||||||||||
1207 | - | |||||||||||||||||||
1208 | return never executed: day;return day; never executed: return day; | 0 | ||||||||||||||||||
1209 | } | - | ||||||||||||||||||
1210 | } executed 1321 times by 1 test: end of block Executed by:
| 1321 | ||||||||||||||||||
1211 | if (usedDay
| 0 | ||||||||||||||||||
1212 | *usedDay = l.dayName(bestMatch, sn.count == 4 ? QLocale::LongFormat : QLocale::ShortFormat); | - | ||||||||||||||||||
1213 | } never executed: end of block | 0 | ||||||||||||||||||
1214 | } never executed: end of block | 0 | ||||||||||||||||||
1215 | if (used
| 0 | ||||||||||||||||||
1216 | * never executed: used = bestCount;*used = bestCount; never executed: *used = bestCount; | 0 | ||||||||||||||||||
1217 | - | |||||||||||||||||||
1218 | return never executed: bestMatch;return bestMatch; never executed: return bestMatch; | 0 | ||||||||||||||||||
1219 | } | - | ||||||||||||||||||
1220 | QDateTimeParser::AmPmFinder QDateTimeParser::findAmPm(QString &str, int sectionIndex, int *used) const | - | ||||||||||||||||||
1221 | { | - | ||||||||||||||||||
1222 | const SectionNode &s = sectionNode(sectionIndex); | - | ||||||||||||||||||
1223 | if (s.type != AmPmSection
| 0-863 | ||||||||||||||||||
1224 | QMessageLogger(__FILE__, 1383, __PRETTY_FUNCTION__).warning("QDateTimeParser::findAmPm Internal error"); | - | ||||||||||||||||||
1225 | return never executed: Neither;return Neither; never executed: return Neither; | 0 | ||||||||||||||||||
1226 | } | - | ||||||||||||||||||
1227 | if (used
| 0-863 | ||||||||||||||||||
1228 | * executed 863 times by 5 tests: used = str.size();*used = str.size(); Executed by:
executed 863 times by 5 tests: *used = str.size(); Executed by:
| 863 | ||||||||||||||||||
1229 | if (QStringRef(&str).trimmed().isEmpty()
| 0-863 | ||||||||||||||||||
1230 | return never executed: PossibleBoth;return PossibleBoth; never executed: return PossibleBoth; | 0 | ||||||||||||||||||
1231 | } | - | ||||||||||||||||||
1232 | const QLatin1Char space(' '); | - | ||||||||||||||||||
1233 | int size = sectionMaxSize(sectionIndex); | - | ||||||||||||||||||
1234 | - | |||||||||||||||||||
1235 | enum { | - | ||||||||||||||||||
1236 | amindex = 0, | - | ||||||||||||||||||
1237 | pmindex = 1 | - | ||||||||||||||||||
1238 | }; | - | ||||||||||||||||||
1239 | QString ampm[2]; | - | ||||||||||||||||||
1240 | ampm[amindex] = getAmPmText(AmText, s.count == 1 ? UpperCase : LowerCase); | - | ||||||||||||||||||
1241 | ampm[pmindex] = getAmPmText(PmText, s.count == 1 ? UpperCase : LowerCase); | - | ||||||||||||||||||
1242 | for (int i=0; i<2
| 863-1726 | ||||||||||||||||||
1243 | ampm[i].truncate(size); executed 1726 times by 5 tests: ampm[i].truncate(size); Executed by:
| 1726 | ||||||||||||||||||
1244 | - | |||||||||||||||||||
1245 | if (false) QMessageLogger(__FILE__, 1404, __PRETTY_FUNCTION__).debug() << "findAmPm" << str << ampm[0] << ampm[1]; dead code: QMessageLogger(__FILE__, 1404, __PRETTY_FUNCTION__).debug() << "findAmPm" << str << ampm[0] << ampm[1]; | - | ||||||||||||||||||
1246 | - | |||||||||||||||||||
1247 | if (str.indexOf(ampm[amindex], 0, Qt::CaseInsensitive) == 0
| 105-758 | ||||||||||||||||||
1248 | str = ampm[amindex]; | - | ||||||||||||||||||
1249 | return executed 758 times by 5 tests: AM;return AM; Executed by:
executed 758 times by 5 tests: return AM; Executed by:
| 758 | ||||||||||||||||||
1250 | } else if (str.indexOf(ampm[pmindex], 0, Qt::CaseInsensitive) == 0
| 2-103 | ||||||||||||||||||
1251 | str = ampm[pmindex]; | - | ||||||||||||||||||
1252 | return executed 103 times by 3 tests: PM;return PM; Executed by:
executed 103 times by 3 tests: return PM; Executed by:
| 103 | ||||||||||||||||||
1253 | } else if (context == FromString
| 0-1 | ||||||||||||||||||
1254 | return executed 1 time by 1 test: Neither;return Neither; Executed by:
executed 1 time by 1 test: return Neither; Executed by:
| 1 | ||||||||||||||||||
1255 | } | - | ||||||||||||||||||
1256 | size = qMin(size, str.size()); | - | ||||||||||||||||||
1257 | - | |||||||||||||||||||
1258 | bool broken[2] = {false, false}; | - | ||||||||||||||||||
1259 | for (int i=0; i<size
| 0-1 | ||||||||||||||||||
1260 | if (str.at(i) != space
| 0-1 | ||||||||||||||||||
1261 | for (int j=0; j<2
| 0-2 | ||||||||||||||||||
1262 | if (!broken[j]
| 0-2 | ||||||||||||||||||
1263 | int index = ampm[j].indexOf(str.at(i)); | - | ||||||||||||||||||
1264 | if (false) QMessageLogger(__FILE__, 1423, __PRETTY_FUNCTION__).debug() << "looking for" << str.at(i) dead code: QMessageLogger(__FILE__, 1423, __PRETTY_FUNCTION__).debug() << "looking for" << str.at(i) << "in" << ampm[j] << "and got" << index; | - | ||||||||||||||||||
1265 | << "in" << ampm[j] << "and got" << index; dead code: QMessageLogger(__FILE__, 1423, __PRETTY_FUNCTION__).debug() << "looking for" << str.at(i) << "in" << ampm[j] << "and got" << index; | - | ||||||||||||||||||
1266 | if (index == -1
| 0-2 | ||||||||||||||||||
1267 | if (str.at(i).category() == QChar::Letter_Uppercase
| 0-2 | ||||||||||||||||||
1268 | index = ampm[j].indexOf(str.at(i).toLower()); | - | ||||||||||||||||||
1269 | if (false) QMessageLogger(__FILE__, 1428, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toLower() dead code: QMessageLogger(__FILE__, 1428, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toLower() << "in" << ampm[j] << "and got" << index; | - | ||||||||||||||||||
1270 | << "in" << ampm[j] << "and got" << index; dead code: QMessageLogger(__FILE__, 1428, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toLower() << "in" << ampm[j] << "and got" << index; | - | ||||||||||||||||||
1271 | } never executed: else if (str.at(i).category() == QChar::Letter_Lowercaseend of block
| 0-2 | ||||||||||||||||||
1272 | index = ampm[j].indexOf(str.at(i).toUpper()); | - | ||||||||||||||||||
1273 | if (false) QMessageLogger(__FILE__, 1432, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toUpper() dead code: QMessageLogger(__FILE__, 1432, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toUpper() << "in" << ampm[j] << "and got" << index; | - | ||||||||||||||||||
1274 | << "in" << ampm[j] << "and got" << index; dead code: QMessageLogger(__FILE__, 1432, __PRETTY_FUNCTION__).debug() << "trying with" << str.at(i).toUpper() << "in" << ampm[j] << "and got" << index; | - | ||||||||||||||||||
1275 | } never executed: end of block | 0 | ||||||||||||||||||
1276 | if (index == -1
| 0-2 | ||||||||||||||||||
1277 | broken[j] = true; | - | ||||||||||||||||||
1278 | if (broken[amindex]
| 0-2 | ||||||||||||||||||
1279 | if (false) QMessageLogger(__FILE__, 1438, __PRETTY_FUNCTION__).debug() << str << "didn't make it"; dead code: QMessageLogger(__FILE__, 1438, __PRETTY_FUNCTION__).debug() << str << "didn't make it"; | - | ||||||||||||||||||
1280 | return executed 1 time by 1 test: Neither;return Neither; Executed by:
executed 1 time by 1 test: return Neither; Executed by:
| 1 | ||||||||||||||||||
1281 | } | - | ||||||||||||||||||
1282 | continue; executed 1 time by 1 test: continue; Executed by:
| 1 | ||||||||||||||||||
1283 | } else { | - | ||||||||||||||||||
1284 | str[i] = ampm[j].at(index); | - | ||||||||||||||||||
1285 | } never executed: end of block | 0 | ||||||||||||||||||
1286 | } | - | ||||||||||||||||||
1287 | ampm[j].remove(index, 1); | - | ||||||||||||||||||
1288 | } never executed: end of block | 0 | ||||||||||||||||||
1289 | } never executed: end of block | 0 | ||||||||||||||||||
1290 | } never executed: end of block | 0 | ||||||||||||||||||
1291 | } never executed: end of block | 0 | ||||||||||||||||||
1292 | if (!broken[pmindex]
| 0 | ||||||||||||||||||
1293 | return never executed: PossibleBoth;return PossibleBoth; never executed: return PossibleBoth; | 0 | ||||||||||||||||||
1294 | return never executed: (!broken[amindex] ? PossibleAM : PossiblePM);return (!broken[amindex] ? PossibleAM : PossiblePM); never executed: return (!broken[amindex] ? PossibleAM : PossiblePM); | 0 | ||||||||||||||||||
1295 | } | - | ||||||||||||||||||
1296 | - | |||||||||||||||||||
1297 | - | |||||||||||||||||||
1298 | - | |||||||||||||||||||
1299 | - | |||||||||||||||||||
1300 | - | |||||||||||||||||||
1301 | - | |||||||||||||||||||
1302 | int QDateTimeParser::SectionNode::maxChange() const | - | ||||||||||||||||||
1303 | { | - | ||||||||||||||||||
1304 | switch (type) { | - | ||||||||||||||||||
1305 | - | |||||||||||||||||||
1306 | case never executed: MSecSection:case MSecSection: never executed: returncase MSecSection: never executed: 999;return 999; never executed: return 999; | 0 | ||||||||||||||||||
1307 | case never executed: SecondSection:case SecondSection: never executed: returncase SecondSection: never executed: 59 * 1000;return 59 * 1000; never executed: return 59 * 1000; | 0 | ||||||||||||||||||
1308 | case executed 11 times by 1 test: MinuteSection:case MinuteSection: Executed by:
executed 11 times by 1 test: returncase MinuteSection: Executed by:
executed 11 times by 1 test: 59 * 60 * 1000;return 59 * 60 * 1000; Executed by:
executed 11 times by 1 test: return 59 * 60 * 1000; Executed by:
| 11 | ||||||||||||||||||
1309 | case executed 9 times by 1 test: Hour24Section:case Hour24Section: Executed by:
executed 9 times by 1 test: casecase Hour24Section: Executed by:
never executed: Hour12Section:case Hour12Section: never executed: returncase Hour12Section: executed 9 times by 1 test: 59 * 60 * 60 * 1000;return 59 * 60 * 60 * 1000; Executed by:
executed 9 times by 1 test: return 59 * 60 * 60 * 1000; Executed by:
| 0-9 | ||||||||||||||||||
1310 | - | |||||||||||||||||||
1311 | - | |||||||||||||||||||
1312 | case never executed: DayOfWeekSectionShort:case DayOfWeekSectionShort: never executed: case DayOfWeekSectionShort: | 0 | ||||||||||||||||||
1313 | case never executed: DayOfWeekSectionLong:case DayOfWeekSectionLong: never executed: returncase DayOfWeekSectionLong: never executed: 7;return 7; never executed: return 7; | 0 | ||||||||||||||||||
1314 | case never executed: DaySection:case DaySection: never executed: returncase DaySection: never executed: 30;return 30; never executed: return 30; | 0 | ||||||||||||||||||
1315 | case never executed: MonthSection:case MonthSection: never executed: returncase MonthSection: never executed: 365 - 31;return 365 - 31; never executed: return 365 - 31; | 0 | ||||||||||||||||||
1316 | case executed 29 times by 1 test: YearSection:case YearSection: Executed by:
executed 29 times by 1 test: returncase YearSection: Executed by:
executed 29 times by 1 test: 9999 * 365;return 9999 * 365; Executed by:
executed 29 times by 1 test: return 9999 * 365; Executed by:
| 29 | ||||||||||||||||||
1317 | case executed 3 times by 1 test: YearSection2Digits:case YearSection2Digits: Executed by:
executed 3 times by 1 test: returncase YearSection2Digits: Executed by:
executed 3 times by 1 test: 100 * 365;return 100 * 365; Executed by:
executed 3 times by 1 test: return 100 * 365; Executed by:
| 3 | ||||||||||||||||||
1318 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
1319 | QMessageLogger(__FILE__, 1478, __PRETTY_FUNCTION__).warning("QDateTimeParser::maxChange() Internal error (%s)", | - | ||||||||||||||||||
1320 | QString(name()).toLocal8Bit().constData()); | - | ||||||||||||||||||
1321 | } never executed: end of block | 0 | ||||||||||||||||||
1322 | - | |||||||||||||||||||
1323 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
1324 | } | - | ||||||||||||||||||
1325 | - | |||||||||||||||||||
1326 | QDateTimeParser::FieldInfo QDateTimeParser::fieldInfo(int index) const | - | ||||||||||||||||||
1327 | { | - | ||||||||||||||||||
1328 | FieldInfo ret = 0; | - | ||||||||||||||||||
1329 | const SectionNode &sn = sectionNode(index); | - | ||||||||||||||||||
1330 | switch (sn.type) { | - | ||||||||||||||||||
1331 | case executed 221 times by 2 tests: MSecSection:case MSecSection: Executed by:
executed 221 times by 2 tests: case MSecSection: Executed by:
| 221 | ||||||||||||||||||
1332 | ret |= Fraction; | - | ||||||||||||||||||
1333 | - | |||||||||||||||||||
1334 | case executed 1712 times by 4 tests: SecondSection:case SecondSection: Executed by:
executed 1712 times by 4 tests: case SecondSection: Executed by:
code before this statement executed 221 times by 2 tests: case SecondSection: Executed by:
| 221-1712 | ||||||||||||||||||
1335 | case executed 1922 times by 8 tests: MinuteSection:case MinuteSection: Executed by:
executed 1922 times by 8 tests: case MinuteSection: Executed by:
| 1922 | ||||||||||||||||||
1336 | case executed 1269 times by 6 tests: Hour24Section:case Hour24Section: Executed by:
executed 1269 times by 6 tests: case Hour24Section: Executed by:
| 1269 | ||||||||||||||||||
1337 | case executed 831 times by 5 tests: Hour12Section:case Hour12Section: Executed by:
executed 831 times by 5 tests: case Hour12Section: Executed by:
| 831 | ||||||||||||||||||
1338 | case executed 1951 times by 6 tests: YearSection:case YearSection: Executed by:
executed 1951 times by 6 tests: case YearSection: Executed by:
| 1951 | ||||||||||||||||||
1339 | case executed 883 times by 7 tests: YearSection2Digits:case YearSection2Digits: Executed by:
executed 883 times by 7 tests: case YearSection2Digits: Executed by:
| 883 | ||||||||||||||||||
1340 | ret |= Numeric; | - | ||||||||||||||||||
1341 | if (sn.type != YearSection
| 1951-6838 | ||||||||||||||||||
1342 | ret |= AllowPartial; | - | ||||||||||||||||||
1343 | } executed 6838 times by 10 tests: end of block Executed by:
| 6838 | ||||||||||||||||||
1344 | if (sn.count != 1
| 318-8471 | ||||||||||||||||||
1345 | ret |= FixedWidth; | - | ||||||||||||||||||
1346 | } executed 8471 times by 11 tests: end of block Executed by:
| 8471 | ||||||||||||||||||
1347 | break; executed 8789 times by 11 tests: break; Executed by:
| 8789 | ||||||||||||||||||
1348 | case executed 1780 times by 7 tests: MonthSection:case MonthSection: Executed by:
executed 1780 times by 7 tests: case MonthSection: Executed by:
| 1780 | ||||||||||||||||||
1349 | case executed 2734 times by 10 tests: DaySection:case DaySection: Executed by:
executed 2734 times by 10 tests: case DaySection: Executed by:
| 2734 | ||||||||||||||||||
1350 | switch (sn.count) { | - | ||||||||||||||||||
1351 | case executed 3502 times by 7 tests: 2:case 2: Executed by:
executed 3502 times by 7 tests: case 2: Executed by:
| 3502 | ||||||||||||||||||
1352 | ret |= FixedWidth; | - | ||||||||||||||||||
1353 | - | |||||||||||||||||||
1354 | case executed 992 times by 7 tests: 1:case 1: Executed by:
executed 992 times by 7 tests: case 1: Executed by:
code before this statement executed 3502 times by 7 tests: case 1: Executed by:
| 992-3502 | ||||||||||||||||||
1355 | ret |= (Numeric|AllowPartial); | - | ||||||||||||||||||
1356 | break; executed 4494 times by 10 tests: break; Executed by:
| 4494 | ||||||||||||||||||
1357 | } | - | ||||||||||||||||||
1358 | break; executed 4514 times by 10 tests: break; Executed by:
| 4514 | ||||||||||||||||||
1359 | case never executed: DayOfWeekSectionShort:case DayOfWeekSectionShort: never executed: case DayOfWeekSectionShort: | 0 | ||||||||||||||||||
1360 | case never executed: DayOfWeekSectionLong:case DayOfWeekSectionLong: never executed: case DayOfWeekSectionLong: | 0 | ||||||||||||||||||
1361 | if (sn.count == 3
| 0 | ||||||||||||||||||
1362 | ret |= FixedWidth; never executed: ret |= FixedWidth; | 0 | ||||||||||||||||||
1363 | break; never executed: break; | 0 | ||||||||||||||||||
1364 | case never executed: AmPmSection:case AmPmSection: never executed: case AmPmSection: | 0 | ||||||||||||||||||
1365 | ret |= FixedWidth; | - | ||||||||||||||||||
1366 | break; never executed: break; | 0 | ||||||||||||||||||
1367 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
1368 | QMessageLogger(__FILE__, 1527, __PRETTY_FUNCTION__).warning("QDateTimeParser::fieldInfo Internal error 2 (%d %s %d)", | - | ||||||||||||||||||
1369 | index, QString(sn.name()).toLocal8Bit().constData(), sn.count); | - | ||||||||||||||||||
1370 | break; never executed: break; | 0 | ||||||||||||||||||
1371 | } | - | ||||||||||||||||||
1372 | return executed 13303 times by 11 tests: ret;return ret; Executed by:
executed 13303 times by 11 tests: return ret; Executed by:
| 13303 | ||||||||||||||||||
1373 | } | - | ||||||||||||||||||
1374 | - | |||||||||||||||||||
1375 | QString QDateTimeParser::SectionNode::format() const | - | ||||||||||||||||||
1376 | { | - | ||||||||||||||||||
1377 | QChar fillChar; | - | ||||||||||||||||||
1378 | switch (type) { | - | ||||||||||||||||||
1379 | case never executed: AmPmSection:case AmPmSection: never executed: returncase AmPmSection: never executed: count == 1 ? QLatin1String("AP") : QLatin1String("ap");return count == 1 ? QLatin1String("AP") : QLatin1String("ap"); never executed: return count == 1 ? QLatin1String("AP") : QLatin1String("ap"); | 0 | ||||||||||||||||||
1380 | case never executed: MSecSection:case MSecSection: never executed: fillChar = QLatin1Char('z'); break;case MSecSection: never executed: break; | 0 | ||||||||||||||||||
1381 | case never executed: SecondSection:case SecondSection: never executed: fillChar = QLatin1Char('s'); break;case SecondSection: never executed: break; | 0 | ||||||||||||||||||
1382 | case never executed: MinuteSection:case MinuteSection: never executed: fillChar = QLatin1Char('m'); break;case MinuteSection: never executed: break; | 0 | ||||||||||||||||||
1383 | case never executed: Hour24Section:case Hour24Section: never executed: fillChar = QLatin1Char('H'); break;case Hour24Section: never executed: break; | 0 | ||||||||||||||||||
1384 | case never executed: Hour12Section:case Hour12Section: never executed: fillChar = QLatin1Char('h'); break;case Hour12Section: never executed: break; | 0 | ||||||||||||||||||
1385 | case never executed: DayOfWeekSectionShort:case DayOfWeekSectionShort: never executed: case DayOfWeekSectionShort: | 0 | ||||||||||||||||||
1386 | case never executed: DayOfWeekSectionLong:case DayOfWeekSectionLong: never executed: case DayOfWeekSectionLong: | 0 | ||||||||||||||||||
1387 | case executed 2 times by 1 test: DaySection:case DaySection: Executed by:
executed 2 times by 1 test: fillChar = QLatin1Char('d'); break;case DaySection: Executed by:
executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||
1388 | case executed 2 times by 1 test: MonthSection:case MonthSection: Executed by:
executed 2 times by 1 test: fillChar = QLatin1Char('M'); break;case MonthSection: Executed by:
executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||
1389 | case never executed: YearSection2Digits:case YearSection2Digits: never executed: case YearSection2Digits: | 0 | ||||||||||||||||||
1390 | case executed 2 times by 1 test: YearSection:case YearSection: Executed by:
executed 2 times by 1 test: fillChar = QLatin1Char('y'); break;case YearSection: Executed by:
executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||
1391 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
1392 | QMessageLogger(__FILE__, 1551, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionFormat Internal error (%s)", | - | ||||||||||||||||||
1393 | QString(name(type)).toLocal8Bit().constData()); | - | ||||||||||||||||||
1394 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
1395 | } | - | ||||||||||||||||||
1396 | if (fillChar.isNull()
| 0-6 | ||||||||||||||||||
1397 | QMessageLogger(__FILE__, 1556, __PRETTY_FUNCTION__).warning("QDateTimeParser::sectionFormat Internal error 2"); | - | ||||||||||||||||||
1398 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
1399 | } | - | ||||||||||||||||||
1400 | return executed 6 times by 1 test: QString(count, fillChar);return QString(count, fillChar); Executed by:
executed 6 times by 1 test: return QString(count, fillChar); Executed by:
| 6 | ||||||||||||||||||
1401 | } | - | ||||||||||||||||||
1402 | bool QDateTimeParser::potentialValue(const QStringRef &str, int min, int max, int index, | - | ||||||||||||||||||
1403 | const QDateTime ¤tValue, int insert) const | - | ||||||||||||||||||
1404 | { | - | ||||||||||||||||||
1405 | if (str.isEmpty()
| 3-1610 | ||||||||||||||||||
1406 | return executed 3 times by 1 test: true;return true; Executed by:
executed 3 times by 1 test: return true; Executed by:
| 3 | ||||||||||||||||||
1407 | } | - | ||||||||||||||||||
1408 | const int size = sectionMaxSize(index); | - | ||||||||||||||||||
1409 | int val = (int)locale().toUInt(str); | - | ||||||||||||||||||
1410 | const SectionNode &sn = sectionNode(index); | - | ||||||||||||||||||
1411 | if (sn.type == YearSection2Digits
| 20-1590 | ||||||||||||||||||
1412 | const int year = currentValue.date().year(); | - | ||||||||||||||||||
1413 | val += year - (year % 100); | - | ||||||||||||||||||
1414 | } executed 20 times by 2 tests: end of block Executed by:
| 20 | ||||||||||||||||||
1415 | if (val >= min
| 201-1409 | ||||||||||||||||||
1416 | return executed 495 times by 4 tests: true;return true; Executed by:
executed 495 times by 4 tests: return true; Executed by:
| 495 | ||||||||||||||||||
1417 | } else if (val > max
| 410-705 | ||||||||||||||||||
1418 | return executed 410 times by 1 test: false;return false; Executed by:
executed 410 times by 1 test: return false; Executed by:
| 410 | ||||||||||||||||||
1419 | } else if (str.size() == size
| 0-590 | ||||||||||||||||||
1420 | return executed 115 times by 1 test: false;return false; Executed by:
executed 115 times by 1 test: return false; Executed by:
| 115 | ||||||||||||||||||
1421 | } | - | ||||||||||||||||||
1422 | - | |||||||||||||||||||
1423 | const int len = size - str.size(); | - | ||||||||||||||||||
1424 | for (int i=0; i<len
| 45-590 | ||||||||||||||||||
1425 | for (int j=0; j<10
| 45-1061 | ||||||||||||||||||
1426 | if (potentialValue(str + QLatin1Char('0' + j), min, max, index, currentValue, insert)
| 519-542 | ||||||||||||||||||
1427 | return executed 542 times by 4 tests: true;return true; Executed by:
executed 542 times by 4 tests: return true; Executed by:
| 542 | ||||||||||||||||||
1428 | } else if (insert >= 0
| 9-510 | ||||||||||||||||||
1429 | const QString tmp = str.left(insert) + QLatin1Char('0' + j) + str.mid(insert); | - | ||||||||||||||||||
1430 | if (potentialValue(tmp, min, max, index, currentValue, insert)
| 3-6 | ||||||||||||||||||
1431 | return executed 3 times by 1 test: true;return true; Executed by:
executed 3 times by 1 test: return true; Executed by:
| 3 | ||||||||||||||||||
1432 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||
1433 | } executed 516 times by 1 test: end of block Executed by:
| 516 | ||||||||||||||||||
1434 | } executed 45 times by 1 test: end of block Executed by:
| 45 | ||||||||||||||||||
1435 | - | |||||||||||||||||||
1436 | return executed 45 times by 1 test: false;return false; Executed by:
executed 45 times by 1 test: return false; Executed by:
| 45 | ||||||||||||||||||
1437 | } | - | ||||||||||||||||||
1438 | - | |||||||||||||||||||
1439 | bool QDateTimeParser::skipToNextSection(int index, const QDateTime ¤t, const QStringRef &text) const | - | ||||||||||||||||||
1440 | { | - | ||||||||||||||||||
1441 | ((!(current >= getMinimum() && current <= getMaximum())) ? qt_assert("current >= getMinimum() && current <= getMaximum()",__FILE__,1609) : qt_noop()); | - | ||||||||||||||||||
1442 | - | |||||||||||||||||||
1443 | const SectionNode &node = sectionNode(index); | - | ||||||||||||||||||
1444 | ((!(text.size() < sectionMaxSize(index))) ? qt_assert("text.size() < sectionMaxSize(index)",__FILE__,1612) : qt_noop()); | - | ||||||||||||||||||
1445 | - | |||||||||||||||||||
1446 | const QDateTime maximum = getMaximum(); | - | ||||||||||||||||||
1447 | const QDateTime minimum = getMinimum(); | - | ||||||||||||||||||
1448 | QDateTime tmp = current; | - | ||||||||||||||||||
1449 | int min = absoluteMin(index); | - | ||||||||||||||||||
1450 | setDigit(tmp, index, min); | - | ||||||||||||||||||
1451 | if (tmp < minimum
| 17-474 | ||||||||||||||||||
1452 | min = getDigit(minimum, index); | - | ||||||||||||||||||
1453 | } executed 17 times by 1 test: end of block Executed by:
| 17 | ||||||||||||||||||
1454 | - | |||||||||||||||||||
1455 | int max = absoluteMax(index, current); | - | ||||||||||||||||||
1456 | setDigit(tmp, index, max); | - | ||||||||||||||||||
1457 | if (tmp > maximum
| 33-458 | ||||||||||||||||||
1458 | max = getDigit(maximum, index); | - | ||||||||||||||||||
1459 | } executed 33 times by 2 tests: end of block Executed by:
| 33 | ||||||||||||||||||
1460 | int pos = cursorPosition() - node.pos; | - | ||||||||||||||||||
1461 | if (pos < 0
| 7-479 | ||||||||||||||||||
1462 | pos = -1; executed 484 times by 4 tests: pos = -1; Executed by:
| 484 | ||||||||||||||||||
1463 | - | |||||||||||||||||||
1464 | const bool potential = potentialValue(text, min, max, index, current, pos); | - | ||||||||||||||||||
1465 | return executed 491 times by 4 tests: !potential;return !potential; Executed by:
executed 491 times by 4 tests: return !potential; Executed by:
| 491 | ||||||||||||||||||
1466 | - | |||||||||||||||||||
1467 | - | |||||||||||||||||||
1468 | - | |||||||||||||||||||
1469 | - | |||||||||||||||||||
1470 | - | |||||||||||||||||||
1471 | - | |||||||||||||||||||
1472 | } | - | ||||||||||||||||||
1473 | - | |||||||||||||||||||
1474 | - | |||||||||||||||||||
1475 | - | |||||||||||||||||||
1476 | - | |||||||||||||||||||
1477 | - | |||||||||||||||||||
1478 | - | |||||||||||||||||||
1479 | QString QDateTimeParser::SectionNode::name(QDateTimeParser::Section s) | - | ||||||||||||||||||
1480 | { | - | ||||||||||||||||||
1481 | switch (s) { | - | ||||||||||||||||||
1482 | case never executed: QDateTimeParser::AmPmSection:case QDateTimeParser::AmPmSection: never executed: returncase QDateTimeParser::AmPmSection: never executed: QLatin1String("AmPmSection");return QLatin1String("AmPmSection"); never executed: return QLatin1String("AmPmSection"); | 0 | ||||||||||||||||||
1483 | case never executed: QDateTimeParser::DaySection:case QDateTimeParser::DaySection: never executed: returncase QDateTimeParser::DaySection: never executed: QLatin1String("DaySection");return QLatin1String("DaySection"); never executed: return QLatin1String("DaySection"); | 0 | ||||||||||||||||||
1484 | case never executed: QDateTimeParser::DayOfWeekSectionShort:case QDateTimeParser::DayOfWeekSectionShort: never executed: returncase QDateTimeParser::DayOfWeekSectionShort: never executed: QLatin1String("DayOfWeekSectionShort");return QLatin1String("DayOfWeekSectionShort"); never executed: return QLatin1String("DayOfWeekSectionShort"); | 0 | ||||||||||||||||||
1485 | case never executed: QDateTimeParser::DayOfWeekSectionLong:case QDateTimeParser::DayOfWeekSectionLong: never executed: returncase QDateTimeParser::DayOfWeekSectionLong: never executed: QLatin1String("DayOfWeekSectionLong");return QLatin1String("DayOfWeekSectionLong"); never executed: return QLatin1String("DayOfWeekSectionLong"); | 0 | ||||||||||||||||||
1486 | case never executed: QDateTimeParser::Hour24Section:case QDateTimeParser::Hour24Section: never executed: returncase QDateTimeParser::Hour24Section: never executed: QLatin1String("Hour24Section");return QLatin1String("Hour24Section"); never executed: return QLatin1String("Hour24Section"); | 0 | ||||||||||||||||||
1487 | case never executed: QDateTimeParser::Hour12Section:case QDateTimeParser::Hour12Section: never executed: returncase QDateTimeParser::Hour12Section: never executed: QLatin1String("Hour12Section");return QLatin1String("Hour12Section"); never executed: return QLatin1String("Hour12Section"); | 0 | ||||||||||||||||||
1488 | case never executed: QDateTimeParser::MSecSection:case QDateTimeParser::MSecSection: never executed: returncase QDateTimeParser::MSecSection: never executed: QLatin1String("MSecSection");return QLatin1String("MSecSection"); never executed: return QLatin1String("MSecSection"); | 0 | ||||||||||||||||||
1489 | case never executed: QDateTimeParser::MinuteSection:case QDateTimeParser::MinuteSection: never executed: returncase QDateTimeParser::MinuteSection: never executed: QLatin1String("MinuteSection");return QLatin1String("MinuteSection"); never executed: return QLatin1String("MinuteSection"); | 0 | ||||||||||||||||||
1490 | case never executed: QDateTimeParser::MonthSection:case QDateTimeParser::MonthSection: never executed: returncase QDateTimeParser::MonthSection: never executed: QLatin1String("MonthSection");return QLatin1String("MonthSection"); never executed: return QLatin1String("MonthSection"); | 0 | ||||||||||||||||||
1491 | case never executed: QDateTimeParser::SecondSection:case QDateTimeParser::SecondSection: never executed: returncase QDateTimeParser::SecondSection: never executed: QLatin1String("SecondSection");return QLatin1String("SecondSection"); never executed: return QLatin1String("SecondSection"); | 0 | ||||||||||||||||||
1492 | case never executed: QDateTimeParser::YearSection:case QDateTimeParser::YearSection: never executed: returncase QDateTimeParser::YearSection: never executed: QLatin1String("YearSection");return QLatin1String("YearSection"); never executed: return QLatin1String("YearSection"); | 0 | ||||||||||||||||||
1493 | case never executed: QDateTimeParser::YearSection2Digits:case QDateTimeParser::YearSection2Digits: never executed: returncase QDateTimeParser::YearSection2Digits: never executed: QLatin1String("YearSection2Digits");return QLatin1String("YearSection2Digits"); never executed: return QLatin1String("YearSection2Digits"); | 0 | ||||||||||||||||||
1494 | case never executed: QDateTimeParser::NoSection:case QDateTimeParser::NoSection: never executed: returncase QDateTimeParser::NoSection: never executed: QLatin1String("NoSection");return QLatin1String("NoSection"); never executed: return QLatin1String("NoSection"); | 0 | ||||||||||||||||||
1495 | case never executed: QDateTimeParser::FirstSection:case QDateTimeParser::FirstSection: never executed: returncase QDateTimeParser::FirstSection: never executed: QLatin1String("FirstSection");return QLatin1String("FirstSection"); never executed: return QLatin1String("FirstSection"); | 0 | ||||||||||||||||||
1496 | case never executed: QDateTimeParser::LastSection:case QDateTimeParser::LastSection: never executed: returncase QDateTimeParser::LastSection: never executed: QLatin1String("LastSection");return QLatin1String("LastSection"); never executed: return QLatin1String("LastSection"); | 0 | ||||||||||||||||||
1497 | default never executed: :default: never executed: returndefault: never executed: QLatin1String("Unknown section ") + QString::number(int(s));return QLatin1String("Unknown section ") + QString::number(int(s)); never executed: return QLatin1String("Unknown section ") + QString::number(int(s)); | 0 | ||||||||||||||||||
1498 | } | - | ||||||||||||||||||
1499 | } | - | ||||||||||||||||||
1500 | - | |||||||||||||||||||
1501 | - | |||||||||||||||||||
1502 | - | |||||||||||||||||||
1503 | - | |||||||||||||||||||
1504 | - | |||||||||||||||||||
1505 | - | |||||||||||||||||||
1506 | QString QDateTimeParser::stateName(State s) const | - | ||||||||||||||||||
1507 | { | - | ||||||||||||||||||
1508 | switch (s) { | - | ||||||||||||||||||
1509 | case never executed: Invalid:case Invalid: never executed: returncase Invalid: never executed: QLatin1String("Invalid");return QLatin1String("Invalid"); never executed: return QLatin1String("Invalid"); | 0 | ||||||||||||||||||
1510 | case never executed: Intermediate:case Intermediate: never executed: returncase Intermediate: never executed: QLatin1String("Intermediate");return QLatin1String("Intermediate"); never executed: return QLatin1String("Intermediate"); | 0 | ||||||||||||||||||
1511 | case never executed: Acceptable:case Acceptable: never executed: returncase Acceptable: never executed: QLatin1String("Acceptable");return QLatin1String("Acceptable"); never executed: return QLatin1String("Acceptable"); | 0 | ||||||||||||||||||
1512 | default never executed: :default: never executed: returndefault: never executed: QLatin1String("Unknown state ") + QString::number(s);return QLatin1String("Unknown state ") + QString::number(s); never executed: return QLatin1String("Unknown state ") + QString::number(s); | 0 | ||||||||||||||||||
1513 | } | - | ||||||||||||||||||
1514 | } | - | ||||||||||||||||||
1515 | - | |||||||||||||||||||
1516 | - | |||||||||||||||||||
1517 | bool QDateTimeParser::fromString(const QString &t, QDate *date, QTime *time) const | - | ||||||||||||||||||
1518 | { | - | ||||||||||||||||||
1519 | QDateTime val(QDate(1900, 1, 1), QTime(0, 0, 0, 0)); | - | ||||||||||||||||||
1520 | QString text = t; | - | ||||||||||||||||||
1521 | int copy = -1; | - | ||||||||||||||||||
1522 | const StateNode tmp = parse(text, copy, val, false); | - | ||||||||||||||||||
1523 | if (tmp.state != Acceptable
| 5-465 | ||||||||||||||||||
1524 | return executed 148 times by 4 tests: false;return false; Executed by:
executed 148 times by 4 tests: return false; Executed by:
| 148 | ||||||||||||||||||
1525 | } | - | ||||||||||||||||||
1526 | if (time
| 36-424 | ||||||||||||||||||
1527 | const QTime t = tmp.value.time(); | - | ||||||||||||||||||
1528 | if (!t.isValid()
| 0-424 | ||||||||||||||||||
1529 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||
1530 | } | - | ||||||||||||||||||
1531 | *time = t; | - | ||||||||||||||||||
1532 | } executed 424 times by 7 tests: end of block Executed by:
| 424 | ||||||||||||||||||
1533 | - | |||||||||||||||||||
1534 | if (date
| 6-454 | ||||||||||||||||||
1535 | const QDate d = tmp.value.date(); | - | ||||||||||||||||||
1536 | if (!d.isValid()
| 0-454 | ||||||||||||||||||
1537 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||
1538 | } | - | ||||||||||||||||||
1539 | *date = d; | - | ||||||||||||||||||
1540 | } executed 454 times by 7 tests: end of block Executed by:
| 454 | ||||||||||||||||||
1541 | return executed 460 times by 8 tests: true;return true; Executed by:
executed 460 times by 8 tests: return true; Executed by:
| 460 | ||||||||||||||||||
1542 | } | - | ||||||||||||||||||
1543 | - | |||||||||||||||||||
1544 | - | |||||||||||||||||||
1545 | QDateTime QDateTimeParser::getMinimum() const | - | ||||||||||||||||||
1546 | { | - | ||||||||||||||||||
1547 | return executed 1121 times by 8 tests: QDateTime(QDate(100, 1, 1), QTime(0, 0, 0, 0), spec);return QDateTime(QDate(100, 1, 1), QTime(0, 0, 0, 0), spec); Executed by:
executed 1121 times by 8 tests: return QDateTime(QDate(100, 1, 1), QTime(0, 0, 0, 0), spec); Executed by:
| 1121 | ||||||||||||||||||
1548 | } | - | ||||||||||||||||||
1549 | - | |||||||||||||||||||
1550 | QDateTime QDateTimeParser::getMaximum() const | - | ||||||||||||||||||
1551 | { | - | ||||||||||||||||||
1552 | return executed 1079 times by 8 tests: QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999), spec);return QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999), spec); Executed by:
executed 1079 times by 8 tests: return QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999), spec); Executed by:
| 1079 | ||||||||||||||||||
1553 | } | - | ||||||||||||||||||
1554 | - | |||||||||||||||||||
1555 | QString QDateTimeParser::getAmPmText(AmPm ap, Case cs) const | - | ||||||||||||||||||
1556 | { | - | ||||||||||||||||||
1557 | const QLocale loc = locale(); | - | ||||||||||||||||||
1558 | QString raw = ap == AmText
| 60 | ||||||||||||||||||
1559 | return executed 120 times by 2 tests: cs == UpperCase ? raw.toUpper() : raw.toLower();return cs == UpperCase ? raw.toUpper() : raw.toLower(); Executed by:
executed 120 times by 2 tests: return cs == UpperCase ? raw.toUpper() : raw.toLower(); Executed by:
| 120 | ||||||||||||||||||
1560 | } | - | ||||||||||||||||||
1561 | - | |||||||||||||||||||
1562 | - | |||||||||||||||||||
1563 | - | |||||||||||||||||||
1564 | - | |||||||||||||||||||
1565 | - | |||||||||||||||||||
1566 | - | |||||||||||||||||||
1567 | - | |||||||||||||||||||
1568 | bool operator==(const QDateTimeParser::SectionNode &s1, const QDateTimeParser::SectionNode &s2) | - | ||||||||||||||||||
1569 | { | - | ||||||||||||||||||
1570 | return never executed: (s1.type == s2.type) && (s1.pos == s2.pos) && (s1.count == s2.count);return (s1.type == s2.type) && (s1.pos == s2.pos) && (s1.count == s2.count); never executed: return (s1.type == s2.type) && (s1.pos == s2.pos) && (s1.count == s2.count); | 0 | ||||||||||||||||||
1571 | } | - | ||||||||||||||||||
1572 | - | |||||||||||||||||||
1573 | - | |||||||||||||||||||
1574 | - | |||||||||||||||||||
1575 | - | |||||||||||||||||||
Switch to Source code | Preprocessed file |