Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cjs_publicmethods_unittest.cpp
Go to the documentation of this file.
1
// Copyright 2016 The PDFium Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#
include
"fxjs/cjs_publicmethods.h"
6
7
#
include
<
iterator
>
8
9
#
include
"testing/gtest/include/gtest/gtest.h"
10
11
TEST
(CJS_PublicMethods,
IsNumber
) {
12
// TODO(weili): Check whether results from case 0, 1, 10, 15 are intended.
13
struct
{
14
const
wchar_t
* input;
15
bool
expected;
16
} test_data[] = {
17
// Empty string.
18
{L"",
true
},
19
// Only whitespaces.
20
{L" ",
true
},
21
// Content with invalid characters.
22
{L"xyz00",
false
},
23
{L"1%",
false
},
24
// Hex string.
25
{L"0x234",
false
},
26
// Signed numbers.
27
{L"+123",
true
},
28
{L"-98765",
true
},
29
// Numbers with whitespaces.
30
{L" 345 ",
true
},
31
// Float numbers.
32
{L"-1e5",
false
},
33
{L"-2e",
false
},
34
{L"e-5",
true
},
35
{L"0.023",
true
},
36
{L".356089",
true
},
37
{L"1e-9",
true
},
38
{L"-1.23e+23",
true
},
39
// Numbers with commas.
40
{L"1,000,000",
false
},
41
{L"560,024",
true
},
42
// Regular numbers.
43
{L"0",
true
},
44
{L"0123",
true
},
45
{L"9876123",
true
},
46
};
47
for
(size_t i = 0; i <
std
::size(test_data); ++i) {
48
EXPECT_EQ(test_data[i].expected,
49
CJS_PublicMethods
::
IsNumber
(
test_data[i].input
)
)
50
<<
"for case "
<< i;
51
}
52
}
TEST
TEST(CJS_PublicMethods, IsNumber)
Definition
cjs_publicmethods_unittest.cpp:11
CJS_PublicMethods::IsNumber
static bool IsNumber(const WideString &str)
Definition
cjs_publicmethods.cpp:269
std
Definition
qfloat16.h:492
qtwebengine
src
3rdparty
chromium
third_party
pdfium
fxjs
cjs_publicmethods_unittest.cpp
Generated on Sat Sep 21 2024 00:59:05 for Qt by
1.12.0